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