Thu, 22 Sep 2005 22:20:21 +0000
[gaim-migrate @ 13831]
Default type of the outgoing messages is CHAT.
| 11414 | 1 | /** |
| 2 | * @file search.c | |
| 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 | #include "lib/libgadu.h" | |
| 25 | ||
| 26 | #include "utils.h" | |
| 27 | #include "search.h" | |
| 28 | ||
| 29 | /* GGPSearchForm *ggp_search_form_new() {{{ */ | |
| 30 | GGPSearchForm *ggp_search_form_new() | |
| 31 | { | |
| 32 | GGPSearchForm *form; | |
| 33 | ||
| 34 | form = g_new0(GGPSearchForm, 1); | |
| 35 | form->uin = NULL; | |
| 36 | form->lastname = NULL; | |
| 37 | form->firstname = NULL; | |
| 38 | form->nickname = NULL; | |
| 39 | form->city = NULL; | |
| 40 | form->birthyear = NULL; | |
| 41 | form->gender = NULL; | |
| 42 | form->active = NULL; | |
| 43 | form->offset = NULL; | |
| 44 | ||
| 45 | form->last_uin = NULL; | |
| 46 | ||
| 47 | return form; | |
| 48 | } | |
| 49 | /* }}} */ | |
| 50 | ||
| 51 | /* void ggp_search_start(GaimConnection *gc, GGPSearchForm *form) {{{ */ | |
| 52 | void ggp_search_start(GaimConnection *gc, GGPSearchForm *form) | |
| 53 | { | |
| 54 | GGPInfo *info = gc->proto_data; | |
| 55 | gg_pubdir50_t req; | |
| 56 | ||
| 57 | gaim_debug_info("gg", "It's time to perform a search...\n"); | |
| 58 | ||
| 59 | if ((req = gg_pubdir50_new(GG_PUBDIR50_SEARCH)) == NULL) { | |
| 60 | gaim_debug_error("gg", "ggp_bmenu_show_details: Unable to create req variable.\n"); | |
| 61 | return; | |
| 62 | } | |
| 63 | ||
| 64 | if (form->uin != NULL) { | |
| 65 | gaim_debug_info("gg", " uin: %s\n", form->uin); | |
| 66 | gg_pubdir50_add(req, GG_PUBDIR50_UIN, form->uin); | |
| 67 | } else { | |
| 68 | if (form->lastname != NULL) { | |
| 69 | gaim_debug_info("gg", " lastname: %s\n", form->lastname); | |
| 70 | gg_pubdir50_add(req, GG_PUBDIR50_LASTNAME, form->lastname); | |
| 71 | } | |
| 72 | ||
| 73 | if (form->firstname != NULL) { | |
| 74 | gaim_debug_info("gg", " firstname: %s\n", form->firstname); | |
| 75 | gg_pubdir50_add(req, GG_PUBDIR50_FIRSTNAME, form->firstname); | |
| 76 | } | |
| 77 | ||
| 78 | if (form->nickname != NULL) { | |
| 79 | gaim_debug_info("gg", " nickname: %s\n", form->nickname); | |
| 80 | gg_pubdir50_add(req, GG_PUBDIR50_NICKNAME, form->nickname); | |
| 81 | } | |
| 82 | ||
| 83 | if (form->city != NULL) { | |
| 84 | gaim_debug_info("gg", " city: %s\n", form->city); | |
| 85 | gg_pubdir50_add(req, GG_PUBDIR50_CITY, form->city); | |
| 86 | } | |
| 87 | ||
| 88 | if (form->birthyear != NULL) { | |
| 89 | gaim_debug_info("gg", " birthyear: %s\n", form->birthyear); | |
| 90 | gg_pubdir50_add(req, GG_PUBDIR50_BIRTHYEAR, form->birthyear); | |
| 91 | } | |
| 92 | ||
| 93 | if (form->gender != NULL) { | |
| 94 | gaim_debug_info("gg", " gender: %s\n", form->gender); | |
| 95 | gg_pubdir50_add(req, GG_PUBDIR50_GENDER, form->gender); | |
| 96 | } | |
| 97 | ||
| 98 | if (form->active != NULL) { | |
| 99 | gaim_debug_info("gg", " active: %s\n", form->active); | |
| 100 | gg_pubdir50_add(req, GG_PUBDIR50_ACTIVE, form->active); | |
| 101 | } | |
| 102 | } | |
| 103 | ||
| 104 | gaim_debug_info("gg", "offset: %s\n", form->offset); | |
| 105 | gg_pubdir50_add(req, GG_PUBDIR50_START, g_strdup(form->offset)); | |
| 106 | ||
| 107 | if (gg_pubdir50(info->session, req) == 0) { | |
| 108 | gaim_debug_warning("gg", "ggp_bmenu_show_details: Search failed.\n"); | |
| 109 | return; | |
| 110 | } | |
| 111 | ||
| 112 | gg_pubdir50_free(req); | |
| 113 | } | |
| 114 | /* }}} */ | |
| 115 | ||
| 116 | /* char *ggp_search_get_result(gg_pubdir50_t res, int num, const char *field) {{{ */ | |
| 117 | char *ggp_search_get_result(gg_pubdir50_t res, int num, const char *field) | |
| 118 | { | |
| 119 | char *tmp; | |
| 120 | ||
| 121 | tmp = charset_convert(gg_pubdir50_get(res, num, field), "CP1250", "UTF-8"); | |
| 122 | ||
| 123 | return (tmp == NULL) ? g_strdup("") : tmp; | |
| 124 | } | |
| 125 | /* }}} */ | |
| 126 | ||
| 127 | ||
| 128 | /* vim: set ts=4 sts=0 sw=4 noet: */ |