~ubuntu-branches/ubuntu/trusty/kvirc/trusty

« back to all changes in this revision

Viewing changes to src/kvilib/ext/KviCryptEngineManager.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Kai Wasserbäch, Kai Wasserbäch, Raúl Sánchez Siles
  • Date: 2011-02-12 10:40:21 UTC
  • mfrom: (14.1.3 sid)
  • Revision ID: james.westby@ubuntu.com-20110212104021-5mh4f75jlku20mnt
The combined "Twisted Experiment" and "Nocturnal Raid" release.

[ Kai Wasserbäch ]
* Synced to upstream's SVN revision 5467.
* debian/rules:
  - Added .PHONY line.
  - Resurrect -DMANUAL_REVISION, got lost somewhere and we build SVN
    revisions again.
  - Replace "-DWITH_NO_EMBEDDED_CODE=YES" with "-DWANT_CRYPTOPP=YES".
  - Change the remaining -DWITH/-DWITHOUT to the new -DWANT syntax.
* debian/control:
  - Removed DMUA, I'm a DD now.
  - Changed my e-mail address.
  - Removed unneeded relationships (no upgrades over two releases are
    supported).
  - Fix Suggests for kvirc-dbg.
  - kvirc-data: Make the "Suggests: kvirc" a Recommends, doesn't make much
    sense to install the -data package without the program.
* debian/source/local-options: Added with "unapply-patches".
* debian/kvirc.lintian-overrides: Updated to work for 4.1.1.
* debian/patches/21_make_shared-mime-info_B-D_superfluous.patch: Updated.
* debian/kvirc-data.install: Added .notifyrc.

[ Raúl Sánchez Siles ]
* Stating the right version where kvirc-data break and replace should happen.
* Fixing link to license file.
* Added French and Portuguese man pages.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//=============================================================================
 
2
//
 
3
//   File : KviCryptEngineManager.cpp
 
4
//   Creation date : Wed Dec 29 2010 22:10:05 CEST by Elvio Basello
 
5
//
 
6
//   This file is part of the KVIrc irc client distribution
 
7
//   Copyright (C) 2010 Elvio Basello (hellvis69 at gmail dot com)
 
8
//
 
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.
 
13
//
 
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.
 
18
//
 
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.
 
22
//
 
23
//=============================================================================
 
24
 
 
25
#include "KviCryptEngineManager.h"
 
26
#include "KviCryptEngine.h"
 
27
#include "KviCryptEngineDescription.h"
 
28
 
 
29
#ifdef COMPILE_CRYPT_SUPPORT
 
30
 
 
31
        KviCryptEngineManager::KviCryptEngineManager()
 
32
        {
 
33
                m_pEngineDict = new KviPointerHashTable<QString,KviCryptEngineDescription>;
 
34
                m_pEngineDict->setAutoDelete(true);
 
35
        }
 
36
 
 
37
        KviCryptEngineManager::~KviCryptEngineManager()
 
38
        {
 
39
                delete m_pEngineDict;
 
40
        }
 
41
 
 
42
        void KviCryptEngineManager::registerEngine(KviCryptEngineDescription * pDesc)
 
43
        {
 
44
                m_pEngineDict->replace(pDesc->m_szName,pDesc);
 
45
        }
 
46
 
 
47
        void KviCryptEngineManager::unregisterEngine(const QString & szName)
 
48
        {
 
49
                m_pEngineDict->remove(szName);
 
50
        }
 
51
 
 
52
        void KviCryptEngineManager::unregisterEngines(void * providerHandle)
 
53
        {
 
54
                KviPointerList<QString> lEnginesToRemove;
 
55
                lEnginesToRemove.setAutoDelete(true);
 
56
 
 
57
                for(KviPointerHashTableEntry<QString,KviCryptEngineDescription> * pDesc = m_pEngineDict->firstEntry();pDesc;pDesc = m_pEngineDict->nextEntry())
 
58
                {
 
59
                        if(pDesc->data()->m_providerHandle == providerHandle)
 
60
                                lEnginesToRemove.append(new QString(pDesc->key()));
 
61
                }
 
62
 
 
63
                for(QString * pszEngineName = lEnginesToRemove.first();pszEngineName;pszEngineName = lEnginesToRemove.next())
 
64
                        m_pEngineDict->remove(*pszEngineName);
 
65
        }
 
66
 
 
67
        KviCryptEngine * KviCryptEngineManager::allocateEngine(const QString & szName)
 
68
        {
 
69
                KviCryptEngineDescription * pDesc =  m_pEngineDict->find(szName);
 
70
                if(!pDesc)
 
71
                        return 0;
 
72
                KviCryptEngine * pEngine = pDesc->m_allocFunc();
 
73
                if(!pEngine)
 
74
                        return 0;
 
75
                pEngine->m_deallocFunc = pDesc->m_deallocFunc; // remember the dealloc func from now on
 
76
                return pEngine;
 
77
        }
 
78
 
 
79
        void KviCryptEngineManager::deallocateEngine(KviCryptEngine * pEngine)
 
80
        {
 
81
                if(!pEngine)
 
82
                        return;
 
83
                crypt_engine_deallocator_func deallocFunc = pEngine->m_deallocFunc;
 
84
                deallocFunc(pEngine);
 
85
        }
 
86
 
 
87
#endif // COMPILE_CRYPT_SUPPORT