UPS: apcupsd clean sources
[tomato.git] / release / src / router / apcupsd / src / win32 / instmgr.h
blob739dd4d0c039488cccedf936c9954155e1e9f9d0
1 /*
2 * Copyright (C) 2009 Adam Kropelin
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of version 2 of the GNU General
6 * Public License as published by the Free Software Foundation.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * General Public License for more details.
13 * You should have received a copy of the GNU General Public
14 * License along with this program; if not, write to the Free
15 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
16 * MA 02111-1307, USA.
19 #include "astring.h"
20 #include "alist.h"
21 #include <windows.h>
23 #ifndef __INSTMGR_H
24 #define __INSTMGR_H
26 #include "balloonmgr.h"
28 class upsMenu;
30 struct MonitorConfig
32 astring id;
33 astring host;
34 DWORD port;
35 DWORD refresh;
36 DWORD popups;
39 class InstanceManager
41 public:
42 InstanceManager(HINSTANCE appinst);
43 ~InstanceManager();
45 void CreateMonitors();
46 int RemoveInstance(const char *id);
47 void AddInstance();
48 void UpdateInstance(const MonitorConfig &mcfg);
49 void RemoveAll();
50 void ResetInstances();
51 bool IsAutoStart();
52 void SetAutoStart(bool start);
54 private:
56 struct InstanceConfig
58 InstanceConfig() : menu(NULL), order(0) {}
59 ~InstanceConfig() {}
61 MonitorConfig mcfg;
62 DWORD order;
63 upsMenu *menu;
66 void Write();
67 InstanceConfig ReadConfig(HKEY key, const char *id);
68 alist<InstanceConfig>::iterator FindInstance(const char *id);
69 astring CreateId();
71 bool RegQueryDWORD(HKEY hkey, const char *name, DWORD &result);
72 bool RegQueryString(HKEY key, const char *name, astring &result);
73 void RegSetDWORD(HKEY key, const char *name, DWORD value);
74 void RegSetString(HKEY key, const char *name, const char *value);
76 static const char *INSTANCES_KEY;
77 static const MonitorConfig DEFAULT_CONFIG;
79 alist<InstanceConfig> _instances;
80 HINSTANCE _appinst;
81 BalloonMgr _balmgr;
84 #endif