Use a macro for method callbacks
This commit is contained in:
parent
4fbb8fa75b
commit
c35801b3ab
52
src/dbus.c
52
src/dbus.c
@ -71,23 +71,19 @@ static const char *stack_tag_hints[] = {
|
||||
"x-canonical-private-synchronous",
|
||||
"x-dunst-stack-tag"
|
||||
};
|
||||
#define DBUS_METHOD(name) static void dbus_cb_##name( \
|
||||
GDBusConnection *connection, \
|
||||
const gchar *sender, \
|
||||
GVariant *parameters, \
|
||||
GDBusMethodInvocation *invocation)
|
||||
|
||||
#define CALL_METHOD(name) dbus_cb_##name(connection, sender, parameters, invocation)
|
||||
|
||||
DBUS_METHOD(Notify);
|
||||
DBUS_METHOD(CloseNotification);
|
||||
DBUS_METHOD(GetCapabilities);
|
||||
DBUS_METHOD(GetServerInformation);
|
||||
|
||||
static void on_get_capabilities(GDBusConnection *connection,
|
||||
const gchar *sender,
|
||||
const GVariant *parameters,
|
||||
GDBusMethodInvocation *invocation);
|
||||
static void on_notify(GDBusConnection *connection,
|
||||
const gchar *sender,
|
||||
GVariant *parameters,
|
||||
GDBusMethodInvocation *invocation);
|
||||
static void on_close_notification(GDBusConnection *connection,
|
||||
const gchar *sender,
|
||||
GVariant *parameters,
|
||||
GDBusMethodInvocation *invocation);
|
||||
static void on_get_server_information(GDBusConnection *connection,
|
||||
const gchar *sender,
|
||||
const GVariant *parameters,
|
||||
GDBusMethodInvocation *invocation);
|
||||
static struct raw_image *get_raw_image_from_data_hint(GVariant *icon_data);
|
||||
|
||||
void handle_method_call(GDBusConnection *connection,
|
||||
@ -100,13 +96,13 @@ void handle_method_call(GDBusConnection *connection,
|
||||
gpointer user_data)
|
||||
{
|
||||
if (STR_EQ(method_name, "GetCapabilities")) {
|
||||
on_get_capabilities(connection, sender, parameters, invocation);
|
||||
CALL_METHOD(GetCapabilities);
|
||||
} else if (STR_EQ(method_name, "Notify")) {
|
||||
on_notify(connection, sender, parameters, invocation);
|
||||
CALL_METHOD(Notify);
|
||||
} else if (STR_EQ(method_name, "CloseNotification")) {
|
||||
on_close_notification(connection, sender, parameters, invocation);
|
||||
CALL_METHOD(CloseNotification);
|
||||
} else if (STR_EQ(method_name, "GetServerInformation")) {
|
||||
on_get_server_information(connection, sender, parameters, invocation);
|
||||
CALL_METHOD(GetServerInformation);
|
||||
} else {
|
||||
LOG_M("Unknown method name: '%s' (sender: '%s').",
|
||||
method_name,
|
||||
@ -114,9 +110,10 @@ void handle_method_call(GDBusConnection *connection,
|
||||
}
|
||||
}
|
||||
|
||||
static void on_get_capabilities(GDBusConnection *connection,
|
||||
static void dbus_cb_GetCapabilities(
|
||||
GDBusConnection *connection,
|
||||
const gchar *sender,
|
||||
const GVariant *parameters,
|
||||
GVariant *parameters,
|
||||
GDBusMethodInvocation *invocation)
|
||||
{
|
||||
GVariantBuilder *builder;
|
||||
@ -273,7 +270,8 @@ static struct notification *dbus_message_to_notification(const gchar *sender, GV
|
||||
return n;
|
||||
}
|
||||
|
||||
static void on_notify(GDBusConnection *connection,
|
||||
static void dbus_cb_Notify(
|
||||
GDBusConnection *connection,
|
||||
const gchar *sender,
|
||||
GVariant *parameters,
|
||||
GDBusMethodInvocation *invocation)
|
||||
@ -301,7 +299,8 @@ static void on_notify(GDBusConnection *connection,
|
||||
wake_up();
|
||||
}
|
||||
|
||||
static void on_close_notification(GDBusConnection *connection,
|
||||
static void dbus_cb_CloseNotification(
|
||||
GDBusConnection *connection,
|
||||
const gchar *sender,
|
||||
GVariant *parameters,
|
||||
GDBusMethodInvocation *invocation)
|
||||
@ -314,9 +313,10 @@ static void on_close_notification(GDBusConnection *connection,
|
||||
g_dbus_connection_flush(connection, NULL, NULL, NULL);
|
||||
}
|
||||
|
||||
static void on_get_server_information(GDBusConnection *connection,
|
||||
static void dbus_cb_GetServerInformation(
|
||||
GDBusConnection *connection,
|
||||
const gchar *sender,
|
||||
const GVariant *parameters,
|
||||
GVariant *parameters,
|
||||
GDBusMethodInvocation *invocation)
|
||||
{
|
||||
GVariant *value;
|
||||
|
Loading…
x
Reference in New Issue
Block a user