Yo.
gtk1-stable
v0_59_9
2003-03-01, Sean Egan
* Copyright (C) 1998-1999, Mark Spencer <markster@marko.net> * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #endif /* GAIM_PLUGINS */ #include "pixmaps/logo.xpm" static gchar *aspell_cmd[] = { "aspell", "--sug-mode=fast","-a", NULL }; static gchar *ispell_cmd[] = { "ispell", "-a", NULL }; GList *log_conversations = NULL; GList *buddy_pounces = NULL; GSList *away_messages = NULL; GList *conversations = NULL; GSList *message_queue = NULL; GSList *away_time_queue = NULL; GtkWidget *mainwindow = NULL; char *opt_away_arg = NULL; char *opt_rcfile_arg = NULL; char *opt_user_arg = NULL; void BuddyTickerCreateWindow(void); * Lists of signals we wish to catch and those we wish to ignore. * Each list terminated with -1 static int catch_sig_list[] = { static int ignore_sig_list[] = { applet_buddy_show = FALSE; gtk_widget_hide(mainwindow); /* first we tell those who have requested it we're quitting */ plugin_event(event_quit, 0, 0, 0, 0); /* then we remove everyone in a mass suicide */ #endif /* GAIM_PLUGINS */ int logins_not_muted = 1; static void sound_timeout() gtk_timeout_remove(snd_tmout); /* we need to do this for Oscar because serv_login only starts the login * process, it doesn't end there. gaim_setup will be called later from * oscar.c, after the buddy list is made and serv_finish_login is called */ void gaim_setup(struct gaim_connection *gc) if ((sound_options & OPT_SOUND_LOGIN) && (sound_options & OPT_SOUND_SILENT_SIGNON)) { snd_tmout = gtk_timeout_add(10000, (GtkFunction)sound_timeout, NULL); applet_widget_unregister_callback(APPLET_WIDGET(applet), "autologin"); applet_widget_register_callback(APPLET_WIDGET(applet), "signoff", _("Signoff"), (AppletCallbackFunc)signoff_all, NULL); static void dologin(GtkWidget *widget, GtkWidget *w) const char *username = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(name)->entry)); const char *password = gtk_entry_get_text(GTK_ENTRY(pass)); do_error_dialog(_("Please enter your logon"), _("Signon Error")); /* if there is more than one user of the same name, then fuck * them, they just have to use the account editor to sign in u = find_user(username, -1); u = new_user(username, DEFAULT_PROTO, OPT_USR_REM_PASS); g_snprintf(u->password, sizeof u->password, "%s", password); static void doenter(GtkWidget *widget, GtkWidget *w) gtk_entry_set_text(GTK_ENTRY(pass), ""); gtk_entry_select_region(GTK_ENTRY(GTK_COMBO(name)->entry), 0, 0); gtk_widget_grab_focus(pass); } else if (widget == pass) { static void combo_changed(GtkWidget *w, GtkWidget *combo) const char *txt = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(combo)->entry)); if (u && u->options & OPT_USR_REM_PASS) { gtk_entry_set_text(GTK_ENTRY(pass), u->password); gtk_entry_set_text(GTK_ENTRY(pass), ""); static GList *combo_user_names() return g_list_append(NULL, "<New User>"); u = (struct aim_user *)usr->data; tmp = g_list_append(tmp, u->username); gtk_widget_show(mainwindow); mainwindow = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_wmclass(GTK_WINDOW(mainwindow), "login", "Gaim"); gtk_window_set_policy(GTK_WINDOW(mainwindow), FALSE, FALSE, TRUE); gtk_signal_connect(GTK_OBJECT(mainwindow), "delete_event", GTK_SIGNAL_FUNC(cancel_logon), mainwindow); gtk_window_set_title(GTK_WINDOW(mainwindow), _("Gaim - Login")); gtk_widget_realize(mainwindow); aol_icon(mainwindow->window); gdk_window_set_group(mainwindow->window, mainwindow->window); table = gtk_table_new(8, 2, FALSE); gtk_container_add(GTK_CONTAINER(mainwindow), table); style = gtk_widget_get_style(mainwindow); pm = gdk_pixmap_create_from_xpm_d(mainwindow->window, &mask, &style->bg[GTK_STATE_NORMAL], (gchar **)gaim_logo_xpm); pmw = gtk_pixmap_new(pm, mask); gtk_table_attach(GTK_TABLE(table), pmw, 0, 2, 0, 1, 0, 0, 5, 5); label = gtk_label_new(_("Screen Name: ")); gtk_table_attach(GTK_TABLE(table), label, 0, 1, 2, 3, 0, 0, 5, 5); tmp = combo_user_names(); gtk_combo_set_popdown_strings(GTK_COMBO(name), tmp); gtk_signal_connect(GTK_OBJECT(GTK_COMBO(name)->entry), "activate", GTK_SIGNAL_FUNC(doenter), mainwindow); gtk_signal_connect(GTK_OBJECT(GTK_COMBO(name)->entry), "changed", GTK_SIGNAL_FUNC(combo_changed), name); gtk_widget_set_usize(name, 100, 0); gtk_table_attach(GTK_TABLE(table), name, 1, 2, 2, 3, 0, 0, 5, 5); label = gtk_label_new(_("Password: ")); gtk_table_attach(GTK_TABLE(table), label, 0, 1, 3, 4, 0, 0, 5, 5); gtk_widget_set_usize(pass, 100, 0); gtk_entry_set_visibility(GTK_ENTRY(pass), FALSE); gtk_signal_connect(GTK_OBJECT(pass), "activate", GTK_SIGNAL_FUNC(doenter), mainwindow); gtk_table_attach(GTK_TABLE(table), pass, 1, 2, 3, 4, 0, 0, 5, 5); sbox = gtk_vbox_new(TRUE, 5); gtk_container_border_width(GTK_CONTAINER(sbox), 10); gtk_table_attach(GTK_TABLE(table), sbox, 0, 2, 7, 8, 0, 0, 5, 5); bbox = gtk_hbox_new(TRUE, 10); gtk_box_pack_start(GTK_BOX(sbox), bbox, TRUE, TRUE, 0); cancel = gtk_button_new_with_label(_("Quit")); cancel = gtk_button_new_with_label(_("Close")); accts = gtk_button_new_with_label(_("Accounts")); signon = gtk_button_new_with_label(_("Signon")); if (misc_options & OPT_MISC_COOL_LOOK) { gtk_button_set_relief(GTK_BUTTON(cancel), GTK_RELIEF_NONE); gtk_button_set_relief(GTK_BUTTON(accts), GTK_RELIEF_NONE); gtk_button_set_relief(GTK_BUTTON(signon), GTK_RELIEF_NONE); gtk_signal_connect(GTK_OBJECT(cancel), "clicked", GTK_SIGNAL_FUNC(cancel_logon), mainwindow); gtk_signal_connect(GTK_OBJECT(accts), "clicked", GTK_SIGNAL_FUNC(account_editor), mainwindow); gtk_signal_connect(GTK_OBJECT(signon), "clicked", GTK_SIGNAL_FUNC(dologin), mainwindow); gtk_box_pack_start(GTK_BOX(bbox), cancel, TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(bbox), accts, TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(bbox), signon, TRUE, TRUE, 0); hbox = gtk_hbox_new(TRUE, 10); gtk_box_pack_start(GTK_BOX(sbox), hbox, TRUE, TRUE, 0); reg = gtk_button_new_with_label(_("About")); options = gtk_button_new_with_label(_("Options")); plugs = gtk_button_new_with_label(_("Plugins")); if (misc_options & OPT_MISC_COOL_LOOK) { gtk_button_set_relief(GTK_BUTTON(reg), GTK_RELIEF_NONE); gtk_button_set_relief(GTK_BUTTON(options), GTK_RELIEF_NONE); gtk_button_set_relief(GTK_BUTTON(plugs), GTK_RELIEF_NONE); gtk_signal_connect(GTK_OBJECT(reg), "clicked", GTK_SIGNAL_FUNC(show_about), NULL); gtk_signal_connect(GTK_OBJECT(options), "clicked", GTK_SIGNAL_FUNC(show_prefs), NULL); gtk_signal_connect(GTK_OBJECT(plugs), "clicked", GTK_SIGNAL_FUNC(show_plugins), NULL); gtk_box_pack_start(GTK_BOX(hbox), reg, TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(hbox), options, TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(hbox), plugs, TRUE, TRUE, 0); gtk_widget_show(options); struct aim_user *c = (struct aim_user *)aim_users->data; if (c->options & OPT_USR_REM_PASS) { combo_changed(NULL, name); gtk_widget_grab_focus(signon); gtk_widget_grab_focus(pass); gtk_widget_grab_focus(name); gtk_widget_show(mainwindow); debug_printf("caught signal %d\n", sig); fprintf(stderr, "Gaim has segfaulted and attempted to dump a core file.\n" "This is a bug in the software and has happened through\n" "no fault of your own.\n\n" "It is possible that this bug is already fixed in CVS.\n" "You can get a tarball of CVS from the Gaim website, at\n" WEBSITE "gaim-CVS.tar.gz.\n\n" "If you are already using CVS, or can reproduce the crash\n" "using the CVS version, please notify the gaim maintainers\n" "by reporting a bug at\n" "Please make sure to specify what you were doing at the time,\n" "and post the backtrace from the core file. If you do not know\n" "how to get the backtrace, please get instructions at\n" WEBSITE "gdb.php. If you need further\n" "assistance, please IM either RobFlynn or SeanEgn and\n" signal(SIGCHLD, sighandler); /* restore signal catching on this one! */ debug_printf("caught signal %d\n", sig); static gboolean socket_readable(GIOChannel *source, GIOCondition cond, gpointer ud) debug_printf("Core says: "); g_io_channel_read(source, &type, sizeof(type), &x); debug_printf("CORE IS GONE!\n"); g_io_channel_close(source); debug_printf("%d ", type); g_io_channel_read(source, &subtype, sizeof(subtype), &x); debug_printf("CORE IS GONE!\n"); g_io_channel_close(source); debug_printf("%d ", subtype); g_io_channel_read(source, (guchar *)&len, sizeof(len), &x); debug_printf("CORE IS GONE!\n"); g_io_channel_close(source); debug_printf("(%d bytes)\n", len); g_io_channel_read(source, data, len, &x); debug_printf("CORE IS GONE! (read %d/%d bytes)\n", x, len); g_io_channel_close(source); static int open_socket(char *name) struct sockaddr_un saddr; if ((fd = socket(AF_UNIX, SOCK_STREAM, 0)) != -1) { saddr.sun_family = AF_UNIX; g_snprintf(saddr.sun_path, 108, "%s", name); if (connect(fd, (struct sockaddr *)&saddr, sizeof(saddr)) != -1) debug_printf("Failed to assign %s to a socket (Error: %s)\n", saddr.sun_path, strerror(errno)); debug_printf("Unable to open socket: %s\n", strerror(errno)); g_snprintf(name, sizeof(name), "%s/gaim_%s.%d", g_get_tmp_dir(), g_get_user_name(), getpid()); UI_fd = open_socket(name); channel = g_io_channel_unix_new(UI_fd); g_io_add_watch(channel, G_IO_IN | G_IO_HUP | G_IO_ERR, socket_readable, NULL); static void set_first_user(char *name) u = g_new0(struct aim_user, 1); g_snprintf(u->username, sizeof(u->username), "%s", name); u->protocol = DEFAULT_PROTO; aim_users = g_slist_prepend(aim_users, u); } else { /* user already exists */ aim_users = g_slist_remove(aim_users, u); aim_users = g_slist_prepend(aim_users, u); /* FUCKING GET ME A TOWEL! */ int main(int argc, char *argv[]) int opt_help = 0, opt_version = 0, opt_login = 0, do_login_ret = -1; char *opt_login_arg = NULL; int sig_indx; /* for setting up signal catching */ struct poptOption popt_options[] = { {"acct", 'a', POPT_ARG_NONE, &opt_acct, 'a', "Display account editor window", NULL}, {"away", 'w', POPT_ARG_STRING, NULL, 'w', "Make away on signon (optional argument MESG specifies name of away message to use)", {"login", 'l', POPT_ARG_STRING, NULL, 'l', "Automatically login (optional argument NAME specifies account(s) to use)", "[NAME]"}, {"user", 'u', POPT_ARG_STRING, &opt_user_arg, 'u', "Use account NAME", "NAME"}, {"file", 'f', POPT_ARG_STRING, &opt_rcfile_arg, 'f', "Use FILE as config", "FILE"}, {"debug", 'd', POPT_ARG_NONE, &opt_debug, 'd', "Print debugging messages to stdout", NULL}, struct option long_options[] = { {"acct", no_argument, NULL, 'a'}, /*{"away", optional_argument, NULL, 'w'}, */ {"help", no_argument, NULL, 'h'}, /*{"login", optional_argument, NULL, 'l'}, */ {"user", required_argument, NULL, 'u'}, {"file", required_argument, NULL, 'f'}, {"debug", no_argument, NULL, 'd'}, {"version", no_argument, NULL, 'v'}, bindtextdomain(PACKAGE, LOCALEDIR); /* Let's not violate any PLA's!!!! */ /* jseymour: whatever the fsck that means */ /* Robot101: for some reason things like gdm like to block * * useful signals like SIGCHLD, so we unblock all the ones we * * declare a handler for. thanks JSeymour and Vann. */ if (sigemptyset(&sigset)) { sprintf(errmsg, "Warning: couldn't initialise empty signal set"); for(sig_indx = 0; catch_sig_list[sig_indx] != -1; ++sig_indx) { if((prev_sig_disp = signal(catch_sig_list[sig_indx], sighandler)) == SIG_ERR) { sprintf(errmsg, "Warning: couldn't set signal %d for catching", catch_sig_list[sig_indx]); if(sigaddset(&sigset, catch_sig_list[sig_indx])) { sprintf(errmsg, "Warning: couldn't include signal %d for unblocking", catch_sig_list[sig_indx]); for(sig_indx = 0; ignore_sig_list[sig_indx] != -1; ++sig_indx) { if((prev_sig_disp = signal(ignore_sig_list[sig_indx], SIG_IGN)) == SIG_ERR) { sprintf(errmsg, "Warning: couldn't set signal %d to ignore", ignore_sig_list[sig_indx]); if (sigprocmask(SIG_UNBLOCK, &sigset, NULL)) { sprintf(errmsg, "Warning: couldn't unblock signals"); init_applet_mgr(argc, argv); for (i = 0; i < argc; i++) { if (strstr(argv[i], "--l") == argv[i]) { if ((equals = strchr(argv[i], '=')) != NULL) { opt_login_arg = g_strdup(equals + 1); if (strlen(opt_login_arg) == 0) { } else if (i + 1 < argc && argv[i + 1][0] != '-') { opt_login_arg = g_strdup(argv[i + 1]); strcpy(argv[i + 1], " "); else if (strstr(argv[i], "-l") == argv[i]) { if (strlen(argv[i]) > 2) { opt_login_arg = g_strdup(argv[i] + 2); } else if (i + 1 < argc && argv[i + 1][0] != '-') { opt_login_arg = g_strdup(argv[i + 1]); strcpy(argv[i + 1], " "); else if (strstr(argv[i], "--aw") == argv[i]) { if ((equals = strchr(argv[i], '=')) != NULL) { opt_away_arg = g_strdup(equals + 1); if (strlen(opt_away_arg) == 0) { } else if (i + 1 < argc && argv[i + 1][0] != '-') { opt_away_arg = g_strdup(argv[i + 1]); strcpy(argv[i + 1], " "); else if (strstr(argv[i], "-w") == argv[i]) { if (strlen(argv[i]) > 2) { opt_away_arg = g_strdup(argv[i] + 2); } else if (i + 1 < argc && argv[i + 1][0] != '-') { opt_away_arg = g_strdup(argv[i + 1]); strcpy(argv[i + 1], " "); printf ("--login given with arg %s\n", opt_login_arg ? opt_login_arg : "NULL"); gnome_init_with_popt_table(PACKAGE, VERSION, argc, argv, popt_options, 0, NULL); /* scan command-line options */ while ((opt = getopt_long(argc, argv, "adhu:f:v", long_options, NULL)) != -1) { opt_user_arg = g_strdup(optarg); case 'a': /* account editor */ opt_rcfile_arg = g_strdup(optarg); /* show version window */ show_about(0, (void *)2); /* set the default username */ if (opt_user_arg != NULL) { set_first_user(opt_user_arg); if (misc_options & OPT_MISC_DEBUG) /*If ispell fails to start, try using aspell in ispell compatibitity mode. Gabber does this the same way -- lorien420@myrealbox.com*/ if (convo_options & OPT_CONVO_CHECK_SPELLING){ if (gtkspell_start(NULL, ispell_cmd)<0){ debug_printf("gtkspell failed to start when using ispell\n"); if (gtkspell_start(NULL, aspell_cmd)<0){ debug_printf("gtkspell failed to start when using aspell\n"); debug_printf("gtkspell started with aspell\n"); debug_printf("gtkspell started with ispell\n"); do_login_ret = do_auto_login(opt_login_arg); if (opt_login_arg != NULL) { applet_widget_register_callback(APPLET_WIDGET(applet), "prefs", _("Preferences"), show_prefs, NULL); applet_widget_register_callback(APPLET_WIDGET(applet), _("Accounts"), (AppletCallbackFunc)account_editor, (void *)1); applet_widget_register_callback(APPLET_WIDGET(applet), "plugins", _("Plugins"), GTK_SIGNAL_FUNC(show_plugins), NULL); #endif /* GAIM_PLUGINS */ applet_widget_register_callback(APPLET_WIDGET(applet), "autologin", _("Auto-login"), (AppletCallbackFunc)auto_login, NULL); applet_widget_gtk_main(); account_editor(NULL, NULL); } else if ((do_login_ret == -1) && !connections) if (convo_options & OPT_CONVO_CHECK_SPELLING) /* don't need ui_quit here because ui doesn't create anything */