|
1 /* |
|
2 * Copyright (c) 2004-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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "cidleguard.h" |
|
20 #include "rimageprintclient.h" |
|
21 #include "imageprint.h" |
|
22 #include "tidleguarddata.h" |
|
23 #include "clog.h" |
|
24 |
|
25 EXPORT_C CIdleGuard* CIdleGuard::NewL( RImagePrintClient& aClient ) |
|
26 { |
|
27 CIdleGuard* self = new ( ELeave ) CIdleGuard( aClient ); |
|
28 CleanupStack::PushL( self ); |
|
29 self->ConstructL(); |
|
30 CleanupStack::Pop(); // self |
|
31 return self; |
|
32 } |
|
33 |
|
34 CIdleGuard::CIdleGuard( RImagePrintClient& aClient ) : |
|
35 CActive( CActive::EPriorityStandard ), |
|
36 iClient( aClient ) |
|
37 { |
|
38 CActiveScheduler::Add( this ); |
|
39 } |
|
40 |
|
41 EXPORT_C CIdleGuard::~CIdleGuard() |
|
42 { |
|
43 Cancel(); |
|
44 delete iData; |
|
45 } |
|
46 |
|
47 void CIdleGuard::ConstructL() |
|
48 { |
|
49 iData = new (ELeave) TIdleGuardData; |
|
50 } |
|
51 |
|
52 EXPORT_C void CIdleGuard::Guard( MIdleObserver* aObserver ) |
|
53 { |
|
54 Cancel(); |
|
55 iObserver = aObserver; |
|
56 iClient.RegisterIdleObserver( *iData, iStatus ); |
|
57 SetActive(); |
|
58 } |
|
59 |
|
60 void CIdleGuard::RunL() |
|
61 { |
|
62 LOG1("CIdleGuard::RunL iStatus.Int(): %d", iStatus.Int()); |
|
63 LOG1("CIdleGuard::RunL iData->iEvent.iProtocol: %d", iData->iEvent.iProtocol); |
|
64 LOG1("CIdleGuard::RunL iData->iEvent.iSeverity: %d", iData->iEvent.iSeverity); |
|
65 LOG1("CIdleGuard::RunL iData->iEvent.iEventType: %d", iData->iEvent.iEventType); |
|
66 LOG1("CIdleGuard::RunL iData->iError: %d", iData->iError); |
|
67 LOG1("CIdleGuard::RunL iData->iMsgCode: %d", iData->iMsgCode); |
|
68 if( iStatus == KErrNone && iObserver ) |
|
69 { |
|
70 iObserver->StatusEvent( iData->iEvent, iData->iError, iData->iMsgCode ); |
|
71 iClient.RegisterIdleObserver( *iData, iStatus ); |
|
72 SetActive(); |
|
73 } |
|
74 } |
|
75 |
|
76 void CIdleGuard::DoCancel() |
|
77 { |
|
78 iClient.CancelRegisterIdleObserver(); |
|
79 } |
|
80 |
|
81 // End of File |