static void status_changed_cb(PurpleBuddy *b, PurpleStatus *os, PurpleStatus *s) { PurpleContact *c = purple_buddy_get_contact(b); if(buddy_ticker_find_contact(c)) buddy_ticker_set_pixmap(c); else buddy_ticker_add_buddy(b); }
static void buddy_signon_cb(PurpleBuddy *b) { PurpleContact *c = purple_buddy_get_contact(b); purple_contact_invalidate_priority_buddy(c); if(buddy_ticker_find_contact(c)) buddy_ticker_update_contact(c); else buddy_ticker_add_buddy(b); }
static void buddytimezone_submitfields_cb(PurpleRequestFields * fields, PurpleBlistNode * data) { PurpleBlistNode *node; PurpleRequestField *list; /* timezone stuff */ purple_debug(PURPLE_DEBUG_INFO, PLUGIN_STATIC_NAME, "buddytimezone_submitfields_cb(%p,%p)\n", fields, data); switch (data->type) { case PURPLE_BLIST_BUDDY_NODE: node = (PurpleBlistNode *) purple_buddy_get_contact((PurpleBuddy *) data); break; case PURPLE_BLIST_CONTACT_NODE: case PURPLE_BLIST_GROUP_NODE: /* code handles either case */ node = data; break; case PURPLE_BLIST_CHAT_NODE: case PURPLE_BLIST_OTHER_NODE: default: /* Not applicable */ return; } list = purple_request_fields_get_field(fields, CONTROL_NAME); if (ui_ops != NULL && ui_ops->get_timezone_menu_selection != NULL) { const char *seldata = ui_ops->get_timezone_menu_selection(list->ui_data); if (seldata == NULL) purple_blist_node_remove_setting(node, SETTING_NAME); else purple_blist_node_set_string(node, SETTING_NAME, seldata); } else { const GList *sellist; void *seldata = NULL; sellist = purple_request_field_list_get_selected(list); if (sellist) seldata = purple_request_field_list_get_data(list, sellist->data); /* Otherwise, it's fixed value and this means deletion */ if (seldata == TIMEZONE_FLAG) purple_blist_node_set_string(node, SETTING_NAME, sellist->data); else if (seldata == DISABLED_FLAG) purple_blist_node_set_string(node, SETTING_NAME, "none"); else purple_blist_node_remove_setting(node, SETTING_NAME); } }
static void buddy_ticker_remove_buddy(PurpleBuddy *b) { PurpleContact *c = purple_buddy_get_contact(b); TickerData *td = buddy_ticker_find_contact(c); if (!td) return; purple_contact_invalidate_priority_buddy(c); /* pop up the ticker window again */ buddy_ticker_create_window(); buddy_ticker_update_contact(c); }
static PurpleBlistNode * _purple_events_ui_get_good_node(PurpleBlistNode *node) { if ( PURPLE_BLIST_NODE_IS_CONTACT(node) ) return node; if ( PURPLE_BLIST_NODE_IS_BUDDY(node) ) return PURPLE_BLIST_NODE(purple_buddy_get_contact(PURPLE_BUDDY(node))); if ( PURPLE_BLIST_NODE_IS_GROUP(node) ) return node; return NULL; }
/* Resolve specifies what the return value should mean: * * If TRUE, it's for display, we want to know the *effect* thus hiding the * "none" value and going to going level to find the default * * If false, we only want what the user enter, thus the string "none" if * that's what it is * * data is here so we can use this as a callback for IPC */ static const char * buddy_get_timezone(PurpleBlistNode * node, gboolean resolve, void *data) { PurpleBlistNode *datanode = NULL; const char *timezone; switch (node->type) { case PURPLE_BLIST_BUDDY_NODE: datanode = (PurpleBlistNode *) purple_buddy_get_contact((PurpleBuddy *) node); break; case PURPLE_BLIST_CONTACT_NODE: datanode = node; break; case PURPLE_BLIST_GROUP_NODE: datanode = node; break; default: return NULL; } timezone = purple_blist_node_get_string(datanode, SETTING_NAME); if (!resolve) return timezone; /* The effect of "none" is to stop recursion */ if (timezone && strcmp(timezone, "none") == 0) return NULL; if (timezone) return timezone; if (datanode->type == PURPLE_BLIST_CONTACT_NODE) { /* There is no purple_blist_contact_get_group(), though there probably should be */ datanode = datanode->parent; timezone = purple_blist_node_get_string(datanode, SETTING_NAME); } if (timezone && strcmp(timezone, "none") == 0) return NULL; return timezone; }
static void buddy_ticker_add_buddy(PurpleBuddy *b) { GtkWidget *hbox; TickerData *td; PurpleContact *contact; contact = purple_buddy_get_contact(b); buddy_ticker_create_window(); if (!ticker) return; if (buddy_ticker_find_contact(contact)) { buddy_ticker_update_contact(contact); return; } td = g_new0(TickerData, 1); td->contact = contact; tickerbuds = g_list_append(tickerbuds, td); td->ebox = gtk_event_box_new(); gtk_ticker_add(GTK_TICKER(ticker), td->ebox); hbox = gtk_hbox_new(FALSE, 0); gtk_container_add(GTK_CONTAINER(td->ebox), hbox); buddy_ticker_set_pixmap(contact); gtk_box_pack_start(GTK_BOX(hbox), td->icon, FALSE, FALSE, 0); g_signal_connect(G_OBJECT(td->ebox), "button-press-event", G_CALLBACK(buddy_click_cb), contact); td->label = gtk_label_new(purple_contact_get_alias(contact)); gtk_box_pack_start(GTK_BOX(hbox), td->label, FALSE, FALSE, 2); gtk_widget_show_all(td->ebox); gtk_widget_show(tickerwindow); /* * Update the icon in a few seconds (after the open door icon has * changed). This is somewhat ugly. */ td->timeout = g_timeout_add(11000, buddy_ticker_set_pixmap_cb, td); }
static void notify (const gchar *title, const gchar *body, PurpleBuddy *buddy, PurpleConversation *conv) { NotifyNotification *notification = NULL; GdkPixbuf *icon; PurpleBuddyIcon *buddy_icon; gchar *tr_body; PurpleContact *contact; if (buddy) contact = purple_buddy_get_contact (buddy); else contact = NULL; if (body) tr_body = truncate_escape_string (body, 60); else tr_body = NULL; if (!conv && buddy) conv = purple_find_conversation_with_account (PURPLE_CONV_TYPE_ANY, buddy->name, buddy->account); if (conv && conv->ui_ops && conv->ui_ops->has_focus) { if (conv->ui_ops->has_focus(conv) == TRUE) { /* do not notify if the conversation is currently in focus */ return; } } if (contact) notification = g_hash_table_lookup (buddy_hash, contact); else if (conv) notification = g_hash_table_lookup (buddy_hash, conv); else notification = NULL; if (notification != NULL) { notify_notification_update (notification, title, tr_body, NULL); notify_notification_set_timeout(notification, purple_prefs_get_int("/plugins/gtk/libnotify/timeout")); /* this shouldn't be necessary, file a bug */ notify_notification_show (notification, NULL); purple_debug_info (PLUGIN_ID, "notify(), update: " "title: '%s', body: '%s', buddy: '%s'\n", title, tr_body, buddy ? best_name (buddy) : ""); g_free (tr_body); return; } #ifdef LIBNOTIFY_07 notification = notify_notification_new (title, tr_body, NULL); #else notification = notify_notification_new (title, tr_body, NULL, NULL); #endif purple_debug_info (PLUGIN_ID, "notify(), new: " "title: '%s', body: '%s', buddy: '%s'\n", title, tr_body, buddy ? best_name (buddy) : ""); g_free (tr_body); if (buddy) buddy_icon = purple_buddy_get_icon (buddy); else buddy_icon = NULL; if (buddy_icon) { icon = pixbuf_from_buddy_icon (buddy_icon); purple_debug_info (PLUGIN_ID, "notify(), has a buddy icon.\n"); } else if (buddy) { icon = pidgin_create_prpl_icon (buddy->account, 1); purple_debug_info (PLUGIN_ID, "notify(), has a prpl icon.\n"); } else if (conv) { icon = pidgin_create_prpl_icon (conv->account, 1); purple_debug_info (PLUGIN_ID, "notify(), has a prpl icon.\n"); } else { icon = NULL; purple_debug_info (PLUGIN_ID, "notify(), has no icon.\n"); } if (icon) { notify_notification_set_icon_from_pixbuf (notification, icon); g_object_unref (icon); } else { purple_debug_warning (PLUGIN_ID, "notify(), couldn't find any icon!\n"); } if (contact) g_hash_table_insert (buddy_hash, contact, notification); else if (conv) g_hash_table_insert (buddy_hash, conv, notification); g_object_set_data (G_OBJECT(notification), "contact", contact); g_object_set_data (G_OBJECT(notification), "conv", conv); g_object_set_data (G_OBJECT(notification), "buddy", buddy); g_signal_connect (notification, "closed", G_CALLBACK(closed_cb), NULL); notify_notification_set_urgency (notification, NOTIFY_URGENCY_NORMAL); notify_notification_add_action (notification, "show", _("Show"), action_cb, NULL, NULL); notify_notification_set_timeout(notification, purple_prefs_get_int("/plugins/gtk/libnotify/timeout")); if (!notify_notification_show (notification, NULL)) { purple_debug_error (PLUGIN_ID, "notify(), failed to send notification\n"); } }