diff options
Diffstat (limited to 'protocols/YAMN/src/protoplugin.cpp')
-rw-r--r-- | protocols/YAMN/src/protoplugin.cpp | 134 |
1 files changed, 57 insertions, 77 deletions
diff --git a/protocols/YAMN/src/protoplugin.cpp b/protocols/YAMN/src/protoplugin.cpp index c119f887bb..c6e6a6aecc 100644 --- a/protocols/YAMN/src/protoplugin.cpp +++ b/protocols/YAMN/src/protoplugin.cpp @@ -6,17 +6,16 @@ #include "stdafx.h" -//-------------------------------------------------------------------------------------------------- -//-------------------------------------------------------------------------------------------------- + //-------------------------------------------------------------------------------------------------- -PYAMN_PROTOPLUGINQUEUE FirstProtoPlugin=nullptr; +PYAMN_PROTOPLUGINQUEUE FirstProtoPlugin = nullptr; -INT_PTR RegisterProtocolPluginSvc(WPARAM,LPARAM); +INT_PTR RegisterProtocolPluginSvc(WPARAM, LPARAM); //Removes plugin from queue and deletes registration structures INT_PTR UnregisterProtocolPlugin(HYAMNPROTOPLUGIN Plugin); -INT_PTR UnregisterProtocolPluginSvc(WPARAM,LPARAM); +INT_PTR UnregisterProtocolPluginSvc(WPARAM, LPARAM); //Removes plugins from queue and deletes registration structures INT_PTR UnregisterProtoPlugins(); @@ -28,53 +27,50 @@ INT_PTR UnregisterProtoPlugins(); // YAMNMailFcn- pointer to imported functions with mails // YAMNMailFcnVer- version of YAMN_MAILIMPORTFCN, use YAMN_MAILIMPORTFCNVERSION // returns nonzero if success -int WINAPI SetProtocolPluginFcnImportFcn(HYAMNPROTOPLUGIN Plugin,PYAMN_PROTOIMPORTFCN YAMNFcn,uint32_t YAMNFcnVer,PYAMN_MAILIMPORTFCN YAMNMailFcn,uint32_t YAMNMailFcnVer); +int WINAPI SetProtocolPluginFcnImportFcn(HYAMNPROTOPLUGIN Plugin, PYAMN_PROTOIMPORTFCN YAMNFcn, uint32_t YAMNFcnVer, PYAMN_MAILIMPORTFCN YAMNMailFcn, uint32_t YAMNMailFcnVer); -struct CExportedFunctions ProtoPluginExportedFcn[]= +struct CExportedFunctions ProtoPluginExportedFcn[] = { - {YAMN_SETPROTOCOLPLUGINFCNIMPORTID,(void *)SetProtocolPluginFcnImportFcn}, + {YAMN_SETPROTOCOLPLUGINFCNIMPORTID, (void *)SetProtocolPluginFcnImportFcn}, }; -struct CExportedServices ProtoPluginExportedSvc[]= +struct CExportedServices ProtoPluginExportedSvc[] = { - {MS_YAMN_REGISTERPROTOPLUGIN,RegisterProtocolPluginSvc}, - {MS_YAMN_UNREGISTERPROTOPLUGIN,UnregisterProtocolPluginSvc}, - {MS_YAMN_GETFILENAME,GetFileNameSvc}, - {MS_YAMN_DELETEFILENAME,DeleteFileNameSvc}, + {MS_YAMN_REGISTERPROTOPLUGIN, RegisterProtocolPluginSvc}, + {MS_YAMN_UNREGISTERPROTOPLUGIN, UnregisterProtocolPluginSvc}, + {MS_YAMN_GETFILENAME, GetFileNameSvc}, + {MS_YAMN_DELETEFILENAME, DeleteFileNameSvc}, }; //-------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------- -INT_PTR RegisterProtocolPluginSvc(WPARAM wParam,LPARAM lParam) +INT_PTR RegisterProtocolPluginSvc(WPARAM wParam, LPARAM lParam) { - PYAMN_PROTOREGISTRATION Registration=(PYAMN_PROTOREGISTRATION)wParam; + PYAMN_PROTOREGISTRATION Registration = (PYAMN_PROTOREGISTRATION)wParam; HYAMNPROTOPLUGIN Plugin; if (lParam != YAMN_PROTOREGISTRATIONVERSION) return 0; - if ((Registration->Name==nullptr) || (Registration->Ver==nullptr)) + if ((Registration->Name == nullptr) || (Registration->Ver == nullptr)) return (INT_PTR)NULL; - if (nullptr==(Plugin=new YAMN_PROTOPLUGIN)) + if (nullptr == (Plugin = new YAMN_PROTOPLUGIN)) return (INT_PTR)NULL; - Plugin->PluginInfo=Registration; + Plugin->PluginInfo = Registration; - Plugin->FirstAccount=nullptr; + Plugin->FirstAccount = nullptr; - Plugin->AccountBrowserSO=new SWMRG; - SWMRGInitialize(Plugin->AccountBrowserSO,nullptr); + Plugin->AccountBrowserSO = new SWMRG; + SWMRGInitialize(Plugin->AccountBrowserSO, nullptr); - Plugin->Fcn=nullptr; - Plugin->MailFcn=nullptr; + Plugin->Fcn = nullptr; + Plugin->MailFcn = nullptr; -#ifdef DEBUG_SYNCHRO - DebugLog(SynchroFile,"::: YAMN- new protocol registered: %0x (%s) :::\n",Plugin,Registration->Name); -#endif return (INT_PTR)Plugin; } -int WINAPI SetProtocolPluginFcnImportFcn(HYAMNPROTOPLUGIN Plugin,PYAMN_PROTOIMPORTFCN YAMNFcn,uint32_t YAMNFcnVer,PYAMN_MAILIMPORTFCN YAMNMailFcn,uint32_t YAMNMailFcnVer) +int WINAPI SetProtocolPluginFcnImportFcn(HYAMNPROTOPLUGIN Plugin, PYAMN_PROTOIMPORTFCN YAMNFcn, uint32_t YAMNFcnVer, PYAMN_MAILIMPORTFCN YAMNMailFcn, uint32_t YAMNMailFcnVer) { PYAMN_PROTOPLUGINQUEUE Parser; @@ -82,82 +78,66 @@ int WINAPI SetProtocolPluginFcnImportFcn(HYAMNPROTOPLUGIN Plugin,PYAMN_PROTOIMPO return 0; if (YAMNMailFcnVer != YAMN_MAILIMPORTFCNVERSION) return 0; - if (YAMNFcn==nullptr) + if (YAMNFcn == nullptr) return 0; - if (YAMNMailFcn==nullptr) + if (YAMNMailFcn == nullptr) return 0; -#ifdef DEBUG_SYNCHRO - DebugLog(SynchroFile,"::: YAMN- protocol %0x import succeed :::\n",Plugin); -#endif - Plugin->Fcn=YAMNFcn; - Plugin->MailFcn=YAMNMailFcn; + Plugin->Fcn = YAMNFcn; + Plugin->MailFcn = YAMNMailFcn; mir_cslock lck(PluginRegCS); // We add protocol to the protocol list - for (Parser=FirstProtoPlugin;Parser != nullptr && Parser->Next != nullptr;Parser=Parser->Next); - if (Parser==nullptr) - { - FirstProtoPlugin=new YAMN_PROTOPLUGINQUEUE; - Parser=FirstProtoPlugin; + for (Parser = FirstProtoPlugin; Parser != nullptr && Parser->Next != nullptr; Parser = Parser->Next); + if (Parser == nullptr) { + FirstProtoPlugin = new YAMN_PROTOPLUGINQUEUE; + Parser = FirstProtoPlugin; } - else - { - Parser->Next=new YAMN_PROTOPLUGINQUEUE; - Parser=Parser->Next; + else { + Parser->Next = new YAMN_PROTOPLUGINQUEUE; + Parser = Parser->Next; } - Parser->Plugin=Plugin; - Parser->Next=nullptr; + Parser->Plugin = Plugin; + Parser->Next = nullptr; return 1; } INT_PTR UnregisterProtocolPlugin(HYAMNPROTOPLUGIN Plugin) { - PYAMN_PROTOPLUGINQUEUE Parser,Found; - -#ifdef DEBUG_SYNCHRO - DebugLog(SynchroFile,"Entering UnregisterProtocolPlugin\n"); -#endif - if (FirstProtoPlugin->Plugin==Plugin) - { - Found=FirstProtoPlugin; - FirstProtoPlugin=FirstProtoPlugin->Next; + PYAMN_PROTOPLUGINQUEUE Parser, Found; + + if (FirstProtoPlugin->Plugin == Plugin) { + Found = FirstProtoPlugin; + FirstProtoPlugin = FirstProtoPlugin->Next; } - else - { - for (Parser=FirstProtoPlugin;(Parser->Next != nullptr) && (Plugin != Parser->Next->Plugin);Parser=Parser->Next); - if (Parser->Next != nullptr) - { - Found=Parser->Next; - Parser->Next=Parser->Next->Next; + else { + for (Parser = FirstProtoPlugin; (Parser->Next != nullptr) && (Plugin != Parser->Next->Plugin); Parser = Parser->Next); + if (Parser->Next != nullptr) { + Found = Parser->Next; + Parser->Next = Parser->Next->Next; } else - Found=nullptr; + Found = nullptr; } - if (Found != nullptr) - { + if (Found != nullptr) { StopAccounts(Plugin); DeleteAccounts(Plugin); if (Plugin->Fcn->UnLoadFcn != nullptr) Plugin->Fcn->UnLoadFcn((void *)nullptr); - + delete Found->Plugin->AccountBrowserSO; delete Found->Plugin; delete Found; - -#ifdef DEBUG_SYNCHRO - DebugLog(SynchroFile,"::: YAMN- protocol %0x unregistered :::\n",Plugin); -#endif } else return 0; return 1; } -INT_PTR UnregisterProtocolPluginSvc(WPARAM wParam,LPARAM) +INT_PTR UnregisterProtocolPluginSvc(WPARAM wParam, LPARAM) { - HYAMNPROTOPLUGIN Plugin=(HYAMNPROTOPLUGIN)wParam; + HYAMNPROTOPLUGIN Plugin = (HYAMNPROTOPLUGIN)wParam; mir_cslock lck(PluginRegCS); UnregisterProtocolPlugin(Plugin); @@ -168,25 +148,25 @@ INT_PTR UnregisterProtoPlugins() { mir_cslock lck(PluginRegCS); // We remove protocols from the protocol list - while(FirstProtoPlugin != nullptr) + while (FirstProtoPlugin != nullptr) UnregisterProtocolPlugin(FirstProtoPlugin->Plugin); return 1; } -INT_PTR GetFileNameSvc(WPARAM wParam,LPARAM) +INT_PTR GetFileNameSvc(WPARAM wParam, LPARAM) { wchar_t *FileName = new wchar_t[MAX_PATH]; if (FileName == nullptr) return NULL; - mir_snwprintf(FileName, MAX_PATH, L"%s\\yamn-accounts.%s.%s.book", UserDirectory, (wchar_t*)wParam, ProfileName); + mir_snwprintf(FileName, MAX_PATH, L"%s\\yamn-accounts.%s.%s.book", UserDirectory, (wchar_t *)wParam, ProfileName); return (INT_PTR)FileName; } -INT_PTR DeleteFileNameSvc(WPARAM wParam,LPARAM) +INT_PTR DeleteFileNameSvc(WPARAM wParam, LPARAM) { - if (( wchar_t* )wParam != nullptr) - delete[] ( wchar_t* ) wParam; + if ((wchar_t *)wParam != nullptr) + delete[](wchar_t *) wParam; return 0; } |