From 48540940b6c28bb4378abfeb500ec45a625b37b6 Mon Sep 17 00:00:00 2001 From: Vadim Dashevskiy Date: Tue, 15 May 2012 10:38:20 +0000 Subject: initial commit git-svn-id: http://svn.miranda-ng.org/main/trunk@2 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/BossKeyPlus/BossKey.cpp | 951 +++++++++++++++++++++ plugins/BossKeyPlus/BossKey.h | 122 +++ plugins/BossKeyPlus/BossKey.rc | 214 +++++ plugins/BossKeyPlus/BossKey.vcproj | 362 ++++++++ plugins/BossKeyPlus/BossKeyIdle.cpp | 91 ++ plugins/BossKeyPlus/BossKeyTriggers.cpp | 146 ++++ plugins/BossKeyPlus/BossKey_10.sln | 25 + plugins/BossKeyPlus/BossKey_10.vcxproj | 294 +++++++ plugins/BossKeyPlus/BossKey_10.vcxproj.filters | 55 ++ plugins/BossKeyPlus/BossKey_9.vcproj | 449 ++++++++++ plugins/BossKeyPlus/Options.cpp | 417 +++++++++ plugins/BossKeyPlus/Resource.rc | 2 + plugins/BossKeyPlus/docs/bosskey_plus_langpack.txt | Bin 0 -> 1874 bytes plugins/BossKeyPlus/docs/bosskey_plus_license.txt | 340 ++++++++ plugins/BossKeyPlus/docs/bosskey_plus_readme.txt | 127 +++ plugins/BossKeyPlus/icos/logo.ico | Bin 0 -> 9062 bytes plugins/BossKeyPlus/resource.h | 49 ++ plugins/BossKeyPlus/version.h | 26 + plugins/BossKeyPlus/version.rc | 40 + 19 files changed, 3710 insertions(+) create mode 100644 plugins/BossKeyPlus/BossKey.cpp create mode 100644 plugins/BossKeyPlus/BossKey.h create mode 100644 plugins/BossKeyPlus/BossKey.rc create mode 100644 plugins/BossKeyPlus/BossKey.vcproj create mode 100644 plugins/BossKeyPlus/BossKeyIdle.cpp create mode 100644 plugins/BossKeyPlus/BossKeyTriggers.cpp create mode 100644 plugins/BossKeyPlus/BossKey_10.sln create mode 100644 plugins/BossKeyPlus/BossKey_10.vcxproj create mode 100644 plugins/BossKeyPlus/BossKey_10.vcxproj.filters create mode 100644 plugins/BossKeyPlus/BossKey_9.vcproj create mode 100644 plugins/BossKeyPlus/Options.cpp create mode 100644 plugins/BossKeyPlus/Resource.rc create mode 100644 plugins/BossKeyPlus/docs/bosskey_plus_langpack.txt create mode 100644 plugins/BossKeyPlus/docs/bosskey_plus_license.txt create mode 100644 plugins/BossKeyPlus/docs/bosskey_plus_readme.txt create mode 100644 plugins/BossKeyPlus/icos/logo.ico create mode 100644 plugins/BossKeyPlus/resource.h create mode 100644 plugins/BossKeyPlus/version.h create mode 100644 plugins/BossKeyPlus/version.rc (limited to 'plugins/BossKeyPlus') diff --git a/plugins/BossKeyPlus/BossKey.cpp b/plugins/BossKeyPlus/BossKey.cpp new file mode 100644 index 0000000000..a0c3e18cae --- /dev/null +++ b/plugins/BossKeyPlus/BossKey.cpp @@ -0,0 +1,951 @@ +/* + BossKey - Hide Miranda from your boss :) + Copyright (C) 2002-2003 Goblineye Entertainment, (C) 2007-2010 Billy_Bons + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#include "BossKey.h" +#include "m_updater.h" +#include "m_msg_buttonsbar.h" + +// multiple instances support: +// when hotkey is hit, handler notifies all listen windows +//#pragma data_seg("Shared") // Shared data segment +// these must be shared, since they're called by the hook (The hook is global and called from the context of each process) +//HHOOK g_hKeyHook = NULL; // shared +// this isn't referenced by hook, but should be shared to keep a reference count of multiple instances +//WORD g_wRefCount = 0; // reference count. when this is 0 on init, the hook is created. when this is 0 on destruction, the hook is destroyed. +//#pragma data_seg() // end of shared data segment + +// unique to this DLL, not to be shared +HINSTANCE g_hInstance; +PLUGINLINK *pluginLink; +MM_INTERFACE mmi; +CLIST_INTERFACE *pcli; +HANDLE g_hmGenMenuInit, g_hIcon, g_hMenuItem, g_hHideService, g_hIsHiddenService; +HANDLE g_hHooks[7]; +HWINEVENTHOOK g_hWinHook; +HWND g_hListenWindow, hDlg, g_hDlgPass, hOldForegroundWindow; +HWND_ITEM *g_pMirWnds; // a pretty simple linked list +HMODULE hWTS, hDwmApi; +DWORD g_dwMirandaPID; +WORD g_wMask, g_wMaskAdv; +bool g_bWindowHidden, g_fKeyPressed, g_fPassRequested, g_TrayIcon; +char g_password[MAXPASSLEN + 1]; +HKL oldLangID, oldLayout; +int protoCount; +PROTOCOLDESCRIPTOR **proto; +unsigned *oldStatus; +TCHAR **oldStatusMsg; +BYTE g_bOldSetting; +int hLangpack; + +PWTSRegisterSessionNotification wtsRegisterSessionNotification ; +PWTSUnRegisterSessionNotification wtsUnRegisterSessionNotification; +PFNDwmIsCompositionEnabled dwmIsCompositionEnabled; + +void LanguageChanged(HWND hDlg); + +static PLUGININFOEX pluginInfo = { + sizeof(PLUGININFOEX), + __PLUGIN_NAME, + __VERSION_DWORD, + __DESC, + __AUTHORS, + __EMAIL, + __COPYRIGHTS, + __FL __PLUGIN_ID_STR, + UNICODE_AWARE, + 0, +#if defined( _UNICODE ) + //4fac353d-0a36-44a4-9064-6759c53ae782 + {0x4fac353d, 0x0a36, 0x44a4, { 0x90, 0x64, 0x67, 0x59, 0xc5, 0x3a, 0xe7, 0x82 }} +#else + //0be17104-518f-411c-9bb7-7c1042a2ed02 + {0x0be17104, 0x518f, 0x411c, { 0x9b, 0xb7, 0x7c, 0x10, 0x42, 0xa2, 0xed, 0x02 }} +#endif +}; + +BOOL WINAPI DllMain(HINSTANCE hinstDLL,DWORD fdwReason,LPVOID lpvReserved) +{ + g_hInstance = hinstDLL; + return(true); +} + +extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD mirandaVersion) +{ + if ( mirandaVersion < PLUGIN_MAKE_VERSION(0,8,0,0)) { + MessageBox( NULL, _T("The BossKey+ cannot be loaded. It requires Miranda IM 0.8 or later."), _T("BossKey+"), MB_OK|MB_ICONWARNING|MB_SETFOREGROUND|MB_TOPMOST ); + return NULL; + } + pluginInfo.cbSize = sizeof(PLUGININFOEX); + return &pluginInfo; +} + + +static const MUUID interfaces[] = { MIID_BOSSKEY, MIID_LAST }; +extern "C" __declspec(dllexport) const MUUID* MirandaPluginInterfaces(void) +{ + return interfaces; +} + +static BOOL IsAeroMode() +{ + BOOL result; + return dwmIsCompositionEnabled && (dwmIsCompositionEnabled(&result) == S_OK) && result; +} + +INT_PTR CALLBACK DlgStdInProc(HWND hDlg, UINT uMsg,WPARAM wParam,LPARAM lParam) +{ + static DWORD dwOldIcon = 0; + HICON hIcon = 0; + + switch(uMsg) + { + case WM_INITDIALOG: + { + g_hDlgPass = hDlg; + hIcon = LoadIcon(g_hInstance, MAKEINTRESOURCE(IDI_DLGPASSWD)); + dwOldIcon = SetClassLongPtr(hDlg, GCLP_HICON, (LONG)hIcon); // set alt+tab icon + SendDlgItemMessage(hDlg,IDC_EDIT1,EM_LIMITTEXT,MAXPASSLEN,0); + + if (IsAeroMode()) + { + SetWindowLongPtr(hDlg, GWL_STYLE, GetWindowLongPtr(hDlg, GWL_STYLE) | WS_DLGFRAME | WS_SYSMENU); + + RECT rect; + GetClientRect(hDlg, &rect); + SetWindowPos(hDlg, 0, 0, 0, rect.right, rect.bottom + + GetSystemMetrics(SM_CYCAPTION) + GetSystemMetrics(SM_CXSIZEFRAME), + SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOZORDER); + } + SendMessage(GetDlgItem(hDlg, IDC_HEADERBAR), WM_SETICON, 0, (LPARAM)hIcon); + SetWindowText(GetDlgItem(hDlg, IDC_HEADERBAR), _T("Miranda IM is locked.\nEnter password to unlock it.")); + + TranslateDialogDefault(hDlg); + oldLangID = 0; + SetTimer(hDlg,1,200,NULL); + + oldLayout = GetKeyboardLayout(0); + if (MAKELCID((WORD)oldLayout & 0xffffffff, SORT_DEFAULT) != (LCID)0x00000409) + ActivateKeyboardLayout((HKL)0x00000409, 0); + LanguageChanged(hDlg); + return TRUE; + } + + case WM_CTLCOLORSTATIC: + { + if (GetWindowLongPtr((HWND)lParam, GWLP_ID) == IDC_LANG) + { + SetTextColor((HDC)wParam, GetSysColor(COLOR_HIGHLIGHTTEXT)); + SetBkMode((HDC)wParam, TRANSPARENT); + return (INT_PTR)GetSysColorBrush(COLOR_HIGHLIGHT); + } + return FALSE; + } + + case WM_COMMAND: + { + UINT uid = LOWORD(wParam); + if(uid == IDOK){ + char password[MAXPASSLEN + 1] = {0}; + int passlen = GetDlgItemTextA(hDlg,IDC_EDIT1,password,MAXPASSLEN+1); + + if (passlen == 0) + { + SetWindowText(GetDlgItem(hDlg, IDC_HEADERBAR), TranslateT("Miranda IM is locked.\nEnter password to unlock it.")); + SendMessage(GetDlgItem(hDlg, IDC_HEADERBAR), WM_NCPAINT, 0, 0); + } + else if (lstrcmpA(password, g_password)) + { + SetWindowText(GetDlgItem(hDlg, IDC_HEADERBAR), TranslateT("Password is not correct!\nPlease, enter correct password.")); + SendMessage(GetDlgItem(hDlg, IDC_HEADERBAR), WM_NCPAINT, 0, 0); + SetDlgItemTextA(hDlg, IDC_EDIT1, ""); + } + else EndDialog(hDlg,IDOK); + + }else if (uid == IDCANCEL) + EndDialog(hDlg,IDCANCEL); + } + + case WM_TIMER: + { + LanguageChanged(hDlg); + return FALSE; + } + case WM_DESTROY: + { + KillTimer(hDlg, 1); + if (GetKeyboardLayout(0) != oldLayout) + ActivateKeyboardLayout(oldLayout, 0); + SetClassLongPtr(hDlg, GCLP_HICON, (long)dwOldIcon); + DestroyIcon(hIcon); + return FALSE; + } + + }return FALSE; +} + +static void LanguageChanged(HWND hDlg) +{ + HKL LangID = GetKeyboardLayout(0); + char Lang[3] = {0}; + if (LangID != oldLangID) + { + oldLangID = LangID; + GetLocaleInfoA(MAKELCID(((WORD)LangID & 0xffffffff), SORT_DEFAULT), LOCALE_SABBREVLANGNAME, Lang, 2); + Lang[0] = toupper(Lang[0]); + Lang[1] = tolower(Lang[1]); + SetDlgItemTextA(hDlg, IDC_LANG, Lang); + } +} + +BOOL CALLBACK EnumWindowsProc(HWND hWnd,LPARAM lParam) +{ + DWORD dwWndPID; + GetWindowThreadProcessId(hWnd,&dwWndPID); + + if ((g_dwMirandaPID == dwWndPID) && hWnd != g_hDlgPass /* && (GetWindowLongPtr(hWnd,GWLP_HWNDPARENT) == NULL)*/ && (IsWindowVisible(hWnd))) + { + char szTemp[32]; + GetClassNameA(hWnd,szTemp,32); + + if (lstrcmpA(szTemp,"MirandaThumbsWnd") == 0) // hide floating contacts + { + CallService("FloatingContacts/MainHideAllThumbs",0,0); + g_bOldSetting |= OLD_FLTCONT; + } + else + if (lstrcmpA(szTemp,"PopupWnd2") == 0 || lstrcmpA(szTemp,"YAPPWinClass") == 0) // destroy opened popups + SendMessage(hWnd, UM_DESTROYPOPUP,0,0); +// else +// if (lstrcmpA(szTemp,"#32770") == 0) +// SendMessage(hWnd, WM_CLOSE,0,0); + else + { + HWND_ITEM *node = new HWND_ITEM; + node->hWnd = hWnd; + // add to list + node->next = g_pMirWnds; + g_pMirWnds = node; + ShowWindow(hWnd,SW_HIDE); + } + } + return(true); +} + +TCHAR* GetDefStatusMsg(unsigned uStatus, const char* szProto) +{ + TCHAR *ret = (TCHAR *)CallService ( MS_AWAYMSG_GETSTATUSMSGT, (WPARAM)uStatus, (LPARAM)szProto ); + if ( (int)ret == CALLSERVICE_NOTFOUND ) + { + char* tmp = ( char* )CallService( MS_AWAYMSG_GETSTATUSMSG, (WPARAM)uStatus, (LPARAM)szProto ); + ret = mir_a2t( tmp ); + mir_free( tmp ); + } + return ret; +} + +void SetStatus(const char* szProto, unsigned status, TCHAR *tszAwayMsg) +{ + if ( tszAwayMsg && CallProtoService( szProto, PS_GETCAPS, PFLAGNUM_1, 0 ) & PF1_MODEMSGSEND ) + { + if ( CallProtoService( szProto, PS_SETAWAYMSGT, status, (LPARAM) tszAwayMsg ) == CALLSERVICE_NOTFOUND ) + { + char *szAwayMsg = mir_t2a(tszAwayMsg); + CallProtoService( szProto, PS_SETAWAYMSG, status, (LPARAM) szAwayMsg ); + mir_free(szAwayMsg); + } + } + CallProtoService( szProto, PS_SETSTATUS, status, 0 ); +} + +static int ChangeAllProtoStatuses(unsigned statusMode, TCHAR *msg) +{ + for (int i=0; i < protoCount; i++) + { + unsigned status = CallProtoService(proto[i]->szName,PS_GETSTATUS,0,0); + if ( + (proto[i]->type == PROTOTYPE_PROTOCOL) + && + (g_wMask & OPT_ONLINEONLY) ? // check "Change only if current status is Online" option + ((status == ID_STATUS_ONLINE) || (status == ID_STATUS_FREECHAT)) // process only "online" and "free for chat" + : + ((status > ID_STATUS_OFFLINE) && (status < ID_STATUS_IDLE) && (status != ID_STATUS_INVISIBLE)) // process all existing statuses except for "invisible" & "offline" + ) + { + if (g_wMask & OPT_SETONLINEBACK){ // need to save old statuses & status messages + oldStatus[i] = status; + + char svc[256]; + mir_snprintf(svc, 256, "%s%s", proto[i]->szName, PS_GETMYAWAYMSG); + if (ServiceExists (svc)) + { + if (ServiceExists (MS_AWAYMSG_GETSTATUSMSGT)) // if core can support unicode status message + oldStatusMsg[i] = (TCHAR *)CallService (svc, 0, SGMA_TCHAR); + else + { + char *tmp = (char *)CallService (svc, 0, 0); + oldStatusMsg[i] = mir_a2t(tmp); + mir_free(tmp); + } + } + else + oldStatusMsg[i] = GetDefStatusMsg(status, proto[i]->szName); + } + SetStatus(proto[i]->szName, statusMode, msg); + } + } + return 0; +} + +static int BackAllProtoStatuses(void) +{ + for (int i=0; i < protoCount; i++) + { + if ( oldStatus[i] ) + { + SetStatus(proto[i]->szName, oldStatus[i], oldStatusMsg[i]); + if (oldStatusMsg[i]) + { + mir_free(oldStatusMsg[i]); + oldStatusMsg[i] = 0; + } + oldStatus[i] = 0; + } + } + return 0; +} + +static void CreateTrayIcon(bool create) +{ + NOTIFYICONDATA nim; + DBVARIANT dbVar; + if (!DBGetContactSettingTString(NULL,MOD_NAME,"ToolTipText",&dbVar)) + { + mir_sntprintf(nim.szTip, 64, _T("%s"), dbVar.ptszVal); + DBFreeVariant(&dbVar); + } + else + lstrcpy(nim.szTip, _T("Miranda IM")); + + nim.cbSize = sizeof(nim); + nim.hWnd = g_hListenWindow; + nim.uID = 100; + nim.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP; + nim.hIcon = ( HICON )CallService( MS_SKIN2_GETICON, 0, (LPARAM)"hidemim" ); + nim.uCallbackMessage = WM_USER + 24; + Shell_NotifyIcon(create ? NIM_ADD : NIM_DELETE, &nim); + g_TrayIcon = create; +} + +static void RestoreOldSettings(void) +{ + if (g_bOldSetting & OLD_POPUP) + CallService(MS_POPUP_QUERY, PUQS_ENABLEPOPUPS, 0); + + if (g_bOldSetting & OLD_SOUND) + DBWriteContactSettingByte(NULL,"Skin","UseSound", 1); + + if (g_bOldSetting & OLD_FLTCONT) // show Floating contacts if needed + { + if(ServiceExists("FloatingContacts/MainHideAllThumbs")) + CallService("FloatingContacts/MainHideAllThumbs",0,0); + else + DBWriteContactSettingByte(NULL,"FloatingContacts","HideAll", 0); + } + g_bOldSetting = 0; +} + +LRESULT CALLBACK ListenWndProc(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam) +{ + switch (uMsg) + { + case WM_WTSSESSION_CHANGE: + { + if (wParam == WTS_SESSION_LOCK && g_wMaskAdv & OPT_HIDEIFLOCK && !g_bWindowHidden) // Windows locked + PostMessage(hWnd,WM_USER + 40, 0, 0); + return 0; + }break; + + case WM_USER + 24: + { + if (lParam == WM_LBUTTONDBLCLK) + PostMessage(hWnd,WM_USER + 52, 0, 0); + return 0; + }break; + + case WM_USER+40: // hide + { + if (g_bWindowHidden || g_fOptionsOpen) // already hidden or in options, no hiding + break; + + if (ServiceExists(MS_TRIGGER_REGISTERTRIGGER)) + BossKeyEvent(g_bWindowHidden, 0); + + DWORD dwWndPID; // remember foreground window + HWND hForegroundWnd = GetForegroundWindow(); + GetWindowThreadProcessId(hForegroundWnd,&dwWndPID); + if (g_dwMirandaPID == dwWndPID) + hOldForegroundWindow = hForegroundWnd; + + EnumWindows(EnumWindowsProc, 0); + + if (g_wMask & OPT_CHANGESTATUS) // is this even needed? + { + BYTE bReqMode = DBGetContactSettingByte(NULL,MOD_NAME,"stattype",2); + unsigned uMode = (STATUS_ARR_TO_ID[bReqMode]); + DBVARIANT dbVar; + if (g_wMask & OPT_USEDEFMSG || DBGetContactSettingTString(NULL,MOD_NAME,"statmsg",&dbVar)) + { + TCHAR *ptszDefMsg = GetDefStatusMsg(uMode, 0); + ChangeAllProtoStatuses(uMode, ptszDefMsg); + if(ptszDefMsg) + mir_free(ptszDefMsg); + } + else + { + if (ServiceExists(MS_VARS_FORMATSTRING)) + { + FORMATINFO fi; + TCHAR *ptszParsed; + + ZeroMemory(&fi, sizeof(fi)); + fi.cbSize = sizeof(fi); + fi.flags = FIF_TCHAR; + fi.tszFormat = dbVar.ptszVal; + ptszParsed = (TCHAR*)CallService(MS_VARS_FORMATSTRING, (WPARAM)&fi, 0); + ChangeAllProtoStatuses(uMode, ptszParsed); + if (ptszParsed) + CallService(MS_VARS_FREEMEMORY, (WPARAM)ptszParsed, 0); + }else + ChangeAllProtoStatuses(uMode, dbVar.ptszVal); + DBFreeVariant(&dbVar); + } + } + + pcli->pfnTrayIconDestroy (pcli->hwndContactList); + pcli->pfnUninitTray(); + + if (g_wMask & OPT_TRAYICON) + CreateTrayIcon(true); + + // disable popups + if (CallService(MS_POPUP_QUERY, PUQS_GETSTATUS, 0) == 1) + { + // save current + g_bOldSetting |= OLD_POPUP; + CallService(MS_POPUP_QUERY, PUQS_DISABLEPOPUPS, 0); + } + + // disable sounds + if ((g_wMask & OPT_DISABLESNDS) && DBGetContactSettingByte(NULL,"Skin","UseSound",1)) + { + // save current + g_bOldSetting |= OLD_SOUND; + DBWriteContactSettingByte(NULL,"Skin","UseSound",0); + } + + g_bWindowHidden = true; + + g_bOldSetting |= OLD_WASHIDDEN; + DBWriteContactSettingByte(NULL, MOD_NAME, "OldSetting", g_bOldSetting); + return(0); + } break; + case WM_USER+52: // back + { + if (!g_bWindowHidden || g_fPassRequested) + break; + + if (g_wMask & OPT_REQPASS){ //password request + DBVARIANT dbVar = {0}; + if(!DBGetContactSettingString(NULL,MOD_NAME,"password",&dbVar)) + { + g_fPassRequested = true; + + strncpy(g_password, dbVar.pszVal, MAXPASSLEN); + DBFreeVariant(&dbVar); + CallService( MS_DB_CRYPT_DECODESTRING, MAXPASSLEN+1, ( LPARAM )g_password ); + + int res = DialogBox(g_hInstance,(MAKEINTRESOURCE(IDD_PASSDIALOGNEW)),GetForegroundWindow(),(DLGPROC)DlgStdInProc); + + g_fPassRequested = false; + if(res != IDOK) return 0; + } + } + + if (ServiceExists(MS_TRIGGER_REGISTERTRIGGER)) + BossKeyEvent(g_bWindowHidden, 0); + + if (g_wMask & OPT_CHANGESTATUS && g_wMask & OPT_SETONLINEBACK) // set back to some status + { + BackAllProtoStatuses(); + } + + HWND_ITEM *pCurWnd = g_pMirWnds; + while (pCurWnd != NULL) + { + HWND_ITEM *pNextWnd = pCurWnd->next; + char szTemp[32]; + GetClassNameA(pCurWnd->hWnd,szTemp,32); + + if (IsWindow(pCurWnd->hWnd) && lstrcmpA(szTemp,"SysShadow") != 0) // precaution + { + ShowWindow(pCurWnd->hWnd, SW_SHOW); + } + + delete pCurWnd; // bye-bye + pCurWnd = pNextWnd; // traverse to next item + } + g_pMirWnds = NULL; + + if (hOldForegroundWindow) + { + SetForegroundWindow(hOldForegroundWindow); + hOldForegroundWindow = NULL; + } + + RestoreOldSettings(); + + if (g_TrayIcon) CreateTrayIcon(false); + + pcli->pfnInitTray(); + pcli->pfnTrayIconInit(pcli->hwndContactList); //this restores the icons without memory leaks :) + + // force a redraw + // should prevent drawing problems + InvalidateRect(pcli->hwndContactList,NULL,true); + UpdateWindow(pcli->hwndContactList); + + PostMessage(hWnd, WM_MOUSEMOVE, 0, (LPARAM)MAKELONG(2, 2)); // reset core's IDLE + g_bWindowHidden = false; + + DBWriteContactSettingByte(NULL, MOD_NAME, "OldSetting", 0); + return(0); + } break; + default:break; + } + return(DefWindowProc(hWnd,uMsg,wParam,lParam)); +} + +static int MsgWinOpening(WPARAM wParam, LPARAM lParam) // hiding new message windows +{ + if (g_bWindowHidden) + EnumWindows(EnumWindowsProc,0); + return 0; +} + +VOID CALLBACK WinEventProc(HWINEVENTHOOK g_hWinHook, DWORD event, HWND hwnd, LONG idObject, LONG idChild, DWORD dwEventThread, DWORD dwmsEventTime) +{ + if (g_bWindowHidden && idObject == OBJID_WINDOW && (event == EVENT_OBJECT_CREATE || event == EVENT_OBJECT_SHOW) && (IsWindowVisible(hwnd)) ) + { + if(hwnd == pcli->hwndContactList) + ShowWindow(hwnd,SW_HIDE); + else + EnumWindows(EnumWindowsProc,0); + } +} + +INT_PTR BossKeyHideMiranda(WPARAM wParam, LPARAM lParam) // for service :) +{ + PostMessage(g_hListenWindow, WM_USER + ((g_bWindowHidden) ? (52) : (40)), 0, 0); + return 0; +} + +static TCHAR *HokeyVkToName(WORD vkKey) +{ + static TCHAR buf[32] = {0}; + DWORD code = MapVirtualKey(vkKey, 0) << 16; + + switch (vkKey) + { + case 0: + case VK_CONTROL: + case VK_SHIFT: + case VK_MENU: + case VK_LWIN: + case VK_RWIN: + case VK_PAUSE: + case VK_CANCEL: + case VK_CAPITAL: + return _T(""); + + case VK_DIVIDE: + case VK_INSERT: + case VK_HOME: + case VK_PRIOR: + case VK_DELETE: + case VK_END: + case VK_NEXT: + case VK_LEFT: + case VK_RIGHT: + case VK_UP: + case VK_DOWN: + case VK_NUMLOCK: + code |= (1UL << 24); + } + + GetKeyNameText(code, buf, SIZEOF(buf)); + return buf; +} + +static TCHAR *GetBossKeyText(void) +{ + WORD wHotKey = DBGetContactSettingWord(NULL,"SkinHotKeys","Hide/Show Miranda",HOTKEYCODE(HOTKEYF_CONTROL, VK_F12)); + + BYTE key = LOBYTE(wHotKey); + BYTE shift = HIBYTE(wHotKey); + static TCHAR buf[128] = {0}; + + mir_sntprintf(buf, SIZEOF(buf), _T("%s%s%s%s%s"), + (shift & HOTKEYF_CONTROL) ? _T("Ctrl + ") : _T(""), + (shift & HOTKEYF_SHIFT) ? _T("Shift + ") : _T(""), + (shift & HOTKEYF_ALT) ? _T("Alt + ") : _T(""), + (shift & HOTKEYF_EXT) ? _T("Win + ") : _T(""), + HokeyVkToName(key)); + + return buf; +} + +static int IcoLibInit (void) // Icolib support +{ + SKINICONDESC sid = {0}; + TCHAR tszFile[MAX_PATH]; + GetModuleFileName(g_hInstance, tszFile, MAX_PATH); + + sid.cbSize = sizeof(SKINICONDESC); + sid.flags = SIDF_ALL_TCHAR; + sid.ptszDefaultFile = tszFile; + sid.cx = sid.cy = 16; + sid.ptszSection = _T("BossKey"); + + sid.pszName = "hidemim"; + sid.ptszDescription = _T("Hide Miranda IM"); + sid.iDefaultIndex = -IDI_DLGPASSWD; + g_hIcon = (HANDLE)CallService(MS_SKIN2_ADDICON, 0, (LPARAM)&sid); + + return 0; +} + +static int GenMenuInit(WPARAM wParam, LPARAM lParam) // Modify menu item text before to show the main menu +{ + if (g_hMenuItem) + { + CLISTMENUITEM mi = {0}; + TCHAR buf[128] = {0}; + mir_sntprintf(buf, SIZEOF(buf), _T("%s [%s]"), TranslateT("Hide"), GetBossKeyText()); + + mi.cbSize = sizeof(mi); + mi.flags = CMIM_FLAGS | CMIF_TCHAR | CMIM_NAME; + mi.ptszName = buf; + + CallService(MS_CLIST_MODIFYMENUITEM,(WPARAM)g_hMenuItem,(LPARAM)&mi); + } + return 0; +} + +void BossKeyMenuItemInit(void) // Add menu item +{ + CLISTMENUITEM mi = {0}; + + mi.cbSize = sizeof(mi); + mi.flags = CMIF_TCHAR; + mi.position = 2000100000; + mi.pszPopupName = 0; + mi.hIcon = ( HICON )CallService( MS_SKIN2_GETICON, 0, (LPARAM)"hidemim" ); + mi.ptszName = _T("Hide"); + mi.pszService = MS_BOSSKEY_HIDE; + + g_hMenuItem = (HANDLE)CallService(MS_CLIST_ADDMAINMENUITEM,0,(LPARAM)&mi); + + g_hmGenMenuInit = HookEvent(ME_CLIST_PREBUILDMAINMENU, GenMenuInit); +} + +void BossKeyMenuItemUnInit(void) // Remove menu item +{ + CallService(MS_CLIST_REMOVEMAINMENUITEM, (WPARAM)g_hMenuItem, 0); + g_hMenuItem = 0; + if(g_hmGenMenuInit) + UnhookEvent(g_hmGenMenuInit); + g_hmGenMenuInit = 0; +} + +void RegisterCoreHotKeys (void) +{ + HOTKEYDESC hotkey = {0}; + hotkey.cbSize = sizeof(HOTKEYDESC); + hotkey.pszName = "Hide/Show Miranda"; + hotkey.pszDescription = LPGEN("Hide/Show Miranda"); + hotkey.pszSection = "BossKey"; + hotkey.pszService = MS_BOSSKEY_HIDE; + hotkey.DefHotKey = HOTKEYCODE(HOTKEYF_CONTROL, VK_F12); + + CallService(MS_HOTKEY_REGISTER, 0, (LPARAM)&hotkey); +} + +static int ModernToolbarInit(WPARAM, LPARAM) // Modern toolbar support +{ + TBButton button = {0}; + button.cbSize = sizeof(button); + button.pszServiceName = MS_BOSSKEY_HIDE; + button.pszButtonID = MOD_NAME; + button.pszTooltipUp = button.pszTooltipDn = button.pszButtonName = "Hide Miranda IM"; + button.defPos = 1099; + button.tbbFlags = TBBF_DISABLED|TBBF_SHOWTOOLTIP; + button.hPrimaryIconHandle = button.hSecondaryIconHandle = g_hIcon; + CallService(MS_TB_ADDBUTTON, 0, (LPARAM)&button); + return 0; +} + +// Tabsrmm toolbar support +static int TabsrmmButtonPressed(WPARAM wParam, LPARAM lParam) +{ + CustomButtonClickData *cbcd=(CustomButtonClickData *)lParam; + + if(!strcmp(cbcd->pszModule, MOD_NAME)) + BossKeyHideMiranda(0, 0); + + return 0; +} + +static int TabsrmmButtonsInit(WPARAM wParam, LPARAM lParam) +{ + BBButton bbd = {0}; + + bbd.cbSize = sizeof(BBButton); + bbd.pszModuleName = MOD_NAME; + bbd.dwDefPos = 5000; + bbd.ptszTooltip = _T("Hide Miranda IM"); + bbd.bbbFlags = BBBF_ISRSIDEBUTTON | BBBF_CANBEHIDDEN; + bbd.hIcon = g_hIcon; + CallService (MS_BB_ADDBUTTON, 0, (LPARAM)&bbd); + + return 0; +} + +static TCHAR *VariablesBossKey(ARGUMENTSINFO *ai) { + if (ai->cbSize < sizeof(ARGUMENTSINFO)) return NULL; + if (ai->argc != 1) return NULL; + + ai->flags |= AIF_DONTPARSE; + + return GetBossKeyText(); +} + +static int EnumProtos(WPARAM wParam, LPARAM lParam) +{ + CallService(MS_PROTO_ENUMPROTOCOLS,(WPARAM)&protoCount,(LPARAM)&proto); + + delete[] oldStatus; + delete[] oldStatusMsg; + + oldStatus = new unsigned[protoCount]; + oldStatusMsg = new TCHAR* [protoCount]; + for (int i = 0; i < protoCount; i++) + { + oldStatus[i] = 0; + oldStatusMsg[i] = 0; + } + return 0; +} + +int MirandaLoaded(WPARAM wParam,LPARAM lParam) +{ + g_wMask = DBGetContactSettingWord(NULL,MOD_NAME,"optsmask",DEFAULTSETTING); + + RegisterCoreHotKeys(); + +#ifndef _UNICODE + if (IsWinVer2000Plus()) +#endif + g_hWinHook = SetWinEventHook(EVENT_OBJECT_CREATE, EVENT_OBJECT_SHOW, + NULL, WinEventProc, GetCurrentProcessId(), 0, 0); + + g_hHooks[0] = HookEvent(ME_OPT_INITIALISE,OptsDlgInit); + g_hHooks[1] = HookEvent(ME_MSG_WINDOWEVENT,MsgWinOpening); + g_hHooks[2] = HookEvent(ME_PROTO_ACCLISTCHANGED, EnumProtos); + g_hHooks[3] = HookEvent(ME_MSG_TOOLBARLOADED, TabsrmmButtonsInit); + if (g_hHooks[3]) + g_hHooks[4] = HookEvent(ME_MSG_BUTTONPRESSED, TabsrmmButtonPressed); + + pcli = (CLIST_INTERFACE *)CallService(MS_CLIST_RETRIEVE_INTERFACE, 0, (LPARAM)g_hInstance); +#if defined _DEBUG + if (pcli == 0) + { + MessageBox(NULL,_T("Can't get CLIST_INTERFACE!"),_T("BossKey+"),MB_ICONERROR); + return 1; + }else +#endif + GetWindowThreadProcessId(pcli->hwndContactList,&g_dwMirandaPID); + + // let's create our secret window + // this is a cheap, cheap hack... + // needed because of the hook, that gives problems + // if the calls aren't made from this context, they won't work + // using the window is a workaround to make this process do its work :) + // see notes + WNDCLASS winclass = {0}; + + winclass.lpfnWndProc = ListenWndProc; + winclass.hInstance = g_hInstance; + //winclass.hIcon = LoadIcon(NULL,IDI_APPLICATION); + //winclass.hCursor = LoadCursor(NULL,IDC_ARROW); + winclass.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH); + winclass.lpszClassName = BOSSKEY_LISTEN_INFO; + + if (RegisterClass(&winclass)) + { + hWTS = LoadLibrary(_T("wtsapi32.dll")); + + g_hListenWindow = CreateWindow(BOSSKEY_LISTEN_INFO,BOSSKEY_LISTEN_INFO,WS_POPUP,0,0,5,5,pcli->hwndContactList,NULL,g_hInstance,NULL); + + if (hWTS) + { + wtsRegisterSessionNotification = (PWTSRegisterSessionNotification)GetProcAddress(hWTS, "WTSRegisterSessionNotification"); + if (wtsRegisterSessionNotification) + { + wtsUnRegisterSessionNotification = (PWTSUnRegisterSessionNotification)GetProcAddress(hWTS, "WTSUnRegisterSessionNotification"); + wtsRegisterSessionNotification(g_hListenWindow, 0); + } + } + } + + if (IsWinVerVistaPlus()) + { + hDwmApi = LoadLibrary(_T("dwmapi.dll")); + if (hDwmApi) + { + dwmIsCompositionEnabled = (PFNDwmIsCompositionEnabled)GetProcAddress(hDwmApi,"DwmIsCompositionEnabled"); + } + } + if (g_wMaskAdv & OPT_MENUITEM) + BossKeyMenuItemInit(); + +// Updater support + if(ServiceExists(MS_UPDATE_REGISTERFL)) + CallService(MS_UPDATE_REGISTERFL, (WPARAM)__PLUGIN_ID, (LPARAM)&pluginInfo); + + if (ServiceExists(MS_TRIGGER_REGISTERTRIGGER)) + RegisterTrigger(); + +// Register token for variables plugin + if (ServiceExists(MS_VARS_REGISTERTOKEN)) + { + TOKENREGISTER tr = {0}; + tr.cbSize = sizeof(TOKENREGISTER); + tr.memType = TR_MEM_OWNER; + tr.flags = TRF_FIELD | TRF_TCHAR | TRF_PARSEFUNC; + + tr.tszTokenString = _T("bosskeyname"); + tr.parseFunctionT = VariablesBossKey; + tr.szHelpText = LPGEN("BossKey\tget the BossKey name"); + CallService(MS_VARS_REGISTERTOKEN, 0, (LPARAM) &tr); + } + + EnumProtos(0, 0); + InitIdleTimer(); + + if (g_bOldSetting && !(g_wMaskAdv & OPT_RESTORE)) // Restore settings if Miranda was crushed or killed in hidden mode and "Restore hiding on startup after failure" option is disabled + RestoreOldSettings(); + + if (g_wMaskAdv & OPT_HIDEONSTART || + (g_wMaskAdv & OPT_RESTORE && g_bOldSetting)) + BossKeyHideMiranda(0, 0); + + return(0); +} + + + +extern "C" int __declspec(dllexport) Load(PLUGINLINK *link) +{ + pluginLink = link; + mir_getMMI( &mmi ); + mir_getLP(&pluginInfo); + + g_wMaskAdv = DBGetContactSettingWord(NULL,MOD_NAME,"optsmaskadv",0); + g_bOldSetting = DBGetContactSettingByte(NULL, MOD_NAME, "OldSetting", 0); + + if ((g_bOldSetting & OLD_POPUP) && !(g_wMaskAdv & OPT_RESTORE)) // Restore popup settings if Miranda was crushed or killed in hidden mode and "Restore hiding on startup after failure" option is disabled + { + if (DBGetContactSettingByte(NULL, "PopUp", "ModuleIsEnabled", 1) == 0) + DBWriteContactSettingByte(NULL, "PopUp", "ModuleIsEnabled", 1); + if (DBGetContactSettingByte(NULL, "YAPP", "Enabled", 1) == 0) + DBWriteContactSettingByte(NULL, "YAPP", "Enabled", 1); + } + if (g_wMaskAdv & OPT_HIDEONSTART && DBGetContactSettingByte(NULL, "PopUp", "ModuleIsEnabled", 0)) // hack for disabling popup on startup if "Hide Miranda on startup" is enabled + { + g_bOldSetting |= OLD_POPUP; + DBWriteContactSettingByte(NULL, "PopUp", "ModuleIsEnabled", 0); + } + + IcoLibInit(); + g_hHooks[5] = HookEvent(ME_SYSTEM_MODULESLOADED,MirandaLoaded); + g_hHideService = CreateServiceFunction(MS_BOSSKEY_HIDE,BossKeyHideMiranda); // Create service + g_hHooks[6] = HookEvent(ME_TB_MODULELOADED, ModernToolbarInit); // Toolbar hook + return 0; +} + + + +extern "C" int __declspec(dllexport) Unload(void) +{ + UninitIdleTimer(); + // nice boys and girls always unhook events :) + for (int i = 0; i < SIZEOF(g_hHooks); i++) + { + if (g_hHooks[i]) + UnhookEvent(g_hHooks[i]); + } + + if(g_hmGenMenuInit) + UnhookEvent(g_hmGenMenuInit); + + if (g_hWinHook != 0) + UnhookWinEvent(g_hWinHook); + + DestroyServiceFunction(g_hHideService); + if (g_hIsHiddenService) + DestroyServiceFunction(g_hIsHiddenService); + + if (g_hListenWindow) + { + if (wtsUnRegisterSessionNotification) + wtsUnRegisterSessionNotification(g_hListenWindow); + DestroyWindow(g_hListenWindow); + } + + if (hWTS) + FreeLibrary(hWTS); + if (hDwmApi) + FreeLibrary(hDwmApi); + + // free all sessions + HWND_ITEM *pTemp = g_pMirWnds; + while (pTemp != NULL) + { + HWND_ITEM *pNext = pTemp->next; + delete pTemp; + pTemp = pNext; + } + g_pMirWnds = NULL; // safety + + // free memory + delete[] oldStatus; + delete[] oldStatusMsg; + + return(0); +} diff --git a/plugins/BossKeyPlus/BossKey.h b/plugins/BossKeyPlus/BossKey.h new file mode 100644 index 0000000000..f187b37915 --- /dev/null +++ b/plugins/BossKeyPlus/BossKey.h @@ -0,0 +1,122 @@ +/* + BossKey - Hide Miranda from your boss :) + Copyright (C) 2002-2003 Goblineye Entertainment, (C) 2007-2010 Billy_Bons + + 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 +*/ + +#pragma once + +#define WIN32_LEAN_AND_MEAN +#define _CRT_SECURE_NO_DEPRECATE + +#define WINVER 0x0700 +#define _WIN32_WINNT 0x0700 +#define _WIN32_IE 0x0601 +#define MIRANDA_VER 0x0900 +#define MIRANDA_CUSTOM_LP + +#define BOSSKEY_LISTEN_INFO _T("MY6BossKey_Param") + +#include +#include +#include +#include +#include +#include +#include "resource.h" +#include "version.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "m_trigger.h" +#include "m_variables.h" +#include "m_toolbar.h" + +#define MOD_NAME "BossKey" +#define KEY_DOWN(key) ((GetAsyncKeyState(key) & 0x8000) ? (true) : (false)) +#define MIID_BOSSKEY { 0xb0f05b6a, 0x8167, 0x4dc3, { 0xa1, 0x8a, 0xaf, 0xba, 0x4c, 0x77, 0xc4, 0x1d } } +#define MAXPASSLEN 16 +#define DEFAULTSETTING ( OPT_SETONLINEBACK | OPT_DISABLESNDS | OPT_ONLINEONLY | OPT_USEDEFMSG ) + +#define OLD_SOUND 1 +#define OLD_POPUP 2 +#define OLD_FLTCONT 4 +#define OLD_WASHIDDEN 128 + +#define OPT_SETONLINEBACK 1 +#define OPT_CHANGESTATUS 2 +#define OPT_DISABLESNDS 8 +#define OPT_REQPASS 16 +#define OPT_ONLINEONLY 32 +#define OPT_USEDEFMSG 128 +#define OPT_TRAYICON 256 + +#define OPT_HIDEIFLOCK 1 +#define OPT_HIDEIFWINIDLE 2 +#define OPT_HIDEIFMIRIDLE 4 +#define OPT_HIDEIFSCRSVR 8 +#define OPT_MENUITEM 16 +#define OPT_HIDEONSTART 32 +#define OPT_RESTORE 64 + +#define MS_BOSSKEY_HIDE "BossKey/HideMiranda" +#define MS_BOSSKEY_ISMIRANDAHIDDEN "BossKey/IsMirandaHidden" + +#define TRIGGERNAME "BossKey: Key pressed" +#define TRIGGER_BK_HIDE 0x01 +#define TRIGGER_BK_SHOW 0x02 +#define SETTING_TRIGGERON "TriggerOn" + +const unsigned STATUS_ARR_TO_ID[8] = { ID_STATUS_OFFLINE, ID_STATUS_ONLINE, ID_STATUS_AWAY, ID_STATUS_NA, ID_STATUS_OCCUPIED, ID_STATUS_DND, ID_STATUS_FREECHAT, ID_STATUS_INVISIBLE }; +extern bool g_fOptionsOpen; // options dialog is open. be sure not to hide anything while we're there. +extern WORD g_wHotKey, g_wMask, g_wMaskAdv; +extern HINSTANCE g_hInstance; +extern bool g_bWindowHidden; +extern UINT minutes; + +int OptsDlgInit(WPARAM wParam,LPARAM lParam); +INT_PTR BossKeyHideMiranda(WPARAM wParam, LPARAM lParam); +void BossKeyMenuItemInit(void); +void BossKeyMenuItemUnInit(void); +int BossKeyEvent(WPARAM wParam, LPARAM lParam); +int RegisterTrigger(void); +TCHAR *GetBossKeyText(void); +void InitIdleTimer(void); +void UninitIdleTimer(void); +LRESULT CALLBACK KbdProc(int nCode,WPARAM wParam,LPARAM lParam); +TCHAR* GetDefStatusMsg(unsigned uMode, const char* szProto); + +// I never really liked STL's vector... hmm this is nicer anyway, more flexible +typedef struct HWND_ITEM_TYPE +{ + HWND hWnd; + HWND_ITEM_TYPE *next; +} HWND_ITEM; + +typedef BOOL (WINAPI *PWTSRegisterSessionNotification)(HWND hWnd, DWORD dwFlags); +typedef BOOL (WINAPI *PWTSUnRegisterSessionNotification)(HWND hWnd); +typedef HRESULT (WINAPI *PFNDwmIsCompositionEnabled)(BOOL *); diff --git a/plugins/BossKeyPlus/BossKey.rc b/plugins/BossKeyPlus/BossKey.rc new file mode 100644 index 0000000000..5915f1a196 --- /dev/null +++ b/plugins/BossKeyPlus/BossKey.rc @@ -0,0 +1,214 @@ +// 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 + +///////////////////////////////////////////////////////////////////////////// +// Russian resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_RUS) +#ifdef _WIN32 +LANGUAGE LANG_RUSSIAN, SUBLANG_DEFAULT +#pragma code_page(1251) +#endif //_WIN32 + +///////////////////////////////////////////////////////////////////////////// +// +// Dialog +// + +IDD_OPT_TRIGGER DIALOGEX 0, 0, 186, 64 +STYLE DS_SETFONT | DS_3DLOOK | DS_FIXEDSYS | WS_CHILD +EXSTYLE WS_EX_CONTROLPARENT +FONT 8, "MS Shell Dlg", 400, 0, 0x1 +BEGIN + CONTROL "Trigger when Miranda is hiding",IDC_BK_HIDE,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,19,22,153,10 + CONTROL "Trigger when Miranda is showing",IDC_BK_SHOW,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,19,38,152,10 + GROUPBOX "Pre-conditions",IDC_STATIC,7,6,172,51 +END + +IDD_OPTDIALOGMAIN DIALOGEX 0, 0, 224, 220 +STYLE DS_SETFONT | DS_MODALFRAME | DS_SETFOREGROUND | DS_3DLOOK | + DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION | + WS_SYSMENU +EXSTYLE WS_EX_CONTROLPARENT +CAPTION "BossKey" +FONT 8, "MS Shell Dlg", 0, 0, 0x1 +BEGIN + CONTROL "Go to Customize -> Hotkeys to change the hotkey", + IDC_MAINOPT_LNK_HOTKEY,"Hyperlink",WS_TABSTOP,12,14,203, + 12 + GROUPBOX "When I press the hotkey:",IDC_STATIC,0,42,224,124 + CONTROL "Change status to",IDC_MAINOPT_CHANGESTATUSBOX,"Button", + BS_AUTOCHECKBOX | BS_LEFT | WS_TABSTOP,12,55,97,10 + COMBOBOX IDC_MAINOPT_CHGSTS,120,53,92,93,CBS_DROPDOWNLIST | + WS_VSCROLL | WS_TABSTOP + CONTROL "Change only if current status is Online", + IDC_MAINOPT_ONLINEONLY,"Button",BS_AUTOCHECKBOX | + WS_TABSTOP,12,69,198,10 + CONTROL "Use default status message",IDC_MAINOPT_USEDEFMSG, + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,82,180,10 + EDITTEXT IDC_MAINOPT_STATMSG,11,97,200,36,ES_MULTILINE | + ES_AUTOVSCROLL | ES_WANTRETURN | WS_VSCROLL + CONTROL "",IDC_MAINOPT_VARHELP,"MButtonClass",WS_TABSTOP,194,80, + 16,14,0x18000000L + CONTROL "Disable Sounds",IDC_MAINOPT_DISABLESNDS,"Button", + BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP,12,137,198, + 10 + CONTROL "Show the Tray Icon",IDC_MAINOPT_TRAYICON,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,12,151,198,10 + GROUPBOX "When I return:",IDC_STATIC,0,174,224,42 + CONTROL "Request password:",IDC_MAINOPT_REQPASS,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,12,186,102,10 + EDITTEXT IDC_MAINOPT_PASS,120,184,92,12,ES_PASSWORD | + ES_AUTOHSCROLL + CONTROL "Change status back",IDC_MAINOPT_SETONLINEBACK,"Button", + BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP,12,200,200, + 10 + GROUPBOX "Hotkey",IDC_STATIC,0,2,223,34 +END + +IDD_PASSDIALOGNEW DIALOGEX 0, 0, 188, 79 +STYLE DS_ABSALIGN | DS_SETFONT | DS_SETFOREGROUND | DS_FIXEDSYS | DS_CENTER | + WS_POPUP | WS_VISIBLE | WS_BORDER +EXSTYLE WS_EX_TOPMOST +FONT 8, "MS Shell Dlg", 400, 0, 0x1 +BEGIN + CONTROL "",IDC_HEADERBAR,"MHeaderbarCtrl",0x0,0,0,188,25 + LTEXT "Password:",-1,6,35,34,8 + EDITTEXT IDC_EDIT1,48,33,113,13,ES_PASSWORD | ES_AUTOHSCROLL + CONTROL "",-1,"Static",SS_ETCHEDHORZ,0,52,190,1 + PUSHBUTTON "OK",IDOK,22,58,60,14 + PUSHBUTTON "Cancel",IDCANCEL,104,58,60,14 + CTEXT "EN",IDC_LANG,166,33,13,13,SS_CENTERIMAGE | NOT WS_GROUP +END + +IDD_OPTDIALOGADV DIALOGEX 0, 0, 224, 232 +STYLE DS_SETFONT | DS_MODALFRAME | DS_SETFOREGROUND | DS_3DLOOK | + DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION | + WS_SYSMENU +EXSTYLE WS_EX_CONTROLPARENT +CAPTION "BossKey" +FONT 8, "MS Shell Dlg", 0, 0, 0x1 +BEGIN + CONTROL "Workstation is Locked (2000/XP+)", + IDC_MAINOPT_HIDEIFLOCK,"Button",BS_AUTOCHECKBOX | + WS_TABSTOP,12,18,204,8 + CONTROL "Screen Saver is running",IDC_MAINOPT_HIDEIFSCRSVR, + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,32,204,8 + CONTROL "Windows is inactive",IDC_MAINOPT_HIDEIFWINIDLE,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,12,46,116,8 + GROUPBOX "Hide Miranda when:",IDC_STATIC,0,4,223,88 + CONTROL "Miranda is inactive",IDC_MAINOPT_HIDEIFMIRIDLE,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,12,60,116,8 + EDITTEXT IDC_MAINOPT_TIME,132,52,31,12,ES_RIGHT | ES_NUMBER, + WS_EX_RIGHT + CONTROL "",IDC_MAINOPT_SPIN_TIME,"msctls_updown32", + UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | + UDS_ARROWKEYS,143,52,10,12 + LTEXT "min",IDC_STATIC,166,54,43,8 + CONTROL "Miranda is started",IDC_MAINOPT_HIDEONSTART,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,12,74,204,8 + GROUPBOX "Others",IDC_STATIC,0,100,223,44 + CONTROL "Create a main menu item",IDC_MAINOPT_MENUITEM,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,12,114,204,8 + CONTROL "Restore hiding on startup after failure", + IDC_MAINOPT_RESTORE,"Button",BS_AUTOCHECKBOX | + WS_TABSTOP,12,128,204,8 +END + + +///////////////////////////////////////////////////////////////////////////// +// +// DESIGNINFO +// + +#ifdef APSTUDIO_INVOKED +GUIDELINES DESIGNINFO +BEGIN + IDD_OPT_TRIGGER, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 179 + TOPMARGIN, 7 + BOTTOMMARGIN, 57 + END + + IDD_OPTDIALOGMAIN, DIALOG + BEGIN + BOTTOMMARGIN, 216 + END + + IDD_PASSDIALOGNEW, DIALOG + BEGIN + BOTTOMMARGIN, 72 + END + + IDD_OPTDIALOGADV, DIALOG + BEGIN + BOTTOMMARGIN, 228 + END +END +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon with lowest ID value placed first to ensure application icon +// remains consistent on all systems. +IDI_DLGPASSWD ICON "icos\\logo.ico" + +#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 + +#endif // Russian resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/plugins/BossKeyPlus/BossKey.vcproj b/plugins/BossKeyPlus/BossKey.vcproj new file mode 100644 index 0000000000..8996480452 --- /dev/null +++ b/plugins/BossKeyPlus/BossKey.vcproj @@ -0,0 +1,362 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/plugins/BossKeyPlus/BossKeyIdle.cpp b/plugins/BossKeyPlus/BossKeyIdle.cpp new file mode 100644 index 0000000000..403681a918 --- /dev/null +++ b/plugins/BossKeyPlus/BossKeyIdle.cpp @@ -0,0 +1,91 @@ +/* + +Miranda IM: the free IM client for Microsoft* Windows* + +Copyright 2000-2005 Miranda ICQ/IM project, +all portions of this codebase are copyrighted to the people +listed in contributors.txt. + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +#include "BossKey.h" + +POINT mousepos; +UINT_PTR hTimer; +UINT mouseidle, minutes; + +static BOOL (WINAPI * MyGetLastInputInfo)(PLASTINPUTINFO); + +VOID CALLBACK IdleTimer(HWND hwnd, UINT umsg, UINT idEvent, DWORD dwTime); + +static bool IsScreenSaverRunning() +{ + bool rc = FALSE; + SystemParametersInfo(SPI_GETSCREENSAVERRUNNING, 0, &rc, FALSE); + return rc; +} + +static bool IsUserIdle() +{ + DWORD dwTick; + if ( g_wMaskAdv & OPT_HIDEIFMIRIDLE ) { + CallService(MS_SYSTEM_GETIDLE, 0, (DWORD)&dwTick); + return GetTickCount() - dwTick > (minutes * 60 * 1000); + } + + if ( MyGetLastInputInfo != NULL ) { + LASTINPUTINFO ii; + ZeroMemory(&ii,sizeof(ii)); + ii.cbSize=sizeof(ii); + if ( MyGetLastInputInfo(&ii) ) + return GetTickCount() - ii.dwTime > (minutes * 60 * 1000); + } + else { + POINT pt; + GetCursorPos(&pt); + if ( pt.x != mousepos.x || pt.y != mousepos.y ) { + mousepos=pt; + mouseidle=0; + } + else mouseidle += 2; + + if ( mouseidle ) + return mouseidle >= (minutes * 60); + } + return FALSE; +} + + +VOID CALLBACK IdleTimer(HWND hwnd, UINT umsg, UINT_PTR idEvent, DWORD dwTime) +{ + if ( hTimer == idEvent && !g_bWindowHidden && + ((g_wMaskAdv & (OPT_HIDEIFWINIDLE | OPT_HIDEIFMIRIDLE) && IsUserIdle()) || + (g_wMaskAdv & OPT_HIDEIFSCRSVR && IsScreenSaverRunning()))) + + BossKeyHideMiranda(0, 0); +} + +void InitIdleTimer() +{ + minutes = DBGetContactSettingByte(NULL,MOD_NAME,"time",10); + MyGetLastInputInfo=(BOOL (WINAPI *)(LASTINPUTINFO*))GetProcAddress(GetModuleHandleA("user32"), "GetLastInputInfo"); + hTimer=SetTimer(NULL, 0, 2000, IdleTimer); +} + +void UninitIdleTimer() +{ + KillTimer(NULL, hTimer); +} diff --git a/plugins/BossKeyPlus/BossKeyTriggers.cpp b/plugins/BossKeyPlus/BossKeyTriggers.cpp new file mode 100644 index 0000000000..a16a0f05b4 --- /dev/null +++ b/plugins/BossKeyPlus/BossKeyTriggers.cpp @@ -0,0 +1,146 @@ +/* + BossKey - Hide Miranda from your boss :) + Copyright (C) 2002-2003 Goblineye Entertainment, (C) 2007-2010 Billy_Bons + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#include "BossKey.h" +extern HANDLE g_hIsHiddenService; + +static INT_PTR CALLBACK DlgProcOptsBossKeyTrigger(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { + + switch (msg) { + case WM_INITDIALOG: { + /* lParam = (LPARAM)(DWORD)triggerID, or 0 if this is a new trigger */ + DWORD triggerID; + + triggerID = (DWORD)lParam; + TranslateDialogDefault(hwndDlg); + CheckDlgButton(hwndDlg, IDC_BK_HIDE, (DBGetTriggerSettingWord(triggerID, NULL, MOD_NAME, SETTING_TRIGGERON, 0)&TRIGGER_BK_HIDE)?BST_CHECKED:BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_BK_SHOW, (DBGetTriggerSettingWord(triggerID, NULL, MOD_NAME, SETTING_TRIGGERON, 0)&TRIGGER_BK_SHOW)?BST_CHECKED:BST_UNCHECKED); + break; + } + + case TM_ADDTRIGGER: { + DWORD triggerID; + int flags = 0; + + triggerID = (DWORD)wParam; + flags |= IsDlgButtonChecked(hwndDlg, IDC_BK_HIDE)?TRIGGER_BK_HIDE:0; + flags |= IsDlgButtonChecked(hwndDlg, IDC_BK_SHOW)?TRIGGER_BK_SHOW:0; + DBWriteTriggerSettingWord(triggerID, NULL, MOD_NAME, SETTING_TRIGGERON, (WORD)flags); + break; + } + + case TM_DELTRIGGER: { + DWORD triggerID; + REMOVETRIGGERSETTINGS rts; + + triggerID = (DWORD)wParam; + rts.cbSize = sizeof(REMOVETRIGGERSETTINGS); + rts.prefix = PREFIX_TRIGGERID; + rts.id = triggerID; + rts.hContact = NULL; + rts.szModule = MOD_NAME; + CallService(MS_TRIGGER_REMOVESETTINGS, 0, (LPARAM)&rts); + break; + } + } + + return FALSE; +} + +int BossKeyEvent(WPARAM wParam, LPARAM lParam) { + + DWORD triggerID = 0; + REPORTINFO ri; + TRIGGERDATA td; + int flags; + + do { + triggerID = (DWORD)CallService(MS_TRIGGER_FINDNEXTTRIGGERID, triggerID, (LPARAM)TRIGGERNAME); + if (triggerID == 0) { + continue; + } + ZeroMemory(&td, sizeof(TRIGGERDATA)); + td.cbSize = sizeof(TRIGGERDATA); + flags = DBGetTriggerSettingWord(triggerID, NULL, MOD_NAME, SETTING_TRIGGERON, 0); + switch (wParam) { + case 0: + if (!(flags&TRIGGER_BK_HIDE)) { + continue; + } + break; + case 1: + if (!(flags&TRIGGER_BK_SHOW)) { + continue; + } + break; + default: + continue; + break; + } + ZeroMemory(&ri, sizeof(REPORTINFO)); + ri.cbSize = sizeof(REPORTINFO); + ri.flags = TRG_PERFORM; + ri.triggerID = triggerID; + ri.td = &td; + CallService(MS_TRIGGER_REPORTEVENT, 0, (LPARAM)&ri); + } while (triggerID != 0); + + return 0; +} + +INT_PTR IsMirandaHidden(WPARAM wParam, LPARAM lParam) // for trigger plugin +{ + return (INT_PTR)g_bWindowHidden; +} + +int RegisterTrigger() { + + g_hIsHiddenService = CreateServiceFunction(MS_BOSSKEY_ISMIRANDAHIDDEN, IsMirandaHidden); + + TRIGGERREGISTER tr; + ZeroMemory(&tr, sizeof(TRIGGERREGISTER)); + tr.cbSize = sizeof(TRIGGERREGISTER); + tr.dFlags = DF_TCHAR; + tr.pszName = Translate(TRIGGERNAME); + tr.hInstance = g_hInstance; + tr.pfnDlgProc = DlgProcOptsBossKeyTrigger; + tr.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_TRIGGER); + + CallService(MS_TRIGGER_REGISTERTRIGGER, 0, (LPARAM)&tr); + + CONDITIONREGISTER cr; + ZeroMemory(&cr, sizeof(CONDITIONREGISTER)); + cr.cbSize = sizeof(CONDITIONREGISTER); + cr.flags = CRF_TCHAR; + cr.pszName = "BossKey: Miranda is hidden"; + cr.pszService = MS_BOSSKEY_ISMIRANDAHIDDEN; + + CallService(MS_TRIGGER_REGISTERCONDITION, 0, (LPARAM)&cr); + + ACTIONREGISTER ar; + ZeroMemory(&ar, sizeof(ACTIONREGISTER)); + ar.cbSize = sizeof(ACTIONREGISTER); + ar.flags = ARF_TCHAR; + ar.pszName = "BossKey: Hide/Show Miranda"; + ar.pszService = MS_BOSSKEY_HIDE; + + CallService(MS_TRIGGER_REGISTERACTION, 0, (LPARAM)&ar); + + return 0; +} diff --git a/plugins/BossKeyPlus/BossKey_10.sln b/plugins/BossKeyPlus/BossKey_10.sln new file mode 100644 index 0000000000..0e0f1175b9 --- /dev/null +++ b/plugins/BossKeyPlus/BossKey_10.sln @@ -0,0 +1,25 @@ +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual C++ Express 2010 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "BossKey", "BossKey_10.vcxproj", "{88E47CF7-7B40-4312-A35A-9B28885FFED9}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug Unicode|Win32 = Debug Unicode|Win32 + Debug Unicode|x64 = Debug Unicode|x64 + Release Unicode|Win32 = Release Unicode|Win32 + Release Unicode|x64 = Release Unicode|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {88E47CF7-7B40-4312-A35A-9B28885FFED9}.Debug Unicode|Win32.ActiveCfg = Debug Unicode|Win32 + {88E47CF7-7B40-4312-A35A-9B28885FFED9}.Debug Unicode|Win32.Build.0 = Debug Unicode|Win32 + {88E47CF7-7B40-4312-A35A-9B28885FFED9}.Debug Unicode|x64.ActiveCfg = Debug Unicode|x64 + {88E47CF7-7B40-4312-A35A-9B28885FFED9}.Debug Unicode|x64.Build.0 = Debug Unicode|x64 + {88E47CF7-7B40-4312-A35A-9B28885FFED9}.Release Unicode|Win32.ActiveCfg = Release Unicode|Win32 + {88E47CF7-7B40-4312-A35A-9B28885FFED9}.Release Unicode|Win32.Build.0 = Release Unicode|Win32 + {88E47CF7-7B40-4312-A35A-9B28885FFED9}.Release Unicode|x64.ActiveCfg = Release Unicode|x64 + {88E47CF7-7B40-4312-A35A-9B28885FFED9}.Release Unicode|x64.Build.0 = Release Unicode|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/plugins/BossKeyPlus/BossKey_10.vcxproj b/plugins/BossKeyPlus/BossKey_10.vcxproj new file mode 100644 index 0000000000..0b19ea30fe --- /dev/null +++ b/plugins/BossKeyPlus/BossKey_10.vcxproj @@ -0,0 +1,294 @@ + + + + + Debug Unicode + Win32 + + + Debug Unicode + x64 + + + Release Unicode + Win32 + + + Release Unicode + x64 + + + + BossKey + {88E47CF7-7B40-4312-A35A-9B28885FFED9} + BossKey + + + + DynamicLibrary + false + Unicode + + + DynamicLibrary + false + Unicode + + + DynamicLibrary + false + Unicode + + + DynamicLibrary + false + Unicode + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + $(SolutionDir)$(Configuration)/Plugins\ + $(SolutionDir)$(Configuration)/Obj/$(ProjectName)\ + $(SolutionDir)$(Configuration)/Plugins\ + $(SolutionDir)$(Configuration)/Obj/$(ProjectName)\ + $(SolutionDir)$(Configuration)64/Plugins\ + $(SolutionDir)$(Configuration)64/Obj/$(ProjectName)\ + false + $(SolutionDir)$(Configuration)64/Plugins\ + $(SolutionDir)$(Configuration)64/Obj/$(ProjectName)\ + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + + + + NDEBUG;%(PreprocessorDefinitions) + true + true + Win32 + $(SolutionDir)$(Configuration)/$(ProjectName).tlb + + + + + Full + Default + Size + true + ../../include;../ExternalAPI;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_WINDOWS;_USRDLL;BossKey_EXPORTS;%(PreprocessorDefinitions) + true + MultiThreadedDLL + true + + + Level3 + + + + + NDEBUG;%(PreprocessorDefinitions) + + + comctl32.lib;%(AdditionalDependencies) + ../../lib;%(AdditionalLibraryDirectories) + 0x32270000 + false + + + $(IntDir)$(TargetName).lib + MachineX86 + + + UseLinkTimeCodeGeneration + true + true + + + + + _DEBUG;%(PreprocessorDefinitions) + true + true + Win32 + $(SolutionDir)$(Configuration)/$(ProjectName).tlb + + + + + Disabled + ../../include;../ExternalAPI;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_WINDOWS;_USRDLL;BossKey_EXPORTS;%(PreprocessorDefinitions) + EnableFastChecks + MultiThreadedDebug + + + + + Level3 + EditAndContinue + + + + + _DEBUG;%(PreprocessorDefinitions) + + + comctl32.lib;%(AdditionalDependencies) + true + false + + + $(IntDir)$(TargetName).lib + MachineX86 + + + + + NDEBUG;%(PreprocessorDefinitions) + true + true + X64 + $(SolutionDir)$(Configuration)/$(ProjectName).tlb + + + + + Full + Default + Size + ../../include;../ExternalAPI;%(AdditionalIncludeDirectories) + _WIN64;%(PreprocessorDefinitions) + true + MultiThreadedDLL + true + + + $(IntDir)$(ProjectName).pch + $(IntDir) + $(IntDir) + $(IntDir)vc70.pdb + Level3 + true + true + + + NDEBUG;%(PreprocessorDefinitions) + 0x0000 + + + comctl32.lib;%(AdditionalDependencies) + $(OutDir)$(ProjectName).dll + true + ../../lib;%(AdditionalLibraryDirectories) + false + false + $(OutDir)$(ProjectName).pdb + false + + + 0x32270000 + false + + + $(IntDir)$(TargetName).lib + MachineX64 + true + true + UseLinkTimeCodeGeneration + + + + + _DEBUG;%(PreprocessorDefinitions) + true + true + X64 + $(SolutionDir)$(Configuration)/$(ProjectName).tlb + + + + + Disabled + ../../include;../ExternalAPI;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_WINDOWS;_USRDLL;BossKey_EXPORTS;%(PreprocessorDefinitions) + EnableFastChecks + MultiThreadedDebug + + + $(IntDir)$(ProjectName).pch + + + $(IntDir) + $(IntDir)vc70.pdb + Level3 + true + ProgramDatabase + + + _DEBUG;%(PreprocessorDefinitions) + 0x0419 + + + comctl32.lib;%(AdditionalDependencies) + $(OutDir)$(ProjectName).dll + true + true + $(OutDir)$(ProjectName).pdb + false + + + $(IntDir)$(TargetName).lib + MachineX64 + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/plugins/BossKeyPlus/BossKey_10.vcxproj.filters b/plugins/BossKeyPlus/BossKey_10.vcxproj.filters new file mode 100644 index 0000000000..322e6f09e9 --- /dev/null +++ b/plugins/BossKeyPlus/BossKey_10.vcxproj.filters @@ -0,0 +1,55 @@ + + + + + {ef0a7df3-a4ae-4d85-b81c-6ba0e28ee632} + cpp;c;cxx;rc;def;r;odl;idl;hpj;bat + + + {a39ebad9-1d2a-4e20-8c0b-3c69872752da} + h;hpp;hxx;hm;inl + + + {f092abde-7f4f-4d83-b851-f71159a4dee8} + ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + + + Header Files + + + Header Files + + + Header Files + + + + + Resource Files + + + Source Files + + + + + Resource Files + + + \ No newline at end of file diff --git a/plugins/BossKeyPlus/BossKey_9.vcproj b/plugins/BossKeyPlus/BossKey_9.vcproj new file mode 100644 index 0000000000..14e58b58cd --- /dev/null +++ b/plugins/BossKeyPlus/BossKey_9.vcproj @@ -0,0 +1,449 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/plugins/BossKeyPlus/Options.cpp b/plugins/BossKeyPlus/Options.cpp new file mode 100644 index 0000000000..0f83079593 --- /dev/null +++ b/plugins/BossKeyPlus/Options.cpp @@ -0,0 +1,417 @@ +/* + BossKey - Hide Miranda from your boss :) + Copyright (C) 2002-2003 Goblineye Entertainment, (C) 2007-2010 Billy_Bons + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#include "BossKey.h" + +bool g_fOptionsOpen; +bool g_fReqRass; +extern HANDLE g_hMenuItem; + +//void Disable_ChildWindows(HWND hwndParent) +//{ +// if (hwndParent != NULL) +// { +// HWND hWorkWnd = GetWindow(hwndParent,GW_CHILD); // first child +// while (hWorkWnd != NULL) +// { +// EnableWindow(hWorkWnd,false); +// hWorkWnd = GetNextWindow(hWorkWnd,GW_HWNDNEXT); +// } +// } +//} + + +INT_PTR CALLBACK MainOptDlg(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM lParam) +{ + static bool s_fRedraw; + + switch (msg) + { + case WM_INITDIALOG: + { + TranslateDialogDefault(hwndDlg); + + g_fOptionsOpen = true; + s_fRedraw = false; + + extern PWTSRegisterSessionNotification wtsRegisterSessionNotification; + + if (wtsRegisterSessionNotification == 0) + EnableWindow(GetDlgItem(hwndDlg, IDC_MAINOPT_HIDEIFLOCK), SW_HIDE); + + // set icon and tooltip for variables help button + + if (ServiceExists(MS_VARS_GETSKINITEM)) { + HICON hIcon = (HICON)CallService(MS_VARS_GETSKINITEM, 0, (LPARAM)VSI_HELPICON); + if (hIcon != NULL) + SendMessage(GetDlgItem(hwndDlg, IDC_MAINOPT_VARHELP), BM_SETIMAGE, (WPARAM)IMAGE_ICON, (LPARAM)hIcon); + SendMessage(GetDlgItem(hwndDlg, IDC_MAINOPT_VARHELP), BUTTONADDTOOLTIP, (WPARAM)TranslateT("Open String Formatting Help"), BATF_TCHAR); + SendDlgItemMessage(hwndDlg, IDC_MAINOPT_VARHELP, BUTTONSETASFLATBTN, 0, 0); + } + + SendDlgItemMessage(hwndDlg,IDC_MAINOPT_PASS,EM_LIMITTEXT,MAXPASSLEN,0); // limit password length + + DBVARIANT dbVar; + + if (!DBGetContactSettingString(NULL,MOD_NAME,"password",&dbVar)) + { + CallService( MS_DB_CRYPT_DECODESTRING, strlen( dbVar.pszVal )+1, ( LPARAM )dbVar.pszVal ); + + SetDlgItemTextA(hwndDlg,IDC_MAINOPT_PASS,dbVar.pszVal); + DBFreeVariant(&dbVar); + } + + CheckDlgButton(hwndDlg,IDC_MAINOPT_SETONLINEBACK,(g_wMask & OPT_SETONLINEBACK) ? (BST_CHECKED) : (BST_UNCHECKED)); + CheckDlgButton(hwndDlg,IDC_MAINOPT_CHANGESTATUSBOX,(g_wMask & OPT_CHANGESTATUS) ? (BST_CHECKED) : (BST_UNCHECKED)); + CheckDlgButton(hwndDlg,IDC_MAINOPT_DISABLESNDS,(g_wMask & OPT_DISABLESNDS) ? (BST_CHECKED) : (BST_UNCHECKED)); + CheckDlgButton(hwndDlg,IDC_MAINOPT_REQPASS,(g_wMask & OPT_REQPASS) ? (BST_CHECKED) : (BST_UNCHECKED)); + CheckDlgButton(hwndDlg,IDC_MAINOPT_ONLINEONLY,(g_wMask & OPT_ONLINEONLY) ? (BST_CHECKED) : (BST_UNCHECKED)); + CheckDlgButton(hwndDlg,IDC_MAINOPT_USEDEFMSG,(g_wMask & OPT_USEDEFMSG) ? (BST_CHECKED) : (BST_UNCHECKED)); + CheckDlgButton(hwndDlg,IDC_MAINOPT_TRAYICON,(g_wMask & OPT_TRAYICON) ? (BST_CHECKED) : (BST_UNCHECKED)); + + const TCHAR *STATUS_ARR_TO_NAME[8] = { _T("Offline"), _T("Online"), _T("Away"), _T("NA"), _T("Occupied"), _T("DND"), _T("Free for chat"), _T("Invisible") }; + + for (BYTE i = 0;i < 8; i++) + SendDlgItemMessage(hwndDlg,IDC_MAINOPT_CHGSTS,CB_INSERTSTRING,-1,(LPARAM)TranslateTS(STATUS_ARR_TO_NAME[i])); + + SendDlgItemMessage(hwndDlg,IDC_MAINOPT_CHGSTS,CB_SETCURSEL,DBGetContactSettingByte(NULL,MOD_NAME,"stattype",2),0); + + SendMessage(hwndDlg,WM_USER + 60,0,0); + SendMessage(hwndDlg,WM_USER + 50,0,0); + + s_fRedraw = true; + return(true); + } break; + case WM_NOTIFY: + { + NMHDR* nmhdr = (NMHDR*)lParam; + switch (nmhdr->code) + { + case PSN_APPLY: + { + WORD wMask = 0; + // we apply changes here + // this plugin ain't that big, no need for a seperate routine + + // write down status type + if (IsDlgButtonChecked(hwndDlg,IDC_MAINOPT_CHANGESTATUSBOX) == BST_CHECKED) + { + DBWriteContactSettingByte(NULL,MOD_NAME,"stattype",(BYTE)SendDlgItemMessage(hwndDlg,IDC_MAINOPT_CHGSTS,CB_GETCURSEL,0,0)); + + // status msg, if needed + if (IsWindowEnabled(GetDlgItem(hwndDlg,IDC_MAINOPT_STATMSG))) // meaning we should save it + { + TCHAR tszMsg[1025]; + GetDlgItemText(hwndDlg,IDC_MAINOPT_STATMSG,tszMsg,1024); + if (lstrlen(tszMsg) != 0) + DBWriteContactSettingTString(NULL,MOD_NAME,"statmsg",tszMsg); + else // delete current setting + DBDeleteContactSetting(NULL,MOD_NAME,"statmsg"); + } + wMask |= OPT_CHANGESTATUS; + } + + // checkbox + if (IsDlgButtonChecked(hwndDlg,IDC_MAINOPT_REQPASS) == BST_CHECKED) + { + char szPass[MAXPASSLEN+1]; + GetDlgItemTextA(hwndDlg,IDC_MAINOPT_PASS,szPass,MAXPASSLEN+1); + if (strlen(szPass) != 0){ + CallService( MS_DB_CRYPT_ENCODESTRING, MAXPASSLEN+1, ( LPARAM )szPass ); + DBWriteContactSettingString(NULL,MOD_NAME,"password",szPass); + wMask |= OPT_REQPASS; + } + } + if (IsDlgButtonChecked(hwndDlg,IDC_MAINOPT_SETONLINEBACK) == BST_CHECKED) wMask |= OPT_SETONLINEBACK; + if (IsDlgButtonChecked(hwndDlg,IDC_MAINOPT_DISABLESNDS) == BST_CHECKED) wMask |= OPT_DISABLESNDS; + if (IsDlgButtonChecked(hwndDlg,IDC_MAINOPT_ONLINEONLY) == BST_CHECKED) wMask |= OPT_ONLINEONLY; + if (IsDlgButtonChecked(hwndDlg,IDC_MAINOPT_USEDEFMSG) == BST_CHECKED) wMask |= OPT_USEDEFMSG; + if (IsDlgButtonChecked(hwndDlg,IDC_MAINOPT_TRAYICON) == BST_CHECKED) wMask |= OPT_TRAYICON; + + DBWriteContactSettingWord(NULL,MOD_NAME,"optsmask",wMask); + g_wMask = wMask; + + return(true); + } break; + } + } break; + case WM_USER+50: // we're told to checkout the selection state of the combobox, and enable/disable accordingly + { + BYTE bSelection = (BYTE)SendDlgItemMessage(hwndDlg,IDC_MAINOPT_CHGSTS,CB_GETCURSEL,0,0); + WORD wMode = STATUS_ARR_TO_ID[bSelection]; + if (IsDlgButtonChecked(hwndDlg,IDC_MAINOPT_USEDEFMSG) == BST_CHECKED) + { + TCHAR *ptszDefMsg = GetDefStatusMsg(wMode, 0); + SetDlgItemText(hwndDlg, IDC_MAINOPT_STATMSG, ptszDefMsg); + if(ptszDefMsg) + mir_free(ptszDefMsg); + } + else + { + DBVARIANT dbVar; + SendDlgItemMessage(hwndDlg,IDC_MAINOPT_STATMSG,EM_LIMITTEXT,1024,0); + if (!DBGetContactSettingTString(NULL,MOD_NAME,"statmsg",&dbVar)) + { + SetDlgItemText(hwndDlg,IDC_MAINOPT_STATMSG,dbVar.ptszVal); + DBFreeVariant(&dbVar); + } + } + EnableWindow(GetDlgItem(hwndDlg,IDC_MAINOPT_STATMSG),(IsDlgButtonChecked(hwndDlg,IDC_MAINOPT_CHANGESTATUSBOX) == BST_CHECKED) && (IsDlgButtonChecked(hwndDlg,IDC_MAINOPT_USEDEFMSG) != BST_CHECKED)); + ShowWindow(GetDlgItem(hwndDlg, IDC_MAINOPT_VARHELP), IsWindowEnabled(GetDlgItem(hwndDlg,IDC_MAINOPT_STATMSG)) && ServiceExists(MS_VARS_FORMATSTRING)); + return(true); + } break; + case WM_USER+60: + { + bool fEnable = IsDlgButtonChecked(hwndDlg,IDC_MAINOPT_CHANGESTATUSBOX) == BST_CHECKED; + EnableWindow(GetDlgItem(hwndDlg,IDC_MAINOPT_CHGSTS),fEnable); + EnableWindow(GetDlgItem(hwndDlg,IDC_MAINOPT_SETONLINEBACK),fEnable); + EnableWindow(GetDlgItem(hwndDlg,IDC_MAINOPT_ONLINEONLY),fEnable); + EnableWindow(GetDlgItem(hwndDlg,IDC_MAINOPT_USEDEFMSG),fEnable); + EnableWindow(GetDlgItem(hwndDlg,IDC_MAINOPT_PASS),IsDlgButtonChecked(hwndDlg,IDC_MAINOPT_REQPASS) == BST_CHECKED); + return(true); + } break; + case WM_COMMAND: + { + switch (HIWORD(wParam)) + { + case CBN_SELCHANGE: + { + // check the type + // if type doesn't require a msg, we don't use one + if (LOWORD(wParam) == IDC_MAINOPT_CHGSTS) + { + SendMessage(hwndDlg,WM_USER + 50,0,0); + } + SendMessage(GetParent(hwndDlg),PSM_CHANGED,(WPARAM)hwndDlg,0); + return(0); + } break; + case BN_CLICKED: + { + switch(LOWORD(wParam)) + { + case IDC_MAINOPT_DISABLESNDS: + case IDC_MAINOPT_SETONLINEBACK: + case IDC_MAINOPT_ONLINEONLY: + case IDC_MAINOPT_TRAYICON: + { + SendMessage(GetParent(hwndDlg),PSM_CHANGED,(WPARAM)hwndDlg,0); + return(true); + } break; + case IDC_MAINOPT_USEDEFMSG: + { + SendMessage(hwndDlg,WM_USER + 50,0,0); + SendMessage(GetParent(hwndDlg),PSM_CHANGED,(WPARAM)hwndDlg,0); + return(true); + } break; + case IDC_MAINOPT_CHANGESTATUSBOX: + { + SendMessage(hwndDlg,WM_USER + 60,0,0); + SendMessage(hwndDlg,WM_USER + 50,0,0); + SendMessage(GetParent(hwndDlg),PSM_CHANGED,(WPARAM)hwndDlg,0); + return(true); + } break; + case IDC_MAINOPT_REQPASS: + { + SendMessage(hwndDlg,WM_USER + 60,0,0); + SendMessage(GetParent(hwndDlg),PSM_CHANGED,(WPARAM)hwndDlg,0); + return(true); + } break; + case IDC_MAINOPT_VARHELP: + { + variables_showhelp(hwndDlg, IDC_MAINOPT_STATMSG, VHF_INPUT|VHF_HELP, 0, 0); + SendMessage(GetParent(hwndDlg),PSM_CHANGED,(WPARAM)hwndDlg,0); + return(true); + } break; + case IDC_MAINOPT_LNK_HOTKEY: + { + OPENOPTIONSDIALOG ood = {0}; + ood.cbSize = sizeof(ood); + ood.pszGroup = "Customize"; + ood.pszPage = "Hotkeys"; + CallService( MS_OPT_OPENOPTIONS, 0, (LPARAM)&ood ); + return (true); + } break; + } + return(0); + } break; + case EN_UPDATE: + { + switch( LOWORD( wParam )) { + case IDC_MAINOPT_STATMSG: + case IDC_MAINOPT_PASS: + if (s_fRedraw) + SendMessage(GetParent(hwndDlg),PSM_CHANGED,(WPARAM)hwndDlg,0); + } + } break; + default:break; + } + } break; + case WM_DESTROY: + { + g_fOptionsOpen = false; + return(0); + } break; + } + return(false); +} + +INT_PTR CALLBACK AdvOptDlg(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM lParam) +{ + static bool inFocus = false; + + switch (msg) + { + case WM_INITDIALOG: + { + TranslateDialogDefault(hwndDlg); + + g_fOptionsOpen = true; + + minutes = DBGetContactSettingByte(NULL,MOD_NAME,"time",10); + char szMinutes[4] = {0}; + _itoa(minutes, szMinutes, 10); + SendDlgItemMessage(hwndDlg,IDC_MAINOPT_TIME,EM_LIMITTEXT,2,0); + SendDlgItemMessage(hwndDlg, IDC_MAINOPT_SPIN_TIME, UDM_SETRANGE32, (WPARAM)1, (LPARAM)99); + SetDlgItemTextA(hwndDlg, IDC_MAINOPT_TIME, szMinutes); + CheckDlgButton(hwndDlg,IDC_MAINOPT_HIDEIFLOCK,(g_wMaskAdv & OPT_HIDEIFLOCK) ? (BST_CHECKED) : (BST_UNCHECKED)); + CheckDlgButton(hwndDlg,IDC_MAINOPT_MENUITEM,(g_wMaskAdv & OPT_MENUITEM) ? (BST_CHECKED) : (BST_UNCHECKED)); + CheckDlgButton(hwndDlg,IDC_MAINOPT_HIDEIFWINIDLE,(g_wMaskAdv & OPT_HIDEIFWINIDLE) ? (BST_CHECKED) : (BST_UNCHECKED)); + CheckDlgButton(hwndDlg,IDC_MAINOPT_HIDEIFMIRIDLE,(g_wMaskAdv & OPT_HIDEIFMIRIDLE) ? (BST_CHECKED) : (BST_UNCHECKED)); + CheckDlgButton(hwndDlg,IDC_MAINOPT_HIDEIFSCRSVR,(g_wMaskAdv & OPT_HIDEIFSCRSVR) ? (BST_CHECKED) : (BST_UNCHECKED)); + CheckDlgButton(hwndDlg,IDC_MAINOPT_HIDEONSTART,(g_wMaskAdv & OPT_HIDEONSTART) ? (BST_CHECKED) : (BST_UNCHECKED)); + CheckDlgButton(hwndDlg,IDC_MAINOPT_RESTORE,(g_wMaskAdv & OPT_RESTORE) ? (BST_CHECKED) : (BST_UNCHECKED)); + + return(true); + } break; + case WM_NOTIFY: + { + NMHDR* nmhdr = (NMHDR*)lParam; + switch (nmhdr->code) + { + case PSN_APPLY: + { + WORD wMaskAdv = 0; + if (IsDlgButtonChecked(hwndDlg,IDC_MAINOPT_HIDEIFLOCK) == BST_CHECKED) wMaskAdv |= OPT_HIDEIFLOCK; + if (IsDlgButtonChecked(hwndDlg,IDC_MAINOPT_HIDEIFWINIDLE) == BST_CHECKED) wMaskAdv |= OPT_HIDEIFWINIDLE; + if (IsDlgButtonChecked(hwndDlg,IDC_MAINOPT_HIDEIFMIRIDLE) == BST_CHECKED) wMaskAdv |= OPT_HIDEIFMIRIDLE; + if (IsDlgButtonChecked(hwndDlg,IDC_MAINOPT_HIDEIFSCRSVR) == BST_CHECKED) wMaskAdv |= OPT_HIDEIFSCRSVR; + if (IsDlgButtonChecked(hwndDlg,IDC_MAINOPT_HIDEONSTART) == BST_CHECKED) wMaskAdv |= OPT_HIDEONSTART; + if (IsDlgButtonChecked(hwndDlg,IDC_MAINOPT_RESTORE) == BST_CHECKED) wMaskAdv |= OPT_RESTORE; + + if (IsDlgButtonChecked(hwndDlg,IDC_MAINOPT_MENUITEM) == BST_CHECKED ) + { + if (g_hMenuItem == 0) BossKeyMenuItemInit(); + wMaskAdv |= OPT_MENUITEM; + } else + if (g_hMenuItem != 0) BossKeyMenuItemUnInit(); + + char szMinutes[4] = {0}; + GetDlgItemTextA(hwndDlg,IDC_MAINOPT_TIME,szMinutes,3); + (atoi(szMinutes) > 0) ? minutes = atoi(szMinutes) : minutes = 1; + DBWriteContactSettingByte(NULL,MOD_NAME,"time",minutes); + DBWriteContactSettingWord(NULL,MOD_NAME,"optsmaskadv",wMaskAdv); + g_wMaskAdv = wMaskAdv; + + return(true); + } break; + } + } break; + case WM_COMMAND: + { + switch (HIWORD(wParam)) + { + case BN_CLICKED: + { + switch(LOWORD(wParam)) + { + case IDC_MAINOPT_MENUITEM: + case IDC_MAINOPT_HIDEIFLOCK: + case IDC_MAINOPT_HIDEIFSCRSVR: + case IDC_MAINOPT_HIDEONSTART: + case IDC_MAINOPT_RESTORE: + { + SendMessage(GetParent(hwndDlg),PSM_CHANGED,(WPARAM)hwndDlg,0); + return(true); + } break; + case IDC_MAINOPT_HIDEIFWINIDLE: + { + if (IsDlgButtonChecked(hwndDlg,IDC_MAINOPT_HIDEIFWINIDLE) == BST_CHECKED) + CheckDlgButton(hwndDlg,IDC_MAINOPT_HIDEIFMIRIDLE,BST_UNCHECKED); + SendMessage(GetParent(hwndDlg),PSM_CHANGED,(WPARAM)hwndDlg,0); + return(true); + } break; + case IDC_MAINOPT_HIDEIFMIRIDLE: + { + if (IsDlgButtonChecked(hwndDlg,IDC_MAINOPT_HIDEIFMIRIDLE) == BST_CHECKED) + CheckDlgButton(hwndDlg,IDC_MAINOPT_HIDEIFWINIDLE,BST_UNCHECKED); + SendMessage(GetParent(hwndDlg),PSM_CHANGED,(WPARAM)hwndDlg,0); + return(true); + } break; + } + return(0); + } break; + case EN_SETFOCUS: + { + inFocus = true; + return(0); + } break; + case EN_UPDATE: + { + switch( LOWORD( wParam )) { + case IDC_MAINOPT_TIME: + if(inFocus) + SendMessage(GetParent(hwndDlg),PSM_CHANGED,(WPARAM)hwndDlg,0); + } + } break; + default:break; + } + } break; + case WM_DESTROY: + { + g_fOptionsOpen = false; + return(0); + } break; + } + return(false); +} + +int OptsDlgInit(WPARAM wParam,LPARAM lParam) +{ + OPTIONSDIALOGPAGE optDi; + ZeroMemory(&optDi, sizeof(optDi)); + optDi.cbSize = sizeof(optDi); + optDi.position = 920000000; + optDi.pfnDlgProc = MainOptDlg; + optDi.pszTemplate = MAKEINTRESOURCEA(IDD_OPTDIALOGMAIN); + optDi.hInstance = g_hInstance; + optDi.ptszTitle = _T("BossKey"); + optDi.ptszGroup = _T("Events"); + optDi.ptszTab = _T("Main"); + optDi.flags = ODPF_BOLDGROUPS | ODPF_TCHAR; + + CallService(MS_OPT_ADDPAGE,wParam,(LPARAM)&optDi); + + optDi.flags |= ODPF_EXPERTONLY; + optDi.pfnDlgProc = AdvOptDlg; + optDi.pszTemplate = MAKEINTRESOURCEA(IDD_OPTDIALOGADV); + optDi.ptszTab = _T("Advanced"); + + CallService(MS_OPT_ADDPAGE,wParam,(LPARAM)&optDi); + return(0); +} diff --git a/plugins/BossKeyPlus/Resource.rc b/plugins/BossKeyPlus/Resource.rc new file mode 100644 index 0000000000..d0587997af --- /dev/null +++ b/plugins/BossKeyPlus/Resource.rc @@ -0,0 +1,2 @@ +#include "BossKey.rc" +#include "version.rc" diff --git a/plugins/BossKeyPlus/docs/bosskey_plus_langpack.txt b/plugins/BossKeyPlus/docs/bosskey_plus_langpack.txt new file mode 100644 index 0000000000..0f7a022f42 Binary files /dev/null and b/plugins/BossKeyPlus/docs/bosskey_plus_langpack.txt differ diff --git a/plugins/BossKeyPlus/docs/bosskey_plus_license.txt b/plugins/BossKeyPlus/docs/bosskey_plus_license.txt new file mode 100644 index 0000000000..45645b4b53 --- /dev/null +++ b/plugins/BossKeyPlus/docs/bosskey_plus_license.txt @@ -0,0 +1,340 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + 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 + + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. diff --git a/plugins/BossKeyPlus/docs/bosskey_plus_readme.txt b/plugins/BossKeyPlus/docs/bosskey_plus_readme.txt new file mode 100644 index 0000000000..51d1930b59 --- /dev/null +++ b/plugins/BossKeyPlus/docs/bosskey_plus_readme.txt @@ -0,0 +1,127 @@ + BossKey+ +-------------------------------------------------------------------------- + -=Miranda Plug-In=- +Copyrights (C) 2002-2003 Goblineye Entertainment, (C) 2007-2008 Billy_Bons +-------------------------------------------------------------------------- + +Desc: +==== + +This plugin is a mod of Bosskey plugin and is intended to hide all window icons +and windows of Miranda on hotkey press. + +Whats new: +- Added ability to set a password +- Added Miranda 0.8 support +- Reworked options dialog +- Status management system was rewritten. Now statuses are changed perprotocol. +- Added main menu item +- Updater plugin support +- Various changes and bugfixes + +This plug-in hides all of Miranda's windows and system tray icon/s when you press a specified hotkey (Ctrl+F12 is the default), mostly useful to hide Miranda from your boss :) +BossKey was very much inspired by AntiA, and adds a couple of features to the original AntiA (Like: Icon/s can be restored, you can set a status message to when you leave etc.) + + +Installation: +============ +To install the plug-in you will need to copy BossKey.dll to your Miranda's plug-in directory (\plugins). + + +Uninstallation: +============== +Delete the BossKey.dll from \plugins. + + +How to use: +========== +Press the hotkey (F12, by default) from anywhere in the system, and see how Miranda "disappears". +You should know that it's still there, it's just hidden (A quick look using a task manager will reveal it), so keep that in mind :) +You should also check out the options (Events->BossKey), they are somewhat useful :) + + +Changelog: +========= +v. 0.5.0.3 +- Fixed occurrence of the second password window, when double-clicking hotkey + +v. 0.5.0.2 +- Increased the space for translation in some controls +- Changed the archive's structure to make updater happy + +v. 0.5.0.1 +- Support unicode status messages +- Removed internal keyboard handling +- Some internal changes and cleanup +- ATTENTION: NOW PLUGIN REQUESTED MIRANDA IM 0.8 AND HIGHER! PLEASE, DO NOT INSTALL THIS VERSION OF THE PLUGIN, IF YOU USE AN EARLIER VERSION OF MIRANDA. + +v. 0.4.1.3 +- Hook keyboard only if it needed +- Memory leak fixed + +v. 0.4.1.2 +- Fixed status message restoring (thnx Dezeath & AL|EN) +- Fixed MHeaderBar drawing in aero mode + +v. 0.4.1.1 +- Password dialog with the MHeaderBar control (for Miranda 0.8.0.29 and newer) +- Icon in Alt+Tab dialog +- Support core's PS_GETMYAWAYMSG service +- Added "Hide Miranda when Miranda is started" and "Restore hiding on startup after failure" +- Added button on Tabsrmm button bar (disabled by default) +- Restoring settings of sound, popups, etc. on startup, if Miranda was incorrectly finished in hidden mode + +v. 0.4.0.9 +- New options: Hide Miranda when workstation / Miranda is inactive or screen saver is running. +- Fixed crash after account deleting +- Improved the password window +- Some fixes and reorganizations in the Options page +- Some possible crushes fixed +- Some optimisations and bugfixes +- msvcr71.dll now is not required + +v. 0.4.0.8 +- Rare crush fixed (by Vasilich) +- Minor internal changes +- "Disable popups" option removed + +v. 0.4.0.7 +- Showing the current hot key combination in menu item +- Added token %bosskeyname% for Variables plugin, returning the current hot key combination (can be used together with UseActions plugin by Vasilich) +- Minor fixes + +v. 0.4.0.6 +- Minor GUI fix +- Possible crush fixed +- Now you can set the custom text of the tray icon's tool tip. +Just using DBE++ create new item (Unicode)ToolTipText = "your text" in module "BossKey". + +v. 0.4.0.5 +- Attempt to fix keyboard processing (by Yasnovidyashii) +- Added Ersatz plugin support +- Fixed beta URL's +- Updated PluginInfo + +v. 0.4.0.4 +- "Show the Tray Icon" option added + +v. 0.4.0.3 +- Added unicode version +- Added support of the new hotkeys module (core version > 0.8.0.3) +- Added support of the clist_modern's toolbar +- Automatic change of the keyboard layout in the input password window +- More correctly hiding of floating contacts +- Other minor fixes and changes + +v. 0.4.0.0 +- Added "Hide Miranda if the computer is locked" option +- Added "Use default status message" option +- Added variables plugin support +- Added storing and restoring of status messages +- Functions of hiding and restoring icons are changed: now it should be more correct, but does not work on old versions of core ( < 0.7) and clists +- Temporary workaround for crash under win98 with popup+ +- Random crash fixed +- Memory leaks fixed +- Various bugfixes and changes +- The minimal supported version of a core now is 0.7 +- Added langpack diff --git a/plugins/BossKeyPlus/icos/logo.ico b/plugins/BossKeyPlus/icos/logo.ico new file mode 100644 index 0000000000..e2dc76f8c4 Binary files /dev/null and b/plugins/BossKeyPlus/icos/logo.ico differ diff --git a/plugins/BossKeyPlus/resource.h b/plugins/BossKeyPlus/resource.h new file mode 100644 index 0000000000..c3dbcc8b2a --- /dev/null +++ b/plugins/BossKeyPlus/resource.h @@ -0,0 +1,49 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by BossKey.rc +// +#define IDD_OPTDIALOGMAIN 101 +#define IDD_PASSDIALOGNEW 103 +#define IDI_DLGPASSWD 105 +#define IDD_OPT_TRIGGER 105 +#define IDD_OPTDIALOGADV 106 +#define IDC_MAINOPT_CHGSTS 1000 +#define IDC_MAINOPT_STATMSG 1001 +#define IDC_MAINOPT_SETONLINEBACK 1002 +#define IDC_MAINOPT_CHANGESTATUSBOX 1003 +#define IDC_MAINOPT_DISABLESNDS 1005 +#define IDC_HEADERBAR 1007 +#define IDC_EDIT1 1009 +#define IDC_LANG 1011 +#define IDC_MAINOPT_REQPASS 1012 +#define IDC_MAINOPT_PASS 1013 +#define IDC_MAINOPT_LNK_HOTKEY 1014 +#define IDC_MAINOPT_ONLINEONLY 1015 +#define IDC_BK_HIDE 1016 +#define IDC_BK_SHOW 1017 +#define IDC_MAINOPT_USEDEFMSG 1018 +#define IDC_MAINOPT_VARHELP 1019 + +#define IDC_MAINOPT_TRAYICON 1023 +#define IDC_MAINOPT_HIDEIFLOCK 1024 +#define IDC_MAINOPT_HIDEIFWINIDLE 1025 +#define IDC_MAINOPT_HIDEIFMIRIDLE 1026 +#define IDC_MAINOPT_HIDEIFSCRSVR 1027 +#define IDC_MAINOPT_TIME 1028 +#define IDC_MAINOPT_SPIN_TIME 1029 +#define IDC_MAINOPT_MENUITEM 1030 +#define IDC_MAINOPT_HIDEONSTART 1031 +#define IDC_MAINOPT_RESTORE 1032 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NO_MFC 1 +#define _APS_3D_CONTROLS 1 +#define _APS_NEXT_RESOURCE_VALUE 107 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1032 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/plugins/BossKeyPlus/version.h b/plugins/BossKeyPlus/version.h new file mode 100644 index 0000000000..f2391d8f48 --- /dev/null +++ b/plugins/BossKeyPlus/version.h @@ -0,0 +1,26 @@ +#define __FILE_VERSION 0,5,0,3 +#define __FILE_VERSION_STR "0, 5, 0, 3" +#define __VERSION_DWORD 0x00050003 + +#if defined ( _WIN64 ) +#define __MODULE_NAME "BossKey+ (x64)" +#define __PLUGIN_ID 4305 +#define __PLUGIN_ID_STR "4305" +#define __PLUGIN_NAME "BossKey+ (x64)" +#elif defined ( _UNICODE ) +#define __MODULE_NAME "BossKey+ (Unicode)" +#define __PLUGIN_ID 3694 +#define __PLUGIN_ID_STR "3694" +#define __PLUGIN_NAME "BossKey+ (Unicode)" +#else +#define __MODULE_NAME "BossKey+" +#define __PLUGIN_ID 3655 +#define __PLUGIN_ID_STR "3655" +#define __PLUGIN_NAME "BossKey+" +#endif + +#define __FL "http://addons.miranda-im.org/details.php?action=viewfile&id=" +#define __DESC "Anti-Boss plugin." +#define __AUTHORS "Goblineye Entertainment, Billy_Bons" +#define __EMAIL "tatarinov.sergey@gmail.com" +#define __COPYRIGHTS "© 2002-2003 Goblineye Entertainment, © 2007-2010 Billy_Bons" diff --git a/plugins/BossKeyPlus/version.rc b/plugins/BossKeyPlus/version.rc new file mode 100644 index 0000000000..078b624b53 --- /dev/null +++ b/plugins/BossKeyPlus/version.rc @@ -0,0 +1,40 @@ +#include +#include "version.h" + +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +VS_VERSION_INFO VERSIONINFO + FILEVERSION __FILE_VERSION + PRODUCTVERSION __FILE_VERSION + FILEFLAGSMASK 0x3fL +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x40004L + FILETYPE 0x2L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "CompanyName", __AUTHORS + VALUE "FileDescription", __DESC + VALUE "FileVersion", __FILE_VERSION_STR + VALUE "InternalName", __MODULE_NAME + VALUE "LegalCopyright", __COPYRIGHTS + VALUE "OriginalFilename", "BossKey.dll" + VALUE "ProductName", __MODULE_NAME + VALUE "ProductVersion", __FILE_VERSION_STR + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END +END -- cgit v1.2.3