static void import_dialog_add_account (EmpathyImportAccountData *data) { McAccount *account; GHashTableIter iter; gpointer key, value; gchar *display_name; GValue *username; account = mc_account_create (data->profile); g_hash_table_iter_init (&iter, data->settings); while (g_hash_table_iter_next (&iter, &key, &value)) { const gchar *param = key; GValue *gvalue = value; switch (G_VALUE_TYPE (gvalue)) { case G_TYPE_STRING: DEBUG ("Set param '%s' to '%s' (string)", param, g_value_get_string (gvalue)); mc_account_set_param_string (account, param, g_value_get_string (gvalue)); break; case G_TYPE_BOOLEAN: DEBUG ("Set param '%s' to %s (boolean)", param, g_value_get_boolean (gvalue) ? "TRUE" : "FALSE"); mc_account_set_param_boolean (account, param, g_value_get_boolean (gvalue)); break; case G_TYPE_INT: DEBUG ("Set param '%s' to '%i' (integer)", param, g_value_get_int (gvalue)); mc_account_set_param_int (account, param, g_value_get_int (gvalue)); break; } } /* Set the display name of the account */ username = g_hash_table_lookup (data->settings, "account"); display_name = g_strdup_printf ("%s (%s)", mc_profile_get_display_name (data->profile), g_value_get_string (username)); mc_account_set_display_name (account, display_name); g_free (display_name); g_object_unref (account); }
static void create_salut_account (void) { McProfile *profile; McProtocol *protocol; gboolean salut_created = FALSE; McAccount *account; GList *accounts; EBook *book; EContact *contact; gchar *nickname = NULL; gchar *first_name = NULL; gchar *last_name = NULL; gchar *email = NULL; gchar *jid = NULL; GError *error = NULL; /* Check if we already created a salut account */ empathy_conf_get_bool (empathy_conf_get(), EMPATHY_PREFS_SALUT_ACCOUNT_CREATED, &salut_created); if (salut_created) { return; } DEBUG ("Try to add a salut account..."); /* Check if the salut CM is installed */ profile = mc_profile_lookup ("salut"); if (!profile) { DEBUG ("No salut profile"); return; } protocol = mc_profile_get_protocol (profile); if (!protocol) { DEBUG ("Salut not installed"); g_object_unref (profile); return; } g_object_unref (protocol); /* Get self EContact from EDS */ if (!e_book_get_self (&contact, &book, &error)) { DEBUG ("Failed to get self econtact: %s", error ? error->message : "No error given"); g_clear_error (&error); g_object_unref (profile); return; } empathy_conf_set_bool (empathy_conf_get (), EMPATHY_PREFS_SALUT_ACCOUNT_CREATED, TRUE); /* Check if there is already a salut account */ accounts = mc_accounts_list_by_profile (profile); if (accounts) { DEBUG ("There is already a salut account"); mc_accounts_list_free (accounts); g_object_unref (profile); return; } account = mc_account_create (profile); mc_account_set_display_name (account, _("People nearby")); nickname = e_contact_get (contact, E_CONTACT_NICKNAME); first_name = e_contact_get (contact, E_CONTACT_GIVEN_NAME); last_name = e_contact_get (contact, E_CONTACT_FAMILY_NAME); email = e_contact_get (contact, E_CONTACT_EMAIL_1); jid = e_contact_get (contact, E_CONTACT_IM_JABBER_HOME_1); if (!tp_strdiff (nickname, "nickname")) { g_free (nickname); nickname = NULL; } DEBUG ("Salut account created:\nnickname=%s\nfirst-name=%s\n" "last-name=%s\nemail=%s\njid=%s\n", nickname, first_name, last_name, email, jid); mc_account_set_param_string (account, "nickname", nickname ? nickname : ""); mc_account_set_param_string (account, "first-name", first_name ? first_name : ""); mc_account_set_param_string (account, "last-name", last_name ? last_name : ""); mc_account_set_param_string (account, "email", email ? email : ""); mc_account_set_param_string (account, "jid", jid ? jid : ""); g_free (nickname); g_free (first_name); g_free (last_name); g_free (email); g_free (jid); g_object_unref (account); g_object_unref (profile); g_object_unref (contact); g_object_unref (book); }