void rc_pop_contacts(PurpleGroup * grp) { if (!grp) return; PurpleBlistNode * gnode = PURPLE_BLIST_NODE(grp); PurpleBlistNode * n = NULL; PurpleBuddy * b = NULL; int total; gboolean offline; //XXX group->totalsize is unreliable!!! for (n=gnode->child, total=0; n!=NULL; total++, n=n->next); trace("Total Group Count %d", total); while (total > g_size) { n = gnode->child; if (PURPLE_BLIST_NODE_IS_CONTACT(n)) { trace("Child Contact : %s", (PURPLE_CONTACT(n)->priority->name)); b = PURPLE_CONTACT(n)->priority; } else if (PURPLE_BLIST_NODE_IS_BUDDY(n)) { trace("Child Buddy : %s", (PURPLE_BUDDY(n)->name)); b = PURPLE_BUDDY(n); } n = PURPLE_BLIST_NODE(b); const char *name = purple_blist_node_get_string(n, NODE_GROUP_KEY); if (!name) { // if cannot find orig group name, put back to Buddies trace("ERROR!!! cannot find original group name"); name = "Buddies"; } PurpleGroup * g = purple_find_group(name); if (!g) { trace("Group %s Not Found. Create one.", name); g = purple_group_new(name); } trace("<<<<<<< Remove %s", b->name); offline = purple_blist_node_get_bool(n, NODE_ORIG_OFFLINE_KEY); purple_blist_node_set_bool(n, NODE_OFFLINE_KEY, offline); purple_blist_add_buddy(b, NULL, g, NULL); total--; } }
void BuddyListContact::ContactContextMenu::removeResponseHandler( CppConsUI::MessageDialog& /*activator*/, CppConsUI::AbstractDialog::ResponseType response) { if (response != CppConsUI::AbstractDialog::RESPONSE_OK) return; // based on gtkdialogs.c:pidgin_dialogs_remove_contact_cb() PurpleContact *contact = parent_contact->getPurpleContact(); PurpleBlistNode *cnode = PURPLE_BLIST_NODE(contact); PurpleGroup *group = purple_contact_get_group(contact); for (PurpleBlistNode *bnode = purple_blist_node_get_first_child(cnode); bnode; bnode = purple_blist_node_get_sibling_next(bnode)) { PurpleBuddy *buddy = PURPLE_BUDDY(bnode); PurpleAccount *account = purple_buddy_get_account(buddy); if (purple_account_is_connected(account)) purple_account_remove_buddy(account, buddy, group); } /* Close the context menu before the contact is deleted because its deletion * can lead to destruction of this object. */ close(); purple_blist_remove_contact(contact); }
BuddyListBuddy::BuddyListBuddy(PurpleBlistNode *node_) : BuddyListNode(node_) { setColorScheme("buddylistbuddy"); buddy = PURPLE_BUDDY(blist_node); }
static GList * skypeweb_node_menu(PurpleBlistNode *node) { GList *m = NULL; PurpleMenuAction *act; PurpleBuddy *buddy; SkypeWebAccount *sa = NULL; if(PURPLE_IS_BUDDY(node)) { buddy = PURPLE_BUDDY(node); if (purple_buddy_get_protocol_data(buddy)) { SkypeWebBuddy *sbuddy = purple_buddy_get_protocol_data(buddy); sa = sbuddy->sa; } if (sa == NULL) { PurpleConnection *pc = purple_account_get_connection(purple_buddy_get_account(buddy)); sa = purple_connection_get_protocol_data(pc); } if (sa != NULL) { act = purple_menu_action_new(_("Initiate _Chat"), PURPLE_CALLBACK(skypeweb_initiate_chat_from_node), sa, NULL); m = g_list_append(m, act); } } return m; }
/* * \brief Update a node in the buddy list. * * This function is called from libpurple to inform us a node in the * buddy_list needs updating. So this function invokes rebuilding * account_<protocol_id>_<account_name>/contacts and updates the * status_messsage_of_<buddy_id> file in the appropriate account-directory. * * \param list The list the changed node belongs to * \param node The changed node */ static void update(PurpleBuddyList *list, PurpleBlistNode *node) { if (PURPLE_BLIST_NODE_IS_BUDDY(node)) { write_buddy_list_to_disk(); write_buddys_status_message_to_disk(PURPLE_BUDDY(node)); } }
static VALUE buddy_get_alias( VALUE self ) { PurpleBuddy *buddy = NULL; PURPLE_BUDDY( self, buddy ); return rb_str_new2( purple_buddy_get_alias( buddy )); }
static VALUE buddy_get_account (VALUE self){ PurpleBuddy *buddy = NULL; PURPLE_BUDDY( self, buddy ); return RB_ACCOUNT(buddy->account); }
void send_connect_request_message() { PurpleAccount* account=purple_buddy_get_account(PURPLE_BUDDY(client_node)); PurpleConversation *conv=purple_conversation_new (PURPLE_CONV_TYPE_IM, account, purple_buddy_get_name (PURPLE_BUDDY(client_node))); PurpleConvIm *im = purple_conversation_get_im_data(conv); const char* remote_message="sharedesk|request_connection|$SERVER_IP|$PORT|" "\nPlease start a vnc connection. Sample command line:" "\n$CLIENT_CMD" "\n|||"; GRegex *port_regex1=g_regex_new("[$]CLIENT_CMD",0,0,NULL); char* msg1=g_regex_replace(port_regex1,remote_message,-1,0,purple_prefs_get_string(PREF_CLIENT_COMMAND_LINE),0,NULL); GRegex *port_regex2=g_regex_new("[$]PORT",0,0,NULL); char* msg2=g_regex_replace(port_regex2,msg1,-1,0,purple_value_get_string(port),0,NULL); GRegex *port_regex3=g_regex_new("[$]SERVER_IP",0,0,NULL); char* msg3=g_regex_replace(port_regex3,msg2,-1,0,purple_value_get_string(server_ip),0,NULL); purple_conv_im_send(im, msg3); g_free(msg3); g_free(msg2); g_free(msg1); g_free(port_regex1); g_free(port_regex2); g_free(port_regex3); }
static VALUE buddy_get_info (VALUE self){ PurpleBuddy *buddy = NULL; PURPLE_BUDDY( self, buddy ); PurpleAccount *account = buddy->account; PurpleConnection *gc = purple_account_get_connection (account); serv_get_info(gc, purple_buddy_get_name( buddy )); return Qnil; }
void qq_send_offline_file(PurpleBlistNode* node) { PurpleBuddy* buddy = PURPLE_BUDDY(node); PurpleAccount* account = purple_buddy_get_account(buddy); PurpleXfer* xfer = purple_xfer_new(account,PURPLE_XFER_SEND,buddy->name); purple_xfer_set_init_fnc(xfer,upload_offline_file_init); purple_xfer_set_request_denied_fnc(xfer,recv_file_request_denied); purple_xfer_set_cancel_send_fnc(xfer,recv_file_cancel); purple_xfer_request(xfer); }
static void blist_example_menu_item(PurpleBlistNode *node, gpointer userdata) { purple_debug_info("nullprpl", "example menu item clicked on user %s\n", purple_buddy_get_name(PURPLE_BUDDY(node))); purple_notify_info(NULL, /* plugin handle or PurpleConnection */ _("Primary title"), _("Secondary title"), _("This is the callback for the nullprpl menu item."), NULL); }
static VALUE buddy_get_status( VALUE self ) { PurpleBuddy *buddy = NULL; PurpleStatus *status = NULL; PurpleStatusType *type = NULL; PURPLE_BUDDY( self, buddy ); status = purple_presence_get_active_status( purple_buddy_get_presence( buddy ) ); type = purple_status_get_type( status ); return INT2NUM( purple_status_type_get_primitive( type ) ); }
void collect_buddies(PurpleBlistNode *p, std::vector<p_rest::Buddy> &list, bool online_only) { if (PURPLE_BLIST_NODE_IS_BUDDY(p)) { if (!online_only || (online_only && PURPLE_BUDDY_IS_ONLINE(PURPLE_BUDDY(p)))) { p_rest::Buddy new_buddy(PURPLE_BUDDY(p)->name); new_buddy.set_group(buddy_get_group_name(p).c_str()); if (PURPLE_BUDDY_IS_ONLINE(PURPLE_BUDDY(p))) { new_buddy.set_online_status(true); } list.push_back(new_buddy); } } if (p->child) { collect_buddies(p->child, list, online_only); } if (p->next) { collect_buddies(p->next, list, online_only); } }
/* drawing-tooltip */ static void drawing_tooltip(PurpleBlistNode *node, GString *text, gboolean full) { if (PURPLE_IS_BUDDY(node)) { PurpleBuddy *buddy = PURPLE_BUDDY(node); CapStatistics *stats = get_stats_for(buddy); /* get the probability that this buddy will respond and add to the tooltip */ if(stats->prediction->probability >= 0.0) { g_string_append_printf(text, "\n<b>%s</b> %3.0f %%", _("Response Probability:"), 100 * stats->prediction->probability); } else { g_string_append_printf(text, "\n<b>%s</b> ???", _("Response Probability:")); } } }
static void visibility_cb(PurpleBlistNode *node, gpointer whatever) { PurpleBuddy *buddy = PURPLE_BUDDY(node); const char* bname = purple_buddy_get_name(buddy); OscarData *od = purple_connection_get_protocol_data(purple_account_get_connection(purple_buddy_get_account(buddy))); guint16 list_type = get_buddy_list_type(od); if (!is_buddy_on_list(od, bname)) { aim_ssi_add_to_private_list(od, bname, list_type); } else { aim_ssi_del_from_private_list(od, bname, list_type); } }
static VALUE buddy_get_avatar (VALUE self){ PurpleBuddy *buddy = NULL; PURPLE_BUDDY( self, buddy ); PurpleBuddyIcon *icon = purple_buddy_get_icon(buddy); if (icon != NULL) { size_t size = NULL; gconstpointer data = purple_buddy_icon_get_data(icon, &size); return rb_str_new(data, size); } else { return Qnil; } }
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; }
static VALUE buddy_get_avatar_type (VALUE self){ PurpleBuddy *buddy = NULL; gconstpointer data; size_t size; PURPLE_BUDDY( self, buddy ); PurpleBuddyIcon *icon = purple_buddy_get_icon(buddy); if (icon != NULL) { return rb_str_new2( purple_buddy_icon_get_extension(icon) ); } else { return Qnil; } }
static gpointer on_offline_find_parent(PurpleBlistNode *node) { gpointer ret = NULL; if (PURPLE_IS_CONTACT(node)) { node = PURPLE_BLIST_NODE(purple_contact_get_priority_buddy(PURPLE_CONTACT(node))); ret = PURPLE_BUDDY_IS_ONLINE(PURPLE_BUDDY(node)) ? online : offline; } else if (PURPLE_IS_BUDDY(node)) { ret = purple_blist_node_get_parent(node); finch_blist_manager_add_node(ret); } else if (PURPLE_IS_CHAT(node)) { ret = online; } return ret; }
PurpleBuddy *tgp_blist_buddy_find (struct tgl_state *TLS, tgl_peer_id_t user) { PurpleBlistNode *node = purple_blist_get_root (); while (node) { if (PURPLE_BLIST_NODE_IS_BUDDY(node)) { PurpleBuddy *buddy = PURPLE_BUDDY(node); if (purple_buddy_get_account (buddy) == tg_get_acc (TLS)) { if (purple_blist_node_get_int (node, TGP_BUDDY_KEY_PEER_ID) == tgl_get_peer_id (user)) { assert (tgl_get_peer_type (user) == purple_blist_node_get_int (node, TGP_BUDDY_KEY_PEER_TYPE)); return buddy; } } } node = purple_blist_node_next (node, FALSE); } return NULL; }
void visit_buddies(std::function<bool(PurpleBuddy*)> func, PurpleBlistNode *p = nullptr) { if (p == nullptr) { p = purple_get_blist()->root; } if (PURPLE_BLIST_NODE_IS_BUDDY(p)) { if (func(PURPLE_BUDDY(p))) { // found something, stop searching return; } } if (p->child) { visit_buddies(func, p->child); } if (p->next) { visit_buddies(func, p->next); } }
void BuddyListGroup::GroupContextMenu::removeResponseHandler( CppConsUI::MessageDialog& /*activator*/, CppConsUI::AbstractDialog::ResponseType response) { if (response != CppConsUI::AbstractDialog::RESPONSE_OK) return; // based on gtkdialogs.c:pidgin_dialogs_remove_group_cb() PurpleGroup *group = parent_group->getPurpleGroup(); PurpleBlistNode *cnode = purple_blist_node_get_first_child( PURPLE_BLIST_NODE(group)); while (cnode) { if (PURPLE_BLIST_NODE_IS_CONTACT(cnode)) { PurpleBlistNode *bnode = purple_blist_node_get_first_child(cnode); cnode = purple_blist_node_get_sibling_next(cnode); while (bnode) if (PURPLE_BLIST_NODE_IS_BUDDY(bnode)) { PurpleBuddy *buddy = PURPLE_BUDDY(bnode); PurpleAccount *account = purple_buddy_get_account(buddy); bnode = purple_blist_node_get_sibling_next(bnode); if (purple_account_is_connected(account)) { purple_account_remove_buddy(account, buddy, group); purple_blist_remove_buddy(buddy); } } else bnode = purple_blist_node_get_sibling_next(bnode); } else if (PURPLE_BLIST_NODE_IS_CHAT(cnode)) { PurpleChat *chat = PURPLE_CHAT(cnode); cnode = purple_blist_node_get_sibling_next(cnode); purple_blist_remove_chat(chat); } else cnode = purple_blist_node_get_sibling_next(cnode); } /* Close the context menu before the group is deleted because its deletion * can lead to destruction of this object. */ close(); purple_blist_remove_group(group); }
void qq_send_offline_file(PurpleBlistNode* node) { PurpleBuddy* buddy = PURPLE_BUDDY(node); PurpleAccount* account = purple_buddy_get_account(buddy); qq_account* ac = purple_connection_get_protocol_data( purple_account_get_connection(account)); const char* who; if(ac->qq_use_qqnum){ const char* qqnum = purple_buddy_get_name(buddy); LwqqBuddy* b = find_buddy_by_qqnumber(ac->qq, qqnum); if(b == NULL) return; who = b->uin; }else{ who = purple_buddy_get_name(buddy); } PurpleXfer* xfer = purple_xfer_new(account,PURPLE_XFER_SEND,who); purple_xfer_set_init_fnc(xfer,upload_offline_file_init); purple_xfer_set_request_denied_fnc(xfer,recv_file_request_denied); purple_xfer_set_cancel_send_fnc(xfer,recv_file_cancel); purple_xfer_request(xfer); }
static gboolean on_offline_can_add_node(PurpleBlistNode *node) { if (PURPLE_IS_CONTACT(node)) { PurpleContact *contact = PURPLE_CONTACT(node); if (purple_counting_node_get_current_size(PURPLE_COUNTING_NODE(contact)) > 0) return TRUE; return FALSE; } else if (PURPLE_IS_BUDDY(node)) { PurpleBuddy *buddy = PURPLE_BUDDY(node); if (PURPLE_BUDDY_IS_ONLINE(buddy)) return TRUE; if (purple_prefs_get_bool("/finch/blist/showoffline") && purple_account_is_connected(purple_buddy_get_account(buddy))) return TRUE; return FALSE; } else if (PURPLE_IS_CHAT(node)) { PurpleChat *chat = PURPLE_CHAT(node); return purple_account_is_connected(purple_chat_get_account(chat)); } return FALSE; }
static void historize(PurpleConversation *c) { PurpleAccount *account = purple_conversation_get_account(c); const char *name = purple_conversation_get_name(c); GList *logs = NULL; const char *alias = name; guint flags; char *history; PidginConversation *gtkconv; #if 0 /* FIXME: WebView has no options */ GtkIMHtmlOptions options = GTK_IMHTML_NO_COLOURS; #endif char *header; #if 0 /* FIXME: WebView has no protocol setting */ char *protocol; #endif char *escaped_alias; const char *header_date; gtkconv = PIDGIN_CONVERSATION(c); g_return_if_fail(gtkconv != NULL); /* An IM which is the first active conversation. */ g_return_if_fail(gtkconv->convs != NULL); if (PURPLE_IS_IM_CONVERSATION(c) && !gtkconv->convs->next) { GSList *buddies; GSList *cur; /* If we're not logging, don't show anything. * Otherwise, we might show a very old log. */ if (!purple_prefs_get_bool("/purple/logging/log_ims")) return; /* Find buddies for this conversation. */ buddies = purple_blist_find_buddies(account, name); /* If we found at least one buddy, save the first buddy's alias. */ if (buddies != NULL) alias = purple_buddy_get_contact_alias(PURPLE_BUDDY(buddies->data)); for (cur = buddies; cur != NULL; cur = cur->next) { PurpleBlistNode *node = cur->data; PurpleBlistNode *prev = purple_blist_node_get_sibling_prev(node); PurpleBlistNode *next = purple_blist_node_get_sibling_next(node); if ((node != NULL) && ((prev != NULL) || (next != NULL))) { PurpleBlistNode *node2; PurpleBlistNode *parent = purple_blist_node_get_parent(node); PurpleBlistNode *child = purple_blist_node_get_first_child(parent); alias = purple_buddy_get_contact_alias(PURPLE_BUDDY(node)); /* We've found a buddy that matches this conversation. It's part of a * PurpleContact with more than one PurpleBuddy. Loop through the PurpleBuddies * in the contact and get all the logs. */ for (node2 = child ; node2 != NULL ; node2 = purple_blist_node_get_sibling_next(node2)) { logs = g_list_concat(purple_log_get_logs(PURPLE_LOG_IM, purple_buddy_get_name(PURPLE_BUDDY(node2)), purple_buddy_get_account(PURPLE_BUDDY(node2))), logs); } break; } } g_slist_free(buddies); if (logs == NULL) logs = purple_log_get_logs(PURPLE_LOG_IM, name, account); else logs = g_list_sort(logs, purple_log_compare); } else if (PURPLE_IS_CHAT_CONVERSATION(c)) { /* If we're not logging, don't show anything. * Otherwise, we might show a very old log. */ if (!purple_prefs_get_bool("/purple/logging/log_chats")) return; logs = purple_log_get_logs(PURPLE_LOG_CHAT, name, account); } if (logs == NULL) return; history = purple_log_read((PurpleLog*)logs->data, &flags); gtkconv = PIDGIN_CONVERSATION(c); #if 0 /* FIXME: WebView has no options */ if (flags & PURPLE_LOG_READ_NO_NEWLINE) options |= GTK_IMHTML_NO_NEWLINE; #endif #if 0 /* FIXME: WebView has no protocol setting */ protocol = g_strdup(gtk_imhtml_get_protocol_name(GTK_IMHTML(gtkconv->imhtml))); gtk_imhtml_set_protocol_name(GTK_IMHTML(gtkconv->imhtml), purple_account_get_protocol_name(((PurpleLog*)logs->data)->account)); #endif #if 0 /* TODO WebKit: Do this properly... */ if (!pidgin_webview_is_empty(PIDGIN_WEBVIEW(gtkconv->webview))) pidgin_webview_append_html(PIDGIN_WEBVIEW(gtkconv->webview), "<BR>"); #endif escaped_alias = g_markup_escape_text(alias, -1); if (((PurpleLog *)logs->data)->tm) header_date = purple_date_format_full(((PurpleLog *)logs->data)->tm); else header_date = purple_date_format_full(localtime(&((PurpleLog *)logs->data)->time)); header = g_strdup_printf(_("<b>Conversation with %s on %s:</b><br>"), escaped_alias, header_date); pidgin_webview_append_html(PIDGIN_WEBVIEW(gtkconv->webview), header); g_free(header); g_free(escaped_alias); g_strchomp(history); pidgin_webview_append_html(PIDGIN_WEBVIEW(gtkconv->webview), history); g_free(history); pidgin_webview_append_html(PIDGIN_WEBVIEW(gtkconv->webview), "<hr>"); #if 0 /* FIXME: WebView has no protocol setting */ gtk_imhtml_set_protocol_name(GTK_IMHTML(gtkconv->imhtml), protocol); g_free(protocol); #endif g_object_ref(G_OBJECT(gtkconv->webview)); g_idle_add(_scroll_webview_to_end, gtkconv->webview); g_list_foreach(logs, (GFunc)purple_log_free, NULL); g_list_free(logs); }