emailservices/nmclientapi/src/nmapiengine.cpp
author hgs
Thu, 14 Oct 2010 17:33:43 +0300
changeset 76 38bf5461e270
parent 74 6c59112cfd31
permissions -rw-r--r--
201041
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     1
/*
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     2
 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     3
 * All rights reserved.
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     4
 * This component and the accompanying materials are made available
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     5
 * under the terms of "Eclipse Public License v1.0"
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     6
 * which accompanies this distribution, and is available
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     7
 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     8
 *
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     9
 * Initial Contributors:
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    10
 * Nokia Corporation - initial contribution.
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    11
 *
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    12
 * Contributors:
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    13
 *
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    14
 * Description:
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    15
 *
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    16
 */
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    17
48
10eaf342f539 201025_1
hgs
parents: 44
diff changeset
    18
#include "nmapiheaders.h"
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
    19
76
hgs
parents: 74
diff changeset
    20
hgs
parents: 74
diff changeset
    21
namespace EmailClientApi
hgs
parents: 74
diff changeset
    22
{
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
    23
NmApiEngine *NmApiEngine::mInstance = NULL;
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
    24
quint32 NmApiEngine::mReferenceCount = 0;
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    25
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    26
/*!
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
    27
   \class NmApiEngine
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
    28
   \brief The NmEngine class provides access to data for
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
    29
   mailboxes, folders and messages.
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    30
 */
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    31
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    32
/*!
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
    33
   Private constructor
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    34
 */
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
    35
NmApiEngine::NmApiEngine() :
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    36
    mFactory(NULL)
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    37
{
43
hgs
parents: 23
diff changeset
    38
    NM_FUNCTION;
hgs
parents: 23
diff changeset
    39
    
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
    40
    mFactory = NmApiDataPluginFactory::instance();
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    41
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    42
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    43
/*!
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
    44
  Destructor
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    45
 */
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
    46
NmApiEngine::~NmApiEngine()
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    47
{
43
hgs
parents: 23
diff changeset
    48
    NM_FUNCTION;
hgs
parents: 23
diff changeset
    49
    
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
    50
    NmApiDataPluginFactory::releaseInstance(mFactory);
68
hgs
parents: 66
diff changeset
    51
    
hgs
parents: 66
diff changeset
    52
    if (mMailPlugins.Count() > 0) {
hgs
parents: 66
diff changeset
    53
        CFSMailPlugin* plugin = NULL;
hgs
parents: 66
diff changeset
    54
        for (int i = 0; i < mMailPlugins.Count(); ++i) {
hgs
parents: 66
diff changeset
    55
            plugin = mMailPlugins[i];
hgs
parents: 66
diff changeset
    56
            
hgs
parents: 66
diff changeset
    57
            if (plugin) {
hgs
parents: 66
diff changeset
    58
                delete plugin;
hgs
parents: 66
diff changeset
    59
                plugin = NULL;
hgs
parents: 66
diff changeset
    60
            }
hgs
parents: 66
diff changeset
    61
            
hgs
parents: 66
diff changeset
    62
            CFSMailPlugin::Close();
hgs
parents: 66
diff changeset
    63
        }
hgs
parents: 66
diff changeset
    64
    }
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    65
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    66
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    67
/*!
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
    68
   Creates instance of NmApiEngine and provide pointer to it.
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
    69
   
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
    70
   If engine exist, it increase references count and provide pointer to it.
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
    71
   
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
    72
   \return Instance of engine
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    73
 */
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
    74
NmApiEngine *NmApiEngine::instance()
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    75
{
43
hgs
parents: 23
diff changeset
    76
    NM_FUNCTION;
hgs
parents: 23
diff changeset
    77
    
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    78
    if (!mInstance) {
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
    79
        mInstance = new NmApiEngine();
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    80
    }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    81
    mReferenceCount++;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    82
    return mInstance;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    83
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    84
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    85
/*!
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
    86
   Creates connections for events from email store.
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    87
 */
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
    88
void NmApiEngine::startCollectingEvents()
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    89
{
43
hgs
parents: 23
diff changeset
    90
    NM_FUNCTION;
hgs
parents: 23
diff changeset
    91
    
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
    92
    QObject *plugin = mFactory->plugin();
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
    93
    if(plugin){
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
    94
        connect(plugin, SIGNAL(messageEvent(NmMessageEvent, NmId, QList<NmId> , NmId)), this,
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
    95
            SLOT(messageChangedArrived(NmMessageEvent, NmId, QList<NmId> , NmId)), Qt::UniqueConnection);
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    96
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    97
        connect(plugin, SIGNAL(mailboxEvent(NmMailboxEvent, QList<NmId> )), this, SLOT(
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    98
            mailboxChangedArrived(NmMailboxEvent, QList<NmId> )), Qt::UniqueConnection);
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    99
    }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   100
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   101
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   102
/*!
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   103
   It process mailbox ids from email store for given event.
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   104
   On end it emit \sa emailStoreEvent
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   105
   
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   106
   \arg Event of mailbox change
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   107
   \arg List of mailbox ids for that event 
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   108
 */
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   109
void NmApiEngine::mailboxChangedArrived(NmMailboxEvent mailboxEvent, const QList<NmId> &mailboxIds)
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   110
{
43
hgs
parents: 23
diff changeset
   111
    NM_FUNCTION;
hgs
parents: 23
diff changeset
   112
    
68
hgs
parents: 66
diff changeset
   113
    NmApiEvent event;
hgs
parents: 66
diff changeset
   114
    event.objectType = EMailbox;
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   115
    switch (mailboxEvent) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   116
        case NmMailboxCreated: {
68
hgs
parents: 66
diff changeset
   117
            event.action = ENew;
44
hgs
parents: 43
diff changeset
   118
            // subscribe all events also for these new mailboxes
hgs
parents: 43
diff changeset
   119
            for(int i=0; i<mailboxIds.count(); i++) {
hgs
parents: 43
diff changeset
   120
                mFactory->interfaceInstance()->subscribeMailboxEvents(mailboxIds[i]);
hgs
parents: 43
diff changeset
   121
            }
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   122
        }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   123
            break;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   124
        case NmMailboxDeleted: {
68
hgs
parents: 66
diff changeset
   125
            event.action = EDeleted;
44
hgs
parents: 43
diff changeset
   126
            // unsubscribe all events from deleted mailboxes
hgs
parents: 43
diff changeset
   127
            for(int i=0; i<mailboxIds.count(); i++) {
hgs
parents: 43
diff changeset
   128
                mFactory->interfaceInstance()->unsubscribeMailboxEvents(mailboxIds[i]);
hgs
parents: 43
diff changeset
   129
            }
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   130
        }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   131
            break;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   132
        case NmMailboxChanged: {
68
hgs
parents: 66
diff changeset
   133
            event.action = EChange;
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   134
        }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   135
            break;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   136
        default:
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   137
            break;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   138
    }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   139
68
hgs
parents: 66
diff changeset
   140
    event.folderId = 0;
hgs
parents: 66
diff changeset
   141
    event.mailboxId = 0;
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   142
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   143
    for (int i = 0; i < mailboxIds.count(); i++) {
68
hgs
parents: 66
diff changeset
   144
        event.objectIds.append(mailboxIds.at(i).id());
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   145
    }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   146
68
hgs
parents: 66
diff changeset
   147
    emit emailStoreEvent(event);
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   148
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   149
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   150
/*!
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   151
   It process message ids from email store for given event.
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   152
   On end it emit \sa emailStoreEvent
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   153
   
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   154
   \param messageEvent Event of message change
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   155
   \param folderId Id of folder from where are messages
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   156
   \param messageIds List of message ids for that event 
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   157
   \param mailboxId Id of mailbox from where are messages
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   158
 */
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   159
void NmApiEngine::messageChangedArrived(
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   160
    NmMessageEvent messageEvent,
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   161
    const NmId &folderId,
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   162
    const QList<NmId> &messageIds,
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   163
    const NmId &mailboxId)
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   164
{
43
hgs
parents: 23
diff changeset
   165
    NM_FUNCTION;
hgs
parents: 23
diff changeset
   166
    
68
hgs
parents: 66
diff changeset
   167
    NmApiEvent event;
hgs
parents: 66
diff changeset
   168
    event.objectType = EMessage;
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   169
    switch (messageEvent) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   170
        case NmMessageCreated: {
68
hgs
parents: 66
diff changeset
   171
            event.action = ENew;
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   172
        }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   173
            break;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   174
        case NmMessageDeleted: {
68
hgs
parents: 66
diff changeset
   175
            event.action = EDeleted;
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   176
        }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   177
            break;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   178
        case NmMessageChanged: {
68
hgs
parents: 66
diff changeset
   179
            event.action = EChange;
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   180
        }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   181
            break;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   182
        default:
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   183
            break;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   184
    }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   185
68
hgs
parents: 66
diff changeset
   186
    event.folderId = folderId.id();
hgs
parents: 66
diff changeset
   187
    event.mailboxId = mailboxId.id();
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   188
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   189
    for (int i = 0; i < messageIds.count(); i++) {
68
hgs
parents: 66
diff changeset
   190
        event.objectIds.append(messageIds.at(i).id());
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   191
    }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   192
68
hgs
parents: 66
diff changeset
   193
    emit emailStoreEvent(event);
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   194
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   195
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   196
/*!
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   197
   Release instance of engine if there are not referenced objects. 
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   198
   If there are refenced objects it only decrease refenced count.
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   199
   
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   200
   \param instance Instance of engine
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   201
 */
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   202
void NmApiEngine::releaseInstance(NmApiEngine *&instance)
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   203
{
43
hgs
parents: 23
diff changeset
   204
    NM_FUNCTION;
hgs
parents: 23
diff changeset
   205
    
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   206
    //can't have passed out instances if we don't have any
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   207
    if (mInstance) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   208
        if (instance == mInstance) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   209
            instance = NULL;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   210
            mReferenceCount--;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   211
        }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   212
        if (0 >= mReferenceCount) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   213
            delete mInstance;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   214
            mInstance = NULL;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   215
        }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   216
    }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   217
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   218
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   219
/*!
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   220
      It get all mailboxes from email store
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   221
      
76
hgs
parents: 74
diff changeset
   222
      \sa NmMailbox
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   223
      \param mailboxList List of mailboxes to be filled.
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   224
 */
76
hgs
parents: 74
diff changeset
   225
void NmApiEngine::listMailboxes(QList<NmApiMailbox> &mailboxList)
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   226
{
43
hgs
parents: 23
diff changeset
   227
    NM_FUNCTION;
hgs
parents: 23
diff changeset
   228
    
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   229
    QList<NmMailbox*> mailboxFromPlugin;
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   230
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   231
    NmDataPluginInterface *instance =  mFactory->interfaceInstance();
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   232
    if (instance) {
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   233
        instance->listMailboxes(mailboxFromPlugin);
66
hgs
parents: 48
diff changeset
   234
        
hgs
parents: 48
diff changeset
   235
        while (mailboxFromPlugin.isEmpty() == false) {
hgs
parents: 48
diff changeset
   236
            NmMailbox* tempNmMailbox = mailboxFromPlugin.takeLast();
hgs
parents: 48
diff changeset
   237
    
hgs
parents: 48
diff changeset
   238
            // subscribe all events also for these new mailboxes
hgs
parents: 48
diff changeset
   239
            instance->subscribeMailboxEvents(tempNmMailbox->id());
hgs
parents: 48
diff changeset
   240
    
hgs
parents: 48
diff changeset
   241
            // construct mailboxlist to platform api
hgs
parents: 48
diff changeset
   242
            mailboxList << NmToApiConverter::NmMailbox2NmApiMailbox(*tempNmMailbox);
hgs
parents: 48
diff changeset
   243
    
hgs
parents: 48
diff changeset
   244
            delete tempNmMailbox;
hgs
parents: 48
diff changeset
   245
        }
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   246
    }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   247
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   248
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   249
/*!
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   250
      It get all folders from email store for given mailbox
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   251
      
76
hgs
parents: 74
diff changeset
   252
      \sa NmApiFolder
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   253
      \param mailboxId Mailbox id from where folders should be returned
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   254
      \param folderList  of folders to be filled.
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   255
 */
76
hgs
parents: 74
diff changeset
   256
void NmApiEngine::listFolders(const quint64 mailboxId, QList<NmApiFolder> &folderList)
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   257
{
43
hgs
parents: 23
diff changeset
   258
    NM_FUNCTION;
hgs
parents: 23
diff changeset
   259
    
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   260
    QList<NmFolder*> folderFromPlugin;
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   261
    NmDataPluginInterface *instance = mFactory->interfaceInstance();
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   262
    if (instance) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   263
        instance->listFolders(mailboxId, folderFromPlugin);
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   264
    }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   265
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   266
    while (folderFromPlugin.isEmpty() == false) {
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   267
        NmFolder* tempNmFolder = folderFromPlugin.takeLast();
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   268
        folderList << NmToApiConverter::NmFolder2NmApiFolder(*tempNmFolder);
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   269
        delete tempNmFolder;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   270
    }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   271
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   272
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   273
/*!
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   274
      It get all envelopes from email store for given mailbox and folder
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   275
      
76
hgs
parents: 74
diff changeset
   276
      \sa NmApiMessageEnvelope
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   277
      \param mailboxId Mailbox id from where envelope should be returned
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   278
      \param folderId Folder id from where envelope should be returned
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   279
      \param messageEnvelopeList List of envelopes to be filled.
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   280
 */
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   281
void NmApiEngine::listEnvelopes(const quint64 mailboxId, const quint64 folderId, 
76
hgs
parents: 74
diff changeset
   282
                    QList<NmApiMessageEnvelope> &messageEnvelopeList)
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   283
{
43
hgs
parents: 23
diff changeset
   284
    NM_FUNCTION;
hgs
parents: 23
diff changeset
   285
    
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   286
    QList<NmMessage*> messages;
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   287
    NmDataPluginInterface *instance = mFactory->interfaceInstance();
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   288
    if (instance) {
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   289
        instance->listMessages(mailboxId, folderId, messages);
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   290
    }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   291
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   292
    while (!messages.isEmpty()) {
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   293
        NmMessage* message = messages.takeFirst();
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   294
            
76
hgs
parents: 74
diff changeset
   295
        NmApiMessageEnvelope nmEnvelope =
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   296
            NmToApiConverter::NmMessageEnvelope2NmApiMessageEnvelope(message->envelope());
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   297
        
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   298
        NmMessagePart *plainTextPart = message->plainTextBodyPart();
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   299
        
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   300
        QString plainText = QString();
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   301
        if (plainTextPart) {
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   302
            plainText = plainTextPart->textContent();
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   303
        }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   304
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   305
        nmEnvelope.setPlainText(plainText);
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   306
        nmEnvelope.setFetchedSize(message->fetchedSize());
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   307
        nmEnvelope.setTotalSize(message->size());
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   308
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   309
        messageEnvelopeList << nmEnvelope;
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   310
        delete message;
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   311
    }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   312
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   313
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   314
/*!
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   315
   Return envelope given by mailbox, folder and envelope id.
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   316
   
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   317
   \param mailboxId Mailbox id from where envlope should come
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   318
   \param folderId Folder id from where envlope should come
74
hgs
parents: 68
diff changeset
   319
   \param messageId Id of envelope which should be returned
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   320
   \param envelope Envelope to fill.
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   321
   
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   322
   \return Return true if it will find any envelope
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   323
 */
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   324
bool NmApiEngine::getEnvelopeById(
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   325
    const quint64 mailboxId,
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   326
    const quint64 folderId,
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   327
    const quint64 envelopeId,
76
hgs
parents: 74
diff changeset
   328
    NmApiMessageEnvelope &envelope)
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   329
{
43
hgs
parents: 23
diff changeset
   330
    NM_FUNCTION;
hgs
parents: 23
diff changeset
   331
    
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   332
    //flag indicating that envelope with given id was found
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   333
    bool found = false;
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   334
    NmDataPluginInterface *instance = mFactory->interfaceInstance();
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   335
    if (instance) {
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   336
        NmMessage *message(NULL);
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   337
        instance->getMessageById(mailboxId, folderId, envelopeId, message);
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   338
        if(message){
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   339
            NmMessageEnvelope env = message->envelope();
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   340
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   341
            envelope = NmToApiConverter::NmMessageEnvelope2NmApiMessageEnvelope(env);
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   342
            QString plainText = QString();
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   343
            
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   344
            NmMessagePart *plainTextPart = message->plainTextBodyPart();
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   345
            if (plainTextPart) {
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   346
                instance->contentToMessagePart(mailboxId, folderId, envelopeId, *plainTextPart);
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   347
                plainText = plainTextPart->textContent();
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   348
            }
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   349
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   350
            envelope.setPlainText(plainText);
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   351
            envelope.setFetchedSize(message->fetchedSize());
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   352
            envelope.setTotalSize(message->size());
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   353
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   354
            found = true;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   355
        }
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   356
        delete message;
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   357
    }
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   358
    return found;
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   359
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   360
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   361
/*!
74
hgs
parents: 68
diff changeset
   362
   Return folder given by mailbox and folder id.
hgs
parents: 68
diff changeset
   363
   
hgs
parents: 68
diff changeset
   364
   \param mailboxId Id of Mailbox which should be returned
hgs
parents: 68
diff changeset
   365
   \param folderId Folder id id of folder to be fetched
hgs
parents: 68
diff changeset
   366
   \param mailboxFolder reference to copy reference of NmApiFolder
hgs
parents: 68
diff changeset
   367
   
hgs
parents: 68
diff changeset
   368
   \return Return true if it will find folder
hgs
parents: 68
diff changeset
   369
 */
hgs
parents: 68
diff changeset
   370
bool NmApiEngine::getFolderById(
hgs
parents: 68
diff changeset
   371
    const quint64 mailboxId,
hgs
parents: 68
diff changeset
   372
    const quint64 folderId,
76
hgs
parents: 74
diff changeset
   373
    NmApiFolder &mailboxFolder)
74
hgs
parents: 68
diff changeset
   374
{
hgs
parents: 68
diff changeset
   375
    NM_FUNCTION;
hgs
parents: 68
diff changeset
   376
hgs
parents: 68
diff changeset
   377
    bool found = false;
hgs
parents: 68
diff changeset
   378
hgs
parents: 68
diff changeset
   379
    listMailPlugins();
hgs
parents: 68
diff changeset
   380
hgs
parents: 68
diff changeset
   381
    CFSMailPlugin *plugin = NULL;
hgs
parents: 68
diff changeset
   382
    CFSMailFolder *fsFolder = NULL;
hgs
parents: 68
diff changeset
   383
    TFSMailMsgId fsMailBoxId = TFSMailMsgId(mailboxId);
hgs
parents: 68
diff changeset
   384
    TFSMailMsgId fsFolderId = TFSMailMsgId(folderId);
hgs
parents: 68
diff changeset
   385
hgs
parents: 68
diff changeset
   386
    for (int i = 0; i < mMailPlugins.Count() && !fsFolder; i++){
hgs
parents: 68
diff changeset
   387
        plugin = mMailPlugins[i];
hgs
parents: 68
diff changeset
   388
        if (plugin && (plugin->Id() == fsMailBoxId.PluginId())) {
hgs
parents: 68
diff changeset
   389
            TRAPD(err, fsFolder = plugin->GetFolderByUidL(fsMailBoxId, fsFolderId));
hgs
parents: 68
diff changeset
   390
            Q_UNUSED(err);
hgs
parents: 68
diff changeset
   391
        }
hgs
parents: 68
diff changeset
   392
    }
hgs
parents: 68
diff changeset
   393
    if (fsFolder) {
hgs
parents: 68
diff changeset
   394
        NmFolder *nmFolder = fsFolder->GetNmFolder();
76
hgs
parents: 74
diff changeset
   395
        NmApiFolder apiFolder = NmToApiConverter::NmFolder2NmApiFolder(*nmFolder);
74
hgs
parents: 68
diff changeset
   396
        mailboxFolder = apiFolder;
hgs
parents: 68
diff changeset
   397
        found = true;
hgs
parents: 68
diff changeset
   398
        delete nmFolder;
hgs
parents: 68
diff changeset
   399
        delete fsFolder;
hgs
parents: 68
diff changeset
   400
    }
hgs
parents: 68
diff changeset
   401
    return found;
hgs
parents: 68
diff changeset
   402
}
hgs
parents: 68
diff changeset
   403
hgs
parents: 68
diff changeset
   404
/*!
68
hgs
parents: 66
diff changeset
   405
   Return message given by mailbox, folder and message id.
hgs
parents: 66
diff changeset
   406
   
hgs
parents: 66
diff changeset
   407
   \param mailboxId Mailbox id from where message should come
hgs
parents: 66
diff changeset
   408
   \param folderId Folder id from where message should come
hgs
parents: 66
diff changeset
   409
   \param messageId Id of message which should be returned
hgs
parents: 66
diff changeset
   410
   \param message Envelope to fill.
hgs
parents: 66
diff changeset
   411
   
hgs
parents: 66
diff changeset
   412
   \return Return true if it will find any envelope
hgs
parents: 66
diff changeset
   413
 */
hgs
parents: 66
diff changeset
   414
bool NmApiEngine::getMessageById(
hgs
parents: 66
diff changeset
   415
    const quint64 mailboxId,
hgs
parents: 66
diff changeset
   416
    const quint64 folderId,
hgs
parents: 66
diff changeset
   417
    const quint64 messageId,
76
hgs
parents: 74
diff changeset
   418
    NmApiMessage &message)
68
hgs
parents: 66
diff changeset
   419
{
hgs
parents: 66
diff changeset
   420
    NM_FUNCTION;
hgs
parents: 66
diff changeset
   421
    
hgs
parents: 66
diff changeset
   422
    bool found = false;
hgs
parents: 66
diff changeset
   423
    
hgs
parents: 66
diff changeset
   424
    listMailPlugins();
hgs
parents: 66
diff changeset
   425
hgs
parents: 66
diff changeset
   426
    CFSMailPlugin *plugin = NULL;
74
hgs
parents: 68
diff changeset
   427
    CFSMailMessage *fsMessage = NULL;
68
hgs
parents: 66
diff changeset
   428
    TFSMailMsgId fsMailBoxId = TFSMailMsgId(mailboxId);
hgs
parents: 66
diff changeset
   429
    TFSMailMsgId fsFolderId = TFSMailMsgId(folderId);
hgs
parents: 66
diff changeset
   430
    TFSMailMsgId fsMessageId = TFSMailMsgId(messageId);
hgs
parents: 66
diff changeset
   431
    
hgs
parents: 66
diff changeset
   432
    for (int i = 0; i < mMailPlugins.Count() && !fsMessage; i++){
hgs
parents: 66
diff changeset
   433
        plugin = mMailPlugins[i];
74
hgs
parents: 68
diff changeset
   434
        if (plugin && (plugin->Id() == fsMailBoxId.PluginId())) {
hgs
parents: 68
diff changeset
   435
            TRAPD(err, fsMessage = plugin->GetMessageByUidL(fsMailBoxId,
68
hgs
parents: 66
diff changeset
   436
                    fsFolderId,
hgs
parents: 66
diff changeset
   437
                    fsMessageId,
74
hgs
parents: 68
diff changeset
   438
                    EFSMsgDataStructure));
hgs
parents: 68
diff changeset
   439
            Q_UNUSED(err);
68
hgs
parents: 66
diff changeset
   440
        }
hgs
parents: 66
diff changeset
   441
    }
hgs
parents: 66
diff changeset
   442
    if (fsMessage) {
hgs
parents: 66
diff changeset
   443
        NmMessage *nmMessage = fsMessage->GetNmMessage();
76
hgs
parents: 74
diff changeset
   444
        NmApiMessage apiMessage = NmToApiConverter::NmMessage2NmApiMessage(*nmMessage);
68
hgs
parents: 66
diff changeset
   445
        message = apiMessage;
hgs
parents: 66
diff changeset
   446
        found = true;
74
hgs
parents: 68
diff changeset
   447
        delete nmMessage;
68
hgs
parents: 66
diff changeset
   448
        delete fsMessage;
hgs
parents: 66
diff changeset
   449
    }
hgs
parents: 66
diff changeset
   450
    return found;
hgs
parents: 66
diff changeset
   451
}
hgs
parents: 66
diff changeset
   452
hgs
parents: 66
diff changeset
   453
hgs
parents: 66
diff changeset
   454
/*!
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   455
   Return mailbox given by mailbox id.
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   456
   
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   457
   \param mailboxId Id of Mailbox which should be returned
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   458
   \param mailbox Mailbox to fill.
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   459
   
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   460
   \return Return true if it will find any envelope
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   461
 */
76
hgs
parents: 74
diff changeset
   462
bool NmApiEngine::getMailboxById(const quint64 mailboxId, NmApiMailbox &mailbox)
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   463
{
43
hgs
parents: 23
diff changeset
   464
    NM_FUNCTION;
hgs
parents: 23
diff changeset
   465
    
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   466
    //flag indicating that mailbox with given id was found
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   467
    bool found = false;
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   468
    NmDataPluginInterface *instance = mFactory->interfaceInstance();
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   469
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   470
    if (instance) {    
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   471
        NmMailbox *nmmailbox = NULL;
74
hgs
parents: 68
diff changeset
   472
        int err =instance->getMailboxById(NmId(mailboxId), nmmailbox);
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   473
    
74
hgs
parents: 68
diff changeset
   474
        if (err == NmNoError && nmmailbox) {
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   475
            mailbox = NmToApiConverter::NmMailbox2NmApiMailbox(*nmmailbox);
74
hgs
parents: 68
diff changeset
   476
            found = true;            
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   477
        }
74
hgs
parents: 68
diff changeset
   478
        delete nmmailbox;
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   479
    }
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   480
    
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   481
    return found;
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   482
}
68
hgs
parents: 66
diff changeset
   483
hgs
parents: 66
diff changeset
   484
/*!
hgs
parents: 66
diff changeset
   485
 \fn listMailPlugins 
hgs
parents: 66
diff changeset
   486
 \param mailPlugins List of mail plugins to be listed.
hgs
parents: 66
diff changeset
   487
 \return True if operation completed succesfully, otherwise false.
hgs
parents: 66
diff changeset
   488
 
hgs
parents: 66
diff changeset
   489
 Lists all mail plugins.  
hgs
parents: 66
diff changeset
   490
 */
hgs
parents: 66
diff changeset
   491
bool NmApiEngine::listMailPlugins(RPointerArray<CFSMailPlugin> &mailPlugins)
hgs
parents: 66
diff changeset
   492
{
hgs
parents: 66
diff changeset
   493
    NM_FUNCTION;
hgs
parents: 66
diff changeset
   494
    bool ret = false;
hgs
parents: 66
diff changeset
   495
    if (mMailPlugins.Count() == 0) {
hgs
parents: 66
diff changeset
   496
        TRAPD(err, listMailPluginsL());
hgs
parents: 66
diff changeset
   497
        if (err == KErrNone){
hgs
parents: 66
diff changeset
   498
            ret = true;
hgs
parents: 66
diff changeset
   499
        }
hgs
parents: 66
diff changeset
   500
    } else {
hgs
parents: 66
diff changeset
   501
        ret = true;
hgs
parents: 66
diff changeset
   502
    }
hgs
parents: 66
diff changeset
   503
    mailPlugins = mMailPlugins;
hgs
parents: 66
diff changeset
   504
    
hgs
parents: 66
diff changeset
   505
    return ret;
hgs
parents: 66
diff changeset
   506
}
hgs
parents: 66
diff changeset
   507
hgs
parents: 66
diff changeset
   508
/*!
hgs
parents: 66
diff changeset
   509
 \fn listMailPlugins 
hgs
parents: 66
diff changeset
   510
 
hgs
parents: 66
diff changeset
   511
 Lists all mail plugins.  
hgs
parents: 66
diff changeset
   512
 */
hgs
parents: 66
diff changeset
   513
void NmApiEngine::listMailPlugins()
hgs
parents: 66
diff changeset
   514
{
hgs
parents: 66
diff changeset
   515
    NM_FUNCTION;
hgs
parents: 66
diff changeset
   516
    if (mMailPlugins.Count() == 0) {
hgs
parents: 66
diff changeset
   517
        TRAP_IGNORE(listMailPluginsL());
hgs
parents: 66
diff changeset
   518
    }
hgs
parents: 66
diff changeset
   519
}
hgs
parents: 66
diff changeset
   520
hgs
parents: 66
diff changeset
   521
/*!
hgs
parents: 66
diff changeset
   522
 \fn ListMailPluginsL
hgs
parents: 66
diff changeset
   523
 
hgs
parents: 66
diff changeset
   524
 Leaving version of listMailPlugins.
hgs
parents: 66
diff changeset
   525
 */
hgs
parents: 66
diff changeset
   526
void NmApiEngine::listMailPluginsL()
hgs
parents: 66
diff changeset
   527
{
hgs
parents: 66
diff changeset
   528
    NM_FUNCTION;
hgs
parents: 66
diff changeset
   529
hgs
parents: 66
diff changeset
   530
    RPointerArray<CImplementationInformation> implInfo;
hgs
parents: 66
diff changeset
   531
    CFSMailPlugin::ListImplementationsL(implInfo);
hgs
parents: 66
diff changeset
   532
    CleanupClosePushL(implInfo);    
hgs
parents: 66
diff changeset
   533
    CFSMailPlugin* plugin = NULL;
hgs
parents: 66
diff changeset
   534
    for (int i = 0; i < implInfo.Count(); ++i) {
hgs
parents: 66
diff changeset
   535
        TUid id = implInfo[i]->ImplementationUid();
hgs
parents: 66
diff changeset
   536
        plugin = CFSMailPlugin::NewL(id);
hgs
parents: 66
diff changeset
   537
        
hgs
parents: 66
diff changeset
   538
        if (plugin) {
hgs
parents: 66
diff changeset
   539
            mMailPlugins.AppendL(plugin);
hgs
parents: 66
diff changeset
   540
        }
hgs
parents: 66
diff changeset
   541
    }
hgs
parents: 66
diff changeset
   542
    CleanupStack::Pop(&implInfo);
hgs
parents: 66
diff changeset
   543
}
76
hgs
parents: 74
diff changeset
   544
}
68
hgs
parents: 66
diff changeset
   545