2 * Copyright (c) copyright 2011-2012 Aricent® Group and its licensors
4 * \author: Sampreeth Ramavana
7 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction,
8 * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
9 * subject to the following conditions:
10 * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
11 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
12 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
13 * THE USE OR OTHER DEALINGS IN THE SOFTWARE.
15 * For further information see http://www.genivi.org/.
18 #include "CAmDbusMessageHandler.h"
19 #include "CAmRoutingSenderDbus.h"
28 DLT_IMPORT_CONTEXT(DLT_CONTEXT)
30 CAmDbusMessageHandler::CAmDbusMessageHandler()
37 mReveiveMessage(NULL),
42 CAmDbusMessageHandler::~CAmDbusMessageHandler()
46 void CAmDbusMessageHandler::initReceive(DBusMessage* msg)
50 if (!dbus_message_iter_init(msg, &mDBusMessageIter))
52 mErrorName=std::string(DBUS_ERROR_INVALID_ARGS);
53 mErrorMsg="DBUS Message has no arguments!";
57 void CAmDbusMessageHandler::initReply(DBusMessage* msg)
60 mDbusMessage = dbus_message_new_method_return(msg);
61 if (mDbusMessage==NULL) {
62 mErrorName=std::string(DBUS_ERROR_NO_MEMORY);
63 mErrorMsg="Cannot create reply!";
65 dbus_message_iter_init_append(mDbusMessage, &mDBusMessageIter);
68 void CAmDbusMessageHandler::initSignal(std::string path, std::string signalName)
70 assert(!path.empty());
71 assert(!signalName.empty());
72 std::string completePath=std::string(DBUS_SERVICE_OBJECT_PATH)+"/"+path;
73 std::string objectpath=std::string(DBUS_SERVICE_PREFIX)+"."+path;
74 mDbusMessage=dbus_message_new_signal(completePath.c_str(),objectpath.c_str(),signalName.c_str());
77 dbus_message_iter_init_append(mDbusMessage, &mDBusMessageIter);
80 void CAmDbusMessageHandler::sendMessage()
82 assert(mDBusConnection!=NULL);
83 if(mReveiveMessage!=0)
85 mSerial=dbus_message_get_serial(mReveiveMessage);
91 if (!mErrorName.empty()) {
92 mDbusMessage = dbus_message_new_error(mReveiveMessage, mErrorName.c_str(), mErrorMsg.c_str());
94 if (!dbus_connection_send(mDBusConnection, mDbusMessage, &mSerial))
98 dbus_connection_flush(mDBusConnection);
99 dbus_message_unref(mDbusMessage);
103 char* CAmDbusMessageHandler::getString()
107 if (DBUS_TYPE_STRING != dbus_message_iter_get_arg_type(&mDBusMessageIter))
109 mErrorName=std::string(DBUS_ERROR_INVALID_ARGS);
110 mErrorMsg="DBus argument is no string";
114 dbus_message_iter_get_basic(&mDBusMessageIter, ¶m);
115 dbus_message_iter_next(&mDBusMessageIter);
120 dbus_bool_t CAmDbusMessageHandler::getBool()
122 dbus_bool_t boolparam=false;
124 if (DBUS_TYPE_BOOLEAN != dbus_message_iter_get_arg_type(&mDBusMessageIter))
126 mErrorName=std::string(DBUS_ERROR_INVALID_ARGS);
127 mErrorMsg="DBus argument is no bool";
131 dbus_message_iter_get_basic(&mDBusMessageIter, &boolparam);
132 dbus_message_iter_next(&mDBusMessageIter);
137 char CAmDbusMessageHandler::getByte()
141 if (DBUS_TYPE_BYTE != dbus_message_iter_get_arg_type(&mDBusMessageIter))
143 mErrorName=std::string(DBUS_ERROR_INVALID_ARGS);
144 mErrorMsg="DBus argument is no byte";
148 dbus_message_iter_get_basic(&mDBusMessageIter, ¶m);
149 dbus_message_iter_next(&mDBusMessageIter);
154 dbus_uint16_t CAmDbusMessageHandler::getUInt()
158 if (DBUS_TYPE_UINT16 != dbus_message_iter_get_arg_type(&mDBusMessageIter))
160 mErrorName=std::string(DBUS_ERROR_INVALID_ARGS);
161 mErrorMsg="DBus argument is no uint16_t";
165 dbus_message_iter_get_basic(&mDBusMessageIter, ¶m);
166 dbus_message_iter_next(&mDBusMessageIter);
171 dbus_int16_t CAmDbusMessageHandler::getInt()
175 if (DBUS_TYPE_INT16 != dbus_message_iter_get_arg_type(&mDBusMessageIter))
177 mErrorName=std::string(DBUS_ERROR_INVALID_ARGS);
178 mErrorMsg="DBus argument is no int16_t";
182 dbus_message_iter_get_basic(&mDBusMessageIter, ¶m);
183 dbus_message_iter_next(&mDBusMessageIter);
188 dbus_uint32_t CAmDbusMessageHandler::getUInt32()
192 if (DBUS_TYPE_UINT32 != dbus_message_iter_get_arg_type(&mDBusMessageIter))
194 mErrorName=std::string(DBUS_ERROR_INVALID_ARGS);
195 mErrorMsg="DBus argument is no uint32_t";
199 dbus_message_iter_get_basic(&mDBusMessageIter, ¶m);
200 dbus_message_iter_next(&mDBusMessageIter);
205 dbus_int32_t CAmDbusMessageHandler::getInt32()
209 if (DBUS_TYPE_INT32 != dbus_message_iter_get_arg_type(&mDBusMessageIter))
211 mErrorName=std::string(DBUS_ERROR_INVALID_ARGS);
212 mErrorMsg="DBus argument is no int32_t";
216 dbus_message_iter_get_basic(&mDBusMessageIter, ¶m);
217 dbus_message_iter_next(&mDBusMessageIter);
222 double CAmDbusMessageHandler::getDouble()
225 if (DBUS_TYPE_DOUBLE != dbus_message_iter_get_arg_type(&mDBusMessageIter))
227 mErrorName=std::string(DBUS_ERROR_INVALID_ARGS);
228 mErrorMsg="DBus argument is no double";
232 dbus_message_iter_get_basic(&mDBusMessageIter, ¶m);
233 dbus_message_iter_next(&mDBusMessageIter);
238 void CAmDbusMessageHandler::getProperty(dbus_int16_t & type, dbus_int16_t & value)
240 DBusMessageIter arrayIter;
241 if (DBUS_TYPE_STRUCT != dbus_message_iter_get_arg_type(&mDBusMessageIter))
243 mErrorName=std::string(DBUS_ERROR_INVALID_ARGS);
244 mErrorMsg="DBus argument is no array";
248 dbus_message_iter_recurse(&mDBusMessageIter, &arrayIter);
249 dbus_message_iter_get_basic(&arrayIter, &type);
250 dbus_message_iter_next(&arrayIter);
251 dbus_message_iter_get_basic(&arrayIter, &value);
252 dbus_message_iter_next(&mDBusMessageIter);
256 void CAmDbusMessageHandler::append(bool toAppend)
258 dbus_bool_t mybool=toAppend;
259 if (!dbus_message_iter_append_basic(&mDBusMessageIter, DBUS_TYPE_BOOLEAN, &mybool))
261 mErrorName=std::string(DBUS_ERROR_NO_MEMORY);
262 mErrorMsg="Cannot create reply!";
267 void CAmDbusMessageHandler::append(double toAppend)
269 if (!dbus_message_iter_append_basic(&mDBusMessageIter, DBUS_TYPE_DOUBLE, &toAppend))
271 mErrorName=std::string(DBUS_ERROR_NO_MEMORY);
272 mErrorMsg="Cannot create reply!";
276 void CAmDbusMessageHandler::append(char toAppend)
278 if (!dbus_message_iter_append_basic(&mDBusMessageIter, DBUS_TYPE_BYTE, &toAppend))
280 mErrorName=std::string(DBUS_ERROR_NO_MEMORY);
281 mErrorMsg="Cannot create reply!";
286 void CAmDbusMessageHandler::append(dbus_int16_t toAppend)
288 if (!dbus_message_iter_append_basic(&mDBusMessageIter, DBUS_TYPE_INT16, &toAppend))
290 mErrorName=std::string(DBUS_ERROR_NO_MEMORY);
291 mErrorMsg="Cannot create reply!";
295 void CAmDbusMessageHandler::append(dbus_uint16_t toAppend)
297 if (!dbus_message_iter_append_basic(&mDBusMessageIter, DBUS_TYPE_UINT16, &toAppend))
299 mErrorName=std::string(DBUS_ERROR_NO_MEMORY);
300 mErrorMsg="Cannot create reply!";
304 void CAmDbusMessageHandler::append(dbus_uint32_t toAppend)
306 if (!dbus_message_iter_append_basic(&mDBusMessageIter, DBUS_TYPE_UINT32, &toAppend))
308 mErrorName=std::string(DBUS_ERROR_NO_MEMORY);
309 mErrorMsg="Cannot create reply!";
313 void CAmDbusMessageHandler::setDBusConnection(DBusConnection *& connection)
315 assert(connection!=NULL);
316 mDBusConnection=connection;
319 void CAmDbusMessageHandler::append(const am::am_SinkType_s& sinkType)
321 DBusMessageIter structIter;
322 DBusMessageIter structAvailIter;
323 dbus_bool_t success=true;
324 success=success && dbus_message_iter_open_container(&mDBusMessageIter, DBUS_TYPE_STRUCT, NULL, &structIter);
325 success=success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_UINT16, &sinkType.sinkID);
326 success=success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_STRING, &sinkType.name);
328 success=success && dbus_message_iter_open_container(&structIter, DBUS_TYPE_STRUCT, NULL, &structAvailIter);
329 success=success && dbus_message_iter_append_basic(&structAvailIter, DBUS_TYPE_INT16, &sinkType.availability.availability);
330 success=success && dbus_message_iter_append_basic(&structAvailIter, DBUS_TYPE_INT16, &sinkType.availability.availabilityReason);
331 success=success && dbus_message_iter_close_container(&structIter, &structAvailIter);
333 success=success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_INT16, &sinkType.volume);
334 success=success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_INT16, &sinkType.muteState);
335 success=success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_UINT16, &sinkType.sinkClassID);
336 success=success && dbus_message_iter_close_container(&mDBusMessageIter, &structIter);
340 mErrorName=std::string(DBUS_ERROR_NO_MEMORY);
341 mErrorMsg="Cannot create reply!";
345 void CAmDbusMessageHandler::append(const am::am_SourceType_s & sourceType)
347 DBusMessageIter structIter;
348 DBusMessageIter structAvailIter;
349 dbus_bool_t success=true;
350 success=success && dbus_message_iter_open_container(&mDBusMessageIter, DBUS_TYPE_STRUCT, NULL, &structIter);
351 success=success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_UINT16, &sourceType.sourceID);
352 success=success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_STRING, &sourceType.name);
354 success=success && dbus_message_iter_open_container(&structIter, DBUS_TYPE_STRUCT, NULL, &structAvailIter);
355 success=success && dbus_message_iter_append_basic(&structAvailIter, DBUS_TYPE_INT16, &sourceType.availability.availability);
356 success=success && dbus_message_iter_append_basic(&structAvailIter, DBUS_TYPE_INT16, &sourceType.availability.availabilityReason);
357 success=success && dbus_message_iter_close_container(&structIter, &structAvailIter);
359 success=success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_UINT16, &sourceType.sourceClassID);
360 success=success && dbus_message_iter_close_container(&mDBusMessageIter, &structIter);
364 mErrorName=std::string(DBUS_ERROR_NO_MEMORY);
365 mErrorMsg="Cannot create reply!";
369 void CAmDbusMessageHandler::append(const am::am_MainSoundProperty_s mainSoundProperty)
371 DBusMessageIter structIter;
372 dbus_bool_t success=true;
373 success=success && dbus_message_iter_open_container(&mDBusMessageIter, DBUS_TYPE_STRUCT, NULL, &structIter);
374 success=success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_INT16, &mainSoundProperty.type);
375 success=success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_INT16, &mainSoundProperty.value);
376 success=success && dbus_message_iter_close_container(&mDBusMessageIter, &structIter);
380 mErrorName=std::string(DBUS_ERROR_NO_MEMORY);
381 mErrorMsg="Cannot create reply!";
385 void CAmDbusMessageHandler::append(const am::am_Availability_s & availability)
387 DBusMessageIter structAvailIter;
388 dbus_bool_t success=true;
389 success=success && dbus_message_iter_open_container(&mDBusMessageIter, DBUS_TYPE_STRUCT,NULL, &structAvailIter);
390 success=success && dbus_message_iter_append_basic(&structAvailIter, DBUS_TYPE_INT16, &availability.availability);
391 success=success && dbus_message_iter_append_basic(&structAvailIter, DBUS_TYPE_INT16, &availability.availabilityReason);
392 success=success && dbus_message_iter_close_container(&mDBusMessageIter, &structAvailIter);
396 mErrorName=std::string(DBUS_ERROR_NO_MEMORY);
397 mErrorMsg="Cannot create reply!";
401 void CAmDbusMessageHandler::append(const am::am_SystemProperty_s & SystemProperty)
403 DBusMessageIter structIter;
404 dbus_bool_t success=true;
405 success=success && dbus_message_iter_open_container(&mDBusMessageIter, DBUS_TYPE_STRUCT, NULL, &structIter);
406 success=success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_INT16, &SystemProperty.type);
407 success=success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_INT16, &SystemProperty.value);
408 success=success && dbus_message_iter_close_container(&mDBusMessageIter, &structIter);
412 mErrorName=std::string(DBUS_ERROR_NO_MEMORY);
413 mErrorMsg="Cannot create reply!";
417 void CAmDbusMessageHandler::append(const std::vector<am::am_MainConnectionType_s>& listMainConnections)
419 DBusMessageIter arrayIter;
420 DBusMessageIter structIter;
421 std::vector<am::am_MainConnectionType_s>::const_iterator listIterator=listMainConnections.begin();
422 dbus_bool_t success=true;
424 success=success && dbus_message_iter_open_container(&mDBusMessageIter, DBUS_TYPE_ARRAY, "(qqqnn)", &arrayIter);
425 for(;listIterator<listMainConnections.end();++listIterator)
427 success=success && dbus_message_iter_open_container(&arrayIter, DBUS_TYPE_STRUCT, NULL, &structIter);
428 success=success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_UINT16, &listIterator->mainConnectionID);
429 success=success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_UINT16, &listIterator->sourceID);
430 success=success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_UINT16, &listIterator->sinkID);
431 success=success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_INT16, &listIterator->delay);
432 success=success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_INT16, &listIterator->connectionState);
433 success=success && dbus_message_iter_close_container(&arrayIter, &structIter);
435 success=success && dbus_message_iter_close_container(&mDBusMessageIter, &arrayIter);
439 mErrorName=std::string(DBUS_ERROR_NO_MEMORY);
440 mErrorMsg="Cannot create reply!";
444 void CAmDbusMessageHandler::append(const std::vector<am::am_SinkType_s> & listMainSinks)
446 DBusMessageIter arrayIter;
447 DBusMessageIter structIter;
448 DBusMessageIter availIter;
449 std::vector<am::am_SinkType_s>::const_iterator listIterator=listMainSinks.begin();
450 dbus_bool_t success=true;
452 success=success && dbus_message_iter_open_container(&mDBusMessageIter, DBUS_TYPE_ARRAY, "(qs(nn)nnq)", &arrayIter);
453 for(;listIterator<listMainSinks.end();++listIterator)
455 success=success && dbus_message_iter_open_container(&arrayIter, DBUS_TYPE_STRUCT, NULL, &structIter);
456 success=success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_UINT16, &listIterator->sinkID);
457 success=success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_STRING, &listIterator->name);
458 success=success && dbus_message_iter_open_container(&structIter, DBUS_TYPE_STRUCT, NULL, &availIter);
459 success=success && dbus_message_iter_append_basic(&availIter, DBUS_TYPE_INT16, &listIterator->availability.availability);
460 success=success && dbus_message_iter_append_basic(&availIter, DBUS_TYPE_INT16, &listIterator->availability.availabilityReason);
461 success=success && dbus_message_iter_close_container(&structIter, &availIter);
462 success=success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_INT16, &listIterator->volume);
463 success=success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_INT16, &listIterator->muteState);
464 success=success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_UINT16, &listIterator->sinkClassID);
465 success=success && dbus_message_iter_close_container(&arrayIter, &structIter);
467 success=success && dbus_message_iter_close_container(&mDBusMessageIter, &arrayIter);
471 mErrorName=std::string(DBUS_ERROR_NO_MEMORY);
472 mErrorMsg="Cannot create reply!";
478 void CAmDbusMessageHandler::append(const std::vector<am::am_SourceType_s> & listMainSources)
480 DBusMessageIter arrayIter;
481 DBusMessageIter structIter;
482 DBusMessageIter availIter;
483 std::vector<am::am_SourceType_s>::const_iterator listIterator=listMainSources.begin();
484 dbus_bool_t success=true;
486 success=success && dbus_message_iter_open_container(&mDBusMessageIter, DBUS_TYPE_ARRAY, "(qs(nn)q)", &arrayIter);
487 for(;listIterator<listMainSources.end();++listIterator)
489 success=success && dbus_message_iter_open_container(&arrayIter, DBUS_TYPE_STRUCT, NULL, &structIter);
490 success=success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_UINT16, &listIterator->sourceID);
491 success=success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_STRING, &listIterator->name);
492 success=success && dbus_message_iter_open_container(&structIter, DBUS_TYPE_STRUCT, NULL, &availIter);
493 success=success && dbus_message_iter_append_basic(&availIter, DBUS_TYPE_INT16, &listIterator->availability.availability);
494 success=success && dbus_message_iter_append_basic(&availIter, DBUS_TYPE_INT16, &listIterator->availability.availabilityReason);
495 success=success && dbus_message_iter_close_container(&structIter, &availIter);
496 success=success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_UINT16, &listIterator->sourceClassID);
497 success=success && dbus_message_iter_close_container(&arrayIter, &structIter);
499 success=success && dbus_message_iter_close_container(&mDBusMessageIter, &arrayIter);
503 mErrorName=std::string(DBUS_ERROR_NO_MEMORY);
504 mErrorMsg="Cannot create reply!";
508 void CAmDbusMessageHandler::append(const std::vector<am::am_MainSoundProperty_s> & listMainSoundProperties)
510 DBusMessageIter arrayIter;
511 DBusMessageIter structIter;
512 std::vector<am::am_MainSoundProperty_s>::const_iterator listIterator=listMainSoundProperties.begin();
513 dbus_bool_t success=true;
515 success=success && dbus_message_iter_open_container(&mDBusMessageIter, DBUS_TYPE_ARRAY, "(nn)", &arrayIter);
516 for(;listIterator<listMainSoundProperties.end();++listIterator)
518 success=success && dbus_message_iter_open_container(&arrayIter, DBUS_TYPE_STRUCT, NULL, &structIter);
519 success=success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_INT16, &listIterator->type);
520 success=success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_INT16, &listIterator->value);
521 success=success && dbus_message_iter_close_container(&arrayIter, &structIter);
523 success=success && dbus_message_iter_close_container(&mDBusMessageIter, &arrayIter);
527 mErrorName=std::string(DBUS_ERROR_NO_MEMORY);
528 mErrorMsg="Cannot create reply!";
532 void CAmDbusMessageHandler::append(const std::vector<am::am_SourceClass_s> & listSourceClasses)
534 DBusMessageIter arrayIter;
535 DBusMessageIter structIter;
536 DBusMessageIter propIter;
537 DBusMessageIter innerIter;
538 std::vector<am::am_SourceClass_s>::const_iterator listIterator=listSourceClasses.begin();
539 dbus_bool_t success=true;
541 success=success && dbus_message_iter_open_container(&mDBusMessageIter, DBUS_TYPE_ARRAY, "(qsa(nn))", &arrayIter);
542 for(;listIterator<listSourceClasses.end();++listIterator)
544 success=success && dbus_message_iter_open_container(&arrayIter, DBUS_TYPE_STRUCT, NULL, &structIter);
545 success=success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_UINT16, &listIterator->sourceClassID);
546 success=success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_STRING, &listIterator->name);
547 success=success && dbus_message_iter_open_container(&structIter, DBUS_TYPE_ARRAY, "(nn)", &innerIter);
549 std::vector<am::am_ClassProperty_s>::const_iterator listInnerIterator=listIterator->listClassProperties.begin();
550 for(;listInnerIterator<listIterator->listClassProperties.end();++listInnerIterator)
552 success=success && dbus_message_iter_open_container(&innerIter, DBUS_TYPE_STRUCT, NULL, &propIter);
553 success=success && dbus_message_iter_append_basic(&propIter, DBUS_TYPE_INT16, &listInnerIterator->classProperty);
554 success=success && dbus_message_iter_append_basic(&propIter, DBUS_TYPE_INT16, &listInnerIterator->value);
555 success=success && dbus_message_iter_close_container(&innerIter, &propIter);
557 success=success && dbus_message_iter_close_container(&structIter, &innerIter);
558 success=success && dbus_message_iter_close_container(&arrayIter, &structIter);
560 success=success && dbus_message_iter_close_container(&mDBusMessageIter, &arrayIter);
564 mErrorName=std::string(DBUS_ERROR_NO_MEMORY);
565 mErrorMsg="Cannot create reply!";
569 void CAmDbusMessageHandler::append(const std::vector<am::am_SinkClass_s> & listSinkClasses)
571 DBusMessageIter arrayIter;
572 DBusMessageIter structIter;
573 DBusMessageIter propIter;
574 DBusMessageIter innerIter;
575 std::vector<am::am_SinkClass_s>::const_iterator listIterator=listSinkClasses.begin();
576 dbus_bool_t success=true;
578 success=success && dbus_message_iter_open_container(&mDBusMessageIter, DBUS_TYPE_ARRAY, "(qsa(nn))", &arrayIter);
579 for(;listIterator<listSinkClasses.end();++listIterator)
581 success=success && dbus_message_iter_open_container(&arrayIter, DBUS_TYPE_STRUCT, NULL, &structIter);
582 success=success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_UINT16, &listIterator->sinkClassID);
583 success=success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_STRING, &listIterator->name);
584 success=success && dbus_message_iter_open_container(&structIter, DBUS_TYPE_ARRAY, "(nn)", &innerIter);
586 std::vector<am::am_ClassProperty_s>::const_iterator listInnerIterator=listIterator->listClassProperties.begin();
587 for(;listInnerIterator<listIterator->listClassProperties.end();++listInnerIterator)
589 success=success && dbus_message_iter_open_container(&innerIter, DBUS_TYPE_STRUCT, NULL, &propIter);
590 success=success && dbus_message_iter_append_basic(&propIter, DBUS_TYPE_INT16, &listInnerIterator->classProperty);
591 success=success && dbus_message_iter_append_basic(&propIter, DBUS_TYPE_INT16, &listInnerIterator->value);
592 success=success && dbus_message_iter_close_container(&innerIter, &propIter);
594 success=success && dbus_message_iter_close_container(&structIter, &innerIter);
595 success=success && dbus_message_iter_close_container(&arrayIter, &structIter);
597 success=success && dbus_message_iter_close_container(&mDBusMessageIter, &arrayIter);
601 mErrorName=std::string(DBUS_ERROR_NO_MEMORY);
602 mErrorMsg="Cannot create reply!";
606 void CAmDbusMessageHandler::append(const std::vector<am::am_SystemProperty_s> & listSystemProperties)
608 DBusMessageIter arrayIter;
609 DBusMessageIter structIter;
610 std::vector<am::am_SystemProperty_s>::const_iterator listIterator=listSystemProperties.begin();
611 dbus_bool_t success=true;
613 success=success && dbus_message_iter_open_container(&mDBusMessageIter, DBUS_TYPE_ARRAY, "(nn)", &arrayIter);
614 for(;listIterator<listSystemProperties.end();++listIterator)
616 success=success && dbus_message_iter_open_container(&arrayIter, DBUS_TYPE_STRUCT, NULL, &structIter);
617 success=success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_INT16, &listIterator->type);
618 success=success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_INT16, &listIterator->value);
619 success=success && dbus_message_iter_close_container(&arrayIter, &structIter);
621 success=success && dbus_message_iter_close_container(&mDBusMessageIter, &arrayIter);
625 mErrorName=std::string(DBUS_ERROR_NO_MEMORY);
626 mErrorMsg="Cannot create reply!";