59
|
1 |
/*
|
|
2 |
* Copyright (c) 2010 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: GBA utility body to perform GBA bootstrapping operation.
|
|
15 |
*/
|
|
16 |
|
|
17 |
#include "gbautilitybody.h"
|
|
18 |
|
|
19 |
CGbaUtilityBody* CGbaUtilityBody::NewL(GbaUtility* aGbautility)
|
|
20 |
{
|
|
21 |
CGbaUtilityBody* self = new (ELeave) CGbaUtilityBody(aGbautility);
|
|
22 |
CleanupStack::PushL(self);
|
|
23 |
self->ConstructL();
|
|
24 |
CleanupStack::Pop(self);
|
|
25 |
return self;
|
|
26 |
}
|
|
27 |
|
|
28 |
void CGbaUtilityBody::ConstructL()
|
|
29 |
{
|
|
30 |
iGbaUtility = CGbaUtility::NewL(*this);
|
|
31 |
}
|
|
32 |
|
|
33 |
CGbaUtilityBody::CGbaUtilityBody(GbaUtility* aGbautility) : iQtGbautility(aGbautility)
|
|
34 |
{
|
|
35 |
}
|
|
36 |
|
|
37 |
CGbaUtilityBody::~CGbaUtilityBody()
|
|
38 |
{
|
|
39 |
delete iGbaUtility;
|
|
40 |
}
|
|
41 |
|
|
42 |
GbaUtility::GbaErrorStatus CGbaUtilityBody::bootstrap(const GbaBootstrapInputData* gbainputdata, GbaBootstrapOutputData* gbaoutputdata)
|
|
43 |
{
|
|
44 |
iGbaOutPutData = gbaoutputdata;
|
|
45 |
iInputGbaParameters.iNAFName.Copy(reinterpret_cast<const TUint8*>(gbainputdata->nafName.toAscii().data())
|
|
46 |
, gbainputdata->nafName.toAscii().length());
|
|
47 |
iInputGbaParameters.iFlags = gbainputdata->bootstrapFlag;
|
|
48 |
iInputGbaParameters.iUICCLabel.Copy(reinterpret_cast<const TUint8*>(gbainputdata->uiccLabel.toAscii().data())
|
|
49 |
, gbainputdata->uiccLabel.toAscii().length());
|
|
50 |
iInputGbaParameters.iProtocolIdentifier.Copy(reinterpret_cast<const TUint8*>(gbainputdata->protocolIdentifier.toAscii().data())
|
|
51 |
, gbainputdata->protocolIdentifier.toAscii().length());
|
|
52 |
iInputGbaParameters.iAPID = gbainputdata->accessPoint;
|
|
53 |
TInt error = iGbaUtility->Bootstrap( iInputGbaParameters, iOutputGbaParameters );
|
|
54 |
if(error != KErrNone) {
|
|
55 |
if (error == KErrInUse)
|
|
56 |
return GbaUtility::GbaErrorInUse;
|
|
57 |
else if (error == KErrGeneral)
|
|
58 |
return GbaUtility::GbaErrorGeneral;
|
|
59 |
}
|
|
60 |
return GbaUtility::GbaNoError;
|
|
61 |
}
|
|
62 |
|
|
63 |
void CGbaUtilityBody::cancelBootstrap()
|
|
64 |
{
|
|
65 |
iGbaUtility->CancelBootstrap();
|
|
66 |
}
|
|
67 |
|
|
68 |
GbaUtility::GbaErrorStatus CGbaUtilityBody::setBsfAddress(const QString& aBsfAddress)
|
|
69 |
{
|
|
70 |
HBufC8*bsfAddress = HBufC8::NewL(aBsfAddress.toAscii().length());
|
|
71 |
bsfAddress->Des().Copy(reinterpret_cast<const unsigned char*>(aBsfAddress.toAscii().data()), aBsfAddress.toAscii().length());
|
|
72 |
TInt error = iGbaUtility->SetBSFAddress(bsfAddress->Des());
|
|
73 |
delete bsfAddress;
|
|
74 |
if (error != KErrNone) {
|
|
75 |
if (error == KErrPermissionDenied)
|
|
76 |
return GbaUtility::GbaErrorPermissionDenied;
|
|
77 |
else
|
|
78 |
return GbaUtility::GbaErrorGeneral;
|
|
79 |
}
|
|
80 |
return GbaUtility::GbaNoError;
|
|
81 |
}
|
|
82 |
|
|
83 |
void CGbaUtilityBody::BootstrapComplete(TInt aError)
|
|
84 |
{
|
|
85 |
if (aError != KErrNone) {
|
|
86 |
emit iQtGbautility->bootstrapCompleted(GbaUtility::GbaErrorBootstrapFailed);
|
|
87 |
return;
|
|
88 |
}
|
|
89 |
// Output: B-TID
|
|
90 |
iGbaOutPutData->bTid = QString::fromAscii(reinterpret_cast<const char*>(iOutputGbaParameters.iBTID.Ptr())
|
|
91 |
,iOutputGbaParameters.iBTID.Length());
|
|
92 |
// Output: Ks_NAFs
|
|
93 |
QByteArray ksNaf;
|
|
94 |
ksNaf.append(reinterpret_cast<const char*>(iOutputGbaParameters.iKNAF.Ptr()));
|
|
95 |
iGbaOutPutData->ksNaf = ksNaf;
|
|
96 |
// Output: lifetime
|
|
97 |
QTime time(iOutputGbaParameters.iLifetime.DateTime().Hour()
|
|
98 |
,iOutputGbaParameters.iLifetime.DateTime().Minute()
|
|
99 |
,iOutputGbaParameters.iLifetime.DateTime().Second()
|
|
100 |
,0/*milli seconds component*/);
|
|
101 |
QDate date(iOutputGbaParameters.iLifetime.DateTime().Year()
|
|
102 |
,iOutputGbaParameters.iLifetime.DateTime().Month()
|
|
103 |
,iOutputGbaParameters.iLifetime.DateTime().Day());
|
|
104 |
iGbaOutPutData->lifetime.setDate(date);
|
|
105 |
iGbaOutPutData->lifetime.setTime(time);
|
|
106 |
// Output: IMPI
|
|
107 |
iGbaOutPutData->impi = QString::fromAscii(reinterpret_cast<const char*>(iOutputGbaParameters.iKIMPI.Ptr())
|
|
108 |
,iOutputGbaParameters.iKIMPI.Length());
|
|
109 |
// Output: GBA run-type
|
|
110 |
switch (iOutputGbaParameters.iGbaRunType) {
|
|
111 |
case E2GGBA:
|
|
112 |
iGbaOutPutData->gbaRunType = RunType2gGba;
|
|
113 |
break;
|
|
114 |
case E3GGBAME:
|
|
115 |
iGbaOutPutData->gbaRunType = RunType3gGbaMe;
|
|
116 |
break;
|
|
117 |
case EGBAU:
|
|
118 |
iGbaOutPutData->gbaRunType = RunType3gGbaU;
|
|
119 |
break;
|
|
120 |
case ENoType:
|
|
121 |
iGbaOutPutData->gbaRunType = RunTypeNone;
|
|
122 |
break;
|
|
123 |
default:
|
|
124 |
break;
|
|
125 |
}
|
|
126 |
// Output: type of UICC application used
|
|
127 |
iGbaOutPutData->uiccLabel = QString::fromAscii(reinterpret_cast<const char*>(iOutputGbaParameters.iOutputUICCLabel.Ptr())
|
|
128 |
,iOutputGbaParameters.iOutputUICCLabel.Length());
|
|
129 |
emit iQtGbautility->bootstrapCompleted(GbaUtility::GbaNoError);
|
|
130 |
}
|
|
131 |
|