videocollection/hgmyvideos/src/vcxhgmyvideosupnpinterface.cpp
changeset 0 96612d01cf9f
equal deleted inserted replaced
-1:000000000000 0:96612d01cf9f
       
     1 /*
       
     2 * Copyright (c) 2008 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 the License "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:      CCVcxuPnPInterface class deifnition*
       
    15 */
       
    16 
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include <upnpshowcommand.h>
       
    22 #include "vcxhgmyvideosupnpinterface.h"
       
    23 
       
    24 // ============================ MEMBER FUNCTIONS ===============================
       
    25 
       
    26 // -----------------------------------------------------------------------------
       
    27 // CVcxHgMyVideosUPnPInterface::CVcxHgMyVideosuPnPInterface()
       
    28 // -----------------------------------------------------------------------------
       
    29 //
       
    30 CVcxHgMyVideosUPnPInterface::CVcxHgMyVideosUPnPInterface()
       
    31     {
       
    32     // No implementation required
       
    33     }
       
    34 
       
    35 // -----------------------------------------------------------------------------
       
    36 // CVcxHgMyVideosUPnPInterface::~CVcxHgMyVideosuPnPInterface()
       
    37 // -----------------------------------------------------------------------------
       
    38 //
       
    39 CVcxHgMyVideosUPnPInterface::~CVcxHgMyVideosUPnPInterface() 
       
    40     {
       
    41     Stop();
       
    42     delete iShowCommand;
       
    43     }
       
    44 
       
    45 // -----------------------------------------------------------------------------
       
    46 // CVcxHgMyVideosUPnPInterface::NewLC()
       
    47 // -----------------------------------------------------------------------------
       
    48 //
       
    49 CVcxHgMyVideosUPnPInterface* CVcxHgMyVideosUPnPInterface::NewLC( 
       
    50         MUpnpCommandObserver* aExtObserver )
       
    51     {
       
    52     CVcxHgMyVideosUPnPInterface* self = new ( ELeave )CVcxHgMyVideosUPnPInterface();
       
    53     CleanupStack::PushL(self);
       
    54     self->ConstructL();
       
    55     self->iExtObserver = aExtObserver;
       
    56     return self;
       
    57     }
       
    58 
       
    59 // -----------------------------------------------------------------------------
       
    60 // CVcxHgMyVideosUPnPInterface::NewL()
       
    61 // -----------------------------------------------------------------------------
       
    62 //
       
    63 CVcxHgMyVideosUPnPInterface* CVcxHgMyVideosUPnPInterface::NewL( 
       
    64         MUpnpCommandObserver* aExtObserver )
       
    65     {
       
    66     CVcxHgMyVideosUPnPInterface* self = CVcxHgMyVideosUPnPInterface::NewLC( aExtObserver );    
       
    67     CleanupStack::Pop(); // self;
       
    68     return self;
       
    69     }
       
    70 
       
    71 // -----------------------------------------------------------------------------
       
    72 // CVcxHgMyVideosUPnPInterface::ConstructL()
       
    73 // -----------------------------------------------------------------------------
       
    74 //
       
    75 void CVcxHgMyVideosUPnPInterface::ConstructL()
       
    76     {
       
    77     TryCreateCmd();
       
    78     }
       
    79 
       
    80 // -----------------------------------------------------------------------------
       
    81 // CVcxHgMyVideosUPnPInterface::TryCreateCmd()
       
    82 // -----------------------------------------------------------------------------
       
    83 //
       
    84 TBool CVcxHgMyVideosUPnPInterface::TryCreateCmd()
       
    85     {
       
    86     if( !iShowCommand )
       
    87         {
       
    88         TRAPD( showCreate, iShowCommand = CUpnpShowCommand::NewL( this ) );
       
    89         if( showCreate != KErrNone )
       
    90             {    
       
    91             iShowCommand = NULL;
       
    92             return EFalse;
       
    93             }
       
    94         }
       
    95     return ETrue;
       
    96     }
       
    97 
       
    98 // -----------------------------------------------------------------------------
       
    99 // CVcxHgMyVideosUPnPInterface::IsApplicable()
       
   100 // -----------------------------------------------------------------------------
       
   101 //
       
   102 TBool CVcxHgMyVideosUPnPInterface::IsApplicable() 
       
   103     {
       
   104 
       
   105     if( !TryCreateCmd() )
       
   106         {
       
   107         return EFalse;
       
   108         }
       
   109 
       
   110     TBool available( EFalse );
       
   111     TRAPD(err, available = iShowCommand->IsAvailableL() );
       
   112                
       
   113     if( err != KErrNone || !available ) 
       
   114         {
       
   115         return EFalse; 
       
   116         }
       
   117 
       
   118     return ETrue;
       
   119     }
       
   120 
       
   121 // -----------------------------------------------------------------------------
       
   122 // CVcxHgMyVideosUPnPInterface::IsStarted()
       
   123 // -----------------------------------------------------------------------------
       
   124 //
       
   125 TBool CVcxHgMyVideosUPnPInterface::IsStarted() 
       
   126     {
       
   127 
       
   128     if( !TryCreateCmd() )
       
   129         {
       
   130         return EFalse;        
       
   131         }
       
   132     return iStarted;
       
   133     }
       
   134 
       
   135 // -----------------------------------------------------------------------------
       
   136 // CVcxHgMyVideosUPnPInterface::Start()
       
   137 // -----------------------------------------------------------------------------
       
   138 //
       
   139 TInt CVcxHgMyVideosUPnPInterface::Start()
       
   140     { 
       
   141  
       
   142     if( !TryCreateCmd() )
       
   143         {
       
   144         iStarted = EFalse;
       
   145         return KErrGeneral;
       
   146         }
       
   147     TRAPD(err, iShowCommand->StartShowingL() );
       
   148     
       
   149     if( err != KErrNone )
       
   150         {
       
   151         iStarted = EFalse;
       
   152         }
       
   153     else
       
   154         {
       
   155         iStarted = ETrue;
       
   156         }
       
   157     return err;
       
   158     }
       
   159 
       
   160 // -----------------------------------------------------------------------------
       
   161 // CVcxHgMyVideosUPnPInterface::ShowVideo()
       
   162 // -----------------------------------------------------------------------------
       
   163 //
       
   164 TInt CVcxHgMyVideosUPnPInterface::ShowVideo( const TDesC& aVideoPath )
       
   165     {
       
   166     TInt err( KErrGeneral );   
       
   167     if( iStarted && aVideoPath.Length() > 0 && TryCreateCmd() )
       
   168         {
       
   169         TRAP( err, iShowCommand->ShowVideoL( aVideoPath ) );
       
   170         }  
       
   171     return err;
       
   172     }
       
   173  
       
   174 // -----------------------------------------------------------------------------
       
   175 // CVcxHgMyVideosUPnPInterface::ShowThumbnail()
       
   176 // -----------------------------------------------------------------------------
       
   177 //
       
   178 TInt CVcxHgMyVideosUPnPInterface::ShowThumbnail( const TDesC& aPath )
       
   179     {
       
   180     TInt err( KErrGeneral );
       
   181     if( iStarted && aPath.Length() > 0, TryCreateCmd() )
       
   182         {
       
   183         TRAP( err, iShowCommand->ShowImageL( aPath ) );  
       
   184         }
       
   185         
       
   186     return err;
       
   187     }
       
   188 
       
   189 // -----------------------------------------------------------------------------
       
   190 // CVcxHgMyVideosUPnPInterface::Stop()
       
   191 // -----------------------------------------------------------------------------
       
   192 //
       
   193 TInt CVcxHgMyVideosUPnPInterface::Stop()
       
   194     {
       
   195     TInt err( KErrNone );
       
   196     if( iStarted )
       
   197         {
       
   198         if(  TryCreateCmd() )
       
   199             {
       
   200             TRAP( err, iShowCommand->StopShowingL( ) );
       
   201             }
       
   202         else
       
   203             {
       
   204             err = KErrGeneral;
       
   205             }
       
   206         iStarted = EFalse;
       
   207         }
       
   208     return err;
       
   209     }
       
   210 
       
   211 // -----------------------------------------------------------------------------
       
   212 // CVcxHgMyVideosUPnPInterface::CommandComplete()
       
   213 // -----------------------------------------------------------------------------
       
   214 //
       
   215 void CVcxHgMyVideosUPnPInterface::CommandComplete( TInt aStatusCode )
       
   216     {
       
   217     if( aStatusCode == KErrDisconnected )
       
   218         {             
       
   219         iStarted = EFalse;
       
   220         }
       
   221     if( iExtObserver )
       
   222         {
       
   223         iExtObserver->CommandComplete( aStatusCode );
       
   224         }
       
   225     }
       
   226 
       
   227