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
|
/*
* Miranda IM LCD Plugin
* Displays incoming text messages on an LCD.
*
* Copyright (c) 2003 Martin Rubli, mrubli@gmx.net
*
******************************************************************************
* This file is part of Miranda IM LCD Plugin.
*
* Miranda IM LCD Plugin 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.
*
* Miranda IM LCD Plugin 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 Miranda IM LCD Plugin; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
******************************************************************************
*
* Miranda.cpp: Miranda plugin initialisation
*/
#ifdef _DEBUG
#include <crtdbg.h>
#define _CRTDBG_MAP_ALLOC
#endif
#include "StdAfx.h"
#include "CAppletManager.h"
#include "CConfig.h"
#include "m_system.h"
// SETTINGS
#define LCD_FPS 10
//************************************************************************
// Variables
//************************************************************************
bool g_bInitialized;
// AppletManager object
CAppletManager* g_AppletManager;
// Plugin Information
HINSTANCE hInstance;
int hLangpack;
// {58D63981-14C1-4099-A3F7-F4FAA4C8FC59}
#define MIID_G15APPLET { 0x58d63981, 0x14c1, 0x4099, { 0xa3, 0xf7, 0xf4, 0xfa, 0xa4, 0xc8, 0xfc, 0x59 } }
extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = {MIID_G15APPLET, MIID_LAST};
static PLUGININFOEX pluginInfo = {
sizeof(PLUGININFOEX),
APP_NAME,
PLUGIN_MAKE_VERSION(0,1,2,0),
"Provides an interface to use Miranda from the LCD of various Logitech devices",
"Martin Kleinhans",
"mail@mkleinhans.de",
"© 2009 Martin Kleinhans",
"http://www.mkleinhans.de",
UNICODE_AWARE, // not transient
// {798221E1-E47A-4dc8-9077-1E576F9C4307}
{ 0x798221e1, 0xe47a, 0x4dc8, { 0x90, 0x77, 0x1e, 0x57, 0x6f, 0x9c, 0x43, 0x7 } }
};
// Function Prototypes
int Init(WPARAM,LPARAM);
void UnInit();
//************************************************************************
// Exported Functions
//************************************************************************
extern "C" {
__declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD mirandaVersion)
{
return &pluginInfo;
}
// Called by Miranda to load the plugin.
// We defer initialization until Miranda's module loading process completed and return 0 to
// mark success, everything else will cause the plugin to be freed right away.
int __declspec(dllexport) Load()
{
g_bInitialized = false;
InitDebug();
TRACE(_T("Plugin loaded\n"));
// Schedule actual initialization for later
HookEvent(ME_SYSTEM_MODULESLOADED, Init);
return 0;
}
// Called by Miranda when the plugin should unload itself.
int __declspec(dllexport) Unload(void)
{
if(!g_bInitialized) {
TRACE(_T("ERROR: Unload requested, but plugin is not initialized?!\n"));
return 0;
}
TRACE(_T("-------------------------------------------\nUnloading started\n"));
UnInit();
TRACE(_T("Unloading successful\n"));
TRACE(_T("Cleaning up: "));
UnInitDebug();
TRACE(_T("OK!\n"));
return 0;
}
}
//************************************************************************
// DllMain
//
// EntryPoint of the DLL
//************************************************************************
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
hInstance = hinstDLL;
return TRUE;
}
//************************************************************************
// Init
//
// Called after Miranda has finished loading all modules
// This is where the main plugin initialization happens and the
// connection to the LCD is established,
//************************************************************************
int Init(WPARAM wParam,LPARAM lParam)
{
g_AppletManager = new CAppletManager();
// Memoryleak Detection
#ifdef _DEBUG
_CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
#endif
// set up the LCD context as non-autostart, non-persist, callbacked
CConfig::Initialize();
// Initialize the output object
if(!g_AppletManager->Initialize(toTstring(APP_SHORTNAME)))
{
if(CConfig::GetBoolSetting(SKIP_DRIVER_ERROR)) {
tstring text = _T("Failed to initialize the LCD connection\n Make sure you have the newest Logitech drivers installed (>=1.03).\n");
tstring title = _T(APP_SHORTNAME);
MessageBox(NULL, text.c_str(), title.c_str(), MB_OK | MB_ICONEXCLAMATION);
}
TRACE(_T("Initialization failed!.\n"));
return 0;
}
g_bInitialized = true;
TRACE(_T("Initialization completed successfully.\n-------------------------------------------\n"));
return 0;
}
//************************************************************************
// UnInit
//
// Called when the plugin is about to be unloaded
//************************************************************************
void UnInit(void)
{
g_AppletManager->Shutdown();
delete g_AppletManager;
//#ifdef _DEBUG
// _CrtDumpMemoryLeaks();
//#endif
}
|