コード例 #1
0
void
tpaw_keyring_set_room_password_async (TpAccount *account,
    const gchar *id,
    const gchar *password,
    GAsyncReadyCallback callback,
    gpointer user_data)
{
  GSimpleAsyncResult *simple;
  const gchar *account_id;
  gchar *name;

  g_return_if_fail (TP_IS_ACCOUNT (account));
  g_return_if_fail (id != NULL);
  g_return_if_fail (password != NULL);

  simple = g_simple_async_result_new (G_OBJECT (account), callback,
      user_data, tpaw_keyring_set_room_password_async);

  account_id = tp_proxy_get_object_path (account) +
    strlen (TP_ACCOUNT_OBJECT_PATH_BASE);

  DEBUG ("Remembering password for room '%s' on account '%s'", id, account_id);

  name = g_strdup_printf (_("Password for chatroom “%s” on account %s (%s)"),
      id, tp_account_get_display_name (account), account_id);

  secret_password_store (&room_keyring_schema, NULL, name, password,
      NULL, store_password_cb, simple,
      "account-id", account_id,
      "room-id", id,
      NULL);

  g_free (name);
}
コード例 #2
0
void
tpaw_keyring_set_account_password_async (TpAccount *account,
    const gchar *password,
    gboolean remember,
    GAsyncReadyCallback callback,
    gpointer user_data)
{
  GSimpleAsyncResult *simple;
  const gchar *account_id;
  gchar *name;

  g_return_if_fail (TP_IS_ACCOUNT (account));
  g_return_if_fail (password != NULL);

  simple = g_simple_async_result_new (G_OBJECT (account), callback,
      user_data, tpaw_keyring_set_account_password_async);

  account_id = tp_proxy_get_object_path (account) +
    strlen (TP_ACCOUNT_OBJECT_PATH_BASE);

  DEBUG ("Remembering password for %s", account_id);

#ifdef HAVE_UOA
    {
      const gchar *provider;

      provider = tp_account_get_storage_provider (account);
      if (!tp_strdiff (provider, TPAW_UOA_PROVIDER))
        {
          uoa_set_account_password (account, password, remember, simple);
          g_object_unref (simple);
          return;
        }
    }
#endif

  name = g_strdup_printf (_("IM account password for %s (%s)"),
      tp_account_get_display_name (account), account_id);

  secret_password_store (&account_keyring_schema,
      remember ? NULL : SECRET_COLLECTION_SESSION,
      name, password,
      NULL, store_password_cb, simple,
      "account-id", account_id,
      "param-name", "password",
      NULL);

  g_free (name);
}
コード例 #3
0
ファイル: web-service.c プロジェクト: KapTmaN/gthumb
static void
get_user_info_ready_cb (GObject      *source_object,
			GAsyncResult *res,
			gpointer      user_data)
{
	WebService   *self = user_data;
	GError       *error = NULL;
	OAuthAccount *account;

	account = web_service_get_user_info_finish (self, res, &error);
	if (account == NULL) {
		show_authentication_error_dialog (self, &error);
		return;
	}

	set_current_account (self, account);
	oauth_accounts_save_to_file (self->priv->service_name,
				     self->priv->accounts,
				     self->priv->account);

#ifdef HAVE_LIBSECRET
	{
		char *secret;

		secret = serialize_secret (account->token, account->token_secret);
		secret_password_store (SECRET_SCHEMA_COMPAT_NETWORK,
				       NULL,
				       self->priv->service_name,
				       secret,
				       self->priv->cancellable,
				       password_store_ready_cb,
				       self,
				       "user", account->id,
				       "server", self->priv->service_address,
				       "protocol", self->priv->service_protocol,
				       NULL);

		g_free (secret);
	}
#else
	web_service_account_ready (self);
#endif

	g_object_unref (account);
}
コード例 #4
0
ファイル: secret.c プロジェクト: vifino/dwb
static void 
on_service_pwd(GObject *source, GAsyncResult *result, dwb_secret_t *secret) {
    SecretService *service = get_service(secret, result);
    const char *path = NULL;
    if (service != NULL) {
        dwb_pwd_t *pwd = secret->data;
        if (pwd->collection != NULL) {
            path = collection_lookup_path(service, pwd->collection);
        }
        if (path != NULL || pwd->collection == NULL) {
            if (secret->action == DWB_SECRET_ACTION_STORE) {
                secret_password_store(&s_schema, path, pwd->label, pwd->pwd, NULL,
                        (GAsyncReadyCallback)on_store_pwd, secret, "id", pwd->id, NULL);
            }
            else {
                secret_password_lookup(&s_schema, NULL, (GAsyncReadyCallback)on_lookup_pwd, secret, "id", pwd->id, NULL);
            }
        }
        else {
            invoke(secret, DWB_SECRET_NO_SUCH_COLLECTION, NULL);
        }
        g_object_unref(service);
    }
}
コード例 #5
0
void
mobile_helper_save_pin_in_keyring (const char *devid,
                                   const char *simid,
                                   const char *pin)
{
	char *name;
	char *error_msg;

	name = g_strdup_printf (_("PIN code for SIM card '%s' on '%s'"),
	                        simid ? simid : "unknown",
	                        devid);

	error_msg = g_strdup_printf ("Saving PIN code in keyring for devid:%s simid:%s failed",
	                             devid, simid ? simid : "(unknown)");

	secret_password_store (&mobile_secret_schema,
	                       NULL, name, pin,
	                       NULL, save_pin_cb, error_msg,
	                       "devid", devid,
	                       simid ? "simid" : NULL, simid,
	                       NULL);

	g_free (name);
}