summaryrefslogtreecommitdiff
path: root/protocols/IcqOscarJ/src/changeinfo
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2014-02-16 18:08:37 +0000
committerGeorge Hazan <george.hazan@gmail.com>2014-02-16 18:08:37 +0000
commit253783569bef2320d04fe1d310709c64c64fd3a1 (patch)
tree55181ccfc8d93cd78aa8ded73bc7ab289e6ec8b9 /protocols/IcqOscarJ/src/changeinfo
parentb3783bb50a312fa59d302aeede929377c18a6ec1 (diff)
- custom list of time zones removed;
- adaptation of ICQ for new Time API; - code cleaning git-svn-id: http://svn.miranda-ng.org/main/trunk@8140 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/IcqOscarJ/src/changeinfo')
-rw-r--r--protocols/IcqOscarJ/src/changeinfo/constants.cpp233
-rw-r--r--protocols/IcqOscarJ/src/changeinfo/db.cpp144
-rw-r--r--protocols/IcqOscarJ/src/changeinfo/dlgproc.cpp272
-rw-r--r--protocols/IcqOscarJ/src/changeinfo/editlist.cpp117
-rw-r--r--protocols/IcqOscarJ/src/changeinfo/editstring.cpp148
5 files changed, 429 insertions, 485 deletions
diff --git a/protocols/IcqOscarJ/src/changeinfo/constants.cpp b/protocols/IcqOscarJ/src/changeinfo/constants.cpp
index 394505a519..0148fba616 100644
--- a/protocols/IcqOscarJ/src/changeinfo/constants.cpp
+++ b/protocols/IcqOscarJ/src/changeinfo/constants.cpp
@@ -25,157 +25,108 @@
// ChangeInfo Plugin stuff
//
// -----------------------------------------------------------------------------
-#include "icqoscar.h"
+#include "icqoscar.h"
-static FieldNamesItem timezones[]={
- {24 ,LPGEN("GMT-12:00 Eniwetok; Kwajalein")},
- {23 ,LPGEN("GMT-11:30")},
- {22 ,LPGEN("GMT-11:00 Midway Island; Samoa")},
- {21 ,LPGEN("GMT-10:30")},
- {20 ,LPGEN("GMT-10:00 Hawaii")},
- {19 ,LPGEN("GMT-9:30")},
- {18 ,LPGEN("GMT-9:00 Alaska")},
- {17 ,LPGEN("GMT-8:30")},
- {16 ,LPGEN("GMT-8:00 Pacific Time; Tijuana")},
- {15 ,LPGEN("GMT-7:30")},
- {14 ,LPGEN("GMT-7:00 Arizona; Mountain Time")},
- {13 ,LPGEN("GMT-6:30")},
- {12 ,LPGEN("GMT-6:00 Central Time; Central America; Saskatchewan")},
- {11 ,LPGEN("GMT-5:30")},
- {10 ,LPGEN("GMT-5:00 Eastern Time; Bogota; Lima; Quito")},
- {9 ,LPGEN("GMT-4:30")},
- {8 ,LPGEN("GMT-4:00 Atlantic Time; Santiago; Caracas; La Paz")},
- {7 ,LPGEN("GMT-3:30 Newfoundland")},
- {6 ,LPGEN("GMT-3:00 Greenland; Buenos Aires; Georgetown")},
- {5 ,LPGEN("GMT-2:30")},
- {4 ,LPGEN("GMT-2:00 Mid-Atlantic")},
- {3 ,LPGEN("GMT-1:30")},
- {2 ,LPGEN("GMT-1:00 Cape Verde Islands; Azores")},
- {1 ,LPGEN("GMT-0:30")},
- {0 ,LPGEN("GMT+0:00 London; Dublin; Edinburgh; Lisbon; Casablanca")},
- {-1 ,LPGEN("GMT+0:30")},
- {-2 ,LPGEN("GMT+1:00 Central European Time; West Central Africa; Warsaw")},
- {-3 ,LPGEN("GMT+1:30")},
- {-4 ,LPGEN("GMT+2:00 Jerusalem; Helsinki; Harare; Cairo; Bucharest; Athens")},
- {-5 ,LPGEN("GMT+2:30")},
- {-6 ,LPGEN("GMT+3:00 Moscow; St. Petersburg; Nairobi; Kuwait; Baghdad")},
- {-7 ,LPGEN("GMT+3:30 Tehran")},
- {-8 ,LPGEN("GMT+4:00 Baku; Tbilisi; Yerevan; Abu Dhabi; Muscat")},
- {-9 ,LPGEN("GMT+4:30 Kabul")},
- {-10 ,LPGEN("GMT+5:00 Calcutta; Chennai; Mumbai; New Delhi; Ekaterinburg")},
- {-11 ,LPGEN("GMT+5:30")},
- {-12 ,LPGEN("GMT+6:00 Astana; Dhaka; Almaty; Novosibirsk; Sri Jayawardenepura")},
- {-13 ,LPGEN("GMT+6:30 Rangoon")},
- {-14 ,LPGEN("GMT+7:00 Bankok; Hanoi; Jakarta; Krasnoyarsk")},
- {-15 ,LPGEN("GMT+7:30")},
- {-16 ,LPGEN("GMT+8:00 Perth; Taipei; Singapore; Hong Kong; Beijing")},
- {-17 ,LPGEN("GMT+8:30")},
- {-18 ,LPGEN("GMT+9:00 Tokyo; Osaka; Seoul; Sapporo; Yakutsk")},
- {-19 ,LPGEN("GMT+9:30 Darwin; Adelaide")},
- {-20 ,LPGEN("GMT+10:00 East Australia; Guam; Vladivostok")},
- {-21 ,LPGEN("GMT+10:30")},
- {-22 ,LPGEN("GMT+11:00 Magadan; Solomon Is.; New Caledonia")},
- {-23 ,LPGEN("GMT+11:30")},
- {-24 ,LPGEN("GMT+12:00 Auckland; Wellington; Fiji; Kamchatka; Marshall Is.")},
- {-100,NULL}
+static FieldNamesItem months[] = {
+ { 1, LPGEN("January") },
+ { 2, LPGEN("February") },
+ { 3, LPGEN("March") },
+ { 4, LPGEN("April") },
+ { 5, LPGEN("May") },
+ { 6, LPGEN("June") },
+ { 7, LPGEN("July") },
+ { 8, LPGEN("August") },
+ { 9, LPGEN("September") },
+ { 10, LPGEN("October") },
+ { 11, LPGEN("November") },
+ { 12, LPGEN("December") },
+ { 0, NULL }
};
+const int ageRange[] = { 13, 0x7FFF }; // 14, 130
+const int yearRange[] = { 1753, 0x7FFF }; // 1880, 2000
+const int dayRange[] = { 1, 31 };
-static FieldNamesItem months[]={
- {1, LPGEN("January")},
- {2, LPGEN("February")},
- {3, LPGEN("March")},
- {4, LPGEN("April")},
- {5, LPGEN("May")},
- {6, LPGEN("June")},
- {7, LPGEN("July")},
- {8, LPGEN("August")},
- {9, LPGEN("September")},
- {10,LPGEN("October")},
- {11,LPGEN("November")},
- {12,LPGEN("December")},
- {0, NULL}
-};
+const SettingItem setting[] =
+{
+ // personal
+ { LPGEN("Personal"), LI_DIVIDER },
+ { LPGEN("Nickname"), LI_STRING, DBVT_UTF8, "Nick" },
+ { LPGEN("First name"), LI_STRING, DBVT_UTF8, "FirstName" },
+ { LPGEN("Last name"), LI_STRING, DBVT_UTF8, "LastName" },
+ { LPGEN("Gender"), LI_LIST, DBVT_BYTE, "Gender", genderField },
+ { LPGEN("About"), LI_LONGSTRING, DBVT_UTF8, "About" },
+
+ // password
+ { LPGEN("Password"), LI_DIVIDER },
+ { LPGEN("Password"), LI_STRING | LIF_PASSWORD, DBVT_UTF8, "Password" },
+ // contact
+ { LPGEN("Contact"), LI_DIVIDER },
+ { LPGEN("Primary e-mail"), LI_STRING, DBVT_UTF8, "e-mail0" },
+ { LPGEN("Secondary e-mail"), LI_STRING, DBVT_UTF8, "e-mail1" },
+ { LPGEN("Tertiary e-mail"), LI_STRING, DBVT_UTF8, "e-mail2" },
+ { LPGEN("Homepage"), LI_STRING, DBVT_UTF8, "Homepage" },
+ { LPGEN("Street"), LI_STRING, DBVT_UTF8, "Street" },
+ { LPGEN("City"), LI_STRING, DBVT_UTF8, "City" },
+ { LPGEN("State"), LI_STRING, DBVT_UTF8, "State" },
+ { LPGEN("ZIP/postcode"), LI_STRING, DBVT_UTF8, "ZIP" },
+ { LPGEN("Country"), LI_LIST, DBVT_WORD, "Country", countryField },
+ { LPGEN("Phone number"), LI_STRING, DBVT_UTF8, "Phone" },
+ { LPGEN("Fax number"), LI_STRING, DBVT_UTF8, "Fax" },
+ { LPGEN("Cellular number"), LI_STRING, DBVT_UTF8, "Cellular" },
+
+ // more
+ { LPGEN("Personal Detail"), LI_DIVIDER },
+ { LPGEN("Timezone"), LI_LIST | LIF_ZEROISVALID | LIF_SIGNED, DBVT_BYTE, "Timezone", timezonesField },
+ { LPGEN("Year of birth"), LI_NUMBER, DBVT_WORD, "BirthYear", yearRange },
+ { LPGEN("Month of birth"), LI_LIST, DBVT_BYTE, "BirthMonth", months },
+ { LPGEN("Day of birth"), LI_NUMBER, DBVT_BYTE, "BirthDay", dayRange },
+ { LPGEN("Marital Status"), LI_LIST, DBVT_BYTE, "MaritalStatus", maritalField },
+ { LPGEN("Spoken language 1"), LI_LIST, DBVT_BYTE, "Language1", languageField },
+ { LPGEN("Spoken language 2"), LI_LIST, DBVT_BYTE, "Language2", languageField },
+ { LPGEN("Spoken language 3"), LI_LIST, DBVT_BYTE, "Language3", languageField },
-const int ageRange[]={13,0x7FFF}; // 14, 130
-const int yearRange[]={1753,0x7FFF}; // 1880, 2000
-const int dayRange[]={1,31};
+ // more
+ { LPGEN("Originally from"), LI_DIVIDER },
+ { LPGEN("Street"), LI_STRING, DBVT_UTF8, "OriginStreet" },
+ { LPGEN("City"), LI_STRING, DBVT_UTF8, "OriginCity" },
+ { LPGEN("State"), LI_STRING, DBVT_UTF8, "OriginState" },
+ { LPGEN("Country"), LI_LIST, DBVT_WORD, "OriginCountry", countryField },
+ // study
+ { LPGEN("Education"), LI_DIVIDER },
+ { LPGEN("Level"), LI_LIST, DBVT_WORD, "StudyLevel", studyLevelField },
+ { LPGEN("Institute"), LI_STRING, DBVT_UTF8, "StudyInstitute" },
+ { LPGEN("Degree"), LI_STRING, DBVT_UTF8, "StudyDegree" },
+ { LPGEN("Graduation Year"), LI_NUMBER, DBVT_WORD, "StudyYear", yearRange },
-const SettingItem setting[]={
- //personal
- {LPGEN("Personal"), LI_DIVIDER},
- {LPGEN("Nickname"), LI_STRING, DBVT_UTF8, "Nick"},
- {LPGEN("First name"), LI_STRING, DBVT_UTF8, "FirstName"},
- {LPGEN("Last name"), LI_STRING, DBVT_UTF8, "LastName"},
- {LPGEN("Gender"), LI_LIST, DBVT_BYTE, "Gender", genderField},
- {LPGEN("About"), LI_LONGSTRING, DBVT_UTF8, "About"},
- //password
- {LPGEN("Password"), LI_DIVIDER},
- {LPGEN("Password"), LI_STRING|LIF_PASSWORD,DBVT_UTF8, "Password"},
- //contact
- {LPGEN("Contact"), LI_DIVIDER},
- {LPGEN("Primary e-mail"), LI_STRING, DBVT_UTF8, "e-mail0"},
- {LPGEN("Secondary e-mail"), LI_STRING, DBVT_UTF8, "e-mail1"},
- {LPGEN("Tertiary e-mail"), LI_STRING, DBVT_UTF8, "e-mail2"},
- {LPGEN("Homepage"), LI_STRING, DBVT_UTF8, "Homepage"},
- {LPGEN("Street"), LI_STRING, DBVT_UTF8, "Street"},
- {LPGEN("City"), LI_STRING, DBVT_UTF8, "City"},
- {LPGEN("State"), LI_STRING, DBVT_UTF8, "State"},
- {LPGEN("ZIP/postcode"), LI_STRING, DBVT_UTF8, "ZIP"},
- {LPGEN("Country"), LI_LIST, DBVT_WORD, "Country", countryField},
- {LPGEN("Phone number"), LI_STRING, DBVT_UTF8, "Phone"},
- {LPGEN("Fax number"), LI_STRING, DBVT_UTF8, "Fax"},
- {LPGEN("Cellular number"),LI_STRING, DBVT_UTF8, "Cellular"},
- //more
- {LPGEN("Personal Detail"),LI_DIVIDER},
- {LPGEN("Timezone"), LI_LIST|LIF_ZEROISVALID|LIF_SIGNED,DBVT_BYTE, "Timezone", timezones},
- {LPGEN("Year of birth"), LI_NUMBER, DBVT_WORD, "BirthYear", yearRange},
- {LPGEN("Month of birth"), LI_LIST, DBVT_BYTE, "BirthMonth", months},
- {LPGEN("Day of birth"), LI_NUMBER, DBVT_BYTE, "BirthDay", dayRange},
- {LPGEN("Marital Status"), LI_LIST, DBVT_BYTE, "MaritalStatus", maritalField},
- {LPGEN("Spoken language 1"), LI_LIST, DBVT_BYTE, "Language1", languageField},
- {LPGEN("Spoken language 2"), LI_LIST, DBVT_BYTE, "Language2", languageField},
- {LPGEN("Spoken language 3"), LI_LIST, DBVT_BYTE, "Language3", languageField},
- //more
- {LPGEN("Originally from"),LI_DIVIDER},
- {LPGEN("Street"), LI_STRING, DBVT_UTF8, "OriginStreet"},
- {LPGEN("City"), LI_STRING, DBVT_UTF8, "OriginCity"},
- {LPGEN("State"), LI_STRING, DBVT_UTF8, "OriginState"},
- {LPGEN("Country"), LI_LIST, DBVT_WORD, "OriginCountry", countryField},
- //study
- {LPGEN("Education"), LI_DIVIDER},
- {LPGEN("Level"), LI_LIST, DBVT_WORD, "StudyLevel", studyLevelField},
- {LPGEN("Institute"), LI_STRING, DBVT_UTF8, "StudyInstitute"},
- {LPGEN("Degree"), LI_STRING, DBVT_UTF8, "StudyDegree"},
- {LPGEN("Graduation Year"),LI_NUMBER, DBVT_WORD, "StudyYear", yearRange},
- //work
- {LPGEN("Work"), LI_DIVIDER},
- {LPGEN("Company name"), LI_STRING, DBVT_UTF8, "Company"},
- {LPGEN("Company homepage"),LI_STRING, DBVT_UTF8, "CompanyHomepage"},
- {LPGEN("Company street"), LI_STRING, DBVT_UTF8, "CompanyStreet"},
- {LPGEN("Company city"), LI_STRING, DBVT_UTF8, "CompanyCity"},
- {LPGEN("Company state"), LI_STRING, DBVT_UTF8, "CompanyState"},
- {LPGEN("Company phone"), LI_STRING, DBVT_UTF8, "CompanyPhone"},
- {LPGEN("Company fax"), LI_STRING, DBVT_UTF8, "CompanyFax"},
- {LPGEN("Company ZIP/postcode"),LI_STRING,DBVT_UTF8, "CompanyZIP"},
- {LPGEN("Company country"),LI_LIST, DBVT_WORD, "CompanyCountry", countryField},
- {LPGEN("Company department"),LI_STRING, DBVT_UTF8, "CompanyDepartment"},
- {LPGEN("Company position"),LI_STRING, DBVT_UTF8, "CompanyPosition"},
- {LPGEN("Company industry"),LI_LIST, DBVT_WORD, "CompanyIndustry", industryField},
+ // work
+ { LPGEN("Work"), LI_DIVIDER },
+ { LPGEN("Company name"), LI_STRING, DBVT_UTF8, "Company" },
+ { LPGEN("Company homepage"), LI_STRING, DBVT_UTF8, "CompanyHomepage" },
+ { LPGEN("Company street"), LI_STRING, DBVT_UTF8, "CompanyStreet" },
+ { LPGEN("Company city"), LI_STRING, DBVT_UTF8, "CompanyCity" },
+ { LPGEN("Company state"), LI_STRING, DBVT_UTF8, "CompanyState" },
+ { LPGEN("Company phone"), LI_STRING, DBVT_UTF8, "CompanyPhone" },
+ { LPGEN("Company fax"), LI_STRING, DBVT_UTF8, "CompanyFax" },
+ { LPGEN("Company ZIP/postcode"), LI_STRING, DBVT_UTF8, "CompanyZIP" },
+ { LPGEN("Company country"), LI_LIST, DBVT_WORD, "CompanyCountry", countryField },
+ { LPGEN("Company department"), LI_STRING, DBVT_UTF8, "CompanyDepartment" },
+ { LPGEN("Company position"), LI_STRING, DBVT_UTF8, "CompanyPosition" },
+ { LPGEN("Company industry"), LI_LIST, DBVT_WORD, "CompanyIndustry", industryField },
- //interests
- {LPGEN("Personal Interests"), LI_DIVIDER},
- {LPGEN("Interest category 1"),LI_LIST, DBVT_WORD, "Interest0Cat", interestsField},
- {LPGEN("Interest areas 1"),LI_STRING, DBVT_UTF8, "Interest0Text"},
- {LPGEN("Interest category 2"),LI_LIST, DBVT_WORD, "Interest1Cat", interestsField},
- {LPGEN("Interest areas 2"),LI_STRING, DBVT_UTF8, "Interest1Text"},
- {LPGEN("Interest category 3"),LI_LIST, DBVT_WORD, "Interest2Cat", interestsField},
- {LPGEN("Interest areas 3"),LI_STRING, DBVT_UTF8, "Interest2Text"},
- {LPGEN("Interest category 4"),LI_LIST, DBVT_WORD, "Interest3Cat", interestsField},
- {LPGEN("Interest areas 4"),LI_STRING, DBVT_UTF8, "Interest3Text"},
+ //interests
+ { LPGEN("Personal Interests"), LI_DIVIDER },
+ { LPGEN("Interest category 1"), LI_LIST, DBVT_WORD, "Interest0Cat", interestsField },
+ { LPGEN("Interest areas 1"), LI_STRING, DBVT_UTF8, "Interest0Text" },
+ { LPGEN("Interest category 2"), LI_LIST, DBVT_WORD, "Interest1Cat", interestsField },
+ { LPGEN("Interest areas 2"), LI_STRING, DBVT_UTF8, "Interest1Text" },
+ { LPGEN("Interest category 3"), LI_LIST, DBVT_WORD, "Interest2Cat", interestsField },
+ { LPGEN("Interest areas 3"), LI_STRING, DBVT_UTF8, "Interest2Text" },
+ { LPGEN("Interest category 4"), LI_LIST, DBVT_WORD, "Interest3Cat", interestsField },
+ { LPGEN("Interest areas 4"), LI_STRING, DBVT_UTF8, "Interest3Text" },
};
const int settingCount = SIZEOF(setting);
diff --git a/protocols/IcqOscarJ/src/changeinfo/db.cpp b/protocols/IcqOscarJ/src/changeinfo/db.cpp
index f32985e764..07807549cd 100644
--- a/protocols/IcqOscarJ/src/changeinfo/db.cpp
+++ b/protocols/IcqOscarJ/src/changeinfo/db.cpp
@@ -29,43 +29,48 @@
void ChangeInfoData::LoadSettingsFromDb(int keepChanged)
{
- for (int i=0; i < settingCount; i++)
- {
- if (setting[i].displayType == LI_DIVIDER) continue;
- if (keepChanged && settingData[i].changed) continue;
- if (setting[i].dbType == DBVT_ASCIIZ || setting[i].dbType == DBVT_UTF8)
- SAFE_FREE((void**)(char**)&settingData[i].value);
+ for (int i = 0; i < settingCount; i++) {
+ const SettingItem &si = setting[i];
+ if (si.displayType == LI_DIVIDER)
+ continue;
+
+ SettingItemData &sid = settingData[i];
+ if (keepChanged && sid.changed)
+ continue;
+
+ if (si.dbType == DBVT_ASCIIZ || si.dbType == DBVT_UTF8)
+ SAFE_FREE((void**)(char**)&sid.value);
else if (!keepChanged)
- settingData[i].value = 0;
+ sid.value = 0;
- settingData[i].changed = 0;
+ sid.changed = 0;
- if (setting[i].displayType & LIF_PASSWORD) continue;
+ if (si.displayType & LIF_PASSWORD)
+ continue;
- DBVARIANT dbv = {DBVT_DELETED};
- if (!ppro->getSetting(NULL, setting[i].szDbSetting, &dbv))
- {
- switch(dbv.type) {
+ DBVARIANT dbv = { DBVT_DELETED };
+ if (!ppro->getSetting(NULL, si.szDbSetting, &dbv)) {
+ switch (dbv.type) {
case DBVT_ASCIIZ:
- settingData[i].value = (LPARAM)ppro->getSettingStringUtf(NULL, setting[i].szDbSetting, NULL);
- break;
+ sid.value = (LPARAM)ppro->getSettingStringUtf(NULL, si.szDbSetting, NULL);
+ break;
case DBVT_UTF8:
- settingData[i].value = (LPARAM)null_strdup(dbv.pszVal);
+ sid.value = (LPARAM)null_strdup(dbv.pszVal);
break;
case DBVT_WORD:
- if (setting[i].displayType & LIF_SIGNED)
- settingData[i].value = dbv.sVal;
- else
- settingData[i].value = dbv.wVal;
+ if (si.displayType & LIF_SIGNED)
+ sid.value = dbv.sVal;
+ else
+ sid.value = dbv.wVal;
break;
case DBVT_BYTE:
- if (setting[i].displayType & LIF_SIGNED)
- settingData[i].value = dbv.cVal;
- else
- settingData[i].value = dbv.bVal;
+ if (si.displayType & LIF_SIGNED)
+ sid.value = dbv.cVal;
+ else
+ sid.value = dbv.bVal;
break;
#ifdef _DEBUG
@@ -77,24 +82,24 @@ void ChangeInfoData::LoadSettingsFromDb(int keepChanged)
db_free(&dbv);
}
- char buf[MAX_PATH];
- TCHAR tbuf[MAX_PATH];
+ char buf[MAX_PATH];
+ TCHAR tbuf[MAX_PATH];
- if (utf8_to_tchar_static(GetItemSettingText(i, buf, SIZEOF(buf)), tbuf, SIZEOF(tbuf)))
- ListView_SetItemText(hwndList, i, 1, tbuf);
+ if (utf8_to_tchar_static(GetItemSettingText(i, buf, SIZEOF(buf)), tbuf, SIZEOF(tbuf)))
+ ListView_SetItemText(hwndList, i, 1, tbuf);
}
}
void ChangeInfoData::FreeStoredDbSettings(void)
{
- for (int i=0; i < settingCount; i++ )
+ for (int i = 0; i < settingCount; i++)
if (setting[i].dbType == DBVT_ASCIIZ || setting[i].dbType == DBVT_UTF8)
SAFE_FREE((void**)&settingData[i].value);
}
int ChangeInfoData::ChangesMade(void)
{
- for (int i=0; i < settingCount; i++ )
+ for (int i = 0; i < settingCount; i++)
if (settingData[i].changed)
return 1;
return 0;
@@ -102,7 +107,7 @@ int ChangeInfoData::ChangesMade(void)
void ChangeInfoData::ClearChangeFlags(void)
{
- for (int i=0; i < settingCount; i++)
+ for (int i = 0; i < settingCount; i++)
settingData[i].changed = 0;
}
@@ -118,40 +123,38 @@ static INT_PTR CALLBACK PwConfirmDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam,
{
PwConfirmDlgParam* dat = (PwConfirmDlgParam*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
- switch(msg) {
+ switch (msg) {
case WM_INITDIALOG:
TranslateDialogDefault(hwndDlg);
SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam);
- SendDlgItemMessage(hwndDlg,IDC_PASSWORD,EM_LIMITTEXT,15,0);
+ SendDlgItemMessage(hwndDlg, IDC_PASSWORD, EM_LIMITTEXT, 15, 0);
return TRUE;
case WM_COMMAND:
- switch(LOWORD(wParam)) {
+ switch (LOWORD(wParam)) {
case IDOK:
- {
+ {
char szTest[16];
- GetDlgItemTextA(hwndDlg,IDC_OLDPASS,szTest,sizeof(szTest));
+ GetDlgItemTextA(hwndDlg, IDC_OLDPASS, szTest, sizeof(szTest));
- if (strcmpnull(szTest, dat->ppro->GetUserPassword(TRUE)))
- {
+ if (strcmpnull(szTest, dat->ppro->GetUserPassword(TRUE))) {
MessageBox(hwndDlg, TranslateT("The password does not match your current password. Check Caps Lock and try again."), TranslateT("Change ICQ Details"), MB_OK);
- SendDlgItemMessage(hwndDlg,IDC_OLDPASS,EM_SETSEL,0,(LPARAM)-1);
- SetFocus(GetDlgItem(hwndDlg,IDC_OLDPASS));
+ 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, dat->Pass))
- {
+ GetDlgItemTextA(hwndDlg, IDC_PASSWORD, szTest, sizeof(szTest));
+ if (strcmpnull(szTest, dat->Pass)) {
MessageBox(hwndDlg, TranslateT("The password does not match the password you originally entered. Check Caps Lock and try again."), TranslateT("Change ICQ Details"), MB_OK);
- SendDlgItemMessage(hwndDlg,IDC_PASSWORD,EM_SETSEL,0,(LPARAM)-1);
- SetFocus(GetDlgItem(hwndDlg,IDC_PASSWORD));
+ SendDlgItemMessage(hwndDlg, IDC_PASSWORD, EM_SETSEL, 0, (LPARAM)-1);
+ SetFocus(GetDlgItem(hwndDlg, IDC_PASSWORD));
break;
}
}
case IDCANCEL:
- EndDialog(hwndDlg,wParam);
+ EndDialog(hwndDlg, wParam);
break;
}
break;
@@ -163,55 +166,54 @@ int ChangeInfoData::SaveSettingsToDb(HWND hwndDlg)
{
int ret = 1;
- for (int i = 0; i < settingCount; i++)
- {
- if (!settingData[i].changed) continue;
- if (!(setting[i].displayType & LIF_ZEROISVALID) && settingData[i].value==0)
- {
- ppro->delSetting(setting[i].szDbSetting);
+ for (int i = 0; i < settingCount; i++) {
+ SettingItemData &sid = settingData[i];
+ if (!sid.changed)
+ continue;
+
+ const SettingItem &si = setting[i];
+ if (!(si.displayType & LIF_ZEROISVALID) && sid.value == 0) {
+ ppro->delSetting(si.szDbSetting);
continue;
}
- switch(setting[i].dbType) {
+ switch (si.dbType) {
case DBVT_ASCIIZ:
- if (setting[i].displayType & LIF_PASSWORD)
- {
- int nSettingLen = strlennull((char*)settingData[i].value);
+ if (si.displayType & LIF_PASSWORD) {
+ int nSettingLen = strlennull((char*)sid.value);
- if (nSettingLen > 8 || nSettingLen < 1)
- {
+ if (nSettingLen > 8 || nSettingLen < 1) {
MessageBox(hwndDlg, TranslateT("The ICQ server does not support passwords longer than 8 characters. Please use a shorter password."), TranslateT("Change ICQ Details"), MB_OK);
- ret=0;
+ ret = 0;
break;
}
- PwConfirmDlgParam param = { ppro, (char*)settingData[i].value };
- if (IDOK != DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_PWCONFIRM), hwndDlg, PwConfirmDlgProc, (LPARAM)&param))
- {
+ PwConfirmDlgParam param = { ppro, (char*)sid.value };
+ if (IDOK != DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_PWCONFIRM), hwndDlg, PwConfirmDlgProc, (LPARAM)&param)) {
ret = 0;
break;
}
- strcpy(ppro->m_szPassword, (char*)settingData[i].value);
+ strcpy(ppro->m_szPassword, (char*)sid.value);
}
else {
- if (*(char*)settingData[i].value)
- db_set_utf(NULL, ppro->m_szModuleName, setting[i].szDbSetting, (char*)settingData[i].value);
+ if (*(char*)sid.value)
+ db_set_utf(NULL, ppro->m_szModuleName, si.szDbSetting, (char*)sid.value);
else
- ppro->delSetting(setting[i].szDbSetting);
+ ppro->delSetting(si.szDbSetting);
}
break;
case DBVT_UTF8:
- if (*(char*)settingData[i].value)
- db_set_utf(NULL, ppro->m_szModuleName, setting[i].szDbSetting, (char*)settingData[i].value);
+ if (*(char*)sid.value)
+ db_set_utf(NULL, ppro->m_szModuleName, si.szDbSetting, (char*)sid.value);
else
- ppro->delSetting(setting[i].szDbSetting);
+ ppro->delSetting(si.szDbSetting);
break;
case DBVT_WORD:
- ppro->setWord(setting[i].szDbSetting, (WORD)settingData[i].value);
+ ppro->setWord(si.szDbSetting, (WORD)sid.value);
break;
case DBVT_BYTE:
- ppro->setByte(setting[i].szDbSetting, (BYTE)settingData[i].value);
+ ppro->setByte(si.szDbSetting, (BYTE)sid.value);
break;
}
}
diff --git a/protocols/IcqOscarJ/src/changeinfo/dlgproc.cpp b/protocols/IcqOscarJ/src/changeinfo/dlgproc.cpp
index 4a1f068b7e..e8d71f869f 100644
--- a/protocols/IcqOscarJ/src/changeinfo/dlgproc.cpp
+++ b/protocols/IcqOscarJ/src/changeinfo/dlgproc.cpp
@@ -27,7 +27,6 @@
// -----------------------------------------------------------------------------
#include "icqoscar.h"
-
#define DM_PROTOACK (WM_USER+10)
static int DrawTextUtf(HDC hDC, char *text, LPRECT lpRect, UINT uFormat, LPSIZE lpSize)
@@ -43,7 +42,6 @@ static int DrawTextUtf(HDC hDC, char *text, LPRECT lpRect, UINT uFormat, LPSIZE
return res;
}
-
char* ChangeInfoData::GetItemSettingText(int i, char *buf, size_t bufsize)
{
char *text = buf;
@@ -51,66 +49,69 @@ char* ChangeInfoData::GetItemSettingText(int i, char *buf, size_t bufsize)
buf[0] = '\0';
- if (settingData[i].value == 0 && !(setting[i].displayType & LIF_ZEROISVALID))
- {
- if (setting[i].displayType & LIF_CHANGEONLY)
+ const SettingItem &si = setting[i];
+ SettingItemData &sid = settingData[i];
+ if (sid.value == 0 && !(si.displayType & LIF_ZEROISVALID)) {
+ if (si.displayType & LIF_CHANGEONLY)
text = ICQTranslateUtfStatic(LPGEN("<unremovable once applied>"), buf, bufsize);
else
text = ICQTranslateUtfStatic(LPGEN("<empty>"), buf, bufsize);
}
- else
- {
- switch (setting[i].displayType & LIM_TYPE) {
+ else {
+ switch (si.displayType & LIM_TYPE) {
case LI_STRING:
case LI_LONGSTRING:
- text = BinaryToEscapes((char*)settingData[i].value);
+ text = BinaryToEscapes((char*)sid.value);
alloced = 1;
break;
case LI_NUMBER:
- _itoa(settingData[i].value, text, 10);
+ _itoa(sid.value, text, 10);
break;
case LI_LIST:
- if (setting[i].dbType == DBVT_ASCIIZ)
- text = ICQTranslateUtfStatic((char*)settingData[i].value, buf, bufsize);
- else
- {
+ if (si.dbType == DBVT_ASCIIZ)
+ text = ICQTranslateUtfStatic((char*)sid.value, buf, bufsize);
+ else {
text = ICQTranslateUtfStatic(LPGEN("Unknown value"), buf, bufsize);
- FieldNamesItem *list = (FieldNamesItem*)setting[i].pList;
- for (int j=0; TRUE; j++)
- if (list[j].code == settingData[i].value)
- {
+ FieldNamesItem *list = (FieldNamesItem*)si.pList;
+ if (list == timezonesField) {
+ HANDLE tz = tmi.createByContact(NULL, ppro->m_szModuleName, 0);
+ text = make_utf8_string_static(tmi.getTzName(tz), buf, bufsize);
+ break;
+ }
+
+ for (int j = 0;; j++) {
+ if (list[j].code == sid.value) {
text = ICQTranslateUtfStatic(list[j].text, buf, bufsize);
break;
}
- else if (!list[j].text)
- {
- if (list[j].code == settingData[i].value)
+ else if (!list[j].text) {
+ if (list[j].code == sid.value)
text = ICQTranslateUtfStatic("Unspecified", buf, bufsize);
break;
}
+ }
}
break;
}
}
- if (setting[i].displayType & LIF_PASSWORD)
- {
- if (settingData[i].changed)
- for (int j=0; text[j]; j++) text[j] = '*';
- else
- {
- if (alloced)
- {
+
+ if (si.displayType & LIF_PASSWORD) {
+ if (sid.changed) {
+ for (int j = 0; text[j]; j++)
+ text[j] = '*';
+ }
+ else {
+ if (alloced) {
SAFE_FREE(&text);
alloced = 0;
}
text = "********";
}
}
- if (text != buf)
- {
+ if (text != buf) {
char *tmp = text;
text = null_strcpy(buf, text, bufsize - 1);
@@ -121,29 +122,26 @@ char* ChangeInfoData::GetItemSettingText(int i, char *buf, size_t bufsize)
return text;
}
-
void ChangeInfoData::PaintItemSetting(HDC hdc, RECT *rc, int i, UINT itemState)
{
char str[MAX_PATH];
char *text = GetItemSettingText(i, str, SIZEOF(str));
- if (settingData[i].value == 0 && !(setting[i].displayType & LIF_ZEROISVALID))
+ const SettingItem &si = setting[i];
+ SettingItemData &sid = settingData[i];
+ if (sid.value == 0 && !(si.displayType & LIF_ZEROISVALID))
SetTextColor(hdc, GetSysColor(COLOR_GRAYTEXT));
- if ((setting[i].displayType & LIM_TYPE) == LI_LIST && (itemState & CDIS_SELECTED || iEditItem == i))
- {
- RECT rcBtn;
-
- rcBtn = *rc;
+ if ((si.displayType & LIM_TYPE) == LI_LIST && (itemState & CDIS_SELECTED || iEditItem == i)) {
+ RECT rcBtn = *rc;
rcBtn.left = rcBtn.right - rc->bottom + rc->top;
- InflateRect(&rcBtn,-2,-2);
+ InflateRect(&rcBtn, -2, -2);
rc->right = rcBtn.left;
- DrawFrameControl(hdc, &rcBtn, DFC_SCROLL, iEditItem == i ? DFCS_SCROLLDOWN|DFCS_PUSHED : DFCS_SCROLLDOWN);
+ DrawFrameControl(hdc, &rcBtn, DFC_SCROLL, iEditItem == i ? DFCS_SCROLLDOWN | DFCS_PUSHED : DFCS_SCROLLDOWN);
}
- DrawTextUtf(hdc, text, rc, DT_END_ELLIPSIS|DT_LEFT|DT_NOCLIP|DT_NOPREFIX|DT_SINGLELINE|DT_VCENTER, NULL);
+ DrawTextUtf(hdc, text, rc, DT_END_ELLIPSIS | DT_LEFT | DT_NOCLIP | DT_NOPREFIX | DT_SINGLELINE | DT_VCENTER, NULL);
}
-
static int ChangeInfoDlg_Resize(HWND hwndDlg, LPARAM lParam, UTILRESIZECONTROL *urc)
{
switch (urc->wId) {
@@ -151,10 +149,10 @@ static int ChangeInfoDlg_Resize(HWND hwndDlg, LPARAM lParam, UTILRESIZECONTROL *
return RD_ANCHORX_WIDTH | RD_ANCHORY_HEIGHT;
case IDC_SAVE:
- return RD_ANCHORX_RIGHT | RD_ANCHORY_BOTTOM;
+ return RD_ANCHORX_RIGHT | RD_ANCHORY_BOTTOM;
case IDC_UPLOADING:
- return RD_ANCHORX_WIDTH | RD_ANCHORY_BOTTOM;
+ return RD_ANCHORX_WIDTH | RD_ANCHORY_BOTTOM;
}
return RD_ANCHORX_LEFT | RD_ANCHORY_TOP; // default
@@ -165,7 +163,7 @@ INT_PTR CALLBACK ChangeInfoDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM
{
ChangeInfoData* dat = (ChangeInfoData*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
- switch(msg) {
+ switch (msg) {
case WM_INITDIALOG:
TranslateDialogDefault(hwndDlg);
@@ -179,35 +177,31 @@ INT_PTR CALLBACK ChangeInfoDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM
ListView_SetExtendedListViewStyle(dat->hwndList, LVS_EX_FULLROWSELECT);
dat->iEditItem = -1;
{
- HFONT hFont;
- LOGFONT lf;
-
dat->hListFont = (HFONT)SendMessage(dat->hwndList, WM_GETFONT, 0, 0);
+
+ LOGFONT lf;
GetObject(dat->hListFont, sizeof(lf), &lf);
lf.lfHeight -= 5;
- hFont = CreateFontIndirect(&lf);
+ HFONT hFont = CreateFontIndirect(&lf);
SendMessage(dat->hwndList, WM_SETFONT, (WPARAM)hFont, 0);
- }
- { // Prepare ListView Columns
- LV_COLUMN lvc = {0};
- RECT rc;
+ // Prepare ListView Columns
+ RECT rc;
GetClientRect(dat->hwndList, &rc);
rc.right -= GetSystemMetrics(SM_CXVSCROLL);
+
+ LV_COLUMN lvc = { 0 };
lvc.mask = LVCF_WIDTH;
lvc.cx = rc.right / 3;
ListView_InsertColumn(dat->hwndList, 0, &lvc);
lvc.cx = rc.right - lvc.cx;
ListView_InsertColumn(dat->hwndList, 1, &lvc);
- }
- { // Prepare Setting Items
- LV_ITEM lvi = {0};
- lvi.mask = LVIF_PARAM | LVIF_TEXT;
- for (lvi.iItem = 0; lvi.iItem < settingCount; lvi.iItem++)
- {
+ // Prepare Setting Items
+ LV_ITEM lvi = { 0 };
+ lvi.mask = LVIF_PARAM | LVIF_TEXT;
+ for (lvi.iItem = 0; lvi.iItem < settingCount; lvi.iItem++) {
TCHAR text[MAX_PATH];
-
lvi.lParam = lvi.iItem;
lvi.pszText = text;
utf8_to_tchar_static(setting[lvi.iItem].szDescription, text, SIZEOF(text));
@@ -227,7 +221,7 @@ INT_PTR CALLBACK ChangeInfoDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM
dat->LoadSettingsFromDb(0);
{
char *pwd = dat->ppro->GetUserPassword(TRUE);
- strcpy(dat->Password, (pwd) ? pwd : "" ); /// FIXME
+ strcpy(dat->Password, (pwd) ? pwd : ""); /// FIXME
}
break;
@@ -241,25 +235,20 @@ INT_PTR CALLBACK ChangeInfoDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM
break;
case PSN_APPLY:
- if (dat->ChangesMade())
- {
- if (MessageBox(hwndDlg, TranslateT("You've made some changes to your ICQ details but it has not been saved to the server. Are you sure you want to close this dialog?"), TranslateT("Change ICQ Details"), MB_YESNOCANCEL) != IDYES)
- {
+ if (dat->ChangesMade()) {
+ if (MessageBox(hwndDlg, TranslateT("You've made some changes to your ICQ details but it has not been saved to the server. Are you sure you want to close this dialog?"), TranslateT("Change ICQ Details"), MB_YESNOCANCEL) != IDYES) {
SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, PSNRET_INVALID_NOCHANGEPAGE);
return TRUE;
}
}
- break;
}
break;
case IDC_LIST:
switch (((LPNMHDR)lParam)->code) {
case LVN_GETDISPINFO:
- if (dat->iEditItem != -1)
- {
- if (dat->editTopIndex != ListView_GetTopIndex(dat->hwndList))
- {
+ if (dat->iEditItem != -1) {
+ if (dat->editTopIndex != ListView_GetTopIndex(dat->hwndList)) {
dat->EndStringEdit(1);
dat->EndListEdit(1);
}
@@ -268,56 +257,48 @@ INT_PTR CALLBACK ChangeInfoDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM
case NM_CUSTOMDRAW:
{
- LPNMLVCUSTOMDRAW cd=(LPNMLVCUSTOMDRAW)lParam;
+ LPNMLVCUSTOMDRAW cd = (LPNMLVCUSTOMDRAW)lParam;
- switch(cd->nmcd.dwDrawStage) {
+ switch (cd->nmcd.dwDrawStage) {
case CDDS_PREPAINT:
SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, CDRF_NOTIFYITEMDRAW);
return TRUE;
case CDDS_ITEMPREPAINT:
+ if (dat->iEditItem != -1) {
+ if (dat->editTopIndex != ListView_GetTopIndex(dat->hwndList)) {
+ dat->EndStringEdit(1);
+ dat->EndListEdit(1);
+ }
+ }
{
RECT rcItem;
-
- if (dat->iEditItem != -1)
- {
- if (dat->editTopIndex != ListView_GetTopIndex(dat->hwndList))
- {
- dat->EndStringEdit(1);
- dat->EndListEdit(1);
- }
- }
-
ListView_GetItemRect(dat->hwndList, cd->nmcd.dwItemSpec, &rcItem, LVIR_BOUNDS);
- if (GetWindowLongPtr(dat->hwndList, GWL_STYLE) & WS_DISABLED)
- { // Disabled List
+ if (GetWindowLongPtr(dat->hwndList, GWL_STYLE) & WS_DISABLED) { // Disabled List
SetTextColor(cd->nmcd.hdc, cd->clrText);
FillRect(cd->nmcd.hdc, &rcItem, GetSysColorBrush(COLOR_3DFACE));
}
else if ((cd->nmcd.uItemState & CDIS_SELECTED || dat->iEditItem == (int)cd->nmcd.dwItemSpec)
- && setting[cd->nmcd.lItemlParam].displayType != LI_DIVIDER)
- { // Selected item
+ && setting[cd->nmcd.lItemlParam].displayType != LI_DIVIDER) { // Selected item
SetTextColor(cd->nmcd.hdc, GetSysColor(COLOR_HIGHLIGHTTEXT));
FillRect(cd->nmcd.hdc, &rcItem, GetSysColorBrush(COLOR_HIGHLIGHT));
}
- else
- { // Unselected item
+ else { // Unselected item
SetTextColor(cd->nmcd.hdc, GetSysColor(COLOR_WINDOWTEXT));
FillRect(cd->nmcd.hdc, &rcItem, GetSysColorBrush(COLOR_WINDOW));
}
HFONT hoFont = (HFONT)SelectObject(cd->nmcd.hdc, dat->hListFont);
- if (setting[cd->nmcd.lItemlParam].displayType == LI_DIVIDER)
- {
+ if (setting[cd->nmcd.lItemlParam].displayType == LI_DIVIDER) {
RECT rcLine;
SIZE textSize;
char str[MAX_PATH];
char *szText = ICQTranslateUtfStatic(setting[cd->nmcd.lItemlParam].szDescription, str, MAX_PATH);
SetTextColor(cd->nmcd.hdc, GetSysColor(COLOR_3DSHADOW));
- DrawTextUtf(cd->nmcd.hdc, szText, &rcItem, DT_CENTER|DT_NOCLIP|DT_NOPREFIX|DT_SINGLELINE|DT_VCENTER, &textSize);
+ DrawTextUtf(cd->nmcd.hdc, szText, &rcItem, DT_CENTER | DT_NOCLIP | DT_NOPREFIX | DT_SINGLELINE | DT_VCENTER, &textSize);
rcLine.top = (rcItem.top + rcItem.bottom) / 2 - 1;
rcLine.bottom = rcLine.top + 2;
rcLine.left = rcItem.left + 3;
@@ -327,8 +308,7 @@ INT_PTR CALLBACK ChangeInfoDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM
rcLine.right = rcItem.right - 3;
DrawEdge(cd->nmcd.hdc, &rcLine, BDR_SUNKENOUTER, BF_RECT);
}
- else
- {
+ else {
RECT rcItemDescr, rcItemValue;
char str[MAX_PATH];
@@ -337,7 +317,7 @@ INT_PTR CALLBACK ChangeInfoDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM
rcItemDescr.right = rcItemValue.left;
rcItemDescr.left += 2;
- DrawTextUtf(cd->nmcd.hdc, ICQTranslateUtfStatic(setting[cd->nmcd.lItemlParam].szDescription, str, MAX_PATH), &rcItemDescr, DT_END_ELLIPSIS|DT_LEFT|DT_NOCLIP|DT_NOPREFIX|DT_SINGLELINE|DT_VCENTER, NULL);
+ DrawTextUtf(cd->nmcd.hdc, ICQTranslateUtfStatic(setting[cd->nmcd.lItemlParam].szDescription, str, MAX_PATH), &rcItemDescr, DT_END_ELLIPSIS | DT_LEFT | DT_NOCLIP | DT_NOPREFIX | DT_SINGLELINE | DT_VCENTER, NULL);
dat->PaintItemSetting(cd->nmcd.hdc, &rcItemValue, cd->nmcd.lItemlParam, cd->nmcd.uItemState);
}
@@ -348,18 +328,19 @@ INT_PTR CALLBACK ChangeInfoDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM
return TRUE;
}
}
- break;
}
+ break;
+
case NM_CLICK:
- {
- LPNMLISTVIEW nm=(LPNMLISTVIEW)lParam;
+ {
+ LPNMLISTVIEW nm = (LPNMLISTVIEW)lParam;
LV_ITEM lvi;
RECT rc;
dat->EndStringEdit(1);
dat->EndListEdit(1);
if (nm->iSubItem != 1) break;
- lvi.mask = LVIF_PARAM|LVIF_STATE;
+ lvi.mask = LVIF_PARAM | LVIF_STATE;
lvi.stateMask = 0xFFFFFFFF;
lvi.iItem = nm->iItem; lvi.iSubItem = nm->iSubItem;
ListView_GetItem(dat->hwndList, &lvi);
@@ -371,61 +352,65 @@ INT_PTR CALLBACK ChangeInfoDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM
case LI_STRING:
case LI_LONGSTRING:
case LI_NUMBER:
- dat->BeginStringEdit(nm->iItem, &rc, lvi. lParam, 0);
+ dat->BeginStringEdit(nm->iItem, &rc, lvi.lParam, 0);
break;
case LI_LIST:
- dat->BeginListEdit(nm->iItem, &rc, lvi. lParam, 0);
+ dat->BeginListEdit(nm->iItem, &rc, lvi.lParam, 0);
break;
}
- break;
}
+ break;
+
case LVN_KEYDOWN:
- {
- LPNMLVKEYDOWN nm=(LPNMLVKEYDOWN)lParam;
+ {
+ LPNMLVKEYDOWN nm = (LPNMLVKEYDOWN)lParam;
LV_ITEM lvi;
RECT rc;
dat->EndStringEdit(1);
dat->EndListEdit(1);
- if(nm->wVKey==VK_SPACE || nm->wVKey==VK_RETURN || nm->wVKey==VK_F2) nm->wVKey=0;
- if(nm->wVKey && (nm->wVKey<'0' || (nm->wVKey>'9' && nm->wVKey<'A') || (nm->wVKey>'Z' && nm->wVKey<VK_NUMPAD0) || nm->wVKey>=VK_F1))
+ if (nm->wVKey == VK_SPACE || nm->wVKey == VK_RETURN || nm->wVKey == VK_F2) nm->wVKey = 0;
+ if (nm->wVKey && (nm->wVKey<'0' || (nm->wVKey>'9' && nm->wVKey<'A') || (nm->wVKey>'Z' && nm->wVKey < VK_NUMPAD0) || nm->wVKey >= VK_F1))
break;
- lvi.mask=LVIF_PARAM|LVIF_STATE;
- lvi.stateMask=0xFFFFFFFF;
- lvi.iItem = ListView_GetNextItem(dat->hwndList, -1, LVNI_ALL|LVNI_SELECTED);
- if (lvi.iItem==-1) break;
- lvi.iSubItem=1;
- ListView_GetItem(dat->hwndList,&lvi);
- ListView_EnsureVisible(dat->hwndList,lvi.iItem,FALSE);
- ListView_GetSubItemRect(dat->hwndList,lvi.iItem,lvi.iSubItem,LVIR_BOUNDS,&rc);
+ lvi.mask = LVIF_PARAM | LVIF_STATE;
+ lvi.stateMask = 0xFFFFFFFF;
+ lvi.iItem = ListView_GetNextItem(dat->hwndList, -1, LVNI_ALL | LVNI_SELECTED);
+ if (lvi.iItem == -1) break;
+ lvi.iSubItem = 1;
+ ListView_GetItem(dat->hwndList, &lvi);
+ ListView_EnsureVisible(dat->hwndList, lvi.iItem, FALSE);
+ ListView_GetSubItemRect(dat->hwndList, lvi.iItem, lvi.iSubItem, LVIR_BOUNDS, &rc);
dat->editTopIndex = ListView_GetTopIndex(dat->hwndList);
- switch(setting[lvi.lParam].displayType & LIM_TYPE) {
+ switch (setting[lvi.lParam].displayType & LIM_TYPE) {
case LI_STRING:
case LI_LONGSTRING:
case LI_NUMBER:
- dat->BeginStringEdit(lvi.iItem,&rc,lvi.lParam,nm->wVKey);
+ dat->BeginStringEdit(lvi.iItem, &rc, lvi.lParam, nm->wVKey);
break;
case LI_LIST:
- dat->BeginListEdit(lvi.iItem,&rc,lvi.lParam,nm->wVKey);
+ dat->BeginListEdit(lvi.iItem, &rc, lvi.lParam, nm->wVKey);
break;
}
SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, TRUE);
- return TRUE;
}
+ return TRUE;
+
case NM_KILLFOCUS:
- if (!IsStringEditWindow(GetFocus())) dat->EndStringEdit(1);
- if (!IsListEditWindow(GetFocus())) dat->EndListEdit(1);
- break;
+ if (!IsStringEditWindow(GetFocus()))
+ dat->EndStringEdit(1);
+ if (!IsListEditWindow(GetFocus()))
+ dat->EndListEdit(1);
}
- break;
}
break;
+
case WM_KILLFOCUS:
dat->EndStringEdit(1);
dat->EndListEdit(1);
break;
+
case WM_COMMAND:
- switch(LOWORD(wParam)) {
+ switch (LOWORD(wParam)) {
case IDCANCEL:
SendMessage(GetParent(hwndDlg), msg, wParam, lParam);
break;
@@ -441,21 +426,19 @@ INT_PTR CALLBACK ChangeInfoDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM
ShowDlgItem(hwndDlg, IDC_UPLOADING, SW_SHOW);
dat->hAckHook = HookEventMessage(ME_PROTO_ACK, hwndDlg, DM_PROTOACK);
- if (!dat->UploadSettings())
- {
+ if (!dat->UploadSettings()) {
EnableDlgItem(hwndDlg, IDC_SAVE, TRUE);
EnableDlgItem(hwndDlg, IDC_LIST, TRUE);
ShowDlgItem(hwndDlg, IDC_UPLOADING, SW_HIDE);
- UnhookEvent(dat->hAckHook);
+ UnhookEvent(dat->hAckHook);
dat->hAckHook = NULL;
}
- break;
}
break;
case WM_SIZE:
{ // make the dlg resizeable
- UTILRESIZEDIALOG urd = {0};
+ UTILRESIZEDIALOG urd = { 0 };
if (IsIconic(hwndDlg)) break;
urd.cbSize = sizeof(urd);
@@ -464,7 +447,7 @@ INT_PTR CALLBACK ChangeInfoDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM
urd.lParam = 0; // user-defined
urd.lpTemplate = MAKEINTRESOURCEA(IDD_INFO_CHANGEINFO);
urd.pfnResizer = ChangeInfoDlg_Resize;
- CallService(MS_UTILS_RESIZEDIALOG, 0, (LPARAM) &urd);
+ CallService(MS_UTILS_RESIZEDIALOG, 0, (LPARAM)&urd);
{ // update listview column widths
RECT rc;
@@ -474,18 +457,17 @@ INT_PTR CALLBACK ChangeInfoDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM
ListView_SetColumnWidth(dat->hwndList, 0, rc.right / 3);
ListView_SetColumnWidth(dat->hwndList, 1, rc.right - rc.right / 3);
}
- break;
}
+ break;
case DM_PROTOACK:
{
- ACKDATA *ack=(ACKDATA*)lParam;
- int i,done;
+ ACKDATA *ack = (ACKDATA*)lParam;
+ int i, done;
if (ack->type != ACKTYPE_SETINFO) break;
- if (ack->result == ACKRESULT_SUCCESS)
- {
- for (i=0; i < SIZEOF(dat->hUpload); i++)
+ if (ack->result == ACKRESULT_SUCCESS) {
+ for (i = 0; i < SIZEOF(dat->hUpload); i++)
if (dat->hUpload[i] && ack->hProcess == dat->hUpload[i]) break;
if (i == SIZEOF(dat->hUpload)) break;
@@ -493,21 +475,20 @@ INT_PTR CALLBACK ChangeInfoDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM
for (done = 0, i = 0; i < SIZEOF(dat->hUpload); i++)
done += dat->hUpload[i] == NULL;
TCHAR buf[MAX_PATH];
- mir_sntprintf(buf, sizeof(buf), TranslateT("Upload in progress...%d%%"), 100*done/(SIZEOF(dat->hUpload)));
+ mir_sntprintf(buf, sizeof(buf), TranslateT("Upload in progress...%d%%"), 100 * done / (SIZEOF(dat->hUpload)));
SetDlgItemText(hwndDlg, IDC_UPLOADING, buf);
if (done < SIZEOF(dat->hUpload)) break;
dat->ClearChangeFlags();
- UnhookEvent(dat->hAckHook);
+ UnhookEvent(dat->hAckHook);
dat->hAckHook = NULL;
EnableDlgItem(hwndDlg, IDC_LIST, TRUE);
EnableDlgItem(hwndDlg, IDC_UPLOADING, FALSE);
SetDlgItemText(hwndDlg, IDC_UPLOADING, TranslateT("Upload complete"));
SendMessage(GetParent(hwndDlg), PSM_FORCECHANGED, 0, 0);
}
- else if (ack->result==ACKRESULT_FAILED)
- {
- UnhookEvent(dat->hAckHook);
+ else if (ack->result == ACKRESULT_FAILED) {
+ UnhookEvent(dat->hAckHook);
dat->hAckHook = NULL;
EnableDlgItem(hwndDlg, IDC_LIST, TRUE);
EnableDlgItem(hwndDlg, IDC_UPLOADING, FALSE);
@@ -515,18 +496,17 @@ INT_PTR CALLBACK ChangeInfoDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM
SendMessage(GetParent(hwndDlg), PSM_FORCECHANGED, 0, 0);
EnableDlgItem(hwndDlg, IDC_SAVE, TRUE);
}
- break;
}
+ break;
+
case WM_DESTROY:
- if (dat->hAckHook)
- {
+ if (dat->hAckHook) {
UnhookEvent(dat->hAckHook);
dat->hAckHook = NULL;
}
- {
- HFONT hFont = (HFONT)SendMessage(dat->hwndList, WM_GETFONT, 0, 0);
- DeleteObject(hFont);
- }
+
+ DeleteObject((HFONT)SendMessage(dat->hwndList, WM_GETFONT, 0, 0));
+
dat->FreeStoredDbSettings();
SetWindowLongPtr(hwndDlg, GWLP_USERDATA, 0);
delete dat;
diff --git a/protocols/IcqOscarJ/src/changeinfo/editlist.cpp b/protocols/IcqOscarJ/src/changeinfo/editlist.cpp
index b18cc30a68..33c0a1e53a 100644
--- a/protocols/IcqOscarJ/src/changeinfo/editlist.cpp
+++ b/protocols/IcqOscarJ/src/changeinfo/editlist.cpp
@@ -25,8 +25,8 @@
// ChangeInfo Plugin stuff
//
// -----------------------------------------------------------------------------
-#include "icqoscar.h"
+#include "icqoscar.h"
static ChangeInfoData *dataListEdit = NULL;
static HWND hwndListEdit = NULL;
@@ -80,43 +80,51 @@ void ChangeInfoData::BeginListEdit(int iItem, RECT *rc, int iSetting, WORD wVKey
UpdateWindow(hwndList);
dataListEdit = this;
- hwndListEdit = CreateWindowEx(WS_EX_TOOLWINDOW | WS_EX_TOPMOST, _T("LISTBOX"), _T(""), WS_POPUP | WS_BORDER | WS_VSCROLL, rc->left, rc->bottom, rc->right - rc->left, 150, NULL, NULL, hInst, NULL);
+ hwndListEdit = CreateWindowEx(WS_EX_TOOLWINDOW | WS_EX_TOPMOST, _T("LISTBOX"), _T(""), WS_POPUP | WS_BORDER | WS_VSCROLL,
+ rc->left, rc->bottom, rc->right - rc->left, 150, NULL, NULL, hInst, NULL);
SendMessage(hwndListEdit, WM_SETFONT, (WPARAM)hListFont, 0);
int itemHeight = SendMessage(hwndListEdit, LB_GETITEMHEIGHT, 0, 0);
- FieldNamesItem *list = (FieldNamesItem*)setting[iSetting].pList;
+ const SettingItem &si = setting[iSetting];
+ SettingItemData &sid = settingData[iSetting];
+ FieldNamesItem *list = (FieldNamesItem*)si.pList;
// some country codes were changed leaving old details uknown, convert it for the user
if (list == countryField) {
- if (settingData[iSetting].value == 420)
- settingData[iSetting].value = 42; // conversion of obsolete codes (OMG!)
- else if (settingData[iSetting].value == 421)
- settingData[iSetting].value = 4201;
- else if (settingData[iSetting].value == 102)
- settingData[iSetting].value = 1201;
+ if (sid.value == 420)
+ sid.value = 42; // conversion of obsolete codes (OMG!)
+ else if (sid.value == 421)
+ sid.value = 4201;
+ else if (sid.value == 102)
+ sid.value = 1201;
}
- int j, n = ListBoxAddStringUtf(hwndListEdit, "Unspecified");
- for (j = 0;; j++)
- if (!list[j].text) {
+ if (list == timezonesField) {
+ tmi.prepareList(NULL, ppro->m_szModuleName, hwndListEdit, TZF_PLF_LB);
+ }
+ else {
+ int j, n = ListBoxAddStringUtf(hwndListEdit, "Unspecified");
+ for (j = 0;; j++)
+ if (!list[j].text) {
+ SendMessage(hwndListEdit, LB_SETITEMDATA, n, j);
+ if ((sid.value == 0 && list[j].code == 0) || (si.dbType != DBVT_ASCIIZ && sid.value == list[j].code))
+ SendMessage(hwndListEdit, LB_SETCURSEL, n, 0);
+ break;
+ }
+
+ for (j = 0; list[j].text; j++) {
+ char str[MAX_PATH];
+ n = ListBoxAddStringUtf(hwndListEdit, list[j].text);
SendMessage(hwndListEdit, LB_SETITEMDATA, n, j);
- if ((settingData[iSetting].value == 0 && list[j].code == 0)
- || (setting[iSetting].dbType != DBVT_ASCIIZ && settingData[iSetting].value == list[j].code))
+ if ((si.dbType == DBVT_ASCIIZ && (!strcmpnull((char*)sid.value, list[j].text))
+ || (si.dbType == DBVT_ASCIIZ && (!strcmpnull((char*)sid.value, ICQTranslateUtfStatic(list[j].text, str, MAX_PATH))))
+ || ((char*)sid.value == NULL && list[j].code == 0))
+ || (si.dbType != DBVT_ASCIIZ && sid.value == list[j].code))
SendMessage(hwndListEdit, LB_SETCURSEL, n, 0);
- break;
}
-
- for (j = 0; list[j].text; j++) {
- char str[MAX_PATH];
- n = ListBoxAddStringUtf(hwndListEdit, list[j].text);
- SendMessage(hwndListEdit, LB_SETITEMDATA, n, j);
- if ((setting[iSetting].dbType == DBVT_ASCIIZ && (!strcmpnull((char*)settingData[iSetting].value, list[j].text))
- || (setting[iSetting].dbType == DBVT_ASCIIZ && (!strcmpnull((char*)settingData[iSetting].value, ICQTranslateUtfStatic(list[j].text, str, MAX_PATH))))
- || ((char*)settingData[iSetting].value == NULL && list[j].code == 0))
- || (setting[iSetting].dbType != DBVT_ASCIIZ && settingData[iSetting].value == list[j].code))
- SendMessage(hwndListEdit, LB_SETCURSEL, n, 0);
+ SendMessage(hwndListEdit, LB_SETTOPINDEX, SendMessage(hwndListEdit, LB_GETCURSEL, 0, 0) - 3, 0);
}
- SendMessage(hwndListEdit, LB_SETTOPINDEX, SendMessage(hwndListEdit, LB_GETCURSEL, 0, 0) - 3, 0);
+
int listCount = SendMessage(hwndListEdit, LB_GETCOUNT, 0, 0);
if (itemHeight * listCount < 150)
SetWindowPos(hwndListEdit, 0, 0, 0, rc->right - rc->left, itemHeight * listCount + GetSystemMetrics(SM_CYBORDER) * 2, SWP_NOZORDER | SWP_NOMOVE);
@@ -132,37 +140,45 @@ void ChangeInfoData::EndListEdit(int save)
{
if (hwndListEdit == NULL || iEditItem == -1 || this != dataListEdit)
return;
-
+
if (save) {
+ const SettingItem &si = setting[iEditItem];
+ SettingItemData &sid = settingData[iEditItem];
+
int iItem = SendMessage(hwndListEdit, LB_GETCURSEL, 0, 0);
int i = SendMessage(hwndListEdit, LB_GETITEMDATA, iItem, 0);
if (iItem != -1 && i != -1) {
- FieldNamesItem &pItem = ((FieldNamesItem*)setting[iEditItem].pList)[i];
-
- if (setting[iEditItem].dbType == DBVT_ASCIIZ) {
- char *szNewValue = pItem.text;
- if (pItem.code || (setting[iEditItem].displayType & LIF_ZEROISVALID)) {
- settingData[iEditItem].changed = strcmpnull(szNewValue, (char*)settingData[iEditItem].value);
- SAFE_FREE((void**)&settingData[iEditItem].value);
- settingData[iEditItem].value = (LPARAM)null_strdup(szNewValue);
+ FieldNamesItem *list = (FieldNamesItem*)si.pList;
+ if (list == timezonesField)
+ tmi.storeListResults(NULL, ppro->m_szModuleName, hwndListEdit, TZF_PLF_LB);
+ else {
+ FieldNamesItem &pItem = list[i];
+
+ if (si.dbType == DBVT_ASCIIZ) {
+ char *szNewValue = pItem.text;
+ if (pItem.code || (si.displayType & LIF_ZEROISVALID)) {
+ sid.changed = strcmpnull(szNewValue, (char*)sid.value);
+ SAFE_FREE((void**)&sid.value);
+ sid.value = (LPARAM)null_strdup(szNewValue);
+ }
+ else {
+ sid.changed = (char*)sid.value != NULL;
+ SAFE_FREE((void**)&sid.value);
+ }
}
else {
- settingData[iEditItem].changed = (char*)settingData[iEditItem].value != NULL;
- SAFE_FREE((void**)&settingData[iEditItem].value);
+ sid.changed = pItem.code != sid.value;
+ sid.value = pItem.code;
+ }
+
+ if (sid.changed) {
+ char buf[MAX_PATH];
+ TCHAR tbuf[MAX_PATH];
+ if (utf8_to_tchar_static(ICQTranslateUtfStatic(pItem.text, buf, SIZEOF(buf)), tbuf, SIZEOF(buf)))
+ ListView_SetItemText(hwndList, iEditItem, 1, tbuf);
+
+ EnableDlgItem(GetParent(hwndList), IDC_SAVE, TRUE);
}
- }
- else {
- settingData[iEditItem].changed = pItem.code != settingData[iEditItem].value;
- settingData[iEditItem].value = pItem.code;
- }
-
- if (settingData[iEditItem].changed) {
- char buf[MAX_PATH];
- TCHAR tbuf[MAX_PATH];
- if (utf8_to_tchar_static(ICQTranslateUtfStatic(pItem.text, buf, SIZEOF(buf)), tbuf, SIZEOF(buf)))
- ListView_SetItemText(hwndList, iEditItem, 1, tbuf);
-
- EnableDlgItem(GetParent(hwndList), IDC_SAVE, TRUE);
}
}
}
@@ -173,7 +189,6 @@ void ChangeInfoData::EndListEdit(int save)
hwndListEdit = NULL;
}
-
int IsListEditWindow(HWND hwnd)
{
if (hwnd == hwndListEdit) return 1;
diff --git a/protocols/IcqOscarJ/src/changeinfo/editstring.cpp b/protocols/IcqOscarJ/src/changeinfo/editstring.cpp
index 4f1b33ba46..2f99e4731f 100644
--- a/protocols/IcqOscarJ/src/changeinfo/editstring.cpp
+++ b/protocols/IcqOscarJ/src/changeinfo/editstring.cpp
@@ -171,53 +171,50 @@ static LRESULT CALLBACK StringEditSubclassProc(HWND hwnd,UINT msg,WPARAM wParam,
return mir_callNextSubclass(hwnd, StringEditSubclassProc, msg, wParam, lParam);
}
-static LRESULT CALLBACK ExpandButtonSubclassProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam)
+static LRESULT CALLBACK ExpandButtonSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
- switch(msg) {
+ switch (msg) {
case WM_LBUTTONUP:
- if(GetCapture()==hwnd)
- {
+ if (GetCapture() == hwnd) {
//do expand
- RECT rcStart,rcEnd;
- DWORD selStart,selEnd;
+ RECT rcStart, rcEnd;
+ DWORD selStart, selEnd;
WCHAR *text;
- BOOL animEnabled=TRUE;
+ BOOL animEnabled = TRUE;
- GetWindowRect(hwndEdit,&rcStart);
- InflateRect(&rcStart,2,2);
+ GetWindowRect(hwndEdit, &rcStart);
+ InflateRect(&rcStart, 2, 2);
text = GetWindowTextUcs(hwndEdit);
- SendMessage(hwndEdit,EM_GETSEL,(WPARAM)&selStart,(LPARAM)&selEnd);
+ SendMessage(hwndEdit, EM_GETSEL, (WPARAM)&selStart, (LPARAM)&selEnd);
DestroyWindow(hwndEdit);
- EscapesToMultiline(text,&selStart,&selEnd);
- hwndEdit=CreateWindowExA(WS_EX_TOOLWINDOW,"EDIT","",WS_POPUP|WS_BORDER|WS_VISIBLE|ES_WANTRETURN|ES_AUTOVSCROLL|WS_VSCROLL|ES_MULTILINE,rcStart.left,rcStart.top,rcStart.right-rcStart.left,rcStart.bottom-rcStart.top,NULL,NULL,hInst,NULL);
+ EscapesToMultiline(text, &selStart, &selEnd);
+ hwndEdit = CreateWindowExA(WS_EX_TOOLWINDOW, "EDIT", "", WS_POPUP | WS_BORDER | WS_VISIBLE | ES_WANTRETURN | ES_AUTOVSCROLL | WS_VSCROLL | ES_MULTILINE, rcStart.left, rcStart.top, rcStart.right - rcStart.left, rcStart.bottom - rcStart.top, NULL, NULL, hInst, NULL);
SetWindowTextUcs(hwndEdit, text);
mir_subclassWindow(hwndEdit, StringEditSubclassProc);
- SendMessage(hwndEdit,WM_SETFONT,(WPARAM)dataStringEdit->hListFont,0);
- SendMessage(hwndEdit,EM_SETSEL,selStart,selEnd);
+ SendMessage(hwndEdit, WM_SETFONT, (WPARAM)dataStringEdit->hListFont, 0);
+ SendMessage(hwndEdit, EM_SETSEL, selStart, selEnd);
SetFocus(hwndEdit);
- rcEnd.left=rcStart.left; rcEnd.top=rcStart.top;
- rcEnd.right=rcEnd.left+350;
- rcEnd.bottom=rcEnd.top+150;
- if (LOBYTE(LOWORD(GetVersion()))>4 || HIBYTE(LOWORD(GetVersion()))>0)
- SystemParametersInfo(SPI_GETCOMBOBOXANIMATION,0,&animEnabled,FALSE);
- if(animEnabled)
- {
- DWORD startTime,timeNow;
- startTime=GetTickCount();
- for (;;)
- {
+ rcEnd.left = rcStart.left; rcEnd.top = rcStart.top;
+ rcEnd.right = rcEnd.left + 350;
+ rcEnd.bottom = rcEnd.top + 150;
+ if (LOBYTE(LOWORD(GetVersion())) > 4 || HIBYTE(LOWORD(GetVersion())) > 0)
+ SystemParametersInfo(SPI_GETCOMBOBOXANIMATION, 0, &animEnabled, FALSE);
+ if (animEnabled) {
+ DWORD startTime, timeNow;
+ startTime = GetTickCount();
+ for (;;) {
UpdateWindow(hwndEdit);
- timeNow=GetTickCount();
- if(timeNow>startTime+200) break;
- SetWindowPos(hwndEdit,0,rcEnd.left,rcEnd.top,(rcEnd.right-rcStart.right)*(timeNow-startTime)/200+rcStart.right-rcEnd.left,(rcEnd.bottom-rcStart.bottom)*(timeNow-startTime)/200+rcStart.bottom-rcEnd.top,SWP_NOZORDER);
+ timeNow = GetTickCount();
+ if (timeNow > startTime + 200) break;
+ SetWindowPos(hwndEdit, 0, rcEnd.left, rcEnd.top, (rcEnd.right - rcStart.right)*(timeNow - startTime) / 200 + rcStart.right - rcEnd.left, (rcEnd.bottom - rcStart.bottom)*(timeNow - startTime) / 200 + rcStart.bottom - rcEnd.top, SWP_NOZORDER);
}
}
- SetWindowPos(hwndEdit,0,rcEnd.left,rcEnd.top,rcEnd.right-rcEnd.left,rcEnd.bottom-rcEnd.top,SWP_NOZORDER);
+ SetWindowPos(hwndEdit, 0, rcEnd.left, rcEnd.top, rcEnd.right - rcEnd.left, rcEnd.bottom - rcEnd.top, SWP_NOZORDER);
DestroyWindow(hwnd);
- hwndExpandButton=NULL;
+ hwndExpandButton = NULL;
SAFE_FREE((void**)&text);
}
@@ -230,57 +227,57 @@ void ChangeInfoData::BeginStringEdit(int iItem, RECT *rc, int i, WORD wVKey)
{
char *szValue;
char str[80];
- int alloced=0;
+ int alloced = 0;
EndStringEdit(0);
- InflateRect(rc,-2,-2);
- rc->left-=2;
- if (setting[i].displayType & LIF_PASSWORD && !settingData[i].changed)
+ InflateRect(rc, -2, -2);
+ rc->left -= 2;
+
+ const SettingItem &si = setting[i];
+ SettingItemData &sid = settingData[i];
+
+ if (si.displayType & LIF_PASSWORD && !sid.changed)
szValue = " ";
- else if ((setting[i].displayType & LIM_TYPE) == LI_NUMBER)
- {
+ else if ((si.displayType & LIM_TYPE) == LI_NUMBER) {
szValue = str;
- mir_snprintf(str, sizeof(str), "%d", settingData[i].value );
+ mir_snprintf(str, sizeof(str), "%d", sid.value);
}
- else if (settingData[i].value)
- {
- szValue = BinaryToEscapes((char*)settingData[i].value);
+ else if (sid.value) {
+ szValue = BinaryToEscapes((char*)sid.value);
alloced = 1;
}
else szValue = "";
iEditItem = iItem;
- if ((setting[i].displayType & LIM_TYPE)==LI_LONGSTRING)
- {
- rc->right-=rc->bottom-rc->top;
- hwndExpandButton=CreateWindowA("BUTTON","",WS_VISIBLE|WS_CHILD|BS_PUSHBUTTON|BS_ICON,rc->right,rc->top,rc->bottom-rc->top,rc->bottom-rc->top,hwndList,NULL,hInst,NULL);
- SendMessage(hwndExpandButton,BM_SETIMAGE,IMAGE_ICON,(LPARAM)LoadImage(hInst,MAKEINTRESOURCE(IDI_EXPANDSTRINGEDIT),IMAGE_ICON,0,0,LR_SHARED));
+ if ((si.displayType & LIM_TYPE) == LI_LONGSTRING) {
+ rc->right -= rc->bottom - rc->top;
+ hwndExpandButton = CreateWindowA("BUTTON", "", WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON | BS_ICON, rc->right, rc->top, rc->bottom - rc->top, rc->bottom - rc->top, hwndList, NULL, hInst, NULL);
+ SendMessage(hwndExpandButton, BM_SETIMAGE, IMAGE_ICON, (LPARAM)LoadImage(hInst, MAKEINTRESOURCE(IDI_EXPANDSTRINGEDIT), IMAGE_ICON, 0, 0, LR_SHARED));
mir_subclassWindow(hwndExpandButton, ExpandButtonSubclassProc);
}
dataStringEdit = this;
- hwndEdit = CreateWindow(_T("EDIT"),_T(""),WS_VISIBLE|WS_CHILD|ES_AUTOHSCROLL|((setting[i].displayType&LIM_TYPE)==LI_NUMBER?ES_NUMBER:0)|(setting[i].displayType&LIF_PASSWORD?ES_PASSWORD:0),rc->left,rc->top,rc->right-rc->left,rc->bottom-rc->top,hwndList,NULL,hInst,NULL);
+ hwndEdit = CreateWindow(_T("EDIT"), _T(""), WS_VISIBLE | WS_CHILD | ES_AUTOHSCROLL | ((si.displayType&LIM_TYPE) == LI_NUMBER ? ES_NUMBER : 0) | (si.displayType&LIF_PASSWORD ? ES_PASSWORD : 0), rc->left, rc->top, rc->right - rc->left, rc->bottom - rc->top, hwndList, NULL, hInst, NULL);
SetWindowTextUtf(hwndEdit, szValue);
if (alloced) SAFE_FREE(&szValue);
mir_subclassWindow(hwndEdit, StringEditSubclassProc);
- SendMessage(hwndEdit,WM_SETFONT,(WPARAM)hListFont,0);
- if ((setting[i].displayType & LIM_TYPE) == LI_NUMBER)
- {
- int *range= (int*)setting[i].pList;
+ SendMessage(hwndEdit, WM_SETFONT, (WPARAM)hListFont, 0);
+ if ((si.displayType & LIM_TYPE) == LI_NUMBER) {
+ int *range = (int*)si.pList;
RECT rcUpDown;
- hwndUpDown=CreateWindow(UPDOWN_CLASS,_T(""),WS_VISIBLE|WS_CHILD|UDS_AUTOBUDDY|UDS_ALIGNRIGHT|UDS_HOTTRACK|UDS_NOTHOUSANDS|UDS_SETBUDDYINT,0,0,0,0,hwndList,NULL,hInst,NULL);
+ hwndUpDown = CreateWindow(UPDOWN_CLASS, _T(""), WS_VISIBLE | WS_CHILD | UDS_AUTOBUDDY | UDS_ALIGNRIGHT | UDS_HOTTRACK | UDS_NOTHOUSANDS | UDS_SETBUDDYINT, 0, 0, 0, 0, hwndList, NULL, hInst, NULL);
SendMessage(hwndUpDown, UDM_SETRANGE32, range[0], range[1]);
- SendMessage(hwndUpDown, UDM_SETPOS32, 0, settingData[i].value);
- if (!(setting[i].displayType & LIF_ZEROISVALID) && settingData[i].value==0)
+ SendMessage(hwndUpDown, UDM_SETPOS32, 0, sid.value);
+ if (!(si.displayType & LIF_ZEROISVALID) && sid.value == 0)
SetWindowTextA(hwndEdit, "");
GetClientRect(hwndUpDown, &rcUpDown);
rc->right -= rcUpDown.right;
- SetWindowPos(hwndEdit,0,0,0,rc->right-rc->left,rc->bottom-rc->top,SWP_NOZORDER|SWP_NOMOVE);
+ SetWindowPos(hwndEdit, 0, 0, 0, rc->right - rc->left, rc->bottom - rc->top, SWP_NOZORDER | SWP_NOMOVE);
}
- SendMessage(hwndEdit,EM_SETSEL,0,(LPARAM)-1);
+ SendMessage(hwndEdit, EM_SETSEL, 0, (LPARAM)-1);
SetFocus(hwndEdit);
- PostMessage(hwndEdit,WM_KEYDOWN,wVKey,0);
+ PostMessage(hwndEdit, WM_KEYDOWN, wVKey, 0);
}
void ChangeInfoData::EndStringEdit(int save)
@@ -289,45 +286,44 @@ void ChangeInfoData::EndStringEdit(int save)
return;
if (save) {
- char *text = (char*)SAFE_MALLOC(GetWindowTextLength(hwndEdit)+1);
+ char *text = (char*)SAFE_MALLOC(GetWindowTextLength(hwndEdit) + 1);
+ const SettingItem &si = setting[iEditItem];
+ SettingItemData &sid = settingData[iEditItem];
- GetWindowTextA(hwndEdit,(char*)text,GetWindowTextLength(hwndEdit)+1);
+ GetWindowTextA(hwndEdit, (char*)text, GetWindowTextLength(hwndEdit) + 1);
EscapesToBinary(text);
- if ((setting[iEditItem].displayType&LIM_TYPE)==LI_NUMBER)
- {
+ if ((si.displayType & LIM_TYPE) == LI_NUMBER) {
LPARAM newValue;
- int *range=(int*)setting[iEditItem].pList;
+ int *range = (int*)si.pList;
newValue = atoi(text);
- if (newValue)
- {
- if (newValue<range[0]) newValue=range[0];
- if (newValue>range[1]) newValue=range[1];
+ if (newValue) {
+ if (newValue<range[0]) newValue = range[0];
+ if (newValue>range[1]) newValue = range[1];
}
- settingData[iEditItem].changed = settingData[iEditItem].value != newValue;
- settingData[iEditItem].value = newValue;
+ sid.changed = sid.value != newValue;
+ sid.value = newValue;
SAFE_FREE(&text);
}
else {
- if (!(setting[iEditItem].displayType & LIF_PASSWORD)) {
+ if (!(si.displayType & LIF_PASSWORD)) {
SAFE_FREE(&text);
text = GetWindowTextUtf(hwndEdit);
EscapesToBinary(text);
}
- if ((setting[iEditItem].displayType & LIF_PASSWORD && strcmpnull(text," ")) ||
- (!(setting[iEditItem].displayType & LIF_PASSWORD) && strcmpnull(text, (char*)settingData[iEditItem].value) && (strlennull(text) + strlennull((char*)settingData[iEditItem].value))))
- {
- SAFE_FREE((void**)&settingData[iEditItem].value);
+ if ((si.displayType & LIF_PASSWORD && strcmpnull(text, " ")) ||
+ (!(si.displayType & LIF_PASSWORD) && strcmpnull(text, (char*)sid.value) && (strlennull(text) + strlennull((char*)sid.value)))) {
+ SAFE_FREE((void**)&sid.value);
if (strlennull(text))
- settingData[iEditItem].value = (LPARAM)text;
+ sid.value = (LPARAM)text;
else {
- settingData[iEditItem].value = 0;
+ sid.value = 0;
SAFE_FREE(&text);
}
- settingData[iEditItem].changed = 1;
+ sid.changed = 1;
}
}
- if (settingData[iEditItem].changed) {
+ if (sid.changed) {
TCHAR tbuf[MAX_PATH];
GetWindowText(hwndEdit, tbuf, SIZEOF(tbuf));