Changeset 3316
- Timestamp:
- 05/04/08 22:39:46 (3 months ago)
- Files:
-
- trunk/opensync/ipc/opensync_serializer.c (modified) (17 diffs)
- trunk/opensync/ipc/opensync_serializer.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/opensync/ipc/opensync_serializer.c
r3201 r3316 31 31 osync_bool osync_marshal_data(OSyncMessage *message, OSyncData *data, OSyncError **error) 32 32 { 33 osync_assert(message); 34 osync_assert(data); 35 33 36 /* Order: 34 37 * … … 46 49 /* Write the format and objtype first */ 47 50 osync_message_write_string(message, osync_objformat_get_name(objformat)); 48 osync_message_write_string(message, osync_objformat_get_config(objformat));49 51 osync_message_write_string(message, osync_data_get_objtype(data)); 50 52 … … 82 84 osync_bool osync_demarshal_data(OSyncMessage *message, OSyncData **data, OSyncFormatEnv *env, OSyncError **error) 83 85 { 86 osync_assert(message); 87 osync_assert(env); 88 84 89 /* Order: 85 90 * … … 91 96 /* Get the objtype and format */ 92 97 char *objformat = NULL; 93 char *objformat_config = NULL;94 98 char *objtype = NULL; 95 99 osync_message_read_string(message, &objformat); 96 osync_message_read_string(message, &objformat_config);97 100 osync_message_read_string(message, &objtype); 98 101 … … 103 106 goto error; 104 107 } 105 osync_objformat_set_config(format, objformat_config);106 g_free(objformat_config);107 108 108 109 unsigned int input_size = 0; … … 147 148 osync_bool osync_marshal_change(OSyncMessage *message, OSyncChange *change, OSyncError **error) 148 149 { 150 osync_assert(message); 151 osync_assert(change); 152 149 153 /* Order: 150 154 * … … 170 174 osync_bool osync_demarshal_change(OSyncMessage *message, OSyncChange **change, OSyncFormatEnv *env, OSyncError **error) 171 175 { 176 osync_assert(message); 177 osync_assert(env); 178 172 179 /* Order: 173 180 * … … 213 220 } 214 221 222 osync_bool osync_marshal_objformat_sink(OSyncMessage *message, OSyncObjFormatSink *sink, OSyncError **error) 223 { 224 /* Order: 225 * 226 * objformat name 227 * objformat sink config 228 */ 229 230 const char *objformat_name = osync_objformat_sink_get_objformat(sink); 231 const char *objformat_sink_config = osync_objformat_sink_get_config(sink); 232 233 osync_message_write_string(message, objformat_name); 234 osync_message_write_string(message, objformat_sink_config); 235 236 return TRUE; 237 } 238 239 osync_bool osync_demarshal_objformat_sink(OSyncMessage *message, OSyncObjFormatSink **sink, OSyncError **error) 240 { 241 osync_assert(message); 242 243 /* Order: 244 * 245 * objformat name 246 * objformat sink config 247 */ 248 249 /* Get the objtype and format */ 250 char *objformat_name = NULL; 251 char *objformat_sink_config = NULL; 252 osync_message_read_string(message, &objformat_name); 253 254 *sink = osync_objformat_sink_new(objformat_name, error); 255 if (!*sink) 256 goto error; 257 258 osync_message_read_string(message, &objformat_sink_config); 259 osync_objformat_sink_set_config(*sink, objformat_sink_config); 260 g_free(objformat_sink_config); 261 262 return TRUE; 263 264 error: 265 osync_trace(TRACE_ERROR, "%s: %s", __func__, osync_error_print(error)); 266 return FALSE; 267 } 268 215 269 osync_bool osync_marshal_objtype_sink(OSyncMessage *message, OSyncObjTypeSink *sink, OSyncError **error) 216 270 { 271 osync_assert(message); 272 osync_assert(sink); 273 217 274 /* Order: 218 275 * … … 221 278 * get_changes function (bool) 222 279 * write function (bool) 223 * number of format s224 * format list (string)280 * number of format sinks 281 * format sink list (format sinks) 225 282 * enabled (int) 226 283 * timeout connect (int) … … 237 294 238 295 int i = 0; 239 int num = osync_objtype_sink_num_objformats(sink);296 unsigned int num = osync_objtype_sink_num_objformat_sinks(sink); 240 297 osync_message_write_string(message, osync_objtype_sink_get_name(sink)); 241 298 … … 246 303 osync_message_write_int(message, num); 247 304 for (i = 0; i < num; i++) { 248 const char *format = osync_objtype_sink_nth_objformat(sink, i); 249 const char *format_config = osync_objtype_sink_nth_objformat_config(sink, i); 250 osync_message_write_string(message, format); 251 osync_message_write_string(message, format_config); 305 OSyncObjFormatSink *formatsink = osync_objtype_sink_nth_objformat_sink(sink, i); 306 if (!osync_marshal_objformat_sink(message, formatsink, error)) 307 goto error; 252 308 } 253 309 … … 270 326 271 327 return TRUE; 328 329 error: 330 return FALSE; 272 331 } 273 332 274 333 osync_bool osync_demarshal_objtype_sink(OSyncMessage *message, OSyncObjTypeSink **sink, OSyncError **error) 275 334 { 335 osync_assert(message); 336 276 337 /* Order: 277 338 * … … 280 341 * get_changes function (bool) 281 342 * write function (bool) 282 * number of format s283 * format list (string)343 * number of format sinks 344 * format sink list (format sinks) 284 345 * enabled (int) 285 346 * timeout connect (int) … … 303 364 int enabled = 0, timeout = 0; 304 365 int read = 0, get_changes = 0, write = 0; 305 char *format = NULL;306 char *format_config = NULL;307 366 308 367 osync_message_read_string(message, &name); … … 322 381 int i = 0; 323 382 for (i = 0; i < num_formats; i++) { 324 osync_message_read_string(message, &format); 325 osync_message_read_string(message, &format_config); 326 osync_objtype_sink_add_objformat_with_config(*sink, format, format_config); 327 g_free(format); 328 g_free(format_config); 383 OSyncObjFormatSink *formatsink; 384 if (!osync_demarshal_objformat_sink(message, &formatsink, error)) 385 goto error; 386 387 osync_objtype_sink_add_objformat_sink(*sink, formatsink); 388 osync_objformat_sink_unref(formatsink); 329 389 } 330 390 … … 369 429 void osync_marshal_error(OSyncMessage *message, OSyncError *error) 370 430 { 431 osync_assert(message); 432 371 433 if (error) { 372 434 osync_message_write_int(message, 1); … … 381 443 void osync_demarshal_error(OSyncMessage *message, OSyncError **error) 382 444 { 445 osync_assert(message); 446 383 447 int hasError = 0; 384 448 trunk/opensync/ipc/opensync_serializer.h
r1084 r3316 31 31 void osync_demarshal_error(OSyncMessage *message, OSyncError **error); 32 32 33 osync_bool osync_marshal_objformat_sink(OSyncMessage *message, OSyncObjFormatSink *sink, OSyncError **error); 34 osync_bool osync_demarshal_objformat_sink(OSyncMessage *message, OSyncObjFormatSink **sink, OSyncError **error); 35 33 36 osync_bool osync_marshal_objtype_sink(OSyncMessage *message, OSyncObjTypeSink *sink, OSyncError **error); 34 37 osync_bool osync_demarshal_objtype_sink(OSyncMessage *message, OSyncObjTypeSink **sink, OSyncError **error);
