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
|
/*
Import plugin for Miranda NG
Copyright (C) 2012 George Hazan
This program 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.
This program 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 this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "import.h"
#include "version.h"
#include "resource.h"
int nImportOption;
int nCustomOptions;
static HANDLE hImportService = NULL;
HINSTANCE hInst;
HANDLE hIcoHandle;
INT_PTR CALLBACK WizardDlgProc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam);
static HWND hwndWizard = NULL;
int hLangpack;
PLUGININFOEX pluginInfo =
{
sizeof(PLUGININFOEX),
"Import contacts and messages",
__VERSION_DWORD,
"Imports contacts and messages from another Miranda profile or from an external program.",
"Miranda team",
"info@miranda-im.org",
"© 2000-2010 Martin Öberg, Richard Hughes, Dmitry Kuzkin, George Hazan",
"http://miranda-ng.org/",
UNICODE_AWARE,
//{2D77A746-00A6-4343-BFC5-F808CDD772EA}
{0x2d77a746, 0xa6, 0x4343, { 0xbf, 0xc5, 0xf8, 0x8, 0xcd, 0xd7, 0x72, 0xea }}
};
BOOL WINAPI DllMain(HINSTANCE hinstDLL,DWORD fdwReason,LPVOID lpvReserved)
{
hInst = hinstDLL;
return TRUE;
}
static INT_PTR ImportCommand(WPARAM wParam,LPARAM lParam)
{
if (IsWindow(hwndWizard)) {
SetForegroundWindow(hwndWizard);
SetFocus(hwndWizard);
}
else hwndWizard = CreateDialog(hInst, MAKEINTRESOURCE(IDD_WIZARD), NULL, WizardDlgProc);
return 0;
}
/////////////////////////////////////////////////////////////////////////////////////////
// MirandaPluginInfoEx - returns an information about a plugin
extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD mirandaVersion)
{
return &pluginInfo;
}
/////////////////////////////////////////////////////////////////////////////////////////
// MirandaInterfaces - returns the protocol interface to the core
extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = {MIID_IMPORT, MIID_LAST};
/////////////////////////////////////////////////////////////////////////////////////////
// Performs a primary set of actions upon plugin loading
static int ModulesLoaded(WPARAM wParam, LPARAM lParam)
{
if (DBGetContactSettingByte(NULL, IMPORT_MODULE, IMP_KEY_FR, 0))
return 0;
// Only autorun import wizard if at least one protocol is installed
int nProtocols = 0;
PROTOACCOUNT **ppProtos = NULL;
ProtoEnumAccounts(&nProtocols, &ppProtos);
if (nProtocols > 0) {
CallService(IMPORT_SERVICE, 0, 0);
DBWriteContactSettingByte(NULL, IMPORT_MODULE, IMP_KEY_FR, 1);
}
return 0;
}
static int OnExit(WPARAM wParam, LPARAM lParam)
{
if ( hwndWizard )
SendMessage(hwndWizard, WM_CLOSE, 0, 0);
return 0;
}
static IconItem iconList[] = {
{ LPGEN("Import..."), "import_main", -IDI_IMPORT }
};
extern "C" __declspec(dllexport) int Load(void)
{
mir_getLP( &pluginInfo );
hImportService = CreateServiceFunction(IMPORT_SERVICE, ImportCommand);
// icon
Icon_Register(hInst, "Import", iconList, SIZEOF(iconList));
// menu item
CLISTMENUITEM mi = { sizeof(mi) };
mi.icolibItem = iconList[0].hIcolib;
mi.pszName = LPGEN("&Import...");
mi.position = 500050000;
mi.pszService = IMPORT_SERVICE;
mi.flags = CMIF_ICONFROMICOLIB;
Menu_AddMainMenuItem(&mi);
HookEvent(ME_SYSTEM_MODULESLOADED, ModulesLoaded);
HookEvent(ME_SYSTEM_OKTOEXIT, OnExit);
INITCOMMONCONTROLSEX icex;
icex.dwSize = sizeof(icex);
icex.dwICC = ICC_DATE_CLASSES;
InitCommonControlsEx(&icex);
return 0;
}
/////////////////////////////////////////////////////////////////////////////////////////
// Unload a plugin
extern "C" __declspec(dllexport) int Unload(void)
{
if (hImportService)
DestroyServiceFunction(hImportService);
return 0;
}
|