diff options
author | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2012-03-06 22:08:03 +0800 |
---|---|---|
committer | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2012-03-06 23:15:17 +0800 |
commit | c69625323288a119356bb6627c00f21a74f32f24 (patch) | |
tree | db2adc21396be4a5413e23027ed3c498ba3c4fb0 /src/empathy-sanity-cleaning.c | |
parent | aeab15ec37370f3c3aa8b4e1a4aec480109a6803 (diff) | |
download | gsoc2013-empathy-c69625323288a119356bb6627c00f21a74f32f24.tar gsoc2013-empathy-c69625323288a119356bb6627c00f21a74f32f24.tar.gz gsoc2013-empathy-c69625323288a119356bb6627c00f21a74f32f24.tar.bz2 gsoc2013-empathy-c69625323288a119356bb6627c00f21a74f32f24.tar.lz gsoc2013-empathy-c69625323288a119356bb6627c00f21a74f32f24.tar.xz gsoc2013-empathy-c69625323288a119356bb6627c00f21a74f32f24.tar.zst gsoc2013-empathy-c69625323288a119356bb6627c00f21a74f32f24.zip |
Add magic to automatically run tasks when empathy-auth-client is started
empathy-auth-client is the best place to do such tasks as it will be run even
if using only the Shell without Empathy's UI.
https://bugzilla.gnome.org/show_bug.cgi?id=671452
Diffstat (limited to 'src/empathy-sanity-cleaning.c')
-rw-r--r-- | src/empathy-sanity-cleaning.c | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/src/empathy-sanity-cleaning.c b/src/empathy-sanity-cleaning.c new file mode 100644 index 000000000..95353eb05 --- /dev/null +++ b/src/empathy-sanity-cleaning.c @@ -0,0 +1,89 @@ +/* + * empathy-sanity-cleaning.c + * Code automatically called when starting a specific version of Empathy for + * the first time doing misc cleaning. + * + * Copyright (C) 2012 Collabora Ltd. + * @author Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "config.h" + +#include "empathy-sanity-cleaning.h" + +#include <telepathy-glib/telepathy-glib.h> + +#include <libempathy/empathy-gsettings.h> + +#define DEBUG_FLAG EMPATHY_DEBUG_OTHER +#include <libempathy/empathy-debug.h> + +/* + * This number has to be increased each time a new task is added or modified. + * + * If the number stored in gsettings is lower than it, all the tasks will + * be executed. + */ +#define SANITY_CLEANING_NUMBER 0 + +static void +run_sanity_cleaning_tasks (TpAccountManager *am) +{ + DEBUG ("Starting sanity cleaning tasks"); +} + +static void +am_prepare_cb (GObject *source, + GAsyncResult *result, + gpointer user_data) +{ + GError *error = NULL; + TpAccountManager *am = TP_ACCOUNT_MANAGER (source); + + if (!tp_proxy_prepare_finish (am, result, &error)) + { + DEBUG ("Failed to prepare account manager: %s", error->message); + g_error_free (error); + return; + } + + run_sanity_cleaning_tasks (am); +} + +void empathy_sanity_checking_run_if_needed (void) +{ + GSettings *settings; + guint number; + TpAccountManager *am; + + settings = g_settings_new (EMPATHY_PREFS_SCHEMA); + number = g_settings_get_uint (settings, EMPATHY_PREFS_SANITY_CLEANING_NUMBER); + + if (number == SANITY_CLEANING_NUMBER) + goto out; + + am = tp_account_manager_dup (); + + tp_proxy_prepare_async (am, NULL, am_prepare_cb, NULL); + + g_settings_set_uint (settings, EMPATHY_PREFS_SANITY_CLEANING_NUMBER, + SANITY_CLEANING_NUMBER); + + g_object_unref (am); +out: + g_object_unref (settings); +} |