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_ST_LIST_H 22 #define _MW_ST_LIST_H 23 24 25 /** @file mw_st_list.h 26 27 Parse and compose buddy lists in the format commonly used by Sametime 28 Connect clients. 29 */ 30 31 32 #include <glib.h> 33 #include <glib.h> 34 #include "mw_common.h" 35 36 37 #ifdef __cplusplus 38 extern "C" { 39 #endif 40 41 42 #define ST_LIST_MAJOR 3 43 #define ST_LIST_MINOR 1 44 #define ST_LIST_MICRO 3 45 46 47 enum mwSametimeGroupType { 48 mwSametimeGroup_NORMAL = 1, /**< a normal group of users */ 49 mwSametimeGroup_DYNAMIC = 2, /**< a server-side group */ 50 mwSametimeGroup_UNKNOWN = 0, /**< error determining group type */ 51 }; 52 53 54 enum mwSametimeUserType { 55 mwSametimeUser_NORMAL = 1, /**< user on same community */ 56 mwSametimeUser_EXTERNAL = 2, /**< external user */ 57 mwSametimeUser_UNKNOWN = 0, /**< error determining user type */ 58 }; 59 60 61 /** @struct mwSametimeList 62 63 Represents a group-based buddy list. */ 64 struct mwSametimeList; 65 66 67 /** @struct mwSametimeGroup 68 69 Represents a group in a buddy list */ 70 struct mwSametimeGroup; 71 72 73 /** @struct mwSametimeUser 74 75 Represents a user in a group in a buddy list */ 76 struct mwSametimeUser; 77 78 79 /** Create a new list */ 80 struct mwSametimeList *mwSametimeList_new(); 81 82 83 /** Free the list, all of its groups, and all of the groups' members */ 84 void mwSametimeList_free(struct mwSametimeList *l); 85 86 87 /** Load a sametime list from a buffer. The list must be encapsulated 88 as a string (eg, the first two bytes in the buffer should be the 89 length of the string) */ 90 void mwSametimeList_get(struct mwGetBuffer *b, struct mwSametimeList *l); 91 92 93 /** Write a sametime list onto a buffer. The list will be encapsulated 94 in a string (the first two bytes written will be the length of the 95 rest of the written list data) */ 96 void mwSametimeList_put(struct mwPutBuffer *b, struct mwSametimeList *l); 97 98 99 /** convert a plain string into a sametime list */ 100 struct mwSametimeList *mwSametimeList_load(const char *str); 101 102 103 /** convert a sametime list into a string */ 104 char *mwSametimeList_store(struct mwSametimeList *l); 105 106 107 void mwSametimeList_setMajor(struct mwSametimeList *l, guint v); 108 109 110 guint mwSametimeList_getMajor(struct mwSametimeList *l); 111 112 113 void mwSametimeList_setMinor(struct mwSametimeList *l, guint v); 114 115 116 guint mwSametimeList_getMinor(struct mwSametimeList *l); 117 118 119 void mwSametimeList_setMicro(struct mwSametimeList *l, guint v); 120 121 122 guint mwSametimeList_getMicro(struct mwSametimeList *l); 123 124 125 /** Get a GList snapshot of the groups in a list */ 126 GList *mwSametimeList_getGroups(struct mwSametimeList *l); 127 128 129 struct mwSametimeGroup * 130 mwSametimeList_findGroup(struct mwSametimeList *l, 131 const char *name); 132 133 134 /** Create a new group in a list */ 135 struct mwSametimeGroup * 136 mwSametimeGroup_new(struct mwSametimeList *l, 137 enum mwSametimeGroupType type, 138 const char *name); 139 140 141 /** Remove a group from its list, and free it. Also frees all users 142 contained in the group */ 143 void mwSametimeGroup_free(struct mwSametimeGroup *g); 144 145 146 enum mwSametimeGroupType mwSametimeGroup_getType(struct mwSametimeGroup *g); 147 148 149 const char *mwSametimeGroup_getName(struct mwSametimeGroup *g); 150 151 152 void mwSametimeGroup_setAlias(struct mwSametimeGroup *g, 153 const char *alias); 154 155 156 const char *mwSametimeGroup_getAlias(struct mwSametimeGroup *g); 157 158 159 void mwSametimeGroup_setOpen(struct mwSametimeGroup *g, gboolean open); 160 161 162 gboolean mwSametimeGroup_isOpen(struct mwSametimeGroup *g); 163 164 165 struct mwSametimeList *mwSametimeGroup_getList(struct mwSametimeGroup *g); 166 167 168 /** Get a GList snapshot of the users in a list */ 169 GList *mwSametimeGroup_getUsers(struct mwSametimeGroup *g); 170 171 172 struct mwSametimeUser * 173 mwSametimeGroup_findUser(struct mwSametimeGroup *g, 174 struct mwIdBlock *user); 175 176 177 /** Create a user in a group */ 178 struct mwSametimeUser * 179 mwSametimeUser_new(struct mwSametimeGroup *g, 180 enum mwSametimeUserType type, 181 struct mwIdBlock *user); 182 183 184 /** Remove user from its group, and free it */ 185 void mwSametimeUser_free(struct mwSametimeUser *u); 186 187 188 struct mwSametimeGroup *mwSametimeUser_getGroup(struct mwSametimeUser *u); 189 190 191 enum mwSametimeUserType mwSametimeUser_getType(struct mwSametimeUser *u); 192 193 194 const char *mwSametimeUser_getUser(struct mwSametimeUser *u); 195 196 197 const char *mwSametimeUser_getCommunity(struct mwSametimeUser *u); 198 199 200 void mwSametimeUser_setShortName(struct mwSametimeUser *u, const char *name); 201 202 203 const char *mwSametimeUser_getShortName(struct mwSametimeUser *u); 204 205 206 void mwSametimeUser_setAlias(struct mwSametimeUser *u, const char *alias); 207 208 209 const char *mwSametimeUser_getAlias(struct mwSametimeUser *u); 210 211 212 213 #ifdef __cplusplus 214 } 215 #endif 216 217 218 #endif /* _MW_ST_LIST_H */ 219