|
Lines 31-36
Link Here
|
| 31 |
#include <dbus/dbus.h> |
31 |
#include <dbus/dbus.h> |
| 32 |
#include <glib.h> |
32 |
#include <glib.h> |
| 33 |
|
33 |
|
|
|
34 |
#include <gio/gio.h> |
| 35 |
|
| 34 |
#include <libpurple/account.h> |
36 |
#include <libpurple/account.h> |
| 35 |
#include <libpurple/core.h> |
37 |
#include <libpurple/core.h> |
| 36 |
#include <libpurple/blist.h> |
38 |
#include <libpurple/blist.h> |
|
Lines 175-180
Link Here
|
| 175 |
|
177 |
|
| 176 |
} |
178 |
} |
| 177 |
|
179 |
|
|
|
180 |
|
| 181 |
static void |
| 182 |
copy_one_cert_dir (const gchar *source_root, |
| 183 |
GFile *target_dir) |
| 184 |
{ |
| 185 |
gchar *source_path; |
| 186 |
GFile *source_dir; |
| 187 |
GFileEnumerator *contents; |
| 188 |
GFileInfo *child_info; |
| 189 |
GError *error = NULL; |
| 190 |
|
| 191 |
source_path = g_build_filename (source_root, "telepathy-haze", |
| 192 |
"certificates", NULL); |
| 193 |
source_dir = g_file_new_for_path (source_path); |
| 194 |
|
| 195 |
contents = g_file_enumerate_children (source_dir, |
| 196 |
G_FILE_ATTRIBUTE_STANDARD_NAME, G_FILE_QUERY_INFO_NONE, NULL, &error); |
| 197 |
|
| 198 |
if (contents == NULL) |
| 199 |
{ |
| 200 |
if (error->domain != G_IO_ERROR || error->code != G_IO_ERROR_NOT_FOUND) |
| 201 |
DEBUG ("couldn't list %s (%s, %d, %s); skipping", source_path, |
| 202 |
g_quark_to_string (error->domain), error->code, error->message); |
| 203 |
|
| 204 |
g_error_free (error); |
| 205 |
goto finally; |
| 206 |
} |
| 207 |
|
| 208 |
while ((child_info = g_file_enumerator_next_file (contents, NULL, &error))) |
| 209 |
{ |
| 210 |
const gchar *child_name = g_file_info_get_name (child_info); |
| 211 |
GFile *source_file = g_file_get_child (source_dir, child_name); |
| 212 |
GFile *target_file = g_file_get_child (target_dir, child_name); |
| 213 |
gboolean yay; |
| 214 |
|
| 215 |
yay = g_file_copy (source_file, target_file, 0, NULL, NULL, NULL, |
| 216 |
&error); |
| 217 |
|
| 218 |
if (!yay) |
| 219 |
{ |
| 220 |
DEBUG ("couldn't copy %s to %s: %s", g_file_get_basename |
| 221 |
(source_file), g_file_get_basename (target_file), |
| 222 |
error->message); |
| 223 |
g_clear_error (&error); |
| 224 |
} |
| 225 |
|
| 226 |
g_object_unref (source_file); |
| 227 |
g_object_unref (target_file); |
| 228 |
g_object_unref (child_info); |
| 229 |
} |
| 230 |
|
| 231 |
g_object_unref (contents); |
| 232 |
|
| 233 |
finally: |
| 234 |
g_object_unref (source_dir); |
| 235 |
g_free (source_path); |
| 236 |
} |
| 237 |
|
| 238 |
|
| 239 |
/** |
| 240 |
* seed_tls_peers: |
| 241 |
* |
| 242 |
* Adds known-trusted certificates from haze's data dirs to the temporary |
| 243 |
* libpurple config directory. Thus, people can work around haze falling down |
| 244 |
* a well if libpurple wants to ask the user to accept or decline a cert. |
| 245 |
*/ |
| 246 |
static void |
| 247 |
seed_tls_peers (void) |
| 248 |
{ |
| 249 |
const gchar * const *dirs = g_get_system_data_dirs (); |
| 250 |
gchar *target_path; |
| 251 |
GFile *target_dir; |
| 252 |
int ret; |
| 253 |
|
| 254 |
target_path = g_build_filename (user_dir, "certificates", "x509", |
| 255 |
"tls_peers", NULL); |
| 256 |
ret = g_mkdir_with_parents (target_path, 0755); |
| 257 |
DEBUG ("%s", target_path); |
| 258 |
|
| 259 |
if (ret != 0) |
| 260 |
{ |
| 261 |
g_warning ("Couldn't mkdir -p %s: %s", target_path, g_strerror (errno)); |
| 262 |
goto finally; |
| 263 |
} |
| 264 |
|
| 265 |
target_dir = g_file_new_for_path (target_path); |
| 266 |
|
| 267 |
copy_one_cert_dir (g_get_user_data_dir (), target_dir); |
| 268 |
|
| 269 |
for (; *dirs != NULL; dirs++) |
| 270 |
copy_one_cert_dir (*dirs, target_dir); |
| 271 |
|
| 272 |
g_object_unref (target_dir); |
| 273 |
|
| 274 |
finally: |
| 275 |
g_free (target_path); |
| 276 |
} |
| 277 |
|
| 278 |
|
| 178 |
static void |
279 |
static void |
| 179 |
init_libpurple (void) |
280 |
init_libpurple (void) |
| 180 |
{ |
281 |
{ |
|
Lines 202-207
Link Here
|
| 202 |
purple_dbus_uninit (); |
303 |
purple_dbus_uninit (); |
| 203 |
#endif |
304 |
#endif |
| 204 |
|
305 |
|
|
|
306 |
seed_tls_peers (); |
| 307 |
|
| 205 |
purple_set_blist(purple_blist_new()); |
308 |
purple_set_blist(purple_blist_new()); |
| 206 |
purple_blist_load(); |
309 |
purple_blist_load(); |
| 207 |
|
310 |
|