libsyncml 0.5.4

- Main Page
- Modules
- Data Structures
- Files

- File List

sml_session.h
1 /*
2 * libsyncml - A syncml protocol implementation
3 * Copyright (C) 2005 Armin Bauer <armin.bauer@opensync.org>
4 * Copyright (C) 2007-2008 Michael Bell <michael.bell@opensync.org>
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 *
20 */
21
22 #ifndef _SML_SESSION_H_
23 #define _SML_SESSION_H_
24
25 typedef enum SmlSessionType {
26 SML_SESSION_TYPE_SERVER,
27 SML_SESSION_TYPE_CLIENT
28 } SmlSessionType;
29
30 typedef enum SmlSessionEventType {
31 SML_SESSION_EVENT_ERROR,
32 SML_SESSION_EVENT_COMMAND_START,
33 SML_SESSION_EVENT_CHILD_COMMAND,
34 SML_SESSION_EVENT_HEADER_REPLY,
35 SML_SESSION_EVENT_FINAL,
36 SML_SESSION_EVENT_END,
37 SML_SESSION_EVENT_FLUSH,
38 SML_SESSION_EVENT_COMMAND_END,
39 SML_SESSION_EVENT_RESPONSE_URI,
40 SML_SESSION_EVENT_ESTABLISHED,
41 } SmlSessionEventType;
42
43 typedef void (* SmlSessionEventCallback) (SmlSession *session, SmlSessionEventType type, SmlCommand *command, SmlCommand *parent, SmlStatus *reply, SmlError *error, void *userdata);
44 typedef void (* SmlSessionDataCallback) (SmlSession *session, SmlTransportData *data, void *userdata);
45
46 /* Session Management */
47 SmlSession *smlSessionNew(SmlSessionType sessionType, SmlMimeType mimetype, SmlProtocolVersion version, SmlProtocolType protocol, SmlLocation *target, SmlLocation *source, const char *sessionID, unsigned int messageID, SmlError **error);
48 SmlSession *smlSessionRef(SmlSession *session);
49 void smlSessionUnref(SmlSession *session);
50 void smlSessionSetEventCallback(SmlSession *session, SmlSessionEventCallback callback, void *userdata);
51 void smlSessionSetDataCallback(SmlSession *session, SmlSessionDataCallback callback, void *userdata);
52
53 /* Session Control */
54 SmlBool smlSessionFlush(SmlSession *session, SmlBool final, SmlError **error);
55 SmlBool smlSessionEnd(SmlSession *session, SmlError **error);
56 void smlSessionUseStringTable(SmlSession *session, SmlBool useStringtable);
57 void smlSessionUseOnlyReplace(SmlSession *session, SmlBool onlyReplace);
58 void smlSessionUseNumberOfChanges(SmlSession *session, SmlBool support);
59 void smlSessionUseLargeObjects(SmlSession *session, SmlBool support);
60
61 void smlSessionSetRemoteMaxMsgSize(SmlSession *session, unsigned int size);
62 void smlSessionSetLocalMaxMsgSize(SmlSession *session, unsigned int size);
63 unsigned int smlSessionGetRemoteMaxMsgSize(SmlSession *session);
64 unsigned int smlSessionGetLocalMaxMsgSize(SmlSession *session);
65
66 void smlSessionSetLocalMaxObjSize(SmlSession *session, unsigned int limit);
67 void smlSessionSetRemoteMaxObjSize(SmlSession *session, unsigned int limit);
68 unsigned int smlSessionGetLocalMaxObjSize(SmlSession *session);
69 unsigned int smlSessionGetRemoteMaxObjSize(SmlSession *session);
70
71 const char *smlSessionGetSessionID(SmlSession *session);
72 void smlSessionSetSessionID(SmlSession *session, const char *sessionID);
73 SmlProtocolVersion smlSessionGetVersion(SmlSession *session);
74 void smlSessionDispatchEvent(SmlSession *session, SmlSessionEventType type, SmlCommand *cmd, SmlCommand *parent, SmlStatus *headerreply, SmlError *error);
75 SmlLocation *smlSessionGetSource(SmlSession *session);
76 SmlLocation *smlSessionGetTarget(SmlSession *session);
77 /* This function MUST NOT be used for servers.
78 * This function is only used to set the credentials for a client.
79 */
80 void smlSessionRegisterCred(SmlSession *session, SmlCred *cred);
81
82 /* Session Data input */
83 SmlBool smlSessionReceiveHeader(SmlSession *session, SmlHeader *header, SmlError **error);
84 SmlBool smlSessionReceiveBody(SmlSession *session, SmlParser *parser, SmlError **error);
85
86 /* Session Command input */
87 SmlBool smlSessionSendCommand(SmlSession *session, SmlCommand *cmd, SmlCommand *parent, SmlStatusReplyCb callback, void *userdata, SmlError **error);
88 SmlBool smlSessionStartCommand(SmlSession *session, SmlCommand *cmd, SmlCommand *parent, SmlStatusReplyCb callback, void *userdata, SmlError **error);
89 SmlBool smlSessionEndCommand(SmlSession *session, SmlCommand *parent, SmlError **error);
90 SmlBool smlSessionSendReply(SmlSession *session, SmlStatus *status, SmlError **error);
91
92 SmlBool smlSessionCheck(SmlSession *session);
93 void smlSessionDispatch(SmlSession *session);
94
95 /* expire date: 20090120 */
96 void smlSessionSetSendingLimit(SmlSession *session, unsigned int limit) LIBSYNCML_DEPRECATED;
97 void smlSessionSetReceivingLimit(SmlSession *session, unsigned int limit) LIBSYNCML_DEPRECATED;
98 unsigned int smlSessionGetSendingLimit(SmlSession *session) LIBSYNCML_DEPRECATED;
99
100 /* expire date: 20090626 */
101 void smlSessionSetSendingMaxMsgSize(SmlSession *session, unsigned int size) LIBSYNCML_DEPRECATED;
102 void smlSessionSetReceivingMaxMsgSize(SmlSession *session, unsigned int size) LIBSYNCML_DEPRECATED;
103 unsigned int smlSessionGetSendingMaxMsgSize(SmlSession *session) LIBSYNCML_DEPRECATED;
104
105 /* expire date: 20090626 */
106 void smlSessionSetSendingMaxObjSize(SmlSession *session, int limit) LIBSYNCML_DEPRECATED;
107 void smlSessionSetRequestedMaxObjSize(SmlSession *session, int limit) LIBSYNCML_DEPRECATED;
108 int smlSessionGetSendingMaxObjSize(SmlSession *session) LIBSYNCML_DEPRECATED;
109 void smlSessionSetReceivingMaxObjSize(SmlSession *session, unsigned int limit) LIBSYNCML_DEPRECATED;
110 unsigned int smlSessionGetReceivingMaxObjSize(SmlSession *session) LIBSYNCML_DEPRECATED;
111
112 #endif //_SML_SESSION_H_