summaryrefslogtreecommitdiff
path: root/miranda-wine/src/modules/userinfo
diff options
context:
space:
mode:
Diffstat (limited to 'miranda-wine/src/modules/userinfo')
-rw-r--r--miranda-wine/src/modules/userinfo/contactinfo.c503
-rw-r--r--miranda-wine/src/modules/userinfo/stdinfo.c541
-rw-r--r--miranda-wine/src/modules/userinfo/userinfo.c500
3 files changed, 1544 insertions, 0 deletions
diff --git a/miranda-wine/src/modules/userinfo/contactinfo.c b/miranda-wine/src/modules/userinfo/contactinfo.c
new file mode 100644
index 0000000..978a34a
--- /dev/null
+++ b/miranda-wine/src/modules/userinfo/contactinfo.c
@@ -0,0 +1,503 @@
+/*
+
+Miranda IM: the free IM client for Microsoft* Windows*
+
+Copyright 2000-2006 Miranda ICQ/IM project,
+all portions of this codebase are copyrighted to the people
+listed in contributors.txt.
+
+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.
+*/
+#include "commonheaders.h"
+
+static HFONT hEmailFont=NULL;
+static HCURSOR hHandCursor=NULL;
+
+static BOOL CALLBACK EditUserEmailDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ switch(msg) {
+ case WM_INITDIALOG:
+ SetWindowLong(hwndDlg,GWL_USERDATA,lParam);
+ if(*(char*)lParam) SetWindowText(hwndDlg,TranslateT("Edit E-Mail Address"));
+ TranslateDialogDefault(hwndDlg);
+ SetDlgItemTextA(hwndDlg,IDC_EMAIL,(char*)lParam);
+ EnableWindow(GetDlgItem(hwndDlg,IDOK),*(char*)lParam);
+ return TRUE;
+ case WM_COMMAND:
+ switch(LOWORD(wParam)) {
+ case IDOK:
+ GetDlgItemTextA(hwndDlg,IDC_EMAIL,(char*)GetWindowLong(hwndDlg,GWL_USERDATA),256);
+ //fall through
+ case IDCANCEL:
+ EndDialog(hwndDlg,wParam);
+ case IDC_EMAIL:
+ if(HIWORD(wParam)==EN_CHANGE)
+ EnableWindow(GetDlgItem(hwndDlg,IDOK),GetWindowTextLength(GetDlgItem(hwndDlg,IDC_EMAIL)));
+ break;
+ }
+ break;
+ }
+ return FALSE;
+}
+
+static BOOL CALLBACK EditUserPhoneDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ switch(msg) {
+ case WM_INITDIALOG:
+ { char *szText=(char*)lParam;
+ int i,item,countryCount;
+ struct CountryListEntry *countries;
+ SetWindowLong(hwndDlg,GWL_USERDATA,lParam);
+ if(szText[0]) SetWindowTextA(hwndDlg,"Edit Phone Number");
+ TranslateDialogDefault(hwndDlg);
+ if(lstrlenA(szText)>4 && !lstrcmpA(szText+lstrlenA(szText)-4," SMS")) {
+ CheckDlgButton(hwndDlg,IDC_SMS,BST_CHECKED);
+ szText[lstrlenA(szText)-4]='\0';
+ }
+ EnableWindow(GetDlgItem(hwndDlg,IDOK),szText[0]);
+ SendDlgItemMessage(hwndDlg,IDC_AREA,EM_LIMITTEXT,31,0);
+ SendDlgItemMessage(hwndDlg,IDC_NUMBER,EM_LIMITTEXT,63,0);
+ CallService(MS_UTILS_GETCOUNTRYLIST,(WPARAM)&countryCount,(LPARAM)&countries);
+ for(i=0;i<countryCount;i++) {
+ if(countries[i].id==0 || countries[i].id==0xFFFF) continue;
+ item=SendDlgItemMessageA(hwndDlg,IDC_COUNTRY,CB_ADDSTRING,0,(LPARAM)countries[i].szName);
+ SendDlgItemMessage(hwndDlg,IDC_COUNTRY,CB_SETITEMDATA,item,countries[i].id);
+ }
+ SetDlgItemTextA(hwndDlg,IDC_PHONE,szText);
+ return TRUE;
+ }
+ case WM_COMMAND:
+ switch(LOWORD(wParam)) {
+ static int noRecursion=0;
+
+ case IDOK:
+ { char *szText=(char*)GetWindowLong(hwndDlg,GWL_USERDATA);
+ int isValid=1;
+ GetDlgItemTextA(hwndDlg,IDC_PHONE,szText,252);
+ if(lstrlenA(szText)<7 || szText[0]!='+') isValid=0;
+ if(isValid) isValid=(lstrlenA(szText+1)==(int)strspn(szText+1,"0123456789 ()-"));
+ if(!isValid) {
+ MessageBox(hwndDlg,TranslateT("The phone number should start with a + and consist of numbers, spaces, brackets and hyphens only."),TranslateT("Invalid Phone Number"),MB_OK);
+ break;
+ }
+ if(IsDlgButtonChecked(hwndDlg,IDC_SMS)) lstrcatA(szText," SMS");
+ }
+ //fall through
+ case IDCANCEL:
+ EndDialog(hwndDlg,wParam);
+ case IDC_COUNTRY:
+ if(HIWORD(wParam)!=CBN_SELCHANGE) break;
+ case IDC_AREA:
+ case IDC_NUMBER:
+ if(LOWORD(wParam)!=IDC_COUNTRY && HIWORD(wParam)!=EN_CHANGE) break;
+ if(noRecursion) break;
+ EnableWindow(GetDlgItem(hwndDlg,IDOK),TRUE);
+ { char szPhone[96],szArea[32],szNumber[64];
+ GetDlgItemTextA(hwndDlg,IDC_AREA,szArea,SIZEOF(szArea));
+ GetDlgItemTextA(hwndDlg,IDC_NUMBER,szNumber,SIZEOF(szNumber));
+ mir_snprintf(szPhone,SIZEOF(szPhone),"+%u (%s) %s",SendDlgItemMessage(hwndDlg,IDC_COUNTRY,CB_GETITEMDATA,SendDlgItemMessage(hwndDlg,IDC_COUNTRY,CB_GETCURSEL,0,0),0),szArea,szNumber);
+ noRecursion=1;
+ SetDlgItemTextA(hwndDlg,IDC_PHONE,szPhone);
+ noRecursion=0;
+ }
+ break;
+ case IDC_PHONE:
+ if(HIWORD(wParam)!=EN_UPDATE) break;
+ if(noRecursion) break;
+ noRecursion=1;
+ { char szText[256],*pText,*pArea,*pNumber;
+ int isValid=1;
+ GetDlgItemTextA(hwndDlg,IDC_PHONE,szText,SIZEOF(szText));
+ if(szText[0]!='+') isValid=0;
+ if(isValid) {
+ int i,country=strtol(szText+1,&pText,10);
+ if(pText-szText>4) isValid=0;
+ else for(i=SendDlgItemMessage(hwndDlg,IDC_COUNTRY,CB_GETCOUNT,0,0)-1;i>=0;i--)
+ if(country==SendDlgItemMessage(hwndDlg,IDC_COUNTRY,CB_GETITEMDATA,i,0))
+ {SendDlgItemMessage(hwndDlg,IDC_COUNTRY,CB_SETCURSEL,i,0); break;}
+ if(i<0) isValid=0;
+ }
+ if(isValid) {
+ pArea=pText+strcspn(pText,"0123456789");
+ pText=pArea+strspn(pArea,"0123456789");
+ if(*pText) {
+ *pText='\0';
+ pNumber=pText+1+strcspn(pText+1,"0123456789");
+ SetDlgItemTextA(hwndDlg,IDC_NUMBER,pNumber);
+ }
+ SetDlgItemTextA(hwndDlg,IDC_AREA,pArea);
+ }
+ if(!isValid) {
+ SendDlgItemMessage(hwndDlg,IDC_COUNTRY,CB_SETCURSEL,-1,0);
+ SetDlgItemTextA(hwndDlg,IDC_AREA,"");
+ SetDlgItemTextA(hwndDlg,IDC_NUMBER,"");
+ }
+ }
+ noRecursion=0;
+ EnableWindow(GetDlgItem(hwndDlg,IDOK),GetWindowTextLength(GetDlgItem(hwndDlg,IDC_PHONE)));
+ break;
+ }
+ break;
+ }
+ return FALSE;
+}
+
+static int IsOverEmail(HWND hwndDlg,TCHAR* szEmail,int cchEmail)
+{
+ RECT rc;
+ HWND hwndEmails;
+ TCHAR szText[256];
+ HDC hdc;
+ SIZE textSize;
+ LVHITTESTINFO hti;
+
+ hwndEmails=GetDlgItem(hwndDlg,IDC_EMAILS);
+ GetCursorPos(&hti.pt);
+ ScreenToClient(hwndEmails,&hti.pt);
+ GetClientRect(hwndEmails,&rc);
+ if(!PtInRect(&rc,hti.pt)) return 0;
+ if(ListView_SubItemHitTest(hwndEmails,&hti)==-1) return 0;
+ if(hti.iSubItem!=1) return 0;
+ if(!(hti.flags&LVHT_ONITEMLABEL)) return 0;
+ ListView_GetSubItemRect(hwndEmails,hti.iItem,1,LVIR_LABEL,&rc);
+ ListView_GetItemText(hwndEmails,hti.iItem,1,szText,SIZEOF(szText));
+ hdc=GetDC(hwndEmails);
+ SelectObject(hdc,hEmailFont);
+ GetTextExtentPoint32(hdc,szText,lstrlen(szText),&textSize);
+ ReleaseDC(hwndEmails,hdc);
+ if(hti.pt.x<rc.left+textSize.cx) {
+ if(szEmail && cchEmail) lstrcpyn(szEmail,szText,cchEmail);
+ return 1;
+ }
+ return 0;
+}
+
+#define M_REMAKELISTS (WM_USER+1)
+BOOL CALLBACK ContactDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ switch(msg) {
+ case WM_INITDIALOG:
+ SetWindowLong(hwndDlg,GWL_USERDATA,lParam);
+ if(hEmailFont) DeleteObject(hEmailFont);
+ { LOGFONT lf;
+ hEmailFont=(HFONT)SendDlgItemMessage(hwndDlg,IDC_EMAILS,WM_GETFONT,0,0);
+ GetObject(hEmailFont,sizeof(lf),&lf);
+ lf.lfUnderline=1;
+ hEmailFont=CreateFontIndirect(&lf);
+ }
+ if(hHandCursor==NULL) {
+ if(IsWinVer2000Plus()) hHandCursor=LoadCursor(NULL,IDC_HAND);
+ else hHandCursor=LoadCursor(GetModuleHandle(NULL),MAKEINTRESOURCE(IDC_HYPERLINKHAND));
+ }
+ TranslateDialogDefault(hwndDlg);
+ { LVCOLUMN lvc;
+ RECT rc;
+ GetClientRect(GetDlgItem(hwndDlg,IDC_EMAILS),&rc);
+ rc.right-=GetSystemMetrics(SM_CXVSCROLL);
+ lvc.mask=LVCF_WIDTH;
+ lvc.cx=rc.right/4;
+ ListView_InsertColumn(GetDlgItem(hwndDlg,IDC_EMAILS),0,&lvc);
+ ListView_InsertColumn(GetDlgItem(hwndDlg,IDC_PHONES),0,&lvc);
+ lvc.cx=rc.right-rc.right/4-40;
+ ListView_InsertColumn(GetDlgItem(hwndDlg,IDC_EMAILS),1,&lvc);
+ lvc.cx=rc.right-rc.right/4-90;
+ ListView_InsertColumn(GetDlgItem(hwndDlg,IDC_PHONES),1,&lvc);
+ lvc.cx=50;
+ ListView_InsertColumn(GetDlgItem(hwndDlg,IDC_PHONES),2,&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),3,&lvc);
+ ListView_InsertColumn(GetDlgItem(hwndDlg,IDC_PHONES),4,&lvc);
+ }
+ return TRUE;
+ case M_REMAKELISTS:
+ { char *szProto;
+ LVITEM lvi;
+ int i;
+ char idstr[33];
+ TCHAR idstr2[33];
+ DBVARIANT dbv;
+ HANDLE hContact=(HANDLE)GetWindowLong(hwndDlg,GWL_USERDATA);
+
+ if (hContact != NULL) {
+ szProto=(char*)CallService(MS_PROTO_GETCONTACTBASEPROTO,(WPARAM)hContact,0);
+ if (szProto==NULL) break;
+ //e-mails
+ ListView_DeleteAllItems(GetDlgItem(hwndDlg,IDC_EMAILS));
+ lvi.mask=LVIF_TEXT|LVIF_PARAM;
+ lvi.lParam=(LPARAM)(-1);
+ lvi.iSubItem=0;
+ lvi.iItem=0;
+ for(i=-1;;i++) {
+ if(i==-1) {
+ if(DBGetContactSettingTString(hContact,szProto,"e-mail",&dbv))
+ continue;
+ lvi.pszText=TranslateT("Primary");
+ }
+ else {
+ wsprintfA(idstr, "e-mail%d", i );
+ if(DBGetContactSettingTString(hContact,szProto,idstr,&dbv))
+ break;
+ lvi.pszText=idstr2;
+ wsprintf(idstr2,_T("%d"),i+2);
+ }
+ ListView_InsertItem(GetDlgItem(hwndDlg,IDC_EMAILS),&lvi);
+ ListView_SetItemText(GetDlgItem(hwndDlg,IDC_EMAILS),lvi.iItem,1,dbv.ptszVal);
+ DBFreeVariant(&dbv);
+ lvi.iItem++;
+ }
+ lvi.iSubItem=0;
+ for(i=0;;i++) {
+ lvi.lParam=i;
+ wsprintfA(idstr,"Mye-mail%d",i);
+ if(DBGetContactSettingTString(hContact,"UserInfo",idstr,&dbv))
+ break;
+ lvi.pszText=idstr2;
+ wsprintf(idstr2,TranslateT("Custom %d"),i+1);
+ ListView_InsertItem(GetDlgItem(hwndDlg,IDC_EMAILS),&lvi);
+ ListView_SetItemText(GetDlgItem(hwndDlg,IDC_EMAILS),lvi.iItem,1,dbv.ptszVal);
+ DBFreeVariant(&dbv);
+ lvi.iItem++;
+ }
+ lvi.mask=LVIF_PARAM;
+ lvi.lParam=(LPARAM)(-2);
+ ListView_InsertItem(GetDlgItem(hwndDlg,IDC_EMAILS),&lvi);
+ //phones
+ ListView_DeleteAllItems(GetDlgItem(hwndDlg,IDC_PHONES));
+ lvi.mask=LVIF_TEXT|LVIF_PARAM;
+ lvi.lParam=(LPARAM)(-1);
+ lvi.iSubItem=0;
+ lvi.iItem=0;
+ if(!DBGetContactSettingTString(hContact,szProto,"Phone",&dbv)) {
+ lvi.pszText=TranslateT("Primary");
+ ListView_InsertItem(GetDlgItem(hwndDlg,IDC_PHONES),&lvi);
+ ListView_SetItemText(GetDlgItem(hwndDlg,IDC_PHONES),lvi.iItem,1,dbv.ptszVal);
+ DBFreeVariant(&dbv);
+ lvi.iItem++;
+ }
+ if(!DBGetContactSettingTString(hContact,szProto,"Fax",&dbv)) {
+ lvi.pszText=TranslateT("Fax");
+ ListView_InsertItem(GetDlgItem(hwndDlg,IDC_PHONES),&lvi);
+ ListView_SetItemText(GetDlgItem(hwndDlg,IDC_PHONES),lvi.iItem,1,dbv.ptszVal);
+ DBFreeVariant(&dbv);
+ lvi.iItem++;
+ }
+ if(!DBGetContactSettingTString(hContact,szProto,"Cellular",&dbv)) {
+ lvi.pszText=TranslateT("Mobile");
+ ListView_InsertItem(GetDlgItem(hwndDlg,IDC_PHONES),&lvi);
+ if(lstrlenA(dbv.pszVal)>4 && !lstrcmpA(dbv.pszVal+lstrlenA(dbv.pszVal)-4," SMS")) {
+ ListView_SetItemText(GetDlgItem(hwndDlg,IDC_PHONES),lvi.iItem,2,_T("y"));
+ dbv.ptszVal[lstrlen(dbv.ptszVal)-4]='\0';
+ }
+ ListView_SetItemText(GetDlgItem(hwndDlg,IDC_PHONES),lvi.iItem,1,dbv.ptszVal);
+ DBFreeVariant(&dbv);
+ lvi.iItem++;
+ }
+ if(!DBGetContactSettingTString(hContact,szProto,"CompanyPhone",&dbv)) {
+ lvi.pszText=TranslateT("Work Phone");
+ ListView_InsertItem(GetDlgItem(hwndDlg,IDC_PHONES),&lvi);
+ ListView_SetItemText(GetDlgItem(hwndDlg,IDC_PHONES),lvi.iItem,1,dbv.ptszVal);
+ DBFreeVariant(&dbv);
+ lvi.iItem++;
+ }
+ if(!DBGetContactSettingTString(hContact,szProto,"CompanyFax",&dbv)) {
+ lvi.pszText=TranslateT("Work Fax");
+ ListView_InsertItem(GetDlgItem(hwndDlg,IDC_PHONES),&lvi);
+ ListView_SetItemText(GetDlgItem(hwndDlg,IDC_PHONES),lvi.iItem,1,dbv.ptszVal);
+ DBFreeVariant(&dbv);
+ lvi.iItem++;
+ }
+ lvi.iSubItem=0;
+ for(i=0;;i++) {
+ lvi.lParam=i;
+ wsprintfA(idstr,"MyPhone%d",i);
+ if(DBGetContactSettingTString(hContact,"UserInfo",idstr,&dbv))
+ break;
+ lvi.pszText=idstr2;
+ wsprintf(idstr2,TranslateT("Custom %d"),i+1);
+ ListView_InsertItem(GetDlgItem(hwndDlg,IDC_PHONES),&lvi);
+ if(lstrlen(dbv.ptszVal)>4 && !lstrcmp(dbv.ptszVal+lstrlen(dbv.ptszVal)-4,_T(" SMS"))) {
+ ListView_SetItemText(GetDlgItem(hwndDlg,IDC_PHONES),lvi.iItem,2,_T("y"));
+ dbv.ptszVal[lstrlen(dbv.ptszVal)-4]='\0';
+ }
+ ListView_SetItemText(GetDlgItem(hwndDlg,IDC_PHONES),lvi.iItem,1,dbv.ptszVal);
+ DBFreeVariant(&dbv);
+ lvi.iItem++;
+ }
+ lvi.mask=LVIF_PARAM;
+ lvi.lParam=(LPARAM)(-2);
+ ListView_InsertItem(GetDlgItem(hwndDlg,IDC_PHONES),&lvi);
+ }
+ break;
+ }
+ case WM_NOTIFY:
+ switch (((LPNMHDR)lParam)->idFrom) {
+ case 0:
+ switch (((LPNMHDR)lParam)->code) {
+ case PSN_INFOCHANGED:
+ SendMessage(hwndDlg,M_REMAKELISTS,0,0);
+ break;
+ }
+ break;
+ case IDC_EMAILS:
+ case IDC_PHONES:
+ switch (((LPNMHDR)lParam)->code) {
+ case NM_CUSTOMDRAW:
+ { NMLVCUSTOMDRAW *nm=(NMLVCUSTOMDRAW*)lParam;
+ switch(nm->nmcd.dwDrawStage) {
+ case CDDS_PREPAINT:
+ case CDDS_ITEMPREPAINT:
+ SetWindowLong(hwndDlg,DWL_MSGRESULT,CDRF_NOTIFYSUBITEMDRAW);
+ return TRUE;
+ 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->iSubItem==1 && nm->nmcd.hdr.idFrom==IDC_EMAILS) {
+ HFONT hoFont;
+ TCHAR szText[256];
+ ListView_GetItemText(nm->nmcd.hdr.hwndFrom,nm->nmcd.dwItemSpec,nm->iSubItem,szText,SIZEOF(szText));
+ hoFont=(HFONT)SelectObject(nm->nmcd.hdc,hEmailFont);
+ SetTextColor(nm->nmcd.hdc,RGB(0,0,255));
+ DrawText(nm->nmcd.hdc,szText,-1,&rc,DT_END_ELLIPSIS|DT_LEFT|DT_NOPREFIX|DT_SINGLELINE|DT_TOP);
+ SelectObject(nm->nmcd.hdc,hoFont);
+ SetWindowLong(hwndDlg,DWL_MSGRESULT,CDRF_SKIPDEFAULT);
+ return TRUE;
+ }
+ if(nm->nmcd.lItemlParam==(LPARAM)(-2) && nm->iSubItem-3==(nm->nmcd.hdr.idFrom==IDC_PHONES))
+ hIcon=LoadImage(GetModuleHandle(NULL),MAKEINTRESOURCE(IDI_ADDCONTACT),IMAGE_ICON,GetSystemMetrics(SM_CXSMICON),GetSystemMetrics(SM_CYSMICON),0);
+ else if(nm->iSubItem>1 && nm->nmcd.lItemlParam!=(LPARAM)(-1) && nm->nmcd.lItemlParam!=(LPARAM)(-2)) {
+ static int iconResources[3]={IDI_RENAME,IDI_DELETE};
+ if(nm->iSubItem==2 && nm->nmcd.hdr.idFrom==IDC_PHONES) {
+ TCHAR szText[2];
+ ListView_GetItemText(nm->nmcd.hdr.hwndFrom,nm->nmcd.dwItemSpec,nm->iSubItem,szText,SIZEOF(szText));
+ if(szText[0]) hIcon=LoadImage(GetModuleHandle(NULL),MAKEINTRESOURCE(IDI_SMS),IMAGE_ICON,GetSystemMetrics(SM_CXSMICON),GetSystemMetrics(SM_CYSMICON),0);
+ }
+ else hIcon=LoadImage(GetModuleHandle(NULL),MAKEINTRESOURCE(iconResources[nm->iSubItem-3+(nm->nmcd.hdr.idFrom==IDC_EMAILS)]),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);
+ DestroyIcon(hIcon);
+ SetWindowLong(hwndDlg,DWL_MSGRESULT,CDRF_SKIPDEFAULT);
+ return TRUE;
+ }
+ }
+ break;
+ }
+ case NM_CLICK:
+ { NMLISTVIEW *nm=(NMLISTVIEW*)lParam;
+ LVITEM lvi;
+ TCHAR szEmail[256];
+ HANDLE hContact=(HANDLE)GetWindowLong(hwndDlg,GWL_USERDATA);
+ char *szIdTemplate=nm->hdr.idFrom==IDC_PHONES?"MyPhone%d":"Mye-mail%d";
+ LVHITTESTINFO hti;
+
+ if(IsOverEmail(hwndDlg,szEmail,SIZEOF(szEmail))) {
+ TCHAR szExec[264];
+ lstrcpy(szExec, _T("mailto:"));
+ lstrcat(szExec,szEmail);
+ ShellExecute(hwndDlg,_T("open"),szExec,NULL,NULL,SW_SHOW);
+ break;
+ }
+ if(nm->iSubItem<2) break;
+ 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;
+ lvi.mask=LVIF_PARAM;
+ lvi.iItem=hti.iItem;
+ lvi.iSubItem=0;
+ ListView_GetItem(nm->hdr.hwndFrom,&lvi);
+ if(lvi.lParam==(LPARAM)(-1)) break;
+ if(lvi.lParam==(LPARAM)(-2)) {
+ if(hti.iSubItem-3==(nm->hdr.idFrom==IDC_PHONES)) {
+ //add
+ char szNewData[256]="",idstr[33];
+ int i;
+ DBVARIANT dbv;
+ if(IDOK!=DialogBoxParam(GetModuleHandle(NULL),MAKEINTRESOURCE(nm->hdr.idFrom==IDC_PHONES?IDD_ADDPHONE:IDD_ADDEMAIL),hwndDlg,nm->hdr.idFrom==IDC_PHONES?EditUserPhoneDlgProc:EditUserEmailDlgProc,(LPARAM)szNewData))
+ break;
+ for(i=0;;i++) {
+ wsprintfA(idstr,szIdTemplate,i);
+ if(DBGetContactSetting(hContact,"UserInfo",idstr,&dbv)) break;
+ DBFreeVariant(&dbv);
+ }
+ DBWriteContactSettingString(hContact,"UserInfo",idstr,szNewData);
+ SendMessage(hwndDlg,M_REMAKELISTS,0,0);
+ }
+ }
+ else {
+ if(hti.iSubItem-3==(nm->hdr.idFrom==IDC_PHONES)) {
+ //delete
+ int i;
+ char idstr[33];
+ DBVARIANT dbv;
+ for(i=lvi.lParam;;i++) {
+ wsprintfA(idstr,szIdTemplate,i+1);
+ if(DBGetContactSetting(hContact,"UserInfo",idstr,&dbv)) break;
+ wsprintfA(idstr,szIdTemplate,i);
+ DBWriteContactSettingString(hContact,"UserInfo",idstr,dbv.pszVal);
+ DBFreeVariant(&dbv);
+ }
+ wsprintfA(idstr,szIdTemplate,i);
+ DBDeleteContactSetting(hContact,"UserInfo",idstr);
+ SendMessage(hwndDlg,M_REMAKELISTS,0,0);
+ }
+ else if(hti.iSubItem-2==(nm->hdr.idFrom==IDC_PHONES)) {
+ //edit
+ char szText[256],idstr[33];
+ DBVARIANT dbv;
+ wsprintfA(idstr,szIdTemplate,lvi.lParam);
+ if(DBGetContactSetting(hContact,"UserInfo",idstr,&dbv)) break;
+ lstrcpynA(szText,dbv.pszVal,SIZEOF(szText));
+ DBFreeVariant(&dbv);
+ if(IDOK!=DialogBoxParam(GetModuleHandle(NULL),MAKEINTRESOURCE(nm->hdr.idFrom==IDC_PHONES?IDD_ADDPHONE:IDD_ADDEMAIL),hwndDlg,nm->hdr.idFrom==IDC_PHONES?EditUserPhoneDlgProc:EditUserEmailDlgProc,(LPARAM)szText))
+ break;
+ DBWriteContactSettingString(hContact,"UserInfo",idstr,szText);
+ SendMessage(hwndDlg,M_REMAKELISTS,0,0);
+ }
+ }
+ break;
+ }
+ }
+ break;
+ }
+ break;
+ case WM_SETCURSOR:
+ if(LOWORD(lParam)!=HTCLIENT) break;
+ if(GetForegroundWindow()==GetParent(hwndDlg)) {
+ POINT pt;
+ GetCursorPos(&pt);
+ ScreenToClient(hwndDlg,&pt);
+ SetFocus(ChildWindowFromPoint(hwndDlg,pt)); //ugly hack because listviews ignore their first click
+ }
+ if(IsOverEmail(hwndDlg,NULL,0)) {
+ SetCursor(hHandCursor);
+ SetWindowLong(hwndDlg,DWL_MSGRESULT,TRUE);
+ return TRUE;
+ }
+ break;
+ case WM_COMMAND:
+ switch(LOWORD(wParam)) {
+ case IDCANCEL:
+ SendMessage(GetParent(hwndDlg),msg,wParam,lParam);
+ break;
+ }
+ break;
+ }
+ return FALSE;
+}
diff --git a/miranda-wine/src/modules/userinfo/stdinfo.c b/miranda-wine/src/modules/userinfo/stdinfo.c
new file mode 100644
index 0000000..79928bd
--- /dev/null
+++ b/miranda-wine/src/modules/userinfo/stdinfo.c
@@ -0,0 +1,541 @@
+/*
+
+Miranda IM: the free IM client for Microsoft* Windows*
+
+Copyright 2000-2006 Miranda ICQ/IM project,
+all portions of this codebase are copyrighted to the people
+listed in contributors.txt.
+
+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.
+*/
+#include "commonheaders.h"
+
+BOOL CALLBACK ContactDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
+
+void Utf8Decode( char* str, wchar_t** ucs2 );
+
+
+#define SVS_NORMAL 0
+#define SVS_GENDER 1
+#define SVS_ZEROISUNSPEC 2
+#define SVS_IP 3
+#define SVS_COUNTRY 4
+#define SVS_MONTH 5
+#define SVS_SIGNED 6
+#define SVS_TIMEZONE 7
+#define SVS_ICQVERSION 8
+
+static void SetValue(HWND hwndDlg,int idCtrl,HANDLE hContact,char *szModule,char *szSetting,int special)
+{
+ DBVARIANT dbv;
+ char str[80],*pstr = NULL;
+ TCHAR* ptstr = NULL;
+ int unspecified=0;
+
+ dbv.type=DBVT_DELETED;
+ if(szModule==NULL) unspecified=1;
+ else unspecified=DBGetContactSettingW(hContact,szModule,szSetting,&dbv);
+ if(!unspecified) {
+ switch(dbv.type) {
+ case DBVT_BYTE:
+ if(special==SVS_GENDER) {
+ if(dbv.cVal=='M') ptstr=TranslateT("Male");
+ else if(dbv.cVal=='F') ptstr=TranslateT("Female");
+ else unspecified=1;
+ }
+ else if(special==SVS_MONTH) {
+ if(dbv.bVal>0 && dbv.bVal<=12) {
+ pstr=str;
+ GetLocaleInfoA(LOCALE_USER_DEFAULT,LOCALE_SABBREVMONTHNAME1-1+dbv.bVal,str,SIZEOF(str));
+ }
+ else unspecified=1;
+ }
+ else if(special==SVS_TIMEZONE) {
+ if(dbv.cVal==-100) unspecified=1;
+ else {
+ pstr=str;
+ sprintf(str,dbv.cVal?"GMT%+d:%02d":"GMT",-dbv.cVal/2,(dbv.cVal&1)*30);
+ }
+ }
+ else {
+ unspecified=(special==SVS_ZEROISUNSPEC && dbv.bVal==0);
+ pstr=_itoa(special==SVS_SIGNED?dbv.cVal:dbv.bVal,str,10);
+ }
+ break;
+ case DBVT_WORD:
+ if(special==SVS_COUNTRY) {
+ pstr=(char*)CallService(MS_UTILS_GETCOUNTRYBYNUMBER,dbv.wVal,0);
+ unspecified=pstr==NULL;
+ }
+ else if (special == SVS_ICQVERSION) {
+ if (dbv.wVal != 0) {
+ static char *szVersionDescr[] = {"", "ICQ 1.x", "ICQ 2.x", "Unknown", "ICQ98", "Unknown", "ICQ99 / licq", "ICQ2000", "ICQ2001-2003, Miranda or Trillian", "ICQ Lite"};
+ pstr = str;
+ wsprintfA(str, "%d: %s", dbv.wVal, dbv.wVal > 9 ? Translate("Unknown") : Translate(szVersionDescr[dbv.wVal]));
+ }
+ else unspecified = 1;
+ }
+ else {
+ unspecified=(special==SVS_ZEROISUNSPEC && dbv.wVal==0);
+ pstr=_itoa(special==SVS_SIGNED?dbv.sVal:dbv.wVal,str,10);
+ }
+ break;
+ case DBVT_DWORD:
+ unspecified=(special==SVS_ZEROISUNSPEC && dbv.dVal==0);
+ if(special==SVS_IP) {
+ struct in_addr ia;
+ ia.S_un.S_addr=htonl(dbv.dVal);
+ pstr=inet_ntoa(ia);
+ if(dbv.dVal==0) unspecified=1;
+ }
+ else pstr=_itoa(special==SVS_SIGNED?dbv.lVal:dbv.dVal,str,10);
+ break;
+ case DBVT_ASCIIZ:
+ unspecified=(special==SVS_ZEROISUNSPEC && dbv.pszVal[0]=='\0');
+ pstr=dbv.pszVal;
+ break;
+ case DBVT_UTF8:
+ unspecified=(special==SVS_ZEROISUNSPEC && dbv.pszVal[0]=='\0');
+ #if defined( _UNICODE )
+ if ( !unspecified )
+ { WCHAR* wszStr;
+ Utf8Decode( dbv.pszVal, &wszStr );
+ SetDlgItemTextW( hwndDlg, idCtrl, wszStr);
+ mir_free( wszStr );
+ goto LBL_Exit;
+ }
+ #endif
+ pstr=dbv.pszVal;
+ Utf8Decode( dbv.pszVal, NULL );
+ break;
+ default: pstr=str; lstrcpyA(str,"???"); break;
+ } }
+
+ if (unspecified)
+ SetDlgItemText(hwndDlg, idCtrl, TranslateT("<not specified>"));
+ else if ( ptstr != NULL )
+ SetDlgItemText(hwndDlg, idCtrl, ptstr);
+ else
+ SetDlgItemTextA(hwndDlg, idCtrl, pstr);
+
+#if defined( _UNICODE )
+LBL_Exit:
+#endif
+ EnableWindow(GetDlgItem(hwndDlg, idCtrl), !unspecified);
+ DBFreeVariant(&dbv);
+}
+
+static BOOL CALLBACK SummaryDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ switch(msg) {
+ case WM_INITDIALOG:
+ TranslateDialogDefault(hwndDlg);
+ return TRUE;
+ case WM_NOTIFY:
+ switch (((LPNMHDR)lParam)->idFrom) {
+ case 0:
+ if (((LPNMHDR)lParam)->code == PSN_INFOCHANGED )
+ { char *szProto;
+ HANDLE hContact=(HANDLE)((LPPSHNOTIFY)lParam)->lParam;
+ if (hContact != NULL) {
+ szProto=(char*)CallService(MS_PROTO_GETCONTACTBASEPROTO,(WPARAM)hContact,0);
+ if (szProto==NULL) break;
+ SetValue(hwndDlg,IDC_NICK,hContact,szProto,"Nick",0);
+ SetValue(hwndDlg,IDC_FIRSTNAME,hContact,szProto,"FirstName",0);
+ SetValue(hwndDlg,IDC_LASTNAME,hContact,szProto,"LastName",0);
+ SetValue(hwndDlg,IDC_EMAIL,hContact,szProto,"e-mail",0);
+ SetValue(hwndDlg,IDC_AGE,hContact,szProto,"Age",SVS_ZEROISUNSPEC);
+ SetValue(hwndDlg,IDC_GENDER,hContact,szProto,"Gender",SVS_GENDER);
+ SetValue(hwndDlg,IDC_DOBDAY,hContact,szProto,"BirthDay",0);
+ SetValue(hwndDlg,IDC_DOBMONTH,hContact,szProto,"BirthMonth",SVS_MONTH);
+ SetValue(hwndDlg,IDC_DOBYEAR,hContact,szProto,"BirthYear",0);
+ } }
+ break;
+ }
+ break;
+ case WM_COMMAND:
+ switch(LOWORD(wParam)) {
+ case IDCANCEL:
+ SendMessage(GetParent(hwndDlg),msg,wParam,lParam);
+ break;
+ case IDC_EMAIL:
+ if(IsWindowEnabled(GetDlgItem(hwndDlg,IDC_EMAIL))) {
+ char szExec[264],szEmail[256];
+ GetDlgItemTextA(hwndDlg,IDC_EMAIL,szEmail,SIZEOF(szEmail));
+ lstrcpyA(szExec,"mailto:");
+ lstrcatA(szExec,szEmail);
+ ShellExecuteA(hwndDlg,"open",szExec,NULL,NULL,SW_SHOW);
+ }
+ break;
+ }
+ break;
+ }
+ return FALSE;
+}
+
+static BOOL CALLBACK LocationDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ switch(msg) {
+ case WM_INITDIALOG:
+ SetWindowLong(hwndDlg,GWL_USERDATA,lParam);
+ TranslateDialogDefault(hwndDlg);
+ SetTimer(hwndDlg,1,1000,NULL);
+ SendMessage(hwndDlg,WM_TIMER,0,0);
+ return TRUE;
+ case WM_TIMER:
+ { char *szProto;
+ HANDLE hContact=(HANDLE)GetWindowLong(hwndDlg,GWL_USERDATA);
+ int timezone;
+ FILETIME ft;
+ LARGE_INTEGER lift;
+ char szTime[80];
+ SYSTEMTIME st;
+
+ if (hContact != NULL) {
+ szProto=(char*)CallService(MS_PROTO_GETCONTACTBASEPROTO,(WPARAM)hContact,0);
+ if (szProto==NULL) break;
+ timezone=DBGetContactSettingByte(hContact,szProto,"Timezone",256);
+ if(timezone==256 || (char)timezone==-100) {
+ EnableWindow(GetDlgItem(hwndDlg,IDC_LOCALTIME),FALSE);
+ SetDlgItemText(hwndDlg,IDC_LOCALTIME,TranslateT("<not specified>"));
+ }
+ else {
+ TIME_ZONE_INFORMATION tzi;
+
+ EnableWindow(GetDlgItem(hwndDlg,IDC_LOCALTIME),TRUE);
+ timezone=(char)timezone;
+ GetSystemTimeAsFileTime(&ft);
+ switch (GetTimeZoneInformation(&tzi)) {
+ case TIME_ZONE_ID_DAYLIGHT:
+ timezone+=tzi.DaylightBias/30;
+ break;
+ }
+ lift.QuadPart=*(__int64*)&ft;
+ lift.QuadPart-=(__int64)timezone*BIGI(30)*BIGI(60)*BIGI(10000000);
+ *(__int64*)&ft=lift.QuadPart;
+ FileTimeToSystemTime(&ft,&st);
+ GetTimeFormatA(LOCALE_USER_DEFAULT,0,&st,NULL,szTime,SIZEOF(szTime));
+ SetDlgItemTextA(hwndDlg,IDC_LOCALTIME,szTime);
+ }
+ }
+ break;
+ }
+ case WM_NOTIFY:
+ switch (((LPNMHDR)lParam)->idFrom) {
+ case 0:
+ if (((LPNMHDR)lParam)->code == PSN_INFOCHANGED )
+ { char *szProto;
+ HANDLE hContact=(HANDLE)((LPPSHNOTIFY)lParam)->lParam;
+ if (hContact != NULL) {
+ szProto=(char*)CallService(MS_PROTO_GETCONTACTBASEPROTO,(WPARAM)hContact,0);
+ if (szProto==NULL) break;
+ SetValue(hwndDlg,IDC_STREET,hContact,szProto,"Street",SVS_ZEROISUNSPEC);
+ SetValue(hwndDlg,IDC_CITY,hContact,szProto,"City",SVS_ZEROISUNSPEC);
+ SetValue(hwndDlg,IDC_STATE,hContact,szProto,"State",SVS_ZEROISUNSPEC);
+ SetValue(hwndDlg,IDC_ZIP,hContact,szProto,"ZIP",SVS_ZEROISUNSPEC);
+ SetValue(hwndDlg,IDC_COUNTRY,hContact,szProto,"Country",SVS_COUNTRY);
+ SetValue(hwndDlg,IDC_LANGUAGE1,hContact,szProto,"Language1",SVS_ZEROISUNSPEC);
+ SetValue(hwndDlg,IDC_LANGUAGE2,hContact,szProto,"Language2",SVS_ZEROISUNSPEC);
+ SetValue(hwndDlg,IDC_LANGUAGE3,hContact,szProto,"Language3",SVS_ZEROISUNSPEC);
+ SetValue(hwndDlg,IDC_TIMEZONE,hContact,szProto,"Timezone",SVS_TIMEZONE);
+ } }
+ break;
+ }
+ break;
+ case WM_COMMAND:
+ switch(LOWORD(wParam)) {
+ case IDCANCEL:
+ SendMessage(GetParent(hwndDlg),msg,wParam,lParam);
+ break;
+ }
+ break;
+ }
+ return FALSE;
+}
+
+static BOOL CALLBACK WorkDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ switch(msg) {
+ case WM_INITDIALOG:
+ TranslateDialogDefault(hwndDlg);
+ return TRUE;
+ case WM_NOTIFY:
+ switch (((LPNMHDR)lParam)->idFrom) {
+ case 0:
+ if (((LPNMHDR)lParam)->code == PSN_INFOCHANGED)
+ { char *szProto;
+ HANDLE hContact=(HANDLE)((LPPSHNOTIFY)lParam)->lParam;
+ if (hContact != NULL) {
+ szProto=(char*)CallService(MS_PROTO_GETCONTACTBASEPROTO,(WPARAM)hContact,0);
+ if (szProto==NULL) break;
+ SetValue(hwndDlg,IDC_COMPANY,hContact,szProto,"Company",SVS_ZEROISUNSPEC);
+ SetValue(hwndDlg,IDC_DEPARTMENT,hContact,szProto,"CompanyDepartment",SVS_ZEROISUNSPEC);
+ SetValue(hwndDlg,IDC_POSITION,hContact,szProto,"CompanyPosition",SVS_ZEROISUNSPEC);
+ SetValue(hwndDlg,IDC_STREET,hContact,szProto,"CompanyStreet",SVS_ZEROISUNSPEC);
+ SetValue(hwndDlg,IDC_CITY,hContact,szProto,"CompanyCity",SVS_ZEROISUNSPEC);
+ SetValue(hwndDlg,IDC_STATE,hContact,szProto,"CompanyState",SVS_ZEROISUNSPEC);
+ SetValue(hwndDlg,IDC_ZIP,hContact,szProto,"CompanyZIP",SVS_ZEROISUNSPEC);
+ SetValue(hwndDlg,IDC_COUNTRY,hContact,szProto,"CompanyCountry",SVS_COUNTRY);
+ SetValue(hwndDlg,IDC_WEBPAGE,hContact,szProto,"CompanyHomepage",SVS_ZEROISUNSPEC);
+ } }
+ break;
+ }
+ break;
+ case WM_COMMAND:
+ switch(LOWORD(wParam)) {
+ case IDCANCEL:
+ SendMessage(GetParent(hwndDlg),msg,wParam,lParam);
+ break;
+ case IDC_WEBPAGE:
+ if(IsWindowEnabled(GetDlgItem(hwndDlg,IDC_WEBPAGE))) {
+ char szPage[256];
+ GetDlgItemTextA(hwndDlg,IDC_WEBPAGE,szPage,SIZEOF(szPage));
+ CallService(MS_UTILS_OPENURL,1,(LPARAM)szPage);
+ }
+ break;
+ }
+ break;
+ }
+ return FALSE;
+}
+
+// Resizes all columns in a listview (report style)
+// to make all text visible
+void ResizeColumns(HWND hwndLV)
+{
+ int nCol = 0; LVCOLUMN lvCol;
+ lvCol.mask = LVCF_WIDTH;
+ while(ListView_GetColumn(hwndLV, nCol++, &lvCol))
+ ListView_SetColumnWidth(hwndLV, nCol-1, LVSCW_AUTOSIZE);
+}
+
+static BOOL CALLBACK BackgroundDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ switch(msg) {
+ case WM_INITDIALOG:
+ TranslateDialogDefault(hwndDlg);
+ { LVCOLUMN lvc;
+ RECT rc;
+ GetClientRect(GetDlgItem(hwndDlg,IDC_PAST),&rc);
+ rc.right-=GetSystemMetrics(SM_CXVSCROLL);
+ lvc.mask=LVCF_WIDTH;
+ lvc.cx=rc.right/3;
+ ListView_InsertColumn(GetDlgItem(hwndDlg,IDC_PAST),0,&lvc);
+ ListView_InsertColumn(GetDlgItem(hwndDlg,IDC_INTERESTS),0,&lvc);
+ lvc.cx=rc.right-rc.right/3;
+ ListView_InsertColumn(GetDlgItem(hwndDlg,IDC_PAST),1,&lvc);
+ ListView_InsertColumn(GetDlgItem(hwndDlg,IDC_INTERESTS),1,&lvc);
+ }
+ ListView_SetExtendedListViewStyleEx(GetDlgItem(hwndDlg,IDC_PAST),LVS_EX_LABELTIP,LVS_EX_LABELTIP);
+ ListView_SetExtendedListViewStyleEx(GetDlgItem(hwndDlg,IDC_INTERESTS),LVS_EX_LABELTIP,LVS_EX_LABELTIP);
+ return TRUE;
+ case WM_NOTIFY:
+ switch (((LPNMHDR)lParam)->idFrom) {
+ case 0:
+ if (((LPNMHDR)lParam)->code == PSN_INFOCHANGED)
+ { char *szProto;
+ LVITEM lvi;
+ int i;
+ char idstr[33];
+ DBVARIANT dbv,dbvText;
+ HANDLE hContact=(HANDLE)((LPPSHNOTIFY)lParam)->lParam;
+
+ if (hContact != NULL) {
+ szProto=(char*)CallService(MS_PROTO_GETCONTACTBASEPROTO,(WPARAM)hContact,0);
+ if (szProto==NULL) break;
+ SetValue(hwndDlg,IDC_WEBPAGE,hContact,szProto,"Homepage",SVS_ZEROISUNSPEC);
+
+ //past
+ ListView_DeleteAllItems(GetDlgItem(hwndDlg,IDC_PAST));
+ lvi.mask=LVIF_TEXT;
+ lvi.iSubItem=0;
+ lvi.iItem=0;
+ for(i=0;;i++) {
+ wsprintfA(idstr,"Past%d",i);
+ if(DBGetContactSettingTString(hContact,szProto,idstr,&dbv))
+ break;
+ wsprintfA(idstr,"Past%dText",i);
+ if(DBGetContactSettingTString(hContact,szProto,idstr,&dbvText))
+ {DBFreeVariant(&dbv); break;}
+ lvi.pszText=dbv.ptszVal;
+ ListView_InsertItem(GetDlgItem(hwndDlg,IDC_PAST),&lvi);
+ ListView_SetItemText(GetDlgItem(hwndDlg,IDC_PAST),lvi.iItem,1,dbvText.ptszVal);
+ DBFreeVariant(&dbvText);
+ DBFreeVariant(&dbv);
+ lvi.iItem++;
+ }
+
+ for(i=0;;i++) {
+ wsprintfA(idstr,"Affiliation%d",i);
+ if(DBGetContactSettingTString(hContact,szProto,idstr,&dbv))
+ break;
+ wsprintfA(idstr,"Affiliation%dText",i);
+ if(DBGetContactSettingTString(hContact,szProto,idstr,&dbvText))
+ {DBFreeVariant(&dbv); break;}
+ lvi.pszText=dbv.ptszVal;
+ ListView_InsertItem(GetDlgItem(hwndDlg,IDC_PAST),&lvi);
+ ListView_SetItemText(GetDlgItem(hwndDlg,IDC_PAST),lvi.iItem,1,dbvText.ptszVal);
+ DBFreeVariant(&dbvText);
+ DBFreeVariant(&dbv);
+ lvi.iItem++;
+ }
+
+ ResizeColumns(GetDlgItem(hwndDlg,IDC_PAST));
+
+ //interests
+ ListView_DeleteAllItems(GetDlgItem(hwndDlg,IDC_INTERESTS));
+ lvi.mask=LVIF_TEXT;
+ lvi.iSubItem=0;
+ lvi.iItem=0;
+ for(i=0;;i++) {
+ wsprintfA(idstr,"Interest%dCat",i);
+ if(DBGetContactSettingTString(hContact,szProto,idstr,&dbv))
+ break;
+ wsprintfA(idstr,"Interest%dText",i);
+ if(DBGetContactSettingTString(hContact,szProto,idstr,&dbvText))
+ {DBFreeVariant(&dbv); break;}
+ lvi.pszText=dbv.ptszVal;
+ ListView_InsertItem(GetDlgItem(hwndDlg,IDC_INTERESTS),&lvi);
+ ListView_SetItemText(GetDlgItem(hwndDlg,IDC_INTERESTS),lvi.iItem,1,dbvText.ptszVal);
+ DBFreeVariant(&dbvText);
+ DBFreeVariant(&dbv);
+ lvi.iItem++;
+ }
+ ResizeColumns(GetDlgItem(hwndDlg,IDC_INTERESTS));
+ } }
+ break;
+ }
+ break;
+ case WM_COMMAND:
+ switch(LOWORD(wParam)) {
+ case IDCANCEL:
+ SendMessage(GetParent(hwndDlg),msg,wParam,lParam);
+ break;
+ case IDC_WEBPAGE:
+ if(IsWindowEnabled(GetDlgItem(hwndDlg,IDC_WEBPAGE))) {
+ char szPage[256];
+ GetDlgItemTextA(hwndDlg,IDC_WEBPAGE,szPage,SIZEOF(szPage));
+ CallService(MS_UTILS_OPENURL,1,(LPARAM)szPage);
+ }
+ break;
+ }
+ break;
+ }
+ return FALSE;
+}
+
+static BOOL CALLBACK NotesDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ switch(msg) {
+ case WM_INITDIALOG:
+ TranslateDialogDefault(hwndDlg);
+ { DBVARIANT dbv;
+ if(!DBGetContactSetting((HANDLE)lParam,"UserInfo","MyNotes",&dbv)) {
+ SetDlgItemTextA(hwndDlg,IDC_MYNOTES,dbv.pszVal);
+ DBFreeVariant(&dbv);
+ }
+ }
+ SendDlgItemMessage(hwndDlg,IDC_MYNOTES,EM_LIMITTEXT,2048,0);
+ return TRUE;
+ case WM_NOTIFY:
+ switch (((LPNMHDR)lParam)->idFrom) {
+ case 0:
+ switch (((LPNMHDR)lParam)->code) {
+ case PSN_INFOCHANGED:
+ { char *szProto;
+ HANDLE hContact=(HANDLE)((LPPSHNOTIFY)lParam)->lParam;
+ if (hContact != NULL) {
+ szProto=(char*)CallService(MS_PROTO_GETCONTACTBASEPROTO,(WPARAM)hContact,0);
+ if (szProto==NULL) break;
+ SetValue(hwndDlg,IDC_ABOUT,hContact,szProto,"About",0);
+ }
+ break;
+ }
+ case PSN_APPLY:
+ { HANDLE hContact=(HANDLE)((LPPSHNOTIFY)lParam)->lParam;
+ if(GetWindowTextLength(GetDlgItem(hwndDlg,IDC_MYNOTES))) {
+ char text[2048];
+ GetDlgItemTextA(hwndDlg,IDC_MYNOTES,text,SIZEOF(text));
+ DBWriteContactSettingString(hContact,"UserInfo","MyNotes",text);
+ }
+ else DBDeleteContactSetting(hContact,"UserInfo","MyNotes");
+ break;
+ }
+ }
+ break;
+ }
+ break;
+ case WM_COMMAND:
+ if(wParam==MAKEWPARAM(IDC_MYNOTES,EN_CHANGE))
+ SendMessage(GetParent(hwndDlg),PSM_CHANGED,0,0);
+ else if(LOWORD(wParam)==IDCANCEL)
+ SendMessage(GetParent(hwndDlg),msg,wParam,lParam);
+ break;
+ }
+ return FALSE;
+}
+
+int DetailsInit(WPARAM wParam,LPARAM lParam)
+{
+ OPTIONSDIALOGPAGE odp;
+
+ if ((HANDLE)lParam == NULL)
+ return 0;
+
+ if ( CallService(MS_PROTO_GETCONTACTBASEPROTO, lParam, 0) == 0 )
+ return 0;
+
+ odp.cbSize = sizeof(odp);
+ odp.hIcon = NULL;
+ odp.hInstance = GetModuleHandle(NULL);
+ odp.flags = 0;
+
+ odp.pfnDlgProc = SummaryDlgProc;
+ odp.position = -2100000000;
+ odp.pszTemplate = MAKEINTRESOURCEA(IDD_INFO_SUMMARY);
+ odp.pszTitle = "Summary";
+ CallService(MS_USERINFO_ADDPAGE, wParam, ( LPARAM )&odp);
+
+ odp.pfnDlgProc = ContactDlgProc;
+ odp.position = -1800000000;
+ odp.pszTemplate = MAKEINTRESOURCEA(IDD_INFO_CONTACT);
+ odp.pszTitle = "Contact";
+ CallService(MS_USERINFO_ADDPAGE, wParam, ( LPARAM )&odp );
+
+ odp.pfnDlgProc = LocationDlgProc;
+ odp.position = -1500000000;
+ odp.pszTemplate = MAKEINTRESOURCEA(IDD_INFO_LOCATION);
+ odp.pszTitle = "Location";
+ CallService(MS_USERINFO_ADDPAGE, wParam, ( LPARAM )&odp);
+
+ odp.pfnDlgProc = WorkDlgProc;
+ odp.position = -1200000000;
+ odp.pszTemplate = MAKEINTRESOURCEA(IDD_INFO_WORK);
+ odp.pszTitle = "Work";
+ CallService(MS_USERINFO_ADDPAGE, wParam, ( LPARAM )&odp);
+
+ odp.pfnDlgProc = BackgroundDlgProc;
+ odp.position = -900000000;
+ odp.pszTemplate = MAKEINTRESOURCEA(IDD_INFO_BACKGROUND);
+ odp.pszTitle = "Background";
+ CallService(MS_USERINFO_ADDPAGE, wParam, ( LPARAM )&odp );
+
+ odp.pfnDlgProc = NotesDlgProc;
+ odp.position = 0;
+ odp.pszTemplate = MAKEINTRESOURCEA(IDD_INFO_NOTES);
+ odp.pszTitle = "Notes";
+ CallService(MS_USERINFO_ADDPAGE, wParam, ( LPARAM )&odp);
+ return 0;
+}
diff --git a/miranda-wine/src/modules/userinfo/userinfo.c b/miranda-wine/src/modules/userinfo/userinfo.c
new file mode 100644
index 0000000..1456c95
--- /dev/null
+++ b/miranda-wine/src/modules/userinfo/userinfo.c
@@ -0,0 +1,500 @@
+/*
+
+Miranda IM: the free IM client for Microsoft* Windows*
+
+Copyright 2000-2006 Miranda ICQ/IM project,
+all portions of this codebase are copyrighted to the people
+listed in contributors.txt.
+
+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.
+*/
+#include "commonheaders.h"
+#define UPDATEANIMFRAMES 20
+
+int DetailsInit(WPARAM wParam,LPARAM lParam);
+static BOOL CALLBACK DlgProcDetails(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
+static HANDLE hWindowList=NULL;
+static HANDLE hDetailsInitEvent;
+
+struct DetailsPageInit {
+ int pageCount;
+ OPTIONSDIALOGPAGE *odp;
+};
+
+struct DetailsPageData {
+ DLGTEMPLATE *pTemplate;
+ HINSTANCE hInst;
+ DLGPROC dlgProc;
+ HWND hwnd;
+ HTREEITEM hItem;
+ int changed;
+};
+
+struct DetailsData {
+ HANDLE hContact;
+ HANDLE hProtoAckEvent;
+ HINSTANCE hInstIcmp;
+ HFONT hBoldFont;
+ int pageCount;
+ int currentPage;
+ struct DetailsPageData *opd;
+ RECT rcDisplay;
+ int updateAnimFrame;
+ TCHAR szUpdating[64];
+ int *infosUpdated;
+};
+
+static int PageSortProc(OPTIONSDIALOGPAGE *item1,OPTIONSDIALOGPAGE *item2)
+{
+ if(item2->position>item1->position) return -1;
+ if(item2->position<item1->position) return 1;
+ return 0;
+}
+
+static int ShowDetailsDialogCommand(WPARAM wParam,LPARAM lParam)
+{
+ HWND hwnd;
+ PROPSHEETHEADER psh;
+ struct DetailsPageInit opi;
+ int i;
+
+ if(hwnd=WindowList_Find(hWindowList,(HANDLE)wParam)) {
+ SetForegroundWindow(hwnd);
+ SetFocus(hwnd);
+ return 0;
+ }
+
+ opi.pageCount=0;
+ opi.odp=NULL;
+ NotifyEventHooks(hDetailsInitEvent,(WPARAM)&opi,wParam);
+ if(opi.pageCount==0) return 0;
+ qsort(opi.odp,opi.pageCount,sizeof(OPTIONSDIALOGPAGE),(int (*)(const void*,const void*))PageSortProc);
+
+ ZeroMemory(&psh,sizeof(psh));
+ psh.dwSize = sizeof(psh);
+ psh.dwFlags = PSH_PROPSHEETPAGE|PSH_NOAPPLYNOW;
+ psh.hwndParent = NULL;
+ psh.nPages = opi.pageCount;
+ psh.pStartPage = 0;
+ psh.pszCaption = (TCHAR*)wParam; //more abuses of structure: this is hContact
+ psh.ppsp = (PROPSHEETPAGE*)opi.odp; //blatent misuse of the structure, but what the hell
+ CreateDialogParam(GetModuleHandle(NULL),MAKEINTRESOURCE(IDD_DETAILS),NULL,DlgProcDetails,(LPARAM)&psh);
+ for(i=0;i<opi.pageCount;i++) {
+ mir_free((char*)opi.odp[i].pszTitle);
+ if(opi.odp[i].pszGroup!=NULL) mir_free(opi.odp[i].pszGroup);
+ if((DWORD)opi.odp[i].pszTemplate&0xFFFF0000) mir_free((char*)opi.odp[i].pszTemplate);
+ }
+ mir_free(opi.odp);
+ return 0;
+}
+
+static int AddDetailsPage(WPARAM wParam,LPARAM lParam)
+{
+ OPTIONSDIALOGPAGE *odp=(OPTIONSDIALOGPAGE*)lParam, *dst;
+ struct DetailsPageInit *opi=(struct DetailsPageInit*)wParam;
+
+ if(odp==NULL||opi==NULL) return 1;
+ if(odp->cbSize!=sizeof(OPTIONSDIALOGPAGE)) return 1;
+ opi->odp=(OPTIONSDIALOGPAGE*)mir_realloc(opi->odp,sizeof(OPTIONSDIALOGPAGE)*(opi->pageCount+1));
+ dst = opi->odp + opi->pageCount;
+ dst->cbSize = sizeof(OPTIONSDIALOGPAGE);
+ dst->hInstance = odp->hInstance;
+ dst->pfnDlgProc = odp->pfnDlgProc;
+ dst->position = odp->position;
+ if((DWORD)odp->pszTemplate&0xFFFF0000) dst->pszTemplate = mir_strdup(odp->pszTemplate);
+ else dst->pszTemplate = odp->pszTemplate;
+
+ #if defined(_UNICODE)
+ if ( odp->flags == ODPF_UNICODE )
+ dst->ptszTitle = (odp->ptszTitle==0) ? NULL : mir_wstrdup(odp->ptszTitle);
+ else
+ #endif
+ dst->ptszTitle = (odp->pszTitle==0) ? NULL : LangPackPcharToTchar(odp->pszTitle);
+
+ dst->pszGroup = NULL;
+ dst->groupPosition = odp->groupPosition;
+ dst->hGroupIcon = odp->hGroupIcon;
+ dst->hIcon = odp->hIcon;
+ opi->pageCount++;
+ return 0;
+}
+
+static int UserInfoContactDelete(WPARAM wParam,LPARAM lParam)
+{
+ HWND hwnd;
+ hwnd=WindowList_Find(hWindowList,(HANDLE)wParam);
+ if(hwnd!=NULL) DestroyWindow(hwnd);
+ return 0;
+}
+
+static void ThemeDialogBackground(HWND hwnd) {
+ if (IsWinVerXPPlus()) {
+ static HMODULE hThemeAPI = NULL;
+ if (!hThemeAPI) hThemeAPI = GetModuleHandleA("uxtheme");
+ if (hThemeAPI) {
+ HRESULT (STDAPICALLTYPE *MyEnableThemeDialogTexture)(HWND,DWORD) = (HRESULT (STDAPICALLTYPE*)(HWND,DWORD))GetProcAddress(hThemeAPI,"EnableThemeDialogTexture");
+ if (MyEnableThemeDialogTexture)
+ MyEnableThemeDialogTexture(hwnd,0x00000002|0x00000004); //0x00000002|0x00000004=ETDT_ENABLETAB
+ }
+ }
+}
+
+#define HM_PROTOACK (WM_USER+10)
+#define M_CHECKONLINE (WM_USER+11)
+static BOOL CALLBACK DlgProcDetails(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ struct DetailsData *dat =(struct DetailsData*)GetWindowLong(hwndDlg,GWL_USERDATA);
+ switch (msg)
+ {
+ case WM_INITDIALOG:
+ { PROPSHEETHEADER *psh=(PROPSHEETHEADER*)lParam;
+ TranslateDialogDefault(hwndDlg);
+ SendMessage(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_USERDETAILS)));
+ dat=(struct DetailsData*)mir_alloc(sizeof(struct DetailsData));
+ SetWindowLong(hwndDlg, GWL_USERDATA, (LONG)dat);
+ dat->hContact=(HANDLE)psh->pszCaption;
+ dat->hProtoAckEvent=HookEventMessage(ME_PROTO_ACK,hwndDlg,HM_PROTOACK);
+ dat->infosUpdated=NULL;
+ WindowList_Add(hWindowList,hwndDlg,dat->hContact);
+ {
+ TCHAR *name, oldTitle[256], newTitle[256];
+ if (dat->hContact == NULL)
+ name = TranslateT("Owner");
+ else
+ name = ( TCHAR* )CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)dat->hContact, GCDNF_TCHAR);
+
+ GetWindowText( hwndDlg, oldTitle, SIZEOF( oldTitle ));
+ mir_sntprintf( newTitle, SIZEOF(newTitle), oldTitle, name );
+ SetWindowText( hwndDlg, newTitle );
+ SetDlgItemText( hwndDlg, IDC_NAME, name );
+ }
+ { LOGFONT lf;
+ HFONT hNormalFont=(HFONT)SendDlgItemMessage(hwndDlg,IDC_NAME,WM_GETFONT,0,0);
+ GetObject(hNormalFont,sizeof(lf),&lf);
+ lf.lfWeight=FW_BOLD;
+ dat->hBoldFont=CreateFontIndirect(&lf);
+ SendDlgItemMessage(hwndDlg,IDC_NAME,WM_SETFONT,(WPARAM)dat->hBoldFont,0);
+ }
+ { OPTIONSDIALOGPAGE *odp;
+ int i;
+ TVINSERTSTRUCT tvis;
+ DBVARIANT dbv;
+
+ dat->currentPage=0;
+ if(DBGetContactSettingTString(NULL,"UserInfo","LastTab",&dbv))
+ dbv.type=DBVT_DELETED;
+ dat->pageCount=psh->nPages;
+ dat->opd=(struct DetailsPageData*)mir_alloc(sizeof(struct DetailsPageData)*dat->pageCount);
+ odp=(OPTIONSDIALOGPAGE*)psh->ppsp;
+
+ for(i=0;i<dat->pageCount;i++) {
+ dat->opd[i].pTemplate=(DLGTEMPLATE *)LockResource(LoadResource(odp[i].hInstance,FindResourceA(odp[i].hInstance,odp[i].pszTemplate,MAKEINTRESOURCEA(5))));
+ dat->opd[i].dlgProc=odp[i].pfnDlgProc;
+ dat->opd[i].hInst=odp[i].hInstance;
+ dat->opd[i].hwnd=NULL;
+ dat->opd[i].changed=0;
+ tvis.hParent = NULL;
+ tvis.hInsertAfter = TVI_LAST;
+ tvis.item.mask = TVIF_TEXT | TVIF_PARAM;
+ tvis.item.lParam = (LPARAM) i;
+ tvis.item.pszText = odp[i].ptszTitle;
+ if(dbv.type!=DBVT_DELETED && !lstrcmp(tvis.item.pszText,dbv.ptszVal))
+ dat->currentPage=i;
+ dat->opd[i].hItem = TreeView_InsertItem(GetDlgItem(hwndDlg, IDC_PAGETREE), &tvis);
+ }
+ DBFreeVariant(&dbv);
+ }
+
+ GetWindowRect(GetDlgItem(hwndDlg,IDC_TABS),&dat->rcDisplay);
+ TabCtrl_AdjustRect(GetDlgItem(hwndDlg,IDC_TABS),FALSE,&dat->rcDisplay);
+ { POINT pt={0,0};
+ ClientToScreen(hwndDlg,&pt);
+ OffsetRect(&dat->rcDisplay,-pt.x,-pt.y);
+ }
+ TreeView_Select(GetDlgItem(hwndDlg,IDC_PAGETREE), dat->opd[dat->currentPage].hItem, TVGN_CARET);
+ dat->opd[dat->currentPage].hwnd=CreateDialogIndirectParam(dat->opd[dat->currentPage].hInst,dat->opd[dat->currentPage].pTemplate,hwndDlg,dat->opd[dat->currentPage].dlgProc,(LPARAM)dat->hContact);
+ ThemeDialogBackground(dat->opd[dat->currentPage].hwnd);
+ SetWindowPos(dat->opd[dat->currentPage].hwnd, HWND_TOP, dat->rcDisplay.left, dat->rcDisplay.top, dat->rcDisplay.right - dat->rcDisplay.left, dat->rcDisplay.bottom - dat->rcDisplay.top, 0);
+ { PSHNOTIFY pshn;
+ pshn.hdr.code=PSN_INFOCHANGED;
+ pshn.hdr.hwndFrom=dat->opd[dat->currentPage].hwnd;
+ pshn.hdr.idFrom=0;
+ pshn.lParam=(LPARAM)dat->hContact;
+ SendMessage(dat->opd[dat->currentPage].hwnd,WM_NOTIFY,0,(LPARAM)&pshn);
+ }
+ ShowWindow(dat->opd[dat->currentPage].hwnd,SW_SHOW);
+ dat->updateAnimFrame=0;
+ GetDlgItemText(hwndDlg,IDC_UPDATING,dat->szUpdating,SIZEOF(dat->szUpdating));
+ SendMessage(hwndDlg,M_CHECKONLINE,0,0);
+ if(!IsWindowEnabled(GetDlgItem(hwndDlg,IDC_UPDATE)))
+ ShowWindow(GetDlgItem(hwndDlg,IDC_UPDATING),SW_HIDE);
+ else {
+ EnableWindow(GetDlgItem(hwndDlg,IDC_UPDATE),FALSE);
+ SetTimer(hwndDlg,1,100,NULL);
+ }
+ CallContactService(dat->hContact,PSS_GETINFO,SGIF_ONOPEN,0);
+ return TRUE;
+ }
+ case WM_TIMER:
+ { TCHAR str[128];
+ mir_sntprintf(str,SIZEOF(str), _T("%.*s%s%.*s"),dat->updateAnimFrame%10,_T("........."),dat->szUpdating,dat->updateAnimFrame%10,_T("........."));
+ SetDlgItemText(hwndDlg,IDC_UPDATING,str);
+ if(++dat->updateAnimFrame==UPDATEANIMFRAMES) dat->updateAnimFrame=0;
+ break;
+ }
+ case WM_CTLCOLORSTATIC:
+ switch (GetDlgCtrlID((HWND)lParam)) {
+ case IDC_WHITERECT:
+ case IDC_LOGO:
+ SetBkColor((HDC)wParam,RGB(255,255,255));
+ return (BOOL)GetStockObject(WHITE_BRUSH);
+
+ case IDC_UPDATING:
+ {
+ COLORREF textCol,bgCol,newCol;
+ int ratio;
+ textCol=GetSysColor(COLOR_BTNTEXT);
+ bgCol=GetSysColor(COLOR_3DFACE);
+ ratio=abs(UPDATEANIMFRAMES/2-dat->updateAnimFrame)*510/UPDATEANIMFRAMES;
+ newCol=RGB(GetRValue(bgCol)+(GetRValue(textCol)-GetRValue(bgCol))*ratio/256,
+ GetGValue(bgCol)+(GetGValue(textCol)-GetGValue(bgCol))*ratio/256,
+ GetBValue(bgCol)+(GetBValue(textCol)-GetBValue(bgCol))*ratio/256);
+ SetTextColor((HDC)wParam,newCol);
+ SetBkColor((HDC)wParam,GetSysColor(COLOR_3DFACE));
+ return (BOOL)GetSysColorBrush(COLOR_3DFACE);
+ }
+ default:
+ SetBkMode((HDC)wParam,TRANSPARENT);
+ return (BOOL)GetStockObject(NULL_BRUSH);
+ }
+ break;
+ case PSM_CHANGED:
+ dat->opd[dat->currentPage].changed=1;
+ return TRUE;
+ case PSM_FORCECHANGED:
+ { PSHNOTIFY pshn;
+ int i;
+
+ pshn.hdr.code=PSN_INFOCHANGED;
+ pshn.hdr.idFrom=0;
+ pshn.lParam=(LPARAM)dat->hContact;
+ for(i=0;i<dat->pageCount;i++) {
+ pshn.hdr.hwndFrom=dat->opd[i].hwnd;
+ if(dat->opd[i].hwnd!=NULL)
+ SendMessage(dat->opd[i].hwnd,WM_NOTIFY,0,(LPARAM)&pshn);
+ }
+ break;
+ }
+ case M_CHECKONLINE:
+ {
+ char *szProto;
+ if (dat->hContact != NULL) {
+ szProto=(char*)CallService(MS_PROTO_GETCONTACTBASEPROTO,(WPARAM)dat->hContact,0);
+ if(szProto==NULL) {EnableWindow(GetDlgItem(hwndDlg,IDC_UPDATE),FALSE); break;}
+ if(CallProtoService(szProto,PS_GETSTATUS,0,0)<ID_STATUS_ONLINE) EnableWindow(GetDlgItem(hwndDlg,IDC_UPDATE),FALSE);
+ else EnableWindow(GetDlgItem(hwndDlg,IDC_UPDATE),!IsWindowVisible(GetDlgItem(hwndDlg,IDC_UPDATING)));
+ }
+ break;
+ }
+ case HM_PROTOACK:
+ { ACKDATA *ack=(ACKDATA*)lParam;
+ int i;
+
+ if(ack->hContact==NULL && ack->type==ACKTYPE_STATUS) {
+ SendMessage(hwndDlg,M_CHECKONLINE,0,0);
+ break;
+ }
+ if(ack->hContact!=dat->hContact) break;
+ if(ack->type!=ACKTYPE_GETINFO) break;
+ SendMessage(hwndDlg,PSM_FORCECHANGED,0,0);
+ /* if they're not gonna send any more ACK's don't let that mean we should crash */
+ if (!ack->hProcess && !ack->lParam) {
+ ShowWindow(GetDlgItem(hwndDlg,IDC_UPDATING),SW_HIDE);
+ KillTimer(hwndDlg,1);
+ SendMessage(hwndDlg,M_CHECKONLINE,0,0);
+ break;
+ } //if
+ if(dat->infosUpdated==NULL) dat->infosUpdated=(int*)mir_calloc(sizeof(int)*(int)ack->hProcess);
+ if(ack->result==ACKRESULT_SUCCESS || ack->result==ACKRESULT_FAILED) dat->infosUpdated[ack->lParam]=1;
+ for(i=0;i<(int)ack->hProcess;i++)
+ if(dat->infosUpdated[i]==0) break;
+ if(i==(int)ack->hProcess) {
+ ShowWindow(GetDlgItem(hwndDlg,IDC_UPDATING),SW_HIDE);
+ KillTimer(hwndDlg,1);
+ SendMessage(hwndDlg,M_CHECKONLINE,0,0);
+ }
+ break;
+ }
+ case WM_NOTIFY:
+ switch(wParam) {
+ case IDC_PAGETREE:
+ switch(((LPNMHDR)lParam)->code) {
+ case TVN_SELCHANGING:
+ { PSHNOTIFY pshn;
+ if(dat->currentPage==-1 || dat->opd[dat->currentPage].hwnd==NULL) break;
+ pshn.hdr.code=PSN_KILLACTIVE;
+ pshn.hdr.hwndFrom=dat->opd[dat->currentPage].hwnd;
+ pshn.hdr.idFrom=0;
+ pshn.lParam=(LPARAM)dat->hContact;
+ if(SendMessage(dat->opd[dat->currentPage].hwnd,WM_NOTIFY,0,(LPARAM)&pshn)) {
+ SetWindowLong(hwndDlg,DWL_MSGRESULT,TRUE);
+ return TRUE;
+ }
+ break;
+ }
+ case TVN_SELCHANGED:
+ if(dat->currentPage!=-1 && dat->opd[dat->currentPage].hwnd!=NULL) {
+ ShowWindow(dat->opd[dat->currentPage].hwnd,SW_HIDE);
+ {
+ LPNMTREEVIEW pnmtv = (LPNMTREEVIEW) lParam;
+ TVITEM tvi = pnmtv->itemNew;
+ dat->currentPage=tvi.lParam;
+ }
+ if(dat->currentPage!=-1) {
+ if(dat->opd[dat->currentPage].hwnd==NULL) {
+ PSHNOTIFY pshn;
+ dat->opd[dat->currentPage].hwnd=CreateDialogIndirectParam(dat->opd[dat->currentPage].hInst,dat->opd[dat->currentPage].pTemplate,hwndDlg,dat->opd[dat->currentPage].dlgProc,(LPARAM)dat->hContact);
+ ThemeDialogBackground(dat->opd[dat->currentPage].hwnd);
+ SetWindowPos(dat->opd[dat->currentPage].hwnd, HWND_TOP, dat->rcDisplay.left, dat->rcDisplay.top, dat->rcDisplay.right - dat->rcDisplay.left, dat->rcDisplay.bottom - dat->rcDisplay.top, 0);
+ pshn.hdr.code=PSN_INFOCHANGED;
+ pshn.hdr.hwndFrom=dat->opd[dat->currentPage].hwnd;
+ pshn.hdr.idFrom=0;
+ pshn.lParam=(LPARAM)dat->hContact;
+ SendMessage(dat->opd[dat->currentPage].hwnd,WM_NOTIFY,0,(LPARAM)&pshn);
+ }
+ ShowWindow(dat->opd[dat->currentPage].hwnd,SW_SHOW);
+ SetFocus(GetDlgItem(hwndDlg,IDC_PAGETREE));
+ }
+ }
+ break;
+ }
+ break;
+ }
+ break;
+ case WM_COMMAND:
+ switch(LOWORD(wParam)) {
+ case IDCANCEL:
+ { int i;
+ PSHNOTIFY pshn;
+ pshn.hdr.idFrom=0;
+ pshn.lParam=(LPARAM)dat->hContact;
+ pshn.hdr.code=PSN_RESET;
+ for(i=0;i<dat->pageCount;i++) {
+ if(dat->opd[i].hwnd==NULL || !dat->opd[i].changed) continue;
+ pshn.hdr.hwndFrom=dat->opd[i].hwnd;
+ SendMessage(dat->opd[i].hwnd,WM_NOTIFY,0,(LPARAM)&pshn);
+ }
+ DestroyWindow(hwndDlg);
+ break;
+ }
+ case IDOK:
+ { int i;
+ PSHNOTIFY pshn;
+ pshn.hdr.idFrom=0;
+ pshn.lParam=(LPARAM)dat->hContact;
+ if(dat->currentPage!=-1) {
+ pshn.hdr.code=PSN_KILLACTIVE;
+ pshn.hdr.hwndFrom=dat->opd[dat->currentPage].hwnd;
+ if(SendMessage(dat->opd[dat->currentPage].hwnd,WM_NOTIFY,0,(LPARAM)&pshn))
+ break;
+ }
+
+ pshn.hdr.code=PSN_APPLY;
+ for(i=0;i<dat->pageCount;i++) {
+ if(dat->opd[i].hwnd==NULL || !dat->opd[i].changed) continue;
+ pshn.hdr.hwndFrom=dat->opd[i].hwnd;
+ if(SendMessage(dat->opd[i].hwnd,WM_NOTIFY,0,(LPARAM)&pshn)==PSNRET_INVALID_NOCHANGEPAGE) {
+ TreeView_Select(GetDlgItem(hwndDlg,IDC_PAGETREE), dat->opd[i].hItem, TVGN_CARET);
+ if(dat->currentPage!=-1) ShowWindow(dat->opd[dat->currentPage].hwnd,SW_HIDE);
+ dat->currentPage=i;
+ ShowWindow(dat->opd[dat->currentPage].hwnd,SW_SHOW);
+ return 0;
+ }
+ }
+ DestroyWindow(hwndDlg);
+ break;
+ }
+ case IDC_UPDATE:
+ if(dat->infosUpdated!=NULL) {mir_free(dat->infosUpdated); dat->infosUpdated=NULL;}
+ if(dat->hContact != NULL) {
+ CallContactService(dat->hContact,PSS_GETINFO,0,0);
+ EnableWindow(GetDlgItem(hwndDlg,IDC_UPDATE),FALSE);
+ ShowWindow(GetDlgItem(hwndDlg,IDC_UPDATING),SW_SHOW);
+ SetTimer(hwndDlg,1,100,NULL);
+ }
+ break;
+ }
+ break;
+ case WM_CLOSE:
+ SendMessage(hwndDlg,WM_COMMAND,MAKEWPARAM(IDOK,BN_CLICKED),(LPARAM)GetDlgItem(hwndDlg,IDOK));
+ break;
+ case WM_DESTROY:
+ {
+ TCHAR name[128];
+ TVITEM tvi;
+ tvi.mask = TVIF_TEXT;
+ tvi.hItem = dat->opd[dat->currentPage].hItem;
+ tvi.pszText=name;
+ tvi.cchTextMax=SIZEOF(name);
+ TreeView_GetItem(GetDlgItem(hwndDlg, IDC_PAGETREE), &tvi);
+ DBWriteContactSettingTString(NULL,"UserInfo","LastTab", name);
+ }
+ SendDlgItemMessage(hwndDlg,IDC_NAME,WM_SETFONT,SendDlgItemMessage(hwndDlg,IDC_WHITERECT,WM_GETFONT,0,0),0);
+ DeleteObject(dat->hBoldFont);
+ WindowList_Remove(hWindowList,hwndDlg);
+ UnhookEvent(dat->hProtoAckEvent);
+ { int i;
+ for(i=0;i<dat->pageCount;i++)
+ if(dat->opd[i].hwnd!=NULL) DestroyWindow(dat->opd[i].hwnd);
+ }
+ if(dat->infosUpdated!=NULL) mir_free(dat->infosUpdated);
+ mir_free(dat->opd);
+ mir_free(dat);
+ break;
+ }
+ return FALSE;
+}
+
+int ShutdownUserInfo(WPARAM wParam,LPARAM lParam)
+{
+ WindowList_BroadcastAsync(hWindowList,WM_DESTROY,0,0);
+ return 0;
+}
+
+int LoadUserInfoModule(void)
+{
+ CLISTMENUITEM mi;
+
+ CreateServiceFunction(MS_USERINFO_SHOWDIALOG,ShowDetailsDialogCommand);
+ hDetailsInitEvent=CreateHookableEvent(ME_USERINFO_INITIALISE);
+ HookEvent(ME_USERINFO_INITIALISE,DetailsInit);
+ HookEvent(ME_DB_CONTACT_DELETED,UserInfoContactDelete);
+ HookEvent(ME_SYSTEM_PRESHUTDOWN,ShutdownUserInfo);
+ CreateServiceFunction(MS_USERINFO_ADDPAGE,AddDetailsPage);
+ ZeroMemory(&mi,sizeof(mi));
+ mi.cbSize=sizeof(mi);
+ mi.position=1000050000;
+ mi.flags=0;
+ mi.hIcon=LoadIcon(GetModuleHandle(NULL),MAKEINTRESOURCE(IDI_USERDETAILS));
+ mi.pszContactOwner=NULL;
+ mi.pszName=Translate("User &Details");
+ mi.pszService=MS_USERINFO_SHOWDIALOG;
+ CallService(MS_CLIST_ADDCONTACTMENUITEM,0,(LPARAM)&mi);
+ mi.position=500050000;
+ mi.pszName=Translate("View/Change My &Details...");
+ CallService(MS_CLIST_ADDMAINMENUITEM,0,(LPARAM)&mi);
+ hWindowList=(HANDLE)CallService(MS_UTILS_ALLOCWINDOWLIST,0,0);
+ return 0;
+}