Mercurial > pidgin
annotate finch/finch.c @ 24087:40a4e02027f4
shuffle some code around to make sure are using the right errno,
References #7032
| author | Ka-Hing Cheung <khc@hxbc.us> |
|---|---|
| date | Thu, 11 Sep 2008 04:19:37 +0000 |
| parents | 2ccda8e9046d |
| children | b2f8b1e1e7cc |
| rev | line source |
|---|---|
| 15822 | 1 /** |
|
15870
66dff3dfdea6
Re-sed the copyright notices so they don't all talk about Purple.
Richard Laager <rlaager@wiktel.com>
parents:
15822
diff
changeset
|
2 * finch |
| 15822 | 3 * |
|
15870
66dff3dfdea6
Re-sed the copyright notices so they don't all talk about Purple.
Richard Laager <rlaager@wiktel.com>
parents:
15822
diff
changeset
|
4 * Finch is the legal property of its developers, whose names are too numerous |
| 15822 | 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 | |
|
19681
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 |
| 15822 | 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 |
| 15822 | 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 | |
|
22007
c38d72677c8a
Probe for -Wstrict-prototypes to get some more warnings. I then cleaned up
Richard Laager <rlaager@wiktel.com>
parents:
21669
diff
changeset
|
52 debug_init(void) |
| 15822 | 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; |
|
22007
c38d72677c8a
Probe for -Wstrict-prototypes to get some more warnings. I then cleaned up
Richard Laager <rlaager@wiktel.com>
parents:
21669
diff
changeset
|
59 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
|
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); |
|
23403
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
|
66 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
|
67 g_hash_table_insert(ui_info, "dev_website", "http://developer.pidgin.im"); |
|
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
|
68 } |
|
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 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
|
71 } |
|
5aae8608e1c6
UI info for finch and pidgin (finch guys probably want to take a look
Nathan Walp <nwalp@pidgin.im>
parents:
18210
diff
changeset
|
72 |
|
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
|
73 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
|
74 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
|
75 { |
|
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 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
|
77 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
|
78 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
|
79 } |
|
8988a205112b
Fix a memory leak from not freeing the ui-info hashtable on exit.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18828
diff
changeset
|
80 |
| 15822 | 81 static PurpleCoreUiOps core_ops = |
| 82 { | |
| 83 finch_prefs_init, | |
| 84 debug_init, | |
| 85 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
|
86 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
|
87 finch_ui_get_info, |
|
16669
30829e806dae
And finch is up to date
Gary Kramlich <grim@reaperworld.com>
parents:
16565
diff
changeset
|
88 |
|
30829e806dae
And finch is up to date
Gary Kramlich <grim@reaperworld.com>
parents:
16565
diff
changeset
|
89 /* padding */ |
|
30829e806dae
And finch is up to date
Gary Kramlich <grim@reaperworld.com>
parents:
16565
diff
changeset
|
90 NULL, |
|
30829e806dae
And finch is up to date
Gary Kramlich <grim@reaperworld.com>
parents:
16565
diff
changeset
|
91 NULL, |
|
30829e806dae
And finch is up to date
Gary Kramlich <grim@reaperworld.com>
parents:
16565
diff
changeset
|
92 NULL |
| 15822 | 93 }; |
| 94 | |
| 95 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
|
96 gnt_core_get_ui_ops(void) |
| 15822 | 97 { |
| 98 return &core_ops; | |
| 99 } | |
| 100 | |
| 101 /* Anything IO-related is directly copied from gtkpurple's source tree */ | |
| 102 | |
| 103 #define FINCH_READ_COND (G_IO_IN | G_IO_HUP | G_IO_ERR) | |
| 104 #define FINCH_WRITE_COND (G_IO_OUT | G_IO_HUP | G_IO_ERR | G_IO_NVAL) | |
| 105 | |
| 106 typedef struct _PurpleGntIOClosure { | |
| 107 PurpleInputFunction function; | |
| 108 guint result; | |
| 109 gpointer data; | |
| 110 | |
| 111 } PurpleGntIOClosure; | |
| 112 | |
| 113 static void purple_gnt_io_destroy(gpointer data) | |
| 114 { | |
| 115 g_free(data); | |
| 116 } | |
| 117 | |
| 118 static gboolean purple_gnt_io_invoke(GIOChannel *source, GIOCondition condition, gpointer data) | |
| 119 { | |
| 120 PurpleGntIOClosure *closure = data; | |
| 121 PurpleInputCondition purple_cond = 0; | |
| 122 | |
| 123 if (condition & FINCH_READ_COND) | |
| 124 purple_cond |= PURPLE_INPUT_READ; | |
| 125 if (condition & FINCH_WRITE_COND) | |
| 126 purple_cond |= PURPLE_INPUT_WRITE; | |
| 127 | |
| 128 #if 0 | |
| 129 purple_debug(PURPLE_DEBUG_MISC, "gtk_eventloop", | |
| 130 "CLOSURE: callback for %d, fd is %d\n", | |
| 131 closure->result, g_io_channel_unix_get_fd(source)); | |
| 132 #endif | |
| 133 | |
| 134 #ifdef _WIN32 | |
| 135 if(! purple_cond) { | |
| 136 #if DEBUG | |
| 137 purple_debug_misc("gnt_eventloop", | |
| 138 "CLOSURE received GIOCondition of 0x%x, which does not" | |
| 139 " match 0x%x (READ) or 0x%x (WRITE)\n", | |
| 140 condition, FINCH_READ_COND, FINCH_WRITE_COND); | |
| 141 #endif /* DEBUG */ | |
| 142 | |
| 143 return TRUE; | |
| 144 } | |
| 145 #endif /* _WIN32 */ | |
| 146 | |
| 147 closure->function(closure->data, g_io_channel_unix_get_fd(source), | |
| 148 purple_cond); | |
| 149 | |
| 150 return TRUE; | |
| 151 } | |
| 152 | |
| 153 static guint gnt_input_add(gint fd, PurpleInputCondition condition, PurpleInputFunction function, | |
| 154 gpointer data) | |
| 155 { | |
| 156 PurpleGntIOClosure *closure = g_new0(PurpleGntIOClosure, 1); | |
| 157 GIOChannel *channel; | |
| 158 GIOCondition cond = 0; | |
| 159 | |
| 160 closure->function = function; | |
| 161 closure->data = data; | |
| 162 | |
| 163 if (condition & PURPLE_INPUT_READ) | |
| 164 cond |= FINCH_READ_COND; | |
| 165 if (condition & PURPLE_INPUT_WRITE) | |
| 166 cond |= FINCH_WRITE_COND; | |
| 167 | |
| 168 channel = g_io_channel_unix_new(fd); | |
| 169 closure->result = g_io_add_watch_full(channel, G_PRIORITY_DEFAULT, cond, | |
| 170 purple_gnt_io_invoke, closure, purple_gnt_io_destroy); | |
| 171 | |
| 172 g_io_channel_unref(channel); | |
| 173 return closure->result; | |
| 174 } | |
| 175 | |
| 176 static PurpleEventLoopUiOps eventloop_ops = | |
| 177 { | |
| 178 g_timeout_add, | |
| 179 g_source_remove, | |
| 180 gnt_input_add, | |
|
19567
b99a158ea85e
disapproval of revision 'c672802b647f1230fbd9b0edf383fb3d558cf719'
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19566
diff
changeset
|
181 g_source_remove, |
|
16669
30829e806dae
And finch is up to date
Gary Kramlich <grim@reaperworld.com>
parents:
16565
diff
changeset
|
182 NULL, /* input_get_error */ |
|
18013
58e82c3b697e
It's GLIB_CHECK_VERSION, not GLIB_VERSION_CHECK.
Richard Laager <rlaager@wiktel.com>
parents:
18009
diff
changeset
|
183 #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:
17049
diff
changeset
|
184 g_timeout_add_seconds, |
|
9ffa9af32854
Wire in g_timeout_add_seconds for Finch and nullclient as well.
Richard Laager <rlaager@wiktel.com>
parents:
17049
diff
changeset
|
185 #else |
|
9ffa9af32854
Wire in g_timeout_add_seconds for Finch and nullclient as well.
Richard Laager <rlaager@wiktel.com>
parents:
17049
diff
changeset
|
186 NULL, |
|
9ffa9af32854
Wire in g_timeout_add_seconds for Finch and nullclient as well.
Richard Laager <rlaager@wiktel.com>
parents:
17049
diff
changeset
|
187 #endif |
|
16669
30829e806dae
And finch is up to date
Gary Kramlich <grim@reaperworld.com>
parents:
16565
diff
changeset
|
188 |
|
30829e806dae
And finch is up to date
Gary Kramlich <grim@reaperworld.com>
parents:
16565
diff
changeset
|
189 /* padding */ |
|
30829e806dae
And finch is up to date
Gary Kramlich <grim@reaperworld.com>
parents:
16565
diff
changeset
|
190 NULL, |
|
30829e806dae
And finch is up to date
Gary Kramlich <grim@reaperworld.com>
parents:
16565
diff
changeset
|
191 NULL, |
|
30829e806dae
And finch is up to date
Gary Kramlich <grim@reaperworld.com>
parents:
16565
diff
changeset
|
192 NULL |
| 15822 | 193 }; |
| 194 | |
| 195 static PurpleEventLoopUiOps * | |
| 196 gnt_eventloop_get_ui_ops(void) | |
| 197 { | |
| 198 return &eventloop_ops; | |
| 199 } | |
| 200 | |
| 201 /* This is mostly copied from gtkpurple's source tree */ | |
| 202 static void | |
| 203 show_usage(const char *name, gboolean terse) | |
| 204 { | |
| 205 char *text; | |
| 206 | |
| 207 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
|
208 text = g_strdup_printf(_("%s. Try `%s -h' for more information.\n"), DISPLAY_VERSION, name); |
| 15822 | 209 } else { |
| 210 text = g_strdup_printf(_("%s\n" | |
| 211 "Usage: %s [OPTION]...\n\n" | |
| 212 " -c, --config=DIR use DIR for config files\n" | |
| 213 " -d, --debug print debugging messages to stdout\n" | |
| 214 " -h, --help display this help and exit\n" | |
| 215 " -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
|
216 " -v, --version display the current version and exit\n"), DISPLAY_VERSION, name); |
| 15822 | 217 } |
| 218 | |
| 219 purple_print_utf8_to_console(stdout, text); | |
| 220 g_free(text); | |
| 221 } | |
| 222 | |
| 223 static int | |
| 224 init_libpurple(int argc, char **argv) | |
| 225 { | |
| 226 char *path; | |
| 227 int opt; | |
| 228 gboolean opt_help = FALSE; | |
| 229 gboolean opt_nologin = FALSE; | |
| 230 gboolean opt_version = FALSE; | |
| 231 char *opt_config_dir_arg = NULL; | |
| 232 char *opt_session_arg = NULL; | |
| 233 gboolean debug_enabled = FALSE; | |
| 234 | |
| 235 struct option long_options[] = { | |
| 236 {"config", required_argument, NULL, 'c'}, | |
| 237 {"debug", no_argument, NULL, 'd'}, | |
| 238 {"help", no_argument, NULL, 'h'}, | |
| 239 {"nologin", no_argument, NULL, 'n'}, | |
| 240 {"session", required_argument, NULL, 's'}, | |
| 241 {"version", no_argument, NULL, 'v'}, | |
| 242 {0, 0, 0, 0} | |
| 243 }; | |
| 244 | |
| 245 #ifdef ENABLE_NLS | |
| 246 bindtextdomain(PACKAGE, LOCALEDIR); | |
| 247 bind_textdomain_codeset(PACKAGE, "UTF-8"); | |
| 248 textdomain(PACKAGE); | |
| 249 #endif | |
| 250 | |
| 251 #ifdef HAVE_SETLOCALE | |
| 252 setlocale(LC_ALL, ""); | |
| 253 #endif | |
| 254 | |
| 255 /* scan command-line options */ | |
| 256 opterr = 1; | |
| 257 while ((opt = getopt_long(argc, argv, | |
| 258 #ifndef _WIN32 | |
| 259 "c:dhn::s:v", | |
| 260 #else | |
| 261 "c:dhn::v", | |
| 262 #endif | |
| 263 long_options, NULL)) != -1) { | |
| 264 switch (opt) { | |
| 265 case 'c': /* config dir */ | |
| 266 g_free(opt_config_dir_arg); | |
| 267 opt_config_dir_arg = g_strdup(optarg); | |
| 268 break; | |
| 269 case 'd': /* debug */ | |
| 270 debug_enabled = TRUE; | |
| 271 break; | |
| 272 case 'h': /* help */ | |
| 273 opt_help = TRUE; | |
| 274 break; | |
| 275 case 'n': /* no autologin */ | |
| 276 opt_nologin = TRUE; | |
| 277 break; | |
| 278 case 's': /* use existing session ID */ | |
| 279 g_free(opt_session_arg); | |
| 280 opt_session_arg = g_strdup(optarg); | |
| 281 break; | |
| 282 case 'v': /* version */ | |
| 283 opt_version = TRUE; | |
| 284 break; | |
| 285 case '?': /* show terse help */ | |
| 286 default: | |
| 287 show_usage(argv[0], TRUE); | |
| 288 return 0; | |
| 289 break; | |
| 290 } | |
| 291 } | |
| 292 | |
| 293 /* show help message */ | |
| 294 if (opt_help) { | |
| 295 show_usage(argv[0], FALSE); | |
| 296 return 0; | |
| 297 } | |
| 298 /* show version message */ | |
| 299 if (opt_version) { | |
|
16943
816759ae9644
Clarify the comments on the names for translators.
Richard Laager <rlaager@wiktel.com>
parents:
16931
diff
changeset
|
300 /* Translators may want to transliterate the name. |
|
816759ae9644
Clarify the comments on the names for translators.
Richard Laager <rlaager@wiktel.com>
parents:
16931
diff
changeset
|
301 It is not to be translated. */ |
|
21030
3cc856ca2338
Add a --with-extraversion option to ./configure so packagers can fine tune
Stu Tomlinson <stu@nosnilmot.com>
parents:
20204
diff
changeset
|
302 printf("%s %s\n", _("Finch"), DISPLAY_VERSION); |
| 15822 | 303 return 0; |
| 304 } | |
| 305 | |
| 306 /* set a user-specified config directory */ | |
| 307 if (opt_config_dir_arg != NULL) { | |
| 308 purple_util_set_user_dir(opt_config_dir_arg); | |
| 309 g_free(opt_config_dir_arg); | |
| 310 } | |
| 311 | |
| 312 /* | |
| 313 * We're done piddling around with command line arguments. | |
| 314 * Fire up this baby. | |
| 315 */ | |
| 316 | |
|
16380
6c97924af83b
Call the migrate code from Finch.
Richard Laager <rlaager@wiktel.com>
parents:
16098
diff
changeset
|
317 /* We don't want debug-messages to show up and corrupt the display */ |
| 15822 | 318 purple_debug_set_enabled(debug_enabled); |
| 319 | |
|
16380
6c97924af83b
Call the migrate code from Finch.
Richard Laager <rlaager@wiktel.com>
parents:
16098
diff
changeset
|
320 /* 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
|
321 * 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
|
322 if (opt_config_dir_arg == NULL) |
|
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 if (!purple_core_migrate()) |
|
6c97924af83b
Call the migrate code from Finch.
Richard Laager <rlaager@wiktel.com>
parents:
16098
diff
changeset
|
325 { |
|
6c97924af83b
Call the migrate code from Finch.
Richard Laager <rlaager@wiktel.com>
parents:
16098
diff
changeset
|
326 char *old = g_strconcat(purple_home_dir(), |
|
6c97924af83b
Call the migrate code from Finch.
Richard Laager <rlaager@wiktel.com>
parents:
16098
diff
changeset
|
327 G_DIR_SEPARATOR_S ".gaim", NULL); |
|
6c97924af83b
Call the migrate code from Finch.
Richard Laager <rlaager@wiktel.com>
parents:
16098
diff
changeset
|
328 char *text = g_strdup_printf(_( |
|
6c97924af83b
Call the migrate code from Finch.
Richard Laager <rlaager@wiktel.com>
parents:
16098
diff
changeset
|
329 "%s encountered errors migrating your settings " |
|
6c97924af83b
Call the migrate code from Finch.
Richard Laager <rlaager@wiktel.com>
parents:
16098
diff
changeset
|
330 "from %s to %s. Please investigate and complete the " |
|
16931
dd768c576ab2
disapproval of revision 'e9933d653551beb8b5f477dcf2c6bd1f3d239c55'
Richard Laager <rlaager@wiktel.com>
parents:
16929
diff
changeset
|
331 "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
|
332 old, purple_user_dir()); |
|
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 g_free(old); |
|
6c97924af83b
Call the migrate code from Finch.
Richard Laager <rlaager@wiktel.com>
parents:
16098
diff
changeset
|
335 |
|
6c97924af83b
Call the migrate code from Finch.
Richard Laager <rlaager@wiktel.com>
parents:
16098
diff
changeset
|
336 purple_print_utf8_to_console(stderr, text); |
|
6c97924af83b
Call the migrate code from Finch.
Richard Laager <rlaager@wiktel.com>
parents:
16098
diff
changeset
|
337 g_free(text); |
|
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 return 0; |
|
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 } |
|
6c97924af83b
Call the migrate code from Finch.
Richard Laager <rlaager@wiktel.com>
parents:
16098
diff
changeset
|
342 |
| 15822 | 343 purple_core_set_ui_ops(gnt_core_get_ui_ops()); |
| 344 purple_eventloop_set_ui_ops(gnt_eventloop_get_ui_ops()); | |
| 345 purple_idle_set_ui_ops(finch_idle_get_ui_ops()); | |
| 346 | |
| 347 path = g_build_filename(purple_user_dir(), "plugins", NULL); | |
| 348 purple_plugins_add_search_path(path); | |
| 349 g_free(path); | |
| 350 | |
| 351 purple_plugins_add_search_path(LIBDIR); | |
| 352 | |
| 353 if (!purple_core_init(FINCH_UI)) | |
| 354 { | |
| 355 fprintf(stderr, | |
| 356 "Initialization of the Purple core failed. Dumping core.\n" | |
| 357 "Please report this!\n"); | |
| 358 abort(); | |
| 359 } | |
| 360 | |
| 361 /* TODO: Move blist loading into purple_blist_init() */ | |
| 362 purple_set_blist(purple_blist_new()); | |
| 363 purple_blist_load(); | |
| 364 | |
|
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
|
365 /* TODO: should this be moved into finch_prefs_init() ? */ |
|
16565
ac0d07c7fd90
Pref migration for finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16525
diff
changeset
|
366 finch_prefs_update_old(); |
| 15822 | 367 |
| 368 /* load plugins we had when we quit */ | |
|
16424
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"); |
| 15822 | 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 */ | |
|
16424
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")) |
| 15822 | 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[]) |
| 15822 | 412 { |
| 413 signal(SIGPIPE, SIG_IGN); | |
| 414 | |
|
19772
7dbeede6da97
Duplicate the fix from 33d699ec: do g_thread_init before using any other
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19681
diff
changeset
|
415 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:
19681
diff
changeset
|
416 |
|
18361
9b5b0cbde65f
Let's use g_set_prgname too.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18329
diff
changeset
|
417 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
|
418 #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
|
419 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
|
420 #endif |
|
18329
477dd067bdc1
Use g_set_application_name here too.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18210
diff
changeset
|
421 |
|
20204
de68625c4c04
applied changes from 1cb036aecbbe359226e69874379d39ce74c8daf6
Richard Laager <rlaager@wiktel.com>
parents:
19772
diff
changeset
|
422 if (gnt_start(&argc, &argv)) { |
|
de68625c4c04
applied changes from 1cb036aecbbe359226e69874379d39ce74c8daf6
Richard Laager <rlaager@wiktel.com>
parents:
19772
diff
changeset
|
423 gnt_main(); |
| 15822 | 424 |
| 425 #ifdef STANDALONE | |
|
20204
de68625c4c04
applied changes from 1cb036aecbbe359226e69874379d39ce74c8daf6
Richard Laager <rlaager@wiktel.com>
parents:
19772
diff
changeset
|
426 purple_core_quit(); |
| 15822 | 427 #endif |
|
20204
de68625c4c04
applied changes from 1cb036aecbbe359226e69874379d39ce74c8daf6
Richard Laager <rlaager@wiktel.com>
parents:
19772
diff
changeset
|
428 } |
| 15822 | 429 |
| 430 return 0; | |
| 431 } | |
| 432 |
