summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rwxr-xr-xplugins/Msg_Export/src/options.cpp1252
1 files changed, 505 insertions, 747 deletions
diff --git a/plugins/Msg_Export/src/options.cpp b/plugins/Msg_Export/src/options.cpp
index a6d3dc35f3..d5254f8303 100755
--- a/plugins/Msg_Export/src/options.cpp
+++ b/plugins/Msg_Export/src/options.cpp
@@ -1,4 +1,4 @@
-/////////////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////////////////////////
// This file is part of Msg_Export a Miranda IM plugin
// Copyright (C)2002 Kennet Nielsen ( http://sourceforge.net/projects/msg-export/ )
//
@@ -18,23 +18,10 @@
#include "stdafx.h"
-#define STRINGIZE(x) #x
-#define EVAL_STRINGIZE(x) STRINGIZE(x)
-#define __LOC__ __FILE__ "("EVAL_STRINGIZE(__LINE__)") : "
-
-// width in pixels of the UIN column in the List Ctrl
-const int nUINColWitdh = 80;
-// width in pixels of the UIN column in the List Ctrl
-const int nProtoColWitdh = 100;
-
-
-// Used to controle the sending of the PSM_CHANGED to miranda
-// and to se if the user has unapplyed changes when he presses the
-// Export All button
-BOOL bUnaplyedChanges = FALSE;
-
+const int nUINColWitdh = 80; // width in pixels of the UIN column in the List Ctrl
+const int nProtoColWitdh = 100; // width in pixels of the UIN column in the List Ctrl
-/////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////
// Class : CLDBEvent
// Superclass :
// Project : Mes_export
@@ -49,9 +36,7 @@ BOOL bUnaplyedChanges = FALSE;
// Version History:
// Ver: Initials: Date: Text:
// 1.0.0 KN 020422 First edition
-//
-/////////////////////////////////////////////////////////////////////
-//
+
class CLDBEvent
{
DWORD time;
@@ -74,7 +59,7 @@ public:
}
};
-/////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////
// Member Function : CompareFunc
// Type : Global
// Parameters : lParam1 - ?
@@ -87,8 +72,7 @@ public:
// Remarks : -
// Created : 020422, 22 April 2002
// Developer : KN
-/////////////////////////////////////////////////////////////////////
-//
+
int CALLBACK CompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort)
{
if (lParamSort == 1)
@@ -107,7 +91,7 @@ int CALLBACK CompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort)
return 0;
}
-/////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////
// Member Function : DialogProc
// Type : Global
// Parameters : hwndDlg - handle to dialog box
@@ -121,8 +105,7 @@ int CALLBACK CompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort)
// Remarks : -
// Created : 020422, 22 April 2002
// Developer : KN
-/////////////////////////////////////////////////////////////////////
-//
+
INT_PTR CALLBACK __stdcall DialogProc(HWND hwndDlg, UINT uMsg, WPARAM, LPARAM lParam)
{
switch (uMsg) {
@@ -228,802 +211,581 @@ void __cdecl exportContactsMessages(ExportDialogData *data)
SendMessage(hDlg, WM_CLOSE, 0, 1);
}
-/////////////////////////////////////////////////////////////////////
-// Member Function : nExportCompleatList
-// Type : Global
-// Parameters : hParent - handle to the parrent, ( Options Dlg )
-// bOnlySelected - Only Export the userges that hase been selected in the list view
-// Returns : int not used currently
-// Description :
-//
-// References : -
-// Remarks : -
-// Created : 020422, 22 April 2002
-// Developer : KN
-/////////////////////////////////////////////////////////////////////
-//
-int nExportCompleatList(HWND hParent, bool bOnlySelected)
-{
- HWND hMapUser = GetDlgItem(hParent, IDC_MAP_USER_LIST);
+/////////////////////////////////////////////////////////////////////////////////////////
+// CBasicOptDlg : basic options dialog
- int nTotalContacts = ListView_GetItemCount(hMapUser);
+class CBasicOptDlg : public CDlgBase
+{
+ CCtrlButton btnExportAll, btnExportSel, btnUserDetails, btnAutoFileName, btnClearAll, btnSetDefault;
+ CCtrlButton btnBrowseDir, btnBrowseFile;
+ CCtrlListView listUsers;
+ CCtrlHyperlink urlHelp;
- int nContacts;
- if (bOnlySelected)
- nContacts = ListView_GetSelectedCount(hMapUser);
- else
- nContacts = nTotalContacts;
+ bool bUnapplyedChanges = false;
- if (!hMapUser || nContacts <= 0) {
- MessageBox(hParent, TranslateT("No contacts found to export"), MSG_BOX_TITEL, MB_OK);
- return 0;
+public:
+ CBasicOptDlg() :
+ CDlgBase(g_plugin, IDD_OPT_MSGEXPORT),
+ urlHelp(this, IDC_OPEN_HELP, "https://miranda-ng.org/p/Msg_Export/"),
+ listUsers(this, IDC_MAP_USER_LIST),
+ btnClearAll(this, IDC_CLEAR_ALL),
+ btnExportAll(this, IDC_EXPORTALL),
+ btnExportSel(this, ID_EXPORTSELECTED),
+ btnBrowseDir(this, IDC_EXPORT_DIR_BROWSE),
+ btnBrowseFile(this, IDC_FILE_VIEWER_BROWSE),
+ btnSetDefault(this, ID_SET_TO_DEFAULT),
+ btnUserDetails(this, ID_USERLIST_USERDETAILS),
+ btnAutoFileName(this, IDC_AUTO_FILENAME)
+ {
+ listUsers.OnKeyDown = Callback(this, &CBasicOptDlg::list_KeyDown);
+ listUsers.OnBuildMenu = Callback(this, &CBasicOptDlg::list_OnMenu);
+ listUsers.OnColumnClick = Callback(this, &CBasicOptDlg::list_ColumnClick);
+ listUsers.OnDoubleClick = Callback(this, &CBasicOptDlg::list_DoubleClick);
+ listUsers.OnEndLabelEdit = Callback(this, &CBasicOptDlg::list_LabelEdit);
+
+ btnClearAll.OnClick = Callback(this, &CBasicOptDlg::onClick_ClearAll);
+ btnExportAll.OnClick = btnExportSel.OnClick = Callback(this, &CBasicOptDlg::onClick_Export);
+ btnBrowseDir.OnClick = Callback(this, &CBasicOptDlg::onClick_BrowseDir);
+ btnBrowseFile.OnClick = Callback(this, &CBasicOptDlg::onClick_BrowseFile);
+ btnSetDefault.OnClick = Callback(this, &CBasicOptDlg::onClick_SetDefault);
+ btnUserDetails.OnClick = Callback(this, &CBasicOptDlg::onClick_Details);
+ btnAutoFileName.OnClick = Callback(this, &CBasicOptDlg::onClick_AutoFileName);
}
- ExportDialogData *data = new ExportDialogData();
-
- // List all contacts to export
+ bool OnInitDialog() override
{
- LVITEM sItem = { 0 };
- sItem.mask = LVIF_PARAM;
+ DWORD dw = listUsers.GetExtendedListViewStyle();
+ dw |= LVS_EX_HEADERDRAGDROP | LVS_EX_FULLROWSELECT | LVS_EX_CHECKBOXES;
+ listUsers.SetExtendedListViewStyle(dw);
- for (int nCur = 0; nCur < nTotalContacts; nCur++) {
- if (bOnlySelected)
- if (!(ListView_GetItemState(hMapUser, nCur, LVIS_SELECTED) & LVIS_SELECTED))
- continue;
+ int nColumnWidth = 100;
+ RECT rListSize;
+ if (GetWindowRect(listUsers.GetHwnd(), &rListSize)) {
+ nColumnWidth = (rListSize.right - rListSize.left - GetSystemMetrics(SM_CXVSCROLL) - 5 - nUINColWitdh - nProtoColWitdh) / 2;
+ if (nColumnWidth < 10)
+ nColumnWidth = 10;
+ }
- sItem.iItem = nCur;
- if (!ListView_GetItem(hMapUser, &sItem)) {
- MessageBox(hParent, TranslateT("Failed to export at least one contact"), MSG_BOX_TITEL, MB_OK);
+ // header setup
+ LVCOLUMN cCol = { 0 };
+ cCol.mask = LVCF_TEXT | LVCF_WIDTH;
+ cCol.cx = nColumnWidth;
+ cCol.pszText = TranslateT("File");
+ listUsers.InsertColumn(0, &cCol);
+
+ cCol.pszText = TranslateT("Nick");
+ listUsers.InsertColumn(1, &cCol);
+
+ cCol.cx = nProtoColWitdh;
+ cCol.pszText = TranslateT("Proto");
+ listUsers.InsertColumn(2, &cCol);
+
+ cCol.cx = nUINColWitdh;
+ cCol.mask |= LVCF_FMT;
+ cCol.fmt = LVCFMT_RIGHT;
+ cCol.pszText = TranslateT("UIN");
+ listUsers.InsertColumn(3, &cCol);
+
+ int nUser = 0;
+ wstring sTmp;
+ LVITEM sItem = { 0 };
+ for (auto &hContact : Contacts()) {
+ PROTOACCOUNT *pa = Proto_GetAccount(GetContactProto(hContact));
+ if (pa == nullptr)
continue;
- }
- MCONTACT hContact = (MCONTACT)sItem.lParam;
- data->contacts.push_back(hContact);
- }
- }
+ sItem.mask = LVIF_TEXT | LVIF_PARAM;
+ sItem.iItem = nUser++;
+ sItem.iSubItem = 0;
+ sItem.lParam = hContact;
- // Create progress dialog
- HWND hDlg = data->hDialog = CreateDialog(g_plugin.getInst(), MAKEINTRESOURCE(IDD_EXPORT_ALL_DLG), nullptr, DialogProc);
- ShowWindow(hDlg, SW_SHOWNORMAL);
-
- // Process the export in other thread
- mir_forkThread<ExportDialogData>(&exportContactsMessages, data);
- return 0;
-}
+ sTmp = _DBGetStringW(hContact, MODULENAME, "FileName", L"");
+ sItem.pszText = (wchar_t*)sTmp.c_str();
+ listUsers.InsertItem(&sItem);
-/////////////////////////////////////////////////////////////////////
-// Member Function : SetToDefault
-// Type : Global
-// Parameters : hwndDlg - ?
-// Returns : void
-// Description :
-//
-// References : -
-// Remarks : -
-// Created : 021228, 28 December 2002
-// Developer : KN
-/////////////////////////////////////////////////////////////////////
-//
-void SetToDefault(HWND hParent)
-{
- HWND hMapUser = GetDlgItem(hParent, IDC_MAP_USER_LIST);
- int nContacts = ListView_GetItemCount(hMapUser);
+ sItem.mask = LVIF_TEXT;
+ sItem.iSubItem = 1;
+ sItem.pszText = Clist_GetContactDisplayName(hContact);
+ listUsers.SetItem(&sItem);
- if (!hMapUser || nContacts <= 0)
- return;
+ sItem.iSubItem = 2;
+ sItem.pszText = pa->tszAccountName;
+ listUsers.SetItem(&sItem);
- wchar_t szTemp[500];
- if (!GetDlgItemText(hParent, IDC_DEFAULT_FILE, szTemp, _countof(szTemp)))
- return;
+ DWORD dwUIN = db_get_dw(hContact, pa->szModuleName, "UIN", 0);
+ wchar_t szTmp[50];
+ mir_snwprintf(szTmp, L"%d", dwUIN);
+ sItem.iSubItem = 3;
+ sItem.pszText = szTmp;
+ listUsers.SetItem(&sItem);
- LVITEM sItem = { 0 };
+ listUsers.SetCheckState(sItem.iItem, db_get_b(hContact, MODULENAME, "EnableLog", 1));
+ }
+ listUsers.SortItems(CompareFunc, 1);
+
+ sItem.mask = LVIF_STATE;
+ sItem.iItem = 0;
+ sItem.iSubItem = 0;
+ sItem.state = LVIS_FOCUSED;
+ sItem.stateMask = LVIS_FOCUSED;
+ listUsers.SetItem(&sItem);
+
+ SetDlgItemInt(m_hwnd, IDC_MAX_CLOUMN_WIDTH, nMaxLineWidth, TRUE);
+
+ // Export dir
+ SetDlgItemText(m_hwnd, IDC_EXPORT_DIR, sExportDir.c_str());
+ HWND hComboBox = GetDlgItem(m_hwnd, IDC_EXPORT_DIR);
+ SendMessage(hComboBox, CB_ADDSTRING, 0, (LPARAM)L"%dbpath%\\MsgExport\\");
+ SendMessage(hComboBox, CB_ADDSTRING, 0, (LPARAM)L"C:\\Backup\\MsgExport\\");
+ SendMessage(hComboBox, CB_ADDSTRING, 0, (LPARAM)L"%dbpath%\\MsgExport\\%group% - ");
+ SendMessage(hComboBox, CB_ADDSTRING, 0, (LPARAM)L"%dbpath%\\MsgExport\\%group%\\");
+
+ // default file
+ SetDlgItemText(m_hwnd, IDC_DEFAULT_FILE, sDefaultFile.c_str());
+ hComboBox = GetDlgItem(m_hwnd, IDC_DEFAULT_FILE);
+ SendMessage(hComboBox, CB_ADDSTRING, 0, (LPARAM)L"%nick%.txt");
+ SendMessage(hComboBox, CB_ADDSTRING, 0, (LPARAM)L"%UIN%.txt");
+ SendMessage(hComboBox, CB_ADDSTRING, 0, (LPARAM)L"%group%.txt");
+ SendMessage(hComboBox, CB_ADDSTRING, 0, (LPARAM)L"%e-mail%.txt");
+ SendMessage(hComboBox, CB_ADDSTRING, 0, (LPARAM)L"%identifier%.txt");
+ SendMessage(hComboBox, CB_ADDSTRING, 0, (LPARAM)L"%year%-%month%-%day%.txt");
+ SendMessage(hComboBox, CB_ADDSTRING, 0, (LPARAM)L"%group%\\%nick%.txt");
+ SendMessage(hComboBox, CB_ADDSTRING, 0, (LPARAM)L"%group%\\%UIN%.txt");
+ SendMessage(hComboBox, CB_ADDSTRING, 0, (LPARAM)L"%group%\\%identifier%.txt");
+ SendMessage(hComboBox, CB_ADDSTRING, 0, (LPARAM)L"%protocol%\\%nick%.txt");
+ SendMessage(hComboBox, CB_ADDSTRING, 0, (LPARAM)L"History.txt");
+
+ // time format
+ SetDlgItemText(m_hwnd, IDC_EXPORT_TIMEFORMAT, sTimeFormat.c_str());
+ hComboBox = GetDlgItem(m_hwnd, IDC_EXPORT_TIMEFORMAT);
+ SendMessage(hComboBox, CB_ADDSTRING, 0, (LPARAM)L"d t");
+ SendMessage(hComboBox, CB_ADDSTRING, 0, (LPARAM)L"d s");
+ SendMessage(hComboBox, CB_ADDSTRING, 0, (LPARAM)L"d m");
+ SendMessage(hComboBox, CB_ADDSTRING, 0, (LPARAM)L"D s");
+ SendMessage(hComboBox, CB_ADDSTRING, 0, (LPARAM)L"D m :");
+
+ // File viewer
+ SetDlgItemText(m_hwnd, IDC_FILE_VIEWER, sFileViewerPrg.c_str());
+ hComboBox = GetDlgItem(m_hwnd, IDC_FILE_VIEWER);
+ SendMessage(hComboBox, CB_ADDSTRING, 0, (LPARAM)L"");
+ SendMessage(hComboBox, CB_ADDSTRING, 0, (LPARAM)L"C:\\Windows\\Notepad.exe");
+ SendMessage(hComboBox, CB_ADDSTRING, 0, (LPARAM)L"C:\\WinNT\\Notepad.exe");
+ SendMessage(hComboBox, CB_ADDSTRING, 0, (LPARAM)L"C:\\Program Files\\Notepad++\\notepad++.exe");
+
+ CheckDlgButton(m_hwnd, IDC_USE_INTERNAL_VIEWER, bUseInternalViewer() ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(m_hwnd, IDC_REPLACE_MIRANDA_HISTORY, bReplaceHistory ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(m_hwnd, IDC_APPEND_NEWLINE, bAppendNewLine ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(m_hwnd, IDC_USE_UTF8_IN_NEW_FILES, bUseUtf8InNewFiles ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(m_hwnd, IDC_USE_LESS_AND_GREATER_IN_EXPORT, bUseLessAndGreaterInExport ? BST_CHECKED : BST_UNCHECKED);
+ return true;
+ }
- for (int nCur = 0; nCur < nContacts; nCur++) {
- if (!(ListView_GetItemState(hMapUser, nCur, LVIS_SELECTED) & LVIS_SELECTED))
- continue;
+ bool OnApply() override
+ {
+ BOOL bTrans;
+ wchar_t szTemp[500];
+
+ int nTmp = GetDlgItemInt(m_hwnd, IDC_MAX_CLOUMN_WIDTH, &bTrans, TRUE);
+ if (!bTrans || (nTmp > 0 && nTmp < 5)) {
+ mir_snwprintf(szTemp, TranslateT("Max line width must be at least %d. Or use 0 for no limit."), 5);
+ MessageBox(m_hwnd, szTemp, MSG_BOX_TITEL, MB_OK);
+ return false;
+ }
+ else nMaxLineWidth = nTmp;
- sItem.iItem = nCur;
- sItem.mask = LVIF_PARAM;
- if (!ListView_GetItem(hMapUser, &sItem))
- continue;
+ GetDlgItemText(m_hwnd, IDC_EXPORT_TIMEFORMAT, szTemp, _countof(szTemp));
+ sTimeFormat = szTemp;
- wstring sFileName = szTemp;
- ReplaceDefines((MCONTACT)sItem.lParam, sFileName);
- ReplaceTimeVariables(sFileName);
+ GetDlgItemText(m_hwnd, IDC_EXPORT_DIR, szTemp, _countof(szTemp));
+ sExportDir = szTemp;
- sItem.mask = LVIF_TEXT;
- sItem.pszText = (wchar_t*)sFileName.c_str();
- ListView_SetItem(hMapUser, &sItem);
+ GetDlgItemText(m_hwnd, IDC_DEFAULT_FILE, szTemp, _countof(szTemp));
+ sDefaultFile = szTemp;
+
+ GetDlgItemText(m_hwnd, IDC_FILE_VIEWER, szTemp, _countof(szTemp));
+ sFileViewerPrg = szTemp;
+
+ bUseInternalViewer(IsDlgButtonChecked(m_hwnd, IDC_USE_INTERNAL_VIEWER) == BST_CHECKED);
- if (!bUnaplyedChanges) {
- bUnaplyedChanges = TRUE;
- SendMessage(GetParent(hParent), PSM_CHANGED, 0, 0);
+ bool bNewRp = IsDlgButtonChecked(m_hwnd, IDC_REPLACE_MIRANDA_HISTORY) == BST_CHECKED;
+ if (bReplaceHistory != bNewRp) {
+ bReplaceHistory = bNewRp;
+ MessageBox(m_hwnd, TranslateT("You need to restart Miranda to change the history function"), MSG_BOX_TITEL, MB_OK);
}
- }
-}
-/////////////////////////////////////////////////////////////////////
-// Member Function : bApplyChanges
-// Type : Global
-// Parameters : hwndDlg - handle to the parrent, ( Options Dlg )
-// Returns : Returns true if the changes was applyed
-// Description : but since we cant abort an apply opperation,
-// this can not currently be used
-// References : -
-// Remarks : -
-// Created : 020422, 22 April 2002
-// Developer : KN
-/////////////////////////////////////////////////////////////////////
-//
-BOOL bApplyChanges(HWND hwndDlg)
-{
- BOOL bTrans;
- BOOL bRet = true;
- wchar_t szTemp[500];
-
- int nTmp = GetDlgItemInt(hwndDlg, IDC_MAX_CLOUMN_WIDTH, &bTrans, TRUE);
- if (!bTrans || (nTmp > 0 && nTmp < 5)) {
- mir_snwprintf(szTemp, TranslateT("Max line width must be at least %d. Or use 0 for no limit."), 5);
- MessageBox(hwndDlg, szTemp, MSG_BOX_TITEL, MB_OK);
- bRet = false;
- }
- else nMaxLineWidth = nTmp;
+ bAppendNewLine = IsDlgButtonChecked(m_hwnd, IDC_APPEND_NEWLINE) == BST_CHECKED;
+ bUseUtf8InNewFiles = IsDlgButtonChecked(m_hwnd, IDC_USE_UTF8_IN_NEW_FILES) == BST_CHECKED;
+ bUseLessAndGreaterInExport = IsDlgButtonChecked(m_hwnd, IDC_USE_LESS_AND_GREATER_IN_EXPORT) == BST_CHECKED;
- GetDlgItemText(hwndDlg, IDC_EXPORT_TIMEFORMAT, szTemp, _countof(szTemp));
- sTimeFormat = szTemp;
+ int nCount = listUsers.GetItemCount();
+ for (int nCur = 0; nCur < nCount; nCur++) {
+ LVITEM sItem = { 0 };
+ sItem.iItem = nCur;
+ sItem.mask = LVIF_TEXT | LVIF_PARAM;
+ sItem.pszText = szTemp;
+ sItem.cchTextMax = _countof(szTemp);
- GetDlgItemText(hwndDlg, IDC_EXPORT_DIR, szTemp, _countof(szTemp));
- sExportDir = szTemp;
+ if (listUsers.GetItem(&sItem)) {
+ MCONTACT hUser = (MCONTACT)sItem.lParam;
+ if (mir_wstrlen(szTemp) > 0)
+ db_set_ws(hUser, MODULENAME, "FileName", szTemp);
+ else
+ db_unset(hUser, MODULENAME, "FileName");
- GetDlgItemText(hwndDlg, IDC_DEFAULT_FILE, szTemp, _countof(szTemp));
- sDefaultFile = szTemp;
+ if (listUsers.GetCheckState(nCur))
+ db_unset(hUser, MODULENAME, "EnableLog");
+ else
+ db_set_b(hUser, MODULENAME, "EnableLog", 0);
+ }
+ }
+ UpdateFileToColWidth();
- GetDlgItemText(hwndDlg, IDC_FILE_VIEWER, szTemp, _countof(szTemp));
- sFileViewerPrg = szTemp;
+ SaveSettings();
- bUseInternalViewer(IsDlgButtonChecked(hwndDlg, IDC_USE_INTERNAL_VIEWER) == BST_CHECKED);
+ bUnapplyedChanges = false;
+ return true;
+ }
- bool bNewRp = IsDlgButtonChecked(hwndDlg, IDC_REPLACE_MIRANDA_HISTORY) == BST_CHECKED;
- if (bReplaceHistory != bNewRp) {
- bReplaceHistory = bNewRp;
- MessageBox(hwndDlg, TranslateT("You need to restart Miranda to change the history function"), MSG_BOX_TITEL, MB_OK);
+ void OnChange() override
+ {
+ bUnapplyedChanges = true;
}
- bAppendNewLine = IsDlgButtonChecked(hwndDlg, IDC_APPEND_NEWLINE) == BST_CHECKED;
- bUseUtf8InNewFiles = IsDlgButtonChecked(hwndDlg, IDC_USE_UTF8_IN_NEW_FILES) == BST_CHECKED;
+ void onClick_Export(CCtrlButton *pButton)
+ {
+ if (bUnapplyedChanges) {
+ DWORD res = MessageBox(m_hwnd, TranslateT("You have not applied the changes, do you wish to apply them first?"), MSG_BOX_TITEL, MB_YESNOCANCEL);
+ if (res == IDCANCEL)
+ return;
+
+ if (res == IDYES)
+ if (!OnApply())
+ return;
+ }
- bUseLessAndGreaterInExport = IsDlgButtonChecked(hwndDlg, IDC_USE_LESS_AND_GREATER_IN_EXPORT) == BST_CHECKED;
+ bool bOnlySelected = pButton->GetCtrlId() != IDC_EXPORTALL;
+ int nTotalContacts = listUsers.GetItemCount();
+ int nContacts;
+ if (bOnlySelected)
+ nContacts = listUsers.GetSelectedCount();
+ else
+ nContacts = nTotalContacts;
- HWND hMapUser = GetDlgItem(hwndDlg, IDC_MAP_USER_LIST);
- int nCount = ListView_GetItemCount(hMapUser);
- for (int nCur = 0; nCur < nCount; nCur++) {
- LVITEM sItem = { 0 };
- sItem.iItem = nCur;
- sItem.mask = LVIF_TEXT | LVIF_PARAM | LVIF_IMAGE;
- sItem.pszText = szTemp;
- sItem.cchTextMax = _countof(szTemp);
-
- if (ListView_GetItem(hMapUser, &sItem)) {
- MCONTACT hUser = (MCONTACT)sItem.lParam;
- if (mir_wstrlen(szTemp) > 0)
- db_set_ws(hUser, MODULENAME, "FileName", szTemp);
- else
- db_unset(hUser, MODULENAME, "FileName");
-
- if (sItem.iImage)
- db_unset(hUser, MODULENAME, "EnableLog"); // default is Enabled !!
- else
- db_set_b(hUser, MODULENAME, "EnableLog", 0);
+ if (nContacts <= 0) {
+ MessageBox(m_hwnd, TranslateT("No contacts found to export"), MSG_BOX_TITEL, MB_OK);
+ return;
}
- }
- UpdateFileToColWidth();
- SaveSettings();
+ ExportDialogData *data = new ExportDialogData();
+ // List all contacts to export
+ LVITEM sItem = { 0 };
+ sItem.mask = LVIF_PARAM;
- bUnaplyedChanges = FALSE;
- return bRet;
-}
+ for (int nCur = 0; nCur < nTotalContacts; nCur++) {
+ if (bOnlySelected)
+ if (!(listUsers.GetItemState(nCur, LVIS_SELECTED) & LVIS_SELECTED))
+ continue;
-/////////////////////////////////////////////////////////////////////
-// Member Function : ClearAllFileNames
-// Type : Global
-// Parameters : hwndDlg - handle to the parrent, ( Options Dlg )
-// Returns : void
-// Description : Just clear all file name's entered
-//
-// References : -
-// Remarks : -
-// Created : 020422, 23 April 2002
-// Developer : KN
-/////////////////////////////////////////////////////////////////////
-//
-void ClearAllFileNames(HWND hwndDlg)
-{
- LVITEM sItem = { 0 };
- sItem.mask = LVIF_TEXT;
- sItem.pszText = L"";
-
- HWND hMapUser = GetDlgItem(hwndDlg, IDC_MAP_USER_LIST);
- int nCount = ListView_GetItemCount(hMapUser);
- for (int nCur = 0; nCur < nCount; nCur++) {
- sItem.iItem = nCur;
- ListView_SetItem(hMapUser, &sItem);
- }
- if (!bUnaplyedChanges) {
- bUnaplyedChanges = TRUE;
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ sItem.iItem = nCur;
+ if (!listUsers.GetItem(&sItem)) {
+ MessageBox(m_hwnd, TranslateT("Failed to export at least one contact"), MSG_BOX_TITEL, MB_OK);
+ continue;
+ }
+
+ MCONTACT hContact = (MCONTACT)sItem.lParam;
+ data->contacts.push_back(hContact);
+ }
+
+ // Create progress dialog
+ HWND hDlg = data->hDialog = CreateDialog(g_plugin.getInst(), MAKEINTRESOURCE(IDD_EXPORT_ALL_DLG), nullptr, DialogProc);
+ ShowWindow(hDlg, SW_SHOWNORMAL);
+
+ // Process the export in other thread
+ mir_forkThread<ExportDialogData>(&exportContactsMessages, data);
}
-}
-/////////////////////////////////////////////////////////////////////
-// Member Function : AutoFindeFileNames
-// Type : Global
-// Parameters : hwndDlg - handle to the parrent, ( Options Dlg )
-// Returns : void
-// Description : Try to finde new file names for user's with 2or more UIN's
-//
-// References : -
-// Remarks : -
-// Created : 020422, 23 April 2002
-// Developer : KN
-/////////////////////////////////////////////////////////////////////
-//
-void AutoFindeFileNames(HWND hwndDlg)
-{
- wchar_t szDefaultFile[500];
- GetDlgItemText(hwndDlg, IDC_DEFAULT_FILE, szDefaultFile, _countof(szDefaultFile));
+ void onClick_Details(CCtrlButton*)
+ {
+ LVITEM sItem;
+ sItem.mask = LVIF_PARAM;
+ sItem.iItem = listUsers.GetNextItem(-1, LVIS_SELECTED);
+ if (sItem.iItem >= 0 && listUsers.GetItem(&sItem))
+ CallService(MS_USERINFO_SHOWDIALOG, (WPARAM)sItem.lParam, 0);
+ }
- LVITEM sItem = { 0 };
+ void onClick_AutoFileName(CCtrlButton*)
+ {
+ wchar_t szDefaultFile[500];
+ GetDlgItemText(m_hwnd, IDC_DEFAULT_FILE, szDefaultFile, _countof(szDefaultFile));
- HWND hMapUser = GetDlgItem(hwndDlg, IDC_MAP_USER_LIST);
- int nCount = ListView_GetItemCount(hMapUser);
- for (int nCur = 0; nCur < nCount; nCur++) {
- wchar_t szSearch[100];
- sItem.pszText = szSearch;
- sItem.mask = LVIF_TEXT;
- sItem.iItem = nCur;
- sItem.iSubItem = 1;
- sItem.cchTextMax = _countof(szSearch);
- if (!ListView_GetItem(hMapUser, &sItem))
- continue;
+ LVITEM sItem = { 0 };
- int nShortestMatch = 0xFFFF;
- MCONTACT hStortest = 0;
- int nStortestIndex = -1;
- for (int nSubCur = 0; nSubCur < nCount; nSubCur++) {
- if (nSubCur == nCur)
- continue;
- wchar_t szSubCur[100];
- sItem.mask = LVIF_TEXT | LVIF_PARAM;
- sItem.iItem = nSubCur;
+ int nCount = listUsers.GetItemCount();
+ for (int nCur = 0; nCur < nCount; nCur++) {
+ wchar_t szSearch[100];
+ sItem.pszText = szSearch;
+ sItem.mask = LVIF_TEXT;
+ sItem.iItem = nCur;
sItem.iSubItem = 1;
- sItem.pszText = szSubCur;
- sItem.cchTextMax = _countof(szSubCur);
- if (ListView_GetItem(hMapUser, &sItem)) {
- size_t nLen = mir_wstrlen(szSubCur);
- if (wcsnicmp(szSubCur, szSearch, nLen) == 0) {
- if (nLen < (size_t)nShortestMatch) {
- nShortestMatch = (int)nLen;
- nStortestIndex = nSubCur;
- hStortest = (MCONTACT)sItem.lParam;
+ sItem.cchTextMax = _countof(szSearch);
+ if (!listUsers.GetItem(&sItem))
+ continue;
+
+ int nShortestMatch = 0xFFFF;
+ MCONTACT hStortest = 0;
+ int nStortestIndex = -1;
+ for (int nSubCur = 0; nSubCur < nCount; nSubCur++) {
+ if (nSubCur == nCur)
+ continue;
+ wchar_t szSubCur[100];
+ sItem.mask = LVIF_TEXT | LVIF_PARAM;
+ sItem.iItem = nSubCur;
+ sItem.iSubItem = 1;
+ sItem.pszText = szSubCur;
+ sItem.cchTextMax = _countof(szSubCur);
+ if (listUsers.GetItem(&sItem)) {
+ size_t nLen = mir_wstrlen(szSubCur);
+ if (wcsnicmp(szSubCur, szSearch, nLen) == 0) {
+ if (nLen < (size_t)nShortestMatch) {
+ nShortestMatch = (int)nLen;
+ nStortestIndex = nSubCur;
+ hStortest = (MCONTACT)sItem.lParam;
+ }
}
}
}
- }
-
- if (nShortestMatch != 0xFFFF) {
- wstring sFileName;
- szSearch[0] = 0;
- ListView_GetItemText(hMapUser, nCur, 0, szSearch, _countof(szSearch));
- bool bPriHasFileName = szSearch[0] != 0;
- if (bPriHasFileName)
- sFileName = szSearch;
-
- szSearch[0] = 0;
- ListView_GetItemText(hMapUser, nStortestIndex, 0, szSearch, _countof(szSearch));
- bool bSubHasFileName = szSearch[0] != 0;
- if (bSubHasFileName)
- sFileName = szSearch;
-
- if (sFileName.empty()) {
- sFileName = szDefaultFile;
- ReplaceDefines(hStortest, sFileName);
- ReplaceTimeVariables(sFileName);
- }
- if (!bPriHasFileName)
- ListView_SetItemText(hMapUser, nCur, 0, (wchar_t*)sFileName.c_str());
+ if (nShortestMatch != 0xFFFF) {
+ wstring sFileName;
+ szSearch[0] = 0;
+ listUsers.GetItemText(nCur, 0, szSearch, _countof(szSearch));
+ bool bPriHasFileName = szSearch[0] != 0;
+ if (bPriHasFileName)
+ sFileName = szSearch;
+
+ szSearch[0] = 0;
+ listUsers.GetItemText(nStortestIndex, 0, szSearch, _countof(szSearch));
+ bool bSubHasFileName = szSearch[0] != 0;
+ if (bSubHasFileName)
+ sFileName = szSearch;
+
+ if (sFileName.empty()) {
+ sFileName = szDefaultFile;
+ ReplaceDefines(hStortest, sFileName);
+ ReplaceTimeVariables(sFileName);
+ }
+
+ if (!bPriHasFileName)
+ listUsers.SetItemText(nCur, 0, (wchar_t*)sFileName.c_str());
- if (!bSubHasFileName)
- ListView_SetItemText(hMapUser, nStortestIndex, 0, (wchar_t*)sFileName.c_str());
+ if (!bSubHasFileName)
+ listUsers.SetItemText(nStortestIndex, 0, (wchar_t*)sFileName.c_str());
- if (!bUnaplyedChanges) {
- bUnaplyedChanges = TRUE;
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ NotifyChange();
}
}
}
-}
-/////////////////////////////////////////////////////////////////////
-// Member Function : DlgProcMsgExportOpts
-// Type : Global
-// Parameters : hwndDlg - handle to this dialog
-// msg - ?
-// wParam - ?
-// lParam - ?
-// Returns : static BOOL CALLBACK
-// Description : Main message prossing fore my options dialog
-//
-// References : -
-// Remarks : -
-// Created : 020422, 22 April 2002
-// Developer : KN
-/////////////////////////////////////////////////////////////////////
+ void onClick_ClearAll(CCtrlButton*)
+ {
+ LVITEM sItem = { 0 };
+ sItem.mask = LVIF_TEXT;
+ sItem.pszText = L"";
-static INT_PTR CALLBACK DlgProcMsgExportOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
-{
- // Used to prevent sending the PSM_CHANGED to miranda
- // when initilizing
- static BOOL bWindowTextSet = FALSE;
+ int nCount = listUsers.GetItemCount();
+ for (int nCur = 0; nCur < nCount; nCur++) {
+ sItem.iItem = nCur;
+ listUsers.SetItem(&sItem);
+ }
- switch (msg) {
- case WM_INITDIALOG:
- TranslateDialogDefault(hwndDlg);
+ NotifyChange();
+ }
- bWindowTextSet = FALSE;
- {
- HWND hMapUser = GetDlgItem(hwndDlg, IDC_MAP_USER_LIST);
+ void onClick_SetDefault(CCtrlButton*)
+ {
+ int nContacts = listUsers.GetItemCount();
+ if (nContacts <= 0)
+ return;
- { // init adv. win styles
- DWORD dw = ListView_GetExtendedListViewStyle(hMapUser);
- dw |= LVS_EX_HEADERDRAGDROP | LVS_EX_FULLROWSELECT;
- ListView_SetExtendedListViewStyle(hMapUser, dw /*| LVS_EX_LABELTIP*/);
- }
+ wchar_t szTemp[500];
+ if (!GetDlgItemText(m_hwnd, IDC_DEFAULT_FILE, szTemp, _countof(szTemp)))
+ return;
- int nColumnWidth = 100;
- RECT rListSize;
- if (GetWindowRect(hMapUser, &rListSize)) {
- nColumnWidth = (rListSize.right - rListSize.left - GetSystemMetrics(SM_CXVSCROLL) - 5 - nUINColWitdh - nProtoColWitdh) / 2;
- if (nColumnWidth < 10)
- nColumnWidth = 10;
- }
+ LVITEM sItem = { 0 };
- // header setup !!
- {
- LVCOLUMN cCol = { 0 };
- cCol.mask = LVCF_TEXT | LVCF_WIDTH;
- cCol.cx = nColumnWidth;
- cCol.pszText = TranslateT("File");
- ListView_InsertColumn(hMapUser, 0, &cCol);
-
- cCol.pszText = TranslateT("Nick");
- ListView_InsertColumn(hMapUser, 1, &cCol);
-
- cCol.cx = nProtoColWitdh;
- cCol.pszText = TranslateT("Proto");
- ListView_InsertColumn(hMapUser, 2, &cCol);
-
- cCol.cx = nUINColWitdh;
- cCol.mask |= LVCF_FMT;
- cCol.fmt = LVCFMT_RIGHT;
- cCol.pszText = TranslateT("UIN");
- ListView_InsertColumn(hMapUser, 3, &cCol);
- }
- {
- HIMAGELIST hIml = ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), ILC_COLOR4 | ILC_MASK, 2, 2);
- ImageList_AddIcon(hIml, Skin_LoadIcon(SKINICON_OTHER_NOTICK));
- ImageList_AddIcon(hIml, Skin_LoadIcon(SKINICON_OTHER_TICK));
- ListView_SetImageList(hMapUser, hIml, LVSIL_SMALL);
- }
- {
- int nUser = 0;
- wstring sTmp;
- LVITEM sItem = { 0 };
- for (auto &hContact : Contacts()) {
- PROTOACCOUNT *pa = Proto_GetAccount(GetContactProto(hContact));
- if (pa == nullptr)
- continue;
-
- sItem.mask = LVIF_TEXT | LVIF_PARAM | LVIF_IMAGE;
- sItem.iItem = nUser++;
- sItem.iSubItem = 0;
- sItem.iImage = db_get_b(hContact, MODULENAME, "EnableLog", 1);
- sItem.lParam = hContact;
-
- sTmp = _DBGetStringW(hContact, MODULENAME, "FileName", L"");
- sItem.pszText = (wchar_t*)sTmp.c_str();
- ListView_InsertItem(hMapUser, &sItem);
-
- sItem.mask = LVIF_TEXT;
- sItem.iSubItem = 1;
- sItem.pszText = Clist_GetContactDisplayName(hContact);
- ListView_SetItem(hMapUser, &sItem);
-
- sItem.iSubItem = 2;
- sItem.pszText = pa->tszAccountName;
- ListView_SetItem(hMapUser, &sItem);
-
- DWORD dwUIN = db_get_dw(hContact, pa->szModuleName, "UIN", 0);
- wchar_t szTmp[50];
- mir_snwprintf(szTmp, L"%d", dwUIN);
- sItem.iSubItem = 3;
- sItem.pszText = szTmp;
- ListView_SetItem(hMapUser, &sItem);
- }
- ListView_SortItems(hMapUser, CompareFunc, 1);
-
- sItem.mask = LVIF_STATE;
- sItem.iItem = 0;
- sItem.iSubItem = 0;
- sItem.state = LVIS_FOCUSED;
- sItem.stateMask = LVIS_FOCUSED;
- ListView_SetItem(hMapUser, &sItem);
- }
- HWND hComboBox;
-
- SetDlgItemInt(hwndDlg, IDC_MAX_CLOUMN_WIDTH, nMaxLineWidth, TRUE);
-
- // Export dir
- SetDlgItemText(hwndDlg, IDC_EXPORT_DIR, sExportDir.c_str());
- hComboBox = GetDlgItem(hwndDlg, IDC_EXPORT_DIR);
- SendMessage(hComboBox, CB_ADDSTRING, 0, (LPARAM)L"%dbpath%\\MsgExport\\");
- SendMessage(hComboBox, CB_ADDSTRING, 0, (LPARAM)L"C:\\Backup\\MsgExport\\");
- SendMessage(hComboBox, CB_ADDSTRING, 0, (LPARAM)L"%dbpath%\\MsgExport\\%group% - ");
- SendMessage(hComboBox, CB_ADDSTRING, 0, (LPARAM)L"%dbpath%\\MsgExport\\%group%\\");
-
- // default file
- SetDlgItemText(hwndDlg, IDC_DEFAULT_FILE, sDefaultFile.c_str());
- hComboBox = GetDlgItem(hwndDlg, IDC_DEFAULT_FILE);
- SendMessage(hComboBox, CB_ADDSTRING, 0, (LPARAM)L"%nick%.txt");
- SendMessage(hComboBox, CB_ADDSTRING, 0, (LPARAM)L"%UIN%.txt");
- SendMessage(hComboBox, CB_ADDSTRING, 0, (LPARAM)L"%group%.txt");
- SendMessage(hComboBox, CB_ADDSTRING, 0, (LPARAM)L"%e-mail%.txt");
- SendMessage(hComboBox, CB_ADDSTRING, 0, (LPARAM)L"%identifier%.txt");
- SendMessage(hComboBox, CB_ADDSTRING, 0, (LPARAM)L"%year%-%month%-%day%.txt");
- SendMessage(hComboBox, CB_ADDSTRING, 0, (LPARAM)L"%group%\\%nick%.txt");
- SendMessage(hComboBox, CB_ADDSTRING, 0, (LPARAM)L"%group%\\%UIN%.txt");
- SendMessage(hComboBox, CB_ADDSTRING, 0, (LPARAM)L"%group%\\%identifier%.txt");
- SendMessage(hComboBox, CB_ADDSTRING, 0, (LPARAM)L"%protocol%\\%nick%.txt");
- SendMessage(hComboBox, CB_ADDSTRING, 0, (LPARAM)L"History.txt");
-
- // time format
- SetDlgItemText(hwndDlg, IDC_EXPORT_TIMEFORMAT, sTimeFormat.c_str());
- hComboBox = GetDlgItem(hwndDlg, IDC_EXPORT_TIMEFORMAT);
- SendMessage(hComboBox, CB_ADDSTRING, 0, (LPARAM)L"d t");
- SendMessage(hComboBox, CB_ADDSTRING, 0, (LPARAM)L"d s");
- SendMessage(hComboBox, CB_ADDSTRING, 0, (LPARAM)L"d m");
- SendMessage(hComboBox, CB_ADDSTRING, 0, (LPARAM)L"D s");
- SendMessage(hComboBox, CB_ADDSTRING, 0, (LPARAM)L"D m :");
-
- // File viewer
- SetDlgItemText(hwndDlg, IDC_FILE_VIEWER, sFileViewerPrg.c_str());
- hComboBox = GetDlgItem(hwndDlg, IDC_FILE_VIEWER);
- SendMessage(hComboBox, CB_ADDSTRING, 0, (LPARAM)L"");
- SendMessage(hComboBox, CB_ADDSTRING, 0, (LPARAM)L"C:\\Windows\\Notepad.exe");
- SendMessage(hComboBox, CB_ADDSTRING, 0, (LPARAM)L"C:\\WinNT\\Notepad.exe");
- SendMessage(hComboBox, CB_ADDSTRING, 0, (LPARAM)L"C:\\Program Files\\Notepad++\\notepad++.exe");
-
- CheckDlgButton(hwndDlg, IDC_USE_INTERNAL_VIEWER, bUseInternalViewer() ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hwndDlg, IDC_REPLACE_MIRANDA_HISTORY, bReplaceHistory ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hwndDlg, IDC_APPEND_NEWLINE, bAppendNewLine ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hwndDlg, IDC_USE_UTF8_IN_NEW_FILES, bUseUtf8InNewFiles ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hwndDlg, IDC_USE_LESS_AND_GREATER_IN_EXPORT, bUseLessAndGreaterInExport ? BST_CHECKED : BST_UNCHECKED);
- }
+ for (int nCur = 0; nCur < nContacts; nCur++) {
+ if (!(listUsers.GetItemState(nCur, LVIS_SELECTED) & LVIS_SELECTED))
+ continue;
- bWindowTextSet = TRUE;
- return TRUE;
+ sItem.iItem = nCur;
+ sItem.mask = LVIF_PARAM;
+ if (!listUsers.GetItem(&sItem))
+ continue;
- case WM_COMMAND:
- switch (LOWORD(wParam)) {
- case ID_EXPORTSELECTED:
- case IDC_EXPORTALL:
- if (bUnaplyedChanges) {
- DWORD res = MessageBox(hwndDlg, TranslateT("You have not applied the changes, do you wish to apply them first?"), MSG_BOX_TITEL, MB_YESNOCANCEL);
- if (res == IDCANCEL)
- return TRUE;
- if (res == IDYES) {
- if (!bApplyChanges(hwndDlg)) {
- return TRUE;
- }
- }
- }
- nExportCompleatList(hwndDlg, LOWORD(wParam) == ID_EXPORTSELECTED);
- return TRUE;
-
- case IDC_EXPORT_DIR:
- case IDC_EXPORT_TIMEFORMAT:
- case IDC_DEFAULT_FILE:
- case IDC_FILE_VIEWER:
- if (!bWindowTextSet)
- return TRUE;
-
- if (HIWORD(wParam) == CBN_EDITUPDATE || HIWORD(wParam) == CBN_SELCHANGE) {
- bUnaplyedChanges = TRUE;
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- }
- return TRUE;
+ wstring sFileName = szTemp;
+ ReplaceDefines((MCONTACT)sItem.lParam, sFileName);
+ ReplaceTimeVariables(sFileName);
- case IDC_MAX_CLOUMN_WIDTH:
- if (!bWindowTextSet)
- return TRUE;
+ sItem.mask = LVIF_TEXT;
+ sItem.pszText = (wchar_t*)sFileName.c_str();
+ listUsers.SetItem(&sItem);
- if (HIWORD(wParam) == EN_CHANGE) {
- bUnaplyedChanges = TRUE;
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- }
- return TRUE;
-
- case IDC_USE_INTERNAL_VIEWER: // fall thru here
- case IDC_REPLACE_MIRANDA_HISTORY:
- case IDC_APPEND_NEWLINE:
- case IDC_USE_UTF8_IN_NEW_FILES:
- case IDC_USE_LESS_AND_GREATER_IN_EXPORT:
- if (HIWORD(wParam) == BN_CLICKED) {
- bUnaplyedChanges = TRUE;
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- }
- return TRUE;
-
- case ID_USERLIST_USERDETAILS:
- {
- LVITEM sItem = { 0 };
- sItem.mask = LVIF_PARAM;
- HWND hMapUser = GetDlgItem(hwndDlg, IDC_MAP_USER_LIST);
- sItem.iItem = ListView_GetNextItem(hMapUser, -1, LVIS_SELECTED);
- if (sItem.iItem >= 0 && ListView_GetItem(hMapUser, &sItem))
- CallService(MS_USERINFO_SHOWDIALOG, (WPARAM)sItem.lParam, 0);
- }
- return TRUE;
-
- case IDC_AUTO_FILENAME:
- AutoFindeFileNames(hwndDlg);
- return TRUE;
-
- case IDC_CLEAR_ALL:
- ClearAllFileNames(hwndDlg);
- return TRUE;
-
- case IDC_OPEN_HELP:
- Utils_OpenUrl("https://miranda-ng.org/p/Msg_Export/");
- return TRUE;
-
- case ID_SET_TO_DEFAULT:
- SetToDefault(hwndDlg);
- return TRUE;
-
- case IDC_FILE_VIEWER_BROWSE:
- wchar_t szFile[260]; // buffer for file name
- GetDlgItemText(hwndDlg, IDC_FILE_VIEWER, szFile, _countof(szFile));
-
- wchar_t buf[MAX_PATH];
- mir_snwprintf(buf, L"%s (*.exe;*.com;*.bat;*.cmd)%c*.exe;*.com;*.bat;*.cmd%c%s (*.*)%c*.*%c%c", TranslateT("Executable files"), 0, 0, TranslateT("All files"), 0, 0, 0);
- {
- OPENFILENAME ofn = {}; // common dialog box structure
- ofn.lStructSize = sizeof(OPENFILENAME);
- ofn.hwndOwner = hwndDlg;
- ofn.lpstrFile = szFile;
- ofn.nMaxFile = _countof(szFile);
- ofn.lpstrFilter = buf;
- ofn.nFilterIndex = 1;
- ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;
-
- // Display the Open dialog box.
- if (GetOpenFileName(&ofn)) {
- SetDlgItemText(hwndDlg, IDC_FILE_VIEWER, szFile);
- bUnaplyedChanges = TRUE;
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- }
- }
- return TRUE;
-
- case IDC_EXPORT_DIR_BROWSE:
- // CoInitializeEx(NULL,COINIT_APARTMENTTHREADED);
- // Get the shells allocator
- LPMALLOC pMalloc;
- if (FAILED(SHGetMalloc(&pMalloc))) { // we need to use this to support old Windows versions
- MessageBox(hwndDlg, TranslateT("Failed to get the shells allocator!"), MSG_BOX_TITEL, MB_OK);
- return TRUE; // TRUE because we have handled the message, sort of *S*
- }
+ NotifyChange();
+ }
+ }
- // Allocate the Dest Dir buffer to receive browse info
- wchar_t *lpDestDir = (wchar_t *)pMalloc->Alloc(MAX_PATH + 100);
- if (!lpDestDir) {
- pMalloc->Release();
- MessageBox(hwndDlg, TranslateT("Failed to Allocate buffer space"), MSG_BOX_TITEL, MB_OK);
- return TRUE;
- }
+ void onClick_BrowseFile(CCtrlButton*)
+ {
+ wchar_t szFile[260]; // buffer for file name
+ GetDlgItemText(m_hwnd, IDC_FILE_VIEWER, szFile, _countof(szFile));
- BROWSEINFO sBrowseInfo;
- sBrowseInfo.hwndOwner = hwndDlg;
- sBrowseInfo.pidlRoot = nullptr;
- sBrowseInfo.pszDisplayName = lpDestDir;
- sBrowseInfo.lpszTitle = TranslateT("Select Destination Directory");
- sBrowseInfo.ulFlags = BIF_NEWDIALOGSTYLE | BIF_EDITBOX;
- sBrowseInfo.lpfn = nullptr;
- sBrowseInfo.lParam = 0;
- sBrowseInfo.iImage = 0;
-
- LPITEMIDLIST psItemIDList = SHBrowseForFolder(&sBrowseInfo);
- if (psItemIDList) {
- SHGetPathFromIDList(psItemIDList, lpDestDir);
- size_t n = mir_wstrlen(lpDestDir);
- if (n > 0 && lpDestDir[n] != '\\') {
- lpDestDir[n] = '\\';
- lpDestDir[n + 1] = 0;
- }
- SetDlgItemText(hwndDlg, IDC_EXPORT_DIR, lpDestDir);
- bUnaplyedChanges = TRUE;
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- // Clean up
- pMalloc->Free(psItemIDList);
+ wchar_t buf[MAX_PATH];
+ mir_snwprintf(buf, L"%s (*.exe;*.com;*.bat;*.cmd)%c*.exe;*.com;*.bat;*.cmd%c%s (*.*)%c*.*%c%c", TranslateT("Executable files"), 0, 0, TranslateT("All files"), 0, 0, 0);
+ {
+ OPENFILENAME ofn = {}; // common dialog box structure
+ ofn.lStructSize = sizeof(OPENFILENAME);
+ ofn.hwndOwner = m_hwnd;
+ ofn.lpstrFile = szFile;
+ ofn.nMaxFile = _countof(szFile);
+ ofn.lpstrFilter = buf;
+ ofn.nFilterIndex = 1;
+ ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;
+
+ // Display the Open dialog box.
+ if (GetOpenFileName(&ofn)) {
+ SetDlgItemText(m_hwnd, IDC_FILE_VIEWER, szFile);
+ NotifyChange();
}
- pMalloc->Free(lpDestDir);
- pMalloc->Release();
- return TRUE;
}
- break;
-
- case WM_CONTEXTMENU:
- if (wParam == (WPARAM)GetDlgItem(hwndDlg, IDC_MAP_USER_LIST)) {
- HMENU hMainMenu = LoadMenu(g_plugin.getInst(), MAKEINTRESOURCE(IDR_MSG_EXPORT));
- if (hMainMenu) {
- HMENU hMenu = GetSubMenu(hMainMenu, 0);
-
- POINT pt = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) };
- if (pt.x == -1 && pt.y == -1) {
- HWND hMapUser = GetDlgItem(hwndDlg, IDC_MAP_USER_LIST);
- int nFirst = ListView_GetNextItem(hMapUser, -1, LVNI_FOCUSED);
- if (nFirst >= 0) {
- ListView_GetItemPosition(hMapUser, nFirst, &pt);
- }
+ }
- if (pt.y < 16)
- pt.y = 16;
- else {
- RECT rUserList;
- GetClientRect(hMapUser, &rUserList);
- if (pt.y > rUserList.bottom - 16)
- pt.y = rUserList.bottom - 16;
- else
- pt.y += 8;
- }
- pt.x = 8;
- ClientToScreen(hMapUser, &pt);
- }
+ void onClick_BrowseDir(CCtrlButton*)
+ {
+ // Get the shells allocator
+ LPMALLOC pMalloc;
+ if (FAILED(SHGetMalloc(&pMalloc))) { // we need to use this to support old Windows versions
+ MessageBox(m_hwnd, TranslateT("Failed to get the shells allocator!"), MSG_BOX_TITEL, MB_OK);
+ return;
+ }
- TranslateMenu(hMenu);
- TrackPopupMenu(hMenu, TPM_TOPALIGN | TPM_LEFTALIGN | TPM_RIGHTBUTTON, pt.x, pt.y, 0, hwndDlg, nullptr);
+ // Allocate the Dest Dir buffer to receive browse info
+ wchar_t *lpDestDir = (wchar_t *)pMalloc->Alloc(MAX_PATH + 100);
+ if (!lpDestDir) {
+ pMalloc->Release();
+ MessageBox(m_hwnd, TranslateT("Failed to Allocate buffer space"), MSG_BOX_TITEL, MB_OK);
+ return;
+ }
- DestroyMenu(hMainMenu);
+ BROWSEINFO sBrowseInfo;
+ sBrowseInfo.hwndOwner = m_hwnd;
+ sBrowseInfo.pidlRoot = nullptr;
+ sBrowseInfo.pszDisplayName = lpDestDir;
+ sBrowseInfo.lpszTitle = TranslateT("Select Destination Directory");
+ sBrowseInfo.ulFlags = BIF_NEWDIALOGSTYLE | BIF_EDITBOX;
+ sBrowseInfo.lpfn = nullptr;
+ sBrowseInfo.lParam = 0;
+ sBrowseInfo.iImage = 0;
+
+ LPITEMIDLIST psItemIDList = SHBrowseForFolder(&sBrowseInfo);
+ if (psItemIDList) {
+ SHGetPathFromIDList(psItemIDList, lpDestDir);
+ size_t n = mir_wstrlen(lpDestDir);
+ if (n > 0 && lpDestDir[n] != '\\') {
+ lpDestDir[n] = '\\';
+ lpDestDir[n + 1] = 0;
}
- return TRUE;
+ SetDlgItemText(m_hwnd, IDC_EXPORT_DIR, lpDestDir);
+ NotifyChange();
+
+ // Clean up
+ pMalloc->Free(psItemIDList);
}
- return FALSE;
-
- case WM_NOTIFY:
- NMHDR *p = ((LPNMHDR)lParam);
- if (p->idFrom == IDC_MAP_USER_LIST) {
- LVHITTESTINFO hti;
- LVITEM lvi;
-
- switch (p->code) {
- case NM_CLICK:
- hti.pt = ((NMLISTVIEW*)lParam)->ptAction;
- ListView_SubItemHitTest(p->hwndFrom, &hti);
-
- if (hti.flags != LVHT_ONITEMICON)
- break;
-
- lvi.mask = LVIF_IMAGE;
- lvi.iItem = hti.iItem;
- lvi.iSubItem = 0;
- ListView_GetItem(p->hwndFrom, &lvi);
- lvi.iImage ^= 1;
- ListView_SetItem(p->hwndFrom, &lvi);
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- break;
-
- case LVN_ENDLABELEDIT:
- {
- NMLVDISPINFO *pdi = (NMLVDISPINFO *)lParam;
- if (pdi->item.mask & LVIF_TEXT) {
- pdi->item.mask &= LVIF_TEXT;
- ListView_SetItem(p->hwndFrom, &pdi->item);
-
- bUnaplyedChanges = TRUE;
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- }
- }
- return TRUE;
-
- case LVN_KEYDOWN:
- {
- NMLVKEYDOWN *lpnmk = (NMLVKEYDOWN *)lParam;
- if (lpnmk->wVKey == 'A' && (GetKeyState(VK_CONTROL) & 0x8000)) {
- // select all
- int nCount = ListView_GetItemCount(p->hwndFrom);
- for (int nCur = 0; nCur < nCount; nCur++)
- ListView_SetItemState(p->hwndFrom, nCur, LVIS_SELECTED, LVIS_SELECTED);
-
- return TRUE;
- }
+ pMalloc->Free(lpDestDir);
+ pMalloc->Release();
+ }
- if (lpnmk->wVKey == VK_F2 || (lpnmk->wVKey >= 'A' && lpnmk->wVKey <= 'Z') || (lpnmk->wVKey >= '1' && lpnmk->wVKey <= '9') || lpnmk->wVKey == VK_BACK) {
- HWND hEdit = ListView_EditLabel(p->hwndFrom, ListView_GetSelectionMark(p->hwndFrom));
- if (hEdit && lpnmk->wVKey != VK_F2) {
- if (isupper(lpnmk->wVKey))
- SendMessage(hEdit, WM_CHAR, tolower(lpnmk->wVKey), 0);
- else
- SendMessage(hEdit, WM_CHAR, lpnmk->wVKey, 0);
- }
- }
- }
- return TRUE;
+ void list_OnMenu(CCtrlBase*)
+ {
+ HMENU hMainMenu = LoadMenu(g_plugin.getInst(), MAKEINTRESOURCE(IDR_MSG_EXPORT));
+ if (hMainMenu) {
+ HMENU hMenu = GetSubMenu(hMainMenu, 0);
- case NM_DBLCLK:
- {
- NMITEMACTIVATE *pdi = (NMITEMACTIVATE *)lParam;
- if (pdi->iItem >= 0)
- ListView_EditLabel(p->hwndFrom, pdi->iItem);
- }
- return TRUE;
+ POINT pt;
+ GetCursorPos(&pt);
- case NM_CUSTOMDRAW:
- LPNMLVCUSTOMDRAW lplvcd = (LPNMLVCUSTOMDRAW)lParam;
- switch (lplvcd->nmcd.dwDrawStage) {
- case CDDS_PREPAINT:
- SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, CDRF_NOTIFYITEMDRAW);
- return true;
+ TranslateMenu(hMenu);
+ TrackPopupMenu(hMenu, TPM_TOPALIGN | TPM_LEFTALIGN | TPM_RIGHTBUTTON, pt.x, pt.y, 0, m_hwnd, nullptr);
- case CDDS_ITEMPREPAINT:
- if (lplvcd->nmcd.lItemlParam == 0)
- lplvcd->clrText = RGB(0, 0, 255);
+ DestroyMenu(hMainMenu);
+ }
+ }
- SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, CDRF_NEWFONT);
- return true;
- }
- return FALSE;
- }
+ void list_LabelEdit(CCtrlListView::TEventInfo *evt)
+ {
+ NMLVDISPINFO *pdi = evt->nmlvdi;
+ if (pdi->item.mask & LVIF_TEXT) {
+ pdi->item.mask &= LVIF_TEXT;
+ listUsers.SetItem(&pdi->item);
+ NotifyChange();
}
- else {
- switch (p->code) {
- case PSN_APPLY:
- bApplyChanges(hwndDlg);
- return TRUE;
-
- case HDN_ITEMCLICK:
- NMHEADER *phdr = (LPNMHEADER)p;
- if (phdr->iButton == 0) { // 0 => Left button
- HWND hMapUser = GetDlgItem(hwndDlg, IDC_MAP_USER_LIST);
- ListView_SortItems(hMapUser, CompareFunc, phdr->iItem);
- return TRUE;
- }
- return FALSE;
+ }
+
+ void list_KeyDown(CCtrlListView::TEventInfo *evt)
+ {
+ NMLVKEYDOWN *lpnmk = evt->nmlvkey;
+ if (lpnmk->wVKey == 'A' && (GetKeyState(VK_CONTROL) & 0x8000)) {
+ // select all
+ int nCount = listUsers.GetItemCount();
+ for (int nCur = 0; nCur < nCount; nCur++)
+ listUsers.SetItemState(nCur, LVIS_SELECTED, LVIS_SELECTED);
+ return;
+ }
+
+ if (lpnmk->wVKey == VK_F2 || (lpnmk->wVKey >= 'A' && lpnmk->wVKey <= 'Z') || (lpnmk->wVKey >= '1' && lpnmk->wVKey <= '9') || lpnmk->wVKey == VK_BACK) {
+ HWND hEdit = listUsers.EditLabel(listUsers.GetSelectionMark());
+ if (hEdit && lpnmk->wVKey != VK_F2) {
+ if (isupper(lpnmk->wVKey))
+ SendMessage(hEdit, WM_CHAR, tolower(lpnmk->wVKey), 0);
+ else
+ SendMessage(hEdit, WM_CHAR, lpnmk->wVKey, 0);
}
}
- break;
}
- return FALSE;
-}
-/////////////////////////////////////////////////////////////////////
-// Member Function : DlgProcMsgExportOpts2
-// Type : Global
-// Parameters : hwndDlg - ?
-// msg - ?
-// wParam - ?
-// lParam - ?
-// Returns : static BOOL CALLBACK
-// Description :
-//
-// References : -
-// Remarks : -
-// Created : 040205, 05 februar 2004
-// Developer : KN
-/////////////////////////////////////////////////////////////////////
+ void list_ColumnClick(CCtrlListView::TEventInfo *evt)
+ {
+ listUsers.SortItems(CompareFunc, evt->nmlv->iSubItem);
+ }
+
+ void list_DoubleClick(CCtrlListView::TEventInfo *evt)
+ {
+ NMITEMACTIVATE *pdi = evt->nmlvia;
+ if (pdi->iItem >= 0)
+ listUsers.EditLabel(pdi->iItem);
+ }
+
+ void list_CustomDraw(CCtrlListView::TEventInfo *evt)
+ {
+ LPNMLVCUSTOMDRAW lplvcd = (LPNMLVCUSTOMDRAW)evt->nmlv;
+ switch (lplvcd->nmcd.dwDrawStage) {
+ case CDDS_PREPAINT:
+ SetWindowLongPtr(m_hwnd, DWLP_MSGRESULT, CDRF_NOTIFYITEMDRAW);
+ break;
+
+ case CDDS_ITEMPREPAINT:
+ if (lplvcd->nmcd.lItemlParam == 0)
+ lplvcd->clrText = RGB(0, 0, 255);
+
+ SetWindowLongPtr(m_hwnd, DWLP_MSGRESULT, CDRF_NEWFONT);
+ break;
+ }
+ }
+};
+
+/////////////////////////////////////////////////////////////////////////////////////////
+// CAdvancedOptDlg - class of advanced options
class CAdvancedOptDlg : public CDlgBase
{
@@ -1157,7 +919,7 @@ public:
}
};
-/////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////
// Member Function : OptionsInitialize
// Type : Global
// Parameters : wParam - ?
@@ -1169,24 +931,20 @@ public:
// Remarks : -
// Created : 020422, 22 April 2002
// Developer : KN
-/////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////
int OptionsInitialize(WPARAM wParam, LPARAM /*lParam*/)
{
- bUnaplyedChanges = FALSE;
-
OPTIONSDIALOGPAGE odp = {};
odp.position = 100000000;
- odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_MSGEXPORT);
odp.flags = ODPF_BOLDGROUPS | ODPF_UNICODE;
odp.szTitle.w = LPGENW("Message export");
odp.szGroup.w = LPGENW("History");
+
odp.szTab.w = LPGENW("General");
- odp.pfnDlgProc = DlgProcMsgExportOpts;
+ odp.pDialog = new CBasicOptDlg();
g_plugin.addOptions(wParam, &odp);
- odp.pfnDlgProc = 0;
- odp.pszTemplate = 0;
odp.position = 100000001;
odp.szTab.w = LPGENW("Additional");
odp.pDialog = new CAdvancedOptDlg();