src/protocols/msn/msn.c

changeset 9030
7b574a641391
parent 9015
3c27e9074fa2
child 9041
cbded2eb14d7
equal deleted inserted replaced
9029:4670ebf1c180 9030:7b574a641391
18 * You should have received a copy of the GNU General Public License 18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software 19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 */ 21 */
22 #include <glib.h> 22 #include <glib.h>
23 23 #include "internal.h"
24
25 #include "blist.h"
24 #include "msn.h" 26 #include "msn.h"
25 #include "accountopt.h" 27 #include "accountopt.h"
26 #include "msg.h" 28 #include "msg.h"
27 #include "page.h" 29 #include "page.h"
28 #include "pluginpref.h" 30 #include "pluginpref.h"
29 #include "prefs.h" 31 #include "prefs.h"
30 #include "session.h" 32 #include "session.h"
31 #include "state.h" 33 #include "state.h"
32 #include "utils.h" 34 #include "utils.h"
33 #include "multi.h"
34 #include "util.h" 35 #include "util.h"
35 36
36 #include "notification.h" 37 #include "notification.h"
37 #include "switchboard.h" 38 #include "switchboard.h"
38 39
232 static void 233 static void
233 msn_show_set_mobile_pages(GaimPluginAction *action) 234 msn_show_set_mobile_pages(GaimPluginAction *action)
234 { 235 {
235 GaimConnection *gc = (GaimConnection *) action->context; 236 GaimConnection *gc = (GaimConnection *) action->context;
236 gaim_request_action(gc, NULL, _("Allow MSN Mobile pages?"), 237 gaim_request_action(gc, NULL, _("Allow MSN Mobile pages?"),
237 _("Do you want to allow or disallow people on " 238 _("Do you want to allow or disallow people on "
238 "your buddy list to send you MSN Mobile pages " 239 "your buddy list to send you MSN Mobile pages "
239 "to your cell phone or other mobile device?"), 240 "to your cell phone or other mobile device?"),
240 -1, gc, 3, 241 -1, gc, 3,
241 _("Allow"), G_CALLBACK(enable_msn_pages_cb), 242 _("Allow"), G_CALLBACK(enable_msn_pages_cb),
242 _("Disallow"), G_CALLBACK(disable_msn_pages_cb), 243 _("Disallow"), G_CALLBACK(disable_msn_pages_cb),
243 _("Cancel"), NULL); 244 _("Cancel"), NULL);
244 } 245 }
245 246
246 static void 247 static void
247 show_send_to_mobile_cb(GaimConnection *gc, const char *passport) 248 show_send_to_mobile_cb(GaimBlistNode *node, gpointer ignored)
248 { 249 {
250 GaimBuddy *buddy;
251 GaimConnection *gc;
252
253 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node));
254
255 buddy = (GaimBuddy *) node;
256 gc = gaim_account_get_connection(buddy->account);
257
249 MsnUser *user; 258 MsnUser *user;
250 MsnSession *session; 259 MsnSession *session;
251 MsnMobileData *data; 260 MsnMobileData *data;
252 261
253 session = gc->proto_data; 262 session = gc->proto_data;
254 user = msn_users_find_with_passport(session->users, passport); 263 user = msn_users_find_with_passport(session->users, buddy->name);
255 264
256 data = g_new0(MsnMobileData, 1); 265 data = g_new0(MsnMobileData, 1);
257 data->gc = gc; 266 data->gc = gc;
258 data->passport = passport; 267 data->passport = buddy->name;
259 268
260 gaim_request_input(gc, NULL, _("Send a mobile message."), NULL, 269 gaim_request_input(gc, NULL, _("Send a mobile message."), NULL,
261 NULL, TRUE, FALSE, NULL, 270 NULL, TRUE, FALSE, NULL,
262 _("Page"), G_CALLBACK(send_to_mobile_cb), 271 _("Page"), G_CALLBACK(send_to_mobile_cb),
263 _("Close"), G_CALLBACK(close_mobile_page_cb), 272 _("Close"), G_CALLBACK(close_mobile_page_cb),
264 data); 273 data);
265 } 274 }
266 275
267 static void 276 static void
268 initiate_chat_cb(GaimConnection *gc, const char *passport) 277 initiate_chat_cb(GaimBlistNode *node, gpointer data)
269 { 278 {
270 GaimAccount *account; 279 GaimBuddy *buddy;
280 GaimConnection *gc;
281
271 MsnSession *session; 282 MsnSession *session;
272 MsnCmdProc *cmdproc; 283 MsnCmdProc *cmdproc;
273 MsnSwitchBoard *swboard; 284 MsnSwitchBoard *swboard;
274 MsnUser *user; 285 MsnUser *user;
275 286
276 account = gaim_connection_get_account(gc); 287 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node));
288
289 buddy = (GaimBuddy *) node;
290 gc = gaim_account_get_connection(buddy->account);
291
277 session = gc->proto_data; 292 session = gc->proto_data;
278 cmdproc = session->notification_conn->cmdproc; 293 cmdproc = session->notification_conn->cmdproc;
279 294
280 if ((swboard = msn_session_open_switchboard(session)) == NULL) 295 if ((swboard = msn_session_open_switchboard(session)) == NULL)
281 return; 296 return;
282 297
283 user = msn_user_new(session, passport, NULL); 298 user = msn_user_new(session, buddy->name, NULL);
284 299
285 msn_switchboard_set_user(swboard, user); 300 msn_switchboard_set_user(swboard, user);
286 301
287 swboard->total_users = 1; 302 swboard->total_users = 1;
288 303
289 session->last_chat_id++; 304 session->last_chat_id++;
290 swboard->chat_id = session->last_chat_id; 305 swboard->chat_id = session->last_chat_id;
291 swboard->chat = serv_got_joined_chat(gc, swboard->chat_id, "MSN Chat"); 306 swboard->chat = serv_got_joined_chat(gc, swboard->chat_id, "MSN Chat");
292 307
293 gaim_conv_chat_add_user(GAIM_CONV_CHAT(swboard->chat), 308 gaim_conv_chat_add_user(GAIM_CONV_CHAT(swboard->chat),
294 gaim_account_get_username(account), NULL); 309 gaim_account_get_username(buddy->account), NULL);
295 } 310 }
296 311
297 /************************************************************************** 312 /**************************************************************************
298 * Protocol Plugin ops 313 * Protocol Plugin ops
299 **************************************************************************/ 314 **************************************************************************/
408 423
409 return m; 424 return m;
410 } 425 }
411 426
412 static GList * 427 static GList *
413 msn_buddy_menu(GaimConnection *gc, const char *who) 428 msn_buddy_menu(GaimBuddy *buddy)
414 { 429 {
415 GaimAccount *account;
416 MsnUser *user; 430 MsnUser *user;
417 struct proto_buddy_menu *pbm; 431
418 GaimBuddy *b;
419 GList *m = NULL; 432 GList *m = NULL;
420 433 GaimBlistNodeAction *act;
421 account = gaim_connection_get_account(gc); 434
422 b = gaim_find_buddy(account, who); 435 user = buddy->proto_data;
423
424 g_return_val_if_fail(b != NULL, NULL);
425
426 user = b->proto_data;
427
428 if (user != NULL) 436 if (user != NULL)
429 { 437 {
430 if (user->mobile) 438 if (user->mobile)
431 { 439 {
432 pbm = g_new0(struct proto_buddy_menu, 1); 440 act = gaim_blist_node_action_new(_("Send to Mobile"),
433 pbm->label = _("Send to Mobile"); 441 show_send_to_mobile_cb, NULL);
434 pbm->callback = show_send_to_mobile_cb; 442 m = g_list_append(m, act);
435 pbm->gc = gc;
436 m = g_list_append(m, pbm);
437 } 443 }
438 } 444 }
439 445
440 if (g_ascii_strcasecmp(who, gaim_account_get_username(account))) 446 if (g_ascii_strcasecmp(buddy->name, gaim_account_get_username(buddy->account)))
441 { 447 {
442 pbm = g_new0(struct proto_buddy_menu, 1); 448 act = gaim_blist_node_action_new(_("Initiate Chat"),
443 pbm->label = _("Initiate Chat"); 449 initiate_chat_cb, NULL);
444 pbm->callback = initiate_chat_cb; 450 m = g_list_append(m, act);
445 pbm->gc = gc;
446 m = g_list_append(m, pbm);
447 } 451 }
448 452
449 return m; 453 return m;
450 } 454 }
455
456
457 static GList *
458 msn_blist_node_menu(GaimBlistNode *node)
459 {
460 if(GAIM_BLIST_NODE_IS_BUDDY(node)) {
461 return msn_buddy_menu((GaimBuddy *) node);
462 } else {
463 return NULL;
464 }
465 }
466
451 467
452 static void 468 static void
453 msn_login(GaimAccount *account) 469 msn_login(GaimAccount *account)
454 { 470 {
455 GaimConnection *gc; 471 GaimConnection *gc;
1624 msn_list_icon, 1640 msn_list_icon,
1625 msn_list_emblems, 1641 msn_list_emblems,
1626 msn_status_text, 1642 msn_status_text,
1627 msn_tooltip_text, 1643 msn_tooltip_text,
1628 msn_away_states, 1644 msn_away_states,
1629 msn_buddy_menu, 1645 msn_blist_node_menu,
1630 NULL, 1646 NULL,
1631 msn_login, 1647 msn_login,
1632 msn_close, 1648 msn_close,
1633 msn_send_im, 1649 msn_send_im,
1634 NULL, 1650 NULL,
1663 msn_buddy_free, 1679 msn_buddy_free,
1664 msn_convo_closed, 1680 msn_convo_closed,
1665 msn_normalize, 1681 msn_normalize,
1666 msn_set_buddy_icon, 1682 msn_set_buddy_icon,
1667 msn_remove_group, 1683 msn_remove_group,
1668 NULL,
1669 NULL, 1684 NULL,
1670 NULL, 1685 NULL,
1671 NULL, 1686 NULL,
1672 NULL, 1687 NULL,
1673 NULL, 1688 NULL,

mercurial