|
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 * WV engine pure data API |
|
16 * |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 // INCLUDE FILES |
|
22 #include "impspurecli.h" |
|
23 #include "impspurehandler.h" |
|
24 #include "Impspurecommand.h" |
|
25 #include "impsServerCommon.h" |
|
26 |
|
27 #include "impsutils.h" |
|
28 |
|
29 // MACROS |
|
30 #ifndef _DEBUG |
|
31 #define _NO_IMPS_LOGGING_ |
|
32 #endif |
|
33 |
|
34 // CONSTANTS |
|
35 |
|
36 const TImpsContent KSendPureElements[] = { EImpsKeySession, |
|
37 EImpsKeyTransaction, |
|
38 EImpsKeyTransactionContent }; |
|
39 |
|
40 |
|
41 // ================= MEMBER FUNCTIONS ======================= |
|
42 |
|
43 // ----------------------------------------------------------------------------- |
|
44 // RImpsPureClient2::RImpsPureClient2 |
|
45 // ----------------------------------------------------------------------------- |
|
46 EXPORT_C RImpsPureClient2::RImpsPureClient2() : |
|
47 RImpsClient2(), |
|
48 iCommand( NULL ), |
|
49 iPureCallback( NULL ) |
|
50 { |
|
51 SetOpIdRange( ); |
|
52 } |
|
53 |
|
54 // --------------------------------------------------------- |
|
55 // RImpsPureClient2::RegisterL |
|
56 // --------------------------------------------------------- |
|
57 EXPORT_C void RImpsPureClient2::RegisterL( |
|
58 RImpsEng& aEngine, |
|
59 MImpsPureHandler2* aImpsObserver, |
|
60 TImpsServiceType aType, |
|
61 TBool aReceiveNew, |
|
62 TInt aPriority ) |
|
63 { |
|
64 |
|
65 if ( aType != EImpsServicePresence ) |
|
66 { |
|
67 User::Leave( KErrNotSupported ); |
|
68 } |
|
69 |
|
70 iPureCallback = aImpsObserver; |
|
71 iHandler = CImpsPureHandler2::NewL( *this, aPriority ); |
|
72 iCommand = CImpsPureCommand2::NewL( *this ); |
|
73 iActiveCommand = iCommand; |
|
74 |
|
75 // Start the handler |
|
76 iHandler->StartRun(); |
|
77 iHandleNew = aReceiveNew; |
|
78 iAnyContent = EFalse; |
|
79 |
|
80 // Send registration to the server thread |
|
81 TInt err = DoRegister( aEngine, iHandler ); |
|
82 User::LeaveIfError( err ); |
|
83 |
|
84 } |
|
85 |
|
86 // ----------------------------------------------------------------------------- |
|
87 // RImpsPureClient2::Unregister() |
|
88 // ----------------------------------------------------------------------------- |
|
89 EXPORT_C void RImpsPureClient2::Unregister() |
|
90 { |
|
91 DoUnregister(); |
|
92 } |
|
93 |
|
94 // ----------------------------------------------------------------------------- |
|
95 // RImpsPureClient2::DoRegister() |
|
96 // ----------------------------------------------------------------------------- |
|
97 TInt RImpsPureClient2::DoRegister( |
|
98 RImpsEng& aEngine, |
|
99 CImpsHandler2* aHandler ) |
|
100 { |
|
101 return DoRegister2( aEngine, aHandler, EImpsServPureRegister ); |
|
102 } |
|
103 |
|
104 // ----------------------------------------------------------------------------- |
|
105 // RImpsPureClient2::SendPureDataL() |
|
106 // --------------------------------------------------------------------------- |
|
107 EXPORT_C TInt RImpsPureClient2::SendPureDataL( |
|
108 const TDesC8& aContent ) |
|
109 { |
|
110 IncreaseOpId( ); |
|
111 iCommand->ResetMembers(); |
|
112 iCommand->InitialiseL( KSendPureElements, |
|
113 sizeof( KSendPureElements ) / |
|
114 sizeof( KSendPureElements[0] ) ); |
|
115 |
|
116 iCommand->InsertElementL( aContent, EImpsKeyPureData ); |
|
117 // syncronous sending |
|
118 TInt ret = iCommand->PackAndSendL( EImpsPureData, iOpId ); |
|
119 if( ret != KErrNone ) |
|
120 { |
|
121 #ifndef _NO_IMPS_LOGGING_ |
|
122 CImpsClientLogger::Log(_L("PureClient2: SendPureDataL opid=%d cli=%d LEAVES with %d"), |
|
123 iOpId, (TInt)this, ret ); |
|
124 #endif |
|
125 User::Leave( ret ); |
|
126 } |
|
127 #ifndef _NO_IMPS_LOGGING_ |
|
128 CImpsClientLogger::Log(_L("PureClient2: SendPureDataL opid=%d cli=%d"), |
|
129 iOpId, (TInt)this); |
|
130 #endif |
|
131 return iOpId; |
|
132 } |
|
133 |
|
134 // ----------------------------------------------------------------------------- |
|
135 // RImpsPureClient2::Handler |
|
136 // ----------------------------------------------------------------------------- |
|
137 MImpsPureHandler2* RImpsPureClient2::Handler( ) |
|
138 { |
|
139 return iPureCallback; |
|
140 } |
|
141 |
|
142 // End of File |
|
143 |