From: <svn...@op...> - 2009-07-16 10:19:40
|
Author: bellmich Date: Thu Jul 16 12:19:18 2009 New Revision: 1205 URL: http://libsyncml.opensync.org/changeset/1205 Log: fixed header files - removed syncml_internals.h - cleaned up syncml.h The header file cleanup requires some new functions. GOAL: A C file should include on normal header files if the header file is not public. GOAL: A C file should only include an internal header file if the normal header file is public. Added: trunk/libsyncml/sml_thread.c trunk/libsyncml/sml_thread.h trunk/libsyncml/sml_thread_internals.h trunk/tools/syncml-ds-tool_internals.c trunk/tools/syncml-ds-tool_internals.h Deleted: trunk/libsyncml/syncml_internals.h Modified: trunk/libsyncml/CMakeLists.txt trunk/libsyncml/data_sync_api/callbacks.h trunk/libsyncml/data_sync_api/data_sync.c trunk/libsyncml/data_sync_api/data_sync.h trunk/libsyncml/data_sync_api/data_sync_abort.c trunk/libsyncml/data_sync_api/data_sync_callbacks.c trunk/libsyncml/data_sync_api/data_sync_common.c trunk/libsyncml/data_sync_api/data_sync_devinf.c trunk/libsyncml/data_sync_api/data_sync_loop.c trunk/libsyncml/data_sync_api/data_sync_server.c trunk/libsyncml/data_sync_api/defines.h trunk/libsyncml/data_sync_api/sml_location.c trunk/libsyncml/data_sync_api/sml_location_internals.h trunk/libsyncml/data_sync_api/standard.h trunk/libsyncml/data_sync_api/transport_obex_client.c trunk/libsyncml/objects/sml_auth.c trunk/libsyncml/objects/sml_auth.h trunk/libsyncml/objects/sml_devinf_obj.c trunk/libsyncml/objects/sml_devinf_obj.h trunk/libsyncml/objects/sml_devinf_obj_internals.h trunk/libsyncml/objects/sml_ds_server.c trunk/libsyncml/objects/sml_ds_server.h trunk/libsyncml/objects/sml_ds_server_internals.h trunk/libsyncml/parser/sml_wbxml.c trunk/libsyncml/parser/sml_wbxml.h trunk/libsyncml/parser/sml_wbxml_internals.h trunk/libsyncml/parser/sml_xml_assm.c trunk/libsyncml/parser/sml_xml_assm_internals.h trunk/libsyncml/parser/sml_xml_parse.c trunk/libsyncml/parser/sml_xml_parse_internals.h trunk/libsyncml/sml_command.c trunk/libsyncml/sml_command.h trunk/libsyncml/sml_command_internals.h trunk/libsyncml/sml_defines.h trunk/libsyncml/sml_elements.c trunk/libsyncml/sml_elements.h trunk/libsyncml/sml_elements_internals.h trunk/libsyncml/sml_error.c trunk/libsyncml/sml_error_internals.h trunk/libsyncml/sml_manager.c trunk/libsyncml/sml_manager.h trunk/libsyncml/sml_manager_internals.h trunk/libsyncml/sml_md5.c trunk/libsyncml/sml_md5.h trunk/libsyncml/sml_notification.c trunk/libsyncml/sml_notification.h trunk/libsyncml/sml_notification_internals.h trunk/libsyncml/sml_parse.c trunk/libsyncml/sml_parse.h trunk/libsyncml/sml_parse_internals.h trunk/libsyncml/sml_queue.c trunk/libsyncml/sml_queue_internals.h trunk/libsyncml/sml_session.c trunk/libsyncml/sml_session.h trunk/libsyncml/sml_session_internals.h trunk/libsyncml/sml_support.c trunk/libsyncml/sml_support.h trunk/libsyncml/sml_transport.c trunk/libsyncml/sml_transport.h trunk/libsyncml/sml_transport_internals.h trunk/libsyncml/syncml.h trunk/libsyncml/transports/http_client.c trunk/libsyncml/transports/http_client_internals.h trunk/libsyncml/transports/http_server.c trunk/libsyncml/transports/http_server_internals.h trunk/libsyncml/transports/obex_client.c trunk/libsyncml/transports/obex_client_samsung.c trunk/libsyncml/transports/obex_server.c trunk/libsyncml/transports/obex_server_internals.h trunk/tests/check_data_sync_api.c trunk/tests/check_libsoup.c trunk/tests/check_manager.c trunk/tests/check_md5.c trunk/tests/check_obex.c trunk/tests/check_san.c trunk/tests/check_session.c trunk/tests/check_sync.c trunk/tests/check_wbxml_assembler.c trunk/tests/check_wbxml_parser.c trunk/tests/check_xml_assembler.c trunk/tests/support.h trunk/tools/CMakeLists.txt trunk/tools/syncml-ds-tool.c Modified: trunk/libsyncml/CMakeLists.txt ============================================================================== --- trunk/libsyncml/CMakeLists.txt Mon Jul 13 18:16:09 2009 (r1204) +++ trunk/libsyncml/CMakeLists.txt Thu Jul 16 12:19:18 2009 (r1205) @@ -13,6 +13,7 @@ sml_queue.c sml_session.c sml_support.c + sml_thread.c sml_transport.c data_sync_api/data_sync.c data_sync_api/data_sync_abort.c @@ -68,7 +69,6 @@ INSTALL( TARGETS syncml DESTINATION ${LIBSYNCML_LIBRARIES_DIR} ) INSTALL( FILES - sml_defines.h sml_error.h syncml.h DESTINATION ${LIBSYNCML_INCLUDE_DIR}/libsyncml Modified: trunk/libsyncml/data_sync_api/callbacks.h ============================================================================== --- trunk/libsyncml/data_sync_api/callbacks.h Mon Jul 13 18:16:09 2009 (r1204) +++ trunk/libsyncml/data_sync_api/callbacks.h Thu Jul 16 12:19:18 2009 (r1205) @@ -28,7 +28,11 @@ #ifndef _SML_DATA_SYNC_API_CALLBACKS_H_ #define _SML_DATA_SYNC_API_CALLBACKS_H_ +#include <libsyncml/data_sync_api/defines.h> #include <libsyncml/data_sync_api/standard.h> +#include <libsyncml/dev_inf_api/sml_dev_inf.h> + +#include <glib.h> #ifdef __cplusplus extern "C" Modified: trunk/libsyncml/data_sync_api/data_sync.c ============================================================================== --- trunk/libsyncml/data_sync_api/data_sync.c Mon Jul 13 18:16:09 2009 (r1204) +++ trunk/libsyncml/data_sync_api/data_sync.c Thu Jul 16 12:19:18 2009 (r1205) @@ -18,16 +18,20 @@ * */ -#include "../syncml.h" -#include "../syncml_internals.h" -#include "../sml_error_internals.h" #include <libsyncml/data_sync_api/defines.h> #include <libsyncml/data_sync_api/standard.h> #include <libsyncml/data_sync_api/callbacks.h> +#include "../syncml.h" +#include "../sml_support.h" +#include "../sml_thread.h" +#include "../sml_error_internals.h" + /* required because of function index */ -#include <strings.h> +#include <string.h> +#include <stdio.h> +#include <stdlib.h> #include "data_sync.h" #include "data_sync_client.h" @@ -51,7 +55,7 @@ smlTrace(TRACE_ENTRY, "%s(%d, %d, %p)", __func__, dsType, tspType, error); CHECK_ERROR_REF - smlTrace(TRACE_INTERNAL, "%s: libsyncml version: %s", __func__, VERSION); + smlTrace(TRACE_INTERNAL, "%s: libsyncml version: %s", __func__, smlGetLibraryVersion()); SmlDataSyncObject *dsObject = smlTryMalloc0(sizeof(SmlDataSyncObject), error); if (!dsObject) Modified: trunk/libsyncml/data_sync_api/data_sync.h ============================================================================== --- trunk/libsyncml/data_sync_api/data_sync.h Mon Jul 13 18:16:09 2009 (r1204) +++ trunk/libsyncml/data_sync_api/data_sync.h Thu Jul 16 12:19:18 2009 (r1205) @@ -24,8 +24,8 @@ #include <libsyncml/data_sync_api/standard.h> #include <libsyncml/data_sync_api/callbacks.h> -#include <libsyncml/syncml_internals.h> #include <libsyncml/sml_support.h> +#include <libsyncml/sml_thread.h> #include <libsyncml/sml_session.h> #include <libsyncml/sml_transport.h> Modified: trunk/libsyncml/data_sync_api/data_sync_abort.c ============================================================================== --- trunk/libsyncml/data_sync_api/data_sync_abort.c Mon Jul 13 18:16:09 2009 (r1204) +++ trunk/libsyncml/data_sync_api/data_sync_abort.c Thu Jul 16 12:19:18 2009 (r1205) @@ -18,8 +18,7 @@ * */ -#include "../syncml.h" -#include "../syncml_internals.h" +#include "../sml_support.h" #include "../sml_error_internals.h" #include <libsyncml/data_sync_api/defines.h> Modified: trunk/libsyncml/data_sync_api/data_sync_callbacks.c ============================================================================== --- trunk/libsyncml/data_sync_api/data_sync_callbacks.c Mon Jul 13 18:16:09 2009 (r1204) +++ trunk/libsyncml/data_sync_api/data_sync_callbacks.c Thu Jul 16 12:19:18 2009 (r1205) @@ -19,11 +19,12 @@ */ #include "data_sync_callbacks.h" -#include "libsyncml/syncml_internals.h" #include "libsyncml/sml_support.h" #include "libsyncml/sml_error_internals.h" #include <string.h> #include <strings.h> +#include <stdio.h> +#include <stdlib.h> #include "defines.h" #include "data_sync_devinf.h" #include "libsyncml/objects/sml_ds_server_internals.h" Modified: trunk/libsyncml/data_sync_api/data_sync_common.c ============================================================================== --- trunk/libsyncml/data_sync_api/data_sync_common.c Mon Jul 13 18:16:09 2009 (r1204) +++ trunk/libsyncml/data_sync_api/data_sync_common.c Thu Jul 16 12:19:18 2009 (r1205) @@ -19,9 +19,11 @@ */ #include "data_sync_common.h" -#include "libsyncml/syncml_internals.h" +#include "libsyncml/sml_support.h" #include "libsyncml/sml_error_internals.h" +#include <string.h> + #include "data_sync_devinf.h" gboolean Modified: trunk/libsyncml/data_sync_api/data_sync_devinf.c ============================================================================== --- trunk/libsyncml/data_sync_api/data_sync_devinf.c Mon Jul 13 18:16:09 2009 (r1204) +++ trunk/libsyncml/data_sync_api/data_sync_devinf.c Thu Jul 16 12:19:18 2009 (r1205) @@ -19,7 +19,7 @@ */ #include "data_sync_devinf.h" -#include "libsyncml/syncml_internals.h" +#include "libsyncml/sml_support.h" #include "libsyncml/sml_error_internals.h" static SmlDevInfProperty* Modified: trunk/libsyncml/data_sync_api/data_sync_loop.c ============================================================================== --- trunk/libsyncml/data_sync_api/data_sync_loop.c Mon Jul 13 18:16:09 2009 (r1204) +++ trunk/libsyncml/data_sync_api/data_sync_loop.c Thu Jul 16 12:19:18 2009 (r1205) @@ -18,8 +18,7 @@ * */ -#include "../syncml.h" -#include "../syncml_internals.h" +#include "../sml_support.h" #include "data_sync_devinf.h" #include "libsyncml/sml_error_internals.h" Modified: trunk/libsyncml/data_sync_api/data_sync_server.c ============================================================================== --- trunk/libsyncml/data_sync_api/data_sync_server.c Mon Jul 13 18:16:09 2009 (r1204) +++ trunk/libsyncml/data_sync_api/data_sync_server.c Thu Jul 16 12:19:18 2009 (r1205) @@ -25,6 +25,7 @@ #include "libsyncml/objects/sml_ds_server.h" #include "data_sync_devinf.h" #include "libsyncml/sml_support.h" +#include <string.h> static gboolean smlDataSyncServerAlertCallback (SmlDsSession *dsession, Modified: trunk/libsyncml/data_sync_api/defines.h ============================================================================== --- trunk/libsyncml/data_sync_api/defines.h Mon Jul 13 18:16:09 2009 (r1204) +++ trunk/libsyncml/data_sync_api/defines.h Thu Jul 16 12:19:18 2009 (r1205) @@ -48,7 +48,57 @@ { #endif -#include <libsyncml/sml_defines.h> +/* necessary public types */ + +typedef enum { + SML_ALERT_UNKNOWN = 0, + SML_ALERT_DISPLAY = 100, + SML_ALERT_TWO_WAY = 200, + SML_ALERT_SLOW_SYNC = 201, + SML_ALERT_ONE_WAY_FROM_CLIENT = 202, + SML_ALERT_REFRESH_FROM_CLIENT = 203, + SML_ALERT_ONE_WAY_FROM_SERVER = 204, + SML_ALERT_REFRESH_FROM_SERVER = 205, + SML_ALERT_TWO_WAY_BY_SERVER = 206, + SML_ALERT_ONE_WAY_FROM_CLIENT_BY_SERVER = 207, + SML_ALERT_REFRESH_FROM_CLIENT_BY_SERVER = 208, + SML_ALERT_ONE_WAY_FROM_SERVER_BY_SERVER = 209, + SML_ALERT_REFRESH_FROM_SERVER_BY_SERVER = 210, + SML_ALERT_RESULT = 221, + SML_ALERT_NEXT_MESSAGE = 222, + SML_ALERT_NO_END_OF_DATA = 223 +} SmlAlertType; + +typedef enum { + SML_CHANGE_UNKNOWN = 0, + SML_CHANGE_ADD = 1, + SML_CHANGE_REPLACE = 2, + SML_CHANGE_DELETE = 3 +} SmlChangeType; + +typedef enum { + SML_TRANSPORT_HTTP_SERVER = 1, + SML_TRANSPORT_HTTP_CLIENT = 2, + SML_TRANSPORT_OBEX_CLIENT = 3, + SML_TRANSPORT_OBEX_SERVER = 4 +} SmlTransportType; + +typedef enum SmlSessionType { + SML_SESSION_TYPE_SERVER = 1, + SML_SESSION_TYPE_CLIENT = 2 +} SmlSessionType; + +/*! @brief These are all possible events which the high level API sends. + */ +typedef enum SmlDataSyncEventType { + SML_DATA_SYNC_EVENT_ERROR = 0, + SML_DATA_SYNC_EVENT_CONNECT = 1, + SML_DATA_SYNC_EVENT_GOT_ALL_ALERTS = 2, + SML_DATA_SYNC_EVENT_GOT_ALL_CHANGES = 3, + SML_DATA_SYNC_EVENT_GOT_ALL_MAPPINGS = 4, + SML_DATA_SYNC_EVENT_DISCONNECT = 5, + SML_DATA_SYNC_EVENT_FINISHED = 6 +} SmlDataSyncEventType; /* SyncML default limitations */ Modified: trunk/libsyncml/data_sync_api/sml_location.c ============================================================================== --- trunk/libsyncml/data_sync_api/sml_location.c Mon Jul 13 18:16:09 2009 (r1204) +++ trunk/libsyncml/data_sync_api/sml_location.c Thu Jul 16 12:19:18 2009 (r1205) @@ -18,9 +18,9 @@ * Boston, MA 02110-1301 USA */ -#include "sml_location.h" -#include <libsyncml/syncml.h> +#include "sml_location_internals.h" #include "../sml_error_internals.h" +#include <string.h> G_DEFINE_TYPE (SmlLocation, sml_location, G_TYPE_OBJECT) Modified: trunk/libsyncml/data_sync_api/sml_location_internals.h ============================================================================== --- trunk/libsyncml/data_sync_api/sml_location_internals.h Mon Jul 13 18:16:09 2009 (r1204) +++ trunk/libsyncml/data_sync_api/sml_location_internals.h Thu Jul 16 12:19:18 2009 (r1205) @@ -22,7 +22,6 @@ #define __SML_LOCATION_INTERNALS_H__ #include "sml_location.h" -#include "../sml_error_internals.h" G_BEGIN_DECLS Modified: trunk/libsyncml/data_sync_api/standard.h ============================================================================== --- trunk/libsyncml/data_sync_api/standard.h Mon Jul 13 18:16:09 2009 (r1204) +++ trunk/libsyncml/data_sync_api/standard.h Thu Jul 16 12:19:18 2009 (r1205) @@ -33,25 +33,14 @@ #ifndef _SML_DATA_SYNC_API_STANDARD_H_ #define _SML_DATA_SYNC_API_STANDARD_H_ -#include <libsyncml/syncml.h> +#include <libsyncml/data_sync_api/defines.h> +#include <libsyncml/data_sync_api/sml_location.h> #ifdef __cplusplus extern "C" { #endif -/*! @brief These are all possible events which the high level API sends. - */ -typedef enum SmlDataSyncEventType { - SML_DATA_SYNC_EVENT_ERROR = 0, - SML_DATA_SYNC_EVENT_CONNECT = 1, - SML_DATA_SYNC_EVENT_GOT_ALL_ALERTS = 2, - SML_DATA_SYNC_EVENT_GOT_ALL_CHANGES = 3, - SML_DATA_SYNC_EVENT_GOT_ALL_MAPPINGS = 4, - SML_DATA_SYNC_EVENT_DISCONNECT = 5, - SML_DATA_SYNC_EVENT_FINISHED = 6 -} SmlDataSyncEventType; - typedef struct SmlDataSyncObject SmlDataSyncObject; /* object creation and configuration */ Modified: trunk/libsyncml/data_sync_api/transport_obex_client.c ============================================================================== --- trunk/libsyncml/data_sync_api/transport_obex_client.c Mon Jul 13 18:16:09 2009 (r1204) +++ trunk/libsyncml/data_sync_api/transport_obex_client.c Thu Jul 16 12:19:18 2009 (r1205) @@ -21,6 +21,7 @@ #include "transport.h" #include "libsyncml/sml_error_internals.h" #include "libsyncml/sml_support.h" +#include <string.h> gboolean smlDataSyncTransportObexClientInit (SmlDataSyncObject *dsObject, Modified: trunk/libsyncml/objects/sml_auth.c ============================================================================== --- trunk/libsyncml/objects/sml_auth.c Mon Jul 13 18:16:09 2009 (r1204) +++ trunk/libsyncml/objects/sml_auth.c Thu Jul 16 12:19:18 2009 (r1205) @@ -19,15 +19,13 @@ * */ -#include <libsyncml/syncml.h> -#include "sml_auth.h" - -#include <libsyncml/syncml_internals.h> #include "sml_auth_internals.h" +#include <libsyncml/sml_support.h> #include <libsyncml/sml_session_internals.h> #include <libsyncml/sml_elements_internals.h> #include <libsyncml/sml_command_internals.h> #include "libsyncml/sml_error_internals.h" +#include <string.h> static SmlStatus* _smlAuthHeaderReply(SmlSession *session, SmlErrorType code, SmlAuthType auth, GError **error); Modified: trunk/libsyncml/objects/sml_auth.h ============================================================================== --- trunk/libsyncml/objects/sml_auth.h Mon Jul 13 18:16:09 2009 (r1204) +++ trunk/libsyncml/objects/sml_auth.h Thu Jul 16 12:19:18 2009 (r1205) @@ -30,7 +30,12 @@ #ifndef _SML_AUTH_H_ #define _SML_AUTH_H_ +#include <glib.h> +#include "../sml_elements.h" +#include "../sml_manager.h" + typedef struct SmlAuthenticator SmlAuthenticator; + typedef gboolean (* SmlAuthVerifyCb)(SmlChal *chal, SmlCred *cred, const gchar *username, void *userdata, GError **error); SmlAuthenticator* smlAuthNew (GError **error); Modified: trunk/libsyncml/objects/sml_devinf_obj.c ============================================================================== --- trunk/libsyncml/objects/sml_devinf_obj.c Mon Jul 13 18:16:09 2009 (r1204) +++ trunk/libsyncml/objects/sml_devinf_obj.c Thu Jul 16 12:19:18 2009 (r1205) @@ -19,11 +19,10 @@ * */ -#include <libsyncml/syncml.h> -#include "sml_devinf_obj.h" +#include <config.h> -#include <libsyncml/syncml_internals.h> #include "sml_devinf_obj_internals.h" +#include <libsyncml/sml_support.h> #include <libsyncml/sml_session_internals.h> #include <libsyncml/sml_elements_internals.h> #include <libsyncml/sml_command_internals.h> @@ -31,6 +30,8 @@ #include "libsyncml/parser/sml_xml_parse.h" #include "libsyncml/data_sync_api/sml_location_internals.h" +#include "../syncml.h" + #ifdef WIN32 #include <windef.h> #else @@ -446,7 +447,7 @@ #endif } if (!sml_dev_inf_get_swv(devinf) && - !sml_dev_inf_set_swv(devinf, VERSION, error)) + !sml_dev_inf_set_swv(devinf, smlGetLibraryVersion(), error)) goto error; smlTrace(TRACE_EXIT, "%s: %p", __func__, agent); Modified: trunk/libsyncml/objects/sml_devinf_obj.h ============================================================================== --- trunk/libsyncml/objects/sml_devinf_obj.h Mon Jul 13 18:16:09 2009 (r1204) +++ trunk/libsyncml/objects/sml_devinf_obj.h Thu Jul 16 12:19:18 2009 (r1205) @@ -30,6 +30,10 @@ #ifndef _SML_DEVINF_OBJ_H_ #define _SML_DEVINF_OBJ_H_ +#include <glib.h> +#include "../sml_manager.h" +#include "../sml_session.h" + typedef struct SmlDevInfAgent SmlDevInfAgent; // only the SmlDevInf pointer of smlDevInfAgentNew is the local DevInf Modified: trunk/libsyncml/objects/sml_devinf_obj_internals.h ============================================================================== --- trunk/libsyncml/objects/sml_devinf_obj_internals.h Mon Jul 13 18:16:09 2009 (r1204) +++ trunk/libsyncml/objects/sml_devinf_obj_internals.h Thu Jul 16 12:19:18 2009 (r1205) @@ -30,6 +30,8 @@ #ifndef _SML_DEVINF_OBJ_INTERNALS_H_ #define _SML_DEVINF_OBJ_INTERNALS_H_ +#include "sml_devinf_obj.h" + typedef struct SmlDevInfAgentSession { /* states */ gboolean devinfSent; Modified: trunk/libsyncml/objects/sml_ds_server.c ============================================================================== --- trunk/libsyncml/objects/sml_ds_server.c Mon Jul 13 18:16:09 2009 (r1204) +++ trunk/libsyncml/objects/sml_ds_server.c Thu Jul 16 12:19:18 2009 (r1205) @@ -19,11 +19,8 @@ * */ -#include <libsyncml/syncml.h> -#include "sml_ds_server.h" - -#include <libsyncml/syncml_internals.h> #include "sml_ds_server_internals.h" +#include <libsyncml/sml_support.h> #include <libsyncml/sml_error_internals.h> #include <libsyncml/sml_manager_internals.h> #include <libsyncml/sml_session_internals.h> Modified: trunk/libsyncml/objects/sml_ds_server.h ============================================================================== --- trunk/libsyncml/objects/sml_ds_server.h Mon Jul 13 18:16:09 2009 (r1204) +++ trunk/libsyncml/objects/sml_ds_server.h Thu Jul 16 12:19:18 2009 (r1205) @@ -30,6 +30,8 @@ #ifndef _SML_DS_SERVER_H_ #define _SML_DS_SERVER_H_ +#include "../sml_notification.h" + typedef struct SmlDsServer SmlDsServer; typedef struct SmlDsSession SmlDsSession; Modified: trunk/libsyncml/objects/sml_ds_server_internals.h ============================================================================== --- trunk/libsyncml/objects/sml_ds_server_internals.h Mon Jul 13 18:16:09 2009 (r1204) +++ trunk/libsyncml/objects/sml_ds_server_internals.h Thu Jul 16 12:19:18 2009 (r1205) @@ -30,6 +30,8 @@ #ifndef _SML_DS_SERVER_INTERNALS_H_ #define _SML_DS_SERVER_INTERNALS_H_ +#include "sml_ds_server.h" + typedef void (* SmlDsSessionMapCb) (SmlDsSession *dsession, SmlLocation *orig, SmlLocation *mapped, void *userdata); typedef struct SmlWriteContext { Modified: trunk/libsyncml/parser/sml_wbxml.c ============================================================================== --- trunk/libsyncml/parser/sml_wbxml.c Mon Jul 13 18:16:09 2009 (r1204) +++ trunk/libsyncml/parser/sml_wbxml.c Thu Jul 16 12:19:18 2009 (r1205) @@ -19,21 +19,20 @@ * */ -#include <libsyncml/syncml.h> - -#include <libsyncml/syncml_internals.h> +#include <libsyncml/sml_support.h> #include <libsyncml/sml_elements_internals.h> #include <libsyncml/sml_command_internals.h> #include <libsyncml/sml_session_internals.h> #include "libsyncml/sml_error_internals.h" +#include <config.h> + #ifdef ENABLE_WBXML #include "sml_xml_assm.h" #include "sml_xml_assm_internals.h" #include "sml_xml_parse.h" #include "sml_xml_parse_internals.h" -#include "sml_wbxml.h" #include "sml_wbxml_internals.h" gboolean Modified: trunk/libsyncml/parser/sml_wbxml.h ============================================================================== --- trunk/libsyncml/parser/sml_wbxml.h Mon Jul 13 18:16:09 2009 (r1204) +++ trunk/libsyncml/parser/sml_wbxml.h Thu Jul 16 12:19:18 2009 (r1205) @@ -30,6 +30,9 @@ #ifndef _SML_WBXML_H_ #define _SML_WBXML_H_ +#include "sml_xml_parse.h" +#include "sml_xml_assm.h" + SmlXmlParser* smlWbxmlParserNew (SmlParserFunctions *functions, GError **error); SmlXmlAssembler* smlWbxmlAssemblerNew (SmlAssembler *assembler, SmlAssemblerFunctions *functions, GError **error); Modified: trunk/libsyncml/parser/sml_wbxml_internals.h ============================================================================== --- trunk/libsyncml/parser/sml_wbxml_internals.h Mon Jul 13 18:16:09 2009 (r1204) +++ trunk/libsyncml/parser/sml_wbxml_internals.h Thu Jul 16 12:19:18 2009 (r1205) @@ -31,6 +31,7 @@ #define _SML_WBXML_INTERNALS_H_ #include <wbxml.h> +#include "sml_wbxml.h" gboolean smlWbxmlConvertTo (WBXMLConvXML2WBXMLParams *params, const gchar *input, gchar **output, gsize *outputLen, GError** error); gboolean smlWbxmlConvertFrom (WBXMLConvWBXML2XMLParams *params, const gchar *input, gsize inputLen, gchar **output, gsize *outputLen, GError** error); Modified: trunk/libsyncml/parser/sml_xml_assm.c ============================================================================== --- trunk/libsyncml/parser/sml_xml_assm.c Mon Jul 13 18:16:09 2009 (r1204) +++ trunk/libsyncml/parser/sml_xml_assm.c Thu Jul 16 12:19:18 2009 (r1205) @@ -19,17 +19,16 @@ * */ -#include <libsyncml/syncml.h> - -#include <libsyncml/syncml_internals.h> +#include <libsyncml/sml_support.h> #include <libsyncml/sml_elements_internals.h> #include <libsyncml/sml_command_internals.h> #include <libsyncml/sml_session_internals.h> #include "libsyncml/sml_error_internals.h" -#include "sml_xml_assm.h" #include "sml_xml_assm_internals.h" +#include <string.h> + #define BUFFER_SIZE 500 /** @@ -1044,7 +1043,7 @@ break; default: g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, - "Unknown version"); + "Unknown version %d", session->version); goto error; } break; @@ -1119,7 +1118,7 @@ } /* set MaxMsgSize if available */ - unsigned int localMaxMsgSize = smlSessionGetLocalMaxMsgSize(session); + gsize localMaxMsgSize = smlSessionGetLocalMaxMsgSize(session); if (localMaxMsgSize) { if (!_smlXmlAssemblerStartNode(assm, SML_ELEMENT_META, error)) goto error; Modified: trunk/libsyncml/parser/sml_xml_assm_internals.h ============================================================================== --- trunk/libsyncml/parser/sml_xml_assm_internals.h Mon Jul 13 18:16:09 2009 (r1204) +++ trunk/libsyncml/parser/sml_xml_assm_internals.h Thu Jul 16 12:19:18 2009 (r1205) @@ -31,6 +31,7 @@ #define _SML_XML_ASSM_INTERNALS_H_ #include <libxml/xmlwriter.h> +#include "sml_xml_assm.h" #define XML_NODE_START 1 #define XML_NODE_TEXT 3 Modified: trunk/libsyncml/parser/sml_xml_parse.c ============================================================================== --- trunk/libsyncml/parser/sml_xml_parse.c Mon Jul 13 18:16:09 2009 (r1204) +++ trunk/libsyncml/parser/sml_xml_parse.c Thu Jul 16 12:19:18 2009 (r1205) @@ -19,17 +19,15 @@ * */ -#include <libsyncml/syncml.h> - -#include <libsyncml/syncml_internals.h> +#include <libsyncml/sml_support.h> #include <libsyncml/sml_elements_internals.h> #include <libsyncml/sml_command_internals.h> #include <libsyncml/sml_session_internals.h> #include "libsyncml/sml_error_internals.h" #include "libsyncml/data_sync_api/sml_location_internals.h" -#include "sml_xml_parse.h" #include "sml_xml_parse_internals.h" +#include <string.h> #define BUFFER_SIZE 500 @@ -1312,7 +1310,7 @@ if (!*cmd) goto error; (*cmd)->refCount = 1; - (*cmd)->private.alert.maxObjSize = -1; + (*cmd)->private.alert.maxObjSize = 0; while (1) { if (!_smlXmlParserStep(parser)) { @@ -1395,7 +1393,7 @@ *cmd = smlCommandNew(SML_COMMAND_TYPE_SYNC, error); if (!*cmd) goto error; - (*cmd)->private.sync.maxObjSize = -1; + (*cmd)->private.sync.maxObjSize = 0; while (1) { if (!_smlXmlParserStep(parser)) { Modified: trunk/libsyncml/parser/sml_xml_parse_internals.h ============================================================================== --- trunk/libsyncml/parser/sml_xml_parse_internals.h Mon Jul 13 18:16:09 2009 (r1204) +++ trunk/libsyncml/parser/sml_xml_parse_internals.h Thu Jul 16 12:19:18 2009 (r1205) @@ -38,6 +38,7 @@ #include <libxml/xmlreader.h> #include <libxml/xmlwriter.h> +#include "sml_xml_parse.h" #define XML_NODE_START 1 #define XML_NODE_TEXT 3 Modified: trunk/libsyncml/sml_command.c ============================================================================== --- trunk/libsyncml/sml_command.c Mon Jul 13 18:16:09 2009 (r1204) +++ trunk/libsyncml/sml_command.c Thu Jul 16 12:19:18 2009 (r1205) @@ -19,15 +19,11 @@ * */ -#include "syncml.h" - -#include "syncml_internals.h" -#include "sml_parse_internals.h" #include "sml_command_internals.h" -#include "sml_session_internals.h" -#include "sml_elements_internals.h" #include "sml_error_internals.h" -#include "parser/sml_xml_assm.h" +#include "sml_support.h" +#include <stdio.h> +#include <stdlib.h> SmlCommandType smlCommandTypeFromString (const gchar *name, @@ -245,7 +241,7 @@ switch (cmd->type) { case SML_COMMAND_TYPE_ALERT: if (cmd->private.alert.anchor) { - reply->anchor = smlAnchorNew(NULL, cmd->private.alert.anchor->next, error); + reply->anchor = smlAnchorNew(NULL, smlAnchorGetNext(cmd->private.alert.anchor), error); if (!reply->anchor) goto error; } @@ -287,14 +283,11 @@ if (!result->private.results.status->item) goto error; - result->private.results.status->item->contenttype = g_strdup(contenttype); - result->private.results.status->item->source = sml_location_clone(source, error); - if (!result->private.results.status->item->source) - goto error; - - if (!result->private.results.status->item->source) + if (!smlItemSetContentType(result->private.results.status->item, contenttype, error)) goto error; - + /* FIXME: Why did we use sml_location_clone here? */ + smlItemSetSource(result->private.results.status->item, source); + smlTrace(TRACE_EXIT, "%s: %p", __func__, result); return result; error: @@ -444,16 +437,18 @@ * smlDsSessionQueueChange. So the correct usage of target * and source must be ensured by the XML assembler. */ - item->source = loc; + smlItemSetSource(item, loc); if (type != SML_CHANGE_ADD) { /* If this is an Add command then nobody knows * which ID the remote peer will be use for this item. */ g_object_ref(loc); - item->target = loc; + smlItemSetTarget(item, loc); } + g_object_unref(loc); - item->contenttype = g_strdup(contenttype); + if (!smlItemSetContentType(item, contenttype, error)) + goto error; smlTrace(TRACE_EXIT, "%s: %p", __func__, cmd); return cmd; @@ -518,13 +513,16 @@ if (!sml_location_set_uri(loc, uid, error)) goto error; - if (type != SML_CHANGE_ADD) - item->target = loc; - else - item->source = loc; + if (type != SML_CHANGE_ADD) { + smlItemSetTarget(item, loc); + } else { + smlItemSetSource(item, loc); + } + g_object_unref(loc); - item->moreData = TRUE; - item->contenttype = g_strdup(contenttype); + smlItemSetMoreData(item, TRUE); + if (!smlItemSetContentType(item, contenttype, error)) + goto error; smlTrace(TRACE_EXIT, "%s: %p", __func__, cmd); return cmd; @@ -652,7 +650,8 @@ smlItemSetSource(cmd->private.access.item, cmd->source); } - cmd->private.access.item->contenttype = g_strdup(contenttype); + if (!smlItemSetContentType(cmd->private.access.item, contenttype, error)) + goto error; smlTrace(TRACE_EXIT, "%s: %p", __func__, cmd); return cmd; @@ -684,7 +683,8 @@ g_object_ref(target); smlItemSetTarget(cmd->private.access.item, cmd->target); - cmd->private.access.item->contenttype = g_strdup(contenttype); + if (!smlItemSetContentType(cmd->private.access.item, contenttype, error)) + goto error; smlTrace(TRACE_EXIT, "%s: %p", __func__, cmd); return cmd; @@ -733,7 +733,7 @@ goto error; /* Since the devinf is xml, we want to send it "raw" (without cdata) */ - result->private.results.status->item->raw = TRUE; + smlItemSetRaw(result->private.results.status->item, TRUE); g_object_unref(source); @@ -924,3 +924,33 @@ } } +void +smlCommandSetID (SmlCommand *cmd, + gsize id) +{ + cmd->cmdID = id; +} + +SmlCommandType +smlCommandGetType (SmlCommand *cmd) +{ + return cmd->type; +} + +SmlLocation* +smlCommandGetSource (SmlCommand *cmd) +{ + return cmd->source; +} + +SmlLocation* +smlCommandGetTarget (SmlCommand *cmd) +{ + return cmd->target; +} + +const gchar* +smlCommandGetContentType (SmlCommand *cmd) +{ + return cmd->private.alert.contentType; +} Modified: trunk/libsyncml/sml_command.h ============================================================================== --- trunk/libsyncml/sml_command.h Mon Jul 13 18:16:09 2009 (r1204) +++ trunk/libsyncml/sml_command.h Thu Jul 16 12:19:18 2009 (r1205) @@ -32,6 +32,10 @@ #include <libsyncml/syncml.h> #include <libsyncml/dev_inf_api/sml_dev_inf.h> +#include "sml_elements.h" + +typedef struct SmlCommand SmlCommand; +typedef struct SmlStatus SmlStatus; SmlStatus* smlStatusNew (SmlErrorType data, gsize cmdref, gsize msgref, SmlLocation *sourceref, SmlLocation *targeref, SmlCommandType type, GError **error); SmlStatus* smlStatusRef (SmlStatus *status); @@ -61,6 +65,15 @@ SmlCommand* smlCommandNewMap (SmlLocation *target, SmlLocation *source, GError **error); gboolean smlCommandAddMapItem (SmlCommand *map, SmlMapItem *item, GError **error); +void smlCommandSetID (SmlCommand *cmd, gsize id); + +SmlCommandType smlCommandGetType (SmlCommand *cmd); +SmlLocation* smlCommandGetSource (SmlCommand *cmd); +SmlLocation* smlCommandGetTarget (SmlCommand *cmd); +const gchar* smlCommandGetContentType (SmlCommand *cmd); + +G_CONST_RETURN gchar *smlCommandTypeToString(SmlCommandType type, GError **error); + #endif //_SML_COMMAND_H_ /*@}*/ Modified: trunk/libsyncml/sml_command_internals.h ============================================================================== --- trunk/libsyncml/sml_command_internals.h Mon Jul 13 18:16:09 2009 (r1204) +++ trunk/libsyncml/sml_command_internals.h Thu Jul 16 12:19:18 2009 (r1205) @@ -30,6 +30,10 @@ #ifndef _SML_COMMAND_INTERNALS_H_ #define _SML_COMMAND_INTERNALS_H_ +#include "sml_command.h" +#include "sml_elements.h" +#include "sml_session.h" + typedef struct SmlCommandAlertPrivate { SmlAlertType type; SmlAnchor *anchor; @@ -108,7 +112,6 @@ }; SmlCommandType smlCommandTypeFromString(const gchar *name, GError **error); -G_CONST_RETURN gchar *smlCommandTypeToString(SmlCommandType type, GError **error); SmlAlertType smlAlertTypeConvert(guint id, GError **error); Modified: trunk/libsyncml/sml_defines.h ============================================================================== --- trunk/libsyncml/sml_defines.h Mon Jul 13 18:16:09 2009 (r1204) +++ trunk/libsyncml/sml_defines.h Thu Jul 16 12:19:18 2009 (r1205) @@ -237,13 +237,6 @@ } SmlMimeType; typedef enum { - SML_TRANSPORT_HTTP_SERVER, - SML_TRANSPORT_HTTP_CLIENT, - SML_TRANSPORT_OBEX_CLIENT, - SML_TRANSPORT_OBEX_SERVER -} SmlTransportType; - -typedef enum { SML_RESULT_OK, SML_RESULT_RETRY, SML_RESULT_FATAL @@ -277,32 +270,6 @@ } SmlCommandType; typedef enum { - SML_ALERT_UNKNOWN = 0, - SML_ALERT_DISPLAY = 100, - SML_ALERT_TWO_WAY = 200, - SML_ALERT_SLOW_SYNC = 201, - SML_ALERT_ONE_WAY_FROM_CLIENT = 202, - SML_ALERT_REFRESH_FROM_CLIENT = 203, - SML_ALERT_ONE_WAY_FROM_SERVER = 204, - SML_ALERT_REFRESH_FROM_SERVER = 205, - SML_ALERT_TWO_WAY_BY_SERVER = 206, - SML_ALERT_ONE_WAY_FROM_CLIENT_BY_SERVER = 207, - SML_ALERT_REFRESH_FROM_CLIENT_BY_SERVER = 208, - SML_ALERT_ONE_WAY_FROM_SERVER_BY_SERVER = 209, - SML_ALERT_REFRESH_FROM_SERVER_BY_SERVER = 210, - SML_ALERT_RESULT = 221, - SML_ALERT_NEXT_MESSAGE = 222, - SML_ALERT_NO_END_OF_DATA = 223 -} SmlAlertType; - -typedef enum { - SML_CHANGE_UNKNOWN = 0, - SML_CHANGE_ADD = 1, - SML_CHANGE_REPLACE = 2, - SML_CHANGE_DELETE = 3 -} SmlChangeType; - -typedef enum { SML_AUTH_TYPE_UNKNOWN = 0, SML_AUTH_TYPE_BASIC = 1, SML_AUTH_TYPE_MD5 = 2 Modified: trunk/libsyncml/sml_elements.c ============================================================================== --- trunk/libsyncml/sml_elements.c Mon Jul 13 18:16:09 2009 (r1204) +++ trunk/libsyncml/sml_elements.c Thu Jul 16 12:19:18 2009 (r1205) @@ -19,14 +19,13 @@ * */ -#include "syncml.h" - -#include "syncml_internals.h" -#include "sml_parse_internals.h" #include "sml_elements_internals.h" -#include "sml_command_internals.h" +#include "sml_support.h" +#include "sml_parse.h" +#include "sml_command.h" #include "sml_error_internals.h" #include "data_sync_api/sml_location_internals.h" +#include <string.h> SmlAnchor* smlAnchorNew (const gchar *last, @@ -66,6 +65,54 @@ smlTrace(TRACE_EXIT, "%s", __func__); } +const gchar* +smlAnchorGetLast (SmlAnchor *anchor) +{ + return anchor->last; +} + +const gchar* +smlAnchorGetNext (SmlAnchor *anchor) +{ + return anchor->next; +} + +gsize +smlHeaderGetSessionID (SmlHeader *header) +{ + return header->sessionID; +} + +gsize +smlHeaderGetMessageID (SmlHeader *header) +{ + return header->messageID; +} + +SmlProtocolVersion +smlHeaderGetProtocolVersion (SmlHeader *header) +{ + return header->version; +} + +SmlProtocolType +smlHeaderGetProtocolType (SmlHeader *header) +{ + return header->protocol; +} + +SmlLocation* +smlHeaderGetSource (SmlHeader *header) +{ + return header->source; +} + +SmlLocation* +smlHeaderGetTarget (SmlHeader *header) +{ + return header->target; +} + void smlHeaderFree (SmlHeader *header) { @@ -342,6 +389,35 @@ item->raw = raw; } +void +smlItemSetMoreData (SmlItem *item, + gboolean enable) +{ + item->moreData = enable; +} + +gboolean +smlItemGetMoreData (SmlItem *item) +{ + return item->moreData; +} + +gboolean +smlItemSetContentType (SmlItem *item, + const gchar *ct, + GError **error) +{ + CHECK_ERROR_REF + item->contenttype = g_strdup(ct); + return TRUE; +} + +const gchar* +smlItemGetContentType (SmlItem *item) +{ + return item->contenttype; +} + SmlCred* smlCredNewFromString (const gchar *type, const gchar *format, @@ -492,6 +568,18 @@ smlTrace(TRACE_EXIT, "%s", __func__); } +const gchar* +smlCredGetUsername (SmlCred *cred) +{ + return cred->username; +} + +const gchar* +smlCredGetPassword (SmlCred *cred) +{ + return cred->password; +} + SmlChal* smlChalNew (SmlAuthType type, GError **error) Modified: trunk/libsyncml/sml_elements.h ============================================================================== --- trunk/libsyncml/sml_elements.h Mon Jul 13 18:16:09 2009 (r1204) +++ trunk/libsyncml/sml_elements.h Thu Jul 16 12:19:18 2009 (r1205) @@ -30,14 +30,29 @@ #ifndef _SML_ELEMENTS_H_ #define _SML_ELEMENTS_H_ -SmlCred* smlCredNewFromString (const gchar *type, const gchar *format, const gchar *data, GError **error); -SmlCred* smlCredNewAuth (SmlAuthType type, const gchar *username, const gchar *password, GError **error); -SmlCred* smlCredNew (SmlAuthType type, SmlFormatType format, const gchar *data, const gchar *username, GError **error); -void smlCredRef (SmlCred *cred); -void smlCredUnref (SmlCred *cred); - -SmlAnchor* smlAnchorNew (const gchar *last, const gchar *next, GError **error); -void smlAnchorFree (SmlAnchor *anchor); +#include <glib.h> +#include "sml_defines.h" +#include <libsyncml/data_sync_api/sml_location.h> + +typedef struct SmlCred SmlCred; +typedef struct SmlAnchor SmlAnchor; +typedef struct SmlItem SmlItem; +typedef struct SmlHeader SmlHeader; +typedef struct SmlChal SmlChal; +typedef struct SmlMapItem SmlMapItem; + +SmlCred* smlCredNewFromString (const gchar *type, const gchar *format, const gchar *data, GError **error); +SmlCred* smlCredNewAuth (SmlAuthType type, const gchar *username, const gchar *password, GError **error); +SmlCred* smlCredNew (SmlAuthType type, SmlFormatType format, const gchar *data, const gchar *username, GError **error); +void smlCredRef (SmlCred *cred); +void smlCredUnref (SmlCred *cred); +const gchar* smlCredGetUsername (SmlCred *cred); +const gchar* smlCredGetPassword (SmlCred *cred); + +SmlAnchor* smlAnchorNew (const gchar *last, const gchar *next, GError **error); +const char* smlAnchorGetLast (SmlAnchor *anchor); +const char* smlAnchorGetNext (SmlAnchor *anchor); +void smlAnchorFree (SmlAnchor *anchor); SmlItem* smlItemNew (gsize size, GError **error); SmlItem* smlItemNewForData (const gchar *data, gsize size, GError **error); @@ -49,13 +64,24 @@ gboolean smlItemGetData (SmlItem *item, gchar **data, gsize *size, GError **error); gboolean smlItemStealData (SmlItem *item, gchar **data, gsize *size, GError **error); +void smlItemSetMoreData (SmlItem *item, gboolean enable); +gboolean smlItemGetMoreData (SmlItem *item); +gboolean smlItemSetContentType (SmlItem *item, const gchar *ct, GError **error); +const gchar* smlItemGetContentType (SmlItem *item); + void smlItemSetSource (SmlItem *item, SmlLocation *source); SmlLocation* smlItemGetSource (SmlItem *item); void smlItemSetTarget (SmlItem *item, SmlLocation *target); SmlLocation* smlItemGetTarget (SmlItem *item); void smlItemSetRaw (SmlItem *item, gboolean raw); -void smlHeaderFree(SmlHeader *header); +gsize smlHeaderGetSessionID (SmlHeader *header); +gsize smlHeaderGetMessageID (SmlHeader *header); +SmlProtocolVersion smlHeaderGetProtocolVersion (SmlHeader *header); +SmlProtocolType smlHeaderGetProtocolType (SmlHeader *header); +SmlLocation* smlHeaderGetSource (SmlHeader *header); +SmlLocation* smlHeaderGetTarget (SmlHeader *header); +void smlHeaderFree (SmlHeader *header); SmlChal* smlChalNew (SmlAuthType type, GError **error); SmlChal* smlChalNewFromBinary (SmlAuthType type, const gchar *nonce, gsize length, GError **error); Modified: trunk/libsyncml/sml_elements_internals.h ============================================================================== --- trunk/libsyncml/sml_elements_internals.h Mon Jul 13 18:16:09 2009 (r1204) +++ trunk/libsyncml/sml_elements_internals.h Thu Jul 16 12:19:18 2009 (r1205) @@ -30,6 +30,7 @@ #ifndef _SML_ELEMENTS_INTERNALS_H_ #define _SML_ELEMENTS_INTERNALS_H_ +#include "sml_elements.h" #include <libxml/xmlreader.h> struct SmlAnchor { Modified: trunk/libsyncml/sml_error.c ============================================================================== --- trunk/libsyncml/sml_error.c Mon Jul 13 18:16:09 2009 (r1204) +++ trunk/libsyncml/sml_error.c Thu Jul 16 12:19:18 2009 (r1205) @@ -19,9 +19,6 @@ * */ -#include "syncml.h" - -#include "syncml_internals.h" #include "sml_error_internals.h" /** Modified: trunk/libsyncml/sml_error_internals.h ============================================================================== --- trunk/libsyncml/sml_error_internals.h Mon Jul 13 18:16:09 2009 (r1204) +++ trunk/libsyncml/sml_error_internals.h Thu Jul 16 12:19:18 2009 (r1205) @@ -22,7 +22,9 @@ #ifndef _SML_ERROR_INTERNALS_H_ #define _SML_ERROR_INTERNALS_H_ -#include "syncml_internals.h" +#include "sml_error.h" +#include "sml_support.h" +#include <string.h> #define CHECK_ERROR_REF \ smlAssertMsg(error, "The error handling of the function must be used."); \ Modified: trunk/libsyncml/sml_manager.c ============================================================================== --- trunk/libsyncml/sml_manager.c Mon Jul 13 18:16:09 2009 (r1204) +++ trunk/libsyncml/sml_manager.c Thu Jul 16 12:19:18 2009 (r1205) @@ -19,15 +19,15 @@ * */ -#include "syncml.h" - -#include "syncml_internals.h" #include "sml_error_internals.h" #include "sml_manager_internals.h" -#include "sml_transport_internals.h" -#include "sml_command_internals.h" -#include "sml_elements_internals.h" -#include "sml_session_internals.h" +#include "sml_support.h" +#include <stdio.h> +#include <stdlib.h> +//#include "sml_transport_internals.h" +//#include "sml_command_internals.h" +//#include "sml_elements_internals.h" +//#include "sml_session_internals.h" typedef struct managerSession { SmlLink *link; @@ -230,14 +230,14 @@ break; case SML_TRANSPORT_EVENT_DATA: - parser = smlParserNew(data->type, 0, &locerror); + parser = smlParserNew(smlTransportDataGetType(data), 0, &locerror); if (!parser) goto error; /* add manager to parser for OMA DS 1.2 SAN handling */ smlParserSetManager(parser, manager); /* start to parse the data */ - if (!smlParserStart(parser, data->data, data->size, &locerror)) + if (!smlParserStart(parser, smlTransportDataGetData(data), smlTransportDataGetSize(data), &locerror)) goto error; /* Get the header of the message*/ @@ -247,7 +247,7 @@ goto error; /* Find the session if available otherwise register it as new */ - session = smlManagerSessionFind(manager, header->sessionID); + session = smlManagerSessionFind(manager, smlHeaderGetSessionID(header)); if (!session) { /* If we use the target and source from the header of the received message * then we MUST interchange source and target */ @@ -275,14 +275,18 @@ break; } if (!(session = smlSessionNew( - sessionType, data->type, - header->version, header->protocol, - header->source, header->target, - header->sessionID, 1, &locerror))) + sessionType, + smlTransportDataGetType(data), + smlHeaderGetProtocolVersion(header), + smlHeaderGetProtocolType(header), + smlHeaderGetSource(header), + smlHeaderGetTarget(header), + smlHeaderGetSessionID(header), + 1, &locerror))) goto error; if (link_) { - char *responseURI = smlTransportGetResponseURI(link_, session, &locerror); + char *responseURI = smlLinkGetResponseURI(link_, session, &locerror); if (!responseURI && locerror) goto error; if (responseURI) @@ -303,7 +307,7 @@ * SECURITY: this is important to avoid replay attacks */ if (link_) { - char *responseUri = smlTransportGetResponseURI(link_, session, &locerror); + char *responseUri = smlLinkGetResponseURI(link_, session, &locerror); if (!responseUri && locerror) { goto error; } @@ -625,8 +629,8 @@ * 2.2. this is an active server connection */ GError *error = NULL; - if (manager->transport->connected && - (!sess->link || sess->link->link_data) && + if (smlTransportIsConnected(manager->transport) && + (!sess->link || smlLinkIsConnected(sess->link)) && !smlTransportDisconnect(manager->transport, sess->link, &error)) { g_warning("Errors from the transport layer " \ "cannot be handled while freeing the manager. %s", @@ -1132,9 +1136,10 @@ SmlObject *object = smlManagerObjectFindInternal( manager, session, - cmd->type, - cmd->target, cmd->source, - cmd->private.alert.contentType); + smlCommandGetType(cmd), + smlCommandGetTarget(cmd), + smlCommandGetSource(cmd), + smlCommandGetContentType(cmd)); smlTrace(TRACE_EXIT, "%s(%p)", __func__, object); return object; } @@ -1237,13 +1242,15 @@ CHECK_ERROR_REF if (manager->headerCallback && - session->sessionType == SML_SESSION_TYPE_SERVER) { + smlSessionGetType(session) == SML_SESSION_TYPE_SERVER) { /* Authentication is only specified for OMA DS server. */ manager->headerCallback(session, header, cred, manager->headerCallbackUserdata); } else { smlTrace(TRACE_INTERNAL, "%s: Header not handled!", __func__); - if (session->sessionType == SML_SESSION_TYPE_SERVER && - !session->established) { + smlTrace(TRACE_INTERNAL, "%s: type %d", __func__, smlSessionGetType(session)); + smlTrace(TRACE_INTERNAL, "%s: established %d", __func__, smlSessionGetEstablished(session)); + if (smlSessionGetType(session) == SML_SESSION_TYPE_SERVER && + !smlSessionGetEstablished(session)) { /* An OMA DS server must handle the header for security * reasons - especially authentication. * @@ -1253,15 +1260,16 @@ "The header callback is missing. " \ "All requests will be accepted without authentication.", __func__); - session->established = TRUE; + smlSessionSetEstablished(session, TRUE); smlSessionDispatchEvent( session, SML_SESSION_EVENT_ESTABLISHED, NULL, NULL, NULL, NULL); } SmlStatus *status = smlStatusNew( SML_NO_ERROR, 0, - header->messageID, - header->source, header->target, + smlHeaderGetMessageID(header), + smlHeaderGetSource(header), + smlHeaderGetTarget(header), SML_COMMAND_TYPE_HEADER, error); if (!status) goto error; @@ -1351,18 +1359,18 @@ object->commandCallback(session, cmd, object->commandCallbackUserdata); } else { - const char *type = smlCommandTypeToString(cmd->type, error); + const char *type = smlCommandTypeToString(smlCommandGetType(cmd), error); /* If the type is unknown then this can be part of the error. */ if (*error) { g_error_free(*error); *error = NULL; } const char *srcuri = NULL; - if (cmd->source) - srcuri = sml_location_get_uri(cmd->source); + if (smlCommandGetSource(cmd)) + srcuri = sml_location_get_uri(smlCommandGetSource(cmd)); const char *dsturi = NULL; - if (cmd->target) - dsturi = sml_location_get_uri(cmd->target); + if (smlCommandGetTarget(cmd)) + dsturi = sml_location_get_uri(smlCommandGetTarget(cmd)); g_set_error(error, SML_ERROR, SML_ERROR_NOT_FOUND, "Unable to find command handler (%s: %s -> %s)", (type) ? type : "UNKNOWN", VA_STRING(srcuri), VA_STRING(dsturi)); GError *locerror = NULL; Modified: trunk/libsyncml/sml_manager.h ============================================================================== --- trunk/libsyncml/sml_manager.h Mon Jul 13 18:16:09 2009 (r1204) +++ trunk/libsyncml/sml_manager.h Thu Jul 16 12:19:18 2009 (r1205) @@ -30,6 +30,9 @@ #ifndef _SML_MANAGER_H #define _SML_MANAGER_H +typedef struct SmlManager SmlManager; +typedef struct SmlObject SmlObject; + typedef enum { SML_MANAGER_CONNECT_DONE, SML_MANAGER_DISCONNECT_DONE, @@ -43,10 +46,15 @@ SML_MANAGER_SESSION_ESTABLISHED } SmlManagerEventType; +/* Always include header files after typedefs. */ + +#include "sml_session.h" + +/* Always include callbacks after the inclusion of the header files. */ + typedef void (* SmlManagerEventCb) (SmlManager *manager, SmlManagerEventType type, SmlSession *session, GError *error, void *userdata); typedef void (* SmlCommandCb) (SmlSession *session, SmlCommand *cmd, void *userdata); typedef void (* SmlHeaderCb) (SmlSession *session, SmlHeader *header, SmlCred *cred, void *userdata); -typedef void (* SmlStatusReplyCb) (SmlSession *session, SmlStatus *status, void *userdata); SmlManager* smlManagerNew (SmlTransport *tsp, GError **error); void smlManagerFree (SmlManager *manager); @@ -79,6 +87,8 @@ gsize smlManagerGetNewSessionID (SmlManager *manager); +SmlTransport* smlManagerGetTransport (SmlManager *manager); + #endif //_SML_MANAGER_H /*@}*/ Modified: trunk/libsyncml/sml_manager_internals.h ============================================================================== --- trunk/libsyncml/sml_manager_internals.h Mon Jul 13 18:16:09 2009 (r1204) +++ trunk/libsyncml/sml_manager_internals.h Thu Jul 16 12:19:18 2009 (r1205) @@ -30,6 +30,8 @@ #ifndef _SML_MANAGER_INTERNALS_H #define _SML_MANAGER_INTERNALS_H +#include "sml_manager.h" +#include "sml_thread.h" #include "sml_queue_internals.h" struct SmlManager { Modified: trunk/libsyncml/sml_md5.c ============================================================================== --- trunk/libsyncml/sml_md5.c Mon Jul 13 18:16:09 2009 (r1204) +++ trunk/libsyncml/sml_md5.c Thu Jul 16 12:19:18 2009 (r1205) @@ -8,13 +8,15 @@ * */ -#include "syncml.h" -#include "syncml_internals.h" +#include "sml_md5.h" + #include "sml_error_internals.h" +#include "sml_support.h" #include <string.h> #include <stdint.h> -#include "sml_md5.h" +#include <stdio.h> +#include <stdlib.h> #include <glib.h> typedef struct SmlMD5Context { Modified: trunk/libsyncml/sml_md5.h ============================================================================== --- trunk/libsyncml/sml_md5.h Mon Jul 13 18:16:09 2009 (r1204) +++ trunk/libsyncml/sml_md5.h Thu Jul 16 12:19:18 2009 (r1205) @@ -30,6 +30,8 @@ #ifndef _SML_MD5_H_ #define _SML_MD5_H_ +#include <glib.h> + void smlMD5GetDigest (const gchar *buffer, gsize buffer_size, guchar digest[16]); gchar* smlMD5ToString (guchar digest[16], GError **error); Modified: trunk/libsyncml/sml_notification.c ============================================================================== --- trunk/libsyncml/sml_notification.c Mon Jul 13 18:16:09 2009 (r1204) +++ trunk/libsyncml/sml_notification.c Thu Jul 16 12:19:18 2009 (r1205) @@ -19,17 +19,21 @@ * */ -#include "syncml.h" - -#include "syncml_internals.h" #include "sml_notification_internals.h" -#include "sml_transport_internals.h" -#include "sml_command_internals.h" -#include "sml_manager_internals.h" + +#include "sml_support.h" + +#include "string.h" +#include "sml_transport.h" +//#include "sml_command_internals.h" +//#include "sml_manager_internals.h" #include "sml_error_internals.h" -#include "objects/sml_auth_internals.h" -#include "sml_elements_internals.h" +//#include "objects/sml_auth_internals.h" +//#include "sml_elements_internals.h" #include "data_sync_api/sml_location_internals.h" +#include <stdlib.h> +#include <stdio.h> + SmlNotification* smlNotificationNew (SmlNotificationVersion version, @@ -192,7 +196,7 @@ goto error; } - unsigned int idLength = (uint8_t)data[23]; + guint8 idLength = (guint8) data[23]; if (size < (25 + idLength)) { g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Size too small2"); goto error; @@ -204,8 +208,8 @@ san->type = SML_MIMETYPE_SAN; /* Version */ - unsigned int version = ((uint8_t)data[16]) << 2; - version = version | ((uint8_t)data[17]) >> 6; + guint8 version = ((guint8)data[16]) << 2; + version = version | ((guint8)data[17]) >> 6; switch (version) { case 12: san->version = SML_SAN_VERSION_12; @@ -216,14 +220,14 @@ } /* ui mode */ - san->mode = (((uint8_t)data[17]) & 0x30) >> 4; + san->mode = (((guint8)data[17]) & 0x30) >> 4; /* initiator */ - san->init = (((uint8_t)data[17]) & 0x08) >> 3; + san->init = (((guint8)data[17]) & 0x08) >> 3; /* session id */ - san->sessionID = ((uint8_t)data[21]) << 8; - san->sessionID = san->sessionID | (uint8_t)data[22]; + san->sessionID = ((guint8)data[21]) << 8; + san->sessionID = san->sessionID | (guint8)data[22]; /* server identifier */ if (idLength) { @@ -235,9 +239,9 @@ memcpy(san->identifier, data + 24, idLength); } - unsigned int numSync = ((uint8_t)data[24 + idLength]) >> 4; + guint8 numSync = ((guint8)data[24 + idLength]) >> 4; data += 25 + idLength; - unsigned int alertLength = 25 + idLength; + guint8 alertLength = 25 + idLength; unsigned int i = 0; for (i = 0; i < numSync; i++) { @@ -246,7 +250,7 @@ goto error; } - idLength = (uint8_t)data[4]; + idLength = (guint8)data[4]; if (size < (alertLength + 5 + idLength)) { g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Size too small4"); goto error; @@ -254,15 +258,15 @@ alertLength = alertLength + 5 + idLength; /* Alert type + future */ - SmlAlertType alert_type = (((uint8_t)data[0]) >> 4) + 200; + SmlAlertType alert_type = (((guint8)data[0]) >> 4) + 200; if (alert_type < 206 || alert_type > 210) { g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Wrong alert type"); goto error; } - unsigned int contenttype = ((uint8_t)data[1]) << 16; - contenttype = contenttype | ((uint8_t)data[2]) << 8; - contenttype = contenttype | ((uint8_t)data[3]); + guint32 contenttype = ((guint8)data[1]) << 16; + contenttype = contenttype | ((guint8)data[2]) << 8; + contenttype = contenttype | ((guint8)data[3]); /* The contenttype */ const char *alert_ct; @@ -409,7 +413,7 @@ goto error; } - cmd->cmdID = i; + smlCommandSetID(cmd, i); i++; if (!smlAssemblerStartCommand(assm, NULL, cmd, error) == SML_ASSEMBLER_RESULT_OK) @@ -569,8 +573,8 @@ const char *username = ""; const char *password = ""; if (san->cred) { - username = san->cred->username; - password = san->cred->password; + username = smlCredGetUsername(san->cred); + password = smlCredGetPassword(san->cred); } char *auth = g_strdup_printf("%s:%s", username, password); smlMD5GetDigest (auth, strlen(auth), digest); @@ -659,7 +663,7 @@ SyncML message type (xml/wbxml) for GET. To avoid that we response after the PUT with a GET SML_MIMETYPE_SAN request. */ if (san->version == SML_SAN_VERSION_12) - tspdata->type_get = san->type; + smlTransportDataSetRequestedType(tspdata, san->type); if (!smlTransportSend(tsp, NULL, tspdata, error)) goto error; Modified: trunk/libsyncml/sml_notification.h ============================================================================== --- trunk/libsyncml/sml_notification.h Mon Jul 13 18:16:09 2009 (r1204) +++ trunk/libsyncml/sml_notification.h Thu Jul 16 12:19:18 2009 (r1205) @@ -30,6 +30,13 @@ #ifndef _SML_NOTIFICATION_H_ #define _SML_NOTIFICATION_H_ +#include "sml_elements.h" +#include "sml_manager.h" +#include "sml_transport.h" + +typedef struct SmlNotification SmlNotification; +typedef struct SmlSanAlert SmlSanAlert; + typedef enum { SML_SAN_VERSION_UNKNOWN = 0, SML_SAN_VERSION_10 = 1, Modified: trunk/libsyncml/sml_notification_internals.h ============================================================================== --- trunk/libsyncml/sml_notification_internals.h Mon Jul 13 18:16:09 2009 (r1204) +++ trunk/libsyncml/sml_notification_internals.h Thu Jul 16 12:19:18 2009 (r1205) @@ -30,6 +30,8 @@ #ifndef _SML_NOTIFICATION_INTERNALS_H_ #define _SML_NOTIFICATION_INTERNALS_H_ +#include "sml_notification.h" + struct SmlNotification { SmlNotificationVersion version; SmlNotificationUIMode mode; Modified: trunk/libsyncml/sml_parse.c ============================================================================== --- trunk/libsyncml/sml_parse.c Mon Jul 13 18:16:09 2009 (r1204) +++ trunk/libsyncml/sml_parse.c Thu Jul 16 12:19:18 2009 (r1205) @@ -19,10 +19,10 @@ * */ -#include "syncml.h" +#include <config.h> -#include "syncml_internals.h" #include "sml_error_internals.h" +#include "sml_support.h" #include "sml_parse_internals.h" #include "sml_command_internals.h" #include "sml_elements_internals.h" @@ -573,11 +573,11 @@ * * This command tries to add the given command to the assembler without the * item data. Then it returns how big the item data could be without violating - * the limits. If there is not limit set, -1 is returned. This command only + * the limits. If there is not limit set, 0 is returned. This command only * makes sense for change commands */ gboolean smlAssemblerGetSpace (SmlAssembler *assm, - gsize *space, + gssize *space, SmlCommand *parent, SmlCommand *cmd, GError **error) @@ -592,7 +592,7 @@ smlAssert(cmd->type == SML_COMMAND_TYPE_ADD || cmd->type == SML_COMMAND_TYPE_REPLACE); unsigned int parentID = 0; - int limit = smlAssemblerGetRemoteMaxMsgSize(assm); + gsize limit = smlAssemblerGetRemoteMaxMsgSize(assm); if (!limit) { *space = -1; smlTrace(TRACE_EXIT, "%s: No limit", __func__); @@ -721,10 +721,10 @@ goto error; /* Lets see if the new buffer is small enough */ - int limit = smlAssemblerGetRemoteMaxMsgSize(assm); + gsize limit = smlAssemblerGetRemoteMaxMsgSize(assm); if (limit) { /* Now check the size */ - int size = 0; + gsize size = 0; if (!(size = smlAssemblerCheckSize(assm, FALSE, error))) goto error; @@ -904,10 +904,10 @@ if (!force) { /* Lets see if the new buffer is small enough */ - int limit = smlAssemblerGetRemoteMaxMsgSize(assm); + gsize limit = smlAssemblerGetRemoteMaxMsgSize(assm); if (limit) { /* Now check the size */ - int size = 0; + gsize size = 0; if (!(size = smlAssemblerCheckSize(assm, FALSE, error))) goto error; Modified: trunk/libsyncml/sml_parse.h ============================================================================== --- trunk/libsyncml/sml_parse.h Mon Jul 13 18:16:09 2009 (r1204) +++ trunk/libsyncml/sml_parse.h Thu Jul 16 12:19:18 2009 (r1205) @@ -22,6 +22,11 @@ #ifndef _SML_PARSE_H_ #define _SML_PARSE_H_ +typedef struct SmlParser SmlParser; +typedef struct SmlAssembler SmlAssembler; + +#include "sml_manager.h" + typedef enum { SML_PARSER_RESULT_ERROR = 0, SML_PARSER_RESULT_OPEN = 1, @@ -115,7 +120,7 @@ gsize smlAssemblerSetRemoteMaxMsgSize (SmlAssembler *assm, gsize limit); gsize smlAssemblerGetRemoteMaxMsgSize (SmlAssembler *assm); -gboolean smlAssemblerGetSpace (SmlAssembler *assm, gsize *space, SmlCommand *parent, SmlCommand *cmd, GError **error); +gboolean smlAssemblerGetSpace (SmlAssembler *assm, gssize *space, SmlCommand *parent, SmlCommand *cmd, GError **error); gsize smlAssemblerGetRemoteMaxObjSize (SmlAssembler *assm); gsize smlAssemblerSetRemoteMaxObjSize (SmlAssembler *assm, gsize limit); Modified: trunk/libsyncml/sml_parse_internals.h ============================================================================== --- trunk/libsyncml/sml_parse_internals.h Mon Jul 13 18:16:09 2009 (r1204) +++ trunk/libsyncml/sml_parse_internals.h Thu Jul 16 12:19:18 2009 (r1205) @@ -22,6 +22,8 @@ #ifndef _SML_PARSE_INTERNALS_H_ #define _SML_PARSE_INTERNALS_H_ +#include "sml_parse.h" + struct SmlParser { SmlParserFunctions functions; void *parser_userdata; Modified: trunk/libsyncml/sml_queue.c ============================================================================== --- trunk/libsyncml/sml_queue.c Mon Jul 13 18:16:09 2009 (r1204) +++ trunk/libsyncml/sml_queue.c Thu Jul 16 12:19:18 2009 (r1205) @@ -19,12 +19,14 @@ * */ -#include "syncml.h" -#include "syncml_internals.h" +#include "sml_support.h" #include "sml_queue_internals.h" #include "sml_error_internals.h" +#include <stdio.h> +#include <stdlib.h> + #ifndef DOXYGEN_SHOULD_SKIP_THIS static gboolean Modified: trunk/libsyncml/sml_queue_internals.h ============================================================================== --- trunk/libsyncml/sml_queue_internals.h Mon Jul 13 18:16:09 2009 (r1204) +++ trunk/libsyncml/sml_queue_internals.h Thu Jul 16 12:19:18 2009 (r1205) @@ -30,6 +30,8 @@ #ifndef _SML_QUEUE_INTERNALS_H_ #define _SML_QUEUE_INTERNALS_H_ +#include <glib.h> + typedef void (*SmlQueueHandler)(void *message, void *userdata); /*! @brief Represents a Queue which can be used to receive messages Modified: trunk/libsyncml/sml_session.c... [truncated message content] |