/* Get method for GObject properties */ static void purple_counting_node_get_property(GObject *obj, guint param_id, GValue *value, GParamSpec *pspec) { PurpleCountingNode *node = PURPLE_COUNTING_NODE(obj); switch (param_id) { case CNODE_PROP_TOTAL_SIZE: g_value_set_int(value, purple_counting_node_get_total_size(node)); break; case CNODE_PROP_CURRENT_SIZE: g_value_set_int(value, purple_counting_node_get_current_size(node)); break; case CNODE_PROP_ONLINE_COUNT: g_value_set_int(value, purple_counting_node_get_online_count(node)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec); break; } }
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); }