Esempio n. 1
0
EmpathyAccount *
get_test_account (void)
{
  McProfile *profile;
  EmpathyAccountManager *account_manager;
  EmpathyAccount *account;
  GList *accounts;

  account_manager = empathy_account_manager_dup_singleton ();
  profile = mc_profile_lookup ("test");
  accounts = mc_accounts_list_by_profile (profile);
  if (g_list_length (accounts) == 0)
    {
      /* need to create a test account */
      account = empathy_account_manager_create_by_profile (account_manager,
          profile);
    }
  else
    {
      /* reuse an existing test account */
      McAccount *mc_account;
      mc_account = accounts->data;
      account = empathy_account_manager_lookup (account_manager,
        mc_account_get_unique_name (mc_account));
    }
  g_object_unref (account_manager);

  g_object_unref (profile);

  return account;
}
static void
import_dialog_add_accounts_to_model (EmpathyImportDialog *dialog)
{
  GtkTreeModel *model;
  GtkTreeIter iter;
  GList *l;

  model = gtk_tree_view_get_model (GTK_TREE_VIEW (dialog->treeview));

  for (l = dialog->accounts; l; l = l->next)
    {
      GValue *value;
      EmpathyImportAccountData *data = l->data;
      gboolean import;
      GList *accounts;

      value = g_hash_table_lookup (data->settings, "account");

      accounts = mc_accounts_list_by_profile (data->profile);

      /* Only set the "Import" cell to be active if there isn't already an
       * account set up with the same account id. */
      import = !import_dialog_account_id_in_list (accounts,
          g_value_get_string (value));

      mc_accounts_list_free (accounts);

      gtk_list_store_append (GTK_LIST_STORE (model), &iter);

      gtk_list_store_set (GTK_LIST_STORE (model), &iter,
          COL_IMPORT, import,
          COL_PROTOCOL, mc_profile_get_display_name (data->profile),
          COL_NAME, g_value_get_string (value),
          COL_SOURCE, data->source,
          COL_ACCOUNT_DATA, data,
          -1);
    }
}
Esempio n. 3
0
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);
}