summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGluzskiy Alexandr <sss@sss.chaoslab.ru>2011-10-16 13:06:27 +0300
committerGluzskiy Alexandr <sss@sss.chaoslab.ru>2011-10-16 13:06:27 +0300
commiteb1a49653f9dc3fde2f3b631c537b69a6db729a2 (patch)
treeff74f48d93e89e4552390dd970418439983c7f2c
parent6ab8c4ff109bfeec0df3f840a85cb28ec5d38259 (diff)
msg_export pluginmsg_export
-rwxr-xr-xChangelog.txt399
-rwxr-xr-xFileViewer.cpp1424
-rwxr-xr-xFileViewer.h38
-rwxr-xr-xGlob.h29
-rwxr-xr-xUpgradeLog.XML12
-rwxr-xr-xexport_m.icobin0 -> 9062 bytes
-rw-r--r--includes/m_dos.h22
-rwxr-xr-xlangpack_msg_export.txt325
-rwxr-xr-xmain.cpp413
-rwxr-xr-xmsg_export.dep54
-rwxr-xr-xmsg_export.dsp236
-rwxr-xr-xmsg_export.dsw29
-rwxr-xr-xmsg_export.sln26
-rwxr-xr-xmsg_export.txt200
-rwxr-xr-xmsg_export.vcproj603
-rwxr-xr-xnotick.icobin0 -> 318 bytes
-rwxr-xr-xoptions.cpp1483
-rwxr-xr-xoptions.h26
-rwxr-xr-xresource.h59
-rwxr-xr-xresource.rc327
-rwxr-xr-xtick.icobin0 -> 318 bytes
-rwxr-xr-xutils.cpp1740
-rwxr-xr-xutils.h125
23 files changed, 7548 insertions, 22 deletions
diff --git a/Changelog.txt b/Changelog.txt
new file mode 100755
index 0000000..e099413
--- /dev/null
+++ b/Changelog.txt
@@ -0,0 +1,399 @@
+Mod by ring0
+=============================
+Version 3.1.0.3
+-Bug fix: UTF8 was decoded incorrectly
+
+
+Original version
+=============================
+Version 3.01.00
+-New : Compiled with VS2005
+-New : Compiled as Unicode
+-Changed : Ansi version will no longer read UTF8 event from the database
+
+
+Version 3.00.00
+
+-New : Export to UTF8 text files. ( Langpack updated )
+-New : When used with unicode version of miranda you can export unicode.
+-New : When %identifier% is used with a contact using jabber the Jabber ID is used.
+
+Version 2.15.01
+
+-Bug fix : Message Export2 in options was not translatable.
+
+Version 2.15.00
+
+-New : Select protocols to export. This should fix the double entries with metacontacts. ( Langpack updated )
+
+Version 2.14.03
+
+-Bug fix : Message window (SRMM) sends EVENTTYPE_STATUSCHANGE event this was logged as Unknowen event. It will be ignored.
+-Bug fix : If the internal file viewer window is closed while minimized it will not show next time it is opened.
+
+
+Version 2.14.02
+
+
+-Bug fix : %identifier% was only replaced for ICQ and MSN protocols. Now it will use %nick% if it is not one of those protocols
+
+
+Version 2.14.01
+
+
+-Bug fix : Backslash in user name was not replaced.
+
+
+Version 2.14.00
+
+
+-New : Clickable URIs in message history
+
+
+Version 2.13.00
+
+
+-New : Variable %year%, %month% and %day% in export path or file name.
+-Changed : Doc was updated.
+
+
+Version 2.12.00
+
+
+-New : Variable %identifier% in export path or file name.
+-New : Page in the options "Message Export2"
+-New : When the filename is changed the action can be set to Prompt, Rename or Nothing.
+-New : When the user is deleted the action can be set to Prompt, Delete or Nothing.
+-Changed : File size was decreased
+
+
+Version 2.11.00
+
+
+-When copying text from internal file viewer leading spaces after a new line will be removed.
+
+
+Version 2.10.00
+
+
+-Option to enable or disable history for every contact on the list. Default is enabled.
+-Added syntax highlighting for files with << and >> in the exported format.
+
+
+Version 2.09.00
+
+
+-Option to use << and >> in the exported format instead of the usual nick. ( Langpack updated )
+ Note Syntax highlighting will not work !! ( coming later )
+
+
+Version 2.08.01
+
+
+-Bug fix if you had multiply ICQ protocols the ICQ variables might not work.
+-Export file header now also includes the protocol for the contact.
+-Some ICQ dependencies removed.
+
+
+Version 2.08.00
+
+
+-Internal file viewer will not scroll to the bottom when a new event is added to the file.
+-Improvement in the "Auto filename". Only sets the filename if it's not already set. When a match is found it will set the filename for both contacts.
+
+
+Version 2.07.01
+
+
+-Bug fix If you export old history and you have more than 32768 events some of the history
+ will not be exportet. This was because of a bug in Microsoft STD.
+ Thanks Carl.
+
+
+Version 2.07.00
+
+
+IMPORTANT UPDATE !
+-Bug fix old history might be owerwritten by new history !!!
+If you history file has a size which can be divided by 65536.
+It will write new events in the beginning of the file.
+
+-Bug fix Apply Button was not enabled when "Set to default filename" was used.
+-Only prompts if you want to delete a file if there are no other contacts using it.
+-Code changed to compile with warning level 4.
+
+
+Version 2.06.00
+
+
+-Show User details in options. ( Langpack updated )
+
+
+Version 2.05.01
+
+
+-Bug fix : was not always being replaced causing file creation to fail.
+
+
+Version 2.05.00
+
+
+-WebPager support. ( Langpack updated )
+Will be exported to Current user File.
+You do not need to have the WebPager plugin, but if you dont you will not see
+that you have receive a WebPager message.
+
+
+Version 2.04.01
+
+
+-Bugfix: MSN file transfer event not same format as ICQ event.
+-Icon changed so that if you use Replace miranda history it will show ,
+msg_export icon in right click menu.
+
+
+Version 2.04.00
+
+
+-User defined file viewer.
+-Optional extra new line.
+-Added variable %protocol% in export path or file name.
+-Improved (Unknown Contact) handling.
+-Save as RTF, in the file viewer menu, this feature may be removed again.
+
+
+Version 2.03.00
+
+
+-Syntax highlighting ( in the internal file viewer )
+
+
+Version 2.02.00
+
+
+-Clicking the header in the options allows you to sort the user list by Nick, Proto or UIN.
+
+
+Version 2.01.00
+
+
+-Checks for errors in the language pack which may result in crashes.
+-When %UIN% can not be found %nick% is used
+-Many language pack strings removed.
+-New column in options with protocol.
+-Size optimized
+
+
+Version 2.00.00
+
+
+-Bugfix. The relative path detection had a flaw which causes it not to detect a relative path. When this happens the location of your exported files will change after a file transfer.
+
+
+Version 1.9.9
+
+
+If you are using 1.9.7 and not having any problems no need to update.
+
+-Bugfix. This bug is just way too stupid to describe. Let’s just say you don’t want to release crash testing code.
+
+
+Version 1.9.8
+
+
+If you are not having problems no need to update.
+
+-Added error dialog when used with Miranda 0.2.0.0 alpha, would otherwise crash at startup. ( Langpack updated )
+
+
+
+Version 1.9.7
+
+
+-Optional if you want a "Prompt to delete file" when you delete a contact. ( Langpack updated )
+
+
+Version 1.9.6
+
+
+-%e-mail% variable can be used to name files. If the user does not have one %nick% will be used. Supports ICQ and MSN.
+-"Set to default filename" allows you to set the file name on some users to what you have written in the “Default File” option.
+-Dialog if the path to Miranda.exe can not be found. This will result in the use of relative paths.
+-Debug button in options dialog will shows internal variables.
+
+
+Version 1.9.5
+
+
+-Question if you want to delete file when you delete contact. ( Langpack updated )
+-Bugfix: Ignore file change to (Unknown Contact) working when you have language pack installed.
+
+
+Version 1.9.4
+
+
+-File change detection / reload
+
+
+Version 1.9.3
+
+
+-Bugfix /*?<>|" was not beeing replaced (intruduced in 1.9.1) sorry about that.
+
+
+
+Version 1.9.2
+
+
+-If no file is found when using the internal file viewer, it will display file path and number of events in the Miranda database.
+-If something fails you can save debug information.
+-More fail checking in AUTHREQUEST or ADDED handling.
+
+
+
+Version 1.9.1
+
+
+-Font selection.
+-Bug fix : and " in User nick was not replaced causing file creation to fail.
+-Bug fix selecting new path with browse button did not enable apply button.
+
+
+
+Version 1.9.0
+
+
+-Background color selection.
+
+
+
+Version 1.8.0
+
+
+-FileName change detection.
+-File Viewer Font changed on Win 98 / NT 4.0, ( not changeable )
+
+
+Version 1.7.1
+
+
+-Fixed internal file viewer not working.
+-New Icon ( thanks to Muhannad )
+
+
+
+Version 1.7.0
+
+
+-Internal File Viewer
+-Your can replace miranda history with File viewer.
+
+
+Version 1.6.0
+
+
+- SMS support. You need the SMS plugin for this to work.
+It is only tested with LB_Sms Version 0.0.0.1
+
+
+Version 1.5.0
+
+
+- EmailExpress support. Will be exported to Current user File(your nick). You do not need to have the EmailExpress plugin, but if you dont you will not see that you have receive an EmailExpress message.
+
+
+Version 1.4.1
+
+
+- Fixed multi line File and URL descriptions was not indented.
+- Rewrite line splitting algorithm. Will now also split lines at ' ','?','-','.',','.
+- Default time format changes to “d s”
+- A few more error dialogs you properly will never see.
+
+
+
+Version 1.4.0
+
+
+-Variable %group% in export path
+-Export "authorization requests" to Current user file
+-Export "added to contact list" to Current user file
+-Export history for selected users.
+-Current user added to user list
+-Auto create export folders
+
+
+
+Version 1.3.0
+
+
+-Language pack support
+
+
+Version 1.2.1
+
+
+-Workaround for bug in Convers.dll
+
+
+Version 1.2.0
+
+
+-Bugfix for using relative paths
+-Default file name option (%UIN% / %nick%)
+-Dropdown listbox. (help)
+-Help file.
+-Help button.
+-Rebased ( 0x22100000 )
+
+
+Version 1.1.0(a)
+
+
+-Configurable output file for every user
+-Progress bar on Export All
+-Export All Sorting
+-Initial user info expanded.
+-More Error dialogs.
+-Auto file name
+-Some code cleaning
+(Updated preview)
+
+
+Version 1.1.0
+
+
+-Configurable output file for every user
+-Progress bar on Export All
+-Export All Sorting
+-Initial user info expanded.
+-More Error dialogs.
+-Auto file name
+-Some code cleaning
+
+
+
+Version 1.0.4
+
+
+-Bugfix for not loading on Windows 98 / 95 / ME
+
+
+Version 1.0.3
+
+
+-Added message boxes on all initilizing failures
+-Added browse button in options
+
+
+Version 1.0.2
+
+
+- Bug fix, the first character is missing on the second and subsequent lines.
+- added support for uninstall plugin
+
+
+Version 1.0.0
+
+
+-First release \ No newline at end of file
diff --git a/FileViewer.cpp b/FileViewer.cpp
new file mode 100755
index 0000000..f53d446
--- /dev/null
+++ b/FileViewer.cpp
@@ -0,0 +1,1424 @@
+
+//This file is part of Msg_Export a Miranda IM plugin
+//Copyright (C)2002 Kennet Nielsen ( http://sourceforge.net/projects/msg-export/ )
+//
+//This program is free software; you can redistribute it and/or
+//modify it under the terms of the GNU General Public License
+//as published by the Free Software Foundation; either
+//version 2 of the License, or (at your option) any later version.
+//
+//This program is distributed in the hope that it will be useful,
+//but WITHOUT ANY WARRANTY; without even the implied warranty of
+//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+//GNU General Public License for more details.
+//
+//You should have received a copy of the GNU General Public License
+//along with this program; if not, write to the Free Software
+//Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+
+#include <windows.h>
+#include <Richedit.h>
+
+#include <iostream>
+#include <fstream>
+
+using namespace std;
+
+
+#include "Utils.h"
+#include "Glob.h"
+#include "FileViewer.h"
+
+#include "resource.h"
+
+#include <stdio.h>
+#include <basetsd.h>
+
+//#include <map>
+
+#define szFileViewDB "FileV_"
+
+#define WM_RELOAD_FILE (WM_USER+10)
+
+using namespace std;
+
+static UINT UM_FIND_CMD = RegisterWindowMessage( FINDMSGSTRING );
+
+#define ID_FV_FONT 0x0010
+#define ID_FV_COLOR 0x0020
+#define ID_FV_SYNTAX_HL 0x0030
+#define ID_FV_SAVE_AS_RTF 0x0040
+// ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
+// ASSERT(IDM_ABOUTBOX < 0xF000);
+
+
+// Specifies if history is opened internaly or externaly
+bool bUseIntViewer = true;
+
+// External program used to view files
+tstring sFileViewerPrg;
+
+// handle to the RichEditDll. We need to load this dll to use a RichEdit.
+HMODULE hRichEditDll = NULL;
+
+
+#define CONT(i) ((in[i]&0xc0) == 0x80)
+#define VAL(i, s) ((in[i]&0x3f) << s)
+
+void swap(char &c1, char &c2) {
+ char ch;
+ ch=c1;
+ c1=c2;
+ c2=ch;
+}
+
+int DecodeUTF8(const char *pcBuff,int iBufSize,char *pcOutBuf) {
+ int iBytesInOut=0;
+ int cp,i;
+ char ch,*p;
+
+//Parse UTF-8 sequence
+//Support only chars up to three bytes (UCS-4 - go away!)
+//Warning: Partial decoding is possible!
+ i=0;
+ ch=pcBuff[i];
+ if(!(ch&0x80)) {
+ pcOutBuf[iBytesInOut++]=ch;
+ pcOutBuf[iBytesInOut++]='\0';
+ }
+ else if(!(ch&0x20)) {
+ pcOutBuf[iBytesInOut++]=(ch>>2)&0x07;
+ i++;
+ pcOutBuf[iBytesInOut++]=(pcBuff[i]&0x3F)|(ch<<6);
+ swap(pcOutBuf[iBytesInOut-1],pcOutBuf[iBytesInOut-2]);
+ }
+ else if(!(ch&0x10)) {
+ i++;
+
+ pcOutBuf[iBytesInOut++]=(ch<<4)|((pcBuff[i]>>2)&0x0F);
+ ch=pcBuff[i];
+ i++;
+ pcOutBuf[iBytesInOut++]=(pcBuff[i]&0x3F)|(ch<<6);
+ swap(pcOutBuf[iBytesInOut-1],pcOutBuf[iBytesInOut-2]);
+ }
+ else {
+ p=(char*)&pcBuff[i];
+ pcOutBuf[iBytesInOut++]='\x3F';
+ pcOutBuf[iBytesInOut++]='\0';
+ if(!(ch&0x08)) i+=3;
+ else if(!(ch&0x04)) i+=4;
+ else if(!(ch&0x02)) i+=5;
+ }
+
+ i++;
+
+ return i;
+}
+
+
+int __utf8_get_char(const char *in, int *chr)
+{ /* 2-byte, 0x80-0x7ff */
+ return DecodeUTF8(in,256,(char *)chr);
+}
+
+// there is one instance of CLHistoryDlg for every history dialog on screeen.
+class CLHistoryDlg
+{
+ public:
+ HWND hWnd;
+
+ HANDLE hContact;
+ tstring sPath;
+
+ WNDPROC wpOrigEditProc;
+
+ HWND hFindDlg;
+ FINDREPLACE fr;
+ _TCHAR acFindStr[100];
+
+ bool bFirstLoad;
+ bool bUtf8File;
+
+ CLHistoryDlg( HANDLE hContact ) : hContact( hContact )
+ {
+ hFindDlg = NULL;
+ acFindStr[0] = 0;
+ ZeroMemory( &fr , sizeof( fr ));
+ fr.lStructSize = sizeof( fr );
+ fr.hInstance = hInstance;
+ fr.Flags = FR_NOUPDOWN|FR_HIDEUPDOWN;//|FR_MATCHCASE|FR_WHOLEWORD;
+ // FR_DOWN|FR_FINDNEXT|FR_NOMATCHCASE;
+ fr.lpstrFindWhat = acFindStr;
+ fr.wFindWhatLen = sizeof(acFindStr);
+ bFirstLoad = true;
+ bUtf8File = false;
+ }
+};
+
+// List of all open history windows
+list< CLHistoryDlg* > clHistoryDlgList;
+// CRITICAL_SECTION used to access the window list
+// this is nesery because UpdateFileViews is called from callback thread.
+CRITICAL_SECTION csHistoryList;
+
+
+// CLStreamRTFInfo is used when reading RTF into rich edit from a stream.
+// RTF is used when Syntax highlighting is used.
+class CLStreamRTFInfo
+{
+ private:
+ HANDLE hFile;
+ bool bHeaderWriten;
+ bool bTailWriten;
+ bool bCheckFirstForNick;
+ bool bLastColorMyNick;
+
+ // buffer size supplyed on win XP 4092 byte when streamin in
+ // optimal size it to fully use this buffer but we can guess
+ // how may bytes need converting in the file we are reading.
+ BYTE abBuf[3300];
+ char szMyNick[100];
+ int nNickLen;
+ static int nOptimalReadLen;
+
+ int nWriteHeader( char * pszTarget , int nLen );
+ public:
+ bool bUtf8File;
+ CLStreamRTFInfo( HANDLE hFile )
+ {
+ this->hFile = hFile;
+ bHeaderWriten = false;
+ bTailWriten = false;
+ bCheckFirstForNick = false;
+ bLastColorMyNick = false;
+ bUtf8File = false;
+ nNickLen = 0;
+ }
+ int nLoadFileStream( LPBYTE pbBuff , LONG cb );
+};
+int CLStreamRTFInfo::nOptimalReadLen = 3300;
+
+/////////////////////////////////////////////////////////////////////
+// Member Function : nWriteHeader
+// Type : Private / Public / Protected
+// Parameters : pszTarget - ?
+// nLen - ?
+// Returns : int
+// Description :
+//
+// References : -
+// Remarks : -
+// Created : 030204 , 04 February 2003
+// Developer : KN
+/////////////////////////////////////////////////////////////////////
+
+int CLStreamRTFInfo::nWriteHeader( char * pszTarget , int nLen )
+{
+ COLORREF cMyText = DBGetContactSettingDword(NULL,"SRMsg","Font3Col",RGB(64,0,128));
+ COLORREF cYourText = DBGetContactSettingDword(NULL,"SRMsg","Font0Col",RGB(240,0,0));
+
+/* original header !!
+ "{\\rtf1\\ansi\\deff0{\\fonttbl{\\f0\\fnil\\fcharset0 Courier New;}}\r\n"
+ "{\\colortbl ;\\red%d\\green%d\\blue%d;\\red%d\\green%d\\blue%d;}\r\n"
+ "\\viewkind4\\uc1\\pard\\cf2\\lang1033\\f0\\fs16 " ,
+
+*/
+ char szRtfHeader[400];
+ int nSrcLen = _snprintf( szRtfHeader , sizeof( szRtfHeader ) ,
+ "{\\rtf1\\ansi\r\n"
+ "{\\colortbl ;\\red%d\\green%d\\blue%d;\\red%d\\green%d\\blue%d;}\r\n"
+ "\\viewkind4\\uc1\\pard\\cf2 " ,
+ GetRValue( cMyText ) ,GetGValue( cMyText ) ,GetBValue( cMyText ) ,
+ GetRValue( cYourText ) ,GetGValue( cYourText ) ,GetBValue( cYourText ) );
+
+ if( nSrcLen > nLen )
+ {
+ MessageBox( NULL , _T("Failed to write to the RichEdit the buffer was to small."),MSG_BOX_TITEL,MB_OK );
+ return 0; // target buffer to small
+ }
+
+ memcpy( pszTarget , szRtfHeader , nSrcLen );
+ bHeaderWriten = true;
+ return nSrcLen;
+}
+
+const char szNewLine[] = "\n\\par ";
+const char szRtfEnd[] = "\r\n\\par }\r\n\0";
+
+/////////////////////////////////////////////////////////////////////
+// Member Function : nLoadFileStream
+// Type : Private / Public / Protected
+// Parameters : pbBuff - ?
+// cb - ?
+// Returns : int
+// Description :
+//
+// References : -
+// Remarks : -
+// Created : 030204 , 04 February 2003
+// Developer : KN
+/////////////////////////////////////////////////////////////////////
+
+int CLStreamRTFInfo::nLoadFileStream( LPBYTE pbBuff , LONG cb )
+{
+ if( bTailWriten )
+ return 0;
+
+ if( nOptimalReadLen < 500 )
+ {
+ MessageBox( NULL , _T("Error: Optimal buffer size decrecied to a to low size !!"),MSG_BOX_TITEL,MB_OK );
+ return 0;
+ }
+
+ DWORD dwRead;
+ DWORD dwToRead = nOptimalReadLen;
+
+ if( ! ReadFile(hFile , abBuf, dwToRead , &dwRead, (LPOVERLAPPED)NULL) )
+ return 0;
+
+ DWORD dwCurrent = 0;
+ DWORD n = 0;
+ if( ! bHeaderWriten )
+ {
+ if( dwRead >= 3 )
+ {
+ bUtf8File = bIsUtf8Header( abBuf );
+ if( bUtf8File )
+ n = 3;
+ }
+ dwCurrent += nWriteHeader( (char*)pbBuff , cb );
+
+ tstring sMyNick = NickFromHandle(0);
+#ifdef _UNICODE
+ nNickLen = WideCharToMultiByte(bUtf8File ? CP_UTF8 : CP_ACP , 0, sMyNick.c_str(), sMyNick.length() , szMyNick , sizeof( szMyNick ), NULL , NULL );
+#else
+ strcpy( szMyNick , sMyNick.c_str() );
+ nNickLen = sMyNick.length();
+#endif
+ }
+ else
+ {
+ if( bCheckFirstForNick )
+ {
+ // Test against "<<" also
+ if( ( (memcmp( abBuf , szMyNick , nNickLen ) == 0) ||
+ (abBuf[0] == '<' && abBuf[1] == '<')
+ ) != bLastColorMyNick )
+ {
+ // we shut only get here if we need to change color !!
+ bLastColorMyNick = !bLastColorMyNick;
+ // change color
+ memcpy( &pbBuff[dwCurrent] , bLastColorMyNick ? "\\cf1 " : "\\cf2 ", 5 );
+ }
+ bCheckFirstForNick = false;
+ }
+ }
+
+ bool bIsFileEnd = dwRead < dwToRead;
+
+ for( ; n < dwRead ; n++ )
+ {
+ // worst case is a file ending with \n or a unicode letter. resulting in a big unicode string
+ // here we need szNewLine and szRtfEnd. the 10 is a small safty margin.
+ if( dwCurrent + (sizeof( szNewLine ) + sizeof( szRtfEnd ) + 10 ) > (DWORD)cb )
+ {
+ // oh no !!! we have almost reached the end of the windows supplyed buffer
+ // we are writing to. we need to abort mision *S*!!
+ // and rewinde file
+ // we will adjust the optima buffer size
+ nOptimalReadLen -= 50;
+ SetFilePointer( hFile , n - dwRead , NULL , FILE_CURRENT );
+ return dwCurrent;
+ }
+
+ if( abBuf[n] == '\n' )
+ {
+ memcpy( &pbBuff[dwCurrent] , szNewLine , sizeof( szNewLine )-1 );
+ dwCurrent += sizeof( szNewLine )-1;
+
+ if( n + 1 >= dwRead )
+ {
+ // this is an anoing case because here we have read \n as the last char in the file
+ // this means that the if the next data read from file begins with <UserNick> it has
+ // to be highlighted
+ if( !bIsFileEnd )
+ bCheckFirstForNick = true;
+ break;
+ }
+
+ if( abBuf[n+1] == ' ' || abBuf[n+1] == '\t' || abBuf[n+1] == '\r' )
+ continue;
+
+ if( n + nNickLen >= dwRead )
+ {
+ if( !bIsFileEnd )
+ {
+ // here we have a problem we haven't read this data yet
+ // the data we need to compare to is still in the file.
+ // we can't read more data from the file because the we
+ // might just move the problem. if file contains \n\n\n\n\n ...
+
+ LONG lExtraRead = (n+1) - dwRead;
+ if( lExtraRead >= 0 )
+ MessageBox( NULL , _T("Internal error !! (lExtraRead >= 0)"),MSG_BOX_TITEL,MB_OK );
+ SetFilePointer( hFile , lExtraRead , NULL , FILE_CURRENT );
+ bCheckFirstForNick = true;
+ return dwCurrent;
+ }
+
+ if( ! bLastColorMyNick )
+ continue;
+ // else the last color user was my nick
+ // we needd to change color to the other user color.
+
+
+ /* old code !!
+ DWORD dwAddedToBuf;
+ if( ! ReadFile(hFile , &abBuf[dwRead], dwNeeded , &dwAddedToBuf, (LPOVERLAPPED)NULL) )
+ return 0;
+ dwToRead += dwNeeded;
+ dwRead += dwAddedToBuf;*/
+ }
+ else
+ {
+ // the data we need is here just compare
+ if( ( ( memcmp( &abBuf[n+1] , szMyNick , nNickLen ) == 0) ||
+ ( abBuf[n+1] == '<' && abBuf[n+2] == '<')
+ ) == bLastColorMyNick )
+ continue;
+ }
+ // we shut only get here if we need to change color !!
+ bLastColorMyNick = !bLastColorMyNick;
+
+ // change color
+ memcpy( &pbBuff[dwCurrent] , bLastColorMyNick ? "\\cf1 " : "\\cf2 ", 5 );
+ dwCurrent += 5;
+ continue;
+ }
+ else if( abBuf[n] == '\\' || abBuf[n] == '}' || abBuf[n] == '{')
+ {
+ pbBuff[dwCurrent++]='\\';
+ }
+ else if( bUtf8File && (abBuf[n] & 0x80) )
+ {
+ int nValue;
+ int nLen = __utf8_get_char( (const char *)&abBuf[n] , &nValue );
+ if(nLen+n>dwRead) {
+ SetFilePointer(hFile,n-dwRead,NULL,FILE_CURRENT);
+ break;
+ }
+ dwCurrent += sprintf( (char*)&pbBuff[dwCurrent] , "\\u%d?" , nValue );
+ //continue;
+/* // Then we have an extended char in the UTF8 file.
+ // we need to convert this to UCS-2 and then to \uN in the RTF
+ int nUtf8Len = 1;
+ while( ( (n + nUtf8Len) < dwRead ) && ((abBuf[ n + nUtf8Len ] & 0xC0) == 0x80) )
+ nUtf8Len++;
+ wchar_t szWstr[2];
+ if( MultiByteToWideChar( CP_UTF8 , 0 , (char*)&abBuf[n] , nUtf8Len , szWstr , 2 ) == 1 )
+ {
+ if( (int)(szWstr[0]) != nValue )
+ __utf8_get_char( (const char *)&abBuf[n] , &nValue );
+
+// dwCurrent += sprintf( (char*)&pbBuff[dwCurrent] , "\\u%d?" , (int)(szWstr[0]) );
+// n += nUtf8Len - 1;
+// continue;
+ }*/
+ n += nLen-1;
+ continue;
+ }
+ pbBuff[dwCurrent++] = abBuf[n];
+ }
+
+ if( bIsFileEnd )
+ {// write end
+ memcpy( &pbBuff[dwCurrent] , szRtfEnd , sizeof( szRtfEnd )-1 );
+ dwCurrent += sizeof( szRtfEnd )-1;
+ bTailWriten = true;
+ }
+ //memcpy( pbBuff , abBuf , dwRead );
+ return dwCurrent;
+}
+
+
+/////////////////////////////////////////////////////////////////////
+// Member Function : Initilize
+// Type : Global
+// Parameters : None
+// Returns : void
+// Description :
+//
+// References : -
+// Remarks : -
+// Created : 021213 , 13 December 2002
+// Developer : KN
+/////////////////////////////////////////////////////////////////////
+
+void Initilize()
+{
+ InitializeCriticalSection( &csHistoryList );
+}
+
+/////////////////////////////////////////////////////////////////////
+// Member Function : Uninitilize
+// Type : Global
+// Parameters : None
+// Returns : void
+// Description :
+//
+// References : -
+// Remarks : -
+// Created : 021213 , 13 December 2002
+// Developer : KN
+/////////////////////////////////////////////////////////////////////
+
+void Uninitilize()
+{
+ DeleteCriticalSection( &csHistoryList );
+}
+
+/////////////////////////////////////////////////////////////////////
+// Member Function : UpdateFileViews
+// Type : Global
+// Parameters : pszFile - File which has been updated
+// Returns : void
+// Description : Send a message to alle to windows that need updating
+//
+// References : -
+// Remarks : -
+// Created : 021213 , 13 December 2002
+// Developer : KN
+/////////////////////////////////////////////////////////////////////
+
+void UpdateFileViews( const _TCHAR * pszFile )
+{
+ EnterCriticalSection( &csHistoryList );
+
+ list< CLHistoryDlg* >::const_iterator iterator;
+ for( iterator = clHistoryDlgList.begin() ; iterator != clHistoryDlgList.end() ; ++iterator )
+ {
+ CLHistoryDlg* pcl = (*iterator);
+ if( pcl->sPath == pszFile )
+ {
+ PostMessage( pcl->hWnd , WM_RELOAD_FILE , 0 , 0 );
+ }
+ }
+ LeaveCriticalSection( &csHistoryList );
+}
+
+/////////////////////////////////////////////////////////////////////
+// Member Function : bOpenExternaly
+// Type : Global
+// Parameters : hContact - ?
+// Returns : Returns true if
+// Description :
+//
+// References : -
+// Remarks : -
+// Created : 021010 , 10 October 2002
+// Developer : KN
+/////////////////////////////////////////////////////////////////////
+
+bool bOpenExternaly( HANDLE hContact )
+{
+ tstring sPath = GetFilePathFromUser( hContact );
+
+ if( sFileViewerPrg.empty() )
+ {
+ SHELLEXECUTEINFO st = {0};
+ st.cbSize = sizeof(st);
+ st.fMask = SEE_MASK_INVOKEIDLIST;
+ st.hwnd = NULL;
+ st.lpFile = sPath.c_str();
+ st.nShow = SW_SHOWDEFAULT;
+ ShellExecuteEx(&st);
+ return true;
+ }
+ tstring sTmp = sFileViewerPrg;
+ sTmp += _T(" ");
+ sTmp += sPath;
+ //sTmp += '\"';
+
+ STARTUPINFO sStartupInfo = { 0 };
+ GetStartupInfo(&sStartupInfo); // we parse oure owne info on
+ sStartupInfo.lpTitle = (_TCHAR*)sFileViewerPrg.c_str();
+ PROCESS_INFORMATION stProcesses = {0};
+
+ if( ! CreateProcess( NULL,
+ (_TCHAR*)sTmp.c_str(),
+ NULL,
+ NULL,
+ FALSE,
+ CREATE_DEFAULT_ERROR_MODE | CREATE_NEW_CONSOLE | CREATE_NEW_PROCESS_GROUP ,
+ NULL,
+ NULL,
+ &sStartupInfo,
+ &stProcesses ) )
+ {
+ DisplayLastError( _T("Faile to execute external file view") );
+ }
+ return true;
+}
+
+
+/////////////////////////////////////////////////////////////////////
+// Member Function : bGetInternalViewer
+// Type : Global
+// Parameters : None
+// Returns : Returns true if
+// Description :
+//
+// References : -
+// Remarks : -
+// Created : 021016 , 16 October 2002
+// Developer : KN
+/////////////////////////////////////////////////////////////////////
+
+bool bUseInternalViewer()
+{
+ return bUseIntViewer;
+}
+
+/////////////////////////////////////////////////////////////////////
+// Member Function : bUseInternalViewer
+// Type : Global
+// Parameters : bNew - ?
+// Returns : Returns true if
+// Description :
+//
+// References : -
+// Remarks : -
+// Created : 021016 , 16 October 2002
+// Developer : KN
+/////////////////////////////////////////////////////////////////////
+
+bool bUseInternalViewer( bool bNew )
+{
+ bUseIntViewer = bNew;
+ if( bUseIntViewer && !hRichEditDll )
+ {
+ hRichEditDll = LoadLibraryA("RICHED32.DLL");
+ if( !hRichEditDll )
+ {
+ DisplayLastError( _T("Failed to load Rich Edit ( RICHED32.DLL )" ));
+ return false;
+ }
+ }
+ else if( !bUseIntViewer && hRichEditDll )
+ {
+ if( ::FreeLibrary(hRichEditDll) == 0 )
+ {
+ DisplayLastError( _T("Failed to unload Rich Edit ( RICHED32.DLL )") );
+ hRichEditDll = NULL;
+ return false;
+ }
+ hRichEditDll = NULL;
+ }
+ return true;
+}
+
+
+/////////////////////////////////////////////////////////////////////
+// Member Function : RichEditStreamLoadFile
+// Type : Global
+// Parameters : dwCookie - ?
+// pbBuff - ?
+// cb - ?
+// pcb - ?
+// Returns : DWORD CALLBACK
+// Description :
+//
+// References : -
+// Remarks : -
+// Created : 021010 , 10 October 2002
+// Developer : KN
+/////////////////////////////////////////////////////////////////////
+
+DWORD CALLBACK RichEditStreamLoadFile(DWORD_PTR dwCookie, LPBYTE pbBuff, LONG cb, LONG *pcb)
+{
+ ReadFile((HANDLE)dwCookie, pbBuff, (DWORD)cb, (DWORD *)pcb, (LPOVERLAPPED)NULL);
+ return (DWORD) ( *pcb >= 0 ? NOERROR : ( *pcb = 0, E_FAIL ) );
+}
+
+DWORD CALLBACK RichEditRTFStreamLoadFile(DWORD_PTR dwCookie, LPBYTE pbBuff, LONG cb, LONG *pcb)
+{
+ *pcb = ((CLStreamRTFInfo *)dwCookie)->nLoadFileStream( pbBuff, cb );
+ if( *pcb )
+ return NOERROR;
+ return (DWORD)E_FAIL;
+}
+
+DWORD CALLBACK RichEditStreamSaveFile(DWORD_PTR dwCookie, LPBYTE pbBuff, LONG cb, LONG *pcb)
+{
+ WriteFile((HANDLE)dwCookie, pbBuff, cb , (DWORD*)pcb, (LPOVERLAPPED)NULL);
+ return *pcb != cb;
+}
+
+/*
+DWORD dwCurPos = 0;
+DWORD dwDataRead = 0;
+BYTE * pabFileData = NULL;
+
+DWORD CALLBACK RichEditStreamLoadFile(DWORD_PTR dwCookie, LPBYTE pbBuff, LONG cb, LONG *pcb)
+{
+ *pcb = 0;
+ while( dwCurPos < dwDataRead && *pcb < cb )
+ {
+ pbBuff[ *pcb ] = pabFileData[ dwCurPos ];
+ dwCurPos++;
+ (*pcb)++;
+ }
+ return (DWORD) ( *pcb >= 0 ? NOERROR : ( *pcb = 0, E_FAIL ) );
+}
+*/
+/////////////////////////////////////////////////////////////////////
+// Member Function : bLoadFile
+// Type : Global
+// Parameters : hwndDlg - ?
+// hContact - ?
+// Returns : Returns true if
+// Description :
+//
+// References : -
+// Remarks : -
+// Created : 021010 , 10 October 2002
+// Developer : KN
+/////////////////////////////////////////////////////////////////////
+
+bool bLoadFile( HWND hwndDlg , CLHistoryDlg * pclDlg )
+{
+ DWORD dwStart = GetTickCount();
+
+ HWND hRichEdit = GetDlgItem( hwndDlg , IDC_RICHEDIT );
+ if( ! hRichEdit )
+ {
+ MessageBox( hwndDlg , _T("Failed to get handle to RichEdit!"),MSG_BOX_TITEL,MB_OK );
+ return false;
+ }
+
+
+ HANDLE hFile = CreateFile( pclDlg->sPath.c_str() , GENERIC_READ ,
+ FILE_SHARE_READ | FILE_SHARE_WRITE , NULL ,
+ OPEN_EXISTING , FILE_ATTRIBUTE_NORMAL , NULL );
+
+
+ if( hFile == INVALID_HANDLE_VALUE )
+ {
+ int nDBCount = CallService( MS_DB_EVENT_GETCOUNT , (WPARAM)(pclDlg->hContact) ,0 );
+ _TCHAR szTmp[1500];
+
+ if( nDBCount == -1 )
+ {
+ _stprintf( szTmp , _T("Failed to open file\r\n%s\r\n\r\nContact handle is invalid") , pclDlg->sPath.c_str() );
+ }
+ else
+ {
+ _stprintf( szTmp , _T("Failed to open file\r\n%s\r\n\r\nMiranda database contains %d events") , pclDlg->sPath.c_str() , nDBCount );
+ }
+
+ SETTEXTEX stText = {0};
+ stText.codepage = CP_ACP;
+ SendMessage( hRichEdit , EM_SETTEXTEX, (WPARAM) &stText, (LPARAM) szTmp );
+ return false;
+ }
+
+ POINT ptOldPos;
+ SendMessage( hRichEdit , EM_GETSCROLLPOS , 0 , (LPARAM) &ptOldPos );
+
+ bool bScrollToBottom = true;
+ if( pclDlg->bFirstLoad )
+ pclDlg->bFirstLoad = false;
+ else
+ {
+ SCROLLINFO sScrollInfo = { 0 };
+ sScrollInfo.cbSize = sizeof( SCROLLINFO );
+ sScrollInfo.fMask = SIF_POS | SIF_RANGE | SIF_PAGE;
+ if( GetScrollInfo( hRichEdit,SB_VERT,&sScrollInfo) )
+ bScrollToBottom = sScrollInfo.nPos + (int)sScrollInfo.nPage + 50 > sScrollInfo.nMax;
+ }
+
+
+ HMENU hSysMenu = GetSystemMenu( hwndDlg , FALSE );
+ bool bUseSyntaxHL = (GetMenuState( hSysMenu , ID_FV_SYNTAX_HL , MF_BYCOMMAND ) & MF_CHECKED)!=0;
+
+/*
+ DWORD dwSize = GetFileSize( hFile , NULL );
+ dwCurPos = 0;
+ pabFileData = new BYTE[ dwSize ];
+ ReadFile( hFile , pabFileData, dwSize , &dwDataRead, (LPOVERLAPPED)NULL);
+*/
+
+
+ // SendMessage( hRichEdit , EM_SETBKGNDCOLOR, 0 , RGB( 0 , 0 , 128 ) );
+ // SendMessage( hRichEdit , EM_SETTEXTMODE, TM_RICHTEXT ,0);
+
+ // DWORD dw = SendMessage( hRichEdit , EM_GETLIMITTEXT, NULL, NULL);
+
+ EDITSTREAM eds;
+ eds.dwError = 0;
+
+ if( bUseSyntaxHL )
+ {
+ SendMessage( hRichEdit , // handle to destination window
+ EM_EXLIMITTEXT, // message to send
+ 0, // not used; must be zero
+ 0x7FFFFFFF );
+
+ CLStreamRTFInfo clInfo( hFile );
+ eds.dwCookie = (DWORD)&clInfo;
+ eds.pfnCallback = RichEditRTFStreamLoadFile;
+
+ SendMessage(hRichEdit, EM_STREAMIN, (WPARAM)SF_RTF , (LPARAM)&eds);
+ pclDlg->bUtf8File = clInfo.bUtf8File;
+ }
+ else
+ {
+ eds.dwCookie = (DWORD )hFile;
+ eds.pfnCallback = RichEditStreamLoadFile;
+
+ SendMessage(hRichEdit, EM_STREAMIN, (WPARAM)SF_TEXT , (LPARAM)&eds);
+ }
+
+ CloseHandle( hFile );
+ //delete [] pabFileData;
+
+ _TCHAR szTmp[100];
+ _stprintf( szTmp , _T("File open time %d\n") , GetTickCount() - dwStart );
+ OutputDebugString( szTmp );
+
+
+ GETTEXTLENGTHEX sData = { 0 };
+ sData.flags = GTL_NUMCHARS;
+ sData.flags = GTL_DEFAULT;
+
+ DWORD dwDataRead = SendMessage( hRichEdit , EM_GETTEXTLENGTHEX, (WPARAM)&sData , 0 );
+ SendMessage( hRichEdit , EM_SETSEL , dwDataRead - 1, dwDataRead - 1 );
+
+ if( ! bScrollToBottom )
+ SendMessage( hRichEdit , EM_SETSCROLLPOS , 0 , (LPARAM) &ptOldPos );
+
+ _stprintf( szTmp , _T("With scroll to bottom %d\n") , GetTickCount() - dwStart );
+ OutputDebugString( szTmp );
+
+ return true;
+}
+
+/////////////////////////////////////////////////////////////////////
+// Member Function : bAdvancedCopy
+// Type : Global
+// Parameters : hwnd - handle to RichEdit control
+// Returns : Returns true if text was copied to the clipboard
+// Description :
+//
+// References : -
+// Remarks : -
+// Created : 030730 , 30 juli 2003
+// Developer : KN
+/////////////////////////////////////////////////////////////////////
+
+bool bAdvancedCopy(HWND hwnd)
+{
+ CHARRANGE sSelectRange;
+ SendMessage( hwnd, EM_EXGETSEL, 0 , (LPARAM)&sSelectRange );
+ int nSelLenght = sSelectRange.cpMax - sSelectRange.cpMin + 1; // +1 for null termination
+ if( nSelLenght > 1 )
+ {
+ OpenClipboard(NULL);
+ EmptyClipboard();
+
+ _TCHAR * pszSrcBuf = new _TCHAR[ nSelLenght];
+ pszSrcBuf[0] = 0;
+ SendMessage( hwnd, EM_GETSELTEXT, 0 , (LPARAM)pszSrcBuf );
+
+ HANDLE hDecMem = GlobalAlloc(GMEM_MOVEABLE|GMEM_DDESHARE, nSelLenght );
+ _TCHAR * pszCurDec = (_TCHAR*)GlobalLock(hDecMem);
+
+ bool bInSpaces = false;
+ for( _TCHAR * pszCur = pszSrcBuf ; pszCur[0] ; pszCur++ )
+ {
+ if( bInSpaces )
+ {
+ if( pszCur[0] == ' ' )
+ continue;
+ bInSpaces = false;
+ }
+
+ if( pszCur[0] == '\n' )
+ {
+ bInSpaces = true;
+ }
+ pszCurDec[0] = pszCur[0];
+ pszCurDec++;
+ }
+ pszCurDec[0] = 0;
+ GlobalUnlock(hDecMem);
+
+ SetClipboardData(CF_TEXT,hDecMem);
+ delete [] pszSrcBuf;
+ CloseClipboard();
+ return true;
+ }
+ return false;
+}
+
+/////////////////////////////////////////////////////////////////////
+// Member Function : EditSubclassProc
+// Type : Global
+// Parameters : hwnd - ?
+// uMsg - ?
+// wParam - ?
+// lParam - ?
+// Returns : LRESULT CALLBACK
+// Description :
+//
+// References : -
+// Remarks : -
+// Created : 021013 , 13 October 2002
+// Developer : KN
+/////////////////////////////////////////////////////////////////////
+
+LRESULT CALLBACK EditSubclassProc( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ CLHistoryDlg * pclDlg = (CLHistoryDlg *)GetWindowLong(hwnd,GWL_USERDATA);
+
+ switch( msg )
+ {
+ case WM_CONTEXTMENU:
+ {
+ HMENU nMenu = LoadMenu( hInstance, MAKEINTRESOURCE( IDR_FV_EDIT ) );
+ HMENU nSubMenu = GetSubMenu( nMenu , 0 );
+ POINT pt;
+ pt.x=(short)LOWORD(lParam);
+ pt.y=(short)HIWORD(lParam);
+
+ if(pt.x==-1 && pt.y==-1)
+ {
+ DWORD dwStart,dwEnd;
+ SendMessage( hwnd , EM_GETSEL , (WPARAM)&dwStart, (LPARAM)&dwEnd );
+ SendMessage( hwnd , EM_POSFROMCHAR, (WPARAM)&pt, (LPARAM)dwEnd);
+ ClientToScreen( hwnd , &pt );
+ }
+ TrackPopupMenu( nSubMenu , TPM_RIGHTBUTTON , pt.x , pt.y , 0 , hwnd , 0 );
+
+ DestroyMenu( nSubMenu );
+ DestroyMenu( nMenu );
+ return TRUE;
+ }
+ case WM_GETDLGCODE:
+ {
+ return DLGC_WANTARROWS;
+ }
+ case WM_COPY:
+ { // not working for "CTRL + C"
+ if( bAdvancedCopy( hwnd ) )
+ return TRUE;
+ break;
+ }
+ case WM_KEYDOWN:
+ {
+ if( (wParam == VK_INSERT || wParam == 'C') && (GetKeyState(VK_CONTROL) & 0x80) )
+ {
+ if( bAdvancedCopy( hwnd ) )
+ return TRUE;
+ }
+ break;
+ }
+ case WM_COMMAND:
+ {
+ switch (LOWORD(wParam))
+ {
+ case ID_EDIT_COPY:
+ {
+ SendMessage( hwnd , WM_COPY, 0, 0 );
+ return TRUE;
+ }
+ }
+ }
+ }
+ if( msg == UM_FIND_CMD )
+ {
+ FINDREPLACE *fr = (FINDREPLACE *)lParam;
+ if( fr->Flags & FR_DIALOGTERM )
+ {
+ pclDlg->hFindDlg = NULL;
+ return 0;
+ }
+
+ FINDTEXT ft = { 0 };
+
+ if( fr->Flags & FR_FINDNEXT)
+ {
+ ft.lpstrText = fr->lpstrFindWhat;
+
+ SendMessage(hwnd, EM_EXGETSEL, 0, (LPARAM)&ft.chrg);
+ ft.chrg.cpMin = ft.chrg.cpMax+1;
+ ft.chrg.cpMax = -1;
+ int res = SendMessage(hwnd, EM_FINDTEXT, (WPARAM)fr->Flags,(LPARAM)&ft);
+ if(res == -1)
+ {
+ ft.chrg.cpMin = 0;
+ res = SendMessage(hwnd, EM_FINDTEXT, (WPARAM)fr->Flags,(LPARAM)&ft);
+ if(res == -1)
+ {
+ MessageBox( hwnd , TranslateTS(_T("Search string was not found !")),MSG_BOX_TITEL,MB_OK );
+ return 0;
+ }
+ }
+ ft.chrg.cpMin = res;
+ ft.chrg.cpMax = res + _tcslen(fr->lpstrFindWhat);
+ SendMessage(hwnd , EM_EXSETSEL, 0, (LPARAM)&ft.chrg);
+ return 0;
+ }
+
+ }
+ return CallWindowProc(pclDlg->wpOrigEditProc, hwnd, msg, wParam, lParam);
+}
+
+/////////////////////////////////////////////////////////////////////
+// Member Function : SetWindowsCtrls
+// Type : Global
+// Parameters : hwndDlg - ?
+// Returns : void
+// Description :
+//
+// References : -
+// Remarks : -
+// Created : 021001 , 01 October 2002
+// Developer : KN
+/////////////////////////////////////////////////////////////////////
+
+void SetWindowsCtrls( HWND hwndDlg )
+{
+ RECT rNewSize;
+ GetClientRect( hwndDlg , &rNewSize );
+
+ RECT rCurSize;
+
+ const int nSpacing = 12;
+
+
+ HWND hButton = GetDlgItem( hwndDlg , IDOK );
+ GetWindowRect( hButton , &rCurSize );
+ int nButtonHeight = rCurSize.bottom - rCurSize.top;
+
+ SetWindowPos( GetDlgItem( hwndDlg , IDC_RICHEDIT ) , 0 ,
+ nSpacing , nSpacing ,
+ rNewSize.right - (nSpacing * 2) ,
+ rNewSize.bottom - ( nSpacing * 3 + nButtonHeight ),
+ SWP_NOZORDER );
+
+
+ int nButtonWidth = rCurSize.right - rCurSize.left;
+ int nButtonSpace = (rNewSize.right - ( 3 * nButtonWidth )) / 4;
+ int nButtonTop = rNewSize.bottom - ( nSpacing + nButtonHeight );
+ int nCurLeft = nButtonSpace;
+
+ SetWindowPos( GetDlgItem( hwndDlg , IDC_FV_FIND ) , 0 ,
+ nCurLeft , nButtonTop , 0 , 0 , SWP_NOZORDER | SWP_NOSIZE );
+
+ nCurLeft += nButtonSpace + nButtonWidth;
+
+ SetWindowPos( GetDlgItem( hwndDlg , IDC_FV_EXTERNAL ) , 0 ,
+ nCurLeft , nButtonTop , 0 , 0 , SWP_NOZORDER | SWP_NOSIZE );
+
+ nCurLeft += nButtonSpace + nButtonWidth;
+
+ SetWindowPos( hButton , 0 ,
+ nCurLeft , nButtonTop , 0 , 0 , SWP_NOZORDER | SWP_NOSIZE );
+
+}
+
+/////////////////////////////////////////////////////////////////////
+// Member Function : SetRichEditFont
+// Type : Global
+// Parameters : hRichEdit - RichEdit to set the font in
+// bUseSyntaxHL - Is Syntax hilighting is used the color
+// will not be set
+// Returns : void
+// Description :
+//
+// References : -
+// Remarks : -
+// Created : 030205 , 05 February 2003
+// Developer : KN
+/////////////////////////////////////////////////////////////////////
+
+void SetRichEditFont(HWND hRichEdit, bool bUseSyntaxHL )
+{
+ CHARFORMAT ncf = { 0 };
+ ncf.cbSize = sizeof( CHARFORMAT );
+ ncf.dwMask = CFM_BOLD | CFM_FACE | CFM_ITALIC | CFM_SIZE | CFM_UNDERLINE;
+ ncf.dwEffects = DBGetContactSettingDword( NULL , MODULE , szFileViewDB "TEffects" , 0 );
+ ncf.yHeight = DBGetContactSettingDword( NULL , MODULE , szFileViewDB "THeight" , 165 );
+ _tcscpy( ncf.szFaceName , DBGetString( NULL , MODULE , szFileViewDB "TFace" , _T("Courier New")).c_str() );
+
+ if( ! bUseSyntaxHL )
+ {
+ ncf.dwMask |= CFM_COLOR;
+ ncf.crTextColor = DBGetContactSettingDword( NULL , MODULE , szFileViewDB "TColor" , 0 );
+ }
+ SendMessage(hRichEdit, EM_SETCHARFORMAT, (WPARAM)SCF_ALL, (LPARAM)&ncf);
+
+}
+
+/////////////////////////////////////////////////////////////////////
+// Member Function : DlgProcFileViewer
+// Type : Global
+// Parameters : hwndDlg - ?
+// msg - ?
+// wParam - ?
+// lParam - ?
+// Returns : static BOOL CALLBACK
+// Description :
+//
+// References : -
+// Remarks : -
+// Created : 020929 , 29 September 2002
+// Developer : KN
+/////////////////////////////////////////////////////////////////////
+
+static BOOL CALLBACK DlgProcFileViewer(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ CLHistoryDlg * pclDlg = (CLHistoryDlg *)GetWindowLong(hwndDlg,GWL_USERDATA);
+
+ switch (msg)
+ {
+ case WM_INITDIALOG:
+ {
+ SetWindowLong(hwndDlg,GWL_USERDATA,lParam);
+ CLHistoryDlg * pclDlg = (CLHistoryDlg *)lParam;
+#ifdef _UNICODE
+ EnableWindow( GetDlgItem( hwndDlg , IDC_FV_FIND ) , FALSE );
+#endif
+ SendMessage(hwndDlg, WM_SETICON, ICON_BIG,
+ (LPARAM)LoadIcon( hInstance, MAKEINTRESOURCE(IDI_EXPORT_MESSAGE)));
+
+ HWND hRichEdit = GetDlgItem( hwndDlg , IDC_RICHEDIT );
+ pclDlg->wpOrigEditProc = (WNDPROC) SetWindowLongPtr( hRichEdit, GWL_WNDPROC, (LONG) EditSubclassProc);
+
+ SetWindowLongPtr( hRichEdit, GWLP_USERDATA, (LONG) pclDlg );
+
+ SendMessage( hRichEdit , EM_SETEVENTMASK , 0 , ENM_LINK);
+ SendMessage( hRichEdit , EM_AUTOURLDETECT , TRUE , 0 );
+
+ HMENU hSysMenu = GetSystemMenu( hwndDlg , FALSE );
+
+ InsertMenu( hSysMenu , 0 , MF_SEPARATOR | MF_BYPOSITION , 0 , 0 );
+ InsertMenu( hSysMenu , 0 , MF_STRING | MF_BYPOSITION , ID_FV_SAVE_AS_RTF, TranslateTS(_T("Save as RTF")) );
+
+ InsertMenu( hSysMenu , 0 , MF_SEPARATOR | MF_BYPOSITION , 0 , 0 );
+
+ BYTE bUseCC = (BYTE)DBGetContactSettingByte( NULL , MODULE , szFileViewDB "UseCC" , 0 );
+ InsertMenu( hSysMenu , 0 , MF_STRING | MF_BYPOSITION | ( bUseCC ? MF_CHECKED : 0 ) , ID_FV_COLOR, TranslateTS(_T("Color...")) );
+
+ if( bUseCC )
+ {
+ SendMessage( hRichEdit , EM_SETBKGNDCOLOR, 0 ,
+ DBGetContactSettingDword( NULL , MODULE , szFileViewDB "CustomC" , RGB(255,255,255) )
+ );
+ }
+
+ InsertMenu( hSysMenu , 0 , MF_STRING | MF_BYPOSITION , ID_FV_FONT, TranslateTS(_T("Font...")) );
+
+
+ bool bUseSyntaxHL = DBGetContactSettingByte( NULL , MODULE , szFileViewDB "UseSyntaxHL" , 1 )!=0;
+ InsertMenu( hSysMenu , 0 , MF_STRING | MF_BYPOSITION | ( bUseSyntaxHL ? MF_CHECKED : 0 ) , ID_FV_SYNTAX_HL, TranslateTS(_T("Syntax highlight")) );
+
+ SetRichEditFont( hRichEdit , bUseSyntaxHL );
+
+ TranslateDialogDefault(hwndDlg);
+
+ int cx= DBGetContactSettingDword( NULL , MODULE , szFileViewDB "cx" , 0 );
+ int cy= DBGetContactSettingDword( NULL , MODULE , szFileViewDB "cy" , 0 );
+
+ if( cx > 0 && cy > 0)
+ {
+ int x = DBGetContactSettingDword( NULL , MODULE , szFileViewDB "x" , 0 );
+ int y = DBGetContactSettingDword( NULL , MODULE , szFileViewDB "y" , 0 );
+
+ SetWindowPos( hwndDlg , NULL , x , y , cx , cy , SWP_NOZORDER );
+ }
+
+ pclDlg->sPath = GetFilePathFromUser( pclDlg->hContact );
+
+ SetWindowsCtrls( hwndDlg );
+
+
+ bLoadFile(hwndDlg , pclDlg );
+
+ { // set Title
+ _TCHAR szFormat[200];
+ _TCHAR szTitle[200];
+ if( GetWindowText( hwndDlg , szFormat , sizeof( szFormat ) ) )
+ {
+ const _TCHAR * pszNick = NickFromHandle( pclDlg->hContact );
+ tstring sPath = pclDlg->sPath;
+ string::size_type n = sPath.find_last_of( '\\' );
+ if( n != sPath.npos )
+ sPath.erase( 0 , n + 1 );
+
+ if( _sntprintf( szTitle , sizeof( szTitle ) , szFormat , pszNick , sPath.c_str() , (pclDlg->bUtf8File ? _T("UTF8"):_T("ANSI")) ) > 0 )
+ {
+ SetWindowText( hwndDlg , szTitle);
+ }
+ }
+ }
+
+ return TRUE;
+ }
+ case WM_RELOAD_FILE:
+ {
+ bLoadFile(hwndDlg , pclDlg );
+ return TRUE;
+ }
+ case WM_SIZE:
+ case WM_SIZING:
+ {
+ SetWindowsCtrls( hwndDlg );
+ return TRUE;
+ }
+ case WM_NCDESTROY:
+ {
+ EnterCriticalSection( &csHistoryList );
+ clHistoryDlgList.remove( pclDlg );
+ LeaveCriticalSection( &csHistoryList );
+
+ delete pclDlg;
+ SetWindowLong(hwndDlg,GWL_USERDATA,NULL);
+ return 0;
+ }
+ case WM_DESTROY:
+ {
+ RECT rSize;
+ if( GetWindowRect( hwndDlg , &rSize ) )
+ {
+ // first we make sure the window has resonable dimentions.
+ // if it is minimized it will not have that.
+ if( rSize.left <= -32000 || rSize.top <= -32000 )
+ return 0;
+ if( rSize.right <= -32000 || rSize.bottom <= -32000 )
+ return 0;
+ DBWriteContactSettingDword( NULL , MODULE , szFileViewDB "x" , rSize.left );
+ DBWriteContactSettingDword( NULL , MODULE , szFileViewDB "y" , rSize.top );
+ DBWriteContactSettingDword( NULL , MODULE , szFileViewDB "cx" , rSize.right - rSize.left );
+ DBWriteContactSettingDword( NULL , MODULE , szFileViewDB "cy" , rSize.bottom - rSize.top );
+ }
+ return 0;
+ }
+ case WM_SYSCOMMAND:
+ {
+ HMENU hSysMenu = GetSystemMenu( hwndDlg , FALSE );
+ bool bUseSyntaxHL = (GetMenuState( hSysMenu , ID_FV_SYNTAX_HL , MF_BYCOMMAND ) & MF_CHECKED)!=0;
+ HWND hRichEdit = GetDlgItem( hwndDlg , IDC_RICHEDIT );
+
+ if ((wParam & 0xFFF0) == ID_FV_FONT)
+ {
+ LOGFONT lf = { 0 };
+ lf.lfHeight = 14L;
+
+ { DWORD dwEffects = DBGetContactSettingDword( NULL , MODULE , szFileViewDB "TEffects" , 0 );
+ lf.lfWeight = (dwEffects & CFE_BOLD) ? FW_BOLD : 0;
+ lf.lfUnderline = (dwEffects & CFE_UNDERLINE) != 0;
+ lf.lfStrikeOut = (dwEffects & CFE_STRIKEOUT) != 0;
+ lf.lfItalic = (dwEffects & CFE_ITALIC) != 0;
+ }
+ _tcscpy(lf.lfFaceName, DBGetString( NULL , MODULE , szFileViewDB "TFace" , _T("Courier New")).c_str());
+ CHOOSEFONT cf = { 0 };
+ cf.lStructSize = sizeof( cf );
+ cf.hwndOwner = hwndDlg;
+ cf.lpLogFont = &lf;
+ cf.rgbColors = DBGetContactSettingDword( NULL , MODULE , szFileViewDB "TColor" , 0 );
+ cf.Flags = CF_EFFECTS | CF_SCREENFONTS | CF_INITTOLOGFONTSTRUCT;
+
+ if( ChooseFont( &cf ) )
+ {
+ DWORD dwEffects = (lf.lfWeight == FW_BOLD ? CFE_BOLD : 0) |
+ (lf.lfItalic ? CFE_ITALIC : 0) |
+ (lf.lfStrikeOut ? CFE_STRIKEOUT : 0) |
+ (lf.lfUnderline ? CFE_UNDERLINE : 0);
+
+ DBWriteContactSettingDword( NULL , MODULE , szFileViewDB "TEffects" , dwEffects );
+ DBWriteContactSettingDword( NULL , MODULE , szFileViewDB "THeight" , cf.iPointSize * 2 );
+ DBWriteContactSettingDword( NULL , MODULE , szFileViewDB "TColor" , cf.rgbColors );
+ DBWriteContactSettingTString( NULL , MODULE , szFileViewDB "TFace" , lf.lfFaceName );
+ SetRichEditFont( hRichEdit , bUseSyntaxHL );
+ }
+ return TRUE;
+ }
+ else if ((wParam & 0xFFF0) == ID_FV_COLOR)
+ {
+ BYTE bUseCC = ! DBGetContactSettingByte( NULL , MODULE , szFileViewDB "UseCC" , 0 );
+ if( bUseCC )
+ {
+ CHOOSECOLOR cc = {0};
+ cc.lStructSize = sizeof( cc );
+ cc.hwndOwner = hwndDlg;
+ cc.rgbResult = DBGetContactSettingDword( NULL , MODULE , szFileViewDB "CustomC" , RGB(255,255,255) );
+ cc.Flags = CC_ANYCOLOR | CC_FULLOPEN | CC_RGBINIT;
+ static COLORREF MyCustColors[16] = { 0xFFFFFFFF };
+ cc.lpCustColors = MyCustColors;
+ if( ChooseColor( &cc ) )
+ {
+ SendMessage( hRichEdit , EM_SETBKGNDCOLOR, 0 , cc.rgbResult );
+ DBWriteContactSettingDword( NULL , MODULE , szFileViewDB "CustomC" , cc.rgbResult );
+ }
+ else
+ {
+ /*DWORD dwError =*/ CommDlgExtendedError();
+ return TRUE;
+ }
+ }
+ else
+ {
+ SendMessage( hRichEdit , EM_SETBKGNDCOLOR, TRUE , 0 );
+ }
+ CheckMenuItem( hSysMenu , ID_FV_COLOR , MF_BYCOMMAND | (bUseCC ? MF_CHECKED : 0) );
+ DBWriteContactSettingByte( NULL , MODULE , szFileViewDB "UseCC" , bUseCC );
+ return TRUE;
+ }
+ else if ((wParam & 0xFFF0) == ID_FV_SYNTAX_HL)
+ {
+ // we use the current state from the menu not the DB value
+ // because we want to toggel the option for this window
+ // still the new option selected will be stored.
+ // so user may open 2 windows, now he can set SyntaxHL in both.
+
+ bUseSyntaxHL = !bUseSyntaxHL;
+ CheckMenuItem( hSysMenu , ID_FV_SYNTAX_HL , MF_BYCOMMAND | (bUseSyntaxHL ? MF_CHECKED : 0) );
+ DBWriteContactSettingByte( NULL , MODULE , szFileViewDB "UseSyntaxHL" , bUseSyntaxHL );
+
+ if( bUseSyntaxHL )
+ bLoadFile(hwndDlg , pclDlg );
+ else
+ SetRichEditFont( hRichEdit , bUseSyntaxHL );
+
+ return TRUE;
+ }
+ else if ((wParam & 0xFFF0) == ID_FV_SAVE_AS_RTF)
+ {
+ tstring sFile = pclDlg->sPath;
+ sFile += _T(".rtf");
+ HANDLE hFile = CreateFile( sFile.c_str() , GENERIC_WRITE ,
+ FILE_SHARE_READ , NULL , CREATE_ALWAYS , FILE_ATTRIBUTE_NORMAL , NULL );
+
+ if( hFile == INVALID_HANDLE_VALUE )
+ {
+ DisplayLastError( _T("Failed to create file") );
+ return TRUE;
+ }
+
+ EDITSTREAM eds;
+ eds.dwCookie = (DWORD )hFile;
+ eds.dwError = 0;
+ eds.pfnCallback = RichEditStreamSaveFile;
+ int nWriteOk = SendMessage(hRichEdit, EM_STREAMOUT, (WPARAM)SF_RTF , (LPARAM)&eds);
+ if( nWriteOk <= 0 || eds.dwError != 0 )
+ {
+ DisplayLastError( _T("Failed to save file") );
+ CloseHandle( hFile );
+ return TRUE;
+ }
+ CloseHandle( hFile );
+ tstring sReport = _T("History was saved successfully in file\r\n");
+ sReport += sFile;
+ MessageBox( NULL , sReport.c_str() ,MSG_BOX_TITEL ,MB_OK );
+ return TRUE;
+ }
+ return FALSE;
+ }
+
+ case WM_COMMAND:
+ {
+ switch (LOWORD(wParam))
+ {
+ case IDCANCEL:
+ case IDOK:
+ DestroyWindow(hwndDlg);
+ return TRUE;
+ case IDC_FV_EXTERNAL:
+ bOpenExternaly( pclDlg->hContact );
+ return TRUE;
+ case IDC_FV_FIND:
+ {
+ if( pclDlg->hFindDlg )
+ {
+ BringWindowToTop( pclDlg->hFindDlg );
+ return TRUE;
+ }
+ pclDlg->fr.hwndOwner = GetDlgItem( hwndDlg , IDC_RICHEDIT );
+ pclDlg->hFindDlg = FindText( &pclDlg->fr );
+ return TRUE;
+ }
+ }
+ break;
+ }
+ case WM_NOTIFY:
+ {
+ if( ((NMHDR*)lParam)->idFrom == IDC_RICHEDIT )
+ {
+ if( ((NMHDR*)lParam)->code == EN_LINK )
+ {
+ ENLINK* pstLink = (ENLINK*)lParam;
+ if( pstLink->msg == WM_LBUTTONUP )
+ {
+ _TCHAR szUrl[ 500 ];
+ if( (pstLink->chrg.cpMax - pstLink->chrg.cpMin) > (sizeof( szUrl ) - 2) )
+ return FALSE;
+
+ TEXTRANGE stToGet;
+ stToGet.chrg = pstLink->chrg;
+ stToGet.lpstrText = szUrl;
+ if( SendMessage( pstLink->nmhdr.hwndFrom , EM_GETTEXTRANGE , 0 , (LPARAM)&stToGet ) > 0 )
+ {
+ CallService(MS_UTILS_OPENURL,1,(LPARAM)szUrl);
+ }
+ return TRUE;
+ }
+ }
+ }
+ break;
+ }
+ case WM_CLOSE:
+ {
+ DestroyWindow(hwndDlg);
+ return TRUE;
+ }
+ }
+ return FALSE;
+//FALSE;//DefWindowProc( hwndDlg, msg, wParam, lParam );
+//DefDlgProc( hwndDlg, msg, wParam, lParam );
+}
+
+
+
+/////////////////////////////////////////////////////////////////////
+// Member Function : bShowFileViewer
+// Type : Global
+// Parameters : hContact - ?
+// Returns : Returns true if
+// Description :
+//
+// References : -
+// Remarks : -
+// Created : 020929 , 29 September 2002
+// Developer : KN
+/////////////////////////////////////////////////////////////////////
+
+bool bShowFileViewer( HANDLE hContact )
+{
+ CLHistoryDlg * pcl = new CLHistoryDlg( hContact );
+ pcl->hWnd = CreateDialogParam( hInstance,MAKEINTRESOURCE(IDD_FILE_VIEWER),NULL,DlgProcFileViewer,(LPARAM)pcl);
+ if( pcl->hWnd )
+ {
+ EnterCriticalSection( &csHistoryList );
+ clHistoryDlgList.push_front( pcl );
+ LeaveCriticalSection( &csHistoryList );
+
+ ShowWindow( pcl->hWnd , SW_SHOWNORMAL );
+ return true;
+ }
+ DisplayLastError( _T("Failed to create history dialog") );
+ delete pcl;
+ return false;
+}
diff --git a/FileViewer.h b/FileViewer.h
new file mode 100755
index 0000000..6da79c9
--- /dev/null
+++ b/FileViewer.h
@@ -0,0 +1,38 @@
+
+//This file is part of Msg_Export a Miranda IM plugin
+//Copyright (C)2002 Kennet Nielsen ( http://sourceforge.net/projects/msg-export/ )
+//
+//This program is free software; you can redistribute it and/or
+//modify it under the terms of the GNU General Public License
+//as published by the Free Software Foundation; either
+//version 2 of the License, or (at your option) any later version.
+//
+//This program is distributed in the hope that it will be useful,
+//but WITHOUT ANY WARRANTY; without even the implied warranty of
+//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+//GNU General Public License for more details.
+//
+//You should have received a copy of the GNU General Public License
+//along with this program; if not, write to the Free Software
+//Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+#ifndef MSG_EXP_FILE_VIEWER
+#define MSG_EXP_FILE_VIEWER
+
+#include <windows.h>
+
+void Initilize();
+void Uninitilize();
+
+void UpdateFileViews( const _TCHAR * pszFile );
+
+bool bOpenExternaly( HANDLE hContact );
+bool bShowFileViewer( HANDLE hContact );
+
+bool bUseInternalViewer( bool bNew );
+bool bUseInternalViewer();
+
+extern tstring sFileViewerPrg;
+
+#endif
+
diff --git a/Glob.h b/Glob.h
new file mode 100755
index 0000000..8de2c08
--- /dev/null
+++ b/Glob.h
@@ -0,0 +1,29 @@
+
+//This file is part of Msg_Export a Miranda IM plugin
+//Copyright (C)2002 Kennet Nielsen ( http://sourceforge.net/projects/msg-export/ )
+//
+//This program is free software; you can redistribute it and/or
+//modify it under the terms of the GNU General Public License
+//as published by the Free Software Foundation; either
+//version 2 of the License, or (at your option) any later version.
+//
+//This program is distributed in the hope that it will be useful,
+//but WITHOUT ANY WARRANTY; without even the implied warranty of
+//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+//GNU General Public License for more details.
+//
+//You should have received a copy of the GNU General Public License
+//along with this program; if not, write to the Free Software
+//Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+#ifndef MSG_EXP_GLOB_H
+#define MSG_EXP_GLOB_H
+
+#include <windows.h>
+
+#define MODULE "Msg_Export"
+#define MSG_BOX_TITEL _T("Miranda (Msg_Export.dll)")
+
+extern HINSTANCE hInstance;
+
+#endif \ No newline at end of file
diff --git a/UpgradeLog.XML b/UpgradeLog.XML
new file mode 100755
index 0000000..3b6a763
--- /dev/null
+++ b/UpgradeLog.XML
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?><?xml-stylesheet type='text/xsl' href='_UpgradeReport_Files/UpgradeReport.xslt'?><UpgradeLog>
+<Properties><Property Name="Solution" Value="msg_export">
+</Property><Property Name="Файл реŃения" Value="X:\temp\msgexport\msg_export.sln">
+</Property><Property Name="Date" Value="16 октября 2011 г.">
+</Property><Property Name="Time" Value="11:02">
+</Property></Properties><Event ErrorLevel="0" Project="msg_export" Source="msg_export.vcproj" Description="Веб-развертывание на локальном IIS-Ńервере больŃе не поддерживаетŃŃŹ. ĐĐ˝ŃŃ‚Ń€Ńмент веб-развертывания был Ńдален из параметров проекта.">
+</Event><Event ErrorLevel="1" Project="msg_export" Source="msg_export.vcproj" Description="Приложение было обновлено, чтобы включить параметры, Ńвязанные Ń ĐşĐľĐ˝Ń‚Ń€ĐľĐ»ĐµĐĽ Ńчетных запиŃей пользователей (UAC), появивŃемŃŃŹ в Windows Vista. По Ńмолчанию, в Windows Vista при включенном UAC, приложение Đ·Đ°ĐżŃŃкаетŃŃŹ Ń Ń‚ĐµĐĽĐ¸ же привилегиями, что и Đ·Đ°ĐżŃŃтивŃий его процеŃŃ. Đ­Ń‚Đľ также делает невозможным Đ·Đ°ĐżŃŃĐş приложений Ń Ń‚ĐµŃ…Đ˝ĐľĐ»ĐľĐłĐ¸ĐµĐą виртŃализации. Параметры, Ńвязанные Ń UAC можно поменять на Ńтранице ŃвойŃтв проекта.">
+</Event><Event ErrorLevel="0" Project="msg_export" Source="msg_export.vcproj" Description="Проект обновлен ŃŃпеŃно.">
+</Event><Event ErrorLevel="3" Project="msg_export" Source="msg_export.vcproj" Description="Converted">
+</Event><Event ErrorLevel="0" Project="" Source="msg_export.sln" Description="Преобразование реŃения ŃŃпеŃно заверŃено">
+</Event><Event ErrorLevel="3" Project="" Source="msg_export.sln" Description="Converted">
+</Event></UpgradeLog> \ No newline at end of file
diff --git a/export_m.ico b/export_m.ico
new file mode 100755
index 0000000..5f85a18
--- /dev/null
+++ b/export_m.ico
Binary files differ
diff --git a/includes/m_dos.h b/includes/m_dos.h
deleted file mode 100644
index db0aadf..0000000
--- a/includes/m_dos.h
+++ /dev/null
@@ -1,22 +0,0 @@
-// Copyright © 2008 sss, chaos.persei
-//
-// This program is free software; you can redistribute it and/or
-// modify it under the terms of the GNU General Public License
-// as published by the Free Software Foundation; either version 2
-// of the License, or (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-//Start sending messages to contact
-//effect depend on DOS plugin settings
-//wParam=(HANDLE)hContact
-//lParam=int
-//always returns 0
-#define MS_DOS_SERVICE "/StartDos"
diff --git a/langpack_msg_export.txt b/langpack_msg_export.txt
new file mode 100755
index 0000000..2397ac0
--- /dev/null
+++ b/langpack_msg_export.txt
@@ -0,0 +1,325 @@
+;; ====== Message Export ===========
+; This file contains all the strings used in the Message Export
+; plugin.
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; Contact menu item
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+[Open E&xported History]
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; Main options Tree
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+[Plugins]
+[Message export]
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; Main options dialog
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+; Static
+[Export directory]
+[Browse]
+[Default file]
+[Export format]
+[Max column width]
+[Time format]
+
+; ListCtrl
+[File]
+[Nick]
+[UIN]
+
+; Buttons
+[Auto filename]
+[Clear all]
+[Help]
+[Export all history]
+
+; Errors / Questions
+[You have unapplyed changes do you wish to apply these first ?]
+[No contacts found to export]
+[Failed to export at least one contact]
+[Max line width must be at least %d]
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; Dialog Export all, Progress bar
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+[Exporting old messages]
+[Reading database information ( Phase 1 of 2 )]
+[Sorting and writing database information ( Phase 2 of 2 )]
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; Folder Browse dialog
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+[Select Destination Directory]
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; Strings written to export file
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+[The following user added you to their contact list:]
+[The following user made an authorization request:]
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; General Error dialogs
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+[Message has not been saved !]
+[Failed to get the path to Msg_Export.dll\nPlease locate Msg_Export.txt your self]
+[Failed to move to the end of the file :\n]
+[Failed to open or create file :\n]
+
+;/////////////////////
+;// Version 1.4.0 //
+;/////////////////////
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; Strings written to export file
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+[The following user added you to their contact list:]
+[The following user made an authorization request:]
+[Nick :]
+[FirstName :]
+[LastName :]
+[e-mail :]
+[Reason :]
+
+; Errors
+
+;/////////////////////
+;// Version 1.4.1 //
+;/////////////////////
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; General Error dialogs
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+[Failed to write message to the file :\n]
+[Failed to write URL/File to the file :\n]
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; Strings written to export file
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+[URL: ]
+[File: ]
+[Description: ]
+
+
+;/////////////////////
+;// Version 1.5.0 //
+;/////////////////////
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; Strings written to export file
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+[EmailExpress from:]
+[No from address]
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; General Error dialogs
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+[Failed to write EmailExpress to the file :\n]
+
+
+;/////////////////////
+;// Version 1.6.0 //
+;/////////////////////
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; General Error dialogs
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+[Failed to write SMS to the file :\n]
+
+
+
+;/////////////////////
+;// Version 1.7.0 //
+;/////////////////////
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; Main options dialog
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+[Replace miranda history]
+[Use internal viewer]
+[You need to restart miranda to change the history function]
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; File Viewer dialog
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+[History file for %s (%s)]
+[Find...]
+[Close]
+[External]
+
+[Search string was not found !]
+
+;/////////////////////
+;// Version 1.8.0 //
+;/////////////////////
+
+[File name for the user \"%s\" has changed !\n\nfrom:\t%s\nto:\t%s\n\nDo you wish to rename file ?]
+[Failed to rename file\n\nfrom:\t%s\nto:\t%s\n\nFailed with error: %s]
+[&Yes]
+[Yes to &All]
+[&No]
+[No to A&ll]
+
+;/////////////////////
+;// Version 1.9.0 //
+;/////////////////////
+
+; File Viewer menu item
+[Color...]
+
+;/////////////////////
+;// Version 1.9.1 //
+;/////////////////////
+
+; File Viewer menu item
+[Font...]
+
+
+;/////////////////////
+;// Version 1.9.5 //
+;/////////////////////
+
+; Errors / Questions
+[Failed to delete the file]
+
+
+;/////////////////////
+;// Version 1.9.6 //
+;/////////////////////
+
+Removed : [Failed to read ProfileDir from mirandaboot.ini]
+Removed : [Failed to get path to Miranda.exe]
+
+;/////////////////////
+;// Version 1.9.7 //
+;/////////////////////
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; Main options dialog
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+[Prompt to delete file]
+
+
+;/////////////////////
+;// Version 1.9.8 //
+;/////////////////////
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; General Error dialogs
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+[Failed to replace Miranda History.\r\nThis is most likely due to changes in Miranda.]
+
+
+;/////////////////////
+;// Version 2.0.1 //
+;/////////////////////
+
+Removed : [Unknowen event type %d, size %d]
+Removed : [Invalid Database event received. Type %d, size %d]
+Removed : [User has been deleted do you want to delete the file ?\r\n%s]
+Removed : [Failed to HookEvent ME_DB_EVENT_ADDED]
+Removed : [Failed to HookEvent ME_OPT_INITIALISE]
+Removed : [Failed to HookEvent ME_SYSTEM_MODULESLOADED]
+Removed : [Failed to add menu item Open Exported History\nCallService(MS_CLIST_ADDCONTACTMENUITEM,...)]
+Removed : [Failed to CreateServiceFunction MS_SHOW_EXPORT_HISTORY]
+Removed : [Failed to get the shells allocator !]
+Removed : [Failed to Allocate buffer space]
+
+; Errors / Questions
+[User has been deleted do you want to delete the file ?]
+
+;///////////////////////
+;// Version 2.03.00 //
+;///////////////////////
+
+; File Viewer menu item
+[Syntax highlight]
+
+
+;///////////////////////
+;// Version 2.04.00 //
+;///////////////////////
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; Main options dialog
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+[File viewer]
+[Append extra new line]
+
+
+;///////////////////////
+;// Version 2.05.00 //
+;///////////////////////
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; Strings written to export file
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+[WebPager from:]
+
+;///////////////////////
+;// Version 2.06.00 //
+;///////////////////////
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; Main options dialog
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+; ListCtrl right click menu
+[User &Details]
+; These were not added in 2.06.00 but were forgotten in previous versions.
+[Export selected]
+[Set to default filename]
+
+;///////////////////////
+;// Version 2.09.00 //
+;///////////////////////
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; Main options dialog
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+[Use << and >>]
+
+
+;///////////////////////
+;// Version 2.12.00 //
+;///////////////////////
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; Main options dialog
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+Removed : [User has been deleted do you want to delete the file ?]
+
+[When filename changes]
+[When user is deleted]
+[Prompt for action]
+[Rename file]
+[Do nothing]
+[Delete file]
+
+
+;///////////////////////
+;// Version 2.15.00 //
+;///////////////////////
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; Main options dialog
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+[Export Protocols]
+
+
+;///////////////////////
+;// Version 3.00.00 //
+;///////////////////////
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; Main options dialog
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+[Use UTF8 in new files] \ No newline at end of file
diff --git a/main.cpp b/main.cpp
new file mode 100755
index 0000000..71a5bff
--- /dev/null
+++ b/main.cpp
@@ -0,0 +1,413 @@
+
+//This file is part of Msg_Export a Miranda IM plugin
+//Copyright (C)2002 Kennet Nielsen ( http://sourceforge.net/projects/msg-export/ )
+//
+//This program is free software; you can redistribute it and/or
+//modify it under the terms of the GNU General Public License
+//as published by the Free Software Foundation; either
+//version 2 of the License, or (at your option) any later version.
+//
+//This program is distributed in the hope that it will be useful,
+//but WITHOUT ANY WARRANTY; without even the implied warranty of
+//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+//GNU General Public License for more details.
+//
+//You should have received a copy of the GNU General Public License
+//along with this program; if not, write to the Free Software
+//Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+#include <windows.h>
+#include <Shellapi.h>
+
+//#include "../Miranda-IM/resource.h"
+
+#include "utils.h"
+#include "options.h"
+#include "FileViewer.h"
+#include "Glob.h"
+
+#include "resource.h"
+
+
+#define MS_SHOW_EXPORT_HISTORY "History/ShowExportHistory"
+
+MM_INTERFACE mmi = {0};
+
+UTF8_INTERFACE utfi = {0};
+
+HINSTANCE hInstance = NULL;
+
+PLUGINLINK *pluginLink;
+
+// static so they can not be used from other modules ( sourcefiles )
+static HANDLE hEventOptionsInitialize = 0;
+static HANDLE hDBEventAdded = 0;
+static HANDLE hDBContactDeleted = 0;
+static HANDLE hEventSystemInit = 0;
+static HANDLE hEventSystemShutdown = 0;
+
+static HANDLE hServiceFunc = 0;
+
+static HANDLE hOpenHistoryMenuItem = 0;
+
+/////////////////////////////////////////////////////
+// Remember to update the Version in the resource !!!
+/////////////////////////////////////////////////////
+
+PLUGININFOEX pluginInfo = {
+ sizeof(PLUGININFOEX),
+ "Message export (mod by ring0)",
+ PLUGIN_MAKE_VERSION(3,1,0,3),
+ "Exports every message, URL or File you receive to a text file.\r\n"
+ "Messages are exported to one file per user, users may be set to use the same file",
+ "Kennet Nielsen, mod by ring0",
+ "Kennet_N@ofir.dk",
+ "© 2002 Kennet Nielsen",
+ "http://sourceforge.net/projects/msg-export/",
+ UNICODE_AWARE,
+ 0,
+ #ifdef _UNICODE
+ { 0x46102b07, 0xc215, 0x4162, { 0x9c, 0x83, 0xd3, 0x77, 0x88, 0x1d, 0xa7, 0xcc } } // {46102B07-C215-4162-9C83-D377881DA7CC}
+ #else
+ { 0x13ff3b7e, 0x4976, 0x471f, { 0xa4, 0x75, 0x16, 0x62, 0xa4, 0xdd, 0xc, 0x3e } } // {13FF3B7E-4976-471f-A475-1662A4DD0C3E}
+ #endif
+};
+
+
+/////////////////////////////////////////////////////////////////////
+// Member Function : ShowExportHistory
+// Type : Global
+// Parameters : wParam - (WPARAM)(HANDLE)hContact
+// lParam - ?
+// Returns : static int
+// Description : Called when user selects my menu item "Open Exported History"
+//
+// References : -
+// Remarks : -
+// Created : 020422 , 22 April 2002
+// Developer : KN
+/////////////////////////////////////////////////////////////////////
+
+static int ShowExportHistory(WPARAM wParam,LPARAM /*lParam*/)
+{
+ if( bUseInternalViewer() )
+ {
+ bShowFileViewer( (HANDLE)wParam );
+ return 0;
+ }
+ bOpenExternaly( (HANDLE)wParam );
+ return 0;
+}
+
+/////////////////////////////////////////////////////////////////////
+// Member Function : nSystemShutdown
+// Type : Global
+// Parameters : wparam - 0
+// lparam - 0
+// Returns : int
+// Description :
+//
+// References : -
+// Remarks : -
+// Created : 020428 , 28 April 2002
+// Developer : KN
+/////////////////////////////////////////////////////////////////////
+
+int nSystemShutdown(WPARAM /*wparam*/,LPARAM /*lparam*/)
+{
+ if( hEventOptionsInitialize )
+ {
+ UnhookEvent(hEventOptionsInitialize);
+ hEventOptionsInitialize = 0;
+ }
+
+ if( hDBEventAdded )
+ {
+ UnhookEvent(hDBEventAdded);
+ hDBEventAdded = 0;
+ }
+
+ if( hDBContactDeleted )
+ {
+ UnhookEvent(hDBContactDeleted);
+ hDBContactDeleted = 0;
+ }
+
+ if( hServiceFunc )
+ {
+ DestroyServiceFunction( hServiceFunc );
+ hServiceFunc = 0;
+ }
+
+ if( hEventSystemInit )
+ {
+ UnhookEvent(hEventSystemInit);
+ hEventSystemInit = 0;
+ }
+
+ if( hEventSystemShutdown )
+ {
+ UnhookEvent(hEventSystemShutdown); // here we unhook the fun we are in, might not bee good
+ hEventSystemShutdown = 0;
+ }
+ return 0;
+}
+
+/////////////////////////////////////////////////////////////////////
+// Member Function : MainInit
+// Type : Global
+// Parameters : wparam - ?
+// lparam - ?
+// Returns : int
+// Description : Called when system modules has been loaded
+//
+// References : -
+// Remarks : -
+// Created : 020422 , 22 April 2002
+// Developer : KN
+/////////////////////////////////////////////////////////////////////
+
+int MainInit(WPARAM /*wparam*/,LPARAM /*lparam*/)
+{
+
+ Initilize();
+
+ bReadMirandaDirAndPath();
+ UpdateFileToColWidth();
+
+ hDBEventAdded = HookEvent( ME_DB_EVENT_ADDED , nExportEvent );
+ if( !hDBEventAdded )
+ MessageBox( NULL , _T("Failed to HookEvent ME_DB_EVENT_ADDED") , MSG_BOX_TITEL , MB_OK );
+
+
+ hDBContactDeleted = HookEvent( ME_DB_CONTACT_DELETED , nContactDeleted );
+ if( !hDBContactDeleted )
+ MessageBox( NULL , _T("Failed to HookEvent ME_DB_CONTACT_DELETED") , MSG_BOX_TITEL , MB_OK );
+
+
+ hEventOptionsInitialize = HookEvent( ME_OPT_INITIALISE , OptionsInitialize );
+ if( !hEventOptionsInitialize )
+ MessageBox( NULL , _T("Failed to HookEvent ME_OPT_INITIALISE") , MSG_BOX_TITEL , MB_OK );
+
+
+ CLISTMENUITEM mi;
+ ZeroMemory(&mi,sizeof(mi));
+ mi.cbSize=sizeof(mi);
+ mi.flags=0;
+ mi.pszContactOwner=NULL; //all contacts
+ mi.hIcon=LoadIcon(hInstance,MAKEINTRESOURCE(IDI_EXPORT_MESSAGE));
+
+ if( bReplaceHistory )
+ {
+ mi.position= 1000090000;
+ mi.pszName=Translate("View &History");
+ mi.pszService=MS_HISTORY_SHOWCONTACTHISTORY;
+ }
+ else
+ {
+ mi.position = 1000090100;
+ mi.pszName=Translate("Open E&xported History");
+ mi.pszService=MS_SHOW_EXPORT_HISTORY;
+ }
+
+ hOpenHistoryMenuItem = (HANDLE)CallService(MS_CLIST_ADDCONTACTMENUITEM,0,(LPARAM)&mi);
+
+ if( !hOpenHistoryMenuItem )
+ MessageBox( NULL , _T("Failed to add menu item Open Exported History\nCallService(MS_CLIST_ADDCONTACTMENUITEM,...)") , MSG_BOX_TITEL , MB_OK );
+
+/*
+ hEventSystemShutdown = HookEvent( ME_SYSTEM_SHUTDOWN , nSystemShutdown );
+
+ if( !hEventSystemShutdown )
+ MessageBox( NULL , "Failed to HookEvent ME_SYSTEM_SHUTDOWN" , MSG_BOX_TITEL , MB_OK );
+*/
+
+/*
+ _TCHAR szBuf[ 10000 ];
+ for( int n = 0 ; n < 1000 ; n++ )
+ {
+ for( int y = 0 ; y < n ; y++ )
+ {
+ szBuf[ y ] = '0' + y%10;//((n + y) % 8 ) ? ('0' + ((n + y) % 10)) : ' ' ;
+ }
+ szBuf[ y ] = 0;
+
+ HANDLE hFile = CreateFile( "C:\\test.txt" , GENERIC_WRITE , FILE_SHARE_READ , 0 ,OPEN_ALWAYS , FILE_ATTRIBUTE_NORMAL , NULL );
+ SetFilePointer( hFile , 0 , 0 , FILE_END );
+
+ bWriteNewLine( hFile , 10 );
+ bWriteNewLine( hFile , 0 );
+ bWriteNewLine( hFile , 120 );
+
+ DWORD dwBytesWritten;
+ WriteFile( hFile , "\r\n\r\n" , 4 , &dwBytesWritten , NULL );
+
+ CloseHandle( hFile );
+ //}*/
+
+ return 0;
+}
+
+
+
+/////////////////////////////////////////////////////////////////////
+// Member Function : DllMain
+// Type : Global
+// Parameters : hinst - ?
+// fdwReason - ?
+// lpvReserved - ?
+// Returns : BOOL WINAPI
+// Description :
+//
+// References : -
+// Remarks : -
+// Created : 020422 , 22 April 2002
+// Developer : KN
+/////////////////////////////////////////////////////////////////////
+
+BOOL WINAPI DllMain(HINSTANCE hinst,DWORD /*fdwReason*/,LPVOID /*lpvReserved*/)
+{
+ hInstance=hinst;
+ return 1;
+}
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/////////////////////////////////////////////////////////////////////
+// Member Function : MirandaPluginInfo
+// Type : Global
+// Parameters : mirandaVersion - ?
+// Returns :
+// Description :
+//
+// References : -
+// Remarks : -
+// Created : 020422 , 22 April 2002
+// Developer : KN
+/////////////////////////////////////////////////////////////////////
+
+__declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD /*mirandaVersion*/)
+{
+ return &pluginInfo;
+}
+
+static const MUUID interfaces[] = { MIID_HISTORYEXPORT, MIID_LAST};
+extern "C" __declspec(dllexport) const MUUID * MirandaPluginInterfaces(void)
+{
+ return interfaces;
+}
+
+/////////////////////////////////////////////////////////////////////
+// Member Function : Load
+// Type : Global
+// Parameters : link - ?
+// Returns : int
+// Description :
+//
+// References : -
+// Remarks : -
+// Created : 020422 , 22 April 2002
+// Developer : KN
+/////////////////////////////////////////////////////////////////////
+
+int __declspec(dllexport)Load(PLUGINLINK *link)
+{
+ pluginLink=link;
+ mir_getMMI( &mmi );
+ mir_getUTFI(&utfi);
+ hEventSystemInit = HookEvent(ME_SYSTEM_MODULESLOADED,MainInit);
+
+ if( !hEventSystemInit )
+ {
+ MessageBox( NULL , _T("Failed to HookEvent ME_SYSTEM_MODULESLOADED") , MSG_BOX_TITEL , MB_OK );
+ return 0;
+ }
+
+ nMaxLineWidth = DBGetContactSettingWord( NULL , MODULE , "MaxLineWidth" , nMaxLineWidth );
+ if( nMaxLineWidth < 5 )
+ nMaxLineWidth = 5;
+
+ sExportDir = DBGetString( NULL , MODULE , "ExportDir" , _T("%dbpath%\\MsgExport\\") );
+ sDefaultFile = DBGetString( NULL , MODULE , "DefaultFile" , _T("%nick%.txt") );
+
+ sTimeFormat = DBGetString( NULL , MODULE , "TimeFormat" , _T("d s") );
+
+ sFileViewerPrg = DBGetString( NULL , MODULE , "FileViewerPrg" , _T("") );
+ bUseInternalViewer( DBGetContactSettingByte( NULL , MODULE , "UseInternalViewer" , bUseInternalViewer() ) != 0 );
+
+ bReplaceHistory = DBGetContactSettingByte( NULL , MODULE , "ReplaceHistory" , bReplaceHistory ) != 0;
+ bAppendNewLine = DBGetContactSettingByte( NULL , MODULE , "AppendNewLine" , bAppendNewLine ) != 0;
+ bUseUtf8InNewFiles = DBGetContactSettingByte( NULL , MODULE , "UseUtf8InNewFiles" , bUseUtf8InNewFiles ) != 0;
+ bUseLessAndGreaterInExport = DBGetContactSettingByte( NULL , MODULE , "UseLessAndGreaterInExport" , bUseLessAndGreaterInExport ) != 0;
+
+ enRenameAction = (ENDialogAction)DBGetContactSettingByte( NULL , MODULE , "RenameAction" , enRenameAction );
+ enDeleteAction = (ENDialogAction)DBGetContactSettingByte( NULL , MODULE , "DeleteAction" , enDeleteAction );;
+
+ // Plugin sweeper support
+ DBWriteContactSettingTString(NULL,"Uninstall","Message Export",_T(MODULE));
+
+ if( bReplaceHistory )
+ {
+ hServiceFunc = CreateServiceFunction(MS_HISTORY_SHOWCONTACTHISTORY,ShowExportHistory);
+ if( hServiceFunc )
+ {
+ int *disableDefaultModule=(int*)CallService(MS_PLUGINS_GETDISABLEDEFAULTARRAY,0,0);
+ if( disableDefaultModule )
+ {
+ disableDefaultModule[DEFMOD_UIHISTORY] = TRUE;
+ }
+ else
+ {
+ DestroyServiceFunction( hServiceFunc );
+ hServiceFunc = 0;
+ }
+ }
+
+ if( ! hServiceFunc )
+ MessageBox( NULL , TranslateTS(_T("Failed to replace Miranda History.\r\nThis is most likely due to changes in Miranda.")) , MSG_BOX_TITEL , MB_OK );
+ }
+
+ if( ! hServiceFunc )
+ {
+ hServiceFunc = CreateServiceFunction(MS_SHOW_EXPORT_HISTORY,ShowExportHistory);
+ }
+
+ if( ! hServiceFunc )
+ {
+ MessageBox( NULL , _T("Failed to CreateServiceFunction MS_SHOW_EXPORT_HISTORY") , MSG_BOX_TITEL , MB_OK );
+ }
+
+ return 0;
+}
+
+/////////////////////////////////////////////////////////////////////
+// Member Function : Unload
+// Type : Global
+// Parameters : none
+// Returns :
+// Description :
+//
+// References : -
+// Remarks : -
+// Created : 020422 , 22 April 2002
+// Developer : KN
+/////////////////////////////////////////////////////////////////////
+
+__declspec(dllexport)int Unload(void)
+{
+ //if( !hEventSystemShutdown ) // we will try to unload anyway
+ {
+ nSystemShutdown(0,0);
+ }
+ Uninitilize();
+ bUseInternalViewer( false );
+ return 0;
+}
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/msg_export.dep b/msg_export.dep
new file mode 100755
index 0000000..4ca2789
--- /dev/null
+++ b/msg_export.dep
@@ -0,0 +1,54 @@
+# Microsoft Developer Studio Generated Dependency File, included by msg_export.mak
+
+.\main.c : \
+ "..\..\miranda32\core\m_system.h"\
+ "..\..\miranda32\database\m_database.h"\
+ "..\..\miranda32\random\langpack\m_langpack.h"\
+ "..\..\miranda32\random\plugins\m_plugins.h"\
+ "..\..\miranda32\random\plugins\newpluginapi.h"\
+ "..\..\miranda32\random\skin\m_skin.h"\
+ "..\..\miranda32\ui\contactlist\m_clist.h"\
+ "..\..\miranda32\ui\contactlist\statusmodes.h"\
+ "..\..\miranda32\ui\options\m_options.h"\
+ ".\glob.h"\
+ ".\options.h"\
+ ".\utils.h"\
+ "c:\program files\microsoft platform sdk\include\basetsd.h"\
+ "c:\program files\microsoft platform sdk\include\guiddef.h"\
+ "c:\program files\microsoft platform sdk\include\propidl.h"\
+ "c:\program files\microsoft platform sdk\include\tvout.h"\
+ "c:\program files\microsoft platform sdk\include\winefs.h"\
+
+
+.\options.c : \
+ "..\..\miranda32\database\m_database.h"\
+ "..\..\miranda32\random\plugins\m_plugins.h"\
+ "..\..\miranda32\random\plugins\newpluginapi.h"\
+ "..\..\miranda32\ui\options\m_options.h"\
+ ".\glob.h"\
+ ".\utils.h"\
+ "c:\program files\microsoft platform sdk\include\basetsd.h"\
+ "c:\program files\microsoft platform sdk\include\guiddef.h"\
+ "c:\program files\microsoft platform sdk\include\propidl.h"\
+ "c:\program files\microsoft platform sdk\include\shldisp.h"\
+ "c:\program files\microsoft platform sdk\include\tvout.h"\
+ "c:\program files\microsoft platform sdk\include\winefs.h"\
+
+
+.\utils.c : \
+ "..\..\miranda32\database\m_database.h"\
+ "..\..\miranda32\random\plugins\m_plugins.h"\
+ "..\..\miranda32\random\plugins\newpluginapi.h"\
+ "..\..\miranda32\ui\contactlist\m_clist.h"\
+ "..\..\miranda32\ui\contactlist\statusmodes.h"\
+ ".\glob.h"\
+ "c:\program files\microsoft platform sdk\include\basetsd.h"\
+ "c:\program files\microsoft platform sdk\include\guiddef.h"\
+ "c:\program files\microsoft platform sdk\include\propidl.h"\
+ "c:\program files\microsoft platform sdk\include\tvout.h"\
+ "c:\program files\microsoft platform sdk\include\winefs.h"\
+
+
+.\resource.rc : \
+ ".\export_m.ico"\
+
diff --git a/msg_export.dsp b/msg_export.dsp
new file mode 100755
index 0000000..6dba434
--- /dev/null
+++ b/msg_export.dsp
@@ -0,0 +1,236 @@
+# Microsoft Developer Studio Project File - Name="msg_export" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
+
+CFG=msg_export - Win32 Release
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "msg_export.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "msg_export.mak" CFG="msg_export - Win32 Release"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "msg_export - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "msg_export - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "msg_export - Win32 Debug Unicode" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "msg_export - Win32 Release Unicode" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+MTL=midl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "msg_export - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MSG_EXPORT_EXPORTS" /YX /FD /c
+# ADD CPP /nologo /MT /W4 /Gi /GX /O1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x407 /d "NDEBUG"
+# ADD RSC /l 0x409 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
+# ADD LINK32 msvcrt.lib User32.lib Kernel32.lib Comdlg32.lib Shell32.lib Gdi32.lib comctl32.lib libcpmtd.lib oldnames.lib /nologo /base:"0x22100000" /dll /pdb:none /machine:I386 /nodefaultlib /filealign:0x200
+# SUBTRACT LINK32 /map /debug
+
+!ELSEIF "$(CFG)" == "msg_export - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "msg_export___Win32_Debug"
+# PROP BASE Intermediate_Dir "msg_export___Win32_Debug"
+# PROP BASE Ignore_Export_Lib 1
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "msg_export___Win32_Debug"
+# PROP Intermediate_Dir "msg_export___Win32_Debug"
+# PROP Ignore_Export_Lib 1
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MD /W3 /Gi /GX /O2 /YX /FD /c
+# ADD CPP /nologo /MT /W4 /Gi /GX /ZI /Od /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /FR /YX /FD /c
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x407 /d "NDEBUG"
+# ADD RSC /l 0x409 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 user32.lib gdi32.lib comdlg32.lib /nologo /dll /pdb:none /machine:I386 /out:"Release/enotify.dll" /filealign:0x200
+# ADD LINK32 User32.lib Shell32.lib Comdlg32.lib Gdi32.lib comctl32.lib /nologo /base:"0x22100000" /dll /pdb:none /debug /debugtype:both /machine:I386 /out:"../Bin/Debug/plugins/Msg_Export.dll" /filealign:0x200
+# SUBTRACT LINK32 /map /nodefaultlib
+
+!ELSEIF "$(CFG)" == "msg_export - Win32 Debug Unicode"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "msg_export___Win32_Debug_Unicode"
+# PROP BASE Intermediate_Dir "msg_export___Win32_Debug_Unicode"
+# PROP BASE Ignore_Export_Lib 1
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "msg_export___Win32_Debug_Unicode"
+# PROP Intermediate_Dir "msg_export___Win32_Debug_Unicode"
+# PROP Ignore_Export_Lib 1
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MT /W4 /Gi /GX /ZI /Od /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_UNICODE" /D "UNICODE" /FR /YX /FD /c
+# ADD CPP /nologo /MT /W4 /Gi /GX /ZI /Od /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_UNICODE" /D "UNICODE" /FR /YX /FD /c
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 User32.lib Shell32.lib Comdlg32.lib Gdi32.lib comctl32.lib /nologo /base:"0x22100000" /dll /pdb:none /debug /debugtype:both /machine:I386 /out:"../Bin/Debug/plugins/Msg_Export.dll" /filealign:0x200
+# SUBTRACT BASE LINK32 /map /nodefaultlib
+# ADD LINK32 User32.lib Shell32.lib Comdlg32.lib Gdi32.lib comctl32.lib /nologo /base:"0x22100000" /dll /pdb:none /debug /debugtype:both /machine:I386 /out:"../Bin/Debug/plugins/Msg_Export.dll" /filealign:0x200
+# SUBTRACT LINK32 /map /nodefaultlib
+
+!ELSEIF "$(CFG)" == "msg_export - Win32 Release Unicode"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "msg_export___Win32_Release_Unicode"
+# PROP BASE Intermediate_Dir "msg_export___Win32_Release_Unicode"
+# PROP BASE Ignore_Export_Lib 0
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release_Unicode"
+# PROP Intermediate_Dir "Release_Unicode"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MT /W4 /Gi /GX /O1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
+# ADD CPP /nologo /MT /W4 /Gi /GX /O1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_UNICODE" /D "UNICODE" /YX /FD /c
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x409 /d "NDEBUG"
+# ADD RSC /l 0x409 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 msvcrt.lib User32.lib Kernel32.lib Comdlg32.lib Shell32.lib Gdi32.lib comctl32.lib libcpmtd.lib oldnames.lib /nologo /base:"0x22100000" /dll /pdb:none /machine:I386 /nodefaultlib /filealign:0x200
+# SUBTRACT BASE LINK32 /map /debug
+# ADD LINK32 msvcrt.lib User32.lib Kernel32.lib Comdlg32.lib Shell32.lib Gdi32.lib comctl32.lib libcpmtd.lib oldnames.lib /nologo /base:"0x22100000" /dll /pdb:none /machine:I386 /nodefaultlib /filealign:0x200
+# SUBTRACT LINK32 /map /debug
+
+!ENDIF
+
+# Begin Target
+
+# Name "msg_export - Win32 Release"
+# Name "msg_export - Win32 Debug"
+# Name "msg_export - Win32 Debug Unicode"
+# Name "msg_export - Win32 Release Unicode"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=.\FileViewer.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\FileViewer.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\Glob.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\main.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\options.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\options.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\utils.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\utils.h
+# End Source File
+# End Group
+# Begin Group "Resource Files"
+
+# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+# Begin Source File
+
+SOURCE=.\export_m.ico
+# End Source File
+# Begin Source File
+
+SOURCE=.\file_vie.ico
+# End Source File
+# Begin Source File
+
+SOURCE=.\notick.ico
+# End Source File
+# Begin Source File
+
+SOURCE=.\resource.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\resource.rc
+# End Source File
+# Begin Source File
+
+SOURCE=.\tick.ico
+# End Source File
+# End Group
+# Begin Source File
+
+SOURCE=.\Changelog.txt
+# End Source File
+# Begin Source File
+
+SOURCE=.\langpack_msg_export.txt
+# End Source File
+# Begin Source File
+
+SOURCE=.\msg_export.txt
+# End Source File
+# Begin Source File
+
+SOURCE=.\TimeNotes.txt
+# End Source File
+# End Target
+# End Project
diff --git a/msg_export.dsw b/msg_export.dsw
new file mode 100755
index 0000000..fc79aff
--- /dev/null
+++ b/msg_export.dsw
@@ -0,0 +1,29 @@
+Microsoft Developer Studio Workspace File, Format Version 6.00
+# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
+
+###############################################################################
+
+Project: "msg_export"=".\msg_export.dsp" - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Global:
+
+Package=<5>
+{{{
+}}}
+
+Package=<3>
+{{{
+}}}
+
+###############################################################################
+
diff --git a/msg_export.sln b/msg_export.sln
new file mode 100755
index 0000000..cb62ce4
--- /dev/null
+++ b/msg_export.sln
@@ -0,0 +1,26 @@
+
+Microsoft Visual Studio Solution File, Format Version 10.00
+# Visual Studio 2008
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "msg_export", "msg_export.vcproj", "{4CE78D43-FF23-4134-A5AC-B2CF0F8D9F3B}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug - Unicode|Win32 = Debug - Unicode|Win32
+ Debug|Win32 = Debug|Win32
+ Release - Unicode|Win32 = Release - Unicode|Win32
+ Release|Win32 = Release|Win32
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {4CE78D43-FF23-4134-A5AC-B2CF0F8D9F3B}.Debug - Unicode|Win32.ActiveCfg = Debug - Unicode|Win32
+ {4CE78D43-FF23-4134-A5AC-B2CF0F8D9F3B}.Debug - Unicode|Win32.Build.0 = Debug - Unicode|Win32
+ {4CE78D43-FF23-4134-A5AC-B2CF0F8D9F3B}.Debug|Win32.ActiveCfg = Debug|Win32
+ {4CE78D43-FF23-4134-A5AC-B2CF0F8D9F3B}.Debug|Win32.Build.0 = Debug|Win32
+ {4CE78D43-FF23-4134-A5AC-B2CF0F8D9F3B}.Release - Unicode|Win32.ActiveCfg = Release - Unicode|Win32
+ {4CE78D43-FF23-4134-A5AC-B2CF0F8D9F3B}.Release - Unicode|Win32.Build.0 = Release - Unicode|Win32
+ {4CE78D43-FF23-4134-A5AC-B2CF0F8D9F3B}.Release|Win32.ActiveCfg = Release|Win32
+ {4CE78D43-FF23-4134-A5AC-B2CF0F8D9F3B}.Release|Win32.Build.0 = Release|Win32
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/msg_export.txt b/msg_export.txt
new file mode 100755
index 0000000..114b2b7
--- /dev/null
+++ b/msg_export.txt
@@ -0,0 +1,200 @@
+Description
+ Exports every message, URL or File you receive to a text file.
+ Messages are exported to one file per user. New messages are
+ exported when you receive them. Can be used as history management.
+
+ Features:
+ -Export all or some of your current history
+ -Set individual files per user
+ -Set the time format/ column width
+ -Open history file for a user from Miranda.
+ -Use internal or external File Viewer
+ -File change detection / reload
+ -File name change detection.
+ -Font and background color selection.
+
+ Send bug reports, comments and Suggestions to: Kennet_N@ofir.dk.
+
+Export directory
+ The path your messages will be exported to.
+ You can write a complete path or you can use %dbpath% which is the
+ ProfileDir= from your mirandaboot.ini.
+ You can also use all the variables ( %..% ) from Default File.
+ The "Default File" or the file from "User list" will be joined together
+ with the "Export directory" to form the complete file path.
+
+ Default: %dbpath%\MsgExport\
+
+Browse
+ This will open a "Browse for a folder" where you can select the
+ Export directory.
+ see Export directory for details.
+
+Default File
+ This sets the default file name which will be used if you do not
+ specify another on in the User list.
+ You can use
+ %nick% Nick you are received from or sending to.
+ %UIN% UIN you are received from or sending to.
+ %group% The group you have put the user in.
+ %e-mail% The users E-mail address.
+ %protocol% The protocol which the user is using.
+ %identifier% This is a protocol specific variable.
+ If it is an ICQ user it will be UIN.
+ If it is a MSN user it will be e-mail.
+ If it is a Jabber user Jabber ID is used.
+ When %UIN% or %e-mail% can nor be found %nick% is used.
+
+ The following variables do not cause the file name change notification
+ %year% The current year as a 4 digit number
+ %month% The current month as a 2 digit number
+ %day% The current day as a 2 digit number
+ %hour% The current day as a 2 digit number
+
+ Default: %nick%.txt
+
+Max column width
+ This is the maximum line width that will be written to the file.
+ If you receive a message which has a longer line the line will
+ be broken up in 2 or more lines.
+
+ Default: 80
+
+Time format
+ Here you can set the format of the time column in the export file.
+ The time column is the one after the user.
+ You can use:
+ t Time without seconds, e.g. hh:mm
+ s Time with seconds, e.g. hh:mm:ss
+ m Time without minutes, e.g. hh
+ d Short date, e.g. dd/mm/yyyy
+ D Long date, e.g. d mmmm yyyy
+
+ If you write any other characters they will simply be copied over.
+ So you may use "d t :" if you like to add a ":" before the message.
+
+ Default: "d s"
+
+Replace miranda history
+ This option allows you to make the msg_export File Viewer you default
+ miranda history viewer. If you do not set this option msg_export will
+ create a new menu item to view the exported text file.
+
+ Default: Not checked
+
+Use internal viewer
+ If you set this option msg_export will use its own File Viewer to
+ open the history file's. If you do not set it it will use the program
+ you have associated with *.txt files
+
+ Default: Checked
+
+External file viewer
+ Here you can set the program you which to use to view your history files
+ If you set the path to en empty string the explorer default will be
+ used, this is just like double clicking the file in your explorer.
+ The program that you choose will be lunched with the file as the first
+ parameter.
+
+ Default:
+
+Use UTF8 in new files
+ This option allows you to select the file format you wish message export
+ to use. When this option is enabled new files created will use Unicode
+ Transformation Format 8. When used with the Unicode version of Miranda
+ you can store Unicode in the text files.
+ When the option is not enabled files are stored in ANSI format.
+ UTF8 file format allows you to move the file to a PC with a different
+ code page and the text will still be displayed right.
+ Message export always read what format a file is before exporting and
+ will use the same format again. To convert an existing file to use UTF8
+ you can open it in Notepad and save it as UTF8.
+
+Append extra new line
+ If this option is checked every message exported will have en extra new
+ line between them.
+
+ Default: Checked
+
+Use << and >>
+ If this option is checked << and >> will be used instead of "your nick"
+ and "receiver nick" in the exported format.
+
+ Default: Not checked
+
+User list
+ This is a list of your users.
+ Here you can set which file you would like to export to.
+ If you do not set any file the default <Nick>.txt will be used.
+ If you remove the check in the checkbox no export will be made.
+
+Auto filename
+ This will try to find accounts in your user list which is the same
+ person.
+ Some people have multiply accounts on different networks or one at
+ work (nick@work) and one at home (nick).
+ Normally these two accounts would become 2 different files.
+ If you set the (nick@work) to use the (nick) file, events from both
+ accounts will be written to the same file, creating a single file with
+ all your message history from that person.
+ It will not replace any filenames that is already set!
+
+Clear all
+ This will clear all the file's you have entered in the User list.
+
+Export all history
+ This will export all your history from the database.
+ You will only need to activate this function after you have installed
+ this plugin or if you change the export directory or format.
+ Note that all events will simply be added to the current files even if
+ the event is already in the file.
+ Important !
+ Exported events will be sorted according to the time you received them,
+ therefore the order may NOT be the same as when you look in the
+ history in Miranda.
+ The history in Miranda may be in incorrect order if the original
+ messages come from the AOL's ICQ. This is my experience.
+
+When filename changes
+ This sets the action that msg_export will take when it detects that a
+ file has been renamed. You can choose between
+ -Prompt for action: This will show a dialog every time
+ -Rename file: This will automatically rename the file every time
+ -Do nothing: This will ignore the event, resulting in multiply files
+
+ Default: Prompt for action
+
+When user is deleted
+ This sets the action that msg_export will take when it detects that a
+ user has been deleted and that no other user is using the file the
+ deleted user was writing to. You can choose between
+ -Prompt for action: This will show a dialog every time.
+ -Delete file: This will automatically delete the file.
+ -Do nothing: This will ignore the event, resulting in an unused file.
+
+ Default: Prompt for action
+
+Export Protocols
+ This is a list of your protocols.
+ If you remove the check in the checkbox no export will be made for that
+ protocol.
+
+##########################################################################
+########################## File Viewer ###########################
+##########################################################################
+
+Find...
+ Openens a standart search dialog box to search in the open file.
+
+External
+ This will open the Text File in the program you have associated with
+ *.txt files.
+
+Font...
+ This item is located in the system menu (Top left corner) it alows you to
+ change the font used in the file viewer. You can also set the Font
+ color.
+
+Color...
+ This item is located in the system menu (Top left corner) it alows you to
+ change the back ground color. \ No newline at end of file
diff --git a/msg_export.vcproj b/msg_export.vcproj
new file mode 100755
index 0000000..fb41abc
--- /dev/null
+++ b/msg_export.vcproj
@@ -0,0 +1,603 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="9,00"
+ Name="msg_export"
+ ProjectGUID="{4CE78D43-FF23-4134-A5AC-B2CF0F8D9F3B}"
+ RootNamespace="msg_export"
+ TargetFrameworkVersion="131072"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="2"
+ InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
+ UseOfMFC="0"
+ ATLMinimizesCRunTimeLibraryUsage="false"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ PreprocessorDefinitions="NDEBUG"
+ MkTypLibCompatible="true"
+ SuppressStartupBanner="true"
+ TargetEnvironment="1"
+ TypeLibraryName=".\Release/msg_export.tlb"
+ HeaderFileName=""
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="1"
+ InlineFunctionExpansion="1"
+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS"
+ StringPooling="true"
+ RuntimeLibrary="0"
+ EnableFunctionLevelLinking="true"
+ UsePrecompiledHeader="0"
+ WarningLevel="4"
+ SuppressStartupBanner="true"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ PreprocessorDefinitions="NDEBUG"
+ Culture="1033"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalOptions="/filealign:0x200"
+ AdditionalDependencies="comctl32.lib"
+ LinkIncremental="1"
+ SuppressStartupBanner="true"
+ GenerateManifest="false"
+ IgnoreAllDefaultLibraries="false"
+ BaseAddress="0x22100000"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="2"
+ InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
+ UseOfMFC="0"
+ ATLMinimizesCRunTimeLibraryUsage="false"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ PreprocessorDefinitions="NDEBUG"
+ MkTypLibCompatible="true"
+ SuppressStartupBanner="true"
+ TargetEnvironment="1"
+ TypeLibraryName=".\msg_export___Win32_Debug/msg_export.tlb"
+ HeaderFileName=""
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions="_DEBUG;WIN32;_WINDOWS"
+ RuntimeLibrary="1"
+ UsePrecompiledHeader="0"
+ BrowseInformation="1"
+ WarningLevel="4"
+ SuppressStartupBanner="true"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ PreprocessorDefinitions="_DEBUG"
+ Culture="1033"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ IgnoreImportLibrary="true"
+ AdditionalOptions="/filealign:0x200"
+ AdditionalDependencies="comctl32.lib"
+ OutputFile="../Bin/Debug/plugins/Msg_Export.dll"
+ LinkIncremental="1"
+ SuppressStartupBanner="true"
+ GenerateManifest="false"
+ IgnoreAllDefaultLibraries="false"
+ GenerateDebugInformation="true"
+ BaseAddress="0x22100000"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Debug - Unicode|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="2"
+ InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
+ UseOfMFC="0"
+ ATLMinimizesCRunTimeLibraryUsage="false"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ PreprocessorDefinitions="NDEBUG"
+ MkTypLibCompatible="true"
+ SuppressStartupBanner="true"
+ TargetEnvironment="1"
+ TypeLibraryName=".\msg_export___Win32_Debug/msg_export.tlb"
+ HeaderFileName=""
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories="&quot;X:\install\git\miranda\miranda-im\miranda\include&quot;"
+ PreprocessorDefinitions="_DEBUG;WIN32;_WINDOWS;UNICODE;_UNICODE;_CRT_SECURE_NO_DEPRECATE"
+ RuntimeLibrary="1"
+ UsePrecompiledHeader="0"
+ BrowseInformation="1"
+ WarningLevel="4"
+ SuppressStartupBanner="true"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ PreprocessorDefinitions="_DEBUG"
+ Culture="1033"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ IgnoreImportLibrary="true"
+ AdditionalOptions="/filealign:0x200"
+ AdditionalDependencies="comctl32.lib user32.lib kernel32.lib comdlg32.lib shell32.lib"
+ LinkIncremental="1"
+ SuppressStartupBanner="true"
+ GenerateManifest="false"
+ IgnoreAllDefaultLibraries="false"
+ GenerateDebugInformation="true"
+ ProgramDatabaseFile="c:\debug\$(TargetName).pdb"
+ BaseAddress="0x22100000"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release - Unicode|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="2"
+ InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
+ UseOfMFC="0"
+ ATLMinimizesCRunTimeLibraryUsage="false"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ PreprocessorDefinitions="NDEBUG"
+ MkTypLibCompatible="true"
+ SuppressStartupBanner="true"
+ TargetEnvironment="1"
+ TypeLibraryName=".\Release/msg_export.tlb"
+ HeaderFileName=""
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="1"
+ InlineFunctionExpansion="1"
+ AdditionalIncludeDirectories="&quot;X:\install\git\miranda\miranda-im\miranda\include&quot;"
+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;UNICODE;_UNICODE;_CRT_SECURE_NO_DEPRECATE"
+ StringPooling="true"
+ RuntimeLibrary="0"
+ EnableFunctionLevelLinking="true"
+ UsePrecompiledHeader="0"
+ WarningLevel="4"
+ SuppressStartupBanner="true"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ PreprocessorDefinitions="NDEBUG"
+ Culture="1033"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalOptions="/filealign:0x200"
+ AdditionalDependencies="comctl32.lib user32.lib kernel32.lib comdlg32.lib shell32.lib"
+ LinkIncremental="1"
+ SuppressStartupBanner="true"
+ GenerateManifest="false"
+ IgnoreAllDefaultLibraries="false"
+ BaseAddress="0x22100000"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+ >
+ <File
+ RelativePath="FileViewer.cpp"
+ >
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="1"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ BrowseInformation="1"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug - Unicode|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ BrowseInformation="1"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release - Unicode|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="1"
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="FileViewer.h"
+ >
+ </File>
+ <File
+ RelativePath="Glob.h"
+ >
+ </File>
+ <File
+ RelativePath="main.cpp"
+ >
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="1"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ BrowseInformation="1"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug - Unicode|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ BrowseInformation="1"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release - Unicode|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="1"
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="options.cpp"
+ >
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="1"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ BrowseInformation="1"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug - Unicode|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ BrowseInformation="1"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release - Unicode|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="1"
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="options.h"
+ >
+ </File>
+ <File
+ RelativePath="utils.cpp"
+ >
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="1"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ BrowseInformation="1"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug - Unicode|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ BrowseInformation="1"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release - Unicode|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="1"
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="utils.h"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Resource Files"
+ Filter="ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+ >
+ <File
+ RelativePath="export_m.ico"
+ >
+ </File>
+ <File
+ RelativePath="file_vie.ico"
+ >
+ </File>
+ <File
+ RelativePath="notick.ico"
+ >
+ </File>
+ <File
+ RelativePath="resource.h"
+ >
+ </File>
+ <File
+ RelativePath="resource.rc"
+ >
+ </File>
+ <File
+ RelativePath="tick.ico"
+ >
+ </File>
+ </Filter>
+ <File
+ RelativePath="Changelog.txt"
+ >
+ </File>
+ <File
+ RelativePath="langpack_msg_export.txt"
+ >
+ </File>
+ <File
+ RelativePath="msg_export.txt"
+ >
+ </File>
+ <File
+ RelativePath="TimeNotes.txt"
+ >
+ </File>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/notick.ico b/notick.ico
new file mode 100755
index 0000000..4ff17df
--- /dev/null
+++ b/notick.ico
Binary files differ
diff --git a/options.cpp b/options.cpp
new file mode 100755
index 0000000..4464658
--- /dev/null
+++ b/options.cpp
@@ -0,0 +1,1483 @@
+
+//This file is part of Msg_Export a Miranda IM plugin
+//Copyright (C)2002 Kennet Nielsen ( http://sourceforge.net/projects/msg-export/ )
+//
+//This program is free software; you can redistribute it and/or
+//modify it under the terms of the GNU General Public License
+//as published by the Free Software Foundation; either
+//version 2 of the License, or (at your option) any later version.
+//
+//This program is distributed in the hope that it will be useful,
+//but WITHOUT ANY WARRANTY; without even the implied warranty of
+//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+//GNU General Public License for more details.
+//
+//You should have received a copy of the GNU General Public License
+//along with this program; if not, write to the Free Software
+//Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+
+#include <windows.h>
+#include <commctrl.h>
+#include "Shlobj.h"
+
+
+#include "Utils.h"
+#include "Glob.h"
+#include "FileViewer.h"
+
+#include "resource.h"
+
+#include <stdio.h>
+#include <list>
+//#include <algorithm>
+
+#define STRINGIZE(x) #x
+#define EVAL_STRINGIZE(x) STRINGIZE(x)
+#define __LOC__ __FILE__ "("EVAL_STRINGIZE(__LINE__)") : "
+
+
+#pragma message ( __LOC__ "My warning: STD list contains a bug when sorting lists of more than 32,768 elements, you need to fix this")
+/* Change code for VC 6.0
+ if (_I == _MAXN)
+ _A[_I].merge(_X);
+ SHOULD BE
+ if (_I == _MAXN)
+ _A[_I - 1].merge(_X);
+
+ - And -
+
+ if (_I == _MAXN)
+ _A[_I].merge(_X, _Pr);
+ SHOULD BE
+ if (_I == _MAXN)
+ _A[_I - 1].merge(_X, _Pr);
+
+You need to change this in the file <list> function sort() and sort(_Pr3 _Pr)
+*/
+
+using namespace std;
+
+
+// width in pixels of the UIN column in the List Ctrl
+const int nUINColWitdh = 80;
+// width in pixels of the UIN column in the List Ctrl
+const int nProtoColWitdh = 40;
+
+
+// Used to controle the sending of the PSM_CHANGED to miranda
+// and to se if the user has unapplyed changes when he presses the
+// Export All button
+BOOL bUnaplyedChanges = FALSE;
+
+
+/////////////////////////////////////////////////////////////////////
+// Class : CLDBEvent
+// Superclass :
+// Project : Mes_export
+// Designer : Kennet Nielsen
+// Version : 1.0.0
+// Date : 020422 , 22 April 2002
+//
+//
+// Description: This class is used to store one DB event dyring the export
+// All history function
+//
+// Version History:
+// Ver: Initials: Date: Text:
+// 1.0.0 KN 020422 First edition
+//
+/////////////////////////////////////////////////////////////////////
+
+class CLDBEvent
+{
+ DWORD time;
+ public:
+ HANDLE hUser;
+ HANDLE hDbEvent;
+
+ CLDBEvent( HANDLE hU , HANDLE hDBE )
+ {
+ hUser = hU;
+ hDbEvent = hDBE;
+
+ DBEVENTINFO dbei={0}; //dbei.cbBlob=0;
+ dbei.cbSize=sizeof(dbei);
+ CallService(MS_DB_EVENT_GET,(WPARAM)hDbEvent,(LPARAM)&dbei);
+ time = dbei.timestamp;
+ }
+ bool operator <(const CLDBEvent& rOther) const
+ {
+ return time < rOther.time;
+ }
+};
+
+/////////////////////////////////////////////////////////////////////
+// Member Function : CompareFunc
+// Type : Global
+// Parameters : lParam1 - ?
+// lParam2 - ?
+// lParamSort - ?
+// Returns : int CALLBACK
+// Description : Used to sort list view by Nick
+//
+// References : -
+// Remarks : -
+// Created : 020422 , 22 April 2002
+// Developer : KN
+/////////////////////////////////////////////////////////////////////
+
+int CALLBACK CompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort)
+{
+ if( lParamSort == 1 )
+ {
+ return _tcsicmp( NickFromHandle((HANDLE)lParam1) , NickFromHandle((HANDLE)lParam2) );
+ }
+
+ if( lParamSort == 2 )
+ {
+ return DBGetString( (HANDLE)lParam1 , "Protocol" , "p" , _T("") ).compare(
+ DBGetString( (HANDLE)lParam2 , "Protocol" , "p" , _T("") )
+ );
+ }
+ if( lParamSort == 3 )
+ {
+ DWORD dwUin1 = DBGetContactSettingDword(
+ (HANDLE)lParam1,
+ DBGetStringA( (HANDLE)lParam1 , "Protocol" , "p" , "" ).c_str(),
+ "UIN",
+ 0);
+ DWORD dwUin2 = DBGetContactSettingDword(
+ (HANDLE)lParam2,
+ DBGetStringA( (HANDLE)lParam2 , "Protocol" , "p" , "" ).c_str(),
+ "UIN",
+ 0);
+
+ if( dwUin1 == dwUin2 )
+ return 0;
+ if( dwUin1 > dwUin2 )
+ return -1;
+ return 1;
+ }
+ return 0;
+}
+
+
+/////////////////////////////////////////////////////////////////////
+// Member Function : DialogProc
+// Type : Global
+// Parameters : hwndDlg - ?
+// uMsg - ?
+// wParam - ?
+// parameter - ?
+// Returns : INT_PTR CALLBACK
+// Description : Progress bar window function
+//
+// References : -
+// Remarks : -
+// Created : 020422 , 22 April 2002
+// Developer : KN
+/////////////////////////////////////////////////////////////////////
+
+INT_PTR CALLBACK __stdcall DialogProc(
+ HWND hwndDlg, // handle to dialog box
+ UINT uMsg, // message
+ WPARAM /*wParam*/, // first message parameter
+ LPARAM /*lParam*/ // second message parameter
+)
+{
+ switch (uMsg)
+ {
+ case WM_INITDIALOG:
+ {
+ TranslateDialogDefault(hwndDlg);
+ return TRUE;
+ }
+ }
+ 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 )
+{
+ 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 , TranslateTS(_T("No contacts found to export")),MSG_BOX_TITEL,MB_OK );
+ return 0;
+ }
+
+ 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 ) );
+
+ SetWindowText( hStatus , TranslateTS(_T("Reading database information ( Phase 1 of 2 )")) );
+
+ { // position and show proigrassbar dialog
+
+ RECT rParrent;
+ RECT 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 );
+ }
+
+ // 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 , TranslateTS(_T("Failed to export at least one contact")),MSG_BOX_TITEL,MB_OK );
+ continue;
+ }
+
+ HANDLE hContact = (HANDLE)sItem.lParam;
+
+ list< CLDBEvent > & rclCurList = AllEvents[ GetFilePathFromUser( hContact ) ];
+
+ HANDLE hDbEvent = (HANDLE) CallService(MS_DB_EVENT_FINDFIRST,(WPARAM)hContact,0);
+ while( hDbEvent )
+ {
+ rclCurList.push_back( CLDBEvent( hContact , hDbEvent ) );
+
+ // Get next event in chain
+ hDbEvent = (HANDLE) CallService(MS_DB_EVENT_FINDNEXT,(WPARAM)hDbEvent,0);
+ }
+
+ SendMessage( hProg , PBM_SETPOS , nCur , 0);
+ RedrawWindow( hDlg , NULL , NULL , RDW_ALLCHILDREN | RDW_UPDATENOW );
+ }
+
+/*
+ if( hContact )
+ MessageBox( hParent , TranslateTS(_T("Failed to export at least one contact")),MSG_BOX_TITEL,MB_OK );
+ */
+ }
+
+
+ { // window text update
+
+ SetWindowText( hStatus , TranslateTS(_T("Sorting and writing database information ( Phase 2 of 2 )")) );
+ SendMessage( hProg , PBM_SETRANGE , 0 , MAKELPARAM( 0 , AllEvents.size() ) );
+ SendMessage( hProg , PBM_SETPOS , 0 , 0);
+ }
+
+ { // time to write to files !!!
+ map<tstring, list< CLDBEvent >, less<tstring> >::iterator FileIterator;
+
+ int nCur=0;
+ for( FileIterator = AllEvents.begin() ; FileIterator != AllEvents.end() ; ++FileIterator )
+ {
+ (FileIterator->second).sort(); // Sort is preformed here !!
+ // events with same time will not be swaped, they will
+ // remain in there original order
+
+ list< CLDBEvent >::const_iterator iterator;
+ for( iterator = FileIterator->second.begin() ; iterator != FileIterator->second.end() ; ++iterator )
+ {
+ HANDLE hDbEvent = (*iterator).hDbEvent;
+ nExportEvent( (WPARAM) (*iterator).hUser , (LPARAM) hDbEvent );
+ }
+ SendMessage( hProg , PBM_SETPOS , ++nCur , 0);
+ RedrawWindow( hDlg , NULL , NULL , RDW_ALLCHILDREN | RDW_UPDATENOW );
+ }
+ }
+
+ DestroyWindow( hDlg );
+ return 0;
+}
+
+/////////////////////////////////////////////////////////////////////
+// Member Function : SetToDefault
+// Type : Global
+// Parameters : hwndDlg - ?
+// Returns : void
+// Description :
+//
+// References : -
+// Remarks : -
+// Created : 021228 , 28 December 2002
+// Developer : KN
+/////////////////////////////////////////////////////////////////////
+
+void SetToDefault( HWND hParent )
+{
+ HWND hMapUser = GetDlgItem( hParent , IDC_MAP_USER_LIST );
+
+ int nContacts = ListView_GetItemCount( hMapUser );
+
+ if( !hMapUser || nContacts <= 0 )
+ {
+ return;
+ }
+
+ _TCHAR szTemp[ 500 ];
+ if( ! GetDlgItemText( hParent , IDC_DEFAULT_FILE , szTemp , sizeof( szTemp ) ) )
+ return;
+
+ LVITEM sItem = { 0 };
+
+ for( int nCur = 0 ; nCur < nContacts ; nCur++ )
+ {
+ if( ! (ListView_GetItemState( hMapUser , nCur , LVIS_SELECTED ) & LVIS_SELECTED) )
+ continue;
+
+ sItem.iItem = nCur;
+ sItem.mask = LVIF_PARAM;
+ if( ! ListView_GetItem( hMapUser, &sItem ) )
+ continue;
+
+ tstring sFileName = szTemp;
+ ReplaceDefines( (HANDLE)sItem.lParam , sFileName );
+ ReplaceTimeVariables( sFileName );
+
+ sItem.mask = LVIF_TEXT;
+ sItem.pszText = (_TCHAR*)sFileName.c_str();
+ ListView_SetItem( hMapUser, &sItem );
+
+ if( ! bUnaplyedChanges )
+ {
+ bUnaplyedChanges = TRUE;
+ SendMessage(GetParent(hParent), PSM_CHANGED, 0, 0);
+ }
+ }
+}
+
+/////////////////////////////////////////////////////////////////////
+// Member Function : bApplyChanges
+// Type : Global
+// Parameters : hwndDlg - handle to the parrent, ( Options Dlg )
+// Returns : Returns true if the changes was applyed
+// Description : but since we cant abort an apply opperation ,
+// this can not currently be used
+// References : -
+// Remarks : -
+// Created : 020422 , 22 April 2002
+// Developer : KN
+/////////////////////////////////////////////////////////////////////
+
+BOOL bApplyChanges( HWND hwndDlg )
+{
+ BOOL bTrans;
+ BOOL bRet = true;
+ _TCHAR szTemp[500];
+
+ int nTmp = GetDlgItemInt( hwndDlg , IDC_MAX_CLOUMN_WIDTH , &bTrans , TRUE );
+ if( !bTrans || nTmp < 5 )
+ {
+ _sntprintf( szTemp , sizeof( szTemp ) ,CheckedTranslate(_T("Max line width must be at least %d"),1) , 5 );
+ MessageBox( hwndDlg , szTemp ,MSG_BOX_TITEL,MB_OK );
+ bRet = false;
+ }
+ else
+ {
+ nMaxLineWidth = nTmp;
+ }
+
+ GetDlgItemText( hwndDlg , IDC_EXPORT_TIMEFORMAT , szTemp , sizeof( szTemp ) );
+ sTimeFormat = szTemp;
+
+ GetDlgItemText( hwndDlg , IDC_EXPORT_DIR , szTemp , sizeof( szTemp ) );
+ sExportDir = szTemp;
+
+ GetDlgItemText( hwndDlg , IDC_DEFAULT_FILE , szTemp , sizeof( szTemp ) );
+ sDefaultFile = szTemp;
+
+ GetDlgItemText( hwndDlg , IDC_FILE_VIEWER , szTemp , sizeof( szTemp ) );
+ sFileViewerPrg = szTemp;
+
+ bUseInternalViewer( IsDlgButtonChecked( hwndDlg , IDC_USE_INTERNAL_VIEWER ) == BST_CHECKED );
+
+ bool bNewRp = IsDlgButtonChecked( hwndDlg , IDC_REPLACE_MIRANDA_HISTORY ) == BST_CHECKED;
+ if( bReplaceHistory != bNewRp )
+ {
+ bReplaceHistory = bNewRp;
+ MessageBox( hwndDlg , TranslateTS(_T("You need to restart miranda to change the history function")) ,MSG_BOX_TITEL,MB_OK );
+ }
+
+ bAppendNewLine = IsDlgButtonChecked( hwndDlg , IDC_APPEND_NEWLINE ) == BST_CHECKED;
+ bUseUtf8InNewFiles = IsDlgButtonChecked( hwndDlg , IDC_USE_UTF8_IN_NEW_FILES ) == BST_CHECKED;
+
+ bUseLessAndGreaterInExport = IsDlgButtonChecked( hwndDlg , IDC_USE_LESS_AND_GREATER_IN_EXPORT ) == BST_CHECKED;
+
+
+ HWND hMapUser = GetDlgItem( hwndDlg , IDC_MAP_USER_LIST );
+ int nCount = ListView_GetItemCount( hMapUser );
+ for( int nCur = 0 ; nCur < nCount ; nCur++ )
+ {
+ LVITEM sItem = { 0 };
+ sItem.iItem = nCur;
+ sItem.mask = LVIF_TEXT | LVIF_PARAM | LVIF_IMAGE;
+ sItem.pszText = szTemp;
+ sItem.cchTextMax = sizeof( szTemp );
+
+ if( ListView_GetItem( hMapUser, &sItem ) )
+ {
+ HANDLE hUser = (HANDLE)sItem.lParam;
+ if( _tcslen( szTemp ) > 0 )
+ DBWriteContactSettingTString( hUser , MODULE , "FileName" , szTemp );
+ else
+ DBDeleteContactSetting( hUser , MODULE , "FileName" );
+
+ if( sItem.iImage )
+ DBDeleteContactSetting( hUser , MODULE , "EnableLog" ); // default is Enabled !!
+ else
+ DBWriteContactSettingByte( hUser , MODULE , "EnableLog",0);
+ }
+ }
+ UpdateFileToColWidth();
+
+ SaveSettings();
+
+
+ bUnaplyedChanges = FALSE;
+ return bRet;
+}
+
+/////////////////////////////////////////////////////////////////////
+// Member Function : ClearAllFileNames
+// Type : Global
+// Parameters : hwndDlg - handle to the parrent, ( Options Dlg )
+// Returns : void
+// Description : Just clear all file name's entered
+//
+// References : -
+// Remarks : -
+// Created : 020422 , 23 April 2002
+// Developer : KN
+/////////////////////////////////////////////////////////////////////
+
+void ClearAllFileNames(HWND hwndDlg)
+{
+ LVITEM sItem = { 0 };
+ sItem.mask = LVIF_TEXT;
+ sItem.pszText = _T("");
+
+ HWND hMapUser = GetDlgItem( hwndDlg , IDC_MAP_USER_LIST );
+ int nCount = ListView_GetItemCount( hMapUser );
+ for( int nCur = 0 ; nCur < nCount ; nCur++ )
+ {
+ sItem.iItem = nCur;
+ ListView_SetItem( hMapUser, &sItem );
+ }
+ if( ! bUnaplyedChanges )
+ {
+ bUnaplyedChanges = TRUE;
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ }
+}
+
+/////////////////////////////////////////////////////////////////////
+// Member Function : AutoFindeFileNames
+// Type : Global
+// Parameters : hwndDlg - handle to the parrent, ( Options Dlg )
+// Returns : void
+// Description : Try to finde new file names for user's with 2or more UIN's
+//
+// References : -
+// Remarks : -
+// Created : 020422 , 23 April 2002
+// Developer : KN
+/////////////////////////////////////////////////////////////////////
+
+void AutoFindeFileNames(HWND hwndDlg)
+{
+
+ _TCHAR szDefaultFile[500];
+ GetDlgItemText( hwndDlg , IDC_DEFAULT_FILE , szDefaultFile , sizeof( szDefaultFile ) );
+
+ LVITEM sItem = { 0 };
+
+ HWND hMapUser = GetDlgItem( hwndDlg , IDC_MAP_USER_LIST );
+ int nCount = ListView_GetItemCount( hMapUser );
+ for( int nCur = 0 ; nCur < nCount ; nCur++ )
+ {
+ _TCHAR szSearch[ 100 ];
+
+ sItem.mask = LVIF_TEXT;
+ sItem.iItem = nCur;
+ sItem.iSubItem = 1;
+ sItem.pszText = szSearch;
+ sItem.cchTextMax = sizeof( szSearch );
+
+ if( ! ListView_GetItem( hMapUser, &sItem ) )
+ {
+ continue;
+ }
+
+ int nShortestMatch = 0xFFFF;
+ HANDLE hStortest = 0;
+ int nStortestIndex = -1;
+ for( int nSubCur = 0 ; nSubCur < nCount ; nSubCur++ )
+ {
+ if( nSubCur == nCur )
+ continue;
+ _TCHAR szSubCur[ 100 ];
+ sItem.mask = LVIF_TEXT | LVIF_PARAM;
+ sItem.iItem = nSubCur;
+ sItem.iSubItem = 1;
+ sItem.pszText = szSubCur;
+ sItem.cchTextMax = sizeof( szSubCur );
+ if( ListView_GetItem( hMapUser, &sItem ) )
+ {
+ int nLen = _tcslen( szSubCur );
+ if( _tcsncicmp( szSubCur , szSearch , nLen ) == 0 )
+ {
+ if( nLen < nShortestMatch )
+ {
+ nShortestMatch = nLen;
+ nStortestIndex = nSubCur;
+ hStortest = (HANDLE)sItem.lParam;
+ }
+ }
+ }
+ }
+ if( nShortestMatch != 0xFFFF )
+ {
+ tstring sFileName;
+ szSearch[0] = 0;
+ ListView_GetItemText( hMapUser, nCur , 0 , szSearch , sizeof( szSearch ));
+ bool bPriHasFileName = szSearch[0] != 0;
+ if( bPriHasFileName )
+ sFileName = szSearch;
+
+ szSearch[0] = 0;
+ ListView_GetItemText( hMapUser, nStortestIndex , 0 , szSearch , sizeof( szSearch ));
+ bool bSubHasFileName = szSearch[0] != 0;
+ if( bSubHasFileName )
+ sFileName = szSearch;
+
+ if( sFileName.empty() )
+ {
+ sFileName = szDefaultFile;
+ ReplaceDefines( hStortest , sFileName );
+ ReplaceTimeVariables( sFileName );
+ }
+
+ if( !bPriHasFileName )
+ ListView_SetItemText( hMapUser, nCur , 0 , (_TCHAR*)sFileName.c_str() );
+
+ if( !bSubHasFileName )
+ ListView_SetItemText( hMapUser, nStortestIndex , 0 , (_TCHAR*)sFileName.c_str() );
+
+ if( ! bUnaplyedChanges )
+ {
+ bUnaplyedChanges = TRUE;
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ }
+ }
+ }
+}
+
+
+/////////////////////////////////////////////////////////////////////
+// Member Function : OpenHelp
+// Type : Global
+// Parameters : hwndDlg - handle to the parrent, ( Options Dlg )
+// Returns : void
+// Description :
+//
+// References : -
+// Remarks : -
+// Created : 020427 , 27 April 2002
+// Developer : KN
+/////////////////////////////////////////////////////////////////////
+
+void OpenHelp(HWND hwndDlg)
+{
+ _TCHAR szPath[MAX_PATH];
+ if( GetModuleFileName( hInstance , szPath , sizeof( szPath ) ) )
+ {
+ int nLen = _tcslen( szPath );
+ if( nLen > 3 )
+ {
+ szPath[nLen-1] = 't';
+ szPath[nLen-2] = 'x';
+ szPath[nLen-3] = 't';
+
+ SHELLEXECUTEINFO st = {0};
+ st.cbSize = sizeof(st);
+ st.fMask = SEE_MASK_INVOKEIDLIST;
+ st.hwnd = NULL;
+ st.lpFile = szPath;
+ st.nShow = SW_SHOWDEFAULT;
+ ShellExecuteEx(&st);
+
+ return;
+ }
+ }
+
+ MessageBox( hwndDlg , TranslateTS(_T("Failed to get the path to Msg_Export.dll\nPlease locate Msg_Export.txt your self")),MSG_BOX_TITEL,MB_OK );
+}
+
+/////////////////////////////////////////////////////////////////////
+// Member Function : DlgProcMsgExportOpts
+// Type : Global
+// Parameters : hwndDlg - handle to this dialog
+// msg - ?
+// wParam - ?
+// lParam - ?
+// Returns : static BOOL CALLBACK
+// Description : Main message prossing fore my options dialog
+//
+// References : -
+// Remarks : -
+// Created : 020422 , 22 April 2002
+// Developer : KN
+/////////////////////////////////////////////////////////////////////
+
+static BOOL CALLBACK DlgProcMsgExportOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+// Used to prevent sending the PSM_CHANGED to miranda
+// when initilizing
+ static BOOL bWindowTextSet = FALSE;
+
+ switch (msg)
+ {
+ case WM_INITDIALOG:
+ {
+ bWindowTextSet = FALSE;
+
+ HWND hMapUser = GetDlgItem( hwndDlg , IDC_MAP_USER_LIST );
+
+ { // init adv. win styles
+ DWORD dw = ListView_GetExtendedListViewStyle( hMapUser );
+ dw |= LVS_EX_HEADERDRAGDROP | LVS_EX_FULLROWSELECT;
+ ListView_SetExtendedListViewStyle( hMapUser , dw /*| LVS_EX_LABELTIP*/);
+ }
+
+
+ int nColumnWidth = 100;
+ RECT rListSize;
+ if( GetWindowRect( hMapUser , &rListSize ) )
+ {
+ nColumnWidth = (rListSize.right - rListSize.left- GetSystemMetrics(SM_CXVSCROLL) - 5 - nUINColWitdh - nProtoColWitdh) / 2;
+ if( nColumnWidth < 10 )
+ nColumnWidth = 10;
+ }
+
+ { // header setup !!
+
+ LVCOLUMN cCol = { 0 };
+ cCol.mask = LVCF_TEXT | LVCF_WIDTH;
+ cCol.cx = nColumnWidth;
+ cCol.pszText = TranslateTS(_T("File"));
+ ListView_InsertColumn( hMapUser , 0 , &cCol );
+ cCol.pszText = TranslateTS(_T("Nick"));
+ ListView_InsertColumn( hMapUser , 1 , &cCol );
+ cCol.cx = nProtoColWitdh;
+ cCol.pszText = TranslateTS(_T("Proto"));
+ ListView_InsertColumn( hMapUser , 2 , &cCol );
+ cCol.cx = nUINColWitdh;
+ cCol.mask |= LVCF_FMT;
+ cCol.fmt = LVCFMT_RIGHT;
+ cCol.pszText = TranslateTS(_T("UIN"));
+
+ ListView_InsertColumn( hMapUser , 3 , &cCol );
+
+ /*
+ int nOrder[3] = { 1 , 2 , 0 };
+ ListView_SetColumnOrderArray( hMapUser , 3 , nOrder );*/
+ }
+
+ {
+ HIMAGELIST hIml;
+ hIml = ImageList_Create( GetSystemMetrics(SM_CXSMICON) , GetSystemMetrics(SM_CYSMICON),ILC_COLOR4|ILC_MASK,2,2);
+ ImageList_AddIcon(hIml,LoadIcon(GetModuleHandle(NULL),MAKEINTRESOURCE(IDI_NOTICK)));
+ ImageList_AddIcon(hIml,LoadIcon(GetModuleHandle(NULL),MAKEINTRESOURCE(IDI_TICK)));
+ ListView_SetImageList( hMapUser, hIml, LVSIL_SMALL);
+ }
+
+ {
+ tstring sTmp;
+ LVITEM sItem = { 0 };
+ HANDLE hContact = (HANDLE) CallService(MS_DB_CONTACT_FINDFIRST, 0, 0);
+ for( int nUser = 0; /*hContact*/ ; nUser++ )
+ {
+ sItem.mask = LVIF_TEXT | LVIF_PARAM | LVIF_IMAGE;
+ sItem.iItem = nUser;
+ sItem.iSubItem = 0;
+ sItem.iImage = DBGetContactSettingByte(hContact,MODULE,"EnableLog",1);
+ sItem.lParam = (LPARAM) hContact;
+
+
+ sTmp = DBGetString( hContact , MODULE , "FileName" , _T("") );
+ sItem.pszText = (_TCHAR*)sTmp.c_str();
+
+ ListView_InsertItem( hMapUser , &sItem );
+
+ sItem.mask = LVIF_TEXT;
+ sItem.iSubItem = 1;
+ sItem.pszText = (_TCHAR*)NickFromHandle(hContact);
+ ListView_SetItem( hMapUser , &sItem );
+
+ sItem.iSubItem = 2;
+
+ sTmp = DBGetString( hContact , "Protocol" , "p" , _T("") );
+ string sTmpA = DBGetStringA( hContact , "Protocol" , "p" , "" );
+ sItem.pszText = (_TCHAR*)sTmp.c_str();
+ ListView_SetItem( hMapUser , &sItem );
+
+
+ DWORD dwUIN = DBGetContactSettingDword(hContact, sTmpA.c_str(), "UIN", 0);
+ _TCHAR szTmp[50];
+ _sntprintf( szTmp , sizeof(szTmp) ,_T("%d") , dwUIN );
+ sItem.iSubItem = 3;
+ sItem.pszText = szTmp;
+ ListView_SetItem( hMapUser , &sItem );
+
+ if( ! hContact ) // written like this to add the current user ( handle = 0 )
+ break;
+
+ hContact = (HANDLE) CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM) hContact, 0);
+ }
+ ListView_SortItems( hMapUser , CompareFunc , 1 );
+
+ sItem.mask = LVIF_STATE;
+ sItem.iItem = 0;
+ sItem.iSubItem = 0;
+ sItem.state = LVIS_FOCUSED;
+ sItem.stateMask = LVIS_FOCUSED;
+ ListView_SetItem( hMapUser , &sItem );
+
+ }
+ HWND hComboBox;
+
+ SetDlgItemInt( hwndDlg , IDC_MAX_CLOUMN_WIDTH , nMaxLineWidth , TRUE );
+
+ {// Export dir
+ SetDlgItemText( hwndDlg , IDC_EXPORT_DIR , sExportDir.c_str() );
+ hComboBox = GetDlgItem( hwndDlg , IDC_EXPORT_DIR );
+ SendMessage( hComboBox , CB_ADDSTRING, 0 , (LPARAM)_T("%dbpath%\\MsgExport\\") );
+ SendMessage( hComboBox , CB_ADDSTRING, 0 , (LPARAM)_T("C:\\Backup\\MsgExport\\") );
+ SendMessage( hComboBox , CB_ADDSTRING, 0 , (LPARAM)_T("%dbpath%\\MsgExport\\%group% - ") );
+ SendMessage( hComboBox , CB_ADDSTRING, 0 , (LPARAM)_T("%dbpath%\\MsgExport\\%group%\\") );
+ }
+ {// default file
+ SetDlgItemText( hwndDlg , IDC_DEFAULT_FILE , sDefaultFile.c_str() );
+ hComboBox = GetDlgItem( hwndDlg , IDC_DEFAULT_FILE );
+ SendMessage( hComboBox , CB_ADDSTRING, 0 , (LPARAM)_T("%nick%.txt") );
+ SendMessage( hComboBox , CB_ADDSTRING, 0 , (LPARAM)_T("%UIN%.txt") );
+ SendMessage( hComboBox , CB_ADDSTRING, 0 , (LPARAM)_T("%group%.txt") );
+ SendMessage( hComboBox , CB_ADDSTRING, 0 , (LPARAM)_T("%e-mail%.txt") );
+ SendMessage( hComboBox , CB_ADDSTRING, 0 , (LPARAM)_T("%identifier%.txt") );
+ SendMessage( hComboBox , CB_ADDSTRING, 0 , (LPARAM)_T("%year%-%month%-%day%.txt") );
+ SendMessage( hComboBox , CB_ADDSTRING, 0 , (LPARAM)_T("%group%\\%nick%.txt") );
+ SendMessage( hComboBox , CB_ADDSTRING, 0 , (LPARAM)_T("%group%\\%UIN%.txt") );
+ SendMessage( hComboBox , CB_ADDSTRING, 0 , (LPARAM)_T("%group%\\%identifier%.txt") );
+ SendMessage( hComboBox , CB_ADDSTRING, 0 , (LPARAM)_T("%protocol%\\%nick%.txt") );
+ SendMessage( hComboBox , CB_ADDSTRING, 0 , (LPARAM)_T("History.txt"));
+ }
+ {// time format
+ SetDlgItemText( hwndDlg , IDC_EXPORT_TIMEFORMAT , sTimeFormat.c_str() );
+ hComboBox = GetDlgItem( hwndDlg , IDC_EXPORT_TIMEFORMAT );
+ SendMessage( hComboBox , CB_ADDSTRING, 0 , (LPARAM)_T("d t") );
+ SendMessage( hComboBox , CB_ADDSTRING, 0 , (LPARAM)_T("d s") );
+ SendMessage( hComboBox , CB_ADDSTRING, 0 , (LPARAM)_T("d m") );
+ SendMessage( hComboBox , CB_ADDSTRING, 0 , (LPARAM)_T("D s") );
+ SendMessage( hComboBox , CB_ADDSTRING, 0 , (LPARAM)_T("D m :"));
+ }
+ {// File viewer
+ SetDlgItemText( hwndDlg , IDC_FILE_VIEWER , sFileViewerPrg.c_str() );
+ hComboBox = GetDlgItem( hwndDlg , IDC_FILE_VIEWER );
+ SendMessage( hComboBox , CB_ADDSTRING, 0 , (LPARAM)_T("") );
+ SendMessage( hComboBox , CB_ADDSTRING, 0 , (LPARAM)_T("C:\\Windows\\Notepad.exe") );
+ SendMessage( hComboBox , CB_ADDSTRING, 0 , (LPARAM)_T("C:\\WinNT\\Notepad.exe") );
+ //EnableWindow( GetDlgItem( hwndDlg , IDC_FILE_VIEWER ) , ! bUseInternalViewer() );
+ }
+
+
+ CheckDlgButton( hwndDlg , IDC_USE_INTERNAL_VIEWER , bUseInternalViewer() ? BST_CHECKED : BST_UNCHECKED );
+ CheckDlgButton( hwndDlg , IDC_REPLACE_MIRANDA_HISTORY , bReplaceHistory ? BST_CHECKED : BST_UNCHECKED );
+ CheckDlgButton( hwndDlg , IDC_APPEND_NEWLINE , bAppendNewLine ? BST_CHECKED : BST_UNCHECKED );
+ CheckDlgButton( hwndDlg , IDC_USE_UTF8_IN_NEW_FILES , bUseUtf8InNewFiles ? BST_CHECKED : BST_UNCHECKED );
+ CheckDlgButton( hwndDlg , IDC_USE_LESS_AND_GREATER_IN_EXPORT , bUseLessAndGreaterInExport ? BST_CHECKED : BST_UNCHECKED );
+
+
+ TranslateDialogDefault(hwndDlg);
+
+ bWindowTextSet = TRUE;
+ return TRUE;
+ }
+ case WM_COMMAND:
+ {
+ switch(LOWORD(wParam))
+ {
+ case ID_EXPORTSELECTED:
+ case IDC_EXPORTALL:
+ {
+ if( bUnaplyedChanges )
+ {
+ DWORD res = MessageBox( hwndDlg , TranslateTS(_T("You have unapplyed changes do you wish to apply these first ?")),MSG_BOX_TITEL,MB_YESNOCANCEL );
+ if( res == IDCANCEL )
+ return TRUE;
+ if( res == IDYES )
+ {
+ if( ! bApplyChanges( hwndDlg ) )
+ {
+ return TRUE;
+ }
+ }
+ }
+ nExportCompleatList( hwndDlg , LOWORD(wParam) == ID_EXPORTSELECTED );
+ return TRUE;
+ }
+ case IDC_EXPORT_DIR:
+ case IDC_EXPORT_TIMEFORMAT:
+ case IDC_DEFAULT_FILE:
+ case IDC_FILE_VIEWER:
+ {
+ if( !bWindowTextSet )
+ return TRUE;
+
+ if( HIWORD(wParam) == CBN_EDITUPDATE || HIWORD(wParam) == CBN_SELCHANGE )
+ {
+ bUnaplyedChanges = TRUE;
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ }
+ return TRUE;
+ }
+ case IDC_MAX_CLOUMN_WIDTH:
+ {
+ if( !bWindowTextSet )
+ return TRUE;
+
+ if( HIWORD(wParam) == EN_CHANGE )
+ {
+ bUnaplyedChanges = TRUE;
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ }
+ return TRUE;
+ }
+ case IDC_USE_INTERNAL_VIEWER:
+/* {
+ EnableWindow(
+ GetDlgItem( hwndDlg , IDC_FILE_VIEWER ) ,
+ !IsDlgButtonChecked( hwndDlg , IDC_USE_INTERNAL_VIEWER )
+ );
+ }// fall thru here !!*/
+ case IDC_REPLACE_MIRANDA_HISTORY:
+ case IDC_APPEND_NEWLINE:
+ case IDC_USE_UTF8_IN_NEW_FILES:
+ case IDC_USE_LESS_AND_GREATER_IN_EXPORT:
+ {
+ if( HIWORD(wParam) == BN_CLICKED )
+ {
+ bUnaplyedChanges = TRUE;
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ }
+ return TRUE;
+ }
+ case ID_USERLIST_USERDETAILS:
+ {
+ LVITEM sItem = { 0 };
+ sItem.mask = LVIF_PARAM;
+ HWND hMapUser = GetDlgItem( hwndDlg , IDC_MAP_USER_LIST );
+ sItem.iItem = ListView_GetNextItem( hMapUser , -1 , LVIS_SELECTED );
+ if( sItem.iItem >= 0 && ListView_GetItem( hMapUser, &sItem ))
+ {
+ CallService(MS_USERINFO_SHOWDIALOG,(WPARAM)sItem.lParam ,0);
+ }
+ return TRUE;
+ }
+ case IDC_AUTO_FILENAME:
+ {
+ AutoFindeFileNames(hwndDlg);
+ return TRUE;
+ }
+ case IDC_CLEAR_ALL:
+ {
+ ClearAllFileNames(hwndDlg);
+ return TRUE;
+
+ }
+ case IDC_OPEN_HELP:
+ {
+ OpenHelp(hwndDlg);
+ return TRUE;
+ }
+ case ID_SET_TO_DEFAULT:
+ {
+ SetToDefault( hwndDlg );
+ return TRUE;
+ }
+ case IDC_FILE_VIEWER_BROWSE:
+ {
+ OPENFILENAME ofn = { 0 }; // common dialog box structure
+ _TCHAR szFile[260]; // buffer for file name
+
+ GetDlgItemText( hwndDlg , IDC_FILE_VIEWER , szFile , sizeof(szFile));
+ // Initialize OPENFILENAME
+ //ZeroMemory(&ofn, sizeof(OPENFILENAME));
+ ofn.lStructSize = sizeof(OPENFILENAME);
+ ofn.hwndOwner = hwndDlg;
+ ofn.lpstrFile = szFile;
+ ofn.nMaxFile = sizeof(szFile);
+ ofn.lpstrFilter = _T("Executable files (*.exe;*.com;*.bat;*.cmd)\0*.exe;*.com;*.bat;*.cmd\0All files(*.*)\0*.*\0");
+ ofn.nFilterIndex = 1;
+ //ofn.lpstrFileTitle = NULL;
+ //ofn.nMaxFileTitle = 0;
+ //ofn.lpstrInitialDir = NULL;
+ ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;
+
+ // Display the Open dialog box.
+
+ if (GetOpenFileName(&ofn))
+ {
+ SetDlgItemText( hwndDlg , IDC_FILE_VIEWER , szFile );
+ bUnaplyedChanges = TRUE;
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ }
+ // OPENFILENAME
+ //GetOpenFileName(
+ return TRUE;
+ }
+ case IDC_EXPORT_DIR_BROWSE:
+ {
+ LPMALLOC pMalloc;
+
+ //CoInitializeEx(NULL,COINIT_APARTMENTTHREADED );
+ // Get the shells allocator
+ if (FAILED(SHGetMalloc(&pMalloc))) // we need to use this to support old Windows versions
+ {
+ MessageBox( hwndDlg , _T("Failed to get the shells allocator !"),MSG_BOX_TITEL,MB_OK );
+ return TRUE; // TRUE because we have handled the message , sort of *S*
+ }
+
+ // Allocate the Dest Dir buffer to receive browse info
+ _TCHAR * lpDestDir = (_TCHAR * ) pMalloc->Alloc(MAX_PATH+100);
+ if ( ! lpDestDir )
+ {
+ pMalloc->Release();
+ MessageBox( hwndDlg , _T("Failed to Allocate buffer space"),MSG_BOX_TITEL,MB_OK );
+ return TRUE;
+ }
+
+ BROWSEINFO sBrowseInfo;
+ sBrowseInfo.hwndOwner = hwndDlg;
+ sBrowseInfo.pidlRoot = NULL;
+ sBrowseInfo.pszDisplayName = lpDestDir;
+ sBrowseInfo.lpszTitle = TranslateTS(_T("Select Destination Directory"));
+ sBrowseInfo.ulFlags = BIF_NEWDIALOGSTYLE | BIF_EDITBOX;;
+ sBrowseInfo.lpfn = NULL;
+ sBrowseInfo.lParam = 0;
+ sBrowseInfo.iImage = 0;
+
+ LPITEMIDLIST psItemIDList = SHBrowseForFolder(&sBrowseInfo);
+ if( psItemIDList )
+ {
+ SHGetPathFromIDList(psItemIDList, lpDestDir);
+ int n = _tcslen( lpDestDir );
+ if( n > 0 && lpDestDir[n] != '\\' )
+ {
+ lpDestDir[n] = '\\' ;
+ lpDestDir[n+1] = 0;
+ }
+ SetDlgItemText( hwndDlg , IDC_EXPORT_DIR , lpDestDir );
+ bUnaplyedChanges = TRUE;
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ // Clean up
+ pMalloc->Free( psItemIDList );
+ }
+ pMalloc->Free( lpDestDir );
+ pMalloc->Release();
+ return TRUE;
+ }
+ }
+ break;
+ }
+ case WM_CONTEXTMENU:
+ {
+ if( wParam != (WPARAM)GetDlgItem( hwndDlg , IDC_MAP_USER_LIST ) )
+ return FALSE;
+
+ HMENU hMainMenu = LoadMenu(hInstance ,MAKEINTRESOURCE(IDR_MSG_EXPORT));
+ if( hMainMenu )
+ {
+ HMENU hMenu = GetSubMenu(hMainMenu,0);
+
+ POINT pt;
+ pt.x=(short)LOWORD(lParam);
+ pt.y=(short)HIWORD(lParam);
+ if( pt.x == -1 && pt.y == -1 )
+ {
+ HWND hMapUser = GetDlgItem( hwndDlg , IDC_MAP_USER_LIST );
+ int nFirst = ListView_GetNextItem( hMapUser , -1 , LVNI_FOCUSED );
+ if( nFirst >= 0 )
+ {
+ ListView_GetItemPosition( hMapUser , nFirst , &pt );
+ }
+
+ if( pt.y < 16 )
+ pt.y = 16;
+ else
+ {
+ RECT rUserList;
+ GetClientRect( hMapUser , &rUserList );
+ if( pt.y > rUserList.bottom - 16 )
+ pt.y = rUserList.bottom - 16;
+ else
+ pt.y += 8;
+ }
+ pt.x = 8;
+ ClientToScreen(hMapUser,&pt);
+ }
+
+ CallService(MS_LANGPACK_TRANSLATEMENU,(WPARAM)hMenu,0);
+ TrackPopupMenu(hMenu,TPM_TOPALIGN|TPM_LEFTALIGN|TPM_RIGHTBUTTON,pt.x,pt.y,0,hwndDlg,NULL);
+
+ DestroyMenu(hMainMenu);
+ }
+ return TRUE;
+ }
+ case WM_NOTIFY:
+ {
+ NMHDR * p = ((LPNMHDR)lParam);
+ if( p->idFrom == IDC_MAP_USER_LIST )
+ {
+ switch (p->code)
+ {
+ case NM_CLICK:
+ { LVHITTESTINFO hti;
+ LVITEM lvi;
+ hti.pt=((NMLISTVIEW*)lParam)->ptAction;
+ ListView_SubItemHitTest( p->hwndFrom ,&hti);
+
+ if( hti.flags != LVHT_ONITEMICON )
+ break;
+
+ lvi.mask=LVIF_IMAGE;
+ lvi.iItem=hti.iItem;
+ lvi.iSubItem=0;
+ ListView_GetItem( p->hwndFrom , &lvi);
+ lvi.iImage^=1;
+ ListView_SetItem( p->hwndFrom , &lvi);
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ break;
+ }
+ case LVN_ENDLABELEDIT:
+ {
+ NMLVDISPINFO * pdi = (NMLVDISPINFO *) lParam;
+ if( pdi->item.mask & LVIF_TEXT )
+ {
+ pdi->item.mask &= LVIF_TEXT;
+ ListView_SetItem( p->hwndFrom , &pdi->item );
+
+ bUnaplyedChanges = TRUE;
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ }
+ return TRUE;
+ }
+ case LVN_KEYDOWN:
+ {
+ NMLVKEYDOWN * lpnmk = (NMLVKEYDOWN *) lParam;
+ if( lpnmk->wVKey == 'A' && (GetKeyState( VK_CONTROL ) & 0x8000) )
+ {
+ // select all
+ int nCount = ListView_GetItemCount( p->hwndFrom );
+ for( int nCur = 0 ; nCur < nCount ; nCur++ )
+ {
+ ListView_SetItemState( p->hwndFrom , nCur , LVIS_SELECTED , LVIS_SELECTED );
+ }
+ return TRUE;
+ }
+
+
+ if( lpnmk->wVKey == VK_F2 ||
+ ( lpnmk->wVKey >= 'A' && lpnmk->wVKey <= 'Z') ||
+ ( lpnmk->wVKey >= '1' && lpnmk->wVKey <= '9') ||
+ lpnmk->wVKey == VK_BACK
+ )
+ {
+ HWND hEdit = ListView_EditLabel( p->hwndFrom , ListView_GetSelectionMark(p->hwndFrom) );
+ if( hEdit && lpnmk->wVKey != VK_F2 )
+ {
+ if( isupper( lpnmk->wVKey ) )
+ SendMessage( hEdit , WM_CHAR , tolower( lpnmk->wVKey ) , 0 );
+ else
+ SendMessage( hEdit , WM_CHAR , lpnmk->wVKey , 0 );
+ }
+ }
+ return TRUE;
+ }
+ case NM_DBLCLK:
+ {
+ NMITEMACTIVATE * pdi = (NMITEMACTIVATE *) lParam;
+ if( pdi->iItem >= 0 )
+ {
+ ListView_EditLabel( p->hwndFrom , pdi->iItem );
+ }
+ return TRUE;
+ }
+ case NM_CUSTOMDRAW:
+ {
+ LPNMLVCUSTOMDRAW lplvcd = (LPNMLVCUSTOMDRAW)lParam;
+ switch(lplvcd->nmcd.dwDrawStage)
+ {
+ case CDDS_PREPAINT:
+ {
+ SetWindowLong(hwndDlg, DWL_MSGRESULT, CDRF_NOTIFYITEMDRAW);
+ return true;
+ }
+ case CDDS_ITEMPREPAINT:
+ {
+ if( lplvcd->nmcd.lItemlParam == 0 )
+ {
+ lplvcd->clrText = RGB( 0 , 0 , 255 );
+ }
+ SetWindowLong(hwndDlg, DWL_MSGRESULT, CDRF_NEWFONT);
+ return true;
+ }
+ }
+ return FALSE;
+ }
+ }
+ }
+ else
+ {
+ switch (p->code)
+ {
+ case PSN_APPLY:
+ {
+ bApplyChanges( hwndDlg );
+ return TRUE;
+ }
+ case HDN_ITEMCLICK:
+ {
+ NMHEADER * phdr = (LPNMHEADER) p;
+ if( phdr->iButton == 0 )// 0 => Left button
+ {
+ HWND hMapUser = GetDlgItem( hwndDlg , IDC_MAP_USER_LIST );
+ ListView_SortItems( hMapUser , CompareFunc , phdr->iItem );
+ return TRUE;
+ }
+ return FALSE;
+ }
+ }
+ }
+ break;
+ }
+ }
+ return FALSE;
+}
+
+/////////////////////////////////////////////////////////////////////
+// Member Function : bApplyChanges2
+// Type : Global
+// Parameters : hwndDlg - ?
+// Returns : Returns true if
+// Description :
+//
+// References : -
+// Remarks : -
+// Created : 050429 , 29 april 2005
+// Developer : KN
+/////////////////////////////////////////////////////////////////////
+
+BOOL bApplyChanges2( HWND hwndDlg )
+{
+ if( IsDlgButtonChecked( hwndDlg , IDC_FC_PROMPT ) == BST_CHECKED )
+ enRenameAction = eDAPromptUser;
+ else if( IsDlgButtonChecked( hwndDlg , IDC_FC_RENAME ) == BST_CHECKED )
+ enRenameAction = eDAAutomatic;
+ else if( IsDlgButtonChecked( hwndDlg , IDC_FC_NOTHING ) == BST_CHECKED )
+ enRenameAction = eDANothing;
+
+ if( IsDlgButtonChecked( hwndDlg , IDC_FD_PROMPT ) == BST_CHECKED )
+ enDeleteAction = eDAPromptUser;
+ else if( IsDlgButtonChecked( hwndDlg , IDC_FD_DELETE ) == BST_CHECKED )
+ enDeleteAction = eDAAutomatic;
+ else if( IsDlgButtonChecked( hwndDlg , IDC_FD_NOTHING ) == BST_CHECKED )
+ enDeleteAction = eDANothing;
+
+ char szTemp[ 500 ];
+ strcpy( szTemp , "DisableProt_" );
+
+ HWND hMapUser = GetDlgItem( hwndDlg , IDC_EXPORT_PROTOS );
+ int nCount = ListView_GetItemCount( hMapUser );
+ for( int nCur = 0 ; nCur < nCount ; nCur++ )
+ {
+ LVITEMA sItem = { 0 };
+ sItem.iItem = nCur;
+ sItem.mask = LVIF_TEXT | LVIF_IMAGE;
+ sItem.pszText = &szTemp[12];
+ sItem.cchTextMax = sizeof( szTemp )-15;
+ if( ::SendMessage(hMapUser, LVM_GETITEMA, 0, (LPARAM)&sItem ) )
+ {
+ if( sItem.iImage )
+ DBDeleteContactSetting( NULL , MODULE , szTemp ); // default is Enabled !!
+ else
+ DBWriteContactSettingByte( NULL , MODULE , szTemp,0);
+ }
+ }
+ SaveSettings();
+ return TRUE;
+}
+
+/////////////////////////////////////////////////////////////////////
+// Member Function : DlgProcMsgExportOpts2
+// Type : Global
+// Parameters : hwndDlg - ?
+// msg - ?
+// wParam - ?
+// lParam - ?
+// Returns : static BOOL CALLBACK
+// Description :
+//
+// References : -
+// Remarks : -
+// Created : 040205 , 05 februar 2004
+// Developer : KN
+/////////////////////////////////////////////////////////////////////
+
+static BOOL CALLBACK DlgProcMsgExportOpts2(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ static BOOL bWindowTextSet = FALSE;
+
+ switch (msg)
+ {
+ case WM_INITDIALOG:
+ {
+ bWindowTextSet = FALSE;
+ switch( enRenameAction )
+ {
+ case eDAPromptUser:
+ CheckDlgButton( hwndDlg , IDC_FC_PROMPT , true );
+ break;
+ case eDAAutomatic:
+ CheckDlgButton( hwndDlg , IDC_FC_RENAME , true );
+ break;
+ case eDANothing:
+ CheckDlgButton( hwndDlg , IDC_FC_NOTHING , true );
+ break;
+ }
+ switch( enDeleteAction )
+ {
+ case eDAPromptUser:
+ CheckDlgButton( hwndDlg , IDC_FD_PROMPT , true );
+ break;
+ case eDAAutomatic:
+ CheckDlgButton( hwndDlg , IDC_FD_DELETE , true );
+ break;
+ case eDANothing:
+ CheckDlgButton( hwndDlg , IDC_FD_NOTHING , true );
+ break;
+ }
+ HWND hMapUser = GetDlgItem( hwndDlg , IDC_EXPORT_PROTOS );
+/*
+ { // init adv. win styles
+ DWORD dw = ListView_GetExtendedListViewStyle( hMapUser );
+ dw |= LVS_EX_HEADERDRAGDROP | LVS_EX_FULLROWSELECT;
+ ListView_SetExtendedListViewStyle( hMapUser , dw /);
+ }
+*/
+ int nColumnWidth = 100;
+ RECT rListSize;
+ if( GetWindowRect( hMapUser , &rListSize ) )
+ {
+ nColumnWidth = (rListSize.right - rListSize.left- GetSystemMetrics(SM_CXVSCROLL) - 5 );
+ if( nColumnWidth < 10 )
+ nColumnWidth = 10;
+ }
+
+ { // header setup !!
+ LVCOLUMN cCol = { 0 };
+ cCol.mask = LVCF_TEXT | LVCF_WIDTH;
+ cCol.cx = nColumnWidth;
+ cCol.pszText = TranslateTS(_T("Export Protocols"));
+ ListView_InsertColumn( hMapUser , 0 , &cCol );
+ }
+
+ {
+ HIMAGELIST hIml;
+ hIml = ImageList_Create( GetSystemMetrics(SM_CXSMICON) , GetSystemMetrics(SM_CYSMICON),ILC_COLOR4|ILC_MASK,2,2);
+ ImageList_AddIcon(hIml,LoadIcon(GetModuleHandle(NULL),MAKEINTRESOURCE(IDI_NOTICK)));
+ ImageList_AddIcon(hIml,LoadIcon(GetModuleHandle(NULL),MAKEINTRESOURCE(IDI_TICK)));
+ ListView_SetImageList( hMapUser, hIml, LVSIL_SMALL);
+ }
+
+ {
+ PROTOCOLDESCRIPTOR **proto;
+ int nCount;
+ LVITEMA sItem = { 0 };
+ sItem.mask = LVIF_TEXT | LVIF_IMAGE;
+ char szTemp[ 500 ];
+
+ CallService(MS_PROTO_ENUMPROTOCOLS,(WPARAM)&nCount,(LPARAM)&proto);
+
+ for( int i=0 ; i < nCount ; i++)
+ {
+ if( proto[i]->type==PROTOTYPE_IGNORE) //PROTOTYPE_PROTOCOL
+ continue;
+ _snprintf( szTemp , sizeof( szTemp ) , "DisableProt_%s" , proto[i]->szName );
+ sItem.pszText = proto[i]->szName;
+ sItem.iImage = DBGetContactSettingByte(NULL,MODULE,szTemp,1);
+ ::SendMessage( hMapUser , LVM_INSERTITEMA , 0 ,(LPARAM)&sItem );
+ sItem.iItem++;
+ }
+ }
+
+ TranslateDialogDefault(hwndDlg);
+
+ bWindowTextSet = TRUE;
+ return TRUE;
+ }
+ case WM_COMMAND:
+ {
+ switch(LOWORD(wParam))
+ {
+ case IDC_FC_PROMPT:
+ case IDC_FC_RENAME:
+ case IDC_FC_NOTHING:
+ case IDC_FD_PROMPT:
+ case IDC_FD_DELETE:
+ case IDC_FD_NOTHING:
+ {
+ if( !bWindowTextSet )
+ return TRUE;
+
+ if( HIWORD(wParam) == BN_CLICKED )
+ {
+ bUnaplyedChanges = TRUE;
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ }
+ return TRUE;
+ }
+ case IDC_DEBUG_INFO:
+ {
+ ShowDebugInfo();
+ return TRUE;
+ }
+ }
+ break;
+ }
+ case WM_NOTIFY:
+ {
+ NMHDR * p = ((LPNMHDR)lParam);
+ if( p->idFrom == IDC_EXPORT_PROTOS )
+ {
+ switch (p->code)
+ {
+ case NM_CLICK:
+ { LVHITTESTINFO hti;
+ LVITEM lvi;
+ hti.pt=((NMLISTVIEW*)lParam)->ptAction;
+ ListView_SubItemHitTest( p->hwndFrom ,&hti);
+
+ if( hti.flags != LVHT_ONITEMICON )
+ break;
+
+ lvi.mask=LVIF_IMAGE;
+ lvi.iItem=hti.iItem;
+ lvi.iSubItem=0;
+ ListView_GetItem( p->hwndFrom , &lvi);
+ lvi.iImage^=1;
+ ListView_SetItem( p->hwndFrom , &lvi);
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ break;
+ }
+ }
+ break;
+ }
+ switch (p->code)
+ {
+ case PSN_APPLY:
+ {
+ bApplyChanges2(hwndDlg);
+ return TRUE;
+ }
+ case HDN_ITEMCLICK:
+ {
+ return FALSE;
+ }
+ }
+ break;
+ }
+ }
+ //
+ return FALSE;
+}
+
+
+/////////////////////////////////////////////////////////////////////
+// Member Function : OptionsInitialize
+// Type : Global
+// Parameters : wParam - ?
+// lParam - ?
+// Returns : int
+// Description : Called when the user openes the options dialog
+// I need to add my options page.
+// References : -
+// Remarks : -
+// Created : 020422 , 22 April 2002
+// Developer : KN
+/////////////////////////////////////////////////////////////////////
+
+int OptionsInitialize(WPARAM wParam,LPARAM /*lParam*/)
+{
+ OPTIONSDIALOGPAGE odp;
+
+ bUnaplyedChanges = FALSE;
+
+ ZeroMemory(&odp,sizeof(odp));
+ odp.cbSize = sizeof(odp);
+ odp.position = 100000000;
+ odp.hInstance = hInstance;
+ odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_MSGEXPORT);
+ odp.flags = ODPF_BOLDGROUPS;
+ odp.pszTitle = Translate("Message export");
+ odp.pszGroup = Translate("Plugins");
+ odp.groupPosition = 100000000;
+ odp.pfnDlgProc = DlgProcMsgExportOpts;
+ CallService(MS_OPT_ADDPAGE,wParam,(LPARAM)&odp);
+
+
+ odp.position = 100000001;
+ odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_MSGEXPORT2);
+ odp.pszTitle = Translate("Message export2");
+ odp.pfnDlgProc = DlgProcMsgExportOpts2;
+ CallService(MS_OPT_ADDPAGE,wParam,(LPARAM)&odp);
+ return 0;
+}
diff --git a/options.h b/options.h
new file mode 100755
index 0000000..60debd4
--- /dev/null
+++ b/options.h
@@ -0,0 +1,26 @@
+
+//This file is part of Msg_Export a Miranda IM plugin
+//Copyright (C)2002 Kennet Nielsen ( http://sourceforge.net/projects/msg-export/ )
+//
+//This program is free software; you can redistribute it and/or
+//modify it under the terms of the GNU General Public License
+//as published by the Free Software Foundation; either
+//version 2 of the License, or (at your option) any later version.
+//
+//This program is distributed in the hope that it will be useful,
+//but WITHOUT ANY WARRANTY; without even the implied warranty of
+//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+//GNU General Public License for more details.
+//
+//You should have received a copy of the GNU General Public License
+//along with this program; if not, write to the Free Software
+//Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+
+#ifndef MSG_EXP_OPTIONS_H
+#define MSG_EXP_OPTIONS_H
+
+int OptionsInitialize( WPARAM , LPARAM );
+int nExportCompleatList(HWND hParent , bool bOnlySelected );
+
+#endif \ No newline at end of file
diff --git a/resource.h b/resource.h
new file mode 100755
index 0000000..cd12714
--- /dev/null
+++ b/resource.h
@@ -0,0 +1,59 @@
+//{{NO_DEPENDENCIES}}
+// Microsoft Developer Studio generated include file.
+// Used by 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_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
+#define IDC_EXPORT_TIMEFORMAT 1004
+#define IDC_EXPORT_DIR_BROWSE 1032
+#define IDC_MAP_USER_LIST 1034
+#define IDC_AUTO_FILENAME 1035
+#define IDC_CLEAR_ALL 1036
+#define IDC_EXPORT_PROGRESS 1037
+#define IDC_EXP_ALL_STATUS 1039
+#define IDC_OPEN_HELP 1041
+#define IDC_DEFAULT_FILE 1043
+#define IDC_RICHEDIT 1046
+#define IDC_USE_INTERNAL_VIEWER 1048
+#define IDC_FV_EXTERNAL 1049
+#define IDC_FV_FIND 1050
+#define IDC_REPLACE_MIRANDA_HISTORY 1054
+#define IDC_DEBUG_INFO 1060
+#define IDC_FILE_VIEWER_BROWSE 1063
+#define IDC_FILE_VIEWER 1064
+#define IDC_APPEND_NEWLINE 1065
+#define IDC_USE_LESS_AND_GREATER_IN_EXPORT 1066
+#define IDC_FC_PROMPT 1067
+#define IDC_FC_RENAME 1068
+#define IDC_FC_NOTHING 1069
+#define IDC_FD_PROMPT 1070
+#define IDC_FD_DELETE 1071
+#define IDC_FD_NOTHING 1072
+#define IDC_EXPORT_PROTOS 1073
+#define IDC_USE_UTF8_IN_NEW_FILES 1074
+#define ID_EXPORTSELECTED 40002
+#define ID_EDIT_COPY 40003
+#define ID_SET_TO_DEFAULT 40004
+#define ID_USERLIST_USERDETAILS 40005
+#define IDC_STATIC -1
+
+// Next default values for new objects
+//
+#ifdef APSTUDIO_INVOKED
+#ifndef APSTUDIO_READONLY_SYMBOLS
+#define _APS_NEXT_RESOURCE_VALUE 124
+#define _APS_NEXT_COMMAND_VALUE 40006
+#define _APS_NEXT_CONTROL_VALUE 1075
+#define _APS_NEXT_SYMED_VALUE 101
+#endif
+#endif
diff --git a/resource.rc b/resource.rc
new file mode 100755
index 0000000..8ca0115
--- /dev/null
+++ b/resource.rc
@@ -0,0 +1,327 @@
+// Microsoft Visual C++ generated resource script.
+//
+#include "resource.h"
+
+#define APSTUDIO_READONLY_SYMBOLS
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 2 resource.
+//
+#include <windows.h>
+#include <richedit.h>
+/////////////////////////////////////////////////////////////////////////////
+#undef APSTUDIO_READONLY_SYMBOLS
+
+/////////////////////////////////////////////////////////////////////////////
+// Neutral (Default) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_NEUD)
+#ifdef _WIN32
+LANGUAGE LANG_NEUTRAL, SUBLANG_DEFAULT
+#pragma code_page(1252)
+#endif //_WIN32
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Version
+//
+
+VS_VERSION_INFO VERSIONINFO
+ FILEVERSION 3,1,0,3
+ PRODUCTVERSION 3,1,0,3
+ FILEFLAGSMASK 0x3fL
+#ifdef _DEBUG
+ FILEFLAGS 0x1L
+#else
+ FILEFLAGS 0x0L
+#endif
+ FILEOS 0x40004L
+ FILETYPE 0x2L
+ FILESUBTYPE 0x0L
+BEGIN
+ BLOCK "StringFileInfo"
+ BEGIN
+ BLOCK "000004b0"
+ BEGIN
+ VALUE "Comments", "Message export plugin for Miranda IM (mod by ring0)"
+ VALUE "CompanyName", "Tip Top Tools"
+ VALUE "FileDescription", "Message export"
+ VALUE "FileVersion", "3, 1, 0, 3"
+ VALUE "InternalName", "Msg_export"
+ VALUE "LegalCopyright", "© 2002 Kennet Nielsen, mod by ring0"
+ VALUE "OriginalFilename", "Msg_Export"
+ VALUE "ProductName", "Message export (mod by ring0)"
+ VALUE "ProductVersion", "3, 1, 0, 3"
+ END
+ END
+ BLOCK "VarFileInfo"
+ BEGIN
+ VALUE "Translation", 0x0, 1200
+ END
+END
+
+#endif // Neutral (Default) resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+/////////////////////////////////////////////////////////////////////////////
+// Danish resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_DAN)
+#ifdef _WIN32
+LANGUAGE LANG_DANISH, SUBLANG_DEFAULT
+#pragma code_page(1252)
+#endif //_WIN32
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// String Table
+//
+
+STRINGTABLE
+BEGIN
+ ID_EDIT_COPY "Copies the selection and puts it on the Clipboard\nCopy"
+END
+
+#endif // Danish resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+/////////////////////////////////////////////////////////////////////////////
+// German (Germany) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_DEU)
+#ifdef _WIN32
+LANGUAGE LANG_GERMAN, SUBLANG_GERMAN
+#pragma code_page(1252)
+#endif //_WIN32
+
+#ifdef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// TEXTINCLUDE
+//
+
+1 TEXTINCLUDE
+BEGIN
+ "resource.h\0"
+END
+
+2 TEXTINCLUDE
+BEGIN
+ "#include <windows.h>\r\n"
+ "#include <richedit.h>\0"
+END
+
+3 TEXTINCLUDE
+BEGIN
+ "\r\n"
+ "\0"
+END
+
+#endif // APSTUDIO_INVOKED
+
+#endif // German (Germany) resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+/////////////////////////////////////////////////////////////////////////////
+// English (U.S.) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
+#ifdef _WIN32
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
+#pragma code_page(1252)
+#endif //_WIN32
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Dialog
+//
+
+IDD_OPT_MSGEXPORT DIALOGEX 0, 0, 314, 240
+STYLE DS_SETFONT | DS_3DLOOK | DS_CENTER | WS_CHILD | WS_VISIBLE
+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,76,10
+ CONTROL "Replace miranda history",IDC_REPLACE_MIRANDA_HISTORY,
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,96,61,91,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,264,11,39,14,ES_AUTOHSCROLL | ES_NUMBER
+ COMBOBOX IDC_EXPORT_TIMEFORMAT,246,29,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,201,46,85,10
+ CONTROL "Append extra new line",IDC_APPEND_NEWLINE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,201,59,86,10
+ CONTROL "Use << and >>",IDC_USE_LESS_AND_GREATER_IN_EXPORT,
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,201,72,63,10
+ CONTROL "List1",IDC_MAP_USER_LIST,"SysListView32",LVS_REPORT | LVS_SHOWSELALWAYS | LVS_EDITLABELS | WS_BORDER | WS_TABSTOP,5,100,304,120
+ PUSHBUTTON "Auto filename",IDC_AUTO_FILENAME,5,226,63,14
+ PUSHBUTTON "Clear all",IDC_CLEAR_ALL,86,226,63,14
+ PUSHBUTTON "Help",IDC_OPEN_HELP,161,226,63,14
+ PUSHBUTTON "Export all history",IDC_EXPORTALL,242,226,63,14
+ GROUPBOX "Export directory",IDC_STATIC,5,0,186,46
+ LTEXT "Max column width",IDC_STATIC,201,14,58,8
+ LTEXT "Time format",IDC_STATIC,201,31,38,8
+ GROUPBOX "Export format",IDC_STATIC,195,0,114,94
+ LTEXT "Default file",IDC_STATIC,11,32,34,8
+ GROUPBOX "File viewer",IDC_STATIC,5,49,186,45
+END
+
+IDD_EXPORT_ALL_DLG DIALOGEX 0, 0, 252, 46
+STYLE DS_SETFONT | WS_POPUP | WS_CAPTION
+EXSTYLE WS_EX_TOOLWINDOW
+CAPTION "Exporting old messages"
+FONT 8, "MS Shell Dlg", 0, 0, 0x1
+BEGIN
+ CONTROL "Progress1",IDC_EXPORT_PROGRESS,"msctls_progress32",WS_BORDER,7,7,238,15
+ LTEXT "",IDC_EXP_ALL_STATUS,7,31,238,8
+END
+
+IDD_FILE_VIEWER DIALOG 0, 0, 346, 259
+STYLE DS_SETFONT | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME
+CAPTION "History file for %s (%s format %s)"
+FONT 8, "MS Sans Serif"
+BEGIN
+ CONTROL "",IDC_RICHEDIT,"RICHEDIT",TCS_HOTTRACK | TCS_VERTICAL | TCS_BUTTONS | TCS_RAGGEDRIGHT | TCS_MULTISELECT | WS_BORDER | WS_VSCROLL | WS_HSCROLL | WS_TABSTOP,6,7,333,224
+ PUSHBUTTON "&Find...",IDC_FV_FIND,46,238,50,14
+ PUSHBUTTON "&External",IDC_FV_EXTERNAL,142,238,50,14
+ DEFPUSHBUTTON "&Close",IDOK,246,238,50,14
+END
+
+IDD_OPT_MSGEXPORT2 DIALOGEX 0, 0, 314, 240
+STYLE DS_SETFONT | DS_3DLOOK | DS_CENTER | WS_CHILD | WS_VISIBLE
+EXSTYLE WS_EX_CONTROLPARENT
+FONT 8, "MS Sans Serif", 0, 0, 0x1
+BEGIN
+ CONTROL "Prompt for action",IDC_FC_PROMPT,"Button",BS_AUTORADIOBUTTON | WS_GROUP,51,53,69,10
+ GROUPBOX "When filename changes",IDC_STATIC,43,38,100,56
+ CONTROL "Rename file",IDC_FC_RENAME,"Button",BS_AUTORADIOBUTTON,51,66,53,10
+ CONTROL "Do nothing",IDC_FC_NOTHING,"Button",BS_AUTORADIOBUTTON,51,79,51,10
+ GROUPBOX "When user is deleted",IDC_STATIC,171,39,100,56
+ CONTROL "Prompt for action",IDC_FD_PROMPT,"Button",BS_AUTORADIOBUTTON | WS_GROUP,180,53,69,10
+ CONTROL "Delete file",IDC_FD_DELETE,"Button",BS_AUTORADIOBUTTON,180,66,47,10
+ CONTROL "Do nothing",IDC_FD_NOTHING,"Button",BS_AUTORADIOBUTTON,180,79,51,10
+ CONTROL "List1",IDC_EXPORT_PROTOS,"SysListView32",LVS_REPORT | LVS_SHOWSELALWAYS | LVS_EDITLABELS | WS_BORDER | WS_TABSTOP,44,101,227,106
+ PUSHBUTTON "Debug",IDC_DEBUG_INFO,237,214,32,10
+END
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// DESIGNINFO
+//
+
+#ifdef APSTUDIO_INVOKED
+GUIDELINES DESIGNINFO
+BEGIN
+ IDD_OPT_MSGEXPORT, DIALOG
+ BEGIN
+ RIGHTMARGIN, 313
+ VERTGUIDE, 5
+ VERTGUIDE, 11
+ VERTGUIDE, 136
+ VERTGUIDE, 141
+ VERTGUIDE, 201
+ VERTGUIDE, 303
+ VERTGUIDE, 309
+ HORZGUIDE, 18
+ HORZGUIDE, 36
+ HORZGUIDE, 46
+ HORZGUIDE, 66
+ END
+
+ IDD_EXPORT_ALL_DLG, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 245
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 39
+ END
+
+ IDD_FILE_VIEWER, DIALOG
+ BEGIN
+ LEFTMARGIN, 6
+ RIGHTMARGIN, 339
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 252
+ END
+END
+#endif // APSTUDIO_INVOKED
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Icon
+//
+
+// Icon with lowest ID value placed first to ensure application icon
+// remains consistent on all systems.
+IDI_EXPORT_MESSAGE ICON "export_m.ico"
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Menu
+//
+
+IDR_MSG_EXPORT MENU
+BEGIN
+ POPUP "UserList"
+ BEGIN
+ MENUITEM "User &Details", ID_USERLIST_USERDETAILS
+ MENUITEM "Export selected", ID_EXPORTSELECTED
+ MENUITEM "Set to default filename", ID_SET_TO_DEFAULT
+ MENUITEM SEPARATOR
+ MENUITEM "Auto filename", IDC_AUTO_FILENAME
+ MENUITEM "Clear all", IDC_CLEAR_ALL
+ END
+END
+
+IDR_FV_EDIT MENU
+BEGIN
+ POPUP "1"
+ BEGIN
+ MENUITEM "Copy", ID_EDIT_COPY
+ END
+END
+
+#endif // English (U.S.) resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+/////////////////////////////////////////////////////////////////////////////
+// English (U.K.) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENG)
+#ifdef _WIN32
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_UK
+#pragma code_page(1252)
+#endif //_WIN32
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Icon
+//
+
+// Icon with lowest ID value placed first to ensure application icon
+// remains consistent on all systems.
+IDI_TICK ICON "tick.ico"
+IDI_NOTICK ICON "notick.ico"
+#endif // English (U.K.) resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+
+#ifndef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 3 resource.
+//
+
+
+/////////////////////////////////////////////////////////////////////////////
+#endif // not APSTUDIO_INVOKED
+
diff --git a/tick.ico b/tick.ico
new file mode 100755
index 0000000..d24d6ad
--- /dev/null
+++ b/tick.ico
Binary files differ
diff --git a/utils.cpp b/utils.cpp
new file mode 100755
index 0000000..6df102a
--- /dev/null
+++ b/utils.cpp
@@ -0,0 +1,1740 @@
+
+//This file is part of Msg_Export a Miranda IM plugin
+//Copyright (C)2002 Kennet Nielsen ( http://sourceforge.net/projects/msg-export/ )
+//
+//This program is free software; you can redistribute it and/or
+//modify it under the terms of the GNU General Public License
+//as published by the Free Software Foundation; either
+//version 2 of the License, or (at your option) any later version.
+//
+//This program is distributed in the hope that it will be useful,
+//but WITHOUT ANY WARRANTY; without even the implied warranty of
+//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+//GNU General Public License for more details.
+//
+//You should have received a copy of the GNU General Public License
+//along with this program; if not, write to the Free Software
+//Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+
+
+#include <stdio.h>
+
+#include "Glob.h"
+#include "Utils.h"
+#include "FileViewer.h"
+
+#pragma warning (disable:4996)
+#include <m_protosvc.h>
+#include <m_icq.h>
+#pragma warning (default:4996)
+
+// Default error string used upon errors
+const _TCHAR *pszNickError = _T("No_Nick");
+const _TCHAR *pszGroupError = _T("No_Group");
+const _TCHAR *pszDbPathError = _T(".");
+
+// Replacement for chareteres not alowed in file names.
+const _TCHAR cBadCharReplace = _T('_');
+
+// sTimeFormat
+tstring sTimeFormat;
+
+// path from options dialog
+tstring sExportDir;
+
+// The default filename. Used if no other file name is specifyed in DB.
+tstring sDefaultFile;
+
+// path used then %dbpath% is used in export file path
+tstring sDBPath = pszDbPathError;
+
+// path to miranda exe file used when to avoid relative paths
+tstring 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
+// may be shorter. so to make all event have the same first
+// column width this map contains the largest user name
+map<tstring , string::size_type , less<tstring> > clFileTo1ColWidth;
+
+// default line width
+int nMaxLineWidth = 80;
+
+const _TCHAR *pszReplaceList[] =
+{
+ _T("%FirstName%") ,
+ _T("%LastName%") ,
+ _T("%e-mail%") ,
+ _T("%Nick%") ,
+ _T("%City%") ,
+ _T("%State%") ,
+ _T("%Phone%") ,
+ _T("%Homepage%") ,
+ _T("%About%")
+};
+const char *pszReplaceListA[] =
+{
+ "FirstName" ,
+ "LastName" ,
+ "e-mail" ,
+ "Nick" ,
+ "City" ,
+ "State" ,
+ "Phone" ,
+ "Homepage" ,
+ "About"
+};
+
+// Alowes this plugin to replace the history function of miranda !!
+bool bReplaceHistory = false;
+
+// This enum define the actions which MsgExport must take when a File is renamed
+ENDialogAction enRenameAction = eDAPromptUser;
+
+// This enum define the actions which MsgExport must take when a user is delete
+ENDialogAction enDeleteAction = eDAPromptUser;
+
+// If true MsgExport will use << and >> insted of the nick in the exported format
+bool bUseLessAndGreaterInExport = false;
+
+bool bAppendNewLine = true;
+bool bUseUtf8InNewFiles = true;
+
+const char szUtf8ByteOrderHeader[] = "\xEF\xBB\xBF";
+bool bIsUtf8Header( BYTE * pucByteOrder )
+{
+ return memcmp( pucByteOrder , szUtf8ByteOrderHeader , 3 ) == 0;
+}
+
+/////////////////////////////////////////////////////////////////////
+// Member Function : ShowDebugInfo
+// Type : Global
+// Parameters : None
+// Returns : void
+// Description :
+//
+// References : -
+// Remarks : -
+// Created : 021228 , 28 December 2002
+// Developer : KN
+/////////////////////////////////////////////////////////////////////
+
+void ShowDebugInfo()
+{
+ tstring sDebug = _T("Debug information\r\nsDBPath :");
+ sDebug += sDBPath;
+ sDebug += _T("\r\nsMirandaPath :");
+ sDebug += sMirandaPath;
+ sDebug += _T("\r\nsDefaultFile :");
+ sDebug += sDefaultFile;
+
+ sDebug += _T("\r\nGetFilePathFromUser( NULL ) :");
+ sDebug += GetFilePathFromUser( NULL );
+
+ MessageBox( NULL , sDebug.c_str() ,MSG_BOX_TITEL,MB_OK );
+}
+
+
+/////////////////////////////////////////////////////////////////////
+// Member Function : nGetFormatCount
+// Type : Global
+// Parameters : pszToCheck - ?
+// Returns : int
+// Description :
+//
+// References : -
+// Remarks : -
+// Created : 030107 , 07 January 2003
+// Developer : KN
+/////////////////////////////////////////////////////////////////////
+
+int nGetFormatCount( const _TCHAR * pszToCheck )
+{
+ if( !pszToCheck || pszToCheck[0] == 0 )
+ return 0;
+
+ int nCount = 0;
+ for( ; pszToCheck[1] != 0 ; pszToCheck++)
+ {
+ if( pszToCheck[0] == '%' && pszToCheck[1] != '%' )
+ nCount++;
+ }
+ return nCount;
+}
+
+/////////////////////////////////////////////////////////////////////
+// Member Function : CheckedTranslate
+// Type : Global
+// Parameters : szEng - ?
+// nFormatCount - ?
+// Returns : _TCHAR *
+// Description :
+//
+// References : -
+// Remarks : -
+// Created : 030107 , 07 January 2003
+// Developer : KN
+/////////////////////////////////////////////////////////////////////
+
+_TCHAR * CheckedTranslate( const _TCHAR *szEng , int nFormatCount /*= -1*/ )
+{
+ _TCHAR * szRet = TranslateTS( szEng );
+ if( szEng == szRet )
+ return (_TCHAR*)szEng;
+
+ if( nFormatCount == -1 )
+ nFormatCount = nGetFormatCount( szEng );
+
+ if( nFormatCount != nGetFormatCount( szRet ) )
+ {
+ tstring sError = _T("The language pack you are using has an error in the transalation of\r\n");
+ sError += szEng;
+ sError += _T("\r\n--------------- It was translated to ---------------\r\n");
+ sError += szRet;
+ MessageBox( NULL , sError.c_str() ,MSG_BOX_TITEL ,MB_OK );
+ return (_TCHAR*)szEng;
+ }
+ return szRet;
+}
+
+/////////////////////////////////////////////////////////////////////
+// Member Function : sGetErrorString
+// Type : Global
+// Parameters : dwError - ?
+// Returns : string
+// Description :
+//
+// References : -
+// Remarks : -
+// Created : 021012 , 12 October 2002
+// Developer : KN
+/////////////////////////////////////////////////////////////////////
+
+tstring sGetErrorString(DWORD dwError)
+{
+ LPVOID lpMsgBuf;
+ FormatMessage(
+ FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
+ NULL,
+ dwError,
+ MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
+ (LPTSTR) &lpMsgBuf,
+ 0,
+ NULL );
+ // Process any inserts in lpMsgBuf.
+ // ...
+ // Display the string.
+ tstring ret = (LPCTSTR)lpMsgBuf;
+ ReplaceAll( ret , _T("\r") , _T(" "));
+ ReplaceAll( ret , _T("\n") , _T(" "));
+ ReplaceAll( ret , _T(" ") , _T(" "));
+
+ // Free the buffer.
+ LocalFree( lpMsgBuf );
+ return ret;
+}
+
+tstring sGetErrorString()
+{
+ return sGetErrorString(GetLastError());
+}
+
+void DisplayLastError(const _TCHAR * pszError)
+{
+ tstring sError = pszError;
+ DWORD error = GetLastError();
+
+ _TCHAR szTemp[50];
+ _sntprintf( szTemp , sizeof( szTemp ) , _T("\r\nErrorCode : %d\r\n") , error );
+ sError += szTemp;
+ sError += sGetErrorString(error);
+ MessageBox( NULL , sError.c_str() ,MSG_BOX_TITEL ,MB_OK );
+}
+
+
+/////////////////////////////////////////////////////////////////////
+// Member Function : NickFromHandle
+// Type : Global
+// Parameters : hContact - ?
+// Returns : _TCHAR*
+// Description : Reads a Nick from the database and returns a
+// pointer to this.
+// References : -
+// Remarks : -
+// Created : 020422 , 22 April 2002
+// Developer : KN
+/////////////////////////////////////////////////////////////////////
+
+const _TCHAR* NickFromHandle(HANDLE hContact)
+{
+ const _TCHAR * psz = (const _TCHAR *)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, GCDNF_TCHAR );
+ if( psz )
+ return psz;
+ return pszNickError;
+}
+
+/////////////////////////////////////////////////////////////////////
+// Member Function : DBGetString
+// Type : Global
+// Parameters : hContact - ?
+// szModule - ?
+// szSetting - ?
+// pszError - ?
+// Returns : string
+// Description : Reads a string from the database
+// Just like those in database.h
+// References : -
+// Remarks : -
+// Created : 020422 , 22 April 2002
+// Developer : KN
+/////////////////////////////////////////////////////////////////////
+
+tstring DBGetStringW(HANDLE hContact,const char *szModule,const char *szSetting , const _TCHAR * pszError )
+{
+ tstring ret;
+ DBVARIANT dbv = {0};
+ //DBGetContactSetting
+ if( ! DBGetContactSettingWString( hContact , szModule , szSetting , &dbv ) )
+ {
+ if( dbv.type != DBVT_WCHAR)
+ {
+ MessageBox(NULL,_T("DB: Attempt to get wrong type of value, string"),MSG_BOX_TITEL,MB_OK);
+ ret = pszError;
+ }
+ else
+ {
+ ret = (_TCHAR*)dbv.pszVal;
+ }
+ }
+ else
+ ret = pszError;
+ DBFreeVariant(&dbv);
+ return ret;
+}
+
+string DBGetStringA(HANDLE hContact,const char *szModule,const char *szSetting , const char * pszError )
+{
+ string ret;
+ DBVARIANT dbv = {0};
+ if( ! DBGetContactSetting( hContact , szModule , szSetting , &dbv ) )
+ {
+ if( dbv.type != DBVT_ASCIIZ)
+ {
+ MessageBox(NULL,_T("DB: Attempt to get wrong type of value, string"),MSG_BOX_TITEL,MB_OK);
+ ret = pszError;
+ }
+ else
+ {
+ ret = dbv.pszVal;
+ }
+ }
+ else
+ ret = pszError;
+ DBFreeVariant(&dbv);
+ return ret;
+}
+
+/////////////////////////////////////////////////////////////////////
+// Member Function : ReplaceAll
+// Type : Global
+// Parameters : sSrc - string to replace in
+// pszReplace - what to replace
+// sNew - the string to insert insted of pszReplace
+// Returns : void
+// Description : will replace all acurances of a string with another string
+// used to replace %user% , and other user
+// References : -
+// Remarks : -
+// Created : 020422 , 22 April 2002
+// Developer : KN
+/////////////////////////////////////////////////////////////////////
+
+void ReplaceAll( tstring &sSrc , const _TCHAR * pszReplace , const tstring &sNew)
+{
+ string::size_type nCur = 0;
+ while( (nCur = sSrc.find(pszReplace,nCur)) != sSrc.npos )
+ {
+ sSrc.replace( nCur , _tcslen( pszReplace ) , sNew );
+ nCur += sNew.size();
+ }
+}
+
+void ReplaceAll( tstring &sSrc , const _TCHAR * pszReplace , const _TCHAR * pszNew)
+{
+ tstring sNew = pszNew;
+ ReplaceAll( sSrc , pszReplace , sNew );
+}
+
+
+/////////////////////////////////////////////////////////////////////
+// Member Function : bCreatePathToFile
+// Type : Global
+// Parameters : sFilePath - File name to create path to ( file name may be empty ( i.e. c:\Folder\ )
+// Returns : Returns true if the path is created or already exists
+// Description :
+//
+// References : -
+// Remarks : -
+// Created : 020525 , 25 May 2002
+// Developer : KN
+/////////////////////////////////////////////////////////////////////
+
+bool bCreatePathToFile( tstring sFilePath )
+{
+ string::size_type nPos = sFilePath.rfind( '\\' );
+ if( nPos != string.npos )
+ {
+ if( nPos + 1 < sFilePath.size() )
+ sFilePath.erase( nPos + 1);
+ }
+ else
+ {
+ // cant find \
+ return false;
+ }
+
+ // create directory
+ if( ! CreateDirectory( sFilePath.c_str() , NULL ) )
+ {
+ DWORD dwE = GetLastError();
+ if( dwE == 183 ) // Cannot create a file when that file already exists.
+ return true;
+ if( ! bCreatePathToFile( sFilePath.substr( 0 , nPos ) ) )
+ return false;
+
+ // try again
+ if( ! CreateDirectory( sFilePath.c_str() , NULL ) )
+ {
+ return false;
+ }
+ }
+ return true;
+}
+
+/////////////////////////////////////////////////////////////////////
+// Member Function : bWriteToFile
+// Type : Global
+// Parameters : hFile - ?
+// pszSrc - in UTF8 or ANSII
+// nLen - ?
+// Returns : Returns true if all the data was written to the file
+// Description :
+//
+// References : -
+// Remarks : -
+// Created : 020629 , 29 June 2002
+// Developer : KN
+/////////////////////////////////////////////////////////////////////
+
+bool bWriteToFile( HANDLE hFile , const char * pszSrc , int nLen = -1 )
+{
+ if( nLen < 0 )
+ nLen = strlen( pszSrc );
+ DWORD dwBytesWritten;
+ return WriteFile( hFile , pszSrc , nLen , &dwBytesWritten , NULL ) && (dwBytesWritten == (DWORD)nLen);
+}
+
+
+/////////////////////////////////////////////////////////////////////
+// Member Function : bWriteTextToFile
+// Type : Global
+// Parameters : hFile - ?
+// pszSrc - ?
+// bUtf8File - ?
+// Returns : Returns true if
+// Description :
+//
+// References : -
+// Remarks : -
+// Created : 060130 , 30 januar 2006
+// Developer : KN
+/////////////////////////////////////////////////////////////////////
+
+bool bWriteTextToFile( HANDLE hFile , const _TCHAR * pszSrc , bool bUtf8File ,int nLen = -1 )
+{
+ if( nLen < 0 )
+ nLen = _tcslen( pszSrc );
+ if( ! bUtf8File )
+ {
+#ifdef _UNICODE // We need to downgrade text to ansi
+ char * pszAstr = new char[nLen];
+ int nAnsiLen = WideCharToMultiByte(CP_ACP, 0, pszSrc, nLen, pszAstr , nLen , NULL , NULL );
+ bool bRet = bWriteToFile( hFile , pszAstr , nAnsiLen );
+ delete [] pszAstr;
+ return bRet;
+#else
+ return bWriteToFile( hFile , pszSrc , nLen );
+#endif
+ }
+#ifndef _UNICODE
+ wchar_t * pszWstr = new wchar_t[nLen];
+ if( MultiByteToWideChar(CP_ACP, 0, pszSrc, nLen, pszWstr, nLen ) != nLen )
+ {
+ delete [] pszWstr;
+ return false;
+ }
+ char * pszUtf8 = new char[nLen*2];// Ansi can't generate more then this.
+ int nUtf8Len = WideCharToMultiByte(CP_UTF8, 0, pszWstr, nLen, pszUtf8 , nLen * 2 , NULL , NULL );
+ delete [] pszWstr;
+ if( nUtf8Len < nLen ) // Not all was converted ?
+ {
+ delete [] pszUtf8;
+ return false;
+ }
+ bool bRet = bWriteToFile( hFile , pszUtf8 , nUtf8Len );
+ delete [] pszUtf8;
+#else
+ char * pszUtf8 = new char[nLen*3];// UCS-2 can't generate more then this.
+ int nUtf8Len = WideCharToMultiByte(CP_UTF8, 0, pszSrc, nLen, pszUtf8 , nLen * 3 , NULL , NULL );
+ bool bRet = bWriteToFile( hFile , pszUtf8 , nUtf8Len );
+#endif
+ return bRet;
+}
+
+#ifdef _UNICODE
+bool bWriteTextToFile( HANDLE hFile , const char * pszSrc , bool bUtf8File ,int nLen = -1 )
+{
+ if( nLen == -1 )
+ nLen = strlen( pszSrc );
+ wchar_t * pszWstr = new wchar_t[nLen];
+ bool bRet = false;
+ if( MultiByteToWideChar(CP_ACP, 0, pszSrc, nLen, pszWstr, nLen ) == nLen )
+ {
+ bRet = bWriteTextToFile( hFile , pszWstr , bUtf8File , nLen );
+ }
+ return bRet;
+}
+#endif
+
+
+/////////////////////////////////////////////////////////////////////
+// Member Function : bWriteNewLine
+// Type : Global
+// Parameters : hFile - ?
+// nIndent - ?
+// Returns : Returns true if all the data was written to the file
+// Description :
+//
+// References : -
+// Remarks : -
+// Created : 020629 , 29 June 2002
+// Developer : KN
+/////////////////////////////////////////////////////////////////////
+
+const char szNewLineIndent[] = "\r\n ";
+bool bWriteNewLine( HANDLE hFile , DWORD dwIndent )
+{
+ if( dwIndent > sizeof( szNewLineIndent ) - 2 )
+ dwIndent = sizeof( szNewLineIndent ) - 2;
+ return bWriteToFile( hFile , szNewLineIndent , dwIndent + 2 );
+}
+
+/////////////////////////////////////////////////////////////////////
+// Member Function : bWriteHexToFile
+// Type : Global
+// Parameters : hFile - ?
+// - ?
+// nSize - ?
+// Returns : void
+// Description :
+//
+// References : -
+// Remarks : -
+// Created : 021203 , 03 December 2002
+// Developer : KN
+/////////////////////////////////////////////////////////////////////
+
+bool bWriteHexToFile( HANDLE hFile , void * pData, int nSize )
+{
+ char cBuf[10];
+ BYTE * p = (BYTE*)pData;
+ for( int n = 0 ; n < nSize ; n++ )
+ {
+ sprintf( cBuf , "%.2X " , p[n] );
+ if( ! bWriteToFile( hFile , cBuf , 3 ) )
+ return false;
+ }
+ return true;
+}
+
+/////////////////////////////////////////////////////////////////////
+// Member Function : bReadMirandaDirAndPath
+// Type : Global
+// Parameters : None
+// Returns : void
+// Description : Used to set the internal path.
+// Handles the reading from the mirandaboot.ini to get the %dbpath%
+// References : -
+// Remarks : -
+// Created : 020422 , 22 April 2002
+// Developer : KN
+/////////////////////////////////////////////////////////////////////
+
+extern UTF8_INTERFACE utfi;
+
+bool bReadMirandaDirAndPath()
+{
+ _TCHAR szDBPath[MAX_PATH];
+ char tmp[MAX_PATH];
+ TCHAR *tmp2;
+ _tcscpy( szDBPath , pszDbPathError );
+ CallService(MS_UTILS_PATHTOABSOLUTE, (WPARAM)"miranda32.exe", (LPARAM)tmp);
+ tmp2 = mir_utf8decodeT(tmp);
+ sMirandaPath = tmp2;
+ sMirandaPath.erase(sMirandaPath.find_last_of(_T("\\")));
+ mir_free(tmp);
+ CallService(MS_DB_GETPROFILEPATHT, (WPARAM)MAX_PATH - 1, (LPARAM)szDBPath);
+ sDBPath = szDBPath;
+ CallService(MS_DB_GETPROFILENAMET, (WPARAM)MAX_PATH - 1, (LPARAM)szDBPath);
+ sDBPath.append(_T("\\")).append(szDBPath);
+ sDBPath.erase(sDBPath.size()-4);
+ return true;
+}
+
+/////////////////////////////////////////////////////////////////////
+// Member Function : ReplaceDBPath
+// Type : Global
+// Parameters : sRet - ?
+// Returns : void
+// Description :
+//
+// References : -
+// Remarks : -
+// Created : 021020 , 20 October 2002
+// Developer : KN
+/////////////////////////////////////////////////////////////////////
+
+void ReplaceDBPath( tstring &sRet )
+{
+ ReplaceAll( sRet , _T("%dbpath%") , 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;
+ }
+}
+
+
+/////////////////////////////////////////////////////////////////////
+// Member Function : GetFilePathFromUser
+// Type : Global
+// Parameters : hContact - Handle to user
+// Returns : string contaning the compleate file name and path
+// Description :
+//
+// References : -
+// Remarks : -
+// Created : 020422 , 22 April 2002
+// Developer : KN
+/////////////////////////////////////////////////////////////////////
+
+tstring GetFilePathFromUser( HANDLE hContact )
+{
+ tstring sFilePath = sExportDir + DBGetString( hContact , MODULE , "FileName" , sDefaultFile.c_str() );
+
+ bool bNickUsed = sFilePath.find( _T("%nick%") ) != string.npos;
+
+ ReplaceDefines( hContact , sFilePath );
+
+ tstring sNoDBPath = sFilePath;
+
+ ReplaceTimeVariables( sFilePath );
+ ReplaceDBPath( sFilePath );
+
+ // Previous file name check to see if it has changed !!
+ tstring sPrevFileName = DBGetString( hContact , MODULE , "PrevFileName" , _T("") );
+ if( sNoDBPath != sPrevFileName )
+ {
+ if( ! sPrevFileName.empty() )
+ {
+ ReplaceDBPath( sPrevFileName );
+
+ // Here we will try to avoide the (Unknown Contact) in cases where the protocol for
+ // this user has been removed.
+ if( bNickUsed && ( _tcsstr( NickFromHandle( hContact ),TranslateTS(_T("(Unknown Contact)"))) != 0) )
+ {
+ // Then the filename must have changed from a correct path to one including the (Unknown Contact)
+ return sPrevFileName;
+ }
+
+ // file name has changed
+
+ if( enRenameAction != eDANothing )
+ {
+
+ // we can not use FILE_SHARE_DELETE because this is not supported by
+ // win 98 / ME
+ HANDLE hPrevFile = CreateFile( sPrevFileName.c_str() ,
+ GENERIC_READ ,
+ FILE_SHARE_READ | FILE_SHARE_WRITE ,
+ NULL,
+ OPEN_EXISTING ,
+ FILE_ATTRIBUTE_NORMAL ,
+ NULL );
+
+ if( hPrevFile != INVALID_HANDLE_VALUE )
+ {
+ CloseHandle( hPrevFile );
+ _TCHAR szTemp[500];
+ // There is a previous file we can move
+ // ask user ?
+ bool bTryRename;
+
+ if( enRenameAction != eDAAutomatic )
+ {
+ tstring sRemoteUser = NickFromHandle(hContact);
+ _sntprintf( szTemp , sizeof( szTemp ) ,
+ CheckedTranslate(_T("File name for the user \"%s\" has changed !\n\nfrom:\t%s\nto:\t%s\n\nDo you wish to rename file ?"),3) ,
+ sRemoteUser.c_str(),
+ sPrevFileName.c_str(),
+ sFilePath.c_str() );
+ bTryRename = MessageBox( NULL , szTemp ,MSG_BOX_TITEL ,MB_YESNO ) == IDYES;
+ }
+ else
+ bTryRename = true;
+
+
+ if( bTryRename )
+ {
+ if( ! MoveFile( sPrevFileName.c_str(), sFilePath.c_str() ) )
+ {
+ // this might be because the new path isent created
+ // so we will try to create it
+ bCreatePathToFile( sFilePath );
+
+ while( ! MoveFile( sPrevFileName.c_str(), sFilePath.c_str() ) )
+ {
+ _sntprintf( szTemp , sizeof( szTemp ) ,
+ CheckedTranslate(_T("Failed to rename file\n\nfrom:\t%s\nto:\t%s\n\nFailed with error: %s"),3) ,
+ sPrevFileName.c_str(),
+ sFilePath.c_str() ,
+ sGetErrorString().c_str() );
+
+ if( MessageBox( NULL , szTemp ,MSG_BOX_TITEL,MB_RETRYCANCEL ) != IDRETRY )
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ // Store the Filename used so that we can check if it changes.
+ DBWriteContactSettingTString( hContact , MODULE , "PrevFileName" , sNoDBPath.c_str() );
+ }
+
+ return sFilePath;
+}
+
+
+/////////////////////////////////////////////////////////////////////
+// Member Function : FileNickFromHandle
+// Type : Global
+// Parameters : hContact - ?
+// Returns : string
+// Description : Replaceses invalid file name chars
+// References : -
+// Remarks : -
+// Created : 030107 , 07 January 2003
+// Developer : KN
+/////////////////////////////////////////////////////////////////////
+
+tstring FileNickFromHandle( HANDLE hContact)
+{
+ tstring ret = NickFromHandle( hContact );
+ string::size_type nCur = 0;
+ while( (nCur = ret.find_first_of(_T(":\\"),nCur)) != ret.npos )
+ ret[nCur] = cBadCharReplace;
+ return ret;
+}
+
+
+/////////////////////////////////////////////////////////////////////
+// Member Function : ReplaceAllNoColon
+// Type : Global
+// Parameters : sSrc - ?
+// pszReplace - ?
+// sNew - ?
+// Returns : void
+// Description : Removes any ':' in the new string
+//
+// References : -
+// Remarks : -
+// Created : 040205 , 05 februar 2004
+// Developer : KN
+/////////////////////////////////////////////////////////////////////
+
+void ReplaceAllNoColon( tstring &sSrc , const _TCHAR * pszReplace , tstring &sNew)
+{
+ tstring::size_type nCur = 0;
+ while( (nCur = sNew.find_first_of(_T(':'),nCur)) != sNew.npos )
+ sNew[nCur] = cBadCharReplace;
+ ReplaceAll( sSrc , pszReplace , sNew );
+}
+
+/////////////////////////////////////////////////////////////////////
+// Member Function : ReplaceDefines
+// Type : Global
+// Parameters : hContact - Handle to user
+// sTarget - String with either %user% or %UIN%, to replace in
+// Returns : void
+// Description :
+//
+// References : -
+// Remarks : -
+// Created : 020525 , 25 May 2002
+// Developer : KN
+/////////////////////////////////////////////////////////////////////
+
+void ReplaceDefines( HANDLE hContact , tstring & sTarget )
+{
+ if( sTarget.find( _T("%nick%") ) != string.npos )
+ {
+ ReplaceAll( sTarget , _T("%nick%") , FileNickFromHandle( hContact ) );
+ }
+
+ bool bUINUsed = sTarget.find( _T("%UIN%") ) != string.npos;
+ bool bEMailUsed = sTarget.find( _T("%e-mail%") ) != string.npos;
+ bool bProtoUsed = sTarget.find( _T("%protocol%") ) != string.npos;
+ bool bIdentifierUsed = sTarget.find( _T("%identifier%") ) != string.npos;
+
+ if( bUINUsed || bEMailUsed || bProtoUsed || bIdentifierUsed )
+ {
+ string sProto = DBGetStringA( hContact , "Protocol" , "p" , "" );
+ if( bUINUsed || ( bIdentifierUsed && sProto == "ICQ" ) )
+ {
+ DWORD dwUIN = DBGetContactSettingDword(hContact, sProto.c_str(), "UIN", 0);
+ tstring sReplaceUin;
+ if( dwUIN )
+ {
+ _TCHAR sTmp[20];
+ _sntprintf( sTmp , sizeof( sTmp ) ,_T("%d") , dwUIN );
+ sReplaceUin = sTmp;
+ }
+ else
+ {
+ sReplaceUin = FileNickFromHandle( hContact );
+ }
+
+ if( bUINUsed )
+ ReplaceAll( sTarget , _T("%UIN%") , sReplaceUin );
+ if( bIdentifierUsed && sProto == "ICQ" )
+ {
+ bIdentifierUsed = false;
+ ReplaceAll( sTarget , _T("%identifier%") , sReplaceUin );
+ }
+ }
+
+ if( bEMailUsed || ( bIdentifierUsed && sProto == "MSN"))
+ {
+ tstring sEMail = DBGetString( hContact , sProto.c_str() , "e-mail" , _T("") );
+ if( sEMail.empty() )
+ {
+ sEMail = DBGetString( hContact , "MSN" , "e-mail" , _T("") );
+ if( sEMail.empty() )
+ {
+ // We can't finde the E-mail address we will use the the nick
+ sEMail = FileNickFromHandle( hContact );
+ }
+ }
+ if( bEMailUsed )
+ ReplaceAllNoColon( sTarget , _T("%e-mail%") , sEMail );
+ if( bIdentifierUsed && sProto == "MSN")
+ {
+ bIdentifierUsed = false;
+ ReplaceAllNoColon( sTarget , _T("%identifier%") , sEMail );
+ }
+ }
+ if( bIdentifierUsed && sProto == "Jabber" )
+ {
+ tstring sReplace = DBGetString( hContact , "Jabber" , "jid" , _T("") );
+ if( sReplace.empty() )
+ {
+ sReplace = FileNickFromHandle( hContact );
+ }
+ bIdentifierUsed = false;
+ ReplaceAll( sTarget , _T("%identifier%") , sReplace );
+ }
+ if( bProtoUsed )
+ {
+ tstring tmp = DBGetString( hContact , "Protocol" , "p" , _T("") );
+ ReplaceAllNoColon( sTarget , _T("%protocol%") , tmp );
+ }
+ if( bIdentifierUsed )
+ {
+ // It has still not been replaced we will just use nick
+ ReplaceAll( sTarget , _T("%nick%") , FileNickFromHandle( hContact ) );
+ }
+ }
+
+ if( sTarget.find( _T("%group%") ) != string.npos )
+ {
+ tstring sGroup = DBGetString( hContact , "CList" , "Group" , _T("") );
+ ReplaceAllNoColon( sTarget , _T("%group%") , sGroup );
+ }
+
+ // We can't replace the : here because if the user uses C:\... in the file path
+ // this will also be replaced
+ string::size_type nCur = 0;
+ while( (nCur = sTarget.find_first_of(_T("/*?<>|\""),nCur)) != sTarget.npos )
+ sTarget[nCur] = cBadCharReplace;
+
+}
+
+
+/////////////////////////////////////////////////////////////////////
+// Member Function : ReplaceTimeVariables
+// Type : Global
+// Parameters : sRet - ?
+// Returns : void
+// Description :
+//
+// References : -
+// Remarks : -
+// Created : 040219 , 19 februar 2004
+// Developer : KN
+/////////////////////////////////////////////////////////////////////
+
+void ReplaceTimeVariables( tstring &sRet )
+{
+ if( sRet.find( _T("%year%") ) != string.npos ||
+ sRet.find( _T("%month%") ) != string.npos ||
+ sRet.find( _T("%day%") ) != string.npos )
+ {
+ SYSTEMTIME stTime;
+ GetLocalTime( &stTime );
+ _TCHAR sTmp[20];
+
+ _sntprintf( sTmp , sizeof( sTmp ) ,_T("%d") , stTime.wYear );
+ ReplaceAll( sRet , _T("%year%") , sTmp );
+ _sntprintf( sTmp , sizeof( sTmp ) ,_T("%.2d") , stTime.wMonth );
+ ReplaceAll( sRet , _T("%month%") , sTmp );
+ _sntprintf( sTmp , sizeof( sTmp ) ,_T("%.2d") , stTime.wDay );
+ ReplaceAll( sRet , _T("%day%") , sTmp );
+ }
+}
+
+/////////////////////////////////////////////////////////////////////
+// Member Function : UpdateFileToColWidth
+// Type : Global
+// Parameters : None
+// Returns : void
+// Description : updates clFileTo1ColWidth,
+//
+// References : -
+// Remarks : -
+// Created : 020422 , 22 April 2002
+// Developer : KN
+/////////////////////////////////////////////////////////////////////
+
+void UpdateFileToColWidth()
+{
+ clFileTo1ColWidth.clear();
+
+ HANDLE hContact = (HANDLE) CallService(MS_DB_CONTACT_FINDFIRST, 0, 0);
+ for(;;)
+ {
+ tstring sNick = NickFromHandle( hContact );
+ string::size_type &rnValue = clFileTo1ColWidth[ GetFilePathFromUser( hContact ) ];
+ if( rnValue < sNick.size() )
+ rnValue = sNick.size();
+
+ if( ! hContact )
+ break;
+
+ hContact = (HANDLE) CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM) hContact, 0);
+ }
+}
+
+
+
+/////////////////////////////////////////////////////////////////////
+// Member Function : DisplayErrorDialog
+// Type : Global
+// Parameters : pszError - ?
+// sFile - ?
+// dbei - ?
+// Returns : void
+// Description :
+//
+// References : -
+// Remarks : -
+// Created : 021203 , 03 December 2002
+// Developer : KN
+/////////////////////////////////////////////////////////////////////
+
+void DisplayErrorDialog( const _TCHAR * pszError , tstring& sFilePath , DBEVENTINFO * dbei )
+{
+ tstring sError = TranslateTS( pszError );
+ sError += sFilePath;
+ sError += _T("\nError :");
+ sError += sGetErrorString();
+ sError += _T("\n");
+ sError += TranslateTS(_T("Message has not been saved !\n"));
+ sError += TranslateTS(_T("Do you wish to save debug information ?"));
+ if( MessageBox( NULL , sError.c_str() ,MSG_BOX_TITEL,MB_YESNO ) == IDYES )
+ {
+ OPENFILENAME ofn; // common dialog box structure
+ _TCHAR szFile[260]; // buffer for file name
+ _tcscpy( szFile , _T("DebugInfo.txt") );
+
+ // Initialize OPENFILENAME
+ ZeroMemory(&ofn, sizeof(OPENFILENAME));
+ ofn.lStructSize = sizeof(OPENFILENAME);
+ //ofn.hwndOwner = NULL;
+ ofn.lpstrFile = szFile;
+ ofn.nMaxFile = sizeof(szFile);
+ ofn.lpstrFilter = _T("All\0*.*\0Text\0*.TXT\0\0");
+ ofn.nFilterIndex = 1;
+ ofn.lpstrFileTitle = NULL;
+ ofn.nMaxFileTitle = 0;
+ ofn.lpstrInitialDir = NULL;
+ ofn.Flags = 0 /*OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST*/;
+ ofn.lpstrDefExt = _T("TXT");
+
+ // Display the Open dialog box.
+
+ if( GetSaveFileName(&ofn) )
+ {
+ HANDLE hf; // file handle
+ hf = CreateFile(ofn.lpstrFile, GENERIC_WRITE,
+ 0, (LPSECURITY_ATTRIBUTES) NULL,
+ CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL,
+ (HANDLE) NULL);
+
+ bWriteTextToFile( hf , sError.c_str() , false );
+ if( dbei )
+ {
+ bWriteToFile( hf , "\r\ndbei :" );
+
+ bWriteHexToFile( hf , dbei , sizeof( DBEVENTINFO ));
+ if( dbei->pBlob )
+ {
+ bWriteToFile( hf , "\r\ndbei.pBlob :" );
+ bWriteHexToFile( hf , dbei->pBlob , min( dbei->cbBlob , 10000 ));
+ }
+ if( dbei->szModule )
+ {
+ bWriteToFile( hf , "\r\ndbei.szModule :" );
+ bWriteToFile( hf , dbei->szModule );
+ }
+ }
+ CloseHandle( hf );
+ }
+ }
+}
+
+/////////////////////////////////////////////////////////////////////
+// Member Function : ExportDBEventInfo
+// Type : Global
+// Parameters : hContact - handle to contact
+// dbei - Event to export
+// Returns : void
+// Description :
+//
+// References : -
+// Remarks : -
+// Created : 050429 , 29 april 2005
+// Developer : KN
+/////////////////////////////////////////////////////////////////////
+
+void ExportDBEventInfo(HANDLE hContact, DBEVENTINFO &dbei )
+{
+ _TCHAR szTemp[500];
+ tstring sFilePath = GetFilePathFromUser( hContact );
+
+ GetLastError();// Clear last error !!
+
+ HANDLE hFile = CreateFile( sFilePath.c_str() , GENERIC_WRITE | GENERIC_READ, FILE_SHARE_READ , 0 ,OPEN_ALWAYS , FILE_ATTRIBUTE_NORMAL , NULL );
+ if( hFile == INVALID_HANDLE_VALUE )
+ {
+ // this might be because the path isent created
+ // so we will try to create it
+ if( bCreatePathToFile( sFilePath ) )
+ {
+ hFile = CreateFile( sFilePath.c_str() , GENERIC_WRITE | GENERIC_READ, FILE_SHARE_READ , 0 ,OPEN_ALWAYS , FILE_ATTRIBUTE_NORMAL , NULL );
+ }
+ }
+
+ if( hFile == INVALID_HANDLE_VALUE )
+ {
+ DisplayErrorDialog( _T("Failed to open or create file :\n") , sFilePath , NULL );
+ return;
+ }
+
+ tstring sLocalUser;
+ tstring sRemoteUser;
+ string::size_type nFirstColumnWidth;
+
+ if( bUseLessAndGreaterInExport )
+ {
+ sLocalUser = _T("<<");
+ sRemoteUser = _T(">>");
+ nFirstColumnWidth = 4;
+ }
+ else
+ {
+ sLocalUser = NickFromHandle(0);
+ sRemoteUser = NickFromHandle(hContact);
+ nFirstColumnWidth = max( sRemoteUser.size() , clFileTo1ColWidth[sFilePath] );
+ nFirstColumnWidth = max( sLocalUser.size() , nFirstColumnWidth );
+ nFirstColumnWidth += 2;
+ }
+
+ bool bWriteUTF8Format = false;
+
+ {
+ DWORD dwLowSize;
+ DWORD dwHighSize = 0;
+
+ dwLowSize = GetFileSize( hFile , &dwHighSize );
+
+ if( dwLowSize == INVALID_FILE_SIZE || dwLowSize != 0 || dwHighSize != 0 )
+ {
+ DWORD dwDataRead = 0;
+ BYTE ucByteOrder[3];
+ if( ReadFile( hFile , ucByteOrder , 3 , &dwDataRead , NULL ) )
+ {
+ bWriteUTF8Format = bIsUtf8Header( ucByteOrder );
+ }
+ DWORD dwPtr = SetFilePointer( hFile , 0 , 0 , FILE_END );
+ if( dwPtr == INVALID_SET_FILE_POINTER )
+ {
+ // we need to aborte mission here because if we continue we risk
+ // overwriting old log.
+ DisplayErrorDialog( _T("Failed to move to the end of the file :\n") , sFilePath , NULL );
+ CloseHandle( hFile );
+ return;
+ }
+ }
+ else
+ {
+ bWriteUTF8Format = bUseUtf8InNewFiles;
+ if( bWriteUTF8Format )
+ {
+ if( ! bWriteToFile( hFile , szUtf8ByteOrderHeader, sizeof( szUtf8ByteOrderHeader ) - 1 ) )
+ {
+ DisplayErrorDialog( _T("Failed to UTF8 byte order code to file :\n") , sFilePath , NULL );
+ CloseHandle( hFile );
+ return;
+ }
+ }
+ tstring output = _T("------------------------------------------------\r\n")
+ _T(" History for\r\n")
+ _T("User : %User%\r\n")
+ _T("Protocol : %Proto%\r\n")
+ _T("UIN : %UIN%\r\n")
+ _T("FirstName : %FirstName%\r\n")
+ _T("LastName : %LastName%\r\n")
+ _T("Age : %Age%\r\n")
+ _T("Gender : %Gender%\r\n")
+ _T("e-mail : %e-mail%\r\n")
+ _T("Nick : %Nick% \r\n")
+ _T("City : %City%\r\n")
+ _T("State : %State%\r\n")
+ _T("Phone : %Phone%\r\n")
+ _T("Homepage : %Homepage%\r\n")
+ _T("- About -\r\n%About%\r\n")
+ _T("------------------------------------------------\r\n");
+
+ // This is written this way because I expect this will become a string the user may set
+ // in the options dialog.
+ ReplaceAll( output , _T("%User%") , sRemoteUser );
+
+ string sProto = DBGetStringA( hContact , "Protocol" , "p" , "" );
+ ReplaceAll( output , _T("%Proto%") , DBGetString( hContact , "Protocol" , "p" , _T("") ) );
+
+ for( int nCur = 0 ; nCur < 9 ; nCur++ )
+ {
+ ReplaceAll( output , pszReplaceList[nCur] , DBGetString( hContact , sProto.c_str() , pszReplaceListA[nCur] , _T("") ) );
+ }
+
+ _sntprintf( szTemp , sizeof( szTemp ) , _T("%d") , DBGetContactSettingDword(hContact, sProto.c_str(), "UIN", 0) );
+ ReplaceAll( output , _T("%UIN%") , szTemp );
+
+ _sntprintf( szTemp , sizeof( szTemp ) , _T("%d") , DBGetContactSettingWord(hContact, sProto.c_str(), "Age", 0));
+ ReplaceAll( output , _T("%Age%") , szTemp );
+
+ szTemp[0] = (_TCHAR)DBGetContactSettingByte(hContact, sProto.c_str(), "Gender", 0);
+ szTemp[1] = 0;
+ ReplaceAll( output , _T("%Gender%") , szTemp );
+
+ if( ! bWriteTextToFile( hFile , output.data(), bWriteUTF8Format, output.size() ) )
+ {
+ DisplayErrorDialog( _T("Failed to write user details to file :\n") , sFilePath , NULL );
+ CloseHandle( hFile );
+ return;
+ }
+ }
+ }
+
+ int nIndent;
+ { // Get time stamp
+
+ nIndent = _sntprintf( szTemp , sizeof( szTemp ) , _T("%-*s") ,
+ nFirstColumnWidth ,
+ dbei.flags & DBEF_SENT ? sLocalUser.c_str() : sRemoteUser.c_str() );
+
+ DBTIMETOSTRINGT dbtts;
+ dbtts.cbDest = sizeof(szTemp) - nIndent - 2;
+ dbtts.szDest = &szTemp[nIndent];
+ dbtts.szFormat = (_TCHAR*)sTimeFormat.c_str();
+#ifdef _UNICODE
+ CallService(MS_DB_TIME_TIMESTAMPTOSTRINGT,dbei.timestamp,(LPARAM)&dbtts);
+#else
+ CallService(MS_DB_TIME_TIMESTAMPTOSTRING,dbei.timestamp,(LPARAM)&dbtts);
+#endif
+ nIndent = _tcslen( szTemp );
+ szTemp[nIndent++] = ' ';
+
+ // Write first part of line with name and timestamp
+ if( ! bWriteTextToFile( hFile , szTemp , bWriteUTF8Format , nIndent ) )
+ {
+ DisplayErrorDialog( _T("Failed to write timestamp and username to file :\n") , sFilePath , &dbei );
+ CloseHandle( hFile );
+ return;
+ }
+ }
+
+ if( dbei.pBlob != NULL && dbei.cbBlob >= 2 )
+ {
+ dbei.pBlob[ dbei.cbBlob ] = 0;
+
+ switch(dbei.eventType)
+ {
+ case EVENTTYPE_MESSAGE:
+ {
+ TCHAR* msg = DbGetEventTextT( &dbei, CP_ACP );
+ if( ! bWriteIndentedToFile( hFile , nIndent , msg , bWriteUTF8Format ) )
+ {
+ DisplayErrorDialog( _T("Failed to write message to the file :\n") , sFilePath , &dbei );
+ }
+ mir_free(msg);
+ break;
+/*
+ const char * pszData = (const char*)dbei.pBlob;
+ bool bConvertedToUtf8 = false;
+ if( bWriteUTF8Format )// Write UTF-8 format in file ?
+ {
+ int nAnsiLen = strlen((char *) dbei.pBlob)+1;
+ if( nAnsiLen < (int)dbei.cbBlob )
+ {
+ // Message is also encoded in unicode UTF-16/UCS-2, little endian.
+ if( WideCharToMultiByte( CP_UTF8 , 0 , (wchar_t*)&dbei.pBlob[ nAnsiLen ] , nAnsiLen , szTemp , sizeof(szTemp) , 0 , 0 ) )
+ {
+ pszData = szTemp;
+ bConvertedToUtf8 = true;
+ }
+ }
+ // We need to write in UTF8 format so we have to convert ansi string to UTF8
+ }
+ if( ! bWriteIndentedToFile( hFile , nIndent , pszData , bWriteUTF8Format ) )
+ {
+ DisplayErrorDialog( _T("Failed to write message to the file :\n") , sFilePath , &dbei );
+ }
+ break;*/
+ }
+ case EVENTTYPE_URL:
+ case EVENTTYPE_FILE:
+ {
+ const _TCHAR * pszType;
+ const char * pszData;
+
+ if( dbei.eventType == EVENTTYPE_URL )
+ {
+ pszType = TranslateTS(_T("URL: "));
+ pszData = (char *)dbei.pBlob;
+ }
+ else
+ {
+ pszType = TranslateTS(_T("File: "));
+ pszData = (char *)(dbei.pBlob + sizeof( DWORD ));
+ }
+
+ bool bWriteOk = false;
+
+ int nLen = strlen( pszData );
+ if( (pszData - (char *)dbei.pBlob) + nLen < (int)dbei.cbBlob )
+ {
+ if( bWriteTextToFile( hFile , pszType , bWriteUTF8Format ) &&
+ bWriteIndentedToFile( hFile , nIndent , pszData , bWriteUTF8Format ) )
+ {
+ pszData += nLen + 1;
+ if( (pszData - (char *)dbei.pBlob) >= (int)dbei.cbBlob )
+ {
+ bWriteOk = true;
+ }
+ else
+ {
+ nLen = strlen( pszData );
+ if( (pszData - (char *)dbei.pBlob) + nLen < (int)dbei.cbBlob )
+ {
+ if( bWriteNewLine( hFile , nIndent ) &&
+ bWriteTextToFile( hFile , TranslateTS(_T("Description: ")) , bWriteUTF8Format) &&
+ bWriteIndentedToFile( hFile , nIndent , pszData , bWriteUTF8Format ) )
+ {
+ bWriteOk = true;
+ }
+ }
+ }
+ }
+ }
+
+ if( ! bWriteOk )
+ DisplayErrorDialog( _T("Failed to write URL/File to the file :\n") , sFilePath , &dbei );
+ break;
+ }
+ case EVENTTYPE_AUTHREQUEST:
+ case EVENTTYPE_ADDED:
+ {
+ const _TCHAR * pszTypes[] = {
+ _T("Nick :"),
+ _T("FirstName :"),
+ _T("LastName :"),
+ _T("e-mail :"),
+ _T("Reason :")};
+
+ /*// test code
+ dbei.pBlob = (BYTE*)("\xED\xA8\x29\x09nick\0first\0last\0email");
+ dbei.cbBlob = 26;
+ */
+
+ if( dbei.cbBlob < 8 || dbei.cbBlob > 5000 )
+ {
+ int n = _sntprintf( szTemp , sizeof( szTemp ) ,_T("Invalid Database event received. Type %d, size %d"),dbei.eventType, dbei.cbBlob );
+ if( ! bWriteTextToFile( hFile , szTemp , bWriteUTF8Format , n ) )
+ DisplayErrorDialog( _T("Failed to write Invalid Database event the file :\n") , sFilePath , &dbei );
+ break;
+ }
+
+ bool bWriteOk = false;
+
+ int nStringCount;
+ const _TCHAR * pszTitle;
+ if( dbei.eventType == EVENTTYPE_AUTHREQUEST )
+ { // request
+ //blob is: uin(DWORD), nick(ASCIIZ), first(ASCIIZ), last(ASCIIZ), email(ASCIIZ), reason(ASCIIZ)
+ nStringCount = 5;
+ pszTitle = TranslateTS(_T("The following user made an authorization request:"));
+ }
+ else
+ { // Added
+ //blob is: uin(DWORD), nick(ASCIIZ), first(ASCIIZ), last(ASCIIZ), email(ASCIIZ)
+ nStringCount = 4;
+ pszTitle = TranslateTS(_T("The following user added you to their contact list:"));
+ }
+
+ if( bWriteTextToFile( hFile , pszTitle , bWriteUTF8Format ) &&
+ bWriteNewLine( hFile , nIndent ) &&
+ bWriteTextToFile( hFile , TranslateTS(_T("UIN :")) , bWriteUTF8Format ) )
+ {
+ DWORD uin = *((PDWORD)(dbei.pBlob));
+ int n = _sntprintf( szTemp , sizeof( szTemp ) ,_T("%d"), uin );
+ if( bWriteTextToFile( hFile , szTemp , bWriteUTF8Format , n ) )
+ {
+ char * pszCurBlobPos = (char *) (dbei.pBlob + sizeof( DWORD ));
+ char * pszEnd = (char *) (dbei.pBlob + dbei.cbSize);
+ for( int n = 0 ; n < nStringCount && pszCurBlobPos < pszEnd ; n++ )
+ {
+ if( *pszCurBlobPos )
+ {
+ if( ! bWriteNewLine( hFile , nIndent ) ||
+ ! bWriteTextToFile( hFile , TranslateTS(pszTypes[ n ]) , bWriteUTF8Format ) ||
+ ! bWriteIndentedToFile( hFile , nIndent , pszCurBlobPos , bWriteUTF8Format ) )
+ {
+ break;
+ }
+ pszCurBlobPos += strlen( pszCurBlobPos );
+ }
+ pszCurBlobPos++;
+ }
+ bWriteOk = true;
+ }
+ }
+
+ if( ! bWriteOk )
+ DisplayErrorDialog( _T("Failed to write AUTHREQUEST or ADDED to the file :\n") , sFilePath , &dbei );
+
+ break;
+ }
+ case ICQEVENTTYPE_EMAILEXPRESS:
+ case ICQEVENTTYPE_WEBPAGER:
+ {
+ //e-mail express
+ //db event added to NULL contact
+ //blob format is:
+ //ASCIIZ text, usually of the form "Subject: %s\r\n%s"
+ //ASCIIZ from name
+ //ASCIIZ from e-mail
+
+ //www pager
+ //db event added to NULL contact
+ //blob format is:
+ //ASCIIZ text, usually "Sender IP: xxx.xxx.xxx.xxx\r\n%s"
+ //ASCIIZ from name
+ //ASCIIZ from e-mail
+ const char* pszStr = (const char*)dbei.pBlob;
+
+ if( dbei.eventType == ICQEVENTTYPE_EMAILEXPRESS )
+ bWriteTextToFile( hFile , TranslateTS(_T("EmailExpress from:")) , bWriteUTF8Format);
+ else
+ bWriteTextToFile( hFile , TranslateTS(_T("WebPager from:")) , bWriteUTF8Format );
+
+ bWriteNewLine( hFile , nIndent );
+
+ size_t nMsgLenght = strlen( pszStr ) + 1;
+ if( nMsgLenght < dbei.cbBlob )
+ {
+ size_t nFriendlyLen = strlen( &pszStr[nMsgLenght] );
+ bWriteTextToFile( hFile , &pszStr[nMsgLenght] , bWriteUTF8Format , nFriendlyLen );
+ size_t nEmailOffset = nMsgLenght + nFriendlyLen + 1;
+ if( nEmailOffset < dbei.cbBlob )
+ {
+ bWriteTextToFile( hFile , _T("<") , bWriteUTF8Format );
+ size_t nEmailLen = strlen( &pszStr[nEmailOffset] );
+ bWriteTextToFile( hFile , &pszStr[nEmailOffset] , bWriteUTF8Format , nEmailLen );
+ bWriteTextToFile( hFile , _T(">") , bWriteUTF8Format );
+ }
+ }
+ else
+ {
+ bWriteTextToFile( hFile , TranslateTS(_T("No from address")) , bWriteUTF8Format );
+ }
+
+ if( ! bWriteNewLine( hFile , nIndent ) ||
+ ! bWriteIndentedToFile( hFile , nIndent , pszStr , bWriteUTF8Format ) )
+ {
+ DisplayErrorDialog( _T("Failed to write EmailExpress to the file :\n") , sFilePath , &dbei );
+ }
+ break;
+ }
+ case ICQEVENTTYPE_SMS:
+ {
+ if( ! bWriteIndentedToFile( hFile , nIndent , (const char*)dbei.pBlob , bWriteUTF8Format ) )
+ {
+ DisplayErrorDialog( _T("Failed to write SMS to the file :\n") , sFilePath , &dbei );
+ }
+ break;
+ }
+ default:
+ {
+ int n = _sntprintf( szTemp , sizeof( szTemp ) ,_T("Unknown event type %d, size %d") , dbei.eventType, dbei.cbBlob );
+ if( ! bWriteTextToFile( hFile , szTemp , bWriteUTF8Format , n ) )
+ {
+ DisplayErrorDialog( _T("Failed to write Unknown event to the file :\n") , sFilePath , &dbei );
+ }
+ break;
+ }
+ }
+ }
+ else
+ {
+ int n = _sntprintf( szTemp , sizeof( szTemp ) ,_T("Unknown event type %d, size %d") , dbei.eventType, dbei.cbBlob );
+ bWriteTextToFile( hFile , szTemp , bWriteUTF8Format , n );
+ }
+ bWriteToFile( hFile , bAppendNewLine ? "\r\n\r\n" : "\r\n" );
+
+ CloseHandle( hFile );
+
+ UpdateFileViews( sFilePath.c_str() );
+}
+
+/////////////////////////////////////////////////////////////////////
+// Member Function : nExportEvent
+// Type : Global
+// Parameters : wparam - handle to contact
+// lparam - handle to the new DB event
+// Returns : int
+// Description : Called when an event is added to the DB
+// Or from the Export All funktion
+// References : -
+// Remarks : -
+// Created : 020422 , 22 April 2002
+// Developer : KN
+/////////////////////////////////////////////////////////////////////
+
+
+int nExportEvent(WPARAM wparam,LPARAM lparam)
+{
+ HANDLE hContact = (HANDLE)wparam;
+
+ if( ! DBGetContactSettingByte(hContact,MODULE,"EnableLog",1) )
+ return 0;
+
+ DBEVENTINFO dbei={0};
+ dbei.cbSize=sizeof(dbei);
+ char szTemp[500];
+
+ { // Get Blob data size
+
+ int nSize = CallService(MS_DB_EVENT_GETBLOBSIZE,(WPARAM)lparam,0);
+ 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
+ }
+ // else dbei.cbBlob will be 0
+ }
+
+ if( ! CallService(MS_DB_EVENT_GET,(WPARAM)lparam,(LPARAM)&dbei) )
+ {
+ if( dbei.eventType != EVENTTYPE_STATUSCHANGE )
+ {
+ _snprintf( szTemp , sizeof( szTemp ) , "DisableProt_%s" , dbei.szModule );
+ if( DBGetContactSettingByte(NULL,MODULE,szTemp,1) )
+ {
+ ExportDBEventInfo( hContact , dbei );
+ }
+ }
+ }
+ if( dbei.pBlob )
+ free(dbei.pBlob);
+ return 0;
+}
+
+#ifdef _UNICODE
+bool bWriteIndentedToFile( HANDLE hFile , int nIndent , const char * pszSrc , bool bUtf8File )
+{
+ int nLen = strlen( pszSrc );
+ wchar_t * pszWstr = new wchar_t[nLen+1];
+ bool bRet = false;
+ if( MultiByteToWideChar(CP_ACP, 0, pszSrc, nLen, pszWstr, nLen ) == nLen )
+ {
+ pszWstr[nLen] = NULL;
+ bRet = bWriteIndentedToFile( hFile , nIndent , pszWstr , bUtf8File );
+ }
+ return bRet;
+}
+#endif
+
+/////////////////////////////////////////////////////////////////////
+// Member Function : bWriteIndentedToFile
+// Type : Global
+// Parameters : hFile - ?
+// nIndent - ?
+// pszSrc -
+// Returns : Returns true if
+// Description :
+//
+// References : -
+// Remarks : -
+// Created : 020629 , 29 June 2002
+// Developer : KN
+/////////////////////////////////////////////////////////////////////
+
+bool bWriteIndentedToFile( HANDLE hFile , int nIndent , const _TCHAR * pszSrc , bool bUtf8File )
+{
+ bool bOk = true;
+ bool bFirstLine = true;
+
+ while( *pszSrc )
+ { // first we will scan forward in string to finde either new line or "max line with"
+ int nLineLen = 0;
+ do
+ {
+/* if( bUtf8Src )
+ { // need to do some stuff here
+ }*/
+ if( pszSrc[nLineLen] == _T('\n') || pszSrc[nLineLen] == _T('\r'))
+ { // the line naturly broken here stop scan
+ break;
+ }
+
+ if( nLineLen >= nMaxLineWidth )
+ { // ok the line was not broken. we need to force a break
+ // we will scan backwards again to finde a space !!
+ // then we will look for a ? and so on.
+
+ const _TCHAR ac[] = { _T(' '),_T('?'),_T('-'),_T('.'),_T(',') };
+ for( int y = 0 ; y < sizeof( ac ) ; y++)
+ {
+ for( int n = nLineLen ; n > 0 ; n-- )
+ {
+ if( pszSrc[n] == ac[y] )
+ {
+ nLineLen = n;
+ goto SuperBreak;
+ }
+ }
+ }
+ break;
+ }
+ nLineLen++;
+ }
+ while( pszSrc[nLineLen] );
+
+ // trim away traling spaces !!
+ if( nLineLen > 0 )
+ {
+ while( pszSrc[nLineLen-1] == ' ' )
+ nLineLen--;
+ }
+
+SuperBreak:
+
+
+ // nLineLen should contain the number af chars we need to write to the file
+ if( nLineLen > 0 )
+ {
+ if( !bFirstLine )
+ {
+ if( ! bWriteNewLine( hFile , nIndent ) )
+ {
+ bOk = false;
+ }
+ }
+/* if( bUtf8Src )
+ {
+ // Programming error writing UTF8 string to ansi file
+ if( ! bUtf8File )
+ {
+ MessageBox( NULL , _T("Programming error writing UTF8 string to ansi file") ,MSG_BOX_TITEL,MB_OK );
+ // bUtf8File must be true here
+ }
+ if( !bWriteToFile( hFile , pszSrc , nLineLen ) )
+ {
+ bOk = false;
+ }
+ }
+ else*/
+ {// Text format !!
+ if( ! bWriteTextToFile( hFile , pszSrc , bUtf8File , nLineLen ) )
+ bOk = false;
+ }
+ }
+ bFirstLine = false;
+
+ // skip any noice chars, MAC style '\r' '\r' '\n'
+ // and excess spaces
+ const _TCHAR * pszPrev = pszSrc;
+ pszSrc += nLineLen;
+ while( *pszSrc == _T(' ') || *pszSrc == _T('\n') || *pszSrc == _T('\r') )
+ pszSrc++;
+
+ if( pszPrev == pszSrc )
+ {
+ // this is an programming error we have not moved forward in string
+ MessageBox( NULL , _T("Programming error on line __LINE__ please report this") ,MSG_BOX_TITEL,MB_OK );
+ break;
+ }
+ }
+
+ // if bOk if false file writing failed
+ return bOk;
+}
+
+
+/////////////////////////////////////////////////////////////////////
+// Member Function : nContactDeleted
+// Type : Global
+// Parameters : wparam - handle to the deleted Contact
+// lparam - 0
+// Returns : int
+// Description : Called when an contact is about to be deleted
+//
+// References : -
+// Remarks : -
+// Created : 021222 , 22 December 2002
+// Developer : KN
+/////////////////////////////////////////////////////////////////////
+
+int nContactDeleted(WPARAM wparam,LPARAM /*lparam*/)
+{
+ if( enDeleteAction == eDANothing )
+ return 0;
+
+ HANDLE hContact = (HANDLE)wparam;
+
+ tstring sFilePath = GetFilePathFromUser( hContact );
+
+ { // Test if there is another user using this file
+ HANDLE hOtherContact = (HANDLE) CallService(MS_DB_CONTACT_FINDFIRST, 0, 0);
+ for(;;)
+ {
+ if( hContact != hOtherContact && sFilePath == GetFilePathFromUser( hOtherContact ) )
+ {
+ return 0; // we found another contact abort mission :-)
+ }
+
+ if( ! hOtherContact )
+ break;
+ hOtherContact = (HANDLE) CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM) hOtherContact, 0);
+ }
+ }
+
+ // Test to see if there is a file to delete
+ HANDLE hPrevFile = CreateFile( sFilePath.c_str() ,
+ GENERIC_READ ,
+ FILE_SHARE_READ | FILE_SHARE_WRITE ,
+ NULL,
+ OPEN_EXISTING ,
+ FILE_ATTRIBUTE_NORMAL ,
+ NULL );
+
+ if( hPrevFile != INVALID_HANDLE_VALUE )
+ {
+ CloseHandle( hPrevFile );
+
+ _TCHAR szTemp[500];
+ _sntprintf( szTemp , sizeof( szTemp ) , _T("%s\r\n%s") ,
+ TranslateTS(_T("User has been deleted do you want to delete the file ?")) ,
+ sFilePath.c_str() );
+
+ if( enDeleteAction == eDAAutomatic ||
+ MessageBox( NULL , szTemp ,MSG_BOX_TITEL,MB_YESNO ) == IDYES )
+ {
+ if( ! DeleteFile( sFilePath.c_str() ) )
+ {
+ _sntprintf( szTemp , sizeof( szTemp ) ,
+ _T("%s\r\n%s"),
+ TranslateTS(_T("Failed to delete the file")),
+ sFilePath.c_str() );
+
+ DisplayLastError( szTemp );
+ }
+ }
+ }
+ return 0;
+}
+
+/////////////////////////////////////////////////////////////////////
+// Member Function : SaveSettings
+// Type : Global
+// Parameters : None
+// Returns : void
+// Description : Save Settings
+//
+// References : -
+// Remarks : -
+// Created : 020429 , 29 April 2002
+// Developer : KN
+/////////////////////////////////////////////////////////////////////
+
+void SaveSettings()
+{
+ DBWriteContactSettingWord( NULL , MODULE , "MaxLineWidth" , (WORD) nMaxLineWidth );
+ DBWriteContactSettingTString( NULL , MODULE , "ExportDir" , sExportDir.c_str() );
+ DBWriteContactSettingTString( NULL , MODULE , "DefaultFile" , sDefaultFile.c_str() );
+ DBWriteContactSettingTString( NULL , MODULE , "TimeFormat" , sTimeFormat.c_str() );
+
+ DBWriteContactSettingTString( NULL , MODULE , "FileViewerPrg" , sFileViewerPrg.c_str() );
+ DBWriteContactSettingByte( NULL , MODULE , "UseInternalViewer" , bUseInternalViewer() );
+ DBWriteContactSettingByte( NULL , MODULE , "ReplaceHistory" , bReplaceHistory );
+ DBWriteContactSettingByte( NULL , MODULE , "AppendNewLine" , bAppendNewLine );
+ DBWriteContactSettingByte( NULL , MODULE , "UseUtf8InNewFiles" , bUseUtf8InNewFiles );
+ DBWriteContactSettingByte( NULL , MODULE , "UseLessAndGreaterInExport" , bUseLessAndGreaterInExport );
+
+ DBWriteContactSettingByte( NULL , MODULE , "RenameAction" , (BYTE)enRenameAction );
+ DBWriteContactSettingByte( NULL , MODULE , "DeleteAction" , (BYTE)enDeleteAction );
+}
+
diff --git a/utils.h b/utils.h
new file mode 100755
index 0000000..7b4523f
--- /dev/null
+++ b/utils.h
@@ -0,0 +1,125 @@
+
+//This file is part of Msg_Export a Miranda IM plugin
+//Copyright (C)2002 Kennet Nielsen ( http://sourceforge.net/projects/msg-export/ )
+//
+//This program is free software; you can redistribute it and/or
+//modify it under the terms of the GNU General Public License
+//as published by the Free Software Foundation; either
+//version 2 of the License, or (at your option) any later version.
+//
+//This program is distributed in the hope that it will be useful,
+//but WITHOUT ANY WARRANTY; without even the implied warranty of
+//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+//GNU General Public License for more details.
+//
+//You should have received a copy of the GNU General Public License
+//along with this program; if not, write to the Free Software
+//Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+
+#ifndef MSG_EXP_UTILS_H
+#define MSG_EXP_UTILS_H
+
+#include <windows.h>
+
+#if defined ( _MSC_VER ) // A Microsoft C Compiler
+ #ifdef _DEBUG // The _ASSERT macro contains a constant expression
+ #pragma warning( disable : 4786 )
+ #endif
+#endif // defined ( _MSC_VER )
+
+#pragma warning (push, 3 )
+#pragma warning (disable:4996)
+
+#include "stdio.h"
+
+#include <newpluginapi.h>
+#include <m_database.h>
+#include <m_clist.h>
+#include <m_skin.h>
+#include <m_langpack.h>
+#include <m_options.h>
+#include <m_system.h>
+#include <m_history.h>
+#include <m_userinfo.h>
+#include <m_utils.h>
+#include <m_protocols.h>
+
+#define EVENTTYPE_STATUSCHANGE 25368
+
+#include <list>
+#include <string>
+#include <map>
+#pragma warning (default:4996)
+#pragma warning (pop)
+
+using namespace std;
+
+#ifdef _UNICODE
+ #define tstring wstring
+ #define DBGetString DBGetStringW
+#else
+ #define tstring string
+ #define DBGetString DBGetStringA
+#endif
+
+enum ENDialogAction
+{
+ eDAPromptUser,
+ eDAAutomatic,
+ eDANothing
+};
+
+extern ENDialogAction enRenameAction;
+extern ENDialogAction enDeleteAction;
+
+extern int nMaxLineWidth;
+extern tstring sExportDir;
+extern tstring sDefaultFile;
+extern tstring sTimeFormat;
+extern map<tstring , string::size_type , less<tstring> > clFileTo1ColWidth;
+
+extern bool bAppendNewLine;
+extern bool bUseUtf8InNewFiles;
+extern bool bUseLessAndGreaterInExport;
+
+extern bool bReplaceHistory;
+
+tstring sGetErrorString(DWORD dwError);
+tstring sGetErrorString();
+void DisplayLastError(const _TCHAR * pszError);
+
+_TCHAR * CheckedTranslate( const _TCHAR *szEng , int nFormatCount = -1 );
+
+void SaveSettings();
+void ShowDebugInfo();
+
+int nExportEvent(WPARAM wparam,LPARAM lparam);
+int nContactDeleted(WPARAM wparam,LPARAM lparam);
+
+const _TCHAR *NickFromHandle(HANDLE hContact);
+
+tstring __inline DBGetStringW(HANDLE hContact,const char *szModule,const char *szSetting , const _TCHAR * pszError );
+string __inline DBGetStringA(HANDLE hContact,const char *szModule,const char *szSetting , const char * pszError );
+
+void ReplaceAll( tstring &sSrc , const _TCHAR * pszReplace , const tstring &sNew);
+void ReplaceAll( tstring &sSrc , const _TCHAR * pszReplace , const _TCHAR * pszNew);
+
+void UpdateFileToColWidth();
+
+bool bReadMirandaDirAndPath();
+tstring GetFilePathFromUser( HANDLE hContact );
+
+void ReplaceDefines( HANDLE hContact , tstring & sTarget );
+void ReplaceTimeVariables( tstring &sRet );
+
+bool bCreatePathToFile( tstring sFilePath );
+#ifdef _UNICODE
+bool bWriteIndentedToFile( HANDLE hFile , int nIndent , const char * pszSrc , bool bUtf8File );
+#endif
+bool bWriteIndentedToFile( HANDLE hFile , int nIndent , const _TCHAR * pszSrc , bool bUtf8File );
+bool bWriteNewLine( HANDLE hFile , DWORD dwIndent );
+bool bIsUtf8Header( BYTE * pucByteOrder );
+
+
+#endif \ No newline at end of file