From bd39a0d0ea64bec7b0025d80adb2d1ee8357bea6 Mon Sep 17 00:00:00 2001 From: sje Date: Fri, 16 Feb 2007 03:26:31 +0000 Subject: fix folders implementation show user fingerprints in options git-svn-id: https://server.scottellis.com.au/svn/mim_plugs@122 4f64403b-2f21-0410-a795-97e2b3489a10 --- otr/options.cpp | 41 ++++++++++++++++++++++++++++++++++++++--- 1 file changed, 38 insertions(+), 3 deletions(-) (limited to 'otr/options.cpp') diff --git a/otr/options.cpp b/otr/options.cpp index d94afa0..650da18 100644 --- a/otr/options.cpp +++ b/otr/options.cpp @@ -9,6 +9,9 @@ Options options; #include typedef std::map ContactPolicyMap; +typedef std::map ContactFingerprintMap; + +HANDLE hFolderPath = 0; void SetFilenames(const char *path) { strcpy(fingerprint_store_filename, path); @@ -38,7 +41,7 @@ int FoldersChanged(WPARAM wParam, LPARAM lParam) { fgd.nMaxPathSize = sizeof(path); fgd.szPath = path; - CallService(MS_FOLDERS_GET_PATH, 0, (LPARAM)&fgd); + CallService(MS_FOLDERS_GET_PATH, (LPARAM)hFolderPath, (LPARAM)&fgd); SetFilenames(path); ReadPrivkeyFiles(); @@ -54,7 +57,7 @@ void LoadFilenames() { strncpy(fd.szName, "Private Data", FOLDERS_NAME_MAX_SIZE); fd.szFormat = PROFILE_PATH "\\OTR_data"; - CallService(MS_FOLDERS_REGISTER_PATH, 0, (LPARAM)&fd); + hFolderPath = (HANDLE)CallService(MS_FOLDERS_REGISTER_PATH, 0, (LPARAM)&fd); HookEvent(ME_FOLDERS_PATH_CHANGED, FoldersChanged); // get the path - above are only defaults - there may be a different value in the db @@ -126,6 +129,7 @@ void SaveOptions(ContactPolicyMap *contact_policies) { DBWriteContactSettingByte(0, MODULE, "DeleteHistory", options.delete_history ? 1 : 0); } +ContactFingerprintMap strlist; // temp storage for fingerprint string pointers INT_PTR CALLBACK DlgProcOpts1(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { switch ( msg ) { @@ -199,8 +203,13 @@ INT_PTR CALLBACK DlgProcOpts1(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPar lvc.iSubItem = 2; lvc.pszText = Translate("Policy"); - lvc.cx = 100; // width of column in pixels + lvc.cx = 130; // width of column in pixels ListView_InsertColumn(GetDlgItem(hwndDlg, IDC_CLIST), 2, &lvc); + + lvc.iSubItem = 3; + lvc.pszText = Translate("Fingerprint"); + lvc.cx = 300; // width of column in pixels + ListView_InsertColumn(GetDlgItem(hwndDlg, IDC_CLIST), 3, &lvc); } SendMessage(hwndDlg, WMU_REFRESHLIST, 0, 0); @@ -258,8 +267,19 @@ INT_PTR CALLBACK DlgProcOpts1(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPar lvI.iSubItem = 2; lvI.pszText = LPSTR_TEXTCALLBACK; ListView_SetItem(GetDlgItem(hwndDlg, IDC_CLIST), &lvI); + + lvI.iSubItem = 3; + lvI.pszText = LPSTR_TEXTCALLBACK; + ListView_SetItem(GetDlgItem(hwndDlg, IDC_CLIST), &lvI); + + // fill fingerprint map + if(strlist.find(hContact) != strlist.end()) free(strlist[hContact]); + char fp[45]; + if(GetFingerprint(hContact, fp)) + strlist[hContact] = strdup(fp); } + hContact = ( HANDLE )CallService( MS_DB_CONTACT_FINDNEXT,( WPARAM )hContact, 0 ); } } @@ -376,6 +396,8 @@ INT_PTR CALLBACK DlgProcOpts1(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPar ListView_RedrawItems(GetDlgItem(hwndDlg, IDC_CLIST), lvi.iItem, lvi.iItem); SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 ); + } else if(((LPNMLISTVIEW)lParam)->iSubItem == 3) { + // forget fingerprint? } break; case LVN_GETDISPINFO: @@ -426,7 +448,17 @@ INT_PTR CALLBACK DlgProcOpts1(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPar } break; + case 3: + { + HANDLE hContact = (HANDLE)lvi.lParam; + if(strlist.find(hContact) != strlist.end()) + ((NMLVDISPINFO *)lParam)->item.pszText = strlist[hContact]; + else + ((NMLVDISPINFO *)lParam)->item.pszText = Translate("None"); + } + break; } + } break; } @@ -459,6 +491,9 @@ INT_PTR CALLBACK DlgProcOpts1(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPar ContactPolicyMap *contact_policies = (ContactPolicyMap *)GetWindowLong(hwndDlg, GWL_USERDATA); SetWindowLong(hwndDlg, GWL_USERDATA, 0); delete contact_policies; + + for(std::map::iterator i = strlist.begin(); i != strlist.end(); i++) + free(i->second); } } -- cgit v1.2.3