Main Page | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

mw_session.h

Go to the documentation of this file.
00001 
00002 /*
00003   Meanwhile - Unofficial Lotus Sametime Community Client Library
00004   Copyright (C) 2004  Christopher (siege) O'Brien
00005   
00006   This library is free software; you can redistribute it and/or
00007   modify it under the terms of the GNU Library General Public
00008   License as published by the Free Software Foundation; either
00009   version 2 of the License, or (at your option) any later version.
00010   
00011   This library is distributed in the hope that it will be useful,
00012   but WITHOUT ANY WARRANTY; without even the implied warranty of
00013   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014   Library General Public License for more details.
00015   
00016   You should have received a copy of the GNU Library General Public
00017   License along with this library; if not, write to the Free
00018   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019 */
00020 
00021 #ifndef _MW_SESSION_H
00022 #define _MW_SESSION_H
00023 
00024 
00047 #include "mw_common.h"
00048 
00049 
00050 struct mwChannelSet;
00051 struct mwCipher;
00052 struct mwMessage;
00053 struct mwService;
00054 
00055 
00057 #define MW_PROTOCOL_VERSION_MAJOR  0x001e
00058 
00059 
00061 #define MW_PROTOCOL_VERSION_MINOR  0x001d
00062 
00063 
00068 
00070 #define mwSession_AUTH_USER_ID      "session.auth.user"
00071 
00073 #define mwSession_AUTH_PASSWORD     "session.auth.password"
00074 
00076 #define mwSession_AUTH_TOKEN        "session.auth.token"
00077 
00079 #define mwSession_CLIENT_HOST       "client.host"
00080 
00082 #define mwSession_CLIENT_IP         "client.ip"
00083 
00085 #define mwSession_CLIENT_VER_MAJOR  "client.version.major"
00086 
00088 #define mwSession_CLIENT_VER_MINOR  "client.version.minor"
00089 
00091 #define mwSession_CLIENT_TYPE_ID    "client.id"
00092 
00094 #define mwSession_SERVER_VER_MAJOR  "server.version.major"
00095 
00097 #define mwSession_SERVER_VER_MINOR  "server.version.minor"
00098 
00102 enum mwSessionState {
00103   mwSession_STARTING,      
00104   mwSession_HANDSHAKE,     
00105   mwSession_HANDSHAKE_ACK, 
00106   mwSession_LOGIN,         
00107   mwSession_LOGIN_REDIR,   
00108   mwSession_LOGIN_ACK,     
00109   mwSession_STARTED,       
00110   mwSession_STOPPING,      
00111   mwSession_STOPPED,       
00112   mwSession_UNKNOWN,       
00113   mwSession_LOGIN_CONT,    
00114 };
00115 
00116 
00117 #define mwSession_isState(session, state) \
00118   (mwSession_getState((session)) == (state))
00119 
00120 #define mwSession_isStarting(s) \
00121   (mwSession_isState((s), mwSession_STARTING)  || \
00122    mwSession_isState((s), mwSession_HANDSHAKE) || \
00123    mwSession_isState((s), mwSession_HANDSHAKE_ACK) || \
00124    mwSession_isState((s), mwSession_LOGIN) || \
00125    mwSession_isState((s), mwSession_LOGIN_ACK) || \
00126    mwSession_isState((s), mwSession_LOGIN_REDIR) || \
00127    mwSession_isState((s), mwSession_LOGIN_CONT))
00128 
00129 #define mwSession_isStarted(s) \
00130   (mwSession_isState((s), mwSession_STARTED))
00131 
00132 #define mwSession_isStopping(s) \
00133   (mwSession_isState((s), mwSession_STOPPING))
00134 
00135 #define mwSession_isStopped(s) \
00136   (mwSession_isState((s), mwSession_STOPPED))
00137 
00138 
00142 struct mwSession;
00143 
00144 
00149 struct mwSessionHandler {
00150   
00153   int (*io_write)(struct mwSession *, const char *buf, gsize len);
00154   
00156   void (*io_close)(struct mwSession *);
00157 
00159   void (*clear)(struct mwSession *);
00160 
00168   void (*on_stateChange)(struct mwSession *s,
00169                          enum mwSessionState state, gpointer info);
00170 
00175   void (*on_setPrivacyInfo)(struct mwSession *);
00176 
00180   void (*on_setUserStatus)(struct mwSession *);
00181 
00183   void (*on_admin)(struct mwSession *, const char *text);
00184 
00186   void (*on_announce)(struct mwSession *, struct mwLoginInfo *from,
00187                       gboolean may_reply, const char *text);
00188 
00189 };
00190 
00191 
00193 struct mwSession *mwSession_new(struct mwSessionHandler *);
00194 
00195 
00198 void mwSession_free(struct mwSession *);
00199 
00200 
00202 struct mwSessionHandler *mwSession_getHandler(struct mwSession *);
00203 
00204 
00207 void mwSession_start(struct mwSession *);
00208 
00209 
00212 void mwSession_stop(struct mwSession *, guint32 reason);
00213 
00214 
00217 void mwSession_recv(struct mwSession *, const char *, gsize);
00218 
00219 
00224 int mwSession_send(struct mwSession *s, struct mwMessage *msg);
00225 
00226 
00228 int mwSession_sendKeepalive(struct mwSession *s);
00229 
00230 
00233 int mwSession_forceLogin(struct mwSession *s);
00234 
00235 
00246 int mwSession_sendAnnounce(struct mwSession *s, gboolean may_reply,
00247                            const char *text, const GList *recipients);
00248 
00249 
00252 int mwSession_setPrivacyInfo(struct mwSession *, struct mwPrivacyInfo *);
00253 
00254 
00256 struct mwPrivacyInfo *mwSession_getPrivacyInfo(struct mwSession *);
00257 
00258 
00260 struct mwLoginInfo *mwSession_getLoginInfo(struct mwSession *);
00261 
00262 
00265 int mwSession_setUserStatus(struct mwSession *, struct mwUserStatus *);
00266 
00267 
00268 struct mwUserStatus *mwSession_getUserStatus(struct mwSession *);
00269 
00270 
00272 enum mwSessionState mwSession_getState(struct mwSession *);
00273 
00274 
00287 gpointer mwSession_getStateInfo(struct mwSession *);
00288 
00289 
00290 struct mwChannelSet *mwSession_getChannels(struct mwSession *);
00291 
00292 
00300 gboolean mwSession_addService(struct mwSession *, struct mwService *);
00301 
00302 
00304 struct mwService *mwSession_getService(struct mwSession *, guint32 type);
00305 
00306 
00310 struct mwService *mwSession_removeService(struct mwSession *, guint32 type);
00311 
00312 
00315 GList *mwSession_getServices(struct mwSession *);
00316 
00317 
00330 void mwSession_senseService(struct mwSession *s, guint32 type);
00331 
00332 
00334 gboolean mwSession_addCipher(struct mwSession *, struct mwCipher *);
00335 
00336 
00338 struct mwCipher *mwSession_getCipher(struct mwSession *, guint16 type);
00339 
00340 
00342 struct mwCipher *mwSession_removeCipher(struct mwSession *, guint16 type);
00343 
00344 
00347 GList *mwSession_getCiphers(struct mwSession *);
00348 
00349 
00353 void mwSession_setProperty(struct mwSession *, const char *key,
00354                            gpointer val, GDestroyNotify clear);
00355 
00356 
00358 gpointer mwSession_getProperty(struct mwSession *, const char *key);
00359 
00360 
00363 void mwSession_removeProperty(struct mwSession *, const char *key);
00364 
00365 
00374 void mwSession_setClientData(struct mwSession *session,
00375                              gpointer data, GDestroyNotify clear);
00376 
00377 
00378 gpointer mwSession_getClientData(struct mwSession *session);
00379 
00380 
00383 void mwSession_removeClientData(struct mwSession *session);
00384 
00385 
00386 #endif
00387 

Generated on Sun Nov 27 16:49:56 2005 for meanwhile by  doxygen 1.3.9.1