summaryrefslogtreecommitdiff
path: root/plugins/Msg_Export
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/Msg_Export')
-rwxr-xr-xplugins/Msg_Export/src/options.cpp4
-rwxr-xr-xplugins/Msg_Export/src/utils.cpp67
-rwxr-xr-xplugins/Msg_Export/src/utils.h1
3 files changed, 34 insertions, 38 deletions
diff --git a/plugins/Msg_Export/src/options.cpp b/plugins/Msg_Export/src/options.cpp
index cf55041001..d2a027545e 100755
--- a/plugins/Msg_Export/src/options.cpp
+++ b/plugins/Msg_Export/src/options.cpp
@@ -210,6 +210,10 @@ int nExportCompleatList(HWND hParent, bool bOnlySelected)
MCONTACT hContact = (MCONTACT)sItem.lParam;
+ // Check if we should ignore this contact/protocol
+ if (!bIsExportEnabled(hContact))
+ continue;
+
list<CLDBEvent> &rclCurList = AllEvents[GetFilePathFromUser(hContact)];
MEVENT hDbEvent = db_event_first(hContact);
diff --git a/plugins/Msg_Export/src/utils.cpp b/plugins/Msg_Export/src/utils.cpp
index 89388048ac..6f0a26d065 100755
--- a/plugins/Msg_Export/src/utils.cpp
+++ b/plugins/Msg_Export/src/utils.cpp
@@ -1204,50 +1204,44 @@ HANDLE openCreateFile(tstring sFilePath)
return hFile;
}
-int nExportEvent(WPARAM hContact, LPARAM hDbEvent)
+bool bIsExportEnabled(MCONTACT hContact)
{
if (!db_get_b(hContact, MODULE, "EnableLog", 1))
- return 0;
+ return false;
- DBEVENTINFO dbei = {};
- int nSize = db_event_getBlobSize(hDbEvent);
- if (nSize > 0) {
- dbei.cbBlob = nSize;
- dbei.pBlob = (PBYTE)malloc(dbei.cbBlob + 2);
- dbei.pBlob[dbei.cbBlob] = 0;
- dbei.pBlob[dbei.cbBlob + 1] = 0;
- // Double null terminate, this shut pervent most errors
- // where the blob received has an invalid format
- }
+ const char *szProto = GetContactProto(hContact);
+ char szTemp[500];
+ mir_snprintf(szTemp, "DisableProt_%s", szProto);
+ if (!db_get_b(NULL, MODULE, szTemp, 1))
+ return false;
- if (!db_event_get(hDbEvent, &dbei)) {
- // Open/create file for writing
- tstring sFilePath = GetFilePathFromUser(hContact);
- HANDLE hFile = openCreateFile(sFilePath);
- if (hFile == INVALID_HANDLE_VALUE) {
- DisplayErrorDialog(LPGENW("Failed to open or create file :\n"), sFilePath, NULL);
- }
- else {
- // Write the event
- char szTemp[500];
- mir_snprintf(szTemp, "DisableProt_%s", dbei.szModule);
- if (db_get_b(NULL, MODULE, szTemp, 1))
- ExportDBEventInfo(hContact, hFile, sFilePath, dbei);
-
- // Close the file
- CloseHandle(hFile);
- }
+ return true;
+}
+
+int nExportEvent(WPARAM hContact, LPARAM hDbEvent)
+{
+ if (!bIsExportEnabled(hContact))
+ return 0;
+
+ // Open/create file for writing
+ tstring sFilePath = GetFilePathFromUser(hContact);
+ HANDLE hFile = openCreateFile(sFilePath);
+ if (hFile == INVALID_HANDLE_VALUE) {
+ DisplayErrorDialog(LPGENW("Failed to open or create file :\n"), sFilePath, NULL);
+ return 0;
}
- if (dbei.pBlob)
- free(dbei.pBlob);
+
+ // Write the event
+ bExportEvent((MCONTACT)hContact, (MEVENT)hDbEvent, hFile, sFilePath);
+
+ // Close the file
+ CloseHandle(hFile);
+
return 0;
}
bool bExportEvent(MCONTACT hContact, MEVENT hDbEvent, HANDLE hFile, tstring sFilePath)
{
- if (!db_get_b(hContact, MODULE, "EnableLog", 1))
- return 0;
-
DBEVENTINFO dbei = {};
int nSize = db_event_getBlobSize(hDbEvent);
if (nSize > 0) {
@@ -1262,10 +1256,7 @@ bool bExportEvent(MCONTACT hContact, MEVENT hDbEvent, HANDLE hFile, tstring sFil
bool result = true;
if (!db_event_get(hDbEvent, &dbei)) {
// Write the event
- char szTemp[500];
- mir_snprintf(szTemp, "DisableProt_%s", dbei.szModule);
- if (db_get_b(NULL, MODULE, szTemp, 1))
- result = ExportDBEventInfo(hContact, hFile, sFilePath, dbei);
+ result = ExportDBEventInfo(hContact, hFile, sFilePath, dbei);
}
if (dbei.pBlob)
free(dbei.pBlob);
diff --git a/plugins/Msg_Export/src/utils.h b/plugins/Msg_Export/src/utils.h
index c4f318e133..de0055fccc 100755
--- a/plugins/Msg_Export/src/utils.h
+++ b/plugins/Msg_Export/src/utils.h
@@ -55,6 +55,7 @@ wchar_t *CheckedTranslate(const wchar_t *szEng, int nFormatCount = -1);
void SaveSettings();
void ShowDebugInfo();
+bool bIsExportEnabled(MCONTACT hContact);
HANDLE openCreateFile(tstring sFilePath);
bool bExportEvent(MCONTACT hContact, MEVENT hDbEvent, HANDLE hFile, tstring sFilePath);