Changeset 170
- Timestamp:
- 05/24/06 16:46:47 (2 years ago)
- Files:
-
- branches/6230-branch/devices.txt (added)
- branches/6230-branch/libsyncml/objects/sml_auth.c (modified) (4 diffs)
- branches/6230-branch/libsyncml/objects/sml_devinf_obj.c (modified) (6 diffs)
- branches/6230-branch/libsyncml/objects/sml_devinf_obj.h (modified) (1 diff)
- branches/6230-branch/libsyncml/objects/sml_devinf_obj_internals.h (modified) (1 diff)
- branches/6230-branch/libsyncml/objects/sml_ds_server.c (modified) (9 diffs)
- branches/6230-branch/libsyncml/objects/sml_ds_server.h (modified) (3 diffs)
- branches/6230-branch/libsyncml/objects/sml_ds_server_internals.h (modified) (1 diff)
- branches/6230-branch/libsyncml/parser/sml_wbxml.c (modified) (2 diffs)
- branches/6230-branch/libsyncml/parser/sml_xml_assm.c (modified) (30 diffs)
- branches/6230-branch/libsyncml/parser/sml_xml_parse.c (modified) (15 diffs)
- branches/6230-branch/libsyncml/parser/sml_xml_parse.h (modified) (1 diff)
- branches/6230-branch/libsyncml/sml_command.c (modified) (15 diffs)
- branches/6230-branch/libsyncml/sml_command.h (modified) (2 diffs)
- branches/6230-branch/libsyncml/sml_command_internals.h (modified) (5 diffs)
- branches/6230-branch/libsyncml/sml_defines.h (modified) (3 diffs)
- branches/6230-branch/libsyncml/sml_devinf.c (modified) (7 diffs)
- branches/6230-branch/libsyncml/sml_devinf.h (modified) (2 diffs)
- branches/6230-branch/libsyncml/sml_devinf_internals.h (modified) (1 diff)
- branches/6230-branch/libsyncml/sml_elements.c (modified) (2 diffs)
- branches/6230-branch/libsyncml/sml_elements.h (modified) (1 diff)
- branches/6230-branch/libsyncml/sml_elements_internals.h (modified) (1 diff)
- branches/6230-branch/libsyncml/sml_manager.c (modified) (5 diffs)
- branches/6230-branch/libsyncml/sml_manager.h (modified) (1 diff)
- branches/6230-branch/libsyncml/sml_notification.c (modified) (6 diffs)
- branches/6230-branch/libsyncml/sml_notification.h (modified) (2 diffs)
- branches/6230-branch/libsyncml/sml_notification_internals.h (modified) (1 diff)
- branches/6230-branch/libsyncml/sml_parse.c (modified) (4 diffs)
- branches/6230-branch/libsyncml/sml_parse.h (modified) (1 diff)
- branches/6230-branch/libsyncml/sml_session.c (modified) (27 diffs)
- branches/6230-branch/libsyncml/sml_session.h (modified) (2 diffs)
- branches/6230-branch/libsyncml/sml_session_internals.h (modified) (2 diffs)
- branches/6230-branch/libsyncml/sml_support.c (modified) (1 diff)
- branches/6230-branch/libsyncml/transports/obex_client.c (modified) (2 diffs)
- branches/6230-branch/tests/check_devinf.c (modified) (2 diffs)
- branches/6230-branch/tests/check_ds.c (modified) (31 diffs)
- branches/6230-branch/tests/check_manager.c (modified) (2 diffs)
- branches/6230-branch/tests/check_obex.c (modified) (4 diffs)
- branches/6230-branch/tests/check_san.c (modified) (5 diffs)
- branches/6230-branch/tests/check_session.c (modified) (43 diffs)
- branches/6230-branch/tests/check_sync.c (modified) (11 diffs)
- branches/6230-branch/tests/check_wbxml_assembler.c (modified) (21 diffs)
- branches/6230-branch/tests/check_xml_assembler.c (modified) (23 diffs)
- branches/6230-branch/tests/check_xml_parser.c (modified) (2 diffs)
- branches/6230-branch/tests/valgrind.supp (modified) (1 diff)
- branches/6230-branch/tools/syncml-http-server.c (modified) (17 diffs)
- branches/6230-branch/tools/syncml-obex-client.c (modified) (21 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/6230-branch/libsyncml/objects/sml_auth.c
r127 r170 60 60 smlTrace(TRACE_INTERNAL, "Auth is required"); 61 61 auth->state = SML_ERROR_AUTH_REQUIRED; 62 63 smlErrorSet(&error, SML_ERROR_AUTH_REQUIRED, "Auth required but not given"); 64 smlSessionDispatchEvent(session, SML_SESSION_EVENT_ERROR, NULL, NULL, NULL, error); 65 smlErrorDeref(&error); 62 66 } else if ((!cred && auth->enabled && auth->state == SML_AUTH_ACCEPTED) || \ 63 67 (cred && !auth->enabled)) { … … 86 90 auth->state = SML_ERROR_AUTH_REJECTED; 87 91 } 92 93 if (auth->state == SML_ERROR_AUTH_REJECTED) { 94 smlErrorSet(&error, SML_ERROR_AUTH_REJECTED, "Auth rejected for username %s", arr[0]); 95 smlSessionDispatchEvent(session, SML_SESSION_EVENT_ERROR, NULL, NULL, NULL, error); 96 smlErrorDeref(&error); 97 } 98 88 99 g_strfreev(arr); 89 100 … … 97 108 } 98 109 99 if (auth->state == SML_ERROR_AUTH_REJECTED || auth->state == SML_ERROR_AUTH_REQUIRED) 110 if (auth->state == SML_ERROR_AUTH_REJECTED || auth->state == SML_ERROR_AUTH_REQUIRED) { 111 smlTrace(TRACE_INTERNAL, "Ending session due to wrong / missing creds"); 100 112 session->end = TRUE; 113 } 101 114 102 115 reply = smlAuthHeaderReply(session, auth->state, &error); … … 115 128 116 129 error: 117 smlSession SetError(session, &error);130 smlSessionDispatchEvent(session, SML_SESSION_EVENT_ERROR, NULL, NULL, NULL, error); 118 131 smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(&error)); 119 132 smlErrorDeref(&error); branches/6230-branch/libsyncml/objects/sml_devinf_obj.c
r127 r170 36 36 /*@{*/ 37 37 38 static void _get_devinf_reply(SmlSession *session, SmlStatus *status, void *userdata) 39 { 40 smlTrace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, session, status, userdata); 41 SmlError *error = NULL; 42 SmlDevInfAgent *agent = userdata; 43 44 if (smlStatusIsResult(status)) { 45 SmlCommand *result = smlStatusGetResult(status); 46 printf("result: %p\n", result); 47 48 agent->recvDevInf = smlDevInfFromResult(result, &error); 49 if (!agent->recvDevInf) 50 goto error; 51 52 SmlStatus *reply = smlCommandNewReply(result, SML_NO_ERROR, &error); 53 if (!reply) 54 goto error; 55 56 if (!smlSessionSendReply(session, reply, &error)) { 57 smlStatusUnref(reply); 58 goto error; 59 } 60 61 smlStatusUnref(reply); 62 } 63 64 smlTrace(TRACE_EXIT, "%s", __func__); 65 return; 66 67 error: 68 smlSessionDispatchEvent(session, SML_SESSION_EVENT_ERROR, NULL, NULL, NULL, error); 69 smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(&error)); 70 smlErrorDeref(&error); 71 } 72 38 73 static void _devinf_reply(SmlSession *session, SmlStatus *status, void *userdata) 39 74 { … … 57 92 { 58 93 smlTrace(TRACE_ENTRY, "%s(%p, %p, %p, %p)", __func__, agent, session, get, error); 59 Sml Status*result = NULL;94 SmlCommand *result = NULL; 60 95 SmlCommand *cmd = NULL; 61 96 … … 70 105 goto error; 71 106 72 if (!smlSessionSend Result(session, result, _devinf_reply, agent, error)) {73 sml StatusUnref(result);107 if (!smlSessionSendCommand(session, result, NULL, _devinf_reply, agent, error)) { 108 smlCommandUnref(result); 74 109 goto error; 75 110 } 76 111 77 sml StatusUnref(result);112 smlCommandUnref(result); 78 113 79 114 SmlStatus *reply = smlCommandNewReply(get, SML_NO_ERROR, error); … … 134 169 SmlDevInfAgent *agent = userdata; 135 170 SmlError *error = NULL; 136 137 agent->recvDevInf = cmd; 138 smlCommandRef(cmd); 139 140 SmlStatus *reply = smlCommandNewReply(agent->recvDevInf, SML_NO_ERROR, &error); 171 char *data = NULL; 172 unsigned int size = 0; 173 174 if (!smlItemGetData(cmd->private.access.item, &data, &size, &error)) 175 goto error; 176 177 agent->recvDevInf = smlDevInfParse(data, size, &error); 178 if (!agent->recvDevInf) 179 goto error; 180 181 SmlStatus *reply = smlCommandNewReply(cmd, SML_NO_ERROR, &error); 141 182 if (!reply) 142 183 goto error; … … 205 246 206 247 /* Get the devinf that was sent in the session. Returns FALSE if no devinf was received yet. */ 207 SmlDevInf *smlDevInfAgentGetDevInf(SmlDevInfAgent *agent, SmlError **error) 208 { 209 smlTrace(TRACE_ENTRY, "%s(%p, %p)", __func__, agent, error); 210 smlAssert(agent); 211 212 if (agent->recvDevInf) { 213 char *data = NULL; 214 unsigned int size = 0; 215 if (!smlItemGetData(agent->recvDevInf->private.access.item, &data, &size, error)) 216 goto error; 217 218 SmlDevInf *devinf = smlDevInfParse(data, size, error); 219 if (!devinf) 220 goto error; 221 222 smlCommandUnref(agent->recvDevInf); 223 agent->recvDevInf = NULL; 224 225 smlTrace(TRACE_EXIT, "%s: %p", __func__, devinf); 226 return devinf; 227 } 228 229 smlTrace(TRACE_EXIT, "%s: No devinf yet", __func__); 230 return NULL; 231 232 error: 233 smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(error)); 234 return NULL; 248 SmlDevInf *smlDevInfAgentGetDevInf(SmlDevInfAgent *agent) 249 { 250 smlAssert(agent); 251 return agent->recvDevInf; 235 252 } 236 253 … … 257 274 smlTrace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, agent, session, error); 258 275 smlAssert(agent); 259 260 //TODO 261 276 SmlCommand *get = NULL; 277 278 if (agent->recvDevInf) { 279 smlTrace(TRACE_EXIT, "%s: Already have the devinf", __func__); 280 return TRUE; 281 } 282 283 if (smlSessionGetVersion(session) == SML_VERSION_10) 284 get = smlDevInfNewGet(SML_DEVINF_VERSION_10, error); 285 else 286 get = smlDevInfNewGet(SML_DEVINF_VERSION_11, error); 287 288 if (!get) 289 goto error; 290 291 if (!smlSessionSendCommand(session, get, NULL, _get_devinf_reply, agent, error)) { 292 smlCommandUnref(get); 293 goto error; 294 } 295 296 smlCommandUnref(get); 297 262 298 smlTrace(TRACE_EXIT, "%s", __func__); 263 299 return TRUE; 264 300 265 /*error:266 smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(error)); 267 return FALSE; */301 error: 302 smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(error)); 303 return FALSE; 268 304 } 269 305 branches/6230-branch/libsyncml/objects/sml_devinf_obj.h
r127 r170 26 26 SmlDevInfAgent *smlDevInfAgentNew(SmlDevInf *devinf, SmlError **error); 27 27 void smlDevInfAgentFree(SmlDevInfAgent *agent); 28 SmlDevInf *smlDevInfAgentGetDevInf(SmlDevInfAgent *agent , SmlError **error);28 SmlDevInf *smlDevInfAgentGetDevInf(SmlDevInfAgent *agent); 29 29 SmlBool smlDevInfAgentRegister(SmlDevInfAgent *agent, SmlManager *manager, SmlError **error); 30 30 SmlBool smlDevInfAgentSendDevInf(SmlDevInfAgent *agent, SmlSession *session, SmlError **error); branches/6230-branch/libsyncml/objects/sml_devinf_obj_internals.h
r127 r170 26 26 SmlBool devinfSent; 27 27 28 Sml Command*recvDevInf;28 SmlDevInf *recvDevInf; 29 29 }; 30 30 branches/6230-branch/libsyncml/objects/sml_ds_server.c
r152 r170 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/6230-branch/libsyncml/objects/sml_ds_server.h
r127 r170 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/6230-branch/libsyncml/objects/sml_ds_server_internals.h
r127 r170 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/6230-branch/libsyncml/parser/sml_wbxml.c
r127 r170 79 79 80 80 smlTrace(TRACE_INTERNAL, "Wbxml input: %s", smlPrintBinary(data, size)); 81 smlLog("received-%i.wbxml", data, size); 81 82 82 83 char *buffer = NULL; … … 136 137 137 138 smlTrace(TRACE_INTERNAL, "Wbxml assembled: %s", smlPrintHex(*data, *size)); 139 smlLog("sent-%i.wbxml", *data, *size); 138 140 139 141 smlTrace(TRACE_EXIT, "%s", __func__); branches/6230-branch/libsyncml/parser/sml_xml_assm.c
r153 r170 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"); … … 197 198 } 198 199 199 SmlBool smlItemAssemble(SmlItem *item, SmlXmlAssembler *assm, Sml Bool raw, unsigned int complete_size, SmlError **error)200 { 201 smlTrace(TRACE_ENTRY, "%s(%p, %p, % i, %i, %p)", __func__, item, assm, raw, complete_size, error);200 SmlBool smlItemAssemble(SmlItem *item, SmlXmlAssembler *assm, SmlError **error) 201 { 202 smlTrace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, item, assm, error); 202 203 smlAssert(assm); 203 204 smlAssert(item); … … 221 222 } 222 223 223 //Meta224 /*if (complete_size) {225 if (!_smlXmlAssemblerStartNode(assm, SML_ELEMENT_META, error))226 goto error;227 228 if (!_smlXmlAssemblerAddIDNS(assm, NULL, SML_ELEMENT_SIZE, SML_NAMESPACE_METINF, complete_size, error))229 goto error;230 231 //META232 if (!_smlXmlAssemblerEndNode(assm, error))233 goto error;234 }*/235 236 224 if (smlItemHasData(item)) { 237 225 if (item->disabled) { 238 if (!_smlXmlAssemblerAddData(assm, SML_ELEMENT_DATA, "", 0, raw, error))226 if (!_smlXmlAssemblerAddData(assm, SML_ELEMENT_DATA, "", 0, item->raw, error)) 239 227 goto error; 240 228 } else { … … 244 232 goto error; 245 233 246 if (!_smlXmlAssemblerAddData(assm, SML_ELEMENT_DATA, data, size, raw, error))234 if (!_smlXmlAssemblerAddData(assm, SML_ELEMENT_DATA, data, size, item->raw, error)) 247 235 goto error; 248 236 } … … 339 327 goto error; 340 328 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)) 329 if (!_smlXmlAssemblerAddStringNS(assm, SML_ELEMENT_TYPE, SML_NAMESPACE_METINF, change->private.access.item->contenttype, error)) 346 330 goto error; 347 331 … … 350 334 goto error; 351 335 352 if (!smlItemAssemble(change->private.access.item, assm, FALSE, 0,error))336 if (!smlItemAssemble(change->private.access.item, assm, error)) 353 337 goto error; 354 338 … … 381 365 goto error; 382 366 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)) 388 goto error; 389 390 if (change->size) { 367 if (!_smlXmlAssemblerAddStringNS(assm, SML_ELEMENT_TYPE, SML_NAMESPACE_METINF, change->private.change.item->contenttype, error)) 368 goto error; 369 370 const char *opt = smlAssemblerGetOption(assm->assembler, "USE_LARGEOBJECTS"); 371 SmlBool supportsLargeObjects = (opt && !atoi(opt)) ? FALSE : TRUE; 372 if (supportsLargeObjects && change->size) { 391 373 if (!_smlXmlAssemblerAddIDNS(assm, SML_ELEMENT_SIZE, SML_NAMESPACE_METINF, change->size, error)) 392 374 goto error; … … 397 379 goto error; 398 380 399 const char *opt = smlAssemblerGetOption(assm->assembler, "ONLY_REPLACE");381 opt = smlAssemblerGetOption(assm->assembler, "ONLY_REPLACE"); 400 382 if (opt && atoi(opt) && change->type == SML_COMMAND_TYPE_ADD) { 401 383 change->private.change.item->target = change->private.change.item->source; … … 403 385 } 404 386 405 if (!smlItemAssemble(change->private.change.item, assm, FALSE, change->size,error))387 if (!smlItemAssemble(change->private.change.item, assm, error)) 406 388 goto error; 407 389 … … 416 398 SmlBool smlSyncAssemble(SmlXmlAssembler *assm, SmlCommand *cmd, SmlError **error) 417 399 { 418 smlTrace(TRACE_ENTRY, "%s(%p, %p, %p , %p)", __func__, assm, cmd, error);400 smlTrace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, assm, cmd, error); 419 401 smlAssert(cmd); 420 402 smlAssert(assm); … … 425 407 } 426 408 427 /*if (assm->session->incomingMaxObjSize && assm->session->version != SML_VERSION_10) { 409 const char *opt = smlAssemblerGetOption(assm->assembler, "USE_LARGEOBJECTS"); 410 SmlBool supportsLargeObjects = (opt && !atoi(opt)) ? FALSE : TRUE; 411 if (supportsLargeObjects && assm->session->incomingMaxObjSize && assm->session->version != SML_VERSION_10) { 428 412 if (!_smlXmlAssemblerStartNode(assm, SML_ELEMENT_META, error)) 429 413 goto error; … … 435 419 if (!_smlXmlAssemblerEndNode(assm, error)) 436 420 goto error; 437 } */421 } 438 422 439 423 if (!smlLocationAssemble(cmd->target, assm, SML_ELEMENT_TARGET, error)) … … 448 432 goto error; 449 433 450 /*if (assm->session->version != SML_VERSION_10) { 434 opt = smlAssemblerGetOption(assm->assembler, "USE_NUMBEROFCHANGES"); 435 SmlBool supportsNumberOfChanges = (opt && !atoi(opt)) ? FALSE : TRUE; 436 if (supportsNumberOfChanges && assm->session->version != SML_VERSION_10) { 451 437 if (!_smlXmlAssemblerAddID(assm, SML_ELEMENT_NUMBEROFCHANGES, cmd->private.sync.numChanged, error)) 452 438 goto error; 453 } */439 } 454 440 455 441 smlTrace(TRACE_EXIT, "%s", __func__); … … 566 552 } 567 553 568 if (cmd->private.alert.contentType != SML_CONTENT_TYPE_UNKNOWN) {554 if (cmd->private.alert.contentType) { 569 555 if (!_smlXmlAssemblerStartNode(assm, SML_ELEMENT_META, error)) 570 556 goto error; 571 572 const char *contenttype = smlContentTypeToString(cmd->private.alert.contentType, error);573 if (!contenttype)574 goto error;575 557 576 if (!_smlXmlAssemblerAddStringNS(assm, SML_ELEMENT_TYPE, SML_NAMESPACE_METINF, c ontenttype, error))558 if (!_smlXmlAssemblerAddStringNS(assm, SML_ELEMENT_TYPE, SML_NAMESPACE_METINF, cmd->private.alert.contentType, error)) 577 559 goto error; 578 560 … … 585 567 if (!_smlXmlAssemblerEndNode(assm, error)) 586 568 goto error; 569 570 smlTrace(TRACE_EXIT, "%s", __func__); 571 return TRUE; 572 573 error: 574 smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(error)); 575 return FALSE; 576 } 577 578 SmlBool smlResultsAssemble(SmlXmlAssembler *assm, SmlCommand *cmd, SmlError **error) 579 { 580 smlTrace(TRACE_ENTRY, "%s(%p, %p, %p, %p)", __func__, assm, cmd, error); 581 smlAssert(cmd); 582 smlAssert(assm); 583 584 if (!_smlXmlAssemblerAddID(assm, SML_ELEMENT_MSGREF, cmd->private.results.status->msgRef, error)) 585 goto error; 586 587 if (!_smlXmlAssemblerAddID(assm, SML_ELEMENT_CMDREF, cmd->private.results.status->cmdRef, error)) 588 goto error; 589 590 if (!_smlXmlAssemblerStartNode(assm, SML_ELEMENT_META, error)) 591 goto error; 592 593 if (!_smlXmlAssemblerAddStringNS(assm, SML_ELEMENT_TYPE, SML_NAMESPACE_METINF, cmd->private.results.status->item->contenttype, error)) 594 goto error; 595 596 //META 597 if (!_smlXmlAssemblerEndNode(assm, error)) 598 goto error; 599 600 if (!smlItemAssemble(cmd->private.results.status->item, assm, error)) 601 goto error; 602 603 if (cmd->private.results.status->sourceRef) { 604 if (!_smlXmlAssemblerAddString(assm, SML_ELEMENT_SOURCEREF, cmd->private.results.status->sourceRef->locURI, error)) 605 goto error; 606 } 607 608 if (cmd->private.results.status->targetRef) { 609 if (!_smlXmlAssemblerAddString(assm, SML_ELEMENT_TARGETREF, cmd->private.results.status->targetRef->locURI, error)) 610 goto error; 611 } 587 612 588 613 smlTrace(TRACE_EXIT, "%s", __func__); … … 680 705 goto error_free_writer; 681 706 682 if (session->incomingMaxMsgSize || session->incomingMaxObjSize) { 707 //const char *opt = smlAssemblerGetOption(assm->assembler, "USE_LARGEOBJECTS"); 708 //SmlBool supportsLargeObjects = (opt && !atoi(opt)) ? FALSE : TRUE; 709 if (session->incomingMaxMsgSize) { // || (session->incomingMaxObjSize && supportsLargeObjects)) { 683 710 if (!_smlXmlAssemblerStartNode(assm, SML_ELEMENT_META, error)) 684 711 goto error_free_writer; … … 689 716 } 690 717 691 if (session->incomingMaxObjSize) {718 /*if (supportsLargeObjects && session->incomingMaxObjSize) { 692 719 if (!_smlXmlAssemblerAddIDNS(assm, SML_ELEMENT_MAXOBJSIZE, SML_NAMESPACE_METINF, session->incomingMaxObjSize, error)) 693 720 goto error_free_writer; 694 } 721 }*/ 695 722 696 723 //META … … 798 825 break; 799 826 case SML_COMMAND_TYPE_PUT: 827 case SML_COMMAND_TYPE_GET: 800 828 if (!smlAccessAssemble(assm, cmd, error)) 801 829 goto error_free_writer; … … 805 833 goto error_free_writer; 806 834 break; 835 case SML_COMMAND_TYPE_RESULTS: 836 if (!smlResultsAssemble(assm, cmd, error)) 837 goto error_free_writer; 807 838 default: 808 839 smlErrorSet(error, SML_ERROR_GENERIC, "Unknown command type"); … … 1002 1033 } 1003 1034 1004 /* If the status is a result, we create a new buffer here 1005 * since it was not reserved before */ 1006 if (status->type == SML_COMMAND_TYPE_RESULTS) { 1007 if (!smlXmlAssemblerReserveStatus(assm, status->cmdRef, status->msgRef, status->cmdID, error)) 1008 goto error; 1009 res = g_list_last(assm->statuses)->data; 1010 } else { 1011 GList *s = NULL; 1012 for (s = assm->statuses; s; s = s->next) { 1013 res = s->data; 1014 if (res->cmdRef == status->cmdRef && res->msgRef == status->msgRef) 1015 break; 1016 res = NULL; 1017 } 1035 /* Get the reserved buffer */ 1036 GList *s = NULL; 1037 for (s = assm->statuses; s; s = s->next) { 1038 res = s->data; 1039 if (res->cmdRef == status->cmdRef && res->msgRef == status->msgRef) 1040 break; 1041 res = NULL; 1018 1042 } 1019 1043 … … 1046 1070 } 1047 1071 1048 if (status->type != SML_COMMAND_TYPE_RESULTS) { 1049 if (!_smlXmlAssemblerStartNode(assm, SML_ELEMENT_STATUS, error)) 1050 goto error; 1051 } else { 1052 if (!_smlXmlAssemblerStartNode(assm, SML_ELEMENT_RESULTS, error)) 1053 goto error; 1054 } 1072 if (!_smlXmlAssemblerStartNode(assm, SML_ELEMENT_STATUS, error)) 1073 goto error; 1055 1074 1056 1075 if (!_smlXmlAssemblerAddID(assm, SML_ELEMENT_CMDID, res->cmdID, error)) … … 1063 1082 goto error; 1064 1083 1065 if (status->type != SML_COMMAND_TYPE_RESULTS) { 1066 const char *cmdname = smlCommandTypeToString(status->type, error); 1067 if (!cmdname) 1068 goto error; 1069 1070 if (!_smlXmlAssemblerAddString(assm, SML_ELEMENT_CMD, cmdname, error)) 1071 goto error; 1072 } 1084 const char *cmdname = smlCommandTypeToString(status->type, error); 1085 if (!cmdname) 1086 goto error; 1087 1088 if (!_smlXmlAssemblerAddString(assm, SML_ELEMENT_CMD, cmdname, error)) 1089 goto error; 1073 1090 1074 1091 switch (status->type) { … … 1127 1144 } 1128 1145 break; 1129 case SML_COMMAND_TYPE_RESULTS:1130 if (!_smlXmlAssemblerStartNode(assm, SML_ELEMENT_META, error))1131 goto error;1132 1133 const char *contenttype = smlContentTypeToString(status->item->contenttype, error);1134 if (!contenttype)1135 goto error;1136 1137 if (!_smlXmlAssemblerAddStringNS(assm, SML_ELEMENT_TYPE, SML_NAMESPACE_METINF, contenttype, error))1138 goto error;1139 1140 //META1141 if (!_smlXmlAssemblerEndNode(assm, error))1142 goto error;1143 1144 if (!smlItemAssemble(status->item, assm, TRUE, 0, error))1145 goto error;1146 break;1147 1146 default: 1148 1147 ; … … 1159 1158 } 1160 1159 1161 if (status-> type != SML_COMMAND_TYPE_RESULTS && status->data) {1160 if (status->data) { 1162 1161 if (!_smlXmlAssemblerAddString(assm, SML_ELEMENT_DATA, status->data, error)) 1163 1162 goto error; … … 1334 1333 /* Add the corresponding command opener */ 1335 1334 1336 if ( onlyReplace)1335 if (cmd->cmdType == SML_COMMAND_TYPE_ADD && onlyReplace) 1337 1336 cmdname = SML_ELEMENT_REPLACE; 1338 1337 else { … … 1456 1455 SmlXmlAssemblerStatus *status = b->data; 1457 1456 if (!status->buffer) { 1457 if (status->cmdRef == 0 && check) { 1458 smlErrorSet(error, SML_ERROR_GENERIC, "Reserved status 0 has not been added"); 1459 goto error_free_writer; 1460 } 1458 1461 smlTrace(TRACE_INTERNAL, "Reserved status %i is missing", status->cmdRef); 1459 1462 missingstatus = TRUE; … … 1548 1551 SmlBool smlXmlAssemblerRun(SmlXmlAssembler *assm, char **data, unsigned int *size, SmlBool *end, SmlBool final, unsigned int maxsize, SmlError **error) 1549 1552 { 1550 return smlXmlAssemblerRunFull(assm, data, size, end, final, TRUE, maxsize, error); 1553 SmlBool ans = smlXmlAssemblerRunFull(assm, data, size, end, final, TRUE, maxsize, error); 1554 1555 smlLog("sent-%i.xml", *data, *size); 1556 return ans; 1551 1557 } 1552 1558 … … 1584 1590 SmlBool smlXmlAssemblerNextCmdRef(SmlXmlAssembler *assm, unsigned int *cmdRef, unsigned int *msgRef) 1585 1591 { 1586 smlTrace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, assm, cmdRef, msgRef);1587 1592 smlAssert(assm); 1588 1593 smlAssert(cmdRef); … … 1596 1601 *cmdRef = status->cmdRef; 1597 1602 *msgRef = status->msgRef; 1598 1599 smlTrace(TRACE_EXIT, "%s: Found one", __func__);1600 1603 return TRUE; 1601 1604 } 1602 1605 } 1603 1606 1604 smlTrace(TRACE_EXIT, "%s: None found", __func__);1605 1607 return FALSE; 1606 1608 } <
