finch/libfinch.c

Thu, 22 Sep 2022 23:26:05 -0500

author
Gary Kramlich <grim@reaperworld.com>
date
Thu, 22 Sep 2022 23:26:05 -0500
changeset 41735
c9b476c9c9d2
parent 41730
f76b8bc39892
child 41806
b7a1aab4b3be
permissions
-rw-r--r--

Fix the purplepath unit tests by setting up the test ui and fixing the paths we validate

Testing Done:
Ran the tests.

Reviewed at https://reviews.imfreedom.org/r/1827/

39887
9c8f874c74a0 Clean up all of the license headers
Gary Kramlich <grim@reaperworld.com>
parents: 39411
diff changeset
1 /*
15931
716b5fac1895 Re-sed the copyright notices so they don't all talk about Purple.
Richard Laager <rlaager@pidgin.im>
parents: 15914
diff changeset
2 * finch
14620
90d599495d65 [gaim-migrate @ 17281]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14413
diff changeset
3 *
15931
716b5fac1895 Re-sed the copyright notices so they don't all talk about Purple.
Richard Laager <rlaager@pidgin.im>
parents: 15914
diff changeset
4 * Finch is the legal property of its developers, whose names are too numerous
14620
90d599495d65 [gaim-migrate @ 17281]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14413
diff changeset
5 * to list here. Please refer to the COPYRIGHT file distributed with this
90d599495d65 [gaim-migrate @ 17281]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14413
diff changeset
6 * source distribution.
90d599495d65 [gaim-migrate @ 17281]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14413
diff changeset
7 *
90d599495d65 [gaim-migrate @ 17281]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14413
diff changeset
8 * This program is free software; you can redistribute it and/or modify
90d599495d65 [gaim-migrate @ 17281]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14413
diff changeset
9 * it under the terms of the GNU General Public License as published by
90d599495d65 [gaim-migrate @ 17281]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14413
diff changeset
10 * the Free Software Foundation; either version 2 of the License, or
90d599495d65 [gaim-migrate @ 17281]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14413
diff changeset
11 * (at your option) any later version.
90d599495d65 [gaim-migrate @ 17281]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14413
diff changeset
12 *
90d599495d65 [gaim-migrate @ 17281]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14413
diff changeset
13 * This program is distributed in the hope that it will be useful,
90d599495d65 [gaim-migrate @ 17281]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14413
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
90d599495d65 [gaim-migrate @ 17281]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14413
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
90d599495d65 [gaim-migrate @ 17281]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14413
diff changeset
16 * GNU General Public License for more details.
90d599495d65 [gaim-migrate @ 17281]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14413
diff changeset
17 *
90d599495d65 [gaim-migrate @ 17281]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14413
diff changeset
18 * You should have received a copy of the GNU General Public License
90d599495d65 [gaim-migrate @ 17281]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14413
diff changeset
19 * along with this program; if not, write to the Free Software
19859
71d37b57eff2 The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 19733
diff changeset
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
14620
90d599495d65 [gaim-migrate @ 17281]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14413
diff changeset
21 */
39887
9c8f874c74a0 Clean up all of the license headers
Gary Kramlich <grim@reaperworld.com>
parents: 39411
diff changeset
22
40462
24ed25d87550 Fix some issues on macos that resulted from the internal.h cleanup
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
23 #include <errno.h>
24ed25d87550 Fix some issues on macos that resulted from the internal.h cleanup
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
24
40439
e9838d634d5e Make sure that internal.h can only be included by libpurple and split out some pieces to purpleprivate.h
Gary Kramlich <grim@reaperworld.com>
parents: 40359
diff changeset
25 #include <glib.h>
e9838d634d5e Make sure that internal.h can only be included by libpurple and split out some pieces to purpleprivate.h
Gary Kramlich <grim@reaperworld.com>
parents: 40359
diff changeset
26 #include <glib/gi18n-lib.h>
e9838d634d5e Make sure that internal.h can only be included by libpurple and split out some pieces to purpleprivate.h
Gary Kramlich <grim@reaperworld.com>
parents: 40359
diff changeset
27 #include <glib/gstdio.h>
e9838d634d5e Make sure that internal.h can only be included by libpurple and split out some pieces to purpleprivate.h
Gary Kramlich <grim@reaperworld.com>
parents: 40359
diff changeset
28
39372
43e3da39daf6 Include 'locale.h' directly in files which use setlocale()
Mike Ruprecht <cmaiku@gmail.com>
parents: 39121
diff changeset
29 #include <locale.h>
18273
e61c53184c52 #include reorganizations to allow compiling with glib < 2.8 using the
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 18075
diff changeset
30
40359
ca141ea93b83 Make all of finch use purple.h
Gary Kramlich <grim@reaperworld.com>
parents: 40337
diff changeset
31 #include <purple.h>
13852
1d3ae9f34d42 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
32
14045
12b8c2bfd3fb [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14028
diff changeset
33 #include "gntdebug.h"
40590
597b9c74296e Finch shouldn't include finch.h
Gary Kramlich <grim@reaperworld.com>
parents: 40462
diff changeset
34 #include "gntidle.h"
14045
12b8c2bfd3fb [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14028
diff changeset
35 #include "gntprefs.h"
13958
bd1c3bb3f33d [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13931
diff changeset
36 #include "gntui.h"
40616
064ff9f4150a Don't allow libraries to include their own global header files.
Gary Kramlich <grim@reaperworld.com>
parents: 40590
diff changeset
37 #include "libfinch.h"
13852
1d3ae9f34d42 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
38
14253
b63ebf84c42b This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents: 14078
diff changeset
39 #include "config.h"
27945
93ece0c6a9ad Add the MTN revision in the Pidgin About and finch --version dialogs.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27829
diff changeset
40 #include "package_revision.h"
14253
b63ebf84c42b This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents: 14078
diff changeset
41
19239
a6866f1419c4 Fix a memory leak from not freeing the ui-info hashtable on exit.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19124
diff changeset
42 static void
a6866f1419c4 Fix a memory leak from not freeing the ui-info hashtable on exit.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19124
diff changeset
43 finch_quit(void)
a6866f1419c4 Fix a memory leak from not freeing the ui-info hashtable on exit.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19124
diff changeset
44 {
35494
e631108a5464 Fix namespace issues in libgnt and finch.
Ankit Vani <a@nevitus.org>
parents: 35387
diff changeset
45 finch_ui_uninit();
19239
a6866f1419c4 Fix a memory leak from not freeing the ui-info hashtable on exit.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19124
diff changeset
46 }
a6866f1419c4 Fix a memory leak from not freeing the ui-info hashtable on exit.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19124
diff changeset
47
41723
124c95083fad Move PurpleCoreUiOps to struct intializers.
Gary Kramlich <grim@reaperworld.com>
parents: 41396
diff changeset
48 static PurpleCoreUiOps core_ops = {
124c95083fad Move PurpleCoreUiOps to struct intializers.
Gary Kramlich <grim@reaperworld.com>
parents: 41396
diff changeset
49 .ui_prefs_init = finch_prefs_init,
124c95083fad Move PurpleCoreUiOps to struct intializers.
Gary Kramlich <grim@reaperworld.com>
parents: 41396
diff changeset
50 .ui_init = finch_ui_init,
124c95083fad Move PurpleCoreUiOps to struct intializers.
Gary Kramlich <grim@reaperworld.com>
parents: 41396
diff changeset
51 .quit = finch_quit,
13852
1d3ae9f34d42 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
52 };
1d3ae9f34d42 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
53
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15878
diff changeset
54 static PurpleCoreUiOps *
22104
56970903b8e9 Probe for -Wstrict-prototypes to get some more warnings. I then cleaned up
Richard Laager <rlaager@pidgin.im>
parents: 21720
diff changeset
55 gnt_core_get_ui_ops(void)
13852
1d3ae9f34d42 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
56 {
1d3ae9f34d42 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
57 return &core_ops;
1d3ae9f34d42 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
58 }
1d3ae9f34d42 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
59
41127
cd297cfc56f3 Move debug command-line option to the UIs
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41120
diff changeset
60 static gboolean
cd297cfc56f3 Move debug command-line option to the UIs
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41120
diff changeset
61 start_with_debugwin(gpointer null)
cd297cfc56f3 Move debug command-line option to the UIs
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41120
diff changeset
62 {
cd297cfc56f3 Move debug command-line option to the UIs
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41120
diff changeset
63 finch_debug_window_show();
cd297cfc56f3 Move debug command-line option to the UIs
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41120
diff changeset
64 return FALSE;
cd297cfc56f3 Move debug command-line option to the UIs
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41120
diff changeset
65 }
cd297cfc56f3 Move debug command-line option to the UIs
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41120
diff changeset
66
41169
4103b3869912 Upgrade to gplugin 0.37.0
Gary Kramlich <grim@reaperworld.com>
parents: 41136
diff changeset
67 static void
4103b3869912 Upgrade to gplugin 0.37.0
Gary Kramlich <grim@reaperworld.com>
parents: 41136
diff changeset
68 finch_plugins_init(void) {
4103b3869912 Upgrade to gplugin 0.37.0
Gary Kramlich <grim@reaperworld.com>
parents: 41136
diff changeset
69 GPluginManager *manager = NULL;
4103b3869912 Upgrade to gplugin 0.37.0
Gary Kramlich <grim@reaperworld.com>
parents: 41136
diff changeset
70 gchar *path = NULL;
4103b3869912 Upgrade to gplugin 0.37.0
Gary Kramlich <grim@reaperworld.com>
parents: 41136
diff changeset
71
4103b3869912 Upgrade to gplugin 0.37.0
Gary Kramlich <grim@reaperworld.com>
parents: 41136
diff changeset
72 manager = gplugin_manager_get_default();
4103b3869912 Upgrade to gplugin 0.37.0
Gary Kramlich <grim@reaperworld.com>
parents: 41136
diff changeset
73
4103b3869912 Upgrade to gplugin 0.37.0
Gary Kramlich <grim@reaperworld.com>
parents: 41136
diff changeset
74 gplugin_manager_append_paths_from_environment(manager,
4103b3869912 Upgrade to gplugin 0.37.0
Gary Kramlich <grim@reaperworld.com>
parents: 41136
diff changeset
75 "FINCH_PLUGIN_PATH");
4103b3869912 Upgrade to gplugin 0.37.0
Gary Kramlich <grim@reaperworld.com>
parents: 41136
diff changeset
76
4103b3869912 Upgrade to gplugin 0.37.0
Gary Kramlich <grim@reaperworld.com>
parents: 41136
diff changeset
77 path = g_build_filename(purple_data_dir(), "plugins", NULL);
4103b3869912 Upgrade to gplugin 0.37.0
Gary Kramlich <grim@reaperworld.com>
parents: 41136
diff changeset
78 if(g_mkdir(path, S_IRUSR | S_IWUSR | S_IXUSR) != 0 && errno != EEXIST) {
4103b3869912 Upgrade to gplugin 0.37.0
Gary Kramlich <grim@reaperworld.com>
parents: 41136
diff changeset
79 fprintf(stderr, "Couldn't create plugins dir\n");
4103b3869912 Upgrade to gplugin 0.37.0
Gary Kramlich <grim@reaperworld.com>
parents: 41136
diff changeset
80 }
4103b3869912 Upgrade to gplugin 0.37.0
Gary Kramlich <grim@reaperworld.com>
parents: 41136
diff changeset
81 gplugin_manager_append_path(manager, path);
4103b3869912 Upgrade to gplugin 0.37.0
Gary Kramlich <grim@reaperworld.com>
parents: 41136
diff changeset
82 g_free(path);
4103b3869912 Upgrade to gplugin 0.37.0
Gary Kramlich <grim@reaperworld.com>
parents: 41136
diff changeset
83
4103b3869912 Upgrade to gplugin 0.37.0
Gary Kramlich <grim@reaperworld.com>
parents: 41136
diff changeset
84 gplugin_manager_append_path(manager, FINCH_LIBDIR);
4103b3869912 Upgrade to gplugin 0.37.0
Gary Kramlich <grim@reaperworld.com>
parents: 41136
diff changeset
85
4103b3869912 Upgrade to gplugin 0.37.0
Gary Kramlich <grim@reaperworld.com>
parents: 41136
diff changeset
86 purple_plugins_refresh();
4103b3869912 Upgrade to gplugin 0.37.0
Gary Kramlich <grim@reaperworld.com>
parents: 41136
diff changeset
87 }
4103b3869912 Upgrade to gplugin 0.37.0
Gary Kramlich <grim@reaperworld.com>
parents: 41136
diff changeset
88
13973
99603d7e2662 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13969
diff changeset
89 static int
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15878
diff changeset
90 init_libpurple(int argc, char **argv)
13852
1d3ae9f34d42 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
91 {
41396
2ef3d6eeffb3 Update purple_core_init to take a PurpleUiInfo instance
Gary Kramlich <grim@reaperworld.com>
parents: 41169
diff changeset
92 PurpleUiInfo *ui_info = NULL;
13973
99603d7e2662 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13969
diff changeset
93 gboolean opt_nologin = FALSE;
99603d7e2662 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13969
diff changeset
94 gboolean opt_version = FALSE;
41127
cd297cfc56f3 Move debug command-line option to the UIs
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41120
diff changeset
95 gboolean opt_debug = FALSE;
13973
99603d7e2662 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13969
diff changeset
96 char *opt_config_dir_arg = NULL;
38596
0504444b6c25 libfinch: Port to use GOptionContext for parsing command line args
Mike Ruprecht <cmaiku@gmail.com>
parents: 38421
diff changeset
97 GOptionContext *context;
0504444b6c25 libfinch: Port to use GOptionContext for parsing command line args
Mike Ruprecht <cmaiku@gmail.com>
parents: 38421
diff changeset
98 gchar **args;
0504444b6c25 libfinch: Port to use GOptionContext for parsing command line args
Mike Ruprecht <cmaiku@gmail.com>
parents: 38421
diff changeset
99 GError *error = NULL;
13852
1d3ae9f34d42 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
100
38596
0504444b6c25 libfinch: Port to use GOptionContext for parsing command line args
Mike Ruprecht <cmaiku@gmail.com>
parents: 38421
diff changeset
101 GOptionEntry option_entries[] = {
0504444b6c25 libfinch: Port to use GOptionContext for parsing command line args
Mike Ruprecht <cmaiku@gmail.com>
parents: 38421
diff changeset
102 {"config", 'c', 0,
0504444b6c25 libfinch: Port to use GOptionContext for parsing command line args
Mike Ruprecht <cmaiku@gmail.com>
parents: 38421
diff changeset
103 G_OPTION_ARG_FILENAME, &opt_config_dir_arg,
0504444b6c25 libfinch: Port to use GOptionContext for parsing command line args
Mike Ruprecht <cmaiku@gmail.com>
parents: 38421
diff changeset
104 _("use DIR for config files"), _("DIR")},
41127
cd297cfc56f3 Move debug command-line option to the UIs
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41120
diff changeset
105 {"debug", 'd', 0,
cd297cfc56f3 Move debug command-line option to the UIs
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41120
diff changeset
106 G_OPTION_ARG_NONE, &opt_debug,
cd297cfc56f3 Move debug command-line option to the UIs
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41120
diff changeset
107 _("open debug window on startup"), NULL},
38596
0504444b6c25 libfinch: Port to use GOptionContext for parsing command line args
Mike Ruprecht <cmaiku@gmail.com>
parents: 38421
diff changeset
108 {"nologin", 'n', 0,
0504444b6c25 libfinch: Port to use GOptionContext for parsing command line args
Mike Ruprecht <cmaiku@gmail.com>
parents: 38421
diff changeset
109 G_OPTION_ARG_NONE, &opt_nologin,
0504444b6c25 libfinch: Port to use GOptionContext for parsing command line args
Mike Ruprecht <cmaiku@gmail.com>
parents: 38421
diff changeset
110 _("don't automatically login"), NULL},
0504444b6c25 libfinch: Port to use GOptionContext for parsing command line args
Mike Ruprecht <cmaiku@gmail.com>
parents: 38421
diff changeset
111 {"version", 'v', 0,
0504444b6c25 libfinch: Port to use GOptionContext for parsing command line args
Mike Ruprecht <cmaiku@gmail.com>
parents: 38421
diff changeset
112 G_OPTION_ARG_NONE, &opt_version,
0504444b6c25 libfinch: Port to use GOptionContext for parsing command line args
Mike Ruprecht <cmaiku@gmail.com>
parents: 38421
diff changeset
113 _("display the current version and exit"), NULL},
0504444b6c25 libfinch: Port to use GOptionContext for parsing command line args
Mike Ruprecht <cmaiku@gmail.com>
parents: 38421
diff changeset
114 {NULL}
13973
99603d7e2662 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13969
diff changeset
115 };
99603d7e2662 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13969
diff changeset
116
35850
1abeda205d6c cross-win32: make dirs more flexible, add them to the config.h
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35494
diff changeset
117 bindtextdomain(PACKAGE, PURPLE_LOCALEDIR);
15098
e4f3eb20c4e3 [gaim-migrate @ 17819]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 15097
diff changeset
118 bind_textdomain_codeset(PACKAGE, "UTF-8");
e4f3eb20c4e3 [gaim-migrate @ 17819]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 15097
diff changeset
119 textdomain(PACKAGE);
e4f3eb20c4e3 [gaim-migrate @ 17819]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 15097
diff changeset
120
e4f3eb20c4e3 [gaim-migrate @ 17819]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 15097
diff changeset
121 setlocale(LC_ALL, "");
e4f3eb20c4e3 [gaim-migrate @ 17819]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 15097
diff changeset
122
38596
0504444b6c25 libfinch: Port to use GOptionContext for parsing command line args
Mike Ruprecht <cmaiku@gmail.com>
parents: 38421
diff changeset
123 context = g_option_context_new(NULL);
0504444b6c25 libfinch: Port to use GOptionContext for parsing command line args
Mike Ruprecht <cmaiku@gmail.com>
parents: 38421
diff changeset
124 g_option_context_set_summary(context, DISPLAY_VERSION);
0504444b6c25 libfinch: Port to use GOptionContext for parsing command line args
Mike Ruprecht <cmaiku@gmail.com>
parents: 38421
diff changeset
125 g_option_context_add_main_entries(context, option_entries, PACKAGE);
0504444b6c25 libfinch: Port to use GOptionContext for parsing command line args
Mike Ruprecht <cmaiku@gmail.com>
parents: 38421
diff changeset
126
38802
afb1c8302e49 The start of the libpurple option group
Gary Kramlich <grim@reaperworld.com>
parents: 38800
diff changeset
127 g_option_context_add_group(context, purple_get_option_group());
38800
8a2ea9672bcb Add the gplugin GOptionGroup to the GOptionContext of both Pidgin and Finch
Gary Kramlich <grim@reaperworld.com>
parents: 38647
diff changeset
128 g_option_context_add_group(context, gplugin_get_option_group());
8a2ea9672bcb Add the gplugin GOptionGroup to the GOptionContext of both Pidgin and Finch
Gary Kramlich <grim@reaperworld.com>
parents: 38647
diff changeset
129
38596
0504444b6c25 libfinch: Port to use GOptionContext for parsing command line args
Mike Ruprecht <cmaiku@gmail.com>
parents: 38421
diff changeset
130 #ifdef G_OS_WIN32
0504444b6c25 libfinch: Port to use GOptionContext for parsing command line args
Mike Ruprecht <cmaiku@gmail.com>
parents: 38421
diff changeset
131 /* Handle Unicode filenames on Windows. See GOptionContext docs. */
0504444b6c25 libfinch: Port to use GOptionContext for parsing command line args
Mike Ruprecht <cmaiku@gmail.com>
parents: 38421
diff changeset
132 args = g_win32_get_command_line();
0504444b6c25 libfinch: Port to use GOptionContext for parsing command line args
Mike Ruprecht <cmaiku@gmail.com>
parents: 38421
diff changeset
133 #else
0504444b6c25 libfinch: Port to use GOptionContext for parsing command line args
Mike Ruprecht <cmaiku@gmail.com>
parents: 38421
diff changeset
134 args = g_strdupv(argv);
0504444b6c25 libfinch: Port to use GOptionContext for parsing command line args
Mike Ruprecht <cmaiku@gmail.com>
parents: 38421
diff changeset
135 #endif
0504444b6c25 libfinch: Port to use GOptionContext for parsing command line args
Mike Ruprecht <cmaiku@gmail.com>
parents: 38421
diff changeset
136
0504444b6c25 libfinch: Port to use GOptionContext for parsing command line args
Mike Ruprecht <cmaiku@gmail.com>
parents: 38421
diff changeset
137 if (!g_option_context_parse_strv(context, &args, &error)) {
0504444b6c25 libfinch: Port to use GOptionContext for parsing command line args
Mike Ruprecht <cmaiku@gmail.com>
parents: 38421
diff changeset
138 g_strfreev(args);
0504444b6c25 libfinch: Port to use GOptionContext for parsing command line args
Mike Ruprecht <cmaiku@gmail.com>
parents: 38421
diff changeset
139 g_printerr(_("%s: %s\nTry `%s -h' for more information.\n"),
0504444b6c25 libfinch: Port to use GOptionContext for parsing command line args
Mike Ruprecht <cmaiku@gmail.com>
parents: 38421
diff changeset
140 DISPLAY_VERSION, error->message, argv[0]);
0504444b6c25 libfinch: Port to use GOptionContext for parsing command line args
Mike Ruprecht <cmaiku@gmail.com>
parents: 38421
diff changeset
141 g_clear_error(&error);
0504444b6c25 libfinch: Port to use GOptionContext for parsing command line args
Mike Ruprecht <cmaiku@gmail.com>
parents: 38421
diff changeset
142 return 1;
13973
99603d7e2662 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13969
diff changeset
143 }
99603d7e2662 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13969
diff changeset
144
38596
0504444b6c25 libfinch: Port to use GOptionContext for parsing command line args
Mike Ruprecht <cmaiku@gmail.com>
parents: 38421
diff changeset
145 g_strfreev(args);
0504444b6c25 libfinch: Port to use GOptionContext for parsing command line args
Mike Ruprecht <cmaiku@gmail.com>
parents: 38421
diff changeset
146
13973
99603d7e2662 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13969
diff changeset
147 /* show version message */
99603d7e2662 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13969
diff changeset
148 if (opt_version) {
17001
09ceabd6b129 Clarify the comments on the names for translators.
Richard Laager <rlaager@pidgin.im>
parents: 16987
diff changeset
149 /* Translators may want to transliterate the name.
09ceabd6b129 Clarify the comments on the names for translators.
Richard Laager <rlaager@pidgin.im>
parents: 16987
diff changeset
150 It is not to be translated. */
27945
93ece0c6a9ad Add the MTN revision in the Pidgin About and finch --version dialogs.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27829
diff changeset
151 printf("%s %s (%s)\n", _("Finch"), DISPLAY_VERSION, REVISION);
13973
99603d7e2662 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13969
diff changeset
152 return 0;
99603d7e2662 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13969
diff changeset
153 }
99603d7e2662 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13969
diff changeset
154
99603d7e2662 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13969
diff changeset
155 /* set a user-specified config directory */
99603d7e2662 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13969
diff changeset
156 if (opt_config_dir_arg != NULL) {
32785
5e08d5a41442 pidgin/finch: Make relative paths absolute with -c
Paul Aurich <darkrain42@pidgin.im>
parents: 31992
diff changeset
157 if (g_path_is_absolute(opt_config_dir_arg)) {
5e08d5a41442 pidgin/finch: Make relative paths absolute with -c
Paul Aurich <darkrain42@pidgin.im>
parents: 31992
diff changeset
158 purple_util_set_user_dir(opt_config_dir_arg);
5e08d5a41442 pidgin/finch: Make relative paths absolute with -c
Paul Aurich <darkrain42@pidgin.im>
parents: 31992
diff changeset
159 } else {
5e08d5a41442 pidgin/finch: Make relative paths absolute with -c
Paul Aurich <darkrain42@pidgin.im>
parents: 31992
diff changeset
160 /* Make an absolute (if not canonical) path */
5e08d5a41442 pidgin/finch: Make relative paths absolute with -c
Paul Aurich <darkrain42@pidgin.im>
parents: 31992
diff changeset
161 char *cwd = g_get_current_dir();
5e08d5a41442 pidgin/finch: Make relative paths absolute with -c
Paul Aurich <darkrain42@pidgin.im>
parents: 31992
diff changeset
162 char *path = g_build_path(G_DIR_SEPARATOR_S, cwd, opt_config_dir_arg, NULL);
5e08d5a41442 pidgin/finch: Make relative paths absolute with -c
Paul Aurich <darkrain42@pidgin.im>
parents: 31992
diff changeset
163 purple_util_set_user_dir(path);
5e08d5a41442 pidgin/finch: Make relative paths absolute with -c
Paul Aurich <darkrain42@pidgin.im>
parents: 31992
diff changeset
164 g_free(path);
5e08d5a41442 pidgin/finch: Make relative paths absolute with -c
Paul Aurich <darkrain42@pidgin.im>
parents: 31992
diff changeset
165 g_free(cwd);
5e08d5a41442 pidgin/finch: Make relative paths absolute with -c
Paul Aurich <darkrain42@pidgin.im>
parents: 31992
diff changeset
166 }
5e08d5a41442 pidgin/finch: Make relative paths absolute with -c
Paul Aurich <darkrain42@pidgin.im>
parents: 31992
diff changeset
167
14786
5dcd5187f20d [gaim-migrate @ 17478]
Richard Nelson <wabz@pidgin.im>
parents: 14647
diff changeset
168 g_free(opt_config_dir_arg);
13973
99603d7e2662 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13969
diff changeset
169 }
99603d7e2662 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13969
diff changeset
170
99603d7e2662 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13969
diff changeset
171 /*
99603d7e2662 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13969
diff changeset
172 * We're done piddling around with command line arguments.
99603d7e2662 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13969
diff changeset
173 * Fire up this baby.
99603d7e2662 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13969
diff changeset
174 */
99603d7e2662 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13969
diff changeset
175
16445
634622ab1c7b Call the migrate code from Finch.
Richard Laager <rlaager@pidgin.im>
parents: 16158
diff changeset
176 /* We don't want debug-messages to show up and corrupt the display */
41118
bd2767810a18 Initialize Finch debug handlers earlier
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41063
diff changeset
177 finch_debug_init_handler();
41127
cd297cfc56f3 Move debug command-line option to the UIs
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41120
diff changeset
178 if (opt_debug) {
cd297cfc56f3 Move debug command-line option to the UIs
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41120
diff changeset
179 g_timeout_add(0, start_with_debugwin, NULL);
cd297cfc56f3 Move debug command-line option to the UIs
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41120
diff changeset
180 }
13852
1d3ae9f34d42 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
181
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15878
diff changeset
182 purple_core_set_ui_ops(gnt_core_get_ui_ops());
41136
5397330041d6 Replace PurpleIdleUiOps with the PurpleIdleUi Interface
Gary Kramlich <grim@reaperworld.com>
parents: 41127
diff changeset
183 purple_idle_set_ui(finch_idle_new());
13852
1d3ae9f34d42 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
184
41730
f76b8bc39892 Use the id property of PurpleUiInfo as the directory name to use with XDG_CONFIG_HOME
Gary Kramlich <grim@reaperworld.com>
parents: 41723
diff changeset
185 ui_info = purple_ui_info_new("finch3", _("Finch"), VERSION,
41396
2ef3d6eeffb3 Update purple_core_init to take a PurpleUiInfo instance
Gary Kramlich <grim@reaperworld.com>
parents: 41169
diff changeset
186 "https://pidgin.im",
2ef3d6eeffb3 Update purple_core_init to take a PurpleUiInfo instance
Gary Kramlich <grim@reaperworld.com>
parents: 41169
diff changeset
187 "https://developer.pidgin.im", "console");
2ef3d6eeffb3 Update purple_core_init to take a PurpleUiInfo instance
Gary Kramlich <grim@reaperworld.com>
parents: 41169
diff changeset
188
2ef3d6eeffb3 Update purple_core_init to take a PurpleUiInfo instance
Gary Kramlich <grim@reaperworld.com>
parents: 41169
diff changeset
189 if (!purple_core_init(ui_info))
13852
1d3ae9f34d42 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
190 {
13973
99603d7e2662 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13969
diff changeset
191 fprintf(stderr,
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15878
diff changeset
192 "Initialization of the Purple core failed. Dumping core.\n"
13973
99603d7e2662 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13969
diff changeset
193 "Please report this!\n");
13852
1d3ae9f34d42 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
194 abort();
1d3ae9f34d42 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
195 }
1d3ae9f34d42 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
196
41169
4103b3869912 Upgrade to gplugin 0.37.0
Gary Kramlich <grim@reaperworld.com>
parents: 41136
diff changeset
197 finch_plugins_init();
13852
1d3ae9f34d42 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
198
19681
8399d8f69f1b 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 <datallah@pidgin.im>
parents: 19239
diff changeset
199 /* TODO: should this be moved into finch_prefs_init() ? */
16629
781a662d1fc3 Pref migration for finch.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 16593
diff changeset
200 finch_prefs_update_old();
13852
1d3ae9f34d42 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
201
1d3ae9f34d42 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
202 /* load plugins we had when we quit */
16478
19107605c565 Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@pidgin.im>
parents: 16158
diff changeset
203 purple_plugins_load_saved("/finch/plugins/loaded");
13852
1d3ae9f34d42 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
204
13973
99603d7e2662 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13969
diff changeset
205 if (opt_nologin)
99603d7e2662 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13969
diff changeset
206 {
99603d7e2662 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13969
diff changeset
207 /* Set all accounts to "offline" */
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15878
diff changeset
208 PurpleSavedStatus *saved_status;
13973
99603d7e2662 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13969
diff changeset
209
99603d7e2662 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13969
diff changeset
210 /* If we've used this type+message before, lookup the transient status */
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15878
diff changeset
211 saved_status = purple_savedstatus_find_transient_by_type_and_message(
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15878
diff changeset
212 PURPLE_STATUS_OFFLINE, NULL);
13973
99603d7e2662 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13969
diff changeset
213
99603d7e2662 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13969
diff changeset
214 /* If this type+message is unique then create a new transient saved status */
99603d7e2662 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13969
diff changeset
215 if (saved_status == NULL)
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15878
diff changeset
216 saved_status = purple_savedstatus_new(NULL, PURPLE_STATUS_OFFLINE);
13973
99603d7e2662 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13969
diff changeset
217
99603d7e2662 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13969
diff changeset
218 /* Set the status for each account */
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15878
diff changeset
219 purple_savedstatus_activate(saved_status);
13973
99603d7e2662 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13969
diff changeset
220 }
99603d7e2662 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13969
diff changeset
221 else
99603d7e2662 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13969
diff changeset
222 {
99603d7e2662 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13969
diff changeset
223 /* Everything is good to go--sign on already */
16478
19107605c565 Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@pidgin.im>
parents: 16158
diff changeset
224 if (!purple_prefs_get_bool("/purple/savedstatus/startup_current_status"))
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15878
diff changeset
225 purple_savedstatus_activate(purple_savedstatus_get_startup());
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15878
diff changeset
226 purple_accounts_restore_current_statuses();
13973
99603d7e2662 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13969
diff changeset
227 }
99603d7e2662 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13969
diff changeset
228
99603d7e2662 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13969
diff changeset
229 return 1;
13852
1d3ae9f34d42 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
230 }
1d3ae9f34d42 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
231
35494
e631108a5464 Fix namespace issues in libgnt and finch.
Ankit Vani <a@nevitus.org>
parents: 35387
diff changeset
232 gboolean finch_start(int *argc, char ***argv)
19239
a6866f1419c4 Fix a memory leak from not freeing the ui-info hashtable on exit.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19124
diff changeset
233 {
a6866f1419c4 Fix a memory leak from not freeing the ui-info hashtable on exit.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19124
diff changeset
234 /* Initialize the libpurple stuff */
a6866f1419c4 Fix a memory leak from not freeing the ui-info hashtable on exit.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19124
diff changeset
235 if (!init_libpurple(*argc, *argv))
a6866f1419c4 Fix a memory leak from not freeing the ui-info hashtable on exit.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19124
diff changeset
236 return FALSE;
31294
73607ab89c6f Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents: 30477
diff changeset
237
19239
a6866f1419c4 Fix a memory leak from not freeing the ui-info hashtable on exit.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19124
diff changeset
238 purple_blist_show();
a6866f1419c4 Fix a memory leak from not freeing the ui-info hashtable on exit.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19124
diff changeset
239 return TRUE;
a6866f1419c4 Fix a memory leak from not freeing the ui-info hashtable on exit.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19124
diff changeset
240 }

mercurial