Esempio n. 1
0
File: secret.c Progetto: vifino/dwb
static void 
on_service_lock_unlock_collection(GObject *source, GAsyncResult *result, dwb_secret_t *secret) {
    SecretService *service = get_service(secret, result);
    if (service == NULL) 
        return;

    GList *cols = NULL;
    GList *collections = secret_service_get_collections(service);
    gboolean lock = secret->action == DWB_SECRET_ACTION_LOCK;

    for (GList *l = collections; l != NULL; l=l->next) {
        SecretCollection *collection = l->data;
        gboolean locked = secret_collection_get_locked(collection);
        if ((lock && !locked) || (!lock && locked)) {
            char *label = secret_collection_get_label(collection);
            if (!g_strcmp0(secret->data, label)) {
                cols = g_list_append(cols, collection);
            }
            g_free(label);
        }
    }
    if (cols != NULL) {
        if (!lock) 
            secret_service_unlock(service, cols, NULL, (GAsyncReadyCallback)on_lock_unlock_collection, secret);
        else 
            secret_service_lock(service, cols, NULL, (GAsyncReadyCallback)on_lock_unlock_collection, secret);
    }
    else {
        invoke(secret, DWB_SECRET_NO_SUCH_COLLECTION, NULL);
    }
    if (collections != NULL) {
        g_list_free_full(collections, g_object_unref);
    }
    g_object_unref(service);
}
Esempio n. 2
0
static void remmina_plugin_glibsecret_unlock_secret_service()
{
	TRACE_CALL(__func__);

#ifdef LIBSECRET_VERSION_0_18

	GError *error = NULL;
	GList *objects, *ul;
	gchar* lbl;

	if (secretservice && defaultcollection) {
		if (secret_collection_get_locked(defaultcollection)) {
			lbl = secret_collection_get_label(defaultcollection);
			remmina_plugin_service->log_printf("[glibsecret] requesting unlock of the default '%s' collection\n", lbl);
			objects = g_list_append(NULL, defaultcollection);
			secret_service_unlock_sync(secretservice, objects, NULL, &ul, &error);
			g_list_free(objects);
			g_list_free(ul);
		}
	}
#endif
	return;
}