|
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: This is the client side internal file to handle |
|
15 * property used in Publish and Subscribe framework. |
|
16 * |
|
17 */ |
|
18 |
|
19 //SYSTEM INCLUDES |
|
20 #include <CPsRequestHandler.h> |
|
21 #include <MPsResultsObserver.h> |
|
22 |
|
23 // USER INCLUDES |
|
24 #include "CPsPropertyHandler.h" |
|
25 #include "CPcsDebug.h" |
|
26 |
|
27 |
|
28 // ========================= MEMBER FUNCTIONS ================================== |
|
29 |
|
30 // ----------------------------------------------------------------------------- |
|
31 // CPsPropertyHandler::NewL() |
|
32 // Two-phased constructor. |
|
33 // ----------------------------------------------------------------------------- |
|
34 CPsPropertyHandler* CPsPropertyHandler::NewL( CPSRequestHandler* aRequestHandler ) |
|
35 { |
|
36 PRINT ( _L("Enter CPsPropertyHandler::NewL") ); |
|
37 |
|
38 CPsPropertyHandler* self = new ( ELeave ) CPsPropertyHandler(aRequestHandler); |
|
39 CleanupStack::PushL( self ); |
|
40 self->ConstructL(); |
|
41 CleanupStack::Pop( self ); |
|
42 |
|
43 PRINT ( _L("End CPsPropertyHandler::NewL") ); |
|
44 |
|
45 return( self ) ; |
|
46 } |
|
47 |
|
48 // ----------------------------------------------------------------------------- |
|
49 // CPsPropertyHandler::ConstructL() |
|
50 // Symbian 2nd phase constructor can leave. |
|
51 // ----------------------------------------------------------------------------- |
|
52 void CPsPropertyHandler::ConstructL() |
|
53 { |
|
54 PRINT ( _L("Enter CPsPropertyHandler::ConstructL") ); |
|
55 |
|
56 TInt err = iCacheStatusProperty.Attach( KPcsInternalUidCacheStatus, EPsKeyCacheStatus ); |
|
57 User::LeaveIfError(err); |
|
58 |
|
59 // Attach the cache error property |
|
60 err = iCacheErrorProperty.Attach( KPcsInternalUidCacheStatus, EPsKeyCacheError ); |
|
61 User::LeaveIfError(err); |
|
62 |
|
63 iCacheStatusProperty.Subscribe(iStatus); |
|
64 |
|
65 SetActive(); |
|
66 |
|
67 PRINT ( _L("End CPsPropertyHandler::ConstructL") ); |
|
68 } |
|
69 |
|
70 // ----------------------------------------------------------------------------- |
|
71 // CPsPropertyHandler::CPsPropertyHandler() |
|
72 // C++ default constructor can NOT contain any code, that might leave. |
|
73 // ----------------------------------------------------------------------------- |
|
74 CPsPropertyHandler::CPsPropertyHandler( CPSRequestHandler* aRequestHandler ) |
|
75 : CActive( EPriorityStandard ), |
|
76 iRequestHandler(aRequestHandler) |
|
77 { |
|
78 PRINT ( _L("Enter CPsPropertyHandler::CPsPropertyHandler") ); |
|
79 |
|
80 CActiveScheduler::Add( this ); |
|
81 |
|
82 PRINT ( _L("End CPsPropertyHandler::CPsPropertyHandler") ); |
|
83 } |
|
84 |
|
85 // ----------------------------------------------------------------------------- |
|
86 // CPsPropertyHandler::~CPsPropertyHandler() |
|
87 // Destructor. |
|
88 // ----------------------------------------------------------------------------- |
|
89 CPsPropertyHandler::~CPsPropertyHandler() |
|
90 { |
|
91 PRINT ( _L("Enter CPsPropertyHandler::~CPsPropertyHandler") ); |
|
92 |
|
93 Cancel(); // Causes call to DoCancel() |
|
94 |
|
95 iCacheStatusProperty.Close(); |
|
96 iCacheErrorProperty.Close(); |
|
97 } |
|
98 |
|
99 // ----------------------------------------------------------------------------- |
|
100 // CPsPropertyHandler::RunL() |
|
101 // Invoked to handle responses from the server. |
|
102 // ----------------------------------------------------------------------------- |
|
103 void CPsPropertyHandler::RunL() |
|
104 { |
|
105 iCacheStatusProperty.Subscribe(iStatus); |
|
106 SetActive(); |
|
107 |
|
108 //Get the value |
|
109 TCachingStatus status; |
|
110 TInt statusValue; |
|
111 iCacheStatusProperty.Get(statusValue); |
|
112 status = (TCachingStatus)statusValue; |
|
113 |
|
114 TInt cacheError; |
|
115 iCacheErrorProperty.Get(cacheError); |
|
116 |
|
117 if ( (status == ECachingComplete) || (status == ECachingCompleteWithErrors) ) |
|
118 { |
|
119 iRequestHandler->NotifyCachingStatus( status, cacheError ); |
|
120 } |
|
121 } |
|
122 |
|
123 // ----------------------------------------------------------------------------- |
|
124 // CPsPropertyHandler::DoCancel() |
|
125 // Cancels any outstanding operation. |
|
126 // ----------------------------------------------------------------------------- |
|
127 void CPsPropertyHandler::DoCancel() |
|
128 { |
|
129 iCacheStatusProperty.Cancel(); |
|
130 } |
|
131 |
|
132 // ----------------------------------------------------------------------------- |
|
133 // CPsPropertyHandler::GetCachingStatusL() |
|
134 // Returns the caching status fr synchronous request |
|
135 // ----------------------------------------------------------------------------- |
|
136 TInt CPsPropertyHandler::GetCachingStatusL(TCachingStatus& aStatus) |
|
137 { |
|
138 TInt status; |
|
139 //Get the status from the property |
|
140 iCacheStatusProperty.Get(status); |
|
141 |
|
142 aStatus = (TCachingStatus)status; |
|
143 |
|
144 TInt cacheError; |
|
145 iCacheErrorProperty.Get(cacheError); |
|
146 |
|
147 return cacheError; |
|
148 } |
|
149 |
|
150 //END OF FILE |