~ubuntu-branches/ubuntu/natty/kadu/natty

« back to all changes in this revision

Viewing changes to kadu-core/protocols_manager.cpp

  • Committer: Package Import Robot
  • Author(s): Kiszel Kristóf
  • Date: 2010-07-21 15:24:54 UTC
  • mfrom: (0.6.1) (0.5.1) (1.4.1) (22.1.2 maverick)
  • Revision ID: package-import@ubuntu.com-20100721152454-vttqle18lovfudni
Tags: 0.6.5.4.ds1-3ubuntu2
Remove libqt4-webkit-dev from build-depends and add
libqtwebkit-dev for qtwebkit transition

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/***************************************************************************
 
2
 *                                                                         *
 
3
 *   This program is free software; you can redistribute it and/or modify  *
 
4
 *   it under the terms of the GNU General Public License as published by  *
 
5
 *   the Free Software Foundation; either version 2 of the License, or     *
 
6
 *   (at your option) any later version.                                   *
 
7
 *                                                                         *
 
8
 ***************************************************************************/
 
9
 
 
10
#include "debug.h"
 
11
#include "misc.h"
 
12
 
 
13
#include "protocols_manager.h"
 
14
 
 
15
ProtocolsManager::ProtocolsManager()
 
16
        : QObject(), protocolDescriptions(), protocols()
 
17
{
 
18
}
 
19
 
 
20
ProtocolsManager::~ProtocolsManager()
 
21
{
 
22
}
 
23
 
 
24
void ProtocolsManager::initModule()
 
25
{
 
26
        protocols_manager = new ProtocolsManager();
 
27
}
 
28
 
 
29
void ProtocolsManager::closeModule()
 
30
{
 
31
        delete protocols_manager;
 
32
        protocols_manager = 0;
 
33
}
 
34
 
 
35
void ProtocolsManager::registerProtocol(const QString &protocolID, const QString &name, ProtocolManager *manager)
 
36
{
 
37
        protocolDescriptions.append(ProtocolDescription(protocolID, name, manager));
 
38
}
 
39
 
 
40
void ProtocolsManager::unregisterProtocol(const QString &protocolID)
 
41
{
 
42
        foreach(const ProtocolDescription &protoDesc, protocolDescriptions)
 
43
                if (protoDesc.protocolID == protocolID)
 
44
                {
 
45
                        protocolDescriptions.removeAll(protoDesc);
 
46
                        return;
 
47
                }
 
48
 
 
49
        kdebugm(KDEBUG_WARNING, "protocol(%s) not found\n", qPrintable(protocolID));
 
50
}
 
51
 
 
52
QList<Protocol *> ProtocolsManager::byProtocolID(const QString &protocolID)
 
53
{
 
54
        QList<Protocol *> ret;
 
55
 
 
56
        foreach(Protocol *proto, protocols)
 
57
                if (proto->protocolID() == protocolID)
 
58
                        ret.append(proto);
 
59
 
 
60
        if (ret.size() == 0)
 
61
                kdebugm(KDEBUG_WARNING, "protocol(%s) not found\n", qPrintable(protocolID));
 
62
 
 
63
        return ret;
 
64
}
 
65
 
 
66
Protocol * ProtocolsManager::byID(const QString &protocolID, const QString &ID)
 
67
{
 
68
        foreach(Protocol *proto, protocols)
 
69
                if (proto->protocolID() == protocolID && proto->ID() == ID)
 
70
                        return proto;
 
71
 
 
72
        kdebugm(KDEBUG_WARNING, "protocol,id(%s,%s) not found\n", qPrintable(protocolID), qPrintable(ID));
 
73
        return 0;
 
74
}
 
75
 
 
76
Protocol * ProtocolsManager::newProtocol(const QString &protocolID, const QString &ID)
 
77
{
 
78
        Protocol *proto = 0;
 
79
        foreach(const ProtocolDescription &protoDesc, protocolDescriptions)
 
80
                if (protoDesc.protocolID == protocolID)
 
81
                {
 
82
                        proto = protoDesc.Manager->newInstance(ID);
 
83
                        break;
 
84
                }
 
85
 
 
86
        if (proto)
 
87
                protocols.append(proto);
 
88
        else
 
89
                kdebugm(KDEBUG_WARNING, "protocol(%s) not found\n", qPrintable(protocolID));
 
90
 
 
91
        return proto;
 
92
}
 
93
 
 
94
ProtocolsManager *protocols_manager;