|
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 namespace EmailClientApi |
|
22 { |
|
23 |
|
24 /*! |
|
25 \class Class for creating list of all folders |
|
26 */ |
|
27 |
|
28 /*! |
|
29 Constructor of class. It set start values. |
|
30 */ |
|
31 NmApiFolderListing::NmApiFolderListing(QObject *parent, const quint64 &mailboxId) : |
|
32 NmApiMessageTask(parent) |
|
33 { |
|
34 NM_FUNCTION; |
|
35 mFolderListing = new NmApiFolderListingPrivate(mailboxId, this); |
|
36 } |
|
37 |
|
38 /*! |
|
39 Destructor of class. It release engine to be safe if manual releasing won't work. |
|
40 */ |
|
41 NmApiFolderListing::~NmApiFolderListing() |
|
42 { |
|
43 NM_FUNCTION; |
|
44 } |
|
45 |
|
46 /*! |
|
47 \brief Returns results after foldersListed signal is received. |
|
48 |
|
49 Caller gets ownership of messages. Returns true if results were available. |
|
50 It clears list of folders after be called. |
|
51 It also at start clear inputlist of NmFolder. |
|
52 */ |
|
53 bool NmApiFolderListing::getFolders(QList<EmailClientApi::NmApiFolder> &folders) |
|
54 { |
|
55 NM_FUNCTION; |
|
56 return mFolderListing->folders(folders); |
|
57 } |
|
58 |
|
59 /*! |
|
60 \brief Starts gathering folders list. |
|
61 |
|
62 In first turn it will get whole folderlist. and then |
|
63 it emits information signal \sa folderListed |
|
64 |
|
65 To asynchronous operation ce be used \sa QTimer::singleShot on this method. |
|
66 Example: |
|
67 <code> |
|
68 QTimer::singleShot(0,nmFolderListing,SLOT(start()); |
|
69 </code> |
|
70 |
|
71 */ |
|
72 bool NmApiFolderListing::start() |
|
73 { |
|
74 NM_FUNCTION; |
|
75 qint32 folderCount = mFolderListing->listFolders(); |
|
76 QMetaObject::invokeMethod(this, "foldersListed", Qt::QueuedConnection, |
|
77 Q_ARG(qint32, folderCount)); |
|
78 |
|
79 return true; |
|
80 } |
|
81 |
|
82 /*! |
|
83 \brief Stop gathering folder list. |
|
84 |
|
85 In first it change state of listing. |
|
86 Then it release engine. |
|
87 On end it clears list of folders and emits \sa NmApiMessageTask::canceled() signal. |
|
88 */ |
|
89 void NmApiFolderListing::cancel() |
|
90 { |
|
91 NM_FUNCTION; |
|
92 |
|
93 mFolderListing->cancel(); |
|
94 emit canceled(); |
|
95 } |
|
96 |
|
97 /*! |
|
98 \brief Return info if listing is running |
|
99 */ |
|
100 bool NmApiFolderListing::isRunning() const |
|
101 { |
|
102 NM_FUNCTION; |
|
103 return mFolderListing->isRunning(); |
|
104 } |
|
105 |
|
106 } |
|
107 |
|
108 |