35
|
1 |
/*
|
|
2 |
* Copyright (c) 2007-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: Handles Set personality request
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
#include <usbwatcher.h>
|
|
20 |
|
|
21 |
#include "csetpersonality.h"
|
|
22 |
#include "cremotepersonalityhandler.h"
|
|
23 |
#include "debug.h"
|
|
24 |
|
|
25 |
// ---------------------------------------------------------------------------
|
|
26 |
// Two-phase construction
|
|
27 |
// ---------------------------------------------------------------------------
|
|
28 |
//
|
|
29 |
CSetPersonality* CSetPersonality::NewL(CRemotePersonalityHandler& aCallBack)
|
|
30 |
{
|
|
31 |
|
|
32 |
FLOG( _L( "[USBREMOTEPERSONALITY]\tCSetPersonality::NewL" ) );
|
|
33 |
|
|
34 |
CSetPersonality* self = new (ELeave) CSetPersonality(aCallBack);
|
|
35 |
CleanupStack::PushL(self);
|
|
36 |
self->ConstructL();
|
|
37 |
CleanupStack::Pop(self);
|
|
38 |
return self;
|
|
39 |
}
|
|
40 |
|
|
41 |
// ---------------------------------------------------------------------------
|
|
42 |
// Default construction
|
|
43 |
// ---------------------------------------------------------------------------
|
|
44 |
//
|
|
45 |
CSetPersonality::CSetPersonality(CRemotePersonalityHandler& aCallBack) :
|
|
46 |
CActive(EPriorityStandard),
|
|
47 |
iCallBack(aCallBack)
|
|
48 |
{
|
|
49 |
CActiveScheduler::Add(this);
|
|
50 |
}
|
|
51 |
|
|
52 |
// ---------------------------------------------------------------------------
|
|
53 |
// Two-phase construction
|
|
54 |
// ---------------------------------------------------------------------------
|
|
55 |
//
|
|
56 |
void CSetPersonality::ConstructL()
|
|
57 |
{
|
|
58 |
|
|
59 |
FLOG( _L( "[USBREMOTEPERSONALITY]\tCSetPersonality::ConstructL" ) );
|
|
60 |
|
|
61 |
}
|
|
62 |
|
|
63 |
// ---------------------------------------------------------------------------
|
|
64 |
// Destruction
|
|
65 |
// ---------------------------------------------------------------------------
|
|
66 |
//
|
|
67 |
CSetPersonality::~CSetPersonality()
|
|
68 |
{
|
|
69 |
|
|
70 |
FLOG( _L( "[USBREMOTEPERSONALITY]\tCSetPersonality::~CSetPersonality" ) );
|
|
71 |
Cancel();
|
|
72 |
|
|
73 |
}
|
|
74 |
|
|
75 |
// ---------------------------------------------------------------------------
|
|
76 |
// Sets Usb Watcher
|
|
77 |
// ---------------------------------------------------------------------------
|
|
78 |
//
|
|
79 |
void CSetPersonality::SetUsbWatcher(RUsbWatcher* aUsbWatcher)
|
|
80 |
{
|
|
81 |
iUsbWatcher = aUsbWatcher;
|
|
82 |
}
|
|
83 |
|
|
84 |
// ---------------------------------------------------------------------------
|
|
85 |
// Cancellation
|
|
86 |
// ---------------------------------------------------------------------------
|
|
87 |
//
|
|
88 |
void CSetPersonality::DoCancel()
|
|
89 |
{
|
|
90 |
iUsbWatcher->CancelSetPersonality();
|
|
91 |
}
|
|
92 |
|
|
93 |
// ----------------------------------------------------------------------------
|
|
94 |
// Standard active object error function.
|
|
95 |
// ----------------------------------------------------------------------------
|
|
96 |
//
|
|
97 |
TInt CSetPersonality::RunError( TInt /*aError*/ )
|
|
98 |
{
|
|
99 |
return KErrNone;
|
|
100 |
}
|
|
101 |
|
|
102 |
// ---------------------------------------------------------------------------
|
|
103 |
// Asynchronous request has been completed
|
|
104 |
// ---------------------------------------------------------------------------
|
|
105 |
//
|
|
106 |
void CSetPersonality::RunL()
|
|
107 |
{
|
|
108 |
|
|
109 |
FTRACE(FPrint(
|
|
110 |
_L("[USBREMOTEPERSONALITY]\tCSetPersonality::RunL iStatus.Int() = %d" ), iStatus.Int()));
|
|
111 |
|
|
112 |
CRemotePersonalityHandler::TLastResult result(CRemotePersonalityHandler::EUndefinedError);
|
|
113 |
|
|
114 |
// set result code according to the problem happened
|
|
115 |
switch(iStatus.Int())
|
|
116 |
{
|
|
117 |
case KErrNone:
|
|
118 |
{
|
|
119 |
result =CRemotePersonalityHandler::ESuccess;
|
|
120 |
break;
|
|
121 |
}
|
|
122 |
case KErrNotFound:
|
|
123 |
{
|
|
124 |
result = CRemotePersonalityHandler::ENonExistingPersonality;
|
|
125 |
break;
|
|
126 |
}
|
|
127 |
case KErrNotSupported:
|
|
128 |
{
|
|
129 |
result = CRemotePersonalityHandler::EFeatureIsNotSupported;
|
|
130 |
break;
|
|
131 |
}
|
|
132 |
case KErrCancel:
|
|
133 |
default:
|
|
134 |
{
|
|
135 |
result = CRemotePersonalityHandler::EUndefinedError;
|
|
136 |
}
|
|
137 |
}
|
|
138 |
iCallBack.SetPersonalityCallBack(result);
|
|
139 |
}
|
|
140 |
|
|
141 |
// ---------------------------------------------------------------------------
|
|
142 |
// Process SetPersonality request
|
|
143 |
// ---------------------------------------------------------------------------
|
|
144 |
//
|
|
145 |
void CSetPersonality::SetPersonality(TUint aPersonalityId)
|
|
146 |
{
|
|
147 |
|
|
148 |
FTRACE(FPrint(
|
|
149 |
_L("[USBREMOTEPERSONALITY]\tCSetPersonality::SetPersonality Personality Id = %d" ), aPersonalityId));
|
|
150 |
|
|
151 |
if(IsActive())
|
|
152 |
{
|
|
153 |
Cancel();
|
|
154 |
}
|
|
155 |
|
|
156 |
// No Ask-on-connection query, no confirmation for unload personality
|
|
157 |
iUsbWatcher->SetPersonality(iStatus, aPersonalityId, EFalse, ETrue);
|
|
158 |
SetActive();
|
|
159 |
|
|
160 |
}
|
|
161 |
|
|
162 |
|