1 /* |
|
2 * Copyright (c) 2009 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 #ifndef MMSTESTSTATICUTILS_H |
|
18 #define MMSTESTSTATICUTILS_H |
|
19 |
|
20 #include <e32std.h> |
|
21 #include <msvstd.h> |
|
22 #include <badesca.h> |
|
23 |
|
24 #include "mmsconst.h" |
|
25 |
|
26 class RFs; |
|
27 class CMsvSession; |
|
28 class CMmsEncode; |
|
29 class CMmsHeaders; |
|
30 |
|
31 #ifdef __WINS__ |
|
32 _LIT( KRootPath, "c:\\" ); |
|
33 #else |
|
34 // This is removable disk. |
|
35 // drive letter should not be hard coded, must be investigated further |
|
36 // We use c: for a while for the tests (to be cahnged later) |
|
37 _LIT( KRootPath, "c:\\" ); |
|
38 //_LIT( KRootPath, "e:\\" ); |
|
39 #endif |
|
40 |
|
41 // directory where mmbox descriptions are created |
|
42 _LIT( KMmsMMBoxDescriptionDirectory, "C:\\mmsmmboxdescriptions\\"); |
|
43 // directory where created headers are dumped |
|
44 _LIT( KMmsDumpDirectory, "C:\\mmsdump\\"); |
|
45 // content type of MMS PDUs |
|
46 _LIT8( KMmsMimeType, "application/vnd.wap.mms-message" ); |
|
47 |
|
48 _LIT( KWild, "*" ); |
|
49 |
|
50 |
|
51 /** |
|
52 * joined array structure |
|
53 * |
|
54 */ |
|
55 NONSHARABLE_CLASS( TMmsJoinedArrays ): public MDesCArray |
|
56 { |
|
57 public: |
|
58 TMmsJoinedArrays(CDesCArray* const & aArray1, CDesCArray* const & aArray2); |
|
59 TInt MdcaCount() const; |
|
60 TPtrC16 MdcaPoint(TInt aIndex) const; |
|
61 private: |
|
62 CDesCArray* const & iArray1; |
|
63 CDesCArray* const & iArray2; |
|
64 }; |
|
65 |
|
66 /** |
|
67 * static utility functions |
|
68 * |
|
69 */ |
|
70 class TMmsTestUtils |
|
71 { |
|
72 |
|
73 public: |
|
74 |
|
75 /** |
|
76 * |
|
77 */ |
|
78 TMmsTestUtils(); |
|
79 |
|
80 /** |
|
81 * read phone number for sending messages |
|
82 * |
|
83 * @param aFileName full path for filename |
|
84 * @param aFs file system handle |
|
85 * @return allocated pointer containing the name |
|
86 * The caller must delete the pointer when no longer needed |
|
87 */ |
|
88 static HBufC* ReadContactFromFileL( TDesC& aFileName, RFs& aFs ); |
|
89 |
|
90 static void DecodeLoggingOnL(); |
|
91 static void DecodeLoggingOffL(); |
|
92 static void BinaryDumpOnL(); |
|
93 static void BinaryDumpOffL(); |
|
94 |
|
95 /** |
|
96 * Clean all temporary directories used in local mode. |
|
97 * Does not delete the directories, only the contents |
|
98 * |
|
99 * @param aFs file system handle |
|
100 */ |
|
101 static void CleanDirectoryL( RFs& aFs ); |
|
102 |
|
103 /** |
|
104 * Dump a binary message |
|
105 * |
|
106 * @param aBuffer buffer containing the binary message |
|
107 * @param aFilename full path of the directory whenre the dump goes |
|
108 * @param aParse reference to parser (to save stack space) |
|
109 * @param aFs file system handle |
|
110 */ |
|
111 static void Dump( |
|
112 CBufFlat& aBuffer, TFileName& aFilename, TParse& aParse, RFs& aFs ); |
|
113 |
|
114 /** |
|
115 * Delete all MMS messages and notifications from a given folder |
|
116 * |
|
117 * @param aBoxId folder id |
|
118 * @param aSession Messaging server session |
|
119 */ |
|
120 static void CleanBoxL(TMsvId aBoxId, CMsvSession& aSession); |
|
121 |
|
122 /** |
|
123 * turn on logging messages sent to email addresses |
|
124 */ |
|
125 static void EmailLoggingOnL(); |
|
126 |
|
127 /** |
|
128 * turn off logging messages sent to email addresses |
|
129 */ |
|
130 static void EmailLoggingOffL(); |
|
131 |
|
132 /** |
|
133 * load list of children into selection and return count |
|
134 * |
|
135 * @param aBoxId folder id |
|
136 * @param aMsvEntrySelection reference to a pointer that will contain the list of child ids |
|
137 * caller is responsible of deleting the pointer afterwards. |
|
138 * Pointer may be NULL at entry, and a new pointer will be allocated |
|
139 * @param aSession messge server session |
|
140 * @param aMessageType child MTM type, default is multimedia message |
|
141 * @return number of entries in selection |
|
142 */ |
|
143 static TInt CountChildrenL( |
|
144 TMsvId aBoxId, |
|
145 CMsvEntrySelection*& aMsvEntrySelection, |
|
146 CMsvSession& aSession, |
|
147 TUid aMessageType = KUidMsgTypeMultimedia); |
|
148 |
|
149 /** |
|
150 * Create a folder entry |
|
151 * |
|
152 * @param aSession messge server session |
|
153 * @param aParentFolder the parent folder |
|
154 * @param aFolderName name of the folder |
|
155 * @param aFolderId will contain the if of the new folder if creation was successful |
|
156 */ |
|
157 static void CreateFolderEntryL( |
|
158 CMsvSession& aSession, |
|
159 TMsvId aParentFolder, |
|
160 const TDesC& aFolderName, |
|
161 TMsvId& aFolderId ); |
|
162 |
|
163 /** |
|
164 * Create an MMS notification from data in buffer |
|
165 * @param aNotificationFolder mms notification folder (target folder) |
|
166 * @param aServiceId id of MMS service |
|
167 * @param aEncodeBuffer buffer that contains the data |
|
168 * @param aSession message server session |
|
169 * @return id of the created notification |
|
170 */ |
|
171 static TMsvId CreateNotificationEntryL( |
|
172 TMsvId aNotificationFolder, |
|
173 TMsvId aServiceId, |
|
174 CBufFlat* aEncodeBuffer, |
|
175 CMsvSession& aSession ); |
|
176 |
|
177 /** |
|
178 * Encode an MMS notification into buffer |
|
179 * @param aUrl url of the notification for local messages a filepath |
|
180 * @param aSize size of the message |
|
181 * @param aMmsHeaders MMS headers structure for creating the notification |
|
182 * @param aMmsEncoder reference to CMmsEncode class |
|
183 * @param aEncodeBuffer flat buffer that will contain the encoded notification |
|
184 */ |
|
185 static void FormNotification( |
|
186 TDesC8& aUrl, |
|
187 TInt aSize, |
|
188 CMmsHeaders& aMmsHeaders, |
|
189 CMmsEncode& aMmsEncoder, |
|
190 CBufFlat* aEncodeBuffer ); |
|
191 |
|
192 |
|
193 static TBool IsDrive(const TDesC& aFileName); |
|
194 static TBool IsDir(const TDesC& aFileName, RFs& aFs); |
|
195 static TBool IsFile(const TDesC& aFileName, RFs& aFs); |
|
196 |
|
197 |
|
198 private: |
|
199 |
|
200 }; |
|
201 |
|
202 |
|
203 #endif // MMSTESTSTATICUTILS_H |
|