static gboolean plugin_load(PurplePlugin *plugin, GError **error) { purple_prefs_add_none("/plugins/gtk"); purple_prefs_add_none("/plugins/gtk/win32"); purple_prefs_add_none("/plugins/gtk/win32/winprefs"); purple_prefs_add_bool(PREF_DBLIST_DOCKABLE, FALSE); purple_prefs_add_bool(PREF_DBLIST_DOCKED, FALSE); purple_prefs_add_int(PREF_DBLIST_HEIGHT, 0); purple_prefs_add_int(PREF_DBLIST_SIDE, 0); /* Convert old preferences */ if(purple_prefs_exists(PREF_DBLIST_ON_TOP)) { gint blist_top = BLIST_TOP_NEVER; if(purple_prefs_get_bool(PREF_BLIST_ON_TOP)) blist_top = BLIST_TOP_ALWAYS; else if(purple_prefs_get_bool(PREF_DBLIST_ON_TOP)) blist_top = BLIST_TOP_DOCKED; purple_prefs_remove(PREF_BLIST_ON_TOP); purple_prefs_remove(PREF_DBLIST_ON_TOP); purple_prefs_add_int(PREF_BLIST_ON_TOP, blist_top); } else purple_prefs_add_int(PREF_BLIST_ON_TOP, BLIST_TOP_NEVER); purple_prefs_remove(PREF_CHAT_BLINK); handle = plugin; /* blist docking init */ if(purple_blist_get_buddy_list() && PIDGIN_BLIST(purple_blist_get_buddy_list()) && PIDGIN_BLIST(purple_blist_get_buddy_list())->window) { blist_create_cb(purple_blist_get_buddy_list(), NULL); } /* This really shouldn't happen anymore generally, but if for some strange reason, the blist is recreated, we need to set it up again. */ purple_signal_connect(pidgin_blist_get_handle(), "gtkblist-created", plugin, PURPLE_CALLBACK(blist_create_cb), NULL); purple_signal_connect((void*)purple_get_core(), "quitting", plugin, PURPLE_CALLBACK(purple_quit_cb), NULL); purple_prefs_connect_callback(handle, PREF_BLIST_ON_TOP, winprefs_set_blist_ontop, NULL); purple_prefs_connect_callback(handle, PREF_DBLIST_DOCKABLE, winprefs_set_blist_dockable, NULL); return TRUE; }
static void use_icon_theme(GtkWidget *w, GtkWidget *window) { /* I don't quite understand the icon-theme stuff. For example, I don't * know why PidginIconTheme needs to be abstract, or how PidginStatusIconTheme * would be different from other PidginIconTheme's (e.g. PidginStockIconTheme) * etc., but anyway, this works for now. * * Here's an interesting note: A PidginStatusIconTheme can be used for both * stock and status icons. Like I said, I don't quite know how they could be * different. So I am going to just keep it as it is, for now anyway, until I * have the time to dig through this, or someone explains this stuff to me * clearly. * -- Sad */ PidginStatusIconTheme *theme = create_icon_theme(window); pidgin_stock_load_status_icon_theme(PIDGIN_STATUS_ICON_THEME(theme)); pidgin_stock_load_stock_icon_theme((PidginStockIconTheme *)theme); pidgin_blist_refresh(purple_blist_get_buddy_list()); g_object_unref(theme); }
static void blist_set_ontop(gboolean val) { if(!blist) return; gtk_window_set_keep_above(GTK_WINDOW(PIDGIN_BLIST(purple_blist_get_buddy_list())->window), val); }
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); }
static void send_group_list_cb (PurpleBlistNode *cnode, gpointer data) { PurplePlugin *plugin = (PurplePlugin *)data; PurpleBuddy *buddy; const char *receiver, *gname = NULL; PurpleAccount *account; PurpleIMConversation *im; PurpleConnection *gc; PurpleBlistNode *gnode; PurpleGroup *g; gchar *grouptotal, *grouplist = NULL; int count = 0, counter = 0, flag = 0, total = 0; buddy = (PurpleBuddy *)cnode; purple_debug_info("send-option", "Inside send_group_list_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)) { ++total; grouptotal = g_strdup_printf("Groups (%d):\n", total); grouplist = g_strconcat(grouptotal, gname, ",\t", NULL); } } for(gnode = purple_blist_get_buddy_list()->root; gnode != NULL; gnode = gnode->next) { if (PURPLE_IS_GROUP(gnode)) { g = (PurpleGroup*)gnode; gname = purple_group_get_name(g); purple_debug_info("send-option", " Group checked: %s \n",gname); ++count; ++counter; if (flag == 1 && counter != total) { grouplist = g_strconcat(gname, ",\t", NULL); flag = 0; } else if (flag == 1 && counter == total) { grouplist = g_strconcat(gname, ".\t", NULL); purple_debug_info(NULL, "%s", grouplist); purple_conversation_send(PURPLE_CONVERSATION(im), grouplist); grouplist = NULL; count = 0; } else{ if (count <= 20 && counter != total) { grouplist = g_strconcat(grouplist, gname, ",\t", NULL); /*fishy cant insert newline*/ } else { if (counter == total) grouplist = g_strconcat(grouplist, gname, ".\t", NULL); else grouplist = g_strconcat(grouplist, gname, ",\t", NULL); purple_debug_info(NULL, "%s", grouplist); purple_conversation_send(PURPLE_CONVERSATION(im), grouplist); grouplist = NULL; count = 0; flag = 1; } } } } purple_notify_message (plugin, PURPLE_NOTIFY_MSG_INFO, "Send group list", "Successfully sent your group list :)", NULL, NULL, NULL, NULL); g_free(grouplist); }