Mercurial > pidgin.yaz
comparison libpurple/protocols/jabber/google.c @ 29523:ecd2136ff818
Broke out the generation of random UUIDs to its own function
Adapted the Google group chat functionallity to use the new function
author | Marcus Lundblad <ml@update.uu.se> |
---|---|
date | Tue, 13 Oct 2009 22:13:57 +0000 |
parents | 63dc67b32577 |
children | e3206d6da6c7 |
comparison
equal
deleted
inserted
replaced
29522:739886e6dac2 | 29523:ecd2136ff818 |
---|---|
1432 PurpleBuddy *buddy; | 1432 PurpleBuddy *buddy; |
1433 PurpleConnection *gc; | 1433 PurpleConnection *gc; |
1434 JabberStream *js; | 1434 JabberStream *js; |
1435 JabberChat *chat; | 1435 JabberChat *chat; |
1436 gchar *room; | 1436 gchar *room; |
1437 guint32 tmp, a, b; | 1437 gchar *uuid = purple_uuid_random(); |
1438 | 1438 |
1439 g_return_if_fail(PURPLE_BLIST_NODE_IS_BUDDY(node)); | 1439 g_return_if_fail(PURPLE_BLIST_NODE_IS_BUDDY(node)); |
1440 | 1440 |
1441 buddy = PURPLE_BUDDY(node); | 1441 buddy = PURPLE_BUDDY(node); |
1442 gc = purple_account_get_connection(purple_buddy_get_account(buddy)); | 1442 gc = purple_account_get_connection(purple_buddy_get_account(buddy)); |
1443 g_return_if_fail(gc != NULL); | 1443 g_return_if_fail(gc != NULL); |
1444 js = purple_connection_get_protocol_data(gc); | 1444 js = purple_connection_get_protocol_data(gc); |
1445 | 1445 |
1446 /* Generate a version 4 UUID */ | 1446 room = g_strdup_printf("private-chat-%s", uuid); |
1447 tmp = g_random_int(); | |
1448 a = 0x4000 | (tmp & 0xFFF); /* 0x4000 to 0x4FFF */ | |
1449 tmp >>= 12; | |
1450 b = ((1 << 3) << 12) | (tmp & 0x3FFF); /* 0x8000 to 0xBFFF */ | |
1451 | |
1452 tmp = g_random_int(); | |
1453 room = g_strdup_printf("private-chat-%08x-%04x-%04x-%04x-%04x%08x", | |
1454 g_random_int(), | |
1455 tmp & 0xFFFF, | |
1456 a, | |
1457 b, | |
1458 (tmp >> 16) & 0xFFFF, g_random_int()); | |
1459 | |
1460 chat = jabber_join_chat(js, room, GOOGLE_GROUPCHAT_SERVER, js->user->node, | 1447 chat = jabber_join_chat(js, room, GOOGLE_GROUPCHAT_SERVER, js->user->node, |
1461 NULL, NULL); | 1448 NULL, NULL); |
1462 if (chat) { | 1449 if (chat) { |
1463 chat->muc = TRUE; | 1450 chat->muc = TRUE; |
1464 jabber_chat_invite(gc, chat->id, "", buddy->name); | 1451 jabber_chat_invite(gc, chat->id, "", buddy->name); |
1465 } | 1452 } |
1466 | 1453 |
1467 g_free(room); | 1454 g_free(room); |
1468 } | 1455 g_free(uuid); |
1456 } |