From bbeb2217dbaad57a221186442bba2f8842240eaf Mon Sep 17 00:00:00 2001 From: pescuma Date: Mon, 1 Feb 2010 02:03:39 +0000 Subject: iax: 0.2.0.0 + Allow more than one protocol instance git-svn-id: http://pescuma.googlecode.com/svn/trunk/Miranda@221 c086bb3d-8645-0410-b8da-73a8550f86e7 --- Protocols/IAX/iax.cpp | 47 +++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 41 insertions(+), 6 deletions(-) (limited to 'Protocols/IAX/iax.cpp') diff --git a/Protocols/IAX/iax.cpp b/Protocols/IAX/iax.cpp index 20b8af4..4d77e4f 100644 --- a/Protocols/IAX/iax.cpp +++ b/Protocols/IAX/iax.cpp @@ -30,7 +30,7 @@ PLUGININFOEX pluginInfo={ #else "IAX protocol (Ansi)", #endif - PLUGIN_MAKE_VERSION(0,1,3,0), + PLUGIN_MAKE_VERSION(0,2,0,0), "Provides support for Inter-Asterisk eXchange (IAX) protocol", "Ricardo Pescuma Domenecci", "pescuma@miranda-im.org", @@ -52,6 +52,8 @@ MM_INTERFACE mmi; UTF8_INTERFACE utfi; LIST_INTERFACE li; +void * iaxclientDllCode = NULL; + std::vector hHooks; int ModulesLoaded(WPARAM wParam, LPARAM lParam); @@ -100,13 +102,14 @@ extern "C" __declspec(dllexport) const MUUID* MirandaPluginInterfaces(void) static IAXProto *IAXProtoInit(const char* pszProtoName, const TCHAR* tszUserName) { - if (instances.getCount() != 0) + HMEMORYMODULE iaxclient = MemoryLoadLibrary((const char *) iaxclientDllCode); + if (iaxclient == NULL) { - MessageBox(NULL, TranslateT("Only one instance is allowed.\nI will crash now."), _T("IAX"), MB_OK | MB_ICONERROR); + MessageBox(NULL, TranslateT("Error loading iaxclient dll"), TranslateT("IAX"), MB_OK | MB_ICONERROR); return NULL; } - - IAXProto *proto = new IAXProto(pszProtoName, tszUserName); + + IAXProto *proto = new IAXProto(iaxclient, pszProtoName, tszUserName); instances.insert(proto); return proto; } @@ -119,11 +122,40 @@ static int IAXProtoUninit(IAXProto *proto) } +static void * LoadDllFromResource(LPCTSTR lpName) +{ + HRSRC hRes = FindResource(hInst, lpName, RT_RCDATA); + if (hRes == NULL) + return NULL; + + HGLOBAL hResLoad = LoadResource(hInst, hRes); + if (hResLoad == NULL) + return NULL; + + return LockResource(hResLoad); +} + + extern "C" int __declspec(dllexport) Load(PLUGINLINK *link) { pluginLink = link; - CHECK_VERSION("IAX") + CHECK_VERSION("IAX"); + + iaxclientDllCode = LoadDllFromResource(MAKEINTRESOURCE(IDR_IAXCLIENT_DLL)); + if (iaxclientDllCode == NULL) + { + MessageBox(NULL, TranslateT("Could not load iaxclient module"), TranslateT("IAX"), MB_OK | MB_ICONERROR); + return -1; + } + + HMEMORYMODULE iaxclient = MemoryLoadLibrary((const char *) iaxclientDllCode); + if (iaxclient == NULL) + { + MessageBox(NULL, TranslateT("Error loading iaxclient dll"), TranslateT("IAX"), MB_OK | MB_ICONERROR); + return -1; + } + MemoryFreeLibrary(iaxclient); // TODO Assert results here mir_getMMI(&mmi); @@ -154,6 +186,9 @@ extern "C" int __declspec(dllexport) Unload(void) // Called when all the modules are loaded int ModulesLoaded(WPARAM wParam, LPARAM lParam) { + if (!ServiceExists(MS_VOICESERVICE_REGISTER)) + MessageBox(NULL, TranslateT("IAX needs Voice Service plugin to work!"), _T("IAX"), MB_OK | MB_ICONERROR); + // Add our modules to the KnownModules list CallService("DBEditorpp/RegisterSingleModule", (WPARAM) MODULE_NAME, 0); -- cgit v1.2.3