diff options
author | Robert Pösel <robyer@seznam.cz> | 2017-02-06 02:30:46 +0100 |
---|---|---|
committer | Robert Pösel <robyer@seznam.cz> | 2017-02-06 02:45:27 +0100 |
commit | d980ff0b1d69136793e39f4b67c6db4164742326 (patch) | |
tree | f1dc677355fbea745e5f0bb3d3447e1111774a25 /plugins/Msg_Export | |
parent | c87d46c2af765e61b64dfb0859760b46cb432a59 (diff) |
Msg_Export: Don't block whole Miranda during export
Diffstat (limited to 'plugins/Msg_Export')
-rwxr-xr-x | plugins/Msg_Export/res/resource.rc | 3 | ||||
-rwxr-xr-x | plugins/Msg_Export/src/options.cpp | 120 |
2 files changed, 75 insertions, 48 deletions
diff --git a/plugins/Msg_Export/res/resource.rc b/plugins/Msg_Export/res/resource.rc index be7e33ec6f..99a517a8b9 100755 --- a/plugins/Msg_Export/res/resource.rc +++ b/plugins/Msg_Export/res/resource.rc @@ -84,8 +84,7 @@ BEGIN END
IDD_EXPORT_ALL_DLG DIALOGEX 0, 0, 252, 46
-STYLE DS_SETFONT | WS_POPUP | WS_CAPTION
-EXSTYLE WS_EX_TOOLWINDOW
+STYLE DS_SETFONT | DS_CENTER | WS_POPUP | WS_CAPTION
CAPTION "Exporting old messages"
FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN
diff --git a/plugins/Msg_Export/src/options.cpp b/plugins/Msg_Export/src/options.cpp index 6dff0ee80d..0f2c960192 100755 --- a/plugins/Msg_Export/src/options.cpp +++ b/plugins/Msg_Export/src/options.cpp @@ -142,73 +142,39 @@ INT_PTR CALLBACK __stdcall DialogProc( return FALSE;
}
-/////////////////////////////////////////////////////////////////////
-// 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)
+void exportContactsMessages(void *p)
{
- HWND hMapUser = GetDlgItem(hParent, IDC_MAP_USER_LIST);
-
- int nTotalContacts = ListView_GetItemCount(hMapUser);
-
- int nContacts;
- if (bOnlySelected)
- nContacts = ListView_GetSelectedCount(hMapUser);
- else
- nContacts = nTotalContacts;
-
- if (!hMapUser || nContacts <= 0) {
- MessageBox(hParent, TranslateT("No contacts found to export"), MSG_BOX_TITEL, MB_OK);
- return 0;
- }
+ list< MCONTACT > *contacts = (list< MCONTACT >*)p;
+ HWND hParent = NULL;
HWND hDlg = CreateDialog(hInstance, MAKEINTRESOURCE(IDD_EXPORT_ALL_DLG), hParent, DialogProc);
HWND hProg = GetDlgItem(hDlg, IDC_EXPORT_PROGRESS);
HWND hStatus = GetDlgItem(hDlg, IDC_EXP_ALL_STATUS);
- SendMessage(hProg, PBM_SETRANGE, 0, MAKELPARAM(0, nContacts));
+ SendMessage(hProg, PBM_SETRANGE, 0, MAKELPARAM(0, contacts->size() - 1));
SetWindowText(hStatus, TranslateT("Reading database information (Phase 1 of 2)"));
// position and show proigrassbar dialog
- RECT rParrent, rDlg;
+ /*RECT rParrent, rDlg;
if (GetWindowRect(hParent, &rParrent) && GetWindowRect(hDlg, &rDlg)) {
int x = ((rParrent.right + rParrent.left) / 2) - ((rDlg.right - rDlg.left) / 2);
int y = ((rParrent.bottom + rParrent.top) / 2) - ((rDlg.bottom - rDlg.top) / 2);
SetWindowPos(hDlg, 0, x, y, 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_SHOWWINDOW);
}
- else ShowWindow(hDlg, SW_SHOWNORMAL);
+ else*/ ShowWindow(hDlg, SW_SHOWNORMAL);
// map with list to stored all DB history before it is exported
map<tstring, list< CLDBEvent >, less<tstring> > AllEvents;
- {
+ {
// reading from the database !!!
LVITEM sItem = { 0 };
sItem.mask = LVIF_PARAM;
- for (int nCur = 0; nCur < nTotalContacts; nCur++) {
- if (bOnlySelected)
- if (!(ListView_GetItemState(hMapUser, nCur, LVIS_SELECTED) & LVIS_SELECTED))
- continue;
-
- sItem.iItem = nCur;
- if (!ListView_GetItem(hMapUser, &sItem)) {
- MessageBox(hParent, TranslateT("Failed to export at least one contact"), MSG_BOX_TITEL, MB_OK);
- continue;
- }
-
- MCONTACT hContact = (MCONTACT)sItem.lParam;
+ int nCur = 0;
+ list< MCONTACT >::const_iterator iterator;
+ for (iterator = contacts->begin(); iterator != contacts->end(); ++iterator) {
+ MCONTACT hContact = (*iterator);
// Check if we should ignore this contact/protocol
if (!bIsExportEnabled(hContact))
@@ -224,12 +190,17 @@ int nExportCompleatList(HWND hParent, bool bOnlySelected) SendMessage(hProg, PBM_SETPOS, nCur, 0);
RedrawWindow(hDlg, NULL, NULL, RDW_ALLCHILDREN | RDW_UPDATENOW);
+
+ nCur++;
}
+ // Free the list of contacts
+ contacts->clear();
+ delete contacts;
}
// window text update
SetWindowText(hStatus, TranslateT("Sorting and writing database information (Phase 2 of 2)"));
- SendMessage(hProg, PBM_SETRANGE, 0, MAKELPARAM(0, AllEvents.size()));
+ SendMessage(hProg, PBM_SETRANGE, 0, MAKELPARAM(0, AllEvents.size() - 1));
SendMessage(hProg, PBM_SETPOS, 0, 0);
// time to write to files !!!
@@ -268,9 +239,66 @@ int nExportCompleatList(HWND hParent, bool bOnlySelected) SendMessage(hProg, PBM_SETPOS, ++nCur, 0);
RedrawWindow(hDlg, NULL, NULL, RDW_ALLCHILDREN | RDW_UPDATENOW);
+ UpdateWindow(hDlg);
}
DestroyWindow(hDlg);
+}
+
+/////////////////////////////////////////////////////////////////////
+// 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);
+
+ int nTotalContacts = ListView_GetItemCount(hMapUser);
+
+ int nContacts;
+ if (bOnlySelected)
+ nContacts = ListView_GetSelectedCount(hMapUser);
+ else
+ nContacts = nTotalContacts;
+
+ if (!hMapUser || nContacts <= 0) {
+ MessageBox(hParent, TranslateT("No contacts found to export"), MSG_BOX_TITEL, MB_OK);
+ return 0;
+ }
+
+ // List all contacts to export
+ list<MCONTACT> *contacts = new list<MCONTACT>();
+ {
+ LVITEM sItem = { 0 };
+ sItem.mask = LVIF_PARAM;
+
+ for (int nCur = 0; nCur < nTotalContacts; nCur++) {
+ if (bOnlySelected)
+ if (!(ListView_GetItemState(hMapUser, nCur, LVIS_SELECTED) & LVIS_SELECTED))
+ continue;
+
+ sItem.iItem = nCur;
+ if (!ListView_GetItem(hMapUser, &sItem)) {
+ MessageBox(hParent, TranslateT("Failed to export at least one contact"), MSG_BOX_TITEL, MB_OK);
+ continue;
+ }
+
+ MCONTACT hContact = (MCONTACT)sItem.lParam;
+ contacts->push_back(hContact);
+ }
+ }
+
+ mir_forkthread(&exportContactsMessages, contacts);
return 0;
}
|