~ubuntu-branches/ubuntu/wily/psi/wily-proposed

« back to all changes in this revision

Viewing changes to iris/xmpp-im/xmpp_discoitem.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jan Niehusmann
  • Date: 2009-09-25 17:49:51 UTC
  • mfrom: (6.1.3 sid)
  • Revision ID: james.westby@ubuntu.com-20090925174951-lvm7kdap82o8xhn3
Tags: 0.13-1
* Updated to upstream version 0.13
* Set Standards-Version to 3.8.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * xmpp_discoitem.cpp
3
 
 * Copyright (C) 2003  Justin Karneges
4
 
 *
5
 
 * This library is free software; you can redistribute it and/or
6
 
 * modify it under the terms of the GNU Lesser General Public
7
 
 * License as published by the Free Software Foundation; either
8
 
 * version 2.1 of the License, or (at your option) any later version.
9
 
 *
10
 
 * This library is distributed in the hope that it will be useful,
11
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
 
 * Lesser General Public License for more details.
14
 
 *
15
 
 * You should have received a copy of the GNU Lesser General Public
16
 
 * License along with this library; if not, write to the Free Software
17
 
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18
 
 *
19
 
 */
20
 
 
21
 
#include "xmpp_discoitem.h"
22
 
 
23
 
using namespace XMPP;
24
 
 
25
 
class DiscoItem::Private
26
 
{
27
 
public:
28
 
        Private()
29
 
        {
30
 
                action = None;
31
 
        }
32
 
 
33
 
        Jid jid;
34
 
        QString name;
35
 
        QString node;
36
 
        Action action;
37
 
 
38
 
        Features features;
39
 
        Identities identities;
40
 
};
41
 
 
42
 
DiscoItem::DiscoItem()
43
 
{
44
 
        d = new Private;
45
 
}
46
 
 
47
 
DiscoItem::DiscoItem(const DiscoItem &from)
48
 
{
49
 
        d = new Private;
50
 
        *this = from;
51
 
}
52
 
 
53
 
DiscoItem & DiscoItem::operator= (const DiscoItem &from)
54
 
{
55
 
        d->jid = from.d->jid;
56
 
        d->name = from.d->name;
57
 
        d->node = from.d->node;
58
 
        d->action = from.d->action;
59
 
        d->features = from.d->features;
60
 
        d->identities = from.d->identities;
61
 
 
62
 
        return *this;
63
 
}
64
 
 
65
 
DiscoItem::~DiscoItem()
66
 
{
67
 
        delete d;
68
 
}
69
 
 
70
 
AgentItem DiscoItem::toAgentItem() const
71
 
{
72
 
        AgentItem ai;
73
 
 
74
 
        ai.setJid( jid() );
75
 
        ai.setName( name() );
76
 
 
77
 
        Identity id;
78
 
        if ( !identities().isEmpty() )
79
 
                id = identities().first();
80
 
 
81
 
        ai.setCategory( id.category );
82
 
        ai.setType( id.type );
83
 
 
84
 
        ai.setFeatures( d->features );
85
 
 
86
 
        return ai;
87
 
}
88
 
 
89
 
void DiscoItem::fromAgentItem(const AgentItem &ai)
90
 
{
91
 
        setJid( ai.jid() );
92
 
        setName( ai.name() );
93
 
 
94
 
        Identity id;
95
 
        id.category = ai.category();
96
 
        id.type = ai.type();
97
 
        id.name = ai.name();
98
 
 
99
 
        Identities idList;
100
 
        idList << id;
101
 
 
102
 
        setIdentities( idList );
103
 
 
104
 
        setFeatures( ai.features() );
105
 
}
106
 
 
107
 
const Jid &DiscoItem::jid() const
108
 
{
109
 
        return d->jid;
110
 
}
111
 
 
112
 
void DiscoItem::setJid(const Jid &j)
113
 
{
114
 
        d->jid = j;
115
 
}
116
 
 
117
 
const QString &DiscoItem::name() const
118
 
{
119
 
        return d->name;
120
 
}
121
 
 
122
 
void DiscoItem::setName(const QString &n)
123
 
{
124
 
        d->name = n;
125
 
}
126
 
 
127
 
const QString &DiscoItem::node() const
128
 
{
129
 
        return d->node;
130
 
}
131
 
 
132
 
void DiscoItem::setNode(const QString &n)
133
 
{
134
 
        d->node = n;
135
 
}
136
 
 
137
 
DiscoItem::Action DiscoItem::action() const
138
 
{
139
 
        return d->action;
140
 
}
141
 
 
142
 
void DiscoItem::setAction(Action a)
143
 
{
144
 
        d->action = a;
145
 
}
146
 
 
147
 
const Features &DiscoItem::features() const
148
 
{
149
 
        return d->features;
150
 
}
151
 
 
152
 
void DiscoItem::setFeatures(const Features &f)
153
 
{
154
 
        d->features = f;
155
 
}
156
 
 
157
 
const DiscoItem::Identities &DiscoItem::identities() const
158
 
{
159
 
        return d->identities;
160
 
}
161
 
 
162
 
void DiscoItem::setIdentities(const Identities &i)
163
 
{
164
 
        d->identities = i;
165
 
 
166
 
        if ( name().isEmpty() && i.count() )
167
 
                setName( i.first().name );
168
 
}
169
 
 
170
 
 
171
 
DiscoItem::Action DiscoItem::string2action(QString s)
172
 
{
173
 
        Action a;
174
 
 
175
 
        if ( s == "update" )
176
 
                a = Update;
177
 
        else if ( s == "remove" )
178
 
                a = Remove;
179
 
        else
180
 
                a = None;
181
 
 
182
 
        return a;
183
 
}
184
 
 
185
 
QString DiscoItem::action2string(Action a)
186
 
{
187
 
        QString s;
188
 
 
189
 
        if ( a == Update )
190
 
                s = "update";
191
 
        else if ( a == Remove )
192
 
                s = "remove";
193
 
        else
194
 
                s = QString::null;
195
 
 
196
 
        return s;
197
 
}
198
 
 
199