Changes update_proplist to set_allow_remote_access 34/241034/2 tizen_dev
authorJaechul Lee <jcsing.lee@samsung.com>
Fri, 14 Aug 2020 02:26:29 +0000 (11:26 +0900)
committerJaechul Lee <jcsing.lee@samsung.com>
Fri, 14 Aug 2020 03:37:44 +0000 (12:37 +0900)
Change-Id: Ice5caccf25f7d0eb1f2f500642f092a55e005f9b
Signed-off-by: Jaechul Lee <jcsing.lee@samsung.com>
src/stream-manager-dbus-priv.h
src/stream-manager-dbus.c

index 32052e193899a3ac772fbbb7e4f69649ea11a6bd..ae6e9acb8f2c98f368703a468d8e27897b32534e 100644 (file)
@@ -54,7 +54,7 @@
 #define STREAM_MANAGER_METHOD_NAME_GET_PID_OF_LATEST_STREAM          "GetPidOfLatestStream"
 #define STREAM_MANAGER_METHOD_NAME_ACTIVATE_DUCKING                  "ActivateDucking"
 #define STREAM_MANAGER_METHOD_NAME_GET_DUCKING_STATE                 "GetDuckingState"
-#define STREAM_MANAGER_METHOD_NAME_UPDATE_PROPLIST                   "UpdateProplist"
+#define STREAM_MANAGER_METHOD_NAME_SET_REMOTE_PERMISSION             "SetRemotePermission"
 #define STREAM_MANAGER_METHOD_NAME_DISCOVER_REMOTE_DEVICE            "DiscoverRemoteDevice"
 #define STREAM_MANAGER_METHOD_NAME_PUBLISH_LOCAL_DEVICE              "PublishLocalDevice"
 /* signal */
@@ -62,7 +62,6 @@
 #define STREAM_MANAGER_SIGNAL_NAME_DUCKING_STATE_CHANGED             "DuckingStateChanged"
 #define STREAM_MANAGER_SIGNAL_NAME_COMMAND                           "Command"
 #define STREAM_MANAGER_SIGNAL_NAME_REMOTE_FOUND                      "RemoteFound"
-#define STREAM_MANAGER_SIGNAL_NAME_REMOTE_ACCESS                     "RemoteAccess"//TODO:?
 
 enum method_handler_index {
     METHOD_HANDLER_GET_STREAM_INFO,
@@ -93,7 +92,7 @@ enum method_handler_index {
     METHOD_HANDLER_GET_PID_OF_LATEST_STREAM,
     METHOD_HANDLER_ACTIVATE_DUCKING,
     METHOD_HANDLER_GET_DUCKING_STATE,
-    METHOD_HANDLER_UPDATE_PROPLIST,
+    METHOD_HANDLER_NAME_SET_REMOTE_PERMISSION,
     METHOD_HANDLER_DISCOVER_REMOTE_DEVICE,
     METHOD_HANDLER_PUBLISH_LOCAL_DEVICE,
     METHOD_HANDLER_MAX
@@ -274,10 +273,10 @@ pa_dbus_interface_info stream_manager_interface_info = {
     "   <arg name=\"is_ducked\" direction=\"out\" type=\"b\"/>"              \
     "   <arg name=\"ret_msg\" direction=\"out\" type=\"s\"/>"                \
     "  </method>"                                                            \
-    "  <method name=\"STREAM_MANAGER_METHOD_NAME_UPDATE_PROPLIST\">"         \
+    "  <method name=\"STREAM_MANAGER_METHOD_NAME_SET_REMOTE_PERMISSION\">"   \
     "   <arg name=\"type\" direction=\"in\" type=\"s\"/>"                    \
     "   <arg name=\"index\" direction=\"in\" type=\"u\"/>"                   \
-    "   <arg name=\"proplist\" direction=\"in\" type=\"s\"/>"                \
+    "   <arg name=\"allowed\" direction=\"in\" type=\"b\"/>"                 \
     "  </method>"                                                            \
     "  <method name=\"STREAM_MANAGER_METHOD_NAME_DISCOVER_REMOTE_DEVICEE\">" \
     "   <arg name=\"enable\" direction=\"in\" type=\"b\"/>"                  \
index 03cfe767eac1f8c44d3f1c58a28862502c7c5949..fb591d9cdeb191b07a24008cc32310d1416707b7 100644 (file)
@@ -70,7 +70,7 @@ static void handle_check_stream_exist_by_pid(DBusConnection *conn, DBusMessage *
 static void handle_get_pid_of_latest_stream(DBusConnection *conn, DBusMessage *msg, void *userdata);
 static void handle_activate_ducking(DBusConnection *conn, DBusMessage *msg, void *userdata);
 static void handle_get_ducking_state(DBusConnection *conn, DBusMessage *msg, void *userdata);
-static void handle_update_proplist(DBusConnection *conn, DBusMessage *msg, void *userdata);
+static void handle_set_remote_permission(DBusConnection *conn, DBusMessage *msg, void *userdata);
 static void handle_discover_remote_device(DBusConnection *conn, DBusMessage *msg, void *userdata);
 static void handle_publish_local_device(DBusConnection *conn, DBusMessage *msg, void *userdata);
 static void send_volume_changed_signal(DBusConnection *conn, const char *direction, const char *volume_type, const uint32_t volume_level);
@@ -182,9 +182,9 @@ static pa_dbus_arg_info activate_ducking_args[] = { { "index", "u", "in" },
 static pa_dbus_arg_info get_ducking_state_args[] = { { "index", "u", "in" },
                                                { "is_ducked", "b",  "out" },
                                                 { "ret_msg", "s", "out" } };
-static pa_dbus_arg_info update_proplist_args[] = { { "type", "s", "in" },
+static pa_dbus_arg_info set_remote_permission_args[] = { { "type", "s", "in" },
                                                    { "index", "u",  "in" },
-                                                   { "property", "s", "in" } };
+                                                   { "allowed", "b", "in" } };
 static pa_dbus_arg_info discover_remote_device_args[] = { { "enable", "b", "in" } };
 static pa_dbus_arg_info publish_local_device_args[] = { { "enable", "b", "in" } };
 
@@ -218,7 +218,7 @@ static const char* signature_args_for_in[] = {
     "sas",      /* METHOD_HANDLER_GET_PID_OF_LATEST_STREAM */
     "ubsud",    /* METHOD_HANDLER_ACTIVATE_DUCKING */
     "u",        /* METHOD_HANDLER_GET_DUCKING_STATE */
-    "sus",      /* METHOD_HANDLER_UPDATE_PROPLIST */
+    "sub",      /* METHOD_HANDLER_SET_REMOTE_PERMISSION */
     "b",        /* METHOD_HANDLER_DISCOVER_REMOTE_DEVICE */
     "b"         /* METHOD_HANDLER_PUBLISH_LOCAL_DEVICE */
     };
@@ -364,11 +364,11 @@ static pa_dbus_method_handler method_handlers[METHOD_HANDLER_MAX] = {
         .arguments = get_ducking_state_args,
         .n_arguments = sizeof(get_ducking_state_args) / sizeof(pa_dbus_arg_info),
         .receive_cb = handle_get_ducking_state },
-    [METHOD_HANDLER_UPDATE_PROPLIST] = {
-        .method_name = STREAM_MANAGER_METHOD_NAME_UPDATE_PROPLIST,
-        .arguments = update_proplist_args,
-        .n_arguments = sizeof(update_proplist_args) / sizeof(pa_dbus_arg_info),
-        .receive_cb = handle_update_proplist },
+    [METHOD_HANDLER_NAME_SET_REMOTE_PERMISSION] = {
+        .method_name = STREAM_MANAGER_METHOD_NAME_SET_REMOTE_PERMISSION,
+        .arguments = set_remote_permission_args,
+        .n_arguments = sizeof(set_remote_permission_args) / sizeof(pa_dbus_arg_info),
+        .receive_cb = handle_set_remote_permission },
     [METHOD_HANDLER_DISCOVER_REMOTE_DEVICE] = {
         .method_name = STREAM_MANAGER_METHOD_NAME_DISCOVER_REMOTE_DEVICE,
         .arguments = discover_remote_device_args,
@@ -2349,11 +2349,41 @@ static void handle_get_ducking_state(DBusConnection *conn, DBusMessage *msg, voi
     dbus_message_unref(reply);
 }
 
-static void handle_update_proplist(DBusConnection *conn, DBusMessage *msg, void *userdata) {
+static int dbus_launch_mdnsd(pa_stream_manager *m, DBusConnection *conn) {
+    const char *name = "NONAME";
+    DBusMessage *msg, *reply;
+    DBusError err;
+
+    pa_log_info("launching mdnsd");
+
+    if (!(msg = dbus_message_new_method_call("net.netconfig", "/net/netconfig/network", "net.netconfig.network", "LaunchMdns"))) {
+        pa_log_error("dbus method call failed");
+        return -1;
+    }
+
+    pa_assert_se(dbus_message_append_args(msg, DBUS_TYPE_STRING, &name, DBUS_TYPE_INVALID));
+
+    dbus_error_init(&err);
+    if (!(reply = dbus_connection_send_with_reply_and_block(conn, msg, -1, &err))) {
+        pa_log_error("Failed to method call :  %s", err.message);
+        dbus_error_free(&err);
+        return -1;
+    }
+
+    dbus_message_unref(reply);
+
+    pa_log_info("success");
+
+    return 0;
+}
+
+static void handle_set_remote_permission(DBusConnection *conn, DBusMessage *msg, void *userdata) {
     pa_stream_manager *m = (pa_stream_manager*)userdata;
     dbus_uint32_t index;
-    char *type = NULL, *proplist = NULL;
+    dbus_bool_t allowed;
     pa_proplist *p = NULL;
+    char *type = NULL;
+    static const char *remote_access[] = { "media.remote.access=denied", "media.remote.access=allowed" };
 
     pa_assert(conn);
     pa_assert(msg);
@@ -2362,17 +2392,17 @@ static void handle_update_proplist(DBusConnection *conn, DBusMessage *msg, void
     pa_assert_se(dbus_message_get_args(msg, NULL,
                                        DBUS_TYPE_STRING, &type,
                                        DBUS_TYPE_UINT32, &index,
-                                       DBUS_TYPE_STRING, &proplist,
+                                       DBUS_TYPE_BOOLEAN, &allowed,
                                        DBUS_TYPE_INVALID));
 
-    if (!type || !proplist) {
+    if (!type) {
         pa_log_error("invalid arguments");
         goto out;
     }
 
-    pa_log_info("type(%s), index(%d), proplist(%s)", type, index, proplist);
+    pa_log_info("type(%s), index(%d), allowed(%d)", type, index, allowed);
 
-    p = pa_proplist_from_string(proplist);
+    p = pa_proplist_from_string(remote_access[allowed]);
     if (!p) {
         pa_log_error("failed to create proplist");
         goto out;
@@ -2409,34 +2439,6 @@ out:
     pa_dbus_send_empty_reply(conn, msg);
 }
 
-static int dbus_launch_mdnsd(pa_stream_manager *m, DBusConnection *conn) {
-    const char *name = "NONAME";
-    DBusMessage *msg, *reply;
-    DBusError err;
-
-    pa_log_info("launching mdnsd");
-
-    if (!(msg = dbus_message_new_method_call("net.netconfig", "/net/netconfig/network", "net.netconfig.network", "LaunchMdns"))) {
-        pa_log_error("dbus method call failed");
-        return -1;
-    }
-
-    pa_assert_se(dbus_message_append_args(msg, DBUS_TYPE_STRING, &name, DBUS_TYPE_INVALID));
-
-    dbus_error_init(&err);
-    if (!(reply = dbus_connection_send_with_reply_and_block(conn, msg, -1, &err))) {
-        pa_log_error("Failed to method call :  %s", err.message);
-        dbus_error_free(&err);
-        return -1;
-    }
-
-    dbus_message_unref(reply);
-
-    pa_log_info("success");
-
-    return 0;
-}
-
 static uint32_t discover;
 static uint32_t protocol_tcp;
 static uint32_t publish;
@@ -2687,26 +2689,6 @@ void broadcast_connected_remote_device(DBusConnection *conn, int type, bool conn
     dbus_message_unref(signal_msg);
 }
 
-/* TODO: */
-void broadcast_changed_remote_access(DBusConnection *conn, unsigned int index, const char *perm) {
-    DBusMessage *signal_msg;
-    DBusMessageIter msg_iter;
-
-    if (!perm) {
-        pa_log_error("unknown permision");
-        return;
-    }
-
-    pa_assert_se((signal_msg = dbus_message_new_signal(STREAM_MANAGER_OBJECT_PATH, STREAM_MANAGER_INTERFACE, STREAM_MANAGER_SIGNAL_NAME_REMOTE_ACCESS)));
-    dbus_message_iter_init_append(signal_msg, &msg_iter);
-
-    dbus_message_iter_append_basic(&msg_iter, DBUS_TYPE_UINT32, &index);
-    dbus_message_iter_append_basic(&msg_iter, DBUS_TYPE_STRING, &perm);
-
-    pa_assert_se(dbus_connection_send(conn, signal_msg, NULL));
-    dbus_message_unref(signal_msg);
-}
-
 int32_t init_sm_dbus(pa_stream_manager *m) {
     pa_assert(m);