upnpavcontrolpoint/avcontrolframework/src/upnprcactionfactory.cpp
branchIOP_Improvements
changeset 40 08b5eae9f9ff
parent 39 6369bfd1b60d
child 41 b4d83ea1d6e2
equal deleted inserted replaced
39:6369bfd1b60d 40:08b5eae9f9ff
     1 /** @file
       
     2 * Copyright (c) 2005-2006 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:  Produces rc actions
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include "upnprcactionfactory.h"
       
    21 #include "upnpavcontrolpoint.h"
       
    22 #include "upnpavcpstring.h"
       
    23 
       
    24 // CONSTANTS
       
    25 using namespace UpnpAVCPStrings;
       
    26 const TInt KMaxIntLength = 10;
       
    27 
       
    28 // ============================= LOCAL FUNCTIONS ===============================
       
    29 
       
    30 
       
    31 
       
    32 // ================= MEMBER FUNCTIONS =======================
       
    33 
       
    34 // -----------------------------------------------------------------------------
       
    35 // CUpnpRcActionFactory::CUpnpRcActionFactory
       
    36 // C++ default constructor can NOT contain any code, that
       
    37 // might leave.
       
    38 // -----------------------------------------------------------------------------
       
    39 //
       
    40 CUpnpRcActionFactory::CUpnpRcActionFactory( MUpnpAVControlPointObserver& aAVCPObserver,
       
    41                                    CUpnpAVControlPoint& aAVCP )
       
    42 :iAVControlPointObserver( aAVCPObserver ), iAVCP( aAVCP )
       
    43     {
       
    44     }
       
    45 
       
    46 // -----------------------------------------------------------------------------
       
    47 // CUpnpRcActionFactory::ConstructL
       
    48 // Symbian 2nd phase constructor can leave.
       
    49 // -----------------------------------------------------------------------------
       
    50 //
       
    51 void CUpnpRcActionFactory::ConstructL() 
       
    52     {
       
    53     }
       
    54 
       
    55 // -----------------------------------------------------------------------------
       
    56 // CSuperDir::NewL
       
    57 // Two-phased constructor.
       
    58 // -----------------------------------------------------------------------------
       
    59 //
       
    60 CUpnpRcActionFactory* CUpnpRcActionFactory::NewL(
       
    61                                       MUpnpAVControlPointObserver& aAVCPObserver,
       
    62                                       CUpnpAVControlPoint& aAVCP )
       
    63     {
       
    64     CUpnpRcActionFactory* self = new (ELeave) CUpnpRcActionFactory( 
       
    65         aAVCPObserver,
       
    66         aAVCP );
       
    67     CleanupStack::PushL( self );
       
    68     self->ConstructL();
       
    69     CleanupStack::Pop( self );
       
    70     return self;
       
    71     }
       
    72 
       
    73 // -----------------------------------------------------------------------------
       
    74 // CUpnpRcActionFactory::~CUpnpRcActionFactory
       
    75 // Destructor
       
    76 // -----------------------------------------------------------------------------
       
    77 //
       
    78 CUpnpRcActionFactory::~CUpnpRcActionFactory()
       
    79     {
       
    80     }
       
    81 
       
    82 // -----------------------------------------------------------------------------
       
    83 // CUpnpRcActionFactory::RcGetVolumeActionLC
       
    84 // Creates an action for deleting resource from content directory.
       
    85 // (other items were commented in a header)
       
    86 // -----------------------------------------------------------------------------
       
    87 //
       
    88 TInt CUpnpRcActionFactory::RcGetVolumeActionLC(CUpnpAction*& aAction,
       
    89                                             CUpnpDevice* aDevice,
       
    90                                             TInt aInstanceID,
       
    91                                             const TDesC8& aChannel)
       
    92     {
       
    93     CUpnpService* service = iAVCP.Service(aDevice, KRenderingControl);
       
    94     if( !service )
       
    95         {
       
    96         return KErrUnknown;
       
    97         }
       
    98     TBuf8<KMaxIntLength> instanceId;
       
    99 	instanceId.Num( aInstanceID );
       
   100 
       
   101     aAction = service->CreateActionLC( KGetVolume );
       
   102     
       
   103     if ( aAction )
       
   104         {
       
   105         aAction->SetArgumentL( KInstanceID(), instanceId );
       
   106 	    aAction->SetArgumentL( KChannel(), aChannel );
       
   107         return KErrNone;
       
   108         }
       
   109     else
       
   110         {
       
   111         return KErrGeneral;
       
   112         }
       
   113     }
       
   114 // -----------------------------------------------------------------------------
       
   115 // CUpnpRcActionFactory::RcSetVolumeActionLC
       
   116 // Creates an action for deleting resource from content directory.
       
   117 // (other items were commented in a header)
       
   118 // -----------------------------------------------------------------------------
       
   119 //
       
   120 TInt CUpnpRcActionFactory::RcSetVolumeActionLC(CUpnpAction*& aAction,
       
   121                                             CUpnpDevice* aDevice,
       
   122                                             TInt aInstanceID,
       
   123                                             const TDesC8& aChannel,
       
   124                                             TInt aVolume)
       
   125     {
       
   126     CUpnpService* service = iAVCP.Service(aDevice, KRenderingControl);
       
   127     if( !service )
       
   128         {
       
   129         return KErrUnknown;
       
   130         }
       
   131     TBuf8<KMaxIntLength> instanceId;
       
   132 	instanceId.Num( aInstanceID );
       
   133 	TBuf8<KMaxIntLength> volume;
       
   134 	volume.Num( aVolume );
       
   135 
       
   136     aAction = service->CreateActionLC( KSetVolume );
       
   137     
       
   138     if ( aAction )
       
   139         {
       
   140         aAction->SetArgumentL( KInstanceID(), instanceId );
       
   141         aAction->SetArgumentL( KChannel(), aChannel );
       
   142         aAction->SetArgumentL( KDesiredVolume(), volume );
       
   143         return KErrNone;
       
   144         }
       
   145     else
       
   146         {
       
   147         return KErrGeneral;
       
   148         }
       
   149     }
       
   150 // -----------------------------------------------------------------------------
       
   151 // CUpnpCdsActionFactory::RcGetMuteActionLC
       
   152 // Creates an action for deleting resource from content directory.
       
   153 // (other items were commented in a header)
       
   154 // -----------------------------------------------------------------------------
       
   155 //
       
   156 TInt CUpnpRcActionFactory::RcGetMuteActionLC(CUpnpAction*& aAction,
       
   157                                             CUpnpDevice* aDevice,
       
   158                                             TInt aInstanceID,
       
   159                                             const TDesC8& aChannel)
       
   160     {
       
   161     CUpnpService* service = iAVCP.Service(aDevice, KRenderingControl);
       
   162     if( !service )
       
   163         {
       
   164         return KErrUnknown;
       
   165         }
       
   166     TBuf8<KMaxIntLength> instanceId;
       
   167 	instanceId.Num( aInstanceID );
       
   168 
       
   169     aAction = service->CreateActionLC( KGetMute );
       
   170 
       
   171     if ( aAction )
       
   172         {
       
   173         aAction->SetArgumentL( KInstanceID(), instanceId );
       
   174         aAction->SetArgumentL( KChannel(), aChannel );
       
   175         return KErrNone;
       
   176         }
       
   177     else
       
   178         {
       
   179         return KErrGeneral;
       
   180         }
       
   181     }
       
   182 // -----------------------------------------------------------------------------
       
   183 // CUpnpCdsActionFactory::RcSetMuteActionLC
       
   184 // Creates an action for deleting resource from content directory.
       
   185 // (other items were commented in a header)
       
   186 // -----------------------------------------------------------------------------
       
   187 //
       
   188 TInt CUpnpRcActionFactory::RcSetMuteActionLC(CUpnpAction*& aAction,
       
   189                                             CUpnpDevice* aDevice,
       
   190                                             TInt aInstanceID,
       
   191                                             const TDesC8& aChannel,
       
   192                                             const TDesC8& aMute)
       
   193     {
       
   194     CUpnpService* service = iAVCP.Service(aDevice, KRenderingControl);
       
   195     if( !service )
       
   196         {
       
   197         return KErrUnknown;
       
   198         }
       
   199     TBuf8<KMaxIntLength> instanceId;
       
   200 	instanceId.Num( aInstanceID );
       
   201 
       
   202     aAction = service->CreateActionLC( KSetMute );
       
   203 	
       
   204     if ( aAction )
       
   205 	    {
       
   206         aAction->SetArgumentL( KInstanceID(), instanceId );
       
   207         aAction->SetArgumentL( KChannel(), aChannel );
       
   208         aAction->SetArgumentL( KDesiredMute(), aMute );
       
   209         return KErrNone;
       
   210         }
       
   211     else
       
   212         {
       
   213         return KErrGeneral;
       
   214         }
       
   215     }