plugins/contacts/maemo5/qcontactabook_p.h
changeset 0 876b1a06bc25
child 5 603d3f8b6302
equal deleted inserted replaced
-1:000000000000 0:876b1a06bc25
       
     1 /****************************************************************************
       
     2 **
       
     3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
       
     4 ** All rights reserved.
       
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
       
     6 **
       
     7 ** This file is part of the Qt Mobility Components.
       
     8 **
       
     9 ** $QT_BEGIN_LICENSE:LGPL$
       
    10 ** No Commercial Usage
       
    11 ** This file contains pre-release code and may not be distributed.
       
    12 ** You may use this file in accordance with the terms and conditions
       
    13 ** contained in the Technology Preview License Agreement accompanying
       
    14 ** this package.
       
    15 **
       
    16 ** GNU Lesser General Public License Usage
       
    17 ** Alternatively, this file may be used under the terms of the GNU Lesser
       
    18 ** General Public License version 2.1 as published by the Free Software
       
    19 ** Foundation and appearing in the file LICENSE.LGPL included in the
       
    20 ** packaging of this file.  Please review the following information to
       
    21 ** ensure the GNU Lesser General Public License version 2.1 requirements
       
    22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
       
    23 **
       
    24 ** In addition, as a special exception, Nokia gives you certain additional
       
    25 ** rights.  These rights are described in the Nokia Qt LGPL Exception
       
    26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
       
    27 **
       
    28 ** If you have questions regarding the use of this file, please contact
       
    29 ** Nokia at qt-info@nokia.com.
       
    30 **
       
    31 **
       
    32 **
       
    33 **
       
    34 **
       
    35 **
       
    36 **
       
    37 **
       
    38 ** $QT_END_LICENSE$
       
    39 **
       
    40 ****************************************************************************/
       
    41 
       
    42 #ifndef QCONTACTABOOK_P_H
       
    43 #define QCONTACTABOOK_P_H
       
    44 
       
    45 #include <QObject>
       
    46 #include <QMutex>
       
    47 
       
    48 #include "qtcontacts.h"
       
    49 #include "qcontactmaemo5debug_p.h"
       
    50 
       
    51 #undef signals
       
    52 #include <libosso-abook/osso-abook.h>
       
    53 #include <gdk-pixbuf/gdk-pixbuf.h>
       
    54 
       
    55 #include "qcontactidshash.h"
       
    56 
       
    57 QTM_USE_NAMESPACE
       
    58 
       
    59 /* Data shared with contact changes/added/removed callbacks */
       
    60 struct cbSharedData;
       
    61 /* Data shared with job callbacks */
       
    62 struct jobSharedData;
       
    63 
       
    64 class QContactABook : public QObject
       
    65 {
       
    66   Q_OBJECT
       
    67   
       
    68 public:  
       
    69   QContactABook(QObject* parent = 0);
       
    70   ~QContactABook();
       
    71   
       
    72   QList<QContactLocalId> contactIds(const QContactFilter& filter, const QList<QContactSortOrder>& sortOrders, QContactManager::Error* error) const;
       
    73   //QList<QContactLocalId> contactIds(const QList<QContactSortOrder>& sortOrders, QContactManager::Error* error) const;
       
    74   QContact* getQContact(const QContactLocalId& contactId, QContactManager::Error* error) const;
       
    75   bool removeContact(const QContactLocalId& contactId, QContactManager::Error* error);
       
    76   bool saveContact(QContact* contact, QContactManager::Error* error);
       
    77 
       
    78   const QString getDisplayName(const QContact& contact) const;
       
    79   
       
    80   QContactLocalId selfContactId(QContactManager::Error* errors) const;
       
    81 
       
    82 Q_SIGNALS:
       
    83   void contactsAdded(const QList<QContactLocalId>& contactIds);
       
    84   void contactsChanged(const QList<QContactLocalId>& contactIds);
       
    85   void contactsRemoved(const QList<QContactLocalId>& contactIds);
       
    86   void jobSavingCompleted();
       
    87   void jobRemovingCompleted();
       
    88   
       
    89 public:
       
    90   /* Members used by callbacks */
       
    91   void _contactsAdded(const QList<QContactLocalId>& contactIds ){ emit contactsAdded(contactIds); };
       
    92   void _contactsRemoved(const QList<QContactLocalId>& contactIds ){ emit contactsRemoved(contactIds); };
       
    93   void _contactsChanged(const QList<QContactLocalId>& contactIds ){ emit contactsChanged(contactIds); };
       
    94   void _jobSavingCompleted(){ emit jobSavingCompleted(); };
       
    95   void _jobRemovingCompleted(){ emit jobRemovingCompleted(); };
       
    96   
       
    97 private:
       
    98   void initAddressBook();
       
    99   void initLocalIdHash();
       
   100   
       
   101   bool setDetailValues(const QVariantMap& data, QContactDetail* detail) const;
       
   102   
       
   103   OssoABookContact* getAContact(const QContactLocalId& contactId, QContactManager::Error* error) const;
       
   104   
       
   105   /* Filtering */
       
   106   bool contactActionsMatch(OssoABookContact *contact, QList<QContactActionDescriptor> descriptors) const;
       
   107   EBookQuery* convert(const QContactFilter& filter) const;
       
   108   
       
   109   /* Reading - eContact/abookContact to QContact methods */
       
   110   QContact* convert(EContact *eContact) const;
       
   111   
       
   112   QContactId getContactId(EContact *eContact) const;
       
   113   QList<QContactAddress*> getAddressDetail(EContact *eContact) const;
       
   114   QContactName* getNameDetail(EContact *eContact) const;
       
   115   QContactNickname* getNicknameDetail(EContact *eContact) const;
       
   116   QList<QContactEmailAddress*> getEmailDetail(EContact *eContact) const;
       
   117   QContactAvatar* getAvatarDetail(EContact *eContact) const;
       
   118   QContactBirthday* getBirthdayDetail(EContact *eContact) const;
       
   119   QContactGender* getGenderDetail(EContact *eContact) const;
       
   120   QContactGuid* getGuidDetail(EContact *eContact) const;
       
   121   QContactNote* getNoteDetail(EContact *eContact) const;
       
   122   void getOnlineAccountAndPresenceDetails(EContact *eContact, 
       
   123                                          QList<QContactOnlineAccount*>& onlineAccounts,
       
   124                                          QList<QContactPresence*>& presences) const;
       
   125   QContactOrganization* getOrganizationDetail(EContact *eContact) const;
       
   126   QList<QContactPhoneNumber*> getPhoneDetail(EContact *eContact) const;
       
   127   QList<QContactPresence*> getPresenceDetail(EContact *eContact) const;
       
   128   QContactTimestamp* getTimestampDetail(EContact *eContact) const; 
       
   129   QContactThumbnail* getThumbnailDetail(EContact *eContact) const;
       
   130   QContactUrl* getUrlDetail(EContact *eContact) const;
       
   131   
       
   132   /* Saving - QContact to abookContact */
       
   133   OssoABookContact* convert(const QContact *contact, QContactManager::Error* error) const;
       
   134   
       
   135   /* Save QDetails in OssoABookContact attributes */
       
   136   void setAddressDetail(const OssoABookContact* aContact, const QContactAddress& detail) const;
       
   137   void setAvatarDetail(const OssoABookContact* aContact, const QContactAvatar& detail) const;
       
   138   void setBirthdayDetail(const OssoABookContact* aContact, const QContactBirthday& detail) const;
       
   139   void setEmailDetail(const OssoABookContact* aContact, const QContactEmailAddress& detail) const;
       
   140   void setGenderDetail(const OssoABookContact* aContact, const QContactGender& detail) const;
       
   141   void setNameDetail(const OssoABookContact* aContact, const QContactName& detail) const;
       
   142   void setNicknameDetail(const OssoABookContact* aContact, const QContactNickname& detail) const;
       
   143   void setNoteDetail(const OssoABookContact* aContact, const QContactNote& detail) const;
       
   144   void setOnlineAccountDetail(const OssoABookContact* aContact, const QContactOnlineAccount& detail) const;
       
   145   void setOrganizationDetail(const OssoABookContact* aContact, const QContactOrganization& detail) const;
       
   146   void setPhoneDetail(const OssoABookContact* aContact, const QContactPhoneNumber& detail) const;
       
   147   void setPresenceDetail(const OssoABookContact* aContact, const QContactPresence& detail) const;
       
   148   void setThumbnailDetail(const OssoABookContact* aContact, const QContactThumbnail& detail) const;
       
   149   void setUrlDetail(const OssoABookContact* aContact, const QContactUrl& detail) const;
       
   150   
       
   151   /* Internal Vars */
       
   152   gulong m_contactAddedHandlerId;
       
   153   gulong m_contactChangedHandlerId;
       
   154   gulong m_contactRemovedHandlerId;
       
   155   
       
   156   OssoABookAggregator *m_abookAgregator;
       
   157   mutable QContactIDsHash m_localIds; //Converts QLocalId <=> eContactId
       
   158   
       
   159   QMutex m_saveContactMutex;
       
   160   QMutex m_delContactMutex;
       
   161   
       
   162   cbSharedData *m_cbSD;
       
   163   jobSharedData *m_deleteJobSD;
       
   164   jobSharedData *m_saveJobSD;
       
   165 };
       
   166 
       
   167 #endif