Mercurial > pidgin.yaz
annotate finch/finch.c @ 31909:60c0790a1f97
!ChangeLog kartikmohta's patch. Refs #1131.
author | John Bailey <rekkanoryo@rekkanoryo.org> |
---|---|
date | Fri, 08 Apr 2011 01:22:46 +0000 |
parents | a8cc50c2279f |
children | d82d402c39fb da81195f635e |
rev | line source |
---|---|
15823 | 1 /** |
15871
66dff3dfdea6
Re-sed the copyright notices so they don't all talk about Purple.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
2 * finch |
15823 | 3 * |
15871
66dff3dfdea6
Re-sed the copyright notices so they don't all talk about Purple.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
4 * Finch is the legal property of its developers, whose names are too numerous |
15823 | 5 * to list here. Please refer to the COPYRIGHT file distributed with this |
6 * source distribution. | |
7 * | |
8 * This program is free software; you can redistribute it and/or modify | |
9 * it under the terms of the GNU General Public License as published by | |
10 * the Free Software Foundation; either version 2 of the License, or | |
11 * (at your option) any later version. | |
12 * | |
13 * This program is distributed in the hope that it will be useful, | |
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 * GNU General Public License for more details. | |
17 * | |
18 * You should have received a copy of the GNU General Public License | |
19 * along with this program; if not, write to the Free Software | |
19680
44b4e8bd759b
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19567
diff
changeset
|
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
15823 | 21 */ |
29152
259bbfb423d4
Fix all the remaining files for which internal.h doesn't end up being the first include.
Paul Aurich <paul@darkrain42.org>
parents:
28012
diff
changeset
|
22 #include <internal.h> |
18210
b8572b937c09
#include reorganizations to allow compiling with glib < 2.8 using the
Stu Tomlinson <stu@nosnilmot.com>
parents:
18013
diff
changeset
|
23 #include "finch.h" |
b8572b937c09
#include reorganizations to allow compiling with glib < 2.8 using the
Stu Tomlinson <stu@nosnilmot.com>
parents:
18013
diff
changeset
|
24 |
15823 | 25 #include "account.h" |
26 #include "conversation.h" | |
27 #include "core.h" | |
28 #include "debug.h" | |
29 #include "eventloop.h" | |
30 #include "ft.h" | |
31 #include "log.h" | |
32 #include "notify.h" | |
33 #include "prefs.h" | |
34 #include "prpl.h" | |
35 #include "pounce.h" | |
36 #include "savedstatuses.h" | |
37 #include "sound.h" | |
38 #include "status.h" | |
39 #include "util.h" | |
40 #include "whiteboard.h" | |
41 | |
42 #include "gntdebug.h" | |
43 #include "gntprefs.h" | |
44 #include "gntui.h" | |
45 #include "gntidle.h" | |
46 | |
47 #define _GNU_SOURCE | |
48 #include <getopt.h> | |
49 | |
50 #include "config.h" | |
28012
cc8f641d2fde
Add the MTN revision in the Pidgin About and finch --version dialogs.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27663
diff
changeset
|
51 #include "package_revision.h" |
15823 | 52 |
53 static void | |
22007
c38d72677c8a
Probe for -Wstrict-prototypes to get some more warnings. I then cleaned up
Richard Laager <rlaager@wiktel.com>
parents:
21669
diff
changeset
|
54 debug_init(void) |
15823 | 55 { |
56 finch_debug_init(); | |
57 purple_debug_set_ui_ops(finch_debug_get_ui_ops()); | |
58 } | |
59 | |
18293
5aae8608e1c6
UI info for finch and pidgin (finch guys probably want to take a look
Nathan Walp <nwalp@pidgin.im>
parents:
18210
diff
changeset
|
60 static GHashTable *ui_info = NULL; |
22007
c38d72677c8a
Probe for -Wstrict-prototypes to get some more warnings. I then cleaned up
Richard Laager <rlaager@wiktel.com>
parents:
21669
diff
changeset
|
61 static GHashTable *finch_ui_get_info(void) |
18293
5aae8608e1c6
UI info for finch and pidgin (finch guys probably want to take a look
Nathan Walp <nwalp@pidgin.im>
parents:
18210
diff
changeset
|
62 { |
18877
8988a205112b
Fix a memory leak from not freeing the ui-info hashtable on exit.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18828
diff
changeset
|
63 if (ui_info == NULL) { |
18293
5aae8608e1c6
UI info for finch and pidgin (finch guys probably want to take a look
Nathan Walp <nwalp@pidgin.im>
parents:
18210
diff
changeset
|
64 ui_info = g_hash_table_new(g_str_hash, g_str_equal); |
5aae8608e1c6
UI info for finch and pidgin (finch guys probably want to take a look
Nathan Walp <nwalp@pidgin.im>
parents:
18210
diff
changeset
|
65 |
5aae8608e1c6
UI info for finch and pidgin (finch guys probably want to take a look
Nathan Walp <nwalp@pidgin.im>
parents:
18210
diff
changeset
|
66 g_hash_table_insert(ui_info, "name", (char*)_("Finch")); |
5aae8608e1c6
UI info for finch and pidgin (finch guys probably want to take a look
Nathan Walp <nwalp@pidgin.im>
parents:
18210
diff
changeset
|
67 g_hash_table_insert(ui_info, "version", VERSION); |
23405
2ccda8e9046d
Added website and dev_website items to Finch's ui_get_info hash table
Evan Schoenberg <evan.s@dreskin.net>
parents:
22007
diff
changeset
|
68 g_hash_table_insert(ui_info, "website", "http://pidgin.im"); |
2ccda8e9046d
Added website and dev_website items to Finch's ui_get_info hash table
Evan Schoenberg <evan.s@dreskin.net>
parents:
22007
diff
changeset
|
69 g_hash_table_insert(ui_info, "dev_website", "http://developer.pidgin.im"); |
25837
a95eed74fdd7
Changed "type" to "client_type" for the hash value specifying client type
Marcus Lundblad <ml@update.uu.se>
parents:
25836
diff
changeset
|
70 g_hash_table_insert(ui_info, "client_type", "console"); |
27503
88ef8c38a639
Use a custom clientkey for AIM and ICQ for Pidgin and Finch
Mark Doliner <mark@kingant.net>
parents:
25837
diff
changeset
|
71 |
88ef8c38a639
Use a custom clientkey for AIM and ICQ for Pidgin and Finch
Mark Doliner <mark@kingant.net>
parents:
25837
diff
changeset
|
72 /* |
88ef8c38a639
Use a custom clientkey for AIM and ICQ for Pidgin and Finch
Mark Doliner <mark@kingant.net>
parents:
25837
diff
changeset
|
73 * This is the client key for "Finch." It is owned by the AIM |
88ef8c38a639
Use a custom clientkey for AIM and ICQ for Pidgin and Finch
Mark Doliner <mark@kingant.net>
parents:
25837
diff
changeset
|
74 * account "markdoliner." Please don't use this key for other |
88ef8c38a639
Use a custom clientkey for AIM and ICQ for Pidgin and Finch
Mark Doliner <mark@kingant.net>
parents:
25837
diff
changeset
|
75 * applications. You can either not specify a client key, in |
88ef8c38a639
Use a custom clientkey for AIM and ICQ for Pidgin and Finch
Mark Doliner <mark@kingant.net>
parents:
25837
diff
changeset
|
76 * which case the default "libpurple" key will be used, or you |
88ef8c38a639
Use a custom clientkey for AIM and ICQ for Pidgin and Finch
Mark Doliner <mark@kingant.net>
parents:
25837
diff
changeset
|
77 * can register for your own client key at |
88ef8c38a639
Use a custom clientkey for AIM and ICQ for Pidgin and Finch
Mark Doliner <mark@kingant.net>
parents:
25837
diff
changeset
|
78 * http://developer.aim.com/manageKeys.jsp |
88ef8c38a639
Use a custom clientkey for AIM and ICQ for Pidgin and Finch
Mark Doliner <mark@kingant.net>
parents:
25837
diff
changeset
|
79 */ |
88ef8c38a639
Use a custom clientkey for AIM and ICQ for Pidgin and Finch
Mark Doliner <mark@kingant.net>
parents:
25837
diff
changeset
|
80 g_hash_table_insert(ui_info, "prpl-aim-clientkey", "ma19sqWV9ymU6UYc"); |
88ef8c38a639
Use a custom clientkey for AIM and ICQ for Pidgin and Finch
Mark Doliner <mark@kingant.net>
parents:
25837
diff
changeset
|
81 g_hash_table_insert(ui_info, "prpl-icq-clientkey", "ma19sqWV9ymU6UYc"); |
27506
74e487f82f39
Oh, we don't need a special ui_info field for the AIM clientstring
Mark Doliner <mark@kingant.net>
parents:
27503
diff
changeset
|
82 |
74e487f82f39
Oh, we don't need a special ui_info field for the AIM clientstring
Mark Doliner <mark@kingant.net>
parents:
27503
diff
changeset
|
83 /* |
74e487f82f39
Oh, we don't need a special ui_info field for the AIM clientstring
Mark Doliner <mark@kingant.net>
parents:
27503
diff
changeset
|
84 * This is the distid for Finch, given to us by AOL. Please |
74e487f82f39
Oh, we don't need a special ui_info field for the AIM clientstring
Mark Doliner <mark@kingant.net>
parents:
27503
diff
changeset
|
85 * don't use this for other applications. You can just not |
74e487f82f39
Oh, we don't need a special ui_info field for the AIM clientstring
Mark Doliner <mark@kingant.net>
parents:
27503
diff
changeset
|
86 * specify a distid and libpurple will use a default. |
74e487f82f39
Oh, we don't need a special ui_info field for the AIM clientstring
Mark Doliner <mark@kingant.net>
parents:
27503
diff
changeset
|
87 */ |
74e487f82f39
Oh, we don't need a special ui_info field for the AIM clientstring
Mark Doliner <mark@kingant.net>
parents:
27503
diff
changeset
|
88 g_hash_table_insert(ui_info, "prpl-aim-distid", GINT_TO_POINTER(1552)); |
74e487f82f39
Oh, we don't need a special ui_info field for the AIM clientstring
Mark Doliner <mark@kingant.net>
parents:
27503
diff
changeset
|
89 g_hash_table_insert(ui_info, "prpl-icq-distid", GINT_TO_POINTER(1552)); |
18293
5aae8608e1c6
UI info for finch and pidgin (finch guys probably want to take a look
Nathan Walp <nwalp@pidgin.im>
parents:
18210
diff
changeset
|
90 } |
5aae8608e1c6
UI info for finch and pidgin (finch guys probably want to take a look
Nathan Walp <nwalp@pidgin.im>
parents:
18210
diff
changeset
|
91 |
5aae8608e1c6
UI info for finch and pidgin (finch guys probably want to take a look
Nathan Walp <nwalp@pidgin.im>
parents:
18210
diff
changeset
|
92 return ui_info; |
5aae8608e1c6
UI info for finch and pidgin (finch guys probably want to take a look
Nathan Walp <nwalp@pidgin.im>
parents:
18210
diff
changeset
|
93 } |
5aae8608e1c6
UI info for finch and pidgin (finch guys probably want to take a look
Nathan Walp <nwalp@pidgin.im>
parents:
18210
diff
changeset
|
94 |
18877
8988a205112b
Fix a memory leak from not freeing the ui-info hashtable on exit.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18828
diff
changeset
|
95 static void |
8988a205112b
Fix a memory leak from not freeing the ui-info hashtable on exit.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18828
diff
changeset
|
96 finch_quit(void) |
8988a205112b
Fix a memory leak from not freeing the ui-info hashtable on exit.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18828
diff
changeset
|
97 { |
8988a205112b
Fix a memory leak from not freeing the ui-info hashtable on exit.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18828
diff
changeset
|
98 gnt_ui_uninit(); |
8988a205112b
Fix a memory leak from not freeing the ui-info hashtable on exit.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18828
diff
changeset
|
99 if (ui_info) |
8988a205112b
Fix a memory leak from not freeing the ui-info hashtable on exit.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18828
diff
changeset
|
100 g_hash_table_destroy(ui_info); |
8988a205112b
Fix a memory leak from not freeing the ui-info hashtable on exit.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18828
diff
changeset
|
101 } |
8988a205112b
Fix a memory leak from not freeing the ui-info hashtable on exit.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18828
diff
changeset
|
102 |
15823 | 103 static PurpleCoreUiOps core_ops = |
104 { | |
105 finch_prefs_init, | |
106 debug_init, | |
107 gnt_ui_init, | |
18877
8988a205112b
Fix a memory leak from not freeing the ui-info hashtable on exit.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18828
diff
changeset
|
108 finch_quit, |
18293
5aae8608e1c6
UI info for finch and pidgin (finch guys probably want to take a look
Nathan Walp <nwalp@pidgin.im>
parents:
18210
diff
changeset
|
109 finch_ui_get_info, |
16677
30829e806dae
And finch is up to date
Gary Kramlich <grim@reaperworld.com>
parents:
16573
diff
changeset
|
110 |
30829e806dae
And finch is up to date
Gary Kramlich <grim@reaperworld.com>
parents:
16573
diff
changeset
|
111 /* padding */ |
30829e806dae
And finch is up to date
Gary Kramlich <grim@reaperworld.com>
parents:
16573
diff
changeset
|
112 NULL, |
30829e806dae
And finch is up to date
Gary Kramlich <grim@reaperworld.com>
parents:
16573
diff
changeset
|
113 NULL, |
30829e806dae
And finch is up to date
Gary Kramlich <grim@reaperworld.com>
parents:
16573
diff
changeset
|
114 NULL |
15823 | 115 }; |
116 | |
117 static PurpleCoreUiOps * | |
22007
c38d72677c8a
Probe for -Wstrict-prototypes to get some more warnings. I then cleaned up
Richard Laager <rlaager@wiktel.com>
parents:
21669
diff
changeset
|
118 gnt_core_get_ui_ops(void) |
15823 | 119 { |
120 return &core_ops; | |
121 } | |
122 | |
123 /* Anything IO-related is directly copied from gtkpurple's source tree */ | |
124 | |
125 #define FINCH_READ_COND (G_IO_IN | G_IO_HUP | G_IO_ERR) | |
126 #define FINCH_WRITE_COND (G_IO_OUT | G_IO_HUP | G_IO_ERR | G_IO_NVAL) | |
127 | |
128 typedef struct _PurpleGntIOClosure { | |
129 PurpleInputFunction function; | |
130 guint result; | |
131 gpointer data; | |
132 | |
133 } PurpleGntIOClosure; | |
134 | |
135 static void purple_gnt_io_destroy(gpointer data) | |
136 { | |
137 g_free(data); | |
138 } | |
139 | |
140 static gboolean purple_gnt_io_invoke(GIOChannel *source, GIOCondition condition, gpointer data) | |
141 { | |
142 PurpleGntIOClosure *closure = data; | |
143 PurpleInputCondition purple_cond = 0; | |
144 | |
145 if (condition & FINCH_READ_COND) | |
146 purple_cond |= PURPLE_INPUT_READ; | |
147 if (condition & FINCH_WRITE_COND) | |
148 purple_cond |= PURPLE_INPUT_WRITE; | |
149 | |
150 #if 0 | |
151 purple_debug(PURPLE_DEBUG_MISC, "gtk_eventloop", | |
152 "CLOSURE: callback for %d, fd is %d\n", | |
153 closure->result, g_io_channel_unix_get_fd(source)); | |
154 #endif | |
155 | |
156 #ifdef _WIN32 | |
157 if(! purple_cond) { | |
158 #if DEBUG | |
159 purple_debug_misc("gnt_eventloop", | |
160 "CLOSURE received GIOCondition of 0x%x, which does not" | |
161 " match 0x%x (READ) or 0x%x (WRITE)\n", | |
162 condition, FINCH_READ_COND, FINCH_WRITE_COND); | |
163 #endif /* DEBUG */ | |
164 | |
165 return TRUE; | |
166 } | |
167 #endif /* _WIN32 */ | |
168 | |
169 closure->function(closure->data, g_io_channel_unix_get_fd(source), | |
170 purple_cond); | |
171 | |
172 return TRUE; | |
173 } | |
174 | |
175 static guint gnt_input_add(gint fd, PurpleInputCondition condition, PurpleInputFunction function, | |
176 gpointer data) | |
177 { | |
178 PurpleGntIOClosure *closure = g_new0(PurpleGntIOClosure, 1); | |
179 GIOChannel *channel; | |
180 GIOCondition cond = 0; | |
181 | |
182 closure->function = function; | |
183 closure->data = data; | |
184 | |
185 if (condition & PURPLE_INPUT_READ) | |
186 cond |= FINCH_READ_COND; | |
187 if (condition & PURPLE_INPUT_WRITE) | |
188 cond |= FINCH_WRITE_COND; | |
189 | |
190 channel = g_io_channel_unix_new(fd); | |
191 closure->result = g_io_add_watch_full(channel, G_PRIORITY_DEFAULT, cond, | |
192 purple_gnt_io_invoke, closure, purple_gnt_io_destroy); | |
193 | |
194 g_io_channel_unref(channel); | |
195 return closure->result; | |
196 } | |
197 | |
198 static PurpleEventLoopUiOps eventloop_ops = | |
199 { | |
200 g_timeout_add, | |
201 g_source_remove, | |
202 gnt_input_add, | |
19567
b99a158ea85e
disapproval of revision 'c672802b647f1230fbd9b0edf383fb3d558cf719'
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19566
diff
changeset
|
203 g_source_remove, |
16677
30829e806dae
And finch is up to date
Gary Kramlich <grim@reaperworld.com>
parents:
16573
diff
changeset
|
204 NULL, /* input_get_error */ |
18013
58e82c3b697e
It's GLIB_CHECK_VERSION, not GLIB_VERSION_CHECK.
Richard Laager <rlaager@wiktel.com>
parents:
18009
diff
changeset
|
205 #if GLIB_CHECK_VERSION(2,14,0) |
18009
9ffa9af32854
Wire in g_timeout_add_seconds for Finch and nullclient as well.
Richard Laager <rlaager@wiktel.com>
parents:
17060
diff
changeset
|
206 g_timeout_add_seconds, |
9ffa9af32854
Wire in g_timeout_add_seconds for Finch and nullclient as well.
Richard Laager <rlaager@wiktel.com>
parents:
17060
diff
changeset
|
207 #else |
9ffa9af32854
Wire in g_timeout_add_seconds for Finch and nullclient as well.
Richard Laager <rlaager@wiktel.com>
parents:
17060
diff
changeset
|
208 NULL, |
9ffa9af32854
Wire in g_timeout_add_seconds for Finch and nullclient as well.
Richard Laager <rlaager@wiktel.com>
parents:
17060
diff
changeset
|
209 #endif |
16677
30829e806dae
And finch is up to date
Gary Kramlich <grim@reaperworld.com>
parents:
16573
diff
changeset
|
210 |
30829e806dae
And finch is up to date
Gary Kramlich <grim@reaperworld.com>
parents:
16573
diff
changeset
|
211 /* padding */ |
30829e806dae
And finch is up to date
Gary Kramlich <grim@reaperworld.com>
parents:
16573
diff
changeset
|
212 NULL, |
30829e806dae
And finch is up to date
Gary Kramlich <grim@reaperworld.com>
parents:
16573
diff
changeset
|
213 NULL, |
30829e806dae
And finch is up to date
Gary Kramlich <grim@reaperworld.com>
parents:
16573
diff
changeset
|
214 NULL |
15823 | 215 }; |
216 | |
217 static PurpleEventLoopUiOps * | |
218 gnt_eventloop_get_ui_ops(void) | |
219 { | |
220 return &eventloop_ops; | |
221 } | |
222 | |
223 /* This is mostly copied from gtkpurple's source tree */ | |
224 static void | |
225 show_usage(const char *name, gboolean terse) | |
226 { | |
227 char *text; | |
228 | |
229 if (terse) { | |
21030
3cc856ca2338
Add a --with-extraversion option to ./configure so packagers can fine tune
Stu Tomlinson <stu@nosnilmot.com>
parents:
20204
diff
changeset
|
230 text = g_strdup_printf(_("%s. Try `%s -h' for more information.\n"), DISPLAY_VERSION, name); |
15823 | 231 } else { |
232 text = g_strdup_printf(_("%s\n" | |
233 "Usage: %s [OPTION]...\n\n" | |
234 " -c, --config=DIR use DIR for config files\n" | |
25059
49d51dbcb799
Debug log is sent to stderr. Thanks to whoever noticed it in IRC the other day.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24852
diff
changeset
|
235 " -d, --debug print debugging messages to stderr\n" |
15823 | 236 " -h, --help display this help and exit\n" |
237 " -n, --nologin don't automatically login\n" | |
21030
3cc856ca2338
Add a --with-extraversion option to ./configure so packagers can fine tune
Stu Tomlinson <stu@nosnilmot.com>
parents:
20204
diff
changeset
|
238 " -v, --version display the current version and exit\n"), DISPLAY_VERSION, name); |
15823 | 239 } |
240 | |
241 purple_print_utf8_to_console(stdout, text); | |
242 g_free(text); | |
243 } | |
244 | |
245 static int | |
246 init_libpurple(int argc, char **argv) | |
247 { | |
248 char *path; | |
249 int opt; | |
250 gboolean opt_help = FALSE; | |
251 gboolean opt_nologin = FALSE; | |
252 gboolean opt_version = FALSE; | |
253 char *opt_config_dir_arg = NULL; | |
254 gboolean debug_enabled = FALSE; | |
30651
f30a02140f74
Create the ~/.purple/plugins directory on startup if it does not exist
Stu Tomlinson <stu@nosnilmot.com>
parents:
29771
diff
changeset
|
255 struct stat st; |
15823 | 256 |
257 struct option long_options[] = { | |
258 {"config", required_argument, NULL, 'c'}, | |
259 {"debug", no_argument, NULL, 'd'}, | |
260 {"help", no_argument, NULL, 'h'}, | |
261 {"nologin", no_argument, NULL, 'n'}, | |
262 {"version", no_argument, NULL, 'v'}, | |
263 {0, 0, 0, 0} | |
264 }; | |
265 | |
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 | |
276 /* scan command-line options */ | |
277 opterr = 1; | |
278 while ((opt = getopt_long(argc, argv, | |
279 #ifndef _WIN32 | |
24852
b2f8b1e1e7cc
Remove unused option, thanks to KuSh. Closes #7856.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23405
diff
changeset
|
280 "c:dhn::v", |
15823 | 281 #else |
282 "c:dhn::v", | |
283 #endif | |
284 long_options, NULL)) != -1) { | |
285 switch (opt) { | |
286 case 'c': /* config dir */ | |
287 g_free(opt_config_dir_arg); | |
288 opt_config_dir_arg = g_strdup(optarg); | |
289 break; | |
290 case 'd': /* debug */ | |
291 debug_enabled = TRUE; | |
292 break; | |
293 case 'h': /* help */ | |
294 opt_help = TRUE; | |
295 break; | |
296 case 'n': /* no autologin */ | |
297 opt_nologin = TRUE; | |
298 break; | |
299 case 'v': /* version */ | |
300 opt_version = TRUE; | |
301 break; | |
302 case '?': /* show terse help */ | |
303 default: | |
304 show_usage(argv[0], TRUE); | |
305 return 0; | |
306 break; | |
307 } | |
308 } | |
309 | |
310 /* show help message */ | |
311 if (opt_help) { | |
312 show_usage(argv[0], FALSE); | |
313 return 0; | |
314 } | |
315 /* show version message */ | |
316 if (opt_version) { | |
16954
816759ae9644
Clarify the comments on the names for translators.
Richard Laager <rlaager@wiktel.com>
parents:
16942
diff
changeset
|
317 /* Translators may want to transliterate the name. |
816759ae9644
Clarify the comments on the names for translators.
Richard Laager <rlaager@wiktel.com>
parents:
16942
diff
changeset
|
318 It is not to be translated. */ |
28012
cc8f641d2fde
Add the MTN revision in the Pidgin About and finch --version dialogs.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27663
diff
changeset
|
319 printf("%s %s (%s)\n", _("Finch"), DISPLAY_VERSION, REVISION); |
15823 | 320 return 0; |
321 } | |
322 | |
323 /* set a user-specified config directory */ | |
324 if (opt_config_dir_arg != NULL) { | |
325 purple_util_set_user_dir(opt_config_dir_arg); | |
326 g_free(opt_config_dir_arg); | |
327 } | |
328 | |
329 /* | |
330 * We're done piddling around with command line arguments. | |
331 * Fire up this baby. | |
332 */ | |
333 | |
16380
6c97924af83b
Call the migrate code from Finch.
Richard Laager <rlaager@wiktel.com>
parents:
16098
diff
changeset
|
334 /* We don't want debug-messages to show up and corrupt the display */ |
15823 | 335 purple_debug_set_enabled(debug_enabled); |
336 | |
16380
6c97924af83b
Call the migrate code from Finch.
Richard Laager <rlaager@wiktel.com>
parents:
16098
diff
changeset
|
337 /* If we're using a custom configuration directory, we |
6c97924af83b
Call the migrate code from Finch.
Richard Laager <rlaager@wiktel.com>
parents:
16098
diff
changeset
|
338 * do NOT want to migrate, or weird things will happen. */ |
6c97924af83b
Call the migrate code from Finch.
Richard Laager <rlaager@wiktel.com>
parents:
16098
diff
changeset
|
339 if (opt_config_dir_arg == NULL) |
6c97924af83b
Call the migrate code from Finch.
Richard Laager <rlaager@wiktel.com>
parents:
16098
diff
changeset
|
340 { |
6c97924af83b
Call the migrate code from Finch.
Richard Laager <rlaager@wiktel.com>
parents:
16098
diff
changeset
|
341 if (!purple_core_migrate()) |
6c97924af83b
Call the migrate code from Finch.
Richard Laager <rlaager@wiktel.com>
parents:
16098
diff
changeset
|
342 { |
6c97924af83b
Call the migrate code from Finch.
Richard Laager <rlaager@wiktel.com>
parents:
16098
diff
changeset
|
343 char *old = g_strconcat(purple_home_dir(), |
6c97924af83b
Call the migrate code from Finch.
Richard Laager <rlaager@wiktel.com>
parents:
16098
diff
changeset
|
344 G_DIR_SEPARATOR_S ".gaim", NULL); |
6c97924af83b
Call the migrate code from Finch.
Richard Laager <rlaager@wiktel.com>
parents:
16098
diff
changeset
|
345 char *text = g_strdup_printf(_( |
6c97924af83b
Call the migrate code from Finch.
Richard Laager <rlaager@wiktel.com>
parents:
16098
diff
changeset
|
346 "%s encountered errors migrating your settings " |
6c97924af83b
Call the migrate code from Finch.
Richard Laager <rlaager@wiktel.com>
parents:
16098
diff
changeset
|
347 "from %s to %s. Please investigate and complete the " |
16942
dd768c576ab2
disapproval of revision 'e9933d653551beb8b5f477dcf2c6bd1f3d239c55'
Richard Laager <rlaager@wiktel.com>
parents:
16940
diff
changeset
|
348 "migration by hand. Please report this error at http://developer.pidgin.im"), _("Finch"), |
16380
6c97924af83b
Call the migrate code from Finch.
Richard Laager <rlaager@wiktel.com>
parents:
16098
diff
changeset
|
349 old, purple_user_dir()); |
6c97924af83b
Call the migrate code from Finch.
Richard Laager <rlaager@wiktel.com>
parents:
16098
diff
changeset
|
350 |
6c97924af83b
Call the migrate code from Finch.
Richard Laager <rlaager@wiktel.com>
parents:
16098
diff
changeset
|
351 g_free(old); |
6c97924af83b
Call the migrate code from Finch.
Richard Laager <rlaager@wiktel.com>
parents:
16098
diff
changeset
|
352 |
6c97924af83b
Call the migrate code from Finch.
Richard Laager <rlaager@wiktel.com>
parents:
16098
diff
changeset
|
353 purple_print_utf8_to_console(stderr, text); |
6c97924af83b
Call the migrate code from Finch.
Richard Laager <rlaager@wiktel.com>
parents:
16098
diff
changeset
|
354 g_free(text); |
6c97924af83b
Call the migrate code from Finch.
Richard Laager <rlaager@wiktel.com>
parents:
16098
diff
changeset
|
355 |
6c97924af83b
Call the migrate code from Finch.
Richard Laager <rlaager@wiktel.com>
parents:
16098
diff
changeset
|
356 return 0; |
6c97924af83b
Call the migrate code from Finch.
Richard Laager <rlaager@wiktel.com>
parents:
16098
diff
changeset
|
357 } |
6c97924af83b
Call the migrate code from Finch.
Richard Laager <rlaager@wiktel.com>
parents:
16098
diff
changeset
|
358 } |
6c97924af83b
Call the migrate code from Finch.
Richard Laager <rlaager@wiktel.com>
parents:
16098
diff
changeset
|
359 |
15823 | 360 purple_core_set_ui_ops(gnt_core_get_ui_ops()); |
361 purple_eventloop_set_ui_ops(gnt_eventloop_get_ui_ops()); | |
362 purple_idle_set_ui_ops(finch_idle_get_ui_ops()); | |
363 | |
364 path = g_build_filename(purple_user_dir(), "plugins", NULL); | |
30651
f30a02140f74
Create the ~/.purple/plugins directory on startup if it does not exist
Stu Tomlinson <stu@nosnilmot.com>
parents:
29771
diff
changeset
|
365 if (!g_stat(path, &st)) |
f30a02140f74
Create the ~/.purple/plugins directory on startup if it does not exist
Stu Tomlinson <stu@nosnilmot.com>
parents:
29771
diff
changeset
|
366 g_mkdir(path, S_IRUSR | S_IWUSR | S_IXUSR); |
15823 | 367 purple_plugins_add_search_path(path); |
368 g_free(path); | |
369 | |
370 purple_plugins_add_search_path(LIBDIR); | |
371 | |
372 if (!purple_core_init(FINCH_UI)) | |
373 { | |
374 fprintf(stderr, | |
375 "Initialization of the Purple core failed. Dumping core.\n" | |
376 "Please report this!\n"); | |
377 abort(); | |
378 } | |
379 | |
380 /* TODO: Move blist loading into purple_blist_init() */ | |
381 purple_set_blist(purple_blist_new()); | |
382 purple_blist_load(); | |
383 | |
19520
098c04602065
Make a note about purple_prefs_load no longer needing to be called by the UI and update finch accordingly. There doesn't appear to be any negative effects of having the purple_prefs_load called twice.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
18877
diff
changeset
|
384 /* TODO: should this be moved into finch_prefs_init() ? */ |
16573
ac0d07c7fd90
Pref migration for finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16533
diff
changeset
|
385 finch_prefs_update_old(); |
15823 | 386 |
387 /* load plugins we had when we quit */ | |
16427
4999bbc52881
Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@gmail.com>
parents:
16098
diff
changeset
|
388 purple_plugins_load_saved("/finch/plugins/loaded"); |
15823 | 389 |
390 /* TODO: Move pounces loading into purple_pounces_init() */ | |
391 purple_pounces_load(); | |
392 | |
393 if (opt_nologin) | |
394 { | |
395 /* Set all accounts to "offline" */ | |
396 PurpleSavedStatus *saved_status; | |
397 | |
398 /* If we've used this type+message before, lookup the transient status */ | |
399 saved_status = purple_savedstatus_find_transient_by_type_and_message( | |
400 PURPLE_STATUS_OFFLINE, NULL); | |
401 | |
402 /* If this type+message is unique then create a new transient saved status */ | |
403 if (saved_status == NULL) | |
404 saved_status = purple_savedstatus_new(NULL, PURPLE_STATUS_OFFLINE); | |
405 | |
406 /* Set the status for each account */ | |
407 purple_savedstatus_activate(saved_status); | |
408 } | |
409 else | |
410 { | |
411 /* Everything is good to go--sign on already */ | |
16427
4999bbc52881
Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@gmail.com>
parents:
16098
diff
changeset
|
412 if (!purple_prefs_get_bool("/purple/savedstatus/startup_current_status")) |
15823 | 413 purple_savedstatus_activate(purple_savedstatus_get_startup()); |
414 purple_accounts_restore_current_statuses(); | |
415 } | |
416 | |
417 return 1; | |
418 } | |
419 | |
18877
8988a205112b
Fix a memory leak from not freeing the ui-info hashtable on exit.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18828
diff
changeset
|
420 static gboolean gnt_start(int *argc, char ***argv) |
8988a205112b
Fix a memory leak from not freeing the ui-info hashtable on exit.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18828
diff
changeset
|
421 { |
8988a205112b
Fix a memory leak from not freeing the ui-info hashtable on exit.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18828
diff
changeset
|
422 /* Initialize the libpurple stuff */ |
8988a205112b
Fix a memory leak from not freeing the ui-info hashtable on exit.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18828
diff
changeset
|
423 if (!init_libpurple(*argc, *argv)) |
8988a205112b
Fix a memory leak from not freeing the ui-info hashtable on exit.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18828
diff
changeset
|
424 return FALSE; |
31534
a8cc50c2279f
Remove trailing whitespace
Richard Laager <rlaager@wiktel.com>
parents:
30651
diff
changeset
|
425 |
18877
8988a205112b
Fix a memory leak from not freeing the ui-info hashtable on exit.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18828
diff
changeset
|
426 purple_blist_show(); |
8988a205112b
Fix a memory leak from not freeing the ui-info hashtable on exit.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18828
diff
changeset
|
427 return TRUE; |
8988a205112b
Fix a memory leak from not freeing the ui-info hashtable on exit.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18828
diff
changeset
|
428 } |
8988a205112b
Fix a memory leak from not freeing the ui-info hashtable on exit.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18828
diff
changeset
|
429 |
8988a205112b
Fix a memory leak from not freeing the ui-info hashtable on exit.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18828
diff
changeset
|
430 int main(int argc, char *argv[]) |
15823 | 431 { |
432 signal(SIGPIPE, SIG_IGN); | |
433 | |
19948
7dbeede6da97
Duplicate the fix from 33d699ec: do g_thread_init before using any other
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19680
diff
changeset
|
434 g_thread_init(NULL); |
7dbeede6da97
Duplicate the fix from 33d699ec: do g_thread_init before using any other
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19680
diff
changeset
|
435 |
18361
9b5b0cbde65f
Let's use g_set_prgname too.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18329
diff
changeset
|
436 g_set_prgname("Finch"); |
18329
477dd067bdc1
Use g_set_application_name here too.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18210
diff
changeset
|
437 g_set_application_name(_("Finch")); |
477dd067bdc1
Use g_set_application_name here too.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18210
diff
changeset
|
438 |
20204
de68625c4c04
applied changes from 1cb036aecbbe359226e69874379d39ce74c8daf6
Richard Laager <rlaager@wiktel.com>
parents:
19948
diff
changeset
|
439 if (gnt_start(&argc, &argv)) { |
de68625c4c04
applied changes from 1cb036aecbbe359226e69874379d39ce74c8daf6
Richard Laager <rlaager@wiktel.com>
parents:
19948
diff
changeset
|
440 gnt_main(); |
15823 | 441 |
442 #ifdef STANDALONE | |
20204
de68625c4c04
applied changes from 1cb036aecbbe359226e69874379d39ce74c8daf6
Richard Laager <rlaager@wiktel.com>
parents:
19948
diff
changeset
|
443 purple_core_quit(); |
15823 | 444 #endif |
20204
de68625c4c04
applied changes from 1cb036aecbbe359226e69874379d39ce74c8daf6
Richard Laager <rlaager@wiktel.com>
parents:
19948
diff
changeset
|
445 } |
15823 | 446 |
447 return 0; | |
448 } | |
449 |