|
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 namespace EmailClientApi |
|
21 { |
|
22 /*! |
|
23 Constructor of class. It set start values. |
|
24 */ |
|
25 NmApiEnvelopeListing::NmApiEnvelopeListing( |
|
26 QObject *parent, |
|
27 const quint64 folderId, |
|
28 const quint64 mailboxId) : |
|
29 NmApiMessageTask(parent) |
|
30 { |
|
31 NM_FUNCTION; |
|
32 mListingPrivate = new NmApiEnvelopeListingPrivate(folderId, mailboxId, this); |
|
33 } |
|
34 |
|
35 /*! |
|
36 Destructor of class. |
|
37 */ |
|
38 NmApiEnvelopeListing::~NmApiEnvelopeListing() |
|
39 { |
|
40 NM_FUNCTION; |
|
41 } |
|
42 |
|
43 /*! |
|
44 \brief Fetches envelope list. Emits envelopesListed signal when ready. |
|
45 Results can be fetched with getEnvelopes. |
|
46 |
|
47 To asynchronous operation ce be used \sa QTimer::singleShot on this method. |
|
48 Example: |
|
49 <code> |
|
50 QTimer::singleShot(0,nmEnvelopeListing,SLOT(start()); |
|
51 </code> |
|
52 |
|
53 */ |
|
54 bool NmApiEnvelopeListing::start() |
|
55 { |
|
56 NM_FUNCTION; |
|
57 |
|
58 qint32 envelopesCount = mListingPrivate->listEnvelopes(); |
|
59 QMetaObject::invokeMethod(this, "envelopesListed", Qt::QueuedConnection, Q_ARG(qint32, |
|
60 envelopesCount)); |
|
61 return true; |
|
62 } |
|
63 |
|
64 /*! |
|
65 \brief Stop gathering envelope list. |
|
66 |
|
67 Clears list of envelopes and emits \sa NmApiMessageTask::canceled() signal. |
|
68 */ |
|
69 void NmApiEnvelopeListing::cancel() |
|
70 { |
|
71 NM_FUNCTION; |
|
72 mListingPrivate->cancel(); |
|
73 emit canceled(); |
|
74 |
|
75 } |
|
76 |
|
77 /*! |
|
78 \brief Returns results after envelopesListed signal is received. |
|
79 |
|
80 Caller gets ownership of envelopes. Returns true if results were available. |
|
81 Before calling start should be called, otherwise will return empty list. |
|
82 It also clears inputlist of NmMessageEnvelope. |
|
83 */ |
|
84 bool NmApiEnvelopeListing::getEnvelopes(QList<EmailClientApi::NmApiMessageEnvelope> &envelopes) |
|
85 { |
|
86 NM_FUNCTION; |
|
87 return mListingPrivate->envelopes(envelopes); |
|
88 } |
|
89 |
|
90 /*! |
|
91 \brief Return info if listing is running |
|
92 */ |
|
93 bool NmApiEnvelopeListing::isRunning() const |
|
94 { |
|
95 NM_FUNCTION; |
|
96 return mListingPrivate->isRunning(); |
|
97 } |
|
98 |
|
99 } |