Mercurial > pidgin.yaz
annotate console/gntgaim.c @ 15241:7ce73985115a
[gaim-migrate @ 18030]
Fix a rather large oversight on my part: I wasn't allowing people
to set icons at all for protocols that didn't have a max icon
file size.
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Wed, 20 Dec 2006 09:35:24 +0000 |
parents | 1c4d0d3f4f5f |
children | d720141d70a2 |
rev | line source |
---|---|
14558
81650a27f253
[gaim-migrate @ 17281]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14351
diff
changeset
|
1 /** |
81650a27f253
[gaim-migrate @ 17281]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14351
diff
changeset
|
2 * gaim |
81650a27f253
[gaim-migrate @ 17281]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14351
diff
changeset
|
3 * |
81650a27f253
[gaim-migrate @ 17281]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14351
diff
changeset
|
4 * Gaim is the legal property of its developers, whose names are too numerous |
81650a27f253
[gaim-migrate @ 17281]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14351
diff
changeset
|
5 * to list here. Please refer to the COPYRIGHT file distributed with this |
81650a27f253
[gaim-migrate @ 17281]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14351
diff
changeset
|
6 * source distribution. |
81650a27f253
[gaim-migrate @ 17281]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14351
diff
changeset
|
7 * |
81650a27f253
[gaim-migrate @ 17281]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14351
diff
changeset
|
8 * This program is free software; you can redistribute it and/or modify |
81650a27f253
[gaim-migrate @ 17281]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14351
diff
changeset
|
9 * it under the terms of the GNU General Public License as published by |
81650a27f253
[gaim-migrate @ 17281]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14351
diff
changeset
|
10 * the Free Software Foundation; either version 2 of the License, or |
81650a27f253
[gaim-migrate @ 17281]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14351
diff
changeset
|
11 * (at your option) any later version. |
81650a27f253
[gaim-migrate @ 17281]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14351
diff
changeset
|
12 * |
81650a27f253
[gaim-migrate @ 17281]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14351
diff
changeset
|
13 * This program is distributed in the hope that it will be useful, |
81650a27f253
[gaim-migrate @ 17281]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14351
diff
changeset
|
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
81650a27f253
[gaim-migrate @ 17281]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14351
diff
changeset
|
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
81650a27f253
[gaim-migrate @ 17281]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14351
diff
changeset
|
16 * GNU General Public License for more details. |
81650a27f253
[gaim-migrate @ 17281]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14351
diff
changeset
|
17 * |
81650a27f253
[gaim-migrate @ 17281]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14351
diff
changeset
|
18 * You should have received a copy of the GNU General Public License |
81650a27f253
[gaim-migrate @ 17281]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14351
diff
changeset
|
19 * along with this program; if not, write to the Free Software |
81650a27f253
[gaim-migrate @ 17281]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14351
diff
changeset
|
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
81650a27f253
[gaim-migrate @ 17281]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14351
diff
changeset
|
21 */ |
13850
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
22 #include "account.h" |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
23 #include "conversation.h" |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
24 #include "core.h" |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
25 #include "debug.h" |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
26 #include "eventloop.h" |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
27 #include "ft.h" |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
28 #include "log.h" |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
29 #include "notify.h" |
15036 | 30 #include "prefix.h" |
13850
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
31 #include "prefs.h" |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
32 #include "prpl.h" |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
33 #include "pounce.h" |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
34 #include "savedstatuses.h" |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
35 #include "sound.h" |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
36 #include "status.h" |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
37 #include "util.h" |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
38 #include "whiteboard.h" |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
39 |
13983
b7a99d54a5a9
[gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13966
diff
changeset
|
40 #include "gntdebug.h" |
13850
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
41 #include "gntgaim.h" |
13983
b7a99d54a5a9
[gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13966
diff
changeset
|
42 #include "gntprefs.h" |
13896
a621329e8c85
[gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13869
diff
changeset
|
43 #include "gntui.h" |
13850
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
44 |
13911
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
45 #define _GNU_SOURCE |
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
46 #include <getopt.h> |
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
47 |
14191
009db0b357b5
This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
14016
diff
changeset
|
48 #include "config.h" |
009db0b357b5
This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
14016
diff
changeset
|
49 |
13983
b7a99d54a5a9
[gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13966
diff
changeset
|
50 static void |
b7a99d54a5a9
[gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13966
diff
changeset
|
51 debug_init() |
b7a99d54a5a9
[gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13966
diff
changeset
|
52 { |
b7a99d54a5a9
[gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13966
diff
changeset
|
53 gg_debug_init(); |
b7a99d54a5a9
[gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13966
diff
changeset
|
54 gaim_debug_set_ui_ops(gg_debug_get_ui_ops()); |
b7a99d54a5a9
[gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13966
diff
changeset
|
55 } |
13850
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
56 |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
57 static GaimCoreUiOps core_ops = |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
58 { |
13983
b7a99d54a5a9
[gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13966
diff
changeset
|
59 gg_prefs_init, |
b7a99d54a5a9
[gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13966
diff
changeset
|
60 debug_init, |
14847
d478f3853671
[gaim-migrate @ 17616]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14746
diff
changeset
|
61 gnt_ui_init, |
d478f3853671
[gaim-migrate @ 17616]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14746
diff
changeset
|
62 gnt_ui_uninit |
13850
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
63 }; |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
64 |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
65 static GaimCoreUiOps * |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
66 gnt_core_get_ui_ops() |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
67 { |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
68 return &core_ops; |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
69 } |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
70 |
13983
b7a99d54a5a9
[gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13966
diff
changeset
|
71 /* Anything IO-related is directly copied from gtkgaim's source tree */ |
b7a99d54a5a9
[gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13966
diff
changeset
|
72 |
13850
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
73 #define GAIM_GTK_READ_COND (G_IO_IN | G_IO_HUP | G_IO_ERR) |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
74 #define GAIM_GTK_WRITE_COND (G_IO_OUT | G_IO_HUP | G_IO_ERR | G_IO_NVAL) |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
75 |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
76 typedef struct _GaimGtkIOClosure { |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
77 GaimInputFunction function; |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
78 guint result; |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
79 gpointer data; |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
80 |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
81 } GaimGtkIOClosure; |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
82 |
14746
54ce6f592b01
[gaim-migrate @ 17503]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14724
diff
changeset
|
83 static void gaim_gnt_io_destroy(gpointer data) |
13850
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
84 { |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
85 g_free(data); |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
86 } |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
87 |
14746
54ce6f592b01
[gaim-migrate @ 17503]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14724
diff
changeset
|
88 static gboolean gaim_gnt_io_invoke(GIOChannel *source, GIOCondition condition, gpointer data) |
13850
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
89 { |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
90 GaimGtkIOClosure *closure = data; |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
91 GaimInputCondition gaim_cond = 0; |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
92 |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
93 if (condition & GAIM_GTK_READ_COND) |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
94 gaim_cond |= GAIM_INPUT_READ; |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
95 if (condition & GAIM_GTK_WRITE_COND) |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
96 gaim_cond |= GAIM_INPUT_WRITE; |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
97 |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
98 #if 0 |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
99 gaim_debug(GAIM_DEBUG_MISC, "gtk_eventloop", |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
100 "CLOSURE: callback for %d, fd is %d\n", |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
101 closure->result, g_io_channel_unix_get_fd(source)); |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
102 #endif |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
103 |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
104 #ifdef _WIN32 |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
105 if(! gaim_cond) { |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
106 #if DEBUG |
14746
54ce6f592b01
[gaim-migrate @ 17503]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14724
diff
changeset
|
107 gaim_debug_misc("gnt_eventloop", |
13850
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
108 "CLOSURE received GIOCondition of 0x%x, which does not" |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
109 " match 0x%x (READ) or 0x%x (WRITE)\n", |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
110 condition, GAIM_GTK_READ_COND, GAIM_GTK_WRITE_COND); |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
111 #endif /* DEBUG */ |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
112 |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
113 return TRUE; |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
114 } |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
115 #endif /* _WIN32 */ |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
116 |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
117 closure->function(closure->data, g_io_channel_unix_get_fd(source), |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
118 gaim_cond); |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
119 |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
120 return TRUE; |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
121 } |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
122 |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
123 static guint gnt_input_add(gint fd, GaimInputCondition condition, GaimInputFunction function, |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
124 gpointer data) |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
125 { |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
126 GaimGtkIOClosure *closure = g_new0(GaimGtkIOClosure, 1); |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
127 GIOChannel *channel; |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
128 GIOCondition cond = 0; |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
129 |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
130 closure->function = function; |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
131 closure->data = data; |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
132 |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
133 if (condition & GAIM_INPUT_READ) |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
134 cond |= GAIM_GTK_READ_COND; |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
135 if (condition & GAIM_INPUT_WRITE) |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
136 cond |= GAIM_GTK_WRITE_COND; |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
137 |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
138 channel = g_io_channel_unix_new(fd); |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
139 closure->result = g_io_add_watch_full(channel, G_PRIORITY_DEFAULT, cond, |
14746
54ce6f592b01
[gaim-migrate @ 17503]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14724
diff
changeset
|
140 gaim_gnt_io_invoke, closure, gaim_gnt_io_destroy); |
13850
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
141 |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
142 g_io_channel_unref(channel); |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
143 return closure->result; |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
144 } |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
145 |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
146 static GaimEventLoopUiOps eventloop_ops = |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
147 { |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
148 g_timeout_add, |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
149 (guint (*)(guint))g_source_remove, |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
150 gnt_input_add, |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
151 (guint (*)(guint))g_source_remove |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
152 }; |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
153 |
14198
c65ed4f6eea8
[gaim-migrate @ 16870]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14191
diff
changeset
|
154 static GaimEventLoopUiOps * |
13850
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
155 gnt_eventloop_get_ui_ops(void) |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
156 { |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
157 return &eventloop_ops; |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
158 } |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
159 |
15036 | 160 /* This is copied from gtkgaim */ |
161 static char * | |
162 gnt_find_binary_location(void *symbol, void *data) | |
163 { | |
164 static char *fullname = NULL; | |
165 static gboolean first = TRUE; | |
166 | |
167 char *argv0 = data; | |
168 struct stat st; | |
169 char *basebuf, *linkbuf, *fullbuf; | |
170 | |
171 if (!first) | |
172 /* We've already been through this. */ | |
173 return strdup(fullname); | |
174 | |
175 first = FALSE; | |
176 | |
177 if (!argv0) | |
178 return NULL; | |
179 | |
180 | |
181 basebuf = g_find_program_in_path(argv0); | |
182 | |
183 /* But we still need to deal with symbolic links */ | |
184 g_lstat(basebuf, &st); | |
185 while ((st.st_mode & S_IFLNK) == S_IFLNK) { | |
186 int written; | |
187 linkbuf = g_malloc(1024); | |
188 written = readlink(basebuf, linkbuf, 1024 - 1); | |
189 if (written == -1) | |
190 { | |
191 /* This really shouldn't happen, but do we | |
192 * need something better here? */ | |
193 g_free(linkbuf); | |
194 continue; | |
195 } | |
196 linkbuf[written] = '\0'; | |
197 if (linkbuf[0] == G_DIR_SEPARATOR) { | |
198 /* an absolute path */ | |
199 fullbuf = g_strdup(linkbuf); | |
200 } else { | |
201 char *dirbuf = g_path_get_dirname(basebuf); | |
202 /* a relative path */ | |
203 fullbuf = g_strdup_printf("%s%s%s", | |
204 dirbuf, G_DIR_SEPARATOR_S, | |
205 linkbuf); | |
206 g_free(dirbuf); | |
207 } | |
208 /* There's no memory leak here. Really! */ | |
209 g_free(linkbuf); | |
210 g_free(basebuf); | |
211 basebuf = fullbuf; | |
212 g_lstat(basebuf, &st); | |
213 } | |
214 | |
215 fullname = basebuf; | |
216 return strdup(fullname); | |
217 } | |
218 | |
219 | |
13850
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
220 /* This is mostly copied from gtkgaim's source tree */ |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
221 static void |
13911
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
222 show_usage(const char *name, gboolean terse) |
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
223 { |
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
224 char *text; |
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
225 |
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
226 if (terse) { |
14016
a4aee1adefcf
[gaim-migrate @ 16609]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14007
diff
changeset
|
227 text = g_strdup_printf(_("%s. Try `%s -h' for more information.\n"), VERSION, name); |
13911
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
228 } else { |
14016
a4aee1adefcf
[gaim-migrate @ 16609]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14007
diff
changeset
|
229 text = g_strdup_printf(_("%s\n" |
13911
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
230 "Usage: %s [OPTION]...\n\n" |
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
231 " -c, --config=DIR use DIR for config files\n" |
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
232 " -d, --debug print debugging messages to stdout\n" |
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
233 " -h, --help display this help and exit\n" |
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
234 " -n, --nologin don't automatically login\n" |
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
235 " -v, --version display the current version and exit\n"), VERSION, name); |
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
236 } |
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
237 |
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
238 gaim_print_utf8_to_console(stdout, text); |
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
239 g_free(text); |
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
240 } |
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
241 |
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
242 static int |
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
243 init_libgaim(int argc, char **argv) |
13850
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
244 { |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
245 char *path; |
13911
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
246 int opt; |
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
247 gboolean opt_help = FALSE; |
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
248 gboolean opt_nologin = FALSE; |
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
249 gboolean opt_version = FALSE; |
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
250 char *opt_config_dir_arg = NULL; |
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
251 char *opt_session_arg = NULL; |
13928 | 252 gboolean debug_enabled = FALSE; |
13850
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
253 |
13911
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
254 struct option long_options[] = { |
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
255 {"config", required_argument, NULL, 'c'}, |
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
256 {"debug", no_argument, NULL, 'd'}, |
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
257 {"help", no_argument, NULL, 'h'}, |
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
258 {"nologin", no_argument, NULL, 'n'}, |
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
259 {"session", required_argument, NULL, 's'}, |
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
260 {"version", no_argument, NULL, 'v'}, |
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
261 {0, 0, 0, 0} |
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
262 }; |
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
263 |
15036 | 264 gaim_br_set_locate_fallback_func(gnt_find_binary_location, argv[0]); |
265 | |
15037 | 266 #ifdef ENABLE_NLS |
267 bindtextdomain(PACKAGE, LOCALEDIR); | |
268 bind_textdomain_codeset(PACKAGE, "UTF-8"); | |
269 textdomain(PACKAGE); | |
270 #endif | |
271 | |
272 #ifdef HAVE_SETLOCALE | |
273 setlocale(LC_ALL, ""); | |
274 #endif | |
275 | |
13911
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
276 /* scan command-line options */ |
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
277 opterr = 1; |
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
278 while ((opt = getopt_long(argc, argv, |
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
279 #ifndef _WIN32 |
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
280 "c:dhn::s:v", |
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
281 #else |
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
282 "c:dhn::v", |
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
283 #endif |
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
284 long_options, NULL)) != -1) { |
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
285 switch (opt) { |
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
286 case 'c': /* config dir */ |
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
287 g_free(opt_config_dir_arg); |
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
288 opt_config_dir_arg = g_strdup(optarg); |
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
289 break; |
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
290 case 'd': /* debug */ |
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
291 debug_enabled = TRUE; |
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
292 break; |
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
293 case 'h': /* help */ |
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
294 opt_help = TRUE; |
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
295 break; |
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
296 case 'n': /* no autologin */ |
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
297 opt_nologin = TRUE; |
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
298 break; |
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
299 case 's': /* use existing session ID */ |
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
300 g_free(opt_session_arg); |
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
301 opt_session_arg = g_strdup(optarg); |
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
302 break; |
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
303 case 'v': /* version */ |
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
304 opt_version = TRUE; |
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
305 break; |
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
306 case '?': /* show terse help */ |
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
307 default: |
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
308 show_usage(argv[0], TRUE); |
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
309 return 0; |
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
310 break; |
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
311 } |
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
312 } |
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
313 |
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
314 /* show help message */ |
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
315 if (opt_help) { |
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
316 show_usage(argv[0], FALSE); |
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
317 return 0; |
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
318 } |
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
319 /* show version message */ |
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
320 if (opt_version) { |
14585 | 321 printf("gaim-text %s\n", VERSION); |
13911
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
322 return 0; |
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
323 } |
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
324 |
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
325 /* set a user-specified config directory */ |
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
326 if (opt_config_dir_arg != NULL) { |
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
327 gaim_util_set_user_dir(opt_config_dir_arg); |
14724
d9bd8925efcc
[gaim-migrate @ 17478]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14585
diff
changeset
|
328 g_free(opt_config_dir_arg); |
13911
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
329 } |
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
330 |
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
331 /* |
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
332 * We're done piddling around with command line arguments. |
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
333 * Fire up this baby. |
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
334 */ |
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
335 |
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
336 /* Because we don't want debug-messages to show up and corrup the display */ |
13927
9309d27d780c
[gaim-migrate @ 16447]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13911
diff
changeset
|
337 gaim_debug_set_enabled(debug_enabled); |
13850
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
338 |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
339 gaim_core_set_ui_ops(gnt_core_get_ui_ops()); |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
340 gaim_eventloop_set_ui_ops(gnt_eventloop_get_ui_ops()); |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
341 |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
342 path = g_build_filename(gaim_user_dir(), "plugins", NULL); |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
343 gaim_plugins_add_search_path(path); |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
344 g_free(path); |
13911
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
345 |
14007
9653b21bde9e
[gaim-migrate @ 16592]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13983
diff
changeset
|
346 gaim_plugins_add_search_path(LIBDIR); |
13850
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
347 |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
348 if (!gaim_core_init(GAIM_GNT_UI)) |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
349 { |
13911
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
350 fprintf(stderr, |
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
351 "Initialization of the Gaim core failed. Dumping core.\n" |
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
352 "Please report this!\n"); |
13850
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
353 abort(); |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
354 } |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
355 |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
356 /* TODO: Move blist loading into gaim_blist_init() */ |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
357 gaim_set_blist(gaim_blist_new()); |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
358 gaim_blist_load(); |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
359 |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
360 /* TODO: Move prefs loading into gaim_prefs_init() */ |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
361 gaim_prefs_load(); |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
362 gaim_prefs_update_old(); |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
363 |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
364 /* load plugins we had when we quit */ |
13911
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
365 gaim_plugins_load_saved("/gaim/gnt/plugins/loaded"); |
13850
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
366 |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
367 /* TODO: Move pounces loading into gaim_pounces_init() */ |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
368 gaim_pounces_load(); |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
369 |
13911
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
370 if (opt_nologin) |
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
371 { |
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
372 /* Set all accounts to "offline" */ |
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
373 GaimSavedStatus *saved_status; |
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
374 |
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
375 /* If we've used this type+message before, lookup the transient status */ |
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
376 saved_status = gaim_savedstatus_find_transient_by_type_and_message( |
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
377 GAIM_STATUS_OFFLINE, NULL); |
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
378 |
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
379 /* If this type+message is unique then create a new transient saved status */ |
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
380 if (saved_status == NULL) |
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
381 saved_status = gaim_savedstatus_new(NULL, GAIM_STATUS_OFFLINE); |
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
382 |
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
383 /* Set the status for each account */ |
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
384 gaim_savedstatus_activate(saved_status); |
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
385 } |
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
386 else |
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
387 { |
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
388 /* Everything is good to go--sign on already */ |
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
389 if (!gaim_prefs_get_bool("/core/savedstatus/startup_current_status")) |
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
390 gaim_savedstatus_activate(gaim_savedstatus_get_startup()); |
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
391 gaim_accounts_restore_current_statuses(); |
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
392 } |
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
393 |
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
394 return 1; |
13850
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
395 } |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
396 |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
397 int main(int argc, char **argv) |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
398 { |
13864
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13857
diff
changeset
|
399 /* XXX: Don't puke */ |
13869
5642f4658b59
[gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13864
diff
changeset
|
400 freopen(".error", "w", stderr); |
13864
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13857
diff
changeset
|
401 |
14746
54ce6f592b01
[gaim-migrate @ 17503]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14724
diff
changeset
|
402 signal(SIGPIPE, SIG_IGN); |
54ce6f592b01
[gaim-migrate @ 17503]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14724
diff
changeset
|
403 |
13850
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
404 /* Initialize the libgaim stuff */ |
13911
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
405 if (!init_libgaim(argc, argv)) |
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
406 return 0; |
13850
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
407 |
14847
d478f3853671
[gaim-migrate @ 17616]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14746
diff
changeset
|
408 gaim_blist_show(); |
d478f3853671
[gaim-migrate @ 17616]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14746
diff
changeset
|
409 gnt_main(); |
d478f3853671
[gaim-migrate @ 17616]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14746
diff
changeset
|
410 |
13966
80cbf6c2d562
[gaim-migrate @ 16522]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13928
diff
changeset
|
411 #ifdef STANDALONE |
13850
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
412 gaim_core_quit(); |
13966
80cbf6c2d562
[gaim-migrate @ 16522]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13928
diff
changeset
|
413 #endif |
13850
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
414 |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
415 return 0; |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
416 } |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
417 |