comparison libpurple/protocols/oscar/oscar.c @ 28309:bd9df4e45904

Add a "Cancel Direct IM" buddy action when connected. Closes #2556.
author Paul Aurich <paul@darkrain42.org>
date Wed, 15 Jul 2009 04:04:12 +0000
parents 5048054d319a
children 1f329bdc91ab
comparison
equal deleted inserted replaced
27619:205267108d6e 28309:bd9df4e45904
6364 _("_Cancel"), G_CALLBACK(oscar_ask_directim_no_cb)); 6364 _("_Cancel"), G_CALLBACK(oscar_ask_directim_no_cb));
6365 g_free(buf); 6365 g_free(buf);
6366 } 6366 }
6367 6367
6368 static void 6368 static void
6369 oscar_close_directim(gpointer object, gpointer ignored)
6370 {
6371 PurpleBlistNode *node;
6372 PurpleBuddy *buddy;
6373 PurpleAccount *account;
6374 PurpleConnection *gc;
6375 PurpleConversation *conv;
6376 OscarData *od;
6377 PeerConnection *conn;
6378 const char *name;
6379
6380 node = object;
6381
6382 g_return_if_fail(PURPLE_BLIST_NODE_IS_BUDDY(node));
6383
6384 buddy = (PurpleBuddy*)node;
6385 name = purple_buddy_get_name(buddy);
6386 account = purple_buddy_get_account(buddy);
6387 gc = purple_account_get_connection(account);
6388 od = gc->proto_data;
6389 conn = peer_connection_find_by_type(od, name, OSCAR_CAPABILITY_DIRECTIM);
6390
6391 if (conn != NULL)
6392 {
6393 if (!conn->ready)
6394 aim_im_sendch2_cancel(conn);
6395
6396 peer_connection_destroy(conn, OSCAR_DISCONNECT_LOCAL_CLOSED, NULL);
6397
6398 /* OSCAR_DISCONNECT_LOCAL_CLOSED doesn't write anything to the convo
6399 * window. Let the user know that we canceled the Direct IM. */
6400 conv = purple_conversation_new(PURPLE_CONV_TYPE_IM, account, name);
6401 purple_conversation_write(conv, NULL, _("You closed the connection."),
6402 PURPLE_MESSAGE_SYSTEM, time(NULL));
6403 }
6404 }
6405
6406 static void
6369 oscar_get_aim_info_cb(PurpleBlistNode *node, gpointer ignore) 6407 oscar_get_aim_info_cb(PurpleBlistNode *node, gpointer ignore)
6370 { 6408 {
6371 PurpleBuddy *buddy; 6409 PurpleBuddy *buddy;
6372 PurpleConnection *gc; 6410 PurpleConnection *gc;
6373 6411
6426 6464
6427 if (userinfo && 6465 if (userinfo &&
6428 oscar_util_name_compare(purple_account_get_username(account), bname) && 6466 oscar_util_name_compare(purple_account_get_username(account), bname) &&
6429 PURPLE_BUDDY_IS_ONLINE(buddy)) 6467 PURPLE_BUDDY_IS_ONLINE(buddy))
6430 { 6468 {
6469 PeerConnection *conn;
6470 conn = peer_connection_find_by_type(od, bname, OSCAR_CAPABILITY_DIRECTIM);
6471
6431 if (userinfo->capabilities & OSCAR_CAPABILITY_DIRECTIM) 6472 if (userinfo->capabilities & OSCAR_CAPABILITY_DIRECTIM)
6432 { 6473 {
6433 act = purple_menu_action_new(_("Direct IM"), 6474 if (conn)
6434 PURPLE_CALLBACK(oscar_ask_directim), 6475 {
6435 NULL, NULL); 6476 act = purple_menu_action_new(_("Cancel Direct IM"),
6477 PURPLE_CALLBACK(oscar_close_directim),
6478 NULL, NULL);
6479 }
6480 else
6481 {
6482 act = purple_menu_action_new(_("Direct IM"),
6483 PURPLE_CALLBACK(oscar_ask_directim),
6484 NULL, NULL);
6485 }
6436 menu = g_list_prepend(menu, act); 6486 menu = g_list_prepend(menu, act);
6437 } 6487 }
6438 #if 0 6488 #if 0
6439 /* TODO: This menu item should be added by the core */ 6489 /* TODO: This menu item should be added by the core */
6440 if (userinfo->capabilities & OSCAR_CAPABILITY_GETFILE) { 6490 if (userinfo->capabilities & OSCAR_CAPABILITY_GETFILE) {