You can subscribe to this list here.
2005 |
Jan
|
Feb
|
Mar
(56) |
Apr
(109) |
May
(15) |
Jun
(3) |
Jul
(37) |
Aug
(96) |
Sep
(40) |
Oct
(4) |
Nov
(54) |
Dec
|
---|---|---|---|---|---|---|---|---|---|---|---|---|
2006 |
Jan
(47) |
Feb
(30) |
Mar
(102) |
Apr
(120) |
May
(68) |
Jun
(54) |
Jul
(53) |
Aug
(122) |
Sep
(190) |
Oct
(71) |
Nov
(85) |
Dec
(108) |
2007 |
Jan
(72) |
Feb
(190) |
Mar
(53) |
Apr
(101) |
May
(145) |
Jun
(148) |
Jul
(167) |
Aug
(143) |
Sep
(23) |
Oct
(198) |
Nov
(223) |
Dec
(195) |
2008 |
Jan
(100) |
Feb
(129) |
Mar
(79) |
Apr
(77) |
May
(34) |
Jun
(95) |
Jul
(112) |
Aug
(160) |
Sep
(82) |
Oct
(124) |
Nov
(199) |
Dec
(355) |
2009 |
Jan
(436) |
Feb
(89) |
Mar
(298) |
Apr
(189) |
May
(33) |
Jun
(88) |
Jul
(105) |
Aug
(44) |
Sep
(181) |
Oct
(87) |
Nov
(75) |
Dec
(1) |
2010 |
Jan
(63) |
Feb
(21) |
Mar
(3) |
Apr
(1) |
May
(1) |
Jun
(3) |
Jul
(26) |
Aug
(37) |
Sep
(26) |
Oct
(15) |
Nov
(13) |
Dec
|
From: <svn...@op...> - 2009-03-18 17:40:56
|
Author: bellmich Date: Wed Mar 18 18:40:51 2009 New Revision: 999 URL: http://libsyncml.opensync.org/changeset/999 Log: use new SAN callback which provides the session too which avoids race conditions (alternatively you can block the thread until the event SESSION_NEW will be dispatched) Modified: trunk/libsyncml/data_sync_api/data_sync_client.c Modified: trunk/libsyncml/data_sync_api/data_sync_client.c ============================================================================== --- trunk/libsyncml/data_sync_api/data_sync_client.c Wed Mar 18 18:38:50 2009 (r998) +++ trunk/libsyncml/data_sync_api/data_sync_client.c Wed Mar 18 18:40:51 2009 (r999) @@ -250,15 +250,22 @@ static SmlErrorType smlDataSyncSanCallback( SmlDsServer *server, + SmlSession *session, SmlAlertType type, void *userdata) { - smlTrace(TRACE_ENTRY, "%s(%p, %d, %p)", __func__, server, type, userdata); + smlTrace(TRACE_ENTRY, "%s(%p, %p, %d, %p)", __func__, server, session, type, userdata); SmlDataSyncDatastore *datastore = userdata; SmlDataSyncObject *dsObject = datastore->dsObject; SmlError *error = NULL; SmlErrorType ret = SML_NO_ERROR; + /* soemtimes the event manager thread is too slow */ + if (!dsObject->session) { + dsObject->session = session; + smlSessionRef(session); + } + if (!smlDataSyncClientSendAlert(datastore, type, &error)) { if (!error) ret = SML_ERROR_REQUIRE_REFRESH; @@ -324,7 +331,7 @@ smlDataSyncDatastoreConnectCallback, datastore); - smlDsServerSetSanCallback( + smlDsServerSetSanSessionCallback( datastore->server, smlDataSyncSanCallback, datastore); |
From: <svn...@op...> - 2009-03-18 17:38:53
|
Author: bellmich Date: Wed Mar 18 18:38:50 2009 New Revision: 998 URL: http://libsyncml.opensync.org/changeset/998 Log: If the alerts and the device information are in the same SyncML message then the alerts are dispatched faster. So it is necessary to check manually for an available remote device information. Modified: trunk/libsyncml/data_sync_api/data_sync_common.c Modified: trunk/libsyncml/data_sync_api/data_sync_common.c ============================================================================== --- trunk/libsyncml/data_sync_api/data_sync_common.c Wed Mar 18 18:37:04 2009 (r997) +++ trunk/libsyncml/data_sync_api/data_sync_common.c Wed Mar 18 18:38:50 2009 (r998) @@ -56,10 +56,24 @@ use_timestamp = smlDataSyncIsTimestamp(last, datastore->dsObject->useTimestampAnchor); - smlTrace(TRACE_INTERNAL, "%s - use timestamp is %d", __func__, use_timestamp); + smlTrace(TRACE_INTERNAL, "%s: use timestamp is %d", __func__, use_timestamp); if (use_timestamp) { + /* It is necessary to be sure that the remote device supports UTC. */ + smlTrace(TRACE_INTERNAL, + "%s: session %p, localtime %d, remoteDevInf %p", + __func__, + datastore->dsObject->session, + datastore->dsObject->onlyLocaltime, + datastore->dsObject->remoteDevInf); + if (datastore->dsObject->session && + !datastore->dsObject->onlyLocaltime && + !datastore->dsObject->remoteDevInf && + !smlDataSyncManageDevInf(datastore->dsObject, error)) + { + goto error; + } next = smlTryMalloc0(sizeof(char)*17, error); if (!next) goto error; |
From: <svn...@op...> - 2009-03-18 17:37:08
|
Author: bellmich Date: Wed Mar 18 18:37:04 2009 New Revision: 997 URL: http://libsyncml.opensync.org/changeset/997 Log: fixed remote device handling to be multi session safe This is important if you ever implement long living processes or if you implement a client which wants to use its own session ID. Modified: trunk/libsyncml/data_sync_api/data_sync_devinf.c Modified: trunk/libsyncml/data_sync_api/data_sync_devinf.c ============================================================================== --- trunk/libsyncml/data_sync_api/data_sync_devinf.c Wed Mar 18 18:33:12 2009 (r996) +++ trunk/libsyncml/data_sync_api/data_sync_devinf.c Wed Mar 18 18:37:04 2009 (r997) @@ -568,6 +568,7 @@ smlTrace(TRACE_ENTRY, "%s(%p,%p)", __func__, dsObject, error); CHECK_ERROR_REF smlAssert(dsObject); + smlAssertMsg(dsObject->session, "an active session is needed to have a remote device"); /* if there is already a remote device information * then cleanup the reference. @@ -575,7 +576,7 @@ if (dsObject->remoteDevInf) smlDevInfUnref(dsObject->remoteDevInf); - dsObject->remoteDevInf = smlDevInfAgentGetDevInf(dsObject->agent); + dsObject->remoteDevInf = smlDevInfAgentGetSessionDevInf(dsObject->agent, dsObject->session); if (dsObject->remoteDevInf) { smlTrace(TRACE_INTERNAL, "%s: The remote DevInf was received.", __func__); @@ -605,8 +606,17 @@ if (!devinf && *error) goto error; if (devinf) { - smlDevInfAgentSetDevInf(dsObject->agent, devinf); - dsObject->remoteDevInf = smlDevInfAgentGetDevInf(dsObject->agent); + if (!smlDevInfAgentSetSessionDevInf( + dsObject->agent, + dsObject->session, + devinf, + error)) + { + goto error; + } + dsObject->remoteDevInf = smlDevInfAgentGetSessionDevInf( + dsObject->agent, + dsObject->session); /* smlDevInfAgentSetDevInf consumes the DevInf object. * So the reference counter must be incremented for * remoteDevInf. @@ -714,6 +724,7 @@ { smlTrace(TRACE_ENTRY, "%s(%p, %p)", __func__, dsObject, error); CHECK_ERROR_REF + smlAssertMsg(dsObject->session, "an active session is needed to manage device informations"); /* If the callback is available * then we dump the local device information first. |
From: <svn...@op...> - 2009-03-18 17:33:16
|
Author: bellmich Date: Wed Mar 18 18:33:12 2009 New Revision: 996 URL: http://libsyncml.opensync.org/changeset/996 Log: fixed device information agent to be multi session safe The old code only works if the manager manages exactly one session. If there is more than one session then the agent must take care about the different remote device capabilities. Modified: trunk/libsyncml/objects/sml_devinf_obj.c trunk/libsyncml/objects/sml_devinf_obj.h trunk/libsyncml/objects/sml_devinf_obj_internals.h Modified: trunk/libsyncml/objects/sml_devinf_obj.c ============================================================================== --- trunk/libsyncml/objects/sml_devinf_obj.c Wed Mar 18 18:31:30 2009 (r995) +++ trunk/libsyncml/objects/sml_devinf_obj.c Wed Mar 18 18:33:12 2009 (r996) @@ -31,6 +31,71 @@ #include<sys/utsname.h> +/* Design notice + * + * There is only one SmlDevInfAgent per SmlManager + * because there is only one local device information. + * Therefore the agent must be able to manage one + * device information per session because every remote + * device can have different capabilities. + */ + +/* functions to manage SmlDevInfAgentSession */ + +static SmlDevInfAgentSession* _new_session( + SmlDevInfAgent *agent, + SmlSession *session, + SmlError **error) +{ + smlTrace(TRACE_ENTRY, "%s", __func__); + + CHECK_ERROR_REF + smlAssert(agent); + smlAssert(agent->sessions); + smlAssert(session); + + SmlDevInfAgentSession *as = smlTryMalloc0(sizeof(SmlDevInfAgentSession), error); + if (!as) + goto error; + + g_hash_table_insert(agent->sessions, session, as); + + smlTrace(TRACE_EXIT, "%s", __func__); + return as; +error: + smlSafeFree((gpointer *) &as); + smlTrace(TRACE_EXIT_ERROR, "%s - %s", __func__, smlErrorPrint(error)); + return NULL; +} + +static SmlDevInfAgentSession* _get_session( + SmlDevInfAgent *agent, + SmlSession *session) +{ + smlTrace(TRACE_ENTRY, "%s", __func__); + + smlAssert(agent); + smlAssert(agent->sessions); + smlAssert(session); + + smlTrace(TRACE_EXIT, "%s", __func__); + return g_hash_table_lookup(agent->sessions, session); +} + +static void _free_session (gpointer data) +{ + smlTrace(TRACE_ENTRY, "%s(%p)", __func__, data); + + SmlDevInfAgentSession *as = data; + if (as->recvDevInf) + smlDevInfUnref(as->recvDevInf); + smlSafeFree((gpointer *) &as); + + smlTrace(TRACE_EXIT, "%s", __func__); +} + +/* functions to manage SmlDevInfAgent */ + static void _get_devinf_reply(SmlSession *session, SmlStatus *status, void *userdata) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, session, status, userdata); @@ -40,9 +105,22 @@ if (smlStatusIsResult(status)) { SmlCommand *result = smlStatusGetResult(status); - agent->recvDevInf = smlDevInfFromResult(result, &error); - if (!agent->recvDevInf) + /* get cached session or add session to agent cache */ + + SmlDevInfAgentSession *as = _get_session(agent, session); + if (!as) { + as = _new_session(agent, session, &error); + if (!as) + goto error; + } + + /* cache device information */ + + as->recvDevInf = smlDevInfFromResult(result, &error); + if (!as->recvDevInf) goto error; + + /* send answer */ SmlStatus *reply = smlCommandNewReply(result, SML_NO_ERROR, &error); if (!reply) @@ -114,9 +192,18 @@ } } + /* get cached session or add session to agent cache */ + + SmlDevInfAgentSession *as = _get_session(agent, session); + if (!as) { + as = _new_session(agent, session, error); + if (!as) + goto error; + } + /* Sanity checks complete. Sending device information ... */ - if (!agent->devinfSent) { + if (!as->devinfSent) { if (get) { if (smlSessionGetVersion(session) == SML_VERSION_10) result = smlDevInfNewResult(get, agent->devinf, SML_DEVINF_VERSION_10, error); @@ -163,7 +250,7 @@ smlCommandUnref(cmd); } - agent->devinfSent = TRUE; + as->devinfSent = TRUE; } else { smlTrace(TRACE_INTERNAL, "%s: Already sent the devinf!", __func__); @@ -189,7 +276,9 @@ * with its own device information. Nevertheless * this is an error - but it can be ignored. */ - g_warning("libsyncml does not send local device information twice."); + smlTrace(TRACE_INTERNAL, + "%s: libsyncml does not send local device information twice.", + __func__); } } @@ -212,8 +301,15 @@ if (!smlItemGetData(cmd->private.access.item, &data, &size, &error)) goto error; - agent->recvDevInf = smlDevInfParse(data, size, &error); - if (!agent->recvDevInf) + SmlDevInfAgentSession *as = _get_session(agent, session); + if (!as) { + as = _new_session(agent, session, &error); + if (!as) + goto error; + } + + as->recvDevInf = smlDevInfParse(data, size, &error); + if (!as->recvDevInf) goto error; SmlStatus *reply = smlCommandNewReply(cmd, SML_NO_ERROR, &error); @@ -262,9 +358,12 @@ if (!agent) goto error; - agent->devinfSent = FALSE; agent->devinf = devinf; - agent->recvDevInf = NULL; + agent->sessions = g_hash_table_new_full(NULL, NULL, NULL, _free_session); + if (!agent->sessions) { + smlErrorSet(error, SML_ERROR_INTERNAL_NO_MEMORY, "Cannot create new hash table."); + goto error; + } if (!smlDevInfGetManufacturer(devinf)) smlDevInfSetManufacturer(devinf, "OpenSync"); @@ -287,6 +386,8 @@ return agent; error: + if (agent) + smlSafeFree((gpointer *) &agent); smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(error)); return NULL; } @@ -299,29 +400,74 @@ if (agent->devinf) smlDevInfUnref(agent->devinf); - if (agent->recvDevInf) - smlDevInfUnref(agent->recvDevInf); + g_hash_table_destroy(agent->sessions); smlSafeFree((gpointer *)&agent); smlTrace(TRACE_EXIT, "%s", __func__); } -/* Set the devinf of the remote peer. */ +/* FIXME: DEPRECATED */ void smlDevInfAgentSetDevInf(SmlDevInfAgent *agent, SmlDevInf *devinf) { - smlTrace(TRACE_ENTRY, "%s(%p, %p)", __func__, agent, devinf); + smlAssertMsg(NULL, "This function is a design bug."); +} + +/* FIXME: DEPRECATED */ +SmlDevInf *smlDevInfAgentGetDevInf(SmlDevInfAgent *agent) +{ + smlAssertMsg(NULL, "This function is a design bug."); + return NULL; +} + +/* Set the devinf of the remote peer. */ +SmlBool smlDevInfAgentSetSessionDevInf( + SmlDevInfAgent *agent, + SmlSession *session, + SmlDevInf *devinf, + SmlError **error) +{ + smlTrace(TRACE_ENTRY, "%s(%p, %p, %p, %p)", __func__, agent, session, devinf, error); + + CHECK_ERROR_REF smlAssert(agent); + smlAssert(agent->sessions); + smlAssert(session); smlAssert(devinf); - agent->recvDevInf = devinf; - smlTrace(TRACE_EXIT, "%s", __func__); + + SmlDevInfAgentSession *as = _get_session(agent, session); + if (!as) { + as = _new_session(agent, session, error); + if (!as) + goto error; + } + + as->recvDevInf = devinf; + + smlTrace(TRACE_EXIT, "%s", __func__); + return TRUE; +error: + smlTrace(TRACE_EXIT_ERROR, "%s - %s", __func__, smlErrorPrint(error)); + return FALSE; } /* Get the devinf that was sent in the session. Returns FALSE if no devinf was received yet. */ -SmlDevInf *smlDevInfAgentGetDevInf(SmlDevInfAgent *agent) +SmlDevInf *smlDevInfAgentGetSessionDevInf(SmlDevInfAgent *agent, SmlSession *session) { - smlTrace(TRACE_INTERNAL, "%s(%p)", __func__, agent); + smlTrace(TRACE_ENTRY, "%s(%p, %p)", __func__, agent, session); + smlAssert(agent); - return agent->recvDevInf; + smlAssert(agent->sessions); + smlAssert(session); + + SmlDevInfAgentSession *as = _get_session(agent, session); + if (!as) + { + smlTrace(TRACE_EXIT, "%s - the session is not cached until now", __func__); + return NULL; + } + + smlTrace(TRACE_EXIT, "%s - %p", __func__, as->recvDevInf); + return as->recvDevInf; } /** Issues a put request on the session if needed */ @@ -349,28 +495,42 @@ CHECK_ERROR_REF smlAssert(agent); SmlCommand *get = NULL; + + SmlDevInfAgentSession *as = _get_session(agent, session); + if (!as) { + as = _new_session(agent, session, error); + if (!as) + goto error; + } - if (agent->recvDevInf) { + if (as->recvDevInf) { smlTrace(TRACE_EXIT, "%s: Already have the devinf", __func__); return TRUE; } - if (smlSessionGetVersion(session) == SML_VERSION_10) - get = smlDevInfNewGet(SML_DEVINF_VERSION_10, error); - else if (smlSessionGetVersion(session) == SML_VERSION_12) - get = smlDevInfNewGet(SML_DEVINF_VERSION_12, error); - else - get = smlDevInfNewGet(SML_DEVINF_VERSION_11, error); - - if (!get) - goto error; - - if (!smlSessionSendCommand(session, get, NULL, _get_devinf_reply, agent, error)) { + if (!as->devinfRequested) + { + if (smlSessionGetVersion(session) == SML_VERSION_10) + get = smlDevInfNewGet(SML_DEVINF_VERSION_10, error); + else if (smlSessionGetVersion(session) == SML_VERSION_12) + get = smlDevInfNewGet(SML_DEVINF_VERSION_12, error); + else + get = smlDevInfNewGet(SML_DEVINF_VERSION_11, error); + + if (!get) + goto error; + + if (!smlSessionSendCommand(session, get, NULL, _get_devinf_reply, agent, error)) { + smlCommandUnref(get); + goto error; + } + smlCommandUnref(get); - goto error; + + as->devinfRequested = TRUE; + } else { + smlTrace(TRACE_INTERNAL, "%s: Already requested the devinf!", __func__); } - - smlCommandUnref(get); smlTrace(TRACE_EXIT, "%s", __func__); return TRUE; Modified: trunk/libsyncml/objects/sml_devinf_obj.h ============================================================================== --- trunk/libsyncml/objects/sml_devinf_obj.h Wed Mar 18 18:31:30 2009 (r995) +++ trunk/libsyncml/objects/sml_devinf_obj.h Wed Mar 18 18:33:12 2009 (r996) @@ -37,12 +37,21 @@ SmlDevInfAgent *smlDevInfAgentNew(SmlDevInf *devinf, SmlError **error); void smlDevInfAgentFree(SmlDevInfAgent *agent); -void smlDevInfAgentSetDevInf(SmlDevInfAgent *agent, SmlDevInf *devinf); -SmlDevInf *smlDevInfAgentGetDevInf(SmlDevInfAgent *agent); SmlBool smlDevInfAgentRegisterSession(SmlDevInfAgent *agent, SmlManager *manager, SmlSession *session, SmlError **error); SmlBool smlDevInfAgentRegister(SmlDevInfAgent *agent, SmlManager *manager, SmlError **error); SmlBool smlDevInfAgentSendDevInf(SmlDevInfAgent *agent, SmlSession *session, SmlError **error); SmlBool smlDevInfAgentRequestDevInf(SmlDevInfAgent *agent, SmlSession *session, SmlError **error); +SmlBool smlDevInfAgentSetSessionDevInf(SmlDevInfAgent *agent, SmlSession *session, SmlDevInf *devinf, SmlError **error); +SmlDevInf *smlDevInfAgentGetSessionDevInf(SmlDevInfAgent *agent, SmlSession *session); + +/* These functions can only work in a single session environemnt. +/* This is a design bug. The functions are not removed immediately + * to avoid breaking applications which ignore the device information. + * These functions always fire an assertion. + */ +void smlDevInfAgentSetDevInf(SmlDevInfAgent *agent, SmlDevInf *devinf) LIBSYNCML_DEPRECATED; +SmlDevInf *smlDevInfAgentGetDevInf(SmlDevInfAgent *agent) LIBSYNCML_DEPRECATED; + #endif //_SML_DEVINF_OBJ_H_ /*@}*/ Modified: trunk/libsyncml/objects/sml_devinf_obj_internals.h ============================================================================== --- trunk/libsyncml/objects/sml_devinf_obj_internals.h Wed Mar 18 18:31:30 2009 (r995) +++ trunk/libsyncml/objects/sml_devinf_obj_internals.h Wed Mar 18 18:33:12 2009 (r996) @@ -29,11 +29,18 @@ #ifndef _SML_DEVINF_OBJ_INTERNALS_H_ #define _SML_DEVINF_OBJ_INTERNALS_H_ -struct SmlDevInfAgent { - SmlDevInf *devinf; +typedef struct SmlDevInfAgentSession { + /* states */ SmlBool devinfSent; - + SmlBool devinfRequested; + /* remote device information */ SmlDevInf *recvDevInf; + +} SmlDevInfAgentSession; + +struct SmlDevInfAgent { + SmlDevInf *devinf; + GHashTable *sessions; }; #endif //_SML_DEVINF_OBJ_INTERNALS_H_ |
From: <svn...@op...> - 2009-03-18 17:31:39
|
Author: bellmich Date: Wed Mar 18 18:31:30 2009 New Revision: 995 URL: http://libsyncml.opensync.org/changeset/995 Log: added multi session safe SAN callback Modified: trunk/libsyncml/objects/sml_ds_server.c trunk/libsyncml/objects/sml_ds_server.h trunk/libsyncml/objects/sml_ds_server_internals.h Modified: trunk/libsyncml/objects/sml_ds_server.c ============================================================================== --- trunk/libsyncml/objects/sml_ds_server.c Wed Mar 18 18:29:06 2009 (r994) +++ trunk/libsyncml/objects/sml_ds_server.c Wed Mar 18 18:31:30 2009 (r995) @@ -277,6 +277,18 @@ smlTrace(TRACE_EXIT, "%s", __func__); } +void smlDsServerSetSanSessionCallback(SmlDsServer *server, SmlDsServerSanSessionCb callback, void *userdata) +{ + smlTrace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, server, callback, userdata); + smlAssert(server); + smlAssert(server->servertype == SML_DS_CLIENT); + + server->sanSessionCallback = callback; + server->sanSessionCallbackUserdata = userdata; + + smlTrace(TRACE_EXIT, "%s", __func__); +} + const char *smlDsServerGetLocation(SmlDsServer *server) { smlAssert(server); @@ -1240,8 +1252,23 @@ server->target = cmd->source; smlLocationRef(server->target); - /* handle the SAN */ - if (server->sanCallback) { + /* handle the SAN */ + if (server->sanSessionCallback) { + SmlErrorType type = server->sanSessionCallback( + server, + session, + cmd->private.alert.type, + server->sanSessionCallbackUserdata); + + SmlStatus *reply = smlCommandNewReply(cmd, type, &error); + if (!reply) + goto error; + + if (!smlSessionSendReply(session, reply, &error)) + goto error; + + smlStatusUnref(reply); + } else if (server->sanCallback) { SmlErrorType type = server->sanCallback(server, cmd->private.alert.type, server->sanCallbackUserdata); SmlStatus *reply = smlCommandNewReply(cmd, type, &error); Modified: trunk/libsyncml/objects/sml_ds_server.h ============================================================================== --- trunk/libsyncml/objects/sml_ds_server.h Wed Mar 18 18:29:06 2009 (r994) +++ trunk/libsyncml/objects/sml_ds_server.h Wed Mar 18 18:31:30 2009 (r995) @@ -38,8 +38,6 @@ SML_DS_EVENT_COMMITEDCHANGES = 1 } SmlDsEvent; -typedef SmlErrorType (* SmlDsServerSanCb) (SmlDsServer *dsserver, SmlAlertType type, void *userdata); - typedef void (* SmlDsSessionConnectCb) (SmlDsSession *dsession, void *userdata); typedef SmlBool (* SmlDsSessionAlertCb) (SmlDsSession *dsession, SmlAlertType type, const char *last, const char *next, void *userdata); typedef void (* SmlDsSessionSyncCb) (SmlDsSession *dsession, unsigned int numchanges, void *userdata); @@ -55,7 +53,6 @@ SmlBool smlDsServerAddSan(SmlDsServer *server, SmlNotification *san, SmlError **error); void smlDsServerReset(SmlDsServer *server); void smlDsServerSetConnectCallback(SmlDsServer *server, SmlDsSessionConnectCb callback, void *userdata); -void smlDsServerSetSanCallback(SmlDsServer *server, SmlDsServerSanCb callback, void *userdata); const char *smlDsServerGetLocation(SmlDsServer *server); const char *smlDsServerGetContentType(SmlDsServer *server); SmlDsSession *smlDsServerSendAlert(SmlDsServer *server, SmlSession *session, SmlAlertType type, const char *last, const char *next, SmlStatusReplyCb callback, void *userdata, SmlError **error); @@ -80,5 +77,15 @@ SmlDsServer *smlDsSessionGetServer(SmlDsSession *dsession); SmlLocation *smlDsSessionGetTarget(SmlDsSession *dsession); +/* multi session safe SAN handling */ + +typedef SmlErrorType (* SmlDsServerSanSessionCb) (SmlDsServer *dsserver, SmlSession *session, SmlAlertType type, void *userdata); +void smlDsServerSetSanSessionCallback(SmlDsServer *server, SmlDsServerSanSessionCb callback, void *userdata); + +/* deprecated SAN handling */ + +typedef SmlErrorType (* SmlDsServerSanCb) (SmlDsServer *dsserver, SmlAlertType type, void *userdata); +void smlDsServerSetSanCallback(SmlDsServer *server, SmlDsServerSanCb callback, void *userdata) LIBSYNCML_DEPRECATED; + #endif //_SML_DS_SERVER_H_ /*@}*/ Modified: trunk/libsyncml/objects/sml_ds_server_internals.h ============================================================================== --- trunk/libsyncml/objects/sml_ds_server_internals.h Wed Mar 18 18:29:06 2009 (r994) +++ trunk/libsyncml/objects/sml_ds_server_internals.h Wed Mar 18 18:31:30 2009 (r995) @@ -104,6 +104,8 @@ SmlDsSessionConnectCb connectCallback; void *connectCallbackUserdata; + SmlDsServerSanSessionCb sanSessionCallback; + void *sanSessionCallbackUserdata; SmlDsServerSanCb sanCallback; void *sanCallbackUserdata; }; |
From: <svn...@op...> - 2009-03-18 17:29:09
|
Author: bellmich Date: Wed Mar 18 18:29:06 2009 New Revision: 994 URL: http://libsyncml.opensync.org/changeset/994 Log: added missing trace statement to smlDataSyncTransportHttpClientInitNewSession Modified: trunk/libsyncml/data_sync_api/transport_http_client.c Modified: trunk/libsyncml/data_sync_api/transport_http_client.c ============================================================================== --- trunk/libsyncml/data_sync_api/transport_http_client.c Wed Mar 18 18:28:13 2009 (r993) +++ trunk/libsyncml/data_sync_api/transport_http_client.c Wed Mar 18 18:29:06 2009 (r994) @@ -61,6 +61,7 @@ static SmlBool smlDataSyncTransportHttpClientInitNewSession (SmlDataSyncObject *dsObject, SmlError **error) { + smlTrace(TRACE_ENTRY, "%s(%p, %p)", __func__, dsObject, error); smlAssert(dsObject->url); smlAssert(dsObject->identifier); smlAssert(dsObject->tsp); @@ -111,6 +112,7 @@ if (!smlDevInfAgentRegisterSession(dsObject->agent, dsObject->manager, dsObject->session, error)) goto error; + smlTrace(TRACE_EXIT, "%s", __func__); return TRUE; error: if (target) { @@ -121,6 +123,7 @@ smlLocationUnref(source); source = NULL; } + smlTrace(TRACE_EXIT_ERROR, "%s - %s", __func__, smlErrorPrint(error)); return FALSE; } |
From: <svn...@op...> - 2009-03-18 17:28:21
|
Author: bellmich Date: Wed Mar 18 18:28:13 2009 New Revision: 993 URL: http://libsyncml.opensync.org/changeset/993 Log: more detailed trace Modified: trunk/tests/mobiles/obex_mobile_ds_client.c Modified: trunk/tests/mobiles/obex_mobile_ds_client.c ============================================================================== --- trunk/tests/mobiles/obex_mobile_ds_client.c Wed Mar 18 18:27:49 2009 (r992) +++ trunk/tests/mobiles/obex_mobile_ds_client.c Wed Mar 18 18:28:13 2009 (r993) @@ -136,7 +136,7 @@ const char *recv_data, size_t recv_size, const char *orig_data, size_t orig_size) { - smlTrace(TRACE_ENTRY, "%s", __func__); + smlTrace(TRACE_ENTRY, "%s(%p, %d, %p, %d)", __func__, recv_data, recv_size, orig_data, orig_size); /* convert wbxml messages to xml */ |
From: <svn...@op...> - 2009-03-18 17:27:54
|
Author: bellmich Date: Wed Mar 18 18:27:49 2009 New Revision: 992 URL: http://libsyncml.opensync.org/changeset/992 Log: fixed a memory leak in the test code Modified: trunk/tests/check_libsoup.c Modified: trunk/tests/check_libsoup.c ============================================================================== --- trunk/tests/check_libsoup.c Wed Mar 18 13:12:37 2009 (r991) +++ trunk/tests/check_libsoup.c Wed Mar 18 18:27:49 2009 (r992) @@ -182,7 +182,7 @@ g_main_context_unref(ctx); soup_server_quit(server); g_object_unref(server); - + smlQueueFree(queue); } END_TEST |
From: <svn...@op...> - 2009-03-18 12:12:55
|
Author: bellmich Date: Wed Mar 18 13:12:37 2009 New Revision: 991 URL: http://libsyncml.opensync.org/changeset/991 Log: fixed Solaris and libsoup 2.2 detection again Modified: trunk/CMakeLists.txt Modified: trunk/CMakeLists.txt ============================================================================== --- trunk/CMakeLists.txt Wed Mar 18 12:30:56 2009 (r990) +++ trunk/CMakeLists.txt Wed Mar 18 13:12:37 2009 (r991) @@ -118,21 +118,24 @@ SET( ENABLE_WBXML ON) ENDIF(LIBWBXML2_FOUND) -OPTION( HAVE_LIBSOUP22_SOLARIS "enable Solaris libsoup workarounds" OFF ) IF(LIBSOUP2_FOUND) OPTION( ENABLE_HTTP "enable http transports" ON ) IF (LIBSOUP24_FOUND) - OPTION ( HAVE_LIBSOUP24 "building with libsoup 2.4" ON ) - OPTION ( HAVE_LIBSOUP22 "building with libsoup 2.2" OFF ) + OPTION( HAVE_LIBSOUP24 "building with libsoup 2.4" ON ) + OPTION( HAVE_LIBSOUP22 "building with libsoup 2.2" OFF ) + OPTION( HAVE_LIBSOUP22_SOLARIS "enable Solaris libsoup workarounds" OFF ) ELSE (LIBSOUP24_FOUND) - OPTION ( HAVE_LIBSOUP24 "building with libsoup 2.4" OFF ) - OPTION ( HAVE_LIBSOUP22 "building with libsoup 2.2" ON ) + OPTION( HAVE_LIBSOUP24 "building with libsoup 2.4" OFF ) + OPTION( HAVE_LIBSOUP22 "building with libsoup 2.2" ON ) IF( CMAKE_SYSTEM_NAME STREQUAL "SunOS" ) OPTION( HAVE_LIBSOUP22_SOLARIS "enable Solaris libsoup workarounds" ON ) + ELSE( CMAKE_SYSTEM_NAME STREQUAL "SunOS" ) + OPTION( HAVE_LIBSOUP22_SOLARIS "enable Solaris libsoup workarounds" OFF ) ENDIF( CMAKE_SYSTEM_NAME STREQUAL "SunOS" ) ENDIF (LIBSOUP24_FOUND) ELSE(LIBSOUP2_FOUND) - SET( ENABLE_HTTP OFF ) + OPTION( ENABLE_HTTP "enable http transports" OFF ) + OPTION( HAVE_LIBSOUP22_SOLARIS "enable Solaris libsoup workarounds" OFF ) ENDIF(LIBSOUP2_FOUND) IF(OPENOBEX_FOUND) |
From: <svn...@op...> - 2009-03-18 11:31:03
|
Author: bellmich Date: Wed Mar 18 12:30:56 2009 New Revision: 990 URL: http://libsyncml.opensync.org/changeset/990 Log: added next version of Solaris detection Modified: trunk/CMakeLists.txt Modified: trunk/CMakeLists.txt ============================================================================== --- trunk/CMakeLists.txt Wed Mar 18 11:50:50 2009 (r989) +++ trunk/CMakeLists.txt Wed Mar 18 12:30:56 2009 (r990) @@ -127,9 +127,9 @@ ELSE (LIBSOUP24_FOUND) OPTION ( HAVE_LIBSOUP24 "building with libsoup 2.4" OFF ) OPTION ( HAVE_LIBSOUP22 "building with libsoup 2.2" ON ) - IF( CMAKE_C_PLATFORM_ID STREQUAL "SunOS" ) + IF( CMAKE_SYSTEM_NAME STREQUAL "SunOS" ) OPTION( HAVE_LIBSOUP22_SOLARIS "enable Solaris libsoup workarounds" ON ) - ENDIF( CMAKE_C_PLATFORM_ID STREQUAL "SunOS" ) + ENDIF( CMAKE_SYSTEM_NAME STREQUAL "SunOS" ) ENDIF (LIBSOUP24_FOUND) ELSE(LIBSOUP2_FOUND) SET( ENABLE_HTTP OFF ) @@ -241,15 +241,17 @@ # status output INCLUDE( ShowStatus ) MESSAGE( STATUS "==================================================" ) +MESSAGE( STATUS "Operating System ${CMAKE_SYSTEM_NAME}" ) +IF( CMAKE_SYSTEM_NAME STREQUAL "SunOS" ) + SHOW_STATUS( HAVE_LIBSOUP22_SOLARIS "libsoup 2.2 Solaris workaround" ) +ENDIF( CMAKE_SYSTEM_NAME STREQUAL "SunOS" ) +MESSAGE( STATUS "==================================================" ) SHOW_STATUS( ENABLE_TOOLS "building tools\t\t" ) SHOW_STATUS( ENABLE_TRACE "tracing tools\t\t" ) SHOW_STATUS( ENABLE_UNIT_TEST "unit tests\t\t\t" ) SHOW_STATUS( THREAD_SAFE_CHECK "check is thread safe\t\t" CHECK_VERSION ) SHOW_STATUS( ENABLE_WBXML "WAP Binary XML\t\t" LIBWBXML2_VERSION ) SHOW_STATUS( ENABLE_HTTP "http transports\t\t" LIBSOUP2_VERSION ) -IF( CMAKE_C_PLATFORM_ID STREQUAL "SunOS" ) - SHOW_STATUS( HAVE_LIBSOUP22_SOLARIS "libsoup 2.2 Solaris workaround" ) -ENDIF( CMAKE_C_PLATFORM_ID STREQUAL "SunOS" ) SHOW_STATUS( ENABLE_OBEX "obex transports\t\t" OPENOBEX_VERSION ) SHOW_STATUS( ENABLE_BLUETOOTH "obex over bluetooth transports" BLUEZ_VERSION ) SHOW_STATUS( ENABLE_BLUETOOTH_SDPLIB "bluetooth channel discovery\t" ) |
From: <svn...@op...> - 2009-03-18 10:51:02
|
Author: bellmich Date: Wed Mar 18 11:50:50 2009 New Revision: 989 URL: http://libsyncml.opensync.org/changeset/989 Log: added automatic localtime enforcement if the remote device sends a device information without UTC support Modified: trunk/libsyncml/data_sync_api/data_sync_devinf.c Modified: trunk/libsyncml/data_sync_api/data_sync_devinf.c ============================================================================== --- trunk/libsyncml/data_sync_api/data_sync_devinf.c Tue Mar 17 19:15:41 2009 (r988) +++ trunk/libsyncml/data_sync_api/data_sync_devinf.c Wed Mar 18 11:50:50 2009 (r989) @@ -744,9 +744,22 @@ */ goto error; } else { - /* check if there was an error during DevInfLoadRemote */ + /* check if there was an error during DevInfLoadRemote + * or dsObject->handleRemoteDevInfCallback + */ if (*error != NULL) goto error; + /* if the remote peer does not support UTC + * then dsObject must be configured properly + */ + if (dsObject->remoteDevInf && + !smlDevInfSupportsUTC(dsObject->remoteDevInf)) + { + smlTrace(TRACE_INTERNAL, + "%s: enforcing localtime because of remote DevInf", + __func__); + dsObject->onlyLocaltime = TRUE; + } } smlTrace(TRACE_EXIT, "%s - TRUE", __func__); |
From: <svn...@op...> - 2009-03-17 18:15:52
|
Author: bellmich Date: Tue Mar 17 19:15:41 2009 New Revision: 988 URL: http://libsyncml.opensync.org/changeset/988 Log: - added workaround for libsoup 2.2 http clients under Solaris (asynchronous http client support does not work under Solaris) - some cosmetical changes for http server code (traces, comments, assertions) Modified: trunk/CMakeLists.txt trunk/config.h.cmake trunk/libsyncml/transports/http_client.c trunk/libsyncml/transports/http_client_internals.h trunk/libsyncml/transports/http_server.c Modified: trunk/CMakeLists.txt ============================================================================== --- trunk/CMakeLists.txt Tue Mar 17 17:52:03 2009 (r987) +++ trunk/CMakeLists.txt Tue Mar 17 19:15:41 2009 (r988) @@ -118,6 +118,7 @@ SET( ENABLE_WBXML ON) ENDIF(LIBWBXML2_FOUND) +OPTION( HAVE_LIBSOUP22_SOLARIS "enable Solaris libsoup workarounds" OFF ) IF(LIBSOUP2_FOUND) OPTION( ENABLE_HTTP "enable http transports" ON ) IF (LIBSOUP24_FOUND) @@ -126,6 +127,9 @@ ELSE (LIBSOUP24_FOUND) OPTION ( HAVE_LIBSOUP24 "building with libsoup 2.4" OFF ) OPTION ( HAVE_LIBSOUP22 "building with libsoup 2.2" ON ) + IF( CMAKE_C_PLATFORM_ID STREQUAL "SunOS" ) + OPTION( HAVE_LIBSOUP22_SOLARIS "enable Solaris libsoup workarounds" ON ) + ENDIF( CMAKE_C_PLATFORM_ID STREQUAL "SunOS" ) ENDIF (LIBSOUP24_FOUND) ELSE(LIBSOUP2_FOUND) SET( ENABLE_HTTP OFF ) @@ -243,6 +247,9 @@ SHOW_STATUS( THREAD_SAFE_CHECK "check is thread safe\t\t" CHECK_VERSION ) SHOW_STATUS( ENABLE_WBXML "WAP Binary XML\t\t" LIBWBXML2_VERSION ) SHOW_STATUS( ENABLE_HTTP "http transports\t\t" LIBSOUP2_VERSION ) +IF( CMAKE_C_PLATFORM_ID STREQUAL "SunOS" ) + SHOW_STATUS( HAVE_LIBSOUP22_SOLARIS "libsoup 2.2 Solaris workaround" ) +ENDIF( CMAKE_C_PLATFORM_ID STREQUAL "SunOS" ) SHOW_STATUS( ENABLE_OBEX "obex transports\t\t" OPENOBEX_VERSION ) SHOW_STATUS( ENABLE_BLUETOOTH "obex over bluetooth transports" BLUEZ_VERSION ) SHOW_STATUS( ENABLE_BLUETOOTH_SDPLIB "bluetooth channel discovery\t" ) Modified: trunk/config.h.cmake ============================================================================== --- trunk/config.h.cmake Tue Mar 17 17:52:03 2009 (r987) +++ trunk/config.h.cmake Tue Mar 17 19:15:41 2009 (r988) @@ -10,6 +10,7 @@ #cmakedefine ENABLE_HTTP /* libsoup version in use */ +#cmakedefine HAVE_LIBSOUP22_SOLARIS #cmakedefine HAVE_LIBSOUP22 #cmakedefine HAVE_LIBSOUP24 Modified: trunk/libsyncml/transports/http_client.c ============================================================================== --- trunk/libsyncml/transports/http_client.c Tue Mar 17 17:52:03 2009 (r987) +++ trunk/libsyncml/transports/http_client.c Tue Mar 17 19:15:41 2009 (r988) @@ -262,8 +262,12 @@ { if (env->cafile != NULL && strlen(env->cafile)) { +#ifdef HAVE_LIBSOUP22_SOLARIS + env->session = soup_session_sync_new_with_options( +#else env->session = soup_session_async_new_with_options( SOUP_SESSION_ASYNC_CONTEXT, env->tsp->context, +#endif SOUP_SESSION_PROXY_URI, env->proxy, SOUP_SESSION_SSL_CA_FILE, env->cafile, NULL); @@ -272,21 +276,33 @@ * FIXME: http://bugzilla.gnome.org/show_bug.cgi?id=547881 */ } else { +#ifdef HAVE_LIBSOUP22_SOLARIS + env->session = soup_session_sync_new_with_options( +#else env->session = soup_session_async_new_with_options( SOUP_SESSION_ASYNC_CONTEXT, env->tsp->context, +#endif SOUP_SESSION_PROXY_URI, env->proxy, NULL); } } else { if (env->cafile != NULL && strlen(env->cafile)) { +#ifdef HAVE_LIBSOUP22_SOLARIS + env->session = soup_session_sync_new_with_options( +#else env->session = soup_session_async_new_with_options( SOUP_SESSION_ASYNC_CONTEXT, env->tsp->context, +#endif SOUP_SESSION_SSL_CA_FILE, env->cafile, NULL); } else { +#ifdef HAVE_LIBSOUP22_SOLARIS + env->session = soup_session_sync_new_with_options( +#else env->session = soup_session_async_new_with_options( SOUP_SESSION_ASYNC_CONTEXT, env->tsp->context, +#endif NULL); } } @@ -427,7 +443,13 @@ smlTrace(TRACE_INTERNAL, "%s: data length: %i", __func__, msg->request_body->length); #endif +#ifdef HAVE_LIBSOUP22_SOLARIS + soup_session_send_message(env->session, msg); + smlTransportHttpClientCallback(msg, userdata); + g_object_unref(msg); /* synchronous mode !!! */ +#else soup_session_queue_message(env->session, msg, smlTransportHttpClientCallback, userdata); +#endif smlTrace(TRACE_EXIT, "%s", __func__); return; @@ -482,6 +504,10 @@ CHECK_ERROR_REF smlAssert(tsp); +#ifdef HAVE_LIBSOUP22_SOLARIS + smlTrace(TRACE_INTERNAL, "%s: Enabled libsoup 2.2 Solaris workarounds", __func__); +#endif + tsp->functions.set_config_option = smlTransportHttpClientSetConfigOption; tsp->functions.set_response_uri = smlTransportHttpClientSetResponseURI; tsp->functions.disconnect = smlTransportHttpClientDisconnect; Modified: trunk/libsyncml/transports/http_client_internals.h ============================================================================== --- trunk/libsyncml/transports/http_client_internals.h Tue Mar 17 17:52:03 2009 (r987) +++ trunk/libsyncml/transports/http_client_internals.h Tue Mar 17 19:15:41 2009 (r988) @@ -22,7 +22,12 @@ #ifndef _HTTP_CLIENT_INTERNALS_H_ #define _HTTP_CLIENT_INTERNALS_H_ +#ifdef HAVE_LIBSOUP22_SOLARIS +#include <libsoup/soup-session-sync.h> +#else #include <libsoup/soup-session-async.h> +#endif + #include <libsoup/soup-uri.h> #ifndef HAVE_LIBSOUP22 #include <libsoup/soup-auth.h> Modified: trunk/libsyncml/transports/http_server.c ============================================================================== --- trunk/libsyncml/transports/http_server.c Tue Mar 17 17:52:03 2009 (r987) +++ trunk/libsyncml/transports/http_server.c Tue Mar 17 19:15:41 2009 (r988) @@ -173,7 +173,7 @@ smlErrorDeref(&error); } -#else /* !HAVE_LIBSOUP22 */ +#else /* !HAVE_LIBSOUP22 == libsoup 2.4 */ static void smlTransportHttpServerCallback( SoupServer *server, @@ -361,6 +361,7 @@ smlTrace(TRACE_ENTRY, "%s(%p, %p)", __func__, tsp, error); CHECK_ERROR_REF smlAssert(tsp); + smlAssert(tsp->context); smlAssert(tsp->transport_data); SmlTransportHttpServerEnv *env = tsp->transport_data; @@ -796,6 +797,7 @@ SmlBool smlTransportHttpServerNew(SmlTransport *tsp, SmlError **error) { + smlTrace(TRACE_ENTRY, "%s(%p, %p)", __func__, tsp, error); CHECK_ERROR_REF smlAssert(tsp); @@ -814,6 +816,7 @@ env->sessionToUri = g_hash_table_new(g_direct_hash, g_direct_equal); env->uriToLink = g_hash_table_new_full(g_str_hash, g_str_equal, smlTransportHttpServerFreeResponseURI, NULL); + smlTrace(TRACE_EXIT, "%s", __func__); return TRUE; } |
From: <svn...@op...> - 2009-03-17 16:52:14
|
Author: bellmich Date: Tue Mar 17 17:52:03 2009 New Revision: 987 URL: http://libsyncml.opensync.org/changeset/987 Log: fixed compiler warning on 64 bit integer Modified: trunk/tests/check_libsoup.c Modified: trunk/tests/check_libsoup.c ============================================================================== --- trunk/tests/check_libsoup.c Tue Mar 17 16:56:52 2009 (r986) +++ trunk/tests/check_libsoup.c Tue Mar 17 17:52:03 2009 (r987) @@ -155,7 +155,7 @@ /* wait until message was received by server */ - int64_t sleep_max = 5000000000; + int64_t sleep_max = 5000000000LL; int64_t sleep_interval = 50000000; int64_t sleep_total = 0; while (server_messages < 1 && server_errors < 1 && sleep_total < sleep_max) |
From: <svn...@op...> - 2009-03-17 15:57:00
|
Author: bellmich Date: Tue Mar 17 16:56:52 2009 New Revision: 986 URL: http://libsyncml.opensync.org/changeset/986 Log: own thread and ctx for HTTP client Modified: trunk/tests/check_libsoup.c Modified: trunk/tests/check_libsoup.c ============================================================================== --- trunk/tests/check_libsoup.c Tue Mar 17 16:39:45 2009 (r985) +++ trunk/tests/check_libsoup.c Tue Mar 17 16:56:52 2009 (r986) @@ -132,8 +132,13 @@ /* create asynchronous client */ + GMainContext *client_ctx = g_main_context_new(); + sml_fail_unless(client_ctx != NULL, NULL); + SmlThread *client_thread = smlThreadNew(client_ctx, &error); + sml_fail_unless(client_thread != NULL, "%s", smlErrorPrint(&error)); + smlThreadStart(client_thread); SoupSession *session = soup_session_async_new_with_options( - SOUP_SESSION_ASYNC_CONTEXT, ctx, + SOUP_SESSION_ASYNC_CONTEXT, client_ctx, SOUP_SESSION_TIMEOUT, 5, NULL); sml_fail_unless(session != NULL, NULL); @@ -168,6 +173,10 @@ /* cleanup */ soup_session_abort(session); g_object_unref(session); + smlThreadStop(client_thread); + smlThreadFree(client_thread); + g_main_context_unref(client_ctx); + smlThreadStop(thread); smlThreadFree(thread); g_main_context_unref(ctx); |
From: <svn...@op...> - 2009-03-17 15:40:01
|
Author: bellmich Date: Tue Mar 17 16:39:45 2009 New Revision: 985 URL: http://libsyncml.opensync.org/changeset/985 Log: added error message for old libsoup 2.2 implementations Modified: trunk/tests/check_libsoup.c Modified: trunk/tests/check_libsoup.c ============================================================================== --- trunk/tests/check_libsoup.c Tue Mar 17 16:35:50 2009 (r984) +++ trunk/tests/check_libsoup.c Tue Mar 17 16:39:45 2009 (r985) @@ -161,6 +161,7 @@ /* check counter */ + sml_fail_unless(sleep_total < sleep_max, "timeout detected"); sml_fail_unless(server_messages == 1, NULL); sml_fail_unless(server_errors == 0, NULL); |
From: <svn...@op...> - 2009-03-17 15:36:15
|
Author: bellmich Date: Tue Mar 17 16:35:50 2009 New Revision: 984 URL: http://libsyncml.opensync.org/changeset/984 Log: try to fix core dump on Solaris Modified: trunk/tests/support.h Modified: trunk/tests/support.h ============================================================================== --- trunk/tests/support.h Tue Mar 17 16:00:49 2009 (r983) +++ trunk/tests/support.h Tue Mar 17 16:35:50 2009 (r984) @@ -51,8 +51,9 @@ g_static_mutex_lock(&__libsyncml_check_mutex);\ fail_unless(_result, ## __VA_ARGS__);\ g_static_mutex_unlock(&__libsyncml_check_mutex);\ - if (!_result) smlAssertMsg(0, g_strdup_printf(__VA_ARGS__));\ } + // disabled to avoid unwanted aborts + // if (!_result) smlAssertMsg(0, g_strdup_printf(__VA_ARGS__));\ #endif /* THREAD_SAFE_CHECK */ |
From: <svn...@op...> - 2009-03-17 15:01:00
|
Author: bellmich Date: Tue Mar 17 16:00:49 2009 New Revision: 983 URL: http://libsyncml.opensync.org/changeset/983 Log: added timeout in the while loop of the client Modified: trunk/tests/check_libsoup.c trunk/tests/support.c trunk/tests/support.h Modified: trunk/tests/check_libsoup.c ============================================================================== --- trunk/tests/check_libsoup.c Tue Mar 17 14:04:24 2009 (r982) +++ trunk/tests/check_libsoup.c Tue Mar 17 16:00:49 2009 (r983) @@ -150,9 +150,13 @@ /* wait until message was received by server */ - while (server_messages < 1 && server_errors < 1) + int64_t sleep_max = 5000000000; + int64_t sleep_interval = 50000000; + int64_t sleep_total = 0; + while (server_messages < 1 && server_errors < 1 && sleep_total < sleep_max) { - usleep(50); + sml_sleep(sleep_interval); + sleep_total += sleep_interval; } /* check counter */ Modified: trunk/tests/support.c ============================================================================== --- trunk/tests/support.c Tue Mar 17 14:04:24 2009 (r982) +++ trunk/tests/support.c Tue Mar 17 16:00:49 2009 (r983) @@ -145,3 +145,13 @@ return parser; } + +int sml_sleep(int64_t nanoseconds) +{ + long seconds = nanoseconds / 1000000000; + nanoseconds = nanoseconds % 1000000000; + struct timespec timestr; + timestr.tv_sec = seconds; + timestr.tv_nsec = nanoseconds; + return nanosleep(×tr, NULL); +} Modified: trunk/tests/support.h ============================================================================== --- trunk/tests/support.h Tue Mar 17 14:04:24 2009 (r982) +++ trunk/tests/support.h Tue Mar 17 16:00:49 2009 (r983) @@ -28,6 +28,7 @@ void destroy_testbed(char *path); void create_case(Suite *s, const char *name, TFun function); SmlParser *start_parser(const char *data, SmlError **error); +int sml_sleep(int64_t nanoseconds); #ifdef THREAD_SAFE_CHECK |
From: <svn...@op...> - 2009-03-17 13:04:40
|
Author: bellmich Date: Tue Mar 17 14:04:24 2009 New Revision: 982 URL: http://libsyncml.opensync.org/changeset/982 Log: added timeout to asynchronous http client session Modified: trunk/tests/check_libsoup.c Modified: trunk/tests/check_libsoup.c ============================================================================== --- trunk/tests/check_libsoup.c Tue Mar 17 13:05:21 2009 (r981) +++ trunk/tests/check_libsoup.c Tue Mar 17 14:04:24 2009 (r982) @@ -130,10 +130,11 @@ smlThreadStart(thread); - /* create synchonous client */ + /* create asynchronous client */ SoupSession *session = soup_session_async_new_with_options( SOUP_SESSION_ASYNC_CONTEXT, ctx, + SOUP_SESSION_TIMEOUT, 5, NULL); sml_fail_unless(session != NULL, NULL); SoupMessage *msg = soup_message_new (SOUP_METHOD_POST, "http://127.0.0.1:13001/"); @@ -177,8 +178,6 @@ //Suite *s2 = suite_create("libsoup validation"); create_case(s, "libsoup_async", libsoup_async); - //create_case(s, "libsoup_async_server", libsoup_async_server); - //create_case(s, "libsoup_async_client", libsoup_async_client); return s; } |
From: <svn...@op...> - 2009-03-17 13:02:40
|
Author: henrik Date: Tue Mar 17 14:02:07 2009 New Revision: 5294 URL: http://www.opensync.org/changeset/5294 Log: Look for Thunderbird in /usr/lib64/mozilla-thunderbird/include/ for Gentoo Modified: branches/3rd-party-cmake-modules/modules/FindThunderbirdXpcom.cmake Modified: branches/3rd-party-cmake-modules/modules/FindThunderbirdXpcom.cmake ============================================================================== --- branches/3rd-party-cmake-modules/modules/FindThunderbirdXpcom.cmake Tue Mar 17 13:51:16 2009 (r5293) +++ branches/3rd-party-cmake-modules/modules/FindThunderbirdXpcom.cmake Tue Mar 17 14:02:07 2009 (r5294) @@ -40,6 +40,7 @@ /sw/include/ /usr/local/include/ /usr/include/ + /usr/lib64/mozilla-thunderbird/include/ ) IF ( NOT THUNDERBIRD_XPCOM_MAIN_INCLUDE_DIR ) MESSAGE ( FATAL_ERROR "*** *** Did not find Thunderbird include directory with mozilla-config.h" ) |
From: <svn...@op...> - 2009-03-17 12:51:58
|
Author: henrik Date: Tue Mar 17 13:51:16 2009 New Revision: 5293 URL: http://www.opensync.org/changeset/5293 Log: Link libxpcomglue_s for Thunderbird 3 Modified: branches/3rd-party-cmake-modules/modules/FindThunderbirdXpcom.cmake Modified: branches/3rd-party-cmake-modules/modules/FindThunderbirdXpcom.cmake ============================================================================== --- branches/3rd-party-cmake-modules/modules/FindThunderbirdXpcom.cmake Tue Mar 17 12:10:16 2009 (r5292) +++ branches/3rd-party-cmake-modules/modules/FindThunderbirdXpcom.cmake Tue Mar 17 13:51:16 2009 (r5293) @@ -75,6 +75,30 @@ # Usually the only library we need is the xpcom SET ( THUNDERBIRD_XPCOM_LIBRARIES "xpcom" ) + + # For Thunderbird 3.0 we need to link the glue library + EXEC_PROGRAM ( thunderbird ARGS "--version" + OUTPUT_VARIABLE _THUNDERBIRD_VERSION + RETURN_VALUE _THUNDERBIRD_VERSION_RET ) + + IF ( _THUNDERBIRD_VERSION_RET ) + EXEC_PROGRAM ( icedove ARGS "--version" + OUTPUT_VARIABLE _THUNDERBIRD_VERSION + RETURN_VALUE _THUNDERBIRD_VERSION_RET ) + ENDIF ( _THUNDERBIRD_VERSION_RET ) + + IF ( NOT _THUNDERBIRD_VERSION_RET ) + + STRING ( REGEX MATCH ".*([0-9]\\.[0-9]).*" _THUNDERBIRD_VERSION_OK "${_THUNDERBIRD_VERSION}" ) + IF ( _THUNDERBIRD_VERSION_OK ) + STRING ( REGEX REPLACE ".*([0-9]\\.[0-9]).*" "\\1" THUNDERBIRD_VERSION "${_THUNDERBIRD_VERSION}" ) + MESSAGE ( STATUS "THUNDERBIRD_VERSION [${THUNDERBIRD_VERSION}]" ) + IF ( THUNDERBIRD_VERSION STREQUAL "3.0" ) + SET ( THUNDERBIRD_XPCOM_LIBRARIES "xpcomglue_s;xpcom" ) + ENDIF ( THUNDERBIRD_VERSION STREQUAL "3.0" ) + ENDIF ( _THUNDERBIRD_VERSION_OK ) + ENDIF ( NOT _THUNDERBIRD_VERSION_RET ) + ENDIF( THUNDERBIRD_XPCOM_FOUND ) # So, by now we should have the following variables set: |
From: <svn...@op...> - 2009-03-17 12:05:24
|
Author: bellmich Date: Tue Mar 17 13:05:21 2009 New Revision: 981 URL: http://libsyncml.opensync.org/changeset/981 Log: fixed client callback for libsoup 2.2 Modified: trunk/tests/check_libsoup.c Modified: trunk/tests/check_libsoup.c ============================================================================== --- trunk/tests/check_libsoup.c Tue Mar 17 12:58:54 2009 (r980) +++ trunk/tests/check_libsoup.c Tue Mar 17 13:05:21 2009 (r981) @@ -92,7 +92,7 @@ static void client_callback(SoupSession *session, SoupMessage *msg, gpointer userdata) #endif { - smlTrace(TRACE_ENTRY, "%s(%p, %p)", __func__, session, msg); + smlTrace(TRACE_ENTRY, "%s(%p)", __func__, msg); smlTrace(TRACE_EXIT, "%s", __func__); } |
From: <svn...@op...> - 2009-03-17 11:59:08
|
Author: bellmich Date: Tue Mar 17 12:58:54 2009 New Revision: 980 URL: http://libsyncml.opensync.org/changeset/980 Log: added code for asynchronous http client Modified: trunk/tests/check_libsoup.c Modified: trunk/tests/check_libsoup.c ============================================================================== --- trunk/tests/check_libsoup.c Mon Mar 16 17:22:06 2009 (r979) +++ trunk/tests/check_libsoup.c Tue Mar 17 12:58:54 2009 (r980) @@ -86,6 +86,16 @@ smlTrace(TRACE_EXIT, "%s", __func__); } +#ifdef HAVE_LIBSOUP22 +static void client_callback(SoupMessage *msg, gpointer userdata) +#else +static void client_callback(SoupSession *session, SoupMessage *msg, gpointer userdata) +#endif +{ + smlTrace(TRACE_ENTRY, "%s(%p, %p)", __func__, session, msg); + smlTrace(TRACE_EXIT, "%s", __func__); +} + START_TEST (libsoup_async) { init_testbed(); @@ -122,9 +132,11 @@ /* create synchonous client */ - SoupSession *session = soup_session_sync_new (); + SoupSession *session = soup_session_async_new_with_options( + SOUP_SESSION_ASYNC_CONTEXT, ctx, + NULL); sml_fail_unless(session != NULL, NULL); - SoupMessage *msg = soup_message_new (SOUP_METHOD_GET, "http://127.0.0.1:13001/"); + SoupMessage *msg = soup_message_new (SOUP_METHOD_POST, "http://127.0.0.1:13001/"); soup_message_headers_append(msg->request_headers, "Accept", "text/plain"); soup_message_set_request (msg, "text/plain", #ifdef HAVE_LIBSOUP22 @@ -133,7 +145,7 @@ SOUP_MEMORY_TAKE, #endif g_memdup("test", 4), 4); - soup_session_send_message (session, msg); + soup_session_queue_message(session, msg, client_callback, NULL); /* wait until message was received by server */ @@ -165,6 +177,8 @@ //Suite *s2 = suite_create("libsoup validation"); create_case(s, "libsoup_async", libsoup_async); + //create_case(s, "libsoup_async_server", libsoup_async_server); + //create_case(s, "libsoup_async_client", libsoup_async_client); return s; } |
From: <svn...@op...> - 2009-03-17 11:10:29
|
Author: henrik Date: Tue Mar 17 12:10:16 2009 New Revision: 5292 URL: http://www.opensync.org/changeset/5292 Log: Updates for Thunderbird 3. It compiles, but a lot more work is needed in order to get to work. Added: plugins/mozilla-sync/trunk/tests/storage.sdb_10 (contents, props changed) Modified: plugins/mozilla-sync/trunk/CMakeLists.txt plugins/mozilla-sync/trunk/src/calendar-event.cpp plugins/mozilla-sync/trunk/src/mozilla-calendar.cpp plugins/mozilla-sync/trunk/src/mozilla-headers.h plugins/mozilla-sync/trunk/src/mozilla-utils.cpp plugins/mozilla-sync/trunk/src/mozilla-utils.h plugins/mozilla-sync/trunk/src/mozilla-xpcom.cpp plugins/mozilla-sync/trunk/src/thunderbird-addressbook.cpp plugins/mozilla-sync/trunk/src/thunderbird-addressbook.h plugins/mozilla-sync/trunk/src/thunderbird-card.cpp plugins/mozilla-sync/trunk/src/thunderbird-card.h plugins/mozilla-sync/trunk/tests/unit_test_abook.cpp plugins/mozilla-sync/trunk/tests/unit_test_xpcom.cpp Modified: plugins/mozilla-sync/trunk/CMakeLists.txt ============================================================================== --- plugins/mozilla-sync/trunk/CMakeLists.txt Fri Mar 13 13:38:53 2009 (r5291) +++ plugins/mozilla-sync/trunk/CMakeLists.txt Tue Mar 17 12:10:16 2009 (r5292) @@ -44,7 +44,8 @@ FIND_PACKAGE( OpenSync REQUIRED ) FIND_PACKAGE( ThunderbirdXpcom REQUIRED ) -STRING (REGEX REPLACE "[0-9]*\\.([0-9])*" "\\1" CALENDAR_VERSION "${SUNBIRD_VERSION}" ) +STRING (REGEX REPLACE "^([0-9]+)\\.([0-9]+)$" "\\1\\2" _CALENDAR_VERSION "${SUNBIRD_VERSION}" ) +STRING (REGEX REPLACE "^0*([0-9]+)$" "\\1" CALENDAR_VERSION "${_CALENDAR_VERSION}" ) MESSAGE ( "CALENDAR_VERSION=[${CALENDAR_VERSION}]" ) ### SEEMS THAT WE CANNOT LINK TO GLUE SINCE IT IS NOT THREAD SAFE, AND WE WILL SEGFAULT Modified: plugins/mozilla-sync/trunk/src/calendar-event.cpp ============================================================================== --- plugins/mozilla-sync/trunk/src/calendar-event.cpp Fri Mar 13 13:38:53 2009 (r5291) +++ plugins/mozilla-sync/trunk/src/calendar-event.cpp Tue Mar 17 12:10:16 2009 (r5292) @@ -7,7 +7,7 @@ See http://www.KaarPoSoft.dk/bluezync/ $Id$ - Copyright (C) 2007 Henrik Kaare Poulsen /KaarPoSoft + Copyright (C) 2007, 2008, 2009 Henrik Kaare Poulsen /KaarPoSoft This plugin is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by @@ -51,6 +51,9 @@ #elif CALENDAR_VERSION==9 #include <calbase/calITimezone.h> #include <calbase/calITimezoneProvider.h> +#elif CALENDAR_VERSION==10 +#include <calbase/calITimezone.h> +#include <calbase/calITimezoneProvider.h> #endif #include "mozilla-sync-utils.h" @@ -95,17 +98,14 @@ **/ nsCOMPtr<calIICSService> globalIcsService; -#if CALENDAR_VERSION==8 // ---------------------------------------- /** @brief Global holding Mozilla TimeZone service **/ +#if CALENDAR_VERSION==8 nsCOMPtr<calITimezoneService> globalTimezoneService; -#endif - -#if CALENDAR_VERSION==9 -// ---------------------------------------- -/** @brief Global holding Mozilla TimeZone service -**/ +#elif CALENDAR_VERSION==9 +nsCOMPtr<calITimezoneService> globalTimezoneService; +#elif CALENDAR_VERSION==10 nsCOMPtr<calITimezoneService> globalTimezoneService; #endif @@ -253,8 +253,15 @@ MOZ_ERROR_CHECK_FALSE(rv, "GetTimezone"); \ rv=calTimezone->ToString(acsTZ); \ MOZ_ERROR_CHECK_FALSE(rv, "GetTimezone->ToString"); +#elif CALENDAR_VERSION==10 +#define GET_TZ \ + nsCOMPtr<calITimezone> calTimezone; \ + rv=calDateTime->GetTimezone(getter_AddRefs(calTimezone)); \ + MOZ_ERROR_CHECK_FALSE(rv, "GetTimezone"); \ + rv=calTimezone->ToString(acsTZ); \ + MOZ_ERROR_CHECK_FALSE(rv, "GetTimezone->ToString"); #else -#error Only CALENDAR_VERSION 0.7, 0.8 and 0.9 are supported +#error Only CALENDAR_VERSION 0.7, 0.8, 0.9, and 1.0 are supported #endif // ---------------------------------------- @@ -334,8 +341,10 @@ rv=globalIcsService->ParseICS(acICS, NULL, getter_AddRefs(icsCalendar)); #elif CALENDAR_VERSION==9 rv=globalIcsService->ParseICS(acICS, NULL, getter_AddRefs(icsCalendar)); +#elif CALENDAR_VERSION==10 + rv=globalIcsService->ParseICS(acICS, NULL, getter_AddRefs(icsCalendar)); #else -#error Only CALENDAR_VERSION 0.7, 0.8, and 0.9 are supported +#error Only CALENDAR_VERSION 0.7, 0.8, 0.9, and 1.0 are supported #endif MOZ_ERROR_CHECK_FALSE(rv, "parseICS"); @@ -514,8 +523,14 @@ rv=globalTimezoneService->GetUTC(getter_AddRefs(calTimezone)); \ MOZ_ERROR_CHECK_FALSE(rv, "GetUTC"); \ rv=calDateTimeUTC->SetTimeInTimezone(statement->AsInt64(IDX), calTimezone); +#elif CALENDAR_VERSION==10 +#define SET_IN_TZ(IDX) \ + nsCOMPtr<calITimezone> calTimezone; \ + rv=globalTimezoneService->GetUTC(getter_AddRefs(calTimezone)); \ + MOZ_ERROR_CHECK_FALSE(rv, "GetUTC"); \ + rv=calDateTimeUTC->SetTimeInTimezone(statement->AsInt64(IDX), calTimezone); #else -#error Only CALENDAR_VERSION 0.7, 0.8 and 0.9 are supported +#error Only CALENDAR_VERSION 0.7, 0.8, 0.9 and 1.0 are supported #endif @@ -536,8 +551,13 @@ rv=globalTimezoneService->GetTimezone(NS_ConvertUTF16toUTF8(asTZ), getter_AddRefs(calTimezone)); \ MOZ_ERROR_CHECK_FALSE(rv, "GetTimezone"); \ rv=calDateTimeUTC->GetInTimezone(calTimezone, getter_AddRefs(calDateTimeTZ)); +#elif CALENDAR_VERSION==10 +#define GET_IN_TZ \ + rv=globalTimezoneService->GetTimezone(NS_ConvertUTF16toUTF8(asTZ), getter_AddRefs(calTimezone)); \ + MOZ_ERROR_CHECK_FALSE(rv, "GetTimezone"); \ + rv=calDateTimeUTC->GetInTimezone(calTimezone, getter_AddRefs(calDateTimeTZ)); #else -#error Only CALENDAR_VERSION 0.7, 0.8 and 0.9 are supported +#error Only CALENDAR_VERSION 0.7, 0.8, 0.9, and 1.0 are supported #endif @@ -567,8 +587,15 @@ rv=icsCalendar->AddTimezoneReference(calTimezone); \ MOZ_ERROR_CHECK_FALSE(rv, "AddTimezoneReference"); \ } +#elif CALENDAR_VERSION==10 +#define ADD_TZ_REF \ + rv=globalTimezoneService->GetTimezone(NS_ConvertUTF16toUTF8(asTZ), getter_AddRefs(calTimezone)); \ + if (NS_SUCCEEDED(rv)) { \ + rv=icsCalendar->AddTimezoneReference(calTimezone); \ + MOZ_ERROR_CHECK_FALSE(rv, "AddTimezoneReference"); \ + } #else -#error Only CALENDAR_VERSION 0.7, 0.8 and 0.9 are supported +#error Only CALENDAR_VERSION 0.7, 0.8, 0.9 and 1.0 are supported #endif @@ -643,9 +670,13 @@ globalTimezoneService=do_GetService("@mozilla.org/calendar/timezone-service;1", &rv); MOZ_ERROR_CHECK_FALSE(rv, "@mozilla.org/calendar/timezone-service;1"); } -#endif - -#if CALENDAR_VERSION==9 +#elif CALENDAR_VERSION==9 + if (!globalTimezoneService) { + LOG(10, "Getting TimeZone service"); + globalTimezoneService=do_GetService("@mozilla.org/calendar/timezone-service;1", &rv); + MOZ_ERROR_CHECK_FALSE(rv, "@mozilla.org/calendar/timezone-service;1"); + } +#elif CALENDAR_VERSION==10 if (!globalTimezoneService) { LOG(10, "Getting TimeZone service"); globalTimezoneService=do_GetService("@mozilla.org/calendar/timezone-service;1", &rv); Modified: plugins/mozilla-sync/trunk/src/mozilla-calendar.cpp ============================================================================== --- plugins/mozilla-sync/trunk/src/mozilla-calendar.cpp Fri Mar 13 13:38:53 2009 (r5291) +++ plugins/mozilla-sync/trunk/src/mozilla-calendar.cpp Tue Mar 17 12:10:16 2009 (r5292) @@ -8,7 +8,7 @@ See http://www.KaarPoSoft.dk/bluezync/ $Id$ - Copyright (C) 2007 Henrik Kaare Poulsen /KaarPoSoft + Copyright (C) 2007, 2008, 2009 Henrik Kaare Poulsen /KaarPoSoft This plugin is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by @@ -31,7 +31,6 @@ #include <nsEmbedString.h> #include <nsIArray.h> -#include <nsIURI.h> #include <nsIServiceManager.h> #include <nsServiceManagerUtils.h> Modified: plugins/mozilla-sync/trunk/src/mozilla-headers.h ============================================================================== --- plugins/mozilla-sync/trunk/src/mozilla-headers.h Fri Mar 13 13:38:53 2009 (r5291) +++ plugins/mozilla-sync/trunk/src/mozilla-headers.h Tue Mar 17 12:10:16 2009 (r5292) @@ -10,7 +10,7 @@ See http://www.KaarPoSoft.dk/bluezync/ $Id$ - Copyright (C) 2007 Henrik Kaare Poulsen /KaarPoSoft + Copyright (C) 2007, 2008, 2009 Henrik Kaare Poulsen /KaarPoSoft This plugin is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by @@ -37,7 +37,14 @@ #include <nsCOMPtr.h> #include <nsXPCOM.h> -#if 1 +/* Poor man's way of testing for Thunderbird 3 */ +#ifdef DECL_CLASS +#define TBIRD_3 3 +#endif + +#ifdef TBIRD_3 +#include <nsStringAPI.h> +#else #include <nsStringAPI.h> /** nsIABDirectory pulls in xpcom_obsolete/nsFileSpec.h. @@ -50,13 +57,6 @@ #define nsString_h___ #define nsReadableUtils_h___ // #define nsAString_h___ - -#else - -#define MOZILLA_INTERNAL_API -#include <string.h> -#include <nsStringAPI.h> - #endif Modified: plugins/mozilla-sync/trunk/src/mozilla-utils.cpp ============================================================================== --- plugins/mozilla-sync/trunk/src/mozilla-utils.cpp Fri Mar 13 13:38:53 2009 (r5291) +++ plugins/mozilla-sync/trunk/src/mozilla-utils.cpp Tue Mar 17 12:10:16 2009 (r5292) @@ -55,6 +55,13 @@ #include "mozilla-utils.h" +// The string functions below are defined in libxpcomglue, +// which is not linked by default. +// So we define them here. +// However, for Thunderbird 3 it seems we must link to libxpcomglue, +// so do NOT define them for Thunderbird 3 + +#ifndef TBIRD_3 PRUnichar* NS_strdup(const PRUnichar *aString) { @@ -84,3 +91,4 @@ return end - aString; } +#endif Modified: plugins/mozilla-sync/trunk/src/mozilla-utils.h ============================================================================== --- plugins/mozilla-sync/trunk/src/mozilla-utils.h Fri Mar 13 13:38:53 2009 (r5291) +++ plugins/mozilla-sync/trunk/src/mozilla-utils.h Tue Mar 17 12:10:16 2009 (r5292) @@ -10,7 +10,7 @@ See http://www.KaarPoSoft.dk/bluezync/ $Id$ - Copyright (C) 2007 Henrik Kaare Poulsen /KaarPoSoft + Copyright (C) 2007, 2008, 2009 Henrik Kaare Poulsen /KaarPoSoft This plugin is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by @@ -29,6 +29,15 @@ #include "mozilla-headers.h" + +// The string functions below are defined in libxpcomglue, +// which is not linked by default. +// So we define them here. +// However, for Thunderbird 3 it seems we must link to libxpcomglue, +// so do NOT define them for Thunderbird 3 + +#ifndef TB3 + /** * "strlen" for PRUnichar strings */ @@ -51,3 +60,4 @@ NS_strndup(const PRUnichar *aString, PRUint32 aLen); #endif +#endif Modified: plugins/mozilla-sync/trunk/src/mozilla-xpcom.cpp ============================================================================== --- plugins/mozilla-sync/trunk/src/mozilla-xpcom.cpp Fri Mar 13 13:38:53 2009 (r5291) +++ plugins/mozilla-sync/trunk/src/mozilla-xpcom.cpp Tue Mar 17 12:10:16 2009 (r5292) @@ -9,7 +9,7 @@ See http://www.KaarPoSoft.dk/bluezync/ $Id$ - Copyright (C) 2007 Henrik Kaare Poulsen /KaarPoSoft + Copyright (C) 2007, 2008, 2009 Henrik Kaare Poulsen /KaarPoSoft This plugin is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by @@ -43,7 +43,9 @@ #include <nsDirectoryServiceDefs.h> #include <nsISimpleEnumerator.h> #include <nsISupportsPrimitives.h> +#ifndef TBIRD_3 #include <nsIEventQueueService.h> +#endif #include <nsIXULAppInfo.h> #include <nsIExtensionManager.h> #include "nsProfileDirServiceProvider.h" @@ -56,29 +58,37 @@ void (*pLogFunction)(int level, bool sensitive, const char* szFile, int iLine, const char *szFunc, const char* szFormat, ...)) { nsresult rv; - LOG(10, "Getting version info"); + LOG(10, "Getting XULAppInfo"); nsCOMPtr<nsIXULAppInfo> xulAppInfo = do_GetService("@mozilla.org/xre/app-info;1", &rv); if (NS_SUCCEEDED(rv)) { LOG(10, "Got XULAppInfo"); - nsCString appName; - rv=xulAppInfo->GetName(appName); - LOG(10, "XULApp name [%s]", appName.get()); - nsCString appID; - rv=xulAppInfo->GetID(appID); - LOG(10, "XULApp ID [%s]", appID.get()); - nsCString appVersion; - rv=xulAppInfo->GetVersion(appVersion); - LOG(10, "XULApp version [%s]", appVersion.get()); - nsCString appPlatformVersion; - rv=xulAppInfo->GetVersion(appPlatformVersion); - LOG(10, "XULApp PlatformVersion [%s]", appPlatformVersion.get()); + nsCString cs; + const char *sz; + PRBool f; + rv=xulAppInfo->GetName(cs); + if (NS_SUCCEEDED(rv)) { + NS_CStringGetData(cs, &sz, &f); + LOG(10, "XULApp Name [%s]", sz); } + rv=xulAppInfo->GetID(cs); + if (NS_SUCCEEDED(rv)) { + NS_CStringGetData(cs, &sz, &f); + LOG(10, "XULApp ID [%s]", sz); } + rv=xulAppInfo->GetVersion(cs); + if (NS_SUCCEEDED(rv)) { + NS_CStringGetData(cs, &sz, &f); + LOG(10, "XULApp Version [%s]", sz); } + rv=xulAppInfo->GetVersion(cs); + if (NS_SUCCEEDED(rv)) { + NS_CStringGetData(cs, &sz, &f); + LOG(10, "XULApp PlatformVersion [%s]", sz); } } else { LOG(10, "Unable to get XULAppInfo"); //return FALSE; } + LOG(10, "Getting Version for Lightning"); nsCOMPtr<nsIExtensionManager> extensionManager = do_GetService("@mozilla.org/extensions/manager;1", &rv); if (NS_SUCCEEDED(rv)) { @@ -86,13 +96,19 @@ NS_NAMED_LITERAL_STRING(lightGUID, "{e2fda1a4-762b-4020-b5ad-a41df1933103}"); rv=extensionManager->GetItemForID(lightGUID, getter_AddRefs(updateItem)); if (NS_SUCCEEDED(rv)) { + LOG(10, "Got Version for Lightning"); nsString lightningVersion; rv=updateItem->GetVersion(lightningVersion); - LOG(10, "Lightning Version [%s]", lightningVersion.get()); + if (NS_SUCCEEDED(rv)) { + nsCString cs; + const char* sz; + PRBool f; + cs=NS_ConvertUTF16toUTF8(lightningVersion); + NS_CStringGetData(cs, &sz, &f); + LOG(10, "Lightning Version [%s]", sz); } } else { LOG(10, "No lightning extension"); } - } else { LOG(10, "Unable to get ExtensionManager"); //return FALSE; @@ -124,6 +140,15 @@ // (This may happen e.g. if called from within a thunderbird extension) // It seems that many things are initialized partly even before NS_InitXPCOM2 is called // But it looks like the event queue service is not, so we can use that + + // + // *** TODO Thunderbird 3 + // + // This trick does not work for Thunderbird 3. + // Need to find another trick! + // + +#ifndef TBIRD_3 nsCOMPtr<nsIEventQueueService> eventQService = do_GetService("@mozilla.org/event-queue-service;1", &rv); @@ -133,6 +158,8 @@ mozilla_getversion(pLogFunction); return TRUE; } +#endif + #ifdef XPCOM_GLUE LOG(10, "Starting up XPCOMGlue"); rv = XPCOMGlueStartup(nsnull); @@ -162,9 +189,14 @@ MOZ_ERROR_CHECK_FALSE(rv, "NS_NewNativeLocalFile for localFileGreDir"); nsString s; + nsCString cs; rv=localFileGreDir->GetPath(s); - MOZ_ERROR_CHECK_FALSE(rv, "GetPath"); - LOG(10, "GRE path: [%s]", NS_ConvertUTF16toUTF8(s).get()); + MOZ_ERROR_CHECK_FALSE(rv, "localFileGreDir->GetPath"); + cs=NS_ConvertUTF16toUTF8(s); + const char *sz; + PRBool f; + NS_CStringGetData(cs, &sz, &f); + LOG(10, "GRE path: [%s]", sz); LOG(10, "ProfileDir: [%s]", szProfileDirectory); nsCString csProfileDir; @@ -203,10 +235,12 @@ rv=registrar->AutoRegister(localFileGreComponents); //MOZ_ERROR_CHECK_FALSE(rv, "AutoRegister"); if (NS_FAILED(rv)) LOG(0, "AutoRegister failed. Continuing anyway..."); - nsString ss; - rv=localFileGreComponents->GetPath(ss); - LOG(10, "GRE component path: [%s]", NS_ConvertUTF16toUTF8(ss).get()); - MOZ_ERROR_CHECK_FALSE(rv, "NS_StringContainerInit"); + + rv=localFileGreComponents->GetPath(s); + MOZ_ERROR_CHECK_FALSE(rv, "localFileGreComponents->GetPath"); + cs=NS_ConvertUTF16toUTF8(s); + NS_CStringGetData(cs, &sz, &f); + LOG(10, "GRE component path: [%s]", sz); LOG(10, "GRE services registered"); Modified: plugins/mozilla-sync/trunk/src/thunderbird-addressbook.cpp ============================================================================== --- plugins/mozilla-sync/trunk/src/thunderbird-addressbook.cpp Fri Mar 13 13:38:53 2009 (r5291) +++ plugins/mozilla-sync/trunk/src/thunderbird-addressbook.cpp Tue Mar 17 12:10:16 2009 (r5292) @@ -9,7 +9,7 @@ See http://www.KaarPoSoft.dk/bluezync/ $Id$ - Copyright (C) 2007 Henrik Kaare Poulsen /KaarPoSoft + Copyright (C) 2007, 2008, 2009 Henrik Kaare Poulsen /KaarPoSoft This plugin is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by @@ -36,7 +36,15 @@ #include <nsServiceManagerUtils.h> #include <nsComponentManagerUtils.h> +#ifdef TBIRD_3 +#include <nsIFile.h> +#include <nsILocalFile.h> +#include <nsIAbManager.h> +#else +#include <nsIAddressBook.h> #include <nsIAbMDBCard.h> +#include <nsIFileSpec.h> +#endif #include "mozilla-sync-utils.h" #include "thunderbird-addressbook.h" @@ -56,8 +64,54 @@ void (*pLogFunction)(int level, bool sensitive, const char* szFile, int iLine, const char *szFunc, const char* szFormat, ...)) { nsresult rv; + PRBool f; + +#ifdef TBIRD_3 + + // See http://groups.google.com/group/mozilla.dev.apps.thunderbird/browse_thread/thread/39036007fed1c4ea# + + LOG(10, "Getting addressbook"); + + nsCOMPtr<nsIAbManager> abMgr(do_GetService("@mozilla.org/abmanager;1", &rv)); + MOZ_ERROR_CHECK_FALSE(rv, "do_GetService @mozilla.org/abmanager;1"); + + // This gets all address books which also forces an initialisation. + nsCOMPtr<nsISimpleEnumerator> directories; + + // + // *** TODO Thunderbird 3 + // + // Currently this fails with 0x080004005 (NS_ERROR_FAILURE) + // Still no answer on http://groups.google.com/group/mozilla.dev.apps.thunderbird/browse_thread/thread/39036007fed1c4ea# + // + + rv = abMgr->GetDirectories(getter_AddRefs(directories)); + MOZ_ERROR_CHECK_FALSE(rv, "nsIAbManager->GetDirectories"); + + gchar *szAB=g_strconcat("moz-abmdbdirectory://", szThunderbirdAddressbookFile, NULL); + nsCString csc; + rv = NS_CStringSetData(csc, szAB); + MOZ_ERROR_CHECK_FALSE(rv, "NS_CStringSetData"); + //nsCOMPtr<nsIAbDirectory> myAbDirectory; + rv = abMgr->GetDirectory(csc, getter_AddRefs(myAbDirectory)); + MOZ_ERROR_CHECK_FALSE(rv, "nsIAbManager->GetDirectory"); + + nsCString csURI; + rv=myAbDirectory->GetURI(csURI); + MOZ_ERROR_CHECK_FALSE(rv, "GetURI for nsIAbDirectory"); + const char *szURI; + NS_CStringGetData(csURI, &szURI, &f); + LOG(10, "AbDirectory URI [%s]", szURI); + + nsCString csFn; + rv=myAbDirectory->GetFileName(csFn); + MOZ_ERROR_CHECK_FALSE(rv, "GetFileName for nsIAbDirectory"); + const char *szFn; + NS_CStringGetData(csFn, &szFn, &f); + LOG(10, "AbDirectory filename [%s]", szFn); +#else LOG(10, "Getting addressbook"); nsCOMPtr<nsIRDFService> rdfService; rdfService=do_GetService("@mozilla.org/rdf/rdf-service;1", &rv); @@ -69,10 +123,12 @@ MOZ_ERROR_CHECK_FALSE(rv, "NS_CStringSetData"); rv=rdfService->GetResource(csc, getter_AddRefs(rs)); MOZ_ERROR_CHECK_FALSE(rv, "GetResource"); - mySzURI=csc.get(); + NS_CStringGetData(csc, &mySzURI, &f); LOG(10, "Resource URI [%s]", mySzURI); + myAbDirectory = do_QueryInterface(rs, &rv); MOZ_ERROR_CHECK_FALSE(rv, "do_QueryInterface for nsIAbDirectory"); +#endif // It seems that we can query the interface, // and also ask for all kinds of information @@ -81,6 +137,21 @@ // even if there is no addressbook at the specified URI. // So let's see if we can get child cards. // (Better to fail already now) + +#ifdef TBIRD_3 + nsCOMPtr<nsISimpleEnumerator> cards; + rv=myAbDirectory->GetChildCards(getter_AddRefs(cards)); + if (NS_FAILED(rv)) { + *pSzError=g_strdup_printf("%s(%d): Unable to get child cards. Address book is not valid [0x0%x]", __func__, __LINE__, rv ); + return FALSE; } + PRBool more; + rv=cards->HasMoreElements(&more); + if (NS_FAILED(rv)) { + *pSzError=g_strdup_printf("%s(%d): Unable to enumerate child cards. Address book is not valid [0x0%x]", __func__, __LINE__, rv ); + return FALSE; } + if (!more) + LOG(1, "WARNING: No address cards in address book"); +#else nsCOMPtr<nsIEnumerator> cards; rv=myAbDirectory->GetChildCards(getter_AddRefs(cards)); if (NS_FAILED(rv)) { @@ -92,14 +163,44 @@ rv=NS_OK; } else MOZ_ERROR_CHECK_FALSE(rv, "cards->First"); - +#endif + +#ifdef TBIRD_3 + + nsString sAB; + sAB=NS_ConvertUTF8toUTF16(szAB); + + nsCOMPtr<nsILocalFile> localFile; + localFile=do_CreateInstance("@mozilla.org/file/local;1", &rv); + MOZ_ERROR_CHECK_FALSE(rv, "do_CreateInstance for nsILocalFile"); + rv=localFile->InitWithPath(sAB); + MOZ_ERROR_CHECK_FALSE(rv, "init nsILocalFile"); + + nsCOMPtr<nsIFile> file; + rv=localFile->QueryInterface(NS_GET_IID(nsIFile), getter_AddRefs(file)); + MOZ_ERROR_CHECK_FALSE(rv, "do_QueryInterface for nsIFile"); + + LOG(10, "Getting DB1"); + myAddrDatabase=do_CreateInstance("@mozilla.org/carddatabase;1", &rv); + MOZ_ERROR_CHECK_FALSE(rv, "do_CreateInstance for nsIAddrDatabase"); + + LOG(10, "Getting database"); + rv=myAddrDatabase->OpenMDB(file, (PRBool) PR_FALSE); + MOZ_ERROR_CHECK_FALSE(rv, "database"); + +#else + nsCOMPtr<nsIAddressBook> addressBook; LOG(10, "Getting addressbook"); - myAddressBook=do_CreateInstance("@mozilla.org/addressbook;1", &rv); + addressBook=do_CreateInstance("@mozilla.org/addressbook;1", &rv); MOZ_ERROR_CHECK_FALSE(rv, "do_CreateInstance for nsIAddressBook"); LOG(10, "Getting database"); - rv=myAddressBook->GetAbDatabaseFromURI(szAB, getter_AddRefs(myAddrDatabase)); + rv=addressBook->GetAbDatabaseFromURI(szAB, getter_AddRefs(myAddrDatabase)); MOZ_ERROR_CHECK_FALSE(rv, "database"); + + +#endif + GFREE(szAB); LOG(10, "Addressbook initialized"); @@ -161,6 +262,20 @@ myPCurrentCard=NULL; nsCOMPtr<nsISupports> supp; nsCOMPtr<nsIAbCard> aCard; + +#ifdef TBIRD_3 + rv=myAbDirectory->GetChildCards(getter_AddRefs(myCards)); + MOZ_ERROR_CHECK_FALSE(rv, "nsIAbDirectory::GetChildCards"); + PRBool more; + rv=myCards->HasMoreElements(&more); + MOZ_ERROR_CHECK_FALSE(rv, "nsISimpleEnumerator::HasMoreElements"); + if (!more) { + LOG(1, "WARNING: No address cards in address book"); + return TRUE; + } + rv=myCards->GetNext(getter_AddRefs(supp)); + MOZ_ERROR_CHECK_FALSE(rv, "nsISimpleEnumerator::GetNext"); +#else rv=myAbDirectory->GetChildCards(getter_AddRefs(myCards)); MOZ_ERROR_CHECK_FALSE(rv, "nsIAbDirectory::GetChildCards"); rv=myCards->First(); @@ -170,6 +285,8 @@ MOZ_ERROR_CHECK_FALSE(rv, "nsIEnumerator::First"); rv=myCards->CurrentItem(getter_AddRefs(supp)); MOZ_ERROR_CHECK_FALSE(rv, "nsIEnumerator::CurrentItem"); +#endif + rv=supp->QueryInterface(NS_GET_IID(nsIAbCard), getter_AddRefs(aCard)); MOZ_ERROR_CHECK_FALSE(rv, "nsISupportsQueryInterface"); myPCurrentCard = new ThunderbirdCard(aCard); @@ -192,11 +309,21 @@ myPCurrentCard=NULL; nsCOMPtr<nsISupports> supp; nsCOMPtr<nsIAbCard> aCard; + +#ifdef TBIRD_3 + PRBool more; + rv=myCards->HasMoreElements(&more); + MOZ_ERROR_CHECK_FALSE(rv, "nsISimpleEnumerator::HasMoreElements"); + if (!more) return TRUE; // No more cards + rv=myCards->GetNext(getter_AddRefs(supp)); + MOZ_ERROR_CHECK_FALSE(rv, "nsISimpleEnumerator::GetNext"); +#else rv=myCards->Next(); if (rv==NS_ERROR_INVALID_POINTER) return TRUE; // No more cards MOZ_ERROR_CHECK_FALSE(rv, "nsIEnumerator::Next"); rv=myCards->CurrentItem(getter_AddRefs(supp)); MOZ_ERROR_CHECK_FALSE(rv, "nsIEnumerator::CurrentItem"); +#endif rv=supp->QueryInterface(NS_GET_IID(nsIAbCard), getter_AddRefs(aCard)); MOZ_ERROR_CHECK_FALSE(rv, "nsISupportsQueryInterface"); myPCurrentCard = new ThunderbirdCard(aCard); @@ -242,9 +369,16 @@ rv=myAbDirectory->AddCard(pCard->myCard, getter_AddRefs(newCard)); MOZ_ERROR_CHECK_FALSE(rv, "AddCard"); +// +// *** TODO Thunderbird 3 +// +// We need to figure out how to put the card back in the database! +// + +#ifndef TBIRD_3 rv=newCard->EditCardToDatabase(mySzURI); MOZ_ERROR_CHECK_FALSE(rv, "nsIAbCard::EditCardToDatabase"); - +#endif // For some reason Commit here results in segmentation fault // rv=myAddrDatabase->Commit(nsAddrDBCommitType::kSmallCommit); // MOZ_ERROR_CHECK(rv, "Commit"); @@ -268,15 +402,32 @@ LOG(10, "Deleting card [%s]", szKey); nsresult rv; nsCOMPtr<nsIAbCard> theCard; +#ifdef TBIRD_3 + nsCString cs; + rv = NS_CStringSetData(cs, szKey); + MOZ_ERROR_CHECK_FALSE(rv, "NS_CStringSetData"); + rv=myAddrDatabase->GetCardFromAttribute(myAbDirectory, OPEN_SYNC_KEY, cs, PR_FALSE, getter_AddRefs(theCard)); +#else rv=myAddrDatabase->GetCardFromAttribute(myAbDirectory, OPEN_SYNC_KEY, szKey, PR_FALSE, getter_AddRefs(theCard)); +#endif MOZ_ERROR_CHECK_FALSE(rv, "GetCardFromAttribute"); if (!theCard) ERROR("Could not find card with key [%s] in Thunderbird Address-book", szKey); +#ifdef TBIRD_3 + rv=myAddrDatabase->DeleteCard(theCard, PR_FALSE, myAbDirectory); + MOZ_ERROR_CHECK_FALSE(rv, "DeleteCard"); +#else rv=myAddrDatabase->DeleteCard(theCard, PR_FALSE); - MOZ_ERROR_CHECK_FALSE(rv, "DropCard"); + MOZ_ERROR_CHECK_FALSE(rv, "DeleteCard"); +#endif +#ifdef TBIRD_3 + rv=myAbDirectory->ModifyCard(theCard); + MOZ_ERROR_CHECK_FALSE(rv, "modifyCard"); +#else rv=theCard->EditCardToDatabase(mySzURI); MOZ_ERROR_CHECK_FALSE(rv, "nsIAbCard::EditCardToDatabase"); +#endif rv=myAddrDatabase->Commit(nsAddrDBCommitType::kSmallCommit); MOZ_ERROR_CHECK_FALSE(rv, "Commit"); @@ -306,7 +457,16 @@ LOG(10, "Modifying card [%s]", szKey); nsresult rv; nsCOMPtr<nsIAbCard> theCard; + +#ifdef TBIRD_3 + nsCString cs; + rv = NS_CStringSetData(cs, szKey); + MOZ_ERROR_CHECK_FALSE(rv, "NS_CStringSetData"); + rv=myAddrDatabase->GetCardFromAttribute(myAbDirectory, OPEN_SYNC_KEY, cs, PR_FALSE, getter_AddRefs(theCard)); +#else rv=myAddrDatabase->GetCardFromAttribute(myAbDirectory, OPEN_SYNC_KEY, szKey, PR_FALSE, getter_AddRefs(theCard)); +#endif + MOZ_ERROR_CHECK_FALSE(rv, "GetCardFromAttribute"); if (!theCard) ERROR("Could not find card with key [%s] in Thunderbird Address-book", szKey); @@ -323,8 +483,15 @@ gboolean f; f=pCard->ResetFromXML(szXML, pSzError, pLogFunction); if (!f) return FALSE; + +#ifdef TBIRD_3 + rv=myAbDirectory->ModifyCard(theCard); + MOZ_ERROR_CHECK_FALSE(rv, "modifyCard"); +#else rv=theCard->EditCardToDatabase(mySzURI); MOZ_ERROR_CHECK_FALSE(rv, "nsIAbCard::EditCardToDatabase"); +#endif + rv=myAddrDatabase->Commit(nsAddrDBCommitType::kSmallCommit); MOZ_ERROR_CHECK_FALSE(rv, "Commit"); @@ -336,85 +503,3 @@ return TRUE; } - - -// ------------------------------------------------------------ -/** @brief Log contents of address book - just for debugging and fun - - @param pSzError Pointer to string, into which we shall write an error message if we return false - @param pLogFunction Function used to log information text - @return TRUE on success; FALSE on error -**/ -gboolean ThunderbirdAddressbook::LogInfo( - char **pSzError, - void (*pLogFunction)(int level, bool sensitive, const char* szFile, int iLine, const char *szFunc, const char* szFormat, ...)) -{ - nsresult rv; - LOG(10, "Listing first (up to) 10 address cards"); - if (!CardFirst(pSzError, pLogFunction)) return FALSE; - int i=0; - if (CardDone()) { - LOG(10, "No address cards in address book"); - } else { - while(!CardDone()) { - i++; - if (i>10) { - if (!CardNext(pSzError, pLogFunction)) return FALSE; - continue; } - ThunderbirdCard *pCard=CardCurrent(); - char *szKey=pCard->GetKey(myAddrDatabase, pSzError, pLogFunction); - if (!szKey) return FALSE; - char *szHash=pCard->GetHash(pSzError, pLogFunction); - if (!szHash) return FALSE; - char *szLongName=pCard->GetLongName(pSzError, pLogFunction); - if (!szLongName) return FALSE; - LOG(10, "%s [%s]: %s", szKey, szHash, szLongName); - free(szKey); free(szHash); free(szLongName); - char *szXML=pCard->GetXML(pSzError, pLogFunction); - if (!szXML) return FALSE; - LOG(10, szXML); - g_free(szXML); - if (!CardNext(pSzError, pLogFunction)) return FALSE; - } - } - LOG(10, "%d address cards listed", i); - // It does not seem that any of the below returns any usefull information !! - // Why? - LOG(10, "Getting AbDirectoryProperties"); - nsCOMPtr<nsIAbDirectoryProperties> directoryProperties; - rv=myAbDirectory->GetDirectoryProperties(getter_AddRefs(directoryProperties)); - MOZ_ERROR_CHECK_FALSE(rv, "GetDirectoryProperties"); - char *sz; - rv=directoryProperties->GetFileName(&sz); - MOZ_ERROR_CHECK_FALSE(rv, "directoryProperties->GetFileName"); - LOG(10, "File Name [%s]", sz); // Gennerally seems to be _nonascii - rv=directoryProperties->GetURI(&sz); - MOZ_ERROR_CHECK_FALSE(rv, "directoryProperties->GetURI"); - LOG(10, "URI [%s]", sz); // Gennerally seems to be _nonascii - rv=directoryProperties->GetPrefName(&sz); - MOZ_ERROR_CHECK_FALSE(rv, "directoryProperties->GetPrefName"); - LOG(10, "Pref Name [%s]", sz); // Gennerally seems to be _nonascii - nsString sc; - MOZ_ERROR_CHECK_FALSE(rv, "NS_StringContainerInit"); - rv=directoryProperties->GetDescription(sc); - MOZ_ERROR_CHECK_FALSE(rv, "directoryProperties->GetDescription"); - LOG(10, "Description [%s]", sc.get()); // Generally seems to be empty - directoryProperties=nsnull; - LOG(10, "Got AbDirectoryProperties"); - - LOG(10, "Address book info"); - PRUnichar *c16; - nsCString csc; - rv=myAbDirectory->GetDirName(&c16); - MOZ_ERROR_CHECK_FALSE(rv, "abDirectory->GetDirName"); - LOG(10, "DirName [%s]", NS_ConvertUTF16toUTF8(c16).get()); - rv=myAbDirectory->GetDescription(&c16); // Generally seems to be empty - MOZ_ERROR_CHECK_FALSE(rv, "abDirectory->GetDescription"); - LOG(10, "Description [%s]", NS_ConvertUTF16toUTF8(c16).get()); // Generally seems to be empty - rv=myAbDirectory->GetDirPrefId(csc); - MOZ_ERROR_CHECK_FALSE(rv, "abDirectory->GetDirPrefId"); - LOG(10, "DirPrefId [%s]", csc.get()); - LOG(10, "End of address book info"); - - return TRUE; -} Modified: plugins/mozilla-sync/trunk/src/thunderbird-addressbook.h ============================================================================== --- plugins/mozilla-sync/trunk/src/thunderbird-addressbook.h Fri Mar 13 13:38:53 2009 (r5291) +++ plugins/mozilla-sync/trunk/src/thunderbird-addressbook.h Tue Mar 17 12:10:16 2009 (r5292) @@ -10,7 +10,7 @@ See http://www.KaarPoSoft.dk/bluezync/ $Id$ - Copyright (C) 2007 Henrik Kaare Poulsen /KaarPoSoft + Copyright (C) 2007, 2008, 2009 Henrik Kaare Poulsen /KaarPoSoft This plugin is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by @@ -32,7 +32,6 @@ #include "mozilla-headers.h" #include <nsIAbDirectory.h> -#include <nsIAddressBook.h> #include <nsIAddrDatabase.h> #include "thunderbird-card.h" @@ -42,9 +41,12 @@ public: nsCOMPtr<nsIAbDirectory> myAbDirectory; - nsCOMPtr<nsIAddressBook> myAddressBook; nsCOMPtr<nsIAddrDatabase> myAddrDatabase; +#ifdef TBIRD_3 + nsCOMPtr<nsISimpleEnumerator> myCards; +#else nsCOMPtr<nsIEnumerator> myCards; +#endif public: Modified: plugins/mozilla-sync/trunk/src/thunderbird-card.cpp ============================================================================== --- plugins/mozilla-sync/trunk/src/thunderbird-card.cpp Fri Mar 13 13:38:53 2009 (r5291) +++ plugins/mozilla-sync/trunk/src/thunderbird-card.cpp Tue Mar 17 12:10:16 2009 (r5292) @@ -9,7 +9,7 @@ See http://www.KaarPoSoft.dk/bluezync/ $Id$ - Copyright (C) 2007 Henrik Kaare Poulsen /KaarPoSoft + Copyright (C) 2007, 2008, 2009 Henrik Kaare Poulsen /KaarPoSoft This plugin is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by @@ -36,7 +36,10 @@ #include "mozilla-headers.h" #include <nsComponentManagerUtils.h> + +#ifndef TBIRD_3 #include <nsIAbMDBCard.h> +#endif #include "mozilla-sync-utils.h" #include "thunderbird-card.h" @@ -55,6 +58,37 @@ #define ATTRIBUTE_EQUAL ((void*) 1) //!< Attribute value shall match specified value #define ATTRIBUTE_NOTEQUAL ((void*) 2) //!< Attribute muat be absent or NOT match specified value +#ifdef TBIRD_3 +#define SET_PROPERTY(card, property, sz) { \ + nsString s; \ + s=NS_ConvertUTF8toUTF16(sz); \ + rv=card->SetPropertyAsAString(property, s); \ + MOZ_ERROR_CHECK_FALSE(rv, "SetPropertyAsAString"); \ + /* free? */ } +#else +#define SET_PROPERTY(card, property, sz) { \ + PRUnichar *c16=NS_strdup(NS_ConvertUTF8toUTF16(sz).get()); \ + rv=card->SetCardValue(property, c16); \ + NS_Free(c16); } +#endif + +#ifdef TBIRD_3 +#define GET_PROPERTY(card, property, sz) { \ + nsString s; \ + s=NS_ConvertUTF8toUTF16(sz); \ + rv=card->GetPropertyAsAString(property, s); \ + /* free? */ } +#else +#define GET_PROPERTY(card, property, sz) { \ + PRUnichar *u16; \ + rv=card->GetCardValue(property, &u16); \ + MOZ_ERROR_CHECK(rv, "nsIAbCard::GetCardValue"); \ + sz=g_strdup(NS_ConvertUTF16toUTF8(u16).get()); \ + NS_Free(u16); } +#endif + + + /** One attribute to set or check in xmlformat-card **/ typedef struct _XMLAttributeDef { @@ -379,9 +413,17 @@ char *sz0=(char*)xmlNodeGetContent(xNode); char *sz=g_strstrip(sz0); LOG_SENSITIVE(1000, "Value %s", sz); +#ifdef TBIRD_3 + nsString s; + s=NS_ConvertUTF8toUTF16(sz); + MOZ_ERROR_CHECK_FALSE(rv, "NS_ConvertUTF8toUTF16"); + rv=myCard->SetPropertyAsAString(pXmlEntryDef->szProperty, s); +#else PRUnichar *c16=NS_strdup(NS_ConvertUTF8toUTF16(sz).get()); rv=myCard->SetCardValue(pXmlEntryDef->szProperty, c16); NS_Free(c16); +#endif + SET_PROPERTY(myCard, pXmlEntryDef->szProperty, sz); xmlFree(sz0); MOZ_ERROR_CHECK_FALSE(rv, "nsIAbCard::SetCardValue"); @@ -419,11 +461,7 @@ LOG(1000, "Setting %s", pXmlEntryDef->szProperty); char *sz=g_strstrip((char*)xmlNodeGetContent(pChildNode)); LOG_SENSITIVE(1000, "Value %s", sz); - PRUnichar *c16=NS_strdup(NS_ConvertUTF8toUTF16(sz).get()); - rv=myCard->SetCardValue(pXmlEntryDef->szProperty, c16); - MOZ_ERROR_CHECK_FALSE(rv, "nsIAbCard::SetCardValue"); - NS_Free(c16); - + SET_PROPERTY(myCard, pXmlEntryDef->szProperty, sz); goto next_node; } } @@ -442,6 +480,24 @@ // if it is not already set if (!g_hash_table_lookup(pHashTableProperties, (void*)"DisplayName")) { LOG(30, "Setting DisplayName"); +#ifdef TBIRD_3 + + nsString fn; + rv=myCard->GetPropertyAsAString("FirstName", fn); + MOZ_ERROR_CHECK_FALSE(rv, "nsIAbCard::GetPropertyAsAString FirstName"); + nsString ln; + rv=myCard->GetPropertyAsAString("LastName", ln); + MOZ_ERROR_CHECK_FALSE(rv, "nsIAbCard::GetPropertyAsAString LastName"); + + nsString dn; + dn.Assign(fn); + dn.Append(0x20); + dn.Append(ln); + + rv=myCard->SetPropertyAsAString("DisplayName", dn); + MOZ_ERROR_CHECK_FALSE(rv, "SetPropertyAsAString"); \ + +#else PRUnichar *pruFirstName; rv=myCard->GetCardValue("FirstName", &pruFirstName); MOZ_ERROR_CHECK_FALSE(rv, "nsIAbCard::GetCardValue First Name"); @@ -460,6 +516,7 @@ NS_Free(pruFirstName); NS_Free(pruLastName); NS_Free(pruDisplayName); +#endif } g_hash_table_destroy(pHashTableNodes); @@ -508,7 +565,8 @@ void (*pLogFunction)(int level, bool sensitive, const char* szFile, int iLine, const char *szFunc, const char* szFormat, ...)) { nsresult rv; - nsCOMPtr<nsIAbMDBCard> abMDBCard; + + nsCOMPtr<nsIAbCard> abCard; LOG(10, "Creating nsIAbCard from xmlformat-card\n"); myCard=do_CreateInstance("@mozilla.org/addressbook/moz-abmdbcard;1", &rv); @@ -544,6 +602,24 @@ char **pSzError, void (*pLogFunction)(int level, bool sensitive, const char* szFile, int iLine, const char *szFunc, const char* szFormat, ...)) { + +// +// *** TODO Thunderbird 3 +// +// Need to figure out a way to get key in Thunderbird 3 +// Watch https://bugzilla.mozilla.org/show_bug.cgi?id=444093 +// + + +#ifdef TBIRD_3 + + nsresult rv; + nsCString cs; + rv=myCard->GetPropertyAsAUTF8String(OPEN_SYNC_KEY, cs); + MOZ_ERROR_CHECK(rv, "nsIAbMDBCard::GetStringAttribute"); + +#else + nsresult rv; char *c8; @@ -582,6 +658,7 @@ LOG(30, "Key=[%s]", c8); return c8; +#endif } @@ -600,41 +677,15 @@ void (*pLogFunction)(int level, bool sensitive, const char* szFile, int iLine, const char *szFunc, const char* szFormat, ...)) { nsresult rv; +#ifdef TBIRD_3 + gchar *sz; + GET_PROPERTY(myCard, "LastModifiedDate", sz) +#else PRUint32 kk; rv=myCard->GetLastModifiedDate(&kk); MOZ_ERROR_CHECK(rv, "nsIAbCard::GetLastModifiedDate"); return g_strdup_printf("%d", kk); -} - - -// ---------------------------------------- -/** @brief Get a strange name, only useful for debugging... - - @param pSzError Pointer to string, into which we shall write an error message if we return false - @param pLogFunction Function used to log information text - @return string on success; NULL on error -**/ -gchar* ThunderbirdCard::GetLongName( - char **pSzError, - void (*pLogFunction)(int level, bool sensitive, const char* szFile, int iLine, const char *szFunc, const char* szFormat, ...)) -{ - nsresult rv; - PRUnichar *dn16; - rv=myCard->GetDisplayName(&dn16); - MOZ_ERROR_CHECK(rv, "nsIAbCard::GetDisplayName"); - char *dn8=strdup(NS_ConvertUTF16toUTF8(dn16).get()); - PRUnichar *ln16; - rv=myCard->GetLastName(&ln16); - MOZ_ERROR_CHECK(rv, "nsIAbCard::GetLastName"); - char *ln8=strdup(NS_ConvertUTF16toUTF8(ln16).get()); - PRUnichar *fn16; - rv=myCard->GetFirstName(&fn16); - MOZ_ERROR_CHECK(rv, "nsIAbCard::GetFirstName"); - char *fn8=strdup(NS_ConvertUTF16toUTF8(fn16).get()); - - gchar* szResult=g_strdup_printf("[%s] [%s, %s]", dn8, ln8, fn8); - free(dn8); free(ln8); free(fn8); - return szResult; +#endif } @@ -684,11 +735,11 @@ gboolean groupWritten=FALSE; XMLEntryDef *pXmlEntryDef; for (pXmlEntryDef=&(pXmlGroupDef->xmlEntryDef[0]); pXmlEntryDef->szEntry; pXmlEntryDef++) { - PRUnichar *u16; - rv=myCard->GetCardValue(pXmlEntryDef->szProperty, &u16); - MOZ_ERROR_CHECK(rv, "nsIAbCard::GetCardValue"); - char *sz=g_strdup(NS_ConvertUTF16toUTF8(u16).get()); - if (*u16) { + + char *sz; + GET_PROPERTY(myCard, pXmlEntryDef->szProperty, sz); + + if (*sz) { if (!groupWritten) { rc = xmlTextWriterStartElement(writer, BAD_CAST pXmlGroupDef->szGroup); RC_ERROR_CHECK(buf,"xmlTextWriterStartElement: Error at xmlTextWriterStartElement\n"); Modified: plugins/mozilla-sync/trunk/src/thunderbird-card.h ============================================================================== --- plugins/mozilla-sync/trunk/src/thunderbird-card.h Fri Mar 13 13:38:53 2009 (r5291) +++ plugins/mozilla-sync/trunk/src/thunderbird-card.h Tue Mar 17 12:10:16 2009 (r5292) @@ -32,6 +32,7 @@ #include "mozilla-headers.h" +#include <nsIAddrDatabase.h> #include <nsIAbCard.h> Added: plugins/mozilla-sync/trunk/tests/storage.sdb_10 ============================================================================== Binary file. No diff available. Modified: plugins/mozilla-sync/trunk/tests/unit_test_abook.cpp ============================================================================== --- plugins/mozilla-sync/trunk/tests/unit_test_abook.cpp Fri Mar 13 13:38:53 2009 (r5291) +++ plugins/mozilla-sync/trunk/tests/unit_test_abook.cpp Tue Mar 17 12:10:16 2009 (r5292) @@ -30,17 +30,19 @@ #include <mozilla-headers.h> #include <mozilla-xpcom.h> -#if 0 -#include <nsServiceManagerUtils.h> -#include <nsIDirectoryService.h> #include <nsIProperties.h> -#include <nsAppDirectoryServiceDefs.h> -#include <nsIComponentRegistrar.h> -#endif +#include <nsIDirectoryService.h> #include <nsComponentManagerUtils.h> +#ifdef TBIRD_3 +#include <nsServiceManagerUtils.h> +#include <nsAppDirectoryServiceDefs.h> +#include <nsIFile.h> +#include <nsILocalFile.h> +#else #include <nsDirPrefs.h> #include <nsIAddressBook.h> +#endif #include "thunderbird-addressbook.h" #include "thunderbird-card.h" @@ -76,6 +78,52 @@ f=mozilla_startup(szTmp, &fWasStarted, &szError, &logFunction); fail_unless(f, "mozilla_startup failed: %s", szError); + +#ifdef TBIRD_3 + +/* + nsCOMPtr<nsILocalFile> localFile; + localFile=do_CreateInstance("@mozilla.org/file/local;1", &rv); + fail_unless(NS_SUCCEEDED(rv), "do_CreateInstance for nsILocalFile returned [0x0%x]", rv); + rv=localFile->InitWithPath(NS_LITERAL_STRING("moz-abmdbdirectory://test.mab")); + fail_unless(NS_SUCCEEDED(rv), "InitWithPath for nsILocalFile returned [0x0%x]", rv); + + rv=localFile->QueryInterface(NS_GET_IID(nsIFile), getter_AddRefs(file)); + fail_unless(NS_SUCCEEDED(rv), "QueryInterface for nsILocalFile to nsIFile returned [0x0%x]", rv); +*/ +/* + nsCOMPtr<nsIFile> file; + nsCOMPtr<nsIDirectoryServiceProvider> dirService; + PRBool persistent; + dirService=do_GetService("@mozilla.org/file/directory_service;1", &rv); + fail_unless(NS_SUCCEEDED(rv), "do_GetService for nsIDirectoryServiceProvider returned [0x0%x]", rv); + +// rv=dirService->GetFile(NS_APP_USER_PROFILE_50_DIR, &persistent, getter_AddRefs(file)); + rv=dirService->GetFile("GreD", &persistent, getter_AddRefs(file)); + fail_unless(NS_SUCCEEDED(rv), "GetFile for nsIDirectoryServiceProvider returned [0x0%x]", rv); +*/ + + char *szAbook = g_strconcat(szTmp, G_DIR_SEPARATOR_S, "abook.mab", NULL); + nsCString csAbook; + rv = NS_CStringSetData(csAbook, szAbook); + fail_unless(NS_SUCCEEDED(rv), "NS_CStringSetData for csAbook returned [0x0%x]", rv); + nsCOMPtr<nsILocalFile> localFileAbook; + rv = NS_NewNativeLocalFile(csAbook, PR_FALSE, getter_AddRefs(localFileAbook)); + + nsCOMPtr<nsIFile> file; + rv=localFileAbook->QueryInterface(NS_GET_IID(nsIFile), getter_AddRefs(file)); + fail_unless(NS_SUCCEEDED(rv), "QueryInterface for nsILocalFile to nsIFile returned [0x0%x]", rv); + + + nsCOMPtr<nsIAddrDatabase> addrDatabase; + addrDatabase=do_CreateInstance("@mozilla.org/addressbook/carddatabase;1", &rv); + fail_unless(NS_SUCCEEDED(rv), "do_CreateInstance for nsIAddrDatabase returned [0x0%x]", rv); + + rv=addrDatabase->OpenMDB(file, (PRBool) PR_TRUE); + fail_unless(NS_SUCCEEDED(rv), "OpenMDB for nsIAddrDatabase returned [0x0%x]", rv); + +#else + nsCOMPtr<nsIAddressBook> ab=do_CreateInstance("@mozilla.org/addressbook;1", &rv); fail_unless(NS_SUCCEEDED(rv), "do_CreateInstance for nsIAddressBook returned [0x0%x]", rv); @@ -91,6 +139,8 @@ rv=ab->NewAddressBook(abDirProps); fail_unless(NS_SUCCEEDED(rv), "NewAddressBook returned [0x0%x]", rv); +#endif + f=mozilla_shutdown(&szError, &logFunction); fail_unless(f, "mozilla_shutdown failed: %s", szError); } END_TEST @@ -108,8 +158,11 @@ f=mozilla_startup(szTmp, &fWasStarted, &szError, &logFunction); fail_unless(f, "mozilla_startup failed: %s", szError); +printf("===========================================\n"); ThunderbirdAddressbook *pAb=new ThunderbirdAddressbook(); +printf("===========================================\n"); f=pAb->Init("abook.mab", &szError, &logFunction); +printf("===========================================\n"); fail_unless(f, "could not open addressbook: %s", szError); f=mozilla_shutdown(&szError, &logFunction); @@ -197,7 +250,7 @@ tcase_add_test (tc_core, test_abook_open); tcase_add_test (tc_core, test_abook_findnonexistent); tcase_add_test (tc_core, test_abook_addcard); - tcase_add_test (tc_core, test_abook_cleanup); + //tcase_add_test (tc_core, test_abook_cleanup); suite_add_tcase (s, tc_core); return s; } Modified: plugins/mozilla-sync/trunk/tests/unit_test_xpcom.cpp ============================================================================== --- plugins/mozilla-sync/trunk/tests/unit_test_xpcom.cpp Fri Mar 13 13:38:53 2009 (r5291) +++ plugins/mozilla-sync/trunk/tests/unit_test_xpcom.cpp Tue Mar 17 12:10:16 2009 (r5292) @@ -35,6 +35,8 @@ #include <nsIProperties.h> #include <nsAppDirectoryServiceDefs.h> #include <nsIComponentRegistrar.h> +#include <nsISimpleEnumerator.h> +#include "nsISupportsPrimitives.h" #define MOZ_ERROR_CHECK(rv, str) \ @@ -59,6 +61,8 @@ nsresult rv; nsString sc; + nsCString cs; + PRBool f; const char *sz; nsCOMPtr<nsIProperties> directoryService; nsCOMPtr<nsIFile> file; @@ -71,7 +75,10 @@ rv=file->GetPath(sc); MOZ_ERROR_CHECK(rv, "GetPath for Profile"); - sz=NS_ConvertUTF16toUTF8(sc).get(); + //sz=NS_ConvertUTF16toUTF8(sc).get(); + cs=NS_ConvertUTF16toUTF8(sc); + NS_CStringGetData(cs, &sz, &f); + if ( strcmp(sz, szExpectedProfile) != 0) { *pSzError=g_strdup_printf( \ "%s(%d): Got Profile path [%s]; expected [%s]", __func__, __LINE__, sz, szExpectedProfile); @@ -83,7 +90,8 @@ rv=file->GetPath(sc); MOZ_ERROR_CHECK(rv, "GetPath for Preferences"); - sz=NS_ConvertUTF16toUTF8(sc).get(); + cs=NS_ConvertUTF16toUTF8(sc); + NS_CStringGetData(cs, &sz, &f); if ( strcmp(sz, szExpectedPreferences) != 0) { *pSzError=g_strdup_printf( \ "%s(%d): Got Preference path [%s]; expected [%s]", __func__, __LINE__, sz, szExpectedPreferences); @@ -117,11 +125,21 @@ // Some of the contract IDs we need. // Guess that if those are there, probably the rest are as well... const char *aszContractIDs[] = { + +// +// *** *** Todo Thunderbird 3 +// + +#ifdef TBIRD_3 +// "@mozilla.org/carddatabase;1", + "@mozilla.org/file/local;1", +#else "@mozilla.org/rdf/rdf-service;1", "@mozilla.org/addressbook;1", "@mozilla.org/addressbook/carddatabase;1", - "@mozilla.org/addressbook/moz-abmdbcard;1", "@mozilla.org/rdf/resource-factory;1?name=moz-abmdbdirectory", + "@mozilla.org/addressbook/moz-abmdbcard;1", +#endif NULL }; // ------------------------------------------------------------ @@ -156,6 +174,58 @@ } END_TEST // ------------------------------------------------------------ +START_TEST (test_xpcom_allcomponents) { + + fail_unless(szTmp!=NULL, "unable to create temporary directory"); + + nsresult rv; + char *szError=NULL; + gboolean f; + + gboolean fWasStarted; + f=mozilla_startup(szTmp, &fWasStarted, &szError, &logFunction); + fail_unless(f, "mozilla_startup failed: %s", szError); + + nsCOMPtr<nsIServiceManager> servMan; + rv = NS_GetServiceManager(getter_AddRefs(servMan)); + fail_unless(NS_SUCCEEDED(rv), "NS_GetServiceManager returned [0x0%x]", rv); + nsCOMPtr<nsIComponentRegistrar> registrar = do_QueryInterface(servMan, &rv); + fail_unless(NS_SUCCEEDED(rv), "do_QueryInterface for nsIComponentRegistrar returned [0x0%x]", rv); + + printf("Enumerating component ContractIDs\n"); + + nsCOMPtr<nsISimpleEnumerator> e; + rv=registrar->EnumerateContractIDs(getter_AddRefs(e)); + fail_unless(NS_SUCCEEDED(rv), "enumerateContractIDs returned [0x0%x]", rv); + + int n=0; + PRBool fm; + rv=e->HasMoreElements(&fm); + fail_unless(NS_SUCCEEDED(rv), "nsISimpleEnumerator::HasMoreElements returned [0x0%x]", rv); + while (fm) { + n++; + nsCOMPtr<nsISupports> s; + rv=e->GetNext(getter_AddRefs(s)); + fail_unless(NS_SUCCEEDED(rv), "nsISimpleEnumerator::GetNext returned [0x0%x]", rv); + nsCOMPtr<nsISupportsCString> scs = do_QueryInterface(s, &rv); + char* sz; + rv=scs->ToString(&sz); + fail_unless(NS_SUCCEEDED(rv), "ToString returned [0x0%x]", rv); + printf("\t%s\n", sz); + rv=e->HasMoreElements(&fm); + fail_unless(NS_SUCCEEDED(rv), "nsISimpleEnumerator::HasMoreElements returned [0x0%x]", rv); + } + + printf("Found %d component ContractIDs\n", n); + + int m=500; + fail_unless(n>m, "Only found %d components; expected at least %d", n, m); + + f=mozilla_shutdown(&szError, &logFunction); + fail_unless(f, "mozilla_shutdown failed: %s", szError); +} END_TEST + +// ------------------------------------------------------------ START_TEST (test_xpcom_cleanup) { // put it here instead of in teardown, so signals will be trapped // no error checking. If it does not work, what can we do anyway? @@ -170,6 +240,7 @@ tcase_add_unchecked_fixture (tc_core, fixture_setup, fixture_teardown); tcase_add_test (tc_core, test_xpcom_connect); tcase_add_test (tc_core, test_xpcom_components); + tcase_add_test (tc_core, test_xpcom_allcomponents); tcase_add_test (tc_core, test_xpcom_cleanup); suite_add_tcase (s, tc_core); return s; |
From: <svn...@op...> - 2009-03-16 16:22:22
|
Author: bellmich Date: Mon Mar 16 17:22:06 2009 New Revision: 979 URL: http://libsyncml.opensync.org/changeset/979 Log: added missing string protection in smlTrace Modified: trunk/libsyncml/parser/sml_xml_parse.c Modified: trunk/libsyncml/parser/sml_xml_parse.c ============================================================================== --- trunk/libsyncml/parser/sml_xml_parse.c Mon Mar 16 17:01:07 2009 (r978) +++ trunk/libsyncml/parser/sml_xml_parse.c Mon Mar 16 17:22:06 2009 (r979) @@ -2342,7 +2342,7 @@ goto error_free_status; } - smlTrace(TRACE_INTERNAL, "Got status %p with: cmdRef %i, msgRef %i, type %i, data %s", *status, (*status)->cmdRef, (*status)->msgRef, (*status)->type, (*status)->data); + smlTrace(TRACE_INTERNAL, "Got status %p with: cmdRef %i, msgRef %i, type %i, data %s", *status, (*status)->cmdRef, (*status)->msgRef, (*status)->type, VA_STRING((*status)->data)); smlTrace(TRACE_EXIT, "%s", __func__); return TRUE; |
From: <svn...@op...> - 2009-03-16 16:01:18
|
Author: bellmich Date: Mon Mar 16 17:01:07 2009 New Revision: 978 URL: http://libsyncml.opensync.org/changeset/978 Log: added code to test the transport layer context management Modified: trunk/tests/check_libsoup.c Modified: trunk/tests/check_libsoup.c ============================================================================== --- trunk/tests/check_libsoup.c Mon Mar 16 16:45:40 2009 (r977) +++ trunk/tests/check_libsoup.c Mon Mar 16 17:01:07 2009 (r978) @@ -19,6 +19,7 @@ */ #include "support.h" +#include <libsyncml/sml_queue_internals.h> #include <libsoup/soup-session-async.h> #include <libsoup/soup-uri.h> @@ -44,6 +45,13 @@ server_errors = 0; } +/* dummy callback for the transport queue */ +void transport_dummy_callback(void *message, void *userdata) +{ + /* this function should never be called */ + g_atomic_int_inc(&server_errors); +} + #ifdef HAVE_LIBSOUP22 static void server_callback(SoupServerContext *context, SoupMessage *msg, gpointer data) #else @@ -90,6 +98,13 @@ SmlThread *thread = smlThreadNew(ctx, &error); sml_fail_unless(thread != NULL, "%s", smlErrorPrint(&error)); + /* simulate the transport layer behaviour */ + + SmlQueue *queue = smlQueueNew(&error); + sml_fail_unless(queue != NULL, "%s", smlErrorPrint(&error)); + smlQueueSetHandler(queue, (SmlQueueHandler)transport_dummy_callback, NULL); + smlQueueAttach(queue, ctx); + /* create async server */ SoupServer *server = soup_server_new (SOUP_SERVER_PORT, 13001, SOUP_SERVER_ASYNC_CONTEXT, ctx, NULL); |