5
|
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 the License "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: Implements callback methods which is called my core dll call
|
|
15 |
* callback methods.
|
|
16 |
*
|
|
17 |
*/
|
|
18 |
|
|
19 |
#include <liwserviceifbase.h>
|
|
20 |
#include <LiwCommon.h>
|
|
21 |
#include <logwrap.h>
|
|
22 |
#include <LOGCLIENTCHANGEOBSERVER.H>
|
|
23 |
|
|
24 |
#include "logiter.h"
|
|
25 |
#include "logginginterface.h"
|
|
26 |
#include "loggingasyncservice.h"
|
|
27 |
#include "loggingcallback.h"
|
|
28 |
#include "loggingevent.h"
|
|
29 |
#include "liwlogiter.h"
|
|
30 |
|
|
31 |
|
|
32 |
/**
|
|
33 |
* OverLoaded constructor which accepts the callback adderss
|
|
34 |
* and registers it
|
|
35 |
*/
|
|
36 |
LoggingInterfaceCB :: LoggingInterfaceCB( MLiwNotifyCallback* aCallBack ) : iCallBack(aCallBack)
|
|
37 |
{
|
|
38 |
}
|
|
39 |
|
|
40 |
/**
|
|
41 |
* Default destructor
|
|
42 |
*/
|
|
43 |
LoggingInterfaceCB :: ~LoggingInterfaceCB()
|
|
44 |
{
|
|
45 |
//delete iOutParmList;
|
|
46 |
}
|
|
47 |
|
|
48 |
/**
|
|
49 |
* overloaded NewL function for creating local call back objects
|
|
50 |
* as required by logginginterface.cpp
|
|
51 |
*/
|
|
52 |
LoggingInterfaceCB *LoggingInterfaceCB :: NewL( MLiwNotifyCallback* aCallBack )
|
|
53 |
{
|
|
54 |
LoggingInterfaceCB *self = new( ELeave ) LoggingInterfaceCB( aCallBack ) ;
|
|
55 |
return self ;
|
|
56 |
}
|
|
57 |
|
|
58 |
/**
|
|
59 |
* HandleNotifyL method, callback method, called by the core class
|
|
60 |
* for async events
|
|
61 |
*/
|
|
62 |
|
|
63 |
void LoggingInterfaceCB :: HandleNotifyL( TUint aTransId, TUint aStatus, CLogIter *aIter )
|
|
64 |
{
|
|
65 |
CleanupStack :: PushL( this ) ;
|
|
66 |
|
|
67 |
CLiwGenericParamList *OutParm = CLiwGenericParamList :: NewL() ;
|
|
68 |
CleanupStack :: PushL(OutParm) ;
|
|
69 |
CLiwGenericParamList *InParm = CLiwGenericParamList :: NewL() ;
|
|
70 |
CleanupStack :: PushL(InParm) ;
|
|
71 |
|
|
72 |
TInt32 sapierror ;
|
|
73 |
|
|
74 |
sapierror = CLoggingInterface::ConvertToSapiError( aStatus );
|
|
75 |
|
|
76 |
OutParm->AppendL(TLiwGenericParam(KErrCode , TLiwVariant((TInt32)sapierror))) ;
|
|
77 |
|
|
78 |
switch( iRequestType )
|
|
79 |
{
|
|
80 |
case EReadEvents :
|
|
81 |
{
|
|
82 |
CLiwLogIter *iter = CLiwLogIter :: NewL( aIter ) ;
|
|
83 |
CleanupClosePushL( *iter );
|
|
84 |
OutParm->AppendL( TLiwGenericParam ( KResponse , TLiwVariant( iter ) ) ) ;
|
|
85 |
CleanupStack :: Pop( iter ) ;
|
|
86 |
iter->DecRef();
|
|
87 |
iCallBack->HandleNotifyL( aTransId, KLiwEventCompleted, *OutParm, *InParm ) ;
|
|
88 |
CleanupStack::PopAndDestroy( InParm );
|
|
89 |
CleanupStack::PopAndDestroy( OutParm );
|
|
90 |
CleanupStack :: Pop( this ) ;
|
|
91 |
delete this ;
|
|
92 |
break ;
|
|
93 |
}
|
|
94 |
|
|
95 |
case EGetEvent :
|
|
96 |
{
|
|
97 |
CLiwLogIter *iter = CLiwLogIter :: NewL( aIter ) ;
|
|
98 |
CleanupClosePushL( *iter );
|
|
99 |
OutParm->AppendL( TLiwGenericParam ( KResponse , TLiwVariant( iter ) ) ) ;
|
|
100 |
CleanupStack :: Pop( iter ) ;
|
|
101 |
iter->DecRef();
|
|
102 |
iCallBack->HandleNotifyL( aTransId, KLiwEventCompleted, *OutParm, *InParm ) ;
|
|
103 |
CleanupStack::PopAndDestroy( InParm );
|
|
104 |
CleanupStack::PopAndDestroy( OutParm );
|
|
105 |
CleanupStack :: Pop( this ) ;
|
|
106 |
delete this ;
|
|
107 |
break ;
|
|
108 |
}
|
|
109 |
|
|
110 |
case EGetRecent :
|
|
111 |
{
|
|
112 |
CLiwLogIter *iter = CLiwLogIter :: NewL( aIter ) ;
|
|
113 |
CleanupClosePushL( *iter );
|
|
114 |
OutParm->AppendL( TLiwGenericParam ( KResponse , TLiwVariant( iter ) ) ) ;
|
|
115 |
CleanupStack :: Pop( iter ) ;
|
|
116 |
iter->DecRef();
|
|
117 |
iCallBack->HandleNotifyL( aTransId, KLiwEventCompleted, *OutParm, *InParm ) ;
|
|
118 |
CleanupStack::PopAndDestroy( InParm );
|
|
119 |
CleanupStack::PopAndDestroy( OutParm );
|
|
120 |
CleanupStack :: Pop( this ) ;
|
|
121 |
delete this ;
|
|
122 |
break ;
|
|
123 |
}
|
|
124 |
|
|
125 |
case EAddEvent :
|
|
126 |
{
|
|
127 |
if( aStatus == KErrNone )
|
|
128 |
{
|
|
129 |
TLogId ret=(aIter->Event())->Id();
|
|
130 |
TBuf<8> des;
|
|
131 |
des.Num( ret );
|
|
132 |
OutParm->AppendL( TLiwGenericParam ( KResponse , TLiwVariant( des ) ) ) ;
|
|
133 |
iCallBack->HandleNotifyL( aTransId, KLiwEventCompleted, *OutParm, *InParm ) ;
|
|
134 |
}
|
|
135 |
else
|
|
136 |
{
|
|
137 |
iCallBack->HandleNotifyL( aTransId, KLiwEventError, *OutParm, *InParm ) ;
|
|
138 |
}
|
|
139 |
|
|
140 |
CleanupStack::PopAndDestroy( InParm );
|
|
141 |
CleanupStack::PopAndDestroy( OutParm );
|
|
142 |
CleanupStack :: Pop( this ) ;
|
|
143 |
delete this ;
|
|
144 |
delete aIter;
|
|
145 |
break ;
|
|
146 |
}
|
|
147 |
|
|
148 |
case ENotification :
|
|
149 |
{
|
|
150 |
iCallBack->HandleNotifyL( aTransId, KLiwEventInProgress, *OutParm, *InParm ) ;
|
|
151 |
CleanupStack::PopAndDestroy( InParm );
|
|
152 |
CleanupStack::PopAndDestroy( OutParm );
|
|
153 |
CleanupStack :: Pop( this ) ;
|
|
154 |
break ;
|
|
155 |
}
|
|
156 |
|
|
157 |
case EDeleteEvent :
|
|
158 |
{
|
|
159 |
if( aStatus == KErrNone )
|
|
160 |
{
|
|
161 |
iCallBack->HandleNotifyL( aTransId, KLiwEventCompleted, *OutParm, *InParm ) ;
|
|
162 |
}
|
|
163 |
else
|
|
164 |
{
|
|
165 |
iCallBack->HandleNotifyL( aTransId, KLiwEventError, *OutParm, *InParm ) ;
|
|
166 |
}
|
|
167 |
CleanupStack::PopAndDestroy( InParm );
|
|
168 |
CleanupStack::PopAndDestroy( OutParm );
|
|
169 |
CleanupStack :: Pop( this ) ;
|
|
170 |
delete this;
|
|
171 |
break ;
|
|
172 |
}
|
|
173 |
|
|
174 |
default :
|
|
175 |
{
|
|
176 |
break ;
|
|
177 |
}
|
|
178 |
}
|
|
179 |
}
|
|
180 |
|
|
181 |
void LoggingInterfaceCB :: CancelNotifyL( TUint aTransid )
|
|
182 |
{
|
|
183 |
CleanupStack :: PushL( this ) ;
|
|
184 |
CLiwGenericParamList *OutParm = CLiwGenericParamList :: NewL() ;
|
|
185 |
CleanupStack :: PushL( OutParm ) ;
|
|
186 |
CLiwGenericParamList *InParm = CLiwGenericParamList :: NewL() ;
|
|
187 |
CleanupStack :: PushL( InParm ) ;
|
|
188 |
OutParm->AppendL( TLiwGenericParam( KErrCode , TLiwVariant( ( TInt32 )SErrNone ) ) ) ;
|
|
189 |
iCallBack->HandleNotifyL( aTransid, KLiwEventCanceled, *OutParm, *InParm ) ;
|
|
190 |
CleanupStack::PopAndDestroy( InParm );
|
|
191 |
CleanupStack::PopAndDestroy( OutParm );
|
|
192 |
CleanupStack :: Pop( this ) ;
|
|
193 |
delete this;
|
|
194 |
}
|