meanwhile  1.0.2
mw_common.h
Go to the documentation of this file.
00001 /*
00002   Meanwhile - Unofficial Lotus Sametime Community Client Library
00003   Copyright (C) 2004  Christopher (siege) O'Brien
00004   
00005   This library is free software; you can redistribute it and/or
00006   modify it under the terms of the GNU Library General Public
00007   License as published by the Free Software Foundation; either
00008   version 2 of the License, or (at your option) any later version.
00009   
00010   This library is distributed in the hope that it will be useful,
00011   but WITHOUT ANY WARRANTY; without even the implied warranty of
00012   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013   Library General Public License for more details.
00014   
00015   You should have received a copy of the GNU Library General Public
00016   License along with this library; if not, write to the Free
00017   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018 */
00019 
00020 #ifndef _MW_COMMON_H
00021 #define _MW_COMMON_H
00022 
00023 
00060 #include <glib.h>
00061 
00062 
00063 #ifdef __cplusplus
00064 extern "C" {
00065 #endif
00066 
00067 
00070 struct mwPutBuffer;
00071 
00074 struct mwGetBuffer;
00075 
00076 
00078 struct mwOpaque {
00079   gsize len;     
00080   guchar *data;  
00081 };
00082 
00083 
00084 /* 8.3.6 Login Types */
00085 
00092 enum mwLoginType {
00093   mwLogin_LIB           = 0x1000,  
00094   mwLogin_JAVA_WEB      = 0x1001,  
00095   mwLogin_BINARY        = 0x1002,  
00096   mwLogin_JAVA_APP      = 0x1003,  
00097   mwLogin_LINKS         = 0x100a,  
00099   /* now we're getting crazy */
00100   mwLogin_NOTES_6_5        = 0x1200,
00101   mwLogin_NOTES_6_5_3      = 0x1203,
00102   mwLogin_NOTES_7_0_beta   = 0x1210,
00103   mwLogin_NOTES_7_0        = 0x1214,
00104   mwLogin_ICT              = 0x1300,
00105   mwLogin_ICT_1_7_8_2      = 0x1302,
00106   mwLogin_ICT_SIP          = 0x1303,
00107   mwLogin_NOTESBUDDY_4_14  = 0x1400,  
00108   mwLogin_NOTESBUDDY_4_15  = 0x1405,
00109   mwLogin_NOTESBUDDY_4_16  = 0x1406,
00110   mwLogin_SANITY           = 0x1600,
00111   mwLogin_ST_PERL          = 0x1625,
00112   mwLogin_PMR_ALERT        = 0x1650,
00113   mwLogin_TRILLIAN         = 0x16aa,  
00114   mwLogin_TRILLIAN_IBM     = 0x16bb,
00115   mwLogin_MEANWHILE        = 0x1700,  
00116 };
00117 
00118 
00119 /* 8.2 Common Structures */
00120 /* 8.2.1 Login Info block */
00121 
00122 struct mwLoginInfo {
00123   char *login_id;   
00124   guint16 type;     
00125   char *user_id;    
00126   char *user_name;  
00127   char *community;  
00128   gboolean full;    
00129   char *desc;       
00130   guint32 ip_addr;  
00131   char *server_id;  
00132 };
00133 
00134 
00135 /* 8.2.2 Private Info Block */
00136 
00137 struct mwUserItem {
00138   gboolean full;    
00139   char *id;         
00140   char *community;  
00141   char *name;       
00142 };
00143 
00144 
00145 struct mwPrivacyInfo {
00146   gboolean deny;             
00147   guint32 count;             
00148   struct mwUserItem *users;  
00149 };
00150 
00151 
00152 /* 8.3.5 User Status Types */
00153 
00154 enum mwStatusType {
00155   mwStatus_OFFLINE = 0x0000,
00156 
00157   mwStatus_ACTIVE  = 0x0020,
00158   mwStatus_IDLE    = 0x0040,
00159   mwStatus_AWAY    = 0x0060,
00160   mwStatus_BUSY    = 0x0080,
00161 
00162   mwStatus_MASK_MOBILE = 0x0200,
00163 };
00164 
00165 
00166 /* 8.2.3 User Status Block */
00167 
00168 struct mwUserStatus {
00169   guint16 status;  
00170   guint32 time;    
00171   char *desc;      
00172 };
00173 
00174 
00175 /* 8.2.4 ID Block */
00176 
00177 struct mwIdBlock {
00178   char *user;       
00179   char *community;  
00180 };
00181 
00182 
00183 /* 8.3.8.2 Awareness Presence Types */
00184 
00185 /* @todo move mwAwareType, mwAwareIdBlock and mwAwareSnapshot into the
00186    aware service and out of common */
00187 
00189 enum mwAwareType {
00190   mwAware_USER    = 0x0002,  
00191   mwAware_GROUP   = 0x0003,  
00192   mwAware_SERVER  = 0x0008,  
00193 };
00194 
00195 
00196 /* 8.4.2 Awareness Messages */
00197 /* 8.4.2.1 Awareness ID Block */
00198 
00199 struct mwAwareIdBlock {
00200   guint16 type;     
00201   char *user;       
00202   char *community;  
00203 };
00204 
00205 
00206 /* 8.4.2.4 Snapshot */
00207 
00208 struct mwAwareSnapshot {
00209   struct mwAwareIdBlock id;
00210   char *group;                 
00211   gboolean online;             
00212   char *alt_id;                
00213   struct mwUserStatus status;  
00214   char *name;                  
00215 };
00216 
00217 
00219 struct mwEncryptItem {
00220   guint16 id;            
00221   struct mwOpaque info;  
00222 };
00223 
00224 
00227 
00228 
00230 struct mwPutBuffer *mwPutBuffer_new(void);
00231 
00232 
00234 void mwPutBuffer_write(struct mwPutBuffer *b, gpointer data, gsize len);
00235 
00236 
00238 void mwPutBuffer_free(struct mwPutBuffer *b);
00239 
00240 
00242 void mwPutBuffer_finalize(struct mwOpaque *to, struct mwPutBuffer *from);
00243 
00244 
00246 struct mwGetBuffer *mwGetBuffer_new(struct mwOpaque *data);
00247 
00248 
00254 gsize mwGetBuffer_read(struct mwGetBuffer *b, gpointer mem, gsize len);
00255 
00256 
00262 gsize mwGetBuffer_advance(struct mwGetBuffer *b, gsize len);
00263 
00264 
00268 struct mwGetBuffer *mwGetBuffer_wrap(const struct mwOpaque *data);
00269 
00270 
00272 void mwGetBuffer_free(struct mwGetBuffer *b);
00273 
00274 
00277 void mwGetBuffer_reset(struct mwGetBuffer *b);
00278 
00279 
00281 gsize mwGetBuffer_remaining(struct mwGetBuffer *b);
00282 
00283 
00286 gboolean mwGetBuffer_error(struct mwGetBuffer *b);
00287 
00288 
00296 
00297 
00298 void guint16_put(struct mwPutBuffer *b, guint16 val);
00299 
00300 void guint16_get(struct mwGetBuffer *b, guint16 *val);
00301 
00302 guint16 guint16_peek(struct mwGetBuffer *b);
00303 
00304 
00305 void guint32_put(struct mwPutBuffer *b, guint32 val);
00306 
00307 void guint32_get(struct mwGetBuffer *b, guint32 *val);
00308 
00309 guint32 guint32_peek(struct mwGetBuffer *b);
00310 
00311 
00312 void gboolean_put(struct mwPutBuffer *b, gboolean val);
00313 
00314 void gboolean_get(struct mwGetBuffer *b, gboolean *val);
00315 
00316 gboolean gboolean_peek(struct mwGetBuffer *b);
00317 
00318 
00319 void mwString_put(struct mwPutBuffer *b, const char *str);
00320 
00321 void mwString_get(struct mwGetBuffer *b, char **str);
00322 
00323 
00324 void mwOpaque_put(struct mwPutBuffer *b, const struct mwOpaque *o);
00325 
00326 void mwOpaque_get(struct mwGetBuffer *b, struct mwOpaque *o);
00327 
00328 void mwOpaque_clear(struct mwOpaque *o);
00329 
00330 void mwOpaque_free(struct mwOpaque *o);
00331 
00332 void mwOpaque_clone(struct mwOpaque *to, const struct mwOpaque *from);
00333 
00334 
00340 
00341 
00342 void mwLoginInfo_put(struct mwPutBuffer *b, const struct mwLoginInfo *info);
00343 
00344 void mwLoginInfo_get(struct mwGetBuffer *b, struct mwLoginInfo *info);
00345 
00346 void mwLoginInfo_clear(struct mwLoginInfo *info);
00347 
00348 void mwLoginInfo_clone(struct mwLoginInfo *to, const struct mwLoginInfo *from);
00349 
00350 
00351 void mwUserItem_put(struct mwPutBuffer *b, const struct mwUserItem *user);
00352 
00353 void mwUserItem_get(struct mwGetBuffer *b, struct mwUserItem *user);
00354 
00355 void mwUserItem_clear(struct mwUserItem *user);
00356 
00357 void mwUserItem_clone(struct mwUserItem *to, const struct mwUserItem *from);
00358 
00359 
00360 void mwPrivacyInfo_put(struct mwPutBuffer *b,
00361                        const struct mwPrivacyInfo *info);
00362 
00363 void mwPrivacyInfo_get(struct mwGetBuffer *b, struct mwPrivacyInfo *info);
00364 
00365 void mwPrivacyInfo_clear(struct mwPrivacyInfo *info);
00366 
00367 void mwPrivacyInfo_clone(struct mwPrivacyInfo *to,
00368                          const struct mwPrivacyInfo *from);
00369 
00370 
00371 void mwUserStatus_put(struct mwPutBuffer *b,
00372                       const struct mwUserStatus *stat);
00373 
00374 void mwUserStatus_get(struct mwGetBuffer *b, struct mwUserStatus *stat);
00375 
00376 void mwUserStatus_clear(struct mwUserStatus *stat);
00377 
00378 void mwUserStatus_clone(struct mwUserStatus *to,
00379                         const struct mwUserStatus *from);
00380 
00381 
00382 void mwIdBlock_put(struct mwPutBuffer *b, const struct mwIdBlock *id);
00383 
00384 void mwIdBlock_get(struct mwGetBuffer *b, struct mwIdBlock *id);
00385 
00386 void mwIdBlock_clear(struct mwIdBlock *id);
00387 
00388 void mwIdBlock_clone(struct mwIdBlock *to,
00389                      const struct mwIdBlock *from);
00390 
00391 guint mwIdBlock_hash(const struct mwIdBlock *idb);
00392 
00393 gboolean mwIdBlock_equal(const struct mwIdBlock *a,
00394                          const struct mwIdBlock *b);
00395 
00396 
00397 void mwAwareIdBlock_put(struct mwPutBuffer *b,
00398                         const struct mwAwareIdBlock *idb);
00399 
00400 void mwAwareIdBlock_get(struct mwGetBuffer *b, struct mwAwareIdBlock *idb);
00401 
00402 void mwAwareIdBlock_clear(struct mwAwareIdBlock *idb);
00403 
00404 void mwAwareIdBlock_clone(struct mwAwareIdBlock *to,
00405                           const struct mwAwareIdBlock *from);
00406 
00407 guint mwAwareIdBlock_hash(const struct mwAwareIdBlock *a);
00408 
00409 gboolean mwAwareIdBlock_equal(const struct mwAwareIdBlock *a,
00410                               const struct mwAwareIdBlock *b);
00411 
00412 
00413 void mwAwareSnapshot_get(struct mwGetBuffer *b,
00414                          struct mwAwareSnapshot *idb);
00415 
00416 void mwAwareSnapshot_clear(struct mwAwareSnapshot *idb);
00417 
00418 void mwAwareSnapshot_clone(struct mwAwareSnapshot *to,
00419                            const struct mwAwareSnapshot *from);
00420 
00421 
00422 void mwEncryptItem_put(struct mwPutBuffer *b,
00423                        const struct mwEncryptItem *item);
00424 
00425 void mwEncryptItem_get(struct mwGetBuffer *b, struct mwEncryptItem *item);
00426 
00427 void mwEncryptItem_clear(struct mwEncryptItem *item);
00428 
00429 void mwEncryptItem_free(struct mwEncryptItem *item);
00430 
00431 
00435 #ifdef __cplusplus
00436 }
00437 #endif
00438 
00439 
00440 #endif /* _MW_COMMON_H */