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