diff options
Diffstat (limited to 'plugins/BasicHistory/src')
-rw-r--r-- | plugins/BasicHistory/src/HistoryWindow.cpp | 52 | ||||
-rw-r--r-- | plugins/BasicHistory/src/Options.cpp | 41 |
2 files changed, 29 insertions, 64 deletions
diff --git a/plugins/BasicHistory/src/HistoryWindow.cpp b/plugins/BasicHistory/src/HistoryWindow.cpp index e5cd9c7384..5902dc3de8 100644 --- a/plugins/BasicHistory/src/HistoryWindow.cpp +++ b/plugins/BasicHistory/src/HistoryWindow.cpp @@ -1773,27 +1773,19 @@ void HistoryWindow::ReloadContacts() }
}
- HANDLE _hContact = db_find_first();
- while(_hContact)
- {
- if(EventList::GetContactMessageNumber(_hContact) && (metaContactProto == NULL || db_get_b(_hContact, metaContactProto, "IsSubcontact", 0) == 0))
+ HANDLE hContact;
+ for (hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
+ if(EventList::GetContactMessageNumber(hContact) && (metaContactProto == NULL || db_get_b(hContact, metaContactProto, "IsSubcontact", 0) == 0))
{
- HANDLE hItem = (HANDLE)SendMessage(contactList, CLM_FINDCONTACT, (WPARAM)_hContact, 0);
+ HANDLE hItem = (HANDLE)SendMessage(contactList, CLM_FINDCONTACT, (WPARAM)hContact, 0);
if(hItem == NULL)
- {
- SendMessage(contactList, CLM_ADDCONTACT, (WPARAM)_hContact, 0);
- }
+ SendMessage(contactList, CLM_ADDCONTACT, (WPARAM)hContact, 0);
}
- else
- {
- HANDLE hItem = (HANDLE)SendMessage(contactList, CLM_FINDCONTACT, (WPARAM)_hContact, 0);
+ else {
+ HANDLE hItem = (HANDLE)SendMessage(contactList, CLM_FINDCONTACT, (WPARAM)hContact, 0);
if(hItem != NULL)
- {
- SendMessage(contactList, CLM_DELETEITEM, (WPARAM)_hContact, 0);
- }
+ SendMessage(contactList, CLM_DELETEITEM, (WPARAM)hContact, 0);
}
-
- _hContact = db_find_next(_hContact);
}
if(hContact != NULL)
@@ -1944,17 +1936,14 @@ void HistoryWindow::SavePos(bool all) HANDLE contactToSave = hContact;
if(all)
{
- HANDLE _hContact = db_find_first();
- while(_hContact)
- {
- db_unset(_hContact, MODULE, "history_x");
- db_unset(_hContact, MODULE, "history_y");
- db_unset(_hContact, MODULE, "history_width");
- db_unset(_hContact, MODULE, "history_height");
- db_unset(_hContact, MODULE, "history_ismax");
- db_unset(_hContact, MODULE, "history_splitterv");
- db_unset(_hContact, MODULE, "history_splitter");
- _hContact = db_find_next(_hContact);
+ for (hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
+ db_unset(hContact, MODULE, "history_x");
+ db_unset(hContact, MODULE, "history_y");
+ db_unset(hContact, MODULE, "history_width");
+ db_unset(hContact, MODULE, "history_height");
+ db_unset(hContact, MODULE, "history_ismax");
+ db_unset(hContact, MODULE, "history_splitterv");
+ db_unset(hContact, MODULE, "history_splitter");
}
contactToSave = NULL;
@@ -2170,12 +2159,9 @@ void HistoryWindow::DoImport(IImport::ImportType type) std::vector<IImport::ExternalMessage> messages;
std::wstring err;
std::vector<HANDLE> contacts;
- HANDLE _hContact = db_find_first();
- while(_hContact)
- {
- contacts.push_back(_hContact);
- _hContact = db_find_next(_hContact);
- }
+
+ for(hContact = db_find_first(); hContact; hContact = db_find_next(hContact))
+ contacts.push_back(hContact);
bool changeContact = false;
HANDLE lastContact = hContact;
diff --git a/plugins/BasicHistory/src/Options.cpp b/plugins/BasicHistory/src/Options.cpp index 3e9283df10..8e3d159289 100644 --- a/plugins/BasicHistory/src/Options.cpp +++ b/plugins/BasicHistory/src/Options.cpp @@ -598,18 +598,12 @@ void Options::SaveTasks(std::list<TaskOptions>* tasks) sprintf_s(buf, "Task_zipPassword_%d", i);
db_set_s(0, MODULE, buf, it->zipPassword.c_str());
- HANDLE _hContact = db_find_first();
sprintf_s(buf, "IsInTask_%d", i);
- while(_hContact)
- {
- db_unset(_hContact, MODULE, buf);
- _hContact = db_find_next(_hContact);
- }
+ 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)
- {
db_set_b(it->contacts[j], MODULE, buf, 1);
- }
it->orderNr = i++;
taskOptions.push_back(*it);
@@ -660,13 +654,9 @@ void Options::SaveTasks(std::list<TaskOptions>* tasks) sprintf_s(buf, "Task_taskName_%d", i);
db_unset(NULL, MODULE, buf);
- HANDLE _hContact = db_find_first();
sprintf_s(buf, "IsInTask_%d", i);
- while(_hContact)
- {
- db_unset(_hContact, MODULE, buf);
- _hContact = db_find_next(_hContact);
- }
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact))
+ db_unset(hContact, MODULE, buf);
}
LeaveCriticalSection(&criticalSection);
@@ -758,17 +748,10 @@ void Options::LoadTasks() db_free(&var);
}
- HANDLE _hContact = db_find_first();
sprintf_s(buf, "IsInTask_%d", i);
- while(_hContact)
- {
- if(db_get_b(_hContact, MODULE, buf, 0) == 1)
- {
- to.contacts.push_back(_hContact);
- }
-
- _hContact = db_find_next(_hContact);
- }
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact))
+ if(db_get_b(hContact, MODULE, buf, 0) == 1)
+ to.contacts.push_back(hContact);
to.orderNr = i;
taskOptions.push_back(to);
@@ -1765,19 +1748,15 @@ void RebuildList(HWND hwnd, HANDLE hSystem, TaskOptions* to) void SaveList(HWND hwnd, HANDLE hSystem, TaskOptions* to)
{
- HANDLE hContact, hItem;
-
to->contacts.clear();
if (hSystem)
to->isSystem = SendMessage(hwnd, CLM_GETCHECKMARK, (WPARAM) hSystem, 0) != 0;
- hContact = db_find_first();
- do
- {
- hItem = (HANDLE) SendMessage(hwnd, CLM_FINDCONTACT, (WPARAM) hContact, 0);
+
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
+ HANDLE hItem = (HANDLE) SendMessage(hwnd, CLM_FINDCONTACT, (WPARAM) hContact, 0);
if (hItem && SendMessage(hwnd, CLM_GETCHECKMARK, (WPARAM) hItem, 0))
to->contacts.push_back(hContact);
}
- while (hContact = db_find_next(hContact));
}
bool IsValidTask(TaskOptions& to, std::list<TaskOptions>* top = NULL, std::wstring* err = NULL, std::wstring* errDescr = NULL);
|