emailservices/nmclientapi/src/nmapiemailservice.cpp
branchRCL_3
changeset 63 d189ee25cf9d
equal deleted inserted replaced
61:dcf0eedfc1a3 63:d189ee25cf9d
       
     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 "nmapiheaders.h"
       
    19 
       
    20 
       
    21 namespace EmailClientApi
       
    22 {
       
    23 
       
    24 /*!
       
    25    constructor for NmEmailService
       
    26  */
       
    27 NmApiEmailService::NmApiEmailService(QObject *parent) :
       
    28     QObject(parent), mEngine(NULL), mIsRunning(false)
       
    29 {
       
    30     NM_FUNCTION;
       
    31 }
       
    32 
       
    33 /*!
       
    34    destructor for NmApiEmailService
       
    35  */
       
    36 NmApiEmailService::~NmApiEmailService()
       
    37 {
       
    38     NM_FUNCTION;
       
    39     
       
    40     if (mEngine) {
       
    41         uninitialise();
       
    42     }
       
    43 }
       
    44 
       
    45 /*!
       
    46    gets mail message envelope by id (see also NmEventNotifier)
       
    47  */
       
    48 bool NmApiEmailService::getEnvelope(
       
    49     const quint64 mailboxId,
       
    50     const quint64 folderId,
       
    51     const quint64 envelopeId,
       
    52     EmailClientApi::NmApiMessageEnvelope &envelope)
       
    53 {
       
    54     NM_FUNCTION;
       
    55     
       
    56     if (!mEngine) {
       
    57         return false;
       
    58     }
       
    59     return mEngine->getEnvelopeById(mailboxId, folderId, envelopeId, envelope);
       
    60 }
       
    61 
       
    62 /*!
       
    63     gets mailbox info by id (see also NmEventNotifier)
       
    64  */
       
    65 bool NmApiEmailService::getMailbox(const quint64 mailboxId, EmailClientApi::NmApiMailbox &mailboxInfo)
       
    66 {
       
    67     NM_FUNCTION;
       
    68     
       
    69     if (!mEngine) {
       
    70         return false;
       
    71     }
       
    72     return mEngine->getMailboxById(mailboxId, mailboxInfo);
       
    73 }
       
    74 
       
    75 /*!
       
    76    Initialises email service. this must be called and initialised signal received 
       
    77    before services of the library are used.
       
    78  */
       
    79 void NmApiEmailService::initialise()
       
    80 {
       
    81     NM_FUNCTION;
       
    82     
       
    83     if (!mEngine) {
       
    84         mEngine = NmApiEngine::instance();
       
    85     }
       
    86 
       
    87     if (mEngine) {
       
    88         mIsRunning = true;
       
    89         emit initialized(true);
       
    90     }
       
    91     else {
       
    92         emit initialized(false);
       
    93     }
       
    94 }
       
    95 
       
    96 /*!
       
    97     frees resources.
       
    98  */
       
    99 void NmApiEmailService::uninitialise()
       
   100 {
       
   101     NM_FUNCTION;
       
   102     
       
   103     NmApiEngine::releaseInstance(mEngine);
       
   104     mIsRunning = false;
       
   105 }
       
   106 
       
   107 /*!
       
   108    returns isrunning flag value
       
   109  */
       
   110 bool NmApiEmailService::isRunning() const
       
   111 {
       
   112     NM_FUNCTION;
       
   113     
       
   114     return mIsRunning;
       
   115 }
       
   116 
       
   117 }
       
   118