summaryrefslogtreecommitdiff
path: root/protocols/YAMN/src/protoplugin.cpp
diff options
context:
space:
mode:
authorKirill Volinsky <mataes2007@gmail.com>2012-10-14 09:45:11 +0000
committerKirill Volinsky <mataes2007@gmail.com>2012-10-14 09:45:11 +0000
commit4b6899c098f97960bf58456313ac8d643336dcd0 (patch)
treee04b9a7e1ddcff868fe81c2a6db3716c49d11c2f /protocols/YAMN/src/protoplugin.cpp
parente179ffc995c96568bfdce46ac73f58d569166f05 (diff)
YAMN: folders restructurization
git-svn-id: http://svn.miranda-ng.org/main/trunk@1919 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/YAMN/src/protoplugin.cpp')
-rw-r--r--protocols/YAMN/src/protoplugin.cpp197
1 files changed, 197 insertions, 0 deletions
diff --git a/protocols/YAMN/src/protoplugin.cpp b/protocols/YAMN/src/protoplugin.cpp
new file mode 100644
index 0000000000..479b54ce67
--- /dev/null
+++ b/protocols/YAMN/src/protoplugin.cpp
@@ -0,0 +1,197 @@
+/*
+ * YAMN plugin export functions for protocols
+ *
+ * (c) majvan 2002-2004
+ */
+
+#include "yamn.h"
+
+//--------------------------------------------------------------------------------------------------
+//--------------------------------------------------------------------------------------------------
+
+PYAMN_PROTOPLUGINQUEUE FirstProtoPlugin=NULL;
+
+INT_PTR RegisterProtocolPluginSvc(WPARAM,LPARAM);
+
+//Removes plugin from queue and deletes registration structures
+INT_PTR UnregisterProtocolPlugin(HYAMNPROTOPLUGIN Plugin);
+
+INT_PTR UnregisterProtocolPluginSvc(WPARAM,LPARAM);
+
+//Removes plugins from queue and deletes registration structures
+INT_PTR UnregisterProtoPlugins();
+
+//Sets imported functions for an plugin and therefore it starts plugin to be registered and running
+// Plugin- plugin, which wants to set its functions
+// YAMNFcn- pointer to imported functions with accounts
+// YAMNFcnVer- version of YAMN_PROTOIMPORTFCN, use YAMN_PROTOIMPORTFCNVERSION
+// 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,DWORD YAMNFcnVer,PYAMN_MAILIMPORTFCN YAMNMailFcn,DWORD YAMNMailFcnVer);
+
+struct CExportedFunctions ProtoPluginExportedFcn[]=
+{
+ {YAMN_SETPROTOCOLPLUGINFCNIMPORTID,(void *)SetProtocolPluginFcnImportFcn},
+};
+
+struct CExportedServices ProtoPluginExportedSvc[]=
+{
+ {MS_YAMN_REGISTERPROTOPLUGIN,RegisterProtocolPluginSvc},
+ {MS_YAMN_UNREGISTERPROTOPLUGIN,UnregisterProtocolPluginSvc},
+ {MS_YAMN_GETFILENAME,GetFileNameSvc},
+ {MS_YAMN_DELETEFILENAME,DeleteFileNameSvc},
+};
+
+//--------------------------------------------------------------------------------------------------
+//--------------------------------------------------------------------------------------------------
+
+INT_PTR RegisterProtocolPluginSvc(WPARAM wParam,LPARAM lParam)
+{
+ PYAMN_PROTOREGISTRATION Registration=(PYAMN_PROTOREGISTRATION)wParam;
+ HYAMNPROTOPLUGIN Plugin;
+
+ if (lParam!=YAMN_PROTOREGISTRATIONVERSION)
+ return 0;
+ if ((Registration->Name==NULL) || (Registration->Ver==NULL))
+ return (INT_PTR)NULL;
+ if (NULL==(Plugin=new YAMN_PROTOPLUGIN))
+ return (INT_PTR)NULL;
+
+ Plugin->PluginInfo=Registration;
+
+ Plugin->FirstAccount=NULL;
+
+ Plugin->AccountBrowserSO=new SWMRG;
+ SWMRGInitialize(Plugin->AccountBrowserSO,NULL);
+
+ Plugin->Fcn=NULL;
+ Plugin->MailFcn=NULL;
+
+#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,DWORD YAMNFcnVer,PYAMN_MAILIMPORTFCN YAMNMailFcn,DWORD YAMNMailFcnVer)
+{
+ PYAMN_PROTOPLUGINQUEUE Parser;
+
+ if (YAMNFcnVer!=YAMN_PROTOIMPORTFCNVERSION)
+ return 0;
+ if (YAMNMailFcnVer!=YAMN_MAILIMPORTFCNVERSION)
+ return 0;
+ if (YAMNFcn==NULL)
+ return 0;
+ if (YAMNMailFcn==NULL)
+ return 0;
+
+#ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"::: YAMN- protocol %0x import succeed :::\n",Plugin);
+#endif
+ Plugin->Fcn=YAMNFcn;
+ Plugin->MailFcn=YAMNMailFcn;
+
+ EnterCriticalSection(&PluginRegCS);
+//We add protocol to the protocol list
+ for (Parser=FirstProtoPlugin;Parser!=NULL && Parser->Next!=NULL;Parser=Parser->Next);
+ if (Parser==NULL)
+ {
+ FirstProtoPlugin=new YAMN_PROTOPLUGINQUEUE;
+ Parser=FirstProtoPlugin;
+ }
+ else
+ {
+ Parser->Next=new YAMN_PROTOPLUGINQUEUE;
+ Parser=Parser->Next;
+ }
+
+ Parser->Plugin=Plugin;
+ Parser->Next=NULL;
+
+ LeaveCriticalSection(&PluginRegCS);
+ 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;
+ }
+ else
+ {
+ for (Parser=FirstProtoPlugin;(Parser->Next!=NULL) && (Plugin!=Parser->Next->Plugin);Parser=Parser->Next);
+ if (Parser->Next!=NULL)
+ {
+ Found=Parser->Next;
+ Parser->Next=Parser->Next->Next;
+ }
+ else
+ Found=NULL;
+ }
+ if (Found!=NULL)
+ {
+ StopAccounts(Plugin);
+ DeleteAccounts(Plugin);
+ if (Plugin->Fcn->UnLoadFcn!=NULL)
+ Plugin->Fcn->UnLoadFcn((void *)0);
+
+ 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 lParam)
+{
+ HYAMNPROTOPLUGIN Plugin=(HYAMNPROTOPLUGIN)wParam;
+
+ EnterCriticalSection(&PluginRegCS);
+ UnregisterProtocolPlugin(Plugin);
+ LeaveCriticalSection(&PluginRegCS);
+ return 1;
+
+}
+
+INT_PTR UnregisterProtoPlugins()
+{
+ EnterCriticalSection(&PluginRegCS);
+//We remove protocols from the protocol list
+ while(FirstProtoPlugin!=NULL)
+ UnregisterProtocolPlugin(FirstProtoPlugin->Plugin);
+ LeaveCriticalSection(&PluginRegCS);
+ return 1;
+}
+
+INT_PTR GetFileNameSvc(WPARAM wParam,LPARAM)
+{
+ TCHAR *FileName = new TCHAR[MAX_PATH];
+ if (FileName == NULL)
+ return NULL;
+
+ mir_sntprintf(FileName, MAX_PATH, _T("%s\\yamn-accounts.%s.%s.book"), UserDirectory, wParam, ProfileName);
+ return (INT_PTR)FileName;
+}
+
+INT_PTR DeleteFileNameSvc(WPARAM wParam,LPARAM)
+{
+ if (( TCHAR* )wParam != NULL)
+ delete[] ( TCHAR* ) wParam;
+
+ return 0;
+}