diff -r c39a6cfd1fb9 -r be09cf1f39dd smf/smfservermodule/smfclient/common/smfcontact.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/smf/smfservermodule/smfclient/common/smfcontact.cpp Tue May 18 17:37:12 2010 +0530 @@ -0,0 +1,156 @@ +/* + * smfcontact.cpp + * + * Created on: Apr 15, 2010 + * Author: manasij + */ +#include "smfcontact.h" +#include +#include + + + /** + * Constructor with default argument + * @param aParent The parent object + */ + SmfContact::SmfContact( QObject *aParent)//:QObject(aParent) + { + d = new SmfContactPrivate; + } + + /** + * Copy Constructor + * @param aOther The reference object + */ + SmfContact::SmfContact( const SmfContact &aOther ): d (aOther.d) + { + + } + + /** + * Destructor + */ + SmfContact::~SmfContact( ) + { + + } + QStringList SmfContact::subTypes( ) const + { + + } + + /** + * Method to convert an SmfContact to a QContact + * Changes made to the returned QContact will not be reflected + * in its parent SmfContact object + * @param aContact QContact corresponding to SmfContact + */ + void SmfContact::convert( QContact &aContact ) const + { + + } + + /** + * Method to get the value of a sub field for this contact + * @param aSubType The sub field type + * @return The value of the sub field subType + * @see subTypes() + */ + QVariant SmfContact::value( const QString& aSubType ) const + { + if(d->m_details.contains(aSubType)) + return d->m_details.value(aSubType); + else + return QString("Not found"); + } + + void SmfContact::setValue(const QString& aSubType,QVariant& value) + { + d->m_details.insert(aSubType,value); + } + void SmfContact::writeLog(QString log) const + { + QFile file("c:\\data\\SmfClientLogs.txt"); + if (!file.open(QIODevice::Append | QIODevice::Text)) + return; + QTextStream out(&file); + out << log << "\n"; + file.close(); + + } + /** + * Method for Externalization. Writes the SmfContact object to + * the stream and returns a reference to the stream. + * @param aDataStream Stream to be written + * @param aContact The SmfContact object to be externalized + * @return reference to the written stream + */ + //TODO:-Need to revisit + + QDataStream &operator<<( QDataStream &aDataStream, + const SmfContact& aContact ) + { + aContact.writeLog("smfContact::operator<<"); + QVariant var = aContact.value("Name"); + QContactName cn = var.value(); + aDataStream<>( QDataStream &aDataStream, + SmfContact& aContact ) + { + aContact.writeLog("smfContact::operator>>"); + //explicitely adding fields for the classes that don't provide + //internalizatio/externalization :( + QContactName name; + //QString name; + aDataStream>>name; + QVariant var = QVariant::fromValue(name); + aContact.setValue("Name",var); + return aDataStream; + } + QDataStream &operator<<( QDataStream &aDataStream, + const QContactName &aContact ) + { + //Qt mobility introduces API compatibility break +#ifdef OLDER_QT_MOBILITY + aDataStream<>( QDataStream &aDataStream, + QContactName &aContact ) + { + QString first; + QString last; + aDataStream>>first; +#ifdef OLDER_QT_MOBILITY + aContact.setFirst(first); +#else + aContact.setFirstName(first); +#endif + + aDataStream>>last; +#ifdef OLDER_QT_MOBILITY + aContact.setLast(last); +#else + aContact.setLastName(last); +#endif + return aDataStream; + }