void AccountWindow::ProtocolOption::onProtocolChanged(ComboBox& /*activator*/, size_t /*new_entry*/, const char* /*title*/, intptr_t data) { purple_account_set_protocol_id(account, purple_plugin_get_id( reinterpret_cast<PurplePlugin*>(data))); // this deletes us so don't touch any instance variable after account_window->populateAccount(account); }
void AccountWindow::addAccount(CppConsUI::Button& /*activator*/) { GList *i = purple_plugins_get_protocols(); PurpleAccount *account = purple_account_new(_("Username"), purple_plugin_get_id(reinterpret_cast<PurplePlugin*>(i->data))); /* Stop here if libpurple returned an already created account. This happens * when user pressed Add button twice in a row. In that case there is * already one "empty" account that user can edit. */ if (account_entries.find(account) == account_entries.end()) { purple_accounts_add(account); populateAccount(account); } account_entries[account].parent->grabFocus(); }
static gboolean xmpp_uri_handler(const char *proto, const char *user, GHashTable *params) { char *acct_id = params ? g_hash_table_lookup(params, "account") : NULL; PurpleAccount *acct; if (g_ascii_strcasecmp(proto, "xmpp")) return FALSE; acct = find_acct(purple_plugin_get_id(my_protocol), acct_id); if (!acct) return FALSE; /* xmpp:[email protected]?message;subject=Test%20Message;body=Here%27s%20a%20test%20message */ /* params is NULL if the URI has no '?' (or anything after it) */ if (!params || g_hash_table_lookup_extended(params, "message", NULL, NULL)) { char *body = g_hash_table_lookup(params, "body"); if (user && *user) { PurpleConversation *conv = purple_conversation_new(PURPLE_CONV_TYPE_IM, acct, user); purple_conversation_present(conv); if (body && *body) purple_conv_send_confirm(conv, body); } } else if (g_hash_table_lookup_extended(params, "roster", NULL, NULL)) { char *name = g_hash_table_lookup(params, "name"); if (user && *user) purple_blist_request_add_buddy(acct, user, NULL, name); } else if (g_hash_table_lookup_extended(params, "join", NULL, NULL)) { PurpleConnection *gc = purple_account_get_connection(acct); if (user && *user) { GHashTable *params = jabber_chat_info_defaults(gc, user); jabber_chat_join(gc, params); } return TRUE; } return FALSE; }
static gboolean yahoo_uri_handler(const char *proto, const char *cmd, GHashTable *params) { char *acct_id = g_hash_table_lookup(params, "account"); PurpleAccount *acct; if (g_ascii_strcasecmp(proto, "ymsgr")) return FALSE; acct = find_acct(purple_plugin_get_id(my_protocol), acct_id); if (!acct) return FALSE; /* ymsgr:SendIM?screename&m=The+Message */ if (!g_ascii_strcasecmp(cmd, "SendIM")) { char *sname = NULL; g_hash_table_foreach(params, yahoo_find_uri_novalue_param, &sname); if (sname) { char *message = g_hash_table_lookup(params, "m"); PurpleConversation *conv = purple_find_conversation_with_account( PURPLE_CONV_TYPE_IM, sname, acct); if (conv == NULL) conv = purple_conversation_new(PURPLE_CONV_TYPE_IM, acct, sname); purple_conversation_present(conv); if (message) { /* Spaces are encoded as '+' */ g_strdelimit(message, "+", ' '); purple_conv_send_confirm(conv, message); } } /* else **If pidgindialogs_im() was in the core, we could use it here. * It is all purple_request_* based, but I'm not sure it really belongs in the core pidgindialogs_im(); */ return TRUE; } /* ymsgr:Chat?roomname */ else if (!g_ascii_strcasecmp(cmd, "Chat")) { char *rname = NULL; g_hash_table_foreach(params, yahoo_find_uri_novalue_param, &rname); if (rname) { /* This is somewhat hacky, but the params aren't useful after this command */ g_hash_table_insert(params, g_strdup("room"), g_strdup(rname)); g_hash_table_insert(params, g_strdup("type"), g_strdup("Chat")); serv_join_chat(purple_account_get_connection(acct), params); } /* else ** Same as above (except that this would have to be re-written using purple_request_*) pidgin_blist_joinchat_show(); */ return TRUE; } /* ymsgr:AddFriend?name */ else if (!g_ascii_strcasecmp(cmd, "AddFriend")) { char *name = NULL; g_hash_table_foreach(params, yahoo_find_uri_novalue_param, &name); purple_blist_request_add_buddy(acct, name, NULL, NULL); return TRUE; } return FALSE; }