libpurple/core.c

Tue, 19 Feb 2008 19:41:56 +0000

author
Sadrul Habib Chowdhury <sadrul@pidgin.im>
date
Tue, 19 Feb 2008 19:41:56 +0000
branch
custom_smiley
changeset 22443
7b8772af6bb7
parent 21503
b3cad646ba4a
child 22656
c4c7c4852390
permissions
-rw-r--r--

Apply the custom smiley patches from #1187, from Jorge Villaseño (Masca) and
Mauro Sérgio Ferreira Brasil.

I have not applied the bits on MSN yet. I will have to look at it later, but
I would rather someone else more familiar with the MSN code look at it first.

I changed some bits of the applied patch (whitespacing, camelcasing etc.), and
the bit that required a major version bump (in gtkthemes.h). There are a few
more things that need to be done for this to be merged back to i.p.p.

6179
4df73df94250 [gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents: 6168
diff changeset
1 /**
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15678
diff changeset
2 * @file core.c Purple Core API
6179
4df73df94250 [gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents: 6168
diff changeset
3 * @ingroup core
20147
66f05a854eee applied changes from 8a731bbd0197fbcc91a705c2d8f528154216defa
Richard Laager <rlaager@pidgin.im>
parents: 19859
diff changeset
4 */
66f05a854eee applied changes from 8a731bbd0197fbcc91a705c2d8f528154216defa
Richard Laager <rlaager@pidgin.im>
parents: 19859
diff changeset
5
66f05a854eee applied changes from 8a731bbd0197fbcc91a705c2d8f528154216defa
Richard Laager <rlaager@pidgin.im>
parents: 19859
diff changeset
6 /* purple
2416
32a1499fe87e [gaim-migrate @ 2429]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
7 *
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15678
diff changeset
8 * Purple is the legal property of its developers, whose names are too numerous
8046
c581b20a47d6 [gaim-migrate @ 8730]
Sean Egan <seanegan@pidgin.im>
parents: 7646
diff changeset
9 * to list here. Please refer to the COPYRIGHT file distributed with this
c581b20a47d6 [gaim-migrate @ 8730]
Sean Egan <seanegan@pidgin.im>
parents: 7646
diff changeset
10 * source distribution.
2416
32a1499fe87e [gaim-migrate @ 2429]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
11 *
32a1499fe87e [gaim-migrate @ 2429]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
12 * This program is free software; you can redistribute it and/or modify
32a1499fe87e [gaim-migrate @ 2429]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
13 * it under the terms of the GNU General Public License as published by
32a1499fe87e [gaim-migrate @ 2429]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
14 * the Free Software Foundation; either version 2 of the License, or
32a1499fe87e [gaim-migrate @ 2429]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
15 * (at your option) any later version.
32a1499fe87e [gaim-migrate @ 2429]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
16 *
32a1499fe87e [gaim-migrate @ 2429]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
17 * This program is distributed in the hope that it will be useful,
32a1499fe87e [gaim-migrate @ 2429]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
32a1499fe87e [gaim-migrate @ 2429]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
32a1499fe87e [gaim-migrate @ 2429]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
20 * GNU General Public License for more details.
32a1499fe87e [gaim-migrate @ 2429]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
21 *
32a1499fe87e [gaim-migrate @ 2429]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
22 * You should have received a copy of the GNU General Public License
32a1499fe87e [gaim-migrate @ 2429]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
23 * 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: 19675
diff changeset
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
2416
32a1499fe87e [gaim-migrate @ 2429]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
25 */
6179
4df73df94250 [gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents: 6168
diff changeset
26 #include "internal.h"
10684
0325b164a7eb [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents: 10504
diff changeset
27 #include "cipher.h"
18477
47243c0d52c6 - Certificate system now has init and uninit like other systems
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18303
diff changeset
28 #include "certificate.h"
6179
4df73df94250 [gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents: 6168
diff changeset
29 #include "connection.h"
4df73df94250 [gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents: 6168
diff changeset
30 #include "conversation.h"
4df73df94250 [gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents: 6168
diff changeset
31 #include "core.h"
4df73df94250 [gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents: 6168
diff changeset
32 #include "debug.h"
14300
68a0aa63f3b8 [gaim-migrate @ 16920]
Mark Doliner <markdoliner@pidgin.im>
parents: 14286
diff changeset
33 #include "dnsquery.h"
11281
a5cda37a16be [gaim-migrate @ 13478]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 11256
diff changeset
34 #include "ft.h"
12272
4eee92ead973 [gaim-migrate @ 14574]
Mark Doliner <markdoliner@pidgin.im>
parents: 12129
diff changeset
35 #include "idle.h"
16437
7ff7c3405ea2 Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents: 16409
diff changeset
36 #include "imgstore.h"
8231
347c8992c445 [gaim-migrate @ 8954]
Tim Ringenbach <marv@pidgin.im>
parents: 8046
diff changeset
37 #include "network.h"
12129
314cd0274e6a [gaim-migrate @ 14429]
Ka-Hing Cheung <khc@pidgin.im>
parents: 12080
diff changeset
38 #include "notify.h"
6179
4df73df94250 [gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents: 6168
diff changeset
39 #include "plugin.h"
4df73df94250 [gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents: 6168
diff changeset
40 #include "pounce.h"
4df73df94250 [gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents: 6168
diff changeset
41 #include "prefs.h"
6371
e92b66ee5518 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents: 6266
diff changeset
42 #include "privacy.h"
6179
4df73df94250 [gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents: 6168
diff changeset
43 #include "proxy.h"
10418
7b632343a29c [gaim-migrate @ 11669]
Mark Doliner <markdoliner@pidgin.im>
parents: 10322
diff changeset
44 #include "savedstatuses.h"
6485
3c7ba18e32f1 [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
45 #include "signals.h"
22443
7b8772af6bb7 Apply the custom smiley patches from #1187, from Jorge Villaseño (Masca) and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21503
diff changeset
46 #include "smiley.h"
14300
68a0aa63f3b8 [gaim-migrate @ 16920]
Mark Doliner <markdoliner@pidgin.im>
parents: 14286
diff changeset
47 #include "sound.h"
6701
7e2db9273748 [gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents: 6612
diff changeset
48 #include "sslconn.h"
9944
71ef020ec4b0 [gaim-migrate @ 10838]
Christian Hammond <chipx86@chipx86.com>
parents: 9649
diff changeset
49 #include "status.h"
11424
b0f8535daa74 [gaim-migrate @ 13661]
Thomas Butter <tbutter@users.sourceforge.net>
parents: 11281
diff changeset
50 #include "stun.h"
16409
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
51 #include "util.h"
2416
32a1499fe87e [gaim-migrate @ 2429]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
52
11171
a25653d60f9c [gaim-migrate @ 13272]
Piotr Zielinski <zielaj@users.sourceforge.net>
parents: 11033
diff changeset
53 #ifdef HAVE_DBUS
17121
43d41f5ce17b Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents: 16763
diff changeset
54 # define DBUS_API_SUBJECT_TO_CHANGE
43d41f5ce17b Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents: 16763
diff changeset
55 # include <dbus/dbus.h>
43d41f5ce17b Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents: 16763
diff changeset
56 # include "dbus-purple.h"
11171
a25653d60f9c [gaim-migrate @ 13272]
Piotr Zielinski <zielaj@users.sourceforge.net>
parents: 11033
diff changeset
57 # include "dbus-server.h"
17121
43d41f5ce17b Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents: 16763
diff changeset
58 # include "dbus-bindings.h"
11171
a25653d60f9c [gaim-migrate @ 13272]
Piotr Zielinski <zielaj@users.sourceforge.net>
parents: 11033
diff changeset
59 #endif
a25653d60f9c [gaim-migrate @ 13272]
Piotr Zielinski <zielaj@users.sourceforge.net>
parents: 11033
diff changeset
60
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15678
diff changeset
61 struct PurpleCore
6179
4df73df94250 [gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents: 6168
diff changeset
62 {
4df73df94250 [gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents: 6168
diff changeset
63 char *ui;
4df73df94250 [gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents: 6168
diff changeset
64
4df73df94250 [gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents: 6168
diff changeset
65 void *reserved;
4df73df94250 [gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents: 6168
diff changeset
66 };
4df73df94250 [gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents: 6168
diff changeset
67
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15678
diff changeset
68 static PurpleCoreUiOps *_ops = NULL;
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15678
diff changeset
69 static PurpleCore *_core = NULL;
6179
4df73df94250 [gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents: 6168
diff changeset
70
4df73df94250 [gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents: 6168
diff changeset
71 STATIC_PROTO_INIT
4df73df94250 [gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents: 6168
diff changeset
72
4df73df94250 [gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents: 6168
diff changeset
73 gboolean
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15678
diff changeset
74 purple_core_init(const char *ui)
6179
4df73df94250 [gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents: 6168
diff changeset
75 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15678
diff changeset
76 PurpleCoreUiOps *ops;
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15678
diff changeset
77 PurpleCore *core;
6179
4df73df94250 [gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents: 6168
diff changeset
78
4df73df94250 [gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents: 6168
diff changeset
79 g_return_val_if_fail(ui != NULL, FALSE);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15678
diff changeset
80 g_return_val_if_fail(purple_get_core() == NULL, FALSE);
6179
4df73df94250 [gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents: 6168
diff changeset
81
16124
8e5e3e9ada60 Hopefully prevent libpurple causing problems for 3rd party UIs if they also
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 15884
diff changeset
82 #ifdef ENABLE_NLS
8e5e3e9ada60 Hopefully prevent libpurple causing problems for 3rd party UIs if they also
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 15884
diff changeset
83 bindtextdomain(PACKAGE, LOCALEDIR);
8e5e3e9ada60 Hopefully prevent libpurple causing problems for 3rd party UIs if they also
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 15884
diff changeset
84 #endif
14286
9ff15ceacd34 [gaim-migrate @ 16905]
Daniel Atallah <datallah@pidgin.im>
parents: 14254
diff changeset
85 #ifdef _WIN32
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15678
diff changeset
86 wpurple_init();
14286
9ff15ceacd34 [gaim-migrate @ 16905]
Daniel Atallah <datallah@pidgin.im>
parents: 14254
diff changeset
87 #endif
9ff15ceacd34 [gaim-migrate @ 16905]
Daniel Atallah <datallah@pidgin.im>
parents: 14254
diff changeset
88
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15678
diff changeset
89 _core = core = g_new0(PurpleCore, 1);
6179
4df73df94250 [gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents: 6168
diff changeset
90 core->ui = g_strdup(ui);
4df73df94250 [gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents: 6168
diff changeset
91 core->reserved = NULL;
4df73df94250 [gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents: 6168
diff changeset
92
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15678
diff changeset
93 ops = purple_core_get_ui_ops();
6179
4df73df94250 [gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents: 6168
diff changeset
94
6485
3c7ba18e32f1 [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
95 /* The signals subsystem is important and should be first. */
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15678
diff changeset
96 purple_signals_init();
6485
3c7ba18e32f1 [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
97
21238
cd326828c870 Add and call a purple_util_uninit() to free user_dir and customer_home_dir
Richard Laager <rlaager@pidgin.im>
parents: 20147
diff changeset
98 purple_util_init();
cd326828c870 Add and call a purple_util_uninit() to free user_dir and customer_home_dir
Richard Laager <rlaager@pidgin.im>
parents: 20147
diff changeset
99
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15678
diff changeset
100 purple_signal_register(core, "uri-handler",
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15678
diff changeset
101 purple_marshal_BOOLEAN__POINTER_POINTER_POINTER,
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15678
diff changeset
102 purple_value_new(PURPLE_TYPE_BOOLEAN), 3,
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15678
diff changeset
103 purple_value_new(PURPLE_TYPE_STRING), /* Protocol */
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15678
diff changeset
104 purple_value_new(PURPLE_TYPE_STRING), /* Command */
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15678
diff changeset
105 purple_value_new(PURPLE_TYPE_BOXED, "GHashTable *")); /* Parameters */
15678
7434ef155a3a Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <datallah@pidgin.im>
parents: 15435
diff changeset
106
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15678
diff changeset
107 purple_signal_register(core, "quitting", purple_marshal_VOID, NULL, 0);
6485
3c7ba18e32f1 [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
108
10087
e5b80a38939d [gaim-migrate @ 11098]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 9944
diff changeset
109 /* The prefs subsystem needs to be initialized before static protocols
e5b80a38939d [gaim-migrate @ 11098]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 9944
diff changeset
110 * for protocol prefs to work. */
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15678
diff changeset
111 purple_prefs_init();
10087
e5b80a38939d [gaim-migrate @ 11098]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 9944
diff changeset
112
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15678
diff changeset
113 purple_debug_init();
10448
4415ffba12e9 [gaim-migrate @ 11713]
Mark Doliner <markdoliner@pidgin.im>
parents: 10418
diff changeset
114
9944
71ef020ec4b0 [gaim-migrate @ 10838]
Christian Hammond <chipx86@chipx86.com>
parents: 9649
diff changeset
115 if (ops != NULL)
71ef020ec4b0 [gaim-migrate @ 10838]
Christian Hammond <chipx86@chipx86.com>
parents: 9649
diff changeset
116 {
6179
4df73df94250 [gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents: 6168
diff changeset
117 if (ops->ui_prefs_init != NULL)
4df73df94250 [gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents: 6168
diff changeset
118 ops->ui_prefs_init();
4df73df94250 [gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents: 6168
diff changeset
119
4df73df94250 [gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents: 6168
diff changeset
120 if (ops->debug_ui_init != NULL)
4df73df94250 [gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents: 6168
diff changeset
121 ops->debug_ui_init();
4df73df94250 [gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents: 6168
diff changeset
122 }
4df73df94250 [gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents: 6168
diff changeset
123
11171
a25653d60f9c [gaim-migrate @ 13272]
Piotr Zielinski <zielaj@users.sourceforge.net>
parents: 11033
diff changeset
124 #ifdef HAVE_DBUS
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15678
diff changeset
125 purple_dbus_init();
11171
a25653d60f9c [gaim-migrate @ 13272]
Piotr Zielinski <zielaj@users.sourceforge.net>
parents: 11033
diff changeset
126 #endif
a25653d60f9c [gaim-migrate @ 13272]
Piotr Zielinski <zielaj@users.sourceforge.net>
parents: 11033
diff changeset
127
16660
05ee74f25b2a Part of the patch in ticket #383:
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 16608
diff changeset
128 purple_ciphers_init();
05ee74f25b2a Part of the patch in ticket #383:
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 16608
diff changeset
129
11033
dc68e074f10d [gaim-migrate @ 12919]
Etan Reisner <deryni@pidgin.im>
parents: 10684
diff changeset
130 /* Initialize all static protocols. */
dc68e074f10d [gaim-migrate @ 12919]
Etan Reisner <deryni@pidgin.im>
parents: 10684
diff changeset
131 static_proto_init();
dc68e074f10d [gaim-migrate @ 12919]
Etan Reisner <deryni@pidgin.im>
parents: 10684
diff changeset
132
dc68e074f10d [gaim-migrate @ 12919]
Etan Reisner <deryni@pidgin.im>
parents: 10684
diff changeset
133 /* Since plugins get probed so early we should probably initialize their
dc68e074f10d [gaim-migrate @ 12919]
Etan Reisner <deryni@pidgin.im>
parents: 10684
diff changeset
134 * subsystem right away too.
dc68e074f10d [gaim-migrate @ 12919]
Etan Reisner <deryni@pidgin.im>
parents: 10684
diff changeset
135 */
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15678
diff changeset
136 purple_plugins_init();
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15678
diff changeset
137 purple_plugins_probe(G_MODULE_SUFFIX);
11033
dc68e074f10d [gaim-migrate @ 12919]
Etan Reisner <deryni@pidgin.im>
parents: 10684
diff changeset
138
16437
7ff7c3405ea2 Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents: 16409
diff changeset
139 /* The buddy icon code uses the imgstore, so init it early. */
7ff7c3405ea2 Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents: 16409
diff changeset
140 purple_imgstore_init();
7ff7c3405ea2 Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents: 16409
diff changeset
141
21292
076fbf488504 Connect to connection-error in account.c so that the account error is actually
Will Thompson <resiak@pidgin.im>
parents: 21238
diff changeset
142 /* Accounts use status, buddy icons and connection signals, so
076fbf488504 Connect to connection-error in account.c so that the account error is actually
Will Thompson <resiak@pidgin.im>
parents: 21238
diff changeset
143 * initialize these before accounts
076fbf488504 Connect to connection-error in account.c so that the account error is actually
Will Thompson <resiak@pidgin.im>
parents: 21238
diff changeset
144 */
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15678
diff changeset
145 purple_status_init();
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15678
diff changeset
146 purple_buddy_icons_init();
21292
076fbf488504 Connect to connection-error in account.c so that the account error is actually
Will Thompson <resiak@pidgin.im>
parents: 21238
diff changeset
147 purple_connections_init();
13481
6a4badb9f8e4 [gaim-migrate @ 15856]
Evan Schoenberg <evands@pidgin.im>
parents: 13294
diff changeset
148
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15678
diff changeset
149 purple_accounts_init();
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15678
diff changeset
150 purple_savedstatuses_init();
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15678
diff changeset
151 purple_notify_init();
18477
47243c0d52c6 - Certificate system now has init and uninit like other systems
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18303
diff changeset
152 purple_certificate_init();
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15678
diff changeset
153 purple_conversations_init();
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15678
diff changeset
154 purple_blist_init();
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15678
diff changeset
155 purple_log_init();
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15678
diff changeset
156 purple_network_init();
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15678
diff changeset
157 purple_privacy_init();
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15678
diff changeset
158 purple_pounces_init();
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15678
diff changeset
159 purple_proxy_init();
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15678
diff changeset
160 purple_dnsquery_init();
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15678
diff changeset
161 purple_sound_init();
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15678
diff changeset
162 purple_ssl_init();
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15678
diff changeset
163 purple_stun_init();
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15678
diff changeset
164 purple_xfers_init();
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15678
diff changeset
165 purple_idle_init();
22443
7b8772af6bb7 Apply the custom smiley patches from #1187, from Jorge Villaseño (Masca) and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21503
diff changeset
166 purple_smileys_init();
6179
4df73df94250 [gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents: 6168
diff changeset
167
15116
037b787407ba [gaim-migrate @ 17838]
Mark Doliner <markdoliner@pidgin.im>
parents: 14300
diff changeset
168 /*
037b787407ba [gaim-migrate @ 17838]
Mark Doliner <markdoliner@pidgin.im>
parents: 14300
diff changeset
169 * Call this early on to try to auto-detect our IP address and
037b787407ba [gaim-migrate @ 17838]
Mark Doliner <markdoliner@pidgin.im>
parents: 14300
diff changeset
170 * hopefully save some time later.
037b787407ba [gaim-migrate @ 17838]
Mark Doliner <markdoliner@pidgin.im>
parents: 14300
diff changeset
171 */
19675
3c1669c529a1 Move purple_prefs_load() to purple_prefs_init() - there's been a TODO for this for a long time. I have no idea why this wasn't done sooner; it seems to work just fine and fixes some bugs where stuff isn't loaded before being used. Fixes #1848 (and I'm sure others). Yell at me if this breaks anything.
Daniel Atallah <datallah@pidgin.im>
parents: 19341
diff changeset
172 purple_network_get_my_ip(-1);
13181
2a22fe4717ed [gaim-migrate @ 15543]
Daniel Atallah <datallah@pidgin.im>
parents: 13130
diff changeset
173
6179
4df73df94250 [gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents: 6168
diff changeset
174 if (ops != NULL && ops->ui_init != NULL)
4df73df94250 [gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents: 6168
diff changeset
175 ops->ui_init();
4df73df94250 [gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents: 6168
diff changeset
176
4df73df94250 [gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents: 6168
diff changeset
177 return TRUE;
4df73df94250 [gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents: 6168
diff changeset
178 }
4df73df94250 [gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents: 6168
diff changeset
179
4df73df94250 [gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents: 6168
diff changeset
180 void
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15678
diff changeset
181 purple_core_quit(void)
6179
4df73df94250 [gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents: 6168
diff changeset
182 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15678
diff changeset
183 PurpleCoreUiOps *ops;
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15678
diff changeset
184 PurpleCore *core = purple_get_core();
6179
4df73df94250 [gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents: 6168
diff changeset
185
4df73df94250 [gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents: 6168
diff changeset
186 g_return_if_fail(core != NULL);
4df73df94250 [gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents: 6168
diff changeset
187
4df73df94250 [gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents: 6168
diff changeset
188 /* The self destruct sequence has been initiated */
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15678
diff changeset
189 purple_signal_emit(purple_get_core(), "quitting");
6179
4df73df94250 [gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents: 6168
diff changeset
190
4df73df94250 [gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents: 6168
diff changeset
191 /* Transmission ends */
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15678
diff changeset
192 purple_connections_disconnect_all();
6179
4df73df94250 [gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents: 6168
diff changeset
193
8235
00045afab151 [gaim-migrate @ 8958]
Gary Kramlich <grim@pidgin.im>
parents: 8231
diff changeset
194 /* Save .xml files, remove signals, etc. */
22443
7b8772af6bb7 Apply the custom smiley patches from #1187, from Jorge Villaseño (Masca) and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21503
diff changeset
195 purple_smileys_uninit();
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15678
diff changeset
196 purple_idle_uninit();
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15678
diff changeset
197 purple_ssl_uninit();
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15678
diff changeset
198 purple_pounces_uninit();
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15678
diff changeset
199 purple_blist_uninit();
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15678
diff changeset
200 purple_ciphers_uninit();
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15678
diff changeset
201 purple_notify_uninit();
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15678
diff changeset
202 purple_conversations_uninit();
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15678
diff changeset
203 purple_connections_uninit();
18477
47243c0d52c6 - Certificate system now has init and uninit like other systems
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18303
diff changeset
204 purple_certificate_uninit();
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15678
diff changeset
205 purple_buddy_icons_uninit();
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15678
diff changeset
206 purple_accounts_uninit();
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15678
diff changeset
207 purple_savedstatuses_uninit();
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15678
diff changeset
208 purple_status_uninit();
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15678
diff changeset
209 purple_prefs_uninit();
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15678
diff changeset
210 purple_xfers_uninit();
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15678
diff changeset
211 purple_proxy_uninit();
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15678
diff changeset
212 purple_dnsquery_uninit();
16437
7ff7c3405ea2 Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents: 16409
diff changeset
213 purple_imgstore_uninit();
6485
3c7ba18e32f1 [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
214
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15678
diff changeset
215 purple_debug_info("main", "Unloading all plugins\n");
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15678
diff changeset
216 purple_plugins_destroy_all();
6485
3c7ba18e32f1 [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
217
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15678
diff changeset
218 ops = purple_core_get_ui_ops();
9649
c73921e0e7a0 [gaim-migrate @ 10497]
Mark Doliner <markdoliner@pidgin.im>
parents: 9633
diff changeset
219 if (ops != NULL && ops->quit != NULL)
c73921e0e7a0 [gaim-migrate @ 10497]
Mark Doliner <markdoliner@pidgin.im>
parents: 9633
diff changeset
220 ops->quit();
c73921e0e7a0 [gaim-migrate @ 10497]
Mark Doliner <markdoliner@pidgin.im>
parents: 9633
diff changeset
221
11464
f8871b9c1866 [gaim-migrate @ 13704]
Mark Doliner <markdoliner@pidgin.im>
parents: 11424
diff changeset
222 /*
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15678
diff changeset
223 * purple_sound_uninit() should be called as close to
11464
f8871b9c1866 [gaim-migrate @ 13704]
Mark Doliner <markdoliner@pidgin.im>
parents: 11424
diff changeset
224 * shutdown as possible. This is because the call
f8871b9c1866 [gaim-migrate @ 13704]
Mark Doliner <markdoliner@pidgin.im>
parents: 11424
diff changeset
225 * to ao_shutdown() can sometimes leave our
f8871b9c1866 [gaim-migrate @ 13704]
Mark Doliner <markdoliner@pidgin.im>
parents: 11424
diff changeset
226 * environment variables in an unusable state, which
f8871b9c1866 [gaim-migrate @ 13704]
Mark Doliner <markdoliner@pidgin.im>
parents: 11424
diff changeset
227 * can cause a crash when getenv is called (by gettext
f8871b9c1866 [gaim-migrate @ 13704]
Mark Doliner <markdoliner@pidgin.im>
parents: 11424
diff changeset
228 * for example). See the complete bug report at
f8871b9c1866 [gaim-migrate @ 13704]
Mark Doliner <markdoliner@pidgin.im>
parents: 11424
diff changeset
229 * http://trac.xiph.org/cgi-bin/trac.cgi/ticket/701
f8871b9c1866 [gaim-migrate @ 13704]
Mark Doliner <markdoliner@pidgin.im>
parents: 11424
diff changeset
230 *
f8871b9c1866 [gaim-migrate @ 13704]
Mark Doliner <markdoliner@pidgin.im>
parents: 11424
diff changeset
231 * TODO: Eventually move this call higher up with the others.
f8871b9c1866 [gaim-migrate @ 13704]
Mark Doliner <markdoliner@pidgin.im>
parents: 11424
diff changeset
232 */
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15678
diff changeset
233 purple_sound_uninit();
11464
f8871b9c1866 [gaim-migrate @ 13704]
Mark Doliner <markdoliner@pidgin.im>
parents: 11424
diff changeset
234
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15678
diff changeset
235 purple_plugins_uninit();
14017
db3f1bdc95c6 [gaim-migrate @ 16503]
Mark Doliner <markdoliner@pidgin.im>
parents: 13481
diff changeset
236 #ifdef HAVE_DBUS
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15678
diff changeset
237 purple_dbus_uninit();
14017
db3f1bdc95c6 [gaim-migrate @ 16503]
Mark Doliner <markdoliner@pidgin.im>
parents: 13481
diff changeset
238 #endif
21238
cd326828c870 Add and call a purple_util_uninit() to free user_dir and customer_home_dir
Richard Laager <rlaager@pidgin.im>
parents: 20147
diff changeset
239
cd326828c870 Add and call a purple_util_uninit() to free user_dir and customer_home_dir
Richard Laager <rlaager@pidgin.im>
parents: 20147
diff changeset
240 purple_util_uninit();
cd326828c870 Add and call a purple_util_uninit() to free user_dir and customer_home_dir
Richard Laager <rlaager@pidgin.im>
parents: 20147
diff changeset
241
18303
5cc245e1fcf3 Uninit the dbus system before uniniting the signals.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18267
diff changeset
242 purple_signals_uninit();
14017
db3f1bdc95c6 [gaim-migrate @ 16503]
Mark Doliner <markdoliner@pidgin.im>
parents: 13481
diff changeset
243
14097
0c340861ab79 [gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents: 14017
diff changeset
244 g_free(core->ui);
6179
4df73df94250 [gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents: 6168
diff changeset
245 g_free(core);
4df73df94250 [gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents: 6168
diff changeset
246
14286
9ff15ceacd34 [gaim-migrate @ 16905]
Daniel Atallah <datallah@pidgin.im>
parents: 14254
diff changeset
247 #ifdef _WIN32
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15678
diff changeset
248 wpurple_cleanup();
14286
9ff15ceacd34 [gaim-migrate @ 16905]
Daniel Atallah <datallah@pidgin.im>
parents: 14254
diff changeset
249 #endif
9ff15ceacd34 [gaim-migrate @ 16905]
Daniel Atallah <datallah@pidgin.im>
parents: 14254
diff changeset
250
6179
4df73df94250 [gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents: 6168
diff changeset
251 _core = NULL;
4df73df94250 [gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents: 6168
diff changeset
252 }
4df73df94250 [gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents: 6168
diff changeset
253
7646
6806a6893ac0 [gaim-migrate @ 8289]
Mark Doliner <markdoliner@pidgin.im>
parents: 7431
diff changeset
254 gboolean
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15678
diff changeset
255 purple_core_quit_cb(gpointer unused)
7646
6806a6893ac0 [gaim-migrate @ 8289]
Mark Doliner <markdoliner@pidgin.im>
parents: 7431
diff changeset
256 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15678
diff changeset
257 purple_core_quit();
7646
6806a6893ac0 [gaim-migrate @ 8289]
Mark Doliner <markdoliner@pidgin.im>
parents: 7431
diff changeset
258
6806a6893ac0 [gaim-migrate @ 8289]
Mark Doliner <markdoliner@pidgin.im>
parents: 7431
diff changeset
259 return FALSE;
6806a6893ac0 [gaim-migrate @ 8289]
Mark Doliner <markdoliner@pidgin.im>
parents: 7431
diff changeset
260 }
6806a6893ac0 [gaim-migrate @ 8289]
Mark Doliner <markdoliner@pidgin.im>
parents: 7431
diff changeset
261
6612
aac6af649208 [gaim-migrate @ 7136]
Christian Hammond <chipx86@chipx86.com>
parents: 6564
diff changeset
262 const char *
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15678
diff changeset
263 purple_core_get_version(void)
6612
aac6af649208 [gaim-migrate @ 7136]
Christian Hammond <chipx86@chipx86.com>
parents: 6564
diff changeset
264 {
aac6af649208 [gaim-migrate @ 7136]
Christian Hammond <chipx86@chipx86.com>
parents: 6564
diff changeset
265 return VERSION;
aac6af649208 [gaim-migrate @ 7136]
Christian Hammond <chipx86@chipx86.com>
parents: 6564
diff changeset
266 }
aac6af649208 [gaim-migrate @ 7136]
Christian Hammond <chipx86@chipx86.com>
parents: 6564
diff changeset
267
6179
4df73df94250 [gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents: 6168
diff changeset
268 const char *
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15678
diff changeset
269 purple_core_get_ui(void)
6179
4df73df94250 [gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents: 6168
diff changeset
270 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15678
diff changeset
271 PurpleCore *core = purple_get_core();
6179
4df73df94250 [gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents: 6168
diff changeset
272
4df73df94250 [gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents: 6168
diff changeset
273 g_return_val_if_fail(core != NULL, NULL);
4df73df94250 [gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents: 6168
diff changeset
274
4df73df94250 [gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents: 6168
diff changeset
275 return core->ui;
4df73df94250 [gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents: 6168
diff changeset
276 }
4df73df94250 [gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents: 6168
diff changeset
277
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15678
diff changeset
278 PurpleCore *
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15678
diff changeset
279 purple_get_core(void)
6179
4df73df94250 [gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents: 6168
diff changeset
280 {
4df73df94250 [gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents: 6168
diff changeset
281 return _core;
4df73df94250 [gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents: 6168
diff changeset
282 }
4df73df94250 [gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents: 6168
diff changeset
283
4df73df94250 [gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents: 6168
diff changeset
284 void
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15678
diff changeset
285 purple_core_set_ui_ops(PurpleCoreUiOps *ops)
6179
4df73df94250 [gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents: 6168
diff changeset
286 {
4df73df94250 [gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents: 6168
diff changeset
287 _ops = ops;
4df73df94250 [gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents: 6168
diff changeset
288 }
4df73df94250 [gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents: 6168
diff changeset
289
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15678
diff changeset
290 PurpleCoreUiOps *
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15678
diff changeset
291 purple_core_get_ui_ops(void)
6179
4df73df94250 [gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents: 6168
diff changeset
292 {
4df73df94250 [gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents: 6168
diff changeset
293 return _ops;
4df73df94250 [gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents: 6168
diff changeset
294 }
16409
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
295
17121
43d41f5ce17b Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents: 16763
diff changeset
296 #ifdef HAVE_DBUS
43d41f5ce17b Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents: 16763
diff changeset
297 static char *purple_dbus_owner_user_dir(void)
43d41f5ce17b Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents: 16763
diff changeset
298 {
43d41f5ce17b Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents: 16763
diff changeset
299 DBusMessage *msg = NULL, *reply = NULL;
43d41f5ce17b Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents: 16763
diff changeset
300 DBusConnection *dbus_connection = NULL;
43d41f5ce17b Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents: 16763
diff changeset
301 DBusError dbus_error;
43d41f5ce17b Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents: 16763
diff changeset
302 char *remote_user_dir = NULL;
43d41f5ce17b Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents: 16763
diff changeset
303
17122
5ba216aa4583 Style changes + removed unnecessary NULL checks.
Gabriel Schulhof <nix@go-nix.ca>
parents: 17121
diff changeset
304 if ((dbus_connection = purple_dbus_get_connection()) == NULL)
17121
43d41f5ce17b Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents: 16763
diff changeset
305 return NULL;
43d41f5ce17b Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents: 16763
diff changeset
306
17122
5ba216aa4583 Style changes + removed unnecessary NULL checks.
Gabriel Schulhof <nix@go-nix.ca>
parents: 17121
diff changeset
307 if ((msg = dbus_message_new_method_call(DBUS_SERVICE_PURPLE, DBUS_PATH_PURPLE, DBUS_INTERFACE_PURPLE, "PurpleUserDir")) == NULL)
17121
43d41f5ce17b Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents: 16763
diff changeset
308 return NULL;
43d41f5ce17b Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents: 16763
diff changeset
309
43d41f5ce17b Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents: 16763
diff changeset
310 dbus_error_init(&dbus_error);
43d41f5ce17b Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents: 16763
diff changeset
311 reply = dbus_connection_send_with_reply_and_block(dbus_connection, msg, 5000, &dbus_error);
43d41f5ce17b Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents: 16763
diff changeset
312 dbus_message_unref(msg);
43d41f5ce17b Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents: 16763
diff changeset
313 dbus_error_free(&dbus_error);
43d41f5ce17b Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents: 16763
diff changeset
314
17882
35499bfa38fb Style changes.
Richard Laager <rlaager@pidgin.im>
parents: 17220
diff changeset
315 if (reply)
35499bfa38fb Style changes.
Richard Laager <rlaager@pidgin.im>
parents: 17220
diff changeset
316 {
17121
43d41f5ce17b Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents: 16763
diff changeset
317 dbus_error_init(&dbus_error);
43d41f5ce17b Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents: 16763
diff changeset
318 dbus_message_get_args(reply, &dbus_error, DBUS_TYPE_STRING, &remote_user_dir, DBUS_TYPE_INVALID);
17123
b1ef108e361b Minor formatting tweaks for the dbus_uniq code.
Richard Laager <rlaager@pidgin.im>
parents: 17122
diff changeset
319 remote_user_dir = g_strdup(remote_user_dir);
17121
43d41f5ce17b Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents: 16763
diff changeset
320 dbus_error_free(&dbus_error);
43d41f5ce17b Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents: 16763
diff changeset
321 dbus_message_unref(reply);
17122
5ba216aa4583 Style changes + removed unnecessary NULL checks.
Gabriel Schulhof <nix@go-nix.ca>
parents: 17121
diff changeset
322 }
17121
43d41f5ce17b Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents: 16763
diff changeset
323
43d41f5ce17b Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents: 16763
diff changeset
324 return remote_user_dir;
43d41f5ce17b Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents: 16763
diff changeset
325 }
43d41f5ce17b Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents: 16763
diff changeset
326
43d41f5ce17b Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents: 16763
diff changeset
327 static void purple_dbus_owner_show_buddy_list(void)
43d41f5ce17b Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents: 16763
diff changeset
328 {
43d41f5ce17b Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents: 16763
diff changeset
329 DBusError dbus_error;
43d41f5ce17b Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents: 16763
diff changeset
330 DBusMessage *msg = NULL, *reply = NULL;
17122
5ba216aa4583 Style changes + removed unnecessary NULL checks.
Gabriel Schulhof <nix@go-nix.ca>
parents: 17121
diff changeset
331 DBusConnection *dbus_connection = NULL;
17121
43d41f5ce17b Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents: 16763
diff changeset
332
17122
5ba216aa4583 Style changes + removed unnecessary NULL checks.
Gabriel Schulhof <nix@go-nix.ca>
parents: 17121
diff changeset
333 if ((dbus_connection = purple_dbus_get_connection()) == NULL)
5ba216aa4583 Style changes + removed unnecessary NULL checks.
Gabriel Schulhof <nix@go-nix.ca>
parents: 17121
diff changeset
334 return;
17121
43d41f5ce17b Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents: 16763
diff changeset
335
17122
5ba216aa4583 Style changes + removed unnecessary NULL checks.
Gabriel Schulhof <nix@go-nix.ca>
parents: 17121
diff changeset
336 if ((msg = dbus_message_new_method_call(DBUS_SERVICE_PURPLE, DBUS_PATH_PURPLE, DBUS_INTERFACE_PURPLE, "PurpleBlistShow")) == NULL)
17123
b1ef108e361b Minor formatting tweaks for the dbus_uniq code.
Richard Laager <rlaager@pidgin.im>
parents: 17122
diff changeset
337 return;
17121
43d41f5ce17b Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents: 16763
diff changeset
338
43d41f5ce17b Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents: 16763
diff changeset
339 dbus_error_init(&dbus_error);
17882
35499bfa38fb Style changes.
Richard Laager <rlaager@pidgin.im>
parents: 17220
diff changeset
340 if ((reply = dbus_connection_send_with_reply_and_block(dbus_connection, msg, 5000, &dbus_error)) != NULL)
35499bfa38fb Style changes.
Richard Laager <rlaager@pidgin.im>
parents: 17220
diff changeset
341 {
17121
43d41f5ce17b Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents: 16763
diff changeset
342 dbus_message_unref(msg);
17122
5ba216aa4583 Style changes + removed unnecessary NULL checks.
Gabriel Schulhof <nix@go-nix.ca>
parents: 17121
diff changeset
343 }
17121
43d41f5ce17b Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents: 16763
diff changeset
344 dbus_error_free(&dbus_error);
43d41f5ce17b Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents: 16763
diff changeset
345 }
43d41f5ce17b Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents: 16763
diff changeset
346 #endif /* HAVE_DBUS */
43d41f5ce17b Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents: 16763
diff changeset
347
17882
35499bfa38fb Style changes.
Richard Laager <rlaager@pidgin.im>
parents: 17220
diff changeset
348 gboolean
35499bfa38fb Style changes.
Richard Laager <rlaager@pidgin.im>
parents: 17220
diff changeset
349 purple_core_ensure_single_instance()
17121
43d41f5ce17b Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents: 16763
diff changeset
350 {
17882
35499bfa38fb Style changes.
Richard Laager <rlaager@pidgin.im>
parents: 17220
diff changeset
351 gboolean is_single_instance = TRUE;
17121
43d41f5ce17b Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents: 16763
diff changeset
352 #ifdef HAVE_DBUS
17122
5ba216aa4583 Style changes + removed unnecessary NULL checks.
Gabriel Schulhof <nix@go-nix.ca>
parents: 17121
diff changeset
353 /* in the future, other mechanisms might have already set this to FALSE */
17882
35499bfa38fb Style changes.
Richard Laager <rlaager@pidgin.im>
parents: 17220
diff changeset
354 if (is_single_instance)
35499bfa38fb Style changes.
Richard Laager <rlaager@pidgin.im>
parents: 17220
diff changeset
355 {
35499bfa38fb Style changes.
Richard Laager <rlaager@pidgin.im>
parents: 17220
diff changeset
356 if (!purple_dbus_is_owner())
35499bfa38fb Style changes.
Richard Laager <rlaager@pidgin.im>
parents: 17220
diff changeset
357 {
17121
43d41f5ce17b Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents: 16763
diff changeset
358 const char *user_dir = purple_user_dir();
43d41f5ce17b Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents: 16763
diff changeset
359 char *dbus_owner_user_dir = purple_dbus_owner_user_dir();
43d41f5ce17b Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents: 16763
diff changeset
360
43d41f5ce17b Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents: 16763
diff changeset
361 if (NULL == user_dir && NULL != dbus_owner_user_dir)
43d41f5ce17b Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents: 16763
diff changeset
362 is_single_instance = TRUE;
17122
5ba216aa4583 Style changes + removed unnecessary NULL checks.
Gabriel Schulhof <nix@go-nix.ca>
parents: 17121
diff changeset
363 else if (NULL != user_dir && NULL == dbus_owner_user_dir)
17121
43d41f5ce17b Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents: 16763
diff changeset
364 is_single_instance = TRUE;
17122
5ba216aa4583 Style changes + removed unnecessary NULL checks.
Gabriel Schulhof <nix@go-nix.ca>
parents: 17121
diff changeset
365 else if (NULL == user_dir && NULL == dbus_owner_user_dir)
17121
43d41f5ce17b Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents: 16763
diff changeset
366 is_single_instance = FALSE;
43d41f5ce17b Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents: 16763
diff changeset
367 else
43d41f5ce17b Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents: 16763
diff changeset
368 is_single_instance = strcmp(dbus_owner_user_dir, user_dir);
43d41f5ce17b Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents: 16763
diff changeset
369
43d41f5ce17b Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents: 16763
diff changeset
370 if (!is_single_instance)
43d41f5ce17b Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents: 16763
diff changeset
371 purple_dbus_owner_show_buddy_list();
43d41f5ce17b Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents: 16763
diff changeset
372
43d41f5ce17b Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents: 16763
diff changeset
373 g_free(dbus_owner_user_dir);
43d41f5ce17b Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents: 16763
diff changeset
374 }
17122
5ba216aa4583 Style changes + removed unnecessary NULL checks.
Gabriel Schulhof <nix@go-nix.ca>
parents: 17121
diff changeset
375 }
17121
43d41f5ce17b Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents: 16763
diff changeset
376 #endif /* HAVE_DBUS */
17123
b1ef108e361b Minor formatting tweaks for the dbus_uniq code.
Richard Laager <rlaager@pidgin.im>
parents: 17122
diff changeset
377
17121
43d41f5ce17b Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents: 16763
diff changeset
378 return is_single_instance;
43d41f5ce17b Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents: 16763
diff changeset
379 }
43d41f5ce17b Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents: 16763
diff changeset
380
16409
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
381 static gboolean
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
382 move_and_symlink_dir(const char *path, const char *basename, const char *old_base, const char *new_base, const char *relative)
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
383 {
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
384 char *new_name = g_build_filename(new_base, basename, NULL);
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
385 #ifndef _WIN32
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
386 char *old_name;
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
387 #endif
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
388 if (g_rename(path, new_name))
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
389 {
16763
f00ec654e74a Solicit bug reports
Sean Egan <seanegan@pidgin.im>
parents: 16698
diff changeset
390 purple_debug_error("core", "Error renaming %s to %s: %s. Please report this at http://developer.pidgin.im\n",
21389
e1dd8142bb87 replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents: 20147
diff changeset
391 path, new_name, g_strerror(errno));
16409
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
392 g_free(new_name);
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
393 return FALSE;
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
394 }
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
395 g_free(new_name);
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
396
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
397 #ifndef _WIN32
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
398 /* NOTE: This new_name is relative. */
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
399 new_name = g_build_filename(relative, basename, NULL);
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
400 old_name = g_build_filename(old_base, basename, NULL);
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
401 if (symlink(new_name, old_name))
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
402 {
16763
f00ec654e74a Solicit bug reports
Sean Egan <seanegan@pidgin.im>
parents: 16698
diff changeset
403 purple_debug_warning("core", "Error symlinking %s to %s: %s. Please report this at http://developer.pidgin.im\n",
21389
e1dd8142bb87 replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents: 20147
diff changeset
404 old_name, new_name, g_strerror(errno));
16409
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
405 }
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
406 g_free(old_name);
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
407 g_free(new_name);
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
408 #endif
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
409
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
410 return TRUE;
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
411 }
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
412
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
413 gboolean
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
414 purple_core_migrate(void)
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
415 {
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
416 const char *user_dir = purple_user_dir();
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
417 char *old_user_dir = g_strconcat(purple_home_dir(),
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
418 G_DIR_SEPARATOR_S ".gaim", NULL);
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
419 char *status_file;
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
420 FILE *fp;
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
421 GDir *dir;
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
422 GError *err;
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
423 const char *entry;
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
424 #ifndef _WIN32
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
425 char *logs_dir;
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
426 #endif
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
427 char *old_icons_dir;
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
428
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
429 if (!g_file_test(old_user_dir, G_FILE_TEST_EXISTS))
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
430 {
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
431 /* ~/.gaim doesn't exist, so there's nothing to migrate. */
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
432 g_free(old_user_dir);
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
433 return TRUE;
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
434 }
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
435
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
436 status_file = g_strconcat(user_dir, G_DIR_SEPARATOR_S "migrating", NULL);
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
437
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
438 if (g_file_test(user_dir, G_FILE_TEST_EXISTS))
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
439 {
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
440 /* If we're here, we have both ~/.gaim and .purple. */
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
441
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
442 if (!g_file_test(status_file, G_FILE_TEST_EXISTS))
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
443 {
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
444 /* There's no "migrating" status file,
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
445 * so ~/.purple is all up to date. */
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
446 g_free(status_file);
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
447 g_free(old_user_dir);
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
448 return TRUE;
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
449 }
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
450 }
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
451
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
452 /* If we're here, it's time to migrate from ~/.gaim to ~/.purple. */
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
453
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
454 /* Ensure the user directory exists */
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
455 if (!g_file_test(user_dir, G_FILE_TEST_IS_DIR))
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
456 {
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
457 if (g_mkdir(user_dir, S_IRUSR | S_IWUSR | S_IXUSR) == -1)
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
458 {
16763
f00ec654e74a Solicit bug reports
Sean Egan <seanegan@pidgin.im>
parents: 16698
diff changeset
459 purple_debug_error("core", "Error creating directory %s: %s. Please report this at http://developer.pidgin.im\n",
21389
e1dd8142bb87 replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents: 20147
diff changeset
460 user_dir, g_strerror(errno));
16409
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
461 g_free(status_file);
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
462 g_free(old_user_dir);
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
463 return FALSE;
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
464 }
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
465 }
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
466
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
467 /* This writes ~/.purple/migrating, which allows us to detect
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
468 * incomplete migrations and properly retry. */
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
469 if (!(fp = g_fopen(status_file, "w")))
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
470 {
16763
f00ec654e74a Solicit bug reports
Sean Egan <seanegan@pidgin.im>
parents: 16698
diff changeset
471 purple_debug_error("core", "Error opening file %s for writing: %s. Please report this at http://developer.pidgin.im\n",
21389
e1dd8142bb87 replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents: 20147
diff changeset
472 status_file, g_strerror(errno));
16409
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
473 g_free(status_file);
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
474 g_free(old_user_dir);
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
475 return FALSE;
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
476 }
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
477 fclose(fp);
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
478
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
479 /* Open ~/.gaim so we can loop over its contents. */
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
480 err = NULL;
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
481 if (!(dir = g_dir_open(old_user_dir, 0, &err)))
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
482 {
16763
f00ec654e74a Solicit bug reports
Sean Egan <seanegan@pidgin.im>
parents: 16698
diff changeset
483 purple_debug_error("core", "Error opening directory %s: %s. Please report this at http://developer.pidgin.im\n",
16409
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
484 status_file,
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
485 (err ? err->message : "Unknown error"));
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
486 if (err)
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
487 g_error_free(err);
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
488 g_free(status_file);
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
489 g_free(old_user_dir);
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
490 return FALSE;
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
491 }
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
492
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
493 /* Loop over the contents of ~/.gaim */
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
494 while ((entry = g_dir_read_name(dir)))
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
495 {
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
496 char *name = g_build_filename(old_user_dir, entry, NULL);
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
497
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
498 #ifndef _WIN32
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
499 /* Deal with symlinks... */
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
500 if (g_file_test(name, G_FILE_TEST_IS_SYMLINK))
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
501 {
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
502 /* We're only going to duplicate a logs symlink. */
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
503 if (!strcmp(entry, "logs"))
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
504 {
18220
c88669a9d3dd Use dynamicly allocated string manipulation here as well to avoid a
Richard Laager <rlaager@pidgin.im>
parents: 18072
diff changeset
505 char *link;
c88669a9d3dd Use dynamicly allocated string manipulation here as well to avoid a
Richard Laager <rlaager@pidgin.im>
parents: 18072
diff changeset
506 #if GLIB_CHECK_VERSION(2,4,0)
c88669a9d3dd Use dynamicly allocated string manipulation here as well to avoid a
Richard Laager <rlaager@pidgin.im>
parents: 18072
diff changeset
507 GError *err = NULL;
c88669a9d3dd Use dynamicly allocated string manipulation here as well to avoid a
Richard Laager <rlaager@pidgin.im>
parents: 18072
diff changeset
508
c88669a9d3dd Use dynamicly allocated string manipulation here as well to avoid a
Richard Laager <rlaager@pidgin.im>
parents: 18072
diff changeset
509 if ((link = g_file_read_link(name, &err)) == NULL)
c88669a9d3dd Use dynamicly allocated string manipulation here as well to avoid a
Richard Laager <rlaager@pidgin.im>
parents: 18072
diff changeset
510 {
c88669a9d3dd Use dynamicly allocated string manipulation here as well to avoid a
Richard Laager <rlaager@pidgin.im>
parents: 18072
diff changeset
511 char *name_utf8 = g_filename_to_utf8(name, -1, NULL, NULL, NULL);
c88669a9d3dd Use dynamicly allocated string manipulation here as well to avoid a
Richard Laager <rlaager@pidgin.im>
parents: 18072
diff changeset
512 purple_debug_error("core", "Error reading symlink %s: %s. Please report this at http://developer.pidgin.im\n",
c88669a9d3dd Use dynamicly allocated string manipulation here as well to avoid a
Richard Laager <rlaager@pidgin.im>
parents: 18072
diff changeset
513 name_utf8 ? name_utf8 : name, err->message);
c88669a9d3dd Use dynamicly allocated string manipulation here as well to avoid a
Richard Laager <rlaager@pidgin.im>
parents: 18072
diff changeset
514 g_free(name_utf8);
c88669a9d3dd Use dynamicly allocated string manipulation here as well to avoid a
Richard Laager <rlaager@pidgin.im>
parents: 18072
diff changeset
515 g_error_free(err);
c88669a9d3dd Use dynamicly allocated string manipulation here as well to avoid a
Richard Laager <rlaager@pidgin.im>
parents: 18072
diff changeset
516 g_free(name);
c88669a9d3dd Use dynamicly allocated string manipulation here as well to avoid a
Richard Laager <rlaager@pidgin.im>
parents: 18072
diff changeset
517 g_dir_close(dir);
c88669a9d3dd Use dynamicly allocated string manipulation here as well to avoid a
Richard Laager <rlaager@pidgin.im>
parents: 18072
diff changeset
518 g_free(status_file);
c88669a9d3dd Use dynamicly allocated string manipulation here as well to avoid a
Richard Laager <rlaager@pidgin.im>
parents: 18072
diff changeset
519 g_free(old_user_dir);
c88669a9d3dd Use dynamicly allocated string manipulation here as well to avoid a
Richard Laager <rlaager@pidgin.im>
parents: 18072
diff changeset
520 return FALSE;
c88669a9d3dd Use dynamicly allocated string manipulation here as well to avoid a
Richard Laager <rlaager@pidgin.im>
parents: 18072
diff changeset
521 }
c88669a9d3dd Use dynamicly allocated string manipulation here as well to avoid a
Richard Laager <rlaager@pidgin.im>
parents: 18072
diff changeset
522 #else
16409
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
523 char buf[MAXPATHLEN];
16666
44017931b1e7 #386: readlink does not append NUL to the end of buffer
Ka-Hing Cheung <khc@pidgin.im>
parents: 16660
diff changeset
524 size_t linklen;
16409
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
525
16666
44017931b1e7 #386: readlink does not append NUL to the end of buffer
Ka-Hing Cheung <khc@pidgin.im>
parents: 16660
diff changeset
526 if ((linklen = readlink(name, buf, sizeof(buf) - 1) == -1))
16409
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
527 {
18267
076446fd04a3 Bring back MAXPATHLEN (which was always guaranteed to be defined earlier
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 18220
diff changeset
528 char *name_utf8 = g_filename_to_utf8(name, -1, NULL, NULL, NULL);
16763
f00ec654e74a Solicit bug reports
Sean Egan <seanegan@pidgin.im>
parents: 16698
diff changeset
529 purple_debug_error("core", "Error reading symlink %s: %s. Please report this at http://developer.pidgin.im\n",
21389
e1dd8142bb87 replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents: 20147
diff changeset
530 name_utf8, g_strerror(errno));
18220
c88669a9d3dd Use dynamicly allocated string manipulation here as well to avoid a
Richard Laager <rlaager@pidgin.im>
parents: 18072
diff changeset
531 g_free(name_utf8);
16409
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
532 g_free(name);
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
533 g_dir_close(dir);
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
534 g_free(status_file);
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
535 g_free(old_user_dir);
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
536 return FALSE;
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
537 }
16666
44017931b1e7 #386: readlink does not append NUL to the end of buffer
Ka-Hing Cheung <khc@pidgin.im>
parents: 16660
diff changeset
538 buf[linklen] = '\0';
16409
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
539
18220
c88669a9d3dd Use dynamicly allocated string manipulation here as well to avoid a
Richard Laager <rlaager@pidgin.im>
parents: 18072
diff changeset
540 /* This way we don't have to GLIB_VERSION_CHECK every g_free(link) below. */
c88669a9d3dd Use dynamicly allocated string manipulation here as well to avoid a
Richard Laager <rlaager@pidgin.im>
parents: 18072
diff changeset
541 link = g_strdup(buf);
c88669a9d3dd Use dynamicly allocated string manipulation here as well to avoid a
Richard Laager <rlaager@pidgin.im>
parents: 18072
diff changeset
542 #endif
16409
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
543
18220
c88669a9d3dd Use dynamicly allocated string manipulation here as well to avoid a
Richard Laager <rlaager@pidgin.im>
parents: 18072
diff changeset
544 logs_dir = g_build_filename(user_dir, "logs", NULL);
c88669a9d3dd Use dynamicly allocated string manipulation here as well to avoid a
Richard Laager <rlaager@pidgin.im>
parents: 18072
diff changeset
545
c88669a9d3dd Use dynamicly allocated string manipulation here as well to avoid a
Richard Laager <rlaager@pidgin.im>
parents: 18072
diff changeset
546 if (!strcmp(link, "../.purple/logs") || !strcmp(link, logs_dir))
16409
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
547 {
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
548 /* If the symlink points to the new directory, we're
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
549 * likely just trying again after a failed migration,
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
550 * so there's no need to fail here. */
18220
c88669a9d3dd Use dynamicly allocated string manipulation here as well to avoid a
Richard Laager <rlaager@pidgin.im>
parents: 18072
diff changeset
551 g_free(link);
16409
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
552 g_free(logs_dir);
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
553 continue;
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
554 }
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
555
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
556 /* In case we are trying again after a failed migration, we need
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
557 * to unlink any existing symlink. If it's a directory, this
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
558 * will fail, and so will the symlink below, which is good
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
559 * because the user should sort things out. */
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
560 g_unlink(logs_dir);
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
561
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
562 /* Relative links will most likely still be
18220
c88669a9d3dd Use dynamicly allocated string manipulation here as well to avoid a
Richard Laager <rlaager@pidgin.im>
parents: 18072
diff changeset
563 * valid from ~/.purple, though it's not
16409
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
564 * guaranteed. Oh well. */
18220
c88669a9d3dd Use dynamicly allocated string manipulation here as well to avoid a
Richard Laager <rlaager@pidgin.im>
parents: 18072
diff changeset
565 if (symlink(link, logs_dir))
16409
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
566 {
16763
f00ec654e74a Solicit bug reports
Sean Egan <seanegan@pidgin.im>
parents: 16698
diff changeset
567 purple_debug_error("core", "Error symlinking %s to %s: %s. Please report this at http://developer.pidgin.im\n",
21389
e1dd8142bb87 replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents: 20147
diff changeset
568 logs_dir, link, g_strerror(errno));
18220
c88669a9d3dd Use dynamicly allocated string manipulation here as well to avoid a
Richard Laager <rlaager@pidgin.im>
parents: 18072
diff changeset
569 g_free(link);
16409
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
570 g_free(name);
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
571 g_free(logs_dir);
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
572 g_dir_close(dir);
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
573 g_free(status_file);
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
574 g_free(old_user_dir);
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
575 return FALSE;
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
576 }
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
577
18220
c88669a9d3dd Use dynamicly allocated string manipulation here as well to avoid a
Richard Laager <rlaager@pidgin.im>
parents: 18072
diff changeset
578 g_free(link);
16409
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
579 g_free(logs_dir);
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
580 continue;
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
581 }
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
582
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
583 /* Ignore all other symlinks. */
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
584 continue;
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
585 }
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
586 #endif
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
587
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
588 /* Deal with directories... */
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
589 if (g_file_test(name, G_FILE_TEST_IS_DIR))
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
590 {
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
591 if (!strcmp(entry, "icons"))
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
592 {
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
593 /* This is a special case for the Album plugin, which
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
594 * stores data in the icons folder. We're not copying
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
595 * the icons directory over because previous bugs
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
596 * meant that it filled up with junk for many users.
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
597 * This is a great time to purge it. */
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
598
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
599 GDir *icons_dir;
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
600 char *new_icons_dir;
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
601 const char *icons_entry;
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
602
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
603 err = NULL;
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
604 if (!(icons_dir = g_dir_open(name, 0, &err)))
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
605 {
16763
f00ec654e74a Solicit bug reports
Sean Egan <seanegan@pidgin.im>
parents: 16698
diff changeset
606 purple_debug_error("core", "Error opening directory %s: %s. Please report this at http://developer.pidgin.im\n",
16409
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
607 name,
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
608 (err ? err->message : "Unknown error"));
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
609 if (err)
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
610 g_error_free(err);
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
611 g_free(name);
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
612 g_dir_close(dir);
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
613 g_free(status_file);
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
614 g_free(old_user_dir);
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
615 return FALSE;
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
616 }
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
617
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
618 new_icons_dir = g_build_filename(user_dir, "icons", NULL);
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
619 /* Ensure the new icon directory exists */
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
620 if (!g_file_test(new_icons_dir, G_FILE_TEST_IS_DIR))
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
621 {
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
622 if (g_mkdir(new_icons_dir, S_IRUSR | S_IWUSR | S_IXUSR) == -1)
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
623 {
16763
f00ec654e74a Solicit bug reports
Sean Egan <seanegan@pidgin.im>
parents: 16698
diff changeset
624 purple_debug_error("core", "Error creating directory %s: %s. Please report this at http://developer.pidgin.im\n",
21389
e1dd8142bb87 replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents: 20147
diff changeset
625 new_icons_dir, g_strerror(errno));
16409
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
626 g_free(new_icons_dir);
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
627 g_dir_close(icons_dir);
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
628 g_free(name);
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
629 g_dir_close(dir);
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
630 g_free(status_file);
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
631 g_free(old_user_dir);
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
632 return FALSE;
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
633 }
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
634 }
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
635
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
636 while ((icons_entry = g_dir_read_name(icons_dir)))
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
637 {
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
638 char *icons_name = g_build_filename(name, icons_entry, NULL);
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
639
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
640 if (g_file_test(icons_name, G_FILE_TEST_IS_DIR))
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
641 {
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
642 if (!move_and_symlink_dir(icons_name, icons_entry,
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
643 name, new_icons_dir, "../../.purple/icons"))
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
644 {
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
645 g_free(icons_name);
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
646 g_free(new_icons_dir);
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
647 g_dir_close(icons_dir);
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
648 g_free(name);
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
649 g_dir_close(dir);
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
650 g_free(status_file);
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
651 g_free(old_user_dir);
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
652 return FALSE;
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
653 }
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
654 }
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
655 g_free(icons_name);
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
656 }
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
657
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
658 g_dir_close(icons_dir);
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
659 }
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
660 else if (!strcmp(entry, "plugins"))
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
661 {
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
662 /* Do nothing, because we broke plugin compatibility.
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
663 * This means that the plugins directory gets left behind. */
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
664 }
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
665 else
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
666 {
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
667 /* All other directories are moved and symlinked. */
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
668 if (!move_and_symlink_dir(name, entry, old_user_dir, user_dir, "../.purple"))
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
669 {
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
670 g_free(name);
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
671 g_dir_close(dir);
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
672 g_free(status_file);
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
673 g_free(old_user_dir);
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
674 return FALSE;
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
675 }
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
676 }
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
677 }
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
678 else if (g_file_test(name, G_FILE_TEST_IS_REGULAR))
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
679 {
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
680 /* Regular files are copied. */
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
681
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
682 char *new_name;
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
683 FILE *new_file;
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
684
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
685 if (!(fp = g_fopen(name, "rb")))
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
686 {
16763
f00ec654e74a Solicit bug reports
Sean Egan <seanegan@pidgin.im>
parents: 16698
diff changeset
687 purple_debug_error("core", "Error opening file %s for reading: %s. Please report this at http://developer.pidgin.im\n",
21389
e1dd8142bb87 replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents: 20147
diff changeset
688 name, g_strerror(errno));
16409
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
689 g_free(name);
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
690 g_dir_close(dir);
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
691 g_free(status_file);
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
692 g_free(old_user_dir);
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
693 return FALSE;
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
694 }
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
695
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
696 new_name = g_build_filename(user_dir, entry, NULL);
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
697 if (!(new_file = g_fopen(new_name, "wb")))
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
698 {
16763
f00ec654e74a Solicit bug reports
Sean Egan <seanegan@pidgin.im>
parents: 16698
diff changeset
699 purple_debug_error("core", "Error opening file %s for writing: %s. Please report this at http://developer.pidgin.im\n",
21389
e1dd8142bb87 replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents: 20147
diff changeset
700 new_name, g_strerror(errno));
16409
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
701 fclose(fp);
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
702 g_free(new_name);
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
703 g_free(name);
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
704 g_dir_close(dir);
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
705 g_free(status_file);
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
706 g_free(old_user_dir);
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
707 return FALSE;
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
708 }
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
709
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
710 while (!feof(fp))
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
711 {
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
712 unsigned char buf[256];
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
713 size_t size;
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
714
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
715 size = fread(buf, 1, sizeof(buf), fp);
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
716 if (size != sizeof(buf) && !feof(fp))
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
717 {
16763
f00ec654e74a Solicit bug reports
Sean Egan <seanegan@pidgin.im>
parents: 16698
diff changeset
718 purple_debug_error("core", "Error reading %s: %s. Please report this at http://developer.pidgin.im\n",
21389
e1dd8142bb87 replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents: 20147
diff changeset
719 name, g_strerror(errno));
16409
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
720 fclose(new_file);
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
721 fclose(fp);
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
722 g_free(new_name);
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
723 g_free(name);
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
724 g_dir_close(dir);
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
725 g_free(status_file);
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
726 g_free(old_user_dir);
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
727 return FALSE;
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
728 }
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
729
16554
63f70c76f8c5 Proper error checking on fwrite() call
Sean Egan <seanegan@pidgin.im>
parents: 16546
diff changeset
730 if (!fwrite(buf, size, 1, new_file) && ferror(new_file) != 0)
16409
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
731 {
16763
f00ec654e74a Solicit bug reports
Sean Egan <seanegan@pidgin.im>
parents: 16698
diff changeset
732 purple_debug_error("core", "Error writing %s: %s. Please report this at http://developer.pidgin.im\n",
21389
e1dd8142bb87 replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents: 20147
diff changeset
733 new_name, g_strerror(errno));
16409
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
734 fclose(new_file);
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
735 fclose(fp);
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
736 g_free(new_name);
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
737 g_free(name);
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
738 g_dir_close(dir);
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
739 g_free(status_file);
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
740 g_free(old_user_dir);
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
741 return FALSE;
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
742 }
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
743 }
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
744
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
745 if (fclose(new_file))
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
746 {
16763
f00ec654e74a Solicit bug reports
Sean Egan <seanegan@pidgin.im>
parents: 16698
diff changeset
747 purple_debug_error("core", "Error writing: %s: %s. Please report this at http://developer.pidgin.im\n",
21389
e1dd8142bb87 replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents: 20147
diff changeset
748 new_name, g_strerror(errno));
16409
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
749 }
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
750 if (fclose(fp))
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
751 {
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
752 purple_debug_warning("core", "Error closing %s: %s\n",
21389
e1dd8142bb87 replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents: 20147
diff changeset
753 name, g_strerror(errno));
16409
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
754 }
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
755 g_free(new_name);
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
756 }
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
757 else
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
758 purple_debug_warning("core", "Not a regular file or directory: %s\n", name);
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
759
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
760 g_free(name);
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
761 }
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
762
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
763 /* The migration was successful, so delete the status file. */
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
764 if (g_unlink(status_file))
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
765 {
16763
f00ec654e74a Solicit bug reports
Sean Egan <seanegan@pidgin.im>
parents: 16698
diff changeset
766 purple_debug_error("core", "Error unlinking file %s: %s. Please report this at http://developer.pidgin.im\n",
21389
e1dd8142bb87 replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents: 20147
diff changeset
767 status_file, g_strerror(errno));
16409
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
768 g_free(status_file);
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
769 return FALSE;
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
770 }
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
771
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
772 old_icons_dir = g_build_filename(old_user_dir, "icons", NULL);
16698
1fb16746439f Fix up the private function calls to be prefixed with an underscore.
Richard Laager <rlaager@pidgin.im>
parents: 16666
diff changeset
773 _purple_buddy_icon_set_old_icons_dir(old_icons_dir);
16409
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
774 g_free(old_icons_dir);
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
775
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
776 g_free(old_user_dir);
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
777
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
778 g_free(status_file);
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
779 return TRUE;
8c153c6febdd The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents: 16124
diff changeset
780 }
18441
d255d04c0aa1 core support for UI info...now to do the UI piece
Nathan Walp <nwalp@pidgin.im>
parents: 18303
diff changeset
781
d255d04c0aa1 core support for UI info...now to do the UI piece
Nathan Walp <nwalp@pidgin.im>
parents: 18303
diff changeset
782 GHashTable* purple_core_get_ui_info() {
d255d04c0aa1 core support for UI info...now to do the UI piece
Nathan Walp <nwalp@pidgin.im>
parents: 18303
diff changeset
783 PurpleCoreUiOps *ops = purple_core_get_ui_ops();
d255d04c0aa1 core support for UI info...now to do the UI piece
Nathan Walp <nwalp@pidgin.im>
parents: 18303
diff changeset
784
d255d04c0aa1 core support for UI info...now to do the UI piece
Nathan Walp <nwalp@pidgin.im>
parents: 18303
diff changeset
785 if(NULL == ops || NULL == ops->get_ui_info)
d255d04c0aa1 core support for UI info...now to do the UI piece
Nathan Walp <nwalp@pidgin.im>
parents: 18303
diff changeset
786 return NULL;
d255d04c0aa1 core support for UI info...now to do the UI piece
Nathan Walp <nwalp@pidgin.im>
parents: 18303
diff changeset
787
d255d04c0aa1 core support for UI info...now to do the UI piece
Nathan Walp <nwalp@pidgin.im>
parents: 18303
diff changeset
788 return ops->get_ui_info();
d255d04c0aa1 core support for UI info...now to do the UI piece
Nathan Walp <nwalp@pidgin.im>
parents: 18303
diff changeset
789 }

mercurial