diff --git a/src/dbus/metatypes.h b/src/dbus/metatypes.h index 7b70745c423f2be7ac6a11aa31f2f95056eafc6f..363d451c0cdfb69ca3f2499611759e14a11e0f15 100644 --- a/src/dbus/metatypes.h +++ b/src/dbus/metatypes.h @@ -40,6 +40,7 @@ Q_DECLARE_METATYPE(VectorUInt) Q_DECLARE_METATYPE(VectorString) Q_DECLARE_METATYPE(MapStringVectorString) Q_DECLARE_METATYPE(VectorVectorByte) +Q_DECLARE_METATYPE(DataTransferInfo) #ifndef ENABLE_LIBWRAP static bool dbus_metaTypeInit = false; @@ -55,10 +56,40 @@ inline void registerCommTypes() { qDBusRegisterMetaType<VectorString> (); qDBusRegisterMetaType<MapStringVectorString> (); qDBusRegisterMetaType<VectorVectorByte> (); + qDBusRegisterMetaType<DataTransferInfo> (); dbus_metaTypeInit = true; #endif } +#ifndef ENABLE_LIBWRAP +static inline QDBusArgument &operator<<(QDBusArgument& argument, const DataTransferInfo& info) +{ + argument.beginStructure(); + argument << info.isOutgoing; + argument << info.lastEvent; + argument << info.totalSize; + argument << info.bytesProgress; + argument << info.displayName; + argument << info.path; + argument.endStructure(); + + return argument; +} + +static inline const QDBusArgument &operator>>(const QDBusArgument& argument, DataTransferInfo& info) +{ + argument.beginStructure(); + argument >> info.isOutgoing; + argument >> info.lastEvent; + argument >> info.totalSize; + argument >> info.bytesProgress; + argument >> info.displayName; + argument >> info.path; + argument.endStructure(); + + return argument; +} +#endif #pragma GCC diagnostic pop diff --git a/src/typedefs.h b/src/typedefs.h index 59f73425c3eced8a5a1d50d4cd6be85b633fe718..df1d542da09d1e47872eb150ee0c854cbd6fc676 100644 --- a/src/typedefs.h +++ b/src/typedefs.h @@ -38,6 +38,17 @@ typedef QMap< QString, QMap< QString, QStringList > > MapStringMapStringSt typedef QMap< QString, QStringList > MapStringStringList ; typedef QVector< QByteArray > VectorVectorByte ; +// Adapted from libring DRing::DataTransferInfo +struct DataTransferInfo +{ + bool isOutgoing; + uint lastEvent; + qulonglong totalSize; + qulonglong bytesProgress; + QString displayName; + QString path; +}; + /** * This function add a safe way to get an enum class size * @note it cannot be "const" due to some compiler issues