28
|
1 |
/*
|
|
2 |
* Copyright (c) 2006-2007 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: cch client api implementation
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
#include "cchserviceimplasynchroniser.h"
|
|
20 |
#include "cchlogger.h"
|
|
21 |
|
|
22 |
CCchServiceImplAsynchroniser::CCchServiceImplAsynchroniser(CCchImpl& aCch, TInt aServiceId, CCchUiPrivateApi& aCchUi) :
|
|
23 |
CActive(EPriorityStandard),// Standard priority
|
|
24 |
iCch( aCch ),
|
|
25 |
iServiceId( aServiceId ),
|
|
26 |
iCchUi( aCchUi ),
|
|
27 |
iState ( EIdle )
|
|
28 |
|
|
29 |
{
|
|
30 |
}
|
|
31 |
|
|
32 |
CCchServiceImplAsynchroniser* CCchServiceImplAsynchroniser::NewLC(CCchImpl& aCch, TInt aServiceId, CCchUiPrivateApi& aCchUi)
|
|
33 |
{
|
|
34 |
CCchServiceImplAsynchroniser* self =
|
|
35 |
new (ELeave) CCchServiceImplAsynchroniser(aCch, aServiceId, aCchUi );
|
|
36 |
CleanupStack::PushL(self);
|
|
37 |
self->ConstructL();
|
|
38 |
return self;
|
|
39 |
}
|
|
40 |
|
|
41 |
CCchServiceImplAsynchroniser* CCchServiceImplAsynchroniser::NewL(CCchImpl& aCch, TInt aServiceId, CCchUiPrivateApi& aCchUi)
|
|
42 |
{
|
|
43 |
CCchServiceImplAsynchroniser* self =
|
|
44 |
CCchServiceImplAsynchroniser::NewLC(aCch, aServiceId, aCchUi );
|
|
45 |
CleanupStack::Pop(); // self;
|
|
46 |
return self;
|
|
47 |
}
|
|
48 |
|
|
49 |
void CCchServiceImplAsynchroniser::Enable( TCCHSubserviceType aType )
|
|
50 |
{
|
|
51 |
CCHLOGSTRING( "CCchServiceImplAsynchroniser::Enable IN" );
|
|
52 |
if (iState == EIdle)
|
|
53 |
{
|
|
54 |
iState = EEnabling;
|
|
55 |
TServiceSelection selection( iServiceId, aType );
|
|
56 |
SetActive();
|
|
57 |
iCch.CchClient().EnableService( selection, iStatus, EFalse );
|
|
58 |
}
|
|
59 |
else
|
|
60 |
{
|
|
61 |
CCHLOGSTRING( "CCchServiceImplAsynchroniser already active" );
|
|
62 |
}
|
|
63 |
CCHLOGSTRING( "CCchServiceImplAsynchroniser::Enable OUT" );
|
|
64 |
}
|
|
65 |
|
|
66 |
void CCchServiceImplAsynchroniser::Disable( TCCHSubserviceType aType )
|
|
67 |
{
|
|
68 |
CCHLOGSTRING( "CCchServiceImplAsynchroniser::Disable IN" );
|
|
69 |
if (iState != EIdle)
|
|
70 |
{
|
|
71 |
Cancel();
|
|
72 |
}
|
|
73 |
iState = EDisabling;
|
|
74 |
TRequestStatus status = KErrNone;
|
|
75 |
TServiceSelection selection( iServiceId, aType );
|
|
76 |
SetActive();
|
|
77 |
iCch.CchClient().DisableService( selection, iStatus );
|
|
78 |
|
|
79 |
CCHLOGSTRING( "CCchServiceImplAsynchroniser::Disable OUT" );
|
|
80 |
}
|
|
81 |
|
|
82 |
|
|
83 |
void CCchServiceImplAsynchroniser::ConstructL()
|
|
84 |
{
|
|
85 |
CActiveScheduler::Add(this); // Add to scheduler
|
|
86 |
}
|
|
87 |
|
|
88 |
CCchServiceImplAsynchroniser::~CCchServiceImplAsynchroniser()
|
|
89 |
{
|
|
90 |
Cancel(); // Cancel any request, if outstanding
|
|
91 |
// Delete instance variables if any
|
|
92 |
}
|
|
93 |
|
|
94 |
void CCchServiceImplAsynchroniser::DoCancel()
|
|
95 |
{
|
|
96 |
if ( EEnabling == iState )
|
|
97 |
{
|
|
98 |
iCch.CchClient().EnableServiceCancel();
|
|
99 |
}
|
|
100 |
else if ( EDisabling == iState )
|
|
101 |
{
|
|
102 |
iCch.CchClient().DisableServiceCancel();
|
|
103 |
}
|
|
104 |
}
|
|
105 |
|
|
106 |
void CCchServiceImplAsynchroniser::RunL()
|
|
107 |
{
|
|
108 |
CCHLOGSTRING( "CCchServiceImplAsynchroniser::RunL IN" );
|
|
109 |
if (iStatus.Int() != KErrCancel)
|
|
110 |
{
|
|
111 |
switch (iState)
|
|
112 |
{
|
|
113 |
case EEnabling:
|
|
114 |
{
|
|
115 |
if ( iCch.ConnectivityDialogsAllowed() )
|
|
116 |
{
|
|
117 |
iCchUi.ManualEnableResultL( iServiceId, iStatus.Int() );
|
|
118 |
}
|
|
119 |
CCHLOGSTRING( "CCchServiceImplAsynchroniser::RunL EEnabling done" );
|
|
120 |
iState = EIdle;
|
|
121 |
break;
|
|
122 |
}
|
|
123 |
case EDisabling:
|
|
124 |
{
|
|
125 |
CCHLOGSTRING( "CCchServiceImplAsynchroniser::RunL EDisabling done" );
|
|
126 |
iState = EIdle;
|
|
127 |
break;
|
|
128 |
}
|
|
129 |
default:
|
|
130 |
{
|
|
131 |
break;
|
|
132 |
}
|
|
133 |
|
|
134 |
}
|
|
135 |
}
|
|
136 |
iState = EIdle;
|
|
137 |
CCHLOGSTRING( "CCchServiceImplAsynchroniser::RunL OUT" );
|
|
138 |
}
|
|
139 |
|
|
140 |
TInt CCchServiceImplAsynchroniser::RunError(TInt aError)
|
|
141 |
{
|
|
142 |
return aError;
|
|
143 |
}
|