messagingapp/msgui/unifiedviewer/src/univiewerfeeder_p.cpp
branchRCL_3
changeset 26 ebe688cedc25
equal deleted inserted replaced
25:fa1df4b99609 26:ebe688cedc25
       
     1 /*
       
     2  * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3  * All rights reserved.
       
     4  * This component and the accompanying materials are made available
       
     5  * under the terms of "Eclipse Public License v1.0"
       
     6  * which accompanies this distribution, and is available
       
     7  * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8  *
       
     9  * Initial Contributors:
       
    10  * Nokia Corporation - initial contribution.
       
    11  *
       
    12  * Contributors:
       
    13  *
       
    14  * Description: Feeder Private class for unified viewer. Fetches data from the
       
    15  *              message store for the given message id.
       
    16  *
       
    17  */
       
    18 #include "univiewerfeeder_p.h"
       
    19 // SYSTEM INCLUDES
       
    20 #include <msvstd.h>
       
    21 #include <msvids.h>
       
    22 
       
    23 // USER INCLUDES
       
    24 #include "nativemessageconsts.h"
       
    25 #include "univiewerfeeder.h"
       
    26 #include "unidatamodelloader.h"
       
    27 #include "msgcontacthandler.h"
       
    28 #include "debugtraces.h"
       
    29 #include "msgbiouids.h"
       
    30 
       
    31 // ---------------------------------------------------------------------------
       
    32 // UniViewerFeederPrivate::UniViewerFeederPrivate
       
    33 // @see header file
       
    34 // ---------------------------------------------------------------------------
       
    35 UniViewerFeederPrivate::UniViewerFeederPrivate(qint32 msgId,
       
    36                                                UniViewerFeeder* feeder) :
       
    37     q_ptr(feeder), mSlideCount(0), mSession(NULL)
       
    38 {
       
    39     TRAP_IGNORE(initL(msgId));
       
    40 }
       
    41 
       
    42 // ---------------------------------------------------------------------------
       
    43 // UniViewerFeederPrivate::~UniViewerFeederPrivate
       
    44 // @see header file
       
    45 // ---------------------------------------------------------------------------
       
    46 UniViewerFeederPrivate::~UniViewerFeederPrivate()
       
    47 {
       
    48     q_ptr = NULL;
       
    49     clearContent();
       
    50     if(mPluginLoader)
       
    51     {
       
    52         delete mPluginLoader;
       
    53         mPluginLoader = NULL;
       
    54     }
       
    55 }
       
    56 
       
    57 // ---------------------------------------------------------------------------
       
    58 // UniViewerFeederPrivate::initL
       
    59 // Symbian specific constructions
       
    60 // ---------------------------------------------------------------------------
       
    61 //
       
    62 void UniViewerFeederPrivate::initL(qint32 msgId)
       
    63 {
       
    64     QDEBUG_WRITE("UniViewerFeederPrivate::initL start");
       
    65     TMsvId serviceId = KMsvNullIndexEntryId;
       
    66     mPluginInterface = NULL;
       
    67     mMsgId = msgId;
       
    68     mPluginLoader = new UniDataModelLoader();
       
    69     mPluginInterface = mPluginLoader->getDataModelPlugin(ConvergedMessage::Sms);
       
    70 
       
    71     mSession = mPluginInterface->session();
       
    72     mSession->GetEntry(msgId, serviceId, mEntry);
       
    73     QDEBUG_WRITE("UniViewerFeederPrivate::initL end");
       
    74 }
       
    75 
       
    76 // ---------------------------------------------------------------------------
       
    77 // UniViewerFeederPrivate::msgType
       
    78 // Returns the message type.
       
    79 // ---------------------------------------------------------------------------
       
    80 qint32 UniViewerFeederPrivate::msgType()
       
    81 {
       
    82     return mEntry.iMtm.iUid;
       
    83 }
       
    84 
       
    85 // ---------------------------------------------------------------------------
       
    86 // UniViewerFeederPrivate::isIncoming
       
    87 // Returns if it is a incoming message.
       
    88 // ---------------------------------------------------------------------------
       
    89 bool UniViewerFeederPrivate::isIncoming()
       
    90 {
       
    91     if (mEntry.Parent() == KMsvGlobalInBoxIndexEntryId)
       
    92     {
       
    93         return true;
       
    94     }
       
    95     return false;
       
    96 }
       
    97 
       
    98 // ---------------------------------------------------------------------------
       
    99 // UniViewerFeederPrivate::priority
       
   100 // Returns the message priority.
       
   101 // ---------------------------------------------------------------------------
       
   102 int UniViewerFeederPrivate::priority()
       
   103 {
       
   104     if (mEntry.Priority() == EMsvHighPriority)
       
   105     {
       
   106         return ConvergedMessage::High;
       
   107     }
       
   108     else if (mEntry.Priority() == EMsvLowPriority)
       
   109     {
       
   110         return ConvergedMessage::Low;
       
   111     }
       
   112     return ConvergedMessage::Normal;
       
   113 }
       
   114 
       
   115 // ---------------------------------------------------------------------------
       
   116 // UniViewerFeederPrivate::subject
       
   117 // Returns the message subject.
       
   118 // ---------------------------------------------------------------------------
       
   119 QString UniViewerFeederPrivate::subject()
       
   120 {
       
   121     return mPluginInterface->subject();
       
   122 }
       
   123 
       
   124 // ---------------------------------------------------------------------------
       
   125 // UniViewerFeederPrivate::subject
       
   126 // Returns the message subject.
       
   127 // ---------------------------------------------------------------------------
       
   128 
       
   129 int UniViewerFeederPrivate::sendingState()
       
   130 {
       
   131     return mEntry.SendingState();
       
   132 }
       
   133 // ---------------------------------------------------------------------------
       
   134 // UniViewerFeederPrivate::timeStamp
       
   135 // Returns the time stamp
       
   136 // ---------------------------------------------------------------------------
       
   137 QDateTime UniViewerFeederPrivate::timeStamp()
       
   138 {
       
   139 
       
   140     return mPluginInterface->timeStamp();
       
   141 }
       
   142 
       
   143 // ---------------------------------------------------------------------------
       
   144 // UniViewerFeederPrivate::fetchDetailsL
       
   145 // Fetches message details from the store.
       
   146 // ---------------------------------------------------------------------------
       
   147 void UniViewerFeederPrivate::fetchDetails()
       
   148 {
       
   149     QDEBUG_WRITE("UniViewerFeederPrivate fetchDetailsL : SMS start");
       
   150     if (msgType() == KSenduiMtmSmsUidValue || (msgType() == KSenduiMtmBioUidValue
       
   151         && mEntry.iBioType == KMsgBioNokiaServiceMessage.iUid)) {
       
   152         QString body;
       
   153         mPluginInterface->body(body);
       
   154         q_ptr->emitMsgBody(body);
       
   155     }
       
   156     QDEBUG_WRITE("UniViewerFeederPrivate fetchDetailsL : SMS END");
       
   157 }
       
   158 
       
   159 // ---------------------------------------------------------------------------
       
   160 // UniViewerFeederPrivate::hasAttachments
       
   161 // @see header file
       
   162 // ---------------------------------------------------------------------------
       
   163 bool UniViewerFeederPrivate::hasAttachments()
       
   164 {
       
   165     return mPluginInterface->hasAttachment();
       
   166 }
       
   167 // ---------------------------------------------------------------------------
       
   168 // UniViewerFeederPrivate::attachmentsList
       
   169 // @see header file
       
   170 // ---------------------------------------------------------------------------
       
   171 UniMessageInfoList UniViewerFeederPrivate::attachmentsList()
       
   172 {
       
   173     return mPluginInterface->attachmentList();
       
   174 }
       
   175 
       
   176 // ---------------------------------------------------------------------------
       
   177 // UniViewerFeederPrivate::attachmentCount
       
   178 // @see header file
       
   179 // ---------------------------------------------------------------------------
       
   180 int UniViewerFeederPrivate::attachmentCount()
       
   181 {
       
   182     return mPluginInterface->attachmentCount();
       
   183 }
       
   184 
       
   185 // ---------------------------------------------------------------------------
       
   186 // UniViewerFeederPrivate::objectsList
       
   187 // @see header file
       
   188 // ---------------------------------------------------------------------------
       
   189 UniMessageInfoList UniViewerFeederPrivate::objectsList()
       
   190 {
       
   191     return mPluginInterface->objectList();
       
   192 }
       
   193 
       
   194 // ---------------------------------------------------------------------------
       
   195 // UniViewerFeederPrivate::objectCount
       
   196 // @see header file
       
   197 // ---------------------------------------------------------------------------
       
   198 int UniViewerFeederPrivate::objectCount()
       
   199 {
       
   200     return mPluginInterface->objectCount();
       
   201 }
       
   202 
       
   203 // ---------------------------------------------------------------------------
       
   204 // UniViewerFeederPrivate::slideCount
       
   205 // @see header file
       
   206 // ---------------------------------------------------------------------------
       
   207 int UniViewerFeederPrivate::slideCount()
       
   208 {
       
   209     return mSlideCount;
       
   210 }
       
   211 
       
   212 // ---------------------------------------------------------------------------
       
   213 // UniViewerFeederPrivate::slideContent
       
   214 // @see header file
       
   215 // ---------------------------------------------------------------------------
       
   216 UniMessageInfoList UniViewerFeederPrivate::slideContent(int slidenum)
       
   217 {
       
   218     return mPluginInterface->slideContent(slidenum);
       
   219 }
       
   220 
       
   221 // ---------------------------------------------------------------------------
       
   222 // UniViewerFeederPrivate::updateContent
       
   223 // @see header file
       
   224 // ---------------------------------------------------------------------------
       
   225 void UniViewerFeederPrivate::updateContent(qint32 msgId)
       
   226 {
       
   227   
       
   228     if (msgId != mMsgId)
       
   229     {
       
   230         mMsgId = msgId;
       
   231         TMsvId serviceId = KMsvNullIndexEntryId;
       
   232         mSession->GetEntry(msgId, serviceId, mEntry);
       
   233         clearContent();
       
   234     }
       
   235 
       
   236     if (msgType() == KSenduiMtmSmsUidValue)
       
   237     {
       
   238         mPluginInterface = mPluginLoader->getDataModelPlugin(ConvergedMessage::Sms);
       
   239         mPluginInterface->setMessageId(msgId);
       
   240     }
       
   241 
       
   242     else if (msgType() == KSenduiMtmMmsUidValue) {
       
   243         mPluginInterface = mPluginLoader->getDataModelPlugin(ConvergedMessage::Mms);
       
   244         mPluginInterface->setMessageId(msgId);
       
   245         mSlideCount = mPluginInterface->slideCount();
       
   246 
       
   247     }
       
   248     else if (msgType() == KSenduiMtmBioUidValue && mEntry.iBioType
       
   249         == KMsgBioNokiaServiceMessage.iUid) {
       
   250         mPluginInterface = mPluginLoader->getDataModelPlugin(ConvergedMessage::BioMsg);
       
   251         mPluginInterface->setMessageId(msgId);
       
   252     }
       
   253 
       
   254     mPluginInterface->toRecipientList(mToAddressList);
       
   255     mPluginInterface->ccRecipientList(mCcAddressList);
       
   256     mPluginInterface->bccRecipientList(mBccAddressList);
       
   257 }
       
   258 
       
   259 // ---------------------------------------------------------------------------
       
   260 // UniViewerFeederPrivate::toAddressList
       
   261 // @see header file
       
   262 // ---------------------------------------------------------------------------
       
   263 ConvergedMessageAddressList UniViewerFeederPrivate::toAddressList()
       
   264 {
       
   265     QString alias = QString();
       
   266     int count;
       
   267     for (int i = 0; i < mToAddressList.count(); ++i) {
       
   268         MsgContactHandler::resolveContactDisplayName(
       
   269 		mToAddressList.at(i)->address(), alias, count);
       
   270         mToAddressList.at(i)->setAlias(alias);
       
   271         alias.clear();
       
   272     }
       
   273     return mToAddressList;
       
   274 }
       
   275 
       
   276 // ---------------------------------------------------------------------------
       
   277 // UniViewerFeederPrivate::ccAddressList
       
   278 // @see header file
       
   279 // ---------------------------------------------------------------------------
       
   280 ConvergedMessageAddressList UniViewerFeederPrivate::ccAddressList()
       
   281 {
       
   282     QString alias = QString();
       
   283     int count;
       
   284     for (int i = 0; i < mCcAddressList.count(); ++i) {
       
   285         MsgContactHandler::resolveContactDisplayName(
       
   286 		mToAddressList.at(i)->address(), alias, count);
       
   287         mCcAddressList.at(i)->setAlias(alias);
       
   288         alias.clear();
       
   289 
       
   290     }
       
   291     return mCcAddressList;
       
   292 }
       
   293 
       
   294 // ---------------------------------------------------------------------------
       
   295 // UniViewerFeederPrivate::bccAddressList
       
   296 // @see header file
       
   297 // ---------------------------------------------------------------------------
       
   298 ConvergedMessageAddressList UniViewerFeederPrivate::bccAddressList()
       
   299 {
       
   300     QString alias = QString();
       
   301     int count;
       
   302     for (int i = 0; i < mBccAddressList.count(); ++i)
       
   303     {
       
   304         MsgContactHandler::resolveContactDisplayName(
       
   305             mBccAddressList.at(i)->address(),
       
   306             alias,
       
   307             count);
       
   308         mBccAddressList.at(i)->setAlias(alias);
       
   309         alias.clear();
       
   310     }
       
   311     return mBccAddressList;
       
   312 }
       
   313 
       
   314 // ---------------------------------------------------------------------------
       
   315 // UniViewerFeederPrivate::recipientCount
       
   316 // @see header file
       
   317 // ---------------------------------------------------------------------------
       
   318 int UniViewerFeederPrivate::recipientCount()
       
   319 {
       
   320     return mToAddressList.count() + mCcAddressList.count() + mBccAddressList.count();
       
   321 }
       
   322 
       
   323 // ---------------------------------------------------------------------------
       
   324 // UniViewerFeederPrivate::messageSize
       
   325 // @see header file
       
   326 // ---------------------------------------------------------------------------
       
   327 int UniViewerFeederPrivate::messageSize()
       
   328 {
       
   329     return mPluginInterface->messageSize();
       
   330 }
       
   331 
       
   332 // ---------------------------------------------------------------------------
       
   333 // UniViewerFeederPrivate::fromAddressAndAlias
       
   334 // @see header file
       
   335 // ---------------------------------------------------------------------------
       
   336 void UniViewerFeederPrivate::fromAddressAndAlias(QString& from, QString& alias)
       
   337 {
       
   338     mPluginInterface->fromAddress(from);
       
   339     int count;
       
   340     MsgContactHandler::resolveContactDisplayName(from, alias, count);
       
   341 }
       
   342 
       
   343 // ---------------------------------------------------------------------------
       
   344 // UniViewerFeederPrivate::clearContent
       
   345 // @see header file
       
   346 // ---------------------------------------------------------------------------
       
   347 void UniViewerFeederPrivate::clearContent()
       
   348 {
       
   349     for (int i = 0; i < mToAddressList.count(); ++i)
       
   350     {
       
   351         delete mToAddressList.at(i);
       
   352     }
       
   353     mToAddressList.clear();
       
   354 
       
   355     for (int i = 0; i < mCcAddressList.count(); ++i)
       
   356     {
       
   357         delete mCcAddressList.at(i);
       
   358     }
       
   359     mCcAddressList.clear();
       
   360 
       
   361     for (int i = 0; i < mBccAddressList.count(); ++i)
       
   362     {
       
   363         delete mBccAddressList.at(i);
       
   364     }
       
   365     mBccAddressList.clear();
       
   366 }
       
   367 
       
   368 // EOF