aboutsummaryrefslogtreecommitdiffstats
path: root/protocols/msn/msn.c
diff options
context:
space:
mode:
Diffstat (limited to 'protocols/msn/msn.c')
-rw-r--r--protocols/msn/msn.c76
1 files changed, 58 insertions, 18 deletions
diff --git a/protocols/msn/msn.c b/protocols/msn/msn.c
index 60d58532..ed0881d1 100644
--- a/protocols/msn/msn.c
+++ b/protocols/msn/msn.c
@@ -1,7 +1,7 @@
/********************************************************************\
* BitlBee -- An IRC to other IM-networks gateway *
* *
- * Copyright 2002-2004 Wilmer van der Gaast and others *
+ * Copyright 2002-2010 Wilmer van der Gaast and others *
\********************************************************************/
/* MSN module - Main file; functions to be called from BitlBee */
@@ -24,6 +24,7 @@
*/
#include "nogaim.h"
+#include "soap.h"
#include "msn.h"
int msn_chat_id;
@@ -34,10 +35,15 @@ static char *set_eval_display_name( set_t *set, char *value );
static void msn_init( account_t *acc )
{
- set_add( &acc->set, "display_name", NULL, set_eval_display_name, acc );
- set_add( &acc->set, "local_display_name", "false", set_eval_bool, acc );
+ set_t *s;
+
+ s = set_add( &acc->set, "display_name", NULL, set_eval_display_name, acc );
+ s->flags |= ACC_SET_NOSAVE | ACC_SET_ONLINE_ONLY;
+
set_add( &acc->set, "mail_notifications", "false", set_eval_bool, acc );
set_add( &acc->set, "switchboard_keepalives", "false", set_eval_bool, acc );
+
+ acc->flags |= ACC_FLAG_AWAY_MESSAGE | ACC_FLAG_STATUS_MESSAGE;
}
static void msn_login( account_t *acc )
@@ -67,6 +73,7 @@ static void msn_login( account_t *acc )
md->ic = ic;
md->away_state = msn_away_state_list;
+ md->domaintree = g_tree_new( msn_domaintree_cmp );
msn_connections = g_slist_append( msn_connections, ic );
}
@@ -102,6 +109,13 @@ static void msn_logout( struct im_connection *ic )
while( md->groupcount > 0 )
g_free( md->grouplist[--md->groupcount] );
g_free( md->grouplist );
+ g_free( md->tokens[0] );
+ g_free( md->tokens[1] );
+ g_free( md->tokens[2] );
+ g_free( md->lock_key );
+
+ g_tree_destroy( md->domaintree );
+ md->domaintree = NULL;
while( md->grpq )
{
@@ -173,6 +187,7 @@ static GList *msn_away_states( struct im_connection *ic )
static void msn_set_away( struct im_connection *ic, char *state, char *message )
{
char buf[1024];
+ char *uux;
struct msn_data *md = ic->proto_data;
if( state == NULL )
@@ -181,12 +196,14 @@ static void msn_set_away( struct im_connection *ic, char *state, char *message )
md->away_state = msn_away_state_list + 1;
g_snprintf( buf, sizeof( buf ), "CHG %d %s\r\n", ++md->trId, md->away_state->code );
- msn_write( ic, buf, strlen( buf ) );
-}
-
-static void msn_set_my_name( struct im_connection *ic, char *info )
-{
- msn_set_display_name( ic, info );
+ if( !msn_write( ic, buf, strlen( buf ) ) )
+ return;
+
+ uux = g_markup_printf_escaped( "<Data><PSM>%s</PSM><CurrentMedia></CurrentMedia>"
+ "</Data>", message ? message : "" );
+ g_snprintf( buf, sizeof( buf ), "UUX %d %zd\r\n%s", ++md->trId, strlen( uux ), uux );
+ if( !msn_write( ic, buf, strlen( buf ) ) )
+ return;
}
static void msn_get_info(struct im_connection *ic, char *who)
@@ -313,10 +330,9 @@ static char *set_eval_display_name( set_t *set, char *value )
{
account_t *acc = set->data;
struct im_connection *ic = acc->ic;
-
- /* Allow any name if we're offline. */
- if( ic == NULL )
- return value;
+ struct msn_data *md = ic->proto_data;
+ char buf[512];
+ char *fn;
if( strlen( value ) > 129 )
{
@@ -324,10 +340,32 @@ static char *set_eval_display_name( set_t *set, char *value )
return NULL;
}
- /* Returning NULL would be better, because the server still has to
- confirm the name change. However, it looks a bit confusing to the
- user. */
- return msn_set_display_name( ic, value ) ? value : NULL;
+ msn_soap_addressbook_set_display_name( ic, value );
+
+ fn = g_malloc( strlen( value ) * 3 + 1 );
+ strcpy( fn, value );
+ http_encode( fn );
+ g_snprintf( buf, sizeof( buf ), "PRP %d MFN %s\r\n",
+ ++md->trId, fn );
+ g_free( fn );
+
+ /* Note: We don't actually know if the server accepted the new name,
+ and won't give proper feedback yet if it doesn't. */
+ return msn_write( ic, buf, strlen( buf ) ) ? value : NULL;
+}
+
+static void msn_buddy_data_add( bee_user_t *bu )
+{
+ struct msn_data *md = bu->ic->proto_data;
+ bu->data = g_new0( struct msn_buddy_data, 1 );
+ g_tree_insert( md->domaintree, bu->handle, bu );
+}
+
+static void msn_buddy_data_free( bee_user_t *bu )
+{
+ struct msn_data *md = bu->ic->proto_data;
+ g_tree_remove( md->domaintree, bu->handle );
+ g_free( bu->data );
}
void msn_initmodule()
@@ -342,7 +380,6 @@ void msn_initmodule()
ret->away_states = msn_away_states;
ret->set_away = msn_set_away;
ret->get_info = msn_get_info;
- ret->set_my_name = msn_set_my_name;
ret->add_buddy = msn_add_buddy;
ret->remove_buddy = msn_remove_buddy;
ret->chat_msg = msn_chat_msg;
@@ -356,6 +393,9 @@ void msn_initmodule()
ret->rem_deny = msn_rem_deny;
ret->send_typing = msn_send_typing;
ret->handle_cmp = g_strcasecmp;
+ ret->buddy_data_add = msn_buddy_data_add;
+ ret->buddy_data_free = msn_buddy_data_free;
+
//ret->transfer_request = msn_ftp_transfer_request;
register_protocol(ret);