34 NmApiMailboxSettingsPrivate::~NmApiMailboxSettingsPrivate() |
33 NmApiMailboxSettingsPrivate::~NmApiMailboxSettingsPrivate() |
35 { |
34 { |
36 NM_FUNCTION; |
35 NM_FUNCTION; |
37 NmApiDataPluginFactory::releaseInstance(mFactory); |
36 NmApiDataPluginFactory::releaseInstance(mFactory); |
38 if(mDeleteMailboxOperation && mDeleteMailboxOperation->isRunning()) { |
37 if(mDeleteMailboxOperation && mDeleteMailboxOperation->isRunning()) { |
39 mDeleteMailboxOperation->cancelOperation(); |
38 mDeleteMailboxOperation->cancelOperation(); |
40 } |
39 } |
41 } |
40 } |
42 |
41 |
43 bool NmApiMailboxSettingsPrivate::listMailboxIds(QList<quint64> &idList) |
42 bool NmApiMailboxSettingsPrivate::listMailboxIds(QList<quint64> &idList) |
44 { |
43 { |
45 NM_FUNCTION; |
44 NM_FUNCTION; |
46 QList<NmId> mailboxIds; |
45 QList<NmId> mailboxIds; |
47 bool ret = false; |
46 bool ret = false; |
48 idList.clear(); |
47 idList.clear(); |
49 |
48 |
50 NmDataPluginInterface *instance = mFactory->interfaceInstance(); |
49 NmDataPluginInterface *instance = mFactory->interfaceInstance(); |
51 if (instance) { |
50 if (instance) { |
52 if (instance->listMailboxIds(mailboxIds) == KErrNone) { |
51 if (instance->listMailboxIds(mailboxIds) == KErrNone) { |
53 |
52 |
54 foreach (NmId boxId, mailboxIds) { |
53 foreach (NmId boxId, mailboxIds) { |
55 idList.append(boxId.id()); |
54 idList.append(boxId.id()); |
56 } |
55 } |
57 |
56 |
58 ret = true; |
57 ret = true; |
59 } |
58 } |
60 } |
59 } |
61 |
60 |
62 return ret; |
61 return ret; |
63 } |
62 } |
|
63 |
|
64 QString NmApiMailboxSettingsPrivate::getMailboxType(quint64 mailboxId) |
|
65 { |
|
66 QString mailboxType; |
|
67 //Return null string if mailbox is not resolved or some error occurs |
|
68 TRAP_IGNORE(mailboxType = resolveMailboxTypeL(mailboxId)); |
|
69 NM_ERROR(!mailboxType.isNull(), QString("Can not receive mailbox type") |
|
70 + QString::number(mailboxId)); |
|
71 return mailboxType; |
|
72 } |
|
73 |
|
74 QString NmApiMailboxSettingsPrivate::resolveMailboxTypeL(quint64 mailboxId) |
|
75 { |
|
76 QString mailboxType; |
|
77 quint32 serviceId = mailboxId; |
|
78 CEmailAccounts *accounts = CEmailAccounts::NewLC(); |
|
79 |
|
80 RArray<TImapAccount> imapAccounts; |
|
81 CleanupClosePushL(imapAccounts); |
|
82 accounts->GetImapAccountsL(imapAccounts); |
|
83 for (int i=0; i < imapAccounts.Count(); ++i) { |
|
84 if (imapAccounts[i].iImapService == serviceId) { |
|
85 mailboxType = NmApiMailboxTypeImap; |
|
86 break; |
|
87 } |
|
88 } |
|
89 CleanupStack::PopAndDestroy(&imapAccounts); |
|
90 |
|
91 if (mailboxType.isNull()) { |
|
92 RArray<TPopAccount> popAccounts; |
|
93 CleanupClosePushL(popAccounts); |
|
94 accounts->GetPopAccountsL(popAccounts); |
|
95 for (int i = 0; i < popAccounts.Count(); ++i) { |
|
96 if (popAccounts[i].iPopService == serviceId) { |
|
97 mailboxType = NmApiMailboxTypePop; |
|
98 break; |
|
99 } |
|
100 } |
|
101 CleanupStack::PopAndDestroy(&popAccounts); |
|
102 } |
|
103 CleanupStack::PopAndDestroy(accounts); |
|
104 return mailboxType; |
|
105 } |
|
106 |
64 |
107 |
65 bool NmApiMailboxSettingsPrivate::loadSettings(quint64 mailboxId, NmApiMailboxSettingsData &data) |
108 bool NmApiMailboxSettingsPrivate::loadSettings(quint64 mailboxId, NmApiMailboxSettingsData &data) |
66 { |
109 { |
67 NM_FUNCTION; |
110 NM_FUNCTION; |
68 QScopedPointer<NmApiSettingsManager> settingsManager(new NmApiSettingsManager(mailboxId)); |
111 QScopedPointer<NmApiSettingsManager> settingsManager(new NmApiSettingsManager(mailboxId)); |
69 return settingsManager->load(mailboxId, data); |
112 return settingsManager->load(mailboxId, data); |
70 } |
113 } |
71 |
114 |
72 bool NmApiMailboxSettingsPrivate::saveSettings(const NmApiMailboxSettingsData &data) |
115 bool NmApiMailboxSettingsPrivate::saveSettings(const NmApiMailboxSettingsData &data) |
73 { |
116 { |
74 NM_FUNCTION; |
117 NM_FUNCTION; |
75 QScopedPointer<NmApiSettingsManager> settingsManager(new NmApiSettingsManager(data.mailboxId())); |
118 QScopedPointer<NmApiSettingsManager> settingsManager(new NmApiSettingsManager(data.mailboxId())); |
76 return settingsManager->save(data); |
119 return settingsManager->save(data); |
77 } |
120 } |
78 |
121 |
79 bool NmApiMailboxSettingsPrivate::createMailbox( |
122 bool NmApiMailboxSettingsPrivate::createMailbox( |
80 const QString &mailboxType, |
123 const QString &mailboxType, |
97 //TODO store cenrep stuff here |
140 //TODO store cenrep stuff here |
98 } |
141 } |
99 QT_CATCH(...){ |
142 QT_CATCH(...){ |
100 ret = false; |
143 ret = false; |
101 }*/ |
144 }*/ |
102 |
145 |
103 return ret; |
146 return ret; |
104 } |
147 } |
105 |
148 |
106 bool NmApiMailboxSettingsPrivate::deleteMailbox(quint64 mailboxId) |
149 bool NmApiMailboxSettingsPrivate::deleteMailbox(quint64 mailboxId) |
107 { |
150 { |
108 NM_FUNCTION; |
151 Q_UNUSED(mailboxId); |
109 bool ret = false; |
152 return false; |
110 NmDataPluginInterface *instance = mFactory->interfaceInstance(); |
153 |
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 } |
154 } |
127 |
155 |
128 bool NmApiMailboxSettingsPrivate::populateDefaultSettings( |
156 bool NmApiMailboxSettingsPrivate::populateDefaultSettings( |
129 const QString &mailboxType, NmApiMailboxSettingsData &data) |
157 const QString &mailboxType, NmApiMailboxSettingsData &data) |
130 { |
158 { |
131 NM_FUNCTION; |
159 NM_FUNCTION; |
132 Q_UNUSED(mailboxType); |
160 // Q_UNUSED(mailboxType); |
133 Q_UNUSED(data); |
161 // Q_UNUSED(data); |
134 /*QScopedPointer<NmApiPopImapSettingsManager> popImapManager(new NmApiPopImapSettingsManager()); |
162 QScopedPointer<NmApiPopImapSettingsManager> popImapManager(new NmApiPopImapSettingsManager()); |
135 return popImapManager->populateDefaults(mailboxType, data);*/ |
163 return popImapManager->populateDefaults(mailboxType, data); |
136 return true; |
164 // return true; |
137 } |
165 } |
138 |
166 |
139 }// namespace |
167 }// namespace |