Hi,<br><br>Thanks a lot for your help.<br><br>It was easy, but I am still stuck in an issue. In another function which return and array of struct and one of the struct member is variant. When I call the function from another program. I receive "DBus::Error" , "what(): unknown type". The interesting part is I did not receive this error if I return only structure not the array of structure, or return the array of structure without variant as members.
<br><br>So something is wrong in combination of array and variant. The function example which gives and error is as:<br><br>std::vector< DBus::Struct<DBus::String, DBus::UInt32,<br> DBus::String, DBus::Variant> >
<br>CManager::GetParameters(const DBus::String &pto)<br>{<br> std::cerr << "Method GetParameters\n";<br><br> DBus::Struct< DBus::String, DBus::UInt32,<br> DBus::String,DBus::Variant > param;
<br><br> param._1 = "protocol";<br> param._2 = 1;<br> param._3 = "string";<br> <br> // Add the variant<br> DBus::MessageIter i = param._4.writer();<br> i << DBus::String("None");
<br><br> std::vector < DBus::Struct< DBus::String, DBus::UInt32,<br> DBus::String,DBus::Variant> > temp;<br> temp.push_back(param);<br><br> return temp;<br>}<br><br>In this function if I removed variant from the structure or remove vector and just keep struct then it works fine, otherwise the remote caller function terminate with "DBus::Error" , "what(): unknown type" error.
<br><br>Could anyone please help me to figure out the problem?<br><br>-Thanks & Regards<br>Naveen<br><br><div><span class="gmail_quote">On 7/9/07, <b class="gmail_sendername">P. Durante</b> <<a href="mailto:shackan@gmail.com">
shackan@gmail.com</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Hi,<br><br>On 7/8/07, Naveen Verma <<a href="mailto:ernaveenverma@gmail.com">
ernaveenverma@gmail.com</a>> wrote:<br>> Hi,<br>><br>> I have a function which return a variant. But whenever I am trying to call<br>> the function. I receive an error and program terminates. I am unable to
<br>> understand what is the reason.<br>> May be I am not creating the variant in correct way. Could anyone please<br>> check the code and error below, and give me an idea what is wrong?<br>><br>><br>> DBus::Variant Test::getTestValue()
<br>> {<br>> DBus::Variant var;<br>> DBus::MessageIter i = var.writer();<br>> MessageIter j = i.new_variant("s");<br>> j.append_string("Test");<br>> i.close_container
(j);<br>><br>> return var;<br>> }<br>><br>><br>> And the error message is:<br>><br>> process 6933: arguments to<br>> dbus_message_iter_open_container() were incorrect,<br>> assertion "(type == DBUS_TYPE_STRUCT && contained_signature == NULL) ||
<br>> (type == DBUS_TYPE_DICT_ENTRY && contained_signature == NULL) ||<br>> contained_signature != NULL" failed in file dbus-message.c line 2330.<br>> This is normally a bug in some application using the D-Bus library.
<br>><br><br>it's actually simpler than that<br><br>DBus::Variant Test::getTestValue()<br>{<br> DBus::Variant var;<br> DBus::MessageIter i = var.writer();<br> i.append_string("hello");
<br> return var;<br>}<br><br>or<br> DBus::MessageIter i = var.writer();<br> i << DBus::String("hello")<br>or<br> DBus::MessageIter i = var.writer();<br> i << std::string("hello");
<br><br>of course, if you want to stuff more values into a variant, you'll use<br>a structure or an array accordingly<br><br>regards,<br>Paolo<br></blockquote></div><br>