|
1 /* |
|
2 * Copyright (c) 2006-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: CCallStateSourcePlugIn class implementation. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <cfcontextobject.h> |
|
20 #include <cfcontextinterface.h> |
|
21 |
|
22 #include <ctsydomainpskeys.h> |
|
23 |
|
24 #include "CallStateSourcePlugIn.h" |
|
25 #include "CallStateSourceContextDef.h" |
|
26 #include "PropertyListener.h" |
|
27 |
|
28 |
|
29 // CONSTANTS |
|
30 #ifdef _DEBUG |
|
31 // Panic category |
|
32 _LIT( KPanicCat, "CallStatSrc" ); |
|
33 |
|
34 // Panic codes |
|
35 enum TPanicReason |
|
36 { |
|
37 EPlugInNotInitialized |
|
38 }; |
|
39 |
|
40 // Panic function |
|
41 LOCAL_C void Panic( TInt aCode ) |
|
42 { |
|
43 User::Panic( KPanicCat, aCode ); |
|
44 } |
|
45 #endif |
|
46 |
|
47 CCallStateSourcePlugIn* CCallStateSourcePlugIn::NewL( |
|
48 TContextSourceInitParams* aParams ) |
|
49 { |
|
50 CCallStateSourcePlugIn* self = CCallStateSourcePlugIn::NewLC( aParams ); |
|
51 CleanupStack::Pop( self ); |
|
52 |
|
53 return self; |
|
54 } |
|
55 |
|
56 CCallStateSourcePlugIn* CCallStateSourcePlugIn::NewLC( |
|
57 TContextSourceInitParams* aParams ) |
|
58 { |
|
59 CCallStateSourcePlugIn* self = |
|
60 new( ELeave ) CCallStateSourcePlugIn( aParams ); |
|
61 CleanupStack::PushL( self ); |
|
62 |
|
63 return self; |
|
64 } |
|
65 |
|
66 // Destructor |
|
67 CCallStateSourcePlugIn::~CCallStateSourcePlugIn() |
|
68 { |
|
69 delete iCallStateProperty; |
|
70 delete iContext; |
|
71 } |
|
72 |
|
73 CCallStateSourcePlugIn::CCallStateSourcePlugIn( |
|
74 TContextSourceInitParams* aParams ): |
|
75 CCFContextSourcePlugIn( aParams ) |
|
76 { |
|
77 } |
|
78 |
|
79 // METHODS |
|
80 |
|
81 //----------------------------------------------------------------------------- |
|
82 // CCallStateSourcePlugIn::HandleSettingL |
|
83 //----------------------------------------------------------------------------- |
|
84 // |
|
85 void CCallStateSourcePlugIn::HandleSettingL( |
|
86 CCFContextSourceSettingArray* /*aSettingList*/ ) |
|
87 { |
|
88 // Not called since we don't have settings |
|
89 } |
|
90 |
|
91 //----------------------------------------------------------------------------- |
|
92 // CCallStateSourcePlugIn::DefineContextsL |
|
93 //----------------------------------------------------------------------------- |
|
94 // |
|
95 void CCallStateSourcePlugIn::DefineContextsL() |
|
96 { |
|
97 iCF.DefineContext( KCallStateSource, KCallStateType, KCallStateTypeSec ); |
|
98 } |
|
99 |
|
100 //----------------------------------------------------------------------------- |
|
101 // CCallStateSourcePlugIn::DefineContextsL |
|
102 //----------------------------------------------------------------------------- |
|
103 // |
|
104 void CCallStateSourcePlugIn::InitializeL() |
|
105 { |
|
106 // Initialize context |
|
107 iContext = CCFContextObject::NewL(); |
|
108 |
|
109 // Initialize call state property listener |
|
110 iCallStateProperty = CPropertyListener::NewL( |
|
111 KPSUidCtsyCallInformation, |
|
112 KCTsyCallState, |
|
113 *this ); |
|
114 |
|
115 iContext->SetSourceL( KCallStateSource ); |
|
116 iContext->SetTypeL( KCallStateType ); |
|
117 |
|
118 // Publish current context value |
|
119 PublishContextL(); |
|
120 } |
|
121 |
|
122 //----------------------------------------------------------------------------- |
|
123 // CCallStateSourcePlugIn::HandlePropertyChangedL |
|
124 //----------------------------------------------------------------------------- |
|
125 // |
|
126 void CCallStateSourcePlugIn::HandlePropertyChangedL() |
|
127 { |
|
128 // Publish current context value |
|
129 PublishContextL(); |
|
130 } |
|
131 |
|
132 //----------------------------------------------------------------------------- |
|
133 // CCallStateSourcePlugIn::PublishContextL |
|
134 //----------------------------------------------------------------------------- |
|
135 // |
|
136 void CCallStateSourcePlugIn::PublishContextL() |
|
137 { |
|
138 __ASSERT_DEBUG( iCallStateProperty, Panic( EPlugInNotInitialized ) ); |
|
139 |
|
140 // Get current call state value |
|
141 TInt value = 0; |
|
142 TInt err = iCallStateProperty->Property().Get( value ); |
|
143 if( err == KErrNone ) |
|
144 { |
|
145 if( value >= 0 && value < KCallStateTypeValueCount ) |
|
146 { |
|
147 // Publish context, ignore error values |
|
148 RThread thread; |
|
149 iContext->SetValueL( TPtrC( KCallStateTypeValues[value] ) ); |
|
150 iCF.PublishContext( *iContext, thread ); |
|
151 thread.Close(); |
|
152 } |
|
153 } |
|
154 } |