emailservices/nmclientapi/src/nmapiemailservice.cpp
changeset 18 578830873419
child 20 ecc8def7944a
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 
       
    18 #include "nmapiemailservice.h"
       
    19 #include "nmapiengine.h"
       
    20 namespace EmailClientApi
       
    21 {
       
    22 NmEmailService::NmEmailService(QObject *parent) :
       
    23     QObject(parent), mEngine(NULL)
       
    24 {
       
    25 
       
    26 }
       
    27 
       
    28 NmEmailService::~NmEmailService()
       
    29 {
       
    30     if (mEngine) {
       
    31         uninitialise();
       
    32     }
       
    33 }
       
    34 
       
    35 bool NmEmailService::envelope(
       
    36     const quint64 mailboxId,
       
    37     const quint64 folderId,
       
    38     const quint64 envelopeId,
       
    39     NmMessageEnvelope &envelope)
       
    40 {
       
    41     if (!mEngine) {
       
    42         return false;
       
    43     }
       
    44     return mEngine->envelopeById(mailboxId, folderId, envelopeId, envelope);
       
    45 }
       
    46 
       
    47 bool NmEmailService::mailbox(const quint64 mailboxId, NmMailbox &mailboxInfo)
       
    48 {
       
    49     if (!mEngine) {
       
    50         return false;
       
    51     }
       
    52     return mEngine->mailboxById(mailboxId, mailboxInfo);
       
    53 }
       
    54 
       
    55 void NmEmailService::initialise()
       
    56 {
       
    57     if (!mEngine) {
       
    58         mEngine = NmEngine::instance();
       
    59     }
       
    60 
       
    61     if (mEngine) {
       
    62         mIsRunning = true;
       
    63         emit initialized(true);
       
    64     }
       
    65     else {
       
    66         emit initialized(false);
       
    67     }
       
    68 }
       
    69 
       
    70 void NmEmailService::uninitialise()
       
    71 {
       
    72     NmEngine::releaseInstance(mEngine);
       
    73     mIsRunning = false;
       
    74 }
       
    75 
       
    76 bool NmEmailService::isRunning() const
       
    77 {
       
    78     return mIsRunning;
       
    79 }
       
    80 
       
    81 }