emailservices/nmclientapi/src/nmapienvelopelisting_p.cpp
changeset 18 578830873419
child 23 2dc6caa42ec3
equal deleted inserted replaced
4:e7aa27f58ae1 18:578830873419
       
     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:
       
    15  *
       
    16  */
       
    17 #include "nmapiengine.h"
       
    18 #include "nmapienvelopelisting_p.h"
       
    19 
       
    20 namespace EmailClientApi
       
    21 {
       
    22 NmEnvelopeListingPrivate::NmEnvelopeListingPrivate(QObject* parent) :
       
    23     QObject(parent), mEngine(NULL)
       
    24 {
       
    25 
       
    26 }
       
    27 
       
    28 NmEnvelopeListingPrivate::~NmEnvelopeListingPrivate()
       
    29 {
       
    30     releaseEngine();
       
    31 }
       
    32 
       
    33 /*!
       
    34  * \brief It initialize engine for email operations. 
       
    35  * 
       
    36  * When use initializeEngine need to remember release it.
       
    37  * It return value if initialization go good.
       
    38  * \sa releaseEngine 
       
    39  */
       
    40 bool NmEnvelopeListingPrivate::initializeEngine()
       
    41 {
       
    42     mEngine = NmEngine::instance();
       
    43     return mEngine ? true : false;
       
    44 }
       
    45 
       
    46 /*!
       
    47  * \brief It release engine for email operations.
       
    48  * 
       
    49  * It release Engine and return value if release go good.
       
    50  * 
       
    51  * \arg engine Is used to get info if engine was released, if yes, then argument have value 0.
       
    52  * 
       
    53  * \sa initializeEngine
       
    54  */
       
    55 void NmEnvelopeListingPrivate::releaseEngine()
       
    56 {
       
    57     NmEngine::releaseInstance(mEngine);
       
    58 }
       
    59 
       
    60 /*!
       
    61  * \brief It grab envelopes from engine. 
       
    62  * 
       
    63  * When it start grabing, it release all old.
       
    64  * Because it uses NmMessageEnvelope with sharedData we don't need care about release memory.
       
    65  * 
       
    66  * \return Count of envelopes
       
    67  */
       
    68 qint32 NmEnvelopeListingPrivate::grabEnvelopes()
       
    69 {
       
    70     mEnvelopes.clear();
       
    71     mEngine->listEnvelopes(mailboxId, folderId, mEnvelopes);
       
    72     return mEnvelopes.count();
       
    73 }
       
    74 }
       
    75