annotate contact.cpp @ 6:48045176d1c6

ContactT and Ji improvments
author Goffi <goffi@goffi.org>
date Fri, 12 Aug 2011 22:08:37 +0200
parents 220e5619bf87
children 017925589d4c
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"
220e5619bf87 Profiles selection now fill contact list + new Jid class
Goffi <goffi@goffi.org>
parents:
diff changeset
20
220e5619bf87 Profiles selection now fill contact list + new Jid class
Goffi <goffi@goffi.org>
parents:
diff changeset
21 ContactT::ContactT()
6
48045176d1c6 ContactT and Ji improvments
Goffi <goffi@goffi.org>
parents: 4
diff changeset
22 :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
23 {
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 ContactT::~ContactT()
220e5619bf87 Profiles selection now fill contact list + new Jid class
Goffi <goffi@goffi.org>
parents:
diff changeset
27 {
220e5619bf87 Profiles selection now fill contact list + new Jid class
Goffi <goffi@goffi.org>
parents:
diff changeset
28 }
220e5619bf87 Profiles selection now fill contact list + new Jid class
Goffi <goffi@goffi.org>
parents:
diff changeset
29
220e5619bf87 Profiles selection now fill contact list + new Jid class
Goffi <goffi@goffi.org>
parents:
diff changeset
30
6
48045176d1c6 ContactT and Ji improvments
Goffi <goffi@goffi.org>
parents: 4
diff changeset
31 void ContactT::setProfile(const QString& profile) {
48045176d1c6 ContactT and Ji improvments
Goffi <goffi@goffi.org>
parents: 4
diff changeset
32 m_profile = profile;
48045176d1c6 ContactT and Ji improvments
Goffi <goffi@goffi.org>
parents: 4
diff changeset
33 }
48045176d1c6 ContactT and Ji improvments
Goffi <goffi@goffi.org>
parents: 4
diff changeset
34
48045176d1c6 ContactT and Ji improvments
Goffi <goffi@goffi.org>
parents: 4
diff changeset
35 const QString& ContactT::getProfile() const {
48045176d1c6 ContactT and Ji improvments
Goffi <goffi@goffi.org>
parents: 4
diff changeset
36 return m_profile;
48045176d1c6 ContactT and Ji improvments
Goffi <goffi@goffi.org>
parents: 4
diff changeset
37 }
48045176d1c6 ContactT and Ji improvments
Goffi <goffi@goffi.org>
parents: 4
diff changeset
38
48045176d1c6 ContactT and Ji improvments
Goffi <goffi@goffi.org>
parents: 4
diff changeset
39 void ContactT::setAttributes(const QHash<QString, QString>& attr) {
48045176d1c6 ContactT and Ji improvments
Goffi <goffi@goffi.org>
parents: 4
diff changeset
40 m_name = attr.value("name");
48045176d1c6 ContactT and Ji improvments
Goffi <goffi@goffi.org>
parents: 4
diff changeset
41 m_presence_to = attr.value("to") == "True";
48045176d1c6 ContactT and Ji improvments
Goffi <goffi@goffi.org>
parents: 4
diff changeset
42 m_presence_from = attr.value("from") == "True";
48045176d1c6 ContactT and Ji improvments
Goffi <goffi@goffi.org>
parents: 4
diff changeset
43 m_presence_ask = attr.value("ask") == "True";
4
220e5619bf87 Profiles selection now fill contact list + new Jid class
Goffi <goffi@goffi.org>
parents:
diff changeset
44 }
220e5619bf87 Profiles selection now fill contact list + new Jid class
Goffi <goffi@goffi.org>
parents:
diff changeset
45
6
48045176d1c6 ContactT and Ji improvments
Goffi <goffi@goffi.org>
parents: 4
diff changeset
46 QHash<QString, QString> ContactT::getAttributes() const {
48045176d1c6 ContactT and Ji improvments
Goffi <goffi@goffi.org>
parents: 4
diff changeset
47 QHash<QString, QString> attr;
48045176d1c6 ContactT and Ji improvments
Goffi <goffi@goffi.org>
parents: 4
diff changeset
48 if (jid.isValid()) {
48045176d1c6 ContactT and Ji improvments
Goffi <goffi@goffi.org>
parents: 4
diff changeset
49 attr["name"] = m_name;
48045176d1c6 ContactT and Ji improvments
Goffi <goffi@goffi.org>
parents: 4
diff changeset
50 attr["to"] = m_presence_to ? "True" : "False";
48045176d1c6 ContactT and Ji improvments
Goffi <goffi@goffi.org>
parents: 4
diff changeset
51 attr["from"] = m_presence_from ? "True" : "False";
48045176d1c6 ContactT and Ji improvments
Goffi <goffi@goffi.org>
parents: 4
diff changeset
52 attr["ask"] = m_presence_ask ? "True" : "False";
48045176d1c6 ContactT and Ji improvments
Goffi <goffi@goffi.org>
parents: 4
diff changeset
53 }
4
220e5619bf87 Profiles selection now fill contact list + new Jid class
Goffi <goffi@goffi.org>
parents:
diff changeset
54
6
48045176d1c6 ContactT and Ji improvments
Goffi <goffi@goffi.org>
parents: 4
diff changeset
55 return attr;
48045176d1c6 ContactT and Ji improvments
Goffi <goffi@goffi.org>
parents: 4
diff changeset
56 }
48045176d1c6 ContactT and Ji improvments
Goffi <goffi@goffi.org>
parents: 4
diff changeset
57
48045176d1c6 ContactT and Ji improvments
Goffi <goffi@goffi.org>
parents: 4
diff changeset
58 const QString& ContactT::getName() const {
48045176d1c6 ContactT and Ji improvments
Goffi <goffi@goffi.org>
parents: 4
diff changeset
59 return m_name;
48045176d1c6 ContactT and Ji improvments
Goffi <goffi@goffi.org>
parents: 4
diff changeset
60 }
48045176d1c6 ContactT and Ji improvments
Goffi <goffi@goffi.org>
parents: 4
diff changeset
61
48045176d1c6 ContactT and Ji improvments
Goffi <goffi@goffi.org>
parents: 4
diff changeset
62 bool ContactT::isConnected() {
48045176d1c6 ContactT and Ji improvments
Goffi <goffi@goffi.org>
parents: 4
diff changeset
63 return m_connected;
48045176d1c6 ContactT and Ji improvments
Goffi <goffi@goffi.org>
parents: 4
diff changeset
64 }
48045176d1c6 ContactT and Ji improvments
Goffi <goffi@goffi.org>
parents: 4
diff changeset
65