Skip to content
Snippets Groups Projects

Draft: Re-implement missing functionality-peermanager

Files
7
+ 22
74
@@ -19,6 +19,10 @@
#include "peer-manager.h"
typedef struct _PolkitSubject PolkitSubject; /* Dummy typedef */
struct _PolkitAuthorizationResult;
typedef struct _PolkitAuthorizationResult PolkitAuthorizationResult;
static void vdd_peer_manager_async_initable_init (GAsyncInitableIface *iface);
static void vdd_peer_manager_peer_manager_init (CsrPeerManagerInterface *iface);
@@ -39,10 +43,6 @@ static void vdd_peer_manager_ensure_peer_info_async (CsrPeerManag
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
/* TODO function returning CbyProcessInfo for
* vdd_peer_manager_ensure_peer_info_finish need to
* update with latest implementation
*/
static void * vdd_peer_manager_ensure_peer_info_finish (CsrPeerManager *peer_manager,
GAsyncResult *result,
@@ -75,18 +75,12 @@ static void authority_changed_cb (PolkitAuthor
/* Structure for values in the peers table. */
typedef struct
{
/* TODO
* CbyProcessInfo *process_info;
**/
guint watch_id;
} PeerInfo;
static void
peer_info_free (PeerInfo *info)
{
/*TODO
* g_object_unref (info->process_info);
**/
if (info->watch_id != 0)
g_bus_unwatch_name (info->watch_id);
@@ -95,6 +89,22 @@ peer_info_free (PeerInfo *info)
G_DEFINE_AUTOPTR_CLEANUP_FUNC (PeerInfo, peer_info_free)
static void
polkitsubject_call_data_free (PolkitSubject *data)
{
g_free (data);
}
G_DEFINE_AUTOPTR_CLEANUP_FUNC (PolkitSubject, polkitsubject_call_data_free)
static void
polkit_call_data_free (PolkitAuthorizationResult *data)
{
g_free (data);
}
G_DEFINE_AUTOPTR_CLEANUP_FUNC (PolkitAuthorizationResult, polkit_call_data_free)
/**
* VddPeerManager:
*
@@ -398,9 +408,6 @@ vdd_peer_manager_ensure_peer_info_async (CsrPeerManager *peer_manager,
if (peer_info != NULL)
{
/*TODO
* g_task_return_pointer (task, g_object_ref (peer_info->process_info),g_object_unref);
**/
return;
}
else
@@ -413,13 +420,6 @@ vdd_peer_manager_ensure_peer_info_async (CsrPeerManager *peer_manager,
g_task_set_task_data (task, g_steal_pointer (&data),
(GDestroyNotify) ensure_peer_info_data_free);
/* TODO
cby_process_info_new_for_dbus_sender_async (sender, connection,
cancellable,
ensure_peer_info_cb,
g_steal_pointer (&task));
*/
}
}
@@ -431,16 +431,10 @@ ensure_peer_info_cb (GObject *object,
VddPeerManager *self;
g_autoptr (GTask) task = G_TASK (user_data);
EnsurePeerInfoData *data;
/* TODO
* g_autoptr (CbyProcessInfo) process_info = NULL;
*/
g_autoptr (PeerInfo) peer_info = NULL;
GError *error = NULL;
self = VDD_PEER_MANAGER (g_task_get_source_object (task));
/* TODO
* process_info = cby_process_info_new_for_dbus_sender_finish (result, &error);
*/
data = g_task_get_task_data (task);
if (error != NULL)
@@ -460,23 +454,12 @@ ensure_peer_info_cb (GObject *object,
*
* FIXME: Add a unit test for this. */
peer_info = g_new0 (PeerInfo, 1);
/*TODO
* peer_info->process_info = g_object_ref (process_info);
**/
peer_info->watch_id = g_bus_watch_name_on_connection (data->connection,
data->sender,
G_BUS_NAME_WATCHER_FLAGS_NONE,
NULL,
peer_vanished_cb, self,
NULL);
//TODO
#if 0
g_hash_table_insert (self->peers, g_strdup (data->sender),
g_steal_pointer (&peer_info));
g_object_notify (G_OBJECT (self), "peers");
g_task_return_pointer (task, g_object_ref (process_info), g_object_unref);
#endif
}
static void
@@ -499,10 +482,6 @@ peer_vanished_cb (GDBusConnection *connection,
}
}
/* TODO function returning CbyProcessInfo for
* vdd_peer_manager_ensure_peer_info_finish need to
* update with latest implementation
*/
static void *
vdd_peer_manager_ensure_peer_info_finish (CsrPeerManager *peer_manager,
GAsyncResult *result,
@@ -511,10 +490,6 @@ vdd_peer_manager_ensure_peer_info_finish (CsrPeerManager *peer_manager,
GTask *task = G_TASK (result);
g_return_val_if_fail (g_task_is_valid (result, peer_manager), NULL);
/* TODO
return g_task_propagate_pointer (task, error);
*/
}
typedef struct
@@ -587,10 +562,7 @@ check_authorization_cb1 (GObject *obj,
g_autoptr (GTask) task = G_TASK (user_data);
AuthorizationCheckData *data;
g_autoptr (GError) error = NULL;
/*TODO
* g_autoptr (PolkitSubject) subject = NULL;
* g_autoptr (CbyProcessInfo) process_info = NULL;
* */
g_autoptr (PolkitSubject) subject = NULL;
data = g_task_get_task_data (task);
/* Get the peer’s info. */
@@ -603,22 +575,6 @@ check_authorization_cb1 (GObject *obj,
return;
}
//TODO
#if 0
/* FIXME: Do we want to do other authorisation checks against
* @process_info? */
if (cby_process_info_get_process_type (process_info) ==
CBY_PROCESS_TYPE_UNKNOWN)
{
g_task_return_new_error (task, G_DBUS_ERROR,
G_DBUS_ERROR_ACCESS_DENIED,
_("Unknown-type processes cannot access vehicle "
"data."));
return;
}
#endif
/* Check the peer’s authorisation. */
{
g_auto (GStrv) keys = NULL;
@@ -639,9 +595,7 @@ check_authorization_cb1 (GObject *obj,
* #CbyProcessInfo. This won’t work if we’re running on the session bus.
* */
/*TODO
subject = polkit_system_bus_name_new (data->sender);
*/
polkit_authority_check_authorization (self->authority, NULL,
data->action_id, data->details,
@@ -657,14 +611,9 @@ check_authorization_cb2 (GObject *obj,
gpointer user_data)
{
g_autoptr (GTask) task = G_TASK (user_data);
/* TODO
g_autoptr (PolkitAuthorizationResult) auth_result = NULL;
* */
g_autoptr (PolkitAuthorizationResult) auth_result = NULL;
g_autoptr (GError) error = NULL;
//TODO
#if 0
auth_result = polkit_authority_check_authorization_finish (POLKIT_AUTHORITY (obj),
result, &error);
@@ -700,7 +649,6 @@ check_authorization_cb2 (GObject *obj,
return;
}
#endif
g_task_return_boolean (task, TRUE);
}
Loading