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