From f568b2ea5a3665d917acbe1e4ac3a5e60654d8dc Mon Sep 17 00:00:00 2001 From: Vadim Dashevskiy Date: Mon, 9 Jul 2012 07:19:30 +0000 Subject: BuddyExpectator: changed folder structure git-svn-id: http://svn.miranda-ng.org/main/trunk@870 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/BuddyExpectator/BuddyExpectator.cpp | 927 --------------------- plugins/BuddyExpectator/BuddyExpectator.rc | 216 ----- plugins/BuddyExpectator/BuddyExpectator10.vcxproj | 16 +- .../buddyexpectator-translation.txt | 65 -- plugins/BuddyExpectator/common.h | 64 -- .../docs/buddyexpectator-translation.txt | 65 ++ plugins/BuddyExpectator/icons/disabled.ico | Bin 2550 -> 0 bytes plugins/BuddyExpectator/icons/enabled.ico | Bin 2550 -> 0 bytes plugins/BuddyExpectator/icons/hide.ico | Bin 2550 -> 0 bytes plugins/BuddyExpectator/icons/main.ico | Bin 2550 -> 0 bytes plugins/BuddyExpectator/icons/neverhide.ico | Bin 2550 -> 0 bytes plugins/BuddyExpectator/options.cpp | 627 -------------- plugins/BuddyExpectator/options.h | 64 -- plugins/BuddyExpectator/res/BuddyExpectator.rc | 216 +++++ plugins/BuddyExpectator/res/disabled.ico | Bin 0 -> 2550 bytes plugins/BuddyExpectator/res/enabled.ico | Bin 0 -> 2550 bytes plugins/BuddyExpectator/res/hide.ico | Bin 0 -> 2550 bytes plugins/BuddyExpectator/res/main.ico | Bin 0 -> 2550 bytes plugins/BuddyExpectator/res/neverhide.ico | Bin 0 -> 2550 bytes plugins/BuddyExpectator/resource.h | 56 -- plugins/BuddyExpectator/src/BuddyExpectator.cpp | 927 +++++++++++++++++++++ plugins/BuddyExpectator/src/common.h | 64 ++ plugins/BuddyExpectator/src/options.cpp | 627 ++++++++++++++ plugins/BuddyExpectator/src/options.h | 64 ++ plugins/BuddyExpectator/src/resource.h | 56 ++ 25 files changed, 2025 insertions(+), 2029 deletions(-) delete mode 100644 plugins/BuddyExpectator/BuddyExpectator.cpp delete mode 100644 plugins/BuddyExpectator/BuddyExpectator.rc delete mode 100644 plugins/BuddyExpectator/buddyexpectator-translation.txt delete mode 100644 plugins/BuddyExpectator/common.h create mode 100644 plugins/BuddyExpectator/docs/buddyexpectator-translation.txt delete mode 100644 plugins/BuddyExpectator/icons/disabled.ico delete mode 100644 plugins/BuddyExpectator/icons/enabled.ico delete mode 100644 plugins/BuddyExpectator/icons/hide.ico delete mode 100644 plugins/BuddyExpectator/icons/main.ico delete mode 100644 plugins/BuddyExpectator/icons/neverhide.ico delete mode 100644 plugins/BuddyExpectator/options.cpp delete mode 100644 plugins/BuddyExpectator/options.h create mode 100644 plugins/BuddyExpectator/res/BuddyExpectator.rc create mode 100644 plugins/BuddyExpectator/res/disabled.ico create mode 100644 plugins/BuddyExpectator/res/enabled.ico create mode 100644 plugins/BuddyExpectator/res/hide.ico create mode 100644 plugins/BuddyExpectator/res/main.ico create mode 100644 plugins/BuddyExpectator/res/neverhide.ico delete mode 100644 plugins/BuddyExpectator/resource.h create mode 100644 plugins/BuddyExpectator/src/BuddyExpectator.cpp create mode 100644 plugins/BuddyExpectator/src/common.h create mode 100644 plugins/BuddyExpectator/src/options.cpp create mode 100644 plugins/BuddyExpectator/src/options.h create mode 100644 plugins/BuddyExpectator/src/resource.h diff --git a/plugins/BuddyExpectator/BuddyExpectator.cpp b/plugins/BuddyExpectator/BuddyExpectator.cpp deleted file mode 100644 index ab10cf03cb..0000000000 --- a/plugins/BuddyExpectator/BuddyExpectator.cpp +++ /dev/null @@ -1,927 +0,0 @@ -/* - Buddy Expectator+ plugin for Miranda-IM (www.miranda-im.org) - (c)2005 Anar Ibragimoff (ai91@mail.ru) - (c)2006 Scott Ellis (mail@scottellis.com.au) - (c)2007,2008 Alexander Turyak (thief@miranda-im.org.ua) - - 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 - - File name : $URL: http://svn.miranda.im/mainrepo/buddyexpectator/trunk/BuddyExpectator.cpp $ - Revision : $Rev: 1392 $ - Last change on : $Date: 2009-04-22 17:46:08 +0300 (Ср, 22 апр 2009) $ - Last change by : $Author: Thief $ -*/ - -#include "common.h" -#include "options.h" - -HINSTANCE hInst; -int hLangpack; - -DWORD timer_id = 0; - -HANDLE hEventContactSetting = NULL; -HANDLE hEventContactAdded = NULL; -HANDLE hEventUserInfoInit = NULL; -HANDLE hPrebuildContactMenu = NULL; -HANDLE hContactMenu = NULL; -HANDLE hIcoLibIconsChanged = NULL; -HANDLE hContactReturnedAction = NULL; -HANDLE hContactStillAbsentAction = NULL; -HANDLE hMissYouAction = NULL; -HANDLE hMenuMissYouClick = NULL; -HANDLE hModulesLoaded = NULL; -HANDLE hModulesLoaded2 = NULL; -HANDLE hSystemOKToExit = NULL; -HANDLE hHookExtraIconsRebuild = NULL; -HANDLE hHookExtraIconsApply = NULL; - -HICON hIcon; -HANDLE hEnabledIcon = NULL, hDisabledIcon = NULL; - -IconExtraColumn g_IECMissYou = {0}; -IconExtraColumn g_IECClear = {0}; - -// Popup Actions -POPUPACTION missyouactions[1]; -POPUPACTION hideactions[2]; - -extern int UserinfoInit(WPARAM wparam, LPARAM lparam); - -PLUGININFOEX pluginInfo = { - sizeof(PLUGININFOEX), - "Buddy Expectator+", - PLUGIN_MAKE_VERSION(0,1,2,3), - "Reacts to the return of contacts, or the the extended absence of contacts, with notifications and other actions", - "Anar Ibragimoff, sje, Thief", - "thief@miranda.im", - "© 2005 Anar Ibragimoff, © 2006 Scott Ellis, © 2007-2009 Alexander Turyak", - "http://thief.miranda.im", - UNICODE_AWARE, - {0xddf8aec9, 0x7d37, 0x49af, {0x9d, 0x22, 0xbb, 0xbc, 0x92, 0x0e, 0x6f, 0x05}} //{DDF8AEC9-7D37-49AF-9D22-BBBC920E6F05} -}; - -/* 2D84F403-91F3-4E60-BF02-16C2F1716D86 */ -#define MIID_BUDDYEXPECTATOR {0x2d84f403, 0x91f3, 0x4e60, {0xbf, 0x02, 0x16, 0xc2, 0xf1, 0x71, 0x6d, 0x86}} - -extern "C" __declspec(dllexport) const MUUID* MirandaPluginInterfaces(void) -{ - static const MUUID interfaces[] = {MIID_BUDDYEXPECTATOR, MIID_LAST}; - return interfaces; -} - -extern "C" BOOL WINAPI DllMain(HINSTANCE hinstDLL,DWORD fdwReason,LPVOID lpvReserved) -{ - hInst = hinstDLL; - return TRUE; -} - -time_t getLastSeen(HANDLE hContact) -{ - return DBGetContactSettingDword(hContact, MODULE_NAME, "LastSeen", DBGetContactSettingDword(hContact, MODULE_NAME, "CreationTime", (DWORD)-1)); -} - -void setLastSeen(HANDLE hContact) -{ - DBWriteContactSettingDword(hContact, MODULE_NAME, "LastSeen", (DWORD)time(NULL)); - if (DBGetContactSettingByte(hContact, MODULE_NAME, "StillAbsentNotified", 0)) - DBWriteContactSettingByte(hContact, MODULE_NAME, "StillAbsentNotified", 0); -} - -time_t getLastInputMsg(HANDLE hContact) -{ - HANDLE hDbEvent; - DBEVENTINFO dbei = {0}; - - hDbEvent = (HANDLE)CallService(MS_DB_EVENT_FINDLAST, (WPARAM)hContact, 0); - while (hDbEvent) - { - dbei.cbSize = sizeof(dbei); - dbei.pBlob = 0; - dbei.cbBlob = 0; - CallService(MS_DB_EVENT_GET, (WPARAM)hDbEvent, (LPARAM)&dbei); - if (dbei.eventType == EVENTTYPE_MESSAGE && !(dbei.flags & DBEF_SENT)) - return dbei.timestamp; - hDbEvent = (HANDLE)CallService(MS_DB_EVENT_FINDPREV, (WPARAM)hDbEvent, 0); - } - return -1; -} - -/** - * PopUp window procedures - */ - -int CALLBACK HidePopupDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) -{ - switch (message) - { - case WM_COMMAND: - if (HIWORD(wParam) == STN_CLICKED) - { - DBWriteContactSettingByte(PUGetContact(hWnd), "CList", "Hidden", 1); - PUDeletePopUp(hWnd); - } - break; - case WM_CONTEXTMENU: - DBWriteContactSettingByte(PUGetContact(hWnd), MODULE_NAME, "NeverHide", 1); - PUDeletePopUp(hWnd); - break; - case UM_POPUPACTION: - if (wParam == 2) - { - DBWriteContactSettingByte(PUGetContact(hWnd), "CList", "Hidden", 1); - PUDeletePopUp(hWnd); - } - if (wParam == 3) - { - DBWriteContactSettingByte(PUGetContact(hWnd), MODULE_NAME, "NeverHide", 1); - PUDeletePopUp(hWnd); - } - break; - case UM_FREEPLUGINDATA: - return TRUE; - default: - break; - } - return DefWindowProc(hWnd, message, wParam, lParam); -} - -int CALLBACK MissYouPopupDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) -{ - switch (message) - { - case WM_COMMAND: - if (HIWORD(wParam) == STN_CLICKED) - { - CallServiceSync("BuddyExpectator/actionMissYou", (WPARAM)PUGetContact(hWnd), 0); - if (!DBGetContactSettingByte(PUGetContact(hWnd), MODULE_NAME, "MissYouNotifyAlways", 0)) - { - DBWriteContactSettingByte(PUGetContact(hWnd), MODULE_NAME, "MissYou", 0); - if (options.MissYouIcon) CallService(MS_CLIST_EXTRA_SET_ICON, (WPARAM) PUGetContact(hWnd), (LPARAM) &g_IECClear); - } - PUDeletePopUp(hWnd); - } - break; - case WM_CONTEXTMENU: - PUDeletePopUp(hWnd); - break; - case UM_POPUPACTION: - if (wParam == 1) - { - DBWriteContactSettingByte(PUGetContact(hWnd), MODULE_NAME, "MissYou", 0); - if (options.MissYouIcon) CallService(MS_CLIST_EXTRA_SET_ICON, (WPARAM) PUGetContact(hWnd), (LPARAM) &g_IECClear); - PUDeletePopUp(hWnd); - } - break; - case UM_FREEPLUGINDATA: - return TRUE; - default: - break; - } - return DefWindowProc(hWnd, message, wParam, lParam); -} - -int CALLBACK PopupDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) -{ - switch (message) - { - case WM_COMMAND: - if (HIWORD(wParam) == STN_CLICKED) - { - CallServiceSync(MS_CLIST_REMOVEEVENT, (WPARAM)PUGetContact(hWnd), 0); - CallServiceSync("BuddyExpectator/actionReturned", (WPARAM)PUGetContact(hWnd), 0); - PUDeletePopUp(hWnd); - } - break; - case WM_CONTEXTMENU: - CallServiceSync(MS_CLIST_REMOVEEVENT, (WPARAM)PUGetContact(hWnd), 0); - setLastSeen(PUGetContact(hWnd)); - PUDeletePopUp(hWnd); - break; - case UM_FREEPLUGINDATA: - if (options.iShowEvent == 0) - { - setLastSeen(PUGetContact(hWnd)); - } - return TRUE; - default: - break; - } - return DefWindowProc(hWnd, message, wParam, lParam); -} - -int CALLBACK PopupDlgProcNoSet(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) -{ - switch (message) - { - case WM_COMMAND: - if (HIWORD(wParam) == STN_CLICKED) - { - CallServiceSync(MS_CLIST_REMOVEEVENT, (WPARAM)PUGetContact(hWnd), 0); - CallServiceSync("BuddyExpectator/actionStillAbsent", (WPARAM)PUGetContact(hWnd), 0); - PUDeletePopUp(hWnd); - } - break; - case WM_CONTEXTMENU: - CallServiceSync(MS_CLIST_REMOVEEVENT, (WPARAM)PUGetContact(hWnd), 0); - PUDeletePopUp(hWnd); - break; - case UM_FREEPLUGINDATA: - return TRUE; - default: - break; - } - return DefWindowProc(hWnd, message, wParam, lParam); -} - -/** - * Checks - whether user has been gone for specified number of days - */ -bool isContactGoneFor(HANDLE hContact, int days) -{ - time_t lastSeen = getLastSeen(hContact); - time_t lastInputMsg = getLastInputMsg(hContact); - time_t currentTime = time(NULL); - - int daysSinceOnline = -1; - if (lastSeen != -1) daysSinceOnline = (int)((currentTime - lastSeen)/(60*60*24)); - - int daysSinceMessage = -1; - if (lastInputMsg != -1) daysSinceMessage = (int)((currentTime - lastInputMsg)/(60*60*24)); - - if (options.hideInactive) - { - if (daysSinceMessage >= options.iSilencePeriod) - if (!DBGetContactSettingByte(hContact, "CList", "Hidden", 0) && !DBGetContactSettingByte(hContact, MODULE_NAME, "NeverHide", 0)) - { - char szInfo[200]; - - POPUPDATAT_V2 ppd = {0}; - ppd.cbSize = sizeof(POPUPDATAT_V2); - - ppd.lchContact = hContact; - ppd.lchIcon = (HICON)CallService(MS_SKIN2_GETICON, 0, (LPARAM)"enabled_icon"); - - mir_snprintf(szInfo, 200, Translate("Hiding %s (%s)"), (char*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME,(WPARAM)hContact,0), (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0)); - strncpy(ppd.lpzContactName, szInfo, MAX_CONTACTNAME); - mir_snprintf(szInfo, 200, Translate("%d days since last message"), daysSinceMessage); - strncpy(ppd.lpzText, szInfo, MAX_SECONDLINE); - if (!options.iUsePopupColors) - { - ppd.colorBack = options.iPopUpColorBack; - ppd.colorText = options.iPopUpColorFore; - } - ppd.PluginWindowProc = (WNDPROC)HidePopupDlgProc; - ppd.PluginData = NULL; - ppd.iSeconds = -1; - - hideactions[0].flags = hideactions[1].flags = PAF_ENABLED; - ppd.lpActions = hideactions; - ppd.actionCount = 2; - - CallService(MS_POPUP_ADDPOPUPEX, (WPARAM) &ppd, APF_NEWDATA); - - SkinPlaySound("buddyExpectatorHide"); - } - } - - return (daysSinceOnline >= days && (daysSinceMessage == -1 || daysSinceMessage >= days)); -} - -void ReturnNotify(HANDLE hContact, char *message) -{ - if (DBGetContactSettingByte(hContact, "CList", "NotOnList", 0) == 1 || DBGetContactSettingByte(hContact, "CList", "Hidden", 0) == 1) - return; - - SkinPlaySound("buddyExpectatorReturn"); - - if (options.iShowPopUp > 0) - { - // Display PopUp - POPUPDATAT_V2 ppd = {0}; - ppd.cbSize = sizeof(POPUPDATAT_V2); - - ppd.lchContact = hContact; - ppd.lchIcon = hIcon; - strncpy(ppd.lpzContactName, (char*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME,(WPARAM)hContact,0), MAX_CONTACTNAME); - strncpy(ppd.lpzText, message, MAX_SECONDLINE); - if (!options.iUsePopupColors) - { - ppd.colorBack = options.iPopUpColorBack; - ppd.colorText = options.iPopUpColorFore; - } - ppd.PluginWindowProc = (WNDPROC)PopupDlgProc; - ppd.PluginData = NULL; - ppd.iSeconds = options.iPopUpDelay; - - CallService(MS_POPUP_ADDPOPUPEX, (WPARAM) &ppd, 0); - - } - - if (options.iShowEvent > 0) - { - CLISTEVENT cle = {0}; - - cle.cbSize = sizeof(cle); - cle.hContact = hContact; - cle.hIcon = hIcon; - cle.pszService = (char *)"BuddyExpectator/actionReturned"; - - char* nick = (char*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME,(WPARAM)hContact,0); - char tmpMsg[512]; - mir_snprintf(tmpMsg, 512, "%s %s", nick, message); - cle.pszTooltip = tmpMsg; - - CallServiceSync(MS_CLIST_ADDEVENT, 0, (LPARAM) &cle); - } -} - -void GoneNotify(HANDLE hContact, char *message) -{ - if (DBGetContactSettingByte(hContact, "CList", "NotOnList", 0) == 1 || DBGetContactSettingByte(hContact, "CList", "Hidden", 0) == 1) - return; - - if (options.iShowPopUp2 > 0) - { - // Display PopUp - POPUPDATAT_V2 ppd = {0}; - ppd.cbSize = sizeof(POPUPDATAT_V2); - - ppd.lchContact = hContact; - ppd.lchIcon = hIcon; - strncpy(ppd.lpzContactName, (char*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME,(WPARAM)hContact,0), MAX_CONTACTNAME); - strncpy(ppd.lpzText, message, MAX_SECONDLINE); - if (!options.iUsePopupColors) - { - ppd.colorBack = options.iPopUpColorBack; - ppd.colorText = options.iPopUpColorFore; - } - ppd.PluginWindowProc = (WNDPROC)PopupDlgProcNoSet; - ppd.PluginData = NULL; - ppd.iSeconds = options.iPopUpDelay; - - CallService(MS_POPUP_ADDPOPUPEX, (WPARAM) &ppd, 0); - } - - if (options.iShowEvent2 > 0) - { - CLISTEVENT cle = {0}; - - cle.cbSize = sizeof(cle); - cle.hContact = hContact; - cle.hIcon = hIcon; - cle.pszService = (char *)"BuddyExpectator/actionStillAbsent"; - - char* nick = (char*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME,(WPARAM)hContact,0); - char tmpMsg[512]; - mir_snprintf(tmpMsg, 512, "%s %s", nick, message); - cle.pszTooltip = tmpMsg; - - CallServiceSync(MS_CLIST_ADDEVENT, 0, (LPARAM) &cle); - } -} - -/** - * Miss you action (clist event click) - * when called from popup, wParam = (HANDLE)hContact and lParam == 0, - * when called from clist event, wParam = hWndCList, lParam = &CLISTEVENT - */ -INT_PTR MissYouAction(WPARAM wParam, LPARAM lParam) -{ - HANDLE hContact; - if (lParam) - { - CLISTEVENT* cle = (CLISTEVENT*)lParam; - hContact = cle->hContact; - } else - hContact = (HANDLE)wParam; - - CallService(MS_MSG_SENDMESSAGE, (WPARAM)hContact, 0); - - return 0; -} - -/** - * Contact returned action (clist event click) - * when called from popup, wParam = (HANDLE)hContact and lParam == 0, - * when called from clist event, wParam = hWndCList, lParam = &CLISTEVENT - */ -INT_PTR ContactReturnedAction(WPARAM wParam, LPARAM lParam) -{ - HANDLE hContact; - if (lParam) - { - CLISTEVENT* cle = (CLISTEVENT*)lParam; - hContact = cle->hContact; - } else - hContact = (HANDLE)wParam; - - if (options.iShowMessageWindow>0) - { - CallService(MS_MSG_SENDMESSAGE, (WPARAM)hContact, 0); - } - - if (options.iShowUDetails>0) - { - CallService(MS_USERINFO_SHOWDIALOG, (WPARAM)hContact, 0); - } - - setLastSeen(hContact); - - return 0; -} - -/** - * Contact not returned action (clist event click) - * when called from popup, wParam = (HANDLE)hContact and lParam == 0, - * when called from clist event, wParam = hWndCList, lParam = &CLISTEVENT - */ -INT_PTR ContactStillAbsentAction(WPARAM wParam, LPARAM lParam) -{ - HANDLE hContact; - if (lParam) - { - CLISTEVENT* cle = (CLISTEVENT*)lParam; - hContact = cle->hContact; - } else - hContact = (HANDLE)wParam; - - switch (options.action2) - { - case GCA_DELETE: - CallService(MS_DB_CONTACT_DELETE, (WPARAM)hContact, 0); - break; - case GCA_UDETAILS: - CallService(MS_USERINFO_SHOWDIALOG, (WPARAM)hContact, 0); - break; - case GCA_MESSAGE: - CallService(MS_MSG_SENDMESSAGE, (WPARAM)hContact, 0); - break; - case GCA_NOACTION: - break; - } - - return 0; -} - -/** - * Load icons either from icolib or built in - */ -int onIconsChanged(WPARAM wParam, LPARAM lParam) -{ - hIcon = (HICON)CallService(MS_SKIN2_GETICON, 0, (LPARAM)"main_icon"); - return 0; -} - -/** - * Menu item click action - */ -INT_PTR MenuMissYouClick(WPARAM wParam, LPARAM lParam) -{ - if (DBGetContactSettingByte((HANDLE)wParam, MODULE_NAME, "MissYou", 0)) - { - DBWriteContactSettingByte((HANDLE)wParam, MODULE_NAME, "MissYou", 0); - if (options.MissYouIcon) CallService(MS_CLIST_EXTRA_SET_ICON, (WPARAM) wParam, (LPARAM) &g_IECClear); - } - else - { - DBWriteContactSettingByte((HANDLE)wParam, MODULE_NAME, "MissYou", 1); - if (options.MissYouIcon) CallService(MS_CLIST_EXTRA_SET_ICON, (WPARAM) wParam, (LPARAM) &g_IECMissYou); - } - - return 0; -} - -/** - * Menu is about to appear - */ -int onPrebuildContactMenu(WPARAM wParam, LPARAM lParam) -{ - char *proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, wParam, 0); - if (!proto) return 0; - - CLISTMENUITEM mi = {0}; - mi.cbSize = sizeof(CLISTMENUITEM); - - if (DBGetContactSettingByte((HANDLE)wParam, proto, "ChatRoom", 0) || !(CallProtoService(proto, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_IMSEND)) - mi.flags = CMIM_FLAGS | CMIF_HIDDEN; - else - mi.flags = CMIM_FLAGS; - - if (DBGetContactSettingByte((HANDLE)wParam, MODULE_NAME, "MissYou", 0)) - { - mi.flags |= CMIM_ICON | CMIM_NAME | CMIF_ICONFROMICOLIB; - mi.pszName = Translate("Disable Miss You"); - mi.icolibItem = hEnabledIcon; - } - else - { - mi.flags |= CMIM_ICON | CMIM_NAME | CMIF_ICONFROMICOLIB; - mi.pszName = Translate("Enable Miss You"); - mi.icolibItem = hDisabledIcon; - } - - CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hContactMenu, (LPARAM)&mi); - - return 0; -} - -int onExtraImageApplying(WPARAM wParam, LPARAM lParam) -{ - if (DBGetContactSettingByte((HANDLE)wParam,MODULE_NAME,"MissYou",0)) - CallService(MS_CLIST_EXTRA_SET_ICON, (WPARAM) wParam, (LPARAM) &g_IECMissYou); - - return 0; -} - -int onExtraImageListRebuild(WPARAM wParam, LPARAM lParam) -{ - g_IECMissYou.cbSize = sizeof(IconExtraColumn); - g_IECMissYou.ColumnType = options.MissYouIcon; - - if (ServiceExists(MS_CLIST_EXTRA_ADD_ICON)) - g_IECMissYou.hImage = (HANDLE)CallService(MS_CLIST_EXTRA_ADD_ICON, (WPARAM)(HICON) CallService(MS_SKIN2_GETICON, 0, (LPARAM)"enabled_icon"), (LPARAM)0); - - return 0; -} - -/** - * ContactSettingChanged callback - */ -int SettingChanged(WPARAM wParam, LPARAM lParam) -{ - HANDLE hContact = (HANDLE) wParam; - DBCONTACTWRITESETTING *inf = (DBCONTACTWRITESETTING *) lParam; - - if (hContact == NULL || inf->value.type == DBVT_DELETED || strcmp(inf->szSetting, "Status") != 0) - return 0; - - if (DBGetContactSettingByte(hContact, "CList", "NotOnList", 0) == 1) - return 0; - - char *proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); - if (proto == 0 || (DBGetContactSettingByte(hContact, proto, "ChatRoom", 0) == 1) - || !(CallProtoService(proto, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_IMSEND)) - return 0; - - int currentStatus = inf->value.wVal; - int prevStatus = DBGetContactSettingWord(hContact, "UserOnline", "OldStatus", ID_STATUS_OFFLINE); - - if (currentStatus == prevStatus) - { - return 0; - } - - // Last status - DBWriteContactSettingDword(hContact, MODULE_NAME, "LastStatus", prevStatus); - - if (prevStatus == ID_STATUS_OFFLINE) - { - if (DBGetContactSettingByte(hContact, MODULE_NAME, "MissYou", 0)) - { - // Display PopUp - POPUPDATAT_V2 ppd = {0}; - ppd.cbSize = sizeof(POPUPDATAT_V2); - - ppd.lchContact = hContact; - ppd.lchIcon = (HICON)CallService(MS_SKIN2_GETICON, 0, (LPARAM)"enabled_icon"); - strncpy(ppd.lpzContactName, (char*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME,(WPARAM)hContact,0), MAX_CONTACTNAME); - strncpy(ppd.lpzText, Translate("You awaited this contact!"), MAX_SECONDLINE); - if (!options.iUsePopupColors) - { - ppd.colorBack = options.iPopUpColorBack; - ppd.colorText = options.iPopUpColorFore; - } - ppd.PluginWindowProc = (WNDPROC)MissYouPopupDlgProc; - ppd.PluginData = NULL; - ppd.iSeconds = -1; - - missyouactions[0].flags = PAF_ENABLED; - ppd.lpActions = missyouactions; - ppd.actionCount = 1; - - CallService(MS_POPUP_ADDPOPUPEX, (WPARAM) &ppd, APF_NEWDATA); - - SkinPlaySound("buddyExpectatorMissYou"); - } - } - - if (currentStatus == ID_STATUS_OFFLINE) - { - setLastSeen(hContact); - return 0; - } - - /* - if (CallService(MS_IGNORE_ISIGNORED, (WPARAM) hContact, (LPARAM) IGNOREEVENT_USERONLINE)) - { - setLastSeen(hContact); - return 0; - } - */ - - if (DBGetContactSettingDword(hContact, MODULE_NAME, "LastSeen", (DWORD)-1) == (DWORD)-1 && options.notifyFirstOnline) - { - ReturnNotify(hContact, Translate("has gone online for the first time.")); - - setLastSeen(hContact); - } - - unsigned int AbsencePeriod = DBGetContactSettingDword(hContact, MODULE_NAME, "iAbsencePeriod", options.iAbsencePeriod); - if (isContactGoneFor(hContact, AbsencePeriod)) - { - char* message = Translate("has returned after a long absence."); - time_t tmpTime; - char tmpBuf[251] = {0}; - tmpTime = getLastSeen(hContact); - if (tmpTime != -1) - { - strftime(tmpBuf, 250, Translate("has returned after being absent since %#x"), gmtime(&tmpTime)); - message = tmpBuf; - } - else - { - tmpTime = getLastInputMsg(hContact); - if (tmpTime != -1) - { - strftime(tmpBuf, 250, Translate("has returned after being absent since %#x"), gmtime(&tmpTime)); - message = tmpBuf; - } - } - - ReturnNotify(hContact, message); - - if ((options.iShowMessageWindow == 0 && options.iShowUDetails == 0) || (options.iShowEvent == 0 && options.iShowPopUp == 0)) - { - setLastSeen(hContact); - } - } else - setLastSeen(hContact); - - return 0; -} - -void CALLBACK TimerProc(HWND, UINT, UINT_PTR, DWORD) -{ - HANDLE hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); - char *proto; - while (hContact != 0) - { - proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); - if (proto && (DBGetContactSettingByte(hContact, proto, "ChatRoom", 0) == 0) && (CallProtoService(proto, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_IMSEND) && isContactGoneFor(hContact, options.iAbsencePeriod2) && (DBGetContactSettingByte(hContact, MODULE_NAME, "StillAbsentNotified", 0) == 0)) - { - DBWriteContactSettingByte(hContact, MODULE_NAME, "StillAbsentNotified", 1); - SkinPlaySound("buddyExpectatorStillAbsent"); - - char* message = Translate("has not returned after a long absence."); - time_t tmpTime; - char tmpBuf[251] = {0}; - tmpTime = getLastSeen(hContact); - if (tmpTime != -1) - { - strftime(tmpBuf, 250, Translate("has not returned after being absent since %#x"), gmtime(&tmpTime)); - message = tmpBuf; - } - else - { - tmpTime = getLastInputMsg(hContact); - if (tmpTime != -1) - { - strftime(tmpBuf, 250, Translate("has not returned after being absent since %#x"), gmtime(&tmpTime)); - message = tmpBuf; - } - } - - GoneNotify(hContact, message); - } - - hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM)hContact, 0); - } -} -/** - * Called when all the modules have had their modules loaded event handlers called (dependence of popups on fontservice :( ) - */ -int ModulesLoaded2(WPARAM wParam, LPARAM lParam) -{ - // check for 'still absent' contacts on startup - TimerProc(0, 0, 0, 0); - - return 0; -} - -/** - * Called when all the modules are loaded - */ -int ModulesLoaded(WPARAM wParam, LPARAM lParam) -{ - hEventUserInfoInit = HookEvent(ME_USERINFO_INITIALISE, UserinfoInit); - - // add sounds support - SkinAddNewSoundEx("buddyExpectatorReturn", LPGEN("BuddyExpectator"), LPGEN("Contact returned")); - SkinAddNewSoundEx("buddyExpectatorStillAbsent", LPGEN("BuddyExpectator"), LPGEN("Contact still absent")); - SkinAddNewSoundEx("buddyExpectatorMissYou", LPGEN("BuddyExpectator"), LPGEN("Miss you event")); - SkinAddNewSoundEx("buddyExpectatorHide", LPGEN("BuddyExpectator"), LPGEN("Hide contact event")); - - timer_id = SetTimer(0, 0, 1000 * 60 * 60 * 4, TimerProc); // check every 4 hours - - hModulesLoaded2 = HookEvent(ME_SYSTEM_MODULESLOADED, ModulesLoaded2); - if (options.MissYouIcon) - { - hHookExtraIconsRebuild = HookEvent(ME_CLIST_EXTRA_LIST_REBUILD, onExtraImageListRebuild); - hHookExtraIconsApply = HookEvent(ME_CLIST_EXTRA_IMAGE_APPLY, onExtraImageApplying); - g_IECClear.cbSize = sizeof(IconExtraColumn); - g_IECClear.ColumnType = options.MissYouIcon; - g_IECClear.hImage = (HANDLE) -1; - } - - // IcoLib support - SKINICONDESC sid = {0}; - char szFile[MAX_PATH]; - GetModuleFileNameA(hInst, szFile, MAX_PATH); - sid.pszDefaultFile = szFile; - sid.cbSize = sizeof(sid); - sid.pszSection = "BuddyExpectator"; - - sid.pszDescription = "Tray/popup icon"; - sid.pszName = "main_icon"; - sid.iDefaultIndex = -IDI_MAINICON; - Skin_AddIcon(&sid); - - sid.pszDescription = "Enabled"; - sid.pszName = "enabled_icon"; - sid.iDefaultIndex = -IDI_ENABLED; - hEnabledIcon = Skin_AddIcon(&sid); - - sid.pszDescription = "Disabled"; - sid.pszName = "disabled_icon"; - sid.iDefaultIndex = -IDI_DISABLED; - hDisabledIcon = Skin_AddIcon(&sid); - - sid.pszDescription = "Hide"; - sid.pszName = "hide_icon"; - sid.iDefaultIndex = -IDI_HIDE; - Skin_AddIcon(&sid); - - sid.pszDescription = "NeverHide"; - sid.pszName = "neverhide_icon"; - sid.iDefaultIndex = -IDI_NEVERHIDE; - Skin_AddIcon(&sid); - - hIcoLibIconsChanged = HookEvent(ME_SKIN2_ICONSCHANGED, onIconsChanged); - - onIconsChanged(0,0); - - if (options.enableMissYou) { - hPrebuildContactMenu = HookEvent(ME_CLIST_PREBUILDCONTACTMENU, onPrebuildContactMenu); - - CLISTMENUITEM mi = {0}; - mi.cbSize = sizeof(CLISTMENUITEM); - mi.flags = CMIF_ICONFROMICOLIB; - mi.icolibItem = hDisabledIcon; - mi.position = 200000; - mi.pszName = Translate("Enable Miss You"); - mi.pszService = "BuddyExpectator/actionMissYouClick"; - hContactMenu = Menu_AddContactMenuItem(&mi); - } - - // Updater plugin support - if (ServiceExists(MS_UPDATE_REGISTER)) - { - // register with updater - Update update = {0}; - char szVersion[16]; - - update.cbSize = sizeof(Update); - - update.szComponentName = pluginInfo.shortName; - update.pbVersion = (BYTE *)CreateVersionString(pluginInfo.version, szVersion); - update.cpbVersion = (int)strlen((char *)update.pbVersion); - - update.szUpdateURL = UPDATER_AUTOREGISTER; - - // these are the three lines that matter - the archive, the page containing the version string, and the text (or data) - // before the version that we use to locate it on the page - // (note that if the update URL and the version URL point to standard file listing entries, the backend xml - // data will be used to check for updates rather than the actual web page - this is not true for beta urls) - update.szBetaUpdateURL = "http://thief.miranda.im/BuddyExpectator.zip"; - update.szBetaVersionURL = "http://thief.miranda.im/updater/buddyexpectator_version.txt"; - update.szBetaChangelogURL = "http://thief.miranda.im"; - update.pbBetaVersionPrefix = (BYTE *)"Buddy Expectator "; - - update.cpbBetaVersionPrefix = (int)strlen((char *)update.pbBetaVersionPrefix); - - CallService(MS_UPDATE_REGISTER, 0, (WPARAM)&update); - } - - missyouactions[0].cbSize = sizeof(POPUPACTION); - missyouactions[0].lchIcon = (HICON)CallService(MS_SKIN2_GETICON, 0, (LPARAM)"disabled_icon"); - lstrcpy(missyouactions[0].lpzTitle, Translate("Disable Miss You")); - missyouactions[0].wParam = missyouactions[0].lParam = 1; - - hideactions[0].cbSize = sizeof(POPUPACTION); - hideactions[0].lchIcon = (HICON)CallService(MS_SKIN2_GETICON, 0, (LPARAM)"hide_icon"); - lstrcpy(hideactions[0].lpzTitle, Translate("Hide contact")); - hideactions[0].wParam = hideactions[0].lParam = 2; - - hideactions[1].cbSize = sizeof(POPUPACTION); - hideactions[1].lchIcon = (HICON)CallService(MS_SKIN2_GETICON, 0, (LPARAM)"neverhide_icon"); - lstrcpy(hideactions[1].lpzTitle, Translate("Never hide this contact")); - hideactions[1].wParam = hideactions[1].lParam = 3; - - return 0; -} - -extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD mirandaVersion) -{ - return &pluginInfo; -} - -int ContactAdded(WPARAM wParam, LPARAM lParam) -{ - DBWriteContactSettingDword((HANDLE)wParam, MODULE_NAME, "CreationTime", (DWORD)time(0)); - return 0; -} - -int onSystemOKToExit(WPARAM wParam,LPARAM lParam) -{ - UnhookEvent(hEventContactSetting); - UnhookEvent(hEventContactAdded); - UnhookEvent(hEventUserInfoInit); - if (hPrebuildContactMenu) UnhookEvent(hPrebuildContactMenu); - UnhookEvent(hIcoLibIconsChanged); - UnhookEvent(hModulesLoaded); - UnhookEvent(hModulesLoaded2); - UnhookEvent(hSystemOKToExit); - UnhookEvent(hHookExtraIconsRebuild); - UnhookEvent(hHookExtraIconsApply); - - DestroyServiceFunction(hContactReturnedAction); - DestroyServiceFunction(hContactStillAbsentAction); - DestroyServiceFunction(hMissYouAction); - DestroyServiceFunction(hMenuMissYouClick); - - DeinitOptions(); - - if (hIcoLibIconsChanged) - CallService(MS_SKIN2_RELEASEICON, (WPARAM)hIcon, 0); - else - DestroyIcon(hIcon); - - return 0; -} - -extern "C" int __declspec(dllexport) Load(void) -{ - mir_getLP(&pluginInfo); - - setlocale(LC_ALL, "English"); // Set English locale - - InitOptions(); - - hContactReturnedAction = CreateServiceFunction("BuddyExpectator/actionReturned", ContactReturnedAction); - hContactStillAbsentAction = CreateServiceFunction("BuddyExpectator/actionStillAbsent", ContactStillAbsentAction); - hMissYouAction = CreateServiceFunction("BuddyExpectator/actionMissYou", MissYouAction); - hMenuMissYouClick = CreateServiceFunction("BuddyExpectator/actionMissYouClick", MenuMissYouClick); - - hEventContactSetting = HookEvent(ME_DB_CONTACT_SETTINGCHANGED, SettingChanged); - hModulesLoaded = HookEvent(ME_SYSTEM_MODULESLOADED, ModulesLoaded); - hSystemOKToExit = HookEvent(ME_SYSTEM_OKTOEXIT,onSystemOKToExit); - - hEventContactAdded = HookEvent(ME_DB_CONTACT_ADDED, ContactAdded); - - // ensure all contacts are timestamped - DBVARIANT dbv; - HANDLE hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); - DWORD current_time = (DWORD)time(0); - while (hContact != 0) - { - if (!DBGetContactSetting(hContact, MODULE_NAME, "CreationTime", &dbv)) - DBFreeVariant(&dbv); - else - DBWriteContactSettingDword(hContact, MODULE_NAME, "CreationTime", current_time); - - hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM)hContact, 0); - } - - return 0; -} - -extern "C" int __declspec(dllexport) Unload(void) -{ - KillTimer(0, timer_id); - - return 0; -} - diff --git a/plugins/BuddyExpectator/BuddyExpectator.rc b/plugins/BuddyExpectator/BuddyExpectator.rc deleted file mode 100644 index 39584af909..0000000000 --- a/plugins/BuddyExpectator/BuddyExpectator.rc +++ /dev/null @@ -1,216 +0,0 @@ -// Microsoft Visual C++ generated resource script. -// -#include "resource.h" - -#define APSTUDIO_READONLY_SYMBOLS -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 2 resource. -// -#include "afxres.h" - -///////////////////////////////////////////////////////////////////////////// -#undef APSTUDIO_READONLY_SYMBOLS - -///////////////////////////////////////////////////////////////////////////// -// English (U.S.) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -#ifdef _WIN32 -LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US -#pragma code_page(1252) -#endif //_WIN32 - -#ifdef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// TEXTINCLUDE -// - -1 TEXTINCLUDE -BEGIN - "resource.h\0" -END - -2 TEXTINCLUDE -BEGIN - "#include ""afxres.h""\r\n" - "\0" -END - -3 TEXTINCLUDE -BEGIN - "\r\n" - "\0" -END - -#endif // APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// -// Dialog -// - -IDD_OPTIONSPANEL DIALOGEX 0, 0, 227, 219 -STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD -FONT 8, "MS Shell Dlg", 400, 0, 0xCC -BEGIN - LTEXT "When a contact returns after ",IDC_STATIC,21,16,112,8 - EDITTEXT IDC_EDIT_ABSENCE,137,13,22,13,ES_AUTOHSCROLL - COMBOBOX IDC_COMBO_PERIOD,161,13,49,51,CBS_DROPDOWNLIST | - WS_TABSTOP - CONTROL "Show a popup",IDC_CHECK_POPUP,"Button",BS_AUTOCHECKBOX | - WS_TABSTOP,21,38,189,10 - CONTROL "Add an event (flashing icon) to the contact", - IDC_CHECK_FLASHICON,"Button",BS_AUTOCHECKBOX | - WS_TABSTOP,21,51,187,10 - LTEXT "On event action (double click) or popup click:", - IDC_STATIC,21,63,187,8 - CONTROL "Open User Details",IDC_CHECK_UDETAILS,"Button", - BS_AUTOCHECKBOX | WS_TABSTOP,32,75,176,10 - CONTROL "Open message window",IDC_CHECK_MSGWINDOW,"Button", - BS_AUTOCHECKBOX | WS_TABSTOP,32,86,176,10 - GROUPBOX "Return notification",IDC_STATIC,14,3,199,95 - LTEXT "When a contact is absent for",IDC_STATIC,20,114,112,8 - EDITTEXT IDC_EDIT_ABSENCE2,136,111,22,13,ES_AUTOHSCROLL - COMBOBOX IDC_COMBO_PERIOD2,160,111,49,51,CBS_DROPDOWNLIST | - WS_TABSTOP - GROUPBOX "Long time no see",IDC_STATIC,13,102,199,94 - CONTROL "or comes online for the first time", - IDC_CHECK_FIRSTSIGHT,"Button",BS_AUTOCHECKBOX | - WS_TABSTOP,32,27,176,10 - CONTROL "Show a popup",IDC_CHECK_POPUP2,"Button",BS_AUTOCHECKBOX | - WS_TABSTOP,20,127,189,10 - CONTROL "Add an event (flashing icon) to the contact", - IDC_CHECK_FLASHICON2,"Button",BS_AUTOCHECKBOX | - WS_TABSTOP,20,140,187,10 - LTEXT "On event action (double click) or popup click:", - IDC_STATIC,20,152,187,8 - CONTROL "Enable ""Miss you"" feature",IDC_CHECK_MISSYOU,"Button", - BS_AUTOCHECKBOX | WS_TABSTOP,20,201,186,9 - EDITTEXT IDC_EDIT_SILENTFOR,135,179,22,13,ES_AUTOHSCROLL - COMBOBOX IDC_COMBO_PERIOD3,159,179,49,51,CBS_DROPDOWNLIST | - WS_TABSTOP - CONTROL "Hide when no messages for",IDC_CHECK_NOMSGS,"Button", - BS_AUTOCHECKBOX | WS_TABSTOP,20,180,113,11 - COMBOBOX IDC_COMBO_ACTIONS,32,163,100,57,CBS_DROPDOWNLIST | - WS_TABSTOP -END - -IDD_POPUPPANEL DIALOGEX 0, 0, 190, 134 -STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD -FONT 8, "MS Shell Dlg", 0, 0, 0x0 -BEGIN - GROUPBOX "Colors",IDC_STATIC,7,7,176,42 - LTEXT "Background",IDC_STATIC,17,19,46,8 - LTEXT "Text",IDC_STATIC,17,34,46,8 - CONTROL "",IDC_COLOR_BGR,"ColourPicker",WS_TABSTOP,61,17,26,12 - CONTROL "",IDC_COLOR_FRG,"ColourPicker",WS_TABSTOP,61,32,26,12 - CONTROL "Use Popups colors",IDC_COLORS_POPUP,"Button", - BS_AUTOCHECKBOX | WS_TABSTOP,94,17,82,12 - CONTROL "Use Windows colors",IDC_COLORS_WIN,"Button", - BS_AUTOCHECKBOX | WS_TABSTOP,94,33,82,9 - GROUPBOX "Delay",IDC_STATIC,7,50,176,52 - CONTROL "Default",IDC_DELAY_DEF,"Button",BS_AUTORADIOBUTTON | - WS_GROUP | WS_TABSTOP,18,61,120,10 - CONTROL "Custom",IDC_DELAY_CUST,"Button",BS_AUTORADIOBUTTON,18, - 74,62,10 - CONTROL "Permanent",IDC_DELAY_PERM,"Button",BS_AUTORADIOBUTTON, - 18,87,119,10 - EDITTEXT IDC_EDIT_POPUPDELAY,81,72,30,14,ES_AUTOHSCROLL - LTEXT "sec",IDC_STATIC,116,75,34,8 - PUSHBUTTON "Preview",IDC_PREVIEW,58,106,75,17 -END - -IDD_USERINFO DIALOGEX 0, 0, 222, 132 -STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD -FONT 8, "MS Shell Dlg", 0, 0, 0x0 -BEGIN - LTEXT "Last seen online:",IDC_STATIC,7,7,85,8 - EDITTEXT IDC_EDIT_LASTSEEN,99,7,116,12,ES_AUTOHSCROLL | - ES_READONLY | NOT WS_BORDER - LTEXT "Last input message:",IDC_STATIC,7,22,85,8 - EDITTEXT IDC_EDIT_LASTINPUT,99,22,116,12,ES_AUTOHSCROLL | - ES_READONLY | NOT WS_BORDER - LTEXT "Custom absence period:",IDC_STATIC,7,36,85,12 - EDITTEXT IDC_EDITABSENCE,101,35,31,12,ES_AUTOHSCROLL - CONTROL "",IDC_SPINABSENCE,"msctls_updown32",UDS_SETBUDDYINT | - UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | - UDS_NOTHOUSANDS,163,14,8,13 - LTEXT "days",IDC_STATIC,138,36,77,10 - EDITTEXT IDC_EDIT_WILLNOTICE,7,93,208,30,ES_MULTILINE | - ES_READONLY | NOT WS_BORDER - CONTROL "Never hide this contact",IDC_CHECK_NEVERHIDE,"Button", - BS_AUTOCHECKBOX | WS_TABSTOP,7,75,180,12 - CONTROL "Enable Miss You",IDC_CHECK_MISSYOU,"Button", - BS_AUTOCHECKBOX | WS_TABSTOP,7,47,200,19 - CONTROL "Notify always",IDC_CHECK_NOTIFYALWAYS,"Button", - BS_AUTOCHECKBOX | WS_TABSTOP,27,64,188,10 -END - - -///////////////////////////////////////////////////////////////////////////// -// -// DESIGNINFO -// - -#ifdef APSTUDIO_INVOKED -GUIDELINES DESIGNINFO -BEGIN - IDD_OPTIONSPANEL, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 220 - TOPMARGIN, 7 - BOTTOMMARGIN, 217 - END - - IDD_POPUPPANEL, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 183 - TOPMARGIN, 7 - BOTTOMMARGIN, 127 - END - - IDD_USERINFO, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 215 - VERTGUIDE, 92 - VERTGUIDE, 99 - TOPMARGIN, 7 - BOTTOMMARGIN, 125 - END -END -#endif // APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// -// Icon -// - -// Icon with lowest ID value placed first to ensure application icon -// remains consistent on all systems. -IDI_MAINICON ICON "icons\\main.ico" -IDI_ENABLED ICON "icons\\enabled.ico" -IDI_DISABLED ICON "icons\\disabled.ico" -IDI_HIDE ICON "icons\\hide.ico" -IDI_NEVERHIDE ICON "icons\\neverhide.ico" -#endif // English (U.S.) resources -///////////////////////////////////////////////////////////////////////////// - - - -#ifndef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 3 resource. -// - - -///////////////////////////////////////////////////////////////////////////// -#endif // not APSTUDIO_INVOKED - diff --git a/plugins/BuddyExpectator/BuddyExpectator10.vcxproj b/plugins/BuddyExpectator/BuddyExpectator10.vcxproj index b3f50ecaa8..cd2c17d748 100644 --- a/plugins/BuddyExpectator/BuddyExpectator10.vcxproj +++ b/plugins/BuddyExpectator/BuddyExpectator10.vcxproj @@ -78,7 +78,6 @@ MultiThreadedDebugDLL true Level3 - 4996;%(DisableSpecificWarnings) EditAndContinue @@ -101,7 +100,6 @@ true true Level3 - 4996;%(DisableSpecificWarnings) Size @@ -127,7 +125,6 @@ MultiThreadedDebugDLL true Level3 - 4996;%(DisableSpecificWarnings) _DEBUG;%(PreprocessorDefinitions) @@ -149,7 +146,6 @@ true true Level3 - 4996;%(DisableSpecificWarnings) Size @@ -167,16 +163,16 @@ - - + + - + - - - + + + diff --git a/plugins/BuddyExpectator/buddyexpectator-translation.txt b/plugins/BuddyExpectator/buddyexpectator-translation.txt deleted file mode 100644 index d93b7a4e8e..0000000000 --- a/plugins/BuddyExpectator/buddyexpectator-translation.txt +++ /dev/null @@ -1,65 +0,0 @@ -; Common strings that belong to many files -;[Enable Miss You] -;[Never hide this contact] -;[Open User Details] -;[Open message window] -;[You awaited this contact!] -;[days] - -; ../../plugins/BuddyExpectator/BuddyExpectator.cpp -;[%d days since last message] -;[BuddyExpectator] -;[Contact returned] -;[Contact still absent] -;[Disable Miss You] -;[Hide contact] -;[Hide contact event] -;[Hiding %s (%s)] -;[Miss you event] -;[has gone online for the first time.] -;[has not returned after a long absence.] -;[has not returned after being absent since %#x] -;[has returned after a long absence.] -;[has returned after being absent since %#x] - -; ../../plugins/BuddyExpectator/BuddyExpectator.rc -;[Add an event (flashing icon) to the contact] -;[Background] -;[Colors] -;[Custom] -;[Custom absence period:] -;[Default] -;[Delay] -;[Enable \"Miss you\" feature] -;[Hide when no messages for] -;[Last input message:] -;[Last seen online:] -;[Long time no see] -;[Notify always] -;[On event action (double click) or popup click:] -;[Permanent] -;[Preview] -;[Return notification] -;[Show a popup] -;[Text] -;[Use Popups colors] -;[Use Windows colors] -;[When a contact is absent for] -;[When a contact returns after ] -;[or comes online for the first time] -;[sec] - -; ../../plugins/BuddyExpectator/options.cpp -;[Buddy Expectator] -;[Contact name] -;[Delete the contact] -;[Do nothing] -;[Plugins] -;[PopUps] -;[This contact has been absent for an extended period of time.] -;[has returned after being absent since %d days] -;[months] -;[not detected] -;[not found] -;[weeks] -;[years] diff --git a/plugins/BuddyExpectator/common.h b/plugins/BuddyExpectator/common.h deleted file mode 100644 index 09bfd58011..0000000000 --- a/plugins/BuddyExpectator/common.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - Buddy Expectator+ plugin for Miranda-IM (www.miranda-im.org) - (c)2005 Anar Ibragimoff (ai91@mail.ru) - (c)2006 Scott Ellis (mail@scottellis.com.au) - (c)2007 Alexander Turyak (thief@miranda-im.org.ua) - - 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 - - File name : $URL: http://svn.miranda.im/mainrepo/buddyexpectator/trunk/common.h $ - Revision : $Rev: 1392 $ - Last change on : $Date: 2009-04-22 17:46:08 +0300 (Ср, 22 апр 2009) $ - Last change by : $Author: Thief $ -*/ - -#ifndef _COMMON_INC -#define _COMMON_INC -#define MIRANDA_VER 0x0A00 - -#include // needed by m_icolib.h > r9256 -#include -#include -#include -#include -#include -#include "resource.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "m_popup.h" -#include "m_popup2.h" -#include "m_updater.h" -#include "m_cluiframes.h" - -#define MODULE_NAME "BuddyExpectator" - -extern HINSTANCE hInst; - -void CALLBACK TimerProc(HWND, UINT, UINT_PTR, DWORD); -extern DWORD timer_id; - -#endif diff --git a/plugins/BuddyExpectator/docs/buddyexpectator-translation.txt b/plugins/BuddyExpectator/docs/buddyexpectator-translation.txt new file mode 100644 index 0000000000..d93b7a4e8e --- /dev/null +++ b/plugins/BuddyExpectator/docs/buddyexpectator-translation.txt @@ -0,0 +1,65 @@ +; Common strings that belong to many files +;[Enable Miss You] +;[Never hide this contact] +;[Open User Details] +;[Open message window] +;[You awaited this contact!] +;[days] + +; ../../plugins/BuddyExpectator/BuddyExpectator.cpp +;[%d days since last message] +;[BuddyExpectator] +;[Contact returned] +;[Contact still absent] +;[Disable Miss You] +;[Hide contact] +;[Hide contact event] +;[Hiding %s (%s)] +;[Miss you event] +;[has gone online for the first time.] +;[has not returned after a long absence.] +;[has not returned after being absent since %#x] +;[has returned after a long absence.] +;[has returned after being absent since %#x] + +; ../../plugins/BuddyExpectator/BuddyExpectator.rc +;[Add an event (flashing icon) to the contact] +;[Background] +;[Colors] +;[Custom] +;[Custom absence period:] +;[Default] +;[Delay] +;[Enable \"Miss you\" feature] +;[Hide when no messages for] +;[Last input message:] +;[Last seen online:] +;[Long time no see] +;[Notify always] +;[On event action (double click) or popup click:] +;[Permanent] +;[Preview] +;[Return notification] +;[Show a popup] +;[Text] +;[Use Popups colors] +;[Use Windows colors] +;[When a contact is absent for] +;[When a contact returns after ] +;[or comes online for the first time] +;[sec] + +; ../../plugins/BuddyExpectator/options.cpp +;[Buddy Expectator] +;[Contact name] +;[Delete the contact] +;[Do nothing] +;[Plugins] +;[PopUps] +;[This contact has been absent for an extended period of time.] +;[has returned after being absent since %d days] +;[months] +;[not detected] +;[not found] +;[weeks] +;[years] diff --git a/plugins/BuddyExpectator/icons/disabled.ico b/plugins/BuddyExpectator/icons/disabled.ico deleted file mode 100644 index 5280ef1502..0000000000 Binary files a/plugins/BuddyExpectator/icons/disabled.ico and /dev/null differ diff --git a/plugins/BuddyExpectator/icons/enabled.ico b/plugins/BuddyExpectator/icons/enabled.ico deleted file mode 100644 index 316b22b556..0000000000 Binary files a/plugins/BuddyExpectator/icons/enabled.ico and /dev/null differ diff --git a/plugins/BuddyExpectator/icons/hide.ico b/plugins/BuddyExpectator/icons/hide.ico deleted file mode 100644 index deff488a6a..0000000000 Binary files a/plugins/BuddyExpectator/icons/hide.ico and /dev/null differ diff --git a/plugins/BuddyExpectator/icons/main.ico b/plugins/BuddyExpectator/icons/main.ico deleted file mode 100644 index e7e514fc61..0000000000 Binary files a/plugins/BuddyExpectator/icons/main.ico and /dev/null differ diff --git a/plugins/BuddyExpectator/icons/neverhide.ico b/plugins/BuddyExpectator/icons/neverhide.ico deleted file mode 100644 index 8a6347b2d3..0000000000 Binary files a/plugins/BuddyExpectator/icons/neverhide.ico and /dev/null differ diff --git a/plugins/BuddyExpectator/options.cpp b/plugins/BuddyExpectator/options.cpp deleted file mode 100644 index 2771c1aa15..0000000000 --- a/plugins/BuddyExpectator/options.cpp +++ /dev/null @@ -1,627 +0,0 @@ -/* - Buddy Expectator+ plugin for Miranda-IM (www.miranda-im.org) - (c)2005 Anar Ibragimoff (ai91@mail.ru) - (c)2006 Scott Ellis (mail@scottellis.com.au) - (c)2007,2008 Alexander Turyak (thief@miranda-im.org.ua) - - 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 - - File name : $URL: http://svn.miranda.im/mainrepo/buddyexpectator/trunk/options.cpp $ - Revision : $Rev: 1003 $ - Last change on : $Date: 2008-01-12 17:15:47 +0200 (Сб, 12 янв 2008) $ - Last change by : $Author: Thief $ -*/ - -#include "common.h" -#include "options.h" - -#define DEF_COLOR_BACK 0xCEF7AD -#define DEF_COLOR_FORE 0x000000 - -extern HICON hIcon; -extern time_t getLastSeen(HANDLE); -extern time_t getLastInputMsg(HANDLE); -extern bool isContactGoneFor(HANDLE, int); -Options options; - -void LoadOptions() -{ - options.iAbsencePeriod = DBGetContactSettingDword(NULL, MODULE_NAME, "iAbsencePeriod", 14); - options.iAbsencePeriod2 = DBGetContactSettingDword(NULL, MODULE_NAME, "iAbsencePeriod2", 30 * 3); - options.iSilencePeriod = DBGetContactSettingDword(NULL, MODULE_NAME, "iSilencePeriod", 30); - options.iShowPopUp = DBGetContactSettingByte(NULL, MODULE_NAME, "iShowPopUp", 1); - options.iShowEvent = DBGetContactSettingByte(NULL, MODULE_NAME, "iShowEvent", 0); - options.iShowUDetails = DBGetContactSettingByte(NULL, MODULE_NAME, "iShowUDetails", 0); - options.iShowMessageWindow = DBGetContactSettingByte(NULL, MODULE_NAME, "iShowMessageWindow", 1); - options.iPopUpColorBack = DBGetContactSettingDword(NULL, MODULE_NAME, "iPopUpColorBack", DEF_COLOR_BACK); - options.iPopUpColorFore = DBGetContactSettingDword(NULL, MODULE_NAME, "iPopUpColorFore", DEF_COLOR_FORE); - options.iUsePopupColors = DBGetContactSettingByte(NULL, MODULE_NAME, "iUsePopupColors", 0); - options.iUseWinColors = DBGetContactSettingByte(NULL, MODULE_NAME, "iUseWinColors", 0); - options.iPopUpDelay = DBGetContactSettingByte(NULL, MODULE_NAME, "iPopUpDelay", 0); - - options.iShowPopUp2 = DBGetContactSettingByte(NULL, MODULE_NAME, "iShowPopUp2", 1); - options.iShowEvent2 = DBGetContactSettingByte(NULL, MODULE_NAME, "iShowEvent2", 0); - options.action2 = (GoneContactAction)DBGetContactSettingByte(NULL, MODULE_NAME, "Action2", (BYTE)GCA_NOACTION); - options.notifyFirstOnline = DBGetContactSettingByte(NULL, MODULE_NAME, "bShowFirstSight", 0) ? true : false; - options.hideInactive = DBGetContactSettingByte(NULL, MODULE_NAME, "bHideInactive", 0) ? true : false; - options.enableMissYou = DBGetContactSettingByte(NULL, MODULE_NAME, "bMissYouEnabled", 1) ? true : false; - options.MissYouIcon = DBGetContactSettingByte(NULL, MODULE_NAME, "bMissYouIcon", 0); -} - -void SaveOptions() -{ - DBWriteContactSettingDword(NULL, MODULE_NAME, "iAbsencePeriod", options.iAbsencePeriod); - DBWriteContactSettingDword(NULL, MODULE_NAME, "iAbsencePeriod2", options.iAbsencePeriod2); - DBWriteContactSettingDword(NULL, MODULE_NAME, "iSilencePeriod", options.iSilencePeriod); - DBWriteContactSettingByte(NULL, MODULE_NAME, "iShowPopUp", options.iShowPopUp); - DBWriteContactSettingByte(NULL, MODULE_NAME, "iShowEvent", options.iShowEvent); - DBWriteContactSettingByte(NULL, MODULE_NAME, "iShowUDetails", options.iShowUDetails); - DBWriteContactSettingByte(NULL, MODULE_NAME, "iShowMessageWindow", options.iShowMessageWindow); - - DBWriteContactSettingByte(NULL, MODULE_NAME, "iShowPopUp2", options.iShowPopUp2); - DBWriteContactSettingByte(NULL, MODULE_NAME, "iShowEvent2", options.iShowEvent2); - DBWriteContactSettingByte(NULL, MODULE_NAME, "Action2", (BYTE)options.action2); - DBWriteContactSettingByte(NULL, MODULE_NAME, "bShowFirstSight", options.notifyFirstOnline ? 1 : 0); - DBWriteContactSettingByte(NULL, MODULE_NAME, "bHideInactive", options.hideInactive ? 1 : 0); - DBWriteContactSettingByte(NULL, MODULE_NAME, "bMissYouEnabled", options.enableMissYou ? 1 : 0); -} - - -void SavePopupOptions() -{ - DBWriteContactSettingDword(NULL, MODULE_NAME, "iPopUpColorBack", options.iPopUpColorBack); - DBWriteContactSettingDword(NULL, MODULE_NAME, "iPopUpColorFore", options.iPopUpColorFore); - DBWriteContactSettingByte(NULL, MODULE_NAME, "iUsePopupColors", options.iUsePopupColors); - DBWriteContactSettingByte(NULL, MODULE_NAME, "iUseWinColors", options.iUseWinColors); - DBWriteContactSettingByte(NULL, MODULE_NAME, "iPopUpDelay", options.iPopUpDelay); -} - -/** - * Options panel function - */ -static INT_PTR CALLBACK OptionsFrameProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) -{ - switch (uMsg) - { - case WM_INITDIALOG: - TranslateDialogDefault(hwndDlg); - - if (!ServiceExists(MS_POPUP_ADDPOPUP)) - { - EnableWindow(GetDlgItem(hwndDlg, IDC_CHECK_POPUP), FALSE); - } - - //iAbsencePeriod - SendMessage(GetDlgItem(hwndDlg, IDC_COMBO_PERIOD), CB_RESETCONTENT, 0, 0); - SendMessage(GetDlgItem(hwndDlg, IDC_COMBO_PERIOD), CB_ADDSTRING, 0, (LPARAM) Translate("days")); - SendMessage(GetDlgItem(hwndDlg, IDC_COMBO_PERIOD), CB_ADDSTRING, 0, (LPARAM) Translate("weeks")); - SendMessage(GetDlgItem(hwndDlg, IDC_COMBO_PERIOD), CB_ADDSTRING, 0, (LPARAM) Translate("months")); - SendMessage(GetDlgItem(hwndDlg, IDC_COMBO_PERIOD), CB_ADDSTRING, 0, (LPARAM) Translate("years")); - if (options.iAbsencePeriod % 365 == 0) - { - SetDlgItemInt(hwndDlg, IDC_EDIT_ABSENCE, options.iAbsencePeriod/365, FALSE); - SendMessage(GetDlgItem(hwndDlg, IDC_COMBO_PERIOD), CB_SETCURSEL, 3, 0); - } - else if (options.iAbsencePeriod % 30 == 0) - { - SetDlgItemInt(hwndDlg, IDC_EDIT_ABSENCE, options.iAbsencePeriod/30, FALSE); - SendMessage(GetDlgItem(hwndDlg, IDC_COMBO_PERIOD), CB_SETCURSEL, 2, 0); - } - else if (options.iAbsencePeriod % 7 == 0) - { - SetDlgItemInt(hwndDlg, IDC_EDIT_ABSENCE, options.iAbsencePeriod/7, FALSE); - SendMessage(GetDlgItem(hwndDlg, IDC_COMBO_PERIOD), CB_SETCURSEL, 1, 0); - } - else - { - SetDlgItemInt(hwndDlg, IDC_EDIT_ABSENCE, options.iAbsencePeriod, FALSE); - SendMessage(GetDlgItem(hwndDlg, IDC_COMBO_PERIOD), CB_SETCURSEL, 0, 0); - } - - //iAbsencePeriod2 - SendMessage(GetDlgItem(hwndDlg, IDC_COMBO_PERIOD2), CB_RESETCONTENT, 0, 0); - SendMessage(GetDlgItem(hwndDlg, IDC_COMBO_PERIOD2), CB_ADDSTRING, 0, (LPARAM) Translate("days")); - SendMessage(GetDlgItem(hwndDlg, IDC_COMBO_PERIOD2), CB_ADDSTRING, 0, (LPARAM) Translate("weeks")); - SendMessage(GetDlgItem(hwndDlg, IDC_COMBO_PERIOD2), CB_ADDSTRING, 0, (LPARAM) Translate("months")); - SendMessage(GetDlgItem(hwndDlg, IDC_COMBO_PERIOD2), CB_ADDSTRING, 0, (LPARAM) Translate("years")); - if (options.iAbsencePeriod2 % 365 == 0) - { - SetDlgItemInt(hwndDlg, IDC_EDIT_ABSENCE2, options.iAbsencePeriod2/365, FALSE); - SendMessage(GetDlgItem(hwndDlg, IDC_COMBO_PERIOD2), CB_SETCURSEL, 3, 0); - } - else if (options.iAbsencePeriod2 % 30 == 0) - { - SetDlgItemInt(hwndDlg, IDC_EDIT_ABSENCE2, options.iAbsencePeriod2/30, FALSE); - SendMessage(GetDlgItem(hwndDlg, IDC_COMBO_PERIOD2), CB_SETCURSEL, 2, 0); - } - else if (options.iAbsencePeriod2 % 7 == 0) - { - SetDlgItemInt(hwndDlg, IDC_EDIT_ABSENCE2, options.iAbsencePeriod2/7, FALSE); - SendMessage(GetDlgItem(hwndDlg, IDC_COMBO_PERIOD2), CB_SETCURSEL, 1, 0); - } - else - { - SetDlgItemInt(hwndDlg, IDC_EDIT_ABSENCE2,options.iAbsencePeriod2, FALSE); - SendMessage(GetDlgItem(hwndDlg, IDC_COMBO_PERIOD2), CB_SETCURSEL, 0, 0); - } - - //iSilencePeriod - SendMessage(GetDlgItem(hwndDlg, IDC_COMBO_PERIOD3), CB_RESETCONTENT, 0, 0); - SendMessage(GetDlgItem(hwndDlg, IDC_COMBO_PERIOD3), CB_ADDSTRING, 0, (LPARAM) Translate("days")); - SendMessage(GetDlgItem(hwndDlg, IDC_COMBO_PERIOD3), CB_ADDSTRING, 0, (LPARAM) Translate("weeks")); - SendMessage(GetDlgItem(hwndDlg, IDC_COMBO_PERIOD3), CB_ADDSTRING, 0, (LPARAM) Translate("months")); - SendMessage(GetDlgItem(hwndDlg, IDC_COMBO_PERIOD3), CB_ADDSTRING, 0, (LPARAM) Translate("years")); - if (options.iSilencePeriod % 365 == 0) - { - SetDlgItemInt(hwndDlg, IDC_EDIT_SILENTFOR, options.iSilencePeriod/365, FALSE); - SendMessage(GetDlgItem(hwndDlg, IDC_COMBO_PERIOD3), CB_SETCURSEL, 3, 0); - } - else if (options.iSilencePeriod % 30 == 0) - { - SetDlgItemInt(hwndDlg, IDC_EDIT_SILENTFOR, options.iSilencePeriod/30, FALSE); - SendMessage(GetDlgItem(hwndDlg, IDC_COMBO_PERIOD3), CB_SETCURSEL, 2, 0); - } - else if (options.iSilencePeriod % 7 == 0) - { - SetDlgItemInt(hwndDlg, IDC_EDIT_SILENTFOR, options.iSilencePeriod/7, FALSE); - SendMessage(GetDlgItem(hwndDlg, IDC_COMBO_PERIOD3), CB_SETCURSEL, 1, 0); - } - else - { - SetDlgItemInt(hwndDlg, IDC_EDIT_SILENTFOR,options.iSilencePeriod, FALSE); - SendMessage(GetDlgItem(hwndDlg, IDC_COMBO_PERIOD3), CB_SETCURSEL, 0, 0); - } - - SendMessage(GetDlgItem(hwndDlg, IDC_CHECK_POPUP), BM_SETCHECK, options.iShowPopUp > 0 ? BST_CHECKED : BST_UNCHECKED, 0); - SendMessage(GetDlgItem(hwndDlg, IDC_CHECK_FLASHICON), BM_SETCHECK, options.iShowEvent > 0 ? BST_CHECKED : BST_UNCHECKED, 0); - SendMessage(GetDlgItem(hwndDlg, IDC_CHECK_UDETAILS), BM_SETCHECK, (options.iShowUDetails > 0 ? BST_CHECKED : BST_UNCHECKED), 0); - SendMessage(GetDlgItem(hwndDlg, IDC_CHECK_MSGWINDOW), BM_SETCHECK, (options.iShowMessageWindow > 0 ? BST_CHECKED : BST_UNCHECKED), 0); - SendMessage(GetDlgItem(hwndDlg, IDC_CHECK_FIRSTSIGHT), BM_SETCHECK, options.notifyFirstOnline ? BST_CHECKED : BST_UNCHECKED, 0); - SendMessage(GetDlgItem(hwndDlg, IDC_CHECK_NOMSGS), BM_SETCHECK, options.hideInactive ? BST_CHECKED : BST_UNCHECKED, 0); - SendMessage(GetDlgItem(hwndDlg, IDC_CHECK_MISSYOU), BM_SETCHECK, options.enableMissYou ? BST_CHECKED : BST_UNCHECKED, 0); - - SendMessage(GetDlgItem(hwndDlg, IDC_CHECK_POPUP2), BM_SETCHECK, options.iShowPopUp2 > 0 ? BST_CHECKED : BST_UNCHECKED, 0); - SendMessage(GetDlgItem(hwndDlg, IDC_CHECK_FLASHICON2), BM_SETCHECK, options.iShowEvent2 > 0 ? BST_CHECKED : BST_UNCHECKED, 0); - - - SendMessage(GetDlgItem(hwndDlg, IDC_COMBO_ACTIONS), CB_RESETCONTENT, 0, 0); - SendMessage(GetDlgItem(hwndDlg, IDC_COMBO_ACTIONS), CB_ADDSTRING, 0, (LPARAM) Translate("Do nothing")); - SendMessage(GetDlgItem(hwndDlg, IDC_COMBO_ACTIONS), CB_ADDSTRING, 0, (LPARAM) Translate("Delete the contact")); - SendMessage(GetDlgItem(hwndDlg, IDC_COMBO_ACTIONS), CB_ADDSTRING, 0, (LPARAM) Translate("Open User Details")); - SendMessage(GetDlgItem(hwndDlg, IDC_COMBO_ACTIONS), CB_ADDSTRING, 0, (LPARAM) Translate("Open message window")); - SendMessage(GetDlgItem(hwndDlg, IDC_COMBO_ACTIONS), CB_SETCURSEL, options.action2, 0); - - return TRUE; - case WM_COMMAND: - if ((HIWORD(wParam) == BN_CLICKED) || (HIWORD(wParam) == CBN_SELCHANGE) - || ((HIWORD(wParam) == EN_CHANGE) && (SendMessage(GetDlgItem(hwndDlg, IDC_EDIT_ABSENCE), EM_GETMODIFY, 0, 0))) - || ((HIWORD(wParam) == EN_CHANGE) && (SendMessage(GetDlgItem(hwndDlg, IDC_EDIT_ABSENCE2), EM_GETMODIFY, 0, 0))) - || ((HIWORD(wParam) == EN_CHANGE) && (SendMessage(GetDlgItem(hwndDlg, IDC_EDIT_SILENTFOR), EM_GETMODIFY, 0, 0)))) - { - SendMessage(GetParent(hwndDlg),PSM_CHANGED,0,0); - } - break; - case WM_NOTIFY: - { - NMHDR* nmhdr = (NMHDR*)lParam; - switch (nmhdr->code) - { - case PSN_APPLY: - - //iAbsencePeriod - int num = GetDlgItemInt(hwndDlg, IDC_EDIT_ABSENCE, 0, FALSE); - switch (SendMessage(GetDlgItem(hwndDlg, IDC_COMBO_PERIOD), CB_GETCURSEL, 0, 0)) - { - case 1: options.iAbsencePeriod = 7 * num; break; - case 2: options.iAbsencePeriod = 30 * num; break; - case 3: options.iAbsencePeriod = 365 * num; break; - default: options.iAbsencePeriod = num; break; - } - - //iAbsencePeriod2 - num = GetDlgItemInt(hwndDlg, IDC_EDIT_ABSENCE2, 0, FALSE); - switch (SendMessage(GetDlgItem(hwndDlg, IDC_COMBO_PERIOD2), CB_GETCURSEL, 0, 0)) - { - case 1: options.iAbsencePeriod2 = 7 * num; break; - case 2: options.iAbsencePeriod2 = 30 * num; break; - case 3: options.iAbsencePeriod2 = 365 * num; break; - default: options.iAbsencePeriod2 = num; break; - } - - //iSilencePeriod - num = GetDlgItemInt(hwndDlg, IDC_EDIT_SILENTFOR, 0, FALSE); - switch (SendMessage(GetDlgItem(hwndDlg, IDC_COMBO_PERIOD3), CB_GETCURSEL, 0, 0)) - { - case 1: options.iSilencePeriod = 7 * num; break; - case 2: options.iSilencePeriod = 30 * num; break; - case 3: options.iSilencePeriod = 365 * num; break; - default: options.iSilencePeriod = num; break; - } - - options.iShowPopUp = SendMessage(GetDlgItem(hwndDlg, IDC_CHECK_POPUP), BM_GETCHECK, 0, 0) == BST_CHECKED ? 1:0; - options.iShowEvent = SendMessage(GetDlgItem(hwndDlg, IDC_CHECK_FLASHICON), BM_GETCHECK, 0, 0) == BST_CHECKED ? 1:0; - options.iShowUDetails = SendMessage(GetDlgItem(hwndDlg, IDC_CHECK_UDETAILS), BM_GETCHECK, 0, 0) == BST_CHECKED ? 1:0; - options.iShowMessageWindow = SendMessage(GetDlgItem(hwndDlg, IDC_CHECK_MSGWINDOW), BM_GETCHECK, 0, 0) == BST_CHECKED ? 1:0; - options.notifyFirstOnline = SendMessage(GetDlgItem(hwndDlg, IDC_CHECK_FIRSTSIGHT), BM_GETCHECK, 0, 0) == BST_CHECKED ? true : false; - options.hideInactive = SendMessage(GetDlgItem(hwndDlg, IDC_CHECK_NOMSGS), BM_GETCHECK, 0, 0) == BST_CHECKED ? true : false; - options.enableMissYou = SendMessage(GetDlgItem(hwndDlg, IDC_CHECK_MISSYOU), BM_GETCHECK, 0, 0) == BST_CHECKED ? true : false; - - options.iShowPopUp2 = SendMessage(GetDlgItem(hwndDlg, IDC_CHECK_POPUP2), BM_GETCHECK, 0, 0) == BST_CHECKED ? 1:0; - options.iShowEvent2 = SendMessage(GetDlgItem(hwndDlg, IDC_CHECK_FLASHICON2), BM_GETCHECK, 0, 0) == BST_CHECKED ? 1:0; - - options.action2 = (GoneContactAction)SendMessage(GetDlgItem(hwndDlg, IDC_COMBO_ACTIONS), CB_GETCURSEL, 0, 0); - - // save values to the DB - SaveOptions(); - - // clear all notified settings - HANDLE hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); - while (hContact != 0) - { - if(DBGetContactSettingByte(hContact, MODULE_NAME, "StillAbsentNotified", 0)) - DBWriteContactSettingByte(hContact, MODULE_NAME, "StillAbsentNotified", 0); - - hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM)hContact, 0); - } - - // restart timer & run check - KillTimer(0, timer_id); - timer_id = SetTimer(0, 0, 1000 * 60 * 60 * 4, TimerProc); // check every 4 hours - TimerProc(0, 0, 0, 0); - return TRUE; - } - break; - } - } - return 0; -} - -/** - * PopUp Options panel function - */ -static INT_PTR CALLBACK PopUpOptionsFrameProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) -{ - static int ChangeLock = 0; - switch (uMsg) - { - case WM_INITDIALOG: - - ChangeLock++; - TranslateDialogDefault(hwndDlg); - - //iPopUpColorBack - SendDlgItemMessage(hwndDlg, IDC_COLOR_BGR, CPM_SETCOLOUR, 0, options.iPopUpColorBack); - - //iPopUpColorFore - SendDlgItemMessage(hwndDlg, IDC_COLOR_FRG, CPM_SETCOLOUR, 0, options.iPopUpColorFore); - - if (options.iUsePopupColors) - { - CheckDlgButton(hwndDlg, IDC_COLORS_POPUP, BST_CHECKED); - EnableWindow(GetDlgItem(hwndDlg, IDC_COLOR_BGR), false); - EnableWindow(GetDlgItem(hwndDlg, IDC_COLOR_FRG), false); - EnableWindow(GetDlgItem(hwndDlg, IDC_COLORS_WIN), false); - } - - if (options.iUseWinColors) - { - CheckDlgButton(hwndDlg, IDC_COLORS_WIN, BST_CHECKED); - EnableWindow(GetDlgItem(hwndDlg, IDC_COLOR_BGR), false); - EnableWindow(GetDlgItem(hwndDlg, IDC_COLOR_FRG), false); - EnableWindow(GetDlgItem(hwndDlg, IDC_COLORS_POPUP), false); - } - - //iPopUpDelay - SetDlgItemInt(hwndDlg, IDC_EDIT_POPUPDELAY, 5, FALSE); - if (options.iPopUpDelay < 0) - { - SendMessage(GetDlgItem(hwndDlg, IDC_DELAY_PERM), BM_SETCHECK, BST_CHECKED, 0); - EnableWindow(GetDlgItem(hwndDlg, IDC_EDIT_POPUPDELAY), false); - } - else if(options.iPopUpDelay == 0) - { - SendMessage(GetDlgItem(hwndDlg, IDC_DELAY_DEF), BM_SETCHECK, BST_CHECKED, 0); - EnableWindow(GetDlgItem(hwndDlg, IDC_EDIT_POPUPDELAY), false); - } - else - { - SendMessage(GetDlgItem(hwndDlg, IDC_DELAY_CUST), BM_SETCHECK, BST_CHECKED, 0); - SetDlgItemInt(hwndDlg, IDC_EDIT_POPUPDELAY, options.iPopUpDelay, FALSE); - } - - ChangeLock--; - return TRUE; - case WM_COMMAND: - if (LOWORD(wParam) == IDC_PREVIEW) - { - POPUPDATAEX ppd; - ZeroMemory(&ppd, sizeof(ppd)); - - //iPopUpDelay - options.iPopUpDelay = GetDlgItemInt(hwndDlg, IDC_EDIT_POPUPDELAY, 0, FALSE); - if (SendMessage(GetDlgItem(hwndDlg, IDC_DELAY_PERM), BM_GETCHECK, 0, 0) == BST_CHECKED) - { - options.iPopUpDelay = -1; - } - else if (SendMessage(GetDlgItem(hwndDlg, IDC_DELAY_DEF), BM_GETCHECK, 0, 0) == BST_CHECKED) - { - options.iPopUpDelay = 0; - } - ppd.lchContact = NULL; - ppd.lchIcon = hIcon; - strncpy(ppd.lpzContactName, Translate("Contact name"), MAX_CONTACTNAME); - char szPreviewText[50]; - mir_snprintf(szPreviewText,50,Translate("has returned after being absent since %d days"),rand() % 30); - strncpy(ppd.lpzText, szPreviewText, MAX_SECONDLINE); - - // Get current popups colors options - if (IsDlgButtonChecked(hwndDlg, IDC_COLORS_POPUP)) - { - ppd.colorBack = ppd.colorText = 0; - } - else if (IsDlgButtonChecked(hwndDlg, IDC_COLORS_WIN)) - { - ppd.colorBack = GetSysColor(COLOR_BTNFACE); - ppd.colorText = GetSysColor(COLOR_WINDOWTEXT); - } - else - { - ppd.colorBack = SendDlgItemMessage(hwndDlg, IDC_COLOR_BGR, CPM_GETCOLOUR, 0, 0); - ppd.colorText = SendDlgItemMessage(hwndDlg, IDC_COLOR_FRG, CPM_GETCOLOUR, 0, 0); - } - ppd.PluginData = NULL; - ppd.iSeconds = options.iPopUpDelay; - - CallService(MS_POPUP_ADDPOPUPEX, (WPARAM) &ppd, APF_NO_HISTORY); - - strncpy(ppd.lpzText, Translate("You awaited this contact!"), MAX_SECONDLINE); - ppd.lchIcon = (HICON)CallService(MS_SKIN2_GETICON, 0, (LPARAM)"enabled_icon");; - - CallService(MS_POPUP_ADDPOPUPEX, (WPARAM) &ppd, APF_NO_HISTORY); - } - else - { - if ((HIWORD(wParam) == BN_CLICKED) || (HIWORD(wParam) == CBN_SELCHANGE) || ((HIWORD(wParam) == EN_CHANGE) && !ChangeLock)) { - SendMessage(GetParent(hwndDlg),PSM_CHANGED,0,0); - } - if (LOWORD(wParam) == IDC_COLORS_POPUP) - { - if (IsDlgButtonChecked(hwndDlg, IDC_COLORS_POPUP)) - { - EnableWindow(GetDlgItem(hwndDlg, IDC_COLOR_BGR), false); - EnableWindow(GetDlgItem(hwndDlg, IDC_COLOR_FRG), false); - EnableWindow(GetDlgItem(hwndDlg, IDC_COLORS_WIN), false); - } - else - { - EnableWindow(GetDlgItem(hwndDlg, IDC_COLOR_BGR), true); - EnableWindow(GetDlgItem(hwndDlg, IDC_COLOR_FRG), true); - EnableWindow(GetDlgItem(hwndDlg, IDC_COLORS_WIN), true); - } - } - if (LOWORD(wParam) == IDC_COLORS_WIN) - { - if (IsDlgButtonChecked(hwndDlg, IDC_COLORS_WIN)) - { - EnableWindow(GetDlgItem(hwndDlg, IDC_COLOR_BGR), false); - EnableWindow(GetDlgItem(hwndDlg, IDC_COLOR_FRG), false); - EnableWindow(GetDlgItem(hwndDlg, IDC_COLORS_POPUP), false); - } - else - { - EnableWindow(GetDlgItem(hwndDlg, IDC_COLOR_BGR), true); - EnableWindow(GetDlgItem(hwndDlg, IDC_COLOR_FRG), true); - EnableWindow(GetDlgItem(hwndDlg, IDC_COLORS_POPUP), true); - } - } - if (LOWORD(wParam) == IDC_DELAY_DEF || LOWORD(wParam) == IDC_DELAY_PERM) - { - EnableWindow(GetDlgItem(hwndDlg, IDC_EDIT_POPUPDELAY), false); - } - else if (LOWORD(wParam) == IDC_DELAY_CUST) - { - EnableWindow(GetDlgItem(hwndDlg, IDC_EDIT_POPUPDELAY), true); - } - } - - break; - case WM_NOTIFY:{ - NMHDR* nmhdr = (NMHDR*)lParam; - switch (nmhdr->code) - { - case PSN_APPLY: - - if (IsDlgButtonChecked(hwndDlg, IDC_COLORS_POPUP)) - { - options.iUsePopupColors = 1; - options.iUseWinColors = 0; - } - else if (IsDlgButtonChecked(hwndDlg, IDC_COLORS_WIN)) - { - options.iUseWinColors = 1; - options.iUsePopupColors = 0; - options.iPopUpColorBack = GetSysColor(COLOR_BTNFACE); - options.iPopUpColorFore = GetSysColor(COLOR_WINDOWTEXT); - } - else - { - options.iUseWinColors = options.iUsePopupColors = 0; - options.iPopUpColorBack = SendDlgItemMessage(hwndDlg, IDC_COLOR_BGR, CPM_GETCOLOUR, 0, 0); - options.iPopUpColorFore = SendDlgItemMessage(hwndDlg, IDC_COLOR_FRG, CPM_GETCOLOUR, 0, 0); - } - - //iPopUpDelay - options.iPopUpDelay = GetDlgItemInt(hwndDlg, IDC_EDIT_POPUPDELAY, 0, FALSE); - if (SendMessage(GetDlgItem(hwndDlg, IDC_DELAY_PERM), BM_GETCHECK, 0, 0) == BST_CHECKED) - { - options.iPopUpDelay = -1; - } - else if (SendMessage(GetDlgItem(hwndDlg, IDC_DELAY_DEF), BM_GETCHECK, 0, 0) == BST_CHECKED) - { - options.iPopUpDelay = 0; - } - - // save value to the DB - SavePopupOptions(); - - return TRUE; - } - break; - } - } - return 0; -} - -/** - * Init options panel - */ -static int OptionsInit(WPARAM wParam, LPARAM lParam) -{ - OPTIONSDIALOGPAGE odp; - ZeroMemory(&odp, sizeof(odp)); - odp.cbSize = sizeof(odp); - odp.hInstance = hInst; - odp.pszGroup = LPGEN("Plugins"); - odp.pszTemplate = MAKEINTRESOURCE(IDD_OPTIONSPANEL); - odp.pszTitle = LPGEN("Buddy Expectator"); - odp.pfnDlgProc = OptionsFrameProc; - odp.flags = ODPF_BOLDGROUPS; - Options_AddPage(wParam, &odp); - - if (ServiceExists(MS_POPUP_ADDPOPUP)) { - odp.pszGroup = LPGEN("PopUps"); - odp.pszTemplate = MAKEINTRESOURCE(IDD_POPUPPANEL); - odp.pfnDlgProc = PopUpOptionsFrameProc; - Options_AddPage(wParam, &odp); - } - - return 0; -} - -INT_PTR CALLBACK UserinfoDlgProc(HWND hdlg, UINT msg, WPARAM wparam, LPARAM lparam) -{ - switch (msg) - { - case WM_INITDIALOG: - { - time_t tmpTime; - char tmpBuf[51] = {0}; - tmpTime = getLastSeen((HANDLE)lparam); - if (tmpTime == -1) - SetDlgItemText(hdlg, IDC_EDIT_LASTSEEN, Translate("not detected")); - else - { - /* - int status = DBGetContactSettingWord((HANDLE)lparam, MODULE_NAME, "LastStatus", ID_STATUS_OFFLINE); - char *strptr = (char *)CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION, (WPARAM)status, (LPARAM)0); - */ - strftime(tmpBuf, 50, "%#x", gmtime(&tmpTime)); - SetDlgItemText(hdlg, IDC_EDIT_LASTSEEN, tmpBuf); - } - - tmpTime = getLastInputMsg((HANDLE)lparam); - if (tmpTime == -1) - SetDlgItemText(hdlg, IDC_EDIT_LASTINPUT, Translate("not found")); - else - { - strftime(tmpBuf, 50, "%#x", gmtime(&tmpTime)); - SetDlgItemText(hdlg, IDC_EDIT_LASTINPUT, tmpBuf); - } - - unsigned int AbsencePeriod = DBGetContactSettingDword((HANDLE)lparam, MODULE_NAME, "iAbsencePeriod", options.iAbsencePeriod); - - SendDlgItemMessage(hdlg, IDC_SPINABSENCE, UDM_SETRANGE, 0, MAKELONG(999, 1)); - SetDlgItemInt(hdlg, IDC_EDITABSENCE, AbsencePeriod, FALSE); - - if (isContactGoneFor((HANDLE)lparam, options.iAbsencePeriod2)) - { - SetDlgItemText(hdlg, IDC_EDIT_WILLNOTICE, Translate("This contact has been absent for an extended period of time.")); - } - else - { - SetDlgItemText(hdlg, IDC_EDIT_WILLNOTICE, ""); - } - - SendMessage(GetDlgItem(hdlg, IDC_CHECK_MISSYOU), BM_SETCHECK, DBGetContactSettingByte((HANDLE)lparam, MODULE_NAME, "MissYou", 0) ? BST_CHECKED : BST_UNCHECKED, 0); - SendMessage(GetDlgItem(hdlg, IDC_CHECK_NOTIFYALWAYS), BM_SETCHECK, DBGetContactSettingByte((HANDLE)lparam, MODULE_NAME, "MissYouNotifyAlways", 0) ? BST_CHECKED : BST_UNCHECKED, 0); - SendMessage(GetDlgItem(hdlg, IDC_CHECK_NEVERHIDE), BM_SETCHECK, DBGetContactSettingByte((HANDLE)lparam, MODULE_NAME, "NeverHide", 0) ? BST_CHECKED : BST_UNCHECKED, 0); - - TranslateDialogDefault(hdlg); - - return TRUE; - } - - case WM_NOTIFY: - switch (((LPNMHDR)lparam)->idFrom) - { - case 0: - switch (((LPNMHDR)lparam)->code) - { - case (PSN_APPLY): - { - HANDLE hContact = (HANDLE)((LPPSHNOTIFY)lparam)->lParam; - if (hContact) - { - DBWriteContactSettingDword(hContact, MODULE_NAME, "iAbsencePeriod", GetDlgItemInt(hdlg, IDC_EDITABSENCE, 0, FALSE)); - DBWriteContactSettingByte(hContact, MODULE_NAME, "MissYou", (SendMessage(GetDlgItem(hdlg, IDC_CHECK_MISSYOU), BM_GETCHECK, 0, 0) == BST_CHECKED) ? 1 : 0); - DBWriteContactSettingByte(hContact, MODULE_NAME, "MissYouNotifyAlways", (SendMessage(GetDlgItem(hdlg, IDC_CHECK_NOTIFYALWAYS), BM_GETCHECK, 0, 0) == BST_CHECKED) ? 1 : 0); - DBWriteContactSettingByte(hContact, MODULE_NAME, "NeverHide", (SendMessage(GetDlgItem(hdlg, IDC_CHECK_NEVERHIDE), BM_GETCHECK, 0, 0) == BST_CHECKED) ? 1 : 0); - } - break; - } - } - break; - } - break; - - case WM_COMMAND: - if (wparam == MAKEWPARAM(IDC_EDITABSENCE, EN_CHANGE)) - SendMessage(GetParent(hdlg), PSM_CHANGED, 0, 0); - else if (LOWORD(wparam) == IDCANCEL) - SendMessage(GetParent(hdlg), msg, wparam, lparam); - break; - } - - return FALSE; -} - -int UserinfoInit(WPARAM wparam, LPARAM lparam) -{ - if (lparam > 0) - { - OPTIONSDIALOGPAGE uip = {0}; - uip.cbSize = sizeof(uip); - uip.hInstance = hInst; - uip.pszTemplate = MAKEINTRESOURCE(IDD_USERINFO); - uip.pszTitle = Translate("Buddy Expectator"); - uip.pfnDlgProc = UserinfoDlgProc; - - UserInfo_AddPage(wparam, &uip); - } - return 0; -} - - -HANDLE hEventOptInitialise; -void InitOptions() -{ - LoadOptions(); - hEventOptInitialise = HookEvent(ME_OPT_INITIALISE, OptionsInit); -} - -void DeinitOptions() -{ - UnhookEvent(hEventOptInitialise); -} diff --git a/plugins/BuddyExpectator/options.h b/plugins/BuddyExpectator/options.h deleted file mode 100644 index ade65c50e6..0000000000 --- a/plugins/BuddyExpectator/options.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - Buddy Expectator+ plugin for Miranda-IM (www.miranda-im.org) - (c)2005 Anar Ibragimoff (ai91@mail.ru) - (c)2006 Scott Ellis (mail@scottellis.com.au) - (c)2007,2008 Alexander Turyak (thief@miranda-im.org.ua) - - 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 - - File name : $URL: http://svn.miranda.im/mainrepo/buddyexpectator/trunk/options.h $ - Revision : $Rev: 1003 $ - Last change on : $Date: 2008-01-12 17:15:47 +0200 (Сб, 12 янв 2008) $ - Last change by : $Author: Thief $ -*/ - -#ifndef _OPTIONS_INC -#define _OPTIONS_INC - -typedef enum GoneContactAction { GCA_NOACTION, GCA_DELETE, GCA_UDETAILS, GCA_MESSAGE }; - -typedef struct { - int iAbsencePeriod; // notify period for returning contacts - int iShowPopUp; - int iShowEvent; - int iShowUDetails; - int iShowMessageWindow; - - bool notifyFirstOnline; - bool enableMissYou; - bool hideInactive; - byte MissYouIcon; - - int iAbsencePeriod2; // notify period for contacts that have remained away - int iShowPopUp2; - int iShowEvent2; - GoneContactAction action2; - - int iSilencePeriod; // notify period for contacts that didn't send messages - - int iPopUpColorBack; - int iPopUpColorFore; - int iPopUpDelay; - int iUsePopupColors; - int iUseWinColors; - -} Options; - -extern Options options; - -void InitOptions(); -void DeinitOptions(); - -#endif diff --git a/plugins/BuddyExpectator/res/BuddyExpectator.rc b/plugins/BuddyExpectator/res/BuddyExpectator.rc new file mode 100644 index 0000000000..50cad34afc --- /dev/null +++ b/plugins/BuddyExpectator/res/BuddyExpectator.rc @@ -0,0 +1,216 @@ +// Microsoft Visual C++ generated resource script. +// +#include "..\src\resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "afxres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +#ifdef _WIN32 +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US +#pragma code_page(1252) +#endif //_WIN32 + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "..\src\resource.h\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Dialog +// + +IDD_OPTIONSPANEL DIALOGEX 0, 0, 227, 219 +STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD +FONT 8, "MS Shell Dlg", 400, 0, 0xCC +BEGIN + LTEXT "When a contact returns after ",IDC_STATIC,21,16,112,8 + EDITTEXT IDC_EDIT_ABSENCE,137,13,22,13,ES_AUTOHSCROLL + COMBOBOX IDC_COMBO_PERIOD,161,13,49,51,CBS_DROPDOWNLIST | + WS_TABSTOP + CONTROL "Show a popup",IDC_CHECK_POPUP,"Button",BS_AUTOCHECKBOX | + WS_TABSTOP,21,38,189,10 + CONTROL "Add an event (flashing icon) to the contact", + IDC_CHECK_FLASHICON,"Button",BS_AUTOCHECKBOX | + WS_TABSTOP,21,51,187,10 + LTEXT "On event action (double click) or popup click:", + IDC_STATIC,21,63,187,8 + CONTROL "Open User Details",IDC_CHECK_UDETAILS,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,32,75,176,10 + CONTROL "Open message window",IDC_CHECK_MSGWINDOW,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,32,86,176,10 + GROUPBOX "Return notification",IDC_STATIC,14,3,199,95 + LTEXT "When a contact is absent for",IDC_STATIC,20,114,112,8 + EDITTEXT IDC_EDIT_ABSENCE2,136,111,22,13,ES_AUTOHSCROLL + COMBOBOX IDC_COMBO_PERIOD2,160,111,49,51,CBS_DROPDOWNLIST | + WS_TABSTOP + GROUPBOX "Long time no see",IDC_STATIC,13,102,199,94 + CONTROL "or comes online for the first time", + IDC_CHECK_FIRSTSIGHT,"Button",BS_AUTOCHECKBOX | + WS_TABSTOP,32,27,176,10 + CONTROL "Show a popup",IDC_CHECK_POPUP2,"Button",BS_AUTOCHECKBOX | + WS_TABSTOP,20,127,189,10 + CONTROL "Add an event (flashing icon) to the contact", + IDC_CHECK_FLASHICON2,"Button",BS_AUTOCHECKBOX | + WS_TABSTOP,20,140,187,10 + LTEXT "On event action (double click) or popup click:", + IDC_STATIC,20,152,187,8 + CONTROL "Enable ""Miss you"" feature",IDC_CHECK_MISSYOU,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,20,201,186,9 + EDITTEXT IDC_EDIT_SILENTFOR,135,179,22,13,ES_AUTOHSCROLL + COMBOBOX IDC_COMBO_PERIOD3,159,179,49,51,CBS_DROPDOWNLIST | + WS_TABSTOP + CONTROL "Hide when no messages for",IDC_CHECK_NOMSGS,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,20,180,113,11 + COMBOBOX IDC_COMBO_ACTIONS,32,163,100,57,CBS_DROPDOWNLIST | + WS_TABSTOP +END + +IDD_POPUPPANEL DIALOGEX 0, 0, 190, 134 +STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD +FONT 8, "MS Shell Dlg", 0, 0, 0x0 +BEGIN + GROUPBOX "Colors",IDC_STATIC,7,7,176,42 + LTEXT "Background",IDC_STATIC,17,19,46,8 + LTEXT "Text",IDC_STATIC,17,34,46,8 + CONTROL "",IDC_COLOR_BGR,"ColourPicker",WS_TABSTOP,61,17,26,12 + CONTROL "",IDC_COLOR_FRG,"ColourPicker",WS_TABSTOP,61,32,26,12 + CONTROL "Use Popups colors",IDC_COLORS_POPUP,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,94,17,82,12 + CONTROL "Use Windows colors",IDC_COLORS_WIN,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,94,33,82,9 + GROUPBOX "Delay",IDC_STATIC,7,50,176,52 + CONTROL "Default",IDC_DELAY_DEF,"Button",BS_AUTORADIOBUTTON | + WS_GROUP | WS_TABSTOP,18,61,120,10 + CONTROL "Custom",IDC_DELAY_CUST,"Button",BS_AUTORADIOBUTTON,18, + 74,62,10 + CONTROL "Permanent",IDC_DELAY_PERM,"Button",BS_AUTORADIOBUTTON, + 18,87,119,10 + EDITTEXT IDC_EDIT_POPUPDELAY,81,72,30,14,ES_AUTOHSCROLL + LTEXT "sec",IDC_STATIC,116,75,34,8 + PUSHBUTTON "Preview",IDC_PREVIEW,58,106,75,17 +END + +IDD_USERINFO DIALOGEX 0, 0, 222, 132 +STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD +FONT 8, "MS Shell Dlg", 0, 0, 0x0 +BEGIN + LTEXT "Last seen online:",IDC_STATIC,7,7,85,8 + EDITTEXT IDC_EDIT_LASTSEEN,99,7,116,12,ES_AUTOHSCROLL | + ES_READONLY | NOT WS_BORDER + LTEXT "Last input message:",IDC_STATIC,7,22,85,8 + EDITTEXT IDC_EDIT_LASTINPUT,99,22,116,12,ES_AUTOHSCROLL | + ES_READONLY | NOT WS_BORDER + LTEXT "Custom absence period:",IDC_STATIC,7,36,85,12 + EDITTEXT IDC_EDITABSENCE,101,35,31,12,ES_AUTOHSCROLL + CONTROL "",IDC_SPINABSENCE,"msctls_updown32",UDS_SETBUDDYINT | + UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | + UDS_NOTHOUSANDS,163,14,8,13 + LTEXT "days",IDC_STATIC,138,36,77,10 + EDITTEXT IDC_EDIT_WILLNOTICE,7,93,208,30,ES_MULTILINE | + ES_READONLY | NOT WS_BORDER + CONTROL "Never hide this contact",IDC_CHECK_NEVERHIDE,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,7,75,180,12 + CONTROL "Enable Miss You",IDC_CHECK_MISSYOU,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,7,47,200,19 + CONTROL "Notify always",IDC_CHECK_NOTIFYALWAYS,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,27,64,188,10 +END + + +///////////////////////////////////////////////////////////////////////////// +// +// DESIGNINFO +// + +#ifdef APSTUDIO_INVOKED +GUIDELINES DESIGNINFO +BEGIN + IDD_OPTIONSPANEL, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 220 + TOPMARGIN, 7 + BOTTOMMARGIN, 217 + END + + IDD_POPUPPANEL, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 183 + TOPMARGIN, 7 + BOTTOMMARGIN, 127 + END + + IDD_USERINFO, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 215 + VERTGUIDE, 92 + VERTGUIDE, 99 + TOPMARGIN, 7 + BOTTOMMARGIN, 125 + END +END +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon with lowest ID value placed first to ensure application icon +// remains consistent on all systems. +IDI_MAINICON ICON "main.ico" +IDI_ENABLED ICON "enabled.ico" +IDI_DISABLED ICON "disabled.ico" +IDI_HIDE ICON "hide.ico" +IDI_NEVERHIDE ICON "neverhide.ico" +#endif // English (U.S.) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/plugins/BuddyExpectator/res/disabled.ico b/plugins/BuddyExpectator/res/disabled.ico new file mode 100644 index 0000000000..5280ef1502 Binary files /dev/null and b/plugins/BuddyExpectator/res/disabled.ico differ diff --git a/plugins/BuddyExpectator/res/enabled.ico b/plugins/BuddyExpectator/res/enabled.ico new file mode 100644 index 0000000000..316b22b556 Binary files /dev/null and b/plugins/BuddyExpectator/res/enabled.ico differ diff --git a/plugins/BuddyExpectator/res/hide.ico b/plugins/BuddyExpectator/res/hide.ico new file mode 100644 index 0000000000..deff488a6a Binary files /dev/null and b/plugins/BuddyExpectator/res/hide.ico differ diff --git a/plugins/BuddyExpectator/res/main.ico b/plugins/BuddyExpectator/res/main.ico new file mode 100644 index 0000000000..e7e514fc61 Binary files /dev/null and b/plugins/BuddyExpectator/res/main.ico differ diff --git a/plugins/BuddyExpectator/res/neverhide.ico b/plugins/BuddyExpectator/res/neverhide.ico new file mode 100644 index 0000000000..8a6347b2d3 Binary files /dev/null and b/plugins/BuddyExpectator/res/neverhide.ico differ diff --git a/plugins/BuddyExpectator/resource.h b/plugins/BuddyExpectator/resource.h deleted file mode 100644 index b06406ada8..0000000000 --- a/plugins/BuddyExpectator/resource.h +++ /dev/null @@ -1,56 +0,0 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Visual C++ generated include file. -// Used by BuddyExpectator.rc -// -#define IDI_MAINICON 101 -#define IDI_ENABLED 102 -#define IDI_DISABLED 103 -#define IDI_HIDE 104 -#define IDI_NEVERHIDE 105 -#define IDD_OPTIONSPANEL 201 -#define IDD_POPUPPANEL 202 -#define IDD_USERINFO 203 -#define IDC_CHECK_POPUP 1000 -#define IDC_CHECK_POPUP2 1001 -#define IDC_CHECK_UDETAILS 1002 -#define IDC_CHECK_MSGWINDOW 1003 -#define IDC_CHECK_FLASHICON 1004 -#define IDC_CHECK_FLASHICON2 1005 -#define IDC_CHECK_FIRSTSIGHT 1006 -#define IDC_COMBO_PERIOD 1011 -#define IDC_COMBO_PERIOD2 1012 -#define IDC_COMBO_PERIOD3 1013 -#define IDC_COLOR_FRG 1021 -#define IDC_COLOR_BGR 1022 -#define IDC_COLORS_POPUP 1023 -#define IDC_COLORS_WIN 1024 -#define IDC_DELAY_DEF 1031 -#define IDC_DELAY_CUST 1032 -#define IDC_DELAY_PERM 1033 -#define IDC_EDIT_ABSENCE 1041 -#define IDC_EDIT_ABSENCE2 1042 -#define IDC_EDIT_POPUPDELAY 1043 -#define IDC_EDIT_SILENTFOR 1044 -#define IDC_EDIT_LASTSEEN 1045 -#define IDC_EDIT_LASTINPUT 1046 -#define IDC_EDIT_NOINPUTFOR 1047 -#define IDC_EDIT_WILLNOTICE 1048 -#define IDC_PREVIEW 1061 -#define IDC_CHECK_MISSYOU 1203 -#define IDC_EDITABSENCE 1204 -#define IDC_SPINABSENCE 1205 -#define IDC_CHECK_NOMSGS 1208 -#define IDC_COMBO_ACTIONS 1209 -#define IDC_CHECK_NEVERHIDE 1210 -#define IDC_CHECK_NOTIFYALWAYS 1211 - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 106 -#define _APS_NEXT_COMMAND_VALUE 40001 -#define _APS_NEXT_CONTROL_VALUE 1212 -#define _APS_NEXT_SYMED_VALUE 121 -#endif -#endif diff --git a/plugins/BuddyExpectator/src/BuddyExpectator.cpp b/plugins/BuddyExpectator/src/BuddyExpectator.cpp new file mode 100644 index 0000000000..ab10cf03cb --- /dev/null +++ b/plugins/BuddyExpectator/src/BuddyExpectator.cpp @@ -0,0 +1,927 @@ +/* + Buddy Expectator+ plugin for Miranda-IM (www.miranda-im.org) + (c)2005 Anar Ibragimoff (ai91@mail.ru) + (c)2006 Scott Ellis (mail@scottellis.com.au) + (c)2007,2008 Alexander Turyak (thief@miranda-im.org.ua) + + 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 + + File name : $URL: http://svn.miranda.im/mainrepo/buddyexpectator/trunk/BuddyExpectator.cpp $ + Revision : $Rev: 1392 $ + Last change on : $Date: 2009-04-22 17:46:08 +0300 (Ср, 22 апр 2009) $ + Last change by : $Author: Thief $ +*/ + +#include "common.h" +#include "options.h" + +HINSTANCE hInst; +int hLangpack; + +DWORD timer_id = 0; + +HANDLE hEventContactSetting = NULL; +HANDLE hEventContactAdded = NULL; +HANDLE hEventUserInfoInit = NULL; +HANDLE hPrebuildContactMenu = NULL; +HANDLE hContactMenu = NULL; +HANDLE hIcoLibIconsChanged = NULL; +HANDLE hContactReturnedAction = NULL; +HANDLE hContactStillAbsentAction = NULL; +HANDLE hMissYouAction = NULL; +HANDLE hMenuMissYouClick = NULL; +HANDLE hModulesLoaded = NULL; +HANDLE hModulesLoaded2 = NULL; +HANDLE hSystemOKToExit = NULL; +HANDLE hHookExtraIconsRebuild = NULL; +HANDLE hHookExtraIconsApply = NULL; + +HICON hIcon; +HANDLE hEnabledIcon = NULL, hDisabledIcon = NULL; + +IconExtraColumn g_IECMissYou = {0}; +IconExtraColumn g_IECClear = {0}; + +// Popup Actions +POPUPACTION missyouactions[1]; +POPUPACTION hideactions[2]; + +extern int UserinfoInit(WPARAM wparam, LPARAM lparam); + +PLUGININFOEX pluginInfo = { + sizeof(PLUGININFOEX), + "Buddy Expectator+", + PLUGIN_MAKE_VERSION(0,1,2,3), + "Reacts to the return of contacts, or the the extended absence of contacts, with notifications and other actions", + "Anar Ibragimoff, sje, Thief", + "thief@miranda.im", + "© 2005 Anar Ibragimoff, © 2006 Scott Ellis, © 2007-2009 Alexander Turyak", + "http://thief.miranda.im", + UNICODE_AWARE, + {0xddf8aec9, 0x7d37, 0x49af, {0x9d, 0x22, 0xbb, 0xbc, 0x92, 0x0e, 0x6f, 0x05}} //{DDF8AEC9-7D37-49AF-9D22-BBBC920E6F05} +}; + +/* 2D84F403-91F3-4E60-BF02-16C2F1716D86 */ +#define MIID_BUDDYEXPECTATOR {0x2d84f403, 0x91f3, 0x4e60, {0xbf, 0x02, 0x16, 0xc2, 0xf1, 0x71, 0x6d, 0x86}} + +extern "C" __declspec(dllexport) const MUUID* MirandaPluginInterfaces(void) +{ + static const MUUID interfaces[] = {MIID_BUDDYEXPECTATOR, MIID_LAST}; + return interfaces; +} + +extern "C" BOOL WINAPI DllMain(HINSTANCE hinstDLL,DWORD fdwReason,LPVOID lpvReserved) +{ + hInst = hinstDLL; + return TRUE; +} + +time_t getLastSeen(HANDLE hContact) +{ + return DBGetContactSettingDword(hContact, MODULE_NAME, "LastSeen", DBGetContactSettingDword(hContact, MODULE_NAME, "CreationTime", (DWORD)-1)); +} + +void setLastSeen(HANDLE hContact) +{ + DBWriteContactSettingDword(hContact, MODULE_NAME, "LastSeen", (DWORD)time(NULL)); + if (DBGetContactSettingByte(hContact, MODULE_NAME, "StillAbsentNotified", 0)) + DBWriteContactSettingByte(hContact, MODULE_NAME, "StillAbsentNotified", 0); +} + +time_t getLastInputMsg(HANDLE hContact) +{ + HANDLE hDbEvent; + DBEVENTINFO dbei = {0}; + + hDbEvent = (HANDLE)CallService(MS_DB_EVENT_FINDLAST, (WPARAM)hContact, 0); + while (hDbEvent) + { + dbei.cbSize = sizeof(dbei); + dbei.pBlob = 0; + dbei.cbBlob = 0; + CallService(MS_DB_EVENT_GET, (WPARAM)hDbEvent, (LPARAM)&dbei); + if (dbei.eventType == EVENTTYPE_MESSAGE && !(dbei.flags & DBEF_SENT)) + return dbei.timestamp; + hDbEvent = (HANDLE)CallService(MS_DB_EVENT_FINDPREV, (WPARAM)hDbEvent, 0); + } + return -1; +} + +/** + * PopUp window procedures + */ + +int CALLBACK HidePopupDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) +{ + switch (message) + { + case WM_COMMAND: + if (HIWORD(wParam) == STN_CLICKED) + { + DBWriteContactSettingByte(PUGetContact(hWnd), "CList", "Hidden", 1); + PUDeletePopUp(hWnd); + } + break; + case WM_CONTEXTMENU: + DBWriteContactSettingByte(PUGetContact(hWnd), MODULE_NAME, "NeverHide", 1); + PUDeletePopUp(hWnd); + break; + case UM_POPUPACTION: + if (wParam == 2) + { + DBWriteContactSettingByte(PUGetContact(hWnd), "CList", "Hidden", 1); + PUDeletePopUp(hWnd); + } + if (wParam == 3) + { + DBWriteContactSettingByte(PUGetContact(hWnd), MODULE_NAME, "NeverHide", 1); + PUDeletePopUp(hWnd); + } + break; + case UM_FREEPLUGINDATA: + return TRUE; + default: + break; + } + return DefWindowProc(hWnd, message, wParam, lParam); +} + +int CALLBACK MissYouPopupDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) +{ + switch (message) + { + case WM_COMMAND: + if (HIWORD(wParam) == STN_CLICKED) + { + CallServiceSync("BuddyExpectator/actionMissYou", (WPARAM)PUGetContact(hWnd), 0); + if (!DBGetContactSettingByte(PUGetContact(hWnd), MODULE_NAME, "MissYouNotifyAlways", 0)) + { + DBWriteContactSettingByte(PUGetContact(hWnd), MODULE_NAME, "MissYou", 0); + if (options.MissYouIcon) CallService(MS_CLIST_EXTRA_SET_ICON, (WPARAM) PUGetContact(hWnd), (LPARAM) &g_IECClear); + } + PUDeletePopUp(hWnd); + } + break; + case WM_CONTEXTMENU: + PUDeletePopUp(hWnd); + break; + case UM_POPUPACTION: + if (wParam == 1) + { + DBWriteContactSettingByte(PUGetContact(hWnd), MODULE_NAME, "MissYou", 0); + if (options.MissYouIcon) CallService(MS_CLIST_EXTRA_SET_ICON, (WPARAM) PUGetContact(hWnd), (LPARAM) &g_IECClear); + PUDeletePopUp(hWnd); + } + break; + case UM_FREEPLUGINDATA: + return TRUE; + default: + break; + } + return DefWindowProc(hWnd, message, wParam, lParam); +} + +int CALLBACK PopupDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) +{ + switch (message) + { + case WM_COMMAND: + if (HIWORD(wParam) == STN_CLICKED) + { + CallServiceSync(MS_CLIST_REMOVEEVENT, (WPARAM)PUGetContact(hWnd), 0); + CallServiceSync("BuddyExpectator/actionReturned", (WPARAM)PUGetContact(hWnd), 0); + PUDeletePopUp(hWnd); + } + break; + case WM_CONTEXTMENU: + CallServiceSync(MS_CLIST_REMOVEEVENT, (WPARAM)PUGetContact(hWnd), 0); + setLastSeen(PUGetContact(hWnd)); + PUDeletePopUp(hWnd); + break; + case UM_FREEPLUGINDATA: + if (options.iShowEvent == 0) + { + setLastSeen(PUGetContact(hWnd)); + } + return TRUE; + default: + break; + } + return DefWindowProc(hWnd, message, wParam, lParam); +} + +int CALLBACK PopupDlgProcNoSet(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) +{ + switch (message) + { + case WM_COMMAND: + if (HIWORD(wParam) == STN_CLICKED) + { + CallServiceSync(MS_CLIST_REMOVEEVENT, (WPARAM)PUGetContact(hWnd), 0); + CallServiceSync("BuddyExpectator/actionStillAbsent", (WPARAM)PUGetContact(hWnd), 0); + PUDeletePopUp(hWnd); + } + break; + case WM_CONTEXTMENU: + CallServiceSync(MS_CLIST_REMOVEEVENT, (WPARAM)PUGetContact(hWnd), 0); + PUDeletePopUp(hWnd); + break; + case UM_FREEPLUGINDATA: + return TRUE; + default: + break; + } + return DefWindowProc(hWnd, message, wParam, lParam); +} + +/** + * Checks - whether user has been gone for specified number of days + */ +bool isContactGoneFor(HANDLE hContact, int days) +{ + time_t lastSeen = getLastSeen(hContact); + time_t lastInputMsg = getLastInputMsg(hContact); + time_t currentTime = time(NULL); + + int daysSinceOnline = -1; + if (lastSeen != -1) daysSinceOnline = (int)((currentTime - lastSeen)/(60*60*24)); + + int daysSinceMessage = -1; + if (lastInputMsg != -1) daysSinceMessage = (int)((currentTime - lastInputMsg)/(60*60*24)); + + if (options.hideInactive) + { + if (daysSinceMessage >= options.iSilencePeriod) + if (!DBGetContactSettingByte(hContact, "CList", "Hidden", 0) && !DBGetContactSettingByte(hContact, MODULE_NAME, "NeverHide", 0)) + { + char szInfo[200]; + + POPUPDATAT_V2 ppd = {0}; + ppd.cbSize = sizeof(POPUPDATAT_V2); + + ppd.lchContact = hContact; + ppd.lchIcon = (HICON)CallService(MS_SKIN2_GETICON, 0, (LPARAM)"enabled_icon"); + + mir_snprintf(szInfo, 200, Translate("Hiding %s (%s)"), (char*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME,(WPARAM)hContact,0), (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0)); + strncpy(ppd.lpzContactName, szInfo, MAX_CONTACTNAME); + mir_snprintf(szInfo, 200, Translate("%d days since last message"), daysSinceMessage); + strncpy(ppd.lpzText, szInfo, MAX_SECONDLINE); + if (!options.iUsePopupColors) + { + ppd.colorBack = options.iPopUpColorBack; + ppd.colorText = options.iPopUpColorFore; + } + ppd.PluginWindowProc = (WNDPROC)HidePopupDlgProc; + ppd.PluginData = NULL; + ppd.iSeconds = -1; + + hideactions[0].flags = hideactions[1].flags = PAF_ENABLED; + ppd.lpActions = hideactions; + ppd.actionCount = 2; + + CallService(MS_POPUP_ADDPOPUPEX, (WPARAM) &ppd, APF_NEWDATA); + + SkinPlaySound("buddyExpectatorHide"); + } + } + + return (daysSinceOnline >= days && (daysSinceMessage == -1 || daysSinceMessage >= days)); +} + +void ReturnNotify(HANDLE hContact, char *message) +{ + if (DBGetContactSettingByte(hContact, "CList", "NotOnList", 0) == 1 || DBGetContactSettingByte(hContact, "CList", "Hidden", 0) == 1) + return; + + SkinPlaySound("buddyExpectatorReturn"); + + if (options.iShowPopUp > 0) + { + // Display PopUp + POPUPDATAT_V2 ppd = {0}; + ppd.cbSize = sizeof(POPUPDATAT_V2); + + ppd.lchContact = hContact; + ppd.lchIcon = hIcon; + strncpy(ppd.lpzContactName, (char*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME,(WPARAM)hContact,0), MAX_CONTACTNAME); + strncpy(ppd.lpzText, message, MAX_SECONDLINE); + if (!options.iUsePopupColors) + { + ppd.colorBack = options.iPopUpColorBack; + ppd.colorText = options.iPopUpColorFore; + } + ppd.PluginWindowProc = (WNDPROC)PopupDlgProc; + ppd.PluginData = NULL; + ppd.iSeconds = options.iPopUpDelay; + + CallService(MS_POPUP_ADDPOPUPEX, (WPARAM) &ppd, 0); + + } + + if (options.iShowEvent > 0) + { + CLISTEVENT cle = {0}; + + cle.cbSize = sizeof(cle); + cle.hContact = hContact; + cle.hIcon = hIcon; + cle.pszService = (char *)"BuddyExpectator/actionReturned"; + + char* nick = (char*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME,(WPARAM)hContact,0); + char tmpMsg[512]; + mir_snprintf(tmpMsg, 512, "%s %s", nick, message); + cle.pszTooltip = tmpMsg; + + CallServiceSync(MS_CLIST_ADDEVENT, 0, (LPARAM) &cle); + } +} + +void GoneNotify(HANDLE hContact, char *message) +{ + if (DBGetContactSettingByte(hContact, "CList", "NotOnList", 0) == 1 || DBGetContactSettingByte(hContact, "CList", "Hidden", 0) == 1) + return; + + if (options.iShowPopUp2 > 0) + { + // Display PopUp + POPUPDATAT_V2 ppd = {0}; + ppd.cbSize = sizeof(POPUPDATAT_V2); + + ppd.lchContact = hContact; + ppd.lchIcon = hIcon; + strncpy(ppd.lpzContactName, (char*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME,(WPARAM)hContact,0), MAX_CONTACTNAME); + strncpy(ppd.lpzText, message, MAX_SECONDLINE); + if (!options.iUsePopupColors) + { + ppd.colorBack = options.iPopUpColorBack; + ppd.colorText = options.iPopUpColorFore; + } + ppd.PluginWindowProc = (WNDPROC)PopupDlgProcNoSet; + ppd.PluginData = NULL; + ppd.iSeconds = options.iPopUpDelay; + + CallService(MS_POPUP_ADDPOPUPEX, (WPARAM) &ppd, 0); + } + + if (options.iShowEvent2 > 0) + { + CLISTEVENT cle = {0}; + + cle.cbSize = sizeof(cle); + cle.hContact = hContact; + cle.hIcon = hIcon; + cle.pszService = (char *)"BuddyExpectator/actionStillAbsent"; + + char* nick = (char*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME,(WPARAM)hContact,0); + char tmpMsg[512]; + mir_snprintf(tmpMsg, 512, "%s %s", nick, message); + cle.pszTooltip = tmpMsg; + + CallServiceSync(MS_CLIST_ADDEVENT, 0, (LPARAM) &cle); + } +} + +/** + * Miss you action (clist event click) + * when called from popup, wParam = (HANDLE)hContact and lParam == 0, + * when called from clist event, wParam = hWndCList, lParam = &CLISTEVENT + */ +INT_PTR MissYouAction(WPARAM wParam, LPARAM lParam) +{ + HANDLE hContact; + if (lParam) + { + CLISTEVENT* cle = (CLISTEVENT*)lParam; + hContact = cle->hContact; + } else + hContact = (HANDLE)wParam; + + CallService(MS_MSG_SENDMESSAGE, (WPARAM)hContact, 0); + + return 0; +} + +/** + * Contact returned action (clist event click) + * when called from popup, wParam = (HANDLE)hContact and lParam == 0, + * when called from clist event, wParam = hWndCList, lParam = &CLISTEVENT + */ +INT_PTR ContactReturnedAction(WPARAM wParam, LPARAM lParam) +{ + HANDLE hContact; + if (lParam) + { + CLISTEVENT* cle = (CLISTEVENT*)lParam; + hContact = cle->hContact; + } else + hContact = (HANDLE)wParam; + + if (options.iShowMessageWindow>0) + { + CallService(MS_MSG_SENDMESSAGE, (WPARAM)hContact, 0); + } + + if (options.iShowUDetails>0) + { + CallService(MS_USERINFO_SHOWDIALOG, (WPARAM)hContact, 0); + } + + setLastSeen(hContact); + + return 0; +} + +/** + * Contact not returned action (clist event click) + * when called from popup, wParam = (HANDLE)hContact and lParam == 0, + * when called from clist event, wParam = hWndCList, lParam = &CLISTEVENT + */ +INT_PTR ContactStillAbsentAction(WPARAM wParam, LPARAM lParam) +{ + HANDLE hContact; + if (lParam) + { + CLISTEVENT* cle = (CLISTEVENT*)lParam; + hContact = cle->hContact; + } else + hContact = (HANDLE)wParam; + + switch (options.action2) + { + case GCA_DELETE: + CallService(MS_DB_CONTACT_DELETE, (WPARAM)hContact, 0); + break; + case GCA_UDETAILS: + CallService(MS_USERINFO_SHOWDIALOG, (WPARAM)hContact, 0); + break; + case GCA_MESSAGE: + CallService(MS_MSG_SENDMESSAGE, (WPARAM)hContact, 0); + break; + case GCA_NOACTION: + break; + } + + return 0; +} + +/** + * Load icons either from icolib or built in + */ +int onIconsChanged(WPARAM wParam, LPARAM lParam) +{ + hIcon = (HICON)CallService(MS_SKIN2_GETICON, 0, (LPARAM)"main_icon"); + return 0; +} + +/** + * Menu item click action + */ +INT_PTR MenuMissYouClick(WPARAM wParam, LPARAM lParam) +{ + if (DBGetContactSettingByte((HANDLE)wParam, MODULE_NAME, "MissYou", 0)) + { + DBWriteContactSettingByte((HANDLE)wParam, MODULE_NAME, "MissYou", 0); + if (options.MissYouIcon) CallService(MS_CLIST_EXTRA_SET_ICON, (WPARAM) wParam, (LPARAM) &g_IECClear); + } + else + { + DBWriteContactSettingByte((HANDLE)wParam, MODULE_NAME, "MissYou", 1); + if (options.MissYouIcon) CallService(MS_CLIST_EXTRA_SET_ICON, (WPARAM) wParam, (LPARAM) &g_IECMissYou); + } + + return 0; +} + +/** + * Menu is about to appear + */ +int onPrebuildContactMenu(WPARAM wParam, LPARAM lParam) +{ + char *proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, wParam, 0); + if (!proto) return 0; + + CLISTMENUITEM mi = {0}; + mi.cbSize = sizeof(CLISTMENUITEM); + + if (DBGetContactSettingByte((HANDLE)wParam, proto, "ChatRoom", 0) || !(CallProtoService(proto, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_IMSEND)) + mi.flags = CMIM_FLAGS | CMIF_HIDDEN; + else + mi.flags = CMIM_FLAGS; + + if (DBGetContactSettingByte((HANDLE)wParam, MODULE_NAME, "MissYou", 0)) + { + mi.flags |= CMIM_ICON | CMIM_NAME | CMIF_ICONFROMICOLIB; + mi.pszName = Translate("Disable Miss You"); + mi.icolibItem = hEnabledIcon; + } + else + { + mi.flags |= CMIM_ICON | CMIM_NAME | CMIF_ICONFROMICOLIB; + mi.pszName = Translate("Enable Miss You"); + mi.icolibItem = hDisabledIcon; + } + + CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hContactMenu, (LPARAM)&mi); + + return 0; +} + +int onExtraImageApplying(WPARAM wParam, LPARAM lParam) +{ + if (DBGetContactSettingByte((HANDLE)wParam,MODULE_NAME,"MissYou",0)) + CallService(MS_CLIST_EXTRA_SET_ICON, (WPARAM) wParam, (LPARAM) &g_IECMissYou); + + return 0; +} + +int onExtraImageListRebuild(WPARAM wParam, LPARAM lParam) +{ + g_IECMissYou.cbSize = sizeof(IconExtraColumn); + g_IECMissYou.ColumnType = options.MissYouIcon; + + if (ServiceExists(MS_CLIST_EXTRA_ADD_ICON)) + g_IECMissYou.hImage = (HANDLE)CallService(MS_CLIST_EXTRA_ADD_ICON, (WPARAM)(HICON) CallService(MS_SKIN2_GETICON, 0, (LPARAM)"enabled_icon"), (LPARAM)0); + + return 0; +} + +/** + * ContactSettingChanged callback + */ +int SettingChanged(WPARAM wParam, LPARAM lParam) +{ + HANDLE hContact = (HANDLE) wParam; + DBCONTACTWRITESETTING *inf = (DBCONTACTWRITESETTING *) lParam; + + if (hContact == NULL || inf->value.type == DBVT_DELETED || strcmp(inf->szSetting, "Status") != 0) + return 0; + + if (DBGetContactSettingByte(hContact, "CList", "NotOnList", 0) == 1) + return 0; + + char *proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + if (proto == 0 || (DBGetContactSettingByte(hContact, proto, "ChatRoom", 0) == 1) + || !(CallProtoService(proto, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_IMSEND)) + return 0; + + int currentStatus = inf->value.wVal; + int prevStatus = DBGetContactSettingWord(hContact, "UserOnline", "OldStatus", ID_STATUS_OFFLINE); + + if (currentStatus == prevStatus) + { + return 0; + } + + // Last status + DBWriteContactSettingDword(hContact, MODULE_NAME, "LastStatus", prevStatus); + + if (prevStatus == ID_STATUS_OFFLINE) + { + if (DBGetContactSettingByte(hContact, MODULE_NAME, "MissYou", 0)) + { + // Display PopUp + POPUPDATAT_V2 ppd = {0}; + ppd.cbSize = sizeof(POPUPDATAT_V2); + + ppd.lchContact = hContact; + ppd.lchIcon = (HICON)CallService(MS_SKIN2_GETICON, 0, (LPARAM)"enabled_icon"); + strncpy(ppd.lpzContactName, (char*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME,(WPARAM)hContact,0), MAX_CONTACTNAME); + strncpy(ppd.lpzText, Translate("You awaited this contact!"), MAX_SECONDLINE); + if (!options.iUsePopupColors) + { + ppd.colorBack = options.iPopUpColorBack; + ppd.colorText = options.iPopUpColorFore; + } + ppd.PluginWindowProc = (WNDPROC)MissYouPopupDlgProc; + ppd.PluginData = NULL; + ppd.iSeconds = -1; + + missyouactions[0].flags = PAF_ENABLED; + ppd.lpActions = missyouactions; + ppd.actionCount = 1; + + CallService(MS_POPUP_ADDPOPUPEX, (WPARAM) &ppd, APF_NEWDATA); + + SkinPlaySound("buddyExpectatorMissYou"); + } + } + + if (currentStatus == ID_STATUS_OFFLINE) + { + setLastSeen(hContact); + return 0; + } + + /* + if (CallService(MS_IGNORE_ISIGNORED, (WPARAM) hContact, (LPARAM) IGNOREEVENT_USERONLINE)) + { + setLastSeen(hContact); + return 0; + } + */ + + if (DBGetContactSettingDword(hContact, MODULE_NAME, "LastSeen", (DWORD)-1) == (DWORD)-1 && options.notifyFirstOnline) + { + ReturnNotify(hContact, Translate("has gone online for the first time.")); + + setLastSeen(hContact); + } + + unsigned int AbsencePeriod = DBGetContactSettingDword(hContact, MODULE_NAME, "iAbsencePeriod", options.iAbsencePeriod); + if (isContactGoneFor(hContact, AbsencePeriod)) + { + char* message = Translate("has returned after a long absence."); + time_t tmpTime; + char tmpBuf[251] = {0}; + tmpTime = getLastSeen(hContact); + if (tmpTime != -1) + { + strftime(tmpBuf, 250, Translate("has returned after being absent since %#x"), gmtime(&tmpTime)); + message = tmpBuf; + } + else + { + tmpTime = getLastInputMsg(hContact); + if (tmpTime != -1) + { + strftime(tmpBuf, 250, Translate("has returned after being absent since %#x"), gmtime(&tmpTime)); + message = tmpBuf; + } + } + + ReturnNotify(hContact, message); + + if ((options.iShowMessageWindow == 0 && options.iShowUDetails == 0) || (options.iShowEvent == 0 && options.iShowPopUp == 0)) + { + setLastSeen(hContact); + } + } else + setLastSeen(hContact); + + return 0; +} + +void CALLBACK TimerProc(HWND, UINT, UINT_PTR, DWORD) +{ + HANDLE hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); + char *proto; + while (hContact != 0) + { + proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + if (proto && (DBGetContactSettingByte(hContact, proto, "ChatRoom", 0) == 0) && (CallProtoService(proto, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_IMSEND) && isContactGoneFor(hContact, options.iAbsencePeriod2) && (DBGetContactSettingByte(hContact, MODULE_NAME, "StillAbsentNotified", 0) == 0)) + { + DBWriteContactSettingByte(hContact, MODULE_NAME, "StillAbsentNotified", 1); + SkinPlaySound("buddyExpectatorStillAbsent"); + + char* message = Translate("has not returned after a long absence."); + time_t tmpTime; + char tmpBuf[251] = {0}; + tmpTime = getLastSeen(hContact); + if (tmpTime != -1) + { + strftime(tmpBuf, 250, Translate("has not returned after being absent since %#x"), gmtime(&tmpTime)); + message = tmpBuf; + } + else + { + tmpTime = getLastInputMsg(hContact); + if (tmpTime != -1) + { + strftime(tmpBuf, 250, Translate("has not returned after being absent since %#x"), gmtime(&tmpTime)); + message = tmpBuf; + } + } + + GoneNotify(hContact, message); + } + + hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM)hContact, 0); + } +} +/** + * Called when all the modules have had their modules loaded event handlers called (dependence of popups on fontservice :( ) + */ +int ModulesLoaded2(WPARAM wParam, LPARAM lParam) +{ + // check for 'still absent' contacts on startup + TimerProc(0, 0, 0, 0); + + return 0; +} + +/** + * Called when all the modules are loaded + */ +int ModulesLoaded(WPARAM wParam, LPARAM lParam) +{ + hEventUserInfoInit = HookEvent(ME_USERINFO_INITIALISE, UserinfoInit); + + // add sounds support + SkinAddNewSoundEx("buddyExpectatorReturn", LPGEN("BuddyExpectator"), LPGEN("Contact returned")); + SkinAddNewSoundEx("buddyExpectatorStillAbsent", LPGEN("BuddyExpectator"), LPGEN("Contact still absent")); + SkinAddNewSoundEx("buddyExpectatorMissYou", LPGEN("BuddyExpectator"), LPGEN("Miss you event")); + SkinAddNewSoundEx("buddyExpectatorHide", LPGEN("BuddyExpectator"), LPGEN("Hide contact event")); + + timer_id = SetTimer(0, 0, 1000 * 60 * 60 * 4, TimerProc); // check every 4 hours + + hModulesLoaded2 = HookEvent(ME_SYSTEM_MODULESLOADED, ModulesLoaded2); + if (options.MissYouIcon) + { + hHookExtraIconsRebuild = HookEvent(ME_CLIST_EXTRA_LIST_REBUILD, onExtraImageListRebuild); + hHookExtraIconsApply = HookEvent(ME_CLIST_EXTRA_IMAGE_APPLY, onExtraImageApplying); + g_IECClear.cbSize = sizeof(IconExtraColumn); + g_IECClear.ColumnType = options.MissYouIcon; + g_IECClear.hImage = (HANDLE) -1; + } + + // IcoLib support + SKINICONDESC sid = {0}; + char szFile[MAX_PATH]; + GetModuleFileNameA(hInst, szFile, MAX_PATH); + sid.pszDefaultFile = szFile; + sid.cbSize = sizeof(sid); + sid.pszSection = "BuddyExpectator"; + + sid.pszDescription = "Tray/popup icon"; + sid.pszName = "main_icon"; + sid.iDefaultIndex = -IDI_MAINICON; + Skin_AddIcon(&sid); + + sid.pszDescription = "Enabled"; + sid.pszName = "enabled_icon"; + sid.iDefaultIndex = -IDI_ENABLED; + hEnabledIcon = Skin_AddIcon(&sid); + + sid.pszDescription = "Disabled"; + sid.pszName = "disabled_icon"; + sid.iDefaultIndex = -IDI_DISABLED; + hDisabledIcon = Skin_AddIcon(&sid); + + sid.pszDescription = "Hide"; + sid.pszName = "hide_icon"; + sid.iDefaultIndex = -IDI_HIDE; + Skin_AddIcon(&sid); + + sid.pszDescription = "NeverHide"; + sid.pszName = "neverhide_icon"; + sid.iDefaultIndex = -IDI_NEVERHIDE; + Skin_AddIcon(&sid); + + hIcoLibIconsChanged = HookEvent(ME_SKIN2_ICONSCHANGED, onIconsChanged); + + onIconsChanged(0,0); + + if (options.enableMissYou) { + hPrebuildContactMenu = HookEvent(ME_CLIST_PREBUILDCONTACTMENU, onPrebuildContactMenu); + + CLISTMENUITEM mi = {0}; + mi.cbSize = sizeof(CLISTMENUITEM); + mi.flags = CMIF_ICONFROMICOLIB; + mi.icolibItem = hDisabledIcon; + mi.position = 200000; + mi.pszName = Translate("Enable Miss You"); + mi.pszService = "BuddyExpectator/actionMissYouClick"; + hContactMenu = Menu_AddContactMenuItem(&mi); + } + + // Updater plugin support + if (ServiceExists(MS_UPDATE_REGISTER)) + { + // register with updater + Update update = {0}; + char szVersion[16]; + + update.cbSize = sizeof(Update); + + update.szComponentName = pluginInfo.shortName; + update.pbVersion = (BYTE *)CreateVersionString(pluginInfo.version, szVersion); + update.cpbVersion = (int)strlen((char *)update.pbVersion); + + update.szUpdateURL = UPDATER_AUTOREGISTER; + + // these are the three lines that matter - the archive, the page containing the version string, and the text (or data) + // before the version that we use to locate it on the page + // (note that if the update URL and the version URL point to standard file listing entries, the backend xml + // data will be used to check for updates rather than the actual web page - this is not true for beta urls) + update.szBetaUpdateURL = "http://thief.miranda.im/BuddyExpectator.zip"; + update.szBetaVersionURL = "http://thief.miranda.im/updater/buddyexpectator_version.txt"; + update.szBetaChangelogURL = "http://thief.miranda.im"; + update.pbBetaVersionPrefix = (BYTE *)"Buddy Expectator "; + + update.cpbBetaVersionPrefix = (int)strlen((char *)update.pbBetaVersionPrefix); + + CallService(MS_UPDATE_REGISTER, 0, (WPARAM)&update); + } + + missyouactions[0].cbSize = sizeof(POPUPACTION); + missyouactions[0].lchIcon = (HICON)CallService(MS_SKIN2_GETICON, 0, (LPARAM)"disabled_icon"); + lstrcpy(missyouactions[0].lpzTitle, Translate("Disable Miss You")); + missyouactions[0].wParam = missyouactions[0].lParam = 1; + + hideactions[0].cbSize = sizeof(POPUPACTION); + hideactions[0].lchIcon = (HICON)CallService(MS_SKIN2_GETICON, 0, (LPARAM)"hide_icon"); + lstrcpy(hideactions[0].lpzTitle, Translate("Hide contact")); + hideactions[0].wParam = hideactions[0].lParam = 2; + + hideactions[1].cbSize = sizeof(POPUPACTION); + hideactions[1].lchIcon = (HICON)CallService(MS_SKIN2_GETICON, 0, (LPARAM)"neverhide_icon"); + lstrcpy(hideactions[1].lpzTitle, Translate("Never hide this contact")); + hideactions[1].wParam = hideactions[1].lParam = 3; + + return 0; +} + +extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD mirandaVersion) +{ + return &pluginInfo; +} + +int ContactAdded(WPARAM wParam, LPARAM lParam) +{ + DBWriteContactSettingDword((HANDLE)wParam, MODULE_NAME, "CreationTime", (DWORD)time(0)); + return 0; +} + +int onSystemOKToExit(WPARAM wParam,LPARAM lParam) +{ + UnhookEvent(hEventContactSetting); + UnhookEvent(hEventContactAdded); + UnhookEvent(hEventUserInfoInit); + if (hPrebuildContactMenu) UnhookEvent(hPrebuildContactMenu); + UnhookEvent(hIcoLibIconsChanged); + UnhookEvent(hModulesLoaded); + UnhookEvent(hModulesLoaded2); + UnhookEvent(hSystemOKToExit); + UnhookEvent(hHookExtraIconsRebuild); + UnhookEvent(hHookExtraIconsApply); + + DestroyServiceFunction(hContactReturnedAction); + DestroyServiceFunction(hContactStillAbsentAction); + DestroyServiceFunction(hMissYouAction); + DestroyServiceFunction(hMenuMissYouClick); + + DeinitOptions(); + + if (hIcoLibIconsChanged) + CallService(MS_SKIN2_RELEASEICON, (WPARAM)hIcon, 0); + else + DestroyIcon(hIcon); + + return 0; +} + +extern "C" int __declspec(dllexport) Load(void) +{ + mir_getLP(&pluginInfo); + + setlocale(LC_ALL, "English"); // Set English locale + + InitOptions(); + + hContactReturnedAction = CreateServiceFunction("BuddyExpectator/actionReturned", ContactReturnedAction); + hContactStillAbsentAction = CreateServiceFunction("BuddyExpectator/actionStillAbsent", ContactStillAbsentAction); + hMissYouAction = CreateServiceFunction("BuddyExpectator/actionMissYou", MissYouAction); + hMenuMissYouClick = CreateServiceFunction("BuddyExpectator/actionMissYouClick", MenuMissYouClick); + + hEventContactSetting = HookEvent(ME_DB_CONTACT_SETTINGCHANGED, SettingChanged); + hModulesLoaded = HookEvent(ME_SYSTEM_MODULESLOADED, ModulesLoaded); + hSystemOKToExit = HookEvent(ME_SYSTEM_OKTOEXIT,onSystemOKToExit); + + hEventContactAdded = HookEvent(ME_DB_CONTACT_ADDED, ContactAdded); + + // ensure all contacts are timestamped + DBVARIANT dbv; + HANDLE hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); + DWORD current_time = (DWORD)time(0); + while (hContact != 0) + { + if (!DBGetContactSetting(hContact, MODULE_NAME, "CreationTime", &dbv)) + DBFreeVariant(&dbv); + else + DBWriteContactSettingDword(hContact, MODULE_NAME, "CreationTime", current_time); + + hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM)hContact, 0); + } + + return 0; +} + +extern "C" int __declspec(dllexport) Unload(void) +{ + KillTimer(0, timer_id); + + return 0; +} + diff --git a/plugins/BuddyExpectator/src/common.h b/plugins/BuddyExpectator/src/common.h new file mode 100644 index 0000000000..09bfd58011 --- /dev/null +++ b/plugins/BuddyExpectator/src/common.h @@ -0,0 +1,64 @@ +/* + Buddy Expectator+ plugin for Miranda-IM (www.miranda-im.org) + (c)2005 Anar Ibragimoff (ai91@mail.ru) + (c)2006 Scott Ellis (mail@scottellis.com.au) + (c)2007 Alexander Turyak (thief@miranda-im.org.ua) + + 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 + + File name : $URL: http://svn.miranda.im/mainrepo/buddyexpectator/trunk/common.h $ + Revision : $Rev: 1392 $ + Last change on : $Date: 2009-04-22 17:46:08 +0300 (Ср, 22 апр 2009) $ + Last change by : $Author: Thief $ +*/ + +#ifndef _COMMON_INC +#define _COMMON_INC +#define MIRANDA_VER 0x0A00 + +#include // needed by m_icolib.h > r9256 +#include +#include +#include +#include +#include +#include "resource.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "m_popup.h" +#include "m_popup2.h" +#include "m_updater.h" +#include "m_cluiframes.h" + +#define MODULE_NAME "BuddyExpectator" + +extern HINSTANCE hInst; + +void CALLBACK TimerProc(HWND, UINT, UINT_PTR, DWORD); +extern DWORD timer_id; + +#endif diff --git a/plugins/BuddyExpectator/src/options.cpp b/plugins/BuddyExpectator/src/options.cpp new file mode 100644 index 0000000000..2771c1aa15 --- /dev/null +++ b/plugins/BuddyExpectator/src/options.cpp @@ -0,0 +1,627 @@ +/* + Buddy Expectator+ plugin for Miranda-IM (www.miranda-im.org) + (c)2005 Anar Ibragimoff (ai91@mail.ru) + (c)2006 Scott Ellis (mail@scottellis.com.au) + (c)2007,2008 Alexander Turyak (thief@miranda-im.org.ua) + + 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 + + File name : $URL: http://svn.miranda.im/mainrepo/buddyexpectator/trunk/options.cpp $ + Revision : $Rev: 1003 $ + Last change on : $Date: 2008-01-12 17:15:47 +0200 (Сб, 12 янв 2008) $ + Last change by : $Author: Thief $ +*/ + +#include "common.h" +#include "options.h" + +#define DEF_COLOR_BACK 0xCEF7AD +#define DEF_COLOR_FORE 0x000000 + +extern HICON hIcon; +extern time_t getLastSeen(HANDLE); +extern time_t getLastInputMsg(HANDLE); +extern bool isContactGoneFor(HANDLE, int); +Options options; + +void LoadOptions() +{ + options.iAbsencePeriod = DBGetContactSettingDword(NULL, MODULE_NAME, "iAbsencePeriod", 14); + options.iAbsencePeriod2 = DBGetContactSettingDword(NULL, MODULE_NAME, "iAbsencePeriod2", 30 * 3); + options.iSilencePeriod = DBGetContactSettingDword(NULL, MODULE_NAME, "iSilencePeriod", 30); + options.iShowPopUp = DBGetContactSettingByte(NULL, MODULE_NAME, "iShowPopUp", 1); + options.iShowEvent = DBGetContactSettingByte(NULL, MODULE_NAME, "iShowEvent", 0); + options.iShowUDetails = DBGetContactSettingByte(NULL, MODULE_NAME, "iShowUDetails", 0); + options.iShowMessageWindow = DBGetContactSettingByte(NULL, MODULE_NAME, "iShowMessageWindow", 1); + options.iPopUpColorBack = DBGetContactSettingDword(NULL, MODULE_NAME, "iPopUpColorBack", DEF_COLOR_BACK); + options.iPopUpColorFore = DBGetContactSettingDword(NULL, MODULE_NAME, "iPopUpColorFore", DEF_COLOR_FORE); + options.iUsePopupColors = DBGetContactSettingByte(NULL, MODULE_NAME, "iUsePopupColors", 0); + options.iUseWinColors = DBGetContactSettingByte(NULL, MODULE_NAME, "iUseWinColors", 0); + options.iPopUpDelay = DBGetContactSettingByte(NULL, MODULE_NAME, "iPopUpDelay", 0); + + options.iShowPopUp2 = DBGetContactSettingByte(NULL, MODULE_NAME, "iShowPopUp2", 1); + options.iShowEvent2 = DBGetContactSettingByte(NULL, MODULE_NAME, "iShowEvent2", 0); + options.action2 = (GoneContactAction)DBGetContactSettingByte(NULL, MODULE_NAME, "Action2", (BYTE)GCA_NOACTION); + options.notifyFirstOnline = DBGetContactSettingByte(NULL, MODULE_NAME, "bShowFirstSight", 0) ? true : false; + options.hideInactive = DBGetContactSettingByte(NULL, MODULE_NAME, "bHideInactive", 0) ? true : false; + options.enableMissYou = DBGetContactSettingByte(NULL, MODULE_NAME, "bMissYouEnabled", 1) ? true : false; + options.MissYouIcon = DBGetContactSettingByte(NULL, MODULE_NAME, "bMissYouIcon", 0); +} + +void SaveOptions() +{ + DBWriteContactSettingDword(NULL, MODULE_NAME, "iAbsencePeriod", options.iAbsencePeriod); + DBWriteContactSettingDword(NULL, MODULE_NAME, "iAbsencePeriod2", options.iAbsencePeriod2); + DBWriteContactSettingDword(NULL, MODULE_NAME, "iSilencePeriod", options.iSilencePeriod); + DBWriteContactSettingByte(NULL, MODULE_NAME, "iShowPopUp", options.iShowPopUp); + DBWriteContactSettingByte(NULL, MODULE_NAME, "iShowEvent", options.iShowEvent); + DBWriteContactSettingByte(NULL, MODULE_NAME, "iShowUDetails", options.iShowUDetails); + DBWriteContactSettingByte(NULL, MODULE_NAME, "iShowMessageWindow", options.iShowMessageWindow); + + DBWriteContactSettingByte(NULL, MODULE_NAME, "iShowPopUp2", options.iShowPopUp2); + DBWriteContactSettingByte(NULL, MODULE_NAME, "iShowEvent2", options.iShowEvent2); + DBWriteContactSettingByte(NULL, MODULE_NAME, "Action2", (BYTE)options.action2); + DBWriteContactSettingByte(NULL, MODULE_NAME, "bShowFirstSight", options.notifyFirstOnline ? 1 : 0); + DBWriteContactSettingByte(NULL, MODULE_NAME, "bHideInactive", options.hideInactive ? 1 : 0); + DBWriteContactSettingByte(NULL, MODULE_NAME, "bMissYouEnabled", options.enableMissYou ? 1 : 0); +} + + +void SavePopupOptions() +{ + DBWriteContactSettingDword(NULL, MODULE_NAME, "iPopUpColorBack", options.iPopUpColorBack); + DBWriteContactSettingDword(NULL, MODULE_NAME, "iPopUpColorFore", options.iPopUpColorFore); + DBWriteContactSettingByte(NULL, MODULE_NAME, "iUsePopupColors", options.iUsePopupColors); + DBWriteContactSettingByte(NULL, MODULE_NAME, "iUseWinColors", options.iUseWinColors); + DBWriteContactSettingByte(NULL, MODULE_NAME, "iPopUpDelay", options.iPopUpDelay); +} + +/** + * Options panel function + */ +static INT_PTR CALLBACK OptionsFrameProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) +{ + switch (uMsg) + { + case WM_INITDIALOG: + TranslateDialogDefault(hwndDlg); + + if (!ServiceExists(MS_POPUP_ADDPOPUP)) + { + EnableWindow(GetDlgItem(hwndDlg, IDC_CHECK_POPUP), FALSE); + } + + //iAbsencePeriod + SendMessage(GetDlgItem(hwndDlg, IDC_COMBO_PERIOD), CB_RESETCONTENT, 0, 0); + SendMessage(GetDlgItem(hwndDlg, IDC_COMBO_PERIOD), CB_ADDSTRING, 0, (LPARAM) Translate("days")); + SendMessage(GetDlgItem(hwndDlg, IDC_COMBO_PERIOD), CB_ADDSTRING, 0, (LPARAM) Translate("weeks")); + SendMessage(GetDlgItem(hwndDlg, IDC_COMBO_PERIOD), CB_ADDSTRING, 0, (LPARAM) Translate("months")); + SendMessage(GetDlgItem(hwndDlg, IDC_COMBO_PERIOD), CB_ADDSTRING, 0, (LPARAM) Translate("years")); + if (options.iAbsencePeriod % 365 == 0) + { + SetDlgItemInt(hwndDlg, IDC_EDIT_ABSENCE, options.iAbsencePeriod/365, FALSE); + SendMessage(GetDlgItem(hwndDlg, IDC_COMBO_PERIOD), CB_SETCURSEL, 3, 0); + } + else if (options.iAbsencePeriod % 30 == 0) + { + SetDlgItemInt(hwndDlg, IDC_EDIT_ABSENCE, options.iAbsencePeriod/30, FALSE); + SendMessage(GetDlgItem(hwndDlg, IDC_COMBO_PERIOD), CB_SETCURSEL, 2, 0); + } + else if (options.iAbsencePeriod % 7 == 0) + { + SetDlgItemInt(hwndDlg, IDC_EDIT_ABSENCE, options.iAbsencePeriod/7, FALSE); + SendMessage(GetDlgItem(hwndDlg, IDC_COMBO_PERIOD), CB_SETCURSEL, 1, 0); + } + else + { + SetDlgItemInt(hwndDlg, IDC_EDIT_ABSENCE, options.iAbsencePeriod, FALSE); + SendMessage(GetDlgItem(hwndDlg, IDC_COMBO_PERIOD), CB_SETCURSEL, 0, 0); + } + + //iAbsencePeriod2 + SendMessage(GetDlgItem(hwndDlg, IDC_COMBO_PERIOD2), CB_RESETCONTENT, 0, 0); + SendMessage(GetDlgItem(hwndDlg, IDC_COMBO_PERIOD2), CB_ADDSTRING, 0, (LPARAM) Translate("days")); + SendMessage(GetDlgItem(hwndDlg, IDC_COMBO_PERIOD2), CB_ADDSTRING, 0, (LPARAM) Translate("weeks")); + SendMessage(GetDlgItem(hwndDlg, IDC_COMBO_PERIOD2), CB_ADDSTRING, 0, (LPARAM) Translate("months")); + SendMessage(GetDlgItem(hwndDlg, IDC_COMBO_PERIOD2), CB_ADDSTRING, 0, (LPARAM) Translate("years")); + if (options.iAbsencePeriod2 % 365 == 0) + { + SetDlgItemInt(hwndDlg, IDC_EDIT_ABSENCE2, options.iAbsencePeriod2/365, FALSE); + SendMessage(GetDlgItem(hwndDlg, IDC_COMBO_PERIOD2), CB_SETCURSEL, 3, 0); + } + else if (options.iAbsencePeriod2 % 30 == 0) + { + SetDlgItemInt(hwndDlg, IDC_EDIT_ABSENCE2, options.iAbsencePeriod2/30, FALSE); + SendMessage(GetDlgItem(hwndDlg, IDC_COMBO_PERIOD2), CB_SETCURSEL, 2, 0); + } + else if (options.iAbsencePeriod2 % 7 == 0) + { + SetDlgItemInt(hwndDlg, IDC_EDIT_ABSENCE2, options.iAbsencePeriod2/7, FALSE); + SendMessage(GetDlgItem(hwndDlg, IDC_COMBO_PERIOD2), CB_SETCURSEL, 1, 0); + } + else + { + SetDlgItemInt(hwndDlg, IDC_EDIT_ABSENCE2,options.iAbsencePeriod2, FALSE); + SendMessage(GetDlgItem(hwndDlg, IDC_COMBO_PERIOD2), CB_SETCURSEL, 0, 0); + } + + //iSilencePeriod + SendMessage(GetDlgItem(hwndDlg, IDC_COMBO_PERIOD3), CB_RESETCONTENT, 0, 0); + SendMessage(GetDlgItem(hwndDlg, IDC_COMBO_PERIOD3), CB_ADDSTRING, 0, (LPARAM) Translate("days")); + SendMessage(GetDlgItem(hwndDlg, IDC_COMBO_PERIOD3), CB_ADDSTRING, 0, (LPARAM) Translate("weeks")); + SendMessage(GetDlgItem(hwndDlg, IDC_COMBO_PERIOD3), CB_ADDSTRING, 0, (LPARAM) Translate("months")); + SendMessage(GetDlgItem(hwndDlg, IDC_COMBO_PERIOD3), CB_ADDSTRING, 0, (LPARAM) Translate("years")); + if (options.iSilencePeriod % 365 == 0) + { + SetDlgItemInt(hwndDlg, IDC_EDIT_SILENTFOR, options.iSilencePeriod/365, FALSE); + SendMessage(GetDlgItem(hwndDlg, IDC_COMBO_PERIOD3), CB_SETCURSEL, 3, 0); + } + else if (options.iSilencePeriod % 30 == 0) + { + SetDlgItemInt(hwndDlg, IDC_EDIT_SILENTFOR, options.iSilencePeriod/30, FALSE); + SendMessage(GetDlgItem(hwndDlg, IDC_COMBO_PERIOD3), CB_SETCURSEL, 2, 0); + } + else if (options.iSilencePeriod % 7 == 0) + { + SetDlgItemInt(hwndDlg, IDC_EDIT_SILENTFOR, options.iSilencePeriod/7, FALSE); + SendMessage(GetDlgItem(hwndDlg, IDC_COMBO_PERIOD3), CB_SETCURSEL, 1, 0); + } + else + { + SetDlgItemInt(hwndDlg, IDC_EDIT_SILENTFOR,options.iSilencePeriod, FALSE); + SendMessage(GetDlgItem(hwndDlg, IDC_COMBO_PERIOD3), CB_SETCURSEL, 0, 0); + } + + SendMessage(GetDlgItem(hwndDlg, IDC_CHECK_POPUP), BM_SETCHECK, options.iShowPopUp > 0 ? BST_CHECKED : BST_UNCHECKED, 0); + SendMessage(GetDlgItem(hwndDlg, IDC_CHECK_FLASHICON), BM_SETCHECK, options.iShowEvent > 0 ? BST_CHECKED : BST_UNCHECKED, 0); + SendMessage(GetDlgItem(hwndDlg, IDC_CHECK_UDETAILS), BM_SETCHECK, (options.iShowUDetails > 0 ? BST_CHECKED : BST_UNCHECKED), 0); + SendMessage(GetDlgItem(hwndDlg, IDC_CHECK_MSGWINDOW), BM_SETCHECK, (options.iShowMessageWindow > 0 ? BST_CHECKED : BST_UNCHECKED), 0); + SendMessage(GetDlgItem(hwndDlg, IDC_CHECK_FIRSTSIGHT), BM_SETCHECK, options.notifyFirstOnline ? BST_CHECKED : BST_UNCHECKED, 0); + SendMessage(GetDlgItem(hwndDlg, IDC_CHECK_NOMSGS), BM_SETCHECK, options.hideInactive ? BST_CHECKED : BST_UNCHECKED, 0); + SendMessage(GetDlgItem(hwndDlg, IDC_CHECK_MISSYOU), BM_SETCHECK, options.enableMissYou ? BST_CHECKED : BST_UNCHECKED, 0); + + SendMessage(GetDlgItem(hwndDlg, IDC_CHECK_POPUP2), BM_SETCHECK, options.iShowPopUp2 > 0 ? BST_CHECKED : BST_UNCHECKED, 0); + SendMessage(GetDlgItem(hwndDlg, IDC_CHECK_FLASHICON2), BM_SETCHECK, options.iShowEvent2 > 0 ? BST_CHECKED : BST_UNCHECKED, 0); + + + SendMessage(GetDlgItem(hwndDlg, IDC_COMBO_ACTIONS), CB_RESETCONTENT, 0, 0); + SendMessage(GetDlgItem(hwndDlg, IDC_COMBO_ACTIONS), CB_ADDSTRING, 0, (LPARAM) Translate("Do nothing")); + SendMessage(GetDlgItem(hwndDlg, IDC_COMBO_ACTIONS), CB_ADDSTRING, 0, (LPARAM) Translate("Delete the contact")); + SendMessage(GetDlgItem(hwndDlg, IDC_COMBO_ACTIONS), CB_ADDSTRING, 0, (LPARAM) Translate("Open User Details")); + SendMessage(GetDlgItem(hwndDlg, IDC_COMBO_ACTIONS), CB_ADDSTRING, 0, (LPARAM) Translate("Open message window")); + SendMessage(GetDlgItem(hwndDlg, IDC_COMBO_ACTIONS), CB_SETCURSEL, options.action2, 0); + + return TRUE; + case WM_COMMAND: + if ((HIWORD(wParam) == BN_CLICKED) || (HIWORD(wParam) == CBN_SELCHANGE) + || ((HIWORD(wParam) == EN_CHANGE) && (SendMessage(GetDlgItem(hwndDlg, IDC_EDIT_ABSENCE), EM_GETMODIFY, 0, 0))) + || ((HIWORD(wParam) == EN_CHANGE) && (SendMessage(GetDlgItem(hwndDlg, IDC_EDIT_ABSENCE2), EM_GETMODIFY, 0, 0))) + || ((HIWORD(wParam) == EN_CHANGE) && (SendMessage(GetDlgItem(hwndDlg, IDC_EDIT_SILENTFOR), EM_GETMODIFY, 0, 0)))) + { + SendMessage(GetParent(hwndDlg),PSM_CHANGED,0,0); + } + break; + case WM_NOTIFY: + { + NMHDR* nmhdr = (NMHDR*)lParam; + switch (nmhdr->code) + { + case PSN_APPLY: + + //iAbsencePeriod + int num = GetDlgItemInt(hwndDlg, IDC_EDIT_ABSENCE, 0, FALSE); + switch (SendMessage(GetDlgItem(hwndDlg, IDC_COMBO_PERIOD), CB_GETCURSEL, 0, 0)) + { + case 1: options.iAbsencePeriod = 7 * num; break; + case 2: options.iAbsencePeriod = 30 * num; break; + case 3: options.iAbsencePeriod = 365 * num; break; + default: options.iAbsencePeriod = num; break; + } + + //iAbsencePeriod2 + num = GetDlgItemInt(hwndDlg, IDC_EDIT_ABSENCE2, 0, FALSE); + switch (SendMessage(GetDlgItem(hwndDlg, IDC_COMBO_PERIOD2), CB_GETCURSEL, 0, 0)) + { + case 1: options.iAbsencePeriod2 = 7 * num; break; + case 2: options.iAbsencePeriod2 = 30 * num; break; + case 3: options.iAbsencePeriod2 = 365 * num; break; + default: options.iAbsencePeriod2 = num; break; + } + + //iSilencePeriod + num = GetDlgItemInt(hwndDlg, IDC_EDIT_SILENTFOR, 0, FALSE); + switch (SendMessage(GetDlgItem(hwndDlg, IDC_COMBO_PERIOD3), CB_GETCURSEL, 0, 0)) + { + case 1: options.iSilencePeriod = 7 * num; break; + case 2: options.iSilencePeriod = 30 * num; break; + case 3: options.iSilencePeriod = 365 * num; break; + default: options.iSilencePeriod = num; break; + } + + options.iShowPopUp = SendMessage(GetDlgItem(hwndDlg, IDC_CHECK_POPUP), BM_GETCHECK, 0, 0) == BST_CHECKED ? 1:0; + options.iShowEvent = SendMessage(GetDlgItem(hwndDlg, IDC_CHECK_FLASHICON), BM_GETCHECK, 0, 0) == BST_CHECKED ? 1:0; + options.iShowUDetails = SendMessage(GetDlgItem(hwndDlg, IDC_CHECK_UDETAILS), BM_GETCHECK, 0, 0) == BST_CHECKED ? 1:0; + options.iShowMessageWindow = SendMessage(GetDlgItem(hwndDlg, IDC_CHECK_MSGWINDOW), BM_GETCHECK, 0, 0) == BST_CHECKED ? 1:0; + options.notifyFirstOnline = SendMessage(GetDlgItem(hwndDlg, IDC_CHECK_FIRSTSIGHT), BM_GETCHECK, 0, 0) == BST_CHECKED ? true : false; + options.hideInactive = SendMessage(GetDlgItem(hwndDlg, IDC_CHECK_NOMSGS), BM_GETCHECK, 0, 0) == BST_CHECKED ? true : false; + options.enableMissYou = SendMessage(GetDlgItem(hwndDlg, IDC_CHECK_MISSYOU), BM_GETCHECK, 0, 0) == BST_CHECKED ? true : false; + + options.iShowPopUp2 = SendMessage(GetDlgItem(hwndDlg, IDC_CHECK_POPUP2), BM_GETCHECK, 0, 0) == BST_CHECKED ? 1:0; + options.iShowEvent2 = SendMessage(GetDlgItem(hwndDlg, IDC_CHECK_FLASHICON2), BM_GETCHECK, 0, 0) == BST_CHECKED ? 1:0; + + options.action2 = (GoneContactAction)SendMessage(GetDlgItem(hwndDlg, IDC_COMBO_ACTIONS), CB_GETCURSEL, 0, 0); + + // save values to the DB + SaveOptions(); + + // clear all notified settings + HANDLE hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); + while (hContact != 0) + { + if(DBGetContactSettingByte(hContact, MODULE_NAME, "StillAbsentNotified", 0)) + DBWriteContactSettingByte(hContact, MODULE_NAME, "StillAbsentNotified", 0); + + hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM)hContact, 0); + } + + // restart timer & run check + KillTimer(0, timer_id); + timer_id = SetTimer(0, 0, 1000 * 60 * 60 * 4, TimerProc); // check every 4 hours + TimerProc(0, 0, 0, 0); + return TRUE; + } + break; + } + } + return 0; +} + +/** + * PopUp Options panel function + */ +static INT_PTR CALLBACK PopUpOptionsFrameProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) +{ + static int ChangeLock = 0; + switch (uMsg) + { + case WM_INITDIALOG: + + ChangeLock++; + TranslateDialogDefault(hwndDlg); + + //iPopUpColorBack + SendDlgItemMessage(hwndDlg, IDC_COLOR_BGR, CPM_SETCOLOUR, 0, options.iPopUpColorBack); + + //iPopUpColorFore + SendDlgItemMessage(hwndDlg, IDC_COLOR_FRG, CPM_SETCOLOUR, 0, options.iPopUpColorFore); + + if (options.iUsePopupColors) + { + CheckDlgButton(hwndDlg, IDC_COLORS_POPUP, BST_CHECKED); + EnableWindow(GetDlgItem(hwndDlg, IDC_COLOR_BGR), false); + EnableWindow(GetDlgItem(hwndDlg, IDC_COLOR_FRG), false); + EnableWindow(GetDlgItem(hwndDlg, IDC_COLORS_WIN), false); + } + + if (options.iUseWinColors) + { + CheckDlgButton(hwndDlg, IDC_COLORS_WIN, BST_CHECKED); + EnableWindow(GetDlgItem(hwndDlg, IDC_COLOR_BGR), false); + EnableWindow(GetDlgItem(hwndDlg, IDC_COLOR_FRG), false); + EnableWindow(GetDlgItem(hwndDlg, IDC_COLORS_POPUP), false); + } + + //iPopUpDelay + SetDlgItemInt(hwndDlg, IDC_EDIT_POPUPDELAY, 5, FALSE); + if (options.iPopUpDelay < 0) + { + SendMessage(GetDlgItem(hwndDlg, IDC_DELAY_PERM), BM_SETCHECK, BST_CHECKED, 0); + EnableWindow(GetDlgItem(hwndDlg, IDC_EDIT_POPUPDELAY), false); + } + else if(options.iPopUpDelay == 0) + { + SendMessage(GetDlgItem(hwndDlg, IDC_DELAY_DEF), BM_SETCHECK, BST_CHECKED, 0); + EnableWindow(GetDlgItem(hwndDlg, IDC_EDIT_POPUPDELAY), false); + } + else + { + SendMessage(GetDlgItem(hwndDlg, IDC_DELAY_CUST), BM_SETCHECK, BST_CHECKED, 0); + SetDlgItemInt(hwndDlg, IDC_EDIT_POPUPDELAY, options.iPopUpDelay, FALSE); + } + + ChangeLock--; + return TRUE; + case WM_COMMAND: + if (LOWORD(wParam) == IDC_PREVIEW) + { + POPUPDATAEX ppd; + ZeroMemory(&ppd, sizeof(ppd)); + + //iPopUpDelay + options.iPopUpDelay = GetDlgItemInt(hwndDlg, IDC_EDIT_POPUPDELAY, 0, FALSE); + if (SendMessage(GetDlgItem(hwndDlg, IDC_DELAY_PERM), BM_GETCHECK, 0, 0) == BST_CHECKED) + { + options.iPopUpDelay = -1; + } + else if (SendMessage(GetDlgItem(hwndDlg, IDC_DELAY_DEF), BM_GETCHECK, 0, 0) == BST_CHECKED) + { + options.iPopUpDelay = 0; + } + ppd.lchContact = NULL; + ppd.lchIcon = hIcon; + strncpy(ppd.lpzContactName, Translate("Contact name"), MAX_CONTACTNAME); + char szPreviewText[50]; + mir_snprintf(szPreviewText,50,Translate("has returned after being absent since %d days"),rand() % 30); + strncpy(ppd.lpzText, szPreviewText, MAX_SECONDLINE); + + // Get current popups colors options + if (IsDlgButtonChecked(hwndDlg, IDC_COLORS_POPUP)) + { + ppd.colorBack = ppd.colorText = 0; + } + else if (IsDlgButtonChecked(hwndDlg, IDC_COLORS_WIN)) + { + ppd.colorBack = GetSysColor(COLOR_BTNFACE); + ppd.colorText = GetSysColor(COLOR_WINDOWTEXT); + } + else + { + ppd.colorBack = SendDlgItemMessage(hwndDlg, IDC_COLOR_BGR, CPM_GETCOLOUR, 0, 0); + ppd.colorText = SendDlgItemMessage(hwndDlg, IDC_COLOR_FRG, CPM_GETCOLOUR, 0, 0); + } + ppd.PluginData = NULL; + ppd.iSeconds = options.iPopUpDelay; + + CallService(MS_POPUP_ADDPOPUPEX, (WPARAM) &ppd, APF_NO_HISTORY); + + strncpy(ppd.lpzText, Translate("You awaited this contact!"), MAX_SECONDLINE); + ppd.lchIcon = (HICON)CallService(MS_SKIN2_GETICON, 0, (LPARAM)"enabled_icon");; + + CallService(MS_POPUP_ADDPOPUPEX, (WPARAM) &ppd, APF_NO_HISTORY); + } + else + { + if ((HIWORD(wParam) == BN_CLICKED) || (HIWORD(wParam) == CBN_SELCHANGE) || ((HIWORD(wParam) == EN_CHANGE) && !ChangeLock)) { + SendMessage(GetParent(hwndDlg),PSM_CHANGED,0,0); + } + if (LOWORD(wParam) == IDC_COLORS_POPUP) + { + if (IsDlgButtonChecked(hwndDlg, IDC_COLORS_POPUP)) + { + EnableWindow(GetDlgItem(hwndDlg, IDC_COLOR_BGR), false); + EnableWindow(GetDlgItem(hwndDlg, IDC_COLOR_FRG), false); + EnableWindow(GetDlgItem(hwndDlg, IDC_COLORS_WIN), false); + } + else + { + EnableWindow(GetDlgItem(hwndDlg, IDC_COLOR_BGR), true); + EnableWindow(GetDlgItem(hwndDlg, IDC_COLOR_FRG), true); + EnableWindow(GetDlgItem(hwndDlg, IDC_COLORS_WIN), true); + } + } + if (LOWORD(wParam) == IDC_COLORS_WIN) + { + if (IsDlgButtonChecked(hwndDlg, IDC_COLORS_WIN)) + { + EnableWindow(GetDlgItem(hwndDlg, IDC_COLOR_BGR), false); + EnableWindow(GetDlgItem(hwndDlg, IDC_COLOR_FRG), false); + EnableWindow(GetDlgItem(hwndDlg, IDC_COLORS_POPUP), false); + } + else + { + EnableWindow(GetDlgItem(hwndDlg, IDC_COLOR_BGR), true); + EnableWindow(GetDlgItem(hwndDlg, IDC_COLOR_FRG), true); + EnableWindow(GetDlgItem(hwndDlg, IDC_COLORS_POPUP), true); + } + } + if (LOWORD(wParam) == IDC_DELAY_DEF || LOWORD(wParam) == IDC_DELAY_PERM) + { + EnableWindow(GetDlgItem(hwndDlg, IDC_EDIT_POPUPDELAY), false); + } + else if (LOWORD(wParam) == IDC_DELAY_CUST) + { + EnableWindow(GetDlgItem(hwndDlg, IDC_EDIT_POPUPDELAY), true); + } + } + + break; + case WM_NOTIFY:{ + NMHDR* nmhdr = (NMHDR*)lParam; + switch (nmhdr->code) + { + case PSN_APPLY: + + if (IsDlgButtonChecked(hwndDlg, IDC_COLORS_POPUP)) + { + options.iUsePopupColors = 1; + options.iUseWinColors = 0; + } + else if (IsDlgButtonChecked(hwndDlg, IDC_COLORS_WIN)) + { + options.iUseWinColors = 1; + options.iUsePopupColors = 0; + options.iPopUpColorBack = GetSysColor(COLOR_BTNFACE); + options.iPopUpColorFore = GetSysColor(COLOR_WINDOWTEXT); + } + else + { + options.iUseWinColors = options.iUsePopupColors = 0; + options.iPopUpColorBack = SendDlgItemMessage(hwndDlg, IDC_COLOR_BGR, CPM_GETCOLOUR, 0, 0); + options.iPopUpColorFore = SendDlgItemMessage(hwndDlg, IDC_COLOR_FRG, CPM_GETCOLOUR, 0, 0); + } + + //iPopUpDelay + options.iPopUpDelay = GetDlgItemInt(hwndDlg, IDC_EDIT_POPUPDELAY, 0, FALSE); + if (SendMessage(GetDlgItem(hwndDlg, IDC_DELAY_PERM), BM_GETCHECK, 0, 0) == BST_CHECKED) + { + options.iPopUpDelay = -1; + } + else if (SendMessage(GetDlgItem(hwndDlg, IDC_DELAY_DEF), BM_GETCHECK, 0, 0) == BST_CHECKED) + { + options.iPopUpDelay = 0; + } + + // save value to the DB + SavePopupOptions(); + + return TRUE; + } + break; + } + } + return 0; +} + +/** + * Init options panel + */ +static int OptionsInit(WPARAM wParam, LPARAM lParam) +{ + OPTIONSDIALOGPAGE odp; + ZeroMemory(&odp, sizeof(odp)); + odp.cbSize = sizeof(odp); + odp.hInstance = hInst; + odp.pszGroup = LPGEN("Plugins"); + odp.pszTemplate = MAKEINTRESOURCE(IDD_OPTIONSPANEL); + odp.pszTitle = LPGEN("Buddy Expectator"); + odp.pfnDlgProc = OptionsFrameProc; + odp.flags = ODPF_BOLDGROUPS; + Options_AddPage(wParam, &odp); + + if (ServiceExists(MS_POPUP_ADDPOPUP)) { + odp.pszGroup = LPGEN("PopUps"); + odp.pszTemplate = MAKEINTRESOURCE(IDD_POPUPPANEL); + odp.pfnDlgProc = PopUpOptionsFrameProc; + Options_AddPage(wParam, &odp); + } + + return 0; +} + +INT_PTR CALLBACK UserinfoDlgProc(HWND hdlg, UINT msg, WPARAM wparam, LPARAM lparam) +{ + switch (msg) + { + case WM_INITDIALOG: + { + time_t tmpTime; + char tmpBuf[51] = {0}; + tmpTime = getLastSeen((HANDLE)lparam); + if (tmpTime == -1) + SetDlgItemText(hdlg, IDC_EDIT_LASTSEEN, Translate("not detected")); + else + { + /* + int status = DBGetContactSettingWord((HANDLE)lparam, MODULE_NAME, "LastStatus", ID_STATUS_OFFLINE); + char *strptr = (char *)CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION, (WPARAM)status, (LPARAM)0); + */ + strftime(tmpBuf, 50, "%#x", gmtime(&tmpTime)); + SetDlgItemText(hdlg, IDC_EDIT_LASTSEEN, tmpBuf); + } + + tmpTime = getLastInputMsg((HANDLE)lparam); + if (tmpTime == -1) + SetDlgItemText(hdlg, IDC_EDIT_LASTINPUT, Translate("not found")); + else + { + strftime(tmpBuf, 50, "%#x", gmtime(&tmpTime)); + SetDlgItemText(hdlg, IDC_EDIT_LASTINPUT, tmpBuf); + } + + unsigned int AbsencePeriod = DBGetContactSettingDword((HANDLE)lparam, MODULE_NAME, "iAbsencePeriod", options.iAbsencePeriod); + + SendDlgItemMessage(hdlg, IDC_SPINABSENCE, UDM_SETRANGE, 0, MAKELONG(999, 1)); + SetDlgItemInt(hdlg, IDC_EDITABSENCE, AbsencePeriod, FALSE); + + if (isContactGoneFor((HANDLE)lparam, options.iAbsencePeriod2)) + { + SetDlgItemText(hdlg, IDC_EDIT_WILLNOTICE, Translate("This contact has been absent for an extended period of time.")); + } + else + { + SetDlgItemText(hdlg, IDC_EDIT_WILLNOTICE, ""); + } + + SendMessage(GetDlgItem(hdlg, IDC_CHECK_MISSYOU), BM_SETCHECK, DBGetContactSettingByte((HANDLE)lparam, MODULE_NAME, "MissYou", 0) ? BST_CHECKED : BST_UNCHECKED, 0); + SendMessage(GetDlgItem(hdlg, IDC_CHECK_NOTIFYALWAYS), BM_SETCHECK, DBGetContactSettingByte((HANDLE)lparam, MODULE_NAME, "MissYouNotifyAlways", 0) ? BST_CHECKED : BST_UNCHECKED, 0); + SendMessage(GetDlgItem(hdlg, IDC_CHECK_NEVERHIDE), BM_SETCHECK, DBGetContactSettingByte((HANDLE)lparam, MODULE_NAME, "NeverHide", 0) ? BST_CHECKED : BST_UNCHECKED, 0); + + TranslateDialogDefault(hdlg); + + return TRUE; + } + + case WM_NOTIFY: + switch (((LPNMHDR)lparam)->idFrom) + { + case 0: + switch (((LPNMHDR)lparam)->code) + { + case (PSN_APPLY): + { + HANDLE hContact = (HANDLE)((LPPSHNOTIFY)lparam)->lParam; + if (hContact) + { + DBWriteContactSettingDword(hContact, MODULE_NAME, "iAbsencePeriod", GetDlgItemInt(hdlg, IDC_EDITABSENCE, 0, FALSE)); + DBWriteContactSettingByte(hContact, MODULE_NAME, "MissYou", (SendMessage(GetDlgItem(hdlg, IDC_CHECK_MISSYOU), BM_GETCHECK, 0, 0) == BST_CHECKED) ? 1 : 0); + DBWriteContactSettingByte(hContact, MODULE_NAME, "MissYouNotifyAlways", (SendMessage(GetDlgItem(hdlg, IDC_CHECK_NOTIFYALWAYS), BM_GETCHECK, 0, 0) == BST_CHECKED) ? 1 : 0); + DBWriteContactSettingByte(hContact, MODULE_NAME, "NeverHide", (SendMessage(GetDlgItem(hdlg, IDC_CHECK_NEVERHIDE), BM_GETCHECK, 0, 0) == BST_CHECKED) ? 1 : 0); + } + break; + } + } + break; + } + break; + + case WM_COMMAND: + if (wparam == MAKEWPARAM(IDC_EDITABSENCE, EN_CHANGE)) + SendMessage(GetParent(hdlg), PSM_CHANGED, 0, 0); + else if (LOWORD(wparam) == IDCANCEL) + SendMessage(GetParent(hdlg), msg, wparam, lparam); + break; + } + + return FALSE; +} + +int UserinfoInit(WPARAM wparam, LPARAM lparam) +{ + if (lparam > 0) + { + OPTIONSDIALOGPAGE uip = {0}; + uip.cbSize = sizeof(uip); + uip.hInstance = hInst; + uip.pszTemplate = MAKEINTRESOURCE(IDD_USERINFO); + uip.pszTitle = Translate("Buddy Expectator"); + uip.pfnDlgProc = UserinfoDlgProc; + + UserInfo_AddPage(wparam, &uip); + } + return 0; +} + + +HANDLE hEventOptInitialise; +void InitOptions() +{ + LoadOptions(); + hEventOptInitialise = HookEvent(ME_OPT_INITIALISE, OptionsInit); +} + +void DeinitOptions() +{ + UnhookEvent(hEventOptInitialise); +} diff --git a/plugins/BuddyExpectator/src/options.h b/plugins/BuddyExpectator/src/options.h new file mode 100644 index 0000000000..ade65c50e6 --- /dev/null +++ b/plugins/BuddyExpectator/src/options.h @@ -0,0 +1,64 @@ +/* + Buddy Expectator+ plugin for Miranda-IM (www.miranda-im.org) + (c)2005 Anar Ibragimoff (ai91@mail.ru) + (c)2006 Scott Ellis (mail@scottellis.com.au) + (c)2007,2008 Alexander Turyak (thief@miranda-im.org.ua) + + 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 + + File name : $URL: http://svn.miranda.im/mainrepo/buddyexpectator/trunk/options.h $ + Revision : $Rev: 1003 $ + Last change on : $Date: 2008-01-12 17:15:47 +0200 (Сб, 12 янв 2008) $ + Last change by : $Author: Thief $ +*/ + +#ifndef _OPTIONS_INC +#define _OPTIONS_INC + +typedef enum GoneContactAction { GCA_NOACTION, GCA_DELETE, GCA_UDETAILS, GCA_MESSAGE }; + +typedef struct { + int iAbsencePeriod; // notify period for returning contacts + int iShowPopUp; + int iShowEvent; + int iShowUDetails; + int iShowMessageWindow; + + bool notifyFirstOnline; + bool enableMissYou; + bool hideInactive; + byte MissYouIcon; + + int iAbsencePeriod2; // notify period for contacts that have remained away + int iShowPopUp2; + int iShowEvent2; + GoneContactAction action2; + + int iSilencePeriod; // notify period for contacts that didn't send messages + + int iPopUpColorBack; + int iPopUpColorFore; + int iPopUpDelay; + int iUsePopupColors; + int iUseWinColors; + +} Options; + +extern Options options; + +void InitOptions(); +void DeinitOptions(); + +#endif diff --git a/plugins/BuddyExpectator/src/resource.h b/plugins/BuddyExpectator/src/resource.h new file mode 100644 index 0000000000..b06406ada8 --- /dev/null +++ b/plugins/BuddyExpectator/src/resource.h @@ -0,0 +1,56 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by BuddyExpectator.rc +// +#define IDI_MAINICON 101 +#define IDI_ENABLED 102 +#define IDI_DISABLED 103 +#define IDI_HIDE 104 +#define IDI_NEVERHIDE 105 +#define IDD_OPTIONSPANEL 201 +#define IDD_POPUPPANEL 202 +#define IDD_USERINFO 203 +#define IDC_CHECK_POPUP 1000 +#define IDC_CHECK_POPUP2 1001 +#define IDC_CHECK_UDETAILS 1002 +#define IDC_CHECK_MSGWINDOW 1003 +#define IDC_CHECK_FLASHICON 1004 +#define IDC_CHECK_FLASHICON2 1005 +#define IDC_CHECK_FIRSTSIGHT 1006 +#define IDC_COMBO_PERIOD 1011 +#define IDC_COMBO_PERIOD2 1012 +#define IDC_COMBO_PERIOD3 1013 +#define IDC_COLOR_FRG 1021 +#define IDC_COLOR_BGR 1022 +#define IDC_COLORS_POPUP 1023 +#define IDC_COLORS_WIN 1024 +#define IDC_DELAY_DEF 1031 +#define IDC_DELAY_CUST 1032 +#define IDC_DELAY_PERM 1033 +#define IDC_EDIT_ABSENCE 1041 +#define IDC_EDIT_ABSENCE2 1042 +#define IDC_EDIT_POPUPDELAY 1043 +#define IDC_EDIT_SILENTFOR 1044 +#define IDC_EDIT_LASTSEEN 1045 +#define IDC_EDIT_LASTINPUT 1046 +#define IDC_EDIT_NOINPUTFOR 1047 +#define IDC_EDIT_WILLNOTICE 1048 +#define IDC_PREVIEW 1061 +#define IDC_CHECK_MISSYOU 1203 +#define IDC_EDITABSENCE 1204 +#define IDC_SPINABSENCE 1205 +#define IDC_CHECK_NOMSGS 1208 +#define IDC_COMBO_ACTIONS 1209 +#define IDC_CHECK_NEVERHIDE 1210 +#define IDC_CHECK_NOTIFYALWAYS 1211 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 106 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1212 +#define _APS_NEXT_SYMED_VALUE 121 +#endif +#endif -- cgit v1.2.3