summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorZhang zhengguang <zhengguang.zhang@intel.com>2014-11-19 09:50:45 +0800
committerZhang zhengguang <zhengguang.zhang@intel.com>2014-11-21 14:43:27 +0800
commit9d476728838e2442d349adb679147581a963f8e9 (patch)
treed0160a7a8c5522e5cf884a163fc88676826ac38b /src
parent96469b8ff2cd0e7dc77b7974c431f1dd97981356 (diff)
downloadconnman-9d476728838e2442d349adb679147581a963f8e9.tar.gz
connman-9d476728838e2442d349adb679147581a963f8e9.tar.bz2
connman-9d476728838e2442d349adb679147581a963f8e9.zip
multi-user: Expose function to check service user favorite
Expose the function to check whether the service is favorite to the current user. Change-Id: Ib232f16c652ec94ef2e10b199a638a98554a1066
Diffstat (limited to 'src')
-rw-r--r--src/service.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/service.c b/src/service.c
index 55cf02cc..5eca9706 100644
--- a/src/service.c
+++ b/src/service.c
@@ -4472,6 +4472,30 @@ static DBusMessage *reset_counters(DBusConnection *conn,
return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
}
+static DBusMessage *get_user_favorite(DBusConnection *conn,
+ DBusMessage *msg, void *user_data)
+{
+ DBusMessage *reply;
+ uid_t uid = USER_NONE;
+ dbus_bool_t user_favorite = false;
+ struct connman_service *service = user_data;
+
+ connman_dbus_get_connection_unix_user_sync(conn,
+ dbus_message_get_sender(msg),
+ &uid);
+ if (uid == USER_ROOT)
+ user_favorite = service->favorite;
+ else if (uid != USER_NONE && uid == service->user.favorite_user) {
+ DBG("The service is favorite to this user!");
+ user_favorite = true;
+ }
+
+ reply = g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
+ dbus_message_append_args(reply, DBUS_TYPE_BOOLEAN,
+ &user_favorite, DBUS_TYPE_INVALID);
+ return reply;
+}
+
static struct _services_notify {
int id;
GHashTable *add;
@@ -4613,6 +4637,9 @@ static const GDBusMethodTable service_methods[] = {
GDBUS_ARGS({ "service", "o" }), NULL,
move_after) },
{ GDBUS_METHOD("ResetCounters", NULL, NULL, reset_counters) },
+ { GDBUS_METHOD("GetUserFavorite",
+ NULL, GDBUS_ARGS({ "value", "v" }),
+ get_user_favorite) },
{ },
};