Sun, 13 Jul 2008 15:51:38 +0000
Initialize the commands subsystem before the plugins.
This is necessary because plugins can add commands, and if the commands
subsystem isn't initialized by then, it throws a runtime error, causing a
crash with G_DEBUG=fatal_warnings (and from make check too, it seems).
Thanks to Richard for finding the bug.
|
6179
4df73df94250
[gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents:
6168
diff
changeset
|
1 | /** |
| 15884 | 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 | 7 | * |
| 15884 | 8 | * Purple is the legal property of its developers, whose names are too numerous |
| 8046 | 9 | * to list here. Please refer to the COPYRIGHT file distributed with this |
| 10 | * source distribution. | |
| 2416 | 11 | * |
| 12 | * This program is free software; you can redistribute it and/or modify | |
| 13 | * it under the terms of the GNU General Public License as published by | |
| 14 | * the Free Software Foundation; either version 2 of the License, or | |
| 15 | * (at your option) any later version. | |
| 16 | * | |
| 17 | * This program is distributed in the hope that it will be useful, | |
| 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 20 | * GNU General Public License for more details. | |
| 21 | * | |
| 22 | * You should have received a copy of the GNU General Public License | |
| 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 | 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" |
|
23555
82dab41b4163
cmd-added and cmd-removed signals to emit when commands are registered/unregistered.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23345
diff
changeset
|
29 | #include "cmds.h" |
|
6179
4df73df94250
[gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents:
6168
diff
changeset
|
30 | #include "connection.h" |
|
4df73df94250
[gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents:
6168
diff
changeset
|
31 | #include "conversation.h" |
|
4df73df94250
[gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents:
6168
diff
changeset
|
32 | #include "core.h" |
|
4df73df94250
[gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents:
6168
diff
changeset
|
33 | #include "debug.h" |
|
14300
68a0aa63f3b8
[gaim-migrate @ 16920]
Mark Doliner <markdoliner@pidgin.im>
parents:
14286
diff
changeset
|
34 | #include "dnsquery.h" |
|
11281
a5cda37a16be
[gaim-migrate @ 13478]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11256
diff
changeset
|
35 | #include "ft.h" |
|
12272
4eee92ead973
[gaim-migrate @ 14574]
Mark Doliner <markdoliner@pidgin.im>
parents:
12129
diff
changeset
|
36 | #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
|
37 | #include "imgstore.h" |
| 8231 | 38 | #include "network.h" |
| 12129 | 39 | #include "notify.h" |
|
6179
4df73df94250
[gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents:
6168
diff
changeset
|
40 | #include "plugin.h" |
|
4df73df94250
[gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents:
6168
diff
changeset
|
41 | #include "pounce.h" |
|
4df73df94250
[gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents:
6168
diff
changeset
|
42 | #include "prefs.h" |
|
6371
e92b66ee5518
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6266
diff
changeset
|
43 | #include "privacy.h" |
|
6179
4df73df94250
[gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents:
6168
diff
changeset
|
44 | #include "proxy.h" |
|
10418
7b632343a29c
[gaim-migrate @ 11669]
Mark Doliner <markdoliner@pidgin.im>
parents:
10322
diff
changeset
|
45 | #include "savedstatuses.h" |
|
6485
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
46 | #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
|
47 | #include "smiley.h" |
|
14300
68a0aa63f3b8
[gaim-migrate @ 16920]
Mark Doliner <markdoliner@pidgin.im>
parents:
14286
diff
changeset
|
48 | #include "sound.h" |
|
6701
7e2db9273748
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6612
diff
changeset
|
49 | #include "sslconn.h" |
|
9944
71ef020ec4b0
[gaim-migrate @ 10838]
Christian Hammond <chipx86@chipx86.com>
parents:
9649
diff
changeset
|
50 | #include "status.h" |
|
11424
b0f8535daa74
[gaim-migrate @ 13661]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11281
diff
changeset
|
51 | #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
|
52 | #include "util.h" |
| 2416 | 53 | |
|
11171
a25653d60f9c
[gaim-migrate @ 13272]
Piotr Zielinski <zielaj@users.sourceforge.net>
parents:
11033
diff
changeset
|
54 | #ifdef HAVE_DBUS |
|
22582
838faa931042
Avoid a compile warning when building with NetworkManager support because
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
21503
diff
changeset
|
55 | # ifndef DBUS_API_SUBJECT_TO_CHANGE |
|
838faa931042
Avoid a compile warning when building with NetworkManager support because
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
21503
diff
changeset
|
56 | # define DBUS_API_SUBJECT_TO_CHANGE |
|
838faa931042
Avoid a compile warning when building with NetworkManager support because
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
21503
diff
changeset
|
57 | # endif |
|
17121
43d41f5ce17b
Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents:
16763
diff
changeset
|
58 | # include <dbus/dbus.h> |
|
43d41f5ce17b
Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents:
16763
diff
changeset
|
59 | # include "dbus-purple.h" |
|
11171
a25653d60f9c
[gaim-migrate @ 13272]
Piotr Zielinski <zielaj@users.sourceforge.net>
parents:
11033
diff
changeset
|
60 | # include "dbus-server.h" |
|
17121
43d41f5ce17b
Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents:
16763
diff
changeset
|
61 | # include "dbus-bindings.h" |
|
11171
a25653d60f9c
[gaim-migrate @ 13272]
Piotr Zielinski <zielaj@users.sourceforge.net>
parents:
11033
diff
changeset
|
62 | #endif |
|
a25653d60f9c
[gaim-migrate @ 13272]
Piotr Zielinski <zielaj@users.sourceforge.net>
parents:
11033
diff
changeset
|
63 | |
| 15884 | 64 | struct PurpleCore |
|
6179
4df73df94250
[gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents:
6168
diff
changeset
|
65 | { |
|
4df73df94250
[gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents:
6168
diff
changeset
|
66 | char *ui; |
|
4df73df94250
[gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents:
6168
diff
changeset
|
67 | |
|
4df73df94250
[gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents:
6168
diff
changeset
|
68 | void *reserved; |
|
4df73df94250
[gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents:
6168
diff
changeset
|
69 | }; |
|
4df73df94250
[gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents:
6168
diff
changeset
|
70 | |
| 15884 | 71 | static PurpleCoreUiOps *_ops = NULL; |
| 72 | static PurpleCore *_core = NULL; | |
|
6179
4df73df94250
[gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents:
6168
diff
changeset
|
73 | |
|
4df73df94250
[gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents:
6168
diff
changeset
|
74 | STATIC_PROTO_INIT |
|
4df73df94250
[gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents:
6168
diff
changeset
|
75 | |
|
4df73df94250
[gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents:
6168
diff
changeset
|
76 | gboolean |
| 15884 | 77 | purple_core_init(const char *ui) |
|
6179
4df73df94250
[gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents:
6168
diff
changeset
|
78 | { |
| 15884 | 79 | PurpleCoreUiOps *ops; |
| 80 | PurpleCore *core; | |
|
6179
4df73df94250
[gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents:
6168
diff
changeset
|
81 | |
|
4df73df94250
[gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents:
6168
diff
changeset
|
82 | g_return_val_if_fail(ui != NULL, FALSE); |
| 15884 | 83 | g_return_val_if_fail(purple_get_core() == NULL, FALSE); |
|
6179
4df73df94250
[gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents:
6168
diff
changeset
|
84 | |
|
16124
8e5e3e9ada60
Hopefully prevent libpurple causing problems for 3rd party UIs if they also
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
85 | #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
|
86 | 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
|
87 | #endif |
|
14286
9ff15ceacd34
[gaim-migrate @ 16905]
Daniel Atallah <datallah@pidgin.im>
parents:
14254
diff
changeset
|
88 | #ifdef _WIN32 |
| 15884 | 89 | wpurple_init(); |
|
14286
9ff15ceacd34
[gaim-migrate @ 16905]
Daniel Atallah <datallah@pidgin.im>
parents:
14254
diff
changeset
|
90 | #endif |
|
9ff15ceacd34
[gaim-migrate @ 16905]
Daniel Atallah <datallah@pidgin.im>
parents:
14254
diff
changeset
|
91 | |
|
23138
ca068248eb99
Initialize the glib type system early in purple_core_init() too so UIs
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22873
diff
changeset
|
92 | g_type_init(); |
|
ca068248eb99
Initialize the glib type system early in purple_core_init() too so UIs
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22873
diff
changeset
|
93 | |
| 15884 | 94 | _core = core = g_new0(PurpleCore, 1); |
|
6179
4df73df94250
[gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents:
6168
diff
changeset
|
95 | core->ui = g_strdup(ui); |
|
4df73df94250
[gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents:
6168
diff
changeset
|
96 | core->reserved = NULL; |
|
4df73df94250
[gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents:
6168
diff
changeset
|
97 | |
| 15884 | 98 | ops = purple_core_get_ui_ops(); |
|
6179
4df73df94250
[gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents:
6168
diff
changeset
|
99 | |
|
6485
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
100 | /* The signals subsystem is important and should be first. */ |
| 15884 | 101 | purple_signals_init(); |
|
6485
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
102 | |
|
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
|
103 | 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
|
104 | |
| 15884 | 105 | purple_signal_register(core, "uri-handler", |
| 106 | purple_marshal_BOOLEAN__POINTER_POINTER_POINTER, | |
| 107 | purple_value_new(PURPLE_TYPE_BOOLEAN), 3, | |
| 108 | purple_value_new(PURPLE_TYPE_STRING), /* Protocol */ | |
| 109 | purple_value_new(PURPLE_TYPE_STRING), /* Command */ | |
| 110 | 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
|
111 | |
| 15884 | 112 | purple_signal_register(core, "quitting", purple_marshal_VOID, NULL, 0); |
|
6485
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
113 | |
|
10087
e5b80a38939d
[gaim-migrate @ 11098]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9944
diff
changeset
|
114 | /* The prefs subsystem needs to be initialized before static protocols |
|
e5b80a38939d
[gaim-migrate @ 11098]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9944
diff
changeset
|
115 | * for protocol prefs to work. */ |
| 15884 | 116 | purple_prefs_init(); |
|
10087
e5b80a38939d
[gaim-migrate @ 11098]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9944
diff
changeset
|
117 | |
| 15884 | 118 | purple_debug_init(); |
|
10448
4415ffba12e9
[gaim-migrate @ 11713]
Mark Doliner <markdoliner@pidgin.im>
parents:
10418
diff
changeset
|
119 | |
|
9944
71ef020ec4b0
[gaim-migrate @ 10838]
Christian Hammond <chipx86@chipx86.com>
parents:
9649
diff
changeset
|
120 | if (ops != NULL) |
|
71ef020ec4b0
[gaim-migrate @ 10838]
Christian Hammond <chipx86@chipx86.com>
parents:
9649
diff
changeset
|
121 | { |
|
6179
4df73df94250
[gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents:
6168
diff
changeset
|
122 | if (ops->ui_prefs_init != NULL) |
|
4df73df94250
[gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents:
6168
diff
changeset
|
123 | ops->ui_prefs_init(); |
|
4df73df94250
[gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents:
6168
diff
changeset
|
124 | |
|
4df73df94250
[gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents:
6168
diff
changeset
|
125 | if (ops->debug_ui_init != NULL) |
|
4df73df94250
[gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents:
6168
diff
changeset
|
126 | ops->debug_ui_init(); |
|
4df73df94250
[gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents:
6168
diff
changeset
|
127 | } |
|
4df73df94250
[gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents:
6168
diff
changeset
|
128 | |
|
11171
a25653d60f9c
[gaim-migrate @ 13272]
Piotr Zielinski <zielaj@users.sourceforge.net>
parents:
11033
diff
changeset
|
129 | #ifdef HAVE_DBUS |
| 15884 | 130 | purple_dbus_init(); |
|
11171
a25653d60f9c
[gaim-migrate @ 13272]
Piotr Zielinski <zielaj@users.sourceforge.net>
parents:
11033
diff
changeset
|
131 | #endif |
|
a25653d60f9c
[gaim-migrate @ 13272]
Piotr Zielinski <zielaj@users.sourceforge.net>
parents:
11033
diff
changeset
|
132 | |
|
16660
05ee74f25b2a
Part of the patch in ticket #383:
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16608
diff
changeset
|
133 | purple_ciphers_init(); |
|
23847
a4260c372f4c
Initialize the commands subsystem before the plugins.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23555
diff
changeset
|
134 | purple_cmds_init(); |
|
16660
05ee74f25b2a
Part of the patch in ticket #383:
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16608
diff
changeset
|
135 | |
| 11033 | 136 | /* Since plugins get probed so early we should probably initialize their |
| 137 | * subsystem right away too. | |
| 138 | */ | |
| 15884 | 139 | purple_plugins_init(); |
|
23345
aae374ed980c
If plugins are enabled and some protocols or plugins are also being compiled
Evan Schoenberg <evands@pidgin.im>
parents:
23339
diff
changeset
|
140 | |
|
aae374ed980c
If plugins are enabled and some protocols or plugins are also being compiled
Evan Schoenberg <evands@pidgin.im>
parents:
23339
diff
changeset
|
141 | /* Initialize all static protocols. */ |
|
aae374ed980c
If plugins are enabled and some protocols or plugins are also being compiled
Evan Schoenberg <evands@pidgin.im>
parents:
23339
diff
changeset
|
142 | static_proto_init(); |
|
aae374ed980c
If plugins are enabled and some protocols or plugins are also being compiled
Evan Schoenberg <evands@pidgin.im>
parents:
23339
diff
changeset
|
143 | |
| 15884 | 144 | purple_plugins_probe(G_MODULE_SUFFIX); |
| 11033 | 145 | |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16409
diff
changeset
|
146 | /* 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
|
147 | 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
|
148 | |
|
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
|
149 | /* 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
|
150 | * 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
|
151 | */ |
| 15884 | 152 | purple_status_init(); |
| 153 | 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
|
154 | purple_connections_init(); |
|
13481
6a4badb9f8e4
[gaim-migrate @ 15856]
Evan Schoenberg <evands@pidgin.im>
parents:
13294
diff
changeset
|
155 | |
| 15884 | 156 | purple_accounts_init(); |
| 157 | purple_savedstatuses_init(); | |
| 158 | purple_notify_init(); | |
|
18477
47243c0d52c6
- Certificate system now has init and uninit like other systems
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18303
diff
changeset
|
159 | purple_certificate_init(); |
| 15884 | 160 | purple_conversations_init(); |
| 161 | purple_blist_init(); | |
| 162 | purple_log_init(); | |
| 163 | purple_network_init(); | |
| 164 | purple_privacy_init(); | |
| 165 | purple_pounces_init(); | |
| 166 | purple_proxy_init(); | |
| 167 | purple_dnsquery_init(); | |
| 168 | purple_sound_init(); | |
| 169 | purple_ssl_init(); | |
| 170 | purple_stun_init(); | |
| 171 | purple_xfers_init(); | |
| 172 | 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
|
173 | purple_smileys_init(); |
|
6179
4df73df94250
[gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents:
6168
diff
changeset
|
174 | |
|
15116
037b787407ba
[gaim-migrate @ 17838]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
175 | /* |
|
037b787407ba
[gaim-migrate @ 17838]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
176 | * 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
|
177 | * hopefully save some time later. |
|
037b787407ba
[gaim-migrate @ 17838]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
178 | */ |
|
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
|
179 | purple_network_get_my_ip(-1); |
|
13181
2a22fe4717ed
[gaim-migrate @ 15543]
Daniel Atallah <datallah@pidgin.im>
parents:
13130
diff
changeset
|
180 | |
|
6179
4df73df94250
[gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents:
6168
diff
changeset
|
181 | if (ops != NULL && ops->ui_init != NULL) |
|
4df73df94250
[gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents:
6168
diff
changeset
|
182 | ops->ui_init(); |
|
4df73df94250
[gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents:
6168
diff
changeset
|
183 | |
|
4df73df94250
[gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents:
6168
diff
changeset
|
184 | return TRUE; |
|
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 | |
|
4df73df94250
[gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents:
6168
diff
changeset
|
187 | void |
| 15884 | 188 | purple_core_quit(void) |
|
6179
4df73df94250
[gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents:
6168
diff
changeset
|
189 | { |
| 15884 | 190 | PurpleCoreUiOps *ops; |
| 191 | PurpleCore *core = purple_get_core(); | |
|
6179
4df73df94250
[gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents:
6168
diff
changeset
|
192 | |
|
4df73df94250
[gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents:
6168
diff
changeset
|
193 | g_return_if_fail(core != NULL); |
|
4df73df94250
[gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents:
6168
diff
changeset
|
194 | |
|
4df73df94250
[gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents:
6168
diff
changeset
|
195 | /* The self destruct sequence has been initiated */ |
| 15884 | 196 | purple_signal_emit(purple_get_core(), "quitting"); |
|
6179
4df73df94250
[gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents:
6168
diff
changeset
|
197 | |
|
4df73df94250
[gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents:
6168
diff
changeset
|
198 | /* Transmission ends */ |
| 15884 | 199 | purple_connections_disconnect_all(); |
|
6179
4df73df94250
[gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents:
6168
diff
changeset
|
200 | |
| 8235 | 201 | /* 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
|
202 | purple_smileys_uninit(); |
| 15884 | 203 | purple_idle_uninit(); |
| 204 | purple_ssl_uninit(); | |
| 205 | purple_pounces_uninit(); | |
| 206 | purple_blist_uninit(); | |
| 207 | purple_ciphers_uninit(); | |
| 208 | purple_notify_uninit(); | |
| 209 | purple_conversations_uninit(); | |
| 210 | purple_connections_uninit(); | |
|
18477
47243c0d52c6
- Certificate system now has init and uninit like other systems
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18303
diff
changeset
|
211 | purple_certificate_uninit(); |
| 15884 | 212 | purple_buddy_icons_uninit(); |
| 213 | purple_accounts_uninit(); | |
| 214 | purple_savedstatuses_uninit(); | |
| 215 | purple_status_uninit(); | |
| 216 | purple_prefs_uninit(); | |
|
23339
ccda14e05414
Revert f8871b9c186682ffab8d6b6aa32260788caf0653 to fix a TODO about calling
Richard Laager <rlaager@pidgin.im>
parents:
23302
diff
changeset
|
217 | purple_sound_uninit(); |
| 15884 | 218 | purple_xfers_uninit(); |
| 219 | purple_proxy_uninit(); | |
| 220 | 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
|
221 | purple_imgstore_uninit(); |
|
6485
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
222 | |
| 15884 | 223 | purple_debug_info("main", "Unloading all plugins\n"); |
| 224 | purple_plugins_destroy_all(); | |
|
6485
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
225 | |
| 15884 | 226 | ops = purple_core_get_ui_ops(); |
|
9649
c73921e0e7a0
[gaim-migrate @ 10497]
Mark Doliner <markdoliner@pidgin.im>
parents:
9633
diff
changeset
|
227 | if (ops != NULL && ops->quit != NULL) |
|
c73921e0e7a0
[gaim-migrate @ 10497]
Mark Doliner <markdoliner@pidgin.im>
parents:
9633
diff
changeset
|
228 | ops->quit(); |
|
c73921e0e7a0
[gaim-migrate @ 10497]
Mark Doliner <markdoliner@pidgin.im>
parents:
9633
diff
changeset
|
229 | |
| 15884 | 230 | purple_plugins_uninit(); |
|
14017
db3f1bdc95c6
[gaim-migrate @ 16503]
Mark Doliner <markdoliner@pidgin.im>
parents:
13481
diff
changeset
|
231 | #ifdef HAVE_DBUS |
| 15884 | 232 | purple_dbus_uninit(); |
|
14017
db3f1bdc95c6
[gaim-migrate @ 16503]
Mark Doliner <markdoliner@pidgin.im>
parents:
13481
diff
changeset
|
233 | #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
|
234 | |
|
23847
a4260c372f4c
Initialize the commands subsystem before the plugins.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23555
diff
changeset
|
235 | purple_cmds_uninit(); |
|
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
|
236 | 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
|
237 | |
|
18303
5cc245e1fcf3
Uninit the dbus system before uniniting the signals.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18267
diff
changeset
|
238 | purple_signals_uninit(); |
|
14017
db3f1bdc95c6
[gaim-migrate @ 16503]
Mark Doliner <markdoliner@pidgin.im>
parents:
13481
diff
changeset
|
239 | |
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
14017
diff
changeset
|
240 | g_free(core->ui); |
|
6179
4df73df94250
[gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents:
6168
diff
changeset
|
241 | g_free(core); |
|
4df73df94250
[gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents:
6168
diff
changeset
|
242 | |
|
14286
9ff15ceacd34
[gaim-migrate @ 16905]
Daniel Atallah <datallah@pidgin.im>
parents:
14254
diff
changeset
|
243 | #ifdef _WIN32 |
| 15884 | 244 | wpurple_cleanup(); |
|
14286
9ff15ceacd34
[gaim-migrate @ 16905]
Daniel Atallah <datallah@pidgin.im>
parents:
14254
diff
changeset
|
245 | #endif |
|
9ff15ceacd34
[gaim-migrate @ 16905]
Daniel Atallah <datallah@pidgin.im>
parents:
14254
diff
changeset
|
246 | |
|
6179
4df73df94250
[gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents:
6168
diff
changeset
|
247 | _core = NULL; |
|
4df73df94250
[gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents:
6168
diff
changeset
|
248 | } |
|
4df73df94250
[gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents:
6168
diff
changeset
|
249 | |
|
7646
6806a6893ac0
[gaim-migrate @ 8289]
Mark Doliner <markdoliner@pidgin.im>
parents:
7431
diff
changeset
|
250 | gboolean |
| 15884 | 251 | purple_core_quit_cb(gpointer unused) |
|
7646
6806a6893ac0
[gaim-migrate @ 8289]
Mark Doliner <markdoliner@pidgin.im>
parents:
7431
diff
changeset
|
252 | { |
| 15884 | 253 | purple_core_quit(); |
|
7646
6806a6893ac0
[gaim-migrate @ 8289]
Mark Doliner <markdoliner@pidgin.im>
parents:
7431
diff
changeset
|
254 | |
|
6806a6893ac0
[gaim-migrate @ 8289]
Mark Doliner <markdoliner@pidgin.im>
parents:
7431
diff
changeset
|
255 | return FALSE; |
|
6806a6893ac0
[gaim-migrate @ 8289]
Mark Doliner <markdoliner@pidgin.im>
parents:
7431
diff
changeset
|
256 | } |
|
6806a6893ac0
[gaim-migrate @ 8289]
Mark Doliner <markdoliner@pidgin.im>
parents:
7431
diff
changeset
|
257 | |
|
6612
aac6af649208
[gaim-migrate @ 7136]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
258 | const char * |
| 15884 | 259 | purple_core_get_version(void) |
|
6612
aac6af649208
[gaim-migrate @ 7136]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
260 | { |
|
aac6af649208
[gaim-migrate @ 7136]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
261 | return VERSION; |
|
aac6af649208
[gaim-migrate @ 7136]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
262 | } |
|
aac6af649208
[gaim-migrate @ 7136]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
263 | |
|
6179
4df73df94250
[gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents:
6168
diff
changeset
|
264 | const char * |
| 15884 | 265 | purple_core_get_ui(void) |
|
6179
4df73df94250
[gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents:
6168
diff
changeset
|
266 | { |
| 15884 | 267 | PurpleCore *core = purple_get_core(); |
|
6179
4df73df94250
[gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents:
6168
diff
changeset
|
268 | |
|
4df73df94250
[gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents:
6168
diff
changeset
|
269 | g_return_val_if_fail(core != NULL, NULL); |
|
4df73df94250
[gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents:
6168
diff
changeset
|
270 | |
|
4df73df94250
[gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents:
6168
diff
changeset
|
271 | return core->ui; |
|
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 | |
| 15884 | 274 | PurpleCore * |
| 275 | purple_get_core(void) | |
|
6179
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 | return _core; |
|
4df73df94250
[gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents:
6168
diff
changeset
|
278 | } |
|
4df73df94250
[gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents:
6168
diff
changeset
|
279 | |
|
4df73df94250
[gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents:
6168
diff
changeset
|
280 | void |
| 15884 | 281 | purple_core_set_ui_ops(PurpleCoreUiOps *ops) |
|
6179
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 | _ops = ops; |
|
4df73df94250
[gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents:
6168
diff
changeset
|
284 | } |
|
4df73df94250
[gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents:
6168
diff
changeset
|
285 | |
| 15884 | 286 | PurpleCoreUiOps * |
| 287 | purple_core_get_ui_ops(void) | |
|
6179
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 | return _ops; |
|
4df73df94250
[gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents:
6168
diff
changeset
|
290 | } |
|
16409
8c153c6febdd
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents:
16124
diff
changeset
|
291 | |
|
17121
43d41f5ce17b
Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents:
16763
diff
changeset
|
292 | #ifdef HAVE_DBUS |
|
43d41f5ce17b
Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents:
16763
diff
changeset
|
293 | static char *purple_dbus_owner_user_dir(void) |
|
43d41f5ce17b
Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents:
16763
diff
changeset
|
294 | { |
|
43d41f5ce17b
Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents:
16763
diff
changeset
|
295 | DBusMessage *msg = NULL, *reply = NULL; |
|
43d41f5ce17b
Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents:
16763
diff
changeset
|
296 | DBusConnection *dbus_connection = NULL; |
|
43d41f5ce17b
Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents:
16763
diff
changeset
|
297 | DBusError dbus_error; |
|
43d41f5ce17b
Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents:
16763
diff
changeset
|
298 | char *remote_user_dir = NULL; |
|
43d41f5ce17b
Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents:
16763
diff
changeset
|
299 | |
|
17122
5ba216aa4583
Style changes + removed unnecessary NULL checks.
Gabriel Schulhof <nix@go-nix.ca>
parents:
17121
diff
changeset
|
300 | if ((dbus_connection = purple_dbus_get_connection()) == NULL) |
|
17121
43d41f5ce17b
Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents:
16763
diff
changeset
|
301 | return NULL; |
|
43d41f5ce17b
Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents:
16763
diff
changeset
|
302 | |
|
17122
5ba216aa4583
Style changes + removed unnecessary NULL checks.
Gabriel Schulhof <nix@go-nix.ca>
parents:
17121
diff
changeset
|
303 | 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
|
304 | return NULL; |
|
43d41f5ce17b
Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents:
16763
diff
changeset
|
305 | |
|
43d41f5ce17b
Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents:
16763
diff
changeset
|
306 | dbus_error_init(&dbus_error); |
|
43d41f5ce17b
Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents:
16763
diff
changeset
|
307 | 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
|
308 | dbus_message_unref(msg); |
|
43d41f5ce17b
Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents:
16763
diff
changeset
|
309 | dbus_error_free(&dbus_error); |
|
43d41f5ce17b
Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents:
16763
diff
changeset
|
310 | |
| 17882 | 311 | if (reply) |
| 312 | { | |
|
17121
43d41f5ce17b
Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents:
16763
diff
changeset
|
313 | dbus_error_init(&dbus_error); |
|
43d41f5ce17b
Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents:
16763
diff
changeset
|
314 | 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
|
315 | remote_user_dir = g_strdup(remote_user_dir); |
|
17121
43d41f5ce17b
Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents:
16763
diff
changeset
|
316 | dbus_error_free(&dbus_error); |
|
43d41f5ce17b
Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents:
16763
diff
changeset
|
317 | dbus_message_unref(reply); |
|
17122
5ba216aa4583
Style changes + removed unnecessary NULL checks.
Gabriel Schulhof <nix@go-nix.ca>
parents:
17121
diff
changeset
|
318 | } |
|
17121
43d41f5ce17b
Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents:
16763
diff
changeset
|
319 | |
|
43d41f5ce17b
Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents:
16763
diff
changeset
|
320 | return remote_user_dir; |
|
43d41f5ce17b
Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents:
16763
diff
changeset
|
321 | } |
|
43d41f5ce17b
Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents:
16763
diff
changeset
|
322 | |
|
43d41f5ce17b
Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents:
16763
diff
changeset
|
323 | #endif /* HAVE_DBUS */ |
|
43d41f5ce17b
Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents:
16763
diff
changeset
|
324 | |
| 17882 | 325 | gboolean |
| 326 | purple_core_ensure_single_instance() | |
|
17121
43d41f5ce17b
Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents:
16763
diff
changeset
|
327 | { |
| 17882 | 328 | gboolean is_single_instance = TRUE; |
|
17121
43d41f5ce17b
Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents:
16763
diff
changeset
|
329 | #ifdef HAVE_DBUS |
|
17122
5ba216aa4583
Style changes + removed unnecessary NULL checks.
Gabriel Schulhof <nix@go-nix.ca>
parents:
17121
diff
changeset
|
330 | /* in the future, other mechanisms might have already set this to FALSE */ |
| 17882 | 331 | if (is_single_instance) |
| 332 | { | |
| 333 | if (!purple_dbus_is_owner()) | |
| 334 | { | |
|
17121
43d41f5ce17b
Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents:
16763
diff
changeset
|
335 | const char *user_dir = purple_user_dir(); |
|
43d41f5ce17b
Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents:
16763
diff
changeset
|
336 | 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
|
337 | |
|
43d41f5ce17b
Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents:
16763
diff
changeset
|
338 | if (NULL == user_dir && NULL != dbus_owner_user_dir) |
|
43d41f5ce17b
Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents:
16763
diff
changeset
|
339 | is_single_instance = TRUE; |
|
17122
5ba216aa4583
Style changes + removed unnecessary NULL checks.
Gabriel Schulhof <nix@go-nix.ca>
parents:
17121
diff
changeset
|
340 | 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
|
341 | is_single_instance = TRUE; |
|
17122
5ba216aa4583
Style changes + removed unnecessary NULL checks.
Gabriel Schulhof <nix@go-nix.ca>
parents:
17121
diff
changeset
|
342 | 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
|
343 | is_single_instance = FALSE; |
|
43d41f5ce17b
Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents:
16763
diff
changeset
|
344 | else |
|
43d41f5ce17b
Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents:
16763
diff
changeset
|
345 | 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
|
346 | |
|
43d41f5ce17b
Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents:
16763
diff
changeset
|
347 | g_free(dbus_owner_user_dir); |
|
43d41f5ce17b
Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents:
16763
diff
changeset
|
348 | } |
|
17122
5ba216aa4583
Style changes + removed unnecessary NULL checks.
Gabriel Schulhof <nix@go-nix.ca>
parents:
17121
diff
changeset
|
349 | } |
|
17121
43d41f5ce17b
Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents:
16763
diff
changeset
|
350 | #endif /* HAVE_DBUS */ |
|
17123
b1ef108e361b
Minor formatting tweaks for the dbus_uniq code.
Richard Laager <rlaager@pidgin.im>
parents:
17122
diff
changeset
|
351 | |
|
17121
43d41f5ce17b
Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents:
16763
diff
changeset
|
352 | return is_single_instance; |
|
43d41f5ce17b
Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents:
16763
diff
changeset
|
353 | } |
|
43d41f5ce17b
Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents:
16763
diff
changeset
|
354 | |
|
16409
8c153c6febdd
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents:
16124
diff
changeset
|
355 | 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
|
356 | 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
|
357 | { |
|
8c153c6febdd
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents:
16124
diff
changeset
|
358 | 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
|
359 | #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
|
360 | 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
|
361 | #endif |
|
8c153c6febdd
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents:
16124
diff
changeset
|
362 | 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
|
363 | { |
| 16763 | 364 | 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
|
365 | 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
|
366 | 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
|
367 | 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
|
368 | } |
|
8c153c6febdd
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents:
16124
diff
changeset
|
369 | 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
|
370 | |
|
8c153c6febdd
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents:
16124
diff
changeset
|
371 | #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
|
372 | /* 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
|
373 | 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
|
374 | 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
|
375 | 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
|
376 | { |
| 16763 | 377 | 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
|
378 | 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
|
379 | } |
|
8c153c6febdd
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents:
16124
diff
changeset
|
380 | 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
|
381 | 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
|
382 | #endif |
|
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 | 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
|
385 | } |
|
8c153c6febdd
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents:
16124
diff
changeset
|
386 | |
|
8c153c6febdd
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents:
16124
diff
changeset
|
387 | gboolean |
|
8c153c6febdd
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents:
16124
diff
changeset
|
388 | 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
|
389 | { |
|
8c153c6febdd
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents:
16124
diff
changeset
|
390 | 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
|
391 | 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
|
392 | 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
|
393 | 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
|
394 | 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
|
395 | 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
|
396 | 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
|
397 | 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
|
398 | #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
|
399 | 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
|
400 | #endif |
|
8c153c6febdd
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents:
16124
diff
changeset
|
401 | 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
|
402 | |
|
8c153c6febdd
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents:
16124
diff
changeset
|
403 | 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
|
404 | { |
|
8c153c6febdd
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents:
16124
diff
changeset
|
405 | /* ~/.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
|
406 | 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
|
407 | 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
|
408 | } |
|
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 | 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
|
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 | 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
|
413 | { |
|
8c153c6febdd
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents:
16124
diff
changeset
|
414 | /* 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
|
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 | 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
|
417 | { |
|
8c153c6febdd
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents:
16124
diff
changeset
|
418 | /* 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
|
419 | * 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
|
420 | 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
|
421 | 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
|
422 | 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
|
423 | } |
|
8c153c6febdd
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents:
16124
diff
changeset
|
424 | } |
|
8c153c6febdd
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents:
16124
diff
changeset
|
425 | |
|
8c153c6febdd
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents:
16124
diff
changeset
|
426 | /* 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
|
427 | |
|
8c153c6febdd
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents:
16124
diff
changeset
|
428 | /* 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
|
429 | 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
|
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 | 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
|
432 | { |
| 16763 | 433 | 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
|
434 | 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
|
435 | 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
|
436 | 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
|
437 | 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
|
438 | } |
|
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 | |
|
8c153c6febdd
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents:
16124
diff
changeset
|
441 | /* 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
|
442 | * 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
|
443 | 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
|
444 | { |
| 16763 | 445 | 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
|
446 | 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
|
447 | 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
|
448 | 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
|
449 | 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
|
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 | 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
|
452 | |
|
8c153c6febdd
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents:
16124
diff
changeset
|
453 | /* 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
|
454 | 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
|
455 | 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
|
456 | { |
| 16763 | 457 | 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
|
458 | 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
|
459 | (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
|
460 | 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
|
461 | 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
|
462 | 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
|
463 | 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
|
464 | 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
|
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 | /* 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
|
468 | 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
|
469 | { |
|
8c153c6febdd
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents:
16124
diff
changeset
|
470 | 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
|
471 | |
|
8c153c6febdd
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents:
16124
diff
changeset
|
472 | #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
|
473 | /* 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
|
474 | 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
|
475 | { |
|
8c153c6febdd
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents:
16124
diff
changeset
|
476 | /* 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
|
477 | 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
|
478 | { |
|
18220
c88669a9d3dd
Use dynamicly allocated string manipulation here as well to avoid a
Richard Laager <rlaager@pidgin.im>
parents:
18072
diff
changeset
|
479 | char *link; |
|
c88669a9d3dd
Use dynamicly allocated string manipulation here as well to avoid a
Richard Laager <rlaager@pidgin.im>
parents:
18072
diff
changeset
|
480 | #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
|
481 | GError *err = NULL; |
|
c88669a9d3dd
Use dynamicly allocated string manipulation here as well to avoid a
Richard Laager <rlaager@pidgin.im>
parents:
18072
diff
changeset
|
482 | |
|
c88669a9d3dd
Use dynamicly allocated string manipulation here as well to avoid a
Richard Laager <rlaager@pidgin.im>
parents:
18072
diff
changeset
|
483 | 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
|
484 | { |
|
c88669a9d3dd
Use dynamicly allocated string manipulation here as well to avoid a
Richard Laager <rlaager@pidgin.im>
parents:
18072
diff
changeset
|
485 | 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
|
486 | 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
|
487 | 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
|
488 | 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
|
489 | 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
|
490 | g_free(name); |
|
c88669a9d3dd
Use dynamicly allocated string manipulation here as well to avoid a
Richard Laager <rlaager@pidgin.im>
parents:
18072
diff
changeset
|
491 | 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
|
492 | 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
|
493 | 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
|
494 | return FALSE; |
|
c88669a9d3dd
Use dynamicly allocated string manipulation here as well to avoid a
Richard Laager <rlaager@pidgin.im>
parents:
18072
diff
changeset
|
495 | } |
|
c88669a9d3dd
Use dynamicly allocated string manipulation here as well to avoid a
Richard Laager <rlaager@pidgin.im>
parents:
18072
diff
changeset
|
496 | #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
|
497 | 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
|
498 | 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
|
499 | |
|
16666
44017931b1e7
#386: readlink does not append NUL to the end of buffer
Ka-Hing Cheung <khc@pidgin.im>
parents:
16660
diff
changeset
|
500 | 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
|
501 | { |
|
18267
076446fd04a3
Bring back MAXPATHLEN (which was always guaranteed to be defined earlier
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
18220
diff
changeset
|
502 | char *name_utf8 = g_filename_to_utf8(name, -1, NULL, NULL, NULL); |
| 16763 | 503 | 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
|
504 | 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
|
505 | 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
|
506 | 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
|
507 | 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
|
508 | 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
|
509 | 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
|
510 | 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
|
511 | } |
|
16666
44017931b1e7
#386: readlink does not append NUL to the end of buffer
Ka-Hing Cheung <khc@pidgin.im>
parents:
16660
diff
changeset
|
512 | 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
|
513 | |
|
18220
c88669a9d3dd
Use dynamicly allocated string manipulation here as well to avoid a
Richard Laager <rlaager@pidgin.im>
parents:
18072
diff
changeset
|
514 | /* 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
|
515 | 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
|
516 | #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
|
517 | |
|
18220
c88669a9d3dd
Use dynamicly allocated string manipulation here as well to avoid a
Richard Laager <rlaager@pidgin.im>
parents:
18072
diff
changeset
|
518 | 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
|
519 | |
|
c88669a9d3dd
Use dynamicly allocated string manipulation here as well to avoid a
Richard Laager <rlaager@pidgin.im>
parents:
18072
diff
changeset
|
520 | 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
|
521 | { |
|
8c153c6febdd
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents:
16124
diff
changeset
|
522 | /* 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
|
523 | * 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
|
524 | * 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
|
525 | 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
|
526 | 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
|
527 | continue; |
|
8c153c6febdd
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents:
16124
diff
changeset
|
528 | } |
|
8c153c6febdd
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents:
16124
diff
changeset
|
529 | |
|
8c153c6febdd
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents:
16124
diff
changeset
|
530 | /* 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
|
531 | * 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
|
532 | * 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
|
533 | * 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
|
534 | 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
|
535 | |
|
8c153c6febdd
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents:
16124
diff
changeset
|
536 | /* 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
|
537 | * 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
|
538 | * 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
|
539 | 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
|
540 | { |
| 16763 | 541 | 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
|
542 | 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
|
543 | 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
|
544 | 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
|
545 | 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
|
546 | 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
|
547 | 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
|
548 | 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
|
549 | 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
|
550 | } |
|
8c153c6febdd
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents:
16124
diff
changeset
|
551 | |
|
18220
c88669a9d3dd
Use dynamicly allocated string manipulation here as well to avoid a
Richard Laager <rlaager@pidgin.im>
parents:
18072
diff
changeset
|
552 | 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
|
553 | 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
|
554 | continue; |
|
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 | |
|
8c153c6febdd
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents:
16124
diff
changeset
|
557 | /* 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
|
558 | continue; |
|
8c153c6febdd
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents:
16124
diff
changeset
|
559 | } |
|
8c153c6febdd
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents:
16124
diff
changeset
|
560 | #endif |
|
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 | /* 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
|
563 | 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
|
564 | { |
|
8c153c6febdd
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents:
16124
diff
changeset
|
565 | 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
|
566 | { |
|
8c153c6febdd
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents:
16124
diff
changeset
|
567 | /* 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
|
568 | * 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
|
569 | * 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
|
570 | * 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
|
571 | * 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
|
572 | |
|
8c153c6febdd
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents:
16124
diff
changeset
|
573 | 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
|
574 | 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
|
575 | 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
|
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 | 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
|
578 | 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
|
579 | { |
| 16763 | 580 | 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
|
581 | name, |
|
8c153c6febdd
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents:
16124
diff
changeset
|
582 | (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
|
583 | 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
|
584 | 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
|
585 | 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
|
586 | 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
|
587 | 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
|
588 | 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
|
589 | 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
|
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 | |
|
8c153c6febdd
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents:
16124
diff
changeset
|
592 | 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
|
593 | /* 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
|
594 | 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
|
595 | { |
|
8c153c6febdd
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents:
16124
diff
changeset
|
596 | 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
|
597 | { |
| 16763 | 598 | 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
|
599 | 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
|
600 | 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
|
601 | 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
|
602 | 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
|
603 | 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
|
604 | 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
|
605 | 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
|
606 | 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
|
607 | } |
|
8c153c6febdd
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents:
16124
diff
changeset
|
608 | } |
|
8c153c6febdd
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents:
16124
diff
changeset
|
609 | |
|
8c153c6febdd
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents:
16124
diff
changeset
|
610 | 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
|
611 | { |
|
8c153c6febdd
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents:
16124
diff
changeset
|
612 | 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
|
613 | |
|
8c153c6febdd
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents:
16124
diff
changeset
|
614 | 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
|
615 | { |
|
8c153c6febdd
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents:
16124
diff
changeset
|
616 | 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
|
617 | 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
|
618 | { |
|
8c153c6febdd
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents:
16124
diff
changeset
|
619 | 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
|
620 | 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
|
621 | 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
|
622 | 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
|
623 | 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
|
624 | 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
|
625 | 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
|
626 | 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
|
627 | } |
|
8c153c6febdd
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents:
16124
diff
changeset
|
628 | } |
|
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_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
|
630 | } |
|
8c153c6febdd
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents:
16124
diff
changeset
|
631 | |
|
8c153c6febdd
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents:
16124
diff
changeset
|
632 | 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
|
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 | 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
|
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 | /* 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
|
637 | * 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
|
638 | } |
|
8c153c6febdd
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents:
16124
diff
changeset
|
639 | else |
|
8c153c6febdd
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents:
16124
diff
changeset
|
640 | { |
|
8c153c6febdd
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents:
16124
diff
changeset
|
641 | /* 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
|
642 | 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
|
643 | { |
|
8c153c6febdd
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents:
16124
diff
changeset
|
644 | 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
|
645 | 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
|
646 | 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
|
647 | 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
|
648 | 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
|
649 | } |
|
8c153c6febdd
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents:
16124
diff
changeset
|
650 | } |
|
8c153c6febdd
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents:
16124
diff
changeset
|
651 | } |
|
8c153c6febdd
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents:
16124
diff
changeset
|
652 | 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
|
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 | /* 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
|
655 | |
|
8c153c6febdd
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents:
16124
diff
changeset
|
656 | 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
|
657 | 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
|
658 | |
|
8c153c6febdd
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents:
16124
diff
changeset
|
659 | 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
|
660 | { |
| 16763 | 661 | 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
|
662 | 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
|
663 | 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
|
664 | 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
|
665 | 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
|
666 | 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
|
667 | 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
|
668 | } |
|
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 | 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
|
671 | 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
|
672 | { |
| 16763 | 673 | 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
|
674 | 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
|
675 | 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
|
676 | 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
|
677 | 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
|
678 | 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
|
679 | 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
|
680 | 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
|
681 | 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
|
682 | } |
|
8c153c6febdd
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents:
16124
diff
changeset
|
683 | |
|
8c153c6febdd
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents:
16124
diff
changeset
|
684 | 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
|
685 | { |
|
8c153c6febdd
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents:
16124
diff
changeset
|
686 | 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
|
687 | 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
|
688 | |
|
8c153c6febdd
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents:
16124
diff
changeset
|
689 | 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
|
690 | 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
|
691 | { |
| 16763 | 692 | 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
|
693 | 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
|
694 | 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
|
695 | 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
|
696 | 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
|
697 | 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
|
698 | 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
|
699 | 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
|
700 | 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
|
701 | 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
|
702 | } |
|
8c153c6febdd
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents:
16124
diff
changeset
|
703 | |
|
16554
63f70c76f8c5
Proper error checking on fwrite() call
Sean Egan <seanegan@pidgin.im>
parents:
16546
diff
changeset
|
704 | 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
|
705 | { |
| 16763 | 706 | 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
|
707 | 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
|
708 | 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
|
709 | 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
|
710 | 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
|
711 | 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
|
712 | 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
|
713 | 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
|
714 | 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
|
715 | 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
|
716 | } |
|
8c153c6febdd
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents:
16124
diff
changeset
|
717 | } |
|
8c153c6febdd
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents:
16124
diff
changeset
|
718 | |
|
8c153c6febdd
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents:
16124
diff
changeset
|
719 | 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
|
720 | { |
| 16763 | 721 | 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
|
722 | 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
|
723 | } |
|
8c153c6febdd
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents:
16124
diff
changeset
|
724 | 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
|
725 | { |
|
8c153c6febdd
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents:
16124
diff
changeset
|
726 | 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
|
727 | 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
|
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 | 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
|
730 | } |
|
8c153c6febdd
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents:
16124
diff
changeset
|
731 | else |
|
8c153c6febdd
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents:
16124
diff
changeset
|
732 | 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
|
733 | |
|
8c153c6febdd
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents:
16124
diff
changeset
|
734 | 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
|
735 | } |
|
8c153c6febdd
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents:
16124
diff
changeset
|
736 | |
|
8c153c6febdd
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents:
16124
diff
changeset
|
737 | /* 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
|
738 | 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
|
739 | { |
| 16763 | 740 | 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
|
741 | 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
|
742 | 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
|
743 | 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
|
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 | |
|
8c153c6febdd
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@pidgin.im>
parents:
16124
diff
changeset
|
746 | 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
|
747 | _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
|
748 | 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
|
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 | 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
|
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 | 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
|
753 | 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
|
754 | } |
|
18441
d255d04c0aa1
core support for UI info...now to do the UI piece
Nathan Walp <nwalp@pidgin.im>
parents:
18303
diff
changeset
|
755 | |
|
d255d04c0aa1
core support for UI info...now to do the UI piece
Nathan Walp <nwalp@pidgin.im>
parents:
18303
diff
changeset
|
756 | 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
|
757 | 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
|
758 | |
|
d255d04c0aa1
core support for UI info...now to do the UI piece
Nathan Walp <nwalp@pidgin.im>
parents:
18303
diff
changeset
|
759 | 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
|
760 | return NULL; |
|
d255d04c0aa1
core support for UI info...now to do the UI piece
Nathan Walp <nwalp@pidgin.im>
parents:
18303
diff
changeset
|
761 | |
|
d255d04c0aa1
core support for UI info...now to do the UI piece
Nathan Walp <nwalp@pidgin.im>
parents:
18303
diff
changeset
|
762 | 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
|
763 | } |