annotate src/gtkmain.c @ 11067:2eca9ed49469

[gaim-migrate @ 13048] Modified configure.ac so that it rejects dbus builds with the dbus library older than 0.34 Added a simple object registration system to the dbus implementation so that it is possible to query object properties remotely (eg. give me property "name" of buddy with id = 5). committer: Tailor Script <tailor@pidgin.im>
author Piotr Zielinski <zielaj>
date Thu, 07 Jul 2005 15:43:48 +0000
parents df0241eb602c
children f54740547c95
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10302
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1 /*
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
2 * gaim
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
3 *
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
4 * Gaim is the legal property of its developers, whose names are too numerous
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
5 * to list here. Please refer to the COPYRIGHT file distributed with this
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
6 * source distribution.
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
7 *
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
8 * This program is free software; you can redistribute it and/or modify
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
9 * it under the terms of the GNU General Public License as published by
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
10 * the Free Software Foundation; either version 2 of the License, or
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
11 * (at your option) any later version.
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
12 *
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful,
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
16 * GNU General Public License for more details.
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
17 *
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
19 * along with this program; if not, write to the Free Software
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
21 *
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
22 */
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
23
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
24 #include "internal.h"
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
25 #include "gtkgaim.h"
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
26
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
27 #include "account.h"
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
28 #include "conversation.h"
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
29 #include "core.h"
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
30 #include "debug.h"
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
31 #include "eventloop.h"
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
32 #include "ft.h"
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
33 #include "log.h"
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
34 #include "notify.h"
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
35 #include "prefs.h"
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
36 #include "prpl.h"
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
37 #include "pounce.h"
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
38 #include "sound.h"
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
39 #include "status.h"
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
40 #include "util.h"
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
41
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
42 #include "gtkaccount.h"
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
43 #include "gtkblist.h"
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
44 #include "gtkconn.h"
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
45 #include "gtkconv.h"
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
46 #include "gtkdebug.h"
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
47 #include "gtkdialogs.h"
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
48 #include "gtkeventloop.h"
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
49 #include "gtkft.h"
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
50 #include "gtknotify.h"
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
51 #include "gtkplugin.h"
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
52 #include "gtkpounce.h"
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
53 #include "gtkprefs.h"
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
54 #include "gtkprivacy.h"
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
55 #include "gtkrequest.h"
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
56 #include "gtkroomlist.h"
10574
77ef3f2f0df8 [gaim-migrate @ 11966]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10448
diff changeset
57 #include "gtksavedstatuses.h"
10302
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
58 #include "gtksound.h"
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
59 #include "gtkutils.h"
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
60 #include "gtkstock.h"
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
61
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
62 #if HAVE_SIGNAL_H
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
63 # include <signal.h>
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
64 #endif
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
65
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
66 #include <getopt.h>
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
67
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
68 #ifdef HAVE_STARTUP_NOTIFICATION
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
69 # define SN_API_NOT_YET_FROZEN
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
70 # include <libsn/sn-launchee.h>
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
71 # include <gdk/gdkx.h>
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
72 #endif
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
73
11055
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents: 11033
diff changeset
74 #ifdef HAVE_DBUS
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents: 11033
diff changeset
75 # include "dbus-server.h"
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents: 11033
diff changeset
76 #endif
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents: 11033
diff changeset
77
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents: 11033
diff changeset
78
10302
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
79 #ifdef HAVE_STARTUP_NOTIFICATION
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
80 static SnLauncheeContext *sn_context = NULL;
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
81 static SnDisplay *sn_display = NULL;
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
82 #endif
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
83
10448
6a20307ef8dc [gaim-migrate @ 11713]
Mark Doliner <mark@kingant.net>
parents: 10447
diff changeset
84 /* TODO: Get this out of here? */
10302
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
85 int docklet_count = 0;
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
86
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
87 #if HAVE_SIGNAL_H
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
88 /*
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
89 * Lists of signals we wish to catch and those we wish to ignore.
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
90 * Each list terminated with -1
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
91 */
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
92 static int catch_sig_list[] = {
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
93 SIGSEGV,
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
94 SIGHUP,
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
95 SIGINT,
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
96 SIGTERM,
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
97 SIGQUIT,
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
98 SIGCHLD,
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
99 -1
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
100 };
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
101
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
102 static int ignore_sig_list[] = {
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
103 SIGPIPE,
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
104 -1
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
105 };
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
106 #endif
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
107
10323
bb2514e075db [gaim-migrate @ 11530]
Mark Doliner <mark@kingant.net>
parents: 10322
diff changeset
108 static int
bb2514e075db [gaim-migrate @ 11530]
Mark Doliner <mark@kingant.net>
parents: 10322
diff changeset
109 dologin_named(const char *name)
10302
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
110 {
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
111 GaimAccount *account;
10323
bb2514e075db [gaim-migrate @ 11530]
Mark Doliner <mark@kingant.net>
parents: 10322
diff changeset
112 char **names;
bb2514e075db [gaim-migrate @ 11530]
Mark Doliner <mark@kingant.net>
parents: 10322
diff changeset
113 int i;
bb2514e075db [gaim-migrate @ 11530]
Mark Doliner <mark@kingant.net>
parents: 10322
diff changeset
114 int ret = -1;
10302
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
115
10323
bb2514e075db [gaim-migrate @ 11530]
Mark Doliner <mark@kingant.net>
parents: 10322
diff changeset
116 if (name != NULL) { /* list of names given */
bb2514e075db [gaim-migrate @ 11530]
Mark Doliner <mark@kingant.net>
parents: 10322
diff changeset
117 names = g_strsplit(name, ",", 64);
bb2514e075db [gaim-migrate @ 11530]
Mark Doliner <mark@kingant.net>
parents: 10322
diff changeset
118 for (i = 0; names[i] != NULL; i++) {
bb2514e075db [gaim-migrate @ 11530]
Mark Doliner <mark@kingant.net>
parents: 10322
diff changeset
119 account = gaim_accounts_find(names[i], NULL);
bb2514e075db [gaim-migrate @ 11530]
Mark Doliner <mark@kingant.net>
parents: 10322
diff changeset
120 if (account != NULL) { /* found a user */
bb2514e075db [gaim-migrate @ 11530]
Mark Doliner <mark@kingant.net>
parents: 10322
diff changeset
121 ret = 0;
10738
55af3fa46329 [gaim-migrate @ 12340]
Mark Doliner <mark@kingant.net>
parents: 10638
diff changeset
122 gaim_account_connect(account);
10302
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
123 }
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
124 }
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
125 g_strfreev(names);
10323
bb2514e075db [gaim-migrate @ 11530]
Mark Doliner <mark@kingant.net>
parents: 10322
diff changeset
126 } else { /* no name given, use the first account */
10302
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
127 account = (GaimAccount *)gaim_accounts_get_all()->data;
10323
bb2514e075db [gaim-migrate @ 11530]
Mark Doliner <mark@kingant.net>
parents: 10322
diff changeset
128 ret = 0;
10738
55af3fa46329 [gaim-migrate @ 12340]
Mark Doliner <mark@kingant.net>
parents: 10638
diff changeset
129 gaim_account_connect(account);
10302
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
130 }
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
131
10323
bb2514e075db [gaim-migrate @ 11530]
Mark Doliner <mark@kingant.net>
parents: 10322
diff changeset
132 return ret;
10302
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
133 }
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
134
10333
5eb81f349da7 [gaim-migrate @ 11540]
Mark Doliner <mark@kingant.net>
parents: 10332
diff changeset
135 #if HAVE_SIGNAL_H
10302
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
136 static void
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
137 clean_pid(void)
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
138 {
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
139 int status;
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
140 pid_t pid;
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
141
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
142 do {
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
143 pid = waitpid(-1, &status, WNOHANG);
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
144 } while (pid != 0 && pid != (pid_t)-1);
10334
5aa8ed1ec91e [gaim-migrate @ 11541]
Mark Doliner <mark@kingant.net>
parents: 10333
diff changeset
145
5aa8ed1ec91e [gaim-migrate @ 11541]
Mark Doliner <mark@kingant.net>
parents: 10333
diff changeset
146 if ((pid == (pid_t) - 1) && (errno != ECHILD)) {
10302
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
147 char errmsg[BUFSIZ];
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
148 snprintf(errmsg, BUFSIZ, "Warning: waitpid() returned %d", pid);
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
149 perror(errmsg);
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
150 }
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
151 }
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
152
10871
6240d7fd5b2c [gaim-migrate @ 12558]
Mark Doliner <mark@kingant.net>
parents: 10819
diff changeset
153 static void
10323
bb2514e075db [gaim-migrate @ 11530]
Mark Doliner <mark@kingant.net>
parents: 10322
diff changeset
154 sighandler(int sig)
10302
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
155 {
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
156 switch (sig) {
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
157 case SIGHUP:
10323
bb2514e075db [gaim-migrate @ 11530]
Mark Doliner <mark@kingant.net>
parents: 10322
diff changeset
158 gaim_debug_warning("sighandler", "Caught signal %d\n", sig);
10302
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
159 gaim_connections_disconnect_all();
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
160 break;
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
161 case SIGSEGV:
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
162 #ifndef DEBUG
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
163 fprintf(stderr, "Gaim has segfaulted and attempted to dump a core file.\n"
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
164 "This is a bug in the software and has happened through\n"
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
165 "no fault of your own.\n\n"
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
166 "It is possible that this bug is already fixed in CVS.\n"
10323
bb2514e075db [gaim-migrate @ 11530]
Mark Doliner <mark@kingant.net>
parents: 10322
diff changeset
167 "If you can reproduce the crash, please notify the gaim\n"
10302
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
168 "maintainers by reporting a bug at\n"
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
169 GAIM_WEBSITE "bug.php\n\n"
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
170 "Please make sure to specify what you were doing at the time,\n"
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
171 "and post the backtrace from the core file. If you do not know\n"
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
172 "how to get the backtrace, please get instructions at\n"
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
173 GAIM_WEBSITE "gdb.php. If you need further\n"
10638
222b53ee74f3 [gaim-migrate @ 12135]
Luke Schierer <lschiere@pidgin.im>
parents: 10589
diff changeset
174 "assistance, please IM either SeanEgn or LSchiere and\n"
10302
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
175 "they can help you.\n");
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
176 #else
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
177 fprintf(stderr, "Hi, user. We need to talk.\n"
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
178 "I think something's gone wrong here. It's probably my fault.\n"
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
179 "No, really, it's not you... it's me... no no no, I think we get along well\n"
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
180 "it's just that.... well, I want to see other people. I... what?!? NO! I haven't\n"
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
181 "been cheating on you!! How many times do you want me to tell you?! And for the\n"
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
182 "last time, it's just a rash!\n");
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
183 /*g_on_error_query (g_get_prgname());*/
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
184 #endif
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
185 abort();
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
186 break;
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
187 case SIGCHLD:
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
188 clean_pid();
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
189 signal(SIGCHLD, sighandler); /* restore signal catching on this one! */
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
190 break;
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
191 default:
10323
bb2514e075db [gaim-migrate @ 11530]
Mark Doliner <mark@kingant.net>
parents: 10322
diff changeset
192 gaim_debug_warning("sighandler", "Caught signal %d\n", sig);
10302
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
193 gaim_connections_disconnect_all();
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
194
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
195 gaim_plugins_unload_all();
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
196
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
197 if (gtk_main_level())
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
198 gtk_main_quit();
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
199 exit(0);
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
200 }
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
201 }
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
202 #endif
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
203
10323
bb2514e075db [gaim-migrate @ 11530]
Mark Doliner <mark@kingant.net>
parents: 10322
diff changeset
204 static int
bb2514e075db [gaim-migrate @ 11530]
Mark Doliner <mark@kingant.net>
parents: 10322
diff changeset
205 ui_main()
10302
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
206 {
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
207 #ifndef _WIN32
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
208 GList *icons = NULL;
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
209 GdkPixbuf *icon = NULL;
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
210 char *icon_path;
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
211 #endif
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
212
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
213 if (current_smiley_theme == NULL) {
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
214 smiley_theme_probe();
10323
bb2514e075db [gaim-migrate @ 11530]
Mark Doliner <mark@kingant.net>
parents: 10322
diff changeset
215 if (smiley_themes != NULL) {
10302
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
216 struct smiley_theme *smile = smiley_themes->data;
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
217 load_smiley_theme(smile->path, TRUE);
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
218 }
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
219 }
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
220
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
221 gaim_gtk_blist_setup_sort_methods();
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
222
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
223 #ifndef _WIN32
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
224 /* use the nice PNG icon for all the windows */
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
225 icon_path = g_build_filename(DATADIR, "pixmaps", "gaim", "icons", "online.png", NULL);
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
226 icon = gdk_pixbuf_new_from_file(icon_path, NULL);
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
227 g_free(icon_path);
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
228 if (icon) {
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
229 icons = g_list_append(icons,icon);
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
230 gtk_window_set_default_icon_list(icons);
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
231 g_object_unref(G_OBJECT(icon));
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
232 g_list_free(icons);
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
233 } else {
10323
bb2514e075db [gaim-migrate @ 11530]
Mark Doliner <mark@kingant.net>
parents: 10322
diff changeset
234 gaim_debug_error("ui_main",
bb2514e075db [gaim-migrate @ 11530]
Mark Doliner <mark@kingant.net>
parents: 10322
diff changeset
235 "Failed to load the default window icon!\n");
10302
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
236 }
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
237 #endif
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
238
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
239 return 0;
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
240 }
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
241
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
242 static void
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
243 debug_init(void)
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
244 {
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
245 gaim_debug_set_ui_ops(gaim_gtk_debug_get_ui_ops());
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
246 gaim_gtk_debug_init();
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
247 }
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
248
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
249 static void
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
250 gaim_gtk_ui_init(void)
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
251 {
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
252 /* Set the UI operation structures. */
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
253 gaim_accounts_set_ui_ops(gaim_gtk_accounts_get_ui_ops());
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
254 gaim_conversations_set_win_ui_ops(gaim_gtk_conversations_get_win_ui_ops());
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
255 gaim_xfers_set_ui_ops(gaim_gtk_xfers_get_ui_ops());
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
256 gaim_blist_set_ui_ops(gaim_gtk_blist_get_ui_ops());
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
257 gaim_notify_set_ui_ops(gaim_gtk_notify_get_ui_ops());
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
258 gaim_privacy_set_ui_ops(gaim_gtk_privacy_get_ui_ops());
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
259 gaim_request_set_ui_ops(gaim_gtk_request_get_ui_ops());
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
260 gaim_sound_set_ui_ops(gaim_gtk_sound_get_ui_ops());
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
261 gaim_connections_set_ui_ops(gaim_gtk_connections_get_ui_ops());
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
262
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
263 gaim_gtk_stock_init();
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
264 gaim_gtk_prefs_init();
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
265 gaim_gtk_account_init();
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
266 gaim_gtk_blist_init();
10574
77ef3f2f0df8 [gaim-migrate @ 11966]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10448
diff changeset
267 gaim_gtk_status_init();
10302
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
268 gaim_gtk_conversations_init();
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
269 gaim_gtk_pounces_init();
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
270 gaim_gtk_privacy_init();
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
271 gaim_gtk_xfers_init();
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
272 gaim_gtk_roomlist_init();
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
273 }
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
274
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
275 static void
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
276 gaim_gtk_quit(void)
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
277 {
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
278 /* XXX? */
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
279 /* YYY is there an XXX here? */
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
280
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
281 /* captain's log, stardate... */
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
282 /* LOG system_log(log_quit, NULL, NULL, OPT_LOG_BUDDY_SIGNON | OPT_LOG_MY_SIGNON); */
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
283
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
284 #ifdef USE_SM
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
285 /* unplug */
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
286 session_end();
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
287 #endif
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
288
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
289 /* Save the plugins we have loaded for next time. */
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
290 gaim_gtk_plugins_save();
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
291
10574
77ef3f2f0df8 [gaim-migrate @ 11966]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10448
diff changeset
292 /* Uninit */
77ef3f2f0df8 [gaim-migrate @ 11966]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10448
diff changeset
293 gaim_gtk_conversations_uninit();
77ef3f2f0df8 [gaim-migrate @ 11966]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10448
diff changeset
294 gaim_gtk_status_uninit();
77ef3f2f0df8 [gaim-migrate @ 11966]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10448
diff changeset
295 gaim_gtk_blist_uninit();
77ef3f2f0df8 [gaim-migrate @ 11966]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10448
diff changeset
296 gaim_gtk_account_uninit();
11010
9fe9c7e00666 [gaim-migrate @ 12871]
Mark Doliner <mark@kingant.net>
parents: 10871
diff changeset
297 gaim_gtk_xfers_uninit();
11033
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 11010
diff changeset
298 gaim_gtk_debug_uninit();
10574
77ef3f2f0df8 [gaim-migrate @ 11966]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10448
diff changeset
299
10302
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
300 /* and end it all... */
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
301 gtk_main_quit();
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
302 }
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
303
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
304 static GaimCoreUiOps core_ops =
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
305 {
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
306 gaim_gtk_prefs_init,
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
307 debug_init,
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
308 gaim_gtk_ui_init,
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
309 gaim_gtk_quit
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
310 };
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
311
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
312 static GaimCoreUiOps *
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
313 gaim_gtk_core_get_ui_ops(void)
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
314 {
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
315 return &core_ops;
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
316 }
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
317
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
318 static void
10320
61852117568f [gaim-migrate @ 11527]
Mark Doliner <mark@kingant.net>
parents: 10317
diff changeset
319 show_usage(const char *name, gboolean terse)
10302
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
320 {
10320
61852117568f [gaim-migrate @ 11527]
Mark Doliner <mark@kingant.net>
parents: 10317
diff changeset
321 char *text;
61852117568f [gaim-migrate @ 11527]
Mark Doliner <mark@kingant.net>
parents: 10317
diff changeset
322 char *text_conv;
61852117568f [gaim-migrate @ 11527]
Mark Doliner <mark@kingant.net>
parents: 10317
diff changeset
323 GError *error = NULL;
10302
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
324
10320
61852117568f [gaim-migrate @ 11527]
Mark Doliner <mark@kingant.net>
parents: 10317
diff changeset
325 if (terse) {
61852117568f [gaim-migrate @ 11527]
Mark Doliner <mark@kingant.net>
parents: 10317
diff changeset
326 text = g_strdup_printf(_("Gaim %s. Try `%s -h' for more information.\n"), VERSION, name);
61852117568f [gaim-migrate @ 11527]
Mark Doliner <mark@kingant.net>
parents: 10317
diff changeset
327 } else {
61852117568f [gaim-migrate @ 11527]
Mark Doliner <mark@kingant.net>
parents: 10317
diff changeset
328 text = g_strdup_printf(_("Gaim %s\n"
10302
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
329 "Usage: %s [OPTION]...\n\n"
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
330 " -a, --acct display account editor window\n"
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
331 " -c, --config=DIR use DIR for config files\n"
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
332 " -d, --debug print debugging messages to stdout\n"
10320
61852117568f [gaim-migrate @ 11527]
Mark Doliner <mark@kingant.net>
parents: 10317
diff changeset
333 " -h, --help display this help and exit\n"
10323
bb2514e075db [gaim-migrate @ 11530]
Mark Doliner <mark@kingant.net>
parents: 10322
diff changeset
334 " -n, --nologin don't automatically login\n"
10320
61852117568f [gaim-migrate @ 11527]
Mark Doliner <mark@kingant.net>
parents: 10317
diff changeset
335 " -l, --login[=NAME] automatically login (optional argument NAME specifies\n"
61852117568f [gaim-migrate @ 11527]
Mark Doliner <mark@kingant.net>
parents: 10317
diff changeset
336 " account(s) to use, seperated by commas)\n"
10323
bb2514e075db [gaim-migrate @ 11530]
Mark Doliner <mark@kingant.net>
parents: 10322
diff changeset
337 " -v, --version display the current version and exit\n"), VERSION, name);
10302
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
338 }
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
339
10320
61852117568f [gaim-migrate @ 11527]
Mark Doliner <mark@kingant.net>
parents: 10317
diff changeset
340 /* tries to convert 'text' to users locale */
61852117568f [gaim-migrate @ 11527]
Mark Doliner <mark@kingant.net>
parents: 10317
diff changeset
341 text_conv = g_locale_from_utf8(text, -1, NULL, NULL, &error);
61852117568f [gaim-migrate @ 11527]
Mark Doliner <mark@kingant.net>
parents: 10317
diff changeset
342 if (text_conv != NULL) {
61852117568f [gaim-migrate @ 11527]
Mark Doliner <mark@kingant.net>
parents: 10317
diff changeset
343 puts(text_conv);
61852117568f [gaim-migrate @ 11527]
Mark Doliner <mark@kingant.net>
parents: 10317
diff changeset
344 g_free(text_conv);
10302
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
345 }
10320
61852117568f [gaim-migrate @ 11527]
Mark Doliner <mark@kingant.net>
parents: 10317
diff changeset
346 /* use 'text' as a fallback */
61852117568f [gaim-migrate @ 11527]
Mark Doliner <mark@kingant.net>
parents: 10317
diff changeset
347 else {
61852117568f [gaim-migrate @ 11527]
Mark Doliner <mark@kingant.net>
parents: 10317
diff changeset
348 g_warning("%s\n", error->message);
61852117568f [gaim-migrate @ 11527]
Mark Doliner <mark@kingant.net>
parents: 10317
diff changeset
349 g_error_free(error);
61852117568f [gaim-migrate @ 11527]
Mark Doliner <mark@kingant.net>
parents: 10317
diff changeset
350 puts(text);
61852117568f [gaim-migrate @ 11527]
Mark Doliner <mark@kingant.net>
parents: 10317
diff changeset
351 }
61852117568f [gaim-migrate @ 11527]
Mark Doliner <mark@kingant.net>
parents: 10317
diff changeset
352 g_free(text);
10302
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
353 }
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
354
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
355 #ifdef HAVE_STARTUP_NOTIFICATION
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
356 static void
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
357 sn_error_trap_push(SnDisplay *display, Display *xdisplay)
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
358 {
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
359 gdk_error_trap_push();
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
360 }
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
361
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
362 static void
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
363 sn_error_trap_pop(SnDisplay *display, Display *xdisplay)
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
364 {
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
365 gdk_error_trap_pop();
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
366 }
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
367
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
368 static void
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
369 startup_notification_complete(void)
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
370 {
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
371 Display *xdisplay;
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
372
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
373 xdisplay = GDK_DISPLAY();
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
374 sn_display = sn_display_new(xdisplay,
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
375 sn_error_trap_push,
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
376 sn_error_trap_pop);
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
377 sn_context =
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
378 sn_launchee_context_new_from_environment(sn_display,
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
379 DefaultScreen(xdisplay));
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
380
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
381 if (sn_context != NULL)
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
382 {
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
383 sn_launchee_context_complete(sn_context);
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
384 sn_launchee_context_unref(sn_context);
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
385
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
386 sn_display_unref(sn_display);
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
387 }
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
388 }
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
389 #endif /* HAVE_STARTUP_NOTIFICATION */
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
390
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
391 #ifndef _WIN32
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
392 static char *gaim_find_binary_location(void *symbol, void *data)
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
393 {
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
394 static char *fullname = NULL;
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
395 static gboolean first = TRUE;
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
396
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
397 char *argv0 = data;
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
398 struct stat st;
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
399 char *basebuf, *linkbuf, *fullbuf;
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
400
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
401 if (!first)
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
402 /* We've already been through this. */
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
403 return strdup(fullname);
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
404
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
405 first = FALSE;
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
406
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
407 if (!argv0)
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
408 return NULL;
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
409
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
410
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
411 basebuf = g_find_program_in_path(argv0);
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
412
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
413 /* But we still need to deal with symbolic links */
10589
0f7452b1f777 [gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10581
diff changeset
414 g_lstat(basebuf, &st);
10302
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
415 while ((st.st_mode & S_IFLNK) == S_IFLNK) {
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
416 linkbuf = g_malloc(1024);
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
417 readlink(basebuf, linkbuf, 1024);
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
418 if (linkbuf[0] == G_DIR_SEPARATOR) {
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
419 /* an absolute path */
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
420 fullbuf = g_strdup(linkbuf);
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
421 } else {
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
422 char *dirbuf = g_path_get_dirname(basebuf);
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
423 /* a relative path */
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
424 fullbuf = g_strdup_printf("%s%s%s",
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
425 dirbuf, G_DIR_SEPARATOR_S,
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
426 linkbuf);
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
427 g_free(dirbuf);
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
428 }
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
429 /* There's no memory leak here. Really! */
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
430 g_free(linkbuf);
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
431 g_free(basebuf);
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
432 basebuf = fullbuf;
10589
0f7452b1f777 [gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10581
diff changeset
433 g_lstat(basebuf, &st);
10302
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
434 }
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
435
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
436 fullname = basebuf;
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
437 return strdup(fullname);
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
438 }
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
439 #endif /* #ifndef _WIN32 */
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
440
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
441 /* FUCKING GET ME A TOWEL! */
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
442 #ifdef _WIN32
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
443 int gaim_main(HINSTANCE hint, int argc, char *argv[])
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
444 #else
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
445 int main(int argc, char *argv[])
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
446 #endif
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
447 {
10323
bb2514e075db [gaim-migrate @ 11530]
Mark Doliner <mark@kingant.net>
parents: 10322
diff changeset
448 gboolean opt_acct = FALSE;
bb2514e075db [gaim-migrate @ 11530]
Mark Doliner <mark@kingant.net>
parents: 10322
diff changeset
449 gboolean opt_help = FALSE;
bb2514e075db [gaim-migrate @ 11530]
Mark Doliner <mark@kingant.net>
parents: 10322
diff changeset
450 gboolean opt_login = FALSE;
bb2514e075db [gaim-migrate @ 11530]
Mark Doliner <mark@kingant.net>
parents: 10322
diff changeset
451 gboolean opt_nologin = FALSE;
bb2514e075db [gaim-migrate @ 11530]
Mark Doliner <mark@kingant.net>
parents: 10322
diff changeset
452 gboolean opt_version = FALSE;
bb2514e075db [gaim-migrate @ 11530]
Mark Doliner <mark@kingant.net>
parents: 10322
diff changeset
453 char *opt_config_dir_arg = NULL;
bb2514e075db [gaim-migrate @ 11530]
Mark Doliner <mark@kingant.net>
parents: 10322
diff changeset
454 char *opt_login_arg = NULL;
bb2514e075db [gaim-migrate @ 11530]
Mark Doliner <mark@kingant.net>
parents: 10322
diff changeset
455 char *opt_session_arg = NULL;
bb2514e075db [gaim-migrate @ 11530]
Mark Doliner <mark@kingant.net>
parents: 10322
diff changeset
456 int dologin_ret = -1;
10447
6feef0a9098a [gaim-migrate @ 11712]
Mark Doliner <mark@kingant.net>
parents: 10433
diff changeset
457 char *search_path;
10302
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
458 #if HAVE_SIGNAL_H
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
459 int sig_indx; /* for setting up signal catching */
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
460 sigset_t sigset;
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
461 void (*prev_sig_disp)();
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
462 #endif
10323
bb2514e075db [gaim-migrate @ 11530]
Mark Doliner <mark@kingant.net>
parents: 10322
diff changeset
463 int opt;
10302
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
464 gboolean gui_check;
10307
2ac21bf20e04 [gaim-migrate @ 11497]
Mark Doliner <mark@kingant.net>
parents: 10306
diff changeset
465 gboolean debug_enabled;
10334
5aa8ed1ec91e [gaim-migrate @ 11541]
Mark Doliner <mark@kingant.net>
parents: 10333
diff changeset
466 #if HAVE_SIGNAL_H
10323
bb2514e075db [gaim-migrate @ 11530]
Mark Doliner <mark@kingant.net>
parents: 10322
diff changeset
467 char errmsg[BUFSIZ];
10334
5aa8ed1ec91e [gaim-migrate @ 11541]
Mark Doliner <mark@kingant.net>
parents: 10333
diff changeset
468 #endif
10302
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
469
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
470 struct option long_options[] = {
10323
bb2514e075db [gaim-migrate @ 11530]
Mark Doliner <mark@kingant.net>
parents: 10322
diff changeset
471 {"acct", no_argument, NULL, 'a'},
bb2514e075db [gaim-migrate @ 11530]
Mark Doliner <mark@kingant.net>
parents: 10322
diff changeset
472 {"config", required_argument, NULL, 'c'},
bb2514e075db [gaim-migrate @ 11530]
Mark Doliner <mark@kingant.net>
parents: 10322
diff changeset
473 {"debug", no_argument, NULL, 'd'},
bb2514e075db [gaim-migrate @ 11530]
Mark Doliner <mark@kingant.net>
parents: 10322
diff changeset
474 {"help", no_argument, NULL, 'h'},
bb2514e075db [gaim-migrate @ 11530]
Mark Doliner <mark@kingant.net>
parents: 10322
diff changeset
475 {"login", optional_argument, NULL, 'l'},
bb2514e075db [gaim-migrate @ 11530]
Mark Doliner <mark@kingant.net>
parents: 10322
diff changeset
476 {"nologin", no_argument, NULL, 'n'},
bb2514e075db [gaim-migrate @ 11530]
Mark Doliner <mark@kingant.net>
parents: 10322
diff changeset
477 {"session", required_argument, NULL, 's'},
bb2514e075db [gaim-migrate @ 11530]
Mark Doliner <mark@kingant.net>
parents: 10322
diff changeset
478 {"version", no_argument, NULL, 'v'},
10302
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
479 {0, 0, 0, 0}
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
480 };
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
481
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
482 #ifdef DEBUG
10307
2ac21bf20e04 [gaim-migrate @ 11497]
Mark Doliner <mark@kingant.net>
parents: 10306
diff changeset
483 debug_enabled = TRUE;
2ac21bf20e04 [gaim-migrate @ 11497]
Mark Doliner <mark@kingant.net>
parents: 10306
diff changeset
484 #else
2ac21bf20e04 [gaim-migrate @ 11497]
Mark Doliner <mark@kingant.net>
parents: 10306
diff changeset
485 debug_enabled = FALSE;
10302
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
486 #endif
10307
2ac21bf20e04 [gaim-migrate @ 11497]
Mark Doliner <mark@kingant.net>
parents: 10306
diff changeset
487
10302
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
488 #ifndef _WIN32
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
489 br_set_locate_fallback_func(gaim_find_binary_location, argv[0]);
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
490 #endif
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
491 #ifdef ENABLE_NLS
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
492 bindtextdomain(PACKAGE, LOCALEDIR);
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
493 bind_textdomain_codeset(PACKAGE, "UTF-8");
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
494 textdomain(PACKAGE);
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
495 #endif
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
496
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
497 #if HAVE_SIGNAL_H
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
498 /* Let's not violate any PLA's!!!! */
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
499 /* jseymour: whatever the fsck that means */
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
500 /* Robot101: for some reason things like gdm like to block *
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
501 * useful signals like SIGCHLD, so we unblock all the ones we *
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
502 * declare a handler for. thanks JSeymour and Vann. */
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
503 if (sigemptyset(&sigset)) {
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
504 snprintf(errmsg, BUFSIZ, "Warning: couldn't initialise empty signal set");
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
505 perror(errmsg);
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
506 }
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
507 for(sig_indx = 0; catch_sig_list[sig_indx] != -1; ++sig_indx) {
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
508 if((prev_sig_disp = signal(catch_sig_list[sig_indx], sighandler)) == SIG_ERR) {
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
509 snprintf(errmsg, BUFSIZ, "Warning: couldn't set signal %d for catching",
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
510 catch_sig_list[sig_indx]);
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
511 perror(errmsg);
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
512 }
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
513 if(sigaddset(&sigset, catch_sig_list[sig_indx])) {
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
514 snprintf(errmsg, BUFSIZ, "Warning: couldn't include signal %d for unblocking",
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
515 catch_sig_list[sig_indx]);
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
516 perror(errmsg);
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
517 }
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
518 }
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
519 for(sig_indx = 0; ignore_sig_list[sig_indx] != -1; ++sig_indx) {
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
520 if((prev_sig_disp = signal(ignore_sig_list[sig_indx], SIG_IGN)) == SIG_ERR) {
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
521 snprintf(errmsg, BUFSIZ, "Warning: couldn't set signal %d to ignore",
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
522 ignore_sig_list[sig_indx]);
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
523 perror(errmsg);
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
524 }
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
525 }
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
526
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
527 if (sigprocmask(SIG_UNBLOCK, &sigset, NULL)) {
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
528 snprintf(errmsg, BUFSIZ, "Warning: couldn't unblock signals");
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
529 perror(errmsg);
10307
2ac21bf20e04 [gaim-migrate @ 11497]
Mark Doliner <mark@kingant.net>
parents: 10306
diff changeset
530 }
10302
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
531 #endif
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
532
10581
59a2807e10bb [gaim-migrate @ 11981]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10574
diff changeset
533 gui_check = gtk_init_check(&argc, &argv);
59a2807e10bb [gaim-migrate @ 11981]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10574
diff changeset
534 if (!gui_check) {
59a2807e10bb [gaim-migrate @ 11981]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10574
diff changeset
535 char *display = gdk_get_display();
59a2807e10bb [gaim-migrate @ 11981]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10574
diff changeset
536
11033
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 11010
diff changeset
537 printf("Gaim %s\n", VERSION);
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 11010
diff changeset
538
10581
59a2807e10bb [gaim-migrate @ 11981]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10574
diff changeset
539 g_warning("cannot open display: %s", display ? display : "unset");
59a2807e10bb [gaim-migrate @ 11981]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10574
diff changeset
540 g_free(display);
59a2807e10bb [gaim-migrate @ 11981]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10574
diff changeset
541
59a2807e10bb [gaim-migrate @ 11981]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10574
diff changeset
542 return 1;
59a2807e10bb [gaim-migrate @ 11981]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10574
diff changeset
543 }
59a2807e10bb [gaim-migrate @ 11981]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10574
diff changeset
544
10302
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
545 /* scan command-line options */
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
546 opterr = 1;
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
547 while ((opt = getopt_long(argc, argv,
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
548 #ifndef _WIN32
10323
bb2514e075db [gaim-migrate @ 11530]
Mark Doliner <mark@kingant.net>
parents: 10322
diff changeset
549 "ac:dhnl::s:v",
10302
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
550 #else
10323
bb2514e075db [gaim-migrate @ 11530]
Mark Doliner <mark@kingant.net>
parents: 10322
diff changeset
551 "ac:dhnl::v",
10302
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
552 #endif
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
553 long_options, NULL)) != -1) {
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
554 switch (opt) {
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
555 case 'a': /* account editor */
10323
bb2514e075db [gaim-migrate @ 11530]
Mark Doliner <mark@kingant.net>
parents: 10322
diff changeset
556 opt_acct = TRUE;
bb2514e075db [gaim-migrate @ 11530]
Mark Doliner <mark@kingant.net>
parents: 10322
diff changeset
557 break;
bb2514e075db [gaim-migrate @ 11530]
Mark Doliner <mark@kingant.net>
parents: 10322
diff changeset
558 case 'c': /* config dir */
bb2514e075db [gaim-migrate @ 11530]
Mark Doliner <mark@kingant.net>
parents: 10322
diff changeset
559 g_free(opt_config_dir_arg);
bb2514e075db [gaim-migrate @ 11530]
Mark Doliner <mark@kingant.net>
parents: 10322
diff changeset
560 opt_config_dir_arg = g_strdup(optarg);
10302
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
561 break;
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
562 case 'd': /* debug */
10307
2ac21bf20e04 [gaim-migrate @ 11497]
Mark Doliner <mark@kingant.net>
parents: 10306
diff changeset
563 debug_enabled = TRUE;
10302
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
564 break;
10323
bb2514e075db [gaim-migrate @ 11530]
Mark Doliner <mark@kingant.net>
parents: 10322
diff changeset
565 case 'h': /* help */
bb2514e075db [gaim-migrate @ 11530]
Mark Doliner <mark@kingant.net>
parents: 10322
diff changeset
566 opt_help = TRUE;
bb2514e075db [gaim-migrate @ 11530]
Mark Doliner <mark@kingant.net>
parents: 10322
diff changeset
567 break;
bb2514e075db [gaim-migrate @ 11530]
Mark Doliner <mark@kingant.net>
parents: 10322
diff changeset
568 case 'n': /* no autologin */
bb2514e075db [gaim-migrate @ 11530]
Mark Doliner <mark@kingant.net>
parents: 10322
diff changeset
569 opt_nologin = TRUE;
10302
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
570 break;
10323
bb2514e075db [gaim-migrate @ 11530]
Mark Doliner <mark@kingant.net>
parents: 10322
diff changeset
571 case 'l': /* login, option username */
bb2514e075db [gaim-migrate @ 11530]
Mark Doliner <mark@kingant.net>
parents: 10322
diff changeset
572 opt_login = TRUE;
bb2514e075db [gaim-migrate @ 11530]
Mark Doliner <mark@kingant.net>
parents: 10322
diff changeset
573 g_free(opt_login_arg);
bb2514e075db [gaim-migrate @ 11530]
Mark Doliner <mark@kingant.net>
parents: 10322
diff changeset
574 if (optarg != NULL)
bb2514e075db [gaim-migrate @ 11530]
Mark Doliner <mark@kingant.net>
parents: 10322
diff changeset
575 opt_login_arg = g_strdup(optarg);
10302
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
576 break;
10320
61852117568f [gaim-migrate @ 11527]
Mark Doliner <mark@kingant.net>
parents: 10317
diff changeset
577 case 's': /* use existing session ID */
10323
bb2514e075db [gaim-migrate @ 11530]
Mark Doliner <mark@kingant.net>
parents: 10322
diff changeset
578 g_free(opt_session_arg);
10320
61852117568f [gaim-migrate @ 11527]
Mark Doliner <mark@kingant.net>
parents: 10317
diff changeset
579 opt_session_arg = g_strdup(optarg);
61852117568f [gaim-migrate @ 11527]
Mark Doliner <mark@kingant.net>
parents: 10317
diff changeset
580 break;
10323
bb2514e075db [gaim-migrate @ 11530]
Mark Doliner <mark@kingant.net>
parents: 10322
diff changeset
581 case 'v': /* version */
bb2514e075db [gaim-migrate @ 11530]
Mark Doliner <mark@kingant.net>
parents: 10322
diff changeset
582 opt_version = TRUE;
10320
61852117568f [gaim-migrate @ 11527]
Mark Doliner <mark@kingant.net>
parents: 10317
diff changeset
583 break;
10323
bb2514e075db [gaim-migrate @ 11530]
Mark Doliner <mark@kingant.net>
parents: 10322
diff changeset
584 case '?': /* show terse help */
10302
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
585 default:
10320
61852117568f [gaim-migrate @ 11527]
Mark Doliner <mark@kingant.net>
parents: 10317
diff changeset
586 show_usage(argv[0], TRUE);
10302
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
587 return 0;
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
588 break;
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
589 }
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
590 }
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
591
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
592 /* show help message */
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
593 if (opt_help) {
10320
61852117568f [gaim-migrate @ 11527]
Mark Doliner <mark@kingant.net>
parents: 10317
diff changeset
594 show_usage(argv[0], FALSE);
10302
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
595 return 0;
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
596 }
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
597 /* show version message */
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
598 if (opt_version) {
10323
bb2514e075db [gaim-migrate @ 11530]
Mark Doliner <mark@kingant.net>
parents: 10322
diff changeset
599 printf("Gaim %s\n", VERSION);
10302
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
600 return 0;
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
601 }
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
602
10323
bb2514e075db [gaim-migrate @ 11530]
Mark Doliner <mark@kingant.net>
parents: 10322
diff changeset
603 /* set a user-specified config directory */
bb2514e075db [gaim-migrate @ 11530]
Mark Doliner <mark@kingant.net>
parents: 10322
diff changeset
604 if (opt_config_dir_arg != NULL) {
10871
6240d7fd5b2c [gaim-migrate @ 12558]
Mark Doliner <mark@kingant.net>
parents: 10819
diff changeset
605 gaim_util_set_user_dir(opt_config_dir_arg);
10323
bb2514e075db [gaim-migrate @ 11530]
Mark Doliner <mark@kingant.net>
parents: 10322
diff changeset
606 }
bb2514e075db [gaim-migrate @ 11530]
Mark Doliner <mark@kingant.net>
parents: 10322
diff changeset
607
10448
6a20307ef8dc [gaim-migrate @ 11713]
Mark Doliner <mark@kingant.net>
parents: 10447
diff changeset
608 /*
6a20307ef8dc [gaim-migrate @ 11713]
Mark Doliner <mark@kingant.net>
parents: 10447
diff changeset
609 * We're done piddling around with command line arguments.
6a20307ef8dc [gaim-migrate @ 11713]
Mark Doliner <mark@kingant.net>
parents: 10447
diff changeset
610 * Fire up this baby.
6a20307ef8dc [gaim-migrate @ 11713]
Mark Doliner <mark@kingant.net>
parents: 10447
diff changeset
611 */
6a20307ef8dc [gaim-migrate @ 11713]
Mark Doliner <mark@kingant.net>
parents: 10447
diff changeset
612
6a20307ef8dc [gaim-migrate @ 11713]
Mark Doliner <mark@kingant.net>
parents: 10447
diff changeset
613 gaim_debug_set_enabled(debug_enabled);
6a20307ef8dc [gaim-migrate @ 11713]
Mark Doliner <mark@kingant.net>
parents: 10447
diff changeset
614
10302
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
615 #ifdef _WIN32
10323
bb2514e075db [gaim-migrate @ 11530]
Mark Doliner <mark@kingant.net>
parents: 10322
diff changeset
616 wgaim_init(hint);
10302
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
617 #endif
11067
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
618
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
619 #ifdef HAVE_DBUS
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
620 /* start dbus pointer registration system */
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
621 gaim_dbus_init_ids();
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
622 #endif
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
623
10302
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
624 gaim_core_set_ui_ops(gaim_gtk_core_get_ui_ops());
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
625 gaim_eventloop_set_ui_ops(gaim_gtk_eventloop_get_ui_ops());
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
626
10447
6feef0a9098a [gaim-migrate @ 11712]
Mark Doliner <mark@kingant.net>
parents: 10433
diff changeset
627 /* Set plugin search directories */
6feef0a9098a [gaim-migrate @ 11712]
Mark Doliner <mark@kingant.net>
parents: 10433
diff changeset
628 gaim_plugins_add_search_path(LIBDIR);
6feef0a9098a [gaim-migrate @ 11712]
Mark Doliner <mark@kingant.net>
parents: 10433
diff changeset
629 search_path = g_build_filename(gaim_user_dir(), "plugins", NULL);
6feef0a9098a [gaim-migrate @ 11712]
Mark Doliner <mark@kingant.net>
parents: 10433
diff changeset
630 gaim_plugins_add_search_path(search_path);
6feef0a9098a [gaim-migrate @ 11712]
Mark Doliner <mark@kingant.net>
parents: 10433
diff changeset
631 g_free(search_path);
6feef0a9098a [gaim-migrate @ 11712]
Mark Doliner <mark@kingant.net>
parents: 10433
diff changeset
632
10302
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
633 if (!gaim_core_init(GAIM_GTK_UI)) {
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
634 fprintf(stderr,
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
635 "Initialization of the Gaim core failed. Dumping core.\n"
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
636 "Please report this!\n");
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
637 abort();
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
638 }
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
639
10428
04c663ccbcb1 [gaim-migrate @ 11680]
Mark Doliner <mark@kingant.net>
parents: 10425
diff changeset
640 /* TODO: Move blist loading into gaim_blist_init() */
10302
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
641 gaim_set_blist(gaim_blist_new());
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
642 gaim_blist_load();
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
643
10433
f7f06cb69d5e [gaim-migrate @ 11689]
Mark Doliner <mark@kingant.net>
parents: 10428
diff changeset
644 /* TODO: Move prefs loading into gaim_prefs_init() */
10302
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
645 gaim_prefs_load();
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
646 gaim_prefs_update_old();
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
647 gaim_gtk_prefs_update_old();
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
648
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
649 /* load plugins we had when we quit */
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
650 gaim_plugins_load_saved("/gaim/gtk/plugins/loaded");
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
651
10433
f7f06cb69d5e [gaim-migrate @ 11689]
Mark Doliner <mark@kingant.net>
parents: 10428
diff changeset
652 /* TODO: Move pounces loading into gaim_pounces_init() */
10302
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
653 gaim_pounces_load();
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
654
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
655 ui_main();
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
656
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
657 #ifdef USE_SM
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
658 session_init(argv[0], opt_session_arg, opt_config_dir_arg);
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
659 #endif
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
660 if (opt_session_arg != NULL) {
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
661 g_free(opt_session_arg);
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
662 opt_session_arg = NULL;
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
663 }
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
664 if (opt_config_dir_arg != NULL) {
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
665 g_free(opt_config_dir_arg);
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
666 opt_config_dir_arg = NULL;
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
667 }
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
668
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
669 if (gaim_prefs_get_bool("/gaim/gtk/debug/enabled"))
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
670 gaim_gtk_debug_window_show();
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
671
10323
bb2514e075db [gaim-migrate @ 11530]
Mark Doliner <mark@kingant.net>
parents: 10322
diff changeset
672 gaim_blist_show();
bb2514e075db [gaim-migrate @ 11530]
Mark Doliner <mark@kingant.net>
parents: 10322
diff changeset
673
10302
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
674 if (opt_login) {
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
675 dologin_ret = dologin_named(opt_login_arg);
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
676 if (opt_login_arg != NULL) {
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
677 g_free(opt_login_arg);
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
678 opt_login_arg = NULL;
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
679 }
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
680 }
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
681
10738
55af3fa46329 [gaim-migrate @ 12340]
Mark Doliner <mark@kingant.net>
parents: 10638
diff changeset
682 if (!opt_acct && opt_nologin)
55af3fa46329 [gaim-migrate @ 12340]
Mark Doliner <mark@kingant.net>
parents: 10638
diff changeset
683 {
55af3fa46329 [gaim-migrate @ 12340]
Mark Doliner <mark@kingant.net>
parents: 10638
diff changeset
684 /* TODO: Need to disable all accounts or set them all to offline */
55af3fa46329 [gaim-migrate @ 12340]
Mark Doliner <mark@kingant.net>
parents: 10638
diff changeset
685 }
10302
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
686
10323
bb2514e075db [gaim-migrate @ 11530]
Mark Doliner <mark@kingant.net>
parents: 10322
diff changeset
687 if (opt_acct || (gaim_accounts_get_all() == NULL)) {
10302
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
688 gaim_gtk_accounts_window_show();
10315
deec4b58d516 [gaim-migrate @ 11515]
Sean Egan <seanegan@gmail.com>
parents: 10307
diff changeset
689 }
10302
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
690
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
691 #ifdef HAVE_STARTUP_NOTIFICATION
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
692 startup_notification_complete();
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
693 #endif
10320
61852117568f [gaim-migrate @ 11527]
Mark Doliner <mark@kingant.net>
parents: 10317
diff changeset
694
11033
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 11010
diff changeset
695 gaim_debug_register_category("sighandler");
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 11010
diff changeset
696 gaim_debug_register_category("ui_main");
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 11010
diff changeset
697
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 11010
diff changeset
698 /* XXX These don't really belong here, but I don't have a better place for
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 11010
diff changeset
699 * them right now */
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 11010
diff changeset
700 gaim_debug_register_category("gtkimhtml");
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 11010
diff changeset
701 gaim_debug_register_category("gtk_imhtml_tip");
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 11010
diff changeset
702 gaim_debug_register_category("html clipboard");
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 11010
diff changeset
703 /* #if 0'ed out for Windows stuff
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 11010
diff changeset
704 gaim_debug_register_category("imhtml clipboard");
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 11010
diff changeset
705 */
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 11010
diff changeset
706 gaim_debug_register_category("imgstore");
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 11010
diff changeset
707 gaim_debug_register_category("pluginpref");
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 11010
diff changeset
708 gaim_debug_register_category("request");
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 11010
diff changeset
709 gaim_debug_register_category("roomlist");
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 11010
diff changeset
710 /* gtkutils.c */
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 11010
diff changeset
711 gaim_debug_register_category("accels");
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 11010
diff changeset
712 gaim_debug_register_category("gtkspell");
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 11010
diff changeset
713 /* These are from util.c */
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 11010
diff changeset
714 gaim_debug_register_category("build_dir");
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 11010
diff changeset
715 gaim_debug_register_category("gaim_mkstemp");
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 11010
diff changeset
716 gaim_debug_register_category("gaim_str_add_cr");
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 11010
diff changeset
717 gaim_debug_register_category("gaim_url_fetch");
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 11010
diff changeset
718 gaim_debug_register_category("gaim_utf8_strcasecmp");
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 11010
diff changeset
719 gaim_debug_register_category("parse_content_len");
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 11010
diff changeset
720 gaim_debug_register_category("program_is_valid");
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 11010
diff changeset
721 gaim_debug_register_category("util");
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 11010
diff changeset
722 /* These only show up once */
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 11010
diff changeset
723 gaim_debug_register_category("gtknotify");
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 11010
diff changeset
724 gaim_debug_register_category("gtksound");
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 11010
diff changeset
725 gaim_debug_register_category("prpl");
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 11010
diff changeset
726 gaim_debug_register_category("server");
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 11010
diff changeset
727 gaim_debug_register_category("stringref");
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 11010
diff changeset
728
11055
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents: 11033
diff changeset
729 #ifdef HAVE_DBUS
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents: 11033
diff changeset
730 /* Starting DBUS */
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents: 11033
diff changeset
731 dbus_server_init();
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents: 11033
diff changeset
732 #endif
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents: 11033
diff changeset
733
10302
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
734 gtk_main();
10320
61852117568f [gaim-migrate @ 11527]
Mark Doliner <mark@kingant.net>
parents: 10317
diff changeset
735
10302
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
736 #ifdef _WIN32
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
737 wgaim_cleanup();
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
738 #endif
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
739
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
740 return 0;
581de78cf809 [gaim-migrate @ 11487]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
741 }