UPS: apcupsd clean sources
[tomato.git] / release / src / router / apcupsd / src / win32 / wintray.h
blob5513040244bd52af84ed32eb86008d227c7360ab
1 // This file has been adapted to the Win32 version of Apcupsd
2 // by Kern E. Sibbald. Many thanks to ATT and James Weatherall,
3 // the original author, for providing an excellent template.
4 //
5 // Rewrite/Refactoring by Adam Kropelin
6 //
7 // Copyright (2007) Adam D. Kropelin
8 // Copyright (2000) Kern E. Sibbald
11 // This class handles creation of a system-tray icon & menu
13 #ifndef WINTRAY_H
14 #define WINTRAY_H
16 #include <windows.h>
17 #include "winabout.h"
18 #include "winstat.h"
19 #include "winevents.h"
20 #include "winconfig.h"
21 #include "astring.h"
22 #include "instmgr.h"
23 #include "amutex.h"
25 // Forward declarations
26 class StatMgr;
27 class BalloonMgr;
29 // The tray menu class itself
30 class upsMenu
32 public:
33 upsMenu(HINSTANCE appinst, MonitorConfig &mcfg, BalloonMgr *balmgr,
34 InstanceManager *instmgr);
35 ~upsMenu();
36 void Destroy();
37 void Redraw();
38 void Reconfigure(const MonitorConfig &mcfg);
39 void Refresh();
41 protected:
42 // Tray icon handling
43 void AddTrayIcon();
44 void DelTrayIcon();
45 void UpdateTrayIcon();
46 void SendTrayMsg(DWORD msg);
48 // Message handler for the tray window
49 static LRESULT CALLBACK WndProc(
50 HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam);
51 LRESULT WndProcess(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam);
53 // Fetch UPS status info
54 bool FetchStatus(int &battstat, astring &statstr, astring &upsname);
56 // Thread to poll for UPS status changes
57 static DWORD WINAPI StatusPollThread(LPVOID param);
59 HWND _hwnd; // Window handle
60 HMENU _hmenu; // Menu handle
61 HMENU _hsubmenu; // Submenu handle
62 StatMgr *_statmgr; // Manager for UPS stats
63 HANDLE _thread; // Handle to status polling thread
64 HANDLE _wait; // Handle to wait mutex
65 astring _upsname; // Cache UPS name
66 astring _laststatus; // Cache previous status string
67 BalloonMgr *_balmgr; // Balloon tip manager
68 UINT _tbcreated_msg; // Id of TaskbarCreated message
69 HINSTANCE _appinst; // Application instance handle
70 MonitorConfig _config; // Configuration (host, port, etc.)
71 bool _runthread; // Run the poll thread?
72 amutex _mutex; // Lock to protect statmgr
73 WPARAM _generation;
74 bool _reconfig;
75 InstanceManager *_instmgr;
77 // Dialogs for About, Status, Config, and Events
78 upsAbout _about;
79 upsStatus _status;
80 upsConfig _configdlg;
81 upsEvents _events;
83 // The icon handles
84 HICON _online_icon;
85 HICON _onbatt_icon;
86 HICON _charging_icon;
87 HICON _commlost_icon;
90 #endif // WINTRAY_H