diff options
Diffstat (limited to 'Plugins')
-rw-r--r-- | Plugins/historylog/Docs/historylog_changelog.txt | 6 | ||||
-rw-r--r-- | Plugins/historylog/Docs/historylog_readme.txt | 10 | ||||
-rw-r--r-- | Plugins/historylog/Docs/historylog_version.txt | 2 | ||||
-rw-r--r-- | Plugins/historylog/historylog.cpp | 166 | ||||
-rw-r--r-- | Plugins/historylog/options.cpp | 7 | ||||
-rw-r--r-- | Plugins/historylog/options.h | 1 | ||||
-rw-r--r-- | Plugins/historylog/resource.h | 5 | ||||
-rw-r--r-- | Plugins/historylog/resource.rc | 7 |
8 files changed, 181 insertions, 23 deletions
diff --git a/Plugins/historylog/Docs/historylog_changelog.txt b/Plugins/historylog/Docs/historylog_changelog.txt index 34a736c..aa1b65e 100644 --- a/Plugins/historylog/Docs/historylog_changelog.txt +++ b/Plugins/historylog/Docs/historylog_changelog.txt @@ -2,5 +2,11 @@ History Log Changelog:
+. 0.0.0.2
+ * Fix for multi-line messages (closes #41)
+ + Added new variables to filename (closes #44)
+ + Added option to ident multi-line messages (closes #43)
+ * Fix for invalid chars in msgs filename
+
. 0.0.0.1
+ Initial version
\ No newline at end of file diff --git a/Plugins/historylog/Docs/historylog_readme.txt b/Plugins/historylog/Docs/historylog_readme.txt index ee7b3e6..d964cfc 100644 --- a/Plugins/historylog/Docs/historylog_readme.txt +++ b/Plugins/historylog/Docs/historylog_readme.txt @@ -5,6 +5,16 @@ CAUTION: THIS IS ALPHA QUALITY SOFTWARE. USE AT YOUR OWN RISK. This is a plugin that logs to a text file all messages exchanged with contact. The text file is encoded in UTF-8. It can't handle group chat.
+The filename pattern accepts the following vars: (also, it support variables plugin)
+ %contact%
+ %contact_id%
+ %protocol%
+ %group%
+ %year%
+ %month%
+ %month_name%
+ %day%
+
This plugin requires at least Miranda 0.7 and needs History Events to work.
To report bugs/make suggestions, go to the forum thread: http://forums.miranda-im.org/showthread.php?t=18488
diff --git a/Plugins/historylog/Docs/historylog_version.txt b/Plugins/historylog/Docs/historylog_version.txt index 1a63d93..46d219a 100644 --- a/Plugins/historylog/Docs/historylog_version.txt +++ b/Plugins/historylog/Docs/historylog_version.txt @@ -1 +1 @@ -HistoryLog 0.0.0.1
\ No newline at end of file +HistoryLog 0.0.0.2
\ No newline at end of file diff --git a/Plugins/historylog/historylog.cpp b/Plugins/historylog/historylog.cpp index 0f28077..85e22a0 100644 --- a/Plugins/historylog/historylog.cpp +++ b/Plugins/historylog/historylog.cpp @@ -1,5 +1,5 @@ /*
-Copyright (C) 2006 Ricardo Pescuma Domenecci
+Copyright (C) 2008 Ricardo Pescuma Domenecci
This is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
@@ -31,7 +31,7 @@ PLUGININFOEX pluginInfo={ #else
"History Log",
#endif
- PLUGIN_MAKE_VERSION(0,0,0,1),
+ PLUGIN_MAKE_VERSION(0,0,0,2),
"Logs history events to disk on the fly",
"Ricardo Pescuma Domenecci",
"",
@@ -252,6 +252,105 @@ int DbEventAdded(WPARAM wParam, LPARAM lParam) }
+int GetUIDFromHContact(HANDLE contact, TCHAR* uinout, size_t uinout_len)
+{
+ CONTACTINFO cinfo;
+
+ ZeroMemory(&cinfo,sizeof(CONTACTINFO));
+ cinfo.cbSize = sizeof(CONTACTINFO);
+ cinfo.hContact = contact;
+ cinfo.dwFlag = CNF_UNIQUEID;
+#ifdef UNICODE
+ cinfo.dwFlag |= CNF_UNICODE;
+#endif
+
+ BOOL found = TRUE;
+ if(CallService(MS_CONTACT_GETCONTACTINFO,0,(LPARAM)&cinfo)==0)
+ {
+ if(cinfo.type == CNFT_ASCIIZ)
+ {
+ lstrcpyn(uinout, cinfo.pszVal, uinout_len);
+ mir_free(cinfo.pszVal);
+ }
+ else if(cinfo.type == CNFT_DWORD)
+ {
+ _itot(cinfo.dVal,uinout,10);
+ }
+ else if(cinfo.type == CNFT_WORD)
+ {
+ _itot(cinfo.wVal,uinout,10);
+ }
+ else found = FALSE;
+ }
+ else found = FALSE;
+
+ if (!found)
+ {
+#ifdef UNICODE
+ // Try non unicode ver
+ cinfo.dwFlag = CNF_UNIQUEID;
+
+ found = TRUE;
+ if(CallService(MS_CONTACT_GETCONTACTINFO,0,(LPARAM)&cinfo)==0)
+ {
+ if(cinfo.type == CNFT_ASCIIZ)
+ {
+ MultiByteToWideChar(CP_ACP, 0, (char *) cinfo.pszVal, -1, uinout, uinout_len);
+ mir_free(cinfo.pszVal);
+ }
+ else if(cinfo.type == CNFT_DWORD)
+ {
+ _itot(cinfo.dVal,uinout,10);
+ }
+ else if(cinfo.type == CNFT_WORD)
+ {
+ _itot(cinfo.wVal,uinout,10);
+ }
+ else found = FALSE;
+ }
+ else found = FALSE;
+
+ if (!found)
+#endif
+ lstrcpy(uinout, TranslateT("Unknown UIN"));
+ }
+ return 0;
+}
+
+
+void GetDateTexts(DWORD timestamp, TCHAR year[16], TCHAR month[16], TCHAR month_name[32], TCHAR day[16])
+{
+ LARGE_INTEGER liFiletime;
+ FILETIME filetime;
+ SYSTEMTIME st;
+ liFiletime.QuadPart=((__int64)11644473600+(__int64)(DWORD)CallService(MS_DB_TIME_TIMESTAMPTOLOCAL, timestamp, 0))*10000000;
+ filetime.dwHighDateTime=liFiletime.HighPart;
+ filetime.dwLowDateTime=liFiletime.LowPart;
+ FileTimeToSystemTime(&filetime,&st);
+
+ GetDateFormat(LOCALE_USER_DEFAULT, 0, &st, _T("yyyy"), year, MAX_REGS(year));
+ GetDateFormat(LOCALE_USER_DEFAULT, 0, &st, _T("MM"), month, MAX_REGS(month));
+ GetDateFormat(LOCALE_USER_DEFAULT, 0, &st, _T("MMMM"), month_name, MAX_REGS(month_name));
+ GetDateFormat(LOCALE_USER_DEFAULT, 0, &st, _T("dd"), day, MAX_REGS(day));
+}
+
+
+TCHAR * GetContactGroup(HANDLE hContact)
+{
+ TCHAR *group = NULL;
+
+ DBVARIANT db = {0};
+ if (DBGetContactSettingTString(hContact, "CList", "Group", &db) == 0)
+ {
+ if (db.ptszVal != NULL)
+ group = mir_tstrdup(db.ptszVal);
+ DBFreeVariant(&db);
+ }
+
+ return group;
+}
+
+
void ProcessEvent(HANDLE hDbEvent, void *param)
{
HANDLE hContact = (HANDLE) param;
@@ -321,7 +420,28 @@ void ProcessEvent(HANDLE hDbEvent, void *param) text.append(_T(": "));
}
- text.append(eventText);
+ size_t spaces = text.len;
+ for(TCHAR *c = eventText; *c != NULL; c++)
+ {
+ if (*c == _T('\r'))
+ {
+ if (*(c+1) == _T('\n'))
+ continue;
+ else
+ *c = _T('\n');
+ }
+ if (*c == _T('\n'))
+ {
+ text.append(_T("\r\n"));
+ if (opts.ident_multiline_msgs)
+ text.appendn(spaces, _T(' '));
+ }
+ else
+ {
+ text.append(*c);
+ }
+ }
+// text.append(eventText);
text.pack();
char path[1024];
@@ -331,22 +451,40 @@ void ProcessEvent(HANDLE hDbEvent, void *param) filename.append(path);
filename.append(_T("\\"));
+ TCHAR year[16];
+ TCHAR month[16];
+ TCHAR month_name[32];
+ TCHAR day[16];
+ GetDateTexts(dbe.timestamp, year, month, month_name, day);
+
TCHAR *protocol = mir_a2t(proto);
- TCHAR *group = NULL;
- DBVARIANT db = {0};
- if (DBGetContactSettingTString(hContact, "CList", "Group", &db) == 0)
- {
- if (db.ptszVal != NULL)
- group = mir_tstrdup(db.ptszVal);
- DBFreeVariant(&db);
- }
+ TCHAR *group = GetContactGroup(hContact);
+
+ TCHAR cid[512];
+ GetUIDFromHContact(hContact, cid, MAX_REGS(cid));
TCHAR *vars[] = {
_T("group"), group == NULL ? _T("") : group,
- _T("protocol"), protocol
+ _T("protocol"), protocol,
+ _T("year"), year,
+ _T("month"), month,
+ _T("month_name"), month_name,
+ _T("day"), day,
+ _T("contact_id"), cid
};
ReplaceTemplate(&filename, hContact, opts.filename_pattern, vars, MAX_REGS(vars));
+
+ filename.replaceAll(_T('\\'), _T('_'));
+ filename.replaceAll(_T('/'), _T('_'));
+ filename.replaceAll(_T(':'), _T('_'));
+ filename.replaceAll(_T('*'), _T('_'));
+ filename.replaceAll(_T('?'), _T('_'));
+ filename.replaceAll(_T('"'), _T('_'));
+ filename.replaceAll(_T('<'), _T('_'));
+ filename.replaceAll(_T('>'), _T('_'));
+ filename.replaceAll(_T('|'), _T('_'));
+
filename.pack();
// Assert folder exists
@@ -361,11 +499,11 @@ void ProcessEvent(HANDLE hDbEvent, void *param) p = _tcschr(p+1, _T('\\'));
}
- FILE *out = _tfopen(filename.str, _T("a"));
+ FILE *out = _tfopen(filename.str, _T("ab"));
if (out != NULL)
{
char *utf = mir_utf8encodeT(text.str);
- fprintf(out, "%s\n", utf);
+ fprintf(out, "%s\r\n", utf);
mir_free(utf);
fclose(out);
}
diff --git a/Plugins/historylog/options.cpp b/Plugins/historylog/options.cpp index c942601..1773201 100644 --- a/Plugins/historylog/options.cpp +++ b/Plugins/historylog/options.cpp @@ -1,5 +1,5 @@ /*
-Copyright (C) 2006 Ricardo Pescuma Domenecci
+Copyright (C) 2008 Ricardo Pescuma Domenecci
This is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
@@ -41,8 +41,9 @@ BOOL AllowProtocol(const char *proto) static OptPageControl optionsControls[] = {
- { &opts.filename_pattern, CONTROL_TEXT, IDC_FILENAME, "FilenamePattern", (DWORD) _T("Log\\%group%\\%contact%.msgs") },
- { NULL, CONTROL_PROTOCOL_LIST, IDC_PROTOCOLS, "Enable%s", TRUE, (int)AllowProtocol }
+ { &opts.filename_pattern, CONTROL_TEXT, IDC_FILENAME, "FilenamePattern", (DWORD) _T("Log\\%group%\\%contact%.msgs") },
+ { &opts.ident_multiline_msgs, CONTROL_CHECKBOX, IDC_IDENT_MULTILINE,"IdentMultilineMsgs", TRUE },
+ { NULL, CONTROL_PROTOCOL_LIST, IDC_PROTOCOLS, "Enable%s", TRUE, (int)AllowProtocol }
};
diff --git a/Plugins/historylog/options.h b/Plugins/historylog/options.h index 9df762c..e0b327b 100644 --- a/Plugins/historylog/options.h +++ b/Plugins/historylog/options.h @@ -28,6 +28,7 @@ Boston, MA 02111-1307, USA. typedef struct
{
TCHAR filename_pattern[1024];
+ BYTE ident_multiline_msgs;
} Options;
diff --git a/Plugins/historylog/resource.h b/Plugins/historylog/resource.h index 0597ded..5e20b99 100644 --- a/Plugins/historylog/resource.h +++ b/Plugins/historylog/resource.h @@ -73,8 +73,9 @@ #define IDC_NAME_L 1101
#define IDC_EVENT_TYPES 1102
#define IDC_COMBO1 1103
-#define IDC_EDIT1 1104
#define IDC_FILENAME 1104
+#define IDC_CHECK1 1105
+#define IDC_IDENT_MULTILINE 1105
#define IDC_STATIC -1
// Next default values for new objects
@@ -85,7 +86,7 @@ #define _APS_3D_CONTROLS 1
#define _APS_NEXT_RESOURCE_VALUE 126
#define _APS_NEXT_COMMAND_VALUE 40004
-#define _APS_NEXT_CONTROL_VALUE 1105
+#define _APS_NEXT_CONTROL_VALUE 1106
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
diff --git a/Plugins/historylog/resource.rc b/Plugins/historylog/resource.rc index 7de4c7d..6e5ca07 100644 --- a/Plugins/historylog/resource.rc +++ b/Plugins/historylog/resource.rc @@ -34,9 +34,10 @@ FONT 8, "MS Shell Dlg", 0, 0, 0x1 BEGIN
LTEXT "Filename pattern:",IDC_STATIC,5,5,76,11
EDITTEXT IDC_FILENAME,87,3,193,14,ES_AUTOHSCROLL
- LTEXT "Only log for these protocols:",IDC_STATIC,5,26,282,9
- CONTROL "",IDC_PROTOCOLS,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_SORTASCENDING | LVS_NOCOLUMNHEADER | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP,13,38,142,55
- LTEXT "Only these event types:",IDC_EVENT_TYPES,5,104,272,10
+ LTEXT "Only log for these protocols:",IDC_STATIC,5,42,275,9
+ CONTROL "",IDC_PROTOCOLS,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_SORTASCENDING | LVS_NOCOLUMNHEADER | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP,13,54,142,55
+ LTEXT "Only these event types:",IDC_EVENT_TYPES,5,120,275,10
+ CONTROL "Ident multi-line messages",IDC_IDENT_MULTILINE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,5,23,275,12
END
|