meanwhile: mw_service.h Source File

- Main Page
- Related Pages
- Data Structures
- Files

# mw_service.h

Go to the documentation of this file.

    00001
    00002 /*
    00003   Meanwhile - Unofficial Lotus Sametime Community Client Library
    00004   Copyright (C) 2004  Christopher (siege) O'Brien
    00005
    00006   This library is free software; you can redistribute it and/or
    00007   modify it under the terms of the GNU Library General Public
    00008   License as published by the Free Software Foundation; either
    00009   version 2 of the License, or (at your option) any later version.
    00010
    00011   This library is distributed in the hope that it will be useful,
    00012   but WITHOUT ANY WARRANTY; without even the implied warranty of
    00013   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    00014   Library General Public License for more details.
    00015
    00016   You should have received a copy of the GNU Library General Public
    00017   License along with this library; if not, write to the Free
    00018   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    00019 */
    00020
    00021 #ifndef _MW_SERVICE_H
    00022 #define _MW_SERVICE_H
    00023
    00024
    00025 #include "mw_common.h"
    00026
    00027
    00028 #ifdef __cplusplus
    00029 extern "C" {
    00030 #endif
    00031
    00032
    00033 /* place-holders */
    00034 struct mwChannel;
    00035 struct mwService;
    00036 struct mwSession;
    00037 struct mwMsgChannelCreate;
    00038 struct mwMsgChannelAccept;
    00039 struct mwMsgChannelDestroy;
    00040
    00041
    00043 enum mwServiceState {
    00044   mwServiceState_STOPPED,
    00045   mwServiceState_STOPPING,
    00046   mwServiceState_STARTED,
    00047   mwServiceState_STARTING,
    00048   mwServiceState_ERROR,
    00049   mwServiceState_UNKNOWN,
    00050 };
    00051
    00052
    00054 #define MW_SERVICE(srv) ((struct mwService *) srv)
    00055
    00056
    00057 #define MW_SERVICE_IS_STATE(srvc, state) \
    00058   (mwService_getState(MW_SERVICE(srvc)) == (state))
    00059
    00060 #define MW_SERVICE_IS_STOPPED(srvc)  \
    00061   MW_SERVICE_IS_STATE(srvc, mwServiceState_STOPPED)
    00062
    00063 #define MW_SERVICE_IS_STOPPING(srvc) \
    00064   MW_SERVICE_IS_STATE(srvc, mwServiceState_STOPPING)
    00065
    00066 #define MW_SERVICE_IS_STARTED(srvc)  \
    00067   MW_SERVICE_IS_STATE(srvc, mwServiceState_STARTED)
    00068
    00069 #define MW_SERVICE_IS_STARTING(srvc) \
    00070   MW_SERVICE_IS_STATE(srvc, mwServiceState_STARTING)
    00071
    00072
    00074 #define MW_SERVICE_IS_LIVE(srvc) \
    00075   (MW_SERVICE_IS_STARTING(srvc) || MW_SERVICE_IS_STARTED(srvc))
    00076
    00078 #define MW_SERVICE_IS_DEAD(srvc) \
    00079   (MW_SERVICE_IS_STOPPING(srvc) || MW_SERVICE_IS_STOPPED(srvc))
    00080
    00081
    00082 typedef void (*mwService_funcStart)(struct mwService *service);
    00083
    00084 typedef void (*mwService_funcStop)(struct mwService *service);
    00085
    00086 typedef void (*mwService_funcClear)(struct mwService *service);
    00087
    00088 typedef const char *(*mwService_funcGetName)(struct mwService *service);
    00089
    00090 typedef const char *(*mwService_funcGetDesc)(struct mwService *service);
    00091
    00093 typedef void (*mwService_funcRecvCreate)
    00094      (struct mwService *service,
    00095       struct mwChannel *channel,
    00096       struct mwMsgChannelCreate *msg);
    00097
    00099 typedef void (*mwService_funcRecvAccept)
    00100      (struct mwService *service,
    00101       struct mwChannel *channel,
    00102       struct mwMsgChannelAccept *msg);
    00103
    00105 typedef void (*mwService_funcRecvDestroy)
    00106      (struct mwService *service,
    00107       struct mwChannel *channel,
    00108       struct mwMsgChannelDestroy *msg);
    00109
    00110 typedef void (*mwService_funcRecv)
    00111      (struct mwService *service,
    00112       struct mwChannel *channel,
    00113       guint16 msg_type,
    00114       struct mwOpaque *data);
    00115
    00116
    00123 struct mwService {
    00124
    00128   guint32 type;
    00129
    00135   enum mwServiceState state;
    00136
    00139   struct mwSession *session;
    00140
    00143   mwService_funcGetName get_name;
    00144
    00147   mwService_funcGetDesc get_desc;
    00148
    00154   mwService_funcRecvCreate recv_create;
    00155
    00161   mwService_funcRecvAccept recv_accept;
    00162
    00168   mwService_funcRecvDestroy recv_destroy;
    00169
    00174   mwService_funcRecv recv;
    00175
    00180   mwService_funcStart start;
    00181
    00186   mwService_funcStop stop;
    00187
    00195   mwService_funcClear clear;
    00196
    00201   gpointer client_data;
    00202
    00208   GDestroyNotify client_cleanup;
    00209 };
    00210
    00211
    00216
    00217
    00228 void mwService_init(struct mwService *service,
    00229                     struct mwSession *session,
    00230                     guint32 service_type);
    00231
    00232
    00235 void mwService_started(struct mwService *service);
    00236
    00237
    00240 void mwService_stopped(struct mwService *service);
    00241
    00242
    00251
    00252
    00258 void mwService_recvCreate(struct mwService *service,
    00259                           struct mwChannel *channel,
    00260                           struct mwMsgChannelCreate *msg);
    00261
    00262
    00268 void mwService_recvAccept(struct mwService *service,
    00269                           struct mwChannel *channel,
    00270                           struct mwMsgChannelAccept *msg);
    00271
    00272
    00278 void mwService_recvDestroy(struct mwService *service,
    00279                            struct mwChannel *channel,
    00280                            struct mwMsgChannelDestroy *msg);
    00281
    00282
    00289 void mwService_recv(struct mwService *service,
    00290                     struct mwChannel *channel,
    00291                     guint16 msg_type,
    00292                     struct mwOpaque *data);
    00293
    00294
    00296 guint32 mwService_getType(struct mwService *);
    00297
    00298
    00300 const char *mwService_getName(struct mwService *);
    00301
    00302
    00304 const char *mwService_getDesc(struct mwService *);
    00305
    00306
    00308 struct mwSession *mwService_getSession(struct mwService *service);
    00309
    00310
    00313 enum mwServiceState mwService_getState(struct mwService *service);
    00314
    00315
    00323 void mwService_start(struct mwService *service);
    00324
    00325
    00332 void mwService_stop(struct mwService *service);
    00333
    00334
    00341 void mwService_free(struct mwService *service);
    00342
    00343
    00348 void mwService_setClientData(struct mwService *service,
    00349                              gpointer data, GDestroyNotify cleanup);
    00350
    00351
    00353 gpointer mwService_getClientData(struct mwService *service);
    00354
    00355
    00358 void mwService_removeClientData(struct mwService *service);
    00359
    00360
    00364 #ifdef __cplusplus
    00365 }
    00366 #endif
    00367
    00368
    00369 #endif /* _MW_SERVICE_H */
    00370