emailservices/nmclientapi/src/nmapifolderlisting_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 "nmapifolderlisting_p.h"
       
    19 
       
    20 namespace EmailClientApi
       
    21 {
       
    22 NmFolderListingPrivate::NmFolderListingPrivate(QObject* parent) :
       
    23     QObject(parent), mEngine(NULL)
       
    24 {
       
    25 
       
    26 }
       
    27 
       
    28 NmFolderListingPrivate::~NmFolderListingPrivate()
       
    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 NmFolderListingPrivate::initializeEngine()
       
    41 {
       
    42     if (!mEngine) {
       
    43         mEngine = NmEngine::instance();
       
    44     }
       
    45 
       
    46     return mEngine ? true : false;
       
    47 }
       
    48 
       
    49 /*!
       
    50  * \brief It release engine for email operations.
       
    51  * 
       
    52  * It release Engine and return value if release go good.
       
    53  * 
       
    54  * \arg engine Is used to get info if engine was released, if yes, then argument have value 0.
       
    55  * 
       
    56  * \sa initializeEngine
       
    57  */
       
    58 void NmFolderListingPrivate::releaseEngine()
       
    59 {
       
    60     NmEngine::releaseInstance(mEngine);
       
    61 }
       
    62 
       
    63 /*!
       
    64  * \brief It grab folders from engine. 
       
    65  * 
       
    66  * When it start grabing, it release all old.
       
    67  * Because it uses NmFolder with sharedData we don't need care about release memory.
       
    68  * 
       
    69  * \return Count of folders
       
    70  */
       
    71 qint32 NmFolderListingPrivate::grabFolders()
       
    72 {
       
    73     mFolders.clear();
       
    74     mEngine->listFolders(mMailboxId, mFolders);
       
    75     return mFolders.count();
       
    76 }
       
    77 
       
    78 }
       
    79