|
1 /* |
|
2 * Copyright (c) 2007 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: Implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "SIPConstants.h" |
|
19 #include "TCmdStopIAP.h" |
|
20 #include "CTcSIPContext.h" |
|
21 |
|
22 #include <es_sock.h> |
|
23 #include <es_enum_partner.h> |
|
24 |
|
25 /** |
|
26 * INPUT: |
|
27 * Headers: - |
|
28 * Parameters: IAPName |
|
29 * IDs: - |
|
30 * |
|
31 * OUTPUT: |
|
32 * Parameters: - |
|
33 * IDs: - |
|
34 */ |
|
35 void TCmdStopIAP::ExecuteL() |
|
36 { |
|
37 // -- Setup --------------------------------------------------------------- |
|
38 |
|
39 // Get mandatory IAPName |
|
40 TPtrC8 name = ExtractTextL( KParamIAPName ); |
|
41 |
|
42 TUint32 iapId = iContext.IAPIdL( name ); |
|
43 |
|
44 RSocketServ socketServ; |
|
45 User::LeaveIfError( socketServ.Connect() ); |
|
46 CleanupClosePushL( socketServ ); |
|
47 |
|
48 RConnection rcon; |
|
49 User::LeaveIfError( rcon.Open( socketServ ) ); |
|
50 CleanupClosePushL( rcon ); |
|
51 |
|
52 TUint activeCount( 0 ); |
|
53 User::LeaveIfError( rcon.EnumerateConnections( activeCount ) ); |
|
54 |
|
55 TBool closed( EFalse ); |
|
56 |
|
57 // Search correct connection info |
|
58 if( activeCount > 0 ) |
|
59 { |
|
60 for( TUint i = 1; i <= activeCount && !closed; i++ ) |
|
61 { |
|
62 TPckgBuf<TConnectionInfoV2> connectionInfoV2; |
|
63 User::LeaveIfError( rcon.GetConnectionInfo( i, connectionInfoV2 ) ); |
|
64 |
|
65 if ( connectionInfoV2().iIapId == iapId ) |
|
66 { |
|
67 // V2 con info cannot be used |
|
68 TConnectionInfo connectionInfo = static_cast<TConnectionInfo>( connectionInfoV2() ); |
|
69 |
|
70 User::LeaveIfError( rcon.Attach( TPckgBuf<TConnectionInfo>( connectionInfo ), |
|
71 RConnection::EAttachTypeNormal ) ); |
|
72 |
|
73 // Stop the connection |
|
74 User::LeaveIfError( rcon.Stop() ); |
|
75 closed = ETrue; |
|
76 } |
|
77 } |
|
78 } |
|
79 |
|
80 |
|
81 __ASSERT_ALWAYS( closed, User::Leave( KErrNotFound ) ); |
|
82 |
|
83 CleanupStack::PopAndDestroy( 2 ); // socketServ, rcon |
|
84 } |
|
85 |
|
86 TBool TCmdStopIAP::Match( const TTcIdentifier& aId ) |
|
87 { |
|
88 return TTcSIPCommandBase::Match( aId, _L8("StopIAP") ); |
|
89 } |
|
90 |
|
91 TTcCommandBase* TCmdStopIAP::CreateL( MTcTestContext& aContext ) |
|
92 { |
|
93 return new( ELeave ) TCmdStopIAP( aContext ); |
|
94 } |