![]() |
Functions for manage easydbus dict entry containers
Functions | |
int | easydbus_add_dict_entry_tomsg (DBusMessage *msg, DBusMessageIter *iter, struct EasyDbus_elem *el) |
Add unique dict entry element to DBusMessage. | |
struct EasyDbus_container * | easydbus_dict_entry_build_container (enum event_type type, void *container, DBusMessageIter *iter) |
Create a dict entry container from iter passed in input. |
int easydbus_add_dict_entry_tomsg | ( | DBusMessage * | msg, | |
DBusMessageIter * | iter, | |||
struct EasyDbus_elem * | el | |||
) |
Add unique dict entry element to DBusMessage.
For internal use only.
msg | pointer to DBusMessage used for insert dict entry element. | |
iter | pointer to DBusMessageIter (array initialize iterator) | |
el | pointer to dict_entry element. |
0 ok
With new version signature of dict entry MUST be null
signature = prepare_signature (el, EASYDBUS_SIGNATURE_NORMAL); EasyDbusDebug ("Signature of Dict Entry = %s\n", signature); if (signature == NULL) return -1;
Definition at line 206 of file dict_entry_internal.c.
References add_variant_to_container_on_msg(), EasyDbus_elem::byte, EasyDbus_elem::Double, EASYDBUS_ELTYPE_BOOLEAN, EASYDBUS_ELTYPE_BYTE, EASYDBUS_ELTYPE_DOUBLE, EASYDBUS_ELTYPE_INT16, EASYDBUS_ELTYPE_INT32, EASYDBUS_ELTYPE_INT64, EASYDBUS_ELTYPE_OBJECT_PATH, EASYDBUS_ELTYPE_SIGNATURE, EASYDBUS_ELTYPE_STRING, EASYDBUS_ELTYPE_UINT16, EASYDBUS_ELTYPE_UINT32, EASYDBUS_ELTYPE_UINT64, EASYDBUS_ELTYPE_VARIANT, EasyDbusDebug, EasyDbus_elem::i16, EasyDbus_elem::i32, EasyDbus_elem::i64, EasyDbus_elem::next, EasyDbus_elem::p_container, EasyDbus_container::p_data, EasyDbus_elem::payload, EasyDbus_elem::type, EasyDbus_elem::ui16, EasyDbus_elem::ui32, and EasyDbus_elem::ui64.
Referenced by add_array_to_msg(), and easydbus_add_array_on_container_tomsg().
00209 { 00210 int i; 00211 DBusMessageIter iter2; 00212 struct EasyDbus_elem *dict_entry = NULL; 00213 //char *signature = NULL; 00214 int ret_val = 0; 00215 00224 dbus_message_iter_open_container (iter, 00225 DBUS_TYPE_DICT_ENTRY, NULL, 00226 //DBUS_TYPE_DICT_ENTRY, signature, 00227 &iter2); 00228 dict_entry = (struct EasyDbus_elem *) 00229 el->payload.p_container->p_data; 00230 00231 for (i = 0; i < 2; i++) { 00232 switch (dict_entry->type) { 00233 case EASYDBUS_ELTYPE_STRING: 00234 dbus_message_iter_append_basic (&iter2, 00235 DBUS_TYPE_STRING, 00236 &dict_entry->payload. 00237 string); 00238 break; 00239 case EASYDBUS_ELTYPE_BYTE: 00240 dbus_message_iter_append_basic (&iter2, 00241 DBUS_TYPE_BYTE, 00242 &dict_entry->payload. 00243 byte); 00244 break; 00245 case EASYDBUS_ELTYPE_BOOLEAN: 00246 dbus_message_iter_append_basic (&iter2, 00247 DBUS_TYPE_BOOLEAN, 00248 &dict_entry->payload. 00249 boolean); 00250 break; 00251 case EASYDBUS_ELTYPE_DOUBLE: 00252 dbus_message_iter_append_basic (&iter2, 00253 DBUS_TYPE_DOUBLE, 00254 &dict_entry->payload. 00255 Double); 00256 break; 00257 case EASYDBUS_ELTYPE_INT16: 00258 dbus_message_iter_append_basic (&iter2, 00259 DBUS_TYPE_INT16, 00260 &dict_entry->payload.i16); 00261 break; 00262 case EASYDBUS_ELTYPE_UINT16: 00263 dbus_message_iter_append_basic (&iter2, 00264 DBUS_TYPE_UINT16, 00265 &dict_entry->payload. 00266 ui16); 00267 break; 00268 case EASYDBUS_ELTYPE_INT32: 00269 dbus_message_iter_append_basic (&iter2, 00270 DBUS_TYPE_INT32, 00271 &dict_entry->payload.i32); 00272 break; 00273 case EASYDBUS_ELTYPE_UINT32: 00274 dbus_message_iter_append_basic (&iter2, 00275 DBUS_TYPE_UINT32, 00276 &dict_entry->payload. 00277 ui32); 00278 break; 00279 case EASYDBUS_ELTYPE_INT64: 00280 dbus_message_iter_append_basic (&iter2, 00281 DBUS_TYPE_INT64, 00282 &dict_entry->payload.i64); 00283 break; 00284 case EASYDBUS_ELTYPE_UINT64: 00285 dbus_message_iter_append_basic (&iter2, 00286 DBUS_TYPE_UINT64, 00287 &dict_entry->payload. 00288 ui64); 00289 break; 00290 case EASYDBUS_ELTYPE_OBJECT_PATH: 00291 dbus_message_iter_append_basic (&iter2, 00292 DBUS_TYPE_OBJECT_PATH, 00293 &dict_entry->payload. 00294 string); 00295 break; 00296 case EASYDBUS_ELTYPE_SIGNATURE: 00297 dbus_message_iter_append_basic (&iter2, 00298 DBUS_TYPE_SIGNATURE, 00299 &dict_entry->payload. 00300 string); 00301 break; 00302 case EASYDBUS_ELTYPE_VARIANT: 00303 if (add_variant_to_container_on_msg 00304 (msg, dict_entry, &iter2)) { 00305 ret_val = -1; 00306 goto end; 00307 } 00308 break; 00309 default: 00310 EasyDbusDebug ("Element not managed!"); 00311 ret_val = -1; 00312 goto end; 00313 break; 00314 } 00315 dict_entry = dict_entry->next; 00316 } // end of for with i 00317 end: 00318 dbus_message_iter_close_container (iter, &iter2); 00319 // free (signature); 00320 return ret_val; 00321 }
struct EasyDbus_container* easydbus_dict_entry_build_container | ( | enum event_type | type, | |
void * | container, | |||
DBusMessageIter * | iter | |||
) | [read] |
Create a dict entry container from iter passed in input.
For internal use only.
type | type of message object | |
container | pointer to message object | |
iter | pointer to DBusMessageIter where recover data about dict entry from DBusMessage. |
pointer to new dict entry container.
Definition at line 64 of file dict_entry_internal.c.
References easydbus_container_create_skeleton(), easydbus_container_free(), easydbus_dict_entry_add_boolean(), easydbus_dict_entry_add_byte(), easydbus_dict_entry_add_double(), easydbus_dict_entry_add_i16(), easydbus_dict_entry_add_i32(), easydbus_dict_entry_add_i64(), easydbus_dict_entry_add_obj_path(), easydbus_dict_entry_add_signature(), easydbus_dict_entry_add_string(), easydbus_dict_entry_add_ui16(), easydbus_dict_entry_add_ui32(), easydbus_dict_entry_add_ui64(), easydbus_dict_entry_add_variant(), EASYDBUS_ELTYPE_DICT_ENTRY, easydbus_variant_build_elem(), EasyDbusDebug, and EasyDbus_container::signature.
Referenced by easydbus_get_marshal_data_from_array().
00067 { 00068 struct EasyDbus_container *dict_entry = NULL; 00069 struct EasyDbus_container *variant = NULL; 00070 DBusMessageIter subiter; 00071 int i32 = 0, i = 0; 00072 unsigned int ui32 = 0; 00073 short i16 = 0; 00074 char byte = 0; 00075 char *string = NULL; 00076 unsigned short ui16 = 0; 00077 long long i64 = 0; 00078 double d = 0; 00079 unsigned long long ui64 = 0; 00080 00081 #ifdef EASYDBUS_DEBUG 00082 char *signature = NULL; 00083 #endif 00084 00085 if (container == NULL || iter == NULL) 00086 return NULL; 00087 00088 dict_entry = 00089 easydbus_container_create_skeleton (EASYDBUS_ELTYPE_DICT_ENTRY); 00090 00091 if (dict_entry == NULL) 00092 return NULL; 00093 00094 00095 // see if there a dedicated function to inizialize 00096 // this variable. 00097 memset (&subiter, 0, sizeof (DBusMessageIter)); 00098 00099 dbus_message_iter_recurse (iter, &subiter); 00100 00101 #ifdef EASYDBUS_DEBUG 00102 signature = dbus_message_iter_get_signature (&subiter); 00103 EasyDbusDebug ("Current Signature = %s", signature); 00104 dbus_free (signature); 00105 #endif 00106 00107 for (i = 0; i < 2; i++) { 00108 switch (dbus_message_iter_get_arg_type (&subiter)) { 00109 case DBUS_TYPE_STRING: 00110 dbus_message_iter_get_basic (&subiter, &string); 00111 EasyDbusDebug ("founded string = %s\n", string); 00112 easydbus_dict_entry_add_string (dict_entry, string); 00113 break; 00114 case DBUS_TYPE_INT32: 00115 dbus_message_iter_get_basic (&subiter, &i32); 00116 EasyDbusDebug ("founded int32 = %d", i32); 00117 easydbus_dict_entry_add_i32 (dict_entry, i32); 00118 break; 00119 case DBUS_TYPE_UINT32: 00120 dbus_message_iter_get_basic (&subiter, &ui32); 00121 EasyDbusDebug ("founded uint32 = %d", ui32); 00122 easydbus_dict_entry_add_ui32 (dict_entry, ui32); 00123 break; 00124 case DBUS_TYPE_INT16: 00125 dbus_message_iter_get_basic (&subiter, &i16); 00126 EasyDbusDebug ("founded int16 = %d", i16); 00127 easydbus_dict_entry_add_i16 (dict_entry, i16); 00128 break; 00129 case DBUS_TYPE_UINT16: 00130 dbus_message_iter_get_basic (&subiter, &ui16); 00131 EasyDbusDebug ("founded uint16 = %d", ui16); 00132 easydbus_dict_entry_add_ui16 (dict_entry, ui16); 00133 break; 00134 case DBUS_TYPE_INT64: 00135 dbus_message_iter_get_basic (&subiter, &i64); 00136 EasyDbusDebug ("founded int64 = %lld", i64); 00137 easydbus_dict_entry_add_i64 (dict_entry, i64); 00138 break; 00139 case DBUS_TYPE_UINT64: 00140 dbus_message_iter_get_basic (&subiter, &ui64); 00141 EasyDbusDebug ("founded uint64 = %lld", ui64); 00142 easydbus_dict_entry_add_ui64 (dict_entry, ui64); 00143 break; 00144 case DBUS_TYPE_BYTE: 00145 dbus_message_iter_get_basic (&subiter, &byte); 00146 EasyDbusDebug ("founded byte = %d", byte); 00147 easydbus_dict_entry_add_byte (dict_entry, byte); 00148 break; 00149 case DBUS_TYPE_BOOLEAN: 00150 dbus_message_iter_get_basic (&subiter, &byte); 00151 EasyDbusDebug ("founded boolean = %d", byte); 00152 easydbus_dict_entry_add_boolean (dict_entry, byte); 00153 break; 00154 case DBUS_TYPE_DOUBLE: 00155 dbus_message_iter_get_basic (&subiter, &d); 00156 EasyDbusDebug ("founded double = %f", d); 00157 easydbus_dict_entry_add_double (dict_entry, d); 00158 break; 00159 case DBUS_TYPE_OBJECT_PATH: 00160 dbus_message_iter_get_basic (&subiter, &string); 00161 EasyDbusDebug ("founded obj_path = %s\n", string); 00162 easydbus_dict_entry_add_obj_path (dict_entry, string); 00163 break; 00164 case DBUS_TYPE_SIGNATURE: 00165 dbus_message_iter_get_basic (&subiter, &string); 00166 EasyDbusDebug ("founded signature = %s\n", string); 00167 easydbus_dict_entry_add_signature (dict_entry, string); 00168 break; 00169 case DBUS_TYPE_VARIANT: 00170 variant = easydbus_variant_build_elem 00171 (type, (void *) container, &subiter); 00172 if (variant != NULL) { 00173 easydbus_dict_entry_add_variant (dict_entry, variant); 00174 EasyDbusDebug ("Added variant to container"); 00175 } 00176 else 00177 EasyDbusDebug ("Error on add variant to container"); 00178 break; 00179 default: 00180 goto error; 00181 break; 00182 } 00183 dbus_message_iter_next (&subiter); 00184 } 00185 00186 return dict_entry; 00187 00188 error: 00189 if (dict_entry != NULL) 00190 easydbus_container_free (dict_entry); 00191 return NULL; 00192 }