summaryrefslogtreecommitdiff
path: root/protocols/JabberG/src/jabber_vcard.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2015-01-30 20:55:58 +0000
committerGeorge Hazan <george.hazan@gmail.com>2015-01-30 20:55:58 +0000
commit4f275199a51a68f93bff688d76925b118413471b (patch)
tree0c0011e6b6423ada35aa2104c63ae2d295766826 /protocols/JabberG/src/jabber_vcard.cpp
parent23031c6d7053159764690b35bb440d6260295f81 (diff)
code cleaning
git-svn-id: http://svn.miranda-ng.org/main/trunk@11959 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/JabberG/src/jabber_vcard.cpp')
-rw-r--r--protocols/JabberG/src/jabber_vcard.cpp361
1 files changed, 182 insertions, 179 deletions
diff --git a/protocols/JabberG/src/jabber_vcard.cpp b/protocols/JabberG/src/jabber_vcard.cpp
index a8763794a1..0c277f266a 100644
--- a/protocols/JabberG/src/jabber_vcard.cpp
+++ b/protocols/JabberG/src/jabber_vcard.cpp
@@ -36,7 +36,7 @@ int CJabberProto::SendGetVcard(const TCHAR *jid)
if (!m_bJabberOnline) return 0;
CJabberIqInfo *pInfo = AddIQ(&CJabberProto::OnIqResultGetVcard, JABBER_IQ_TYPE_GET, jid);
- m_ThreadInfo->send( XmlNodeIq(pInfo) << XCHILDNS(_T("vCard"), JABBER_FEAT_VCARD_TEMP)
+ m_ThreadInfo->send(XmlNodeIq(pInfo) << XCHILDNS(_T("vCard"), JABBER_FEAT_VCARD_TEMP)
<< XATTR(_T("prodid"), _T("-//HandGen//NONSGML vGen v1.0//EN")) << XATTR(_T("version"), _T("2.0")));
return pInfo->GetIqId();
@@ -46,7 +46,7 @@ int CJabberProto::SendGetVcard(const TCHAR *jid)
static void SetDialogField(CJabberProto *ppro, HWND hwndDlg, int nDlgItem, char* key, bool bTranslate = false)
{
- ptrT tszValue( ppro->getTStringA(key));
+ ptrT tszValue(ppro->getTStringA(key));
if (tszValue != NULL)
SetDlgItemText(hwndDlg, nDlgItem, (bTranslate) ? TranslateTS(tszValue) : tszValue);
else
@@ -84,10 +84,9 @@ static INT_PTR CALLBACK PersonalDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, L
break;
case WM_COMMAND:
- if (((HWND)lParam==GetFocus() && HIWORD(wParam)==EN_CHANGE) ||
- ((HWND)lParam==GetDlgItem(hwndDlg, IDC_GENDER) && (HIWORD(wParam)==CBN_EDITCHANGE||HIWORD(wParam)==CBN_SELCHANGE)))
- {
- ppro->m_vCardUpdates |= (1UL<<iPageId);
+ if (((HWND)lParam == GetFocus() && HIWORD(wParam) == EN_CHANGE) ||
+ ((HWND)lParam == GetDlgItem(hwndDlg, IDC_GENDER) && (HIWORD(wParam) == CBN_EDITCHANGE || HIWORD(wParam) == CBN_SELCHANGE))) {
+ ppro->m_vCardUpdates |= (1UL << iPageId);
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
}
break;
@@ -99,12 +98,13 @@ static INT_PTR CALLBACK PersonalDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, L
SendMessage(hwndDlg, WM_INITDIALOG, 0, ((PSHNOTIFY*)lParam)->lParam);
break;
case PSN_APPLY:
- ppro->m_vCardUpdates &= ~(1UL<<iPageId);
+ ppro->m_vCardUpdates &= ~(1UL << iPageId);
ppro->SaveVcardToDB(hwndDlg, iPageId);
if (!ppro->m_vCardUpdates)
ppro->SetServerVcard(ppro->m_bPhotoChanged, ppro->m_szPhotoFileName);
break;
- } }
+ }
+ }
break;
case WM_DESTROY:
@@ -124,7 +124,7 @@ static INT_PTR CALLBACK HomeDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA
if (lParam) {
ppro = (CJabberProto*)lParam;
TranslateDialogDefault(hwndDlg);
- for (int i=0; i < g_cbCountries; i++) {
+ for (int i = 0; i < g_cbCountries; i++) {
if (g_countries[i].id != 0xFFFF && g_countries[i].id != 0) {
TCHAR *country = mir_a2t(g_countries[i].szName);
SendDlgItemMessage(hwndDlg, IDC_COUNTRY, CB_ADDSTRING, 0, (LPARAM)TranslateTS(country));
@@ -147,10 +147,10 @@ static INT_PTR CALLBACK HomeDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA
break;
case WM_COMMAND:
- if (((HWND)lParam==GetFocus() && HIWORD(wParam)==EN_CHANGE) ||
- ((HWND)lParam==GetDlgItem(hwndDlg, IDC_COUNTRY) && (HIWORD(wParam)==CBN_EDITCHANGE||HIWORD(wParam)==CBN_SELCHANGE)))
+ if (((HWND)lParam == GetFocus() && HIWORD(wParam) == EN_CHANGE) ||
+ ((HWND)lParam == GetDlgItem(hwndDlg, IDC_COUNTRY) && (HIWORD(wParam) == CBN_EDITCHANGE || HIWORD(wParam) == CBN_SELCHANGE)))
{
- ppro->m_vCardUpdates |= (1UL<<iPageId);
+ ppro->m_vCardUpdates |= (1UL << iPageId);
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
}
break;
@@ -162,12 +162,13 @@ static INT_PTR CALLBACK HomeDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA
SendMessage(hwndDlg, WM_INITDIALOG, 0, ((PSHNOTIFY*)lParam)->lParam);
break;
case PSN_APPLY:
- ppro->m_vCardUpdates &= ~(1UL<<iPageId);
+ ppro->m_vCardUpdates &= ~(1UL << iPageId);
ppro->SaveVcardToDB(hwndDlg, iPageId);
if (!ppro->m_vCardUpdates)
ppro->SetServerVcard(ppro->m_bPhotoChanged, ppro->m_szPhotoFileName);
break;
- } }
+ }
+ }
break;
case WM_DESTROY:
@@ -187,7 +188,7 @@ static INT_PTR CALLBACK WorkDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA
if (lParam) { // proto info is available
ppro = (CJabberProto*)lParam;
TranslateDialogDefault(hwndDlg);
- for (int i=0; i < g_cbCountries; i++) {
+ for (int i = 0; i < g_cbCountries; i++) {
if (g_countries[i].id != 0xFFFF && g_countries[i].id != 0) {
TCHAR *country = mir_a2t(g_countries[i].szName);
SendDlgItemMessage(hwndDlg, IDC_COUNTRY, CB_ADDSTRING, 0, (LPARAM)TranslateTS(country));
@@ -213,10 +214,10 @@ static INT_PTR CALLBACK WorkDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA
break;
case WM_COMMAND:
- if (((HWND)lParam==GetFocus() && HIWORD(wParam)==EN_CHANGE) ||
- ((HWND)lParam==GetDlgItem(hwndDlg, IDC_COUNTRY) && (HIWORD(wParam)==CBN_EDITCHANGE||HIWORD(wParam)==CBN_SELCHANGE)))
+ if (((HWND)lParam == GetFocus() && HIWORD(wParam) == EN_CHANGE) ||
+ ((HWND)lParam == GetDlgItem(hwndDlg, IDC_COUNTRY) && (HIWORD(wParam) == CBN_EDITCHANGE || HIWORD(wParam) == CBN_SELCHANGE)))
{
- ppro->m_vCardUpdates |= (1UL<<iPageId);
+ ppro->m_vCardUpdates |= (1UL << iPageId);
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
}
break;
@@ -228,12 +229,13 @@ static INT_PTR CALLBACK WorkDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA
SendMessage(hwndDlg, WM_INITDIALOG, 0, ((PSHNOTIFY*)lParam)->lParam);
break;
case PSN_APPLY:
- ppro->m_vCardUpdates &= ~(1UL<<iPageId);
+ ppro->m_vCardUpdates &= ~(1UL << iPageId);
ppro->SaveVcardToDB(hwndDlg, iPageId);
if (!ppro->m_vCardUpdates)
ppro->SetServerVcard(ppro->m_bPhotoChanged, ppro->m_szPhotoFileName);
break;
- } }
+ }
+ }
break;
case WM_DESTROY:
@@ -248,8 +250,6 @@ static INT_PTR CALLBACK WorkDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA
struct PhotoDlgProcData
{
CJabberProto *ppro;
-// char szPhotoFileName[MAX_PATH];
-// BOOL bPhotoChanged;
HBITMAP hBitmap;
};
@@ -257,7 +257,7 @@ static INT_PTR CALLBACK PhotoDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
{
const unsigned long iPageId = 3;
- TCHAR szAvatarFileName[ MAX_PATH ], szTempPath[MAX_PATH], szTempFileName[MAX_PATH];
+ TCHAR szAvatarFileName[MAX_PATH], szTempPath[MAX_PATH], szTempFileName[MAX_PATH];
PhotoDlgProcData* dat = (PhotoDlgProcData*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
switch (msg) {
@@ -295,7 +295,7 @@ static INT_PTR CALLBACK PhotoDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
if (GetTempFileName(szTempPath, _T("jab"), 0, szTempFileName) > 0) {
dat->ppro->debugLog(_T("Temp file = %s"), szTempFileName);
if (CopyFile(szAvatarFileName, szTempFileName, FALSE) == TRUE) {
- if ((dat->hBitmap=(HBITMAP) CallService(MS_UTILS_LOADBITMAPT, 0, (LPARAM)szTempFileName)) != NULL) {
+ if ((dat->hBitmap = (HBITMAP)CallService(MS_UTILS_LOADBITMAPT, 0, (LPARAM)szTempFileName)) != NULL) {
FIP->FI_Premultiply(dat->hBitmap);
_tcscpy(dat->ppro->m_szPhotoFileName, szTempFileName);
EnableWindow(GetDlgItem(hwndDlg, IDC_DELETE), TRUE);
@@ -303,7 +303,8 @@ static INT_PTR CALLBACK PhotoDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
else DeleteFile(szTempFileName);
}
else DeleteFile(szTempFileName);
- } }
+ }
+ }
dat->ppro->m_bPhotoChanged = FALSE;
InvalidateRect(hwndDlg, NULL, TRUE);
@@ -316,61 +317,6 @@ static INT_PTR CALLBACK PhotoDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
case WM_COMMAND:
switch (LOWORD(wParam)) {
- case IDC_LOAD:
- {
- TCHAR szFilter[512];
- TCHAR szFileName[MAX_PATH];
-
- CallService(MS_UTILS_GETBITMAPFILTERSTRINGST, SIZEOF(szFilter), (LPARAM)szFilter);
-
- OPENFILENAME ofn = {0};
- ofn.lStructSize = sizeof(ofn);
- ofn.hwndOwner = hwndDlg;
- ofn.lpstrFilter = szFilter;
- ofn.lpstrCustomFilter = NULL;
- ofn.lpstrFile = szFileName;
- ofn.nMaxFile = MAX_PATH;
- ofn.Flags = OFN_FILEMUSTEXIST | OFN_DONTADDTORECENT;
- szFileName[0] = '\0';
- if (GetOpenFileName(&ofn)) {
- struct _stat st;
- HBITMAP hNewBitmap;
-
- dat->ppro->debugLog(_T("File selected is %s"), szFileName);
- if (_tstat(szFileName, &st)<0 || st.st_size>40*1024) {
- MessageBox(hwndDlg, TranslateT("Only JPG, GIF, and BMP image files smaller than 40 KB are supported."), TranslateT("Jabber vCard"), MB_OK|MB_SETFOREGROUND);
- break;
- }
- if (GetTempPath(SIZEOF(szTempPath), szTempPath) <= 0)
- _tcscpy(szTempPath, _T(".\\"));
- if (GetTempFileName(szTempPath, _T("jab"), 0, szTempFileName) > 0) {
- dat->ppro->debugLog(_T("Temp file = %s"), szTempFileName);
- if (CopyFile(szFileName, szTempFileName, FALSE) == TRUE) {
- char* pszTemp = mir_t2a(szTempFileName);
- if ((hNewBitmap=(HBITMAP) CallService(MS_UTILS_LOADBITMAP, 0, (LPARAM)pszTemp)) != NULL) {
- if (dat->hBitmap) {
- DeleteObject(dat->hBitmap);
- DeleteFile(dat->ppro->m_szPhotoFileName);
- }
-
- dat->hBitmap = hNewBitmap;
- _tcscpy(dat->ppro->m_szPhotoFileName, szTempFileName);
- dat->ppro->m_bPhotoChanged = TRUE;
- EnableWindow(GetDlgItem(hwndDlg, IDC_DELETE), TRUE);
- InvalidateRect(hwndDlg, NULL, TRUE);
- UpdateWindow(hwndDlg);
- dat->ppro->m_vCardUpdates |= (1UL<<iPageId);
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- }
- else DeleteFile(szTempFileName);
-
- mir_free(pszTemp);
- }
- else DeleteFile(szTempFileName);
- }
- }
- }
- break;
case IDC_DELETE:
if (dat->hBitmap) {
DeleteObject(dat->hBitmap);
@@ -381,12 +327,67 @@ static INT_PTR CALLBACK PhotoDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
EnableWindow(GetDlgItem(hwndDlg, IDC_DELETE), FALSE);
InvalidateRect(hwndDlg, NULL, TRUE);
UpdateWindow(hwndDlg);
- dat->ppro->m_vCardUpdates |= (1UL<<iPageId);
+ dat->ppro->m_vCardUpdates |= (1UL << iPageId);
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
}
break;
+
+ case IDC_LOAD:
+ TCHAR szFilter[512];
+ TCHAR szFileName[MAX_PATH];
+
+ CallService(MS_UTILS_GETBITMAPFILTERSTRINGST, SIZEOF(szFilter), (LPARAM)szFilter);
+
+ OPENFILENAME ofn = { 0 };
+ ofn.lStructSize = sizeof(ofn);
+ ofn.hwndOwner = hwndDlg;
+ ofn.lpstrFilter = szFilter;
+ ofn.lpstrCustomFilter = NULL;
+ ofn.lpstrFile = szFileName;
+ ofn.nMaxFile = MAX_PATH;
+ ofn.Flags = OFN_FILEMUSTEXIST | OFN_DONTADDTORECENT;
+ szFileName[0] = '\0';
+ if (GetOpenFileName(&ofn)) {
+ struct _stat st;
+ HBITMAP hNewBitmap;
+
+ dat->ppro->debugLog(_T("File selected is %s"), szFileName);
+ if (_tstat(szFileName, &st) < 0 || st.st_size > 40 * 1024) {
+ MessageBox(hwndDlg, TranslateT("Only JPG, GIF, and BMP image files smaller than 40 KB are supported."), TranslateT("Jabber vCard"), MB_OK | MB_SETFOREGROUND);
+ break;
+ }
+ if (GetTempPath(SIZEOF(szTempPath), szTempPath) <= 0)
+ _tcscpy(szTempPath, _T(".\\"));
+ if (GetTempFileName(szTempPath, _T("jab"), 0, szTempFileName) > 0) {
+ dat->ppro->debugLog(_T("Temp file = %s"), szTempFileName);
+ if (CopyFile(szFileName, szTempFileName, FALSE) == TRUE) {
+ char* pszTemp = mir_t2a(szTempFileName);
+ if ((hNewBitmap = (HBITMAP)CallService(MS_UTILS_LOADBITMAP, 0, (LPARAM)pszTemp)) != NULL) {
+ if (dat->hBitmap) {
+ DeleteObject(dat->hBitmap);
+ DeleteFile(dat->ppro->m_szPhotoFileName);
+ }
+
+ dat->hBitmap = hNewBitmap;
+ _tcscpy(dat->ppro->m_szPhotoFileName, szTempFileName);
+ dat->ppro->m_bPhotoChanged = TRUE;
+ EnableWindow(GetDlgItem(hwndDlg, IDC_DELETE), TRUE);
+ InvalidateRect(hwndDlg, NULL, TRUE);
+ UpdateWindow(hwndDlg);
+ dat->ppro->m_vCardUpdates |= (1UL << iPageId);
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ }
+ else DeleteFile(szTempFileName);
+
+ mir_free(pszTemp);
+ }
+ else DeleteFile(szTempFileName);
+ }
+ }
+ break;
}
break;
+
case WM_PAINT:
if (dat->hBitmap) {
BITMAP bm;
@@ -398,7 +399,7 @@ static INT_PTR CALLBACK PhotoDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
HDC hdcMem = CreateCompatibleDC(hdcCanvas);
SelectObject(hdcMem, dat->hBitmap);
SetMapMode(hdcMem, GetMapMode(hdcCanvas));
- GetObject(dat->hBitmap, sizeof(BITMAP), (LPVOID) &bm);
+ GetObject(dat->hBitmap, sizeof(BITMAP), (LPVOID)&bm);
ptSize.x = bm.bmWidth;
ptSize.y = bm.bmHeight;
DPtoLP(hdcCanvas, &ptSize, 1);
@@ -407,22 +408,22 @@ static INT_PTR CALLBACK PhotoDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
GetClientRect(hwndCanvas, &rect);
InvalidateRect(hwndCanvas, NULL, TRUE);
UpdateWindow(hwndCanvas);
- if (ptSize.x<=rect.right && ptSize.y<=rect.bottom) {
- pt.x = (rect.right - ptSize.x)/2;
- pt.y = (rect.bottom - ptSize.y)/2;
+ if (ptSize.x <= rect.right && ptSize.y <= rect.bottom) {
+ pt.x = (rect.right - ptSize.x) / 2;
+ pt.y = (rect.bottom - ptSize.y) / 2;
ptFitSize = ptSize;
}
else {
- if (((float)(ptSize.x-rect.right))/ptSize.x > ((float)(ptSize.y-rect.bottom))/ptSize.y) {
+ if (((float)(ptSize.x - rect.right)) / ptSize.x > ((float)(ptSize.y - rect.bottom)) / ptSize.y) {
ptFitSize.x = rect.right;
- ptFitSize.y = (ptSize.y*rect.right)/ptSize.x;
+ ptFitSize.y = (ptSize.y*rect.right) / ptSize.x;
pt.x = 0;
- pt.y = (rect.bottom - ptFitSize.y)/2;
+ pt.y = (rect.bottom - ptFitSize.y) / 2;
}
else {
- ptFitSize.x = (ptSize.x*rect.bottom)/ptSize.y;
+ ptFitSize.x = (ptSize.x*rect.bottom) / ptSize.y;
ptFitSize.y = rect.bottom;
- pt.x = (rect.right - ptFitSize.x)/2;
+ pt.x = (rect.right - ptFitSize.x) / 2;
pt.y = 0;
}
}
@@ -435,7 +436,7 @@ static INT_PTR CALLBACK PhotoDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
FillRect(hdcCanvas, &rc, (HBRUSH)GetSysColorBrush(COLOR_BTNFACE));
if (bm.bmBitsPixel == 32) {
- BLENDFUNCTION bf = {0};
+ BLENDFUNCTION bf = { 0 };
bf.AlphaFormat = AC_SRC_ALPHA;
bf.BlendOp = AC_SRC_OVER;
bf.SourceConstantAlpha = 255;
@@ -456,13 +457,15 @@ static INT_PTR CALLBACK PhotoDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
case PSN_PARAMCHANGED:
SendMessage(hwndDlg, WM_INITDIALOG, 0, ((PSHNOTIFY*)lParam)->lParam);
break;
+
case PSN_APPLY:
- dat->ppro->m_vCardUpdates &= ~(1UL<<iPageId);
+ dat->ppro->m_vCardUpdates &= ~(1UL << iPageId);
dat->ppro->SaveVcardToDB(hwndDlg, iPageId);
if (!dat->ppro->m_vCardUpdates)
dat->ppro->SetServerVcard(dat->ppro->m_bPhotoChanged, dat->ppro->m_szPhotoFileName);
break;
- } }
+ }
+ }
break;
case WM_DESTROY:
@@ -496,18 +499,18 @@ static INT_PTR CALLBACK NoteDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA
SendMessage(hwndDlg, WM_JABBER_REFRESH_VCARD, 0, 0);
ppro->WindowSubscribe(hwndDlg);
break;
+
case WM_JABBER_REFRESH_VCARD:
- {
SetDialogField(ppro, hwndDlg, IDC_DESC, "About");
break;
- }
+
case WM_COMMAND:
- if ((HWND)lParam==GetFocus() && HIWORD(wParam)==EN_CHANGE)
- {
- ppro->m_vCardUpdates |= (1UL<<iPageId);
+ if ((HWND)lParam == GetFocus() && HIWORD(wParam) == EN_CHANGE) {
+ ppro->m_vCardUpdates |= (1UL << iPageId);
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
}
break;
+
case WM_NOTIFY:
if (((LPNMHDR)lParam)->idFrom == 0) {
switch (((LPNMHDR)lParam)->code) {
@@ -520,7 +523,8 @@ static INT_PTR CALLBACK NoteDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA
if (!ppro->m_vCardUpdates)
ppro->SetServerVcard(ppro->m_bPhotoChanged, ppro->m_szPhotoFileName);
break;
- } }
+ }
+ }
break;
case WM_DESTROY:
ppro->WindowUnsubscribe(hwndDlg);
@@ -553,7 +557,7 @@ static INT_PTR CALLBACK EditEmailDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam,
char idstr[33];
mir_snprintf(idstr, SIZEOF(idstr), "e-mail%d", dat->id);
- ptrA email( dat->ppro->getStringA(idstr));
+ ptrA email(dat->ppro->getStringA(idstr));
if (email != NULL)
SetDlgItemTextA(hwndDlg, IDC_EMAIL, email);
@@ -572,9 +576,9 @@ static INT_PTR CALLBACK EditEmailDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam,
char idstr[33];
if (dat->id < 0)
- for (dat->id=0;;dat->id++) {
+ for (dat->id = 0;; dat->id++) {
mir_snprintf(idstr, SIZEOF(idstr), "e-mail%d", dat->id);
- if ( ptrA( dat->ppro->getStringA(idstr)) == NULL)
+ if (ptrA(dat->ppro->getStringA(idstr)) == NULL)
break;
}
@@ -615,7 +619,7 @@ static INT_PTR CALLBACK EditPhoneDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam,
char idstr[33];
mir_snprintf(idstr, SIZEOF(idstr), "Phone%d", dat->id);
- ptrA phone( dat->ppro->getStringA(idstr));
+ ptrA phone(dat->ppro->getStringA(idstr));
if (phone != NULL)
SetDlgItemTextA(hwndDlg, IDC_PHONE, phone);
@@ -639,38 +643,38 @@ static INT_PTR CALLBACK EditPhoneDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam,
case WM_COMMAND:
switch (LOWORD(wParam)) {
case IDOK:
- {
- char idstr[33];
-
- if (dat->id < 0)
- for (dat->id=0;;dat->id++) {
- mir_snprintf(idstr, SIZEOF(idstr), "Phone%d", dat->id);
- if ( ptrA( dat->ppro->getStringA(idstr)) == NULL)
- break;
- }
+ {
+ char idstr[33];
- char text[128];
- GetDlgItemTextA(hwndDlg, IDC_PHONE, text, SIZEOF(text));
- mir_snprintf(idstr, SIZEOF(idstr), "Phone%d", dat->id);
- dat->ppro->setString(idstr, text);
+ if (dat->id < 0)
+ for (dat->id = 0;; dat->id++) {
+ mir_snprintf(idstr, SIZEOF(idstr), "Phone%d", dat->id);
+ if (ptrA(dat->ppro->getStringA(idstr)) == NULL)
+ break;
+ }
- WORD nFlag = 0;
- if (IsDlgButtonChecked(hwndDlg, IDC_HOME)) nFlag |= JABBER_VCTEL_HOME;
- if (IsDlgButtonChecked(hwndDlg, IDC_WORK)) nFlag |= JABBER_VCTEL_WORK;
- if (IsDlgButtonChecked(hwndDlg, IDC_VOICE)) nFlag |= JABBER_VCTEL_VOICE;
- if (IsDlgButtonChecked(hwndDlg, IDC_FAX)) nFlag |= JABBER_VCTEL_FAX;
- if (IsDlgButtonChecked(hwndDlg, IDC_PAGER)) nFlag |= JABBER_VCTEL_PAGER;
- if (IsDlgButtonChecked(hwndDlg, IDC_MSG)) nFlag |= JABBER_VCTEL_MSG;
- if (IsDlgButtonChecked(hwndDlg, IDC_CELL)) nFlag |= JABBER_VCTEL_CELL;
- if (IsDlgButtonChecked(hwndDlg, IDC_VIDEO)) nFlag |= JABBER_VCTEL_VIDEO;
- if (IsDlgButtonChecked(hwndDlg, IDC_BBS)) nFlag |= JABBER_VCTEL_BBS;
- if (IsDlgButtonChecked(hwndDlg, IDC_MODEM)) nFlag |= JABBER_VCTEL_MODEM;
- if (IsDlgButtonChecked(hwndDlg, IDC_ISDN)) nFlag |= JABBER_VCTEL_ISDN;
- if (IsDlgButtonChecked(hwndDlg, IDC_PCS)) nFlag |= JABBER_VCTEL_PCS;
- mir_snprintf(idstr, SIZEOF(idstr), "PhoneFlag%d", dat->id);
- dat->ppro->setWord(idstr, nFlag);
- }
- // fall through
+ char text[128];
+ GetDlgItemTextA(hwndDlg, IDC_PHONE, text, SIZEOF(text));
+ mir_snprintf(idstr, SIZEOF(idstr), "Phone%d", dat->id);
+ dat->ppro->setString(idstr, text);
+
+ WORD nFlag = 0;
+ if (IsDlgButtonChecked(hwndDlg, IDC_HOME)) nFlag |= JABBER_VCTEL_HOME;
+ if (IsDlgButtonChecked(hwndDlg, IDC_WORK)) nFlag |= JABBER_VCTEL_WORK;
+ if (IsDlgButtonChecked(hwndDlg, IDC_VOICE)) nFlag |= JABBER_VCTEL_VOICE;
+ if (IsDlgButtonChecked(hwndDlg, IDC_FAX)) nFlag |= JABBER_VCTEL_FAX;
+ if (IsDlgButtonChecked(hwndDlg, IDC_PAGER)) nFlag |= JABBER_VCTEL_PAGER;
+ if (IsDlgButtonChecked(hwndDlg, IDC_MSG)) nFlag |= JABBER_VCTEL_MSG;
+ if (IsDlgButtonChecked(hwndDlg, IDC_CELL)) nFlag |= JABBER_VCTEL_CELL;
+ if (IsDlgButtonChecked(hwndDlg, IDC_VIDEO)) nFlag |= JABBER_VCTEL_VIDEO;
+ if (IsDlgButtonChecked(hwndDlg, IDC_BBS)) nFlag |= JABBER_VCTEL_BBS;
+ if (IsDlgButtonChecked(hwndDlg, IDC_MODEM)) nFlag |= JABBER_VCTEL_MODEM;
+ if (IsDlgButtonChecked(hwndDlg, IDC_ISDN)) nFlag |= JABBER_VCTEL_ISDN;
+ if (IsDlgButtonChecked(hwndDlg, IDC_PCS)) nFlag |= JABBER_VCTEL_PCS;
+ mir_snprintf(idstr, SIZEOF(idstr), "PhoneFlag%d", dat->id);
+ dat->ppro->setWord(idstr, nFlag);
+ }
+ // fall through
case IDCANCEL:
EndDialog(hwndDlg, wParam);
break;
@@ -685,7 +689,7 @@ static INT_PTR CALLBACK ContactDlgProc(HWND hwndDlg, UINT msg, WPARAM, LPARAM lP
const unsigned long iPageId = 5;
CJabberProto *ppro = (CJabberProto*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
- switch(msg) {
+ switch (msg) {
case WM_INITDIALOG:
if (!lParam) break; // Launched from userinfo
ppro = (CJabberProto*)lParam;
@@ -696,20 +700,20 @@ static INT_PTR CALLBACK ContactDlgProc(HWND hwndDlg, UINT msg, WPARAM, LPARAM lP
SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam);
TranslateDialogDefault(hwndDlg);
- GetClientRect(GetDlgItem(hwndDlg,IDC_EMAILS), &rc);
+ GetClientRect(GetDlgItem(hwndDlg, IDC_EMAILS), &rc);
rc.right -= GetSystemMetrics(SM_CXVSCROLL);
lvc.mask = LVCF_WIDTH;
lvc.cx = 30;
- ListView_InsertColumn(GetDlgItem(hwndDlg,IDC_EMAILS), 0, &lvc);
- ListView_InsertColumn(GetDlgItem(hwndDlg,IDC_PHONES), 0, &lvc);
+ ListView_InsertColumn(GetDlgItem(hwndDlg, IDC_EMAILS), 0, &lvc);
+ ListView_InsertColumn(GetDlgItem(hwndDlg, IDC_PHONES), 0, &lvc);
lvc.cx = rc.right - 30 - 40;
- ListView_InsertColumn(GetDlgItem(hwndDlg,IDC_EMAILS), 1, &lvc);
- ListView_InsertColumn(GetDlgItem(hwndDlg,IDC_PHONES), 1, &lvc);
+ ListView_InsertColumn(GetDlgItem(hwndDlg, IDC_EMAILS), 1, &lvc);
+ ListView_InsertColumn(GetDlgItem(hwndDlg, IDC_PHONES), 1, &lvc);
lvc.cx = 20;
- ListView_InsertColumn(GetDlgItem(hwndDlg,IDC_EMAILS), 2, &lvc);
- ListView_InsertColumn(GetDlgItem(hwndDlg,IDC_EMAILS), 3, &lvc);
- ListView_InsertColumn(GetDlgItem(hwndDlg,IDC_PHONES), 2, &lvc);
- ListView_InsertColumn(GetDlgItem(hwndDlg,IDC_PHONES), 3, &lvc);
+ ListView_InsertColumn(GetDlgItem(hwndDlg, IDC_EMAILS), 2, &lvc);
+ ListView_InsertColumn(GetDlgItem(hwndDlg, IDC_EMAILS), 3, &lvc);
+ ListView_InsertColumn(GetDlgItem(hwndDlg, IDC_PHONES), 2, &lvc);
+ ListView_InsertColumn(GetDlgItem(hwndDlg, IDC_PHONES), 3, &lvc);
SendMessage(hwndDlg, M_REMAKELISTS, 0, 0);
ppro->WindowSubscribe(hwndDlg);
@@ -774,8 +778,9 @@ static INT_PTR CALLBACK ContactDlgProc(HWND hwndDlg, UINT msg, WPARAM, LPARAM lP
case PSN_PARAMCHANGED:
SendMessage(hwndDlg, WM_INITDIALOG, 0, ((PSHNOTIFY*)lParam)->lParam);
break;
+
case PSN_APPLY:
- ppro->m_vCardUpdates &= ~(1UL<<iPageId);
+ ppro->m_vCardUpdates &= ~(1UL << iPageId);
ppro->SaveVcardToDB(hwndDlg, iPageId);
if (!ppro->m_vCardUpdates)
ppro->SetServerVcard(ppro->m_bPhotoChanged, ppro->m_szPhotoFileName);
@@ -788,7 +793,7 @@ static INT_PTR CALLBACK ContactDlgProc(HWND hwndDlg, UINT msg, WPARAM, LPARAM lP
switch (((LPNMHDR)lParam)->code) {
case NM_CUSTOMDRAW:
{
- NMLVCUSTOMDRAW *nm = (NMLVCUSTOMDRAW *) lParam;
+ NMLVCUSTOMDRAW *nm = (NMLVCUSTOMDRAW *)lParam;
switch (nm->nmcd.dwDrawStage) {
case CDDS_PREPAINT:
@@ -796,19 +801,19 @@ static INT_PTR CALLBACK ContactDlgProc(HWND hwndDlg, UINT msg, WPARAM, LPARAM lP
SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, CDRF_NOTIFYSUBITEMDRAW);
return TRUE;
- case CDDS_SUBITEM|CDDS_ITEMPREPAINT:
+ case CDDS_SUBITEM | CDDS_ITEMPREPAINT:
RECT rc;
HICON hIcon;
ListView_GetSubItemRect(nm->nmcd.hdr.hwndFrom, nm->nmcd.dwItemSpec, nm->iSubItem, LVIR_LABEL, &rc);
- if (nm->nmcd.lItemlParam==(LPARAM)(-1) && nm->iSubItem==3)
+ if (nm->nmcd.lItemlParam == (LPARAM)(-1) && nm->iSubItem == 3)
hIcon = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_ADDCONTACT), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0);
- else if (nm->iSubItem==2 && nm->nmcd.lItemlParam!=(LPARAM)(-1))
+ else if (nm->iSubItem == 2 && nm->nmcd.lItemlParam != (LPARAM)(-1))
hIcon = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_EDIT), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0);
- else if (nm->iSubItem==3 && nm->nmcd.lItemlParam!=(LPARAM)(-1))
+ else if (nm->iSubItem == 3 && nm->nmcd.lItemlParam != (LPARAM)(-1))
hIcon = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_DELETE), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0);
else break;
- DrawIconEx(nm->nmcd.hdc, (rc.left+rc.right-GetSystemMetrics(SM_CXSMICON))/2, (rc.top+rc.bottom-GetSystemMetrics(SM_CYSMICON))/2,hIcon, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0, NULL, DI_NORMAL);
+ DrawIconEx(nm->nmcd.hdc, (rc.left + rc.right - GetSystemMetrics(SM_CXSMICON)) / 2, (rc.top + rc.bottom - GetSystemMetrics(SM_CYSMICON)) / 2, hIcon, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0, NULL, DI_NORMAL);
DestroyIcon(hIcon);
SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, CDRF_SKIPDEFAULT);
return TRUE;
@@ -817,7 +822,7 @@ static INT_PTR CALLBACK ContactDlgProc(HWND hwndDlg, UINT msg, WPARAM, LPARAM lP
break;
case NM_CLICK:
- NMLISTVIEW *nm = (NMLISTVIEW *) lParam;
+ NMLISTVIEW *nm = (NMLISTVIEW *)lParam;
if (nm->iSubItem < 2)
break;
@@ -825,8 +830,8 @@ static INT_PTR CALLBACK ContactDlgProc(HWND hwndDlg, UINT msg, WPARAM, LPARAM lP
const char* szFlagTemplate = (nm->hdr.idFrom == IDC_PHONES) ? "PhoneFlag%d" : "e-mailFlag%d";
LVHITTESTINFO hti;
- hti.pt.x = (short) LOWORD(GetMessagePos());
- hti.pt.y = (short) HIWORD(GetMessagePos());
+ hti.pt.x = (short)LOWORD(GetMessagePos());
+ hti.pt.y = (short)HIWORD(GetMessagePos());
ScreenToClient(nm->hdr.hwndFrom, &hti.pt);
if (ListView_SubItemHitTest(nm->hdr.hwndFrom, &hti) == -1)
break;
@@ -848,7 +853,7 @@ static INT_PTR CALLBACK ContactDlgProc(HWND hwndDlg, UINT msg, WPARAM, LPARAM lP
if (res != IDOK)
break;
SendMessage(hwndDlg, M_REMAKELISTS, 0, 0);
- ppro->m_vCardUpdates |= (1UL<<iPageId);
+ ppro->m_vCardUpdates |= (1UL << iPageId);
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
}
}
@@ -858,9 +863,9 @@ static INT_PTR CALLBACK ContactDlgProc(HWND hwndDlg, UINT msg, WPARAM, LPARAM lP
char idstr[33];
int i;
- for (i=lvi.lParam; ; i++) {
+ for (i = lvi.lParam;; i++) {
mir_snprintf(idstr, SIZEOF(idstr), szIdTemplate, i + 1);
- ptrA fieldVal( ppro->getStringA(idstr));
+ ptrA fieldVal(ppro->getStringA(idstr));
if (fieldVal == NULL) break;
mir_snprintf(idstr, SIZEOF(idstr), szIdTemplate, i);
ppro->setString(idstr, fieldVal);
@@ -887,8 +892,8 @@ static INT_PTR CALLBACK ContactDlgProc(HWND hwndDlg, UINT msg, WPARAM, LPARAM lP
res = DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_VCARD_ADDEMAIL), hwndDlg, EditEmailDlgProc, (LPARAM)&param);
if (res != IDOK)
break;
- SendMessage(hwndDlg,M_REMAKELISTS,0,0);
- ppro->m_vCardUpdates |= (1UL<<iPageId);
+ SendMessage(hwndDlg, M_REMAKELISTS, 0, 0);
+ ppro->m_vCardUpdates |= (1UL << iPageId);
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
}
}
@@ -901,8 +906,8 @@ static INT_PTR CALLBACK ContactDlgProc(HWND hwndDlg, UINT msg, WPARAM, LPARAM lP
if (GetForegroundWindow() == GetParent(hwndDlg)) {
POINT pt;
GetCursorPos(&pt);
- ScreenToClient(hwndDlg,&pt);
- SetFocus(ChildWindowFromPoint(hwndDlg,pt)); //ugly hack because listviews ignore their first click
+ ScreenToClient(hwndDlg, &pt);
+ SetFocus(ChildWindowFromPoint(hwndDlg, pt)); //ugly hack because listviews ignore their first click
}
break;
@@ -957,7 +962,7 @@ void CJabberProto::SaveVcardToDB(HWND hwndPage, int iPage)
setTString("ZIP", text);
{
int i = SendDlgItemMessage(hwndPage, IDC_COUNTRY, CB_GETCURSEL, 0, 0);
- TCHAR *country = mir_a2t((i) ? g_countries[i+2].szName : g_countries[1].szName);
+ TCHAR *country = mir_a2t((i) ? g_countries[i + 2].szName : g_countries[1].szName);
setTString("Country", country);
mir_free(country);
}
@@ -983,7 +988,7 @@ void CJabberProto::SaveVcardToDB(HWND hwndPage, int iPage)
setTString("CompanyZIP", text);
{
int i = SendDlgItemMessage(hwndPage, IDC_COUNTRY, CB_GETCURSEL, 0, 0);
- TCHAR *country = mir_a2t((i) ? g_countries[i+2].szName : g_countries[1].szName);
+ TCHAR *country = mir_a2t((i) ? g_countries[i + 2].szName : g_countries[1].szName);
setTString("CompanyCountry", country);
mir_free(country);
}
@@ -997,18 +1002,16 @@ void CJabberProto::SaveVcardToDB(HWND hwndPage, int iPage)
GetDlgItemText(hwndPage, IDC_DESC, text, SIZEOF(text));
setTString("About", text);
break;
-
- // Page 5: Contacts
- // is always synced with db
-} }
+ }
+}
void CJabberProto::AppendVcardFromDB(HXML n, char *tag, char *key)
{
if (n == NULL || tag == NULL || key == NULL)
return;
- ptrT tszValue( getTStringA(key));
- n << XCHILD( _A2T(tag), tszValue);
+ ptrT tszValue(getTStringA(key));
+ n << XCHILD(_A2T(tag), tszValue);
}
void CJabberProto::SetServerVcard(BOOL bPhotoChanged, TCHAR* szPhotoFileName)
@@ -1018,7 +1021,7 @@ void CJabberProto::SetServerVcard(BOOL bPhotoChanged, TCHAR* szPhotoFileName)
int i;
char idstr[33];
- XmlNodeIq iq( AddIQ(&CJabberProto::OnIqResultSetVcard, JABBER_IQ_TYPE_SET));
+ XmlNodeIq iq(AddIQ(&CJabberProto::OnIqResultSetVcard, JABBER_IQ_TYPE_SET));
HXML v = iq << XCHILDNS(_T("vCard"), JABBER_FEAT_VCARD_TEMP);
AppendVcardFromDB(v, "FN", "FullName");
@@ -1032,9 +1035,9 @@ void CJabberProto::SetServerVcard(BOOL bPhotoChanged, TCHAR* szPhotoFileName)
AppendVcardFromDB(v, "BDAY", "BirthDate");
AppendVcardFromDB(v, "GENDER", "GenderString");
- for (i=0; ; i++) {
+ for (i = 0;; i++) {
mir_snprintf(idstr, SIZEOF(idstr), "e-mail%d", i);
- ptrT email( getTStringA(idstr));
+ ptrT email(getTStringA(idstr));
if (email == NULL)
break;
@@ -1080,9 +1083,9 @@ void CJabberProto::SetServerVcard(BOOL bPhotoChanged, TCHAR* szPhotoFileName)
AppendVcardFromDB(v, "URL", "Homepage");
AppendVcardFromDB(v, "DESC", "About");
- for (i=0; ; i++) {
+ for (i = 0;; i++) {
mir_snprintf(idstr, SIZEOF(idstr), "Phone%d", i);
- ptrT phone( getTStringA(idstr));
+ ptrT phone(getTStringA(idstr));
if (phone == NULL)
break;
@@ -1124,7 +1127,7 @@ void CJabberProto::SetServerVcard(BOOL bPhotoChanged, TCHAR* szPhotoFileName)
debugLog(_T("Saving picture from %s"), szFileName);
struct _stat st;
- if ( _tstat(szFileName, &st) >= 0) {
+ if (_tstat(szFileName, &st) >= 0) {
// Note the FILE_SHARE_READ attribute so that the CopyFile can succeed
HANDLE hFile = CreateFile(szFileName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (hFile != INVALID_HANDLE_VALUE) {
@@ -1132,11 +1135,11 @@ void CJabberProto::SetServerVcard(BOOL bPhotoChanged, TCHAR* szPhotoFileName)
if (buffer != NULL) {
DWORD nRead;
if (ReadFile(hFile, buffer, st.st_size, &nRead, NULL)) {
- ptrA str( mir_base64_encode((PBYTE)(LPSTR)buffer, nRead));
+ ptrA str(mir_base64_encode((PBYTE)(LPSTR)buffer, nRead));
if (str != NULL) {
n = v << XCHILD(_T("PHOTO"));
TCHAR *szFileType;
- switch( ProtoGetBufferFormat(buffer)) {
+ switch (ProtoGetBufferFormat(buffer)) {
case PA_FORMAT_PNG: szFileType = _T("image/png"); break;
case PA_FORMAT_GIF: szFileType = _T("image/gif"); break;
case PA_FORMAT_BMP: szFileType = _T("image/bmp"); break;
@@ -1152,9 +1155,9 @@ void CJabberProto::SetServerVcard(BOOL bPhotoChanged, TCHAR* szPhotoFileName)
mir_sha1_append(&sha1ctx, (BYTE*)(LPSTR)buffer, nRead);
mir_sha1_finish(&sha1ctx, digest);
- char buf[MIR_SHA1_HASH_SIZE*2+1];
+ char buf[MIR_SHA1_HASH_SIZE * 2 + 1];
bin2hex(digest, sizeof(digest), buf);
-
+
m_options.AvatarType = ProtoGetBufferFormat(buffer);
if (bPhotoChanged) {
@@ -1188,7 +1191,7 @@ void CJabberProto::OnUserInfoInit_VCard(WPARAM wParam, LPARAM)
OPTIONSDIALOGPAGE odp = { sizeof(odp) };
odp.hInstance = hInst;
odp.dwInitParam = (LPARAM)this;
- odp.flags = ODPF_TCHAR|ODPF_USERINFOTAB|ODPF_DONTTRANSLATE;
+ odp.flags = ODPF_TCHAR | ODPF_USERINFOTAB | ODPF_DONTTRANSLATE;
odp.ptszTitle = m_tszUserName;
odp.pfnDlgProc = PersonalDlgProc;