1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
|
// ---------------------------------------------------------------------------80
// ICQ plugin for Miranda Instant Messenger
// ________________________________________
//
// Copyright © 2000-2001 Richard Hughes, Roland Rabien, Tristan Van de Vreede
// Copyright © 2001-2002 Jon Keating, Richard Hughes
// Copyright © 2002-2004 Martin Öberg, Sam Kothari, Robert Rainwater
// Copyright © 2004-2008 Joe Kucera, Bio
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
// -----------------------------------------------------------------------------
//
// File name : $URL: http://miranda.googlecode.com/svn/trunk/miranda/protocols/IcqOscarJ/icq_advsearch.cpp $
// Revision : $Revision: 14148 $
// Last change on : $Date: 2012-03-10 00:01:01 +0200 (Сб, 10 мар 2012) $
// Last change by : $Author: george.hazan $
//
// DESCRIPTION:
//
// Describe me here please...
//
// -----------------------------------------------------------------------------
#include "icqoscar.h"
static void InitComboBox(HWND hwndCombo, const FieldNamesItem *names)
{
int iItem;
int i;
iItem = ComboBoxAddStringUtf(hwndCombo, NULL, 0);
SendMessage(hwndCombo, CB_SETCURSEL, iItem, 0);
if (names){
for (i = 0; names[i].text; i++) {
iItem = ComboBoxAddStringUtf(hwndCombo, names[i].text, names[i].code);
}
}
else {
int ctryCount;
struct CountryListEntry *countries;
CallService( MS_UTILS_GETCOUNTRYLIST, ( WPARAM )&ctryCount, ( LPARAM )&countries );
for (i = 0; i < ctryCount; i++) {
if (countries[i].id != 0xFFFF && countries[i].id != 0)
iItem = ComboBoxAddStringUtf(hwndCombo, LPGEN(countries[i].szName), countries[i].id);
}
}
}
INT_PTR CALLBACK AdvancedSearchDlgProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
switch(message)
{
case WM_INITDIALOG:
TranslateDialogDefault(hwndDlg);
InitComboBox(GetDlgItem(hwndDlg, IDC_GENDER), genderField);
InitComboBox(GetDlgItem(hwndDlg, IDC_AGERANGE), agesField);
InitComboBox(GetDlgItem(hwndDlg, IDC_MARITALSTATUS), maritalField);
InitComboBox(GetDlgItem(hwndDlg, IDC_WORKFIELD), occupationField);
InitComboBox(GetDlgItem(hwndDlg, IDC_ORGANISATION), affiliationField);
InitComboBox(GetDlgItem(hwndDlg, IDC_LANGUAGE), languageField);
InitComboBox(GetDlgItem(hwndDlg, IDC_COUNTRY), countryField);
InitComboBox(GetDlgItem(hwndDlg, IDC_INTERESTSCAT), interestsField);
InitComboBox(GetDlgItem(hwndDlg, IDC_PASTCAT), pastField);
return TRUE;
case WM_COMMAND:
{
switch(LOWORD(wParam))
{
case IDOK:
SendMessage(GetParent(hwndDlg), WM_COMMAND, MAKEWPARAM(IDOK, BN_CLICKED), (LPARAM)GetDlgItem(GetParent(hwndDlg), IDOK));
break;
case IDCANCEL:
// CheckDlgButton(GetParent(hwndDlg),IDC_ADVANCED,BST_UNCHECKED);
// SendMessage(GetParent(hwndDlg),WM_COMMAND,MAKEWPARAM(IDC_ADVANCED,BN_CLICKED),(LPARAM)GetDlgItem(GetParent(hwndDlg),IDC_ADVANCED));
break;
default:
break;
}
break;
}
default:
break;
}
return FALSE;
}
static DWORD getCurItemData(HWND hwndDlg, UINT iCtrl)
{
return SendDlgItemMessage(hwndDlg, iCtrl, CB_GETITEMDATA, SendDlgItemMessage(hwndDlg, iCtrl, CB_GETCURSEL, 0, 0), 0);
}
static void searchPackTLVLNTS(PBYTE *buf, int *buflen, HWND hwndDlg, UINT idControl, WORD wType)
{
char str[512];
GetDlgItemTextA(hwndDlg, idControl, str, sizeof(str));
ppackLETLVLNTS(buf, buflen, str, wType, 0);
}
static void searchPackTLVWordLNTS(PBYTE *buf, int *buflen, HWND hwndDlg, UINT idControl, WORD w, WORD wType)
{
char str[512];
GetDlgItemTextA(hwndDlg, idControl, str, sizeof(str));
ppackLETLVWordLNTS(buf, buflen, w, str, wType, 0);
}
static PBYTE createAdvancedSearchStructureTLV(HWND hwndDlg, int *length)
{
PBYTE buf = NULL;
int buflen = 0;
ppackLEWord(&buf, &buflen, META_SEARCH_GENERIC); /* subtype: full search */
searchPackTLVLNTS(&buf, &buflen, hwndDlg, IDC_FIRSTNAME, TLV_FIRSTNAME);
searchPackTLVLNTS(&buf, &buflen, hwndDlg, IDC_LASTNAME, TLV_LASTNAME);
searchPackTLVLNTS(&buf, &buflen, hwndDlg, IDC_NICK, TLV_NICKNAME);
searchPackTLVLNTS(&buf, &buflen, hwndDlg, IDC_EMAIL, TLV_EMAIL);
searchPackTLVLNTS(&buf, &buflen, hwndDlg, IDC_CITY, TLV_CITY);
searchPackTLVLNTS(&buf, &buflen, hwndDlg, IDC_STATE, TLV_STATE);
searchPackTLVLNTS(&buf, &buflen, hwndDlg, IDC_COMPANY, TLV_COMPANY);
searchPackTLVLNTS(&buf, &buflen, hwndDlg, IDC_DEPARTMENT, TLV_DEPARTMENT);
searchPackTLVLNTS(&buf, &buflen, hwndDlg, IDC_POSITION, TLV_POSITION);
searchPackTLVLNTS(&buf, &buflen, hwndDlg, IDC_KEYWORDS, TLV_KEYWORDS);
ppackLETLVDWord(&buf, &buflen, (DWORD)getCurItemData(hwndDlg, IDC_AGERANGE), TLV_AGERANGE, 0);
BYTE b = (BYTE)getCurItemData(hwndDlg, IDC_GENDER);
switch (b) {
case 'F': b = 1; break;
case 'M': b = 2; break;
default: b = 0;
};
ppackLETLVByte(&buf, &buflen, b, TLV_GENDER, 0);
ppackLETLVByte(&buf, &buflen, (BYTE)getCurItemData(hwndDlg, IDC_MARITALSTATUS), TLV_MARITAL, 0);
ppackLETLVWord(&buf, &buflen, (WORD)getCurItemData(hwndDlg, IDC_LANGUAGE), TLV_LANGUAGE, 0);
ppackLETLVWord(&buf, &buflen, (WORD)getCurItemData(hwndDlg, IDC_COUNTRY), TLV_COUNTRY, 0);
ppackLETLVWord(&buf, &buflen, (WORD)getCurItemData(hwndDlg, IDC_WORKFIELD), TLV_OCUPATION, 0);
WORD w = (WORD)getCurItemData(hwndDlg, IDC_PASTCAT);
searchPackTLVWordLNTS(&buf, &buflen, hwndDlg, IDC_PASTKEY, w, TLV_PASTINFO);
w = (WORD)getCurItemData(hwndDlg, IDC_INTERESTSCAT);
searchPackTLVWordLNTS(&buf, &buflen, hwndDlg, IDC_INTERESTSKEY, w, TLV_INTERESTS);
w = (WORD)getCurItemData(hwndDlg, IDC_ORGANISATION);
searchPackTLVWordLNTS(&buf, &buflen, hwndDlg, IDC_ORGKEYWORDS, w, TLV_AFFILATIONS);
w = (WORD)getCurItemData(hwndDlg, IDC_HOMEPAGECAT);
if (w != 0xFFFF)
searchPackTLVWordLNTS(&buf, &buflen, hwndDlg, IDC_HOMEPAGEKEY, w, TLV_HOMEPAGE);
if (IsDlgButtonChecked(hwndDlg, IDC_ONLINEONLY))
ppackLETLVByte(&buf, &buflen, 1, TLV_ONLINEONLY, 1);
if (length)
*length = buflen;
return buf;
}
PBYTE createAdvancedSearchStructure(HWND hwndDlg, int *length)
{
if (!hwndDlg)
return NULL;
return createAdvancedSearchStructureTLV(hwndDlg, length);
}
|