messagingapp/msgui/unifiedviewer/src/univiewerfeeder_p.cpp
changeset 25 84d9eb65b26f
parent 23 238255e8b033
child 27 e4592d119491
child 37 518b245aa84c
equal deleted inserted replaced
23:238255e8b033 25:84d9eb65b26f
    15  *              message store for the given message id.
    15  *              message store for the given message id.
    16  *
    16  *
    17  */
    17  */
    18 #include "univiewerfeeder_p.h"
    18 #include "univiewerfeeder_p.h"
    19 // SYSTEM INCLUDES
    19 // SYSTEM INCLUDES
    20 #include <mtclreg.h>
       
    21 #include <mtclbase.h>
       
    22 #include <msvstd.h>
    20 #include <msvstd.h>
    23 #include <txtetext.h>
       
    24 #include <txtrich.h>
       
    25 #include <s60qconversions.h>
    21 #include <s60qconversions.h>
    26 #include <msvids.h>
    22 #include <msvids.h>
    27 #include <qtcontactsglobal.h>
    23 #include <qtcontactsglobal.h>
    28 #include "qtcontacts.h"
    24 #include "qtcontacts.h"
    29 #include "qcontactdetailfilter.h"
    25 #include "qcontactdetailfilter.h"
    51 // ---------------------------------------------------------------------------
    47 // ---------------------------------------------------------------------------
    52 UniViewerFeederPrivate::~UniViewerFeederPrivate()
    48 UniViewerFeederPrivate::~UniViewerFeederPrivate()
    53 {
    49 {
    54     q_ptr = NULL;
    50     q_ptr = NULL;
    55     clearContent();
    51     clearContent();
    56     if(pluginLoader)
    52     if(mPluginLoader)
    57     {
    53     {
    58         delete pluginLoader;
    54         delete mPluginLoader;
    59         pluginLoader = NULL;
    55         mPluginLoader = NULL;
    60     }
    56     }
    61 }
    57 }
    62 
    58 
    63 // ---------------------------------------------------------------------------
    59 // ---------------------------------------------------------------------------
    64 // UniViewerFeederPrivate::initL
    60 // UniViewerFeederPrivate::initL
    67 //
    63 //
    68 void UniViewerFeederPrivate::initL(qint32 msgId)
    64 void UniViewerFeederPrivate::initL(qint32 msgId)
    69 {
    65 {
    70     QDEBUG_WRITE("UniViewerFeederPrivate::initL start");
    66     QDEBUG_WRITE("UniViewerFeederPrivate::initL start");
    71     TMsvId serviceId = KMsvNullIndexEntryId;
    67     TMsvId serviceId = KMsvNullIndexEntryId;
    72     pluginInterface = NULL;
    68     mPluginInterface = NULL;
    73     mMsgId = msgId;
    69     mMsgId = msgId;
    74     pluginLoader = new UniDataModelLoader();
    70     mPluginLoader = new UniDataModelLoader();
    75     pluginLoader->loadPlugins();
    71     mPluginInterface = mPluginLoader->getDataModelPlugin(ConvergedMessage::Sms);
    76     pluginInterface = pluginLoader->getDataModelPlugin("sms");
    72 
    77 
    73     mSession = mPluginInterface->session();
    78     mSession = pluginInterface->session();
       
    79     mSession->GetEntry(msgId, serviceId, mEntry);
    74     mSession->GetEntry(msgId, serviceId, mEntry);
    80     QDEBUG_WRITE("UniViewerFeederPrivate::initL end");
    75     QDEBUG_WRITE("UniViewerFeederPrivate::initL end");
    81 }
    76 }
    82 
    77 
    83 // ---------------------------------------------------------------------------
    78 // ---------------------------------------------------------------------------
   132 // UniViewerFeederPrivate::subject
   127 // UniViewerFeederPrivate::subject
   133 // Returns the message subject.
   128 // Returns the message subject.
   134 // ---------------------------------------------------------------------------
   129 // ---------------------------------------------------------------------------
   135 QString UniViewerFeederPrivate::subject()
   130 QString UniViewerFeederPrivate::subject()
   136 {
   131 {
   137     return pluginInterface->subject();
   132     return mPluginInterface->subject();
   138 }
   133 }
   139 
   134 
       
   135 // ---------------------------------------------------------------------------
       
   136 // UniViewerFeederPrivate::subject
       
   137 // Returns the message subject.
       
   138 // ---------------------------------------------------------------------------
       
   139 
       
   140 int UniViewerFeederPrivate::sendingState()
       
   141 {
       
   142     return mEntry.SendingState();
       
   143 }
   140 // ---------------------------------------------------------------------------
   144 // ---------------------------------------------------------------------------
   141 // UniViewerFeederPrivate::timeStamp
   145 // UniViewerFeederPrivate::timeStamp
   142 // Returns the time stamp
   146 // Returns the time stamp
   143 // ---------------------------------------------------------------------------
   147 // ---------------------------------------------------------------------------
   144 QDateTime UniViewerFeederPrivate::timeStamp()
   148 QDateTime UniViewerFeederPrivate::timeStamp()
   145 {
   149 {
   146 
   150 
   147     return pluginInterface->timeStamp();
   151     return mPluginInterface->timeStamp();
   148 }
   152 }
   149 
   153 
   150 // ---------------------------------------------------------------------------
   154 // ---------------------------------------------------------------------------
   151 // UniViewerFeederPrivate::fetchDetailsL
   155 // UniViewerFeederPrivate::fetchDetailsL
   152 // Fetches message details from the store.
   156 // Fetches message details from the store.
   153 // ---------------------------------------------------------------------------
   157 // ---------------------------------------------------------------------------
   154 void UniViewerFeederPrivate::fetchDetailsL()
   158 void UniViewerFeederPrivate::fetchDetailsL()
   155 {
   159 {
   156     QDEBUG_WRITE("UniViewerFeederPrivate fetchDetailsL : SMS start");
   160     QDEBUG_WRITE("UniViewerFeederPrivate fetchDetailsL : SMS start");
   157 
       
   158     if (msgType() == KSenduiMtmSmsUidValue)
   161     if (msgType() == KSenduiMtmSmsUidValue)
   159     {
   162     {
   160         QString body;
   163         QString body;
   161         pluginInterface->body(body);
   164         mPluginInterface->body(body);
   162         q_ptr->emitMsgBody(body);
   165         q_ptr->emitMsgBody(body);
   163     }
   166     }
   164 
       
   165     QDEBUG_WRITE("UniViewerFeederPrivate fetchDetailsL : SMS END");
   167     QDEBUG_WRITE("UniViewerFeederPrivate fetchDetailsL : SMS END");
   166 }
   168 }
   167 
   169 
   168 // ---------------------------------------------------------------------------
   170 // ---------------------------------------------------------------------------
   169 // UniViewerFeederPrivate::hasAttachments
   171 // UniViewerFeederPrivate::hasAttachments
   170 // @see header file
   172 // @see header file
   171 // ---------------------------------------------------------------------------
   173 // ---------------------------------------------------------------------------
   172 bool UniViewerFeederPrivate::hasAttachments()
   174 bool UniViewerFeederPrivate::hasAttachments()
   173 {
   175 {
   174     return pluginInterface->hasAttachment();
   176     return mPluginInterface->hasAttachment();
   175 }
   177 }
   176 // ---------------------------------------------------------------------------
   178 // ---------------------------------------------------------------------------
   177 // UniViewerFeederPrivate::attachmentsList
   179 // UniViewerFeederPrivate::attachmentsList
   178 // @see header file
   180 // @see header file
   179 // ---------------------------------------------------------------------------
   181 // ---------------------------------------------------------------------------
   180 UniMessageInfoList UniViewerFeederPrivate::attachmentsList()
   182 UniMessageInfoList UniViewerFeederPrivate::attachmentsList()
   181 {
   183 {
   182     return pluginInterface->attachmentList();
   184     return mPluginInterface->attachmentList();
   183 }
   185 }
   184 
   186 
   185 // ---------------------------------------------------------------------------
   187 // ---------------------------------------------------------------------------
   186 // UniViewerFeederPrivate::attachmentCount
   188 // UniViewerFeederPrivate::attachmentCount
   187 // @see header file
   189 // @see header file
   188 // ---------------------------------------------------------------------------
   190 // ---------------------------------------------------------------------------
   189 int UniViewerFeederPrivate::attachmentCount()
   191 int UniViewerFeederPrivate::attachmentCount()
   190 {
   192 {
   191     return pluginInterface->attachmentCount();
   193     return mPluginInterface->attachmentCount();
   192 }
   194 }
   193 
   195 
   194 // ---------------------------------------------------------------------------
   196 // ---------------------------------------------------------------------------
   195 // UniViewerFeederPrivate::objectsList
   197 // UniViewerFeederPrivate::objectsList
   196 // @see header file
   198 // @see header file
   197 // ---------------------------------------------------------------------------
   199 // ---------------------------------------------------------------------------
   198 UniMessageInfoList UniViewerFeederPrivate::objectsList()
   200 UniMessageInfoList UniViewerFeederPrivate::objectsList()
   199 {
   201 {
   200     return pluginInterface->objectList();
   202     return mPluginInterface->objectList();
   201 }
   203 }
   202 
   204 
   203 // ---------------------------------------------------------------------------
   205 // ---------------------------------------------------------------------------
   204 // UniViewerFeederPrivate::objectCount
   206 // UniViewerFeederPrivate::objectCount
   205 // @see header file
   207 // @see header file
   206 // ---------------------------------------------------------------------------
   208 // ---------------------------------------------------------------------------
   207 int UniViewerFeederPrivate::objectCount()
   209 int UniViewerFeederPrivate::objectCount()
   208 {
   210 {
   209     return pluginInterface->objectCount();
   211     return mPluginInterface->objectCount();
   210 }
   212 }
   211 
   213 
   212 // ---------------------------------------------------------------------------
   214 // ---------------------------------------------------------------------------
   213 // UniViewerFeederPrivate::slideCount
   215 // UniViewerFeederPrivate::slideCount
   214 // @see header file
   216 // @see header file
   222 // UniViewerFeederPrivate::slideContent
   224 // UniViewerFeederPrivate::slideContent
   223 // @see header file
   225 // @see header file
   224 // ---------------------------------------------------------------------------
   226 // ---------------------------------------------------------------------------
   225 UniMessageInfoList UniViewerFeederPrivate::slideContent(int slidenum)
   227 UniMessageInfoList UniViewerFeederPrivate::slideContent(int slidenum)
   226 {
   228 {
   227     return pluginInterface->slideContent(slidenum);
   229     return mPluginInterface->slideContent(slidenum);
   228 }
   230 }
   229 
   231 
   230 // ---------------------------------------------------------------------------
   232 // ---------------------------------------------------------------------------
   231 // UniViewerFeederPrivate::updateContent
   233 // UniViewerFeederPrivate::updateContent
   232 // @see header file
   234 // @see header file
   242         clearContent();
   244         clearContent();
   243     }
   245     }
   244 
   246 
   245     if (msgType() == KSenduiMtmSmsUidValue)
   247     if (msgType() == KSenduiMtmSmsUidValue)
   246     {
   248     {
   247         pluginInterface = pluginLoader->getDataModelPlugin("sms");
   249         mPluginInterface = mPluginLoader->getDataModelPlugin(ConvergedMessage::Sms);
   248         pluginInterface->setMessageId(msgId);
   250         mPluginInterface->setMessageId(msgId);
   249     }
   251     }
   250 
   252 
   251     if (msgType() == KSenduiMtmMmsUidValue)
   253     if (msgType() == KSenduiMtmMmsUidValue)
   252     {
   254     {
   253         pluginInterface = pluginLoader->getDataModelPlugin("mms");
   255         mPluginInterface = mPluginLoader->getDataModelPlugin(ConvergedMessage::Mms);
   254         pluginInterface->setMessageId(msgId);
   256         mPluginInterface->setMessageId(msgId);
   255         mSlideCount = pluginInterface->slideCount();
   257         mSlideCount = mPluginInterface->slideCount();
   256     }
   258     }
   257     pluginInterface->toRecipientList(mToAddressList);
   259     mPluginInterface->toRecipientList(mToAddressList);
   258     pluginInterface->ccRecipientList(mCcAddressList);
   260     mPluginInterface->ccRecipientList(mCcAddressList);
   259 }
   261 }
   260 
   262 
   261 // ---------------------------------------------------------------------------
   263 // ---------------------------------------------------------------------------
   262 // UniViewerFeederPrivate::toAddressList
   264 // UniViewerFeederPrivate::toAddressList
   263 // @see header file
   265 // @see header file
   264 // ---------------------------------------------------------------------------
   266 // ---------------------------------------------------------------------------
   265 ConvergedMessageAddressList UniViewerFeederPrivate::toAddressList()
   267 ConvergedMessageAddressList UniViewerFeederPrivate::toAddressList()
   266 {
   268 {
       
   269     QString alias = QString();
   267     for (int i = 0; i < mToAddressList.count(); ++i)
   270     for (int i = 0; i < mToAddressList.count(); ++i)
   268     {
   271     {
   269         if (mToAddressList.at(i)->alias().isEmpty())
   272         GetNameFromContacts(mToAddressList.at(i)->address(), alias);
   270         {
   273         mToAddressList.at(i)->setAlias(alias);
   271             QString alias = QString();
   274         alias.clear();
   272             GetNameFromContacts(mToAddressList.at(i)->address(), alias);
       
   273             mToAddressList.at(i)->setAlias(alias);
       
   274             alias.clear();
       
   275         }
       
   276     }
   275     }
   277     return mToAddressList;
   276     return mToAddressList;
   278 }
   277 }
   279 
   278 
   280 // ---------------------------------------------------------------------------
   279 // ---------------------------------------------------------------------------
   281 // UniViewerFeederPrivate::ccAddressList
   280 // UniViewerFeederPrivate::ccAddressList
   282 // @see header file
   281 // @see header file
   283 // ---------------------------------------------------------------------------
   282 // ---------------------------------------------------------------------------
   284 ConvergedMessageAddressList UniViewerFeederPrivate::ccAddressList()
   283 ConvergedMessageAddressList UniViewerFeederPrivate::ccAddressList()
   285 {
   284 {
       
   285     QString alias = QString();
   286     for (int i = 0; i < mCcAddressList.count(); ++i)
   286     for (int i = 0; i < mCcAddressList.count(); ++i)
   287     {
   287     {
   288         if (mCcAddressList.at(i)->alias().isEmpty())
   288         GetNameFromContacts(mCcAddressList.at(i)->address(), alias);
   289         {
   289         mCcAddressList.at(i)->setAlias(alias);
   290             QString alias = QString();
   290         alias.clear();
   291             GetNameFromContacts(mCcAddressList.at(i)->address(), alias);
   291 
   292             mCcAddressList.at(i)->setAlias(alias);
       
   293             alias.clear();
       
   294         }
       
   295     }
   292     }
   296     return mCcAddressList;
   293     return mCcAddressList;
   297 }
   294 }
   298 
   295 
   299 // ---------------------------------------------------------------------------
   296 // ---------------------------------------------------------------------------
   300 // UniViewerFeederPrivate::messageSize
   297 // UniViewerFeederPrivate::messageSize
   301 // @see header file
   298 // @see header file
   302 // ---------------------------------------------------------------------------
   299 // ---------------------------------------------------------------------------
   303 int UniViewerFeederPrivate::messageSize()
   300 int UniViewerFeederPrivate::messageSize()
   304 {
   301 {
   305     return pluginInterface->messageSize();
   302     return mPluginInterface->messageSize();
   306 }
   303 }
   307 
   304 
   308 // ---------------------------------------------------------------------------
   305 // ---------------------------------------------------------------------------
   309 // UniViewerFeederPrivate::fromAddressAndAlias
   306 // UniViewerFeederPrivate::fromAddressAndAlias
   310 // @see header file
   307 // @see header file
   311 // ---------------------------------------------------------------------------
   308 // ---------------------------------------------------------------------------
   312 void UniViewerFeederPrivate::fromAddressAndAlias(QString& from, QString& alias)
   309 void UniViewerFeederPrivate::fromAddressAndAlias(QString& from, QString& alias)
   313 {
   310 {
   314     pluginInterface->fromAddress(from);
   311     mPluginInterface->fromAddress(from);
   315     GetNameFromContacts(from, alias);
   312     GetNameFromContacts(from, alias);
   316 }
   313 }
   317 
   314 
   318 // ---------------------------------------------------------------------------
   315 // ---------------------------------------------------------------------------
   319 // UniViewerFeederPrivate::clearContent
   316 // UniViewerFeederPrivate::clearContent
   349                                         QContactPhoneNumber::FieldNumber);
   346                                         QContactPhoneNumber::FieldNumber);
   350     phoneFilter.setMatchFlags(QContactFilter::MatchEndsWith);
   347     phoneFilter.setMatchFlags(QContactFilter::MatchEndsWith);
   351 
   348 
   352     phoneFilter.setValue(address); // this is the phone number to be resolved
   349     phoneFilter.setValue(address); // this is the phone number to be resolved
   353 
   350 
   354     QList<QContactLocalId> matchingContacts =
   351     QList<QContactSortOrder> sortOrder;
   355             contactManager.contacts(phoneFilter);
   352     QList<QContact> matchingContacts =
       
   353             contactManager.contacts(phoneFilter,
       
   354                                     sortOrder,
       
   355                                     QStringList());
       
   356                                     
   356     int count = 0;
   357     int count = 0;
   357     if (matchingContacts.count() > 0)
   358     if (matchingContacts.count() > 0)
   358     {
   359     {
   359         QContact match = contactManager.contact(matchingContacts.at(0));
   360         QContact match = matchingContacts.at(0);       
   360         
       
   361         QContactName name = match.detail(QContactName::DefinitionName);
       
   362         QString nickName(match.detail<QContactNickname> ().nickname());
       
   363         
   361         
   364         QString displayLabel = match.displayLabel();
   362         QString displayLabel = match.displayLabel();
   365           
   363 
       
   364         if (displayLabel != "Unnamed")
       
   365         {
       
   366             alias.append(displayLabel);
       
   367         }
       
   368         
   366         QList<QContactPhoneNumber> numbers =
   369         QList<QContactPhoneNumber> numbers =
   367                 match.details<QContactPhoneNumber> ();
   370                 match.details<QContactPhoneNumber> ();
   368         count = numbers.count();
   371         count = numbers.count();
   369         if(displayLabel != "Unnamed")
   372      
   370         {
   373     }
   371             alias.append(displayLabel);
   374     
   372         }
       
   373         else if(!nickName.isEmpty())
       
   374         {
       
   375             alias.append(nickName);
       
   376         }
       
   377             
       
   378     }
       
   379     return count;
   375     return count;
   380 }
   376 }
   381 
   377 
   382 // EOF
   378 // EOF