emailservices/nmclientapi/src/nmapimailboxlisting_p.cpp
changeset 23 2dc6caa42ec3
parent 18 578830873419
child 30 759dc5235cdb
equal deleted inserted replaced
20:ecc8def7944a 23:2dc6caa42ec3
    15  *
    15  *
    16  */
    16  */
    17 #include "nmapiengine.h"
    17 #include "nmapiengine.h"
    18 #include "nmapimailboxlisting_p.h"
    18 #include "nmapimailboxlisting_p.h"
    19 
    19 
       
    20 #include <nmapimailbox.h>
       
    21 
    20 namespace EmailClientApi
    22 namespace EmailClientApi
    21 {
    23 {
    22 NmMailboxListingPrivate::NmMailboxListingPrivate(QObject* parent) :
    24 NmApiMailboxListingPrivate::NmApiMailboxListingPrivate(QObject *parent) :
    23     QObject(parent), mNmEngine(NULL)
    25     QObject(parent), mNmApiEngine(NULL)
    24 {
    26 {
    25 
    27 
    26 }
    28 }
    27 
    29 
    28 NmMailboxListingPrivate::~NmMailboxListingPrivate()
    30 NmApiMailboxListingPrivate::~NmApiMailboxListingPrivate()
    29 {
    31 {
    30 
    32 
    31 }
    33 }
    32 
    34 
    33 /*!
    35 /*!
    34  * \brief It initialize engine for email operations. 
    36    \brief It initialize engine for email operations. 
    35  * 
    37    
    36  * When use initializeEngine need to remember release it.
    38    When use initializeEngine need to remember release it.
    37  * It return value if initialization go good.
    39    It return value if initialization go good.
    38  * \sa releaseEngine 
    40    \sa releaseEngine 
    39  * \return Return true if engine is good initilialized.
    41    \return Return true if engine is good initilialized.
    40  */
    42  */
    41 bool NmMailboxListingPrivate::initializeEngine()
    43 bool NmApiMailboxListingPrivate::initializeEngine()
    42 {
    44 {
    43     if (!mNmEngine) {
    45     if (!mNmApiEngine) {
    44         mNmEngine = NmEngine::instance();
    46         mNmApiEngine = NmApiEngine::instance();
    45     }
    47     }
    46 
    48 
    47     return mNmEngine ? true : false;
    49     return mNmApiEngine ? true : false;
    48 }
    50 }
    49 
    51 
    50 /*!
    52 /*!
    51  * \brief It release engine for email operations.
    53    \brief It release engine for email operations.
    52  * 
    54    
    53  * It release Engine and return value if release go good.
    55    \sa initializeEngine
    54  * 
       
    55  * \arg engine Is used to get info if engine was released, if yes, then argument have value 0.
       
    56  * 
       
    57  * \sa initializeEngine
       
    58  */
    56  */
    59 void NmMailboxListingPrivate::releaseEngine()
    57 void NmApiMailboxListingPrivate::releaseEngine()
    60 {
    58 {
    61     NmEngine::releaseInstance(mNmEngine);
    59     NmApiEngine::releaseInstance(mNmApiEngine);
    62 }
    60 }
    63 
    61 
    64 /*!
    62 /*!
    65  * \brief It grab mailboxes from engine. 
    63    \brief It grab mailboxes from engine. 
    66  * 
    64    
    67  * When it start grabing, it release all old.
    65    When it start grabing, it release all old.
    68  * Because it uses NmMailbox with sharedData we don't need care about release memory.
    66    Because it uses NmApiMailbox with sharedData we don't need care about release memory.
    69  * 
    67    
    70  * \return Count of mailboxes
    68    \return Count of mailboxes or "-1" if there is no engine
    71  */
    69  */
    72 qint32 NmMailboxListingPrivate::grabMailboxes()
    70 qint32 NmApiMailboxListingPrivate::grabMailboxes()
    73 {
    71 {
       
    72     if (!mNmApiEngine) {
       
    73         return -1;
       
    74     }
       
    75     
    74     mMailboxes.clear();
    76     mMailboxes.clear();
    75 
    77 
    76     mNmEngine->listMailboxes(mMailboxes);
    78     mNmApiEngine->listMailboxes(mMailboxes);
    77     return mMailboxes.count();
    79     return mMailboxes.count();
    78 }
    80 }
    79 }
    81 }