|
1 /* |
|
2 * Copyright (c) 2010 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 * cache update notifications sent by the server using |
|
16 * Publish and Subscribe framework. |
|
17 * |
|
18 */ |
|
19 |
|
20 #include <CPsRequestHandler.h> |
|
21 #include "CPsUpdateHandler.h" |
|
22 |
|
23 |
|
24 // ----------------------------------------------------------------------------- |
|
25 // CPsUpdateHandler::CPsUpdateHandler |
|
26 // C++ constructor |
|
27 // ----------------------------------------------------------------------------- |
|
28 CPsUpdateHandler::CPsUpdateHandler( CPSRequestHandler& aRequestHandler, TInt aPsKey ) : |
|
29 CActive( EPriorityStandard ), |
|
30 iRequestHandler( aRequestHandler ), |
|
31 iPsKey( aPsKey ) |
|
32 { |
|
33 CActiveScheduler::Add( this ); |
|
34 } |
|
35 |
|
36 // ----------------------------------------------------------------------------- |
|
37 // CPsUpdateHandler::NewLC |
|
38 // Two-phased constructor |
|
39 // ----------------------------------------------------------------------------- |
|
40 CPsUpdateHandler* CPsUpdateHandler::NewLC( CPSRequestHandler& aRequestHandler, TInt aPsKey ) |
|
41 { |
|
42 CPsUpdateHandler* self = new (ELeave) CPsUpdateHandler( aRequestHandler, aPsKey ); |
|
43 CleanupStack::PushL( self ); |
|
44 self->ConstructL(); |
|
45 return self; |
|
46 } |
|
47 |
|
48 // ----------------------------------------------------------------------------- |
|
49 // CPsUpdateHandler::NewL |
|
50 // Two-phased constructor |
|
51 // ----------------------------------------------------------------------------- |
|
52 CPsUpdateHandler* CPsUpdateHandler::NewL( CPSRequestHandler& aRequestHandler, TInt aPsKey ) |
|
53 { |
|
54 CPsUpdateHandler* self = CPsUpdateHandler::NewLC( aRequestHandler, aPsKey ); |
|
55 CleanupStack::Pop( self ); |
|
56 return self; |
|
57 } |
|
58 |
|
59 // ----------------------------------------------------------------------------- |
|
60 // CPsUpdateHandler::ConstructL |
|
61 // Second phase constructor |
|
62 // ----------------------------------------------------------------------------- |
|
63 void CPsUpdateHandler::ConstructL() |
|
64 { |
|
65 TInt err = iProperty.Attach( KPcsInternalUidCacheStatus, iPsKey ); |
|
66 User::LeaveIfError(err); |
|
67 |
|
68 iProperty.Subscribe(iStatus); |
|
69 SetActive(); |
|
70 } |
|
71 |
|
72 // ----------------------------------------------------------------------------- |
|
73 // CPsUpdateHandler::~CPsUpdateHandler |
|
74 // Destructor |
|
75 // ----------------------------------------------------------------------------- |
|
76 CPsUpdateHandler::~CPsUpdateHandler() |
|
77 { |
|
78 Cancel(); |
|
79 iProperty.Close(); |
|
80 } |
|
81 |
|
82 // ----------------------------------------------------------------------------- |
|
83 // CPsUpdateHandler::DoCancel |
|
84 // Cancel subscription to the property |
|
85 // ----------------------------------------------------------------------------- |
|
86 void CPsUpdateHandler::DoCancel() |
|
87 { |
|
88 iProperty.Cancel(); |
|
89 } |
|
90 |
|
91 // ----------------------------------------------------------------------------- |
|
92 // CPsUpdateHandler::RunL |
|
93 // Handle change in the subscribed property |
|
94 // ----------------------------------------------------------------------------- |
|
95 void CPsUpdateHandler::RunL() |
|
96 { |
|
97 iProperty.Subscribe(iStatus); |
|
98 SetActive(); |
|
99 |
|
100 // Notify all observers about the update |
|
101 switch ( iPsKey ) |
|
102 { |
|
103 case EPsKeyContactRemovedCounter: |
|
104 iRequestHandler.NotifyCachingStatus( ECacheUpdateContactRemoved, 0 ); |
|
105 break; |
|
106 case EPsKeyContactModifiedCounter: |
|
107 iRequestHandler.NotifyCachingStatus( ECacheUpdateContactModified, 0 ); |
|
108 break; |
|
109 case EPsKeyContactAddedCounter: |
|
110 iRequestHandler.NotifyCachingStatus( ECacheUpdateContactAdded, 0 ); |
|
111 break; |
|
112 default: |
|
113 break; |
|
114 } |
|
115 } |
|
116 |
|
117 // end of file |