1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
|
#ifndef _COUTPUTMANAGER_H_
#define _COUTPUTMANAGER_H_
#include "LCDFramework/CLCDOutputManager.h"
#include "CProtocolData.h"
#include "CIRCHistory.h"
#include "CIRCConnection.h"
#include "CNotificationScreen.h"
#include "CEventScreen.h"
#include "CContactlistScreen.h"
#include "CChatScreen.h"
#include "CCreditsScreen.h"
#include "CScreensaverScreen.h"
#include "LCDFramework/CLCDConnectionLogitech.h"
struct SMessageJob
{
MEVENT hEvent;
MCONTACT hContact;
uint32_t dwFlags;
char *pcBuffer;
int iBufferSize;
uint32_t dwTimestamp;
};
class CAppletManager : public CLCDOutputManager
{
public:
// returns the AppletManager's instance
static CAppletManager *GetInstance();
// Constructor
CAppletManager();
// Destructor
~CAppletManager();
// Initializes the AppletManager
bool Initialize(tstring strAppletName);
// Deinitializes the AppletManager
bool Shutdown();
// Updates the AppletManager
bool Update();
// the update timer's callback function
static VOID CALLBACK UpdateTimer(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime);
// called when the plugin's configuration has changed
void OnConfigChanged();
// called to process the specified event
void HandleEvent(CEvent *pEvent);
// screen activation functions
void ActivatePreviousScreen();
void ActivateScreensaverScreen();
void ActivateCreditsScreen();
void ActivateEventScreen();
void ActivateCListScreen();
bool ActivateChatScreen(MCONTACT hContact);
// hook functions
static int HookMessageWindowEvent(WPARAM wParam, LPARAM lParam);
static int HookContactIsTyping(WPARAM wParam, LPARAM lParam);
static int HookEventAdded(WPARAM wParam, LPARAM lParam);
static int HookStatusChanged(WPARAM wParam, LPARAM lParam);
static int HookProtoAck(WPARAM wParam, LPARAM lParam);
static int HookContactAdded(WPARAM wParam, LPARAM lParam);
static int HookContactDeleted(WPARAM wParam, LPARAM lParam);
static int HookSettingChanged(WPARAM wParam, LPARAM lParam);
static int HookChatInbound(WPARAM wParam, LPARAM lParam);
// check if a contacts message window is opened
static bool IsMessageWindowOpen(MCONTACT hContact);
// marks the given event as read
static void MarkMessageAsRead(MCONTACT hContact, MEVENT hEvent);
// translates the given database event
static bool TranslateDBEvent(CEvent *pEvent, WPARAM wParam, LPARAM lParam);
// sends a message to the specified contact
static MEVENT SendMessageToContact(MCONTACT hContact, tstring strMessage);
// sends typing notifications to the specified contact
static void SendTypingNotification(MCONTACT hContact, bool bEnable);
// returns a formatted timestamp string
static tstring GetFormattedTimestamp(tm *time);
// returns the contacts group
static tstring GetContactGroup(MCONTACT hContact);
// returns the contacts displayname
static tstring GetContactDisplayname(MCONTACT hContact, bool bShortened = false);
// returns the history class for the specified IRC channel
CIRCHistory *GetIRCHistory(MCONTACT hContact);
CIRCHistory *GetIRCHistoryByName(tstring strProtocol, tstring strChannel);
// returns the IRC connection class for the specified protocol
CIRCConnection *GetIRCConnection(tstring strProtocol);
// creates the IRC connection class for the specified protocol
CIRCConnection *CreateIRCConnection(tstring strProtocol);
// returns the bitmap for the specified status
HBITMAP GetStatusBitmap(int iStatus);
// returns the bitmap for the specified event
HBITMAP GetEventBitmap(EventType eType, bool bLarge = false);
// checks if the patched IRC protocol is in place
bool IsIRCHookEnabled();
static tstring TranslateString(wchar_t *szString, ...);
private:
list<CIRCHistory*> m_LIRCHistorys;
// deletes the history class for the specified IRC channel
void DeleteIRCHistory(MCONTACT hContact);
// creates a history class for the specified IRC channel
CIRCHistory *CreateIRCHistory(MCONTACT hContact, tstring strChannel);
CIRCHistory *CreateIRCHistoryByName(tstring strProtocol, tstring strChannel);
// activate a screen
void ActivateScreen(CScreen *pScreen);
// applies the volumewheel setting
void SetVolumeWheelHook();
// Called when the connection state has changed
void OnConnectionChanged(int iConnectionState);
// Called when the active screen has expired
void OnScreenExpired(CLCDScreen *pScreen);
// updates all pending message jobs
void UpdateMessageJobs();
// adds a message job to the list
void AddMessageJob(SMessageJob *pJob);
// finishes a message job
void FinishMessageJob(SMessageJob *pJob);
// cancels a message job
void CancelMessageJob(SMessageJob *pJob);
// removes a message job from the list
// strip IRC formatting
static tstring StripIRCFormatting(tstring strText);
// Light status
SG15LightStatus m_G15LightStatus;
list<SMessageJob*> m_MessageJobs;
// update timer handle
UINT m_uiTimer = 0;
// screens
CNotificationScreen m_NotificationScreen;
CEventScreen m_EventScreen;
CContactlistScreen m_ContactlistScreen;
CChatScreen m_ChatScreen;
CCreditsScreen m_CreditsScreen;
CScreensaverScreen m_ScreensaverScreen;
// protocol data
vector<CProtocolData*> m_vProtocolData;
CProtocolData* GetProtocolData(tstring strProtocol);
// hook handles
HANDLE m_hMIHookMessageWindowEvent = 0;
HANDLE m_hMIHookContactIsTyping = 0;
HANDLE m_hMIHookEventAdded = 0;
HANDLE m_hMIHookStatusChanged = 0;
HANDLE m_hMIHookProtoAck = 0;
HANDLE m_hMIHookSettingChanged = 0;
HANDLE m_hMIHookContactDeleted = 0;
HANDLE m_hMIHookContactAdded = 0;
HANDLE m_hMIHookChatEvent = 0;
vector<CIRCConnection*> m_vIRCConnections;
// last active screen
CScreen *m_pLastScreen = nullptr;
bool m_bScreensaver = false;
HBITMAP m_ahStatusBitmaps[8];
HBITMAP m_ahEventBitmaps[4];
HBITMAP m_ahLargeEventBitmaps[4];
};
#endif
|