diff options
author | George Hazan <george.hazan@gmail.com> | 2012-08-01 13:01:42 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2012-08-01 13:01:42 +0000 |
commit | 1aa6b664f3ba7574673a1ff9735f2264fefa04ee (patch) | |
tree | 2a0e032488eea718857f39676f94515a72ddccfc /plugins/PackUpdater_new/Src | |
parent | 2bd0e0f058acbabd6281256211a9f1ff7d88ede2 (diff) |
this folder considered to be useless
git-svn-id: http://svn.miranda-ng.org/main/trunk@1299 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/PackUpdater_new/Src')
-rw-r--r-- | plugins/PackUpdater_new/Src/Common.h | 140 | ||||
-rw-r--r-- | plugins/PackUpdater_new/Src/Events.cpp | 82 | ||||
-rw-r--r-- | plugins/PackUpdater_new/Src/Notifications.cpp | 695 | ||||
-rw-r--r-- | plugins/PackUpdater_new/Src/Notifications.h | 72 | ||||
-rw-r--r-- | plugins/PackUpdater_new/Src/Options.cpp | 493 | ||||
-rw-r--r-- | plugins/PackUpdater_new/Src/PackUpdater.cpp | 108 | ||||
-rw-r--r-- | plugins/PackUpdater_new/Src/Utils.cpp | 497 |
7 files changed, 0 insertions, 2087 deletions
diff --git a/plugins/PackUpdater_new/Src/Common.h b/plugins/PackUpdater_new/Src/Common.h deleted file mode 100644 index e18abc61f3..0000000000 --- a/plugins/PackUpdater_new/Src/Common.h +++ /dev/null @@ -1,140 +0,0 @@ -/*
-Copyright (C) 2010 Mataes
-
-This is free software; you can redistribute it and/or
-modify it under the terms of the GNU Library General Public
-License as published by the Free Software Foundation; either
-version 2 of the License, or (at your option) any later version.
-
-This 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
-Library General Public License for more details.
-
-You should have received a copy of the GNU Library General Public
-License along with this file; see the file license.txt. If
-not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA.
-*/
-
-#define MIRANDA_VER 0x0A00
-
-// Windows Header Files:
-#include <time.h>
-#include <stdio.h>
-#include <windows.h>
-#include <Windowsx.h>
-#include "vector" // stl vector header
-#include <Shlobj.h>
-
-// Miranda header files
-#include "win2k.h"
-#include <newpluginapi.h>
-#include <m_clist.h>
-#include <m_skin.h>
-#include <m_langpack.h>
-#include <m_options.h>
-#include <m_database.h>
-#include <m_utils.h>
-#include <m_system.h>
-#include <m_popup.h>
-#include <m_hotkeys.h>
-#include <m_netlib.h>
-#include <m_icolib.h>
-
-#include <m_folders.h>
-#include "m_popup2.h"
-
-#include "..\version.h"
-#include "..\resource.h"
-#include "Notifications.h"
-
-#define MODNAME "PackUpdater"
-#define MODULEA "Pack Updater"
-#define MODULEW L"Pack Updater"
-#define DEFAULT_UPDATES_FOLDER L"Pack Updates"
-typedef std::wstring tString;
-#define MODULE MODULEW
-
-struct FILEURL
-{
- TCHAR tszDownloadURL[2048];
- TCHAR tszDiskPath[MAX_PATH];
-};
-
-struct FILEINFO
-{
- TCHAR curhash[32];
- TCHAR newhash[32];
- TCHAR tszAdvFolder[256];
- TCHAR tszInfoURL[2048];
- TCHAR tszMessage[5000];
- TCHAR tszDescr[256];
- FILEURL File;
- BOOL enabled;
- BYTE FileType;
- INT FileNum;
- BYTE Force;
-};
-
-struct PackUpdaterIconList
-{
- char* szIconName;
- TCHAR* tszDescr;
- int IconID;
-};
-
-struct PopupDataText
-{
- TCHAR* Title;
- TCHAR* Text;
-};
-
-#define DEFAULT_REMINDER 1
-#define DEFAULT_UPDATEONSTARTUP 1
-#define DEFAULT_ONLYONCEADAY 0
-#define DEFAULT_UPDATEONPERIOD 0
-#define DEFAULT_PERIOD 1
-#define DEFAULT_PERIODMEASURE 1
-#define DEFAULT_FILETYPE 0 //0 - not defined, 1 - pack, 2 - plugin, 3 - icon, 4 - files in miranda root (e.g. langpack, dbtool), 5 - same as 4 without restart
-#define DEFAULT_UPDATE_URL "http://nightly.miranda.im/x32/checksum.txt"
-
-#define IDINFO 3
-#define IDDOWNLOAD 4
-#define IDDOWNLOADALL 5
-
-using std::wstring;
-using namespace std;
-
-extern HINSTANCE hInst;
-extern INT /*CurrentFile,*/ Number, UpdatesCount, Period;
-extern BOOL Silent, DlgDld;
-extern BYTE Reminder, UpdateOnStartup, UpdateOnPeriod, OnlyOnceADay, PeriodMeasure;
-extern TCHAR tszRoot[MAX_PATH], tszDialogMsg[2048];
-extern FILEINFO* pFileInfo;
-//extern FILEURL* pFileUrl;
-extern HANDLE CheckThread, hOnPreShutdown, hOptHook, hLoadHook;
-extern MYOPTIONS MyOptions;
-extern aPopups PopupsList[POPUPS];
-extern HANDLE Timer;
-
-VOID InitPopupList();
-VOID LoadOptions();
-BOOL NetlibInit();
-VOID IcoLibInit();
-VOID NetlibUnInit();
-INT ModulesLoaded(WPARAM wParam, LPARAM lParam);
-INT_PTR MenuCommand(WPARAM wParam,LPARAM lParam);
-INT_PTR EmptyFolder(WPARAM wParam,LPARAM lParam);
-INT OnPreShutdown(WPARAM wParam, LPARAM lParam);
-INT OptInit(WPARAM wParam, LPARAM lParam);
-VOID DoCheck(INT iFlag, INT iFlag2);
-BOOL DownloadFile(LPCTSTR tszURL, LPCTSTR tszLocal);
-VOID show_popup(HWND hDlg, LPCTSTR Title, LPCTSTR Text, INT Number, INT ActType);
-VOID DlgDownloadProc(FILEURL *pFileUrl, PopupDataText temp);
-INT_PTR CALLBACK DlgUpdate(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
-INT_PTR CALLBACK DlgMsgPop(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
-void __stdcall ExitMe(void*);
-void __stdcall RestartMe(void*);
-BOOL AllowUpdateOnStartup();
-VOID InitTimer();
\ No newline at end of file diff --git a/plugins/PackUpdater_new/Src/Events.cpp b/plugins/PackUpdater_new/Src/Events.cpp deleted file mode 100644 index eef80fc3f4..0000000000 --- a/plugins/PackUpdater_new/Src/Events.cpp +++ /dev/null @@ -1,82 +0,0 @@ -/*
-Copyright (C) 2010 Mataes
-
-This is free software; you can redistribute it and/or
-modify it under the terms of the GNU Library General Public
-License as published by the Free Software Foundation; either
-version 2 of the License, or (at your option) any later version.
-
-This 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
-Library General Public License for more details.
-
-You should have received a copy of the GNU Library General Public
-License along with this file; see the file license.txt. If
-not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA.
-*/
-
-#include "common.h"
-
-HANDLE Timer;
-BOOL Silent;
-
-int ModulesLoaded(WPARAM wParam, LPARAM lParam)
-{
- UnhookEvent(hLoadHook);
- Silent = true;
- HOTKEYDESC hkd = {0};
- hkd.cbSize = sizeof(hkd);
- hkd.dwFlags = HKD_TCHAR;
- hkd.pszName = "Check for pack updates";
- hkd.ptszDescription = _T("Check for pack updates");
- hkd.ptszSection = _T("Pack Updater");
- hkd.pszService = MODNAME"/CheckUpdates";
- hkd.DefHotKey = HOTKEYCODE(HOTKEYF_CONTROL, VK_F10) | HKF_MIRANDA_LOCAL;
- hkd.lParam = FALSE;
- Hotkey_Register(&hkd);
-
- if (AllowUpdateOnStartup())
- DoCheck(UpdateOnStartup, (int)CheckThread);
-
- Timer = CreateWaitableTimer(NULL, FALSE, NULL);
- InitTimer();
-
- return 0;
-}
-
-INT_PTR MenuCommand(WPARAM wParam,LPARAM lParam)
-{
- Silent = false;
- DoCheck(1, (int)CheckThread);
- return 0;
-}
-
-INT_PTR EmptyFolder(WPARAM wParam,LPARAM lParam)
-{
- SHFILEOPSTRUCT file_op = {
- NULL,
- FO_DELETE,
- tszRoot,
- _T(""),
- FOF_NOERRORUI |
- FOF_SILENT,
- false,
- 0,
- _T("") };
- if (lParam)
- file_op.fFlags |= FOF_NOCONFIRMATION;
- SHFileOperation(&file_op);
- return 0;
-}
-
-INT OnPreShutdown(WPARAM wParam, LPARAM lParam)
-{
- CancelWaitableTimer(Timer);
- CloseHandle(Timer);
-
- UnhookEvent(hOptHook);
- UnhookEvent(hOnPreShutdown);
- return 0;
-}
\ No newline at end of file diff --git a/plugins/PackUpdater_new/Src/Notifications.cpp b/plugins/PackUpdater_new/Src/Notifications.cpp deleted file mode 100644 index d8d6db8839..0000000000 --- a/plugins/PackUpdater_new/Src/Notifications.cpp +++ /dev/null @@ -1,695 +0,0 @@ -/*
-Copyright (C) 2010 Mataes
-
-This is free software; you can redistribute it and/or
-modify it under the terms of the GNU Library General Public
-License as published by the Free Software Foundation; either
-version 2 of the License, or (at your option) any later version.
-
-This 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
-Library General Public License for more details.
-
-You should have received a copy of the GNU Library General Public
-License along with this file; see the file license.txt. If
-not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA.
-*/
-
-#include "common.h"
-
-INT UpdatesCount = 0;
-
-void PopupAction(HWND hWnd, BYTE action)
-{
- switch (action)
- {
- case PCA_CLOSEPOPUP:
- break;
- case PCA_DONOTHING:
- return;
- }//end* switch
- PUDeletePopUp(hWnd);
-}
-
-static INT_PTR CALLBACK PopupDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
-{
- switch (uMsg)
- {
- case UM_POPUPACTION:
- {
- if (HIWORD(wParam) == BN_CLICKED)
- {
- LPMSGPOPUPDATA pmpd = (LPMSGPOPUPDATA)PUGetPluginData(hDlg);
-
- if (pmpd)
- {
- switch (LOWORD(wParam))
- {
- case IDYES:
- {
- if (IsWindow(pmpd->hDialog))
- EndDialog(pmpd->hDialog, LOWORD(wParam));
- PUDeletePopUp(hDlg);
- break;
- }
- case IDNO:
- {
- if (IsWindow(pmpd->hDialog))
- EndDialog(pmpd->hDialog, LOWORD(wParam));
- PUDeletePopUp(hDlg);
- break;
- }
- }
- }
- }
- }
- break;
-
- case UM_FREEPLUGINDATA:
- {
- LPMSGPOPUPDATA pmpd = (LPMSGPOPUPDATA)PUGetPluginData(hDlg);
- if (pmpd > 0)
- mir_free(pmpd);
- return TRUE; //TRUE or FALSE is the same, it gets ignored.
- }
- break;
-
- default:
- break;
- }
- return DefWindowProc(hDlg, uMsg, wParam, lParam);
-}
-
-static INT_PTR CALLBACK PopupDlgProc2(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
-{
- switch (uMsg)
- {
- case WM_COMMAND:
- {
- PopupAction(hDlg, MyOptions.LeftClickAction);
- break;
- }
- case WM_CONTEXTMENU:
- {
- PopupAction(hDlg, MyOptions.RightClickAction);
- break;
- }
- case UM_FREEPLUGINDATA:
- {
- LPMSGPOPUPDATA pmpd = (LPMSGPOPUPDATA)PUGetPluginData(hDlg);
- if (pmpd > 0)
- mir_free(pmpd);
- return TRUE; //TRUE or FALSE is the same, it gets ignored.
- }
- break;
- }
- return DefWindowProc(hDlg, uMsg, wParam, lParam);
-}
-
-static VOID MakePopupAction(POPUPACTION &pa, INT id)
-{
- pa.cbSize = sizeof(POPUPACTION);
- pa.flags = PAF_ENABLED;
- pa.wParam = MAKEWORD(id, BN_CLICKED);
- pa.lParam = 0;
- switch (id)
- {
- case IDYES:
- {
- pa.lchIcon = (HICON)CallService(MS_SKIN2_GETICON, 0, (LPARAM)"btn_ok");
- strncpy_s(pa.lpzTitle, MODNAME"/Yes", SIZEOF(pa.lpzTitle));
- }
- break;
- case IDNO:
- {
- pa.lchIcon = (HICON)CallService(MS_SKIN2_GETICON, 0, (LPARAM)"btn_cancel");
- strncpy_s(pa.lpzTitle, MODNAME"/No", SIZEOF(pa.lpzTitle));
- }
- break;
- }
-}
-
-VOID show_popup(HWND hDlg, LPCTSTR Title, LPCTSTR Text, int Number, int ActType)
-{
- POPUPDATAT_V2 pd;
- LPMSGPOPUPDATA pmpd;
- pmpd = (LPMSGPOPUPDATA)mir_alloc(sizeof(MSGPOPUPDATA));
- if (pmpd)
- {
- ZeroMemory(&pd, sizeof(pd));
- pd.cbSize = sizeof(POPUPDATAT_V2);
- pd.lchContact = NULL; //(HANDLE)wParam;
- pd.lchIcon = LoadSkinnedIcon(PopupsList[Number].Icon);
- lstrcpyn(pd.lptzText, Text, SIZEOF(pd.lptzText));
- lstrcpyn(pd.lptzContactName, Title, SIZEOF(pd.lptzContactName));
- switch (MyOptions.DefColors)
- {
- case byCOLOR_WINDOWS:
- pd.colorBack = GetSysColor(COLOR_BTNFACE);
- pd.colorText = GetSysColor(COLOR_WINDOWTEXT);
- break;
- case byCOLOR_OWN:
- pd.colorBack = PopupsList[Number].colorBack;
- pd.colorText = PopupsList[Number].colorText;
- break;
- case byCOLOR_POPUP:
- pd.colorBack = pd.colorText = 0;
- break;
- }//end* switch
- if (Number == 0 && ActType != 0)
- pd.PluginWindowProc = (WNDPROC)PopupDlgProc;
- else
- pd.PluginWindowProc = (WNDPROC)PopupDlgProc2;
- pd.PluginData = pmpd;
- if (Number == 0)
- pd.iSeconds = -1;
- else
- pd.iSeconds = MyOptions.Timeout;
- pd.hNotification = NULL;
- pd.lpActions = pmpd->pa;
- }
- pmpd->hDialog = hDlg;
- switch (ActType)
- {
- case 0:
- break;
- case 1:
- {
- MakePopupAction(pmpd->pa[pd.actionCount++], IDYES);
- MakePopupAction(pmpd->pa[pd.actionCount++], IDNO);
- }
- break;
- }
-
- CallService(MS_POPUP_ADDPOPUPT, (WPARAM) &pd, APF_NEWDATA);
-}
-
-INT_PTR CALLBACK DlgDownload(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
-{
- switch (message)
- {
- case WM_INITDIALOG:
- SetWindowText(GetDlgItem(hDlg, IDC_LABEL), tszDialogMsg);
- SetWindowLongPtr(GetDlgItem(hDlg, IDC_PB), GWL_STYLE, GetWindowLongPtr(GetDlgItem(hDlg, IDC_PB), GWL_STYLE) | PBS_MARQUEE);
- SendMessage(GetDlgItem(hDlg, IDC_PB), PBM_SETMARQUEE, 1, 50);
- return TRUE;
- }//end* switch
- return FALSE;
-}
-
-INT_PTR CALLBACK DlgDownloadPop(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
-{
- switch (uMsg)
- {
- case WM_INITDIALOG:
- {
- PopupDataText *temp = (PopupDataText*)lParam;
- Number = 3;
- show_popup(hDlg, temp->Title, temp->Text, Number, 0);
- return TRUE;
- } // end* WM_INITDIALOG:
- } // end* switch (uMsg)
- return FALSE;
-}
-
-/*static void __stdcall CreateDownloadDialog(void* param)
-{
- PopupDataText *temp = (PopupDataText*)param;
- if (ServiceExists(MS_POPUP_ADDPOPUPEX) && DBGetContactSettingByte(NULL, "PopUp", "ModuleIsEnabled", 1) && DBGetContactSettingByte(NULL,MODNAME, "Popups3", DEFAULT_POPUP_ENABLED))
- hDlgDld = CreateDialog(hInst, MAKEINTRESOURCE(IDD_POPUPDUMMI), NULL, DlgDownloadPop);
- else if (DBGetContactSettingByte(NULL,MODNAME, "Popups3M", DEFAULT_MESSAGE_ENABLED))
- {
- lstrcpyn(tszDialogMsg, Text, SIZEOF(tszDialogMsg));
- hDlgDld = CreateDialog(hInst, MAKEINTRESOURCE(IDD_DOWNLOAD), NULL, DlgDownload);
- }
-}*/
-
-/*static void __stdcall DestroyDownloadDialog(void*)
-{
- DestroyWindow(hDlgDld);
-}*/
-
-void DlgDownloadProc(FILEURL *pFileUrl, PopupDataText temp)
-{
- HWND hDlgDld = NULL;
- if (ServiceExists(MS_POPUP_ADDPOPUPEX) && DBGetContactSettingByte(NULL, "PopUp", "ModuleIsEnabled", 1) && DBGetContactSettingByte(NULL,MODNAME, "Popups3", DEFAULT_POPUP_ENABLED))
- hDlgDld = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_POPUPDUMMI), NULL, DlgDownloadPop, (LPARAM)&temp);
- else if (DBGetContactSettingByte(NULL,MODNAME, "Popups3M", DEFAULT_MESSAGE_ENABLED))
- {
- lstrcpyn(tszDialogMsg, temp.Text, SIZEOF(tszDialogMsg));
- hDlgDld = CreateDialog(hInst, MAKEINTRESOURCE(IDD_DOWNLOAD), NULL, DlgDownload);
- }
-
- if (!DownloadFile(pFileUrl->tszDownloadURL, pFileUrl->tszDiskPath))
- {
- LPCTSTR Title = TranslateT("Pack Updater");
- LPCTSTR Text = TranslateT("An error occured while downloading the update.");
- if (ServiceExists(MS_POPUP_ADDPOPUPEX) && DBGetContactSettingByte(NULL, "PopUp", "ModuleIsEnabled", 1) && DBGetContactSettingByte(NULL, MODNAME, "Popups1", DEFAULT_POPUP_ENABLED))
- {
- Number = 1;
- show_popup(0, Title, Text, Number, 0);
- }
- else if (DBGetContactSettingByte(NULL, MODNAME, "Popups1M", DEFAULT_MESSAGE_ENABLED))
- MessageBox(NULL, Text, Title, MB_ICONSTOP);
- }
- DestroyWindow(hDlgDld);
- //CallFunctionAsync(DestroyDownloadDialog, 0);
-}
-
-INT_PTR CALLBACK DlgUpdate(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
-{
- HWND hwndList = GetDlgItem(hDlg, IDC_LIST_UPDATES);
-
- switch (message)
- {
- case WM_INITDIALOG:
- {
- TranslateDialogDefault( hDlg );
- SetWindowLongPtr(hDlg, GWLP_USERDATA, 0);
- SendMessage(hwndList, LVM_SETEXTENDEDLISTVIEWSTYLE, 0, LVS_EX_FULLROWSELECT | LVS_EX_CHECKBOXES);
-
- LVCOLUMN lvc = {0};
- // Initialize the LVCOLUMN structure.
- // The mask specifies that the format, width, text, and
- // subitem members of the structure are valid.
- lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
- lvc.fmt = LVCFMT_LEFT;
-
- lvc.iSubItem = 0;
- lvc.pszText = TranslateT("Component Name");
- lvc.cx = 145; // width of column in pixels
- ListView_InsertColumn(hwndList, 0, &lvc);
-
- lvc.iSubItem = 1;
- lvc.pszText = TranslateT("Current Version");
- lvc.cx = 95; // width of column in pixels
- ListView_InsertColumn(hwndList, 1, &lvc);
-
- lvc.iSubItem = 2;
- lvc.pszText = TranslateT("New Version");
- lvc.cx = 82; // width of column in pixels
- ListView_InsertColumn(hwndList, 2, &lvc);
-
- //enumerate plugins, fill in list
- //bool one_enabled = false;
- ListView_DeleteAllItems(hwndList);
-
- LVITEM lvI = {0};
-
- // Some code to create the list-view control.
- // Initialize LVITEM members that are common to all
- // items.
- lvI.mask = LVIF_TEXT | LVIF_PARAM | LVIF_NORECOMPUTE;// | LVIF_IMAGE;
-
- vector<FILEINFO> &todo = *(vector<FILEINFO> *)lParam;
- for (int i = 0; i < (int)todo.size(); ++i)
- {
- lvI.mask = LVIF_TEXT | LVIF_PARAM;// | LVIF_IMAGE;
- lvI.iSubItem = 0;
- lvI.lParam = (LPARAM)&todo[i];
- lvI.pszText = todo[i].tszDescr;
- lvI.iItem = i;
- ListView_InsertItem(hwndList, &lvI);
-
- lvI.mask = LVIF_TEXT;// | LVIF_IMAGE;
-
- lvI.iSubItem = 1;
- //lvI.pszText = todo[i].tszCurVer;
- ListView_SetItem(hwndList, &lvI);
-
- lvI.iSubItem = 2;
- //lvI.pszText = todo[i].tszNewVer;
- ListView_SetItem(hwndList, &lvI);
-
- // remember whether the user has decided not to update this component with this particular new version
- /*char stored_setting[256];
- char* descr = mir_t2a(todo[i].tszDescr);
- mir_snprintf(stored_setting, 256, "DisabledVer%s", descr);
- mir_free(descr);
- DBVARIANT dbv;
- bool check = todo[i].enabled;
- if (!DBGetContactSettingTString(0, MODNAME, stored_setting, &dbv))
- {
- if (dbv.ptszVal && lstrcmp(dbv.ptszVal, todo[i].tszNewVer) == 0)
- check = false;
- else
- DBDeleteContactSetting(0, MODNAME, stored_setting);
- DBFreeVariant(&dbv);
- }
- one_enabled |= check;*/
- ListView_SetCheckState(hwndList, lvI.iItem, true);
- todo[i].enabled = true;
- }
- HWND hwOk = GetDlgItem(hDlg, IDOK);
- EnableWindow(hwOk, true/*one_enabled ? TRUE : FALSE*/);
- // do this after filling list - enables 'ITEMCHANGED' below
- SetWindowLongPtr(hDlg, GWLP_USERDATA, lParam);
- Utils_RestoreWindowPositionNoSize(hDlg,0,MODNAME,"ConfirmWindow");
- //if (!IsUserAnAdmin())
- //SendDlgItemMessage(hDlg, IDOK, BCM_SETSHIELD, 0, TRUE);
- return TRUE;
- }
- case WM_NOTIFY:
- {
- if (((LPNMHDR) lParam)->hwndFrom == hwndList)
- {
- switch (((LPNMHDR) lParam)->code)
- {
- case LVN_ITEMCHANGED:
- {
- if (GetWindowLongPtr(hDlg, GWLP_USERDATA))
- {
- NMLISTVIEW *nmlv = (NMLISTVIEW *)lParam;
-
- LVITEM lvI = {0};
-
- lvI.iItem = nmlv->iItem;
- lvI.iSubItem = 0;
- lvI.mask = LVIF_PARAM;
- ListView_GetItem(hwndList, &lvI);
-
- vector<FILEINFO> &todo = *(vector<FILEINFO> *)GetWindowLongPtr(hDlg, GWLP_USERDATA);
- if ((nmlv->uNewState ^ nmlv->uOldState) & LVIS_STATEIMAGEMASK)
- {
- todo[lvI.iItem].enabled = ListView_GetCheckState(hwndList, nmlv->iItem);
-
- /*char stored_setting[256];
- mir_snprintf(stored_setting, 256, "DisabledVer%s", ((UpdateInternal *)lvI.lParam)->update.szComponentName);
-
- if (((UpdateInternal *)lvI.lParam)->update_options.enabled)
- DBDeleteContactSetting(0, "Updater", stored_setting); // user has re-enabled update to this version - remove setting from db
- else
- DBWriteContactSettingString(0, "Updater", stored_setting, ((UpdateInternal *)lvI.lParam)->newVersion);
- //ListView_SetItem(hwndList, &lvI);
- */
-
- bool enableOk = false;
- for(int i=0; i<(int)todo.size(); ++i)
- {
- if(todo[i].enabled)
- {
- enableOk = true;
- break;
- }
- }
- HWND hwOk = GetDlgItem(hDlg, IDOK);
- EnableWindow(hwOk, enableOk ? TRUE : FALSE);
- }
- if (nmlv->uNewState & LVIS_SELECTED)
- {
- if (lstrcmp(todo[lvI.iItem].tszInfoURL, _T("")))
- EnableWindow(GetDlgItem(hDlg, IDC_INFO), TRUE);
- else
- EnableWindow(GetDlgItem(hDlg, IDC_INFO), FALSE);
- SetDlgItemText(hDlg, IDC_MESSAGE, TranslateTS(todo[lvI.iItem].tszMessage));
- /*char stored_setting[256];
- char* descr = mir_t2a(todo[lvI.iItem].tszDescr);
- mir_snprintf(stored_setting, 256, "DisabledVer%s", descr);
- mir_free(descr);
- DBVARIANT dbv;
- if (!DBGetContactSettingTString(0, MODNAME, stored_setting, &dbv))
- {
- if(dbv.ptszVal && lstrcmp(dbv.ptszVal, todo[lvI.iItem].tszNewVer) == 0)
- CheckDlgButton(hDlg, IDC_DONOTREMIND, BST_CHECKED);
- else
- DBDeleteContactSetting(0, MODNAME, stored_setting);
- DBFreeVariant(&dbv);
- }
- else
- CheckDlgButton(hDlg, IDC_DONOTREMIND, BST_UNCHECKED);
- */
-
- }
- }
- break;
- }
- }
- }
- break;
- }
- case WM_COMMAND:
- {
- if (HIWORD( wParam ) == BN_CLICKED)
- {
- switch(LOWORD(wParam))
- {
- case IDOK:
- {
- vector<FILEINFO> &todo = *(vector<FILEINFO> *)GetWindowLongPtr(hDlg, GWLP_USERDATA);
- ShowWindow(hDlg, SW_HIDE);
- TCHAR tszBuff[2048] = {0}, tszFileDest[MAX_PATH] = {0}, tszFilePathDest[MAX_PATH] = {0}, tszFilePathBack[MAX_PATH] = {0}, tszFileName[MAX_PATH] = {0};
- TCHAR* tszExt = NULL;
- char szKey[64] = {0};
- vector<int> arFileType;
- vector<tString> arFilePath;
- vector<tString> arFileName;
- vector<tString> arAdvFolder;
- vector<tString> arExt;
- STARTUPINFO si;
- PROCESS_INFORMATION pi;
-
- SetWindowLongPtr(hDlg, GWLP_USERDATA, 0);
- Utils_SaveWindowPosition(hDlg, NULL, MODNAME, "ConfirmWindow");
- /*DBWriteContactSettingByte(NULL, "Updater", "DefaultConfAll", IsDlgButtonChecked(hwndDlg, IDC_CHK_CONFALL) ? 1 : 0);
- DBWriteContactSettingByte(NULL, "Updater", "NoInstall", IsDlgButtonChecked(hwndDlg, IDC_CHK_NOINSTALL) ? 1 : 0);
-
- if (IsDlgButtonChecked(hDlg, IDC_CHK_CONFALL))
- EndDialog(hDlg, CD_CONFALL);
- else if (IsDlgButtonChecked(hDlg, IDC_CHK_NOINSTALL))
- EndDialog(hDlg, CD_NOINSTALL);
- else
- */
-
- arFileType.clear();
- arFilePath.clear();
- arFileName.clear();
- arAdvFolder.clear();
- arExt.clear();
- for(int i=0; i<(int)todo.size(); ++i)
- {
- if(todo[i].enabled)
- {
- switch (todo[i].FileType)
- {
- case 1:
- mir_sntprintf(tszFileDest, SIZEOF(tszFileDest), _T("%s\\Pack"), tszRoot);
- CreateDirectory(tszFileDest, NULL);
- break;
- case 2:
- mir_sntprintf(tszFileDest, SIZEOF(tszFileDest), _T("%s\\Plugins"), tszRoot);
- CreateDirectory(tszFileDest, NULL);
- break;
- case 3:
- mir_sntprintf(tszFileDest, SIZEOF(tszFileDest), _T("%s\\Icons"), tszRoot);
- CreateDirectory(tszFileDest, NULL);
- break;
- case 4:
- mir_sntprintf(tszFileDest, SIZEOF(tszFileDest), _T("%s\\Others"), tszRoot);
- CreateDirectory(tszFileDest, NULL);
- break;
- case 5:
- mir_sntprintf(tszFileDest, SIZEOF(tszFileDest), _T("%s\\Others"), tszRoot);
- CreateDirectory(tszFileDest, NULL);
- break;
- default:
- lstrcpyn(tszFileDest, tszRoot, SIZEOF(tszFileDest));
- break;
- }//end * switch (todo[i].FileType)
- mir_sntprintf(tszBuff, SIZEOF(tszBuff), _T("%s\\Backups"), tszRoot);
- CreateDirectory(tszBuff, NULL);
- lstrcpyn(tszFileName, todo[i].File.tszDiskPath, SIZEOF(tszFileName));
- mir_sntprintf(todo[i].File.tszDiskPath, SIZEOF(todo[i].File.tszDiskPath), _T("%s\\%s"), tszFileDest, tszFileName);
- UpdatesCount++;
-
- tszExt = &todo[i].File.tszDownloadURL[lstrlen(todo[i].File.tszDownloadURL)-5];
- if (lstrcmp(tszExt, _T(".html")) == 0)
- {
- char* szUrl = mir_t2a(todo[i].File.tszDownloadURL);
- CallService(MS_UTILS_OPENURL, TRUE, (LPARAM)szUrl);
- mir_free(szUrl);
- }
- else
- {
- // download update
- FILEURL *pFileUrl = &todo[i].File;
- PopupDataText temp;
- temp.Title = TranslateT("Pack Updater");
- if (todo[i].FileType == 1)
- temp.Text = TranslateT("Downloading pack updates...");
- else
- temp.Text = TranslateT("Downloading update...");
- DlgDownloadProc(pFileUrl, temp);
- if (!DlgDld)
- {
- if (UpdatesCount)
- UpdatesCount--;
- continue;
- }
- }
- // Save last version
- //перенести сюда
- //DBWriteContactSettingTString(NULL, MODNAME, _T2A(ffd.cFileName), todo[i].newhash);
-
- //lstrcpyn(todo[i].tszCurVer, todo[i].tszNewVer, SIZEOF(todo[i].tszCurVer));
- //mir_snprintf(szKey, SIZEOF(szKey), "File_%d_CurrentVersion", todo[i].FileNum);
- //DBWriteContactSettingTString(NULL, MODNAME, szKey, todo[i].tszCurVer);
- arFileType.push_back(todo[i].FileType);
- arFilePath.push_back(todo[i].File.tszDiskPath);
- arFileName.push_back(tszFileName);
- arAdvFolder.push_back(todo[i].tszAdvFolder);
- arExt.push_back(tszExt);
- if (todo[i].FileType == 1)
- i = (int)todo.size();
- }
- }
-
- if (UpdatesCount > 1 && lstrcmp(arExt[0].c_str(), _T(".html")) != 0)
- lstrcpyn(tszBuff, TranslateT("Downloads complete. Start updating? All your data will be saved and Miranda IM will be closed."), SIZEOF(tszBuff));
- else if (UpdatesCount == 1 && lstrcmp(arExt[0].c_str(), _T(".html")) != 0)
- lstrcpyn(tszBuff, TranslateT("Download complete. Start updating? All your data will be saved and Miranda IM will be closed."), SIZEOF(tszBuff));
- if (UpdatesCount > 0 && lstrcmp(arExt[0].c_str(), _T(".html")) != 0)
- {
- INT rc = -1;
- PopupDataText temp;
- temp.Title = TranslateT("Pack Updater");
- temp.Text = tszBuff;
- if (ServiceExists(MS_POPUP_ADDPOPUPEX) && ServiceExists(MS_POPUP_REGISTERACTIONS) && DBGetContactSettingByte(NULL, "PopUp", "ModuleIsEnabled", 1) && DBGetContactSettingByte(NULL,MODNAME, "Popups0", DEFAULT_POPUP_ENABLED) && (DBGetContactSettingDword(NULL, "PopUp", "Actions", 0) & 1))
- rc = DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_POPUPDUMMI), NULL, DlgMsgPop, (LPARAM)&temp);
- else
- rc = MessageBox(NULL, temp.Text, temp.Title, MB_YESNO | MB_ICONQUESTION);
- if (rc == IDYES)
- {
- for (int i = 0; i < UpdatesCount; i++)
- {
- TCHAR* tszUtilRootPlug = NULL;
- TCHAR* tszUtilRootIco = NULL;
- TCHAR* tszUtilRoot = NULL;
-
- switch (arFileType[i])
- {
- case 0:
- break;
- case 1:
- if (Reminder == 2)
- DBWriteContactSettingByte(NULL, MODNAME, "Reminder", 1);
- memset(&si, 0, sizeof(STARTUPINFO));
- memset(&pi, 0, sizeof(PROCESS_INFORMATION));
- si.cb = sizeof(STARTUPINFO);
- CreateProcess(arFilePath[i].c_str(), _T(""), NULL, NULL, FALSE, NULL, NULL, NULL, &si, &pi);
- i = UpdatesCount;
- CallFunctionAsync(ExitMe, 0);
- break;
- case 2:
- tszUtilRootPlug = Utils_ReplaceVarsT(_T("%miranda_path%\\Plugins"));
- if (lstrcmp(arAdvFolder[i].c_str(), _T("")) == 0)
- mir_sntprintf(tszFilePathDest, SIZEOF(tszFilePathDest), _T("%s\\%s"), tszUtilRootPlug, arFileName[i].c_str());
- else
- mir_sntprintf(tszFilePathDest, SIZEOF(tszFilePathDest), _T("%s\\%s\\%s"), tszUtilRootPlug, arAdvFolder[i].c_str(), arFileName[i].c_str());
- mir_sntprintf(tszFilePathBack, SIZEOF(tszFilePathBack), _T("%s\\Backups\\%s"), tszRoot, arFileName[i].c_str());
- MoveFile(tszFilePathDest, tszFilePathBack);
- MoveFile(arFilePath[i].c_str(), tszFilePathDest);
- mir_free(tszUtilRootPlug);
- if (i == UpdatesCount - 1)
- CallFunctionAsync(RestartMe, 0);
- break;
- case 3:
- tszUtilRootIco = Utils_ReplaceVarsT(_T("%miranda_path%\\Icons"));
- if (lstrcmp(arAdvFolder[i].c_str(), _T("")) == 0)
- mir_sntprintf(tszFilePathDest, SIZEOF(tszFilePathDest), _T("%s\\%s"), tszUtilRootIco, arFileName[i].c_str());
- else
- mir_sntprintf(tszFilePathDest, SIZEOF(tszFilePathDest), _T("%s\\%s\\%s"), tszUtilRootIco, arAdvFolder[i].c_str(), arFileName[i].c_str());
- mir_sntprintf(tszFilePathBack, SIZEOF(tszFilePathBack), _T("%s\\Backups\\%s"), tszRoot, arFileName[i].c_str());
- MoveFile(tszFilePathDest, tszFilePathBack);
- MoveFile(arFilePath[i].c_str(), tszFilePathDest);
- mir_free(tszUtilRootIco);
- if (i == UpdatesCount - 1)
- CallFunctionAsync(RestartMe, 0);
- break;
- case 4:
- tszUtilRoot = Utils_ReplaceVarsT(_T("%miranda_path%"));
- if (lstrcmp(arAdvFolder[i].c_str(), _T("")) == 0)
- mir_sntprintf(tszFilePathDest, SIZEOF(tszFilePathDest), _T("%s\\%s"), tszUtilRoot, arFileName[i].c_str());
- else
- mir_sntprintf(tszFilePathDest, SIZEOF(tszFilePathDest), _T("%s\\%s\\%s"), tszUtilRoot, arAdvFolder[i].c_str(), arFileName[i].c_str());
- mir_sntprintf(tszFilePathBack, SIZEOF(tszFilePathBack), _T("%s\\Backups\\%s"), tszRoot, arFileName[i].c_str());
- MoveFile(tszFilePathDest, tszFilePathBack);
- MoveFile(arFilePath[i].c_str(), tszFilePathDest);
- mir_free(tszUtilRoot);
- if (i == UpdatesCount - 1)
- CallFunctionAsync(RestartMe, 0);
- break;
- case 5:
- tszUtilRoot = Utils_ReplaceVarsT(_T("%miranda_path%"));
- if (lstrcmp(arAdvFolder[i].c_str(), _T("")) == 0)
- mir_sntprintf(tszFilePathDest, SIZEOF(tszFilePathDest), _T("%s\\%s"), tszUtilRoot, arFileName[i].c_str());
- else
- mir_sntprintf(tszFilePathDest, SIZEOF(tszFilePathDest), _T("%s\\%s\\%s"), tszUtilRoot, arAdvFolder[i].c_str(), arFileName[i].c_str());
- mir_sntprintf(tszFilePathBack, SIZEOF(tszFilePathBack), _T("%s\\Backups\\%s"), tszRoot, arFileName[i].c_str());
- MoveFile(tszFilePathDest, tszFilePathBack);
- MoveFile(arFilePath[i].c_str(), tszFilePathDest);
- mir_free(tszUtilRoot);
- break;
- }//end* switch (arFileType[i])
- }//end* for (int i = 0; i < UpdatesCount; i++)
- }//end* if (IDYES == MessageBox(NULL, tszBuff, Title, MB_YESNO | MB_ICONQUESTION))
- else
- {//reminder for not installed pack update
- if (Reminder && (UpdatesCount == 1) && (arFileType[0] == 1))
- DBWriteContactSettingByte(NULL, MODNAME, "Reminder", 2);
- mir_sntprintf(tszBuff, SIZEOF(tszBuff), TranslateT("You have chosen not to install the pack update immediately.\nYou can install it manually from this location:\n\n%s"), arFilePath[0].c_str());
- LPCTSTR Title = TranslateT("Pack Updater");
- LPCTSTR Text = tszBuff;
- if (ServiceExists(MS_POPUP_ADDPOPUPEX) && DBGetContactSettingByte(NULL, "PopUp", "ModuleIsEnabled", 1) && DBGetContactSettingByte(NULL, MODNAME, "Popups2", DEFAULT_POPUP_ENABLED))
- {
- Number = 2;
- show_popup(0, Title, Text, Number, 0);
- }
- else if (DBGetContactSettingByte(NULL, MODNAME, "Popups2M", DEFAULT_MESSAGE_ENABLED))
- MessageBox(NULL, Text, Title, MB_ICONINFORMATION);
- }
- }//end* if (UpdatesCount > 0)
-
- EndDialog(hDlg, IDOK);
- return TRUE;
- }
- case IDCANCEL:
- {
- SetWindowLongPtr(hDlg, GWLP_USERDATA, 0);
- Utils_SaveWindowPosition(hDlg, NULL, MODNAME, "ConfirmWindow");
- EndDialog(hDlg, IDCANCEL);
- return TRUE;
- }
- case IDC_INFO:
- {
- int sel = ListView_GetSelectionMark(hwndList);
- vector<FILEINFO> &todo = *(vector<FILEINFO> *)GetWindowLongPtr(hDlg, GWLP_USERDATA);
- char* szUrl = mir_t2a(todo[sel].tszInfoURL);
- CallService(MS_UTILS_OPENURL, TRUE, (LPARAM)szUrl);
- mir_free(szUrl);
- break;
- }
- }
- }
- break;
- }
- }
- return FALSE;
-}
-
-INT_PTR CALLBACK DlgMsgPop(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
-{
- switch (uMsg)
- {
- case WM_INITDIALOG:
- {
- PopupDataText *temp = (PopupDataText*)lParam;
- Number = 0;
- show_popup(hDlg, temp->Title, temp->Text, Number, 1);
- return TRUE;
- } // end* WM_INITDIALOG:
- } // end* switch (uMsg)
- ShowWindow(hDlg, SW_HIDE);
- return FALSE;
-}
\ No newline at end of file diff --git a/plugins/PackUpdater_new/Src/Notifications.h b/plugins/PackUpdater_new/Src/Notifications.h deleted file mode 100644 index 09bc77a810..0000000000 --- a/plugins/PackUpdater_new/Src/Notifications.h +++ /dev/null @@ -1,72 +0,0 @@ -/*
-Copyright (C) 2010 Mataes
-
-This is free software; you can redistribute it and/or
-modify it under the terms of the GNU Library General Public
-License as published by the Free Software Foundation; either
-version 2 of the License, or (at your option) any later version.
-
-This 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
-Library General Public License for more details.
-
-You should have received a copy of the GNU Library General Public
-License along with this file; see the file license.txt. If
-not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA.
-*/
-
-#define POPUPS 4
-
-//=== Objects =====
-//This one is used to easily tie status id, icon, text...
-typedef struct
-{
- int ID;
- int Icon;
- COLORREF colorBack;
- COLORREF colorText;
-} aPopups;
-
-typedef struct _MSGPOPUPDATA
-{
- POPUPACTION pa[4];
- HWND hDialog;
-}
-MSGPOPUPDATA, *LPMSGPOPUPDATA;
-
-#define DEFAULT_POPUP_LCLICK 1
-#define DEFAULT_POPUP_RCLICK 0
-#define DEFAULT_POPUP_ENABLED 1
-#define DEFAULT_MESSAGE_ENABLED 1
-#define DEFAULT_TIMEOUT_VALUE 0
-
-#define COLOR_BG_FIRSTDEFAULT RGB(173,206,247)
-#define COLOR_BG_SECONDDEFAULT RGB(255,189,189)
-#define COLOR_TX_DEFAULT RGB(0,0,0)
-
-#define byCOLOR_OWN 0x1
-#define byCOLOR_WINDOWS 0x2
-#define byCOLOR_POPUP 0x3
-#define DEFAULT_COLORS byCOLOR_POPUP
-
-// Actions on popup click
-#define PCA_CLOSEPOPUP 0 // close popup
-#define PCA_DONOTHING 1 // do nothing
-
-//===== Options flags
-typedef struct tagMYOPTIONS {
- BYTE DefColors;
- BYTE LeftClickAction;
- BYTE RightClickAction;
- int Timeout;
-} MYOPTIONS;
-
-static struct {
- TCHAR *Text;
- int Action;
-} PopupActions[] = {
- _T("Close popup"), PCA_CLOSEPOPUP,
- _T("Do nothing"), PCA_DONOTHING
-};
diff --git a/plugins/PackUpdater_new/Src/Options.cpp b/plugins/PackUpdater_new/Src/Options.cpp deleted file mode 100644 index 5b0be1b730..0000000000 --- a/plugins/PackUpdater_new/Src/Options.cpp +++ /dev/null @@ -1,493 +0,0 @@ -/*
-Copyright (C) 2010 Mataes
-
-This is free software; you can redistribute it and/or
-modify it under the terms of the GNU Library General Public
-License as published by the Free Software Foundation; either
-version 2 of the License, or (at your option) any later version.
-
-This 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
-Library General Public License for more details.
-
-You should have received a copy of the GNU Library General Public
-License along with this file; see the file license.txt. If
-not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA.
-*/
-
-#include "common.h"
-
-WNDPROC g_pOldProc;
-
-LRESULT CALLBACK MyEditProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
-{
- switch (message)
- {
- case WM_KEYDOWN:
- SendMessage(GetParent(GetParent(hwnd)), PSM_CHANGED, 0, 0);
- break;
- }
- return CallWindowProc (g_pOldProc, hwnd, message, wParam, lParam);
-}
-
-INT_PTR CALLBACK UpdateNotifyOptsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
-{
- WORD i = 0;
- char str[20] = {0};
- switch (msg)
- {
- case WM_INITDIALOG:
- {
- TranslateDialogDefault(hwndDlg);
- CheckDlgButton(hwndDlg, IDC_UPDATEONSTARTUP, (int)UpdateOnStartup);
- CheckDlgButton(hwndDlg, IDC_ONLYONCEADAY, (int)OnlyOnceADay);
- EnableWindow(GetDlgItem(hwndDlg, IDC_ONLYONCEADAY), UpdateOnStartup);
- CheckDlgButton(hwndDlg, IDC_UPDATEONPERIOD, (int)UpdateOnPeriod);
- EnableWindow(GetDlgItem(hwndDlg, IDC_PERIOD), UpdateOnPeriod);
- EnableWindow(GetDlgItem(hwndDlg, IDC_PERIODSPIN), UpdateOnPeriod);
- EnableWindow(GetDlgItem(hwndDlg, IDC_PERIODMEASURE), UpdateOnPeriod);
-
- SendDlgItemMessage(hwndDlg, IDC_PERIODSPIN, UDM_SETRANGE, 0, MAKELONG(99, 1));
- SendDlgItemMessage(hwndDlg, IDC_PERIODSPIN, UDM_SETPOS, 0, (LPARAM)Period);
-
- Edit_LimitText(GetDlgItem(hwndDlg, IDC_PERIOD), 2);
- g_pOldProc = (WNDPROC)SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_PERIOD), GWLP_WNDPROC, (LONG)MyEditProc);
-
- ComboBox_InsertString(GetDlgItem(hwndDlg, IDC_PERIODMEASURE), 0, TranslateT("hours"));
- ComboBox_InsertString(GetDlgItem(hwndDlg, IDC_PERIODMEASURE), 1, TranslateT("days"));
- ComboBox_SetCurSel(GetDlgItem(hwndDlg, IDC_PERIODMEASURE), PeriodMeasure);
-
- CheckDlgButton(hwndDlg, IDC_REMINDER, (int)Reminder);
- if (ServiceExists(MS_POPUP_ADDPOPUP))
- {
- ShowWindow(GetDlgItem(hwndDlg, IDC_NOTIFY2), SW_HIDE);
- ShowWindow(GetDlgItem(hwndDlg, IDC_MSG_BOXES2), SW_HIDE);
- ShowWindow(GetDlgItem(hwndDlg, IDC_ERRORS2), SW_HIDE);
- ShowWindow(GetDlgItem(hwndDlg, IDC_INFO_MESSAGES2), SW_HIDE);
- ShowWindow(GetDlgItem(hwndDlg, IDC_PROGR_DLG2), SW_HIDE);
- }
- else
- {
- for (i = 1; i < POPUPS; i++)
- {
- mir_snprintf(str, SIZEOF(str), "Popups%dM", i);
- CheckDlgButton(hwndDlg, (i+1029), (DBGetContactSettingByte(NULL, MODNAME, str, DEFAULT_MESSAGE_ENABLED)) ? BST_CHECKED: BST_UNCHECKED);
- }
- }
- DBVARIANT dbVar = {0};
- if (!DBGetContactSettingTString(NULL, MODNAME, "UpdateURL", &dbVar))
- SetDlgItemText(hwndDlg, IDC_UPDATE_URL, dbVar.ptszVal);
- else
- {
- SetDlgItemText(hwndDlg, IDC_UPDATE_URL, _T(DEFAULT_UPDATE_URL));
- DBWriteContactSettingTString(NULL, MODNAME, "UpdateURL", _T(DEFAULT_UPDATE_URL));
- }
- DBFreeVariant(&dbVar);
- return TRUE;
- }
-
- case WM_COMMAND:
- {
- switch (LOWORD(wParam))
- {
- case IDC_UPDATEONSTARTUP:
- {
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- EnableWindow(GetDlgItem(hwndDlg, IDC_ONLYONCEADAY), IsDlgButtonChecked(hwndDlg, IDC_UPDATEONSTARTUP));
- }
- break;
- case IDC_ONLYONCEADAY:
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- break;
- case IDC_UPDATEONPERIOD:
- {
- BOOL value = IsDlgButtonChecked(hwndDlg, IDC_UPDATEONPERIOD);
- EnableWindow(GetDlgItem(hwndDlg, IDC_PERIOD), value);
- EnableWindow(GetDlgItem(hwndDlg, IDC_PERIODSPIN), value);
- EnableWindow(GetDlgItem(hwndDlg, IDC_PERIODMEASURE), value);
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- }
- break;
- case IDC_PERIODMEASURE:
- if (HIWORD(wParam) == CBN_SELCHANGE)
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- break;
- case IDC_REMINDER:
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- break;
- case IDC_LINK_HOTKEY:
- {
- OPENOPTIONSDIALOG ood = {0};
- ood.cbSize = sizeof(ood);
- ood.pszGroup = "Customize";
- ood.pszPage = "Hotkeys";
- CallService( MS_OPT_OPENOPTIONS, 0, (LPARAM)&ood );
- return (true);
- }
- case IDC_MSG_BOXES2:
- case IDC_ERRORS2:
- case IDC_INFO_MESSAGES2:
- case IDC_PROGR_DLG2:
- case IDC_UPDATE_URL:
- if ((HIWORD(wParam) == BN_CLICKED || HIWORD(wParam) == EN_CHANGE) && (HWND)lParam == GetFocus())
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- break;
- }
- break;
- }
- case WM_NOTIFY:
- {
- NMHDR *hdr = (NMHDR *)lParam;
- if(hdr && hdr->code == UDN_DELTAPOS)
- {
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- }
- if (hdr && hdr->code == PSN_APPLY)
- {
- UpdateOnStartup = IsDlgButtonChecked(hwndDlg, IDC_UPDATEONSTARTUP);
- OnlyOnceADay = IsDlgButtonChecked(hwndDlg, IDC_ONLYONCEADAY);
-
- UpdateOnPeriod = IsDlgButtonChecked(hwndDlg, IDC_UPDATEONPERIOD);
-
- char buffer[3] = {0};
- Edit_GetText(GetDlgItem(hwndDlg, IDC_PERIOD), (LPWSTR)&buffer, 2);
- Period = atoi(buffer);
-
- PeriodMeasure = ComboBox_GetCurSel(GetDlgItem(hwndDlg, IDC_PERIODMEASURE));
-
- InitTimer();
-
- DBWriteContactSettingByte(NULL, MODNAME, "UpdateOnStartup", UpdateOnStartup);
- DBWriteContactSettingByte(NULL, MODNAME, "OnlyOnceADay", OnlyOnceADay);
- DBWriteContactSettingByte(NULL, MODNAME, "UpdateOnPeriod", UpdateOnPeriod);
- DBWriteContactSettingDword(NULL, MODNAME, "Period", Period);
- DBWriteContactSettingByte(NULL, MODNAME, "PeriodMeasure", PeriodMeasure);
- Reminder = IsDlgButtonChecked(hwndDlg, IDC_REMINDER);
- DBWriteContactSettingByte(NULL, MODNAME, "Reminder", Reminder);
- if (!ServiceExists(MS_POPUP_ADDPOPUP))
- {
- for (i = 1; i < POPUPS; i++)
- {
- mir_snprintf(str, SIZEOF(str), "Popups%dM", i);
- DBWriteContactSettingByte(NULL, MODNAME, str, (BYTE)(IsDlgButtonChecked(hwndDlg, (i+1029))));
- }
- }
- TCHAR buf[MAX_PATH];
- GetDlgItemText(hwndDlg, IDC_UPDATE_URL, buf, SIZEOF(buf));
- DBWriteContactSettingTString(NULL, MODNAME, "UpdateURL", buf);
- }
- break;
- }
- }//end* switch (msg)
- return FALSE;
-}
-
-INT_PTR CALLBACK DlgPopUpOpts(HWND hdlg, UINT msg, WPARAM wParam, LPARAM lParam)
-{
- WORD i = 0;
- char str[20] = {0}, str2[20] = {0};
-
- switch (msg)
- {
- case WM_INITDIALOG:
- {
- TranslateDialogDefault(hdlg);
- //Colors
- if (MyOptions.DefColors == byCOLOR_OWN)
- {
- CheckDlgButton(hdlg, IDC_USEOWNCOLORS, BST_CHECKED);
- CheckDlgButton(hdlg, IDC_USEPOPUPCOLORS, BST_UNCHECKED);
- CheckDlgButton(hdlg, IDC_USEWINCOLORS, BST_UNCHECKED);
- }
- if (MyOptions.DefColors == byCOLOR_WINDOWS)
- {
- CheckDlgButton(hdlg, IDC_USEOWNCOLORS, BST_UNCHECKED);
- CheckDlgButton(hdlg, IDC_USEPOPUPCOLORS, BST_UNCHECKED);
- CheckDlgButton(hdlg, IDC_USEWINCOLORS, BST_CHECKED);
- }
- if (MyOptions.DefColors == byCOLOR_POPUP)
- {
- CheckDlgButton(hdlg, IDC_USEOWNCOLORS, BST_UNCHECKED);
- CheckDlgButton(hdlg, IDC_USEPOPUPCOLORS, BST_CHECKED);
- CheckDlgButton(hdlg, IDC_USEWINCOLORS, BST_UNCHECKED);
- }
- SendDlgItemMessage(hdlg, (42071), CPM_SETCOLOUR, 0, PopupsList[0].colorBack);
- SendDlgItemMessage(hdlg, (41071), CPM_SETCOLOUR, 0, PopupsList[0].colorText);
- for (i = 1; i < POPUPS; i++)
- {
- SendDlgItemMessage(hdlg, (i+42071), CPM_SETCOLOUR, 0, PopupsList[i].colorBack);
- SendDlgItemMessage(hdlg, (i+41071), CPM_SETCOLOUR, 0, PopupsList[i].colorText);
- EnableWindow(GetDlgItem(hdlg, (i+42071)), (MyOptions.DefColors == byCOLOR_OWN));
- EnableWindow(GetDlgItem(hdlg, (i+41071)), (MyOptions.DefColors == byCOLOR_OWN));
- }
- //Timeout
- SendDlgItemMessage(hdlg, IDC_TIMEOUT_VALUE, EM_LIMITTEXT, 4, 0);
- SendDlgItemMessage(hdlg, IDC_TIMEOUT_VALUE_SPIN, UDM_SETRANGE32, -1, 9999);
- SetDlgItemInt(hdlg, IDC_TIMEOUT_VALUE, MyOptions.Timeout, TRUE);
- //Mouse actions
- for (i = 0; i < SIZEOF(PopupActions); i++)
- {
- SendMessage(GetDlgItem(hdlg, IDC_LC), CB_SETITEMDATA, SendMessage(GetDlgItem(hdlg, IDC_LC), CB_ADDSTRING, 0, (LPARAM)TranslateTS(PopupActions[i].Text)), PopupActions[i].Action);
- SendMessage(GetDlgItem(hdlg, IDC_RC), CB_SETITEMDATA, SendMessage(GetDlgItem(hdlg, IDC_RC), CB_ADDSTRING, 0, (LPARAM)TranslateTS(PopupActions[i].Text)), PopupActions[i].Action);
- }
- SendDlgItemMessage(hdlg, IDC_LC, CB_SETCURSEL, MyOptions.LeftClickAction, 0);
- SendDlgItemMessage(hdlg, IDC_RC, CB_SETCURSEL, MyOptions.RightClickAction, 0);
- //Popups nitified
- for (i = 0; i < POPUPS; i++)
- {
- mir_snprintf(str, SIZEOF(str), "Popups%d", i);
- mir_snprintf(str2, SIZEOF(str2), "Popups%dM", i);
- CheckDlgButton(hdlg, (i+40071), (DBGetContactSettingByte(NULL, MODNAME, str, DEFAULT_POPUP_ENABLED)) ? BST_CHECKED: BST_UNCHECKED);
- CheckDlgButton(hdlg, (i+1024), (DBGetContactSettingByte(NULL, MODNAME, str2, DEFAULT_MESSAGE_ENABLED)) ? BST_CHECKED: BST_UNCHECKED);
- if (IsDlgButtonChecked(hdlg, (i+40071)))
- EnableWindow(GetDlgItem(hdlg, (i+1024)), FALSE);
- else if (i > 0)
- EnableWindow(GetDlgItem(hdlg, (i+1024)), TRUE);
- }
- if (!(DBGetContactSettingDword(NULL, "PopUp", "Actions", 0) & 1) || !ServiceExists(MS_POPUP_REGISTERACTIONS))
- {
- EnableWindow(GetDlgItem(hdlg, (40071)), FALSE);
- EnableWindow(GetDlgItem(hdlg, (41071)), FALSE);
- EnableWindow(GetDlgItem(hdlg, (42071)), FALSE);
- }
- else
- {
- EnableWindow(GetDlgItem(hdlg, (40071)), TRUE);
- EnableWindow(GetDlgItem(hdlg, (41071)), (MyOptions.DefColors == byCOLOR_OWN));
- EnableWindow(GetDlgItem(hdlg, (42071)), (MyOptions.DefColors == byCOLOR_OWN));
- }
- return TRUE;
- }
- case WM_SHOWWINDOW:
- if (!(DBGetContactSettingDword(NULL, "PopUp", "Actions", 0) & 1) || !ServiceExists(MS_POPUP_REGISTERACTIONS))
- {
- EnableWindow(GetDlgItem(hdlg, (40071)), FALSE);
- EnableWindow(GetDlgItem(hdlg, (41071)), FALSE);
- EnableWindow(GetDlgItem(hdlg, (42071)), FALSE);
- }
- else
- {
- EnableWindow(GetDlgItem(hdlg, (40071)), TRUE);
- EnableWindow(GetDlgItem(hdlg, (41071)), (MyOptions.DefColors == byCOLOR_OWN));
- EnableWindow(GetDlgItem(hdlg, (42071)), (MyOptions.DefColors == byCOLOR_OWN));
- }
- return TRUE;
- case WM_COMMAND:
- {
- WORD idCtrl = LOWORD(wParam), wNotifyCode = HIWORD(wParam);
- if (wNotifyCode == CPN_COLOURCHANGED)
- {
- if(idCtrl > 40070)
- {
- //It's a color picker change. idCtrl is the control id.
- COLORREF color = SendDlgItemMessage(hdlg, idCtrl, CPM_GETCOLOUR, 0, 0);
- int ctlID = idCtrl;
- if ((ctlID > 41070) && (ctlID < 42070)) //It's 41071 or above => Text color.
- PopupsList[ctlID-41071].colorText = color;
- else if (ctlID > 42070)//Background color.
- PopupsList[ctlID-42071].colorBack = color;
- SendMessage(GetParent(hdlg), PSM_CHANGED, 0, 0);
- return TRUE;
- }
- }
- if (wNotifyCode == CBN_SELCHANGE)
- {
- if (idCtrl == IDC_LC)
- {
- MyOptions.LeftClickAction = (BYTE)SendDlgItemMessage(hdlg, IDC_LC, CB_GETCURSEL, 0, 0);
- }
- else if(idCtrl == IDC_RC)
- {
- MyOptions.RightClickAction = (BYTE)SendDlgItemMessage(hdlg, IDC_RC, CB_GETCURSEL, 0, 0);
- }
- SendMessage(GetParent(hdlg), PSM_CHANGED, 0, 0);
- return TRUE;
- }
- switch(idCtrl)
- {
- case IDC_USEOWNCOLORS:
- {
- BOOL bEnableOthers = FALSE;
- if (wNotifyCode != BN_CLICKED)
- break;
- MyOptions.DefColors = byCOLOR_OWN;
- bEnableOthers = TRUE;
- if (!(DBGetContactSettingDword(NULL, "PopUp", "Actions", 0) & 1) || !ServiceExists(MS_POPUP_REGISTERACTIONS))
- {
- EnableWindow(GetDlgItem(hdlg, (41071)), FALSE);
- EnableWindow(GetDlgItem(hdlg, (42071)), FALSE);
- }
- else
- {
- EnableWindow(GetDlgItem(hdlg, (41071)), bEnableOthers);
- EnableWindow(GetDlgItem(hdlg, (42071)), bEnableOthers);
- }
- for (i = 1; i < POPUPS; i++)
- {
- EnableWindow(GetDlgItem(hdlg, (i+42071)), bEnableOthers); //Background
- EnableWindow(GetDlgItem(hdlg, (i+41071)), bEnableOthers); //Text
- }
- SendMessage(GetParent(hdlg), PSM_CHANGED, 0, 0);
- break;
- }
- case IDC_USEWINCOLORS:
- {
- BOOL bEnableOthers = FALSE;
- if (wNotifyCode != BN_CLICKED)
- break;
- //Use Windows colors
- MyOptions.DefColors = byCOLOR_WINDOWS;
- bEnableOthers = FALSE;
- for (i = 0; i < POPUPS; i++)
- {
- EnableWindow(GetDlgItem(hdlg, (i+42071)), bEnableOthers); //Background
- EnableWindow(GetDlgItem(hdlg, (i+41071)), bEnableOthers); //Text
- }
- SendMessage(GetParent(hdlg), PSM_CHANGED, 0, 0);
- break;
- }
- case IDC_USEPOPUPCOLORS:
- {
- BOOL bEnableOthers = FALSE;
- if (wNotifyCode != BN_CLICKED)
- break;
- //Use Popup colors
- MyOptions.DefColors = byCOLOR_POPUP;
- bEnableOthers = FALSE;
- for (i = 0; i < POPUPS; i++)
- {
- EnableWindow(GetDlgItem(hdlg, (i+42071)), bEnableOthers); //Background
- EnableWindow(GetDlgItem(hdlg, (i+41071)), bEnableOthers); //Text
- }
- SendMessage(GetParent(hdlg), PSM_CHANGED, 0, 0);
- break;
- }
- case IDC_PREVIEW:
- {//Declarations and initializations
- LPCTSTR Title = TranslateT("Pack Updater");
- LPCTSTR Text = TranslateT("Test");
- for (int i = 0; i < POPUPS; i++)
- {
- if ((!IsDlgButtonChecked(hdlg, (i+40071))) || (!IsWindowEnabled(GetDlgItem(hdlg, (i+40071)))))
- continue;
- show_popup(0, Title, Text, i, 0);
- }
- break;
- }
- case IDC_TIMEOUT_VALUE:
- case IDC_MSG_BOXES:
- case IDC_ERRORS:
- {
- if (!IsDlgButtonChecked(hdlg, IDC_ERRORS))
- EnableWindow(GetDlgItem(hdlg, IDC_ERRORS_MSG), TRUE);
- else
- EnableWindow(GetDlgItem(hdlg, IDC_ERRORS_MSG), FALSE);
- if ((HIWORD(wParam) == BN_CLICKED || HIWORD(wParam) == EN_CHANGE) && (HWND)lParam == GetFocus())
- SendMessage(GetParent(hdlg), PSM_CHANGED, 0, 0);
- break;
- }
- case IDC_INFO_MESSAGES:
- {
- if (!IsDlgButtonChecked(hdlg, IDC_INFO_MESSAGES))
- EnableWindow(GetDlgItem(hdlg, IDC_INFO_MESSAGES_MSG), TRUE);
- else
- EnableWindow(GetDlgItem(hdlg, IDC_INFO_MESSAGES_MSG), FALSE);
- if ((HIWORD(wParam) == BN_CLICKED || HIWORD(wParam) == EN_CHANGE) && (HWND)lParam == GetFocus())
- SendMessage(GetParent(hdlg), PSM_CHANGED, 0, 0);
- break;
- }
- case IDC_PROGR_DLG:
- {
- if (!IsDlgButtonChecked(hdlg, IDC_PROGR_DLG))
- EnableWindow(GetDlgItem(hdlg, IDC_PROGR_DLG_MSG), TRUE);
- else
- EnableWindow(GetDlgItem(hdlg, IDC_PROGR_DLG_MSG), FALSE);
- if ((HIWORD(wParam) == BN_CLICKED || HIWORD(wParam) == EN_CHANGE) && (HWND)lParam == GetFocus())
- SendMessage(GetParent(hdlg), PSM_CHANGED, 0, 0);
- break;
- }
- case IDC_MSG_BOXES_MSG:
- case IDC_ERRORS_MSG:
- case IDC_INFO_MESSAGES_MSG:
- case IDC_PROGR_DLG_MSG:
- if ((HIWORD(wParam) == BN_CLICKED || HIWORD(wParam) == EN_CHANGE) && (HWND)lParam == GetFocus())
- SendMessage(GetParent(hdlg), PSM_CHANGED, 0, 0);
- break;
- }//end* switch(idCtrl)
- break;
- }//end* case WM_COMMAND:
- case WM_NOTIFY:
- switch (((LPNMHDR)lParam)->code)
- {
- case PSN_RESET:
- {
- //Restore the options stored in memory.
- LoadOptions();
- InitPopupList();
- return TRUE;
- }
- case PSN_APPLY:
- {
- //Text color
- char szSetting[20] = {0};
- DWORD ctlColor = 0;
- for (i = 0; i <= POPUPS-1; i++)
- {
- ctlColor = SendDlgItemMessage(hdlg, (i+42071), CPM_GETCOLOUR, 0, 0);
- PopupsList[i].colorBack = ctlColor;
- mir_snprintf(szSetting, SIZEOF(szSetting), "Popups%iBg", i);
- DBWriteContactSettingDword(NULL, MODNAME, szSetting, ctlColor);
- ctlColor = SendDlgItemMessage(hdlg, (i+41071), CPM_GETCOLOUR, 0, 0);
- PopupsList[i].colorText = ctlColor;
- mir_snprintf(szSetting, SIZEOF(szSetting), "Popups%iTx", i);
- DBWriteContactSettingDword(NULL, MODNAME, szSetting, ctlColor);
- }
- //Colors
- DBWriteContactSettingByte(NULL, MODNAME, "DefColors", MyOptions.DefColors);
- //Timeout
- MyOptions.Timeout = GetDlgItemInt(hdlg, IDC_TIMEOUT_VALUE, 0, TRUE);
- DBWriteContactSettingDword(NULL, MODNAME, "Timeout", MyOptions.Timeout);
- //Left mouse click
- DBWriteContactSettingByte(NULL, MODNAME, "LeftClickAction", MyOptions.LeftClickAction);
- //Right mouse click
- DBWriteContactSettingByte(NULL, MODNAME, "RightClickAction", MyOptions.RightClickAction);
- //Notified popups
- for (i = 0; i < POPUPS; i++)
- {
- mir_snprintf(str, SIZEOF(str), "Popups%d", i);
- DBWriteContactSettingByte(NULL, MODNAME, str, (BYTE)(IsDlgButtonChecked(hdlg, (i+40071))));
- mir_snprintf(str2, SIZEOF(str2), "Popups%dM", i);
- DBWriteContactSettingByte(NULL, MODNAME, str2, (BYTE)(IsDlgButtonChecked(hdlg, (i+1024))));
- }
- return TRUE;
- } //case PSN_APPLY
- } // switch code
- break; //End WM_NOTIFY
- } //switch message
-return FALSE;
-}
-
-int OptInit(WPARAM wParam, LPARAM lParam)
-{
- OPTIONSDIALOGPAGE odp = {0};
- odp.cbSize = sizeof(odp);
- odp.position = 100000000;
- odp.hInstance = hInst;
- odp.flags = ODPF_BOLDGROUPS | ODPF_TCHAR;
- odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_UPDATENOTIFY);
- odp.ptszGroup = LPGENT("Events");
- odp.ptszTitle = LPGENT("Pack Updater");
- odp.pfnDlgProc = UpdateNotifyOptsProc;
- Options_AddPage(wParam, &odp);
-
- if (ServiceExists(MS_POPUP_ADDPOPUP)) {
- odp.pszTemplate = MAKEINTRESOURCEA(IDD_POPUP);
- odp.ptszGroup = LPGENT("PopUps");
- odp.ptszTitle = LPGENT("Pack Updater");
- odp.pfnDlgProc = DlgPopUpOpts;
- Options_AddPage(wParam, &odp);
- }
- return 0;
-}
\ No newline at end of file diff --git a/plugins/PackUpdater_new/Src/PackUpdater.cpp b/plugins/PackUpdater_new/Src/PackUpdater.cpp deleted file mode 100644 index 1d58853c1c..0000000000 --- a/plugins/PackUpdater_new/Src/PackUpdater.cpp +++ /dev/null @@ -1,108 +0,0 @@ -/*
-Copyright (C) 2010 Mataes
-
-This is free software; you can redistribute it and/or
-modify it under the terms of the GNU Library General Public
-License as published by the Free Software Foundation; either
-version 2 of the License, or (at your option) any later version.
-
-This 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
-Library General Public License for more details.
-
-You should have received a copy of the GNU Library General Public
-License along with this file; see the file license.txt. If
-not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA.
-*/
-
-#include "common.h"
-
-HINSTANCE hInst = NULL;
-
-HANDLE hOptHook = NULL, hLoadHook = NULL, hPackUpdaterFolder = NULL, hCheckUpdates = NULL, hEmptyFolder = NULL, hOnPreShutdown = NULL;
-TCHAR tszRoot[MAX_PATH] = {0};
-int hLangpack;
-
-PLUGININFOEX pluginInfoEx = {
- sizeof(PLUGININFOEX),
- __PLUGIN_NAME,
- PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM),
- __DESCRIPTION,
- __AUTHOR,
- __AUTHOREMAIL,
- __COPYRIGHT,
- __AUTHORWEB,
- UNICODE_AWARE,
- //{29517BE5-779A-48e5-8950-CB4DE1D43172}
- {0x29517be5, 0x779a, 0x48e5, {0x89, 0x50, 0xcb, 0x4d, 0xe1, 0xd4, 0x31, 0x72}}
-};
-
-BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
-{
- hInst = hinstDLL;
- return TRUE;
-}
-
-extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD mirandaVersion)
-{
- return &pluginInfoEx;
-}
-
-extern "C" __declspec(dllexport) int Load(void)
-{
- CLISTMENUITEM mi;
-
- mir_getLP(&pluginInfoEx);
- TCHAR* tszFolder = Utils_ReplaceVarsT(_T("%miranda_userdata%\\"DEFAULT_UPDATES_FOLDER));
- lstrcpyn(tszRoot, tszFolder, SIZEOF(tszRoot));
- if (ServiceExists(MS_FOLDERS_REGISTER_PATH))
- {
- hPackUpdaterFolder = FoldersRegisterCustomPathT(MODULEA, "Pack Updater", MIRANDA_USERDATAT _T("\\")DEFAULT_UPDATES_FOLDER);
- FoldersGetCustomPathT(hPackUpdaterFolder, tszRoot, MAX_PATH, _T(""));
- }
- mir_free(tszFolder);
- LoadOptions();
- InitPopupList();
- NetlibInit();
- IcoLibInit();
-
- // Add cheking update menu item
- hCheckUpdates = CreateServiceFunction(MODNAME"/CheckUpdates", MenuCommand);
- ZeroMemory(&mi, sizeof(mi));
- mi.cbSize = sizeof(mi);
- mi.position = -0x7FFFFFFF;
- mi.flags = CMIF_TCHAR;
- mi.hIcon = (HICON)CallService(MS_SKIN2_GETICON, 0, (LPARAM)"check_update");
- mi.ptszName = _T("Check for pack updates");
- mi.pszService = MODNAME"/CheckUpdates";
- Menu_AddMainMenuItem(&mi);
- // Add empty updates folder menu item
- hEmptyFolder = CreateServiceFunction(MODNAME"/EmptyFolder", EmptyFolder);
- ZeroMemory(&mi, sizeof(mi));
- mi.cbSize = sizeof(mi);
- mi.position = -0x7FFFFFFF;
- mi.flags = CMIF_TCHAR;
- mi.hIcon = (HICON)CallService(MS_SKIN2_GETICON, 0, (LPARAM)"empty_folder");
- mi.ptszName = _T("Clear pack updates folder");
- mi.pszService = MODNAME"/EmptyFolder";
- Menu_AddMainMenuItem(&mi);
-
- // Add options hook
- hOptHook = HookEvent(ME_OPT_INITIALISE, OptInit);
- hLoadHook = HookEvent(ME_SYSTEM_MODULESLOADED, ModulesLoaded);
- hOnPreShutdown = HookEvent(ME_SYSTEM_PRESHUTDOWN, OnPreShutdown);
-
- return 0;
-}
-
-extern "C" __declspec(dllexport) int Unload(void)
-{
- if (CheckThread)
- CheckThread = NULL;
- NetlibUnInit();
- DestroyServiceFunction(hCheckUpdates);
- DestroyServiceFunction(hEmptyFolder);
- return 0;
-}
\ No newline at end of file diff --git a/plugins/PackUpdater_new/Src/Utils.cpp b/plugins/PackUpdater_new/Src/Utils.cpp deleted file mode 100644 index 0174961e0e..0000000000 --- a/plugins/PackUpdater_new/Src/Utils.cpp +++ /dev/null @@ -1,497 +0,0 @@ -/*
-Copyright (C) 2010 Mataes
-
-This is free software; you can redistribute it and/or
-modify it under the terms of the GNU Library General Public
-License as published by the Free Software Foundation; either
-version 2 of the License, or (at your option) any later version.
-
-This 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
-Library General Public License for more details.
-
-You should have received a copy of the GNU Library General Public
-License along with this file; see the file license.txt. If
-not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA.
-*/
-
-#include "Common.h"
-
-//vector<FILEINFO> Files;
-BOOL DlgDld;
-INT /*CurrentFile = 0,*/ Number = 0;
-BYTE Reminder, AutoUpdate;
-BYTE UpdateOnStartup, UpdateOnPeriod, OnlyOnceADay, PeriodMeasure;
-INT Period;
-TCHAR tszDialogMsg[2048] = {0};
-FILEINFO* pFileInfo = NULL;
-//FILEURL* pFileUrl = NULL;
-HANDLE CheckThread = NULL, hNetlibUser = NULL;
-MYOPTIONS MyOptions = {0};
-aPopups PopupsList[POPUPS];
-
-PackUpdaterIconList iconList[] =
-{
- { "check_update", _T("Check for pack updates"), IDI_MENU },
- { "empty_folder", _T("Clear pack updates folder"), IDI_DELETE },
- { "btn_ok", _T("'Yes' Button"), IDI_OK },
- { "btn_cancel", _T("'No' Button"), IDI_CANCEL }
-};
-
-VOID IcoLibInit()
-{
- SKINICONDESC sid;
- TCHAR destfile[MAX_PATH];
-
- GetModuleFileName(hInst, destfile, MAX_PATH);
-
- sid.cbSize = sizeof(sid);
- sid.flags = SIDF_ALL_TCHAR;
- sid.cx = sid.cy = 16;
- sid.ptszDefaultFile = destfile;
- sid.ptszSection = MODULE;
-
- for (int i = 0; i < SIZEOF(iconList); i++)
- {
- sid.pszName = iconList[i].szIconName;
- sid.ptszDescription = iconList[i].tszDescr;
- sid.iDefaultIndex = -iconList[i].IconID;
- Skin_AddIcon(&sid);
- }
-}
-
-BOOL NetlibInit()
-{
- NETLIBUSER nlu = {0};
- nlu.cbSize = sizeof(nlu);
- nlu.flags = NUF_OUTGOING | NUF_INCOMING | NUF_HTTPCONNS | NUF_TCHAR; // | NUF_HTTPGATEWAY;
- nlu.ptszDescriptiveName = TranslateT("Pack Updater HTTP connection");
- nlu.szSettingsModule = MODNAME;
- hNetlibUser = (HANDLE)CallService(MS_NETLIB_REGISTERUSER, 0, (LPARAM)&nlu);
-
- return hNetlibUser != NULL;
-}
-
-VOID NetlibUnInit()
-{
- Netlib_CloseHandle(hNetlibUser);
- hNetlibUser = NULL;
-}
-
-VOID InitPopupList()
-{
- int index = 0;
- PopupsList[index].ID = index;
- PopupsList[index].Icon = SKINICON_OTHER_MIRANDA;
- PopupsList[index].colorBack = DBGetContactSettingDword(NULL, MODNAME, "Popups0Bg", COLOR_BG_FIRSTDEFAULT);
- PopupsList[index].colorText = DBGetContactSettingDword(NULL, MODNAME, "Popups0Tx", COLOR_TX_DEFAULT);
-
- index = 1;
- PopupsList[index].ID = index;
- PopupsList[index].Icon = SKINICON_OTHER_MIRANDA;
- PopupsList[index].colorBack = DBGetContactSettingDword(NULL, MODNAME, "Popups1Bg", COLOR_BG_SECONDDEFAULT);
- PopupsList[index].colorText = DBGetContactSettingDword(NULL, MODNAME, "Popups1Tx", COLOR_TX_DEFAULT);
-
- index = 2;
- PopupsList[index].ID = index;
- PopupsList[index].Icon = SKINICON_OTHER_MIRANDA;
- PopupsList[index].colorBack = DBGetContactSettingDword(NULL, MODNAME, "Popups2Bg", COLOR_BG_FIRSTDEFAULT);
- PopupsList[index].colorText = DBGetContactSettingDword(NULL, MODNAME, "Popups2Tx", COLOR_TX_DEFAULT);
-
- index = 3;
- PopupsList[index].ID = index;
- PopupsList[index].Icon = SKINICON_OTHER_MIRANDA;
- PopupsList[index].colorBack = DBGetContactSettingDword(NULL, MODNAME, "Popups3Bg", COLOR_BG_SECONDDEFAULT);
- PopupsList[index].colorText = DBGetContactSettingDword(NULL, MODNAME, "Popups3Tx", COLOR_TX_DEFAULT);
-}
-
-VOID LoadOptions()
-{
- MyOptions.DefColors = DBGetContactSettingByte(NULL, MODNAME, "DefColors", DEFAULT_COLORS);
- MyOptions.LeftClickAction= DBGetContactSettingByte(NULL, MODNAME, "LeftClickAction", DEFAULT_POPUP_LCLICK);
- MyOptions.RightClickAction = DBGetContactSettingByte(NULL, MODNAME, "RightClickAction", DEFAULT_POPUP_RCLICK);
- MyOptions.Timeout = DBGetContactSettingDword(NULL, MODNAME, "Timeout", DEFAULT_TIMEOUT_VALUE);
- UpdateOnStartup = DBGetContactSettingByte(NULL, MODNAME, "UpdateOnStartup", DEFAULT_UPDATEONSTARTUP);
- OnlyOnceADay = DBGetContactSettingByte(NULL, MODNAME, "OnlyOnceADay", DEFAULT_ONLYONCEADAY);
- UpdateOnPeriod = DBGetContactSettingByte(NULL, MODNAME, "UpdateOnPeriod", DEFAULT_UPDATEONPERIOD);
- Period = DBGetContactSettingDword(NULL, MODNAME, "Period", DEFAULT_PERIOD);
- PeriodMeasure = DBGetContactSettingByte(NULL, MODNAME, "PeriodMeasure", DEFAULT_PERIODMEASURE);
- Reminder = DBGetContactSettingByte(NULL, MODNAME, "Reminder", DEFAULT_REMINDER);
-}
-
-BOOL DownloadFile(LPCTSTR tszURL, LPCTSTR tszLocal)
-{
- HANDLE hFile = NULL;
- DWORD dwBytes;
-
- NETLIBHTTPREQUEST nlhr = {0};
- nlhr.cbSize = sizeof(nlhr);
- nlhr.requestType = REQUEST_GET;
- nlhr.flags = NLHRF_DUMPASTEXT | NLHRF_HTTP11;
- char* szUrl = mir_t2a(tszURL);
- nlhr.szUrl = szUrl;
- nlhr.headersCount = 4;
- nlhr.headers=(NETLIBHTTPHEADER*)mir_alloc(sizeof(NETLIBHTTPHEADER)*nlhr.headersCount);
- nlhr.headers[0].szName = "User-Agent";
- nlhr.headers[0].szValue = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)";
- nlhr.headers[1].szName = "Connection";
- nlhr.headers[1].szValue = "close";
- nlhr.headers[2].szName = "Cache-Control";
- nlhr.headers[2].szValue = "no-cache";
- nlhr.headers[3].szName = "Pragma";
- nlhr.headers[3].szValue = "no-cache";
-
- bool ret = false;
- NETLIBHTTPREQUEST* pReply = NULL;
- pReply = (NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)hNetlibUser,(LPARAM)&nlhr);
-
- if (pReply)
- {
- if ((200 == pReply->resultCode) && (pReply->dataLength > 0))
- {
- hFile = CreateFile(tszLocal, GENERIC_READ | GENERIC_WRITE, NULL, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
- WriteFile(hFile, pReply->pData, (DWORD)pReply->dataLength, &dwBytes, NULL);
- ret = true;
- }
- CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT,0,(LPARAM)pReply);
- }
-
- mir_free(szUrl);
- mir_free(nlhr.headers);
-
- if (hFile)
- CloseHandle(hFile);
- DlgDld = ret;
- return ret;
-}
-
-VOID __stdcall ExitMe(void*)
-{
- CallService("CloseAction", 0, 0);
-}
-
-VOID __stdcall RestartMe(void*)
-{
- CallService(MS_SYSTEM_RESTART, 0, 0);
-}
-
-BOOL Exists(LPCTSTR strName)
-{
- return GetFileAttributes(strName) != INVALID_FILE_ATTRIBUTES;
-}
-
-BOOL IsPluginDisabled(TCHAR* filename)
-{
- char* fname = mir_t2a(filename);
- int res = DBGetContactSettingByte(NULL, "PluginDisable", fname, 0);
- mir_free(fname);
- return res;
-}
-
-/*INT getVer(const TCHAR* verStr)
-{
- INT v1 = 0, v2 = 0, v3 = 0, v4 = 0;
- _stscanf(verStr, _T("%d.%d.%d.%d"), &v1, &v2, &v3, &v4);
- return v1*1000000 + v2*10000 + v3*1000 + v4;
-}*/
-
-static void CheckUpdates(void *)
-{
- TCHAR tszBuff[2048] = {0}, /*tszFileInfo[30] = {0},*/ tszTmpIni[MAX_PATH] = {0};
- char szKey[64] = {0};
- INT upd_ret;
- DBVARIANT dbVar = {0};
- vector<FILEINFO> UpdateFiles;
-
- if (!Exists(tszRoot))
- CreateDirectory(tszRoot, NULL);
- //Files.clear();
- Reminder = DBGetContactSettingByte(NULL, MODNAME, "Reminder", DEFAULT_REMINDER);
-
- // Load files info
- if (DBGetContactSettingTString(NULL, MODNAME, "UpdateURL", &dbVar))// URL is not set
- {
- LPCTSTR Title=TranslateT("Pack Updater");
- LPCTSTR Text = TranslateT("URL for checking updates not found.");
- if (ServiceExists(MS_POPUP_ADDPOPUPEX) && DBGetContactSettingByte(NULL, "PopUp", "ModuleIsEnabled", 1) && DBGetContactSettingByte(NULL, MODNAME, "Popups1", DEFAULT_POPUP_ENABLED))
- {
- Number = 1;
- show_popup(0, Title, Text, Number, 0);
- }
- else if (DBGetContactSettingByte(NULL, MODNAME, "Popups1M", DEFAULT_MESSAGE_ENABLED))
- MessageBox(NULL, Text, Title, MB_ICONSTOP);
- DBFreeVariant(&dbVar);
- CheckThread = NULL;
- return;
- }
-
- // Download version info
- FILEURL *pFileUrl = (FILEURL *)mir_alloc(sizeof(*pFileUrl));
- lstrcpyn(pFileUrl->tszDownloadURL, dbVar.ptszVal, SIZEOF(pFileUrl->tszDownloadURL));
- DBFreeVariant(&dbVar);
- mir_sntprintf(tszBuff, SIZEOF(tszBuff), _T("%s\\tmp.ini"), tszRoot);
- lstrcpyn(pFileUrl->tszDiskPath, tszBuff, SIZEOF(pFileUrl->tszDiskPath));
- lstrcpyn(tszTmpIni, tszBuff, SIZEOF(tszTmpIni));
- PopupDataText temp;
- temp.Title = TranslateT("Pack Updater");
- temp.Text = TranslateT("Downloading version info...");
- DlgDownloadProc(pFileUrl, temp);
- mir_free(pFileUrl);
- if (!DlgDld)
- {
- CheckThread = NULL;
- return;
- }
-
-
- WIN32_FIND_DATA ffd;
- TCHAR *dirname = Utils_ReplaceVarsT(_T("%miranda_path%\\Plugins\\*"));
- HANDLE hFind = INVALID_HANDLE_VALUE;
-
- hFind = FindFirstFile(dirname, &ffd);
- mir_free(dirname);
- while( hFind != INVALID_HANDLE_VALUE )
- {
- if (!(ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) && !lstrcmp(&ffd.cFileName[lstrlen(ffd.cFileName)-4], _T(".dll")))
- {
- TCHAR *plugname = ffd.cFileName;
- FILEINFO FileInfo = {_T(""), _T(""), _T(""), _T(""), _T(""), _T(""), {_T(""), _T("")}};
-
- //dbVar.ptszVal = NULL;
- //mir_snprintf(szKey, SIZEOF(szKey), "File_%d_CurrentVersion", CurrentFile + 1);
- if (!DBGetContactSettingTString(NULL, MODNAME, _T2A(ffd.cFileName), &dbVar))
- {
- //считать хэш файла
- lstrcpyn(FileInfo.curhash, _T(""), SIZEOF(FileInfo.curhash));
- }
- else
- lstrcpyn(FileInfo.curhash, dbVar.ptszVal, SIZEOF(FileInfo.curhash));
- DBFreeVariant(&dbVar);
- //dbVar.ptszVal = NULL;
- //Files.push_back(FileInfo);
-
- // Read version info
- //mir_sntprintf(tszFileInfo, SIZEOF(tszFileInfo), _T("FileInfo_%d"), CurrentFile + 1);
- GetPrivateProfileString(ffd.cFileName, _T("Hash"), _T(""), FileInfo.newhash, SIZEOF(FileInfo.newhash), tszTmpIni);
-
- // Compare versions
- if (lstrcmp(FileInfo.curhash, FileInfo.newhash)) // Yeah, we've got new version.
- {
- GetPrivateProfileString(ffd.cFileName, _T("Message"), _T(""), FileInfo.tszMessage, SIZEOF(FileInfo.tszMessage), tszTmpIni);
- GetPrivateProfileString(ffd.cFileName, _T("DownloadURL"), _T(""), FileInfo.File.tszDownloadURL, SIZEOF(FileInfo.File.tszDownloadURL), tszTmpIni);
- GetPrivateProfileString(ffd.cFileName, _T("AdvFolder"), _T(""), FileInfo.tszAdvFolder, SIZEOF(FileInfo.tszAdvFolder), tszTmpIni);
- GetPrivateProfileString(ffd.cFileName, _T("Descr"), _T(""), FileInfo.tszDescr, SIZEOF(FileInfo.tszDescr), tszTmpIni);
- GetPrivateProfileString(ffd.cFileName, _T("DiskFileName"), _T(""), tszBuff, MAX_PATH, tszTmpIni);
-
- if (_tcsstr(tszBuff, _T("\\"))) //check update name
- {
- LPCTSTR Title = TranslateT("Pack Updater");
- LPCTSTR Text = TranslateT("Name of Update's file is not supported.");
- if (ServiceExists(MS_POPUP_ADDPOPUPEX) && DBGetContactSettingByte(NULL, "PopUp", "ModuleIsEnabled", 1) && DBGetContactSettingByte(NULL, MODNAME, "Popups1", DEFAULT_POPUP_ENABLED))
- {
- Number = 1;
- show_popup(0, Title, Text, Number, 0);
- }
- else if (DBGetContactSettingByte(NULL, MODNAME, "Popups1M", DEFAULT_MESSAGE_ENABLED))
- MessageBox(NULL, Text, Title, MB_ICONINFORMATION);
- continue;
- } // end check update name
- lstrcpyn(FileInfo.File.tszDiskPath, tszBuff, SIZEOF(FileInfo.File.tszDiskPath));
- GetPrivateProfileString(ffd.cFileName, _T("InfoURL"), _T(""), FileInfo.tszInfoURL, SIZEOF(FileInfo.tszInfoURL), tszTmpIni);
- FileInfo.FileType = GetPrivateProfileInt(ffd.cFileName, _T("FileType"), 0, tszTmpIni);
- FileInfo.Force = GetPrivateProfileInt(ffd.cFileName, _T("Force"), 0, tszTmpIni);
- //FileInfo.FileNum = CurrentFile+1;
-
- if (FileInfo.FileType == 2)
- {
- TCHAR pluginFolgerName[MAX_PATH];
- if (!lstrcmp(FileInfo.tszAdvFolder, _T("")))
- mir_sntprintf(tszBuff, SIZEOF(tszBuff), _T("Plugins\\%s"), FileInfo.File.tszDiskPath);
- else
- mir_sntprintf(tszBuff, SIZEOF(tszBuff), _T("Plugins\\%s\\%s"), FileInfo.tszAdvFolder, FileInfo.File.tszDiskPath);
- CallService(MS_UTILS_PATHTOABSOLUTET, (WPARAM)tszBuff, (LPARAM)pluginFolgerName);
- if ((IsPluginDisabled(FileInfo.File.tszDiskPath) || !Exists(pluginFolgerName))) //check if plugin disabled or not exists
- continue;
- }
- TCHAR* tszSysRoot = Utils_ReplaceVarsT(_T("%SystemRoot%"));
- TCHAR* tszProgFiles = Utils_ReplaceVarsT(_T("%ProgramFiles%"));
-
- if (FileInfo.FileType != 1 && !IsUserAnAdmin() && (_tcsstr(tszRoot, tszSysRoot) || _tcsstr(tszRoot, tszProgFiles)))
- {
- LPCTSTR Title = TranslateT("Pack Updater");
- MessageBox(NULL, TranslateT("Update is not possible!\nYou have no Administrator's rights.\nPlease run Miranda IM with Administrator's rights."), Title, MB_ICONINFORMATION);
- DeleteFile(tszTmpIni);
- CheckThread = NULL;
- return;
- } // user have not admin's rights
- else
- {
- //добавить проверку на существование файла
- TCHAR tszFilePathDest[MAX_PATH] = {0};
- TCHAR* tszUtilRootPlug = NULL;
- TCHAR* tszUtilRootIco = NULL;
- TCHAR* tszUtilRoot = NULL;
-
- switch (FileInfo.FileType)
- {
- case 0:
- case 1:
- break;
- case 2:
- tszUtilRootPlug = Utils_ReplaceVarsT(_T("%miranda_path%\\Plugins"));
- if (lstrcmp(FileInfo.tszAdvFolder, _T("")) == 0)
- mir_sntprintf(tszFilePathDest, SIZEOF(tszFilePathDest), _T("%s\\%s"), tszUtilRootPlug, FileInfo.File.tszDiskPath);
- else
- mir_sntprintf(tszFilePathDest, SIZEOF(tszFilePathDest), _T("%s\\%s\\%s"), tszUtilRootPlug, FileInfo.tszAdvFolder, FileInfo.File.tszDiskPath);
- mir_free(tszUtilRootPlug);
- break;
- case 3:
- tszUtilRootIco = Utils_ReplaceVarsT(_T("%miranda_path%\\Icons"));
- if (lstrcmp(FileInfo.tszAdvFolder, _T("")) == 0)
- mir_sntprintf(tszFilePathDest, SIZEOF(tszFilePathDest), _T("%s\\%s"), tszUtilRootIco, FileInfo.File.tszDiskPath);
- else
- mir_sntprintf(tszFilePathDest, SIZEOF(tszFilePathDest), _T("%s\\%s\\%s"), tszUtilRootIco, FileInfo.tszAdvFolder, FileInfo.File.tszDiskPath);
- mir_free(tszUtilRootIco);
- break;
- case 4:
- case 5:
- tszUtilRoot = Utils_ReplaceVarsT(_T("%miranda_path%"));
- if (lstrcmp(FileInfo.tszAdvFolder, _T("")) == 0)
- mir_sntprintf(tszFilePathDest, SIZEOF(tszFilePathDest), _T("%s\\%s"), tszUtilRoot, FileInfo.File.tszDiskPath);
- else
- mir_sntprintf(tszFilePathDest, SIZEOF(tszFilePathDest), _T("%s\\%s\\%s"), tszUtilRoot, FileInfo.tszAdvFolder, FileInfo.File.tszDiskPath);
- mir_free(tszUtilRoot);
- break;
- }//end* switch (Files[CurrentFile].FileType)
-
- if (FileInfo.Force || Exists(tszFilePathDest))
- UpdateFiles.push_back(FileInfo);
- // Save last version
- //убрать отсюда
- DBWriteContactSettingTString(NULL, MODNAME, _T2A(ffd.cFileName), FileInfo.newhash);
- } // user have admin's rights
- mir_free(tszSysRoot);
- mir_free(tszProgFiles);
- } // end compare versions
-
- }
-
- if (!FindNextFile(hFind, &ffd ))
- break;
- }
- FindClose(hFind);
-
-
- // Show dialog
- if (UpdateFiles.size()>0)
- upd_ret = DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_UPDATE), GetDesktopWindow(), DlgUpdate, (LPARAM)&UpdateFiles);
- DeleteFile(tszTmpIni);
- if (upd_ret == IDCANCEL)
- {
- CheckThread = NULL;
- return;
- }
- if (!UpdatesCount && !Silent)
- {
- LPCTSTR Title = TranslateT("Pack Updater");
- LPCTSTR Text = TranslateT("No updates found.");
- if (ServiceExists(MS_POPUP_ADDPOPUPEX) && DBGetContactSettingByte(NULL, "PopUp", "ModuleIsEnabled", 1) && DBGetContactSettingByte(NULL, MODNAME, "Popups2", DEFAULT_POPUP_ENABLED))
- {
- Number = 2;
- show_popup(0, Title, Text, Number, 0);
- }
- else if (DBGetContactSettingByte(NULL, MODNAME, "Popups2M", DEFAULT_MESSAGE_ENABLED))
- MessageBox(NULL, Text, Title, MB_ICONINFORMATION);
- }
- /*if (!FileCount)
- {
- Title = TranslateT("Pack Updater");
- Text = TranslateT("No files for update.");
- if (ServiceExists(MS_POPUP_ADDPOPUPEX) && DBGetContactSettingByte(NULL, "PopUp", "ModuleIsEnabled", 1) && DBGetContactSettingByte(NULL, MODNAME, "Popups2", DEFAULT_POPUP_ENABLED))
- {
- Number = 2;
- show_popup(0, Title, Text, Number, 0);
- }
- else if (DBGetContactSettingByte(NULL, MODNAME, "Popups2M", DEFAULT_MESSAGE_ENABLED))
- MessageBox(NULL, Text, Title, MB_ICONINFORMATION);
- }*/
- CheckThread = NULL;
-}//end* static void CheckUpdates(void *)
-
-void DoCheck(int iFlag, int iFlag2)
-{
- if (iFlag2)
- {
- LPCTSTR Title = TranslateT("Pack Updater");
- LPCTSTR Text = TranslateT("Update checking already started!");
- if (ServiceExists(MS_POPUP_ADDPOPUPEX) && DBGetContactSettingByte(NULL, "PopUp", "ModuleIsEnabled", 1) && DBGetContactSettingByte(NULL, MODNAME, "Popups2", DEFAULT_POPUP_ENABLED))
- {
- Number = 2;
- show_popup(0, Title, Text, Number, 0);
- }
- else if (DBGetContactSettingByte(NULL, MODNAME, "Popups2M", DEFAULT_MESSAGE_ENABLED))
- MessageBox(NULL, Text, Title, MB_ICONINFORMATION);
- }
- else if (iFlag)
- {
- CheckThread = mir_forkthread(CheckUpdates, 0);
- DBWriteContactSettingDword(NULL, MODNAME, "LastUpdate", time(NULL));
- }
-}
-
-BOOL AllowUpdateOnStartup()
-{
- if(OnlyOnceADay)
- {
- time_t now = time(NULL);
- time_t was = DBGetContactSettingDword(NULL, MODNAME, "LastUpdate", 0);
-
- if((now - was) < 86400)
- return FALSE;
- }
- return TRUE;
-}
-
-LONG PeriodToMilliseconds(const INT period, BYTE& periodMeasure)
-{
- LONG result = period * 1000;
- switch(periodMeasure)
- {
- case 1:
- // day
- result *= 60 * 60 * 24;
- break;
-
- default:
- // hour
- if(periodMeasure != 0)
- periodMeasure = 0;
- result *= 60 * 60;
- break;
- }
- return result;
-}
-
-VOID CALLBACK TimerAPCProc(LPVOID lpArg, DWORD dwTimerLowValue, DWORD dwTimerHighValue)
-{
- DoCheck(1, (int)CheckThread);
-}
-
-VOID InitTimer()
-{
- CancelWaitableTimer(Timer);
- if(UpdateOnPeriod)
- {
- LONG interval = PeriodToMilliseconds(Period, PeriodMeasure);
-
- _int64 qwDueTime = -10000i64 * interval;
-
- LARGE_INTEGER li = {0};
- li.LowPart = (DWORD) ( qwDueTime & 0xFFFFFFFF );
- li.HighPart = (LONG) ( qwDueTime >> 32 );
-
- SetWaitableTimer(Timer, &li, interval, TimerAPCProc, NULL, 0);
- }
-}
\ No newline at end of file |