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-09-14 10:37:25
|
Author: bellmich Date: Mon Sep 14 12:37:09 2009 New Revision: 1265 URL: http://libsyncml.opensync.org/changeset/1265 Log: reverted a wrong change of r1253 It was only necessary to add one function to the internals header file. It was wrong to use another function. Modified: trunk/libsyncml/data_sync_api/sml_data_sync.c trunk/libsyncml/data_sync_api/sml_data_sync_session_internals.h Modified: trunk/libsyncml/data_sync_api/sml_data_sync.c ============================================================================== --- trunk/libsyncml/data_sync_api/sml_data_sync.c Mon Sep 14 12:34:56 2009 (r1264) +++ trunk/libsyncml/data_sync_api/sml_data_sync.c Mon Sep 14 12:37:09 2009 (r1265) @@ -908,7 +908,7 @@ case SML_MANAGER_SESSION_ERROR: case SML_MANAGER_SESSION_WARNING: smlTrace(TRACE_INTERNAL, "%s: forwarding session %p event %d", __func__, data_sync_session, type); - sml_data_sync_session_send_event(data_sync_session, NULL, type, error); + sml_data_sync_session_event_callback(data_sync_session, type, error); break; case SML_MANAGER_CONNECT_DONE: smlTrace(TRACE_INTERNAL, "%s: the transport was connected", __func__); Modified: trunk/libsyncml/data_sync_api/sml_data_sync_session_internals.h ============================================================================== --- trunk/libsyncml/data_sync_api/sml_data_sync_session_internals.h Mon Sep 14 12:34:56 2009 (r1264) +++ trunk/libsyncml/data_sync_api/sml_data_sync_session_internals.h Mon Sep 14 12:37:09 2009 (r1265) @@ -35,7 +35,8 @@ gboolean sml_data_sync_session_check (SmlDataSyncSession *self); gboolean sml_data_sync_session_dispatch (SmlDataSyncSession *self); -void sml_data_sync_session_send_event (SmlDataSyncSession *self, SmlDataSync *data_sync, SmlDataSyncEventType type, const GError *error); +void sml_data_sync_session_send_event (SmlDataSyncSession *self, SmlDataSync *data_sync, SmlDataSyncEventType type, const GError *error); +void sml_data_sync_session_event_callback (SmlDataSyncSession *self, SmlManagerEventType type, const GError *error); G_END_DECLS |
From: <svn...@op...> - 2009-09-14 10:35:07
|
Author: bellmich Date: Mon Sep 14 12:34:56 2009 New Revision: 1264 URL: http://libsyncml.opensync.org/changeset/1264 Log: SmlDataSyncSession should never include sml_data_sync_private.h. Modified: trunk/libsyncml/data_sync_api/sml_data_sync.c trunk/libsyncml/data_sync_api/sml_data_sync_internals.h trunk/libsyncml/data_sync_api/sml_data_sync_session.c Modified: trunk/libsyncml/data_sync_api/sml_data_sync.c ============================================================================== --- trunk/libsyncml/data_sync_api/sml_data_sync.c Mon Sep 14 11:24:28 2009 (r1263) +++ trunk/libsyncml/data_sync_api/sml_data_sync.c Mon Sep 14 12:34:56 2009 (r1264) @@ -523,6 +523,12 @@ return FALSE; } +gboolean +sml_data_sync_get_only_localtime (SmlDataSync *self) +{ + return self->priv->only_localtime; +} + /** * sml_data_sync_add_data_store: * @self: A #SmlDataSync @@ -745,6 +751,8 @@ return data_sync_session; } else { data_sync_session = sml_data_sync_session_new(session, self, error); + if (!data_sync_session) + return NULL; g_hash_table_insert(self->priv->data_sync_sessions, data_sync_session, data_sync_session); g_hash_table_insert(self->priv->sessions, session, data_sync_session); g_object_ref(data_sync_session); @@ -761,12 +769,77 @@ return self->priv->alert_callback; } +gboolean +sml_data_sync_configure_session (SmlDataSync *self, + SmlSession *session, + GError **error) +{ + smlTrace(TRACE_ENTRY, "%s (%p, %p, %p)", __func__, self, session, error); + CHECK_ERROR_REF + sml_return_val_error_if_fail (SML_IS_DATA_SYNC (self), FALSE, error, SML_ERROR_GENERIC, "There must be a SmlDataSync object."); + sml_return_val_error_if_fail (session, FALSE, error, SML_ERROR_GENERIC, "There must be a SmlSession object."); + + smlSessionUseStringTable(session, self->priv->use_string_table); + smlSessionUseOnlyReplace(session, self->priv->only_replace); + smlSessionUseNumberOfChanges(session, self->priv->use_number_of_changes); + + /* authentication management for OMA DS clients*/ + if (self->priv->session_type == SML_SESSION_TYPE_CLIENT && + (self->priv->username || self->priv->password)) + { + /* prepare credential */ + SmlCred *cred = smlCredNewAuth (self->priv->auth_type, + self->priv->username, + self->priv->password, + error); + if (!cred) { + smlTrace(TRACE_EXIT_ERROR, "%s - %s", __func__, (*error)->message); + return FALSE; + /* FIXME: Memory Leak !!! */ + } + + smlSessionRegisterCred(session, cred); + } + smlTrace(TRACE_EXIT, "%s - TRUE", __func__); + return TRUE; +} + +gboolean +sml_data_sync_disconnect_session (SmlDataSync *self, + SmlSession *session, + GError **error) +{ + SmlLink *link_ = smlManagerSessionGetLink (self->priv->manager, + session, + error); + if (!link_ && *error) + return FALSE; + + /* OBEX is a stateful protocol and the client should + * init the disconnect. The problem is what happens + * when the client hangs? + * + * if (dsObject->tspType != SML_TRANSPORT_OBEX_SERVER && + * !smlTransportDisconnect(dsObject->tsp, link, &error)) + */ + if (!smlTransportDisconnect(self->priv->tsp, link_, error)) + { + if (link_) + smlLinkDeref(link_); + return FALSE; + } + if (link_) + smlLinkDeref(link_); + + return TRUE; +} + /* *************************************** */ /* ***** Management Callback ***** */ /* *************************************** */ static void -sml_data_sync_disconnect_session (gpointer key, gpointer value, void *userdata) +sml_data_sync_disconnect_data_sync_session (gpointer key, gpointer value, void *userdata) { SmlDataSyncSession *dss = key; /* value is the same */ SmlDataSync *ds = userdata; @@ -865,7 +938,7 @@ self->priv->state < SML_DATA_SYNC_STATE_DISCONNECTED) { if (self->priv->state < SML_DATA_SYNC_STATE_DISCONNECT_IN_PROGRESS) { self->priv->state = SML_DATA_SYNC_STATE_DISCONNECT_IN_PROGRESS; - g_hash_table_foreach (self->priv->data_sync_sessions, sml_data_sync_disconnect_session, self); + g_hash_table_foreach (self->priv->data_sync_sessions, sml_data_sync_disconnect_data_sync_session, self); } else { /* disconnect failed */ self->priv->state = SML_DATA_SYNC_STATE_DISCONNECTED; Modified: trunk/libsyncml/data_sync_api/sml_data_sync_internals.h ============================================================================== --- trunk/libsyncml/data_sync_api/sml_data_sync_internals.h Mon Sep 14 11:24:28 2009 (r1263) +++ trunk/libsyncml/data_sync_api/sml_data_sync_internals.h Mon Sep 14 12:34:56 2009 (r1264) @@ -56,10 +56,14 @@ SmlDataSyncDataStore* sml_data_sync_get_data_store_from_local_uri (SmlDataSync *self, const gchar *local, GError **error); SmlDataSyncSession* sml_data_sync_get_session (SmlDataSync *self, SmlSession *session, GError **error); +gboolean sml_data_sync_configure_session (SmlDataSync *self, SmlSession *session, GError **error); +gboolean sml_data_sync_disconnect_session (SmlDataSync *self, SmlSession *session, GError **error); SmlDataSyncSessionEventCallback sml_data_sync_get_event_callback (SmlDataSync *self); void* sml_data_sync_get_event_userdata (SmlDataSync *self); +gboolean sml_data_sync_get_only_localtime (SmlDataSync *self); + SmlDsSessionAlertCb sml_data_sync_get_alert_callback (SmlDataSync *self); G_END_DECLS Modified: trunk/libsyncml/data_sync_api/sml_data_sync_session.c ============================================================================== --- trunk/libsyncml/data_sync_api/sml_data_sync_session.c Mon Sep 14 11:24:28 2009 (r1263) +++ trunk/libsyncml/data_sync_api/sml_data_sync_session.c Mon Sep 14 12:34:56 2009 (r1264) @@ -22,9 +22,6 @@ #include "sml_data_sync_data_store_session_internals.h" #include "data_sync_devinf.h" -/* FIXME: !!!!!!! */ -#include "sml_data_sync_private.h" - #include "sml_data_sync_internals.h" #include "../sml_support.h" #include "../sml_error_internals.h" @@ -158,6 +155,7 @@ SmlDataSync *data_sync, GError **error) { + smlTrace(TRACE_ENTRY, "%s (%p, %p, %p)", __func__, session, data_sync, error); CHECK_ERROR_REF sml_return_val_error_if_fail (session != NULL, NULL, error, SML_ERROR_GENERIC, "There must be a SmlSession object."); sml_return_val_error_if_fail (SML_IS_DATA_SYNC (data_sync), NULL, error, SML_ERROR_GENERIC, "There must be a SmlDataSync object."); @@ -167,26 +165,13 @@ self->priv->session = session; self->priv->data_sync = data_sync; self->priv->actual_package = SML_PACKAGE_0; - self->priv->only_localtime = data_sync->priv->only_localtime; + self->priv->only_localtime = sml_data_sync_get_only_localtime(data_sync); - smlSessionUseStringTable(session, data_sync->priv->use_string_table); - smlSessionUseOnlyReplace(session, data_sync->priv->only_replace); - smlSessionUseNumberOfChanges(session, data_sync->priv->use_number_of_changes); - - /* authentication management for OMA DS clients*/ - if (data_sync->priv->session_type == SML_SESSION_TYPE_CLIENT && - (data_sync->priv->username || data_sync->priv->password)) + if (!sml_data_sync_configure_session(data_sync, session, error)) { - /* prepare credential */ - SmlCred *cred = smlCredNewAuth(data_sync->priv->auth_type, - data_sync->priv->username, data_sync->priv->password, - error); - if (!cred) - return NULL; - /* FIXME: Memory Leak !!! */ - - smlSessionRegisterCred(self->priv->session, cred); - smlTrace(TRACE_INTERNAL, "%s: credential initialized", __func__); + g_object_unref(self); + smlTrace(TRACE_EXIT_ERROR, "%s - %s", __func__, (*error)->message); + return NULL; } self->priv->hash_ds2dsdss = g_hash_table_new_full(g_direct_hash, @@ -201,6 +186,7 @@ g_direct_equal, sml_data_sync_session_free_data_store_session, sml_data_sync_session_free_data_store_session); + smlTrace(TRACE_EXIT, "%s - %p", __func__, self); return self; } @@ -421,13 +407,7 @@ { self->priv->state = SML_DATA_SYNC_STATE_DISCONNECT_IN_PROGRESS; - SmlLink *link_ = smlManagerSessionGetLink(self->priv->data_sync->priv->manager, - self->priv->session, - error); - if (!link_ && *error) - goto error; - - if (!smlTransportDisconnect(self->priv->data_sync->priv->tsp, link_, error)) + if (!sml_data_sync_disconnect_session (self->priv->data_sync, self->priv->session, error)) goto error; } //} @@ -538,10 +518,6 @@ case SML_MANAGER_SESSION_NEW: smlTrace(TRACE_INTERNAL, "%s: Just received a new session with ID %d.", __func__, smlSessionGetSessionID(self->priv->session)); - - smlTrace(TRACE_INTERNAL, "%s: maxObjSize %d", - __func__, self->priv->data_sync->priv->max_obj_size); - break; case SML_MANAGER_SESSION_FINAL: smlTrace(TRACE_INTERNAL, "%s: Session %d reported final.", @@ -549,7 +525,7 @@ /* determine which package was received */ - if (self->priv->data_sync->priv->session_type == SML_SESSION_TYPE_CLIENT) + if (sml_data_sync_get_session_type(self->priv->data_sync) == SML_SESSION_TYPE_CLIENT) { /* only devinf receiving is not supported */ if (self->priv->actual_package < SML_PACKAGE_1) @@ -640,27 +616,8 @@ /* initiate disconnect */ - SmlLink *link_ = smlManagerSessionGetLink( - self->priv->data_sync->priv->manager, - self->priv->session, - &locerror); - if (!link_ && locerror) - goto error; - /* OBEX is a stateful protocol and the client should - * init the disconnect. The problem is what happens - * when the client hangs? - * - * if (dsObject->tspType != SML_TRANSPORT_OBEX_SERVER && - * !smlTransportDisconnect(dsObject->tsp, link, &error)) - */ - if (!smlTransportDisconnect(self->priv->data_sync->priv->tsp, link_, &locerror)) - { - if (link_) - smlLinkDeref(link_); + if (!sml_data_sync_disconnect_session (self->priv->data_sync, self->priv->session, &locerror)) goto error; - } - if (link_) - smlLinkDeref(link_); sml_data_sync_session_send_event(self, NULL, SML_DATA_SYNC_SESSION_EVENT_FINISHED, NULL); break; |
From: <svn...@op...> - 2009-09-14 09:24:46
|
Author: bellmich Date: Mon Sep 14 11:24:28 2009 New Revision: 1263 URL: http://libsyncml.opensync.org/changeset/1263 Log: fixed several compiler warnings Modified: trunk/libsyncml/data_sync_api/sml_data_sync.c trunk/libsyncml/data_sync_api/sml_data_sync.h trunk/libsyncml/data_sync_api/sml_data_sync_data_store.c trunk/libsyncml/data_sync_api/sml_data_sync_data_store_session.c trunk/libsyncml/data_sync_api/sml_data_sync_session.c trunk/libsyncml/sml_session.c trunk/libsyncml/sml_transport.c trunk/libsyncml/transports/obex_server.c trunk/tests/check_data_sync_api.c trunk/tests/check_devinf.c trunk/tests/check_ds.c trunk/tests/check_http.c trunk/tests/check_manager.c trunk/tests/check_obex.c trunk/tests/check_session.c trunk/tests/check_sync.c trunk/tests/mobiles/obex_mobile_ds_client.c trunk/tests/support.c trunk/tests/support.h Modified: trunk/libsyncml/data_sync_api/sml_data_sync.c ============================================================================== --- trunk/libsyncml/data_sync_api/sml_data_sync.c Sat Sep 12 16:48:23 2009 (r1262) +++ trunk/libsyncml/data_sync_api/sml_data_sync.c Mon Sep 14 11:24:28 2009 (r1263) @@ -296,7 +296,7 @@ SmlTransportType type, GError **error) { - g_return_if_fail (SML_IS_DATA_SYNC (self)); + sml_return_val_error_if_fail (SML_IS_DATA_SYNC (self), FALSE, error, SML_ERROR_GENERIC, "There must be a SmlDataSync object."); self->priv->tsp_type = type; self->priv->tsp = smlTransportNew(self->priv->tsp_type, error); @@ -357,7 +357,7 @@ SmlSessionType type, GError **error) { - g_return_if_fail (SML_IS_DATA_SYNC (self)); + sml_return_val_error_if_fail (SML_IS_DATA_SYNC (self), FALSE, error, SML_ERROR_GENERIC, "There must be a SmlDataSync object."); self->priv->session_type = type; switch(self->priv->session_type) @@ -529,15 +529,17 @@ * @ds: A #SmlDataSyncDataStore * */ -void +gboolean sml_data_sync_add_data_store (SmlDataSync *self, - SmlDataSyncDataStore *ds) + SmlDataSyncDataStore *ds, + GError **error) { - g_return_if_fail (SML_IS_DATA_SYNC (self)); - g_return_if_fail (SML_IS_DATA_SYNC_DATA_STORE (ds)); + sml_return_val_error_if_fail (SML_IS_DATA_SYNC (self), FALSE, error, SML_ERROR_GENERIC, "There must be a SmlDataSync object."); + sml_return_val_error_if_fail (SML_IS_DATA_SYNC_DATA_STORE (ds), FALSE, error, SML_ERROR_GENERIC, "There must be a SmlDataSyncDataStore object."); self->priv->data_stores = g_list_append(self->priv->data_stores, ds); sml_data_sync_data_store_set_data_sync(ds, self); + return TRUE; } /** @@ -811,7 +813,6 @@ smlTrace(TRACE_ENTRY, "%s(%p, %i, %p, %p, %p)", __func__, manager, type, session, error, userdata); SmlDataSync *self = userdata; smlAssert(self); - GList *o = NULL; GError *locerror = NULL; /* FIXME: Is this lock really needed? */ /* FIXME: Who is allowed to call smlManagerDispatch? */ @@ -834,7 +835,7 @@ case SML_MANAGER_SESSION_ERROR: case SML_MANAGER_SESSION_WARNING: smlTrace(TRACE_INTERNAL, "%s: forwarding session %p event %d", __func__, data_sync_session, type); - sml_data_sync_session_event_callback(data_sync_session, type, error); + sml_data_sync_session_send_event(data_sync_session, NULL, type, error); break; case SML_MANAGER_CONNECT_DONE: smlTrace(TRACE_INTERNAL, "%s: the transport was connected", __func__); @@ -864,7 +865,6 @@ self->priv->state < SML_DATA_SYNC_STATE_DISCONNECTED) { if (self->priv->state < SML_DATA_SYNC_STATE_DISCONNECT_IN_PROGRESS) { self->priv->state = SML_DATA_SYNC_STATE_DISCONNECT_IN_PROGRESS; - GError *locerror = NULL; g_hash_table_foreach (self->priv->data_sync_sessions, sml_data_sync_disconnect_session, self); } else { /* disconnect failed */ Modified: trunk/libsyncml/data_sync_api/sml_data_sync.h ============================================================================== --- trunk/libsyncml/data_sync_api/sml_data_sync.h Sat Sep 12 16:48:23 2009 (r1262) +++ trunk/libsyncml/data_sync_api/sml_data_sync.h Mon Sep 14 11:24:28 2009 (r1263) @@ -64,6 +64,7 @@ }; #include "sml_data_sync_session.h" +#include "sml_data_sync_data_store.h" GType sml_data_sync_get_type (void); SmlDataSync* sml_data_sync_new (void); @@ -74,6 +75,7 @@ gboolean sml_data_sync_set_option (SmlDataSync *self, const gchar *name, const gchar *value, GError **error); gboolean sml_data_sync_initialize (SmlDataSync *self, GError **error); gboolean sml_data_sync_run (SmlDataSync *self, GError **error); +gboolean sml_data_sync_add_data_store (SmlDataSync *self, SmlDataSyncDataStore *ds, GError **error); typedef void (* SmlDataSyncSessionEventCallback) (SmlDataSyncSession *self, SmlDataSync *data_sync, SmlDataSyncEventType type, void *userdata, const GError *error); typedef gboolean (* SmlDataSyncSessionWriteDevInfCallback) (SmlDataSyncSession *self, SmlDevInf *devinf, void *userdata, GError **error); Modified: trunk/libsyncml/data_sync_api/sml_data_sync_data_store.c ============================================================================== --- trunk/libsyncml/data_sync_api/sml_data_sync_data_store.c Sat Sep 12 16:48:23 2009 (r1262) +++ trunk/libsyncml/data_sync_api/sml_data_sync_data_store.c Mon Sep 14 11:24:28 2009 (r1263) @@ -351,7 +351,7 @@ G_CONST_RETURN gchar* sml_data_sync_data_store_get_local_uri (SmlDataSyncDataStore *self) { - g_return_if_fail (SML_IS_DATA_SYNC_DATA_STORE (self)); + g_return_val_if_fail (SML_IS_DATA_SYNC_DATA_STORE (self), NULL); if (!self->priv->local) return NULL; return sml_location_get_uri(self->priv->local); Modified: trunk/libsyncml/data_sync_api/sml_data_sync_data_store_session.c ============================================================================== --- trunk/libsyncml/data_sync_api/sml_data_sync_data_store_session.c Sat Sep 12 16:48:23 2009 (r1262) +++ trunk/libsyncml/data_sync_api/sml_data_sync_data_store_session.c Mon Sep 14 11:24:28 2009 (r1263) @@ -30,6 +30,7 @@ #include "sml_data_sync_defines.h" #include "sml_data_sync_internals.h" #include "sml_data_sync_session_internals.h" +#include "data_sync_devinf.h" G_DEFINE_TYPE (SmlDataSyncDataStoreSession, sml_data_sync_data_store_session, G_TYPE_OBJECT) Modified: trunk/libsyncml/data_sync_api/sml_data_sync_session.c ============================================================================== --- trunk/libsyncml/data_sync_api/sml_data_sync_session.c Sat Sep 12 16:48:23 2009 (r1262) +++ trunk/libsyncml/data_sync_api/sml_data_sync_session.c Mon Sep 14 11:24:28 2009 (r1263) @@ -20,6 +20,9 @@ #include "sml_data_sync_session_private.h" #include "sml_data_sync_data_store_session_internals.h" +#include "data_sync_devinf.h" + +/* FIXME: !!!!!!! */ #include "sml_data_sync_private.h" #include "sml_data_sync_internals.h" Modified: trunk/libsyncml/sml_session.c ============================================================================== --- trunk/libsyncml/sml_session.c Sat Sep 12 16:48:23 2009 (r1262) +++ trunk/libsyncml/sml_session.c Mon Sep 14 11:24:28 2009 (r1263) @@ -34,6 +34,8 @@ #include "data_sync_api/sml_location.h" #include "data_sync_api/sml_data_sync_change_item_internals.h" +#include <unistd.h> + /** * @defgroup SmlSessionPrivate SyncML Session Private API * @ingroup PrivateLowLevelAPI Modified: trunk/libsyncml/sml_transport.c ============================================================================== --- trunk/libsyncml/sml_transport.c Sat Sep 12 16:48:23 2009 (r1262) +++ trunk/libsyncml/sml_transport.c Mon Sep 14 11:24:28 2009 (r1263) @@ -25,6 +25,7 @@ #include "sml_support.h" #include <config.h> +#include <unistd.h> #ifdef ENABLE_HTTP #include "transports/http_client_internals.h" @@ -812,6 +813,9 @@ g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "OBEX Transport not enabled in this build"); goto error; #endif + case SML_TRANSPORT_UNKNOWN: + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "The transport type must be specified."); + goto error; } tsp->command_queue = smlQueueNew(error); Modified: trunk/libsyncml/transports/obex_server.c ============================================================================== --- trunk/libsyncml/transports/obex_server.c Sat Sep 12 16:48:23 2009 (r1262) +++ trunk/libsyncml/transports/obex_server.c Mon Sep 14 11:24:28 2009 (r1263) @@ -31,6 +31,7 @@ #include <errno.h> #include <string.h> +#include <unistd.h> #ifndef WIN32 #include <fcntl.h> Modified: trunk/tests/check_data_sync_api.c ============================================================================== --- trunk/tests/check_data_sync_api.c Sat Sep 12 16:48:23 2009 (r1262) +++ trunk/tests/check_data_sync_api.c Mon Sep 14 11:24:28 2009 (r1263) @@ -26,6 +26,7 @@ #include <libsyncml/data_sync_api/sml_data_sync.h> #include <string.h> +#include <unistd.h> GMutex *runMutex = NULL; int locks; @@ -63,7 +64,6 @@ for (;list;list = list->next) { count++; - const char *test_data = list->data; char *name = g_strdup_printf("%d", count); SmlLocation *loc = sml_location_new(); sml_location_set_uri(loc, name); @@ -371,9 +371,9 @@ goto error; /* The OBEX server needs some time to start. */ if (g_getenv("SYNCML_TRACE")) - sleep(2); + usleep(2000); else - sleep(5); + usleep(5000); if (!sml_data_sync_run(server, &error)) goto error; } Modified: trunk/tests/check_devinf.c ============================================================================== --- trunk/tests/check_devinf.c Sat Sep 12 16:48:23 2009 (r1262) +++ trunk/tests/check_devinf.c Mon Sep 14 11:24:28 2009 (r1263) @@ -27,6 +27,7 @@ #include "libsyncml/parser/sml_xml_parse.h" #include <string.h> +#include <unistd.h> #define NUM_SESSIONS 30 Modified: trunk/tests/check_ds.c ============================================================================== --- trunk/tests/check_ds.c Sat Sep 12 16:48:23 2009 (r1262) +++ trunk/tests/check_ds.c Mon Sep 14 11:24:28 2009 (r1263) @@ -31,6 +31,7 @@ #include <libsyncml/data_sync_api/sml_location.h> #include <string.h> +#include <unistd.h> typedef struct SmlSessionThread { GMainContext *context; Modified: trunk/tests/check_http.c ============================================================================== --- trunk/tests/check_http.c Sat Sep 12 16:48:23 2009 (r1262) +++ trunk/tests/check_http.c Mon Sep 14 11:24:28 2009 (r1263) @@ -24,6 +24,8 @@ #include <libsyncml/sml_transport_internals.h> #include <libsyncml/sml_error_internals.h> +#include <unistd.h> + int client_connects; int client_disconnects; int client_receives; Modified: trunk/tests/check_manager.c ============================================================================== --- trunk/tests/check_manager.c Sat Sep 12 16:48:23 2009 (r1262) +++ trunk/tests/check_manager.c Mon Sep 14 11:24:28 2009 (r1263) @@ -25,6 +25,8 @@ #include <libsyncml/data_sync_api/sml_location.h> #include <libsyncml/sml_error_internals.h> +#include <unistd.h> + #define NUM_SESSIONS 30 unsigned int defaultMaxMsgSize = 10240; Modified: trunk/tests/check_obex.c ============================================================================== --- trunk/tests/check_obex.c Sat Sep 12 16:48:23 2009 (r1262) +++ trunk/tests/check_obex.c Mon Sep 14 11:24:28 2009 (r1263) @@ -26,6 +26,7 @@ #include <libsyncml/sml_error_internals.h> #include <errno.h> +#include <unistd.h> START_TEST (obex_get_result_macro) { @@ -725,7 +726,7 @@ sml_fail_unless(smlTransportConnect(client, &error), NULL); sml_fail_unless(error == NULL, "%s", GET_ERROR_MESSAGE(error)); - sleep(1); + // usleep(50); while (client_errors < 1) { usleep(50); }; Modified: trunk/tests/check_session.c ============================================================================== --- trunk/tests/check_session.c Sat Sep 12 16:48:23 2009 (r1262) +++ trunk/tests/check_session.c Mon Sep 14 11:24:28 2009 (r1263) @@ -30,6 +30,8 @@ #include <libsyncml/sml_notification.h> +#include <unistd.h> + typedef struct SmlSessionThread { GMainContext *context; GSourceFuncs *functions; Modified: trunk/tests/check_sync.c ============================================================================== --- trunk/tests/check_sync.c Sat Sep 12 16:48:23 2009 (r1262) +++ trunk/tests/check_sync.c Mon Sep 14 11:24:28 2009 (r1263) @@ -31,6 +31,7 @@ #include <libsyncml/sml_error_internals.h> #include <config.h> +#include <unistd.h> #define NUM_SESSIONS 30 Modified: trunk/tests/mobiles/obex_mobile_ds_client.c ============================================================================== --- trunk/tests/mobiles/obex_mobile_ds_client.c Sat Sep 12 16:48:23 2009 (r1262) +++ trunk/tests/mobiles/obex_mobile_ds_client.c Mon Sep 14 11:24:28 2009 (r1263) @@ -29,6 +29,7 @@ #include <libsyncml/sml_transport_internals.h> #include <wbxml.h> +#include <unistd.h> /* external configuration */ Modified: trunk/tests/support.c ============================================================================== --- trunk/tests/support.c Sat Sep 12 16:48:23 2009 (r1262) +++ trunk/tests/support.c Mon Sep 14 11:24:28 2009 (r1263) @@ -21,6 +21,7 @@ #include "support.h" #include <libsyncml/sml_error_internals.h> #include <libxml/parser.h> +#include <unistd.h> #ifndef THREAD_SAFE_CHECK GStaticMutex __libsyncml_check_mutex = G_STATIC_MUTEX_INIT; Modified: trunk/tests/support.h ============================================================================== --- trunk/tests/support.h Sat Sep 12 16:48:23 2009 (r1262) +++ trunk/tests/support.h Mon Sep 14 11:24:28 2009 (r1263) @@ -26,6 +26,7 @@ #include <check.h> #include <libsyncml/sml_support.h> #include <libsyncml/sml_parse.h> +#include <libsyncml/data_sync_api/sml_data_sync_change_item_internals.h> void configure_environment(); void cleanup_environment(); |
From: <svn...@op...> - 2009-09-12 14:48:40
|
Author: bellmich Date: Sat Sep 12 16:48:23 2009 New Revision: 1262 URL: http://libsyncml.opensync.org/changeset/1262 Log: - fixed wrong error check in data_sync_client.c - fixed wrong header file include position in sml_data_sync.h - added function sml_data_sync_session_get_data_sync - added function sml_data_sync_data_store_session_get_data_sync_session - fixed include file position in sml_data_sync_session.h - fixed data_sync_api tests All tests are migrated to the new data sync API. Only two tests are not working because the 0.5.x versions does not adapt so good to the remote peer's behaviour. Modified: trunk/libsyncml/data_sync_api/data_sync_client.c trunk/libsyncml/data_sync_api/data_sync_devinf.c trunk/libsyncml/data_sync_api/sml_data_sync.h trunk/libsyncml/data_sync_api/sml_data_sync_data_store_session.c trunk/libsyncml/data_sync_api/sml_data_sync_data_store_session.h trunk/libsyncml/data_sync_api/sml_data_sync_session.c trunk/libsyncml/data_sync_api/sml_data_sync_session.h trunk/libsyncml/data_sync_api/sml_data_sync_session_internals.h trunk/tests/CMakeLists.txt trunk/tests/check_data_sync_api.c Modified: trunk/libsyncml/data_sync_api/data_sync_client.c ============================================================================== --- trunk/libsyncml/data_sync_api/data_sync_client.c Fri Sep 11 23:16:10 2009 (r1261) +++ trunk/libsyncml/data_sync_api/data_sync_client.c Sat Sep 12 16:48:23 2009 (r1262) @@ -363,7 +363,7 @@ smlTrace(TRACE_INTERNAL, "preparing DsServer (datastore) %s", sml_location_get_uri(sml_data_sync_data_store_get_local(datastore))); - if (sml_data_sync_data_store_client_init(datastore, error)) + if (!sml_data_sync_data_store_client_init(datastore, error)) goto error; /* And we also add the devinfo to the devinf agent */ Modified: trunk/libsyncml/data_sync_api/data_sync_devinf.c ============================================================================== --- trunk/libsyncml/data_sync_api/data_sync_devinf.c Fri Sep 11 23:16:10 2009 (r1261) +++ trunk/libsyncml/data_sync_api/data_sync_devinf.c Sat Sep 12 16:48:23 2009 (r1262) @@ -524,7 +524,7 @@ SmlDataSyncDataStore *datastore, GError **error) { - smlTrace(TRACE_ENTRY, "%s (%p, %p)", __func__, devinf, datastore); + smlTrace(TRACE_ENTRY, "%s (%p, %p, %p)", __func__, devinf, datastore, error); CHECK_ERROR_REF smlAssert(datastore); smlAssert(datastore->priv->content_type); Modified: trunk/libsyncml/data_sync_api/sml_data_sync.h ============================================================================== --- trunk/libsyncml/data_sync_api/sml_data_sync.h Fri Sep 11 23:16:10 2009 (r1261) +++ trunk/libsyncml/data_sync_api/sml_data_sync.h Sat Sep 12 16:48:23 2009 (r1262) @@ -22,7 +22,6 @@ #define __SML_DATA_SYNC_H__ #include <glib-object.h> -#include "sml_data_sync_session.h" G_BEGIN_DECLS @@ -64,6 +63,8 @@ GObjectClass parent_class; }; +#include "sml_data_sync_session.h" + GType sml_data_sync_get_type (void); SmlDataSync* sml_data_sync_new (void); gboolean sml_data_sync_set_transport_type (SmlDataSync *self, SmlTransportType type, GError **error); Modified: trunk/libsyncml/data_sync_api/sml_data_sync_data_store_session.c ============================================================================== --- trunk/libsyncml/data_sync_api/sml_data_sync_data_store_session.c Fri Sep 11 23:16:10 2009 (r1261) +++ trunk/libsyncml/data_sync_api/sml_data_sync_data_store_session.c Sat Sep 12 16:48:23 2009 (r1262) @@ -532,6 +532,12 @@ return self->priv->data_store; } +SmlDataSyncSession* +sml_data_sync_data_store_session_get_data_sync_session (SmlDataSyncDataStoreSession *self) +{ + return self->priv->data_sync_session; +} + void sml_data_sync_data_store_session_set_session (SmlDataSyncDataStoreSession *self, SmlDsSession *session) Modified: trunk/libsyncml/data_sync_api/sml_data_sync_data_store_session.h ============================================================================== --- trunk/libsyncml/data_sync_api/sml_data_sync_data_store_session.h Fri Sep 11 23:16:10 2009 (r1261) +++ trunk/libsyncml/data_sync_api/sml_data_sync_data_store_session.h Sat Sep 12 16:48:23 2009 (r1262) @@ -80,12 +80,14 @@ typedef gboolean (* SmlDataSyncDataStoreSessionSetAnchorCallback) (SmlDataSyncDataStoreSession *self, gboolean remote, const gchar *value, void *userdata, GError **error); #include "sml_data_sync_data_store.h" +#include "sml_data_sync_session.h" GType sml_data_sync_data_store_session_get_type (void); gboolean sml_data_sync_data_store_session_add_change (SmlDataSyncDataStoreSession *self, SmlDataSyncChangeItem *item, void *userdata, GError **error); gboolean sml_data_sync_data_store_session_add_mapping (SmlDataSyncDataStoreSession *self, SmlMapItem *item, void *userdata, GError **error); -SmlDataSyncDataStore* sml_data_sync_data_store_session_get_data_store (SmlDataSyncDataStoreSession *self); +SmlDataSyncDataStore* sml_data_sync_data_store_session_get_data_store (SmlDataSyncDataStoreSession *self); +SmlDataSyncSession* sml_data_sync_data_store_session_get_data_sync_session (SmlDataSyncDataStoreSession *self); G_END_DECLS Modified: trunk/libsyncml/data_sync_api/sml_data_sync_session.c ============================================================================== --- trunk/libsyncml/data_sync_api/sml_data_sync_session.c Fri Sep 11 23:16:10 2009 (r1261) +++ trunk/libsyncml/data_sync_api/sml_data_sync_session.c Sat Sep 12 16:48:23 2009 (r1262) @@ -207,6 +207,12 @@ return self->priv->session; } +SmlDataSync* +sml_data_sync_session_get_data_sync (SmlDataSyncSession *self) +{ + return self->priv->data_sync; +} + SmlDataSyncDataStoreSession* sml_data_sync_session_get_data_store_session (SmlDataSyncSession *self, SmlDataSyncDataStore *datastore, Modified: trunk/libsyncml/data_sync_api/sml_data_sync_session.h ============================================================================== --- trunk/libsyncml/data_sync_api/sml_data_sync_session.h Fri Sep 11 23:16:10 2009 (r1261) +++ trunk/libsyncml/data_sync_api/sml_data_sync_session.h Sat Sep 12 16:48:23 2009 (r1262) @@ -24,7 +24,6 @@ #include <glib-object.h> #include <libsyncml/dev_inf_api/sml_dev_inf.h> #include "sml_location.h" -#include "sml_data_sync_data_store.h" G_BEGIN_DECLS @@ -62,11 +61,15 @@ GObjectClass parent_class; }; +#include "sml_data_sync.h" +#include "sml_data_sync_data_store.h" + GType sml_data_sync_session_get_type (void); SmlLocation* sml_data_sync_session_get_remote (SmlDataSyncSession *self); gboolean sml_data_sync_session_send_changes (SmlDataSyncSession *self, GError **error); gboolean sml_data_sync_session_abort (SmlDataSyncSession *self, GError **error); +SmlDataSync* sml_data_sync_session_get_data_sync (SmlDataSyncSession *self); SmlDataSyncDataStoreSession* sml_data_sync_session_get_data_store_session (SmlDataSyncSession *self, SmlDataSyncDataStore *datastore, GError **error); G_END_DECLS Modified: trunk/libsyncml/data_sync_api/sml_data_sync_session_internals.h ============================================================================== --- trunk/libsyncml/data_sync_api/sml_data_sync_session_internals.h Fri Sep 11 23:16:10 2009 (r1261) +++ trunk/libsyncml/data_sync_api/sml_data_sync_session_internals.h Sat Sep 12 16:48:23 2009 (r1262) @@ -30,7 +30,7 @@ SmlDataSyncSession* sml_data_sync_session_new (SmlSession *session, SmlDataSync *sync, GError **error); -SmlSession* sml_data_sync_session_get_session (SmlDataSyncSession *self); +SmlSession* sml_data_sync_session_get_session (SmlDataSyncSession *self); gboolean sml_data_sync_session_check (SmlDataSyncSession *self); gboolean sml_data_sync_session_dispatch (SmlDataSyncSession *self); Modified: trunk/tests/CMakeLists.txt ============================================================================== --- trunk/tests/CMakeLists.txt Fri Sep 11 23:16:10 2009 (r1261) +++ trunk/tests/CMakeLists.txt Sat Sep 12 16:48:23 2009 (r1262) @@ -510,14 +510,14 @@ ADD_MOBILE_TEST( nokia_9500_vcard_vcal ${TEST_TARGET_LIBRARIES} ) ENDIF ( ENABLE_OBEX AND ENABLE_OPENOBEX_TCP AND ENABLE_WBXML AND ENABLE_GLIB2_GREGEX ) -# IF ( ENABLE_OPENOBEX_TCP OR ENABLE_HTTP ) -# SML_START_TEST( "OMA DS API" ds_api check_data_sync_api.c ${TEST_TARGET_LIBRARIES} ) -# SML_ADD_TESTCASE( ds_api_text_vcard_21 ) -# SML_ADD_TESTCASE( ds_api_image_jpeg ) -# SML_ADD_TESTCASE( ds_api_unknown_ct ) -# SML_ADD_TESTCASE( ds_api_multi_text_vcard_21 ) -# SML_END_TEST() -# ENDIF ( ENABLE_OPENOBEX_TCP OR ENABLE_HTTP ) + IF ( ENABLE_OPENOBEX_TCP OR ENABLE_HTTP ) + SML_START_TEST( "OMA DS API" ds_api check_data_sync_api.c ${TEST_TARGET_LIBRARIES} ) + SML_ADD_TESTCASE( ds_api_text_vcard_21 ) + SML_ADD_TESTCASE( ds_api_image_jpeg ) + SML_ADD_TESTCASE( ds_api_unknown_ct ) + SML_ADD_TESTCASE( ds_api_multi_text_vcard_21 ) + SML_END_TEST() + ENDIF ( ENABLE_OPENOBEX_TCP OR ENABLE_HTTP ) ENDIF( ENABLE_UNIT_TEST ) Modified: trunk/tests/check_data_sync_api.c ============================================================================== --- trunk/tests/check_data_sync_api.c Fri Sep 11 23:16:10 2009 (r1261) +++ trunk/tests/check_data_sync_api.c Sat Sep 12 16:48:23 2009 (r1262) @@ -22,10 +22,8 @@ #include "tests/support.h" -#include <libsyncml/data_sync_api/defines.h> -#include <libsyncml/data_sync_api/standard.h> -#include <libsyncml/data_sync_api/callbacks.h> -#include <glib.h> +#include <libsyncml/data_sync_api/sml_data_sync_defines.h> +#include <libsyncml/data_sync_api/sml_data_sync.h> #include <string.h> @@ -33,10 +31,10 @@ int locks; GList *client_items; -SmlDataSyncObject *client; -SmlDataSyncObject *server; -const char *client_source; -const char *server_source; +SmlDataSync *client; +SmlDataSync *server; +SmlDataSyncDataStore *client_data_store; +SmlDataSyncDataStore *server_data_store; const char *transport; @@ -44,12 +42,20 @@ /* *********** CALLBACKS ************** */ /* ************************************ */ -gboolean sendAllChanges( - SmlDataSyncObject *dsObject, +gboolean +sendAllChanges (SmlDataSyncSession *session, GError **error) { smlTrace(TRACE_ENTRY, "%s", __func__); + SmlDataSync *dsObject = sml_data_sync_session_get_data_sync(session); + SmlDataSyncDataStoreSession *dss = NULL; + if (dsObject == client) + dss = sml_data_sync_session_get_data_store_session(session, client_data_store, error); + else + dss = sml_data_sync_session_get_data_store_session(session, server_data_store, error); + sml_fail_unless(dss != NULL, "%s", GET_ERROR_MESSAGE((*error))); + if (dsObject == client) { GList *list = client_items; @@ -59,64 +65,75 @@ count++; const char *test_data = list->data; char *name = g_strdup_printf("%d", count); - if (!smlDataSyncAddChange(client, client_source, SML_CHANGE_ADD, - name , test_data, strlen(test_data), NULL, error)) { - sml_fail_unless(FALSE, "%s", (*error)->message); - } + SmlLocation *loc = sml_location_new(); + sml_location_set_uri(loc, name); smlSafeCFree(&name); + + SmlDataSyncChangeItem *item = sml_data_sync_change_item_new(); + sml_data_sync_change_item_set_action(item, SML_CHANGE_ADD); + sml_fail_unless(sml_data_sync_change_item_set_data(item, list->data, 0, error), "%s", GET_ERROR_MESSAGE((*error))); + sml_fail_unless(sml_data_sync_change_item_set_location(item, loc, error), "%s", GET_ERROR_MESSAGE((*error))); + g_object_unref(loc); + loc = NULL; + + sml_fail_unless(sml_data_sync_data_store_session_add_change(dss, item, NULL, error), "%s", GET_ERROR_MESSAGE((*error))); } } smlTrace(TRACE_EXIT, "%s", __func__); - return smlDataSyncSendChanges(dsObject, error); + return sml_data_sync_session_send_changes(session, error); } -static void recvEventCallback( - SmlDataSyncObject *dsObject, - SmlDataSyncEventType type, - void *userdata, - const GError *error) +static void +recvEventCallback (SmlDataSyncSession *session, + SmlDataSync *dsObject, + SmlDataSyncEventType type, + void *userdata, + const GError *error) { smlTrace(TRACE_ENTRY, "%s(%p, %i, %p, %p)", __func__, dsObject, type, userdata, error); GError *locerror = NULL; + + //if (!dsObject) + // dsObject = sml_data_sync_session_get_data_sync(session); switch (type) { - case SML_DATA_SYNC_EVENT_ERROR: + case SML_DATA_SYNC_SESSION_EVENT_ERROR: if (dsObject == client) { sml_fail_unless(FALSE, "OMA DS client failed: %s", error->message); } else { sml_fail_unless(FALSE, "OMA DS server failed: %s", error->message); } break; - case SML_DATA_SYNC_EVENT_CONNECT: + case SML_DATA_SYNC_SESSION_EVENT_CONNECT: /* g_message("Remote device was successfully connected."); */ break; - case SML_DATA_SYNC_EVENT_DISCONNECT: + case SML_DATA_SYNC_SESSION_EVENT_DISCONNECT: /* g_message("Remote device was successfully disconnected."); */ break; - case SML_DATA_SYNC_EVENT_FINISHED: + case SML_DATA_SYNC_SESSION_EVENT_FINISHED: /* g_message("SyncML session finished successfully."); */ if (g_atomic_int_dec_and_test(&locks)) g_mutex_unlock(runMutex); break; - case SML_DATA_SYNC_EVENT_GOT_ALL_ALERTS: + case SML_DATA_SYNC_SESSION_EVENT_GOT_ALL_ALERTS: /* g_message("All alerts of the remote device were received."); */ if (dsObject == client) { - if (!sendAllChanges(dsObject, &locerror)) + if (!sendAllChanges(session, &locerror)) goto error; } break; - case SML_DATA_SYNC_EVENT_GOT_ALL_CHANGES: + case SML_DATA_SYNC_SESSION_EVENT_GOT_ALL_CHANGES: /* g_message("All changes of the remote device were received."); */ if (dsObject == server) { - if (!sendAllChanges(dsObject, &locerror)) + if (!sendAllChanges(session, &locerror)) goto error; } /* the map of the client is send automatically */ break; - case SML_DATA_SYNC_EVENT_GOT_ALL_MAPPINGS: + case SML_DATA_SYNC_SESSION_EVENT_GOT_ALL_MAPPINGS: if (dsObject == server) { /* g_message("All mappings of the remote device were received."); */ @@ -139,28 +156,28 @@ exit(3); } -static gboolean recvChangeCallback( - SmlDataSyncObject *dsObject, - const char *source, - SmlChangeType type, - const char *uid, - char *data, - gsize size, - void *userdata, - GError **error) +static gboolean +recvChangeCallback (SmlDataSyncDataStoreSession *session, + SmlDataSyncChangeItem *item, + void *userdata, + GError **error) { - smlTrace(TRACE_ENTRY, "%s: %s ==> %s(%p, %d, %p, %d, %p, %p)", __func__, VA_STRING(source), VA_STRING(uid), dsObject, type, data, size, userdata, error); + smlTrace(TRACE_ENTRY, "%s: (%p, %p, %p, %p)", __func__, session, item, userdata, error); /* clients should never receive a change in this test */ + SmlDataSyncDataStore *datastore = sml_data_sync_data_store_session_get_data_store(session); + SmlDataSyncSession *dss = sml_data_sync_data_store_session_get_data_sync_session(session); + SmlDataSync *dsObject = sml_data_sync_session_get_data_sync(dss); + if (dsObject == client) { sml_fail_unless(FALSE, "A change was received from the server."); } /* check the source */ - if (strcmp(server_source, source)) { - sml_fail_unless(FALSE, "The source %s is wrong.", server_source); + if (datastore == client_data_store) { + sml_fail_unless(FALSE, "The data store is wrong (from client)."); } /* handle the item */ @@ -170,6 +187,7 @@ count++; /* test the uid */ + const gchar *uid = sml_location_get_full_uri(sml_data_sync_change_item_get_location(item)); char *name = g_strdup_printf("%d", count); if (strcmp(name, uid)) { smlSafeCFree(&name); @@ -178,11 +196,11 @@ smlSafeCFree(&name); /* item with correct uid */ + const gchar *data = sml_data_sync_change_item_get_data(item); if (strcmp(list->data, data)) { sml_fail_unless(FALSE, "The data of the item %s was wrong(%s != %s).", uid, data, list->data); } } - smlSafeCFree(&data); smlTrace(TRACE_EXIT, "%s - TRUE", __func__); return TRUE; @@ -255,36 +273,38 @@ #endif if (!strcmp(transport, "HTTP")) { - client = smlDataSyncNew(SML_SESSION_TYPE_CLIENT, SML_TRANSPORT_HTTP_CLIENT, &error); - if (!client) + client = sml_data_sync_new(); + if (!sml_data_sync_set_session_type(client, SML_SESSION_TYPE_CLIENT, &error)) + goto error; + if (!sml_data_sync_set_transport_type(client, SML_TRANSPORT_HTTP_CLIENT, &error)) + goto error; + server = sml_data_sync_new(); + if (!sml_data_sync_set_session_type(server, SML_SESSION_TYPE_SERVER, &error)) goto error; - server = smlDataSyncNew(SML_SESSION_TYPE_SERVER, SML_TRANSPORT_HTTP_SERVER, &error); - if (!server) + if (!sml_data_sync_set_transport_type(server, SML_TRANSPORT_HTTP_SERVER, &error)) goto error; } else { - client = smlDataSyncNew(SML_SESSION_TYPE_CLIENT, SML_TRANSPORT_OBEX_SERVER, &error); - if (!client) + client = sml_data_sync_new(); + if (!sml_data_sync_set_session_type(client, SML_SESSION_TYPE_CLIENT, &error)) goto error; - server = smlDataSyncNew(SML_SESSION_TYPE_SERVER, SML_TRANSPORT_OBEX_CLIENT, &error); - if (!server) + if (!sml_data_sync_set_transport_type(client, SML_TRANSPORT_OBEX_SERVER, &error)) + goto error; + server = sml_data_sync_new(); + if (!sml_data_sync_set_session_type(server, SML_SESSION_TYPE_SERVER, &error)) + goto error; + if (!sml_data_sync_set_transport_type(server, SML_TRANSPORT_OBEX_CLIENT, &error)) goto error; } /* default configuration of callbacks */ - smlDataSyncRegisterEventCallback(client, recvEventCallback, NULL); - smlDataSyncRegisterEventCallback(server, recvEventCallback, NULL); - // smlDataSyncRegisterGetAlertTypeCallback(client, recvAlertTypeCallback, NULL); - // smlDataSyncRegisterGetAlertTypeCallback(server, recvAlertTypeCallback, NULL); - smlDataSyncRegisterChangeCallback(client, recvChangeCallback, NULL); - smlDataSyncRegisterChangeCallback(server, recvChangeCallback, NULL); - // smlDataSyncRegisterChangeStatusCallback(dsObject, recvChangeStatusCallback); - // smlDataSyncRegisterMappingCallback(dsObject, recvMappingCallback, NULL); + sml_data_sync_register_event_callback(client, recvEventCallback, NULL); + sml_data_sync_register_event_callback(server, recvEventCallback, NULL); /* configure transport */ if (!strcmp(transport, "HTTP")) { /* HTTP */ char *url = g_strdup_printf("http://127.0.0.1:%s", port); - if (!smlDataSyncSetOption( + if (!sml_data_sync_set_option( client, SML_TRANSPORT_CONFIG_URL, url, &error)) @@ -292,30 +312,30 @@ smlSafeCFree(&url); } else { /* OBEX */ - if (!smlDataSyncSetOption( + if (!sml_data_sync_set_option( client, SML_DATA_SYNC_CONFIG_CONNECTION_TYPE, SML_DATA_SYNC_CONFIG_CONNECTION_NET, &error)) goto error; - if (!smlDataSyncSetOption( + if (!sml_data_sync_set_option( server, SML_DATA_SYNC_CONFIG_CONNECTION_TYPE, SML_DATA_SYNC_CONFIG_CONNECTION_NET, &error)) goto error; - if (!smlDataSyncSetOption( + if (!sml_data_sync_set_option( server, SML_TRANSPORT_CONFIG_URL, "127.0.0.1", &error)) goto error; - if (!smlDataSyncSetOption( + if (!sml_data_sync_set_option( client, SML_TRANSPORT_CONFIG_PORT, port, &error)) goto error; } - if (!smlDataSyncSetOption( + if (!sml_data_sync_set_option( server, SML_TRANSPORT_CONFIG_PORT, port, &error)) @@ -334,27 +354,27 @@ /* init the sync */ if (!strcmp(transport, "HTTP")) { - if (!smlDataSyncInit(server, &error)) + if (!sml_data_sync_initialize(server, &error)) goto error; - if (!smlDataSyncInit(client, &error)) + if (!sml_data_sync_initialize(client, &error)) goto error; - if (!smlDataSyncRun(server, &error)) + if (!sml_data_sync_run(server, &error)) goto error; - if (!smlDataSyncRun(client, &error)) + if (!sml_data_sync_run(client, &error)) goto error; } else { - if (!smlDataSyncInit(client, &error)) + if (!sml_data_sync_initialize(client, &error)) goto error; - if (!smlDataSyncInit(server, &error)) + if (!sml_data_sync_initialize(server, &error)) goto error; - if (!smlDataSyncRun(client, &error)) + if (!sml_data_sync_run(client, &error)) goto error; /* The OBEX server needs some time to start. */ if (g_getenv("SYNCML_TRACE")) sleep(2); else sleep(5); - if (!smlDataSyncRun(server, &error)) + if (!sml_data_sync_run(server, &error)) goto error; } @@ -366,8 +386,8 @@ runMutex = NULL; /* close the object */ - smlDataSyncObjectUnref(&client); - smlDataSyncObjectUnref(&server); + g_object_unref(client); + g_object_unref(server); g_list_free(client_items); return; @@ -383,21 +403,19 @@ /* register datastore * the source must be identical because this is http */ - client_source = "contacts"; - server_source = "contacts"; - if (!smlDataSyncAddDatastore( - client, - "text/x-vcard", - NULL, - client_source, - &error)) + + client_data_store = sml_data_sync_data_store_new(); + sml_data_sync_data_store_set_content_type (client_data_store, "text/x-vcard"); + sml_data_sync_data_store_set_local_uri (client_data_store, "contacts"); + sml_data_sync_data_store_register_change_callback(client_data_store, recvChangeCallback, NULL); + if (!sml_data_sync_add_data_store(client, client_data_store, &error)) goto error; - if (!smlDataSyncAddDatastore( - server, - "text/x-vcard", - NULL, - server_source, - &error)) + + server_data_store = sml_data_sync_data_store_new(); + sml_data_sync_data_store_set_content_type (server_data_store, "text/x-vcard"); + sml_data_sync_data_store_set_local_uri (server_data_store, "contacts"); + sml_data_sync_data_store_register_change_callback(server_data_store, recvChangeCallback, NULL); + if (!sml_data_sync_add_data_store(server, server_data_store, &error)) goto error; /* configure test data */ @@ -419,24 +437,22 @@ /* register datastore * the source must be identical if this is http */ - client_source = "dcim"; + + client_data_store = sml_data_sync_data_store_new(); + sml_data_sync_data_store_set_content_type (client_data_store, "image/jpeg"); + sml_data_sync_data_store_set_local_uri (client_data_store, "dcim"); + sml_data_sync_data_store_register_change_callback(client_data_store, recvChangeCallback, NULL); + if (!sml_data_sync_add_data_store(client, client_data_store, &error)) + goto error; + + server_data_store = sml_data_sync_data_store_new(); + sml_data_sync_data_store_set_content_type (server_data_store, "image/jpeg"); if (!strcmp(transport, "OBEX")) - server_source = "photos"; + sml_data_sync_data_store_set_local_uri (server_data_store, "photos"); else - server_source = "dcim"; - if (!smlDataSyncAddDatastore( - client, - "image/jpeg", - NULL, - client_source, - &error)) - goto error; - if (!smlDataSyncAddDatastore( - server, - "image/jpeg", - NULL, - server_source, - &error)) + sml_data_sync_data_store_set_local_uri (server_data_store, "dcim"); + sml_data_sync_data_store_register_change_callback(server_data_store, recvChangeCallback, NULL); + if (!sml_data_sync_add_data_store(server, server_data_store, &error)) goto error; /* configure test data */ @@ -458,21 +474,19 @@ /* register datastore * the source must be identical because this is http */ - client_source = "data"; - server_source = "data"; - if (!smlDataSyncAddDatastore( - client, - "unknown/content-type", - NULL, - client_source, - &error)) + + client_data_store = sml_data_sync_data_store_new(); + sml_data_sync_data_store_set_content_type (client_data_store, "unknown/content-type"); + sml_data_sync_data_store_set_local_uri (client_data_store, "data"); + sml_data_sync_data_store_register_change_callback(client_data_store, recvChangeCallback, NULL); + if (!sml_data_sync_add_data_store(client, client_data_store, &error)) goto error; - if (!smlDataSyncAddDatastore( - server, - "unknown/content-type", - NULL, - server_source, - &error)) + + server_data_store = sml_data_sync_data_store_new(); + sml_data_sync_data_store_set_content_type (server_data_store, "unknown/content-type"); + sml_data_sync_data_store_set_local_uri (server_data_store, "data"); + sml_data_sync_data_store_register_change_callback(server_data_store, recvChangeCallback, NULL); + if (!sml_data_sync_add_data_store(server, server_data_store, &error)) goto error; /* configure test data */ @@ -494,21 +508,19 @@ /* register datastore * the source must be identical because this is http */ - client_source = "contacts"; - server_source = "contacts"; - if (!smlDataSyncAddDatastore( - client, - "text/x-vcard", - NULL, - client_source, - &error)) + + client_data_store = sml_data_sync_data_store_new(); + sml_data_sync_data_store_set_content_type (client_data_store, "text/x-vcard"); + sml_data_sync_data_store_set_local_uri (client_data_store, "contacts"); + sml_data_sync_data_store_register_change_callback(client_data_store, recvChangeCallback, NULL); + if (!sml_data_sync_add_data_store(client, client_data_store, &error)) goto error; - if (!smlDataSyncAddDatastore( - server, - "text/x-vcard", - NULL, - server_source, - &error)) + + server_data_store = sml_data_sync_data_store_new(); + sml_data_sync_data_store_set_content_type (server_data_store, "text/x-vcard"); + sml_data_sync_data_store_set_local_uri (server_data_store, "contacts"); + sml_data_sync_data_store_register_change_callback(server_data_store, recvChangeCallback, NULL); + if (!sml_data_sync_add_data_store(server, server_data_store, &error)) goto error; /* configure test data */ |
From: <svn...@op...> - 2009-09-11 21:16:23
|
Author: bellmich Date: Fri Sep 11 23:16:10 2009 New Revision: 1261 URL: http://libsyncml.opensync.org/changeset/1261 Log: fixed mobile tests Problem: The old code adapts not so good to the remote part. Problem: The old tests differ a little bit. Question: Can somebody create new samples for the tests. Modified: trunk/libsyncml/data_sync_api/data_sync_loop.c trunk/libsyncml/data_sync_api/data_sync_server.c trunk/libsyncml/data_sync_api/sml_data_sync.c trunk/libsyncml/data_sync_api/sml_data_sync_data_store.c trunk/libsyncml/data_sync_api/sml_data_sync_data_store_internals.h trunk/libsyncml/data_sync_api/sml_data_sync_data_store_session.c trunk/libsyncml/data_sync_api/sml_data_sync_session.c trunk/tests/CMakeLists.txt trunk/tests/mobiles/libsyncml_ds_server.c trunk/tests/mobiles/obex_mobile_ds_client.c Modified: trunk/libsyncml/data_sync_api/data_sync_loop.c ============================================================================== --- trunk/libsyncml/data_sync_api/data_sync_loop.c Thu Sep 10 17:24:56 2009 (r1260) +++ trunk/libsyncml/data_sync_api/data_sync_loop.c Fri Sep 11 23:16:10 2009 (r1261) @@ -62,11 +62,10 @@ static void sml_data_sync_loop_check_dispatch (gpointer key, gpointer value, void *userdata) { + smlTrace(TRACE_INTERNAL, "%s(%p)", __func__, key); SmlDataSyncSession *session = key; /* value is the same like the key */ - gboolean *result = userdata; - if (sml_data_sync_session_dispatch(session)) - *result = TRUE; + sml_data_sync_session_dispatch(session); } static gboolean sml_data_sync_loop_dispatch(GSource *source, GSourceFunc callback, gpointer user_data) @@ -76,14 +75,10 @@ /* Every data store session of every data sync session must be checked. */ - gboolean result = FALSE; - - g_hash_table_foreach(self->priv->data_sync_sessions, sml_data_sync_loop_check_dispatch, &result); - - if (result) - return TRUE; + g_hash_table_foreach(self->priv->data_sync_sessions, sml_data_sync_loop_check_dispatch, NULL); smlManagerDispatch(self->priv->manager); + return TRUE; } Modified: trunk/libsyncml/data_sync_api/data_sync_server.c ============================================================================== --- trunk/libsyncml/data_sync_api/data_sync_server.c Thu Sep 10 17:24:56 2009 (r1260) +++ trunk/libsyncml/data_sync_api/data_sync_server.c Fri Sep 11 23:16:10 2009 (r1261) @@ -264,7 +264,7 @@ smlDsServerSetConnectCallback( datastore->priv->data_store_server, sml_data_sync_data_store_connect_callback, - self); + datastore); /* And we also add the devinfo to the devinf agent */ if (!sml_data_sync_dev_inf_add_data_store(self->priv->local_dev_inf, datastore, error)) Modified: trunk/libsyncml/data_sync_api/sml_data_sync.c ============================================================================== --- trunk/libsyncml/data_sync_api/sml_data_sync.c Thu Sep 10 17:24:56 2009 (r1260) +++ trunk/libsyncml/data_sync_api/sml_data_sync.c Fri Sep 11 23:16:10 2009 (r1261) @@ -393,6 +393,7 @@ const gchar *value, GError **error) { + smlTrace(TRACE_ENTRY, "%s", __func__); CHECK_ERROR_REF sml_return_val_error_if_fail (SML_IS_DATA_SYNC (self), FALSE, error, SML_ERROR_GENERIC, "There must be a SmlDataSync object."); sml_return_val_error_if_fail (name != NULL, FALSE, error, SML_ERROR_GENERIC, "There must be a name."); @@ -578,13 +579,13 @@ sml_data_sync_initialize (SmlDataSync *self, GError **error) { - CHECK_ERROR_REF + smlTrace(TRACE_ENTRY, "%s", __func__); sml_return_val_error_if_fail (SML_IS_DATA_SYNC (self), FALSE, error, SML_ERROR_GENERIC, "There must be a SmlDataSync object."); GList *h = self->priv->data_stores; for (; h; h = h->next) { SmlDataSyncDataStore *ds = h->data; - if (!sml_data_sync_data_store_initialize (ds, self, error)) + if (!sml_data_sync_data_store_initialize (ds, error)) return FALSE; } @@ -608,6 +609,7 @@ smlTrace(TRACE_EXIT, "%s - TRUE", __func__); return TRUE; error: + smlTrace(TRACE_EXIT, "%s - FALSE", __func__); return FALSE; } Modified: trunk/libsyncml/data_sync_api/sml_data_sync_data_store.c ============================================================================== --- trunk/libsyncml/data_sync_api/sml_data_sync_data_store.c Thu Sep 10 17:24:56 2009 (r1260) +++ trunk/libsyncml/data_sync_api/sml_data_sync_data_store.c Fri Sep 11 23:16:10 2009 (r1261) @@ -383,12 +383,13 @@ sml_data_sync_data_store_initialize (SmlDataSyncDataStore *self, GError **error) { + smlTrace(TRACE_ENTRY, "%s", __func__); CHECK_ERROR_REF sml_return_val_error_if_fail (SML_IS_DATA_SYNC_DATA_STORE (self), FALSE, error, SML_ERROR_GENERIC, "There must be a SmlDataSyncDataStore object."); - sml_return_val_error_if_fail (!self->priv->data_sync, FALSE, error, SML_ERROR_GENERIC, "The data sync object is missing."); - sml_return_val_error_if_fail (!self->priv->remote, FALSE, error, SML_ERROR_GENERIC, "The remote location is missing."); - sml_return_val_error_if_fail (!self->priv->local, FALSE, error, SML_ERROR_GENERIC, "The local location is missing."); - sml_return_val_error_if_fail (!self->priv->content_type, FALSE, error, SML_ERROR_GENERIC, "The content-type is missing."); + sml_return_val_error_if_fail (self->priv->data_sync, FALSE, error, SML_ERROR_GENERIC, "The data sync object is missing."); + // sml_return_val_error_if_fail (self->priv->remote, FALSE, error, SML_ERROR_GENERIC, "The remote location is missing."); + sml_return_val_error_if_fail (self->priv->local, FALSE, error, SML_ERROR_GENERIC, "The local location is missing."); + sml_return_val_error_if_fail (self->priv->content_type, FALSE, error, SML_ERROR_GENERIC, "The content-type is missing."); gchar *lcCT = NULL; gchar *lcSource = NULL; @@ -398,6 +399,7 @@ if (tsp_type == SML_TRANSPORT_OBEX_CLIENT) { + smlTrace(TRACE_INTERNAL, "%s: initializing content types for Samsung", __func__); lcCT = g_ascii_strdown(self->priv->content_type, strlen(self->priv->content_type)); lcSource = g_utf8_strdown(sml_location_get_uri(self->priv->local), @@ -453,6 +455,7 @@ smlSafeCFree(&lcCT); if (lcSource) smlSafeCFree(&lcSource); + smlTrace(TRACE_EXIT, "%s - FALSE", __func__); return FALSE; } Modified: trunk/libsyncml/data_sync_api/sml_data_sync_data_store_internals.h ============================================================================== --- trunk/libsyncml/data_sync_api/sml_data_sync_data_store_internals.h Thu Sep 10 17:24:56 2009 (r1260) +++ trunk/libsyncml/data_sync_api/sml_data_sync_data_store_internals.h Fri Sep 11 23:16:10 2009 (r1261) @@ -27,6 +27,7 @@ G_BEGIN_DECLS +gboolean sml_data_sync_data_store_initialize (SmlDataSyncDataStore *self, GError **error); SmlDataSync* sml_data_sync_data_store_get_data_sync (SmlDataSyncDataStore *self); void sml_data_sync_data_store_set_data_sync (SmlDataSyncDataStore *self, SmlDataSync* ds); SmlLocation* sml_data_sync_data_store_get_remote (SmlDataSyncDataStore *self); Modified: trunk/libsyncml/data_sync_api/sml_data_sync_data_store_session.c ============================================================================== --- trunk/libsyncml/data_sync_api/sml_data_sync_data_store_session.c Thu Sep 10 17:24:56 2009 (r1260) +++ trunk/libsyncml/data_sync_api/sml_data_sync_data_store_session.c Fri Sep 11 23:16:10 2009 (r1261) @@ -586,6 +586,7 @@ sml_data_sync_data_store_session_send_changes (SmlDataSyncDataStoreSession *self, GError **error) { + smlTrace(TRACE_ENTRY, "%s (%p, %p)", __func__, self, error); CHECK_ERROR_REF sml_return_val_error_if_fail (SML_IS_DATA_SYNC_DATA_STORE_SESSION (self), FALSE, error, SML_ERROR_GENERIC, "There must be a SmlDataSyncDataStoreSession object."); @@ -612,8 +613,10 @@ if (!smlDsSessionCloseSync(self->priv->data_store_session, error)) goto error; + smlTrace(TRACE_EXIT, "%s - TRUE", __func__); return TRUE; error: + smlTrace(TRACE_EXIT, "%s - FALSE", __func__); return FALSE; } Modified: trunk/libsyncml/data_sync_api/sml_data_sync_session.c ============================================================================== --- trunk/libsyncml/data_sync_api/sml_data_sync_session.c Thu Sep 10 17:24:56 2009 (r1260) +++ trunk/libsyncml/data_sync_api/sml_data_sync_session.c Fri Sep 11 23:16:10 2009 (r1261) @@ -37,6 +37,39 @@ }; static void +sml_data_sync_session_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec) +{ + switch (property_id) { + case PROP_REMOTE: + g_value_set_object (value, SML_DATA_SYNC_SESSION (object)->priv->remote); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + } +} + +static void +sml_data_sync_session_set_property (GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec) +{ + switch (property_id) { + case PROP_REMOTE: + if (SML_DATA_SYNC_SESSION (object)->priv->remote) + g_object_unref (SML_DATA_SYNC_SESSION (object)->priv->remote); + SML_DATA_SYNC_SESSION (object)->priv->remote = SML_LOCATION (value); + g_object_ref(SML_LOCATION (value)); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + } +} + +static void sml_data_sync_session_free_ds_session(gpointer key) { smlTrace(TRACE_ENTRY, "%s(%p)", __func__, key); @@ -83,6 +116,8 @@ g_type_class_add_private (klass, sizeof (SmlDataSyncSessionPrivate)); + object_class->get_property = sml_data_sync_session_get_property; + object_class->set_property = sml_data_sync_session_set_property; object_class->finalize = sml_data_sync_session_finalize; /** @@ -177,10 +212,10 @@ SmlDataSyncDataStore *datastore, GError **error) { + smlTrace(TRACE_ENTRY, "%s (%p, %p, %p)", __func__, self, datastore, error); + smlTrace(TRACE_INTERNAL, "%s: %s", __func__, sml_data_sync_data_store_get_local_uri(datastore)); SmlDataSyncDataStoreSession *data_store_session = g_hash_table_lookup(self->priv->hash_dsds2dsdss, datastore); - if (data_store_session) { - return data_store_session; - } else { + if (!data_store_session) { data_store_session = sml_data_sync_data_store_session_new(datastore, self, error); self->priv->list_data_store_sessions = g_list_append(self->priv->list_data_store_sessions, data_store_session); g_hash_table_insert(self->priv->hash_dsds2dsdss, datastore, data_store_session); @@ -189,8 +224,10 @@ g_object_ref(data_store_session); g_object_ref(data_store_session); g_object_ref(datastore); - return data_store_session; + smlTrace(TRACE_INTERNAL, "%s: data store sessions => %d", __func__, g_list_length(self->priv->list_data_store_sessions)); } + smlTrace(TRACE_EXIT, "%s - %p", __func__, data_store_session); + return data_store_session; } /** @@ -422,15 +459,22 @@ gboolean sml_data_sync_session_dispatch (SmlDataSyncSession *self) { + smlTrace(TRACE_ENTRY, "%s (%p)", __func__, self); g_return_val_if_fail (SML_IS_DATA_SYNC_SESSION (self), FALSE); GList *o = self->priv->list_data_store_sessions; - for (; o; o = o->next) { + for (; o; o = o->next) + { + smlTrace(TRACE_INTERNAL, "%s: data store session %p", __func__, o->data); SmlDataSyncDataStoreSession *session = o->data; - if (sml_data_sync_data_store_session_dispatch(session)) - return TRUE; + if (!sml_data_sync_data_store_session_dispatch(session)) + { + smlTrace(TRACE_EXIT, "%s - FALSE", __func__); + return FALSE; + } } - return FALSE; + smlTrace(TRACE_EXIT, "%s - TRUE", __func__); + return TRUE; } /** Modified: trunk/tests/CMakeLists.txt ============================================================================== --- trunk/tests/CMakeLists.txt Thu Sep 10 17:24:56 2009 (r1260) +++ trunk/tests/CMakeLists.txt Fri Sep 11 23:16:10 2009 (r1261) @@ -499,16 +499,16 @@ SML_END_TEST() ENDIF( ENABLE_WBXML ) -# IF ( ENABLE_OBEX AND ENABLE_OPENOBEX_TCP AND ENABLE_WBXML AND ENABLE_GLIB2_GREGEX ) -# # mobile tests -# ADD_MOBILE_TEST( nokia_e65_vcard ${TEST_TARGET_LIBRARIES} ) -# ADD_MOBILE_TEST( nokia_e65_vcard_vcal ${TEST_TARGET_LIBRARIES} ) -# ADD_MOBILE_TEST( nokia_6230_vcard ${TEST_TARGET_LIBRARIES} ) -# ADD_MOBILE_TEST( nokia_6230_vcal ${TEST_TARGET_LIBRARIES} ) -# ADD_MOBILE_TEST( nokia_9500_vcard ${TEST_TARGET_LIBRARIES} ) -# ADD_MOBILE_TEST( nokia_9500_vcal ${TEST_TARGET_LIBRARIES} ) -# ADD_MOBILE_TEST( nokia_9500_vcard_vcal ${TEST_TARGET_LIBRARIES} ) -# ENDIF ( ENABLE_OBEX AND ENABLE_OPENOBEX_TCP AND ENABLE_WBXML AND ENABLE_GLIB2_GREGEX ) + IF ( ENABLE_OBEX AND ENABLE_OPENOBEX_TCP AND ENABLE_WBXML AND ENABLE_GLIB2_GREGEX ) + # mobile tests + ADD_MOBILE_TEST( nokia_e65_vcard ${TEST_TARGET_LIBRARIES} ) + ADD_MOBILE_TEST( nokia_e65_vcard_vcal ${TEST_TARGET_LIBRARIES} ) + ADD_MOBILE_TEST( nokia_6230_vcard ${TEST_TARGET_LIBRARIES} ) + ADD_MOBILE_TEST( nokia_6230_vcal ${TEST_TARGET_LIBRARIES} ) + ADD_MOBILE_TEST( nokia_9500_vcard ${TEST_TARGET_LIBRARIES} ) + ADD_MOBILE_TEST( nokia_9500_vcal ${TEST_TARGET_LIBRARIES} ) + ADD_MOBILE_TEST( nokia_9500_vcard_vcal ${TEST_TARGET_LIBRARIES} ) + ENDIF ( ENABLE_OBEX AND ENABLE_OPENOBEX_TCP AND ENABLE_WBXML AND ENABLE_GLIB2_GREGEX ) # IF ( ENABLE_OPENOBEX_TCP OR ENABLE_HTTP ) # SML_START_TEST( "OMA DS API" ds_api check_data_sync_api.c ${TEST_TARGET_LIBRARIES} ) Modified: trunk/tests/mobiles/libsyncml_ds_server.c ============================================================================== --- trunk/tests/mobiles/libsyncml_ds_server.c Thu Sep 10 17:24:56 2009 (r1260) +++ trunk/tests/mobiles/libsyncml_ds_server.c Fri Sep 11 23:16:10 2009 (r1261) @@ -36,36 +36,39 @@ extern const char *identifier; extern const char *locList[]; -#include <libsyncml/data_sync_api/defines.h> -#include <libsyncml/data_sync_api/standard.h> -#include <libsyncml/data_sync_api/callbacks.h> - -static void _libsyncml_event_callback( - SmlDataSyncObject *dsObject, - SmlDataSyncEventType type, - void *userdata, - const GError *error) +#include <libsyncml/data_sync_api/sml_data_sync_defines.h> +#include <libsyncml/data_sync_api/sml_data_sync.h> + +static void +_libsyncml_event_callback (SmlDataSyncSession *session, + SmlDataSync *dsObject, + SmlDataSyncEventType type, + void *userdata, + const GError *error) { - smlTrace(TRACE_ENTRY, "%s(%p, %i, %p, %p)", __func__, dsObject, type, userdata, error); + smlTrace(TRACE_ENTRY, "%s(%p, %p, %i, %p, %p)", __func__, session, dsObject, type, userdata, error); + if (error) + smlTrace(TRACE_INTERNAL, "%s: error ::= %s", __func__, GET_ERROR_MESSAGE(error)); GError *locerror = NULL; switch (type) { - case SML_DATA_SYNC_EVENT_ERROR: + case SML_DATA_SYNC_SESSION_EVENT_ERROR: sml_fail_unless(FALSE, "%s", GET_ERROR_MESSAGE(error)); smlAssert(FALSE); break; - case SML_DATA_SYNC_EVENT_CONNECT: - case SML_DATA_SYNC_EVENT_DISCONNECT: - case SML_DATA_SYNC_EVENT_GOT_ALL_ALERTS: - case SML_DATA_SYNC_EVENT_GOT_ALL_MAPPINGS: + case SML_DATA_SYNC_SESSION_EVENT_CONNECT: + case SML_DATA_SYNC_SESSION_EVENT_DISCONNECT: + case SML_DATA_SYNC_SESSION_EVENT_GOT_ALL_ALERTS: + case SML_DATA_SYNC_SESSION_EVENT_GOT_ALL_MAPPINGS: break; - case SML_DATA_SYNC_EVENT_FINISHED: + case SML_DATA_SYNC_SESSION_EVENT_FINISHED: /* cleanup */ break; - case SML_DATA_SYNC_EVENT_GOT_ALL_CHANGES: + case SML_DATA_SYNC_SESSION_EVENT_GOT_ALL_CHANGES: + sml_fail_unless(session != NULL, "The session must be present on GOT_ALL_CHANGES event."); sml_fail_unless( - smlDataSyncSendChanges(dsObject, &locerror), + sml_data_sync_session_send_changes(session, &locerror), "%s", GET_ERROR_MESSAGE(locerror)); break; default: @@ -75,45 +78,40 @@ smlTrace(TRACE_EXIT, "%s", __func__); } -static gboolean _recv_change( - SmlDataSyncObject *dsObject, - const char *source, - SmlChangeType type, - const char *uid, - char *data, - unsigned int size, - void *userdata, - GError **error) +static gboolean +_recv_change (SmlDataSyncDataStoreSession *session, + SmlDataSyncChangeItem *item, + void *userdata, + GError **error) { - smlTrace(TRACE_INTERNAL, "%s: %s ==> %s (%p, %d, %p, %d, %p, %p)", __func__, VA_STRING(source), VA_STRING(uid), dsObject, type, data, size, userdata, error); - smlSafeCFree(&data); + smlTrace(TRACE_INTERNAL, "%s (%p, %p, %p, %p)", __func__, session, item, userdata, error); return TRUE; } -SmlDataSyncObject *dsObject = NULL; +SmlDataSync *dsObject = NULL; void libsyncml_connect() { + smlTrace(TRACE_ENTRY, "%s", __func__); GError *error = NULL; - dsObject = smlDataSyncNew( - SML_SESSION_TYPE_SERVER, - tspType, - &error); - sml_fail_unless(dsObject != NULL, "%s", GET_ERROR_MESSAGE(error)); + dsObject = sml_data_sync_new(); + sml_fail_unless(dsObject != NULL, "Cannot create SmlDataSync object.", NULL); + sml_fail_unless(sml_data_sync_set_transport_type(dsObject, tspType, &error), "%s", GET_ERROR_MESSAGE(error)); + sml_fail_unless(sml_data_sync_set_session_type(dsObject, SML_SESSION_TYPE_SERVER, &error), "%s", GET_ERROR_MESSAGE(error)); switch(tspType) { case SML_TRANSPORT_OBEX_CLIENT: sml_fail_unless( - smlDataSyncSetOption( + sml_data_sync_set_option( dsObject, SML_DATA_SYNC_CONFIG_CONNECTION_TYPE, SML_DATA_SYNC_CONFIG_CONNECTION_NET, &error), "%s", GET_ERROR_MESSAGE(error)); sml_fail_unless( - smlDataSyncSetOption( + sml_data_sync_set_option( dsObject, SML_TRANSPORT_CONFIG_PORT, obex_port, &error), @@ -124,72 +122,71 @@ } sml_fail_unless( - smlDataSyncSetOption( + sml_data_sync_set_option( dsObject, SML_TRANSPORT_CONFIG_URL, "127.0.0.1", &error), "%s", GET_ERROR_MESSAGE(error)); sml_fail_unless( - smlDataSyncSetOption( + sml_data_sync_set_option( dsObject, SML_DATA_SYNC_CONFIG_MAX_MSG_SIZE, maxMsgSize, &error), "%s", GET_ERROR_MESSAGE(error)); sml_fail_unless( - smlDataSyncSetOption( + sml_data_sync_set_option( dsObject, SML_DATA_SYNC_CONFIG_MAX_OBJ_SIZE, maxObjSize, &error), "%s", GET_ERROR_MESSAGE(error)); sml_fail_unless( - smlDataSyncSetOption( + sml_data_sync_set_option( dsObject, SML_DATA_SYNC_CONFIG_USE_WBXML, enableWbxml, &error), "%s", GET_ERROR_MESSAGE(error)); sml_fail_unless( - smlDataSyncSetOption( + sml_data_sync_set_option( dsObject, SML_DATA_SYNC_CONFIG_IDENTIFIER, identifier, &error), "%s", GET_ERROR_MESSAGE(error)); sml_fail_unless( - smlDataSyncSetOption( + sml_data_sync_set_option( dsObject, SML_DATA_SYNC_CONFIG_USE_TIMESTAMP_ANCHOR, useTimestamp, &error), "%s", GET_ERROR_MESSAGE(error)); sml_fail_unless( - smlDataSyncSetOption( + sml_data_sync_set_option( dsObject, SML_DATA_SYNC_CONFIG_VERSION, "1.1", &error), "%s", GET_ERROR_MESSAGE(error)); - smlDataSyncRegisterEventCallback(dsObject, _libsyncml_event_callback, NULL); - smlDataSyncRegisterChangeCallback(dsObject, _recv_change, NULL); + sml_data_sync_register_event_callback(dsObject, _libsyncml_event_callback, NULL); int i = 0; for (i = 0; locList[2*i] != NULL; i++) { - sml_fail_unless( - smlDataSyncAddDatastore( - dsObject, - locList[2*i+1], /* content-type */ - NULL, - locList[2*i], /* source */ - &error), - "%s", GET_ERROR_MESSAGE(error)); - sml_fail_unless(error == NULL, NULL); + SmlDataSyncDataStore *ds = sml_data_sync_data_store_new(); + sml_data_sync_data_store_set_content_type(ds, locList[2*i+1]); + sml_data_sync_data_store_register_change_callback(ds, _recv_change, NULL); + + sml_data_sync_data_store_set_local_uri(ds, locList[2*i]); + + sml_fail_unless(sml_data_sync_add_data_store(dsObject, ds, &error), "%s", GET_ERROR_MESSAGE(error)); } - sml_fail_unless(smlDataSyncInit(dsObject, &error), "%s", GET_ERROR_MESSAGE(error)); + sml_fail_unless(sml_data_sync_initialize(dsObject, &error), "%s", GET_ERROR_MESSAGE(error)); sml_fail_unless(error == NULL, "%s", GET_ERROR_MESSAGE(error)); - sml_fail_unless(smlDataSyncRun(dsObject, &error), "%s", GET_ERROR_MESSAGE(error)); + sml_fail_unless(sml_data_sync_run(dsObject, &error), "%s", GET_ERROR_MESSAGE(error)); sml_fail_unless(error == NULL, "%s", GET_ERROR_MESSAGE(error)); + + smlTrace(TRACE_EXIT, "%s", __func__); } void libsyncml_disconnect() { - smlDataSyncObjectUnref(&dsObject); + g_object_unref(dsObject); } Modified: trunk/tests/mobiles/obex_mobile_ds_client.c ============================================================================== --- trunk/tests/mobiles/obex_mobile_ds_client.c Thu Sep 10 17:24:56 2009 (r1260) +++ trunk/tests/mobiles/obex_mobile_ds_client.c Fri Sep 11 23:16:10 2009 (r1261) @@ -130,6 +130,8 @@ smlSafeCFree(&original); g_regex_unref(regex); + smlTrace(TRACE_EXIT, "%s => %s", __func__, result); + return result; } |
From: <svn...@op...> - 2009-09-10 21:20:25
|
Author: paule Date: Thu Sep 10 23:20:07 2009 New Revision: 5764 URL: http://www.opensync.org/changeset/5764 Log: opie-sync: Fix for osync_format_env_register_converter API change Modified: plugins/opie-sync/src/opie_format.c Modified: plugins/opie-sync/src/opie_format.c ============================================================================== --- plugins/opie-sync/src/opie_format.c Mon Sep 7 19:51:45 2009 (r5763) +++ plugins/opie-sync/src/opie_format.c Thu Sep 10 23:20:07 2009 (r5764) @@ -1316,14 +1316,14 @@ if (!conv) return FALSE; - osync_format_env_register_converter(env, conv); + osync_format_env_register_converter(env, conv, error); osync_converter_unref(conv); conv = osync_converter_new(OSYNC_CONVERTER_CONV, format2, format1, conv_format2_to_format1, error); if (!conv) return FALSE; - osync_format_env_register_converter(env, conv); + osync_format_env_register_converter(env, conv, error); osync_converter_unref(conv); return TRUE; } |
From: <svn...@op...> - 2009-09-10 15:25:13
|
Author: bellmich Date: Thu Sep 10 17:24:56 2009 New Revision: 1260 URL: http://libsyncml.opensync.org/changeset/1260 Log: updated version handling Added: trunk/libsyncml.pc.cmake.in - copied unchanged from r1201, trunk/libsyncml-1.0.pc.cmake.in Deleted: trunk/libsyncml-1.0.pc.cmake.in Modified: trunk/CMakeLists.txt Modified: trunk/CMakeLists.txt ============================================================================== --- trunk/CMakeLists.txt Thu Sep 10 17:24:34 2009 (r1259) +++ trunk/CMakeLists.txt Thu Sep 10 17:24:56 2009 (r1260) @@ -47,7 +47,7 @@ #MESSAGE(STATUS "CMAKE_MODULE_PATH: ${CMAKE_MODULE_PATH}" ) SET( LIBSYNCML_LIBRARIES_DIR "${LIB_INSTALL_DIR}" CACHE PATH "Syncml library location" ) -SET( LIBSYNCML_INCLUDE_DIR "${INCLUDE_INSTALL_DIR}/libsyncml-1.0" CACHE PATH "Syncml headers location" ) +SET( LIBSYNCML_INCLUDE_DIR "${INCLUDE_INSTALL_DIR}/libsyncml-${LIBSYNCML_LIBVERSION_SOVERSION}.${LIBSYNCML_LIBVERSION_AGE}" CACHE PATH "Syncml headers location" ) SET( LIBSYNCML_BIN_DIR "${BIN_INSTALL_DIR}" CACHE PATH "Syncml binaries location" ) SET( LIBSYNCML_DATA_DIR "${CMAKE_INSTALL_PREFIX}/share" CACHE PATH "Syncml data location" ) SET( LIBSYNCML_EXEC_INSTALL_DIR "${BIN_INSTALL_DIR}" CACHE PATH "Syncml binary location" ) @@ -208,7 +208,7 @@ SET( VERSION "${LIBSYNCML_VERSION}" ) CONFIGURE_FILE( "config.h.cmake" "${CMAKE_CURRENT_BINARY_DIR}/config.h") -CONFIGURE_FILE( "libsyncml-1.0.pc.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/libsyncml-1.0.pc" @ONLY) +CONFIGURE_FILE( "libsyncml.pc.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/libsyncml-${LIBSYNCML_LIBVERSION_SOVERSION}.${LIBSYNCML_LIBVERSION_AGE}.pc" @ONLY) # add uninstall target CONFIGURE_FILE( "${CMAKE_SOURCE_DIR}/cmake/modules/cmake_uninstall.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" IMMEDIATE @ONLY) @@ -247,7 +247,7 @@ ENDIF ( BUILD_DOCUMENTATION ) # todo: add requires in pc file -INSTALL( FILES "${CMAKE_CURRENT_BINARY_DIR}/libsyncml-1.0.pc" DESTINATION "${LIBDATA_INSTALL_DIR}/pkgconfig/" ) +INSTALL( FILES "${CMAKE_CURRENT_BINARY_DIR}/libsyncml-${LIBSYNCML_LIBVERSION_SOVERSION}.${LIBSYNCML_LIBVERSION_AGE}.pc" DESTINATION "${LIBDATA_INSTALL_DIR}/pkgconfig/" ) # status output INCLUDE( ShowStatus ) |
From: <svn...@op...> - 2009-09-10 15:24:49
|
Author: bellmich Date: Thu Sep 10 17:24:34 2009 New Revision: 1259 URL: http://libsyncml.opensync.org/changeset/1259 Log: GObject introspection is supported the complete API now Modified: trunk/tools/syncml-gir-scanner.sh.cmake Modified: trunk/tools/syncml-gir-scanner.sh.cmake ============================================================================== --- trunk/tools/syncml-gir-scanner.sh.cmake Thu Sep 10 17:15:04 2009 (r1258) +++ trunk/tools/syncml-gir-scanner.sh.cmake Thu Sep 10 17:24:34 2009 (r1259) @@ -8,6 +8,16 @@ SML_HEADER="$SML_HEADER @LIBSYNCML_INCLUDE_DIR@/libsyncml/dev_inf_api/sml_dev_inf.h" SML_HEADER="$SML_HEADER @LIBSYNCML_INCLUDE_DIR@/libsyncml/dev_inf_api/sml_dev_inf_enum_types.h" +SML_HEADER="$SML_HEADER @LIBSYNCML_INCLUDE_DIR@/libsyncml/data_sync_api/sml_location.h" +SML_HEADER="$SML_HEADER @LIBSYNCML_INCLUDE_DIR@/libsyncml/data_sync_api/sml_map_item.h" +SML_HEADER="$SML_HEADER @LIBSYNCML_INCLUDE_DIR@/libsyncml/data_sync_api/sml_data_sync_change_item.h" +SML_HEADER="$SML_HEADER @LIBSYNCML_INCLUDE_DIR@/libsyncml/data_sync_api/sml_data_sync_defines.h" +SML_HEADER="$SML_HEADER @LIBSYNCML_INCLUDE_DIR@/libsyncml/data_sync_api/sml_data_sync_enum_types.h" +SML_HEADER="$SML_HEADER @LIBSYNCML_INCLUDE_DIR@/libsyncml/data_sync_api/sml_data_sync.h" +SML_HEADER="$SML_HEADER @LIBSYNCML_INCLUDE_DIR@/libsyncml/data_sync_api/sml_data_sync_session.h" +SML_HEADER="$SML_HEADER @LIBSYNCML_INCLUDE_DIR@/libsyncml/data_sync_api/sml_data_sync_data_store.h" +SML_HEADER="$SML_HEADER @LIBSYNCML_INCLUDE_DIR@/libsyncml/data_sync_api/sml_data_sync_data_store_session.h" + g-ir-scanner \ --namespace=Sml \ --library=syncml \ |
From: <svn...@op...> - 2009-09-07 17:52:03
|
Author: scriptor Date: Mon Sep 7 19:51:45 2009 New Revision: 5763 URL: http://www.opensync.org/changeset/5763 Log: As it seems, I cannot free this from inside the LDAP plugin. Well, then so be it. Cf. valgrind output: ctest -R vg_osynctool_add_contact1_ldif -V ==6123== Thread 5: ==6123== Invalid read of size 4 ==6123== at 0x3217A14B32: g_atomic_int_exchange_and_add (in /lib64/libglib-2.0.so.0.2000.1) ==6123== by 0x4C7F73D: osync_objtype_sink_unref (opensync_objtype_sink.c:77) ==6123== by 0x4C7C842: osync_plugin_info_unref (opensync_plugin_info.c:67) ==6123== by 0x4C46ED8: _osync_client_message_handler (opensync_client.c:840) ==6123== by 0x4C6E84B: _incoming_dispatch (opensync_queue.c:399) ==6123== by 0x3217A3818D: g_main_context_dispatch (in /lib64/libglib-2.0.so.0.2000.1) ==6123== by 0x3217A3B8E7: (within /lib64/libglib-2.0.so.0.2000.1) ==6123== by 0x3217A3BD84: g_main_loop_run (in /lib64/libglib-2.0.so.0.2000.1) ==6123== by 0x3217A616E3: (within /lib64/libglib-2.0.so.0.2000.1) ==6123== by 0x3216E06869: start_thread (in /lib64/libpthread-2.10.1.so) ==6123== by 0x32162DE25C: clone (in /lib64/libc-2.10.1.so) ==6123== Address 0xc78d51c is 188 bytes inside a block of size 200 free'd ==6123== at 0x4A0633D: free (vg_replace_malloc.c:323) ==6123== by 0x8BA8FCB: ldap_plugin_free_env (ldap_plugin.c:137) ==6123== by 0x8BB1F87: ldap_plugin_finalize (ldap_plugin.c:4275) ==6123== by 0x4C46EA3: _osync_client_message_handler (opensync_client.c:828) ==6123== by 0x4C6E84B: _incoming_dispatch (opensync_queue.c:399) ==6123== by 0x3217A3818D: g_main_context_dispatch (in /lib64/libglib-2.0.so.0.2000.1) ==6123== by 0x3217A3B8E7: (within /lib64/libglib-2.0.so.0.2000.1) ==6123== by 0x3217A3BD84: g_main_loop_run (in /lib64/libglib-2.0.so.0.2000.1) ==6123== by 0x3217A616E3: (within /lib64/libglib-2.0.so.0.2000.1) ==6123== by 0x3216E06869: start_thread (in /lib64/libpthread-2.10.1.so) ==6123== by 0x32162DE25C: clone (in /lib64/libc-2.10.1.so) Modified: plugins/ldap-sync/src/ldap_plugin.c plugins/ldap-sync/tests/opensync.suppr Modified: plugins/ldap-sync/src/ldap_plugin.c ============================================================================== --- plugins/ldap-sync/src/ldap_plugin.c Mon Sep 7 03:01:09 2009 (r5762) +++ plugins/ldap-sync/src/ldap_plugin.c Mon Sep 7 19:51:45 2009 (r5763) @@ -133,9 +133,45 @@ env->sink_envs = g_list_remove(env->sink_envs, sinkenv); +/* + +I have commented out the following code, because of this +memory error: + +==6123== Thread 5: +==6123== Invalid read of size 4 +==6123== at 0x3217A14B32: g_atomic_int_exchange_and_add (in /lib64/libglib-2.0.so.0.2000.1) +==6123== by 0x4C7F73D: osync_objtype_sink_unref (opensync_objtype_sink.c:77) +==6123== by 0x4C7C842: osync_plugin_info_unref (opensync_plugin_info.c:67) +==6123== by 0x4C46ED8: _osync_client_message_handler (opensync_client.c:840) +==6123== by 0x4C6E84B: _incoming_dispatch (opensync_queue.c:399) +==6123== by 0x3217A3818D: g_main_context_dispatch (in /lib64/libglib-2.0.so.0.2000.1) +==6123== by 0x3217A3B8E7: (within /lib64/libglib-2.0.so.0.2000.1) +==6123== by 0x3217A3BD84: g_main_loop_run (in /lib64/libglib-2.0.so.0.2000.1) +==6123== by 0x3217A616E3: (within /lib64/libglib-2.0.so.0.2000.1) +==6123== by 0x3216E06869: start_thread (in /lib64/libpthread-2.10.1.so) +==6123== by 0x32162DE25C: clone (in /lib64/libc-2.10.1.so) +==6123== Address 0xc78d51c is 188 bytes inside a block of size 200 free'd +==6123== at 0x4A0633D: free (vg_replace_malloc.c:323) +==6123== by 0x8BA8FCB: ldap_plugin_free_env (ldap_plugin.c:137) +==6123== by 0x8BB1F87: ldap_plugin_finalize (ldap_plugin.c:4275) +==6123== by 0x4C46EA3: _osync_client_message_handler (opensync_client.c:828) +==6123== by 0x4C6E84B: _incoming_dispatch (opensync_queue.c:399) +==6123== by 0x3217A3818D: g_main_context_dispatch (in /lib64/libglib-2.0.so.0.2000.1) +==6123== by 0x3217A3B8E7: (within /lib64/libglib-2.0.so.0.2000.1) +==6123== by 0x3217A3BD84: g_main_loop_run (in /lib64/libglib-2.0.so.0.2000.1) +==6123== by 0x3217A616E3: (within /lib64/libglib-2.0.so.0.2000.1) +==6123== by 0x3216E06869: start_thread (in /lib64/libpthread-2.10.1.so) +==6123== by 0x32162DE25C: clone (in /lib64/libc-2.10.1.so) + + */ + +#if 0 if (sinkenv && sinkenv->sink) { osync_objtype_sink_unref(sinkenv->sink); ///< @sa ldap_plugin_initialize_sink() } +#endif + } env->sink_envs = NULL; Modified: plugins/ldap-sync/tests/opensync.suppr ============================================================================== --- plugins/ldap-sync/tests/opensync.suppr Mon Sep 7 03:01:09 2009 (r5762) +++ plugins/ldap-sync/tests/opensync.suppr Mon Sep 7 19:51:45 2009 (r5763) @@ -12,40 +12,6 @@ } -{ - <invalid read 1> - Memcheck:Addr4 - fun:g_atomic_int_exchange_and_add - fun:osync_objtype_sink_unref - fun:osync_plugin_info_unref - fun:_osync_client_handle_finalize - fun:_osync_client_message_handler - fun:_incoming_dispatch - fun:g_main_context_dispatch - obj:/lib/libglib-2.0.so.0.1800.3 - fun:g_main_loop_run - fun:osync_client_run_and_block - fun:main -} - - - -{ - <invalid_read 2> - Memcheck:Addr4 - fun:g_atomic_int_exchange_and_add - fun:osync_plugin_info_unref - fun:_osync_client_handle_finalize - fun:_osync_client_message_handler - fun:_incoming_dispatch - fun:g_main_context_dispatch - obj:/lib/libglib-2.0.so.0.1800.3 - fun:g_main_loop_run - obj:/lib/libglib-2.0.so.0.1800.3 - fun:start_thread - fun:clone -} - @@ -2194,23 +2160,6 @@ -{ - <ldap_plugin.c:78: osync_objtype_sink_unref(sinkenv->sink); and later, on: Invalid read of size 4 > - Memcheck:Addr4 - fun:g_atomic_int_exchange_and_add - fun:osync_objtype_sink_unref - fun:osync_plugin_info_unref - fun:_osync_client_handle_finalize - fun:_osync_client_message_handler - fun:_incoming_dispatch - fun:g_main_context_dispatch - obj:/lib/libglib-2.0.so.0.1800.3 - fun:g_main_loop_run - obj:/lib/libglib-2.0.so.0.1800.3 - fun:start_thread - fun:clone -} - @@ -4374,20 +4323,3 @@ -{ - <Invalid read of size 4 - because of ldap_plugin_free_env() in ldap_plugin_finalize() > - Memcheck:Addr4 - fun:g_atomic_int_exchange_and_add - fun:osync_objtype_sink_unref - fun:osync_plugin_info_unref - fun:_osync_client_handle_finalize - fun:_osync_client_message_handler - fun:_incoming_dispatch - fun:g_main_context_dispatch - obj:/lib64/libglib-2.0.so.0.2000.1 - fun:g_main_loop_run - obj:/lib64/libglib-2.0.so.0.2000.1 - fun:start_thread - fun:clone -} - |
From: <svn...@op...> - 2009-09-07 01:01:37
|
Author: dgollub Date: Mon Sep 7 03:01:09 2009 New Revision: 5762 URL: http://www.opensync.org/changeset/5762 Log: Convert the capabilities format to a capabilities format of a merger which is able to demerge capabilties of the current objformat. e.g.: evo2-caps to xmlformat the capsformat Modified: trunk/opensync.sym trunk/opensync/engine/opensync_mapping_engine.c trunk/opensync/engine/opensync_obj_engine.c Modified: trunk/opensync.sym ============================================================================== --- trunk/opensync.sym Mon Sep 7 02:58:49 2009 (r5761) +++ trunk/opensync.sym Mon Sep 7 03:01:09 2009 (r5762) @@ -164,6 +164,7 @@ osync_format_env_convert osync_format_env_detect_objformat osync_format_env_detect_objformat_full +osync_format_env_find_caps_converter osync_format_env_find_caps_converters osync_format_env_find_converter osync_format_env_find_converters Modified: trunk/opensync/engine/opensync_mapping_engine.c ============================================================================== --- trunk/opensync/engine/opensync_mapping_engine.c Mon Sep 7 02:58:49 2009 (r5761) +++ trunk/opensync/engine/opensync_mapping_engine.c Mon Sep 7 03:01:09 2009 (r5762) @@ -464,10 +464,14 @@ if (osync_change_get_changetype(rightchange) == OSYNC_CHANGE_TYPE_UNKNOWN) continue; + /* XXX: this compare is obsolate?! we do one complicated compare with dermging before this step! */ +#if 1 if (osync_change_compare(leftchange, rightchange) != OSYNC_CONV_DATA_SAME) { engine->conflict = TRUE; goto conflict; - } else { + } else +#endif + { is_same++; /* Update the change to the master change. Modified: trunk/opensync/engine/opensync_obj_engine.c ============================================================================== --- trunk/opensync/engine/opensync_obj_engine.c Mon Sep 7 02:58:49 2009 (r5761) +++ trunk/opensync/engine/opensync_obj_engine.c Mon Sep 7 03:01:09 2009 (r5762) @@ -47,6 +47,7 @@ #include "client/opensync_client_proxy_internals.h" #include "group/opensync_member_internals.h" #include "format/opensync_objformat_internals.h" +#include "format/opensync_format_env_internals.h" #include "format/opensync_merger_internals.h" #include "mapping/opensync_mapping_table_internals.h" #include "mapping/opensync_mapping_table_internals.h" @@ -203,21 +204,65 @@ static OSyncChange *_osync_obj_engine_clone_and_demerge_change(OSyncObjEngine *engine, OSyncCapabilities *caps, OSyncChange *change, OSyncError **error) { - + OSyncList *mergers, *m; OSyncFormatEnv *formatenv = engine->formatenv; + osync_trace(TRACE_ENTRY, "%s(%p, %p, %p, %p)", __func__, engine, caps, change, error); + OSyncChange *clone_change = osync_change_clone(change, error); if (!clone_change) goto error; + + + //OSyncCapabilities *caps = osync_member_get_capabilities(member); + const char *current_capsformat = osync_capabilities_get_format(caps); + OSyncObjFormat *objformat = osync_change_get_objformat(clone_change); OSyncMerger *merger = osync_format_env_find_merger(formatenv, - osync_objformat_get_name(osync_change_get_objformat(clone_change)), - osync_capabilities_get_format(caps)); + osync_objformat_get_name(objformat), osync_capabilities_get_format(caps)); + + if (!merger) { + + osync_trace(TRACE_INTERNAL, "Couldn't found merger for capsformat \"%s\" and objformat \"%s\". Looking further.", + current_capsformat, osync_objformat_get_name(objformat)); + + mergers = osync_format_env_find_mergers_objformat(formatenv, osync_objformat_get_name(objformat)); + for (m = mergers; m; m = m->next) { + OSyncMerger *it_merger = (OSyncMerger *) m->data; + OSyncCapsConverter *caps_converter; + const char *capsformat = osync_merger_get_capsformat(it_merger); + + /* Find OSyncCapsConverter */ + caps_converter = osync_format_env_find_caps_converter(formatenv, current_capsformat, capsformat); + if (!caps_converter) + continue; + + /* Convert capabilities if there is a chance to do so ... */ + if (!osync_caps_converter_invoke(caps_converter, &caps, NULL /* config */, error)) + goto error; + - if (merger && caps &&!osync_merger_demerge(merger, clone_change, caps, error)) + // osync_member_set_capabilities(member, caps, error); + + merger = it_merger; + + break; + } + + } + + if (!merger) { + osync_error_set(error, OSYNC_ERROR_GENERIC, "Couldn't handle the capabilities in format \"%s\" to process a reported change in format \"%s\"", + current_capsformat, osync_objformat_get_name(objformat)); goto error; + } + if (!osync_merger_demerge(merger, clone_change, caps, error)) + goto error; + + osync_trace(TRACE_EXIT, "%s: %p", __func__, clone_change); return clone_change; error: + osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(error)); return NULL; } @@ -263,8 +308,10 @@ OSyncChange *change1 = change; OSyncChange *change2 = mapping_change; + osync_trace(TRACE_INTERNAL, "Member1-caps: %p Member2-caps: %p", caps1, caps2); + if (caps1) { - clone_change1 = _osync_obj_engine_clone_and_demerge_change(sinkengine->engine, caps1, change, error); + clone_change1 = _osync_obj_engine_clone_and_demerge_change(sinkengine->engine, caps1, change2, error); if (!clone_change1) goto error; @@ -272,7 +319,7 @@ } if (caps2) { - clone_change2 = _osync_obj_engine_clone_and_demerge_change(sinkengine->engine, caps2, mapping_change, error); + clone_change2 = _osync_obj_engine_clone_and_demerge_change(sinkengine->engine, caps2, change1, error); if (!clone_change2) goto error; |
From: <svn...@op...> - 2009-09-07 00:59:00
|
Author: dgollub Date: Mon Sep 7 02:58:49 2009 New Revision: 5761 URL: http://www.opensync.org/changeset/5761 Log: Don't unref the origianl capabilities object. This caused various issues in the test-suite. TODO: check if this is not leaking the old capabiltieis object. Sort capabiliteis object after caps-format conversion Modified: trunk/opensync/format/opensync_caps_converter.c Modified: trunk/opensync/format/opensync_caps_converter.c ============================================================================== --- trunk/opensync/format/opensync_caps_converter.c Mon Sep 7 02:57:32 2009 (r5760) +++ trunk/opensync/format/opensync_caps_converter.c Mon Sep 7 02:58:49 2009 (r5761) @@ -110,7 +110,11 @@ if (!converter->convert_func(*caps, &new_caps, config, converter->userdata, error)) goto error; - osync_capabilities_unref(*caps); + /* Sort capabilities by field-Name */ + osync_capabilities_sort(new_caps); + + /* TODO: check if the old capabilities object is really not leaking. */ + /* osync_capabilities_unref(*caps); */ *caps = new_caps; osync_capabilities_set_format(*caps, converter->target_capsformat); |
From: <svn...@op...> - 2009-09-07 00:58:10
|
Author: dgollub Date: Mon Sep 7 02:57:32 2009 New Revision: 5760 URL: http://www.opensync.org/changeset/5760 Log: Note for final API review Modified: trunk/opensync/group/opensync_member.c Modified: trunk/opensync/group/opensync_member.c ============================================================================== --- trunk/opensync/group/opensync_member.c Mon Sep 7 02:57:11 2009 (r5759) +++ trunk/opensync/group/opensync_member.c Mon Sep 7 02:57:32 2009 (r5760) @@ -865,6 +865,7 @@ return member->capabilities; } +/* FIXME - why has this bool as return value - there is never return FALSE! */ osync_bool osync_member_set_capabilities(OSyncMember *member, OSyncCapabilities *capabilities, OSyncError **error) { osync_assert(member); |
From: <svn...@op...> - 2009-09-07 00:57:24
|
Author: dgollub Date: Mon Sep 7 02:57:11 2009 New Revision: 5759 URL: http://www.opensync.org/changeset/5759 Log: Implementation of r5758 Modified: trunk/opensync/format/opensync_format_env.c Modified: trunk/opensync/format/opensync_format_env.c ============================================================================== --- trunk/opensync/format/opensync_format_env.c Mon Sep 7 02:56:48 2009 (r5758) +++ trunk/opensync/format/opensync_format_env.c Mon Sep 7 02:57:11 2009 (r5759) @@ -1041,6 +1041,25 @@ return NULL; } + +OSyncList *osync_format_env_find_mergers_objformat(OSyncFormatEnv *env, const char *objformat) +{ + OSyncList *m, *result = NULL; + osync_assert(env); + osync_assert(objformat); + + + for (m = env->mergers; m; m = m->next) { + OSyncMerger *merger = m->data; + if (strcmp(objformat, osync_merger_get_objformat(merger))) + continue; + + result = osync_list_append(result, merger); + } + + return result; +} + OSyncObjFormat *osync_format_env_detect_objformat(OSyncFormatEnv *env, OSyncData *data) { OSyncList *d = NULL; |
From: <svn...@op...> - 2009-09-07 00:57:21
|
Author: dgollub Date: Mon Sep 7 02:56:48 2009 New Revision: 5758 URL: http://www.opensync.org/changeset/5758 Log: Add interface osync_format_env_find_mergers_objformat() to get a list of all mergers which are able to deal with a specified objformat Modified: trunk/opensync/format/opensync_format_env_internals.h Modified: trunk/opensync/format/opensync_format_env_internals.h ============================================================================== --- trunk/opensync/format/opensync_format_env_internals.h Mon Sep 7 02:54:23 2009 (r5757) +++ trunk/opensync/format/opensync_format_env_internals.h Mon Sep 7 02:56:48 2009 (r5758) @@ -21,6 +21,8 @@ #ifndef _OPENSYNC_FORMAT_ENV_INTERNALS_H_ #define _OPENSYNC_FORMAT_ENV_INTERNALS_H_ +#include "opensync/format/opensync_filter_internals.h" + /** * @defgroup OSyncFormatEnvInternalAPI OpenSync Format Environment Internals * @ingroup OSyncFormatPrivate @@ -163,6 +165,8 @@ */ OSYNC_TEST_EXPORT OSyncFormatConverter *osync_format_env_nth_converter(OSyncFormatEnv *env, int nth); +OSYNC_TEST_EXPORT OSyncList *osync_format_env_find_mergers_objformat(OSyncFormatEnv *env, const char *objformat); + /*@}*/ |
From: <svn...@op...> - 2009-09-07 00:54:38
|
Author: dgollub Date: Mon Sep 7 02:54:23 2009 New Revision: 5757 URL: http://www.opensync.org/changeset/5757 Log: Added interfaces for OSyncCapabilities API to sort the capabilities object. This is handy after converting/assemling to a different capsformat. Sorted capabilities is required by various mergers. e.g. the xmlformat merger Modified: trunk/opensync/capabilities/opensync_capabilities.c trunk/opensync/capabilities/opensync_capabilities_internals.h trunk/opensync/capabilities/opensync_capabilities_objtype.c trunk/opensync/capabilities/opensync_capabilities_objtype_internals.h trunk/opensync/capabilities/opensync_capability.c trunk/opensync/capabilities/opensync_capability_internals.h Modified: trunk/opensync/capabilities/opensync_capabilities.c ============================================================================== --- trunk/opensync/capabilities/opensync_capabilities.c Mon Sep 7 02:51:40 2009 (r5756) +++ trunk/opensync/capabilities/opensync_capabilities.c Mon Sep 7 02:54:23 2009 (r5757) @@ -306,3 +306,16 @@ capabilities->objtypes = osync_list_append(capabilities->objtypes, capabilitiesobjtype); } +void osync_capabilities_sort(OSyncCapabilities *capabilities) +{ + OSyncList *l; + osync_assert(capabilities); + + for (l = capabilities->objtypes; l; l = l->next) { + OSyncCapabilitiesObjType *capsobjtype = (OSyncCapabilitiesObjType *) l->data; + + osync_capabilities_objtype_sort(capsobjtype); + } + +} + Modified: trunk/opensync/capabilities/opensync_capabilities_internals.h ============================================================================== --- trunk/opensync/capabilities/opensync_capabilities_internals.h Mon Sep 7 02:51:40 2009 (r5756) +++ trunk/opensync/capabilities/opensync_capabilities_internals.h Mon Sep 7 02:54:23 2009 (r5757) @@ -85,6 +85,8 @@ */ OSYNC_TEST_EXPORT OSyncCapabilities *osync_capabilities_parse(const char *buffer, unsigned int size, OSyncError **error); +OSYNC_TEST_EXPORT void osync_capabilities_sort(OSyncCapabilities *capabilities); + /*@}*/ Modified: trunk/opensync/capabilities/opensync_capabilities_objtype.c ============================================================================== --- trunk/opensync/capabilities/opensync_capabilities_objtype.c Mon Sep 7 02:51:40 2009 (r5756) +++ trunk/opensync/capabilities/opensync_capabilities_objtype.c Mon Sep 7 02:54:23 2009 (r5757) @@ -163,3 +163,8 @@ capsobjtype->capabilities = osync_list_append(capsobjtype->capabilities, capability); } +void osync_capabilities_objtype_sort(OSyncCapabilitiesObjType *capsobjtype) +{ + capsobjtype->capabilities = osync_list_sort(capsobjtype->capabilities, osync_capability_compare); +} + Modified: trunk/opensync/capabilities/opensync_capabilities_objtype_internals.h ============================================================================== --- trunk/opensync/capabilities/opensync_capabilities_objtype_internals.h Mon Sep 7 02:51:40 2009 (r5756) +++ trunk/opensync/capabilities/opensync_capabilities_objtype_internals.h Mon Sep 7 02:54:23 2009 (r5757) @@ -53,6 +53,8 @@ OSYNC_TEST_EXPORT void osync_capabilities_objtype_add_capability(OSyncCapabilitiesObjType *capsobjtype, OSyncCapability *capability); +OSYNC_TEST_EXPORT void osync_capabilities_objtype_sort(OSyncCapabilitiesObjType *capsobjtype); + /*@}*/ #endif /*OPENSYNC_CAPABILITIES_OBJTYPE_INTERNAL_H_*/ Modified: trunk/opensync/capabilities/opensync_capability.c ============================================================================== --- trunk/opensync/capabilities/opensync_capability.c Mon Sep 7 02:51:40 2009 (r5756) +++ trunk/opensync/capabilities/opensync_capability.c Mon Sep 7 02:54:23 2009 (r5757) @@ -35,6 +35,10 @@ return strcmp(osync_capability_get_name(*(OSyncCapability **)capability1), osync_capability_get_name(*(OSyncCapability **)capability2)); } +int osync_capability_compare(const void *capability1, const void *capability2) +{ + return strcmp(osync_capability_get_name((OSyncCapability *)capability1), osync_capability_get_name((OSyncCapability *)capability2)); +} OSyncCapability *osync_capability_parse_child(OSyncCapability *cap, xmlNodePtr node, OSyncError **error) { Modified: trunk/opensync/capabilities/opensync_capability_internals.h ============================================================================== --- trunk/opensync/capabilities/opensync_capability_internals.h Mon Sep 7 02:51:40 2009 (r5756) +++ trunk/opensync/capabilities/opensync_capability_internals.h Mon Sep 7 02:54:23 2009 (r5757) @@ -53,13 +53,21 @@ void osync_capability_free(OSyncCapability *capability); /** - * @brief Compare the names of two capabilities + * @brief Compare the names of two capabilities (for stdlib) + * + * 1st and 2nd pointer get dereferneced, to fit the needs of e.g. qsort() + * * @param capability1 The pointer to a capability object * @param capability2 The pointer to a capability object */ int osync_capability_compare_stdlib(const void *capability1, const void *capability2); - +/** + * @brief Compare the names of two capabilities + * @param capability1 The pointer to a capability object + * @param capability2 The pointer to a capability object + */ +int osync_capability_compare(const void *capability1, const void *capability2); /*@}*/ |
From: <svn...@op...> - 2009-09-07 00:51:47
|
Author: dgollub Date: Mon Sep 7 02:51:40 2009 New Revision: 5756 URL: http://www.opensync.org/changeset/5756 Log: Fix typo in declaration Modified: trunk/opensync/format/opensync_format_env.h Modified: trunk/opensync/format/opensync_format_env.h ============================================================================== --- trunk/opensync/format/opensync_format_env.h Mon Sep 7 02:42:16 2009 (r5755) +++ trunk/opensync/format/opensync_format_env.h Mon Sep 7 02:51:40 2009 (r5756) @@ -158,7 +158,7 @@ * @returns The converter, or NULL if not found * */ -OSYNC_EXPORT OSyncCapsConverter *osync_format_env_find__caps_converter(OSyncFormatEnv *env, const char *sourcecapsformat, const char *targetcapsformat); +OSYNC_EXPORT OSyncCapsConverter *osync_format_env_find_caps_converter(OSyncFormatEnv *env, const char *sourcecapsformat, const char *targetcapsformat); /** @brief Returns a list of all capabilities converters with the given source and target format * |
From: <svn...@op...> - 2009-09-07 00:43:34
|
Author: dgollub Date: Mon Sep 7 02:38:18 2009 New Revision: 5753 URL: http://www.opensync.org/changeset/5753 Log: Implemented initial evolution2 format plugin to convert native capabilities to xmlformat-like capabilities. Added: plugins/evolution2/src/evolution2_format.c Modified: plugins/evolution2/src/CMakeLists.txt plugins/evolution2/src/evolution2_capabilities.c Modified: plugins/evolution2/src/CMakeLists.txt ============================================================================== --- plugins/evolution2/src/CMakeLists.txt Mon Sep 7 02:27:45 2009 (r5752) +++ plugins/evolution2/src/CMakeLists.txt Mon Sep 7 02:38:18 2009 (r5753) @@ -9,10 +9,14 @@ ) OPENSYNC_PLUGIN_ADD( evo2-sync ${evo2_sync_LIB_SRCS} ) +OPENSYNC_FORMAT_ADD( evo2-format evolution2_format.c ) TARGET_LINK_LIBRARIES( evo2-sync ${LIBEBOOK_LIBRARIES} ${LIBECAL_LIBRARIES} ${LIBEDATABOOK_LIBRARIES} ${LIBEDATACAL_LIBRARIES} ${LIBEDATASERVER_LIBRARIES} ${OPENSYNC_LIBRARIES} ) +TARGET_LINK_LIBRARIES( evo2-format ${OPENSYNC_LIBRARIES} ${GLIB2_LIBRARIES} ) ###### INSTALL ################### OPENSYNC_PLUGIN_INSTALL( evo2-sync ) - OPENSYNC_PLUGIN_CONFIG( evo2-sync ) + +OPENSYNC_FORMAT_INSTALL( evo2-format ) + Modified: plugins/evolution2/src/evolution2_capabilities.c ============================================================================== --- plugins/evolution2/src/evolution2_capabilities.c Mon Sep 7 02:27:45 2009 (r5752) +++ plugins/evolution2/src/evolution2_capabilities.c Mon Sep 7 02:38:18 2009 (r5753) @@ -25,78 +25,10 @@ #include "evolution2_capabilities.h" -#define cast_g_hash_table_insert(hash, a, b) g_hash_table_insert(hash, (gpointer) a, (gpointer) b) - -static GHashTable* get_ebook_to_xmlformat_hash() -{ - osync_trace(TRACE_ENTRY, "%s", __func__); - GHashTable *hash = g_hash_table_new(g_str_hash, g_str_equal); - - cast_g_hash_table_insert(hash, "address", "Address"); - cast_g_hash_table_insert(hash, "address_label_home", "AddressLabel"); - cast_g_hash_table_insert(hash, "address_label_other", "AddressLabel"); - cast_g_hash_table_insert(hash, "address_label_work", "AddressLabel"); - cast_g_hash_table_insert(hash, "anniversary", "Anniversary"); - cast_g_hash_table_insert(hash, "assistant", "Assistant"); - cast_g_hash_table_insert(hash, "birth_date", "Birthday"); - cast_g_hash_table_insert(hash, "blog_url", "BlogUrl"); - cast_g_hash_table_insert(hash, "caluri", "CalendarUrl"); - cast_g_hash_table_insert(hash, "categories", "Categories"); - /* cast_g_hash_table_insert(hash, "", "Class");*/ - cast_g_hash_table_insert(hash, "email_1", "EMail"); - cast_g_hash_table_insert(hash, "email_2", "EMail"); - cast_g_hash_table_insert(hash, "email_3", "EMail"); - cast_g_hash_table_insert(hash, "email_4", "EMail"); - cast_g_hash_table_insert(hash, "email", "EMail"); - cast_g_hash_table_insert(hash, "file_as", "FileAs"); - cast_g_hash_table_insert(hash, "full_name", "FormattedName"); - cast_g_hash_table_insert(hash, "fburl", "FreeBusyUrl"); - /* cast_g_hash_table_insert(hash, "", "GroupwiseDirectory");*/ - cast_g_hash_table_insert(hash, "im_aim", "IM-AIM"); - cast_g_hash_table_insert(hash, "im_gadugadu", "IM-GaduGadu"); - cast_g_hash_table_insert(hash, "im_icq", "IM-ICQ"); - cast_g_hash_table_insert(hash, "im_jabber", "IM-Jabber"); - cast_g_hash_table_insert(hash, "im_msn", "IM-MSN"); - /* cast_g_hash_table_insert(hash, "", "IM-Yabber");*/ - cast_g_hash_table_insert(hash, "im_yahoo", "IM-Yahoo"); - /* cast_g_hash_table_insert(hash, "", "IRC");*/ - /* cast_g_hash_table_insert(hash, "", "KDE-Extension");*/ - /* cast_g_hash_table_insert(hash, "", "Key");*/ - /* cast_g_hash_table_insert(hash, "", "Location");*/ - cast_g_hash_table_insert(hash, "logo", "Logo"); - cast_g_hash_table_insert(hash, "manager", "Manager"); - cast_g_hash_table_insert(hash, "name", "Name"); - cast_g_hash_table_insert(hash, "nickname", "Nickname"); - cast_g_hash_table_insert(hash, "note", "Note"); - cast_g_hash_table_insert(hash, "org", "Organization"); - cast_g_hash_table_insert(hash, "photo", "Photo"); - /*cast_g_hash_table_insert(hash, "", "PhotoUrl");*/ - - /*To match the vcard translators view that evolution role is really profession */ - cast_g_hash_table_insert(hash, "role", "Profession"); - cast_g_hash_table_insert(hash, "Rev", "Revision"); - /* cast_g_hash_table_insert(hash, "", "Role"); Evolution's role is profession */ - /* cast_g_hash_table_insert(hash, "", "SMS");*/ - /* cast_g_hash_table_insert(hash, "", "Sound");*/ - cast_g_hash_table_insert(hash, "spouse", "Spouse"); - cast_g_hash_table_insert(hash, "phone", "Telephone"); - cast_g_hash_table_insert(hash, "title", "Title"); - cast_g_hash_table_insert(hash, "id", "Uid"); - cast_g_hash_table_insert(hash, "homepage_url", "Url"); - /* cast_g_hash_table_insert(hash, "", "UserDefined");*/ - /* cast_g_hash_table_insert(hash, "", "Version");*/ - cast_g_hash_table_insert(hash, "video_url", "VideoUrl"); - cast_g_hash_table_insert(hash, "wants_html", "WantsHtml"); - - osync_trace(TRACE_EXIT, "%s", __func__); - return hash; -} - -osync_bool evo2_translate_capabilities(OSyncCapabilities *caps, GHashTable *hash, GList *fields, const char *objtype, OSyncError **error) +osync_bool evo2_translate_capabilities(OSyncCapabilities *caps, GList *fields, const char *objtype, OSyncError **error) { - osync_trace(TRACE_ENTRY, "%s(%p, %p, %p, %s, %p)", __func__, caps, hash, fields, objtype, error); + osync_trace(TRACE_ENTRY, "%s(%p, %p, %p, %s, %p)", __func__, caps, fields, objtype, error); osync_assert(caps); - osync_assert(hash); osync_assert(fields); osync_assert(objtype); @@ -104,19 +36,6 @@ for(; fields; fields = g_list_next(fields)) { -#if 0 - const char *value = g_hash_table_lookup(hash, fields->data); - if (value == NULL) { - osync_trace(TRACE_INTERNAL, "%s: ebook capability '%s' could not be translated", __func__, fields->data); - } else { - osync_trace(TRACE_INTERNAL, "%s: ebook capability '%s' translated to '%s'", __func__, fields->data, value); - /* TODO Check for uniqueness of the added capability as several fields - translate to the same capability */ - if (!osync_capability_new(caps, objtype, value, error)) { - goto error; - } - } -#endif OSyncCapability *cap = osync_capability_new(capsobjtype, error); if (!cap) goto error; @@ -133,7 +52,5 @@ } osync_bool evo2_capbilities_translate_ebook(OSyncCapabilities *caps, GList *fields, OSyncError **error) { - GHashTable *hash; - hash = get_ebook_to_xmlformat_hash(); - return evo2_translate_capabilities(caps, hash, fields, "contact", error); + return evo2_translate_capabilities(caps, fields, "contact", error); } Added: plugins/evolution2/src/evolution2_format.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ plugins/evolution2/src/evolution2_format.c Mon Sep 7 02:38:18 2009 (r5753) @@ -0,0 +1,167 @@ +/* + * evolution2_format - A evolution2 format plugin for the OpenSync framework + * Copyright (C) 2009 Daniel Gollub <go...@b1...> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include <glib.h> + +#include <opensync/opensync.h> +#include <opensync/opensync-capabilities.h> +#include <opensync/opensync-format.h> + +#define cast_g_hash_table_insert(hash, a, b) g_hash_table_insert(hash, (gpointer) a, (gpointer) b) + +static GHashTable* get_ebook_to_xmlformat_hash() +{ + osync_trace(TRACE_ENTRY, "%s", __func__); + GHashTable *hash = g_hash_table_new(g_str_hash, g_str_equal); + + cast_g_hash_table_insert(hash, "address", "Address"); + cast_g_hash_table_insert(hash, "address_label_home", "AddressLabel"); + cast_g_hash_table_insert(hash, "address_label_other", "AddressLabel"); + cast_g_hash_table_insert(hash, "address_label_work", "AddressLabel"); + cast_g_hash_table_insert(hash, "anniversary", "Anniversary"); + cast_g_hash_table_insert(hash, "assistant", "Assistant"); + cast_g_hash_table_insert(hash, "birth_date", "Birthday"); + cast_g_hash_table_insert(hash, "blog_url", "BlogUrl"); + cast_g_hash_table_insert(hash, "caluri", "CalendarUrl"); + cast_g_hash_table_insert(hash, "categories", "Categories"); + /* cast_g_hash_table_insert(hash, "", "Class");*/ + cast_g_hash_table_insert(hash, "email_1", "EMail"); + cast_g_hash_table_insert(hash, "email_2", "EMail"); + cast_g_hash_table_insert(hash, "email_3", "EMail"); + cast_g_hash_table_insert(hash, "email_4", "EMail"); + cast_g_hash_table_insert(hash, "email", "EMail"); + cast_g_hash_table_insert(hash, "file_as", "FileAs"); + cast_g_hash_table_insert(hash, "full_name", "FormattedName"); + cast_g_hash_table_insert(hash, "fburl", "FreeBusyUrl"); + /* cast_g_hash_table_insert(hash, "", "GroupwiseDirectory");*/ + cast_g_hash_table_insert(hash, "im_aim", "IM-AIM"); + cast_g_hash_table_insert(hash, "im_gadugadu", "IM-GaduGadu"); + cast_g_hash_table_insert(hash, "im_icq", "IM-ICQ"); + cast_g_hash_table_insert(hash, "im_jabber", "IM-Jabber"); + cast_g_hash_table_insert(hash, "im_msn", "IM-MSN"); + /* cast_g_hash_table_insert(hash, "", "IM-Yabber");*/ + cast_g_hash_table_insert(hash, "im_yahoo", "IM-Yahoo"); + /* cast_g_hash_table_insert(hash, "", "IRC");*/ + /* cast_g_hash_table_insert(hash, "", "KDE-Extension");*/ + /* cast_g_hash_table_insert(hash, "", "Key");*/ + /* cast_g_hash_table_insert(hash, "", "Location");*/ + cast_g_hash_table_insert(hash, "logo", "Logo"); + cast_g_hash_table_insert(hash, "manager", "Manager"); + cast_g_hash_table_insert(hash, "name", "Name"); + cast_g_hash_table_insert(hash, "nickname", "Nickname"); + cast_g_hash_table_insert(hash, "note", "Note"); + cast_g_hash_table_insert(hash, "org", "Organization"); + cast_g_hash_table_insert(hash, "photo", "Photo"); + /*cast_g_hash_table_insert(hash, "", "PhotoUrl");*/ + + /*To match the vcard translators view that evolution role is really profession */ + cast_g_hash_table_insert(hash, "role", "Profession"); + cast_g_hash_table_insert(hash, "Rev", "Revision"); + /* cast_g_hash_table_insert(hash, "", "Role"); Evolution's role is profession */ + /* cast_g_hash_table_insert(hash, "", "SMS");*/ + /* cast_g_hash_table_insert(hash, "", "Sound");*/ + cast_g_hash_table_insert(hash, "spouse", "Spouse"); + cast_g_hash_table_insert(hash, "phone", "Telephone"); + cast_g_hash_table_insert(hash, "title", "Title"); + cast_g_hash_table_insert(hash, "id", "Uid"); + cast_g_hash_table_insert(hash, "homepage_url", "Url"); + /* cast_g_hash_table_insert(hash, "", "UserDefined");*/ + /* cast_g_hash_table_insert(hash, "", "Version");*/ + cast_g_hash_table_insert(hash, "video_url", "VideoUrl"); + cast_g_hash_table_insert(hash, "wants_html", "WantsHtml"); + + osync_trace(TRACE_EXIT, "%s", __func__); + return hash; +} + + +osync_bool caps_conv_generic(OSyncCapabilities *oldcaps, OSyncCapabilities *newcaps, const char *objtype, GHashTable *hash, OSyncError **error) +{ + + OSyncCapabilitiesObjType *newcapsobjtype, *capsobjtype = osync_capabilities_get_objtype(oldcaps, objtype); + OSyncList *c, *oldcapslist = osync_capabilities_objtype_get_caps(capsobjtype); + + newcapsobjtype = osync_capabilities_objtype_new(newcaps, objtype, error); + if (!newcapsobjtype) + goto error; + + for (c = oldcapslist; c; c = c->next) { + OSyncCapability *oldcap = (OSyncCapability *) c->data; + const char *name = osync_capability_get_name(oldcap); + const char *new_name = g_hash_table_lookup(hash, name); + if (!new_name) { + osync_trace(TRACE_INTERNAL, "Couldn't find counter-part for capability \"%s\"", __NULLSTR(name)); + continue; + } + + OSyncCapability *newcap = osync_capability_new(newcapsobjtype, error); + if (!newcap) + goto error; + + osync_capability_set_name(newcap, new_name); + } + + + return TRUE; +error: + return FALSE; +} + +osync_bool caps_conv_evo2_to_xmlformat(OSyncCapabilities *oldcaps, OSyncCapabilities **newcaps, const char *config, void *userdata, OSyncError **error) +{ + + GHashTable *ebook_hash = get_ebook_to_xmlformat_hash(); + + + *newcaps = osync_capabilities_new("xmlformat" ,error); + if (!*newcaps) + goto error; + + if (!caps_conv_generic(oldcaps, *newcaps, "contact", ebook_hash, error)) + goto error; + + return TRUE; + +error: + return FALSE; +} + +osync_bool get_conversion_info(OSyncFormatEnv *env) +{ + OSyncError *error; + /** Register Caps Converter */ + OSyncCapsConverter *caps_converter = osync_caps_converter_new("evo2-caps", "xmlformat", caps_conv_evo2_to_xmlformat, &error); + if (!caps_converter) + goto error; + + osync_format_env_register_caps_converter(env, caps_converter, &error); + + return TRUE; + +error: + osync_trace(TRACE_ERROR, "%s", osync_error_print(&error)); + osync_error_unref(&error); + return FALSE; +} + +int get_version(void) +{ + return 1; +} |
From: <svn...@op...> - 2009-09-07 00:42:24
|
Author: dgollub Date: Mon Sep 7 02:42:16 2009 New Revision: 5755 URL: http://www.opensync.org/changeset/5755 Log: Register caps-converter "vformat" to "xmlformat" capsformat Skip capabilities which are intentionally ignored (e.g. empty value/name in hashtable: BEGIN, END, ...) Modified: format-plugins/vformat/src/vformat-xmlformat.c format-plugins/vformat/src/xmlformat-vcard.c Modified: format-plugins/vformat/src/vformat-xmlformat.c ============================================================================== --- format-plugins/vformat/src/vformat-xmlformat.c Mon Sep 7 02:40:35 2009 (r5754) +++ format-plugins/vformat/src/vformat-xmlformat.c Mon Sep 7 02:42:16 2009 (r5755) @@ -205,10 +205,12 @@ osync_converter_unref(conv); /** Register Caps Converter */ - OSyncCapsConverter *caps_converter = osync_caps_converter_new("vcard30", "xmlformat", caps_conv_vcard_to_xmlformat, &error); + OSyncCapsConverter *caps_converter = osync_caps_converter_new("vformat", "xmlformat", caps_conv_vcard_to_xmlformat, &error); if (!caps_converter) goto error; + osync_format_env_register_caps_converter(env, caps_converter, &error); + return TRUE; error: Modified: format-plugins/vformat/src/xmlformat-vcard.c ============================================================================== --- format-plugins/vformat/src/xmlformat-vcard.c Mon Sep 7 02:40:35 2009 (r5754) +++ format-plugins/vformat/src/xmlformat-vcard.c Mon Sep 7 02:42:16 2009 (r5755) @@ -2000,6 +2000,10 @@ continue; } + /* Ignore the known, but intenitonally skipped/ignored fields ... */ + if (*new_name == '\0') + continue; + OSyncCapability *newcap = osync_capability_new(newcapsobjtype, error); if (!newcap) goto error; |
From: <svn...@op...> - 2009-09-07 00:40:44
|
Author: dgollub Date: Mon Sep 7 02:40:35 2009 New Revision: 5754 URL: http://www.opensync.org/changeset/5754 Log: Use for now the generic vforamt(-field-name) capabilities format Modified: plugins/syncml/src/syncml_devinf.c Modified: plugins/syncml/src/syncml_devinf.c ============================================================================== --- plugins/syncml/src/syncml_devinf.c Mon Sep 7 02:38:18 2009 (r5753) +++ plugins/syncml/src/syncml_devinf.c Mon Sep 7 02:40:35 2009 (r5754) @@ -54,7 +54,8 @@ osync_trace(TRACE_INTERNAL, "%s: assertions ok", __func__); /* create fresh capabilties */ - OSyncCapabilities *caps = osync_capabilities_new("syncml-caps", &oerror); + /* TODO: register custom capabilities. "vformat" is only valid for text/{,x-}v{card,calendar,todo,note} */ + OSyncCapabilities *caps = osync_capabilities_new("vformat", &oerror); osync_assert(caps); /* now manage all content type capabilities */ |
From: <svn...@op...> - 2009-09-07 00:35:10
|
Author: dgollub Date: Mon Sep 7 02:27:45 2009 New Revision: 5752 URL: http://www.opensync.org/changeset/5752 Log: If there is no marshaled data, due to missing marshal function, store the orignal data (e.g. vcard-dump) in the archive Modified: trunk/opensync/engine/opensync_mapping_entry_engine.c Modified: trunk/opensync/engine/opensync_mapping_entry_engine.c ============================================================================== --- trunk/opensync/engine/opensync_mapping_entry_engine.c Sat Sep 5 17:12:42 2009 (r5751) +++ trunk/opensync/engine/opensync_mapping_entry_engine.c Mon Sep 7 02:27:45 2009 (r5752) @@ -182,6 +182,11 @@ osync_marshal_get_buffer(marshal, &marshalbuf, &marshalsize); + if (marshalbuf == 0) { + marshalbuf = buffer; + marshalsize = size; + } + if (!osync_archive_save_data(archive, osync_mapping_get_id(mapping), objtype, marshalbuf, marshalsize, error)) { osync_free(buffer); /* TODO: Is this a valid free? */ goto error_free_marshal; |
From: <svn...@op...> - 2009-09-05 15:12:57
|
Author: vschreiner Date: Sat Sep 5 17:12:42 2009 New Revision: 5751 URL: http://www.opensync.org/changeset/5751 Log: changed the function call osync_objtype_sink_add_objformat to osync_objtype_sink_add_objformat_sink. Modified: plugins/irmc-sync/src/irmc_sync.c Modified: plugins/irmc-sync/src/irmc_sync.c ============================================================================== --- plugins/irmc-sync/src/irmc_sync.c Sat Sep 5 14:34:42 2009 (r5750) +++ plugins/irmc-sync/src/irmc_sync.c Sat Sep 5 17:12:42 2009 (r5751) @@ -1376,7 +1376,7 @@ "Is the vformat plugin correctly installed?", format, objtype); goto error_free_db; } - osync_objtype_sink_add_objformat(database->sink, format); + osync_objtype_sink_add_objformat_sink(database->sink, format); osync_plugin_info_add_objtype(info, database->sink); |
From: <svn...@op...> - 2009-09-05 12:35:02
|
Author: dgollub Date: Sat Sep 5 14:34:42 2009 New Revision: 5750 URL: http://www.opensync.org/changeset/5750 Log: PoC of caps-converter in vformat plugin for capabilities conversion from plain vcard fieldnames to xmlformat(-contact) refs #1146 Modified: format-plugins/vformat/src/vformat-xmlformat.c format-plugins/vformat/src/xmlformat-common.h format-plugins/vformat/src/xmlformat-vcard.c format-plugins/vformat/src/xmlformat-vcard.h Modified: format-plugins/vformat/src/vformat-xmlformat.c ============================================================================== --- format-plugins/vformat/src/vformat-xmlformat.c Sat Sep 5 14:21:58 2009 (r5749) +++ format-plugins/vformat/src/vformat-xmlformat.c Sat Sep 5 14:34:42 2009 (r5750) @@ -204,7 +204,16 @@ osync_format_env_register_converter(env, conv, &error); osync_converter_unref(conv); + /** Register Caps Converter */ + OSyncCapsConverter *caps_converter = osync_caps_converter_new("vcard30", "xmlformat", caps_conv_vcard_to_xmlformat, &error); + if (!caps_converter) + goto error; + return TRUE; + +error: + osync_trace(TRACE_ERROR, "%s", osync_error_print(&error)); + return FALSE; } #endif // BUILD_XMLFORMAT_VCARD Modified: format-plugins/vformat/src/xmlformat-common.h ============================================================================== --- format-plugins/vformat/src/xmlformat-common.h Sat Sep 5 14:21:58 2009 (r5749) +++ format-plugins/vformat/src/xmlformat-common.h Sat Sep 5 14:34:42 2009 (r5750) @@ -30,6 +30,7 @@ #include <opensync/opensync-xmlformat.h> #include <opensync/opensync-format.h> #include <opensync/opensync-time.h> +#include <opensync/opensync-capabilities.h> #include "vformat.h" Modified: format-plugins/vformat/src/xmlformat-vcard.c ============================================================================== --- format-plugins/vformat/src/xmlformat-vcard.c Sat Sep 5 14:21:58 2009 (r5749) +++ format-plugins/vformat/src/xmlformat-vcard.c Sat Sep 5 14:34:42 2009 (r5750) @@ -1938,3 +1938,97 @@ return conv_xmlformat_to_vcard(input, inpsize, output, outpsize, free_input, config, error, VFORMAT_CARD_21); } +/* + * Caps converter + * */ + +static GHashTable* get_vcard_hash() +{ + osync_trace(TRACE_ENTRY, "%s", __func__); + GHashTable *hash = g_hash_table_new(g_str_hash, g_str_equal); + + g_hash_table_insert(hash, "BEGIN", ""); + g_hash_table_insert(hash, "VERSION", ""); + g_hash_table_insert(hash, "END", ""); + + g_hash_table_insert(hash, "ADR", "Address"); + g_hash_table_insert(hash, "AGENT", "Agent"); + g_hash_table_insert(hash, "BDAY", "Birthday"); + g_hash_table_insert(hash, "CATEGORIES", "Categories"); + g_hash_table_insert(hash, "CLASS", "Class"); + g_hash_table_insert(hash, "EMAIL", "EMail"); + g_hash_table_insert(hash, "FN", "FormattedName"); + g_hash_table_insert(hash, "GEO", "Location"); + g_hash_table_insert(hash, "KEY", "Key"); + g_hash_table_insert(hash, "LABEL", "AddressLabel"); + g_hash_table_insert(hash, "LOGO", "Logo"); + g_hash_table_insert(hash, "MAILER", "Mailer"); + g_hash_table_insert(hash, "N", "Name"); + g_hash_table_insert(hash, "NICKNAME", "Nickname"); + g_hash_table_insert(hash, "NOTE", "Note"); + g_hash_table_insert(hash, "ORG", "Organization"); + g_hash_table_insert(hash, "PHOTO", "Photo"); + g_hash_table_insert(hash, "REV", "Revision"); + g_hash_table_insert(hash, "ROLE", "Role"); + g_hash_table_insert(hash, "SOUND", "Sound"); + g_hash_table_insert(hash, "TEL", "Telephone"); + g_hash_table_insert(hash, "TITLE", "Title"); + g_hash_table_insert(hash, "TZ", "Timezone"); + g_hash_table_insert(hash, "UID", "Uid"); + g_hash_table_insert(hash, "URL", "Url"); + + osync_trace(TRACE_EXIT, "%s", __func__); + return hash; +} + +osync_bool caps_conv_generic(OSyncCapabilities *oldcaps, OSyncCapabilities *newcaps, const char *objtype, GHashTable *hash, OSyncError **error) +{ + + OSyncCapabilitiesObjType *newcapsobjtype, *capsobjtype = osync_capabilities_get_objtype(oldcaps, objtype); + OSyncList *c, *oldcapslist = osync_capabilities_objtype_get_caps(capsobjtype); + + newcapsobjtype = osync_capabilities_objtype_new(newcaps, objtype, error); + if (!newcapsobjtype) + goto error; + + for (c = oldcapslist; c; c = c->next) { + OSyncCapability *oldcap = (OSyncCapability *) c->data; + const char *name = osync_capability_get_name(oldcap); + const char *new_name = g_hash_table_lookup(hash, name); + if (!new_name) { + osync_trace(TRACE_INTERNAL, "Couldn't find counter-part for capability \"%s\"", __NULLSTR(name)); + continue; + } + + OSyncCapability *newcap = osync_capability_new(newcapsobjtype, error); + if (!newcap) + goto error; + + osync_capability_set_name(newcap, new_name); + } + + + return TRUE; +error: + return FALSE; +} + +osync_bool caps_conv_vcard_to_xmlformat(OSyncCapabilities *oldcaps, OSyncCapabilities **newcaps, const char *config, void *userdata, OSyncError **error) +{ + + GHashTable *vcard_hash = get_vcard_hash(); + + + *newcaps = osync_capabilities_new("xmlformat" ,error); + if (!*newcaps) + goto error; + + if (!caps_conv_generic(oldcaps, *newcaps, "contact", vcard_hash, error)) + goto error; + + return TRUE; + +error: + return FALSE; +} + Modified: format-plugins/vformat/src/xmlformat-vcard.h ============================================================================== --- format-plugins/vformat/src/xmlformat-vcard.h Sat Sep 5 14:21:58 2009 (r5749) +++ format-plugins/vformat/src/xmlformat-vcard.h Sat Sep 5 14:34:42 2009 (r5750) @@ -41,6 +41,6 @@ osync_bool conv_xmlformat_to_vcard21(char *input, unsigned int inpsize, char **output, unsigned int *outpsize, osync_bool *free_input, const char *config, void *userdata, OSyncError **error); - +osync_bool caps_conv_vcard_to_xmlformat(OSyncCapabilities *oldcaps, OSyncCapabilities **newcaps, const char *config, void *userdata, OSyncError **error); #endif /*XMLFORMAT_VCARD_H_*/ |
From: <svn...@op...> - 2009-09-05 12:29:14
|
Author: dgollub Date: Sat Sep 5 14:21:58 2009 New Revision: 5749 URL: http://www.opensync.org/changeset/5749 Log: Added OSyncCapsConverter API Added: trunk/opensync/format/opensync_caps_converter.c - copied, changed from r5745, trunk/opensync/format/opensync_converter.c trunk/opensync/format/opensync_caps_converter.h - copied, changed from r5745, trunk/opensync/format/opensync_converter.h trunk/opensync/format/opensync_caps_converter_internals.h - copied, changed from r5745, trunk/opensync/format/opensync_converter_internals.h trunk/opensync/format/opensync_caps_converter_private.h - copied, changed from r5745, trunk/opensync/format/opensync_converter_private.h Modified: trunk/opensync.sym trunk/opensync/CMakeLists.txt trunk/opensync/format/opensync_format_env.c trunk/opensync/format/opensync_format_env.h trunk/opensync/format/opensync_format_env_internals.h trunk/opensync/format/opensync_objformat.h trunk/opensync/format/opensync_objformat_private.h trunk/opensync/opensync-format.h trunk/opensync/opensync.h Modified: trunk/opensync.sym ============================================================================== --- trunk/opensync.sym Sat Sep 5 03:24:23 2009 (r5748) +++ trunk/opensync.sym Sat Sep 5 14:21:58 2009 (r5749) @@ -28,6 +28,16 @@ osync_capability_set_parameter osync_capability_set_type osync_capability_unref +osync_caps_converter_finalize +osync_caps_converter_get_sourceformat +osync_caps_converter_get_targetformat +osync_caps_converter_initialize +osync_caps_converter_invoke +osync_caps_converter_new +osync_caps_converter_ref +osync_caps_converter_set_finalize_func +osync_caps_converter_set_initialize_func +osync_caps_converter_unref osync_change_compare osync_change_get_changetype osync_change_get_data @@ -154,6 +164,7 @@ osync_format_env_convert osync_format_env_detect_objformat osync_format_env_detect_objformat_full +osync_format_env_find_caps_converters osync_format_env_find_converter osync_format_env_find_converters osync_format_env_find_merger @@ -167,6 +178,7 @@ osync_format_env_load_plugins osync_format_env_new osync_format_env_ref +osync_format_env_register_caps_converter osync_format_env_register_converter osync_format_env_register_merger osync_format_env_register_objformat Modified: trunk/opensync/CMakeLists.txt ============================================================================== --- trunk/opensync/CMakeLists.txt Sat Sep 5 03:24:23 2009 (r5748) +++ trunk/opensync/CMakeLists.txt Sat Sep 5 14:21:58 2009 (r5749) @@ -29,6 +29,7 @@ engine/opensync_obj_engine.c engine/opensync_sink_engine.c engine/opensync_status.c + format/opensync_caps_converter.c format/opensync_converter.c format/opensync_filter.c format/opensync_format_env.c Copied and modified: trunk/opensync/format/opensync_caps_converter.c (from r5745, trunk/opensync/format/opensync_converter.c) ============================================================================== --- trunk/opensync/format/opensync_converter.c Sat Sep 5 00:58:28 2009 (r5745, copy source) +++ trunk/opensync/format/opensync_caps_converter.c Sat Sep 5 14:21:58 2009 (r5749) @@ -21,72 +21,44 @@ #include "opensync.h" #include "opensync_internals.h" +#include "opensync-capabilities.h" #include "opensync-data.h" + #include "data/opensync_data_internals.h" #include "opensync-format.h" #include "format/opensync_objformat_internals.h" +#include "capabilities/opensync_capabilities_internals.h" -#include "opensync_converter_private.h" -#include "opensync_converter_internals.h" +#include "opensync_caps_converter_private.h" +#include "opensync_caps_converter_internals.h" -OSyncFormatConverter *osync_converter_new(OSyncConverterType type, OSyncObjFormat *sourceformat, OSyncObjFormat *targetformat, OSyncFormatConvertFunc convert_func, OSyncError **error) +OSyncCapsConverter *osync_caps_converter_new(const char *sourceformat, const char *targetformat, OSyncCapsConvertFunc convert_func, OSyncError **error) { - OSyncFormatConverter *converter = NULL; - osync_trace(TRACE_ENTRY, "%s(%i, %s %p, %s %p, %p, %p)", __func__, type, __NULLSTR(osync_objformat_get_name(sourceformat)), sourceformat, __NULLSTR(osync_objformat_get_name(targetformat)), targetformat, convert_func, error); + OSyncCapsConverter *converter = NULL; + osync_trace(TRACE_ENTRY, "%s(%s, %s, %p, %p)", __func__, __NULLSTR(sourceformat), sourceformat, __NULLSTR(targetformat), targetformat, convert_func, error); - converter = osync_try_malloc0(sizeof(OSyncFormatConverter), error); + converter = osync_try_malloc0(sizeof(OSyncCapsConverter), error); if (!converter) { osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(error)); return NULL; } - converter->source_format = sourceformat; - osync_objformat_ref(sourceformat); + converter->source_capsformat = osync_strdup(sourceformat); - converter->target_format = targetformat; - osync_objformat_ref(targetformat); + converter->target_capsformat = osync_strdup(targetformat); converter->convert_func = convert_func; converter->initialize_func = NULL; converter->finalize_func = NULL; converter->userdata = NULL; - converter->type = type; converter->ref_count = 1; osync_trace(TRACE_EXIT, "%s: %p", __func__, converter); return converter; } -OSyncFormatConverter *osync_converter_new_detector(OSyncObjFormat *sourceformat, OSyncObjFormat *targetformat, OSyncFormatDetectFunc detect_func, OSyncError **error) -{ - OSyncFormatConverter *converter = NULL; - osync_trace(TRACE_ENTRY, "%s(%s %p, %s %p, %p, %p)", __func__, __NULLSTR(osync_objformat_get_name(sourceformat)), sourceformat, __NULLSTR(osync_objformat_get_name(targetformat)), targetformat, detect_func, error); - - converter = osync_try_malloc0(sizeof(OSyncFormatConverter), error); - if (!converter) { - osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(error)); - return NULL; - } - - converter->source_format = sourceformat; - osync_objformat_ref(sourceformat); - - converter->target_format = targetformat; - osync_objformat_ref(targetformat); - - converter->detect_func = detect_func; - converter->initialize_func = NULL; - converter->finalize_func = NULL; - converter->userdata = NULL; - converter->type = OSYNC_CONVERTER_DETECTOR; - converter->ref_count = 1; - - osync_trace(TRACE_EXIT, "%s: %p", __func__, converter); - return converter; -} - -OSyncFormatConverter *osync_converter_ref(OSyncFormatConverter *converter) +OSyncCapsConverter *osync_caps_converter_ref(OSyncCapsConverter *converter) { osync_assert(converter); @@ -95,120 +67,53 @@ return converter; } -void osync_converter_unref(OSyncFormatConverter *converter) +void osync_caps_converter_unref(OSyncCapsConverter *converter) { osync_assert(converter); if (g_atomic_int_dec_and_test(&(converter->ref_count))) { - if (converter->source_format) - osync_objformat_unref(converter->source_format); + if (converter->source_capsformat) + osync_free(converter->source_capsformat); - if (converter->target_format) - osync_objformat_unref(converter->target_format); + if (converter->target_capsformat) + osync_free(converter->target_capsformat); osync_free(converter); } } -OSyncObjFormat *osync_converter_get_sourceformat(OSyncFormatConverter *converter) -{ - osync_assert(converter); - return converter->source_format; -} - -OSyncObjFormat *osync_converter_get_targetformat(OSyncFormatConverter *converter) +const char *osync_caps_converter_get_sourceformat(OSyncCapsConverter *converter) { osync_assert(converter); - return converter->target_format; + return converter->source_capsformat; } -OSyncConverterType osync_converter_get_type(OSyncFormatConverter *converter) +const char *osync_caps_converter_get_targetformat(OSyncCapsConverter *converter) { osync_assert(converter); - return converter->type; + return converter->target_capsformat; } -OSyncObjFormat *osync_converter_detect(OSyncFormatConverter *detector, OSyncData *data) +osync_bool osync_caps_converter_invoke(OSyncCapsConverter *converter, OSyncCapabilities **caps, const char *config, OSyncError **error) { - OSyncObjFormat *sourceformat = NULL; - char *buffer = NULL; - unsigned int size = 0; - - osync_trace(TRACE_ENTRY, "%s(%p, %p)", __func__, detector, data); - osync_assert(detector); - osync_assert(data); - - if (detector->type != OSYNC_CONVERTER_DETECTOR) { - osync_trace(TRACE_EXIT, "%s: Not a detector", __func__); - return NULL; - } - - sourceformat = osync_data_get_objformat(data); - - /* First, we check if this is a "inverse" detection. So we check if our targetformat - * is the sourceformat of the data. There must always be a detector capable of converting - * this case */ - if (osync_objformat_is_equal(detector->target_format, sourceformat)) { - osync_trace(TRACE_EXIT, "%s: %p", __func__, detector->source_format); - return detector->source_format; - } - - if (!osync_objformat_is_equal(detector->source_format, sourceformat)) { - osync_trace(TRACE_EXIT, "%s: Format does not match", __func__); - return NULL; - } - - osync_data_get_data(data, &buffer, &size); - if (!detector->detect_func || detector->detect_func(buffer, size, detector->userdata)) { - /* Successfully detected the data */ - osync_trace(TRACE_EXIT, "%s: %p", __func__, detector->target_format); - return detector->target_format; - } - - osync_trace(TRACE_EXIT, "%s: Not detected", __func__); - return NULL; -} - -osync_bool osync_converter_invoke(OSyncFormatConverter *converter, OSyncData *data, const char *config, OSyncError **error) -{ - char *input_data = NULL; - unsigned int input_size = 0; - char *output_data = NULL; - unsigned int output_size = 0; - osync_bool free_input = FALSE; + OSyncCapabilities *new_caps; osync_assert(converter); - osync_assert(data); + osync_assert(caps); - osync_trace(TRACE_ENTRY, "%s(%p, %p, %s, %p)", __func__, converter, data, __NULLSTR(config), error); - osync_trace(TRACE_INTERNAL, "Converter of type %i, from %p(%s) to %p(%s)", converter->type, converter->source_format, osync_objformat_get_name(converter->source_format), converter->target_format, osync_objformat_get_name(converter->target_format)); + osync_trace(TRACE_ENTRY, "%s(%p, %p, %s, %p)", __func__, converter, caps, __NULLSTR(config), error); + osync_trace(TRACE_INTERNAL, "Converter from %s to %s", converter->source_capsformat, converter->target_capsformat); - if (converter->type != OSYNC_CONVERTER_DETECTOR) { - - osync_data_steal_data(data, &input_data, &input_size); - if (input_data) { - osync_assert(converter->convert_func); - - /* Invoke the converter */ - if (!converter->convert_func(input_data, input_size, &output_data, &output_size, &free_input, config, converter->userdata, error)) - goto error; - - /* Validate if for this objformat are format-plugin validiation-function is provided */ - if (osync_objformat_must_validate(converter->target_format)) { - if (!osync_objformat_validate(converter->target_format, output_data, output_size, error)) - goto error; - } - - /* Good. We now have some new data. Now we have to see what to do with the old data */ - if (free_input) { - osync_objformat_destroy(converter->source_format, input_data, input_size); - } - osync_data_set_data(data, output_data, output_size); - } - } - - osync_data_set_objformat(data, converter->target_format); - osync_data_set_objtype(data, osync_objformat_get_objtype(converter->target_format)); + osync_assert(converter->convert_func); + + /* Invoke the converter */ + if (!converter->convert_func(*caps, &new_caps, config, converter->userdata, error)) + goto error; + + osync_capabilities_unref(*caps); + *caps = new_caps; + + osync_capabilities_set_format(*caps, converter->target_capsformat); osync_trace(TRACE_EXIT, "%s", __func__); return TRUE; @@ -218,111 +123,20 @@ return FALSE; } -osync_bool osync_converter_matches(OSyncFormatConverter *converter, OSyncData *data) -{ - OSyncObjFormat *format = NULL; - osync_assert(converter); - osync_assert(data); - - format = osync_data_get_objformat(data); - if (!strcmp(osync_objformat_get_name(converter->source_format), osync_objformat_get_name(format))) - return TRUE; - return FALSE; -} - -OSyncFormatConverterPath *osync_converter_path_new(OSyncError **error) -{ - OSyncFormatConverterPath *path = osync_try_malloc0(sizeof(OSyncFormatConverterPath), error); - if (!path) - return NULL; - - path->ref_count = 1; - - return path; -} - -OSyncFormatConverterPath *osync_converter_path_ref(OSyncFormatConverterPath *path) -{ - osync_assert(path); - - g_atomic_int_inc(&(path->ref_count)); - - return path; -} - -void osync_converter_path_unref(OSyncFormatConverterPath *path) -{ - osync_assert(path); - - if (g_atomic_int_dec_and_test(&(path->ref_count))) { - while (path->converters) { - OSyncFormatConverter *converter = path->converters->data; - osync_converter_unref(converter); - path->converters = osync_list_remove(path->converters, converter); - } - - if (path->config) - osync_free(path->config); - - osync_free(path); - } -} - -void osync_converter_path_add_edge(OSyncFormatConverterPath *path, OSyncFormatConverter *edge) -{ - osync_assert(path); - osync_assert(edge); - - path->converters = osync_list_append(path->converters, edge); - osync_converter_ref(edge); -} - -unsigned int osync_converter_path_num_edges(OSyncFormatConverterPath *path) -{ - osync_assert(path); - return osync_list_length(path->converters); -} - -OSyncFormatConverter *osync_converter_path_nth_edge(OSyncFormatConverterPath *path, unsigned int nth) -{ - osync_assert(path); - return osync_list_nth_data(path->converters, nth); -} - -const char *osync_converter_path_get_config(OSyncFormatConverterPath *path) -{ - osync_assert(path); - return path->config; -} - -void osync_converter_path_set_config(OSyncFormatConverterPath *path, const char *config) -{ - osync_return_if_fail(path); - osync_return_if_fail(config); - - if (path->config) { - osync_free(path->config); - path->config = NULL; - } - - if (config) - path->config = osync_strdup(config); -} - -void osync_converter_set_initialize_func(OSyncFormatConverter *converter, OSyncFormatConverterInitializeFunc initialize_func) +void osync_caps_converter_set_initialize_func(OSyncCapsConverter *converter, OSyncCapsConverterInitializeFunc initialize_func) { osync_assert(converter); converter->initialize_func = initialize_func; } -void osync_converter_set_finalize_func(OSyncFormatConverter *converter, OSyncFormatConverterFinalizeFunc finalize_func) +void osync_caps_converter_set_finalize_func(OSyncCapsConverter *converter, OSyncCapsConverterFinalizeFunc finalize_func) { osync_assert(converter); converter->finalize_func = finalize_func; } -void osync_converter_initialize(OSyncFormatConverter *converter, const char *config, OSyncError **error) { +void osync_caps_converter_initialize(OSyncCapsConverter *converter, const char *config, OSyncError **error) { osync_assert(converter); @@ -331,7 +145,7 @@ } } -void osync_converter_finalize(OSyncFormatConverter *converter) +void osync_caps_converter_finalize(OSyncCapsConverter *converter) { osync_assert(converter); @@ -340,7 +154,3 @@ } } -OSyncList *osync_converter_path_get_edges(OSyncFormatConverterPath *path) { - return osync_list_copy(path->converters); -} - Copied and modified: trunk/opensync/format/opensync_caps_converter.h (from r5745, trunk/opensync/format/opensync_converter.h) ============================================================================== --- trunk/opensync/format/opensync_converter.h Sat Sep 5 00:58:28 2009 (r5745, copy source) +++ trunk/opensync/format/opensync_caps_converter.h Sat Sep 5 14:21:58 2009 (r5749) @@ -18,8 +18,8 @@ * */ -#ifndef _OPENSYNC_CONVERTER_H_ -#define _OPENSYNC_CONVERTER_H_ +#ifndef _OPENSYNC_CAPS_CONVERTER_H_ +#define _OPENSYNC_CAPS_CONVERTER_H_ /** * @defgroup OSyncConverterAPI OpenSync Converter @@ -29,22 +29,9 @@ */ /*@{*/ -/** Type of the converter */ -typedef enum { - /** Simple converter */ - OSYNC_CONVERTER_CONV = 1, - /** Encapsulator */ - OSYNC_CONVERTER_ENCAP = 2, - /** Desencapsulator */ - OSYNC_CONVERTER_DECAP = 3, - /** Detector */ - OSYNC_CONVERTER_DETECTOR = 4 -} OSyncConverterType; - -typedef osync_bool (* OSyncFormatDetectFunc) (const char *data, int size, void *userdata); -typedef osync_bool (* OSyncFormatConvertFunc) (char *input, unsigned int inpsize, char **output, unsigned int *outpsize, osync_bool *free_input, const char *config, void *userdata, OSyncError **error); -typedef void * (* OSyncFormatConverterInitializeFunc) (const char *config, OSyncError **error); -typedef void (* OSyncFormatConverterFinalizeFunc) (void *userdata); +typedef osync_bool (* OSyncCapsConvertFunc) (OSyncCapabilities *oldcaps, OSyncCapabilities **newcaps, const char *config, void *userdata, OSyncError **error); +typedef void * (* OSyncCapsConverterInitializeFunc) (const char *config, OSyncError **error); +typedef void (* OSyncCapsConverterFinalizeFunc) (void *userdata); /** * @brief Creates a new converter @@ -55,134 +42,60 @@ * @param error Pointer to an error struct * @returns The pointer to the newly allocated converter or NULL in case of error */ -OSYNC_EXPORT OSyncFormatConverter *osync_converter_new(OSyncConverterType type, OSyncObjFormat *sourceformat, OSyncObjFormat *targetformat, OSyncFormatConvertFunc convert_func, OSyncError **error); - -/** - * @brief Creates a new detector - * - * @param sourceformat the source format for the converter - * @param targetformat the target format for the converter - * @param detect_func the detection function - * @param error Pointer to an error struct - * @returns The pointer to the newly allocated detector or NULL in case of error - */ -OSYNC_EXPORT OSyncFormatConverter *osync_converter_new_detector(OSyncObjFormat *sourceformat, OSyncObjFormat *targetformat, OSyncFormatDetectFunc detect_func, OSyncError **error); +OSYNC_EXPORT OSyncCapsConverter *osync_caps_converter_new(const char *sourceformat, const char *targetformat, OSyncCapsConvertFunc convert_func, OSyncError **error); /** @brief Increase the reference count on a converter * * @param converter Pointer to the converter * */ -OSYNC_EXPORT OSyncFormatConverter *osync_converter_ref(OSyncFormatConverter *converter); +OSYNC_EXPORT OSyncCapsConverter *osync_caps_converter_ref(OSyncCapsConverter *converter); /** @brief Decrease the reference count on a converter * * @param converter Pointer to the converter * */ -OSYNC_EXPORT void osync_converter_unref(OSyncFormatConverter *converter); +OSYNC_EXPORT void osync_caps_converter_unref(OSyncCapsConverter *converter); /** * @brief Returns the source format of a converter * @param converter Pointer to the converter * @returns The source format of the specified converter */ -OSYNC_EXPORT OSyncObjFormat *osync_converter_get_sourceformat(OSyncFormatConverter *converter); +OSYNC_EXPORT const char *osync_caps_converter_get_sourceformat(OSyncCapsConverter *converter); /** * @brief Returns the target format of a converter * @param converter Pointer to the converter * @returns The target format of the specified converter */ -OSYNC_EXPORT OSyncObjFormat *osync_converter_get_targetformat(OSyncFormatConverter *converter); - -/** - * @brief Returns the type of a converter - * @param converter Pointer to the converter - * @returns The type of the specified converter - */ -OSYNC_EXPORT OSyncConverterType osync_converter_get_type(OSyncFormatConverter *converter); - -/** - * @brief Detects the Object Format of passed OSyncData - * @param converter Pointer to the converter - * @param data Pointer to OSyncData object which should be detected - * @returns The detected Object Format or NULL - */ -OSYNC_EXPORT OSyncObjFormat *osync_converter_detect(OSyncFormatConverter *converter, OSyncData *data); +OSYNC_EXPORT const char *osync_caps_converter_get_targetformat(OSyncCapsConverter *converter); /** - * @brief Invokes converter for OSyncData object with passed format converter configuration + * @brief Invokes converter for OSyncCapabilities object with passed format converter configuration * * @param converter Pointer to the converter - * @param data Pointer to OSyncData object which should be detected + * @param caps Pointer to OSyncCapabilitiesobject which should be converted * @param config Format converter configuration * @param error Pointer to an error struct * @returns TRUE on successful conversion, FALSE on error */ -OSYNC_EXPORT osync_bool osync_converter_invoke(OSyncFormatConverter *converter, OSyncData *data, const char *config, OSyncError **error); - -/** - * @brief Checks if the Format Converter fits the Object Format of OSyncData object - * @param converter Pointer to the converter - * @param data Pointer to OSyncData object which should be converted - * @returns TRUE if Object Format matches the Converter source format, FALSE otherwise - */ -OSYNC_EXPORT osync_bool osync_converter_matches(OSyncFormatConverter *converter, OSyncData *data); - -/** - * @brief Creates a new converter path - * @param error Pointer to an error struct - * @returns The pointer to the newly allocated converter path or NULL in case of error - */ -OSYNC_EXPORT OSyncFormatConverterPath *osync_converter_path_new(OSyncError **error); - -/** @brief Increase the reference count on a converter path - * - * @param path Pointer to the converter path - * @returns Pointer of converter path object - * - */ -OSYNC_EXPORT OSyncFormatConverterPath *osync_converter_path_ref(OSyncFormatConverterPath *path); - -/** @brief Decrease the reference count on a converter path - * - * @param path Pointer to the converter path - * - */ -OSYNC_EXPORT void osync_converter_path_unref(OSyncFormatConverterPath *path); - -/** @brief Add a converter to a converter path - * @param path Pointer to the converter path - * @param edge Pointer to the converter to add - */ -OSYNC_EXPORT void osync_converter_path_add_edge(OSyncFormatConverterPath *path, OSyncFormatConverter *edge); - -/** @brief Returns configuration for converter path - * @param path Pointer to the converter path - * @returns The converter path configuration - */ -OSYNC_EXPORT const char *osync_converter_path_get_config(OSyncFormatConverterPath *path); - -/** @brief Sets the configuration for converter path - * @param path Pointer to the converter path - * @param config The converter path configuration - */ -OSYNC_EXPORT void osync_converter_path_set_config(OSyncFormatConverterPath *path, const char *config); +OSYNC_EXPORT osync_bool osync_caps_converter_invoke(OSyncCapsConverter *converter, OSyncCapabilities **caps, const char *config, OSyncError **error); /** * @brief Sets the initialize function of a converter * @param converter Pointer to the converter * @param initialize_func Pointer to the initialize function */ -OSYNC_EXPORT void osync_converter_set_initialize_func(OSyncFormatConverter *converter, OSyncFormatConverterInitializeFunc initialize_func); +OSYNC_EXPORT void osync_caps_converter_set_initialize_func(OSyncCapsConverter *converter, OSyncCapsConverterInitializeFunc initialize_func); /** * @brief Sets the finalize function of a converter * @param converter Pointer to the converter * @param finalize_func Pointer to the finalize function */ -OSYNC_EXPORT void osync_converter_set_finalize_func(OSyncFormatConverter *converter, OSyncFormatConverterFinalizeFunc finalize_func); +OSYNC_EXPORT void osync_caps_converter_set_finalize_func(OSyncCapsConverter *converter, OSyncCapsConverterFinalizeFunc finalize_func); /** * @brief Invokes initialize function of a converter @@ -193,22 +106,15 @@ * * @todo config is not used currently. Should be used in the future to pass a directory for xml format schema location */ -OSYNC_EXPORT void osync_converter_initialize(OSyncFormatConverter *converter, const char *config, OSyncError **error); +OSYNC_EXPORT void osync_caps_converter_initialize(OSyncCapsConverter *converter, const char *config, OSyncError **error); /** * @brief Invokes finalize function of a converter * * @param converter Pointer to the converter which should be finalized */ -OSYNC_EXPORT void osync_converter_finalize(OSyncFormatConverter *converter); - -/** - * @brief Returns a OSyncList of the format converters in this path - * @param path Pointer to the OSyncFormatConverterPath - * @return a shallow copy of the OSyncFormatConverter in the conversion path - */ -OSYNC_EXPORT OSyncList *osync_converter_path_get_edges(OSyncFormatConverterPath *path); +OSYNC_EXPORT void osync_caps_converter_finalize(OSyncCapsConverter *converter); /*@}*/ -#endif //_OPENSYNC_CONVERTER_H_ +#endif //_OPENSYNC_CAPS_CONVERTER_H_ Copied and modified: trunk/opensync/format/opensync_caps_converter_internals.h (from r5745, trunk/opensync/format/opensync_converter_internals.h) ============================================================================== --- trunk/opensync/format/opensync_converter_internals.h Sat Sep 5 00:58:28 2009 (r5745, copy source) +++ trunk/opensync/format/opensync_caps_converter_internals.h Sat Sep 5 14:21:58 2009 (r5749) @@ -18,21 +18,7 @@ * */ -#ifndef _OPENSYNC_CONVERTER_INTERNALS_H_ -#define _OPENSYNC_CONVERTER_INTERNALS_H_ +#ifndef _OPENSYNC_CAPS_CONVERTER_INTERNALS_H_ +#define _OPENSYNC_CAPS_CONVERTER_INTERNALS_H_ -/** @brief Returns the number of converters in a converter path - * @param path Pointer to the converter path - * @returns the number of converters in the specified path - */ -OSYNC_TEST_EXPORT unsigned int osync_converter_path_num_edges(OSyncFormatConverterPath *path); - -/** @brief Returns the nth converter in a converter path - * @param path Pointer to the converter path - * @param nth The position of the converter to retrieve - * @returns the converter at the specified index - */ -OSYNC_TEST_EXPORT OSyncFormatConverter *osync_converter_path_nth_edge(OSyncFormatConverterPath *path, unsigned int nth); - - -#endif /* _OPENSYNC_CONVERTER_INTERNALS_H_ */ +#endif /* _OPENSYNC_CAPS_CONVERTER_INTERNALS_H_ */ Copied and modified: trunk/opensync/format/opensync_caps_converter_private.h (from r5745, trunk/opensync/format/opensync_converter_private.h) ============================================================================== --- trunk/opensync/format/opensync_converter_private.h Sat Sep 5 00:58:28 2009 (r5745, copy source) +++ trunk/opensync/format/opensync_caps_converter_private.h Sat Sep 5 14:21:58 2009 (r5749) @@ -18,8 +18,8 @@ * */ -#ifndef OPENSYNC_CONVERTER_PRIVATE_H_ -#define OPENSYNC_CONVERTER_PRIVATE_H_ +#ifndef OPENSYNC_CAPS_CONVERTER_PRIVATE_H_ +#define OPENSYNC_CAPS_CONVERTER_PRIVATE_H_ /** @@ -32,25 +32,16 @@ /** @brief Represent a converter from one format to another */ -struct OSyncFormatConverter { - OSyncObjFormat *source_format; - OSyncObjFormat *target_format; - OSyncFormatConvertFunc convert_func; - OSyncFormatDetectFunc detect_func; - OSyncFormatConverterInitializeFunc initialize_func; - OSyncFormatConverterFinalizeFunc finalize_func; - OSyncConverterType type; +struct OSyncCapsConverter { + char *source_capsformat; + char *target_capsformat; + OSyncCapsConvertFunc convert_func; + OSyncCapsConverterInitializeFunc initialize_func; + OSyncCapsConverterFinalizeFunc finalize_func; int ref_count; void *userdata; }; -/** @brief Shortest conversion path between formats */ -struct OSyncFormatConverterPath { - OSyncList *converters; - char *config; - int ref_count; -}; - /*@}*/ -#endif /*OPENSYNC_CONVERTER_PRIVATE_H_*/ +#endif /*OPENSYNC_CAPS_CONVERTER_PRIVATE_H_*/ Modified: trunk/opensync/format/opensync_format_env.c ============================================================================== --- trunk/opensync/format/opensync_format_env.c Sat Sep 5 03:24:23 2009 (r5748) +++ trunk/opensync/format/opensync_format_env.c Sat Sep 5 14:21:58 2009 (r5749) @@ -933,6 +933,60 @@ return osync_list_copy(env->converters); } +void osync_format_env_register_caps_converter(OSyncFormatEnv *env, OSyncCapsConverter *converter, OSyncError **error) +{ + osync_assert(env); + osync_assert(converter); + + env->caps_converters = osync_list_append(env->caps_converters, converter); + osync_caps_converter_ref(converter); +} + +OSyncCapsConverter *osync_format_env_find_caps_converter(OSyncFormatEnv *env, const char *sourcecapsformat, const char *targetcapsformat) +{ + OSyncList *c = NULL; + + osync_assert(env); + osync_assert(sourcecapsformat); + osync_assert(targetcapsformat); + + for (c = env->caps_converters; c; c = c->next) { + OSyncCapsConverter *converter = c->data; + if (strcmp(sourcecapsformat, osync_caps_converter_get_sourceformat(converter))) + continue; + + if (strcmp(targetcapsformat, osync_caps_converter_get_targetformat(converter))) + continue; + + return converter; + } + + return NULL; +} + +OSyncList *osync_format_env_find_caps_converters(OSyncFormatEnv *env, const char *sourcecapsformat, const char *targetcapsformat) +{ + OSyncList *r = NULL; + OSyncList *c = NULL; + + osync_assert(env); + osync_assert(sourcecapsformat); + osync_assert(targetcapsformat); + + for (c = env->converters; c; c = c->next) { + OSyncCapsConverter *converter = c->data; + if (strcmp(sourcecapsformat, osync_caps_converter_get_sourceformat(converter))) + continue; + + if (strcmp(targetcapsformat, osync_caps_converter_get_targetformat(converter))) + continue; + + r = osync_list_append(r, converter); + } + + return r; +} + void osync_format_env_register_filter(OSyncFormatEnv *env, OSyncCustomFilter *filter) { osync_assert(env); Modified: trunk/opensync/format/opensync_format_env.h ============================================================================== --- trunk/opensync/format/opensync_format_env.h Sat Sep 5 03:24:23 2009 (r5748) +++ trunk/opensync/format/opensync_format_env.h Sat Sep 5 14:21:58 2009 (r5749) @@ -142,6 +142,37 @@ */ OSYNC_EXPORT OSyncList *osync_format_env_find_converters(OSyncFormatEnv *env, OSyncObjFormat *sourceformat, OSyncObjFormat *targetformat); +/** @brief Registers Capabilities Converter to Format Environment + * + * @param env The format environment + * @param converter Pointer of the Capabilities Converter + * @param error An OSyncError + */ +OSYNC_EXPORT void osync_format_env_register_caps_converter(OSyncFormatEnv *env, OSyncCapsConverter *converter, OSyncError **error); + +/** @brief Finds first capabilities converter with the given source and target capsformat + * + * @param env Pointer to the environment + * @param sourceformat The source format + * @param targetformat The target format + * @returns The converter, or NULL if not found + * + */ +OSYNC_EXPORT OSyncCapsConverter *osync_format_env_find__caps_converter(OSyncFormatEnv *env, const char *sourcecapsformat, const char *targetcapsformat); + +/** @brief Returns a list of all capabilities converters with the given source and target format + * + * The returned list must be freed with osync_list_free(). The ref count on each + * OSyncCapsConverter is not increased. + * + * @param env Pointer to the environment + * @param sourceformat The source capabilities format + * @param targetformat The target capabilities format + * @returns List of OSyncCapsConverter, or NULL if none found + * + */ +OSYNC_EXPORT OSyncList *osync_format_env_find_caps_converters(OSyncFormatEnv *env, const char *sourcecapsformat, const char *targetcapsformat); + /** * @brief Return a OSyncList of all converters which are store in this format environment * Modified: trunk/opensync/format/opensync_format_env_internals.h ============================================================================== --- trunk/opensync/format/opensync_format_env_internals.h Sat Sep 5 03:24:23 2009 (r5748) +++ trunk/opensync/format/opensync_format_env_internals.h Sat Sep 5 14:21:58 2009 (r5749) @@ -42,8 +42,10 @@ struct OSyncFormatEnv { /** A List of formats */ OSyncList *objformats; - /** A list of available converters */ + /** A list of available format converters */ OSyncList *converters; + /** A list of available capabilities converters */ + OSyncList *caps_converters; /** A list of filter functions */ OSyncList *custom_filters; /** A list of mergers (OSyncMergers *) */ Modified: trunk/opensync/format/opensync_objformat.h ============================================================================== --- trunk/opensync/format/opensync_objformat.h Sat Sep 5 03:24:23 2009 (r5748) +++ trunk/opensync/format/opensync_objformat.h Sat Sep 5 14:21:58 2009 (r5749) @@ -44,8 +44,6 @@ typedef osync_bool (* OSyncFormatDemarshalFunc) (OSyncMarshal *marshal, char **output, unsigned int *outpsize, void *user_data, OSyncError **error); typedef osync_bool (* OSyncFormatValidateFunc) (const char *data, unsigned int size, void *user_data, OSyncError **error); -typedef osync_bool (* OSyncFormatCapsConverterFunc) (OSyncCapabilities *oldcaps, OSyncCapabilities **newcaps, OSyncError **error); - /** * @brief Creates a new object format * @param name the name of the object format @@ -224,12 +222,6 @@ OSYNC_EXPORT void osync_objformat_set_validate_func(OSyncObjFormat *format, OSyncFormatValidateFunc validate_func); /** - * @param format Pointer to the object format - * @param capsconverter_func The function to convert capabilities - */ -OSYNC_EXPORT void osync_objformat_set_capsconverter_func(OSyncObjFormat *format, OSyncFormatCapsConverterFunc capsconverter_func); - -/** * @brief Prints the specified object * * Uses the object format's print function if set, otherwise the object's Modified: trunk/opensync/format/opensync_objformat_private.h ============================================================================== --- trunk/opensync/format/opensync_objformat_private.h Sat Sep 5 03:24:23 2009 (r5748) +++ trunk/opensync/format/opensync_objformat_private.h Sat Sep 5 14:21:58 2009 (r5749) @@ -61,7 +61,6 @@ OSyncFormatMarshalFunc marshal_func; OSyncFormatDemarshalFunc demarshal_func; OSyncFormatValidateFunc validate_func; - OSyncFormatCapsConverterFunc capsconverter_func; }; /*@}*/ Modified: trunk/opensync/opensync-format.h ============================================================================== --- trunk/opensync/opensync-format.h Sat Sep 5 03:24:23 2009 (r5748) +++ trunk/opensync/opensync-format.h Sat Sep 5 14:21:58 2009 (r5749) @@ -23,6 +23,7 @@ OPENSYNC_BEGIN_DECLS +#include "format/opensync_caps_converter.h" #include "format/opensync_converter.h" #include "format/opensync_format_env.h" #include "format/opensync_objformat.h" Modified: trunk/opensync/opensync.h ============================================================================== --- trunk/opensync/opensync.h Sat Sep 5 03:24:23 2009 (r5748) +++ trunk/opensync/opensync.h Sat Sep 5 14:21:58 2009 (r5749) @@ -198,6 +198,7 @@ typedef struct OSyncFormatConverter OSyncFormatConverter; typedef struct OSyncObjFormatSink OSyncObjFormatSink; typedef struct OSyncMerger OSyncMerger; +typedef struct OSyncCapsConverter OSyncCapsConverter; /* Plugin component */ typedef struct OSyncContext OSyncContext; |
From: <svn...@op...> - 2009-09-05 01:24:37
|
Author: vschreiner Date: Sat Sep 5 03:24:23 2009 New Revision: 5748 URL: http://www.opensync.org/changeset/5748 Log: compiling state of the irmc plugin. changed the methods to use the new API. Modified: plugins/irmc-sync/src/irmc_sync.c Modified: plugins/irmc-sync/src/irmc_sync.c ============================================================================== --- plugins/irmc-sync/src/irmc_sync.c Sat Sep 5 02:24:21 2009 (r5747) +++ plugins/irmc-sync/src/irmc_sync.c Sat Sep 5 03:24:23 2009 (r5748) @@ -156,22 +156,22 @@ // set defaults config->donttellsync = FALSE; config->serial_number = NULL; - - switch( configdata->connection->type ) + OSyncPluginConnection *conn = osync_plugin_config_get_connection( configdata ); + switch( osync_plugin_connection_get_type(conn) ) { #ifdef HAVE_BLUETOOTH case OSYNC_PLUGIN_CONNECTION_BLUETOOTH: { config->connectmedium = MEDIUM_BLUETOOTH; - config->btchannel = configdata->connection->bt_channel; - str2ba(configdata->connection->bt_address, &(config->bdaddr)); + config->btchannel = osync_plugin_connection_bt_get_channel(conn); + str2ba(osync_plugin_connection_bt_get_addr(conn), &(config->bdaddr)); } break; #endif case OSYNC_PLUGIN_CONNECTION_IRDA: { config->connectmedium = MEDIUM_IR; - strncpy(config->irunit.name, configdata->connection->irda_service, 31); - strncpy(config->irunit.serial, configdata->connection->irda_service, 31); + strncpy(config->irunit.name, osync_plugin_connection_irda_get_service(conn), 31); + strncpy(config->irunit.serial, osync_plugin_connection_irda_get_service(conn), 31); } break; case OSYNC_PLUGIN_CONNECTION_USB: { @@ -186,11 +186,18 @@ } if( config->connectmedium == MEDIUM_CABLE ) { - config->cabledev = configdata->connection->usb_interface; - strncpy( config->cabledev, configdata->serial_devicenode, 127 ); + const char *devnode; + osync_plugin_connection_serial_set_devicenode( conn, devnode ); + strncpy( config->cabledev, devnode, 127 ); + } + + if( !strcmp( osync_plugin_config_get_advancedoption_value_by_name(configdata, "donttellsync"), "true" )) + { + config->donttellsync = TRUE; + } else { + config->donttellsync = FALSE; } - // FIXME: implement parsing of config->donttellsync! // FIXME: implement parsing of config->cabletype! osync_trace(TRACE_EXIT, "%s", __func__); return TRUE; @@ -203,47 +210,50 @@ /** * Load the general synchronization anchor. */ -void load_sync_anchors( irmc_environment *env ) +void load_sync_anchors( OSyncObjTypeSink *sink, OSyncPluginConfig *origconf, irmc_environment *env ) { + unsigned int i; osync_trace(TRACE_ENTRY, "%s(%p)", __func__, env); irmc_config *config = &(env->config); OSyncSinkStateDB *state_db = osync_objtype_sink_get_state_db(sink); + OSyncList *resList = (OSyncList *)osync_plugin_config_get_resources( origconf ); - char *anchor = osync_sink_state_get( state_db, ) - -/* FIXME port to SinkStateDb */ -#if 0 - char *anchor = osync_anchor_retrieve(env->anchor_path, "general"); - if (!anchor) { - config->serial_number = NULL; - } else { - char data[ 256 ]; - memset( data, 0, sizeof( data ) ); - - sscanf( anchor, "%s", data ); - config->serial_number = g_strdup( data ); + for( i = 0; i < osync_list_length(resList); i++ ) + { + const char *anchor = osync_plugin_resource_get_path( (OSyncPluginResource *)osync_list_nth(resList,i) ); + if (!anchor) { + config->serial_number = NULL; + } else { + char data[ 256 ]; + memset( data, 0, sizeof( data ) ); + + sscanf( anchor, "%s", data ); + config->serial_number = g_strdup( data ); + break; + } + g_free( (void*)anchor ); } - g_free( anchor ); -#endif osync_trace(TRACE_EXIT, "%s", __func__); } /** * Save synchronization anchors. */ -void save_sync_anchors( const irmc_environment *env ) +void save_sync_anchors( OSyncObjTypeSink *sink, OSyncPluginConfig *origconf, const irmc_environment *env ) { + unsigned int i; osync_trace(TRACE_ENTRY, "%s(%p)", __func__, env); const irmc_config *config = &(env->config); - -/* FIXME port to SinkStateDb */ -#if 0 - osync_anchor_update( env->anchor_path, "general", config->serial_number ); -#endif + OSyncSinkStateDB *state_db = osync_objtype_sink_get_state_db(sink); + OSyncList *resList = osync_plugin_config_get_resources( origconf ); + for( i = 0; i < osync_list_length(resList); i++ ) + { + osync_plugin_resource_set_path( (OSyncPluginResource *)osync_list_nth(resList,i) ,"general"); + } osync_trace(TRACE_EXIT, "%s", __func__); } @@ -843,7 +853,7 @@ irmc_database *database = (irmc_database *)userdata; irmc_environment *env = database->env; irmc_config *config = &(env->config); - + OSyncPluginConfig *origconf = osync_plugin_info_get_config(info); /* * Now connect to your devices and report * @@ -858,23 +868,13 @@ */ const char *objtype = osync_objtype_sink_get_name(sink); - OSyncSinkStateDB *stateDB = sink->state_db; //you can also use the anchor system to detect a device reset //or some parameter change here. Check the docs to see how it works //Now you get the last stored anchor from the device OSyncSinkStateDB *state_db = osync_objtype_sink_get_state_db(sink); - osync_bool anchormatch; - if (!osync_sink_state_equal(state_db, "anchor_key", "dynamic_anchor_value", &anchormatch, &error)) { - /* anchor couldn't be compared */ - goto error; - } - if (!anchormatch) { - /* request slow sync */ - osync_context_report_slowsync(ctx); - } - char *anchor = osync_sink_state_get(state_db, env->anchor_path); + char *anchor = osync_sink_state_get(state_db, env->anchor_path, &error ); if( !anchor) { database->changecounter = 0; @@ -890,7 +890,6 @@ osync_trace(TRACE_EXIT, "%s", __func__); return; - OSyncError *error = NULL; if (env->isConnected == 0) { config->obexhandle = irmc_obex_client(config); @@ -903,7 +902,7 @@ } // load the general synchronization anchors - load_sync_anchors(env); + load_sync_anchors(sink, origconf, env ); } env->isConnected++; @@ -950,8 +949,8 @@ } else { env->isConnected--; } - - save_sync_anchors(env); + OSyncPluginConfig *origconf = osync_plugin_info_get_config(info); + save_sync_anchors(sink, origconf, env); osync_context_report_success(ctx); @@ -1397,6 +1396,7 @@ /* Initialize connection */ static void *irmcInitialize(OSyncPlugin *plugin, OSyncPluginInfo *info, OSyncError **error) { + unsigned int i = 0; osync_trace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, plugin, info, error); OSyncPluginConfig *configdata = NULL; @@ -1410,7 +1410,7 @@ // retrieve the config data /* FIXME: PORT to OSyncPluginConfig */ - OSyncPluginConfig *configdata = osync_plugin_info_get_config(info); + configdata = osync_plugin_info_get_config(info); assert(configdata); if (!configdata) { @@ -1430,7 +1430,22 @@ env->anchor_path = g_strdup_printf("%s/anchor.db", osync_plugin_info_get_configdir(info)); #endif - + OSyncList *resList = (OSyncList *)osync_plugin_config_get_resources( configdata ); + for( i = 0; i < osync_list_length(resList); i++ ) + { + const char *anchor = osync_plugin_resource_get_path( (OSyncPluginResource *)osync_list_nth(resList,i) ); + if (!anchor) { + env->anchor_path = NULL; + } else { + char data[ 256 ]; + memset( data, 0, sizeof( data ) ); + + sscanf( anchor, "%s", data ); + env->anchor_path = g_strdup( data ); + break; + } + g_free( (void*)anchor ); + } irmc_database *contactdb; irmc_database *eventdb; irmc_database *tododb; |
From: <svn...@op...> - 2009-09-05 00:33:49
|
Author: dgollub Date: Sat Sep 5 02:24:21 2009 New Revision: 5747 URL: http://www.opensync.org/changeset/5747 Log: Make use of Capabilities (if available) to make mapping of changes more successful. With the help of capabilities a copy of the change get demerged of the oponenten capabilities. This will results more often on a compare in a SAME mapping - instead of a SIMILAR. This means less conflicts on a (slow-)sync. Enjoy! ;) Modified: trunk/opensync/engine/opensync_obj_engine.c trunk/opensync/format/opensync_merger.c Modified: trunk/opensync/engine/opensync_obj_engine.c ============================================================================== --- trunk/opensync/engine/opensync_obj_engine.c Sat Sep 5 01:56:21 2009 (r5746) +++ trunk/opensync/engine/opensync_obj_engine.c Sat Sep 5 02:24:21 2009 (r5747) @@ -22,6 +22,7 @@ #include "opensync_internals.h" #include "opensync-group.h" +#include "opensync-capabilities.h" #include "opensync-engine.h" #include "opensync-client.h" #include "opensync-data.h" @@ -46,6 +47,8 @@ #include "client/opensync_client_proxy_internals.h" #include "group/opensync_member_internals.h" #include "format/opensync_objformat_internals.h" +#include "format/opensync_merger_internals.h" +#include "mapping/opensync_mapping_table_internals.h" #include "mapping/opensync_mapping_table_internals.h" OSyncMappingEngine *_osync_obj_engine_create_mapping_engine(OSyncObjEngine *engine, OSyncError **error) @@ -197,15 +200,37 @@ osync_trace(TRACE_EXIT, "%s", __func__); } + +static OSyncChange *_osync_obj_engine_clone_and_demerge_change(OSyncObjEngine *engine, OSyncCapabilities *caps, OSyncChange *change, OSyncError **error) +{ + + OSyncFormatEnv *formatenv = engine->formatenv; + OSyncChange *clone_change = osync_change_clone(change, error); + if (!clone_change) + goto error; + OSyncMerger *merger = osync_format_env_find_merger(formatenv, + osync_objformat_get_name(osync_change_get_objformat(clone_change)), + osync_capabilities_get_format(caps)); + + if (merger && caps &&!osync_merger_demerge(merger, clone_change, caps, error)) + goto error; + + return clone_change; + +error: + return NULL; +} + /* Finds the mapping to which the entry should belong. The * return value is MISMATCH if no mapping could be found, * SIMILAR if a mapping has been found but its not completely the same * SAME if a mapping has been found and is the same */ -static OSyncConvCmpResult _osync_obj_engine_mapping_find(OSyncList *mapping_engines, OSyncChange *change, OSyncSinkEngine *sinkengine, OSyncMappingEngine **mapping_engine) +static OSyncConvCmpResult _osync_obj_engine_mapping_find(OSyncList *mapping_engines, OSyncChange *change, OSyncSinkEngine *sinkengine, OSyncMappingEngine **mapping_engine, OSyncError **error) { OSyncList *m = NULL; OSyncList *e = NULL; OSyncConvCmpResult result = OSYNC_CONV_DATA_MISMATCH; + osync_trace(TRACE_ENTRY, "%s(%p, %p, %p, %p)", __func__, mapping_engines, change, sinkengine, mapping_engine); for (m=mapping_engines; m && (result != OSYNC_CONV_DATA_SAME); m=m->next) { @@ -227,7 +252,41 @@ if (!mapping_change) continue; - tmp_result = osync_change_compare(mapping_change, change); + OSyncMember *member1 = osync_client_proxy_get_member(sinkengine->proxy); + OSyncMember *member2 = osync_client_proxy_get_member(entry_engine->sink_engine->proxy); + + + OSyncCapabilities *caps1 = osync_member_get_capabilities(member1); + OSyncCapabilities *caps2 = osync_member_get_capabilities(member2); + + OSyncChange *clone_change1, *clone_change2; + OSyncChange *change1 = change; + OSyncChange *change2 = mapping_change; + + if (caps1) { + clone_change1 = _osync_obj_engine_clone_and_demerge_change(sinkengine->engine, caps1, change, error); + if (!clone_change1) + goto error; + + change1 = clone_change1; + } + + if (caps2) { + clone_change2 = _osync_obj_engine_clone_and_demerge_change(sinkengine->engine, caps2, mapping_change, error); + if (!clone_change2) + goto error; + + change2 = mapping_change; + } + + tmp_result = osync_change_compare(change1, change2); + + if (caps1) + osync_change_unref(clone_change1); + + if (caps2) + osync_change_unref(clone_change2); + if(tmp_result == OSYNC_CONV_DATA_SAME) { /* SAME is the best we can get */ result = OSYNC_CONV_DATA_SAME; @@ -245,6 +304,10 @@ osync_trace(TRACE_EXIT, "%s: %d, %p", __func__, (int)result, *mapping_engine); return result; + +error: + osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(error)); + return OSYNC_CONV_DATA_UNKNOWN; } osync_bool osync_obj_engine_map_changes(OSyncObjEngine *engine, OSyncError **error) @@ -279,22 +342,29 @@ osync_trace(TRACE_INTERNAL, "Looking for mapping for change %s, changetype %i from member %lli", osync_change_get_uid(change), osync_change_get_changetype(change), memberid); /* See if there is an exisiting mapping, which fits the unmapped change */ - result = _osync_obj_engine_mapping_find(unmapped_mappings, change, sinkengine, &mapping_engine); - if (result == OSYNC_CONV_DATA_MISMATCH) { - /* If there is none, create one */ - mapping_engine = _osync_obj_engine_create_mapping_engine(engine, error); - if (!mapping_engine) + result = _osync_obj_engine_mapping_find(unmapped_mappings, change, sinkengine, &mapping_engine, error); + switch (result) { + case OSYNC_CONV_DATA_MISMATCH: + /* If there is none, create one */ + mapping_engine = _osync_obj_engine_create_mapping_engine(engine, error); + if (!mapping_engine) + goto error; + + osync_trace(TRACE_INTERNAL, "Unable to find mapping. Creating new mapping with id %lli", osync_mapping_get_id(mapping_engine->mapping)); + /* TODO: what about _prepend (O(1)) instead of _append (O(n))? Order doesn't matter here - right? */ + new_mappings = osync_list_append(new_mappings, mapping_engine); + unmapped_mappings = osync_list_append(unmapped_mappings, mapping_engine); + break; + case OSYNC_CONV_DATA_SIMILAR: + mapping_engine->conflict = TRUE; + break; + case OSYNC_CONV_DATA_SAME: + unmapped_mappings = osync_list_remove(unmapped_mappings, mapping_engine); + mapping_engine->conflict = FALSE; + break; + case OSYNC_CONV_DATA_UNKNOWN: goto error; - - osync_trace(TRACE_INTERNAL, "Unable to find mapping. Creating new mapping with id %lli", osync_mapping_get_id(mapping_engine->mapping)); - /* TODO: what about _prepend (O(1)) instead of _append (O(n))? Order doesn't matter here - right? */ - new_mappings = osync_list_append(new_mappings, mapping_engine); - unmapped_mappings = osync_list_append(unmapped_mappings, mapping_engine); - } else if (result == OSYNC_CONV_DATA_SIMILAR) { - mapping_engine->conflict = TRUE; - } else if (result == OSYNC_CONV_DATA_SAME) { - unmapped_mappings = osync_list_remove(unmapped_mappings, mapping_engine); - mapping_engine->conflict = FALSE; + break; } /* Update the entry which belongs to our sinkengine with the the change */ @@ -337,7 +407,7 @@ osync_trace(TRACE_EXIT, "%s", __func__); return TRUE; - error: +error: osync_trace_enable(); osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(error)); return FALSE; Modified: trunk/opensync/format/opensync_merger.c ============================================================================== --- trunk/opensync/format/opensync_merger.c Sat Sep 5 01:56:21 2009 (r5746) +++ trunk/opensync/format/opensync_merger.c Sat Sep 5 02:24:21 2009 (r5747) @@ -112,6 +112,10 @@ char *buffer; unsigned int size; + osync_assert(merger); + osync_assert(change); + osync_return_val_if_fail(caps, TRUE); + OSyncData *data = osync_change_get_data(change); osync_data_get_data(data, &buffer, &size); |