|
1 // Copyright (c) 2002-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 #ifndef __SIMPHONESMARTCARDAPP_H_ |
|
17 #define __SIMPHONESMARTCARDAPP_H_ |
|
18 |
|
19 /** |
|
20 * @file |
|
21 * |
|
22 * Contains the class definitions required for the Phone Smart Card applications. |
|
23 * @internalAll |
|
24 */ |
|
25 |
|
26 #include <etelmm.h> |
|
27 #include <et_phone.h> |
|
28 #include <mpbutil.h> |
|
29 #include "csimtimer.h" |
|
30 #include "CSimPhone.h" |
|
31 |
|
32 const TInt KDefaultMaxActiveSmartCardApps = 4; |
|
33 const TInt KMaxFileSize = 2047; //Max size of an EF file |
|
34 const TInt KMaxHexFIDLen = 4; |
|
35 const TInt KMaxBinFIDLen = 2; |
|
36 const TInt KNoAID = -1; |
|
37 |
|
38 /** |
|
39 * The main Phone Smart Card applications class which simulates Smart Card application/File features. |
|
40 */ |
|
41 class CSimPhone; |
|
42 class CTestConfigSection; |
|
43 class CTestConfigItem; |
|
44 class CSimPhoneSmartCardApp : public CSubSessionExtBase, public MTimerCallBack |
|
45 { |
|
46 public: |
|
47 static CSimPhoneSmartCardApp* NewL(CSimPhone* aPhone); |
|
48 CSimPhoneSmartCardApp(CSimPhone* aPhone); |
|
49 ~CSimPhoneSmartCardApp(); |
|
50 |
|
51 virtual CTelObject::TReqMode ReqModeL(const TInt aIpc); |
|
52 // MTelObjectTSY pure virtual |
|
53 virtual TInt RegisterNotification(const TInt aIpc); |
|
54 virtual TInt DeregisterNotification(const TInt aIpc); |
|
55 virtual void Init(); |
|
56 virtual CTelObject* OpenNewObjectByNameL(const TDesC& aName); |
|
57 virtual CTelObject* OpenNewObjectL(TDes& aNewName); |
|
58 virtual TInt NumberOfSlotsL(const TInt aIpc); |
|
59 virtual TInt CancelService(const TInt aIpc, const TTsyReqHandle aTsyReqHandle); |
|
60 |
|
61 // MSubSessionExtBaseTSY pure virtual |
|
62 virtual TInt ExtFunc(const TTsyReqHandle aTsyReqHandle,const TInt aIpc,const TDataPackage& aPackage); |
|
63 virtual void TimerCallBack(TInt aId); |
|
64 const CTestConfigSection* CfgFile(); |
|
65 RMobilePhone::TAID GetActiveUSim(); |
|
66 |
|
67 TBool FoundScAppTags(); |
|
68 |
|
69 protected: |
|
70 void ConstructL(); |
|
71 |
|
72 private: |
|
73 struct TSmartCardAppEvent |
|
74 { |
|
75 TUint32 iDuration; //The amount of time after a notify request, that the event shoudl occur |
|
76 RMobilePhone::TAID iAID; //The AID that should be affected by the event |
|
77 RMobilePhone::TSmartCardApplicationAction iAction; //The event action |
|
78 }; |
|
79 |
|
80 struct TSmartCardNotifyData |
|
81 { |
|
82 TBool iNotifyPending; //indicates if a notification is pending |
|
83 TTsyReqHandle iNotifyHandle; //the TSY notification handle |
|
84 TAny* iNotifyData1; //Holds the data for the notification pending |
|
85 TAny* iNotifyData2; //Holds the data for the notification pending |
|
86 }; |
|
87 |
|
88 enum TSmartCardAppType |
|
89 { |
|
90 EUSimApp, //Indicates that the Smart card App is a USim App |
|
91 ESmartCardApp //Indicates a standard Smart Card App |
|
92 }; |
|
93 |
|
94 enum TSmartCardAppStatus |
|
95 { |
|
96 EInactive, //Indicates that the Smart Card App is installed and inactive |
|
97 EActive //Indicates that the Smart Card App is installed and active |
|
98 }; |
|
99 |
|
100 struct TSmartCardApplication |
|
101 { |
|
102 RMobilePhone::TAID iAID; //SmartCard Application's AID |
|
103 TBuf8<RMobilePhone::KSmartCardApplicationLabelMaxSize> iLabel; //SmartCard Application's Label |
|
104 TSmartCardAppType iAppType; //The type of smart card application |
|
105 TSmartCardAppStatus iAppStatus; //The status of the smart card application |
|
106 TBuf8<RMobilePhone::KEapSupportedTypeListSize> iEapList; //EAP support list |
|
107 }; |
|
108 |
|
109 class TSmartCardFile |
|
110 { |
|
111 public: |
|
112 void GetFileInfo(RMobilePhone::TScFileInfoV5& aScFileInfo); |
|
113 virtual TInt ReadFile(const RMobilePhone::TScFilePathWithAccessOffsets& aFilePathOffsets, TDes8* aReadBuffer) =0; |
|
114 virtual TInt UpdateFile(const RMobilePhone::TScFilePathWithAccessOffsets& aFilePathOffsets, TDes8* aWriteBuffer) =0; |
|
115 |
|
116 public: |
|
117 RMobilePhone::TScFileID iFileID; //Holds the FID ofthe file |
|
118 RMobilePhone::TScFileType iType; //Holds the 'Type' of the file |
|
119 TInt iTotalLength; //Holds the total length (in Bytes) of the file |
|
120 TInt iRecordLength; //Holds the length of each record contained in the file |
|
121 TUint iNumberRecords; //Holds the number of records held in the file |
|
122 TInt iAIDIndex; //Holds an index to the ScApplication the file is under |
|
123 RMobilePhone::TScFilePathReference iPath; //Holds the full path reference of the file |
|
124 TBuf8<KMaxFileSize> iFileData; //Holds the file's data |
|
125 }; |
|
126 |
|
127 class TLinearSmartCardFile : public TSmartCardFile |
|
128 { |
|
129 public: |
|
130 virtual TInt ReadFile(const RMobilePhone::TScFilePathWithAccessOffsets& aFilePathOffsets, TDes8* aReadBuffer); |
|
131 virtual TInt UpdateFile(const RMobilePhone::TScFilePathWithAccessOffsets& aFilePathOffsets, TDes8* aWriteBuffer); |
|
132 }; |
|
133 |
|
134 class TCyclicSmartCardFile : public TSmartCardFile |
|
135 { |
|
136 public: |
|
137 TCyclicSmartCardFile(); |
|
138 virtual TInt ReadFile(const RMobilePhone::TScFilePathWithAccessOffsets& aFilePathOffsets, TDes8* aReadBuffer); |
|
139 virtual TInt UpdateFile(const RMobilePhone::TScFilePathWithAccessOffsets& aFilePathOffsets, TDes8* aWriteBuffer); |
|
140 private: |
|
141 void UpdateOldestRecordPointer(); |
|
142 private: |
|
143 TInt iOldestRecord; //Points to the beginning of the oldest record in the buffer |
|
144 }; |
|
145 |
|
146 class TTransparentSmartCardFile : public TSmartCardFile |
|
147 { |
|
148 public: |
|
149 virtual TInt ReadFile(const RMobilePhone::TScFilePathWithAccessOffsets& aFilePathOffsets, TDes8* aReadBuffer); |
|
150 virtual TInt UpdateFile(const RMobilePhone::TScFilePathWithAccessOffsets& aFilePathOffsets, TDes8* aWriteBuffer); |
|
151 }; |
|
152 |
|
153 TInt GetCurrentActiveUSimApplication(const TTsyReqHandle aTsyReqHandle, RMobilePhone::TAID* aAID); |
|
154 TInt GetCurrentActiveUSimApplicationCancel(const TTsyReqHandle aTsyReqHandle); |
|
155 TInt EnumerateUSimApplications(const TTsyReqHandle aTsyReqHandle, TInt* aCount, RMobilePhone::TAID* aActiveAID); |
|
156 TInt EnumerateUSimApplicationsCancel(const TTsyReqHandle aTsyReqHandle); |
|
157 TInt GetUSimApplicationInfo(const TTsyReqHandle aTsyReqHandle, TInt* aUSimAppIndex, TDes8* aInfo); |
|
158 TInt GetUSimApplicationInfoCancel(const TTsyReqHandle aTsyReqHandle); |
|
159 TInt NotifyUSimApplicationsInfoChange(const TTsyReqHandle aTsyReqHandle, TInt* aCount, RMobilePhone::TAID* aActiveAID); |
|
160 TInt NotifyUSimApplicationsInfoChangeCancel(const TTsyReqHandle aTsyReqHandle); |
|
161 TInt SetUSimApplicationStatus(const TTsyReqHandle aTsyReqHandle, RMobilePhone::TAID* aAID, RMobilePhone::TUSimAppAction* aUsimAppAction); |
|
162 TInt SetUSimApplicationStatusCancel(const TTsyReqHandle aTsyReqHandle); |
|
163 TInt EnumerateScApplications(const TTsyReqHandle aTsyReqHandle, TUint* aCount); |
|
164 TInt EnumerateScApplicationsCancel(const TTsyReqHandle aTsyReqHandle); |
|
165 TInt GetScApplicationInfo(const TTsyReqHandle aTsyReqHandle, TInt* aAppIndex, TDes8* aInfo); |
|
166 TInt GetScApplicationInfoCancel(const TTsyReqHandle aTsyReqHandle); |
|
167 TInt NotifyScApplicationInfoChange(const TTsyReqHandle aTsyReqHandle, RMobilePhone::TAID* aAID, RMobilePhone::TSmartCardApplicationEvent* aEvent); |
|
168 TInt NotifyScApplicationInfoChangeCancel(const TTsyReqHandle aTsyReqHandle); |
|
169 TInt SetScApplicationStatus(const TTsyReqHandle aTsyReqHandle, RMobilePhone::TAID* aAID, RMobilePhone::TSmartCardApplicationAction* aAction); |
|
170 TInt SetScApplicationStatusCancel(const TTsyReqHandle aTsyReqHandle); |
|
171 TInt SetUSimAppsSelectionMode(const TTsyReqHandle aTsyReqHandle, RMobilePhone::TUSimSelectionMode* aUSimSelectionMode); |
|
172 TInt SetUSimAppsSelectionModeCancel(const TTsyReqHandle aTsyReqHandle); |
|
173 TInt GetUSimAppsSelectionMode(const TTsyReqHandle aTsyReqHandle, RMobilePhone::TUSimSelectionMode* aUSimSelectionMode); |
|
174 TInt GetUSimAppsSelectionModeCancel(const TTsyReqHandle aTsyReqHandle); |
|
175 TInt NotifyUSIMAppsSelectionModeChange(const TTsyReqHandle aTsyReqHandle, RMobilePhone::TUSimSelectionMode* aUSimSelectionMode); |
|
176 TInt NotifyUSIMAppsSelectionModeChangeCancel(const TTsyReqHandle aTsyReqHandle); |
|
177 TInt GetScFileInfo(const TTsyReqHandle aTsyReqHandle, const RMobilePhone::TScFilePath& aFilePathId, TDes8* aInfo); |
|
178 TInt GetScFileInfoCancel(const TTsyReqHandle aTsyReqHandle); |
|
179 TInt ReadScFile(const TTsyReqHandle aTsyReqHandle, const RMobilePhone::TScFilePathWithAccessOffsets& aFilePathOffsets, TDes8* aReadBuffer); |
|
180 TInt ReadScFileCancel(const TTsyReqHandle aTsyReqHandle); |
|
181 TInt UpdateScFile(const TTsyReqHandle aTsyReqHandle, const RMobilePhone::TScFilePathWithAccessOffsets& aFilePathOffsets, TDes8* aWriteBuffer); |
|
182 TInt UpdateScFileCancel(const TTsyReqHandle aTsyReqHandle); |
|
183 |
|
184 //Helper functions |
|
185 void ParseSmartCardApplicationInfoL(); |
|
186 void ParseSmartCardFileInfoL(); |
|
187 void MapUSimAppsL(); |
|
188 TInt FindScFile(const RMobilePhone::TScFilePath& aFilePathInfo, TSmartCardFile*& aSmartCardFile); |
|
189 TInt ActivateSmartCardApp(const RMobilePhone::TAID aAID, TBool& aActivatedUSimApp); |
|
190 TInt TerminateSmartCardApp(const RMobilePhone::TAID aAID, TBool& aTerminatedUSimApp); |
|
191 void TextToBin(const TDesC8& aSrc, TDes8& aDst); |
|
192 |
|
193 private: |
|
194 CSimPhone* iPhone; |
|
195 CSimTimer* iTimer; |
|
196 TSmartCardNotifyData iNotifyUSimInfo; |
|
197 TSmartCardNotifyData iNotifyScInfo; |
|
198 TNotifyData iNotifyMode; |
|
199 TBool iTimerStarted; |
|
200 TInt iMaxActiveSmartCardApps; |
|
201 |
|
202 CArrayFixFlat<TSmartCardAppEvent>* iSmartCardAppEventList; |
|
203 TInt iEventPointer; |
|
204 CArrayFixFlat<TSmartCardApplication>* iSmartCardAppList; |
|
205 TInt iNumActiveSmartCardApps; |
|
206 RMobilePhone::TAID iActiveUSimApp; |
|
207 RPointerArray<TSmartCardApplication>* iUSimAppList; |
|
208 CArrayPtrFlat<TSmartCardFile>* iSmartCardFileList; |
|
209 RMobilePhone::TUSimSelectionMode iCurrentSelection; |
|
210 TBool iFoundScAppTags; |
|
211 }; |
|
212 |
|
213 #endif |