1
/****************************************************************************
2
* Copyright (C) 2013-2014 by Savoir-Faire Linux *
3
* Author : Emmanuel Lepage Vallee <emmanuel.lepage@savoirfairelinux.com> *
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. *
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. *
15
* You should have received a copy of the GNU General Public License *
16
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
17
***************************************************************************/
24
#include <QStringList>
25
#include <QtCore/QSize>
26
#include <QtCore/QObject>
32
class PhoneNumberPrivate;
33
class TemporaryPhoneNumber;
36
///PhoneNumber: represent a phone number
37
class LIB_EXPORT PhoneNumber : public QObject {
40
friend class PhoneDirectoryModel;
41
virtual ~PhoneNumber();
44
Q_PROPERTY(Account* account READ account WRITE setAccount)
45
Q_PROPERTY(Contact* contact READ contact WRITE setContact)
46
Q_PROPERTY(int lastUsed READ lastUsed )
47
Q_PROPERTY(QString uri READ uri )
48
Q_PROPERTY(int callCount READ callCount )
49
Q_PROPERTY(QList<Call*> calls READ calls )
50
Q_PROPERTY(int popularityIndex READ popularityIndex )
51
Q_PROPERTY(bool bookmarked READ isBookmarked )
52
Q_PROPERTY(QString uid READ uid WRITE setUid )
53
Q_PROPERTY(bool isTracked READ isTracked NOTIFY trackedChanged )
54
Q_PROPERTY(bool isPresent READ isPresent NOTIFY presentChanged )
55
Q_PROPERTY(bool supportPresence READ supportPresence )
56
Q_PROPERTY(QString presenceMessage READ presenceMessage NOTIFY presenceMessageChanged )
57
Q_PROPERTY(uint weekCount READ weekCount )
58
Q_PROPERTY(uint trimCount READ trimCount )
59
Q_PROPERTY(bool haveCalled READ haveCalled )
60
Q_PROPERTY(QString hostname READ hostname )
61
Q_PROPERTY(QString fullUri READ fullUri )
62
Q_PROPERTY(QString primaryName READ primaryName )
63
Q_PROPERTY(bool isBookmarked READ isBookmarked )
64
Q_PROPERTY(QVariant icon READ icon )
65
Q_PROPERTY(int totalSpentTime READ totalSpentTime )
67
// Q_PROPERTY(QHash<QString,int> alternativeNames READ alternativeNames )
69
///@enum Type: Is this temporary, blank, used or unused
71
BLANK = 0, /*This number represent no number */
72
TEMPORARY = 1, /*This number is not yet complete */
73
USED = 2, /*This number have been called before */
74
UNUSED = 3, /*This number have never been called, but is in the address book */
75
ACCOUNT = 4, /*This number correspond to the URI of a SIP account */
81
NumberCategory* category () const;
82
bool isTracked () const;
83
bool isPresent () const;
84
QString presenceMessage () const;
85
Account* account () const;
86
Contact* contact () const;
87
time_t lastUsed () const;
88
PhoneNumber::Type type () const;
89
int callCount () const;
90
uint weekCount () const;
91
uint trimCount () const;
92
bool haveCalled () const;
93
QList<Call*> calls () const;
94
int popularityIndex () const;
95
QHash<QString,int> alternativeNames() const;
96
QString hostname () const;
97
QString fullUri () const;
98
QString primaryName () const;
99
bool isBookmarked () const;
100
bool supportPresence () const;
101
QVariant icon () const;
102
int totalSpentTime () const;
103
QString uid () const;
106
Q_INVOKABLE void setAccount(Account* account);
107
Q_INVOKABLE void setContact(Contact* contact);
108
Q_INVOKABLE void setTracked(bool track );
109
void setCategory(NumberCategory* cat );
110
void setBookmarked(bool bookmarked );
111
void setUid(const QString& uri );
112
bool setType(PhoneNumber::Type t );
115
Q_INVOKABLE void addCall(Call* call);
116
Q_INVOKABLE void incrementAlternativeName(const QString& name);
119
static const PhoneNumber* BLANK();
122
QString toHash() const;
126
PhoneNumber(const QString& uri, NumberCategory* cat, Type st = Type::UNUSED);
130
PhoneNumber::Type m_Type ;
133
static QString stripUri(const QString& uri);
136
void setPresent(bool present);
137
void setPresenceMessage(const QString& message);
140
friend class PhoneNumberPrivate;
143
NumberCategory* m_pCategory ;
145
QString m_PresentMessage ;
147
Contact* m_pContact ;
148
Account* m_pAccount ;
150
QList<Call*> m_lCalls ;
151
int m_PopularityIndex ;
152
QString m_MostCommonName ;
153
QHash<QString,int> m_hNames ;
155
uint m_LastWeekCount ;
156
uint m_LastTrimCount ;
164
static QHash<int,Call*> m_shMostUsed ;
165
static const PhoneNumber* m_spBlank ;
168
void accountDestroyed(QObject* o);
171
void callAdded(Call* call);
173
void presentChanged(bool);
174
void presenceMessageChanged(QString);
175
void trackedChanged(bool);
178
Q_DECLARE_METATYPE(PhoneNumber*)
180
///@class TemporaryPhoneNumber: An incomplete phone number
181
class LIB_EXPORT TemporaryPhoneNumber : public PhoneNumber {
184
explicit TemporaryPhoneNumber(const PhoneNumber* number = nullptr);
185
void setUri(const QString& uri);