Ejemplo n.º 1
0
// General initialization. Takes care of all the other stuff.
const backend_kwallet_context_t* dt_pwstorage_kwallet_new()
{
  backend_kwallet_context_t *context = g_malloc(sizeof(backend_kwallet_context_t));
  memset(context, 0, sizeof(backend_kwallet_context_t));

  GError* error = NULL;
  context->connection = g_bus_get_sync(G_BUS_TYPE_SESSION,NULL, &error);
  if(check_error(error))
  {
    g_free(context);
    return NULL;
  }

  if(!init_kwallet(context))
  {
    // kwalletd may not be running. Try to start it and try again.
    if (!start_kwallet(context) || !init_kwallet(context))
    {
      g_object_unref(context->connection);
      g_free(context);
      return NULL;
    }
  }

  return context;
}
Ejemplo n.º 2
0
// General initialization. Takes care of all the other stuff.
const backend_kwallet_context_t* dt_pwstorage_kwallet_new()
{
  _context = g_malloc(sizeof(backend_kwallet_context_t));

  // NULL the context
  memset(_context, 0, sizeof(backend_kwallet_context_t));

#if GLIB_MAJOR_VERSION <= 2
#if GLIB_MINOR_VERSION < 31
  // Initialize threading in dbus-glib - it should be fine for
  // dbus_g_thread_init to be called multiple times.
  if (!g_thread_supported())
    g_thread_init(NULL);
#endif
#endif
  dbus_g_thread_init();

  GError* error = NULL;
  // Get a connection to the session bus.
  _context->connection = dbus_g_bus_get(DBUS_BUS_SESSION, &error);

  if (CheckError(error))
    return NULL;

  if (!init_kwallet())
  {
    // kwalletd may not be running. Try to start it and try again.
    if (!start_kwallet() || !init_kwallet())
      return NULL;
  }

  return _context;
}