|
1 /* |
|
2 * Copyright (c) 2008 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 |
|
18 |
|
19 // INCLUDE FILES |
|
20 |
|
21 #include "cstscardoperationsfacade.h" |
|
22 #include "cstsslotmanager.h" |
|
23 #include "stsapduconstants.h" |
|
24 #include "cstsslotinfo.h" |
|
25 #include "logger.h" |
|
26 #include "javasymbianoslayer.h" |
|
27 |
|
28 namespace java |
|
29 { |
|
30 namespace satsa |
|
31 { |
|
32 |
|
33 // CONSTANTS |
|
34 const TInt KSTSDefaulGranularity = 1; |
|
35 const TUint8 KSTSSlotZeroColdSwappable = 0xD0; |
|
36 |
|
37 // ============================ MEMBER FUNCTIONS =============================== |
|
38 |
|
39 |
|
40 CSTSSlotManager::CSTSSlotManager(CSTSCardOperationsFacade* aCOFacade) |
|
41 { |
|
42 iCOFacade = aCOFacade; |
|
43 iGetPerformed = EFalse; |
|
44 } |
|
45 |
|
46 void CSTSSlotManager::ConstructL() |
|
47 { |
|
48 iSlotArray |
|
49 = new(ELeave) CArrayPtrFlat<CSTSSlotInfo> (KSTSDefaulGranularity); |
|
50 } |
|
51 |
|
52 CSTSSlotManager* CSTSSlotManager::NewL(CSTSCardOperationsFacade* aCOFacade) |
|
53 { |
|
54 LOG(ESATSA, EInfo, "+ CSTSSlotManager::NewL"); |
|
55 CSTSSlotManager* self = new(ELeave) CSTSSlotManager(aCOFacade); |
|
56 CleanupStack::PushL(self); |
|
57 self->ConstructL(); |
|
58 CleanupStack::Pop(self); |
|
59 LOG(ESATSA, EInfo, "--- CSTSSlotManager::NewL"); |
|
60 return self; |
|
61 } |
|
62 |
|
63 CSTSSlotManager::~CSTSSlotManager() |
|
64 { |
|
65 delete iSlotString; |
|
66 if (iSlotArray) |
|
67 { |
|
68 iSlotArray->ResetAndDestroy(); |
|
69 } |
|
70 delete iSlotArray; |
|
71 } |
|
72 |
|
73 // ----------------------------------------------------------------------------- |
|
74 // CSTSSlotManager::GetSlotsL |
|
75 // Get the slots available in the card |
|
76 // (other items were commented in a header). |
|
77 // ----------------------------------------------------------------------------- |
|
78 // |
|
79 std::wstring CSTSSlotManager::GetSlotsL() |
|
80 { |
|
81 |
|
82 LOG(ESATSA, EInfo, "+ CSTSClotManager::GetSlotsL() called"); |
|
83 |
|
84 //TPtr8 respPtr( NULL, 0 ); |
|
85 HBufC* tmp = HBufC::NewL(KMaxReaderAmount); |
|
86 delete iSlotString; |
|
87 iSlotString = tmp; |
|
88 |
|
89 TInt readerCount = 1; // one reader at this point |
|
90 for (TInt reader = 0; reader < readerCount; reader++) |
|
91 { |
|
92 LOG(ESATSA, EInfo, "CSTSSlotManager::GetSlotsL:Going to get slot information"); |
|
93 CSTSSlotInfo* slotInfo = CSTSSlotInfo::NewL(KSTSSlotZeroColdSwappable); |
|
94 LOG(ESATSA, EInfo, "After initializing slotInfo object"); |
|
95 CleanupStack::PushL(slotInfo); |
|
96 //ownership moved to array |
|
97 iSlotArray->AppendL(slotInfo); |
|
98 CleanupStack::Pop(slotInfo); |
|
99 |
|
100 if (reader > 0) |
|
101 { |
|
102 LOG(ESATSA, EInfo, "CSTSSlotManager::GetSlotsL:reader > 0"); |
|
103 // comma-separator between slots info |
|
104 iSlotString->Des().Append(','); |
|
105 } |
|
106 LOG(ESATSA, EInfo, "CSTSSlotManager::GetSlotsL: Append the slotInfo"); |
|
107 iSlotString->Des().AppendNum(slotInfo->Slot()); |
|
108 iSlotString->Des().Append(slotInfo->Type()); |
|
109 |
|
110 } |
|
111 |
|
112 iGetPerformed = ETrue; |
|
113 LOG(ESATSA, EInfo, "CSTSSlotManager::GetSlotsL:Start Convertion!"); |
|
114 TPtr toConvert(iSlotString->Des()); |
|
115 std::wstring slotString = desToWstring(toConvert); |
|
116 LOG(ESATSA, EInfo, "-- CSTSClotManager::GetSlotsL()"); |
|
117 return slotString; |
|
118 |
|
119 } |
|
120 |
|
121 // ----------------------------------------------------------------------------- |
|
122 // CSTSSlotManager::DoesExistL |
|
123 // Verifies whether the slot exists in the card |
|
124 // (other items were commented in a header). |
|
125 // ----------------------------------------------------------------------------- |
|
126 // |
|
127 TBool CSTSSlotManager::DoesExistL(TInt aSlot) |
|
128 { |
|
129 // get slots if needed and check does the gived slot exist on the phone |
|
130 LOG(ESATSA, EInfo, "+ CSTSSlotManager::DoesExistL called"); |
|
131 |
|
132 if (!iGetPerformed) |
|
133 { |
|
134 std::wstring slots = GetSlotsL(); |
|
135 } |
|
136 for (TInt i = 0; i < iSlotArray->Count(); i++) |
|
137 { |
|
138 if (iSlotArray->At(i)->Slot() == aSlot) |
|
139 { |
|
140 LOG(ESATSA, EInfo, "CSTSSlotManager::DoesExistL: Slot exists"); |
|
141 return ETrue; |
|
142 } |
|
143 } |
|
144 |
|
145 ELOG(ESATSA, "CSTSSlotManager::DoesExistL: Slot does NOT exist"); |
|
146 return EFalse; |
|
147 |
|
148 } |
|
149 |
|
150 } // namespace satsa |
|
151 } // namespace java |
|
152 // End of File |
|
153 |