diff options
Diffstat (limited to 'plugins/BasicHistory')
-rw-r--r-- | plugins/BasicHistory/src/BasicHistory.cpp | 31 | ||||
-rw-r--r-- | plugins/BasicHistory/src/BinaryExport.cpp | 22 | ||||
-rw-r--r-- | plugins/BasicHistory/src/DatExport.cpp | 24 | ||||
-rw-r--r-- | plugins/BasicHistory/src/EventList.cpp | 262 | ||||
-rw-r--r-- | plugins/BasicHistory/src/ExportManager.cpp | 86 | ||||
-rw-r--r-- | plugins/BasicHistory/src/HistoryWindow.cpp | 971 | ||||
-rw-r--r-- | plugins/BasicHistory/src/Options.cpp | 1326 | ||||
-rw-r--r-- | plugins/BasicHistory/src/PlainHtmlExport.cpp | 8 | ||||
-rw-r--r-- | plugins/BasicHistory/src/RichHtmlExport.cpp | 240 | ||||
-rw-r--r-- | plugins/BasicHistory/src/Scheduler.cpp | 714 | ||||
-rw-r--r-- | plugins/BasicHistory/src/Searcher.cpp | 143 | ||||
-rw-r--r-- | plugins/BasicHistory/src/version.h | 26 |
12 files changed, 1490 insertions, 2363 deletions
diff --git a/plugins/BasicHistory/src/BasicHistory.cpp b/plugins/BasicHistory/src/BasicHistory.cpp index 12a75bb37a..bb2a360756 100644 --- a/plugins/BasicHistory/src/BasicHistory.cpp +++ b/plugins/BasicHistory/src/BasicHistory.cpp @@ -131,8 +131,7 @@ void InitTaskMenuItems() std::vector<TaskOptions>::iterator taskIt = Options::instance->taskOptions.begin();
std::vector<HGENMENU>::iterator it = taskMenus.begin();
- for(; it != taskMenus.end() && taskIt != Options::instance->taskOptions.end(); ++it, ++taskIt)
- {
+ for (; it != taskMenus.end() && taskIt != Options::instance->taskOptions.end(); ++it, ++taskIt) {
memset(&mi, 0, sizeof(mi));
mi.cbSize = sizeof(mi);
mi.flags = CMIM_FLAGS | CMIM_NAME | CMIF_CHILDPOPUP | CMIF_ROOTHANDLE | CMIF_TCHAR | CMIF_KEEPUNTRANSLATED;
@@ -141,8 +140,7 @@ void InitTaskMenuItems() Menu_ModifyItem((HGENMENU)*it, &mi);
}
- for(; it != taskMenus.end(); ++it)
- {
+ for (; it != taskMenus.end(); ++it) {
memset(&mi, 0, sizeof(mi));
mi.cbSize = sizeof(mi);
mi.flags = CMIM_FLAGS | CMIF_CHILDPOPUP | CMIF_ROOTHANDLE | CMIF_TCHAR | CMIF_KEEPUNTRANSLATED | CMIF_HIDDEN;
@@ -151,8 +149,7 @@ void InitTaskMenuItems() }
int pos = (int)taskMenus.size();
- for(; taskIt != Options::instance->taskOptions.end(); ++taskIt)
- {
+ for (; taskIt != Options::instance->taskOptions.end(); ++taskIt) {
memset(&mi, 0, sizeof(mi));
mi.cbSize = sizeof(mi);
mi.flags = CMIF_CHILDPOPUP | CMIF_ROOTHANDLE | CMIF_TCHAR | CMIF_KEEPUNTRANSLATED;
@@ -164,8 +161,7 @@ void InitTaskMenuItems() taskMenus.push_back(menu);
}
}
- else if (hTaskMainMenu != NULL)
- {
+ else if (hTaskMainMenu != NULL) {
CLISTMENUITEM mi = { sizeof(mi) };
mi.flags = CMIM_FLAGS | CMIF_ROOTPOPUP | CMIF_HIDDEN;
Menu_ModifyItem(hTaskMainMenu, &mi);
@@ -223,26 +219,20 @@ int ModulesLoaded(WPARAM wParam, LPARAM lParam) InitMenuItems();
TCHAR ftpExe[MAX_PATH];
- if (SUCCEEDED(SHGetFolderPath(NULL, CSIDL_PROGRAM_FILES, NULL, SHGFP_TYPE_CURRENT, ftpExe)))
- {
+ if (SUCCEEDED(SHGetFolderPath(NULL, CSIDL_PROGRAM_FILES, NULL, SHGFP_TYPE_CURRENT, ftpExe))) {
_tcscat_s(ftpExe, _T("\\WinSCP\\WinSCP.exe"));
DWORD atr = GetFileAttributes(ftpExe);
- if (atr == INVALID_FILE_ATTRIBUTES || atr & FILE_ATTRIBUTE_DIRECTORY)
- {
+ if (atr == INVALID_FILE_ATTRIBUTES || atr & FILE_ATTRIBUTE_DIRECTORY) {
#ifdef _WIN64
- if (SUCCEEDED(SHGetFolderPath(NULL, CSIDL_PROGRAM_FILESX86, NULL, SHGFP_TYPE_CURRENT, ftpExe)))
- {
+ if (SUCCEEDED(SHGetFolderPath(NULL, CSIDL_PROGRAM_FILESX86, NULL, SHGFP_TYPE_CURRENT, ftpExe))) {
_tcscat_s(ftpExe, _T("\\WinSCP\\WinSCP.exe"));
atr = GetFileAttributes(ftpExe);
if (!(atr == INVALID_FILE_ATTRIBUTES || atr & FILE_ATTRIBUTE_DIRECTORY))
- {
Options::instance->ftpExePathDef = ftpExe;
- }
}
#endif
}
- else
- Options::instance->ftpExePathDef = ftpExe;
+ else Options::instance->ftpExePathDef = ftpExe;
}
TCHAR* log = _T("%miranda_logpath%\\BasicHistory\\ftplog.txt");
@@ -310,17 +300,14 @@ extern "C" int __declspec(dllexport) Unload(void) EventList::Deinit();
- if (Options::instance != NULL)
- {
+ if (Options::instance != NULL) {
Options::instance->Unload();
delete Options::instance;
Options::instance = NULL;
}
if (hEventIcons != NULL)
- {
delete [] hEventIcons;
- }
return 0;
}
diff --git a/plugins/BasicHistory/src/BinaryExport.cpp b/plugins/BasicHistory/src/BinaryExport.cpp index 76239cb098..0e1636af2f 100644 --- a/plugins/BasicHistory/src/BinaryExport.cpp +++ b/plugins/BasicHistory/src/BinaryExport.cpp @@ -65,11 +65,9 @@ bool BinaryExport::ReadString(std::wstring &str) int size = 1024;
int pos = 0;
int totalSize = 0;
- while(1)
- {
+ while(true) {
buf.resize(size);
- if (IMP_FILE.peek() == 0)
- {
+ if (IMP_FILE.peek() == 0) {
IMP_FILE.get();
break;
}
@@ -96,6 +94,7 @@ bool BinaryExport::ReadString(std::wstring &str) if (totalSize == 0)
return true;
+
int sizeW = MultiByteToWideChar(codepage, 0, (char*)buf.c_str(), totalSize, NULL, 0);
str.resize(sizeW);
MultiByteToWideChar(codepage, 0, (char*)buf.c_str(), totalSize, (wchar_t*)str.c_str(), sizeW);
@@ -133,8 +132,7 @@ void BinaryExport::WriteGroup(bool isMe, const std::wstring &time, const std::ws void BinaryExport::WriteMessage(bool isMe, const std::wstring &longDate, const std::wstring &shortDate, const std::wstring &user, const std::wstring &message, const DBEVENTINFO& dbei)
{
- if (dbei.timestamp >= lTime)
- {
+ if (dbei.timestamp >= lTime) {
BinaryFileMessageHeader header;
header.eventType = dbei.eventType;
header.flags = dbei.flags & (~(0x800));
@@ -150,8 +148,10 @@ bool ReadHeader(BinaryFileHeader& header, std::istream* stream) stream->read((char*)&header, sizeof(BinaryFileHeader));
if (!stream->good())
return false;
+
if (memcmp(header.signature, "BHBF", 4) != 0)
return false;
+
if (header.version != 0 || header.codepage == 12000 || header.codepage == 12001)
return false;
@@ -163,6 +163,7 @@ int BinaryExport::IsContactInFile(const std::vector<HANDLE>& contacts) BinaryFileHeader header;
if (!ReadHeader(header, IImport::stream))
return -2;
+
codepage = header.codepage;
std::wstring filterName;
std::wstring myName;
@@ -188,14 +189,11 @@ int BinaryExport::IsContactInFile(const std::vector<HANDLE>& contacts) return -2;
IMP_FILE.seekg(0, std::ios_base::beg);
- for(int i = 0; i < (int)contacts.size(); ++i)
- {
+ for (int i = 0; i < (int)contacts.size(); ++i) {
std::wstring pn = GetProtocolName(contacts[i]);
std::wstring id = GetContactId(contacts[i]);
if (pn == proto1 && id == id1)
- {
return i;
- }
}
return -1;
@@ -206,11 +204,11 @@ bool BinaryExport::GetEventList(std::vector<IImport::ExternalMessage>& eventList BinaryFileHeader header;
if (!ReadHeader(header, IImport::stream))
return false;
+
codepage = header.codepage;
IMP_FILE.seekg(header.dataStart, std::ios_base::beg);
BinaryFileMessageHeader messageHeader;
- while(1)
- {
+ while(true) {
IMP_FILE.read((char*)&messageHeader, sizeof(BinaryFileMessageHeader));
if (IMP_FILE.eof())
break;
diff --git a/plugins/BasicHistory/src/DatExport.cpp b/plugins/BasicHistory/src/DatExport.cpp index 7518567a71..491f446560 100644 --- a/plugins/BasicHistory/src/DatExport.cpp +++ b/plugins/BasicHistory/src/DatExport.cpp @@ -55,14 +55,11 @@ DatExport::~DatExport() {
}
-
int DatExport::WriteString(const std::wstring &str)
{
int conv = WideCharToMultiByte(CP_UTF8, 0, str.c_str(), (int)str.length() + 1, NULL, 0, NULL, NULL);
if (conv > (int)memBuf.size())
- {
memBuf.resize(conv);
- }
conv = WideCharToMultiByte(CP_UTF8, 0, str.c_str(), (int)str.length() + 1, (char*)memBuf.c_str(), conv, NULL, NULL);
return conv;
@@ -102,16 +99,14 @@ void DatExport::WriteMessage(bool isMe, const std::wstring &longDate, const std: header.timestamp = dbei.timestamp;
header.szModule = 0;
header.pBlob = 0;
- if (dbei.flags & 0x800)
- {
+ if (dbei.flags & 0x800) {
//Imported
header.flags |= DBEF_UTF;
header.cbBlob = WriteString(message);
EXP_FILE.write((char*)&header, header.cbSize);
EXP_FILE.write(memBuf.c_str(), header.cbBlob);
}
- else
- {
+ else {
//Internal
header.cbBlob = dbei.cbBlob;
EXP_FILE.write((char*)&header, header.cbSize);
@@ -126,6 +121,7 @@ bool ReadHeader(MCHeader& header, std::istream* stream) stream->read((char*)&header, sizeof(MCHeader));
if (!stream->good())
return false;
+
if (memcmp(header.signature, "HB", 2) != 0)
return false;
@@ -139,9 +135,7 @@ int DatExport::IsContactInFile(const std::vector<HANDLE>& contacts) return -2;
if (contacts.size() == 1)
- {
hContact = contacts[0];
- }
IMP_FILE.seekg(0, std::ios_base::beg);
return -3;
@@ -152,6 +146,7 @@ bool DatExport::GetEventList(std::vector<IImport::ExternalMessage>& eventList) MCHeader header;
if (!ReadHeader(header, IImport::stream))
return false;
+
dataSize = header.dataSize;
DBEVENTINFO86 messageHeader;
DBEVENTINFO info = {0};
@@ -159,8 +154,7 @@ bool DatExport::GetEventList(std::vector<IImport::ExternalMessage>& eventList) info.szModule = GetContactProto(hContact);
TCHAR _str[MAXSELECTSTR + 8]; // for safety reason
std::multimap<DWORD, IImport::ExternalMessage> sortedEvents;
- while(dataSize > 0)
- {
+ while(dataSize > 0) {
messageHeader.cbSize = 0;
IMP_FILE.read((char*)&messageHeader, sizeof(DBEVENTINFO86));
if (!IMP_FILE.good())
@@ -170,18 +164,14 @@ bool DatExport::GetEventList(std::vector<IImport::ExternalMessage>& eventList) return false;
if (messageHeader.cbSize > sizeof(DBEVENTINFO86))
- {
IMP_FILE.seekg(messageHeader.cbSize - sizeof(DBEVENTINFO86), std::ios_base::cur);
- }
IImport::ExternalMessage exMsg;
exMsg.eventType = messageHeader.eventType;
exMsg.flags = messageHeader.flags;
exMsg.timestamp = messageHeader.timestamp;
if (messageHeader.cbBlob > memBuf.size())
- {
memBuf.resize(messageHeader.cbBlob);
- }
IMP_FILE.read((char*)memBuf.c_str(), messageHeader.cbBlob);
if (!IMP_FILE.good())
@@ -201,10 +191,8 @@ bool DatExport::GetEventList(std::vector<IImport::ExternalMessage>& eventList) memBuf.resize(0);
memBuf.shrink_to_fit();
- for(std::multimap<DWORD, IImport::ExternalMessage>::iterator it = sortedEvents.begin(); it != sortedEvents.end(); ++it)
- {
+ for (std::multimap<DWORD, IImport::ExternalMessage>::iterator it = sortedEvents.begin(); it != sortedEvents.end(); ++it)
eventList.push_back(it->second);
- }
return true;
}
diff --git a/plugins/BasicHistory/src/EventList.cpp b/plugins/BasicHistory/src/EventList.cpp index b72eeaa144..44ba5db4cc 100644 --- a/plugins/BasicHistory/src/EventList.cpp +++ b/plugins/BasicHistory/src/EventList.cpp @@ -54,7 +54,6 @@ EventList::EventList(HANDLE _hContact, int filter) SetDefFilter(filter);
}
-
EventList::~EventList()
{
mir_free(gdbei.pBlob);
@@ -63,15 +62,12 @@ EventList::~EventList() bool EventList::CanShowHistory(DBEVENTINFO* dbei)
{
- if (deltaTime != 0)
- {
- if (deltaTime > 0)
- {
+ if (deltaTime != 0) {
+ if (deltaTime > 0) {
if (now - deltaTime < dbei->timestamp)
return false;
}
- else
- {
+ else {
if (now + deltaTime > dbei->timestamp)
return false;
}
@@ -80,56 +76,42 @@ bool EventList::CanShowHistory(DBEVENTINFO* dbei) if (hContact == NULL || defFilter == 1)
return true;
- else if (defFilter < 1)
- {
- switch( dbei->eventType )
- {
+ if (defFilter < 1) {
+ switch(dbei->eventType) {
case EVENTTYPE_MESSAGE:
case EVENTTYPE_URL:
case EVENTTYPE_FILE:
return true;
default:
- {
- DBEVENTTYPEDESCR* et = ( DBEVENTTYPEDESCR* )CallService(MS_DB_EVENT_GETTYPE, ( WPARAM )dbei->szModule, ( LPARAM )dbei->eventType );
- if ( et && ( et->flags & DETF_HISTORY ))
- {
- return true;
- }
- }
+ DBEVENTTYPEDESCR* et = ( DBEVENTTYPEDESCR* )CallService(MS_DB_EVENT_GETTYPE, ( WPARAM )dbei->szModule, ( LPARAM )dbei->eventType );
+ if ( et && ( et->flags & DETF_HISTORY ))
+ return true;
}
return false;
}
- else
- {
- if (filterMap.find(dbei->eventType) != filterMap.end())
- {
- if (onlyInFilter)
- {
- return !(dbei->flags & DBEF_SENT);
- }
- else if (onlyOutFilter)
- {
- return (dbei->flags & DBEF_SENT) != 0;
- }
- return true;
- }
- return false;
+
+ if (filterMap.find(dbei->eventType) != filterMap.end()) {
+ if (onlyInFilter)
+ return !(dbei->flags & DBEF_SENT);
+
+ if (onlyOutFilter)
+ return (dbei->flags & DBEF_SENT) != 0;
+
+ return true;
}
+ return false;
}
bool EventList::CanShowHistory(const IImport::ExternalMessage& message)
{
- if (deltaTime != 0)
- {
- if (deltaTime > 0)
- {
+ if (deltaTime != 0) {
+ if (deltaTime > 0) {
if (now - deltaTime < message.timestamp)
return false;
}
- else
- {
+ else {
if (now + deltaTime > message.timestamp)
return false;
}
@@ -138,10 +120,8 @@ bool EventList::CanShowHistory(const IImport::ExternalMessage& message) if (hContact == NULL || defFilter == 1)
return true;
- else if (defFilter < 1)
- {
- switch(message.eventType )
- {
+ if (defFilter < 1) {
+ switch(message.eventType ) {
case EVENTTYPE_MESSAGE:
case EVENTTYPE_URL:
case EVENTTYPE_FILE:
@@ -150,22 +130,17 @@ bool EventList::CanShowHistory(const IImport::ExternalMessage& message) return false;
}
- else
- {
- if (filterMap.find(message.eventType) != filterMap.end())
- {
- if (onlyInFilter)
- {
- return !(message.flags & DBEF_SENT);
- }
- else if (onlyOutFilter)
- {
- return (message.flags & DBEF_SENT) != 0;
- }
- return true;
- }
- return false;
+
+ if (filterMap.find(message.eventType) != filterMap.end()) {
+ if (onlyInFilter)
+ return !(message.flags & DBEF_SENT);
+
+ if (onlyOutFilter)
+ return (message.flags & DBEF_SENT) != 0;
+
+ return true;
}
+ return false;
}
void EventList::InitFilters()
@@ -173,51 +148,34 @@ void EventList::InitFilters() filterMap.clear();
onlyInFilter = false;
onlyOutFilter = false;
- if (defFilter >= 2)
- {
+ if (defFilter >= 2) {
defFilter = 0;
- for(int i = 0; i < (int)Options::instance->customFilters.size(); ++i)
- {
- if (filterName == Options::instance->customFilters[i].name)
- {
+ for (int i = 0; i < (int)Options::instance->customFilters.size(); ++i) {
+ if (filterName == Options::instance->customFilters[i].name) {
defFilter = i + 2;
if (Options::instance->customFilters[i].onlyIncomming && !Options::instance->customFilters[i].onlyOutgoing)
- {
onlyInFilter = true;
- }
else if (Options::instance->customFilters[i].onlyOutgoing && !Options::instance->customFilters[i].onlyIncomming)
- {
onlyOutFilter = true;
- }
- for(std::vector<int>::iterator it = Options::instance->customFilters[i].events.begin(); it != Options::instance->customFilters[i].events.end(); ++it)
- {
+ for (std::vector<int>::iterator it = Options::instance->customFilters[i].events.begin(); it != Options::instance->customFilters[i].events.end(); ++it)
filterMap[*it] = true;
- }
-
break;
}
}
}
- else
- filterName = L"";
+ else filterName = L"";
}
void EventList::SetDefFilter(int filter)
{
defFilter = filter;
if (filter >= 2 && filter - 2 < (int)Options::instance->customFilters.size())
- {
filterName = Options::instance->customFilters[filter - 2].name;
- }
else if (filter == 1)
- {
filterName = TranslateT("All events");
- }
else
- {
filterName = TranslateT("Default history events");
- }
}
int EventList::GetFilterNr()
@@ -239,15 +197,12 @@ void EventList::GetTempList(std::list<EventTempIndex>& tempList, bool noFilter, ti.isExternal = false;
ei.isExternal = false;
HANDLE hDbEvent = db_event_first(_hContact);
- while ( hDbEvent != NULL )
- {
+ while (hDbEvent != NULL) {
if (isWndLocal && !IsWindow( hWnd ))
break;
ei.hEvent = hDbEvent;
- if (GetEventData(ei, data))
- {
- if (noFilter || CanShowHistory(&gdbei))
- {
+ if (GetEventData(ei, data)) {
+ if (noFilter || CanShowHistory(&gdbei)) {
ti.hEvent = hDbEvent;
ti.timestamp = data.timestamp;
tempList.push_back(ti);
@@ -256,18 +211,14 @@ void EventList::GetTempList(std::list<EventTempIndex>& tempList, bool noFilter, hDbEvent = db_event_next(hDbEvent);
}
- if (!noExt)
- {
+ if (!noExt) {
std::list<EventTempIndex>::iterator itL = tempList.begin();
ti.isExternal = true;
- for(int i = 0; i < (int)importedMessages.size(); ++i)
- {
- if (noFilter || CanShowHistory(importedMessages[i]))
- {
+ for (int i = 0; i < (int)importedMessages.size(); ++i) {
+ if (noFilter || CanShowHistory(importedMessages[i])) {
DWORD ts = importedMessages[i].timestamp;
while(itL != tempList.end() && itL->timestamp < ts)++itL;
- if (itL == tempList.end() || itL->timestamp > ts)
- {
+ if (itL == tempList.end() || itL->timestamp > ts) {
ti.exIdx = i;
ti.timestamp = ts;
tempList.insert(itL, ti);
@@ -282,20 +233,16 @@ void EventList::RefreshEventList() InitNames();
InitFilters();
- if (useImportedMessages)
- {
+ if (useImportedMessages) {
std::vector<IImport::ExternalMessage> messages;
EnterCriticalSection(&criticalSection);
std::map<HANDLE, EventList::ImportDiscData>::iterator it = contactFileMap.find(hContact);
- if (it != contactFileMap.end())
- {
+ if (it != contactFileMap.end()) {
ExportManager imp(hWnd, hContact, 1);
imp.SetAutoImport(it->second.file);
if (!imp.Import(it->second.type, messages, NULL))
- {
messages.clear();
- }
}
LeaveCriticalSection(&criticalSection);
@@ -308,8 +255,7 @@ void EventList::RefreshEventList() std::list<EventTempIndex> revTempList;
std::list<EventTempIndex>& nrTempList = tempList;
bool isNewOnTop = Options::instance->groupNewOnTop;
- if (isNewOnTop)
- {
+ if (isNewOnTop) {
revTempList.insert(revTempList.begin(), tempList.rbegin(), tempList.rend());
nrTempList = revTempList;
}
@@ -321,11 +267,9 @@ void EventList::RefreshEventList() int maxMess = Options::instance->groupMessagesNumber;
int limitator = 0;
EventIndex ei;
- for(std::list<EventTempIndex>::iterator itL = nrTempList.begin(); itL != nrTempList.end(); ++itL)
- {
+ for (std::list<EventTempIndex>::iterator itL = nrTempList.begin(); itL != nrTempList.end(); ++itL) {
DWORD tm = isNewOnTop ? lastTime - itL->timestamp : itL->timestamp - lastTime;
- if (isFlat || tm < groupTime && limitator < maxMess)
- {
+ if (isFlat || tm < groupTime && limitator < maxMess) {
lastTime = itL->timestamp;
ei.isExternal = itL->isExternal;
ei.hEvent = itL->hEvent;
@@ -335,12 +279,10 @@ void EventList::RefreshEventList() eventList.back().push_back(ei);
++limitator;
}
- else
- {
+ else {
limitator = 0;
lastTime = itL->timestamp;
- if (!eventList.back().empty())
- {
+ if (!eventList.back().empty()) {
ei = eventList.back().front();
AddGroup(ei);
eventList.push_back(std::deque<EventIndex>());
@@ -351,8 +293,7 @@ void EventList::RefreshEventList() }
}
- if (!eventList.back().empty())
- {
+ if (!eventList.back().empty()) {
ei = eventList.back().front();
AddGroup(ei);
}
@@ -362,30 +303,22 @@ bool EventList::SearchInContact(HANDLE hContact, TCHAR *strFind, ComparatorInter {
InitFilters();
- if (useImportedMessages)
- {
+ if (useImportedMessages) {
std::vector<IImport::ExternalMessage> messages;
EnterCriticalSection(&criticalSection);
std::map<HANDLE, EventList::ImportDiscData>::iterator it = contactFileMap.find(hContact);
- if (it != contactFileMap.end())
- {
+ if (it != contactFileMap.end()) {
ExportManager imp(hWnd, hContact, 1);
imp.SetAutoImport(it->second.file);
if (!imp.Import(it->second.type, messages, NULL))
- {
messages.clear();
- }
}
LeaveCriticalSection(&criticalSection);
- for(int i = 0; i < (int)importedMessages.size(); ++i)
- {
+ for (int i = 0; i < (int)importedMessages.size(); ++i)
if (compFun->Compare((importedMessages[i].flags & DBEF_SENT) != 0, importedMessages[i].message, strFind))
- {
return true;
- }
- }
}
std::list<EventTempIndex> tempList;
@@ -394,17 +327,13 @@ bool EventList::SearchInContact(HANDLE hContact, TCHAR *strFind, ComparatorInter EventIndex ei;
EventData ed;
TCHAR str[MAXSELECTSTR + 8]; // for safety reason
- for(std::list<EventTempIndex>::iterator itL = tempList.begin(); itL != tempList.end(); ++itL)
- {
+ for (std::list<EventTempIndex>::iterator itL = tempList.begin(); itL != tempList.end(); ++itL) {
ei.isExternal = itL->isExternal;
ei.hEvent = itL->hEvent;
- if (GetEventData(ei, ed))
- {
+ if (GetEventData(ei, ed)) {
GetEventMessage(ei, str);
if (compFun->Compare(ed.isMe, str, strFind))
- {
return true;
- }
}
}
@@ -414,21 +343,17 @@ bool EventList::SearchInContact(HANDLE hContact, TCHAR *strFind, ComparatorInter void EventList::InitNames()
{
TCHAR str[200];
- if (hContact)
- {
+ if (hContact) {
_tcscpy_s(contactName, 256, (TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM) hContact, GCDNF_TCHAR ));
mir_sntprintf(str,200,TranslateT("History for %s"),contactName);
}
- else
- {
+ else {
_tcscpy_s(contactName, 256, TranslateT("System"));
mir_sntprintf(str,200,TranslateT("History"));
}
if (isWnd)
- {
SetWindowText(hWnd,str);
- }
_tcscpy_s(myName, GetMyName().c_str());
}
@@ -448,10 +373,9 @@ void EventList::AddGroup(const EventIndex& ev) else
user = contactName;
GetEventMessage(ev, eventText, 256);
- for(i = 0; eventText[i] != 0 && eventText[i] != _T('\r') && eventText[i] != _T('\n'); ++i);
+ for (i = 0; eventText[i] != 0 && eventText[i] != _T('\r') && eventText[i] != _T('\n'); ++i);
eventText[i] = 0;
- if (i > Options::instance->groupMessageLen)
- {
+ if (i > Options::instance->groupMessageLen) {
eventText[Options::instance->groupMessageLen - 3] = '.';
eventText[Options::instance->groupMessageLen - 2] = '.';
eventText[Options::instance->groupMessageLen - 1] = '.';
@@ -466,33 +390,24 @@ void EventList::AddGroup(const EventIndex& ev) std::wstring EventList::GetContactName()
{
if (hContact)
- {
return (TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM) hContact, GCDNF_TCHAR );
- }
- else
- {
- return TranslateT("System");
- }
+
+ return TranslateT("System");
}
void GetInfo(CONTACTINFO& ci, std::wstring& str)
{
- if (!CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM) & ci))
- {
- if (ci.type == CNFT_ASCIIZ)
- {
+ if (!CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM)&ci)) {
+ if (ci.type == CNFT_ASCIIZ) {
str = ci.pszVal;
mir_free(ci.pszVal);
-
}
- else if (ci.type == CNFT_DWORD)
- {
+ else if (ci.type == CNFT_DWORD) {
TCHAR buf[20];
_ltot_s(ci.dVal, buf, 10 );
str = buf;
}
- else if (ci.type == CNFT_WORD)
- {
+ else if (ci.type == CNFT_WORD) {
TCHAR buf[20];
_ltot_s(ci.wVal, buf, 10 );
str = buf;
@@ -511,9 +426,7 @@ std::wstring EventList::GetMyName() ci.dwFlag = CNF_DISPLAY | CNF_TCHAR;
GetInfo(ci, myName);
if (myName.empty())
- {
return TranslateT("Me");
- }
return myName;
}
@@ -522,11 +435,9 @@ inline std::wstring GetProtocolName(HANDLE hContact) {
char* ac = (char *)CallService(MS_PROTO_GETCONTACTBASEACCOUNT, (WPARAM)hContact, 0);
std::wstring proto1;
- if (ac != NULL)
- {
+ if (ac != NULL) {
PROTOACCOUNT* acnt = ProtoGetAccount(ac);
- if (acnt != NULL && acnt->szModuleName != NULL)
- {
+ if (acnt != NULL && acnt->szModuleName != NULL) {
wchar_t* proto = mir_a2u(acnt->szProtoName);
proto1 = proto;
mir_free(proto);
@@ -616,16 +527,14 @@ static void GetAuthRequestDescription( DBEVENTINFO *dbei, TCHAR* buf, int cbBuf return;
reason = (char*)dbei->pBlob + pos;
TCHAR *newNick, *newFirstName, *newLastName, *newJid, *newReason;
- if (dbei->flags & DBEF_UTF)
- {
+ if (dbei->flags & DBEF_UTF) {
newNick = mir_utf8decodeT( nick );
newFirstName = mir_utf8decodeT( firstName );
newLastName = mir_utf8decodeT( lastName );
newJid = mir_utf8decodeT( jid );
newReason = mir_utf8decodeT( reason );
}
- else
- {
+ else {
newNick = mir_a2t( nick );
newFirstName = mir_a2t( firstName );
newLastName = mir_a2t( lastName );
@@ -633,8 +542,7 @@ static void GetAuthRequestDescription( DBEVENTINFO *dbei, TCHAR* buf, int cbBuf newReason = mir_a2t( reason );
}
- if (newFirstName[0] != 0)
- {
+ if (newFirstName[0] != 0) {
allName += newFirstName;
if (newLastName[0] != 0)
allName += _T(" ");
@@ -644,8 +552,7 @@ static void GetAuthRequestDescription( DBEVENTINFO *dbei, TCHAR* buf, int cbBuf allName += newLastName;
if (!allName.empty())
allName += _T(", ");
- if (newJid[0] != 0)
- {
+ if (newJid[0] != 0) {
allName += newJid;
allName += _T(", ");
}
@@ -662,7 +569,7 @@ static void GetAuthRequestDescription( DBEVENTINFO *dbei, TCHAR* buf, int cbBuf void EventList::GetObjectDescription( DBEVENTINFO *dbei, TCHAR* str, int cbStr )
{
- switch( dbei->eventType ) {
+ switch(dbei->eventType) {
case EVENTTYPE_AUTHREQUEST:
GetAuthRequestDescription( dbei, str, cbStr );
break;
@@ -674,8 +581,7 @@ void EventList::GetObjectDescription( DBEVENTINFO *dbei, TCHAR* str, int cbStr ) bool EventList::GetEventIcon(bool isMe, int eventType, int &id)
{
- switch(eventType)
- {
+ switch(eventType) {
case EVENTTYPE_MESSAGE:
id = isMe ? 1 : 0;
return true;
@@ -701,10 +607,8 @@ void EventList::ImportMessages(const std::vector<IImport::ExternalMessage>& mess {
DWORD lastTime = 0;
importedMessages.clear();
- for(int i = 0; i < (int)messages.size(); ++i)
- {
- if (messages[i].timestamp >= lastTime)
- {
+ for (int i = 0; i < (int)messages.size(); ++i) {
+ if (messages[i].timestamp >= lastTime) {
importedMessages.push_back(messages[i]);
lastTime = messages[i].timestamp;
}
@@ -725,7 +629,7 @@ void EventList::MargeMessages(const std::vector<IImport::ExternalMessage>& messa dbei.szModule = GetContactProto(hContact);
CallService(MS_DB_SETSAFETYMODE, (WPARAM)FALSE, 0);
- for(std::list<EventTempIndex>::iterator it = tempList.begin(); it != tempList.end(); ++it) {
+ for (std::list<EventTempIndex>::iterator it = tempList.begin(); it != tempList.end(); ++it) {
if (it->isExternal) {
IImport::ExternalMessage& msg = importedMessages[it->exIdx];
dbei.flags = msg.flags & (~(DBEF_FIRST));
@@ -802,8 +706,7 @@ HICON EventList::GetEventCoreIcon(const EventIndex& ev) void EventList::RebuildGroup(int selected)
{
std::deque<EventIndex> newGroup;
- for(size_t i = 0; i < eventList[selected].size(); ++i)
- {
+ for (size_t i = 0; i < eventList[selected].size(); ++i) {
EventIndex& ev = eventList[selected][i];
if (!ev.isExternal) {
// If event exist, we add it to new group
@@ -869,9 +772,7 @@ bool EventList::IsImportedHistory(HANDLE hContact) EnterCriticalSection(&criticalSection);
std::map<HANDLE, EventList::ImportDiscData>::iterator it = contactFileMap.find(hContact);
if (it != contactFileMap.end())
- {
count = true;
- }
LeaveCriticalSection(&criticalSection);
return count;
@@ -881,8 +782,7 @@ void EventList::DeleteImporter(HANDLE hContact) {
EnterCriticalSection(&criticalSection);
std::map<HANDLE, EventList::ImportDiscData>::iterator it = contactFileMap.find(hContact);
- if (it != contactFileMap.end())
- {
+ if (it != contactFileMap.end()) {
DeleteFile(it->second.file.c_str());
contactFileMap.erase(it);
}
diff --git a/plugins/BasicHistory/src/ExportManager.cpp b/plugins/BasicHistory/src/ExportManager.cpp index f7cb30b8dd..8107e09621 100644 --- a/plugins/BasicHistory/src/ExportManager.cpp +++ b/plugins/BasicHistory/src/ExportManager.cpp @@ -60,21 +60,15 @@ std::wstring GetFile(const TCHAR* ext, HWND hwnd, bool open) ofn.lpstrTitle = open ? TranslateT("Import") : TranslateT("Export");
ofn.nMaxFile = 1024;
ofn.lpstrDefExt = ext;
- if (open)
- {
+ if (open) {
ofn.Flags = OFN_PATHMUSTEXIST | OFN_EXPLORER | OFN_NOCHANGEDIR | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
if (GetOpenFileName(&ofn))
- {
return stzFilePath;
- }
}
- else
- {
+ else {
ofn.Flags = OFN_NOREADONLYRETURN | OFN_PATHMUSTEXIST | OFN_EXPLORER | OFN_OVERWRITEPROMPT | OFN_NOCHANGEDIR;
if (GetSaveFileName(&ofn))
- {
return stzFilePath;
- }
}
return L"";
@@ -83,8 +77,7 @@ std::wstring GetFile(const TCHAR* ext, HWND hwnd, bool open) std::wstring ReplaceExt(const std::wstring& file, const TCHAR* ext)
{
size_t pos = file.find(_T("<ext>"));
- if (pos < file.length())
- {
+ if (pos < file.length()) {
std::wstring fileName = file.substr(0, pos);
fileName += ext;
fileName += file.substr(pos + 5);
@@ -100,8 +93,7 @@ bool ExportManager::Export(IExport::ExportType type) UINT cp;
std::wstring encoding;
bool isBin = false;
- switch(type)
- {
+ switch(type) {
case IExport::Txt:
exp = new TxtExport();
cp = Options::instance->codepageTxt;
@@ -142,16 +134,13 @@ bool ExportManager::Export(IExport::ExportType type) if (file.empty())
fileName = GetFile(exp->GetExt(), hwnd, false);
else
- {
fileName = ReplaceExt(file, exp->GetExt());
- }
if (fileName.empty())
return false;
std::wofstream* stream;
- if (!isBin)
- {
+ if (!isBin) {
stream = new std::wofstream (fileName.c_str());
if (!stream->is_open())
return false;
@@ -160,8 +149,7 @@ bool ExportManager::Export(IExport::ExportType type) stream->imbue(filelocale);
exp->SetStream(stream);
}
- else
- {
+ else {
std::ofstream* cstream = new std::ofstream (fileName.c_str(), std::ios_base::binary);
if (!cstream->is_open())
return false;
@@ -175,13 +163,11 @@ bool ExportManager::Export(IExport::ExportType type) RefreshEventList();
exp->WriteFooter();
- if (!isBin)
- {
+ if (!isBin) {
stream->close();
delete stream;
}
- else
- {
+ else {
std::ofstream* cstream = (std::ofstream*)stream;
cstream->close();
delete cstream;
@@ -194,8 +180,7 @@ bool ExportManager::Export(IExport::ExportType type) const TCHAR* ExportManager::GetExt(IImport::ImportType type)
{
IImport* imp = NULL;
- switch(type)
- {
+ switch(type) {
case IImport::Binary:
imp = new BinaryExport();
break;
@@ -214,8 +199,7 @@ const TCHAR* ExportManager::GetExt(IImport::ImportType type) int ExportManager::Import(IImport::ImportType type, const std::vector<HANDLE>& contacts)
{
IImport* imp = NULL;
- switch(type)
- {
+ switch(type) {
case IImport::Binary:
imp = new BinaryExport();
break;
@@ -252,8 +236,7 @@ int ExportManager::Import(IImport::ImportType type, const std::vector<HANDLE>& c bool ExportManager::Import(IImport::ImportType type, std::vector<IImport::ExternalMessage>& eventList, std::wstring* err, bool* differentContact, std::vector<HANDLE>* contacts)
{
IImport* imp = NULL;
- switch(type)
- {
+ switch(type) {
case IImport::Binary:
imp = new BinaryExport();
break;
@@ -268,9 +251,7 @@ bool ExportManager::Import(IImport::ImportType type, std::vector<IImport::Extern if (file.empty())
file = fileName = GetFile(imp->GetExt(), hwnd, true);
else
- {
fileName = ReplaceExt(file, imp->GetExt());
- }
std::ifstream* stream = new std::ifstream (fileName.c_str(), std::ios_base::binary);
if (!stream->is_open())
@@ -281,29 +262,25 @@ bool ExportManager::Import(IImport::ImportType type, std::vector<IImport::Extern v.push_back(hContact);
bool ret = true;
int contInFile = imp->IsContactInFile(v);
- if (contInFile == -1)
- {
+ if (contInFile == -1) {
ret = false;
if (err != NULL)
*err = TranslateT("File do not contain selected contact");
- if (contacts != NULL && differentContact != NULL)
- {
+
+ if (contacts != NULL && differentContact != NULL) {
contInFile = imp->IsContactInFile(*contacts);
- if (contInFile >= 0)
- {
+ if (contInFile >= 0) {
*differentContact = true;
hContact = (*contacts)[contInFile];
}
}
}
- else if (contInFile == 0 || contInFile == -3)
- {
+ else if (contInFile == 0 || contInFile == -3) {
ret = imp->GetEventList(eventList);
if (!ret && err != NULL)
*err = TranslateT("File is corrupted");
}
- else
- {
+ else {
ret = false;
if (err != NULL)
*err = TranslateT("File is corrupted");
@@ -318,6 +295,7 @@ void ExportManager::AddGroup(bool isMe, const std::wstring &time, const std::wst {
if (exp == NULL)
return;
+
exp->WriteGroup(isMe, time, user, eventText);
TCHAR str[MAXSELECTSTR + 8]; // for safety reason
str[0] = 0;
@@ -327,31 +305,25 @@ void ExportManager::AddGroup(bool isMe, const std::wstring &time, const std::wst EventData data;
std::deque<EventIndex> revDeq;
std::deque<EventIndex>& deq = eventList.back();
- if (!oldOnTop && Options::instance->messagesNewOnTop)
- {
+ if (!oldOnTop && Options::instance->messagesNewOnTop) {
revDeq.insert(revDeq.begin(), deq.rbegin(), deq.rend());
deq = revDeq;
}
- for(std::deque<EventIndex>::iterator it = deq.begin(); it != deq.end(); ++it)
- {
+ for (std::deque<EventIndex>::iterator it = deq.begin(); it != deq.end(); ++it) {
EventIndex hDbEvent = *it;
- if (GetEventData(hDbEvent, data))
- {
+ if (GetEventData(hDbEvent, data)) {
lastMe = data.isMe;
TCHAR* formatDate = Options::instance->messagesShowSec ? _T("d s") : _T("d t");
TCHAR* longFormatDate = Options::instance->messagesShowSec ? _T("d s") : _T("d t");
- if (!Options::instance->messagesShowDate)
- {
- if (isFirst)
- {
+ if (!Options::instance->messagesShowDate) {
+ if (isFirst) {
isFirst = false;
formatDate = Options::instance->messagesShowSec ? _T("s") : _T("t");
time_t tt = data.timestamp;
localtime_s(&lastTime, &tt);
}
- else
- {
+ else {
time_t tt = data.timestamp;
tm t;
localtime_s(&t, &tt);
@@ -377,9 +349,7 @@ void ExportManager::AddGroup(bool isMe, const std::wstring &time, const std::wst continue;
if (hDbEvent.isExternal)
- {
GetExtEventDBei(hDbEvent);
- }
exp->WriteMessage(lastMe, longDate, shortDate, user, strMessage, gdbei);
}
@@ -388,13 +358,9 @@ void ExportManager::AddGroup(bool isMe, const std::wstring &time, const std::wst void ExportManager::DeleteExportedEvents()
{
- for(size_t j = 0; j < eventList.size(); ++j)
- {
- for(size_t i = 0; i < eventList[j].size(); ++i)
- {
+ for (size_t j = 0; j < eventList.size(); ++j)
+ for (size_t i = 0; i < eventList[j].size(); ++i)
DeleteEvent(eventList[j][i]);
- }
- }
}
void ExportManager::SetDeleteWithoutExportEvents(int _deltaTime, DWORD _now)
diff --git a/plugins/BasicHistory/src/HistoryWindow.cpp b/plugins/BasicHistory/src/HistoryWindow.cpp index 6c34d6838e..589265cab1 100644 --- a/plugins/BasicHistory/src/HistoryWindow.cpp +++ b/plugins/BasicHistory/src/HistoryWindow.cpp @@ -80,7 +80,7 @@ HistoryWindow::~HistoryWindow() {
if (eventIcons != NULL)
{
- for(int i = 0; i < iconsNum; ++i)
+ for (int i = 0; i < iconsNum; ++i)
if (eventIcons[i] != NULL)
Skin_ReleaseIcon(eventIcons[i]);
@@ -119,14 +119,14 @@ void HistoryWindow::Deinit() {
bool destroyed = true;
std::vector<HANDLE> keys;
- for(std::map<HANDLE, HistoryWindow*>::iterator it = windows.begin(); it != windows.end(); ++it)
+ for (std::map<HANDLE, HistoryWindow*>::iterator it = windows.begin(); it != windows.end(); ++it)
{
if (!it->second->isDestroyed)
{
keys.push_back(it->first);
}
}
- for(std::vector<HANDLE>::iterator it = keys.begin(); it != keys.end(); ++it)
+ for (std::vector<HANDLE>::iterator it = keys.begin(); it != keys.end(); ++it)
{
std::map<HANDLE, HistoryWindow*>::iterator it1 = windows.find(*it);
if (it1 != windows.end())
@@ -138,18 +138,18 @@ void HistoryWindow::Deinit() }
std::vector<HistoryWindow*> keys1;
- for(std::vector<HistoryWindow*>::iterator it = freeWindows.begin(); it != freeWindows.end(); ++it)
+ for (std::vector<HistoryWindow*>::iterator it = freeWindows.begin(); it != freeWindows.end(); ++it)
{
if (!(*it)->isDestroyed)
{
keys1.push_back(*it);
}
}
- for(std::vector<HistoryWindow*>::iterator it = keys1.begin(); it != keys1.end(); ++it)
+ for (std::vector<HistoryWindow*>::iterator it = keys1.begin(); it != keys1.end(); ++it)
{
DestroyWindow((*it)->hWnd);
}
- for(std::vector<HistoryWindow*>::iterator it = freeWindows.begin(); it != freeWindows.end(); ++it)
+ for (std::vector<HistoryWindow*>::iterator it = freeWindows.begin(); it != freeWindows.end(); ++it)
{
if (!(*it)->isDestroyed)
{
@@ -160,14 +160,14 @@ void HistoryWindow::Deinit() if (destroyed)
{
- for(std::map<HANDLE, HistoryWindow*>::iterator it = windows.begin(); it != windows.end(); ++it)
+ for (std::map<HANDLE, HistoryWindow*>::iterator it = windows.begin(); it != windows.end(); ++it)
{
delete it->second;
}
windows.clear();
- for(std::vector<HistoryWindow*>::iterator it = freeWindows.begin(); it != freeWindows.end(); ++it)
+ for (std::vector<HistoryWindow*>::iterator it = freeWindows.begin(); it != freeWindows.end(); ++it)
{
delete *it;
}
@@ -231,7 +231,7 @@ void HistoryWindow::Close(HistoryWindow* historyWindow) }
else
{
- for(std::vector<HistoryWindow*>::iterator it = freeWindows.begin(); it != freeWindows.end(); ++it)
+ for (std::vector<HistoryWindow*>::iterator it = freeWindows.begin(); it != freeWindows.end(); ++it)
{
if (*it == historyWindow)
{
@@ -254,7 +254,7 @@ void HistoryWindow::RebuildEvents(HANDLE hContact) }
}
- for(std::vector<HistoryWindow*>::iterator it = freeWindows.begin(); it != freeWindows.end(); ++it)
+ for (std::vector<HistoryWindow*>::iterator it = freeWindows.begin(); it != freeWindows.end(); ++it)
{
if ((*it)->hContact == hContact && !(*it)->isDestroyed)
{
@@ -294,7 +294,7 @@ void HistoryWindow::Focus() int HistoryWindow::FontsChanged(WPARAM wParam, LPARAM lParam)
{
- for(std::map<HANDLE, HistoryWindow*>::iterator it = windows.begin(); it != windows.end(); ++it)
+ for (std::map<HANDLE, HistoryWindow*>::iterator it = windows.begin(); it != windows.end(); ++it)
{
if (!it->second->isDestroyed)
{
@@ -302,7 +302,7 @@ int HistoryWindow::FontsChanged(WPARAM wParam, LPARAM lParam) }
}
- for(std::vector<HistoryWindow*>::iterator it = freeWindows.begin(); it != freeWindows.end(); ++it)
+ for (std::vector<HistoryWindow*>::iterator it = freeWindows.begin(); it != freeWindows.end(); ++it)
{
if (!(*it)->isDestroyed)
{
@@ -345,7 +345,7 @@ void OptionsGroupChanged() void HistoryWindow::OptionsGroupChanged()
{
- for(std::map<HANDLE, HistoryWindow*>::iterator it = windows.begin(); it != windows.end(); ++it)
+ for (std::map<HANDLE, HistoryWindow*>::iterator it = windows.begin(); it != windows.end(); ++it)
{
if (!it->second->isDestroyed)
{
@@ -354,7 +354,7 @@ void HistoryWindow::OptionsGroupChanged() }
}
- for(std::vector<HistoryWindow*>::iterator it = freeWindows.begin(); it != freeWindows.end(); ++it)
+ for (std::vector<HistoryWindow*>::iterator it = freeWindows.begin(); it != freeWindows.end(); ++it)
{
if (!(*it)->isDestroyed)
{
@@ -371,7 +371,7 @@ void OptionsMainChanged() void HistoryWindow::OptionsMainChanged()
{
- for(std::map<HANDLE, HistoryWindow*>::iterator it = windows.begin(); it != windows.end(); ++it)
+ for (std::map<HANDLE, HistoryWindow*>::iterator it = windows.begin(); it != windows.end(); ++it)
{
if (!it->second->isDestroyed)
{
@@ -379,7 +379,7 @@ void HistoryWindow::OptionsMainChanged() }
}
- for(std::vector<HistoryWindow*>::iterator it = freeWindows.begin(); it != freeWindows.end(); ++it)
+ for (std::vector<HistoryWindow*>::iterator it = freeWindows.begin(); it != freeWindows.end(); ++it)
{
if (!(*it)->isDestroyed)
{
@@ -406,7 +406,7 @@ void OptionsSearchingChanged() void HistoryWindow::OptionsSearchingChanged()
{
- for(std::map<HANDLE, HistoryWindow*>::iterator it = windows.begin(); it != windows.end(); ++it)
+ for (std::map<HANDLE, HistoryWindow*>::iterator it = windows.begin(); it != windows.end(); ++it)
{
if (!it->second->isDestroyed)
{
@@ -415,7 +415,7 @@ void HistoryWindow::OptionsSearchingChanged() }
}
- for(std::vector<HistoryWindow*>::iterator it = freeWindows.begin(); it != freeWindows.end(); ++it)
+ for (std::vector<HistoryWindow*>::iterator it = freeWindows.begin(); it != freeWindows.end(); ++it)
{
if (!(*it)->isDestroyed)
{
@@ -435,7 +435,7 @@ INT_PTR HistoryWindow::DeleteAllUserHistory(WPARAM wParam, LPARAM) if (!count)
return FALSE;
- for(std::map<HANDLE, HistoryWindow*>::iterator it = windows.begin(); it != windows.end(); ++it)
+ for (std::map<HANDLE, HistoryWindow*>::iterator it = windows.begin(); it != windows.end(); ++it)
{
if (!it->second->isDestroyed)
{
@@ -453,7 +453,7 @@ INT_PTR HistoryWindow::DeleteAllUserHistory(WPARAM wParam, LPARAM) }
}
- for(std::vector<HistoryWindow*>::iterator it = freeWindows.begin(); it != freeWindows.end(); ++it)
+ for (std::vector<HistoryWindow*>::iterator it = freeWindows.begin(); it != freeWindows.end(); ++it)
{
if (!(*it)->isDestroyed)
{
@@ -495,27 +495,15 @@ INT_PTR HistoryWindow::DeleteAllUserHistory(WPARAM wParam, LPARAM) bool HistoryWindow::IsInList(HWND hWnd)
{
- for(std::map<HANDLE, HistoryWindow*>::iterator it = windows.begin(); it != windows.end(); ++it)
- {
+ for (std::map<HANDLE, HistoryWindow*>::iterator it = windows.begin(); it != windows.end(); ++it)
if (!it->second->isDestroyed)
- {
if (it->second->hWnd == hWnd)
- {
return true;
- }
- }
- }
- for(std::vector<HistoryWindow*>::iterator it = freeWindows.begin(); it != freeWindows.end(); ++it)
- {
+ for (std::vector<HistoryWindow*>::iterator it = freeWindows.begin(); it != freeWindows.end(); ++it)
if (!(*it)->isDestroyed)
- {
if ((*it)->hWnd == hWnd)
- {
return true;
- }
- }
- }
return false;
}
@@ -525,12 +513,11 @@ void ClickLink(HWND hwnd, ENLINK *penLink) TCHAR buf[1024];
if (penLink->msg != WM_LBUTTONUP)
return;
- if (penLink->chrg.cpMin >= 0 && penLink->chrg.cpMax > penLink->chrg.cpMin)
- {
+
+ if (penLink->chrg.cpMin >= 0 && penLink->chrg.cpMax > penLink->chrg.cpMin) {
// selection
int len = penLink->chrg.cpMax - penLink->chrg.cpMin;
- if (len < 1023)
- {
+ if (len < 1023) {
TEXTRANGE tr;
CHARRANGE sel;
@@ -608,24 +595,35 @@ void __stdcall ShowMessageWindow(void* arg) INT_PTR CALLBACK HistoryWindow::DlgProcHistory(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
+ HistoryWindow* historyWindow = (HistoryWindow*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+ LPNMHDR pNmhdr;
+
switch (msg) {
+ case WM_INITDIALOG:
+ TranslateDialogDefault(hwndDlg);
+ historyWindow = (HistoryWindow*)lParam;
+ historyWindow->hWnd = hwndDlg;
+ historyWindow->isWnd = true;
+ SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)lParam);
+ historyWindow->Initialise();
+ DlgReturn(TRUE);
+
case WM_GETMINMAXINFO:
- ((MINMAXINFO*)lParam)->ptMinTrackSize.x=500;
- ((MINMAXINFO*)lParam)->ptMinTrackSize.y=380;
+ ((MINMAXINFO*)lParam)->ptMinTrackSize.x = 500;
+ ((MINMAXINFO*)lParam)->ptMinTrackSize.y = 380;
case WM_SIZE:
{
- UTILRESIZEDIALOG urd={0};
- urd.cbSize=sizeof(urd);
- urd.hwndDlg=hwndDlg;
- urd.hInstance=hInst;
- urd.lpTemplate=MAKEINTRESOURCEA(IDD_HISTORY);
- urd.lParam=0;
- urd.pfnResizer=HistoryWindow::HistoryDlgResizer;
- CallService(MS_UTILS_RESIZEDIALOG,0,(LPARAM)&urd);
+ UTILRESIZEDIALOG urd = { sizeof(urd) };
+ urd.hwndDlg = hwndDlg;
+ urd.hInstance = hInst;
+ urd.lpTemplate = MAKEINTRESOURCEA(IDD_HISTORY);
+ urd.pfnResizer = HistoryWindow::HistoryDlgResizer;
+ CallService(MS_UTILS_RESIZEDIALOG, 0, (LPARAM)&urd);
ListView_SetColumnWidth(GetDlgItem(hwndDlg,IDC_LIST), 0, LVSCW_AUTOSIZE_USEHEADER);
- DlgReturn(TRUE);
}
+ DlgReturn(TRUE);
+
case WM_COMMAND:
switch ( LOWORD( wParam )) {
case IDOK:
@@ -634,528 +632,414 @@ INT_PTR CALLBACK HistoryWindow::DlgProcHistory(HWND hwndDlg, UINT msg, WPARAM wP DlgReturn(TRUE);
case IDM_FIND:
- {
- HistoryWindow* historyWindow =(HistoryWindow*)GetWindowLongPtr(hwndDlg,GWLP_USERDATA);
- historyWindow->searcher.Find();
- DlgReturn(TRUE);
- }
+ historyWindow->searcher.Find();
+ DlgReturn(TRUE);
case IDM_CONFIG:
{
OPENOPTIONSDIALOG opd = {0};
- opd.cbSize = sizeof(OPENOPTIONSDIALOG);
+ opd.cbSize = sizeof(opd);
opd.pszPage = LPGEN("History");
Options_Open(&opd);
- DlgReturn(TRUE);
}
+ DlgReturn(TRUE);
case IDM_DELETE:
- {
- HistoryWindow* historyWindow =(HistoryWindow*)GetWindowLongPtr(hwndDlg,GWLP_USERDATA);
- historyWindow->Delete(0);
- DlgReturn(TRUE);
- }
+ historyWindow->Delete(0);
+ DlgReturn(TRUE);
case IDC_FIND_TEXT:
if (HIWORD(wParam) == EN_CHANGE)
- {
- HistoryWindow* historyWindow =(HistoryWindow*)GetWindowLongPtr(hwndDlg,GWLP_USERDATA);
historyWindow->searcher.ClearFind();
- }
-
DlgReturn(TRUE);
case IDC_SHOWHIDE:
- {
- if (HIWORD( wParam ) == BN_CLICKED)
- {
- HistoryWindow* historyWindow =(HistoryWindow*)GetWindowLongPtr(hwndDlg,GWLP_USERDATA);
- if (Button_GetCheck(GetDlgItem(hwndDlg,IDC_SHOWHIDE)) & BST_CHECKED)
- {
- SendDlgItemMessage( hwndDlg, IDC_SHOWHIDE, BM_SETIMAGE, IMAGE_ICON, (LPARAM)historyWindow->minusIco);
- SendDlgItemMessage( hwndDlg, IDC_SHOWHIDE, BUTTONADDTOOLTIP, (WPARAM)LPGENT("Hide Contacts"), BATF_TCHAR);
- historyWindow->isContactList = true;
- ShowWindow(GetDlgItem(hwndDlg,IDC_LIST_CONTACTS), SW_SHOW);
- ShowWindow(historyWindow->splitterYhWnd, SW_SHOW);
- }
- else
- {
- SendDlgItemMessage( hwndDlg, IDC_SHOWHIDE, BM_SETIMAGE, IMAGE_ICON, (LPARAM)historyWindow->plusIco);
- SendDlgItemMessage( hwndDlg, IDC_SHOWHIDE, BUTTONADDTOOLTIP, (WPARAM)LPGENT("Show Contacts"), BATF_TCHAR);
- historyWindow->isContactList = false;
- ShowWindow(GetDlgItem(hwndDlg,IDC_LIST_CONTACTS), SW_HIDE);
- ShowWindow(historyWindow->splitterYhWnd, SW_HIDE);
- }
-
- SendMessage(hwndDlg, WM_SIZE, 0, 0);
+ if (HIWORD( wParam ) == BN_CLICKED) {
+ if (Button_GetCheck(GetDlgItem(hwndDlg,IDC_SHOWHIDE)) & BST_CHECKED) {
+ SendDlgItemMessage( hwndDlg, IDC_SHOWHIDE, BM_SETIMAGE, IMAGE_ICON, (LPARAM)historyWindow->minusIco);
+ SendDlgItemMessage( hwndDlg, IDC_SHOWHIDE, BUTTONADDTOOLTIP, (WPARAM)LPGENT("Hide Contacts"), BATF_TCHAR);
+ historyWindow->isContactList = true;
+ ShowWindow(GetDlgItem(hwndDlg,IDC_LIST_CONTACTS), SW_SHOW);
+ ShowWindow(historyWindow->splitterYhWnd, SW_SHOW);
+ }
+ else {
+ SendDlgItemMessage( hwndDlg, IDC_SHOWHIDE, BM_SETIMAGE, IMAGE_ICON, (LPARAM)historyWindow->plusIco);
+ SendDlgItemMessage( hwndDlg, IDC_SHOWHIDE, BUTTONADDTOOLTIP, (WPARAM)LPGENT("Show Contacts"), BATF_TCHAR);
+ historyWindow->isContactList = false;
+ ShowWindow(GetDlgItem(hwndDlg,IDC_LIST_CONTACTS), SW_HIDE);
+ ShowWindow(historyWindow->splitterYhWnd, SW_HIDE);
}
- DlgReturn(TRUE);
+ SendMessage(hwndDlg, WM_SIZE, 0, 0);
}
+
+ DlgReturn(TRUE);
}
break;
+
case WM_NOTIFY:
- {
- LPNMHDR pNmhdr;
+ pNmhdr = (LPNMHDR)lParam;
+ switch(pNmhdr->idFrom) {
+ case IDC_LIST_CONTACTS:
+ if (pNmhdr->code == CLN_LISTREBUILT) {
+ if (historyWindow != NULL)
+ historyWindow->ReloadContacts();
- pNmhdr = (LPNMHDR)lParam;
- switch(pNmhdr->idFrom)
- {
- case IDC_LIST_CONTACTS:
- if (pNmhdr->code == CLN_LISTREBUILT)
- {
- HistoryWindow* historyWindow =(HistoryWindow*)GetWindowLongPtr(hwndDlg,GWLP_USERDATA);
- if (historyWindow != NULL)
- {
- historyWindow->ReloadContacts();
- }
+ DlgReturn(TRUE);
+ }
+ else if (pNmhdr->code == CLN_MYSELCHANGED) {
+ if (historyWindow->ContactChanged()) {
+ MSGFILTER* msgFilter = (MSGFILTER *) lParam;
+ if (msgFilter->msg == WM_LBUTTONDOWN)
+ SendMessage(pNmhdr->hwndFrom, WM_LBUTTONUP, msgFilter->wParam, msgFilter->lParam);
+ }
- DlgReturn(TRUE);
- }
- else if (pNmhdr->code == CLN_MYSELCHANGED)
- {
- HistoryWindow* historyWindow =(HistoryWindow*)GetWindowLongPtr(hwndDlg,GWLP_USERDATA);
- if (historyWindow->ContactChanged())
- {
- MSGFILTER* msgFilter = (MSGFILTER *) lParam;
- if (msgFilter->msg == WM_LBUTTONDOWN)
- {
- SendMessage(pNmhdr->hwndFrom, WM_LBUTTONUP, msgFilter->wParam, msgFilter->lParam);
- }
- }
+ DlgReturn(TRUE);
+ }
+ else if (pNmhdr->code == CLN_OPTIONSCHANGED) {
+ ResetCList(hwndDlg);
+ return FALSE;
+ }
+ //fall through
+ case IDC_SHOWHIDE:
+ case IDC_FIND_TEXT:
+ case IDC_EDIT:
+ if (pNmhdr->code == EN_LINK) {
+ ClickLink(GetDlgItem(hwndDlg, IDC_EDIT), (ENLINK *) lParam);
+ return FALSE;
+ }
+ if (pNmhdr->code == EN_SELCHANGE)
+ historyWindow->searcher.ClearFind();
+ else if (pNmhdr->code == EN_MSGFILTER) {
+ MSGFILTER* msgFilter = (MSGFILTER *) lParam;
+ if (msgFilter->msg == WM_KEYDOWN || msgFilter->msg == WM_SYSKEYDOWN)
+ {
+ if (historyWindow->DoHotkey(msgFilter->msg, msgFilter->lParam, msgFilter->wParam, pNmhdr->idFrom))
DlgReturn(TRUE);
+ }
+ else if (msgFilter->msg == WM_RBUTTONDOWN || msgFilter->msg == WM_RBUTTONDBLCLK || msgFilter->msg == WM_NCRBUTTONUP || msgFilter->msg == WM_NCRBUTTONDBLCLK || msgFilter->msg == WM_NCRBUTTONDOWN)
+ DlgReturn(TRUE);
+
+ if (msgFilter->msg == WM_RBUTTONUP) {
+ POINT clicked;
+ LPNMITEMACTIVATE nmlv = (LPNMITEMACTIVATE)lParam;
+ HWND window = historyWindow->editWindow;
+ POINTL p;
+ POINT scrool;
+ LVHITTESTINFO info = {0};
+ p.x = clicked.x = info.pt.x = GET_X_LPARAM(msgFilter->lParam);
+ p.y = clicked.y = info.pt.y = GET_Y_LPARAM(msgFilter->lParam);
+ ClientToScreen(window, &clicked);
+ SetFocus(window);
+ int selChar = SendMessage(window, EM_CHARFROMPOS, 0, (LPARAM)&p);
+ CHARRANGE chrg;
+ SendMessage(window,EM_EXGETSEL,0,(LPARAM)&chrg);
+ SendMessage(window,EM_GETSCROLLPOS,0,(LPARAM)&scrool);
+ if (selChar < chrg.cpMin || selChar > chrg.cpMax)
+ chrg.cpMin = chrg.cpMax = selChar;
+
+ if (chrg.cpMin == chrg.cpMax) {
+ CHARRANGE chrgNew;
+ chrgNew.cpMin = chrg.cpMin;
+ chrgNew.cpMax = chrg.cpMax + 1;
+ SendMessage(window,EM_EXSETSEL,0,(LPARAM)&chrgNew);
}
- else if (pNmhdr->code == CLN_OPTIONSCHANGED)
- {
- ResetCList(hwndDlg);
- return FALSE;
- }
-
- //fall through
- //case IDC_LIST_CONTACTS:
- case IDC_SHOWHIDE:
- case IDC_FIND_TEXT:
- case IDC_EDIT:
- if ( pNmhdr->code == EN_LINK )
- {
- ClickLink(GetDlgItem(hwndDlg, IDC_EDIT), (ENLINK *) lParam);
- return FALSE;
- }
- else if ( pNmhdr->code == EN_SELCHANGE)
- {
- HistoryWindow* historyWindow =(HistoryWindow*)GetWindowLongPtr(hwndDlg,GWLP_USERDATA);
- historyWindow->searcher.ClearFind();
- }
- else if (pNmhdr->code == EN_MSGFILTER)
- {
- MSGFILTER* msgFilter = (MSGFILTER *) lParam;
- if (msgFilter->msg == WM_KEYDOWN || msgFilter->msg == WM_SYSKEYDOWN)
- {
- HistoryWindow* historyWindow =(HistoryWindow*)GetWindowLongPtr(hwndDlg,GWLP_USERDATA);
- if (historyWindow->DoHotkey(msgFilter->msg, msgFilter->lParam, msgFilter->wParam, pNmhdr->idFrom))
- DlgReturn(TRUE);
+ CHARFORMAT2 chf;
+ memset(&chf, 0, sizeof(CHARFORMAT2));
+ chf.cbSize = sizeof(CHARFORMAT2);
+ chf.dwMask = CFM_LINK;
+ SendMessage(window, EM_GETCHARFORMAT, SCF_SELECTION, (LPARAM)&chf);
+ if (chrg.cpMin == chrg.cpMax)
+ SendMessage(window,EM_EXSETSEL,0,(LPARAM)&chrg);
+
+ HMENU hPopupMenu = CreatePopupMenu();
+ if (hPopupMenu != NULL) {
+ if (chf.dwEffects & CFE_LINK) {
+ AppendMenu(hPopupMenu, MF_STRING, IDM_OPENNEW, TranslateT("Open in &new window"));
+ AppendMenu(hPopupMenu, MF_STRING, IDM_OPENEXISTING, TranslateT("&Open in existing window"));
+ AppendMenu(hPopupMenu, MF_STRING, IDM_COPYLINK, TranslateT("&Copy link"));
}
- else if (msgFilter->msg == WM_RBUTTONDOWN || msgFilter->msg == WM_RBUTTONDBLCLK || msgFilter->msg == WM_NCRBUTTONUP || msgFilter->msg == WM_NCRBUTTONDBLCLK || msgFilter->msg == WM_NCRBUTTONDOWN)
- {
- DlgReturn(TRUE);
+ else {
+ AppendMenu(hPopupMenu, MF_STRING, IDM_COPY, TranslateT("Copy"));
+ AppendMenu(hPopupMenu, MF_STRING, IDM_DELETE, TranslateT("Delete"));
+ AppendMenu(hPopupMenu, MFT_SEPARATOR, 0, NULL);
+ AppendMenu(hPopupMenu, MF_STRING, IDM_MESSAGE, TranslateT("Send Message"));
+ AppendMenu(hPopupMenu, MF_STRING, IDM_QUOTE, TranslateT("Reply &Quoted"));
+ AppendMenu(hPopupMenu, MF_STRING, IDM_DELETEGROUP, TranslateT("Delete Group"));
+ AppendMenu(hPopupMenu, MF_STRING, IDM_DELETEUSER, TranslateT("Delete All User History"));
}
- else if (msgFilter->msg == WM_RBUTTONUP)
- {
- HistoryWindow* historyWindow =(HistoryWindow*)GetWindowLongPtr(hwndDlg,GWLP_USERDATA);
- POINT clicked;
- LPNMITEMACTIVATE nmlv = (LPNMITEMACTIVATE)lParam;
- HWND window = historyWindow->editWindow;
- POINTL p;
- POINT scrool;
- LVHITTESTINFO info = {0};
- p.x = clicked.x = info.pt.x = GET_X_LPARAM(msgFilter->lParam);
- p.y = clicked.y = info.pt.y = GET_Y_LPARAM(msgFilter->lParam);
- ClientToScreen(window, &clicked);
- SetFocus(window);
- int selChar = SendMessage(window, EM_CHARFROMPOS, 0, (LPARAM)&p);
- CHARRANGE chrg;
- SendMessage(window,EM_EXGETSEL,0,(LPARAM)&chrg);
- SendMessage(window,EM_GETSCROLLPOS,0,(LPARAM)&scrool);
- if (selChar < chrg.cpMin || selChar > chrg.cpMax)
- {
- chrg.cpMin = chrg.cpMax = selChar;
- }
- if (chrg.cpMin == chrg.cpMax)
- {
- CHARRANGE chrgNew;
- chrgNew.cpMin = chrg.cpMin;
- chrgNew.cpMax = chrg.cpMax + 1;
- SendMessage(window,EM_EXSETSEL,0,(LPARAM)&chrgNew);
- }
- CHARFORMAT2 chf;
- memset(&chf, 0, sizeof(CHARFORMAT2));
- chf.cbSize = sizeof(CHARFORMAT2);
- chf.dwMask = CFM_LINK;
- SendMessage(window, EM_GETCHARFORMAT, SCF_SELECTION, (LPARAM)&chf);
- if (chrg.cpMin == chrg.cpMax)
- SendMessage(window,EM_EXSETSEL,0,(LPARAM)&chrg);
-
- HMENU hPopupMenu = CreatePopupMenu();
- if (hPopupMenu != NULL)
- {
- if (chf.dwEffects & CFE_LINK)
- {
- AppendMenu(hPopupMenu, MF_STRING, IDM_OPENNEW, TranslateT("Open in &new window"));
- AppendMenu(hPopupMenu, MF_STRING, IDM_OPENEXISTING, TranslateT("&Open in existing window"));
- AppendMenu(hPopupMenu, MF_STRING, IDM_COPYLINK, TranslateT("&Copy link"));
+ int selected = TrackPopupMenu(hPopupMenu, TPM_RETURNCMD, clicked.x, clicked.y, 0, hwndDlg, 0);
+ switch (selected) {
+ case IDM_COPY:
+ if (chrg.cpMax == chrg.cpMin && historyWindow->currentGroup.size() > 0) {
+ size_t start = 0;
+ while(start < historyWindow->currentGroup.size() && chrg.cpMin >= historyWindow->currentGroup[start].endPos) ++start;
+ if (start < historyWindow->currentGroup.size()) {
+ CHARRANGE chrgNew;
+ chrgNew.cpMin = 0;
+ if (start > 0)
+ chrgNew.cpMin = historyWindow->currentGroup[start - 1].endPos;
+ chrgNew.cpMax = historyWindow->currentGroup[start].endPos;
+ SendMessage(window,EM_EXSETSEL,0,(LPARAM)&chrgNew);
+ SendMessage(window,WM_COPY,0,0);
+ SendMessage(window,EM_EXSETSEL,0,(LPARAM)&chrg);
}
- else
- {
- AppendMenu(hPopupMenu, MF_STRING, IDM_COPY, TranslateT("Copy"));
- AppendMenu(hPopupMenu, MF_STRING, IDM_DELETE, TranslateT("Delete"));
- AppendMenu(hPopupMenu, MFT_SEPARATOR, 0, NULL);
- AppendMenu(hPopupMenu, MF_STRING, IDM_MESSAGE, TranslateT("Send Message"));
- AppendMenu(hPopupMenu, MF_STRING, IDM_QUOTE, TranslateT("Reply &Quoted"));
- AppendMenu(hPopupMenu, MF_STRING, IDM_DELETEGROUP, TranslateT("Delete Group"));
- AppendMenu(hPopupMenu, MF_STRING, IDM_DELETEUSER, TranslateT("Delete All User History"));
+ }
+ else SendMessage(window,WM_COPY,0,0);
+ break;
+
+ case IDM_MESSAGE:
+ CallFunctionAsync(ShowMessageWindow, new ShowMessageData(historyWindow->hContact));
+ break;
+
+ case IDM_QUOTE:
+ if (historyWindow->currentGroup.size() > 0) {
+ std::wstring quote;
+ if (chrg.cpMax == chrg.cpMin) {
+ size_t start = 0;
+ while(start < historyWindow->currentGroup.size() && chrg.cpMin >= historyWindow->currentGroup[start].endPos) ++start;
+ if (start < historyWindow->currentGroup.size())
+ historyWindow->FormatQuote(quote, historyWindow->currentGroup[start], historyWindow->currentGroup[start].description);
}
-
- int selected = TrackPopupMenu(hPopupMenu, TPM_RETURNCMD, clicked.x, clicked.y, 0, hwndDlg, 0);
- switch (selected)
- {
- case IDM_COPY:
- {
- if (chrg.cpMax == chrg.cpMin && historyWindow->currentGroup.size() > 0)
- {
- size_t start = 0;
- while(start < historyWindow->currentGroup.size() && chrg.cpMin >= historyWindow->currentGroup[start].endPos) ++start;
- if (start < historyWindow->currentGroup.size())
- {
- CHARRANGE chrgNew;
- chrgNew.cpMin = 0;
- if (start > 0)
- chrgNew.cpMin = historyWindow->currentGroup[start - 1].endPos;
- chrgNew.cpMax = historyWindow->currentGroup[start].endPos;
- SendMessage(window,EM_EXSETSEL,0,(LPARAM)&chrgNew);
- SendMessage(window,WM_COPY,0,0);
- SendMessage(window,EM_EXSETSEL,0,(LPARAM)&chrg);
- }
- }
- else
- {
- SendMessage(window,WM_COPY,0,0);
+ else {
+ size_t start = 0;
+ while(start < historyWindow->currentGroup.size() && chrg.cpMin >= historyWindow->currentGroup[start].endPos) ++start;
+ size_t end = 0;
+ while(end < historyWindow->currentGroup.size() && chrg.cpMax > historyWindow->currentGroup[end].endPos) ++end;
+ if (end >= historyWindow->currentGroup.size())
+ end = historyWindow->currentGroup.size() - 1;
+ if (start == end && start < historyWindow->currentGroup.size()) {
+ int iStart = historyWindow->currentGroup[start].startPos;
+ if (chrg.cpMin > iStart)
+ iStart = chrg.cpMin;
+ int iEnd = historyWindow->currentGroup[start].endPos;
+ if (chrg.cpMax < iEnd)
+ iEnd = chrg.cpMax;
+ if (iEnd > iStart) {
+ TEXTRANGE tr;
+ tr.chrg.cpMin = iStart;
+ tr.chrg.cpMax = iEnd;
+ tr.lpstrText = new TCHAR[iEnd - iStart + 1];
+ SendMessage(historyWindow->editWindow, EM_GETTEXTRANGE, 0, (LPARAM) & tr);
+ historyWindow->FormatQuote(quote, historyWindow->currentGroup[start], tr.lpstrText);
+ delete [] tr.lpstrText;
}
}
- break;
- case IDM_MESSAGE:
- //CallService(MS_MSG_SENDMESSAGE, (WPARAM)historyWindow->hContact, 0);
- CallFunctionAsync(ShowMessageWindow, new ShowMessageData(historyWindow->hContact));
- break;
- case IDM_QUOTE:
- {
- if (historyWindow->currentGroup.size() > 0)
- {
- std::wstring quote;
- if (chrg.cpMax == chrg.cpMin)
- {
- size_t start = 0;
- while(start < historyWindow->currentGroup.size() && chrg.cpMin >= historyWindow->currentGroup[start].endPos) ++start;
- if (start < historyWindow->currentGroup.size())
- {
- historyWindow->FormatQuote(quote, historyWindow->currentGroup[start], historyWindow->currentGroup[start].description);
- }
- }
- else
- {
- size_t start = 0;
- while(start < historyWindow->currentGroup.size() && chrg.cpMin >= historyWindow->currentGroup[start].endPos) ++start;
- size_t end = 0;
- while(end < historyWindow->currentGroup.size() && chrg.cpMax > historyWindow->currentGroup[end].endPos) ++end;
- if (end >= historyWindow->currentGroup.size())
- end = historyWindow->currentGroup.size() - 1;
- if (start == end && start < historyWindow->currentGroup.size())
- {
- int iStart = historyWindow->currentGroup[start].startPos;
- if (chrg.cpMin > iStart)
- iStart = chrg.cpMin;
- int iEnd = historyWindow->currentGroup[start].endPos;
- if (chrg.cpMax < iEnd)
- iEnd = chrg.cpMax;
- if (iEnd > iStart)
- {
- TEXTRANGE tr;
- tr.chrg.cpMin = iStart;
- tr.chrg.cpMax = iEnd;
- tr.lpstrText = new TCHAR[iEnd - iStart + 1];
- SendMessage(historyWindow->editWindow, EM_GETTEXTRANGE, 0, (LPARAM) & tr);
- historyWindow->FormatQuote(quote, historyWindow->currentGroup[start], tr.lpstrText);
- delete [] tr.lpstrText;
- }
- }
- else
- {
- while(start <= end)
- {
- historyWindow->FormatQuote(quote, historyWindow->currentGroup[start], historyWindow->currentGroup[start].description);
- ++start;
- }
- }
- }
-
- if (!quote.empty())
- {
- CallFunctionAsync(ShowMessageWindow, new ShowMessageData(historyWindow->hContact, quote));
- }
- }
- }
- break;
- case IDM_DELETE:
- historyWindow->Delete(0);
- break;
- case IDM_DELETEGROUP:
- historyWindow->Delete(1);
- break;
- case IDM_DELETEUSER:
- historyWindow->Delete(2);
- break;
- case IDM_OPENNEW:
- case IDM_OPENEXISTING:
- case IDM_COPYLINK:
- {
- int start = chrg.cpMin, end = chrg.cpMin;
- CHARRANGE chrgNew;
- chrgNew.cpMin = start-1;
- chrgNew.cpMax = start;
- do
- {
- memset(&chf, 0, sizeof(CHARFORMAT2));
- chf.cbSize = sizeof(CHARFORMAT2);
- chf.dwMask = CFM_LINK;
- int sel = SendMessage(window,EM_EXSETSEL,0,(LPARAM)&chrgNew);
- if (sel != chrgNew.cpMax)
- break;
- SendMessage(window, EM_GETCHARFORMAT, SCF_SELECTION, (LPARAM)&chf);
- --chrgNew.cpMin;
- --chrgNew.cpMax;
- --start;
- } while(start >= 0 && chf.dwEffects & CFE_LINK);
-
- ++start;
- chrgNew.cpMin = end;
- chrgNew.cpMax = end + 1;
- do
- {
- memset(&chf, 0, sizeof(CHARFORMAT2));
- chf.cbSize = sizeof(CHARFORMAT2);
- chf.dwMask = CFM_LINK;
- int sel = SendMessage(window,EM_EXSETSEL,0,(LPARAM)&chrgNew);
- if (sel != chrgNew.cpMax)
- break;
- SendMessage(window, EM_GETCHARFORMAT, SCF_SELECTION, (LPARAM)&chf);
- ++chrgNew.cpMin;
- ++chrgNew.cpMax;
- ++end;
- } while(chf.dwEffects & CFE_LINK);
-
- --end;
- if (selected == IDM_COPYLINK)
- {
- chrgNew.cpMin = start;
- chrgNew.cpMax = end;
- SendMessage(window,EM_EXSETSEL,0,(LPARAM)&chrgNew);
- SendMessage(window,WM_COPY,0,0);
- SendMessage(window,EM_EXSETSEL,0,(LPARAM)&chrg);
- }
- else
- {
- ENLINK link;
- link.chrg.cpMin = start;
- link.chrg.cpMax = end;
- link.msg = WM_LBUTTONUP;
- link.nmhdr.code = selected;
- SendMessage(window,EM_EXSETSEL,0,(LPARAM)&chrg);
- ClickLink(window, &link);
+ else {
+ while(start <= end) {
+ historyWindow->FormatQuote(quote, historyWindow->currentGroup[start], historyWindow->currentGroup[start].description);
+ ++start;
}
}
- break;
}
- DestroyMenu(hPopupMenu);
+ if (!quote.empty())
+ CallFunctionAsync(ShowMessageWindow, new ShowMessageData(historyWindow->hContact, quote));
}
- SendMessage(window,EM_SETSCROLLPOS,0,(LPARAM)&scrool);
- DlgReturn(TRUE);
- }
- }
- break;
- case IDC_LIST:
- if ( pNmhdr->code == LVN_ITEMCHANGED)
- {
- NMLISTVIEW *nmlv = (NMLISTVIEW*)lParam;
- HistoryWindow* historyWindow =(HistoryWindow*)GetWindowLongPtr(hwndDlg,GWLP_USERDATA);
- if ((nmlv->uChanged & LVIF_STATE) && (nmlv->uNewState & LVIS_SELECTED) && historyWindow->selected != nmlv->iItem && nmlv->iItem >= 0)
- {
- historyWindow->SelectEventGroup(nmlv->iItem);
- DlgReturn(TRUE);
- }
- }
- else if ( pNmhdr->code == LVN_KEYDOWN)
- {
- LPNMLVKEYDOWN nmlv = (LPNMLVKEYDOWN)lParam;
- HistoryWindow* historyWindow =(HistoryWindow*)GetWindowLongPtr(hwndDlg,GWLP_USERDATA);
- if (historyWindow->DoHotkey(WM_KEYDOWN, 0, nmlv->wVKey, IDC_LIST))
- DlgReturn(TRUE);
- }
- else if (pNmhdr->code == NM_RCLICK)
- {
- HistoryWindow* historyWindow =(HistoryWindow*)GetWindowLongPtr(hwndDlg,GWLP_USERDATA);
- POINT clicked;
- LPNMITEMACTIVATE nmlv = (LPNMITEMACTIVATE)lParam;
- HWND window = historyWindow->listWindow;
- LVHITTESTINFO info = {0};
- clicked.x = info.pt.x = nmlv->ptAction.x;
- clicked.y = info.pt.y = nmlv->ptAction.y;
- ClientToScreen(window, &clicked);
- int newSel = SendMessage(window, LVM_SUBITEMHITTEST, 0, (LPARAM)&info);
- int curSel = historyWindow->selected;
-
- if (newSel >= 0)
- {
- HMENU hPopupMenu = CreatePopupMenu();
- if (hPopupMenu != NULL)
+ break;
+ case IDM_DELETE:
+ historyWindow->Delete(0);
+ break;
+ case IDM_DELETEGROUP:
+ historyWindow->Delete(1);
+ break;
+ case IDM_DELETEUSER:
+ historyWindow->Delete(2);
+ break;
+ case IDM_OPENNEW:
+ case IDM_OPENEXISTING:
+ case IDM_COPYLINK:
{
- AppendMenu(hPopupMenu, MF_STRING, IDM_COPY, TranslateT("Copy"));
- AppendMenu(hPopupMenu, MF_STRING, IDM_DELETEGROUP, TranslateT("Delete Group"));
- AppendMenu(hPopupMenu, MFT_SEPARATOR, 0, NULL);
- AppendMenu(hPopupMenu, MF_STRING, IDM_MESSAGE, TranslateT("Send Message"));
- AppendMenu(hPopupMenu, MF_STRING, IDM_DELETEUSER, TranslateT("Delete All User History"));
-
- int selected = TrackPopupMenu(hPopupMenu, TPM_RETURNCMD, clicked.x, clicked.y, 0, hwndDlg, 0);
- switch (selected)
+ int start = chrg.cpMin, end = chrg.cpMin;
+ CHARRANGE chrgNew;
+ chrgNew.cpMin = start-1;
+ chrgNew.cpMax = start;
+ do
{
- case IDM_COPY:
- {
- CHARRANGE chrg;
- SendMessage(historyWindow->editWindow,EM_EXGETSEL,0,(LPARAM)&chrg);
- CHARRANGE chrgNew;
- chrgNew.cpMin = 0;
- chrgNew.cpMax = -1;
- SendMessage(historyWindow->editWindow,EM_EXSETSEL,0,(LPARAM)&chrgNew);
- SendMessage(historyWindow->editWindow,WM_COPY,0,0);
- SendMessage(historyWindow->editWindow,EM_EXSETSEL,0,(LPARAM)&chrg);
- }
- break;
- case IDM_MESSAGE:
- CallService(MS_MSG_SENDMESSAGE, (WPARAM)historyWindow->hContact, 0);
- break;
- case IDM_DELETEGROUP:
- historyWindow->Delete(1);
- break;
- case IDM_DELETEUSER:
- historyWindow->Delete(2);
- break;
+ memset(&chf, 0, sizeof(CHARFORMAT2));
+ chf.cbSize = sizeof(CHARFORMAT2);
+ chf.dwMask = CFM_LINK;
+ int sel = SendMessage(window,EM_EXSETSEL,0,(LPARAM)&chrgNew);
+ if (sel != chrgNew.cpMax)
+ break;
+ SendMessage(window, EM_GETCHARFORMAT, SCF_SELECTION, (LPARAM)&chf);
+ --chrgNew.cpMin;
+ --chrgNew.cpMax;
+ --start;
+ } while(start >= 0 && chf.dwEffects & CFE_LINK);
+
+ ++start;
+ chrgNew.cpMin = end;
+ chrgNew.cpMax = end + 1;
+ do
+ {
+ memset(&chf, 0, sizeof(CHARFORMAT2));
+ chf.cbSize = sizeof(CHARFORMAT2);
+ chf.dwMask = CFM_LINK;
+ int sel = SendMessage(window,EM_EXSETSEL,0,(LPARAM)&chrgNew);
+ if (sel != chrgNew.cpMax)
+ break;
+ SendMessage(window, EM_GETCHARFORMAT, SCF_SELECTION, (LPARAM)&chf);
+ ++chrgNew.cpMin;
+ ++chrgNew.cpMax;
+ ++end;
+ } while(chf.dwEffects & CFE_LINK);
+
+ --end;
+ if (selected == IDM_COPYLINK) {
+ chrgNew.cpMin = start;
+ chrgNew.cpMax = end;
+ SendMessage(window,EM_EXSETSEL,0,(LPARAM)&chrgNew);
+ SendMessage(window,WM_COPY,0,0);
+ SendMessage(window,EM_EXSETSEL,0,(LPARAM)&chrg);
+ }
+ else {
+ ENLINK link;
+ link.chrg.cpMin = start;
+ link.chrg.cpMax = end;
+ link.msg = WM_LBUTTONUP;
+ link.nmhdr.code = selected;
+ SendMessage(window,EM_EXSETSEL,0,(LPARAM)&chrg);
+ ClickLink(window, &link);
}
-
- DestroyMenu(hPopupMenu);
}
+ break;
}
-
- DlgReturn(TRUE);
+
+ DestroyMenu(hPopupMenu);
}
+ SendMessage(window,EM_SETSCROLLPOS,0,(LPARAM)&scrool);
+ DlgReturn(TRUE);
+ }
+ }
+ break;
- break;
- case IDC_TOOLBAR:
- if ( pNmhdr->code == TBN_DROPDOWN)
- {
- LPNMTOOLBAR lpnmTB= (LPNMTOOLBAR)lParam;
- HistoryWindow* historyWindow =(HistoryWindow*)GetWindowLongPtr(hwndDlg,GWLP_USERDATA);
- if (lpnmTB->iItem == IDM_FIND)
- {
- historyWindow->FindToolbarClicked(lpnmTB);
- }
- else if (lpnmTB->iItem == IDM_CONFIG)
- {
- historyWindow->ConfigToolbarClicked(lpnmTB);
- }
- else if (lpnmTB->iItem == IDM_DELETE)
- {
- historyWindow->DeleteToolbarClicked(lpnmTB);
+ case IDC_LIST:
+ if (pNmhdr->code == LVN_ITEMCHANGED) {
+ NMLISTVIEW *nmlv = (NMLISTVIEW*)lParam;
+ if ((nmlv->uChanged & LVIF_STATE) && (nmlv->uNewState & LVIS_SELECTED) && historyWindow->selected != nmlv->iItem && nmlv->iItem >= 0) {
+ historyWindow->SelectEventGroup(nmlv->iItem);
+ DlgReturn(TRUE);
+ }
+ }
+ else if (pNmhdr->code == LVN_KEYDOWN) {
+ LPNMLVKEYDOWN nmlv = (LPNMLVKEYDOWN)lParam;
+ if (historyWindow->DoHotkey(WM_KEYDOWN, 0, nmlv->wVKey, IDC_LIST))
+ DlgReturn(TRUE);
+ }
+ else if (pNmhdr->code == NM_RCLICK) {
+ POINT clicked;
+ LPNMITEMACTIVATE nmlv = (LPNMITEMACTIVATE)lParam;
+ HWND window = historyWindow->listWindow;
+ LVHITTESTINFO info = {0};
+ clicked.x = info.pt.x = nmlv->ptAction.x;
+ clicked.y = info.pt.y = nmlv->ptAction.y;
+ ClientToScreen(window, &clicked);
+ int newSel = SendMessage(window, LVM_SUBITEMHITTEST, 0, (LPARAM)&info);
+ int curSel = historyWindow->selected;
+
+ if (newSel >= 0) {
+ HMENU hPopupMenu = CreatePopupMenu();
+ if (hPopupMenu != NULL) {
+ AppendMenu(hPopupMenu, MF_STRING, IDM_COPY, TranslateT("Copy"));
+ AppendMenu(hPopupMenu, MF_STRING, IDM_DELETEGROUP, TranslateT("Delete Group"));
+ AppendMenu(hPopupMenu, MFT_SEPARATOR, 0, NULL);
+ AppendMenu(hPopupMenu, MF_STRING, IDM_MESSAGE, TranslateT("Send Message"));
+ AppendMenu(hPopupMenu, MF_STRING, IDM_DELETEUSER, TranslateT("Delete All User History"));
+
+ int selected = TrackPopupMenu(hPopupMenu, TPM_RETURNCMD, clicked.x, clicked.y, 0, hwndDlg, 0);
+ switch (selected) {
+ case IDM_COPY:
+ {
+ CHARRANGE chrg;
+ SendMessage(historyWindow->editWindow,EM_EXGETSEL,0,(LPARAM)&chrg);
+ CHARRANGE chrgNew;
+ chrgNew.cpMin = 0;
+ chrgNew.cpMax = -1;
+ SendMessage(historyWindow->editWindow,EM_EXSETSEL,0,(LPARAM)&chrgNew);
+ SendMessage(historyWindow->editWindow,WM_COPY,0,0);
+ SendMessage(historyWindow->editWindow,EM_EXSETSEL,0,(LPARAM)&chrg);
+ }
+ break;
+ case IDM_MESSAGE:
+ CallService(MS_MSG_SENDMESSAGE, (WPARAM)historyWindow->hContact, 0);
+ break;
+ case IDM_DELETEGROUP:
+ historyWindow->Delete(1);
+ break;
+ case IDM_DELETEUSER:
+ historyWindow->Delete(2);
+ break;
}
-
- DlgReturn(TBDDRET_DEFAULT);
- }
- else if ( pNmhdr->code == NM_KEYDOWN)
- {
- LPNMKEY nmlv = (LPNMKEY)lParam;
- HistoryWindow* historyWindow =(HistoryWindow*)GetWindowLongPtr(hwndDlg,GWLP_USERDATA);
- if (historyWindow->DoHotkey(WM_KEYDOWN, 0, nmlv->nVKey, IDC_TOOLBAR))
- DlgReturn(TRUE);
+
+ DestroyMenu(hPopupMenu);
}
- break;
+ }
+
+ DlgReturn(TRUE);
}
break;
+
+ case IDC_TOOLBAR:
+ if (pNmhdr->code == TBN_DROPDOWN) {
+ LPNMTOOLBAR lpnmTB= (LPNMTOOLBAR)lParam;
+ if (lpnmTB->iItem == IDM_FIND)
+ historyWindow->FindToolbarClicked(lpnmTB);
+ else if (lpnmTB->iItem == IDM_CONFIG)
+ historyWindow->ConfigToolbarClicked(lpnmTB);
+ else if (lpnmTB->iItem == IDM_DELETE)
+ historyWindow->DeleteToolbarClicked(lpnmTB);
+
+ DlgReturn(TBDDRET_DEFAULT);
+ }
+ else if (pNmhdr->code == NM_KEYDOWN) {
+ LPNMKEY nmlv = (LPNMKEY)lParam;
+ if (historyWindow->DoHotkey(WM_KEYDOWN, 0, nmlv->nVKey, IDC_TOOLBAR))
+ DlgReturn(TRUE);
+ }
}
+ break;
+
case WM_CTLCOLORDLG:
- {
- HistoryWindow* historyWindow =(HistoryWindow*)GetWindowLongPtr(hwndDlg,GWLP_USERDATA);
- DlgReturn((LONG_PTR)historyWindow->bkBrush);
- }
+ DlgReturn((LONG_PTR)historyWindow->bkBrush);
+
case WM_CTLCOLORSTATIC:
- {
- HistoryWindow* historyWindow =(HistoryWindow*)GetWindowLongPtr(hwndDlg,GWLP_USERDATA);
+ {
HWND curhWnd = (HWND)lParam;
if (historyWindow->splitterXhWnd == curhWnd || historyWindow->splitterYhWnd == curhWnd)
- {
DlgReturn((LONG_PTR)historyWindow->bkBrush);
- }
break;
- }
+ }
case WM_CTLCOLOREDIT:
- {
- HistoryWindow* historyWindow =(HistoryWindow*)GetWindowLongPtr(hwndDlg,GWLP_USERDATA);
+ {
HWND curhWnd = (HWND)lParam;
- if (historyWindow->findWindow == curhWnd)
- {
+ if (historyWindow->findWindow == curhWnd) {
HDC edithdc = (HDC)wParam;
LOGFONT font;
SetTextColor(edithdc, Options::instance->GetFont(Options::Find, &font));
SetBkColor(edithdc, Options::instance->GetColor(Options::FindBackground));
DlgReturn((LONG_PTR)historyWindow->bkFindBrush);
}
-
- break;
}
+ break;
+
case DM_SPLITTERMOVED:
- {
- HistoryWindow* historyWindow =(HistoryWindow*)GetWindowLongPtr(hwndDlg,GWLP_USERDATA);
- historyWindow->SplitterMoved((HWND)lParam, wParam, true);
- break;
- }
- case WM_INITDIALOG:
- {
- TranslateDialogDefault(hwndDlg);
- HistoryWindow* historyWindow = (HistoryWindow*)lParam;
- historyWindow->hWnd = hwndDlg;
- historyWindow->isWnd = true;
- SetWindowLongPtr(hwndDlg,GWLP_USERDATA,(LONG_PTR)lParam);
- historyWindow->Initialise();
- }
- DlgReturn(TRUE);
+ historyWindow->SplitterMoved((HWND)lParam, wParam, true);
+ break;
case DM_HREBUILD:
- {
- HistoryWindow* historyWindow =(HistoryWindow*)GetWindowLongPtr(hwndDlg,GWLP_USERDATA);
- if (!historyWindow->isLoading)
- {
- historyWindow->isLoading = true;
- historyWindow->ReloadContacts();
- mir_forkthread(HistoryWindow::FillHistoryThread, historyWindow);
- }
+ if (!historyWindow->isLoading) {
+ historyWindow->isLoading = true;
+ historyWindow->ReloadContacts();
+ mir_forkthread(HistoryWindow::FillHistoryThread, historyWindow);
}
DlgReturn(TRUE);
case WM_DESTROY:
- {
- HistoryWindow* historyWindow =(HistoryWindow*)GetWindowLongPtr(hwndDlg,GWLP_USERDATA);
- historyWindow->Destroy();
- }
+ historyWindow->Destroy();
DlgReturn(TRUE);
}
return FALSE;
@@ -1232,7 +1116,7 @@ void HistoryWindow::Initialise() {
allIconNumber = iconsNum + 3;
eventIcons = new HICON[allIconNumber];
- for(int i = 0; i < iconsNum; ++i) {
+ for (int i = 0; i < iconsNum; ++i) {
eventIcons[i] = Skin_GetIconByHandle( iconList[i].hIcolib );
ImageList_AddIcon(himlSmall, eventIcons[i]);
}
@@ -1571,7 +1455,7 @@ void HistoryWindow::SelectEventGroup(int sel) deq = revDeq;
}
COLORREF backColor = GetSysColor(COLOR_WINDOW);
- for(std::deque<EventIndex>::iterator it = deq.begin(); it != deq.end(); ++it)
+ for (std::deque<EventIndex>::iterator it = deq.begin(); it != deq.end(); ++it)
{
EventIndex hDbEvent = *it;
if (GetEventData(hDbEvent, data))
@@ -1966,7 +1850,7 @@ void HistoryWindow::FindToolbarClicked(LPNMTOOLBAR lpnmTB) int filter = GetFilterNr();
AppendMenu(hFilterMenu, filter == 0 ? MF_STRING | MF_CHECKED : MF_STRING, IDM_FILTERDEF, TranslateT("Default history events"));
AppendMenu(hFilterMenu, filter == 1 ? MF_STRING | MF_CHECKED : MF_STRING, IDM_FILTERALL, TranslateT("All events"));
- for(size_t i = 0 ; i < Options::instance->customFilters.size(); ++i)
+ for (size_t i = 0 ; i < Options::instance->customFilters.size(); ++i)
{
UINT flags = MF_STRING;
if (filter - 2 == i)
@@ -2145,7 +2029,7 @@ void HistoryWindow::DoImport(IImport::ImportType type) std::wstring err;
std::vector<HANDLE> contacts;
- for(HANDLE _hContact = db_find_first(); _hContact != NULL; _hContact = db_find_next(_hContact))
+ for (HANDLE _hContact = db_find_first(); _hContact != NULL; _hContact = db_find_next(_hContact))
contacts.push_back(_hContact);
bool changeContact = false;
@@ -2261,7 +2145,7 @@ void HistoryWindow::Delete(int what) bool areImpMessages = false;
bool rebuild = false;
- for(size_t i = start; i < end; ++i) {
+ for (size_t i = start; i < end; ++i) {
EventIndex& ev = eventList[selected][i];
DeleteEvent(ev);
areImpMessages |= ev.isExternal;
@@ -2355,10 +2239,8 @@ void HistoryWindow::FormatQuote(std::wstring& quote, const MessageData& md, cons do
{
int nf = (int)msg.find_first_of(_T("\r\n"), f);
- if (nf >= 0 && nf < (int)msg.length())
- {
- if (nf - f >= 0 )
- {
+ if (nf >= 0 && nf < (int)msg.length()) {
+ if (nf - f >= 0) {
quote += _T(">");
quote += msg.substr(f, nf - f);
quote += _T("\n");
@@ -2368,17 +2250,15 @@ void HistoryWindow::FormatQuote(std::wstring& quote, const MessageData& md, cons if (msg[nf] == _T('\r') && f < (int)msg.length() && msg[f] == _T('\n'))
++f;
}
- else if (msg.length() - f > 0)
- {
+ else if (msg.length() - f > 0) {
quote += _T(">");
quote += msg.substr(f, msg.length() - f);
quote += _T("\n");
f = -1;
}
- else
- f = -1;
+ else f = -1;
}
- while(f > 0 && f < (int)msg.length());
+ while(f > 0 && f < (int)msg.length());
}
HANDLE HistoryWindow::GetNextContact(HANDLE hContact, int adder)
@@ -2386,16 +2266,12 @@ HANDLE HistoryWindow::GetNextContact(HANDLE hContact, int adder) HWND contactList = GetDlgItem(hWnd,IDC_LIST_CONTACTS);
bool find = false;
HANDLE _hContact;
- if (adder > 0)
- {
- if (hContact != NULL)
- {
+ if (adder > 0) {
+ if (hContact != NULL) {
_hContact = db_find_next(hContact);
- while(_hContact)
- {
+ while(_hContact) {
HANDLE hItem = (HANDLE)SendMessage(contactList, CLM_FINDCONTACT, (WPARAM)_hContact, 0);
- if (hItem != NULL)
- {
+ if (hItem != NULL) {
find = true;
break;
}
@@ -2403,21 +2279,17 @@ HANDLE HistoryWindow::GetNextContact(HANDLE hContact, int adder) _hContact = db_find_next(_hContact);
}
- if (!find && EventList::GetContactMessageNumber(NULL))
- {
+ if (!find && EventList::GetContactMessageNumber(NULL)) {
_hContact = NULL;
find = true;
}
}
- if (!find)
- {
+ if (!find) {
_hContact = db_find_first();
- while(_hContact && _hContact != hContact)
- {
+ while(_hContact && _hContact != hContact) {
HANDLE hItem = (HANDLE)SendMessage(contactList, CLM_FINDCONTACT, (WPARAM)_hContact, 0);
- if (hItem != NULL)
- {
+ if (hItem != NULL) {
find = true;
break;
}
@@ -2426,77 +2298,58 @@ HANDLE HistoryWindow::GetNextContact(HANDLE hContact, int adder) }
}
}
- else
- {
+ else {
HANDLE lastContact = NULL;
_hContact = db_find_first();
- while(_hContact && _hContact != hContact)
- {
+ while(_hContact && _hContact != hContact) {
HANDLE hItem = (HANDLE)SendMessage(contactList, CLM_FINDCONTACT, (WPARAM)_hContact, 0);
if (hItem != NULL)
- {
lastContact = _hContact;
- }
_hContact = db_find_next(_hContact);
}
- if (hContact != NULL)
- {
- if (lastContact == NULL && !EventList::GetContactMessageNumber(NULL))
- {
+ if (hContact != NULL) {
+ if (lastContact == NULL && !EventList::GetContactMessageNumber(NULL)) {
_hContact = db_find_next(hContact);
- while(_hContact)
- {
+ while(_hContact) {
HANDLE hItem = (HANDLE)SendMessage(contactList, CLM_FINDCONTACT, (WPARAM)_hContact, 0);
if (hItem != NULL)
- {
lastContact = _hContact;
- }
_hContact = db_find_next(_hContact);
}
}
- if (lastContact != NULL || EventList::GetContactMessageNumber(NULL))
- {
+ if (lastContact != NULL || EventList::GetContactMessageNumber(NULL)) {
_hContact = lastContact;
find = true;
}
}
- else if (lastContact != NULL)
- {
+ else if (lastContact != NULL) {
_hContact = lastContact;
find = true;
}
}
if (find)
- {
return _hContact;
- }
- else
- {
- return hContact;
- }
+
+ return hContact;
}
void HistoryWindow::SelectContact(HANDLE _hContact)
{
- if (hContact != _hContact)
- {
+ if (hContact != _hContact) {
HWND contactList = GetDlgItem(hWnd,IDC_LIST_CONTACTS);
- if (_hContact != NULL)
- {
+ if (_hContact != NULL) {
HANDLE hItem = (HANDLE)SendMessage(contactList, CLM_FINDCONTACT, (WPARAM)_hContact, 0);
- if (hItem != NULL)
- {
+ if (hItem != NULL) {
SendMessage(contactList, CLM_ENSUREVISIBLE, (WPARAM)hItem, 0);
SendMessage(contactList, CLM_SELECTITEM, (WPARAM)hItem, 0);
}
}
- else
- {
+ else {
SendMessage(contactList, CLM_ENSUREVISIBLE, (WPARAM)hSystem, 0);
SendMessage(contactList, CLM_SELECTITEM, (WPARAM)hSystem, 0);
}
diff --git a/plugins/BasicHistory/src/Options.cpp b/plugins/BasicHistory/src/Options.cpp index d73c6feba9..4c8f129016 100644 --- a/plugins/BasicHistory/src/Options.cpp +++ b/plugins/BasicHistory/src/Options.cpp @@ -32,7 +32,8 @@ struct EventNamesType {
int id;
TCHAR* name;
-} EventNames[] =
+}
+EventNames[] =
{
EVENTTYPE_MESSAGE, LPGENT("Message"),
EVENTTYPE_FILE, LPGENT("File transfer"),
@@ -250,8 +251,7 @@ void Options::Load(void) strncpy_s(fid.dbSettingsGroup, "BasicHistory_Fonts", SIZEOF(fid.dbSettingsGroup));
_tcsncpy_s(fid.backgroundGroup, _T("History"), SIZEOF(fid.backgroundGroup));
_tcsncpy_s(fid.group, LPGENT("History"), SIZEOF(fid.group));
- for(int i = 0; i < g_fontsSize; ++i)
- {
+ for (int i = 0; i < g_fontsSize; ++i) {
fid.order = i;
_tcsncpy_s(fid.deffontsettings.szFace, g_FontOptionsList[i].szDefFace, LF_FACESIZE);
fid.deffontsettings.size = g_FontOptionsList[i].defSize;
@@ -267,8 +267,7 @@ void Options::Load(void) strncpy_s(cid.dbSettingsGroup, "BasicHistory_Fonts", SIZEOF(fid.dbSettingsGroup));
_tcsncpy_s(cid.group, LPGENT("History"), SIZEOF(fid.group));
- for(int i = 0; i < g_colorsSize; ++i)
- {
+ for (int i = 0; i < g_colorsSize; ++i) {
_tcsncpy_s(cid.name, g_ColorOptionsList[i].tszName, SIZEOF(cid.name));
mir_snprintf(cid.setting, SIZEOF(cid.setting), "Color%d", i);
cid.order = i;
@@ -277,8 +276,7 @@ void Options::Load(void) }
hid.dwFlags = HKD_TCHAR;
- for(int i = 0; i < g_hotkeysSize; ++i)
- {
+ for (int i = 0; i < g_hotkeysSize; ++i) {
hid.pszName = g_HotkeyOptionsList[i].pszName;
hid.ptszDescription = g_HotkeyOptionsList[i].ptszDescription;
hid.ptszSection = g_HotkeyOptionsList[i].ptszSection;
@@ -321,14 +319,12 @@ void Options::Load(void) defFilter = db_get_b(0, MODULE, "defFilter", defFilter);
int filtersCount = db_get_dw(0, MODULE, "customFiltersCount", 0);
- for(int i = 0; i < filtersCount; ++i)
- {
+ for (int i = 0; i < filtersCount; ++i) {
char buf[256];
FilterOptions fo;
mir_snprintf(buf, SIZEOF(buf), "filterName_%d", i);
DBVARIANT nameV;
- if (!db_get_ws(0, MODULE, buf, &nameV))
- {
+ if (!db_get_ws(0, MODULE, buf, &nameV)) {
fo.name = nameV.pwszVal;
db_free(&nameV);
}
@@ -341,14 +337,11 @@ void Options::Load(void) fo.onlyOutgoing = true;
mir_snprintf(buf, SIZEOF(buf), "filterEvents_%d", i);
DBVARIANT eventsV;
- if (!db_get_s(0, MODULE, buf, &eventsV))
- {
+ if (!db_get_s(0, MODULE, buf, &eventsV)) {
int k = 0;
char* id = eventsV.pszVal;
- while(eventsV.pszVal[k])
- {
- if (eventsV.pszVal[k] == ';')
- {
+ while(eventsV.pszVal[k]) {
+ if (eventsV.pszVal[k] == ';') {
eventsV.pszVal[k] = 0;
fo.events.push_back(strtol(id, NULL, 16));
id = eventsV.pszVal + k + 1;
@@ -363,18 +356,14 @@ void Options::Load(void) customFilters.insert(customFilters.end(), fo);
}
- if (defFilter > 1)
- {
+ if (defFilter > 1) {
defFilter = 0;
DBVARIANT defFilterStrV;
- if (!db_get_ws(0, MODULE, "defFilterStr", &defFilterStrV))
- {
+ if (!db_get_ws(0, MODULE, "defFilterStr", &defFilterStrV)) {
std::wstring filterName = defFilterStrV.pwszVal;
- for(int i = 0; i < (int)customFilters.size(); ++i)
- {
- if (filterName == customFilters[i].name)
- {
+ for (int i = 0; i < (int)customFilters.size(); ++i) {
+ if (filterName == customFilters[i].name) {
defFilter = i + 2;
break;
}
@@ -387,62 +376,43 @@ void Options::Load(void) codepageHtml1 = db_get_dw(0, MODULE, "codepageHtml1", CP_UTF8);
codepageHtml2 = db_get_dw(0, MODULE, "codepageHtml2", CP_UTF8);
DBVARIANT encodingV;
- if (!db_get_ws(0, MODULE, "encodingTxt", &encodingV))
- {
+ if (!db_get_ws(0, MODULE, "encodingTxt", &encodingV)) {
encodingTxt = encodingV.pwszVal;
db_free(&encodingV);
}
- else
- {
- encodingTxt = _T("UTF-8");
- }
- if (!db_get_ws(0, MODULE, "encodingHtml1", &encodingV))
- {
+ else encodingTxt = _T("UTF-8");
+
+ if (!db_get_ws(0, MODULE, "encodingHtml1", &encodingV)) {
encodingHtml1 = encodingV.pwszVal;
db_free(&encodingV);
}
- else
- {
- encodingHtml1 = _T("UTF-8");
- }
- if (!db_get_ws(0, MODULE, "encodingHtml2", &encodingV))
- {
+ else encodingHtml1 = _T("UTF-8");
+
+ if (!db_get_ws(0, MODULE, "encodingHtml2", &encodingV)) {
encodingHtml2 = encodingV.pwszVal;
db_free(&encodingV);
}
- else
- {
- encodingHtml2 = _T("UTF-8");
- }
+ else encodingHtml2 = _T("UTF-8");
exportHtml1ShowDate = db_get_b(0, MODULE, "exportHtml1ShowDate", 1) ? true : false;
exportHtml2ShowDate = db_get_b(0, MODULE, "exportHtml2ShowDate", 0) ? true : false;
exportHtml2UseSmileys = db_get_b(0, MODULE, "exportHtml2UseSmileys", 1) ? true : false;
- if (!db_get_ws(0, MODULE, "extCssHtml2", &encodingV))
- {
+ if (!db_get_ws(0, MODULE, "extCssHtml2", &encodingV)) {
extCssHtml2 = encodingV.pwszVal;
db_free(&encodingV);
}
- else
- {
- extCssHtml2 = _T("");
- }
+ else extCssHtml2 = _T("");
- if (!db_get_ws(0, MODULE, "ftpLogPath", &encodingV))
- {
+ if (!db_get_ws(0, MODULE, "ftpLogPath", &encodingV)) {
ftpLogPath = encodingV.pwszVal;
db_free(&encodingV);
}
- if (!db_get_ws(0, MODULE, "ftpExePath", &encodingV))
- {
+ if (!db_get_ws(0, MODULE, "ftpExePath", &encodingV)) {
ftpExePath = encodingV.pwszVal;
db_free(&encodingV);
}
- else
- {
- ftpExePath = ftpExePathDef;
- }
+ else ftpExePath = ftpExePathDef;
LoadTasks();
}
@@ -475,11 +445,14 @@ void Options::Save() db_set_b(0, MODULE, "groupShowTime", groupShowTime ? 1 : 0);
db_set_b(0, MODULE, "groupShowName", groupShowName ? 1 : 0);
db_set_b(0, MODULE, "groupShowMessage", groupShowMessage ? 1 : 0);
- if (groupMessageLen < 5) groupMessageLen = 5;
+ if (groupMessageLen < 5)
+ groupMessageLen = 5;
db_set_dw(0, MODULE, "groupMessageLen", groupMessageLen);
- if (groupTime < 1) groupTime = 1;
+ if (groupTime < 1)
+ groupTime = 1;
db_set_dw(0, MODULE, "groupTime", groupTime);
- if (groupMessagesNumber < 1) groupMessagesNumber = 1;
+ if (groupMessagesNumber < 1)
+ groupMessagesNumber = 1;
db_set_dw(0, MODULE, "groupMessagesNumber", groupMessagesNumber);
db_set_b(0, MODULE, "messagesNewOnTop", messagesNewOnTop ? 1 : 0);
db_set_b(0, MODULE, "messagesShowDate", messagesShowDate ? 1 : 0);
@@ -497,21 +470,20 @@ void Options::Save() db_set_b(0, MODULE, "searchAllContacts", searchAllContacts ? 1 : 0);
db_set_b(0, MODULE, "schedulerAlerts", schedulerAlerts ? 1 : 0);
db_set_b(0, MODULE, "schedulerHistoryAlerts", schedulerHistoryAlerts ? 1 : 0);
- if (defFilter < 0 || defFilter - 2 >= (int)customFilters.size()) defFilter = 0;
+ if (defFilter < 0 || defFilter - 2 >= (int)customFilters.size())
+ defFilter = 0;
db_set_b(0, MODULE, "defFilter", defFilter < 2 ? defFilter : 2);
if (defFilter >= 2)
db_set_ws(0, MODULE, "defFilterStr", customFilters[defFilter - 2].name.c_str());
db_set_dw(0, MODULE, "customFiltersCount", (DWORD)customFilters.size());
- for(int i = 0 ; i < (int)customFilters.size(); ++i)
- {
+ for (int i = 0 ; i < (int)customFilters.size(); ++i) {
char buf[256];
mir_snprintf(buf, SIZEOF(buf), "filterName_%d", i);
db_set_ws(0, MODULE, buf, customFilters[i].name.c_str());
mir_snprintf(buf, SIZEOF(buf), "filterInOut_%d", i);
db_set_b(0, MODULE, buf, customFilters[i].onlyIncomming ? 1 : (customFilters[i].onlyOutgoing ? 2 : 0));
std::string events;
- for(std::vector<int>::iterator it = customFilters[i].events.begin(); it != customFilters[i].events.end(); ++it)
- {
+ for (std::vector<int>::iterator it = customFilters[i].events.begin(); it != customFilters[i].events.end(); ++it) {
_itoa_s(*it, buf, 16);
events += buf;
events += ";";
@@ -533,13 +505,9 @@ void Options::Save() db_set_ws(0, MODULE, "extCssHtml2", extCssHtml2.c_str());
db_set_ws(0, MODULE, "ftpLogPath", ftpLogPath.c_str());
if (ftpExePath != ftpExePathDef)
- {
db_set_ws(0, MODULE, "ftpExePath", ftpExePath.c_str());
- }
else
- {
db_unset(0, MODULE, "ftpExePath");
- }
}
void Options::SaveTasks(std::list<TaskOptions>* tasks)
@@ -549,7 +517,7 @@ void Options::SaveTasks(std::list<TaskOptions>* tasks) taskOptions.clear();
int i = 0;
char buf[256];
- for(std::list<TaskOptions>::iterator it = tasks->begin(); it != tasks->end(); ++it) {
+ for (std::list<TaskOptions>::iterator it = tasks->begin(); it != tasks->end(); ++it) {
mir_snprintf(buf, SIZEOF(buf), "Task_compress_%d", i);
db_set_b(0, MODULE, buf, it->compress);
mir_snprintf(buf, SIZEOF(buf), "Task_useFtp_%d", i);
@@ -601,7 +569,7 @@ void Options::SaveTasks(std::list<TaskOptions>* tasks) for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact))
db_unset(hContact, MODULE, buf);
- for(size_t j = 0; j < it->contacts.size(); ++j)
+ for (size_t j = 0; j < it->contacts.size(); ++j)
db_set_b(it->contacts[j], MODULE, buf, 1);
it->orderNr = i++;
@@ -610,7 +578,7 @@ void Options::SaveTasks(std::list<TaskOptions>* tasks) db_set_dw(0, MODULE, "Task_count", i);
- for(i = (int)tasks->size(); i < oldTaskNr; ++i) {
+ for (i = (int)tasks->size(); i < oldTaskNr; ++i) {
mir_snprintf(buf, SIZEOF(buf), "Task_compress_%d", i);
db_unset(NULL, MODULE, buf);
mir_snprintf(buf, SIZEOF(buf), "Task_useFtp_%d", i);
@@ -674,8 +642,7 @@ void Options::LoadTasks() {
int taskCount = db_get_dw(0, MODULE, "Task_count", 0);
char buf[256];
- for(int i = 0; i < taskCount; ++i)
- {
+ for (int i = 0; i < taskCount; ++i) {
TaskOptions to;
mir_snprintf(buf, SIZEOF(buf), "Task_compress_%d", i);
to.compress = db_get_b(0, MODULE, buf, to.compress) != 0;
@@ -716,32 +683,27 @@ void Options::LoadTasks() to.lastExport |= ((unsigned long long int)db_get_dw(0, MODULE, buf, le >> 32)) << 32;
mir_snprintf(buf, SIZEOF(buf), "Task_ftpName_%d", i);
DBVARIANT var;
- if (!db_get_ws(0, MODULE, buf, &var))
- {
+ if (!db_get_ws(0, MODULE, buf, &var)) {
to.ftpName = var.ptszVal;
db_free(&var);
}
mir_snprintf(buf, SIZEOF(buf), "Task_filterName_%d", i);
- if (!db_get_ws(0, MODULE, buf, &var))
- {
+ if (!db_get_ws(0, MODULE, buf, &var)) {
to.filterName = var.ptszVal;
db_free(&var);
}
mir_snprintf(buf, SIZEOF(buf), "Task_filePath_%d", i);
- if (!db_get_ws(0, MODULE, buf, &var))
- {
+ if (!db_get_ws(0, MODULE, buf, &var)) {
to.filePath = var.ptszVal;
db_free(&var);
}
mir_snprintf(buf, SIZEOF(buf), "Task_taskName_%d", i);
- if (!db_get_ws(0, MODULE, buf, &var))
- {
+ if (!db_get_ws(0, MODULE, buf, &var)) {
to.taskName = var.ptszVal;
db_free(&var);
}
mir_snprintf(buf, SIZEOF(buf), "Task_zipPassword_%d", i);
- if (!db_get_s(0, MODULE, buf, &var))
- {
+ if (!db_get_s(0, MODULE, buf, &var)) {
to.zipPassword = var.pszVal;
db_free(&var);
}
@@ -767,35 +729,27 @@ void SetEventCB(HWND hwndCB, int eventId) {
int cpCount = SIZEOF(EventNames);
int selCpIdx = -1;
- for(int i = 0; i < cpCount; ++i)
- {
+ for (int i = 0; i < cpCount; ++i)
if (EventNames[i].id == eventId)
selCpIdx = i;
- }
- if (selCpIdx == -1)
- {
+ if (selCpIdx == -1) {
TCHAR buf[24];
mir_sntprintf(buf, SIZEOF(buf), _T("%d"), eventId);
ComboBox_SetText(hwndCB, buf);
}
- else
- {
- ComboBox_SetCurSel(hwndCB, selCpIdx);
- }
+ else ComboBox_SetCurSel(hwndCB, selCpIdx);
}
int GetEventCB(HWND hwndCB, bool errorReport, int &eventId)
{
int selCpIdx = ComboBox_GetCurSel(hwndCB);
- if (selCpIdx < 0)
- {
+ if (selCpIdx < 0) {
TCHAR text[24];
ComboBox_GetText(hwndCB, text, 24);
TCHAR * stopOn = NULL;
long cp = _tcstol(text, &stopOn, 10);
- if (errorReport && (stopOn == text || *stopOn != '\0' || cp < 0))
- {
+ if (errorReport && (stopOn == text || *stopOn != '\0' || cp < 0)) {
MessageBox(GetParent(hwndCB), TranslateT("Invalid event number"), TranslateT("Error"), MB_OK | MB_ICONERROR);
SetFocus(hwndCB);
return -1;
@@ -821,34 +775,25 @@ void ReloadEventLB(HWND hwndLB, const FilterOptions &sel) {
while(ListBox_GetCount(hwndLB) > 0)
ListBox_DeleteString(hwndLB, 0);
+
if (sel.onlyIncomming && !sel.onlyOutgoing)
- {
ListBox_AddString(hwndLB, TranslateT("Incoming events"));
- }
else if (sel.onlyOutgoing && !sel.onlyIncomming)
- {
ListBox_AddString(hwndLB, TranslateT("Outgoing events"));
- }
- for(std::vector<int>::const_iterator it = sel.events.begin(); it != sel.events.end(); ++it)
- {
+ for (std::vector<int>::const_iterator it = sel.events.begin(); it != sel.events.end(); ++it) {
int cpCount = SIZEOF(EventNames);
int selCpIdx = -1;
- for(int i = 0; i < cpCount; ++i)
- {
+ for (int i = 0; i < cpCount; ++i)
if (EventNames[i].id == *it)
selCpIdx = i;
- }
- if (selCpIdx == -1)
- {
+
+ if (selCpIdx == -1) {
TCHAR buf[24];
mir_sntprintf(buf, SIZEOF(buf), _T("%d"), *it);
ListBox_AddString(hwndLB, buf);
}
- else
- {
- ListBox_AddString(hwndLB, TranslateTS(EventNames[selCpIdx].name));
- }
+ else ListBox_AddString(hwndLB, TranslateTS(EventNames[selCpIdx].name));
}
}
@@ -857,8 +802,7 @@ bool CheckFile(HWND hwndEdit) TCHAR buf[MAX_PATH];
Edit_GetText(hwndEdit, buf, MAX_PATH);
DWORD atr = GetFileAttributes(buf);
- if (atr == INVALID_FILE_ATTRIBUTES || atr & FILE_ATTRIBUTE_DIRECTORY)
- {
+ if (atr == INVALID_FILE_ATTRIBUTES || atr & FILE_ATTRIBUTE_DIRECTORY) {
MessageBox(GetParent(hwndEdit), TranslateT("File do not exist. Enter correct file path."), TranslateT("Invalid file"), MB_OK | MB_ICONERROR);
SetFocus(hwndEdit);
return false;
@@ -886,14 +830,12 @@ bool OpenFileDlg(HWND hwndDlg, HWND hwndEdit, const TCHAR* defName, const TCHAR* TCHAR stzFilePath[1024];
Edit_GetText(hwndEdit, stzFilePath, 1023);
- if (stzFilePath[0] == 0)
- {
+ if (stzFilePath[0] == 0) {
_tcscpy_s(stzFilePath, defName);
len = _tcslen(stzFilePath) + 1;
stzFilePath[len] = 0;
}
- else
- {
+ else {
len = _tcslen(stzFilePath) + 1;
stzFilePath[len] = 0;
}
@@ -907,20 +849,16 @@ bool OpenFileDlg(HWND hwndDlg, HWND hwndEdit, const TCHAR* defName, const TCHAR* ofn.lpstrTitle = title;
ofn.nMaxFile = 1024;
ofn.lpstrDefExt = ext;
- if (open)
- {
+ if (open) {
ofn.Flags = OFN_PATHMUSTEXIST | OFN_EXPLORER | OFN_NOCHANGEDIR | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
- if (GetOpenFileName(&ofn))
- {
+ if (GetOpenFileName(&ofn)) {
Edit_SetText(hwndEdit, stzFilePath);
return true;
}
}
- else
- {
+ else {
ofn.Flags = OFN_NOREADONLYRETURN | OFN_PATHMUSTEXIST | OFN_EXPLORER | OFN_NOCHANGEDIR;
- if (GetSaveFileName(&ofn))
- {
+ if (GetSaveFileName(&ofn)) {
Edit_SetText(hwndEdit, stzFilePath);
return true;
}
@@ -931,11 +869,10 @@ bool OpenFileDlg(HWND hwndDlg, HWND hwndEdit, const TCHAR* defName, const TCHAR* INT_PTR CALLBACK Options::DlgProcOptsMain(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
- switch(msg)
- {
- case WM_INITDIALOG:
+ switch(msg) {
+ case WM_INITDIALOG:
+ TranslateDialogDefault(hwndDlg);
{
- TranslateDialogDefault(hwndDlg);
SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)FALSE);
CheckDlgButton(hwndDlg, IDC_SHOWCONTACTS, instance->showContacts ? 1 : 0);
CheckDlgButton(hwndDlg, IDC_SHOWCONTACTGROUPS, instance->showContactGroups ? 1 : 0);
@@ -947,10 +884,8 @@ INT_PTR CALLBACK Options::DlgProcOptsMain(HWND hwndDlg, UINT msg, WPARAM wParam, HWND ftpLog = GetDlgItem(hwndDlg, IDC_WINSCPLOG);
ComboBox_AddString(events, TranslateT("Incoming events"));
ComboBox_AddString(events, TranslateT("Outgoing events"));
- for(int i = 0 ; i < SIZEOF(EventNames); ++i)
- {
+ for (int i = 0 ; i < SIZEOF(EventNames); ++i)
ComboBox_AddString(events, TranslateTS(EventNames[i].name));
- }
ComboBox_AddString(defFilter, TranslateT("Default history events"));
ComboBox_AddString(defFilter, TranslateT("All events"));
@@ -959,8 +894,7 @@ INT_PTR CALLBACK Options::DlgProcOptsMain(HWND hwndDlg, UINT msg, WPARAM wParam, instance->customFiltersTemp.clear();
instance->customFiltersTemp.insert(instance->customFiltersTemp.begin(), instance->customFilters.begin(), instance->customFilters.end());
- for(std::vector<FilterOptions>::iterator it = instance->customFiltersTemp.begin(); it != instance->customFiltersTemp.end(); ++it)
- {
+ for (std::vector<FilterOptions>::iterator it = instance->customFiltersTemp.begin(); it != instance->customFiltersTemp.end(); ++it) {
ComboBox_AddString(defFilter, it->name.c_str());
ListBox_AddString(listFilter, it->name.c_str());
}
@@ -975,35 +909,31 @@ INT_PTR CALLBACK Options::DlgProcOptsMain(HWND hwndDlg, UINT msg, WPARAM wParam, Edit_SetText(ftp, instance->ftpExePath.c_str());
Edit_SetText(ftpLog, instance->ftpLogPath.c_str());
SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)TRUE);
- return TRUE;
}
- case WM_COMMAND:
+ return TRUE;
+
+ case WM_COMMAND:
{
BOOL init = (BOOL)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
- if (HIWORD(wParam) == BN_CLICKED)
- {
+ if (HIWORD(wParam) == BN_CLICKED) {
HWND listFilter = GetDlgItem(hwndDlg, IDC_LIST_FILTERS);
HWND listEvents = GetDlgItem(hwndDlg, IDC_LIST_EVENTS);
HWND nameFilter = GetDlgItem(hwndDlg, IDC_FILTER_NAME);
HWND defFilter = GetDlgItem(hwndDlg, IDC_DEFFILTER);
HWND eventCB = GetDlgItem(hwndDlg, IDC_EVENT);
- switch(LOWORD(wParam))
- {
+ switch(LOWORD(wParam)) {
case IDC_ADD_FILTER:
{
TCHAR name[24];
Edit_GetText(nameFilter, name, 24);
- if (name[0] == 0)
- {
+ if (name[0] == 0) {
MessageBox(hwndDlg, TranslateT("Enter filter name"), TranslateT("Error"), MB_ICONERROR);
return TRUE;
}
-
+
FilterOptions fo(name);
- for(std::vector<FilterOptions>::iterator it = instance->customFiltersTemp.begin(); it != instance->customFiltersTemp.end(); ++it)
- {
- if (it->name == fo.name)
- {
+ for (std::vector<FilterOptions>::iterator it = instance->customFiltersTemp.begin(); it != instance->customFiltersTemp.end(); ++it) {
+ if (it->name == fo.name) {
MessageBox(hwndDlg, TranslateT("Filter name exists"), TranslateT("Error"), MB_ICONERROR);
return TRUE;
}
@@ -1022,24 +952,22 @@ INT_PTR CALLBACK Options::DlgProcOptsMain(HWND hwndDlg, UINT msg, WPARAM wParam, EnableWindow(GetDlgItem(hwndDlg, IDC_DELETE_EVENT), FALSE);
}
break;
+
case IDC_DELETE_FILTER:
{
int sel = ListBox_GetCurSel(listFilter);
if (sel < 0)
return TRUE;
- for(size_t i = sel; i < instance->customFiltersTemp.size() - 1; ++i)
- {
+
+ for (size_t i = sel; i < instance->customFiltersTemp.size() - 1; ++i)
instance->customFiltersTemp[i] = instance->customFiltersTemp[i + 1];
- }
instance->customFiltersTemp.resize(instance->customFiltersTemp.size() - 1);
ListBox_DeleteString(listFilter, sel);
ComboBox_DeleteString(defFilter, sel + 2);
if (ComboBox_GetCurSel(defFilter) < 0)
- {
ComboBox_SetCurSel(defFilter, 0);
- }
-
+
ClearLB(listEvents);
EnableWindow(GetDlgItem(hwndDlg, IDC_DELETE_FILTER), FALSE);
EnableWindow(GetDlgItem(hwndDlg, IDC_EVENT), FALSE);
@@ -1047,19 +975,20 @@ INT_PTR CALLBACK Options::DlgProcOptsMain(HWND hwndDlg, UINT msg, WPARAM wParam, EnableWindow(GetDlgItem(hwndDlg, IDC_DELETE_EVENT), FALSE);
}
break;
+
case IDC_ADD_EVENT:
{
int sel = ListBox_GetCurSel(listFilter);
if (sel < 0)
return TRUE;
+
int eventId;
int selCB = GetEventCB(eventCB, true, eventId);
if (selCB < 0)
return TRUE;
- if (selCB == 1)
- {
- if (instance->customFiltersTemp[sel].onlyIncomming)
- {
+
+ if (selCB == 1) {
+ if (instance->customFiltersTemp[sel].onlyIncomming) {
MessageBox(hwndDlg, TranslateT("Event already exists"), TranslateT("Error"), MB_ICONERROR);
return TRUE;
}
@@ -1069,23 +998,19 @@ INT_PTR CALLBACK Options::DlgProcOptsMain(HWND hwndDlg, UINT msg, WPARAM wParam, else
instance->customFiltersTemp[sel].onlyIncomming = true;
}
- else if (selCB == 2)
- {
- if (instance->customFiltersTemp[sel].onlyOutgoing)
- {
+ else if (selCB == 2) {
+ if (instance->customFiltersTemp[sel].onlyOutgoing) {
MessageBox(hwndDlg, TranslateT("Event already exists"), TranslateT("Error"), MB_ICONERROR);
return TRUE;
}
-
+
if (instance->customFiltersTemp[sel].onlyIncomming)
instance->customFiltersTemp[sel].onlyIncomming = false;
else
instance->customFiltersTemp[sel].onlyOutgoing = true;
}
- else
- {
- if (std::find(instance->customFiltersTemp[sel].events.begin(), instance->customFiltersTemp[sel].events.end(), eventId) != instance->customFiltersTemp[sel].events.end())
- {
+ else {
+ if (std::find(instance->customFiltersTemp[sel].events.begin(), instance->customFiltersTemp[sel].events.end(), eventId) != instance->customFiltersTemp[sel].events.end()) {
MessageBox(hwndDlg, TranslateT("Event already exists"), TranslateT("Error"), MB_ICONERROR);
return TRUE;
}
@@ -1098,29 +1023,28 @@ INT_PTR CALLBACK Options::DlgProcOptsMain(HWND hwndDlg, UINT msg, WPARAM wParam, EnableWindow(GetDlgItem(hwndDlg, IDC_DELETE_EVENT), FALSE);
}
break;
+
case IDC_DELETE_EVENT:
{
int sel = ListBox_GetCurSel(listFilter);
if (sel < 0)
return TRUE;
+
int eventSel = ListBox_GetCurSel(listEvents);
if (eventSel < 0)
return TRUE;
+
int stId = 0;
if (instance->customFiltersTemp[sel].onlyIncomming || instance->customFiltersTemp[sel].onlyOutgoing)
++stId;
- if (eventSel >= stId)
- {
+ if (eventSel >= stId) {
--eventSel;
- for(int i = eventSel; i < (int)instance->customFiltersTemp[sel].events.size() - 1; ++i)
- {
+ for (int i = eventSel; i < (int)instance->customFiltersTemp[sel].events.size() - 1; ++i)
instance->customFiltersTemp[sel].events[i] = instance->customFiltersTemp[sel].events[i + 1];
- }
instance->customFiltersTemp[sel].events.resize(instance->customFiltersTemp[sel].events.size() - 1);
}
- else
- {
+ else {
instance->customFiltersTemp[sel].onlyIncomming = false;
instance->customFiltersTemp[sel].onlyOutgoing = false;
}
@@ -1129,24 +1053,19 @@ INT_PTR CALLBACK Options::DlgProcOptsMain(HWND hwndDlg, UINT msg, WPARAM wParam, EnableWindow(GetDlgItem(hwndDlg, IDC_DELETE_EVENT), FALSE);
}
break;
+
case IDC_WINSCP_BROWSE:
if (!OpenFileDlg(hwndDlg, GetDlgItem(hwndDlg, IDC_WINSCP), _T("WinSCP.exe"), _T("exe"), TranslateT("Browse WinSCP file"), true))
- {
return TRUE;
- }
-
break;
+
case IDC_WINSCPLOG_BROWSE:
if (!OpenFileDlg(hwndDlg, GetDlgItem(hwndDlg, IDC_WINSCPLOG), _T("ftplog.txt"), _T("txt"), TranslateT("Save WinSCP log file"), false))
- {
return TRUE;
- }
-
break;
}
}
- else if (HIWORD(wParam) == CBN_SELCHANGE && LOWORD(wParam) == IDC_LIST_FILTERS)
- {
+ else if (HIWORD(wParam) == CBN_SELCHANGE && LOWORD(wParam) == IDC_LIST_FILTERS) {
HWND listFilter = GetDlgItem(hwndDlg, IDC_LIST_FILTERS);
HWND listEvents = GetDlgItem(hwndDlg, IDC_LIST_EVENTS);
int sel = ListBox_GetCurSel(listFilter);
@@ -1159,8 +1078,7 @@ INT_PTR CALLBACK Options::DlgProcOptsMain(HWND hwndDlg, UINT msg, WPARAM wParam, EnableWindow(GetDlgItem(hwndDlg, IDC_ADD_EVENT), sel >= 0);
EnableWindow(GetDlgItem(hwndDlg, IDC_DELETE_EVENT), FALSE);
}
- else if (HIWORD(wParam) == CBN_SELCHANGE && LOWORD(wParam) == IDC_LIST_EVENTS)
- {
+ else if (HIWORD(wParam) == CBN_SELCHANGE && LOWORD(wParam) == IDC_LIST_EVENTS) {
HWND listEvents = GetDlgItem(hwndDlg, IDC_LIST_EVENTS);
int sel = ListBox_GetCurSel(listEvents);
EnableWindow(GetDlgItem(hwndDlg, IDC_DELETE_EVENT), sel >= 0);
@@ -1170,35 +1088,32 @@ INT_PTR CALLBACK Options::DlgProcOptsMain(HWND hwndDlg, UINT msg, WPARAM wParam, SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
return TRUE;
}
- case WM_NOTIFY:
- {
- if (((LPNMHDR)lParam)->code == PSN_APPLY)
- {
- HWND ftp = GetDlgItem(hwndDlg, IDC_WINSCP);
- TCHAR buf[MAX_PATH];
- Edit_GetText(ftp, buf, MAX_PATH);
- if (buf[0] != 0 && !CheckFile(ftp))
- {
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, PSNRET_INVALID_NOCHANGEPAGE);
- return TRUE;
- }
- instance->ftpExePath = buf;
- Edit_GetText(GetDlgItem(hwndDlg, IDC_WINSCPLOG), buf, MAX_PATH);
- instance->ftpLogPath = buf;
-
- instance->showContacts = IsDlgButtonChecked(hwndDlg, IDC_SHOWCONTACTS) ? true : false;
- instance->showContactGroups = IsDlgButtonChecked(hwndDlg, IDC_SHOWCONTACTGROUPS) ? true : false;
- instance->noFindBorder = IsDlgButtonChecked(hwndDlg, IDC_FINDNOBORDER) ? true : false;
- instance->defFilter = ComboBox_GetCurSel(GetDlgItem(hwndDlg, IDC_DEFFILTER));
- instance->customFilters.clear();
- instance->customFilters.insert(instance->customFilters.begin(), instance->customFiltersTemp.begin(), instance->customFiltersTemp.end());
- Options::instance->Save();
- OptionsMainChanged();
+ case WM_NOTIFY:
+ if (((LPNMHDR)lParam)->code == PSN_APPLY) {
+ HWND ftp = GetDlgItem(hwndDlg, IDC_WINSCP);
+ TCHAR buf[MAX_PATH];
+ Edit_GetText(ftp, buf, MAX_PATH);
+ if (buf[0] != 0 && !CheckFile(ftp)) {
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, PSNRET_INVALID_NOCHANGEPAGE);
+ return TRUE;
}
- return TRUE;
+
+ instance->ftpExePath = buf;
+ Edit_GetText(GetDlgItem(hwndDlg, IDC_WINSCPLOG), buf, MAX_PATH);
+ instance->ftpLogPath = buf;
+
+ instance->showContacts = IsDlgButtonChecked(hwndDlg, IDC_SHOWCONTACTS) ? true : false;
+ instance->showContactGroups = IsDlgButtonChecked(hwndDlg, IDC_SHOWCONTACTGROUPS) ? true : false;
+ instance->noFindBorder = IsDlgButtonChecked(hwndDlg, IDC_FINDNOBORDER) ? true : false;
+ instance->defFilter = ComboBox_GetCurSel(GetDlgItem(hwndDlg, IDC_DEFFILTER));
+ instance->customFilters.clear();
+ instance->customFilters.insert(instance->customFilters.begin(), instance->customFiltersTemp.begin(), instance->customFiltersTemp.end());
+ Options::instance->Save();
+ OptionsMainChanged();
}
+ return TRUE;
}
return FALSE;
@@ -1217,11 +1132,10 @@ public: INT_PTR CALLBACK Options::DlgProcOptsGroupList(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
- switch(msg)
- {
- case WM_INITDIALOG:
+ switch(msg) {
+ case WM_INITDIALOG:
+ TranslateDialogDefault(hwndDlg);
{
- TranslateDialogDefault(hwndDlg);
OptsData* optsData = new OptsData();
SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)optsData);
@@ -1239,20 +1153,18 @@ INT_PTR CALLBACK Options::DlgProcOptsGroupList(HWND hwndDlg, UINT msg, WPARAM wP SetDlgItemInt(hwndDlg, IDC_LIMITMESSAGES, instance->groupMessagesNumber, FALSE);
optsData->init = true;
- return TRUE;
}
- case WM_COMMAND:
+ return TRUE;
+
+ case WM_COMMAND:
{
OptsData* optsData = (OptsData*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
- if (HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == IDC_SHOWMESSAGE)
- {
- if (IsDlgButtonChecked(hwndDlg, IDC_SHOWMESSAGE))
- {
+ if (HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == IDC_SHOWMESSAGE) {
+ if (IsDlgButtonChecked(hwndDlg, IDC_SHOWMESSAGE)) {
EnableWindow(GetDlgItem(hwndDlg, IDC_MESSAGELEN), TRUE);
EnableWindow(GetDlgItem(hwndDlg, IDC_MESSAGELEN_DESC), TRUE);
}
- else
- {
+ else {
EnableWindow(GetDlgItem(hwndDlg, IDC_MESSAGELEN), FALSE);
EnableWindow(GetDlgItem(hwndDlg, IDC_MESSAGELEN_DESC), FALSE);
}
@@ -1261,25 +1173,22 @@ INT_PTR CALLBACK Options::DlgProcOptsGroupList(HWND hwndDlg, UINT msg, WPARAM wP SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
return TRUE;
}
- case WM_NOTIFY:
- {
- if (((LPNMHDR)lParam)->code == PSN_APPLY)
- {
- instance->groupNewOnTop = IsDlgButtonChecked(hwndDlg, IDC_NEWONTOP) ? true : false;
- instance->groupShowEvents = IsDlgButtonChecked(hwndDlg, IDC_SHOWEVENTS) ? true : false;
- instance->groupShowTime = IsDlgButtonChecked(hwndDlg, IDC_SHOWTIME) ? true : false;
- instance->groupShowName = IsDlgButtonChecked(hwndDlg, IDC_SHOWNAME) ? true : false;
- instance->groupShowMessage = IsDlgButtonChecked(hwndDlg, IDC_SHOWMESSAGE) ? true : false;
- BOOL success;
- instance->groupMessageLen = GetDlgItemInt(hwndDlg, IDC_MESSAGELEN, &success, FALSE);
- instance->groupTime = GetDlgItemInt(hwndDlg, IDC_GROUPTIME, &success, FALSE);
- instance->groupMessagesNumber = GetDlgItemInt(hwndDlg, IDC_LIMITMESSAGES, &success, FALSE);
-
- Options::instance->Save();
- OptionsGroupChanged();
- }
- return TRUE;
+ case WM_NOTIFY:
+ if (((LPNMHDR)lParam)->code == PSN_APPLY) {
+ instance->groupNewOnTop = IsDlgButtonChecked(hwndDlg, IDC_NEWONTOP) ? true : false;
+ instance->groupShowEvents = IsDlgButtonChecked(hwndDlg, IDC_SHOWEVENTS) ? true : false;
+ instance->groupShowTime = IsDlgButtonChecked(hwndDlg, IDC_SHOWTIME) ? true : false;
+ instance->groupShowName = IsDlgButtonChecked(hwndDlg, IDC_SHOWNAME) ? true : false;
+ instance->groupShowMessage = IsDlgButtonChecked(hwndDlg, IDC_SHOWMESSAGE) ? true : false;
+ BOOL success;
+ instance->groupMessageLen = GetDlgItemInt(hwndDlg, IDC_MESSAGELEN, &success, FALSE);
+ instance->groupTime = GetDlgItemInt(hwndDlg, IDC_GROUPTIME, &success, FALSE);
+ instance->groupMessagesNumber = GetDlgItemInt(hwndDlg, IDC_LIMITMESSAGES, &success, FALSE);
+
+ Options::instance->Save();
+ OptionsGroupChanged();
}
+ return TRUE;
}
return FALSE;
@@ -1287,44 +1196,38 @@ INT_PTR CALLBACK Options::DlgProcOptsGroupList(HWND hwndDlg, UINT msg, WPARAM wP INT_PTR CALLBACK Options::DlgProcOptsMessages(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
- switch(msg)
- {
- case WM_INITDIALOG:
- {
- TranslateDialogDefault(hwndDlg);
-
- CheckDlgButton(hwndDlg, IDC_NEWONTOP, instance->messagesNewOnTop ? 1 : 0);
- CheckDlgButton(hwndDlg, IDC_SHOWDATE, instance->messagesShowDate ? 1 : 0);
- CheckDlgButton(hwndDlg, IDC_SHOWSECOND, instance->messagesShowSec ? 1 : 0);
- CheckDlgButton(hwndDlg, IDC_SHOWNAME, instance->messagesShowName ? 1 : 0);
- CheckDlgButton(hwndDlg, IDC_SHOWEVENTS, instance->messagesShowEvents ? 1 : 0);
- CheckDlgButton(hwndDlg, IDC_SHOWSMILEYS, instance->messagesUseSmileys ? 1 : 0);
- if (!g_SmileyAddAvail)
- EnableWindow(GetDlgItem(hwndDlg, IDC_SHOWSMILEYS), FALSE);
- return TRUE;
- }
- case WM_COMMAND:
- {
- if (HIWORD(wParam) == BN_CLICKED)
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- return TRUE;
- }
- case WM_NOTIFY:
- {
- if (((LPNMHDR)lParam)->code == PSN_APPLY)
- {
- instance->messagesNewOnTop = IsDlgButtonChecked(hwndDlg, IDC_NEWONTOP) ? true : false;
- instance->messagesShowDate = IsDlgButtonChecked(hwndDlg, IDC_SHOWDATE) ? true : false;
- instance->messagesShowSec = IsDlgButtonChecked(hwndDlg, IDC_SHOWSECOND) ? true : false;
- instance->messagesShowName = IsDlgButtonChecked(hwndDlg, IDC_SHOWNAME) ? true : false;
- instance->messagesShowEvents = IsDlgButtonChecked(hwndDlg, IDC_SHOWEVENTS) ? true : false;
- instance->messagesUseSmileys = IsDlgButtonChecked(hwndDlg, IDC_SHOWSMILEYS) ? true : false;
-
- Options::instance->Save();
- OptionsMessageChanged();
- }
- return TRUE;
+ switch(msg) {
+ case WM_INITDIALOG:
+ TranslateDialogDefault(hwndDlg);
+
+ CheckDlgButton(hwndDlg, IDC_NEWONTOP, instance->messagesNewOnTop ? 1 : 0);
+ CheckDlgButton(hwndDlg, IDC_SHOWDATE, instance->messagesShowDate ? 1 : 0);
+ CheckDlgButton(hwndDlg, IDC_SHOWSECOND, instance->messagesShowSec ? 1 : 0);
+ CheckDlgButton(hwndDlg, IDC_SHOWNAME, instance->messagesShowName ? 1 : 0);
+ CheckDlgButton(hwndDlg, IDC_SHOWEVENTS, instance->messagesShowEvents ? 1 : 0);
+ CheckDlgButton(hwndDlg, IDC_SHOWSMILEYS, instance->messagesUseSmileys ? 1 : 0);
+ if (!g_SmileyAddAvail)
+ EnableWindow(GetDlgItem(hwndDlg, IDC_SHOWSMILEYS), FALSE);
+ return TRUE;
+
+ case WM_COMMAND:
+ if (HIWORD(wParam) == BN_CLICKED)
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ return TRUE;
+
+ case WM_NOTIFY:
+ if (((LPNMHDR)lParam)->code == PSN_APPLY) {
+ instance->messagesNewOnTop = IsDlgButtonChecked(hwndDlg, IDC_NEWONTOP) ? true : false;
+ instance->messagesShowDate = IsDlgButtonChecked(hwndDlg, IDC_SHOWDATE) ? true : false;
+ instance->messagesShowSec = IsDlgButtonChecked(hwndDlg, IDC_SHOWSECOND) ? true : false;
+ instance->messagesShowName = IsDlgButtonChecked(hwndDlg, IDC_SHOWNAME) ? true : false;
+ instance->messagesShowEvents = IsDlgButtonChecked(hwndDlg, IDC_SHOWEVENTS) ? true : false;
+ instance->messagesUseSmileys = IsDlgButtonChecked(hwndDlg, IDC_SHOWSMILEYS) ? true : false;
+
+ Options::instance->Save();
+ OptionsMessageChanged();
}
+ return TRUE;
}
return FALSE;
@@ -1332,61 +1235,49 @@ INT_PTR CALLBACK Options::DlgProcOptsMessages(HWND hwndDlg, UINT msg, WPARAM wPa INT_PTR CALLBACK Options::DlgProcOptsSearching(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
- switch(msg)
- {
- case WM_INITDIALOG:
- {
- TranslateDialogDefault(hwndDlg);
-
- CheckDlgButton(hwndDlg, IDC_FORLIST, instance->searchForInList ? 1 : 0);
- CheckDlgButton(hwndDlg, IDC_FORMES, instance->searchForInMess ? 1 : 0);
- CheckDlgButton(hwndDlg, IDC_MATCHCASE, instance->searchMatchCase ? 1 : 0);
- CheckDlgButton(hwndDlg, IDC_MATCHWHOLE, instance->searchMatchWhole ? 1 : 0);
- CheckDlgButton(hwndDlg, IDC_ONLYIN, instance->searchOnlyIn ? 1 : 0);
- CheckDlgButton(hwndDlg, IDC_ONLYOUT, instance->searchOnlyOut ? 1 : 0);
- CheckDlgButton(hwndDlg, IDC_ONLYGROUP, instance->searchOnlyGroup ? 1 : 0);
- CheckDlgButton(hwndDlg, IDC_ALLCONTACTS, instance->searchAllContacts ? 1 : 0);
- return TRUE;
+ switch(msg) {
+ case WM_INITDIALOG:
+ TranslateDialogDefault(hwndDlg);
+
+ CheckDlgButton(hwndDlg, IDC_FORLIST, instance->searchForInList ? 1 : 0);
+ CheckDlgButton(hwndDlg, IDC_FORMES, instance->searchForInMess ? 1 : 0);
+ CheckDlgButton(hwndDlg, IDC_MATCHCASE, instance->searchMatchCase ? 1 : 0);
+ CheckDlgButton(hwndDlg, IDC_MATCHWHOLE, instance->searchMatchWhole ? 1 : 0);
+ CheckDlgButton(hwndDlg, IDC_ONLYIN, instance->searchOnlyIn ? 1 : 0);
+ CheckDlgButton(hwndDlg, IDC_ONLYOUT, instance->searchOnlyOut ? 1 : 0);
+ CheckDlgButton(hwndDlg, IDC_ONLYGROUP, instance->searchOnlyGroup ? 1 : 0);
+ CheckDlgButton(hwndDlg, IDC_ALLCONTACTS, instance->searchAllContacts ? 1 : 0);
+ return TRUE;
+
+ case WM_COMMAND:
+ if (HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == IDC_ONLYIN) {
+ if (IsDlgButtonChecked(hwndDlg, IDC_ONLYIN) && IsDlgButtonChecked(hwndDlg, IDC_ONLYOUT))
+ CheckDlgButton(hwndDlg, IDC_ONLYOUT, 0);
}
- case WM_COMMAND:
- {
- if (HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == IDC_ONLYIN)
- {
- if (IsDlgButtonChecked(hwndDlg, IDC_ONLYIN) && IsDlgButtonChecked(hwndDlg, IDC_ONLYOUT))
- {
- CheckDlgButton(hwndDlg, IDC_ONLYOUT, 0);
- }
- }
- else if (HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == IDC_ONLYOUT)
- {
- if (IsDlgButtonChecked(hwndDlg, IDC_ONLYOUT) && IsDlgButtonChecked(hwndDlg, IDC_ONLYIN))
- {
- CheckDlgButton(hwndDlg, IDC_ONLYIN, 0);
- }
- }
-
- if (HIWORD(wParam) == BN_CLICKED)
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- return TRUE;
+ else if (HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == IDC_ONLYOUT) {
+ if (IsDlgButtonChecked(hwndDlg, IDC_ONLYOUT) && IsDlgButtonChecked(hwndDlg, IDC_ONLYIN))
+ CheckDlgButton(hwndDlg, IDC_ONLYIN, 0);
}
- case WM_NOTIFY:
- {
- if (((LPNMHDR)lParam)->code == PSN_APPLY)
- {
- instance->searchForInList = IsDlgButtonChecked(hwndDlg, IDC_FORLIST) ? true : false;
- instance->searchForInMess = IsDlgButtonChecked(hwndDlg, IDC_FORMES) ? true : false;
- instance->searchMatchCase = IsDlgButtonChecked(hwndDlg, IDC_MATCHCASE) ? true : false;
- instance->searchMatchWhole = IsDlgButtonChecked(hwndDlg, IDC_MATCHWHOLE) ? true : false;
- instance->searchOnlyIn = IsDlgButtonChecked(hwndDlg, IDC_ONLYIN) ? true : false;
- instance->searchOnlyOut = IsDlgButtonChecked(hwndDlg, IDC_ONLYOUT) ? true : false;
- instance->searchOnlyGroup = IsDlgButtonChecked(hwndDlg, IDC_ONLYGROUP) ? true : false;
- instance->searchAllContacts = IsDlgButtonChecked(hwndDlg, IDC_ALLCONTACTS) ? true : false;
-
- Options::instance->Save();
- OptionsSearchingChanged();
- }
- return TRUE;
+
+ if (HIWORD(wParam) == BN_CLICKED)
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ return TRUE;
+
+ case WM_NOTIFY:
+ if (((LPNMHDR)lParam)->code == PSN_APPLY) {
+ instance->searchForInList = IsDlgButtonChecked(hwndDlg, IDC_FORLIST) ? true : false;
+ instance->searchForInMess = IsDlgButtonChecked(hwndDlg, IDC_FORMES) ? true : false;
+ instance->searchMatchCase = IsDlgButtonChecked(hwndDlg, IDC_MATCHCASE) ? true : false;
+ instance->searchMatchWhole = IsDlgButtonChecked(hwndDlg, IDC_MATCHWHOLE) ? true : false;
+ instance->searchOnlyIn = IsDlgButtonChecked(hwndDlg, IDC_ONLYIN) ? true : false;
+ instance->searchOnlyOut = IsDlgButtonChecked(hwndDlg, IDC_ONLYOUT) ? true : false;
+ instance->searchOnlyGroup = IsDlgButtonChecked(hwndDlg, IDC_ONLYGROUP) ? true : false;
+ instance->searchAllContacts = IsDlgButtonChecked(hwndDlg, IDC_ALLCONTACTS) ? true : false;
+
+ Options::instance->Save();
+ OptionsSearchingChanged();
}
+ return TRUE;
}
return FALSE;
@@ -1397,23 +1288,18 @@ void InitCodepageCB(HWND hwndCB, unsigned int codepage, const std::wstring& name int cpCount = sizeof(cpTable) / sizeof(cpTable[0]);
int selCpIdx = -1;
ComboBox_LimitText(hwndCB, 256);
- for(int i = 0; i < cpCount; ++i)
- {
+ for (int i = 0; i < cpCount; ++i) {
ComboBox_AddString(hwndCB, TranslateTS(cpTable[i].cpName));
if (cpTable[i].cpId == codepage && name == cpTable[i].cpName)
selCpIdx = i;
}
- if (selCpIdx == -1)
- {
+ if (selCpIdx == -1) {
TCHAR buf[300];
mir_sntprintf(buf, 300, _T("%d;%s"), codepage, name.c_str());
ComboBox_SetText(hwndCB, buf);
}
- else
- {
- ComboBox_SetCurSel(hwndCB, selCpIdx);
- }
+ else ComboBox_SetCurSel(hwndCB, selCpIdx);
ComboBox_LimitText(hwndCB, 127);
}
@@ -1421,25 +1307,21 @@ void InitCodepageCB(HWND hwndCB, unsigned int codepage, const std::wstring& name unsigned int GetCodepageCB(HWND hwndCB, bool errorReport, unsigned int defCp, const std::wstring& defName, std::wstring& name)
{
int selCpIdx = ComboBox_GetCurSel(hwndCB);
- if (selCpIdx < 0)
- {
+ if (selCpIdx < 0) {
TCHAR text[128];
ComboBox_GetText(hwndCB, text, 128);
std::wstring str = text;
name = _T("");
size_t pos = str.find_first_of(_T(';'));
- if (pos < str.length())
- {
+ if (pos < str.length()) {
text[pos] = 0;
name = str.substr(pos + 1);
}
TCHAR * stopOn = NULL;
long cp = _tcstol(text, &stopOn, 10);
- if ((pos >= str.length() || name.empty() || stopOn == text || *stopOn != '\0' || cp < 0 || cp > 0xffff))
- {
- if (errorReport)
- {
+ if ((pos >= str.length() || name.empty() || stopOn == text || *stopOn != '\0' || cp < 0 || cp > 0xffff)) {
+ if (errorReport) {
MessageBox(GetParent(hwndCB), TranslateT("You've entered invalid codepage. Select codepage from combo box or enter correct number."), TranslateT("Invalid codepage"), MB_OK | MB_ICONERROR);
SetFocus(hwndCB);
}
@@ -1450,8 +1332,7 @@ unsigned int GetCodepageCB(HWND hwndCB, bool errorReport, unsigned int defCp, co return cp;
}
- else
- {
+ else {
name = cpTable[selCpIdx].cpName;
return cpTable[selCpIdx].cpId;
}
@@ -1459,114 +1340,97 @@ unsigned int GetCodepageCB(HWND hwndCB, bool errorReport, unsigned int defCp, co INT_PTR CALLBACK Options::DlgProcOptsExport(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
- switch(msg)
- {
- case WM_INITDIALOG:
- {
- TranslateDialogDefault(hwndDlg);
- SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)FALSE);
- InitCodepageCB(GetDlgItem(hwndDlg, IDC_TXTENC), instance->codepageTxt, instance->encodingTxt);
- InitCodepageCB(GetDlgItem(hwndDlg, IDC_HTML1ENC), instance->codepageHtml1, instance->encodingHtml1);
- InitCodepageCB(GetDlgItem(hwndDlg, IDC_HTML2ENC), instance->codepageHtml2, instance->encodingHtml2);
- CheckDlgButton(hwndDlg, IDC_HTML1DATE, instance->exportHtml1ShowDate ? 1 : 0);
- CheckDlgButton(hwndDlg, IDC_HTML2DATE, instance->exportHtml2ShowDate ? 1 : 0);
- CheckDlgButton(hwndDlg, IDC_HTML2SHOWSMILEYS, instance->exportHtml2UseSmileys ? 1 : 0);
- Edit_LimitText(GetDlgItem(hwndDlg, IDC_HTML2EXTCSSFILE), MAX_PATH);
- if (instance->extCssHtml2.empty())
- {
- EnableWindow(GetDlgItem(hwndDlg, IDC_HTML2EXTCSSFILE), FALSE);
- EnableWindow(GetDlgItem(hwndDlg, IDC_CSS_BROWSE), FALSE);
- }
- else
- {
- CheckDlgButton(hwndDlg, IDC_HTML2EXTCSS, TRUE);
- Edit_SetText(GetDlgItem(hwndDlg, IDC_HTML2EXTCSSFILE), instance->extCssHtml2.c_str());
- }
-
- if (!g_SmileyAddAvail)
- EnableWindow(GetDlgItem(hwndDlg, IDC_HTML2SHOWSMILEYS), FALSE);
- SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)TRUE);
- return TRUE;
+ switch(msg) {
+ case WM_INITDIALOG:
+ TranslateDialogDefault(hwndDlg);
+ SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)FALSE);
+ InitCodepageCB(GetDlgItem(hwndDlg, IDC_TXTENC), instance->codepageTxt, instance->encodingTxt);
+ InitCodepageCB(GetDlgItem(hwndDlg, IDC_HTML1ENC), instance->codepageHtml1, instance->encodingHtml1);
+ InitCodepageCB(GetDlgItem(hwndDlg, IDC_HTML2ENC), instance->codepageHtml2, instance->encodingHtml2);
+ CheckDlgButton(hwndDlg, IDC_HTML1DATE, instance->exportHtml1ShowDate ? 1 : 0);
+ CheckDlgButton(hwndDlg, IDC_HTML2DATE, instance->exportHtml2ShowDate ? 1 : 0);
+ CheckDlgButton(hwndDlg, IDC_HTML2SHOWSMILEYS, instance->exportHtml2UseSmileys ? 1 : 0);
+ Edit_LimitText(GetDlgItem(hwndDlg, IDC_HTML2EXTCSSFILE), MAX_PATH);
+ if (instance->extCssHtml2.empty()) {
+ EnableWindow(GetDlgItem(hwndDlg, IDC_HTML2EXTCSSFILE), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CSS_BROWSE), FALSE);
+ }
+ else {
+ CheckDlgButton(hwndDlg, IDC_HTML2EXTCSS, TRUE);
+ Edit_SetText(GetDlgItem(hwndDlg, IDC_HTML2EXTCSSFILE), instance->extCssHtml2.c_str());
}
- case WM_COMMAND:
+
+ if (!g_SmileyAddAvail)
+ EnableWindow(GetDlgItem(hwndDlg, IDC_HTML2SHOWSMILEYS), FALSE);
+ SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)TRUE);
+
+ return TRUE;
+
+ case WM_COMMAND:
{
BOOL init = (BOOL)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
- if (HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == IDC_HTML2EXTCSS)
- {
+ if (HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == IDC_HTML2EXTCSS) {
BOOL en = (BOOL)IsDlgButtonChecked(hwndDlg, IDC_HTML2EXTCSS);
EnableWindow(GetDlgItem(hwndDlg, IDC_HTML2EXTCSSFILE), en);
EnableWindow(GetDlgItem(hwndDlg, IDC_CSS_BROWSE), en);
}
- else if (HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == IDC_CSS_BROWSE)
- {
+ else if (HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == IDC_CSS_BROWSE) {
if (!OpenFileDlg(hwndDlg, GetDlgItem(hwndDlg, IDC_HTML2EXTCSSFILE), _T(""), _T("css"), TranslateT("Browse CSS file"), true))
- {
return TRUE;
- }
}
if (init && (HIWORD(wParam) == BN_CLICKED || HIWORD(wParam)==CBN_SELCHANGE || HIWORD(wParam)==CBN_EDITCHANGE || HIWORD(wParam) == EN_CHANGE))
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- return TRUE;
}
- case WM_NOTIFY:
- {
- if (((LPNMHDR)lParam)->code == PSN_APPLY)
- {
- std::wstring newName1, newName2, newName3;
- unsigned int cp1 = GetCodepageCB(GetDlgItem(hwndDlg, IDC_TXTENC), true, instance->codepageTxt, instance->encodingTxt, newName1);
- if (cp1 == -1)
- {
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, PSNRET_INVALID_NOCHANGEPAGE);
- return TRUE;
- }
- unsigned int cp2 = GetCodepageCB(GetDlgItem(hwndDlg, IDC_HTML1ENC), true, instance->codepageHtml1, instance->encodingHtml1, newName2);
- if (cp2 == -1)
- {
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, PSNRET_INVALID_NOCHANGEPAGE);
- return TRUE;
- }
- unsigned int cp3 = GetCodepageCB(GetDlgItem(hwndDlg, IDC_HTML2ENC), true, instance->codepageHtml2, instance->encodingHtml2, newName3);
- if (cp3 == -1)
- {
+ return TRUE;
+
+ case WM_NOTIFY:
+ if (((LPNMHDR)lParam)->code == PSN_APPLY) {
+ std::wstring newName1, newName2, newName3;
+ unsigned int cp1 = GetCodepageCB(GetDlgItem(hwndDlg, IDC_TXTENC), true, instance->codepageTxt, instance->encodingTxt, newName1);
+ if (cp1 == -1) {
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, PSNRET_INVALID_NOCHANGEPAGE);
+ return TRUE;
+ }
+ unsigned int cp2 = GetCodepageCB(GetDlgItem(hwndDlg, IDC_HTML1ENC), true, instance->codepageHtml1, instance->encodingHtml1, newName2);
+ if (cp2 == -1) {
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, PSNRET_INVALID_NOCHANGEPAGE);
+ return TRUE;
+ }
+ unsigned int cp3 = GetCodepageCB(GetDlgItem(hwndDlg, IDC_HTML2ENC), true, instance->codepageHtml2, instance->encodingHtml2, newName3);
+ if (cp3 == -1) {
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, PSNRET_INVALID_NOCHANGEPAGE);
+ return TRUE;
+ }
+ if (IsDlgButtonChecked(hwndDlg, IDC_HTML2EXTCSS)) {
+ if (!CheckFile(GetDlgItem(hwndDlg, IDC_HTML2EXTCSSFILE))) {
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, PSNRET_INVALID_NOCHANGEPAGE);
return TRUE;
}
- if (IsDlgButtonChecked(hwndDlg, IDC_HTML2EXTCSS))
- {
- if (!CheckFile(GetDlgItem(hwndDlg, IDC_HTML2EXTCSSFILE)))
- {
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, PSNRET_INVALID_NOCHANGEPAGE);
- return TRUE;
- }
-
- TCHAR buf[MAX_PATH];
- Edit_GetText(GetDlgItem(hwndDlg, IDC_HTML2EXTCSSFILE), buf, MAX_PATH);
- instance->extCssHtml2 = buf;
- }
- else
- {
- instance->extCssHtml2 = _T("");
- }
- instance->codepageTxt = cp1;
- instance->encodingTxt = newName1;
- instance->codepageHtml1 = cp2;
- instance->encodingHtml1 = newName2;
- instance->codepageHtml2 = cp3;
- instance->encodingHtml2 = newName3;
- instance->exportHtml1ShowDate = IsDlgButtonChecked(hwndDlg, IDC_HTML1DATE) ? true : false;
- instance->exportHtml2ShowDate = IsDlgButtonChecked(hwndDlg, IDC_HTML2DATE) ? true : false;
- instance->exportHtml2UseSmileys = IsDlgButtonChecked(hwndDlg, IDC_HTML2SHOWSMILEYS) ? true : false;
-
- Options::instance->Save();
+ TCHAR buf[MAX_PATH];
+ Edit_GetText(GetDlgItem(hwndDlg, IDC_HTML2EXTCSSFILE), buf, MAX_PATH);
+ instance->extCssHtml2 = buf;
}
- return TRUE;
+ else instance->extCssHtml2 = _T("");
+
+ instance->codepageTxt = cp1;
+ instance->encodingTxt = newName1;
+ instance->codepageHtml1 = cp2;
+ instance->encodingHtml1 = newName2;
+ instance->codepageHtml2 = cp3;
+ instance->encodingHtml2 = newName3;
+ instance->exportHtml1ShowDate = IsDlgButtonChecked(hwndDlg, IDC_HTML1DATE) ? true : false;
+ instance->exportHtml2ShowDate = IsDlgButtonChecked(hwndDlg, IDC_HTML2DATE) ? true : false;
+ instance->exportHtml2UseSmileys = IsDlgButtonChecked(hwndDlg, IDC_HTML2SHOWSMILEYS) ? true : false;
+
+ Options::instance->Save();
}
+ return TRUE;
}
return FALSE;
@@ -1581,137 +1445,117 @@ struct DlgTaskOpt INT_PTR CALLBACK Options::DlgProcOptsScheduler(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
- switch(msg)
- {
- case WM_INITDIALOG:
+ std::list<TaskOptions>* tasks = (std::list<TaskOptions>*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+
+ switch(msg) {
+ case WM_INITDIALOG:
+ TranslateDialogDefault(hwndDlg);
{
- TranslateDialogDefault(hwndDlg);
- std::list<TaskOptions>* tasks = new std::list<TaskOptions>(Options::instance->taskOptions.begin(), Options::instance->taskOptions.end());
+ tasks = new std::list<TaskOptions>(Options::instance->taskOptions.begin(), Options::instance->taskOptions.end());
SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)tasks);
HWND listTasks = GetDlgItem(hwndDlg, IDC_LIST_TASKS);
- for(std::list<TaskOptions>::iterator it = tasks->begin(); it != tasks->end(); ++it)
- {
+ for (std::list<TaskOptions>::iterator it = tasks->begin(); it != tasks->end(); ++it)
ListBox_AddString(listTasks, it->taskName.c_str());
- }
if (!bPopupsEnabled)
- {
EnableWindow(GetDlgItem(hwndDlg, IDC_SCHEDULER_ALERTS), FALSE);
- }
CheckDlgButton(hwndDlg, IDC_SCHEDULER_ALERTS, instance->schedulerAlerts ? 1 : 0);
CheckDlgButton(hwndDlg, IDC_SCHEDULER_HISTORY_ALERTS, instance->schedulerHistoryAlerts ? 1 : 0);
-
+
EnableWindow(GetDlgItem(hwndDlg, IDC_EDIT_TASK), FALSE);
EnableWindow(GetDlgItem(hwndDlg, IDC_DELETE_TASK), FALSE);
- return TRUE;
}
- case WM_COMMAND:
- {
- if (HIWORD(wParam) == BN_CLICKED)
- {
- std::list<TaskOptions>* tasks = (std::list<TaskOptions>*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
- HWND listTasks = GetDlgItem(hwndDlg, IDC_LIST_TASKS);
- int sel = ListBox_GetCurSel(listTasks);
- TaskOptions toAdd;
- TaskOptions* to = &toAdd;
- switch(LOWORD(wParam))
- {
- case IDC_EDIT_TASK:
- if (sel >= 0)
- {
- std::list<TaskOptions>::iterator it = tasks->begin();
- while(sel-- > 0 && it != tasks->end())
- ++it;
- if (it == tasks->end())
- break;
- to = &(*it);
- }
- else
+ return TRUE;
+
+ case WM_COMMAND:
+ if (HIWORD(wParam) == BN_CLICKED) {
+ HWND listTasks = GetDlgItem(hwndDlg, IDC_LIST_TASKS);
+ int sel = ListBox_GetCurSel(listTasks);
+ TaskOptions toAdd;
+ TaskOptions* to = &toAdd;
+ switch(LOWORD(wParam)) {
+ case IDC_EDIT_TASK:
+ if (sel >= 0) {
+ std::list<TaskOptions>::iterator it = tasks->begin();
+ while(sel-- > 0 && it != tasks->end())
+ ++it;
+ if (it == tasks->end())
break;
- case IDC_ADD_TASK:
- {
- DlgTaskOpt top;
- top.tasks = tasks;
- top.to = to;
- if (DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_DLG_TASK), hwndDlg, DlgProcOptsTask, (LPARAM)&top) == IDOK)
- {
- if (LOWORD(wParam) == IDC_ADD_TASK)
- {
- tasks->push_back(*to);
- ListBox_AddString(listTasks, to->taskName.c_str());
- ListBox_SetCurSel(listTasks, tasks->size() - 1);
- }
- else
- {
- sel = ListBox_GetCurSel(listTasks);
- ListBox_DeleteString(listTasks, sel);
- ListBox_InsertString(listTasks, sel, to->taskName.c_str());
- ListBox_SetCurSel(listTasks, sel);
- }
- EnableWindow(GetDlgItem(hwndDlg, IDC_EDIT_TASK), TRUE);
- EnableWindow(GetDlgItem(hwndDlg, IDC_DELETE_TASK), TRUE);
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- }
- }
+ to = &(*it);
+ }
+ else break;
- break;
- case IDC_DELETE_TASK:
- if (sel >= 0)
- {
- ListBox_DeleteString(listTasks, sel);
- std::list<TaskOptions>::iterator it = tasks->begin();
- while(sel-- > 0 && it != tasks->end())
- ++it;
- if (it != tasks->end())
- tasks->erase(it);
- EnableWindow(GetDlgItem(hwndDlg, IDC_EDIT_TASK), FALSE);
- EnableWindow(GetDlgItem(hwndDlg, IDC_DELETE_TASK), FALSE);
+ case IDC_ADD_TASK:
+ {
+ DlgTaskOpt top;
+ top.tasks = tasks;
+ top.to = to;
+ if (DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_DLG_TASK), hwndDlg, DlgProcOptsTask, (LPARAM)&top) == IDOK) {
+ if (LOWORD(wParam) == IDC_ADD_TASK) {
+ tasks->push_back(*to);
+ ListBox_AddString(listTasks, to->taskName.c_str());
+ ListBox_SetCurSel(listTasks, tasks->size() - 1);
+ }
+ else {
+ sel = ListBox_GetCurSel(listTasks);
+ ListBox_DeleteString(listTasks, sel);
+ ListBox_InsertString(listTasks, sel, to->taskName.c_str());
+ ListBox_SetCurSel(listTasks, sel);
+ }
+ EnableWindow(GetDlgItem(hwndDlg, IDC_EDIT_TASK), TRUE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_DELETE_TASK), TRUE);
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
}
-
- break;
- default:
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
}
- }
- else if (HIWORD(wParam) == CBN_SELCHANGE && LOWORD(wParam) == IDC_LIST_TASKS)
- {
- HWND listTasks = GetDlgItem(hwndDlg, IDC_LIST_TASKS);
- int sel = ListBox_GetCurSel(listTasks);
- if (sel < 0)
- {
+ break;
+
+ case IDC_DELETE_TASK:
+ if (sel >= 0) {
+ ListBox_DeleteString(listTasks, sel);
+ std::list<TaskOptions>::iterator it = tasks->begin();
+ while(sel-- > 0 && it != tasks->end())
+ ++it;
+ if (it != tasks->end())
+ tasks->erase(it);
EnableWindow(GetDlgItem(hwndDlg, IDC_EDIT_TASK), FALSE);
EnableWindow(GetDlgItem(hwndDlg, IDC_DELETE_TASK), FALSE);
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
}
- else
- {
- EnableWindow(GetDlgItem(hwndDlg, IDC_EDIT_TASK), TRUE);
- EnableWindow(GetDlgItem(hwndDlg, IDC_DELETE_TASK), TRUE);
- }
+ break;
+
+ default:
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
}
- return TRUE;
}
- case WM_NOTIFY:
- {
- if (((LPNMHDR)lParam)->code == PSN_APPLY)
- {
- std::list<TaskOptions>* tasks = (std::list<TaskOptions>*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
- instance->schedulerAlerts = IsDlgButtonChecked(hwndDlg, IDC_SCHEDULER_ALERTS) ? true : false;
- instance->schedulerHistoryAlerts = IsDlgButtonChecked(hwndDlg, IDC_SCHEDULER_HISTORY_ALERTS) ? true : false;
- Options::instance->SaveTasks(tasks);
- OptionsSchedulerChanged();
- InitTaskMenuItems();
+ else if (HIWORD(wParam) == CBN_SELCHANGE && LOWORD(wParam) == IDC_LIST_TASKS) {
+ HWND listTasks = GetDlgItem(hwndDlg, IDC_LIST_TASKS);
+ int sel = ListBox_GetCurSel(listTasks);
+ if (sel < 0) {
+ EnableWindow(GetDlgItem(hwndDlg, IDC_EDIT_TASK), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_DELETE_TASK), FALSE);
+ }
+ else {
+ EnableWindow(GetDlgItem(hwndDlg, IDC_EDIT_TASK), TRUE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_DELETE_TASK), TRUE);
}
- return TRUE;
}
- case WM_DESTROY:
- {
- std::list<TaskOptions>* tasks = (std::list<TaskOptions>*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
- delete tasks;
- SetWindowLongPtr(hwndDlg, GWLP_USERDATA, NULL);
- break;
+ return TRUE;
+
+ case WM_NOTIFY:
+ if (((LPNMHDR)lParam)->code == PSN_APPLY) {
+ instance->schedulerAlerts = IsDlgButtonChecked(hwndDlg, IDC_SCHEDULER_ALERTS) ? true : false;
+ instance->schedulerHistoryAlerts = IsDlgButtonChecked(hwndDlg, IDC_SCHEDULER_HISTORY_ALERTS) ? true : false;
+ Options::instance->SaveTasks(tasks);
+ OptionsSchedulerChanged();
+ InitTaskMenuItems();
}
+ return TRUE;
+
+ case WM_DESTROY:
+ delete tasks;
+ SetWindowLongPtr(hwndDlg, GWLP_USERDATA, NULL);
+ break;
}
return FALSE;
@@ -1732,12 +1576,9 @@ void RebuildList(HWND hwnd, HANDLE hSystem, TaskOptions* to) {
HANDLE hItem;
if (to->isSystem && hSystem)
- {
SendMessage(hwnd, CLM_SETCHECKMARK, (WPARAM) hSystem, 1);
- }
- for(size_t i = 0; i < to->contacts.size(); ++i)
- {
+ for (size_t i = 0; i < to->contacts.size(); ++i) {
hItem = (HANDLE) SendMessage(hwnd, CLM_FINDCONTACT, (WPARAM) to->contacts[i], 0);
if (hItem)
SendMessage(hwnd, CLM_SETCHECKMARK, (WPARAM) hItem, 1);
@@ -1766,11 +1607,10 @@ bool IsValidTask(TaskOptions& to, std::list<TaskOptions>* top = NULL, std::wstri INT_PTR CALLBACK Options::DlgProcOptsTask(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
static HANDLE hSystem;
- switch(msg)
- {
- case WM_INITDIALOG:
+ switch(msg) {
+ case WM_INITDIALOG:
+ TranslateDialogDefault(hwndDlg);
{
- TranslateDialogDefault(hwndDlg);
DlgTaskOpt* top = (DlgTaskOpt*)lParam;
TaskOptions* to = top->to;
SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam);
@@ -1794,7 +1634,7 @@ INT_PTR CALLBACK Options::DlgProcOptsTask(HWND hwndDlg, UINT msg, WPARAM wParam, HWND star = GetDlgItem(hwndDlg, IDC_TASK_STAR);
HWND password = GetDlgItem(hwndDlg, IDC_PASSWORD);
HWND expImp = GetDlgItem(hwndDlg, IDC_EXPIMP);
-
+
Edit_LimitText(name, 16);
Edit_SetText(name, to->taskName.c_str());
@@ -1822,14 +1662,11 @@ INT_PTR CALLBACK Options::DlgProcOptsTask(HWND hwndDlg, UINT msg, WPARAM wParam, if (selFilter > 1)
selFilter = 0;
int i = 1;
- for(std::vector<FilterOptions>::iterator it = instance->customFilters.begin(); it != instance->customFilters.end(); ++it)
- {
+ for (std::vector<FilterOptions>::iterator it = instance->customFilters.begin(); it != instance->customFilters.end(); ++it) {
++i;
ComboBox_AddString(filter, it->name.c_str());
if (to->filterId > 1 && it->name == to->filterName)
- {
selFilter = i;
- }
}
ComboBox_SetCurSel(filter, selFilter);
@@ -1856,12 +1693,11 @@ INT_PTR CALLBACK Options::DlgProcOptsTask(HWND hwndDlg, UINT msg, WPARAM wParam, Button_SetCheck(compress, to->compress);
Edit_LimitText(password, 99);
SetWindowTextA(password, to->zipPassword.c_str());
-
+
Edit_LimitText(exportPath, MAX_PATH);
Edit_SetText(exportPath, to->filePath.c_str());
-
- if (!FTPAvail())
- {
+
+ if (!FTPAvail()) {
EnableWindow(ftpFile, FALSE);
EnableWindow(ftpFileButton, FALSE);
to->useFtp = false;
@@ -1878,16 +1714,15 @@ INT_PTR CALLBACK Options::DlgProcOptsTask(HWND hwndDlg, UINT msg, WPARAM wParam, ComboBox_AddString(weekList, TranslateT("Saturday"));
ComboBox_AddString(weekList, TranslateT("Sunday"));
ComboBox_SetCurSel(weekList, to->dayOfWeek);
-
+
Edit_LimitText(day, 2);
SetDlgItemInt(hwndDlg, IDC_TRIGER_DAY, to->dayOfMonth, FALSE);
Edit_LimitText(deltaTime, 4);
SetDlgItemInt(hwndDlg, IDC_TRIGER_DELTA_TIME, to->deltaTime, FALSE);
-
+
TCHAR timeFormat[10];
- if (GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SSHORTTIME, timeFormat, 10) == 0)
- {
+ if (GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SSHORTTIME, timeFormat, 10) == 0) {
TCHAR sep = _T(':');
if (GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_STIME, timeFormat, 10) > 0)
sep = timeFormat[0];
@@ -1917,229 +1752,194 @@ INT_PTR CALLBACK Options::DlgProcOptsTask(HWND hwndDlg, UINT msg, WPARAM wParam, SendMessage(hwndDlg, WM_COMMAND, MAKEWPARAM(IDC_COMPRESS, BN_CLICKED), NULL);
SendMessage(hwndDlg, WM_COMMAND, MAKEWPARAM(IDC_UPLOAD, BN_CLICKED), NULL);
SendMessage(hwndDlg, WM_COMMAND, MAKEWPARAM(IDC_COMPRESS, BN_CLICKED), NULL);
- return TRUE;
}
- case WM_COMMAND:
- {
- if (HIWORD(wParam) == BN_CLICKED)
- {
- if (LOWORD(wParam) == IDOK)
- {
- DlgTaskOpt* top = (DlgTaskOpt*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
- TaskOptions* to = top->to;
- TaskOptions toCp(*to);
- toCp.taskName.resize(17);
- int nameLen = Edit_GetText(GetDlgItem(hwndDlg, IDC_TASK_NAME), (wchar_t*)toCp.taskName.c_str(), 17);
- toCp.taskName.resize(nameLen);
- toCp.active = Button_GetCheck(GetDlgItem(hwndDlg, IDC_TASK_ACTIVE)) != 0;
- toCp.exportImported = Button_GetCheck(GetDlgItem(hwndDlg, IDC_EXPIMP)) != 0;
- toCp.type = (enum TaskOptions::TaskType)ComboBox_GetCurSel(GetDlgItem(hwndDlg, IDC_TASK_TYPE));
- toCp.filterId = ComboBox_GetCurSel(GetDlgItem(hwndDlg, IDC_TASK_FILTER));
- if (toCp.filterId > 1)
- toCp.filterName = instance->customFilters[toCp.filterId - 2].name;
- BOOL isOK = FALSE;
- toCp.eventDeltaTime = GetDlgItemInt(hwndDlg, IDC_EVENT_TIME, &isOK, TRUE);
- if (!isOK)
- {
+ return TRUE;
+
+ case WM_COMMAND:
+ if (HIWORD(wParam) == BN_CLICKED) {
+ if (LOWORD(wParam) == IDOK) {
+ DlgTaskOpt* top = (DlgTaskOpt*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+ TaskOptions* to = top->to;
+ TaskOptions toCp(*to);
+ toCp.taskName.resize(17);
+ int nameLen = Edit_GetText(GetDlgItem(hwndDlg, IDC_TASK_NAME), (wchar_t*)toCp.taskName.c_str(), 17);
+ toCp.taskName.resize(nameLen);
+ toCp.active = Button_GetCheck(GetDlgItem(hwndDlg, IDC_TASK_ACTIVE)) != 0;
+ toCp.exportImported = Button_GetCheck(GetDlgItem(hwndDlg, IDC_EXPIMP)) != 0;
+ toCp.type = (enum TaskOptions::TaskType)ComboBox_GetCurSel(GetDlgItem(hwndDlg, IDC_TASK_TYPE));
+ toCp.filterId = ComboBox_GetCurSel(GetDlgItem(hwndDlg, IDC_TASK_FILTER));
+ if (toCp.filterId > 1)
+ toCp.filterName = instance->customFilters[toCp.filterId - 2].name;
+ BOOL isOK = FALSE;
+ toCp.eventDeltaTime = GetDlgItemInt(hwndDlg, IDC_EVENT_TIME, &isOK, TRUE);
+ if (!isOK) {
+ TCHAR msg[256];
+ mir_sntprintf(msg, SIZEOF(msg), TranslateT("Invalid '%s' value."), TranslateT("Events older than"));
+ MessageBox(hwndDlg, msg, TranslateT("Error"), MB_ICONERROR);
+ break;
+ }
+ toCp.eventUnit = (enum TaskOptions::EventUnit)ComboBox_GetCurSel(GetDlgItem(hwndDlg, IDC_EVENT_UNIT));
+ toCp.trigerType = (enum TaskOptions::TrigerType)ComboBox_GetCurSel(GetDlgItem(hwndDlg, IDC_TRIGER_TYPE));
+ toCp.exportType = (enum IExport::ExportType)ComboBox_GetCurSel(GetDlgItem(hwndDlg, IDC_EXPORT_TYPE));
+ toCp.importType = (enum IImport::ImportType)ComboBox_GetCurSel(GetDlgItem(hwndDlg, IDC_IMPORT_TYPE));
+ toCp.compress = Button_GetCheck(GetDlgItem(hwndDlg, IDC_COMPRESS)) != 0;
+ char bufC[100];
+ GetWindowTextA(GetDlgItem(hwndDlg, IDC_PASSWORD), bufC, 100);
+ toCp.zipPassword = bufC;
+ HWND exportPath = GetDlgItem(hwndDlg, IDC_EXPORT_PATH);
+ int exLen = Edit_GetTextLength(exportPath);
+ toCp.filePath.resize(exLen + 1);
+ Edit_GetText(exportPath, (wchar_t*)toCp.filePath.c_str(), exLen + 1);
+ toCp.filePath.resize(exLen);
+ toCp.useFtp = Button_GetCheck(GetDlgItem(hwndDlg, IDC_UPLOAD)) != 0;
+ HWND ftpFile = GetDlgItem(hwndDlg, IDC_FTP);
+ exLen = Edit_GetTextLength(ftpFile);
+ toCp.ftpName.resize(exLen + 1);
+ Edit_GetText(ftpFile, (wchar_t*)toCp.ftpName.c_str(), exLen + 1);
+ toCp.ftpName.resize(exLen);
+ SYSTEMTIME st;
+ DateTime_GetSystemtime(GetDlgItem(hwndDlg, IDC_TRIGER_TIME), &st);
+ toCp.dayTime = st.wHour * 60 + st.wMinute;
+ toCp.dayOfWeek = ComboBox_GetCurSel(GetDlgItem(hwndDlg, IDC_TRIGER_WEEK));
+ toCp.dayOfMonth = GetDlgItemInt(hwndDlg, IDC_TRIGER_DAY, &isOK, FALSE);
+ if (!isOK) {
+ if (toCp.trigerType == TaskOptions::Monthly) {
TCHAR msg[256];
- mir_sntprintf(msg, SIZEOF(msg), TranslateT("Invalid '%s' value."), TranslateT("Events older than"));
+ mir_sntprintf(msg, SIZEOF(msg), TranslateT("Invalid '%s' value."), TranslateT("Day"));
MessageBox(hwndDlg, msg, TranslateT("Error"), MB_ICONERROR);
break;
}
- toCp.eventUnit = (enum TaskOptions::EventUnit)ComboBox_GetCurSel(GetDlgItem(hwndDlg, IDC_EVENT_UNIT));
- toCp.trigerType = (enum TaskOptions::TrigerType)ComboBox_GetCurSel(GetDlgItem(hwndDlg, IDC_TRIGER_TYPE));
- toCp.exportType = (enum IExport::ExportType)ComboBox_GetCurSel(GetDlgItem(hwndDlg, IDC_EXPORT_TYPE));
- toCp.importType = (enum IImport::ImportType)ComboBox_GetCurSel(GetDlgItem(hwndDlg, IDC_IMPORT_TYPE));
- toCp.compress = Button_GetCheck(GetDlgItem(hwndDlg, IDC_COMPRESS)) != 0;
- char bufC[100];
- GetWindowTextA(GetDlgItem(hwndDlg, IDC_PASSWORD), bufC, 100);
- toCp.zipPassword = bufC;
- HWND exportPath = GetDlgItem(hwndDlg, IDC_EXPORT_PATH);
- int exLen = Edit_GetTextLength(exportPath);
- toCp.filePath.resize(exLen + 1);
- Edit_GetText(exportPath, (wchar_t*)toCp.filePath.c_str(), exLen + 1);
- toCp.filePath.resize(exLen);
- toCp.useFtp = Button_GetCheck(GetDlgItem(hwndDlg, IDC_UPLOAD)) != 0;
- HWND ftpFile = GetDlgItem(hwndDlg, IDC_FTP);
- exLen = Edit_GetTextLength(ftpFile);
- toCp.ftpName.resize(exLen + 1);
- Edit_GetText(ftpFile, (wchar_t*)toCp.ftpName.c_str(), exLen + 1);
- toCp.ftpName.resize(exLen);
- SYSTEMTIME st;
- DateTime_GetSystemtime(GetDlgItem(hwndDlg, IDC_TRIGER_TIME), &st);
- toCp.dayTime = st.wHour * 60 + st.wMinute;
- toCp.dayOfWeek = ComboBox_GetCurSel(GetDlgItem(hwndDlg, IDC_TRIGER_WEEK));
- toCp.dayOfMonth = GetDlgItemInt(hwndDlg, IDC_TRIGER_DAY, &isOK, FALSE);
- if (!isOK)
- {
- if (toCp.trigerType == TaskOptions::Monthly)
- {
- TCHAR msg[256];
- mir_sntprintf(msg, SIZEOF(msg), TranslateT("Invalid '%s' value."), TranslateT("Day"));
- MessageBox(hwndDlg, msg, TranslateT("Error"), MB_ICONERROR);
- break;
- }
- else
- toCp.dayOfMonth = to->dayOfMonth;
- }
- toCp.deltaTime = GetDlgItemInt(hwndDlg, IDC_TRIGER_DELTA_TIME, &isOK, FALSE);
- if (!isOK)
- {
- if (toCp.trigerType == TaskOptions::DeltaMin || toCp.trigerType == TaskOptions::DeltaHour)
- {
- TCHAR msg[256];
- mir_sntprintf(msg, SIZEOF(msg), TranslateT("Invalid '%s' value."), TranslateT("Delta time"));
- MessageBox(hwndDlg, msg, TranslateT("Error"), MB_ICONERROR);
- break;
- }
- else
- toCp.deltaTime = to->deltaTime;
- }
- SaveList(GetDlgItem(hwndDlg, IDC_LIST_CONTACTSEX), hSystem, &toCp);
- std::wstring err;
- std::wstring errDescr;
- std::wstring lastName = to->taskName;
- to->taskName = L"";
- if (!IsValidTask(toCp, top->tasks, &err, &errDescr))
- {
- to->taskName = lastName;
+ else toCp.dayOfMonth = to->dayOfMonth;
+ }
+ toCp.deltaTime = GetDlgItemInt(hwndDlg, IDC_TRIGER_DELTA_TIME, &isOK, FALSE);
+ if (!isOK) {
+ if (toCp.trigerType == TaskOptions::DeltaMin || toCp.trigerType == TaskOptions::DeltaHour) {
TCHAR msg[256];
- if (err.empty())
- _tcscpy_s(msg, TranslateT("Some value is invalid"));
- else if (errDescr.empty())
- {
- mir_sntprintf(msg, SIZEOF(msg), TranslateT("Invalid '%s' value."), err.c_str());
- }
- else
- {
- mir_sntprintf(msg, SIZEOF(msg), TranslateT("Invalid '%s' value.\n%s"), err.c_str(), errDescr.c_str());
- }
-
+ mir_sntprintf(msg, SIZEOF(msg), TranslateT("Invalid '%s' value."), TranslateT("Delta time"));
MessageBox(hwndDlg, msg, TranslateT("Error"), MB_ICONERROR);
break;
}
-
- toCp.lastExport = time(NULL);
-
- *to = toCp;
- EndDialog(hwndDlg, IDOK);
- }
- else if (LOWORD(wParam) == IDCANCEL)
- {
- EndDialog(hwndDlg, IDCANCEL);
- }
- else if (LOWORD(wParam) == IDC_UPLOAD)
- {
- if (Button_GetCheck(GetDlgItem(hwndDlg, IDC_UPLOAD)) == 0)
- {
- EnableWindow(GetDlgItem(hwndDlg, IDC_FTP), FALSE);
- }
- else
- {
- EnableWindow(GetDlgItem(hwndDlg, IDC_FTP), TRUE);
- }
+ else toCp.deltaTime = to->deltaTime;
}
- else if (LOWORD(wParam) == IDC_COMPRESS)
- {
- if (Button_GetCheck(GetDlgItem(hwndDlg, IDC_COMPRESS)) == 0)
- {
- EnableWindow(GetDlgItem(hwndDlg, IDC_PASSWORD), FALSE);
- EnableWindow(GetDlgItem(hwndDlg, IDC_PASSWORD_LABEL), FALSE);
- }
+ SaveList(GetDlgItem(hwndDlg, IDC_LIST_CONTACTSEX), hSystem, &toCp);
+ std::wstring err;
+ std::wstring errDescr;
+ std::wstring lastName = to->taskName;
+ to->taskName = L"";
+ if (!IsValidTask(toCp, top->tasks, &err, &errDescr)) {
+ to->taskName = lastName;
+ TCHAR msg[256];
+ if (err.empty())
+ _tcscpy_s(msg, TranslateT("Some value is invalid"));
+ else if (errDescr.empty())
+ mir_sntprintf(msg, SIZEOF(msg), TranslateT("Invalid '%s' value."), err.c_str());
else
- {
- EnableWindow(GetDlgItem(hwndDlg, IDC_PASSWORD), TRUE);
- EnableWindow(GetDlgItem(hwndDlg, IDC_PASSWORD_LABEL), TRUE);
- }
+ mir_sntprintf(msg, SIZEOF(msg), TranslateT("Invalid '%s' value.\n%s"), err.c_str(), errDescr.c_str());
+ MessageBox(hwndDlg, msg, TranslateT("Error"), MB_ICONERROR);
+ break;
}
+
+ toCp.lastExport = time(NULL);
+
+ *to = toCp;
+ EndDialog(hwndDlg, IDOK);
+ }
+ else if (LOWORD(wParam) == IDCANCEL) {
+ EndDialog(hwndDlg, IDCANCEL);
}
- else if (HIWORD(wParam) == CBN_SELCHANGE)
+ else if (LOWORD(wParam) == IDC_UPLOAD) {
+ if (Button_GetCheck(GetDlgItem(hwndDlg, IDC_UPLOAD)) == 0)
+ EnableWindow(GetDlgItem(hwndDlg, IDC_FTP), FALSE);
+ else
+ EnableWindow(GetDlgItem(hwndDlg, IDC_FTP), TRUE);
+ }
+ else if (LOWORD(wParam) == IDC_COMPRESS)
{
- if (LOWORD(wParam) == IDC_TASK_TYPE)
- {
- TaskOptions::TaskType sel = (enum TaskOptions::TaskType)ComboBox_GetCurSel(GetDlgItem(hwndDlg, IDC_TASK_TYPE));
- int show = sel == TaskOptions::Delete ? SW_HIDE : SW_SHOW;
- int showFilter = (sel == TaskOptions::Import || sel == TaskOptions::ImportAndMarge) ? SW_HIDE : SW_SHOW;
- int showImport = (sel == TaskOptions::Import || sel == TaskOptions::ImportAndMarge) ? SW_SHOW : SW_HIDE;
- ShowWindow(GetDlgItem(hwndDlg, IDC_EXPORT_TYPE), show);
- ShowWindow(GetDlgItem(hwndDlg, IDC_EXPORT_TYPE_LABEL), show);
- ShowWindow(GetDlgItem(hwndDlg, IDC_COMPRESS), show);
- ShowWindow(GetDlgItem(hwndDlg, IDC_PASSWORD), show);
- ShowWindow(GetDlgItem(hwndDlg, IDC_PASSWORD_LABEL), show);
- ShowWindow(GetDlgItem(hwndDlg, IDC_EXPORT_PATH), show);
- ShowWindow(GetDlgItem(hwndDlg, IDC_EXPORT_PATH_LABEL), show);
- ShowWindow(GetDlgItem(hwndDlg, IDC_FTP), show);
- ShowWindow(GetDlgItem(hwndDlg, IDC_UPLOAD), show);
- ShowWindow(GetDlgItem(hwndDlg, IDC_FTP_LABEL), show);
- ShowWindow(GetDlgItem(hwndDlg, IDC_EXPIMP), show);
- ShowWindow(GetDlgItem(hwndDlg, IDC_TASK_FILTER), showFilter);
- ShowWindow(GetDlgItem(hwndDlg, IDC_TASK_FILTER_LABEL), showFilter);
- ShowWindow(GetDlgItem(hwndDlg, IDC_EVENT_TIME), showFilter);
- ShowWindow(GetDlgItem(hwndDlg, IDC_EVENT_UNIT), showFilter);
- ShowWindow(GetDlgItem(hwndDlg, IDC_EVENT_LABEL), showFilter);
- if (show != showFilter)
- {
- ShowWindow(GetDlgItem(hwndDlg, IDC_EXPORT_TYPE), SW_HIDE);
- ShowWindow(GetDlgItem(hwndDlg, IDC_EXPIMP), SW_HIDE);
- }
-
- ShowWindow(GetDlgItem(hwndDlg, IDC_IMPORT_TYPE), showImport);
- std::wstring str;
- TCHAR* compressText = TranslateT("Compress output files");
- TCHAR* uploadText = TranslateT("Upload to FTP (WinSCP requred)");
- TCHAR* typeText = TranslateT("Export to");
- if (showFilter == SW_HIDE)
- {
- str = TranslateT("** Use <ext> to insert extension, <contact> to insert contact name");
- compressText = TranslateT("Input files are compressed");
- uploadText = TranslateT("Download from FTP (WinSCP requred)");
- typeText = TranslateT("Import from");
- }
- else if (show == SW_HIDE)
- {
- str = TranslateT("* Use negative values to filter younger events");
- }
- else
- {
- str = TranslateT("* Use negative values to filter younger events");
- str += _T("\n");
- str += TranslateT("** Use <date> to insert date, <ext> to insert extension, <contact> to insert contact name");
- }
-
- Static_SetText(GetDlgItem(hwndDlg, IDC_TASK_STAR), str.c_str());
- Button_SetText(GetDlgItem(hwndDlg, IDC_COMPRESS), compressText);
- Button_SetText(GetDlgItem(hwndDlg, IDC_UPLOAD), uploadText);
- Static_SetText(GetDlgItem(hwndDlg, IDC_EXPORT_TYPE_LABEL), typeText);
+ if (Button_GetCheck(GetDlgItem(hwndDlg, IDC_COMPRESS)) == 0) {
+ EnableWindow(GetDlgItem(hwndDlg, IDC_PASSWORD), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_PASSWORD_LABEL), FALSE);
}
- else if (LOWORD(wParam) == IDC_TRIGER_TYPE)
- {
- TaskOptions::TrigerType sel = (enum TaskOptions::TrigerType)ComboBox_GetCurSel(GetDlgItem(hwndDlg, IDC_TRIGER_TYPE));
- int showT = (sel == TaskOptions::Daily || sel == TaskOptions::Weekly || sel == TaskOptions::Monthly) ? SW_SHOW : SW_HIDE;
- int showW = sel == TaskOptions::Weekly ? SW_SHOW : SW_HIDE;
- int showM = sel == TaskOptions::Monthly ? SW_SHOW : SW_HIDE;
- int showDT = (sel == TaskOptions::DeltaMin || sel == TaskOptions::DeltaHour) ? SW_SHOW : SW_HIDE;
- ShowWindow(GetDlgItem(hwndDlg, IDC_TRIGER_TIME), showT);
- ShowWindow(GetDlgItem(hwndDlg, IDC_TRIGER_TIME_LABEL), showT);
- ShowWindow(GetDlgItem(hwndDlg, IDC_TRIGER_WEEK), showW);
- ShowWindow(GetDlgItem(hwndDlg, IDC_TRIGER_WEEK_LABEL), showW);
- ShowWindow(GetDlgItem(hwndDlg, IDC_TRIGER_DAY), showM);
- ShowWindow(GetDlgItem(hwndDlg, IDC_TRIGER_DAY_LABEL), showM);
- ShowWindow(GetDlgItem(hwndDlg, IDC_TRIGER_DELTA_TIME), showDT);
- ShowWindow(GetDlgItem(hwndDlg, IDC_TRIGER_DELTA_TIME_LABEL), showDT);
+ else {
+ EnableWindow(GetDlgItem(hwndDlg, IDC_PASSWORD), TRUE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_PASSWORD_LABEL), TRUE);
}
}
- return TRUE;
}
- case WM_NOTIFY:
- {
- NMHDR* nmhdr = (NMHDR *) lParam;
- if (nmhdr->idFrom == IDC_LIST_CONTACTSEX && nmhdr->code == CLN_OPTIONSCHANGED)
- {
- ResetListOptions(hwndDlg);
- }
+ else if (HIWORD(wParam) == CBN_SELCHANGE) {
+ if (LOWORD(wParam) == IDC_TASK_TYPE) {
+ TaskOptions::TaskType sel = (enum TaskOptions::TaskType)ComboBox_GetCurSel(GetDlgItem(hwndDlg, IDC_TASK_TYPE));
+ int show = sel == TaskOptions::Delete ? SW_HIDE : SW_SHOW;
+ int showFilter = (sel == TaskOptions::Import || sel == TaskOptions::ImportAndMarge) ? SW_HIDE : SW_SHOW;
+ int showImport = (sel == TaskOptions::Import || sel == TaskOptions::ImportAndMarge) ? SW_SHOW : SW_HIDE;
+ ShowWindow(GetDlgItem(hwndDlg, IDC_EXPORT_TYPE), show);
+ ShowWindow(GetDlgItem(hwndDlg, IDC_EXPORT_TYPE_LABEL), show);
+ ShowWindow(GetDlgItem(hwndDlg, IDC_COMPRESS), show);
+ ShowWindow(GetDlgItem(hwndDlg, IDC_PASSWORD), show);
+ ShowWindow(GetDlgItem(hwndDlg, IDC_PASSWORD_LABEL), show);
+ ShowWindow(GetDlgItem(hwndDlg, IDC_EXPORT_PATH), show);
+ ShowWindow(GetDlgItem(hwndDlg, IDC_EXPORT_PATH_LABEL), show);
+ ShowWindow(GetDlgItem(hwndDlg, IDC_FTP), show);
+ ShowWindow(GetDlgItem(hwndDlg, IDC_UPLOAD), show);
+ ShowWindow(GetDlgItem(hwndDlg, IDC_FTP_LABEL), show);
+ ShowWindow(GetDlgItem(hwndDlg, IDC_EXPIMP), show);
+ ShowWindow(GetDlgItem(hwndDlg, IDC_TASK_FILTER), showFilter);
+ ShowWindow(GetDlgItem(hwndDlg, IDC_TASK_FILTER_LABEL), showFilter);
+ ShowWindow(GetDlgItem(hwndDlg, IDC_EVENT_TIME), showFilter);
+ ShowWindow(GetDlgItem(hwndDlg, IDC_EVENT_UNIT), showFilter);
+ ShowWindow(GetDlgItem(hwndDlg, IDC_EVENT_LABEL), showFilter);
+ if (show != showFilter) {
+ ShowWindow(GetDlgItem(hwndDlg, IDC_EXPORT_TYPE), SW_HIDE);
+ ShowWindow(GetDlgItem(hwndDlg, IDC_EXPIMP), SW_HIDE);
+ }
- return TRUE;
+ ShowWindow(GetDlgItem(hwndDlg, IDC_IMPORT_TYPE), showImport);
+ std::wstring str;
+ TCHAR* compressText = TranslateT("Compress output files");
+ TCHAR* uploadText = TranslateT("Upload to FTP (WinSCP requred)");
+ TCHAR* typeText = TranslateT("Export to");
+ if (showFilter == SW_HIDE) {
+ str = TranslateT("** Use <ext> to insert extension, <contact> to insert contact name");
+ compressText = TranslateT("Input files are compressed");
+ uploadText = TranslateT("Download from FTP (WinSCP requred)");
+ typeText = TranslateT("Import from");
+ }
+ else if (show == SW_HIDE)
+ str = TranslateT("* Use negative values to filter younger events");
+ else {
+ str = TranslateT("* Use negative values to filter younger events");
+ str += _T("\n");
+ str += TranslateT("** Use <date> to insert date, <ext> to insert extension, <contact> to insert contact name");
+ }
+
+ Static_SetText(GetDlgItem(hwndDlg, IDC_TASK_STAR), str.c_str());
+ Button_SetText(GetDlgItem(hwndDlg, IDC_COMPRESS), compressText);
+ Button_SetText(GetDlgItem(hwndDlg, IDC_UPLOAD), uploadText);
+ Static_SetText(GetDlgItem(hwndDlg, IDC_EXPORT_TYPE_LABEL), typeText);
+ }
+ else if (LOWORD(wParam) == IDC_TRIGER_TYPE) {
+ TaskOptions::TrigerType sel = (enum TaskOptions::TrigerType)ComboBox_GetCurSel(GetDlgItem(hwndDlg, IDC_TRIGER_TYPE));
+ int showT = (sel == TaskOptions::Daily || sel == TaskOptions::Weekly || sel == TaskOptions::Monthly) ? SW_SHOW : SW_HIDE;
+ int showW = sel == TaskOptions::Weekly ? SW_SHOW : SW_HIDE;
+ int showM = sel == TaskOptions::Monthly ? SW_SHOW : SW_HIDE;
+ int showDT = (sel == TaskOptions::DeltaMin || sel == TaskOptions::DeltaHour) ? SW_SHOW : SW_HIDE;
+ ShowWindow(GetDlgItem(hwndDlg, IDC_TRIGER_TIME), showT);
+ ShowWindow(GetDlgItem(hwndDlg, IDC_TRIGER_TIME_LABEL), showT);
+ ShowWindow(GetDlgItem(hwndDlg, IDC_TRIGER_WEEK), showW);
+ ShowWindow(GetDlgItem(hwndDlg, IDC_TRIGER_WEEK_LABEL), showW);
+ ShowWindow(GetDlgItem(hwndDlg, IDC_TRIGER_DAY), showM);
+ ShowWindow(GetDlgItem(hwndDlg, IDC_TRIGER_DAY_LABEL), showM);
+ ShowWindow(GetDlgItem(hwndDlg, IDC_TRIGER_DELTA_TIME), showDT);
+ ShowWindow(GetDlgItem(hwndDlg, IDC_TRIGER_DELTA_TIME_LABEL), showDT);
+ }
}
+ return TRUE;
+
+ case WM_NOTIFY:
+ NMHDR* nmhdr = (NMHDR *) lParam;
+ if (nmhdr->idFrom == IDC_LIST_CONTACTSEX && nmhdr->code == CLN_OPTIONSCHANGED)
+ ResetListOptions(hwndDlg);
+
+ return TRUE;
}
return FALSE;
diff --git a/plugins/BasicHistory/src/PlainHtmlExport.cpp b/plugins/BasicHistory/src/PlainHtmlExport.cpp index 695b48d78a..6ff0203124 100644 --- a/plugins/BasicHistory/src/PlainHtmlExport.cpp +++ b/plugins/BasicHistory/src/PlainHtmlExport.cpp @@ -53,23 +53,15 @@ void PlainHtmlExport::WriteHeader(const std::wstring &fileName, const std::wstri EXP_FILE << _T("--></style>\n</head><body>\n<h4>") << TranslateT("History Log") << _T("</h4>\n<h3>");
EXP_FILE << MakeTextHtmled(myName);
if (proto1.length() || myId.length())
- {
EXP_FILE << _T(" (") << MakeTextHtmled(proto1) << _T(": ") << MakeTextHtmled(myId) << _T(") - ");
- }
else
- {
EXP_FILE << _T(" - ");
- }
EXP_FILE << MakeTextHtmled(name1);
if (proto1.length() || id1.length())
- {
EXP_FILE << _T(" (") << MakeTextHtmled(proto1) << _T(": ") << MakeTextHtmled(id1) << _T(")</h3>\n");
- }
else
- {
EXP_FILE << _T("</h3>\n");
- }
EXP_FILE << _T("<h6>") << TranslateT("Filter:") << _T(" ") << MakeTextHtmled(filterName) << _T("</h6>\n");
}
diff --git a/plugins/BasicHistory/src/RichHtmlExport.cpp b/plugins/BasicHistory/src/RichHtmlExport.cpp index 62263145b7..c9552f7cb8 100644 --- a/plugins/BasicHistory/src/RichHtmlExport.cpp +++ b/plugins/BasicHistory/src/RichHtmlExport.cpp @@ -36,11 +36,9 @@ std::wstring MakeTextHtmled(const std::wstring& message, std::queue<std::pair<si size_t start = 0;
size_t find;
size_t currentAdd = 0;
- while((find = message.find_first_of(search, start)) < message.length())
- {
+ while((find = message.find_first_of(search, start)) < message.length()) {
ret += message.substr(start, find - start);
- switch(message[find])
- {
+ switch(message[find]) {
case _T('&'):
ret += _T("&");
break;
@@ -59,11 +57,9 @@ std::wstring MakeTextHtmled(const std::wstring& message, std::queue<std::pair<si }
start = find + 1;
- if (positionMap != NULL)
- {
+ if (positionMap != NULL) {
size_t len = ret.length() - start - currentAdd;
- if (len != 0)
- {
+ if (len != 0) {
positionMap->push(std::pair<size_t, size_t>(start + currentAdd, len));
currentAdd += len;
}
@@ -81,16 +77,14 @@ std::wstring UrlHighlightHtml(const std::wstring& message, bool& isUrl) std::wstring search = _T("://");
size_t start = 0;
size_t find;
- while((find = message.find(search, start)) < message.length())
- {
+ while((find = message.find(search, start)) < message.length()) {
size_t urlStart = message.find_last_of(htmlStop, find);
size_t urlEnd = message.find_first_of(htmlStop, find + 3);
if (urlStart >= message.length())
urlStart = -1;
if (urlEnd >= message.length())
urlEnd = message.length();
- if (((int)urlEnd -3 - (int)find > 0) && ((int)find - (int)urlStart -1 > 0))
- {
+ if (((int)urlEnd -3 - (int)find > 0) && ((int)find - (int)urlStart -1 > 0)) {
ret += message.substr(start, (urlStart + 1) - start);
std::wstring url = message.substr(urlStart + 1, urlEnd - urlStart - 1);
start = urlEnd;
@@ -98,8 +92,7 @@ std::wstring UrlHighlightHtml(const std::wstring& message, bool& isUrl) ret += url + _T("\">") + url + _T("</a>");
isUrl = true;
}
- else
- {
+ else {
ret += message.substr(start, (find + 3) - start);
start = find + 3;
}
@@ -113,9 +106,7 @@ std::wstring RemoveExt(const std::wstring &fileName) {
size_t find = fileName.find_last_of(L'.');
if (find < fileName.length())
- {
return fileName.substr(0, find);
- }
return fileName;
}
@@ -124,9 +115,7 @@ std::wstring GetName(const std::wstring &path) {
size_t find = path.find_last_of(L"\\/");
if (find < path.length())
- {
return path.substr(find + 1);
- }
return path;
}
@@ -134,18 +123,14 @@ std::wstring GetName(const std::wstring &path) void ExtractFile(short int res, const std::wstring &fileName)
{
HRSRC rSrc = FindResource(hInst, MAKEINTRESOURCE(res), MAKEINTRESOURCE(CUSTOMRES));
- if (rSrc != NULL)
- {
+ if (rSrc != NULL) {
HGLOBAL res = LoadResource(hInst, rSrc);
int size = SizeofResource(hInst, rSrc);
- if (res != NULL)
- {
+ if (res != NULL) {
char* resData = (char*)LockResource(res);
- if (resData != NULL)
- {
+ if (resData != NULL) {
std::ofstream stream (fileName.c_str(), std::ios_base::binary);
- if (stream.is_open())
- {
+ if (stream.is_open()) {
stream.write(resData, size);
stream.close();
}
@@ -189,9 +174,9 @@ void IcoSave(const std::wstring &fileName, HICON hicon) std::ofstream store (fileName.c_str(), std::ios_base::binary);
if (!store.is_open())
return;
- ICONINFO ii;
- if (!GetIconInfo(hicon,&ii))
- {
+
+ ICONINFO ii;
+ if ( !GetIconInfo(hicon, &ii)) {
store.close();
return;
}
@@ -200,14 +185,12 @@ void IcoSave(const std::wstring &fileName, HICON hicon) HBITMAP hbmColor = ii.hbmColor;
BITMAP bmiMask;
BITMAP bmiColor;
- if (
- GetObject(hbmColor,sizeof(bmiColor),&bmiColor) &&
- GetObject(hbmMask,sizeof(bmiMask),&bmiMask) &&
- (bmiColor.bmWidth==bmiMask.bmWidth) &&
- (bmiColor.bmHeight==bmiMask.bmHeight) &&
- (bmiMask.bmHeight) > 0 &&
- (bmiMask.bmWidth) > 0
- )
+ if (GetObject(hbmColor,sizeof(bmiColor),&bmiColor) &&
+ GetObject(hbmMask,sizeof(bmiMask),&bmiMask) &&
+ (bmiColor.bmWidth==bmiMask.bmWidth) &&
+ (bmiColor.bmHeight==bmiMask.bmHeight) &&
+ (bmiMask.bmHeight) > 0 &&
+ (bmiMask.bmWidth) > 0)
{
BITMAPINFOHEADER icobmi = {0};
MYBITMAPINFO info1 = {0};
@@ -308,9 +291,7 @@ void RichHtmlExport::WriteHeader(const std::wstring &fileName, const std::wstrin std::wstring css = folder + _T("\\history.css");
BOOL cssCopied = FALSE;
if (!Options::instance->extCssHtml2.empty())
- {
cssCopied = CopyFile(Options::instance->extCssHtml2.c_str(), css.c_str(), FALSE);
- }
if (!cssCopied)
ExtractFile(IDR_CSS, css);
@@ -360,23 +341,15 @@ void RichHtmlExport::WriteHeader(const std::wstring &fileName, const std::wstrin EXP_FILE << _T("<h4>") << TranslateT("History Log") << _T("</h4>\n<h3>");
EXP_FILE << MakeTextHtmled(myName);
if (proto1.length() || myId.length())
- {
EXP_FILE << _T(" (") << MakeTextHtmled(proto1) << _T(": ") << MakeTextHtmled(myId) << _T(") - ");
- }
else
- {
EXP_FILE << _T(" - ");
- }
EXP_FILE << MakeTextHtmled(name1);
if (proto1.length() || id1.length())
- {
EXP_FILE << _T(" (") << MakeTextHtmled(proto1) << _T(": ") << MakeTextHtmled(id1) << _T(")</h3>\n");
- }
else
- {
EXP_FILE << _T("</h3>\n");
- }
EXP_FILE << _T("<h6>") << TranslateT("Filter:") << _T(" ") << MakeTextHtmled(filterName) << _T("</h6>\n");
groupId = 0;
@@ -385,9 +358,7 @@ void RichHtmlExport::WriteHeader(const std::wstring &fileName, const std::wstrin void RichHtmlExport::WriteFooter()
{
if (groupId > 0)
- {
EXP_FILE << _T("</div>\n");
- }
EXP_FILE << _T("<div class=mes id=bottom></div>\n</body></html>\n");
}
@@ -397,9 +368,7 @@ void RichHtmlExport::WriteGroup(bool isMe, const std::wstring &time, const std:: TCHAR *id = isMe ? _T("out") : _T("inc");
TCHAR* ev = (isMe ? _T("1") : _T("0"));
if (groupId > 0)
- {
EXP_FILE << _T("</div>\n");
- }
bool isUrl = false;
std::wstring& mes = ReplaceSmileys(isMe, eventText, isUrl);
@@ -433,114 +402,91 @@ void RichHtmlExport::WriteMessage(bool isMe, const std::wstring &longDate, const std::wstring RichHtmlExport::ReplaceSmileys(bool isMe, const std::wstring &msg, bool &isUrl)
{
- if (Options::instance->exportHtml2UseSmileys && g_SmileyAddAvail)
- {
- TCHAR* msgbuf = new TCHAR[msg.length() + 1];
- memcpy_s(msgbuf, (msg.length() + 1) * sizeof(TCHAR), msg.c_str(), (msg.length() + 1) * sizeof(TCHAR));
- SMADD_BATCHPARSE2 sp = {0};
- SMADD_BATCHPARSERES *spr;
- sp.cbSize = sizeof(sp);
- sp.Protocolname = baseProto.length() == 0 ? NULL : baseProto.c_str();
- sp.str = msgbuf;
- sp.flag = SAFL_TCHAR | SAFL_PATH | (isMe ? SAFL_OUTGOING : 0);
- spr = (SMADD_BATCHPARSERES*)CallService(MS_SMILEYADD_BATCHPARSE, 0, (LPARAM)&sp);
- delete[] msgbuf;
-
- if (spr == NULL || (INT_PTR)spr == CALLSERVICE_NOTFOUND)
- {
- // Did not find a simley
- return UrlHighlightHtml(MakeTextHtmled(msg), isUrl);
- }
+ if (!Options::instance->exportHtml2UseSmileys || !g_SmileyAddAvail)
+ return UrlHighlightHtml(MakeTextHtmled(msg), isUrl);
+
+ TCHAR* msgbuf = new TCHAR[msg.length() + 1];
+ memcpy_s(msgbuf, (msg.length() + 1) * sizeof(TCHAR), msg.c_str(), (msg.length() + 1) * sizeof(TCHAR));
+ SMADD_BATCHPARSE2 sp = {0};
+ SMADD_BATCHPARSERES *spr;
+ sp.cbSize = sizeof(sp);
+ sp.Protocolname = baseProto.length() == 0 ? NULL : baseProto.c_str();
+ sp.str = msgbuf;
+ sp.flag = SAFL_TCHAR | SAFL_PATH | (isMe ? SAFL_OUTGOING : 0);
+ spr = (SMADD_BATCHPARSERES*)CallService(MS_SMILEYADD_BATCHPARSE, 0, (LPARAM)&sp);
+ delete[] msgbuf;
+
+ // Did not find a simley
+ if (spr == NULL || (INT_PTR)spr == CALLSERVICE_NOTFOUND)
+ return UrlHighlightHtml(MakeTextHtmled(msg), isUrl);
- std::queue<std::pair<size_t, size_t> > positionMap;
- std::wstring newMsg = MakeTextHtmled(msg, &positionMap);
- std::wstring smileyMsg;
+ std::queue<std::pair<size_t, size_t> > positionMap;
+ std::wstring newMsg = MakeTextHtmled(msg, &positionMap);
+ std::wstring smileyMsg;
- size_t last_pos=0;
- std::pair<size_t, size_t> pos(0, 0);
- size_t currentAdd = 0;
- if (!positionMap.empty())
- {
- pos = positionMap.front();
- positionMap.pop();
- }
+ size_t last_pos=0;
+ std::pair<size_t, size_t> pos(0, 0);
+ size_t currentAdd = 0;
+ if (!positionMap.empty()) {
+ pos = positionMap.front();
+ positionMap.pop();
+ }
- for (unsigned i = 0; i < sp.numSmileys; ++i)
- {
- size_t startChar = spr[i].startChar + currentAdd;
- while(startChar >= pos.first && pos.second)
- {
- startChar += pos.second;
- currentAdd += pos.second;
- if (!positionMap.empty())
- {
- pos = positionMap.front();
- positionMap.pop();
- }
- else
- {
- pos = std::pair<size_t, size_t>(0, 0);
- }
+ for (unsigned i = 0; i < sp.numSmileys; ++i) {
+ size_t startChar = spr[i].startChar + currentAdd;
+ while(startChar >= pos.first && pos.second) {
+ startChar += pos.second;
+ currentAdd += pos.second;
+ if (!positionMap.empty()) {
+ pos = positionMap.front();
+ positionMap.pop();
}
+ else pos = std::pair<size_t, size_t>(0, 0);
+ }
- size_t endChar = spr[i].startChar + spr[i].size + currentAdd;
- while(endChar >= pos.first && pos.second)
- {
- endChar += pos.second;
- currentAdd += pos.second;
- if (!positionMap.empty())
- {
- pos = positionMap.front();
- positionMap.pop();
- }
- else
- {
- pos = std::pair<size_t, size_t>(0, 0);
- }
+ size_t endChar = spr[i].startChar + spr[i].size + currentAdd;
+ while(endChar >= pos.first && pos.second) {
+ endChar += pos.second;
+ currentAdd += pos.second;
+ if (!positionMap.empty()) {
+ pos = positionMap.front();
+ positionMap.pop();
}
+ else pos = std::pair<size_t, size_t>(0, 0);
+ }
- size_t size = endChar - startChar;
-
- if (spr[i].filepath != NULL) // For deffective smileypacks
- {
- // Add text
- if (startChar - last_pos > 0)
- {
- smileyMsg += newMsg.substr(last_pos, startChar - last_pos);
- }
-
- std::wstring smileyName = GetName(spr[i].filepath);
- if (smileys.find(smileyName) == smileys.end())
- {
- smileys.insert(smileyName);
- CopyFile(spr[i].filepath, (folder + _T("\\") + smileyName).c_str(), FALSE);
- }
+ size_t size = endChar - startChar;
- std::wstring smileyText = newMsg.substr(startChar, size);
- smileyMsg += _T("<img class=smiley src=\"");
- smileyMsg += folderName;
- smileyMsg += _T("\\");
- smileyMsg += smileyName;
- smileyMsg += _T("\" alt=\"");
- smileyMsg += smileyText;
- smileyMsg += _T("\"/>");
+ if (spr[i].filepath != NULL) { // For deffective smileypacks
+ // Add text
+ if (startChar - last_pos > 0) {
+ smileyMsg += newMsg.substr(last_pos, startChar - last_pos);
}
- // Get next
- last_pos = endChar;
- }
+ std::wstring smileyName = GetName(spr[i].filepath);
+ if (smileys.find(smileyName) == smileys.end()) {
+ smileys.insert(smileyName);
+ CopyFile(spr[i].filepath, (folder + _T("\\") + smileyName).c_str(), FALSE);
+ }
- // Add rest of text
- if (last_pos < newMsg.length())
- {
- smileyMsg += newMsg.substr(last_pos);
+ std::wstring smileyText = newMsg.substr(startChar, size);
+ smileyMsg += _T("<img class=smiley src=\"");
+ smileyMsg += folderName;
+ smileyMsg += _T("\\");
+ smileyMsg += smileyName;
+ smileyMsg += _T("\" alt=\"");
+ smileyMsg += smileyText;
+ smileyMsg += _T("\"/>");
}
- CallService(MS_SMILEYADD_BATCHFREE, 0, (LPARAM)spr);
- return UrlHighlightHtml(smileyMsg, isUrl);
- }
- else
- {
- return UrlHighlightHtml(MakeTextHtmled(msg), isUrl);
+ // Get next
+ last_pos = endChar;
}
+
+ // Add rest of text
+ if (last_pos < newMsg.length())
+ smileyMsg += newMsg.substr(last_pos);
+
+ CallService(MS_SMILEYADD_BATCHFREE, 0, (LPARAM)spr);
+ return UrlHighlightHtml(smileyMsg, isUrl);
}
diff --git a/plugins/BasicHistory/src/Scheduler.cpp b/plugins/BasicHistory/src/Scheduler.cpp index c03709d712..768b9fe5b5 100644 --- a/plugins/BasicHistory/src/Scheduler.cpp +++ b/plugins/BasicHistory/src/Scheduler.cpp @@ -89,39 +89,32 @@ void DeinitScheduler() int DoLastTask(WPARAM, LPARAM)
{
- for(std::vector<TaskOptions>::iterator it = Options::instance->taskOptions.begin(); it != Options::instance->taskOptions.end(); ++it)
- {
+ for (std::vector<TaskOptions>::iterator it = Options::instance->taskOptions.begin(); it != Options::instance->taskOptions.end(); ++it)
if (it->trigerType == TaskOptions::AtEnd && it->active)
- {
DoTask(*it);
- }
- }
return 0;
}
bool IsValidTask(TaskOptions& to, std::list<TaskOptions>* top, std::wstring* err, std::wstring* errDescr)
{
- if (to.taskName.empty())
- {
+ if (to.taskName.empty()) {
if (err != NULL)
*err = TranslateT("Name");
return false;
}
- if (top != NULL)
- {
- for(std::list<TaskOptions>::iterator it = top->begin(); it != top->end(); ++it)
- {
- if (it->taskName == to.taskName)
- {
+
+ if (top != NULL) {
+ for (std::list<TaskOptions>::iterator it = top->begin(); it != top->end(); ++it) {
+ if (it->taskName == to.taskName) {
if (err != NULL)
*err = TranslateT("Name");
return false;
}
}
}
- if (!to.isSystem && to.contacts.size() == 0)
- {
+
+ if (!to.isSystem && to.contacts.size() == 0) {
if (err != NULL)
*err = TranslateT("Contacts");
if (errDescr != NULL)
@@ -130,23 +123,18 @@ bool IsValidTask(TaskOptions& to, std::list<TaskOptions>* top, std::wstring* err }
bool isImportTask = to.type == TaskOptions::Import || to.type == TaskOptions::ImportAndMarge;
- if (!isImportTask)
- {
- if (to.filterId > 1)
- {
+ if (!isImportTask) {
+ if (to.filterId > 1) {
int filter = 0;
- for(int i = 0; i < (int)Options::instance->customFilters.size(); ++i)
- {
- if (to.filterName == Options::instance->customFilters[i].name)
- {
+ for (int i = 0; i < (int)Options::instance->customFilters.size(); ++i) {
+ if (to.filterName == Options::instance->customFilters[i].name) {
filter = i + 2;
break;
}
}
- if (filter < 2)
- {
+ if (filter < 2) {
if (err != NULL)
*err = TranslateT("Filter");
return false;
@@ -154,8 +142,7 @@ bool IsValidTask(TaskOptions& to, std::list<TaskOptions>* top, std::wstring* err to.filterId = filter;
}
- else if (to.filterId < 0)
- {
+ else if (to.filterId < 0) {
if (err != NULL)
*err = TranslateT("Filter");
return false;
@@ -163,78 +150,65 @@ bool IsValidTask(TaskOptions& to, std::list<TaskOptions>* top, std::wstring* err }
if (to.type == TaskOptions::Delete)
- {
return true;
- }
- if (!Options::FTPAvail() && to.useFtp)
- {
+ if (!Options::FTPAvail() && to.useFtp) {
if (err != NULL)
*err = TranslateT("Upload to FTP");
return false;
}
- if (to.filePath.empty())
- {
+ if (to.filePath.empty()) {
if (err != NULL)
*err = TranslateT("Path to output file");
return false;
}
- if (to.useFtp && to.ftpName.empty())
- {
+ if (to.useFtp && to.ftpName.empty()) {
if (err != NULL)
*err = TranslateT("Session name");
if (errDescr != NULL)
*errDescr = TranslateT("To create session open WinSCP, click New Session, enter data and save with specific name. Remember if FTP server using password you should save it in WinSCP.");
return false;
}
- if (to.useFtp && (to.filePath.find(_T('\\')) < to.filePath.length() || to.filePath.find(_T(':')) < to.filePath.length() || to.filePath[0] != L'/'))
- {
+ if (to.useFtp && (to.filePath.find(_T('\\')) < to.filePath.length() || to.filePath.find(_T(':')) < to.filePath.length() || to.filePath[0] != L'/')) {
if (err != NULL)
*err = TranslateT("Path to file");
if (errDescr != NULL)
*errDescr = TranslateT("FTP path must contains '/' instead '\\' and starts from '/'.");
return false;
}
- if (isImportTask && to.filePath.find(_T("<date>")) < to.filePath.length())
- {
+ if (isImportTask && to.filePath.find(_T("<date>")) < to.filePath.length()) {
if (err != NULL)
*err = TranslateT("Path to file");
if (errDescr != NULL)
*errDescr = TranslateT("FTP path cannot contain <date> in import task.");
return false;
}
- if (!isImportTask && (to.exportType < IExport::RichHtml || to.exportType > IExport::Dat))
- {
+ if (!isImportTask && (to.exportType < IExport::RichHtml || to.exportType > IExport::Dat)) {
if (err != NULL)
*err = TranslateT("Export to");
return false;
}
- if (isImportTask && (to.importType < IImport::Binary || to.importType > IImport::Dat))
- {
+ if (isImportTask && (to.importType < IImport::Binary || to.importType > IImport::Dat)) {
if (err != NULL)
*err = TranslateT("Import from");
return false;
}
- if ((to.trigerType == TaskOptions::Daily || to.trigerType == TaskOptions::Weekly || to.trigerType == TaskOptions::Monthly) && (to.dayTime < 0 || to.dayTime >= 24 * 60))
- {
+ if ((to.trigerType == TaskOptions::Daily || to.trigerType == TaskOptions::Weekly || to.trigerType == TaskOptions::Monthly) && (to.dayTime < 0 || to.dayTime >= 24 * 60)) {
if (err != NULL)
*err = TranslateT("Time");
return false;
}
- if (to.trigerType == TaskOptions::Weekly && (to.dayOfWeek < 0 || to.dayOfWeek >= 7))
- {
+ if (to.trigerType == TaskOptions::Weekly && (to.dayOfWeek < 0 || to.dayOfWeek >= 7)) {
if (err != NULL)
*err = TranslateT("Day of week");
return false;
}
- if (to.trigerType == TaskOptions::Monthly && (to.dayOfMonth <= 0 || to.dayOfMonth >= 32))
- {
+ if (to.trigerType == TaskOptions::Monthly && (to.dayOfMonth <= 0 || to.dayOfMonth >= 32)) {
if (err != NULL)
*err = TranslateT("Day");
return false;
}
- if ((to.trigerType == TaskOptions::DeltaMin || to.trigerType == TaskOptions::DeltaHour) && (to.deltaTime < 0 || to.deltaTime >= 10000))
- {
+ if ((to.trigerType == TaskOptions::DeltaMin || to.trigerType == TaskOptions::DeltaHour) && (to.deltaTime < 0 || to.deltaTime >= 10000)) {
if (err != NULL)
*err = TranslateT("Delta time");
return false;
@@ -247,10 +221,8 @@ static void CALLBACK DoRebuildEventsInMainAPCFunc(ULONG_PTR dwParam) {
HANDLE* contacts = (HANDLE*) dwParam;
size_t size = (size_t)contacts[0];
- for(size_t i = 1; i <= size; ++i)
- {
+ for (size_t i = 1; i <= size; ++i)
HistoryWindow::RebuildEvents(contacts[i]);
- }
delete[] contacts;
}
@@ -259,19 +231,15 @@ bool DoTask(TaskOptions& to) {
std::wstring err;
std::wstring errDescr;
- if (!IsValidTask(to, NULL, &err, &errDescr))
- {
+ if (!IsValidTask(to, NULL, &err, &errDescr)) {
TCHAR msg[256];
if (err.empty())
_tcscpy_s(msg, TranslateT("Some value is invalid"));
else if (errDescr.empty())
- {
mir_sntprintf(msg, SIZEOF(msg), TranslateT("Invalid '%s' value."), err.c_str());
- }
else
- {
mir_sntprintf(msg, SIZEOF(msg), TranslateT("Invalid '%s' value.\n%s"), err.c_str(), errDescr.c_str());
- }
+
DoError(to, msg);
return true;
}
@@ -282,8 +250,7 @@ bool DoTask(TaskOptions& to) t *= 60LL;
if (to.eventUnit > TaskOptions::Hour)
t *= 24LL;
- if (t > 2147483647LL)
- {
+ if (t > 2147483647LL) {
DoError(to, TranslateT("Unknown error"));
return true;
}
@@ -291,32 +258,27 @@ bool DoTask(TaskOptions& to) bool error = false;
std::wstring errorStr;
std::list<ExportManager*> managers;
- if (to.type == TaskOptions::Delete)
- {
- if (to.isSystem)
- {
+ if (to.type == TaskOptions::Delete) {
+ if (to.isSystem) {
ExportManager *exp = new ExportManager(NULL, NULL, to.filterId);
exp->SetDeleteWithoutExportEvents(t, now);
managers.push_back(exp);
}
- for(size_t i = 0; i < to.contacts.size(); ++i)
- {
+ for (size_t i = 0; i < to.contacts.size(); ++i) {
ExportManager *exp = new ExportManager(NULL, to.contacts[i], to.filterId);
exp->SetDeleteWithoutExportEvents(t, now);
managers.push_back(exp);
}
}
- else if (to.type == TaskOptions::Import || to.type == TaskOptions::ImportAndMarge)
- {
+ else if (to.type == TaskOptions::Import || to.type == TaskOptions::ImportAndMarge) {
std::map<std::wstring, bool> existingContacts1;
ExportManager mExp = ExportManager(NULL, NULL, 1);
std::wstring filePath = to.filePath;
std::wstring dir;
std::list<std::wstring> files;
std::vector<HANDLE> contacts;
- if (to.useFtp || to.compress)
- {
+ if (to.useFtp || to.compress) {
std::map<std::wstring, bool> existingContacts;
TCHAR temp[MAX_PATH];
temp[0] = 0;
@@ -327,25 +289,21 @@ bool DoTask(TaskOptions& to) dir = ReplaceExt(dir, L"");
size_t pos = dir.find_last_of(_T('.'));
if (pos < dir.length())
- {
dir = dir.substr(0, pos);
- }
DeleteDirectory(dir.c_str());
CreateDirectory(dir.c_str(), NULL);
}
const TCHAR* ext = ExportManager::GetExt(to.importType);
- if (to.isSystem)
- {
+ if (to.isSystem) {
std::wstring n = GetFileName(filePath, mExp.GetContactName(), existingContacts1, true);
n = ReplaceExt(n, ext);
files.push_back(n);
contacts.push_back(NULL);
}
- for(size_t i = 0; i < to.contacts.size(); ++i)
- {
+ for (size_t i = 0; i < to.contacts.size(); ++i) {
mExp.hContact = to.contacts[i];
std::wstring n = GetFileName(filePath, mExp.GetContactName(), existingContacts1, true);
n = ReplaceExt(n, ext);
@@ -353,10 +311,8 @@ bool DoTask(TaskOptions& to) contacts.push_back(to.contacts[i]);
}
- if (to.useFtp)
- {
- if (to.compress)
- {
+ if (to.useFtp) {
+ if (to.compress) {
std::map<std::wstring, bool> existingContacts;
std::wstring n = GetFileName(filePath, L"", existingContacts, true);
n = ReplaceExt(n, L"zip");
@@ -366,26 +322,19 @@ bool DoTask(TaskOptions& to) }
error = FtpGetFiles(dir, files, to.ftpName);
- if (error)
- {
+ if (error) {
if (!errorStr.empty())
- {
errorStr += L"\n";
- }
errorStr += TranslateT("Cannot get FTP file(s).");
}
}
- if (!error && to.compress)
- {
+ if (!error && to.compress) {
error = UnzipFiles(dir, filePath, to.zipPassword);
- if (error)
- {
+ if (error) {
if (!errorStr.empty())
- {
errorStr += L"\n";
- }
errorStr += TranslateT("Cannot unzip file(s).");
}
@@ -394,36 +343,26 @@ bool DoTask(TaskOptions& to) DeleteFile(filePath.c_str());
}
- if (!error && (to.useFtp || to.compress))
- {
+ if (!error && (to.useFtp || to.compress)) {
files.clear();
std::list<std::wstring> files1;
ListDirectory(dir, L"\\", files1);
- for(std::list<std::wstring>::iterator it = files1.begin(); it != files1.end(); ++it)
- {
+ for (std::list<std::wstring>::iterator it = files1.begin(); it != files1.end(); ++it)
files.push_back(dir + *it);
- }
}
- if (!error)
- {
+ if (!error) {
std::list<HANDLE> contactList;
- for(std::list<std::wstring>::iterator it = files.begin(); it != files.end(); ++it)
- {
+ for (std::list<std::wstring>::iterator it = files.begin(); it != files.end(); ++it) {
mExp.SetAutoImport(*it);
int ret = mExp.Import(to.importType, contacts);
- if (ret == -3)
- {
+ if (ret == -3) {
if (contacts.size() == 1)
- {
ret = 0;
- }
- else
- {
+ else {
std::map<std::wstring, bool> existingContacts;
std::wstring name = GetName(*it);
- for(ret = 0; ret < (int)contacts.size(); ++ret)
- {
+ for (ret = 0; ret < (int)contacts.size(); ++ret) {
mExp.hContact = contacts[ret];
std::wstring n = GetFileName(to.filePath, mExp.GetContactName(), existingContacts, true);
n = ReplaceExt(n, ext);
@@ -437,42 +376,31 @@ bool DoTask(TaskOptions& to) }
}
- if (ret >= 0)
- {
+ if (ret >= 0) {
mExp.hContact = contacts[ret];
- if (to.type == TaskOptions::Import)
- {
+ if (to.type == TaskOptions::Import) {
EventList::AddImporter(mExp.hContact, to.importType, *it);
contactList.push_back(mExp.hContact);
}
- else
- {
+ else {
std::vector<IImport::ExternalMessage> messages;
- if (mExp.Import(to.importType, messages, NULL))
- {
+ if (mExp.Import(to.importType, messages, NULL)) {
mExp.MargeMessages(messages);
contactList.push_back(mExp.hContact);
}
}
}
- else if (ret != -1)
- {
+ else if (ret != -1) {
if (!errorStr.empty())
- {
errorStr += L"\n";
- }
TCHAR msg[1024];
-
mir_sntprintf(msg, SIZEOF(msg), TranslateT("Incorrect file format: %s."), GetName(*it).c_str());
errorStr += msg;
}
- else
- {
+ else {
if (!errorStr.empty())
- {
errorStr += L"\n";
- }
TCHAR msg[1024];
@@ -481,40 +409,30 @@ bool DoTask(TaskOptions& to) }
}
- if (contactList.size() > 0)
- {
+ if (contactList.size() > 0) {
HANDLE* contacts = new HANDLE[contactList.size() + 1];
contacts[0] = (HANDLE)contactList.size();
int i = 1;
- for(std::list<HANDLE>::iterator it = contactList.begin(); it != contactList.end(); ++it)
- {
+ for (std::list<HANDLE>::iterator it = contactList.begin(); it != contactList.end(); ++it)
contacts[i++] = *it;
- }
QueueUserAPC(DoRebuildEventsInMainAPCFunc, g_hMainThread, (ULONG_PTR) contacts);
}
}
if (to.useFtp || to.compress)
- {
DeleteDirectory(dir.c_str());
- }
}
- else
- {
+ else {
std::map<std::wstring, bool> existingContacts;
std::wstring filePath = to.filePath;
std::wstring dir;
- if (!to.useFtp && !to.compress)
- {
+ if (!to.useFtp && !to.compress) {
dir = GetDirectoryName(filePath);
if (!dir.empty())
- {
CreateDirectory(dir.c_str(), NULL);
- }
}
- else
- {
+ else {
filePath = GetName(filePath);
TCHAR temp[MAX_PATH];
temp[0] = 0;
@@ -525,26 +443,20 @@ bool DoTask(TaskOptions& to) dir = ReplaceExt(dir, L"");
size_t pos = dir.find_last_of(_T('.'));
if (pos < dir.length())
- {
dir = dir.substr(0, pos);
- }
DeleteDirectory(dir.c_str());
CreateDirectory(dir.c_str(), NULL);
filePath = dir + L"\\" + filePath;
}
- if (to.isSystem)
- {
+ if (to.isSystem) {
ExportManager *exp = new ExportManager(NULL, NULL, to.filterId);
exp->SetAutoExport(GetFileName(filePath, exp->GetContactName(), existingContacts, true), t, now);
exp->useImportedMessages = to.exportImported;
- if (!exp->Export(to.exportType))
- {
+ if (!exp->Export(to.exportType)) {
error = true;
if (!errorStr.empty())
- {
errorStr += L"\n";
- }
TCHAR msg[1024];
@@ -553,69 +465,47 @@ bool DoTask(TaskOptions& to) }
if (to.type == TaskOptions::Export)
- {
delete exp;
- }
else
- {
managers.push_back(exp);
- }
}
- if (!error)
- {
- for(size_t i = 0; i < to.contacts.size(); ++i)
- {
+ if (!error) {
+ for (size_t i = 0; i < to.contacts.size(); ++i) {
ExportManager *exp = new ExportManager(NULL, to.contacts[i], to.filterId);
exp->SetAutoExport(GetFileName(filePath, exp->GetContactName(), existingContacts, true), t, now);
exp->useImportedMessages = to.exportImported;
- if (!exp->Export(to.exportType))
- {
+ if (!exp->Export(to.exportType)) {
error = true;
if (!errorStr.empty())
- {
errorStr += L"\n";
- }
TCHAR msg[1024];
-
mir_sntprintf(msg, SIZEOF(msg), TranslateT("Cannot export history for contact: %s."), exp->GetContactName().c_str());
errorStr += msg;
break;
}
if (to.type == TaskOptions::Export)
- {
delete exp;
- }
else
- {
managers.push_back(exp);
- }
}
}
- if (error)
- {
+ if (error) {
if (to.compress && !to.useFtp)
- {
DeleteDirectory(dir.c_str());
- }
}
- else if (to.compress)
- {
+ else if (to.compress) {
std::wstring zipFilePath = to.filePath;
std::wstring zipDir = dir;
- if (!to.useFtp)
- {
+ if (!to.useFtp) {
zipDir = GetDirectoryName(zipFilePath);
if (!zipDir.empty())
- {
CreateDirectory(zipDir.c_str(), NULL);
- }
}
- else
- {
+ else {
zipFilePath = GetName(zipFilePath);
TCHAR temp[MAX_PATH];
temp[0] = 0;
@@ -629,28 +519,20 @@ bool DoTask(TaskOptions& to) }
error = ZipFiles(dir + L"\\", zipFilePath, to.zipPassword);
dir = zipDir;
- if (error)
- {
+ if (error) {
if (!errorStr.empty())
- {
errorStr += L"\n";
- }
errorStr += TranslateT("Cannot compress file(s).");
}
}
- if (to.useFtp)
- {
- if (!error)
- {
+ if (to.useFtp) {
+ if (!error) {
error = FtpFiles(dir, to.filePath, to.ftpName);
- if (error)
- {
+ if (error) {
if (!errorStr.empty())
- {
errorStr += L"\n";
- }
errorStr += TranslateT("Cannot send FTP file(s).");
}
@@ -660,23 +542,17 @@ bool DoTask(TaskOptions& to) }
}
- if (to.type == TaskOptions::Delete || to.type == TaskOptions::ExportAndDelete)
- {
- for(std::list<ExportManager*>::iterator it = managers.begin(); it != managers.end(); ++it)
- {
+ if (to.type == TaskOptions::Delete || to.type == TaskOptions::ExportAndDelete) {
+ for (std::list<ExportManager*>::iterator it = managers.begin(); it != managers.end(); ++it) {
if (!error)
- {
(*it)->DeleteExportedEvents();
- }
delete *it;
}
}
if (error)
- {
DoError(to, errorStr.empty() ? TranslateT("Unknown error") : errorStr);
- }
return error;
}
@@ -685,18 +561,15 @@ std::wstring GetFileName(const std::wstring &baseName, std::wstring contactName, {
std::wstring str = baseName;
size_t pos = baseName.find(_T("<contact>"));
- if (replaceContact && pos < baseName.length())
- {
+ if (replaceContact && pos < baseName.length()) {
str = baseName.substr(0, pos);
std::wstring baseName1 = contactName;
- if (!baseName1.empty())
- {
+ if (!baseName1.empty()) {
std::wstring name = baseName1;
int i = 0;
TCHAR buf[32];
std::map<std::wstring, bool>::iterator it = existingContacts.find(name);
- while(it != existingContacts.end())
- {
+ while(it != existingContacts.end()) {
_itot_s(++i, buf, 10);
name = baseName1 + buf;
it = existingContacts.find(name);
@@ -709,8 +582,7 @@ std::wstring GetFileName(const std::wstring &baseName, std::wstring contactName, }
pos = str.find(_T("<date>"));
- if (pos < str.length())
- {
+ if (pos < str.length()) {
TCHAR time[256];
SYSTEMTIME st;
GetLocalTime(&st);
@@ -728,9 +600,7 @@ std::wstring GetDirectoryName(const std::wstring &path) {
size_t find = path.find_last_of(L"\\/");
if (find < path.length())
- {
return path.substr(0, find);
- }
return L"";
}
@@ -741,20 +611,17 @@ void ListDirectory(const std::wstring &basePath, const std::wstring &path, std:: HANDLE hFind = FindFirstFile((basePath + path + _T("*")).c_str(), &findFileData);
if (hFind == INVALID_HANDLE_VALUE)
return;
+
do
{
- if (findFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
- {
+ if (findFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
std::wstring name = findFileData.cFileName;
if (name != L"." && name != L"..")
ListDirectory(basePath, path + findFileData.cFileName + _T("\\"), files);
}
- else
- {
- files.push_back(path + findFileData.cFileName);
- }
+ else files.push_back(path + findFileData.cFileName);
}
- while(FindNextFile(hFind, &findFileData));
+ while(FindNextFile(hFind, &findFileData));
FindClose(hFind);
}
@@ -763,8 +630,7 @@ std::wstring ReplaceStr(const std::wstring& str, wchar_t oldCh, wchar_t newCh) std::wstring ret;
size_t start = 0;
size_t find;
- while((find = str.find_first_of(oldCh, start)) < str.length())
- {
+ while((find = str.find_first_of(oldCh, start)) < str.length()) {
ret += str.substr(start, find - start);
ret += newCh;
start = find + 1;
@@ -776,8 +642,7 @@ std::wstring ReplaceStr(const std::wstring& str, wchar_t oldCh, wchar_t newCh) time_t GetNextExportTime(TaskOptions& to)
{
- switch(to.trigerType)
- {
+ switch(to.trigerType) {
case TaskOptions::Daily:
{
tm t;
@@ -787,10 +652,7 @@ time_t GetNextExportTime(TaskOptions& to) t.tm_sec = 0;
time_t newTime = mktime(&t);
if (newTime <= to.lastExport)
- {
newTime += 60 * 60 * 24;
- }
-
return newTime;
}
case TaskOptions::Weekly:
@@ -802,18 +664,14 @@ time_t GetNextExportTime(TaskOptions& to) t.tm_sec = 0;
int dow = (to.dayOfWeek + 1) % 7;
time_t newTime = mktime(&t);
- while(dow != t.tm_wday)
- {
+ while(dow != t.tm_wday) {
newTime += 60 * 60 * 24;
localtime_s(&t, &newTime);
newTime = mktime(&t);
}
if (newTime <= to.lastExport)
- {
newTime += 7 * 60 * 60 * 24;
- }
-
return newTime;
}
case TaskOptions::Monthly:
@@ -826,17 +684,14 @@ time_t GetNextExportTime(TaskOptions& to) time_t newTime = mktime(&t);
int lastM = t.tm_mon;
int lastD;
- while(to.dayOfMonth != t.tm_mday || newTime <= to.lastExport)
- {
+ while(to.dayOfMonth != t.tm_mday || newTime <= to.lastExport) {
lastD = t.tm_mday;
newTime += 60 * 60 * 24;
localtime_s(&t, &newTime);
newTime = mktime(&t);
- if (to.dayOfMonth > 28 && t.tm_mon != lastM && (newTime - 60 * 60 * 24) > to.lastExport)
- {
+ if (to.dayOfMonth > 28 && t.tm_mon != lastM && (newTime - 60 * 60 * 24) > to.lastExport) {
lastM = t.tm_mon;
- if (to.dayOfMonth > lastD)
- {
+ if (to.dayOfMonth > lastD) {
newTime -= 60 * 60 * 24;
break;
}
@@ -856,8 +711,7 @@ time_t GetNextExportTime(TaskOptions& to) void SchedulerThreadFunc(void*)
{
- if (initTask)
- {
+ if (initTask) {
WaitForSingleObject(hThreadEvent, 5 * 1000);
initTask = false;
}
@@ -906,32 +760,26 @@ bool GetNextExportTime(bool init, time_t now) {
EnterCriticalSection(&Options::instance->criticalSection);
bool isExport = false;
- for(std::vector<TaskOptions>::iterator it = Options::instance->taskOptions.begin(); it != Options::instance->taskOptions.end(); ++it)
- {
- if (it->forceExecute)
- {
+ for (std::vector<TaskOptions>::iterator it = Options::instance->taskOptions.begin(); it != Options::instance->taskOptions.end(); ++it) {
+ if (it->forceExecute) {
nextExportTime = now;
isExport = true;
initTask = init;
break;
}
- else if (it->active && it->trigerType != TaskOptions::AtStart && it->trigerType != TaskOptions::AtEnd)
- {
+ else if (it->active && it->trigerType != TaskOptions::AtStart && it->trigerType != TaskOptions::AtEnd) {
time_t t = GetNextExportTime(*it);
- if (isExport)
- {
+ if (isExport) {
if (t < nextExportTime)
nextExportTime = t;
}
- else
- {
+ else {
nextExportTime = t;
isExport = true;
initTask = init;
}
}
- else if (it->active && it->trigerType == TaskOptions::AtStart && init)
- {
+ else if (it->active && it->trigerType == TaskOptions::AtStart && init) {
it->forceExecute = true;
it->showMBAfterExecute = false;
nextExportTime = now;
@@ -956,21 +804,17 @@ bool ExecuteCurrentTask(time_t now) EnterCriticalSection(&Options::instance->criticalSection);
TaskOptions to;
bool isExport = false;
- for(std::vector<TaskOptions>::iterator it = Options::instance->taskOptions.begin(); it != Options::instance->taskOptions.end(); ++it)
- {
- if (it->forceExecute)
- {
+ for (std::vector<TaskOptions>::iterator it = Options::instance->taskOptions.begin(); it != Options::instance->taskOptions.end(); ++it) {
+ if (it->forceExecute) {
it->lastExport = time(NULL);
Options::instance->SaveTaskTime(*it);
to = *it;
isExport = true;
break;
}
- else if (it->active && it->trigerType != TaskOptions::AtStart && it->trigerType != TaskOptions::AtEnd)
- {
+ else if (it->active && it->trigerType != TaskOptions::AtStart && it->trigerType != TaskOptions::AtEnd) {
time_t t = GetNextExportTime(*it);
- if (t <= now)
- {
+ if (t <= now) {
it->lastExport = time(NULL);
Options::instance->SaveTaskTime(*it);
to = *it;
@@ -982,16 +826,12 @@ bool ExecuteCurrentTask(time_t now) LeaveCriticalSection(&Options::instance->criticalSection);
- if (isExport)
- {
+ if (isExport) {
bool error = DoTask(to);
- if (to.forceExecute)
- {
+ if (to.forceExecute) {
EnterCriticalSection(&Options::instance->criticalSection);
- for(std::vector<TaskOptions>::iterator it = Options::instance->taskOptions.begin(); it != Options::instance->taskOptions.end(); ++it)
- {
- if (it->taskName == to.taskName)
- {
+ for (std::vector<TaskOptions>::iterator it = Options::instance->taskOptions.begin(); it != Options::instance->taskOptions.end(); ++it) {
+ if (it->taskName == to.taskName) {
it->forceExecute = false;
it->showMBAfterExecute = false;
break;
@@ -1000,19 +840,13 @@ bool ExecuteCurrentTask(time_t now) LeaveCriticalSection(&Options::instance->criticalSection);
- if (to.showMBAfterExecute)
- {
+ if (to.showMBAfterExecute) {
size_t size = to.taskName.size() + 1024;
TCHAR* name = new TCHAR[size];
if (error)
- {
mir_sntprintf(name, size, TranslateT("Task '%s' execution failed"), to.taskName.c_str());
- }
else
- {
mir_sntprintf(name, size, TranslateT("Task '%s' finished successfully"), to.taskName.c_str());
- }
-
QueueUserAPC(DoTaskFinishInMainAPCFunc, g_hMainThread, (ULONG_PTR) name);
}
}
@@ -1024,13 +858,10 @@ bool ExecuteCurrentTask(time_t now) void GetZipFileTime(const TCHAR *file, uLong *dt)
{
FILETIME ftLocal;
- HANDLE hFind;
WIN32_FIND_DATA ff32;
-
- hFind = FindFirstFile(file, &ff32);
- if (hFind != INVALID_HANDLE_VALUE)
- {
- FileTimeToLocalFileTime(&(ff32.ftLastWriteTime),&ftLocal);
+ HANDLE hFind = FindFirstFile(file, &ff32);
+ if (hFind != INVALID_HANDLE_VALUE) {
+ FileTimeToLocalFileTime(&(ff32.ftLastWriteTime), &ftLocal);
FileTimeToDosDateTime(&ftLocal,((LPWORD)dt)+1,((LPWORD)dt)+0);
FindClose(hFind);
}
@@ -1043,29 +874,22 @@ bool GetFileCrc(const TCHAR* filenameinzip, unsigned char* buf, unsigned long si unsigned long calculate_crc = 0;
bool error = true;
HANDLE hFile = CreateFile(filenameinzip, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
- if (hFile != INVALID_HANDLE_VALUE)
- {
+ if (hFile != INVALID_HANDLE_VALUE) {
DWORD readed;
do
{
- if (!ReadFile(hFile, buf, 1024, &readed, NULL))
- {
+ if (!ReadFile(hFile, buf, 1024, &readed, NULL)) {
error = false;
break;
}
if (readed > 0)
- {
- calculate_crc = crc32(calculate_crc, buf, readed);
- }
+ calculate_crc = crc32(calculate_crc, buf, readed);
}
- while (readed > 0);
+ while (readed > 0);
CloseHandle(hFile);
}
- else
- {
- error = false;
- }
+ else error = false;
*result_crc=calculate_crc;
return error;
@@ -1077,25 +901,21 @@ bool ZipFiles(const std::wstring& dir, std::wstring zipFilePath, const std::stri std::map<std::wstring, bool> existingContacts;
ListDirectory(dir, L"", files);
bool error = false;
- if (files.size() > 0)
- {
+ if (files.size() > 0) {
zlib_filefunc_def pzlib_filefunc_def;
fill_win32_filefunc(&pzlib_filefunc_def);
zipFilePath = GetFileName(zipFilePath, L"", existingContacts, true);
zipFilePath = ReplaceExt(zipFilePath, L"zip");
zipFile zf = zipOpen2((LPCSTR)(LPTSTR)zipFilePath.c_str(), APPEND_STATUS_CREATE, NULL, &pzlib_filefunc_def);
- if (zf != NULL)
- {
+ if (zf != NULL) {
unsigned char buf[1024];
char bufF[MAX_PATH + 20];
- while(files.size() > 0)
- {
+ while(files.size() > 0) {
std::wstring zipDir = *files.begin();
std::wstring localDir = dir + L"\\" + zipDir;
zip_fileinfo zi = {0};
GetZipFileTime(localDir.c_str(), &zi.dosDate);
- if (zipDir.size() > MAX_PATH + 19)
- {
+ if (zipDir.size() > MAX_PATH + 19) {
error = true;
break;
}
@@ -1103,18 +923,15 @@ bool ZipFiles(const std::wstring& dir, std::wstring zipFilePath, const std::stri BOOL badChar;
WideCharToMultiByte(CP_OEMCP, WC_NO_BEST_FIT_CHARS, zipDir.c_str(), -1, bufF, MAX_PATH + 20, NULL, &badChar);
int flag = 0;
- if (badChar)
- {
+ if (badChar) {
flag = 0x800; // UTF
WideCharToMultiByte(CP_UTF8, 0, zipDir.c_str(), -1, bufF, MAX_PATH + 20, NULL, NULL);
}
unsigned long calculate_crc = 0;
const char* passwordCh = NULL;
- if (password.size() > 0)
- {
- if (!GetFileCrc(localDir.c_str(), buf, 1024, &calculate_crc))
- {
+ if (password.size() > 0) {
+ if (!GetFileCrc(localDir.c_str(), buf, 1024, &calculate_crc)) {
error = true;
break;
}
@@ -1124,38 +941,31 @@ bool ZipFiles(const std::wstring& dir, std::wstring zipFilePath, const std::stri int err = zipOpenNewFileInZip4_64 (zf, bufF, &zi, NULL, 0, NULL, 0, NULL, Z_DEFLATED, Z_DEFAULT_COMPRESSION, 0,
-MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY, passwordCh, calculate_crc, 0, flag, 0);
- if (err == ZIP_OK)
- {
+ if (err == ZIP_OK) {
HANDLE hFile = CreateFile(localDir.c_str(), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
- if (hFile != INVALID_HANDLE_VALUE)
- {
+ if (hFile != INVALID_HANDLE_VALUE) {
DWORD readed;
do
{
err = ZIP_OK;
- if (!ReadFile(hFile, buf, 1024, &readed, NULL))
- {
+ if (!ReadFile(hFile, buf, 1024, &readed, NULL)) {
error = true;
break;
}
if (readed > 0)
- {
err = zipWriteInFileInZip(zf, buf, readed);
- }
}
- while ((err == ZIP_OK) && (readed > 0));
+ while ((err == ZIP_OK) && (readed > 0));
CloseHandle(hFile);
}
- if (zipCloseFileInZip(zf) != ZIP_OK)
- {
+ if (zipCloseFileInZip(zf) != ZIP_OK) {
error = true;
break;
}
}
- else
- {
+ else {
error = true;
break;
}
@@ -1165,10 +975,7 @@ bool ZipFiles(const std::wstring& dir, std::wstring zipFilePath, const std::stri zipClose(zf, NULL);
}
- else
- {
- error = true;
- }
+ else error = true;
}
DeleteDirectory(dir.c_str());
@@ -1186,129 +993,104 @@ bool UnzipFiles(const std::wstring& dir, std::wstring& zipFilePath, const std::s zipFilePath = GetFileName(zipFilePath, L"", existingContacts, true);
zipFilePath = ReplaceExt(zipFilePath, L"zip");
unzFile zf = unzOpen2((LPCSTR)(LPTSTR)zipFilePath.c_str(), &pzlib_filefunc_def);
- if (zf != NULL)
- {
- char buf[8192];
- char bufF[MAX_PATH + 20];
- unz_file_info file_info;
- do
- {
- int err = unzGetCurrentFileInfo(zf, &file_info, bufF, MAX_PATH + 20, buf, 8192, NULL, 0);
- if (err == UNZ_OK)
- {
- UINT cp = CP_OEMCP;
- if (file_info.flag & 0x800)// UTF
- {
- cp = CP_UTF8;
- }
+ if (zf == NULL)
+ return true;
- // Get Unicode file name for InfoZip style archives, otherwise assume PKZip/WinZip style
- if (file_info.size_file_extra)
- {
- char *p = buf;
- unsigned long size = min(file_info.size_file_extra, 8192);
- while (size > 0)
- {
- unsigned short id = *(unsigned short*)p;
- unsigned len = *(unsigned short*)(p + 2);
+ char buf[8192];
+ char bufF[MAX_PATH + 20];
+ unz_file_info file_info;
+ do
+ {
+ int err = unzGetCurrentFileInfo(zf, &file_info, bufF, MAX_PATH + 20, buf, 8192, NULL, 0);
+ if (err == UNZ_OK) {
+ UINT cp = CP_OEMCP;
+ if (file_info.flag & 0x800)// UTF
+ cp = CP_UTF8;
+
+ // Get Unicode file name for InfoZip style archives, otherwise assume PKZip/WinZip style
+ if (file_info.size_file_extra) {
+ char *p = buf;
+ unsigned long size = min(file_info.size_file_extra, 8192);
+ while (size > 0) {
+ unsigned short id = *(unsigned short*)p;
+ unsigned len = *(unsigned short*)(p + 2);
- if (size < (len + 4)) break;
+ if (size < (len + 4)) break;
- if (id == 0x7075 && len > 5 && (len - 5) < MAX_PATH + 20 && *(p + 4) == 1)
- {
- memcpy(bufF, p + 9, len - 5);
- bufF[len - 5] = 0;
- cp = CP_UTF8;
- break;
- }
- size -= len + 4;
- p += len + 4;
+ if (id == 0x7075 && len > 5 && (len - 5) < MAX_PATH + 20 && *(p + 4) == 1) {
+ memcpy(bufF, p + 9, len - 5);
+ bufF[len - 5] = 0;
+ cp = CP_UTF8;
+ break;
}
+ size -= len + 4;
+ p += len + 4;
}
+ }
- int sizeC = (int)strlen(bufF);
- int sizeW = MultiByteToWideChar(cp, 0, bufF, sizeC, NULL, 0);
- fileNameInZip.resize(sizeW);
- MultiByteToWideChar(cp, 0, bufF, sizeC, (wchar_t*)fileNameInZip.c_str(), sizeW);
- fileNameInZip = dir + L"\\" + fileNameInZip;
- for (size_t i = 0; i < fileNameInZip.length(); ++i)
- {
- if (fileNameInZip[i] == L'/')
- fileNameInZip[i] = L'\\';
- }
+ int sizeC = (int)strlen(bufF);
+ int sizeW = MultiByteToWideChar(cp, 0, bufF, sizeC, NULL, 0);
+ fileNameInZip.resize(sizeW);
+ MultiByteToWideChar(cp, 0, bufF, sizeC, (wchar_t*)fileNameInZip.c_str(), sizeW);
+ fileNameInZip = dir + L"\\" + fileNameInZip;
+ for (size_t i = 0; i < fileNameInZip.length(); ++i)
+ if (fileNameInZip[i] == L'/')
+ fileNameInZip[i] = L'\\';
- if (file_info.external_fa & FILE_ATTRIBUTE_DIRECTORY)
- CreatePath(fileNameInZip.c_str());
- else
- {
- const char* passwordCh = NULL;
- if (password.size() > 0)
- {
- passwordCh = password.c_str();
- }
-
- err = unzOpenCurrentFilePassword(zf, passwordCh);
- if (err == UNZ_OK)
- {
- CreatePath(GetDirectoryName(fileNameInZip).c_str());
- HANDLE hFile = CreateFile(fileNameInZip.c_str(), GENERIC_WRITE, FILE_SHARE_WRITE, NULL, CREATE_ALWAYS, 0, NULL);
- if (hFile != INVALID_HANDLE_VALUE)
- {
- DWORD writed;
- for (;;)
- {
- err = unzReadCurrentFile(zf, buf, 8192);
- if (err <= 0) break;
-
- if (!WriteFile(hFile, buf, err, &writed, FALSE))
- {
- err = -1;
- break;
- }
- }
+ if (file_info.external_fa & FILE_ATTRIBUTE_DIRECTORY)
+ CreatePath(fileNameInZip.c_str());
+ else {
+ const char* passwordCh = NULL;
+ if (password.size() > 0)
+ passwordCh = password.c_str();
- CloseHandle(hFile);
- if (err < 0)
- {
- error = true;
+ err = unzOpenCurrentFilePassword(zf, passwordCh);
+ if (err == UNZ_OK) {
+ CreatePath(GetDirectoryName(fileNameInZip).c_str());
+ HANDLE hFile = CreateFile(fileNameInZip.c_str(), GENERIC_WRITE, FILE_SHARE_WRITE, NULL, CREATE_ALWAYS, 0, NULL);
+ if (hFile != INVALID_HANDLE_VALUE) {
+ DWORD writed;
+ for (;;) {
+ err = unzReadCurrentFile(zf, buf, 8192);
+ if (err <= 0) break;
+
+ if ( !WriteFile(hFile, buf, err, &writed, FALSE)) {
+ err = -1;
break;
}
}
- else
- {
- unzCloseCurrentFile(zf);
- error = true;
- break;
- }
-
- if (unzCloseCurrentFile(zf) != ZIP_OK)
- {
+
+ CloseHandle(hFile);
+ if (err < 0) {
error = true;
break;
}
}
- else
- {
+ else {
+ unzCloseCurrentFile(zf);
+ error = true;
+ break;
+ }
+
+ if (unzCloseCurrentFile(zf) != ZIP_OK) {
error = true;
break;
}
}
+ else {
+ error = true;
+ break;
+ }
}
- else
- {
- error = true;
- break;
- }
}
+ else {
+ error = true;
+ break;
+ }
+ }
while (unzGoToNextFile(zf) == UNZ_OK);
- unzClose(zf);
- }
- else
- {
- error = true;
- }
-
+ unzClose(zf);
return error;
}
@@ -1317,23 +1099,19 @@ bool FtpFiles(const std::wstring& dir, const std::wstring& filePath, const std:: std::list<std::wstring> files;
std::map<std::wstring, bool> existingContacts;
ListDirectory(dir, L"\\", files);
- if (files.size() > 0)
- {
+ if (files.size() > 0) {
std::wofstream stream ((dir + _T("\\script.sc")).c_str());
- if (stream.is_open())
- {
+ if (stream.is_open()) {
std::wstring ftpDir = GetDirectoryName(filePath);
ftpDir = GetFileName(ftpDir, L"", existingContacts, false);
stream << "option batch continue\noption confirm off\nopen \""
<< ftpName << "\"\noption transfer binary\n";
std::wstring lastCD;
size_t filSize = files.size();
- while(files.size() > 0)
- {
+ while(files.size() > 0) {
std::wstring localDir = *files.begin();
std::wstring currentCD = ftpDir + GetDirectoryName(ReplaceStr(localDir, L'\\', L'/'));
- if (currentCD != lastCD)
- {
+ if (currentCD != lastCD) {
if (!currentCD.empty() && currentCD != L"/")
stream << "mkdir \"" << currentCD << "\"\n";
stream << "cd \"" << currentCD << "\"\n";
@@ -1356,54 +1134,39 @@ bool FtpFiles(const std::wstring& dir, const std::wstring& filePath, const std:: STARTUPINFO startupInfo = {0};
PROCESS_INFORMATION processInfo;
startupInfo.cb = sizeof(STARTUPINFO);
- if (CreateProcess(NULL, cmdLine, NULL, NULL, FALSE, 0, NULL, dir.c_str(), &startupInfo, &processInfo))
- {
+ if (CreateProcess(NULL, cmdLine, NULL, NULL, FALSE, 0, NULL, dir.c_str(), &startupInfo, &processInfo)) {
WaitForSingleObject(processInfo.hProcess, INFINITE);
CloseHandle(processInfo.hThread);
CloseHandle(processInfo.hProcess);
if (log.empty())
- {
return false;
- }
std::wifstream logStream (log.c_str());
- if (logStream.is_open())
- {
+ if (logStream.is_open()) {
bool isInMDTM = false;
std::list<std::wstring> dates;
- while(!logStream.eof())
- {
+ while(!logStream.eof()) {
std::wstring lineStr;
std::getline(logStream, lineStr);
- if (lineStr.length() > 1)
- {
- if (lineStr[0] == L'>')
- {
- if (isInMDTM)
- {
- if (lineStr.find(L"Script:") < lineStr.length())
- {
+ if (lineStr.length() > 1) {
+ if (lineStr[0] == L'>') {
+ if (isInMDTM) {
+ if (lineStr.find(L"Script:") < lineStr.length()) {
dates.push_back(L"");
isInMDTM = false;
}
}
if (lineStr.find(L"Script: call MDTM") < lineStr.length())
- {
isInMDTM = true;
- }
}
- else if (isInMDTM && lineStr[0] == L'<')
- {
+ else if (isInMDTM && lineStr[0] == L'<') {
size_t ss = lineStr.find(L"Script: 213 ");
- if (ss < lineStr.length())
- {
+ if (ss < lineStr.length()) {
ss += 12;
- if (ss < lineStr.length())
- {
+ if (ss < lineStr.length()) {
lineStr = lineStr.substr(ss);
- if (lineStr.size() == 14)
- {
+ if (lineStr.size() == 14) {
dates.push_back(lineStr);
isInMDTM = false;
}
@@ -1413,14 +1176,11 @@ bool FtpFiles(const std::wstring& dir, const std::wstring& filePath, const std:: }
}
- if (dates.size() > 0 && dates.size() == filSize * 2)
- {
- for(std::list<std::wstring>::const_iterator it = dates.begin(); it != dates.end(); ++it)
- {
+ if (dates.size() > 0 && dates.size() == filSize * 2) {
+ for (std::list<std::wstring>::const_iterator it = dates.begin(); it != dates.end(); ++it) {
std::wstring date1 = *it++;
if (it->empty() || date1 == *it)
return true;
-
}
return false;
@@ -1438,19 +1198,16 @@ bool FtpGetFiles(const std::wstring& dir, const std::list<std::wstring>& files, std::map<std::wstring, bool> existingContacts;
std::wstring script = dir + _T("\\script.sc");
std::wofstream stream (script.c_str());
- if (stream.is_open())
- {
+ if (stream.is_open()) {
stream << "option batch continue\noption confirm off\nopen \""
<< ftpName << "\"\noption transfer binary\n";
std::wstring lastCD;
std::list<std::wstring> localFiles;
- for(std::list<std::wstring>::const_iterator it = files.begin(); it != files.end(); ++it)
- {
+ for (std::list<std::wstring>::const_iterator it = files.begin(); it != files.end(); ++it) {
std::wstring fileName = GetName(*it);
localFiles.push_back(dir + L"\\" + fileName);
std::wstring currentCD = GetDirectoryName(*it);
- if (currentCD != lastCD)
- {
+ if (currentCD != lastCD) {
stream << "cd \"" << currentCD << "\"\n";
lastCD = currentCD;
}
@@ -1467,21 +1224,17 @@ bool FtpGetFiles(const std::wstring& dir, const std::list<std::wstring>& files, STARTUPINFO startupInfo = {0};
PROCESS_INFORMATION processInfo;
startupInfo.cb = sizeof(STARTUPINFO);
- if (CreateProcess(NULL, cmdLine, NULL, NULL, FALSE, 0, NULL, dir.c_str(), &startupInfo, &processInfo))
- {
+ if (CreateProcess(NULL, cmdLine, NULL, NULL, FALSE, 0, NULL, dir.c_str(), &startupInfo, &processInfo)) {
WaitForSingleObject(processInfo.hProcess, INFINITE);
CloseHandle(processInfo.hThread);
CloseHandle(processInfo.hProcess);
}
DeleteFile(script.c_str());
- for(std::list<std::wstring>::const_iterator it = localFiles.begin(); it != localFiles.end(); ++it)
- {
+ for (std::list<std::wstring>::const_iterator it = localFiles.begin(); it != localFiles.end(); ++it) {
DWORD atr = GetFileAttributes(it->c_str());
if (atr == INVALID_FILE_ATTRIBUTES || atr & FILE_ATTRIBUTE_DIRECTORY)
- {
return true;
- }
}
return false;
@@ -1516,8 +1269,7 @@ INT_PTR ExecuteTaskService(WPARAM wParam, LPARAM lParam) {
EnterCriticalSection(&Options::instance->criticalSection);
int taskNr = (int)wParam;
- if (taskNr < 0 || taskNr >= (int)Options::instance->taskOptions.size())
- {
+ if (taskNr < 0 || taskNr >= (int)Options::instance->taskOptions.size()) {
LeaveCriticalSection(&Options::instance->criticalSection);
return FALSE;
}
@@ -1533,8 +1285,7 @@ void DoError(const TaskOptions& to, const std::wstring _error) {
TCHAR msg[256];
mir_sntprintf(msg, SIZEOF(msg), TranslateT("Task '%s' execution failed:"), to.taskName.c_str());
- if (Options::instance->schedulerHistoryAlerts)
- {
+ if (Options::instance->schedulerHistoryAlerts) {
std::wstring error = msg;
error += L"\n";
error += _error;
@@ -1552,17 +1303,14 @@ void DoError(const TaskOptions& to, const std::wstring _error) dbei.pBlob = (PBYTE)buf;
db_event_add(NULL, &dbei);
}
-
- if (Options::instance->schedulerAlerts)
- {
- if (CallService(MS_SYSTEM_TERMINATED, 0, 0)) return;
- if (ServiceExists(MS_POPUP_ADDPOPUPCLASS))
- {
+ if (Options::instance->schedulerAlerts) {
+ if ( CallService(MS_SYSTEM_TERMINATED, 0, 0))
+ return;
+
+ if ( ServiceExists(MS_POPUP_ADDPOPUPCLASS))
ShowClassPopupT(MODULE, msg, (wchar_t*)_error.c_str());
- }
- else if (ServiceExists( MS_POPUP_ADDPOPUPT ))
- {
+ else if ( ServiceExists(MS_POPUP_ADDPOPUPT)) {
POPUPDATAT ppd = {0};
ppd.lchIcon = LoadSkinnedIcon(SKINICON_OTHER_HISTORY);
_tcscpy_s(ppd.lptzContactName, msg);
diff --git a/plugins/BasicHistory/src/Searcher.cpp b/plugins/BasicHistory/src/Searcher.cpp index 57638e6c6d..0c9091e4f6 100644 --- a/plugins/BasicHistory/src/Searcher.cpp +++ b/plugins/BasicHistory/src/Searcher.cpp @@ -33,20 +33,17 @@ Searcher::Searcher() void Searcher::ChangeFindDirection(bool isBack)
{
- if (isBack != findBack)
- {
+ if (isBack != findBack) {
findBack = isBack;
ClearFind();
TBBUTTONINFO tbInfo;
tbInfo.cbSize = sizeof(TBBUTTONINFO);
tbInfo.dwMask = TBIF_TEXT | TBIF_IMAGE;
- if (isBack)
- {
+ if (isBack) {
tbInfo.pszText = TranslateT("Find Previous");
tbInfo.iImage = 1;
}
- else
- {
+ else {
tbInfo.pszText = TranslateT("Find Next");
tbInfo.iImage = 0;
}
@@ -58,8 +55,7 @@ void Searcher::ChangeFindDirection(bool isBack) void Searcher::ClearFind()
{
- if (lastFindSelection != -1)
- {
+ if (lastFindSelection != -1) {
SendMessage(context->editWindow,EM_SETOPTIONS,ECOOP_AND,~ECO_NOHIDESEL);
lastFindSelection = -1;
}
@@ -77,10 +73,10 @@ bool Searcher::CompareStr(std::wstring str, TCHAR *strFind) std::transform(str.begin(), str.end(), str.begin(), std::bind2nd(std::ptr_fun(mytoupper), &loc));
if (!matchWholeWords)
return str.find(strFind) < str.length();
+
size_t findid = str.find(strFind);
size_t findLen = _tcslen(strFind);
- while(findid < str.length())
- {
+ while(findid < str.length()) {
if ((findid == 0 || std::isspace(str[findid - 1], loc) || std::ispunct(str[findid - 1], loc)) &&
(findid + findLen >= str.length() || std::isspace(str[findid + findLen], loc) || std::ispunct(str[findid + findLen], loc)))
return true;
@@ -100,23 +96,20 @@ void Searcher::Find() ft.chrg.cpMin = 0;
ft.chrg.cpMax = -1;
ft.lpstrText = str;
- if (context->currentGroup.size() < 1)
- {
+ if (context->currentGroup.size() < 1) {
SendMessage(context->editWindow,EM_SETOPTIONS,ECOOP_AND,~ECO_NOHIDESEL);
lastFindSelection = -1;
return;
}
GetWindowText(context->findWindow, str, 128);
- if (!str[0])
- {
+ if (!str[0]) {
TCHAR buf[256];
mir_sntprintf(buf, 256, TranslateT("\"%s\" not found"), str);
MessageBox(context->hWnd, buf, TranslateT("Search"), MB_OK | MB_ICONINFORMATION);
return;
}
- if (!matchCase)
- {
+ if (!matchCase) {
std::locale loc;
std::transform(str, str + _tcslen(str), str, std::bind2nd(std::ptr_fun(mytoupper), &loc));
}
@@ -126,38 +119,26 @@ void Searcher::Find() int adder1 = findBack1 ? -1 : 1;
int adder2 = findBack2 ? -1 : 1;
WPARAM findStyle = (findBack1 ? 0 : FR_DOWN) | (matchCase ? FR_MATCHCASE : 0) | (matchWholeWords ? FR_WHOLEWORD : 0);
- if (lastFindSelection >= 0 && lastFindSelection < (int)context->currentGroup.size())
- {
+ if (lastFindSelection >= 0 && lastFindSelection < (int)context->currentGroup.size()) {
if (onlyIn && context->currentGroup[lastFindSelection].isMe || onlyOut && !context->currentGroup[lastFindSelection].isMe)
- {
curSel = lastFindSelection + adder1;
- }
- else
- {
+ else {
SendDlgItemMessage(context->hWnd,IDC_EDIT,EM_EXGETSEL,0,(LPARAM)&ft.chrg);
- if (findBack1)
- {
+ if (findBack1) {
ft.chrg.cpMin = ft.chrg.cpMin < context->currentGroup[lastFindSelection].endPos ? ft.chrg.cpMin : context->currentGroup[lastFindSelection].endPos;
ft.chrg.cpMax = context->currentGroup[lastFindSelection].startPos;
}
- else
- {
+ else {
ft.chrg.cpMin = ft.chrg.cpMax > context->currentGroup[lastFindSelection].startPos ? ft.chrg.cpMax : context->currentGroup[lastFindSelection].startPos;
ft.chrg.cpMax = context->currentGroup[lastFindSelection].endPos;
}
SendMessage(context->editWindow,EM_FINDTEXTEX, findStyle,(LPARAM)&ft);
if (ft.chrgText.cpMin < 0 || ft.chrgText.cpMax < 0)
- {
curSel = lastFindSelection + adder1;
- }
- else
- {
+ else {
if (isFindContactChanged && startFindContact == context->hContact && isFindSelChanged && context->selected == startFindSel && ((!findBack1 && ft.chrg.cpMin >= startFindPos) || (findBack1 && ft.chrg.cpMax <= startFindPos)))
- {
finished = true;
- }
- else
- {
+ else {
curSel = lastFindSelection;
SendMessage(context->editWindow,EM_EXSETSEL,0,(LPARAM)&ft.chrgText);
SendMessage(context->editWindow,EM_SETOPTIONS,ECOOP_OR,ECO_NOHIDESEL);
@@ -167,8 +148,7 @@ void Searcher::Find() }
}
}
- else
- {
+ else {
isStart = true;
SendMessage(context->editWindow,EM_SETOPTIONS,ECOOP_OR,ECO_NOHIDESEL);
SendMessage(context->editWindow,EM_EXGETSEL,0,(LPARAM)&ft.chrg);
@@ -179,47 +159,38 @@ void Searcher::Find() isFindSelChanged = false;
startFindContact = context->hContact;
isFindContactChanged = !allUsers;
- if (findBack1)
- for(curSel = (int)context->currentGroup.size() - 1; curSel >= 0; --curSel)
- {
+ if (findBack1) {
+ for (curSel = (int)context->currentGroup.size() - 1; curSel >= 0; --curSel)
if (context->currentGroup[curSel].startPos < startFindPos)
break;
- }
+ }
else
- for(; curSel < (int)context->currentGroup.size(); ++curSel)
- {
+ for (; curSel < (int)context->currentGroup.size(); ++curSel)
if (context->currentGroup[curSel].endPos > startFindPos)
break;
- }
}
- if (!finished)
- {
- for(; curSel < (int)context->currentGroup.size() && curSel >= 0; curSel += adder1)
- {
+ if (!finished) {
+ for (; curSel < (int)context->currentGroup.size() && curSel >= 0; curSel += adder1) {
if (onlyIn && context->currentGroup[curSel].isMe || onlyOut && !context->currentGroup[curSel].isMe)
continue;
- if (CompareStr(context->currentGroup[curSel].description, str))
- {
- if (findBack1)
- {
+
+ if (CompareStr(context->currentGroup[curSel].description, str)) {
+ if (findBack1) {
ft.chrg.cpMin = context->currentGroup[curSel].endPos;
ft.chrg.cpMax = context->currentGroup[curSel].startPos;
if (!isFindSelChanged && ft.chrg.cpMin > startFindPos)
ft.chrg.cpMin = startFindPos;
}
- else
- {
+ else {
ft.chrg.cpMin = context->currentGroup[curSel].startPos;
ft.chrg.cpMax = context->currentGroup[curSel].endPos;
if (!isFindSelChanged && ft.chrg.cpMin < startFindPos)
ft.chrg.cpMin = startFindPos;
}
SendMessage(context->editWindow,EM_FINDTEXTEX, findStyle,(LPARAM)&ft);
- if (!(ft.chrgText.cpMin < 0 || ft.chrgText.cpMax < 0))
- {
- if (isFindContactChanged && startFindContact == context->hContact && isFindSelChanged && context->selected == startFindSel && ((!findBack1 && ft.chrg.cpMin >= startFindPos) || (findBack1 && ft.chrg.cpMax <= startFindPos)))
- {
+ if (!(ft.chrgText.cpMin < 0 || ft.chrgText.cpMax < 0)) {
+ if (isFindContactChanged && startFindContact == context->hContact && isFindSelChanged && context->selected == startFindSel && ((!findBack1 && ft.chrg.cpMin >= startFindPos) || (findBack1 && ft.chrg.cpMax <= startFindPos))) {
finished = true;
break;
}
@@ -233,17 +204,12 @@ void Searcher::Find() }
if (isFindContactChanged && startFindContact == context->hContact && isFindSelChanged && context->selected == startFindSel)
- {
finished = true;
- }
- if (!finished)
- {
+ if (!finished) {
isFindSelChanged = true;
- if (onlyGroup)
- {
- if (IsInSel(context->selected, str))
- {
+ if (onlyGroup) {
+ if (IsInSel(context->selected, str)) {
CHARRANGE ch;
ch.cpMin = ch.cpMax = findBack1 ? MAXLONG : 0;
SendMessage(context->editWindow,EM_EXSETSEL,0,(LPARAM)&ch);
@@ -252,44 +218,37 @@ void Searcher::Find() return;
}
}
- else
- {
- for(int sel = context->selected + adder2; ; sel += adder2)
- {
- if (sel < 0)
- {
+ else {
+ for (int sel = context->selected + adder2; ; sel += adder2) {
+ if (sel < 0) {
isFindContactChanged = true;
- if (allUsers)
- {
+ if (allUsers) {
HANDLE hNext = context->hContact;
do
{
hNext = context->GetNextContact(hNext, adder2);
}
- while(hNext != startFindContact && !context->SearchInContact(hNext, str, this));
+ while(hNext != startFindContact && !context->SearchInContact(hNext, str, this));
context->SelectContact(hNext);
}
sel = (int)context->eventList.size() - 1;
}
- else if (sel >= (int)context->eventList.size())
- {
+ else if (sel >= (int)context->eventList.size()) {
isFindContactChanged = true;
- if (allUsers)
- {
+ if (allUsers) {
HANDLE hNext = context->hContact;
do
{
hNext = context->GetNextContact(hNext, adder2);
}
- while(hNext != startFindContact && !context->SearchInContact(hNext, str, this));
+ while(hNext != startFindContact && !context->SearchInContact(hNext, str, this));
context->SelectContact(hNext);
}
sel = 0;
}
- if (IsInSel(sel, str))
- {
+ if (IsInSel(sel, str)) {
LVITEM item = {0};
item.mask = LVIF_STATE;
item.iItem = context->selected;
@@ -316,12 +275,9 @@ void Searcher::Find() }
if (startFindContact != context->hContact)
- {
context->SelectContact(startFindContact);
- }
- if (startFindSel != context->selected)
- {
+ if (startFindSel != context->selected) {
LVITEM item = {0};
item.mask = LVIF_STATE;
item.iItem = context->selected;
@@ -340,17 +296,13 @@ void Searcher::Find() SendMessage(context->editWindow,EM_EXSETSEL,0,(LPARAM)&ft.chrgText);
SendMessage(context->editWindow,EM_SETOPTIONS,ECOOP_AND,~ECO_NOHIDESEL);
lastFindSelection = -1;
- if (isStart)
- {
+ if (isStart) {
TCHAR buf[256];
GetWindowText(context->findWindow, str, 128);
mir_sntprintf(buf, 256, TranslateT("\"%s\" not found"), str);
MessageBox(context->hWnd, buf, TranslateT("Search"), MB_OK | MB_ICONINFORMATION);
}
- else
- {
- MessageBox(context->hWnd, TranslateTS(onlyGroup ? LPGENT("You have reached the end of the group.") : LPGENT("You have reached the end of the history.")), TranslateT("Search"), MB_OK | MB_ICONINFORMATION);
- }
+ else MessageBox(context->hWnd, TranslateTS(onlyGroup ? LPGENT("You have reached the end of the group.") : LPGENT("You have reached the end of the history.")), TranslateT("Search"), MB_OK | MB_ICONINFORMATION);
}
bool Searcher::IsInSel(int sel, TCHAR *strFind)
@@ -360,19 +312,16 @@ bool Searcher::IsInSel(int sel, TCHAR *strFind) TCHAR str[MAXSELECTSTR + 8]; // for safety reason
EventList::EventData data;
- for(std::deque<EventList::EventIndex>::iterator it = context->eventList[sel].begin(); it != context->eventList[sel].end(); ++it)
- {
+ for (std::deque<EventList::EventIndex>::iterator it = context->eventList[sel].begin(); it != context->eventList[sel].end(); ++it) {
EventList::EventIndex hDbEvent = *it;
- if (context->GetEventData(hDbEvent, data))
- {
+ if (context->GetEventData(hDbEvent, data)) {
bool isMe = data.isMe;
if (onlyIn && isMe || onlyOut && !isMe)
continue;
+
context->GetEventMessage(hDbEvent, str);
if (CompareStr(str, strFind))
- {
return true;
- }
}
}
diff --git a/plugins/BasicHistory/src/version.h b/plugins/BasicHistory/src/version.h index ad468abd50..da6b4f91be 100644 --- a/plugins/BasicHistory/src/version.h +++ b/plugins/BasicHistory/src/version.h @@ -1,14 +1,14 @@ -#define __MAJOR_VERSION 1
-#define __MINOR_VERSION 0
-#define __RELEASE_NUM 1
-#define __BUILD_NUM 9
-
-#define __FILEVERSION_STRING __MAJOR_VERSION,__MINOR_VERSION,__RELEASE_NUM,__BUILD_NUM
+#define __MAJOR_VERSION 1
+#define __MINOR_VERSION 0
+#define __RELEASE_NUM 1
+#define __BUILD_NUM 10
-#define __PLUGIN_NAME "Basic history"
-#define __FILENAME "BasicHistory.dll"
-#define __DESCRIPTION "History viewer for Miranda NG."
-#define __AUTHOR "Krzysztof Kral"
-#define __AUTHOREMAIL "krzysztof.kral@gmail.com"
-#define __AUTHORWEB "http://miranda-ng.org/p/BasicHistory/"
-#define __COPYRIGHT "© 2011-2012 Krzysztof Kral"
+#define __FILEVERSION_STRING __MAJOR_VERSION,__MINOR_VERSION,__RELEASE_NUM,__BUILD_NUM
+
+#define __PLUGIN_NAME "Basic history"
+#define __FILENAME "BasicHistory.dll"
+#define __DESCRIPTION "History viewer for Miranda NG."
+#define __AUTHOR "Krzysztof Kral"
+#define __AUTHOREMAIL "krzysztof.kral@gmail.com"
+#define __AUTHORWEB "http://miranda-ng.org/p/BasicHistory/"
+#define __COPYRIGHT "© 2011-2012 Krzysztof Kral"
|