commit 6ac20376cadef5aadc4a456efbc58c3feb27544b
parent dcd3a2585e8790af978a7a599959cc8052e53efc
Author: Sweets <Sweets@users.noreply.github.com>
Date: Sat, 25 Apr 2020 20:18:42 -0700
powered by copious amounts of Monster
Diffstat:
M | callbacks.c | | | 42 | ++++++++++++++++++++++++------------------ |
M | tiramisu.c | | | 38 | +++++++++++++++++++++----------------- |
2 files changed, 45 insertions(+), 35 deletions(-)
diff --git a/callbacks.c b/callbacks.c
@@ -1,31 +1,33 @@
#include "tiramisu.h"
#include "callbacks.h"
-void notification_received(GDBusConnection *connection, const gchar *sender,
- GVariant *parameters, GDBusMethodInvocation *invocation) {
- //
-/* GVariantIter iterator;
- GVariant *value;
- gchar *key;
- GVariant *dictionary;
-
- g_variant_iter_init(&iterator, dictionary);
- while (g_variant_iter_loop(&iterator, "s", &key, &value)) {
- g_print("Item '%s' has type '%s'\n", key,
- g_variant_get_type_string(value));
- }*/
-}
-
void method_handler(GDBusConnection *connection, const gchar *sender,
const gchar *object, const gchar *interface, const gchar *method,
GVariant *parameters, GDBusMethodInvocation *invocation,
gpointer user_data) {
+ GVariant *return_value = NULL;
+
if (!strcmp(method, "Notify")) {
// ?
}
- print("%s %s\n", method, sender);
+ if (!strcmp(method, "GetServerInformation")) {
+ // ?
+ return_value = g_variant_new("(ssss)",
+ "tiramisu", "Sweets", "1.0", "1.2");
+ goto flush;
+ }
+
+ goto unhandled;
+
+flush:
+ g_dbus_method_invocation_return_value(invocation, return_value);
+ g_dbus_connection_flush(connection, NULL, NULL, NULL);
+ return;
+
+unhandled:
+ print("Unhandled: %s %s\n", method, sender);
}
@@ -35,8 +37,12 @@ void bus_acquired(GDBusConnection *connection, const gchar *name,
guint registered_object;
registered_object = g_dbus_connection_register_object(connection,
- "/org/freedesktop/Notifications", introspection->interfaces[0],
- &(const GDBusInterfaceVTable){ method_handler }, NULL, NULL, NULL);
+ "/org/freedesktop/Notifications",
+ introspection->interfaces[0],
+ &(const GDBusInterfaceVTable){ method_handler },
+ NULL,
+ NULL,
+ NULL);
if (!registered_object)
print("%s\n", "Unable to register.");
diff --git a/tiramisu.c b/tiramisu.c
@@ -16,25 +16,29 @@ GDBusNodeInfo *introspection = NULL;
const char *xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
"<node name=\"/org/freedesktop/Notifications\">\n"
" <interface name=\"org.freedesktop.Notifications\">\n"
+
" <method name=\"Notify\">\n"
-//#ifdef RECEIVE_ACTIONS
- " <arg direction=\"in\" name=\"actions\" type=\"as\"/>\n"
-/*#endif
-#ifdef RECEIVE_APP_ICON*/
- " <arg direction=\"in\" name=\"app_icon\" type=\"s\"/>\n"
-//#endif
- " <arg direction=\"in\" name=\"app_name\" type=\"s\"/>\n"
- " <arg direction=\"in\" name=\"body\" type=\"s\"/>\n"
-//#ifdef RECEIVE_EXPIRE_TIMEOUT
- " <arg direction=\"in\" name=\"expire_timeout\" type=\"i\"/>\n"
-//#endif
- " <arg direction=\"in\" name=\"hint\" type=\"a{sv}\"/>\n"
- " <arg direction=\"in\" name=\"id\" type=\"u\"/>\n"
-//#ifdef RECEIVE_REPLACES_ID
- " <arg direction=\"in\" name=\"replaces_id\" type=\"u\"/>\n"
-//#endif
- " <arg direction=\"in\" name=\"summary\" type=\"s\"/>\n"
+ " <arg direction=\"in\" type=\"s\" name=\"app_name\"/>\n"
+ " <arg direction=\"in\" type=\"u\" name=\"replaces_id\"/>\n"
+ " <arg direction=\"in\" type=\"s\" name=\"app_icon\"/>\n"
+ " <arg direction=\"in\" type=\"s\" name=\"summary\"/>\n"
+ " <arg direction=\"in\" type=\"s\" name=\"body\"/>\n"
+ " <arg direction=\"in\" type=\"as\" name=\"actions\"/>\n"
+ " <arg direction=\"in\" type=\"a{sv}\" name=\"hints\"/>\n"
+ " <arg direction=\"in\" type=\"i\""
+ " name=\"expire_timeout\"/>\n"
+ " <arg direction=\"out\" type=\"u\""
+ " name=\"id\"/>\n"
" </method>\n"
+
+
+ " <method name=\"GetServerInformation\">\n"
+ " <arg direction=\"out\" type=\"s\" name=\"name\"/>\n"
+ " <arg direction=\"out\" type=\"s\" name=\"vendor\"/>\n"
+ " <arg direction=\"out\" type=\"s\" name=\"version\"/>\n"
+ " <arg direction=\"out\" type=\"s\" name=\"spec_version\"/>\n"
+ " </method>\n"
+
" </interface>\n"
"</node>";