121 iSenderArray.Close(); |
121 iSenderArray.Close(); |
122 } |
122 } |
123 |
123 |
124 //---------------------------------------------------------------------------- |
124 //---------------------------------------------------------------------------- |
125 |
125 |
126 TBool CCreatorMessages::AskDataFromUserL(TInt aCommand, TInt& aNumberOfEntries) |
126 void CCreatorMessages::QueryDialogClosedL(TBool aPositiveAction, TInt aUserData) |
127 { |
127 { |
128 LOGSTRING("Creator: CCreatorMessages::AskDataFromUserL"); |
128 LOGSTRING("Creator: CCreatorMessages::QueryDialogClosedL"); |
129 |
129 |
130 if ( aCommand == ECmdDeleteMessages ) |
130 if( aPositiveAction == EFalse ) |
131 { |
131 { |
132 return iEngine->GetEngineWrapper()->YesNoQueryDialog( _L("Delete all messages?") ); |
132 iEngine->ShutDownEnginesL(); |
133 } |
133 return; |
134 else if ( aCommand == ECmdDeleteCreatorMessages ) |
134 } |
135 { |
135 |
136 return iEngine->GetEngineWrapper()->YesNoQueryDialog( _L("Delete all messages created with Creator?") ); |
136 TBool finished(EFalse); |
137 } |
137 TBool retval(ETrue); |
138 |
138 switch(aUserData) |
139 if (iEngine->GetEngineWrapper()->EntriesQueryDialog(aNumberOfEntries, _L("How many entries to create?"))) |
139 { |
140 { |
140 case ECreatorMessagesDelete: |
141 |
141 iEntriesToBeCreated = 1; |
142 // message type query |
142 finished = ETrue; |
143 if (iEngine->GetEngineWrapper()->ListQueryDialog(_L("Message type"), R_MESSAGE_TYPE_QUERY, (TInt&) iMessageType)) |
143 break; |
144 { |
144 case ECreatorMessagesStart: |
145 if (iEngine->GetEngineWrapper()->ListQueryDialog(_L("Folder type"), R_FOLDER_TYPE_QUERY, (TInt&) iFolderType)) |
145 // message type query |
|
146 retval = iEngine->GetEngineWrapper()->ListQueryDialog(_L("Message type"), R_MESSAGE_TYPE_QUERY, (TInt*) &iMessageType, this, ECreatorMessagesMessageType); |
|
147 break; |
|
148 case ECreatorMessagesMessageType: |
|
149 retval = iEngine->GetEngineWrapper()->ListQueryDialog(_L("Folder type"), R_FOLDER_TYPE_QUERY, (TInt*) &iFolderType, this, ECreatorMessagesFolderType); |
|
150 break; |
|
151 case ECreatorMessagesFolderType: |
|
152 // query create as unread |
|
153 retval = iEngine->GetEngineWrapper()->ListQueryDialog(_L("Message status"), R_UNREAD_QUERY, (TInt*)&iCreateAsUnread, this, ECreatorMessagesMessageStatus); |
|
154 break; |
|
155 case ECreatorMessagesMessageStatus: |
|
156 if( iMessageType == ESMS || iMessageType == EMMS || iMessageType == EEmail ) |
146 { |
157 { |
147 /* |
158 iDefinedMessageLength = 100; |
148 if (iFolderType == EMailbox) |
159 retval = iEngine->GetEngineWrapper()->EntriesQueryDialog(&iDefinedMessageLength, _L("Amount of characters in message body?"), ETrue, |
149 { |
160 this, ECreatorMessagesCharsInBody |
150 // array to hold mailbox names |
161 ); |
151 CDesCArray* names = new (ELeave) CDesCArrayFlat(16); |
162 break; |
152 CleanupStack::PushL(names); |
|
153 |
|
154 CMsvSession* session = CMsvSession::OpenSyncL(*this); |
|
155 CleanupStack::PushL(session); |
|
156 |
|
157 // generate list of mailboxes |
|
158 CMsvEntrySelection* entrySelection = MsvUiServiceUtilities::GetListOfAccountsWithMTML(*session, KUidMsgTypeSMTP, ETrue); |
|
159 CleanupStack::PushL(entrySelection); |
|
160 |
|
161 TBool doReturn(EFalse); |
|
162 |
|
163 if (entrySelection->Count() == 0) |
|
164 { |
|
165 CAknInformationNote* note = new(ELeave) CAknInformationNote; |
|
166 note->ExecuteLD(_L("No mailboxes found")); |
|
167 |
|
168 doReturn = ETrue; |
|
169 } |
|
170 else |
|
171 { |
|
172 // get mailbox names |
|
173 for (TInt i=0; i<entrySelection->Count(); i++) |
|
174 { |
|
175 CMsvEntry* centry = session->GetEntryL(entrySelection->At(i)); |
|
176 CleanupStack::PushL(centry); |
|
177 |
|
178 TMsvEntry tentry = centry->Entry(); |
|
179 names->AppendL(tentry.iDetails); |
|
180 CleanupStack::PopAndDestroy(); //centry |
|
181 } |
|
182 |
|
183 // show query |
|
184 TInt index(0); |
|
185 CAknListQueryDialog* dlg = new(ELeave) CAknListQueryDialog(&index); |
|
186 dlg->PrepareLC(R_MAILBOX_SELECTION_QUERY); |
|
187 dlg->SetItemTextArray(names); |
|
188 dlg->SetOwnershipType(ELbmDoesNotOwnItemArray); |
|
189 |
|
190 if(dlg->RunLD()) |
|
191 { |
|
192 iUserSelectedMailbox = entrySelection->At(index); |
|
193 |
|
194 doReturn = EFalse; |
|
195 } |
|
196 else |
|
197 { |
|
198 doReturn = ETrue; |
|
199 } |
|
200 |
|
201 } |
|
202 |
|
203 CleanupStack::PopAndDestroy(3); // names, session, entrySelection |
|
204 |
|
205 if (doReturn) |
|
206 return EFalse; |
|
207 } |
|
208 */ |
|
209 |
|
210 // query create as unread |
|
211 if (iEngine->GetEngineWrapper()->ListQueryDialog(_L("Message status"), R_UNREAD_QUERY, (TInt&)iCreateAsUnread)) |
|
212 { |
|
213 // query number of characters in msg body |
|
214 switch (iMessageType) |
|
215 { |
|
216 case ESMS: |
|
217 case EMMS: |
|
218 case EEmail: |
|
219 { |
|
220 iDefinedMessageLength = 100; |
|
221 if (iEngine->GetEngineWrapper()->EntriesQueryDialog(iDefinedMessageLength, _L("Amount of characters in message body?"), ETrue)) |
|
222 { |
|
223 ; |
|
224 } |
|
225 else |
|
226 return EFalse; |
|
227 |
|
228 break; |
|
229 } |
|
230 case EAMS: |
|
231 { |
|
232 iDefinedMessageLength = 0; |
|
233 break; |
|
234 } |
|
235 default: break; |
|
236 } |
|
237 |
|
238 // query attachments |
|
239 iAttachments->Reset(); |
|
240 |
|
241 switch (iMessageType) |
|
242 { |
|
243 case EMMS: |
|
244 case EEmail: |
|
245 { |
|
246 if (iEngine->GetEngineWrapper()->ListQueryDialog(_L("Choose attachment:"), R_ATTACHMENT_MULTI_SELECTION_QUERY, iAttachments)) |
|
247 { |
|
248 // "none" is selected |
|
249 if (iAttachments->At(0) == 0) |
|
250 iAttachments->Reset(); |
|
251 else // otherwise fix indexes |
|
252 { |
|
253 for (TInt i=0; i<iAttachments->Count(); i++) |
|
254 iAttachments->At(i)--; // decrease value by one |
|
255 |
|
256 } |
|
257 } |
|
258 else |
|
259 return EFalse; |
|
260 |
|
261 break; |
|
262 } |
|
263 case EAMS: |
|
264 { |
|
265 iAttachments->AppendL( TInt(0) ); |
|
266 if (iEngine->GetEngineWrapper()->ListQueryDialog(_L("Choose attachment:"), R_AMS_ATTACHMENT_SINGLE_SELECTION_QUERY, iAttachments->At(0))) |
|
267 { |
|
268 ; |
|
269 } |
|
270 else |
|
271 return EFalse; |
|
272 |
|
273 break; |
|
274 } |
|
275 |
|
276 case EIrMessage: |
|
277 case EBTMessage: |
|
278 { |
|
279 iAttachments->AppendL( TInt(0) ); |
|
280 if (iEngine->GetEngineWrapper()->ListQueryDialog(_L("Choose attachment:"), R_ATTACHMENT_SINGLE_SELECTION_QUERY, iAttachments->At(0))) |
|
281 { |
|
282 ; |
|
283 } |
|
284 else |
|
285 return EFalse; |
|
286 |
|
287 break; |
|
288 } |
|
289 default: break; |
|
290 } |
|
291 |
|
292 return ETrue; // all queries accepted |
|
293 |
|
294 } |
|
295 else |
|
296 return EFalse; |
|
297 } |
163 } |
298 else |
164 else |
299 return EFalse; |
165 { |
300 } |
166 iDefinedMessageLength = 0; |
301 else |
167 // goto query attachments ... :-) DO NOT break; |
302 return EFalse; |
168 } |
303 |
169 case ECreatorMessagesCharsInBody: |
304 } |
170 // query attachments |
305 // else |
171 iAttachments->Reset(); |
306 return EFalse; |
172 if( iMessageType == EMMS || iMessageType == EEmail) |
|
173 { |
|
174 retval = iEngine->GetEngineWrapper()->ListQueryDialog(_L("Choose attachment:"), R_ATTACHMENT_MULTI_SELECTION_QUERY, |
|
175 iAttachments, this, ECreatorMessagesAttachment |
|
176 ); |
|
177 } |
|
178 else if( iMessageType == EAMS ) |
|
179 { |
|
180 iAttachments->AppendL( TInt(0) ); |
|
181 retval = iEngine->GetEngineWrapper()->ListQueryDialog(_L("Choose attachment:"), R_AMS_ATTACHMENT_SINGLE_SELECTION_QUERY, |
|
182 &iAttachments->At(0), this, ECreatorMessagesAttachment |
|
183 ); |
|
184 } |
|
185 else if( iMessageType == EIrMessage || iMessageType == EBTMessage ) |
|
186 { |
|
187 iAttachments->AppendL( TInt(0) ); |
|
188 retval = iEngine->GetEngineWrapper()->ListQueryDialog(_L("Choose attachment:"), R_ATTACHMENT_SINGLE_SELECTION_QUERY, |
|
189 &iAttachments->At(0), this, ECreatorMessagesAttachment |
|
190 ); |
|
191 } |
|
192 else |
|
193 { |
|
194 finished = ETrue; |
|
195 } |
|
196 break; |
|
197 case ECreatorMessagesAttachment: |
|
198 finished = ETrue; |
|
199 if(iMessageType== EMMS || iMessageType == EEmail) |
|
200 { |
|
201 // "none" is selected |
|
202 if (iAttachments->At(0) == 0) |
|
203 { |
|
204 iAttachments->Reset(); |
|
205 } |
|
206 else // otherwise fix indexes |
|
207 { |
|
208 for (TInt i=0; i<iAttachments->Count(); i++) |
|
209 iAttachments->At(i)--; // decrease value by one |
|
210 |
|
211 } |
|
212 } |
|
213 break; |
|
214 default: |
|
215 //some error |
|
216 retval = EFalse; |
|
217 break; |
|
218 } |
|
219 if( retval == EFalse ) |
|
220 { |
|
221 iEngine->ShutDownEnginesL(); |
|
222 } |
|
223 else if( finished ) |
|
224 { |
|
225 // add this command to command array |
|
226 iEngine->AppendToCommandArrayL(iCommand, NULL, iEntriesToBeCreated); |
|
227 // started exucuting commands |
|
228 iEngine->ExecuteFirstCommandL( KSavingText ); |
|
229 } |
|
230 } |
|
231 //---------------------------------------------------------------------------- |
|
232 |
|
233 TBool CCreatorMessages::AskDataFromUserL(TInt aCommand) |
|
234 { |
|
235 LOGSTRING("Creator: CCreatorMessages::AskDataFromUserL"); |
|
236 |
|
237 CCreatorModuleBase::AskDataFromUserL(aCommand); |
|
238 |
|
239 if ( aCommand == ECmdDeleteMessages ) |
|
240 { |
|
241 return iEngine->GetEngineWrapper()->YesNoQueryDialog( _L("Delete all messages?"), this, ECreatorMessagesDelete ); |
|
242 } |
|
243 else if ( aCommand == ECmdDeleteCreatorMessages ) |
|
244 { |
|
245 return iEngine->GetEngineWrapper()->YesNoQueryDialog( _L("Delete all messages created with Creator?"), this, ECreatorMessagesDelete ); |
|
246 } |
|
247 |
|
248 return iEngine->GetEngineWrapper()->EntriesQueryDialog( &iEntriesToBeCreated, _L("How many entries to create?"), EFalse, this, ECreatorMessagesStart ); |
307 } |
249 } |
308 |
250 |
309 //---------------------------------------------------------------------------- |
251 //---------------------------------------------------------------------------- |
310 |
252 |
311 TInt CCreatorMessages::CreateRandomMessageEntryL(TInt aCommand) |
253 TInt CCreatorMessages::CreateRandomMessageEntryL(TInt aCommand) |