static void skypeweb_got_self_details(SkypeWebAccount *sa, JsonNode *node, gpointer user_data) { JsonObject *userobj; const gchar *old_alias; const gchar *displayname = NULL; const gchar *username; if (node == NULL || json_node_get_node_type(node) != JSON_NODE_OBJECT) return; userobj = json_node_get_object(node); username = json_object_get_string_member(userobj, "username"); g_free(sa->username); sa->username = g_strdup(username); old_alias = purple_account_get_private_alias(sa->account); if (!old_alias || !*old_alias) { if (json_object_has_member(userobj, "displayname")) displayname = json_object_get_string_member(userobj, "displayname"); if (!displayname || g_str_equal(displayname, username)) displayname = json_object_get_string_member(userobj, "firstname"); if (displayname) purple_account_set_private_alias(sa->account, displayname); } if (!PURPLE_CONNECTION_IS_CONNECTED(sa->pc)) { skypeweb_do_all_the_things(sa); } }
static void irc_connected(struct irc_conn *irc, const char *nick) { PurpleConnection *gc; PurpleStatus *status; PurpleBlistNode *gnode, *cnode, *bnode; if ((gc = purple_account_get_connection(irc->account)) == NULL || PURPLE_CONNECTION_IS_CONNECTED(gc)) return; purple_connection_set_display_name(gc, nick); purple_connection_set_state(gc, PURPLE_CONNECTED); /* If we're away then set our away message */ status = purple_account_get_active_status(irc->account); if (!purple_status_get_type(status) != PURPLE_STATUS_AVAILABLE) { PurplePluginProtocolInfo *prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl); prpl_info->set_status(irc->account, status); } /* this used to be in the core, but it's not now */ for (gnode = purple_get_blist()->root; gnode; gnode = gnode->next) { if(!PURPLE_BLIST_NODE_IS_GROUP(gnode)) continue; for(cnode = gnode->child; cnode; cnode = cnode->next) { if(!PURPLE_BLIST_NODE_IS_CONTACT(cnode)) continue; for(bnode = cnode->child; bnode; bnode = bnode->next) { PurpleBuddy *b; if(!PURPLE_BLIST_NODE_IS_BUDDY(bnode)) continue; b = (PurpleBuddy *)bnode; if(b->account == gc->account) { struct irc_buddy *ib = g_new0(struct irc_buddy, 1); ib->name = g_strdup(b->name); g_hash_table_insert(irc->buddies, ib->name, ib); } } } } irc_blist_timeout(irc); if (!irc->timer) irc->timer = purple_timeout_add_seconds(45, (GSourceFunc)irc_blist_timeout, (gpointer)irc); }
PurpleRoomlist *purple_roomlist_get_list(PurpleConnection *gc) { PurplePlugin *prpl = NULL; PurplePluginProtocolInfo *prpl_info = NULL; g_return_val_if_fail(gc != NULL, NULL); g_return_val_if_fail(PURPLE_CONNECTION_IS_CONNECTED(gc), NULL); prpl = purple_connection_get_prpl(gc); if(prpl != NULL) prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(prpl); if(prpl_info && prpl_info->roomlist_get_list) return prpl_info->roomlist_get_list(gc); return NULL; }
void execute_purple_plugin_action(PurpleConnection *gc, const std::string &name) { PurplePlugin *plugin = gc && PURPLE_CONNECTION_IS_CONNECTED(gc) ? gc->prpl : NULL; if (plugin && PURPLE_PLUGIN_HAS_ACTIONS(plugin)) { PurplePluginAction *action = NULL; GList *actions, *l; actions = PURPLE_PLUGIN_ACTIONS(plugin, gc); for (l = actions; l != NULL; l = l->next) { if (l->data) { action = (PurplePluginAction *) l->data; action->plugin = plugin; action->context = gc; if ((std::string) action->label == name) { action->callback(action); } purple_plugin_action_free(action); } } } }
static void reset_account_list(PurpleAccount *account) { GList *list; GntComboBox *accounts = GNT_COMBO_BOX(froomlist.accounts); gnt_combo_box_remove_all(accounts); for (list = purple_connections_get_all(); list; list = list->next) { PurplePluginProtocolInfo *prpl_info = NULL; PurpleConnection *gc = list->data; prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(purple_connection_get_prpl(gc)); if (PURPLE_CONNECTION_IS_CONNECTED(gc) && prpl_info->roomlist_get_list != NULL) { PurpleAccount *account = purple_connection_get_account(gc); char *text = g_strdup_printf("%s (%s)", purple_account_get_username(account), purple_account_get_protocol_name(account)); gnt_combo_box_add_data(accounts, account, text); g_free(text); } } }