summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xplugins/Msg_Export/src/options.cpp8
-rwxr-xr-xplugins/Msg_Export/src/utils.cpp13
-rwxr-xr-xplugins/Msg_Export/src/utils.h2
3 files changed, 16 insertions, 7 deletions
diff --git a/plugins/Msg_Export/src/options.cpp b/plugins/Msg_Export/src/options.cpp
index 7ae57f3afe..6dff0ee80d 100755
--- a/plugins/Msg_Export/src/options.cpp
+++ b/plugins/Msg_Export/src/options.cpp
@@ -249,12 +249,18 @@ int nExportCompleatList(HWND hParent, bool bOnlySelected)
continue;
}
+ // 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;
- if (!bExportEvent(hContact, hDbEvent, hFile, sFilePath))
+ if (!bExportEvent(hContact, hDbEvent, hFile, sFilePath, bAppendOnly))
break; // serious error, we should close the file and don't continue with it
+
+ // Set this flag, because we're appending to same file now
+ bAppendOnly = true;
}
// Close the file
diff --git a/plugins/Msg_Export/src/utils.cpp b/plugins/Msg_Export/src/utils.cpp
index f3296752ed..d56a396bfb 100755
--- a/plugins/Msg_Export/src/utils.cpp
+++ b/plugins/Msg_Export/src/utils.cpp
@@ -879,7 +879,7 @@ void DisplayErrorDialog(const wchar_t *pszError, tstring& sFilePath, DBEVENTINFO
// Developer : KN
/////////////////////////////////////////////////////////////////////
-bool ExportDBEventInfo(MCONTACT hContact, HANDLE hFile, tstring sFilePath, DBEVENTINFO &dbei)
+bool ExportDBEventInfo(MCONTACT hContact, HANDLE hFile, tstring sFilePath, DBEVENTINFO &dbei, bool bAppendOnly)
{
tstring sLocalUser;
tstring sRemoteUser;
@@ -901,7 +901,10 @@ bool ExportDBEventInfo(MCONTACT hContact, HANDLE hFile, tstring sFilePath, DBEVE
wchar_t szTemp[500];
bool bWriteUTF8Format = false;
- {
+ if (bAppendOnly) {
+ bWriteUTF8Format = bUseUtf8InNewFiles;
+ }
+ else {
DWORD dwHighSize = 0;
DWORD dwLowSize = GetFileSize(hFile, &dwHighSize);
@@ -1232,7 +1235,7 @@ int nExportEvent(WPARAM hContact, LPARAM hDbEvent)
}
// Write the event
- bExportEvent((MCONTACT)hContact, (MEVENT)hDbEvent, hFile, sFilePath);
+ bExportEvent((MCONTACT)hContact, (MEVENT)hDbEvent, hFile, sFilePath, false);
// Close the file
CloseHandle(hFile);
@@ -1240,7 +1243,7 @@ int nExportEvent(WPARAM hContact, LPARAM hDbEvent)
return 0;
}
-bool bExportEvent(MCONTACT hContact, MEVENT hDbEvent, HANDLE hFile, tstring sFilePath)
+bool bExportEvent(MCONTACT hContact, MEVENT hDbEvent, HANDLE hFile, tstring sFilePath, bool bAppendOnly)
{
DBEVENTINFO dbei = {};
int nSize = db_event_getBlobSize(hDbEvent);
@@ -1256,7 +1259,7 @@ bool bExportEvent(MCONTACT hContact, MEVENT hDbEvent, HANDLE hFile, tstring sFil
bool result = true;
if (!db_event_get(hDbEvent, &dbei)) {
// Write the event
- result = ExportDBEventInfo(hContact, hFile, sFilePath, dbei);
+ result = ExportDBEventInfo(hContact, hFile, sFilePath, dbei, bAppendOnly);
}
if (dbei.pBlob)
free(dbei.pBlob);
diff --git a/plugins/Msg_Export/src/utils.h b/plugins/Msg_Export/src/utils.h
index de0055fccc..6835ba182b 100755
--- a/plugins/Msg_Export/src/utils.h
+++ b/plugins/Msg_Export/src/utils.h
@@ -57,7 +57,7 @@ void ShowDebugInfo();
bool bIsExportEnabled(MCONTACT hContact);
HANDLE openCreateFile(tstring sFilePath);
-bool bExportEvent(MCONTACT hContact, MEVENT hDbEvent, HANDLE hFile, tstring sFilePath);
+bool bExportEvent(MCONTACT hContact, MEVENT hDbEvent, HANDLE hFile, tstring sFilePath, bool bAppendOnly);
int nExportEvent(WPARAM wparam, LPARAM lparam);
int nContactDeleted(WPARAM wparam, LPARAM lparam);