tizen 2.3 release
[adaptation/xorg/driver/xserver-xorg-module-xdbg.git] / common / xdbg_dbus_server.c
index ab2645f..3b3180c 100644 (file)
@@ -51,6 +51,8 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #define RECONNECT_TIME  1000
 #define DISPATCH_TIME   50
 
+extern _X_EXPORT char *display;
+
 typedef struct _XDbgDBusServerInfo
 {
     OsTimerPtr timer;
@@ -58,6 +60,8 @@ typedef struct _XDbgDBusServerInfo
     XDbgDbusServerMethod *methods;
     char rule[STR_LEN];
     int fd;
+    char xdbg_dbus_server[STR_LEN];
+    char xdbg_dbus_path[STR_LEN];
 } XDbgDBusServerInfo;
 
 static XDbgDBusServerInfo server_info;
@@ -286,6 +290,11 @@ _xDbgDBusServerInit (XDbgDBusServerInfo *info)
 
     XDBG_RETURN_VAL_IF_FAIL (info->conn == NULL, FALSE);
 
+    snprintf(info->xdbg_dbus_server, sizeof(info->xdbg_dbus_server), "org.x.dbg.server%d", atoi(display));
+    snprintf(info->xdbg_dbus_path, sizeof(info->xdbg_dbus_path), "/org/x/dbg/path/%d", atoi(display));
+
+    XDBG_DEBUG (MDBUS, "[SERVER] display number %d\n", atoi(display));
+
     info->conn = dbus_bus_get (DBUS_BUS_SYSTEM, &err);
     if (dbus_error_is_set (&err))
     {
@@ -298,7 +307,7 @@ _xDbgDBusServerInit (XDbgDBusServerInfo *info)
         goto free_err;
     }
 
-    ret = dbus_bus_request_name (info->conn, XDBG_DBUS_SERVER,
+    ret = dbus_bus_request_name (info->conn, info->xdbg_dbus_server,
                                  DBUS_NAME_FLAG_REPLACE_EXISTING , &err);
     if (dbus_error_is_set (&err))
     {
@@ -323,7 +332,7 @@ _xDbgDBusServerInit (XDbgDBusServerInfo *info)
     }
 
     if (!dbus_connection_register_object_path (info->conn,
-                                               XDBG_DBUS_PATH, &vtable,
+                                               info->xdbg_dbus_path, &vtable,
                                                info))
     {
         XDBG_ERROR (MDBUS, "[SERVER] failed: register object path\n");
@@ -357,12 +366,12 @@ _xDbgDBusServerInit (XDbgDBusServerInfo *info)
 free_filter:
     dbus_connection_remove_filter (info->conn, _xDbgDBusServerMsgFilter, info);
 free_register:
-    dbus_connection_unregister_object_path (info->conn, XDBG_DBUS_PATH);
+    dbus_connection_unregister_object_path (info->conn, info->xdbg_dbus_path);
 free_match:
     dbus_bus_remove_match (info->conn, info->rule, &err);
     dbus_error_free (&err);
 free_name:
-    dbus_bus_release_name (info->conn, XDBG_DBUS_SERVER, &err);
+    dbus_bus_release_name (info->conn, info->xdbg_dbus_server, &err);
     dbus_error_free (&err);
 free_conn:
     dbus_connection_close (info->conn);
@@ -388,10 +397,10 @@ _xDbgDBusServerDeinit (XDbgDBusServerInfo *info)
         DBusError err;
         dbus_error_init (&err);
         dbus_connection_remove_filter (info->conn, _xDbgDBusServerMsgFilter, info);
-        dbus_connection_unregister_object_path (info->conn, XDBG_DBUS_PATH);
+        dbus_connection_unregister_object_path (info->conn, info->xdbg_dbus_path);
         dbus_bus_remove_match (info->conn, info->rule, &err);
         dbus_error_free (&err);
-        dbus_bus_release_name (info->conn, XDBG_DBUS_SERVER, &err);
+        dbus_bus_release_name (info->conn, info->xdbg_dbus_server, &err);
         dbus_error_free (&err);
         dbus_connection_unref (info->conn);
         info->conn = NULL;