meanwhile 1.1.1
mw_service.h
Go to the documentation of this file.
1
2/*
3 Meanwhile - Unofficial Lotus Sametime Community Client Library
4 Copyright (C) 2004 Christopher (siege) O'Brien
5
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either
9 version 2 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 Library General Public License for more details.
15
16 You should have received a copy of the GNU Library General Public
17 License along with this library; if not, write to the Free
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19*/
20
21#ifndef _MW_SERVICE_H
22#define _MW_SERVICE_H
23
24
25#include "mw_common.h"
26
27
28#ifdef __cplusplus
29extern "C" {
30#endif
31
32
33/* place-holders */
34struct mwChannel;
35struct mwService;
36struct mwSession;
40
41
50};
51
52
54#define MW_SERVICE(srv) ((struct mwService *) srv)
55
56
57#define MW_SERVICE_IS_STATE(srvc, state) \
58 (mwService_getState(MW_SERVICE(srvc)) == (state))
59
60#define MW_SERVICE_IS_STOPPED(srvc) \
61 MW_SERVICE_IS_STATE(srvc, mwServiceState_STOPPED)
62
63#define MW_SERVICE_IS_STOPPING(srvc) \
64 MW_SERVICE_IS_STATE(srvc, mwServiceState_STOPPING)
65
66#define MW_SERVICE_IS_STARTED(srvc) \
67 MW_SERVICE_IS_STATE(srvc, mwServiceState_STARTED)
68
69#define MW_SERVICE_IS_STARTING(srvc) \
70 MW_SERVICE_IS_STATE(srvc, mwServiceState_STARTING)
71
72
74#define MW_SERVICE_IS_LIVE(srvc) \
75 (MW_SERVICE_IS_STARTING(srvc) || MW_SERVICE_IS_STARTED(srvc))
76
78#define MW_SERVICE_IS_DEAD(srvc) \
79 (MW_SERVICE_IS_STOPPING(srvc) || MW_SERVICE_IS_STOPPED(srvc))
80
81
82typedef void (*mwService_funcStart)(struct mwService *service);
83
84typedef void (*mwService_funcStop)(struct mwService *service);
85
86typedef void (*mwService_funcClear)(struct mwService *service);
87
88typedef const char *(*mwService_funcGetName)(struct mwService *service);
89
90typedef const char *(*mwService_funcGetDesc)(struct mwService *service);
91
94 (struct mwService *service,
95 struct mwChannel *channel,
96 struct mwMsgChannelCreate *msg);
97
100 (struct mwService *service,
101 struct mwChannel *channel,
102 struct mwMsgChannelAccept *msg);
103
106 (struct mwService *service,
107 struct mwChannel *channel,
108 struct mwMsgChannelDestroy *msg);
109
110typedef void (*mwService_funcRecv)
111 (struct mwService *service,
112 struct mwChannel *channel,
113 guint16 msg_type,
114 struct mwOpaque *data);
115
116
123struct mwService {
124
128 guint32 type;
129
136
140
144
148
155
162
169
175
181
187
196
201 gpointer client_data;
202
208 GDestroyNotify client_cleanup;
209};
210
211
216
217
228void mwService_init(struct mwService *service,
229 struct mwSession *session,
230 guint32 service_type);
231
232
235void mwService_started(struct mwService *service);
236
237
240void mwService_stopped(struct mwService *service);
241
242
251
252
258void mwService_recvCreate(struct mwService *service,
259 struct mwChannel *channel,
260 struct mwMsgChannelCreate *msg);
261
262
268void mwService_recvAccept(struct mwService *service,
269 struct mwChannel *channel,
270 struct mwMsgChannelAccept *msg);
271
272
278void mwService_recvDestroy(struct mwService *service,
279 struct mwChannel *channel,
280 struct mwMsgChannelDestroy *msg);
281
282
289void mwService_recv(struct mwService *service,
290 struct mwChannel *channel,
291 guint16 msg_type,
292 struct mwOpaque *data);
293
294
296guint32 mwService_getType(struct mwService *);
297
298
300const char *mwService_getName(struct mwService *);
301
302
304const char *mwService_getDesc(struct mwService *);
305
306
308struct mwSession *mwService_getSession(struct mwService *service);
309
310
314
315
323void mwService_start(struct mwService *service);
324
325
332void mwService_stop(struct mwService *service);
333
334
341void mwService_free(struct mwService *service);
342
343
349 gpointer data, GDestroyNotify cleanup);
350
351
353gpointer mwService_getClientData(struct mwService *service);
354
355
359
360
364#ifdef __cplusplus
365}
366#endif
367
368
369#endif /* _MW_SERVICE_H */
370
Common data types and functions for handling those types.
void(* mwService_funcClear)(struct mwService *service)
Definition: mw_service.h:86
void mwService_removeClientData(struct mwService *service)
Removes client data from service.
void(* mwService_funcStart)(struct mwService *service)
Definition: mw_service.h:82
void mwService_start(struct mwService *service)
Triggers the start handler for the service.
const char *(* mwService_funcGetDesc)(struct mwService *service)
Definition: mw_service.h:90
void(* mwService_funcStop)(struct mwService *service)
Definition: mw_service.h:84
void(* mwService_funcRecv)(struct mwService *service, struct mwChannel *channel, guint16 msg_type, struct mwOpaque *data)
Definition: mw_service.h:111
void(* mwService_funcRecvAccept)(struct mwService *service, struct mwChannel *channel, struct mwMsgChannelAccept *msg)
Definition: mw_service.h:100
void mwService_setClientData(struct mwService *service, gpointer data, GDestroyNotify cleanup)
Associates client data with service.
mwServiceState
State-tracking for a service.
Definition: mw_service.h:43
@ mwServiceState_STOPPING
the service is shutting down
Definition: mw_service.h:45
@ mwServiceState_STOPPED
the service is not active
Definition: mw_service.h:44
@ mwServiceState_STARTING
the service is starting up
Definition: mw_service.h:47
@ mwServiceState_ERROR
error in service, shutting down
Definition: mw_service.h:48
@ mwServiceState_STARTED
the service is active
Definition: mw_service.h:46
@ mwServiceState_UNKNOWN
error determining state
Definition: mw_service.h:49
enum mwServiceState mwService_getState(struct mwService *service)
void mwService_recvCreate(struct mwService *service, struct mwChannel *channel, struct mwMsgChannelCreate *msg)
Triggers the recv_create handler on the service.
guint32 mwService_getType(struct mwService *)
gpointer mwService_getClientData(struct mwService *service)
Reference associated client data.
void mwService_init(struct mwService *service, struct mwSession *session, guint32 service_type)
Prepares a newly allocated service for use.
const char * mwService_getDesc(struct mwService *)
struct mwSession * mwService_getSession(struct mwService *service)
void mwService_recvDestroy(struct mwService *service, struct mwChannel *channel, struct mwMsgChannelDestroy *msg)
Triggers the recv_destroy handler on the service.
void(* mwService_funcRecvDestroy)(struct mwService *service, struct mwChannel *channel, struct mwMsgChannelDestroy *msg)
Definition: mw_service.h:106
void mwService_stopped(struct mwService *service)
Indicate that a service is stopped.
const char *(* mwService_funcGetName)(struct mwService *service)
Definition: mw_service.h:88
void mwService_free(struct mwService *service)
Frees memory used by a service.
void mwService_recvAccept(struct mwService *service, struct mwChannel *channel, struct mwMsgChannelAccept *msg)
Triggers the recv_accept handler on the service.
const char * mwService_getName(struct mwService *)
void mwService_recv(struct mwService *service, struct mwChannel *channel, guint16 msg_type, struct mwOpaque *data)
Triggers the input handler on the service.
void(* mwService_funcRecvCreate)(struct mwService *service, struct mwChannel *channel, struct mwMsgChannelCreate *msg)
Definition: mw_service.h:94
void mwService_stop(struct mwService *service)
Triggers the stop handler for the service.
void mwService_started(struct mwService *service)
Indicate that a service is started.
Represents a channel to a service.
Definition: mw_message.h:210
Definition: mw_message.h:183
Definition: mw_message.h:238
A length of binary data, not null-terminated.
Definition: mw_common.h:79
guchar * data
data, normally with no NULL termination
Definition: mw_common.h:81
A service is the recipient of sendOnCnl messages sent over channels marked with the corresponding ser...
Definition: mw_service.h:123
gpointer client_data
Optional client data, not for use by service implementations.
Definition: mw_service.h:201
struct mwSession * session
session this service is attached to.
Definition: mw_service.h:139
mwService_funcGetDesc get_desc
Definition: mw_service.h:147
mwService_funcStop stop
The service's stop handler.
Definition: mw_service.h:186
mwService_funcGetName get_name
Definition: mw_service.h:143
mwService_funcRecvDestroy recv_destroy
The service's channel destroy handler.
Definition: mw_service.h:168
mwService_funcClear clear
The service's cleanup handler.
Definition: mw_service.h:195
mwService_funcRecvAccept recv_accept
The service's channel accept handler.
Definition: mw_service.h:161
mwService_funcRecv recv
The service's input handler.
Definition: mw_service.h:174
mwService_funcRecvCreate recv_create
The service's channel create handler.
Definition: mw_service.h:154
enum mwServiceState state
the state of this service.
Definition: mw_service.h:135
mwService_funcStart start
The service's start handler.
Definition: mw_service.h:180
guint32 type
the unique identifier by which this service is registered.
Definition: mw_service.h:128
GDestroyNotify client_cleanup
Optional client data cleanup function.
Definition: mw_service.h:208
Represents a Sametime client session.