emailservices/nmclientapi/src/nmapienvelopelisting_p.cpp
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Fri, 11 Jun 2010 13:27:14 +0300
changeset 30 759dc5235cdb
parent 23 2dc6caa42ec3
child 48 10eaf342f539
child 54 997a02608b3a
permissions -rw-r--r--
Revision: 201021 Kit: 2010123

/*
 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of "Eclipse Public License v1.0"
 * which accompanies this distribution, and is available
 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
 *
 * Initial Contributors:
 * Nokia Corporation - initial contribution.
 *
 * Contributors:
 *
 * Description:
 *
 */

#include "emailtrace.h"

#include "nmapiengine.h"
#include "nmapienvelopelisting_p.h"

#include <nmapimailbox.h>
#include <nmapimessageenvelope.h>



namespace EmailClientApi
{
NmApiEnvelopeListingPrivate::NmApiEnvelopeListingPrivate(QObject *parent) :
    QObject(parent), mEngine(NULL)
{
    NM_FUNCTION;
}

NmApiEnvelopeListingPrivate::~NmApiEnvelopeListingPrivate()
{
    NM_FUNCTION;
    
    releaseEngine();
}

/*!
   \brief It initialize engine for email operations. 
   
   When use initializeEngine need to remember release it.
   It return value if initialization go good.
   \sa releaseEngine 
 */
bool NmApiEnvelopeListingPrivate::initializeEngine()
{
    NM_FUNCTION;
    
    mEngine = NmApiEngine::instance();
    return mEngine ? true : false;
}

/*!
   \brief It release engine for email operations.
   
   \sa initializeEngine
 */
void NmApiEnvelopeListingPrivate::releaseEngine()
{
    NM_FUNCTION;
    
    NmApiEngine::releaseInstance(mEngine);
}

/*!
   \brief It grab envelopes from engine. 
   
   When it start grabing, it release all old.
   Because it uses NmApiMessageEnvelope with sharedData we don't need care about release memory.
   
   \return Count of envelopes or "-1" if there is no engine initialised
 */
qint32 NmApiEnvelopeListingPrivate::grabEnvelopes()
{
    NM_FUNCTION;
    
    if(!mEngine){
        return -1;
    }
    
    mEnvelopes.clear();
    mEngine->listEnvelopes(mailboxId, folderId, mEnvelopes);
    return mEnvelopes.count();
}
}