1 /* |
|
2 * Copyright (c) 2006 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: Active object for subscribing to Publish & Suscribe properties |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <e32svr.h> |
|
21 #include "appcontrollerpropertyhandler.h" |
|
22 #include "appcontroller.h" |
|
23 |
|
24 // --------------------------------------------------------- |
|
25 // CAppControllerPropertyHandler::NewL |
|
26 // Symbian OS two-phased constructor |
|
27 // --------------------------------------------------------- |
|
28 // |
|
29 CAppControllerPropertyHandler* CAppControllerPropertyHandler::NewL( |
|
30 TUid aCategory, TUint aKey, CVCApplicationControllerImpl* aController) |
|
31 { |
|
32 CAppControllerPropertyHandler* self = new ( ELeave ) CAppControllerPropertyHandler( aController ); |
|
33 CleanupStack::PushL( self ); |
|
34 self->ConstructL( aCategory, aKey ); |
|
35 CleanupStack::Pop( self ); |
|
36 return self; |
|
37 } |
|
38 |
|
39 |
|
40 // --------------------------------------------------------- |
|
41 // CAppControllerPropertyHandler::CAppControllerPropertyHandler |
|
42 // C++ constructor |
|
43 // --------------------------------------------------------- |
|
44 // |
|
45 CAppControllerPropertyHandler::CAppControllerPropertyHandler( CVCApplicationControllerImpl* aController ) |
|
46 : CActive( EPriorityStandard ), |
|
47 iController( aController ) |
|
48 { |
|
49 } |
|
50 |
|
51 // --------------------------------------------------------- |
|
52 // CAppControllerPropertyHandler::ConstructL |
|
53 // Symbian OS 2nd phase constructor |
|
54 // --------------------------------------------------------- |
|
55 // |
|
56 void CAppControllerPropertyHandler::ConstructL(TUid aCategory, TUint aKey ) |
|
57 { |
|
58 User::LeaveIfError( iProperty.Attach( aCategory, aKey ) ); |
|
59 |
|
60 CActiveScheduler::Add(this); |
|
61 // Initial subscription and process current property value |
|
62 RunL(); |
|
63 |
|
64 iRequestIssued = ETrue; |
|
65 } |
|
66 |
|
67 // Destructor |
|
68 CAppControllerPropertyHandler::~CAppControllerPropertyHandler() |
|
69 { |
|
70 Cancel(); |
|
71 iProperty.Close(); |
|
72 } |
|
73 |
|
74 |
|
75 // --------------------------------------------------------- |
|
76 // CAppControllerPropertyHandler::DoCancel |
|
77 // Cancel the request to receive events |
|
78 // --------------------------------------------------------- |
|
79 // |
|
80 void CAppControllerPropertyHandler::DoCancel() |
|
81 { |
|
82 iProperty.Cancel(); |
|
83 } |
|
84 |
|
85 |
|
86 // --------------------------------------------------------- |
|
87 // CAppControllerPropertyHandler::RunL |
|
88 // Handle a change event. |
|
89 // --------------------------------------------------------- |
|
90 // |
|
91 void CAppControllerPropertyHandler::RunL() |
|
92 { |
|
93 // Resubscribe before processing new value to prevent missing updates |
|
94 iProperty.Subscribe( iStatus ); |
|
95 SetActive(); |
|
96 |
|
97 if ( iRequestIssued ) |
|
98 { |
|
99 iController->HandleCurrentCallStatusChange(); |
|
100 } |
|
101 } |
|
102 |
|
103 |
|
104 // --------------------------------------------------------- |
|
105 // CAppControllerPropertyHandler::Value |
|
106 // Get current property value |
|
107 // --------------------------------------------------------- |
|
108 // |
|
109 TInt CAppControllerPropertyHandler::Value() |
|
110 { |
|
111 TInt value = 0; |
|
112 iProperty.Get( value ); |
|
113 return value; |
|
114 } |
|
115 |
|
116 |
|
117 // End of File |
|