Commit a5d23bb8 authored by Christian Kellner's avatar Christian Kellner
Browse files

device: Device::Store -> Device::Stored (boolean)

Change the dbus property "Store" from a enum into a plain boolean.
parent 560c6fc6
......@@ -61,8 +61,8 @@ struct _BoltDevice
BoltSecurity security;
/* when device is stored */
gboolean stored;
BoltPolicy policy;
BoltDatabase store;
BoltKeyState key;
};
......@@ -149,7 +149,7 @@ bolt_device_get_property (GObject *object,
break;
case PROP_STORED:
g_value_set_uint (value, dev->store);
g_value_set_boolean (value, dev->stored);
break;
case PROP_POLICY:
......@@ -204,7 +204,7 @@ bolt_device_set_property (GObject *object,
break;
case PROP_STORED:
dev->store = g_value_get_uint (value);
dev->stored = g_value_get_boolean (value);
break;
case PROP_POLICY:
......@@ -257,7 +257,7 @@ bolt_device_class_init (BoltDeviceClass *klass)
g_object_class_override_property (gobject_class,
PROP_STORED,
"store");
"stored");
g_object_class_override_property (gobject_class,
PROP_POLICY,
......@@ -514,7 +514,7 @@ authorize_thread_done (GObject *object,
else
dev->status = BOLT_STATUS_AUTHORIZED;
if (!dev->store)
if (!dev->stored)
{
ok = bolt_store_put_device (store,
dev,
......@@ -561,7 +561,7 @@ bolt_device_authorize (BoltDevice *dev,
if (level == BOLT_SECURITY_SECURE)
{
if (!dev->store)
if (!dev->stored)
key = bolt_store_create_key (store, dev->uid, error);
else if (dev->key)
key = bolt_store_get_key (store, dev->uid, error);
......@@ -857,10 +857,10 @@ bolt_device_get_status (BoltDevice *dev)
return dev->status;
}
BoltDatabase
bolt_device_get_store (BoltDevice *dev)
gboolean
bolt_device_get_stored (BoltDevice *dev)
{
return dev->store;
return dev->stored;
}
const char *
......
......@@ -77,7 +77,7 @@ const char * bolt_device_get_uid (BoltDevice *dev);
BoltSecurity bolt_device_get_security (BoltDevice *dev);
BoltDatabase bolt_device_get_store (BoltDevice *dev);
gboolean bolt_device_get_stored (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) > BOLT_DB_NONE)
if (bolt_device_get_stored (dev))
handle_udev_device_detached (mgr, dev);
else
hanlde_udev_device_removed (mgr, dev);
......@@ -617,7 +617,7 @@ maybe_authorize_device (BoltManager *mgr,
BoltStatus status = bolt_device_get_status (dev);
BoltPolicy policy = bolt_device_get_policy (dev);
const char *uid = bolt_device_get_uid (dev);
guint store;
gboolean stored;
g_debug ("[%s] checking possible authorization: %s (%x)",
uid, bolt_policy_to_string (policy), status);
......@@ -626,9 +626,9 @@ maybe_authorize_device (BoltManager *mgr,
policy != BOLT_POLICY_AUTO)
return;
store = bolt_device_get_store (dev);
stored = bolt_device_get_stored (dev);
/* sanity check, because we already checked the policy */
g_return_if_fail (store > 0);
g_return_if_fail (stored);
g_idle_add (authorize_device_idle, g_object_ref (dev));
}
......@@ -791,7 +791,7 @@ handle_store_device_removed (BoltStore *store,
/* TODO: maybe move to a new bolt_device_removed (dev) */
g_object_set (dev,
"store", BOLT_DB_NONE,
"stored", TRUE,
"key", BOLT_KEY_MISSING,
"policy", BOLT_POLICY_DEFAULT,
NULL);
......
......@@ -443,7 +443,7 @@ bolt_store_put_device (BoltStore *store,
if (ok)
{
g_object_set (device,
"store", BOLT_DB_FSDB,
"stored", TRUE,
"policy", policy,
"key", keystate,
NULL);
......@@ -501,7 +501,7 @@ bolt_store_get_device (BoltStore *store, const char *uid, GError **error)
"name", name,
"vendor", vendor,
"status", BOLT_STATUS_DISCONNECTED,
"store", BOLT_DB_FSDB,
"stored", TRUE,
"policy", policy,
"key", key,
NULL);
......
......@@ -42,7 +42,7 @@ enum {
PROP_STATUS,
PROP_SYSPATH,
PROP_SECURITY,
PROP_STORE,
PROP_STORED,
PROP_POLICY,
PROP_KEY,
......@@ -75,7 +75,7 @@ bolt_device_get_dbus_props (guint *n)
{"Status", "status", PROP_STATUS, NULL},
{"SysfsPath", "syspath", PROP_SYSPATH, NULL},
{"Security", "security", PROP_SECURITY, NULL},
{"Store", "store", PROP_STORE, NULL},
{"Stored", "stored", PROP_STORED, NULL},
{"Policy", "policy", PROP_POLICY, NULL},
{"Key", "key", PROP_KEY, NULL}
};
......@@ -140,13 +140,12 @@ bolt_device_class_init (BoltDeviceClass *klass)
G_PARAM_READABLE |
G_PARAM_STATIC_NICK);
props[PROP_STORE] =
g_param_spec_enum ("store",
NULL, NULL,
BOLT_TYPE_DATABASE,
BOLT_DB_NONE,
G_PARAM_READABLE |
G_PARAM_STATIC_NICK);
props[PROP_STORED] =
g_param_spec_boolean ("stored",
NULL, NULL,
FALSE,
G_PARAM_READABLE |
G_PARAM_STATIC_NICK);
props[PROP_POLICY] =
g_param_spec_enum ("policy",
......
......@@ -46,7 +46,6 @@ print_device (BoltDevice *dev, gboolean verbose)
g_autofree char *syspath = NULL;
BoltSecurity security = BOLT_SECURITY_NONE;
BoltStatus status;
BoltDatabase store;
BoltKeyState keystate;
BoltPolicy policy;
const char *status_color;
......@@ -65,7 +64,7 @@ print_device (BoltDevice *dev, gboolean verbose)
"uid", &uid,
"security", &security,
"syspath", &syspath,
"store", &store,
"stored", &stored,
"policy", &policy,
"key", &keystate,
NULL);
......@@ -133,8 +132,6 @@ print_device (BoltDevice *dev, gboolean verbose)
bolt_security_to_string (security));
}
stored = store != BOLT_DB_NONE;
g_print (" %s stored: %s\n", tree_right, yes_no (stored));
if (stored)
......
......@@ -53,20 +53,6 @@ typedef enum {
gboolean bolt_status_is_authorized (BoltStatus status);
gboolean bolt_status_is_connected (BoltStatus status);
/**
* BoltDatabase:
* @BOLT_DB_NONE: not stored
* @BOLT_DB_FSDB: file system database
*
* The database used in the store.
*/
typedef enum {
BOLT_DB_NONE,
BOLT_DB_FSDB = 1
} BoltDatabase;
/**
* BoltKeyState:
* @BOLT_KEY_MISSING: no key
......
......@@ -125,7 +125,7 @@
</doc:para></doc:description></doc:doc>
</property>
<property name="Store" type="u" access="read">
<property name="Stored" type="b" access="read">
<doc:doc><doc:description><doc:para>
Indication if the device is stored.
</doc:para></doc:description></doc:doc>
......
......@@ -166,7 +166,7 @@ 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), ==, BOLT_DB_FSDB);
g_assert_cmpuint (bolt_device_get_stored (stored), ==, TRUE);
g_assert_cmpuint (bolt_device_get_key (stored), ==, BOLT_KEY_MISSING);
g_clear_object (&stored);
......@@ -204,7 +204,7 @@ 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_MANUAL);
g_assert_cmpuint (bolt_device_get_store (stored), ==, 1);
g_assert_cmpuint (bolt_device_get_stored (stored), ==, TRUE);
g_assert_cmpuint (bolt_device_get_key (stored), ==, 1);
keystate = bolt_store_have_key (tt->store, uid);
......
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