diff options
author | Vadim Dashevskiy <watcherhd@gmail.com> | 2012-10-12 14:53:57 +0000 |
---|---|---|
committer | Vadim Dashevskiy <watcherhd@gmail.com> | 2012-10-12 14:53:57 +0000 |
commit | 3b55a62fdcb1f8222de3c2c8fbed530792c419a0 (patch) | |
tree | 5b2f628e847f61bb3e16f95ecaed6e187963362f /protocols/IcqOscarJ/src/changeinfo | |
parent | 1f9c986d82657f965462d289bf94aa012cf026fc (diff) |
GTalkExt, ICQ, IRC, Jabber: folders restructurization
git-svn-id: http://svn.miranda-ng.org/main/trunk@1890 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/IcqOscarJ/src/changeinfo')
-rw-r--r-- | protocols/IcqOscarJ/src/changeinfo/changeinfo.h | 122 | ||||
-rw-r--r-- | protocols/IcqOscarJ/src/changeinfo/constants.cpp | 198 | ||||
-rw-r--r-- | protocols/IcqOscarJ/src/changeinfo/db.cpp | 224 | ||||
-rw-r--r-- | protocols/IcqOscarJ/src/changeinfo/dlgproc.cpp | 540 | ||||
-rw-r--r-- | protocols/IcqOscarJ/src/changeinfo/editlist.cpp | 201 | ||||
-rw-r--r-- | protocols/IcqOscarJ/src/changeinfo/editstring.cpp | 367 | ||||
-rw-r--r-- | protocols/IcqOscarJ/src/changeinfo/icqoscar.h | 2 | ||||
-rw-r--r-- | protocols/IcqOscarJ/src/changeinfo/main.cpp | 28 | ||||
-rw-r--r-- | protocols/IcqOscarJ/src/changeinfo/upload.cpp | 91 |
9 files changed, 1773 insertions, 0 deletions
diff --git a/protocols/IcqOscarJ/src/changeinfo/changeinfo.h b/protocols/IcqOscarJ/src/changeinfo/changeinfo.h new file mode 100644 index 0000000000..ecc4fc3106 --- /dev/null +++ b/protocols/IcqOscarJ/src/changeinfo/changeinfo.h @@ -0,0 +1,122 @@ +// ---------------------------------------------------------------------------80
+// ICQ plugin for Miranda Instant Messenger
+// ________________________________________
+//
+// Copyright © 2001-2004 Richard Hughes, Martin Öberg
+// Copyright © 2004-2010 Joe Kucera, Bio
+//
+// 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+//
+// -----------------------------------------------------------------------------
+// DESCRIPTION:
+//
+// ChangeInfo Plugin stuff
+//
+// -----------------------------------------------------------------------------
+
+#ifndef __CHANGEINFO_H
+#define __CHANGEINFO_H
+
+
+#ifndef AW_SLIDE
+#define SPI_GETCOMBOBOXANIMATION 0x1004
+#define AW_SLIDE 0x40000
+#define AW_ACTIVATE 0x20000
+#define AW_VER_POSITIVE 0x4
+#define UDM_SETPOS32 (WM_USER+113)
+#define UDM_GETPOS32 (WM_USER+114)
+#endif
+
+
+#define LI_DIVIDER 0
+#define LI_STRING 1
+#define LI_LIST 2
+#define LI_LONGSTRING 3
+#define LI_NUMBER 4
+#define LIM_TYPE 0x0000FFFF
+#define LIF_ZEROISVALID 0x80000000
+#define LIF_SIGNED 0x40000000
+#define LIF_PASSWORD 0x20000000
+#define LIF_CHANGEONLY 0x10000000
+
+struct SettingItem
+{
+ const char *szDescription;
+ unsigned displayType; //LI_ constant
+ int dbType; //DBVT_ constant
+ const char *szDbSetting;
+ const void *pList;
+};
+
+struct SettingItemData
+{
+ LPARAM value;
+ int changed;
+};
+
+// contants.c
+extern const SettingItem setting[];
+extern const int settingCount;
+
+//dlgproc.c
+struct ChangeInfoData : public MZeroedObject
+{
+ HWND hwndDlg;
+ CIcqProto *ppro;
+ HFONT hListFont;
+ HWND hwndList;
+ int editTopIndex;
+ int iEditItem;
+ char Password[PASSWORDMAXLEN];
+
+ SettingItemData *settingData;
+
+ HANDLE hAckHook;
+ HANDLE hUpload[2];
+
+ ChangeInfoData() { settingData = (SettingItemData*)SAFE_MALLOC(sizeof(SettingItemData) * settingCount); hAckHook = NULL; hUpload[0] = NULL; hUpload[1] = NULL;}
+ ~ChangeInfoData() { SAFE_FREE((void**)&settingData); }
+
+ char* GetItemSettingText(int i, char *buf, size_t buf_size);
+ void PaintItemSetting(HDC hdc, RECT *rc, int i, UINT itemState);
+
+ //db.cpp
+ void LoadSettingsFromDb(int keepChanged);
+ void FreeStoredDbSettings(void);
+ int ChangesMade(void);
+ void ClearChangeFlags(void);
+ int SaveSettingsToDb(HWND hwndDlg);
+
+ //upload.cpp
+ int UploadSettings(void);
+
+ //editstring.cpp
+ void BeginStringEdit(int iItem,RECT *rc,int i,WORD wVKey);
+ void EndStringEdit(int save);
+ //editlist.cpp
+ void BeginListEdit(int iItem, RECT *rc, int iSetting, WORD wVKey);
+ void EndListEdit(int save);
+};
+
+INT_PTR CALLBACK ChangeInfoDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
+
+//editstring.c
+int IsStringEditWindow(HWND hwnd);
+char* BinaryToEscapes(char *str);
+
+//editlist.c
+int IsListEditWindow(HWND hwnd);
+
+#endif /* __CHANGEINFO_H */
diff --git a/protocols/IcqOscarJ/src/changeinfo/constants.cpp b/protocols/IcqOscarJ/src/changeinfo/constants.cpp new file mode 100644 index 0000000000..92403a74f0 --- /dev/null +++ b/protocols/IcqOscarJ/src/changeinfo/constants.cpp @@ -0,0 +1,198 @@ +// ---------------------------------------------------------------------------80
+// ICQ plugin for Miranda Instant Messenger
+// ________________________________________
+//
+// Copyright © 2001-2004 Richard Hughes, Martin Öberg
+// Copyright © 2004-2009 Joe Kucera, Bio
+//
+// 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.
+//
+// -----------------------------------------------------------------------------
+// DESCRIPTION:
+//
+// ChangeInfo Plugin stuff
+//
+// -----------------------------------------------------------------------------
+#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};
+
+
+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("Age"), LI_NUMBER, DBVT_WORD, "Age", ageRange},
+ {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_ASCIIZ, "Password"},
+ //contact
+ {LPGEN("Contact"), LI_DIVIDER},
+ {LPGEN("Primary e-mail"), LI_STRING, DBVT_ASCIIZ, "e-mail0"},
+ {LPGEN("Secondary e-mail"), LI_STRING, DBVT_ASCIIZ, "e-mail1"},
+ {LPGEN("Tertiary e-mail"), LI_STRING, DBVT_ASCIIZ, "e-mail2"},
+ {LPGEN("Homepage"), LI_STRING, DBVT_ASCIIZ, "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_ASCIIZ, "Phone"},
+ {LPGEN("Fax number"), LI_STRING, DBVT_ASCIIZ, "Fax"},
+ {LPGEN("Cellular number"),LI_STRING, DBVT_ASCIIZ, "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_ASCIIZ, "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_ASCIIZ, "CompanyPhone"},
+ {LPGEN("Company fax"), LI_STRING, DBVT_ASCIIZ, "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},
+// {LPGEN("Company occupation"),LI_LIST, DBVT_WORD, "CompanyOccupation", occupationField},
+ //interests
+ {LPGEN("Personal Interests"), LI_DIVIDER},
+ {LPGEN("Interest category 1"),LI_LIST, DBVT_WORD, "Interest0Cat", interestsField},
+ {LPGEN("Interest areas 1"),LI_STRING, DBVT_ASCIIZ, "Interest0Text"},
+ {LPGEN("Interest category 2"),LI_LIST, DBVT_WORD, "Interest1Cat", interestsField},
+ {LPGEN("Interest areas 2"),LI_STRING, DBVT_ASCIIZ, "Interest1Text"},
+ {LPGEN("Interest category 3"),LI_LIST, DBVT_WORD, "Interest2Cat", interestsField},
+ {LPGEN("Interest areas 3"),LI_STRING, DBVT_ASCIIZ, "Interest2Text"},
+ {LPGEN("Interest category 4"),LI_LIST, DBVT_WORD, "Interest3Cat", interestsField},
+ {LPGEN("Interest areas 4"),LI_STRING, DBVT_ASCIIZ, "Interest3Text"},
+ //pastbackground
+// {LPGEN("Past Background"), LI_DIVIDER},
+// {LPGEN("Category 1"), LI_LIST, DBVT_ASCIIZ, "Past0", pastField},
+// {LPGEN("Past Background 1"),LI_STRING, DBVT_ASCIIZ, "Past0Text"},
+// {LPGEN("Category 2"), LI_LIST, DBVT_ASCIIZ, "Past1", pastField},
+// {LPGEN("Past Background 2"),LI_STRING, DBVT_ASCIIZ, "Past1Text"},
+// {LPGEN("Category 3"), LI_LIST, DBVT_ASCIIZ, "Past2", pastField},
+// {LPGEN("Past Background 3"),LI_STRING, DBVT_ASCIIZ, "Past2Text"},
+ //affiliation
+// {LPGEN("Affiliations"), LI_DIVIDER},
+// {LPGEN("Affiliation category 1"),LI_LIST,DBVT_ASCIIZ, "Affiliation0", affiliationField},
+// {LPGEN("Affiliation 1"), LI_STRING, DBVT_ASCIIZ, "Affiliation0Text"},
+// {LPGEN("Affiliation category 2"),LI_LIST,DBVT_ASCIIZ, "Affiliation1", affiliationField},
+// {LPGEN("Affiliation 2"), LI_STRING, DBVT_ASCIIZ, "Affiliation1Text"},
+// {LPGEN("Affiliation category 3"),LI_LIST,DBVT_ASCIIZ, "Affiliation2", affiliationField},
+// {LPGEN("Affiliation 3"), LI_STRING, DBVT_ASCIIZ, "Affiliation2Text"}
+};
+
+const int settingCount = SIZEOF(setting);
diff --git a/protocols/IcqOscarJ/src/changeinfo/db.cpp b/protocols/IcqOscarJ/src/changeinfo/db.cpp new file mode 100644 index 0000000000..643dcaa034 --- /dev/null +++ b/protocols/IcqOscarJ/src/changeinfo/db.cpp @@ -0,0 +1,224 @@ +// ---------------------------------------------------------------------------80
+// ICQ plugin for Miranda Instant Messenger
+// ________________________________________
+//
+// Copyright © 2001-2004 Richard Hughes, Martin Öberg
+// Copyright © 2004-2009 Joe Kucera, Bio
+//
+// 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.
+//
+// -----------------------------------------------------------------------------
+// DESCRIPTION:
+//
+// ChangeInfo Plugin stuff
+//
+// -----------------------------------------------------------------------------
+#include "icqoscar.h"
+
+
+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);
+ else if (!keepChanged)
+ settingData[i].value = 0;
+
+ settingData[i].changed = 0;
+
+ if (setting[i].displayType & LIF_PASSWORD) continue;
+
+ DBVARIANT dbv = {DBVT_DELETED};
+ if (!ppro->getSetting(NULL, setting[i].szDbSetting, &dbv))
+ {
+ switch(dbv.type) {
+ case DBVT_ASCIIZ:
+ settingData[i].value = (LPARAM)ppro->getSettingStringUtf(NULL, setting[i].szDbSetting, NULL);
+ break;
+
+ case DBVT_UTF8:
+ settingData[i].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;
+ break;
+
+ case DBVT_BYTE:
+ if (setting[i].displayType & LIF_SIGNED)
+ settingData[i].value = dbv.cVal;
+ else
+ settingData[i].value = dbv.bVal;
+ break;
+
+#ifdef _DEBUG
+ default:
+ MessageBoxA(NULL, "That's not supposed to happen either", "Huh?", MB_OK);
+ break;
+#endif
+ }
+ ICQFreeVariant(&dbv);
+ }
+
+ 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);
+ }
+}
+
+
+void ChangeInfoData::FreeStoredDbSettings(void)
+{
+ 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++ )
+ if (settingData[i].changed)
+ return 1;
+ return 0;
+}
+
+
+void ChangeInfoData::ClearChangeFlags(void)
+{
+ for (int i=0; i < settingCount; i++)
+ settingData[i].changed = 0;
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
+struct PwConfirmDlgParam
+{
+ CIcqProto* ppro;
+ char* Pass;
+};
+
+static INT_PTR CALLBACK PwConfirmDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ PwConfirmDlgParam* dat = (PwConfirmDlgParam*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+
+ switch(msg) {
+ case WM_INITDIALOG:
+ TranslateDialogDefault(hwndDlg);
+ SetWindowLongPtr(hwndDlg, GWLP_USERDATA, 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, dat->ppro->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, dat->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 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->deleteSetting(NULL, setting[i].szDbSetting);
+ continue;
+ }
+ switch(setting[i].dbType) {
+ case DBVT_ASCIIZ:
+ if (setting[i].displayType & LIF_PASSWORD)
+ {
+ int nSettingLen = strlennull((char*)settingData[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;
+ }
+ PwConfirmDlgParam param = { ppro, (char*)settingData[i].value };
+ if (IDOK != DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_PWCONFIRM), hwndDlg, PwConfirmDlgProc, (LPARAM)¶m))
+ {
+ ret = 0;
+ break;
+ }
+ strcpy(ppro->m_szPassword, (char*)settingData[i].value);
+ }
+ else {
+ if (*(char*)settingData[i].value)
+ ppro->setSettingStringUtf(NULL, setting[i].szDbSetting, (char*)settingData[i].value);
+ else
+ ppro->deleteSetting(NULL, setting[i].szDbSetting);
+ }
+ break;
+
+ case DBVT_UTF8:
+ if (*(char*)settingData[i].value)
+ ppro->setSettingStringUtf(NULL, setting[i].szDbSetting, (char*)settingData[i].value);
+ else
+ ppro->deleteSetting(NULL, setting[i].szDbSetting);
+ break;
+
+ case DBVT_WORD:
+ ppro->setSettingWord(NULL, setting[i].szDbSetting, (WORD)settingData[i].value);
+ break;
+
+ case DBVT_BYTE:
+ ppro->setSettingByte(NULL, setting[i].szDbSetting, (BYTE)settingData[i].value);
+ break;
+ }
+ }
+ return ret;
+}
diff --git a/protocols/IcqOscarJ/src/changeinfo/dlgproc.cpp b/protocols/IcqOscarJ/src/changeinfo/dlgproc.cpp new file mode 100644 index 0000000000..404777aa97 --- /dev/null +++ b/protocols/IcqOscarJ/src/changeinfo/dlgproc.cpp @@ -0,0 +1,540 @@ +// ---------------------------------------------------------------------------80
+// ICQ plugin for Miranda Instant Messenger
+// ________________________________________
+//
+// Copyright © 2001-2004 Richard Hughes, Martin Öberg
+// Copyright © 2004-2010 Joe Kucera, Bio
+//
+// 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+//
+// -----------------------------------------------------------------------------
+// DESCRIPTION:
+//
+// ChangeInfo Plugin stuff
+//
+// -----------------------------------------------------------------------------
+#include "icqoscar.h"
+
+
+#define DM_PROTOACK (WM_USER+10)
+
+static int DrawTextUtf(HDC hDC, char *text, LPRECT lpRect, UINT uFormat, LPSIZE lpSize)
+{
+ int res;
+
+ WCHAR *tmp = make_unicode_string(text);
+ res = DrawTextW(hDC, tmp, -1, lpRect, uFormat);
+ if (lpSize)
+ GetTextExtentPoint32W(hDC, tmp, strlennull(tmp), lpSize);
+ SAFE_FREE((void**)&tmp);
+
+ return res;
+}
+
+
+char* ChangeInfoData::GetItemSettingText(int i, char *buf, size_t bufsize)
+{
+ char *text = buf;
+ int alloced = 0;
+
+ buf[0] = '\0';
+
+ if (settingData[i].value == 0 && !(setting[i].displayType & LIF_ZEROISVALID))
+ {
+ if (setting[i].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) {
+ case LI_STRING:
+ case LI_LONGSTRING:
+ text = BinaryToEscapes((char*)settingData[i].value);
+ alloced = 1;
+ break;
+
+ case LI_NUMBER:
+ _itoa(settingData[i].value, text, 10);
+ break;
+
+ case LI_LIST:
+ if (setting[i].dbType == DBVT_ASCIIZ)
+ text = ICQTranslateUtfStatic((char*)settingData[i].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)
+ {
+ text = ICQTranslateUtfStatic(list[j].text, buf, bufsize);
+ break;
+ }
+ else if (!list[j].text)
+ {
+ if (list[j].code == settingData[i].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)
+ {
+ SAFE_FREE(&text);
+ alloced = 0;
+ }
+ text = "********";
+ }
+ }
+ if (text != buf)
+ {
+ char *tmp = text;
+
+ text = null_strcpy(buf, text, bufsize - 1);
+ if (alloced)
+ SAFE_FREE(&tmp);
+ }
+
+ 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))
+ SetTextColor(hdc, GetSysColor(COLOR_GRAYTEXT));
+
+ if ((setting[i].displayType & LIM_TYPE) == LI_LIST && (itemState & CDIS_SELECTED || iEditItem == i))
+ {
+ RECT rcBtn;
+
+ rcBtn = *rc;
+ rcBtn.left = rcBtn.right - rc->bottom + rc->top;
+ InflateRect(&rcBtn,-2,-2);
+ rc->right = rcBtn.left;
+ 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);
+}
+
+
+static int ChangeInfoDlg_Resize(HWND hwndDlg, LPARAM lParam, UTILRESIZECONTROL *urc)
+{
+ switch (urc->wId) {
+ case IDC_LIST:
+ return RD_ANCHORX_WIDTH | RD_ANCHORY_HEIGHT;
+
+ case IDC_SAVE:
+ return RD_ANCHORX_RIGHT | RD_ANCHORY_BOTTOM;
+
+ case IDC_UPLOADING:
+ return RD_ANCHORX_WIDTH | RD_ANCHORY_BOTTOM;
+ }
+
+ return RD_ANCHORX_LEFT | RD_ANCHORY_TOP; // default
+}
+
+
+INT_PTR CALLBACK ChangeInfoDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ ChangeInfoData* dat = (ChangeInfoData*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+
+ switch(msg) {
+ case WM_INITDIALOG:
+ TranslateDialogDefault(hwndDlg);
+
+ dat = new ChangeInfoData();
+ SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)dat);
+
+ dat->hwndDlg = hwndDlg;
+ dat->ppro = (CIcqProto*)lParam;
+ dat->hwndList = GetDlgItem(hwndDlg, IDC_LIST);
+
+ ListView_SetExtendedListViewStyle(dat->hwndList, LVS_EX_FULLROWSELECT);
+ dat->iEditItem = -1;
+ {
+ HFONT hFont;
+ LOGFONT lf;
+
+ dat->hListFont = (HFONT)SendMessage(dat->hwndList, WM_GETFONT, 0, 0);
+ GetObject(dat->hListFont, sizeof(lf), &lf);
+ lf.lfHeight -= 5;
+ hFont = CreateFontIndirect(&lf);
+ SendMessage(dat->hwndList, WM_SETFONT, (WPARAM)hFont, 0);
+ }
+ { // Prepare ListView Columns
+ LV_COLUMN lvc = {0};
+ RECT rc;
+
+ GetClientRect(dat->hwndList, &rc);
+ rc.right -= GetSystemMetrics(SM_CXVSCROLL);
+ 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++)
+ {
+ TCHAR text[MAX_PATH];
+
+ lvi.lParam = lvi.iItem;
+ lvi.pszText = text;
+ utf8_to_tchar_static(setting[lvi.iItem].szDescription, text, SIZEOF(text));
+ ListView_InsertItem(dat->hwndList, &lvi);
+ }
+ }
+
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ return TRUE;
+
+ case WM_NOTIFY:
+ switch (((LPNMHDR)lParam)->idFrom) {
+ case 0:
+ switch (((LPNMHDR)lParam)->code) {
+ case PSN_PARAMCHANGED:
+ dat->ppro = (CIcqProto*)((PSHNOTIFY*)lParam)->lParam;
+ dat->LoadSettingsFromDb(0);
+ {
+ char *pwd = dat->ppro->GetUserPassword(TRUE);
+ strcpy(dat->Password, (pwd) ? pwd : "" ); /// FIXME
+ }
+ break;
+
+ case PSN_INFOCHANGED:
+ dat->LoadSettingsFromDb(1);
+ break;
+
+ case PSN_KILLACTIVE:
+ dat->EndStringEdit(1);
+ dat->EndListEdit(1);
+ break;
+
+ case PSN_APPLY:
+ if (dat->ChangesMade())
+ {
+ if (IDYES!=MessageBoxUtf(hwndDlg, LPGEN("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?"), LPGEN("Change ICQ Details"), MB_YESNOCANCEL))
+ {
+ 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))
+ {
+ dat->EndStringEdit(1);
+ dat->EndListEdit(1);
+ }
+ }
+ break;
+
+ case NM_CUSTOMDRAW:
+ {
+ LPNMLVCUSTOMDRAW cd=(LPNMLVCUSTOMDRAW)lParam;
+
+ switch(cd->nmcd.dwDrawStage) {
+ case CDDS_PREPAINT:
+ SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, CDRF_NOTIFYITEMDRAW);
+ return TRUE;
+
+ case CDDS_ITEMPREPAINT:
+ {
+ 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
+ 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
+ SetTextColor(cd->nmcd.hdc, GetSysColor(COLOR_HIGHLIGHTTEXT));
+ FillRect(cd->nmcd.hdc, &rcItem, GetSysColorBrush(COLOR_HIGHLIGHT));
+ }
+ 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)
+ {
+ 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);
+ rcLine.top = (rcItem.top + rcItem.bottom) / 2 - 1;
+ rcLine.bottom = rcLine.top + 2;
+ rcLine.left = rcItem.left + 3;
+ rcLine.right = (rcItem.left + rcItem.right - textSize.cx) / 2 - 3;
+ DrawEdge(cd->nmcd.hdc, &rcLine, BDR_SUNKENOUTER, BF_RECT);
+ rcLine.left = (rcItem.left + rcItem.right + textSize.cx) / 2 + 3;
+ rcLine.right = rcItem.right - 3;
+ DrawEdge(cd->nmcd.hdc, &rcLine, BDR_SUNKENOUTER, BF_RECT);
+ }
+ else
+ {
+ RECT rcItemDescr, rcItemValue;
+ char str[MAX_PATH];
+
+ ListView_GetSubItemRect(dat->hwndList, cd->nmcd.dwItemSpec, 0, LVIR_BOUNDS, &rcItemDescr);
+ ListView_GetSubItemRect(dat->hwndList, cd->nmcd.dwItemSpec, 1, LVIR_BOUNDS, &rcItemValue);
+
+ 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);
+
+ dat->PaintItemSetting(cd->nmcd.hdc, &rcItemValue, cd->nmcd.lItemlParam, cd->nmcd.uItemState);
+ }
+ SelectObject(cd->nmcd.hdc, hoFont);
+
+ SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, CDRF_SKIPDEFAULT);
+
+ return TRUE;
+ }
+ }
+ break;
+ }
+ case NM_CLICK:
+ {
+ 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.stateMask = 0xFFFFFFFF;
+ lvi.iItem = nm->iItem; lvi.iSubItem = nm->iSubItem;
+ ListView_GetItem(dat->hwndList, &lvi);
+ if (!(lvi.state & LVIS_SELECTED)) break;
+ 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) {
+ case LI_STRING:
+ case LI_LONGSTRING:
+ case LI_NUMBER:
+ dat->BeginStringEdit(nm->iItem, &rc, lvi. lParam, 0);
+ break;
+ case LI_LIST:
+ dat->BeginListEdit(nm->iItem, &rc, lvi. lParam, 0);
+ break;
+ }
+ break;
+ }
+ case LVN_KEYDOWN:
+ {
+ 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))
+ 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);
+ dat->editTopIndex = ListView_GetTopIndex(dat->hwndList);
+ 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);
+ break;
+ case LI_LIST:
+ dat->BeginListEdit(lvi.iItem,&rc,lvi.lParam,nm->wVKey);
+ break;
+ }
+ SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, TRUE);
+ return TRUE;
+ }
+ case NM_KILLFOCUS:
+ if (!IsStringEditWindow(GetFocus())) dat->EndStringEdit(1);
+ if (!IsListEditWindow(GetFocus())) dat->EndListEdit(1);
+ break;
+ }
+ break;
+ }
+ break;
+ case WM_KILLFOCUS:
+ dat->EndStringEdit(1);
+ dat->EndListEdit(1);
+ break;
+ case WM_COMMAND:
+ switch(LOWORD(wParam)) {
+ case IDCANCEL:
+ SendMessage(GetParent(hwndDlg), msg, wParam, lParam);
+ break;
+
+ case IDC_SAVE:
+ if (!dat->SaveSettingsToDb(hwndDlg))
+ break;
+
+ EnableDlgItem(hwndDlg, IDC_SAVE, FALSE);
+ EnableDlgItem(hwndDlg, IDC_LIST, FALSE);
+ {
+ char str[MAX_PATH];
+ SetDlgItemTextUtf(hwndDlg, IDC_UPLOADING, ICQTranslateUtfStatic(LPGEN("Upload in progress..."), str, MAX_PATH));
+ }
+ EnableDlgItem(hwndDlg, IDC_UPLOADING, TRUE);
+ ShowDlgItem(hwndDlg, IDC_UPLOADING, SW_SHOW);
+ dat->hAckHook = HookEventMessage(ME_PROTO_ACK, hwndDlg, DM_PROTOACK);
+
+ if (!dat->UploadSettings())
+ {
+ EnableDlgItem(hwndDlg, IDC_SAVE, TRUE);
+ EnableDlgItem(hwndDlg, IDC_LIST, TRUE);
+ ShowDlgItem(hwndDlg, IDC_UPLOADING, SW_HIDE);
+ UnhookEvent(dat->hAckHook);
+ dat->hAckHook = NULL;
+ }
+ break;
+ }
+ break;
+
+ case WM_SIZE:
+ { // make the dlg resizeable
+ UTILRESIZEDIALOG urd = {0};
+
+ if (IsIconic(hwndDlg)) break;
+ urd.cbSize = sizeof(urd);
+ urd.hInstance = hInst;
+ urd.hwndDlg = hwndDlg;
+ urd.lParam = 0; // user-defined
+ urd.lpTemplate = MAKEINTRESOURCEA(IDD_INFO_CHANGEINFO);
+ urd.pfnResizer = ChangeInfoDlg_Resize;
+ CallService(MS_UTILS_RESIZEDIALOG, 0, (LPARAM) &urd);
+
+ { // update listview column widths
+ RECT rc;
+
+ GetClientRect(dat->hwndList, &rc);
+ rc.right -= GetSystemMetrics(SM_CXVSCROLL);
+ ListView_SetColumnWidth(dat->hwndList, 0, rc.right / 3);
+ ListView_SetColumnWidth(dat->hwndList, 1, rc.right - rc.right / 3);
+ }
+ break;
+ }
+
+ case DM_PROTOACK:
+ {
+ ACKDATA *ack=(ACKDATA*)lParam;
+ int i,done;
+ char str[MAX_PATH];
+ char buf[MAX_PATH];
+
+ if (ack->type != ACKTYPE_SETINFO) break;
+ 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;
+ dat->hUpload[i] = NULL;
+ for (done = 0, i = 0; i < SIZEOF(dat->hUpload); i++)
+ done += dat->hUpload[i] == NULL;
+ null_snprintf(buf, sizeof(buf), "%s%d%%", ICQTranslateUtfStatic(LPGEN("Upload in progress..."), str, MAX_PATH), 100*done/(SIZEOF(dat->hUpload)));
+ SetDlgItemTextUtf(hwndDlg, IDC_UPLOADING, buf);
+ if (done < SIZEOF(dat->hUpload)) break;
+
+ dat->ClearChangeFlags();
+ UnhookEvent(dat->hAckHook);
+ dat->hAckHook = NULL;
+ EnableDlgItem(hwndDlg, IDC_LIST, TRUE);
+ EnableDlgItem(hwndDlg, IDC_UPLOADING, FALSE);
+ SetDlgItemTextUtf(hwndDlg, IDC_UPLOADING, ICQTranslateUtfStatic(LPGEN("Upload complete"), str, MAX_PATH));
+ SendMessage(GetParent(hwndDlg), PSM_FORCECHANGED, 0, 0);
+ }
+ else if (ack->result==ACKRESULT_FAILED)
+ {
+ UnhookEvent(dat->hAckHook);
+ dat->hAckHook = NULL;
+ EnableDlgItem(hwndDlg, IDC_LIST, TRUE);
+ EnableDlgItem(hwndDlg, IDC_UPLOADING, FALSE);
+ SetDlgItemTextUtf(hwndDlg, IDC_UPLOADING, ICQTranslateUtfStatic(LPGEN("Upload FAILED"), str, MAX_PATH));
+ SendMessage(GetParent(hwndDlg), PSM_FORCECHANGED, 0, 0);
+ EnableDlgItem(hwndDlg, IDC_SAVE, TRUE);
+ }
+ break;
+ }
+ case WM_DESTROY:
+ if (dat->hAckHook)
+ {
+ UnhookEvent(dat->hAckHook);
+ dat->hAckHook = NULL;
+ }
+ {
+ HFONT hFont = (HFONT)SendMessage(dat->hwndList, WM_GETFONT, 0, 0);
+ DeleteObject(hFont);
+ }
+ dat->FreeStoredDbSettings();
+ SetWindowLongPtr(hwndDlg, GWLP_USERDATA, 0);
+ delete dat;
+ break;
+ }
+ return FALSE;
+}
diff --git a/protocols/IcqOscarJ/src/changeinfo/editlist.cpp b/protocols/IcqOscarJ/src/changeinfo/editlist.cpp new file mode 100644 index 0000000000..f2a1470fd3 --- /dev/null +++ b/protocols/IcqOscarJ/src/changeinfo/editlist.cpp @@ -0,0 +1,201 @@ +// ---------------------------------------------------------------------------80
+// ICQ plugin for Miranda Instant Messenger
+// ________________________________________
+//
+// Copyright © 2001-2004 Richard Hughes, Martin Öberg
+// Copyright © 2004-2009 Joe Kucera, Bio
+//
+// 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.
+//
+// -----------------------------------------------------------------------------
+// DESCRIPTION:
+//
+// ChangeInfo Plugin stuff
+//
+// -----------------------------------------------------------------------------
+#include "icqoscar.h"
+
+
+static ChangeInfoData *dataListEdit = NULL;
+static HWND hwndListEdit = NULL;
+static BOOL (WINAPI *MyAnimateWindow)(HWND,DWORD,DWORD);
+static WNDPROC OldListEditProc;
+
+static LRESULT CALLBACK ListEditSubclassProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam)
+{
+ switch(msg)
+ {
+ case WM_LBUTTONUP:
+ CallWindowProc(OldListEditProc, hwnd, msg, wParam, lParam);
+ {
+ POINT pt;
+
+ pt.x = (short)LOWORD(lParam);
+ pt.y = (short)HIWORD(lParam);
+ ClientToScreen(hwnd, &pt);
+ if (SendMessage(hwnd, WM_NCHITTEST, 0, MAKELPARAM(pt.x, pt.y)) == HTVSCROLL) break;
+ }
+ {
+ int i = SendMessage(hwnd, LB_GETCURSEL, 0, 0);
+
+ if (dataListEdit)
+ dataListEdit->EndListEdit(i != LB_ERR);
+ }
+ return 0;
+
+ case WM_CHAR:
+ if (wParam != '\r') break;
+ {
+ int i = SendMessage(hwnd, LB_GETCURSEL, 0, 0);
+
+ if (dataListEdit)
+ dataListEdit->EndListEdit(i != LB_ERR);
+ }
+ return 0;
+ case WM_KILLFOCUS:
+ if (dataListEdit)
+ dataListEdit->EndListEdit(1);
+ return 0;
+ }
+ return CallWindowProc(OldListEditProc, hwnd, msg, wParam, lParam);
+}
+
+
+void ChangeInfoData::BeginListEdit(int iItem, RECT *rc, int iSetting, WORD wVKey)
+{
+ int j,n;
+ POINT pt;
+ int itemHeight;
+ char str[MAX_PATH];
+
+ if (dataListEdit)
+ dataListEdit->EndListEdit(0);
+
+ pt.x=pt.y=0;
+ ClientToScreen(hwndList,&pt);
+ OffsetRect(rc,pt.x,pt.y);
+ InflateRect(rc,-2,-2);
+ rc->left-=2;
+ iEditItem = iItem;
+ ListView_RedrawItems(hwndList, iEditItem, iEditItem);
+ 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);
+ SendMessage(hwndListEdit, WM_SETFONT, (WPARAM)hListFont, 0);
+ itemHeight = SendMessage(hwndListEdit, LB_GETITEMHEIGHT, 0, 0);
+
+ FieldNamesItem *list = (FieldNamesItem*)setting[iSetting].pList;
+
+ if (list == countryField)
+ { // some country codes were changed leaving old details uknown, convert it for the user
+ 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;
+ }
+
+ n = ListBoxAddStringUtf(hwndListEdit, "Unspecified");
+ for (j=0; ; j++)
+ if (!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))
+ SendMessage(hwndListEdit, LB_SETCURSEL, n, 0);
+ break;
+ }
+
+ for (j=0; list[j].text; j++)
+ {
+ 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);
+ 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);
+ OldListEditProc = (WNDPROC)SetWindowLongPtr(hwndListEdit, GWLP_WNDPROC, (LONG_PTR)ListEditSubclassProc);
+ if (MyAnimateWindow = (BOOL (WINAPI*)(HWND,DWORD,DWORD))GetProcAddress(GetModuleHandleA("user32"), "AnimateWindow"))
+ {
+ BOOL enabled;
+
+ SystemParametersInfo(SPI_GETCOMBOBOXANIMATION, 0, &enabled, FALSE);
+ if (enabled) MyAnimateWindow(hwndListEdit, 200, AW_SLIDE|AW_ACTIVATE|AW_VER_POSITIVE);
+ }
+ ShowWindow(hwndListEdit, SW_SHOW);
+ SetFocus(hwndListEdit);
+ if (wVKey)
+ PostMessage(hwndListEdit, WM_KEYDOWN, wVKey, 0);
+}
+
+
+void ChangeInfoData::EndListEdit(int save)
+{
+ if (hwndListEdit == NULL || iEditItem == -1 || this != dataListEdit) return;
+ if (save)
+ {
+ int iItem = SendMessage(hwndListEdit, LB_GETCURSEL, 0, 0);
+ int i = SendMessage(hwndListEdit, LB_GETITEMDATA, iItem, 0);
+
+ if (setting[iEditItem].dbType == DBVT_ASCIIZ)
+ {
+ char *szNewValue = (((FieldNamesItem*)setting[iEditItem].pList)[i].text);
+ if (((FieldNamesItem*)setting[iEditItem].pList)[i].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);
+ }
+ else
+ {
+ settingData[iEditItem].changed = (char*)settingData[iEditItem].value!=NULL;
+ SAFE_FREE((void**)&settingData[iEditItem].value);
+ }
+ }
+ else
+ {
+ settingData[iEditItem].changed = ((FieldNamesItem*)setting[iEditItem].pList)[i].code != settingData[iEditItem].value;
+ settingData[iEditItem].value = ((FieldNamesItem*)setting[iEditItem].pList)[i].code;
+ }
+ if (settingData[iEditItem].changed)
+ {
+ char buf[MAX_PATH];
+ TCHAR tbuf[MAX_PATH];
+
+ if (utf8_to_tchar_static(ICQTranslateUtfStatic(((FieldNamesItem*)setting[iEditItem].pList)[i].text, buf, SIZEOF(buf)), tbuf, SIZEOF(buf)))
+ ListView_SetItemText(hwndList, iEditItem, 1, tbuf);
+
+ EnableDlgItem(GetParent(hwndList), IDC_SAVE, TRUE);
+
+ }
+ }
+ ListView_RedrawItems(hwndList, iEditItem, iEditItem);
+ iEditItem = -1;
+ dataListEdit = NULL;
+ DestroyWindow(hwndListEdit);
+ hwndListEdit = NULL;
+}
+
+
+int IsListEditWindow(HWND hwnd)
+{
+ if (hwnd == hwndListEdit) return 1;
+ return 0;
+}
diff --git a/protocols/IcqOscarJ/src/changeinfo/editstring.cpp b/protocols/IcqOscarJ/src/changeinfo/editstring.cpp new file mode 100644 index 0000000000..288351e8d3 --- /dev/null +++ b/protocols/IcqOscarJ/src/changeinfo/editstring.cpp @@ -0,0 +1,367 @@ +// ---------------------------------------------------------------------------80
+// ICQ plugin for Miranda Instant Messenger
+// ________________________________________
+//
+// Copyright © 2001-2004 Richard Hughes, Martin Öberg
+// Copyright © 2004-2009 Joe Kucera, Bio
+//
+// 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.
+//
+// -----------------------------------------------------------------------------
+// DESCRIPTION:
+//
+// ChangeInfo Plugin stuff
+//
+// -----------------------------------------------------------------------------
+#include "icqoscar.h"
+
+
+static ChangeInfoData *dataStringEdit = NULL;
+static WNDPROC OldStringEditProc, OldExpandButtonProc;
+static HWND hwndEdit = NULL, hwndExpandButton = NULL, hwndUpDown = NULL;
+
+static const char escapes[]={'a','\a',
+'b','\b',
+'e',27,
+'f','\f',
+'r','\r',
+'t','\t',
+'v','\v',
+'\\','\\'};
+
+static void EscapesToMultiline(WCHAR *str,PDWORD selStart,PDWORD selEnd)
+{ //converts "\\n" and "\\t" to "\r\n" and "\t" because a multi-line edit box can show them properly
+ DWORD i;
+
+ for(i=0; *str; str++, i++)
+ {
+ if (*str != '\\') continue;
+ if (str[1] == 'n')
+ {
+ *str++ = '\r';
+ i++;
+ *str = '\n';
+ }
+ else if (str[1] == 't')
+ {
+ *str = '\t';
+ memmove(str+1, str+2, sizeof(WCHAR)*(strlennull(str)-1));
+
+ if (*selStart>i) --*selStart;
+ if (*selEnd>i) --*selEnd;
+ }
+ }
+}
+
+
+
+static void EscapesToBinary(char *str)
+{
+ for (;*str;str++)
+ {
+ if (*str!='\\') continue;
+ if(str[1]=='n') {*str++='\r'; *str='\n'; continue;}
+ if(str[1]=='0')
+ {
+ char *codeend;
+ *str=(char)strtol(str+1,&codeend,8);
+ if (*str==0) {*str='\\'; continue;}
+ memmove(str+1,codeend,strlennull(codeend)+1);
+ continue;
+ }
+ for(int i=0;i<SIZEOF(escapes);i+=2)
+ if(str[1]==escapes[i])
+ {
+ *str=escapes[i+1];
+ memmove(str+1,str+2,strlennull(str)-1);
+ break;
+ }
+ }
+}
+
+
+
+char *BinaryToEscapes(char *str)
+{
+ int extra=10,len=strlennull(str)+11,i;
+ char *out,*pout;
+
+ out=pout=(char*)SAFE_MALLOC(len);
+ for (;*str;str++)
+ {
+ if ((unsigned char)*str>=' ')
+ {
+ *pout++=*str;
+ continue;
+ }
+ if(str[0]=='\r' && str[1]=='\n')
+ {
+ *pout++='\\';
+ *pout++='n';
+ str++;
+ continue;
+ }
+ if(extra<3)
+ {
+ extra+=8; len+=8;
+ pout=out=(char*)SAFE_REALLOC(out,len);
+ }
+ *pout++='\\';
+ for(i = 0; i < SIZEOF(escapes); i += 2)
+ if (*str==escapes[i+1])
+ {
+ *pout++=escapes[i];
+ extra--;
+ break;
+ }
+ if(i < SIZEOF(escapes)) continue;
+ *pout++='0'; extra--;
+ if (*str>=8)
+ {
+ *pout++=(*str>>3)+'0';
+ extra--;
+ }
+ *pout++=(*str&7)+'0'; extra--;
+ }
+ *pout='\0';
+ return out;
+}
+
+
+
+static LRESULT CALLBACK StringEditSubclassProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam)
+{
+ switch(msg)
+ {
+ case WM_KEYDOWN:
+ if (wParam==VK_ESCAPE)
+ {
+ if (dataStringEdit)
+ dataStringEdit->EndStringEdit(0);
+ return 0;
+ }
+ if (wParam==VK_RETURN)
+ {
+ if (GetWindowLongPtr(hwnd, GWL_STYLE) & ES_MULTILINE && !(GetKeyState(VK_CONTROL) & 0x8000)) break;
+ if (dataStringEdit)
+ dataStringEdit->EndStringEdit(1);
+ return 0;
+ }
+ break;
+
+ case WM_GETDLGCODE:
+ return DLGC_WANTALLKEYS|CallWindowProc(OldStringEditProc, hwnd, msg, wParam, lParam);
+
+ case WM_KILLFOCUS:
+ if ((HWND)wParam == hwndExpandButton) break;
+ if (dataStringEdit)
+ dataStringEdit->EndStringEdit(1);
+ return 0;
+ }
+ return CallWindowProc(OldStringEditProc, hwnd, msg, wParam, lParam);
+}
+
+
+
+static LRESULT CALLBACK ExpandButtonSubclassProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam)
+{
+ switch(msg)
+ {
+ case WM_LBUTTONUP:
+ if(GetCapture()==hwnd)
+ {
+ //do expand
+ RECT rcStart,rcEnd;
+ DWORD selStart,selEnd;
+ WCHAR *text;
+ BOOL animEnabled=TRUE;
+
+ GetWindowRect(hwndEdit,&rcStart);
+ InflateRect(&rcStart,2,2);
+
+ text = GetWindowTextUcs(hwndEdit);
+ 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);
+ SetWindowTextUcs(hwndEdit, text);
+ OldStringEditProc=(WNDPROC)SetWindowLongPtr(hwndEdit,GWLP_WNDPROC,(LONG_PTR)StringEditSubclassProc);
+ 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 (;;)
+ {
+ 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);
+ }
+ }
+ SetWindowPos(hwndEdit,0,rcEnd.left,rcEnd.top,rcEnd.right-rcEnd.left,rcEnd.bottom-rcEnd.top,SWP_NOZORDER);
+
+ DestroyWindow(hwnd);
+ hwndExpandButton=NULL;
+
+ SAFE_FREE((void**)&text);
+ }
+ break;
+ }
+ return CallWindowProc(OldExpandButtonProc,hwnd,msg,wParam,lParam);
+}
+
+
+void ChangeInfoData::BeginStringEdit(int iItem, RECT *rc, int i, WORD wVKey)
+{
+ char *szValue;
+ char str[80];
+ int alloced=0;
+
+ EndStringEdit(0);
+ InflateRect(rc,-2,-2);
+ rc->left-=2;
+ if (setting[i].displayType & LIF_PASSWORD && !settingData[i].changed)
+ szValue = " ";
+ else if ((setting[i].displayType & LIM_TYPE) == LI_NUMBER)
+ {
+ szValue = str;
+ null_snprintf(str, sizeof(str), "%d", settingData[i].value );
+ }
+ else if (settingData[i].value)
+ {
+ szValue = BinaryToEscapes((char*)settingData[i].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));
+ OldExpandButtonProc=(WNDPROC)SetWindowLongPtr(hwndExpandButton,GWLP_WNDPROC,(LONG_PTR)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);
+ SetWindowTextUtf(hwndEdit, szValue);
+ if (alloced) SAFE_FREE(&szValue);
+ OldStringEditProc=(WNDPROC)SetWindowLongPtr(hwndEdit,GWLP_WNDPROC,(LONG_PTR)StringEditSubclassProc);
+ SendMessage(hwndEdit,WM_SETFONT,(WPARAM)hListFont,0);
+ if ((setting[i].displayType & LIM_TYPE) == LI_NUMBER)
+ {
+ int *range= (int*)setting[i].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);
+ 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)
+ 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);
+ }
+ SendMessage(hwndEdit,EM_SETSEL,0,(LPARAM)-1);
+ SetFocus(hwndEdit);
+ PostMessage(hwndEdit,WM_KEYDOWN,wVKey,0);
+}
+
+
+void ChangeInfoData::EndStringEdit(int save)
+{
+ if (hwndEdit == NULL || iEditItem == -1 || this != dataStringEdit) return;
+ if (save)
+ {
+ char *text = (char*)SAFE_MALLOC(GetWindowTextLength(hwndEdit)+1);
+
+ GetWindowTextA(hwndEdit,(char*)text,GetWindowTextLength(hwndEdit)+1);
+ EscapesToBinary(text);
+ if ((setting[iEditItem].displayType&LIM_TYPE)==LI_NUMBER)
+ {
+ LPARAM newValue;
+ int *range=(int*)setting[iEditItem].pList;
+ newValue = atoi(text);
+ 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;
+ SAFE_FREE(&text);
+ }
+ else
+ {
+ if (!(setting[iEditItem].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 (strlennull(text))
+ settingData[iEditItem].value = (LPARAM)text;
+ else
+ {
+ settingData[iEditItem].value = 0;
+ SAFE_FREE(&text);
+ }
+ settingData[iEditItem].changed = 1;
+ }
+ }
+ if (settingData[iEditItem].changed)
+ {
+ TCHAR tbuf[MAX_PATH];
+
+ GetWindowText(hwndEdit, tbuf, SIZEOF(tbuf));
+ ListView_SetItemText(hwndList, iEditItem, 1, tbuf);
+
+ EnableDlgItem(hwndDlg, IDC_SAVE, TRUE);
+ }
+ }
+ ListView_RedrawItems(hwndList, iEditItem, iEditItem);
+ iEditItem = -1;
+ dataStringEdit = NULL;
+ DestroyWindow(hwndEdit);
+ hwndEdit = NULL;
+ if (hwndExpandButton) DestroyWindow(hwndExpandButton);
+ hwndExpandButton = NULL;
+ if (hwndUpDown) DestroyWindow(hwndUpDown);
+ hwndUpDown = NULL;
+}
+
+
+
+int IsStringEditWindow(HWND hwnd)
+{
+ if (hwnd == hwndEdit) return 1;
+ if (hwnd == hwndExpandButton) return 1;
+ if (hwnd == hwndUpDown) return 1;
+ return 0;
+}
diff --git a/protocols/IcqOscarJ/src/changeinfo/icqoscar.h b/protocols/IcqOscarJ/src/changeinfo/icqoscar.h new file mode 100644 index 0000000000..77283f6f7f --- /dev/null +++ b/protocols/IcqOscarJ/src/changeinfo/icqoscar.h @@ -0,0 +1,2 @@ +/* For MinGW sake */
+#include "../icqoscar.h"
diff --git a/protocols/IcqOscarJ/src/changeinfo/main.cpp b/protocols/IcqOscarJ/src/changeinfo/main.cpp new file mode 100644 index 0000000000..22669be3aa --- /dev/null +++ b/protocols/IcqOscarJ/src/changeinfo/main.cpp @@ -0,0 +1,28 @@ +// ---------------------------------------------------------------------------80
+// ICQ plugin for Miranda Instant Messenger
+// ________________________________________
+//
+// Copyright © 2001-2004 Richard Hughes, Martin Öberg
+// Copyright © 2004-2008 Joe Kucera, Bio
+//
+// 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.
+//
+// -----------------------------------------------------------------------------
+// DESCRIPTION:
+//
+// ChangeInfo Plugin stuff
+//
+// -----------------------------------------------------------------------------
+#include "icqoscar.h"
diff --git a/protocols/IcqOscarJ/src/changeinfo/upload.cpp b/protocols/IcqOscarJ/src/changeinfo/upload.cpp new file mode 100644 index 0000000000..a468dc9f2b --- /dev/null +++ b/protocols/IcqOscarJ/src/changeinfo/upload.cpp @@ -0,0 +1,91 @@ +// ---------------------------------------------------------------------------80
+// ICQ plugin for Miranda Instant Messenger
+// ________________________________________
+//
+// Copyright © 2001-2004 Richard Hughes, Martin Öberg
+// Copyright © 2004-2009 Joe Kucera, Bio
+//
+// 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.
+//
+// -----------------------------------------------------------------------------
+// DESCRIPTION:
+//
+// ChangeInfo Plugin stuff
+//
+// -----------------------------------------------------------------------------
+#include "icqoscar.h"
+
+
+int CIcqProto::StringToListItemId(const char *szSetting,int def)
+{
+ int i;
+
+ for(i=0;i<settingCount;i++)
+ if (!strcmpnull(szSetting,setting[i].szDbSetting))
+ break;
+
+ if (i==settingCount) return def;
+
+ FieldNamesItem *list = (FieldNamesItem*)setting[i].pList;
+
+ char *szValue = getSettingStringUtf(NULL, szSetting, NULL);
+ if (!szValue)
+ return def;
+
+ for (i=0; list[i].text; i++)
+ if (!strcmpnull(list[i].text, szValue))
+ break;
+
+ SAFE_FREE(&szValue);
+ if (!list[i].text) return def;
+
+ return list[i].code;
+}
+
+
+int ChangeInfoData::UploadSettings(void)
+{
+ if (!ppro->icqOnline())
+ {
+ MessageBoxUtf(hwndDlg, LPGEN("You are not currently connected to the ICQ network. You must be online in order to update your information on the server."), LPGEN("Change ICQ Details"), MB_OK);
+ return 0;
+ }
+
+ hUpload[0] = (HANDLE)ppro->ChangeInfoEx(CIXT_FULL, 0);
+
+ //password
+ char* tmp = ppro->GetUserPassword(TRUE);
+ if (tmp)
+ {
+ if (strlennull(Password) > 0 && strcmpnull(Password, tmp))
+ {
+ hUpload[1] = (HANDLE)ppro->icq_changeUserPasswordServ(tmp);
+ char szPwd[PASSWORDMAXLEN] = {0};
+
+ if (ppro->GetUserStoredPassword(szPwd, sizeof(szPwd)))
+ { // password is stored in DB, update
+ char ptmp[PASSWORDMAXLEN];
+
+ strcpy(ptmp, tmp);
+
+ CallService(MS_DB_CRYPT_ENCODESTRING, sizeof(ptmp), (LPARAM)ptmp);
+
+ ppro->setSettingString(NULL, "Password", ptmp);
+ }
+ }
+ }
+
+ return 1;
+}
|