Changeset 166
- Timestamp:
- 05/21/06 13:14:08 (3 years ago)
- Files:
-
- branches/dev-branch/libsyncml/objects/sml_ds_server.c (modified) (9 diffs)
- branches/dev-branch/libsyncml/objects/sml_ds_server.h (modified) (3 diffs)
- branches/dev-branch/libsyncml/objects/sml_ds_server_internals.h (modified) (1 diff)
- branches/dev-branch/libsyncml/parser/sml_xml_assm.c (modified) (7 diffs)
- branches/dev-branch/libsyncml/parser/sml_xml_parse.c (modified) (5 diffs)
- branches/dev-branch/libsyncml/sml_command.c (modified) (14 diffs)
- branches/dev-branch/libsyncml/sml_command.h (modified) (1 diff)
- branches/dev-branch/libsyncml/sml_command_internals.h (modified) (2 diffs)
- branches/dev-branch/libsyncml/sml_defines.h (modified) (2 diffs)
- branches/dev-branch/libsyncml/sml_devinf.c (modified) (3 diffs)
- branches/dev-branch/libsyncml/sml_elements.c (modified) (1 diff)
- branches/dev-branch/libsyncml/sml_elements_internals.h (modified) (1 diff)
- branches/dev-branch/libsyncml/sml_notification.c (modified) (6 diffs)
- branches/dev-branch/libsyncml/sml_notification.h (modified) (2 diffs)
- branches/dev-branch/libsyncml/sml_notification_internals.h (modified) (1 diff)
- branches/dev-branch/libsyncml/sml_session.c (modified) (8 diffs)
- branches/dev-branch/tests/check_ds.c (modified) (31 diffs)
- branches/dev-branch/tests/check_manager.c (modified) (1 diff)
- branches/dev-branch/tests/check_san.c (modified) (5 diffs)
- branches/dev-branch/tests/check_session.c (modified) (43 diffs)
- branches/dev-branch/tests/check_sync.c (modified) (8 diffs)
- branches/dev-branch/tests/check_wbxml_assembler.c (modified) (21 diffs)
- branches/dev-branch/tests/check_xml_assembler.c (modified) (23 diffs)
- branches/dev-branch/tests/check_xml_parser.c (modified) (2 diffs)
- branches/dev-branch/tests/valgrind.supp (modified) (1 diff)
- branches/dev-branch/tools/syncml-http-server.c (modified) (13 diffs)
- branches/dev-branch/tools/syncml-obex-client.c (modified) (16 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/dev-branch/libsyncml/objects/sml_ds_server.c
r152 r166 171 171 /*@{*/ 172 172 173 SmlDsServer *smlDsServerNew( SmlContentTypetype, SmlLocation *location, SmlError **error)174 { 175 smlTrace(TRACE_ENTRY, "%s(% i, %p, %p)", __func__, type, location, error);173 SmlDsServer *smlDsServerNew(const char *type, SmlLocation *location, SmlError **error) 174 { 175 smlTrace(TRACE_ENTRY, "%s(%s, %p, %p)", __func__, type, location, error); 176 176 smlAssert(location); 177 177 … … 183 183 smlLocationRef(location); 184 184 185 server->contenttype = type;185 server->contenttype = g_strdup(type); 186 186 server->servertype = SML_DS_SERVER; 187 187 … … 194 194 } 195 195 196 SmlDsServer *smlDsClientNew( SmlContentTypetype, SmlLocation *location, SmlLocation *target, SmlError **error)197 { 198 smlTrace(TRACE_ENTRY, "%s(% i, %p, %p, %p)", __func__, type, location, target, error);196 SmlDsServer *smlDsClientNew(const char *type, SmlLocation *location, SmlLocation *target, SmlError **error) 197 { 198 smlTrace(TRACE_ENTRY, "%s(%s, %p, %p, %p)", __func__, type, location, target, error); 199 199 smlAssert(location); 200 200 smlAssert(target); … … 210 210 smlLocationRef(target); 211 211 212 server->contenttype = type;212 server->contenttype = g_strdup(type); 213 213 server->servertype = SML_DS_CLIENT; 214 214 … … 231 231 if (server->target) 232 232 smlLocationUnref(server->target); 233 234 if (server->contenttype) 235 g_free(server->contenttype); 233 236 234 237 g_free(server); … … 265 268 } 266 269 267 SmlContentTypesmlDsServerGetContentType(SmlDsServer *server)270 const char *smlDsServerGetContentType(SmlDsServer *server) 268 271 { 269 272 smlAssert(server); … … 756 759 smlAssert(dsession); 757 760 758 SmlCommand *alert = smlCommandNewAlert(type, dsession->target, dsession->location, next, last, SML_CONTENT_TYPE_UNKNOWN, error);761 SmlCommand *alert = smlCommandNewAlert(type, dsession->target, dsession->location, next, last, NULL, error); 759 762 if (!alert) 760 763 goto error; … … 858 861 859 862 //Send a change to the remote side 860 SmlBool smlDsSessionQueueChange(SmlDsSession *dsession, SmlChangeType type, const char *uid, const char *data, unsigned int size, SmlContentTypecontenttype, SmlDsSessionWriteCb callback, void *userdata, SmlError **error)861 { 862 smlTrace(TRACE_ENTRY, "%s(%p, %i, %s, %p, %i, % i, %p, %p, %p)", __func__, dsession, type, uid, data, size, contenttype, callback, userdata, error);863 SmlBool smlDsSessionQueueChange(SmlDsSession *dsession, SmlChangeType type, const char *uid, const char *data, unsigned int size, const char *contenttype, SmlDsSessionWriteCb callback, void *userdata, SmlError **error) 864 { 865 smlTrace(TRACE_ENTRY, "%s(%p, %i, %s, %p, %i, %s, %p, %p, %p)", __func__, dsession, type, uid, data, size, contenttype, callback, userdata, error); 863 866 smlAssert(dsession); 864 867 … … 1010 1013 } 1011 1014 1012 SmlContentTypesmlDsSessionGetContentType(SmlDsSession *dsession)1015 const char *smlDsSessionGetContentType(SmlDsSession *dsession) 1013 1016 { 1014 1017 smlAssert(dsession); branches/dev-branch/libsyncml/objects/sml_ds_server.h
r127 r166 34 34 typedef SmlBool (* SmlDsSessionAlertCb) (SmlDsSession *dsession, SmlAlertType type, const char *last, const char *next, void *userdata); 35 35 typedef void (* SmlDsSessionSyncCb) (SmlDsSession *dsession, unsigned int numchanges, void *userdata); 36 typedef SmlBool (* SmlDsSessionChangesCb) (SmlDsSession *dsession, SmlChangeType type, const char *uid, char *data, unsigned int size, SmlContentTypecontenttype, void *userdata, SmlError **error);36 typedef SmlBool (* SmlDsSessionChangesCb) (SmlDsSession *dsession, SmlChangeType type, const char *uid, char *data, unsigned int size, const char *contenttype, void *userdata, SmlError **error); 37 37 typedef void (* SmlDsSessionWriteCb) (SmlDsSession *dsession, SmlStatus *status, const char *newuid, void *userdata); 38 38 39 SmlDsServer *smlDsServerNew( SmlContentTypetype, SmlLocation *location, SmlError **error);40 SmlDsServer *smlDsClientNew( SmlContentTypetype, SmlLocation *location, SmlLocation *target, SmlError **error);39 SmlDsServer *smlDsServerNew(const char *type, SmlLocation *location, SmlError **error); 40 SmlDsServer *smlDsClientNew(const char *type, SmlLocation *location, SmlLocation *target, SmlError **error); 41 41 void smlDsServerFree(SmlDsServer *server); 42 42 SmlBool smlDsServerRegister(SmlDsServer *server, SmlManager *manager, SmlError **error); … … 45 45 void smlDsServerSetConnectCallback(SmlDsServer *server, SmlDsSessionConnectCb callback, void *userdata); 46 46 const char *smlDsServerGetLocation(SmlDsServer *server); 47 SmlContentTypesmlDsServerGetContentType(SmlDsServer *server);47 const char *smlDsServerGetContentType(SmlDsServer *server); 48 48 SmlDsSession *smlDsServerSendAlert(SmlDsServer *server, SmlSession *session, SmlAlertType type, const char *last, const char *next, SmlStatusReplyCb callback, void *userdata, SmlError **error); 49 49 … … 57 57 void smlDsSessionGetSync(SmlDsSession *dsession, SmlDsSessionSyncCb chgCallback, void *userdata); 58 58 SmlBool smlDsSessionSendSync(SmlDsSession *dsession, unsigned int num_changes, SmlStatusReplyCb callback, void *userdata, SmlError **error); 59 SmlBool smlDsSessionQueueChange(SmlDsSession *dsession, SmlChangeType type, const char *uid, const char *data, unsigned int size, SmlContentTypecontenttype, SmlDsSessionWriteCb callback, void *userdata, SmlError **error);59 SmlBool smlDsSessionQueueChange(SmlDsSession *dsession, SmlChangeType type, const char *uid, const char *data, unsigned int size, const char *contenttype, SmlDsSessionWriteCb callback, void *userdata, SmlError **error); 60 60 SmlBool smlDsSessionCloseSync(SmlDsSession *dsession, SmlError **error); 61 61 SmlBool smlDsSessionQueueMap(SmlDsSession *dsession, const char *uid, const char *newuid, SmlError **error); 62 62 SmlBool smlDsSessionCloseMap(SmlDsSession *dsession, SmlStatusReplyCb callback, void *userdata, SmlError **error); 63 63 const char *smlDsSessionGetLocation(SmlDsSession *dsession); 64 SmlContentTypesmlDsSessionGetContentType(SmlDsSession *dsession);64 const char *smlDsSessionGetContentType(SmlDsSession *dsession); 65 65 SmlDsServer *smlDsSessionGetServer(SmlDsSession *dsession); 66 66 branches/dev-branch/libsyncml/objects/sml_ds_server_internals.h
r127 r166 81 81 /** The target if the ds server is in client mode */ 82 82 SmlLocation *target; 83 SmlContentTypecontenttype;83 char *contenttype; 84 84 SmlDsServerType servertype; 85 85 SmlManager *manager; branches/dev-branch/libsyncml/parser/sml_xml_assm.c
r162 r166 91 91 else 92 92 rc = xmlTextWriterWriteFormatCDATA(assm->writer, "%*s", size, (xmlChar *)value); 93 93 94 if (rc < 0) { 94 95 smlErrorSet(error, SML_ERROR_GENERIC, "Unable to add data"); … … 339 340 goto error; 340 341 341 const char *contenttype = smlContentTypeToString(change->private.access.item->contenttype, error); 342 if (!contenttype) 343 goto error; 344 345 if (!_smlXmlAssemblerAddStringNS(assm, SML_ELEMENT_TYPE, SML_NAMESPACE_METINF, contenttype, error)) 342 if (!_smlXmlAssemblerAddStringNS(assm, SML_ELEMENT_TYPE, SML_NAMESPACE_METINF, change->private.access.item->contenttype, error)) 346 343 goto error; 347 344 … … 381 378 goto error; 382 379 383 const char *contenttype = smlContentTypeToString(change->private.change.item->contenttype, error); 384 if (!contenttype) 385 goto error; 386 387 if (!_smlXmlAssemblerAddStringNS(assm, SML_ELEMENT_TYPE, SML_NAMESPACE_METINF, contenttype, error)) 380 if (!_smlXmlAssemblerAddStringNS(assm, SML_ELEMENT_TYPE, SML_NAMESPACE_METINF, change->private.change.item->contenttype, error)) 388 381 goto error; 389 382 … … 416 409 SmlBool smlSyncAssemble(SmlXmlAssembler *assm, SmlCommand *cmd, SmlError **error) 417 410 { 418 smlTrace(TRACE_ENTRY, "%s(%p, %p, %p , %p)", __func__, assm, cmd, error);411 smlTrace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, assm, cmd, error); 419 412 smlAssert(cmd); 420 413 smlAssert(assm); … … 566 559 } 567 560 568 if (cmd->private.alert.contentType != SML_CONTENT_TYPE_UNKNOWN) {561 if (cmd->private.alert.contentType) { 569 562 if (!_smlXmlAssemblerStartNode(assm, SML_ELEMENT_META, error)) 570 563 goto error; 571 572 const char *contenttype = smlContentTypeToString(cmd->private.alert.contentType, error);573 if (!contenttype)574 goto error;575 564 576 if (!_smlXmlAssemblerAddStringNS(assm, SML_ELEMENT_TYPE, SML_NAMESPACE_METINF, c ontenttype, error))565 if (!_smlXmlAssemblerAddStringNS(assm, SML_ELEMENT_TYPE, SML_NAMESPACE_METINF, cmd->private.alert.contentType, error)) 577 566 goto error; 578 567 … … 608 597 if (!_smlXmlAssemblerStartNode(assm, SML_ELEMENT_META, error)) 609 598 goto error; 610 611 const char *contenttype = smlContentTypeToString(cmd->private.results.status->item->contenttype, error); 612 if (!contenttype) 613 goto error; 614 615 if (!_smlXmlAssemblerAddStringNS(assm, SML_ELEMENT_TYPE, SML_NAMESPACE_METINF, contenttype, error)) 599 600 if (!_smlXmlAssemblerAddStringNS(assm, SML_ELEMENT_TYPE, SML_NAMESPACE_METINF, cmd->private.results.status->item->contenttype, error)) 616 601 goto error; 617 602 … … 1475 1460 SmlXmlAssemblerStatus *status = b->data; 1476 1461 if (!status->buffer) { 1462 if (status->cmdRef == 0 && check) { 1463 smlErrorSet(error, SML_ERROR_GENERIC, "Reserved status 0 has not been added"); 1464 goto error_free_writer; 1465 } 1477 1466 smlTrace(TRACE_INTERNAL, "Reserved status %i is missing", status->cmdRef); 1478 1467 missingstatus = TRUE; branches/dev-branch/libsyncml/parser/sml_xml_parse.c
r164 r166 593 593 /* Some phones send the type information for the devinf put 594 594 * not in the put itself but in the item */ 595 char *contentType = NULL; 596 597 if (!_smlCommandMetaParse(parser, NULL, &contentType, NULL, NULL, error)) 595 if (!_smlCommandMetaParse(parser, NULL, &(item->contenttype), NULL, NULL, error)) 598 596 goto error_free_item; 599 600 if (contentType) { 601 item->contenttype = smlContentTypeFromString(contentType, error); 602 if (!item->contenttype) 603 goto error_free_item; 604 } 597 598 if (!item->contenttype) 599 goto error_free_item; 605 600 break; 606 601 default: … … 811 806 } 812 807 813 if (contenttype) { 814 (*cmd)->private.change.item->contenttype = smlContentTypeFromString(contenttype, error); 815 if (!(*cmd)->private.change.item->contenttype) 816 goto error_free_cmd; 817 } 818 808 (*cmd)->private.change.item->contenttype = contenttype; 809 contenttype = NULL; 810 819 811 if ((*cmd)->size) 820 812 (*cmd)->private.change.item->size = (*cmd)->size; … … 852 844 goto error_free_cmd; 853 845 } 854 855 if (contenttype)856 g_free(contenttype);857 846 858 847 smlTrace(TRACE_EXIT, "%s: %p", __func__, *cmd); … … 1218 1207 /* We only use the content type of the put command if the item itself did not have 1219 1208 * a content type set */ 1220 if ((*cmd)->private.access.item->contenttype == SML_CONTENT_TYPE_UNKNOWN) { 1221 (*cmd)->private.access.item->contenttype = smlContentTypeFromString(contenttype, error); 1222 if (smlErrorIsSet(error)) 1223 goto error_free_cmd; 1224 } 1209 if (!(*cmd)->private.access.item->contenttype && contenttype) 1210 (*cmd)->private.access.item->contenttype = g_strdup(contenttype); 1225 1211 1226 1212 if (contenttype) … … 1335 1321 /* We only use the content type of the put command if the item itself did not have 1336 1322 * a content type set */ 1337 if ( (*cmd)->private.results.status->item->contenttype == SML_CONTENT_TYPE_UNKNOWN) {1323 if (!(*cmd)->private.results.status->item->contenttype) { 1338 1324 if (!contenttype) { 1339 smlErrorSet(error, SML_ERROR_GENERIC, " Put is missing content type");1325 smlErrorSet(error, SML_ERROR_GENERIC, "Result is missing content type"); 1340 1326 goto error_free_cmd; 1341 1327 } 1342 1328 1343 (*cmd)->private.results.status->item->contenttype = smlContentTypeFromString(contenttype, error); 1344 if (!(*cmd)->private.results.status->item->contenttype) 1345 goto error_free_cmd; 1329 (*cmd)->private.results.status->item->contenttype = g_strdup(contenttype); 1346 1330 } 1347 1331 branches/dev-branch/libsyncml/sml_command.c
r163 r166 34 34 */ 35 35 /*@{*/ 36 37 38 SmlContentType smlContentTypeFromString(const char *name, SmlError **error)39 {40 if (!name)41 return SML_CONTENT_TYPE_UNKNOWN;42 43 if (!strcmp(name, SML_ELEMENT_TEXT_VCARD))44 return SML_CONTENT_TYPE_VCARD;45 else if (!strcmp(name, SML_ELEMENT_TEXT_VCAL))46 return SML_CONTENT_TYPE_VCAL;47 else if (!strcmp(name, SML_ELEMENT_DEVINF_XML))48 return SML_CONTENT_TYPE_DEVINF_XML;49 else if (!strcmp(name, SML_ELEMENT_TEXT_PLAIN))50 return SML_CONTENT_TYPE_PLAIN;51 52 smlErrorSet(error, SML_ERROR_GENERIC, "Unknown content type \"%s\"", name);53 return SML_CONTENT_TYPE_UNKNOWN;54 }55 56 const char *smlContentTypeToString(SmlContentType type, SmlError **error)57 {58 switch (type) {59 case SML_CONTENT_TYPE_VCARD:60 return SML_ELEMENT_TEXT_VCARD;61 case SML_CONTENT_TYPE_VCAL:62 return SML_ELEMENT_TEXT_VCAL;63 case SML_CONTENT_TYPE_DEVINF_XML:64 return SML_ELEMENT_DEVINF_XML;65 case SML_CONTENT_TYPE_PLAIN:66 return SML_ELEMENT_TEXT_PLAIN;67 default:68 ;69 }70 71 smlErrorSet(error, SML_ERROR_GENERIC, "Unknown content type \"%i\"", type);72 return NULL;73 }74 36 75 37 SmlCommandType smlCommandTypeFromString(const char *name, SmlError **error) … … 286 248 } 287 249 288 SmlCommand *smlCommandNewResult(SmlCommand *cmd, SmlLocation *source, char *data, unsigned int size, SmlContentTypecontenttype, SmlError **error)289 { 290 smlTrace(TRACE_ENTRY, "%s(%p, %p, %p, %i, % i, %p)", __func__, cmd, source, data, size, contenttype, error);250 SmlCommand *smlCommandNewResult(SmlCommand *cmd, SmlLocation *source, char *data, unsigned int size, const char *contenttype, SmlError **error) 251 { 252 smlTrace(TRACE_ENTRY, "%s(%p, %p, %p, %i, %s, %p)", __func__, cmd, source, data, size, contenttype, error); 291 253 smlAssert(cmd); 292 254 … … 303 265 goto error_free_cmd; 304 266 305 result->private.results.status->item->contenttype = contenttype;267 result->private.results.status->item->contenttype = g_strdup(contenttype); 306 268 result->private.results.status->item->source = smlLocationClone(source, error); 307 269 … … 385 347 if (cmd->source) 386 348 smlLocationUnref(cmd->source); 387 349 388 350 g_free(cmd); 389 351 } … … 392 354 } 393 355 394 SmlCommand *smlCommandNewChange(SmlChangeType type, const char *uid, const char *data, unsigned int size, SmlContentTypecontenttype, SmlError **error)395 { 396 smlTrace(TRACE_ENTRY, "%s(%i, %s, %p, %i, % i, %p)", __func__, type, uid, data, size, contenttype, error);356 SmlCommand *smlCommandNewChange(SmlChangeType type, const char *uid, const char *data, unsigned int size, const char *contenttype, SmlError **error) 357 { 358 smlTrace(TRACE_ENTRY, "%s(%i, %s, %p, %i, %s, %p)", __func__, type, uid, data, size, contenttype, error); 397 359 SmlCommand *cmd = NULL; 398 360 … … 426 388 cmd->private.change.item->source = loc; 427 389 428 cmd->private.change.item->contenttype = contenttype;390 cmd->private.change.item->contenttype = g_strdup(contenttype); 429 391 430 392 smlTrace(TRACE_EXIT, "%s: %p", __func__, cmd); … … 445 407 * @param partial_size The size of this part. 446 408 */ 447 SmlCommand *smlCommandNewPartialChange(SmlChangeType type, const char *uid, const char *data, unsigned int complete_size, unsigned int partial_size, SmlContentTypecontenttype, SmlError **error)448 { 449 smlTrace(TRACE_ENTRY, "%s(%i, %s, %p, %i, %i, % i, %p)", __func__, type, uid, data, complete_size, partial_size, contenttype, error);409 SmlCommand *smlCommandNewPartialChange(SmlChangeType type, const char *uid, const char *data, unsigned int complete_size, unsigned int partial_size, const char *contenttype, SmlError **error) 410 { 411 smlTrace(TRACE_ENTRY, "%s(%i, %s, %p, %i, %i, %s, %p)", __func__, type, uid, data, complete_size, partial_size, contenttype, error); 450 412 SmlCommand *cmd = NULL; 451 413 … … 481 443 482 444 cmd->private.change.item->moreData = TRUE; 483 cmd->private.change.item->contenttype = contenttype;445 cmd->private.change.item->contenttype = g_strdup(contenttype); 484 446 485 447 smlTrace(TRACE_EXIT, "%s: %p", __func__, cmd); … … 495 457 } 496 458 497 SmlCommand *smlCommandNewAlert(SmlAlertType type, SmlLocation *target, SmlLocation *source, const char *next, const char *last, SmlContentTypecontenttype, SmlError **error)498 { 499 smlTrace(TRACE_ENTRY, "%s(%i, %p, %p, %s, %s, % i, %p)", __func__, type, target, source, next, last, contenttype, error);459 SmlCommand *smlCommandNewAlert(SmlAlertType type, SmlLocation *target, SmlLocation *source, const char *next, const char *last, const char *contenttype, SmlError **error) 460 { 461 smlTrace(TRACE_ENTRY, "%s(%i, %p, %p, %s, %s, %s, %p)", __func__, type, target, source, next, last, contenttype, error); 500 462 501 463 SmlCommand *cmd = smlCommandNew(SML_COMMAND_TYPE_ALERT, error); … … 519 481 } 520 482 cmd->private.alert.type = type; 521 cmd->private.alert.contentType = contenttype;483 cmd->private.alert.contentType = g_strdup(contenttype); 522 484 523 485 smlTrace(TRACE_EXIT, "%s: %p", __func__, cmd); … … 552 514 } 553 515 554 SmlCommand *smlCommandNewPut(SmlLocation *target, SmlLocation *source, const char *data, unsigned int size, SmlContentTypecontenttype, SmlError **error)555 { 556 smlTrace(TRACE_ENTRY, "%s(%p, %p, %p, %i, % i, %p)", __func__, target, source, data, size, contenttype, error);516 SmlCommand *smlCommandNewPut(SmlLocation *target, SmlLocation *source, const char *data, unsigned int size, const char *contenttype, SmlError **error) 517 { 518 smlTrace(TRACE_ENTRY, "%s(%p, %p, %p, %i, %s, %p)", __func__, target, source, data, size, contenttype, error); 557 519 558 520 SmlCommand *cmd = smlCommandNew(SML_COMMAND_TYPE_PUT, error); … … 576 538 } 577 539 578 cmd->private.access.item->contenttype = contenttype;540 cmd->private.access.item->contenttype = g_strdup(contenttype); 579 541 580 542 smlTrace(TRACE_EXIT, "%s: %p", __func__, cmd); … … 588 550 } 589 551 590 SmlCommand *smlCommandNewGet(SmlLocation *target, SmlContentTypecontenttype, SmlError **error)591 { 592 smlTrace(TRACE_ENTRY, "%s(%p, % i, %p)", __func__, target, contenttype, error);552 SmlCommand *smlCommandNewGet(SmlLocation *target, const char *contenttype, SmlError **error) 553 { 554 smlTrace(TRACE_ENTRY, "%s(%p, %s, %p)", __func__, target, contenttype, error); 593 555 smlAssert(target); 594 556 … … 605 567 smlItemSetTarget(cmd->private.access.item, cmd->target); 606 568 607 cmd->private.access.item->contenttype = contenttype;569 cmd->private.access.item->contenttype = g_strdup(contenttype); 608 570 609 571 smlTrace(TRACE_EXIT, "%s: %p", __func__, cmd); branches/dev-branch/libsyncml/sml_command.h
r160 r166 35 35 void smlCommandUnref(SmlCommand *cmd); 36 36 37 SmlCommand *smlCommandNewAlert(SmlAlertType type, SmlLocation *target, SmlLocation *source, const char *next, const char *last, SmlContentTypecontenttype, SmlError **error);37 SmlCommand *smlCommandNewAlert(SmlAlertType type, SmlLocation *target, SmlLocation *source, const char *next, const char *last, const char *contenttype, SmlError **error); 38 38 SmlCommand *smlCommandNewSync(SmlLocation *target, SmlLocation *source, unsigned int num_changes, SmlError **error); 39 SmlCommand *smlCommandNewChange(SmlChangeType type, const char *uid, const char *data, unsigned int size, SmlContentTypecontenttype, SmlError **error);40 SmlCommand *smlCommandNewPartialChange(SmlChangeType type, const char *uid, const char *data, unsigned int complete_size, unsigned int partial_size, SmlContentTypecontenttype, SmlError **error);41 SmlCommand *smlCommandNewResult(SmlCommand *cmd, SmlLocation *source, char *data, unsigned int size, SmlContentTypecontenttype, SmlError **error);42 SmlCommand *smlCommandNewPut(SmlLocation *target, SmlLocation *source, const char *data, unsigned int size, SmlContentTypecontenttype, SmlError **error);43 SmlCommand *smlCommandNewGet(SmlLocation *target, SmlContentTypecontenttype, SmlError **error);39 SmlCommand *smlCommandNewChange(SmlChangeType type, const char *uid, const char *data, unsigned int size, const char *contenttype, SmlError **error); 40 SmlCommand *smlCommandNewPartialChange(SmlChangeType type, const char *uid, const char *data, unsigned int complete_size, unsigned int partial_size, const char *contenttype, SmlError **error); 41 SmlCommand *smlCommandNewResult(SmlCommand *cmd, SmlLocation *source, char *data, unsigned int size, const char *contenttype, SmlError **error); 42 SmlCommand *smlCommandNewPut(SmlLocation *target, SmlLocation *source, const char *data, unsigned int size, const char *contenttype, SmlError **error); 43 SmlCommand *smlCommandNewGet(SmlLocation *target, const char *contenttype, SmlError **error); 44 44 45 45 SmlCommand *smlCommandNewMap(SmlLocation *target, SmlLocation *source, SmlError **error); branches/dev-branch/libsyncml/sml_command_internals.h
r160 r166 25 25 SmlAlertType type; 26 26 SmlAnchor *anchor; 27 SmlContentTypecontentType;27 char *contentType; 28 28 } SmlCommandAlertPrivate; 29 29 … … 99 99 const char *smlCommandTypeToString(SmlCommandType type, SmlError **error); 100 100 101 SmlContentType smlContentTypeFromString(const char *name, SmlError **error);102 const char *smlContentTypeToString(SmlContentType type, SmlError **error);103 104 101 #endif //_SML_COMMAND_INTERNALS_H_ branches/dev-branch/libsyncml/sml_defines.h
r164 r166 161 161 #define SML_ELEMENT_TEXT_VCAL "text/x-vcalendar" 162 162 #define SML_ELEMENT_TEXT_PLAIN "text/plain" 163 #define SML_ELEMENT_TEXT_MESSAGE "text/x-vMessage" 163 164 164 165 #define SML_ELEMENT_DEVINF_XML "application/vnd.syncml-devinf+xml" … … 261 262 262 263 typedef enum { 263 SML_CONTENT_TYPE_UNKNOWN = 0,264 SML_CONTENT_TYPE_VCARD = 1,265 SML_CONTENT_TYPE_VCAL = 2,266 SML_CONTENT_TYPE_VTODO = 3,267 SML_CONTENT_TYPE_PLAIN= 4,268 SML_CONTENT_TYPE_DEVINF_XML = 5269 } SmlContentType;270 271 typedef enum {272 264 SML_AUTH_TYPE_UNKNOWN = 0, 273 265 SML_AUTH_TYPE_BASIC = 1, branches/dev-branch/libsyncml/sml_devinf.c
r160 r166 532 532 goto error_free_data; 533 533 534 SmlCommand *result = smlCommandNewResult(cmd, source, data, size, SML_ CONTENT_TYPE_DEVINF_XML, error);534 SmlCommand *result = smlCommandNewResult(cmd, source, data, size, SML_ELEMENT_DEVINF_XML, error); 535 535 if (!result) { 536 536 smlLocationUnref(source); … … 564 564 goto error; 565 565 566 SmlCommand *cmd = smlCommandNewPut(NULL, source, NULL, 0, SML_ CONTENT_TYPE_DEVINF_XML, error);566 SmlCommand *cmd = smlCommandNewPut(NULL, source, NULL, 0, SML_ELEMENT_DEVINF_XML, error); 567 567 if (!cmd) 568 568 goto error_free_source; … … 605 605 goto error; 606 606 607 SmlCommand *cmd = smlCommandNewGet(target, SML_ CONTENT_TYPE_DEVINF_XML, error);607 SmlCommand *cmd = smlCommandNewGet(target, SML_ELEMENT_DEVINF_XML, error); 608 608 if (!cmd) 609 609 goto error_free_target; branches/dev-branch/libsyncml/sml_elements.c
r152 r166 370 370 xmlBufferFree(item->buffer); 371 371 372 if (item->contenttype) 373 g_free(item->contenttype); 374 372 375 g_free(item); 373 376 item = NULL; branches/dev-branch/libsyncml/sml_elements_internals.h
r127 r166 46 46 unsigned int size; 47 47 48 SmlContentTypecontenttype;48 char *contenttype; 49 49 SmlBool moreData; 50 50 branches/dev-branch/libsyncml/sml_notification.c
r127 r166 91 91 } 92 92 93 SmlBool smlNotificationNewAlert(SmlNotification *san, SmlAlertType type, SmlContentTypecontenttype, const char *serverURI, SmlError **error)93 SmlBool smlNotificationNewAlert(SmlNotification *san, SmlAlertType type, const char *contenttype, const char *serverURI, SmlError **error) 94 94 { 95 95 smlTrace(TRACE_ENTRY, "%s(%p)", __func__, error); … … 101 101 102 102 alert->type = type; 103 alert->contenttype = contenttype;103 alert->contenttype = g_strdup(contenttype); 104 104 alert->serverURI = g_strdup(serverURI); 105 105 … … 119 119 smlAssert(alert); 120 120 121 g_free(alert->contenttype); 121 122 g_free(alert->serverURI); 122 123 g_free(alert); … … 215 216 switch (contenttype) { 216 217 case 0x07: 217 alert->contenttype = SML_CONTENT_TYPE_VCARD;218 alert->contenttype = g_strdup(SML_ELEMENT_TEXT_VCARD); 218 219 break; 219 220 default: … … 407 408 408 409 /* The contenttype */ 409 switch (alert->contenttype) { 410 case SML_CONTENT_TYPE_VCARD: 411 buffer[3] = 0x07; 412 break; 413 case SML_CONTENT_TYPE_VCAL: 414 buffer[3] = 0x06; 415 break; 416 case SML_CONTENT_TYPE_VTODO: 417 buffer[3] = 0x06; 418 break; 419 default: 420 smlErrorSet(error, SML_ERROR_GENERIC, "Unknown content type"); 421 goto error_free_data; 410 if (!strcmp(alert->contenttype, SML_ELEMENT_TEXT_VCARD)) 411 buffer[3] = 0x07; 412 else if (!strcmp(alert->contenttype, SML_ELEMENT_TEXT_VCAL)) 413 buffer[3] = 0x06; 414 else { 415 smlErrorSet(error, SML_ERROR_GENERIC, "Unknown content type"); 416 goto error_free_data; 422 417 } 423 418 … … 544 539 } 545 540 546 SmlContentTypesmlSanAlertGetContentType(SmlSanAlert *alert)541 const char *smlSanAlertGetContentType(SmlSanAlert *alert) 547 542 { 548 543 smlAssert(alert); branches/dev-branch/libsyncml/sml_notification.h
r101 r166 47 47 SmlBool smlNotificationSend(SmlNotification *san, SmlTransport *tsp, SmlError **error); 48 48 49 SmlBool smlNotificationNewAlert(SmlNotification *san, SmlAlertType type, SmlContentTypecontenttype, const char *serverURI, SmlError **error);49 SmlBool smlNotificationNewAlert(SmlNotification *san, SmlAlertType type, const char *contenttype, const char *serverURI, SmlError **error); 50 50 void smlNotificationFreeAlert(SmlSanAlert *alert); 51 51 … … 59 59 60 60 SmlAlertType smlSanAlertGetType(SmlSanAlert *alert); 61 SmlContentTypesmlSanAlertGetContentType(SmlSanAlert *alert);61 const char *smlSanAlertGetContentType(SmlSanAlert *alert); 62 62 const char *smlSanAlertGetServerURI(SmlSanAlert *alert); 63 63 branches/dev-branch/libsyncml/sml_notification_internals.h
r101 r166 34 34 struct SmlSanAlert { 35 35 SmlAlertType type; 36 SmlContentTypecontenttype;36 char *contenttype; 37 37 char *serverURI; 38 38 }; branches/dev-branch/libsyncml/sml_session.c
r160 r166 212 212 smlLocationRef(frag_cmd->private.change.item->source); 213 213 214 frag_cmd->private.change.item->contenttype = orig_cmd->private.change.item->contenttype;214 frag_cmd->private.change.item->contenttype = g_strdup(orig_cmd->private.change.item->contenttype); 215 215 216 216 if (start == 0) … … 226 226 if (!orig_cmd->private.change.item) 227 227 goto error; 228 orig_cmd->private.change.item->contenttype = orig_item->contenttype;228 orig_cmd->private.change.item->contenttype = g_strdup(orig_item->contenttype); 229 229 230 230 orig_cmd->private.change.item->target = orig_item->target; … … 347 347 case SML_ASSEMBLER_RESULT_OK: 348 348 /* We successfully added the command */ 349 cmd->pushedBack = FALSE; 349 350 break; 350 351 case SML_ASSEMBLER_RESULT_MISMATCH: … … 501 502 } 502 503 break; 503 /*case SML_SESSION_RESULT:504 if (!status->pendingReply) {505 pending = smlTryMalloc0(sizeof(SmlPendingStatus), &error);506 if (!pending)507 goto error;508 509 pending->callback = sesscmd->callback;510 pending->userdata = sesscmd->callbackUserdata;511 pending->cmdID = session->lastCommandID;512 pending->msgID = session->lastMessageID;513 514 status->pendingReply = pending;515 session->pendingReplies = g_list_append(session->pendingReplies, pending);516 517 smlTrace(TRACE_INTERNAL, "Appending pending result status with cmdID %i and msgID %i", status->pendingReply->cmdID, status->pendingReply->msgID);518 }519 status->cmdID = session->lastCommandID;520 521 session->lastCommandID++;522 523 switch (smlAssemblerAddStatus(session->assembler, status, &error)) {524 case SML_ASSEMBLER_RESULT_OK:525 break;526 case SML_ASSEMBLER_RESULT_MISMATCH:527 if (!_smlSessionFlushInternal(session, FALSE, &error)) {528 session->lastCommandID--;529 goto error;530 }531 532 smlQueuePushHead(session->command_queue, message);533 return;534 break;535 case SML_ASSEMBLER_RESULT_ERROR:536 goto error;537 }538 break;*/539 504 case SML_SESSION_STATUS:; 540 505 unsigned int cmdRef, msgRef = 0; … … 623 588 SmlBool smlSessionDispatchStatus(SmlSession *session, SmlStatus *status, SmlError **error) 624 589 { 625 smlTrace(TRACE_ENTRY, "%s(%p, %p, %p , %p)", __func__, session, status, error);590 smlTrace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, session, status, error); 626 591 smlAssert(status); 627 592 … … 910 875 session->waiting = FALSE; 911 876 877 /* We have to wait at this point until no status are pending anymore 878 * if we have a incoming buffer. if there is a incoming buffer for large objs open, 879 * the other side expects to see the status for the open buffer of course. so we have to 880 * wait here for all open statuses, since they have to be added in the correct order and 881 * the status for the open buffer is obviously last */ 912 882 if (session->incomingBuffer || session->noPendingReplies) { 913 883 while (1) { … … 920 890 int i = 0; 921 891 unsigned int num = smlQueueLengthPrio(session->command_queue); 922 smlTrace(TRACE_INTERNAL, "Now dispatching %i statuses2", num);923 892 while (!session->waiting && smlQueueCheckPrio(session->command_queue) && i < num) { 924 893 smlSessionDispatch(session); … … 964 933 if (smlAssemblerIsEmpty(session->assembler)) { 965 934 /* The assembler is empty so we need to add an alert */ 966 SmlCommand *alert = smlCommandNewAlert(SML_ALERT_NEXT_MESSAGE, session->target, session->source, NULL, NULL, SML_CONTENT_TYPE_UNKNOWN, error);935 SmlCommand *alert = smlCommandNewAlert(SML_ALERT_NEXT_MESSAGE, session->target, session->source, NULL, NULL, NULL, error); 967 936 if (!alert) 968 937 goto error_free_cmd;
