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

« back to all changes in this revision

Viewing changes to kde/src/lib/abstractcontactbackend.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) 2009-2014 by Savoir-Faire Linux                          *
 
3
 *   Author : Jérémy Quentin <jeremy.quentin@savoirfairelinux.com>          *
 
4
 *            Emmanuel Lepage Vallee <emmanuel.lepage@savoirfairelinux.com> *
 
5
 *                                                                          *
 
6
 *   This library is free software; you can redistribute it and/or          *
 
7
 *   modify it under the terms of the GNU Lesser General Public             *
 
8
 *   License as published by the Free Software Foundation; either           *
 
9
 *   version 2.1 of the License, or (at your option) any later version.     *
 
10
 *                                                                          *
 
11
 *   This library is distributed in the hope that it will be useful,        *
 
12
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of         *
 
13
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU      *
 
14
 *   Lesser General Public License for more details.                        *
 
15
 *                                                                          *
 
16
 *   You should have received a copy of the GNU General Public License      *
 
17
 *   along with this program.  If not, see <http://www.gnu.org/licenses/>.  *
 
18
 ***************************************************************************/
 
19
#ifndef ABSTRACTCONTACTBACKEND_H
 
20
#define ABSTRACTCONTACTBACKEND_H
 
21
 
 
22
#include <QObject>
 
23
#include <QHash>
 
24
#include <QStringList>
 
25
#include <QVariant>
 
26
#include <QtCore/QAbstractItemModel>
 
27
 
 
28
#include "typedefs.h"
 
29
#include "contact.h"
 
30
 
 
31
//SFLPhone
 
32
class Contact;
 
33
class Account;
 
34
 
 
35
//Typedef
 
36
typedef QList<Contact*> ContactList;
 
37
 
 
38
///AbstractContactBackend: Allow different way to handle contact without poluting the library
 
39
class LIB_EXPORT AbstractContactBackend : public QAbstractItemModel {
 
40
   #pragma GCC diagnostic push
 
41
   #pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant"
 
42
   Q_OBJECT
 
43
   #pragma GCC diagnostic pop
 
44
public:
 
45
   enum Role {
 
46
      Organization      = 100,
 
47
      Group             = 101,
 
48
      Department        = 102,
 
49
      PreferredEmail    = 103,
 
50
      FormattedLastUsed = 104,
 
51
      IndexedLastUsed   = 105,
 
52
      DatedLastUsed     = 106,
 
53
      Active            = 107,
 
54
      Filter            = 200, //All roles, all at once
 
55
      DropState         = 300, //State for drag and drop
 
56
   };
 
57
 
 
58
   explicit AbstractContactBackend(QObject* parent = nullptr);
 
59
   virtual ~AbstractContactBackend();
 
60
 
 
61
   ///Get a contact using a phone number
 
62
   ///@param resolveDNS interpret the number as is (false) or parse it to extract the domain and number (true)
 
63
//    virtual Contact*    getContactByPhone ( const QString& phoneNumber , bool resolveDNS = false, Account* a = nullptr) = 0;
 
64
 
 
65
   ///Return a contact (or nullptr) according to the contact unique identifier
 
66
   virtual Contact*    getContactByUid   ( const QString& uid         ) = 0;
 
67
   ///Edit 'contact', the implementation may be a GUI or somehting else
 
68
   virtual void        editContact       ( Contact*       contact     ) = 0;
 
69
   ///Add a new contact to the backend
 
70
   virtual void        addNewContact     ( Contact*       contact     ) = 0;
 
71
   
 
72
   virtual const ContactList& getContactList() const = 0;
 
73
 
 
74
   ///Add a new phone number to an existing contact
 
75
   virtual void addPhoneNumber( Contact*       contact , QString  number, QString type )=0;
 
76
 
 
77
   //Model implementation
 
78
   virtual bool          setData     ( const QModelIndex& index, const QVariant &value, int role   )  __attribute__ ((const));
 
79
   virtual QVariant      data        ( const QModelIndex& index, int role = Qt::DisplayRole        ) const;
 
80
   virtual int           rowCount    ( const QModelIndex& parent = QModelIndex()                   ) const;
 
81
   virtual Qt::ItemFlags flags       ( const QModelIndex& index                                    ) const;
 
82
   virtual int           columnCount ( const QModelIndex& parent = QModelIndex()                   ) const;
 
83
   virtual QModelIndex   parent      ( const QModelIndex& index                                    ) const;
 
84
   virtual QModelIndex   index       ( int row, int column, const QModelIndex& parent=QModelIndex()) const;
 
85
   virtual QVariant      headerData  ( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const;
 
86
 
 
87
   int getUpdateCount();
 
88
 
 
89
protected:
 
90
   virtual ContactList update_slot() = 0;
 
91
 
 
92
   //Helper
 
93
   QString getUserFromPhone    (const QString &phoneNumber);
 
94
 
 
95
   //Attributes
 
96
   QHash<QString,Contact*>        m_ContactByUid   ;
 
97
   int m_UpdatesCounter;
 
98
public Q_SLOTS:
 
99
   ContactList update();
 
100
 
 
101
private Q_SLOTS:
 
102
   void slotReloadModel();
 
103
 
 
104
Q_SIGNALS:
 
105
   void collectionChanged();
 
106
   void newContactAdded(Contact* c);
 
107
};
 
108
 
 
109
#endif