From 18e0b1e1b7e216e13c58d863510af4a25df1fee1 Mon Sep 17 00:00:00 2001 From: Vadim Dashevskiy Date: Mon, 23 Jul 2012 09:46:45 +0000 Subject: HistorySweeperLight, MyDetails, NewEventNotify: changed folder structure git-svn-id: http://svn.miranda-ng.org/main/trunk@1112 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/HistorySweeperLight/act1.ico | Bin 1150 -> 0 bytes plugins/HistorySweeperLight/act2.ico | Bin 1150 -> 0 bytes plugins/HistorySweeperLight/actDel.ico | Bin 1150 -> 0 bytes plugins/HistorySweeperLight/actG.ico | Bin 1150 -> 0 bytes .../docs/historysweeperlight-translation.txt | 14 + .../historysweeperlight-translation.txt | 14 - .../HistorySweeperLight/historysweeperlight.cpp | 248 --------------- plugins/HistorySweeperLight/historysweeperlight.h | 71 ----- plugins/HistorySweeperLight/historysweeperlight.rc | 83 ----- .../historysweeperlight_10.vcxproj | 26 +- .../historysweeperlight_10.vcxproj.filters | 14 +- plugins/HistorySweeperLight/main.cpp | 179 ----------- plugins/HistorySweeperLight/options.cpp | 354 --------------------- plugins/HistorySweeperLight/res/act1.ico | Bin 0 -> 1150 bytes plugins/HistorySweeperLight/res/act2.ico | Bin 0 -> 1150 bytes plugins/HistorySweeperLight/res/actDel.ico | Bin 0 -> 1150 bytes plugins/HistorySweeperLight/res/actG.ico | Bin 0 -> 1150 bytes .../HistorySweeperLight/res/historysweeperlight.rc | 83 +++++ plugins/HistorySweeperLight/resource.h | 18 -- .../src/historysweeperlight.cpp | 248 +++++++++++++++ .../HistorySweeperLight/src/historysweeperlight.h | 71 +++++ plugins/HistorySweeperLight/src/main.cpp | 179 +++++++++++ plugins/HistorySweeperLight/src/options.cpp | 354 +++++++++++++++++++++ plugins/HistorySweeperLight/src/resource.h | 18 ++ plugins/HistorySweeperLight/src/version.h | 23 ++ plugins/HistorySweeperLight/version.h | 23 -- 26 files changed, 1008 insertions(+), 1012 deletions(-) delete mode 100644 plugins/HistorySweeperLight/act1.ico delete mode 100644 plugins/HistorySweeperLight/act2.ico delete mode 100644 plugins/HistorySweeperLight/actDel.ico delete mode 100644 plugins/HistorySweeperLight/actG.ico create mode 100644 plugins/HistorySweeperLight/docs/historysweeperlight-translation.txt delete mode 100644 plugins/HistorySweeperLight/historysweeperlight-translation.txt delete mode 100644 plugins/HistorySweeperLight/historysweeperlight.cpp delete mode 100644 plugins/HistorySweeperLight/historysweeperlight.h delete mode 100644 plugins/HistorySweeperLight/historysweeperlight.rc delete mode 100644 plugins/HistorySweeperLight/main.cpp delete mode 100644 plugins/HistorySweeperLight/options.cpp create mode 100644 plugins/HistorySweeperLight/res/act1.ico create mode 100644 plugins/HistorySweeperLight/res/act2.ico create mode 100644 plugins/HistorySweeperLight/res/actDel.ico create mode 100644 plugins/HistorySweeperLight/res/actG.ico create mode 100644 plugins/HistorySweeperLight/res/historysweeperlight.rc delete mode 100644 plugins/HistorySweeperLight/resource.h create mode 100644 plugins/HistorySweeperLight/src/historysweeperlight.cpp create mode 100644 plugins/HistorySweeperLight/src/historysweeperlight.h create mode 100644 plugins/HistorySweeperLight/src/main.cpp create mode 100644 plugins/HistorySweeperLight/src/options.cpp create mode 100644 plugins/HistorySweeperLight/src/resource.h create mode 100644 plugins/HistorySweeperLight/src/version.h delete mode 100644 plugins/HistorySweeperLight/version.h (limited to 'plugins/HistorySweeperLight') diff --git a/plugins/HistorySweeperLight/act1.ico b/plugins/HistorySweeperLight/act1.ico deleted file mode 100644 index 0557c177a1..0000000000 Binary files a/plugins/HistorySweeperLight/act1.ico and /dev/null differ diff --git a/plugins/HistorySweeperLight/act2.ico b/plugins/HistorySweeperLight/act2.ico deleted file mode 100644 index 957572de2b..0000000000 Binary files a/plugins/HistorySweeperLight/act2.ico and /dev/null differ diff --git a/plugins/HistorySweeperLight/actDel.ico b/plugins/HistorySweeperLight/actDel.ico deleted file mode 100644 index 748ab4b65e..0000000000 Binary files a/plugins/HistorySweeperLight/actDel.ico and /dev/null differ diff --git a/plugins/HistorySweeperLight/actG.ico b/plugins/HistorySweeperLight/actG.ico deleted file mode 100644 index 1273d332ae..0000000000 Binary files a/plugins/HistorySweeperLight/actG.ico and /dev/null differ diff --git a/plugins/HistorySweeperLight/docs/historysweeperlight-translation.txt b/plugins/HistorySweeperLight/docs/historysweeperlight-translation.txt new file mode 100644 index 0000000000..5601d12f3b --- /dev/null +++ b/plugins/HistorySweeperLight/docs/historysweeperlight-translation.txt @@ -0,0 +1,14 @@ +; Common strings that belong to many files +;[Delete all events] +;[Keep all events] + +; ../../plugins/HistorySweeperLight/historysweeperlight.rc +;[Action 1] +;[Action 2] +;[History Sweeper Light] +;[Sweep history for this contacts:] + +; ../../plugins/HistorySweeperLight/options.cpp +;[*** Defaut Action ***] +;[*** System History ***] +;[History] diff --git a/plugins/HistorySweeperLight/historysweeperlight-translation.txt b/plugins/HistorySweeperLight/historysweeperlight-translation.txt deleted file mode 100644 index 5601d12f3b..0000000000 --- a/plugins/HistorySweeperLight/historysweeperlight-translation.txt +++ /dev/null @@ -1,14 +0,0 @@ -; Common strings that belong to many files -;[Delete all events] -;[Keep all events] - -; ../../plugins/HistorySweeperLight/historysweeperlight.rc -;[Action 1] -;[Action 2] -;[History Sweeper Light] -;[Sweep history for this contacts:] - -; ../../plugins/HistorySweeperLight/options.cpp -;[*** Defaut Action ***] -;[*** System History ***] -;[History] diff --git a/plugins/HistorySweeperLight/historysweeperlight.cpp b/plugins/HistorySweeperLight/historysweeperlight.cpp deleted file mode 100644 index 50e37ddc34..0000000000 --- a/plugins/HistorySweeperLight/historysweeperlight.cpp +++ /dev/null @@ -1,248 +0,0 @@ -/* -Miranda IM History Sweeper Light plugin -Copyright (C) 2002-2003 Sergey V. Gershovich -Copyright (C) 2006-2009 Boris Krasnovskiy -Copyright (C) 2010, 2011 tico-tico - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "historysweeperlight.h" - -typedef struct -{ - time_t time; - int keep; -} CriteriaStruct; - -// 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; - } - return tim; -} - -// 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; - } -} - -typedef struct -{ - HANDLE hDBEvent; - DWORD CRC32; - DWORD Timestamp; -} BEventData; - -static int CompareBookmarks( const void* p1, const void* p2 ) -{ - return (BYTE*)((BEventData*)p1)->hDBEvent - (BYTE*)((BEventData*)p2)->hDBEvent; -} - -static void GetBookmarks(HANDLE hContact, BEventData** books, size_t* bookcnt ) -{ - DBVARIANT dbv; - DBCONTACTGETSETTING cgs; - - *books = NULL; - *bookcnt = 0; - - cgs.szModule = "HistoryPlusPlus"; - cgs.szSetting = "Bookmarks"; - cgs.pValue = &dbv; - if (CallService(MS_DB_CONTACT_GETSETTING, (WPARAM)hContact, (LPARAM)&cgs) == 0) - { - if (dbv.cpbVal > 2 && *(WORD*)dbv.pbVal >= sizeof(BEventData)) - { - size_t recSize = *(WORD*)dbv.pbVal; - size_t numb = (dbv.cpbVal - sizeof(WORD)) / recSize; - - BEventData* tbooks = (BEventData*)mir_alloc(sizeof(BEventData)*numb); - size_t tbookcnt = 0; - - size_t i; - BYTE* evs = dbv.pbVal + sizeof(WORD); - - for (i=0; i --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); - } - } - - // find next event - hDBEventNext = (HANDLE)CallService(MS_DB_EVENT_FINDNEXT, (WPARAM)hDBEvent, 0); - - if (doDelete) CallService(MS_DB_EVENT_DELETE, (WPARAM)hContact, (LPARAM)hDBEvent); - - hDBEvent = hDBEventNext; - } // while (hDBEvent != NULL) - - mir_free(books); - - // 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)); - } // if (eventsCnt != 0) -} - -// shutdown action -void ShutdownAction(void) -{ - CriteriaStruct Criteria; - HANDLE hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); - - Criteria.keep = KeepCriteria(DBGetContactSettingByte(NULL, ModuleName, "StartupShutdownKeep", 0)); - Criteria.time = BuildCriteria(DBGetContactSettingByte(NULL, ModuleName, "StartupShutdownOlder", 0)); - - SweepHistoryFromContact(NULL, Criteria, FALSE); // sweep system history, keepunread==0 - - while ( hContact != NULL ) - { - SweepHistoryFromContact(hContact, Criteria, TRUE); // sweep contact history, keepunread==1 - - hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM)hContact, 0); // go to next contact - } -} - -int OnWindowEvent(WPARAM wParam, LPARAM lParam) -{ - MessageWindowEventData* msgEvData = (MessageWindowEventData*)lParam; - - if (msgEvData->uType == MSG_WINDOW_EVT_CLOSE && DBGetContactSettingByte(NULL, ModuleName, "SweepOnClose", 0)) - { - CriteriaStruct Criteria; - - Criteria.keep = KeepCriteria(DBGetContactSettingByte(NULL, ModuleName, "StartupShutdownKeep", 0)); - Criteria.time = BuildCriteria(DBGetContactSettingByte(NULL, ModuleName, "StartupShutdownOlder", 0)); - - SweepHistoryFromContact(msgEvData->hContact, Criteria, TRUE); - } - - return 0; -} \ No newline at end of file diff --git a/plugins/HistorySweeperLight/historysweeperlight.h b/plugins/HistorySweeperLight/historysweeperlight.h deleted file mode 100644 index c7fbeaeb25..0000000000 --- a/plugins/HistorySweeperLight/historysweeperlight.h +++ /dev/null @@ -1,71 +0,0 @@ -/* -Miranda IM History Sweeper Light plugin -Copyright (C) 2002-2003 Sergey V. Gershovich -Copyright (C) 2006-2009 Boris Krasnovskiy -Copyright (C) 2010, 2011 tico-tico - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ -#ifndef __HISTORYSWEEPERLIGHT_H__ -#define __HISTORYSWEEPERLIGHT_H__ - -#define MIRANDA_VER 0x0A00 - -#if !defined( _WIN64 ) - #define _USE_32BIT_TIME_T -#endif - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "resource.h" - -// Plugin name -#define ModuleName "History Sweeper Light" - -// Plugin UUID for New plugin loader -// req. 0.7.18+ core -// {1D9BF74A-44A8-4b3f-A6E5-73069D3A8979} -#define MIID_HISTORYSWEEPERLIGHT { 0x1d9bf74a, 0x44a8, 0x4b3f, { 0xa6, 0xe5, 0x73, 0x6, 0x9d, 0x3a, 0x89, 0x79 } } - -// main.c -extern HINSTANCE hInst; - -// options.c -extern const char* time_stamp_strings[]; -extern const char* keep_strings[]; -int HSOptInitialise(WPARAM wParam, LPARAM lParam); -void InitIcons(void); -void ReleaseIconEx(const char* name); -HICON LoadIconEx(const char* name); -HANDLE GetIconHandle(const char* name); - -// historysweeper.c -void ShutdownAction(void); -int OnWindowEvent(WPARAM wParam, LPARAM lParam); - -#endif diff --git a/plugins/HistorySweeperLight/historysweeperlight.rc b/plugins/HistorySweeperLight/historysweeperlight.rc deleted file mode 100644 index 31129587ca..0000000000 --- a/plugins/HistorySweeperLight/historysweeperlight.rc +++ /dev/null @@ -1,83 +0,0 @@ -// Generated by ResEdit 1.4.13 -// Copyright (C) 2006-2010 -// http://www.resedit.net - -#include -#include "resource.h" -#include "version.h" - - - -// -// Dialog resources -// -LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US -IDD_OPT_HISTORYSWEEPER DIALOGEX 0, 0, 313, 240 -STYLE DS_SHELLFONT | WS_VISIBLE | WS_CHILDWINDOW -EXSTYLE WS_EX_CONTROLPARENT -FONT 8, "MS Shell Dlg", 0, 0, 1 -{ - GROUPBOX "History Sweeper Light", IDC_STATIC, 0, 0, 313, 240 - LTEXT "Sweep history for this contacts:", IDC_STATIC, 8, 12, 296, 10 - CONTROL "", IDC_LIST, "CListControl", 0x500101D2, 8, 22, 297, 139, 0x00000200 - ICON "", IDC_ACT1, 8, 164, 21, 20, SS_ICON - LTEXT "Action 1", IDC_STATIC, 22, 164, 118, 10 - COMBOBOX IDC_SSOLDER, 8, 177, 140, 70, WS_TABSTOP | WS_VSCROLL | WS_TABSTOP | CBS_DROPDOWNLIST - ICON "", IDC_ACT2, 165, 164, 21, 20, SS_ICON - LTEXT "Action 2", IDC_STATIC, 179, 164, 118, 10 - COMBOBOX IDC_SSKEEP, 165, 177, 140, 70, WS_TABSTOP | WS_VSCROLL | WS_TABSTOP | CBS_DROPDOWNLIST - AUTOCHECKBOX "Sweep on closing message window", IDC_SWEEPONCLOSE, 8, 197, 294, 10 - AUTOCHECKBOX "Clicking on the icon in the status bar will change settings", IDC_HISTMW, 8, 211, 294, 10 - AUTOCHECKBOX "Use UNSAFE mode (sweep fastest as possible, but dangerous for DB)", IDC_UNSAFEMODE, 8, 225, 294, 10 -} - - - -// -// Icon resources -// -LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US -IDI_ACT1 ICON "act1.ico" - - -LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US -IDI_ACT2 ICON "act2.ico" - - -LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US -IDI_ACTG ICON "actG.ico" - -LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US -IDI_ACTDEL ICON "actDel.ico" - -// -// Version Information resources -// -LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US -VS_VERSION_INFO VERSIONINFO - FILEVERSION __FILEVERSION_STRING - PRODUCTVERSION __FILEVERSION_STRING - FILEOS VOS__WINDOWS32 - FILETYPE VFT_DLL - FILESUBTYPE VFT2_UNKNOWN - FILEFLAGSMASK 0x00000017 - FILEFLAGS 0x00000000 -{ - BLOCK "StringFileInfo" - { - BLOCK "040904b0" - { - VALUE "FileDescription", "History Sweeper Light Miranda IM Plugin" - VALUE "FileVersion", __VERSION_STRING - VALUE "InternalName", "History Sweeper Light" - VALUE "LegalCopyright", "Copyright (C) Boris Krasnovskiy 2006-2009, (C) 2010, 2011 tico-tico" - VALUE "OriginalFilename", "historysweeperlight.dll" - VALUE "ProductName", "History Sweeper Light Miranda IM Plugin" - VALUE "ProductVersion", __VERSION_STRING - } - } - BLOCK "VarFileInfo" - { - VALUE "Translation", 0x0409, 0x04B0 - } -} diff --git a/plugins/HistorySweeperLight/historysweeperlight_10.vcxproj b/plugins/HistorySweeperLight/historysweeperlight_10.vcxproj index 8e14d01bf3..4025de2343 100644 --- a/plugins/HistorySweeperLight/historysweeperlight_10.vcxproj +++ b/plugins/HistorySweeperLight/historysweeperlight_10.vcxproj @@ -72,13 +72,12 @@ Disabled - WIN32;_DEBUG;_WINDOWS;_USRDLL;HISTORYSWEEPERLIGHT_EXPORTS;%(PreprocessorDefinitions) + WIN32;_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) true EnableFastChecks MultiThreadedDebugDLL Level3 EditAndContinue - 4996;%(DisableSpecificWarnings) ..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) @@ -97,11 +96,10 @@ Disabled - WIN64;_DEBUG;_WINDOWS;_USRDLL;HISTORYSWEEPERLIGHT_EXPORTS;%(PreprocessorDefinitions) + WIN64;_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) EnableFastChecks MultiThreadedDebugDLL Level3 - 4996;%(DisableSpecificWarnings) ..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) @@ -123,11 +121,10 @@ OnlyExplicitInline false Size - WIN32;NDEBUG;_WINDOWS;_USRDLL;HISTORYSWEEPERLIGHT_EXPORTS;%(PreprocessorDefinitions) + WIN32;NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) true true Level3 - 4996;%(DisableSpecificWarnings) ..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) @@ -151,11 +148,10 @@ OnlyExplicitInline false Size - WIN64;NDEBUG;_WINDOWS;_USRDLL;HISTORYSWEEPERLIGHT_EXPORTS;%(PreprocessorDefinitions) + WIN64;NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) true true Level3 - 4996;%(DisableSpecificWarnings) ..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) @@ -174,17 +170,17 @@ - - - + + + - - - + + + - + diff --git a/plugins/HistorySweeperLight/historysweeperlight_10.vcxproj.filters b/plugins/HistorySweeperLight/historysweeperlight_10.vcxproj.filters index 215f46c7f5..8e33f1e2f8 100644 --- a/plugins/HistorySweeperLight/historysweeperlight_10.vcxproj.filters +++ b/plugins/HistorySweeperLight/historysweeperlight_10.vcxproj.filters @@ -15,29 +15,29 @@ - + Source Files - + Source Files - + Source Files - + Header Files - + Header Files - + Header Files - + Resource Files diff --git a/plugins/HistorySweeperLight/main.cpp b/plugins/HistorySweeperLight/main.cpp deleted file mode 100644 index c6f8b427ac..0000000000 --- a/plugins/HistorySweeperLight/main.cpp +++ /dev/null @@ -1,179 +0,0 @@ -/* -Miranda IM History Sweeper Light plugin -Copyright (C) 2002-2003 Sergey V. Gershovich -Copyright (C) 2006-2009 Boris Krasnovskiy -Copyright (C) 2010, 2011 tico-tico - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "historysweeperlight.h" -#include "version.h" - -HINSTANCE hInst; - -static HANDLE hHooks[5]; -int hLangpack; - -static PLUGININFOEX pluginInfoEx = -{ - // about plugin - sizeof(PLUGININFOEX), - "History Sweeper Light", - __VERSION_DWORD, - "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 IM startup/shutdown.", - "Sergey V. Gershovich a.k.a. Jazzy$, Boris Krasnovskiy, tico-tico", - "", - "© 2002-2003 Sergey V. Gershovich a.k.a. Jazzy$, 2006-2009 Boris Krasnovskiy, 2010, 2011 tico-tico", - "", - UNICODE_AWARE, - MIID_HISTORYSWEEPERLIGHT -}; - -BOOL WINAPI DllMain(HINSTANCE hinstDLL,DWORD fdwReason,LPVOID lpvReserved) -{ - hInst=hinstDLL; - return TRUE; -} - -int OnIconPressed(WPARAM wParam, LPARAM lParam) -{ - StatusIconClickData *sicd = (StatusIconClickData *)lParam; - - if ( !(sicd->flags & MBCF_RIGHTBUTTON) && !lstrcmpA(sicd->szModule, ModuleName) - && DBGetContactSettingByte(NULL, ModuleName, "ChangeInMW", 0)) - { - int nh = sicd->dwId; HANDLE hContact = (HANDLE)wParam; StatusIconData sid = {0}; - - sid.cbSize = sizeof(sid); - sid.szModule = ModuleName; - sid.dwId = nh; - sid.flags = MBF_HIDDEN; - CallService(MS_MSG_MODIFYICON, (WPARAM)hContact, (LPARAM)&sid); - - nh = (nh + 1) % 4; - DBWriteContactSettingByte((HANDLE)wParam, ModuleName, "SweepHistory", (BYTE)nh); - - sid.dwId = nh; - sid.flags = 0; - CallService(MS_MSG_MODIFYICON, (WPARAM)hContact, (LPARAM)&sid); - } - return 0; -} - - -int OnModulesLoaded(WPARAM wParam, LPARAM lParam) -{ - StatusIconData sid = {0}; - int i, sweep = DBGetContactSettingByte(NULL, ModuleName, "SweepHistory", 0); - HANDLE hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); - - sid.cbSize = sizeof(sid); - sid.szModule = ModuleName; - - sid.hIcon = LoadIconEx("actG"); - if (sweep == 0) - sid.szTooltip = Translate("Keep all events"); - else if (sweep == 1) - { - sid.szTooltip = Translate(time_stamp_strings[DBGetContactSettingByte(NULL, ModuleName, "StartupShutdownOlder", 0)]); - } - else if (sweep == 2) - { - sid.szTooltip = Translate(keep_strings[DBGetContactSettingByte(NULL, ModuleName, "StartupShutdownKeep", 0)]); - } - else if (sweep == 3) - { - sid.szTooltip = Translate("Delete all events"); - } - sid.flags = MBF_HIDDEN; - CallService(MS_MSG_ADDICON, 0, (LPARAM)&sid); - - sid.dwId = 1; - sid.hIcon = LoadIconEx("act1"); - sid.szTooltip = Translate(time_stamp_strings[DBGetContactSettingByte(NULL, ModuleName, "StartupShutdownOlder", 0)]); - sid.flags = MBF_HIDDEN; - CallService(MS_MSG_ADDICON, 0, (LPARAM)&sid); - - sid.dwId = 2; - sid.hIcon = LoadIconEx("act2"); - sid.szTooltip = Translate(keep_strings[DBGetContactSettingByte(NULL, ModuleName, "StartupShutdownKeep", 0)]); - sid.flags = MBF_HIDDEN; - CallService(MS_MSG_ADDICON, 0, (LPARAM)&sid); - - sid.dwId = 3; - sid.hIcon = LoadIconEx("actDel"); - sid.szTooltip = Translate("Delete all events"); - sid.flags = MBF_HIDDEN; - CallService(MS_MSG_ADDICON, 0, (LPARAM)&sid); - - // for new contacts - while ( hContact != NULL ) - { - ZeroMemory(&sid,sizeof(sid)); - - sweep = DBGetContactSettingByte(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; - CallService(MS_MSG_MODIFYICON, (WPARAM)hContact, (LPARAM)&sid); - } - - hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM)hContact, 0); - } - - hHooks[2] = HookEvent(ME_MSG_WINDOWEVENT, OnWindowEvent); - hHooks[3] = HookEvent(ME_MSG_ICONPRESSED, OnIconPressed); - - return 0; -} - -extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD mirandaVersion) -{ - return &pluginInfoEx; -} - -extern "C" __declspec(dllexport) int Load(void) -{ - - mir_getLP(&pluginInfoEx); - - hHooks[0] = HookEvent(ME_SYSTEM_MODULESLOADED, OnModulesLoaded); - hHooks[1] = HookEvent(ME_OPT_INITIALISE, HSOptInitialise); - - InitIcons(); - - return 0; -} - -extern "C" __declspec(dllexport) int Unload(void) -{ - int i; - - ShutdownAction(); - - for (i = 0; i < SIZEOF(hHooks); i++) - { - if (hHooks[i]) - UnhookEvent(hHooks[i]); - } - - return 0; -} \ No newline at end of file diff --git a/plugins/HistorySweeperLight/options.cpp b/plugins/HistorySweeperLight/options.cpp deleted file mode 100644 index 2963f8bb2b..0000000000 --- a/plugins/HistorySweeperLight/options.cpp +++ /dev/null @@ -1,354 +0,0 @@ -/* -Miranda IM History Sweeper Light plugin -Copyright (C) 2002-2003 Sergey V. Gershovich -Copyright (C) 2006-2009 Boris Krasnovskiy -Copyright (C) 2010, 2011 tico-tico - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "historysweeperlight.h" - -// Time Stamps strings -const char* time_stamp_strings[] = -{ - "Delete older than 1 day", - "Delete older than 3 days", - "Delete older than 7 days", - "Delete older than 2 weeks (14 days)", - "Delete older than 1 month (30 days)", - "Delete older than 3 months (90 days)", - "Delete older than 6 months (180 days)", - "Delete older than 1 year (365 days)" -}; - -const char* keep_strings[] = -{ - "Keep 1 last event", - "Keep 2 last events", - "Keep 5 last events", - "Keep 10 last events", - "Keep 20 last events", - "Keep 50 last events" -}; - -struct -{ - char* szDescr; - char* szName; - int defIconID; -} -static const iconList[] = -{ - { "Default Action", "actG", IDI_ACTG }, - { "Action 1", "act1", IDI_ACT1 }, - { "Action 2", "act2", IDI_ACT2 }, - { "Delete All", "actDel", IDI_ACTDEL } -}; - -static HANDLE hIconLibItem[SIZEOF(iconList)]; - -void InitIcons(void) -{ - TCHAR szFile[MAX_PATH]; - GetModuleFileName(hInst, szFile, SIZEOF(szFile)); - - SKINICONDESC sid = { 0 }; - sid.cbSize = sizeof(SKINICONDESC); - sid.ptszDefaultFile = szFile; - sid.cx = sid.cy = 16; - sid.pszSection = ModuleName; - sid.flags = SIDF_PATH_TCHAR; - - for (int i=0; i < SIZEOF(iconList); i++) { - char szSettingName[100]; - mir_snprintf(szSettingName, SIZEOF(szSettingName), "%s_%s", ModuleName, iconList[i].szName); - sid.pszName = szSettingName; - - sid.pszDescription = (char*)iconList[i].szDescr; - sid.iDefaultIndex = -iconList[i].defIconID; - hIconLibItem[i] = Skin_AddIcon(&sid); - } -} - -HICON LoadIconEx(const char* name) -{ - char szSettingName[100]; - mir_snprintf(szSettingName, sizeof(szSettingName), "%s_%s", ModuleName, name); - return (HICON)CallService(MS_SKIN2_GETICON, 0, (LPARAM)szSettingName); -} - -HANDLE GetIconHandle(const char* name) -{ - int i; - - for (i=0; i < SIZEOF(iconList); i++) - if (lstrcmpA(iconList[i].szName, name) == 0) - return hIconLibItem[i]; - - return NULL; -} - -void ReleaseIconEx(const char* name) -{ - char szSettingName[100]; - mir_snprintf(szSettingName, sizeof(szSettingName), "%s_%s", ModuleName, name); - CallService(MS_SKIN2_RELEASEICON, 0, (LPARAM)szSettingName); -} - -HANDLE hAllContacts, hSystemHistory; - -void ResetListOptions(HWND hwndList) -{ - int i; - - SendMessage(hwndList, CLM_SETBKBITMAP, 0, 0); - SendMessage(hwndList, CLM_SETBKCOLOR, GetSysColor(COLOR_WINDOW), 0); - SendMessage(hwndList, CLM_SETGREYOUTFLAGS, 0, 0); - SendMessage(hwndList, CLM_SETLEFTMARGIN, 4, 0); - SendMessage(hwndList, CLM_SETINDENT, 10, 0); - - for (i=0; i<=FONTID_MAX; i++) - SendMessage(hwndList, CLM_SETTEXTCOLOR, i, GetSysColor(COLOR_WINDOWTEXT)); -} - -static void ShowAllContactIcons(HWND hwndList) -{ - HANDLE hContact, hItem; - - SendMessage(hwndList, CLM_SETEXTRAIMAGE, (WPARAM)hAllContacts, - MAKELPARAM(0, DBGetContactSettingByte(NULL, ModuleName, "SweepHistory", 0))); - SendMessage(hwndList, CLM_SETEXTRAIMAGE, (WPARAM)hSystemHistory, - MAKELPARAM(0, DBGetContactSettingByte(NULL, ModuleName, "SweepSHistory", 0))); - - for (hContact=(HANDLE)CallService(MS_DB_CONTACT_FINDFIRST,0,0); hContact; - hContact=(HANDLE)CallService(MS_DB_CONTACT_FINDNEXT,(WPARAM)hContact,0)) - { - hItem = (HANDLE)SendMessage(hwndList, CLM_FINDCONTACT, (WPARAM)hContact, 0); - SendMessage(hwndList, CLM_SETEXTRAIMAGE, (WPARAM)hItem, - MAKELPARAM(0, DBGetContactSettingByte(hContact, ModuleName, "SweepHistory", 0))); - } -}//ShowAllContactIcons - -void LoadSettings(HWND hwndDlg) -{ - int i; CLCINFOITEM cii = {0}; HWND hwndList = GetDlgItem(hwndDlg, IDC_LIST); - - cii.cbSize = sizeof(cii); - cii.flags = CLCIIF_GROUPFONT; - - cii.pszText = TranslateT("*** Defaut Action ***"); - hAllContacts = (HANDLE)SendMessage(hwndList, CLM_ADDINFOITEM, 0, (LPARAM)&cii); - - cii.pszText = TranslateT("*** System History ***"); - hSystemHistory = (HANDLE)SendMessage(hwndList, CLM_ADDINFOITEM, 0, (LPARAM)&cii); - - ShowAllContactIcons(hwndList); - - 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++) - { - 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++) - { - TCHAR* ptszTimeStr = (TCHAR*)CallService(MS_LANGPACK_PCHARTOTCHAR, 0, (LPARAM)keep_strings[i]); - SendDlgItemMessage(hwndDlg, IDC_SSKEEP, CB_ADDSTRING, 0, (LPARAM)ptszTimeStr); - mir_free(ptszTimeStr); - } - - SendDlgItemMessage(hwndDlg, IDC_SSOLDER, CB_SETCURSEL, DBGetContactSettingByte(NULL, ModuleName, "StartupShutdownOlder", 0), 0); - SendDlgItemMessage(hwndDlg, IDC_SSKEEP, CB_SETCURSEL, DBGetContactSettingByte(NULL, ModuleName, "StartupShutdownKeep", 0), 0); - - CheckDlgButton(hwndDlg, IDC_UNSAFEMODE, DBGetContactSettingByte(NULL, ModuleName, "UnsafeMode", 0)); - CheckDlgButton(hwndDlg, IDC_SWEEPONCLOSE, DBGetContactSettingByte(NULL, ModuleName, "SweepOnClose", 0)); - CheckDlgButton(hwndDlg, IDC_HISTMW, DBGetContactSettingByte(NULL, ModuleName, "ChangeInMW", 0)); -}//LoadSettings - - -void SaveSettings(HWND hwndDlg) -{ - int st, i; StatusIconData sid = {0}; HANDLE hContact, hItem; HWND hwndList = GetDlgItem(hwndDlg, IDC_LIST); - - DBWriteContactSettingByte(NULL, ModuleName, "StartupShutdownOlder", (BYTE)SendDlgItemMessage(hwndDlg, IDC_SSOLDER, CB_GETCURSEL, 0, 0)); - DBWriteContactSettingByte(NULL, ModuleName, "StartupShutdownKeep", (BYTE)SendDlgItemMessage(hwndDlg, IDC_SSKEEP, CB_GETCURSEL, 0, 0)); - DBWriteContactSettingByte(NULL, ModuleName, "UnsafeMode", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_UNSAFEMODE)); - DBWriteContactSettingByte(NULL, ModuleName, "SweepOnClose", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_SWEEPONCLOSE)); - DBWriteContactSettingByte(NULL, ModuleName, "ChangeInMW", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_HISTMW)); - - sid.cbSize = sizeof(sid); - sid.szModule = ModuleName; - - DBWriteContactSettingByte(NULL, ModuleName, "SweepHistory", - (BYTE)SendMessage(hwndList, CLM_GETEXTRAIMAGE, (WPARAM)hAllContacts, 0)); - DBWriteContactSettingByte(NULL, ModuleName, "SweepSHistory", - (BYTE)SendMessage(hwndList, CLM_GETEXTRAIMAGE, (WPARAM)hSystemHistory, 0)); - - for (hContact=(HANDLE)CallService(MS_DB_CONTACT_FINDFIRST,0,0); hContact; - hContact=(HANDLE)CallService(MS_DB_CONTACT_FINDNEXT,(WPARAM)hContact,0)) - { - hItem = (HANDLE)SendMessage(hwndList, CLM_FINDCONTACT, (WPARAM)hContact, 0); - - st = SendMessage(hwndList, CLM_GETEXTRAIMAGE, (WPARAM)hItem, 0); - if ( st != 0 ) DBWriteContactSettingByte(hContact, ModuleName, "SweepHistory", (BYTE)st); - else DBDeleteContactSetting(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; - CallService(MS_MSG_MODIFYICON, (WPARAM)hContact, (LPARAM)&sid); - } - } - - // set tooltips - st = DBGetContactSettingByte(NULL, ModuleName, "SweepHistory", 0); - - sid.dwId = 0; - if (st == 0) sid.szTooltip = Translate("Keep all events"); - else if (st == 1) sid.szTooltip = Translate(time_stamp_strings[DBGetContactSettingByte(NULL, ModuleName, "StartupShutdownOlder", 0)]); - else if (st == 2) sid.szTooltip = Translate(keep_strings[DBGetContactSettingByte(NULL, ModuleName, "StartupShutdownKeep", 0)]); - else if (st == 3) sid.szTooltip = Translate("Delete all events"); - CallService(MS_MSG_MODIFYICON, 0, (LPARAM)&sid); - - sid.dwId = 1; - sid.szTooltip = Translate(time_stamp_strings[DBGetContactSettingByte(NULL, ModuleName, "StartupShutdownOlder", 0)]); - CallService(MS_MSG_MODIFYICON, 0, (LPARAM)&sid); - - sid.dwId = 2; - sid.szTooltip = Translate(keep_strings[DBGetContactSettingByte(NULL, ModuleName, "StartupShutdownKeep", 0)]); - CallService(MS_MSG_MODIFYICON, 0, (LPARAM)&sid); -}//SaveSettings - -INT_PTR CALLBACK DlgProcHSOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) -{ - switch (msg) - { - case WM_INITDIALOG: - { - HIMAGELIST hIml = ImageList_Create( GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), - ILC_MASK | (IsWinVerXPPlus() ? ILC_COLOR32 : ILC_COLOR16 ), 2, 2 ); - - HICON hIcon = LoadSkinnedIcon(SKINICON_OTHER_SMALLDOT); - ImageList_AddIcon(hIml, hIcon); - CallService(MS_SKIN2_RELEASEICON, (WPARAM)hIcon, 0); - - hIcon = LoadIconEx("act1"); - ImageList_AddIcon(hIml, hIcon); - SendDlgItemMessage(hwndDlg, IDC_ACT1, STM_SETICON, (WPARAM)hIcon, 0); - - hIcon = LoadIconEx("act2"); - ImageList_AddIcon(hIml, hIcon); - SendDlgItemMessage(hwndDlg, IDC_ACT2, STM_SETICON, (WPARAM)hIcon, 0); - - hIcon = LoadIconEx("actDel"); - ImageList_AddIcon(hIml, hIcon); - - SendDlgItemMessage(hwndDlg, IDC_LIST, CLM_SETEXTRAIMAGELIST, 0, (LPARAM)hIml); - SendDlgItemMessage(hwndDlg, IDC_LIST, CLM_SETEXTRACOLUMNS, 1, 0); - - TranslateDialogDefault(hwndDlg); - ResetListOptions(GetDlgItem(hwndDlg, IDC_LIST)); - 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"); - } - break; - - case WM_COMMAND: - SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); // Send message to activate "Apply" button - 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); - break; - - case CLN_OPTIONSCHANGED: - ResetListOptions(nmc->hdr.hwndFrom); - 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; - - // 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)); - - // Activate Apply button - SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); - } - break; - } - } - } - break; - } - return FALSE; -} - -int HSOptInitialise(WPARAM wParam,LPARAM lParam) -{ - OPTIONSDIALOGPAGE odp = {0}; - odp.cbSize = sizeof(odp); - odp.position = 0; - odp.hInstance = hInst; - odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_HISTORYSWEEPER); - odp.pszTitle = ModuleName; - odp.pszGroup = LPGEN("History"); - odp.pfnDlgProc = DlgProcHSOpts; - odp.flags = ODPF_BOLDGROUPS; - Options_AddPage(wParam, &odp); - - return 0; -} diff --git a/plugins/HistorySweeperLight/res/act1.ico b/plugins/HistorySweeperLight/res/act1.ico new file mode 100644 index 0000000000..0557c177a1 Binary files /dev/null and b/plugins/HistorySweeperLight/res/act1.ico differ diff --git a/plugins/HistorySweeperLight/res/act2.ico b/plugins/HistorySweeperLight/res/act2.ico new file mode 100644 index 0000000000..957572de2b Binary files /dev/null and b/plugins/HistorySweeperLight/res/act2.ico differ diff --git a/plugins/HistorySweeperLight/res/actDel.ico b/plugins/HistorySweeperLight/res/actDel.ico new file mode 100644 index 0000000000..748ab4b65e Binary files /dev/null and b/plugins/HistorySweeperLight/res/actDel.ico differ diff --git a/plugins/HistorySweeperLight/res/actG.ico b/plugins/HistorySweeperLight/res/actG.ico new file mode 100644 index 0000000000..1273d332ae Binary files /dev/null and b/plugins/HistorySweeperLight/res/actG.ico differ diff --git a/plugins/HistorySweeperLight/res/historysweeperlight.rc b/plugins/HistorySweeperLight/res/historysweeperlight.rc new file mode 100644 index 0000000000..e322d6468e --- /dev/null +++ b/plugins/HistorySweeperLight/res/historysweeperlight.rc @@ -0,0 +1,83 @@ +// Generated by ResEdit 1.4.13 +// Copyright (C) 2006-2010 +// http://www.resedit.net + +#include +#include "..\src\resource.h" +#include "..\src\version.h" + + + +// +// Dialog resources +// +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US +IDD_OPT_HISTORYSWEEPER DIALOGEX 0, 0, 313, 240 +STYLE DS_SHELLFONT | WS_VISIBLE | WS_CHILDWINDOW +EXSTYLE WS_EX_CONTROLPARENT +FONT 8, "MS Shell Dlg", 0, 0, 1 +{ + GROUPBOX "History Sweeper Light", IDC_STATIC, 0, 0, 313, 240 + LTEXT "Sweep history for this contacts:", IDC_STATIC, 8, 12, 296, 10 + CONTROL "", IDC_LIST, "CListControl", 0x500101D2, 8, 22, 297, 139, 0x00000200 + ICON "", IDC_ACT1, 8, 164, 21, 20, SS_ICON + LTEXT "Action 1", IDC_STATIC, 22, 164, 118, 10 + COMBOBOX IDC_SSOLDER, 8, 177, 140, 70, WS_TABSTOP | WS_VSCROLL | WS_TABSTOP | CBS_DROPDOWNLIST + ICON "", IDC_ACT2, 165, 164, 21, 20, SS_ICON + LTEXT "Action 2", IDC_STATIC, 179, 164, 118, 10 + COMBOBOX IDC_SSKEEP, 165, 177, 140, 70, WS_TABSTOP | WS_VSCROLL | WS_TABSTOP | CBS_DROPDOWNLIST + AUTOCHECKBOX "Sweep on closing message window", IDC_SWEEPONCLOSE, 8, 197, 294, 10 + AUTOCHECKBOX "Clicking on the icon in the status bar will change settings", IDC_HISTMW, 8, 211, 294, 10 + AUTOCHECKBOX "Use UNSAFE mode (sweep fastest as possible, but dangerous for DB)", IDC_UNSAFEMODE, 8, 225, 294, 10 +} + + + +// +// Icon resources +// +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US +IDI_ACT1 ICON "act1.ico" + + +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US +IDI_ACT2 ICON "act2.ico" + + +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US +IDI_ACTG ICON "actG.ico" + +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US +IDI_ACTDEL ICON "actDel.ico" + +// +// Version Information resources +// +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US +VS_VERSION_INFO VERSIONINFO + FILEVERSION __FILEVERSION_STRING + PRODUCTVERSION __FILEVERSION_STRING + FILEOS VOS__WINDOWS32 + FILETYPE VFT_DLL + FILESUBTYPE VFT2_UNKNOWN + FILEFLAGSMASK 0x00000017 + FILEFLAGS 0x00000000 +{ + BLOCK "StringFileInfo" + { + BLOCK "040904b0" + { + VALUE "FileDescription", "History Sweeper Light Miranda IM Plugin" + VALUE "FileVersion", __VERSION_STRING + VALUE "InternalName", "History Sweeper Light" + VALUE "LegalCopyright", "Copyright (C) Boris Krasnovskiy 2006-2009, (C) 2010, 2011 tico-tico" + VALUE "OriginalFilename", "historysweeperlight.dll" + VALUE "ProductName", "History Sweeper Light Miranda IM Plugin" + VALUE "ProductVersion", __VERSION_STRING + } + } + BLOCK "VarFileInfo" + { + VALUE "Translation", 0x0409, 0x04B0 + } +} diff --git a/plugins/HistorySweeperLight/resource.h b/plugins/HistorySweeperLight/resource.h deleted file mode 100644 index bfa91d1d4e..0000000000 --- a/plugins/HistorySweeperLight/resource.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef IDC_STATIC -#define IDC_STATIC (-1) -#endif - -#define IDD_OPT_HISTORYSWEEPER 101 -#define IDI_ACTG 102 -#define IDI_ACT1 103 -#define IDI_ACT2 104 -#define IDI_ACTDEL 105 -#define IDC_LIST 106 -#define IDC_SSOLDER 107 -#define IDC_UNSAFEMODE 108 -#define IDC_SWEEPONCLOSE 109 -#define IDC_SSKEEP 110 -#define IDC_HISTMW 111 -#define IDC_ACT1 112 -#define IDC_ACT2 113 - diff --git a/plugins/HistorySweeperLight/src/historysweeperlight.cpp b/plugins/HistorySweeperLight/src/historysweeperlight.cpp new file mode 100644 index 0000000000..50e37ddc34 --- /dev/null +++ b/plugins/HistorySweeperLight/src/historysweeperlight.cpp @@ -0,0 +1,248 @@ +/* +Miranda IM History Sweeper Light plugin +Copyright (C) 2002-2003 Sergey V. Gershovich +Copyright (C) 2006-2009 Boris Krasnovskiy +Copyright (C) 2010, 2011 tico-tico + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +#include "historysweeperlight.h" + +typedef struct +{ + time_t time; + int keep; +} CriteriaStruct; + +// 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; + } + return tim; +} + +// 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; + } +} + +typedef struct +{ + HANDLE hDBEvent; + DWORD CRC32; + DWORD Timestamp; +} BEventData; + +static int CompareBookmarks( const void* p1, const void* p2 ) +{ + return (BYTE*)((BEventData*)p1)->hDBEvent - (BYTE*)((BEventData*)p2)->hDBEvent; +} + +static void GetBookmarks(HANDLE hContact, BEventData** books, size_t* bookcnt ) +{ + DBVARIANT dbv; + DBCONTACTGETSETTING cgs; + + *books = NULL; + *bookcnt = 0; + + cgs.szModule = "HistoryPlusPlus"; + cgs.szSetting = "Bookmarks"; + cgs.pValue = &dbv; + if (CallService(MS_DB_CONTACT_GETSETTING, (WPARAM)hContact, (LPARAM)&cgs) == 0) + { + if (dbv.cpbVal > 2 && *(WORD*)dbv.pbVal >= sizeof(BEventData)) + { + size_t recSize = *(WORD*)dbv.pbVal; + size_t numb = (dbv.cpbVal - sizeof(WORD)) / recSize; + + BEventData* tbooks = (BEventData*)mir_alloc(sizeof(BEventData)*numb); + size_t tbookcnt = 0; + + size_t i; + BYTE* evs = dbv.pbVal + sizeof(WORD); + + for (i=0; i --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); + } + } + + // find next event + hDBEventNext = (HANDLE)CallService(MS_DB_EVENT_FINDNEXT, (WPARAM)hDBEvent, 0); + + if (doDelete) CallService(MS_DB_EVENT_DELETE, (WPARAM)hContact, (LPARAM)hDBEvent); + + hDBEvent = hDBEventNext; + } // while (hDBEvent != NULL) + + mir_free(books); + + // 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)); + } // if (eventsCnt != 0) +} + +// shutdown action +void ShutdownAction(void) +{ + CriteriaStruct Criteria; + HANDLE hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); + + Criteria.keep = KeepCriteria(DBGetContactSettingByte(NULL, ModuleName, "StartupShutdownKeep", 0)); + Criteria.time = BuildCriteria(DBGetContactSettingByte(NULL, ModuleName, "StartupShutdownOlder", 0)); + + SweepHistoryFromContact(NULL, Criteria, FALSE); // sweep system history, keepunread==0 + + while ( hContact != NULL ) + { + SweepHistoryFromContact(hContact, Criteria, TRUE); // sweep contact history, keepunread==1 + + hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM)hContact, 0); // go to next contact + } +} + +int OnWindowEvent(WPARAM wParam, LPARAM lParam) +{ + MessageWindowEventData* msgEvData = (MessageWindowEventData*)lParam; + + if (msgEvData->uType == MSG_WINDOW_EVT_CLOSE && DBGetContactSettingByte(NULL, ModuleName, "SweepOnClose", 0)) + { + CriteriaStruct Criteria; + + Criteria.keep = KeepCriteria(DBGetContactSettingByte(NULL, ModuleName, "StartupShutdownKeep", 0)); + Criteria.time = BuildCriteria(DBGetContactSettingByte(NULL, ModuleName, "StartupShutdownOlder", 0)); + + SweepHistoryFromContact(msgEvData->hContact, Criteria, TRUE); + } + + return 0; +} \ No newline at end of file diff --git a/plugins/HistorySweeperLight/src/historysweeperlight.h b/plugins/HistorySweeperLight/src/historysweeperlight.h new file mode 100644 index 0000000000..c7fbeaeb25 --- /dev/null +++ b/plugins/HistorySweeperLight/src/historysweeperlight.h @@ -0,0 +1,71 @@ +/* +Miranda IM History Sweeper Light plugin +Copyright (C) 2002-2003 Sergey V. Gershovich +Copyright (C) 2006-2009 Boris Krasnovskiy +Copyright (C) 2010, 2011 tico-tico + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ +#ifndef __HISTORYSWEEPERLIGHT_H__ +#define __HISTORYSWEEPERLIGHT_H__ + +#define MIRANDA_VER 0x0A00 + +#if !defined( _WIN64 ) + #define _USE_32BIT_TIME_T +#endif + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "resource.h" + +// Plugin name +#define ModuleName "History Sweeper Light" + +// Plugin UUID for New plugin loader +// req. 0.7.18+ core +// {1D9BF74A-44A8-4b3f-A6E5-73069D3A8979} +#define MIID_HISTORYSWEEPERLIGHT { 0x1d9bf74a, 0x44a8, 0x4b3f, { 0xa6, 0xe5, 0x73, 0x6, 0x9d, 0x3a, 0x89, 0x79 } } + +// main.c +extern HINSTANCE hInst; + +// options.c +extern const char* time_stamp_strings[]; +extern const char* keep_strings[]; +int HSOptInitialise(WPARAM wParam, LPARAM lParam); +void InitIcons(void); +void ReleaseIconEx(const char* name); +HICON LoadIconEx(const char* name); +HANDLE GetIconHandle(const char* name); + +// historysweeper.c +void ShutdownAction(void); +int OnWindowEvent(WPARAM wParam, LPARAM lParam); + +#endif diff --git a/plugins/HistorySweeperLight/src/main.cpp b/plugins/HistorySweeperLight/src/main.cpp new file mode 100644 index 0000000000..c6f8b427ac --- /dev/null +++ b/plugins/HistorySweeperLight/src/main.cpp @@ -0,0 +1,179 @@ +/* +Miranda IM History Sweeper Light plugin +Copyright (C) 2002-2003 Sergey V. Gershovich +Copyright (C) 2006-2009 Boris Krasnovskiy +Copyright (C) 2010, 2011 tico-tico + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +#include "historysweeperlight.h" +#include "version.h" + +HINSTANCE hInst; + +static HANDLE hHooks[5]; +int hLangpack; + +static PLUGININFOEX pluginInfoEx = +{ + // about plugin + sizeof(PLUGININFOEX), + "History Sweeper Light", + __VERSION_DWORD, + "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 IM startup/shutdown.", + "Sergey V. Gershovich a.k.a. Jazzy$, Boris Krasnovskiy, tico-tico", + "", + "© 2002-2003 Sergey V. Gershovich a.k.a. Jazzy$, 2006-2009 Boris Krasnovskiy, 2010, 2011 tico-tico", + "", + UNICODE_AWARE, + MIID_HISTORYSWEEPERLIGHT +}; + +BOOL WINAPI DllMain(HINSTANCE hinstDLL,DWORD fdwReason,LPVOID lpvReserved) +{ + hInst=hinstDLL; + return TRUE; +} + +int OnIconPressed(WPARAM wParam, LPARAM lParam) +{ + StatusIconClickData *sicd = (StatusIconClickData *)lParam; + + if ( !(sicd->flags & MBCF_RIGHTBUTTON) && !lstrcmpA(sicd->szModule, ModuleName) + && DBGetContactSettingByte(NULL, ModuleName, "ChangeInMW", 0)) + { + int nh = sicd->dwId; HANDLE hContact = (HANDLE)wParam; StatusIconData sid = {0}; + + sid.cbSize = sizeof(sid); + sid.szModule = ModuleName; + sid.dwId = nh; + sid.flags = MBF_HIDDEN; + CallService(MS_MSG_MODIFYICON, (WPARAM)hContact, (LPARAM)&sid); + + nh = (nh + 1) % 4; + DBWriteContactSettingByte((HANDLE)wParam, ModuleName, "SweepHistory", (BYTE)nh); + + sid.dwId = nh; + sid.flags = 0; + CallService(MS_MSG_MODIFYICON, (WPARAM)hContact, (LPARAM)&sid); + } + return 0; +} + + +int OnModulesLoaded(WPARAM wParam, LPARAM lParam) +{ + StatusIconData sid = {0}; + int i, sweep = DBGetContactSettingByte(NULL, ModuleName, "SweepHistory", 0); + HANDLE hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); + + sid.cbSize = sizeof(sid); + sid.szModule = ModuleName; + + sid.hIcon = LoadIconEx("actG"); + if (sweep == 0) + sid.szTooltip = Translate("Keep all events"); + else if (sweep == 1) + { + sid.szTooltip = Translate(time_stamp_strings[DBGetContactSettingByte(NULL, ModuleName, "StartupShutdownOlder", 0)]); + } + else if (sweep == 2) + { + sid.szTooltip = Translate(keep_strings[DBGetContactSettingByte(NULL, ModuleName, "StartupShutdownKeep", 0)]); + } + else if (sweep == 3) + { + sid.szTooltip = Translate("Delete all events"); + } + sid.flags = MBF_HIDDEN; + CallService(MS_MSG_ADDICON, 0, (LPARAM)&sid); + + sid.dwId = 1; + sid.hIcon = LoadIconEx("act1"); + sid.szTooltip = Translate(time_stamp_strings[DBGetContactSettingByte(NULL, ModuleName, "StartupShutdownOlder", 0)]); + sid.flags = MBF_HIDDEN; + CallService(MS_MSG_ADDICON, 0, (LPARAM)&sid); + + sid.dwId = 2; + sid.hIcon = LoadIconEx("act2"); + sid.szTooltip = Translate(keep_strings[DBGetContactSettingByte(NULL, ModuleName, "StartupShutdownKeep", 0)]); + sid.flags = MBF_HIDDEN; + CallService(MS_MSG_ADDICON, 0, (LPARAM)&sid); + + sid.dwId = 3; + sid.hIcon = LoadIconEx("actDel"); + sid.szTooltip = Translate("Delete all events"); + sid.flags = MBF_HIDDEN; + CallService(MS_MSG_ADDICON, 0, (LPARAM)&sid); + + // for new contacts + while ( hContact != NULL ) + { + ZeroMemory(&sid,sizeof(sid)); + + sweep = DBGetContactSettingByte(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; + CallService(MS_MSG_MODIFYICON, (WPARAM)hContact, (LPARAM)&sid); + } + + hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM)hContact, 0); + } + + hHooks[2] = HookEvent(ME_MSG_WINDOWEVENT, OnWindowEvent); + hHooks[3] = HookEvent(ME_MSG_ICONPRESSED, OnIconPressed); + + return 0; +} + +extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD mirandaVersion) +{ + return &pluginInfoEx; +} + +extern "C" __declspec(dllexport) int Load(void) +{ + + mir_getLP(&pluginInfoEx); + + hHooks[0] = HookEvent(ME_SYSTEM_MODULESLOADED, OnModulesLoaded); + hHooks[1] = HookEvent(ME_OPT_INITIALISE, HSOptInitialise); + + InitIcons(); + + return 0; +} + +extern "C" __declspec(dllexport) int Unload(void) +{ + int i; + + ShutdownAction(); + + for (i = 0; i < SIZEOF(hHooks); i++) + { + if (hHooks[i]) + UnhookEvent(hHooks[i]); + } + + return 0; +} \ No newline at end of file diff --git a/plugins/HistorySweeperLight/src/options.cpp b/plugins/HistorySweeperLight/src/options.cpp new file mode 100644 index 0000000000..2963f8bb2b --- /dev/null +++ b/plugins/HistorySweeperLight/src/options.cpp @@ -0,0 +1,354 @@ +/* +Miranda IM History Sweeper Light plugin +Copyright (C) 2002-2003 Sergey V. Gershovich +Copyright (C) 2006-2009 Boris Krasnovskiy +Copyright (C) 2010, 2011 tico-tico + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +#include "historysweeperlight.h" + +// Time Stamps strings +const char* time_stamp_strings[] = +{ + "Delete older than 1 day", + "Delete older than 3 days", + "Delete older than 7 days", + "Delete older than 2 weeks (14 days)", + "Delete older than 1 month (30 days)", + "Delete older than 3 months (90 days)", + "Delete older than 6 months (180 days)", + "Delete older than 1 year (365 days)" +}; + +const char* keep_strings[] = +{ + "Keep 1 last event", + "Keep 2 last events", + "Keep 5 last events", + "Keep 10 last events", + "Keep 20 last events", + "Keep 50 last events" +}; + +struct +{ + char* szDescr; + char* szName; + int defIconID; +} +static const iconList[] = +{ + { "Default Action", "actG", IDI_ACTG }, + { "Action 1", "act1", IDI_ACT1 }, + { "Action 2", "act2", IDI_ACT2 }, + { "Delete All", "actDel", IDI_ACTDEL } +}; + +static HANDLE hIconLibItem[SIZEOF(iconList)]; + +void InitIcons(void) +{ + TCHAR szFile[MAX_PATH]; + GetModuleFileName(hInst, szFile, SIZEOF(szFile)); + + SKINICONDESC sid = { 0 }; + sid.cbSize = sizeof(SKINICONDESC); + sid.ptszDefaultFile = szFile; + sid.cx = sid.cy = 16; + sid.pszSection = ModuleName; + sid.flags = SIDF_PATH_TCHAR; + + for (int i=0; i < SIZEOF(iconList); i++) { + char szSettingName[100]; + mir_snprintf(szSettingName, SIZEOF(szSettingName), "%s_%s", ModuleName, iconList[i].szName); + sid.pszName = szSettingName; + + sid.pszDescription = (char*)iconList[i].szDescr; + sid.iDefaultIndex = -iconList[i].defIconID; + hIconLibItem[i] = Skin_AddIcon(&sid); + } +} + +HICON LoadIconEx(const char* name) +{ + char szSettingName[100]; + mir_snprintf(szSettingName, sizeof(szSettingName), "%s_%s", ModuleName, name); + return (HICON)CallService(MS_SKIN2_GETICON, 0, (LPARAM)szSettingName); +} + +HANDLE GetIconHandle(const char* name) +{ + int i; + + for (i=0; i < SIZEOF(iconList); i++) + if (lstrcmpA(iconList[i].szName, name) == 0) + return hIconLibItem[i]; + + return NULL; +} + +void ReleaseIconEx(const char* name) +{ + char szSettingName[100]; + mir_snprintf(szSettingName, sizeof(szSettingName), "%s_%s", ModuleName, name); + CallService(MS_SKIN2_RELEASEICON, 0, (LPARAM)szSettingName); +} + +HANDLE hAllContacts, hSystemHistory; + +void ResetListOptions(HWND hwndList) +{ + int i; + + SendMessage(hwndList, CLM_SETBKBITMAP, 0, 0); + SendMessage(hwndList, CLM_SETBKCOLOR, GetSysColor(COLOR_WINDOW), 0); + SendMessage(hwndList, CLM_SETGREYOUTFLAGS, 0, 0); + SendMessage(hwndList, CLM_SETLEFTMARGIN, 4, 0); + SendMessage(hwndList, CLM_SETINDENT, 10, 0); + + for (i=0; i<=FONTID_MAX; i++) + SendMessage(hwndList, CLM_SETTEXTCOLOR, i, GetSysColor(COLOR_WINDOWTEXT)); +} + +static void ShowAllContactIcons(HWND hwndList) +{ + HANDLE hContact, hItem; + + SendMessage(hwndList, CLM_SETEXTRAIMAGE, (WPARAM)hAllContacts, + MAKELPARAM(0, DBGetContactSettingByte(NULL, ModuleName, "SweepHistory", 0))); + SendMessage(hwndList, CLM_SETEXTRAIMAGE, (WPARAM)hSystemHistory, + MAKELPARAM(0, DBGetContactSettingByte(NULL, ModuleName, "SweepSHistory", 0))); + + for (hContact=(HANDLE)CallService(MS_DB_CONTACT_FINDFIRST,0,0); hContact; + hContact=(HANDLE)CallService(MS_DB_CONTACT_FINDNEXT,(WPARAM)hContact,0)) + { + hItem = (HANDLE)SendMessage(hwndList, CLM_FINDCONTACT, (WPARAM)hContact, 0); + SendMessage(hwndList, CLM_SETEXTRAIMAGE, (WPARAM)hItem, + MAKELPARAM(0, DBGetContactSettingByte(hContact, ModuleName, "SweepHistory", 0))); + } +}//ShowAllContactIcons + +void LoadSettings(HWND hwndDlg) +{ + int i; CLCINFOITEM cii = {0}; HWND hwndList = GetDlgItem(hwndDlg, IDC_LIST); + + cii.cbSize = sizeof(cii); + cii.flags = CLCIIF_GROUPFONT; + + cii.pszText = TranslateT("*** Defaut Action ***"); + hAllContacts = (HANDLE)SendMessage(hwndList, CLM_ADDINFOITEM, 0, (LPARAM)&cii); + + cii.pszText = TranslateT("*** System History ***"); + hSystemHistory = (HANDLE)SendMessage(hwndList, CLM_ADDINFOITEM, 0, (LPARAM)&cii); + + ShowAllContactIcons(hwndList); + + 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++) + { + 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++) + { + TCHAR* ptszTimeStr = (TCHAR*)CallService(MS_LANGPACK_PCHARTOTCHAR, 0, (LPARAM)keep_strings[i]); + SendDlgItemMessage(hwndDlg, IDC_SSKEEP, CB_ADDSTRING, 0, (LPARAM)ptszTimeStr); + mir_free(ptszTimeStr); + } + + SendDlgItemMessage(hwndDlg, IDC_SSOLDER, CB_SETCURSEL, DBGetContactSettingByte(NULL, ModuleName, "StartupShutdownOlder", 0), 0); + SendDlgItemMessage(hwndDlg, IDC_SSKEEP, CB_SETCURSEL, DBGetContactSettingByte(NULL, ModuleName, "StartupShutdownKeep", 0), 0); + + CheckDlgButton(hwndDlg, IDC_UNSAFEMODE, DBGetContactSettingByte(NULL, ModuleName, "UnsafeMode", 0)); + CheckDlgButton(hwndDlg, IDC_SWEEPONCLOSE, DBGetContactSettingByte(NULL, ModuleName, "SweepOnClose", 0)); + CheckDlgButton(hwndDlg, IDC_HISTMW, DBGetContactSettingByte(NULL, ModuleName, "ChangeInMW", 0)); +}//LoadSettings + + +void SaveSettings(HWND hwndDlg) +{ + int st, i; StatusIconData sid = {0}; HANDLE hContact, hItem; HWND hwndList = GetDlgItem(hwndDlg, IDC_LIST); + + DBWriteContactSettingByte(NULL, ModuleName, "StartupShutdownOlder", (BYTE)SendDlgItemMessage(hwndDlg, IDC_SSOLDER, CB_GETCURSEL, 0, 0)); + DBWriteContactSettingByte(NULL, ModuleName, "StartupShutdownKeep", (BYTE)SendDlgItemMessage(hwndDlg, IDC_SSKEEP, CB_GETCURSEL, 0, 0)); + DBWriteContactSettingByte(NULL, ModuleName, "UnsafeMode", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_UNSAFEMODE)); + DBWriteContactSettingByte(NULL, ModuleName, "SweepOnClose", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_SWEEPONCLOSE)); + DBWriteContactSettingByte(NULL, ModuleName, "ChangeInMW", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_HISTMW)); + + sid.cbSize = sizeof(sid); + sid.szModule = ModuleName; + + DBWriteContactSettingByte(NULL, ModuleName, "SweepHistory", + (BYTE)SendMessage(hwndList, CLM_GETEXTRAIMAGE, (WPARAM)hAllContacts, 0)); + DBWriteContactSettingByte(NULL, ModuleName, "SweepSHistory", + (BYTE)SendMessage(hwndList, CLM_GETEXTRAIMAGE, (WPARAM)hSystemHistory, 0)); + + for (hContact=(HANDLE)CallService(MS_DB_CONTACT_FINDFIRST,0,0); hContact; + hContact=(HANDLE)CallService(MS_DB_CONTACT_FINDNEXT,(WPARAM)hContact,0)) + { + hItem = (HANDLE)SendMessage(hwndList, CLM_FINDCONTACT, (WPARAM)hContact, 0); + + st = SendMessage(hwndList, CLM_GETEXTRAIMAGE, (WPARAM)hItem, 0); + if ( st != 0 ) DBWriteContactSettingByte(hContact, ModuleName, "SweepHistory", (BYTE)st); + else DBDeleteContactSetting(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; + CallService(MS_MSG_MODIFYICON, (WPARAM)hContact, (LPARAM)&sid); + } + } + + // set tooltips + st = DBGetContactSettingByte(NULL, ModuleName, "SweepHistory", 0); + + sid.dwId = 0; + if (st == 0) sid.szTooltip = Translate("Keep all events"); + else if (st == 1) sid.szTooltip = Translate(time_stamp_strings[DBGetContactSettingByte(NULL, ModuleName, "StartupShutdownOlder", 0)]); + else if (st == 2) sid.szTooltip = Translate(keep_strings[DBGetContactSettingByte(NULL, ModuleName, "StartupShutdownKeep", 0)]); + else if (st == 3) sid.szTooltip = Translate("Delete all events"); + CallService(MS_MSG_MODIFYICON, 0, (LPARAM)&sid); + + sid.dwId = 1; + sid.szTooltip = Translate(time_stamp_strings[DBGetContactSettingByte(NULL, ModuleName, "StartupShutdownOlder", 0)]); + CallService(MS_MSG_MODIFYICON, 0, (LPARAM)&sid); + + sid.dwId = 2; + sid.szTooltip = Translate(keep_strings[DBGetContactSettingByte(NULL, ModuleName, "StartupShutdownKeep", 0)]); + CallService(MS_MSG_MODIFYICON, 0, (LPARAM)&sid); +}//SaveSettings + +INT_PTR CALLBACK DlgProcHSOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ + switch (msg) + { + case WM_INITDIALOG: + { + HIMAGELIST hIml = ImageList_Create( GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), + ILC_MASK | (IsWinVerXPPlus() ? ILC_COLOR32 : ILC_COLOR16 ), 2, 2 ); + + HICON hIcon = LoadSkinnedIcon(SKINICON_OTHER_SMALLDOT); + ImageList_AddIcon(hIml, hIcon); + CallService(MS_SKIN2_RELEASEICON, (WPARAM)hIcon, 0); + + hIcon = LoadIconEx("act1"); + ImageList_AddIcon(hIml, hIcon); + SendDlgItemMessage(hwndDlg, IDC_ACT1, STM_SETICON, (WPARAM)hIcon, 0); + + hIcon = LoadIconEx("act2"); + ImageList_AddIcon(hIml, hIcon); + SendDlgItemMessage(hwndDlg, IDC_ACT2, STM_SETICON, (WPARAM)hIcon, 0); + + hIcon = LoadIconEx("actDel"); + ImageList_AddIcon(hIml, hIcon); + + SendDlgItemMessage(hwndDlg, IDC_LIST, CLM_SETEXTRAIMAGELIST, 0, (LPARAM)hIml); + SendDlgItemMessage(hwndDlg, IDC_LIST, CLM_SETEXTRACOLUMNS, 1, 0); + + TranslateDialogDefault(hwndDlg); + ResetListOptions(GetDlgItem(hwndDlg, IDC_LIST)); + 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"); + } + break; + + case WM_COMMAND: + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); // Send message to activate "Apply" button + 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); + break; + + case CLN_OPTIONSCHANGED: + ResetListOptions(nmc->hdr.hwndFrom); + 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; + + // 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)); + + // Activate Apply button + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + } + break; + } + } + } + break; + } + return FALSE; +} + +int HSOptInitialise(WPARAM wParam,LPARAM lParam) +{ + OPTIONSDIALOGPAGE odp = {0}; + odp.cbSize = sizeof(odp); + odp.position = 0; + odp.hInstance = hInst; + odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_HISTORYSWEEPER); + odp.pszTitle = ModuleName; + odp.pszGroup = LPGEN("History"); + odp.pfnDlgProc = DlgProcHSOpts; + odp.flags = ODPF_BOLDGROUPS; + Options_AddPage(wParam, &odp); + + return 0; +} diff --git a/plugins/HistorySweeperLight/src/resource.h b/plugins/HistorySweeperLight/src/resource.h new file mode 100644 index 0000000000..bfa91d1d4e --- /dev/null +++ b/plugins/HistorySweeperLight/src/resource.h @@ -0,0 +1,18 @@ +#ifndef IDC_STATIC +#define IDC_STATIC (-1) +#endif + +#define IDD_OPT_HISTORYSWEEPER 101 +#define IDI_ACTG 102 +#define IDI_ACT1 103 +#define IDI_ACT2 104 +#define IDI_ACTDEL 105 +#define IDC_LIST 106 +#define IDC_SSOLDER 107 +#define IDC_UNSAFEMODE 108 +#define IDC_SWEEPONCLOSE 109 +#define IDC_SSKEEP 110 +#define IDC_HISTMW 111 +#define IDC_ACT1 112 +#define IDC_ACT2 113 + diff --git a/plugins/HistorySweeperLight/src/version.h b/plugins/HistorySweeperLight/src/version.h new file mode 100644 index 0000000000..245200a539 --- /dev/null +++ b/plugins/HistorySweeperLight/src/version.h @@ -0,0 +1,23 @@ +/* +Plugin of Miranda IM for communicating with users of the MSN Messenger protocol. +Copyright (c) 2008-2009 Boris Krasnovskiy. +Copyright (C) 2010, 2011 tico-tico + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +#define __FILEVERSION_STRING 0,0,0,7 +#define __VERSION_STRING "0.0.0.7" +#define __VERSION_DWORD PLUGIN_MAKE_VERSION(0, 0, 0, 7) + diff --git a/plugins/HistorySweeperLight/version.h b/plugins/HistorySweeperLight/version.h deleted file mode 100644 index 245200a539..0000000000 --- a/plugins/HistorySweeperLight/version.h +++ /dev/null @@ -1,23 +0,0 @@ -/* -Plugin of Miranda IM for communicating with users of the MSN Messenger protocol. -Copyright (c) 2008-2009 Boris Krasnovskiy. -Copyright (C) 2010, 2011 tico-tico - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -*/ - -#define __FILEVERSION_STRING 0,0,0,7 -#define __VERSION_STRING "0.0.0.7" -#define __VERSION_DWORD PLUGIN_MAKE_VERSION(0, 0, 0, 7) - -- cgit v1.2.3