|
1 // Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #include "LogClientObserver.h" |
|
17 |
|
18 // System includes |
|
19 #include <s32mem.h> |
|
20 |
|
21 // User includes |
|
22 #include <logwrap.h> |
|
23 #include <logcli.h> |
|
24 #include "logservcli.h" |
|
25 #include <logclientchangeobserver.h> |
|
26 |
|
27 ///////////////////////////////////////////////////////////////////////////////////////// |
|
28 // -----> CLogClientObserver (source) |
|
29 ///////////////////////////////////////////////////////////////////////////////////////// |
|
30 |
|
31 CLogClientObserver::CLogClientObserver(CLogClient& aClient, MLogClientChangeObserver& aObserver, TInt aPriority) |
|
32 : CActive(aPriority), iClient(aClient), iObserver(aObserver) |
|
33 { |
|
34 CActiveScheduler::Add(this); |
|
35 } |
|
36 |
|
37 CLogClientObserver::~CLogClientObserver() |
|
38 { |
|
39 Cancel(); |
|
40 } |
|
41 |
|
42 CLogClientObserver* CLogClientObserver::NewL(CLogClient& aClient, MLogClientChangeObserver& aObserver, TInt aPriority) |
|
43 { |
|
44 CLogClientObserver* self = new(ELeave) CLogClientObserver(aClient, aObserver, aPriority); |
|
45 self->RequestChanges(); |
|
46 return self; |
|
47 } |
|
48 |
|
49 ///////////////////////////////////////////////////////////////////////////////////////// |
|
50 ///////////////////////////////////////////////////////////////////////////////////////// |
|
51 ///////////////////////////////////////////////////////////////////////////////////////// |
|
52 |
|
53 void CLogClientObserver::RunL() |
|
54 { |
|
55 if (iStatus.Int() == KErrNone) |
|
56 NotifyObserverL(); |
|
57 RequestChanges(); |
|
58 } |
|
59 |
|
60 void CLogClientObserver::DoCancel() |
|
61 { |
|
62 RequestChangesCancel(); |
|
63 } |
|
64 |
|
65 TInt CLogClientObserver::RunError(TInt /*aError*/) |
|
66 { |
|
67 // Ignore any leave when notifying the client |
|
68 return KErrNone; |
|
69 } |
|
70 |
|
71 ///////////////////////////////////////////////////////////////////////////////////////// |
|
72 ///////////////////////////////////////////////////////////////////////////////////////// |
|
73 ///////////////////////////////////////////////////////////////////////////////////////// |
|
74 |
|
75 void CLogClientObserver::RequestChanges() |
|
76 { |
|
77 __ASSERT_DEBUG(!IsActive(), User::Invariant()); |
|
78 iClient.Session().Send(ELogNotifyExtended, TIpcArgs(&iContextBuf,&iParamBuf1,&iParamBuf2,&iParamBuf3), iStatus); |
|
79 SetActive(); |
|
80 } |
|
81 |
|
82 void CLogClientObserver::RequestChangesCancel() |
|
83 { |
|
84 iClient.Session().Send(ELogNotifyExtendedCancel, TIpcArgs()); |
|
85 } |
|
86 |
|
87 void CLogClientObserver::NotifyObserverL() |
|
88 { |
|
89 const TUid contextUid = { iContextBuf() }; |
|
90 const TInt param1 = iParamBuf1(); |
|
91 const TInt param2 = iParamBuf2(); |
|
92 const TInt param3 = iParamBuf3(); |
|
93 // |
|
94 iObserver.HandleLogClientChangeEventL(contextUid, param1, param2, param3); |
|
95 } |