summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rwxr-xr-xplugins/Msg_Export/src/FileViewer.cpp6
-rwxr-xr-xplugins/Msg_Export/src/FileViewer.h8
-rwxr-xr-xplugins/Msg_Export/src/main.cpp12
-rwxr-xr-xplugins/Msg_Export/src/options.cpp1280
-rwxr-xr-xplugins/Msg_Export/src/options.h2
-rwxr-xr-xplugins/Msg_Export/src/utils.cpp1039
-rwxr-xr-xplugins/Msg_Export/src/utils.h30
7 files changed, 1189 insertions, 1188 deletions
diff --git a/plugins/Msg_Export/src/FileViewer.cpp b/plugins/Msg_Export/src/FileViewer.cpp
index 9996f6c3a0..bd8e0cdfde 100755
--- a/plugins/Msg_Export/src/FileViewer.cpp
+++ b/plugins/Msg_Export/src/FileViewer.cpp
@@ -832,7 +832,7 @@ LRESULT CALLBACK EditSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPa
}
}
ft.chrg.cpMin = LONG(res);
- ft.chrg.cpMax = LONG(res + _tcslen(fr->lpstrFindWhat));
+ ft.chrg.cpMax = LONG(res + mir_tstrlen(fr->lpstrFindWhat));
SendMessage(hwnd, EM_EXSETSEL, 0, (LPARAM)&ft.chrg);
return 0;
}
@@ -912,7 +912,7 @@ void SetRichEditFont(HWND hRichEdit, bool bUseSyntaxHL)
ncf.dwMask = CFM_BOLD | CFM_FACE | CFM_ITALIC | CFM_SIZE | CFM_UNDERLINE;
ncf.dwEffects = db_get_dw(NULL, MODULE, szFileViewDB "TEffects", 0);
ncf.yHeight = db_get_dw(NULL, MODULE, szFileViewDB "THeight", 165);
- _tcscpy(ncf.szFaceName, _DBGetString(NULL, MODULE, szFileViewDB "TFace", _T("Courier New")).c_str());
+ mir_tstrcpy(ncf.szFaceName, _DBGetString(NULL, MODULE, szFileViewDB "TFace", _T("Courier New")).c_str());
if (!bUseSyntaxHL) {
ncf.dwMask |= CFM_COLOR;
@@ -1040,7 +1040,7 @@ static INT_PTR CALLBACK DlgProcFileViewer(HWND hwndDlg, UINT msg, WPARAM wParam,
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());
+ mir_tstrcpy(lf.lfFaceName, _DBGetString(NULL, MODULE, szFileViewDB "TFace", _T("Courier New")).c_str());
CHOOSEFONT cf = { 0 };
cf.lStructSize = sizeof(cf);
cf.hwndOwner = hwndDlg;
diff --git a/plugins/Msg_Export/src/FileViewer.h b/plugins/Msg_Export/src/FileViewer.h
index b1322ff113..e074df6843 100755
--- a/plugins/Msg_Export/src/FileViewer.h
+++ b/plugins/Msg_Export/src/FileViewer.h
@@ -19,12 +19,12 @@
#ifndef MSG_EXP_FILE_VIEWER
#define MSG_EXP_FILE_VIEWER
-void UpdateFileViews( const TCHAR *pszFile);
+void UpdateFileViews(const TCHAR *pszFile);
-bool bOpenExternaly( MCONTACT hContact);
-bool bShowFileViewer( MCONTACT hContact);
+bool bOpenExternaly(MCONTACT hContact);
+bool bShowFileViewer(MCONTACT hContact);
-bool bUseInternalViewer( bool bNew);
+bool bUseInternalViewer(bool bNew);
bool bUseInternalViewer();
extern tstring sFileViewerPrg;
diff --git a/plugins/Msg_Export/src/main.cpp b/plugins/Msg_Export/src/main.cpp
index 48914140c3..e5172f703b 100755
--- a/plugins/Msg_Export/src/main.cpp
+++ b/plugins/Msg_Export/src/main.cpp
@@ -40,7 +40,7 @@ PLUGININFOEX pluginInfo = {
__AUTHORWEB,
UNICODE_AWARE,
// {46102B07-C215-4162-9C83-D377881DA7CC}
- {0x46102b07, 0xc215, 0x4162, {0x9c, 0x83, 0xd3, 0x77, 0x88, 0x1d, 0xa7, 0xcc}}
+ { 0x46102b07, 0xc215, 0x4162, { 0x9c, 0x83, 0xd3, 0x77, 0x88, 0x1d, 0xa7, 0xcc } }
};
@@ -112,7 +112,7 @@ int MainInit(WPARAM /*wparam*/, LPARAM /*lparam*/)
HookEvent(ME_DB_CONTACT_DELETED, nContactDeleted);
HookEvent(ME_OPT_INITIALISE, OptionsInitialize);
- if ( !bReplaceHistory)
+ if (!bReplaceHistory)
{
CLISTMENUITEM mi = { sizeof(mi) };
mi.flags = 0;
@@ -123,7 +123,7 @@ int MainInit(WPARAM /*wparam*/, LPARAM /*lparam*/)
mi.pszService = MS_SHOW_EXPORT_HISTORY;
hOpenHistoryMenuItem = Menu_AddContactMenuItem(&mi);
- if ( !hOpenHistoryMenuItem)
+ if (!hOpenHistoryMenuItem)
MessageBox(NULL, TranslateT("Failed to add menu item Open Exported History\nCallService(MS_CLIST_ADDCONTACTMENUITEM,...)"), MSG_BOX_TITEL, MB_OK);
}
@@ -192,10 +192,10 @@ extern "C" __declspec(dllexport) int Load()
HookEvent(ME_SYSTEM_MODULESLOADED, MainInit);
nMaxLineWidth = db_get_w(NULL, MODULE, "MaxLineWidth", nMaxLineWidth);
- if(nMaxLineWidth < 5)
+ if (nMaxLineWidth < 5)
nMaxLineWidth = 5;
- sExportDir = _DBGetString(NULL, MODULE, "ExportDir", _T("%dbpath%\\MsgExport\\"));
+ sExportDir = _DBGetString(NULL, MODULE, "ExportDir", _T("%dbpath%\\MsgExport\\"));
sDefaultFile = _DBGetString(NULL, MODULE, "DefaultFile", _T("%nick%.txt"));
sTimeFormat = _DBGetString(NULL, MODULE, "TimeFormat", _T("d s"));
@@ -215,7 +215,7 @@ extern "C" __declspec(dllexport) int Load()
if (bReplaceHistory)
hServiceFunñ = CreateServiceFunction(MS_HISTORY_SHOWCONTACTHISTORY, ShowExportHistory); //this need new code
- if ( !hServiceFunñ)
+ if (!hServiceFunñ)
hServiceFunñ = CreateServiceFunction(MS_SHOW_EXPORT_HISTORY, ShowExportHistory);
hInternalWindowList = WindowList_Create();
diff --git a/plugins/Msg_Export/src/options.cpp b/plugins/Msg_Export/src/options.cpp
index 7a424b9df0..50b41fc0cf 100755
--- a/plugins/Msg_Export/src/options.cpp
+++ b/plugins/Msg_Export/src/options.cpp
@@ -91,19 +91,19 @@ public:
int CALLBACK CompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort)
{
- if (lParamSort == 1 )
- return _tcsicmp( NickFromHandle((MCONTACT)lParam1), NickFromHandle((MCONTACT)lParam2));
-
- if (lParamSort == 2 )
+ if (lParamSort == 1)
+ return mir_tstrcmpi(NickFromHandle((MCONTACT)lParam1), NickFromHandle((MCONTACT)lParam2));
+
+ if (lParamSort == 2)
return _DBGetString((MCONTACT)lParam1, "Protocol", "p", _T("")).compare(_DBGetString((MCONTACT)lParam2, "Protocol", "p", _T("")));
- if (lParamSort == 3 )
+ if (lParamSort == 3)
{
- DWORD dwUin1 = db_get_dw((MCONTACT)lParam1, _DBGetStringA((MCONTACT)lParam1, "Protocol", "p", "" ).c_str(), "UIN", 0);
- DWORD dwUin2 = db_get_dw((MCONTACT)lParam2, _DBGetStringA((MCONTACT)lParam2, "Protocol", "p", "" ).c_str(), "UIN", 0);
- if (dwUin1 == dwUin2 )
+ DWORD dwUin1 = db_get_dw((MCONTACT)lParam1, _DBGetStringA((MCONTACT)lParam1, "Protocol", "p", "").c_str(), "UIN", 0);
+ DWORD dwUin2 = db_get_dw((MCONTACT)lParam2, _DBGetStringA((MCONTACT)lParam2, "Protocol", "p", "").c_str(), "UIN", 0);
+ if (dwUin1 == dwUin2)
return 0;
- if (dwUin1 > dwUin2 )
+ if (dwUin1 > dwUin2)
return -1;
return 1;
}
@@ -128,19 +128,19 @@ int CALLBACK CompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort)
/////////////////////////////////////////////////////////////////////
INT_PTR CALLBACK __stdcall DialogProc(
- HWND hwndDlg, // handle to dialog box
- UINT uMsg, // message
- WPARAM /*wParam*/, // first message parameter
- LPARAM /*lParam*/ // second message parameter
-)
+ 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;
- }
+ case WM_INITDIALOG:
+ {
+ TranslateDialogDefault(hwndDlg);
+ return TRUE;
+ }
}
return FALSE;
}
@@ -159,19 +159,19 @@ INT_PTR CALLBACK __stdcall DialogProc(
// Developer : KN
/////////////////////////////////////////////////////////////////////
-int nExportCompleatList(HWND hParent, bool bOnlySelected )
+int nExportCompleatList(HWND hParent, bool bOnlySelected)
{
- HWND hMapUser = GetDlgItem( hParent, IDC_MAP_USER_LIST);
+ HWND hMapUser = GetDlgItem(hParent, IDC_MAP_USER_LIST);
- int nTotalContacts = ListView_GetItemCount( hMapUser);
+ int nTotalContacts = ListView_GetItemCount(hMapUser);
int nContacts;
- if (bOnlySelected )
- nContacts = ListView_GetSelectedCount( hMapUser);
+ if (bOnlySelected)
+ nContacts = ListView_GetSelectedCount(hMapUser);
else
nContacts = nTotalContacts;
- if (!hMapUser || nContacts <= 0 )
+ if (!hMapUser || nContacts <= 0)
{
MessageBox(hParent, TranslateT("No contacts found to export"), MSG_BOX_TITEL, MB_OK);
return 0;
@@ -182,38 +182,38 @@ int nExportCompleatList(HWND hParent, bool bOnlySelected )
HWND hStatus = GetDlgItem(hDlg, IDC_EXP_ALL_STATUS);
SendMessage(hProg, PBM_SETRANGE, 0, MAKELPARAM(0, nContacts));
-
+
SetWindowText(hStatus, TranslateT("Reading database information (Phase 1 of 2)"));
{ // position and show proigrassbar dialog
RECT rParrent;
RECT rDlg;
- if (GetWindowRect( hParent, &rParrent) && GetWindowRect( hDlg, &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);
+ 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);
+ 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++ )
+ for (int nCur = 0; nCur < nTotalContacts; nCur++)
{
- if (bOnlySelected )
- if ( !(ListView_GetItemState( hMapUser, nCur, LVIS_SELECTED) & LVIS_SELECTED))
+ if (bOnlySelected)
+ if (!(ListView_GetItemState(hMapUser, nCur, LVIS_SELECTED) & LVIS_SELECTED))
continue;
sItem.iItem = nCur;
- if(!ListView_GetItem(hMapUser, &sItem))
+ if (!ListView_GetItem(hMapUser, &sItem))
{
MessageBox(hParent, TranslateT("Failed to export at least one contact"), MSG_BOX_TITEL, MB_OK);
continue;
@@ -221,54 +221,54 @@ int nExportCompleatList(HWND hParent, bool bOnlySelected )
MCONTACT hContact = (MCONTACT)sItem.lParam;
- list<CLDBEvent> &rclCurList = AllEvents[ GetFilePathFromUser( hContact) ];
-
+ list<CLDBEvent> &rclCurList = AllEvents[GetFilePathFromUser(hContact)];
+
MEVENT hDbEvent = db_event_first(hContact);
- while( hDbEvent) {
+ while (hDbEvent) {
rclCurList.push_back(CLDBEvent(hContact, hDbEvent));
hDbEvent = db_event_next(hContact, hDbEvent);
}
- SendMessage( hProg, PBM_SETPOS, nCur, 0);
- RedrawWindow( hDlg, NULL, NULL, RDW_ALLCHILDREN | RDW_UPDATENOW);
+ SendMessage(hProg, PBM_SETPOS, nCur, 0);
+ RedrawWindow(hDlg, NULL, NULL, RDW_ALLCHILDREN | RDW_UPDATENOW);
}
-/*
- if (hContact )
- MessageBox( hParent, LPGENT("Failed to export at least one contact"),MSG_BOX_TITEL,MB_OK);
- */
+ /*
+ if (hContact )
+ MessageBox( hParent, LPGENT("Failed to export at least one contact"),MSG_BOX_TITEL,MB_OK);
+ */
}
{ // window text update
- SetWindowText( hStatus, TranslateT("Sorting and writing database information (Phase 2 of 2)"));
- SendMessage( hProg, PBM_SETRANGE, 0, MAKELPARAM( 0, AllEvents.size()));
- SendMessage( hProg, PBM_SETPOS, 0, 0);
+ SetWindowText(hStatus, TranslateT("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 )
+
+ 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 )
+ for (iterator = FileIterator->second.begin(); iterator != FileIterator->second.end(); ++iterator)
{
MEVENT hDbEvent = (*iterator).hDbEvent;
- nExportEvent( (WPARAM) (*iterator).hUser, (LPARAM)hDbEvent);
+ nExportEvent((WPARAM)(*iterator).hUser, (LPARAM)hDbEvent);
}
- SendMessage( hProg, PBM_SETPOS, ++nCur, 0);
- RedrawWindow( hDlg, NULL, NULL, RDW_ALLCHILDREN | RDW_UPDATENOW);
+ SendMessage(hProg, PBM_SETPOS, ++nCur, 0);
+ RedrawWindow(hDlg, NULL, NULL, RDW_ALLCHILDREN | RDW_UPDATENOW);
}
}
- DestroyWindow( hDlg);
+ DestroyWindow(hDlg);
return 0;
}
@@ -285,42 +285,42 @@ int nExportCompleatList(HWND hParent, bool bOnlySelected )
// Developer : KN
/////////////////////////////////////////////////////////////////////
-void SetToDefault( HWND hParent )
+void SetToDefault(HWND hParent)
{
- HWND hMapUser = GetDlgItem( hParent, IDC_MAP_USER_LIST);
+ HWND hMapUser = GetDlgItem(hParent, IDC_MAP_USER_LIST);
- int nContacts = ListView_GetItemCount( hMapUser);
+ int nContacts = ListView_GetItemCount(hMapUser);
- if (!hMapUser || nContacts <= 0 )
+ if (!hMapUser || nContacts <= 0)
{
return;
}
- TCHAR szTemp[ 500 ];
- if ( !GetDlgItemText( hParent, IDC_DEFAULT_FILE, szTemp, SIZEOF(szTemp)) )
+ TCHAR szTemp[500];
+ if (!GetDlgItemText(hParent, IDC_DEFAULT_FILE, szTemp, SIZEOF(szTemp)))
return;
-
+
LVITEM sItem = { 0 };
- for (int nCur = 0 ; nCur < nContacts ; nCur++ )
+ for (int nCur = 0; nCur < nContacts; nCur++)
{
- if ( !(ListView_GetItemState( hMapUser, nCur, LVIS_SELECTED) & LVIS_SELECTED))
+ if (!(ListView_GetItemState(hMapUser, nCur, LVIS_SELECTED) & LVIS_SELECTED))
continue;
sItem.iItem = nCur;
sItem.mask = LVIF_PARAM;
- if ( !ListView_GetItem( hMapUser, &sItem))
+ if (!ListView_GetItem(hMapUser, &sItem))
continue;
tstring sFileName = szTemp;
ReplaceDefines((MCONTACT)sItem.lParam, sFileName);
- ReplaceTimeVariables( sFileName);
+ ReplaceTimeVariables(sFileName);
sItem.mask = LVIF_TEXT;
sItem.pszText = (TCHAR*)sFileName.c_str();
- ListView_SetItem( hMapUser, &sItem);
+ ListView_SetItem(hMapUser, &sItem);
- if ( !bUnaplyedChanges )
+ if (!bUnaplyedChanges)
{
bUnaplyedChanges = TRUE;
SendMessage(GetParent(hParent), PSM_CHANGED, 0, 0);
@@ -341,14 +341,14 @@ void SetToDefault( HWND hParent )
// Developer : KN
/////////////////////////////////////////////////////////////////////
-BOOL bApplyChanges( HWND hwndDlg )
+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 )
+ if (!bTrans || nTmp < 5)
{
mir_sntprintf(szTemp, SIZEOF(szTemp), TranslateT("Max line width must be at least %d"), 5);
MessageBox(hwndDlg, szTemp, MSG_BOX_TITEL, MB_OK);
@@ -371,10 +371,10 @@ BOOL bApplyChanges( HWND hwndDlg )
GetDlgItemText(hwndDlg, IDC_FILE_VIEWER, szTemp, SIZEOF(szTemp));
sFileViewerPrg = szTemp;
- bUseInternalViewer( IsDlgButtonChecked(hwndDlg, IDC_USE_INTERNAL_VIEWER ) == BST_CHECKED);
+ bUseInternalViewer(IsDlgButtonChecked(hwndDlg, IDC_USE_INTERNAL_VIEWER) == BST_CHECKED);
bool bNewRp = IsDlgButtonChecked(hwndDlg, IDC_REPLACE_MIRANDA_HISTORY) == BST_CHECKED;
- if (bReplaceHistory != bNewRp )
+ if (bReplaceHistory != bNewRp)
{
bReplaceHistory = bNewRp;
MessageBox(hwndDlg, TranslateT("You need to restart Miranda to change the history function"), MSG_BOX_TITEL, MB_OK);
@@ -384,11 +384,11 @@ BOOL bApplyChanges( HWND hwndDlg )
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++ )
+ int nCount = ListView_GetItemCount(hMapUser);
+ for (int nCur = 0; nCur < nCount; nCur++)
{
LVITEM sItem = { 0 };
sItem.iItem = nCur;
@@ -396,25 +396,25 @@ BOOL bApplyChanges( HWND hwndDlg )
sItem.pszText = szTemp;
sItem.cchTextMax = SIZEOF(szTemp);
- if (ListView_GetItem( hMapUser, &sItem))
+ if (ListView_GetItem(hMapUser, &sItem))
{
MCONTACT hUser = (MCONTACT)sItem.lParam;
- if (_tcslen( szTemp) > 0 )
+ if (mir_tstrlen(szTemp) > 0)
db_set_ts(hUser, MODULE, "FileName", szTemp);
else
db_unset(hUser, MODULE, "FileName");
- if (sItem.iImage )
+ if (sItem.iImage)
db_unset(hUser, MODULE, "EnableLog"); // default is Enabled !!
else
- db_set_b(hUser, MODULE, "EnableLog",0);
+ db_set_b(hUser, MODULE, "EnableLog", 0);
}
}
UpdateFileToColWidth();
SaveSettings();
-
+
bUnaplyedChanges = FALSE;
return bRet;
}
@@ -439,13 +439,13 @@ void ClearAllFileNames(HWND hwndDlg)
sItem.pszText = _T("");
HWND hMapUser = GetDlgItem(hwndDlg, IDC_MAP_USER_LIST);
- int nCount = ListView_GetItemCount( hMapUser);
- for (int nCur = 0 ; nCur < nCount ; nCur++ )
+ int nCount = ListView_GetItemCount(hMapUser);
+ for (int nCur = 0; nCur < nCount; nCur++)
{
sItem.iItem = nCur;
- ListView_SetItem( hMapUser, &sItem);
+ ListView_SetItem(hMapUser, &sItem);
}
- if ( !bUnaplyedChanges )
+ if (!bUnaplyedChanges)
{
bUnaplyedChanges = TRUE;
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
@@ -467,25 +467,25 @@ void ClearAllFileNames(HWND hwndDlg)
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++ )
+ int nCount = ListView_GetItemCount(hMapUser);
+ for (int nCur = 0; nCur < nCount; nCur++)
{
- TCHAR szSearch[ 100 ];
+ 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))
+
+ if (!ListView_GetItem(hMapUser, &sItem))
{
continue;
}
@@ -493,22 +493,22 @@ void AutoFindeFileNames(HWND hwndDlg)
int nShortestMatch = 0xFFFF;
MCONTACT hStortest = 0;
int nStortestIndex = -1;
- for (int nSubCur = 0 ; nSubCur < nCount ; nSubCur++ )
+ for (int nSubCur = 0; nSubCur < nCount; nSubCur++)
{
- if (nSubCur == nCur )
+ if (nSubCur == nCur)
continue;
- TCHAR szSubCur[ 100 ];
+ 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))
+ if (ListView_GetItem(hMapUser, &sItem))
{
- size_t nLen = _tcslen( szSubCur);
- if (_tcsncicmp( szSubCur, szSearch, nLen) == 0 )
+ size_t nLen = mir_tstrlen(szSubCur);
+ if (_tcsncicmp(szSubCur, szSearch, nLen) == 0)
{
- if (nLen < (size_t)nShortestMatch )
+ if (nLen < (size_t)nShortestMatch)
{
nShortestMatch = (int)nLen;
nStortestIndex = nSubCur;
@@ -517,35 +517,35 @@ void AutoFindeFileNames(HWND hwndDlg)
}
}
}
- if (nShortestMatch != 0xFFFF )
+ if (nShortestMatch != 0xFFFF)
{
tstring sFileName;
szSearch[0] = 0;
- ListView_GetItemText( hMapUser, nCur, 0, szSearch, SIZEOF( szSearch ));
+ ListView_GetItemText(hMapUser, nCur, 0, szSearch, SIZEOF(szSearch));
bool bPriHasFileName = szSearch[0] != 0;
- if (bPriHasFileName )
+ if (bPriHasFileName)
sFileName = szSearch;
szSearch[0] = 0;
- ListView_GetItemText( hMapUser, nStortestIndex, 0, szSearch, SIZEOF( szSearch ));
+ ListView_GetItemText(hMapUser, nStortestIndex, 0, szSearch, SIZEOF(szSearch));
bool bSubHasFileName = szSearch[0] != 0;
- if (bSubHasFileName )
+ if (bSubHasFileName)
sFileName = szSearch;
if (sFileName.empty())
{
sFileName = szDefaultFile;
ReplaceDefines(hStortest, sFileName);
- ReplaceTimeVariables( sFileName);
+ ReplaceTimeVariables(sFileName);
}
- if (!bPriHasFileName )
- ListView_SetItemText( hMapUser, nCur, 0, (TCHAR*)sFileName.c_str());
+ if (!bPriHasFileName)
+ ListView_SetItemText(hMapUser, nCur, 0, (TCHAR*)sFileName.c_str());
- if (!bSubHasFileName )
- ListView_SetItemText( hMapUser, nStortestIndex, 0, (TCHAR*)sFileName.c_str());
+ if (!bSubHasFileName)
+ ListView_SetItemText(hMapUser, nStortestIndex, 0, (TCHAR*)sFileName.c_str());
- if ( !bUnaplyedChanges )
+ if (!bUnaplyedChanges)
{
bUnaplyedChanges = TRUE;
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
@@ -571,16 +571,16 @@ void AutoFindeFileNames(HWND hwndDlg)
void OpenHelp(HWND hwndDlg)
{
TCHAR szPath[MAX_PATH];
- if (GetModuleFileName( hInstance, szPath, sizeof( szPath)) )
+ if (GetModuleFileName(hInstance, szPath, SIZEOF(szPath)))
{
- size_t nLen = _tcslen( szPath);
- if (nLen > 3 )
+ size_t nLen = mir_tstrlen(szPath);
+ if (nLen > 3)
{
- szPath[nLen-1] = 't';
- szPath[nLen-2] = 'x';
- szPath[nLen-3] = 't';
+ szPath[nLen - 1] = 't';
+ szPath[nLen - 2] = 'x';
+ szPath[nLen - 3] = 't';
- SHELLEXECUTEINFO st = {0};
+ SHELLEXECUTEINFO st = { 0 };
st.cbSize = sizeof(st);
st.fMask = SEE_MASK_INVOKEIDLIST;
st.hwnd = NULL;
@@ -613,117 +613,117 @@ void OpenHelp(HWND hwndDlg)
static INT_PTR CALLBACK DlgProcMsgExportOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
-// Used to prevent sending the PSM_CHANGED to miranda
-// when initilizing
+ // Used to prevent sending the PSM_CHANGED to miranda
+ // when initilizing
static BOOL bWindowTextSet = FALSE;
switch (msg)
{
- case WM_INITDIALOG:
- {
- bWindowTextSet = FALSE;
+ case WM_INITDIALOG:
+ {
+ bWindowTextSet = FALSE;
- HWND hMapUser = GetDlgItem(hwndDlg, IDC_MAP_USER_LIST);
+ 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*/);
- }
+ { // 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;
+ }
-
- 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 = TranslateT("File");
- ListView_InsertColumn( hMapUser, 0, &cCol);
+ ListView_InsertColumn(hMapUser, 0, &cCol);
cCol.pszText = TranslateT("Nick");
- ListView_InsertColumn( hMapUser, 1, &cCol);
+ ListView_InsertColumn(hMapUser, 1, &cCol);
cCol.cx = nProtoColWitdh;
cCol.pszText = TranslateT("Proto");
- ListView_InsertColumn( hMapUser, 2, &cCol);
+ ListView_InsertColumn(hMapUser, 2, &cCol);
cCol.cx = nUINColWitdh;
cCol.mask |= LVCF_FMT;
cCol.fmt = LVCFMT_RIGHT;
cCol.pszText = TranslateT("UIN");
- ListView_InsertColumn( hMapUser, 3, &cCol);
+ 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);
+ 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 };
MCONTACT hContact = db_find_first();
- for (int nUser = 0; /*hContact*/ ; nUser++ )
+ for (int nUser = 0; /*hContact*/; nUser++)
{
sItem.mask = LVIF_TEXT | LVIF_PARAM | LVIF_IMAGE;
sItem.iItem = nUser;
sItem.iSubItem = 0;
- sItem.iImage = db_get_b(hContact,MODULE, "EnableLog", 1);
+ sItem.iImage = db_get_b(hContact, MODULE, "EnableLog", 1);
sItem.lParam = hContact;
- sTmp = _DBGetString( hContact, MODULE, "FileName", _T(""));
+ sTmp = _DBGetString(hContact, MODULE, "FileName", _T(""));
sItem.pszText = (TCHAR*)sTmp.c_str();
- ListView_InsertItem( hMapUser, &sItem);
+ ListView_InsertItem(hMapUser, &sItem);
sItem.mask = LVIF_TEXT;
sItem.iSubItem = 1;
sItem.pszText = (TCHAR*)NickFromHandle(hContact);
- ListView_SetItem( hMapUser, &sItem);
+ ListView_SetItem(hMapUser, &sItem);
sItem.iSubItem = 2;
- sTmp = _DBGetString( hContact, "Protocol", "p", _T(""));
- string sTmpA = _DBGetStringA( hContact, "Protocol", "p", "");
+ sTmp = _DBGetString(hContact, "Protocol", "p", _T(""));
+ string sTmpA = _DBGetStringA(hContact, "Protocol", "p", "");
sItem.pszText = (TCHAR*)sTmp.c_str();
- ListView_SetItem( hMapUser, &sItem);
-
+ ListView_SetItem(hMapUser, &sItem);
+
DWORD dwUIN = db_get_dw(hContact, sTmpA.c_str(), "UIN", 0);
TCHAR szTmp[50];
- mir_sntprintf(szTmp, SIZEOF(szTmp),_T("%d"), dwUIN);
+ mir_sntprintf(szTmp, SIZEOF(szTmp), _T("%d"), dwUIN);
sItem.iSubItem = 3;
sItem.pszText = szTmp;
- ListView_SetItem( hMapUser, &sItem);
+ ListView_SetItem(hMapUser, &sItem);
- if ( !hContact) // written like this to add the current user ( handle = 0 )
- break;
+ if (!hContact) // written like this to add the current user ( handle = 0 )
+ break;
hContact = db_find_next(hContact);
}
- ListView_SortItems( hMapUser, CompareFunc, 1);
+ 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);
+ sItem.stateMask = LVIS_FOCUSED;
+ ListView_SetItem(hMapUser, &sItem);
}
HWND hComboBox;
@@ -733,417 +733,417 @@ static INT_PTR CALLBACK DlgProcMsgExportOpts(HWND hwndDlg, UINT msg, WPARAM wPar
{// 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%\\"));
+ 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"));
+ 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 :"));
+ 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") );
+ 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_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:
+ }
+ case WM_COMMAND:
+ {
+ switch (LOWORD(wParam))
+ {
+ case ID_EXPORTSELECTED:
+ case IDC_EXPORTALL:
{
- switch(LOWORD(wParam))
+ if (bUnaplyedChanges)
{
- case ID_EXPORTSELECTED:
- case IDC_EXPORTALL:
- {
- if (bUnaplyedChanges )
- {
- DWORD res = MessageBox(hwndDlg, TranslateT("You have not applied the changes, do you wish to apply them 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);
+ DWORD res = MessageBox(hwndDlg, TranslateT("You have not applied the changes, do you wish to apply them first?"), MSG_BOX_TITEL, MB_YESNOCANCEL);
+ if (res == IDCANCEL)
return TRUE;
- }
- case IDC_EXPORT_DIR:
- case IDC_EXPORT_TIMEFORMAT:
- case IDC_DEFAULT_FILE:
- case IDC_FILE_VIEWER:
+ if (res == IDYES)
{
- if (!bWindowTextSet )
- return TRUE;
-
- if (HIWORD(wParam) == CBN_EDITUPDATE || HIWORD(wParam) == CBN_SELCHANGE )
+ if (!bApplyChanges(hwndDlg))
{
- 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 ),
- BST_UNCHECKED == 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:
+ }
+ 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 ),
+ BST_UNCHECKED == 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; // common dialog box structure
+ TCHAR szFile[260]; // buffer for file name
+ TCHAR buf[MAX_PATH];
+
+ GetDlgItemText(hwndDlg, IDC_FILE_VIEWER, szFile, SIZEOF(szFile));
+ // Initialize OPENFILENAME
+ memset(&ofn, 0, sizeof(OPENFILENAME));
+ ofn.lStructSize = sizeof(OPENFILENAME);
+ ofn.hwndOwner = hwndDlg;
+ ofn.lpstrFile = szFile;
+ ofn.nMaxFile = SIZEOF(szFile);
+ mir_sntprintf(buf, SIZEOF(buf), _T("%s (*.exe;*.com;*.bat;*.cmd)%c*.exe;*.com;*.bat;*.cmd%c%s (*.*)%c*.*%c%c"), TranslateT("Executable files"), 0, 0, TranslateT("All files"), 0, 0, 0);
+ ofn.lpstrFilter = buf;
+ 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, TranslateT("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, TranslateT("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 = TranslateT("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);
+ size_t n = mir_tstrlen(lpDestDir);
+ if (n > 0 && lpDestDir[n] != '\\')
{
- 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;
+ lpDestDir[n] = '\\';
+ lpDestDir[n + 1] = 0;
}
- case IDC_AUTO_FILENAME:
+ 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)
{
- AutoFindeFileNames(hwndDlg);
- return TRUE;
+ ListView_GetItemPosition(hMapUser, nFirst, &pt);
}
- case IDC_CLEAR_ALL:
- {
- ClearAllFileNames(hwndDlg);
- return TRUE;
- }
- case IDC_OPEN_HELP:
+ if (pt.y < 16)
+ pt.y = 16;
+ else
{
- OpenHelp(hwndDlg);
- return TRUE;
+ RECT rUserList;
+ GetClientRect(hMapUser, &rUserList);
+ if (pt.y > rUserList.bottom - 16)
+ pt.y = rUserList.bottom - 16;
+ else
+ pt.y += 8;
}
- case ID_SET_TO_DEFAULT:
+ 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)
{
- SetToDefault(hwndDlg);
- return TRUE;
+ pdi->item.mask &= LVIF_TEXT;
+ ListView_SetItem(p->hwndFrom, &pdi->item);
+
+ bUnaplyedChanges = TRUE;
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
}
- case IDC_FILE_VIEWER_BROWSE:
+ return TRUE;
+ }
+ case LVN_KEYDOWN:
+ {
+ NMLVKEYDOWN * lpnmk = (NMLVKEYDOWN *)lParam;
+ if (lpnmk->wVKey == 'A' && (GetKeyState(VK_CONTROL) & 0x8000))
{
- OPENFILENAME ofn; // common dialog box structure
- TCHAR szFile[260]; // buffer for file name
- TCHAR buf[MAX_PATH];
-
- GetDlgItemText(hwndDlg, IDC_FILE_VIEWER, szFile, SIZEOF(szFile));
- // Initialize OPENFILENAME
- memset(&ofn, 0, sizeof(OPENFILENAME));
- ofn.lStructSize = sizeof(OPENFILENAME);
- ofn.hwndOwner = hwndDlg;
- ofn.lpstrFile = szFile;
- ofn.nMaxFile = SIZEOF(szFile);
- mir_sntprintf(buf, SIZEOF(buf), _T("%s (*.exe;*.com;*.bat;*.cmd)%c*.exe;*.com;*.bat;*.cmd%c%s (*.*)%c*.*%c%c"), TranslateT("Executable files"), 0, 0, TranslateT("All files"), 0, 0, 0);
- ofn.lpstrFilter = buf;
- 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))
+ // select all
+ int nCount = ListView_GetItemCount(p->hwndFrom);
+ for (int nCur = 0; nCur < nCount; nCur++)
{
- SetDlgItemText(hwndDlg, IDC_FILE_VIEWER, szFile);
- bUnaplyedChanges = TRUE;
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ ListView_SetItemState(p->hwndFrom, nCur, LVIS_SELECTED, LVIS_SELECTED);
}
- // 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, TranslateT("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, TranslateT("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 = TranslateT("Select Destination Directory");
- sBrowseInfo.ulFlags = BIF_NEWDIALOGSTYLE | BIF_EDITBOX;
- sBrowseInfo.lpfn = NULL;
- sBrowseInfo.lParam = 0;
- sBrowseInfo.iImage = 0;
-
- LPITEMIDLIST psItemIDList = SHBrowseForFolder(&sBrowseInfo);
- if (psItemIDList )
+ 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)
{
- SHGetPathFromIDList(psItemIDList, lpDestDir);
- size_t 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);
+ if (isupper(lpnmk->wVKey))
+ SendMessage(hEdit, WM_CHAR, tolower(lpnmk->wVKey), 0);
+ else
+ SendMessage(hEdit, WM_CHAR, lpnmk->wVKey, 0);
}
- pMalloc->Free( lpDestDir);
- pMalloc->Release();
- return TRUE;
}
+ 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 )
+ case NM_DBLCLK:
{
- HMENU hMenu = GetSubMenu(hMainMenu,0);
-
- POINT pt;
- pt.x=(short)LOWORD(lParam);
- pt.y=(short)HIWORD(lParam);
- if (pt.x == -1 && pt.y == -1 )
+ NMITEMACTIVATE * pdi = (NMITEMACTIVATE *)lParam;
+ if (pdi->iItem >= 0)
{
- 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);
+ ListView_EditLabel(p->hwndFrom, pdi->iItem);
}
-
- 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;
}
- return TRUE;
- }
- case WM_NOTIFY:
- {
- NMHDR * p = ((LPNMHDR)lParam);
- if (p->idFrom == IDC_MAP_USER_LIST )
+ case NM_CUSTOMDRAW:
{
- switch (p->code)
+ LPNMLVCUSTOMDRAW lplvcd = (LPNMLVCUSTOMDRAW)lParam;
+ switch (lplvcd->nmcd.dwDrawStage)
{
- 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:
+ case CDDS_PREPAINT:
+ {
+ SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, CDRF_NOTIFYITEMDRAW);
+ return true;
+ }
+ case CDDS_ITEMPREPAINT:
+ {
+ if (lplvcd->nmcd.lItemlParam == 0)
{
- LPNMLVCUSTOMDRAW lplvcd = (LPNMLVCUSTOMDRAW)lParam;
- switch(lplvcd->nmcd.dwDrawStage)
- {
- case CDDS_PREPAINT:
- {
- SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, CDRF_NOTIFYITEMDRAW);
- return true;
- }
- case CDDS_ITEMPREPAINT:
- {
- if (lplvcd->nmcd.lItemlParam == 0 )
- {
- lplvcd->clrText = RGB( 0, 0, 255);
- }
- SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, CDRF_NEWFONT);
- return true;
- }
- }
- return FALSE;
+ lplvcd->clrText = RGB(0, 0, 255);
}
+ SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, CDRF_NEWFONT);
+ return true;
+ }
}
+ return FALSE;
}
- else
+ }
+ }
+ else
+ {
+ switch (p->code)
{
- switch (p->code)
+ case PSN_APPLY:
+ {
+ bApplyChanges(hwndDlg);
+ return TRUE;
+ }
+ case HDN_ITEMCLICK:
+ {
+ NMHEADER * phdr = (LPNMHEADER)p;
+ if (phdr->iButton == 0)// 0 => Left button
{
- 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;
- }
+ HWND hMapUser = GetDlgItem(hwndDlg, IDC_MAP_USER_LIST);
+ ListView_SortItems(hMapUser, CompareFunc, phdr->iItem);
+ return TRUE;
}
+ return FALSE;
+ }
}
- break;
}
+ break;
+ }
}
return FALSE;
}
@@ -1161,28 +1161,28 @@ static INT_PTR CALLBACK DlgProcMsgExportOpts(HWND hwndDlg, UINT msg, WPARAM wPar
// Developer : KN
/////////////////////////////////////////////////////////////////////
-BOOL bApplyChanges2( HWND hwndDlg )
+BOOL bApplyChanges2(HWND hwndDlg)
{
- if (IsDlgButtonChecked(hwndDlg, IDC_FC_PROMPT) == BST_CHECKED )
+ if (IsDlgButtonChecked(hwndDlg, IDC_FC_PROMPT) == BST_CHECKED)
enRenameAction = eDAPromptUser;
- else if (IsDlgButtonChecked(hwndDlg, IDC_FC_RENAME) == BST_CHECKED )
+ else if (IsDlgButtonChecked(hwndDlg, IDC_FC_RENAME) == BST_CHECKED)
enRenameAction = eDAAutomatic;
- else if (IsDlgButtonChecked(hwndDlg, IDC_FC_NOTHING) == BST_CHECKED )
+ else if (IsDlgButtonChecked(hwndDlg, IDC_FC_NOTHING) == BST_CHECKED)
enRenameAction = eDANothing;
- if (IsDlgButtonChecked(hwndDlg, IDC_FD_PROMPT) == BST_CHECKED )
+ if (IsDlgButtonChecked(hwndDlg, IDC_FD_PROMPT) == BST_CHECKED)
enDeleteAction = eDAPromptUser;
- else if (IsDlgButtonChecked(hwndDlg, IDC_FD_DELETE) == BST_CHECKED )
+ else if (IsDlgButtonChecked(hwndDlg, IDC_FD_DELETE) == BST_CHECKED)
enDeleteAction = eDAAutomatic;
- else if (IsDlgButtonChecked(hwndDlg, IDC_FD_NOTHING) == BST_CHECKED )
+ else if (IsDlgButtonChecked(hwndDlg, IDC_FD_NOTHING) == BST_CHECKED)
enDeleteAction = eDANothing;
- char szTemp[ 500 ];
- strcpy( szTemp, "DisableProt_");
+ char szTemp[500];
+ mir_strcpy(szTemp, "DisableProt_");
HWND hMapUser = GetDlgItem(hwndDlg, IDC_EXPORT_PROTOS);
- int nCount = ListView_GetItemCount( hMapUser);
- for (int nCur = 0 ; nCur < nCount ; nCur++ )
+ int nCount = ListView_GetItemCount(hMapUser);
+ for (int nCur = 0; nCur < nCount; nCur++)
{
LVITEMA sItem = { 0 };
sItem.iItem = nCur;
@@ -1191,10 +1191,10 @@ BOOL bApplyChanges2( HWND hwndDlg )
sItem.cchTextMax = (SIZEOF(szTemp) - 15);
if (::SendMessage(hMapUser, LVM_GETITEMA, 0, (LPARAM)&sItem))
{
- if (sItem.iImage )
+ if (sItem.iImage)
db_unset(NULL, MODULE, szTemp); // default is Enabled !!
else
- db_set_b(NULL, MODULE, szTemp,0);
+ db_set_b(NULL, MODULE, szTemp, 0);
}
}
SaveSettings();
@@ -1223,81 +1223,81 @@ static INT_PTR CALLBACK DlgProcMsgExportOpts2(HWND hwndDlg, UINT msg, WPARAM wPa
switch (msg)
{
- case WM_INITDIALOG:
+ case WM_INITDIALOG:
+ {
+ bWindowTextSet = FALSE;
+ switch (enRenameAction)
{
- bWindowTextSet = FALSE;
- switch( enRenameAction )
- {
- case eDAPromptUser:
- CheckDlgButton(hwndDlg, IDC_FC_PROMPT, BST_CHECKED);
- break;
- case eDAAutomatic:
- CheckDlgButton(hwndDlg, IDC_FC_RENAME, BST_CHECKED);
- break;
- case eDANothing:
- CheckDlgButton(hwndDlg, IDC_FC_NOTHING, BST_CHECKED);
- break;
- }
- switch( enDeleteAction )
- {
- case eDAPromptUser:
- CheckDlgButton(hwndDlg, IDC_FD_PROMPT, BST_CHECKED);
- break;
- case eDAAutomatic:
- CheckDlgButton(hwndDlg, IDC_FD_DELETE, BST_CHECKED);
- break;
- case eDANothing:
- CheckDlgButton(hwndDlg, IDC_FD_NOTHING, BST_CHECKED);
- 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;
- }
+ case eDAPromptUser:
+ CheckDlgButton(hwndDlg, IDC_FC_PROMPT, BST_CHECKED);
+ break;
+ case eDAAutomatic:
+ CheckDlgButton(hwndDlg, IDC_FC_RENAME, BST_CHECKED);
+ break;
+ case eDANothing:
+ CheckDlgButton(hwndDlg, IDC_FC_NOTHING, BST_CHECKED);
+ break;
+ }
+ switch (enDeleteAction)
+ {
+ case eDAPromptUser:
+ CheckDlgButton(hwndDlg, IDC_FD_PROMPT, BST_CHECKED);
+ break;
+ case eDAAutomatic:
+ CheckDlgButton(hwndDlg, IDC_FD_DELETE, BST_CHECKED);
+ break;
+ case eDANothing:
+ CheckDlgButton(hwndDlg, IDC_FD_NOTHING, BST_CHECKED);
+ 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 = TranslateT("Export Protocols");
- ListView_InsertColumn( hMapUser, 0, &cCol);
+ 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);
- }
-
- {
+ 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);
+ }
+
+ {
PROTOACCOUNT **proto;
int nCount;
LVITEMA sItem = { 0 };
sItem.mask = LVIF_TEXT | LVIF_IMAGE;
- char szTemp[ 500 ];
+ char szTemp[500];
ProtoEnumAccounts(&nCount, &proto);
- for (int i=0 ; i < nCount ; i++)
+ for (int i = 0; i < nCount; i++)
{
mir_snprintf(szTemp, SIZEOF(szTemp), "DisableProt_%s", proto[i]->szModuleName);
sItem.pszText = proto[i]->szModuleName;
- sItem.iImage = db_get_b(NULL,MODULE,szTemp,1);
- ::SendMessage( hMapUser, LVM_INSERTITEMA, 0,(LPARAM)&sItem);
+ sItem.iImage = db_get_b(NULL, MODULE, szTemp, 1);
+ ::SendMessage(hMapUser, LVM_INSERTITEMA, 0, (LPARAM)&sItem);
sItem.iItem++;
}
}
@@ -1306,78 +1306,78 @@ static INT_PTR CALLBACK DlgProcMsgExportOpts2(HWND hwndDlg, UINT msg, WPARAM wPa
bWindowTextSet = TRUE;
return TRUE;
- }
- case WM_COMMAND:
+ }
+ case WM_COMMAND:
+ {
+ switch (LOWORD(wParam))
{
- 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;
+ 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;
- }
+ if (HIWORD(wParam) == BN_CLICKED)
+ {
+ bUnaplyedChanges = TRUE;
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
}
- break;
+ return TRUE;
}
- case WM_NOTIFY:
+ case IDC_DEBUG_INFO:
{
- NMHDR * p = ((LPNMHDR)lParam);
- if (p->idFrom == IDC_EXPORT_PROTOS )
+ ShowDebugInfo();
+ return TRUE;
+ }
+ }
+ break;
+ }
+ case WM_NOTIFY:
+ {
+ NMHDR * p = ((LPNMHDR)lParam);
+ if (p->idFrom == IDC_EXPORT_PROTOS)
+ {
+ switch (p->code)
{
- 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 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;
}
- switch (p->code)
- {
- case PSN_APPLY:
- {
- bApplyChanges2(hwndDlg);
- return TRUE;
- }
- case HDN_ITEMCLICK:
- {
- return FALSE;
- }
}
break;
}
+ switch (p->code)
+ {
+ case PSN_APPLY:
+ {
+ bApplyChanges2(hwndDlg);
+ return TRUE;
+ }
+ case HDN_ITEMCLICK:
+ {
+ return FALSE;
+ }
+ }
+ break;
+ }
}
//
return FALSE;
@@ -1398,7 +1398,7 @@ static INT_PTR CALLBACK DlgProcMsgExportOpts2(HWND hwndDlg, UINT msg, WPARAM wPa
// Developer : KN
/////////////////////////////////////////////////////////////////////
-int OptionsInitialize(WPARAM wParam,LPARAM /*lParam*/)
+int OptionsInitialize(WPARAM wParam, LPARAM /*lParam*/)
{
bUnaplyedChanges = FALSE;
@@ -1406,14 +1406,14 @@ int OptionsInitialize(WPARAM wParam,LPARAM /*lParam*/)
odp.position = 100000000;
odp.hInstance = hInstance;
odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_MSGEXPORT);
- odp.flags = ODPF_BOLDGROUPS|ODPF_TCHAR;
+ odp.flags = ODPF_BOLDGROUPS | ODPF_TCHAR;
odp.ptszTitle = LPGENT("Message export");
odp.ptszGroup = LPGENT("History");
odp.ptszTab = LPGENT("General");
odp.groupPosition = 100000000;
odp.pfnDlgProc = DlgProcMsgExportOpts;
Options_AddPage(wParam, &odp);
-
+
odp.position = 100000001;
odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_MSGEXPORT2);
odp.ptszTab = LPGENT("Additional");
diff --git a/plugins/Msg_Export/src/options.h b/plugins/Msg_Export/src/options.h
index d8fb7afdb6..e0de020b0f 100755
--- a/plugins/Msg_Export/src/options.h
+++ b/plugins/Msg_Export/src/options.h
@@ -20,7 +20,7 @@
#ifndef MSG_EXP_OPTIONS_H
#define MSG_EXP_OPTIONS_H
-int OptionsInitialize( WPARAM, LPARAM);
+int OptionsInitialize(WPARAM, LPARAM);
int nExportCompleatList(HWND hParent, bool bOnlySelected);
#endif \ No newline at end of file
diff --git a/plugins/Msg_Export/src/utils.cpp b/plugins/Msg_Export/src/utils.cpp
index 3adbec1191..b3a012d1c3 100755
--- a/plugins/Msg_Export/src/utils.cpp
+++ b/plugins/Msg_Export/src/utils.cpp
@@ -19,8 +19,8 @@
#include "Glob.h"
// Default error string used upon errors
-const TCHAR *pszNickError = LPGENT("No_Nick");
-const TCHAR *pszGroupError = LPGENT("No_Group");
+const TCHAR *pszNickError = LPGENT("No_Nick");
+const TCHAR *pszGroupError = LPGENT("No_Group");
const TCHAR *pszDbPathError = _T(".");
// Replacement for chareteres not alowed in file names.
@@ -50,20 +50,20 @@ 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 TCHAR *pszReplaceList[] =
+{
+ _T("%FirstName%"),
+ _T("%LastName%"),
+ _T("%e-mail%"),
+ _T("%Nick%"),
+ _T("%City%"),
+ _T("%State%"),
+ _T("%Phone%"),
+ _T("%Homepage%"),
+ _T("%About%")
};
-const char *pszReplaceListA[] =
-{
+const char *pszReplaceListA[] =
+{
"FirstName",
"LastName",
"e-mail",
@@ -91,9 +91,9 @@ bool bAppendNewLine = true;
bool bUseUtf8InNewFiles = true;
const char szUtf8ByteOrderHeader[] = "\xEF\xBB\xBF";
-bool bIsUtf8Header( BYTE * pucByteOrder )
-{
- return memcmp( pucByteOrder, szUtf8ByteOrderHeader, 3) == 0;
+bool bIsUtf8Header(BYTE * pucByteOrder)
+{
+ return memcmp(pucByteOrder, szUtf8ByteOrderHeader, 3) == 0;
}
/////////////////////////////////////////////////////////////////////
@@ -138,15 +138,15 @@ void ShowDebugInfo()
// Developer : KN
/////////////////////////////////////////////////////////////////////
-int nGetFormatCount( const TCHAR *pszToCheck )
+int nGetFormatCount(const TCHAR *pszToCheck)
{
- if (!pszToCheck || pszToCheck[0] == 0 )
+ if (!pszToCheck || pszToCheck[0] == 0)
return 0;
int nCount = 0;
- for (; pszToCheck[1] != 0 ; pszToCheck++)
+ for (; pszToCheck[1] != 0; pszToCheck++)
{
- if (pszToCheck[0] == '%' && pszToCheck[1] != '%' )
+ if (pszToCheck[0] == '%' && pszToCheck[1] != '%')
nCount++;
}
return nCount;
@@ -166,25 +166,25 @@ int nGetFormatCount( const TCHAR *pszToCheck )
// Developer : KN
/////////////////////////////////////////////////////////////////////
/*
-TCHAR *CheckedTranslate( const TCHAR *szEng, int nFormatCount )//= -1
+TCHAR *CheckedTranslate( const TCHAR *szEng, int nFormatCount )//= -1
{
- TCHAR *szRet = TranslateTS( szEng);
- if (szEng == szRet )
- return (TCHAR*)szEng;
+TCHAR *szRet = TranslateTS( szEng);
+if (szEng == szRet )
+return (TCHAR*)szEng;
- if (nFormatCount == -1 )
- nFormatCount = nGetFormatCount( 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;
+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;
}
*/
/////////////////////////////////////////////////////////////////////
@@ -202,31 +202,31 @@ TCHAR *CheckedTranslate( const TCHAR *szEng, int nFormatCount )//= -1
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;
+ 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());
+{
+ return sGetErrorString(GetLastError());
}
void DisplayLastError(const TCHAR *pszError)
@@ -258,7 +258,7 @@ void DisplayLastError(const TCHAR *pszError)
const TCHAR* NickFromHandle(MCONTACT hContact)
{
const TCHAR *psz = (const TCHAR *)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, hContact, GCDNF_TCHAR);
- if (psz )
+ if (psz)
return psz;
return pszNickError;
}
@@ -279,12 +279,12 @@ const TCHAR* NickFromHandle(MCONTACT hContact)
// Developer : KN
/////////////////////////////////////////////////////////////////////
-tstring _DBGetStringW(MCONTACT hContact,const char *szModule,const char *szSetting, const TCHAR *pszError )
+tstring _DBGetStringW(MCONTACT hContact, const char *szModule, const char *szSetting, const TCHAR *pszError)
{
tstring ret;
- DBVARIANT dbv = {0};
+ DBVARIANT dbv = { 0 };
//db_get
- if ( !db_get_ws( hContact, szModule, szSetting, &dbv))
+ if (!db_get_ws(hContact, szModule, szSetting, &dbv))
{
if (dbv.type != DBVT_WCHAR)
{
@@ -302,11 +302,11 @@ tstring _DBGetStringW(MCONTACT hContact,const char *szModule,const char *szSetti
return ret;
}
-string _DBGetStringA(MCONTACT hContact,const char *szModule,const char *szSetting, const char *pszError )
+string _DBGetStringA(MCONTACT hContact, const char *szModule, const char *szSetting, const char *pszError)
{
string ret;
- DBVARIANT dbv = {0};
- if ( !db_get( hContact, szModule, szSetting, &dbv))
+ DBVARIANT dbv = { 0 };
+ if (!db_get(hContact, szModule, szSetting, &dbv))
{
if (dbv.type != DBVT_ASCIIZ)
{
@@ -339,20 +339,20 @@ string _DBGetStringA(MCONTACT hContact,const char *szModule,const char *szSettin
// Developer : KN
/////////////////////////////////////////////////////////////////////
-void ReplaceAll( tstring &sSrc, const TCHAR *pszReplace, const tstring &sNew)
+void ReplaceAll(tstring &sSrc, const TCHAR *pszReplace, const tstring &sNew)
{
string::size_type nCur = 0;
- while( (nCur = sSrc.find(pszReplace,nCur)) != sSrc.npos )
+ while ((nCur = sSrc.find(pszReplace, nCur)) != sSrc.npos)
{
- sSrc.replace( nCur, _tcslen( pszReplace ), sNew);
+ sSrc.replace(nCur, mir_tstrlen(pszReplace), sNew);
nCur += sNew.size();
}
}
-void ReplaceAll( tstring &sSrc, const TCHAR *pszReplace, const TCHAR *pszNew)
+void ReplaceAll(tstring &sSrc, const TCHAR *pszReplace, const TCHAR *pszNew)
{
tstring sNew = pszNew;
- ReplaceAll( sSrc, pszReplace, sNew);
+ ReplaceAll(sSrc, pszReplace, sNew);
}
@@ -369,31 +369,31 @@ void ReplaceAll( tstring &sSrc, const TCHAR *pszReplace, const TCHAR *pszNew)
// Developer : KN
/////////////////////////////////////////////////////////////////////
-bool bCreatePathToFile( tstring sFilePath )
+bool bCreatePathToFile(tstring sFilePath)
{
- string::size_type nPos = sFilePath.rfind( '\\');
- if ( nPos != string::npos )
+ string::size_type nPos = sFilePath.rfind('\\');
+ if (nPos != string::npos)
{
if (nPos + 1 < sFilePath.size())
- sFilePath.erase( nPos + 1);
+ sFilePath.erase(nPos + 1);
}
else
{
// cant find \
return false;
}
-
+
// create directory
- if ( !CreateDirectory( sFilePath.c_str(), NULL))
+ 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)) )
+ if (!bCreatePathToFile(sFilePath.substr(0, nPos)))
return false;
// try again
- if ( !CreateDirectory( sFilePath.c_str(), NULL))
+ if (!CreateDirectory(sFilePath.c_str(), NULL))
{
return false;
}
@@ -419,10 +419,10 @@ bool bCreatePathToFile( tstring sFilePath )
bool bWriteToFile(HANDLE hFile, const char *pszSrc, int nLen = -1)
{
if (nLen < 0)
- nLen = (int)strlen(pszSrc);
+ nLen = (int)mir_strlen(pszSrc);
DWORD dwBytesWritten;
- return WriteFile( hFile, pszSrc, nLen, &dwBytesWritten, NULL) && (dwBytesWritten == (DWORD)nLen);
+ return WriteFile(hFile, pszSrc, nLen, &dwBytesWritten, NULL) && (dwBytesWritten == (DWORD)nLen);
}
@@ -444,36 +444,36 @@ bool bWriteToFile(HANDLE hFile, const char *pszSrc, int nLen = -1)
static bool bWriteTextToFile(HANDLE hFile, const TCHAR *pszSrc, bool bUtf8File, int nLen = -1)
{
if (nLen != -1) {
- TCHAR *tmp = (TCHAR*)alloca(sizeof(TCHAR)*(nLen+1));
- _tcsncpy(tmp, pszSrc, nLen);
+ TCHAR *tmp = (TCHAR*)alloca(sizeof(TCHAR)*(nLen + 1));
+ mir_tstrncpy(tmp, pszSrc, nLen);
tmp[nLen] = 0;
pszSrc = tmp;
}
- if ( !bUtf8File) {
+ if (!bUtf8File) {
// We need to downgrade text to ansi
- ptrA pszAstr( mir_t2a(pszSrc));
+ ptrA pszAstr(mir_t2a(pszSrc));
return bWriteToFile(hFile, pszAstr, -1);
}
-
- ptrA pszUtf8( mir_utf8encodeT(pszSrc));
+
+ ptrA pszUtf8(mir_utf8encodeT(pszSrc));
return bWriteToFile(hFile, pszUtf8, -1);
}
-static bool bWriteTextToFile( HANDLE hFile, const char *pszSrc, bool bUtf8File, int nLen = -1)
+static bool bWriteTextToFile(HANDLE hFile, const char *pszSrc, bool bUtf8File, int nLen = -1)
{
- if ( !bUtf8File)
+ if (!bUtf8File)
return bWriteToFile(hFile, pszSrc, nLen);
if (nLen != -1) {
- char *tmp = (char*)alloca(nLen+1);
- strncpy(tmp, pszSrc, nLen);
+ char *tmp = (char*)alloca(nLen + 1);
+ mir_strncpy(tmp, pszSrc, nLen);
tmp[nLen] = 0;
pszSrc = tmp;
}
- ptrA pszUtf8( mir_utf8encode(pszSrc));
+ ptrA pszUtf8(mir_utf8encode(pszSrc));
return bWriteToFile(hFile, pszUtf8, -1);
}
@@ -492,11 +492,11 @@ static bool bWriteTextToFile( HANDLE hFile, const char *pszSrc, bool bUtf8File,
/////////////////////////////////////////////////////////////////////
const char szNewLineIndent[] = "\r\n ";
-bool bWriteNewLine( HANDLE hFile, DWORD dwIndent )
+bool bWriteNewLine(HANDLE hFile, DWORD dwIndent)
{
- if (dwIndent > sizeof( szNewLineIndent) - 2 )
- dwIndent = sizeof( szNewLineIndent) - 2;
- return bWriteToFile( hFile, szNewLineIndent, dwIndent + 2);
+ if (dwIndent > sizeof(szNewLineIndent) - 2)
+ dwIndent = sizeof(szNewLineIndent) - 2;
+ return bWriteToFile(hFile, szNewLineIndent, dwIndent + 2);
}
/////////////////////////////////////////////////////////////////////
@@ -514,14 +514,14 @@ bool bWriteNewLine( HANDLE hFile, DWORD dwIndent )
// Developer : KN
/////////////////////////////////////////////////////////////////////
-bool bWriteHexToFile( HANDLE hFile, void * pData, int nSize )
+bool bWriteHexToFile(HANDLE hFile, void * pData, int nSize)
{
char cBuf[10];
BYTE * p = (BYTE*)pData;
- for (int n = 0 ; n < nSize ; n++ )
+ for (int n = 0; n < nSize; n++)
{
mir_snprintf(cBuf, SIZEOF(cBuf), "%.2X ", p[n]);
- if ( !bWriteToFile( hFile, cBuf, 3))
+ if (!bWriteToFile(hFile, cBuf, 3))
return false;
}
return true;
@@ -543,15 +543,15 @@ bool bWriteHexToFile( HANDLE hFile, void * pData, int nSize )
bool bReadMirandaDirAndPath()
{
TCHAR szDBPath[MAX_PATH], tmp[MAX_PATH];
- _tcscpy(szDBPath, pszDbPathError);
- PathToAbsoluteT( _T("miranda32.exe"), tmp);
+ mir_tstrcpy(szDBPath, pszDbPathError);
+ PathToAbsoluteT(_T("miranda32.exe"), tmp);
sMirandaPath = tmp;
sMirandaPath.erase(sMirandaPath.find_last_of(_T("\\")));
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);
+ sDBPath.erase(sDBPath.size() - 4);
return true;
}
@@ -568,12 +568,12 @@ bool bReadMirandaDirAndPath()
// Developer : KN
/////////////////////////////////////////////////////////////////////
-void ReplaceDBPath( tstring &sRet )
+void ReplaceDBPath(tstring &sRet)
{
- ReplaceAll( sRet, _T("%dbpath%"), sDBPath);
+ 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] == '\\')))
+ if (sRet.size() <= 2 || !(sRet[1] == ':' ||
+ (sRet[0] == '\\' && sRet[1] == '\\')))
{
// Relative path
// we will prepend the mirande exe path to avoid problems
@@ -596,30 +596,30 @@ void ReplaceDBPath( tstring &sRet )
// Developer : KN
/////////////////////////////////////////////////////////////////////
-tstring GetFilePathFromUser( MCONTACT hContact )
+tstring GetFilePathFromUser(MCONTACT hContact)
{
- tstring sFilePath = sExportDir + _DBGetString( hContact, MODULE, "FileName", sDefaultFile.c_str());
+ tstring sFilePath = sExportDir + _DBGetString(hContact, MODULE, "FileName", sDefaultFile.c_str());
- bool bNickUsed = sFilePath.find( _T("%nick%")) != string::npos;
+ bool bNickUsed = sFilePath.find(_T("%nick%")) != string::npos;
- ReplaceDefines( hContact, sFilePath);
+ ReplaceDefines(hContact, sFilePath);
tstring sNoDBPath = sFilePath;
- ReplaceTimeVariables( sFilePath);
- ReplaceDBPath( 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 )
+ // Previous file name check to see if it has changed !!
+ tstring sPrevFileName = _DBGetString(hContact, MODULE, "PrevFileName", _T(""));
+ if (sNoDBPath != sPrevFileName)
{
- if ( !sPrevFileName.empty())
+ if (!sPrevFileName.empty())
{
- ReplaceDBPath( sPrevFileName);
+ 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 ),LPGENT("(Unknown Contact)")) != 0))
+ if (bNickUsed && (_tcsstr(NickFromHandle(hContact), LPGENT("(Unknown Contact)")) != 0))
{
// Then the filename must have changed from a correct path to one including the (Unknown Contact)
return sPrevFileName;
@@ -627,32 +627,32 @@ tstring GetFilePathFromUser( MCONTACT hContact )
// file name has changed
- if (enRenameAction != eDANothing )
+ 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,
+ HANDLE hPrevFile = CreateFile(sPrevFileName.c_str(),
+ GENERIC_READ,
FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL,
OPEN_EXISTING,
- FILE_ATTRIBUTE_NORMAL,
+ FILE_ATTRIBUTE_NORMAL,
NULL);
- if (hPrevFile != INVALID_HANDLE_VALUE )
+ if (hPrevFile != INVALID_HANDLE_VALUE)
{
- CloseHandle( hPrevFile);
+ CloseHandle(hPrevFile);
TCHAR szTemp[500];
// There is a previous file we can move
// ask user ?
bool bTryRename;
- if (enRenameAction != eDAAutomatic )
+ if (enRenameAction != eDAAutomatic)
{
tstring sRemoteUser = NickFromHandle(hContact);
- mir_sntprintf(szTemp, SIZEOF(szTemp),
- TranslateT("File name for the user \"%s\" has changed!\n\nfrom:\t%s\nto:\t%s\n\nDo you wish to rename file?"),
+ mir_sntprintf(szTemp, SIZEOF(szTemp),
+ TranslateT("File name for the user \"%s\" has changed!\n\nfrom:\t%s\nto:\t%s\n\nDo you wish to rename file?"),
sRemoteUser.c_str(),
sPrevFileName.c_str(),
sFilePath.c_str());
@@ -660,20 +660,20 @@ tstring GetFilePathFromUser( MCONTACT hContact )
}
else
bTryRename = true;
-
-
- if (bTryRename )
+
+
+ if (bTryRename)
{
- if ( !MoveFile( sPrevFileName.c_str(), sFilePath.c_str()))
+ 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);
+ bCreatePathToFile(sFilePath);
- while( ! MoveFile( sPrevFileName.c_str(), sFilePath.c_str()))
+ while (!MoveFile(sPrevFileName.c_str(), sFilePath.c_str()))
{
- mir_sntprintf(szTemp, SIZEOF(szTemp),
- TranslateT("Failed to rename file\n\nfrom:\t%s\nto:\t%s\n\nFailed with error: %s"),
+ mir_sntprintf(szTemp, SIZEOF(szTemp),
+ TranslateT("Failed to rename file\n\nfrom:\t%s\nto:\t%s\n\nFailed with error: %s"),
sPrevFileName.c_str(),
sFilePath.c_str(),
sGetErrorString().c_str());
@@ -688,7 +688,7 @@ tstring GetFilePathFromUser( MCONTACT hContact )
}
// Store the Filename used so that we can check if it changes.
- db_set_ts( hContact, MODULE, "PrevFileName", sNoDBPath.c_str());
+ db_set_ts(hContact, MODULE, "PrevFileName", sNoDBPath.c_str());
}
return sFilePath;
@@ -707,11 +707,11 @@ tstring GetFilePathFromUser( MCONTACT hContact )
// Developer : KN
/////////////////////////////////////////////////////////////////////
-tstring FileNickFromHandle( MCONTACT hContact)
+tstring FileNickFromHandle(MCONTACT hContact)
{
- tstring ret = NickFromHandle( hContact);
+ tstring ret = NickFromHandle(hContact);
string::size_type nCur = 0;
- while( (nCur = ret.find_first_of(_T(":\\"),nCur)) != ret.npos )
+ while ((nCur = ret.find_first_of(_T(":\\"), nCur)) != ret.npos)
ret[nCur] = cBadCharReplace;
return ret;
}
@@ -732,12 +732,12 @@ tstring FileNickFromHandle( MCONTACT hContact)
// Developer : KN
/////////////////////////////////////////////////////////////////////
-void ReplaceAllNoColon( tstring &sSrc, const TCHAR *pszReplace, tstring &sNew)
+void ReplaceAllNoColon(tstring &sSrc, const TCHAR *pszReplace, tstring &sNew)
{
tstring::size_type nCur = 0;
- while( (nCur = sNew.find_first_of(_T(':'),nCur)) != sNew.npos )
+ while ((nCur = sNew.find_first_of(_T(':'), nCur)) != sNew.npos)
sNew[nCur] = cBadCharReplace;
- ReplaceAll( sSrc, pszReplace, sNew);
+ ReplaceAll(sSrc, pszReplace, sNew);
}
/////////////////////////////////////////////////////////////////////
@@ -754,26 +754,26 @@ void ReplaceAllNoColon( tstring &sSrc, const TCHAR *pszReplace, tstring &sNew)
// Developer : KN
/////////////////////////////////////////////////////////////////////
-void ReplaceDefines( MCONTACT hContact, tstring & sTarget )
+void ReplaceDefines(MCONTACT hContact, tstring & sTarget)
{
- if (sTarget.find( _T("%nick%")) != string::npos )
+ if (sTarget.find(_T("%nick%")) != string::npos)
{
- ReplaceAll( sTarget, _T("%nick%"), FileNickFromHandle( hContact));
+ 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;
+ 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 )
+ if (bUINUsed || bEMailUsed || bProtoUsed || bIdentifierUsed)
{
- string sProto = _DBGetStringA( hContact, "Protocol", "p", "");
- if (bUINUsed || ( bIdentifierUsed && sProto == "ICQ"))
+ string sProto = _DBGetStringA(hContact, "Protocol", "p", "");
+ if (bUINUsed || (bIdentifierUsed && sProto == "ICQ"))
{
DWORD dwUIN = db_get_dw(hContact, sProto.c_str(), "UIN", 0);
tstring sReplaceUin;
- if (dwUIN )
+ if (dwUIN)
{
TCHAR sTmp[20];
mir_sntprintf(sTmp, SIZEOF(sTmp), _T("%d"), dwUIN);
@@ -781,70 +781,70 @@ void ReplaceDefines( MCONTACT hContact, tstring & sTarget )
}
else
{
- sReplaceUin = FileNickFromHandle( hContact);
+ sReplaceUin = FileNickFromHandle(hContact);
}
- if (bUINUsed )
- ReplaceAll( sTarget, _T("%UIN%"), sReplaceUin);
- if (bIdentifierUsed && sProto == "ICQ" )
+ if (bUINUsed)
+ ReplaceAll(sTarget, _T("%UIN%"), sReplaceUin);
+ if (bIdentifierUsed && sProto == "ICQ")
{
bIdentifierUsed = false;
- ReplaceAll( sTarget, _T("%identifier%"), sReplaceUin);
+ ReplaceAll(sTarget, _T("%identifier%"), sReplaceUin);
}
}
- if (bEMailUsed || ( bIdentifierUsed && sProto == "MSN"))
+ if (bEMailUsed || (bIdentifierUsed && sProto == "MSN"))
{
- tstring sEMail = _DBGetString( hContact, sProto.c_str(), "e-mail", _T(""));
+ tstring sEMail = _DBGetString(hContact, sProto.c_str(), "e-mail", _T(""));
if (sEMail.empty())
{
- sEMail = _DBGetString( hContact, "MSN", "e-mail", _T(""));
+ 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);
+ sEMail = FileNickFromHandle(hContact);
}
}
- if (bEMailUsed )
- ReplaceAllNoColon( sTarget, _T("%e-mail%"), sEMail);
+ if (bEMailUsed)
+ ReplaceAllNoColon(sTarget, _T("%e-mail%"), sEMail);
if (bIdentifierUsed && sProto == "MSN")
{
bIdentifierUsed = false;
- ReplaceAllNoColon( sTarget, _T("%identifier%"), sEMail);
+ ReplaceAllNoColon(sTarget, _T("%identifier%"), sEMail);
}
}
- if (bIdentifierUsed && sProto == "Jabber" )
+ if (bIdentifierUsed && sProto == "Jabber")
{
- tstring sReplace = _DBGetString( hContact, "Jabber", "jid", _T(""));
+ tstring sReplace = _DBGetString(hContact, "Jabber", "jid", _T(""));
if (sReplace.empty())
{
- sReplace = FileNickFromHandle( hContact);
+ sReplace = FileNickFromHandle(hContact);
}
bIdentifierUsed = false;
- ReplaceAll( sTarget, _T("%identifier%"), sReplace);
+ ReplaceAll(sTarget, _T("%identifier%"), sReplace);
}
- if (bProtoUsed )
+ if (bProtoUsed)
{
- tstring tmp = _DBGetString( hContact, "Protocol", "p", _T(""));
- ReplaceAllNoColon( sTarget, _T("%protocol%"), tmp);
+ tstring tmp = _DBGetString(hContact, "Protocol", "p", _T(""));
+ ReplaceAllNoColon(sTarget, _T("%protocol%"), tmp);
}
- if (bIdentifierUsed )
+ if (bIdentifierUsed)
{
// It has still not been replaced we will just use nick
- ReplaceAll( sTarget, _T("%nick%"), FileNickFromHandle( hContact));
+ ReplaceAll(sTarget, _T("%nick%"), FileNickFromHandle(hContact));
}
}
- if (sTarget.find( _T("%group%")) != string::npos )
+ if (sTarget.find(_T("%group%")) != string::npos)
{
- tstring sGroup = _DBGetString( hContact, "CList", "Group", _T(""));
- ReplaceAllNoColon( sTarget, _T("%group%"), sGroup);
+ 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 )
+ string::size_type nCur = 0;
+ while ((nCur = sTarget.find_first_of(_T("/*?<>|\""), nCur)) != sTarget.npos)
sTarget[nCur] = cBadCharReplace;
}
@@ -863,22 +863,22 @@ void ReplaceDefines( MCONTACT hContact, tstring & sTarget )
// Developer : KN
/////////////////////////////////////////////////////////////////////
-void ReplaceTimeVariables( tstring &sRet )
+void ReplaceTimeVariables(tstring &sRet)
{
- if (sRet.find( _T("%year%")) != string::npos ||
- sRet.find( _T("%month%")) != string::npos ||
- sRet.find( _T("%day%")) != string::npos )
+ 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];
mir_sntprintf(sTmp, SIZEOF(sTmp), _T("%d"), stTime.wYear);
- ReplaceAll( sRet, _T("%year%"), sTmp);
+ ReplaceAll(sRet, _T("%year%"), sTmp);
mir_sntprintf(sTmp, SIZEOF(sTmp), _T("%.2d"), stTime.wMonth);
- ReplaceAll( sRet, _T("%month%"), sTmp);
+ ReplaceAll(sRet, _T("%month%"), sTmp);
mir_sntprintf(sTmp, SIZEOF(sTmp), _T("%.2d"), stTime.wDay);
- ReplaceAll( sRet, _T("%day%"), sTmp);
+ ReplaceAll(sRet, _T("%day%"), sTmp);
}
}
@@ -900,9 +900,9 @@ void UpdateFileToColWidth()
clFileTo1ColWidth.clear();
for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
- tstring sNick = NickFromHandle( hContact);
- string::size_type &rnValue = clFileTo1ColWidth[ GetFilePathFromUser( hContact) ];
- if (rnValue < sNick.size())
+ tstring sNick = NickFromHandle(hContact);
+ string::size_type &rnValue = clFileTo1ColWidth[GetFilePathFromUser(hContact)];
+ if (rnValue < sNick.size())
rnValue = sNick.size();
}
}
@@ -924,7 +924,7 @@ void UpdateFileToColWidth()
// Developer : KN
/////////////////////////////////////////////////////////////////////
-void DisplayErrorDialog( const TCHAR *pszError, tstring& sFilePath, DBEVENTINFO * dbei )
+void DisplayErrorDialog(const TCHAR *pszError, tstring& sFilePath, DBEVENTINFO * dbei)
{
tstring sError = TranslateTS(pszError);
sError += sFilePath;
@@ -936,7 +936,7 @@ void DisplayErrorDialog( const TCHAR *pszError, tstring& sFilePath, DBEVENTINFO
{
OPENFILENAME ofn; // common dialog box structure
TCHAR szFile[260]; // buffer for file name
- _tcscpy( szFile, _T("DebugInfo.txt"));
+ mir_tstrcpy(szFile, _T("DebugInfo.txt"));
// Initialize OPENFILENAME
memset(&ofn, 0, sizeof(OPENFILENAME));
@@ -956,29 +956,29 @@ void DisplayErrorDialog( const TCHAR *pszError, tstring& sFilePath, DBEVENTINFO
if (GetSaveFileName(&ofn))
{
- HANDLE hf = CreateFile(ofn.lpstrFile, GENERIC_WRITE,
- 0, (LPSECURITY_ATTRIBUTES) NULL,
- CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL,
- (HANDLE) NULL); // file handle
+ HANDLE hf = CreateFile(ofn.lpstrFile, GENERIC_WRITE,
+ 0, (LPSECURITY_ATTRIBUTES)NULL,
+ CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL,
+ (HANDLE)NULL); // file handle
- bWriteTextToFile( hf, sError.c_str(), false);
- if (dbei )
+ bWriteTextToFile(hf, sError.c_str(), false);
+ if (dbei)
{
- bWriteToFile( hf, "\r\ndbei :");
+ bWriteToFile(hf, "\r\ndbei :");
- bWriteHexToFile( hf, dbei, sizeof( DBEVENTINFO ));
- if (dbei->pBlob )
+ bWriteHexToFile(hf, dbei, sizeof(DBEVENTINFO));
+ if (dbei->pBlob)
{
- bWriteToFile( hf, "\r\ndbei.pBlob :");
- bWriteHexToFile( hf, dbei->pBlob, min( dbei->cbBlob, 10000 ));
+ bWriteToFile(hf, "\r\ndbei.pBlob :");
+ bWriteHexToFile(hf, dbei->pBlob, min(dbei->cbBlob, 10000));
}
- if (dbei->szModule )
+ if (dbei->szModule)
{
- bWriteToFile( hf, "\r\ndbei.szModule :");
- bWriteToFile( hf, dbei->szModule);
+ bWriteToFile(hf, "\r\ndbei.szModule :");
+ bWriteToFile(hf, dbei->szModule);
}
}
- CloseHandle( hf);
+ CloseHandle(hf);
}
}
}
@@ -997,27 +997,27 @@ void DisplayErrorDialog( const TCHAR *pszError, tstring& sFilePath, DBEVENTINFO
// Developer : KN
/////////////////////////////////////////////////////////////////////
-void ExportDBEventInfo(MCONTACT hContact, DBEVENTINFO &dbei )
+void ExportDBEventInfo(MCONTACT hContact, DBEVENTINFO &dbei)
{
TCHAR szTemp[500];
- tstring sFilePath = GetFilePathFromUser( hContact);
-
+ 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 )
+ 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))
+ if (bCreatePathToFile(sFilePath))
{
- hFile = CreateFile( sFilePath.c_str(), GENERIC_WRITE | GENERIC_READ, FILE_SHARE_READ, 0,OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
+ hFile = CreateFile(sFilePath.c_str(), GENERIC_WRITE | GENERIC_READ, FILE_SHARE_READ, 0, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
}
}
- if (hFile == INVALID_HANDLE_VALUE )
+ if (hFile == INVALID_HANDLE_VALUE)
{
- DisplayErrorDialog( LPGENT("Failed to open or create file :\n"), sFilePath, NULL);
+ DisplayErrorDialog(LPGENT("Failed to open or create file :\n"), sFilePath, NULL);
return;
}
@@ -1025,7 +1025,7 @@ void ExportDBEventInfo(MCONTACT hContact, DBEVENTINFO &dbei )
tstring sRemoteUser;
string::size_type nFirstColumnWidth;
- if (bUseLessAndGreaterInExport )
+ if (bUseLessAndGreaterInExport)
{
sLocalUser = _T("<<");
sRemoteUser = _T(">>");
@@ -1035,8 +1035,8 @@ void ExportDBEventInfo(MCONTACT hContact, DBEVENTINFO &dbei )
{
sLocalUser = NickFromHandle(0);
sRemoteUser = NickFromHandle(hContact);
- nFirstColumnWidth = max( sRemoteUser.size(), clFileTo1ColWidth[sFilePath]);
- nFirstColumnWidth = max( sLocalUser.size(), nFirstColumnWidth);
+ nFirstColumnWidth = max(sRemoteUser.size(), clFileTo1ColWidth[sFilePath]);
+ nFirstColumnWidth = max(sLocalUser.size(), nFirstColumnWidth);
nFirstColumnWidth += 2;
}
@@ -1046,82 +1046,82 @@ void ExportDBEventInfo(MCONTACT hContact, DBEVENTINFO &dbei )
DWORD dwLowSize;
DWORD dwHighSize = 0;
- dwLowSize = GetFileSize( hFile, &dwHighSize);
+ dwLowSize = GetFileSize(hFile, &dwHighSize);
- if (dwLowSize == INVALID_FILE_SIZE || dwLowSize != 0 || dwHighSize != 0 )
+ if (dwLowSize == INVALID_FILE_SIZE || dwLowSize != 0 || dwHighSize != 0)
{
DWORD dwDataRead = 0;
BYTE ucByteOrder[3];
- if (ReadFile( hFile, ucByteOrder, 3, &dwDataRead, NULL))
+ if (ReadFile(hFile, ucByteOrder, 3, &dwDataRead, NULL))
{
- bWriteUTF8Format = bIsUtf8Header( ucByteOrder);
+ bWriteUTF8Format = bIsUtf8Header(ucByteOrder);
}
- DWORD dwPtr = SetFilePointer( hFile, 0, 0, FILE_END);
- if (dwPtr == INVALID_SET_FILE_POINTER )
+ 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( LPGENT("Failed to move to the end of the file :\n"), sFilePath, NULL);
- CloseHandle( hFile);
+ DisplayErrorDialog(LPGENT("Failed to move to the end of the file :\n"), sFilePath, NULL);
+ CloseHandle(hFile);
return;
}
}
else
{
bWriteUTF8Format = bUseUtf8InNewFiles;
- if (bWriteUTF8Format )
+ if (bWriteUTF8Format)
{
- if ( !bWriteToFile( hFile, szUtf8ByteOrderHeader, sizeof( szUtf8ByteOrderHeader) - 1))
+ if (!bWriteToFile(hFile, szUtf8ByteOrderHeader, sizeof(szUtf8ByteOrderHeader) - 1))
{
- DisplayErrorDialog( LPGENT("Failed to UTF8 byte order code to file :\n"), sFilePath, NULL);
- CloseHandle( hFile);
+ DisplayErrorDialog(LPGENT("Failed to UTF8 byte order code to file :\n"), sFilePath, NULL);
+ CloseHandle(hFile);
return;
}
}
tstring output = _T("------------------------------------------------\r\n")
- LPGENT(" History for\r\n")
- LPGENT("User : %User%\r\n")
- LPGENT("Protocol : %Proto%\r\n")
- LPGENT("UIN : %UIN%\r\n")
- LPGENT("FirstName : %FirstName%\r\n")
- LPGENT("LastName : %LastName%\r\n")
- LPGENT("Age : %Age%\r\n")
- LPGENT("Gender : %Gender%\r\n")
- LPGENT("e-mail : %e-mail%\r\n")
- LPGENT("Nick : %Nick%\r\n")
- LPGENT("City : %City%\r\n")
- LPGENT("State : %State%\r\n")
- LPGENT("Phone : %Phone%\r\n")
- LPGENT("Homepage : %Homepage%\r\n")
- LPGENT("- About -\r\n%About%\r\n")
- _T("------------------------------------------------\r\n");
+ LPGENT(" History for\r\n")
+ LPGENT("User : %User%\r\n")
+ LPGENT("Protocol : %Proto%\r\n")
+ LPGENT("UIN : %UIN%\r\n")
+ LPGENT("FirstName : %FirstName%\r\n")
+ LPGENT("LastName : %LastName%\r\n")
+ LPGENT("Age : %Age%\r\n")
+ LPGENT("Gender : %Gender%\r\n")
+ LPGENT("e-mail : %e-mail%\r\n")
+ LPGENT("Nick : %Nick%\r\n")
+ LPGENT("City : %City%\r\n")
+ LPGENT("State : %State%\r\n")
+ LPGENT("Phone : %Phone%\r\n")
+ LPGENT("Homepage : %Homepage%\r\n")
+ LPGENT("- 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);
+ ReplaceAll(output, _T("%User%"), sRemoteUser);
- string sProto = _DBGetStringA( hContact, "Protocol", "p", "");
- ReplaceAll( output, _T("%Proto%"), _DBGetString( hContact, "Protocol", "p", _T("")));
+ string sProto = _DBGetStringA(hContact, "Protocol", "p", "");
+ ReplaceAll(output, _T("%Proto%"), _DBGetString(hContact, "Protocol", "p", _T("")));
- for (int nCur = 0 ; nCur < 9 ; nCur++ )
+ for (int nCur = 0; nCur < 9; nCur++)
{
- ReplaceAll( output, pszReplaceList[nCur], _DBGetString( hContact, sProto.c_str(), pszReplaceListA[nCur], _T("")));
+ ReplaceAll(output, pszReplaceList[nCur], _DBGetString(hContact, sProto.c_str(), pszReplaceListA[nCur], _T("")));
}
mir_sntprintf(szTemp, SIZEOF(szTemp), _T("%d"), db_get_dw(hContact, sProto.c_str(), "UIN", 0));
- ReplaceAll( output, _T("%UIN%"), szTemp);
-
+ ReplaceAll(output, _T("%UIN%"), szTemp);
+
mir_sntprintf(szTemp, SIZEOF(szTemp), _T("%d"), db_get_w(hContact, sProto.c_str(), "Age", 0));
- ReplaceAll( output, _T("%Age%"), szTemp);
+ ReplaceAll(output, _T("%Age%"), szTemp);
szTemp[0] = (TCHAR)db_get_b(hContact, sProto.c_str(), "Gender", 0);
szTemp[1] = 0;
- ReplaceAll( output, _T("%Gender%"), szTemp);
+ ReplaceAll(output, _T("%Gender%"), szTemp);
- if ( !bWriteTextToFile( hFile, output.data(), bWriteUTF8Format, (int)output.size()))
+ if (!bWriteTextToFile(hFile, output.data(), bWriteUTF8Format, (int)output.size()))
{
- DisplayErrorDialog( LPGENT("Failed to write user details to file :\n"), sFilePath, NULL);
- CloseHandle( hFile);
+ DisplayErrorDialog(LPGENT("Failed to write user details to file :\n"), sFilePath, NULL);
+ CloseHandle(hFile);
return;
}
}
@@ -1129,9 +1129,9 @@ void ExportDBEventInfo(MCONTACT hContact, DBEVENTINFO &dbei )
int nIndent;
{ // Get time stamp
-
- nIndent = mir_sntprintf(szTemp, SIZEOF(szTemp), _T("%-*s"),
- nFirstColumnWidth,
+
+ nIndent = mir_sntprintf(szTemp, SIZEOF(szTemp), _T("%-*s"),
+ nFirstColumnWidth,
dbei.flags & DBEF_SENT ? sLocalUser.c_str() : sRemoteUser.c_str());
DBTIMETOSTRINGT dbtts;
@@ -1139,258 +1139,258 @@ void ExportDBEventInfo(MCONTACT hContact, DBEVENTINFO &dbei )
dbtts.szDest = &szTemp[nIndent];
dbtts.szFormat = (TCHAR*)sTimeFormat.c_str();
- CallService(MS_DB_TIME_TIMESTAMPTOSTRINGT,dbei.timestamp,(LPARAM)&dbtts);
+ CallService(MS_DB_TIME_TIMESTAMPTOSTRINGT, dbei.timestamp, (LPARAM)&dbtts);
- nIndent = (int)_tcslen( szTemp);
+ nIndent = (int)mir_tstrlen(szTemp);
szTemp[nIndent++] = ' ';
-
+
// Write first part of line with name and timestamp
- if ( !bWriteTextToFile( hFile, szTemp, bWriteUTF8Format, nIndent))
+ if (!bWriteTextToFile(hFile, szTemp, bWriteUTF8Format, nIndent))
{
- DisplayErrorDialog( LPGENT("Failed to write timestamp and username to file :\n"), sFilePath, &dbei);
- CloseHandle( hFile);
+ DisplayErrorDialog(LPGENT("Failed to write timestamp and username to file :\n"), sFilePath, &dbei);
+ CloseHandle(hFile);
return;
}
}
- if (dbei.pBlob != NULL && dbei.cbBlob >= 2 )
+ if (dbei.pBlob != NULL && dbei.cbBlob >= 2)
{
- dbei.pBlob[ dbei.cbBlob ] = 0;
+ dbei.pBlob[dbei.cbBlob] = 0;
- switch(dbei.eventType)
+ switch (dbei.eventType)
{
- case EVENTTYPE_MESSAGE:
+ case EVENTTYPE_MESSAGE:
+ {
+ TCHAR* msg = DbGetEventTextT(&dbei, CP_ACP);
+ if (!bWriteIndentedToFile(hFile, nIndent, msg, bWriteUTF8Format))
{
- TCHAR* msg = DbGetEventTextT(&dbei, CP_ACP);
- if ( !bWriteIndentedToFile( hFile, nIndent, msg, bWriteUTF8Format))
- {
- DisplayErrorDialog( LPGENT("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))
- {
+ DisplayErrorDialog(LPGENT("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;*/
+ }
+ }
+ // 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 = LPGENT("URL: ");
+ pszData = (char *)dbei.pBlob;
}
- case EVENTTYPE_URL:
- case EVENTTYPE_FILE:
+ else
{
- const TCHAR *pszType;
- const char *pszData;
-
- if (dbei.eventType == EVENTTYPE_URL )
- {
- pszType = LPGENT("URL: ");
- pszData = (char *)dbei.pBlob;
- }
- else
- {
- pszType = LPGENT("File: ");
- pszData = (char *)(dbei.pBlob + sizeof( DWORD ));
- }
+ pszType = LPGENT("File: ");
+ pszData = (char *)(dbei.pBlob + sizeof(DWORD));
+ }
- bool bWriteOk = false;
+ bool bWriteOk = false;
- int nLen = (int)strlen( pszData);
- if ((pszData - (char *)dbei.pBlob) + nLen < (int)dbei.cbBlob )
+ int nLen = (int)mir_strlen(pszData);
+ if ((pszData - (char *)dbei.pBlob) + nLen < (int)dbei.cbBlob)
+ {
+ if (bWriteTextToFile(hFile, pszType, bWriteUTF8Format) &&
+ bWriteIndentedToFile(hFile, nIndent, pszData, bWriteUTF8Format))
{
- if (bWriteTextToFile( hFile, pszType, bWriteUTF8Format) &&
- bWriteIndentedToFile( hFile, nIndent, pszData, bWriteUTF8Format))
+ pszData += nLen + 1;
+ if ((pszData - (char *)dbei.pBlob) >= (int)dbei.cbBlob)
{
- pszData += nLen + 1;
- if ((pszData - (char *)dbei.pBlob) >= (int)dbei.cbBlob )
- {
- bWriteOk = true;
- }
- else
+ bWriteOk = true;
+ }
+ else
+ {
+ nLen = (int)mir_strlen(pszData);
+ if ((pszData - (char *)dbei.pBlob) + nLen < (int)dbei.cbBlob)
{
- nLen = (int)strlen( pszData);
- if ((pszData - (char *)dbei.pBlob) + nLen < (int)dbei.cbBlob )
+ if (bWriteNewLine(hFile, nIndent) &&
+ bWriteTextToFile(hFile, LPGENT("Description: "), bWriteUTF8Format) &&
+ bWriteIndentedToFile(hFile, nIndent, pszData, bWriteUTF8Format))
{
- if (bWriteNewLine( hFile, nIndent) &&
- bWriteTextToFile( hFile, LPGENT("Description: "), bWriteUTF8Format) &&
- bWriteIndentedToFile( hFile, nIndent, pszData, bWriteUTF8Format))
- {
- bWriteOk = true;
- }
+ bWriteOk = true;
}
}
}
}
+ }
- if ( !bWriteOk )
- DisplayErrorDialog( LPGENT("Failed to write URL/File to the file :\n"), sFilePath, &dbei);
+ if (!bWriteOk)
+ DisplayErrorDialog(LPGENT("Failed to write URL/File to the file :\n"), sFilePath, &dbei);
+ break;
+ }
+ case EVENTTYPE_AUTHREQUEST:
+ case EVENTTYPE_ADDED:
+ {
+ const TCHAR *pszTypes[] = {
+ LPGENT("Nick :"),
+ LPGENT("FirstName :"),
+ LPGENT("LastName :"),
+ LPGENT("e-mail :"),
+ LPGENT("Reason :") };
+
+ if (dbei.cbBlob < 8 || dbei.cbBlob > 5000)
+ {
+ int n = mir_sntprintf(szTemp, SIZEOF(szTemp), TranslateT("Invalid Database event received. Type %d, size %d"), dbei.eventType, dbei.cbBlob);
+ if (!bWriteTextToFile(hFile, szTemp, bWriteUTF8Format, n))
+ DisplayErrorDialog(LPGENT("Failed to write Invalid Database event the file :\n"), sFilePath, &dbei);
break;
}
- case EVENTTYPE_AUTHREQUEST:
- case EVENTTYPE_ADDED:
- {
- const TCHAR *pszTypes[] = {
- LPGENT("Nick :"),
- LPGENT("FirstName :"),
- LPGENT("LastName :"),
- LPGENT("e-mail :"),
- LPGENT("Reason :")};
-
- if (dbei.cbBlob < 8 || dbei.cbBlob > 5000 )
- {
- int n = mir_sntprintf(szTemp, SIZEOF(szTemp), TranslateT("Invalid Database event received. Type %d, size %d"), dbei.eventType, dbei.cbBlob);
- if ( !bWriteTextToFile( hFile, szTemp, bWriteUTF8Format, n))
- DisplayErrorDialog( LPGENT("Failed to write Invalid Database event the file :\n"), sFilePath, &dbei);
- break;
- }
- bool bWriteOk = false;
-
- int nStringCount;
- const TCHAR *pszTitle;
- char *pszCurBlobPos;
- if (dbei.eventType == EVENTTYPE_AUTHREQUEST )
- { // request
- //blob is: uin(DWORD), hContact(DWORD), nick(ASCIIZ), first(ASCIIZ), last(ASCIIZ), email(ASCIIZ), reason(ASCIIZ)
- nStringCount = 5;
- pszCurBlobPos = (char *)dbei.pBlob + sizeof( DWORD )*2;
- pszTitle = LPGENT("The following user made an authorization request:");
- }
- else
- { // Added
- //blob is: uin(DWORD), nick(ASCIIZ), first(ASCIIZ), last(ASCIIZ), email(ASCIIZ)
- pszCurBlobPos = (char *)dbei.pBlob + sizeof(DWORD);
- nStringCount = 4;
- pszTitle = LPGENT("The following user added you to their contact list:");
- }
+ bool bWriteOk = false;
+
+ int nStringCount;
+ const TCHAR *pszTitle;
+ char *pszCurBlobPos;
+ if (dbei.eventType == EVENTTYPE_AUTHREQUEST)
+ { // request
+ //blob is: uin(DWORD), hContact(DWORD), nick(ASCIIZ), first(ASCIIZ), last(ASCIIZ), email(ASCIIZ), reason(ASCIIZ)
+ nStringCount = 5;
+ pszCurBlobPos = (char *)dbei.pBlob + sizeof(DWORD) * 2;
+ pszTitle = LPGENT("The following user made an authorization request:");
+ }
+ else
+ { // Added
+ //blob is: uin(DWORD), nick(ASCIIZ), first(ASCIIZ), last(ASCIIZ), email(ASCIIZ)
+ pszCurBlobPos = (char *)dbei.pBlob + sizeof(DWORD);
+ nStringCount = 4;
+ pszTitle = LPGENT("The following user added you to their contact list:");
+ }
- if (bWriteTextToFile( hFile, pszTitle, bWriteUTF8Format) &&
- bWriteNewLine( hFile, nIndent) &&
- bWriteTextToFile( hFile, LPGENT("UIN :"), bWriteUTF8Format))
+ if (bWriteTextToFile(hFile, pszTitle, bWriteUTF8Format) &&
+ bWriteNewLine(hFile, nIndent) &&
+ bWriteTextToFile(hFile, LPGENT("UIN :"), bWriteUTF8Format))
+ {
+ DWORD uin = *((PDWORD)(dbei.pBlob));
+ int n = mir_sntprintf(szTemp, SIZEOF(szTemp), _T("%d"), uin);
+ if (bWriteTextToFile(hFile, szTemp, bWriteUTF8Format, n))
{
- DWORD uin = *((PDWORD)(dbei.pBlob));
- int n = mir_sntprintf(szTemp, SIZEOF(szTemp), _T("%d"), uin);
- if (bWriteTextToFile( hFile, szTemp, bWriteUTF8Format, n))
+ char *pszEnd = (char *)(dbei.pBlob + dbei.cbSize);
+ for (int n = 0; n < nStringCount && pszCurBlobPos < pszEnd; n++)
{
- char *pszEnd = (char *) (dbei.pBlob + dbei.cbSize);
- for (int n = 0 ; n < nStringCount && pszCurBlobPos < pszEnd ; n++ )
+ if (*pszCurBlobPos)
{
- if (*pszCurBlobPos )
+ if (!bWriteNewLine(hFile, nIndent) ||
+ !bWriteTextToFile(hFile, TranslateTS(pszTypes[n]), bWriteUTF8Format) ||
+ !bWriteIndentedToFile(hFile, nIndent, pszCurBlobPos, bWriteUTF8Format))
{
- if ( !bWriteNewLine( hFile, nIndent) ||
- ! bWriteTextToFile( hFile, TranslateTS(pszTypes[ n ]), bWriteUTF8Format) ||
- ! bWriteIndentedToFile( hFile, nIndent, pszCurBlobPos, bWriteUTF8Format))
- {
- break;
- }
- pszCurBlobPos += strlen( pszCurBlobPos);
+ break;
}
- pszCurBlobPos++;
+ pszCurBlobPos += mir_strlen(pszCurBlobPos);
}
- bWriteOk = true;
+ pszCurBlobPos++;
}
+ bWriteOk = true;
}
+ }
- if ( !bWriteOk )
- DisplayErrorDialog( LPGENT("Failed to write AUTHREQUEST or ADDED to the file :\n"), sFilePath, &dbei);
+ if (!bWriteOk)
+ DisplayErrorDialog(LPGENT("Failed to write AUTHREQUEST or ADDED to the file :\n"), sFilePath, &dbei);
- break;
- }
- case ICQEVENTTYPE_EMAILEXPRESS:
- case ICQEVENTTYPE_WEBPAGER:
+ 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, LPGENT("EmailExpress from:"), bWriteUTF8Format);
+ else
+ bWriteTextToFile(hFile, LPGENT("WebPager from:"), bWriteUTF8Format);
+
+ bWriteNewLine(hFile, nIndent);
+
+ size_t nMsgLenght = mir_strlen(pszStr) + 1;
+ if (nMsgLenght < dbei.cbBlob)
{
- //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, LPGENT("EmailExpress from:"), bWriteUTF8Format);
- else
- bWriteTextToFile( hFile, LPGENT("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, (int)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, (int)nEmailLen);
- bWriteTextToFile( hFile, _T(">"), bWriteUTF8Format);
- }
- }
- else
+ size_t nFriendlyLen = mir_strlen(&pszStr[nMsgLenght]);
+ bWriteTextToFile(hFile, &pszStr[nMsgLenght], bWriteUTF8Format, (int)nFriendlyLen);
+ size_t nEmailOffset = nMsgLenght + nFriendlyLen + 1;
+ if (nEmailOffset < dbei.cbBlob)
{
- bWriteTextToFile( hFile, LPGENT("No from address"), bWriteUTF8Format);
+ bWriteTextToFile(hFile, _T("<"), bWriteUTF8Format);
+ size_t nEmailLen = mir_strlen(&pszStr[nEmailOffset]);
+ bWriteTextToFile(hFile, &pszStr[nEmailOffset], bWriteUTF8Format, (int)nEmailLen);
+ bWriteTextToFile(hFile, _T(">"), bWriteUTF8Format);
}
+ }
+ else
+ {
+ bWriteTextToFile(hFile, LPGENT("No from address"), bWriteUTF8Format);
+ }
- if ( !bWriteNewLine( hFile, nIndent) ||
- ! bWriteIndentedToFile( hFile, nIndent, pszStr, bWriteUTF8Format))
- {
- DisplayErrorDialog( LPGENT("Failed to write EmailExpress to the file :\n"), sFilePath, &dbei);
- }
- break;
+ if (!bWriteNewLine(hFile, nIndent) ||
+ !bWriteIndentedToFile(hFile, nIndent, pszStr, bWriteUTF8Format))
+ {
+ DisplayErrorDialog(LPGENT("Failed to write EmailExpress to the file :\n"), sFilePath, &dbei);
}
- case ICQEVENTTYPE_SMS:
+ break;
+ }
+ case ICQEVENTTYPE_SMS:
+ {
+ if (!bWriteIndentedToFile(hFile, nIndent, (const char*)dbei.pBlob, bWriteUTF8Format))
{
- if ( !bWriteIndentedToFile( hFile, nIndent, (const char*)dbei.pBlob, bWriteUTF8Format))
- {
- DisplayErrorDialog( LPGENT("Failed to write SMS to the file :\n"), sFilePath, &dbei);
- }
- break;
+ DisplayErrorDialog(LPGENT("Failed to write SMS to the file :\n"), sFilePath, &dbei);
}
- default:
+ break;
+ }
+ default:
+ {
+ int n = mir_sntprintf(szTemp, SIZEOF(szTemp), TranslateT("Unknown event type %d, size %d"), dbei.eventType, dbei.cbBlob);
+ if (!bWriteTextToFile(hFile, szTemp, bWriteUTF8Format, n))
{
- int n = mir_sntprintf(szTemp, SIZEOF(szTemp), TranslateT("Unknown event type %d, size %d"), dbei.eventType, dbei.cbBlob);
- if ( !bWriteTextToFile( hFile, szTemp, bWriteUTF8Format, n))
- {
- DisplayErrorDialog( LPGENT("Failed to write Unknown event to the file :\n"), sFilePath, &dbei);
- }
- break;
+ DisplayErrorDialog(LPGENT("Failed to write Unknown event to the file :\n"), sFilePath, &dbei);
}
+ break;
+ }
}
}
else
{
int n = mir_sntprintf(szTemp, SIZEOF(szTemp), TranslateT("Unknown event type %d, size %d"), dbei.eventType, dbei.cbBlob);
- bWriteTextToFile( hFile, szTemp, bWriteUTF8Format, n);
+ bWriteTextToFile(hFile, szTemp, bWriteUTF8Format, n);
}
- bWriteToFile( hFile, bAppendNewLine ? "\r\n\r\n" : "\r\n");
+ bWriteToFile(hFile, bAppendNewLine ? "\r\n\r\n" : "\r\n");
- CloseHandle( hFile);
+ CloseHandle(hFile);
- UpdateFileViews( sFilePath.c_str());
+ UpdateFileViews(sFilePath.c_str());
}
/////////////////////////////////////////////////////////////////////
@@ -1410,7 +1410,7 @@ void ExportDBEventInfo(MCONTACT hContact, DBEVENTINFO &dbei )
int nExportEvent(WPARAM hContact, LPARAM hDbEvent)
{
- if ( !db_get_b(hContact,MODULE,"EnableLog",1))
+ if (!db_get_b(hContact, MODULE, "EnableLog", 1))
return 0;
DBEVENTINFO dbei = { sizeof(dbei) };
@@ -1419,33 +1419,35 @@ int nExportEvent(WPARAM hContact, LPARAM hDbEvent)
dbei.cbBlob = nSize;
dbei.pBlob = (PBYTE)malloc(dbei.cbBlob + 2);
dbei.pBlob[dbei.cbBlob] = 0;
- dbei.pBlob[dbei.cbBlob+1] = 0;
+ dbei.pBlob[dbei.cbBlob + 1] = 0;
// Double null terminate, this shut pervent most errors
// where the blob received has an invalid format
}
- if ( !db_event_get(hDbEvent, &dbei)) {
+ if (!db_event_get(hDbEvent, &dbei)) {
char szTemp[500];
mir_snprintf(szTemp, SIZEOF(szTemp), "DisableProt_%s", dbei.szModule);
- if (db_get_b(NULL,MODULE,szTemp,1))
- ExportDBEventInfo( hContact, dbei);
+ if (db_get_b(NULL, MODULE, szTemp, 1))
+ ExportDBEventInfo(hContact, dbei);
}
- if (dbei.pBlob )
+ if (dbei.pBlob)
free(dbei.pBlob);
return 0;
}
#ifdef _UNICODE
-bool bWriteIndentedToFile( HANDLE hFile, int nIndent, const char *pszSrc, bool bUtf8File )
+bool bWriteIndentedToFile(HANDLE hFile, int nIndent, const char *pszSrc, bool bUtf8File)
{
- int nLen = (int)strlen( pszSrc);
- wchar_t * pszWstr = new wchar_t[nLen+1];
+ int nLen = (int)mir_strlen(pszSrc);
+ wchar_t * pszWstr = new wchar_t[nLen + 1];
bool bRet = false;
- if (MultiByteToWideChar(CP_ACP, 0, pszSrc, nLen, pszWstr, nLen) == nLen )
+ if (MultiByteToWideChar(CP_ACP, 0, pszSrc, nLen, pszWstr, nLen) == nLen)
{
pszWstr[nLen] = NULL;
- bRet = bWriteIndentedToFile( hFile, nIndent, pszWstr, bUtf8File);
+ bRet = bWriteIndentedToFile(hFile, nIndent, pszWstr, bUtf8File);
}
+ delete[] pszWstr;
+
return bRet;
}
#endif
@@ -1465,15 +1467,15 @@ bool bWriteIndentedToFile( HANDLE hFile, int nIndent, const char *pszSrc, bool b
// Developer : KN
/////////////////////////////////////////////////////////////////////
-bool bWriteIndentedToFile( HANDLE hFile, int nIndent, const TCHAR *pszSrc, bool bUtf8File )
+bool bWriteIndentedToFile(HANDLE hFile, int nIndent, const TCHAR *pszSrc, bool bUtf8File)
{
if (pszSrc == NULL)
return true;
bool bOk = true;
bool bFirstLine = true;
-
- while( *pszSrc )
+
+ while (*pszSrc)
{ // first we will scan forward in string to finde either new line or "max line with"
int nLineLen = 0;
do
@@ -1481,17 +1483,17 @@ bool bWriteIndentedToFile( HANDLE hFile, int nIndent, const TCHAR *pszSrc, bool
if (pszSrc[nLineLen] == _T('\n') || pszSrc[nLineLen] == _T('\r'))
break;
- if (nLineLen >= nMaxLineWidth )
+ 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++)
+ const TCHAR ac[] = { _T(' '), _T('?'), _T('-'), _T('.'), _T(',') };
+ for (int y = 0; y < SIZEOF(ac); y++)
{
- for (int n = nLineLen ; n > 0 ; n-- )
+ for (int n = nLineLen; n > 0; n--)
{
- if (pszSrc[n] == ac[y] )
+ if (pszSrc[n] == ac[y])
{
nLineLen = n;
goto SuperBreak;
@@ -1501,45 +1503,44 @@ bool bWriteIndentedToFile( HANDLE hFile, int nIndent, const TCHAR *pszSrc, bool
break;
}
nLineLen++;
- }
- while( pszSrc[nLineLen]);
-
+ } while (pszSrc[nLineLen]);
+
// trim away traling spaces !!
- if (nLineLen > 0 )
+ if (nLineLen > 0)
{
- while( pszSrc[nLineLen-1] == ' ' )
+ while (pszSrc[nLineLen - 1] == ' ')
nLineLen--;
}
-SuperBreak:
+ SuperBreak:
// nLineLen should contain the number af chars we need to write to the file
- if (nLineLen > 0 )
+ if (nLineLen > 0)
{
- if (!bFirstLine )
- {
- if ( !bWriteNewLine( hFile, nIndent))
- {
- bOk = false;
- }
- }
-/* if (bUtf8Src )
+ if (!bFirstLine)
{
- // 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))
+ if (!bWriteNewLine(hFile, nIndent))
{
bOk = false;
}
}
- else*/
+ /* 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))
+ if (!bWriteTextToFile(hFile, pszSrc, bUtf8File, nLineLen))
bOk = false;
}
}
@@ -1549,10 +1550,10 @@ SuperBreak:
// and excess spaces
const TCHAR *pszPrev = pszSrc;
pszSrc += nLineLen;
- while( *pszSrc == _T(' ') || *pszSrc == _T('\n') || *pszSrc == _T('\r'))
+ while (*pszSrc == _T(' ') || *pszSrc == _T('\n') || *pszSrc == _T('\r'))
pszSrc++;
- if (pszPrev == 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);
@@ -1579,52 +1580,52 @@ SuperBreak:
// Developer : KN
/////////////////////////////////////////////////////////////////////
-int nContactDeleted(WPARAM wparam,LPARAM /*lparam*/)
+int nContactDeleted(WPARAM wparam, LPARAM /*lparam*/)
{
MCONTACT hContact = (MCONTACT)wparam;
-
- HWND hInternalWindow = WindowList_Find(hInternalWindowList,hContact);
- if(hInternalWindow)
+
+ HWND hInternalWindow = WindowList_Find(hInternalWindowList, hContact);
+ if (hInternalWindow)
CloseWindow(hInternalWindow);
- if (enDeleteAction == eDANothing )
+ if (enDeleteAction == eDANothing)
return 0;
- tstring sFilePath = GetFilePathFromUser( hContact);
+ tstring sFilePath = GetFilePathFromUser(hContact);
// Test if there is another user using this file
- for(MCONTACT hOtherContact = db_find_first();hOtherContact;hOtherContact = db_find_next(hOtherContact))
- if (hContact != hOtherContact && sFilePath == GetFilePathFromUser( hOtherContact))
+ for (MCONTACT hOtherContact = db_find_first(); hOtherContact; hOtherContact = db_find_next(hOtherContact))
+ if (hContact != hOtherContact && sFilePath == GetFilePathFromUser(hOtherContact))
return 0; // we found another contact abort mission :-)
// Test to see if there is a file to delete
- HANDLE hPrevFile = CreateFile( sFilePath.c_str(),
- GENERIC_READ,
+ HANDLE hPrevFile = CreateFile(sFilePath.c_str(),
+ GENERIC_READ,
FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL,
OPEN_EXISTING,
- FILE_ATTRIBUTE_NORMAL,
+ FILE_ATTRIBUTE_NORMAL,
NULL);
- if (hPrevFile != INVALID_HANDLE_VALUE )
+ if (hPrevFile != INVALID_HANDLE_VALUE)
{
- CloseHandle( hPrevFile);
+ CloseHandle(hPrevFile);
TCHAR szTemp[500];
mir_sntprintf(szTemp, SIZEOF(szTemp), _T("%s\r\n%s"),
TranslateT("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 )
+ MessageBox(NULL, szTemp, MSG_BOX_TITEL, MB_YESNO) == IDYES)
{
- if ( !DeleteFile( sFilePath.c_str()))
+ if (!DeleteFile(sFilePath.c_str()))
{
- mir_sntprintf(szTemp, SIZEOF(szTemp),
+ mir_sntprintf(szTemp, SIZEOF(szTemp),
_T("%s\r\n%s"),
TranslateT("Failed to delete the file"),
sFilePath.c_str());
- DisplayLastError( szTemp);
+ DisplayLastError(szTemp);
}
}
}
@@ -1646,7 +1647,7 @@ int nContactDeleted(WPARAM wparam,LPARAM /*lparam*/)
void SaveSettings()
{
- db_set_w(NULL, MODULE, "MaxLineWidth", (WORD) nMaxLineWidth);
+ db_set_w(NULL, MODULE, "MaxLineWidth", (WORD)nMaxLineWidth);
db_set_ts(NULL, MODULE, "ExportDir", sExportDir.c_str());
db_set_ts(NULL, MODULE, "DefaultFile", sDefaultFile.c_str());
db_set_ts(NULL, MODULE, "TimeFormat", sTimeFormat.c_str());
diff --git a/plugins/Msg_Export/src/utils.h b/plugins/Msg_Export/src/utils.h
index 2b2a11768e..ce3036fda9 100755
--- a/plugins/Msg_Export/src/utils.h
+++ b/plugins/Msg_Export/src/utils.h
@@ -49,35 +49,35 @@ tstring sGetErrorString(DWORD dwError);
tstring sGetErrorString();
void DisplayLastError(const TCHAR *pszError);
-TCHAR *CheckedTranslate( const TCHAR *szEng, int nFormatCount = -1);
+TCHAR *CheckedTranslate(const TCHAR *szEng, int nFormatCount = -1);
void SaveSettings();
void ShowDebugInfo();
-int nExportEvent(WPARAM wparam,LPARAM lparam);
-int nContactDeleted(WPARAM wparam,LPARAM lparam);
+int nExportEvent(WPARAM wparam, LPARAM lparam);
+int nContactDeleted(WPARAM wparam, LPARAM lparam);
const TCHAR *NickFromHandle(MCONTACT hContact);
-tstring __inline _DBGetStringW(MCONTACT hContact,const char *szModule,const char *szSetting, const TCHAR *pszError);
-string __inline _DBGetStringA(MCONTACT hContact,const char *szModule,const char *szSetting, const char *pszError);
+tstring __inline _DBGetStringW(MCONTACT hContact, const char *szModule, const char *szSetting, const TCHAR *pszError);
+string __inline _DBGetStringA(MCONTACT 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 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( MCONTACT hContact);
+tstring GetFilePathFromUser(MCONTACT hContact);
-void ReplaceDefines( MCONTACT hContact, tstring & sTarget);
-void ReplaceTimeVariables( tstring &sRet);
+void ReplaceDefines(MCONTACT hContact, tstring & sTarget);
+void ReplaceTimeVariables(tstring &sRet);
-bool bCreatePathToFile( tstring sFilePath);
+bool bCreatePathToFile(tstring sFilePath);
-bool bWriteIndentedToFile( HANDLE hFile, int nIndent, const char *pszSrc, bool bUtf8File);
-bool bWriteIndentedToFile( HANDLE hFile, int nIndent, const TCHAR *pszSrc, bool bUtf8File);
-bool bWriteNewLine( HANDLE hFile, DWORD dwIndent);
-bool bIsUtf8Header( BYTE * pucByteOrder);
+bool bWriteIndentedToFile(HANDLE hFile, int nIndent, const char *pszSrc, bool bUtf8File);
+bool bWriteIndentedToFile(HANDLE hFile, int nIndent, const TCHAR *pszSrc, bool bUtf8File);
+bool bWriteNewLine(HANDLE hFile, DWORD dwIndent);
+bool bIsUtf8Header(BYTE * pucByteOrder);
#endif