2 * Copyright (C) 2007-2010 Collabora Ltd.
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 * Authors: Xavier Claessens <xclaesse@gmail.com>
19 * Guillaume Desmottes <guillaume.desmottes@collabora.co.uk>
25 #include <glib/gi18n-lib.h>
27 #include <telepathy-glib/account-manager.h>
28 #include <telepathy-glib/util.h>
31 #include <libebook/e-book.h>
34 #include <libempathy/empathy-account-settings.h>
36 #define DEBUG_FLAG EMPATHY_DEBUG_ACCOUNT
37 #include <libempathy/empathy-debug.h>
39 #include "empathy-auto-salut-account-helper.h"
41 EmpathyAccountSettings *
42 create_salut_account_settings (void)
44 EmpathyAccountSettings *settings;
48 gchar *nickname = NULL;
49 gchar *first_name = NULL;
50 gchar *last_name = NULL;
56 settings = empathy_account_settings_new ("salut", "local-xmpp", NULL,
60 /* Get self EContact from EDS */
61 if (!e_book_get_self (&contact, &book, &error))
63 DEBUG ("Failed to get self econtact: %s", error->message);
68 nickname = e_contact_get (contact, E_CONTACT_NICKNAME);
69 first_name = e_contact_get (contact, E_CONTACT_GIVEN_NAME);
70 last_name = e_contact_get (contact, E_CONTACT_FAMILY_NAME);
71 email = e_contact_get (contact, E_CONTACT_EMAIL_1);
72 jid = e_contact_get (contact, E_CONTACT_IM_JABBER_HOME_1);
74 if (!tp_strdiff (nickname, "nickname"))
80 DEBUG ("Salut account created:\nnickname=%s\nfirst-name=%s\n"
81 "last-name=%s\nemail=%s\njid=%s\n",
82 nickname, first_name, last_name, email, jid);
84 empathy_account_settings_set_string (settings,
85 "nickname", nickname ? nickname : "");
86 empathy_account_settings_set_string (settings,
87 "first-name", first_name ? first_name : "");
88 empathy_account_settings_set_string (settings,
89 "last-name", last_name ? last_name : "");
90 empathy_account_settings_set_string (settings, "email", email ? email : "");
91 empathy_account_settings_set_string (settings, "jid", jid ? jid : "");
98 g_object_unref (contact);
99 g_object_unref (book);