messagingapp/msgui/unifiedviewer/src/univiewerfeeder_p.cpp
changeset 31 ebfee66fde93
child 34 84197e66a4bd
equal deleted inserted replaced
30:6a20128ce557 31:ebfee66fde93
       
     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 <s60qconversions.h>
       
    22 #include <msvids.h>
       
    23 
       
    24 // USER INCLUDES
       
    25 #include "nativemessageconsts.h"
       
    26 #include "univiewerfeeder.h"
       
    27 #include "unidatamodelloader.h"
       
    28 #include "msgcontacthandler.h"
       
    29 #include "debugtraces.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::fetchDetails
       
    78 // Fetches message details from the store
       
    79 // ---------------------------------------------------------------------------
       
    80 void UniViewerFeederPrivate::fetchDetails()
       
    81 {
       
    82     TRAP_IGNORE(fetchDetailsL());
       
    83 }
       
    84 
       
    85 // ---------------------------------------------------------------------------
       
    86 // UniViewerFeederPrivate::msgType
       
    87 // Returns the message type.
       
    88 // ---------------------------------------------------------------------------
       
    89 qint32 UniViewerFeederPrivate::msgType()
       
    90 {
       
    91     return mEntry.iMtm.iUid;
       
    92 }
       
    93 
       
    94 // ---------------------------------------------------------------------------
       
    95 // UniViewerFeederPrivate::isIncoming
       
    96 // Returns if it is a incoming message.
       
    97 // ---------------------------------------------------------------------------
       
    98 bool UniViewerFeederPrivate::isIncoming()
       
    99 {
       
   100     if (mEntry.Parent() == KMsvGlobalInBoxIndexEntryId)
       
   101     {
       
   102         return true;
       
   103     }
       
   104     return false;
       
   105 }
       
   106 
       
   107 // ---------------------------------------------------------------------------
       
   108 // UniViewerFeederPrivate::priority
       
   109 // Returns the message priority.
       
   110 // ---------------------------------------------------------------------------
       
   111 int UniViewerFeederPrivate::priority()
       
   112 {
       
   113     if (mEntry.Priority() == EMsvHighPriority)
       
   114     {
       
   115         return ConvergedMessage::High;
       
   116     }
       
   117     else if (mEntry.Priority() == EMsvLowPriority)
       
   118     {
       
   119         return ConvergedMessage::Low;
       
   120     }
       
   121     return ConvergedMessage::Normal;
       
   122 }
       
   123 
       
   124 // ---------------------------------------------------------------------------
       
   125 // UniViewerFeederPrivate::subject
       
   126 // Returns the message subject.
       
   127 // ---------------------------------------------------------------------------
       
   128 QString UniViewerFeederPrivate::subject()
       
   129 {
       
   130     return mPluginInterface->subject();
       
   131 }
       
   132 
       
   133 // ---------------------------------------------------------------------------
       
   134 // UniViewerFeederPrivate::subject
       
   135 // Returns the message subject.
       
   136 // ---------------------------------------------------------------------------
       
   137 
       
   138 int UniViewerFeederPrivate::sendingState()
       
   139 {
       
   140     return mEntry.SendingState();
       
   141 }
       
   142 // ---------------------------------------------------------------------------
       
   143 // UniViewerFeederPrivate::timeStamp
       
   144 // Returns the time stamp
       
   145 // ---------------------------------------------------------------------------
       
   146 QDateTime UniViewerFeederPrivate::timeStamp()
       
   147 {
       
   148 
       
   149     return mPluginInterface->timeStamp();
       
   150 }
       
   151 
       
   152 // ---------------------------------------------------------------------------
       
   153 // UniViewerFeederPrivate::fetchDetailsL
       
   154 // Fetches message details from the store.
       
   155 // ---------------------------------------------------------------------------
       
   156 void UniViewerFeederPrivate::fetchDetailsL()
       
   157 {
       
   158     QDEBUG_WRITE("UniViewerFeederPrivate fetchDetailsL : SMS start");
       
   159     if (msgType() == KSenduiMtmSmsUidValue)
       
   160     {
       
   161         QString body;
       
   162         mPluginInterface->body(body);
       
   163         q_ptr->emitMsgBody(body);
       
   164     }
       
   165     QDEBUG_WRITE("UniViewerFeederPrivate fetchDetailsL : SMS END");
       
   166 }
       
   167 
       
   168 // ---------------------------------------------------------------------------
       
   169 // UniViewerFeederPrivate::hasAttachments
       
   170 // @see header file
       
   171 // ---------------------------------------------------------------------------
       
   172 bool UniViewerFeederPrivate::hasAttachments()
       
   173 {
       
   174     return mPluginInterface->hasAttachment();
       
   175 }
       
   176 // ---------------------------------------------------------------------------
       
   177 // UniViewerFeederPrivate::attachmentsList
       
   178 // @see header file
       
   179 // ---------------------------------------------------------------------------
       
   180 UniMessageInfoList UniViewerFeederPrivate::attachmentsList()
       
   181 {
       
   182     return mPluginInterface->attachmentList();
       
   183 }
       
   184 
       
   185 // ---------------------------------------------------------------------------
       
   186 // UniViewerFeederPrivate::attachmentCount
       
   187 // @see header file
       
   188 // ---------------------------------------------------------------------------
       
   189 int UniViewerFeederPrivate::attachmentCount()
       
   190 {
       
   191     return mPluginInterface->attachmentCount();
       
   192 }
       
   193 
       
   194 // ---------------------------------------------------------------------------
       
   195 // UniViewerFeederPrivate::objectsList
       
   196 // @see header file
       
   197 // ---------------------------------------------------------------------------
       
   198 UniMessageInfoList UniViewerFeederPrivate::objectsList()
       
   199 {
       
   200     return mPluginInterface->objectList();
       
   201 }
       
   202 
       
   203 // ---------------------------------------------------------------------------
       
   204 // UniViewerFeederPrivate::objectCount
       
   205 // @see header file
       
   206 // ---------------------------------------------------------------------------
       
   207 int UniViewerFeederPrivate::objectCount()
       
   208 {
       
   209     return mPluginInterface->objectCount();
       
   210 }
       
   211 
       
   212 // ---------------------------------------------------------------------------
       
   213 // UniViewerFeederPrivate::slideCount
       
   214 // @see header file
       
   215 // ---------------------------------------------------------------------------
       
   216 int UniViewerFeederPrivate::slideCount()
       
   217 {
       
   218     return mSlideCount;
       
   219 }
       
   220 
       
   221 // ---------------------------------------------------------------------------
       
   222 // UniViewerFeederPrivate::slideContent
       
   223 // @see header file
       
   224 // ---------------------------------------------------------------------------
       
   225 UniMessageInfoList UniViewerFeederPrivate::slideContent(int slidenum)
       
   226 {
       
   227     return mPluginInterface->slideContent(slidenum);
       
   228 }
       
   229 
       
   230 // ---------------------------------------------------------------------------
       
   231 // UniViewerFeederPrivate::updateContent
       
   232 // @see header file
       
   233 // ---------------------------------------------------------------------------
       
   234 void UniViewerFeederPrivate::updateContent(qint32 msgId)
       
   235 {
       
   236   
       
   237     if (msgId != mMsgId)
       
   238     {
       
   239         mMsgId = msgId;
       
   240         TMsvId serviceId = KMsvNullIndexEntryId;
       
   241         mSession->GetEntry(msgId, serviceId, mEntry);
       
   242         clearContent();
       
   243     }
       
   244 
       
   245     if (msgType() == KSenduiMtmSmsUidValue)
       
   246     {
       
   247         mPluginInterface = mPluginLoader->getDataModelPlugin(ConvergedMessage::Sms);
       
   248         mPluginInterface->setMessageId(msgId);
       
   249     }
       
   250 
       
   251     if (msgType() == KSenduiMtmMmsUidValue)
       
   252     {
       
   253         mPluginInterface = mPluginLoader->getDataModelPlugin(ConvergedMessage::Mms);
       
   254         mPluginInterface->setMessageId(msgId);
       
   255         mSlideCount = mPluginInterface->slideCount();
       
   256     }
       
   257     mPluginInterface->toRecipientList(mToAddressList);
       
   258     mPluginInterface->ccRecipientList(mCcAddressList);
       
   259 }
       
   260 
       
   261 // ---------------------------------------------------------------------------
       
   262 // UniViewerFeederPrivate::toAddressList
       
   263 // @see header file
       
   264 // ---------------------------------------------------------------------------
       
   265 ConvergedMessageAddressList UniViewerFeederPrivate::toAddressList()
       
   266 {
       
   267     QString alias = QString();
       
   268     for (int i = 0; i < mToAddressList.count(); ++i)
       
   269     {
       
   270         MsgContactHandler::resolveContactDisplayName(
       
   271                 mToAddressList.at(i)->address(),
       
   272                 alias,
       
   273                 0);
       
   274         mToAddressList.at(i)->setAlias(alias);
       
   275         alias.clear();
       
   276     }
       
   277     return mToAddressList;
       
   278 }
       
   279 
       
   280 // ---------------------------------------------------------------------------
       
   281 // UniViewerFeederPrivate::ccAddressList
       
   282 // @see header file
       
   283 // ---------------------------------------------------------------------------
       
   284 ConvergedMessageAddressList UniViewerFeederPrivate::ccAddressList()
       
   285 {
       
   286     QString alias = QString();
       
   287     for (int i = 0; i < mCcAddressList.count(); ++i)
       
   288     {
       
   289         MsgContactHandler::resolveContactDisplayName(
       
   290                         mToAddressList.at(i)->address(),
       
   291                         alias,
       
   292                         0);
       
   293         mCcAddressList.at(i)->setAlias(alias);
       
   294         alias.clear();
       
   295 
       
   296     }
       
   297     return mCcAddressList;
       
   298 }
       
   299 
       
   300 // ---------------------------------------------------------------------------
       
   301 // UniViewerFeederPrivate::messageSize
       
   302 // @see header file
       
   303 // ---------------------------------------------------------------------------
       
   304 int UniViewerFeederPrivate::messageSize()
       
   305 {
       
   306     return mPluginInterface->messageSize();
       
   307 }
       
   308 
       
   309 // ---------------------------------------------------------------------------
       
   310 // UniViewerFeederPrivate::fromAddressAndAlias
       
   311 // @see header file
       
   312 // ---------------------------------------------------------------------------
       
   313 void UniViewerFeederPrivate::fromAddressAndAlias(QString& from, QString& alias)
       
   314 {
       
   315     mPluginInterface->fromAddress(from);
       
   316     MsgContactHandler::resolveContactDisplayName(
       
   317                     from,
       
   318                     alias,
       
   319                     0);
       
   320 }
       
   321 
       
   322 // ---------------------------------------------------------------------------
       
   323 // UniViewerFeederPrivate::clearContent
       
   324 // @see header file
       
   325 // ---------------------------------------------------------------------------
       
   326 void UniViewerFeederPrivate::clearContent()
       
   327 {
       
   328     for (int i = 0; i < mToAddressList.count(); ++i)
       
   329     {
       
   330         delete mToAddressList.at(i);
       
   331     }
       
   332     mToAddressList.clear();
       
   333 
       
   334     for (int i = 0; i < mCcAddressList.count(); ++i)
       
   335     {
       
   336         delete mCcAddressList.at(i);
       
   337     }
       
   338 
       
   339     mCcAddressList.clear();
       
   340 }
       
   341 
       
   342 // EOF