|
1 /* |
|
2 * Copyright (c) 2002-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: |
|
15 * imps client interface. |
|
16 * |
|
17 */ |
|
18 |
|
19 // INCLUDE FILES |
|
20 |
|
21 #include "impsImHandler.h" |
|
22 #include "ImpsImCli.h" |
|
23 #include "ImpsImCommand.h" |
|
24 #include "impsServerCommon.h" |
|
25 |
|
26 #include "impsutils.h" |
|
27 |
|
28 // MACROS |
|
29 #ifndef _DEBUG |
|
30 #define _NO_IMPS_LOGGING_ |
|
31 #endif |
|
32 |
|
33 |
|
34 // ================= MEMBER FUNCTIONS ======================= |
|
35 |
|
36 // --------------------------------------------------------- |
|
37 // RImpsImClient2::RImpsImClient2 |
|
38 // --------------------------------------------------------- |
|
39 EXPORT_C RImpsImClient2::RImpsImClient2() : |
|
40 RImpsClient2(), |
|
41 iImHandlerCallback( NULL ), |
|
42 iBlockingHandlerCallback( NULL ), |
|
43 iCommand( NULL ) |
|
44 { |
|
45 SetOpIdRange( ); |
|
46 } |
|
47 |
|
48 // --------------------------------------------------------- |
|
49 // RImpsImClient2::RegisterL |
|
50 // --------------------------------------------------------- |
|
51 EXPORT_C void RImpsImClient2::RegisterL( |
|
52 RImpsEng& aEngine, |
|
53 MImpsImHandler2* aImpsObserver, |
|
54 MImpsBlockingHandler2* aBlockingHandler, |
|
55 const TDesC& aClientId, |
|
56 TBool aReceiveNew, |
|
57 TInt aPriority ) |
|
58 { |
|
59 iImHandlerCallback = aImpsObserver; |
|
60 iBlockingHandlerCallback = aBlockingHandler; |
|
61 iHandler = CImpsImHandler2::NewL( *this, aPriority ); |
|
62 iCommand = CImpsImCommand2::NewL( *this ); |
|
63 iActiveCommand = iCommand; |
|
64 |
|
65 // Start the handler |
|
66 iHandler->StartRun(); |
|
67 iHandleNew = aReceiveNew; |
|
68 iAnyContent = EFalse; |
|
69 |
|
70 // Send registration to the server thread |
|
71 TInt err = DoRegister( aEngine, iHandler ); |
|
72 User::LeaveIfError( err ); |
|
73 |
|
74 (void) DoAssign( aClientId ); |
|
75 } |
|
76 |
|
77 // ---------------------------------------------------------------------------- |
|
78 // RImpsImClient2::Unregister() |
|
79 // ---------------------------------------------------------------------------- |
|
80 EXPORT_C void RImpsImClient2::Unregister() |
|
81 { |
|
82 DoUnregister(); |
|
83 } |
|
84 |
|
85 // ---------------------------------------------------------------------------- |
|
86 // RImpsImClient2::DoRegister() |
|
87 // ---------------------------------------------------------------------------- |
|
88 TInt RImpsImClient2::DoRegister( |
|
89 RImpsEng& aEngine, |
|
90 CImpsHandler2* aHandler ) |
|
91 { |
|
92 return DoRegister2( aEngine, aHandler, EImpsImRegister ); |
|
93 } |
|
94 |
|
95 // ---------------------------------------------------------------------------- |
|
96 // RImpsImClient2::SendTextMessageL() |
|
97 // ---------------------------------------------------------------------------- |
|
98 EXPORT_C TInt RImpsImClient2::SendTextMessageL( |
|
99 const TDesC* aSenderSn, |
|
100 const MDesCArray* aUserIds, |
|
101 const TDesC* aGroupId, |
|
102 const MDesCArray* aScreenNames, |
|
103 const TDesC& aContent, |
|
104 TBool aDeliveryReportWanted ) |
|
105 { |
|
106 IncreaseOpId( ); |
|
107 |
|
108 #ifndef _NO_IMPS_LOGGING_ |
|
109 CImpsClientLogger::Log(_L("RImpsImClient2: SendTextMessageL opid=%d cli=%d"), |
|
110 iOpId, (TInt)this ); |
|
111 #endif |
|
112 |
|
113 iCommand->SetParametersL( |
|
114 aSenderSn, aUserIds, aGroupId, aScreenNames, aContent, aDeliveryReportWanted ); |
|
115 |
|
116 iMessagePtr.Set( iCommand->iMessageStream->Des() ); |
|
117 iCommand->StartRunL( iOpId, EImpsServWVSendOnly ); |
|
118 SendReceive( EImpsServWVSendOnly, |
|
119 TIpcArgs( &iMessagePtr, iOpId ), iCommand->iStatus ); |
|
120 |
|
121 return iOpId; |
|
122 } |
|
123 |
|
124 // ---------------------------------------------------------------------------- |
|
125 // RImpsImClient2::BlockEntityRequestL |
|
126 // ---------------------------------------------------------------------------- |
|
127 EXPORT_C TInt RImpsImClient2::BlockEntityRequestL( |
|
128 const MDesCArray* aBlockEntity, |
|
129 const MDesCArray* aUnBlockEntity, |
|
130 TBool aBlockedListInUse, |
|
131 const MDesCArray* aGrantedEntityList, |
|
132 const MDesCArray* aUnGrantEntity, |
|
133 TBool aGrantedListInUse ) |
|
134 { |
|
135 IncreaseOpId( ); |
|
136 |
|
137 iCommand->SetParametersL( |
|
138 aBlockEntity, aUnBlockEntity, aBlockedListInUse, |
|
139 aGrantedEntityList, aUnGrantEntity, aGrantedListInUse ); |
|
140 |
|
141 iMessagePtr.Set( iCommand->iMessageStream->Des() ); |
|
142 |
|
143 iCommand->StartRunL( iOpId, EImpsServBlock ); |
|
144 |
|
145 #ifndef _NO_IMPS_LOGGING_ |
|
146 CImpsClientLogger::Log(_L("RImpsImClient2: BlockEntityRequestL opid=%d cli=%d"), |
|
147 iOpId, (TInt)this ); |
|
148 #endif |
|
149 SendReceive( EImpsServBlock, |
|
150 TIpcArgs( &iMessagePtr, iOpId ), iCommand->iStatus ); |
|
151 |
|
152 return iOpId; |
|
153 |
|
154 } |
|
155 |
|
156 // ---------------------------------------------------------------------------- |
|
157 // RImpsImClient2::GetBlockedListRequestL |
|
158 // ---------------------------------------------------------------------------- |
|
159 EXPORT_C TInt RImpsImClient2::GetBlockedListRequestL() |
|
160 { |
|
161 IncreaseOpId( ); |
|
162 |
|
163 #ifndef _NO_IMPS_LOGGING_ |
|
164 CImpsClientLogger::Log(_L("RImpsImClient2: GetBlockedListRequestL opid=%d cli=%d"), |
|
165 iOpId, (TInt)this ); |
|
166 #endif |
|
167 |
|
168 // This has no serialized data, but the message |
|
169 // primitive is created in a server thread to minimize |
|
170 // the amount of data transferred between client and server thread. |
|
171 iCommand->StartRunL( iOpId, EImpsServBlock ); |
|
172 TImpsServRequest req = EImpsServGetBlocked; |
|
173 SendReceive( req, TIpcArgs( TIpcArgs::ENothing, iOpId ), iCommand->iStatus ); |
|
174 #ifndef _NO_IMPS_LOGGING_ |
|
175 CImpsClientLogger::Log(_L("RImpsImClient2: GetBlockedListRequestL opid=%d cli=%d"), |
|
176 iOpId, (TInt)this ); |
|
177 #endif |
|
178 return iOpId; |
|
179 } |
|
180 |
|
181 // ---------------------------------------------------------------------------- |
|
182 // RImpsImClient2::SendContentMessageL |
|
183 // ---------------------------------------------------------------------------- |
|
184 EXPORT_C TInt RImpsImClient2::SendContentMessageL( const TDesC* aSenderSn, |
|
185 const MDesCArray* aUserIds, |
|
186 const TDesC* aGroupId, |
|
187 const MDesCArray* aScreenNames, |
|
188 const TDesC& aContentType, |
|
189 const TDesC8& aContent, |
|
190 TBool aDeliveryReportWanted ) |
|
191 { |
|
192 IncreaseOpId( ); |
|
193 |
|
194 #ifndef _NO_IMPS_LOGGING_ |
|
195 CImpsClientLogger::Log(_L("RImpsImClient2: SendContentMessageL opid=%d cli=%d"), |
|
196 iOpId, (TInt)this ); |
|
197 #endif |
|
198 |
|
199 iCommand->SetParametersL( |
|
200 aSenderSn, aUserIds, aGroupId, aScreenNames, aContentType, aContent, aDeliveryReportWanted ); |
|
201 |
|
202 iMessagePtr.Set( iCommand->iMessageStream->Des() ); |
|
203 iCommand->StartRunL( iOpId, EImpsServWVSendOnly ); |
|
204 SendReceive( EImpsServWVSendOnly, |
|
205 TIpcArgs( &iMessagePtr, iOpId ), iCommand->iStatus ); |
|
206 |
|
207 return iOpId; |
|
208 } |
|
209 // ---------------------------------------------------------------------------- |
|
210 // RImpsImClient2::Handler |
|
211 // ---------------------------------------------------------------------------- |
|
212 MImpsImHandler2* RImpsImClient2::Handler( ) |
|
213 { |
|
214 return iImHandlerCallback; |
|
215 } |
|
216 |
|
217 // ---------------------------------------------------------------------------- |
|
218 // RImpsImClient2::BlockHandler |
|
219 // ---------------------------------------------------------------------------- |
|
220 MImpsBlockingHandler2* RImpsImClient2::BlockHandler( ) |
|
221 { |
|
222 return iBlockingHandlerCallback; |
|
223 } |
|
224 |
|
225 // ================= OTHER EXPORTED FUNCTIONS ============== |
|
226 |
|
227 |
|
228 // End of File |