Example #1
0
static void
password_lookup_ready_cb (GObject      *source_object,
			  GAsyncResult *result,
			  gpointer      user_data)
{
	WebService *self = user_data;
	char       *secret;

	secret = secret_password_lookup_finish (result, NULL);
	if (secret != NULL) {
		char *token;
		char *token_secret;

		if (deserialize_secret (secret, &token, &token_secret)) {
			g_object_set (G_OBJECT (self->priv->account),
				      "token", token,
				      "token-secret", token_secret,
				      NULL);

			g_free (token);
			g_free (token_secret);
		}

		g_free (secret);
	}

	connect_to_server_step2 (self);
}
static void
lookup_item_cb (GObject *source,
    GAsyncResult *result,
    gpointer user_data)
{
  GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (user_data);
  GError *error = NULL;
  gchar *password;

  password = secret_password_lookup_finish (result, &error);
  if (error != NULL)
    {
      g_simple_async_result_set_error (simple, TP_ERROR,
          TP_ERROR_DOES_NOT_EXIST, "%s", error->message);
      g_clear_error (&error);
      goto out;
    }

  if (password == NULL)
    {
      g_simple_async_result_set_error (simple, TP_ERROR,
          TP_ERROR_DOES_NOT_EXIST, _("Password not found"));
      goto out;
    }

  g_simple_async_result_set_op_res_gpointer (simple, password,
      (GDestroyNotify) secret_password_free);

out:
  g_simple_async_result_complete (simple);
  g_object_unref (simple);
}
Example #3
0
File: secret.c Project: vifino/dwb
static void 
on_lookup_pwd(GObject *o, GAsyncResult *result, dwb_secret_t *secret) {
    GError *e = NULL;
    char *pwd = secret_password_lookup_finish(result, &e);
    if (e == NULL) {
        invoke(secret, DWB_SECRET_OK, pwd);
        secret_password_free(pwd);
    }
    else {
        invoke(secret, DWB_SECRET_ERROR, NULL);
        g_error_free(e);
    }
}