/* * Copyright (C) 2011-12 Intel Corporation * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) version 3. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * 02110-1301 USA */ /** * GDBus traits for sending some common structs over D-Bus. * Needed by by syncevo-local-sync and syncevo-dbus-helper. */ #ifndef INCL_SYNCEVO_DBUS_TRAITS # define INCL_SYNCEVO_DBUS_TRAITS #include #include #include #include #include namespace GDBusCXX { template <> struct dbus_traits : dbus_enum_traits {}; template <> struct dbus_traits : dbus_enum_traits {}; /** like a pair of two values, but with different storage class on the host */ template struct dbus_traits< SyncEvo::InitState > : public dbus_traits< std::pair > { typedef dbus_traits< std::pair > base_traits; typedef SyncEvo::InitState host_type; typedef const host_type &arg_type; #ifdef GDBUS_CXX_GIO static void get(ExtractArgs &context, reader_type &reader, host_type &value) { typename base_traits::host_type tmp; base_traits::get(context, reader, tmp); value = host_type(tmp.first, tmp.second); } #else static void get(connection_type *conn, message_type *msg, reader_type &reader, host_type &value) { typename base_traits::host_type tmp; base_traits::get(conn, msg, reader, tmp); value = host_type(tmp.first, tmp.second); } #endif static void append(builder_type &builder, arg_type value) { base_traits::append(builder, typename base_traits::host_type(value.get(), value.wasSet())); } }; /** * Actual content is a std::map, so serialization can be done using that. * We only have to ensure that instances and parameters use FullProps. */ template <> struct dbus_traits : public dbus_traits < std::map > > { typedef SyncEvo::FullProps host_type; typedef const SyncEvo::FullProps &arg_type; }; /** * Similar to SyncEvo::FullProps. */ template <> struct dbus_traits : public dbus_traits < std::map > > { typedef SyncEvo::SourceProps host_type; typedef const SyncEvo::SourceProps &arg_type; }; template <> struct dbus_traits : public dbus_traits < std::map > > { typedef SyncEvo::ConfigProps host_type; typedef const SyncEvo::ConfigProps &arg_type; }; /** * a struct containing ConfigProps + SourceProps */ template <> struct dbus_traits : public dbus_struct_traits > > {}; /** * a struct containing various strings and an integer */ template <> struct dbus_traits : public dbus_struct_traits > > > > > > > {}; } #endif // INCL_SYNCEVO_DBUS_TRAITS