|
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: Subscribe source implementation for getting calendar status |
|
15 * notification from publisher . |
|
16 * |
|
17 */ |
|
18 #include "calendarsubscriber.h" |
|
19 #include <locationservicedefines.h> |
|
20 #include "mylocationlogger.h" |
|
21 const TUid KCalendarPropertyCat={0x10005901}; |
|
22 enum TMyPropertyKeys {EMyPropertyInteger=0x1}; |
|
23 |
|
24 // ----------------------------------------------------------------------------- |
|
25 // CCalendarSubscriber::NewL() |
|
26 // ----------------------------------------------------------------------------- |
|
27 // |
|
28 CCalendarSubscriber* CCalendarSubscriber::NewL(MNotifyChange* aNotifyChange) |
|
29 { |
|
30 CCalendarSubscriber* self = CCalendarSubscriber::NewLC(aNotifyChange); |
|
31 CleanupStack::Pop(self); |
|
32 return self; |
|
33 } |
|
34 |
|
35 // ----------------------------------------------------------------------------- |
|
36 // CCalendarSubscriber::NewLC() |
|
37 // ----------------------------------------------------------------------------- |
|
38 // |
|
39 CCalendarSubscriber* CCalendarSubscriber::NewLC( |
|
40 MNotifyChange* aNotifyChange) |
|
41 { |
|
42 CCalendarSubscriber* self = new (ELeave) CCalendarSubscriber( |
|
43 aNotifyChange); |
|
44 CleanupStack::PushL(self); |
|
45 self->ConstructL(); |
|
46 return self; |
|
47 } |
|
48 |
|
49 // ----------------------------------------------------------------------------- |
|
50 // CCalendarSubscriber::ConstructL() |
|
51 // Symbian 2nd phase constructor can leave. |
|
52 // ----------------------------------------------------------------------------- |
|
53 // |
|
54 void CCalendarSubscriber::ConstructL() |
|
55 { |
|
56 __TRACE_CALLSTACK; |
|
57 CActiveScheduler::Add(this); |
|
58 TInt ret = iProperty.Attach(KCalendarPropertyCat, EMyPropertyInteger); |
|
59 |
|
60 if (KErrNone == ret) |
|
61 { |
|
62 SubscribeChangeNotiFication(); |
|
63 |
|
64 } |
|
65 } |
|
66 |
|
67 |
|
68 // ----------------------------------------------------------------------------- |
|
69 // CCalendarSubscriber::SubscribeChangeNotiFication() |
|
70 // start subscribe for calendar entry |
|
71 // ----------------------------------------------------------------------------- |
|
72 // |
|
73 void CCalendarSubscriber::SubscribeChangeNotiFication() |
|
74 { |
|
75 __TRACE_CALLSTACK; |
|
76 Cancel(); |
|
77 // resubscribe before processing new value to prevent missing updates |
|
78 iProperty.Subscribe(iStatus); |
|
79 SetActive(); |
|
80 } |
|
81 |
|
82 // ----------------------------------------------------------------------------- |
|
83 // CCalendarSubscriber::CCalendarSubscriber() |
|
84 // Default constructor . |
|
85 // ----------------------------------------------------------------------------- |
|
86 // |
|
87 CCalendarSubscriber::CCalendarSubscriber(MNotifyChange* aNotifyChange) : |
|
88 CActive(EPriorityStandard), |
|
89 iNotifyChange(*aNotifyChange) |
|
90 |
|
91 { |
|
92 } |
|
93 // ----------------------------------------------------------------------------- |
|
94 // CCalendarSubscriber::~CCalendarSubscriber() |
|
95 // default destuctor. |
|
96 // ----------------------------------------------------------------------------- |
|
97 // |
|
98 CCalendarSubscriber::~CCalendarSubscriber() |
|
99 { |
|
100 __TRACE_CALLSTACK; |
|
101 Cancel(); |
|
102 iProperty.Close(); |
|
103 |
|
104 } |
|
105 // ----------------------------------------------------------------------------- |
|
106 // CCalendarSubscriber::RunL() |
|
107 // Assyncronous request handler , on completion of notification |
|
108 // ----------------------------------------------------------------------------- |
|
109 // |
|
110 void CCalendarSubscriber::RunL() |
|
111 { |
|
112 __TRACE_CALLSTACK; |
|
113 SubscribeChangeNotiFication(); |
|
114 // property updated, get new value |
|
115 TInt value; |
|
116 if ( KErrNone == iProperty.Get( value ) && value > 0) |
|
117 { |
|
118 iNotifyChange.SubscribeFromCalendarL( value ); |
|
119 } |
|
120 } |
|
121 // ----------------------------------------------------------------------------- |
|
122 // CCalendarSubscriber::DoCancel() |
|
123 // Handels the error condition on assynchronous request |
|
124 // ----------------------------------------------------------------------------- |
|
125 // |
|
126 void CCalendarSubscriber::DoCancel() |
|
127 { |
|
128 __TRACE_CALLSTACK; |
|
129 iProperty.Cancel(); |
|
130 } |
|
131 |
|
132 //End of file |
|
133 |