Mercurial > pidgin
diff libpurple/protocols/silc/silc.c @ 32819:2c6510167895 default tip
propagate from branch 'im.pidgin.pidgin.2.x.y' (head 3315c5dfbd0ad16511bdcf865e5b07c02d07df24)
to branch 'im.pidgin.pidgin' (head cbd1eda6bcbf0565ae7766396bb8f6f419cb6a9a)
author | Elliott Sales de Andrade <qulogic@pidgin.im> |
---|---|
date | Sat, 02 Jun 2012 02:30:49 +0000 |
parents | f07501af8bae |
children |
line wrap: on
line diff
--- a/libpurple/protocols/silc/silc.c Sat Jun 02 02:30:13 2012 +0000 +++ b/libpurple/protocols/silc/silc.c Sat Jun 02 02:30:49 2012 +0000 @@ -78,7 +78,7 @@ const char *state; if (gc != NULL) - sg = gc->proto_data; + sg = purple_connection_get_protocol_data(gc); if (status == NULL) return; @@ -125,7 +125,7 @@ static void silcpurple_keepalive(PurpleConnection *gc) { - SilcPurple sg = gc->proto_data; + SilcPurple sg = purple_connection_get_protocol_data(gc); silc_packet_send(sg->conn->stream, SILC_PACKET_HEARTBEAT, 0, NULL, 0); } @@ -180,7 +180,7 @@ { SilcClient client = (SilcClient)context; PurpleConnection *gc = client->application; - SilcPurple sg = gc->proto_data; + SilcPurple sg = purple_connection_get_protocol_data(gc); SilcPurpleTask ptask = NULL; if (added) { @@ -252,7 +252,7 @@ struct utsname u; #endif - sg = gc->proto_data; + sg = purple_connection_get_protocol_data(gc); switch (status) { case SILC_CLIENT_CONN_SUCCESS: @@ -316,7 +316,7 @@ /* Close the connection */ if (!sg->detaching) - purple_connection_error_reason(gc, + purple_connection_error(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, _("Disconnected by server")); else @@ -325,30 +325,30 @@ break; case SILC_CLIENT_CONN_ERROR: - purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, + purple_connection_error(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, _("Error connecting to SILC Server")); g_unlink(silcpurple_session_file(purple_account_get_username(sg->account))); break; case SILC_CLIENT_CONN_ERROR_KE: - purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_ENCRYPTION_ERROR, + purple_connection_error(gc, PURPLE_CONNECTION_ERROR_ENCRYPTION_ERROR, _("Key Exchange failed")); break; case SILC_CLIENT_CONN_ERROR_AUTH: - purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED, + purple_connection_error(gc, PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED, _("Authentication failed")); break; case SILC_CLIENT_CONN_ERROR_RESUME: - purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_OTHER_ERROR, + purple_connection_error(gc, PURPLE_CONNECTION_ERROR_OTHER_ERROR, _("Resuming detached session failed. " "Press Reconnect to create new connection.")); g_unlink(silcpurple_session_file(purple_account_get_username(sg->account))); break; case SILC_CLIENT_CONN_ERROR_TIMEOUT: - purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, + purple_connection_error(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, _("Connection timed out")); break; } @@ -367,16 +367,16 @@ SilcClientConnectionParams params; const char *dfile; - sg = gc->proto_data; + sg = purple_connection_get_protocol_data(gc); if (status != SILC_SOCKET_OK) { - purple_connection_error_reason(gc, + purple_connection_error(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, _("Connection failed")); silc_pkcs_public_key_free(sg->public_key); silc_pkcs_private_key_free(sg->private_key); silc_free(sg); - gc->proto_data = NULL; + purple_connection_set_protocol_data(gc, NULL); return; } @@ -400,7 +400,7 @@ } /* Perform SILC Key Exchange. */ - silc_client_key_exchange(sg->client, ¶ms, sg->public_key, + silc_client_key_exchange(client, ¶ms, sg->public_key, sg->private_key, stream, SILC_CONN_SERVER, silcpurple_connect_cb, gc); @@ -415,15 +415,15 @@ g_return_if_fail(gc != NULL); - sg = gc->proto_data; + sg = purple_connection_get_protocol_data(gc); if (source < 0) { - purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, + purple_connection_error(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, _("Connection failed")); silc_pkcs_public_key_free(sg->public_key); silc_pkcs_private_key_free(sg->private_key); silc_free(sg); - gc->proto_data = NULL; + purple_connection_set_protocol_data(gc, NULL); return; } @@ -447,9 +447,9 @@ purple_account_get_int(account, "port", 706), silcpurple_login_connected, gc) == NULL) { - purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, + purple_connection_error(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, _("Unable to connect")); - gc->proto_data = NULL; + purple_connection_set_protocol_data(gc, NULL); silc_free(sg); return; } @@ -457,7 +457,7 @@ static void silcpurple_got_password_cb(PurpleConnection *gc, PurpleRequestFields *fields) { - SilcPurple sg = (SilcPurple)gc->proto_data; + SilcPurple sg = purple_connection_get_protocol_data(gc); PurpleAccount *account = purple_connection_get_account(gc); char pkd[256], prd[256]; const char *password; @@ -473,7 +473,7 @@ if (!password || !*password) { purple_notify_error(gc, NULL, _("Password is required to sign on."), NULL); - gc->proto_data = NULL; + purple_connection_set_protocol_data(gc, NULL); silc_free(sg); return; } @@ -490,9 +490,9 @@ (char *)purple_account_get_string(account, "private-key", prd), password, &sg->public_key, &sg->private_key)) { - purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_OTHER_ERROR, + purple_connection_error(gc, PURPLE_CONNECTION_ERROR_OTHER_ERROR, _("Unable to load SILC key pair")); - gc->proto_data = NULL; + purple_connection_set_protocol_data(gc, NULL); silc_free(sg); return; } @@ -505,10 +505,10 @@ /* The password prompt dialog doesn't get disposed if the account disconnects */ if (!PURPLE_CONNECTION_IS_VALID(gc)) return; - sg = gc->proto_data; - purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_OTHER_ERROR, + sg = purple_connection_get_protocol_data(gc); + purple_connection_error(gc, PURPLE_CONNECTION_ERROR_OTHER_ERROR, _("Unable to load SILC key pair")); - gc->proto_data = NULL; + purple_connection_set_protocol_data(gc, NULL); silc_free(sg); } @@ -528,16 +528,16 @@ g_snprintf(prd, sizeof(prd), "%s" G_DIR_SEPARATOR_S "private_key.prv", silcpurple_silcdir()); if (!silc_load_key_pair((char *)purple_account_get_string(account, "public-key", pkd), (char *)purple_account_get_string(account, "private-key", prd), - (gc->password == NULL) ? "" : gc->password, + (purple_connection_get_password(gc) == NULL) ? "" : purple_connection_get_password(gc), &sg->public_key, &sg->private_key)) { if (!purple_account_get_password(account)) { purple_account_request_password(account, G_CALLBACK(silcpurple_got_password_cb), G_CALLBACK(silcpurple_no_password_cb), gc); return; } - purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_OTHER_ERROR, + purple_connection_error(gc, PURPLE_CONNECTION_ERROR_OTHER_ERROR, _("Unable to load SILC key pair")); - gc->proto_data = NULL; + purple_connection_set_protocol_data(gc, NULL); silc_free(sg); return; } @@ -555,10 +555,10 @@ char *username, *hostname, *realname, **up; int i; - gc = account->gc; + gc = purple_account_get_connection(account); if (!gc) return; - gc->proto_data = NULL; + purple_connection_set_protocol_data(gc, NULL); memset(¶ms, 0, sizeof(params)); strcat(params.nickname_format, "%n#a"); @@ -566,7 +566,7 @@ /* Allocate SILC client */ client = silc_client_alloc(&ops, ¶ms, gc, NULL); if (!client) { - purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_OTHER_ERROR, + purple_connection_error(gc, PURPLE_CONNECTION_ERROR_OTHER_ERROR, _("Out of memory")); return; } @@ -612,14 +612,14 @@ sg->client = client; sg->gc = gc; sg->account = account; - gc->proto_data = sg; + purple_connection_set_protocol_data(gc, sg); /* Init SILC client */ if (!silc_client_init(client, username, hostname, realname, silcpurple_running, sg)) { - purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_OTHER_ERROR, + purple_connection_error(gc, PURPLE_CONNECTION_ERROR_OTHER_ERROR, _("Unable to initialize SILC protocol")); - gc->proto_data = NULL; + purple_connection_set_protocol_data(gc, NULL); silc_free(sg); silc_free(hostname); g_free(username); @@ -630,9 +630,9 @@ /* Check the ~/.silc dir and create it, and new key pair if necessary. */ if (!silcpurple_check_silc_dir(gc)) { - purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_OTHER_ERROR, + purple_connection_error(gc, PURPLE_CONNECTION_ERROR_OTHER_ERROR, _("Error loading SILC key pair")); - gc->proto_data = NULL; + purple_connection_set_protocol_data(gc, NULL); silc_free(sg); return; } @@ -669,7 +669,7 @@ static void silcpurple_close(PurpleConnection *gc) { - SilcPurple sg = gc->proto_data; + SilcPurple sg = purple_connection_get_protocol_data(gc); #if __SILC_TOOLKIT_VERSION >= SILC_VERSION(1,1,1) SilcPurpleTask task; #endif /* __SILC_TOOLKIT_VERSION */ @@ -733,7 +733,7 @@ static void silcpurple_attrs_cb(PurpleConnection *gc, PurpleRequestFields *fields) { - SilcPurple sg = gc->proto_data; + SilcPurple sg = purple_connection_get_protocol_data(gc); SilcClient client = sg->client; SilcClientConnection conn = sg->conn; PurpleRequestField *f; @@ -744,7 +744,7 @@ SilcVCardStruct vcard; const char *val; - sg = gc->proto_data; + sg = purple_connection_get_protocol_data(gc); if (!sg) return; @@ -905,7 +905,7 @@ silcpurple_attrs(PurplePluginAction *action) { PurpleConnection *gc = (PurpleConnection *) action->context; - SilcPurple sg = gc->proto_data; + SilcPurple sg = purple_connection_get_protocol_data(gc); SilcClient client = sg->client; SilcClientConnection conn = sg->conn; PurpleRequestFields *fields; @@ -922,7 +922,7 @@ gboolean device = TRUE; char status[1024], tz[16]; - sg = gc->proto_data; + sg = purple_connection_get_protocol_data(gc); if (!sg) return; @@ -1061,7 +1061,7 @@ fields, _("OK"), G_CALLBACK(silcpurple_attrs_cb), _("Cancel"), G_CALLBACK(silcpurple_attrs_cancel), - gc->account, NULL, NULL, gc); + purple_connection_get_account(gc), NULL, NULL, gc); } static void @@ -1072,7 +1072,7 @@ if (!gc) return; - sg = gc->proto_data; + sg = purple_connection_get_protocol_data(gc); if (!sg) return; @@ -1090,7 +1090,7 @@ if (!gc) return; - sg = gc->proto_data; + sg = purple_connection_get_protocol_data(gc); if (!sg) return; @@ -1125,7 +1125,7 @@ int keylen = SILCPURPLE_DEF_PKCS_LEN; SilcPublicKey public_key; - sg = gc->proto_data; + sg = purple_connection_get_protocol_data(gc); if (!sg) return; @@ -1208,7 +1208,7 @@ silcpurple_create_keypair(PurplePluginAction *action) { PurpleConnection *gc = (PurpleConnection *) action->context; - SilcPurple sg = gc->proto_data; + SilcPurple sg = purple_connection_get_protocol_data(gc); PurpleRequestFields *fields; PurpleRequestFieldGroup *g; PurpleRequestField *f; @@ -1226,9 +1226,9 @@ g_snprintf(pkd2, sizeof(pkd2), "%s" G_DIR_SEPARATOR_S"public_key.pub", silcpurple_silcdir()); g_snprintf(prd2, sizeof(prd2), "%s" G_DIR_SEPARATOR_S"private_key.prv", silcpurple_silcdir()); g_snprintf(pkd, sizeof(pkd) - 1, "%s", - purple_account_get_string(gc->account, "public-key", pkd2)); + purple_account_get_string(purple_connection_get_account(gc), "public-key", pkd2)); g_snprintf(prd, sizeof(prd) - 1, "%s", - purple_account_get_string(gc->account, "private-key", prd2)); + purple_account_get_string(purple_connection_get_account(gc), "private-key", prd2)); fields = purple_request_fields_new(); @@ -1269,7 +1269,7 @@ _("Create New SILC Key Pair"), NULL, fields, _("Generate Key Pair"), G_CALLBACK(silcpurple_create_keypair_cb), _("Cancel"), G_CALLBACK(silcpurple_create_keypair_cancel), - gc->account, NULL, NULL, gc); + purple_connection_get_account(gc), NULL, NULL, gc); g_strfreev(u); silc_free(hostname); @@ -1287,7 +1287,7 @@ { char prd[256]; g_snprintf(prd, sizeof(prd), "%s" G_DIR_SEPARATOR_S "private_key.pub", silcpurple_silcdir()); - silc_change_private_key_passphrase(purple_account_get_string(gc->account, + silc_change_private_key_passphrase(purple_account_get_string(purple_connection_get_account(gc), "private-key", prd), old ? old : "", new ? new : ""); } @@ -1356,7 +1356,7 @@ void *context) { PurpleConnection *gc = client->application; - SilcPurple sg = gc->proto_data; + SilcPurple sg = purple_connection_get_protocol_data(gc); SilcPurpleIM im = context; PurpleConversation *convo; char tmp[256]; @@ -1433,7 +1433,7 @@ silcpurple_send_im(PurpleConnection *gc, const char *who, const char *message, PurpleMessageFlags flags) { - SilcPurple sg = gc->proto_data; + SilcPurple sg = purple_connection_get_protocol_data(gc); SilcClient client = sg->client; SilcClientConnection conn = sg->conn; SilcDList clients; @@ -1548,14 +1548,14 @@ PurpleConversation *convo = conv; int id = 0; - gc = purple_conversation_get_gc(conv); + gc = purple_conversation_get_connection(conv); if (gc == NULL) return PURPLE_CMD_RET_FAILED; if(args && args[0]) convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, args[0], - gc->account); + purple_connection_get_account(gc)); if (convo != NULL) id = purple_conv_chat_get_id(PURPLE_CONV_CHAT(convo)); @@ -1577,7 +1577,7 @@ char *buf, *tmp, *tmp2; const char *topic; - gc = purple_conversation_get_gc(conv); + gc = purple_conversation_get_connection(conv); id = purple_conv_chat_get_id(PURPLE_CONV_CHAT(conv)); if (gc == NULL || id == 0) @@ -1593,7 +1593,7 @@ g_free(tmp2); } else buf = g_strdup(_("No topic is set")); - purple_conv_chat_write(PURPLE_CONV_CHAT(conv), gc->account->username, buf, + purple_conv_chat_write(PURPLE_CONV_CHAT(conv), purple_account_get_username(purple_connection_get_account(gc)), buf, PURPLE_MESSAGE_SYSTEM|PURPLE_MESSAGE_NO_LOG, time(NULL)); g_free(buf); @@ -1623,7 +1623,7 @@ if(args[1]) g_hash_table_replace(comp, "passphrase", args[1]); - silcpurple_chat_join(purple_conversation_get_gc(conv), comp); + silcpurple_chat_join(purple_conversation_get_connection(conv), comp); g_hash_table_destroy(comp); return PURPLE_CMD_RET_OK; @@ -1633,7 +1633,7 @@ const char *cmd, char **args, char **error, void *data) { PurpleConnection *gc; - gc = purple_conversation_get_gc(conv); + gc = purple_conversation_get_connection(conv); purple_roomlist_show_with_account(purple_connection_get_account(gc)); return PURPLE_CMD_RET_OK; } @@ -1643,7 +1643,7 @@ { PurpleConnection *gc; - gc = purple_conversation_get_gc(conv); + gc = purple_conversation_get_connection(conv); if (gc == NULL) return PURPLE_CMD_RET_FAILED; @@ -1659,7 +1659,7 @@ int ret; PurpleConnection *gc; - gc = purple_conversation_get_gc(conv); + gc = purple_conversation_get_connection(conv); if (gc == NULL) return PURPLE_CMD_RET_FAILED; @@ -1685,7 +1685,7 @@ return PURPLE_CMD_RET_FAILED; } - gc = purple_conversation_get_gc(conv); + gc = purple_conversation_get_connection(conv); if (gc == NULL) return PURPLE_CMD_RET_FAILED; @@ -1713,12 +1713,12 @@ SilcPurple sg; char *tmp; - gc = purple_conversation_get_gc(conv); + gc = purple_conversation_get_connection(conv); if (gc == NULL) return PURPLE_CMD_RET_FAILED; - sg = gc->proto_data; + sg = purple_connection_get_protocol_data(gc); if (sg == NULL) return PURPLE_CMD_RET_FAILED; @@ -1742,12 +1742,12 @@ PurpleConnection *gc; SilcPurple sg; - gc = purple_conversation_get_gc(conv); + gc = purple_conversation_get_connection(conv); if (gc == NULL) return PURPLE_CMD_RET_FAILED; - sg = gc->proto_data; + sg = purple_connection_get_protocol_data(gc); if (sg == NULL) return PURPLE_CMD_RET_FAILED; @@ -1767,12 +1767,12 @@ char *silccmd, *silcargs, *msg, tmp[256]; const char *chname; - gc = purple_conversation_get_gc(conv); + gc = purple_conversation_get_connection(conv); - if (gc == NULL || !args || gc->proto_data == NULL) + if (gc == NULL || !args || purple_connection_get_protocol_data(gc) == NULL) return PURPLE_CMD_RET_FAILED; - sg = gc->proto_data; + sg = purple_connection_get_protocol_data(gc); if (args[0]) chname = args[0]; @@ -1818,12 +1818,12 @@ SilcPurple sg; char *silccmd, *silcargs; - gc = purple_conversation_get_gc(conv); + gc = purple_conversation_get_connection(conv); if (gc == NULL) return PURPLE_CMD_RET_FAILED; - sg = gc->proto_data; + sg = purple_connection_get_protocol_data(gc); if (sg == NULL) return PURPLE_CMD_RET_FAILED; @@ -1850,12 +1850,12 @@ const char *ui_name = NULL, *ui_website = NULL; char *quit_msg; - gc = purple_conversation_get_gc(conv); + gc = purple_conversation_get_connection(conv); if (gc == NULL) return PURPLE_CMD_RET_FAILED; - sg = gc->proto_data; + sg = purple_connection_get_protocol_data(gc); if (sg == NULL) return PURPLE_CMD_RET_FAILED; @@ -1887,12 +1887,12 @@ PurpleConnection *gc; SilcPurple sg; - gc = purple_conversation_get_gc(conv); + gc = purple_conversation_get_connection(conv); if (gc == NULL) return PURPLE_CMD_RET_FAILED; - sg = gc->proto_data; + sg = purple_connection_get_protocol_data(gc); if (sg == NULL) return PURPLE_CMD_RET_FAILED; @@ -2050,6 +2050,7 @@ static PurplePluginProtocolInfo prpl_info = { + sizeof(PurplePluginProtocolInfo), /* struct_size */ OPT_PROTO_CHAT_TOPIC | OPT_PROTO_UNIQUE_CHATNAME | OPT_PROTO_PASSWORD_OPTIONAL | OPT_PROTO_IM_IMAGE | OPT_PROTO_SLASH_COMMANDS_NATIVE, @@ -2092,7 +2093,6 @@ silcpurple_keepalive, /* keepalive */ NULL, /* register_user */ NULL, /* get_cb_info */ - NULL, /* get_cb_away */ NULL, /* alias_buddy */ NULL, /* group_buddy */ NULL, /* rename_group */ @@ -2117,15 +2117,12 @@ NULL, /* unregister_user */ NULL, /* send_attention */ NULL, /* get_attention_types */ - sizeof(PurplePluginProtocolInfo), /* struct_size */ NULL, /* get_account_text_table */ NULL, /* initiate_media */ NULL, /* get_media_caps */ NULL, /* get_moods */ NULL, /* set_public_alias */ - NULL, /* get_public_alias */ - NULL, /* add_buddy_with_invite */ - NULL /* add_buddies_with_invite */ + NULL /* get_public_alias */ }; static PurplePluginInfo info =