daemon: Change ActiveTransaction value

Change the ActiveTransaction property from the bus address of the active
transaction to a string tuple: (method name, sender name)

The bus address was only a placeholder, and not very useful since each
transaction only accepts one connection (presumably the method caller).
This commit is contained in:
Matthew Barnes 2015-08-24 14:28:09 -04:00
parent 495bf4c3f3
commit 188be0cd58
4 changed files with 34 additions and 20 deletions

View File

@ -7,7 +7,8 @@
<!-- The booted OSName -->
<property name="Booted" type="o" access="read"/>
<property name="ActiveTransaction" type="s" access="read"/>
<!-- The values are (method-name, sender-name) -->
<property name="ActiveTransaction" type="(ss)" access="read"/>
<method name="CreateOSName">
<arg type="s" name="name"/>
@ -100,8 +101,6 @@
</interface>
<interface name="org.projectatomic.rpmostree1.Transaction">
<property name="MethodName" type="s" access="read"/>
<property name="Owner" type="s" access="read"/>
<property name="Active" type="b" access="read"/>
<!-- Yes, we can. -->

View File

@ -443,23 +443,30 @@ out:
}
static gboolean
sysroot_transform_transaction_to_address (GBinding *binding,
const GValue *src_value,
GValue *dst_value,
gpointer user_data)
sysroot_transform_transaction_to_attrs (GBinding *binding,
const GValue *src_value,
GValue *dst_value,
gpointer user_data)
{
Transaction *transaction;
const char *client_address = NULL;
GVariant *variant;
const char *method_name = "";
const char *sender_name = "";
transaction = g_value_get_object (src_value);
if (transaction != NULL)
client_address = transaction_get_client_address (transaction);
{
GDBusMethodInvocation *invocation;
if (client_address == NULL)
client_address = "";
invocation = transaction_get_invocation (transaction);
method_name = g_dbus_method_invocation_get_method_name (invocation);
sender_name = g_dbus_method_invocation_get_sender (invocation);
}
g_value_set_string (dst_value, client_address);
variant = g_variant_new ("(ss)", method_name, sender_name);
g_value_set_variant (dst_value, variant);
return TRUE;
}
@ -571,7 +578,7 @@ sysroot_constructed (GObject *object)
"active-transaction",
G_BINDING_DEFAULT |
G_BINDING_SYNC_CREATE,
sysroot_transform_transaction_to_address,
sysroot_transform_transaction_to_attrs,
NULL,
NULL,
NULL);

View File

@ -400,19 +400,13 @@ transaction_constructed (GObject *object)
if (priv->invocation != NULL)
{
GDBusConnection *connection;
const char *method_name;
const char *sender;
connection = g_dbus_method_invocation_get_connection (priv->invocation);
method_name = g_dbus_method_invocation_get_method_name (priv->invocation);
sender = g_dbus_method_invocation_get_sender (priv->invocation);
/* Initialize D-Bus properties. */
g_object_set (self,
"method-name", method_name,
"owner", sender,
"active", TRUE,
NULL);
rpmostree_transaction_set_active (RPMOSTREE_TRANSACTION (self), TRUE);
priv->watch_id = g_bus_watch_name_on_connection (connection,
sender,
@ -624,6 +618,18 @@ transaction_get_sysroot (Transaction *transaction)
return priv->sysroot;
}
GDBusMethodInvocation *
transaction_get_invocation (Transaction *transaction)
{
TransactionPrivate *priv;
g_return_val_if_fail (IS_TRANSACTION (transaction), NULL);
priv = transaction_get_private (transaction);
return priv->invocation;
}
const char *
transaction_get_client_address (Transaction *transaction)
{

View File

@ -46,6 +46,8 @@ struct _TransactionClass
GType transaction_get_type (void) G_GNUC_CONST;
OstreeSysroot * transaction_get_sysroot (Transaction *transaction);
GDBusMethodInvocation *
transaction_get_invocation (Transaction *transaction);
const char * transaction_get_client_address (Transaction *transaction);
void transaction_emit_message_printf (Transaction *transaction,
const char *format,