diff --git a/src/Makefile b/src/Makefile index 5ee5a0790d920f0d3d0137d9841876b58db1a2c0..a6f861cc9a7f4bad8472a70d66957d28f1272e82 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1,7 +1,7 @@ CXX ?= g++ # Accepts CXXSTD >= C++14 -CXXFLAGS := $(shell pkg-config --cflags --libs gnome-keyring-1) -I ./lib -I . -std=c++14 +CXXFLAGS := $(shell pkg-config --cflags --libs gnome-keyring-1) $(shell pkg-config --cflags --libs libsecret-1) -I ./lib -I . -std=c++14 EXTRA_FLAGS ?= secret: diff --git a/src/keyring_op.hpp b/src/keyring_op.hpp index de9d1da0c84e68c7fe2baab98a5f5a9d0efda442..d61034064311e1f7367b88825104e26b6dbf2f05 100644 --- a/src/keyring_op.hpp +++ b/src/keyring_op.hpp @@ -2,6 +2,35 @@ #include <string> #include <rlib/macro.hpp> +#include <libsecret/secret.h> +#include <gmodule.h> +#include <rlib/stdio.hpp> + +inline std::string do_unlock_2(std::string keyring, std::string password) { + GError *err = NULL; + SecretService *service_proxy_ptr = secret_service_get_sync(SECRET_SERVICE_LOAD_COLLECTIONS, NULL, &err); + if(err != NULL or service_proxy_ptr == NULL) { + return err->message; + } + rlib_defer([&]{g_object_unref(service_proxy_ptr);}); + + GList *collections = secret_service_get_collections(service_proxy_ptr); + if(collections == NULL) return "collection gg"; + + auto curr = collections; + while (curr != NULL) + { + auto iter = reinterpret_cast<SecretCollection *>(curr->data); + auto label = secret_collection_get_label(iter); + if(label == NULL) break; + rlib_defer([&]{g_free(label);}); + rlib::println("DEBUG: LABEL=", label); + + curr = curr->next; + } + return ""; +} + inline GnomeKeyringResult do_unlock(std::string keyring, std::string password) { return gnome_keyring_unlock_sync(keyring.c_str(), password.c_str()); }