|
1 /* |
|
2 * Copyright (c) 2005 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: RNcnNotification implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // ---------------------------------------------------------------------------- |
|
21 // INCLUDE FILES |
|
22 // ---------------------------------------------------------------------------- |
|
23 // |
|
24 #include "RNcnNotification.h" |
|
25 #include "NcnCommsDefs.h" |
|
26 #include "CNcnPackDescrArray.h" |
|
27 #include "NcnNotificationUIDs.hrh" |
|
28 #include <bamdesca.h> |
|
29 |
|
30 // CONSTANTS |
|
31 /// Unnamed namespace for local definitions |
|
32 namespace { |
|
33 |
|
34 const TInt KNcnNotifMessageSlots = 1; // only synchronous services -> 1 slot |
|
35 |
|
36 } // namespace |
|
37 |
|
38 // ---------------------------------------------------------------------------- |
|
39 // MEMBER FUNCTIONS |
|
40 // ---------------------------------------------------------------------------- |
|
41 // |
|
42 |
|
43 // ---------------------------------------------------------------------------- |
|
44 // RNcnNotification::NewL |
|
45 // |
|
46 // Heap constructor for ECOM use. |
|
47 // Note: this class can be instantiated to stack but we hide |
|
48 // class type from the ECOM API client -> instantiate to heap. |
|
49 // ---------------------------------------------------------------------------- |
|
50 // |
|
51 RNcnNotification* RNcnNotification::NewL() |
|
52 { |
|
53 RNcnNotification* self = |
|
54 new( ELeave ) RNcnNotification(); |
|
55 CleanupDeletePushL( self ); |
|
56 self->InitializeSessionL(); |
|
57 CleanupStack::Pop(); |
|
58 return self; |
|
59 } |
|
60 |
|
61 // ---------------------------------------------------------------------------- |
|
62 // RNcnNotification::RNcnNotification |
|
63 // |
|
64 // Constructor. |
|
65 // ---------------------------------------------------------------------------- |
|
66 // |
|
67 RNcnNotification::RNcnNotification() |
|
68 { |
|
69 } |
|
70 |
|
71 // ---------------------------------------------------------------------------- |
|
72 // RNcnNotification::~RNcnNotification |
|
73 // |
|
74 // Destructor. |
|
75 // ---------------------------------------------------------------------------- |
|
76 // |
|
77 RNcnNotification::~RNcnNotification() |
|
78 { |
|
79 Close(); |
|
80 } |
|
81 |
|
82 // ---------------------------------------------------------------------------- |
|
83 // RNcnNotification::InitializeSessionL |
|
84 // |
|
85 // Initializes server session. |
|
86 // ---------------------------------------------------------------------------- |
|
87 // |
|
88 void RNcnNotification::InitializeSessionL() |
|
89 { |
|
90 TVersion version( KNcnNotificationServerMajor, |
|
91 KNcnNotificationServerMinor, |
|
92 KNcnNotificationServerBuild ); |
|
93 User::LeaveIfError( CreateSession( KNcnServerName, |
|
94 version, |
|
95 KNcnNotifMessageSlots ) ); |
|
96 } |
|
97 |
|
98 // ---------------------------------------------------------------------------- |
|
99 // RNcnNotification::NewMessages |
|
100 // |
|
101 // From MNcnNotification interface. |
|
102 // ---------------------------------------------------------------------------- |
|
103 // |
|
104 TInt RNcnNotification::NewMessages( |
|
105 const TMsvId& aMailBox, |
|
106 MNcnNotification::TIndicationType aIndicationType, |
|
107 const MDesCArray& aInfo ) |
|
108 { |
|
109 TInt err = KErrNone; |
|
110 TDesC8* packed = 0; |
|
111 |
|
112 TIpcArgs args( aMailBox, aIndicationType ); |
|
113 TRAP( err, packed = CNcnPackDescrArray::PackL( aInfo ) ); |
|
114 |
|
115 // only try to send if packing succeeded |
|
116 if( err == KErrNone ) |
|
117 { |
|
118 args.Set( 2, packed ); |
|
119 err = SendReceive( ENewMessages1, args ); |
|
120 delete packed; |
|
121 } |
|
122 |
|
123 return err; |
|
124 } |
|
125 |
|
126 // ---------------------------------------------------------------------------- |
|
127 // RNcnNotification::MarkUnread |
|
128 // |
|
129 // From MNcnNotification interface. |
|
130 // ---------------------------------------------------------------------------- |
|
131 // |
|
132 TInt RNcnNotification::MarkUnread( const TMsvId& aMailBox ) |
|
133 { |
|
134 TIpcArgs args( aMailBox ); |
|
135 return SendReceive( EMarkUnread1, args ); |
|
136 } |
|
137 |
|
138 // ---------------------------------------------------------------------------- |
|
139 // RNcnNotification::NewMessages |
|
140 // |
|
141 // From MNcnInternalNotification interface. |
|
142 // ---------------------------------------------------------------------------- |
|
143 // |
|
144 TInt RNcnNotification::NewMessages( |
|
145 const TNcnNotifMessageType aType ) |
|
146 { |
|
147 TIpcArgs args( aType ); |
|
148 return SendReceive( ENewInternalMessages1, args ); |
|
149 } |
|
150 |
|
151 // ---------------------------------------------------------------------------- |
|
152 // RNcnNotification::NewMessages |
|
153 // |
|
154 // From MNcnInternalNotification interface. |
|
155 // ---------------------------------------------------------------------------- |
|
156 // |
|
157 TInt RNcnNotification::NewMessages( |
|
158 const TNcnNotifMessageType aType, |
|
159 const TMsvId& aMailBox, |
|
160 const MDesCArray& aInfo ) |
|
161 { |
|
162 TInt err = KErrNone; |
|
163 TDesC8* packed = 0; |
|
164 |
|
165 TIpcArgs args( aType, aMailBox ); |
|
166 TRAP( err, packed = CNcnPackDescrArray::PackL( aInfo ) ); |
|
167 |
|
168 // only try to send if packing succeeded |
|
169 if( err == KErrNone ) |
|
170 { |
|
171 args.Set( 2, packed ); |
|
172 err = SendReceive( ENewInternalMessages2, args ); |
|
173 delete packed; |
|
174 } |
|
175 |
|
176 return err; |
|
177 } |
|
178 |
|
179 // ---------------------------------------------------------------------------- |
|
180 // RNcnNotification::MarkUnread |
|
181 // |
|
182 // From MNcnInternalNotification interface. |
|
183 // ---------------------------------------------------------------------------- |
|
184 // |
|
185 TInt RNcnNotification::MarkUnread( |
|
186 const TNcnUnreadRequestType aRequest ) |
|
187 { |
|
188 TIpcArgs args( aRequest ); |
|
189 return SendReceive( EInternalMarkUnread1, args ); |
|
190 } |
|
191 |
|
192 |
|
193 // ---------------------------------------------------------------------------- |
|
194 // RNcnNotification::MarkUnread |
|
195 // |
|
196 // From MNcnInternalNotification interface. |
|
197 // ---------------------------------------------------------------------------- |
|
198 // |
|
199 void RNcnNotification::MarkUnread( |
|
200 const TNcnUnreadRequestType aRequest, |
|
201 TRequestStatus& aRequestStatus ) |
|
202 { |
|
203 TIpcArgs args( aRequest ); |
|
204 return SendReceive( EInternalMarkUnread1, args, aRequestStatus ); |
|
205 } |
|
206 |
|
207 // ---------------------------------------------------------------------------- |
|
208 // RNcnNotification::MarkUnread |
|
209 // |
|
210 // From MNcnInternalNotification interface. |
|
211 // ---------------------------------------------------------------------------- |
|
212 // |
|
213 TInt RNcnNotification::MarkUnread( |
|
214 const TNcnUnreadRequestType aRequest, |
|
215 const TMsvId& aMailbox ) |
|
216 { |
|
217 TIpcArgs args( aRequest, aMailbox ); |
|
218 return SendReceive( EInternalMarkUnread2, args ); |
|
219 } |
|
220 |
|
221 // ---------------------------------------------------------------------------- |
|
222 // RNcnNotification::MarkUnread |
|
223 // |
|
224 // From MNcnInternalNotification interface. |
|
225 // ---------------------------------------------------------------------------- |
|
226 // |
|
227 void RNcnNotification::MarkUnread( |
|
228 const TNcnUnreadRequestType aRequest, |
|
229 const TMsvId& aMailbox, |
|
230 TRequestStatus& aRequestStatus ) |
|
231 { |
|
232 TIpcArgs args( aRequest, aMailbox ); |
|
233 return SendReceive( EInternalMarkUnread2, args, aRequestStatus ); |
|
234 } |
|
235 |
|
236 // ---------------------------------------------------------------------------- |
|
237 // RNcnNotification::CancelMarkUnread |
|
238 // |
|
239 // From MNcnInternalNotification interface. |
|
240 // ---------------------------------------------------------------------------- |
|
241 // |
|
242 void RNcnNotification::CancelMarkUnread() |
|
243 { |
|
244 SendReceive( EInternalCancelMarkUnread, TIpcArgs() ); |
|
245 } |
|
246 |
|
247 // End of file |