mw_session.h
Go to the documentation of this file.
/*
Meanwhile - Unofficial Lotus Sametime Community Client Library
Copyright (C) 2004 Christopher (siege) O'Brien
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef _MW_SESSION_H
#define _MW_SESSION_H
#include "mw_common.h"
#ifdef __cplusplus
extern "C" {
#endif
struct mwChannelSet;
struct mwCipher;
struct mwMessage;
struct mwService;
#define MW_PROTOCOL_VERSION_MAJOR 0x001e
#define MW_PROTOCOL_VERSION_MINOR 0x001d
#define mwSession_AUTH_USER_ID "session.auth.user"
#define mwSession_AUTH_PASSWORD "session.auth.password"
#define mwSession_AUTH_TOKEN "session.auth.token"
#define mwSession_CLIENT_HOST "client.host"
#define mwSession_CLIENT_IP "client.ip"
#define mwSession_CLIENT_VER_MAJOR "client.version.major"
#define mwSession_CLIENT_VER_MINOR "client.version.minor"
#define mwSession_CLIENT_TYPE_ID "client.id"
#define mwSession_SERVER_VER_MAJOR "server.version.major"
#define mwSession_SERVER_VER_MINOR "server.version.minor"
enum mwSessionState {
mwSession_STARTING,
mwSession_HANDSHAKE,
mwSession_HANDSHAKE_ACK,
mwSession_LOGIN,
mwSession_LOGIN_REDIR,
mwSession_LOGIN_ACK,
mwSession_STARTED,
mwSession_STOPPING,
mwSession_STOPPED,
mwSession_UNKNOWN,
mwSession_LOGIN_CONT,
};
#define mwSession_isState(session, state) \
(mwSession_getState((session)) == (state))
#define mwSession_isStarting(s) \
(mwSession_isState((s), mwSession_STARTING) || \
mwSession_isState((s), mwSession_HANDSHAKE) || \
mwSession_isState((s), mwSession_HANDSHAKE_ACK) || \
mwSession_isState((s), mwSession_LOGIN) || \
mwSession_isState((s), mwSession_LOGIN_ACK) || \
mwSession_isState((s), mwSession_LOGIN_REDIR) || \
mwSession_isState((s), mwSession_LOGIN_CONT))
#define mwSession_isStarted(s) \
(mwSession_isState((s), mwSession_STARTED))
#define mwSession_isStopping(s) \
(mwSession_isState((s), mwSession_STOPPING))
#define mwSession_isStopped(s) \
(mwSession_isState((s), mwSession_STOPPED))
struct mwSession;
struct mwSessionHandler {
int (*io_write)(struct mwSession *, const guchar *buf, gsize len);
void (*io_close)(struct mwSession *);
void (*clear)(struct mwSession *);
void (*on_stateChange)(struct mwSession *s,
enum mwSessionState state, gpointer info);
void (*on_setPrivacyInfo)(struct mwSession *);
void (*on_setUserStatus)(struct mwSession *);
void (*on_admin)(struct mwSession *, const char *text);
void (*on_announce)(struct mwSession *, struct mwLoginInfo *from,
gboolean may_reply, const char *text);
};
struct mwSession *mwSession_new(struct mwSessionHandler *);
void mwSession_free(struct mwSession *);
struct mwSessionHandler *mwSession_getHandler(struct mwSession *);
void mwSession_start(struct mwSession *);
void mwSession_stop(struct mwSession *, guint32 reason);
void mwSession_recv(struct mwSession *, const guchar *, gsize);
int mwSession_send(struct mwSession *s, struct mwMessage *msg);
int mwSession_sendKeepalive(struct mwSession *s);
int mwSession_forceLogin(struct mwSession *s);
int mwSession_sendAnnounce(struct mwSession *s, gboolean may_reply,
const char *text, const GList *recipients);
int mwSession_setPrivacyInfo(struct mwSession *, struct mwPrivacyInfo *);
struct mwPrivacyInfo *mwSession_getPrivacyInfo(struct mwSession *);
struct mwLoginInfo *mwSession_getLoginInfo(struct mwSession *);
int mwSession_setUserStatus(struct mwSession *, struct mwUserStatus *);
struct mwUserStatus *mwSession_getUserStatus(struct mwSession *);
enum mwSessionState mwSession_getState(struct mwSession *);
gpointer mwSession_getStateInfo(struct mwSession *);
struct mwChannelSet *mwSession_getChannels(struct mwSession *);
gboolean mwSession_addService(struct mwSession *, struct mwService *);
struct mwService *mwSession_getService(struct mwSession *, guint32 type);
struct mwService *mwSession_removeService(struct mwSession *, guint32 type);
GList *mwSession_getServices(struct mwSession *);
void mwSession_senseService(struct mwSession *s, guint32 type);
gboolean mwSession_addCipher(struct mwSession *, struct mwCipher *);
struct mwCipher *mwSession_getCipher(struct mwSession *, guint16 type);
struct mwCipher *mwSession_removeCipher(struct mwSession *, guint16 type);
GList *mwSession_getCiphers(struct mwSession *);
void mwSession_setProperty(struct mwSession *, const char *key,
gpointer val, GDestroyNotify clear);
gpointer mwSession_getProperty(struct mwSession *, const char *key);
void mwSession_removeProperty(struct mwSession *, const char *key);
void mwSession_setClientData(struct mwSession *session,
gpointer data, GDestroyNotify clear);
gpointer mwSession_getClientData(struct mwSession *session);
void mwSession_removeClientData(struct mwSession *session);
#ifdef __cplusplus
}
#endif
#endif /* _MW_SESSION_H */
mw_common.h
Common data types and functions for handling those types.
mwSession_getHandler
struct mwSessionHandler * mwSession_getHandler(struct mwSession *)
obtain a reference to the session's handler
mwSession_forceLogin
int mwSession_forceLogin(struct mwSession *s)
respond to a login redirect message by forcing the login sequence to continue through the immediate s...
mwSession_free
void mwSession_free(struct mwSession *)
stop, clear, free a session.
mwSession_start
void mwSession_start(struct mwSession *)
instruct the session to begin.
mwSession_getClientData
gpointer mwSession_getClientData(struct mwSession *session)
mwSession_removeCipher
struct mwCipher * mwSession_removeCipher(struct mwSession *, guint16 type)
remove a cipher from the session
mwSession_getCiphers
GList * mwSession_getCiphers(struct mwSession *)
a GList of ciphers in this session.
mwSession_new
struct mwSession * mwSession_new(struct mwSessionHandler *)
allocate a new session
mwSession_getStateInfo
gpointer mwSession_getStateInfo(struct mwSession *)
additional status-specific information.
mwSession_send
int mwSession_send(struct mwSession *s, struct mwMessage *msg)
primarily used by services to have messages serialized and sent
mwSession_recv
void mwSession_recv(struct mwSession *, const guchar *, gsize)
Data is buffered, unpacked, and parsed into a message, then processed accordingly.
mwSession_setUserStatus
int mwSession_setUserStatus(struct mwSession *, struct mwUserStatus *)
set the internal user status state, and inform the server as necessary.
mwSession_sendKeepalive
int mwSession_sendKeepalive(struct mwSession *s)
sends the keepalive byte
mwSession_senseService
void mwSession_senseService(struct mwSession *s, guint32 type)
instruct a STARTED session to check the server for the presense of a given service.
mwSession_getService
struct mwService * mwSession_getService(struct mwSession *, guint32 type)
find a service by its type identifier
mwSession_addCipher
gboolean mwSession_addCipher(struct mwSession *, struct mwCipher *)
adds a cipher to the session.
mwSession_sendAnnounce
int mwSession_sendAnnounce(struct mwSession *s, gboolean may_reply, const char *text, const GList *recipients)
send an announcement to a list of users/groups.
mwSession_getLoginInfo
struct mwLoginInfo * mwSession_getLoginInfo(struct mwSession *)
reference the login information for the session
mwSession_getUserStatus
struct mwUserStatus * mwSession_getUserStatus(struct mwSession *)
mwSession_addService
gboolean mwSession_addService(struct mwSession *, struct mwService *)
adds a service to the session.
mwSession_getState
enum mwSessionState mwSession_getState(struct mwSession *)
current status of the session
mwSession_stop
void mwSession_stop(struct mwSession *, guint32 reason)
instruct the session to shut down with the following reason code.
mwSession_getProperty
gpointer mwSession_getProperty(struct mwSession *, const char *key)
obtain the value of a previously set property, or NULL
mwSession_removeProperty
void mwSession_removeProperty(struct mwSession *, const char *key)
remove a property, calling the optional GDestroyNotify function indicated in mwSession_setProperty if...
mwSession_setClientData
void mwSession_setClientData(struct mwSession *session, gpointer data, GDestroyNotify clear)
associate arbitrary data with the session for use by the client code.
mwSession_getPrivacyInfo
struct mwPrivacyInfo * mwSession_getPrivacyInfo(struct mwSession *)
direct reference to the session's internal privacy structure
mwSession_setProperty
void mwSession_setProperty(struct mwSession *, const char *key, gpointer val, GDestroyNotify clear)
associate a key:value pair with the session.
mwSession_getChannels
struct mwChannelSet * mwSession_getChannels(struct mwSession *)
mwSession_getCipher
struct mwCipher * mwSession_getCipher(struct mwSession *, guint16 type)
find a cipher by its type identifier
mwSession_getServices
GList * mwSession_getServices(struct mwSession *)
a GList of services in this session.
mwSession_setPrivacyInfo
int mwSession_setPrivacyInfo(struct mwSession *, struct mwPrivacyInfo *)
set the internal privacy information, and inform the server as necessary.
mwSessionState
mwSessionState
Definition mw_session.h:107
mwSession_LOGIN_ACK
@ mwSession_LOGIN_ACK
session has received login ack
Definition mw_session.h:113
mwSession_HANDSHAKE
@ mwSession_HANDSHAKE
session has sent handshake
Definition mw_session.h:109
mwSession_LOGIN_CONT
@ mwSession_LOGIN_CONT
session has sent a login continue
Definition mw_session.h:118
mwSession_STARTED
@ mwSession_STARTED
session is active
Definition mw_session.h:114
mwSession_STOPPED
@ mwSession_STOPPED
session is stopped
Definition mw_session.h:116
mwSession_LOGIN_REDIR
@ mwSession_LOGIN_REDIR
session has been redirected
Definition mw_session.h:112
mwSession_STARTING
@ mwSession_STARTING
session is starting
Definition mw_session.h:108
mwSession_HANDSHAKE_ACK
@ mwSession_HANDSHAKE_ACK
session has received handshake ack
Definition mw_session.h:110
mwSession_STOPPING
@ mwSession_STOPPING
session is shutting down
Definition mw_session.h:115
mwSession_UNKNOWN
@ mwSession_UNKNOWN
indicates an error determining state
Definition mw_session.h:117
mwSession_LOGIN
@ mwSession_LOGIN
session has sent login
Definition mw_session.h:111
mwSession_removeClientData
void mwSession_removeClientData(struct mwSession *session)
remove client data, calling the optional GDestroyNotify function indicated in mwSession_setClientData...
mwSession_removeService
struct mwService * mwSession_removeService(struct mwSession *, guint32 type)
removes a service from the session.
mwChannelSet
Collection of channels.
mwCipher
A cipher.
Definition mw_cipher.h:70
mwCipher::type
guint16 type
Definition mw_cipher.h:76
mwCipher::clear
void(* clear)(struct mwCipher *c)
prepare this cipher for being free'd
Definition mw_cipher.h:94
mwCipher::session
struct mwSession * session
service this cipher is providing for
Definition mw_cipher.h:74
mwLoginInfo
Definition mw_common.h:123
mwMessage
Definition mw_message.h:72
mwPrivacyInfo
Definition mw_common.h:146
mwService
A service is the recipient of sendOnCnl messages sent over channels marked with the corresponding ser...
Definition mw_service.h:123
mwService::type
guint32 type
the unique identifier by which this service is registered.
Definition mw_service.h:128
mwSessionHandler
session handler.
Definition mw_session.h:154
mwSessionHandler::on_stateChange
void(* on_stateChange)(struct mwSession *s, enum mwSessionState state, gpointer info)
Called when the session has changed status.
Definition mw_session.h:173
mwSessionHandler::io_close
void(* io_close)(struct mwSession *)
close the server connection.
Definition mw_session.h:161
mwSessionHandler::io_write
int(* io_write)(struct mwSession *, const guchar *buf, gsize len)
write data to the server connection.
Definition mw_session.h:158
mwSessionHandler::clear
void(* clear)(struct mwSession *)
triggered by mwSession_free.
Definition mw_session.h:164
mwSessionHandler::on_setUserStatus
void(* on_setUserStatus)(struct mwSession *)
called when user status has changed
Definition mw_session.h:185
mwSessionHandler::on_setPrivacyInfo
void(* on_setPrivacyInfo)(struct mwSession *)
called when privacy information has been sent or received
Definition mw_session.h:180
mwSessionHandler::on_announce
void(* on_announce)(struct mwSession *, struct mwLoginInfo *from, gboolean may_reply, const char *text)
called when an announcement arrives
Definition mw_session.h:191
mwSessionHandler::on_admin
void(* on_admin)(struct mwSession *, const char *text)
called when an admin messages has been received
Definition mw_session.h:188
mwSession
Represents a Sametime client session.
mwUserStatus
Definition mw_common.h:169