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
|
/*
* $Id: options.c 3640 2006-08-29 17:54:56Z 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 <windows.h>
#include <shlwapi.h>
#include "yahoo.h"
#include "resource.h"
#include <m_langpack.h>
#include <m_utils.h>
#include <m_options.h>
#include <m_popup.h>
#include "options.h"
/*
* YahooOptInit - initialize/register our Options w/ Miranda.
*/
int YahooOptInit(WPARAM wParam,LPARAM lParam)
{
OPTIONSDIALOGPAGE odp;
ZeroMemory(&odp, sizeof( odp ));
odp.cbSize = sizeof(odp);
odp.position = -790000000;
odp.hInstance = hinstance;
odp.pszTemplate = MAKEINTRESOURCE(IDD_OPT_YAHOO);
odp.pszTitle = Translate( yahooProtocolName );
odp.pszGroup = Translate("Network");
odp.flags = ODPF_BOLDGROUPS;
odp.nIDBottomSimpleControl = IDC_STYAHOOGROUP;
odp.pfnDlgProc = DlgProcYahooOpts;
YAHOO_CallService( MS_OPT_ADDPAGE, wParam,( LPARAM )&odp );
return 0;
}
/*
* DlgProcYahooOpts - Connection Options Dialog
*/
BOOL CALLBACK DlgProcYahooOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
DBVARIANT dbv;
YList *l;
switch ( msg ) {
case WM_INITDIALOG:
TranslateDialogDefault( hwndDlg );
if ( !DBGetContactSetting( NULL, yahooProtocolName, YAHOO_LOGINID, &dbv )) {
SetDlgItemText(hwndDlg,IDC_HANDLE,dbv.pszVal);
DBFreeVariant(&dbv);
}
if ( !DBGetContactSetting( NULL, yahooProtocolName, "Nick", &dbv )) {
SetDlgItemText(hwndDlg,IDC_NICK,dbv.pszVal);
DBFreeVariant(&dbv);
}
if ( !DBGetContactSetting( NULL, yahooProtocolName, 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 );
SetDlgItemText( hwndDlg, IDC_PASSWORD, dbv.pszVal );
DBFreeVariant( &dbv );
}
if ( !DBGetContactSetting( NULL, yahooProtocolName, YAHOO_LOGINSERVER, &dbv )){
SetDlgItemText( hwndDlg, IDC_LOGINSERVER, dbv. pszVal );
DBFreeVariant( &dbv );
}
else SetDlgItemText( hwndDlg, IDC_LOGINSERVER, YAHOO_DEFAULT_LOGIN_SERVER );
SetDlgItemInt( hwndDlg, IDC_YAHOOPORT, YAHOO_GetWord( NULL, YAHOO_LOGINPORT, 5050 ), FALSE );
SetButtonCheck( hwndDlg, IDC_YAHOO_JAPAN, YAHOO_GetByte( "YahooJapan", 0 ) );
SetButtonCheck( hwndDlg, IDC_DISMAINMENU, YAHOO_GetByte( "DisableMainMenu", 0 ) );
SetButtonCheck( hwndDlg, IDC_USE_YAB, YAHOO_GetByte( "UseYAB", 1 ));
SetButtonCheck( hwndDlg, IDC_SHOW_AVATARS, YAHOO_GetByte( "ShowAvatars", 0 ));
SetButtonCheck( hwndDlg, IDC_MAIL_AUTOLOGIN, YAHOO_GetByte( "MailAutoLogin", 0 ));
SetButtonCheck( hwndDlg, IDC_DISABLEYAHOOMAIL, !YAHOO_GetByte( "DisableYahoomail", 0 ));
SetButtonCheck( hwndDlg, IDC_SHOW_ERRORS, YAHOO_GetByte( "ShowErrors", 1 ));
/* show our current ignore list */
l = (YList *)YAHOO_GetIgnoreList();
while (l != NULL) {
struct yahoo_buddy *b = (struct yahoo_buddy *) l->data;
//MessageBox(NULL, b->id, "ID", MB_OK);
SendMessage(GetDlgItem(hwndDlg,IDC_YIGN_LIST), LB_ADDSTRING, 0, (LPARAM)b->id);
l = l->next;
}
return TRUE;
case WM_COMMAND:
switch ( LOWORD( wParam )) {
case IDC_NEWYAHOOACCOUNTLINK:
YAHOO_CallService( MS_UTILS_OPENURL, 1,
YAHOO_GetByte( "YahooJapan", 0 )
?(LPARAM)"http://edit.yahoo.co.jp/config/eval_register"
:(LPARAM)"http://edit.yahoo.com/config/eval_register" );
return TRUE;
case IDC_RESETSERVER:
SetDlgItemText( hwndDlg, IDC_LOGINSERVER, YAHOO_DEFAULT_LOGIN_SERVER );
SetDlgItemInt( hwndDlg, IDC_YAHOOPORT, 5050, FALSE );
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
break;
case IDC_IGN_ADD:
{
char id[128];
int i;
if (!yahooLoggedIn) {
MessageBox(hwndDlg, Translate("You need to be connected to Yahoo to add to Ignore List."), Translate("Yahoo Ignore"), MB_OK| MB_ICONINFORMATION);
break;
}
i = GetDlgItemText( hwndDlg, IDC_YIGN_EDIT, id, sizeof( id ));
if (i < 3) {
MessageBox(hwndDlg, Translate("Please enter a valid buddy name to ignore."), Translate("Yahoo Ignore"), MB_OK| MB_ICONINFORMATION);
break;
}
i = SendMessage(GetDlgItem(hwndDlg,IDC_YIGN_LIST), LB_FINDSTRINGEXACT,(WPARAM) -1, (LPARAM)id);
if (i != LB_ERR ) {
MessageBox(hwndDlg, Translate("The buddy is already on your ignore list. "), Translate("Yahoo Ignore"), MB_OK | MB_ICONINFORMATION);
break;
}
YAHOO_IgnoreBuddy(id, 0);
SendMessage(GetDlgItem(hwndDlg,IDC_YIGN_LIST), LB_ADDSTRING, 0, (LPARAM)id);
SetDlgItemText( hwndDlg, IDC_YIGN_EDIT, "" );
}
break;
case IDC_IGN_REMOVE:
{
int i;
char id[128];
if (!yahooLoggedIn) {
MessageBox(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) {
MessageBox(hwndDlg, Translate("Please select a buddy on the ignore list to remove."), Translate("Yahoo Ignore"), MB_OK| MB_ICONINFORMATION);
break;
}
SendMessage(GetDlgItem(hwndDlg,IDC_YIGN_LIST), LB_GETTEXT, i, (LPARAM)id);
YAHOO_IgnoreBuddy(id, 1);
SendMessage(GetDlgItem(hwndDlg,IDC_YIGN_LIST), LB_DELETESTRING, i, 0);
}
break;
case IDC_YAHOO_JAPAN:
SetDlgItemText( 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
case IDC_DISMAINMENU:
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_LOGINSERVER:
case IDC_YAHOOPORT:
case IDC_NICK:
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];
char id[128];
DBVARIANT dbv;
GetDlgItemText( hwndDlg, IDC_HANDLE, id, sizeof( id ));
dbv.pszVal = NULL;
if ( DBGetContactSetting( NULL, yahooProtocolName, YAHOO_LOGINID, &dbv ) ||
lstrcmp( id, dbv.pszVal ))
reconnectRequired = TRUE;
if ( dbv.pszVal != NULL ) DBFreeVariant( &dbv );
YAHOO_SetString( NULL, YAHOO_LOGINID, id );
GetDlgItemText( hwndDlg, IDC_PASSWORD, str, sizeof( str ));
YAHOO_CallService( MS_DB_CRYPT_ENCODESTRING, sizeof( str ),( LPARAM )str );
dbv.pszVal = NULL;
if ( DBGetContactSetting( NULL, yahooProtocolName, YAHOO_PASSWORD, &dbv ) ||
lstrcmp( str, dbv.pszVal ))
reconnectRequired = TRUE;
if ( dbv.pszVal != NULL ) DBFreeVariant( &dbv );
YAHOO_SetString( NULL, YAHOO_PASSWORD, str );
GetDlgItemText( hwndDlg, IDC_NICK, str, sizeof( str ));
YAHOO_SetString( NULL, "Nick", str );
GetDlgItemText( hwndDlg, IDC_LOGINSERVER, str, sizeof( str ));
YAHOO_SetString( NULL, YAHOO_LOGINSERVER, str );
YAHOO_SetWord( NULL, YAHOO_LOGINPORT, GetDlgItemInt( hwndDlg, IDC_YAHOOPORT, NULL, FALSE ));
YAHOO_SetByte("YahooJapan", ( BYTE )IsDlgButtonChecked( hwndDlg, IDC_YAHOO_JAPAN ));
YAHOO_SetByte("DisableMainMenu", ( BYTE )IsDlgButtonChecked( hwndDlg, IDC_DISMAINMENU ));
YAHOO_SetByte("UseYAB", ( BYTE )IsDlgButtonChecked( hwndDlg, IDC_USE_YAB ));
YAHOO_SetByte("ShowAvatars", ( BYTE )IsDlgButtonChecked( hwndDlg, IDC_SHOW_AVATARS ));
YAHOO_SetByte("MailAutoLogin", ( BYTE )IsDlgButtonChecked( hwndDlg, IDC_MAIL_AUTOLOGIN ));
YAHOO_SetByte("DisableYahoomail", ( BYTE )!IsDlgButtonChecked( hwndDlg, IDC_DISABLEYAHOOMAIL ));
YAHOO_SetByte("ShowErrors", ( BYTE )IsDlgButtonChecked( hwndDlg, IDC_SHOW_ERRORS ));
if ( restartRequired )
MessageBox( 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 && yahooLoggedIn )
MessageBox( 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;
}
|