meanwhile 1.1.0
|
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_CHANNEL_H 00022 #define _MW_CHANNEL_H 00023 00024 00079 #include <time.h> 00080 #include "mw_common.h" 00081 00082 00083 #ifdef __cplusplus 00084 extern "C" { 00085 #endif 00086 00087 00088 /* place-holders */ 00089 struct mwCipherInstance; 00090 struct mwMsgChannelAccept; 00091 struct mwMsgChannelCreate; 00092 struct mwMsgChannelDestroy; 00093 struct mwMsgChannelSend; 00094 struct mwService; 00095 struct mwSession; 00096 00097 00098 00101 struct mwChannel; 00102 00103 00106 struct mwChannelSet; 00107 00108 00110 #define MW_MASTER_CHANNEL_ID 0x00000000 00111 00112 00114 #define mwChannel_idIsOutgoing(id) \ 00115 (! (0x80000000 & (id))) 00116 00118 #define mwChannel_idIsIncoming(id) \ 00119 (! mwChannel_idIsOutgoing(id)) 00120 00122 #define mwChannel_isOutgoing(chan) \ 00123 mwChannel_idIsOutgoing(mwChannel_getId(chan)) 00124 00126 #define mwChannel_isIncoming(chan) \ 00127 mwChannel_idIsIncoming(mwChannel_getId(chan)) 00128 00129 00131 enum mwChannelState { 00132 mwChannel_NEW, 00133 mwChannel_INIT, 00134 mwChannel_WAIT, 00135 mwChannel_OPEN, 00136 mwChannel_DESTROY, 00137 mwChannel_ERROR, 00138 mwChannel_UNKNOWN, 00139 }; 00140 00141 00142 #define mwChannel_isState(chan, state) \ 00143 (mwChannel_getState(chan) == (state)) 00144 00145 00148 enum mwChannelStatField { 00149 mwChannelStat_MSG_SENT, 00150 mwChannelStat_MSG_RECV, 00151 mwChannelStat_U_BYTES_SENT, 00152 mwChannelStat_U_BYTES_RECV, 00153 mwChannelStat_OPENED_AT, 00154 mwChannelStat_CLOSED_AT, 00155 }; 00156 00157 00163 enum mwEncryptPolicy { 00164 mwEncrypt_NONE = 0x0000, 00165 mwEncrypt_WHATEVER = 0x0001, 00166 mwEncrypt_ALL = 0x0002, 00167 mwEncrypt_RC2_40 = 0x1000, 00168 mwEncrypt_RC2_128 = 0x2000, 00169 }; 00170 00171 00173 struct mwChannelSet *mwChannelSet_new(struct mwSession *); 00174 00175 00178 void mwChannelSet_free(struct mwChannelSet *); 00179 00180 00183 struct mwChannel *mwChannel_newIncoming(struct mwChannelSet *, guint32 id); 00184 00185 00188 struct mwChannel *mwChannel_newOutgoing(struct mwChannelSet *); 00189 00190 00193 struct mwChannel *mwChannel_find(struct mwChannelSet *cs, guint32 chan); 00194 00195 00198 guint32 mwChannel_getId(struct mwChannel *); 00199 00200 00202 struct mwSession *mwChannel_getSession(struct mwChannel *); 00203 00204 00207 guint32 mwChannel_getServiceId(struct mwChannel *); 00208 00209 00212 struct mwService *mwChannel_getService(struct mwChannel *); 00213 00214 00216 void mwChannel_setService(struct mwChannel *chan, struct mwService *srvc); 00217 00218 00222 gpointer mwChannel_getServiceData(struct mwChannel *chan); 00223 00224 00228 void mwChannel_setServiceData(struct mwChannel *chan, 00229 gpointer data, GDestroyNotify clean); 00230 00231 00232 void mwChannel_removeServiceData(struct mwChannel *chan); 00233 00234 00235 guint32 mwChannel_getProtoType(struct mwChannel *chan); 00236 00237 00238 void mwChannel_setProtoType(struct mwChannel *chan, guint32 proto_type); 00239 00240 00241 guint32 mwChannel_getProtoVer(struct mwChannel *chan); 00242 00243 00244 void mwChannel_setProtoVer(struct mwChannel *chan, guint32 proto_ver); 00245 00246 00255 guint16 mwChannel_getEncryptPolicy(struct mwChannel *chan); 00256 00257 00258 guint32 mwChannel_getOptions(struct mwChannel *chan); 00259 00260 00261 void mwChannel_setOptions(struct mwChannel *chan, guint32 options); 00262 00263 00266 struct mwLoginInfo *mwChannel_getUser(struct mwChannel *chan); 00267 00268 00270 struct mwOpaque *mwChannel_getAddtlCreate(struct mwChannel *); 00271 00272 00274 struct mwOpaque *mwChannel_getAddtlAccept(struct mwChannel *); 00275 00276 00279 void mwChannel_populateSupportedCipherInstances(struct mwChannel *chan); 00280 00281 00284 void mwChannel_addSupportedCipherInstance(struct mwChannel *chan, 00285 struct mwCipherInstance *ci); 00286 00287 00290 GList *mwChannel_getSupportedCipherInstances(struct mwChannel *chan); 00291 00292 00295 void mwChannel_selectCipherInstance(struct mwChannel *chan, 00296 struct mwCipherInstance *ci); 00297 00298 00299 struct mwCipherInstance * 00300 mwChannel_getCipherInstance(struct mwChannel *chan); 00301 00302 00304 enum mwChannelState mwChannel_getState(struct mwChannel *); 00305 00306 00308 gpointer mwChannel_getStatistic(struct mwChannel *chan, 00309 enum mwChannelStatField stat); 00310 00311 00322 int mwChannel_create(struct mwChannel *chan); 00323 00324 00328 int mwChannel_accept(struct mwChannel *chan); 00329 00330 00338 int mwChannel_destroy(struct mwChannel *chan, guint32 reason, 00339 struct mwOpaque *data); 00340 00341 00344 int mwChannel_send(struct mwChannel *chan, guint32 msg_type, 00345 struct mwOpaque *msg); 00346 00347 00350 int mwChannel_sendEncrypted(struct mwChannel *chan, 00351 guint32 msg_type, struct mwOpaque *msg, 00352 gboolean encrypt); 00353 00354 00356 void mwChannel_recvCreate(struct mwChannel *chan, 00357 struct mwMsgChannelCreate *msg); 00358 00359 00361 void mwChannel_recvAccept(struct mwChannel *chan, 00362 struct mwMsgChannelAccept *msg); 00363 00364 00366 void mwChannel_recvDestroy(struct mwChannel *chan, 00367 struct mwMsgChannelDestroy *msg); 00368 00369 00371 void mwChannel_recv(struct mwChannel *chan, struct mwMsgChannelSend *msg); 00372 00373 00374 #ifdef __cplusplus 00375 } 00376 #endif 00377 00378 00379 #endif /* _MW_CHANNEL_H */ 00380