Sun, 20 May 2007 06:19:49 +0000
merge of 'b98e72d4089afb8a1879e5fe9627cfb132ee88de'
and 'b2836a24d81e7a1bd1d21b3aea8794b094391344'
| 11414 | 1 | /** |
| 2 | * @file search.h | |
| 3 | * | |
| 4 | * gaim | |
| 5 | * | |
| 6 | * Copyright (C) 2005 Bartosz Oler <bartosz@bzimage.us> | |
| 7 | * | |
| 8 | * This program is free software; you can redistribute it and/or modify | |
| 9 | * it under the terms of the GNU General Public License as published by | |
| 10 | * the Free Software Foundation; either version 2 of the License, or | |
| 11 | * (at your option) any later version. | |
| 12 | * | |
| 13 | * This program is distributed in the hope that it will be useful, | |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 16 | * GNU General Public License for more details. | |
| 17 | * | |
| 18 | * You should have received a copy of the GNU General Public License | |
| 19 | * along with this program; if not, write to the Free Software | |
| 20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
| 21 | */ | |
| 22 | ||
| 23 | ||
| 24 | #ifndef _GAIM_GG_SEARCH_H | |
| 25 | #define _GAIM_GG_SEARCH_H | |
| 26 | ||
| 27 | #include "connection.h" | |
| 28 | ||
| 13318 | 29 | #include <libgadu.h> |
| 11414 | 30 | #include "gg.h" |
| 31 | ||
| 32 | ||
| 13641 | 33 | typedef enum { |
| 34 | GGP_SEARCH_TYPE_INFO, | |
| 35 | GGP_SEARCH_TYPE_FULL | |
| 36 | ||
| 37 | } GGPSearchType; | |
| 38 | ||
| 11414 | 39 | typedef struct { |
| 40 | ||
| 41 | char *uin; | |
| 42 | char *lastname; | |
| 43 | char *firstname; | |
| 44 | char *nickname; | |
| 45 | char *city; | |
| 46 | char *birthyear; | |
| 47 | char *gender; | |
| 48 | char *active; | |
| 49 | char *offset; | |
| 50 | ||
| 51 | char *last_uin; | |
| 52 | ||
| 13641 | 53 | GGPSearchType search_type; |
| 54 | guint32 seq; | |
| 55 | ||
| 56 | void *user_data; | |
| 57 | void *window; | |
| 11414 | 58 | } GGPSearchForm; |
| 59 | ||
| 13641 | 60 | typedef GHashTable GGPSearches; |
| 61 | ||
| 62 | ||
| 11414 | 63 | /** |
| 64 | * Create a new GGPSearchForm structure, and set the fields | |
| 65 | * to the sane defaults. | |
| 66 | * | |
| 67 | * @return Newly allocated GGPSearchForm. | |
| 68 | */ | |
| 69 | GGPSearchForm * | |
| 13641 | 70 | ggp_search_form_new(GGPSearchType st); |
| 71 | ||
| 72 | /** | |
| 73 | * Destroy a Search Form. | |
| 74 | * | |
| 75 | * @param form Search Form to destroy. | |
| 76 | */ | |
| 77 | void | |
| 78 | ggp_search_form_destroy(GGPSearchForm *form); | |
| 79 | ||
| 80 | /** | |
| 81 | * Add a search to the list of searches. | |
| 82 | * | |
| 83 | * @param searches The list of searches. | |
| 84 | * @param seq Search (form) ID number. | |
| 85 | * @param form The search form to add. | |
| 86 | */ | |
| 87 | void | |
| 88 | ggp_search_add(GGPSearches *searches, guint32 seq, GGPSearchForm *form); | |
| 89 | ||
| 90 | /** | |
| 91 | * Remove a search from the list. | |
| 92 | * | |
| 93 | * If you want to destory the search completely also call: | |
| 94 | * ggp_search_form_destroy(). | |
| 95 | * | |
| 96 | * @param searches The list of searches. | |
| 97 | * @param seq ID number of the search. | |
| 98 | */ | |
| 99 | void | |
| 100 | ggp_search_remove(GGPSearches *searches, guint32 seq); | |
| 101 | ||
| 102 | /** | |
| 103 | * Return the search with the specified ID. | |
| 104 | * | |
| 105 | * @param searches The list of searches. | |
| 106 | * @param seq ID number of the search. | |
| 107 | */ | |
| 108 | GGPSearchForm * | |
| 109 | ggp_search_get(GGPSearches *searches, guint32 seq); | |
| 110 | ||
| 111 | /** | |
| 112 | * Create a new GGPSearches structure. | |
| 113 | * | |
| 114 | * @return GGPSearches instance. | |
| 115 | */ | |
| 116 | GGPSearches * | |
| 117 | ggp_search_new(void); | |
| 118 | ||
| 119 | /** | |
| 120 | * Destroy GGPSearches instance. | |
| 121 | * | |
| 122 | * @param searches GGPSearches instance. | |
| 123 | */ | |
| 124 | void | |
| 125 | ggp_search_destroy(GGPSearches *searches); | |
| 11414 | 126 | |
| 127 | /** | |
| 128 | * Initiate a search in the public directory. | |
| 129 | * | |
| 130 | * @param gc GaimConnection. | |
| 131 | * @param form Filled in GGPSearchForm. | |
| 13641 | 132 | * |
| 133 | * @return Sequence number of a search or 0 if an error occured. | |
| 11414 | 134 | */ |
| 13641 | 135 | guint32 |
| 11414 | 136 | ggp_search_start(GaimConnection *gc, GGPSearchForm *form); |
| 137 | ||
| 138 | /* | |
| 139 | * Return converted to the UTF-8 value of the specified field. | |
| 140 | * | |
| 12007 | 141 | * @param res Public directory look-up result. |
| 142 | * @param num Id of the record. | |
| 143 | * @param fileld Name of the field. | |
| 11414 | 144 | * |
| 12007 | 145 | * @return UTF-8 encoded value of the field. |
| 11414 | 146 | */ |
| 147 | char * | |
| 148 | ggp_search_get_result(gg_pubdir50_t res, int num, const char *field); | |
| 149 | ||
| 150 | ||
| 151 | #endif /* _GAIM_GG_SEARCH_H */ | |
| 152 | ||
| 12007 | 153 | /* vim: set ts=8 sts=0 sw=8 noet: */ |