bool BuddyListChat::lessOrEqual(const BuddyListNode& other) const { const BuddyListChat *o = dynamic_cast<const BuddyListChat*>(&other); if (o) return g_utf8_collate(purple_chat_get_name(chat), purple_chat_get_name(o->chat)) <= 0; return lessOrEqualByType(other); }
void BuddyListChat::onActivate(Button& /*activator*/) { PurpleAccount *account = purple_chat_get_account(chat); PurplePluginProtocolInfo *prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO( purple_find_prpl(purple_account_get_protocol_id(account))); GHashTable *components = purple_chat_get_components(chat); char *chat_name = NULL; if (prpl_info && prpl_info->get_chat_name) chat_name = prpl_info->get_chat_name(components); const char *name; if (chat_name) name = chat_name; else name = purple_chat_get_name(chat); PurpleConversation *conv = purple_find_conversation_with_account( PURPLE_CONV_TYPE_CHAT, name, account); if (conv) purple_conversation_present(conv); serv_join_chat(purple_account_get_connection(account), components); g_free(chat_name); }
void BuddyListChat::ChatContextMenu::onChangeAlias(Button& /*activator*/) { PurpleChat *chat = parent_chat->getPurpleChat(); CppConsUI::InputDialog *dialog = new CppConsUI::InputDialog( _("Alias"), purple_chat_get_name(chat)); dialog->signal_response.connect(sigc::mem_fun(this, &ChatContextMenu::changeAliasResponseHandler)); dialog->show(); }
static void log_delete_log_cb(GtkWidget *menuitem, gpointer *data) { PidginLogViewer *lv = data[0]; PurpleLog *log = data[1]; const char *time = log_get_date(log); const char *name; char *tmp; gpointer *data2; if (log->type == PURPLE_LOG_IM) { PurpleBuddy *buddy = purple_find_buddy(log->account, log->name); if (buddy != NULL) name = purple_buddy_get_contact_alias(buddy); else name = log->name; tmp = g_strdup_printf(_("Are you sure you want to permanently delete the log of the " "conversation with %s which started at %s?"), name, time); } else if (log->type == PURPLE_LOG_CHAT) { PurpleChat *chat = purple_blist_find_chat(log->account, log->name); if (chat != NULL) name = purple_chat_get_name(chat); else name = log->name; tmp = g_strdup_printf(_("Are you sure you want to permanently delete the log of the " "conversation in %s which started at %s?"), name, time); } else if (log->type == PURPLE_LOG_SYSTEM) { tmp = g_strdup_printf(_("Are you sure you want to permanently delete the system log " "which started at %s?"), time); } else g_return_if_reached(); /* The only way to free data in all cases is to tie it to the menuitem with * g_object_set_data_full(). But, since we need to get some data down to * delete_log_cb() to delete the log from the log viewer after the file is * deleted, we have to allocate a new data array and make sure it gets freed * either way. */ data2 = g_new(gpointer, 3); data2[0] = lv->treestore; data2[1] = data[3]; /* iter */ data2[2] = log; purple_request_action(lv, NULL, _("Delete Log?"), tmp, 0, NULL, NULL, NULL, data2, 2, _("Delete"), delete_log_cb, _("Cancel"), delete_log_cleanup_cb); g_free(tmp); }
void pidgin_log_show(PurpleLogType type, const char *screenname, PurpleAccount *account) { struct log_viewer_hash_t *ht; PidginLogViewer *lv = NULL; const char *name = screenname; char *title; GdkPixbuf *prpl_icon; g_return_if_fail(account != NULL); g_return_if_fail(screenname != NULL); ht = g_new0(struct log_viewer_hash_t, 1); ht->type = type; ht->screenname = g_strdup(screenname); ht->account = account; if (log_viewers == NULL) { log_viewers = g_hash_table_new(log_viewer_hash, log_viewer_equal); } else if ((lv = g_hash_table_lookup(log_viewers, ht))) { gtk_window_present(GTK_WINDOW(lv->window)); g_free(ht->screenname); g_free(ht); return; } if (type == PURPLE_LOG_CHAT) { PurpleChat *chat; chat = purple_blist_find_chat(account, screenname); if (chat != NULL) name = purple_chat_get_name(chat); title = g_strdup_printf(_("Conversations in %s"), name); } else { PurpleBuddy *buddy; buddy = purple_find_buddy(account, screenname); if (buddy != NULL) name = purple_buddy_get_contact_alias(buddy); title = g_strdup_printf(_("Conversations with %s"), name); } prpl_icon = pidgin_create_prpl_icon(account, PIDGIN_PRPL_ICON_MEDIUM); display_log_viewer(ht, purple_log_get_logs(type, screenname, account), title, gtk_image_new_from_pixbuf(prpl_icon), purple_log_get_total_size(type, screenname, account)); if (prpl_icon) g_object_unref(prpl_icon); g_free(title); }
void BuddyListChat::ChatContextMenu::onRemove(Button& /*activator*/) { PurpleChat *chat = parent_chat->getPurpleChat(); char *msg = g_strdup_printf( _("Are you sure you want to delete chat %s from the list?"), purple_chat_get_name(chat)); CppConsUI::MessageDialog *dialog = new CppConsUI::MessageDialog( _("Chat deletion"), msg); g_free(msg); dialog->signal_response.connect(sigc::mem_fun(this, &ChatContextMenu::removeResponseHandler)); dialog->show(); }
void BuddyListChat::update() { BuddyListNode::update(); const char *name = purple_chat_get_name(chat); setText(name); sortIn(); // hide if account is offline setVisibility(purple_account_is_connected(purple_chat_get_account(chat))); updateFilterVisibility(name); }
static void translate_action_blist_cb(PurpleBlistNode *node, PurpleKeyValuePair *pair) { PurpleConversation *conv = NULL; gchar *message; PurpleChat *chat; PurpleContact *contact; PurpleBuddy *buddy; if (pair == NULL) purple_blist_node_set_string(node, DEST_LANG_SETTING, NULL); else purple_blist_node_set_string(node, DEST_LANG_SETTING, pair->key); switch(node->type) { case PURPLE_BLIST_CHAT_NODE: chat = (PurpleChat *) node; conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, purple_chat_get_name(chat), chat->account); break; case PURPLE_BLIST_CONTACT_NODE: contact = (PurpleContact *) node; node = (PurpleBlistNode *)purple_contact_get_priority_buddy(contact); //fallthrough intentional case PURPLE_BLIST_BUDDY_NODE: buddy = (PurpleBuddy *) node; conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, purple_buddy_get_name(buddy), purple_buddy_get_account(buddy)); break; default: break; } if (conv != NULL && pair != NULL) { message = g_strdup_printf("Now translating to %s", (const gchar *)pair->value); purple_conversation_write(conv, NULL, message, PURPLE_MESSAGE_SYSTEM | PURPLE_MESSAGE_NO_LOG, time(NULL)); g_free(message); } }
PurpleStoredImage * purple_buddy_icons_node_set_custom_icon(PurpleBlistNode *node, guchar *icon_data, size_t icon_len) { char *old_icon; PurpleStoredImage *old_img; PurpleStoredImage *img = NULL; g_return_val_if_fail(node != NULL, NULL); if (!PURPLE_BLIST_NODE_IS_CONTACT(node) && !PURPLE_BLIST_NODE_IS_CHAT(node) && !PURPLE_BLIST_NODE_IS_GROUP(node)) { return NULL; } old_img = g_hash_table_lookup(pointer_icon_cache, node); if (icon_data != NULL && icon_len > 0) { img = purple_buddy_icon_data_new(icon_data, icon_len, NULL); } old_icon = g_strdup(purple_blist_node_get_string(node, "custom_buddy_icon")); if (img && purple_buddy_icons_is_caching()) { const char *filename = purple_imgstore_get_filename(img); purple_blist_node_set_string(node, "custom_buddy_icon", filename); ref_filename(filename); } else { purple_blist_node_remove_setting(node, "custom_buddy_icon"); } unref_filename(old_icon); if (img) g_hash_table_insert(pointer_icon_cache, node, img); else g_hash_table_remove(pointer_icon_cache, node); if (PURPLE_BLIST_NODE_IS_CONTACT(node)) { PurpleBlistNode *child; for (child = purple_blist_node_get_first_child(node); child; child = purple_blist_node_get_sibling_next(child)) { PurpleBuddy *buddy; PurpleConversation *conv; if (!PURPLE_BLIST_NODE_IS_BUDDY(child)) continue; buddy = (PurpleBuddy *)child; conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, purple_buddy_get_name(buddy), purple_buddy_get_account(buddy)); if (conv) purple_conversation_update(conv, PURPLE_CONV_UPDATE_ICON); /* Is this call necessary anymore? Can the buddies * themselves need updating when the custom buddy * icon changes? */ purple_blist_update_node_icon((PurpleBlistNode*)buddy); } } else if (PURPLE_BLIST_NODE_IS_CHAT(node)) { PurpleConversation *conv = NULL; conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, purple_chat_get_name((PurpleChat*)node), purple_chat_get_account((PurpleChat*)node)); if (conv) { purple_conversation_update(conv, PURPLE_CONV_UPDATE_ICON); } } purple_blist_update_node_icon(node); if (old_img) { purple_imgstore_unref(old_img); } else if (old_icon) { /* The old icon may not have been loaded into memory. In that * case, we'll need to uncache the filename. The filenames * are ref-counted, so this is safe. */ purple_buddy_icon_data_uncache_file(old_icon); } g_free(old_icon); return img; }
const char *BuddyListChat::toString() const { return purple_chat_get_name(chat); }
xmlnode * _h_elim_add_chat( const char *name , const char *id , SEXP_VALUE *args , gpointer data ) { ASSERT_ALISTP( args, id, name ); elim_ping(); const char *aname = ALIST_VAL_STR ( args, "account-name" ); const char *proto = ALIST_VAL_STR ( args, "im-protocol" ); const char *alias = ALIST_VAL_STR ( args, "chat-alias" ); gpointer auid = ALIST_VAL_PTR ( args, "account-uid" ); GHashTable *opts = ALIST_VAL_ALIST( args, "chat-options" ); GHashTable *options = __ghash_str_sexp__str_str( opts ); PurpleAccount *acct = auid ? find_acct_by_uid( auid ) : purple_accounts_find( aname, proto ); if( !acct ) { sexp_val_free( args ); return response_error( ENXIO, id, name, "unknown account" ); } // cook up a chat node. if it's already on our buddy list, uncook it // and use the old one instead (name should be unique per account // so the operation is reasonable - we cannot supply a name as this // parameter can be delegated to the plugin to generate automatically): // this will trigger a new_node call, and possibly a remove call PurpleChat *chat = purple_chat_new( acct, alias, options ); const char *chn = purple_chat_get_name( chat ); PurpleChat *ch_2 = purple_blist_find_chat( acct, chn ); if( ch_2 ) { fprintf( stderr, "(elim-debug chat already exists)\n" ); purple_blist_remove_chat( chat ); chat = ch_2; chn = purple_chat_get_name( chat ); purple_blist_alias_chat( chat, alias ); } fprintf( stderr, "(elim-debug adding chat to blist)\n" ); purple_blist_add_chat( chat, NULL, NULL ); // if we have a conversation already, prod the client to show it fprintf( stderr, "(elim-debug looking for conversation)\n" ); PurpleConversation *conv = purple_find_conversation_with_account( PURPLE_CONV_TYPE_CHAT, chn, acct ); if( conv ) purple_conversation_present( conv ); xmlnode *rval = xnode_new( "alist" ); AL_STR( rval, "account-name", purple_account_get_username (acct) ); AL_STR( rval, "im-protocol" , purple_account_get_protocol_id(acct) ); AL_PTR( rval, "account-uid" , acct ); AL_STR( rval, "chat-name" , chn ); if( conv ) { PurpleConversationType pct = purple_conversation_get_type ( conv ); PurpleConnectionFlags pcf = purple_conversation_get_features( conv ); AL_PTR ( rval, "conv-uid" , conv ); AL_STR ( rval, "conv-name" , purple_conversation_get_name (conv) ); AL_STR ( rval, "conv-title" , purple_conversation_get_title(conv) ); AL_ENUM( rval, "conv-type" , pct, ":conversation-type" ); AL_ENUM( rval, "conv-features", pcf, ":connection-flags" ); } sexp_val_free( args ); return response_value( 0, id, name, rval ); }