?? encrypt.c
字號:
} /* Not the one to resend: pitch it */ gaim_debug(GAIM_DEBUG_INFO, "gaim-encryption", " Deleted\n"); g_free(sent_msg_item->id); g_free(sent_msg_item->msg); g_free(sent_msg_item); } if (msg) { baggage_size = sprintf(baggage, msg_format, header, our_key->digest, his_key->digest, 10000, "", footer); GE_encrypt_signed(&crypt_msg, msg, our_key, his_key); msgsize = strlen(crypt_msg); out_msg = g_malloc(msgsize + baggage_size + 1); sprintf(out_msg, msg_format, header, our_key->digest, his_key->digest, msgsize, crypt_msg, footer); gaim_conversation_write(conv, 0, "Resending...", GAIM_MESSAGE_SYSTEM, time((time_t)NULL)); serv_send_im(conv->account->gc, name, out_msg, 0); gaim_debug(GAIM_DEBUG_INFO, "gaim-encryption", "resend_im: %s: %d\n", name, strlen(out_msg)); gaim_debug(GAIM_DEBUG_INFO, "gaim-encryption", "resend outgoing:%s:\n", out_msg); g_free(msg); g_free(out_msg); g_free(crypt_msg); } else { gaim_conversation_write(conv, 0, _("Outgoing message lost."), GAIM_MESSAGE_SYSTEM, time((time_t)NULL)); } } }static void GE_new_conv(GaimConversation *conv) { gaim_debug(GAIM_DEBUG_MISC, "gaim-encryption", "New conversation\n"); if ((conv != NULL) && (gaim_conversation_get_type(conv) == GAIM_CONV_IM)) { g_hash_table_insert(conv->data, g_strdup("sent messages"), g_queue_new()); g_hash_table_insert(conv->data, g_strdup("sent_capable"), FALSE); GE_add_buttons(conv); } else { gaim_debug(GAIM_DEBUG_ERROR, "gaim-encryption", "New conversation IS NULL\n"); }}static void GE_new_conv_cb(GaimConversation *conv, void* data) { GE_new_conv(conv);}static void GE_del_conv_cb(GaimConversation *conv, void* data){ GQueue *sent_msg_queue; if ((conv != NULL) && (gaim_conversation_get_type(conv) == GAIM_CONV_IM)) { gaim_debug(GAIM_DEBUG_MISC, "gaim-encryption", "Got conversation delete event for %s\n", conv->name); /* Remove cached copies of sent messages */ reap_all_sent_messages(conv); sent_msg_queue = g_hash_table_lookup(conv->data, "sent messages"); g_queue_free(sent_msg_queue); g_hash_table_remove(conv->data, "sent messages"); /* Remove to-be-sent-on-receipt-of-key messages: */ GE_delete_stored_msgs(conv->account, gaim_normalize(conv->account, conv->name)); GE_buddy_ring = GE_del_key_from_ring(GE_buddy_ring, gaim_normalize(conv->account, conv->name), conv->account); /* Would be good to add prefs for these, but for now, just reset: */ GE_reset_state(conv->account, conv->name); gaim_debug(GAIM_DEBUG_MISC, "gaim-encryption", "Finished conversation delete event for %s\n", conv->name); /* button widgets (hopefully) destroyed on window close */ /* hash table entries destroyed on hash table deletion, except */ /* for any dynamically allocated values (keys are ok). */ }} static void GE_headers_init() { header_table = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); footer_table = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); notify_table = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); g_hash_table_insert(header_table, g_strdup("prpl-toc"), g_strdup("*** Encrypted with the Gaim-Encryption plugin <A HREF=\"")); g_hash_table_insert(footer_table, g_strdup("prpl-toc"), g_strdup("\"></A>")); g_hash_table_insert(notify_table, g_strdup("prpl-toc"), g_strdup("<A HREF=\"Gaim-Encryption Capable\"></A>")); g_hash_table_insert(header_table, g_strdup("prpl-oscar"), g_strdup("*** Encrypted with the Gaim-Encryption plugin <A HREF=\"")); g_hash_table_insert(footer_table, g_strdup("prpl-oscar"), g_strdup("\"></A>")); g_hash_table_insert(notify_table, g_strdup("prpl-oscar"), g_strdup("<A HREF=\"Gaim-Encryption Capable\"></A>"));/* If jabber stops stripping HTML, we can go back to these headers *//* g_hash_table_insert(header_table, g_strdup("prpl-jabber"), *//* g_strdup("*** Encrypted with the Gaim-Encryption plugin <A HREF='")); *//* g_hash_table_insert(footer_table, g_strdup("prpl-jabber"), *//* g_strdup("'></A>")); *//* g_hash_table_insert(notify_table, g_strdup("prpl-jabber"), *//* g_strdup("<A HREF='Gaim-Encryption Capable'> </A>")); */ g_hash_table_insert(header_table, g_strdup("prpl-jabber"), g_strdup("*** Encrypted with the Gaim-Encryption plugin ")); g_hash_table_insert(footer_table, g_strdup("prpl-jabber"), g_strdup(" ")); g_hash_table_insert(notify_table, g_strdup("prpl-jabber"), g_strdup("<A HREF='Gaim-Encryption Capable'> </A>")); header_default = g_strdup("*** Encrypted :");}/* #define CRYPT_HEADER "*** Encrypted with the Gaim-Encryption plugin <A HREF=\"" *//* #define CRYPT_FOOTER "\"></A>" *//* #define CRYPT_NOTIFY_HEADER "<A HREF=\"Gaim-Encryption Capable\"></A>" */// Jabber seems to turn our double quotes into single quotes at times, so define// the same headers, only with single quotes. Lengths MUST be the same as above/* #define CRYPT_HEADER_MANGLED "*** Encrypted with the Gaim-Encryption plugin <A HREF='" *//* #define CRYPT_NOTIFY_HEADER_MANGLED "<A HREF='Gaim-Encryption Capable'></A>" */static void init_prefs() { /* These only add/set a pref if it doesn't currently exist: */ int default_width; if (gaim_prefs_get_type("/plugins/gtk/encrypt/accept_unknown_key") == GAIM_PREF_NONE) { /* First time loading the plugin, since we don't have our prefs set yet */ /* so up the default window width to accomodate new buttons */ default_width = gaim_prefs_get_int("/gaim/gtk/conversations/im/default_width"); if (default_width == 410) { /* the stock gaim default width */ gaim_prefs_set_int("/gaim/gtk/conversations/im/default_width", 490); } } gaim_prefs_add_none("/plugins/gtk"); gaim_prefs_add_none("/plugins/gtk/encrypt"); gaim_prefs_add_bool("/plugins/gtk/encrypt/accept_unknown_key", TRUE); gaim_prefs_add_bool("/plugins/gtk/encrypt/accept_conflicting_key", FALSE); gaim_prefs_add_bool("/plugins/gtk/encrypt/encrypt_response", TRUE); gaim_prefs_add_bool("/plugins/gtk/encrypt/broadcast_notify", FALSE); gaim_prefs_add_bool("/plugins/gtk/encrypt/encrypt_if_notified", TRUE); GE_convert_legacy_prefs();}/* Called by Gaim when plugin is first loaded */static gboolean GE_plugin_load(GaimPlugin *h) { void *conv_handle;#ifdef ENABLE_NLS bindtextdomain (ENC_PACKAGE, LOCALEDIR); bind_textdomain_codeset (ENC_PACKAGE, "UTF-8"); setlocale(LC_ALL, "");#endif if (strcmp(gaim_core_get_version(), VERSION) != 0) { gaim_debug(GAIM_DEBUG_ERROR, "gaim-encryption", "Compiled with Gaim v'%s', running with v'%s'.\n" VERSION, gaim_core_get_version()); /* GE_error_window(_("Gaim-Encryption plugin was compiled with a different " */ /* "version of Gaim. You may experience problems.")); */ } init_prefs(); conv_handle = gaim_conversations_get_handle(); gaim_debug(GAIM_DEBUG_INFO, "gaim-encryption", "plugin_load called\n"); GE_plugin_handle = h; GE_state_init(); GE_pixmap_init(); if (!rsa_nss_init()) { return FALSE; } GE_key_rings_init(); GE_nonce_map_init(); GE_headers_init(); gaim_signal_connect(conv_handle, "receiving-im-msg", h, GAIM_CALLBACK(GE_got_msg_cb), NULL); gaim_signal_connect(conv_handle, "sending-im-msg", h, GAIM_CALLBACK(GE_send_msg_cb), NULL); gaim_signal_connect(conv_handle, "conversation-created", h, GAIM_CALLBACK(GE_new_conv_cb), NULL); gaim_signal_connect(conv_handle, "deleting-conversation", h, GAIM_CALLBACK(GE_del_conv_cb), NULL); gaim_signal_connect(gaim_blist_get_handle(), "blist-node-extended-menu", h, GAIM_CALLBACK(GE_buddy_menu_cb), NULL); gaim_conversation_foreach(GE_add_buttons); gaim_debug(GAIM_DEBUG_MISC, "gaim-encryption", "done loading\n"); return TRUE;}/* Called by Gaim when plugin is removed */static gboolean GE_plugin_unload(GaimPlugin *h) { void * conv_handle = gaim_conversations_get_handle(); gaim_signal_disconnect(conv_handle, "receiving-im-msg", h, GAIM_CALLBACK(GE_got_msg_cb)); gaim_signal_disconnect(conv_handle, "sending-im-msg", h, GAIM_CALLBACK(GE_send_msg_cb)); gaim_signal_disconnect(conv_handle, "conversation-created", h, GAIM_CALLBACK(GE_new_conv_cb)); gaim_signal_disconnect(conv_handle, "deleting-conversation", h, GAIM_CALLBACK(GE_del_conv_cb)); gaim_signal_disconnect(gaim_blist_get_handle(), "blist-node-extended-menu", h, GAIM_CALLBACK(GE_buddy_menu_cb)); GE_config_unload(); gaim_conversation_foreach(GE_remove_buttons); GE_my_priv_ring = GE_clear_ring(GE_my_priv_ring); GE_my_pub_ring = GE_clear_ring(GE_my_pub_ring); GE_buddy_ring = GE_clear_ring(GE_buddy_ring); GE_state_delete(); return TRUE;}static GaimGtkPluginUiInfo ui_info ={ GE_get_config_frame};static GaimPluginInfo info ={ GAIM_PLUGIN_MAGIC, /**< I'm a plugin! */ GAIM_MAJOR_VERSION, GAIM_MINOR_VERSION, GAIM_PLUGIN_STANDARD, /**< type */ GAIM_GTK_PLUGIN_TYPE, /**< ui_requirement */ 0, /**< flags */ NULL, /**< dependencies */ GAIM_PRIORITY_DEFAULT, /**< priority */ ENCRYPT_PLUGIN_ID, /**< id */ 0, /**< name */ ENC_VERSION " (Gaim " VERSION ")", /**< version */ 0, /** summary */ 0, /** description */ 0, /**< author */ ENC_WEBSITE, /**< homepage */ GE_plugin_load, /**< load */ GE_plugin_unload, /**< unload */ NULL, /**< destroy */ &ui_info, /**< ui_info */ NULL, /**< extra_info */ NULL, /**< prefs_info */ NULL /**< actions */};static voidinit_plugin(GaimPlugin *plugin){#ifdef ENABLE_NLS bindtextdomain (ENC_PACKAGE, LOCALEDIR); bind_textdomain_codeset (ENC_PACKAGE, "UTF-8"); setlocale(LC_ALL, "");#endif info.name = _("Gaim-Encryption"); info.summary = _("Encrypts conversations with RSA encryption."); info.description = _("RSA encryption with keys up to 4096 bits," " using the Mozilla NSS crypto library.\n"); /* Translators: Feel free to add your name to the author field, with text like */ /* "Bill Tompkins, translation by Phil McGee" */ info.author = _("Bill Tompkins");}GAIM_INIT_PLUGIN(gaim_encryption, init_plugin, info);
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -