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