[b7d3cc34] | 1 | /********************************************************************\ |
---|
| 2 | * BitlBee -- An IRC to other IM-networks gateway * |
---|
| 3 | * * |
---|
[0e788f5] | 4 | * Copyright 2002-2013 Wilmer van der Gaast and others * |
---|
[b7d3cc34] | 5 | \********************************************************************/ |
---|
| 6 | |
---|
| 7 | /* MSN module - Main file; functions to be called from BitlBee */ |
---|
| 8 | |
---|
| 9 | /* |
---|
| 10 | This program is free software; you can redistribute it and/or modify |
---|
| 11 | it under the terms of the GNU General Public License as published by |
---|
| 12 | the Free Software Foundation; either version 2 of the License, or |
---|
| 13 | (at your option) any later version. |
---|
| 14 | |
---|
| 15 | This program is distributed in the hope that it will be useful, |
---|
| 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 18 | GNU General Public License for more details. |
---|
| 19 | |
---|
| 20 | You should have received a copy of the GNU General Public License with |
---|
| 21 | the Debian GNU/Linux distribution in /usr/share/common-licenses/GPL; |
---|
[6f10697] | 22 | if not, write to the Free Software Foundation, Inc., 51 Franklin St., |
---|
| 23 | Fifth Floor, Boston, MA 02110-1301 USA |
---|
[b7d3cc34] | 24 | */ |
---|
| 25 | |
---|
| 26 | #include "nogaim.h" |
---|
[4452e69] | 27 | #include "soap.h" |
---|
[b7d3cc34] | 28 | #include "msn.h" |
---|
| 29 | |
---|
[c6ca3ee] | 30 | int msn_chat_id; |
---|
| 31 | GSList *msn_connections; |
---|
| 32 | GSList *msn_switchboards; |
---|
| 33 | |
---|
[e3413cc] | 34 | static char *set_eval_display_name( set_t *set, char *value ); |
---|
[911f2eb] | 35 | |
---|
[0da65d5] | 36 | static void msn_init( account_t *acc ) |
---|
[911f2eb] | 37 | { |
---|
[4452e69] | 38 | set_t *s; |
---|
| 39 | |
---|
| 40 | s = set_add( &acc->set, "display_name", NULL, set_eval_display_name, acc ); |
---|
[bb5ce568] | 41 | s->flags |= SET_NOSAVE | ACC_SET_ONLINE_ONLY; |
---|
[4452e69] | 42 | |
---|
[bc7a0d4] | 43 | s = set_add( &acc->set, "server", MSN_NS_HOST, set_eval_account, acc ); |
---|
| 44 | s->flags |= SET_NOSAVE | ACC_SET_OFFLINE_ONLY; |
---|
| 45 | |
---|
| 46 | s = set_add( &acc->set, "port", MSN_NS_PORT, set_eval_int, acc ); |
---|
| 47 | s->flags |= ACC_SET_OFFLINE_ONLY; |
---|
| 48 | |
---|
[e3413cc] | 49 | set_add( &acc->set, "mail_notifications", "false", set_eval_bool, acc ); |
---|
[efbc154] | 50 | set_add( &acc->set, "switchboard_keepalives", "false", set_eval_bool, acc ); |
---|
[12767e3] | 51 | |
---|
[06eef80] | 52 | acc->flags |= ACC_FLAG_AWAY_MESSAGE | ACC_FLAG_STATUS_MESSAGE | |
---|
| 53 | ACC_FLAG_HANDLE_DOMAINS; |
---|
[911f2eb] | 54 | } |
---|
| 55 | |
---|
[0a3c243] | 56 | static void msn_login( account_t *acc ) |
---|
[b7d3cc34] | 57 | { |
---|
[84b045d] | 58 | struct im_connection *ic = imcb_new( acc ); |
---|
[b7d3cc34] | 59 | struct msn_data *md = g_new0( struct msn_data, 1 ); |
---|
| 60 | |
---|
[0da65d5] | 61 | ic->proto_data = md; |
---|
[e132b60] | 62 | ic->flags |= OPT_PONGS | OPT_PONGED; |
---|
[b7d3cc34] | 63 | |
---|
[0a3c243] | 64 | if( strchr( acc->user, '@' ) == NULL ) |
---|
[b7d3cc34] | 65 | { |
---|
[84b045d] | 66 | imcb_error( ic, "Invalid account name" ); |
---|
[c2fb3809] | 67 | imc_logout( ic, FALSE ); |
---|
[b7d3cc34] | 68 | return; |
---|
| 69 | } |
---|
| 70 | |
---|
[0da65d5] | 71 | md->ic = ic; |
---|
[2a29eac] | 72 | md->away_state = msn_away_state_list; |
---|
[ca7de3a] | 73 | md->domaintree = g_tree_new( msn_domaintree_cmp ); |
---|
[27053b5] | 74 | md->ns->fd = -1; |
---|
[2a29eac] | 75 | |
---|
[bae0617] | 76 | msn_connections = g_slist_prepend( msn_connections, ic ); |
---|
| 77 | |
---|
| 78 | imcb_log( ic, "Connecting" ); |
---|
[bc7a0d4] | 79 | msn_ns_connect( ic, md->ns, |
---|
| 80 | set_getstr( &ic->acc->set, "server" ), |
---|
| 81 | set_getint( &ic->acc->set, "port" ) ); |
---|
[b7d3cc34] | 82 | } |
---|
| 83 | |
---|
[0da65d5] | 84 | static void msn_logout( struct im_connection *ic ) |
---|
[b7d3cc34] | 85 | { |
---|
[0da65d5] | 86 | struct msn_data *md = ic->proto_data; |
---|
[b7d3cc34] | 87 | GSList *l; |
---|
[80175a1] | 88 | int i; |
---|
[b7d3cc34] | 89 | |
---|
[5a5c926] | 90 | if( md ) |
---|
[b7d3cc34] | 91 | { |
---|
[17a6ee9] | 92 | /** Disabling MSN ft support for now. |
---|
[a2b99ec] | 93 | while( md->filetransfers ) { |
---|
[1c3008a] | 94 | imcb_file_canceled( md->filetransfers->data, "Closing connection" ); |
---|
[a2b99ec] | 95 | } |
---|
[17a6ee9] | 96 | */ |
---|
[a2b99ec] | 97 | |
---|
[bae0617] | 98 | msn_ns_close( md->ns ); |
---|
[5a5c926] | 99 | |
---|
| 100 | while( md->switchboards ) |
---|
| 101 | msn_sb_destroy( md->switchboards->data ); |
---|
[1053836] | 102 | |
---|
[46dca11] | 103 | msn_msgq_purge( ic, &md->msgq ); |
---|
[4e1be76] | 104 | msn_soapq_flush( ic, FALSE ); |
---|
[5a5c926] | 105 | |
---|
[80175a1] | 106 | for( i = 0; i < sizeof( md->tokens ) / sizeof( md->tokens[0] ); i ++ ) |
---|
| 107 | g_free( md->tokens[i] ); |
---|
[ffb6dea] | 108 | g_free( md->lock_key ); |
---|
[27053b5] | 109 | g_free( md->pp_policy ); |
---|
[f9258ae] | 110 | g_free( md->uuid ); |
---|
[59f5c42a] | 111 | |
---|
[ff27648] | 112 | while( md->groups ) |
---|
| 113 | { |
---|
| 114 | struct msn_group *mg = md->groups->data; |
---|
| 115 | g_free( mg->id ); |
---|
| 116 | g_free( mg->name ); |
---|
| 117 | g_free( mg ); |
---|
| 118 | md->groups = g_slist_remove( md->groups, mg ); |
---|
| 119 | } |
---|
| 120 | |
---|
[76c89dc7] | 121 | g_free( md->profile_rid ); |
---|
| 122 | |
---|
[9e9140b] | 123 | if( md->domaintree ) |
---|
| 124 | g_tree_destroy( md->domaintree ); |
---|
[ca7de3a] | 125 | md->domaintree = NULL; |
---|
| 126 | |
---|
[70ac477] | 127 | while( md->grpq ) |
---|
| 128 | { |
---|
| 129 | struct msn_groupadd *ga = md->grpq->data; |
---|
| 130 | g_free( ga->group ); |
---|
| 131 | g_free( ga->who ); |
---|
| 132 | g_free( ga ); |
---|
| 133 | md->grpq = g_slist_remove( md->grpq, ga ); |
---|
| 134 | } |
---|
| 135 | |
---|
[5a5c926] | 136 | g_free( md ); |
---|
[b7d3cc34] | 137 | } |
---|
| 138 | |
---|
[0da65d5] | 139 | for( l = ic->permit; l; l = l->next ) |
---|
[b7d3cc34] | 140 | g_free( l->data ); |
---|
[0da65d5] | 141 | g_slist_free( ic->permit ); |
---|
[b7d3cc34] | 142 | |
---|
[0da65d5] | 143 | for( l = ic->deny; l; l = l->next ) |
---|
[b7d3cc34] | 144 | g_free( l->data ); |
---|
[0da65d5] | 145 | g_slist_free( ic->deny ); |
---|
[b7d3cc34] | 146 | |
---|
[0da65d5] | 147 | msn_connections = g_slist_remove( msn_connections, ic ); |
---|
[b7d3cc34] | 148 | } |
---|
| 149 | |
---|
[f6c963b] | 150 | static int msn_buddy_msg( struct im_connection *ic, char *who, char *message, int away ) |
---|
[b7d3cc34] | 151 | { |
---|
[208db4b] | 152 | struct bee_user *bu = bee_user_by_handle( ic->bee, ic, who ); |
---|
| 153 | struct msn_buddy_data *bd = bu ? bu->data : NULL; |
---|
[b7d3cc34] | 154 | struct msn_switchboard *sb; |
---|
| 155 | |
---|
[70ac477] | 156 | #ifdef DEBUG |
---|
| 157 | if( strcmp( who, "raw" ) == 0 ) |
---|
| 158 | { |
---|
[64768d4] | 159 | msn_ns_write( ic, -1, "%s\r\n", message ); |
---|
[70ac477] | 160 | } |
---|
| 161 | else |
---|
| 162 | #endif |
---|
[208db4b] | 163 | if( bd && bd->flags & MSN_BUDDY_FED ) |
---|
| 164 | { |
---|
| 165 | msn_ns_sendmessage( ic, bu, message ); |
---|
| 166 | } |
---|
| 167 | else if( ( sb = msn_sb_by_handle( ic, who ) ) ) |
---|
[b7d3cc34] | 168 | { |
---|
| 169 | return( msn_sb_sendmessage( sb, message ) ); |
---|
| 170 | } |
---|
| 171 | else |
---|
| 172 | { |
---|
| 173 | struct msn_message *m; |
---|
| 174 | |
---|
| 175 | /* Create a message. We have to arrange a usable switchboard, and send the message later. */ |
---|
| 176 | m = g_new0( struct msn_message, 1 ); |
---|
| 177 | m->who = g_strdup( who ); |
---|
| 178 | m->text = g_strdup( message ); |
---|
| 179 | |
---|
[a830512] | 180 | return msn_sb_write_msg( ic, m ); |
---|
[b7d3cc34] | 181 | } |
---|
| 182 | |
---|
| 183 | return( 0 ); |
---|
| 184 | } |
---|
| 185 | |
---|
[0da65d5] | 186 | static GList *msn_away_states( struct im_connection *ic ) |
---|
[b7d3cc34] | 187 | { |
---|
[5e202b0] | 188 | static GList *l = NULL; |
---|
[b7d3cc34] | 189 | int i; |
---|
| 190 | |
---|
[5e202b0] | 191 | if( l == NULL ) |
---|
[b051d39] | 192 | for( i = 0; *msn_away_state_list[i].code; i ++ ) |
---|
| 193 | if( *msn_away_state_list[i].name ) |
---|
| 194 | l = g_list_append( l, (void*) msn_away_state_list[i].name ); |
---|
[b7d3cc34] | 195 | |
---|
[5e202b0] | 196 | return l; |
---|
[b7d3cc34] | 197 | } |
---|
| 198 | |
---|
[0da65d5] | 199 | static void msn_set_away( struct im_connection *ic, char *state, char *message ) |
---|
[b7d3cc34] | 200 | { |
---|
[12767e3] | 201 | char *uux; |
---|
[0da65d5] | 202 | struct msn_data *md = ic->proto_data; |
---|
[b7d3cc34] | 203 | |
---|
[daae10f] | 204 | if( state == NULL ) |
---|
[b051d39] | 205 | md->away_state = msn_away_state_list; |
---|
[daae10f] | 206 | else if( ( md->away_state = msn_away_state_by_name( state ) ) == NULL ) |
---|
| 207 | md->away_state = msn_away_state_list + 1; |
---|
[b7d3cc34] | 208 | |
---|
[080c43a] | 209 | if( !msn_ns_write( ic, -1, "CHG %d %s %d:%02d\r\n", ++md->trId, md->away_state->code, MSN_CAP1, MSN_CAP2 ) ) |
---|
[12767e3] | 210 | return; |
---|
| 211 | |
---|
[080c43a] | 212 | uux = g_markup_printf_escaped( "<EndpointData><Capabilities>%d:%02d" |
---|
| 213 | "</Capabilities></EndpointData>", |
---|
| 214 | MSN_CAP1, MSN_CAP2 ); |
---|
| 215 | msn_ns_write( ic, -1, "UUX %d %zd\r\n%s", ++md->trId, strlen( uux ), uux ); |
---|
| 216 | g_free( uux ); |
---|
| 217 | |
---|
| 218 | uux = g_markup_printf_escaped( "<PrivateEndpointData><EpName>%s</EpName>" |
---|
| 219 | "<Idle>%s</Idle><ClientType>%d</ClientType>" |
---|
| 220 | "<State>%s</State></PrivateEndpointData>", |
---|
| 221 | md->uuid, |
---|
| 222 | strcmp( md->away_state->code, "IDL" ) ? "false" : "true", |
---|
| 223 | 1, /* ? */ |
---|
| 224 | md->away_state->code ); |
---|
| 225 | msn_ns_write( ic, -1, "UUX %d %zd\r\n%s", ++md->trId, strlen( uux ), uux ); |
---|
| 226 | g_free( uux ); |
---|
| 227 | |
---|
| 228 | uux = g_markup_printf_escaped( "<Data><DDP></DDP><PSM>%s</PSM>" |
---|
| 229 | "<CurrentMedia></CurrentMedia>" |
---|
| 230 | "<MachineGuid>%s</MachineGuid></Data>", |
---|
| 231 | message ? message : "", md->uuid ); |
---|
[64768d4] | 232 | msn_ns_write( ic, -1, "UUX %d %zd\r\n%s", ++md->trId, strlen( uux ), uux ); |
---|
| 233 | g_free( uux ); |
---|
[b7d3cc34] | 234 | } |
---|
| 235 | |
---|
[0da65d5] | 236 | static void msn_get_info(struct im_connection *ic, char *who) |
---|
[b7d3cc34] | 237 | { |
---|
| 238 | /* Just make an URL and let the user fetch the info */ |
---|
[84b045d] | 239 | imcb_log( ic, "%s\n%s: %s%s", _("User Info"), _("For now, fetch yourself"), PROFILE_URL, who ); |
---|
[b7d3cc34] | 240 | } |
---|
| 241 | |
---|
[0da65d5] | 242 | static void msn_add_buddy( struct im_connection *ic, char *who, char *group ) |
---|
[b7d3cc34] | 243 | { |
---|
[8b01217] | 244 | struct bee_user *bu = bee_user_by_handle( ic->bee, ic, who ); |
---|
| 245 | |
---|
[193dc74] | 246 | msn_buddy_list_add( ic, MSN_BUDDY_FL, who, who, group ); |
---|
[8b01217] | 247 | if( bu && bu->group ) |
---|
[193dc74] | 248 | msn_buddy_list_remove( ic, MSN_BUDDY_FL, who, bu->group->name ); |
---|
[b7d3cc34] | 249 | } |
---|
| 250 | |
---|
[0da65d5] | 251 | static void msn_remove_buddy( struct im_connection *ic, char *who, char *group ) |
---|
[b7d3cc34] | 252 | { |
---|
[193dc74] | 253 | msn_buddy_list_remove( ic, MSN_BUDDY_FL, who, NULL ); |
---|
[b7d3cc34] | 254 | } |
---|
| 255 | |
---|
[f6c963b] | 256 | static void msn_chat_msg( struct groupchat *c, char *message, int flags ) |
---|
[b7d3cc34] | 257 | { |
---|
[fa29d093] | 258 | struct msn_switchboard *sb = msn_sb_by_chat( c ); |
---|
[b7d3cc34] | 259 | |
---|
| 260 | if( sb ) |
---|
[0da65d5] | 261 | msn_sb_sendmessage( sb, message ); |
---|
| 262 | /* FIXME: Error handling (although this can't happen unless something's |
---|
| 263 | already severely broken) disappeared here! */ |
---|
[b7d3cc34] | 264 | } |
---|
| 265 | |
---|
[c058ff9] | 266 | static void msn_chat_invite( struct groupchat *c, char *who, char *message ) |
---|
[b7d3cc34] | 267 | { |
---|
[fa29d093] | 268 | struct msn_switchboard *sb = msn_sb_by_chat( c ); |
---|
[b7d3cc34] | 269 | |
---|
| 270 | if( sb ) |
---|
[bc676ac] | 271 | msn_sb_write( sb, "CAL %d %s\r\n", ++sb->trId, who ); |
---|
[b7d3cc34] | 272 | } |
---|
| 273 | |
---|
[0da65d5] | 274 | static void msn_chat_leave( struct groupchat *c ) |
---|
[b7d3cc34] | 275 | { |
---|
[fa29d093] | 276 | struct msn_switchboard *sb = msn_sb_by_chat( c ); |
---|
[b7d3cc34] | 277 | |
---|
| 278 | if( sb ) |
---|
[bc676ac] | 279 | msn_sb_write( sb, "OUT\r\n" ); |
---|
[b7d3cc34] | 280 | } |
---|
| 281 | |
---|
[0da65d5] | 282 | static struct groupchat *msn_chat_with( struct im_connection *ic, char *who ) |
---|
[b7d3cc34] | 283 | { |
---|
| 284 | struct msn_switchboard *sb; |
---|
[36577aa] | 285 | struct groupchat *c = imcb_chat_new( ic, who ); |
---|
[b7d3cc34] | 286 | |
---|
[0da65d5] | 287 | if( ( sb = msn_sb_by_handle( ic, who ) ) ) |
---|
[b7d3cc34] | 288 | { |
---|
| 289 | debug( "Converting existing switchboard to %s to a groupchat", who ); |
---|
[fa29d093] | 290 | return msn_sb_to_chat( sb ); |
---|
[b7d3cc34] | 291 | } |
---|
| 292 | else |
---|
| 293 | { |
---|
| 294 | struct msn_message *m; |
---|
| 295 | |
---|
| 296 | /* Create a magic message. This is quite hackish, but who cares? :-P */ |
---|
| 297 | m = g_new0( struct msn_message, 1 ); |
---|
| 298 | m->who = g_strdup( who ); |
---|
| 299 | m->text = g_strdup( GROUPCHAT_SWITCHBOARD_MESSAGE ); |
---|
| 300 | |
---|
[a830512] | 301 | msn_sb_write_msg( ic, m ); |
---|
| 302 | |
---|
[36577aa] | 303 | return c; |
---|
[b7d3cc34] | 304 | } |
---|
| 305 | } |
---|
| 306 | |
---|
[0da65d5] | 307 | static void msn_keepalive( struct im_connection *ic ) |
---|
[b7d3cc34] | 308 | { |
---|
[64768d4] | 309 | msn_ns_write( ic, -1, "PNG\r\n" ); |
---|
[b7d3cc34] | 310 | } |
---|
| 311 | |
---|
[0da65d5] | 312 | static void msn_add_permit( struct im_connection *ic, char *who ) |
---|
[b7d3cc34] | 313 | { |
---|
[193dc74] | 314 | msn_buddy_list_add( ic, MSN_BUDDY_AL, who, who, NULL ); |
---|
[b7d3cc34] | 315 | } |
---|
| 316 | |
---|
[0da65d5] | 317 | static void msn_rem_permit( struct im_connection *ic, char *who ) |
---|
[b7d3cc34] | 318 | { |
---|
[27053b5] | 319 | msn_buddy_list_remove( ic, MSN_BUDDY_AL, who, NULL ); |
---|
[b7d3cc34] | 320 | } |
---|
| 321 | |
---|
[0da65d5] | 322 | static void msn_add_deny( struct im_connection *ic, char *who ) |
---|
[b7d3cc34] | 323 | { |
---|
| 324 | struct msn_switchboard *sb; |
---|
| 325 | |
---|
[193dc74] | 326 | msn_buddy_list_add( ic, MSN_BUDDY_BL, who, who, NULL ); |
---|
[b7d3cc34] | 327 | |
---|
| 328 | /* If there's still a conversation with this person, close it. */ |
---|
[0da65d5] | 329 | if( ( sb = msn_sb_by_handle( ic, who ) ) ) |
---|
[b7d3cc34] | 330 | { |
---|
| 331 | msn_sb_destroy( sb ); |
---|
| 332 | } |
---|
| 333 | } |
---|
| 334 | |
---|
[0da65d5] | 335 | static void msn_rem_deny( struct im_connection *ic, char *who ) |
---|
[b7d3cc34] | 336 | { |
---|
[27053b5] | 337 | msn_buddy_list_remove( ic, MSN_BUDDY_BL, who, NULL ); |
---|
[b7d3cc34] | 338 | } |
---|
| 339 | |
---|
[0da65d5] | 340 | static int msn_send_typing( struct im_connection *ic, char *who, int typing ) |
---|
[b7d3cc34] | 341 | { |
---|
[4255320] | 342 | struct bee_user *bu = bee_user_by_handle( ic->bee, ic, who ); |
---|
| 343 | |
---|
| 344 | if( !( bu->flags & BEE_USER_ONLINE ) ) |
---|
| 345 | return 0; |
---|
| 346 | else if( typing & OPT_TYPING ) |
---|
[f6c963b] | 347 | return( msn_buddy_msg( ic, who, TYPING_NOTIFICATION_MESSAGE, 0 ) ); |
---|
[b7d3cc34] | 348 | else |
---|
[4255320] | 349 | return 1; |
---|
[b7d3cc34] | 350 | } |
---|
| 351 | |
---|
[e3413cc] | 352 | static char *set_eval_display_name( set_t *set, char *value ) |
---|
[911f2eb] | 353 | { |
---|
| 354 | account_t *acc = set->data; |
---|
[0da65d5] | 355 | struct im_connection *ic = acc->ic; |
---|
[80175a1] | 356 | struct msn_data *md = ic->proto_data; |
---|
[911f2eb] | 357 | |
---|
[ed0589c] | 358 | if( md->flags & MSN_EMAIL_UNVERIFIED ) |
---|
| 359 | imcb_log( ic, "Warning: Your e-mail address is unverified. MSN doesn't allow " |
---|
[10685d3] | 360 | "changing your display name until your e-mail address is verified." ); |
---|
[ed0589c] | 361 | |
---|
[76c89dc7] | 362 | if( md->flags & MSN_GOT_PROFILE_DN ) |
---|
| 363 | msn_soap_profile_set_dn( ic, value ); |
---|
| 364 | else |
---|
| 365 | msn_soap_addressbook_set_display_name( ic, value ); |
---|
| 366 | |
---|
[e0e1546] | 367 | return msn_ns_set_display_name( ic, value ) ? value : NULL; |
---|
[911f2eb] | 368 | } |
---|
| 369 | |
---|
[7f34ce2] | 370 | static void msn_buddy_data_add( bee_user_t *bu ) |
---|
| 371 | { |
---|
[ca7de3a] | 372 | struct msn_data *md = bu->ic->proto_data; |
---|
[208db4b] | 373 | struct msn_buddy_data *bd; |
---|
| 374 | char *handle; |
---|
| 375 | |
---|
| 376 | bd = bu->data = g_new0( struct msn_buddy_data, 1 ); |
---|
[ca7de3a] | 377 | g_tree_insert( md->domaintree, bu->handle, bu ); |
---|
[208db4b] | 378 | |
---|
[6b13103] | 379 | for( handle = bu->handle; g_ascii_isdigit( *handle ); handle ++ ); |
---|
[208db4b] | 380 | if( *handle == ':' ) |
---|
| 381 | { |
---|
| 382 | /* Pass a nick hint so hopefully the stupid numeric prefix |
---|
| 383 | won't show up to the user. */ |
---|
| 384 | char *s = strchr( ++handle, '@' ); |
---|
| 385 | if( s ) |
---|
| 386 | { |
---|
| 387 | handle = g_strndup( handle, s - handle ); |
---|
| 388 | imcb_buddy_nick_hint( bu->ic, bu->handle, handle ); |
---|
| 389 | g_free( handle ); |
---|
| 390 | } |
---|
| 391 | |
---|
| 392 | bd->flags |= MSN_BUDDY_FED; |
---|
| 393 | } |
---|
[7f34ce2] | 394 | } |
---|
| 395 | |
---|
| 396 | static void msn_buddy_data_free( bee_user_t *bu ) |
---|
| 397 | { |
---|
[ca7de3a] | 398 | struct msn_data *md = bu->ic->proto_data; |
---|
[c1d40e7] | 399 | struct msn_buddy_data *bd = bu->data; |
---|
[23b29c6] | 400 | |
---|
[c1d40e7] | 401 | g_free( bd->cid ); |
---|
[23b29c6] | 402 | g_free( bd ); |
---|
| 403 | |
---|
| 404 | g_tree_remove( md->domaintree, bu->handle ); |
---|
[7f34ce2] | 405 | } |
---|
| 406 | |
---|
[9c84617] | 407 | GList *msn_buddy_action_list( bee_user_t *bu ) |
---|
| 408 | { |
---|
| 409 | static GList *ret = NULL; |
---|
| 410 | |
---|
| 411 | if( ret == NULL ) |
---|
| 412 | { |
---|
| 413 | static const struct buddy_action ba[2] = { |
---|
| 414 | { "NUDGE", "Draw attention" }, |
---|
| 415 | }; |
---|
| 416 | |
---|
| 417 | ret = g_list_prepend( ret, (void*) ba + 0 ); |
---|
| 418 | } |
---|
| 419 | |
---|
| 420 | return ret; |
---|
| 421 | } |
---|
| 422 | |
---|
| 423 | void *msn_buddy_action( struct bee_user *bu, const char *action, char * const args[], void *data ) |
---|
| 424 | { |
---|
| 425 | if( g_strcasecmp( action, "NUDGE" ) == 0 ) |
---|
| 426 | msn_buddy_msg( bu->ic, bu->handle, NUDGE_MESSAGE, 0 ); |
---|
| 427 | |
---|
| 428 | return NULL; |
---|
| 429 | } |
---|
| 430 | |
---|
[0da65d5] | 431 | void msn_initmodule() |
---|
[b7d3cc34] | 432 | { |
---|
[7b23afd] | 433 | struct prpl *ret = g_new0(struct prpl, 1); |
---|
[911f2eb] | 434 | |
---|
[7b23afd] | 435 | ret->name = "msn"; |
---|
[76c89dc7] | 436 | ret->mms = 1409; /* this guess taken from libotr UPGRADING file */ |
---|
[b7d3cc34] | 437 | ret->login = msn_login; |
---|
[0da65d5] | 438 | ret->init = msn_init; |
---|
| 439 | ret->logout = msn_logout; |
---|
[f6c963b] | 440 | ret->buddy_msg = msn_buddy_msg; |
---|
[b7d3cc34] | 441 | ret->away_states = msn_away_states; |
---|
| 442 | ret->set_away = msn_set_away; |
---|
| 443 | ret->get_info = msn_get_info; |
---|
| 444 | ret->add_buddy = msn_add_buddy; |
---|
| 445 | ret->remove_buddy = msn_remove_buddy; |
---|
[f6c963b] | 446 | ret->chat_msg = msn_chat_msg; |
---|
[b7d3cc34] | 447 | ret->chat_invite = msn_chat_invite; |
---|
| 448 | ret->chat_leave = msn_chat_leave; |
---|
[0da65d5] | 449 | ret->chat_with = msn_chat_with; |
---|
[b7d3cc34] | 450 | ret->keepalive = msn_keepalive; |
---|
| 451 | ret->add_permit = msn_add_permit; |
---|
| 452 | ret->rem_permit = msn_rem_permit; |
---|
| 453 | ret->add_deny = msn_add_deny; |
---|
| 454 | ret->rem_deny = msn_rem_deny; |
---|
| 455 | ret->send_typing = msn_send_typing; |
---|
[5b52a48] | 456 | ret->handle_cmp = g_strcasecmp; |
---|
[7f34ce2] | 457 | ret->buddy_data_add = msn_buddy_data_add; |
---|
| 458 | ret->buddy_data_free = msn_buddy_data_free; |
---|
[9c84617] | 459 | ret->buddy_action_list = msn_buddy_action_list; |
---|
| 460 | ret->buddy_action = msn_buddy_action; |
---|
[7f34ce2] | 461 | |
---|
[17a6ee9] | 462 | //ret->transfer_request = msn_ftp_transfer_request; |
---|
[b7d3cc34] | 463 | |
---|
[7b23afd] | 464 | register_protocol(ret); |
---|
[b7d3cc34] | 465 | } |
---|