Mercurial > pidgin.yaz
annotate libpurple/core.c @ 25875:dfd7be3e3cb7
Backport 96cf043274a971d5a2b9e01ef85fb60ca2a4bcd1 (#8747 - Crash when a prpl has no protocol options.)
author | Daniel Atallah <daniel.atallah@gmail.com> |
---|---|
date | Thu, 30 Apr 2009 05:18:04 +0000 |
parents | 1bfc20b76bb2 |
children | 01f1929d0936 |
rev | line source |
---|---|
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1 /** |
15823 | 2 * @file core.c Purple Core API |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3 * @ingroup core |
20074
6bf32c9e15a7
remove gpl boilerplate from doxygen docs
Sean Egan <seanegan@gmail.com>
parents:
19680
diff
changeset
|
4 */ |
6bf32c9e15a7
remove gpl boilerplate from doxygen docs
Sean Egan <seanegan@gmail.com>
parents:
19680
diff
changeset
|
5 |
6bf32c9e15a7
remove gpl boilerplate from doxygen docs
Sean Egan <seanegan@gmail.com>
parents:
19680
diff
changeset
|
6 /* purple |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
7 * |
15823 | 8 * Purple is the legal property of its developers, whose names are too numerous |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
9 * to list here. Please refer to the COPYRIGHT file distributed with this |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
10 * source distribution. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
11 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
12 * This program is free software; you can redistribute it and/or modify |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
13 * it under the terms of the GNU General Public License as published by |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
14 * the Free Software Foundation; either version 2 of the License, or |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
15 * (at your option) any later version. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
16 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
17 * This program is distributed in the hope that it will be useful, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
20 * GNU General Public License for more details. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
21 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
22 * You should have received a copy of the GNU General Public License |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
23 * along with this program; if not, write to the Free Software |
19680
44b4e8bd759b
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19512
diff
changeset
|
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
25 */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
26 #include "internal.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
27 #include "cipher.h" |
18957
9205841eed06
- Certificate system now has init and uninit like other systems
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18224
diff
changeset
|
28 #include "certificate.h" |
23414
b5f679e95666
cmd-added and cmd-removed signals to emit when commands are registered/unregistered.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23204
diff
changeset
|
29 #include "cmds.h" |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
30 #include "connection.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
31 #include "conversation.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
32 #include "core.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
33 #include "debug.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
34 #include "dnsquery.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
35 #include "ft.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
36 #include "idle.h" |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16341
diff
changeset
|
37 #include "imgstore.h" |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
38 #include "network.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
39 #include "notify.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
40 #include "plugin.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
41 #include "pounce.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
42 #include "prefs.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
43 #include "privacy.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
44 #include "proxy.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
45 #include "savedstatuses.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
46 #include "signals.h" |
22874
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21418
diff
changeset
|
47 #include "smiley.h" |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
48 #include "sound.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
49 #include "sslconn.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
50 #include "status.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
51 #include "stun.h" |
16341
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
52 #include "util.h" |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
53 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
54 #ifdef HAVE_DBUS |
22434
48d09d62912e
Avoid a compile warning when building with NetworkManager support because
Stu Tomlinson <stu@nosnilmot.com>
parents:
21418
diff
changeset
|
55 # ifndef DBUS_API_SUBJECT_TO_CHANGE |
48d09d62912e
Avoid a compile warning when building with NetworkManager support because
Stu Tomlinson <stu@nosnilmot.com>
parents:
21418
diff
changeset
|
56 # define DBUS_API_SUBJECT_TO_CHANGE |
48d09d62912e
Avoid a compile warning when building with NetworkManager support because
Stu Tomlinson <stu@nosnilmot.com>
parents:
21418
diff
changeset
|
57 # endif |
17123
176d0fc8bc16
Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents:
16700
diff
changeset
|
58 # include <dbus/dbus.h> |
176d0fc8bc16
Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents:
16700
diff
changeset
|
59 # include "dbus-purple.h" |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
60 # include "dbus-server.h" |
17123
176d0fc8bc16
Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents:
16700
diff
changeset
|
61 # include "dbus-bindings.h" |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
62 #endif |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
63 |
15823 | 64 struct PurpleCore |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
65 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
66 char *ui; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
67 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
68 void *reserved; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
69 }; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
70 |
15823 | 71 static PurpleCoreUiOps *_ops = NULL; |
72 static PurpleCore *_core = NULL; | |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
73 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
74 STATIC_PROTO_INIT |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
75 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
76 gboolean |
15823 | 77 purple_core_init(const char *ui) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
78 { |
15823 | 79 PurpleCoreUiOps *ops; |
80 PurpleCore *core; | |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
81 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
82 g_return_val_if_fail(ui != NULL, FALSE); |
15823 | 83 g_return_val_if_fail(purple_get_core() == NULL, FALSE); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
84 |
16063
fa8aeab4ca5a
Hopefully prevent libpurple causing problems for 3rd party UIs if they also
Stu Tomlinson <stu@nosnilmot.com>
parents:
15823
diff
changeset
|
85 #ifdef ENABLE_NLS |
fa8aeab4ca5a
Hopefully prevent libpurple causing problems for 3rd party UIs if they also
Stu Tomlinson <stu@nosnilmot.com>
parents:
15823
diff
changeset
|
86 bindtextdomain(PACKAGE, LOCALEDIR); |
fa8aeab4ca5a
Hopefully prevent libpurple causing problems for 3rd party UIs if they also
Stu Tomlinson <stu@nosnilmot.com>
parents:
15823
diff
changeset
|
87 #endif |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
88 #ifdef _WIN32 |
15823 | 89 wpurple_init(); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
90 #endif |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
91 |
22975
9331f4c7f6d8
Initialize the glib type system early in purple_core_init() too so UIs
Stu Tomlinson <stu@nosnilmot.com>
parents:
22716
diff
changeset
|
92 g_type_init(); |
9331f4c7f6d8
Initialize the glib type system early in purple_core_init() too so UIs
Stu Tomlinson <stu@nosnilmot.com>
parents:
22716
diff
changeset
|
93 |
15823 | 94 _core = core = g_new0(PurpleCore, 1); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
95 core->ui = g_strdup(ui); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
96 core->reserved = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
97 |
15823 | 98 ops = purple_core_get_ui_ops(); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
99 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
100 /* The signals subsystem is important and should be first. */ |
15823 | 101 purple_signals_init(); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
102 |
21248
5915ad785ee7
Add and call a purple_util_uninit() to free user_dir and customer_home_dir
Richard Laager <rlaager@wiktel.com>
parents:
20074
diff
changeset
|
103 purple_util_init(); |
5915ad785ee7
Add and call a purple_util_uninit() to free user_dir and customer_home_dir
Richard Laager <rlaager@wiktel.com>
parents:
20074
diff
changeset
|
104 |
15823 | 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 */ | |
15613
b0471b2a1de9
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 <daniel.atallah@gmail.com>
parents:
15374
diff
changeset
|
111 |
15823 | 112 purple_signal_register(core, "quitting", purple_marshal_VOID, NULL, 0); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
113 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
114 /* The prefs subsystem needs to be initialized before static protocols |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
115 * for protocol prefs to work. */ |
15823 | 116 purple_prefs_init(); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
117 |
15823 | 118 purple_debug_init(); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
119 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
120 if (ops != NULL) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
121 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
122 if (ops->ui_prefs_init != NULL) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
123 ops->ui_prefs_init(); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
124 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
125 if (ops->debug_ui_init != NULL) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
126 ops->debug_ui_init(); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
127 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
128 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
129 #ifdef HAVE_DBUS |
15823 | 130 purple_dbus_init(); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
131 #endif |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
132 |
16599
976a9b4c336a
Part of the patch in ticket #383:
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16548
diff
changeset
|
133 purple_ciphers_init(); |
23580
fae54e746bde
Initialize the commands subsystem before the plugins.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23414
diff
changeset
|
134 purple_cmds_init(); |
16599
976a9b4c336a
Part of the patch in ticket #383:
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16548
diff
changeset
|
135 |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
136 /* Since plugins get probed so early we should probably initialize their |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
137 * subsystem right away too. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
138 */ |
15823 | 139 purple_plugins_init(); |
24869
cf8c060cdd25
disapproval of revision 'd61c2fc82b19cd2629b498d903d7018d41a00108'
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24868
diff
changeset
|
140 |
23204
aa6395907702
If plugins are enabled and some protocols or plugins are also being compiled
Evan Schoenberg <evan.s@dreskin.net>
parents:
23192
diff
changeset
|
141 /* Initialize all static protocols. */ |
aa6395907702
If plugins are enabled and some protocols or plugins are also being compiled
Evan Schoenberg <evan.s@dreskin.net>
parents:
23192
diff
changeset
|
142 static_proto_init(); |
aa6395907702
If plugins are enabled and some protocols or plugins are also being compiled
Evan Schoenberg <evan.s@dreskin.net>
parents:
23192
diff
changeset
|
143 |
15823 | 144 purple_plugins_probe(G_MODULE_SUFFIX); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
145 |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16341
diff
changeset
|
146 /* The buddy icon code uses the imgstore, so init it early. */ |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16341
diff
changeset
|
147 purple_imgstore_init(); |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16341
diff
changeset
|
148 |
21370
0aa18e21a595
Connect to connection-error in account.c so that the account error is actually
Will Thompson <will.thompson@collabora.co.uk>
parents:
21248
diff
changeset
|
149 /* Accounts use status, buddy icons and connection signals, so |
0aa18e21a595
Connect to connection-error in account.c so that the account error is actually
Will Thompson <will.thompson@collabora.co.uk>
parents:
21248
diff
changeset
|
150 * initialize these before accounts |
0aa18e21a595
Connect to connection-error in account.c so that the account error is actually
Will Thompson <will.thompson@collabora.co.uk>
parents:
21248
diff
changeset
|
151 */ |
15823 | 152 purple_status_init(); |
153 purple_buddy_icons_init(); | |
21370
0aa18e21a595
Connect to connection-error in account.c so that the account error is actually
Will Thompson <will.thompson@collabora.co.uk>
parents:
21248
diff
changeset
|
154 purple_connections_init(); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
155 |
15823 | 156 purple_accounts_init(); |
157 purple_savedstatuses_init(); | |
158 purple_notify_init(); | |
18957
9205841eed06
- Certificate system now has init and uninit like other systems
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18224
diff
changeset
|
159 purple_certificate_init(); |
15823 | 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(); | |
22874
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21418
diff
changeset
|
173 purple_smileys_init(); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
174 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
175 /* |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
176 * Call this early on to try to auto-detect our IP address and |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
177 * hopefully save some time later. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
178 */ |
19512
c88e64f1ed76
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 <daniel.atallah@gmail.com>
parents:
19200
diff
changeset
|
179 purple_network_get_my_ip(-1); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
180 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
181 if (ops != NULL && ops->ui_init != NULL) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
182 ops->ui_init(); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
183 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
184 return TRUE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
185 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
186 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
187 void |
15823 | 188 purple_core_quit(void) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
189 { |
15823 | 190 PurpleCoreUiOps *ops; |
191 PurpleCore *core = purple_get_core(); | |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
192 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
193 g_return_if_fail(core != NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
194 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
195 /* The self destruct sequence has been initiated */ |
15823 | 196 purple_signal_emit(purple_get_core(), "quitting"); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
197 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
198 /* Transmission ends */ |
15823 | 199 purple_connections_disconnect_all(); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
200 |
24999
fc8fd4fef166
Fix a crash on exit with a patch from im.pidgin.next.minor.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24979
diff
changeset
|
201 /* |
fc8fd4fef166
Fix a crash on exit with a patch from im.pidgin.next.minor.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24979
diff
changeset
|
202 * Certificates must be destroyed before the SSL plugins, because |
fc8fd4fef166
Fix a crash on exit with a patch from im.pidgin.next.minor.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24979
diff
changeset
|
203 * PurpleCertificates contain pointers to PurpleCertificateSchemes, |
fc8fd4fef166
Fix a crash on exit with a patch from im.pidgin.next.minor.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24979
diff
changeset
|
204 * and the PurpleCertificateSchemes will be unregistered when the |
fc8fd4fef166
Fix a crash on exit with a patch from im.pidgin.next.minor.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24979
diff
changeset
|
205 * SSL plugin is uninit. |
fc8fd4fef166
Fix a crash on exit with a patch from im.pidgin.next.minor.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24979
diff
changeset
|
206 */ |
fc8fd4fef166
Fix a crash on exit with a patch from im.pidgin.next.minor.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24979
diff
changeset
|
207 purple_certificate_uninit(); |
fc8fd4fef166
Fix a crash on exit with a patch from im.pidgin.next.minor.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24979
diff
changeset
|
208 |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
209 /* Save .xml files, remove signals, etc. */ |
22874
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21418
diff
changeset
|
210 purple_smileys_uninit(); |
15823 | 211 purple_idle_uninit(); |
212 purple_pounces_uninit(); | |
213 purple_blist_uninit(); | |
214 purple_ciphers_uninit(); | |
215 purple_notify_uninit(); | |
216 purple_conversations_uninit(); | |
217 purple_connections_uninit(); | |
218 purple_buddy_icons_uninit(); | |
219 purple_accounts_uninit(); | |
220 purple_savedstatuses_uninit(); | |
221 purple_status_uninit(); | |
23192
ead0e6aa9c46
Revert 159826573dec53526cd1237639fdf5cf13826cf4 to fix a TODO about calling
Richard Laager <rlaager@wiktel.com>
parents:
23161
diff
changeset
|
222 purple_sound_uninit(); |
15823 | 223 purple_xfers_uninit(); |
224 purple_proxy_uninit(); | |
225 purple_dnsquery_uninit(); | |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16341
diff
changeset
|
226 purple_imgstore_uninit(); |
24856
a6742d9eadf3
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <paul@darkrain42.org>
parents:
24113
diff
changeset
|
227 purple_network_uninit(); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
228 |
25858
1bfc20b76bb2
Alternate, API-safe fix for #8774 (crash on exit)
Ethan Blanton <elb@pidgin.im>
parents:
25857
diff
changeset
|
229 /* The SSL plugins must be uninit before they're unloaded */ |
1bfc20b76bb2
Alternate, API-safe fix for #8774 (crash on exit)
Ethan Blanton <elb@pidgin.im>
parents:
25857
diff
changeset
|
230 purple_ssl_uninit(); |
1bfc20b76bb2
Alternate, API-safe fix for #8774 (crash on exit)
Ethan Blanton <elb@pidgin.im>
parents:
25857
diff
changeset
|
231 |
1bfc20b76bb2
Alternate, API-safe fix for #8774 (crash on exit)
Ethan Blanton <elb@pidgin.im>
parents:
25857
diff
changeset
|
232 purple_debug_info("main", "Unloading all plugins\n"); |
1bfc20b76bb2
Alternate, API-safe fix for #8774 (crash on exit)
Ethan Blanton <elb@pidgin.im>
parents:
25857
diff
changeset
|
233 purple_plugins_destroy_all(); |
1bfc20b76bb2
Alternate, API-safe fix for #8774 (crash on exit)
Ethan Blanton <elb@pidgin.im>
parents:
25857
diff
changeset
|
234 |
1bfc20b76bb2
Alternate, API-safe fix for #8774 (crash on exit)
Ethan Blanton <elb@pidgin.im>
parents:
25857
diff
changeset
|
235 ops = purple_core_get_ui_ops(); |
1bfc20b76bb2
Alternate, API-safe fix for #8774 (crash on exit)
Ethan Blanton <elb@pidgin.im>
parents:
25857
diff
changeset
|
236 if (ops != NULL && ops->quit != NULL) |
1bfc20b76bb2
Alternate, API-safe fix for #8774 (crash on exit)
Ethan Blanton <elb@pidgin.im>
parents:
25857
diff
changeset
|
237 ops->quit(); |
1bfc20b76bb2
Alternate, API-safe fix for #8774 (crash on exit)
Ethan Blanton <elb@pidgin.im>
parents:
25857
diff
changeset
|
238 |
25857
d5cf115b7c58
disapproval of revision '2f2d084c77a5b905a47b7b28508172451a2bb82f'
Ethan Blanton <elb@pidgin.im>
parents:
25856
diff
changeset
|
239 /* Everything after this must not try to read any prefs */ |
24974
114e66c2fa7e
Reorder (and document) purple_core_quit() so that the prefs_uninit() fixes can
Paul Aurich <paul@darkrain42.org>
parents:
24868
diff
changeset
|
240 purple_prefs_uninit(); |
15823 | 241 purple_plugins_uninit(); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
242 #ifdef HAVE_DBUS |
15823 | 243 purple_dbus_uninit(); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
244 #endif |
21248
5915ad785ee7
Add and call a purple_util_uninit() to free user_dir and customer_home_dir
Richard Laager <rlaager@wiktel.com>
parents:
20074
diff
changeset
|
245 |
23580
fae54e746bde
Initialize the commands subsystem before the plugins.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23414
diff
changeset
|
246 purple_cmds_uninit(); |
25857
d5cf115b7c58
disapproval of revision '2f2d084c77a5b905a47b7b28508172451a2bb82f'
Ethan Blanton <elb@pidgin.im>
parents:
25856
diff
changeset
|
247 /* Everything after this cannot try to write things to the confdir */ |
21248
5915ad785ee7
Add and call a purple_util_uninit() to free user_dir and customer_home_dir
Richard Laager <rlaager@wiktel.com>
parents:
20074
diff
changeset
|
248 purple_util_uninit(); |
5915ad785ee7
Add and call a purple_util_uninit() to free user_dir and customer_home_dir
Richard Laager <rlaager@wiktel.com>
parents:
20074
diff
changeset
|
249 |
18224
73ea3328b0d1
Uninit the dbus system before uniniting the signals.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18204
diff
changeset
|
250 purple_signals_uninit(); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
251 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
252 g_free(core->ui); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
253 g_free(core); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
254 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
255 #ifdef _WIN32 |
15823 | 256 wpurple_cleanup(); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
257 #endif |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
258 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
259 _core = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
260 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
261 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
262 gboolean |
15823 | 263 purple_core_quit_cb(gpointer unused) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
264 { |
15823 | 265 purple_core_quit(); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
266 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
267 return FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
268 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
269 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
270 const char * |
15823 | 271 purple_core_get_version(void) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
272 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
273 return VERSION; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
274 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
275 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
276 const char * |
15823 | 277 purple_core_get_ui(void) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
278 { |
15823 | 279 PurpleCore *core = purple_get_core(); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
280 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
281 g_return_val_if_fail(core != NULL, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
282 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
283 return core->ui; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
284 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
285 |
15823 | 286 PurpleCore * |
287 purple_get_core(void) | |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
288 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
289 return _core; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
290 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
291 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
292 void |
15823 | 293 purple_core_set_ui_ops(PurpleCoreUiOps *ops) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
294 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
295 _ops = ops; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
296 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
297 |
15823 | 298 PurpleCoreUiOps * |
299 purple_core_get_ui_ops(void) | |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
300 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
301 return _ops; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
302 } |
16341
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
303 |
17123
176d0fc8bc16
Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents:
16700
diff
changeset
|
304 #ifdef HAVE_DBUS |
176d0fc8bc16
Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents:
16700
diff
changeset
|
305 static char *purple_dbus_owner_user_dir(void) |
176d0fc8bc16
Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents:
16700
diff
changeset
|
306 { |
176d0fc8bc16
Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents:
16700
diff
changeset
|
307 DBusMessage *msg = NULL, *reply = NULL; |
176d0fc8bc16
Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents:
16700
diff
changeset
|
308 DBusConnection *dbus_connection = NULL; |
176d0fc8bc16
Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents:
16700
diff
changeset
|
309 DBusError dbus_error; |
176d0fc8bc16
Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents:
16700
diff
changeset
|
310 char *remote_user_dir = NULL; |
176d0fc8bc16
Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents:
16700
diff
changeset
|
311 |
17124
601594a64190
Style changes + removed unnecessary NULL checks.
Gabriel Schulhof <nix@go-nix.ca>
parents:
17123
diff
changeset
|
312 if ((dbus_connection = purple_dbus_get_connection()) == NULL) |
17123
176d0fc8bc16
Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents:
16700
diff
changeset
|
313 return NULL; |
176d0fc8bc16
Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents:
16700
diff
changeset
|
314 |
17124
601594a64190
Style changes + removed unnecessary NULL checks.
Gabriel Schulhof <nix@go-nix.ca>
parents:
17123
diff
changeset
|
315 if ((msg = dbus_message_new_method_call(DBUS_SERVICE_PURPLE, DBUS_PATH_PURPLE, DBUS_INTERFACE_PURPLE, "PurpleUserDir")) == NULL) |
17123
176d0fc8bc16
Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents:
16700
diff
changeset
|
316 return NULL; |
176d0fc8bc16
Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents:
16700
diff
changeset
|
317 |
176d0fc8bc16
Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents:
16700
diff
changeset
|
318 dbus_error_init(&dbus_error); |
176d0fc8bc16
Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents:
16700
diff
changeset
|
319 reply = dbus_connection_send_with_reply_and_block(dbus_connection, msg, 5000, &dbus_error); |
176d0fc8bc16
Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents:
16700
diff
changeset
|
320 dbus_message_unref(msg); |
176d0fc8bc16
Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents:
16700
diff
changeset
|
321 dbus_error_free(&dbus_error); |
176d0fc8bc16
Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents:
16700
diff
changeset
|
322 |
17211 | 323 if (reply) |
324 { | |
17123
176d0fc8bc16
Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents:
16700
diff
changeset
|
325 dbus_error_init(&dbus_error); |
176d0fc8bc16
Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents:
16700
diff
changeset
|
326 dbus_message_get_args(reply, &dbus_error, DBUS_TYPE_STRING, &remote_user_dir, DBUS_TYPE_INVALID); |
17128
9d5121f2ab5d
Minor formatting tweaks for the dbus_uniq code.
Richard Laager <rlaager@wiktel.com>
parents:
17124
diff
changeset
|
327 remote_user_dir = g_strdup(remote_user_dir); |
17123
176d0fc8bc16
Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents:
16700
diff
changeset
|
328 dbus_error_free(&dbus_error); |
176d0fc8bc16
Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents:
16700
diff
changeset
|
329 dbus_message_unref(reply); |
17124
601594a64190
Style changes + removed unnecessary NULL checks.
Gabriel Schulhof <nix@go-nix.ca>
parents:
17123
diff
changeset
|
330 } |
17123
176d0fc8bc16
Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents:
16700
diff
changeset
|
331 |
176d0fc8bc16
Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents:
16700
diff
changeset
|
332 return remote_user_dir; |
176d0fc8bc16
Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents:
16700
diff
changeset
|
333 } |
176d0fc8bc16
Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents:
16700
diff
changeset
|
334 |
176d0fc8bc16
Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents:
16700
diff
changeset
|
335 #endif /* HAVE_DBUS */ |
176d0fc8bc16
Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents:
16700
diff
changeset
|
336 |
17211 | 337 gboolean |
338 purple_core_ensure_single_instance() | |
17123
176d0fc8bc16
Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents:
16700
diff
changeset
|
339 { |
17211 | 340 gboolean is_single_instance = TRUE; |
17123
176d0fc8bc16
Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents:
16700
diff
changeset
|
341 #ifdef HAVE_DBUS |
17124
601594a64190
Style changes + removed unnecessary NULL checks.
Gabriel Schulhof <nix@go-nix.ca>
parents:
17123
diff
changeset
|
342 /* in the future, other mechanisms might have already set this to FALSE */ |
17211 | 343 if (is_single_instance) |
344 { | |
345 if (!purple_dbus_is_owner()) | |
346 { | |
17123
176d0fc8bc16
Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents:
16700
diff
changeset
|
347 const char *user_dir = purple_user_dir(); |
176d0fc8bc16
Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents:
16700
diff
changeset
|
348 char *dbus_owner_user_dir = purple_dbus_owner_user_dir(); |
176d0fc8bc16
Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents:
16700
diff
changeset
|
349 |
176d0fc8bc16
Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents:
16700
diff
changeset
|
350 if (NULL == user_dir && NULL != dbus_owner_user_dir) |
176d0fc8bc16
Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents:
16700
diff
changeset
|
351 is_single_instance = TRUE; |
17124
601594a64190
Style changes + removed unnecessary NULL checks.
Gabriel Schulhof <nix@go-nix.ca>
parents:
17123
diff
changeset
|
352 else if (NULL != user_dir && NULL == dbus_owner_user_dir) |
17123
176d0fc8bc16
Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents:
16700
diff
changeset
|
353 is_single_instance = TRUE; |
17124
601594a64190
Style changes + removed unnecessary NULL checks.
Gabriel Schulhof <nix@go-nix.ca>
parents:
17123
diff
changeset
|
354 else if (NULL == user_dir && NULL == dbus_owner_user_dir) |
17123
176d0fc8bc16
Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents:
16700
diff
changeset
|
355 is_single_instance = FALSE; |
176d0fc8bc16
Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents:
16700
diff
changeset
|
356 else |
176d0fc8bc16
Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents:
16700
diff
changeset
|
357 is_single_instance = strcmp(dbus_owner_user_dir, user_dir); |
176d0fc8bc16
Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents:
16700
diff
changeset
|
358 |
176d0fc8bc16
Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents:
16700
diff
changeset
|
359 g_free(dbus_owner_user_dir); |
176d0fc8bc16
Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents:
16700
diff
changeset
|
360 } |
17124
601594a64190
Style changes + removed unnecessary NULL checks.
Gabriel Schulhof <nix@go-nix.ca>
parents:
17123
diff
changeset
|
361 } |
17123
176d0fc8bc16
Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents:
16700
diff
changeset
|
362 #endif /* HAVE_DBUS */ |
17128
9d5121f2ab5d
Minor formatting tweaks for the dbus_uniq code.
Richard Laager <rlaager@wiktel.com>
parents:
17124
diff
changeset
|
363 |
17123
176d0fc8bc16
Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents:
16700
diff
changeset
|
364 return is_single_instance; |
176d0fc8bc16
Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents:
16700
diff
changeset
|
365 } |
176d0fc8bc16
Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents:
16700
diff
changeset
|
366 |
16341
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
367 static gboolean |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
368 move_and_symlink_dir(const char *path, const char *basename, const char *old_base, const char *new_base, const char *relative) |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
369 { |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
370 char *new_name = g_build_filename(new_base, basename, NULL); |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
371 #ifndef _WIN32 |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
372 char *old_name; |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
373 #endif |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
374 if (g_rename(path, new_name)) |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
375 { |
24113
a29ae9a5c311
Use PURPLE_DEVEL_WEBSITE instead of hardcoding it.
Richard Laager <rlaager@wiktel.com>
parents:
23580
diff
changeset
|
376 purple_debug_error("core", "Error renaming %s to %s: %s. Please report this at " PURPLE_DEVEL_WEBSITE "\n", |
21121
35b4f1dc4c8d
replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents:
20074
diff
changeset
|
377 path, new_name, g_strerror(errno)); |
16341
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
378 g_free(new_name); |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
379 return FALSE; |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
380 } |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
381 g_free(new_name); |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
382 |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
383 #ifndef _WIN32 |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
384 /* NOTE: This new_name is relative. */ |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
385 new_name = g_build_filename(relative, basename, NULL); |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
386 old_name = g_build_filename(old_base, basename, NULL); |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
387 if (symlink(new_name, old_name)) |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
388 { |
24113
a29ae9a5c311
Use PURPLE_DEVEL_WEBSITE instead of hardcoding it.
Richard Laager <rlaager@wiktel.com>
parents:
23580
diff
changeset
|
389 purple_debug_warning("core", "Error symlinking %s to %s: %s. Please report this at " PURPLE_DEVEL_WEBSITE "\n", |
21121
35b4f1dc4c8d
replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents:
20074
diff
changeset
|
390 old_name, new_name, g_strerror(errno)); |
16341
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
391 } |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
392 g_free(old_name); |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
393 g_free(new_name); |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
394 #endif |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
395 |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
396 return TRUE; |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
397 } |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
398 |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
399 gboolean |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
400 purple_core_migrate(void) |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
401 { |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
402 const char *user_dir = purple_user_dir(); |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
403 char *old_user_dir = g_strconcat(purple_home_dir(), |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
404 G_DIR_SEPARATOR_S ".gaim", NULL); |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
405 char *status_file; |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
406 FILE *fp; |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
407 GDir *dir; |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
408 GError *err; |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
409 const char *entry; |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
410 #ifndef _WIN32 |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
411 char *logs_dir; |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
412 #endif |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
413 char *old_icons_dir; |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
414 |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
415 if (!g_file_test(old_user_dir, G_FILE_TEST_EXISTS)) |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
416 { |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
417 /* ~/.gaim doesn't exist, so there's nothing to migrate. */ |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
418 g_free(old_user_dir); |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
419 return TRUE; |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
420 } |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
421 |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
422 status_file = g_strconcat(user_dir, G_DIR_SEPARATOR_S "migrating", NULL); |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
423 |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
424 if (g_file_test(user_dir, G_FILE_TEST_EXISTS)) |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
425 { |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
426 /* If we're here, we have both ~/.gaim and .purple. */ |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
427 |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
428 if (!g_file_test(status_file, G_FILE_TEST_EXISTS)) |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
429 { |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
430 /* There's no "migrating" status file, |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
431 * so ~/.purple is all up to date. */ |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
432 g_free(status_file); |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
433 g_free(old_user_dir); |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
434 return TRUE; |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
435 } |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
436 } |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
437 |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
438 /* If we're here, it's time to migrate from ~/.gaim to ~/.purple. */ |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
439 |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
440 /* Ensure the user directory exists */ |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
441 if (!g_file_test(user_dir, G_FILE_TEST_IS_DIR)) |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
442 { |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
443 if (g_mkdir(user_dir, S_IRUSR | S_IWUSR | S_IXUSR) == -1) |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
444 { |
24113
a29ae9a5c311
Use PURPLE_DEVEL_WEBSITE instead of hardcoding it.
Richard Laager <rlaager@wiktel.com>
parents:
23580
diff
changeset
|
445 purple_debug_error("core", "Error creating directory %s: %s. Please report this at " PURPLE_DEVEL_WEBSITE "\n", |
21121
35b4f1dc4c8d
replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents:
20074
diff
changeset
|
446 user_dir, g_strerror(errno)); |
16341
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
447 g_free(status_file); |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
448 g_free(old_user_dir); |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
449 return FALSE; |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
450 } |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
451 } |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
452 |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
453 /* This writes ~/.purple/migrating, which allows us to detect |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
454 * incomplete migrations and properly retry. */ |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
455 if (!(fp = g_fopen(status_file, "w"))) |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
456 { |
24113
a29ae9a5c311
Use PURPLE_DEVEL_WEBSITE instead of hardcoding it.
Richard Laager <rlaager@wiktel.com>
parents:
23580
diff
changeset
|
457 purple_debug_error("core", "Error opening file %s for writing: %s. Please report this at " PURPLE_DEVEL_WEBSITE "\n", |
21121
35b4f1dc4c8d
replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents:
20074
diff
changeset
|
458 status_file, g_strerror(errno)); |
16341
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
459 g_free(status_file); |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
460 g_free(old_user_dir); |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
461 return FALSE; |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
462 } |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
463 fclose(fp); |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
464 |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
465 /* Open ~/.gaim so we can loop over its contents. */ |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
466 err = NULL; |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
467 if (!(dir = g_dir_open(old_user_dir, 0, &err))) |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
468 { |
24113
a29ae9a5c311
Use PURPLE_DEVEL_WEBSITE instead of hardcoding it.
Richard Laager <rlaager@wiktel.com>
parents:
23580
diff
changeset
|
469 purple_debug_error("core", "Error opening directory %s: %s. Please report this at " PURPLE_DEVEL_WEBSITE "\n", |
16341
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
470 status_file, |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
471 (err ? err->message : "Unknown error")); |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
472 if (err) |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
473 g_error_free(err); |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
474 g_free(status_file); |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
475 g_free(old_user_dir); |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
476 return FALSE; |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
477 } |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
478 |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
479 /* Loop over the contents of ~/.gaim */ |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
480 while ((entry = g_dir_read_name(dir))) |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
481 { |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
482 char *name = g_build_filename(old_user_dir, entry, NULL); |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
483 |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
484 #ifndef _WIN32 |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
485 /* Deal with symlinks... */ |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
486 if (g_file_test(name, G_FILE_TEST_IS_SYMLINK)) |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
487 { |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
488 /* We're only going to duplicate a logs symlink. */ |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
489 if (!strcmp(entry, "logs")) |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
490 { |
18148
f160b6e84d0c
Use dynamicly allocated string manipulation here as well to avoid a
Richard Laager <rlaager@wiktel.com>
parents:
17211
diff
changeset
|
491 char *link; |
f160b6e84d0c
Use dynamicly allocated string manipulation here as well to avoid a
Richard Laager <rlaager@wiktel.com>
parents:
17211
diff
changeset
|
492 #if GLIB_CHECK_VERSION(2,4,0) |
f160b6e84d0c
Use dynamicly allocated string manipulation here as well to avoid a
Richard Laager <rlaager@wiktel.com>
parents:
17211
diff
changeset
|
493 GError *err = NULL; |
f160b6e84d0c
Use dynamicly allocated string manipulation here as well to avoid a
Richard Laager <rlaager@wiktel.com>
parents:
17211
diff
changeset
|
494 |
f160b6e84d0c
Use dynamicly allocated string manipulation here as well to avoid a
Richard Laager <rlaager@wiktel.com>
parents:
17211
diff
changeset
|
495 if ((link = g_file_read_link(name, &err)) == NULL) |
f160b6e84d0c
Use dynamicly allocated string manipulation here as well to avoid a
Richard Laager <rlaager@wiktel.com>
parents:
17211
diff
changeset
|
496 { |
f160b6e84d0c
Use dynamicly allocated string manipulation here as well to avoid a
Richard Laager <rlaager@wiktel.com>
parents:
17211
diff
changeset
|
497 char *name_utf8 = g_filename_to_utf8(name, -1, NULL, NULL, NULL); |
24113
a29ae9a5c311
Use PURPLE_DEVEL_WEBSITE instead of hardcoding it.
Richard Laager <rlaager@wiktel.com>
parents:
23580
diff
changeset
|
498 purple_debug_error("core", "Error reading symlink %s: %s. Please report this at " PURPLE_DEVEL_WEBSITE "\n", |
18148
f160b6e84d0c
Use dynamicly allocated string manipulation here as well to avoid a
Richard Laager <rlaager@wiktel.com>
parents:
17211
diff
changeset
|
499 name_utf8 ? name_utf8 : name, err->message); |
f160b6e84d0c
Use dynamicly allocated string manipulation here as well to avoid a
Richard Laager <rlaager@wiktel.com>
parents:
17211
diff
changeset
|
500 g_free(name_utf8); |
f160b6e84d0c
Use dynamicly allocated string manipulation here as well to avoid a
Richard Laager <rlaager@wiktel.com>
parents:
17211
diff
changeset
|
501 g_error_free(err); |
f160b6e84d0c
Use dynamicly allocated string manipulation here as well to avoid a
Richard Laager <rlaager@wiktel.com>
parents:
17211
diff
changeset
|
502 g_free(name); |
f160b6e84d0c
Use dynamicly allocated string manipulation here as well to avoid a
Richard Laager <rlaager@wiktel.com>
parents:
17211
diff
changeset
|
503 g_dir_close(dir); |
f160b6e84d0c
Use dynamicly allocated string manipulation here as well to avoid a
Richard Laager <rlaager@wiktel.com>
parents:
17211
diff
changeset
|
504 g_free(status_file); |
f160b6e84d0c
Use dynamicly allocated string manipulation here as well to avoid a
Richard Laager <rlaager@wiktel.com>
parents:
17211
diff
changeset
|
505 g_free(old_user_dir); |
f160b6e84d0c
Use dynamicly allocated string manipulation here as well to avoid a
Richard Laager <rlaager@wiktel.com>
parents:
17211
diff
changeset
|
506 return FALSE; |
f160b6e84d0c
Use dynamicly allocated string manipulation here as well to avoid a
Richard Laager <rlaager@wiktel.com>
parents:
17211
diff
changeset
|
507 } |
f160b6e84d0c
Use dynamicly allocated string manipulation here as well to avoid a
Richard Laager <rlaager@wiktel.com>
parents:
17211
diff
changeset
|
508 #else |
16341
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
509 char buf[MAXPATHLEN]; |
16605
99e786de5bd5
#386: readlink does not append NUL to the end of buffer
Ka-Hing Cheung <khc@hxbc.us>
parents:
16599
diff
changeset
|
510 size_t linklen; |
16341
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
511 |
16605
99e786de5bd5
#386: readlink does not append NUL to the end of buffer
Ka-Hing Cheung <khc@hxbc.us>
parents:
16599
diff
changeset
|
512 if ((linklen = readlink(name, buf, sizeof(buf) - 1) == -1)) |
16341
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
513 { |
18204
4cc042912ac2
Bring back MAXPATHLEN (which was always guaranteed to be defined earlier
Stu Tomlinson <stu@nosnilmot.com>
parents:
18148
diff
changeset
|
514 char *name_utf8 = g_filename_to_utf8(name, -1, NULL, NULL, NULL); |
24113
a29ae9a5c311
Use PURPLE_DEVEL_WEBSITE instead of hardcoding it.
Richard Laager <rlaager@wiktel.com>
parents:
23580
diff
changeset
|
515 purple_debug_error("core", "Error reading symlink %s: %s. Please report this at " PURPLE_DEVEL_WEBSITE "\n", |
21121
35b4f1dc4c8d
replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents:
20074
diff
changeset
|
516 name_utf8, g_strerror(errno)); |
18148
f160b6e84d0c
Use dynamicly allocated string manipulation here as well to avoid a
Richard Laager <rlaager@wiktel.com>
parents:
17211
diff
changeset
|
517 g_free(name_utf8); |
16341
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
518 g_free(name); |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
519 g_dir_close(dir); |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
520 g_free(status_file); |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
521 g_free(old_user_dir); |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
522 return FALSE; |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
523 } |
16605
99e786de5bd5
#386: readlink does not append NUL to the end of buffer
Ka-Hing Cheung <khc@hxbc.us>
parents:
16599
diff
changeset
|
524 buf[linklen] = '\0'; |
16341
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
525 |
18148
f160b6e84d0c
Use dynamicly allocated string manipulation here as well to avoid a
Richard Laager <rlaager@wiktel.com>
parents:
17211
diff
changeset
|
526 /* This way we don't have to GLIB_VERSION_CHECK every g_free(link) below. */ |
f160b6e84d0c
Use dynamicly allocated string manipulation here as well to avoid a
Richard Laager <rlaager@wiktel.com>
parents:
17211
diff
changeset
|
527 link = g_strdup(buf); |
f160b6e84d0c
Use dynamicly allocated string manipulation here as well to avoid a
Richard Laager <rlaager@wiktel.com>
parents:
17211
diff
changeset
|
528 #endif |
16341
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
529 |
18148
f160b6e84d0c
Use dynamicly allocated string manipulation here as well to avoid a
Richard Laager <rlaager@wiktel.com>
parents:
17211
diff
changeset
|
530 logs_dir = g_build_filename(user_dir, "logs", NULL); |
f160b6e84d0c
Use dynamicly allocated string manipulation here as well to avoid a
Richard Laager <rlaager@wiktel.com>
parents:
17211
diff
changeset
|
531 |
f160b6e84d0c
Use dynamicly allocated string manipulation here as well to avoid a
Richard Laager <rlaager@wiktel.com>
parents:
17211
diff
changeset
|
532 if (!strcmp(link, "../.purple/logs") || !strcmp(link, logs_dir)) |
16341
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
533 { |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
534 /* If the symlink points to the new directory, we're |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
535 * likely just trying again after a failed migration, |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
536 * so there's no need to fail here. */ |
18148
f160b6e84d0c
Use dynamicly allocated string manipulation here as well to avoid a
Richard Laager <rlaager@wiktel.com>
parents:
17211
diff
changeset
|
537 g_free(link); |
16341
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
538 g_free(logs_dir); |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
539 continue; |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
540 } |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
541 |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
542 /* In case we are trying again after a failed migration, we need |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
543 * to unlink any existing symlink. If it's a directory, this |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
544 * will fail, and so will the symlink below, which is good |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
545 * because the user should sort things out. */ |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
546 g_unlink(logs_dir); |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
547 |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
548 /* Relative links will most likely still be |
18148
f160b6e84d0c
Use dynamicly allocated string manipulation here as well to avoid a
Richard Laager <rlaager@wiktel.com>
parents:
17211
diff
changeset
|
549 * valid from ~/.purple, though it's not |
16341
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
550 * guaranteed. Oh well. */ |
18148
f160b6e84d0c
Use dynamicly allocated string manipulation here as well to avoid a
Richard Laager <rlaager@wiktel.com>
parents:
17211
diff
changeset
|
551 if (symlink(link, logs_dir)) |
16341
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
552 { |
24113
a29ae9a5c311
Use PURPLE_DEVEL_WEBSITE instead of hardcoding it.
Richard Laager <rlaager@wiktel.com>
parents:
23580
diff
changeset
|
553 purple_debug_error("core", "Error symlinking %s to %s: %s. Please report this at " PURPLE_DEVEL_WEBSITE "\n", |
21121
35b4f1dc4c8d
replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents:
20074
diff
changeset
|
554 logs_dir, link, g_strerror(errno)); |
18148
f160b6e84d0c
Use dynamicly allocated string manipulation here as well to avoid a
Richard Laager <rlaager@wiktel.com>
parents:
17211
diff
changeset
|
555 g_free(link); |
16341
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
556 g_free(name); |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
557 g_free(logs_dir); |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
558 g_dir_close(dir); |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
559 g_free(status_file); |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
560 g_free(old_user_dir); |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
561 return FALSE; |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
562 } |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
563 |
18148
f160b6e84d0c
Use dynamicly allocated string manipulation here as well to avoid a
Richard Laager <rlaager@wiktel.com>
parents:
17211
diff
changeset
|
564 g_free(link); |
16341
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
565 g_free(logs_dir); |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
566 continue; |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
567 } |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
568 |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
569 /* Ignore all other symlinks. */ |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
570 continue; |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
571 } |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
572 #endif |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
573 |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
574 /* Deal with directories... */ |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
575 if (g_file_test(name, G_FILE_TEST_IS_DIR)) |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
576 { |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
577 if (!strcmp(entry, "icons")) |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
578 { |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
579 /* This is a special case for the Album plugin, which |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
580 * stores data in the icons folder. We're not copying |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
581 * the icons directory over because previous bugs |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
582 * meant that it filled up with junk for many users. |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
583 * This is a great time to purge it. */ |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
584 |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
585 GDir *icons_dir; |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
586 char *new_icons_dir; |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
587 const char *icons_entry; |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
588 |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
589 err = NULL; |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
590 if (!(icons_dir = g_dir_open(name, 0, &err))) |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
591 { |
24113
a29ae9a5c311
Use PURPLE_DEVEL_WEBSITE instead of hardcoding it.
Richard Laager <rlaager@wiktel.com>
parents:
23580
diff
changeset
|
592 purple_debug_error("core", "Error opening directory %s: %s. Please report this at " PURPLE_DEVEL_WEBSITE "\n", |
16341
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
593 name, |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
594 (err ? err->message : "Unknown error")); |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
595 if (err) |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
596 g_error_free(err); |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
597 g_free(name); |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
598 g_dir_close(dir); |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
599 g_free(status_file); |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
600 g_free(old_user_dir); |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
601 return FALSE; |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
602 } |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
603 |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
604 new_icons_dir = g_build_filename(user_dir, "icons", NULL); |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
605 /* Ensure the new icon directory exists */ |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
606 if (!g_file_test(new_icons_dir, G_FILE_TEST_IS_DIR)) |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
607 { |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
608 if (g_mkdir(new_icons_dir, S_IRUSR | S_IWUSR | S_IXUSR) == -1) |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
609 { |
24113
a29ae9a5c311
Use PURPLE_DEVEL_WEBSITE instead of hardcoding it.
Richard Laager <rlaager@wiktel.com>
parents:
23580
diff
changeset
|
610 purple_debug_error("core", "Error creating directory %s: %s. Please report this at " PURPLE_DEVEL_WEBSITE "\n", |
21121
35b4f1dc4c8d
replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents:
20074
diff
changeset
|
611 new_icons_dir, g_strerror(errno)); |
16341
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
612 g_free(new_icons_dir); |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
613 g_dir_close(icons_dir); |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
614 g_free(name); |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
615 g_dir_close(dir); |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
616 g_free(status_file); |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
617 g_free(old_user_dir); |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
618 return FALSE; |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
619 } |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
620 } |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
621 |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
622 while ((icons_entry = g_dir_read_name(icons_dir))) |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
623 { |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
624 char *icons_name = g_build_filename(name, icons_entry, NULL); |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
625 |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
626 if (g_file_test(icons_name, G_FILE_TEST_IS_DIR)) |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
627 { |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
628 if (!move_and_symlink_dir(icons_name, icons_entry, |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
629 name, new_icons_dir, "../../.purple/icons")) |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
630 { |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
631 g_free(icons_name); |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
632 g_free(new_icons_dir); |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
633 g_dir_close(icons_dir); |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
634 g_free(name); |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
635 g_dir_close(dir); |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
636 g_free(status_file); |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
637 g_free(old_user_dir); |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
638 return FALSE; |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
639 } |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
640 } |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
641 g_free(icons_name); |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
642 } |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
643 |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
644 g_dir_close(icons_dir); |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
645 } |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
646 else if (!strcmp(entry, "plugins")) |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
647 { |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
648 /* Do nothing, because we broke plugin compatibility. |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
649 * This means that the plugins directory gets left behind. */ |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
650 } |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
651 else |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
652 { |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
653 /* All other directories are moved and symlinked. */ |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
654 if (!move_and_symlink_dir(name, entry, old_user_dir, user_dir, "../.purple")) |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
655 { |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
656 g_free(name); |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
657 g_dir_close(dir); |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
658 g_free(status_file); |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
659 g_free(old_user_dir); |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
660 return FALSE; |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
661 } |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
662 } |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
663 } |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
664 else if (g_file_test(name, G_FILE_TEST_IS_REGULAR)) |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
665 { |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
666 /* Regular files are copied. */ |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
667 |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
668 char *new_name; |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
669 FILE *new_file; |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
670 |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
671 if (!(fp = g_fopen(name, "rb"))) |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
672 { |
24113
a29ae9a5c311
Use PURPLE_DEVEL_WEBSITE instead of hardcoding it.
Richard Laager <rlaager@wiktel.com>
parents:
23580
diff
changeset
|
673 purple_debug_error("core", "Error opening file %s for reading: %s. Please report this at " PURPLE_DEVEL_WEBSITE "\n", |
21121
35b4f1dc4c8d
replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents:
20074
diff
changeset
|
674 name, g_strerror(errno)); |
16341
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
675 g_free(name); |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
676 g_dir_close(dir); |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
677 g_free(status_file); |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
678 g_free(old_user_dir); |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
679 return FALSE; |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
680 } |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
681 |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
682 new_name = g_build_filename(user_dir, entry, NULL); |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
683 if (!(new_file = g_fopen(new_name, "wb"))) |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
684 { |
24113
a29ae9a5c311
Use PURPLE_DEVEL_WEBSITE instead of hardcoding it.
Richard Laager <rlaager@wiktel.com>
parents:
23580
diff
changeset
|
685 purple_debug_error("core", "Error opening file %s for writing: %s. Please report this at " PURPLE_DEVEL_WEBSITE "\n", |
21121
35b4f1dc4c8d
replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents:
20074
diff
changeset
|
686 new_name, g_strerror(errno)); |
16341
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
687 fclose(fp); |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
688 g_free(new_name); |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
689 g_free(name); |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
690 g_dir_close(dir); |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
691 g_free(status_file); |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
692 g_free(old_user_dir); |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
693 return FALSE; |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
694 } |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
695 |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
696 while (!feof(fp)) |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
697 { |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
698 unsigned char buf[256]; |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
699 size_t size; |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
700 |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
701 size = fread(buf, 1, sizeof(buf), fp); |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
702 if (size != sizeof(buf) && !feof(fp)) |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
703 { |
24113
a29ae9a5c311
Use PURPLE_DEVEL_WEBSITE instead of hardcoding it.
Richard Laager <rlaager@wiktel.com>
parents:
23580
diff
changeset
|
704 purple_debug_error("core", "Error reading %s: %s. Please report this at " PURPLE_DEVEL_WEBSITE "\n", |
21121
35b4f1dc4c8d
replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents:
20074
diff
changeset
|
705 name, g_strerror(errno)); |
16341
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
706 fclose(new_file); |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
707 fclose(fp); |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
708 g_free(new_name); |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
709 g_free(name); |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
710 g_dir_close(dir); |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
711 g_free(status_file); |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
712 g_free(old_user_dir); |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
713 return FALSE; |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
714 } |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
715 |
16490
dec693050305
Proper error checking on fwrite() call
Sean Egan <seanegan@gmail.com>
parents:
16484
diff
changeset
|
716 if (!fwrite(buf, size, 1, new_file) && ferror(new_file) != 0) |
16341
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
717 { |
24113
a29ae9a5c311
Use PURPLE_DEVEL_WEBSITE instead of hardcoding it.
Richard Laager <rlaager@wiktel.com>
parents:
23580
diff
changeset
|
718 purple_debug_error("core", "Error writing %s: %s. Please report this at " PURPLE_DEVEL_WEBSITE "\n", |
21121
35b4f1dc4c8d
replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents:
20074
diff
changeset
|
719 new_name, g_strerror(errno)); |
16341
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
720 fclose(new_file); |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
721 fclose(fp); |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
722 g_free(new_name); |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
723 g_free(name); |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
724 g_dir_close(dir); |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
725 g_free(status_file); |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
726 g_free(old_user_dir); |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
727 return FALSE; |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
728 } |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
729 } |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
730 |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
731 if (fclose(new_file)) |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
732 { |
24113
a29ae9a5c311
Use PURPLE_DEVEL_WEBSITE instead of hardcoding it.
Richard Laager <rlaager@wiktel.com>
parents:
23580
diff
changeset
|
733 purple_debug_error("core", "Error writing: %s: %s. Please report this at " PURPLE_DEVEL_WEBSITE "\n", |
21121
35b4f1dc4c8d
replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents:
20074
diff
changeset
|
734 new_name, g_strerror(errno)); |
16341
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
735 } |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
736 if (fclose(fp)) |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
737 { |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
738 purple_debug_warning("core", "Error closing %s: %s\n", |
21121
35b4f1dc4c8d
replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents:
20074
diff
changeset
|
739 name, g_strerror(errno)); |
16341
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
740 } |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
741 g_free(new_name); |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
742 } |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
743 else |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
744 purple_debug_warning("core", "Not a regular file or directory: %s\n", name); |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
745 |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
746 g_free(name); |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
747 } |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
748 |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
749 /* The migration was successful, so delete the status file. */ |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
750 if (g_unlink(status_file)) |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
751 { |
24113
a29ae9a5c311
Use PURPLE_DEVEL_WEBSITE instead of hardcoding it.
Richard Laager <rlaager@wiktel.com>
parents:
23580
diff
changeset
|
752 purple_debug_error("core", "Error unlinking file %s: %s. Please report this at " PURPLE_DEVEL_WEBSITE "\n", |
21121
35b4f1dc4c8d
replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents:
20074
diff
changeset
|
753 status_file, g_strerror(errno)); |
16341
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
754 g_free(status_file); |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
755 return FALSE; |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
756 } |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
757 |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
758 old_icons_dir = g_build_filename(old_user_dir, "icons", NULL); |
16639
f9c369b4291c
Fix up the private function calls to be prefixed with an underscore.
Richard Laager <rlaager@wiktel.com>
parents:
16605
diff
changeset
|
759 _purple_buddy_icon_set_old_icons_dir(old_icons_dir); |
16341
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
760 g_free(old_icons_dir); |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
761 |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
762 g_free(old_user_dir); |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
763 |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
764 g_free(status_file); |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
765 return TRUE; |
786edf5e2144
The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents:
16063
diff
changeset
|
766 } |
18292
9db52d9b8436
core support for UI info...now to do the UI piece
Nathan Walp <nwalp@pidgin.im>
parents:
18224
diff
changeset
|
767 |
9db52d9b8436
core support for UI info...now to do the UI piece
Nathan Walp <nwalp@pidgin.im>
parents:
18224
diff
changeset
|
768 GHashTable* purple_core_get_ui_info() { |
9db52d9b8436
core support for UI info...now to do the UI piece
Nathan Walp <nwalp@pidgin.im>
parents:
18224
diff
changeset
|
769 PurpleCoreUiOps *ops = purple_core_get_ui_ops(); |
9db52d9b8436
core support for UI info...now to do the UI piece
Nathan Walp <nwalp@pidgin.im>
parents:
18224
diff
changeset
|
770 |
9db52d9b8436
core support for UI info...now to do the UI piece
Nathan Walp <nwalp@pidgin.im>
parents:
18224
diff
changeset
|
771 if(NULL == ops || NULL == ops->get_ui_info) |
9db52d9b8436
core support for UI info...now to do the UI piece
Nathan Walp <nwalp@pidgin.im>
parents:
18224
diff
changeset
|
772 return NULL; |
9db52d9b8436
core support for UI info...now to do the UI piece
Nathan Walp <nwalp@pidgin.im>
parents:
18224
diff
changeset
|
773 |
9db52d9b8436
core support for UI info...now to do the UI piece
Nathan Walp <nwalp@pidgin.im>
parents:
18224
diff
changeset
|
774 return ops->get_ui_info(); |
9db52d9b8436
core support for UI info...now to do the UI piece
Nathan Walp <nwalp@pidgin.im>
parents:
18224
diff
changeset
|
775 } |