meanwhile  1.1.0
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
29 extern "C" {
30 #endif
31 
32 
33 /* place-holders */
34 struct mwChannel;
35 struct mwService;
36 struct mwSession;
37 struct mwMsgChannelCreate;
38 struct mwMsgChannelAccept;
39 struct mwMsgChannelDestroy;
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 
82 typedef void (*mwService_funcStart)(struct mwService *service);
83 
84 typedef void (*mwService_funcStop)(struct mwService *service);
85 
86 typedef void (*mwService_funcClear)(struct mwService *service);
87 
88 typedef const char *(*mwService_funcGetName)(struct mwService *service);
89 
90 typedef const char *(*mwService_funcGetDesc)(struct mwService *service);
91 
93 typedef void (*mwService_funcRecvCreate)
94  (struct mwService *service,
95  struct mwChannel *channel,
96  struct mwMsgChannelCreate *msg);
97 
99 typedef void (*mwService_funcRecvAccept)
100  (struct mwService *service,
101  struct mwChannel *channel,
102  struct mwMsgChannelAccept *msg);
103 
105 typedef void (*mwService_funcRecvDestroy)
106  (struct mwService *service,
107  struct mwChannel *channel,
108  struct mwMsgChannelDestroy *msg);
109 
110 typedef void (*mwService_funcRecv)
111  (struct mwService *service,
112  struct mwChannel *channel,
113  guint16 msg_type,
114  struct mwOpaque *data);
115 
116 
123 struct 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 
228 void mwService_init(struct mwService *service,
229  struct mwSession *session,
230  guint32 service_type);
231 
232 
235 void mwService_started(struct mwService *service);
236 
237 
240 void mwService_stopped(struct mwService *service);
241 
242 
251 
252 
258 void mwService_recvCreate(struct mwService *service,
259  struct mwChannel *channel,
260  struct mwMsgChannelCreate *msg);
261 
262 
268 void mwService_recvAccept(struct mwService *service,
269  struct mwChannel *channel,
270  struct mwMsgChannelAccept *msg);
271 
272 
278 void mwService_recvDestroy(struct mwService *service,
279  struct mwChannel *channel,
280  struct mwMsgChannelDestroy *msg);
281 
282 
289 void mwService_recv(struct mwService *service,
290  struct mwChannel *channel,
291  guint16 msg_type,
292  struct mwOpaque *data);
293 
294 
296 guint32 mwService_getType(struct mwService *);
297 
298 
300 const char *mwService_getName(struct mwService *);
301 
302 
304 const char *mwService_getDesc(struct mwService *);
305 
306 
308 struct mwSession *mwService_getSession(struct mwService *service);
309 
310 
313 enum mwServiceState mwService_getState(struct mwService *service);
314 
315 
323 void mwService_start(struct mwService *service);
324 
325 
332 void mwService_stop(struct mwService *service);
333 
334 
341 void mwService_free(struct mwService *service);
342 
343 
348 void mwService_setClientData(struct mwService *service,
349  gpointer data, GDestroyNotify cleanup);
350 
351 
353 gpointer mwService_getClientData(struct mwService *service);
354 
355 
358 void mwService_removeClientData(struct mwService *service);
359 
360 
364 #ifdef __cplusplus
365 }
366 #endif
367 
368 
369 #endif /* _MW_SERVICE_H */
370 
mwService_funcClear clear
The service's cleanup handler.
Definition: mw_service.h:195
mwService_funcRecvCreate recv_create
The service's channel create handler.
Definition: mw_service.h:154
error determining state
Definition: mw_service.h:49
const char *(* mwService_funcGetName)(struct mwService *service)
Definition: mw_service.h:88
Definition: mw_message.h:183
Definition: mw_message.h:210
void(* mwService_funcRecvCreate)(struct mwService *service, struct mwChannel *channel, struct mwMsgChannelCreate *msg)
Definition: mw_service.h:94
void mwService_recvCreate(struct mwService *service, struct mwChannel *channel, struct mwMsgChannelCreate *msg)
Triggers the recv_create handler on the service.
void mwService_init(struct mwService *service, struct mwSession *session, guint32 service_type)
Prepares a newly allocated service for use.
guint32 type
the unique identifier by which this service is registered.
Definition: mw_service.h:128
mwService_funcStop stop
The service's stop handler.
Definition: mw_service.h:186
void mwService_setClientData(struct mwService *service, gpointer data, GDestroyNotify cleanup)
Associates client data with service.
void mwService_free(struct mwService *service)
Frees memory used by a service.
void mwService_recvDestroy(struct mwService *service, struct mwChannel *channel, struct mwMsgChannelDestroy *msg)
Triggers the recv_destroy handler on the service.
mwService_funcGetDesc get_desc
Definition: mw_service.h:147
void mwService_start(struct mwService *service)
Triggers the start handler for the service.
Represents a Sametime client session.
void mwService_stop(struct mwService *service)
Triggers the stop handler for the service.
void(* mwService_funcStart)(struct mwService *service)
Definition: mw_service.h:82
mwService_funcRecvDestroy recv_destroy
The service's channel destroy handler.
Definition: mw_service.h:168
Common data types and functions for handling those types.
mwService_funcRecv recv
The service's input handler.
Definition: mw_service.h:174
void mwService_started(struct mwService *service)
Indicate that a service is started.
struct mwSession * session
session this service is attached to.
Definition: mw_service.h:139
const char * mwService_getDesc(struct mwService *)
Definition: mw_message.h:238
the service is starting up
Definition: mw_service.h:47
void(* mwService_funcRecv)(struct mwService *service, struct mwChannel *channel, guint16 msg_type, struct mwOpaque *data)
Definition: mw_service.h:111
error in service, shutting down
Definition: mw_service.h:48
void mwService_recvAccept(struct mwService *service, struct mwChannel *channel, struct mwMsgChannelAccept *msg)
Triggers the recv_accept handler on the service.
GDestroyNotify client_cleanup
Optional client data cleanup function.
Definition: mw_service.h:208
A service is the recipient of sendOnCnl messages sent over channels marked with the corresponding ser...
Definition: mw_service.h:123
guint32 mwService_getType(struct mwService *)
void mwService_recv(struct mwService *service, struct mwChannel *channel, guint16 msg_type, struct mwOpaque *data)
Triggers the input handler on the service.
enum mwServiceState mwService_getState(struct mwService *service)
Represents a channel to a service.
Definition: mw_channel.h:95
the service is not active
Definition: mw_service.h:44
void(* mwService_funcRecvAccept)(struct mwService *service, struct mwChannel *channel, struct mwMsgChannelAccept *msg)
Definition: mw_service.h:100
mwService_funcStart start
The service's start handler.
Definition: mw_service.h:180
gpointer mwService_getClientData(struct mwService *service)
Reference associated client data.
void mwService_stopped(struct mwService *service)
Indicate that a service is stopped.
A length of binary data, not null-terminated.
Definition: mw_common.h:79
void(* mwService_funcRecvDestroy)(struct mwService *service, struct mwChannel *channel, struct mwMsgChannelDestroy *msg)
Definition: mw_service.h:106
void(* mwService_funcClear)(struct mwService *service)
Definition: mw_service.h:86
const char *(* mwService_funcGetDesc)(struct mwService *service)
Definition: mw_service.h:90
gpointer client_data
Optional client data, not for use by service implementations.
Definition: mw_service.h:201
enum mwServiceState state
the state of this service.
Definition: mw_service.h:135
mwServiceState
State-tracking for a service.
Definition: mw_service.h:43
the service is active
Definition: mw_service.h:46
mwService_funcGetName get_name
Definition: mw_service.h:143
const char * mwService_getName(struct mwService *)
void mwService_removeClientData(struct mwService *service)
Removes client data from service.
mwService_funcRecvAccept recv_accept
The service's channel accept handler.
Definition: mw_service.h:161
guchar * data
data, normally with no NULL termination
Definition: mw_common.h:81
the service is shutting down
Definition: mw_service.h:45
struct mwSession * mwService_getSession(struct mwService *service)
void(* mwService_funcStop)(struct mwService *service)
Definition: mw_service.h:84