mw_service.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_SERVICE_H
#define _MW_SERVICE_H
#include "mw_common.h"
#ifdef __cplusplus
extern "C" {
#endif
/* place-holders */
struct mwChannel;
struct mwService;
struct mwSession;
struct mwMsgChannelCreate;
struct mwMsgChannelAccept;
struct mwMsgChannelDestroy;
enum mwServiceState {
mwServiceState_STOPPED,
mwServiceState_STOPPING,
mwServiceState_STARTED,
mwServiceState_STARTING,
mwServiceState_ERROR,
mwServiceState_UNKNOWN,
};
#define MW_SERVICE(srv) ((struct mwService *) srv)
#define MW_SERVICE_IS_STATE(srvc, state) \
(mwService_getState(MW_SERVICE(srvc)) == (state))
#define MW_SERVICE_IS_STOPPED(srvc) \
MW_SERVICE_IS_STATE(srvc, mwServiceState_STOPPED)
#define MW_SERVICE_IS_STOPPING(srvc) \
MW_SERVICE_IS_STATE(srvc, mwServiceState_STOPPING)
#define MW_SERVICE_IS_STARTED(srvc) \
MW_SERVICE_IS_STATE(srvc, mwServiceState_STARTED)
#define MW_SERVICE_IS_STARTING(srvc) \
MW_SERVICE_IS_STATE(srvc, mwServiceState_STARTING)
#define MW_SERVICE_IS_LIVE(srvc) \
(MW_SERVICE_IS_STARTING(srvc) || MW_SERVICE_IS_STARTED(srvc))
#define MW_SERVICE_IS_DEAD(srvc) \
(MW_SERVICE_IS_STOPPING(srvc) || MW_SERVICE_IS_STOPPED(srvc))
typedef void (*mwService_funcStart)(struct mwService *service);
typedef void (*mwService_funcStop)(struct mwService *service);
typedef void (*mwService_funcClear)(struct mwService *service);
typedef const char *(*mwService_funcGetName)(struct mwService *service);
typedef const char *(*mwService_funcGetDesc)(struct mwService *service);
typedef void (*mwService_funcRecvCreate)
(struct mwService *service,
struct mwChannel *channel,
struct mwMsgChannelCreate *msg);
typedef void (*mwService_funcRecvAccept)
(struct mwService *service,
struct mwChannel *channel,
struct mwMsgChannelAccept *msg);
typedef void (*mwService_funcRecvDestroy)
(struct mwService *service,
struct mwChannel *channel,
struct mwMsgChannelDestroy *msg);
typedef void (*mwService_funcRecv)
(struct mwService *service,
struct mwChannel *channel,
guint16 msg_type,
struct mwOpaque *data);
struct mwService {
guint32 type;
enum mwServiceState state;
struct mwSession *session;
mwService_funcGetName get_name;
mwService_funcGetDesc get_desc;
mwService_funcRecvCreate recv_create;
mwService_funcRecvAccept recv_accept;
mwService_funcRecvDestroy recv_destroy;
mwService_funcRecv recv;
mwService_funcStart start;
mwService_funcStop stop;
mwService_funcClear clear;
gpointer client_data;
GDestroyNotify client_cleanup;
};
void mwService_init(struct mwService *service,
struct mwSession *session,
guint32 service_type);
void mwService_started(struct mwService *service);
void mwService_stopped(struct mwService *service);
void mwService_recvCreate(struct mwService *service,
struct mwChannel *channel,
struct mwMsgChannelCreate *msg);
void mwService_recvAccept(struct mwService *service,
struct mwChannel *channel,
struct mwMsgChannelAccept *msg);
void mwService_recvDestroy(struct mwService *service,
struct mwChannel *channel,
struct mwMsgChannelDestroy *msg);
void mwService_recv(struct mwService *service,
struct mwChannel *channel,
guint16 msg_type,
struct mwOpaque *data);
guint32 mwService_getType(struct mwService *);
const char *mwService_getName(struct mwService *);
const char *mwService_getDesc(struct mwService *);
struct mwSession *mwService_getSession(struct mwService *service);
enum mwServiceState mwService_getState(struct mwService *service);
void mwService_start(struct mwService *service);
void mwService_stop(struct mwService *service);
void mwService_free(struct mwService *service);
void mwService_setClientData(struct mwService *service,
gpointer data, GDestroyNotify cleanup);
gpointer mwService_getClientData(struct mwService *service);
void mwService_removeClientData(struct mwService *service);
#ifdef __cplusplus
}
#endif
#endif /* _MW_SERVICE_H */
mw_common.h
Common data types and functions for handling those types.
mwService_funcClear
void(* mwService_funcClear)(struct mwService *service)
Definition mw_service.h:86
mwService_removeClientData
void mwService_removeClientData(struct mwService *service)
Removes client data from service.
mwService_funcStart
void(* mwService_funcStart)(struct mwService *service)
Definition mw_service.h:82
mwService_start
void mwService_start(struct mwService *service)
Triggers the start handler for the service.
mwService_funcGetDesc
const char *(* mwService_funcGetDesc)(struct mwService *service)
Definition mw_service.h:90
mwService_funcStop
void(* mwService_funcStop)(struct mwService *service)
Definition mw_service.h:84
mwService_funcRecv
void(* mwService_funcRecv)(struct mwService *service, struct mwChannel *channel, guint16 msg_type, struct mwOpaque *data)
Definition mw_service.h:111
mwService_funcRecvAccept
void(* mwService_funcRecvAccept)(struct mwService *service, struct mwChannel *channel, struct mwMsgChannelAccept *msg)
Definition mw_service.h:100
mwService_setClientData
void mwService_setClientData(struct mwService *service, gpointer data, GDestroyNotify cleanup)
Associates client data with service.
mwServiceState
mwServiceState
State-tracking for a service.
Definition mw_service.h:43
mwServiceState_STOPPING
@ mwServiceState_STOPPING
the service is shutting down
Definition mw_service.h:45
mwServiceState_STOPPED
@ mwServiceState_STOPPED
the service is not active
Definition mw_service.h:44
mwServiceState_STARTING
@ mwServiceState_STARTING
the service is starting up
Definition mw_service.h:47
mwServiceState_ERROR
@ mwServiceState_ERROR
error in service, shutting down
Definition mw_service.h:48
mwServiceState_STARTED
@ mwServiceState_STARTED
the service is active
Definition mw_service.h:46
mwServiceState_UNKNOWN
@ mwServiceState_UNKNOWN
error determining state
Definition mw_service.h:49
mwService_getState
enum mwServiceState mwService_getState(struct mwService *service)
mwService_recvCreate
void mwService_recvCreate(struct mwService *service, struct mwChannel *channel, struct mwMsgChannelCreate *msg)
Triggers the recv_create handler on the service.
mwService_getType
guint32 mwService_getType(struct mwService *)
mwService_getClientData
gpointer mwService_getClientData(struct mwService *service)
Reference associated client data.
mwService_init
void mwService_init(struct mwService *service, struct mwSession *session, guint32 service_type)
Prepares a newly allocated service for use.
mwService_getDesc
const char * mwService_getDesc(struct mwService *)
mwService_getSession
struct mwSession * mwService_getSession(struct mwService *service)
mwService_recvDestroy
void mwService_recvDestroy(struct mwService *service, struct mwChannel *channel, struct mwMsgChannelDestroy *msg)
Triggers the recv_destroy handler on the service.
mwService_funcRecvDestroy
void(* mwService_funcRecvDestroy)(struct mwService *service, struct mwChannel *channel, struct mwMsgChannelDestroy *msg)
Definition mw_service.h:106
mwService_stopped
void mwService_stopped(struct mwService *service)
Indicate that a service is stopped.
mwService_funcGetName
const char *(* mwService_funcGetName)(struct mwService *service)
Definition mw_service.h:88
mwService_free
void mwService_free(struct mwService *service)
Frees memory used by a service.
mwService_recvAccept
void mwService_recvAccept(struct mwService *service, struct mwChannel *channel, struct mwMsgChannelAccept *msg)
Triggers the recv_accept handler on the service.
mwService_getName
const char * mwService_getName(struct mwService *)
mwService_recv
void mwService_recv(struct mwService *service, struct mwChannel *channel, guint16 msg_type, struct mwOpaque *data)
Triggers the input handler on the service.
mwService_funcRecvCreate
void(* mwService_funcRecvCreate)(struct mwService *service, struct mwChannel *channel, struct mwMsgChannelCreate *msg)
Definition mw_service.h:94
mwService_stop
void mwService_stop(struct mwService *service)
Triggers the stop handler for the service.
mwService_started
void mwService_started(struct mwService *service)
Indicate that a service is started.
mwChannel
Represents a channel to a service.
mwMsgChannelAccept
Definition mw_message.h:210
mwMsgChannelCreate
Definition mw_message.h:183
mwMsgChannelDestroy
Definition mw_message.h:238
mwOpaque
A length of binary data, not null-terminated.
Definition mw_common.h:79
mwOpaque::data
guchar * data
data, normally with no NULL termination
Definition mw_common.h:81
mwService
A service is the recipient of sendOnCnl messages sent over channels marked with the corresponding ser...
Definition mw_service.h:123
mwService::client_data
gpointer client_data
Optional client data, not for use by service implementations.
Definition mw_service.h:201
mwService::session
struct mwSession * session
session this service is attached to.
Definition mw_service.h:139
mwService::get_desc
mwService_funcGetDesc get_desc
Definition mw_service.h:147
mwService::stop
mwService_funcStop stop
The service's stop handler.
Definition mw_service.h:186
mwService::get_name
mwService_funcGetName get_name
Definition mw_service.h:143
mwService::recv_destroy
mwService_funcRecvDestroy recv_destroy
The service's channel destroy handler.
Definition mw_service.h:168
mwService::clear
mwService_funcClear clear
The service's cleanup handler.
Definition mw_service.h:195
mwService::recv_accept
mwService_funcRecvAccept recv_accept
The service's channel accept handler.
Definition mw_service.h:161
mwService::recv
mwService_funcRecv recv
The service's input handler.
Definition mw_service.h:174
mwService::recv_create
mwService_funcRecvCreate recv_create
The service's channel create handler.
Definition mw_service.h:154
mwService::state
enum mwServiceState state
the state of this service.
Definition mw_service.h:135
mwService::start
mwService_funcStart start
The service's start handler.
Definition mw_service.h:180
mwService::type
guint32 type
the unique identifier by which this service is registered.
Definition mw_service.h:128
mwService::client_cleanup
GDestroyNotify client_cleanup
Optional client data cleanup function.
Definition mw_service.h:208
mwSession
Represents a Sametime client session.