13 * |
13 * |
14 * Description: |
14 * Description: |
15 * |
15 * |
16 */ |
16 */ |
17 |
17 |
|
18 |
|
19 #include <nmapifolderlisting.h> |
18 #include "nmapifolderlisting_p.h" |
20 #include "nmapifolderlisting_p.h" |
19 #include "nmapifolderlisting.h" |
21 |
20 #include <QtCore> |
22 #include <nmapimailbox.h> |
|
23 #include <nmapifolder.h> |
21 |
24 |
22 namespace EmailClientApi |
25 namespace EmailClientApi |
23 { |
26 { |
24 |
27 |
25 /*! |
28 /*! |
26 * \class Class for creating list of all folders |
29 \class Class for creating list of all folders |
27 */ |
30 */ |
28 |
31 |
29 /*! |
32 /*! |
30 * Constructor of class. It set start values. |
33 Constructor of class. It set start values. |
31 */ |
34 */ |
32 NmFolderListing::NmFolderListing(QObject *parent, const quint64 &nmMailboxId) : |
35 NmApiFolderListing::NmApiFolderListing(QObject *parent, const quint64 &nmMailboxId) : |
33 NmMessageTask(parent) |
36 NmApiMessageTask(parent) |
34 { |
37 { |
35 mFolderListing = new NmFolderListingPrivate(this); |
38 mFolderListing = new NmApiFolderListingPrivate(this); |
36 mFolderListing->mIsRunning = false; |
39 mFolderListing->mIsRunning = false; |
37 mFolderListing->mMailboxId = nmMailboxId; |
40 mFolderListing->mMailboxId = nmMailboxId; |
38 } |
41 } |
39 |
42 |
40 /*! |
43 /*! |
41 * Destructor of class. It release engine to be safe if manual releasing won't work. |
44 Destructor of class. It release engine to be safe if manual releasing won't work. |
42 */ |
45 */ |
43 NmFolderListing::~NmFolderListing() |
46 NmApiFolderListing::~NmApiFolderListing() |
44 { |
47 { |
45 if (mFolderListing->mIsRunning) { |
48 if (mFolderListing->mIsRunning) { |
46 mFolderListing->releaseEngine(); |
49 mFolderListing->releaseEngine(); |
47 } |
50 } |
48 } |
51 } |
49 |
52 |
50 /*! |
53 /*! |
51 * \brief Returns results after foldersListed signal is received. |
54 \brief Returns results after foldersListed signal is received. |
52 * |
55 |
53 * Caller gets ownership of messages. Returns true if results were available. |
56 Caller gets ownership of messages. Returns true if results were available. |
54 * It clears list of folders after be called. |
57 It clears list of folders after be called. |
55 * It also at start clear inputlist of NmFolder. |
58 It also at start clear inputlist of NmFolder. |
56 */ |
59 */ |
57 bool NmFolderListing::getFolders(QList<EmailClientApi::NmFolder> &folders) |
60 bool NmApiFolderListing::getFolders(QList<EmailClientApi::NmApiFolder> &folders) |
58 { |
61 { |
59 folders.clear(); |
62 folders.clear(); |
60 if (!mFolderListing->mIsRunning || mFolderListing->mFolders.isEmpty()) { |
63 if (!mFolderListing->mIsRunning || mFolderListing->mFolders.isEmpty()) { |
61 return false; |
64 return false; |
62 } |
65 } |
64 mFolderListing->mFolders.clear(); |
67 mFolderListing->mFolders.clear(); |
65 return true; |
68 return true; |
66 } |
69 } |
67 |
70 |
68 /*! |
71 /*! |
69 * \brief Starts gathering folders list. |
72 \brief Starts gathering folders list. |
70 * |
73 |
71 * In first turn it will get whole folderlist. and then |
74 In first turn it will get whole folderlist. and then |
72 * it emits information signal \sa folderListed |
75 it emits information signal \sa folderListed |
73 * |
76 |
74 * To asynchronous operation ce be used \sa QTimer::singleShot on this method. |
77 To asynchronous operation ce be used \sa QTimer::singleShot on this method. |
75 * Example: |
78 Example: |
76 * <code> |
79 <code> |
77 * QTimer::singleShot(0,nmFolderListing,SLOT(start()); |
80 QTimer::singleShot(0,nmFolderListing,SLOT(start()); |
78 * </code> |
81 </code> |
79 * |
82 |
80 */ |
83 */ |
81 bool NmFolderListing::start() |
84 bool NmApiFolderListing::start() |
82 { |
85 { |
83 if (mFolderListing->mIsRunning) { |
86 if (mFolderListing->mIsRunning) { |
84 return true; |
87 return true; |
85 } |
88 } |
86 |
89 |
98 |
101 |
99 return true; |
102 return true; |
100 } |
103 } |
101 |
104 |
102 /*! |
105 /*! |
103 * \brief Stop gathering folder list. |
106 \brief Stop gathering folder list. |
104 * |
107 |
105 * In first it change state of listing. |
108 In first it change state of listing. |
106 * Then it release engine. |
109 Then it release engine. |
107 * On end it clears list of folders and emits \sa NmMessageTask::canceled() signal. |
110 On end it clears list of folders and emits \sa NmApiMessageTask::canceled() signal. |
108 */ |
111 */ |
109 void NmFolderListing::cancel() |
112 void NmApiFolderListing::cancel() |
110 { |
113 { |
111 if (!mFolderListing->mIsRunning) { |
114 if (!mFolderListing->mIsRunning) { |
112 return; |
115 return; |
113 } |
116 } |
114 |
117 |