Commit 560c6fc6 authored by Christian Kellner's avatar Christian Kellner
Browse files

Use BoltKeyStore, BoltDatabase enums everywhere

parent f10a9e7c
......@@ -61,9 +61,9 @@ struct _BoltDevice
BoltSecurity security;
/* when device is stored */
BoltPolicy policy;
guint store; /* currently: 0,no / 1,yes */
guint key; /* currently 0,no / 1,yes */
BoltPolicy policy;
BoltDatabase store;
BoltKeyState key;
};
......@@ -803,7 +803,7 @@ bolt_device_update_from_udev (BoltDevice *dev,
return status;
}
guint
BoltKeyState
bolt_device_get_key (BoltDevice *dev)
{
return dev->key;
......@@ -857,7 +857,7 @@ bolt_device_get_status (BoltDevice *dev)
return dev->status;
}
guint
BoltDatabase
bolt_device_get_store (BoltDevice *dev)
{
return dev->store;
......
......@@ -65,7 +65,7 @@ gboolean bolt_device_authorize (BoltDevice *dev,
gpointer user_data,
GError **error);
guint bolt_device_get_key (BoltDevice *dev);
BoltKeyState bolt_device_get_key (BoltDevice *dev);
const char * bolt_device_get_name (BoltDevice *dev);
......@@ -77,7 +77,7 @@ const char * bolt_device_get_uid (BoltDevice *dev);
BoltSecurity bolt_device_get_security (BoltDevice *dev);
guint bolt_device_get_store (BoltDevice *dev);
BoltDatabase bolt_device_get_store (BoltDevice *dev);
BoltStatus bolt_device_get_status (BoltDevice *dev);
......
......@@ -377,7 +377,7 @@ handle_uevent_udev (GIOChannel *source,
if (!dev)
return G_SOURCE_CONTINUE;
if (bolt_device_get_store (dev) > 0)
if (bolt_device_get_store (dev) > BOLT_DB_NONE)
handle_udev_device_detached (mgr, dev);
else
hanlde_udev_device_removed (mgr, dev);
......
......@@ -430,7 +430,7 @@ bolt_store_put_device (BoltStore *store,
if (!ok)
g_warning ("failed to store key: %s", err->message);
else
keystate = 1;
keystate = BOLT_KEY_HAVE;
}
ok = g_file_replace_contents (entry,
......@@ -443,7 +443,7 @@ bolt_store_put_device (BoltStore *store,
if (ok)
{
g_object_set (device,
"store", 1,
"store", BOLT_DB_FSDB,
"policy", policy,
"key", keystate,
NULL);
......@@ -464,9 +464,9 @@ bolt_store_get_device (BoltStore *store, const char *uid, GError **error)
g_autofree char *data = NULL;
g_autofree char *polstr = NULL;
BoltPolicy policy;
BoltKeyState key;
gboolean ok;
gsize len;
guint key;
g_return_val_if_fail (store != NULL, FALSE);
g_return_val_if_fail (uid != NULL, FALSE);
......@@ -501,7 +501,7 @@ bolt_store_get_device (BoltStore *store, const char *uid, GError **error)
"name", name,
"vendor", vendor,
"status", BOLT_STATUS_DISCONNECTED,
"store", 1,
"store", BOLT_DB_FSDB,
"policy", policy,
"key", key,
NULL);
......@@ -551,7 +551,7 @@ bolt_store_create_key (BoltStore *store,
}
guint
BoltKeyState
bolt_store_have_key (BoltStore *store,
const char *uid)
{
......@@ -564,7 +564,7 @@ bolt_store_have_key (BoltStore *store,
keyinfo = g_file_query_info (keypath, "standard::*", 0, NULL, &err);
if (keyinfo != NULL)
key = 1; /* todo: check size */
key = BOLT_KEY_HAVE; /* todo: check size */
else if (!bolt_err_notfound (err))
g_warning ("error querying key info for %s: %s", uid, err->message);
......
......@@ -68,7 +68,7 @@ BoltKey * bolt_store_create_key (BoltStore *store,
const char *uid,
GError **error);
guint bolt_store_have_key (BoltStore *store,
BoltKeyState bolt_store_have_key (BoltStore *store,
const char *uid);
BoltKey * bolt_store_get_key (BoltStore *store,
......
......@@ -133,8 +133,9 @@ test_store_basic (TestStore *tt, gconstpointer user_data)
g_autoptr(BoltKey) key = NULL;
g_autoptr(GError) error = NULL;
char uid[] = "fbc83890-e9bf-45e5-a777-b3728490989c";
BoltKeyState keystate;
gboolean ok;
guint keystate;
dev = g_object_new (BOLT_TYPE_DEVICE,
"uid", uid,
......@@ -165,8 +166,8 @@ test_store_basic (TestStore *tt, gconstpointer user_data)
g_assert_cmpstr (bolt_device_get_vendor (stored), ==, bolt_device_get_vendor (dev));
g_assert_cmpuint (bolt_device_get_policy (stored), ==, BOLT_POLICY_AUTO);
g_assert_cmpuint (bolt_device_get_store (stored), ==, 1);
g_assert_cmpuint (bolt_device_get_key (stored), ==, 0);
g_assert_cmpuint (bolt_device_get_store (stored), ==, BOLT_DB_FSDB);
g_assert_cmpuint (bolt_device_get_key (stored), ==, BOLT_KEY_MISSING);
g_clear_object (&stored);
g_clear_object (&dev);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment