diff options
author | George Hazan <ghazan@miranda.im> | 2018-08-13 19:16:38 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2018-08-13 19:16:38 +0300 |
commit | 7572c2f49fc29f3f5b20128cdb96e6087f89ab9a (patch) | |
tree | 331c8eca7d807e7c0af7c3b18b3674e180a7b217 /plugins | |
parent | 4e8d4723c8d60474147e12e7f6ff85836681d746 (diff) |
MsgExport: options diivded into two separate dialogs, code cleaning
Diffstat (limited to 'plugins')
-rwxr-xr-x | plugins/Msg_Export/res/resource.rc | 87 | ||||
-rwxr-xr-x | plugins/Msg_Export/src/main.cpp | 27 | ||||
-rwxr-xr-x | plugins/Msg_Export/src/options.cpp | 464 | ||||
-rwxr-xr-x | plugins/Msg_Export/src/resource.h | 9 | ||||
-rwxr-xr-x | plugins/Msg_Export/src/stdafx.h | 2 | ||||
-rwxr-xr-x | plugins/Msg_Export/src/utils.cpp | 90 | ||||
-rwxr-xr-x | plugins/Msg_Export/src/utils.h | 22 |
7 files changed, 364 insertions, 337 deletions
diff --git a/plugins/Msg_Export/res/resource.rc b/plugins/Msg_Export/res/resource.rc index 99a517a8b9..7341a8be4f 100755 --- a/plugins/Msg_Export/res/resource.rc +++ b/plugins/Msg_Export/res/resource.rc @@ -50,37 +50,50 @@ END // Dialog
//
-IDD_OPT_MSGEXPORT DIALOGEX 0, 0, 310, 234
+IDD_OPT_MSGEXPORT DIALOGEX 0, 0, 310, 208
STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD
EXSTYLE WS_EX_CONTROLPARENT
FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN
- COMBOBOX IDC_EXPORT_DIR,11,12,125,114,CBS_DROPDOWN | CBS_AUTOHSCROLL | WS_VSCROLL | WS_TABSTOP
- PUSHBUTTON "Browse",IDC_EXPORT_DIR_BROWSE,141,11,43,14
- COMBOBOX IDC_DEFAULT_FILE,53,29,83,112,CBS_DROPDOWN | CBS_AUTOHSCROLL | WS_VSCROLL | WS_TABSTOP
- CONTROL "Use internal viewer",IDC_USE_INTERNAL_VIEWER,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,11,61,78,10
- CONTROL "Replace Miranda history",IDC_REPLACE_MIRANDA_HISTORY,
- "Button",BS_AUTOCHECKBOX | WS_TABSTOP,91,61,90,10
- COMBOBOX IDC_FILE_VIEWER,11,75,125,89,CBS_DROPDOWN | CBS_AUTOHSCROLL | WS_VSCROLL | WS_TABSTOP
- PUSHBUTTON "Browse",IDC_FILE_VIEWER_BROWSE,141,74,43,14
- EDITTEXT IDC_MAX_CLOUMN_WIDTH,259,11,39,14,ES_AUTOHSCROLL | ES_NUMBER
- COMBOBOX IDC_EXPORT_TIMEFORMAT,241,38,57,122,CBS_DROPDOWN | CBS_AUTOHSCROLL | WS_VSCROLL | WS_TABSTOP
- CONTROL "Use UTF8 in new files",IDC_USE_UTF8_IN_NEW_FILES,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,194,55,104,10
- CONTROL "Append extra new line",IDC_APPEND_NEWLINE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,194,68,104,10
- CONTROL "Use << and >>",IDC_USE_LESS_AND_GREATER_IN_EXPORT,
- "Button",BS_AUTOCHECKBOX | WS_TABSTOP,194,81,104,10
- CONTROL "List1",IDC_MAP_USER_LIST,"SysListView32",LVS_REPORT | LVS_SHOWSELALWAYS | LVS_EDITLABELS | WS_BORDER | WS_TABSTOP,5,100,299,114
+ GROUPBOX "Export directory",IDC_STATIC,5,0,299,46
+ COMBOBOX IDC_EXPORT_DIR,11,12,233,114,CBS_DROPDOWN | CBS_AUTOHSCROLL | WS_VSCROLL | WS_TABSTOP
+ PUSHBUTTON "Browse",IDC_EXPORT_DIR_BROWSE,255,11,43,14
+
+ LTEXT "Default file",IDC_STATIC,11,32,34,8
+ COMBOBOX IDC_DEFAULT_FILE,53,29,191,112,CBS_DROPDOWN | CBS_AUTOHSCROLL | WS_VSCROLL | WS_TABSTOP
+
+ GROUPBOX "File viewer",IDC_STATIC,5,49,299,45
+ CONTROL "Use internal viewer",IDC_USE_INTERNAL_VIEWER,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,11,59,130,10
+ CONTROL "Replace Miranda history",IDC_REPLACE_MIRANDA_HISTORY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,149,59,149,10
+
+ COMBOBOX IDC_FILE_VIEWER,11,75,233,89,CBS_DROPDOWN | CBS_AUTOHSCROLL | WS_VSCROLL | WS_TABSTOP
+ PUSHBUTTON "Browse",IDC_FILE_VIEWER_BROWSE,255,74,43,14
+
+ GROUPBOX "Export format",IDC_STATIC,5,98,299,105
+
+ LTEXT "Max column width",IDC_STATIC,11,113,58,8
+ EDITTEXT IDC_MAX_CLOUMN_WIDTH,141,111,39,14,ES_AUTOHSCROLL | ES_NUMBER
+ LTEXT "Note: 0 = no limit",IDC_STATIC,193,113,105,8
+
+ LTEXT "Time format",IDC_STATIC,11,132,38,8
+ COMBOBOX IDC_EXPORT_TIMEFORMAT,141,130,57,122,CBS_DROPDOWN | CBS_AUTOHSCROLL | WS_VSCROLL | WS_TABSTOP
+
+ CONTROL "Use JSON format for export",IDC_USE_JSON,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,11,150,287,10
+ CONTROL "Use UTF8 in new files",IDC_USE_UTF8_IN_NEW_FILES,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,11,163,287,10
+ CONTROL "Append extra new line",IDC_APPEND_NEWLINE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,11,176,287,10
+ CONTROL "Use << and >>",IDC_USE_LESS_AND_GREATER_IN_EXPORT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,11,188,287,10
+END
+
+IDD_OPT_CONTACTS DIALOGEX 0, 0, 310, 234
+STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD
+EXSTYLE WS_EX_CONTROLPARENT
+FONT 8, "MS Shell Dlg", 0, 0, 0x1
+BEGIN
+ CONTROL "List1",IDC_MAP_USER_LIST,"SysListView32",LVS_REPORT | LVS_SHOWSELALWAYS | LVS_EDITLABELS | WS_BORDER | WS_TABSTOP,5,5,299,209
PUSHBUTTON "Auto filename",IDC_AUTO_FILENAME,5,218,63,14
PUSHBUTTON "Clear all",IDC_CLEAR_ALL,86,218,63,14
PUSHBUTTON "Help",IDC_OPEN_HELP,161,218,63,14
PUSHBUTTON "Export all history",IDC_EXPORTALL,235,218,63,14
- GROUPBOX "Export directory",IDC_STATIC,5,0,181,46
- LTEXT "Max column width",IDC_STATIC,194,14,58,8
- LTEXT "Note: 0 = no limit",IDC_STATIC,194,26,104,8
- LTEXT "Time format",IDC_STATIC,194,40,38,8
- GROUPBOX "Export format",IDC_STATIC,190,0,114,94
- LTEXT "Default file",IDC_STATIC,11,32,34,8
- GROUPBOX "File viewer",IDC_STATIC,5,49,181,45
END
IDD_EXPORT_ALL_DLG DIALOGEX 0, 0, 252, 46
@@ -136,14 +149,17 @@ BEGIN VERTGUIDE, 11
VERTGUIDE, 136
VERTGUIDE, 141
- VERTGUIDE, 186
- VERTGUIDE, 194
+ VERTGUIDE, 193
VERTGUIDE, 298
VERTGUIDE, 304
HORZGUIDE, 18
HORZGUIDE, 36
HORZGUIDE, 46
- HORZGUIDE, 66
+ HORZGUIDE, 64
+ END
+
+ IDD_OPT_CONTACTS, DIALOG
+ BEGIN
END
IDD_EXPORT_ALL_DLG, DIALOG
@@ -186,9 +202,12 @@ END // Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDI_EXPORT_MESSAGE ICON "export_m.ico"
+
IDI_TICK ICON "tick.ico"
+
IDI_NOTICK ICON "notick.ico"
+
/////////////////////////////////////////////////////////////////////////////
//
// Menu
@@ -215,6 +234,22 @@ BEGIN END
END
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// AFX_DIALOG_LAYOUT
+//
+
+IDD_OPT_CONTACTS AFX_DIALOG_LAYOUT
+BEGIN
+ 0
+END
+
+IDD_OPT_MSGEXPORT AFX_DIALOG_LAYOUT
+BEGIN
+ 0
+END
+
#endif // Russian (Russia) resources
/////////////////////////////////////////////////////////////////////////////
diff --git a/plugins/Msg_Export/src/main.cpp b/plugins/Msg_Export/src/main.cpp index 3ce7781be1..08cb626d0e 100755 --- a/plugins/Msg_Export/src/main.cpp +++ b/plugins/Msg_Export/src/main.cpp @@ -110,7 +110,7 @@ int MainInit(WPARAM /*wparam*/, LPARAM /*lparam*/) HookEvent(ME_DB_CONTACT_DELETED, nContactDeleted);
HookEvent(ME_OPT_INITIALISE, OptionsInitialize);
- if (!bReplaceHistory) {
+ if (!g_bReplaceHistory) {
CMenuItem mi(&g_plugin);
SET_UID(mi, 0x701c543, 0xd078, 0x41dd, 0x95, 0xe3, 0x96, 0x49, 0x8a, 0x72, 0xc7, 0x50);
mi.hIcolibItem = LoadIcon(g_plugin.getInst(), MAKEINTRESOURCE(IDI_EXPORT_MESSAGE));
@@ -141,28 +141,29 @@ int CMPlugin::Load() {
HookEvent(ME_SYSTEM_MODULESLOADED, MainInit);
- nMaxLineWidth = db_get_w(NULL, MODULENAME, "MaxLineWidth", nMaxLineWidth);
+ nMaxLineWidth = getWord("MaxLineWidth", nMaxLineWidth);
if (nMaxLineWidth > 0 && nMaxLineWidth < 5)
nMaxLineWidth = 5;
- sExportDir = _DBGetStringW(NULL, MODULENAME, "ExportDir", L"%dbpath%\\MsgExport\\");
- sDefaultFile = _DBGetStringW(NULL, MODULENAME, "DefaultFile", L"%nick%.txt");
+ g_sExportDir = _DBGetStringW(NULL, MODULENAME, "ExportDir", L"%dbpath%\\MsgExport\\");
+ g_sDefaultFile = _DBGetStringW(NULL, MODULENAME, "DefaultFile", L"%nick%.txt");
- sTimeFormat = _DBGetStringW(NULL, MODULENAME, "TimeFormat", L"d s");
+ g_sTimeFormat = _DBGetStringW(NULL, MODULENAME, "TimeFormat", L"d s");
sFileViewerPrg = _DBGetStringW(NULL, MODULENAME, "FileViewerPrg", L"");
- bUseInternalViewer(db_get_b(NULL, MODULENAME, "UseInternalViewer", bUseInternalViewer()) != 0);
+ bUseInternalViewer(getBool("UseInternalViewer", bUseInternalViewer()));
- bReplaceHistory = db_get_b(NULL, MODULENAME, "ReplaceHistory", bReplaceHistory) != 0;
- bAppendNewLine = db_get_b(NULL, MODULENAME, "AppendNewLine", bAppendNewLine) != 0;
- bUseUtf8InNewFiles = db_get_b(NULL, MODULENAME, "UseUtf8InNewFiles", bUseUtf8InNewFiles) != 0;
- bUseLessAndGreaterInExport = db_get_b(NULL, MODULENAME, "UseLessAndGreaterInExport", bUseLessAndGreaterInExport) != 0;
+ g_bUseJson = getBool("UseJson", false);
+ g_bAppendNewLine = getBool("AppendNewLine", true);
+ g_bReplaceHistory = getBool("ReplaceHistory", false);
+ g_bUseUtf8InNewFiles = getBool("UseUtf8InNewFiles", g_bUseUtf8InNewFiles);
+ g_bUseLessAndGreaterInExport = getBool("UseLessAndGreaterInExport", false);
- enRenameAction = (ENDialogAction)db_get_b(NULL, MODULENAME, "RenameAction", enRenameAction);
- enDeleteAction = (ENDialogAction)db_get_b(NULL, MODULENAME, "DeleteAction", enDeleteAction);
+ g_enRenameAction = (ENDialogAction)getByte("RenameAction", eDAPromptUser);
+ g_enDeleteAction = (ENDialogAction)getByte("DeleteAction", eDAPromptUser);
HANDLE hServiceFunc = nullptr;
- if (bReplaceHistory)
+ if (g_bReplaceHistory)
hServiceFunc = CreateServiceFunction(MS_HISTORY_SHOWCONTACTHISTORY, ShowExportHistory); //this need new code
if (!hServiceFunc)
diff --git a/plugins/Msg_Export/src/options.cpp b/plugins/Msg_Export/src/options.cpp index d5254f8303..4710593346 100755 --- a/plugins/Msg_Export/src/options.cpp +++ b/plugins/Msg_Export/src/options.cpp @@ -139,10 +139,7 @@ void __cdecl exportContactsMessages(ExportDialogData *data) {
// reading from the database !!!
int nCur = 0;
- list< MCONTACT >::const_iterator iterator;
- for (iterator = data->contacts.begin(); iterator != data->contacts.end(); ++iterator) {
- MCONTACT hContact = (*iterator);
-
+ for (auto &hContact : data->contacts) {
// Check if we should ignore this contact/protocol
if (!bIsExportEnabled(hContact))
continue;
@@ -157,9 +154,9 @@ void __cdecl exportContactsMessages(ExportDialogData *data) SendMessage(hProg, PBM_SETPOS, nCur, 0);
RedrawWindow(hDlg, nullptr, nullptr, RDW_ALLCHILDREN | RDW_UPDATENOW);
-
nCur++;
}
+
// Free the list of contacts
data->contacts.clear();
delete data;
@@ -171,16 +168,14 @@ void __cdecl exportContactsMessages(ExportDialogData *data) SendMessage(hProg, PBM_SETPOS, 0, 0);
// time to write to files !!!
- map<wstring, list< CLDBEvent >, less<wstring> >::iterator FileIterator;
-
int nCur = 0;
- for (FileIterator = AllEvents.begin(); FileIterator != AllEvents.end(); ++FileIterator) {
- (FileIterator->second).sort(); // Sort is preformed here !!
+ for (auto &F : AllEvents) {
+ F.second.sort(); // Sort is preformed here !!
// events with same time will not be swaped, they will
// remain in there original order
// Open/create file for writing
- wstring sFilePath = FileIterator->first;
+ wstring sFilePath = F.first;
HANDLE hFile = openCreateFile(sFilePath);
if (hFile == INVALID_HANDLE_VALUE) {
DisplayErrorDialog(LPGENW("Failed to open or create file :\n"), sFilePath, nullptr);
@@ -190,10 +185,9 @@ void __cdecl exportContactsMessages(ExportDialogData *data) // At first write we need to have this false (to write file header, etc.), for each next write to same file use true
bool bAppendOnly = false;
- list< CLDBEvent >::const_iterator iterator;
- for (iterator = FileIterator->second.begin(); iterator != FileIterator->second.end(); ++iterator) {
- MEVENT hDbEvent = (*iterator).hDbEvent;
- MCONTACT hContact = (*iterator).hUser;
+ for (auto &E : F.second) {
+ MEVENT hDbEvent = E.hDbEvent;
+ MCONTACT hContact = E.hUser;
if (!bExportEvent(hContact, hDbEvent, hFile, sFilePath, bAppendOnly))
break; // serious error, we should close the file and don't continue with it
@@ -216,40 +210,231 @@ void __cdecl exportContactsMessages(ExportDialogData *data) class CBasicOptDlg : public CDlgBase
{
- CCtrlButton btnExportAll, btnExportSel, btnUserDetails, btnAutoFileName, btnClearAll, btnSetDefault;
- CCtrlButton btnBrowseDir, btnBrowseFile;
- CCtrlListView listUsers;
CCtrlHyperlink urlHelp;
-
- bool bUnapplyedChanges = false;
+ CCtrlButton btnBrowseDir, btnBrowseFile;
+ CCtrlCombo cmbExportDir, cmbDefaultFile, cmbTimeFormat, cmbFileViewer;
public:
CBasicOptDlg() :
CDlgBase(g_plugin, IDD_OPT_MSGEXPORT),
urlHelp(this, IDC_OPEN_HELP, "https://miranda-ng.org/p/Msg_Export/"),
+ btnBrowseDir(this, IDC_EXPORT_DIR_BROWSE),
+ btnBrowseFile(this, IDC_FILE_VIEWER_BROWSE),
+ cmbExportDir(this, IDC_EXPORT_DIR),
+ cmbTimeFormat(this, IDC_EXPORT_TIMEFORMAT),
+ cmbFileViewer(this, IDC_FILE_VIEWER),
+ cmbDefaultFile(this, IDC_DEFAULT_FILE)
+ {
+ btnBrowseDir.OnClick = Callback(this, &CBasicOptDlg::onClick_BrowseDir);
+ btnBrowseFile.OnClick = Callback(this, &CBasicOptDlg::onClick_BrowseFile);
+ }
+
+ bool OnInitDialog() override
+ {
+ SetDlgItemInt(m_hwnd, IDC_MAX_CLOUMN_WIDTH, nMaxLineWidth, TRUE);
+
+ // Export dir
+ cmbExportDir.SetText(g_sExportDir.c_str());
+
+ cmbExportDir.AddString(L"%dbpath%\\MsgExport\\");
+ cmbExportDir.AddString(L"C:\\Backup\\MsgExport\\");
+ cmbExportDir.AddString(L"%dbpath%\\MsgExport\\%group% - ");
+ cmbExportDir.AddString(L"%dbpath%\\MsgExport\\%group%\\");
+
+ // default file
+ cmbDefaultFile.SetText(g_sDefaultFile.c_str());
+
+ cmbDefaultFile.AddString(L"%nick%.txt");
+ cmbDefaultFile.AddString(L"%UIN%.txt");
+ cmbDefaultFile.AddString(L"%group%.txt");
+ cmbDefaultFile.AddString(L"%e-mail%.txt");
+ cmbDefaultFile.AddString(L"%identifier%.txt");
+ cmbDefaultFile.AddString(L"%year%-%month%-%day%.txt");
+ cmbDefaultFile.AddString(L"%group%\\%nick%.txt");
+ cmbDefaultFile.AddString(L"%group%\\%UIN%.txt");
+ cmbDefaultFile.AddString(L"%group%\\%identifier%.txt");
+ cmbDefaultFile.AddString(L"%protocol%\\%nick%.txt");
+ cmbDefaultFile.AddString(L"History.txt");
+
+ // time format
+ cmbTimeFormat.SetText(g_sTimeFormat.c_str());
+
+ cmbTimeFormat.AddString(L"d t");
+ cmbTimeFormat.AddString(L"d s");
+ cmbTimeFormat.AddString(L"d m");
+ cmbTimeFormat.AddString(L"D s");
+ cmbTimeFormat.AddString(L"D m :");
+
+ // File viewer
+ cmbFileViewer.SetText(sFileViewerPrg.c_str());
+
+ cmbFileViewer.AddString(L"");
+ cmbFileViewer.AddString(L"C:\\Windows\\Notepad.exe");
+ cmbFileViewer.AddString(L"C:\\WinNT\\Notepad.exe");
+ cmbFileViewer.AddString(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, g_bReplaceHistory ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(m_hwnd, IDC_APPEND_NEWLINE, g_bAppendNewLine ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(m_hwnd, IDC_USE_UTF8_IN_NEW_FILES, g_bUseUtf8InNewFiles ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(m_hwnd, IDC_USE_LESS_AND_GREATER_IN_EXPORT, g_bUseLessAndGreaterInExport ? BST_CHECKED : BST_UNCHECKED);
+ return true;
+ }
+
+ 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;
+ g_plugin.setWord("MaxLineWidth", (WORD)nMaxLineWidth);
+
+ cmbTimeFormat.GetText(szTemp, _countof(szTemp));
+ g_sTimeFormat = szTemp;
+ g_plugin.setWString("TimeFormat", g_sTimeFormat.c_str());
+
+ cmbExportDir.GetText(szTemp, _countof(szTemp));
+ g_sExportDir = szTemp;
+ g_plugin.setWString("ExportDir", g_sExportDir.c_str());
+
+ cmbDefaultFile.GetText(szTemp, _countof(szTemp));
+ g_sDefaultFile = szTemp;
+ g_plugin.setWString("DefaultFile", g_sDefaultFile.c_str());
+
+ cmbFileViewer.GetText(szTemp, _countof(szTemp));
+ sFileViewerPrg = szTemp;
+ g_plugin.setWString("FileViewerPrg", sFileViewerPrg.c_str());
+
+ bUseInternalViewer(IsDlgButtonChecked(m_hwnd, IDC_USE_INTERNAL_VIEWER) == BST_CHECKED);
+ g_plugin.setByte("UseInternalViewer", bUseInternalViewer());
+
+ bool bNewRp = IsDlgButtonChecked(m_hwnd, IDC_REPLACE_MIRANDA_HISTORY) == BST_CHECKED;
+ if (g_bReplaceHistory != bNewRp) {
+ g_bReplaceHistory = bNewRp;
+ MessageBox(m_hwnd, TranslateT("You need to restart Miranda to change the history function"), MSG_BOX_TITEL, MB_OK);
+ }
+ g_plugin.setByte("ReplaceHistory", g_bReplaceHistory);
+
+ g_bUseJson = IsDlgButtonChecked(m_hwnd, IDC_USE_JSON) == BST_CHECKED;
+ g_plugin.setByte("UseJson", g_bUseJson);
+
+ g_bAppendNewLine = IsDlgButtonChecked(m_hwnd, IDC_APPEND_NEWLINE) == BST_CHECKED;
+ g_plugin.setByte("AppendNewLine", g_bAppendNewLine);
+
+ g_bUseUtf8InNewFiles = IsDlgButtonChecked(m_hwnd, IDC_USE_UTF8_IN_NEW_FILES) == BST_CHECKED;
+ g_plugin.setByte("UseUtf8InNewFiles", g_bUseUtf8InNewFiles);
+
+ g_bUseLessAndGreaterInExport = IsDlgButtonChecked(m_hwnd, IDC_USE_LESS_AND_GREATER_IN_EXPORT) == BST_CHECKED;
+ g_plugin.setByte("UseLessAndGreaterInExport", g_bUseLessAndGreaterInExport);
+ return true;
+ }
+
+ void onClick_BrowseFile(CCtrlButton*)
+ {
+ wchar_t szFile[260]; // buffer for file name
+ cmbFileViewer.GetText(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 = 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();
+ }
+ }
+
+ 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;
+ }
+
+ // 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;
+ }
+
+ 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;
+ }
+ cmbExportDir.SetText(lpDestDir);
+ NotifyChange();
+
+ // Clean up
+ pMalloc->Free(psItemIDList);
+ }
+ pMalloc->Free(lpDestDir);
+ pMalloc->Release();
+ }
+};
+
+/////////////////////////////////////////////////////////////////////////////////////////
+// CContactsOptDlg - class of advanced options
+
+class CContactsOptDlg : public CDlgBase
+{
+ CCtrlButton btnExportAll, btnExportSel, btnUserDetails, btnAutoFileName, btnClearAll, btnSetDefault;
+ CCtrlListView listUsers;
+
+public:
+ CContactsOptDlg() :
+ CDlgBase(g_plugin, IDD_OPT_CONTACTS),
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);
+ listUsers.OnKeyDown = Callback(this, &CContactsOptDlg::list_KeyDown);
+ listUsers.OnBuildMenu = Callback(this, &CContactsOptDlg::list_OnMenu);
+ listUsers.OnColumnClick = Callback(this, &CContactsOptDlg::list_ColumnClick);
+ listUsers.OnDoubleClick = Callback(this, &CContactsOptDlg::list_DoubleClick);
+ listUsers.OnEndLabelEdit = Callback(this, &CContactsOptDlg::list_LabelEdit);
+
+ btnClearAll.OnClick = Callback(this, &CContactsOptDlg::onClick_ClearAll);
+ btnExportAll.OnClick = btnExportSel.OnClick = Callback(this, &CContactsOptDlg::onClick_Export);
+ btnSetDefault.OnClick = Callback(this, &CContactsOptDlg::onClick_SetDefault);
+ btnUserDetails.OnClick = Callback(this, &CContactsOptDlg::onClick_Details);
+ btnAutoFileName.OnClick = Callback(this, &CContactsOptDlg::onClick_AutoFileName);
}
bool OnInitDialog() override
@@ -329,95 +514,14 @@ public: 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;
}
bool OnApply() override
{
- BOOL bTrans;
+ int nCount = listUsers.GetItemCount();
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;
-
- GetDlgItemText(m_hwnd, IDC_EXPORT_TIMEFORMAT, szTemp, _countof(szTemp));
- sTimeFormat = szTemp;
-
- GetDlgItemText(m_hwnd, IDC_EXPORT_DIR, szTemp, _countof(szTemp));
- sExportDir = szTemp;
-
- 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);
-
- 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);
- }
-
- 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;
-
- int nCount = listUsers.GetItemCount();
for (int nCur = 0; nCur < nCount; nCur++) {
LVITEM sItem = { 0 };
sItem.iItem = nCur;
@@ -440,29 +544,11 @@ public: }
UpdateFileToColWidth();
- SaveSettings();
-
- bUnapplyedChanges = false;
return true;
}
- void OnChange() override
- {
- bUnapplyedChanges = true;
- }
-
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;
- }
-
bool bOnlySelected = pButton->GetCtrlId() != IDC_EXPORTALL;
int nTotalContacts = listUsers.GetItemCount();
@@ -517,9 +603,6 @@ public: void onClick_AutoFileName(CCtrlButton*)
{
- wchar_t szDefaultFile[500];
- GetDlgItemText(m_hwnd, IDC_DEFAULT_FILE, szDefaultFile, _countof(szDefaultFile));
-
LVITEM sItem = { 0 };
int nCount = listUsers.GetItemCount();
@@ -572,7 +655,7 @@ public: sFileName = szSearch;
if (sFileName.empty()) {
- sFileName = szDefaultFile;
+ sFileName = g_sDefaultFile;
ReplaceDefines(hStortest, sFileName);
ReplaceTimeVariables(sFileName);
}
@@ -636,76 +719,6 @@ public: }
}
- void onClick_BrowseFile(CCtrlButton*)
- {
- wchar_t szFile[260]; // buffer for file name
- GetDlgItemText(m_hwnd, 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 = 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();
- }
- }
- }
-
- 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;
- }
-
- // 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;
- }
-
- 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;
- }
- SetDlgItemText(m_hwnd, IDC_EXPORT_DIR, lpDestDir);
- NotifyChange();
-
- // Clean up
- pMalloc->Free(psItemIDList);
- }
- pMalloc->Free(lpDestDir);
- pMalloc->Release();
- }
-
void list_OnMenu(CCtrlBase*)
{
HMENU hMainMenu = LoadMenu(g_plugin.getInst(), MAKEINTRESOURCE(IDR_MSG_EXPORT));
@@ -757,7 +770,7 @@ public: void list_ColumnClick(CCtrlListView::TEventInfo *evt)
{
listUsers.SortItems(CompareFunc, evt->nmlv->iSubItem);
- }
+ }
void list_DoubleClick(CCtrlListView::TEventInfo *evt)
{
@@ -784,6 +797,7 @@ public: }
};
+
/////////////////////////////////////////////////////////////////////////////////////////
// CAdvancedOptDlg - class of advanced options
@@ -810,7 +824,7 @@ public: bool OnInitDialog() override
{
- switch (enRenameAction) {
+ switch (g_enRenameAction) {
case eDAPromptUser:
chkFcPrompt.SetState(true);
break;
@@ -822,7 +836,7 @@ public: break;
}
- switch (enDeleteAction) {
+ switch (g_enDeleteAction) {
case eDAPromptUser:
chkFdPrompt.SetState(true);
break;
@@ -872,18 +886,20 @@ public: bool OnApply() override
{
if (chkFcPrompt.GetState())
- enRenameAction = eDAPromptUser;
+ g_enRenameAction = eDAPromptUser;
else if (chkFcRename.GetState() == BST_CHECKED)
- enRenameAction = eDAAutomatic;
+ g_enRenameAction = eDAAutomatic;
else if (chkFcNothing.GetState() == BST_CHECKED)
- enRenameAction = eDANothing;
+ g_enRenameAction = eDANothing;
+ db_set_b(NULL, MODULENAME, "RenameAction", (BYTE)g_enRenameAction);
if (chkFdPrompt.GetState() == BST_CHECKED)
- enDeleteAction = eDAPromptUser;
+ g_enDeleteAction = eDAPromptUser;
else if (chkFdDelete.GetState() == BST_CHECKED)
- enDeleteAction = eDAAutomatic;
+ g_enDeleteAction = eDAAutomatic;
else if (chkFdNothing.GetState() == BST_CHECKED)
- enDeleteAction = eDANothing;
+ g_enDeleteAction = eDANothing;
+ db_set_b(NULL, MODULENAME, "DeleteAction", (BYTE)g_enDeleteAction);
int nCount = listProtos.GetItemCount();
for (int nCur = 0; nCur < nCount; nCur++) {
@@ -899,18 +915,17 @@ public: db_set_b(NULL, MODULENAME, szTemp, 0);
}
}
- SaveSettings();
return true;
}
void onClick_Debug(CCtrlButton*)
{
wstring sDebug = L"Debug information\r\nsDBPath :";
- sDebug += sDBPath;
+ sDebug += g_sDBPath;
sDebug += L"\r\nsMirandaPath :";
- sDebug += sMirandaPath;
+ sDebug += g_sMirandaPath;
sDebug += L"\r\nsDefaultFile :";
- sDebug += sDefaultFile;
+ sDebug += g_sDefaultFile;
sDebug += L"\r\nGetFilePathFromUser(NULL) :";
sDebug += GetFilePathFromUser(NULL);
@@ -936,16 +951,21 @@ public: int OptionsInitialize(WPARAM wParam, LPARAM /*lParam*/)
{
OPTIONSDIALOGPAGE odp = {};
- odp.position = 100000000;
odp.flags = ODPF_BOLDGROUPS | ODPF_UNICODE;
odp.szTitle.w = LPGENW("Message export");
odp.szGroup.w = LPGENW("History");
+ odp.position = 100000000;
odp.szTab.w = LPGENW("General");
odp.pDialog = new CBasicOptDlg();
g_plugin.addOptions(wParam, &odp);
odp.position = 100000001;
+ odp.szTab.w = LPGENW("Contacts");
+ odp.pDialog = new CContactsOptDlg();
+ g_plugin.addOptions(wParam, &odp);
+
+ odp.position = 100000002;
odp.szTab.w = LPGENW("Additional");
odp.pDialog = new CAdvancedOptDlg();
g_plugin.addOptions(wParam, &odp);
diff --git a/plugins/Msg_Export/src/resource.h b/plugins/Msg_Export/src/resource.h index db15b889a1..9616639263 100755 --- a/plugins/Msg_Export/src/resource.h +++ b/plugins/Msg_Export/src/resource.h @@ -1,16 +1,17 @@ //{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
-// Used by resource.rc
+// Used by w:\miranda-ng\plugins\Msg_Export\res\resource.rc
//
#define IDI_EXPORT_MESSAGE 108
#define IDD_EXPORT_ALL_DLG 110
#define IDR_MSG_EXPORT 114
#define IDD_FILE_VIEWER 116
#define IDR_FV_EDIT 117
+#define IDD_OPT_MSGEXPORT 121
+#define IDD_OPT_CONTACTS 122
#define IDD_OPT_MSGEXPORT2 123
#define IDI_NOTICK 205
#define IDI_TICK 206
-#define IDD_OPT_MSGEXPORT 999
#define IDC_EXPORTALL 1001
#define IDC_EXPORT_DIR 1002
#define IDC_MAX_CLOUMN_WIDTH 1003
@@ -41,6 +42,8 @@ #define IDC_FD_NOTHING 1072
#define IDC_EXPORT_PROTOS 1073
#define IDC_USE_UTF8_IN_NEW_FILES 1074
+#define IDC_USE_UTF8_IN_NEW_FILES2 1075
+#define IDC_USE_JSON 1075
#define ID_EXPORTSELECTED 40002
#define ID_EDIT_COPY 40003
#define ID_SET_TO_DEFAULT 40004
@@ -50,7 +53,7 @@ //
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
-#define _APS_NEXT_RESOURCE_VALUE 124
+#define _APS_NEXT_RESOURCE_VALUE 126
#define _APS_NEXT_COMMAND_VALUE 40006
#define _APS_NEXT_CONTROL_VALUE 1075
#define _APS_NEXT_SYMED_VALUE 101
diff --git a/plugins/Msg_Export/src/stdafx.h b/plugins/Msg_Export/src/stdafx.h index 0508f1e2be..ddbe5076d8 100755 --- a/plugins/Msg_Export/src/stdafx.h +++ b/plugins/Msg_Export/src/stdafx.h @@ -64,6 +64,6 @@ struct CMPlugin : public PLUGIN<CMPlugin> };
extern MWindowList hInternalWindowList;
-extern wstring sDBPath, sMirandaPath;
+extern wstring g_sDBPath, g_sMirandaPath;
#endif
\ No newline at end of file diff --git a/plugins/Msg_Export/src/utils.cpp b/plugins/Msg_Export/src/utils.cpp index a2ae4a9a39..ed9a47da33 100755 --- a/plugins/Msg_Export/src/utils.cpp +++ b/plugins/Msg_Export/src/utils.cpp @@ -25,20 +25,20 @@ const wchar_t *pszDbPathError = L"."; // Replacement for chareteres not alowed in file names.
const wchar_t cBadCharReplace = '_';
-// sTimeFormat
-wstring sTimeFormat;
+// g_sTimeFormat
+wstring g_sTimeFormat;
// path from options dialog
-wstring sExportDir;
+wstring g_sExportDir;
// The default filename. Used if no other file name is specifyed in DB.
-wstring sDefaultFile;
+wstring g_sDefaultFile;
// path used then %dbpath% is used in export file path
-wstring sDBPath = pszDbPathError;
+wstring g_sDBPath = pszDbPathError;
// path to miranda exe file used when to avoid relative paths
-wstring sMirandaPath = pszDbPathError;
+wstring g_sMirandaPath = pszDbPathError;
// Used to store the width of the user name for a file.
// if a file contains events from many users the one user name
@@ -75,19 +75,20 @@ const char *pszReplaceListA[] = };
// Alowes this plugin to replace the history function of miranda !!
-bool bReplaceHistory = false;
+bool g_bReplaceHistory;
// This enum define the actions which MsgExport must take when a File is renamed
-ENDialogAction enRenameAction = eDAPromptUser;
+ENDialogAction g_enRenameAction;
// This enum define the actions which MsgExport must take when a user is delete
-ENDialogAction enDeleteAction = eDAPromptUser;
+ENDialogAction g_enDeleteAction;
// If true MsgExport will use << and >> insted of the nick in the exported format
-bool bUseLessAndGreaterInExport = false;
+bool g_bUseLessAndGreaterInExport;
-bool bAppendNewLine = true;
-bool bUseUtf8InNewFiles = true;
+bool g_bAppendNewLine;
+bool g_bUseUtf8InNewFiles;
+bool g_bUseJson;
const char szUtf8ByteOrderHeader[] = "\xEF\xBB\xBF";
bool bIsUtf8Header(BYTE * pucByteOrder)
@@ -428,13 +429,13 @@ bool bReadMirandaDirAndPath() wchar_t szDBPath[MAX_PATH], tmp[MAX_PATH];
wcsncpy_s(szDBPath, pszDbPathError, _TRUNCATE);
PathToAbsoluteW(L"miranda32.exe", tmp);
- sMirandaPath = tmp;
- sMirandaPath.erase(sMirandaPath.find_last_of(L"\\"));
+ g_sMirandaPath = tmp;
+ g_sMirandaPath.erase(g_sMirandaPath.find_last_of(L"\\"));
Profile_GetPathW(MAX_PATH, szDBPath);
- sDBPath = szDBPath;
+ g_sDBPath = szDBPath;
Profile_GetNameW(MAX_PATH, szDBPath);
- sDBPath.append(L"\\").append(szDBPath);
- sDBPath.erase(sDBPath.size() - 4);
+ g_sDBPath.append(L"\\").append(szDBPath);
+ g_sDBPath.erase(g_sDBPath.size() - 4);
return true;
}
@@ -453,14 +454,14 @@ bool bReadMirandaDirAndPath() void ReplaceDBPath(wstring &sRet)
{
- ReplaceAll(sRet, L"%dbpath%", sDBPath);
+ ReplaceAll(sRet, L"%dbpath%", g_sDBPath);
// Try to firure out if it is a relative path ( ..\..\MsgExport\ )
if (sRet.size() <= 2 || !(sRet[1] == ':' ||
(sRet[0] == '\\' && sRet[1] == '\\'))) {
// Relative path
// we will prepend the mirande exe path to avoid problems
// if the current directory changes ( User receives a file )
- sRet = sMirandaPath + sRet;
+ sRet = g_sMirandaPath + sRet;
}
}
@@ -480,7 +481,7 @@ void ReplaceDBPath(wstring &sRet) wstring GetFilePathFromUser(MCONTACT hContact)
{
- wstring sFilePath = sExportDir + _DBGetStringW(hContact, MODULENAME, "FileName", sDefaultFile.c_str());
+ wstring sFilePath = g_sExportDir + _DBGetStringW(hContact, MODULENAME, "FileName", g_sDefaultFile.c_str());
bool bNickUsed = sFilePath.find(L"%nick%") != string::npos;
@@ -503,7 +504,7 @@ wstring GetFilePathFromUser(MCONTACT hContact) return sPrevFileName; // Then the filename must have changed from a correct path to one including the (Unknown Contact)
// file name has changed
- if (enRenameAction != eDANothing) {
+ if (g_enRenameAction != eDANothing) {
// we can not use FILE_SHARE_DELETE because this is not supported by
// win 98 / ME
@@ -522,7 +523,7 @@ wstring GetFilePathFromUser(MCONTACT hContact) // ask user ?
bool bTryRename;
- if (enRenameAction != eDAAutomatic) {
+ if (g_enRenameAction != eDAAutomatic) {
wstring sRemoteUser = Clist_GetContactDisplayName(hContact);
mir_snwprintf(szTemp,
TranslateT("File name for the user \"%s\" has changed!\n\nfrom:\t%s\nto:\t%s\n\nDo you wish to rename file?"),
@@ -847,7 +848,7 @@ bool ExportDBEventInfo(MCONTACT hContact, HANDLE hFile, wstring sFilePath, DBEVE wstring sRemoteUser;
string::size_type nFirstColumnWidth;
- if (bUseLessAndGreaterInExport) {
+ if (g_bUseLessAndGreaterInExport) {
sLocalUser = L"<<";
sRemoteUser = L">>";
nFirstColumnWidth = 4;
@@ -864,7 +865,7 @@ bool ExportDBEventInfo(MCONTACT hContact, HANDLE hFile, wstring sFilePath, DBEVE bool bWriteUTF8Format = false;
if (bAppendOnly) {
- bWriteUTF8Format = bUseUtf8InNewFiles;
+ bWriteUTF8Format = g_bUseUtf8InNewFiles;
}
else {
DWORD dwHighSize = 0;
@@ -885,7 +886,7 @@ bool ExportDBEventInfo(MCONTACT hContact, HANDLE hFile, wstring sFilePath, DBEVE }
}
else {
- bWriteUTF8Format = bUseUtf8InNewFiles;
+ bWriteUTF8Format = g_bUseUtf8InNewFiles;
if (bWriteUTF8Format) {
if (!bWriteToFile(hFile, szUtf8ByteOrderHeader, sizeof(szUtf8ByteOrderHeader) - 1)) {
DisplayErrorDialog(LPGENW("Failed to UTF8 byte order code to file :\n"), sFilePath, nullptr);
@@ -941,7 +942,7 @@ bool ExportDBEventInfo(MCONTACT hContact, HANDLE hFile, wstring sFilePath, DBEVE // Get time stamp
int nIndent = mir_snwprintf(szTemp, L"%-*s", nFirstColumnWidth, dbei.flags & DBEF_SENT ? sLocalUser.c_str() : sRemoteUser.c_str());
- TimeZone_ToStringT(dbei.timestamp, sTimeFormat.c_str(), &szTemp[nIndent], _countof(szTemp) - nIndent - 2);
+ TimeZone_ToStringT(dbei.timestamp, g_sTimeFormat.c_str(), &szTemp[nIndent], _countof(szTemp) - nIndent - 2);
nIndent = (int)mir_wstrlen(szTemp);
szTemp[nIndent++] = ' ';
@@ -1134,7 +1135,7 @@ bool ExportDBEventInfo(MCONTACT hContact, HANDLE hFile, wstring sFilePath, DBEVE bWriteTextToFile(hFile, szTemp, bWriteUTF8Format, n);
}
- bWriteToFile(hFile, bAppendNewLine ? "\r\n\r\n" : "\r\n");
+ bWriteToFile(hFile, g_bAppendNewLine ? "\r\n\r\n" : "\r\n");
UpdateFileViews(sFilePath.c_str());
return true;
}
@@ -1351,7 +1352,7 @@ int nContactDeleted(WPARAM wparam, LPARAM /*lparam*/) if (hInternalWindow)
CloseWindow(hInternalWindow);
- if (enDeleteAction == eDANothing)
+ if (g_enDeleteAction == eDANothing)
return 0;
wstring sFilePath = GetFilePathFromUser(hContact);
@@ -1377,7 +1378,7 @@ int nContactDeleted(WPARAM wparam, LPARAM /*lparam*/) mir_snwprintf(szTemp, L"%s\r\n%s",
TranslateT("User has been deleted. Do you want to delete the file?"), sFilePath.c_str());
- if (enDeleteAction == eDAAutomatic ||
+ if (g_enDeleteAction == eDAAutomatic ||
MessageBox(nullptr, szTemp, MSG_BOX_TITEL, MB_YESNO) == IDYES) {
if (!DeleteFile(sFilePath.c_str())) {
mir_snwprintf(szTemp,
@@ -1393,37 +1394,6 @@ int nContactDeleted(WPARAM wparam, LPARAM /*lparam*/) }
/////////////////////////////////////////////////////////////////////
-// Member Function : SaveSettings
-// Type : Global
-// Parameters : None
-// Returns : void
-// Description : Save Settings
-//
-// References : -
-// Remarks : -
-// Created : 020429, 29 April 2002
-// Developer : KN
-/////////////////////////////////////////////////////////////////////
-
-void SaveSettings()
-{
- db_set_w(NULL, MODULENAME, "MaxLineWidth", (WORD)nMaxLineWidth);
- db_set_ws(NULL, MODULENAME, "ExportDir", sExportDir.c_str());
- db_set_ws(NULL, MODULENAME, "DefaultFile", sDefaultFile.c_str());
- db_set_ws(NULL, MODULENAME, "TimeFormat", sTimeFormat.c_str());
-
- db_set_ws(NULL, MODULENAME, "FileViewerPrg", sFileViewerPrg.c_str());
- db_set_b(NULL, MODULENAME, "UseInternalViewer", bUseInternalViewer());
- db_set_b(NULL, MODULENAME, "ReplaceHistory", bReplaceHistory);
- db_set_b(NULL, MODULENAME, "AppendNewLine", bAppendNewLine);
- db_set_b(NULL, MODULENAME, "UseUtf8InNewFiles", bUseUtf8InNewFiles);
- db_set_b(NULL, MODULENAME, "UseLessAndGreaterInExport", bUseLessAndGreaterInExport);
-
- db_set_b(NULL, MODULENAME, "RenameAction", (BYTE)enRenameAction);
- db_set_b(NULL, MODULENAME, "DeleteAction", (BYTE)enDeleteAction);
-}
-
-/////////////////////////////////////////////////////////////////////
wchar_t* GetMyOwnNick(MCONTACT hContact)
{
diff --git a/plugins/Msg_Export/src/utils.h b/plugins/Msg_Export/src/utils.h index 2a725d2920..25b9fac08a 100755 --- a/plugins/Msg_Export/src/utils.h +++ b/plugins/Msg_Export/src/utils.h @@ -27,29 +27,27 @@ enum ENDialogAction eDANothing
};
-extern ENDialogAction enRenameAction;
-extern ENDialogAction enDeleteAction;
+extern ENDialogAction g_enRenameAction;
+extern ENDialogAction g_enDeleteAction;
extern int nMaxLineWidth;
-extern wstring sExportDir;
-extern wstring sDefaultFile;
-extern wstring sTimeFormat;
+extern wstring g_sExportDir;
+extern wstring g_sDefaultFile;
+extern wstring g_sTimeFormat;
extern map<wstring, string::size_type, less<wstring> > clFileTo1ColWidth;
-extern bool bAppendNewLine;
-extern bool bUseUtf8InNewFiles;
-extern bool bUseLessAndGreaterInExport;
+extern bool g_bAppendNewLine;
+extern bool g_bUseJson;
+extern bool g_bUseUtf8InNewFiles;
+extern bool g_bUseLessAndGreaterInExport;
-extern bool bReplaceHistory;
+extern bool g_bReplaceHistory;
wstring sGetErrorString(DWORD dwError);
wstring sGetErrorString();
void DisplayLastError(const wchar_t *pszError);
void DisplayErrorDialog(const wchar_t *pszError, wstring &sFilePath, DBEVENTINFO *dbei);
-void SaveSettings();
-void ShowDebugInfo();
-
bool bIsExportEnabled(MCONTACT hContact);
HANDLE openCreateFile(wstring sFilePath);
bool bExportEvent(MCONTACT hContact, MEVENT hDbEvent, HANDLE hFile, wstring sFilePath, bool bAppendOnly);
|