1
//=============================================================================
3
// File : KviCryptEngineManager.cpp
4
// Creation date : Wed Dec 29 2010 22:10:05 CEST by Elvio Basello
6
// This file is part of the KVIrc irc client distribution
7
// Copyright (C) 2010 Elvio Basello (hellvis69 at gmail dot com)
9
// This program is FREE software. You can redistribute it and/or
10
// modify it under the terms of the GNU General Public License
11
// as published by the Free Software Foundation; either version 2
12
// of the License, or (at your opinion) any later version.
14
// This program is distributed in the HOPE that it will be USEFUL,
15
// but WITHOUT ANY WARRANTY; without even the implied warranty of
16
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
17
// See the GNU General Public License for more details.
19
// You should have received a copy of the GNU General Public License
20
// along with this program. If not, write to the Free Software Foundation,
21
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23
//=============================================================================
25
#include "KviCryptEngineManager.h"
26
#include "KviCryptEngine.h"
27
#include "KviCryptEngineDescription.h"
29
#ifdef COMPILE_CRYPT_SUPPORT
31
KviCryptEngineManager::KviCryptEngineManager()
33
m_pEngineDict = new KviPointerHashTable<QString,KviCryptEngineDescription>;
34
m_pEngineDict->setAutoDelete(true);
37
KviCryptEngineManager::~KviCryptEngineManager()
42
void KviCryptEngineManager::registerEngine(KviCryptEngineDescription * pDesc)
44
m_pEngineDict->replace(pDesc->m_szName,pDesc);
47
void KviCryptEngineManager::unregisterEngine(const QString & szName)
49
m_pEngineDict->remove(szName);
52
void KviCryptEngineManager::unregisterEngines(void * providerHandle)
54
KviPointerList<QString> lEnginesToRemove;
55
lEnginesToRemove.setAutoDelete(true);
57
for(KviPointerHashTableEntry<QString,KviCryptEngineDescription> * pDesc = m_pEngineDict->firstEntry();pDesc;pDesc = m_pEngineDict->nextEntry())
59
if(pDesc->data()->m_providerHandle == providerHandle)
60
lEnginesToRemove.append(new QString(pDesc->key()));
63
for(QString * pszEngineName = lEnginesToRemove.first();pszEngineName;pszEngineName = lEnginesToRemove.next())
64
m_pEngineDict->remove(*pszEngineName);
67
KviCryptEngine * KviCryptEngineManager::allocateEngine(const QString & szName)
69
KviCryptEngineDescription * pDesc = m_pEngineDict->find(szName);
72
KviCryptEngine * pEngine = pDesc->m_allocFunc();
75
pEngine->m_deallocFunc = pDesc->m_deallocFunc; // remember the dealloc func from now on
79
void KviCryptEngineManager::deallocateEngine(KviCryptEngine * pEngine)
83
crypt_engine_deallocator_func deallocFunc = pEngine->m_deallocFunc;
87
#endif // COMPILE_CRYPT_SUPPORT