|
1 // Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of the License "Symbian Foundation License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // This contains CTestMessEditEntry which edits the entry characterstics |
|
15 // |
|
16 // |
|
17 |
|
18 #include "TestMessEditEntry.h" |
|
19 #include "TestMessEditEntryUtil.h" |
|
20 |
|
21 /** |
|
22 * @name Constant Literals used. |
|
23 */ |
|
24 /*@{*/ |
|
25 _LIT(KPtSaveToOutbox, "SaveToOutbox"); |
|
26 /*@}*/ |
|
27 |
|
28 /// Default value for depth of the count |
|
29 #define KDefaultDepthCount 1 |
|
30 |
|
31 /** |
|
32 * Override of base class pure virtual |
|
33 * @param None |
|
34 * @return TVerdict - return TVerdict codes |
|
35 * @panic None |
|
36 * @leave KErrNoMemory |
|
37 * |
|
38 */ |
|
39 void CTestMessEditEntry::ProcessMessageL(CBaseMtm& /*aBaseMtm*/, TMsvId /*aMsgId*/) |
|
40 { |
|
41 // Printing to the console and log file |
|
42 INFO_PRINTF1(_L("Edit Entry")); |
|
43 |
|
44 if ( TestStepResult() == EPass ) |
|
45 { |
|
46 CTestMessEditEntryUtil* editUtil=new (ELeave) CTestMessEditEntryUtil(*this, EFalse, EFalse, RMobilePhone::TMobileAddress()); |
|
47 CleanupStack::PushL(editUtil); |
|
48 |
|
49 editUtil->ProcessEntryL(EntryL().EntryId()); |
|
50 |
|
51 //Read whether the message is saved in outbox |
|
52 TBool saveOutbox; |
|
53 if( ! GetBoolFromConfig(ConfigSection(), KPtSaveToOutbox, saveOutbox)) |
|
54 { |
|
55 saveOutbox = EFalse; |
|
56 } |
|
57 |
|
58 INFO_PRINTF2(_L("The message saved in outbox flag is : %S"), &saveOutbox); |
|
59 if(saveOutbox) |
|
60 { |
|
61 //Move the message to outbox |
|
62 MoveMessageL(EntryL().EntryId(), KMsvGlobalOutBoxIndexEntryId); |
|
63 } |
|
64 else |
|
65 { |
|
66 INFO_PRINTF1(_L("Entry is not moved")); |
|
67 } |
|
68 |
|
69 CleanupStack::PopAndDestroy(editUtil); |
|
70 } |
|
71 } |
|
72 |
|
73 /** |
|
74 Move the message the destination folder |
|
75 @param aMessageId - TMsvId of the message |
|
76 @param aFolderId - TMsvId of the destination folder |
|
77 @leave KErrNoMemory |
|
78 @leave KErrNotFound |
|
79 */ |
|
80 void CTestMessEditEntry::MoveMessageL(TMsvId aMessageId,TMsvId aFolderId) |
|
81 { |
|
82 // Get CMsvEntry object and the TMsvEntry of the message |
|
83 CMsvEntry* msgvEntry = iSession->GetEntryL(aMessageId); |
|
84 CleanupStack::PushL(msgvEntry); |
|
85 TMsvEntry entry= msgvEntry->Entry(); |
|
86 |
|
87 // Get the parent folder Id of the messaage and create the CMsvEntry |
|
88 TMsvId parentId = entry.Parent(); |
|
89 CMsvEntry* msvEntry = iSession->GetEntryL(parentId); |
|
90 CleanupStack::PushL(msvEntry); |
|
91 |
|
92 // Create the active object for handling asynchronous request |
|
93 CMoveOperation* activeOperation = CMoveOperation::NewL(); |
|
94 CleanupStack::PushL(activeOperation); |
|
95 |
|
96 // Move the selected message to given target folder |
|
97 CMsvOperation* op = msvEntry->MoveL(aMessageId, aFolderId, activeOperation->iStatus); |
|
98 CleanupStack::PushL(op); |
|
99 |
|
100 // Start the Active scheduler |
|
101 activeOperation->SetOperation(); |
|
102 CActiveScheduler::Start(); |
|
103 TInt error = activeOperation->iStatus.Int(); |
|
104 if(error == KErrNone) |
|
105 { |
|
106 INFO_PRINTF1(_L("message moved successfully")); |
|
107 } |
|
108 else |
|
109 { |
|
110 INFO_PRINTF2(_L("message failed to be moved. Error : %d"),error); |
|
111 SetTestStepResult(EFail); |
|
112 } |
|
113 //Destroy the object |
|
114 CleanupStack::PopAndDestroy(4, msgvEntry); |
|
115 } |
|
116 |
|
117 /** |
|
118 Constructor for CMoveOperation |
|
119 */ |
|
120 CTestMessEditEntry::CMoveOperation::CMoveOperation() |
|
121 : CActive(CActive::EPriorityStandard) |
|
122 { |
|
123 } |
|
124 |
|
125 /** |
|
126 Two phase constructor |
|
127 @return CTestMessEditEntry::CMoveOperation* - pointer of CTestMessEditEntry::CMoveOperation |
|
128 @leave - KErrNoMemory |
|
129 @leave - System wide error codes |
|
130 */ |
|
131 CTestMessEditEntry::CMoveOperation* CTestMessEditEntry::CMoveOperation::NewL() |
|
132 { |
|
133 CMoveOperation* self = new (ELeave) CMoveOperation(); |
|
134 CleanupStack::PushL(self); |
|
135 self->ConstructL(); |
|
136 CleanupStack::Pop(self); |
|
137 return self; |
|
138 } |
|
139 |
|
140 /** |
|
141 Second phase construction |
|
142 @leave - sytem wide error codes |
|
143 */ |
|
144 void CTestMessEditEntry::CMoveOperation::ConstructL() |
|
145 { |
|
146 CActiveScheduler::Add(this); |
|
147 } |
|
148 |
|
149 /** |
|
150 Sets the operation as active |
|
151 */ |
|
152 void CTestMessEditEntry::CMoveOperation::SetOperation() |
|
153 { |
|
154 SetActive(); |
|
155 } |
|
156 |
|
157 /** |
|
158 Operation completed event handler. |
|
159 */ |
|
160 void CTestMessEditEntry::CMoveOperation::RunL() |
|
161 { |
|
162 CActiveScheduler::Stop(); |
|
163 } |
|
164 |
|
165 /** |
|
166 Cancels the active operation |
|
167 */ |
|
168 void CTestMessEditEntry::CMoveOperation::DoCancel() |
|
169 { |
|
170 } |