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