[PATCH] Add getCoreInfo function

Mike Dransfield mike at blueroot.co.uk
Thu May 17 06:37:39 PDT 2007


---
 plugins/dbus.c |   54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 54 insertions(+), 0 deletions(-)

diff --git a/plugins/dbus.c b/plugins/dbus.c
index 46ded89..664fbf1 100644
--- a/plugins/dbus.c
+++ b/plugins/dbus.c
@@ -47,6 +47,7 @@ static CompMetadata dbusMetadata;
 #define COMPIZ_DBUS_LIST_MEMBER_NAME		    "list"
 #define COMPIZ_DBUS_GET_PLUGINS_MEMBER_NAME	    "getPlugins"
 #define COMPIZ_DBUS_GET_PLUGIN_METADATA_MEMBER_NAME "getPluginMetadata"
+#define COMPIZ_DBUS_GET_CORE_INFO_MEMBER_NAME	    "getCoreInfo"
 
 #define COMPIZ_DBUS_CHANGED_SIGNAL_NAME		    "changed"
 #define COMPIZ_DBUS_PLUGINS_CHANGED_SIGNAL_NAME	    "pluginsChanged"
@@ -307,6 +308,9 @@ dbusHandleRootIntrospectMessage (DBusConnection *connection,
 			     COMPIZ_DBUS_GET_PLUGIN_METADATA_MEMBER_NAME, 7,
 			     "s", "in", "s", "out", "s", "out", "s", "out",
 			     "b", "out", "as", "out", "as", "out");
+    dbusIntrospectAddMethod (writer, COMPIZ_DBUS_GET_CORE_INFO_MEMBER_NAME, 5,
+			     "s", "out", "i", "out", "s", "out", "s", "out",
+			     "s", "out");
     dbusIntrospectAddSignal (writer,
 			     COMPIZ_DBUS_PLUGINS_CHANGED_SIGNAL_NAME, 0);
 
@@ -1693,6 +1697,47 @@ dbusHandleGetPluginsMessage (DBusConnection *connection,
 }
 
 /*
+ * 'GetCoreInfo' can be used to retrieve information about the running
+ * Compiz process.
+ *
+ * Returns (s)programName, (i)ABIVERSION, (s)PLUGINDIR, (s)HOME_PLUGINDIR,
+ *	   (s)METADATADIR
+ *
+ * Example:
+ *
+ * dbus-send --print-reply --type=method_call \
+ * --dest=org.freedesktop.compiz	      \
+ * /org/freedesktop/compiz		      \
+ * org.freedesktop.compiz.getCoreInfo
+ */
+static Bool
+dbusHandleGetCoreInfoMessage (DBusConnection *connection,
+			     DBusMessage    *message,
+			     CompDisplay    *d)
+{
+    DBusMessage *reply;
+    const char *pluginDir = PLUGINDIR;
+    const char *homePluginDir = HOME_PLUGINDIR;
+    const char *metadataDir = METADATADIR;
+    int version = ABIVERSION;
+
+    reply = dbus_message_new_method_return (message);
+
+    dbus_message_append_args (reply, DBUS_TYPE_STRING, &programName, DBUS_TYPE_INVALID);
+    dbus_message_append_args (reply, DBUS_TYPE_INT32, &version, DBUS_TYPE_INVALID);
+    dbus_message_append_args (reply, DBUS_TYPE_STRING, &pluginDir, DBUS_TYPE_INVALID);
+    dbus_message_append_args (reply, DBUS_TYPE_STRING, &homePluginDir, DBUS_TYPE_INVALID);
+    dbus_message_append_args (reply, DBUS_TYPE_STRING, &metadataDir, DBUS_TYPE_INVALID);
+
+    dbus_connection_send (connection, reply, NULL);
+    dbus_connection_flush (connection);
+
+    dbus_message_unref (reply);
+
+    return TRUE;
+}
+
+/*
  * 'GetPluginMetadata' can be used to retrieve metadata for a plugin.
  *
  * Example:
@@ -1943,6 +1988,15 @@ dbusHandleMessage (DBusConnection *connection,
 		return DBUS_HANDLER_RESULT_HANDLED;
 	    }
 	}
+	else if (dbus_message_is_method_call (message, COMPIZ_DBUS_INTERFACE,
+					      COMPIZ_DBUS_GET_CORE_INFO_MEMBER_NAME))
+	{
+	    if (dbusHandleGetCoreInfoMessage (connection, message, d))
+	    {
+		dbus_free_string_array (path);
+		return DBUS_HANDLER_RESULT_HANDLED;
+	    }
+	}
     }
     /* plugin message */
     else if (!path[4])
-- 
1.5.0.7


--------------060602030508070501000901--



More information about the compiz mailing list