47
|
1 |
/*
|
|
2 |
* Copyright (c) 2010 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 |
|
48
|
18 |
#include "nmapiheaders.h"
|
56
|
19 |
#include <nmapisettingsmanager.h>
|
47
|
20 |
|
|
21 |
|
|
22 |
namespace EmailClientApi
|
|
23 |
{
|
|
24 |
NmApiMailboxSettingsPrivate::NmApiMailboxSettingsPrivate(QObject *parent) :
|
|
25 |
QObject(parent),
|
|
26 |
mFactory(NULL),
|
|
27 |
mDeleteMailboxOperation(NULL)
|
|
28 |
{
|
|
29 |
NM_FUNCTION;
|
|
30 |
mFactory = NmApiDataPluginFactory::instance();
|
|
31 |
Q_CHECK_PTR(mFactory);
|
|
32 |
}
|
|
33 |
|
|
34 |
NmApiMailboxSettingsPrivate::~NmApiMailboxSettingsPrivate()
|
|
35 |
{
|
|
36 |
NM_FUNCTION;
|
|
37 |
NmApiDataPluginFactory::releaseInstance(mFactory);
|
|
38 |
if(mDeleteMailboxOperation && mDeleteMailboxOperation->isRunning()) {
|
|
39 |
mDeleteMailboxOperation->cancelOperation();
|
|
40 |
}
|
|
41 |
}
|
|
42 |
|
|
43 |
bool NmApiMailboxSettingsPrivate::listMailboxIds(QList<quint64> &idList)
|
|
44 |
{
|
|
45 |
NM_FUNCTION;
|
|
46 |
QList<NmId> mailboxIds;
|
|
47 |
bool ret = false;
|
|
48 |
idList.clear();
|
|
49 |
|
|
50 |
NmDataPluginInterface *instance = mFactory->interfaceInstance();
|
|
51 |
if (instance) {
|
|
52 |
if (instance->listMailboxIds(mailboxIds) == KErrNone) {
|
|
53 |
|
|
54 |
foreach (NmId boxId, mailboxIds) {
|
|
55 |
idList.append(boxId.id());
|
|
56 |
}
|
|
57 |
|
|
58 |
ret = true;
|
|
59 |
}
|
|
60 |
}
|
|
61 |
|
|
62 |
return ret;
|
|
63 |
}
|
|
64 |
|
|
65 |
bool NmApiMailboxSettingsPrivate::loadSettings(quint64 mailboxId, NmApiMailboxSettingsData &data)
|
|
66 |
{
|
|
67 |
NM_FUNCTION;
|
56
|
68 |
QScopedPointer<NmApiSettingsManager> settingsManager(new NmApiSettingsManager(mailboxId));
|
|
69 |
return settingsManager->load(mailboxId, data);
|
47
|
70 |
}
|
|
71 |
|
|
72 |
bool NmApiMailboxSettingsPrivate::saveSettings(const NmApiMailboxSettingsData &data)
|
|
73 |
{
|
|
74 |
NM_FUNCTION;
|
56
|
75 |
QScopedPointer<NmApiSettingsManager> settingsManager(new NmApiSettingsManager(data.mailboxId()));
|
|
76 |
return settingsManager->save(data);
|
47
|
77 |
}
|
|
78 |
|
|
79 |
bool NmApiMailboxSettingsPrivate::createMailbox(
|
|
80 |
const QString &mailboxType,
|
|
81 |
NmApiMailboxSettingsData &data)
|
|
82 |
{
|
|
83 |
NM_FUNCTION;
|
48
|
84 |
Q_UNUSED(mailboxType);
|
|
85 |
Q_UNUSED(data);
|
47
|
86 |
bool ret = false;
|
|
87 |
|
|
88 |
/*QT_TRY {
|
|
89 |
if (mailboxType==NmApiMailboxTypePop || mailboxType==NmApiMailboxTypeImap) {
|
|
90 |
QScopedPointer<NmApiPopImapSettingsManager> popImapManager(new NmApiPopImapSettingsManager());
|
|
91 |
popImapManager->createMailbox(mailboxType, data);
|
|
92 |
ret = true;
|
|
93 |
}
|
|
94 |
else {
|
|
95 |
ret = false;
|
|
96 |
}
|
|
97 |
//TODO store cenrep stuff here
|
|
98 |
}
|
|
99 |
QT_CATCH(...){
|
|
100 |
ret = false;
|
|
101 |
}*/
|
|
102 |
|
|
103 |
return ret;
|
|
104 |
}
|
|
105 |
|
|
106 |
bool NmApiMailboxSettingsPrivate::deleteMailbox(quint64 mailboxId)
|
|
107 |
{
|
|
108 |
NM_FUNCTION;
|
|
109 |
bool ret = false;
|
|
110 |
NmDataPluginInterface *instance = mFactory->interfaceInstance();
|
|
111 |
if (instance) {
|
|
112 |
if (mDeleteMailboxOperation && mDeleteMailboxOperation->isRunning()) {
|
|
113 |
mDeleteMailboxOperation->cancelOperation();
|
|
114 |
}
|
|
115 |
mDeleteMailboxOperation = instance->deleteMailboxById(NmId(mailboxId));
|
|
116 |
|
|
117 |
if (mDeleteMailboxOperation) {
|
|
118 |
ret = true;
|
|
119 |
connect(mDeleteMailboxOperation,
|
|
120 |
SIGNAL(operationCompleted(int)),
|
|
121 |
this,
|
|
122 |
SIGNAL(mailboxDeleted(int)));
|
|
123 |
}
|
|
124 |
}
|
|
125 |
return ret;
|
|
126 |
}
|
|
127 |
|
|
128 |
bool NmApiMailboxSettingsPrivate::populateDefaultSettings(
|
|
129 |
const QString &mailboxType, NmApiMailboxSettingsData &data)
|
|
130 |
{
|
|
131 |
NM_FUNCTION;
|
48
|
132 |
Q_UNUSED(mailboxType);
|
|
133 |
Q_UNUSED(data);
|
47
|
134 |
/*QScopedPointer<NmApiPopImapSettingsManager> popImapManager(new NmApiPopImapSettingsManager());
|
|
135 |
return popImapManager->populateDefaults(mailboxType, data);*/
|
|
136 |
return true;
|
|
137 |
}
|
|
138 |
|
|
139 |
}// namespace
|