example/clientapi/smf/inc/common/smfcontacts/smfcontact.h
changeset 2 86af6c333601
parent 1 4b1e636e8a71
equal deleted inserted replaced
1:4b1e636e8a71 2:86af6c333601
     1 /**************************************************************************************************
     1 /**
     2 * Copyright (c) 2010 Sasken Communication Technologies Ltd.
     2  * Copyright (c) 2010 Sasken Communication Technologies Ltd.
     3 * All rights reserved.
     3  * All rights reserved.
     4 * This component and the accompanying materials are made available
     4  * This component and the accompanying materials are made available
     5 * under the terms of the "{License}"
     5  * under the terms of the "Eclipse Public License v1.0" 
     6 * which accompanies  this distribution, and is available
     6  * which accompanies  this distribution, and is available
     7 * at the URL "{LicenseUrl}".
     7  * at the URL "http://www.eclipse.org/legal/epl-v10.html"
     8 *
     8  *
     9 * Initial Contributors:
     9  * Initial Contributors:
    10 * Chandradeep Gandhi, Sasken Communication Technologies Ltd - Initial contribution
    10  * Chandradeep Gandhi, Sasken Communication Technologies Ltd - Initial contribution
    11 *
    11  *
    12 * Contributors:
    12  * Contributors:
    13 * Manasij Roy
    13  * Manasij Roy, Nalina Hariharan
    14 * Description:
    14  * 
    15 * Interface spefication for profile of a contact in a social networking site
    15  * Description:
    16 *
    16  * The contact class represents a social contact
    17 /*************************************************************************************************/
    17  * Note: This class has dependencies on QtMobility project
       
    18  *
       
    19  */
    18 
    20 
    19 #ifndef SMFPROFILE_H
    21 #ifndef SMFCONTACT_H_
    20 #define SMFPROFILE_H
    22 #define SMFCONTACT_H_
    21 
    23 
    22 #include <QObject>
    24 #include "qtcontacts.h"
       
    25 #include <qdatastream.h>
       
    26 #include <QSharedData>
       
    27 #include <smfclientglobal.h>
    23 
    28 
    24 //From Qt mobility project
    29 using namespace QtMobility;
    25 #include "qtcontacts.h"
    30 
    26 #include "../common/SmfClientGlobal.h"
    31 class SmfContactPrivate;
    27 #include "smfprovider.h"
    32 
    28 /**
    33 /**
    29  * Interface for a contact from a service provider. This class
    34  * @ingroup smf_common_group
    30  * provides basic functionality to allow applications to obtain details of a
    35  * The contact class represents a social contact
    31  * contact (self or friends) in a social networking service.
       
    32  * 
    36  * 
    33  * All of the functionality described here should be implemented by a service
    37  * Note: This class has dependencies on QtMobility project
    34  * specific plug-in object.
       
    35  * Note this class has dependencies on QtMobility project
       
    36  */
    38  */
    37 class SMFCLIENT_EXPORT SmfContact : public QObject
    39 class SMFCLIENT_EXPORT SmfContact : public QObject
    38 {
    40 	{
    39   Q_OBJECT
    41 	Q_OBJECT
    40 
    42 
    41 public:
    43 public:
    42   /** 
    44 	/**
    43    * Constructs SmfContact with base provider info
    45 	 * Constructor with default argument
    44    * Seeing as this is a plug-in implementation, these will realistically
    46 	 * @param aParent The parent object
    45    * be generated by SMF factory of some kind
    47 	 */
    46    */
    48 	SmfContact( QObject *aParent = 0 );
    47   SmfContact(SmfProvider* baseProvider = 0);
    49 	
    48   ~SmfContact();
    50 	/**
       
    51 	 * Copy Constructor
       
    52 	 * @param aOther The reference object
       
    53 	 */
       
    54 	SmfContact( const SmfContact &aOther );
       
    55 	
       
    56 	/**
       
    57 	 * Destructor
       
    58 	 */
       
    59 	~SmfContact( );
       
    60 	
       
    61 public slots:
       
    62 	/**
       
    63 	 * Method to get the available sub fields for contacts.
       
    64 	 * The following are the available sub types of a contact
       
    65 	 *   QtMobility::QContactAddress		Address;
       
    66 	 *   QtMobility::QContactAnniversary	Anniversary;
       
    67 	 *   QtMobility::QContactAvatar			Avatar;
       
    68 	 *   QtMobility::QContactBirthday		Birthday;
       
    69 	 *   QtMobility::QContactId				ContactId;
       
    70 	 *   QtMobility::QContactEmailAddress	EmailAddress;
       
    71 	 *   QtMobility::QContactGender			Gender;
       
    72 	 *   QtMobility::QContactGeolocation	Geolocation;
       
    73 	 *   QtMobility::QContactGuid			Guid;
       
    74 	 *   QtMobility::QContactName			Name;
       
    75 	 *   QtMobility::QContactNickname		Nickname;
       
    76 	 *   QtMobility::QContactNote			Note;
       
    77 	 *   QtMobility::QContactOnlineAccount	OnlineAccount;
       
    78 	 *   QtMobility::QContactOrganization	Organization;
       
    79 	 *   QtMobility::QContactPhoneNumber	PhoneNumber;
       
    80 	 *   QtMobility::QContactTimestamp		Timestamp;
       
    81 	 *   QtMobility::QContactType			Type;
       
    82 	 *   QtMobility::QContactUrl			Url;
       
    83 	 * @return The Available sub fields for this contact
       
    84 	 */
       
    85 	QStringList subTypes( ) const;
       
    86 	
       
    87 	/**
       
    88 	 * Method to convert an SmfContact to a QContact
       
    89 	 * Changes made to the returned QContact will not be reflected 
       
    90 	 * in its parent SmfContact object
       
    91 	 * @param aContact QContact corresponding to SmfContact 
       
    92 	 */
       
    93 	void convert( QContact &aContact ) const;
       
    94 	
       
    95 	/**
       
    96 	 * Method to get the value of a sub field for this contact
       
    97 	 * @param aSubType The sub field type 
       
    98 	 * @return The value of the sub field subType
       
    99 	 * @see subTypes()
       
   100 	 */
       
   101 	QVariant value( const QString& aSubType ) const;
       
   102 	
       
   103 private:
       
   104 	QSharedDataPointer<SmfContactPrivate> d;
       
   105 	
       
   106 	friend QDataStream &operator<<( QDataStream &aDataStream, 
       
   107 			const SmfContact &aContact );
       
   108 
       
   109 	friend QDataStream &operator>>( QDataStream &aDataStream, 
       
   110 			SmfContact &aContact );
       
   111 	
       
   112 	};
    49 
   113 
    50 
   114 
    51   /**
   115 /**
    52    * Returns the available sub fields for contacts.
   116  * Method for Externalization. Writes the SmfContact object to 
    53     * The following subtypes are available,-
   117  * the stream and returns a reference to the stream.
    54     * QString userIdInProvider;
   118  * @param aDataStream Stream to be written
    55     * QtMobility::QContactAddress Adress;
   119  * @param aContact The SmfContact object to be externalized
    56     * QtMobility::QContactAnniversary Anniversary;
   120  * @return reference to the written stream
    57     * QtMobility::QContactAvatar  Avatar;
   121  */
    58     * QtMobility::QContactBirthday Birthday;
   122 QDataStream &operator<<( QDataStream &aDataStream, 
    59     * QtMobility::QContactEmailAddress EmailAddress;
   123 		const SmfContact &aContact );
    60     * QtMobility::QContactGender Gender;
       
    61     * QtMobility::QContactGeolocation Geolocation;
       
    62     * QtMobility::QContactGuid Guid;
       
    63     * QtMobility::QContactName Name;
       
    64     * QtMobility::QContactNickname Nickname;
       
    65     * QtMobility::QContactNote Note;
       
    66     * QtMobility::QContactOnlineAccount OnlineAccount;
       
    67     * QtMobility::QContactOrganization  Organization;
       
    68     * QtMobility::QContactPhoneNumber PhoneNumber;
       
    69     * QtMobility::QContactTimestamp Timestamp;
       
    70     * QtMobility::QContactType Type;
       
    71     * QtMobility::QContactUrl  Url;
       
    72    */
       
    73   virtual QStringList subTypes() const;
       
    74   
       
    75   //APIs to get base provider info (SmfProvider)
       
    76   
       
    77   /**
       
    78    * Gets the base provider info, note setting the provider is not permitted here
       
    79    */
       
    80   virtual SmfProvider* getProvider() = 0;
       
    81   
       
    82 public slots:
       
    83 
   124 
    84 /**
   125 /**
    85  * Gets value of the sub field for any contact.
   126  * Method for Internalization. Reads a SmfContact object from 
    86  * @param  subType sub field type 
   127  * the stream and returns a reference to the stream.
    87  * @param info value of the sub field subType
   128  * @param aDataStream Stream to be read
    88  * @see subTypes()
   129  * @param aContact The SmfContact object to be internalized
    89  * The following subtypes are available,-
   130  * @return reference to the stream
    90  * QString userIdInProvider;
       
    91  * QtMobility::QContactAddress Adress;
       
    92  * QtMobility::QContactAnniversary Anniversary;
       
    93  * QtMobility::QContactAvatar  Avatar;
       
    94  * QtMobility::QContactBirthday Birthday;
       
    95  * QtMobility::QContactEmailAddress EmailAddress;
       
    96  * QtMobility::QContactGender Gender;
       
    97  * QtMobility::QContactGeolocation Geolocation;
       
    98  * QtMobility::QContactGuid Guid;
       
    99  * QtMobility::QContactName Name;
       
   100  * QtMobility::QContactNickname Nickname;
       
   101  * QtMobility::QContactNote Note;
       
   102  * QtMobility::QContactOnlineAccount OnlineAccount;
       
   103  * QtMobility::QContactOrganization  Organization;
       
   104  * QtMobility::QContactPhoneNumber PhoneNumber;
       
   105  * QtMobility::QContactTimestamp Timestamp;
       
   106  * QtMobility::QContactType Type;
       
   107  * QtMobility::QContactUrl  Url;
       
   108  */
   131  */
   109   virtual void value(const QString& subType,const QVariant& info); //for any contact
   132 QDataStream &operator>>( QDataStream &aDataStream, 
   110   
   133 		SmfContact &aContact );
   111   /**
   134 
   112    * Sets the value of the sub field for self contact
   135 #endif /* SMFCONTACT_H_ */
   113    * @param  key sub field type 
       
   114    * @param value value to be set for  sub field key
       
   115    * @return success of the set
       
   116    * @see subTypes()
       
   117    */
       
   118   virtual bool setValue( const QString & key, const QVariant & value );//for self contact only
       
   119 	 
       
   120   
       
   121 signals:
       
   122 /**
       
   123  * Emitted when value of self contact changes.
       
   124  * @param key the key which is changed
       
   125  */
       
   126   void detailsUpdated(const QString& key); //for setvalue on self contact
       
   127   
       
   128 private:
       
   129   /**
       
   130    * Conatact details
       
   131    */
       
   132   QVariantMap m_details;
       
   133 	QString m_caption;
       
   134 	 /**
       
   135 	 * Externalization
       
   136 	 */
       
   137 };
       
   138 	/**
       
   139 	 * Externalization
       
   140 	 */
       
   141 	QDataStream &operator<<(QDataStream &, const SmfContact&);
       
   142 	/**
       
   143 	 * Internalization
       
   144 	 */
       
   145 QDataStream &operator>>(QDataStream &, SmfContact&);
       
   146 SMF_GETSERVICES(SmfContact, "org.symbian.smf.client.contact")
       
   147 #endif // SMFPROFILE_H