|
1 /* |
|
2 * Copyright (c) 2002 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: Implementation of the CProfilePresenceImpl. |
|
15 * This implementation is used when presence is supported. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 // INCLUDE FILES |
|
22 #include "CProfilePresenceImpl.h" |
|
23 #include <centralrepository.h> |
|
24 #include <bautils.h> |
|
25 #include <barsc.h> |
|
26 #include <ProfileEng.rsg> |
|
27 #include "ProfileEng.hrh" |
|
28 #include "ProfileEngineConstants.h" |
|
29 #include "ProfileEnginePrivateCRKeys.h" |
|
30 #include "ProfileEngUtils.h" |
|
31 |
|
32 // EXTERNAL DATA STRUCTURES |
|
33 // EXTERNAL FUNCTION PROTOTYPES |
|
34 // CONSTANTS |
|
35 const TInt KProfileMaxStatusMessageLength( PROFILES_MAX_STATUS_MSG_LENGTH ); |
|
36 |
|
37 // MACROS |
|
38 // LOCAL CONSTANTS AND MACROS |
|
39 // MODULE DATA STRUCTURES |
|
40 // LOCAL FUNCTION PROTOTYPES |
|
41 // FORWARD DECLARATIONS |
|
42 |
|
43 // ============================= LOCAL FUNCTIONS =============================== |
|
44 |
|
45 // ============================ MEMBER FUNCTIONS =============================== |
|
46 |
|
47 |
|
48 // ----------------------------------------------------------------------------- |
|
49 // CProfileNameImpl::CProfilePresenceImpl |
|
50 // C++ default constructor can NOT contain any code, that |
|
51 // might leave. |
|
52 // ----------------------------------------------------------------------------- |
|
53 // |
|
54 CProfilePresenceImpl::CProfilePresenceImpl() |
|
55 { |
|
56 } |
|
57 |
|
58 // ----------------------------------------------------------------------------- |
|
59 // CProfilePresenceImpl::ConstructL |
|
60 // Symbian 2nd phase constructor can leave. |
|
61 // ----------------------------------------------------------------------------- |
|
62 // |
|
63 void CProfilePresenceImpl::ConstructL() |
|
64 { |
|
65 iStatusMessage = KNullDesC().AllocL(); |
|
66 } |
|
67 |
|
68 // ----------------------------------------------------------------------------- |
|
69 // CProfilePresenceImpl::ConstructL |
|
70 // Symbian 2nd phase constructor can leave. |
|
71 // ----------------------------------------------------------------------------- |
|
72 // |
|
73 void CProfilePresenceImpl::ConstructL( |
|
74 const MProfilePresence& aPresence ) |
|
75 { |
|
76 iStatusMessage = aPresence.StatusMessage().AllocL(); |
|
77 iAvailabilityAttribute = aPresence.AvailabilityAttribute(); |
|
78 } |
|
79 |
|
80 // ----------------------------------------------------------------------------- |
|
81 // CProfilePresenceImpl::NewL |
|
82 // Two-phased constructor. |
|
83 // ----------------------------------------------------------------------------- |
|
84 // |
|
85 CProfilePresenceImpl* CProfilePresenceImpl::NewL() |
|
86 { |
|
87 CProfilePresenceImpl* self = new( ELeave ) CProfilePresenceImpl; |
|
88 |
|
89 CleanupStack::PushL( self ); |
|
90 self->ConstructL(); |
|
91 CleanupStack::Pop(); |
|
92 |
|
93 return self; |
|
94 } |
|
95 |
|
96 // ----------------------------------------------------------------------------- |
|
97 // CProfilePresenceImpl::NewL |
|
98 // Two-phased constructor. |
|
99 // ----------------------------------------------------------------------------- |
|
100 // |
|
101 CProfilePresenceImpl* CProfilePresenceImpl::NewL( |
|
102 const MProfilePresence& aPresence ) |
|
103 { |
|
104 CProfilePresenceImpl* self = new( ELeave ) CProfilePresenceImpl; |
|
105 |
|
106 CleanupStack::PushL( self ); |
|
107 self->ConstructL( aPresence ); |
|
108 CleanupStack::Pop(); |
|
109 |
|
110 return self; |
|
111 } |
|
112 |
|
113 // Destructor |
|
114 CProfilePresenceImpl::~CProfilePresenceImpl() |
|
115 { |
|
116 delete iStatusMessage; |
|
117 } |
|
118 |
|
119 // ----------------------------------------------------------------------------- |
|
120 // CProfilePresenceImpl::InternalizeL |
|
121 // |
|
122 // (other items were commented in a header). |
|
123 // ----------------------------------------------------------------------------- |
|
124 // |
|
125 void CProfilePresenceImpl::InternalizeL( CRepository& aCenRep, |
|
126 TInt aProfileId ) |
|
127 { |
|
128 delete iStatusMessage; |
|
129 iStatusMessage = NULL; |
|
130 |
|
131 // Status message |
|
132 TBuf< KProfileMaxStatusMessageLength > buf; |
|
133 aCenRep.Get( ProfileEngUtils::ResolveKey( KProEngStatusMsg, |
|
134 aProfileId ), buf ); |
|
135 iStatusMessage = buf.AllocL(); |
|
136 |
|
137 // AvailabilityAttribute |
|
138 TInt tmpAttr( 0 ); |
|
139 aCenRep.Get( ProfileEngUtils::ResolveKey( KProEngAvailAttribute, |
|
140 aProfileId ), tmpAttr ); |
|
141 iAvailabilityAttribute = tmpAttr; |
|
142 } |
|
143 |
|
144 // ----------------------------------------------------------------------------- |
|
145 // CProfilePresenceImpl::ExternalizeL |
|
146 // |
|
147 // (other items were commented in a header). |
|
148 // ----------------------------------------------------------------------------- |
|
149 // |
|
150 void CProfilePresenceImpl::ExternalizeL( CRepository& aCenRep, |
|
151 TInt aProfileId ) const |
|
152 { |
|
153 aCenRep.Set( ProfileEngUtils::ResolveKey( KProEngStatusMsg, |
|
154 aProfileId ), *iStatusMessage ); |
|
155 aCenRep.Set( ProfileEngUtils::ResolveKey( KProEngAvailAttribute, |
|
156 aProfileId ), ( TInt ) iAvailabilityAttribute ); |
|
157 } |
|
158 |
|
159 // ----------------------------------------------------------------------------- |
|
160 // CProfilePresenceImpl::AvailabilityAttribute |
|
161 // |
|
162 // (other items were commented in a header). |
|
163 // ----------------------------------------------------------------------------- |
|
164 // |
|
165 TUint32 CProfilePresenceImpl::AvailabilityAttribute() const |
|
166 { |
|
167 return iAvailabilityAttribute; |
|
168 } |
|
169 |
|
170 // ----------------------------------------------------------------------------- |
|
171 // CProfilePresenceImpl::SetAvailabilityAttribute |
|
172 // |
|
173 // (other items were commented in a header). |
|
174 // ----------------------------------------------------------------------------- |
|
175 // |
|
176 void CProfilePresenceImpl::SetAvailabilityAttribute( |
|
177 const TUint32 aAvailabilityAttribute ) |
|
178 { |
|
179 iAvailabilityAttribute = aAvailabilityAttribute; |
|
180 } |
|
181 |
|
182 // ----------------------------------------------------------------------------- |
|
183 // CProfilePresenceImpl::StatusMessage |
|
184 // |
|
185 // (other items were commented in a header). |
|
186 // ----------------------------------------------------------------------------- |
|
187 // |
|
188 const TDesC& CProfilePresenceImpl::StatusMessage() const |
|
189 { |
|
190 return *iStatusMessage; |
|
191 } |
|
192 |
|
193 // ----------------------------------------------------------------------------- |
|
194 // CProfilePresenceImpl::SetStatusMessageL |
|
195 // |
|
196 // (other items were commented in a header). |
|
197 // ----------------------------------------------------------------------------- |
|
198 // |
|
199 void CProfilePresenceImpl::SetStatusMessageL( |
|
200 const TDesC& aStatusMessage ) |
|
201 { |
|
202 HBufC* tmp = aStatusMessage.Left( KProfileMaxStatusMessageLength ).AllocL(); |
|
203 delete iStatusMessage; |
|
204 iStatusMessage = tmp; |
|
205 } |
|
206 |
|
207 // ========================== OTHER EXPORTED FUNCTIONS ========================= |
|
208 |
|
209 // End of File |