13 * |
13 * |
14 * Description: |
14 * Description: |
15 * |
15 * |
16 */ |
16 */ |
17 |
17 |
|
18 |
|
19 #include <nmapienvelopelisting.h> |
18 #include "nmapienvelopelisting_p.h" |
20 #include "nmapienvelopelisting_p.h" |
19 #include "nmapienvelopelisting.h" |
21 |
|
22 #include <nmapicommonheader.h> |
|
23 |
20 #include "nmapiengine.h" |
24 #include "nmapiengine.h" |
|
25 |
|
26 |
21 |
27 |
22 namespace EmailClientApi |
28 namespace EmailClientApi |
23 { |
29 { |
24 /*! |
30 /*! |
25 * Constructor of class. It set start values. |
31 Constructor of class. It set start values. |
26 */ |
32 */ |
27 NmEnvelopeListing::NmEnvelopeListing( |
33 NmApiEnvelopeListing::NmApiEnvelopeListing( |
28 QObject *parent, |
34 QObject *parent, |
29 const quint64 folderId, |
35 const quint64 folderId, |
30 const quint64 mailboxId) : |
36 const quint64 mailboxId) : |
31 NmMessageTask(parent) |
37 NmApiMessageTask(parent) |
32 { |
38 { |
33 mListingPrivate = new NmEnvelopeListingPrivate(this); |
39 mListingPrivate = new NmApiEnvelopeListingPrivate(this); |
34 mListingPrivate->mailboxId = mailboxId; |
40 mListingPrivate->mailboxId = mailboxId; |
35 mListingPrivate->folderId = folderId; |
41 mListingPrivate->folderId = folderId; |
36 mListingPrivate->mIsRunning = false; |
42 mListingPrivate->mIsRunning = false; |
37 } |
43 } |
38 |
44 |
39 /*! |
45 /*! |
40 * Destructor of class. It release engine to be safe if manual releasing won't work. |
46 Destructor of class. It release engine to be safe if manual releasing won't work. |
41 */ |
47 */ |
42 NmEnvelopeListing::~NmEnvelopeListing() |
48 NmApiEnvelopeListing::~NmApiEnvelopeListing() |
43 { |
49 { |
44 if (mListingPrivate->mIsRunning) { |
50 if (mListingPrivate->mIsRunning) { |
45 mListingPrivate->releaseEngine(); |
51 mListingPrivate->releaseEngine(); |
46 } |
52 } |
47 } |
53 } |
48 |
54 |
49 /*! |
55 /*! |
50 * \brief Starts gathering envelopes list. |
56 \brief Starts gathering envelopes list. |
51 * |
57 |
52 * In first turn it will get whole folderlist. |
58 In first turn it will get whole folderlist. |
53 * If start works, it do nothing. |
59 If start works, it do nothing. |
54 * |
60 |
55 * To asynchronous operation ce be used \sa QTimer::singleShot on this method. |
61 To asynchronous operation ce be used \sa QTimer::singleShot on this method. |
56 * Example: |
62 Example: |
57 * <code> |
63 <code> |
58 * QTimer::singleShot(0,nmEnvelopeListing,SLOT(start()); |
64 QTimer::singleShot(0,nmEnvelopeListing,SLOT(start()); |
59 * </code> |
65 </code> |
60 * |
66 |
61 */ |
67 */ |
62 bool NmEnvelopeListing::start() |
68 bool NmApiEnvelopeListing::start() |
63 { |
69 { |
64 bool result = false; |
70 bool result = false; |
65 |
71 |
66 if (mListingPrivate->mIsRunning) { |
72 if (mListingPrivate->mIsRunning) { |
67 result = true; |
73 result = true; |
85 } |
91 } |
86 return result; |
92 return result; |
87 } |
93 } |
88 |
94 |
89 /*! |
95 /*! |
90 * \brief Stop gathering envelope list. |
96 \brief Stop gathering envelope list. |
91 * |
97 |
92 * In first it change state of listing. |
98 In first it change state of listing. |
93 * Then it release engine. |
99 Then it release engine. |
94 * On end it clears list of envelopes and emits \sa NmMessageTask::canceled() signal. |
100 On end it clears list of envelopes and emits \sa NmApiMessageTask::canceled() signal. |
95 */ |
101 */ |
96 void NmEnvelopeListing::cancel() |
102 void NmApiEnvelopeListing::cancel() |
97 { |
103 { |
98 if (mListingPrivate->mIsRunning) { |
104 if (mListingPrivate->mIsRunning) { |
99 mListingPrivate->mIsRunning = false; |
105 mListingPrivate->mIsRunning = false; |
100 mListingPrivate->releaseEngine(); |
106 mListingPrivate->releaseEngine(); |
101 mListingPrivate->mEnvelopes.clear(); |
107 mListingPrivate->mEnvelopes.clear(); |
103 emit canceled(); |
109 emit canceled(); |
104 } |
110 } |
105 } |
111 } |
106 |
112 |
107 /*! |
113 /*! |
108 * \brief Returns results after envelopesListed signal is received. |
114 \brief Returns results after envelopesListed signal is received. |
109 * |
115 |
110 * Caller gets ownership of envelopes. Returns true if results were available. |
116 Caller gets ownership of envelopes. Returns true if results were available. |
111 * It clears list of envelopes after be called. |
117 Before calling cancel and start should be called, |
112 * It also at start clear inputlist of NmMessageEnvelope. |
118 because after second calling it return empty list. |
|
119 It also at start clear inputlist of NmMessageEnvelope. |
113 */ |
120 */ |
114 bool NmEnvelopeListing::getEnvelopes(QList<EmailClientApi::NmMessageEnvelope> &envelopes) |
121 bool NmApiEnvelopeListing::getEnvelopes(QList<EmailClientApi::NmApiMessageEnvelope> &envelopes) |
115 { |
122 { |
116 envelopes.clear(); |
123 envelopes.clear(); |
117 |
124 |
118 bool result = false; |
125 bool result = false; |
119 |
126 |