Mercurial > pidgin.yaz
annotate finch/finch.c @ 19462:105305518622
On login, get contacts from server using msim_get_contact_list().
This is part of #2658.
author | Jeffrey Connelly <jaconnel@calpoly.edu> |
---|---|
date | Mon, 27 Aug 2007 02:29:15 +0000 |
parents | 8988a205112b |
children | 098c04602065 |
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 | |
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
21 */ | |
18210
b8572b937c09
#include reorganizations to allow compiling with glib < 2.8 using the
Stu Tomlinson <stu@nosnilmot.com>
parents:
18013
diff
changeset
|
22 #include "finch.h" |
b8572b937c09
#include reorganizations to allow compiling with glib < 2.8 using the
Stu Tomlinson <stu@nosnilmot.com>
parents:
18013
diff
changeset
|
23 |
15823 | 24 #include "account.h" |
25 #include "conversation.h" | |
26 #include "core.h" | |
27 #include "debug.h" | |
28 #include "eventloop.h" | |
29 #include "ft.h" | |
30 #include "log.h" | |
31 #include "notify.h" | |
32 #include "prefs.h" | |
33 #include "prpl.h" | |
34 #include "pounce.h" | |
35 #include "savedstatuses.h" | |
36 #include "sound.h" | |
37 #include "status.h" | |
38 #include "util.h" | |
39 #include "whiteboard.h" | |
40 | |
41 #include "gntdebug.h" | |
42 #include "gntprefs.h" | |
43 #include "gntui.h" | |
44 #include "gntidle.h" | |
45 | |
46 #define _GNU_SOURCE | |
47 #include <getopt.h> | |
48 | |
49 #include "config.h" | |
50 | |
51 static void | |
52 debug_init() | |
53 { | |
54 finch_debug_init(); | |
55 purple_debug_set_ui_ops(finch_debug_get_ui_ops()); | |
56 } | |
57 | |
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
|
58 static GHashTable *ui_info = NULL; |
5aae8608e1c6
UI info for finch and pidgin (finch guys probably want to take a look
Nathan Walp <nwalp@pidgin.im>
parents:
18210
diff
changeset
|
59 static GHashTable *finch_ui_get_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
|
60 { |
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
|
61 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
|
62 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
|
63 |
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 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
|
65 g_hash_table_insert(ui_info, "version", VERSION); |
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 } |
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 |
5aae8608e1c6
UI info for finch and pidgin (finch guys probably want to take a look
Nathan Walp <nwalp@pidgin.im>
parents:
18210
diff
changeset
|
68 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
|
69 } |
5aae8608e1c6
UI info for finch and pidgin (finch guys probably want to take a look
Nathan Walp <nwalp@pidgin.im>
parents:
18210
diff
changeset
|
70 |
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
|
71 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
|
72 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
|
73 { |
8988a205112b
Fix a memory leak from not freeing the ui-info hashtable on exit.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18828
diff
changeset
|
74 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
|
75 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
|
76 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
|
77 } |
8988a205112b
Fix a memory leak from not freeing the ui-info hashtable on exit.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18828
diff
changeset
|
78 |
15823 | 79 static PurpleCoreUiOps core_ops = |
80 { | |
81 finch_prefs_init, | |
82 debug_init, | |
83 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
|
84 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
|
85 finch_ui_get_info, |
16677
30829e806dae
And finch is up to date
Gary Kramlich <grim@reaperworld.com>
parents:
16573
diff
changeset
|
86 |
30829e806dae
And finch is up to date
Gary Kramlich <grim@reaperworld.com>
parents:
16573
diff
changeset
|
87 /* padding */ |
30829e806dae
And finch is up to date
Gary Kramlich <grim@reaperworld.com>
parents:
16573
diff
changeset
|
88 NULL, |
30829e806dae
And finch is up to date
Gary Kramlich <grim@reaperworld.com>
parents:
16573
diff
changeset
|
89 NULL, |
30829e806dae
And finch is up to date
Gary Kramlich <grim@reaperworld.com>
parents:
16573
diff
changeset
|
90 NULL |
15823 | 91 }; |
92 | |
93 static PurpleCoreUiOps * | |
94 gnt_core_get_ui_ops() | |
95 { | |
96 return &core_ops; | |
97 } | |
98 | |
99 /* Anything IO-related is directly copied from gtkpurple's source tree */ | |
100 | |
101 #define FINCH_READ_COND (G_IO_IN | G_IO_HUP | G_IO_ERR) | |
102 #define FINCH_WRITE_COND (G_IO_OUT | G_IO_HUP | G_IO_ERR | G_IO_NVAL) | |
103 | |
104 typedef struct _PurpleGntIOClosure { | |
105 PurpleInputFunction function; | |
106 guint result; | |
107 gpointer data; | |
108 | |
109 } PurpleGntIOClosure; | |
110 | |
111 static void purple_gnt_io_destroy(gpointer data) | |
112 { | |
113 g_free(data); | |
114 } | |
115 | |
116 static gboolean purple_gnt_io_invoke(GIOChannel *source, GIOCondition condition, gpointer data) | |
117 { | |
118 PurpleGntIOClosure *closure = data; | |
119 PurpleInputCondition purple_cond = 0; | |
120 | |
121 if (condition & FINCH_READ_COND) | |
122 purple_cond |= PURPLE_INPUT_READ; | |
123 if (condition & FINCH_WRITE_COND) | |
124 purple_cond |= PURPLE_INPUT_WRITE; | |
125 | |
126 #if 0 | |
127 purple_debug(PURPLE_DEBUG_MISC, "gtk_eventloop", | |
128 "CLOSURE: callback for %d, fd is %d\n", | |
129 closure->result, g_io_channel_unix_get_fd(source)); | |
130 #endif | |
131 | |
132 #ifdef _WIN32 | |
133 if(! purple_cond) { | |
134 #if DEBUG | |
135 purple_debug_misc("gnt_eventloop", | |
136 "CLOSURE received GIOCondition of 0x%x, which does not" | |
137 " match 0x%x (READ) or 0x%x (WRITE)\n", | |
138 condition, FINCH_READ_COND, FINCH_WRITE_COND); | |
139 #endif /* DEBUG */ | |
140 | |
141 return TRUE; | |
142 } | |
143 #endif /* _WIN32 */ | |
144 | |
145 closure->function(closure->data, g_io_channel_unix_get_fd(source), | |
146 purple_cond); | |
147 | |
148 return TRUE; | |
149 } | |
150 | |
151 static guint gnt_input_add(gint fd, PurpleInputCondition condition, PurpleInputFunction function, | |
152 gpointer data) | |
153 { | |
154 PurpleGntIOClosure *closure = g_new0(PurpleGntIOClosure, 1); | |
155 GIOChannel *channel; | |
156 GIOCondition cond = 0; | |
157 | |
158 closure->function = function; | |
159 closure->data = data; | |
160 | |
161 if (condition & PURPLE_INPUT_READ) | |
162 cond |= FINCH_READ_COND; | |
163 if (condition & PURPLE_INPUT_WRITE) | |
164 cond |= FINCH_WRITE_COND; | |
165 | |
166 channel = g_io_channel_unix_new(fd); | |
167 closure->result = g_io_add_watch_full(channel, G_PRIORITY_DEFAULT, cond, | |
168 purple_gnt_io_invoke, closure, purple_gnt_io_destroy); | |
169 | |
170 g_io_channel_unref(channel); | |
171 return closure->result; | |
172 } | |
173 | |
174 static PurpleEventLoopUiOps eventloop_ops = | |
175 { | |
176 g_timeout_add, | |
177 g_source_remove, | |
178 gnt_input_add, | |
179 g_source_remove, | |
16677
30829e806dae
And finch is up to date
Gary Kramlich <grim@reaperworld.com>
parents:
16573
diff
changeset
|
180 NULL, /* input_get_error */ |
18013
58e82c3b697e
It's GLIB_CHECK_VERSION, not GLIB_VERSION_CHECK.
Richard Laager <rlaager@wiktel.com>
parents:
18009
diff
changeset
|
181 #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
|
182 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
|
183 #else |
9ffa9af32854
Wire in g_timeout_add_seconds for Finch and nullclient as well.
Richard Laager <rlaager@wiktel.com>
parents:
17060
diff
changeset
|
184 NULL, |
9ffa9af32854
Wire in g_timeout_add_seconds for Finch and nullclient as well.
Richard Laager <rlaager@wiktel.com>
parents:
17060
diff
changeset
|
185 #endif |
16677
30829e806dae
And finch is up to date
Gary Kramlich <grim@reaperworld.com>
parents:
16573
diff
changeset
|
186 |
30829e806dae
And finch is up to date
Gary Kramlich <grim@reaperworld.com>
parents:
16573
diff
changeset
|
187 /* padding */ |
30829e806dae
And finch is up to date
Gary Kramlich <grim@reaperworld.com>
parents:
16573
diff
changeset
|
188 NULL, |
30829e806dae
And finch is up to date
Gary Kramlich <grim@reaperworld.com>
parents:
16573
diff
changeset
|
189 NULL, |
30829e806dae
And finch is up to date
Gary Kramlich <grim@reaperworld.com>
parents:
16573
diff
changeset
|
190 NULL |
15823 | 191 }; |
192 | |
193 static PurpleEventLoopUiOps * | |
194 gnt_eventloop_get_ui_ops(void) | |
195 { | |
196 return &eventloop_ops; | |
197 } | |
198 | |
199 /* This is mostly copied from gtkpurple's source tree */ | |
200 static void | |
201 show_usage(const char *name, gboolean terse) | |
202 { | |
203 char *text; | |
204 | |
205 if (terse) { | |
206 text = g_strdup_printf(_("%s. Try `%s -h' for more information.\n"), VERSION, name); | |
207 } else { | |
208 text = g_strdup_printf(_("%s\n" | |
209 "Usage: %s [OPTION]...\n\n" | |
210 " -c, --config=DIR use DIR for config files\n" | |
211 " -d, --debug print debugging messages to stdout\n" | |
212 " -h, --help display this help and exit\n" | |
213 " -n, --nologin don't automatically login\n" | |
214 " -v, --version display the current version and exit\n"), VERSION, name); | |
215 } | |
216 | |
217 purple_print_utf8_to_console(stdout, text); | |
218 g_free(text); | |
219 } | |
220 | |
221 static int | |
222 init_libpurple(int argc, char **argv) | |
223 { | |
224 char *path; | |
225 int opt; | |
226 gboolean opt_help = FALSE; | |
227 gboolean opt_nologin = FALSE; | |
228 gboolean opt_version = FALSE; | |
229 char *opt_config_dir_arg = NULL; | |
230 char *opt_session_arg = NULL; | |
231 gboolean debug_enabled = FALSE; | |
232 | |
233 struct option long_options[] = { | |
234 {"config", required_argument, NULL, 'c'}, | |
235 {"debug", no_argument, NULL, 'd'}, | |
236 {"help", no_argument, NULL, 'h'}, | |
237 {"nologin", no_argument, NULL, 'n'}, | |
238 {"session", required_argument, NULL, 's'}, | |
239 {"version", no_argument, NULL, 'v'}, | |
240 {0, 0, 0, 0} | |
241 }; | |
242 | |
243 #ifdef ENABLE_NLS | |
244 bindtextdomain(PACKAGE, LOCALEDIR); | |
245 bind_textdomain_codeset(PACKAGE, "UTF-8"); | |
246 textdomain(PACKAGE); | |
247 #endif | |
248 | |
249 #ifdef HAVE_SETLOCALE | |
250 setlocale(LC_ALL, ""); | |
251 #endif | |
252 | |
253 /* scan command-line options */ | |
254 opterr = 1; | |
255 while ((opt = getopt_long(argc, argv, | |
256 #ifndef _WIN32 | |
257 "c:dhn::s:v", | |
258 #else | |
259 "c:dhn::v", | |
260 #endif | |
261 long_options, NULL)) != -1) { | |
262 switch (opt) { | |
263 case 'c': /* config dir */ | |
264 g_free(opt_config_dir_arg); | |
265 opt_config_dir_arg = g_strdup(optarg); | |
266 break; | |
267 case 'd': /* debug */ | |
268 debug_enabled = TRUE; | |
269 break; | |
270 case 'h': /* help */ | |
271 opt_help = TRUE; | |
272 break; | |
273 case 'n': /* no autologin */ | |
274 opt_nologin = TRUE; | |
275 break; | |
276 case 's': /* use existing session ID */ | |
277 g_free(opt_session_arg); | |
278 opt_session_arg = g_strdup(optarg); | |
279 break; | |
280 case 'v': /* version */ | |
281 opt_version = TRUE; | |
282 break; | |
283 case '?': /* show terse help */ | |
284 default: | |
285 show_usage(argv[0], TRUE); | |
286 return 0; | |
287 break; | |
288 } | |
289 } | |
290 | |
291 /* show help message */ | |
292 if (opt_help) { | |
293 show_usage(argv[0], FALSE); | |
294 return 0; | |
295 } | |
296 /* show version message */ | |
297 if (opt_version) { | |
16954
816759ae9644
Clarify the comments on the names for translators.
Richard Laager <rlaager@wiktel.com>
parents:
16942
diff
changeset
|
298 /* 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
|
299 It is not to be translated. */ |
16942
dd768c576ab2
disapproval of revision 'e9933d653551beb8b5f477dcf2c6bd1f3d239c55'
Richard Laager <rlaager@wiktel.com>
parents:
16940
diff
changeset
|
300 printf("%s %s\n", _("Finch"), VERSION); |
15823 | 301 return 0; |
302 } | |
303 | |
304 /* set a user-specified config directory */ | |
305 if (opt_config_dir_arg != NULL) { | |
306 purple_util_set_user_dir(opt_config_dir_arg); | |
307 g_free(opt_config_dir_arg); | |
308 } | |
309 | |
310 /* | |
311 * We're done piddling around with command line arguments. | |
312 * Fire up this baby. | |
313 */ | |
314 | |
16380
6c97924af83b
Call the migrate code from Finch.
Richard Laager <rlaager@wiktel.com>
parents:
16098
diff
changeset
|
315 /* We don't want debug-messages to show up and corrupt the display */ |
15823 | 316 purple_debug_set_enabled(debug_enabled); |
317 | |
16380
6c97924af83b
Call the migrate code from Finch.
Richard Laager <rlaager@wiktel.com>
parents:
16098
diff
changeset
|
318 /* 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
|
319 * 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
|
320 if (opt_config_dir_arg == NULL) |
6c97924af83b
Call the migrate code from Finch.
Richard Laager <rlaager@wiktel.com>
parents:
16098
diff
changeset
|
321 { |
6c97924af83b
Call the migrate code from Finch.
Richard Laager <rlaager@wiktel.com>
parents:
16098
diff
changeset
|
322 if (!purple_core_migrate()) |
6c97924af83b
Call the migrate code from Finch.
Richard Laager <rlaager@wiktel.com>
parents:
16098
diff
changeset
|
323 { |
6c97924af83b
Call the migrate code from Finch.
Richard Laager <rlaager@wiktel.com>
parents:
16098
diff
changeset
|
324 char *old = g_strconcat(purple_home_dir(), |
6c97924af83b
Call the migrate code from Finch.
Richard Laager <rlaager@wiktel.com>
parents:
16098
diff
changeset
|
325 G_DIR_SEPARATOR_S ".gaim", NULL); |
6c97924af83b
Call the migrate code from Finch.
Richard Laager <rlaager@wiktel.com>
parents:
16098
diff
changeset
|
326 char *text = g_strdup_printf(_( |
6c97924af83b
Call the migrate code from Finch.
Richard Laager <rlaager@wiktel.com>
parents:
16098
diff
changeset
|
327 "%s encountered errors migrating your settings " |
6c97924af83b
Call the migrate code from Finch.
Richard Laager <rlaager@wiktel.com>
parents:
16098
diff
changeset
|
328 "from %s to %s. Please investigate and complete the " |
16942
dd768c576ab2
disapproval of revision 'e9933d653551beb8b5f477dcf2c6bd1f3d239c55'
Richard Laager <rlaager@wiktel.com>
parents:
16940
diff
changeset
|
329 "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
|
330 old, purple_user_dir()); |
6c97924af83b
Call the migrate code from Finch.
Richard Laager <rlaager@wiktel.com>
parents:
16098
diff
changeset
|
331 |
6c97924af83b
Call the migrate code from Finch.
Richard Laager <rlaager@wiktel.com>
parents:
16098
diff
changeset
|
332 g_free(old); |
6c97924af83b
Call the migrate code from Finch.
Richard Laager <rlaager@wiktel.com>
parents:
16098
diff
changeset
|
333 |
6c97924af83b
Call the migrate code from Finch.
Richard Laager <rlaager@wiktel.com>
parents:
16098
diff
changeset
|
334 purple_print_utf8_to_console(stderr, text); |
6c97924af83b
Call the migrate code from Finch.
Richard Laager <rlaager@wiktel.com>
parents:
16098
diff
changeset
|
335 g_free(text); |
6c97924af83b
Call the migrate code from Finch.
Richard Laager <rlaager@wiktel.com>
parents:
16098
diff
changeset
|
336 |
6c97924af83b
Call the migrate code from Finch.
Richard Laager <rlaager@wiktel.com>
parents:
16098
diff
changeset
|
337 return 0; |
6c97924af83b
Call the migrate code from Finch.
Richard Laager <rlaager@wiktel.com>
parents:
16098
diff
changeset
|
338 } |
6c97924af83b
Call the migrate code from Finch.
Richard Laager <rlaager@wiktel.com>
parents:
16098
diff
changeset
|
339 } |
6c97924af83b
Call the migrate code from Finch.
Richard Laager <rlaager@wiktel.com>
parents:
16098
diff
changeset
|
340 |
15823 | 341 purple_core_set_ui_ops(gnt_core_get_ui_ops()); |
342 purple_eventloop_set_ui_ops(gnt_eventloop_get_ui_ops()); | |
343 purple_idle_set_ui_ops(finch_idle_get_ui_ops()); | |
344 | |
345 path = g_build_filename(purple_user_dir(), "plugins", NULL); | |
346 purple_plugins_add_search_path(path); | |
347 g_free(path); | |
348 | |
349 purple_plugins_add_search_path(LIBDIR); | |
350 | |
351 if (!purple_core_init(FINCH_UI)) | |
352 { | |
353 fprintf(stderr, | |
354 "Initialization of the Purple core failed. Dumping core.\n" | |
355 "Please report this!\n"); | |
356 abort(); | |
357 } | |
358 | |
359 /* TODO: Move blist loading into purple_blist_init() */ | |
360 purple_set_blist(purple_blist_new()); | |
361 purple_blist_load(); | |
362 | |
363 /* TODO: Move prefs loading into purple_prefs_init() */ | |
364 purple_prefs_load(); | |
365 purple_prefs_update_old(); | |
16573
ac0d07c7fd90
Pref migration for finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16533
diff
changeset
|
366 finch_prefs_update_old(); |
15823 | 367 |
368 /* 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
|
369 purple_plugins_load_saved("/finch/plugins/loaded"); |
15823 | 370 |
371 /* TODO: Move pounces loading into purple_pounces_init() */ | |
372 purple_pounces_load(); | |
373 | |
374 if (opt_nologin) | |
375 { | |
376 /* Set all accounts to "offline" */ | |
377 PurpleSavedStatus *saved_status; | |
378 | |
379 /* If we've used this type+message before, lookup the transient status */ | |
380 saved_status = purple_savedstatus_find_transient_by_type_and_message( | |
381 PURPLE_STATUS_OFFLINE, NULL); | |
382 | |
383 /* If this type+message is unique then create a new transient saved status */ | |
384 if (saved_status == NULL) | |
385 saved_status = purple_savedstatus_new(NULL, PURPLE_STATUS_OFFLINE); | |
386 | |
387 /* Set the status for each account */ | |
388 purple_savedstatus_activate(saved_status); | |
389 } | |
390 else | |
391 { | |
392 /* 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
|
393 if (!purple_prefs_get_bool("/purple/savedstatus/startup_current_status")) |
15823 | 394 purple_savedstatus_activate(purple_savedstatus_get_startup()); |
395 purple_accounts_restore_current_statuses(); | |
396 } | |
397 | |
398 return 1; | |
399 } | |
400 | |
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
|
401 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
|
402 { |
8988a205112b
Fix a memory leak from not freeing the ui-info hashtable on exit.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18828
diff
changeset
|
403 /* 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
|
404 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
|
405 return FALSE; |
8988a205112b
Fix a memory leak from not freeing the ui-info hashtable on exit.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18828
diff
changeset
|
406 |
8988a205112b
Fix a memory leak from not freeing the ui-info hashtable on exit.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18828
diff
changeset
|
407 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
|
408 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
|
409 } |
8988a205112b
Fix a memory leak from not freeing the ui-info hashtable on exit.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18828
diff
changeset
|
410 |
8988a205112b
Fix a memory leak from not freeing the ui-info hashtable on exit.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18828
diff
changeset
|
411 int main(int argc, char *argv[]) |
15823 | 412 { |
413 signal(SIGPIPE, SIG_IGN); | |
414 | |
18361
9b5b0cbde65f
Let's use g_set_prgname too.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18329
diff
changeset
|
415 g_set_prgname("Finch"); |
18828
f8b22b11a126
g_set_application_name requires glib 2.2 for finch
Richard Nelson <wabz@pidgin.im>
parents:
18456
diff
changeset
|
416 #if GLIB_CHECK_VERSION(2,2,0) |
18329
477dd067bdc1
Use g_set_application_name here too.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18210
diff
changeset
|
417 g_set_application_name(_("Finch")); |
18828
f8b22b11a126
g_set_application_name requires glib 2.2 for finch
Richard Nelson <wabz@pidgin.im>
parents:
18456
diff
changeset
|
418 #endif |
18329
477dd067bdc1
Use g_set_application_name here too.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18210
diff
changeset
|
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 gnt_init(); |
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 gnt_start(&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
|
423 |
15823 | 424 gnt_main(); |
425 | |
426 #ifdef STANDALONE | |
427 purple_core_quit(); | |
428 #endif | |
429 | |
430 return 0; | |
431 } | |
432 |