From cae63f959eeacca02bf3504e77e8a6e4a1aa8499 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Fri, 6 Jul 2012 16:58:48 +0000 Subject: + stdautoaway + stdhelp + stduihist + stdidle + stduseronline git-svn-id: http://svn.miranda-ng.org/main/trunk@795 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- src/modules/autoaway/autoaway.cpp | 84 ---- src/modules/help/about.cpp | 144 ------- src/modules/help/help.cpp | 116 ------ src/modules/history/history.cpp | 428 ------------------- src/modules/idle/idle.cpp | 524 ------------------------ src/modules/plugins/newplugins.cpp | 9 +- src/modules/updatenotify/updatenotify.cpp | 656 ------------------------------ src/modules/useronline/useronline.cpp | 117 ------ 8 files changed, 4 insertions(+), 2074 deletions(-) delete mode 100644 src/modules/autoaway/autoaway.cpp delete mode 100644 src/modules/help/about.cpp delete mode 100644 src/modules/help/help.cpp delete mode 100644 src/modules/history/history.cpp delete mode 100644 src/modules/idle/idle.cpp delete mode 100644 src/modules/updatenotify/updatenotify.cpp delete mode 100644 src/modules/useronline/useronline.cpp (limited to 'src/modules') diff --git a/src/modules/autoaway/autoaway.cpp b/src/modules/autoaway/autoaway.cpp deleted file mode 100644 index 278fff1af4..0000000000 --- a/src/modules/autoaway/autoaway.cpp +++ /dev/null @@ -1,84 +0,0 @@ -/* - -Miranda IM: the free IM client for Microsoft* Windows* - -Copyright 2000-2009 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 "..\..\core\commonheaders.h" - -#define AA_MODULE "AutoAway" - -void Proto_SetStatus(const char* szProto, unsigned status); - -static int iBreakSounds = 0; - -static int AutoAwaySound(WPARAM, LPARAM lParam) -{ - return iBreakSounds; -} - -static int AutoAwayEvent(WPARAM, LPARAM lParam) -{ - int i; - - MIRANDA_IDLE_INFO mii; - mii.cbSize = sizeof(mii); - CallService(MS_IDLE_GETIDLEINFO, 0, (LPARAM)&mii); - if (mii.aaStatus == 0) - return 0; - - for (i=0; i < accounts.getCount(); i++) { - PROTOACCOUNT* pa = accounts[i]; - - if ( !Proto_IsAccountEnabled(pa) || Proto_IsAccountLocked(pa)) continue; - - int statusbits = CallProtoServiceInt(NULL,pa->szModuleName, PS_GETCAPS, PFLAGNUM_2, 0); - int currentstatus = CallProtoServiceInt(NULL,pa->szModuleName, PS_GETSTATUS, 0, 0); - int status = mii.aaStatus; - if ( !(statusbits & Proto_Status2Flag(status))) { - // the protocol doesnt support the given status - if (statusbits & Proto_Status2Flag(ID_STATUS_AWAY)) - status = ID_STATUS_AWAY; - // the proto doesnt support user mode or even away, bail. - else - continue; - } - if (currentstatus >= ID_STATUS_ONLINE && currentstatus != ID_STATUS_INVISIBLE) { - if ((lParam&IDF_ISIDLE) && (currentstatus == ID_STATUS_ONLINE || currentstatus == ID_STATUS_FREECHAT)) { - DBWriteContactSettingByte(NULL, AA_MODULE, pa->szModuleName, 1); - Proto_SetStatus(pa->szModuleName, status); - } - else if ( !(lParam & IDF_ISIDLE) && DBGetContactSettingByte(NULL, AA_MODULE, pa->szModuleName, 0)) { - // returning from idle and this proto was set away, set it back - DBWriteContactSettingByte(NULL, AA_MODULE, pa->szModuleName, 0); - if ( !mii.aaLock) - Proto_SetStatus(pa->szModuleName, ID_STATUS_ONLINE); - } } } - if (mii.idlesoundsoff) - iBreakSounds = (lParam&IDF_ISIDLE) != 0; - - return 0; -} - -int LoadAutoAwayModule(void) -{ - HookEvent(ME_SKIN_PLAYINGSOUND, AutoAwaySound); - HookEvent(ME_IDLE_CHANGED, AutoAwayEvent); - return 0; -} diff --git a/src/modules/help/about.cpp b/src/modules/help/about.cpp deleted file mode 100644 index b01e139a01..0000000000 --- a/src/modules/help/about.cpp +++ /dev/null @@ -1,144 +0,0 @@ -/* - -Miranda IM: the free IM client for Microsoft* Windows* - -Copyright 2000-2009 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 "..\..\core\commonheaders.h" - -#define STR_VERSION_FORMAT "%s%S%S" - -INT_PTR CALLBACK DlgProcAbout(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) -{ - static int iState = 0; - switch (msg) { - case WM_INITDIALOG: - TranslateDialogDefault(hwndDlg); - { TCHAR filename[MAX_PATH], *productCopyright; - DWORD unused; - DWORD verInfoSize; - UINT blockSize; - PVOID pVerInfo; - - GetModuleFileName(NULL, filename, SIZEOF(filename)); - verInfoSize = GetFileVersionInfoSize(filename, &unused); - pVerInfo = mir_alloc(verInfoSize); - GetFileVersionInfo(filename, 0, verInfoSize, pVerInfo); - VerQueryValue(pVerInfo, _T("\\StringFileInfo\\000004b0\\LegalCopyright"), (LPVOID*)&productCopyright, &blockSize); - SetDlgItemText(hwndDlg, IDC_DEVS, productCopyright); - mir_free(pVerInfo); - } - { char productVersion[56], *p; - int isAnsi = 0; - TCHAR str[64]; - CallService(MS_SYSTEM_GETVERSIONTEXT, SIZEOF(productVersion), (LPARAM)productVersion); - // Hide Unicode from version text as it is assumed at this point - p = strstr(productVersion, " Unicode"); - if (p) - *p = '\0'; - else - isAnsi = 1; - mir_sntprintf(str, SIZEOF(str), _T(STR_VERSION_FORMAT), TranslateT("v"), productVersion, isAnsi?" ANSI":""); - { - TCHAR oldTitle[256], newTitle[256]; - GetDlgItemText(hwndDlg, IDC_HEADERBAR, oldTitle, SIZEOF(oldTitle)); - mir_sntprintf(newTitle, SIZEOF(newTitle), oldTitle, str); - SetDlgItemText(hwndDlg, IDC_HEADERBAR, newTitle); - } - - mir_sntprintf(str, SIZEOF(str), TranslateT("Built %s %s"), _T(__DATE__), _T(__TIME__)); - SetDlgItemText(hwndDlg, IDC_BUILDTIME, str); - } - ShowWindow(GetDlgItem(hwndDlg, IDC_CREDITSFILE), SW_HIDE); - { - HRSRC hResInfo = FindResource(hInst, MAKEINTRESOURCE(IDR_CREDITS), _T("TEXT")); - DWORD ResSize = SizeofResource(hInst, hResInfo); - HGLOBAL hRes = LoadResource(hInst, hResInfo); - char* pszMsg = (char*)LockResource(hRes); - if (pszMsg) - { - char* pszMsgt = (char*)alloca(ResSize + 1); - memcpy(pszMsgt, pszMsg, ResSize); pszMsgt[ResSize] = 0; - - TCHAR *ptszMsg; - if (ResSize >=3 && pszMsgt[0] == '\xef' && pszMsgt[1] == '\xbb' && pszMsgt[2] == '\xbf') - ptszMsg = Utf8DecodeT(pszMsgt + 3); - else - ptszMsg = mir_a2t_cp(pszMsgt, 1252); - - SetDlgItemText(hwndDlg, IDC_CREDITSFILE, ptszMsg); - UnlockResource(pszMsg); - mir_free(ptszMsg); - } - FreeResource(hRes); - } - Window_SetIcon_IcoLib(hwndDlg, SKINICON_OTHER_MIRANDA); - return TRUE; - - case WM_COMMAND: - switch(LOWORD(wParam)) { - case IDOK: - case IDCANCEL: - DestroyWindow(hwndDlg); - return TRUE; - case IDC_CONTRIBLINK: - if (iState) { - iState = 0; - SetDlgItemText(hwndDlg, IDC_CONTRIBLINK, TranslateT("Credits >")); - ShowWindow(GetDlgItem(hwndDlg, IDC_DEVS), SW_SHOW); - ShowWindow(GetDlgItem(hwndDlg, IDC_BUILDTIME), SW_SHOW); - ShowWindow(GetDlgItem(hwndDlg, IDC_CREDITSFILE), SW_HIDE); - } - else { - iState = 1; - SetDlgItemText(hwndDlg, IDC_CONTRIBLINK, TranslateT("< Copyright")); - ShowWindow(GetDlgItem(hwndDlg, IDC_DEVS), SW_HIDE); - ShowWindow(GetDlgItem(hwndDlg, IDC_BUILDTIME), SW_HIDE); - ShowWindow(GetDlgItem(hwndDlg, IDC_CREDITSFILE), SW_SHOW); - } - break; - } - break; - - case WM_CTLCOLOREDIT: - case WM_CTLCOLORSTATIC: - switch (GetWindowLongPtr((HWND)lParam, GWL_ID)) { - case IDC_WHITERECT: - case IDC_BUILDTIME: - case IDC_CREDITSFILE: - case IDC_DEVS: - SetTextColor((HDC)wParam, GetSysColor(COLOR_WINDOWTEXT)); - break; - default: - return FALSE; - } - SetBkColor((HDC)wParam, GetSysColor(COLOR_WINDOW)); - return (INT_PTR)GetSysColorBrush(COLOR_WINDOW); - - case WM_DESTROY: - Window_FreeIcon_IcoLib(hwndDlg); - { - HFONT hFont = (HFONT)SendDlgItemMessage(hwndDlg, IDC_VERSION, WM_GETFONT, 0, 0); - SendDlgItemMessage(hwndDlg, IDC_VERSION, WM_SETFONT, SendDlgItemMessage(hwndDlg, IDOK, WM_GETFONT, 0, 0), 0); - DeleteObject(hFont); - } - break; - } - return FALSE; -} diff --git a/src/modules/help/help.cpp b/src/modules/help/help.cpp deleted file mode 100644 index 30c25ff87c..0000000000 --- a/src/modules/help/help.cpp +++ /dev/null @@ -1,116 +0,0 @@ -/* - -Miranda IM: the free IM client for Microsoft* Windows* - -Copyright 2000-2009 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 "..\..\core\commonheaders.h" - -INT_PTR CALLBACK DlgProcAbout(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam); - -HWND hAboutDlg = NULL; -static HANDLE hBugEvent = NULL; - -static INT_PTR AboutCommand(WPARAM wParam, LPARAM) -{ - if (IsWindow(hAboutDlg)) { - SetForegroundWindow(hAboutDlg); - SetFocus(hAboutDlg); - return 0; - } - hAboutDlg = CreateDialog(hInst, MAKEINTRESOURCE(IDD_ABOUT), (HWND)wParam, DlgProcAbout); - return 0; -} - -static INT_PTR IndexCommand(WPARAM, LPARAM) -{ - CallService(MS_UTILS_OPENURL, 1, (LPARAM)Translate("http://wiki.miranda-im.org/")); - return 0; -} - -static INT_PTR WebsiteCommand(WPARAM, LPARAM) -{ - CallService(MS_UTILS_OPENURL, 1, (LPARAM)"http://www.miranda-im.org"); - return 0; -} - -static int BugCommandEvent(WPARAM wParam, LPARAM lParam) -{ - char *szUrl = (char*)lParam; - if (szUrl) - CallService(MS_UTILS_OPENURL, 1, (LPARAM)szUrl); - - return 0; -} - -static INT_PTR BugCommand(WPARAM, LPARAM) -{ - NotifyEventHooks(hBugEvent, 0, (LPARAM)"http://code.google.com/p/miranda/issues/list"); - return 0; -} - -int ShutdownHelpModule(WPARAM, LPARAM) -{ - if (IsWindow(hAboutDlg)) DestroyWindow(hAboutDlg); - hAboutDlg = NULL; - return 0; -} - -int LoadHelpModule(void) -{ - HookEvent(ME_SYSTEM_PRESHUTDOWN, ShutdownHelpModule); - - CreateServiceFunction("Help/AboutCommand", AboutCommand); - CreateServiceFunction("Help/IndexCommand", IndexCommand); - CreateServiceFunction("Help/WebsiteCommand", WebsiteCommand); - CreateServiceFunction("Help/BugCommand", BugCommand); - - hBugEvent = CreateHookableEvent(ME_HELP_BUGREPORT); - SetHookDefaultForHookableEvent(hBugEvent, BugCommandEvent); - - CLISTMENUITEM mi = { 0 }; - mi.cbSize = sizeof(mi); - mi.flags = CMIF_ICONFROMICOLIB; - mi.icolibItem = GetSkinIconHandle(SKINICON_OTHER_MIRANDA); - mi.pszPopupName = LPGEN("&Help"); - mi.popupPosition = 2000090000; - mi.position = 2000090000; - mi.pszName = LPGEN("&About..."); - mi.pszService = "Help/AboutCommand"; - Menu_AddMainMenuItem(&mi); - - mi.icolibItem = GetSkinIconHandle(SKINICON_OTHER_HELP); - mi.position = -500050000; - mi.pszName = LPGEN("&Support"); - mi.pszService = "Help/IndexCommand"; - Menu_AddMainMenuItem(&mi); - - mi.icolibItem = GetSkinIconHandle(SKINICON_OTHER_MIRANDAWEB); - mi.position = 2000050000; - mi.pszName = LPGEN("&Miranda IM Homepage"); - mi.pszService = "Help/WebsiteCommand"; - Menu_AddMainMenuItem(&mi); - - mi.icolibItem = GetSkinIconHandle(SKINICON_EVENT_URL); - mi.position = 2000040000; - mi.pszName = LPGEN("&Report Bug"); - mi.pszService = "Help/BugCommand"; - Menu_AddMainMenuItem(&mi); - return 0; -} diff --git a/src/modules/history/history.cpp b/src/modules/history/history.cpp deleted file mode 100644 index c4d56a858a..0000000000 --- a/src/modules/history/history.cpp +++ /dev/null @@ -1,428 +0,0 @@ -/* - -Miranda IM: the free IM client for Microsoft* Windows* - -Copyright 2000-2009 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 "..\..\core\commonheaders.h" - -#define SUMMARY 0 -#define DETAIL 1 -#define DM_FINDNEXT (WM_USER+10) -#define DM_HREBUILD (WM_USER+11) - -static INT_PTR CALLBACK DlgProcHistory(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam); -static INT_PTR CALLBACK DlgProcHistoryFind(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam); -static HANDLE hWindowList = 0; - -static INT_PTR UserHistoryCommand(WPARAM wParam, LPARAM) -{ - HWND hwnd = WindowList_Find(hWindowList, (HANDLE)wParam); - if (hwnd) { - SetForegroundWindow(hwnd); - SetFocus(hwnd); - return 0; - } - CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_HISTORY), NULL, DlgProcHistory, wParam); - return 0; -} - -static int HistoryContactDelete(WPARAM wParam, LPARAM) -{ - HWND hwnd = WindowList_Find(hWindowList, (HANDLE)wParam); - if (hwnd != NULL) - DestroyWindow(hwnd); - return 0; -} - -int PreShutdownHistoryModule(WPARAM, LPARAM) -{ - if (hWindowList) - WindowList_BroadcastAsync(hWindowList, WM_DESTROY, 0, 0); - return 0; -} - -int LoadHistoryModule(void) -{ - CLISTMENUITEM mi = { 0 }; - mi.cbSize = sizeof(mi); - mi.position = 1000090000; - mi.flags = CMIF_ICONFROMICOLIB; - mi.icolibItem = GetSkinIconHandle(SKINICON_OTHER_HISTORY); - mi.pszName = LPGEN("View &History"); - mi.pszService = MS_HISTORY_SHOWCONTACTHISTORY; - Menu_AddContactMenuItem(&mi); - - CreateServiceFunction(MS_HISTORY_SHOWCONTACTHISTORY, UserHistoryCommand); - hWindowList = (HANDLE)CallService(MS_UTILS_ALLOCWINDOWLIST, 0, 0); - HookEvent(ME_DB_CONTACT_DELETED, HistoryContactDelete); - HookEvent(ME_SYSTEM_PRESHUTDOWN, PreShutdownHistoryModule); - return 0; -} - -///////////////////////////////////////////////////////////////////////////////////////// -// Fills the events list - -static void GetMessageDescription(DBEVENTINFO *dbei, TCHAR* buf, int cbBuf) -{ - TCHAR* msg = DbGetEventTextT(dbei, CP_ACP); - _tcsncpy(buf, msg ? msg : TranslateT("Invalid Message"), cbBuf); - buf[ cbBuf-1 ] = 0; - mir_free(msg); -} - -static void GetUrlDescription(DBEVENTINFO *dbei, TCHAR* buf, int cbBuf) -{ - int len = dbei->cbBlob; - if (len >= cbBuf) - len = cbBuf-1; - - MultiByteToWideChar(CP_ACP, 0, (LPCSTR)dbei->pBlob, len, buf, cbBuf); - buf[ len ] = 0; - - if (len < cbBuf-3) - _tcscat(buf, _T("\r\n")); -} - -static void GetFileDescription(DBEVENTINFO *dbei, TCHAR* buf, int cbBuf) -{ - int len = dbei->cbBlob - sizeof(DWORD); - if (len >= cbBuf) - len = cbBuf-1; - - MultiByteToWideChar(CP_ACP, 0, (LPCSTR)dbei->pBlob + sizeof(DWORD), len, buf, cbBuf); - buf[ len ] = 0; - - if (len < cbBuf-3) - _tcscat(buf, _T("\r\n")); -} - -static void GetObjectDescription(DBEVENTINFO *dbei, TCHAR* str, int cbStr) -{ - switch(dbei->eventType) { - case EVENTTYPE_MESSAGE: - GetMessageDescription(dbei, str, cbStr); - break; - - case EVENTTYPE_URL: - GetUrlDescription(dbei, str, cbStr); - break; - - case EVENTTYPE_FILE: - GetFileDescription(dbei, str, cbStr); - break; - - default: - { - DBEVENTTYPEDESCR* et = (DBEVENTTYPEDESCR*)CallService(MS_DB_EVENT_GETTYPE, (WPARAM)dbei->szModule, (LPARAM)dbei->eventType); - if (et && (et->flags & DETF_HISTORY)) { - GetMessageDescription(dbei, str, cbStr); - } - else - str[ 0 ] = 0; -} } } - -static void GetObjectSummary(DBEVENTINFO *dbei, TCHAR* str, int cbStr) -{ - TCHAR* pszSrc, *pszTmp = NULL; - - switch(dbei->eventType) { - case EVENTTYPE_MESSAGE: - if (dbei->flags & DBEF_SENT) pszSrc = TranslateT("Outgoing Message"); - else pszSrc = TranslateT("Incoming Message"); - break; - - case EVENTTYPE_URL: - if (dbei->flags & DBEF_SENT) pszSrc = TranslateT("Outgoing URL"); - else pszSrc = TranslateT("Incoming URL"); - break; - - case EVENTTYPE_FILE: - if (dbei->flags & DBEF_SENT) pszSrc = TranslateT("Outgoing File"); - else pszSrc = TranslateT("Incoming File"); - break; - - default: - { - DBEVENTTYPEDESCR* et = (DBEVENTTYPEDESCR*)CallService(MS_DB_EVENT_GETTYPE, (WPARAM)dbei->szModule, (LPARAM)dbei->eventType); - if (et && (et->flags & DETF_HISTORY)) { - pszTmp = mir_a2t(et->descr); - pszSrc = TranslateTS(pszTmp); - break; - } - else { - str[ 0 ] = 0; - return; - } } } - - _tcsncpy(str, (const TCHAR*)pszSrc, cbStr); - str[ cbStr-1 ] = 0; - - mir_free(pszTmp); -} - -typedef struct { - HANDLE hContact; - HWND hwnd; -} THistoryThread; - -static void FillHistoryThread(void* param) -{ - Thread_SetName("HistoryWindow::FillHistoryThread"); - - TCHAR str[200], eventText[256], strdatetime[64]; - HANDLE hDbEvent; - DBEVENTINFO dbei; - int newBlobSize, oldBlobSize, i; - HWND hwndList; - THistoryThread *hInfo = (THistoryThread*)param; - - SendDlgItemMessage(hInfo->hwnd, IDC_LIST, LB_RESETCONTENT, 0, 0); - i = CallService(MS_DB_EVENT_GETCOUNT, (WPARAM)hInfo->hContact, 0); - SendDlgItemMessage(hInfo->hwnd, IDC_LIST, LB_INITSTORAGE, i, i*40); - - ZeroMemory(&dbei, sizeof(dbei)); - dbei.cbSize = sizeof(dbei); - oldBlobSize = 0; - hDbEvent = (HANDLE)CallService(MS_DB_EVENT_FINDLAST, (WPARAM)hInfo->hContact, 0); - hwndList = GetDlgItem(hInfo->hwnd, IDC_LIST); - while (hDbEvent != NULL) { - if ( !IsWindow(hInfo->hwnd)) - break; - newBlobSize = CallService(MS_DB_EVENT_GETBLOBSIZE, (WPARAM)hDbEvent, 0); - if (newBlobSize>oldBlobSize) { - dbei.pBlob = (PBYTE)mir_realloc(dbei.pBlob, newBlobSize); - oldBlobSize = newBlobSize; - } - dbei.cbBlob = oldBlobSize; - CallService(MS_DB_EVENT_GET, (WPARAM)hDbEvent, (LPARAM)&dbei); - GetObjectSummary(&dbei, str, SIZEOF(str)); - if (str[0]) { - tmi.printTimeStamp(NULL, dbei.timestamp, _T("d t"), strdatetime, SIZEOF(strdatetime), 0); - mir_sntprintf(eventText, SIZEOF(eventText), _T("%s: %s"), strdatetime, str); - i = SendMessage(hwndList, LB_ADDSTRING, 0, (LPARAM)eventText); - SendMessage(hwndList, LB_SETITEMDATA, i, (LPARAM)hDbEvent); - } - hDbEvent = (HANDLE)CallService(MS_DB_EVENT_FINDPREV, (WPARAM)hDbEvent, 0); - } - mir_free(dbei.pBlob); - - SendDlgItemMessage(hInfo->hwnd, IDC_LIST, LB_SETCURSEL, 0, 0); - SendMessage(hInfo->hwnd, WM_COMMAND, MAKEWPARAM(IDC_LIST, LBN_SELCHANGE), 0); - EnableWindow(GetDlgItem(hInfo->hwnd, IDC_LIST), TRUE); - mir_free(hInfo); -} - -static int HistoryDlgResizer(HWND, LPARAM, UTILRESIZECONTROL *urc) -{ - switch(urc->wId) { - case IDC_LIST: - return RD_ANCHORX_WIDTH|RD_ANCHORY_HEIGHT; - case IDC_EDIT: - return RD_ANCHORX_WIDTH|RD_ANCHORY_BOTTOM; - case IDC_FIND: - case IDC_DELETEHISTORY: - return RD_ANCHORX_LEFT|RD_ANCHORY_BOTTOM; - case IDOK: - return RD_ANCHORX_RIGHT|RD_ANCHORY_BOTTOM; - } - return RD_ANCHORX_LEFT|RD_ANCHORY_TOP; -} - -static INT_PTR CALLBACK DlgProcHistory(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) -{ - HANDLE hContact; - - hContact = (HANDLE)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); - switch (msg) { - case WM_INITDIALOG: - TranslateDialogDefault(hwndDlg); - SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)lParam); - hContact = (HANDLE)lParam; - WindowList_Add(hWindowList, hwndDlg, hContact); - Utils_RestoreWindowPosition(hwndDlg, hContact, "History", ""); - { - TCHAR* contactName, str[200]; - contactName = cli.pfnGetContactDisplayName(hContact, 0); - mir_sntprintf(str, SIZEOF(str), TranslateT("History for %s"), contactName); - SetWindowText(hwndDlg, str); - } - Window_SetIcon_IcoLib(hwndDlg, SKINICON_OTHER_HISTORY); - SendMessage(hwndDlg, DM_HREBUILD, 0, 0); - return TRUE; - - case DM_HREBUILD: - { - THistoryThread* hInfo = (THistoryThread*)mir_alloc(sizeof(THistoryThread)); - EnableWindow(GetDlgItem(hwndDlg, IDC_LIST), FALSE); - hInfo->hContact = hContact; - hInfo->hwnd = hwndDlg; - forkthread(FillHistoryThread, 0, hInfo); - } - return TRUE; - - case WM_DESTROY: - Window_FreeIcon_IcoLib(hwndDlg); - Utils_SaveWindowPosition(hwndDlg, hContact, "History", ""); - WindowList_Remove(hWindowList, hwndDlg); - return TRUE; - - case WM_GETMINMAXINFO: - ((MINMAXINFO*)lParam)->ptMinTrackSize.x = 300; - ((MINMAXINFO*)lParam)->ptMinTrackSize.y = 230; - - case WM_SIZE: - { - UTILRESIZEDIALOG urd = {0}; - urd.cbSize = sizeof(urd); - urd.hwndDlg = hwndDlg; - urd.hInstance = hInst; - urd.lpTemplate = MAKEINTRESOURCEA(IDD_HISTORY); - urd.lParam = (LPARAM)NULL; - urd.pfnResizer = HistoryDlgResizer; - CallService(MS_UTILS_RESIZEDIALOG, 0, (LPARAM)&urd); - return TRUE; - } - case WM_COMMAND: - switch (LOWORD(wParam)) { - case IDOK: - case IDCANCEL: - DestroyWindow(hwndDlg); - return TRUE; - - case IDC_FIND: - ShowWindow(CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_HISTORY_FIND), hwndDlg, DlgProcHistoryFind, (LPARAM)hwndDlg), SW_SHOW); - return TRUE; - - case IDC_DELETEHISTORY: - { - HANDLE hDbevent; - int index = SendDlgItemMessage(hwndDlg, IDC_LIST, LB_GETCURSEL, 0, 0); - if (index == LB_ERR) - break; - - if (MessageBox(hwndDlg, TranslateT("Are you sure you want to delete this history item?"), TranslateT("Delete History"), MB_YESNO|MB_ICONQUESTION) == IDYES) { - hDbevent = (HANDLE)SendDlgItemMessage(hwndDlg, IDC_LIST, LB_GETITEMDATA, index, 0); - CallService(MS_DB_EVENT_DELETE, (WPARAM)hContact, (LPARAM)hDbevent); - SendMessage(hwndDlg, DM_HREBUILD, 0, 0); - } - return TRUE; - } - case IDC_LIST: - if (HIWORD(wParam) == LBN_SELCHANGE) { - TCHAR str[8192], *contactName; - HANDLE hDbEvent; - DBEVENTINFO dbei; - int sel; - sel = SendDlgItemMessage(hwndDlg, IDC_LIST, LB_GETCURSEL, 0, 0); - if (sel == LB_ERR) { EnableWindow(GetDlgItem(hwndDlg, IDC_DELETEHISTORY), FALSE); break; } - EnableWindow(GetDlgItem(hwndDlg, IDC_DELETEHISTORY), TRUE); - contactName = cli.pfnGetContactDisplayName(hContact, 0); - hDbEvent = (HANDLE)SendDlgItemMessage(hwndDlg, IDC_LIST, LB_GETITEMDATA, sel, 0); - ZeroMemory(&dbei, sizeof(dbei)); - dbei.cbSize = sizeof(dbei); - dbei.cbBlob = CallService(MS_DB_EVENT_GETBLOBSIZE, (WPARAM)hDbEvent, 0); - if ((int)dbei.cbBlob != -1) - { - dbei.pBlob = (PBYTE)mir_alloc(dbei.cbBlob); - if (CallService(MS_DB_EVENT_GET, (WPARAM)hDbEvent, (LPARAM)&dbei) == 0) - { - GetObjectDescription(&dbei, str, SIZEOF(str)); - if (str[0]) - SetDlgItemText(hwndDlg, IDC_EDIT, str); - } - mir_free(dbei.pBlob); - } - } - return TRUE; - } - break; - case DM_FINDNEXT: - { - TCHAR str[1024]; - HANDLE hDbEvent, hDbEventStart; - DBEVENTINFO dbei; - int newBlobSize, oldBlobSize; - - int index = SendDlgItemMessage(hwndDlg, IDC_LIST, LB_GETCURSEL, 0, 0); - if (index == LB_ERR) - break; - - hDbEventStart = (HANDLE)SendDlgItemMessage(hwndDlg, IDC_LIST, LB_GETITEMDATA, index, 0); - ZeroMemory(&dbei, sizeof(dbei)); - dbei.cbSize = sizeof(dbei); - dbei.pBlob = NULL; - oldBlobSize = 0; - for (;;) { - hDbEvent = (HANDLE)SendDlgItemMessage(hwndDlg, IDC_LIST, LB_GETITEMDATA, ++index, 0); - if (hDbEvent == (HANDLE)LB_ERR) { - index = -1; - continue; - } - if (hDbEvent == hDbEventStart) break; - newBlobSize = CallService(MS_DB_EVENT_GETBLOBSIZE, (WPARAM)hDbEvent, 0); - if (newBlobSize>oldBlobSize) { - dbei.pBlob = (PBYTE)mir_realloc(dbei.pBlob, newBlobSize); - oldBlobSize = newBlobSize; - } - dbei.cbBlob = oldBlobSize; - CallService(MS_DB_EVENT_GET, (WPARAM)hDbEvent, (LPARAM)&dbei); - GetObjectDescription(&dbei, str, SIZEOF(str)); - if (str[0]) { - CharUpperBuff(str, lstrlen(str)); - if (_tcsstr(str, (const TCHAR*)lParam) != NULL) { - SendDlgItemMessage(hwndDlg, IDC_LIST, LB_SETCURSEL, index, 0); - SendMessage(hwndDlg, WM_COMMAND, MAKEWPARAM(IDC_LIST, LBN_SELCHANGE), 0); - break; - } } } - - mir_free(dbei.pBlob); - break; - } - } - return FALSE; -} - -static INT_PTR CALLBACK DlgProcHistoryFind(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) -{ - switch (msg) { - case WM_INITDIALOG: - TranslateDialogDefault(hwndDlg); - SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)lParam); - return TRUE; - - case WM_COMMAND: - switch (LOWORD(wParam)) { - case IDOK://find Next - { - TCHAR str[128]; - HWND hwndParent = (HWND)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); - GetDlgItemText(hwndDlg, IDC_FINDWHAT, str, SIZEOF(str)); - CharUpperBuff(str, lstrlen(str)); - SendMessage(hwndParent, DM_FINDNEXT, 0, (LPARAM)str); - return TRUE; - } - case IDCANCEL: - DestroyWindow(hwndDlg); - return TRUE; - } - break; - } - return FALSE; -} diff --git a/src/modules/idle/idle.cpp b/src/modules/idle/idle.cpp deleted file mode 100644 index fdd842ef79..0000000000 --- a/src/modules/idle/idle.cpp +++ /dev/null @@ -1,524 +0,0 @@ -/* - -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 "..\..\core\commonheaders.h" - -#define IDLEMOD "Idle" -#define IDL_USERIDLECHECK "UserIdleCheck" -#define IDL_IDLEMETHOD "IdleMethod" -#define IDL_IDLETIME1ST "IdleTime1st" -#define IDL_IDLEONSAVER "IdleOnSaver" // IDC_SCREENSAVER -#define IDL_IDLEONFULLSCR "IdleOnFullScr" // IDC_FULLSCREEN -#define IDL_IDLEONLOCK "IdleOnLock" // IDC_LOCKED -#define IDL_IDLEONTSDC "IdleOnTerminalDisconnect" // -#define IDL_IDLEPRIVATE "IdlePrivate" // IDC_IDLEPRIVATE -#define IDL_IDLESTATUSLOCK "IdleStatusLock" // IDC_IDLESTATUSLOCK -#define IDL_AAENABLE "AAEnable" -#define IDL_AASTATUS "AAStatus" -#define IDL_IDLESOUNDSOFF "IdleSoundsOff" - -#define IdleObject_IsIdle(obj) (obj->state&0x1) -#define IdleObject_SetIdle(obj) (obj->state|=0x1) -#define IdleObject_ClearIdle(obj) (obj->state&=~0x1) - -// either use meth 0, 1 or figure out which one -#define IdleObject_UseMethod0(obj) (obj->state&=~0x2) -#define IdleObject_UseMethod1(obj) (obj->state|=0x2) -#define IdleObject_GetMethod(obj) (obj->state&0x2) - -#define IdleObject_IdleCheckSaver(obj) (obj->state&0x4) -#define IdleObject_SetSaverCheck(obj) (obj->state|=0x4) - -#define IdleObject_IdleCheckWorkstation(obj) (obj->state&0x8) -#define IdleObject_SetWorkstationCheck(obj) (obj->state|=0x8) - -#define IdleObject_IsPrivacy(obj) (obj->state&0x10) -#define IdleObject_SetPrivacy(obj) (obj->state|=0x10) - -#define IdleObject_SetStatusLock(obj) (obj->state|=0x20) - -#define IdleObject_IdleCheckTerminal(obj) (obj->state&0x40) -#define IdleObject_SetTerminalCheck(obj) (obj->state|=0x40) - -#define IdleObject_IdleCheckFullScr(obj) (obj->state&0x80) -#define IdleObject_SetFullScrCheck(obj) (obj->state|=0x80) - -//#include - -#ifndef _INC_WTSAPI - -#define WTS_CURRENT_SERVER_HANDLE ((HANDLE)NULL) -#define WTS_CURRENT_SESSION ((DWORD)-1) - -typedef enum _WTS_CONNECTSTATE_CLASS { - WTSActive, // User logged on to WinStation - WTSConnected, // WinStation connected to client - WTSConnectQuery, // In the process of connecting to client - WTSShadow, // Shadowing another WinStation - WTSDisconnected, // WinStation logged on without client - WTSIdle, // Waiting for client to connect - WTSListen, // WinStation is listening for connection - WTSReset, // WinStation is being reset - WTSDown, // WinStation is down due to error - WTSInit, // WinStation in initialization -} WTS_CONNECTSTATE_CLASS; - -typedef enum _WTS_INFO_CLASS { - WTSInitialProgram, - WTSApplicationName, - WTSWorkingDirectory, - WTSOEMId, - WTSSessionId, - WTSUserName, - WTSWinStationName, - WTSDomainName, - WTSConnectState, - WTSClientBuildNumber, - WTSClientName, - WTSClientDirectory, - WTSClientProductId, - WTSClientHardwareId, - WTSClientAddress, - WTSClientDisplay, - WTSClientProtocolType, -} WTS_INFO_CLASS; - -#endif - -VOID (WINAPI *_WTSFreeMemory)(PVOID); -BOOL (WINAPI *_WTSQuerySessionInformation)(HANDLE, DWORD, WTS_INFO_CLASS, PVOID, DWORD*); - -BOOL bIsWTSApiPresent = FALSE; - -static BOOL bModuleInitialized = FALSE; - -BOOL InitWTSAPI() -{ - HMODULE hDll = LoadLibraryA("wtsapi32.dll"); - if (hDll) { - _WTSFreeMemory = (VOID (WINAPI *)(PVOID))GetProcAddress(hDll, "WTSFreeMemory"); - _WTSQuerySessionInformation = (BOOL (WINAPI *)(HANDLE, DWORD, WTS_INFO_CLASS, PVOID, DWORD*))GetProcAddress(hDll, "WTSQuerySessionInformationW"); - - if (_WTSFreeMemory && _WTSQuerySessionInformation) return 1; - } - return 0; -} - -BOOL IsTerminalDisconnected() -{ - PVOID pBuffer = NULL; - DWORD pBytesReturned = 0; - BOOL result = FALSE; - - if ( !bIsWTSApiPresent) - return FALSE; - - if (_WTSQuerySessionInformation(WTS_CURRENT_SERVER_HANDLE, WTS_CURRENT_SESSION, WTSConnectState, &pBuffer, &pBytesReturned)) { - if (*(PDWORD)pBuffer == WTSDisconnected) - result = TRUE; - } - else bIsWTSApiPresent = FALSE; - - if (pBuffer) - _WTSFreeMemory(pBuffer); - return result; -} - -typedef struct { - UINT_PTR hTimer; - unsigned int useridlecheck; - unsigned int state; - unsigned int minutes; // user setting, number of minutes of inactivity to wait for - POINT mousepos; - unsigned int mouseidle; - int aastatus; - int idleType; - int aasoundsoff; -} - IdleObject; - -static const WORD aa_Status[] = {ID_STATUS_AWAY, ID_STATUS_NA, ID_STATUS_OCCUPIED, ID_STATUS_DND, ID_STATUS_ONTHEPHONE, ID_STATUS_OUTTOLUNCH}; - -static IdleObject gIdleObject; -static HANDLE hIdleEvent; -static BOOL (WINAPI * MyGetLastInputInfo)(PLASTINPUTINFO); - -void CALLBACK IdleTimer(HWND hwnd, UINT umsg, UINT_PTR idEvent, DWORD dwTime); - -static void IdleObject_ReadSettings(IdleObject * obj) -{ - obj->useridlecheck = DBGetContactSettingByte(NULL, IDLEMOD, IDL_USERIDLECHECK, 0); - obj->minutes = DBGetContactSettingByte(NULL, IDLEMOD, IDL_IDLETIME1ST, 10); - obj->aastatus = !DBGetContactSettingByte(NULL, IDLEMOD, IDL_AAENABLE, 0) ? 0 : DBGetContactSettingWord(NULL, IDLEMOD, IDL_AASTATUS, 0); - if (DBGetContactSettingByte(NULL, IDLEMOD, IDL_IDLESOUNDSOFF, 1)) - obj->aasoundsoff = 1; - else - obj->aasoundsoff = 0; - if (DBGetContactSettingByte(NULL, IDLEMOD, IDL_IDLEMETHOD, 0)) IdleObject_UseMethod1(obj); - else IdleObject_UseMethod0(obj); - if (DBGetContactSettingByte(NULL, IDLEMOD, IDL_IDLEONSAVER, 0)) IdleObject_SetSaverCheck(obj); - if (DBGetContactSettingByte(NULL, IDLEMOD, IDL_IDLEONFULLSCR, 0)) IdleObject_SetFullScrCheck(obj); - if (DBGetContactSettingByte(NULL, IDLEMOD, IDL_IDLEONLOCK, 0)) IdleObject_SetWorkstationCheck(obj); - if (DBGetContactSettingByte(NULL, IDLEMOD, IDL_IDLEPRIVATE, 0)) IdleObject_SetPrivacy(obj); - if (DBGetContactSettingByte(NULL, IDLEMOD, IDL_IDLESTATUSLOCK, 0)) IdleObject_SetStatusLock(obj); - if (DBGetContactSettingByte(NULL, IDLEMOD, IDL_IDLEONTSDC, 0)) IdleObject_SetTerminalCheck(obj); -} - -static void IdleObject_Create(IdleObject * obj) -{ - ZeroMemory(obj, sizeof(IdleObject)); - obj->hTimer = SetTimer(NULL, 0, 2000, IdleTimer); - IdleObject_ReadSettings(obj); -} - -static void IdleObject_Destroy(IdleObject * obj) -{ - if (IdleObject_IsIdle(obj)) - NotifyEventHooks(hIdleEvent, 0, 0); - IdleObject_ClearIdle(obj); - KillTimer(NULL, obj->hTimer); -} - -static int IdleObject_IsUserIdle(IdleObject * obj) -{ - DWORD dwTick; - if (IdleObject_GetMethod(obj)) { - CallService(MS_SYSTEM_GETIDLE, 0, (LPARAM)&dwTick); - return GetTickCount() - dwTick > (obj->minutes * 60 * 1000); - } - - if (MyGetLastInputInfo != NULL) { - LASTINPUTINFO ii; - ZeroMemory(&ii, sizeof(ii)); - ii.cbSize = sizeof(ii); - if (MyGetLastInputInfo(&ii)) - return GetTickCount() - ii.dwTime > (obj->minutes * 60 * 1000); - } - else { - POINT pt; - GetCursorPos(&pt); - if (pt.x != obj->mousepos.x || pt.y != obj->mousepos.y) { - obj->mousepos = pt; - obj->mouseidle = 0; - } - else obj->mouseidle += 2; - - if (obj->mouseidle) - return obj->mouseidle * 1000 >= (obj->minutes * 60 * 1000); - } - return FALSE; -} - -static bool IsWorkstationLocked (void) -{ - bool rc = false; - - if (openInputDesktop != NULL) { - HDESK hDesk = openInputDesktop(0, FALSE, DESKTOP_SWITCHDESKTOP); - if (hDesk == NULL) - rc = true; - else if (closeDesktop != NULL) - closeDesktop(hDesk); - } - return rc; -} - -static bool IsScreenSaverRunning(void) -{ - BOOL rc = FALSE; - SystemParametersInfo(SPI_GETSCREENSAVERRUNNING, 0, &rc, FALSE); - return rc != 0; -} - -bool IsFullScreen(void) -{ - RECT rcScreen = {0}; - - rcScreen.right = GetSystemMetrics(SM_CXSCREEN); - rcScreen.bottom = GetSystemMetrics(SM_CYSCREEN); - - if (MyMonitorFromWindow) - { - HMONITOR hMon = MyMonitorFromWindow(cli.hwndContactList, MONITOR_DEFAULTTONEAREST); - MONITORINFO mi; - mi.cbSize = sizeof(mi); - if (MyGetMonitorInfo(hMon, &mi)) - rcScreen = mi.rcMonitor; - } - - HWND hWndDesktop = GetDesktopWindow(); - HWND hWndShell = GetShellWindow(); - - // check foregroundwindow - HWND hWnd = GetForegroundWindow(); - if (hWnd && hWnd != hWndDesktop && hWnd != hWndShell) - { - TCHAR tszClassName[128] = _T(""); - GetClassName(hWnd, tszClassName, SIZEOF(tszClassName)); - if (_tcscmp(tszClassName, _T("WorkerW"))) - { - RECT rect, rectw, recti; - GetWindowRect(hWnd, &rectw); - - GetClientRect(hWnd, &rect); - ClientToScreen(hWnd, (LPPOINT)&rect); - ClientToScreen(hWnd, (LPPOINT)&rect.right); - - if (EqualRect(&rect, &rectw) && IntersectRect(&recti, &rect, &rcScreen) && - EqualRect(&recti, &rcScreen)) - return true; - } - } - - return false; -} - -static void IdleObject_Tick(IdleObject * obj) -{ - bool idle = false; - int idleType = 0, flags = 0; - - if (obj->useridlecheck && IdleObject_IsUserIdle(obj)) { - idleType = 1; idle = true; - } - else if (IdleObject_IdleCheckSaver(obj) && IsScreenSaverRunning()) { - idleType = 2; idle = true; - } - else if (IdleObject_IdleCheckFullScr(obj) && IsFullScreen()) { - idleType = 5; idle = true; - } - else if (IdleObject_IdleCheckWorkstation(obj) && IsWorkstationLocked()) { - idleType = 3; idle = true; - } - else if (IdleObject_IdleCheckTerminal(obj) && IsTerminalDisconnected()) { - idleType = 4; idle = true; - } - - if (IdleObject_IsPrivacy(obj)) - flags |= IDF_PRIVACY; - - if ( !IdleObject_IsIdle(obj) && idle) { - IdleObject_SetIdle(obj); - obj->idleType = idleType; - NotifyEventHooks(hIdleEvent, 0, IDF_ISIDLE | flags); - } - if (IdleObject_IsIdle(obj) && !idle) { - IdleObject_ClearIdle(obj); - obj->idleType = 0; - NotifyEventHooks(hIdleEvent, 0, flags); -} } - -void CALLBACK IdleTimer(HWND, UINT, UINT_PTR idEvent, DWORD) -{ - if (gIdleObject.hTimer == idEvent) - IdleObject_Tick(&gIdleObject); -} - -int IdleGetStatusIndex(WORD status) -{ - int j; - for (j = 0; j < SIZEOF(aa_Status); j++) - if (aa_Status[j] == status) - return j; - - return 0; -} - -static INT_PTR CALLBACK IdleOptsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) -{ - switch (msg) { - case WM_INITDIALOG: - { - int j; - int method = DBGetContactSettingByte(NULL, IDLEMOD, IDL_IDLEMETHOD, 0); - TranslateDialogDefault(hwndDlg); - CheckDlgButton(hwndDlg, IDC_IDLESHORT, DBGetContactSettingByte(NULL, IDLEMOD, IDL_USERIDLECHECK, 0) ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_IDLEONWINDOWS, method == 0 ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_IDLEONMIRANDA, method ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_SCREENSAVER, DBGetContactSettingByte(NULL, IDLEMOD, IDL_IDLEONSAVER, 0) ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_FULLSCREEN, DBGetContactSettingByte(NULL, IDLEMOD, IDL_IDLEONFULLSCR, 0) ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_LOCKED, DBGetContactSettingByte(NULL, IDLEMOD, IDL_IDLEONLOCK, 0) ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_IDLEPRIVATE, DBGetContactSettingByte(NULL, IDLEMOD, IDL_IDLEPRIVATE, 0) ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_IDLESTATUSLOCK, DBGetContactSettingByte(NULL, IDLEMOD, IDL_IDLESTATUSLOCK, 0) ? BST_CHECKED : BST_UNCHECKED); - if ( !bIsWTSApiPresent) - EnableWindow(GetDlgItem(hwndDlg, IDC_IDLETERMINAL), FALSE); - else - CheckDlgButton(hwndDlg, IDC_IDLETERMINAL, DBGetContactSettingByte(NULL, IDLEMOD, IDL_IDLEONTSDC, 0) ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_IDLESOUNDSOFF, DBGetContactSettingByte(NULL, IDLEMOD, IDL_IDLESOUNDSOFF, 1) ? BST_CHECKED : BST_UNCHECKED); - SendDlgItemMessage(hwndDlg, IDC_IDLESPIN, UDM_SETBUDDY, (WPARAM)GetDlgItem(hwndDlg, IDC_IDLE1STTIME), 0); - SendDlgItemMessage(hwndDlg, IDC_IDLESPIN, UDM_SETRANGE32, 1, 60); - SendDlgItemMessage(hwndDlg, IDC_IDLESPIN, UDM_SETPOS, 0, MAKELONG((short) DBGetContactSettingByte(NULL, IDLEMOD, IDL_IDLETIME1ST, 10), 0)); - SendDlgItemMessage(hwndDlg, IDC_IDLE1STTIME, EM_LIMITTEXT, (WPARAM)2, 0); - - CheckDlgButton(hwndDlg, IDC_AASHORTIDLE, DBGetContactSettingByte(NULL, IDLEMOD, IDL_AAENABLE, 0) ? BST_CHECKED:BST_UNCHECKED); - for (j = 0; j < SIZEOF(aa_Status); j++) - SendDlgItemMessage(hwndDlg, IDC_AASTATUS, CB_ADDSTRING, 0, (LPARAM)cli.pfnGetStatusModeDescription(aa_Status[j], 0)); - - j = IdleGetStatusIndex((WORD)(DBGetContactSettingWord(NULL, IDLEMOD, IDL_AASTATUS, 0))); - SendDlgItemMessage(hwndDlg, IDC_AASTATUS, CB_SETCURSEL, j, 0); - SendMessage(hwndDlg, WM_USER+2, 0, 0); - return TRUE; - } - case WM_USER+2: - { - BOOL checked = IsDlgButtonChecked(hwndDlg, IDC_IDLESHORT) == BST_CHECKED; - EnableWindow(GetDlgItem(hwndDlg, IDC_IDLEONWINDOWS), checked); - EnableWindow(GetDlgItem(hwndDlg, IDC_IDLEONMIRANDA), checked); - EnableWindow(GetDlgItem(hwndDlg, IDC_IDLE1STTIME), checked); - EnableWindow(GetDlgItem(hwndDlg, IDC_AASTATUS), IsDlgButtonChecked(hwndDlg, IDC_AASHORTIDLE) == BST_CHECKED?1:0); - EnableWindow(GetDlgItem(hwndDlg, IDC_IDLESTATUSLOCK), IsDlgButtonChecked(hwndDlg, IDC_AASHORTIDLE) == BST_CHECKED?1:0); - break; - } - case WM_NOTIFY: - { - NMHDR * hdr = (NMHDR *)lParam; - if (hdr && hdr->code == PSN_APPLY) { - int method = IsDlgButtonChecked(hwndDlg, IDC_IDLEONWINDOWS) == BST_CHECKED; - int mins = SendDlgItemMessage(hwndDlg, IDC_IDLESPIN, UDM_GETPOS, 0, 0); - DBWriteContactSettingByte(NULL, IDLEMOD, IDL_IDLETIME1ST, (BYTE)(HIWORD(mins) == 0 ? LOWORD(mins) : 10)); - DBWriteContactSettingByte(NULL, IDLEMOD, IDL_USERIDLECHECK, (BYTE)(IsDlgButtonChecked(hwndDlg, IDC_IDLESHORT) == BST_CHECKED)); - DBWriteContactSettingByte(NULL, IDLEMOD, IDL_IDLEMETHOD, (BYTE)(method ? 0 : 1)); - DBWriteContactSettingByte(NULL, IDLEMOD, IDL_IDLEONSAVER, (BYTE)(IsDlgButtonChecked(hwndDlg, IDC_SCREENSAVER) == BST_CHECKED)); - DBWriteContactSettingByte(NULL, IDLEMOD, IDL_IDLEONFULLSCR, (BYTE)(IsDlgButtonChecked(hwndDlg, IDC_FULLSCREEN) == BST_CHECKED)); - DBWriteContactSettingByte(NULL, IDLEMOD, IDL_IDLEONLOCK, (BYTE)(IsDlgButtonChecked(hwndDlg, IDC_LOCKED) == BST_CHECKED)); - DBWriteContactSettingByte(NULL, IDLEMOD, IDL_IDLEONTSDC, (BYTE)(IsDlgButtonChecked(hwndDlg, IDC_IDLETERMINAL) == BST_CHECKED)); - DBWriteContactSettingByte(NULL, IDLEMOD, IDL_IDLEPRIVATE, (BYTE)(IsDlgButtonChecked(hwndDlg, IDC_IDLEPRIVATE) == BST_CHECKED)); - DBWriteContactSettingByte(NULL, IDLEMOD, IDL_AAENABLE, (BYTE)(IsDlgButtonChecked(hwndDlg, IDC_AASHORTIDLE) == BST_CHECKED?1:0)); - DBWriteContactSettingByte(NULL, IDLEMOD, IDL_IDLESTATUSLOCK, (BYTE)(IsDlgButtonChecked(hwndDlg, IDC_IDLESTATUSLOCK) == BST_CHECKED?1:0)); - { - int curSel = SendDlgItemMessage(hwndDlg, IDC_AASTATUS, CB_GETCURSEL, 0, 0); - if (curSel != CB_ERR) { - DBWriteContactSettingWord(NULL, IDLEMOD, IDL_AASTATUS, (WORD)(aa_Status[curSel])); - } - } - DBWriteContactSettingByte(NULL, IDLEMOD, IDL_IDLESOUNDSOFF, (BYTE)(IsDlgButtonChecked(hwndDlg, IDC_IDLESOUNDSOFF) == BST_CHECKED)); - // destroy any current idle and reset settings. - IdleObject_Destroy(&gIdleObject); - IdleObject_Create(&gIdleObject); - } - break; - } - case WM_COMMAND: - switch (LOWORD(wParam)) { - case IDC_IDLE1STTIME: - { - int min; - if ((HWND)lParam != GetFocus() || HIWORD(wParam) != EN_CHANGE) return FALSE; - min = GetDlgItemInt(hwndDlg, IDC_IDLE1STTIME, NULL, FALSE); - if (min == 0 && GetWindowTextLength(GetDlgItem(hwndDlg, IDC_IDLE1STTIME))) - SendDlgItemMessage(hwndDlg, IDC_IDLESPIN, UDM_SETPOS, 0, MAKELONG((short) 1, 0)); - break; - } - case IDC_IDLESHORT: - case IDC_AASHORTIDLE: - SendMessage(hwndDlg, WM_USER+2, 0, 0); - break; - - case IDC_AASTATUS: - if (HIWORD(wParam) != CBN_SELCHANGE) - return TRUE; - } - SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); - break; - } - return FALSE; -} - -static int IdleOptInit(WPARAM wParam, LPARAM) -{ - OPTIONSDIALOGPAGE odp = { 0 }; - odp.cbSize = sizeof(odp); - odp.position = 100000000; - odp.hInstance = hInst; - odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_IDLE); - odp.pszGroup = LPGEN("Status"); - odp.pszTitle = LPGEN("Idle"); - odp.pfnDlgProc = IdleOptsDlgProc; - odp.flags = ODPF_BOLDGROUPS; - Options_AddPage(wParam, &odp); - return 0; -} - -static INT_PTR IdleGetInfo(WPARAM, LPARAM lParam) -{ - MIRANDA_IDLE_INFO *mii = (MIRANDA_IDLE_INFO*)lParam; - if ( !mii || (mii->cbSize != sizeof(MIRANDA_IDLE_INFO) && mii->cbSize != MIRANDA_IDLE_INFO_SIZE_1)) - return 1; - - mii->idleTime = gIdleObject.minutes; - mii->privacy = gIdleObject.state&0x10; - mii->aaStatus = gIdleObject.aastatus; - mii->aaLock = gIdleObject.state&0x20; - mii->idlesoundsoff = gIdleObject.aasoundsoff; - - if (mii->cbSize == sizeof(MIRANDA_IDLE_INFO)) - mii->idleType = gIdleObject.idleType; - return 0; -} - -static int IdleModernOptInit(WPARAM wParam, LPARAM) -{ - static const int iBoldControls[] = - { - IDC_TXT_TITLE1, IDC_TXT_TITLE2, IDC_TXT_TITLE3, - MODERNOPT_CTRL_LAST - }; - - MODERNOPTOBJECT obj = {0}; - obj.cbSize = sizeof(obj); - obj.hInstance = hInst; - obj.dwFlags = MODEROPT_FLG_TCHAR | MODEROPT_FLG_NORESIZE; - obj.iSection = MODERNOPT_PAGE_STATUS; - obj.iType = MODERNOPT_TYPE_SECTIONPAGE; - obj.iBoldControls = (int*)iBoldControls; - obj.lpzTemplate = MAKEINTRESOURCEA(IDD_MODERNOPT_IDLE); - obj.pfnDlgProc = IdleOptsDlgProc; -// obj.lpzClassicGroup = "Status"; -// obj.lpzClassicPage = "Messages"; - obj.lpzHelpUrl = "http://wiki.miranda-im.org/"; - CallService(MS_MODERNOPT_ADDOBJECT, wParam, (LPARAM)&obj); - return 0; -} - -int LoadIdleModule(void) -{ - bModuleInitialized = TRUE; - - bIsWTSApiPresent = InitWTSAPI(); - MyGetLastInputInfo = (BOOL (WINAPI *)(LASTINPUTINFO*))GetProcAddress(GetModuleHandleA("user32"), "GetLastInputInfo"); - hIdleEvent = CreateHookableEvent(ME_IDLE_CHANGED); - IdleObject_Create(&gIdleObject); - CreateServiceFunction(MS_IDLE_GETIDLEINFO, IdleGetInfo); - HookEvent(ME_OPT_INITIALISE, IdleOptInit); - HookEvent(ME_MODERNOPT_INITIALIZE, IdleModernOptInit); - return 0; -} - -void UnloadIdleModule() -{ - if ( !bModuleInitialized) return; - - IdleObject_Destroy(&gIdleObject); - DestroyHookableEvent(hIdleEvent); - hIdleEvent = NULL; -} diff --git a/src/modules/plugins/newplugins.cpp b/src/modules/plugins/newplugins.cpp index 16606ff990..04ac293b97 100644 --- a/src/modules/plugins/newplugins.cpp +++ b/src/modules/plugins/newplugins.cpp @@ -56,12 +56,11 @@ MuuidReplacement pluginDefault[] = { MIID_IDLE, _T("stdidle"), NULL }, // 7 { MIID_AUTOAWAY, _T("stdautoaway"), NULL }, // 8 { MIID_USERONLINE, _T("stduseronline"), NULL }, // 9 - { MIID_UPDATENOTIFY, _T("stdupdate"), NULL }, // 10 - { MIID_CLIST, NULL, NULL }, // 11 - { MIID_CHAT, NULL, NULL }, // 12 - { MIID_SRMM, NULL, NULL }, // 13 - { MIID_DATABASE, NULL, NULL }, // 14 + { MIID_CLIST, NULL, NULL }, // 10 + { MIID_CHAT, NULL, NULL }, // 11 + { MIID_SRMM, NULL, NULL }, // 12 + { MIID_DATABASE, NULL, NULL }, // 13 }; static BOOL bModuleInitialized = FALSE; diff --git a/src/modules/updatenotify/updatenotify.cpp b/src/modules/updatenotify/updatenotify.cpp deleted file mode 100644 index a223076062..0000000000 --- a/src/modules/updatenotify/updatenotify.cpp +++ /dev/null @@ -1,656 +0,0 @@ -/* - -Miranda IM: the free IM client for Microsoft* Windows* - -Copyright 2000-2009 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 "..\..\core\commonheaders.h" - -#define UN_MOD "UpdateNotify" -#define UN_ENABLE "UpdateNotifyEnable" -#define UN_ENABLE_DEF 1 -#define UN_LASTCHECK "UpdateNotifyLastCheck" -#define UN_SERVERPERIOD "UpdateNotifyPingDelayPeriod" -#define UN_CURRENTVERSION "UpdateNotifyCurrentVersion" -#define UN_CURRENTVERSIONFND "UpdateNotifyCurrentVersionFound" -#define UN_NOTIFYTYPE "UpdateNotifyType" -#define UN_NOTIFYTYPE_STABLE 1 -#define UN_NOTIFYTYPE_BETA 2 -#define UN_NOTIFYTYPE_ALPHA 3 -#define UN_NOTIFYTYPE_DEF UN_NOTIFYTYPE_STABLE -#define UN_CUSTOMXMLURL "UpdateNotifyCustomXMLURL" -#define UN_URLXML "http://update.miranda-im.org/update.xml" -#define UN_MINCHECKTIME 60*60 /* Check no more than once an hour */ -#define UN_DEFAULTCHECKTIME 60*48*60 /* Default to check once every 48 hours */ -#define UN_FIRSTCHECK 15 /* First check 15 seconds after startup */ -#define UN_REPEATNOTIFYDLY 24*60*60 /* 24 hours before showing release notification again */ - -typedef struct { - int isNew; - int isManual; - char version[64]; - char versionReal[16]; - char notesUrl[256]; - char downloadUrl[256]; - DWORD reqTime; -} UpdateNotifyData; - -typedef struct { - DWORD dwVersion; - char *szVersionPublic; - char *szVersion; - char *szDownload; - char *szNotes; -} UpdateNotifyReleaseData; - -static BOOL bModuleInitialized = FALSE; -static HANDLE hNetlibUser = 0, hHookModules, hHookPreShutdown; -static UINT_PTR updateTimerId; -static HANDLE dwUpdateThreadID = 0; -static HWND hwndUpdateDlg = 0, hwndManualUpdateDlg = 0; -static XML_API xun; - -static int UpdateNotifyOptInit(WPARAM wParam, LPARAM lParam); -static INT_PTR UpdateNotifyMenuCommand(WPARAM wParam, LPARAM lParam); -static VOID CALLBACK UpdateNotifyTimerCheck(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime); -static int UpdateNotifyMakeRequest(UpdateNotifyData *und); -static void UpdateNotifyPerform(void *m); -static INT_PTR CALLBACK UpdateNotifyProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam); -static INT_PTR CALLBACK UpdateNotifyOptsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam); - -static int UpdateNotifyModulesLoaded(WPARAM, LPARAM) { - NETLIBUSER nlu; - - ZeroMemory(&nlu, sizeof(nlu)); - nlu.cbSize = sizeof(nlu); - nlu.flags = NUF_OUTGOING|NUF_HTTPCONNS; - nlu.szSettingsModule = UN_MOD; - nlu.szDescriptiveName = Translate("Update notification"); - hNetlibUser = (HANDLE)CallService(MS_NETLIB_REGISTERUSER, 0, (LPARAM)&nlu); - return 0; -} - -static int UpdateNotifyPreShutdown(WPARAM, LPARAM) { - if (IsWindow(hwndUpdateDlg)) { - SendMessage(hwndUpdateDlg, WM_COMMAND, MAKELONG(IDOK, 0), 0); - } - if (IsWindow(hwndManualUpdateDlg)) { - SendMessage(hwndManualUpdateDlg, WM_COMMAND, MAKELONG(IDOK, 0), 0); - } - return 0; -} - -int LoadUpdateNotifyModule(void) { - CLISTMENUITEM mi = { 0 }; - - bModuleInitialized = TRUE; - - // Upgrade Routine - if (DBGetContactSettingByte(NULL, UN_MOD, "UpdateNotifyNotifyAlpha", 0)) { - DBDeleteContactSetting(NULL, UN_MOD, "UpdateNotifyNotifyAlpha"); - DBWriteContactSettingByte(NULL, UN_MOD, UN_NOTIFYTYPE, UN_NOTIFYTYPE_ALPHA); - } - // Ene Upgrade Routine - - CreateServiceFunction("UpdateNotify/UpdateCommand", UpdateNotifyMenuCommand); - mi.cbSize = sizeof(mi); - mi.flags = CMIF_ICONFROMICOLIB; - mi.icolibItem = GetSkinIconHandle(SKINICON_OTHER_EMPTYBLOB); - mi.pszPopupName = LPGEN("&Help"); - mi.position = 2000030000; - mi.pszName = LPGEN("Check for Update"); - mi.pszService = "UpdateNotify/UpdateCommand"; - Menu_AddMainMenuItem(&mi); - - hHookModules = HookEvent(ME_SYSTEM_MODULESLOADED, UpdateNotifyModulesLoaded); - hHookPreShutdown = HookEvent(ME_SYSTEM_PRESHUTDOWN, UpdateNotifyPreShutdown); - HookEvent(ME_OPT_INITIALISE, UpdateNotifyOptInit); - updateTimerId = SetTimer(NULL, 0, 1000*UN_FIRSTCHECK, UpdateNotifyTimerCheck); - mir_getXI(&xun); - return 0; -} - -void UnloadUpdateNotifyModule() -{ - if ( !bModuleInitialized) return; - UnhookEvent(hHookModules); - UnhookEvent(hHookPreShutdown); -} - -static int UpdateNotifyOptInit(WPARAM wParam, LPARAM) -{ - OPTIONSDIALOGPAGE odp = { 0 }; - odp.cbSize = sizeof(odp); - odp.position = 100000000; - odp.hInstance = hInst; - odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_UPDATENOTIFY); - odp.pszGroup = LPGEN("Events"); - odp.pszTitle = LPGEN("Update Notify"); - odp.pfnDlgProc = UpdateNotifyOptsProc; - odp.flags = ODPF_BOLDGROUPS; - Options_AddPage(wParam, &odp); - return 0; -} - -static INT_PTR UpdateNotifyMenuCommand(WPARAM, LPARAM) { - UpdateNotifyData und; - - if (IsWindow(hwndManualUpdateDlg)) { - SetForegroundWindow(hwndManualUpdateDlg); - return 0; - } - ZeroMemory(&und, sizeof(und)); - UpdateNotifyMakeRequest(&und); - if (und.isNew) { - DBWriteContactSettingString(NULL, UN_MOD, UN_CURRENTVERSION, und.versionReal); - DBWriteContactSettingDword(NULL, UN_MOD, UN_CURRENTVERSIONFND, und.reqTime); - } - und.isManual = 1; - DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_UPDATE_NOTIFY), 0, UpdateNotifyProc, (LPARAM)&und); - hwndManualUpdateDlg = 0; - return 0; -} - -static VOID CALLBACK UpdateNotifyTimerCheck(HWND, UINT, UINT_PTR, DWORD) -{ - KillTimer(NULL, updateTimerId); - if ( !DBGetContactSettingByte(NULL, UN_MOD, UN_ENABLE, UN_ENABLE_DEF)) - return; - if (dwUpdateThreadID != 0) { - Netlib_Logf(hNetlibUser, "Update notification already running, ignoring attempt"); - return; - } - { - DWORD lastCheck = 0; - - if ( !hNetlibUser) - return; - lastCheck = DBGetContactSettingDword(NULL, UN_MOD, UN_LASTCHECK, 0); - if ( !lastCheck) { // never checked for update before - Netlib_Logf(hNetlibUser, "Running update notify check for the first time."); - dwUpdateThreadID = mir_forkthread(UpdateNotifyPerform, 0); - } - else { - DWORD dwNow = time(NULL), dwTimeDiff; - DWORD dwServerPing = DBGetContactSettingDword(NULL, UN_MOD, UN_SERVERPERIOD, UN_DEFAULTCHECKTIME); - - if (lastCheck>dwNow) { - // time for last check is after the current date so reset lastcheck and quit - DBWriteContactSettingDword(NULL, UN_MOD, UN_LASTCHECK, dwNow); - return; - } - dwTimeDiff = dwNow - lastCheck; - if (dwServerPingdwServerPing) - dwUpdateThreadID = mir_forkthread(UpdateNotifyPerform, 0); - } - updateTimerId = SetTimer(NULL, 0, 1000*UN_MINCHECKTIME, UpdateNotifyTimerCheck); - } -} - -static DWORD UpdateNotifyMakeVersion(char *str) { - DWORD a1, a2, a3, a4; - if ( !str) - return 0; - sscanf(str, "%u.%u.%u.%u", &a1, &a2, &a3, &a4); - return PLUGIN_MAKE_VERSION(a1, a2, a3, a4); -} - -inline bool UpdateNotifyIsNewer(DWORD dwCurrent, DWORD dwTest) -{ return dwTest > dwCurrent; } - -inline bool UpdateNotifyReleaseDataValid(UpdateNotifyReleaseData *d) -{ return d && d->szVersionPublic && d->szVersion && d->szDownload && d->szNotes; } - -static void UpdateNotifyFreeReleaseData(UpdateNotifyReleaseData *d) { - if ( !d) - return; - if (d->szVersionPublic) mir_free(d->szVersionPublic); - if (d->szVersion) mir_free(d->szVersion); - if (d->szDownload) mir_free(d->szDownload); - if (d->szNotes) mir_free(d->szNotes); -} - -static void UpdateNotifyReleaseLogUpdate(UpdateNotifyReleaseData *d) { - if ( !UpdateNotifyReleaseDataValid(d)) - return; - #ifdef _WIN64 - Netlib_Logf(hNetlibUser, "Update server version: %s [%s] [64-bit]", d->szVersionPublic, d->szVersion); - #else defined(_UNICODE) - Netlib_Logf(hNetlibUser, "Update server version: %s [%s] [Unicode]", d->szVersionPublic, d->szVersion); - #endif -} - -static void UpdateNotifyReleaseCopyData(UpdateNotifyReleaseData *d, UpdateNotifyData *und) { - if ( !UpdateNotifyReleaseDataValid(d) || !und) - return; - mir_snprintf(und->version, sizeof(und->version), "%s", d->szVersionPublic); - mir_snprintf(und->versionReal, sizeof(und->versionReal), "%s", d->szVersion); - mir_snprintf(und->notesUrl, sizeof(und->notesUrl), "%s", d->szNotes); - mir_snprintf(und->downloadUrl, sizeof(und->downloadUrl), "%s", d->szDownload); -} - -static int UpdateNotifyMakeRequest(UpdateNotifyData *und) { - NETLIBHTTPREQUEST req; - NETLIBHTTPREQUEST *resp; - NETLIBHTTPHEADER headers[1]; - DWORD dwVersion; - char szVersion[32], szUrl[256], szVersionText[128], szUserAgent[64]; - int isUnicode, isAlphaCheck, isBetaCheck; - DBVARIANT dbv; - - if ( !und) - return 0; - und->version[0] = 0; - und->versionReal[0] = 0; - und->notesUrl[0] = 0; - und->downloadUrl[0] = 0; - und->reqTime = time(NULL); - - DBWriteContactSettingDword(NULL, UN_MOD, UN_LASTCHECK, und->reqTime); - CallService(MS_SYSTEM_GETVERSIONTEXT, sizeof(szVersionText), (LPARAM)szVersionText); - isUnicode = strstr(szVersionText, "Unicode") != NULL ? 1 : 0; - isBetaCheck = DBGetContactSettingByte(NULL, UN_MOD, UN_NOTIFYTYPE, UN_NOTIFYTYPE_DEF) == UN_NOTIFYTYPE_BETA?1:0; - isAlphaCheck = DBGetContactSettingByte(NULL, UN_MOD, UN_NOTIFYTYPE, UN_NOTIFYTYPE_DEF) == UN_NOTIFYTYPE_ALPHA?1:0; - dwVersion = CallService(MS_SYSTEM_GETVERSION, 0, 0); - mir_snprintf(szVersion, sizeof(szVersion), "%d.%d.%d.%d", - HIBYTE(HIWORD(dwVersion)), LOBYTE(HIWORD(dwVersion)), - HIBYTE(LOWORD(dwVersion)), LOBYTE(LOWORD(dwVersion))); - if ( !DBGetContactSettingString(NULL, UN_MOD, UN_CUSTOMXMLURL, &dbv)) { - mir_snprintf(szUrl, sizeof(szUrl), "%s", dbv.pszVal?dbv.pszVal:UN_URLXML); - DBFreeVariant(&dbv); - } - else mir_snprintf(szUrl, sizeof(szUrl), "%s", UN_URLXML); - ZeroMemory(&req, sizeof(req)); - req.cbSize = sizeof(req); - req.requestType = REQUEST_GET; - req.szUrl = szUrl; - req.flags = 0; - headers[0].szName = "User-Agent"; - headers[0].szValue = szUserAgent; - #ifdef _WIN64 - mir_snprintf(szUserAgent, sizeof(szUserAgent), "Miranda/%s (x64)", szVersion); - #else defined(_UNICODE) - mir_snprintf(szUserAgent, sizeof(szUserAgent), "Miranda/%s (Unicode)", szVersion); - #endif - req.headersCount = 1; - req.headers = headers; - resp = (NETLIBHTTPREQUEST *)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)hNetlibUser, (LPARAM)&req); - if (resp) { - if (resp->resultCode == 200 && resp->dataLength > 0) { - //int i; - int resUpdate = 0; - TCHAR *tXml; - char *tmp; - HXML nodeDoc, n; - - tXml = mir_a2t(resp->pData); - nodeDoc = xun.parseString(tXml, 0, _T("miranda")); - if (nodeDoc) { - int rdStableValid = 0, rdBetaValid = 0, rdAlphaValid = 0; - // stable release - UpdateNotifyReleaseData rdStable; - ZeroMemory(&rdStable, sizeof(rdStable)); - if ((n = xun.getChildByPath(nodeDoc, _T("releases/releasestable/versionpublic"), 0)) != NULL && xun.getText(n)) { - rdStable.szVersionPublic = mir_t2a(xun.getText(n)); - } - if ((n = xun.getChildByPath(nodeDoc, _T("releases/releasestable/versionreal"), 0)) != NULL && xun.getText(n)) { - rdStable.szVersion = mir_t2a(xun.getText(n)); - if (rdStable.szVersion) - rdStable.dwVersion = UpdateNotifyMakeVersion(rdStable.szVersion); - } - #ifdef _WIN64 - if ((n = xun.getChildByPath(nodeDoc, _T("releases/releasestable/downloadx64exe"), 0)) != NULL && xun.getText(n)) { - rdStable.szDownload = mir_t2a(xun.getText(n)); - } - #else defined(_UNICODE) - if ((n = xun.getChildByPath(nodeDoc, _T("releases/releasestable/downloadunicodeexe"), 0)) != NULL && xun.getText(n)) { - rdStable.szDownload = mir_t2a(xun.getText(n)); - } - #endif - if ((n = xun.getChildByPath(nodeDoc, _T("releases/releasestable/notesurl"), 0)) != NULL && xun.getText(n)) { - rdStable.szNotes = mir_t2a(xun.getText(n)); - } - rdStableValid = UpdateNotifyReleaseDataValid(&rdStable); - - // beta release - UpdateNotifyReleaseData rdBeta; - ZeroMemory(&rdBeta, sizeof(rdBeta)); - if ((n = xun.getChildByPath(nodeDoc, _T("releases/releasebeta/versionpublic"), 0)) != NULL && xun.getText(n)) { - rdBeta.szVersionPublic = mir_t2a(xun.getText(n)); - } - if ((n = xun.getChildByPath(nodeDoc, _T("releases/releasebeta/versionreal"), 0)) != NULL && xun.getText(n)) { - rdBeta.szVersion = mir_t2a(xun.getText(n)); - if (rdBeta.szVersion) - rdBeta.dwVersion = UpdateNotifyMakeVersion(rdBeta.szVersion); - } - #ifdef _WIN64 - if ((n = xun.getChildByPath(nodeDoc, _T("releases/releasebeta/downloadx64zip"), 0)) != NULL && xun.getText(n)) { - rdBeta.szDownload = mir_t2a(xun.getText(n)); - } - #else defined(_UNICODE) - if ((n = xun.getChildByPath(nodeDoc, _T("releases/releasebeta/downloadunicodeexe"), 0)) != NULL && xun.getText(n)) { - rdBeta.szDownload = mir_t2a(xun.getText(n)); - } - #endif - if ((n = xun.getChildByPath(nodeDoc, _T("releases/releasebeta/notesurl"), 0)) != NULL && xun.getText(n)) { - rdBeta.szNotes = mir_t2a(xun.getText(n)); - } - rdBetaValid = UpdateNotifyReleaseDataValid(&rdBeta); - - // alpha release - UpdateNotifyReleaseData rdAlpha; - ZeroMemory(&rdAlpha, sizeof(rdAlpha)); - if ((n = xun.getChildByPath(nodeDoc, _T("releases/releasealpha/versionpublic"), 0)) != NULL && xun.getText(n)) { - rdAlpha.szVersionPublic = mir_t2a(xun.getText(n)); - } - if ((n = xun.getChildByPath(nodeDoc, _T("releases/releasealpha/versionreal"), 0)) != NULL && xun.getText(n)) { - rdAlpha.szVersion = mir_t2a(xun.getText(n)); - if (rdAlpha.szVersion) - rdAlpha.dwVersion = UpdateNotifyMakeVersion(rdAlpha.szVersion); - } - #ifdef _WIN64 - if ((n = xun.getChildByPath(nodeDoc, _T("releases/releasealpha/downloadx64zip"), 0)) != NULL && xun.getText(n)) { - rdAlpha.szDownload = mir_t2a(xun.getText(n)); - } - #else defined(_UNICODE) - if ((n = xun.getChildByPath(nodeDoc, _T("releases/releasealpha/downloadunicodezip"), 0)) != NULL && xun.getText(n)) { - rdAlpha.szDownload = mir_t2a(xun.getText(n)); - } - #endif - if ((n = xun.getChildByPath(nodeDoc, _T("releases/releasealpha/notesurl"), 0)) != NULL && xun.getText(n)) { - rdAlpha.szNotes = mir_t2a(xun.getText(n)); - } - rdAlphaValid = UpdateNotifyReleaseDataValid(&rdAlpha); - - if (isBetaCheck) { - if ( !rdBetaValid && rdStableValid) { - UpdateNotifyReleaseLogUpdate(&rdStable); - if (UpdateNotifyIsNewer(dwVersion, rdStable.dwVersion)) - resUpdate = 1; - UpdateNotifyReleaseCopyData(&rdStable, und); - } - else if (rdBetaValid && rdStableValid && UpdateNotifyIsNewer(rdBeta.dwVersion, rdStable.dwVersion)) { - UpdateNotifyReleaseLogUpdate(&rdStable); - if (UpdateNotifyIsNewer(dwVersion, UpdateNotifyMakeVersion(rdStable.szVersion))) - resUpdate = 1; - UpdateNotifyReleaseCopyData(&rdStable, und); - } - else if (rdBetaValid) { - UpdateNotifyReleaseLogUpdate(&rdBeta); - if (UpdateNotifyIsNewer(dwVersion, rdBeta.dwVersion)) - resUpdate = 1; - UpdateNotifyReleaseCopyData(&rdBeta, und); - } - } - else if (isAlphaCheck) { - if ( !rdAlphaValid && rdStableValid) { - if (UpdateNotifyIsNewer(rdStable.dwVersion, rdAlpha.dwVersion)) { - UpdateNotifyReleaseLogUpdate(&rdAlpha); - if (UpdateNotifyIsNewer(dwVersion, rdAlpha.dwVersion)) - resUpdate = 1; - UpdateNotifyReleaseCopyData(&rdAlpha, und); - } - else { - UpdateNotifyReleaseLogUpdate(&rdStable); - if (UpdateNotifyIsNewer(dwVersion, rdStable.dwVersion)) - resUpdate = 1; - UpdateNotifyReleaseCopyData(&rdStable, und); - } - } - else if (rdAlphaValid && rdStableValid && UpdateNotifyIsNewer(rdAlpha.dwVersion, rdStable.dwVersion)) { - UpdateNotifyReleaseLogUpdate(&rdStable); - if (UpdateNotifyIsNewer(dwVersion, rdStable.dwVersion)) - resUpdate = 1; - UpdateNotifyReleaseCopyData(&rdStable, und); - } - else if ( !rdAlphaValid && rdBetaValid && rdStableValid) { - if (UpdateNotifyIsNewer(rdStable.dwVersion, rdBeta.dwVersion)) { - UpdateNotifyReleaseLogUpdate(&rdBeta); - if (UpdateNotifyIsNewer(dwVersion, rdBeta.dwVersion)) - resUpdate = 1; - UpdateNotifyReleaseCopyData(&rdBeta, und); - } - else { - UpdateNotifyReleaseLogUpdate(&rdStable); - if (UpdateNotifyIsNewer(dwVersion, rdStable.dwVersion)) - resUpdate = 1; - UpdateNotifyReleaseCopyData(&rdStable, und); - } - } - else if (rdAlphaValid) { - UpdateNotifyReleaseLogUpdate(&rdAlpha); - if (UpdateNotifyIsNewer(dwVersion, rdAlpha.dwVersion)) - resUpdate = 1; - UpdateNotifyReleaseCopyData(&rdAlpha, und); - } - } - else { - if (rdStableValid) { - UpdateNotifyReleaseLogUpdate(&rdStable); - if (UpdateNotifyIsNewer(dwVersion, rdStable.dwVersion)) - resUpdate = 1; - UpdateNotifyReleaseCopyData(&rdStable, und); - } - } - - UpdateNotifyFreeReleaseData(&rdStable); - UpdateNotifyFreeReleaseData(&rdBeta); - UpdateNotifyFreeReleaseData(&rdAlpha); - // settings - if ((n = xun.getChildByPath(nodeDoc, _T("settings/ping"), 0)) != NULL && xun.getText(n)) { - tmp = mir_t2a(xun.getText(n)); - if (tmp) { - int pingval = atoi(tmp); - if ((pingval*60*60)>UN_MINCHECKTIME) { - Netlib_Logf(hNetlibUser, "Next update check in %d hours", pingval); - DBWriteContactSettingDword(NULL, UN_MOD, UN_SERVERPERIOD, pingval*60*60); - } - mir_free(tmp); - } - } - if ((n = xun.getChildByPath(nodeDoc, _T("settings/updateurl"), 0)) != NULL && xun.getText(n)) { - tmp = mir_t2a(xun.getText(n)); - if (tmp) { - Netlib_Logf(hNetlibUser, "Update URL has changed (%s)", tmp); - DBWriteContactSettingString(NULL, UN_MOD, UN_CUSTOMXMLURL, tmp); - mir_free(tmp); - } - } - if (resUpdate && und->version && und->versionReal && und->notesUrl && und->downloadUrl) { - Netlib_Logf(hNetlibUser, "A new version of Miranda IM is available: %s", und->version); - und->isNew = 1; - } - xun.destroyNode(nodeDoc); - } - mir_free(tXml); - } - else Netlib_Logf(hNetlibUser, "Invalid response code from HTTP request"); - CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)resp); - } - else Netlib_Logf(hNetlibUser, "No response from HTTP request"); - return und->isNew; -} - -static void UpdateNotifyPerform(void *) -{ - UpdateNotifyData und; - DBVARIANT dbv; - - ZeroMemory(&und, sizeof(und)); - UpdateNotifyMakeRequest(&und); - if (und.isNew) { - int notify = 1; - - if ( !DBGetContactSettingString(NULL, UN_MOD, UN_CURRENTVERSION, &dbv)) { - if ( !strcmp(dbv.pszVal, und.versionReal)) { // already notified of this version - - DWORD dwNotifyLast = DBGetContactSettingDword(NULL, UN_MOD, UN_CURRENTVERSIONFND, 0); - - if (dwNotifyLast>und.reqTime) { // fix last check date if time has changed - DBWriteContactSettingDword(NULL, UN_MOD, UN_CURRENTVERSIONFND, und.reqTime); - notify = 0; - } - else if (und.reqTime-dwNotifyLastisManual) - hwndManualUpdateDlg = hwndDlg; - else hwndUpdateDlg = hwndDlg; - if (und->isNew) { - TCHAR* ptszVer = mir_a2t(und->version); - mir_sntprintf(szTmp, SIZEOF(szTmp), TranslateT("Miranda IM %s Now Available"), ptszVer); - mir_free(ptszVer); - ShowWindow(GetDlgItem(hwndDlg, IDC_UPDATE), SW_HIDE); - } - else { - mir_sntprintf(szTmp, SIZEOF(szTmp), TranslateT("No Update Available")); - SetDlgItemText(hwndDlg, IDC_MESSAGE, TranslateT("You are running the latest version of Miranda IM. No update is available at this time.")); - EnableWindow(GetDlgItem(hwndDlg, IDC_DOWNLOAD), FALSE); - ShowWindow(GetDlgItem(hwndDlg, IDC_VERSION), SW_HIDE); - } - SetWindowText(hwndDlg, szTmp); - CallService(MS_SYSTEM_GETVERSIONTEXT, sizeof(szVersion), (LPARAM)szVersion); - p = strstr(szVersion, "x64 Unicode"); - if (p) - *p = '\0'; - p = strstr(szVersion, " Unicode"); - if (p) - *p = '\0'; - SetDlgItemTextA(hwndDlg, IDC_CURRENTVERSION, szVersion); - mir_snprintf(szVersionTmp, SIZEOF(szVersionTmp), "%s", und->version?und->version:szVersion); - SetDlgItemTextA(hwndDlg, und->isNew?IDC_VERSION:IDC_UPDATE, szVersionTmp); - if (und->isNew) { - HFONT hFont; - LOGFONT lf; - - hFont = (HFONT)SendDlgItemMessage(hwndDlg, IDC_VERSION, WM_GETFONT, 0, 0); - GetObject(hFont, sizeof(lf), &lf); - lf.lfWeight = FW_BOLD; - hFont = CreateFontIndirect(&lf); - SendDlgItemMessage(hwndDlg, IDC_VERSION, WM_SETFONT, (WPARAM)hFont, 0); - hFont = (HFONT)SendDlgItemMessage(hwndDlg, IDC_NEWVERSIONLABEL, WM_GETFONT, 0, 0); - GetObject(hFont, sizeof(lf), &lf); - lf.lfWeight = FW_BOLD; - hFont = CreateFontIndirect(&lf); - SendDlgItemMessage(hwndDlg, IDC_NEWVERSIONLABEL, WM_SETFONT, (WPARAM)hFont, 0); - } - SetFocus(GetDlgItem(hwndDlg, IDOK)); - SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam); - } - break; - - case WM_COMMAND: - switch (LOWORD(wParam)) { - case IDC_VERSION: - { - UpdateNotifyData *und = (UpdateNotifyData*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); - if (und && und->notesUrl) - CallService(MS_UTILS_OPENURL, 1, (LPARAM)und->notesUrl); - break; - } - case IDC_DOWNLOAD: - { - UpdateNotifyData *und = (UpdateNotifyData*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); - if (und && und->downloadUrl) { - CallService(MS_UTILS_OPENURL, 1, (LPARAM)und->downloadUrl); - DestroyWindow(hwndDlg); - } - break; - } - case IDOK: - case IDCANCEL: - DestroyWindow(hwndDlg); - return TRUE; - } - break; - - case WM_DESTROY: - Window_FreeIcon_IcoLib(hwndDlg); - break; - } - return FALSE; -} - -static INT_PTR CALLBACK UpdateNotifyOptsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) -{ - switch (msg) { - case WM_INITDIALOG: - TranslateDialogDefault(hwndDlg); - CheckDlgButton(hwndDlg, IDC_ENABLEUPDATES, DBGetContactSettingByte(NULL, UN_MOD, UN_ENABLE, UN_ENABLE_DEF) ? BST_CHECKED : BST_UNCHECKED); - switch (DBGetContactSettingByte(NULL, UN_MOD, UN_NOTIFYTYPE, UN_NOTIFYTYPE_STABLE)) { - case UN_NOTIFYTYPE_BETA: CheckDlgButton(hwndDlg, IDC_ENABLEBETA, BST_CHECKED); break; - case UN_NOTIFYTYPE_ALPHA: CheckDlgButton(hwndDlg, IDC_ENABLEALPHA, BST_CHECKED); break; - default: CheckDlgButton(hwndDlg, IDC_ENABLESTABLE, BST_CHECKED); break; - } - return TRUE; - - case WM_COMMAND: - switch (LOWORD(wParam)) { - case IDC_ENABLEUPDATES: - case IDC_ENABLEALPHA: - case IDC_ENABLEBETA: - case IDC_ENABLESTABLE: - SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); - break; - } - break; - - case WM_NOTIFY: - { - NMHDR *hdr = (NMHDR *)lParam; - if (hdr && hdr->code == PSN_APPLY) { - DBWriteContactSettingByte(NULL, UN_MOD, UN_ENABLE, (BYTE)(IsDlgButtonChecked(hwndDlg, IDC_ENABLEUPDATES))); - if (IsDlgButtonChecked(hwndDlg, IDC_ENABLESTABLE)) - DBWriteContactSettingByte(NULL, UN_MOD, UN_NOTIFYTYPE, UN_NOTIFYTYPE_STABLE); - if (IsDlgButtonChecked(hwndDlg, IDC_ENABLEBETA)) - DBWriteContactSettingByte(NULL, UN_MOD, UN_NOTIFYTYPE, UN_NOTIFYTYPE_BETA); - if (IsDlgButtonChecked(hwndDlg, IDC_ENABLEALPHA)) - DBWriteContactSettingByte(NULL, UN_MOD, UN_NOTIFYTYPE, UN_NOTIFYTYPE_ALPHA); - } - break; - } - } - return FALSE; -} diff --git a/src/modules/useronline/useronline.cpp b/src/modules/useronline/useronline.cpp deleted file mode 100644 index e6f5148f50..0000000000 --- a/src/modules/useronline/useronline.cpp +++ /dev/null @@ -1,117 +0,0 @@ -/* - -Miranda IM: the free IM client for Microsoft* Windows* - -Copyright 2000-2009 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 "..\..\core\commonheaders.h" - -static int uniqueEventId = 0; - -static int UserOnlineSettingChanged(WPARAM wParam, LPARAM lParam) -{ - DBCONTACTWRITESETTING *cws = (DBCONTACTWRITESETTING*)lParam; - int newStatus, oldStatus; - - if ((HANDLE)wParam == NULL || strcmp(cws->szSetting, "Status")) return 0; - newStatus = cws->value.wVal; - oldStatus = DBGetContactSettingWord((HANDLE)wParam, "UserOnline", "OldStatus", ID_STATUS_OFFLINE); - DBWriteContactSettingWord((HANDLE)wParam, "UserOnline", "OldStatus", (WORD)newStatus); - if (CallService(MS_IGNORE_ISIGNORED, wParam, IGNOREEVENT_USERONLINE)) return 0; - if (DBGetContactSettingByte((HANDLE)wParam, "CList", "Hidden", 0)) return 0; - if (newStatus == ID_STATUS_OFFLINE && oldStatus != ID_STATUS_OFFLINE) { - // Remove the event from the queue if it exists since they are now offline - int lastEvent = (int)DBGetContactSettingDword((HANDLE)wParam, "UserOnline", "LastEvent", 0); - - if (lastEvent) { - CallService(MS_CLIST_REMOVEEVENT, wParam, (LPARAM)lastEvent); - DBWriteContactSettingDword((HANDLE)wParam, "UserOnline", "LastEvent", 0); - } - } - if ((newStatus == ID_STATUS_ONLINE || newStatus == ID_STATUS_FREECHAT) && - oldStatus != ID_STATUS_ONLINE && oldStatus != ID_STATUS_FREECHAT) { - { - DWORD ticked = db_dword_get(NULL, "UserOnline", cws->szModule, GetTickCount()); - // only play the sound (or show event) if this event happens at least 10 secs after the proto went from offline - if (GetTickCount() - ticked > (1000*10)) { - CLISTEVENT cle; - TCHAR tooltip[256]; - - ZeroMemory(&cle, sizeof(cle)); - cle.cbSize = sizeof(cle); - cle.flags = CLEF_ONLYAFEW | CLEF_TCHAR; - cle.hContact = (HANDLE)wParam; - cle.hDbEvent = (HANDLE)(uniqueEventId++); - cle.hIcon = LoadSkinIcon(SKINICON_OTHER_USERONLINE, false); - cle.pszService = "UserOnline/Description"; - mir_sntprintf(tooltip, SIZEOF(tooltip), TranslateT("%s is Online"), cli.pfnGetContactDisplayName((HANDLE)wParam, 0)); - cle.ptszTooltip = tooltip; - CallService(MS_CLIST_ADDEVENT, 0, (LPARAM)&cle); - IcoLib_ReleaseIcon(cle.hIcon, 0); - DBWriteContactSettingDword(cle.hContact, "UserOnline", "LastEvent", (DWORD)cle.hDbEvent); - SkinPlaySound("UserOnline"); - } - } - } - return 0; -} - -static int UserOnlineAck(WPARAM, LPARAM lParam) -{ - ACKDATA * ack = (ACKDATA*) lParam; - if (ack != 0 && ack->szModule && ack->type == ACKTYPE_STATUS && ack->result == ACKRESULT_SUCCESS && ack->hProcess == (HANDLE)ID_STATUS_OFFLINE) { - // if going from offline to any other mode, remember when it happened. - db_dword_set(NULL, "UserOnline", ack->szModule, GetTickCount()); - } - return 0; -} - -static int UserOnlineModulesLoaded(WPARAM, LPARAM) -{ - // reset the counter - for (int j = 0; j < accounts.getCount(); j++) - if (Proto_IsAccountEnabled(accounts[j])) db_dword_set(NULL, "UserOnline", accounts[j]->szModuleName, GetTickCount()); - - return 0; -} - -static int UserOnlineAccountsChanged(WPARAM eventCode, LPARAM lParam) -{ - PROTOACCOUNT* pa = (PROTOACCOUNT*)lParam; - - switch(eventCode) { - case PRAC_ADDED: - case PRAC_CHECKED: - // reset the counter - if (Proto_IsAccountEnabled(pa)) - db_dword_set(NULL, "UserOnline", pa->szModuleName, GetTickCount()); - break; - } - return 0; -} - -int LoadUserOnlineModule(void) -{ - HookEvent(ME_DB_CONTACT_SETTINGCHANGED, UserOnlineSettingChanged); - HookEvent(ME_PROTO_ACK, UserOnlineAck); - HookEvent(ME_SYSTEM_MODULESLOADED, UserOnlineModulesLoaded); - HookEvent(ME_PROTO_ACCLISTCHANGED, UserOnlineAccountsChanged); - SkinAddNewSoundEx("UserOnline", LPGEN("Alerts"), LPGEN("Online")); - return 0; -} -- cgit v1.2.3