upnpavcontrolpoint/avcontrolframework/src/upnpcmactionfactory.cpp
changeset 0 7f85d04be362
equal deleted inserted replaced
-1:000000000000 0:7f85d04be362
       
     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 cm actions
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include "upnpcmactionfactory.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 // CUpnpCmActionFactory::CUpnpCmActionFactory
       
    36 // C++ default constructor can NOT contain any code, that
       
    37 // might leave.
       
    38 // -----------------------------------------------------------------------------
       
    39 //
       
    40 CUpnpCmActionFactory::CUpnpCmActionFactory( MUpnpAVControlPointObserver& aAVCPObserver,
       
    41                                    CUpnpAVControlPoint& aAVCP )
       
    42 :iAVControlPointObserver( aAVCPObserver ), iAVCP( aAVCP )
       
    43     {
       
    44     }
       
    45 
       
    46 // -----------------------------------------------------------------------------
       
    47 // CUpnpCmActionFactory::ConstructL
       
    48 // Symbian 2nd phase constructor can leave.
       
    49 // -----------------------------------------------------------------------------
       
    50 //
       
    51 void CUpnpCmActionFactory::ConstructL() 
       
    52     {
       
    53     }
       
    54 
       
    55 // -----------------------------------------------------------------------------
       
    56 // CUpnpCmActionFactory::NewL
       
    57 // Two-phased constructor.
       
    58 // -----------------------------------------------------------------------------
       
    59 //
       
    60 CUpnpCmActionFactory* CUpnpCmActionFactory::NewL( 
       
    61                                       MUpnpAVControlPointObserver& aAVCPObserver,
       
    62                                       CUpnpAVControlPoint& aAVCP )
       
    63     {
       
    64     CUpnpCmActionFactory* self = new (ELeave) CUpnpCmActionFactory( 
       
    65         aAVCPObserver,
       
    66         aAVCP );
       
    67     CleanupStack::PushL( self );
       
    68     self->ConstructL();
       
    69     CleanupStack::Pop( self );
       
    70     return self;
       
    71     }
       
    72 
       
    73 // -----------------------------------------------------------------------------
       
    74 // CUpnpCmActionFactory::~CUpnpCmActionFactory
       
    75 // Destructor.
       
    76 // -----------------------------------------------------------------------------
       
    77 //
       
    78 CUpnpCmActionFactory::~CUpnpCmActionFactory()
       
    79     {
       
    80     }
       
    81 
       
    82 // -----------------------------------------------------------------------------
       
    83 // CUpnpCmActionFactory::CmProtocolInfoActionLC
       
    84 // Creates an action for deleting resource from content directory.
       
    85 // (other items were commented in a header)
       
    86 // -----------------------------------------------------------------------------
       
    87 //
       
    88 TInt CUpnpCmActionFactory::CmProtocolInfoActionLC(CUpnpAction*& aAction,
       
    89                                               CUpnpDevice* aDevice)
       
    90     {
       
    91     CUpnpService* service = iAVCP.Service(aDevice, KConnectionManager);
       
    92     if( !service )
       
    93         {
       
    94         return KErrUnknown;
       
    95         }
       
    96     aAction = service->CreateActionLC( KGetProtocolInfo );
       
    97 
       
    98     if( aAction )
       
    99         {
       
   100         return KErrNone;
       
   101         }
       
   102     else
       
   103         {
       
   104         return KErrGeneral;
       
   105         }
       
   106     }             
       
   107 // -----------------------------------------------------------------------------
       
   108 // CUpnpCmActionFactory::CmCurrentConnectionsActionLC
       
   109 // Creates an action for deleting resource from content directory.
       
   110 // (other items were commented in a header)
       
   111 // -----------------------------------------------------------------------------
       
   112 //
       
   113 TInt CUpnpCmActionFactory::CmCurrentConnectionsActionLC(CUpnpAction*& aAction,
       
   114                                                     CUpnpDevice* aDevice)
       
   115     {
       
   116     CUpnpService* service = iAVCP.Service(aDevice, KConnectionManager);
       
   117     if( !service )
       
   118         {
       
   119         return KErrUnknown;
       
   120         }
       
   121     aAction = service->CreateActionLC( KGetCurrentConnectionIDs );
       
   122 
       
   123     if( aAction )
       
   124         {
       
   125         return KErrNone;
       
   126         }
       
   127     else
       
   128         {
       
   129         return KErrGeneral;
       
   130         }
       
   131     }
       
   132  // -----------------------------------------------------------------------------
       
   133 // CUpnpCmActionFactory::CmPrepareConnectionActionLC
       
   134 // Creates an action for deleting resource from content directory.
       
   135 // (other items were commented in a header)
       
   136 // -----------------------------------------------------------------------------
       
   137 //
       
   138 TInt CUpnpCmActionFactory::CmPrepareConnectionActionLC(
       
   139                                            CUpnpAction*& aAction,
       
   140                                            CUpnpDevice* aDevice,
       
   141                                            const TDesC8& aRemoteProtocolInfo,
       
   142                                            const TDesC8& aPeerConnectionManager,
       
   143 										   TInt aPeerConnectionID,
       
   144                                            const TDesC8& aDirection
       
   145                                            )
       
   146     {
       
   147     CUpnpService* service = iAVCP.Service(aDevice, KConnectionManager);
       
   148     if( !service )
       
   149         {
       
   150         return KErrUnknown;
       
   151         }
       
   152    	TBuf8<KMaxIntLength> conId;
       
   153 	conId.Num( aPeerConnectionID );
       
   154     aAction = service->CreateActionLC( KPrepareForConnection );
       
   155 
       
   156     if( aAction )
       
   157         {
       
   158         aAction->SetArgumentL( KRemoteProtocolInfo(), aRemoteProtocolInfo );
       
   159 	    aAction->SetArgumentL( KPeerConnectionManager(), aPeerConnectionManager );
       
   160 	    aAction->SetArgumentL( KPeerConnectionID(), conId );
       
   161 	    aAction->SetArgumentL( KDirection(), aDirection );
       
   162         return KErrNone;
       
   163         }
       
   164     else
       
   165         {
       
   166         return KErrGeneral;
       
   167         }
       
   168     }
       
   169 // -----------------------------------------------------------------------------
       
   170 // CUpnpCmActionFactory::CmConnectionCompleteActionLC
       
   171 // Creates an action for deleting resource from content directory.
       
   172 // (other items were commented in a header)
       
   173 // -----------------------------------------------------------------------------
       
   174 //
       
   175 TInt CUpnpCmActionFactory::CmConnectionCompleteActionLC(CUpnpAction*& aAction, 
       
   176                                                     CUpnpDevice* aDevice,
       
   177                                                     TInt aConnectionId)
       
   178     {
       
   179     CUpnpService* service = iAVCP.Service(aDevice, KConnectionManager);
       
   180     if( !service )
       
   181         {
       
   182         return KErrUnknown;
       
   183         }
       
   184     aAction = service->CreateActionLC( KConnectionComplete );
       
   185 
       
   186     if( aAction )
       
   187         {
       
   188    	    TBuf8<KMaxIntLength> connectionId;
       
   189 	    connectionId.Num(aConnectionId);
       
   190         aAction->SetArgumentL( KConnectionID, connectionId );
       
   191         return KErrNone;
       
   192         }
       
   193     else
       
   194         {
       
   195         return KErrGeneral;
       
   196         }
       
   197     }
       
   198 // -----------------------------------------------------------------------------
       
   199 // CUpnpCmActionFactory::CmCurrentConnectionInfoActionLC
       
   200 // Creates an action for deleting resource from content directory.
       
   201 // (other items were commented in a header)
       
   202 // -----------------------------------------------------------------------------
       
   203 //
       
   204 TInt CUpnpCmActionFactory::CmCurrentConnectionInfoActionLC(CUpnpAction*& aAction, 
       
   205                                                     CUpnpDevice* aDevice,
       
   206                                                     TInt aConnectionId)
       
   207     {
       
   208     CUpnpService* service = iAVCP.Service(aDevice, KConnectionManager);
       
   209     if( !service )
       
   210         {
       
   211         return KErrUnknown;
       
   212         }
       
   213     aAction = service->CreateActionLC( KGetCurrentConnectionInfo );
       
   214     
       
   215     if( aAction )
       
   216         {
       
   217    	    TBuf8<KMaxIntLength> connectionId;
       
   218 	    connectionId.Num(aConnectionId);
       
   219         aAction->SetArgumentL( KConnectionID, connectionId );
       
   220         return KErrNone;
       
   221         }
       
   222     else
       
   223         {
       
   224         return KErrGeneral;
       
   225         }
       
   226     }