|
@@ -367,31 +367,41 @@ void SDL_DBus_ScreensaverTickle(void)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static SDL_bool SDL_DBus_AppendDictWithKeyValue(DBusMessageIter *iterInit, const char *key, const char *value)
|
|
|
+static SDL_bool SDL_DBus_AppendDictWithKeysValues(DBusMessageIter *iterInit, const char **keys, const char **values, int count)
|
|
|
{
|
|
|
- DBusMessageIter iterDict, iterEntry, iterValue;
|
|
|
+ DBusMessageIter iterDict;
|
|
|
|
|
|
if (!dbus.message_iter_open_container(iterInit, DBUS_TYPE_ARRAY, "{sv}", &iterDict)) {
|
|
|
goto failed;
|
|
|
}
|
|
|
|
|
|
- if (!dbus.message_iter_open_container(&iterDict, DBUS_TYPE_DICT_ENTRY, NULL, &iterEntry)) {
|
|
|
- goto failed;
|
|
|
- }
|
|
|
+ for (int i = 0; i < count; i++) {
|
|
|
+ DBusMessageIter iterEntry, iterValue;
|
|
|
+ const char *key = keys[i];
|
|
|
+ const char *value = values[i];
|
|
|
|
|
|
- if (!dbus.message_iter_append_basic(&iterEntry, DBUS_TYPE_STRING, &key)) {
|
|
|
- goto failed;
|
|
|
- }
|
|
|
+ if (!dbus.message_iter_open_container(&iterDict, DBUS_TYPE_DICT_ENTRY, NULL, &iterEntry)) {
|
|
|
+ goto failed;
|
|
|
+ }
|
|
|
|
|
|
- if (!dbus.message_iter_open_container(&iterEntry, DBUS_TYPE_VARIANT, DBUS_TYPE_STRING_AS_STRING, &iterValue)) {
|
|
|
- goto failed;
|
|
|
- }
|
|
|
+ if (!dbus.message_iter_append_basic(&iterEntry, DBUS_TYPE_STRING, &key)) {
|
|
|
+ goto failed;
|
|
|
+ }
|
|
|
|
|
|
- if (!dbus.message_iter_append_basic(&iterValue, DBUS_TYPE_STRING, &value)) {
|
|
|
- goto failed;
|
|
|
+ if (!dbus.message_iter_open_container(&iterEntry, DBUS_TYPE_VARIANT, DBUS_TYPE_STRING_AS_STRING, &iterValue)) {
|
|
|
+ goto failed;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!dbus.message_iter_append_basic(&iterValue, DBUS_TYPE_STRING, &value)) {
|
|
|
+ goto failed;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!dbus.message_iter_close_container(&iterEntry, &iterValue) || !dbus.message_iter_close_container(&iterDict, &iterEntry)) {
|
|
|
+ goto failed;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- if (!dbus.message_iter_close_container(&iterEntry, &iterValue) || !dbus.message_iter_close_container(&iterDict, &iterEntry) || !dbus.message_iter_close_container(iterInit, &iterDict)) {
|
|
|
+ if (!dbus.message_iter_close_container(iterInit, &iterDict)) {
|
|
|
goto failed;
|
|
|
}
|
|
|
|
|
@@ -447,9 +457,17 @@ SDL_bool SDL_DBus_ScreensaverInhibit(SDL_bool inhibit)
|
|
|
}
|
|
|
|
|
|
dbus.message_iter_init_append(msg, &iterInit);
|
|
|
- if (!SDL_DBus_AppendDictWithKeyValue(&iterInit, key, reason)) {
|
|
|
- dbus.message_unref(msg);
|
|
|
- return SDL_FALSE;
|
|
|
+
|
|
|
+ /* a{sv} */
|
|
|
+ {
|
|
|
+ const char *keys[1];
|
|
|
+ const char *values[1];
|
|
|
+ keys[0] = key;
|
|
|
+ values[0] = reason;
|
|
|
+ if (!SDL_DBus_AppendDictWithKeysValues(&iterInit, keys, values, 1)) {
|
|
|
+ dbus.message_unref(msg);
|
|
|
+ return SDL_FALSE;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
if (SDL_DBus_CallWithBasicReply(dbus.session_conn, msg, DBUS_TYPE_OBJECT_PATH, &reply)) {
|