/** * \brief Remove created contacts-files * * This function removes the contacts-files for each account. It should be called on exit. */ void mimoc_buddy_list_clean_up() { g_list_foreach( purple_accounts_get_all(), (GFunc) &remove_accounts_contacts_file, NULL ); g_slist_foreach( purple_blist_get_buddies(), (GFunc) &remove_buddys_status_message_file, NULL ); }
void IMInvoker::invoke(void *userdata, const std::string event) { _accountMutex.lock(); EventContext* ctx = (EventContext*)userdata; IMInvoker* instance = ctx->instance; std::string username; Event::getParam(ctx->invokeReq.params, "username", username); std::string protocolId; Event::getParam(ctx->invokeReq.params, "protocol", protocolId); std::string password; Event::getParam(ctx->invokeReq.params, "password", password); instance->_account = purple_account_new(username.c_str(), protocolId.c_str()); _accountInstances[instance->_account] = instance; #if LIBPURPLE_VERSION_MAJOR >= 3 purple_account_set_password(instance->_account, password.c_str(), NULL, NULL); #else purple_account_set_password(instance->_account, password.c_str()); #endif purple_account_set_enabled(instance->_account, "uscxml", true); GSList* buddies = purple_blist_get_buddies(); GSList *cur; for (cur = buddies; cur; cur = cur->next) { std::string buddyName = purple_buddy_get_name((PurpleBuddy *)cur->data); Data buddyData = buddyToData((PurpleBuddy *)cur->data); instance->_dataModelVars.compound["buddies"].compound[buddyName] = buddyData; } g_slist_free(buddies); delete(ctx); _accountMutex.unlock(); }
static void send_online_buddy_cb (PurpleBlistNode *cnode, gpointer data) { PurplePlugin *plugin = (PurplePlugin *)data; PurpleConnection *gc; GSList *blist; PurpleBlistNode *gnode, *node; PurpleBuddy *b, *buddy; PurpleGroup *g, *check_group; const char *name, *gname, *receiver; int count = 0; PurpleAccount *account; PurpleIMConversation *im; gchar *buddylist = NULL; int total, flag = 0, counter = 0; gchar *group_info; const gchar *groupname = purple_group_get_name(data); purple_debug_info("send-option", "The group selected is: %s", groupname); buddy = (PurpleBuddy *)cnode; purple_debug_info("send-option", "Inside send_online_buddy_cb"); receiver = purple_buddy_get_name(buddy); purple_debug_info("send-option", "Receiver name: %s", receiver); account = purple_buddy_get_account(buddy); gc = purple_account_get_connection(account); im = purple_conversations_find_im_with_account(receiver, purple_connection_get_account(gc)); if(im) purple_debug_info("send-option", "Yayy, IM!"); else purple_debug_info("send-option", "Boo! No IM :("); if (im == NULL) im = purple_im_conversation_new(purple_connection_get_account(gc), receiver); for(gnode = purple_blist_get_buddy_list()->root; gnode != NULL; gnode = gnode->next) { if (PURPLE_IS_GROUP(gnode)) { g = (PurpleGroup*)gnode; /*fishy. It says g may be uninitiliazed here. What can I initilalie g to in the else, to get rid of the warning*/ if (g != data) continue; else break; } } gname = purple_group_get_name(g); total = purple_counting_node_get_online_count(PURPLE_COUNTING_NODE(g));; purple_debug_info("send-option", "%s (%d): \n",gname, total); group_info = g_strdup_printf("%s (%d):\n",gname, total); buddylist = g_strconcat(group_info, "\t","\t", NULL); for (blist = purple_blist_get_buddies(); blist != NULL; blist = blist->next) { node = blist->data; if (PURPLE_IS_BUDDY(node)) { b = (PurpleBuddy*)node; name = purple_buddy_get_alias(b); check_group = purple_buddy_get_group(b); if (data == check_group && PURPLE_BUDDY_IS_ONLINE(b)) { ++count; ++counter; if (flag == 1 && counter != total) { buddylist = g_strconcat(name, ",\t", NULL); flag = 0; } else if (flag == 1 && counter == total) { buddylist = g_strconcat(name, ".\t", NULL); purple_debug_info(NULL, "%s", buddylist); purple_conversation_send(PURPLE_CONVERSATION(im), buddylist); buddylist = NULL; count = 0; } else{ if (count <= 20 && counter != total) { buddylist = g_strconcat(buddylist, name, ",\t", NULL); /*fishy cant insert newline*/ } else { if (counter == total) buddylist = g_strconcat(buddylist, name, ".\t", NULL); else buddylist = g_strconcat(buddylist, name, ",\t", NULL); purple_debug_info(NULL, "%s", buddylist); purple_conversation_send(PURPLE_CONVERSATION(im), buddylist); buddylist = NULL; count = 0; flag = 1; } } } } } purple_debug_info("send-option", "The counter is (%d): \n",counter); purple_notify_message (plugin, PURPLE_NOTIFY_MSG_INFO, "Send online buddies", "Successfully sent your online buddies :)", NULL, NULL, NULL, NULL); g_free(buddylist); }