Changeset 163
- Timestamp:
- 05/18/06 16:36:45 (3 years ago)
- Files:
-
- branches/dev-branch/libsyncml/parser/sml_xml_parse.c (modified) (2 diffs)
- branches/dev-branch/libsyncml/sml_command.c (modified) (2 diffs)
- branches/dev-branch/libsyncml/sml_manager.c (modified) (4 diffs)
- branches/dev-branch/libsyncml/sml_manager.h (modified) (1 diff)
- branches/dev-branch/tests/check_devinf.c (modified) (1 diff)
- branches/dev-branch/tests/check_manager.c (modified) (1 diff)
- branches/dev-branch/tests/check_sync.c (modified) (1 diff)
- branches/dev-branch/tools/syncml-http-server.c (modified) (9 diffs)
- branches/dev-branch/tools/syncml-obex-client.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/dev-branch/libsyncml/parser/sml_xml_parse.c
r162 r163 1206 1206 1207 1207 if (!(*cmd)->private.access.item) { 1208 smlErrorSet(error, SML_ERROR_GENERIC, "Put is missing item");1208 smlErrorSet(error, SML_ERROR_GENERIC, "Put/Get is missing item"); 1209 1209 goto error_free_cmd; 1210 1210 } … … 1213 1213 * a content type set */ 1214 1214 if ((*cmd)->private.access.item->contenttype == SML_CONTENT_TYPE_UNKNOWN) { 1215 if (!contenttype) {1216 smlErrorSet(error, SML_ERROR_GENERIC, "Put is missing content type");1217 goto error_free_cmd;1218 }1219 1220 1215 (*cmd)->private.access.item->contenttype = smlContentTypeFromString(contenttype, error); 1221 if ( !(*cmd)->private.access.item->contenttype)1216 if (smlErrorIsSet(error)) 1222 1217 goto error_free_cmd; 1223 1218 } branches/dev-branch/libsyncml/sml_command.c
r160 r163 38 38 SmlContentType smlContentTypeFromString(const char *name, SmlError **error) 39 39 { 40 if (!name) 41 return SML_CONTENT_TYPE_UNKNOWN; 42 40 43 if (!strcmp(name, SML_ELEMENT_TEXT_VCARD)) 41 44 return SML_CONTENT_TYPE_VCARD; … … 72 75 SmlCommandType smlCommandTypeFromString(const char *name, SmlError **error) 73 76 { 77 if (!name) 78 return SML_COMMAND_TYPE_UNKNOWN; 79 74 80 if (!strcmp(name, SML_ELEMENT_ALERT)) { 75 81 return SML_COMMAND_TYPE_ALERT; branches/dev-branch/libsyncml/sml_manager.c
r160 r163 472 472 break; 473 473 case SML_SESSION_EVENT_CHILD_COMMAND: 474 if (!smlManagerDispatchChildCommand(manager, session, parent, command, &locerror)) 474 if (!smlManagerDispatchChildCommand(manager, session, parent, command, &locerror)) { 475 _smlManagerSendEvent(manager, SML_MANAGER_SESSION_WARNING, session, NULL, NULL, locerror); 475 476 goto error; 477 } 476 478 break; 477 479 case SML_SESSION_EVENT_COMMAND: 478 if (!smlManagerDispatchCommand(manager, session, command, &locerror)) 480 if (!smlManagerDispatchCommand(manager, session, command, &locerror)) { 481 _smlManagerSendEvent(manager, SML_MANAGER_SESSION_WARNING, session, NULL, NULL, locerror); 479 482 goto error; 483 } 480 484 break; 481 485 case SML_SESSION_EVENT_FINAL: … … 494 498 /* Pass the error through */ 495 499 smlErrorDuplicate(&locerror, &error); 500 _smlManagerSendEvent(manager, SML_MANAGER_SESSION_ERROR, session, NULL, NULL, locerror); 496 501 goto error; 497 502 break; … … 502 507 503 508 error: 504 _smlManagerSendEvent(manager, SML_MANAGER_SESSION_ERROR, session, NULL, NULL, locerror);505 509 smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(&locerror)); 506 510 smlErrorDeref(&locerror); … … 850 854 object->commandCallback(session, cmd, object->commandCallbackUserdata); 851 855 } else { 852 smlErrorSet(error, SML_ERROR_ GENERIC, "Unable to find command handler");856 smlErrorSet(error, SML_ERROR_NOT_FOUND, "Unable to find command handler"); 853 857 854 858 SmlStatus *reply = smlCommandNewReply(cmd, SML_ERROR_NOT_FOUND, error); branches/dev-branch/libsyncml/sml_manager.h
r127 r163 30 30 SML_MANAGER_SESSION_END, 31 31 SML_MANAGER_SESSION_FLUSH, 32 SML_MANAGER_SESSION_WARNING, 32 33 SML_MANAGER_SESSION_ERROR 33 34 } SmlManagerEventType; branches/dev-branch/tests/check_devinf.c
r160 r163 70 70 break; 71 71 case SML_MANAGER_SESSION_ERROR: 72 case SML_MANAGER_SESSION_WARNING: 72 73 session_errors++; 73 74 break; branches/dev-branch/tests/check_manager.c
r127 r163 115 115 break; 116 116 case SML_MANAGER_SESSION_ERROR: 117 case SML_MANAGER_SESSION_WARNING: 117 118 session_errors++; 118 119 break; branches/dev-branch/tests/check_sync.c
r152 r163 86 86 break; 87 87 case SML_MANAGER_SESSION_ERROR: 88 case SML_MANAGER_SESSION_WARNING: 88 89 session_errors++; 89 90 break; branches/dev-branch/tools/syncml-http-server.c
r160 r163 63 63 fprintf (stderr, "[--allowLateStatus]\t\t\tAllows that a phone can send commands before statuses (Needed for some phones)\n\n"); 64 64 fprintf (stderr, "[--maxObjSize <limit>]\t\t\tThe maximum size of a object that we can receive (Needed for some phones)\n\n"); 65 fprintf (stderr, "[--noPendingReplies]\t\t\tRequire that no pending replies are allowed (Needed for some phones)\n"); 65 fprintf (stderr, "[--noPendingReplies]\t\t\tRequire that no pending replies are allowed (Needed for some phones)\n\n"); 66 fprintf (stderr, "[--dumpinfo]\t\t\tPrint info about the phone at the end which can be sent to the developers\n"); 66 67 fprintf (stderr, "Example: %s --port 9999 --sync vcal /events --sync vcard /addressbook --multi --san\n", name); 67 68 exit (ecode); … … 226 227 SmlBool lateStatus = FALSE; 227 228 SmlBool noPending = FALSE; 229 SmlBool dumpinfo = FALSE; 230 SmlProtocolVersion sessionVersion = SML_VERSION_UNKNOWN; 231 SmlDevInf *deviceDevinf = NULL; 232 228 233 229 234 static void _manager_event(SmlManager *manager, SmlManagerEventType type, SmlSession *session, SmlError *error, void *userdata) 230 235 { 231 236 smlTrace(TRACE_ENTRY, "%s(%p, %i, %p, %p, %p)", __func__, manager, type, session, error, userdata); 232 Sml DevInf *devinf= NULL;237 SmlError *locerror = NULL; 233 238 234 239 switch (type) { … … 240 245 break; 241 246 case SML_MANAGER_TRANSPORT_ERROR: 242 printf("Received an transport error\n"); 247 printf("Received an transport error: %s\n", smlErrorPrint(&error)); 248 smlManagerQuit(manager); 249 g_main_loop_quit(loop); 243 250 break; 244 251 case SML_MANAGER_SESSION_NEW: 245 252 printf("Just received a new session with ID %s\n", smlSessionGetSessionID(session)); 253 sessionVersion = smlSessionGetVersion(session); 246 254 247 255 if (recvLimit) … … 258 266 break; 259 267 case SML_MANAGER_SESSION_FINAL: 260 if ( (devinf = smlDevInfAgentGetDevInf(agent)))268 if (!deviceDevinf && (deviceDevinf = smlDevInfAgentGetDevInf(agent))) 261 269 printf("Received the DevInf\n"); 270 271 /* We want to know about the device so we check if we received 272 * the devinf already */ 273 if (dumpinfo && !deviceDevinf) { 274 printf("Going to request the devinf\n"); 275 if (!smlDevInfAgentRequestDevInf(agent, session, &locerror)) 276 goto error; 277 } 262 278 263 279 printf("Session %s reported final. flushing\n", smlSessionGetSessionID(session)); … … 271 287 } 272 288 break; 289 case SML_MANAGER_SESSION_WARNING: 290 printf("WARNING: %s", smlErrorPrint(&error)); 291 break; 273 292 case SML_MANAGER_SESSION_ERROR: 274 293 printf("There was an error in the session %s: %s", smlSessionGetSessionID(session), smlErrorPrint(&error)); 275 break; 276 } 277 278 smlTrace(TRACE_EXIT, "%s", __func__); 294 smlManagerQuit(manager); 295 g_main_loop_quit(loop); 296 break; 297 } 298 299 smlTrace(TRACE_EXIT, "%s", __func__); 300 return; 301 302 error: 303 printf("An error occured while handling events: %s\n", smlErrorPrint(&locerror)); 304 smlManagerQuit(manager); 305 g_main_loop_quit(loop); 306 smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(&locerror)); 307 smlErrorDeref(&locerror); 279 308 } 280 309 … … 336 365 config.url = NULL; 337 366 config.interface = NULL; 367 368 char *contactDB = NULL; 369 char *eventDB = NULL; 370 char *todoDB = NULL; 371 char *noteDB = NULL; 338 372 339 373 SmlError *error = NULL; … … 373 407 } else if (!strcmp (arg, "--noPendingReplies")) { 374 408 noPending = TRUE; 409 } else if (!strcmp (arg, "--dumpinfo")) { 410 dumpinfo = TRUE; 375 411 } else if (!strcmp (arg, "--help")) { 376 412 usage (argv[0], 0); … … 426 462 427 463 SmlContentType type = SML_CONTENT_TYPE_UNKNOWN; 428 if (!strcmp(argv[i], "vcal")) 464 if (!strcmp(argv[i], "vcal")) { 429 465 type = SML_CONTENT_TYPE_VCAL; 430 else if (!strcmp(argv[i], "vcard")) 466 eventDB = argv[i]; 467 } else if (!strcmp(argv[i], "vcard")) { 431 468 type = SML_CONTENT_TYPE_VCARD; 432 else if (!strcmp(argv[i], "vtodo")) 469 contactDB = argv[i]; 470 }else if (!strcmp(argv[i], "vtodo")) { 433 471 type = SML_CONTENT_TYPE_VTODO; 472 todoDB = argv[i]; 473 } else if (!strcmp(argv[i], "note")) { 474 type = SML_CONTENT_TYPE_PLAIN; 475 noteDB = argv[i]; 476 } 434 477 435 478 if (type == SML_CONTENT_TYPE_UNKNOWN) … … 543 586 smlTransportFree(client); 544 587 588 if (dumpinfo) { 589 if (!deviceDevinf) { 590 printf("Didnt receive the devinf though it was requested\n"); 591 } else { 592 printf("Send the output below to the libsyncml developers\n"); 593 printf("\n========================================\n"); 594 printf("Man: %s\n", smlDevInfGetManufacturer(deviceDevinf)); 595 printf("Mod: %s\n", smlDevInfGetModel(deviceDevinf)); 596 printf("FirmwareVersion: %s\n", smlDevInfGetFirmwareVersion(deviceDevinf)); 597 printf("SoftwareVersion: %s\n", smlDevInfGetSoftwareVersion(deviceDevinf)); 598 printf("HardwareVersion: %s\n", smlDevInfGetHardwareVersion(deviceDevinf)); 599 printf("\n"); 600 printf("ReceiveLimit: %i\n", recvLimit); 601 printf("MaxObjSize: %i\n", maxObjSize); 602 printf("AllowLateStatus: %s\n", lateStatus ? "yes" : "no"); 603 printf("NoPendingReplies: %s\n", noPending ? "yes" : "no"); 604 printf("Connection used: Obex\n"); 605 printf("Contact DB: %s\n", contactDB); 606 printf("Event DB: %s\n", eventDB); 607 printf("Todo DB: %s\n", todoDB); 608 printf("Note DB: %s\n", noteDB); 609 printf("\n"); 610 printf("SyncML Version: 1.%i\n", sessionVersion - 1); 611 printf("SupportsNumberofChanges: %s\n", smlDevInfSupportsNumberOfChanges(deviceDevinf) ? "Yes" : "No"); 612 printf("SupportsLargeObjects: %s\n", smlDevInfSupportsLargeObjs(deviceDevinf) ? "Yes" : "No"); 613 } 614 } 615 545 616 return 0; 546 617 branches/dev-branch/tools/syncml-obex-client.c
r162 r163 311 311 g_main_loop_quit(loop); 312 312 break; 313 case SML_MANAGER_SESSION_WARNING: 314 printf("WARNING: %s", smlErrorPrint(&error)); 315 break; 313 316 case SML_MANAGER_SESSION_FLUSH: 314 317 break; … … 429 432 char *noteDB = NULL; 430 433 431 SmlMimeType type = SML_MIMETYPE_XML;434 SmlMimeType mimeType = SML_MIMETYPE_XML; 432 435 433 436 SmlError *error = NULL; … … 520 523 usage (argv[0], 0); 521 524 } else if (!strcmp (arg, "--wbxml")) { 522 type = SML_MIMETYPE_WBXML;525 mimeType = SML_MIMETYPE_WBXML; 523 526 } else if (!strcmp (arg, "--dumpinfo")) { 524 527 dumpinfo = TRUE; … … 569 572 identifier = g_strdup("LibSyncML Test Suite"); 570 573 571 SmlNotification *san = smlNotificationNew(sanVersion, SML_SAN_UIMODE_UNSPECIFIED, SML_SAN_INITIATOR_USER, 1, identifier, type, &error);574 SmlNotification *san = smlNotificationNew(sanVersion, SML_SAN_UIMODE_UNSPECIFIED, SML_SAN_INITIATOR_USER, 1, identifier, mimeType, &error); 572 575 if (!san) 573 576 goto error; … … 751 754 printf("\n"); 752 755 printf("Bluetooth: %s\n", config.type == SML_OBEX_TYPE_BLUETOOTH ? "Yes" : "Unknown"); 753 printf("Wbxml: %s\n", type == SML_MIMETYPE_WBXML ? "Yes" : "No");756 printf("Wbxml: %s\n", mimeType == SML_MIMETYPE_WBXML ? "Yes" : "No"); 754 757 printf("SyncML Version: 1.%i\n", sessionVersion - 1); 755 758 printf("SupportsNumberofChanges: %s\n", smlDevInfSupportsNumberOfChanges(deviceDevinf) ? "Yes" : "No");
