|
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 |
|
22 namespace EmailClientApi |
|
23 { |
|
24 NmApiEnvelopeListingPrivate::NmApiEnvelopeListingPrivate(const quint64 folderId, const quint64 mailboxId, QObject *parent) |
|
25 :QObject(parent), |
|
26 mFolderId(folderId), |
|
27 mMailboxId(mailboxId), |
|
28 mIsRunning(false), |
|
29 mEngine(NULL) |
|
30 { |
|
31 NM_FUNCTION; |
|
32 mEngine = NmApiEngine::instance(); |
|
33 Q_CHECK_PTR(mEngine); |
|
34 } |
|
35 |
|
36 NmApiEnvelopeListingPrivate::~NmApiEnvelopeListingPrivate() |
|
37 { |
|
38 NM_FUNCTION; |
|
39 NmApiEngine::releaseInstance(mEngine); |
|
40 } |
|
41 |
|
42 /*! |
|
43 \brief Fills envelopes to the input parameter. |
|
44 |
|
45 Caller gets ownership of envelopes. Returns true if results were available. |
|
46 */ |
|
47 bool NmApiEnvelopeListingPrivate::envelopes(QList<EmailClientApi::NmApiMessageEnvelope> &envelopes) |
|
48 { |
|
49 NM_FUNCTION; |
|
50 bool ret(mIsRunning); |
|
51 envelopes.clear(); |
|
52 while (!mEnvelopes.isEmpty()) { |
|
53 envelopes << mEnvelopes.takeFirst(); |
|
54 } |
|
55 mIsRunning = false; |
|
56 return ret; |
|
57 } |
|
58 |
|
59 /*! |
|
60 \brief It fetches envelopes from engine. |
|
61 |
|
62 Because it uses NmApiMessageEnvelope with sharedData we don't need care about release memory. |
|
63 |
|
64 \return Count of envelopes |
|
65 */ |
|
66 qint32 NmApiEnvelopeListingPrivate::listEnvelopes() |
|
67 { |
|
68 NM_FUNCTION; |
|
69 mIsRunning = true; |
|
70 mEnvelopes.clear(); |
|
71 mEngine->listEnvelopes(mMailboxId, mFolderId, mEnvelopes); |
|
72 return mEnvelopes.count(); |
|
73 } |
|
74 /*! |
|
75 \brief Return info if listing is running |
|
76 */ |
|
77 bool NmApiEnvelopeListingPrivate::isRunning() const |
|
78 { |
|
79 return mIsRunning; |
|
80 } |
|
81 /*! |
|
82 \brief Clears list of envelopes. |
|
83 */ |
|
84 void NmApiEnvelopeListingPrivate::cancel() |
|
85 { |
|
86 mIsRunning = false; |
|
87 mEnvelopes.clear(); |
|
88 } |
|
89 } |
|
90 |