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
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
|
/*
* $Id: options.cpp 12038 2010-06-21 16:46:22Z gena01 $
*
* myYahoo Miranda Plugin
*
* Authors: Gennady Feldman (aka Gena01)
* Laurent Marechal (aka Peorth)
*
* This code is under GPL and is based on AIM, MSN and Miranda source code.
* I want to thank Robert Rainwater and George Hazan for their code and support
* and for answering some of my questions during development of this plugin.
*/
#include "yahoo.h"
#include "resource.h"
#include <shlwapi.h>
#include <m_langpack.h>
#include <m_utils.h>
#include <m_options.h>
#include <m_popup.h>
#include "ignore.h"
/*
* DlgProcYahooOpts - Account Options Dialog
*/
static INT_PTR CALLBACK DlgProcYahooOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
DBVARIANT dbv;
CYahooProto* ppro = (CYahooProto*)GetWindowLongPtr( hwndDlg, GWLP_USERDATA );
switch ( msg ) {
case WM_INITDIALOG:
TranslateDialogDefault( hwndDlg );
ppro = (CYahooProto*)lParam;
SetWindowLongPtr( hwndDlg, GWLP_USERDATA, lParam );
if ( !ppro->GetString( YAHOO_LOGINID, &dbv )) {
SetDlgItemTextA(hwndDlg,IDC_HANDLE,dbv.pszVal);
DBFreeVariant(&dbv);
}
if ( !ppro->GetString( "Nick", &dbv )) {
SetDlgItemTextA(hwndDlg,IDC_NICK,dbv.pszVal);
DBFreeVariant(&dbv);
}
if ( !ppro->GetString( YAHOO_PASSWORD, &dbv )) {
//bit of a security hole here, since it's easy to extract a password from an edit box
YAHOO_CallService( MS_DB_CRYPT_DECODESTRING, strlen( dbv.pszVal )+1, ( LPARAM )dbv.pszVal );
SetDlgItemTextA( hwndDlg, IDC_PASSWORD, dbv.pszVal );
DBFreeVariant( &dbv );
}
//SetButtonCheck( hwndDlg, IDC_DISABLE_UTF8, ppro->GetByte( "DisableUTF8", 0 ));
SetButtonCheck( hwndDlg, IDC_USE_YAB, ppro->GetByte( "UseYAB", 1 ));
SetButtonCheck( hwndDlg, IDC_SHOW_AVATARS, ppro->GetByte( "ShowAvatars", 1 ));
SetButtonCheck( hwndDlg, IDC_MAIL_AUTOLOGIN, ppro->GetByte( "MailAutoLogin", 1 ));
SetButtonCheck( hwndDlg, IDC_DISABLEYAHOOMAIL, !ppro->GetByte( "DisableYahoomail", 0 ));
SetButtonCheck( hwndDlg, IDC_SHOW_ERRORS, ppro->GetByte( "ShowErrors", 1 ));
return TRUE;
case WM_COMMAND:
switch ( LOWORD( wParam )) {
case IDC_NEWYAHOOACCOUNTLINK:
YAHOO_CallService( MS_UTILS_OPENURL, 1,
ppro->GetByte( "YahooJapan", 0 ) ?
(LPARAM)"http://edit.yahoo.co.jp/config/eval_register" :
(LPARAM)"http://edit.yahoo.com/config/eval_register" );
return TRUE;
//case IDC_DISABLE_UTF8:
case IDC_USE_YAB:
case IDC_SHOW_AVATARS:
case IDC_MAIL_AUTOLOGIN:
case IDC_SHOW_ERRORS:
case IDC_DISABLEYAHOOMAIL:
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
break;
}
if ( HIWORD( wParam ) == EN_CHANGE && ( HWND )lParam == GetFocus())
switch( LOWORD( wParam )) {
case IDC_HANDLE:
case IDC_PASSWORD:
case IDC_NICK:
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
}
break;
case WM_NOTIFY:
if (((LPNMHDR)lParam)->code == (UINT) PSN_APPLY ) {
BOOL reconnectRequired = FALSE;
char str[128];
GetDlgItemTextA( hwndDlg, IDC_HANDLE, str, sizeof( str ));
dbv.pszVal = NULL;
if ( ppro->GetString( YAHOO_LOGINID, &dbv ) || lstrcmpA( str, dbv.pszVal ))
reconnectRequired = TRUE;
if ( dbv.pszVal != NULL )
DBFreeVariant( &dbv );
ppro->SetString( YAHOO_LOGINID, str );
GetDlgItemTextA( hwndDlg, IDC_PASSWORD, str, sizeof( str ));
YAHOO_CallService( MS_DB_CRYPT_ENCODESTRING, sizeof( str ),( LPARAM )str );
dbv.pszVal = NULL;
if ( ppro->GetString( YAHOO_PASSWORD, &dbv ) || lstrcmpA( str, dbv.pszVal ))
reconnectRequired = TRUE;
if ( dbv.pszVal != NULL )
DBFreeVariant( &dbv );
ppro->SetString( YAHOO_PASSWORD, str );
GetDlgItemTextA( hwndDlg, IDC_NICK, str, sizeof( str ));
if (str[0] == '\0') {
/* Check for empty Nick, if so delete the key in the DB */
DBDeleteContactSetting( NULL, ppro->m_szModuleName, "Nick" );
} else {
/* otherwise save the new Nick */
ppro->SetString( "Nick", str );
}
//ppro->SetByte("DisableUTF8", ( BYTE )IsDlgButtonChecked( hwndDlg, IDC_DISABLE_UTF8 ));
ppro->SetByte("UseYAB", ( BYTE )IsDlgButtonChecked( hwndDlg, IDC_USE_YAB ));
ppro->SetByte("ShowAvatars", ( BYTE )IsDlgButtonChecked( hwndDlg, IDC_SHOW_AVATARS ));
ppro->SetByte("MailAutoLogin", ( BYTE )IsDlgButtonChecked( hwndDlg, IDC_MAIL_AUTOLOGIN ));
ppro->SetByte("DisableYahoomail", ( BYTE )!IsDlgButtonChecked( hwndDlg, IDC_DISABLEYAHOOMAIL ));
ppro->SetByte("ShowErrors", ( BYTE )IsDlgButtonChecked( hwndDlg, IDC_SHOW_ERRORS ));
if (reconnectRequired ) {
DBDeleteContactSetting(NULL, ppro->m_szModuleName, YAHOO_PWTOKEN);
}
/*if ( restartRequired )
MessageBoxA( hwndDlg, Translate( "The changes you have made require you to restart Miranda IM before they take effect"), Translate("YAHOO Options"), MB_OK );
else */
if ( reconnectRequired && ppro->m_bLoggedIn )
MessageBoxA( hwndDlg, Translate( "The changes you have made require you to reconnect to the Yahoo network before they take effect"), Translate("YAHOO Options"), MB_OK );
return TRUE;
}
break;
}
return FALSE;
}
/*
* DlgProcYahooOpts - Connection Options Dialog
*/
static INT_PTR CALLBACK DlgProcYahooOptsConn(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
DBVARIANT dbv;
CYahooProto* ppro = (CYahooProto*)GetWindowLongPtr( hwndDlg, GWLP_USERDATA );
switch ( msg ) {
case WM_INITDIALOG:
TranslateDialogDefault( hwndDlg );
ppro = ( CYahooProto* )lParam;
SetWindowLongPtr( hwndDlg, GWLP_USERDATA, lParam );
if ( !ppro->GetString( YAHOO_LOGINSERVER, &dbv )) {
SetDlgItemTextA( hwndDlg, IDC_LOGINSERVER, dbv.pszVal );
DBFreeVariant( &dbv );
}
else SetDlgItemTextA( hwndDlg, IDC_LOGINSERVER,
ppro->GetByte( "YahooJapan", 0 )
? YAHOO_DEFAULT_JAPAN_LOGIN_SERVER
: YAHOO_DEFAULT_LOGIN_SERVER );
SetDlgItemInt( hwndDlg, IDC_YAHOOPORT, ppro->GetWord( NULL, YAHOO_LOGINPORT, YAHOO_DEFAULT_PORT ), FALSE );
SetButtonCheck( hwndDlg, IDC_YAHOO_JAPAN, ppro->GetByte( "YahooJapan", 0 ));
return TRUE;
case WM_COMMAND:
switch ( LOWORD( wParam )) {
case IDC_RESETSERVER:
SetDlgItemTextA( hwndDlg, IDC_LOGINSERVER, YAHOO_DEFAULT_LOGIN_SERVER );
SetDlgItemInt( hwndDlg, IDC_YAHOOPORT, YAHOO_DEFAULT_PORT, FALSE );
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
break;
case IDC_YAHOO_JAPAN:
SetDlgItemTextA( hwndDlg, IDC_LOGINSERVER,
(IsDlgButtonChecked(hwndDlg,IDC_YAHOO_JAPAN)==BST_CHECKED) ?
YAHOO_DEFAULT_JAPAN_LOGIN_SERVER :
YAHOO_DEFAULT_LOGIN_SERVER );
// fall through and enable apply button
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
break;
}
if ( HIWORD( wParam ) == EN_CHANGE && ( HWND )lParam == GetFocus())
switch( LOWORD( wParam )) {
case IDC_LOGINSERVER:
case IDC_YAHOOPORT:
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
}
break;
case WM_NOTIFY:
if (((LPNMHDR)lParam)->code == PSN_APPLY )
{
BOOL reconnectRequired = FALSE/*, restartRequired = FALSE*/;
char str[128];
DBVARIANT dbv;
int port;
GetDlgItemTextA( hwndDlg, IDC_LOGINSERVER, str, sizeof( str ));
if ( ppro->GetString( YAHOO_LOGINSERVER, &dbv ) || lstrcmpA( str, dbv.pszVal ))
reconnectRequired = TRUE;
if ( dbv.pszVal != NULL )
DBFreeVariant( &dbv );
ppro->SetString( YAHOO_LOGINSERVER, str );
port = GetDlgItemInt( hwndDlg, IDC_YAHOOPORT, NULL, FALSE );
if ( ppro->GetWord(NULL, YAHOO_LOGINPORT, -1) != port)
reconnectRequired = TRUE;
ppro->SetWord( NULL, YAHOO_LOGINPORT, port);
ppro->SetByte("YahooJapan", ( BYTE )IsDlgButtonChecked( hwndDlg, IDC_YAHOO_JAPAN ));
/*if ( restartRequired )
MessageBoxA( hwndDlg, Translate( "The changes you have made require you to restart Miranda IM before they take effect"), Translate("YAHOO Options"), MB_OK );
else */
if ( reconnectRequired && ppro->m_bLoggedIn )
MessageBoxA( hwndDlg, Translate( "The changes you have made require you to reconnect to the Yahoo network before they take effect"), Translate("YAHOO Options"), MB_OK );
return TRUE;
}
break;
}
return FALSE;
}
/*
* DlgProcYahooOpts - Connection Options Dialog
*/
static INT_PTR CALLBACK DlgProcYahooOptsIgnore(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
YList *l;
CYahooProto* ppro = (CYahooProto*)GetWindowLongPtr( hwndDlg, GWLP_USERDATA );
switch ( msg ) {
case WM_INITDIALOG:
TranslateDialogDefault( hwndDlg );
ppro = ( CYahooProto* )lParam;
SetWindowLongPtr( hwndDlg, GWLP_USERDATA, lParam );
if ( ppro->GetByte( "IgnoreUnknown", 0 )) {
CheckDlgButton(hwndDlg, IDC_OPT_IGN_UNKNOWN, 1);
EnableWindow( GetDlgItem(hwndDlg, IDC_IGN_ADD), 0);
EnableWindow( GetDlgItem(hwndDlg, IDC_IGN_REMOVE), 0);
EnableWindow( GetDlgItem(hwndDlg, IDC_YIGN_EDIT), 0);
EnableWindow( GetDlgItem(hwndDlg, IDC_YIGN_LIST), 0);
}
else CheckDlgButton(hwndDlg, IDC_OPT_IGN_LIST, 1);
/* show our current ignore list */
LOG(("[DlgProcYahooOptsIgnore] Grabbing current ignore list..."))
l = (YList *)ppro->GetIgnoreList();
while (l != NULL) {
struct yahoo_buddy *b = (struct yahoo_buddy *) l->data;
LOG(("[DlgProcYahooOptsIgnore] Buddy: %s", b->id ))
SendMessageA(GetDlgItem(hwndDlg,IDC_YIGN_LIST), LB_ADDSTRING, 0, (LPARAM)b->id);
l = l->next;
}
LOG(("[DlgProcYahooOptsIgnore] End of Ignore List..."))
return TRUE;
case WM_COMMAND:
switch ( LOWORD( wParam )) {
case IDC_OPT_IGN_UNKNOWN:
case IDC_OPT_IGN_LIST:
if (( HWND )lParam != GetFocus()) return 0;
EnableWindow( GetDlgItem(hwndDlg, IDC_IGN_ADD), LOWORD( wParam ) == IDC_OPT_IGN_LIST);
EnableWindow( GetDlgItem(hwndDlg, IDC_IGN_REMOVE), LOWORD( wParam ) == IDC_OPT_IGN_LIST);
EnableWindow( GetDlgItem(hwndDlg, IDC_YIGN_EDIT), LOWORD( wParam ) == IDC_OPT_IGN_LIST);
EnableWindow( GetDlgItem(hwndDlg, IDC_YIGN_LIST), LOWORD( wParam ) == IDC_OPT_IGN_LIST);
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
break;
case IDC_IGN_ADD:
if (!ppro->m_bLoggedIn)
MessageBoxA(hwndDlg, Translate("You need to be connected to Yahoo to add to Ignore List."), Translate("Yahoo Ignore"), MB_OK| MB_ICONINFORMATION);
else {
char id[128];
int i = GetDlgItemTextA( hwndDlg, IDC_YIGN_EDIT, id, sizeof( id ));
if (i < 3) {
MessageBoxA(hwndDlg, Translate("Please enter a valid buddy name to ignore."), Translate("Yahoo Ignore"), MB_OK| MB_ICONINFORMATION);
break;
}
i = SendMessageA(GetDlgItem(hwndDlg,IDC_YIGN_LIST), LB_FINDSTRINGEXACT,(WPARAM) -1, (LPARAM)id);
if (i != LB_ERR ) {
MessageBoxA(hwndDlg, Translate("The buddy is already on your ignore list. "), Translate("Yahoo Ignore"), MB_OK | MB_ICONINFORMATION);
break;
}
ppro->IgnoreBuddy(id, 0);
SendMessageA(GetDlgItem(hwndDlg,IDC_YIGN_LIST), LB_ADDSTRING, 0, (LPARAM)id);
SetDlgItemTextA( hwndDlg, IDC_YIGN_EDIT, "" );
}
break;
case IDC_IGN_REMOVE:
{
int i;
char id[128];
if (!ppro->m_bLoggedIn) {
MessageBoxA(hwndDlg, Translate("You need to be connected to Yahoo to remove from the Ignore List."), Translate("Yahoo Ignore"), MB_OK| MB_ICONINFORMATION);
break;
}
i = SendMessage(GetDlgItem(hwndDlg,IDC_YIGN_LIST), LB_GETCURSEL, 0, 0);
if (i == LB_ERR) {
MessageBoxA(hwndDlg, Translate("Please select a buddy on the ignore list to remove."), Translate("Yahoo Ignore"), MB_OK| MB_ICONINFORMATION);
break;
}
SendMessageA(GetDlgItem(hwndDlg,IDC_YIGN_LIST), LB_GETTEXT, i, (LPARAM)id);
ppro->IgnoreBuddy(id, 1);
SendMessage(GetDlgItem(hwndDlg,IDC_YIGN_LIST), LB_DELETESTRING, i, 0);
}
}
break;
case WM_NOTIFY:
if (((LPNMHDR)lParam)->code == PSN_APPLY ) {
ppro->SetByte("IgnoreUnknown", ( BYTE )IsDlgButtonChecked( hwndDlg, IDC_OPT_IGN_UNKNOWN ));
return TRUE;
}
break;
}
return FALSE;
}
/*
* YahooOptInit - initialize/register our Options w/ Miranda.
*/
int __cdecl CYahooProto::OnOptionsInit(WPARAM wParam,LPARAM lParam)
{
OPTIONSDIALOGPAGE odp = { 0 };
odp.cbSize = sizeof(odp);
odp.position = -790000000;
odp.hInstance = hInstance;
odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_YAHOO);
odp.ptszTitle = m_tszUserName;
odp.flags = ODPF_BOLDGROUPS | ODPF_TCHAR | ODPF_DONTTRANSLATE;
odp.ptszGroup = LPGENT("Network");
odp.ptszTab = LPGENT("Account");
odp.pfnDlgProc = DlgProcYahooOpts;
odp.dwInitParam = LPARAM(this);
Options_AddPage(wParam, &odp);
odp.ptszTab = LPGENT("Connection");
odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_YAHOO_CONNECTION);
odp.pfnDlgProc = DlgProcYahooOptsConn;
Options_AddPage(wParam, &odp);
odp.ptszTab = LPGENT("Ignore List");
odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_YAHOO_IGNORE);
odp.pfnDlgProc = DlgProcYahooOptsIgnore;
Options_AddPage(wParam, &odp);
return 0;
}
|