Sun, 05 Jun 2005 02:50:13 +0000
[gaim-migrate @ 12790]
importing meanwhile library for use in the sametime plugin
| 10969 | 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_SRVC_RESOLVE_H | |
| 22 | #define _MW_SRVC_RESOLVE_H | |
| 23 | ||
| 24 | ||
| 25 | #include <glib.h> | |
| 26 | #include <glib/glist.h> | |
| 27 | ||
| 28 | ||
| 29 | /** Type identifier for the conference service */ | |
| 30 | #define SERVICE_RESOLVE 0x00000015 | |
| 31 | ||
| 32 | ||
| 33 | /** Return value of mwServiceResolve_search indicating an error */ | |
| 34 | #define SEARCH_ERROR 0x00 | |
| 35 | ||
| 36 | ||
| 37 | /** @struct mwServiceResolve | |
| 38 | User lookup service */ | |
| 39 | struct mwServiceResolve; | |
| 40 | ||
| 41 | ||
| 42 | enum mwResolveFlag { | |
| 43 | /** return unique results or none at all */ | |
| 44 | mwResolveFlag_UNIQUE = 0x00000001, | |
| 45 | ||
| 46 | /** return only the first result */ | |
| 47 | mwResolveFlag_FIRST = 0x00000002, | |
| 48 | ||
| 49 | /** search all directories, not just the first with a match */ | |
| 50 | mwResolveFlag_ALL_DIRS = 0x00000004, | |
| 51 | ||
| 52 | /** search for users */ | |
| 53 | mwResolveFlag_USERS = 0x00000008, | |
| 54 | ||
| 55 | /** search for groups */ | |
| 56 | mwResolveFlag_GROUPS = 0x00000010, | |
| 57 | }; | |
| 58 | ||
| 59 | ||
| 60 | /** @see mwResolveResult */ | |
| 61 | enum mwResolveCode { | |
| 62 | /** successful search */ | |
| 63 | mwResolveCode_SUCCESS = 0x00000000, | |
| 64 | ||
| 65 | /** only some of the nested searches were successful */ | |
| 66 | mwResolveCode_PARTIAL = 0x00010000, | |
| 67 | ||
| 68 | /** more than one result (occurs when mwResolveFlag_UNIQUE is used | |
| 69 | and more than one result would have been otherwise returned) */ | |
| 70 | mwResolveCode_MULTIPLE = 0x80020000, | |
| 71 | ||
| 72 | /** the name is not resolvable due to its format */ | |
| 73 | mwResolveCode_BAD_FORMAT = 0x80030000, | |
| 74 | }; | |
| 75 | ||
| 76 | ||
| 77 | enum mwResolveMatchType { | |
| 78 | mwResolveMatch_USER = 0x00000001, | |
| 79 | mwResolveMatch_GROUP = 0x00000002, | |
| 80 | }; | |
| 81 | ||
| 82 | ||
| 83 | struct mwResolveMatch { | |
| 84 | char *id; /**< user id */ | |
| 85 | char *name; /**< user name */ | |
| 86 | char *desc; /**< description */ | |
| 87 | guint32 type; /**< @see mwResolveMatchType */ | |
| 88 | }; | |
| 89 | ||
| 90 | ||
| 91 | struct mwResolveResult { | |
| 92 | guint32 code; /**< @see mwResolveCode */ | |
| 93 | char *name; /**< name of the result */ | |
| 94 | GList *matches; /**< list of mwResolveMatch */ | |
| 95 | }; | |
| 96 | ||
| 97 | ||
| 98 | /** Handle the results of a resolve request. If there was a cleanup | |
| 99 | function specified to mwServiceResolve_search, it will be called | |
| 100 | upon the user data after this callback returns. | |
| 101 | ||
| 102 | @param srvc the resolve service | |
| 103 | @param id the resolve request ID | |
| 104 | @param code return code | |
| 105 | @param results list of mwResolveResult | |
| 106 | @param data optional user data attached to the request | |
| 107 | */ | |
| 108 | typedef void (*mwResolveHandler) | |
| 109 | (struct mwServiceResolve *srvc, | |
| 110 | guint32 id, guint32 code, GList *results, | |
| 111 | gpointer data); | |
| 112 | ||
| 113 | ||
| 114 | /** Allocate a new resolve service */ | |
| 115 | struct mwServiceResolve *mwServiceResolve_new(struct mwSession *); | |
| 116 | ||
| 117 | ||
| 118 | /** Inisitate a resolve request. | |
| 119 | ||
| 120 | @param queries list query strings | |
| 121 | @param flags search flags | |
| 122 | @param handler result handling function | |
| 123 | @param data optional user data attached to the request | |
| 124 | @param cleanup optional function to clean up user data | |
| 125 | @return generated ID for the search request, or SEARCH_ERROR | |
| 126 | */ | |
| 127 | guint32 mwServiceResolve_resolve(struct mwServiceResolve *srvc, | |
| 128 | GList *queries, enum mwResolveFlag flags, | |
| 129 | mwResolveHandler handler, | |
| 130 | gpointer data, GDestroyNotify cleanup); | |
| 131 | ||
| 132 | ||
| 133 | /** Cancel a resolve request by its generated ID. The handler function | |
| 134 | will not be called, and the optional cleanup function will be | |
| 135 | called upon the optional user data for the request */ | |
| 136 | void mwServiceResolve_cancelResolve(struct mwServiceResolve *, guint32); | |
| 137 | ||
| 138 | ||
| 139 | #endif |