messagingapp/msgui/unifiedviewer/src/univiewerfeeder_p.cpp
changeset 37 518b245aa84c
parent 25 84d9eb65b26f
child 48 4f501b74aeb1
equal deleted inserted replaced
25:84d9eb65b26f 37:518b245aa84c
    16  *
    16  *
    17  */
    17  */
    18 #include "univiewerfeeder_p.h"
    18 #include "univiewerfeeder_p.h"
    19 // SYSTEM INCLUDES
    19 // SYSTEM INCLUDES
    20 #include <msvstd.h>
    20 #include <msvstd.h>
    21 #include <s60qconversions.h>
       
    22 #include <msvids.h>
    21 #include <msvids.h>
    23 #include <qtcontactsglobal.h>
       
    24 #include "qtcontacts.h"
       
    25 #include "qcontactdetailfilter.h"
       
    26 
    22 
    27 // USER INCLUDES
    23 // USER INCLUDES
    28 #include "nativemessageconsts.h"
    24 #include "nativemessageconsts.h"
    29 #include "univiewerfeeder.h"
    25 #include "univiewerfeeder.h"
    30 #include "unidatamodelloader.h"
    26 #include "unidatamodelloader.h"
       
    27 #include "msgcontacthandler.h"
    31 #include "debugtraces.h"
    28 #include "debugtraces.h"
       
    29 #include "msgbiouids.h"
    32 
    30 
    33 // ---------------------------------------------------------------------------
    31 // ---------------------------------------------------------------------------
    34 // UniViewerFeederPrivate::UniViewerFeederPrivate
    32 // UniViewerFeederPrivate::UniViewerFeederPrivate
    35 // @see header file
    33 // @see header file
    36 // ---------------------------------------------------------------------------
    34 // ---------------------------------------------------------------------------
   156 // Fetches message details from the store.
   154 // Fetches message details from the store.
   157 // ---------------------------------------------------------------------------
   155 // ---------------------------------------------------------------------------
   158 void UniViewerFeederPrivate::fetchDetailsL()
   156 void UniViewerFeederPrivate::fetchDetailsL()
   159 {
   157 {
   160     QDEBUG_WRITE("UniViewerFeederPrivate fetchDetailsL : SMS start");
   158     QDEBUG_WRITE("UniViewerFeederPrivate fetchDetailsL : SMS start");
   161     if (msgType() == KSenduiMtmSmsUidValue)
   159     if (msgType() == KSenduiMtmSmsUidValue || (msgType() == KSenduiMtmBioUidValue
   162     {
   160         && mEntry.iBioType == KMsgBioNokiaServiceMessage.iUid)) {
   163         QString body;
   161         QString body;
   164         mPluginInterface->body(body);
   162         mPluginInterface->body(body);
   165         q_ptr->emitMsgBody(body);
   163         q_ptr->emitMsgBody(body);
   166     }
   164     }
   167     QDEBUG_WRITE("UniViewerFeederPrivate fetchDetailsL : SMS END");
   165     QDEBUG_WRITE("UniViewerFeederPrivate fetchDetailsL : SMS END");
   248     {
   246     {
   249         mPluginInterface = mPluginLoader->getDataModelPlugin(ConvergedMessage::Sms);
   247         mPluginInterface = mPluginLoader->getDataModelPlugin(ConvergedMessage::Sms);
   250         mPluginInterface->setMessageId(msgId);
   248         mPluginInterface->setMessageId(msgId);
   251     }
   249     }
   252 
   250 
   253     if (msgType() == KSenduiMtmMmsUidValue)
   251     else if (msgType() == KSenduiMtmMmsUidValue) {
   254     {
       
   255         mPluginInterface = mPluginLoader->getDataModelPlugin(ConvergedMessage::Mms);
   252         mPluginInterface = mPluginLoader->getDataModelPlugin(ConvergedMessage::Mms);
   256         mPluginInterface->setMessageId(msgId);
   253         mPluginInterface->setMessageId(msgId);
   257         mSlideCount = mPluginInterface->slideCount();
   254         mSlideCount = mPluginInterface->slideCount();
   258     }
   255 
       
   256     }
       
   257     else if (msgType() == KSenduiMtmBioUidValue && mEntry.iBioType
       
   258         == KMsgBioNokiaServiceMessage.iUid) {
       
   259         mPluginInterface = mPluginLoader->getDataModelPlugin(ConvergedMessage::BioMsg);
       
   260         mPluginInterface->setMessageId(msgId);
       
   261     }
       
   262 
   259     mPluginInterface->toRecipientList(mToAddressList);
   263     mPluginInterface->toRecipientList(mToAddressList);
   260     mPluginInterface->ccRecipientList(mCcAddressList);
   264     mPluginInterface->ccRecipientList(mCcAddressList);
       
   265     mPluginInterface->bccRecipientList(mBccAddressList);
   261 }
   266 }
   262 
   267 
   263 // ---------------------------------------------------------------------------
   268 // ---------------------------------------------------------------------------
   264 // UniViewerFeederPrivate::toAddressList
   269 // UniViewerFeederPrivate::toAddressList
   265 // @see header file
   270 // @see header file
   266 // ---------------------------------------------------------------------------
   271 // ---------------------------------------------------------------------------
   267 ConvergedMessageAddressList UniViewerFeederPrivate::toAddressList()
   272 ConvergedMessageAddressList UniViewerFeederPrivate::toAddressList()
   268 {
   273 {
   269     QString alias = QString();
   274     QString alias = QString();
   270     for (int i = 0; i < mToAddressList.count(); ++i)
   275     int count;
   271     {
   276     for (int i = 0; i < mToAddressList.count(); ++i) {
   272         GetNameFromContacts(mToAddressList.at(i)->address(), alias);
   277         MsgContactHandler::resolveContactDisplayName(
       
   278 		mToAddressList.at(i)->address(), alias, count);
   273         mToAddressList.at(i)->setAlias(alias);
   279         mToAddressList.at(i)->setAlias(alias);
   274         alias.clear();
   280         alias.clear();
   275     }
   281     }
   276     return mToAddressList;
   282     return mToAddressList;
   277 }
   283 }
   281 // @see header file
   287 // @see header file
   282 // ---------------------------------------------------------------------------
   288 // ---------------------------------------------------------------------------
   283 ConvergedMessageAddressList UniViewerFeederPrivate::ccAddressList()
   289 ConvergedMessageAddressList UniViewerFeederPrivate::ccAddressList()
   284 {
   290 {
   285     QString alias = QString();
   291     QString alias = QString();
   286     for (int i = 0; i < mCcAddressList.count(); ++i)
   292     int count;
   287     {
   293     for (int i = 0; i < mCcAddressList.count(); ++i) {
   288         GetNameFromContacts(mCcAddressList.at(i)->address(), alias);
   294         MsgContactHandler::resolveContactDisplayName(
       
   295 		mToAddressList.at(i)->address(), alias, count);
   289         mCcAddressList.at(i)->setAlias(alias);
   296         mCcAddressList.at(i)->setAlias(alias);
   290         alias.clear();
   297         alias.clear();
   291 
   298 
   292     }
   299     }
   293     return mCcAddressList;
   300     return mCcAddressList;
   294 }
   301 }
   295 
   302 
   296 // ---------------------------------------------------------------------------
   303 // ---------------------------------------------------------------------------
       
   304 // UniViewerFeederPrivate::bccAddressList
       
   305 // @see header file
       
   306 // ---------------------------------------------------------------------------
       
   307 ConvergedMessageAddressList UniViewerFeederPrivate::bccAddressList()
       
   308 {
       
   309     QString alias = QString();
       
   310     int count;
       
   311     for (int i = 0; i < mBccAddressList.count(); ++i)
       
   312     {
       
   313         MsgContactHandler::resolveContactDisplayName(
       
   314             mBccAddressList.at(i)->address(),
       
   315             alias,
       
   316             count);
       
   317         mBccAddressList.at(i)->setAlias(alias);
       
   318         alias.clear();
       
   319     }
       
   320     return mBccAddressList;
       
   321 }
       
   322 
       
   323 // ---------------------------------------------------------------------------
       
   324 // UniViewerFeederPrivate::recipientCount
       
   325 // @see header file
       
   326 // ---------------------------------------------------------------------------
       
   327 int UniViewerFeederPrivate::recipientCount()
       
   328 {
       
   329     return mToAddressList.count() + mCcAddressList.count() + mBccAddressList.count();
       
   330 }
       
   331 
       
   332 // ---------------------------------------------------------------------------
   297 // UniViewerFeederPrivate::messageSize
   333 // UniViewerFeederPrivate::messageSize
   298 // @see header file
   334 // @see header file
   299 // ---------------------------------------------------------------------------
   335 // ---------------------------------------------------------------------------
   300 int UniViewerFeederPrivate::messageSize()
   336 int UniViewerFeederPrivate::messageSize()
   301 {
   337 {
   307 // @see header file
   343 // @see header file
   308 // ---------------------------------------------------------------------------
   344 // ---------------------------------------------------------------------------
   309 void UniViewerFeederPrivate::fromAddressAndAlias(QString& from, QString& alias)
   345 void UniViewerFeederPrivate::fromAddressAndAlias(QString& from, QString& alias)
   310 {
   346 {
   311     mPluginInterface->fromAddress(from);
   347     mPluginInterface->fromAddress(from);
   312     GetNameFromContacts(from, alias);
   348     int count;
       
   349     MsgContactHandler::resolveContactDisplayName(from, alias, count);
   313 }
   350 }
   314 
   351 
   315 // ---------------------------------------------------------------------------
   352 // ---------------------------------------------------------------------------
   316 // UniViewerFeederPrivate::clearContent
   353 // UniViewerFeederPrivate::clearContent
   317 // @see header file
   354 // @see header file
   326 
   363 
   327     for (int i = 0; i < mCcAddressList.count(); ++i)
   364     for (int i = 0; i < mCcAddressList.count(); ++i)
   328     {
   365     {
   329         delete mCcAddressList.at(i);
   366         delete mCcAddressList.at(i);
   330     }
   367     }
   331 
       
   332     mCcAddressList.clear();
   368     mCcAddressList.clear();
   333 }
   369 
   334 
   370     for (int i = 0; i < mBccAddressList.count(); ++i)
   335 // ---------------------------------------------------------------------------
   371     {
   336 // UniViewerFeederPrivate::GetNameFromContacts
   372         delete mBccAddressList.at(i);
   337 // @see header file
   373     }
   338 //----------------------------------------------------------------------------
   374     mBccAddressList.clear();
   339 int UniViewerFeederPrivate::GetNameFromContacts(const QString& address,
       
   340                                                 QString& alias)
       
   341 {
       
   342     QContactManager contactManager("symbian");
       
   343     //set filter
       
   344     QContactDetailFilter phoneFilter;
       
   345     phoneFilter.setDetailDefinitionName(QContactPhoneNumber::DefinitionName,
       
   346                                         QContactPhoneNumber::FieldNumber);
       
   347     phoneFilter.setMatchFlags(QContactFilter::MatchEndsWith);
       
   348 
       
   349     phoneFilter.setValue(address); // this is the phone number to be resolved
       
   350 
       
   351     QList<QContactSortOrder> sortOrder;
       
   352     QList<QContact> matchingContacts =
       
   353             contactManager.contacts(phoneFilter,
       
   354                                     sortOrder,
       
   355                                     QStringList());
       
   356                                     
       
   357     int count = 0;
       
   358     if (matchingContacts.count() > 0)
       
   359     {
       
   360         QContact match = matchingContacts.at(0);       
       
   361         
       
   362         QString displayLabel = match.displayLabel();
       
   363 
       
   364         if (displayLabel != "Unnamed")
       
   365         {
       
   366             alias.append(displayLabel);
       
   367         }
       
   368         
       
   369         QList<QContactPhoneNumber> numbers =
       
   370                 match.details<QContactPhoneNumber> ();
       
   371         count = numbers.count();
       
   372      
       
   373     }
       
   374     
       
   375     return count;
       
   376 }
   375 }
   377 
   376 
   378 // EOF
   377 // EOF