diff options
author | Slávek Banko <slavek.banko@axis.cz> | 2013-11-18 21:21:15 +0100 |
---|---|---|
committer | Slávek Banko <slavek.banko@axis.cz> | 2013-11-18 21:21:15 +0100 |
commit | 9a134f5699708c76d4abd12da71c9df03830556a (patch) | |
tree | b44367da3f90252d7d9dffd12c71e1160174bd11 /tqdbusmarshall.cpp | |
parent | 52933e3b969e8b44f6a94db486cb27ddf5c322d7 (diff) | |
download | dbus-1-tqt-9a134f5699708c76d4abd12da71c9df03830556a.tar.gz dbus-1-tqt-9a134f5699708c76d4abd12da71c9df03830556a.zip |
Add support for data type UnixFD
Diffstat (limited to 'tqdbusmarshall.cpp')
-rw-r--r-- | tqdbusmarshall.cpp | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/tqdbusmarshall.cpp b/tqdbusmarshall.cpp index 330e5ac..f4aa5f7 100644 --- a/tqdbusmarshall.cpp +++ b/tqdbusmarshall.cpp @@ -27,6 +27,7 @@ #include "tqdbusdatalist.h" #include "tqdbusdatamap.h" #include "tqdbusobjectpath.h" +#include "tqdbusunixfd.h" #include "tqdbusvariant.h" #include <tqvariant.h> @@ -62,6 +63,7 @@ static TQT_DBusData::Type qSingleTypeForDBusSignature(char signature) case 'o': return TQT_DBusData::ObjectPath; case 'g': return TQT_DBusData::String; case 'v': return TQT_DBusData::Variant; + case 'h': return TQT_DBusData::UnixFd; default: break; @@ -133,6 +135,10 @@ static TQValueList<TQT_DBusData> parseSignature(TQCString& signature) result << TQT_DBusData::fromObjectPathKeyMap( TQT_DBusDataMap<TQT_DBusObjectPath>(valueType)); break; + case TQT_DBusData::UnixFd: + result << TQT_DBusData::fromUnixFdKeyMap( + TQT_DBusDataMap<TQT_DBusUnixFd>(valueType)); + break; default: tqWarning("TQT_DBusMarshall: unsupported map key type %s " "at de-marshalling", @@ -186,6 +192,10 @@ static TQValueList<TQT_DBusData> parseSignature(TQCString& signature) result << TQT_DBusData::fromObjectPathKeyMap( TQT_DBusDataMap<TQT_DBusObjectPath>(valueContainer[0])); break; + case TQT_DBusData::UnixFd: + result << TQT_DBusData::fromUnixFdKeyMap( + TQT_DBusDataMap<TQT_DBusUnixFd>(valueContainer[0])); + break; default: tqWarning("TQT_DBusMarshall: unsupported map key type %s " "at de-marshalling", @@ -273,6 +283,10 @@ static TQValueList<TQT_DBusData> parseSignature(TQCString& signature) result << TQT_DBusData::fromObjectPath( (TQT_DBusObjectPath())); break; + case TQT_DBusData::UnixFd: + result << TQT_DBusData::fromUnixFd( + (TQT_DBusUnixFd())); + break; default: result << TQT_DBusData(); tqWarning("TQT_DBusMarshall: unsupported element type %s " @@ -585,6 +599,8 @@ static TQT_DBusData qFetchParameter(DBusMessageIter *it) return TQT_DBusData::fromStruct(memberList); } + case DBUS_TYPE_UNIX_FD: + return TQT_DBusData::fromUnixFd(TQT_DBusUnixFd(qIterGet<dbus_uint32_t>(it))); #if 0 case DBUS_TYPE_INVALID: // TODO: check if there is better way to detect empty arrays @@ -627,6 +643,12 @@ static void tqAppendToMessage(DBusMessageIter *it, const TQT_DBusObjectPath &pat dbus_message_iter_append_basic(it, DBUS_TYPE_OBJECT_PATH, &cdata); } +static void tqAppendToMessage(DBusMessageIter *it, const TQT_DBusUnixFd &unixFd) +{ + const dbus_int32_t cdata = unixFd.fileDescriptor(); + dbus_message_iter_append_basic(it, DBUS_TYPE_UNIX_FD, &cdata); +} + static const char* qDBusTypeForTQT_DBusType(TQT_DBusData::Type type) { switch (type) @@ -678,6 +700,9 @@ static const char* qDBusTypeForTQT_DBusType(TQT_DBusData::Type type) case TQT_DBusData::Map: return DBUS_TYPE_DICT_ENTRY_AS_STRING; + + case TQT_DBusData::UnixFd: + return DBUS_TYPE_UNIX_FD_AS_STRING; } return 0; } @@ -991,6 +1016,40 @@ static void qDBusObjectPathKeyMapToIterator(DBusMessageIter* it, dbus_message_iter_close_container(it, &sub); } +static void qDBusUnixFdKeyMapToIterator(DBusMessageIter* it, const TQT_DBusData& var) +{ + DBusMessageIter sub; + TQCString sig; + + TQT_DBusDataMap<TQT_DBusUnixFd> map = var.toUnixFdKeyMap(); + + sig += DBUS_DICT_ENTRY_BEGIN_CHAR; + sig += qDBusTypeForTQT_DBusType(map.keyType()); + + if (map.hasContainerValueType()) + sig += map.containerValueType().buildDBusSignature(); + else + sig += qDBusTypeForTQT_DBusType(map.valueType()); + sig += DBUS_DICT_ENTRY_END_CHAR; + + dbus_message_iter_open_container(it, DBUS_TYPE_ARRAY, sig.data(), &sub); + + TQT_DBusDataMap<TQT_DBusUnixFd>::const_iterator mit = map.begin(); + for (; mit != map.end(); ++mit) + { + DBusMessageIter itemIterator; + dbus_message_iter_open_container(&sub, DBUS_TYPE_DICT_ENTRY, + 0, &itemIterator); + + dbus_message_iter_append_basic(it, DBUS_TYPE_UNIX_FD, &(mit.key())); + qDBusDataToIterator(&itemIterator, mit.data()); + + dbus_message_iter_close_container(&sub, &itemIterator); + } + + dbus_message_iter_close_container(it, &sub); +} + static void qDBusDataToIterator(DBusMessageIter* it, const TQT_DBusData& var) { switch (var.type()) @@ -1048,6 +1107,10 @@ static void qDBusDataToIterator(DBusMessageIter* it, const TQT_DBusData& var) case TQT_DBusData::ObjectPath: tqAppendToMessage(it, var.toObjectPath()); break; + case TQT_DBusData::UnixFd: { + tqAppendToMessage(it, var.toUnixFd()); + break; + } case TQT_DBusData::List: { TQT_DBusDataList list = var.toList(); @@ -1100,6 +1163,9 @@ static void qDBusDataToIterator(DBusMessageIter* it, const TQT_DBusData& var) case TQT_DBusData::ObjectPath: qDBusObjectPathKeyMapToIterator(it, var); break; + case TQT_DBusData::UnixFd: + qDBusUnixFdKeyMapToIterator(it, var); + break; default: tqWarning("TQT_DBusMarshall: unhandled map key type %s " "at marshalling", |