Changeset 166

Show
Ignore:
Timestamp:
05/21/06 13:14:08 (3 years ago)
Author:
abauer
Message:

Fixed some bugs in the unit tests

Added support for text based mimetypes

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/dev-branch/libsyncml/objects/sml_ds_server.c

    r152 r166  
    171171/*@{*/ 
    172172 
    173 SmlDsServer *smlDsServerNew(SmlContentType type, SmlLocation *location, SmlError **error) 
    174 { 
    175         smlTrace(TRACE_ENTRY, "%s(%i, %p, %p)", __func__, type, location, error); 
     173SmlDsServer *smlDsServerNew(const char *type, SmlLocation *location, SmlError **error) 
     174{ 
     175        smlTrace(TRACE_ENTRY, "%s(%s, %p, %p)", __func__, type, location, error); 
    176176        smlAssert(location); 
    177177         
     
    183183        smlLocationRef(location); 
    184184 
    185         server->contenttype = type
     185        server->contenttype = g_strdup(type)
    186186        server->servertype = SML_DS_SERVER; 
    187187         
     
    194194} 
    195195 
    196 SmlDsServer *smlDsClientNew(SmlContentType type, SmlLocation *location, SmlLocation *target, SmlError **error) 
    197 { 
    198         smlTrace(TRACE_ENTRY, "%s(%i, %p, %p, %p)", __func__, type, location, target, error); 
     196SmlDsServer *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); 
    199199        smlAssert(location); 
    200200        smlAssert(target); 
     
    210210        smlLocationRef(target); 
    211211 
    212         server->contenttype = type
     212        server->contenttype = g_strdup(type)
    213213        server->servertype = SML_DS_CLIENT; 
    214214         
     
    231231        if (server->target) 
    232232                smlLocationUnref(server->target); 
     233         
     234        if (server->contenttype) 
     235                g_free(server->contenttype); 
    233236         
    234237        g_free(server); 
     
    265268} 
    266269 
    267 SmlContentType smlDsServerGetContentType(SmlDsServer *server) 
     270const char *smlDsServerGetContentType(SmlDsServer *server) 
    268271{ 
    269272        smlAssert(server); 
     
    756759        smlAssert(dsession); 
    757760         
    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); 
    759762        if (!alert) 
    760763                goto error; 
     
    858861 
    859862//Send a change to the remote side 
    860 SmlBool smlDsSessionQueueChange(SmlDsSession *dsession, SmlChangeType type, const char *uid, const char *data, unsigned int size, SmlContentType contenttype, 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); 
     863SmlBool 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); 
    863866        smlAssert(dsession); 
    864867         
     
    10101013} 
    10111014 
    1012 SmlContentType smlDsSessionGetContentType(SmlDsSession *dsession) 
     1015const char *smlDsSessionGetContentType(SmlDsSession *dsession) 
    10131016{ 
    10141017        smlAssert(dsession); 
  • branches/dev-branch/libsyncml/objects/sml_ds_server.h

    r127 r166  
    3434typedef SmlBool (* SmlDsSessionAlertCb) (SmlDsSession *dsession, SmlAlertType type, const char *last, const char *next, void *userdata); 
    3535typedef 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, SmlContentType contenttype, void *userdata, SmlError **error); 
     36typedef SmlBool (* SmlDsSessionChangesCb) (SmlDsSession *dsession, SmlChangeType type, const char *uid, char *data, unsigned int size, const char *contenttype, void *userdata, SmlError **error); 
    3737typedef void (* SmlDsSessionWriteCb) (SmlDsSession *dsession, SmlStatus *status, const char *newuid, void *userdata); 
    3838 
    39 SmlDsServer *smlDsServerNew(SmlContentType type, SmlLocation *location, SmlError **error); 
    40 SmlDsServer *smlDsClientNew(SmlContentType type, SmlLocation *location, SmlLocation *target, SmlError **error); 
     39SmlDsServer *smlDsServerNew(const char *type, SmlLocation *location, SmlError **error); 
     40SmlDsServer *smlDsClientNew(const char *type, SmlLocation *location, SmlLocation *target, SmlError **error); 
    4141void smlDsServerFree(SmlDsServer *server); 
    4242SmlBool smlDsServerRegister(SmlDsServer *server, SmlManager *manager, SmlError **error); 
     
    4545void smlDsServerSetConnectCallback(SmlDsServer *server, SmlDsSessionConnectCb callback, void *userdata); 
    4646const char *smlDsServerGetLocation(SmlDsServer *server); 
    47 SmlContentType smlDsServerGetContentType(SmlDsServer *server); 
     47const char *smlDsServerGetContentType(SmlDsServer *server); 
    4848SmlDsSession *smlDsServerSendAlert(SmlDsServer *server, SmlSession *session, SmlAlertType type, const char *last, const char *next, SmlStatusReplyCb callback, void *userdata, SmlError **error); 
    4949 
     
    5757void smlDsSessionGetSync(SmlDsSession *dsession, SmlDsSessionSyncCb chgCallback, void *userdata); 
    5858SmlBool 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, SmlContentType contenttype, SmlDsSessionWriteCb callback, void *userdata, SmlError **error); 
     59SmlBool smlDsSessionQueueChange(SmlDsSession *dsession, SmlChangeType type, const char *uid, const char *data, unsigned int size, const char *contenttype, SmlDsSessionWriteCb callback, void *userdata, SmlError **error); 
    6060SmlBool smlDsSessionCloseSync(SmlDsSession *dsession, SmlError **error); 
    6161SmlBool smlDsSessionQueueMap(SmlDsSession *dsession, const char *uid, const char *newuid, SmlError **error); 
    6262SmlBool smlDsSessionCloseMap(SmlDsSession *dsession, SmlStatusReplyCb callback, void *userdata, SmlError **error); 
    6363const char *smlDsSessionGetLocation(SmlDsSession *dsession); 
    64 SmlContentType smlDsSessionGetContentType(SmlDsSession *dsession); 
     64const char *smlDsSessionGetContentType(SmlDsSession *dsession); 
    6565SmlDsServer *smlDsSessionGetServer(SmlDsSession *dsession); 
    6666 
  • branches/dev-branch/libsyncml/objects/sml_ds_server_internals.h

    r127 r166  
    8181        /** The target if the ds server is in client mode */ 
    8282        SmlLocation *target; 
    83         SmlContentType contenttype; 
     83        char *contenttype; 
    8484        SmlDsServerType servertype; 
    8585        SmlManager *manager; 
  • branches/dev-branch/libsyncml/parser/sml_xml_assm.c

    r162 r166  
    9191        else 
    9292                rc = xmlTextWriterWriteFormatCDATA(assm->writer, "%*s", size, (xmlChar *)value); 
     93                 
    9394        if (rc < 0) { 
    9495                smlErrorSet(error, SML_ERROR_GENERIC, "Unable to add data"); 
     
    339340                goto error; 
    340341         
    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)) 
    346343                goto error; 
    347344         
     
    381378                goto error; 
    382379         
    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)) 
    388381                goto error; 
    389382         
     
    416409SmlBool smlSyncAssemble(SmlXmlAssembler *assm, SmlCommand *cmd, SmlError **error) 
    417410{ 
    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); 
    419412        smlAssert(cmd); 
    420413        smlAssert(assm); 
     
    566559        } 
    567560         
    568         if (cmd->private.alert.contentType != SML_CONTENT_TYPE_UNKNOWN) { 
     561        if (cmd->private.alert.contentType) { 
    569562                if (!_smlXmlAssemblerStartNode(assm, SML_ELEMENT_META, error)) 
    570563                        goto error; 
    571                  
    572                 const char *contenttype = smlContentTypeToString(cmd->private.alert.contentType, error); 
    573                 if (!contenttype) 
    574                         goto error; 
    575564                         
    576                 if (!_smlXmlAssemblerAddStringNS(assm, SML_ELEMENT_TYPE, SML_NAMESPACE_METINF, contenttype, error)) 
     565                if (!_smlXmlAssemblerAddStringNS(assm, SML_ELEMENT_TYPE, SML_NAMESPACE_METINF, cmd->private.alert.contentType, error)) 
    577566                        goto error; 
    578567                 
     
    608597        if (!_smlXmlAssemblerStartNode(assm, SML_ELEMENT_META, error)) 
    609598                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)) 
    616601                goto error; 
    617602         
     
    14751460                SmlXmlAssemblerStatus *status = b->data; 
    14761461                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                        } 
    14771466                        smlTrace(TRACE_INTERNAL, "Reserved status %i is missing", status->cmdRef); 
    14781467                        missingstatus = TRUE; 
  • branches/dev-branch/libsyncml/parser/sml_xml_parse.c

    r164 r166  
    593593                                        /* Some phones send the type information for the devinf put 
    594594                                         * 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)) 
    598596                                                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; 
    605600                                        break; 
    606601                                default: 
     
    811806        } 
    812807         
    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                                 
    819811        if ((*cmd)->size) 
    820812                (*cmd)->private.change.item->size = (*cmd)->size; 
     
    852844                goto error_free_cmd; 
    853845        } 
    854          
    855         if (contenttype) 
    856                 g_free(contenttype); 
    857846         
    858847        smlTrace(TRACE_EXIT, "%s: %p", __func__, *cmd); 
     
    12181207        /* We only use the content type of the put command if the item itself did not have 
    12191208         * 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); 
    12251211         
    12261212        if (contenttype) 
     
    13351321        /* We only use the content type of the put command if the item itself did not have 
    13361322         * a content type set */ 
    1337         if ((*cmd)->private.results.status->item->contenttype == SML_CONTENT_TYPE_UNKNOWN) { 
     1323        if (!(*cmd)->private.results.status->item->contenttype) { 
    13381324                if (!contenttype) { 
    1339                         smlErrorSet(error, SML_ERROR_GENERIC, "Put is missing content type"); 
     1325                        smlErrorSet(error, SML_ERROR_GENERIC, "Result is missing content type"); 
    13401326                        goto error_free_cmd; 
    13411327                } 
    13421328                 
    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); 
    13461330        } 
    13471331         
  • branches/dev-branch/libsyncml/sml_command.c

    r163 r166  
    3434 */ 
    3535/*@{*/ 
    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 } 
    7436 
    7537SmlCommandType smlCommandTypeFromString(const char *name, SmlError **error) 
     
    286248} 
    287249 
    288 SmlCommand *smlCommandNewResult(SmlCommand *cmd, SmlLocation *source, char *data, unsigned int size, SmlContentType contenttype, SmlError **error) 
    289 { 
    290         smlTrace(TRACE_ENTRY, "%s(%p, %p, %p, %i, %i, %p)", __func__, cmd, source, data, size, contenttype, error); 
     250SmlCommand *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); 
    291253        smlAssert(cmd); 
    292254         
     
    303265                goto error_free_cmd; 
    304266         
    305         result->private.results.status->item->contenttype = contenttype
     267        result->private.results.status->item->contenttype = g_strdup(contenttype)
    306268        result->private.results.status->item->source = smlLocationClone(source, error); 
    307269         
     
    385347                if (cmd->source) 
    386348                        smlLocationUnref(cmd->source); 
    387                         
     349                 
    388350                g_free(cmd); 
    389351        } 
     
    392354} 
    393355 
    394 SmlCommand *smlCommandNewChange(SmlChangeType type, const char *uid, const char *data, unsigned int size, SmlContentType contenttype, SmlError **error) 
    395 { 
    396         smlTrace(TRACE_ENTRY, "%s(%i, %s, %p, %i, %i, %p)", __func__, type, uid, data, size, contenttype, error); 
     356SmlCommand *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); 
    397359        SmlCommand *cmd = NULL; 
    398360         
     
    426388                cmd->private.change.item->source = loc; 
    427389         
    428         cmd->private.change.item->contenttype = contenttype
     390        cmd->private.change.item->contenttype = g_strdup(contenttype)
    429391         
    430392        smlTrace(TRACE_EXIT, "%s: %p", __func__, cmd); 
     
    445407 * @param partial_size The size of this part. 
    446408 */ 
    447 SmlCommand *smlCommandNewPartialChange(SmlChangeType type, const char *uid, const char *data, unsigned int complete_size, unsigned int partial_size, SmlContentType contenttype, 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); 
     409SmlCommand *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); 
    450412        SmlCommand *cmd = NULL; 
    451413         
     
    481443         
    482444        cmd->private.change.item->moreData = TRUE; 
    483         cmd->private.change.item->contenttype = contenttype
     445        cmd->private.change.item->contenttype = g_strdup(contenttype)
    484446         
    485447        smlTrace(TRACE_EXIT, "%s: %p", __func__, cmd); 
     
    495457} 
    496458 
    497 SmlCommand *smlCommandNewAlert(SmlAlertType type, SmlLocation *target, SmlLocation *source, const char *next, const char *last, SmlContentType contenttype, SmlError **error) 
    498 { 
    499         smlTrace(TRACE_ENTRY, "%s(%i, %p, %p, %s, %s, %i, %p)", __func__, type, target, source, next, last, contenttype, error); 
     459SmlCommand *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); 
    500462         
    501463        SmlCommand *cmd = smlCommandNew(SML_COMMAND_TYPE_ALERT, error); 
     
    519481        } 
    520482        cmd->private.alert.type = type; 
    521         cmd->private.alert.contentType = contenttype
     483        cmd->private.alert.contentType = g_strdup(contenttype)
    522484         
    523485        smlTrace(TRACE_EXIT, "%s: %p", __func__, cmd); 
     
    552514} 
    553515 
    554 SmlCommand *smlCommandNewPut(SmlLocation *target, SmlLocation *source, const char *data, unsigned int size, SmlContentType contenttype, SmlError **error) 
    555 { 
    556         smlTrace(TRACE_ENTRY, "%s(%p, %p, %p, %i, %i, %p)", __func__, target, source, data, size, contenttype, error); 
     516SmlCommand *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); 
    557519         
    558520        SmlCommand *cmd = smlCommandNew(SML_COMMAND_TYPE_PUT, error); 
     
    576538        } 
    577539         
    578         cmd->private.access.item->contenttype = contenttype
     540        cmd->private.access.item->contenttype = g_strdup(contenttype)
    579541         
    580542        smlTrace(TRACE_EXIT, "%s: %p", __func__, cmd); 
     
    588550} 
    589551 
    590 SmlCommand *smlCommandNewGet(SmlLocation *target, SmlContentType contenttype, SmlError **error) 
    591 { 
    592         smlTrace(TRACE_ENTRY, "%s(%p, %i, %p)", __func__, target, contenttype, error); 
     552SmlCommand *smlCommandNewGet(SmlLocation *target, const char *contenttype, SmlError **error) 
     553{ 
     554        smlTrace(TRACE_ENTRY, "%s(%p, %s, %p)", __func__, target, contenttype, error); 
    593555        smlAssert(target); 
    594556         
     
    605567        smlItemSetTarget(cmd->private.access.item, cmd->target); 
    606568         
    607         cmd->private.access.item->contenttype = contenttype
     569        cmd->private.access.item->contenttype = g_strdup(contenttype)
    608570         
    609571        smlTrace(TRACE_EXIT, "%s: %p", __func__, cmd); 
  • branches/dev-branch/libsyncml/sml_command.h

    r160 r166  
    3535void smlCommandUnref(SmlCommand *cmd); 
    3636 
    37 SmlCommand *smlCommandNewAlert(SmlAlertType type, SmlLocation *target, SmlLocation *source, const char *next, const char *last, SmlContentType contenttype, SmlError **error); 
     37SmlCommand *smlCommandNewAlert(SmlAlertType type, SmlLocation *target, SmlLocation *source, const char *next, const char *last, const char *contenttype, SmlError **error); 
    3838SmlCommand *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, SmlContentType contenttype, SmlError **error); 
    40 SmlCommand *smlCommandNewPartialChange(SmlChangeType type, const char *uid, const char *data, unsigned int complete_size, unsigned int partial_size, SmlContentType contenttype, SmlError **error); 
    41 SmlCommand *smlCommandNewResult(SmlCommand *cmd, SmlLocation *source, char *data, unsigned int size, SmlContentType contenttype, SmlError **error); 
    42 SmlCommand *smlCommandNewPut(SmlLocation *target, SmlLocation *source, const char *data, unsigned int size, SmlContentType contenttype, SmlError **error); 
    43 SmlCommand *smlCommandNewGet(SmlLocation *target, SmlContentType contenttype, SmlError **error); 
     39SmlCommand *smlCommandNewChange(SmlChangeType type, const char *uid, const char *data, unsigned int size, const char *contenttype, SmlError **error); 
     40SmlCommand *smlCommandNewPartialChange(SmlChangeType type, const char *uid, const char *data, unsigned int complete_size, unsigned int partial_size, const char *contenttype, SmlError **error); 
     41SmlCommand *smlCommandNewResult(SmlCommand *cmd, SmlLocation *source, char *data, unsigned int size, const char *contenttype, SmlError **error); 
     42SmlCommand *smlCommandNewPut(SmlLocation *target, SmlLocation *source, const char *data, unsigned int size, const char *contenttype, SmlError **error); 
     43SmlCommand *smlCommandNewGet(SmlLocation *target, const char *contenttype, SmlError **error); 
    4444 
    4545SmlCommand *smlCommandNewMap(SmlLocation *target, SmlLocation *source, SmlError **error); 
  • branches/dev-branch/libsyncml/sml_command_internals.h

    r160 r166  
    2525        SmlAlertType type; 
    2626        SmlAnchor *anchor; 
    27         SmlContentType contentType; 
     27        char *contentType; 
    2828} SmlCommandAlertPrivate; 
    2929 
     
    9999const char *smlCommandTypeToString(SmlCommandType type, SmlError **error); 
    100100 
    101 SmlContentType smlContentTypeFromString(const char *name, SmlError **error); 
    102 const char *smlContentTypeToString(SmlContentType type, SmlError **error); 
    103  
    104101#endif //_SML_COMMAND_INTERNALS_H_ 
  • branches/dev-branch/libsyncml/sml_defines.h

    r164 r166  
    161161#define SML_ELEMENT_TEXT_VCAL "text/x-vcalendar" 
    162162#define SML_ELEMENT_TEXT_PLAIN "text/plain" 
     163#define SML_ELEMENT_TEXT_MESSAGE "text/x-vMessage" 
    163164 
    164165#define SML_ELEMENT_DEVINF_XML "application/vnd.syncml-devinf+xml" 
     
    261262 
    262263typedef 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 = 5 
    269 } SmlContentType; 
    270  
    271 typedef enum { 
    272264        SML_AUTH_TYPE_UNKNOWN = 0, 
    273265        SML_AUTH_TYPE_BASIC = 1, 
  • branches/dev-branch/libsyncml/sml_devinf.c

    r160 r166  
    532532                goto error_free_data; 
    533533         
    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); 
    535535        if (!result) { 
    536536                smlLocationUnref(source); 
     
    564564                goto error; 
    565565                 
    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); 
    567567        if (!cmd) 
    568568                goto error_free_source; 
     
    605605                goto error; 
    606606                 
    607         SmlCommand *cmd = smlCommandNewGet(target, SML_CONTENT_TYPE_DEVINF_XML, error); 
     607        SmlCommand *cmd = smlCommandNewGet(target, SML_ELEMENT_DEVINF_XML, error); 
    608608        if (!cmd) 
    609609                goto error_free_target; 
  • branches/dev-branch/libsyncml/sml_elements.c

    r152 r166  
    370370                        xmlBufferFree(item->buffer); 
    371371                 
     372                if (item->contenttype) 
     373                        g_free(item->contenttype); 
     374                 
    372375                g_free(item); 
    373376                item = NULL; 
  • branches/dev-branch/libsyncml/sml_elements_internals.h

    r127 r166  
    4646        unsigned int size; 
    4747         
    48         SmlContentType contenttype; 
     48        char *contenttype; 
    4949        SmlBool moreData; 
    5050         
  • branches/dev-branch/libsyncml/sml_notification.c

    r127 r166  
    9191} 
    9292 
    93 SmlBool smlNotificationNewAlert(SmlNotification *san, SmlAlertType type, SmlContentType contenttype, const char *serverURI, SmlError **error) 
     93SmlBool smlNotificationNewAlert(SmlNotification *san, SmlAlertType type, const char *contenttype, const char *serverURI, SmlError **error) 
    9494{ 
    9595        smlTrace(TRACE_ENTRY, "%s(%p)", __func__, error); 
     
    101101 
    102102        alert->type = type; 
    103         alert->contenttype = contenttype
     103        alert->contenttype = g_strdup(contenttype)
    104104        alert->serverURI = g_strdup(serverURI); 
    105105 
     
    119119        smlAssert(alert); 
    120120         
     121        g_free(alert->contenttype); 
    121122        g_free(alert->serverURI); 
    122123        g_free(alert); 
     
    215216                switch (contenttype) { 
    216217                        case 0x07: 
    217                                 alert->contenttype = SML_CONTENT_TYPE_VCARD
     218                                alert->contenttype = g_strdup(SML_ELEMENT_TEXT_VCARD)
    218219                                break; 
    219220                        default: 
     
    407408                 
    408409                /* 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; 
    422417                } 
    423418                 
     
    544539} 
    545540 
    546 SmlContentType smlSanAlertGetContentType(SmlSanAlert *alert) 
     541const char *smlSanAlertGetContentType(SmlSanAlert *alert) 
    547542{ 
    548543        smlAssert(alert); 
  • branches/dev-branch/libsyncml/sml_notification.h

    r101 r166  
    4747SmlBool smlNotificationSend(SmlNotification *san, SmlTransport *tsp, SmlError **error); 
    4848 
    49 SmlBool smlNotificationNewAlert(SmlNotification *san, SmlAlertType type, SmlContentType contenttype, const char *serverURI, SmlError **error); 
     49SmlBool smlNotificationNewAlert(SmlNotification *san, SmlAlertType type, const char *contenttype, const char *serverURI, SmlError **error); 
    5050void smlNotificationFreeAlert(SmlSanAlert *alert); 
    5151 
     
    5959 
    6060SmlAlertType smlSanAlertGetType(SmlSanAlert *alert); 
    61 SmlContentType smlSanAlertGetContentType(SmlSanAlert *alert); 
     61const char *smlSanAlertGetContentType(SmlSanAlert *alert); 
    6262const char *smlSanAlertGetServerURI(SmlSanAlert *alert); 
    6363 
  • branches/dev-branch/libsyncml/sml_notification_internals.h

    r101 r166  
    3434struct SmlSanAlert { 
    3535        SmlAlertType type; 
    36         SmlContentType contenttype; 
     36        char *contenttype; 
    3737        char *serverURI; 
    3838}; 
  • branches/dev-branch/libsyncml/sml_session.c

    r160 r166  
    212212                        smlLocationRef(frag_cmd->private.change.item->source); 
    213213                 
    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)
    215215                 
    216216                if (start == 0) 
     
    226226                if (!orig_cmd->private.change.item) 
    227227                        goto error; 
    228                 orig_cmd->private.change.item->contenttype = orig_item->contenttype
     228                orig_cmd->private.change.item->contenttype = g_strdup(orig_item->contenttype)
    229229                 
    230230                orig_cmd->private.change.item->target = orig_item->target; 
     
    347347                case SML_ASSEMBLER_RESULT_OK: 
    348348                        /* We successfully added the command */ 
     349                        cmd->pushedBack = FALSE; 
    349350                        break; 
    350351                case SML_ASSEMBLER_RESULT_MISMATCH: 
     
    501502                        } 
    502503                        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;*/ 
    539504                case SML_SESSION_STATUS:; 
    540505                        unsigned int cmdRef, msgRef = 0; 
     
    623588SmlBool smlSessionDispatchStatus(SmlSession *session, SmlStatus *status, SmlError **error) 
    624589{ 
    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); 
    626591        smlAssert(status); 
    627592         
     
    910875        session->waiting = FALSE; 
    911876         
     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 */ 
    912882        if (session->incomingBuffer || session->noPendingReplies) { 
    913883                while (1) { 
     
    920890                        int i = 0; 
    921891                        unsigned int num = smlQueueLengthPrio(session->command_queue); 
    922                         smlTrace(TRACE_INTERNAL, "Now dispatching %i statuses2", num); 
    923892                        while (!session->waiting && smlQueueCheckPrio(session->command_queue) && i < num) { 
    924893                                smlSessionDispatch(session); 
     
    964933                if (smlAssemblerIsEmpty(session->assembler)) { 
    965934                        /* 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); 
    967936                        if (!alert) 
    968937                                goto error_free_cmd;