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