comparison libpurple/protocols/silc/buddy.c @ 32672:3828a61c44da

A boring and large patch so I can merge heads.
author Elliott Sales de Andrade <qulogic@pidgin.im>
date Fri, 23 Dec 2011 08:21:58 +0000
parents 99ca503ea087
children
comparison
equal deleted inserted replaced
32671:0e69949b3e61 32672:3828a61c44da
70 SilcKeyAgreementStatus status, 70 SilcKeyAgreementStatus status,
71 SilcSKEKeyMaterial key, 71 SilcSKEKeyMaterial key,
72 void *context) 72 void *context)
73 { 73 {
74 PurpleConnection *gc = client->application; 74 PurpleConnection *gc = client->application;
75 SilcPurple sg = gc->proto_data; 75 SilcPurple sg = purple_connection_get_protocol_data(gc);
76 76
77 if (!sg->conn) 77 if (!sg->conn)
78 return; 78 return;
79 79
80 switch (status) { 80 switch (status) {
144 144
145 static void 145 static void
146 silcpurple_buddy_keyagr_do(PurpleConnection *gc, const char *name, 146 silcpurple_buddy_keyagr_do(PurpleConnection *gc, const char *name,
147 gboolean force_local) 147 gboolean force_local)
148 { 148 {
149 SilcPurple sg = gc->proto_data; 149 SilcPurple sg = purple_connection_get_protocol_data(gc);
150 SilcDList clients; 150 SilcDList clients;
151 SilcClientEntry client_entry; 151 SilcClientEntry client_entry;
152 SilcClientConnectionParams params; 152 SilcClientConnectionParams params;
153 char *local_ip = NULL, *remote_ip = NULL; 153 char *local_ip = NULL, *remote_ip = NULL;
154 gboolean local = TRUE; 154 gboolean local = TRUE;
312 if (hostname) 312 if (hostname)
313 a->hostname = g_strdup(hostname); 313 a->hostname = g_strdup(hostname);
314 a->port = port; 314 a->port = port;
315 315
316 purple_request_action(client->application, _("Key Agreement Request"), tmp, 316 purple_request_action(client->application, _("Key Agreement Request"), tmp,
317 hostname ? tmp2 : NULL, 1, gc->account, client_entry->nickname, 317 hostname ? tmp2 : NULL, 1, purple_connection_get_account(gc), client_entry->nickname,
318 NULL, a, 2, _("Yes"), G_CALLBACK(silcpurple_buddy_keyagr_request_cb), 318 NULL, a, 2, _("Yes"), G_CALLBACK(silcpurple_buddy_keyagr_request_cb),
319 _("No"), G_CALLBACK(silcpurple_buddy_keyagr_request_cb)); 319 _("No"), G_CALLBACK(silcpurple_buddy_keyagr_request_cb));
320 } 320 }
321 321
322 static void 322 static void
344 344
345 g_return_if_fail(PURPLE_BLIST_NODE_IS_BUDDY(node)); 345 g_return_if_fail(PURPLE_BLIST_NODE_IS_BUDDY(node));
346 346
347 b = (PurpleBuddy *) node; 347 b = (PurpleBuddy *) node;
348 gc = purple_account_get_connection(purple_buddy_get_account(b)); 348 gc = purple_account_get_connection(purple_buddy_get_account(b));
349 sg = gc->proto_data; 349 sg = purple_connection_get_protocol_data(gc);
350 350
351 /* Find client entry */ 351 /* Find client entry */
352 clients = silc_client_get_clients_local(sg->client, sg->conn, 352 clients = silc_client_get_clients_local(sg->client, sg->conn,
353 purple_buddy_get_name(b), FALSE); 353 purple_buddy_get_name(b), FALSE);
354 if (!clients) 354 if (!clients)
424 } 424 }
425 425
426 static void 426 static void
427 silcpurple_buddy_privkey(PurpleConnection *gc, const char *name) 427 silcpurple_buddy_privkey(PurpleConnection *gc, const char *name)
428 { 428 {
429 SilcPurple sg = gc->proto_data; 429 SilcPurple sg = purple_connection_get_protocol_data(gc);
430 SilcPurplePrivkey p; 430 SilcPurplePrivkey p;
431 SilcDList clients; 431 SilcDList clients;
432 SilcClientEntry client_entry; 432 SilcClientEntry client_entry;
433 433
434 if (!name) 434 if (!name)
455 p->client_id = client_entry->id; 455 p->client_id = client_entry->id;
456 purple_request_input(gc, _("IM With Password"), NULL, 456 purple_request_input(gc, _("IM With Password"), NULL,
457 _("Set IM Password"), NULL, FALSE, TRUE, NULL, 457 _("Set IM Password"), NULL, FALSE, TRUE, NULL,
458 _("OK"), G_CALLBACK(silcpurple_buddy_privkey_cb), 458 _("OK"), G_CALLBACK(silcpurple_buddy_privkey_cb),
459 _("Cancel"), G_CALLBACK(silcpurple_buddy_privkey_cb), 459 _("Cancel"), G_CALLBACK(silcpurple_buddy_privkey_cb),
460 gc->account, NULL, NULL, p); 460 purple_connection_get_account(gc), NULL, NULL, p);
461 461
462 silc_client_list_free(sg->client, sg->conn, clients); 462 silc_client_list_free(sg->client, sg->conn, clients);
463 } 463 }
464 464
465 static void 465 static void
552 } 552 }
553 553
554 static void 554 static void
555 silcpurple_buddy_getkey(PurpleConnection *gc, const char *name) 555 silcpurple_buddy_getkey(PurpleConnection *gc, const char *name)
556 { 556 {
557 SilcPurple sg = gc->proto_data; 557 SilcPurple sg = purple_connection_get_protocol_data(gc);
558 SilcClient client = sg->client; 558 SilcClient client = sg->client;
559 SilcClientConnection conn = sg->conn; 559 SilcClientConnection conn = sg->conn;
560 SilcClientEntry client_entry; 560 SilcClientEntry client_entry;
561 SilcDList clients; 561 SilcDList clients;
562 SilcPurpleBuddyGetkey g; 562 SilcPurpleBuddyGetkey g;
616 616
617 g_return_if_fail(PURPLE_BLIST_NODE_IS_BUDDY(node)); 617 g_return_if_fail(PURPLE_BLIST_NODE_IS_BUDDY(node));
618 618
619 b = (PurpleBuddy *) node; 619 b = (PurpleBuddy *) node;
620 gc = purple_account_get_connection(purple_buddy_get_account(b)); 620 gc = purple_account_get_connection(purple_buddy_get_account(b));
621 sg = gc->proto_data; 621 sg = purple_connection_get_protocol_data(gc);
622 622
623 pkfile = purple_blist_node_get_string(node, "public-key"); 623 pkfile = purple_blist_node_get_string(node, "public-key");
624 if (!silc_pkcs_load_public_key(pkfile, &public_key)) { 624 if (!silc_pkcs_load_public_key(pkfile, &public_key)) {
625 purple_notify_error(gc, 625 purple_notify_error(gc,
626 _("Show Public Key"), 626 _("Show Public Key"),
667 SilcDList clients, 667 SilcDList clients,
668 void *context); 668 void *context);
669 669
670 void silcpurple_get_info(PurpleConnection *gc, const char *who) 670 void silcpurple_get_info(PurpleConnection *gc, const char *who)
671 { 671 {
672 SilcPurple sg = gc->proto_data; 672 SilcPurple sg = purple_connection_get_protocol_data(gc);
673 SilcClient client = sg->client; 673 SilcClient client = sg->client;
674 SilcClientConnection conn = sg->conn; 674 SilcClientConnection conn = sg->conn;
675 SilcClientEntry client_entry; 675 SilcClientEntry client_entry;
676 PurpleBuddy *b; 676 PurpleBuddy *b;
677 const char *filename, *nick = who; 677 const char *filename, *nick = who;
684 if (strlen(who) > 1 && who[0] == '*') 684 if (strlen(who) > 1 && who[0] == '*')
685 nick = who + 1; 685 nick = who + 1;
686 if (strlen(who) > 2 && who[0] == '*' && who[1] == '@') 686 if (strlen(who) > 2 && who[0] == '*' && who[1] == '@')
687 nick = who + 2; 687 nick = who + 2;
688 688
689 b = purple_find_buddy(gc->account, nick); 689 b = purple_find_buddy(purple_connection_get_account(gc), nick);
690 if (b) { 690 if (b) {
691 /* See if we have this buddy's public key. If we do use that 691 /* See if we have this buddy's public key. If we do use that
692 to search the details. */ 692 to search the details. */
693 gpointer proto_data; 693 gpointer proto_data;
694 filename = purple_blist_node_get_string((PurpleBlistNode *)b, "public-key"); 694 filename = purple_blist_node_get_string((PurpleBlistNode *)b, "public-key");
1336 } 1336 }
1337 1337
1338 static void 1338 static void
1339 silcpurple_add_buddy_i(PurpleConnection *gc, PurpleBuddy *b, gboolean init) 1339 silcpurple_add_buddy_i(PurpleConnection *gc, PurpleBuddy *b, gboolean init)
1340 { 1340 {
1341 SilcPurple sg = gc->proto_data; 1341 SilcPurple sg = purple_connection_get_protocol_data(gc);
1342 SilcClient client = sg->client; 1342 SilcClient client = sg->client;
1343 SilcClientConnection conn = sg->conn; 1343 SilcClientConnection conn = sg->conn;
1344 SilcPurpleBuddyRes r; 1344 SilcPurpleBuddyRes r;
1345 SilcBuffer attrs; 1345 SilcBuffer attrs;
1346 const char *filename, *name = purple_buddy_get_name(b); 1346 const char *filename, *name = purple_buddy_get_name(b);
1394 silc_client_get_clients_whois(client, conn, name, NULL, attrs, 1394 silc_client_get_clients_whois(client, conn, name, NULL, attrs,
1395 silcpurple_add_buddy_resolved, r); 1395 silcpurple_add_buddy_resolved, r);
1396 silc_buffer_free(attrs); 1396 silc_buffer_free(attrs);
1397 } 1397 }
1398 1398
1399 void silcpurple_add_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group) 1399 void silcpurple_add_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group, const char *message)
1400 { 1400 {
1401 /* Don't add if the buddy is already on the list. 1401 /* Don't add if the buddy is already on the list.
1402 * 1402 *
1403 * SILC doesn't have groups, so we also don't need to do anything 1403 * SILC doesn't have groups, so we also don't need to do anything
1404 * for a move. */ 1404 * for a move. */
1435 SilcClientConnection conn; 1435 SilcClientConnection conn;
1436 SilcAttributeObjService service; 1436 SilcAttributeObjService service;
1437 const char *server; 1437 const char *server;
1438 int port; 1438 int port;
1439 1439
1440 sg = gc->proto_data; 1440 sg = purple_connection_get_protocol_data(gc);
1441 if (sg == NULL) 1441 if (sg == NULL)
1442 return; 1442 return;
1443 1443
1444 client = sg->client; 1444 client = sg->client;
1445 if (client == NULL) 1445 if (client == NULL)
1465 1465
1466 char *silcpurple_status_text(PurpleBuddy *b) 1466 char *silcpurple_status_text(PurpleBuddy *b)
1467 { 1467 {
1468 PurpleAccount *account = purple_buddy_get_account(b); 1468 PurpleAccount *account = purple_buddy_get_account(b);
1469 PurpleConnection *gc = purple_account_get_connection(account); 1469 PurpleConnection *gc = purple_account_get_connection(account);
1470 SilcPurple sg = gc->proto_data; 1470 SilcPurple sg = purple_connection_get_protocol_data(gc);
1471 SilcClient client = sg->client; 1471 SilcClient client = sg->client;
1472 SilcClientConnection conn = sg->conn; 1472 SilcClientConnection conn = sg->conn;
1473 SilcClientID *client_id = purple_buddy_get_protocol_data(b); 1473 SilcClientID *client_id = purple_buddy_get_protocol_data(b);
1474 SilcClientEntry client_entry; 1474 SilcClientEntry client_entry;
1475 SilcAttributePayload attr; 1475 SilcAttributePayload attr;
1531 1531
1532 void silcpurple_tooltip_text(PurpleBuddy *b, PurpleNotifyUserInfo *user_info, gboolean full) 1532 void silcpurple_tooltip_text(PurpleBuddy *b, PurpleNotifyUserInfo *user_info, gboolean full)
1533 { 1533 {
1534 PurpleAccount *account = purple_buddy_get_account(b); 1534 PurpleAccount *account = purple_buddy_get_account(b);
1535 PurpleConnection *gc = purple_account_get_connection(account); 1535 PurpleConnection *gc = purple_account_get_connection(account);
1536 SilcPurple sg = gc->proto_data; 1536 SilcPurple sg = purple_connection_get_protocol_data(gc);
1537 SilcClient client = sg->client; 1537 SilcClient client = sg->client;
1538 SilcClientConnection conn = sg->conn; 1538 SilcClientConnection conn = sg->conn;
1539 SilcClientID *client_id = purple_buddy_get_protocol_data(b); 1539 SilcClientID *client_id = purple_buddy_get_protocol_data(b);
1540 SilcClientEntry client_entry; 1540 SilcClientEntry client_entry;
1541 char *moodstr, *statusstr, *contactstr, *langstr, *devicestr, *tzstr, *geostr; 1541 char *moodstr, *statusstr, *contactstr, *langstr, *devicestr, *tzstr, *geostr;
1627 1627
1628 g_return_if_fail(PURPLE_BLIST_NODE_IS_BUDDY(node)); 1628 g_return_if_fail(PURPLE_BLIST_NODE_IS_BUDDY(node));
1629 1629
1630 b = (PurpleBuddy *) node; 1630 b = (PurpleBuddy *) node;
1631 gc = purple_account_get_connection(purple_buddy_get_account(b)); 1631 gc = purple_account_get_connection(purple_buddy_get_account(b));
1632 sg = gc->proto_data; 1632 sg = purple_connection_get_protocol_data(gc);
1633 1633
1634 /* Call KILL */ 1634 /* Call KILL */
1635 silc_client_command_call(sg->client, sg->conn, NULL, "KILL", 1635 silc_client_command_call(sg->client, sg->conn, NULL, "KILL",
1636 purple_buddy_get_name(b), "Killed by operator", NULL); 1636 purple_buddy_get_name(b), "Killed by operator", NULL);
1637 } 1637 }
1651 1651
1652 GList *silcpurple_buddy_menu(PurpleBuddy *buddy) 1652 GList *silcpurple_buddy_menu(PurpleBuddy *buddy)
1653 { 1653 {
1654 PurpleAccount *account = purple_buddy_get_account(buddy); 1654 PurpleAccount *account = purple_buddy_get_account(buddy);
1655 PurpleConnection *gc = purple_account_get_connection(account); 1655 PurpleConnection *gc = purple_account_get_connection(account);
1656 SilcPurple sg = gc->proto_data; 1656 SilcPurple sg = purple_connection_get_protocol_data(gc);
1657 SilcClientConnection conn = sg->conn; 1657 SilcClientConnection conn = sg->conn;
1658 const char *pkfile = NULL; 1658 const char *pkfile = NULL;
1659 SilcClientEntry client_entry = NULL; 1659 SilcClientEntry client_entry = NULL;
1660 PurpleMenuAction *act; 1660 PurpleMenuAction *act;
1661 GList *m = NULL; 1661 GList *m = NULL;
1717 return m; 1717 return m;
1718 } 1718 }
1719 1719
1720 void silcpurple_buddy_set_icon(PurpleConnection *gc, PurpleStoredImage *img) 1720 void silcpurple_buddy_set_icon(PurpleConnection *gc, PurpleStoredImage *img)
1721 { 1721 {
1722 SilcPurple sg = gc->proto_data; 1722 SilcPurple sg = purple_connection_get_protocol_data(gc);
1723 SilcClient client = sg->client; 1723 SilcClient client = sg->client;
1724 SilcClientConnection conn = sg->conn; 1724 SilcClientConnection conn = sg->conn;
1725 SilcMime mime; 1725 SilcMime mime;
1726 char type[32]; 1726 char type[32];
1727 const char *t; 1727 const char *t;