|
1 /* |
|
2 * Copyright (c) 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: Implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "CTcSIPContext.h" |
|
19 #include "SIPConstants.h" |
|
20 #include "TCmdGetClientDiscoveryStatus.h" |
|
21 #include "CTcSIPClientDiscoveryContainer.h" |
|
22 |
|
23 /** |
|
24 * INPUT: |
|
25 * Headers: - |
|
26 * Parameters: Timeout* |
|
27 * IDs: - |
|
28 * |
|
29 * OUTPUT: |
|
30 * Parameters: ClientDiscoveryRequestId, ClientDiscoveryErrorCode, |
|
31 * ApplicationUid, ClientDiscoveryStatus |
|
32 * |
|
33 * IDs: |
|
34 */ |
|
35 void TCmdGetClientDiscoveryStatus::ExecuteL() |
|
36 { |
|
37 // Get an item off the receive queue (waits until timeout if none is present) |
|
38 // |
|
39 TInt timeout = ExtractIntegerL( KParamTimeout, KDefaultReceiveTimeout, EFalse ); |
|
40 |
|
41 TTcClientDiscoveryEvent event = |
|
42 iContext.ClientDiscoveryL().ReceivedClientDiscoveryEventL( timeout ); |
|
43 |
|
44 |
|
45 // Create response |
|
46 // |
|
47 AddIntegerResponseL( |
|
48 KParamClientDiscoveryRequestId, static_cast<TInt>( event.iRequestId ) ); |
|
49 AddIntegerResponseL( KParamClientDiscoveryErrorCode, event.iError ); |
|
50 |
|
51 const TInt KMaxTUidAsTextLength = 11; |
|
52 TBuf8<KMaxTUidAsTextLength> uidText; |
|
53 uidText.AppendFormat( _L8("0x%x"), event.iChannel.iUid ); |
|
54 AddTextResponseL( KParamApplicationUid, uidText ); |
|
55 |
|
56 TPtrC8 status; |
|
57 switch( event.iType ) |
|
58 { |
|
59 case ETcClientDiscoveryChannelResolved: |
|
60 { |
|
61 status.Set( KClientDiscoveryChannelResolved ); |
|
62 break; |
|
63 } |
|
64 case ETcClientDiscoveryClientNotFound: |
|
65 { |
|
66 status.Set( KClientDiscoveryClientNotFound ); |
|
67 break; |
|
68 } |
|
69 case ETcClientDiscoveryError: |
|
70 { |
|
71 status.Set( KClientDiscoveryErrorOccured ); |
|
72 break; |
|
73 } |
|
74 default: |
|
75 { |
|
76 status.Set( KUnknown ); |
|
77 break; |
|
78 } |
|
79 } |
|
80 |
|
81 AddTextResponseL( KParamClientDiscoveryStatus, status ); |
|
82 } |
|
83 |
|
84 |
|
85 TBool TCmdGetClientDiscoveryStatus::Match( const TTcIdentifier& aId ) |
|
86 { |
|
87 return TTcSIPCommandBase::Match( aId, _L8("GetClientDiscoveryStatus") ); |
|
88 } |
|
89 |
|
90 TTcCommandBase* TCmdGetClientDiscoveryStatus::CreateL( MTcTestContext& aContext ) |
|
91 { |
|
92 return new( ELeave ) TCmdGetClientDiscoveryStatus( aContext ); |
|
93 } |
|
94 |