~ubuntu-branches/ubuntu/wily/sflphone/wily

« back to all changes in this revision

Viewing changes to kde/src/lib/phonenumber.h

  • Committer: Package Import Robot
  • Author(s): Mark Purcell
  • Date: 2014-01-28 18:23:36 UTC
  • mfrom: (1.1.11)
  • mto: This revision was merged to the branch mainline in revision 24.
  • Revision ID: package-import@ubuntu.com-20140128182336-3xenud1kbnwmf3mz
* New upstream release 
  - Fixes "New Upstream Release" (Closes: #735846)
  - Fixes "Ringtone does not stop" (Closes: #727164)
  - Fixes "[sflphone-kde] crash on startup" (Closes: #718178)
  - Fixes "sflphone GUI crashes when call is hung up" (Closes: #736583)
* Build-Depends: ensure GnuTLS 2.6
  - libucommon-dev (>= 6.0.7-1.1), libccrtp-dev (>= 2.0.6-3)
  - Fixes "FTBFS Build-Depends libgnutls{26,28}-dev" (Closes: #722040)
* Fix "boost 1.49 is going away" unversioned Build-Depends: (Closes: #736746)
* Add Build-Depends: libsndfile-dev, nepomuk-core-dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/****************************************************************************
 
2
 *   Copyright (C) 2013-2014 by Savoir-Faire Linux                          *
 
3
 *   Author : Emmanuel Lepage Vallee <emmanuel.lepage@savoirfairelinux.com> *
 
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 General Public License      *
 
16
 *   along with this program.  If not, see <http://www.gnu.org/licenses/>.  *
 
17
 ***************************************************************************/
 
18
#ifndef PHONENUMBER_H
 
19
#define PHONENUMBER_H
 
20
 
 
21
#include "typedefs.h"
 
22
 
 
23
//Qt
 
24
#include <QStringList>
 
25
#include <QtCore/QSize>
 
26
#include <QtCore/QObject>
 
27
 
 
28
//SFLPhone
 
29
class Account;
 
30
class Contact;
 
31
class Call;
 
32
class PhoneNumberPrivate;
 
33
class TemporaryPhoneNumber;
 
34
class NumberCategory;
 
35
 
 
36
///PhoneNumber: represent a phone number
 
37
class LIB_EXPORT PhoneNumber : public QObject {
 
38
   Q_OBJECT
 
39
public:
 
40
   friend class PhoneDirectoryModel;
 
41
   virtual ~PhoneNumber();
 
42
 
 
43
   //Properties
 
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           )
 
66
 
 
67
//    Q_PROPERTY(QHash<QString,int> alternativeNames READ alternativeNames         )
 
68
 
 
69
   ///@enum Type: Is this temporary, blank, used or unused
 
70
   enum class Type {
 
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               */
 
76
   };
 
77
   Q_ENUMS(Type)
 
78
 
 
79
   //Getters
 
80
   QString            uri             () const;
 
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;
 
104
 
 
105
   //Setters
 
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      );
 
113
 
 
114
   //Mutator
 
115
   Q_INVOKABLE void addCall(Call* call);
 
116
   Q_INVOKABLE void incrementAlternativeName(const QString& name);
 
117
 
 
118
   //Static
 
119
   static const PhoneNumber* BLANK();
 
120
 
 
121
   //Helper
 
122
   QString toHash() const;
 
123
 
 
124
protected:
 
125
   //Constructor
 
126
   PhoneNumber(const QString& uri, NumberCategory* cat, Type st = Type::UNUSED);
 
127
 
 
128
   //Attributes
 
129
   QString            m_Uri  ;
 
130
   PhoneNumber::Type  m_Type ;
 
131
 
 
132
   //Helper
 
133
   static QString stripUri(const QString& uri);
 
134
 
 
135
   //Private setters
 
136
   void setPresent(bool present);
 
137
   void setPresenceMessage(const QString& message);
 
138
 
 
139
private:
 
140
   friend class PhoneNumberPrivate;
 
141
 
 
142
   //Attributes
 
143
   NumberCategory*    m_pCategory        ;
 
144
   bool               m_Present          ;
 
145
   QString            m_PresentMessage   ;
 
146
   bool               m_Tracked          ;
 
147
   Contact*           m_pContact         ;
 
148
   Account*           m_pAccount         ;
 
149
   time_t             m_LastUsed         ;
 
150
   QList<Call*>       m_lCalls           ;
 
151
   int                m_PopularityIndex  ;
 
152
   QString            m_MostCommonName   ;
 
153
   QHash<QString,int> m_hNames           ;
 
154
   bool               m_hasType          ;
 
155
   uint               m_LastWeekCount    ;
 
156
   uint               m_LastTrimCount    ;
 
157
   bool               m_HaveCalled       ;
 
158
   uint               m_Index            ;
 
159
   bool               m_IsBookmark       ;
 
160
   int                m_TotalSeconds     ;
 
161
   QString            m_Uid              ;
 
162
 
 
163
   //Static attributes
 
164
   static QHash<int,Call*> m_shMostUsed  ;
 
165
   static const PhoneNumber* m_spBlank   ;
 
166
 
 
167
private Q_SLOTS:
 
168
   void accountDestroyed(QObject* o);
 
169
 
 
170
Q_SIGNALS:
 
171
   void callAdded(Call* call);
 
172
   void changed  (          );
 
173
   void presentChanged(bool);
 
174
   void presenceMessageChanged(QString);
 
175
   void trackedChanged(bool);
 
176
};
 
177
 
 
178
Q_DECLARE_METATYPE(PhoneNumber*)
 
179
 
 
180
///@class TemporaryPhoneNumber: An incomplete phone number
 
181
class LIB_EXPORT TemporaryPhoneNumber : public PhoneNumber {
 
182
   Q_OBJECT
 
183
public:
 
184
   explicit TemporaryPhoneNumber(const PhoneNumber* number = nullptr);
 
185
   void setUri(const QString& uri);
 
186
};
 
187
 
 
188
#endif