0
|
1 |
/*
|
|
2 |
* Copyright (c) 2004-2006 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
1
|
5 |
* under the terms of the License "Eclipse Public License v1.0"
|
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 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
// INCLUDES
|
|
20 |
#include "SIPExGameEngine.h"
|
|
21 |
#include "SIPExStateViewNotifier.h"
|
|
22 |
#include "SIPExGameObserver.h"
|
|
23 |
#include "SIPExStateAcceptingSIP.h"
|
|
24 |
#include "SIPExStateConnecting.h"
|
|
25 |
#include "SIPExStateIdle.h"
|
|
26 |
#include "SIPExStateInviting.h"
|
|
27 |
#include "SIPExStateLocal.h"
|
|
28 |
#include "SIPExStateRemote.h"
|
|
29 |
#include "SIPExStateRegistering.h"
|
|
30 |
#include "SIPExStateRegistered.h"
|
|
31 |
#include "SIPExSocketEngine.h"
|
|
32 |
#include "SIPExSIPEngine.h"
|
|
33 |
#include "SIPExEngine.pan"
|
|
34 |
#include <in_sock.h> // TInetAddr
|
|
35 |
|
|
36 |
// Remove exports in unit test build
|
|
37 |
#ifdef CPPUNIT_TEST
|
|
38 |
#undef EXPORT_C
|
|
39 |
#define EXPORT_C
|
|
40 |
#endif
|
|
41 |
|
|
42 |
// CONSTANTS
|
1
|
43 |
const TUid KUidSIPExApp = { 0xE00001EB };
|
0
|
44 |
|
|
45 |
// -----------------------------------------------------------------------------
|
|
46 |
// CSIPExEngine::NewL
|
|
47 |
// Static constructor.
|
|
48 |
// -----------------------------------------------------------------------------
|
|
49 |
//
|
|
50 |
EXPORT_C CSIPExEngine* CSIPExEngine::NewL( MSIPExGameObserver& aGameObserver )
|
|
51 |
{
|
|
52 |
CSIPExEngine* self = NewLC( aGameObserver );
|
|
53 |
CleanupStack::Pop(self);
|
|
54 |
return self;
|
|
55 |
}
|
|
56 |
|
|
57 |
// -----------------------------------------------------------------------------
|
|
58 |
// CSIPExEngine::NewLC
|
|
59 |
// Static constructor. The instance is left to the CleanupStack.
|
|
60 |
// -----------------------------------------------------------------------------
|
|
61 |
//
|
|
62 |
EXPORT_C CSIPExEngine* CSIPExEngine::NewLC( MSIPExGameObserver& aGameObserver )
|
|
63 |
{
|
|
64 |
CSIPExEngine* self = new (ELeave) CSIPExEngine( aGameObserver );
|
|
65 |
CleanupStack::PushL(self);
|
|
66 |
self->ConstructL();
|
|
67 |
return self;
|
|
68 |
}
|
|
69 |
|
|
70 |
// -----------------------------------------------------------------------------
|
|
71 |
// CSIPExEngine::CSIPExEngine
|
|
72 |
// C++ default constructor. Initializes the observer member variable.
|
|
73 |
// -----------------------------------------------------------------------------
|
|
74 |
//
|
|
75 |
CSIPExEngine::CSIPExEngine( MSIPExGameObserver& aGameObserver )
|
|
76 |
: iGameObserver( aGameObserver )
|
|
77 |
{
|
|
78 |
}
|
|
79 |
|
|
80 |
// -----------------------------------------------------------------------------
|
|
81 |
// CSIPExEngine::~CSIPExEngine
|
|
82 |
// Destructor. Destroy all members.
|
|
83 |
// -----------------------------------------------------------------------------
|
|
84 |
//
|
|
85 |
EXPORT_C CSIPExEngine::~CSIPExEngine()
|
|
86 |
{
|
|
87 |
DestroySocketEngine();
|
|
88 |
delete iSIPEngine;
|
|
89 |
|
|
90 |
// Delete all state objects
|
|
91 |
delete iStateIdle;
|
|
92 |
delete iStateRegistering;
|
|
93 |
delete iStateRegistered;
|
|
94 |
delete iStateInviting;
|
|
95 |
delete iStateConnecting;
|
|
96 |
delete iStateLocal;
|
|
97 |
delete iStateRemote;
|
|
98 |
delete iStateAcceptingSIP;
|
|
99 |
}
|
|
100 |
|
|
101 |
// -----------------------------------------------------------------------------
|
|
102 |
// CSIPExEngine::ConstructL
|
|
103 |
// Symbian 2nd phase constructor can leave.
|
|
104 |
// Initializes the game data, socket and sip engines and all state objects.
|
|
105 |
// -----------------------------------------------------------------------------
|
|
106 |
//
|
|
107 |
void CSIPExEngine::ConstructL()
|
|
108 |
{
|
|
109 |
// Init all state objects
|
|
110 |
iStateIdle = new (ELeave) TSIPExStateIdle;
|
|
111 |
iStateRegistering = new (ELeave) TSIPExStateRegistering;
|
|
112 |
iStateRegistered = new (ELeave) TSIPExStateRegistered;
|
|
113 |
iStateInviting = new (ELeave) TSIPExStateInviting;
|
|
114 |
iStateConnecting = new (ELeave) TSIPExStateConnecting;
|
|
115 |
iStateLocal = new (ELeave) TSIPExStateLocal;
|
|
116 |
iStateRemote = new (ELeave) TSIPExStateRemote;
|
|
117 |
iStateAcceptingSIP = new (ELeave) TSIPExStateAcceptingSIP;
|
|
118 |
|
|
119 |
iSocketEngine = CSIPExSocketEngine::NewL( *this );
|
|
120 |
iSIPEngine = CSIPExSIPEngine::NewL( KUidSIPExApp, this );
|
|
121 |
|
|
122 |
// Set the first state as active state
|
|
123 |
iActiveState = iStateIdle;
|
|
124 |
|
|
125 |
// Reset game data
|
|
126 |
ResetGame();
|
|
127 |
}
|
|
128 |
|
|
129 |
|
|
130 |
// ----------------------------------------------------------------------------
|
|
131 |
// New functions.
|
|
132 |
// ----------------------------------------------------------------------------
|
|
133 |
|
|
134 |
// -----------------------------------------------------------------------------
|
|
135 |
// CSIPExEngine::SetViewNotifier
|
|
136 |
// Sets a new reference to the iNotifier.
|
|
137 |
// -----------------------------------------------------------------------------
|
|
138 |
//
|
|
139 |
EXPORT_C void CSIPExEngine::SetViewNotifier( MSIPExStateViewNotifier& aNotifier )
|
|
140 |
{
|
|
141 |
iNotifier = &aNotifier;
|
|
142 |
}
|
|
143 |
|
|
144 |
// -----------------------------------------------------------------------------
|
|
145 |
// CSIPExEngine::ResetGame
|
|
146 |
// Resets the game area, moves and cursor position.
|
|
147 |
// -----------------------------------------------------------------------------
|
|
148 |
//
|
|
149 |
void CSIPExEngine::ResetGame()
|
|
150 |
{
|
|
151 |
for ( TInt i=0 ; i < KBoxCountX; i++ )
|
|
152 |
{
|
|
153 |
for ( TInt j=0 ; j < KBoxCountY; j++ )
|
|
154 |
{
|
|
155 |
iBoard[i][j] = -1;
|
|
156 |
}
|
|
157 |
}
|
|
158 |
|
|
159 |
iCursor = 0;
|
|
160 |
iMoves = 0;
|
|
161 |
iPeer = EUnknown;
|
|
162 |
}
|
|
163 |
|
|
164 |
// -----------------------------------------------------------------------------
|
|
165 |
// CSIPExEngine::SetBoard
|
|
166 |
// Sets the value (aValue) to the board to the place specified in aX and aY.
|
|
167 |
// -----------------------------------------------------------------------------
|
|
168 |
//
|
|
169 |
void CSIPExEngine::SetBoard( const TInt aX, const TInt aY, const TInt aValue )
|
|
170 |
{
|
|
171 |
__ASSERT_DEBUG( aX < KBoxCountX && aY < KBoxCountY,
|
|
172 |
Panic( EBoardValueOOR ) );
|
|
173 |
iBoard[ aX ][ aY ] = aValue;
|
|
174 |
}
|
|
175 |
|
|
176 |
// -----------------------------------------------------------------------------
|
|
177 |
// CSIPExEngine::IncreaseMovesBy
|
|
178 |
// Increases the iMoves by aAmount.
|
|
179 |
// -----------------------------------------------------------------------------
|
|
180 |
//
|
|
181 |
void CSIPExEngine::IncreaseMovesBy( const TInt aAmount )
|
|
182 |
{
|
|
183 |
iMoves += aAmount;
|
|
184 |
}
|
|
185 |
|
|
186 |
// -----------------------------------------------------------------------------
|
|
187 |
// CSIPExEngine::BoardValue
|
|
188 |
// Returns the board value from the specified place.
|
|
189 |
// -----------------------------------------------------------------------------
|
|
190 |
//
|
|
191 |
EXPORT_C TInt CSIPExEngine::BoardValue( TInt aX, TInt aY )
|
|
192 |
{
|
|
193 |
__ASSERT_DEBUG( aX < KBoxCountX && aY < KBoxCountY,
|
|
194 |
Panic( EBoardValueOOR ) );
|
|
195 |
return iBoard[ aX ][ aY ];
|
|
196 |
}
|
|
197 |
|
|
198 |
// -----------------------------------------------------------------------------
|
|
199 |
// CSIPExEngine::Cursor
|
|
200 |
// Returns the iCursor value.
|
|
201 |
// -----------------------------------------------------------------------------
|
|
202 |
//
|
|
203 |
EXPORT_C TInt CSIPExEngine::Cursor()
|
|
204 |
{
|
|
205 |
return iCursor;
|
|
206 |
}
|
|
207 |
|
|
208 |
// -----------------------------------------------------------------------------
|
|
209 |
// CSIPExEngine::SetCursor
|
|
210 |
// Sets a new value to the iCursor.
|
|
211 |
// -----------------------------------------------------------------------------
|
|
212 |
//
|
|
213 |
void CSIPExEngine::SetCursor( const TInt aNewValue )
|
|
214 |
{
|
|
215 |
iCursor = aNewValue;
|
|
216 |
}
|
|
217 |
|
|
218 |
// -----------------------------------------------------------------------------
|
|
219 |
// CSIPExEngine::ChangeState
|
|
220 |
// Changes a new value to the iActiveState and notifies the game observer.
|
|
221 |
// -----------------------------------------------------------------------------
|
|
222 |
//
|
|
223 |
void CSIPExEngine::ChangeState( TSIPExState& aNewState )
|
|
224 |
{
|
|
225 |
iActiveState = &aNewState;
|
|
226 |
|
|
227 |
TEngineState state( EIdle );
|
|
228 |
if( iActiveState == iStateIdle || iActiveState == iStateRegistering )
|
|
229 |
{
|
|
230 |
state = EIdle;
|
|
231 |
}
|
|
232 |
else if( iActiveState == iStateRegistered )
|
|
233 |
{
|
|
234 |
state = EEnabled;
|
|
235 |
}
|
|
236 |
else if ( iActiveState == iStateInviting ||
|
|
237 |
iActiveState == iStateAcceptingSIP ||
|
|
238 |
iActiveState == iStateConnecting )
|
|
239 |
{
|
|
240 |
state = EActivating;
|
|
241 |
}
|
|
242 |
else if( iActiveState == iStateLocal || iActiveState == iStateRemote )
|
|
243 |
{
|
|
244 |
state = EActive;
|
|
245 |
}
|
|
246 |
else { /*Nothing to do*/ }
|
|
247 |
|
|
248 |
iGameObserver.GameStateChanged( state );
|
|
249 |
}
|
|
250 |
|
|
251 |
// -----------------------------------------------------------------------------
|
|
252 |
// CSIPExEngine::SendMessage
|
|
253 |
// Formats and sends the message to the socket.
|
|
254 |
// -----------------------------------------------------------------------------
|
|
255 |
//
|
|
256 |
void CSIPExEngine::SendMessage( const TInt aX, const TInt aY )
|
|
257 |
{
|
|
258 |
__ASSERT_DEBUG( aX < KBoxCountX && aY < KBoxCountY,
|
|
259 |
Panic( EBoardValueOOR ) );
|
|
260 |
|
|
261 |
TBuf8<8> msg;
|
|
262 |
msg.Format( KMoveFormatStr(), aX, aY );
|
|
263 |
|
|
264 |
iSocketEngine->Write( msg );
|
|
265 |
}
|
|
266 |
|
|
267 |
// -----------------------------------------------------------------------------
|
|
268 |
// CSIPExEngine::Info
|
|
269 |
// Calls the view notifier.
|
|
270 |
// -----------------------------------------------------------------------------
|
|
271 |
//
|
|
272 |
void CSIPExEngine::InfoL( const TDesC& aInfoTxt )
|
|
273 |
{
|
|
274 |
__ASSERT_DEBUG( iNotifier, Panic( ENoGameViewNotifier ) );
|
|
275 |
|
|
276 |
iNotifier->ShowInfoL( aInfoTxt );
|
|
277 |
}
|
|
278 |
|
|
279 |
// -----------------------------------------------------------------------------
|
|
280 |
// CSIPExEngine::StatusInfo
|
|
281 |
// Calls the view notifier.
|
|
282 |
// -----------------------------------------------------------------------------
|
|
283 |
//
|
|
284 |
void CSIPExEngine::StatusInfoL( const TDesC& aTxt )
|
|
285 |
{
|
|
286 |
__ASSERT_DEBUG( iNotifier, Panic( ENoGameViewNotifier ) );
|
|
287 |
|
|
288 |
iNotifier->ShowStatusInfoL( aTxt );
|
|
289 |
}
|
|
290 |
|
|
291 |
// -----------------------------------------------------------------------------
|
|
292 |
// CSIPExEngine::SetRemote
|
|
293 |
// Sets the remote peer move to the board into the specified place.
|
|
294 |
// -----------------------------------------------------------------------------
|
|
295 |
//
|
|
296 |
void CSIPExEngine::SetRemote( const TInt aX, const TInt aY )
|
|
297 |
{
|
|
298 |
SetBoard( aX, aY, 2 );
|
|
299 |
}
|
|
300 |
|
|
301 |
// -----------------------------------------------------------------------------
|
|
302 |
// CSIPExEngine::DestroySocketEngine
|
|
303 |
// Deletes the socket engine.
|
|
304 |
// -----------------------------------------------------------------------------
|
|
305 |
//
|
|
306 |
void CSIPExEngine::DestroySocketEngine()
|
|
307 |
{
|
|
308 |
delete iSocketEngine;
|
|
309 |
iSocketEngine = NULL;
|
|
310 |
}
|
|
311 |
|
|
312 |
// -----------------------------------------------------------------------------
|
|
313 |
// CSIPExEngine::SIPEngine
|
|
314 |
// Returns the pointer to the SIP engine. The ownership is not transfered.
|
|
315 |
// -----------------------------------------------------------------------------
|
|
316 |
//
|
|
317 |
CSIPExSIPEngine* CSIPExEngine::SIPEngine()
|
|
318 |
{
|
|
319 |
return iSIPEngine;
|
|
320 |
}
|
|
321 |
|
|
322 |
// -----------------------------------------------------------------------------
|
|
323 |
// CSIPExEngine::SocketEngine
|
|
324 |
// Returns the pointer to the socket engine. The ownership is not transfered.
|
|
325 |
// The engine will be created if not already done.
|
|
326 |
// -----------------------------------------------------------------------------
|
|
327 |
//
|
|
328 |
CSIPExSocketEngine* CSIPExEngine::SocketEngineL()
|
|
329 |
{
|
|
330 |
if( !iSocketEngine )
|
|
331 |
{
|
|
332 |
iSocketEngine = CSIPExSocketEngine::NewL( *this );
|
|
333 |
}
|
|
334 |
return iSocketEngine;
|
|
335 |
}
|
|
336 |
|
|
337 |
// -----------------------------------------------------------------------------
|
|
338 |
// CSIPExEngine::GameObserver
|
|
339 |
// Returns the reference to the game observer.
|
|
340 |
// -----------------------------------------------------------------------------
|
|
341 |
//
|
|
342 |
MSIPExGameObserver& CSIPExEngine::GameObserver()
|
|
343 |
{
|
|
344 |
return iGameObserver;
|
|
345 |
}
|
|
346 |
|
|
347 |
// ----------------------------------------------------------------------------
|
|
348 |
// From Game engine
|
|
349 |
// ----------------------------------------------------------------------------
|
|
350 |
|
|
351 |
// -----------------------------------------------------------------------------
|
|
352 |
// CSIPExEngine::InviteL
|
|
353 |
// From MSIPExGameEngine. Redirects the call to the active state object.
|
|
354 |
// -----------------------------------------------------------------------------
|
|
355 |
//
|
|
356 |
EXPORT_C void CSIPExEngine::InviteL( const TDesC& aAddress )
|
|
357 |
{
|
|
358 |
iActiveState->InviteL( this, aAddress );
|
|
359 |
}
|
|
360 |
|
|
361 |
// -----------------------------------------------------------------------------
|
|
362 |
// CSIPExEngine::EnableProfile
|
|
363 |
// From MSIPExGameEngine. Redirects the call to the active state object.
|
|
364 |
// -----------------------------------------------------------------------------
|
|
365 |
//
|
|
366 |
EXPORT_C void CSIPExEngine::EnableProfileL()
|
|
367 |
{
|
|
368 |
iActiveState->EnableProfileL( this );
|
|
369 |
}
|
|
370 |
|
|
371 |
// -----------------------------------------------------------------------------
|
|
372 |
// CSIPExEngine::DisableProfile
|
|
373 |
// From MSIPExGameEngine. Redirects the call to the active state object.
|
|
374 |
// -----------------------------------------------------------------------------
|
|
375 |
//
|
|
376 |
EXPORT_C void CSIPExEngine::DisableProfileL()
|
|
377 |
{
|
|
378 |
iActiveState->DisableProfileL( this );
|
|
379 |
}
|
|
380 |
|
|
381 |
// -----------------------------------------------------------------------------
|
|
382 |
// CSIPExEngine::SendInstantMsgL
|
|
383 |
// From MSIPExGameEngine. Redirects the call to the active state object.
|
|
384 |
// -----------------------------------------------------------------------------
|
|
385 |
//
|
|
386 |
EXPORT_C void CSIPExEngine::SendInstantMsgL(
|
|
387 |
const TDesC& aAddress,
|
|
388 |
const TDesC& aMsg )
|
|
389 |
{
|
|
390 |
iActiveState->SendInstantMsgL( this, aAddress, aMsg );
|
|
391 |
}
|
|
392 |
|
|
393 |
// -----------------------------------------------------------------------------
|
|
394 |
// CSIPExEngine::EndGameL
|
|
395 |
// From MSIPExGameEngine. Redirects the call to the active state object.
|
|
396 |
// -----------------------------------------------------------------------------
|
|
397 |
//
|
|
398 |
EXPORT_C void CSIPExEngine::EndGameL()
|
|
399 |
{
|
|
400 |
iActiveState->EndGameL( this );
|
|
401 |
}
|
|
402 |
|
|
403 |
// -----------------------------------------------------------------------------
|
|
404 |
// CSIPExEngine::DrawCursor
|
|
405 |
// From MSIPExGameEngine. Redirects the call to the active state object.
|
|
406 |
// -----------------------------------------------------------------------------
|
|
407 |
//
|
|
408 |
EXPORT_C TBool CSIPExEngine::DrawCursor()
|
|
409 |
{
|
|
410 |
return iActiveState->DrawCursor();
|
|
411 |
}
|
|
412 |
|
|
413 |
// -----------------------------------------------------------------------------
|
|
414 |
// CSIPExEngine::DrawBoard
|
|
415 |
// From MSIPExGameEngine. Redirects the call to the active state object.
|
|
416 |
// -----------------------------------------------------------------------------
|
|
417 |
//
|
|
418 |
EXPORT_C TBool CSIPExEngine::DrawBoard()
|
|
419 |
{
|
|
420 |
return iActiveState->DrawBoard();
|
|
421 |
}
|
|
422 |
|
|
423 |
// -----------------------------------------------------------------------------
|
|
424 |
// CSIPExEngine::CursorLeft
|
|
425 |
// From MSIPExGameEngine. Redirects the call to the active state object.
|
|
426 |
// -----------------------------------------------------------------------------
|
|
427 |
//
|
|
428 |
EXPORT_C void CSIPExEngine::CursorLeft()
|
|
429 |
{
|
|
430 |
iActiveState->CursorLeft( this );
|
|
431 |
}
|
|
432 |
|
|
433 |
// -----------------------------------------------------------------------------
|
|
434 |
// CSIPExEngine::CursorRight
|
|
435 |
// From MSIPExGameEngine. Redirects the call to the active state object.
|
|
436 |
// -----------------------------------------------------------------------------
|
|
437 |
//
|
|
438 |
EXPORT_C void CSIPExEngine::CursorRight()
|
|
439 |
{
|
|
440 |
iActiveState->CursorRight( this );
|
|
441 |
}
|
|
442 |
|
|
443 |
// -----------------------------------------------------------------------------
|
|
444 |
// CSIPExEngine::CursorPressed
|
|
445 |
// Redirects the call to the active state object.
|
|
446 |
// -----------------------------------------------------------------------------
|
|
447 |
//
|
|
448 |
EXPORT_C void CSIPExEngine::CursorPressed()
|
|
449 |
{
|
|
450 |
iActiveState->CursorPressed( this );
|
|
451 |
}
|
|
452 |
|
|
453 |
// -----------------------------------------------------------------------------
|
|
454 |
// CSIPExEngine::MoveCursorL
|
|
455 |
// Redirects the call to the active state object.
|
|
456 |
// -----------------------------------------------------------------------------
|
|
457 |
//
|
|
458 |
EXPORT_C void CSIPExEngine::MoveCursorL( const TInt aNewValue )
|
|
459 |
{
|
|
460 |
iActiveState->MoveCursorL( this, aNewValue );
|
|
461 |
}
|
|
462 |
|
|
463 |
// -----------------------------------------------------------------------------
|
|
464 |
// CSIPExEngine::CalculatePos
|
|
465 |
// From MSIPExGameEngine. Redirects the call to the active state object.
|
|
466 |
// -----------------------------------------------------------------------------
|
|
467 |
//
|
|
468 |
TInt CSIPExEngine::CalculatePos()
|
|
469 |
{
|
|
470 |
return iActiveState->CalculatePos( this );
|
|
471 |
}
|
|
472 |
|
|
473 |
// -----------------------------------------------------------------------------
|
|
474 |
// CSIPExEngine::IsWin
|
|
475 |
// From MSIPExGameEngine. Redirects the call to the active state object.
|
|
476 |
// -----------------------------------------------------------------------------
|
|
477 |
//
|
|
478 |
TInt CSIPExEngine::IsWin( const TInt aX, const TInt aY )
|
|
479 |
{
|
|
480 |
return iActiveState->IsWin( this, aX, aY );
|
|
481 |
}
|
|
482 |
|
|
483 |
// -----------------------------------------------------------------------------
|
|
484 |
// CSIPExEngine::Moves
|
|
485 |
// Getter function for the iMoves.
|
|
486 |
// -----------------------------------------------------------------------------
|
|
487 |
//
|
|
488 |
TInt CSIPExEngine::Moves()
|
|
489 |
{
|
|
490 |
return iMoves;
|
|
491 |
}
|
|
492 |
|
|
493 |
// -----------------------------------------------------------------------------
|
|
494 |
// CSIPExEngine::Peer
|
|
495 |
// Getter function for the iPeer.
|
|
496 |
// -----------------------------------------------------------------------------
|
|
497 |
//
|
|
498 |
CSIPExEngine::TPeer CSIPExEngine::Peer()
|
|
499 |
{
|
|
500 |
return iPeer;
|
|
501 |
}
|
|
502 |
|
|
503 |
// -----------------------------------------------------------------------------
|
|
504 |
// CSIPExEngine::SetPeer
|
|
505 |
// Sets a new value to the iPeer.
|
|
506 |
// -----------------------------------------------------------------------------
|
|
507 |
//
|
|
508 |
void CSIPExEngine::SetPeer( TPeer aPeer )
|
|
509 |
{
|
|
510 |
iPeer = aPeer;
|
|
511 |
}
|
|
512 |
|
|
513 |
// -----------------------------------------------------------------------------
|
|
514 |
// CSIPExEngine::AcceptInvitationL
|
|
515 |
// Asks from game observer whether user accept the invitation or not.
|
|
516 |
// -----------------------------------------------------------------------------
|
|
517 |
//
|
|
518 |
TBool CSIPExEngine::AcceptInvitationL( const TDesC8& aFrom )
|
|
519 |
{
|
|
520 |
HBufC* from = HBufC::NewLC( aFrom.Length() );
|
|
521 |
from->Des().Copy( aFrom );
|
|
522 |
TBool retVal = iGameObserver.AcceptInvitationL( *from );
|
|
523 |
CleanupStack::PopAndDestroy( from );
|
|
524 |
return retVal;
|
|
525 |
}
|
|
526 |
|
|
527 |
// ----------------------------------------------------------------------------
|
|
528 |
// From Socket Observer
|
|
529 |
// ----------------------------------------------------------------------------
|
|
530 |
|
|
531 |
// -----------------------------------------------------------------------------
|
|
532 |
// CSIPExEngine::SocketState
|
|
533 |
// From MSIPExSocketEngineObserver. Redirects the call to the active state object.
|
|
534 |
// Called when the socket engine's state changes.
|
|
535 |
// -----------------------------------------------------------------------------
|
|
536 |
//
|
|
537 |
void CSIPExEngine::SocketState( TInt aNewState )
|
|
538 |
{
|
|
539 |
iActiveState->SocketState( this, aNewState );
|
|
540 |
}
|
|
541 |
|
|
542 |
// -----------------------------------------------------------------------------
|
|
543 |
// CSIPExEngine::SocketData
|
|
544 |
// From MSIPExSocketEngineObserver. Redirects the call to the active state object.
|
|
545 |
// Called when data has arrived from the socket.
|
|
546 |
// -----------------------------------------------------------------------------
|
|
547 |
//
|
|
548 |
void CSIPExEngine::SocketData( TDesC8& aData )
|
|
549 |
{
|
|
550 |
iActiveState->SocketData( this, aData );
|
|
551 |
}
|
|
552 |
|
|
553 |
// ----------------------------------------------------------------------------
|
|
554 |
// From SIP Observer
|
|
555 |
// ----------------------------------------------------------------------------
|
|
556 |
|
|
557 |
// -----------------------------------------------------------------------------
|
|
558 |
// CSIPExEngine::InviteReceived
|
|
559 |
// From MSIPExSIPEngineObserver. Redirects the call to the active state object.
|
|
560 |
// -----------------------------------------------------------------------------
|
|
561 |
//
|
|
562 |
void CSIPExEngine::InviteReceived( const TDesC8& aFrom, const TUint32 aIapId )
|
|
563 |
{
|
|
564 |
iActiveState->InviteReceived( this, aFrom, aIapId );
|
|
565 |
}
|
|
566 |
|
|
567 |
// -----------------------------------------------------------------------------
|
|
568 |
// CSIPExEngine::InviteAcceptedByRemote
|
|
569 |
// From MSIPExSIPEngineObserver. Redirects the call to the active state object.
|
|
570 |
// -----------------------------------------------------------------------------
|
|
571 |
//
|
|
572 |
void CSIPExEngine::InviteAcceptedByRemote(
|
|
573 |
const TInetAddr& aIPAddress,
|
|
574 |
const TUint32 aIapId )
|
|
575 |
{
|
|
576 |
iActiveState->InviteAcceptedByRemote( this, aIPAddress, aIapId );
|
|
577 |
}
|
|
578 |
|
|
579 |
// -----------------------------------------------------------------------------
|
|
580 |
// CSIPExEngine::InviteAcceptedByUs
|
|
581 |
// From MSIPExSIPEngineObserver. Redirects the call to the active state object.
|
|
582 |
// -----------------------------------------------------------------------------
|
|
583 |
//
|
|
584 |
void CSIPExEngine::InviteAcceptedByUs()
|
|
585 |
{
|
|
586 |
iActiveState->InviteAcceptedByUs( this );
|
|
587 |
}
|
|
588 |
|
|
589 |
// -----------------------------------------------------------------------------
|
|
590 |
// CSIPExEngine::InviteDeclinedByRemote
|
|
591 |
// From MSIPExSIPEngineObserver. Redirects the call to the active state object.
|
|
592 |
// -----------------------------------------------------------------------------
|
|
593 |
//
|
|
594 |
void CSIPExEngine::InviteDeclinedByRemote( const TInt aResponse )
|
|
595 |
{
|
|
596 |
iActiveState->InviteDeclinedByRemote( this, aResponse );
|
|
597 |
}
|
|
598 |
|
|
599 |
// -----------------------------------------------------------------------------
|
|
600 |
// CSIPExEngine::InviteReceivedByRemote
|
|
601 |
// From MSIPExSIPEngineObserver. Redirects the call to the active state object.
|
|
602 |
// -----------------------------------------------------------------------------
|
|
603 |
//
|
|
604 |
void CSIPExEngine::InviteReceivedByRemote( const TInt aResponse )
|
|
605 |
{
|
|
606 |
iActiveState->InviteReceivedByRemote( this, aResponse );
|
|
607 |
}
|
|
608 |
|
|
609 |
// -----------------------------------------------------------------------------
|
|
610 |
// CSIPExEngine::EngineError
|
|
611 |
// From MSIPExSIPEngineObserver. Redirects the call to the active state object.
|
|
612 |
// -----------------------------------------------------------------------------
|
|
613 |
//
|
|
614 |
void CSIPExEngine::EngineError( TInt aError )
|
|
615 |
{
|
|
616 |
iActiveState->EngineError( this, aError );
|
|
617 |
}
|
|
618 |
|
|
619 |
// -----------------------------------------------------------------------------
|
|
620 |
// CSIPExEngine::InvitationCancelled
|
|
621 |
// From MSIPExSIPEngineObserver. Redirects the call to the active state object.
|
|
622 |
// -----------------------------------------------------------------------------
|
|
623 |
//
|
|
624 |
void CSIPExEngine::InvitationCancelled()
|
|
625 |
{
|
|
626 |
iActiveState->InvitationCancelled( this );
|
|
627 |
}
|
|
628 |
|
|
629 |
// -----------------------------------------------------------------------------
|
|
630 |
// CSIPExEngine::CancelFailed
|
|
631 |
// From MSIPExSIPEngineObserver. Redirects the call to the active state object.
|
|
632 |
// -----------------------------------------------------------------------------
|
|
633 |
//
|
|
634 |
void CSIPExEngine::CancelFailed()
|
|
635 |
{
|
|
636 |
iActiveState->CancelFailed( this );
|
|
637 |
}
|
|
638 |
|
|
639 |
// -----------------------------------------------------------------------------
|
|
640 |
// CSIPExEngine::SessionEnded
|
|
641 |
// From MSIPExSIPEngineObserver. Redirects the call to the active state object.
|
|
642 |
// -----------------------------------------------------------------------------
|
|
643 |
//
|
|
644 |
void CSIPExEngine::SessionEnded()
|
|
645 |
{
|
|
646 |
iActiveState->SessionEnded( this );
|
|
647 |
}
|
|
648 |
|
|
649 |
// -----------------------------------------------------------------------------
|
|
650 |
// CSIPExEngine::ConnectionLost
|
|
651 |
// From MSIPExSIPEngineObserver. Redirects the call to the active state object.
|
|
652 |
// -----------------------------------------------------------------------------
|
|
653 |
//
|
|
654 |
void CSIPExEngine::ConnectionLost()
|
|
655 |
{
|
|
656 |
iActiveState->ConnectionLost( this );
|
|
657 |
}
|
|
658 |
|
|
659 |
// -----------------------------------------------------------------------------
|
|
660 |
// CSIPExEngine::ProfileEnabled
|
|
661 |
// From MSIPExSIPEngineObserver. Redirects the call to the active state object.
|
|
662 |
// -----------------------------------------------------------------------------
|
|
663 |
//
|
|
664 |
void CSIPExEngine::ProfileEnabled( TUint32 aSIPProfileId )
|
|
665 |
{
|
|
666 |
iActiveState->ProfileEnabled( this, aSIPProfileId );
|
|
667 |
}
|
|
668 |
|
|
669 |
// -----------------------------------------------------------------------------
|
|
670 |
// CSIPExEngine::ProfileError
|
|
671 |
// From MSIPExSIPEngineObserver. Redirects the call to the active state object.
|
|
672 |
// -----------------------------------------------------------------------------
|
|
673 |
//
|
|
674 |
void CSIPExEngine::ProfileError( TInt aError )
|
|
675 |
{
|
|
676 |
iActiveState->ProfileError( this, aError );
|
|
677 |
}
|
|
678 |
|
|
679 |
// -----------------------------------------------------------------------------
|
|
680 |
// CSIPExEngine::IMReceived
|
|
681 |
// From MSIPExSIPEngineObserver. Redirects the call to the active state object.
|
|
682 |
// -----------------------------------------------------------------------------
|
|
683 |
//
|
|
684 |
void CSIPExEngine::IMReceived( const TDesC8& aFrom,
|
|
685 |
const TDesC8& aMessage )
|
|
686 |
{
|
|
687 |
iActiveState->IMReceived( this, aFrom, aMessage );
|
|
688 |
}
|
|
689 |
|
|
690 |
// -----------------------------------------------------------------------------
|
|
691 |
// CSIPExEngine::WriteLog
|
|
692 |
// From MSIPExSIPEngineObserver. Logs SIP engine events
|
|
693 |
// -----------------------------------------------------------------------------
|
|
694 |
//
|
|
695 |
void CSIPExEngine::WriteLog( const TDesC8& aLog )
|
|
696 |
{
|
|
697 |
if( iNotifier )
|
|
698 |
{
|
|
699 |
TRAPD( ignore, iNotifier->ShowInfoL( aLog ) );
|
|
700 |
}
|
|
701 |
}
|
|
702 |
|
|
703 |
|
|
704 |
// End of file
|
|
705 |
|