1 /* |
|
2 * Copyright (c) 2002-2006 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 the License "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: Provides functionality to open SIM data file and |
|
15 * to make searches and comperations to its content. |
|
16 * Each line in SIM data file represent a separate elementary file |
|
17 * or file's record (referenced as RefEfs). |
|
18 * |
|
19 */ |
|
20 |
|
21 |
|
22 |
|
23 #ifndef SATFILE_H |
|
24 #define SATFILE_H |
|
25 |
|
26 // INCLUDES |
|
27 #include <e32base.h> |
|
28 #include <f32file.h> |
|
29 |
|
30 // FORWARDS |
|
31 // None |
|
32 |
|
33 // DATA TYPES |
|
34 |
|
35 // CLASS DECLARATION |
|
36 |
|
37 /** |
|
38 * Provides functionality to interact with SIM data file |
|
39 * @lib SimAtk.dll |
|
40 */ |
|
41 NONSHARABLE_CLASS( CSatFile ) : public CBase |
|
42 { |
|
43 public: // Constructors and destructor |
|
44 |
|
45 /** |
|
46 * Constructor. |
|
47 */ |
|
48 CSatFile(); |
|
49 |
|
50 /** |
|
51 * Destructor. |
|
52 */ |
|
53 virtual ~CSatFile(); |
|
54 |
|
55 |
|
56 public: // New Methods |
|
57 |
|
58 /* |
|
59 * Opens SIM data file |
|
60 * @return KErrNone if OK, KErrNotFound if file was not found. |
|
61 */ |
|
62 TInt OpenFile(); |
|
63 |
|
64 /* |
|
65 * Locate reference elementary file (RefEf) in SIM data file |
|
66 * @param aSimType Type of RefEf (SATTS/GCF) |
|
67 * @param aFileId File to be searched (eg. 4F21) |
|
68 * @param aRecord Record to be searched. Default is none. |
|
69 * @return KErrNone if RefEf was found from the SIM data |
|
70 * file. KErrNotFound if not. |
|
71 */ |
|
72 TInt FindFile( const TPtrC aSimType, const TInt aFileId, |
|
73 const TInt aRecord = 0 ); |
|
74 |
|
75 /** |
|
76 * Match the content to provided data to the RefEf. |
|
77 * Correct SIM file has to be searched first using the FindFile |
|
78 * method. |
|
79 * @param aData Data to be validated |
|
80 * @param aOffset Offset to data start within the RefEf. |
|
81 * default is zero (=start validation from the beginging of RefEf. |
|
82 * @return KErrNone if data matches, KErrCorrupt if not. KErrOverFlow |
|
83 * if provided data contain more bytes that could be parsed from |
|
84 * RefEf |
|
85 */ |
|
86 TInt MatchData( const TDesC8& aData, const TUint aOffset = 0 ); |
|
87 |
|
88 /** |
|
89 * Reads data from RefEf to output. Reading continues until the max |
|
90 * capacity of output is reached or more values can't be read from |
|
91 * RefEf. |
|
92 * Correct SIM file has to be searched first using the FindFile |
|
93 * method. |
|
94 * @param aData Read data is stored here. |
|
95 * @param Offset from where the reading of data shall start. |
|
96 * @return KErrNone or KErrNotFound if output buffer could not be |
|
97 * filled completely. |
|
98 */ |
|
99 TInt FetchData( TDes8& aData, const TUint aOffset ); |
|
100 |
|
101 private: // New Methods |
|
102 |
|
103 /** |
|
104 * Return next character from current line. Error is returned if end |
|
105 * Line has been reached. |
|
106 * @param aChar Next character read from line |
|
107 * @return KErrNone if successful, KErrNotFound if end of line |
|
108 * encountered. |
|
109 */ |
|
110 TInt NextChar( TChar& aChar ); |
|
111 |
|
112 /** |
|
113 * Skips the current line. Error is return if end of file has been |
|
114 * reached. |
|
115 * @return KErrNone or KErrNout found if end of file encountered |
|
116 */ |
|
117 TInt NextLine(); |
|
118 |
|
119 /** |
|
120 * Reads next token (word, number) from the file. |
|
121 * @param aToken Token read from the file. |
|
122 * @return KErrNone KErrNotFound if end of file reached. |
|
123 */ |
|
124 TInt NextToken( TDes8& aToken ); |
|
125 |
|
126 /** |
|
127 * Reads next integer value from the RefEf. |
|
128 * @param aValue Value read from the file. |
|
129 * @return KErrNone KErrNotFound if end of line reached. |
|
130 */ |
|
131 TInt NextValue( TUint& aValue ); |
|
132 |
|
133 /** |
|
134 * Goes to a specified position in the RefEf file. |
|
135 */ |
|
136 TInt Goto( const TUint aOffset ); |
|
137 |
|
138 |
|
139 private: // Data |
|
140 |
|
141 // Resource file server |
|
142 RFs iFileServer; |
|
143 |
|
144 // Resource file |
|
145 RFile iFile; |
|
146 |
|
147 // Start position of requested RefEf within the SIM data file |
|
148 TInt iSimFilePos; |
|
149 |
|
150 }; |
|
151 |
|
152 #endif // SATFILE_H |
|
153 |
|
154 // End of |
|