|
1 // mrouter.cpp |
|
2 // |
|
3 // Copyright (c) 2007 - 2010 Accenture. All rights reserved. |
|
4 // This component and the accompanying materials are made available |
|
5 // under the terms of the "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 // Accenture - Initial contribution |
|
11 // |
|
12 |
|
13 #include <fshell/ioutils.h> |
|
14 #include <mrouterclient30.h> |
|
15 |
|
16 using namespace IoUtils; |
|
17 |
|
18 class CCmdMrouter : public CCommandBase |
|
19 { |
|
20 public: |
|
21 static CCommandBase* NewLC(); |
|
22 ~CCmdMrouter(); |
|
23 private: |
|
24 CCmdMrouter(); |
|
25 private: // From CCommandBase. |
|
26 virtual const TDesC& Name() const; |
|
27 virtual void DoRunL(); |
|
28 private: |
|
29 }; |
|
30 |
|
31 |
|
32 CCommandBase* CCmdMrouter::NewLC() |
|
33 { |
|
34 CCmdMrouter* self = new(ELeave) CCmdMrouter(); |
|
35 CleanupStack::PushL(self); |
|
36 self->BaseConstructL(); |
|
37 return self; |
|
38 } |
|
39 |
|
40 CCmdMrouter::~CCmdMrouter() |
|
41 { |
|
42 } |
|
43 |
|
44 CCmdMrouter::CCmdMrouter() |
|
45 { |
|
46 } |
|
47 |
|
48 const TDesC& CCmdMrouter::Name() const |
|
49 { |
|
50 _LIT(KName, "mrouter"); |
|
51 return KName; |
|
52 } |
|
53 |
|
54 #define CASE_RETURN_LIT(XXX) case XXX: { _LIT(_KLit, #XXX); return &_KLit; } |
|
55 #define DEFAULT_RETURN_LIT(XXX) default: { _LIT(_KLit, XXX); return &_KLit; } |
|
56 |
|
57 const TDesC* StringifyConnectionStatus(TmRouterProgressStatus aStatus) |
|
58 { |
|
59 switch (aStatus) |
|
60 { |
|
61 CASE_RETURN_LIT(EmRouterConnecting); |
|
62 CASE_RETURN_LIT(EmRouterConnected); |
|
63 CASE_RETURN_LIT(EmRouterDisconnected); |
|
64 CASE_RETURN_LIT(EmRouterDisconnecting); |
|
65 DEFAULT_RETURN_LIT("Unknown connection status"); |
|
66 } |
|
67 } |
|
68 |
|
69 void CCmdMrouter::DoRunL() |
|
70 { |
|
71 RmRouterClient30 mRouter; |
|
72 mRouter.OpenL(); |
|
73 CleanupClosePushL(mRouter); |
|
74 TmRouterConnectionStatus connectionStatus; |
|
75 mRouter.ConnectionStatus(connectionStatus); |
|
76 TName connectionName; |
|
77 mRouter.GetConnectionNameL(connectionName); |
|
78 CleanupStack::PopAndDestroy(&mRouter); |
|
79 |
|
80 Printf(_L("Connection status: %S\r\n"), StringifyConnectionStatus(connectionStatus.iStatus)); |
|
81 Printf(_L("Connection bearer: 0x%08x\r\n"), connectionStatus.iCurrentBearer.iUid); |
|
82 Printf(_L("Connection name: \"%S\"\r\n"), &connectionName); |
|
83 } |
|
84 |
|
85 |
|
86 EXE_BOILER_PLATE(CCmdMrouter) |
|
87 |