Mercurial > pidgin.yaz
annotate src/gtkmain.c @ 12024:e67993da8a22
[gaim-migrate @ 14317]
I strongly suspect CruiseControl is going to yell at me for this.
A voice chat API, GUI + mediastreamer. This is what I'm using for Google Talk.
This doesn't actually do anything at all. There's no code in the Jabber plugin yet
to use this API (although it Works For Me). All it will do is compile and link.
If you're lucky.
To build this, you should install oRTP from Linphone, Speex and iLBC (also
from linphone, I believe). To not build this, ./configure --disable-vv.
Most of the configure.ac and Makefile.am hackery was lifted right out of
Linphone with a few modifications. It seems to work if you have everything
installed or if you --disable-vv. I haven't really tested not having
everything installed and not --disabling-vv.
It's kinda funky to include all of mediastreamer in the source tree like this,
but linphone doesn't build it as a separate library. I'll probably wind up
writing them a patch to build it as a .so so we can link it dynamically instead.
This code certainly isn't finished. It'll adapt as I progress on the Google code,
but it's certainly of more use here in CVS than in my personal tree.
committer: Tailor Script <tailor@pidgin.im>
author | Sean Egan <seanegan@gmail.com> |
---|---|
date | Wed, 09 Nov 2005 08:07:20 +0000 |
parents | b4d7d6dbc95c |
children | 7165a7a444da |
rev | line source |
---|---|
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" | |
11475
7fab28c991f3
[gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
11403
diff
changeset
|
41 #include "whiteboard.h" |
10302 | 42 |
43 #include "gtkaccount.h" | |
44 #include "gtkblist.h" | |
45 #include "gtkconn.h" | |
46 #include "gtkconv.h" | |
47 #include "gtkdebug.h" | |
48 #include "gtkdialogs.h" | |
49 #include "gtkeventloop.h" | |
50 #include "gtkft.h" | |
12024 | 51 #include "gtkmedia.h" |
11907 | 52 #include "gtkidle.h" |
10302 | 53 #include "gtknotify.h" |
54 #include "gtkplugin.h" | |
55 #include "gtkpounce.h" | |
56 #include "gtkprefs.h" | |
57 #include "gtkprivacy.h" | |
58 #include "gtkrequest.h" | |
59 #include "gtkroomlist.h" | |
10574 | 60 #include "gtksavedstatuses.h" |
10302 | 61 #include "gtksound.h" |
11525 | 62 #include "gtkthemes.h" |
10302 | 63 #include "gtkutils.h" |
64 #include "gtkstock.h" | |
11475
7fab28c991f3
[gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
11403
diff
changeset
|
65 #include "gtkwhiteboard.h" |
10302 | 66 |
67 #if HAVE_SIGNAL_H | |
68 # include <signal.h> | |
69 #endif | |
70 | |
71 #include <getopt.h> | |
72 | |
73 #ifdef HAVE_STARTUP_NOTIFICATION | |
74 # define SN_API_NOT_YET_FROZEN | |
75 # include <libsn/sn-launchee.h> | |
76 # include <gdk/gdkx.h> | |
77 #endif | |
78 | |
11055 | 79 |
80 | |
10302 | 81 #ifdef HAVE_STARTUP_NOTIFICATION |
82 static SnLauncheeContext *sn_context = NULL; | |
83 static SnDisplay *sn_display = NULL; | |
84 #endif | |
85 | |
86 #if HAVE_SIGNAL_H | |
87 /* | |
88 * Lists of signals we wish to catch and those we wish to ignore. | |
89 * Each list terminated with -1 | |
90 */ | |
91 static int catch_sig_list[] = { | |
92 SIGSEGV, | |
93 SIGHUP, | |
94 SIGINT, | |
95 SIGTERM, | |
96 SIGQUIT, | |
97 SIGCHLD, | |
98 -1 | |
99 }; | |
100 | |
101 static int ignore_sig_list[] = { | |
102 SIGPIPE, | |
103 -1 | |
104 }; | |
105 #endif | |
106 | |
10323 | 107 static int |
108 dologin_named(const char *name) | |
10302 | 109 { |
110 GaimAccount *account; | |
10323 | 111 char **names; |
112 int i; | |
113 int ret = -1; | |
10302 | 114 |
10323 | 115 if (name != NULL) { /* list of names given */ |
116 names = g_strsplit(name, ",", 64); | |
117 for (i = 0; names[i] != NULL; i++) { | |
118 account = gaim_accounts_find(names[i], NULL); | |
119 if (account != NULL) { /* found a user */ | |
120 ret = 0; | |
10738 | 121 gaim_account_connect(account); |
10302 | 122 } |
123 } | |
124 g_strfreev(names); | |
10323 | 125 } else { /* no name given, use the first account */ |
11520 | 126 GList *accounts; |
127 | |
128 accounts = gaim_accounts_get_all(); | |
129 if (accounts != NULL) | |
130 { | |
131 account = (GaimAccount *)accounts->data; | |
132 ret = 0; | |
133 gaim_account_connect(account); | |
134 } | |
10302 | 135 } |
136 | |
10323 | 137 return ret; |
10302 | 138 } |
139 | |
10333 | 140 #if HAVE_SIGNAL_H |
10302 | 141 static void |
142 clean_pid(void) | |
143 { | |
144 int status; | |
145 pid_t pid; | |
146 | |
147 do { | |
148 pid = waitpid(-1, &status, WNOHANG); | |
149 } while (pid != 0 && pid != (pid_t)-1); | |
10334 | 150 |
151 if ((pid == (pid_t) - 1) && (errno != ECHILD)) { | |
10302 | 152 char errmsg[BUFSIZ]; |
153 snprintf(errmsg, BUFSIZ, "Warning: waitpid() returned %d", pid); | |
154 perror(errmsg); | |
155 } | |
156 } | |
157 | |
10871 | 158 static void |
10323 | 159 sighandler(int sig) |
10302 | 160 { |
161 switch (sig) { | |
162 case SIGHUP: | |
10323 | 163 gaim_debug_warning("sighandler", "Caught signal %d\n", sig); |
10302 | 164 gaim_connections_disconnect_all(); |
165 break; | |
166 case SIGSEGV: | |
167 #ifndef DEBUG | |
168 fprintf(stderr, "Gaim has segfaulted and attempted to dump a core file.\n" | |
169 "This is a bug in the software and has happened through\n" | |
170 "no fault of your own.\n\n" | |
171 "It is possible that this bug is already fixed in CVS.\n" | |
10323 | 172 "If you can reproduce the crash, please notify the gaim\n" |
10302 | 173 "maintainers by reporting a bug at\n" |
174 GAIM_WEBSITE "bug.php\n\n" | |
175 "Please make sure to specify what you were doing at the time,\n" | |
176 "and post the backtrace from the core file. If you do not know\n" | |
177 "how to get the backtrace, please get instructions at\n" | |
178 GAIM_WEBSITE "gdb.php. If you need further\n" | |
10638
222b53ee74f3
[gaim-migrate @ 12135]
Luke Schierer <lschiere@pidgin.im>
parents:
10589
diff
changeset
|
179 "assistance, please IM either SeanEgn or LSchiere and\n" |
10302 | 180 "they can help you.\n"); |
181 #else | |
182 fprintf(stderr, "Hi, user. We need to talk.\n" | |
183 "I think something's gone wrong here. It's probably my fault.\n" | |
184 "No, really, it's not you... it's me... no no no, I think we get along well\n" | |
185 "it's just that.... well, I want to see other people. I... what?!? NO! I haven't\n" | |
186 "been cheating on you!! How many times do you want me to tell you?! And for the\n" | |
187 "last time, it's just a rash!\n"); | |
188 /*g_on_error_query (g_get_prgname());*/ | |
189 #endif | |
190 abort(); | |
191 break; | |
192 case SIGCHLD: | |
193 clean_pid(); | |
194 signal(SIGCHLD, sighandler); /* restore signal catching on this one! */ | |
195 break; | |
196 default: | |
10323 | 197 gaim_debug_warning("sighandler", "Caught signal %d\n", sig); |
10302 | 198 gaim_connections_disconnect_all(); |
199 | |
200 gaim_plugins_unload_all(); | |
201 | |
202 if (gtk_main_level()) | |
203 gtk_main_quit(); | |
204 exit(0); | |
205 } | |
206 } | |
207 #endif | |
208 | |
10323 | 209 static int |
210 ui_main() | |
10302 | 211 { |
212 #ifndef _WIN32 | |
213 GList *icons = NULL; | |
214 GdkPixbuf *icon = NULL; | |
215 char *icon_path; | |
216 #endif | |
217 | |
11525 | 218 gaim_gtkthemes_init(); |
10302 | 219 |
220 gaim_gtk_blist_setup_sort_methods(); | |
221 | |
222 #ifndef _WIN32 | |
223 /* use the nice PNG icon for all the windows */ | |
224 icon_path = g_build_filename(DATADIR, "pixmaps", "gaim", "icons", "online.png", NULL); | |
225 icon = gdk_pixbuf_new_from_file(icon_path, NULL); | |
226 g_free(icon_path); | |
227 if (icon) { | |
228 icons = g_list_append(icons,icon); | |
229 gtk_window_set_default_icon_list(icons); | |
230 g_object_unref(G_OBJECT(icon)); | |
231 g_list_free(icons); | |
232 } else { | |
10323 | 233 gaim_debug_error("ui_main", |
234 "Failed to load the default window icon!\n"); | |
10302 | 235 } |
236 #endif | |
237 | |
238 return 0; | |
239 } | |
240 | |
241 static void | |
242 debug_init(void) | |
243 { | |
244 gaim_debug_set_ui_ops(gaim_gtk_debug_get_ui_ops()); | |
245 gaim_gtk_debug_init(); | |
246 } | |
247 | |
248 static void | |
249 gaim_gtk_ui_init(void) | |
250 { | |
251 /* Set the UI operation structures. */ | |
252 gaim_accounts_set_ui_ops(gaim_gtk_accounts_get_ui_ops()); | |
253 gaim_xfers_set_ui_ops(gaim_gtk_xfers_get_ui_ops()); | |
254 gaim_blist_set_ui_ops(gaim_gtk_blist_get_ui_ops()); | |
255 gaim_notify_set_ui_ops(gaim_gtk_notify_get_ui_ops()); | |
256 gaim_privacy_set_ui_ops(gaim_gtk_privacy_get_ui_ops()); | |
257 gaim_request_set_ui_ops(gaim_gtk_request_get_ui_ops()); | |
258 gaim_sound_set_ui_ops(gaim_gtk_sound_get_ui_ops()); | |
259 gaim_connections_set_ui_ops(gaim_gtk_connections_get_ui_ops()); | |
11475
7fab28c991f3
[gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
11403
diff
changeset
|
260 gaim_whiteboard_set_ui_ops(gaim_gtk_whiteboard_get_ui_ops()); |
10302 | 261 |
262 gaim_gtk_stock_init(); | |
263 gaim_gtk_prefs_init(); | |
264 gaim_gtk_account_init(); | |
265 gaim_gtk_blist_init(); | |
10574 | 266 gaim_gtk_status_init(); |
10302 | 267 gaim_gtk_conversations_init(); |
268 gaim_gtk_pounces_init(); | |
269 gaim_gtk_privacy_init(); | |
270 gaim_gtk_xfers_init(); | |
271 gaim_gtk_roomlist_init(); | |
12024 | 272 #ifdef HAEV_VV |
273 gaim_gtk_media_init(); | |
274 #endif | |
11907 | 275 gaim_gtk_idle_init(); |
10302 | 276 } |
277 | |
278 static void | |
279 gaim_gtk_quit(void) | |
280 { | |
281 /* XXX? */ | |
282 /* YYY is there an XXX here? */ | |
283 | |
284 /* captain's log, stardate... */ | |
285 /* LOG system_log(log_quit, NULL, NULL, OPT_LOG_BUDDY_SIGNON | OPT_LOG_MY_SIGNON); */ | |
286 | |
287 #ifdef USE_SM | |
288 /* unplug */ | |
289 session_end(); | |
290 #endif | |
291 | |
292 /* Save the plugins we have loaded for next time. */ | |
293 gaim_gtk_plugins_save(); | |
294 | |
10574 | 295 /* Uninit */ |
296 gaim_gtk_conversations_uninit(); | |
297 gaim_gtk_status_uninit(); | |
298 gaim_gtk_blist_uninit(); | |
299 gaim_gtk_account_uninit(); | |
11010 | 300 gaim_gtk_xfers_uninit(); |
11033
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11010
diff
changeset
|
301 gaim_gtk_debug_uninit(); |
11907 | 302 gaim_gtk_idle_uninit(); |
10574 | 303 |
10302 | 304 /* and end it all... */ |
305 gtk_main_quit(); | |
306 } | |
307 | |
308 static GaimCoreUiOps core_ops = | |
309 { | |
310 gaim_gtk_prefs_init, | |
311 debug_init, | |
312 gaim_gtk_ui_init, | |
313 gaim_gtk_quit | |
314 }; | |
315 | |
316 static GaimCoreUiOps * | |
317 gaim_gtk_core_get_ui_ops(void) | |
318 { | |
319 return &core_ops; | |
320 } | |
321 | |
322 static void | |
10320 | 323 show_usage(const char *name, gboolean terse) |
10302 | 324 { |
10320 | 325 char *text; |
326 char *text_conv; | |
327 GError *error = NULL; | |
10302 | 328 |
10320 | 329 if (terse) { |
330 text = g_strdup_printf(_("Gaim %s. Try `%s -h' for more information.\n"), VERSION, name); | |
331 } else { | |
332 text = g_strdup_printf(_("Gaim %s\n" | |
10302 | 333 "Usage: %s [OPTION]...\n\n" |
334 " -c, --config=DIR use DIR for config files\n" | |
335 " -d, --debug print debugging messages to stdout\n" | |
10320 | 336 " -h, --help display this help and exit\n" |
10323 | 337 " -n, --nologin don't automatically login\n" |
10320 | 338 " -l, --login[=NAME] automatically login (optional argument NAME specifies\n" |
11673
922d0483ca88
[gaim-migrate @ 13959]
Richard Laager <rlaager@wiktel.com>
parents:
11581
diff
changeset
|
339 " account(s) to use, separated by commas)\n" |
10323 | 340 " -v, --version display the current version and exit\n"), VERSION, name); |
10302 | 341 } |
342 | |
10320 | 343 /* tries to convert 'text' to users locale */ |
344 text_conv = g_locale_from_utf8(text, -1, NULL, NULL, &error); | |
345 if (text_conv != NULL) { | |
346 puts(text_conv); | |
347 g_free(text_conv); | |
10302 | 348 } |
10320 | 349 /* use 'text' as a fallback */ |
350 else { | |
351 g_warning("%s\n", error->message); | |
352 g_error_free(error); | |
353 puts(text); | |
354 } | |
355 g_free(text); | |
10302 | 356 } |
357 | |
358 #ifdef HAVE_STARTUP_NOTIFICATION | |
359 static void | |
360 sn_error_trap_push(SnDisplay *display, Display *xdisplay) | |
361 { | |
362 gdk_error_trap_push(); | |
363 } | |
364 | |
365 static void | |
366 sn_error_trap_pop(SnDisplay *display, Display *xdisplay) | |
367 { | |
368 gdk_error_trap_pop(); | |
369 } | |
370 | |
371 static void | |
372 startup_notification_complete(void) | |
373 { | |
374 Display *xdisplay; | |
375 | |
376 xdisplay = GDK_DISPLAY(); | |
377 sn_display = sn_display_new(xdisplay, | |
378 sn_error_trap_push, | |
379 sn_error_trap_pop); | |
380 sn_context = | |
381 sn_launchee_context_new_from_environment(sn_display, | |
382 DefaultScreen(xdisplay)); | |
383 | |
384 if (sn_context != NULL) | |
385 { | |
386 sn_launchee_context_complete(sn_context); | |
387 sn_launchee_context_unref(sn_context); | |
388 | |
389 sn_display_unref(sn_display); | |
390 } | |
391 } | |
392 #endif /* HAVE_STARTUP_NOTIFICATION */ | |
393 | |
394 #ifndef _WIN32 | |
395 static char *gaim_find_binary_location(void *symbol, void *data) | |
396 { | |
397 static char *fullname = NULL; | |
398 static gboolean first = TRUE; | |
399 | |
400 char *argv0 = data; | |
401 struct stat st; | |
402 char *basebuf, *linkbuf, *fullbuf; | |
403 | |
404 if (!first) | |
405 /* We've already been through this. */ | |
406 return strdup(fullname); | |
407 | |
408 first = FALSE; | |
409 | |
410 if (!argv0) | |
411 return NULL; | |
412 | |
413 | |
414 basebuf = g_find_program_in_path(argv0); | |
415 | |
416 /* But we still need to deal with symbolic links */ | |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10581
diff
changeset
|
417 g_lstat(basebuf, &st); |
10302 | 418 while ((st.st_mode & S_IFLNK) == S_IFLNK) { |
419 linkbuf = g_malloc(1024); | |
420 readlink(basebuf, linkbuf, 1024); | |
421 if (linkbuf[0] == G_DIR_SEPARATOR) { | |
422 /* an absolute path */ | |
423 fullbuf = g_strdup(linkbuf); | |
424 } else { | |
425 char *dirbuf = g_path_get_dirname(basebuf); | |
426 /* a relative path */ | |
427 fullbuf = g_strdup_printf("%s%s%s", | |
428 dirbuf, G_DIR_SEPARATOR_S, | |
429 linkbuf); | |
430 g_free(dirbuf); | |
431 } | |
432 /* There's no memory leak here. Really! */ | |
433 g_free(linkbuf); | |
434 g_free(basebuf); | |
435 basebuf = fullbuf; | |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10581
diff
changeset
|
436 g_lstat(basebuf, &st); |
10302 | 437 } |
438 | |
439 fullname = basebuf; | |
440 return strdup(fullname); | |
441 } | |
442 #endif /* #ifndef _WIN32 */ | |
443 | |
444 /* FUCKING GET ME A TOWEL! */ | |
445 #ifdef _WIN32 | |
446 int gaim_main(HINSTANCE hint, int argc, char *argv[]) | |
447 #else | |
448 int main(int argc, char *argv[]) | |
449 #endif | |
450 { | |
10323 | 451 gboolean opt_help = FALSE; |
452 gboolean opt_login = FALSE; | |
453 gboolean opt_nologin = FALSE; | |
454 gboolean opt_version = FALSE; | |
455 char *opt_config_dir_arg = NULL; | |
456 char *opt_login_arg = NULL; | |
457 char *opt_session_arg = NULL; | |
458 int dologin_ret = -1; | |
10447 | 459 char *search_path; |
10302 | 460 #if HAVE_SIGNAL_H |
461 int sig_indx; /* for setting up signal catching */ | |
462 sigset_t sigset; | |
463 void (*prev_sig_disp)(); | |
464 #endif | |
10323 | 465 int opt; |
10302 | 466 gboolean gui_check; |
10307 | 467 gboolean debug_enabled; |
10334 | 468 #if HAVE_SIGNAL_H |
10323 | 469 char errmsg[BUFSIZ]; |
10334 | 470 #endif |
10302 | 471 |
472 struct option long_options[] = { | |
10323 | 473 {"config", required_argument, NULL, 'c'}, |
474 {"debug", no_argument, NULL, 'd'}, | |
475 {"help", no_argument, NULL, 'h'}, | |
476 {"login", optional_argument, NULL, 'l'}, | |
477 {"nologin", no_argument, NULL, 'n'}, | |
478 {"session", required_argument, NULL, 's'}, | |
479 {"version", no_argument, NULL, 'v'}, | |
10302 | 480 {0, 0, 0, 0} |
481 }; | |
482 | |
483 #ifdef DEBUG | |
10307 | 484 debug_enabled = TRUE; |
485 #else | |
486 debug_enabled = FALSE; | |
10302 | 487 #endif |
10307 | 488 |
10302 | 489 #ifndef _WIN32 |
490 br_set_locate_fallback_func(gaim_find_binary_location, argv[0]); | |
491 #endif | |
492 #ifdef ENABLE_NLS | |
493 bindtextdomain(PACKAGE, LOCALEDIR); | |
494 bind_textdomain_codeset(PACKAGE, "UTF-8"); | |
495 textdomain(PACKAGE); | |
496 #endif | |
497 | |
11080 | 498 |
10302 | 499 #if HAVE_SIGNAL_H |
500 /* Let's not violate any PLA's!!!! */ | |
501 /* jseymour: whatever the fsck that means */ | |
502 /* Robot101: for some reason things like gdm like to block * | |
503 * useful signals like SIGCHLD, so we unblock all the ones we * | |
504 * declare a handler for. thanks JSeymour and Vann. */ | |
505 if (sigemptyset(&sigset)) { | |
506 snprintf(errmsg, BUFSIZ, "Warning: couldn't initialise empty signal set"); | |
507 perror(errmsg); | |
508 } | |
509 for(sig_indx = 0; catch_sig_list[sig_indx] != -1; ++sig_indx) { | |
510 if((prev_sig_disp = signal(catch_sig_list[sig_indx], sighandler)) == SIG_ERR) { | |
511 snprintf(errmsg, BUFSIZ, "Warning: couldn't set signal %d for catching", | |
512 catch_sig_list[sig_indx]); | |
513 perror(errmsg); | |
514 } | |
515 if(sigaddset(&sigset, catch_sig_list[sig_indx])) { | |
516 snprintf(errmsg, BUFSIZ, "Warning: couldn't include signal %d for unblocking", | |
517 catch_sig_list[sig_indx]); | |
518 perror(errmsg); | |
519 } | |
520 } | |
521 for(sig_indx = 0; ignore_sig_list[sig_indx] != -1; ++sig_indx) { | |
522 if((prev_sig_disp = signal(ignore_sig_list[sig_indx], SIG_IGN)) == SIG_ERR) { | |
523 snprintf(errmsg, BUFSIZ, "Warning: couldn't set signal %d to ignore", | |
524 ignore_sig_list[sig_indx]); | |
525 perror(errmsg); | |
526 } | |
527 } | |
528 | |
529 if (sigprocmask(SIG_UNBLOCK, &sigset, NULL)) { | |
530 snprintf(errmsg, BUFSIZ, "Warning: couldn't unblock signals"); | |
531 perror(errmsg); | |
10307 | 532 } |
10302 | 533 #endif |
534 | |
10581
59a2807e10bb
[gaim-migrate @ 11981]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10574
diff
changeset
|
535 gui_check = gtk_init_check(&argc, &argv); |
59a2807e10bb
[gaim-migrate @ 11981]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10574
diff
changeset
|
536 if (!gui_check) { |
59a2807e10bb
[gaim-migrate @ 11981]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10574
diff
changeset
|
537 char *display = gdk_get_display(); |
59a2807e10bb
[gaim-migrate @ 11981]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10574
diff
changeset
|
538 |
11033
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11010
diff
changeset
|
539 printf("Gaim %s\n", VERSION); |
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11010
diff
changeset
|
540 |
10581
59a2807e10bb
[gaim-migrate @ 11981]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10574
diff
changeset
|
541 g_warning("cannot open display: %s", display ? display : "unset"); |
59a2807e10bb
[gaim-migrate @ 11981]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10574
diff
changeset
|
542 g_free(display); |
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 return 1; |
59a2807e10bb
[gaim-migrate @ 11981]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10574
diff
changeset
|
545 } |
59a2807e10bb
[gaim-migrate @ 11981]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10574
diff
changeset
|
546 |
10302 | 547 /* scan command-line options */ |
548 opterr = 1; | |
549 while ((opt = getopt_long(argc, argv, | |
550 #ifndef _WIN32 | |
11795
f48e2acaa5d2
[gaim-migrate @ 14086]
Richard Laager <rlaager@wiktel.com>
parents:
11785
diff
changeset
|
551 "c:dhnl::s:v", |
10302 | 552 #else |
11795
f48e2acaa5d2
[gaim-migrate @ 14086]
Richard Laager <rlaager@wiktel.com>
parents:
11785
diff
changeset
|
553 "c:dhnl::v", |
10302 | 554 #endif |
555 long_options, NULL)) != -1) { | |
556 switch (opt) { | |
10323 | 557 case 'c': /* config dir */ |
558 g_free(opt_config_dir_arg); | |
559 opt_config_dir_arg = g_strdup(optarg); | |
10302 | 560 break; |
561 case 'd': /* debug */ | |
10307 | 562 debug_enabled = TRUE; |
10302 | 563 break; |
10323 | 564 case 'h': /* help */ |
565 opt_help = TRUE; | |
566 break; | |
567 case 'n': /* no autologin */ | |
568 opt_nologin = TRUE; | |
10302 | 569 break; |
10323 | 570 case 'l': /* login, option username */ |
571 opt_login = TRUE; | |
572 g_free(opt_login_arg); | |
573 if (optarg != NULL) | |
574 opt_login_arg = g_strdup(optarg); | |
10302 | 575 break; |
10320 | 576 case 's': /* use existing session ID */ |
10323 | 577 g_free(opt_session_arg); |
10320 | 578 opt_session_arg = g_strdup(optarg); |
579 break; | |
10323 | 580 case 'v': /* version */ |
581 opt_version = TRUE; | |
10320 | 582 break; |
10323 | 583 case '?': /* show terse help */ |
10302 | 584 default: |
10320 | 585 show_usage(argv[0], TRUE); |
10302 | 586 return 0; |
587 break; | |
588 } | |
589 } | |
590 | |
591 /* show help message */ | |
592 if (opt_help) { | |
10320 | 593 show_usage(argv[0], FALSE); |
10302 | 594 return 0; |
595 } | |
596 /* show version message */ | |
597 if (opt_version) { | |
10323 | 598 printf("Gaim %s\n", VERSION); |
10302 | 599 return 0; |
600 } | |
601 | |
10323 | 602 /* set a user-specified config directory */ |
603 if (opt_config_dir_arg != NULL) { | |
10871 | 604 gaim_util_set_user_dir(opt_config_dir_arg); |
10323 | 605 } |
606 | |
10448 | 607 /* |
608 * We're done piddling around with command line arguments. | |
609 * Fire up this baby. | |
610 */ | |
611 | |
612 gaim_debug_set_enabled(debug_enabled); | |
613 | |
10302 | 614 #ifdef _WIN32 |
10323 | 615 wgaim_init(hint); |
10302 | 616 #endif |
11067 | 617 |
10302 | 618 gaim_core_set_ui_ops(gaim_gtk_core_get_ui_ops()); |
619 gaim_eventloop_set_ui_ops(gaim_gtk_eventloop_get_ui_ops()); | |
620 | |
10447 | 621 /* Set plugin search directories */ |
622 gaim_plugins_add_search_path(LIBDIR); | |
623 search_path = g_build_filename(gaim_user_dir(), "plugins", NULL); | |
624 gaim_plugins_add_search_path(search_path); | |
625 g_free(search_path); | |
626 | |
10302 | 627 if (!gaim_core_init(GAIM_GTK_UI)) { |
628 fprintf(stderr, | |
629 "Initialization of the Gaim core failed. Dumping core.\n" | |
630 "Please report this!\n"); | |
631 abort(); | |
632 } | |
633 | |
10428 | 634 /* TODO: Move blist loading into gaim_blist_init() */ |
10302 | 635 gaim_set_blist(gaim_blist_new()); |
636 gaim_blist_load(); | |
637 | |
10433 | 638 /* TODO: Move prefs loading into gaim_prefs_init() */ |
10302 | 639 gaim_prefs_load(); |
640 gaim_prefs_update_old(); | |
641 gaim_gtk_prefs_update_old(); | |
642 | |
643 /* load plugins we had when we quit */ | |
644 gaim_plugins_load_saved("/gaim/gtk/plugins/loaded"); | |
645 | |
10433 | 646 /* TODO: Move pounces loading into gaim_pounces_init() */ |
10302 | 647 gaim_pounces_load(); |
648 | |
649 ui_main(); | |
650 | |
651 #ifdef USE_SM | |
652 session_init(argv[0], opt_session_arg, opt_config_dir_arg); | |
653 #endif | |
654 if (opt_session_arg != NULL) { | |
655 g_free(opt_session_arg); | |
656 opt_session_arg = NULL; | |
657 } | |
658 if (opt_config_dir_arg != NULL) { | |
659 g_free(opt_config_dir_arg); | |
660 opt_config_dir_arg = NULL; | |
661 } | |
662 | |
12011 | 663 /* |
664 * We want to show the blist early in the init process so the | |
665 * user feels warm and fuzzy (not cold and prickley). | |
666 */ | |
667 gaim_blist_show(); | |
668 | |
10302 | 669 if (gaim_prefs_get_bool("/gaim/gtk/debug/enabled")) |
670 gaim_gtk_debug_window_show(); | |
671 | |
672 if (opt_login) { | |
673 dologin_ret = dologin_named(opt_login_arg); | |
674 if (opt_login_arg != NULL) { | |
675 g_free(opt_login_arg); | |
676 opt_login_arg = NULL; | |
677 } | |
678 } | |
679 | |
11806 | 680 if (opt_nologin) |
681 { | |
682 /* Set all accounts to "offline" */ | |
683 GaimSavedStatus *saved_status; | |
684 saved_status = gaim_savedstatus_find(_("Default")); | |
685 if (saved_status == NULL) | |
686 saved_status = gaim_savedstatus_new(_("Default"), GAIM_STATUS_OFFLINE); | |
687 else | |
688 gaim_savedstatus_set_type(saved_status, GAIM_STATUS_OFFLINE); | |
689 gaim_prefs_set_string("/core/status/current", _("Default")); | |
690 gaim_savedstatus_activate(saved_status); | |
691 } | |
692 else | |
10738 | 693 { |
11348 | 694 /* Everything is good to go--sign on already */ |
695 gaim_accounts_restore_previous_statuses(); | |
10738 | 696 } |
10302 | 697 |
11785 | 698 if (gaim_accounts_get_all_active() == NULL) |
11403 | 699 { |
10302 | 700 gaim_gtk_accounts_window_show(); |
10315 | 701 } |
10302 | 702 |
703 #ifdef HAVE_STARTUP_NOTIFICATION | |
704 startup_notification_complete(); | |
705 #endif | |
10320 | 706 |
10302 | 707 gtk_main(); |
10320 | 708 |
10302 | 709 #ifdef _WIN32 |
710 wgaim_cleanup(); | |
711 #endif | |
712 | |
713 return 0; | |
714 } |