This draft patch adds a small function called getCoreInfo (maybe
getMetadata would be better?).  It allows external apps to get
information about the _running_ compiz process.

The metadata directory is the most important because it will
be needed to read non-standard metadata directly from the
XML file.  The others are probably useful for image locations
etc.

Any comments, or is there any extra info that could be included?

I will probably change the information to return a dict rather
than a series of values because it marshals better.
>From ee8847e69bcc86a77708a1e529c6fa7f1e26f8ed Mon Sep 17 00:00:00 2001
From: Mike Dransfield <[EMAIL PROTECTED]>
Date: Thu, 17 May 2007 14:37:39 +0100
Subject: [PATCH] Add getCoreInfo function

---
 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

_______________________________________________
compiz mailing list
compiz@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/compiz

Reply via email to