Mercurial > pidgin
comparison libpurple/protocols/jabber/google.c @ 28371:51d507e6c8f3
jabber: Add an "Initiate Chat" blist context menu option for GTalk accounts.
Patch from Eion Robb with minor cleanup. Closes #10413. Refs #3360.
committer: Paul Aurich <paul@darkrain42.org>
author | eion@robbmob.com |
---|---|
date | Mon, 12 Oct 2009 17:36:12 +0000 |
parents | ed88200c79ee |
children | 63dc67b32577 |
comparison
equal
deleted
inserted
replaced
28368:4a917f91bc05 | 28371:51d507e6c8f3 |
---|---|
29 #include "buddy.h" | 29 #include "buddy.h" |
30 #include "google.h" | 30 #include "google.h" |
31 #include "jabber.h" | 31 #include "jabber.h" |
32 #include "presence.h" | 32 #include "presence.h" |
33 #include "iq.h" | 33 #include "iq.h" |
34 #include "chat.h" | |
34 | 35 |
35 #include "jingle/jingle.h" | 36 #include "jingle/jingle.h" |
36 | 37 |
37 #ifdef USE_VV | 38 #ifdef USE_VV |
38 | 39 |
1423 jabber_iq_set_callback(jingle_info, jabber_google_jingle_info_cb, | 1424 jabber_iq_set_callback(jingle_info, jabber_google_jingle_info_cb, |
1424 NULL); | 1425 NULL); |
1425 purple_debug_info("jabber", "sending google:jingleinfo query\n"); | 1426 purple_debug_info("jabber", "sending google:jingleinfo query\n"); |
1426 jabber_iq_send(jingle_info); | 1427 jabber_iq_send(jingle_info); |
1427 } | 1428 } |
1429 | |
1430 void google_buddy_node_chat(PurpleBlistNode *node, gpointer data) | |
1431 { | |
1432 PurpleBuddy *buddy; | |
1433 PurpleConnection *gc; | |
1434 JabberStream *js; | |
1435 JabberChat *jc; | |
1436 GHashTable *chat_info; | |
1437 gchar *chat_name; | |
1438 gchar *uuid; | |
1439 gchar *room; | |
1440 guint32 tmp, a, b; | |
1441 | |
1442 g_return_if_fail(PURPLE_BLIST_NODE_IS_BUDDY(node)); | |
1443 | |
1444 buddy = PURPLE_BUDDY(node); | |
1445 gc = purple_account_get_connection(purple_buddy_get_account(buddy)); | |
1446 js = purple_connection_get_protocol_data(gc); | |
1447 | |
1448 tmp = g_random_int(); | |
1449 a = 0x4000 | (tmp & 0xFFF); /* 0x4000 to 0x4FFF */ | |
1450 tmp >>= 12; | |
1451 b = ((1 << 3) << 12) | (tmp & 0x3FFF); /* 0x8000 to 0xBFFF */ | |
1452 | |
1453 tmp = g_random_int(); | |
1454 uuid = g_strdup_printf("%08x-%04x-%04x-%04x-%04x%08x", | |
1455 g_random_int(), | |
1456 tmp & 0xFFFF, | |
1457 a, | |
1458 b, | |
1459 (tmp >> 16) & 0xFFFF, g_random_int()); | |
1460 | |
1461 room = g_strdup_printf("private-chat-%s", uuid); | |
1462 chat_name = g_strdup_printf("%s@%s", room, GOOGLE_GROUPCHAT_SERVER); | |
1463 chat_info = jabber_chat_info_defaults(gc, chat_name); | |
1464 if (chat_info) { | |
1465 jabber_chat_join(gc, chat_info); | |
1466 jc = jabber_chat_find(js, room, GOOGLE_GROUPCHAT_SERVER); | |
1467 if (jc) | |
1468 { | |
1469 jc->muc = TRUE; | |
1470 jabber_chat_invite(gc, jc->id, "", buddy->name); | |
1471 } | |
1472 g_hash_table_destroy(chat_info); | |
1473 } | |
1474 | |
1475 g_free(room); | |
1476 g_free(uuid); | |
1477 g_free(chat_name); | |
1478 } |