annotate libpurple/core.c @ 17719:a217e9b9ebc2

merge of 'bc75c50283ea211d6f97caefcb83db0e34e10bfe' and 'de314ef335216e20484a1ce9d840a1828f4cc9f9'
author Richard Laager <rlaager@wiktel.com>
date Sat, 19 May 2007 06:55:53 +0000
parents b5935a854ccb 9d5121f2ab5d
children 1d6007400837
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1 /**
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15612
diff changeset
2 * @file core.c Purple Core API
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
3 * @ingroup core
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
4 *
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15612
diff changeset
5 * purple
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
6 *
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15612
diff changeset
7 * Purple is the legal property of its developers, whose names are too numerous
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
8 * 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
9 * source distribution.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
10 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
11 * 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
12 * 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
13 * 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
14 * (at your option) any later version.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
15 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
16 * 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
17 * 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
18 * 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
19 * GNU General Public License for more details.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
20 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
21 * 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
22 * along with this program; if not, write to the Free Software
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
24 */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
25 #include "internal.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
26 #include "cipher.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
27 #include "connection.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
28 #include "conversation.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
29 #include "core.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
30 #include "debug.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
31 #include "dnsquery.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
32 #include "ft.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
33 #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
34 #include "imgstore.h"
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
35 #include "network.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
36 #include "notify.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
37 #include "plugin.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
38 #include "pounce.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
39 #include "prefs.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
40 #include "privacy.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
41 #include "proxy.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
42 #include "savedstatuses.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
43 #include "signals.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
44 #include "sound.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
45 #include "sslconn.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
46 #include "status.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
47 #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
48 #include "util.h"
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
49
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
50 #ifdef HAVE_DBUS
17709
176d0fc8bc16 Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents: 16691
diff changeset
51 # define DBUS_API_SUBJECT_TO_CHANGE
176d0fc8bc16 Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents: 16691
diff changeset
52 # include <dbus/dbus.h>
176d0fc8bc16 Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents: 16691
diff changeset
53 # include "dbus-purple.h"
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
54 # include "dbus-server.h"
17709
176d0fc8bc16 Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents: 16691
diff changeset
55 # include "dbus-bindings.h"
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
56 #endif
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
57
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15612
diff changeset
58 struct PurpleCore
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
59 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
60 char *ui;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
61
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
62 void *reserved;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
63 };
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
64
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15612
diff changeset
65 static PurpleCoreUiOps *_ops = NULL;
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15612
diff changeset
66 static PurpleCore *_core = NULL;
15373
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 STATIC_PROTO_INIT
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 gboolean
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15612
diff changeset
71 purple_core_init(const char *ui)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
72 {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15612
diff changeset
73 PurpleCoreUiOps *ops;
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15612
diff changeset
74 PurpleCore *core;
15373
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 g_return_val_if_fail(ui != NULL, FALSE);
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15612
diff changeset
77 g_return_val_if_fail(purple_get_core() == NULL, FALSE);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
78
16063
fa8aeab4ca5a Hopefully prevent libpurple causing problems for 3rd party UIs if they also
Stu Tomlinson <stu@nosnilmot.com>
parents: 15822
diff changeset
79 #ifdef ENABLE_NLS
fa8aeab4ca5a Hopefully prevent libpurple causing problems for 3rd party UIs if they also
Stu Tomlinson <stu@nosnilmot.com>
parents: 15822
diff changeset
80 bindtextdomain(PACKAGE, LOCALEDIR);
fa8aeab4ca5a Hopefully prevent libpurple causing problems for 3rd party UIs if they also
Stu Tomlinson <stu@nosnilmot.com>
parents: 15822
diff changeset
81 #endif
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
82 #ifdef _WIN32
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15612
diff changeset
83 wpurple_init();
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
84 #endif
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
85
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15612
diff changeset
86 _core = core = g_new0(PurpleCore, 1);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
87 core->ui = g_strdup(ui);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
88 core->reserved = NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
89
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15612
diff changeset
90 ops = purple_core_get_ui_ops();
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
91
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
92 /* The signals subsystem is important and should be first. */
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15612
diff changeset
93 purple_signals_init();
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
94
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15612
diff changeset
95 purple_signal_register(core, "uri-handler",
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15612
diff changeset
96 purple_marshal_BOOLEAN__POINTER_POINTER_POINTER,
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15612
diff changeset
97 purple_value_new(PURPLE_TYPE_BOOLEAN), 3,
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15612
diff changeset
98 purple_value_new(PURPLE_TYPE_STRING), /* Protocol */
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15612
diff changeset
99 purple_value_new(PURPLE_TYPE_STRING), /* Command */
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15612
diff changeset
100 purple_value_new(PURPLE_TYPE_BOXED, "GHashTable *")); /* Parameters */
15612
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: 15373
diff changeset
101
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15612
diff changeset
102 purple_signal_register(core, "quitting", purple_marshal_VOID, NULL, 0);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
103
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
104 /* 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
105 * for protocol prefs to work. */
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15612
diff changeset
106 purple_prefs_init();
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
107
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15612
diff changeset
108 purple_debug_init();
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
109
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
110 if (ops != NULL)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
111 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
112 if (ops->ui_prefs_init != NULL)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
113 ops->ui_prefs_init();
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
114
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
115 if (ops->debug_ui_init != NULL)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
116 ops->debug_ui_init();
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
117 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
118
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
119 #ifdef HAVE_DBUS
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15612
diff changeset
120 purple_dbus_init();
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
121 #endif
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
122
16591
976a9b4c336a Part of the patch in ticket #383:
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16540
diff changeset
123 purple_ciphers_init();
976a9b4c336a Part of the patch in ticket #383:
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16540
diff changeset
124
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
125 /* Initialize all static protocols. */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
126 static_proto_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 /* 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
129 * subsystem right away too.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
130 */
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15612
diff changeset
131 purple_plugins_init();
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15612
diff changeset
132 purple_plugins_probe(G_MODULE_SUFFIX);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
133
16375
391a79778f89 Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents: 16341
diff changeset
134 /* 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
135 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
136
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
137 /* Accounts use status and buddy icons, so initialize these before accounts */
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15612
diff changeset
138 purple_status_init();
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15612
diff changeset
139 purple_buddy_icons_init();
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
140
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15612
diff changeset
141 purple_accounts_init();
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15612
diff changeset
142 purple_savedstatuses_init();
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15612
diff changeset
143 purple_notify_init();
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15612
diff changeset
144 purple_connections_init();
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15612
diff changeset
145 purple_conversations_init();
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15612
diff changeset
146 purple_blist_init();
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15612
diff changeset
147 purple_log_init();
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15612
diff changeset
148 purple_network_init();
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15612
diff changeset
149 purple_privacy_init();
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15612
diff changeset
150 purple_pounces_init();
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15612
diff changeset
151 purple_proxy_init();
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15612
diff changeset
152 purple_dnsquery_init();
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15612
diff changeset
153 purple_sound_init();
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15612
diff changeset
154 purple_ssl_init();
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15612
diff changeset
155 purple_stun_init();
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15612
diff changeset
156 purple_xfers_init();
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15612
diff changeset
157 purple_idle_init();
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
158
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
159 /*
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
160 * 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
161 * hopefully save some time later.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
162 */
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15612
diff changeset
163 purple_network_get_my_ip(-1);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
164
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
165 if (ops != NULL && ops->ui_init != NULL)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
166 ops->ui_init();
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
167
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
168 return TRUE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
169 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
170
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
171 void
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15612
diff changeset
172 purple_core_quit(void)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
173 {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15612
diff changeset
174 PurpleCoreUiOps *ops;
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15612
diff changeset
175 PurpleCore *core = purple_get_core();
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
176
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
177 g_return_if_fail(core != NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
178
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
179 /* The self destruct sequence has been initiated */
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15612
diff changeset
180 purple_signal_emit(purple_get_core(), "quitting");
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
181
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
182 /* Transmission ends */
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15612
diff changeset
183 purple_connections_disconnect_all();
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
184
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
185 /* Save .xml files, remove signals, etc. */
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15612
diff changeset
186 purple_idle_uninit();
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15612
diff changeset
187 purple_ssl_uninit();
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15612
diff changeset
188 purple_pounces_uninit();
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15612
diff changeset
189 purple_blist_uninit();
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15612
diff changeset
190 purple_ciphers_uninit();
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15612
diff changeset
191 purple_notify_uninit();
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15612
diff changeset
192 purple_conversations_uninit();
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15612
diff changeset
193 purple_connections_uninit();
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15612
diff changeset
194 purple_buddy_icons_uninit();
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15612
diff changeset
195 purple_accounts_uninit();
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15612
diff changeset
196 purple_savedstatuses_uninit();
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15612
diff changeset
197 purple_status_uninit();
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15612
diff changeset
198 purple_prefs_uninit();
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15612
diff changeset
199 purple_xfers_uninit();
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15612
diff changeset
200 purple_proxy_uninit();
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15612
diff changeset
201 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
202 purple_imgstore_uninit();
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
203
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15612
diff changeset
204 purple_debug_info("main", "Unloading all plugins\n");
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15612
diff changeset
205 purple_plugins_destroy_all();
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
206
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15612
diff changeset
207 ops = purple_core_get_ui_ops();
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
208 if (ops != NULL && ops->quit != NULL)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
209 ops->quit();
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
210
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
211 /*
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15612
diff changeset
212 * purple_sound_uninit() should be called as close to
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
213 * shutdown as possible. This is because the call
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
214 * to ao_shutdown() can sometimes leave our
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
215 * environment variables in an unusable state, which
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
216 * can cause a crash when getenv is called (by gettext
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
217 * for example). See the complete bug report at
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
218 * http://trac.xiph.org/cgi-bin/trac.cgi/ticket/701
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
219 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
220 * TODO: Eventually move this call higher up with the others.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
221 */
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15612
diff changeset
222 purple_sound_uninit();
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
223
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15612
diff changeset
224 purple_plugins_uninit();
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15612
diff changeset
225 purple_signals_uninit();
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
226
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
227 #ifdef HAVE_DBUS
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15612
diff changeset
228 purple_dbus_uninit();
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
229 #endif
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
230
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
231 g_free(core->ui);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
232 g_free(core);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
233
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
234 #ifdef _WIN32
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15612
diff changeset
235 wpurple_cleanup();
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
236 #endif
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
237
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
238 _core = NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
239 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
240
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
241 gboolean
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15612
diff changeset
242 purple_core_quit_cb(gpointer unused)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
243 {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15612
diff changeset
244 purple_core_quit();
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
245
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
246 return FALSE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
247 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
248
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
249 const char *
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15612
diff changeset
250 purple_core_get_version(void)
15373
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 return VERSION;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
253 }
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 const char *
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15612
diff changeset
256 purple_core_get_ui(void)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
257 {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15612
diff changeset
258 PurpleCore *core = purple_get_core();
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
259
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
260 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
261
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
262 return core->ui;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
263 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
264
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15612
diff changeset
265 PurpleCore *
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15612
diff changeset
266 purple_get_core(void)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
267 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
268 return _core;
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
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
271 void
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15612
diff changeset
272 purple_core_set_ui_ops(PurpleCoreUiOps *ops)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
273 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
274 _ops = ops;
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
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15612
diff changeset
277 PurpleCoreUiOps *
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15612
diff changeset
278 purple_core_get_ui_ops(void)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
279 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
280 return _ops;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
281 }
16341
786edf5e2144 The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents: 16063
diff changeset
282
17709
176d0fc8bc16 Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents: 16691
diff changeset
283 #ifdef HAVE_DBUS
176d0fc8bc16 Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents: 16691
diff changeset
284 static char *purple_dbus_owner_user_dir(void)
176d0fc8bc16 Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents: 16691
diff changeset
285 {
176d0fc8bc16 Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents: 16691
diff changeset
286 DBusMessage *msg = NULL, *reply = NULL;
176d0fc8bc16 Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents: 16691
diff changeset
287 DBusConnection *dbus_connection = NULL;
176d0fc8bc16 Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents: 16691
diff changeset
288 DBusError dbus_error;
176d0fc8bc16 Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents: 16691
diff changeset
289 char *remote_user_dir = NULL;
176d0fc8bc16 Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents: 16691
diff changeset
290
17710
601594a64190 Style changes + removed unnecessary NULL checks.
Gabriel Schulhof <nix@go-nix.ca>
parents: 17709
diff changeset
291 if ((dbus_connection = purple_dbus_get_connection()) == NULL)
17709
176d0fc8bc16 Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents: 16691
diff changeset
292 return NULL;
176d0fc8bc16 Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents: 16691
diff changeset
293
17710
601594a64190 Style changes + removed unnecessary NULL checks.
Gabriel Schulhof <nix@go-nix.ca>
parents: 17709
diff changeset
294 if ((msg = dbus_message_new_method_call(DBUS_SERVICE_PURPLE, DBUS_PATH_PURPLE, DBUS_INTERFACE_PURPLE, "PurpleUserDir")) == NULL)
17709
176d0fc8bc16 Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents: 16691
diff changeset
295 return NULL;
176d0fc8bc16 Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents: 16691
diff changeset
296
176d0fc8bc16 Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents: 16691
diff changeset
297 dbus_error_init(&dbus_error);
176d0fc8bc16 Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents: 16691
diff changeset
298 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: 16691
diff changeset
299 dbus_message_unref(msg);
176d0fc8bc16 Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents: 16691
diff changeset
300 dbus_error_free(&dbus_error);
176d0fc8bc16 Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents: 16691
diff changeset
301
17710
601594a64190 Style changes + removed unnecessary NULL checks.
Gabriel Schulhof <nix@go-nix.ca>
parents: 17709
diff changeset
302 if (reply) {
17709
176d0fc8bc16 Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents: 16691
diff changeset
303 dbus_error_init(&dbus_error);
176d0fc8bc16 Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents: 16691
diff changeset
304 dbus_message_get_args(reply, &dbus_error, DBUS_TYPE_STRING, &remote_user_dir, DBUS_TYPE_INVALID);
17714
9d5121f2ab5d Minor formatting tweaks for the dbus_uniq code.
Richard Laager <rlaager@wiktel.com>
parents: 17710
diff changeset
305 remote_user_dir = g_strdup(remote_user_dir);
17709
176d0fc8bc16 Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents: 16691
diff changeset
306 dbus_error_free(&dbus_error);
176d0fc8bc16 Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents: 16691
diff changeset
307 dbus_message_unref(reply);
17710
601594a64190 Style changes + removed unnecessary NULL checks.
Gabriel Schulhof <nix@go-nix.ca>
parents: 17709
diff changeset
308 }
17709
176d0fc8bc16 Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents: 16691
diff changeset
309
176d0fc8bc16 Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents: 16691
diff changeset
310 return remote_user_dir;
176d0fc8bc16 Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents: 16691
diff changeset
311 }
176d0fc8bc16 Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents: 16691
diff changeset
312
176d0fc8bc16 Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents: 16691
diff changeset
313 static void purple_dbus_owner_show_buddy_list(void)
176d0fc8bc16 Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents: 16691
diff changeset
314 {
176d0fc8bc16 Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents: 16691
diff changeset
315 DBusError dbus_error;
176d0fc8bc16 Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents: 16691
diff changeset
316 DBusMessage *msg = NULL, *reply = NULL;
17710
601594a64190 Style changes + removed unnecessary NULL checks.
Gabriel Schulhof <nix@go-nix.ca>
parents: 17709
diff changeset
317 DBusConnection *dbus_connection = NULL;
17709
176d0fc8bc16 Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents: 16691
diff changeset
318
17710
601594a64190 Style changes + removed unnecessary NULL checks.
Gabriel Schulhof <nix@go-nix.ca>
parents: 17709
diff changeset
319 if ((dbus_connection = purple_dbus_get_connection()) == NULL)
601594a64190 Style changes + removed unnecessary NULL checks.
Gabriel Schulhof <nix@go-nix.ca>
parents: 17709
diff changeset
320 return;
17709
176d0fc8bc16 Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents: 16691
diff changeset
321
17710
601594a64190 Style changes + removed unnecessary NULL checks.
Gabriel Schulhof <nix@go-nix.ca>
parents: 17709
diff changeset
322 if ((msg = dbus_message_new_method_call(DBUS_SERVICE_PURPLE, DBUS_PATH_PURPLE, DBUS_INTERFACE_PURPLE, "PurpleBlistShow")) == NULL)
17714
9d5121f2ab5d Minor formatting tweaks for the dbus_uniq code.
Richard Laager <rlaager@wiktel.com>
parents: 17710
diff changeset
323 return;
17709
176d0fc8bc16 Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents: 16691
diff changeset
324
176d0fc8bc16 Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents: 16691
diff changeset
325 dbus_error_init(&dbus_error);
17710
601594a64190 Style changes + removed unnecessary NULL checks.
Gabriel Schulhof <nix@go-nix.ca>
parents: 17709
diff changeset
326 if ((reply = dbus_connection_send_with_reply_and_block(dbus_connection, msg, 5000, &dbus_error)) != NULL) {
17709
176d0fc8bc16 Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents: 16691
diff changeset
327 dbus_message_unref(msg);
17710
601594a64190 Style changes + removed unnecessary NULL checks.
Gabriel Schulhof <nix@go-nix.ca>
parents: 17709
diff changeset
328 }
17709
176d0fc8bc16 Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents: 16691
diff changeset
329 dbus_error_free(&dbus_error);
176d0fc8bc16 Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents: 16691
diff changeset
330 }
176d0fc8bc16 Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents: 16691
diff changeset
331 #endif /* HAVE_DBUS */
176d0fc8bc16 Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents: 16691
diff changeset
332
176d0fc8bc16 Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents: 16691
diff changeset
333 gboolean purple_core_ensure_single_instance()
176d0fc8bc16 Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents: 16691
diff changeset
334 {
176d0fc8bc16 Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents: 16691
diff changeset
335 gboolean is_single_instance = TRUE;
176d0fc8bc16 Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents: 16691
diff changeset
336 #ifdef HAVE_DBUS
17710
601594a64190 Style changes + removed unnecessary NULL checks.
Gabriel Schulhof <nix@go-nix.ca>
parents: 17709
diff changeset
337 /* in the future, other mechanisms might have already set this to FALSE */
601594a64190 Style changes + removed unnecessary NULL checks.
Gabriel Schulhof <nix@go-nix.ca>
parents: 17709
diff changeset
338 if (is_single_instance) {
17709
176d0fc8bc16 Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents: 16691
diff changeset
339 if (!purple_dbus_is_owner()) {
176d0fc8bc16 Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents: 16691
diff changeset
340 const char *user_dir = purple_user_dir();
176d0fc8bc16 Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents: 16691
diff changeset
341 char *dbus_owner_user_dir = purple_dbus_owner_user_dir();
176d0fc8bc16 Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents: 16691
diff changeset
342
176d0fc8bc16 Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents: 16691
diff changeset
343 if (NULL == user_dir && NULL != dbus_owner_user_dir)
176d0fc8bc16 Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents: 16691
diff changeset
344 is_single_instance = TRUE;
17710
601594a64190 Style changes + removed unnecessary NULL checks.
Gabriel Schulhof <nix@go-nix.ca>
parents: 17709
diff changeset
345 else if (NULL != user_dir && NULL == dbus_owner_user_dir)
17709
176d0fc8bc16 Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents: 16691
diff changeset
346 is_single_instance = TRUE;
17710
601594a64190 Style changes + removed unnecessary NULL checks.
Gabriel Schulhof <nix@go-nix.ca>
parents: 17709
diff changeset
347 else if (NULL == user_dir && NULL == dbus_owner_user_dir)
17709
176d0fc8bc16 Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents: 16691
diff changeset
348 is_single_instance = FALSE;
176d0fc8bc16 Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents: 16691
diff changeset
349 else
176d0fc8bc16 Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents: 16691
diff changeset
350 is_single_instance = strcmp(dbus_owner_user_dir, user_dir);
176d0fc8bc16 Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents: 16691
diff changeset
351
176d0fc8bc16 Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents: 16691
diff changeset
352 if (!is_single_instance)
176d0fc8bc16 Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents: 16691
diff changeset
353 purple_dbus_owner_show_buddy_list();
176d0fc8bc16 Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents: 16691
diff changeset
354
176d0fc8bc16 Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents: 16691
diff changeset
355 g_free(dbus_owner_user_dir);
176d0fc8bc16 Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents: 16691
diff changeset
356 }
17710
601594a64190 Style changes + removed unnecessary NULL checks.
Gabriel Schulhof <nix@go-nix.ca>
parents: 17709
diff changeset
357 }
17709
176d0fc8bc16 Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents: 16691
diff changeset
358 #endif /* HAVE_DBUS */
17714
9d5121f2ab5d Minor formatting tweaks for the dbus_uniq code.
Richard Laager <rlaager@wiktel.com>
parents: 17710
diff changeset
359
17709
176d0fc8bc16 Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents: 16691
diff changeset
360 return is_single_instance;
176d0fc8bc16 Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents: 16691
diff changeset
361 }
176d0fc8bc16 Alternative dbus_uniq implementation
Gabriel Schulhof <nix@go-nix.ca>
parents: 16691
diff changeset
362
16341
786edf5e2144 The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents: 16063
diff changeset
363 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
364 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
365 {
786edf5e2144 The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents: 16063
diff changeset
366 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
367 #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
368 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
369 #endif
786edf5e2144 The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents: 16063
diff changeset
370 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
371 {
16691
f8f78fa7e774 Solicit bug reports
Sean Egan <seanegan@gmail.com>
parents: 16631
diff changeset
372 purple_debug_error("core", "Error renaming %s to %s: %s. Please report this at http://developer.pidgin.im\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
373 path, new_name, strerror(errno));
786edf5e2144 The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents: 16063
diff changeset
374 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
375 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
376 }
786edf5e2144 The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents: 16063
diff changeset
377 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
378
786edf5e2144 The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents: 16063
diff changeset
379 #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
380 /* 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
381 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
382 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
383 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
384 {
16691
f8f78fa7e774 Solicit bug reports
Sean Egan <seanegan@gmail.com>
parents: 16631
diff changeset
385 purple_debug_warning("core", "Error symlinking %s to %s: %s. Please report this at http://developer.pidgin.im\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
386 old_name, new_name, strerror(errno));
786edf5e2144 The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents: 16063
diff changeset
387 }
786edf5e2144 The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents: 16063
diff changeset
388 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
389 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
390 #endif
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 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
393 }
786edf5e2144 The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents: 16063
diff changeset
394
786edf5e2144 The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents: 16063
diff changeset
395 gboolean
786edf5e2144 The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents: 16063
diff changeset
396 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
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 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
399 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
400 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
401 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
402 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
403 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
404 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
405 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
406 #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
407 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
408 #endif
786edf5e2144 The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents: 16063
diff changeset
409 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
410
786edf5e2144 The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents: 16063
diff changeset
411 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
412 {
786edf5e2144 The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents: 16063
diff changeset
413 /* ~/.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
414 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
415 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
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
786edf5e2144 The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents: 16063
diff changeset
418 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
419
786edf5e2144 The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents: 16063
diff changeset
420 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
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 /* 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
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(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
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 /* 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
427 * 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
428 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
429 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
430 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
431 }
786edf5e2144 The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents: 16063
diff changeset
432 }
786edf5e2144 The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents: 16063
diff changeset
433
786edf5e2144 The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents: 16063
diff changeset
434 /* 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
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 /* 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
437 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
438 {
786edf5e2144 The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents: 16063
diff changeset
439 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
440 {
16691
f8f78fa7e774 Solicit bug reports
Sean Egan <seanegan@gmail.com>
parents: 16631
diff changeset
441 purple_debug_error("core", "Error creating directory %s: %s. Please report this at http://developer.pidgin.im\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
442 user_dir, strerror(errno));
786edf5e2144 The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents: 16063
diff changeset
443 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
444 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
445 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
446 }
786edf5e2144 The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents: 16063
diff changeset
447 }
786edf5e2144 The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents: 16063
diff changeset
448
786edf5e2144 The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents: 16063
diff changeset
449 /* 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
450 * 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
451 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
452 {
16691
f8f78fa7e774 Solicit bug reports
Sean Egan <seanegan@gmail.com>
parents: 16631
diff changeset
453 purple_debug_error("core", "Error opening file %s for writing: %s. Please report this at http://developer.pidgin.im\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
454 status_file, strerror(errno));
786edf5e2144 The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents: 16063
diff changeset
455 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
456 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
457 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
458 }
786edf5e2144 The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents: 16063
diff changeset
459 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
460
786edf5e2144 The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents: 16063
diff changeset
461 /* 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
462 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
463 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
464 {
16691
f8f78fa7e774 Solicit bug reports
Sean Egan <seanegan@gmail.com>
parents: 16631
diff changeset
465 purple_debug_error("core", "Error opening directory %s: %s. Please report this at http://developer.pidgin.im\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
466 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
467 (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
468 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
469 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
470 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
471 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
472 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
473 }
786edf5e2144 The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents: 16063
diff changeset
474
786edf5e2144 The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents: 16063
diff changeset
475 /* 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
476 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
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 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
479
786edf5e2144 The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents: 16063
diff changeset
480 #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
481 /* 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
482 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
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 /* 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
485 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
486 {
786edf5e2144 The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents: 16063
diff changeset
487 char buf[MAXPATHLEN];
16596
99e786de5bd5 #386: readlink does not append NUL to the end of buffer
Ka-Hing Cheung <khc@hxbc.us>
parents: 16591
diff changeset
488 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
489
16596
99e786de5bd5 #386: readlink does not append NUL to the end of buffer
Ka-Hing Cheung <khc@hxbc.us>
parents: 16591
diff changeset
490 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
491 {
16691
f8f78fa7e774 Solicit bug reports
Sean Egan <seanegan@gmail.com>
parents: 16631
diff changeset
492 purple_debug_error("core", "Error reading symlink %s: %s. Please report this at http://developer.pidgin.im\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
493 name, strerror(errno));
786edf5e2144 The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents: 16063
diff changeset
494 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
495 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
496 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
497 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
498 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
499 }
16596
99e786de5bd5 #386: readlink does not append NUL to the end of buffer
Ka-Hing Cheung <khc@hxbc.us>
parents: 16591
diff changeset
500 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
501
786edf5e2144 The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents: 16063
diff changeset
502 logs_dir = g_strconcat(user_dir, G_DIR_SEPARATOR_S "logs", NULL);
786edf5e2144 The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents: 16063
diff changeset
503
786edf5e2144 The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents: 16063
diff changeset
504 if (!strcmp(buf, "../.purple/logs") || !strcmp(buf, 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
505 {
786edf5e2144 The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents: 16063
diff changeset
506 /* 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
507 * 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
508 * so there's no need to fail here. */
786edf5e2144 The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents: 16063
diff changeset
509 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
510 continue;
786edf5e2144 The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents: 16063
diff changeset
511 }
786edf5e2144 The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents: 16063
diff changeset
512
786edf5e2144 The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents: 16063
diff changeset
513 /* 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
514 * 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
515 * 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
516 * 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
517 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
518
786edf5e2144 The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents: 16063
diff changeset
519 /* Relative links will most likely still be
786edf5e2144 The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents: 16063
diff changeset
520 * valid from ~/.purple, though not it's not
786edf5e2144 The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents: 16063
diff changeset
521 * guaranteed. Oh well. */
786edf5e2144 The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents: 16063
diff changeset
522 if (symlink(buf, 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
523 {
16691
f8f78fa7e774 Solicit bug reports
Sean Egan <seanegan@gmail.com>
parents: 16631
diff changeset
524 purple_debug_error("core", "Error symlinking %s to %s: %s. Please report this at http://developer.pidgin.im\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
525 logs_dir, buf, strerror(errno));
786edf5e2144 The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents: 16063
diff changeset
526 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
527 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
528 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
529 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
530 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
531 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
532 }
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 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
535 continue;
786edf5e2144 The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents: 16063
diff changeset
536 }
786edf5e2144 The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents: 16063
diff changeset
537
786edf5e2144 The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents: 16063
diff changeset
538 /* 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
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 #endif
786edf5e2144 The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents: 16063
diff changeset
542
786edf5e2144 The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents: 16063
diff changeset
543 /* 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
544 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
545 {
786edf5e2144 The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents: 16063
diff changeset
546 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
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 /* 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
549 * 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
550 * 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
551 * 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
552 * 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
553
786edf5e2144 The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents: 16063
diff changeset
554 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
555 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
556 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
557
786edf5e2144 The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents: 16063
diff changeset
558 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
559 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
560 {
16691
f8f78fa7e774 Solicit bug reports
Sean Egan <seanegan@gmail.com>
parents: 16631
diff changeset
561 purple_debug_error("core", "Error opening directory %s: %s. Please report this at http://developer.pidgin.im\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
562 name,
786edf5e2144 The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents: 16063
diff changeset
563 (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
564 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
565 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
566 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
567 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
568 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
569 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
570 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
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
786edf5e2144 The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents: 16063
diff changeset
573 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
574 /* 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
575 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
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 (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
578 {
16691
f8f78fa7e774 Solicit bug reports
Sean Egan <seanegan@gmail.com>
parents: 16631
diff changeset
579 purple_debug_error("core", "Error creating directory %s: %s. Please report this at http://developer.pidgin.im\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
580 new_icons_dir, strerror(errno));
786edf5e2144 The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents: 16063
diff changeset
581 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
582 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
583 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
584 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
585 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
586 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
587 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
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 }
786edf5e2144 The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents: 16063
diff changeset
590
786edf5e2144 The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents: 16063
diff changeset
591 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
592 {
786edf5e2144 The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents: 16063
diff changeset
593 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
594
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 (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
596 {
786edf5e2144 The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents: 16063
diff changeset
597 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
598 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
599 {
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(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
601 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
602 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
603 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
604 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
605 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
606 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
607 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
608 }
786edf5e2144 The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents: 16063
diff changeset
609 }
786edf5e2144 The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents: 16063
diff changeset
610 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
611 }
786edf5e2144 The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents: 16063
diff changeset
612
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 }
786edf5e2144 The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents: 16063
diff changeset
615 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
616 {
786edf5e2144 The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents: 16063
diff changeset
617 /* 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
618 * 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
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 else
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 /* 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
623 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
624 {
786edf5e2144 The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents: 16063
diff changeset
625 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
626 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
627 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
628 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
629 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
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 }
786edf5e2144 The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents: 16063
diff changeset
632 }
786edf5e2144 The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents: 16063
diff changeset
633 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
634 {
786edf5e2144 The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents: 16063
diff changeset
635 /* 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
636
786edf5e2144 The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents: 16063
diff changeset
637 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
638 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
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 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
641 {
16691
f8f78fa7e774 Solicit bug reports
Sean Egan <seanegan@gmail.com>
parents: 16631
diff changeset
642 purple_debug_error("core", "Error opening file %s for reading: %s. Please report this at http://developer.pidgin.im\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
643 name, strerror(errno));
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_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
645 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
646 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
647 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
648 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
649 }
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 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
652 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
653 {
16691
f8f78fa7e774 Solicit bug reports
Sean Egan <seanegan@gmail.com>
parents: 16631
diff changeset
654 purple_debug_error("core", "Error opening file %s for writing: %s. Please report this at http://developer.pidgin.im\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
655 new_name, strerror(errno));
786edf5e2144 The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents: 16063
diff changeset
656 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
657 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
658 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
659 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
660 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
661 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
662 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
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
786edf5e2144 The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents: 16063
diff changeset
665 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
666 {
786edf5e2144 The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents: 16063
diff changeset
667 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
668 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
669
786edf5e2144 The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents: 16063
diff changeset
670 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
671 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
672 {
16691
f8f78fa7e774 Solicit bug reports
Sean Egan <seanegan@gmail.com>
parents: 16631
diff changeset
673 purple_debug_error("core", "Error reading %s: %s. Please report this at http://developer.pidgin.im\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
674 name, strerror(errno));
786edf5e2144 The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents: 16063
diff changeset
675 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
676 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
677 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
678 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
679 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
680 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
681 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
682 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
683 }
786edf5e2144 The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents: 16063
diff changeset
684
16482
dec693050305 Proper error checking on fwrite() call
Sean Egan <seanegan@gmail.com>
parents: 16476
diff changeset
685 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
686 {
16691
f8f78fa7e774 Solicit bug reports
Sean Egan <seanegan@gmail.com>
parents: 16631
diff changeset
687 purple_debug_error("core", "Error writing %s: %s. Please report this at http://developer.pidgin.im\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
688 new_name, strerror(errno));
786edf5e2144 The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents: 16063
diff changeset
689 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
690 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
691 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
692 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
693 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
694 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
695 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
696 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
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 }
786edf5e2144 The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents: 16063
diff changeset
699
786edf5e2144 The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents: 16063
diff changeset
700 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
701 {
16691
f8f78fa7e774 Solicit bug reports
Sean Egan <seanegan@gmail.com>
parents: 16631
diff changeset
702 purple_debug_error("core", "Error writing: %s: %s. Please report this at http://developer.pidgin.im\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
703 new_name, strerror(errno));
786edf5e2144 The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents: 16063
diff changeset
704 }
786edf5e2144 The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents: 16063
diff changeset
705 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
706 {
786edf5e2144 The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents: 16063
diff changeset
707 purple_debug_warning("core", "Error closing %s: %s\n",
786edf5e2144 The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents: 16063
diff changeset
708 name, strerror(errno));
786edf5e2144 The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents: 16063
diff changeset
709 }
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_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
711 }
786edf5e2144 The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents: 16063
diff changeset
712 else
786edf5e2144 The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents: 16063
diff changeset
713 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
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 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
716 }
786edf5e2144 The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents: 16063
diff changeset
717
786edf5e2144 The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents: 16063
diff changeset
718 /* 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
719 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
720 {
16691
f8f78fa7e774 Solicit bug reports
Sean Egan <seanegan@gmail.com>
parents: 16631
diff changeset
721 purple_debug_error("core", "Error unlinking file %s: %s. Please report this at http://developer.pidgin.im\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
722 status_file, strerror(errno));
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(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
724 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
725 }
786edf5e2144 The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents: 16063
diff changeset
726
786edf5e2144 The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents: 16063
diff changeset
727 old_icons_dir = g_build_filename(old_user_dir, "icons", NULL);
16631
f9c369b4291c Fix up the private function calls to be prefixed with an underscore.
Richard Laager <rlaager@wiktel.com>
parents: 16596
diff changeset
728 _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
729 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
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 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
732
786edf5e2144 The core portion of the migration code. This is implemented as I described
Richard Laager <rlaager@wiktel.com>
parents: 16063
diff changeset
733 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
734 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
735 }