|
1 |
|
2 // Copyright (c) 2004-2009 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 // |
|
16 |
|
17 |
|
18 |
|
19 // INCLUDES |
|
20 #include "SIPExStateRegistered.h" |
|
21 #include "SIPExGameEngine.h" |
|
22 #include "SIPExSIPEngine.h" |
|
23 |
|
24 |
|
25 // ----------------------------------------------------------------------------- |
|
26 // TSIPExStateRegistered::InviteL |
|
27 // SIP engine is signaled to send invite to the specified address. |
|
28 // The UI is notified and the active state changed to the Inviting. |
|
29 // ----------------------------------------------------------------------------- |
|
30 // |
|
31 void TSIPExStateRegistered::InviteL( |
|
32 CSIPExEngine* aContext, |
|
33 const TDesC& aAddress ) |
|
34 { |
|
35 ChangeState( aContext, aContext->iStateInviting ); |
|
36 |
|
37 HBufC8* address = HBufC8::NewLC( aAddress.Length() ); |
|
38 address->Des().Copy( aAddress ); |
|
39 aContext->SIPEngine()->SendInviteL( *address ); |
|
40 aContext->InfoL( KInviting() ); |
|
41 aContext->InfoL( aAddress ); |
|
42 aContext->StatusInfoL( KGameStarting() ); |
|
43 CleanupStack::PopAndDestroy( address ); |
|
44 } |
|
45 |
|
46 // ----------------------------------------------------------------------------- |
|
47 // TSIPExStateRegistered::SendInstantMsgL |
|
48 // Calls base classes function to send the instant message. |
|
49 // ----------------------------------------------------------------------------- |
|
50 // |
|
51 void TSIPExStateRegistered::SendInstantMsgL( CSIPExEngine* aContext, |
|
52 const TDesC& aAddress, const TDesC& aMsg ) |
|
53 { |
|
54 HBufC8* addr = HBufC8::NewLC( aAddress.Length() ); |
|
55 addr->Des().Copy( aAddress ); |
|
56 |
|
57 HBufC8* msg = HBufC8::NewLC( aMsg.Length() ); |
|
58 msg->Des().Copy( aMsg ); |
|
59 |
|
60 aContext->SIPEngine()->CreateIML( *msg, *addr ); |
|
61 |
|
62 CleanupStack::PopAndDestroy( msg ); |
|
63 CleanupStack::PopAndDestroy( addr ); |
|
64 } |
|
65 |
|
66 // ----------------------------------------------------------------------------- |
|
67 // TSIPExStateRegistered::SessionEnded |
|
68 // Notifies the UI. |
|
69 // ----------------------------------------------------------------------------- |
|
70 // |
|
71 void TSIPExStateRegistered::SessionEnded( CSIPExEngine* aContext ) |
|
72 { |
|
73 // Keep track whether session ended while accept dialog was shown to user. |
|
74 iEnded = ETrue; |
|
75 |
|
76 Info( aContext, KSessionEnded() ); |
|
77 StatusInfo( aContext, KGameOver() ); |
|
78 TRAPD( ignore, aContext->SocketEngineL()->Stop() ); |
|
79 aContext->DestroySocketEngine(); |
|
80 } |
|
81 |
|
82 // ----------------------------------------------------------------------------- |
|
83 // TSIPExStateRegistered::InviteReceived |
|
84 // The acceptance is asked from the user and if accepted we reset game, start |
|
85 // listening socket and signal the SIP engine to send Accepted to the remote |
|
86 // peer. |
|
87 // ----------------------------------------------------------------------------- |
|
88 // |
|
89 void TSIPExStateRegistered::InviteReceived( |
|
90 CSIPExEngine* aContext, |
|
91 const TDesC8& aFrom, |
|
92 const TUint32 aIapId ) |
|
93 { |
|
94 iEnded = EFalse; |
|
95 |
|
96 TBool retVal( EFalse ); |
|
97 TRAPD( ignore, retVal = aContext->AcceptInvitationL( aFrom ) ); |
|
98 if ( iEnded ) |
|
99 { |
|
100 return; |
|
101 } |
|
102 if( retVal ) |
|
103 { |
|
104 StatusInfo( aContext, KGameStarting() ); |
|
105 ChangeState( aContext, aContext->iStateAcceptingSIP ); |
|
106 aContext->ResetGame(); |
|
107 aContext->SetPeer( CSIPExEngine::EServer ); |
|
108 Info( aContext, KListening() ); |
|
109 TInetAddr addr; |
|
110 TRAP( ignore, addr = |
|
111 aContext->SocketEngineL()->StartListeningL( aIapId ) ); |
|
112 Info( aContext, KAccepting() ); |
|
113 TRAP( ignore, aContext->SIPEngine()->AcceptInviteL( addr ) ); |
|
114 Info( aContext, KWaitingRemoteConn() ); |
|
115 } |
|
116 else |
|
117 { |
|
118 TRAP( ignore, aContext->SIPEngine()->DeclineInviteL() ); |
|
119 Info( aContext, KInviteDeclined() ); |
|
120 } |
|
121 } |
|
122 |
|
123 // ----------------------------------------------------------------------------- |
|
124 // TSIPExStateRegistered::DisableProfile |
|
125 // Disable profile and notify the UI. |
|
126 // ----------------------------------------------------------------------------- |
|
127 // |
|
128 void TSIPExStateRegistered::DisableProfileL( CSIPExEngine* aContext ) |
|
129 { |
|
130 ChangeState( aContext, aContext->iStateIdle ); |
|
131 aContext->SIPEngine()->DisableProfileL(); |
|
132 aContext->InfoL( KProfileDisabled() ); |
|
133 } |
|
134 |
|
135 // ----------------------------------------------------------------------------- |
|
136 // TSIPExStateRegistered::SocketState |
|
137 // Notify the UI. |
|
138 // ----------------------------------------------------------------------------- |
|
139 // |
|
140 void TSIPExStateRegistered::SocketState( CSIPExEngine* aContext, TInt aNewState ) |
|
141 { |
|
142 if( aNewState == CSIPExSocketEngine::ENotConnected ) |
|
143 { |
|
144 Info( aContext, KConnectionDropped() ); |
|
145 StatusInfo( aContext, KGameOver() ); |
|
146 } |
|
147 } |
|
148 |
|
149 // End of file |