annotate contact.cpp @ 11:98485ebbdb86 default tip

LayoutView: WidgetViewBox fix
author Goffi <goffi@goffi.org>
date Sat, 27 Aug 2011 00:31:20 +0200
parents 017925589d4c
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4
220e5619bf87 Profiles selection now fill contact list + new Jid class
Goffi <goffi@goffi.org>
parents:
diff changeset
1 /*
220e5619bf87 Profiles selection now fill contact list + new Jid class
Goffi <goffi@goffi.org>
parents:
diff changeset
2 Bellaciao: a Salut à Toi frontend
220e5619bf87 Profiles selection now fill contact list + new Jid class
Goffi <goffi@goffi.org>
parents:
diff changeset
3 Copyright (C) 2011 Jérôme Poisson (goffi@goffi.org)
220e5619bf87 Profiles selection now fill contact list + new Jid class
Goffi <goffi@goffi.org>
parents:
diff changeset
4
220e5619bf87 Profiles selection now fill contact list + new Jid class
Goffi <goffi@goffi.org>
parents:
diff changeset
5 This program is free software: you can redistribute it and/or modify
220e5619bf87 Profiles selection now fill contact list + new Jid class
Goffi <goffi@goffi.org>
parents:
diff changeset
6 it under the terms of the GNU Affero General Public License as published by
220e5619bf87 Profiles selection now fill contact list + new Jid class
Goffi <goffi@goffi.org>
parents:
diff changeset
7 the Free Software Foundation, either version 3 of the License, or
220e5619bf87 Profiles selection now fill contact list + new Jid class
Goffi <goffi@goffi.org>
parents:
diff changeset
8 (at your option) any later version.
220e5619bf87 Profiles selection now fill contact list + new Jid class
Goffi <goffi@goffi.org>
parents:
diff changeset
9
220e5619bf87 Profiles selection now fill contact list + new Jid class
Goffi <goffi@goffi.org>
parents:
diff changeset
10 This program is distributed in the hope that it will be useful,
220e5619bf87 Profiles selection now fill contact list + new Jid class
Goffi <goffi@goffi.org>
parents:
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
220e5619bf87 Profiles selection now fill contact list + new Jid class
Goffi <goffi@goffi.org>
parents:
diff changeset
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
220e5619bf87 Profiles selection now fill contact list + new Jid class
Goffi <goffi@goffi.org>
parents:
diff changeset
13 GNU Affero General Public License for more details.
220e5619bf87 Profiles selection now fill contact list + new Jid class
Goffi <goffi@goffi.org>
parents:
diff changeset
14
220e5619bf87 Profiles selection now fill contact list + new Jid class
Goffi <goffi@goffi.org>
parents:
diff changeset
15 You should have received a copy of the GNU Affero General Public License
220e5619bf87 Profiles selection now fill contact list + new Jid class
Goffi <goffi@goffi.org>
parents:
diff changeset
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
220e5619bf87 Profiles selection now fill contact list + new Jid class
Goffi <goffi@goffi.org>
parents:
diff changeset
17 */
220e5619bf87 Profiles selection now fill contact list + new Jid class
Goffi <goffi@goffi.org>
parents:
diff changeset
18
220e5619bf87 Profiles selection now fill contact list + new Jid class
Goffi <goffi@goffi.org>
parents:
diff changeset
19 #include "contact.h"
7
017925589d4c Contact (formerly ContactT) now use shared data
Goffi <goffi@goffi.org>
parents: 6
diff changeset
20 #include <QDebug>
4
220e5619bf87 Profiles selection now fill contact list + new Jid class
Goffi <goffi@goffi.org>
parents:
diff changeset
21
7
017925589d4c Contact (formerly ContactT) now use shared data
Goffi <goffi@goffi.org>
parents: 6
diff changeset
22 ContactData::ContactData()
6
48045176d1c6 ContactT and Ji improvments
Goffi <goffi@goffi.org>
parents: 4
diff changeset
23 :m_connected(false), m_presence_to(false), m_presence_from(false), m_presence_ask(false)
4
220e5619bf87 Profiles selection now fill contact list + new Jid class
Goffi <goffi@goffi.org>
parents:
diff changeset
24 {
220e5619bf87 Profiles selection now fill contact list + new Jid class
Goffi <goffi@goffi.org>
parents:
diff changeset
25 }
220e5619bf87 Profiles selection now fill contact list + new Jid class
Goffi <goffi@goffi.org>
parents:
diff changeset
26
7
017925589d4c Contact (formerly ContactT) now use shared data
Goffi <goffi@goffi.org>
parents: 6
diff changeset
27 ContactData::ContactData(const ContactData& other)
017925589d4c Contact (formerly ContactT) now use shared data
Goffi <goffi@goffi.org>
parents: 6
diff changeset
28 :QSharedData(other), jid(other.jid), groups(other.groups), m_connected(other.m_connected),
017925589d4c Contact (formerly ContactT) now use shared data
Goffi <goffi@goffi.org>
parents: 6
diff changeset
29 m_presence_to(other.m_presence_to), m_presence_from(other.m_presence_from),
017925589d4c Contact (formerly ContactT) now use shared data
Goffi <goffi@goffi.org>
parents: 6
diff changeset
30 m_presence_ask(other.m_presence_ask), m_profile(other.m_profile), m_name(other.m_name)
4
220e5619bf87 Profiles selection now fill contact list + new Jid class
Goffi <goffi@goffi.org>
parents:
diff changeset
31 {
220e5619bf87 Profiles selection now fill contact list + new Jid class
Goffi <goffi@goffi.org>
parents:
diff changeset
32 }
220e5619bf87 Profiles selection now fill contact list + new Jid class
Goffi <goffi@goffi.org>
parents:
diff changeset
33
220e5619bf87 Profiles selection now fill contact list + new Jid class
Goffi <goffi@goffi.org>
parents:
diff changeset
34
7
017925589d4c Contact (formerly ContactT) now use shared data
Goffi <goffi@goffi.org>
parents: 6
diff changeset
35 Contact::Contact()
017925589d4c Contact (formerly ContactT) now use shared data
Goffi <goffi@goffi.org>
parents: 6
diff changeset
36 {
017925589d4c Contact (formerly ContactT) now use shared data
Goffi <goffi@goffi.org>
parents: 6
diff changeset
37 d = new ContactData;
017925589d4c Contact (formerly ContactT) now use shared data
Goffi <goffi@goffi.org>
parents: 6
diff changeset
38 }
017925589d4c Contact (formerly ContactT) now use shared data
Goffi <goffi@goffi.org>
parents: 6
diff changeset
39
017925589d4c Contact (formerly ContactT) now use shared data
Goffi <goffi@goffi.org>
parents: 6
diff changeset
40 Contact::Contact(const Contact& other)
017925589d4c Contact (formerly ContactT) now use shared data
Goffi <goffi@goffi.org>
parents: 6
diff changeset
41 : d(other.d)
017925589d4c Contact (formerly ContactT) now use shared data
Goffi <goffi@goffi.org>
parents: 6
diff changeset
42 {
6
48045176d1c6 ContactT and Ji improvments
Goffi <goffi@goffi.org>
parents: 4
diff changeset
43 }
48045176d1c6 ContactT and Ji improvments
Goffi <goffi@goffi.org>
parents: 4
diff changeset
44
7
017925589d4c Contact (formerly ContactT) now use shared data
Goffi <goffi@goffi.org>
parents: 6
diff changeset
45 Jid& Contact::getJid() {
017925589d4c Contact (formerly ContactT) now use shared data
Goffi <goffi@goffi.org>
parents: 6
diff changeset
46 return d->jid;
017925589d4c Contact (formerly ContactT) now use shared data
Goffi <goffi@goffi.org>
parents: 6
diff changeset
47 }
017925589d4c Contact (formerly ContactT) now use shared data
Goffi <goffi@goffi.org>
parents: 6
diff changeset
48
017925589d4c Contact (formerly ContactT) now use shared data
Goffi <goffi@goffi.org>
parents: 6
diff changeset
49 const Jid& Contact::getJid() const {
017925589d4c Contact (formerly ContactT) now use shared data
Goffi <goffi@goffi.org>
parents: 6
diff changeset
50 return d->jid;
017925589d4c Contact (formerly ContactT) now use shared data
Goffi <goffi@goffi.org>
parents: 6
diff changeset
51 }
017925589d4c Contact (formerly ContactT) now use shared data
Goffi <goffi@goffi.org>
parents: 6
diff changeset
52
017925589d4c Contact (formerly ContactT) now use shared data
Goffi <goffi@goffi.org>
parents: 6
diff changeset
53 QList<QString>& Contact::getGroups() {
017925589d4c Contact (formerly ContactT) now use shared data
Goffi <goffi@goffi.org>
parents: 6
diff changeset
54 return d->groups;
017925589d4c Contact (formerly ContactT) now use shared data
Goffi <goffi@goffi.org>
parents: 6
diff changeset
55 }
017925589d4c Contact (formerly ContactT) now use shared data
Goffi <goffi@goffi.org>
parents: 6
diff changeset
56
017925589d4c Contact (formerly ContactT) now use shared data
Goffi <goffi@goffi.org>
parents: 6
diff changeset
57 const QList<QString>& Contact::getGroups() const {
017925589d4c Contact (formerly ContactT) now use shared data
Goffi <goffi@goffi.org>
parents: 6
diff changeset
58 return d->groups;
6
48045176d1c6 ContactT and Ji improvments
Goffi <goffi@goffi.org>
parents: 4
diff changeset
59 }
48045176d1c6 ContactT and Ji improvments
Goffi <goffi@goffi.org>
parents: 4
diff changeset
60
7
017925589d4c Contact (formerly ContactT) now use shared data
Goffi <goffi@goffi.org>
parents: 6
diff changeset
61 void Contact::setProfile(const QString& profile)
017925589d4c Contact (formerly ContactT) now use shared data
Goffi <goffi@goffi.org>
parents: 6
diff changeset
62 {
017925589d4c Contact (formerly ContactT) now use shared data
Goffi <goffi@goffi.org>
parents: 6
diff changeset
63 d->m_profile = profile;
017925589d4c Contact (formerly ContactT) now use shared data
Goffi <goffi@goffi.org>
parents: 6
diff changeset
64 }
017925589d4c Contact (formerly ContactT) now use shared data
Goffi <goffi@goffi.org>
parents: 6
diff changeset
65
017925589d4c Contact (formerly ContactT) now use shared data
Goffi <goffi@goffi.org>
parents: 6
diff changeset
66 const QString& Contact::getProfile() const
017925589d4c Contact (formerly ContactT) now use shared data
Goffi <goffi@goffi.org>
parents: 6
diff changeset
67 {
017925589d4c Contact (formerly ContactT) now use shared data
Goffi <goffi@goffi.org>
parents: 6
diff changeset
68 return d->m_profile;
4
220e5619bf87 Profiles selection now fill contact list + new Jid class
Goffi <goffi@goffi.org>
parents:
diff changeset
69 }
220e5619bf87 Profiles selection now fill contact list + new Jid class
Goffi <goffi@goffi.org>
parents:
diff changeset
70
7
017925589d4c Contact (formerly ContactT) now use shared data
Goffi <goffi@goffi.org>
parents: 6
diff changeset
71 void Contact::setAttributes(const QHash<QString, QString>& attr)
017925589d4c Contact (formerly ContactT) now use shared data
Goffi <goffi@goffi.org>
parents: 6
diff changeset
72 {
017925589d4c Contact (formerly ContactT) now use shared data
Goffi <goffi@goffi.org>
parents: 6
diff changeset
73 d->m_name = attr.value("name");
017925589d4c Contact (formerly ContactT) now use shared data
Goffi <goffi@goffi.org>
parents: 6
diff changeset
74 d->m_presence_to = attr.value("to") == "True";
017925589d4c Contact (formerly ContactT) now use shared data
Goffi <goffi@goffi.org>
parents: 6
diff changeset
75 d->m_presence_from = attr.value("from") == "True";
017925589d4c Contact (formerly ContactT) now use shared data
Goffi <goffi@goffi.org>
parents: 6
diff changeset
76 d->m_presence_ask = attr.value("ask") == "True";
017925589d4c Contact (formerly ContactT) now use shared data
Goffi <goffi@goffi.org>
parents: 6
diff changeset
77 }
017925589d4c Contact (formerly ContactT) now use shared data
Goffi <goffi@goffi.org>
parents: 6
diff changeset
78
017925589d4c Contact (formerly ContactT) now use shared data
Goffi <goffi@goffi.org>
parents: 6
diff changeset
79 QHash<QString, QString> Contact::getAttributes() const
017925589d4c Contact (formerly ContactT) now use shared data
Goffi <goffi@goffi.org>
parents: 6
diff changeset
80 {
6
48045176d1c6 ContactT and Ji improvments
Goffi <goffi@goffi.org>
parents: 4
diff changeset
81 QHash<QString, QString> attr;
7
017925589d4c Contact (formerly ContactT) now use shared data
Goffi <goffi@goffi.org>
parents: 6
diff changeset
82 if (d->jid.isValid()) {
017925589d4c Contact (formerly ContactT) now use shared data
Goffi <goffi@goffi.org>
parents: 6
diff changeset
83 attr["name"] = d->m_name;
017925589d4c Contact (formerly ContactT) now use shared data
Goffi <goffi@goffi.org>
parents: 6
diff changeset
84 attr["to"] = d->m_presence_to ? "True" : "False";
017925589d4c Contact (formerly ContactT) now use shared data
Goffi <goffi@goffi.org>
parents: 6
diff changeset
85 attr["from"] = d->m_presence_from ? "True" : "False";
017925589d4c Contact (formerly ContactT) now use shared data
Goffi <goffi@goffi.org>
parents: 6
diff changeset
86 attr["ask"] = d->m_presence_ask ? "True" : "False";
6
48045176d1c6 ContactT and Ji improvments
Goffi <goffi@goffi.org>
parents: 4
diff changeset
87 }
4
220e5619bf87 Profiles selection now fill contact list + new Jid class
Goffi <goffi@goffi.org>
parents:
diff changeset
88
6
48045176d1c6 ContactT and Ji improvments
Goffi <goffi@goffi.org>
parents: 4
diff changeset
89 return attr;
48045176d1c6 ContactT and Ji improvments
Goffi <goffi@goffi.org>
parents: 4
diff changeset
90 }
48045176d1c6 ContactT and Ji improvments
Goffi <goffi@goffi.org>
parents: 4
diff changeset
91
7
017925589d4c Contact (formerly ContactT) now use shared data
Goffi <goffi@goffi.org>
parents: 6
diff changeset
92 const QString& Contact::getName() const
017925589d4c Contact (formerly ContactT) now use shared data
Goffi <goffi@goffi.org>
parents: 6
diff changeset
93 {
017925589d4c Contact (formerly ContactT) now use shared data
Goffi <goffi@goffi.org>
parents: 6
diff changeset
94 return d->m_name;
6
48045176d1c6 ContactT and Ji improvments
Goffi <goffi@goffi.org>
parents: 4
diff changeset
95 }
48045176d1c6 ContactT and Ji improvments
Goffi <goffi@goffi.org>
parents: 4
diff changeset
96
7
017925589d4c Contact (formerly ContactT) now use shared data
Goffi <goffi@goffi.org>
parents: 6
diff changeset
97 void Contact::setName(const QString& name)
017925589d4c Contact (formerly ContactT) now use shared data
Goffi <goffi@goffi.org>
parents: 6
diff changeset
98 {
017925589d4c Contact (formerly ContactT) now use shared data
Goffi <goffi@goffi.org>
parents: 6
diff changeset
99 d->m_name = name;
6
48045176d1c6 ContactT and Ji improvments
Goffi <goffi@goffi.org>
parents: 4
diff changeset
100 }
48045176d1c6 ContactT and Ji improvments
Goffi <goffi@goffi.org>
parents: 4
diff changeset
101
7
017925589d4c Contact (formerly ContactT) now use shared data
Goffi <goffi@goffi.org>
parents: 6
diff changeset
102 bool Contact::isConnected()
017925589d4c Contact (formerly ContactT) now use shared data
Goffi <goffi@goffi.org>
parents: 6
diff changeset
103 {
017925589d4c Contact (formerly ContactT) now use shared data
Goffi <goffi@goffi.org>
parents: 6
diff changeset
104 return d->m_connected;
017925589d4c Contact (formerly ContactT) now use shared data
Goffi <goffi@goffi.org>
parents: 6
diff changeset
105 }
017925589d4c Contact (formerly ContactT) now use shared data
Goffi <goffi@goffi.org>
parents: 6
diff changeset
106