sml_transport_internals.h
/*
* libsyncml - A syncml protocol implementation
* Copyright (C) 2005 Armin Bauer <armin.bauer@opensync.org>
* Copyright (C) 2007-2008 Michael Bell <michael.bell@opensync.org>
*
* 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
*
*/
#ifndef _SML_TRANSPORT_INTERNALS_H_
#define _SML_TRANSPORT_INTERNALS_H_
#include "sml_queue_internals.h"
typedef SmlBool (* SmlTransportSetConfigOptionFn) (SmlTransport *tsp, const char *name, const char *value, SmlError **error);
typedef SmlBool (* SmlTransportSetConnectionTypeFn) (SmlTransport *tsp, SmlTransportConnectionType type, SmlError **error);
typedef SmlBool (* SmlTransportInitializeFn) (SmlTransport *tsp, SmlError **error);
/* This function is used for transport clients
* to support redirects from the server.
* Example: Funambol works with such redirects
* because of Tomcat's session management.
*/
typedef SmlBool (* SmlTransportSetResponseUriFn) (SmlTransport *tsp, const char *uri, SmlError **error);
/* This function is used to add some kind of session id
* to the URL of the server. This is necessary to
* avoid session hijacking.
*/
typedef char * (* SmlTransportGetResponseUriFn) (SmlLink *link, SmlSession *session, SmlError **error);
typedef SmlBool (* SmlTransportFinalizeFn) (void *data, SmlError **error);
typedef void (* SmlTransportConnectFn) (void *data);
typedef void (* SmlTransportDisconnectFn) (void *data, void *link_data);
typedef void (* SmlTransportSendFn) (void *userdata, void *link_data, SmlTransportData *data, SmlError *error);
typedef struct SmlTransportFunctions {
SmlTransportSetConfigOptionFn set_config_option;
SmlTransportSetConnectionTypeFn set_connection_type;
SmlTransportInitializeFn initialize;
SmlTransportSetResponseUriFn set_response_uri;
SmlTransportGetResponseUriFn get_response_uri;
SmlTransportFinalizeFn finalize;
SmlTransportConnectFn connect;
SmlTransportDisconnectFn disconnect;
SmlTransportSendFn send;
} SmlTransportFunctions;
typedef enum SmlTransportState {
SML_TRANSPORT_UNINITIALIZED,
SML_TRANSPORT_INITIALIZED,
SML_TRANSPORT_CONNECTED,
SML_TRANSPORT_ERROR
} SmlTransportState;
struct SmlTransport {
GMainContext *context;
SmlThread *thread;
SmlTransportState state;
SmlTransportType type;
SmlTransportFunctions functions;
void *transport_data;
SmlQueue *command_queue;
SmlTransportEventCb event_callback;
void *event_callback_userdata;
gint event_callback_ref_count;
SmlError *cached_error;
SmlBool connected;
GHashTable *links;
GMutex *links_mutex;
unsigned int connections;
GMutex *connections_mutex;
};
struct SmlLink {
SmlTransport *tsp;
void *link_data;
gint32 refCount;
};
typedef enum SmlTransportCommandType {
SML_TRANSPORT_CMD_SEND,
SML_TRANSPORT_CMD_CONNECT,
SML_TRANSPORT_CMD_DISCONNECT
} SmlTransportCommandType;
typedef struct SmlTransportCommand {
SmlTransportCommandType type;
SmlTransportData *data;
const void *config;
SmlLink *link;
SmlError *error;
} SmlTransportCommand;
struct SmlTransportData {
char *data;
unsigned long size;
SmlMimeType type;
SmlBool ownsData;
gint32 refCount;
SmlBool needsAnswer;
SmlMimeType type_get;
};
void smlTransportWorkerHandler(void *message, void *userdata);
SmlBool smlTransportReceiveEvent(SmlTransport *tsp, SmlLink *link, SmlTransportEventType type, SmlTransportData *data, SmlError *error);
SmlBool smlTransportSetResponseURI(SmlTransport *tsp, const char *uri, SmlError **error);
char *smlTransportGetResponseURI(SmlLink *link, SmlSession *session, SmlError **error);
#endif //_SML_TRANSPORT_INTERNALS_H_
SmlTransportData::needsAnswer
SmlBool needsAnswer
Definition: sml_transport_internals.h:121
SmlTransportCommand
Definition: sml_transport_internals.h:104
SmlTransport
Definition: sml_transport_internals.h:69
SmlTransportFunctions
Definition: sml_transport_internals.h:50
smlTransportSetResponseURI
SmlBool smlTransportSetResponseURI(SmlTransport *tsp, const char *uri, SmlError **error)
Sets the response URI after initialization.
Definition: sml_transport.c:1041
SmlTransportData
Definition: sml_transport_internals.h:112
SmlSession
Definition: sml_session_internals.h:27
SmlLink
Definition: sml_transport_internals.h:92
SmlQueue
Represents a Queue which can be used to receive messages.
Definition: sml_queue_internals.h:36
SmlTransportData::type_get
SmlMimeType type_get
Definition: sml_transport_internals.h:132
SmlThread
Definition: sml_support.h:52
SmlError
Represent an error.
Definition: sml_error_internals.h:29