1 /* |
|
2 * Copyright (c) 2009 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 class subscribes and listens to the rproperty |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <e32property.h> |
|
21 #include "imstatuspaneindicator.h" |
|
22 |
|
23 |
|
24 // ======== MEMBER FUNCTIONS ======== |
|
25 |
|
26 // --------------------------------------------------------------------------- |
|
27 // CIMStatusPaneIndicator::CIMStatusPaneIndicator |
|
28 // C++ default constructor can NOT contain any code, that |
|
29 // might leave. |
|
30 // --------------------------------------------------------------------------- |
|
31 // |
|
32 CIMStatusPaneIndicator::CIMStatusPaneIndicator() |
|
33 :CActive(CActive::EPriorityStandard ) |
|
34 { |
|
35 } |
|
36 |
|
37 // --------------------------------------------------------------------------- |
|
38 // CIMStatusPaneIndicator::ConstructL |
|
39 // Symbian 2nd phase constructor can leave. |
|
40 // --------------------------------------------------------------------------- |
|
41 // |
|
42 void CIMStatusPaneIndicator::ConstructL() |
|
43 { |
|
44 iSenderId = HBufC::NewL(KMAXLENGTH); |
|
45 // attach the properties. |
|
46 User::LeaveIfError( iProperty.Attach(KIMStatusProperty,EIMStatusPropertyMessageCount ) ); |
|
47 User::LeaveIfError( iProperty.Attach(KIMStatusProperty,EIMStatusPropertyServiceId ) ); |
|
48 User::LeaveIfError( iProperty.Attach(KIMStatusProperty,EIMMultipleSender ) ); |
|
49 User::LeaveIfError( iProperty.Attach(KIMStatusProperty,EIMStatusPropertySenderId ) ); |
|
50 //User::LeaveIfError( iProperty.Attach(KIMStatusProperty,EIMStatusPropertyMessageCount ) ); |
|
51 CActiveScheduler::Add(this); |
|
52 // initial subscription and process current property value |
|
53 RunL(); |
|
54 } |
|
55 |
|
56 // ----------------------------------------------------------------------------- |
|
57 // CIMStatusPaneIndicator::NewL |
|
58 // Two-phased constructor. |
|
59 // ----------------------------------------------------------------------------- |
|
60 // |
|
61 CIMStatusPaneIndicator* CIMStatusPaneIndicator::NewL() |
|
62 { |
|
63 CIMStatusPaneIndicator* self = |
|
64 new( ELeave ) CIMStatusPaneIndicator(); |
|
65 CleanupStack::PushL( self ); |
|
66 self->ConstructL(); |
|
67 CleanupStack::Pop( self ); |
|
68 return self; |
|
69 } |
|
70 |
|
71 |
|
72 // Destructor |
|
73 CIMStatusPaneIndicator::~CIMStatusPaneIndicator() |
|
74 { |
|
75 delete iSenderId; |
|
76 iProperty.Close(); |
|
77 Cancel(); |
|
78 } |
|
79 // --------------------------------------------------------------------------- |
|
80 // CIMStatusPaneIndicator::DoCancel() |
|
81 // --------------------------------------------------------------------------- |
|
82 // |
|
83 void CIMStatusPaneIndicator::DoCancel() |
|
84 { |
|
85 iProperty.Cancel(); |
|
86 } |
|
87 |
|
88 // --------------------------------------------------------------------------- |
|
89 // CIMStatusPaneIndicator::RunL() |
|
90 // --------------------------------------------------------------------------- |
|
91 // |
|
92 void CIMStatusPaneIndicator::RunL() |
|
93 { |
|
94 // resubscribe before processing new value to prevent missing updates |
|
95 iProperty.Subscribe( iStatus ); |
|
96 SetActive(); |
|
97 if( iProperty.Get(KIMStatusProperty, EIMStatusPropertyMessageCount,iMsgCount ) == KErrNotFound ) |
|
98 { |
|
99 //do necessary action |
|
100 } |
|
101 if( iProperty.Get(KIMStatusProperty, EIMStatusPropertyServiceId,iServiceId ) == KErrNotFound ) |
|
102 { |
|
103 //do necessary action |
|
104 } |
|
105 if( iProperty.Get(KIMStatusProperty, EIMMultipleSender,iMultipleSenders ) == KErrNotFound ) |
|
106 { |
|
107 //do necessary action |
|
108 } |
|
109 TBuf<KMAXLENGTH> senderId; |
|
110 if( iProperty.Get(KIMStatusProperty, EIMStatusPropertySenderId,senderId) == KErrNotFound ) |
|
111 { |
|
112 //do necessary action |
|
113 } |
|
114 if(iSenderId) |
|
115 { |
|
116 delete iSenderId; |
|
117 iSenderId = NULL; |
|
118 } |
|
119 iSenderId = senderId.AllocL(); |
|
120 } |
|
121 // --------------------------------------------------------------------------- |
|
122 // CIMStatusPaneIndicator::MsgCount() |
|
123 // --------------------------------------------------------------------------- |
|
124 // |
|
125 TInt CIMStatusPaneIndicator::MsgCount() |
|
126 { |
|
127 return iMsgCount; |
|
128 } |
|
129 |
|
130 // --------------------------------------------------------------------------- |
|
131 // CIMStatusPaneIndicator::ServiceId() |
|
132 // --------------------------------------------------------------------------- |
|
133 // |
|
134 TInt CIMStatusPaneIndicator::ServiceId() |
|
135 { |
|
136 return iServiceId; |
|
137 } |
|
138 |
|
139 // --------------------------------------------------------------------------- |
|
140 // CIMStatusPaneIndicator::SenderId() |
|
141 // --------------------------------------------------------------------------- |
|
142 // |
|
143 const TDesC& CIMStatusPaneIndicator::SenderId() |
|
144 { |
|
145 if(iSenderId) |
|
146 { |
|
147 return *iSenderId; |
|
148 } |
|
149 return KNullDesC() ; |
|
150 } |
|
151 |
|
152 // --------------------------------------------------------------------------- |
|
153 // CIMStatusPaneIndicator::IsMultipleSenders() |
|
154 // --------------------------------------------------------------------------- |
|
155 // |
|
156 TInt CIMStatusPaneIndicator::IsMultipleSenders() |
|
157 { |
|
158 return iMultipleSenders; |
|
159 } |
|
160 // End of File |
|