diff options
author | George Hazan <george.hazan@gmail.com> | 2014-07-27 20:46:17 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2014-07-27 20:46:17 +0000 |
commit | 5950b3dbd1860c333d59ec9ce66ff001a750735d (patch) | |
tree | 7dae201f2a26546f032a35b2e1c08ac1c6fadfd4 /plugins/HistorySweeperLight/src | |
parent | f2f5e5189babe0bfdc2f308679f74b29c254a482 (diff) |
- fix for clearing SRMM icon;
- code cleaning
git-svn-id: http://svn.miranda-ng.org/main/trunk@9974 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/HistorySweeperLight/src')
-rw-r--r-- | plugins/HistorySweeperLight/src/historysweeperlight.cpp | 255 | ||||
-rw-r--r-- | plugins/HistorySweeperLight/src/historysweeperlight.h | 3 | ||||
-rw-r--r-- | plugins/HistorySweeperLight/src/main.cpp | 49 | ||||
-rw-r--r-- | plugins/HistorySweeperLight/src/options.cpp | 149 | ||||
-rw-r--r-- | plugins/HistorySweeperLight/src/version.h | 14 |
5 files changed, 228 insertions, 242 deletions
diff --git a/plugins/HistorySweeperLight/src/historysweeperlight.cpp b/plugins/HistorySweeperLight/src/historysweeperlight.cpp index 23687bb7c8..12042a1b6e 100644 --- a/plugins/HistorySweeperLight/src/historysweeperlight.cpp +++ b/plugins/HistorySweeperLight/src/historysweeperlight.cpp @@ -30,33 +30,32 @@ typedef struct // build criteria
time_t BuildCriteria(int dwti)
{
- time_t tim = time(NULL);
-
- switch (dwti)
- {
- case 0:
- tim -= 1 * 24 * 3600;
- break;
- case 1:
- tim -= 3 * 24 * 3600;
- break;
- case 2:
- tim -= 7 * 24 * 3600;
- break;
- case 3:
- tim -= 14 * 24 * 3600;
- break;
- case 4:
- tim -= 30 * 24 * 3600;
- break;
- case 5:
- tim -= 90 * 24 * 3600;
- break;
- case 6:
- tim -= 180 * 24 * 3600;
- break;
- default:
- tim -= 365 * 24 * 3600;
+ time_t tim = time(NULL);
+
+ switch (dwti) {
+ case 0:
+ tim -= 1 * 24 * 3600;
+ break;
+ case 1:
+ tim -= 3 * 24 * 3600;
+ break;
+ case 2:
+ tim -= 7 * 24 * 3600;
+ break;
+ case 3:
+ tim -= 14 * 24 * 3600;
+ break;
+ case 4:
+ tim -= 30 * 24 * 3600;
+ break;
+ case 5:
+ tim -= 90 * 24 * 3600;
+ break;
+ case 6:
+ tim -= 180 * 24 * 3600;
+ break;
+ default:
+ tim -= 365 * 24 * 3600;
}
return tim;
}
@@ -64,45 +63,42 @@ time_t BuildCriteria(int dwti) // keep criteria
int KeepCriteria(int dwti)
{
- switch (dwti)
- {
- case 0:
- return 1;
- case 1:
- return 2;
- case 2:
- return 5;
- case 3:
- return 10;
- case 4:
- return 20;
- default:
- return 50;
+ switch (dwti) {
+ case 0:
+ return 1;
+ case 1:
+ return 2;
+ case 2:
+ return 5;
+ case 3:
+ return 10;
+ case 4:
+ return 20;
+ default:
+ return 50;
}
}
-typedef struct
+struct BEventData
{
HANDLE hDBEvent;
DWORD CRC32;
DWORD Timestamp;
-} BEventData;
+};
-static int CompareBookmarks( const void* p1, const void* p2 )
+static int CompareBookmarks(const void* p1, const void* p2)
{
return (BYTE*)((BEventData*)p1)->hDBEvent - (BYTE*)((BEventData*)p2)->hDBEvent;
}
-static void GetBookmarks(MCONTACT hContact, BEventData** books, size_t* bookcnt )
+static void GetBookmarks(MCONTACT hContact, BEventData** books, size_t* bookcnt)
{
*books = NULL;
*bookcnt = 0;
DBVARIANT dbv;
- if (db_get(hContact, "HistoryPlusPlus", "Bookmarks", &dbv) == 0)
- {
- if (dbv.cpbVal > 2 && *(WORD*)dbv.pbVal >= sizeof(BEventData))
- {
+ if (db_get(hContact, "HistoryPlusPlus", "Bookmarks", &dbv) == 0) {
+ if (dbv.cpbVal > 2 && *(WORD*)dbv.pbVal >= sizeof(BEventData)) {
size_t recSize = *(WORD*)dbv.pbVal;
size_t numb = (dbv.cpbVal - sizeof(WORD)) / recSize;
@@ -112,21 +108,18 @@ static void GetBookmarks(MCONTACT hContact, BEventData** books, size_t* bookcnt size_t i;
BYTE* evs = dbv.pbVal + sizeof(WORD);
- for (i=0; i<numb; ++i)
- {
+ for (i = 0; i < numb; ++i) {
tbooks[tbookcnt++] = *(BEventData*)evs;
evs += recSize;
}
- if (tbookcnt != 0)
- {
+ if (tbookcnt != 0) {
qsort(tbooks, tbookcnt, sizeof(BEventData), CompareBookmarks);
*bookcnt = tbookcnt;
*books = tbooks;
}
- else
- mir_free(tbooks);
+ else mir_free(tbooks);
}
-
+
db_free(&dbv);
}
}
@@ -134,98 +127,124 @@ static void GetBookmarks(MCONTACT hContact, BEventData** books, size_t* bookcnt //Sweep history from specified contact
void SweepHistoryFromContact(MCONTACT hContact, CriteriaStruct Criteria, BOOL keepUnread)
{
- int lPolicy;
+ int lPolicy;
if (hContact == NULL) // for system history
lPolicy = db_get_b(NULL, ModuleName, "SweepSHistory", 0);
else // for contact history (or "SweepHistory" - default action)
lPolicy = db_get_b(hContact, ModuleName, "SweepHistory", db_get_b(NULL, ModuleName, "SweepHistory", 0));
-
+
if (lPolicy == 0) return; // nothing to do
-
+
int eventsCnt = db_event_count(hContact);
- if (eventsCnt != 0) {
- BOOL doDelete, unsafe = db_get_b(NULL, ModuleName, "UnsafeMode", 0);
- BEventData *books, *item, ev = { 0 };
- size_t bookcnt, btshift;
-
- SetCursor(LoadCursor(0, IDC_WAIT));
-
- // switch off SAFETYMODE if necessary
- if (unsafe) CallService(MS_DB_SETSAFETYMODE, 0, 0);
-
- GetBookmarks(hContact, &books, &bookcnt);
-
- //Get first event
- HANDLE hDBEvent = db_event_first(hContact);
- while (hDBEvent != NULL) {
- DBEVENTINFO dbei = { sizeof(dbei) };
- db_event_get(hDBEvent, &dbei);
-
- // should we stop processing?
- // lPolicy == 1 - for time criterion, lPolicy == 2 - keep N last events, lPolicy == 3 - delete all events
- if ( (lPolicy == 1 && (unsigned)Criteria.time < dbei.timestamp) || (lPolicy == 2 && Criteria.keep > --eventsCnt)) break;
-
- doDelete = TRUE;
-
- if (!(dbei.flags & (DBEF_SENT | DBEF_READ)) && keepUnread) doDelete = FALSE; // keep unread events
-
- if (bookcnt != 0) // keep bookmarks
- {
- ev.hDBEvent = hDBEvent;
- item = (BEventData*)bsearch( &ev, books, bookcnt, sizeof(BEventData), CompareBookmarks);
- if (item != NULL)
- if (item->Timestamp == dbei.timestamp)
- {
- doDelete = FALSE;
- btshift = (--bookcnt - (item - books))*sizeof(BEventData);
- if (btshift) memmove(item, item+1, btshift);
- }
- }
+ if (eventsCnt == 0)
+ return;
+
+ BOOL doDelete, unsafe = db_get_b(NULL, ModuleName, "UnsafeMode", 0);
+ BEventData *books, *item, ev = { 0 };
+ size_t bookcnt, btshift;
+
+ SetCursor(LoadCursor(0, IDC_WAIT));
- // find next event
- HANDLE hDBEventNext = db_event_next(hContact, hDBEvent);
+ // switch off SAFETYMODE if necessary
+ if (unsafe)
+ CallService(MS_DB_SETSAFETYMODE, 0, 0);
- if (doDelete)
- db_event_delete(hContact, hDBEvent);
-
- hDBEvent = hDBEventNext;
+ GetBookmarks(hContact, &books, &bookcnt);
+
+ // Get first event
+ for (HANDLE hDBEvent = db_event_first(hContact); hDBEvent != NULL; ) {
+ DBEVENTINFO dbei = { sizeof(dbei) };
+ db_event_get(hDBEvent, &dbei);
+
+ // should we stop processing?
+ // lPolicy == 1 - for time criterion, lPolicy == 2 - keep N last events, lPolicy == 3 - delete all events
+ if ((lPolicy == 1 && (unsigned)Criteria.time < dbei.timestamp) || (lPolicy == 2 && Criteria.keep > --eventsCnt)) break;
+
+ doDelete = TRUE;
+
+ if (!(dbei.flags & (DBEF_SENT | DBEF_READ)) && keepUnread) doDelete = FALSE; // keep unread events
+
+ if (bookcnt != 0) { // keep bookmarks
+ ev.hDBEvent = hDBEvent;
+ item = (BEventData*)bsearch(&ev, books, bookcnt, sizeof(BEventData), CompareBookmarks);
+ if (item != NULL && item->Timestamp == dbei.timestamp) {
+ doDelete = FALSE;
+ btshift = (--bookcnt - (item - books))*sizeof(BEventData);
+ if (btshift)
+ memmove(item, item + 1, btshift);
+ }
}
- mir_free(books);
+ // find next event
+ HANDLE hDBEventNext = db_event_next(hContact, hDBEvent);
+
+ if (doDelete)
+ db_event_delete(hContact, hDBEvent);
- // switch ON safety mode as fast as we can to avoid DB corruption
- if (unsafe) CallService(MS_DB_SETSAFETYMODE, 1, 0);
+ hDBEvent = hDBEventNext;
+ }
+
+ mir_free(books);
- SetCursor(LoadCursor(0, IDC_ARROW));
- } // if (eventsCnt != 0)
+ // switch ON safety mode as fast as we can to avoid DB corruption
+ if (unsafe)
+ CallService(MS_DB_SETSAFETYMODE, 1, 0);
+
+ SetCursor(LoadCursor(0, IDC_ARROW));
}
// shutdown action
void ShutdownAction(void)
-{
+{
CriteriaStruct Criteria;
Criteria.keep = KeepCriteria(db_get_b(NULL, ModuleName, "StartupShutdownKeep", 0));
Criteria.time = BuildCriteria(db_get_b(NULL, ModuleName, "StartupShutdownOlder", 0));
SweepHistoryFromContact(NULL, Criteria, FALSE); // sweep system history, keepunread==0
-
+
for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact))
SweepHistoryFromContact(hContact, Criteria, TRUE); // sweep contact history, keepunread==1
}
int OnWindowEvent(WPARAM wParam, LPARAM lParam)
{
- MessageWindowEventData* msgEvData = (MessageWindowEventData*)lParam;
+ MessageWindowEventData* msgEvData = (MessageWindowEventData*)lParam;
+ switch (msgEvData->uType) {
+ case MSG_WINDOW_EVT_OPENING:
+ g_hWindows.insert(PVOID(msgEvData->hContact));
+ SetSrmmIcon(msgEvData->hContact);
+ break;
+
+ case MSG_WINDOW_EVT_CLOSE:
+ if (db_get_b(NULL, ModuleName, "SweepOnClose", 0)) {
+ CriteriaStruct Criteria;
- if (msgEvData->uType == MSG_WINDOW_EVT_CLOSE && db_get_b(NULL, ModuleName, "SweepOnClose", 0))
- {
- CriteriaStruct Criteria;
+ Criteria.keep = KeepCriteria(db_get_b(NULL, ModuleName, "StartupShutdownKeep", 0));
+ Criteria.time = BuildCriteria(db_get_b(NULL, ModuleName, "StartupShutdownOlder", 0));
- Criteria.keep = KeepCriteria(db_get_b(NULL, ModuleName, "StartupShutdownKeep", 0));
- Criteria.time = BuildCriteria(db_get_b(NULL, ModuleName, "StartupShutdownOlder", 0));
+ SweepHistoryFromContact(msgEvData->hContact, Criteria, TRUE);
+ }
- SweepHistoryFromContact(msgEvData->hContact, Criteria, TRUE);
+ for (int i = g_hWindows.getCount() - 1; i >= 0; i--)
+ if (g_hWindows[i] == PVOID(msgEvData->hContact))
+ g_hWindows.remove(i);
+ break;
}
return 0;
-}
\ No newline at end of file +}
+
+void SetSrmmIcon(MCONTACT hContact)
+{
+ int sweep = db_get_b(hContact, ModuleName, "SweepHistory", 0);
+
+ StatusIconData sid = { 0 };
+ sid.cbSize = sizeof(sid);
+ sid.szModule = ModuleName;
+
+ for (int i = 0; i < 4; i++) {
+ sid.dwId = i;
+ sid.flags = (sweep == i) ? 0 : MBF_HIDDEN;
+ Srmm_ModifyIcon(hContact, &sid);
+ }
+}
diff --git a/plugins/HistorySweeperLight/src/historysweeperlight.h b/plugins/HistorySweeperLight/src/historysweeperlight.h index 9f820ec439..5e8140c1e8 100644 --- a/plugins/HistorySweeperLight/src/historysweeperlight.h +++ b/plugins/HistorySweeperLight/src/historysweeperlight.h @@ -44,9 +44,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // Plugin name
#define ModuleName "History Sweeper Light"
-
// main.c
extern HINSTANCE hInst;
+extern LIST<void> g_hWindows;
// options.c
extern char* time_stamp_strings[];
@@ -60,5 +60,6 @@ HANDLE GetIconHandle(const char* name); // historysweeper.c
void ShutdownAction(void);
int OnWindowEvent(WPARAM wParam, LPARAM lParam);
+void SetSrmmIcon(MCONTACT hContact);
#endif
diff --git a/plugins/HistorySweeperLight/src/main.cpp b/plugins/HistorySweeperLight/src/main.cpp index 3634c40929..4af28a0d93 100644 --- a/plugins/HistorySweeperLight/src/main.cpp +++ b/plugins/HistorySweeperLight/src/main.cpp @@ -25,8 +25,10 @@ HINSTANCE hInst; int hLangpack;
+LIST<void> g_hWindows(5);
+
static PLUGININFOEX pluginInfoEx =
-{
+{
sizeof(PLUGININFOEX),
__PLUGIN_NAME,
PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM),
@@ -37,7 +39,7 @@ static PLUGININFOEX pluginInfoEx = __AUTHORWEB,
UNICODE_AWARE,
// {1D9BF74A-44A8-4B3F-A6E5-73069D3A8979}
- {0x1d9bf74a, 0x44a8, 0x4b3f, {0xa6, 0xe5, 0x73, 0x6, 0x9d, 0x3a, 0x89, 0x79}}
+ { 0x1d9bf74a, 0x44a8, 0x4b3f, { 0xa6, 0xe5, 0x73, 0x6, 0x9d, 0x3a, 0x89, 0x79 } }
};
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
@@ -46,21 +48,19 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) return TRUE;
}
-int OnIconPressed(WPARAM hContact, LPARAM lParam)
+int OnIconPressed(WPARAM hContact, LPARAM lParam)
{
StatusIconClickData *sicd = (StatusIconClickData *)lParam;
- if ( !(sicd->flags & MBCF_RIGHTBUTTON) && !lstrcmpA(sicd->szModule, ModuleName)
- && db_get_b(NULL, ModuleName, "ChangeInMW", 0))
- {
- int nh = sicd->dwId;
-
+ if (!(sicd->flags & MBCF_RIGHTBUTTON) && !lstrcmpA(sicd->szModule, ModuleName) && db_get_b(NULL, ModuleName, "ChangeInMW", 0)) {
+ int nh = sicd->dwId;
+
StatusIconData sid = { sizeof(sid) };
sid.szModule = ModuleName;
sid.dwId = nh;
sid.flags = MBF_HIDDEN;
- Srmm_ModifyIcon(hContact, &sid);
-
+ Srmm_ModifyIcon(hContact, &sid);
+
nh = (nh + 1) % 4;
db_set_b(hContact, ModuleName, "SweepHistory", (BYTE)nh);
@@ -71,10 +71,9 @@ int OnIconPressed(WPARAM hContact, LPARAM lParam) return 0;
}
-
-int OnModulesLoaded(WPARAM wParam, LPARAM lParam)
+int OnModulesLoaded(WPARAM wParam, LPARAM lParam)
{
- int i, sweep = db_get_b(NULL, ModuleName, "SweepHistory", 0);
+ int sweep = db_get_b(NULL, ModuleName, "SweepHistory", 0);
StatusIconData sid = { sizeof(sid) };
sid.szModule = ModuleName;
@@ -109,26 +108,9 @@ int OnModulesLoaded(WPARAM wParam, LPARAM lParam) sid.szTooltip = LPGEN("Delete all events");
sid.flags = MBF_HIDDEN;
Srmm_AddIcon(&sid);
-
- // for new contacts
- for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
- ZeroMemory(&sid,sizeof(sid));
-
- sweep = db_get_b(hContact, ModuleName, "SweepHistory", 0);
-
- sid.cbSize = sizeof(sid);
- sid.szModule = ModuleName;
-
- for(i = 0; i < 4; i++) {
- sid.dwId = i;
- sid.flags = (sweep == i) ? 0 : MBF_HIDDEN;
- Srmm_ModifyIcon(hContact, &sid);
- }
- }
HookEvent(ME_MSG_WINDOWEVENT, OnWindowEvent);
HookEvent(ME_MSG_ICONPRESSED, OnIconPressed);
-
return 0;
}
@@ -143,14 +125,13 @@ extern "C" __declspec(dllexport) int Load(void) HookEvent(ME_SYSTEM_MODULESLOADED, OnModulesLoaded);
HookEvent(ME_OPT_INITIALISE, HSOptInitialise);
-
- InitIcons();
+ InitIcons();
return 0;
}
extern "C" __declspec(dllexport) int Unload(void)
-{
+{
ShutdownAction();
return 0;
-}
\ No newline at end of file +}
diff --git a/plugins/HistorySweeperLight/src/options.cpp b/plugins/HistorySweeperLight/src/options.cpp index 3c93437366..a7568c304d 100644 --- a/plugins/HistorySweeperLight/src/options.cpp +++ b/plugins/HistorySweeperLight/src/options.cpp @@ -46,10 +46,10 @@ char* keep_strings[] = static IconItem iconList[] =
{
- { LPGEN("Default Action"), "actG", IDI_ACTG },
- { LPGEN("Action 1"), "act1", IDI_ACT1 },
- { LPGEN("Action 2"), "act2", IDI_ACT2 },
- { LPGEN("Delete All"), "actDel", IDI_ACTDEL }
+ { LPGEN("Default Action"), "actG", IDI_ACTG },
+ { LPGEN("Action 1"), "act1", IDI_ACT1 },
+ { LPGEN("Action 2"), "act2", IDI_ACT2 },
+ { LPGEN("Delete All"), "actDel", IDI_ACTDEL }
};
static HANDLE hIconLibItem[SIZEOF(iconList)];
@@ -68,9 +68,7 @@ HICON LoadIconEx(const char* name) HANDLE GetIconHandle(const char* name)
{
- int i;
-
- for (i=0; i < SIZEOF(iconList); i++)
+ for (int i = 0; i < SIZEOF(iconList); i++)
if (lstrcmpA(iconList[i].szName, name) == 0)
return hIconLibItem[i];
@@ -89,21 +87,23 @@ HANDLE hAllContacts, hSystemHistory; static void ShowAllContactIcons(HWND hwndList)
{
SendMessage(hwndList, CLM_SETEXTRAIMAGE, (WPARAM)hAllContacts,
- MAKELPARAM(0, db_get_b(NULL, ModuleName, "SweepHistory", 0)));
+ MAKELPARAM(0, db_get_b(NULL, ModuleName, "SweepHistory", 0)));
SendMessage(hwndList, CLM_SETEXTRAIMAGE, (WPARAM)hSystemHistory,
- MAKELPARAM(0, db_get_b(NULL, ModuleName, "SweepSHistory", 0)));
+ MAKELPARAM(0, db_get_b(NULL, ModuleName, "SweepSHistory", 0)));
for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
HANDLE hItem = (HANDLE)SendMessage(hwndList, CLM_FINDCONTACT, hContact, 0);
SendMessage(hwndList, CLM_SETEXTRAIMAGE, (WPARAM)hItem,
- MAKELPARAM(0, db_get_b(hContact, ModuleName, "SweepHistory", 0)));
+ MAKELPARAM(0, db_get_b(hContact, ModuleName, "SweepHistory", 0)));
}
-}//ShowAllContactIcons
+}
void LoadSettings(HWND hwndDlg)
{
- int i; CLCINFOITEM cii = {0}; HWND hwndList = GetDlgItem(hwndDlg, IDC_LIST);
+ int i;
+ HWND hwndList = GetDlgItem(hwndDlg, IDC_LIST);
+ CLCINFOITEM cii = { 0 };
cii.cbSize = sizeof(cii);
cii.flags = CLCIIF_GROUPFONT;
@@ -118,15 +118,13 @@ void LoadSettings(HWND hwndDlg) SendDlgItemMessage(hwndDlg, IDC_SSOLDER, CB_RESETCONTENT, 0, 0);
SendDlgItemMessage(hwndDlg, IDC_SSKEEP, CB_RESETCONTENT, 0, 0);
- for (i = 0; i < SIZEOF(time_stamp_strings); i++)
- {
+ for (i = 0; i < SIZEOF(time_stamp_strings); i++) {
TCHAR* ptszTimeStr = (TCHAR*)CallService(MS_LANGPACK_PCHARTOTCHAR, 0, (LPARAM)time_stamp_strings[i]);
SendDlgItemMessage(hwndDlg, IDC_SSOLDER, CB_ADDSTRING, 0, (LPARAM)ptszTimeStr);
mir_free(ptszTimeStr);
}
- for (i = 0; i < SIZEOF(keep_strings); i++)
- {
+ for (i = 0; i < SIZEOF(keep_strings); i++) {
TCHAR* ptszTimeStr = (TCHAR*)CallService(MS_LANGPACK_PCHARTOTCHAR, 0, (LPARAM)keep_strings[i]);
SendDlgItemMessage(hwndDlg, IDC_SSKEEP, CB_ADDSTRING, 0, (LPARAM)ptszTimeStr);
mir_free(ptszTimeStr);
@@ -143,7 +141,6 @@ void LoadSettings(HWND hwndDlg) void SaveSettings(HWND hwndDlg)
{
- int st, i;
HWND hwndList = GetDlgItem(hwndDlg, IDC_LIST);
db_set_b(NULL, ModuleName, "StartupShutdownOlder", (BYTE)SendDlgItemMessage(hwndDlg, IDC_SSOLDER, CB_GETCURSEL, 0, 0));
@@ -152,53 +149,54 @@ void SaveSettings(HWND hwndDlg) db_set_b(NULL, ModuleName, "SweepOnClose", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_SWEEPONCLOSE));
db_set_b(NULL, ModuleName, "ChangeInMW", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_HISTMW));
- StatusIconData sid = { sizeof(sid) };
- sid.szModule = ModuleName;
-
db_set_b(NULL, ModuleName, "SweepHistory",
- (BYTE)SendMessage(hwndList, CLM_GETEXTRAIMAGE, (WPARAM)hAllContacts, 0));
+ (BYTE)SendMessage(hwndList, CLM_GETEXTRAIMAGE, (WPARAM)hAllContacts, 0));
db_set_b(NULL, ModuleName, "SweepSHistory",
- (BYTE)SendMessage(hwndList, CLM_GETEXTRAIMAGE, (WPARAM)hSystemHistory, 0));
+ (BYTE)SendMessage(hwndList, CLM_GETEXTRAIMAGE, (WPARAM)hSystemHistory, 0));
for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
HANDLE hItem = (HANDLE)SendMessage(hwndList, CLM_FINDCONTACT, hContact, 0);
- st = SendMessage(hwndList, CLM_GETEXTRAIMAGE, (WPARAM)hItem, 0);
- if ( st != 0 ) db_set_b(hContact, ModuleName, "SweepHistory", (BYTE)st);
- else db_unset(hContact, ModuleName, "SweepHistory");
-
- // set per-contact icons in status bar
- for(i = 0; i < 4; i++) {
- sid.dwId = i;
- sid.flags = (st == i) ? 0 : MBF_HIDDEN;
- Srmm_ModifyIcon(hContact, &sid);
- }
+ int st = SendMessage(hwndList, CLM_GETEXTRAIMAGE, (WPARAM)hItem, 0);
+ if (st != 0)
+ db_set_b(hContact, ModuleName, "SweepHistory", (BYTE)st);
+ else
+ db_unset(hContact, ModuleName, "SweepHistory");
}
+ for (int i = 0; i < g_hWindows.getCount(); i++)
+ SetSrmmIcon(MCONTACT(g_hWindows[i]));
+
// set tooltips
- st = db_get_b(NULL, ModuleName, "SweepHistory", 0);
+ int st = db_get_b(NULL, ModuleName, "SweepHistory", 0);
+ StatusIconData sid = { 0 };
+ sid.cbSize = sizeof(sid);
+ sid.szModule = ModuleName;
sid.dwId = 0;
- if (st == 0) sid.szTooltip = LPGEN("Keep all events");
+ sid.hIcon = LoadIconEx("actG");
+ if (st == 0) sid.szTooltip = LPGEN("Keep all events");
else if (st == 1) sid.szTooltip = LPGEN(time_stamp_strings[db_get_b(NULL, ModuleName, "StartupShutdownOlder", 0)]);
else if (st == 2) sid.szTooltip = LPGEN(keep_strings[db_get_b(NULL, ModuleName, "StartupShutdownKeep", 0)]);
else if (st == 3) sid.szTooltip = LPGEN("Delete all events");
Srmm_ModifyIcon(NULL, &sid);
sid.dwId = 1;
+ sid.hIcon = LoadIconEx("act1");
sid.szTooltip = time_stamp_strings[db_get_b(NULL, ModuleName, "StartupShutdownOlder", 0)];
Srmm_ModifyIcon(NULL, &sid);
sid.dwId = 2;
+ sid.hIcon = LoadIconEx("act2");
sid.szTooltip = keep_strings[db_get_b(NULL, ModuleName, "StartupShutdownKeep", 0)];
Srmm_ModifyIcon(NULL, &sid);
}
INT_PTR CALLBACK DlgProcHSOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
- switch (msg)
- {
+ switch (msg) {
case WM_INITDIALOG:
+ TranslateDialogDefault(hwndDlg);
{
HIMAGELIST hIml = ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), ILC_MASK | ILC_COLOR32, 2, 2);
@@ -219,20 +217,15 @@ INT_PTR CALLBACK DlgProcHSOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa SendDlgItemMessage(hwndDlg, IDC_LIST, CLM_SETEXTRAIMAGELIST, 0, (LPARAM)hIml);
SendDlgItemMessage(hwndDlg, IDC_LIST, CLM_SETEXTRACOLUMNS, 1, 0);
-
- TranslateDialogDefault(hwndDlg);
- LoadSettings(hwndDlg);
}
+ LoadSettings(hwndDlg);
return TRUE;
case WM_DESTROY:
- {
- HIMAGELIST hIml = (HIMAGELIST)SendDlgItemMessage(hwndDlg, IDC_LIST, CLM_GETEXTRAIMAGELIST, 0, 0);
- ImageList_Destroy(hIml);
- ReleaseIconEx("act1");
- ReleaseIconEx("act2");
- ReleaseIconEx("actDel");
- }
+ ImageList_Destroy((HIMAGELIST)SendDlgItemMessage(hwndDlg, IDC_LIST, CLM_GETEXTRAIMAGELIST, 0, 0));
+ ReleaseIconEx("act1");
+ ReleaseIconEx("act2");
+ ReleaseIconEx("actDel");
break;
case WM_COMMAND:
@@ -240,46 +233,38 @@ INT_PTR CALLBACK DlgProcHSOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa return TRUE;
case WM_NOTIFY:
- {
- NMCLISTCONTROL* nmc = (NMCLISTCONTROL*)lParam;
- if ( nmc->hdr.idFrom == 0 && nmc->hdr.code == (unsigned)PSN_APPLY )
- {
- SaveSettings(hwndDlg);
- }
- else if (nmc->hdr.idFrom == IDC_LIST)
- {
- switch (nmc->hdr.code)
- {
- case CLN_NEWCONTACT:
- case CLN_LISTREBUILT:
- ShowAllContactIcons(nmc->hdr.hwndFrom);
+ NMCLISTCONTROL *nmc = (NMCLISTCONTROL*)lParam;
+ if (nmc->hdr.idFrom == 0 && nmc->hdr.code == (unsigned)PSN_APPLY)
+ SaveSettings(hwndDlg);
+ else if (nmc->hdr.idFrom == IDC_LIST) {
+ switch (nmc->hdr.code) {
+ case CLN_NEWCONTACT:
+ case CLN_LISTREBUILT:
+ ShowAllContactIcons(nmc->hdr.hwndFrom);
+ break;
+
+ case NM_CLICK:
+ HANDLE hItem; DWORD hitFlags; int iImage;
+
+ if (nmc->iColumn == -1)
break;
- case NM_CLICK:
- {
- HANDLE hItem; DWORD hitFlags; int iImage;
-
- if ( nmc->iColumn == -1 )
- break;
-
- // Find clicked item
- hItem = (HANDLE)SendMessage(nmc->hdr.hwndFrom, CLM_HITTEST, (WPARAM)&hitFlags, MAKELPARAM(nmc->pt.x,nmc->pt.y));
- // Nothing was clicked
- if (hItem == NULL || !(IsHContactContact(hItem) || IsHContactInfo(hItem)))
- break;
+ // Find clicked item
+ hItem = (HANDLE)SendMessage(nmc->hdr.hwndFrom, CLM_HITTEST, (WPARAM)&hitFlags, MAKELPARAM(nmc->pt.x, nmc->pt.y));
+ // Nothing was clicked
+ if (hItem == NULL || !(IsHContactContact(hItem) || IsHContactInfo(hItem)))
+ break;
- // It was not our extended icon
- if (!(hitFlags & CLCHT_ONITEMEXTRA))
- break;
+ // It was not our extended icon
+ if (!(hitFlags & CLCHT_ONITEMEXTRA))
+ break;
- iImage = SendMessage(nmc->hdr.hwndFrom, CLM_GETEXTRAIMAGE, (WPARAM)hItem, MAKELPARAM(nmc->iColumn, 0));
- SendMessage(nmc->hdr.hwndFrom, CLM_SETEXTRAIMAGE, (WPARAM)hItem, MAKELPARAM(nmc->iColumn, (iImage + 1) % 4));
+ iImage = SendMessage(nmc->hdr.hwndFrom, CLM_GETEXTRAIMAGE, (WPARAM)hItem, MAKELPARAM(nmc->iColumn, 0));
+ SendMessage(nmc->hdr.hwndFrom, CLM_SETEXTRAIMAGE, (WPARAM)hItem, MAKELPARAM(nmc->iColumn, (iImage + 1) % 4));
- // Activate Apply button
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- }
- break;
- }
+ // Activate Apply button
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ break;
}
}
break;
@@ -287,7 +272,7 @@ INT_PTR CALLBACK DlgProcHSOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa return FALSE;
}
-int HSOptInitialise(WPARAM wParam,LPARAM lParam)
+int HSOptInitialise(WPARAM wParam, LPARAM lParam)
{
OPTIONSDIALOGPAGE odp = { sizeof(odp) };
odp.hInstance = hInst;
diff --git a/plugins/HistorySweeperLight/src/version.h b/plugins/HistorySweeperLight/src/version.h index 0230fa1580..b3bc4cb584 100644 --- a/plugins/HistorySweeperLight/src/version.h +++ b/plugins/HistorySweeperLight/src/version.h @@ -1,14 +1,14 @@ #define __MAJOR_VERSION 0
-#define __MINOR_VERSION 0
-#define __RELEASE_NUM 0
-#define __BUILD_NUM 7
+#define __MINOR_VERSION 1
+#define __RELEASE_NUM 0
+#define __BUILD_NUM 1
#include <stdver.h>
#define __PLUGIN_NAME "History sweeper light"
#define __FILENAME "HistorySweeperLight.dll"
-#define __DESCRIPTION "This plugin can sweep system history, history from all contacts or only from chosen; also it may sweep history older than certain time; and may do it at Miranda NG startup/shutdown."
-#define __AUTHOR "Sergey V. Gershovich a.k.a. Jazzy$, Boris Krasnovskiy, tico-tico"
+#define __DESCRIPTION "This plugin can sweep system history, history from all contacts or only from chosen; also it may sweep history older than certain time; and may do it at Miranda NG startup/shutdown."
+#define __AUTHOR "Sergey V. Gershovich a.k.a. Jazzy$, Boris Krasnovskiy, tico-tico"
#define __AUTHOREMAIL ""
-#define __AUTHORWEB "http://miranda-ng.org/p/HistorySweeperLight/"
-#define __COPYRIGHT "© 2002-2003 Sergey V. Gershovich a.k.a. Jazzy$, 2006-2009 Boris Krasnovskiy, 2010-2011 tico-tico"
+#define __AUTHORWEB "http://miranda-ng.org/p/HistorySweeperLight/"
+#define __COPYRIGHT "© 2002-2003 Sergey V. Gershovich a.k.a. Jazzy$, 2006-2009 Boris Krasnovskiy, 2010-2011 tico-tico"
|