4 * Finch is the legal property of its developers, whose names are too numerous
5 * to list here. Please refer to the COPYRIGHT file distributed with this
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.
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.
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., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
28 #include "conversation.h"
31 #include "glibcompat.h"
38 #include "savedstatuses.h"
42 #include "whiteboard.h"
51 #include "package_revision.h"
56 FinchDebugUi
*ui
= finch_debug_ui_new();
57 purple_debug_set_ui(PURPLE_DEBUG_UI(ui
));
60 static GHashTable
*ui_info
= NULL
;
61 static GHashTable
*finch_ui_get_info(void)
63 if (ui_info
== NULL
) {
64 ui_info
= g_hash_table_new(g_str_hash
, g_str_equal
);
66 g_hash_table_insert(ui_info
, "name", (char*)_("Finch"));
67 g_hash_table_insert(ui_info
, "version", VERSION
);
68 g_hash_table_insert(ui_info
, "website", "https://pidgin.im");
69 g_hash_table_insert(ui_info
, "dev_website", "https://developer.pidgin.im");
70 g_hash_table_insert(ui_info
, "client_type", "console");
73 * This is the client key for "Finch." Please don't use this
74 * key for other applications. You can not specify a client
75 * key, in which case the default "libpurple" key will be used
77 g_hash_table_insert(ui_info
, "prpl-aim-clientkey", "ma18nmEklXMR7Cj_");
80 * This is the client key for "Pidgin." It is owned by the AIM
81 * account "markdoliner." Please don't use this key for other
82 * applications. You can either not specify a client key, in
83 * which case the default "libpurple" key will be used, or you
84 * can try to register your own at the AIM or ICQ web sites
85 * (although this functionality was removed at some point, it's
86 * possible it has been re-added). AOL's old key management
87 * page is http://developer.aim.com/manageKeys.jsp
89 * We used to have a Finch-specific devId/clientkey
90 * (ma19sqWV9ymU6UYc), but it stopped working, so we switched
93 g_hash_table_insert(ui_info
, "prpl-icq-clientkey", "ma1cSASNCKFtrdv9");
96 * This is the distid for Finch, given to us by AOL. Please
97 * don't use this for other applications. You can just not
98 * specify a distid and libpurple will use a default.
100 g_hash_table_insert(ui_info
, "prpl-aim-distid", GINT_TO_POINTER(1718));
101 g_hash_table_insert(ui_info
, "prpl-icq-distid", GINT_TO_POINTER(1552));
112 g_hash_table_destroy(ui_info
);
115 static PurpleCoreUiOps core_ops
=
130 static PurpleCoreUiOps
*
131 gnt_core_get_ui_ops(void)
137 init_libpurple(int argc
, char **argv
)
140 gboolean opt_nologin
= FALSE
;
141 gboolean opt_version
= FALSE
;
142 char *opt_config_dir_arg
= NULL
;
143 gboolean debug_enabled
= FALSE
;
144 GOptionContext
*context
;
146 GError
*error
= NULL
;
148 GOptionEntry option_entries
[] = {
150 G_OPTION_ARG_FILENAME
, &opt_config_dir_arg
,
151 _("use DIR for config files"), _("DIR")},
153 G_OPTION_ARG_NONE
, &opt_nologin
,
154 _("don't automatically login"), NULL
},
156 G_OPTION_ARG_NONE
, &opt_version
,
157 _("display the current version and exit"), NULL
},
161 bindtextdomain(PACKAGE
, PURPLE_LOCALEDIR
);
162 bind_textdomain_codeset(PACKAGE
, "UTF-8");
165 setlocale(LC_ALL
, "");
167 context
= g_option_context_new(NULL
);
168 g_option_context_set_summary(context
, DISPLAY_VERSION
);
169 g_option_context_add_main_entries(context
, option_entries
, PACKAGE
);
171 g_option_context_add_group(context
, purple_get_option_group());
172 g_option_context_add_group(context
, gplugin_get_option_group());
175 /* Handle Unicode filenames on Windows. See GOptionContext docs. */
176 args
= g_win32_get_command_line();
178 args
= g_strdupv(argv
);
181 if (!g_option_context_parse_strv(context
, &args
, &error
)) {
183 g_printerr(_("%s: %s\nTry `%s -h' for more information.\n"),
184 DISPLAY_VERSION
, error
->message
, argv
[0]);
185 g_clear_error(&error
);
191 /* show version message */
193 /* Translators may want to transliterate the name.
194 It is not to be translated. */
195 printf("%s %s (%s)\n", _("Finch"), DISPLAY_VERSION
, REVISION
);
199 /* set a user-specified config directory */
200 if (opt_config_dir_arg
!= NULL
) {
201 if (g_path_is_absolute(opt_config_dir_arg
)) {
202 purple_util_set_user_dir(opt_config_dir_arg
);
204 /* Make an absolute (if not canonical) path */
205 char *cwd
= g_get_current_dir();
206 char *path
= g_build_path(G_DIR_SEPARATOR_S
, cwd
, opt_config_dir_arg
, NULL
);
207 purple_util_set_user_dir(path
);
212 g_free(opt_config_dir_arg
);
216 * We're done piddling around with command line arguments.
220 /* We don't want debug-messages to show up and corrupt the display */
221 purple_debug_set_enabled(debug_enabled
);
223 purple_core_set_ui_ops(gnt_core_get_ui_ops());
224 purple_idle_set_ui_ops(finch_idle_get_ui_ops());
226 if (!purple_core_init(FINCH_UI
))
229 "Initialization of the Purple core failed. Dumping core.\n"
230 "Please report this!\n");
234 path
= g_build_filename(purple_data_dir(), "plugins", NULL
);
235 if (g_mkdir(path
, S_IRUSR
| S_IWUSR
| S_IXUSR
) != 0 && errno
!= EEXIST
)
236 fprintf(stderr
, "Couldn't create plugins dir\n");
237 purple_plugins_add_search_path(path
);
240 purple_plugins_add_search_path(FINCH_LIBDIR
);
241 purple_plugins_refresh();
243 /* TODO: should this be moved into finch_prefs_init() ? */
244 finch_prefs_update_old();
246 /* load plugins we had when we quit */
247 purple_plugins_load_saved("/finch/plugins/loaded");
251 /* Set all accounts to "offline" */
252 PurpleSavedStatus
*saved_status
;
254 /* If we've used this type+message before, lookup the transient status */
255 saved_status
= purple_savedstatus_find_transient_by_type_and_message(
256 PURPLE_STATUS_OFFLINE
, NULL
);
258 /* If this type+message is unique then create a new transient saved status */
259 if (saved_status
== NULL
)
260 saved_status
= purple_savedstatus_new(NULL
, PURPLE_STATUS_OFFLINE
);
262 /* Set the status for each account */
263 purple_savedstatus_activate(saved_status
);
267 /* Everything is good to go--sign on already */
268 if (!purple_prefs_get_bool("/purple/savedstatus/startup_current_status"))
269 purple_savedstatus_activate(purple_savedstatus_get_startup());
270 purple_accounts_restore_current_statuses();
276 gboolean
finch_start(int *argc
, char ***argv
)
278 /* Initialize the libpurple stuff */
279 if (!init_libpurple(*argc
, *argv
))