|
1 /* |
|
2 * Copyright (c) 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: Handler for System Agent events* |
|
15 */ |
|
16 |
|
17 |
|
18 // INCLUDE FILES |
|
19 #include <saclient.h> |
|
20 #include "CamSAEventActive.h" |
|
21 #include "CamAppController.h" |
|
22 |
|
23 // We need to use a large enough priority, so that |
|
24 // we get system agent events even when incoming call |
|
25 // occurs during recording. |
|
26 const TInt EPrioritySuperHigh = 2000; |
|
27 |
|
28 // ========================= MEMBER FUNCTIONS ================================ |
|
29 |
|
30 // --------------------------------------------------------- |
|
31 // CCamSAEventActive::CCamSAEventActive |
|
32 // C++ constructor |
|
33 // --------------------------------------------------------- |
|
34 // |
|
35 CCamSAEventActive::CCamSAEventActive( CCamAppController& aController, |
|
36 const RSystemAgent& aSystemAgent ) |
|
37 : CActive( EPrioritySuperHigh ), iController( aController ), |
|
38 iSystemAgent( aSystemAgent ) |
|
39 { |
|
40 iRequestIssued = EFalse; |
|
41 CActiveScheduler::Add( this ); |
|
42 } |
|
43 |
|
44 // --------------------------------------------------------- |
|
45 // Destructor |
|
46 // --------------------------------------------------------- |
|
47 // |
|
48 CCamSAEventActive::~CCamSAEventActive() |
|
49 { |
|
50 PRINT( _L("Camera => ~CCamSAEventActive") ); |
|
51 Cancel(); |
|
52 PRINT( _L("Camera <= ~CCamSAEventActive") ); |
|
53 } |
|
54 |
|
55 // --------------------------------------------------------- |
|
56 // CCamSAEventActive::IssueRequest |
|
57 // Issue a request to receive events from System Agent |
|
58 // --------------------------------------------------------- |
|
59 // |
|
60 void CCamSAEventActive::IssueRequest() |
|
61 { |
|
62 iSAEvent.SetRequestStatus( iStatus ); |
|
63 if ( !iRequestIssued ) |
|
64 { |
|
65 iRequestIssued = ETrue; |
|
66 iSystemAgent.NotifyOnAnyEvent( iSAEvent ); |
|
67 SetActive() ; |
|
68 } |
|
69 } |
|
70 |
|
71 // --------------------------------------------------------- |
|
72 // CCamSAEventActive::DoCancel |
|
73 // Cancel the request to receive events from System Agent |
|
74 // --------------------------------------------------------- |
|
75 // |
|
76 void CCamSAEventActive::DoCancel() |
|
77 { |
|
78 iSystemAgent.NotifyEventCancel(); |
|
79 iRequestIssued = EFalse; |
|
80 } |
|
81 |
|
82 // --------------------------------------------------------- |
|
83 // CCamSAEventActive::RunError |
|
84 // Called when RunL() is trapped by Active Scheduler |
|
85 // --------------------------------------------------------- |
|
86 // |
|
87 TInt CCamSAEventActive::RunError( TInt /*aError*/ ) |
|
88 { |
|
89 Cancel(); |
|
90 IssueRequest(); |
|
91 return KErrNone; |
|
92 } |
|
93 |
|
94 // --------------------------------------------------------- |
|
95 // Called when an event comes from System Agent |
|
96 // --------------------------------------------------------- |
|
97 // |
|
98 void CCamSAEventActive::RunL() |
|
99 { |
|
100 iRequestIssued = EFalse; |
|
101 iController.HandleSysAgentEventL( iSAEvent ); |
|
102 IssueRequest(); |
|
103 } |
|
104 |
|
105 // End of File |