|
1 // Copyright (c) 2004-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 "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #include "IPCCommandForCapsPermissions.h" |
|
17 #include "pigeonservermtm.h" |
|
18 #include <e32std.h> |
|
19 #include <e32base.h> |
|
20 |
|
21 |
|
22 #include "MCLIENT.H" |
|
23 #include "MSERVER.H" |
|
24 |
|
25 #include "SendProxyClient.h" |
|
26 |
|
27 |
|
28 #include "CMtfTestCase.h" |
|
29 #include "CMtfTestActionParameters.h" |
|
30 |
|
31 |
|
32 |
|
33 void IPCCommandReportPassOrFailForCapsPermissions( CMtfTestCase& aTestCase, const TDesC& aTestName, TInt aError ,TInt aPass ) |
|
34 { |
|
35 |
|
36 if ( aError == KErrNone ) |
|
37 { |
|
38 if (aPass==1) |
|
39 { |
|
40 aTestCase.INFO_PRINTF2(_L("%S :: PASS :: Test Expected to Fail and Fails") , &aTestName ); |
|
41 aTestCase.SetTestStepResult(EPass); |
|
42 } |
|
43 else if (aPass==0) |
|
44 { |
|
45 |
|
46 aTestCase.ERR_PRINTF2(_L("%S :: FAIL :: Test Expected to Fail but Passes") , &aTestName ); |
|
47 aTestCase.SetTestStepResult(EFail); |
|
48 } |
|
49 else |
|
50 { |
|
51 aTestCase.ERR_PRINTF2(_L("%S :: FAIL :: Should Specify PASS/FAIL") , &aTestName ); |
|
52 aTestCase.SetTestStepResult(EFail); |
|
53 } |
|
54 } |
|
55 else if ( aError == KErrPermissionDenied ) |
|
56 { |
|
57 if (aPass==1) |
|
58 { |
|
59 aTestCase.ERR_PRINTF2(_L("%S :: FAIL :: Test Expected to Pass but Fails") , &aTestName ); |
|
60 aTestCase.SetTestStepResult(EFail); |
|
61 } |
|
62 else if (aPass==0) |
|
63 { |
|
64 aTestCase.INFO_PRINTF2(_L("%S :: PASS :: Test Expected to Fail and Passes") , &aTestName ); |
|
65 aTestCase.SetTestStepResult(EPass); |
|
66 } |
|
67 else |
|
68 { |
|
69 aTestCase.ERR_PRINTF2(_L("%S :: FAIL :: Should Specify PASS/FAIL") , &aTestName ); |
|
70 aTestCase.SetTestStepResult(EFail); |
|
71 } |
|
72 } |
|
73 else |
|
74 { |
|
75 aTestCase.ERR_PRINTF3(_L("%S :: FAIL Unknown error (%d) ") , &aTestName , aError ); |
|
76 aTestCase.SetTestStepResult(EFail); |
|
77 } |
|
78 |
|
79 } |
|
80 |
|
81 |
|
82 _LIT(KDescription , "CreateEntry" ); |
|
83 _LIT(KNewAddress , "Symbian" ); |
|
84 |
|
85 |
|
86 void FillInSimpleMessageEntry( TMsvId aMessageId, TMsvId aParentId, TMsvId aServiceId, TMsvEntryForward& aEntry) |
|
87 { |
|
88 |
|
89 aEntry.SetId(aMessageId); |
|
90 aEntry.SetParent( aParentId ); |
|
91 aEntry.iType = KUidMsvMessageEntry; |
|
92 aEntry.iMtm = KUidMsgTypeSMTP; |
|
93 aEntry.iServiceId = aServiceId; |
|
94 |
|
95 aEntry.iDescription.Set(KDescription); |
|
96 |
|
97 aEntry.iDetails.Set(KNewAddress); |
|
98 aEntry.iDate.HomeTime(); |
|
99 |
|
100 } |
|
101 |
|
102 void FillInServiceEntry( TMsvId aMessageId, TMsvEntryForward& aEntry) |
|
103 { |
|
104 // This is a service entry, so we need to set parent to root and service ID to |
|
105 // the entry id (ie serviceId is same as entry id) |
|
106 aEntry.SetId(aMessageId); |
|
107 aEntry.SetParent( KMsvRootIndexEntryId ); |
|
108 aEntry.iType = KUidMsvServiceEntry; |
|
109 aEntry.iMtm = KUidMsgTypeSMTP; |
|
110 aEntry.iServiceId = aMessageId; |
|
111 |
|
112 aEntry.iDescription.Set(KDescription); |
|
113 aEntry.iDetails.Set(KNewAddress); |
|
114 aEntry.iDate.HomeTime(); |
|
115 } |
|
116 |
|
117 |
|
118 void FillInRemoteMessageEntry( TMsvId aMessageId, TMsvId aParentId, TMsvId aServiceId, TMsvEntryForward& aEntry) |
|
119 { |
|
120 aEntry.SetId(aMessageId); |
|
121 aEntry.SetParent( aParentId ); |
|
122 aEntry.iType = KUidMsvMessageEntry; |
|
123 aEntry.iMtm = KUidMsgTypePigeon; |
|
124 aEntry.iServiceId = aServiceId; |
|
125 |
|
126 aEntry.iDescription.Set(KDescription); |
|
127 |
|
128 aEntry.iDetails.Set(KNewAddress); |
|
129 aEntry.iDate.HomeTime(); |
|
130 |
|
131 } |
|
132 |
|
133 _LIT(KNewAddress1 , "OverwriteMe" ); |
|
134 |
|
135 |
|
136 // Useful routine just to see and check what has actally gone into the messaginging server. |
|
137 // Note must have correct capabilities. |
|
138 |
|
139 void CheckWentInStoreL(CMtfTestCase& aTestCase, const TDesC& aTestName, |
|
140 RProxyServerSession& RPSS , TMsvId id, TMsvEntryForward& entry , TMsvOp& operationId ) |
|
141 { |
|
142 |
|
143 HBufC8* iBuffer = HBufC8::NewLC(KMsvSessionBufferLength); |
|
144 TPtr8 ptr=iBuffer->Des(); |
|
145 TMsvEntryForward entryStore=entry; |
|
146 entryStore.SetId(id); |
|
147 |
|
148 entryStore.iDetails.Set( KNewAddress1 ); |
|
149 |
|
150 TMsvId aService(0); |
|
151 TPckg<TMsvId> service(aService); |
|
152 |
|
153 operationId++; |
|
154 TInt error = RPSS.SendReceive(EMsvGetEntry,TIpcArgs(entryStore.Id(),&ptr,&service)); |
|
155 if (error!=KErrNone) |
|
156 { |
|
157 aTestCase.ERR_PRINTF2(_L("%S :: PROBLEM :: Unable to read the message back.") , &aTestName ); |
|
158 User::LeaveIfError(error); |
|
159 } |
|
160 |
|
161 |
|
162 TMsvPackedEntry packedEntry(iBuffer); |
|
163 packedEntry.UnpackEntry(entryStore); |
|
164 |
|
165 if ( entryStore.iDetails == KNewAddress1 ) |
|
166 { |
|
167 aTestCase.ERR_PRINTF2(_L("%S :: PROBLEM :: Message was not modified in the store.") , &aTestName ); |
|
168 User::LeaveIfError(error); |
|
169 } |
|
170 else |
|
171 { |
|
172 //RDebug::Printf( " CheckWentInStoreL :: WORKS!!!!!!!!!!!!!!!!!!!!!!!!\n" ); //????? |
|
173 } |
|
174 |
|
175 CleanupStack::Check(iBuffer); |
|
176 CleanupStack::PopAndDestroy(); |
|
177 |
|
178 } |