|
1 /* |
|
2 * Copyright (c) 2007-2008 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: server error handler |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <ximpprotocolconnectionhost.h> |
|
20 #include "cossprotocolservererrorhandler.h" |
|
21 #include "mossprotocolconnectionmanager.h" |
|
22 #include "ossprotocolpluginlogger.h" |
|
23 #include "waittimer.h" |
|
24 #include "cossprotocolconnectionmanager.h" |
|
25 |
|
26 #include <ximpobjectfactory.h> |
|
27 #include <ximpobjectcollection.h> |
|
28 #include <e32des16.h> |
|
29 #include <string.h> |
|
30 #include <sys/types.h> |
|
31 #include <stdio.h> |
|
32 #include <stdlib.h> |
|
33 #include "msgliterals.h" |
|
34 #include <gtypes.h> |
|
35 |
|
36 // ======== MEMBER FUNCTIONS ======== |
|
37 |
|
38 // --------------------------------------------------------------------------- |
|
39 // COssprotocolServerErrorHandler::COssprotocolServerErrorHandler |
|
40 // --------------------------------------------------------------------------- |
|
41 // |
|
42 COssprotocolServerErrorHandler::COssprotocolServerErrorHandler ( |
|
43 MOSSProtocolConnectionManager& aConnMan ) : |
|
44 CActive ( EPriorityNormal ), |
|
45 iConnMan ( aConnMan ) |
|
46 { |
|
47 LOGGER ( TXT ( "COssprotocolServerErrorHandler::COssprotocolServerErrorHandler Start" ) ); |
|
48 CActiveScheduler::Add ( this ); |
|
49 |
|
50 LOGGER ( TXT ( "COssprotocolServerErrorHandler::COssprotocolServerErrorHandler End" ) ); |
|
51 } |
|
52 |
|
53 |
|
54 // --------------------------------------------------------------------------- |
|
55 // COssprotocolServerErrorHandler::ConstructL |
|
56 // --------------------------------------------------------------------------- |
|
57 // |
|
58 void COssprotocolServerErrorHandler::ConstructL() |
|
59 { |
|
60 LOGGER ( TXT ( "COssprotocolServerErrorHandler::ConstructL Start-End" ) ); |
|
61 |
|
62 } |
|
63 |
|
64 |
|
65 // --------------------------------------------------------------------------- |
|
66 // COssprotocolServerErrorHandler::NewL |
|
67 // --------------------------------------------------------------------------- |
|
68 // |
|
69 COssprotocolServerErrorHandler* COssprotocolServerErrorHandler::NewL ( |
|
70 MOSSProtocolConnectionManager& aConnMan ) |
|
71 { |
|
72 LOGGER ( TXT ( "COssprotocolServerErrorHandler::NewL Start" ) ); |
|
73 |
|
74 COssprotocolServerErrorHandler* self = new ( ELeave ) |
|
75 COssprotocolServerErrorHandler ( aConnMan ); |
|
76 CleanupStack::PushL ( self ); |
|
77 self->ConstructL(); |
|
78 CleanupStack::Pop ( self ); |
|
79 |
|
80 LOGGER ( TXT ( "COssprotocolServerErrorHandler::NewL End" ) ); |
|
81 return self; |
|
82 } |
|
83 |
|
84 |
|
85 // --------------------------------------------------------------------------- |
|
86 // COssprotocolServerErrorHandler::NewLC |
|
87 // --------------------------------------------------------------------------- |
|
88 // |
|
89 COssprotocolServerErrorHandler* COssprotocolServerErrorHandler::NewLC ( |
|
90 MOSSProtocolConnectionManager& aConnMan ) |
|
91 { |
|
92 LOGGER ( TXT ( "COssprotocolServerErrorHandler::NewLC Start" ) ); |
|
93 |
|
94 COssprotocolServerErrorHandler* self = |
|
95 COssprotocolServerErrorHandler::NewL ( aConnMan ); |
|
96 CleanupStack::PushL ( self ); |
|
97 |
|
98 LOGGER ( TXT ( "COssprotocolServerErrorHandler::NewLC End" ) ); |
|
99 return self; |
|
100 } |
|
101 |
|
102 // --------------------------------------------------------------------------- |
|
103 // COssprotocolServerErrorHandler::~COssprotocolServerErrorHandler |
|
104 // --------------------------------------------------------------------------- |
|
105 // |
|
106 COssprotocolServerErrorHandler::~COssprotocolServerErrorHandler() |
|
107 { |
|
108 LOGGER ( TXT ( "::~COssprotocolServerErrorHandler Start" ) ); |
|
109 |
|
110 Cancel(); |
|
111 |
|
112 LOGGER ( TXT ( "::~COssprotocolServerErrorHandler End" ) ); |
|
113 } |
|
114 |
|
115 |
|
116 // --------------------------------------------------------------------------- |
|
117 // COssprotocolServerErrorHandler::DoCancel() |
|
118 // --------------------------------------------------------------------------- |
|
119 // |
|
120 void COssprotocolServerErrorHandler::DoCancel() |
|
121 { |
|
122 LOGGER ( TXT ( "COssprotocolServerErrorHandler::DoCancel Start" ) ); |
|
123 |
|
124 iConnMan.DataHandler().CancelListeningServerErrors(); |
|
125 |
|
126 LOGGER ( TXT ( "COssprotocolServerErrorHandler::DoCancel End" ) ); |
|
127 } |
|
128 |
|
129 // --------------------------------------------------------------------------- |
|
130 // COssprotocolServerErrorHandler::RunL() |
|
131 // --------------------------------------------------------------------------- |
|
132 // |
|
133 void COssprotocolServerErrorHandler::RunL() |
|
134 { |
|
135 LOGGER ( TXT ( "COssprotocolServerErrorHandler::RunL Start" ) ); |
|
136 |
|
137 // something is coming from the xmpp server |
|
138 User::LeaveIfError ( iStatus.Int() ); |
|
139 |
|
140 ProcessIncomingDataL(); |
|
141 // StartListeningL(); |
|
142 |
|
143 LOGGER ( TXT ( "COssprotocolServerErrorHandler::RunL End" ) ); |
|
144 } |
|
145 |
|
146 // --------------------------------------------------------------------------- |
|
147 // COssprotocolServerErrorHandler::ProcessIncomingDataL() |
|
148 // --------------------------------------------------------------------------- |
|
149 // |
|
150 void COssprotocolServerErrorHandler::ProcessIncomingDataL() |
|
151 { |
|
152 LOGGER ( TXT ( "COssprotocolServerErrorHandler::ProcessIncomingDataL Start" ) ); |
|
153 TInt senderidlen = 0; |
|
154 TInt messagelen = 0; |
|
155 char* sender = NULL; |
|
156 char* recvdmessage = NULL; |
|
157 guint messagetype = NULL; |
|
158 guint time; |
|
159 char* pResponse = NULL, *pOrigResponse = NULL; |
|
160 User::LeaveIfError ( iStatus.Int() ); |
|
161 pOrigResponse = pResponse = iConnMan.DataHandler().ResponseL ( 3 ); |
|
162 CleanupStack::PushL(pOrigResponse) ; |
|
163 //parse message type |
|
164 |
|
165 memcpy ( &messagetype, pResponse, sizeof ( guint ) ); |
|
166 memcpy ( &time, pResponse + sizeof ( guint ), sizeof ( guint ) ); |
|
167 |
|
168 senderidlen = strlen(pResponse + sizeof ( guint ) * 2 ); |
|
169 sender = ( char* ) User::AllocLC ( senderidlen + 1 ); |
|
170 memset ( sender, '\0', senderidlen ); |
|
171 memcpy ( sender, pResponse + sizeof ( guint ) * 2, senderidlen + 1); |
|
172 |
|
173 messagelen = strlen(pResponse + sizeof ( guint ) * 2 + senderidlen + 1 ); |
|
174 recvdmessage = ( char* ) User::AllocLC ( messagelen + 1 ); |
|
175 memset ( recvdmessage, '\0', messagelen ); |
|
176 memcpy ( recvdmessage, pResponse + sizeof ( guint ) * 2 + 1 + senderidlen, messagelen + 1 ); |
|
177 CleanupStack::PopAndDestroy ( recvdmessage ); |
|
178 CleanupStack::PopAndDestroy ( sender ); |
|
179 CleanupStack::PopAndDestroy(pOrigResponse) ;//pOrigResponse |
|
180 LOGGER ( TXT ( "COssprotocolServerErrorHandler::ProcessIncomingDataL End" ) ); |
|
181 } |
|
182 |
|
183 |
|
184 // --------------------------------------------------------------------------- |
|
185 // COssprotocolServerErrorHandler::RunError |
|
186 // --------------------------------------------------------------------------- |
|
187 // |
|
188 TInt COssprotocolServerErrorHandler::RunError ( TInt aError ) |
|
189 { |
|
190 LOGGER ( TXT ( "COssprotocolServerErrorHandler::RunError Start %d" ), aError ); |
|
191 |
|
192 LOGGER ( TXT ( "COssprotocolServerErrorHandler::RunError End" ) ); |
|
193 return KErrNone; |
|
194 } |
|
195 |
|
196 // --------------------------------------------------------------------------- |
|
197 // COssprotocolServerErrorHandler::StartListeningL |
|
198 // --------------------------------------------------------------------------- |
|
199 // |
|
200 void COssprotocolServerErrorHandler::StartListeningL() |
|
201 { |
|
202 LOGGER ( TXT ( "COssprotocolServerErrorHandler::StartListeningL Start" ) ); |
|
203 |
|
204 if ( ! ( this->IsActive() ) ) |
|
205 { |
|
206 iConnMan.DataHandler().ListenIncomingServerError ( iStatus ); |
|
207 SetActive(); |
|
208 } |
|
209 LOGGER ( TXT ( "COssprotocolServerErrorHandler::StartListeningL End" ) ); |
|
210 } |
|
211 |
|
212 // End of file |