1/*
2 Copyright (c) 2009 Constantin Berzan <exit3219@gmail.com>
3
4 This library is free software; you can redistribute it and/or modify it
5 under the terms of the GNU Library General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or (at your
7 option) any later version.
8
9 This library is distributed in the hope that it will be useful, but WITHOUT
10 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
12 License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to the
16 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17 02110-1301, USA.
18*/
19
20#include "transporttype.h"
21#include "transporttype_p.h"
22#include "transport.h"
23
24#include <akonadi/agentmanager.h>
25
26using namespace MailTransport;
27
28TransportType::TransportType()
29 : d( new Private )
30{
31}
32
33TransportType::TransportType( const TransportType &other )
34 : d( other.d )
35{
36}
37
38TransportType::~TransportType()
39{
40}
41
42TransportType &TransportType::operator=( const TransportType &other )
43{
44 if ( this != &other ) {
45 d = other.d;
46 }
47 return *this;
48}
49
50bool TransportType::operator==( const TransportType &other ) const
51{
52 if ( d->mType == Transport::EnumType::Akonadi &&
53 other.d->mType == Transport::EnumType::Akonadi ) {
54 return ( d->mAgentType == other.d->mAgentType );
55 }
56 return ( d->mType == other.d->mType );
57}
58
59bool TransportType::isValid() const
60{
61 using namespace Akonadi;
62
63 if ( d->mType == Transport::EnumType::Akonadi ) {
64 return d->mAgentType.isValid() &&
65 AgentManager::self()->types().contains( d->mAgentType );
66 } else {
67 return d->mType >= 0;
68 }
69}
70
71TransportBase::EnumType::type TransportType::type() const
72{
73 return static_cast<TransportBase::EnumType::type>( d->mType );
74}
75
76QString TransportType::name() const
77{
78 return d->mName;
79}
80
81QString TransportType::description() const
82{
83 return d->mDescription;
84}
85
86Akonadi::AgentType TransportType::agentType() const
87{
88 Q_ASSERT( d->mType == Transport::EnumType::Akonadi );
89 return d->mAgentType;
90}
91