GaimAccount * gaim_accounts_find_ext(const char *name, const char *protocol_id, gboolean (*account_test)(const GaimAccount *account)) { GaimAccount *result = NULL; GList *l; char *who; if (name) who = g_strdup(gaim_normalize(NULL, name)); else who = NULL; for (l = gaim_accounts_get_all(); l != NULL; l = l->next) { GaimAccount *account = (GaimAccount *)l->data; if (who && strcmp(gaim_normalize(NULL, gaim_account_get_username(account)), who)) continue; if (protocol_id && strcmp(account->protocol_id, protocol_id)) continue; if (account_test && !account_test(account)) continue; result = account; break; } g_free(who); return result; }
static void dequeue_message(GtkTreeIter *iter) { gchar *name; GSList *templist; GaimConversation *cnv; gboolean orig_while_away; orig_while_away = gaim_prefs_get_bool("/core/sound/while_away"); if (orig_while_away) gaim_prefs_set_bool("/core/sound/while_away", FALSE); gtk_tree_model_get(GTK_TREE_MODEL(awayqueuestore), iter, 0, &name, -1); gaim_debug(GAIM_DEBUG_INFO, "away", "Dequeueing messages from %s.\n", name); templist = message_queue; while (templist) { struct queued_message *qm = templist->data; if (templist->data) { if (!gaim_utf8_strcasecmp(qm->name, name)) { GaimAccount *account = NULL; if (g_list_index(gaim_accounts_get_all(), qm->account) >= 0) account = qm->account; cnv = gaim_find_conversation_with_account(name, account); if (!cnv) cnv = gaim_conversation_new(GAIM_CONV_IM, account, qm->name); else gaim_conversation_set_account(cnv, account); gaim_conv_im_write(GAIM_CONV_IM(cnv), NULL, qm->message, qm->flags, qm->tm); g_free(qm->message); g_free(qm); templist = message_queue = g_slist_remove(message_queue, qm); } else { templist = templist->next; } } } g_free(name); /* In GTK 2.2, _store_remove actually returns whether iter is valid or not * after the remove, but in GTK 2.0 it is a void function. */ gtk_list_store_remove(awayqueuestore, iter); if (orig_while_away) gaim_prefs_set_bool("/core/sound/while_away", orig_while_away); }
void purge_away_queue(GSList **queue) { GSList *q = *queue; struct queued_message *qm; GaimConversation *cnv; GaimAccount *account; gboolean orig_while_away; orig_while_away = gaim_prefs_get_bool("/core/sound/while_away"); if (orig_while_away) gaim_prefs_set_bool("/core/sound/while_away", FALSE); while (q) { qm = q->data; account = NULL; if (g_list_index(gaim_accounts_get_all(), qm->account) >= 0) account = qm->account; cnv = gaim_find_conversation_with_account(qm->name, account); if (!cnv) cnv = gaim_conversation_new(GAIM_CONV_IM, account, qm->name); else gaim_conversation_set_account(cnv, account); gaim_conv_im_write(GAIM_CONV_IM(cnv), NULL, qm->message, qm->flags, qm->tm); g_free(qm->message); g_free(qm); q->data = NULL; q = q->next; } g_slist_free(*queue); *queue = NULL; if (orig_while_away) gaim_prefs_set_bool("/core/sound/while_away", orig_while_away); }
/* <name> is a comma-separated list of names, or NULL if NULL and there is at least one user defined in .gaimrc, try to login. if not NULL, parse <name> into separate strings, look up each one in .gaimrc and, if it's there, try to login. returns: 0 if successful -1 if no user was found that had a saved password */ static int dologin_named(char *name) { GaimAccount *account; char **names, **n; int retval = -1; if (name !=NULL) { /* list of names given */ names = g_strsplit(name, ",", 32); for (n = names; *n != NULL; n++) { account = gaim_accounts_find(*n, NULL); if (account) { /* found a user */ retval = 0; gaim_account_connect(account); } } g_strfreev(names); } else { /* no name given, use default */ account = (GaimAccount *)gaim_accounts_get_all()->data; retval = 0; gaim_account_connect(account); } return retval; }
/* go through file and run any commands */ void run_commands() { struct stat finfo; char filename[256]; char buffer[1024]; char *command, *arg1, *arg2; FILE *file; sprintf(filename, "%s/.gaim/control", getenv("HOME")); file = fopen(filename, "r+"); while (fgets(buffer, sizeof buffer, file)) { if (buffer[strlen(buffer) - 1] == '\n') buffer[strlen(buffer) - 1] = 0; gaim_debug(GAIM_DEBUG_MISC, "filectl", "read: %s\n", buffer); command = getarg(buffer, 0, 0); if (!strncasecmp(command, "signon", 6)) { GaimAccount *account = NULL; GList *accts = gaim_accounts_get_all(); arg1 = getarg(buffer, 1, 1); if (arg1) { while (accts) { GaimAccount *a = accts->data; if (!strcmp(a->username, arg1)) { account = a; break; } accts = accts->next; } free(arg1); } if (account) /* username found */ gaim_account_connect(account); } else if (!strncasecmp(command, "signoff", 7)) { GaimConnection *gc = NULL; GList *c = gaim_connections_get_all(); arg1 = getarg(buffer, 1, 1); while (arg1 && c) { gc = c->data; if (!strcmp(gc->account->username, arg1)) { break; } gc = NULL; c = c->next; } if (gc) gaim_connection_disconnect(gc); else if (!arg1) gaim_connections_disconnect_all(); free(arg1); } else if (!strncasecmp(command, "send", 4)) { GaimConversation *c; arg1 = getarg(buffer, 1, 0); arg2 = getarg(buffer, 2, 1); c = gaim_find_conversation(arg1); if (c) { /* disable for now gaim_conversation_write(c, arg2, WFLAG_SEND, NULL, time(NULL), -1); serv_send_im(c->gc, arg1, arg2, 0); */ } free(arg1); free(arg2); } else if (!strncasecmp(command, "away", 4)) { arg1 = getarg(buffer, 1, 1); serv_set_away_all(arg1); free(arg1); } else if (!strncasecmp(command, "hide", 4)) { /* hide_buddy_list(); */ } else if (!strncasecmp(command, "unhide", 6)) { /* unhide_buddy_list(); */ } else if (!strncasecmp(command, "back", 4)) { /* do_im_back(); */ } else if (!strncasecmp(command, "quit", 4)) { /* gaim_core_quit(); */ } free(command); } fclose(file); if (stat (filename, &finfo) != 0) return; mtime = finfo.st_mtime; }
void show_login() { GtkWidget *image; GtkWidget *hbox_toplevel; GtkWidget *vbox; GtkWidget *button; GtkWidget *hbox; GtkWidget *label; GtkWidget *vbox2; GtkWidget *table; #ifdef GAIM_SMALL_SCREEN #ifdef ENABLE_HILDON GtkWidget *hbox1; GtkWidget *vbox1; #endif GtkWidget *hseparator; #endif /* Do we already have a main window opened? If so, bring it back, baby... ribs... yeah */ #ifdef ENABLE_HILDON if (login_app_view) { hildon_app_set_appview(HILDON_APP(app), HILDON_APPVIEW(login_app_view)); g_object_unref(login_app_view); return; } mainwindow = current_app_view = login_app_view = hildon_appview_new(_("Login")); hildon_app_set_appview(HILDON_APP(app), HILDON_APPVIEW(login_app_view)); hbox_toplevel = gtk_hbox_new(FALSE, 0); gtk_container_add(GTK_CONTAINER(login_app_view), hbox_toplevel); g_signal_connect(G_OBJECT(login_app_view), "delete_event", G_CALLBACK(login_window_closed), login_app_view); #else if (mainwindow) { gtk_window_present(GTK_WINDOW(mainwindow)); return; } #ifdef GAIM_SMALL_SCREEN mainwindow = gtk_dialog_new(); gtk_window_set_modal(GTK_WINDOW(mainwindow), TRUE); gtk_dialog_set_has_separator(mainwindow, FALSE); #else mainwindow = gtk_window_new(GTK_WINDOW_TOPLEVEL); #endif gtk_window_set_role(GTK_WINDOW(mainwindow), "login"); gtk_window_set_resizable(GTK_WINDOW(mainwindow), FALSE); gtk_window_set_title(GTK_WINDOW(mainwindow), _("Login")); gtk_container_set_border_width(GTK_CONTAINER(mainwindow), 5); g_signal_connect(G_OBJECT(mainwindow), "delete_event", G_CALLBACK(login_window_closed), mainwindow); hbox_toplevel = gtk_hbox_new(FALSE, 0); #ifdef GAIM_SMALL_SCREEN gtk_container_add(GTK_CONTAINER(GTK_DIALOG(mainwindow)->vbox), hbox_toplevel); #else gtk_container_add(GTK_CONTAINER(mainwindow), hbox_toplevel); #endif #endif vbox_toplevel = vbox = gtk_vbox_new(FALSE, 0); gtk_box_pack_start(GTK_BOX(hbox_toplevel), vbox, FALSE, FALSE, BOX_SPACING); #ifdef GAIM_SMALL_SCREEN /* Now for the button box */ hbox = gtk_hbox_new(FALSE, 0); #ifdef ENABLE_HILDON hbox1 = gtk_hbox_new(FALSE, BOX_SPACING); vbox1 = gtk_vbox_new(FALSE, 0); gtk_box_pack_start(GTK_BOX(vbox), hbox1, TRUE, FALSE, 0); gtk_box_pack_end(GTK_BOX(hbox1), vbox1, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(vbox1), hbox, FALSE, FALSE, 0); vbox = vbox1; #else gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); #endif /* lets put the image also in the hbox */ image = gtk_image_new_from_stock(GAIM_STOCK_LOGO, gtk_icon_size_from_name(GAIM_ICON_SIZE_LOGO)); #ifdef ENABLE_HILDON gtk_box_pack_start(GTK_BOX(hbox1), image, FALSE, FALSE, 0); #else gtk_box_pack_start(GTK_BOX(hbox), image, FALSE, FALSE, 0); #endif /* And now for the buttons */ button = gaim_pixbuf_button_from_stock(_("A_ccounts"), GAIM_STOCK_ACCOUNTS, GAIM_BUTTON_VERTICAL); gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(gaim_gtk_accounts_window_show), mainwindow); gtk_box_pack_end(GTK_BOX(hbox), button, FALSE, FALSE, 0); button = gaim_pixbuf_button_from_stock(_("P_references"), GTK_STOCK_PREFERENCES, GAIM_BUTTON_VERTICAL); gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(gaim_gtk_prefs_show), mainwindow); gtk_box_pack_end(GTK_BOX(hbox), button, FALSE, FALSE, 0); button = gaim_pixbuf_button_from_stock(_("_Sign on"), GAIM_STOCK_SIGN_ON, GAIM_BUTTON_VERTICAL); gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(dologin), mainwindow); g_signal_connect(G_OBJECT(button), "button-press-event", G_CALLBACK(domiddleclick), NULL); gtk_box_pack_end(GTK_BOX(hbox), button, FALSE, FALSE, 0); hseparator = gtk_hseparator_new (); gtk_widget_show (hseparator); gtk_box_pack_start (GTK_BOX (vbox), hseparator, FALSE, TRUE, 2); #else image = gtk_image_new_from_stock(GAIM_STOCK_LOGO, gtk_icon_size_from_name(GAIM_ICON_SIZE_LOGO)); gtk_box_pack_start(GTK_BOX(vbox), image, FALSE, FALSE, 0); #endif table = gtk_table_new (2, 2, FALSE); gtk_widget_show (table); gtk_box_pack_start (GTK_BOX (vbox), table, TRUE, TRUE, 0); gtk_table_set_row_spacings (GTK_TABLE (table), 2); gtk_table_set_col_spacings (GTK_TABLE (table), 2); /* why isn't there a gtk_label_new_with_markup? */ label = gtk_label_new(NULL); gtk_widget_show (label); gtk_label_set_markup_with_mnemonic(GTK_LABEL(label), _("<b>_Account:</b>")); gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0); gtk_misc_set_alignment (GTK_MISC (label), 1, 0.5); name = gaim_gtk_account_option_menu_new(NULL, TRUE, G_CALLBACK(combo_changed), NULL, NULL); gtk_label_set_mnemonic_widget(GTK_LABEL(label), name); gtk_widget_show (name); gtk_table_attach (GTK_TABLE (table), name, 1, 2, 0, 1, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0); label = gtk_label_new(NULL); gtk_widget_show (label); gtk_label_set_markup_with_mnemonic(GTK_LABEL(label), _("<b>_Password:</b>")); gtk_table_attach (GTK_TABLE (table), label, 0, 1, 1, 2, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0); gtk_misc_set_alignment (GTK_MISC (label), 1, 0.5); pass = gtk_entry_new(); gtk_label_set_mnemonic_widget(GTK_LABEL(label), pass); gtk_entry_set_visibility(GTK_ENTRY(pass), FALSE); gtk_table_attach (GTK_TABLE (table), pass, 1, 2, 1, 2, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0); #ifndef GAIM_SMALL_SCREEN g_signal_connect(G_OBJECT(pass), "activate", G_CALLBACK(dologin), mainwindow); /* gtk_box_pack_start(GTK_BOX(vbox2), pass, FALSE, TRUE, 0); gtk_box_pack_start(GTK_BOX(vbox), vbox2, FALSE, TRUE, 0); */ /* Now for the button box */ hbox = gtk_hbox_new(TRUE, 0); /* gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE, 5); */ gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 5); /* And now for the buttons */ button = gaim_pixbuf_button_from_stock(_("A_ccounts"), GAIM_STOCK_ACCOUNTS, GAIM_BUTTON_VERTICAL); gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(gaim_gtk_accounts_window_show), mainwindow); gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); button = gaim_pixbuf_button_from_stock(_("P_references"), GTK_STOCK_PREFERENCES, GAIM_BUTTON_VERTICAL); gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(gaim_gtk_prefs_show), mainwindow); gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); button = gaim_pixbuf_button_from_stock(_("_Sign on"), GAIM_STOCK_SIGN_ON, GAIM_BUTTON_VERTICAL); gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(dologin), mainwindow); g_signal_connect(G_OBJECT(button), "button-press-event", G_CALLBACK(domiddleclick), NULL); gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); #endif /* Now grab the focus that we need */ if (gaim_accounts_get_all()) { GaimAccount *account = gaim_accounts_get_all()->data; if (gaim_account_get_remember_password(account)) { combo_changed(NULL, account, NULL); gtk_widget_grab_focus(button); } else { gtk_widget_grab_focus(pass); } } else { gaim_gtk_accounts_window_show(); gtk_widget_grab_focus(button); } #ifndef ENABLE_HILDON /* And raise the curtain! */ gtk_widget_show_all(mainwindow); #else gtk_widget_show_all(login_app_view); #endif }