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
|
// ---------------------------------------------------------------------------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,2003,2004 Martin Öberg, Sam Kothari, Robert Rainwater
// Copyright © 2004,2005,2006,2007 Joe Kucera
// Copyright © 2006,2007 [sss], chaos.persei, [sin], Faith Healer, Theif, nullbie
//
// 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 : $Source$
// Revision : $Revision: 43 $
// Last change on : $Date: 2007-08-20 01:51:06 +0300 (Пн, 20 авг 2007) $
// Last change by : $Author: sss123next $
//
// DESCRIPTION:
//
// ChangeInfo Plugin stuff
//
// -----------------------------------------------------------------------------
#include "icqoscar.h"
void LoadSettingsFromDb(int keepChanged)
{
int i;
DBVARIANT dbv;
for(i=0;i<settingCount;i++)
{
if (setting[i].displayType==LI_DIVIDER) continue;
if (keepChanged && setting[i].changed) continue;
if (setting[i].dbType==DBVT_ASCIIZ)
{
SAFE_FREE((char**)&setting[i].value);
}
else if (!keepChanged)
setting[i].value = 0;
setting[i].changed=0;
if (setting[i].displayType&LIF_PASSWORD) continue;
if (!ICQGetContactSetting(NULL,setting[i].szDbSetting,&dbv))
{
#ifdef _DEBUG
if(dbv.type!=setting[i].dbType)
MessageBoxA(NULL,"That's not supposed to happen","Huh?",MB_OK);
#endif
switch(dbv.type)
{
case DBVT_ASCIIZ:
setting[i].value=(LPARAM)ICQGetContactSettingUtf(NULL,setting[i].szDbSetting, NULL);
break;
case DBVT_UTF8:
setting[i].value=(LPARAM)null_strdup(dbv.pszVal);
break;
case DBVT_WORD:
if(setting[i].displayType&LIF_SIGNED)
setting[i].value=dbv.sVal;
else
setting[i].value=dbv.wVal;
break;
case DBVT_BYTE:
if(setting[i].displayType&LIF_SIGNED)
setting[i].value=dbv.cVal;
else
setting[i].value=dbv.bVal;
break;
#ifdef _DEBUG
default:
MessageBoxA(NULL,"That's not supposed to happen either","Huh?",MB_OK);
break;
#endif
}
ICQFreeVariant(&dbv);
}
}
}
void FreeStoredDbSettings(void)
{
int i;
for(i=0;i<settingCount;i++)
if(setting[i].dbType==DBVT_ASCIIZ)
SAFE_FREE((char**)&setting[i].value);
}
int ChangesMade(void)
{
int i;
for(i=0;i<settingCount;i++)
if(setting[i].changed) return 1;
return 0;
}
void ClearChangeFlags(void)
{
int i;
for(i=0;i<settingCount;i++)
setting[i].changed=0;
}
static BOOL CALLBACK PwConfirmDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
static char *Pass;
switch(msg)
{
case WM_INITDIALOG:
ICQTranslateDialog(hwndDlg);
Pass = (char*)lParam;
SendDlgItemMessage(hwndDlg,IDC_PASSWORD,EM_LIMITTEXT,15,0);
return TRUE;
case WM_COMMAND:
switch(LOWORD(wParam))
{
case IDOK:
{
char szTest[16];
GetDlgItemTextA(hwndDlg,IDC_OLDPASS,szTest,sizeof(szTest));
if (strcmpnull(szTest, GetUserPassword(TRUE)))
{
MessageBoxUtf(hwndDlg, LPGEN("The password does not match your current password. Check Caps Lock and try again."), LPGEN("Change ICQ Details"), MB_OK);
SendDlgItemMessage(hwndDlg,IDC_OLDPASS,EM_SETSEL,0,(LPARAM)-1);
SetFocus(GetDlgItem(hwndDlg,IDC_OLDPASS));
break;
}
GetDlgItemTextA(hwndDlg,IDC_PASSWORD,szTest,sizeof(szTest));
if(strcmpnull(szTest, Pass))
{
MessageBoxUtf(hwndDlg, LPGEN("The password does not match the password you originally entered. Check Caps Lock and try again."), LPGEN("Change ICQ Details"), MB_OK);
SendDlgItemMessage(hwndDlg,IDC_PASSWORD,EM_SETSEL,0,(LPARAM)-1);
SetFocus(GetDlgItem(hwndDlg,IDC_PASSWORD));
break;
}
}
case IDCANCEL:
EndDialog(hwndDlg,wParam);
break;
}
break;
}
return FALSE;
}
int SaveSettingsToDb(HWND hwndDlg)
{
int i,ret=1;
for(i=0;i<settingCount;i++)
{
if(!setting[i].changed) continue;
if(!(setting[i].displayType&LIF_ZEROISVALID) && setting[i].value==0)
{
ICQDeleteContactSetting(NULL,setting[i].szDbSetting);
continue;
}
switch(setting[i].dbType)
{
case DBVT_ASCIIZ:
if(setting[i].displayType&LIF_PASSWORD)
{
int nSettingLen = strlennull((char*)setting[i].value);
if (nSettingLen>8 || nSettingLen<1)
{
MessageBoxUtf(hwndDlg, LPGEN("The ICQ server does not support passwords longer than 8 characters. Please use a shorter password."), LPGEN("Change ICQ Details"), MB_OK);
ret=0;
break;
}
if (IDOK!=DialogBoxParam(hInst,MAKEINTRESOURCE(IDD_PWCONFIRM),hwndDlg,PwConfirmDlgProc,(LPARAM)setting[i].value))
{
ret=0;
break;
}
strcpy(gpszPassword, (char*)setting[i].value);
}
else
{
if(*(char*)setting[i].value)
ICQWriteContactSettingUtf(NULL,setting[i].szDbSetting,(char*)setting[i].value);
else
ICQDeleteContactSetting(NULL,setting[i].szDbSetting);
}
break;
case DBVT_WORD:
ICQWriteContactSettingWord(NULL,setting[i].szDbSetting,(WORD)setting[i].value);
break;
case DBVT_BYTE:
ICQWriteContactSettingByte(NULL,setting[i].szDbSetting,(BYTE)setting[i].value);
break;
}
}
return ret;
}
|