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