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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
|
/*
IRC plugin for Miranda IM
Copyright (C) 2003-05 Jurgen Persson
Copyright (C) 2007-09 George Hazan
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.
*/
#include "irc.h"
/////////////////////////////////////////////////////////////////////////////////////////
// 'User details' dialog
struct UserDetailsDlgProcParam
{
UserDetailsDlgProcParam( CIrcProto* _pro, HANDLE _info ) :
ppro( _pro ),
hContact( _info )
{}
CIrcProto* ppro;
HANDLE hContact;
};
#define STR_BASIC "Faster! Searches the network for an exact match of the nickname only. The hostmask is optional and provides further security if used. Wildcards (? and *) are allowed."
#define STR_ADVANCED "Slower! Searches the network for nicknames matching a wildcard string. The hostmask is mandatory and a minimum of 4 characters is necessary in the \"Nick\" field. Wildcards (? and *) are allowed."
#define STR_ERROR "Settings could not be saved!\n\nThe \"Nick\" field must contain at least four characters including wildcards,\n and it must also match the default nickname for this contact."
#define STR_ERROR2 "Settings could not be saved!\n\nA full hostmask must be set for this online detection mode to work."
INT_PTR CALLBACK UserDetailsDlgProc(HWND m_hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
UserDetailsDlgProcParam* p = ( UserDetailsDlgProcParam* )GetWindowLongPtr( m_hwnd, GWLP_USERDATA );
switch (msg) {
case WM_INITDIALOG:
p = new UserDetailsDlgProcParam( NULL, ( HANDLE )lParam );
SetWindowLongPtr( m_hwnd, GWLP_USERDATA, ( LPARAM )p );
break;
case WM_NOTIFY:
if ((( LPNMHDR )lParam )->idFrom == 0 && (( LPNMHDR )lParam )->code == PSN_PARAMCHANGED ) {
p->ppro = ( CIrcProto* )(( PSHNOTIFY* )lParam )->lParam;
DBVARIANT dbv;
BYTE bAdvanced = p->ppro->getByte( p->hContact, "AdvancedMode", 0);
TranslateDialogDefault( m_hwnd);
CheckDlgButton( m_hwnd, IDC_RADIO1, bAdvanced?BST_UNCHECKED:BST_CHECKED);
CheckDlgButton( m_hwnd, IDC_RADIO2, bAdvanced?BST_CHECKED:BST_UNCHECKED);
EnableWindow(GetDlgItem( m_hwnd, IDC_WILDCARD), bAdvanced);
if ( !bAdvanced ) {
SetDlgItemText( m_hwnd, IDC_DEFAULT, TranslateT(STR_BASIC));
if ( !p->ppro->getTString( p->hContact, "Default", &dbv)) {
SetDlgItemText( m_hwnd, IDC_WILDCARD, dbv.ptszVal);
DBFreeVariant(&dbv);
}
}
else {
SetDlgItemText( m_hwnd, IDC_DEFAULT, TranslateT(STR_ADVANCED));
if ( !p->ppro->getTString( p->hContact, "UWildcard", &dbv)) {
SetDlgItemText( m_hwnd, IDC_WILDCARD, dbv.ptszVal);
DBFreeVariant(&dbv);
} }
if ( !p->ppro->getTString( p->hContact, "UUser", &dbv)) {
SetDlgItemText( m_hwnd, IDC_USER, dbv.ptszVal);
DBFreeVariant(&dbv);
}
if ( !p->ppro->getTString( p->hContact, "UHost", &dbv)) {
SetDlgItemText( m_hwnd, IDC_HOST, dbv.ptszVal);
DBFreeVariant(&dbv);
}
ProtoBroadcastAck(p->ppro->m_szModuleName, p->hContact, ACKTYPE_GETINFO, ACKRESULT_SUCCESS, (HANDLE) 1, 0);
}
break;
case WM_COMMAND:
if (( LOWORD(wParam) == IDC_WILDCARD || LOWORD(wParam) == IDC_USER || LOWORD(wParam) == IDC_HOST ) &&
( HIWORD(wParam) != EN_CHANGE || (HWND)lParam != GetFocus()))
return true;
EnableWindow(GetDlgItem( m_hwnd, IDC_BUTTON), true);
EnableWindow(GetDlgItem( m_hwnd, IDC_BUTTON2), true);
if( HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == IDC_BUTTON ) {
TCHAR temp[500];
GetDlgItemText( m_hwnd, IDC_WILDCARD, temp, SIZEOF(temp));
DBVARIANT dbv;
BYTE bAdvanced = IsDlgButtonChecked( m_hwnd, IDC_RADIO1)?0:1;
if ( bAdvanced ) {
if ( GetWindowTextLength(GetDlgItem( m_hwnd, IDC_WILDCARD)) == 0 ||
GetWindowTextLength(GetDlgItem( m_hwnd, IDC_USER)) == 0 ||
GetWindowTextLength(GetDlgItem( m_hwnd, IDC_HOST)) == 0)
{
MessageBox( NULL, TranslateT(STR_ERROR2), TranslateT("IRC error"), MB_OK|MB_ICONERROR);
return FALSE;
}
if ( !p->ppro->getTString( p->hContact, "Default", &dbv )) {
CMString S = _T(STR_ERROR);
S += _T(" (");
S += dbv.ptszVal;
S += _T(")");
if (( lstrlen(temp) < 4 && lstrlen(temp)) || !WCCmp(CharLower(temp), CharLower(dbv.ptszVal))) {
MessageBox( NULL, TranslateTS( S.c_str()), TranslateT( "IRC error" ), MB_OK | MB_ICONERROR );
DBFreeVariant( &dbv );
return FALSE;
}
DBFreeVariant( &dbv );
}
GetDlgItemText( m_hwnd, IDC_WILDCARD, temp, SIZEOF(temp));
if ( lstrlen( GetWord(temp, 0).c_str()))
p->ppro->setTString( p->hContact, "UWildcard", GetWord(temp, 0).c_str());
else
DBDeleteContactSetting( p->hContact, p->ppro->m_szModuleName, "UWildcard");
}
p->ppro->setByte( p->hContact, "AdvancedMode", bAdvanced);
GetDlgItemText( m_hwnd, IDC_USER, temp, SIZEOF(temp));
if (lstrlen(GetWord(temp, 0).c_str()))
p->ppro->setTString( p->hContact, "UUser", GetWord(temp, 0).c_str());
else
DBDeleteContactSetting( p->hContact, p->ppro->m_szModuleName, "UUser");
GetDlgItemText( m_hwnd, IDC_HOST, temp, SIZEOF(temp));
if (lstrlen(GetWord(temp, 0).c_str()))
p->ppro->setTString( p->hContact, "UHost", GetWord(temp, 0).c_str());
else
DBDeleteContactSetting( p->hContact, p->ppro->m_szModuleName, "UHost");
EnableWindow(GetDlgItem( m_hwnd, IDC_BUTTON), FALSE);
}
if ( HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == IDC_BUTTON2 ) {
if ( IsDlgButtonChecked( m_hwnd, IDC_RADIO2 ))
SetDlgItemTextA( m_hwnd, IDC_WILDCARD, "");
SetDlgItemTextA( m_hwnd, IDC_HOST, "" );
SetDlgItemTextA( m_hwnd, IDC_USER, "" );
DBDeleteContactSetting( p->hContact, p->ppro->m_szModuleName, "UWildcard");
DBDeleteContactSetting( p->hContact, p->ppro->m_szModuleName, "UUser");
DBDeleteContactSetting( p->hContact, p->ppro->m_szModuleName, "UHost");
EnableWindow(GetDlgItem( m_hwnd, IDC_BUTTON), FALSE );
EnableWindow(GetDlgItem( m_hwnd, IDC_BUTTON2), FALSE );
}
if ( HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == IDC_RADIO1 ) {
SetDlgItemText( m_hwnd, IDC_DEFAULT, TranslateT(STR_BASIC));
DBVARIANT dbv;
if ( !p->ppro->getTString( p->hContact, "Default", &dbv )) {
SetDlgItemText( m_hwnd, IDC_WILDCARD, dbv.ptszVal );
DBFreeVariant( &dbv );
}
EnableWindow(GetDlgItem( m_hwnd, IDC_WILDCARD), FALSE );
}
if ( HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == IDC_RADIO2 ) {
DBVARIANT dbv;
SetDlgItemText( m_hwnd, IDC_DEFAULT, TranslateT(STR_ADVANCED));
if ( !p->ppro->getTString( p->hContact, "UWildcard", &dbv )) {
SetDlgItemText( m_hwnd, IDC_WILDCARD, dbv.ptszVal );
DBFreeVariant( &dbv );
}
EnableWindow(GetDlgItem( m_hwnd, IDC_WILDCARD), true);
}
break;
}
return FALSE;
}
int __cdecl CIrcProto::OnInitUserInfo(WPARAM wParam, LPARAM lParam)
{
char* szProto = ( char* )CallService( MS_PROTO_GETCONTACTBASEPROTO, lParam, 0);
HANDLE hContact = (HANDLE) lParam;
if ( !hContact || !szProto || lstrcmpiA( szProto, m_szModuleName ))
return 0;
if ( getByte( hContact, "ChatRoom", 0 ) != 0 )
return 0;
if ( getByte( hContact, "DCC", 0 ) != 0 )
return 0;
DBVARIANT dbv;
if ( !getTString( hContact, "Default", &dbv )) {
if ( IsChannel( dbv.ptszVal )) {
DBFreeVariant( &dbv );
return 0;
}
DBFreeVariant(&dbv);
}
OPTIONSDIALOGPAGE odp = { 0 };
odp.cbSize = sizeof(odp);
odp.flags = ODPF_DONTTRANSLATE;
odp.pszTitle = m_szModuleName;
odp.hIcon = NULL;
odp.dwInitParam = ( LPARAM )this;
odp.hInstance = hInst;
odp.position = -1900000000;
odp.pfnDlgProc = UserDetailsDlgProc;
odp.pszTemplate = MAKEINTRESOURCEA(IDD_USERINFO);
odp.pszTitle = m_szModuleName;
CallService( MS_USERINFO_ADDPAGE, wParam, (LPARAM) & odp);
return 0;
}
|