Ejemplo n.º 1
0
const backend_libsecret_context_t*
dt_pwstorage_libsecret_new()
{
  backend_libsecret_context_t* context = calloc(1, sizeof(backend_libsecret_context_t));
  if (context == NULL) {
    return NULL;
  }

  context->secret_service = secret_service_get_sync(SECRET_SERVICE_LOAD_COLLECTIONS, NULL, NULL);
  if (context->secret_service == NULL) {
    dt_pwstorage_libsecret_destroy(context);
    return NULL;
  }

  /* Ensure to load all collections */
  if (secret_service_load_collections_sync(context->secret_service, NULL, NULL) == FALSE) {
    dt_pwstorage_libsecret_destroy(context);
    return NULL;
  }

  GList* collections = secret_service_get_collections(context->secret_service);
  SecretCollection* item = NULL;

  gboolean collection_exists = FALSE;
  GFOREACH(item, collections) {
    gchar* label = secret_collection_get_label(item);
    if (g_strcmp0(label, DARKTABLE_KEYRING)) {
      collection_exists = TRUE;
      context->secret_collection = item;
      g_object_ref(context->secret_collection);

      g_free(label);
      break;
    }
    g_free(label);
  }
Ejemplo n.º 2
0
/** Cleanup and destroy pwstorage context. \remarks After this point pointer at pwstorage is invalid. */
void dt_pwstorage_destroy(const dt_pwstorage_t *pwstorage)
{
  dt_print(DT_DEBUG_PWSTORAGE, "[pwstorage_new] Destroying context %p\n", pwstorage);
  switch(darktable.pwstorage->pw_storage_backend)
  {
    case PW_STORAGE_BACKEND_NONE:
      // nothing to be done
      break;
    case PW_STORAGE_BACKEND_LIBSECRET:
#ifdef HAVE_LIBSECRET
      dt_pwstorage_libsecret_destroy(pwstorage->backend_context);
#endif
      break;
    case PW_STORAGE_BACKEND_KWALLET:
#ifdef HAVE_KWALLET
      dt_pwstorage_kwallet_destroy(pwstorage->backend_context);
#endif
      break;
  }
}