|
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: Source file for CUpnpRunSetupCommand class. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <upnprunsetupcommand.h> // CUpnpRunSetupCommand |
|
21 #include "upnpcommand.h" // CUpnpCommand |
|
22 #include "upnpcommandmain.h" // UpnpCommandMain::LoadL |
|
23 |
|
24 // -------------------------------------------------------------------------- |
|
25 // CUpnpRunSetupCommand::NewL |
|
26 // Creates a new UpnpCommand for running the Upnp Fw's setup wizard. |
|
27 // -------------------------------------------------------------------------- |
|
28 // |
|
29 EXPORT_C CUpnpRunSetupCommand* CUpnpRunSetupCommand::NewL() |
|
30 { |
|
31 // Create new CUpnpRunSetupCommand instance |
|
32 CUpnpRunSetupCommand* self = new (ELeave) CUpnpRunSetupCommand(); |
|
33 CleanupStack::PushL( self ); |
|
34 self->ConstructL(); |
|
35 CleanupStack::Pop( self ); |
|
36 return self; |
|
37 } |
|
38 |
|
39 // -------------------------------------------------------------------------- |
|
40 // CUpnpRunSetupCommand::CUpnpRunSetupCommand |
|
41 // Constructor |
|
42 // -------------------------------------------------------------------------- |
|
43 // |
|
44 CUpnpRunSetupCommand::CUpnpRunSetupCommand() |
|
45 { |
|
46 // No implementation |
|
47 } |
|
48 |
|
49 // -------------------------------------------------------------------------- |
|
50 // CUpnpRunSetupCommand::~CUpnpRunSetupCommand |
|
51 // Destructor |
|
52 // -------------------------------------------------------------------------- |
|
53 // |
|
54 CUpnpRunSetupCommand::~CUpnpRunSetupCommand() |
|
55 { |
|
56 delete iCommand; |
|
57 iCommand = NULL; |
|
58 } |
|
59 |
|
60 // -------------------------------------------------------------------------- |
|
61 // CUpnpRunSetupCommand::ConstructL |
|
62 // Second phase constructor |
|
63 // -------------------------------------------------------------------------- |
|
64 // |
|
65 void CUpnpRunSetupCommand::ConstructL() |
|
66 { |
|
67 iCommand = UpnpCommandMain::LoadL( UpnpCommand::ECommandSetup ); |
|
68 } |
|
69 |
|
70 // -------------------------------------------------------------------------- |
|
71 // CUpnpRunSetupCommand::BrowseHomeNetworkL |
|
72 // Allocates Upnp Framework resources, and starts up the Upnp Fw's setup |
|
73 // wizard. |
|
74 // -------------------------------------------------------------------------- |
|
75 // |
|
76 EXPORT_C void CUpnpRunSetupCommand::RunSetupL() |
|
77 { |
|
78 // Allocate Upnp Framework resources |
|
79 iCommand->AllocateResourcesL(); |
|
80 |
|
81 // Execute the command |
|
82 TRAPD( executeError, iCommand->ExecuteL() ); |
|
83 |
|
84 // Release Upnp Framework resources |
|
85 iCommand->ReleaseResources(); |
|
86 |
|
87 // Leave if operation failed |
|
88 if( executeError != KErrNone ) |
|
89 { |
|
90 User::Leave( executeError ); |
|
91 } |
|
92 } |
|
93 |
|
94 // -------------------------------------------------------------------------- |
|
95 // CUpnpRunSetupCommand::IsAvailableL |
|
96 // Returns the availability information of the command. |
|
97 // -------------------------------------------------------------------------- |
|
98 // |
|
99 EXPORT_C TBool CUpnpRunSetupCommand::IsAvailableL() |
|
100 { |
|
101 // create a temporary plugin instance |
|
102 // then query command availability. |
|
103 TBool available = EFalse; |
|
104 TRAP_IGNORE( |
|
105 CUpnpCommand* temp = UpnpCommandMain::LoadL( UpnpCommand::ECommandSetup ); |
|
106 CleanupStack::PushL( temp ); |
|
107 available = temp->IsAvailableL(); |
|
108 CleanupStack::PopAndDestroy( temp ); |
|
109 ); |
|
110 return available; |
|
111 } |
|
112 |
|
113 // End of File |