|
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 CUpnpShowCommand class. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <upnpshowcommand.h> // CUpnpShowCommand |
|
21 #include <upnpcommandobserver.h> // CUpnpCommandObserver |
|
22 #include "upnpcommand.h" // CUpnpCommand |
|
23 #include "upnpcommandmain.h" // UpnpCommandMain::LoadL |
|
24 #include "upnpcommandcallbackadapter.h" // CUpnpCommandCallbackAdapter |
|
25 |
|
26 // -------------------------------------------------------------------------- |
|
27 // CUpnpShowCommand::NewL |
|
28 // Creates a new UpnpCommand for image and video showing purposes. |
|
29 // -------------------------------------------------------------------------- |
|
30 // |
|
31 EXPORT_C CUpnpShowCommand* CUpnpShowCommand::NewL() |
|
32 { |
|
33 // Create new CUpnpShowCommand instance |
|
34 CUpnpShowCommand* self = new (ELeave) CUpnpShowCommand( NULL ); |
|
35 CleanupStack::PushL( self ); |
|
36 self->ConstructL(); |
|
37 CleanupStack::Pop( self ); |
|
38 return self; |
|
39 } |
|
40 |
|
41 // -------------------------------------------------------------------------- |
|
42 // CUpnpShowCommand::NewL |
|
43 // Creates a new UpnpCommand for image and video showing purposes. |
|
44 // -------------------------------------------------------------------------- |
|
45 // |
|
46 EXPORT_C CUpnpShowCommand* CUpnpShowCommand::NewL( |
|
47 MUpnpCommandObserver* aObserver ) |
|
48 { |
|
49 // Check the availability |
|
50 if( !IsAvailableL() ) |
|
51 { |
|
52 User::Leave( KErrNotReady ); |
|
53 } |
|
54 |
|
55 // Create new CUpnpShowCommand instance |
|
56 CUpnpShowCommand* self = new (ELeave) CUpnpShowCommand( aObserver ); |
|
57 CleanupStack::PushL( self ); |
|
58 self->ConstructL(); |
|
59 CleanupStack::Pop( self ); |
|
60 return self; |
|
61 } |
|
62 |
|
63 // -------------------------------------------------------------------------- |
|
64 // CUpnpShowCommand::CUpnpShowCommand |
|
65 // Constructor |
|
66 // -------------------------------------------------------------------------- |
|
67 // |
|
68 CUpnpShowCommand::CUpnpShowCommand( MUpnpCommandObserver* aObserver) |
|
69 { |
|
70 iObserver = NULL; |
|
71 if( aObserver ) |
|
72 { |
|
73 iObserver = aObserver; |
|
74 } |
|
75 } |
|
76 |
|
77 // -------------------------------------------------------------------------- |
|
78 // CUpnpShowCommand::~CUpnpShowCommand |
|
79 // Destructor |
|
80 // -------------------------------------------------------------------------- |
|
81 // |
|
82 CUpnpShowCommand::~CUpnpShowCommand() |
|
83 { |
|
84 delete iCommand; |
|
85 iCommand = NULL; |
|
86 delete iAdapter; |
|
87 iAdapter = NULL; |
|
88 } |
|
89 |
|
90 // -------------------------------------------------------------------------- |
|
91 // CUpnpShowCommand::ConstructL |
|
92 // Second phase constructor |
|
93 // -------------------------------------------------------------------------- |
|
94 // |
|
95 void CUpnpShowCommand::ConstructL() |
|
96 { |
|
97 iCommand = UpnpCommandMain::LoadL( UpnpCommand::ECommandShow ); |
|
98 |
|
99 // Register to observer |
|
100 if( iObserver ) |
|
101 { |
|
102 iAdapter = new (ELeave) CUpnpCommandCallbackAdapter( iObserver ); |
|
103 iCommand->SetObserver( iAdapter ); |
|
104 } |
|
105 } |
|
106 |
|
107 // -------------------------------------------------------------------------- |
|
108 // CUpnpShowCommand::StartShowingL |
|
109 // Starts showing. Allocates Upnp Framework resources. |
|
110 // -------------------------------------------------------------------------- |
|
111 // |
|
112 EXPORT_C void CUpnpShowCommand::StartShowingL() |
|
113 { |
|
114 // Allocate Upnp Fw resources |
|
115 iCommand->AllocateResourcesL(); |
|
116 } |
|
117 |
|
118 // -------------------------------------------------------------------------- |
|
119 // CUpnpShowCommand::StopShowingL |
|
120 // Stops showing. Releases all Upnp Framework resources. |
|
121 // -------------------------------------------------------------------------- |
|
122 // |
|
123 EXPORT_C void CUpnpShowCommand::StopShowingL() |
|
124 { |
|
125 // Release Upnp Fw resources |
|
126 iCommand->ReleaseResources(); |
|
127 |
|
128 // Reset the file pipe |
|
129 iCommand->ResetFiles(); |
|
130 } |
|
131 |
|
132 // -------------------------------------------------------------------------- |
|
133 // CUpnpShowCommand::ShowImageL |
|
134 // Shows the given images on a remote Upnp Media Rendering device. |
|
135 // -------------------------------------------------------------------------- |
|
136 // |
|
137 EXPORT_C void CUpnpShowCommand::ShowImageL( const TDesC& aFilename ) |
|
138 { |
|
139 // Check param |
|
140 if( aFilename == KNullDesC ) |
|
141 { |
|
142 User::Leave( KErrArgument ); |
|
143 } |
|
144 |
|
145 |
|
146 // Push the filename into the parameter pipe |
|
147 iCommand->PushFileL( aFilename ); |
|
148 |
|
149 // Execute the command |
|
150 iCommand->ExecuteL(); |
|
151 } |
|
152 |
|
153 // -------------------------------------------------------------------------- |
|
154 // CUpnpShowCommand::ShowVideoL |
|
155 // Shows the given video on a remote Upnp Media Rendering device. |
|
156 // -------------------------------------------------------------------------- |
|
157 // |
|
158 EXPORT_C void CUpnpShowCommand::ShowVideoL( const TDesC& aFilename ) |
|
159 { |
|
160 // Check param |
|
161 if( aFilename == KNullDesC ) |
|
162 { |
|
163 User::Leave( KErrArgument ); |
|
164 } |
|
165 |
|
166 |
|
167 // Push the filename into the file pipe |
|
168 iCommand->PushFileL( aFilename ); |
|
169 |
|
170 // Execute the command |
|
171 iCommand->ExecuteL(); |
|
172 } |
|
173 |
|
174 // -------------------------------------------------------------------------- |
|
175 // CUpnpShowCommand::IsAvailableL |
|
176 // Returns the availability information of the command. |
|
177 // -------------------------------------------------------------------------- |
|
178 // |
|
179 EXPORT_C TBool CUpnpShowCommand::IsAvailableL() |
|
180 { |
|
181 // create a temporary plugin instance |
|
182 // then query command availability. |
|
183 TBool available = EFalse; |
|
184 TRAP_IGNORE( |
|
185 CUpnpCommand* temp = UpnpCommandMain::LoadL( UpnpCommand::ECommandShow ); |
|
186 CleanupStack::PushL( temp ); |
|
187 available = temp->IsAvailableL(); |
|
188 CleanupStack::PopAndDestroy( temp ); |
|
189 ); |
|
190 return available; |
|
191 } |
|
192 |
|
193 // End of File |