Changeset 163

Show
Ignore:
Timestamp:
05/18/06 16:36:45 (3 years ago)
Author:
abauer
Message:

Added warning events besides error events

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/dev-branch/libsyncml/parser/sml_xml_parse.c

    r162 r163  
    12061206         
    12071207        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"); 
    12091209                goto error_free_cmd; 
    12101210        } 
     
    12131213         * a content type set */ 
    12141214        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                  
    12201215                (*cmd)->private.access.item->contenttype = smlContentTypeFromString(contenttype, error); 
    1221                 if (!(*cmd)->private.access.item->contenttype
     1216                if (smlErrorIsSet(error)
    12221217                        goto error_free_cmd; 
    12231218        } 
  • branches/dev-branch/libsyncml/sml_command.c

    r160 r163  
    3838SmlContentType smlContentTypeFromString(const char *name, SmlError **error) 
    3939{ 
     40        if (!name) 
     41                return SML_CONTENT_TYPE_UNKNOWN; 
     42         
    4043        if (!strcmp(name, SML_ELEMENT_TEXT_VCARD)) 
    4144                return SML_CONTENT_TYPE_VCARD; 
     
    7275SmlCommandType smlCommandTypeFromString(const char *name, SmlError **error) 
    7376{ 
     77        if (!name) 
     78                return SML_COMMAND_TYPE_UNKNOWN; 
     79         
    7480        if (!strcmp(name, SML_ELEMENT_ALERT)) { 
    7581                return SML_COMMAND_TYPE_ALERT; 
  • branches/dev-branch/libsyncml/sml_manager.c

    r160 r163  
    472472                        break; 
    473473                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); 
    475476                                goto error; 
     477                        } 
    476478                        break; 
    477479                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); 
    479482                                goto error; 
     483                        } 
    480484                        break; 
    481485                case SML_SESSION_EVENT_FINAL: 
     
    494498                        /* Pass the error through */ 
    495499                        smlErrorDuplicate(&locerror, &error); 
     500                        _smlManagerSendEvent(manager, SML_MANAGER_SESSION_ERROR, session, NULL, NULL, locerror); 
    496501                        goto error; 
    497502                        break; 
     
    502507                 
    503508error: 
    504         _smlManagerSendEvent(manager, SML_MANAGER_SESSION_ERROR, session, NULL, NULL, locerror); 
    505509        smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(&locerror)); 
    506510        smlErrorDeref(&locerror); 
     
    850854                object->commandCallback(session, cmd, object->commandCallbackUserdata); 
    851855        } else { 
    852                 smlErrorSet(error, SML_ERROR_GENERIC, "Unable to find command handler"); 
     856                smlErrorSet(error, SML_ERROR_NOT_FOUND, "Unable to find command handler"); 
    853857                 
    854858                SmlStatus *reply = smlCommandNewReply(cmd, SML_ERROR_NOT_FOUND, error); 
  • branches/dev-branch/libsyncml/sml_manager.h

    r127 r163  
    3030        SML_MANAGER_SESSION_END, 
    3131        SML_MANAGER_SESSION_FLUSH, 
     32        SML_MANAGER_SESSION_WARNING, 
    3233        SML_MANAGER_SESSION_ERROR 
    3334} SmlManagerEventType; 
  • branches/dev-branch/tests/check_devinf.c

    r160 r163  
    7070                        break; 
    7171                case SML_MANAGER_SESSION_ERROR: 
     72                case SML_MANAGER_SESSION_WARNING: 
    7273                        session_errors++; 
    7374                        break; 
  • branches/dev-branch/tests/check_manager.c

    r127 r163  
    115115                        break; 
    116116                case SML_MANAGER_SESSION_ERROR: 
     117                case SML_MANAGER_SESSION_WARNING: 
    117118                        session_errors++; 
    118119                        break; 
  • branches/dev-branch/tests/check_sync.c

    r152 r163  
    8686                        break; 
    8787                case SML_MANAGER_SESSION_ERROR: 
     88                case SML_MANAGER_SESSION_WARNING: 
    8889                        session_errors++; 
    8990                        break; 
  • branches/dev-branch/tools/syncml-http-server.c

    r160 r163  
    6363        fprintf (stderr, "[--allowLateStatus]\t\t\tAllows that a phone can send commands before statuses (Needed for some phones)\n\n"); 
    6464        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"); 
    6667        fprintf (stderr, "Example: %s --port 9999 --sync vcal /events --sync vcard /addressbook --multi --san\n", name); 
    6768        exit (ecode); 
     
    226227SmlBool lateStatus = FALSE; 
    227228SmlBool noPending = FALSE; 
     229SmlBool dumpinfo = FALSE; 
     230SmlProtocolVersion sessionVersion = SML_VERSION_UNKNOWN; 
     231SmlDevInf *deviceDevinf = NULL; 
     232 
    228233 
    229234static void _manager_event(SmlManager *manager, SmlManagerEventType type, SmlSession *session, SmlError *error, void *userdata) 
    230235{ 
    231236        smlTrace(TRACE_ENTRY, "%s(%p, %i, %p, %p, %p)", __func__, manager, type, session, error, userdata); 
    232         SmlDevInf *devinf = NULL; 
     237        SmlError *locerror = NULL; 
    233238         
    234239        switch (type) { 
     
    240245                        break; 
    241246                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); 
    243250                        break; 
    244251                case SML_MANAGER_SESSION_NEW: 
    245252                        printf("Just received a new session with ID %s\n", smlSessionGetSessionID(session)); 
     253                        sessionVersion = smlSessionGetVersion(session); 
    246254                         
    247255                        if (recvLimit) 
     
    258266                        break; 
    259267                case SML_MANAGER_SESSION_FINAL: 
    260                         if ((devinf = smlDevInfAgentGetDevInf(agent))) 
     268                        if (!deviceDevinf && (deviceDevinf = smlDevInfAgentGetDevInf(agent))) 
    261269                                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                        } 
    262278                         
    263279                        printf("Session %s reported final. flushing\n", smlSessionGetSessionID(session)); 
     
    271287                        } 
    272288                        break; 
     289                case SML_MANAGER_SESSION_WARNING: 
     290                        printf("WARNING: %s", smlErrorPrint(&error)); 
     291                        break; 
    273292                case SML_MANAGER_SESSION_ERROR: 
    274293                        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 
     302error: 
     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); 
    279308} 
    280309 
     
    336365        config.url = NULL; 
    337366        config.interface = NULL; 
     367         
     368        char *contactDB = NULL; 
     369        char *eventDB = NULL; 
     370        char *todoDB = NULL; 
     371        char *noteDB = NULL; 
    338372         
    339373        SmlError *error = NULL; 
     
    373407                } else if (!strcmp (arg, "--noPendingReplies")) { 
    374408                        noPending = TRUE; 
     409                } else if (!strcmp (arg, "--dumpinfo")) { 
     410                        dumpinfo = TRUE; 
    375411                } else if (!strcmp (arg, "--help")) { 
    376412                        usage (argv[0], 0); 
     
    426462                         
    427463                        SmlContentType type = SML_CONTENT_TYPE_UNKNOWN; 
    428                         if (!strcmp(argv[i], "vcal")) 
     464                        if (!strcmp(argv[i], "vcal")) { 
    429465                                type = SML_CONTENT_TYPE_VCAL; 
    430                         else if (!strcmp(argv[i], "vcard")) 
     466                                eventDB = argv[i]; 
     467                        } else if (!strcmp(argv[i], "vcard")) { 
    431468                                type = SML_CONTENT_TYPE_VCARD; 
    432                         else if (!strcmp(argv[i], "vtodo")) 
     469                                contactDB = argv[i]; 
     470                        }else if (!strcmp(argv[i], "vtodo")) { 
    433471                                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                        } 
    434477                         
    435478                        if (type == SML_CONTENT_TYPE_UNKNOWN) 
     
    543586        smlTransportFree(client); 
    544587         
     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         
    545616        return 0; 
    546617 
  • branches/dev-branch/tools/syncml-obex-client.c

    r162 r163  
    311311                        g_main_loop_quit(loop); 
    312312                        break; 
     313                case SML_MANAGER_SESSION_WARNING: 
     314                        printf("WARNING: %s", smlErrorPrint(&error)); 
     315                        break; 
    313316                case SML_MANAGER_SESSION_FLUSH: 
    314317                        break; 
     
    429432        char *noteDB = NULL; 
    430433         
    431         SmlMimeType type = SML_MIMETYPE_XML; 
     434        SmlMimeType mimeType = SML_MIMETYPE_XML; 
    432435         
    433436        SmlError *error = NULL; 
     
    520523                        usage (argv[0], 0); 
    521524                } else if (!strcmp (arg, "--wbxml")) { 
    522                         type = SML_MIMETYPE_WBXML; 
     525                        mimeType = SML_MIMETYPE_WBXML; 
    523526                } else if (!strcmp (arg, "--dumpinfo")) { 
    524527                        dumpinfo = TRUE; 
     
    569572                identifier = g_strdup("LibSyncML Test Suite"); 
    570573                 
    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); 
    572575        if (!san) 
    573576                goto error; 
     
    751754                        printf("\n"); 
    752755                        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"); 
    754757                        printf("SyncML Version: 1.%i\n", sessionVersion - 1); 
    755758                        printf("SupportsNumberofChanges: %s\n", smlDevInfSupportsNumberOfChanges(deviceDevinf) ? "Yes" : "No");