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 AccountWindow::SplitOption::updateSplits() { SplitWidgets *split_widgets = &account_entry->split_widgets; SplitWidgets::iterator split_widget = split_widgets->begin(); SplitOption *widget = *split_widget; const char *val = widget->getValue(); split_widget++; GString *username = g_string_new(val); PurplePluginProtocolInfo *prplinfo = PURPLE_PLUGIN_PROTOCOL_INFO( purple_find_prpl(purple_account_get_protocol_id(account))); for (GList *iter = prplinfo->user_splits; iter && split_widget != split_widgets->end(); iter = iter->next, split_widget++) { PurpleAccountUserSplit *user_split = reinterpret_cast<PurpleAccountUserSplit*>(iter->data); widget = *split_widget; val = widget->getValue(); if (!val || !*val) val = purple_account_user_split_get_default_value(user_split); g_string_append_printf(username, "%c%s", purple_account_user_split_get_separator(user_split), val); } purple_account_set_username(account, username->str); g_string_free(username, TRUE); }
static void buddy_status_changed(PurpleBuddy *buddy, PurpleStatus *old_status, PurpleStatus *status) { PurplePlugin *prpl; PurplePluginProtocolInfo *prpl_info = NULL; char *sip_from = find_sip_user(buddy->name); int d = hashtable_get_counter(buddy->name); PurpleStatusPrimitive primitive; enum purple_publish_basic basic; enum purple_publish_activity activity; char *statustext = NULL, *tmp = NULL, *new; const char *end; LM_DBG("buddy <%s> has changed status\n", buddy->name); if ((sip_from) && (d>0)) { primitive = purple_status_type_get_primitive(purple_status_get_type(status)); primitive_parse(primitive, &basic, &activity); // char *note = purple_status_get_attr_string(status, "message"); prpl = purple_find_prpl(purple_account_get_protocol_id(buddy->account)); if (prpl != NULL) prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(prpl); if (prpl_info && prpl_info->status_text && buddy->account->gc) { tmp = prpl_info->status_text(buddy); if(tmp && !g_utf8_validate(tmp, -1, &end)) { new = g_strndup(tmp, g_utf8_pointer_to_offset(tmp, end)); g_free(tmp); tmp = new; }
void ConfigFile::loadPurpleAccountSettings(Configuration &configuration) { if (!m_loaded) return; if (!g_key_file_has_group(keyfile, "purple")) return; PurplePlugin *plugin = purple_find_prpl(Transport::instance()->protocol()->protocol().c_str()); PurplePluginProtocolInfo *prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(plugin); for (GList *l = prpl_info->protocol_options; l != NULL; l = l->next) { PurpleAccountOption *option = (PurpleAccountOption *) l->data; PurpleAccountSettingValue v; v.type = purple_account_option_get_type(option); std::string key(purple_account_option_get_setting(option)); switch (v.type) { case PURPLE_PREF_BOOLEAN: if (g_key_file_has_key(keyfile, "purple", key.c_str(), NULL)) { loadBoolean(v.b, "purple", key); configuration.purple_account_settings[key] = v; } // else // v.b = purple_account_option_get_default_bool(option); break; case PURPLE_PREF_INT: if (g_key_file_has_key(keyfile, "purple", key.c_str(), NULL)) { loadInteger(v.i, "purple", key); configuration.purple_account_settings[key] = v; } // else // v.i = purple_account_option_get_default_int(option); break; case PURPLE_PREF_STRING: if (g_key_file_has_key(keyfile, "purple", key.c_str(), NULL)) { std::string str; loadString(str, "purple", key); v.str = g_strdup(str.c_str()); configuration.purple_account_settings[key] = v; } // else { // const char *str = purple_account_option_get_default_string(option); // v.str = str ? g_strdup(str) : NULL; // } break; case PURPLE_PREF_STRING_LIST: if (g_key_file_has_key(keyfile, "purple", key.c_str(), NULL)) { loadStringList(v.strlist, "purple", key); configuration.purple_account_settings[key] = v; } break; default: continue; } } }
static gboolean plugin_load(PurplePlugin *plugin) { PurplePlugin *prpl = NULL; PurpleAccountOption *option; void *gc_handle = NULL; #if !PURPLE_VERSION_CHECK(2,4,0) gchar *notice_help = NULL; #endif prpl = purple_find_prpl("prpl-irc"); /* if we didn't find the prpl, bail */ if (!prpl) return FALSE; #if !PURPLE_VERSION_CHECK(2,4,0) /* specify our help string and register our command */ notice_help = _("notice target message: Send a notice to the specified target."); notice_cmd_id = purple_cmd_register("notice", "ws", PURPLE_CMD_P_PLUGIN, PURPLE_CMD_FLAG_IM | PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_PRPL_ONLY, "prpl-irc", notice_cmd_cb, notice_help, NULL); #endif /* we need this handle for the signed-on signal */ gc_handle = purple_connections_get_handle(); /* list signals in alphabetical order for consistency */ purple_signal_connect(prpl, "irc-sending-text", plugin, G_CALLBACK(irc_sending_text), NULL); purple_signal_connect(prpl, "irc-receiving-text", plugin, G_CALLBACK(irc_receiving_text), NULL); purple_signal_connect(gc_handle, "signed-on", plugin, G_CALLBACK(signed_on_cb), NULL); irc_info = PURPLE_PLUGIN_PROTOCOL_INFO(prpl); /* Alphabetize the option label strings */ option = purple_account_option_string_new(_("Auto-Join Channels"), "autojoin", ""); irc_info->protocol_options = g_list_append(irc_info->protocol_options, option); option = purple_account_option_string_new(_("CTCP Version reply"), "ctcp-message", "Purple IRC"); irc_info->protocol_options = g_list_append(irc_info->protocol_options, option); option = purple_account_option_string_new(_("Default Quit Message"), "quit-message", "Leaving."); irc_info->protocol_options = g_list_append(irc_info->protocol_options, option); option = purple_account_option_string_new(_("Default Part Message"), "part-message", "Leaving."); irc_info->protocol_options = g_list_append(irc_info->protocol_options, option); option = purple_account_option_string_new(_("Set User Modes On Connect"), "setumodes", "i"); irc_info->protocol_options = g_list_append(irc_info->protocol_options, option); option = purple_account_option_string_new(_("Unset User Modes On Connect"), "unsetumodes", ""); irc_info->protocol_options = g_list_append(irc_info->protocol_options, option); return TRUE; }
void _purple_connection_new_unregister(PurpleAccount *account, const char *password, PurpleAccountUnregistrationCb cb, void *user_data) { /* Lots of copy/pasted code to avoid API changes. You might want to integrate that into the previous function when posssible. */ PurpleConnection *gc; PurplePlugin *prpl; PurplePluginProtocolInfo *prpl_info; g_return_if_fail(account != NULL); prpl = purple_find_prpl(purple_account_get_protocol_id(account)); if (prpl != NULL) prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(prpl); else { gchar *message; message = g_strdup_printf(_("Missing protocol plugin for %s"), purple_account_get_username(account)); purple_notify_error(NULL, _("Unregistration Error"), message, NULL); g_free(message); return; } if (!purple_account_is_disconnected(account)) { prpl_info->unregister_user(account, cb, user_data); return; } if (((password == NULL) || (*password == '\0')) && !(prpl_info->options & OPT_PROTO_NO_PASSWORD) && !(prpl_info->options & OPT_PROTO_PASSWORD_OPTIONAL)) { purple_debug_error("connection", "Cannot connect to account %s without " "a password.\n", purple_account_get_username(account)); return; } gc = g_new0(PurpleConnection, 1); PURPLE_DBUS_REGISTER_POINTER(gc, PurpleConnection); gc->prpl = prpl; if ((password != NULL) && (*password != '\0')) gc->password = g_strdup(password); purple_connection_set_account(gc, account); purple_connection_set_state(gc, PURPLE_CONNECTING); connections = g_list_append(connections, gc); purple_account_set_connection(account, gc); purple_signal_emit(purple_connections_get_handle(), "signing-on", gc); purple_debug_info("connection", "Unregistering. gc = %p\n", gc); prpl_info->unregister_user(account, cb, user_data); }
bool PurpleIMChat::sendMessageCbk(void * dataIn) { Mutex::ScopedLock lock(PurpleIMChat::_mutex); PurpleIMChatCallbackData* cbData = (PurpleIMChatCallbackData*) dataIn; IMChatSession* chatSession = cbData->getIMChatSession(); // const char * message = (const char *)((misc_t *)data)->data_ptr2; // char *cleanMess = (char *) message; // bool cleaned = false; std::string cleanMsg = cbData->getMessage(); mConvInfo_t *mConv = FindChatStructById(chatSession->getId()); PurpleConversation *gConv = mConv->purple_conv_session; //VOXOX - JRT - 2009.07.09 // special case for ICQ PurpleAccount *gAccount = purple_conversation_get_account(gConv); PurplePlugin *prpl = purple_find_prpl(purple_account_get_protocol_id(gAccount)); if (prpl) { PurplePluginProtocolInfo *prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(prpl); if (prpl_info->list_icon != NULL) { if (!strcmp("icq", prpl_info->list_icon(gAccount, NULL))) { // cleanMess = (char *) purple_markup_strip_html(message); cleanMsg= purple_markup_strip_html( cbData->getMessage().c_str() ); // cleaned = true; } } } if (purple_conversation_get_type(gConv) == PURPLE_CONV_TYPE_IM) { purple_conv_im_send_with_flags(PURPLE_CONV_IM(gConv), cleanMsg.c_str(), PURPLE_MESSAGE_SEND); } else if (purple_conversation_get_type(gConv) == PURPLE_CONV_TYPE_CHAT) { purple_conv_chat_send_with_flags(PURPLE_CONV_CHAT(gConv), cleanMsg.c_str(), PURPLE_MESSAGE_SEND); } // if (cleaned) // { // g_free(cleanMess); // } timeoutRemove( cbData ); delete cbData; return TRUE; }
void purple_prpl_send_attention(PurpleConnection *gc, const char *who, guint type_code) { PurpleAttentionType *attn; PurpleMessageFlags flags; PurplePlugin *prpl; PurpleConversation *conv; gboolean (*send_attention)(PurpleConnection *, const char *, guint); PurpleBuddy *buddy; const char *alias; gchar *description; time_t mtime; g_return_if_fail(gc != NULL); g_return_if_fail(who != NULL); prpl = purple_find_prpl(purple_account_get_protocol_id(gc->account)); send_attention = PURPLE_PLUGIN_PROTOCOL_INFO(prpl)->send_attention; g_return_if_fail(send_attention != NULL); mtime = time(NULL); attn = purple_get_attention_type_from_code(gc->account, type_code); if ((buddy = purple_find_buddy(purple_connection_get_account(gc), who)) != NULL) alias = purple_buddy_get_contact_alias(buddy); else alias = who; if (attn && purple_attention_type_get_outgoing_desc(attn)) { description = g_strdup_printf(purple_attention_type_get_outgoing_desc(attn), alias); } else { description = g_strdup_printf(_("Requesting %s's attention..."), alias); } flags = PURPLE_MESSAGE_SEND | PURPLE_MESSAGE_NOTIFY | PURPLE_MESSAGE_SYSTEM; purple_debug_info("server", "serv_send_attention: sending '%s' to %s\n", description, who); if (!send_attention(gc, who, type_code)) return; conv = purple_conversation_new(PURPLE_CONV_TYPE_IM, gc->account, who); purple_conv_im_write(PURPLE_CONV_IM(conv), NULL, description, flags, mtime); purple_prpl_attention(conv, who, type_code, PURPLE_MESSAGE_SEND, time(NULL)); g_free(description); }
static void do_prpl_change_account_status(PurpleAccount *account, PurpleStatus *old_status, PurpleStatus *new_status) { PurplePlugin *prpl; PurplePluginProtocolInfo *prpl_info; if (purple_status_is_online(new_status) && purple_account_is_disconnected(account) && purple_network_is_available()) { purple_account_connect(account); return; } if (!purple_status_is_online(new_status)) { if (!purple_account_is_disconnected(account)) purple_account_disconnect(account); /* Clear out the unsaved password if we're already disconnected and we switch to offline status */ else if (!purple_account_get_remember_password(account)) purple_account_set_password(account, NULL); return; } if (purple_account_is_connecting(account)) /* * We don't need to call the set_status PRPL function because * the PRPL will take care of setting its status during the * connection process. */ return; prpl = purple_find_prpl(purple_account_get_protocol_id(account)); if (prpl == NULL) return; prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(prpl); if (!purple_account_is_disconnected(account) && prpl_info->set_status != NULL) { prpl_info->set_status(account, new_status); } }
void heliotrope_xfire_tooltip_text(PurpleBuddy *buddy) { PurplePlugin *prpl; PurplePluginProtocolInfo *prpl_info; PurpleAccount *account; PurpleNotifyUserInfo *user_info; PurplePresence *presence; user_info = purple_notify_user_info_new(); account = purple_buddy_get_account(buddy); presence = purple_buddy_get_presence(buddy); prpl = purple_find_prpl(purple_account_get_protocol_id(account)); prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(prpl); if (prpl_info && prpl_info->tooltip_text) { prpl_info->tooltip_text(buddy, user_info, 0); } purple_notify_user_info_destroy(user_info); }
static gboolean plugin_load(PurplePlugin *plugin) { PurplePlugin *jabber; jabber = purple_find_prpl("prpl-jabber"); if (!jabber) return FALSE; xmpp_console_handle = plugin; purple_signal_connect(jabber, "jabber-receiving-xmlnode", xmpp_console_handle, PURPLE_CALLBACK(xmlnode_received_cb), NULL); purple_signal_connect(jabber, "jabber-sending-text", xmpp_console_handle, PURPLE_CALLBACK(xmlnode_sent_cb), NULL); purple_signal_connect(purple_connections_get_handle(), "signing-on", plugin, PURPLE_CALLBACK(signing_on_cb), NULL); purple_signal_connect(purple_connections_get_handle(), "signed-off", plugin, PURPLE_CALLBACK(signed_off_cb), NULL); return TRUE; }
void pidgin_syslog_show() { GList *accounts = NULL; GList *logs = NULL; if (syslog_viewer != NULL) { gtk_window_present(GTK_WINDOW(syslog_viewer->window)); return; } for(accounts = purple_accounts_get_all(); accounts != NULL; accounts = accounts->next) { PurpleAccount *account = (PurpleAccount *)accounts->data; if(purple_find_prpl(purple_account_get_protocol_id(account)) == NULL) continue; logs = g_list_concat(purple_log_get_system_logs(account), logs); } logs = g_list_sort(logs, purple_log_compare); syslog_viewer = display_log_viewer(NULL, logs, _("System Log"), NULL, 0); }
static gboolean plugin_load(PurplePlugin *plugin) { PurplePlugin *jabber = purple_find_prpl("prpl-jabber"); if (!jabber) return FALSE; //Publish support via caps gboolean ok; purple_plugin_ipc_call (jabber, "add_feature", &ok, "urn:xmpp:receipts"); #ifdef DEBUG if (ok) printf("receipt feature added\n"); else printf("receipt feature not added (will work anyway with most clients)\n"); #endif xmpp_console_handle = plugin; ht_locations = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); purple_signal_connect(jabber, "jabber-receiving-xmlnode", xmpp_console_handle, PURPLE_CALLBACK(xmlnode_received_cb), NULL); purple_signal_connect(jabber, "jabber-sending-xmlnode", xmpp_console_handle, PURPLE_CALLBACK(xmlnode_sending_cb), NULL); //Connect signals for conversations to clean references void *conv_handle = purple_conversations_get_handle(); purple_signal_connect(conv_handle, "deleting-conversation", plugin, PURPLE_CALLBACK(deleting_conversation_cb), NULL); return TRUE; }
/* Send an OTR Query Message to attempt to start a connection */ void otrg_ui_connect_connection(ConnContext *context) { /* Send an OTR Query to the other side. */ PurpleAccount *account; char *msg; /* Don't do this if we're already ENCRYPTED */ if (context == NULL || context->msgstate == OTRL_MSGSTATE_ENCRYPTED) return; account = purple_accounts_find(context->accountname, context->protocol); if (!account) { PurplePlugin *p = purple_find_prpl(context->protocol); msg = g_strdup_printf(_("Account %s (%s) could not be found"), context->accountname, (p && p->info->name) ? p->info->name : _("Unknown")); otrg_dialog_notify_error(context->accountname, context->protocol, context->username, _("Account not found"), msg, NULL); g_free(msg); return; } otrg_plugin_send_default_query(context, account); }
/* Update the keylist, if it's visible */ static void otrg_gtk_ui_update_keylist(void) { gchar *titles[5]; char hash[OTRL_PRIVKEY_FPRINT_HUMAN_LEN]; ConnContext * context; Fingerprint * fingerprint; int selected_row = -1; GtkWidget *keylist = ui_layout.keylist; if (keylist == NULL) return; gtk_clist_freeze(GTK_CLIST(keylist)); gtk_clist_clear(GTK_CLIST(keylist)); for (context = otrg_plugin_userstate->context_root; context != NULL; context = context->next) { int i; PurplePlugin *p; const char *proto_name; if (context->m_context != context) continue; fingerprint = context->fingerprint_root.next; /* If there's no fingerprint, don't add it to the known * fingerprints list */ while(fingerprint) { ConnContext *context_iter; TrustLevel best_level = TRUST_NOT_PRIVATE; int used = 0; titles[0] = context->username; titles[1] = _("Unused"); for (context_iter = context->m_context; context_iter && context_iter->m_context == context->m_context; context_iter = context_iter->next) { TrustLevel this_level = TRUST_NOT_PRIVATE; if (context_iter->active_fingerprint == fingerprint) { this_level = otrg_plugin_context_to_trust(context_iter); used = 1; if (this_level == TRUST_PRIVATE) { best_level = TRUST_PRIVATE; } else if (this_level == TRUST_UNVERIFIED && best_level != TRUST_PRIVATE) { best_level = TRUST_UNVERIFIED; } else if (this_level == TRUST_FINISHED && best_level == TRUST_NOT_PRIVATE) { best_level = TRUST_FINISHED; } } } if (used) { titles[1] = (gchar *) _(trust_states[best_level]); } titles[2] = otrg_fingerprint_is_trusted(fingerprint) ? _("Yes") : _("No"); otrl_privkey_hash_to_human(hash, fingerprint->fingerprint); titles[3] = hash; p = purple_find_prpl(context->protocol); proto_name = (p && p->info->name) ? p->info->name : _("Unknown"); titles[4] = g_strdup_printf("%s (%s)", context->accountname, proto_name); i = gtk_clist_append(GTK_CLIST(keylist), titles); g_free(titles[4]); gtk_clist_set_row_data(GTK_CLIST(keylist), i, fingerprint); if (ui_layout.selected_fprint == fingerprint) { selected_row = i; } fingerprint = fingerprint->next; } } if (selected_row >= 0) { gtk_clist_select_row(GTK_CLIST(keylist), selected_row, 0); } else { clist_all_unselected(); } gtk_clist_sort(GTK_CLIST(keylist)); gtk_clist_thaw(GTK_CLIST(keylist)); }
void init_acct_features_dialog(struct acct_features_dialog *f_diag) { GList *a = purple_accounts_get_all_active(); /* TODO: should be freed ? */ GdkPixbuf *yes = gtk_widget_render_icon(f_diag->window, GTK_STOCK_YES, GTK_ICON_SIZE_MENU, NULL); GdkPixbuf *no = gtk_widget_render_icon(f_diag->window, GTK_STOCK_NO, GTK_ICON_SIZE_MENU, NULL); /* last line summarize all available features */ GtkTreeIter e_iter; GdkPixbuf *e_icon = gtk_widget_render_icon(f_diag->window, PIDGIN_STOCK_INFO, GTK_ICON_SIZE_MENU, NULL); GdkPixbuf *e_pm = no; GdkPixbuf *e_buddyicon = no; GdkPixbuf *e_nickname = no; GdkPixbuf *e_mood = no; GdkPixbuf *e_moodmsg = no; GdkPixbuf *e_game = no; GdkPixbuf *e_app = no; GdkPixbuf *e_tune = no; for(; a ; a = a->next) { PurpleAccount *acct = (PurpleAccount *)a->data; PurplePlugin *plugin = purple_find_prpl(acct->protocol_id); PurplePluginProtocolInfo *protocol = PURPLE_PLUGIN_PROTOCOL_INFO(plugin); GtkTreeIter iter; gchar *username = g_strdup_printf("%s (%s)", purple_account_get_username(acct), purple_account_get_protocol_name(acct)); GdkPixbuf *a_icon = pidgin_create_prpl_icon(acct, PIDGIN_PRPL_ICON_MEDIUM); GHashTable *attrs = get_account_attrs(acct); GdkPixbuf *nickname, *mood, *moodmsg, *game, *app, *tune, *pm, *buddyicon; if(g_hash_table_lookup(attrs, "mood")) e_mood = mood = yes; else mood = no; if(g_hash_table_lookup(attrs, "moodtext")) e_moodmsg = moodmsg = yes; else moodmsg = no; if(g_hash_table_lookup(attrs, "game")) e_game = game = yes; else game = no; if(g_hash_table_lookup(attrs, "office")) e_app = app = yes; else app = no; if((g_hash_table_lookup(attrs, "tune_title") && g_hash_table_lookup(attrs, "tune_artist") && g_hash_table_lookup(attrs, "tune_album"))) e_tune = tune = yes; else tune = no; g_hash_table_destroy(attrs); if(protocol->set_status) e_pm = pm = yes; else pm = no; if(protocol->set_buddy_icon) e_buddyicon = buddyicon = yes; else buddyicon = no; /* exception for XMPP nickname supported manually FIXME: however some XMPP account don't support nickname extension */ if(!strcmp(acct->protocol_id, "prpl-jabber") || protocol->set_public_alias) e_nickname = nickname = yes; else nickname = no; gtk_list_store_append(f_diag->list_store, &iter); gtk_list_store_set(f_diag->list_store, &iter, ACCT_COLUMN, username, ACCTICON_COLUMN, a_icon, NICKNAME_COLUMN, nickname, PM_COLUMN, pm, ICON_COLUMN, buddyicon, MOOD_COLUMN, mood, MOODMSG_COLUMN, moodmsg, TUNE_COLUMN, tune, GAME_COLUMN, game, APP_COLUMN, app, -1); g_free(username); } /* last line summarize all available features */ gtk_list_store_append(f_diag->list_store, &e_iter); gtk_list_store_set(f_diag->list_store, &e_iter, ACCT_COLUMN, "Available features", ACCTICON_COLUMN, e_icon, NICKNAME_COLUMN, e_nickname, PM_COLUMN, e_pm, ICON_COLUMN, e_buddyicon, MOOD_COLUMN, e_mood, MOODMSG_COLUMN, e_moodmsg, TUNE_COLUMN, e_tune, GAME_COLUMN, e_game, APP_COLUMN, e_app, -1); }
void AccountWindow::populateAccount(PurpleAccount *account) { if (account_entries.find(account) == account_entries.end()) { // no entry for this account, so add one AccountEntry entry; entry.parent = NULL; account_entries[account] = entry; } else { // the account exists, so clear all data clearAccount(account, false); } AccountEntry *account_entry = &account_entries[account]; if (!account_entry->parent) { CppConsUI::TreeView::ToggleCollapseButton *button = new CppConsUI::TreeView::ToggleCollapseButton; CppConsUI::TreeView::NodeReference parent_reference = treeview->appendNode(treeview->getRootNode(), *button); treeview->setCollapsed(parent_reference, true); account_entry->parent = button; account_entry->parent_reference = parent_reference; } char *label = g_strdup_printf("[%s] %s", purple_account_get_protocol_name(account), purple_account_get_username(account)); account_entry->parent->setText(label); g_free(label); const char *protocol_id = purple_account_get_protocol_id(account); PurplePlugin *prpl = purple_find_prpl(protocol_id); if (!prpl) { // we cannot change the settings of an unknown account CppConsUI::Label *label = new CppConsUI::Label( _("Invalid account or protocol plugin not loaded.")); treeview->appendNode(account_entry->parent_reference, *label); } else { PurplePluginProtocolInfo *prplinfo = PURPLE_PLUGIN_PROTOCOL_INFO(prpl); // protocols combobox ProtocolOption *combobox = new ProtocolOption(account, *this); CppConsUI::TreeView::NodeReference protocol_node = treeview->appendNode(account_entry->parent_reference, *combobox); combobox->grabFocus(); /* The username must be treated in a special way because it can contain * multiple values (e.g. user@server:port/resource). */ char *username = g_strdup(purple_account_get_username(account)); for (GList *iter = g_list_last(prplinfo->user_splits); iter; iter = iter->prev) { PurpleAccountUserSplit *split = reinterpret_cast<PurpleAccountUserSplit*>(iter->data); char *s; if (purple_account_user_split_get_reverse(split)) s = strrchr(username, purple_account_user_split_get_separator(split)); else s = strchr(username, purple_account_user_split_get_separator(split)); const char *value; if (s) { *s = '\0'; value = s + 1; } else value = purple_account_user_split_get_default_value(split); // create widget for the username split and remember SplitOption *widget_split = new SplitOption(account, split, account_entry); widget_split->setValue(value); account_entry->split_widgets.push_front(widget_split); treeview->appendNode(account_entry->parent_reference, *widget_split); } SplitOption *widget_split = new SplitOption(account, NULL, account_entry); widget_split->setValue(username); account_entry->split_widgets.push_front(widget_split); treeview->insertNodeAfter(protocol_node, *widget_split); g_free(username); // password Widget *widget = new StringOption(account, StringOption::TYPE_PASSWORD); treeview->appendNode(account_entry->parent_reference, *widget); // remember password widget = new BoolOption(account, BoolOption::TYPE_REMEMBER_PASSWORD); treeview->appendNode(account_entry->parent_reference, *widget); // alias widget = new StringOption(account, StringOption::TYPE_ALIAS); treeview->appendNode(account_entry->parent_reference, *widget); for (GList *pref = prplinfo->protocol_options; pref; pref = pref->next) { PurpleAccountOption *option = reinterpret_cast<PurpleAccountOption*>(pref->data); PurplePrefType type = purple_account_option_get_type(option); switch (type) { case PURPLE_PREF_STRING: widget = new StringOption(account, option); treeview->appendNode(account_entry->parent_reference, *widget); break; case PURPLE_PREF_INT: widget = new IntegerOption(account, option); treeview->appendNode(account_entry->parent_reference, *widget); break; case PURPLE_PREF_BOOLEAN: widget = new BoolOption(account, option); treeview->appendNode(account_entry->parent_reference, *widget); break; case PURPLE_PREF_STRING_LIST: widget = new StringListOption(account, option); treeview->appendNode(account_entry->parent_reference, *widget); break; default: LOG->error(_("Unhandled account option type '%d'."), type); break; } } // enable/disable account widget = new BoolOption(account, BoolOption::TYPE_ENABLE_ACCOUNT); treeview->appendNode(account_entry->parent_reference, *widget); // coloring widget = new ColorOption(account); treeview->appendNode(account_entry->parent_reference, *widget); } // drop account CppConsUI::Button *drop_button = new CppConsUI::Button(_("Drop account")); drop_button->signal_activate.connect(sigc::bind(sigc::mem_fun(this, &AccountWindow::dropAccount), account)); treeview->appendNode(account_entry->parent_reference, *drop_button); }
void purple_plugins_probe(const char *ext) { #ifdef PURPLE_PLUGINS GDir *dir; const gchar *file; gchar *path; PurplePlugin *plugin; GList *cur; const char *search_path; if (!g_module_supported()) return; /* Probe plugins */ for (cur = search_paths; cur != NULL; cur = cur->next) { search_path = cur->data; dir = g_dir_open(search_path, 0, NULL); if (dir != NULL) { while ((file = g_dir_read_name(dir)) != NULL) { path = g_build_filename(search_path, file, NULL); if (ext == NULL || has_file_extension(file, ext)) purple_plugin_probe(path); g_free(path); } g_dir_close(dir); } } /* See if we have any plugins waiting to load */ while (load_queue != NULL) { plugin = (PurplePlugin *)load_queue->data; load_queue = g_list_remove(load_queue, plugin); if (plugin == NULL || plugin->info == NULL) continue; if (plugin->info->type == PURPLE_PLUGIN_LOADER) { /* We'll just load this right now. */ if (!purple_plugin_load(plugin)) { purple_plugin_destroy(plugin); continue; } plugin_loaders = g_list_append(plugin_loaders, plugin); for (cur = PURPLE_PLUGIN_LOADER_INFO(plugin)->exts; cur != NULL; cur = cur->next) { purple_plugins_probe(cur->data); } } else if (plugin->info->type == PURPLE_PLUGIN_PROTOCOL) { /* We'll just load this right now. */ if (!purple_plugin_load(plugin)) { purple_plugin_destroy(plugin); continue; } /* Make sure we don't load two PRPLs with the same name? */ if (purple_find_prpl(plugin->info->id)) { /* Nothing to see here--move along, move along */ purple_plugin_destroy(plugin); continue; } protocol_plugins = g_list_insert_sorted(protocol_plugins, plugin, (GCompareFunc)compare_prpl); } } #endif /* PURPLE_PLUGINS */ }
void _purple_connection_new(PurpleAccount *account, gboolean regist, const char *password) { PurpleConnection *gc; PurplePlugin *prpl; PurplePluginProtocolInfo *prpl_info; g_return_if_fail(account != NULL); if (!purple_account_is_disconnected(account)) return; prpl = purple_find_prpl(purple_account_get_protocol_id(account)); if (prpl != NULL) prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(prpl); else { gchar *message; message = g_strdup_printf(_("Missing protocol plugin for %s"), purple_account_get_username(account)); purple_notify_error(NULL, regist ? _("Registration Error") : _("Connection Error"), message, NULL); g_free(message); return; } if (regist) { if (prpl_info->register_user == NULL) return; } else { if (((password == NULL) || (*password == '\0')) && !(prpl_info->options & OPT_PROTO_NO_PASSWORD) && !(prpl_info->options & OPT_PROTO_PASSWORD_OPTIONAL)) { purple_debug_error("connection", "Cannot connect to account %s without " "a password.\n", purple_account_get_username(account)); return; } } gc = g_new0(PurpleConnection, 1); PURPLE_DBUS_REGISTER_POINTER(gc, PurpleConnection); gc->prpl = prpl; if ((password != NULL) && (*password != '\0')) gc->password = g_strdup(password); purple_connection_set_account(gc, account); purple_connection_set_state(gc, PURPLE_CONNECTING); connections = g_list_append(connections, gc); purple_account_set_connection(account, gc); purple_signal_emit(purple_connections_get_handle(), "signing-on", gc); if (regist) { purple_debug_info("connection", "Registering. gc = %p\n", gc); /* set this so we don't auto-reconnect after registering */ gc->wants_to_die = TRUE; prpl_info->register_user(account); } else { purple_debug_info("connection", "Connecting. gc = %p\n", gc); purple_signal_emit(purple_accounts_get_handle(), "account-connecting", account); prpl_info->login(account); } }