1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212
|
// DBusTestServer.cc
//
// Copyright (C) 2013 Rob Caelers & Raymond Penners
// All rights reserved.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program 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 General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <QtCore>
#include <QtDBus>
#include "debug.hh"
#include "DBusTestServer.hh"
#include "dbus/IDBus.hh"
#if defined(DBUS_BACKEND_QT)
# include "DBusTestQt.hh"
#elif defined(DBUS_BACKEND_GIO)
# undef signals
# include "DBusTestGio.hh"
ddd
#endif
using namespace std;
//! Constructor.
DBusTestServer::DBusTestServer() = default;
//! Destructor.
DBusTestServer::~DBusTestServer() = default;
void
DBusTestServer::test_basic_out_ref(int i_int,
uint8_t i_uint8,
int16_t i_int16,
uint16_t i_uint16,
int32_t i_int32,
uint32_t i_uint32,
int64_t i_int64,
uint64_t i_uint64,
string i_string,
bool i_bool,
double i_double,
DBusTestData::Enum i_enum,
int &o_int,
uint8_t &o_uint8,
int16_t &o_int16,
uint16_t &o_uint16,
int32_t &o_int32,
uint32_t &o_uint32,
int64_t &o_int64,
uint64_t &o_uint64,
string &o_string,
bool &o_bool,
double &o_double,
DBusTestData::Enum &o_enum)
{
o_int = i_int + 1;
o_uint8 = i_uint8 + 2;
o_int16 = i_int16 + 3;
o_uint16 = i_uint16 + 4;
o_int32 = i_int32 + 5;
o_uint32 = i_uint32 + 6;
o_int64 = i_int64 + 7;
o_uint64 = i_uint64 + 8;
o_string = i_string + " World";
o_bool = !i_bool;
o_double = i_double + 1.1;
o_enum = i_enum;
}
void
DBusTestServer::test_basic_out_ptr(int i_int,
uint8_t i_uint8,
int16_t i_int16,
uint16_t i_uint16,
int32_t i_int32,
uint32_t i_uint32,
int64_t i_int64,
uint64_t i_uint64,
const string &i_string,
bool i_bool,
double i_double,
DBusTestData::Enum i_enum,
int *o_int,
uint8_t *o_uint8,
int16_t *o_int16,
uint16_t *o_uint16,
int32_t *o_int32,
uint32_t *o_uint32,
int64_t *o_int64,
uint64_t *o_uint64,
string *o_string,
bool *o_bool,
double *o_double,
DBusTestData::Enum *o_enum)
{
*o_int = i_int + 1;
*o_uint8 = i_uint8 + 2;
*o_int16 = i_int16 + 3;
*o_uint16 = i_uint16 + 4;
*o_int32 = i_int32 + 5;
*o_uint32 = i_uint32 + 6;
*o_int64 = i_int64 + 7;
*o_uint64 = i_uint64 + 8;
*o_string = i_string + " World";
*o_bool = !i_bool;
*o_double = i_double + 1.1;
*o_enum = i_enum;
}
void
DBusTestServer::test_struct_out_ref(const DBusTestData::StructWithAllBasicTypes &i_struct,
DBusTestData::StructWithAllBasicTypes &o_struct)
{
o_struct.m_int = i_struct.m_int + 1;
o_struct.m_uint8 = i_struct.m_uint8 + 2;
o_struct.m_int16 = i_struct.m_int16 + 3;
o_struct.m_uint16 = i_struct.m_uint16 + 4;
o_struct.m_int32 = i_struct.m_int32 + 5;
o_struct.m_uint32 = i_struct.m_uint32 + 6;
o_struct.m_int64 = i_struct.m_int64 + 7;
o_struct.m_uint64 = i_struct.m_uint64 + 8;
o_struct.m_string = i_struct.m_string + " World";
o_struct.m_bool = !i_struct.m_bool;
o_struct.m_double = i_struct.m_double + 1.1;
o_struct.m_enum = i_struct.m_enum;
}
void
DBusTestServer::test_struct_out_ptr(DBusTestData::StructWithAllBasicTypes i_struct, DBusTestData::StructWithAllBasicTypes *o_struct)
{
o_struct->m_int = i_struct.m_int + 1;
o_struct->m_uint8 = i_struct.m_uint8 + 2;
o_struct->m_int16 = i_struct.m_int16 + 3;
o_struct->m_uint16 = i_struct.m_uint16 + 4;
o_struct->m_int32 = i_struct.m_int32 + 5;
o_struct->m_uint32 = i_struct.m_uint32 + 6;
o_struct->m_int64 = i_struct.m_int64 + 7;
o_struct->m_uint64 = i_struct.m_uint64 + 8;
o_struct->m_string = i_struct.m_string + " World";
o_struct->m_bool = !i_struct.m_bool;
o_struct->m_double = i_struct.m_double + 1.1;
o_struct->m_enum = i_struct.m_enum;
}
std::string
DBusTestServer::test_return_string(int i_int)
{
if (i_int == 42)
{
return "Hello World";
}
else
{
return "Error";
}
}
int
DBusTestServer::test_return_int(int i_int)
{
return 2 * i_int;
}
DBusTestData::DataList
DBusTestServer::test_return_list()
{
DBusTestData::DataList ret;
ret.push_back(DBusTestData::Data(0, 1));
ret.push_back(DBusTestData::Data(1, 2));
ret.push_back(DBusTestData::Data(3, 5));
ret.push_back(DBusTestData::Data(8, 13));
return ret;
}
void
DBusTestServer::test_list_of_struct(DBusTestData::DataList i_data, DBusTestData::DataList &o_data)
{
for (auto &d: i_data)
{
d.m_data += 76;
o_data.push_back(d);
}
}
void
DBusTestServer::test_map_of_struct(DBusTestData::DataMap i_data, DBusTestData::DataMap &o_data)
{
for (auto &d: i_data)
{
o_data[d.first] = d.second;
o_data[d.first].m_data += 65;
}
}
|