Mercurial > pidgin
annotate src/main.c @ 5436:ad445074d239
[gaim-migrate @ 5818]
Another big commit. Ugh. I need a very smart regexp.
Core/UI split do_error_dialog(), and soon the mail dialogs! Yay! This
should work without problems at all, but standard disclaimer..
committer: Tailor Script <tailor@pidgin.im>
author | Christian Hammond <chipx86@chipx86.com> |
---|---|
date | Sun, 18 May 2003 19:59:02 +0000 |
parents | a2f26666de42 |
children | 7e8524b5ff98 |
rev | line source |
---|---|
4489 | 1 /* |
2 * gaim | |
3 * | |
4 * Copyright (C) 1998-1999, Mark Spencer <markster@marko.net> | |
5 * | |
6 * This program is free software; you can redistribute it and/or modify | |
7 * it under the terms of the GNU General Public License as published by | |
8 * the Free Software Foundation; either version 2 of the License, or | |
9 * (at your option) any later version. | |
10 * | |
11 * This program is distributed in the hope that it will be useful, | |
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 * GNU General Public License for more details. | |
15 * | |
16 * You should have received a copy of the GNU General Public License | |
17 * along with this program; if not, write to the Free Software | |
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
19 * | |
20 */ | |
21 | |
22 #ifdef HAVE_CONFIG_H | |
23 #include <config.h> | |
24 #endif | |
25 #ifdef GAIM_PLUGINS | |
26 #ifndef _WIN32 | |
27 #include <dlfcn.h> | |
28 #endif | |
29 #endif /* GAIM_PLUGINS */ | |
30 #include <gtk/gtk.h> | |
31 #ifndef _WIN32 | |
32 #include <gdk/gdkx.h> | |
33 #include <unistd.h> | |
34 #include <sys/socket.h> | |
35 #include <netinet/in.h> | |
36 #include <arpa/inet.h> | |
37 #include <sys/un.h> | |
38 #include <sys/wait.h> | |
39 #endif /* !_WIN32 */ | |
40 #include <gdk/gdk.h> | |
41 #include <sys/types.h> | |
42 #include <sys/stat.h> | |
43 #include <errno.h> | |
44 #include <stdio.h> | |
45 #include <string.h> | |
46 #include <stdarg.h> | |
47 #include <stdlib.h> | |
48 #include <ctype.h> | |
49 #include "prpl.h" | |
4561 | 50 #include "sound.h" |
4489 | 51 #include "gaim.h" |
52 #include "gaim-socket.h" | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
53 #include "notify.h" |
5228
1a53330dfd34
[gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
54 #include "gtkblist.h" |
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
55 #include "gtkdebug.h" |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
56 #include "gtknotify.h" |
4489 | 57 #if HAVE_SIGNAL_H |
58 #include <signal.h> | |
59 #endif | |
60 #include "locale.h" | |
61 #include <getopt.h> | |
62 | |
63 #ifdef _WIN32 | |
64 #include "win32dep.h" | |
65 #endif | |
66 | |
67 static GtkWidget *name; | |
68 static GtkWidget *pass; | |
69 | |
70 GList *log_conversations = NULL; | |
71 GSList *away_messages = NULL; | |
72 GSList *message_queue = NULL; | |
73 GSList *unread_message_queue = NULL; | |
74 GSList *away_time_queue = NULL; | |
75 | |
76 GtkWidget *mainwindow = NULL; | |
77 | |
4561 | 78 |
4489 | 79 int opt_away = 0; |
4687 | 80 int docklet_count = 0; |
4489 | 81 char *opt_away_arg = NULL; |
82 char *opt_rcfile_arg = NULL; | |
83 int opt_debug = 0; | |
84 #ifdef _WIN32 | |
85 int opt_gdebug = 0; | |
86 #endif | |
87 | |
88 #if HAVE_SIGNAL_H | |
89 /* | |
90 * Lists of signals we wish to catch and those we wish to ignore. | |
91 * Each list terminated with -1 | |
92 */ | |
93 static int catch_sig_list[] = { | |
94 SIGSEGV, | |
95 SIGHUP, | |
96 SIGINT, | |
97 SIGTERM, | |
98 SIGQUIT, | |
99 SIGCHLD, | |
100 -1 | |
101 }; | |
102 | |
103 static int ignore_sig_list[] = { | |
104 SIGPIPE, | |
105 -1 | |
106 }; | |
107 #endif | |
108 | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5032
diff
changeset
|
109 STATIC_PROTO_INIT |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5032
diff
changeset
|
110 |
4489 | 111 void do_quit() |
112 { | |
113 /* captain's log, stardate... */ | |
114 system_log(log_quit, NULL, NULL, OPT_LOG_BUDDY_SIGNON | OPT_LOG_MY_SIGNON); | |
115 | |
116 /* the self destruct sequence has been initiated */ | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5032
diff
changeset
|
117 gaim_event_broadcast(event_quit); |
4489 | 118 |
119 /* transmission ends */ | |
120 signoff_all(); | |
121 | |
122 /* record what we have before we blow it away... */ | |
123 save_prefs(); | |
124 | |
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
125 gaim_debug(GAIM_DEBUG_INFO, "main", "Unloading all plugins\n"); |
5242
fd81a00480ac
[gaim-migrate @ 5613]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
126 gaim_plugins_destroy_all(); |
4489 | 127 |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5032
diff
changeset
|
128 /* XXX */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5032
diff
changeset
|
129 #if 0 |
4489 | 130 #ifdef USE_PERL |
131 /* yup, perl too */ | |
132 perl_end(); | |
133 #endif | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5032
diff
changeset
|
134 #endif |
4489 | 135 |
136 #ifdef USE_SM | |
137 /* unplug */ | |
138 session_end(); | |
139 #endif | |
140 | |
141 /* and end it all... */ | |
142 gtk_main_quit(); | |
143 } | |
144 | |
4561 | 145 static guint snd_tmout = 0; |
4489 | 146 static gboolean sound_timeout(gpointer data) |
147 { | |
4561 | 148 gaim_sound_set_login_mute(FALSE); |
149 snd_tmout = 0; | |
4489 | 150 return FALSE; |
151 } | |
152 | |
153 /* we need to do this for Oscar because serv_login only starts the login | |
154 * process, it doesn't end there. gaim_setup will be called later from | |
155 * oscar.c, after the buddy list is made and serv_finish_login is called */ | |
156 void gaim_setup(struct gaim_connection *gc) | |
157 { | |
158 if ((sound_options & OPT_SOUND_LOGIN) && (sound_options & OPT_SOUND_SILENT_SIGNON)) { | |
4561 | 159 if(snd_tmout) { |
160 g_source_remove(snd_tmout); | |
161 } | |
162 gaim_sound_set_login_mute(TRUE); | |
4489 | 163 snd_tmout = g_timeout_add(10000, sound_timeout, NULL); |
164 } | |
165 } | |
166 | |
167 static gboolean domiddleclick(GtkWidget *w, GdkEventButton *event, gpointer null) | |
168 { | |
169 if (event->button != 2) | |
170 return FALSE; | |
171 | |
172 auto_login(); | |
173 return TRUE; | |
174 } | |
175 | |
176 static void dologin(GtkWidget *widget, GtkWidget *w) | |
177 { | |
4491 | 178 struct gaim_account *account; |
4489 | 179 const char *username = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(name)->entry)); |
180 const char *password = gtk_entry_get_text(GTK_ENTRY(pass)); | |
181 | |
182 if (!strlen(username)) { | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
183 gaim_notify_error(NULL, NULL, _("Please enter your login."), NULL); |
4489 | 184 return; |
185 } | |
186 | |
187 /* if there is more than one user of the same name, then fuck | |
188 * them, they just have to use the account editor to sign in | |
189 * the second one */ | |
190 | |
4491 | 191 account = gaim_account_find(username, -1); |
192 if (!account) | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5032
diff
changeset
|
193 account = gaim_account_new(username, GAIM_PROTO_DEFAULT, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5032
diff
changeset
|
194 OPT_ACCT_REM_PASS); |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5032
diff
changeset
|
195 |
4491 | 196 g_snprintf(account->password, sizeof account->password, "%s", password); |
4489 | 197 save_prefs(); |
4491 | 198 serv_login(account); |
4489 | 199 } |
200 | |
201 /* <name> is a comma-separated list of names, or NULL | |
202 if NULL and there is at least one user defined in .gaimrc, try to login. | |
203 if not NULL, parse <name> into separate strings, look up each one in | |
204 .gaimrc and, if it's there, try to login. | |
205 returns: 0 if successful | |
206 -1 if no user was found that had a saved password | |
207 */ | |
208 static int dologin_named(char *name) | |
209 { | |
4491 | 210 struct gaim_account *account; |
4489 | 211 char **names, **n; |
212 int retval = -1; | |
213 | |
214 if (name !=NULL) { /* list of names given */ | |
215 names = g_strsplit(name, ",", 32); | |
216 for (n = names; *n != NULL; n++) { | |
4491 | 217 account = gaim_account_find(*n, -1); |
218 if (account) { /* found a user */ | |
219 if (account->options & OPT_ACCT_REM_PASS) { | |
4489 | 220 retval = 0; |
4491 | 221 serv_login(account); |
4489 | 222 } |
223 } | |
224 } | |
225 g_strfreev(names); | |
226 } else { /* no name given, use default */ | |
4491 | 227 account = (struct gaim_account *)gaim_accounts->data; |
228 if (account->options & OPT_ACCT_REM_PASS) { | |
4489 | 229 retval = 0; |
4491 | 230 serv_login(account); |
4489 | 231 } |
232 } | |
233 | |
234 return retval; | |
235 } | |
236 | |
237 | |
238 static void doenter(GtkWidget *widget, GtkWidget *w) | |
239 { | |
240 if (widget == name) { | |
241 gtk_entry_set_text(GTK_ENTRY(pass), ""); | |
4635 | 242 gtk_editable_select_region(GTK_EDITABLE(GTK_COMBO(name)->entry), 0, 0); |
4489 | 243 gtk_widget_grab_focus(pass); |
244 } else if (widget == pass) { | |
245 dologin(widget, w); | |
246 } | |
247 } | |
248 | |
249 | |
250 static void combo_changed(GtkWidget *w, GtkWidget *combo) | |
251 { | |
252 const char *txt = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(combo)->entry)); | |
4491 | 253 struct gaim_account *account; |
4489 | 254 |
4491 | 255 account = gaim_account_find(txt, -1); |
4489 | 256 |
4491 | 257 if (account && account->options & OPT_ACCT_REM_PASS) { |
258 gtk_entry_set_text(GTK_ENTRY(pass), account->password); | |
4489 | 259 } else { |
260 gtk_entry_set_text(GTK_ENTRY(pass), ""); | |
261 } | |
262 } | |
263 | |
264 | |
265 static GList *combo_user_names() | |
266 { | |
4491 | 267 GSList *accts = gaim_accounts; |
4489 | 268 GList *tmp = NULL; |
4491 | 269 struct gaim_account *account; |
4489 | 270 |
4491 | 271 if (!accts) |
4489 | 272 return g_list_append(NULL, _("<New User>")); |
273 | |
4491 | 274 while (accts) { |
275 account = (struct gaim_account *)accts->data; | |
276 tmp = g_list_append(tmp, account->username); | |
277 accts = accts->next; | |
4489 | 278 } |
279 | |
280 return tmp; | |
281 } | |
282 | |
283 static void login_window_closed(GtkWidget *w, GdkEvent *ev, gpointer d) | |
284 { | |
285 if(docklet_count) { | |
4880
9b51c090236a
[gaim-migrate @ 5210]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4800
diff
changeset
|
286 #ifdef _WIN32 |
4489 | 287 wgaim_systray_minimize(mainwindow); |
288 #endif | |
289 gtk_widget_hide(mainwindow); | |
290 } else | |
291 do_quit(); | |
292 } | |
293 | |
294 void show_login() | |
295 { | |
296 GtkWidget *image; | |
297 GtkWidget *vbox; | |
298 GtkWidget *button; | |
299 GtkWidget *hbox; | |
300 GtkWidget *label; | |
301 GtkWidget *vbox2; | |
302 GList *tmp; | |
303 | |
304 /* Do we already have a main window opened? If so, bring it back, baby... ribs... yeah */ | |
305 if (mainwindow) { | |
306 gtk_window_present(GTK_WINDOW(mainwindow)); | |
307 return; | |
308 } | |
309 | |
310 mainwindow = gtk_window_new(GTK_WINDOW_TOPLEVEL); | |
311 | |
312 gtk_window_set_role(GTK_WINDOW(mainwindow), "login"); | |
4635 | 313 gtk_window_set_resizable(GTK_WINDOW(mainwindow), FALSE); |
4703 | 314 gtk_window_set_title(GTK_WINDOW(mainwindow), _("Login")); |
4489 | 315 gtk_widget_realize(mainwindow); |
316 gdk_window_set_group(mainwindow->window, mainwindow->window); | |
317 gtk_container_set_border_width(GTK_CONTAINER(mainwindow), 5); | |
318 g_signal_connect(G_OBJECT(mainwindow), "delete_event", | |
319 G_CALLBACK(login_window_closed), mainwindow); | |
320 | |
321 vbox = gtk_vbox_new(FALSE, 0); | |
322 gtk_container_add(GTK_CONTAINER(mainwindow), vbox); | |
323 | |
5024 | 324 image = gtk_image_new_from_stock(GAIM_STOCK_LOGO, gtk_icon_size_from_name(GAIM_ICON_SIZE_LOGO)); |
4489 | 325 gtk_box_pack_start(GTK_BOX(vbox), image, FALSE, FALSE, 0); |
326 | |
327 vbox2 = gtk_vbox_new(FALSE, 0); | |
328 gtk_container_set_border_width(GTK_CONTAINER(vbox2), 5); | |
329 | |
330 label = gtk_label_new(_("Screen Name:")); | |
331 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); | |
332 gtk_box_pack_start(GTK_BOX(vbox2), label, FALSE, FALSE, 0); | |
333 | |
334 name = gtk_combo_new(); | |
335 tmp = combo_user_names(); | |
336 gtk_combo_set_popdown_strings(GTK_COMBO(name), tmp); | |
337 g_list_free(tmp); | |
338 g_signal_connect(G_OBJECT(GTK_COMBO(name)->entry), "activate", | |
339 G_CALLBACK(doenter), mainwindow); | |
340 g_signal_connect(G_OBJECT(GTK_COMBO(name)->entry), "changed", | |
341 G_CALLBACK(combo_changed), name); | |
342 gtk_box_pack_start(GTK_BOX(vbox2), name, FALSE, TRUE, 0); | |
343 gtk_box_pack_start(GTK_BOX(vbox), vbox2, FALSE, TRUE, 0); | |
344 | |
345 vbox2 = gtk_vbox_new(FALSE, 0); | |
346 gtk_container_set_border_width(GTK_CONTAINER(vbox2), 5); | |
347 | |
348 label = gtk_label_new(_("Password:")); | |
349 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); | |
350 gtk_box_pack_start(GTK_BOX(vbox2), label, FALSE, FALSE, 0); | |
351 | |
352 pass = gtk_entry_new(); | |
353 gtk_entry_set_visibility(GTK_ENTRY(pass), FALSE); | |
354 g_signal_connect(G_OBJECT(pass), "activate", | |
355 G_CALLBACK(doenter), mainwindow); | |
356 gtk_box_pack_start(GTK_BOX(vbox2), pass, FALSE, TRUE, 0); | |
357 gtk_box_pack_start(GTK_BOX(vbox), vbox2, FALSE, TRUE, 0); | |
358 | |
359 /* Now for the button box */ | |
360 hbox = gtk_hbox_new(TRUE, 0); | |
361 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE, 5); | |
362 | |
363 /* And now for the buttons */ | |
5024 | 364 button = gaim_pixbuf_button_from_stock(_("Accounts"), GAIM_STOCK_ACCOUNTS, GAIM_BUTTON_VERTICAL); |
4489 | 365 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); |
366 g_signal_connect(G_OBJECT(button), "clicked", | |
367 G_CALLBACK(account_editor), mainwindow); | |
368 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); | |
369 | |
370 #ifdef NO_MULTI | |
371 gtk_widget_set_sensitive(GTK_WIDGET(button), FALSE); | |
372 #endif | |
373 | |
5024 | 374 button = gaim_pixbuf_button_from_stock(_("Preferences"), GTK_STOCK_PREFERENCES, GAIM_BUTTON_VERTICAL); |
4489 | 375 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); |
376 g_signal_connect(G_OBJECT(button), "clicked", | |
377 G_CALLBACK(show_prefs), mainwindow); | |
378 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); | |
379 | |
5024 | 380 button = gaim_pixbuf_button_from_stock(_("Sign On"), GAIM_STOCK_SIGN_ON, GAIM_BUTTON_VERTICAL); |
4489 | 381 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); |
382 g_signal_connect(G_OBJECT(button), "clicked", | |
383 G_CALLBACK(dologin), mainwindow); | |
384 g_signal_connect(G_OBJECT(button), "button-press-event", G_CALLBACK(domiddleclick), NULL); | |
385 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); | |
386 | |
387 /* Now grab the focus that we need */ | |
4491 | 388 if (gaim_accounts) { |
389 struct gaim_account *account = gaim_accounts->data; | |
390 if (account->options & OPT_ACCT_REM_PASS) { | |
4489 | 391 combo_changed(NULL, name); |
392 gtk_widget_grab_focus(button); | |
393 } else { | |
394 gtk_widget_grab_focus(pass); | |
395 } | |
396 } else { | |
397 gtk_widget_grab_focus(name); | |
398 } | |
399 | |
400 /* And raise the curtain! */ | |
401 gtk_widget_show_all(mainwindow); | |
402 | |
403 } | |
404 | |
405 #if HAVE_SIGNAL_H | |
406 void sighandler(int sig) | |
407 { | |
408 switch (sig) { | |
409 case SIGHUP: | |
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
410 gaim_debug(GAIM_DEBUG_WARNING, "sighandler", |
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
411 "Caught signal %d\n", sig); |
4489 | 412 signoff_all(NULL, NULL); |
413 break; | |
414 case SIGSEGV: | |
415 core_quit(); | |
416 #ifndef DEBUG | |
417 fprintf(stderr, "Gaim has segfaulted and attempted to dump a core file.\n" | |
418 "This is a bug in the software and has happened through\n" | |
419 "no fault of your own.\n\n" | |
420 "It is possible that this bug is already fixed in CVS.\n" | |
421 "You can get a tarball of CVS from the Gaim website, at\n" | |
422 WEBSITE "gaim-CVS.tar.gz.\n\n" | |
423 "If you are already using CVS, or can reproduce the crash\n" | |
424 "using the CVS version, please notify the gaim maintainers\n" | |
425 "by reporting a bug at\n" | |
426 WEBSITE "bug.php\n\n" | |
427 "Please make sure to specify what you were doing at the time,\n" | |
428 "and post the backtrace from the core file. If you do not know\n" | |
429 "how to get the backtrace, please get instructions at\n" | |
430 WEBSITE "gdb.php. If you need further\n" | |
431 "assistance, please IM either RobFlynn or SeanEgn and\n" | |
432 "they can help you.\n"); | |
433 #else | |
434 fprintf(stderr, "Oh no! Segmentation fault!\n"); | |
4703 | 435 /*g_on_error_query (g_get_prgname());*/ |
4489 | 436 exit(1); |
437 #endif | |
438 abort(); | |
439 break; | |
440 case SIGCHLD: | |
441 clean_pid(); | |
442 #if HAVE_SIGNAL_H | |
443 signal(SIGCHLD, sighandler); /* restore signal catching on this one! */ | |
444 #endif | |
445 break; | |
446 default: | |
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
447 gaim_debug(GAIM_DEBUG_WARNING, "sighandler", |
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
448 "Caught signal %d\n", sig); |
4489 | 449 signoff_all(NULL, NULL); |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5032
diff
changeset
|
450 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5032
diff
changeset
|
451 gaim_plugins_unload_all(); |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5032
diff
changeset
|
452 |
4489 | 453 if (gtk_main_level()) |
454 gtk_main_quit(); | |
455 core_quit(); | |
456 exit(0); | |
457 } | |
458 } | |
459 #endif | |
460 | |
461 #ifndef _WIN32 | |
462 static gboolean socket_readable(GIOChannel *source, GIOCondition cond, gpointer ud) | |
463 { | |
464 guchar type; | |
465 guchar subtype; | |
466 guint32 len; | |
467 guchar *data; | |
468 guint32 x; | |
4793 | 469 GError *error; |
4489 | 470 |
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
471 gaim_debug(GAIM_DEBUG_INFO, "core socket", "Core says: "); |
4793 | 472 g_io_channel_read_chars(source, &type, sizeof(type), &x, &error); |
473 if(error) | |
4800 | 474 g_error_free(error); |
4489 | 475 if (x == 0) { |
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
476 gaim_debug(GAIM_DEBUG_ERROR, NULL, "CORE IS GONE!\n"); |
4793 | 477 g_io_channel_shutdown(source, TRUE, &error); |
478 if(error) | |
479 g_free(error); | |
4489 | 480 return FALSE; |
481 } | |
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
482 gaim_debug(GAIM_DEBUG_INFO, NULL, "%d ", type); |
4793 | 483 g_io_channel_read_chars(source, &subtype, sizeof(subtype), &x, &error); |
484 if(error) | |
4800 | 485 g_error_free(error); |
4489 | 486 if (x == 0) { |
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
487 gaim_debug(GAIM_DEBUG_ERROR, NULL, "CORE IS GONE!\n"); |
4793 | 488 g_io_channel_shutdown(source, TRUE, &error); |
489 if(error) | |
4800 | 490 g_error_free(error); |
4489 | 491 return FALSE; |
492 } | |
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
493 |
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
494 gaim_debug(GAIM_DEBUG_INFO, NULL, "%d ", subtype); |
4793 | 495 g_io_channel_read_chars(source, (guchar *)&len, sizeof(len), &x, &error); |
496 if(error) | |
4800 | 497 g_error_free(error); |
4489 | 498 if (x == 0) { |
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
499 gaim_debug(GAIM_DEBUG_ERROR, NULL, "CORE IS GONE!\n"); |
4793 | 500 g_io_channel_shutdown(source, TRUE, &error); |
501 if(error) | |
4800 | 502 g_error_free(error); |
4489 | 503 return FALSE; |
504 } | |
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
505 |
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
506 gaim_debug(GAIM_DEBUG_INFO, NULL, "(%d bytes)\n", len); |
4489 | 507 |
508 data = g_malloc(len); | |
4793 | 509 g_io_channel_read_chars(source, data, len, &x, &error); |
510 if(error) | |
4800 | 511 g_error_free(error); |
4489 | 512 if (x != len) { |
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
513 gaim_debug(GAIM_DEBUG_ERROR, "core socket", |
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
514 "CORE IS GONE! (read %d/%d bytes)\n", x, len); |
4489 | 515 g_free(data); |
4793 | 516 g_io_channel_shutdown(source, TRUE, &error); |
517 if(error) | |
4800 | 518 g_error_free(error); |
4489 | 519 return FALSE; |
520 } | |
521 | |
522 g_free(data); | |
523 return TRUE; | |
524 } | |
525 #endif /* _WIN32 */ | |
526 | |
527 static int ui_main() | |
528 { | |
529 #ifndef _WIN32 | |
530 GIOChannel *channel; | |
531 int UI_fd; | |
532 char name[256]; | |
533 GList *icons = NULL; | |
534 GdkPixbuf *icon = NULL; | |
535 char *icon_path; | |
536 #endif | |
4978 | 537 |
4489 | 538 if (current_smiley_theme == NULL) { |
539 smiley_theme_probe(); | |
540 if (smiley_themes) { | |
541 struct smiley_theme *smile = smiley_themes->data; | |
542 load_smiley_theme(smile->path, TRUE); | |
543 } | |
544 } | |
545 | |
5422 | 546 gaim_gtk_blist_setup_sort_methods(); |
4489 | 547 setup_stock(); |
548 | |
549 #ifndef _WIN32 | |
550 /* use the nice PNG icon for all the windows */ | |
5024 | 551 icon_path = g_build_filename(DATADIR, "pixmaps", "gaim", "icons", "online.png", NULL); |
4489 | 552 icon = gdk_pixbuf_new_from_file(icon_path, NULL); |
553 g_free(icon_path); | |
554 if (icon) { | |
555 icons = g_list_append(icons,icon); | |
556 gtk_window_set_default_icon_list(icons); | |
557 g_object_unref(G_OBJECT(icon)); | |
4978 | 558 g_list_free(icons); |
4489 | 559 } else { |
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
560 gaim_debug(GAIM_DEBUG_ERROR, "ui_main", |
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
561 "Failed to load the default window icon!\n"); |
4489 | 562 } |
563 | |
564 g_snprintf(name, sizeof(name), "%s" G_DIR_SEPARATOR_S "gaim_%s.%d", g_get_tmp_dir(), g_get_user_name(), gaim_session); | |
565 UI_fd = gaim_connect_to_session(0); | |
566 if (UI_fd < 0) | |
567 return 1; | |
568 | |
569 channel = g_io_channel_unix_new(UI_fd); | |
570 g_io_add_watch(channel, G_IO_IN | G_IO_HUP | G_IO_ERR, socket_readable, NULL); | |
571 #endif | |
4978 | 572 |
4489 | 573 return 0; |
574 } | |
575 | |
576 static void set_first_user(char *name) | |
577 { | |
4491 | 578 struct gaim_account *account; |
4489 | 579 |
4491 | 580 account = gaim_account_find(name, -1); |
4489 | 581 |
4491 | 582 if (!account) { /* new user */ |
583 account = g_new0(struct gaim_account, 1); | |
584 g_snprintf(account->username, sizeof(account->username), "%s", name); | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5032
diff
changeset
|
585 account->protocol = GAIM_PROTO_DEFAULT; |
4491 | 586 gaim_accounts = g_slist_prepend(gaim_accounts, account); |
4489 | 587 } else { /* user already exists */ |
4491 | 588 gaim_accounts = g_slist_remove(gaim_accounts, account); |
589 gaim_accounts = g_slist_prepend(gaim_accounts, account); | |
4489 | 590 } |
591 save_prefs(); | |
592 } | |
593 | |
594 #ifdef _WIN32 | |
595 /* WIN32 print and log handlers */ | |
596 | |
597 static void gaim_dummy_print( const gchar* string ) { | |
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
598 return; |
4489 | 599 } |
600 | |
601 static void gaim_dummy_log_handler (const gchar *domain, | |
602 GLogLevelFlags flags, | |
603 const gchar *msg, | |
604 gpointer user_data) { | |
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
605 return; |
4489 | 606 } |
607 | |
608 static void gaim_log_handler (const gchar *domain, | |
609 GLogLevelFlags flags, | |
610 const gchar *msg, | |
611 gpointer user_data) { | |
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
612 gaim_debug(GAIM_DEBUG_MISC, "log", "%s - %s\n", domain, msg); |
4489 | 613 g_log_default_handler(domain, flags, msg, user_data); |
614 } | |
615 #endif /* _WIN32 */ | |
616 | |
617 /* FUCKING GET ME A TOWEL! */ | |
618 #ifdef _WIN32 | |
619 int gaim_main(int argc, char *argv[]) | |
620 #else | |
621 int main(int argc, char *argv[]) | |
622 #endif | |
623 { | |
624 int opt_acct = 0, opt_help = 0, opt_version = 0, opt_login = 0, opt_nologin = 0, dologin_ret = -1; | |
625 char *opt_user_arg = NULL, *opt_login_arg = NULL; | |
626 char *opt_session_arg = NULL; | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5032
diff
changeset
|
627 char *plugin_search_paths[3]; |
4489 | 628 #if HAVE_SIGNAL_H |
629 int sig_indx; /* for setting up signal catching */ | |
630 sigset_t sigset; | |
631 void (*prev_sig_disp)(); | |
632 #endif | |
633 int opt, opt_user = 0; | |
634 int i; | |
635 | |
636 struct option long_options[] = { | |
637 {"acct", no_argument, NULL, 'a'}, | |
638 /*{"away", optional_argument, NULL, 'w'}, */ | |
639 {"help", no_argument, NULL, 'h'}, | |
640 /*{"login", optional_argument, NULL, 'l'}, */ | |
641 {"loginwin", no_argument, NULL, 'n'}, | |
642 {"user", required_argument, NULL, 'u'}, | |
643 {"file", required_argument, NULL, 'f'}, | |
644 {"debug", no_argument, NULL, 'd'}, | |
645 {"version", no_argument, NULL, 'v'}, | |
646 {"session", required_argument, NULL, 's'}, | |
647 {0, 0, 0, 0} | |
648 }; | |
649 | |
650 #ifdef DEBUG | |
651 opt_debug = 1; | |
652 #endif | |
653 | |
654 #ifdef ENABLE_NLS | |
655 bindtextdomain(PACKAGE, LOCALEDIR); | |
656 bind_textdomain_codeset(PACKAGE, "UTF-8"); | |
657 textdomain(PACKAGE); | |
658 #endif | |
659 | |
660 #if HAVE_SIGNAL_H | |
661 /* Let's not violate any PLA's!!!! */ | |
662 /* jseymour: whatever the fsck that means */ | |
663 /* Robot101: for some reason things like gdm like to block * | |
664 * useful signals like SIGCHLD, so we unblock all the ones we * | |
665 * declare a handler for. thanks JSeymour and Vann. */ | |
666 if (sigemptyset(&sigset)) { | |
667 char errmsg[BUFSIZ]; | |
5435 | 668 snprintf(errmsg, BUFSIZ, "Warning: couldn't initialise empty signal set"); |
4489 | 669 perror(errmsg); |
670 } | |
671 for(sig_indx = 0; catch_sig_list[sig_indx] != -1; ++sig_indx) { | |
672 if((prev_sig_disp = signal(catch_sig_list[sig_indx], sighandler)) == SIG_ERR) { | |
673 char errmsg[BUFSIZ]; | |
5435 | 674 snprintf(errmsg, BUFSIZ, "Warning: couldn't set signal %d for catching", |
4489 | 675 catch_sig_list[sig_indx]); |
676 perror(errmsg); | |
677 } | |
678 if(sigaddset(&sigset, catch_sig_list[sig_indx])) { | |
679 char errmsg[BUFSIZ]; | |
5435 | 680 snprintf(errmsg, BUFSIZ, "Warning: couldn't include signal %d for unblocking", |
4489 | 681 catch_sig_list[sig_indx]); |
682 perror(errmsg); | |
683 } | |
684 } | |
685 for(sig_indx = 0; ignore_sig_list[sig_indx] != -1; ++sig_indx) { | |
686 if((prev_sig_disp = signal(ignore_sig_list[sig_indx], SIG_IGN)) == SIG_ERR) { | |
687 char errmsg[BUFSIZ]; | |
5435 | 688 snprintf(errmsg, BUFSIZ, "Warning: couldn't set signal %d to ignore", |
4489 | 689 ignore_sig_list[sig_indx]); |
690 perror(errmsg); | |
691 } | |
692 } | |
693 | |
694 if (sigprocmask(SIG_UNBLOCK, &sigset, NULL)) { | |
695 char errmsg[BUFSIZ]; | |
5435 | 696 snprintf(errmsg, BUFSIZ, "Warning: couldn't unblock signals"); |
4489 | 697 perror(errmsg); |
698 } | |
699 #endif | |
700 | |
701 for (i = 0; i < argc; i++) { | |
702 /* --login option */ | |
703 if (strstr(argv[i], "--l") == argv[i]) { | |
704 char *equals; | |
705 opt_login = 1; | |
706 if ((equals = strchr(argv[i], '=')) != NULL) { | |
707 /* --login=NAME */ | |
708 opt_login_arg = g_strdup(equals + 1); | |
709 if (strlen(opt_login_arg) == 0) { | |
710 g_free(opt_login_arg); | |
711 opt_login_arg = NULL; | |
712 } | |
713 } else if (i + 1 < argc && argv[i + 1][0] != '-') { | |
714 /* --login NAME */ | |
715 opt_login_arg = g_strdup(argv[i + 1]); | |
716 strcpy(argv[i + 1], " "); | |
717 } | |
718 strcpy(argv[i], " "); | |
719 } | |
720 /* -l option */ | |
721 else if (strstr(argv[i], "-l") == argv[i]) { | |
722 opt_login = 1; | |
723 if (strlen(argv[i]) > 2) { | |
724 /* -lNAME */ | |
725 opt_login_arg = g_strdup(argv[i] + 2); | |
726 } else if (i + 1 < argc && argv[i + 1][0] != '-') { | |
727 /* -l NAME */ | |
728 opt_login_arg = g_strdup(argv[i + 1]); | |
729 strcpy(argv[i + 1], " "); | |
730 } | |
731 strcpy(argv[i], " "); | |
732 } | |
733 /* --away option */ | |
734 else if (strstr(argv[i], "--aw") == argv[i]) { | |
735 char *equals; | |
736 opt_away = 1; | |
737 if ((equals = strchr(argv[i], '=')) != NULL) { | |
738 /* --away=MESG */ | |
739 opt_away_arg = g_strdup(equals + 1); | |
740 if (strlen(opt_away_arg) == 0) { | |
741 g_free(opt_away_arg); | |
742 opt_away_arg = NULL; | |
743 } | |
744 } else if (i + 1 < argc && argv[i + 1][0] != '-') { | |
745 /* --away MESG */ | |
746 opt_away_arg = g_strdup(argv[i + 1]); | |
747 strcpy(argv[i + 1], " "); | |
748 } | |
749 strcpy(argv[i], " "); | |
750 } | |
751 /* -w option */ | |
752 else if (strstr(argv[i], "-w") == argv[i]) { | |
753 opt_away = 1; | |
754 if (strlen(argv[i]) > 2) { | |
755 /* -wMESG */ | |
756 opt_away_arg = g_strdup(argv[i] + 2); | |
757 } else if (i + 1 < argc && argv[i + 1][0] != '-') { | |
758 /* -w MESG */ | |
759 opt_away_arg = g_strdup(argv[i + 1]); | |
760 strcpy(argv[i + 1], " "); | |
761 } | |
762 strcpy(argv[i], " "); | |
763 } | |
764 } | |
765 /* | |
766 if (opt_login) { | |
767 printf ("--login given with arg %s\n", | |
768 opt_login_arg ? opt_login_arg : "NULL"); | |
769 exit(0); | |
770 } | |
771 */ | |
772 | |
773 gtk_set_locale(); | |
774 gtk_init(&argc, &argv); | |
775 | |
776 /* scan command-line options */ | |
777 opterr = 1; | |
778 while ((opt = getopt_long(argc, argv, | |
779 #ifndef _WIN32 | |
780 "adhu:f:vns:", | |
781 #else | |
782 "adghu:f:vn", | |
783 #endif | |
784 long_options, NULL)) != -1) { | |
785 switch (opt) { | |
786 case 'u': /* set user */ | |
787 opt_user = 1; | |
788 opt_user_arg = g_strdup(optarg); | |
789 break; | |
790 case 'a': /* account editor */ | |
791 opt_acct = 1; | |
792 break; | |
793 case 'd': /* debug */ | |
794 opt_debug = 1; | |
795 break; | |
796 case 'f': | |
797 opt_rcfile_arg = g_strdup(optarg); | |
798 break; | |
799 case 's': /* use existing session ID */ | |
800 opt_session_arg = g_strdup(optarg); | |
801 break; | |
802 case 'v': /* version */ | |
803 opt_version = 1; | |
804 break; | |
805 case 'h': /* help */ | |
806 opt_help = 1; | |
807 break; | |
808 case 'n': /* don't autologin */ | |
809 opt_nologin = 1; | |
810 break; | |
811 #ifdef _WIN32 | |
812 case 'g': /* debug GTK and GLIB */ | |
813 opt_gdebug = 1; | |
814 break; | |
815 #endif | |
816 case '?': | |
817 default: | |
818 show_usage(1, argv[0]); | |
819 return 0; | |
820 break; | |
821 } | |
822 } | |
823 | |
824 #ifdef _WIN32 | |
825 /* We don't want a console window.. */ | |
826 /* | |
827 * Any calls to the glib logging functions, result in a call to AllocConsole(). | |
828 * ME and 98 will in such cases produce a console window (2000 not), despite | |
829 * being built as a windows app rather than a console app. So we should either | |
830 * ignore messages by setting dummy log handlers, or redirect messages. | |
831 * This requires setting handlers for all domains (any lib which uses g_logging). | |
832 */ | |
833 | |
834 g_log_set_handler (NULL, G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION, | |
835 (opt_gdebug ? gaim_log_handler : gaim_dummy_log_handler), | |
836 NULL); | |
837 g_log_set_handler ("Gdk", G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION, | |
838 (opt_gdebug ? gaim_log_handler : gaim_dummy_log_handler), | |
839 NULL); | |
840 g_log_set_handler ("Gtk", G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION, | |
841 (opt_gdebug ? gaim_log_handler : gaim_dummy_log_handler), | |
842 NULL); | |
843 g_log_set_handler ("GLib", G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION, | |
844 (opt_gdebug ? gaim_log_handler : gaim_dummy_log_handler), | |
845 NULL); | |
846 g_log_set_handler ("GModule", G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION, | |
847 (opt_gdebug ? gaim_log_handler : gaim_dummy_log_handler), | |
848 NULL); | |
849 g_log_set_handler ("GLib-GObject", G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION, | |
850 (opt_gdebug ? gaim_log_handler : gaim_dummy_log_handler), | |
851 NULL); | |
852 g_log_set_handler ("GThread", G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION, | |
853 (opt_gdebug ? gaim_log_handler : gaim_dummy_log_handler), | |
854 NULL); | |
855 | |
856 /* g_print also makes a call to AllocConsole(), therefore a handler needs to be | |
857 set here aswell */ | |
858 if(!opt_debug) | |
859 g_set_print_handler( gaim_dummy_print ); | |
860 | |
861 #endif | |
862 | |
863 /* show help message */ | |
864 if (opt_help) { | |
865 show_usage(0, argv[0]); | |
866 return 0; | |
867 } | |
868 /* show version message */ | |
869 if (opt_version) { | |
870 printf("Gaim %s\n",VERSION); | |
871 return 0; | |
872 } | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5032
diff
changeset
|
873 |
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
874 /* Set the UI operation structures. */ |
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
875 gaim_set_debug_ui_ops(gaim_get_gtk_debug_ui_ops()); |
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
876 gaim_set_win_ui_ops(gaim_get_gtk_window_ui_ops()); |
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
877 gaim_set_xfer_ui_ops(gaim_get_gtk_xfer_ui_ops()); |
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
878 gaim_set_blist_ui_ops(gaim_get_gtk_blist_ui_ops()); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
879 gaim_set_notify_ui_ops(gaim_get_gtk_notify_ui_ops()); |
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
880 |
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
881 |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5032
diff
changeset
|
882 plugin_search_paths[0] = LIBDIR; |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5032
diff
changeset
|
883 plugin_search_paths[1] = gaim_user_dir(); |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5032
diff
changeset
|
884 plugin_search_paths[2] = g_strdup_printf("%s/plugins", gaim_user_dir()); |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5032
diff
changeset
|
885 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5032
diff
changeset
|
886 gaim_plugins_set_search_paths(sizeof(plugin_search_paths) / |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5032
diff
changeset
|
887 sizeof(*plugin_search_paths), |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5032
diff
changeset
|
888 plugin_search_paths); |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5032
diff
changeset
|
889 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5032
diff
changeset
|
890 g_free(plugin_search_paths[2]); |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5032
diff
changeset
|
891 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5032
diff
changeset
|
892 gaim_plugins_probe(NULL); |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5032
diff
changeset
|
893 |
4489 | 894 #ifdef _WIN32 |
895 /* Various win32 initializations */ | |
896 wgaim_init(); | |
897 #endif | |
898 | |
899 load_prefs(); | |
900 core_main(); | |
5032
cb700c07ee07
[gaim-migrate @ 5375]
Christian Hammond <chipx86@chipx86.com>
parents:
5024
diff
changeset
|
901 load_pounces(); |
4489 | 902 ui_main(); |
903 | |
904 #ifdef USE_SM | |
905 session_init(argv[0], opt_session_arg); | |
906 #endif | |
907 if (opt_session_arg != NULL) { | |
908 g_free(opt_session_arg); | |
909 opt_session_arg = NULL; | |
910 }; | |
911 | |
912 /* set the default username */ | |
913 if (opt_user_arg != NULL) { | |
914 set_first_user(opt_user_arg); | |
915 g_free(opt_user_arg); | |
916 opt_user_arg = NULL; | |
917 } | |
918 | |
919 if (misc_options & OPT_MISC_DEBUG) | |
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
920 gaim_gtk_debug_window_show(); |
4489 | 921 |
922 static_proto_init(); | |
923 | |
924 /* deal with --login */ | |
925 if (opt_login) { | |
926 dologin_ret = dologin_named(opt_login_arg); | |
927 if (opt_login_arg != NULL) { | |
928 g_free(opt_login_arg); | |
929 opt_login_arg = NULL; | |
930 } | |
931 } | |
932 | |
933 if (!opt_acct && !opt_nologin && gaim_session == 0) | |
934 auto_login(); | |
935 | |
936 if (opt_acct) { | |
937 account_editor(NULL, NULL); | |
938 } else if ((dologin_ret == -1) && !connections) | |
939 show_login(); | |
940 | |
941 gtk_main(); | |
942 core_quit(); | |
4561 | 943 gaim_sound_quit(); |
4489 | 944 #ifdef _WIN32 |
945 wgaim_cleanup(); | |
946 #endif | |
947 return 0; | |
948 | |
949 } |