vtprotocols/src/vtprotocolfactory.cpp
changeset 0 ed9695c8bcbe
child 19 856ae1b15d98
equal deleted inserted replaced
-1:000000000000 0:ed9695c8bcbe
       
     1 /*
       
     2 * Copyright (c) 2004-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:  
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <pv_plugin_interfaces.h>
       
    20 #include <pv_2way_symbian_interface.h>
       
    21 #include <pv_2way_h324m_interface.h>
       
    22 #include <pv_audio_output_control_interface.h>
       
    23 #include <pv_2way_factory.h>
       
    24 #include "mvtprotocolhandler.h"
       
    25 #include "cdatasourceproxy.h"
       
    26 #include "cdatasinkproxy.h"
       
    27 #include "csessionhandler.h"
       
    28 #include "caudioconfighandler.h"
       
    29 #include "cvtuserinput.h"
       
    30 #include "ccommserver.h"
       
    31 
       
    32 #ifdef _DEBUG
       
    33 #    define __IF_DEBUG(t) {RDebug::t;}
       
    34 #else
       
    35 #    define __IF_DEBUG(t)
       
    36 #endif
       
    37 // -----------------------------------------------------------------------------
       
    38 // VTProtocolFactory::CreateSessionCommandL
       
    39 // Create one instance. 
       
    40 // -----------------------------------------------------------------------------
       
    41 //
       
    42 EXPORT_C MVtSessionCommand* VTProtocolFactory::CreateSessionCommandL(MVtProtocolHandler* aProtocolHandler, TBool aEnableProxy, TVt3G324MSupported& a3G324MSupported)
       
    43     {
       
    44     __IF_DEBUG(Print(_L("VTProto: VTProtocolFactory::CreateSessionCommandL<")));
       
    45     a3G324MSupported = EVt3G324MSupported;	
       
    46     TSessionHandler * sessionHandler = new (ELeave)TSessionHandler(aProtocolHandler);
       
    47     CleanupStack::PushL(sessionHandler);
       
    48     MPV2WaySymbianInterface *pv2Way = CPV2WayFactory::CreateTerminalL(sessionHandler, sessionHandler, sessionHandler, aEnableProxy );
       
    49     CSessionCommand* sessionCommand = new (ELeave)CSessionCommand(sessionHandler, pv2Way);
       
    50     CleanupStack::Pop();
       
    51     __IF_DEBUG(Print(_L("VTProto: VTProtocolFactory::CreateSessionCommandL sessionCommand %d>"), sessionCommand));
       
    52     return sessionCommand;
       
    53     }
       
    54 
       
    55 // -----------------------------------------------------------------------------
       
    56 // VTProtocolFactory::DeleteSessionCommand
       
    57 // This function allows the application to delete an instance of a terminal 
       
    58 // and reclaim all allocated resources.
       
    59 // -----------------------------------------------------------------------------
       
    60 //
       
    61 EXPORT_C  void VTProtocolFactory::DeleteSessionCommand( MVtSessionCommand* aSessionCommand )
       
    62     {
       
    63     __IF_DEBUG(Print(_L("VTProto: VTProtocolFactory::DeleteSessionCommand<")));		
       
    64     CSessionCommand* sessionCommand = static_cast<CSessionCommand*>(aSessionCommand);
       
    65     CPV2WayFactory::DeleteTerminal( sessionCommand->iPv2Way );
       
    66     delete aSessionCommand;
       
    67     __IF_DEBUG(Print(_L("VTProto: VTProtocolFactory::DeleteSessionCommand>")));	
       
    68     }
       
    69 
       
    70 // -----------------------------------------------------------------------------
       
    71 // VTProtocolFactory::CreateAudioSource
       
    72 // Creates an instance of a DevSound audio data source.
       
    73 // -----------------------------------------------------------------------------
       
    74 //
       
    75 EXPORT_C MVTAudioSource* VTProtocolFactory::CreateAudioSource()
       
    76     {
       
    77     __IF_DEBUG(Print(_L("VTProto: VTProtocolFactory::CreateAudioSource<")));
       
    78     TInt err( KErrNone );
       
    79     CAudioSourceProxy* audioSourceProxy = NULL;	
       
    80     TRAP (err, audioSourceProxy = new (ELeave) CAudioSourceProxy() );
       
    81     if (err != KErrNone)
       
    82         {
       
    83         return NULL;
       
    84         }    
       
    85     audioSourceProxy->iAudioSource = CPVDevSoundAudioFactory::CreateDevSoundAudioDataSource();
       
    86     __IF_DEBUG(Print(_L("VTProto: VTProtocolFactory::CreateAudioSource audioSourceProxy %d>"), audioSourceProxy));
       
    87     return audioSourceProxy;
       
    88     }
       
    89 
       
    90 // -----------------------------------------------------------------------------
       
    91 // VTProtocolFactory::DeletAudioSource
       
    92 // Deletes an instance of a DevSound audio data source.
       
    93 // -----------------------------------------------------------------------------
       
    94 //
       
    95 EXPORT_C TInt VTProtocolFactory::DeletAudioSource(MVTAudioSource *aSource)
       
    96     {
       
    97     __IF_DEBUG(Print(_L("VTProto: VTProtocolFactory::DeletAudioSource<")));	
       
    98     CAudioSourceProxy* audioSourceProxy = static_cast<CAudioSourceProxy*>(aSource);
       
    99     CPVDevSoundAudioFactory::DeleteDevSoundAudioDataSource(audioSourceProxy->iAudioSource);
       
   100     delete aSource;
       
   101    __IF_DEBUG(Print(_L("VTProto: VTProtocolFactory::DeletAudioSource>")));	
       
   102     return KErrNone;
       
   103     }
       
   104 
       
   105 // -----------------------------------------------------------------------------
       
   106 // VTProtocolFactory::CreateAudioSink
       
   107 // Creates an instance of a DevSound audio data sink.
       
   108 // -----------------------------------------------------------------------------
       
   109 //
       
   110 EXPORT_C MVTAudioSink* VTProtocolFactory::CreateAudioSink()
       
   111     {
       
   112     __IF_DEBUG(Print(_L("VTProto: VTProtocolFactory::CreateAudioSink<")));
       
   113     TInt err( KErrNone );		
       
   114     CAudioSinkProxy* audioSinkProxy = NULL;
       
   115     TRAP(err, audioSinkProxy = new (ELeave) CAudioSinkProxy() );
       
   116     if (err != KErrNone)
       
   117         {
       
   118         return NULL;
       
   119         }
       
   120     audioSinkProxy->iAudioSink = CPVDevSoundAudioFactory::CreateDevSoundAudioDataSink();
       
   121    __IF_DEBUG(Print(_L("VTProto: VTProtocolFactory::CreateAudioSink audioSinkProxy %d>"), audioSinkProxy));		
       
   122     return audioSinkProxy;
       
   123     }
       
   124 
       
   125 // -----------------------------------------------------------------------------
       
   126 // VTProtocolFactory::DeleteAudioSink
       
   127 // Deletes an instance of a DevSound audio data sink
       
   128 // -----------------------------------------------------------------------------
       
   129 //
       
   130 EXPORT_C TInt VTProtocolFactory::DeleteAudioSink(MVTAudioSink *aSink)
       
   131     {
       
   132     __IF_DEBUG(Print(_L("VTProto: VTProtocolFactory::DeleteAudioSink<")));			
       
   133     CAudioSinkProxy* audioSinkProxy = static_cast<CAudioSinkProxy*>(aSink);
       
   134     CPVDevSoundAudioFactory::DeleteDevSoundAudioDataSink(audioSinkProxy->iAudioSink);
       
   135     delete aSink;
       
   136      __IF_DEBUG(Print(_L("VTProto: VTProtocolFactory::DeleteAudioSink>")));
       
   137     return KErrNone;
       
   138     }
       
   139 
       
   140 // -----------------------------------------------------------------------------
       
   141 // VTProtocolFactory::CreateCommServerL
       
   142 // Creates an instance of a comm server of a particular name, to be used to
       
   143 // initialize the terminal.
       
   144 // -----------------------------------------------------------------------------
       
   145 //
       
   146 EXPORT_C MCommServer* VTProtocolFactory::CreateCommServerL(const TDesC & aName, TBool aEnableBitReversal)
       
   147     {
       
   148     __IF_DEBUG(Print(_L("VTProto: VTProtocolFactory::CreateCommServerL<")));	
       
   149     CCommServer* commServer = new (ELeave)CCommServer();
       
   150     CleanupStack::PushL(commServer);
       
   151     commServer->iComm = CPVCommFactory::CreateCommServerL(aName, aEnableBitReversal);
       
   152     CleanupStack::Pop();
       
   153     __IF_DEBUG(Print(_L("VTProto: VTProtocolFactory::CreateCommServerL commServer %d>"), commServer));	
       
   154     return commServer;
       
   155     }
       
   156 
       
   157 // -----------------------------------------------------------------------------
       
   158 // VTProtocolFactory::DeleteCommServerL
       
   159 // This function allows the application to delete an instance of a comm server
       
   160 // and reclaim all allocated resources.
       
   161 // -----------------------------------------------------------------------------
       
   162 //
       
   163 EXPORT_C void VTProtocolFactory::DeleteCommServerL(MCommServer* aCommServer)
       
   164     {
       
   165     __IF_DEBUG(Print(_L("VTProto: VTProtocolFactory::DeleteCommServerL<")));		
       
   166     CCommServer* commServer = static_cast<CCommServer*>(aCommServer);
       
   167     CPVCommFactory::DeleteCommServerL(commServer->iComm);
       
   168     delete aCommServer;
       
   169     __IF_DEBUG(Print(_L("VTProto: VTProtocolFactory::DeleteCommServerL>")));	
       
   170     }
       
   171 
       
   172 // -----------------------------------------------------------------------------
       
   173 // VTProtocolFactory::CreateUserInputIndication
       
   174 // Create instance .
       
   175 // -----------------------------------------------------------------------------
       
   176 //
       
   177 EXPORT_C MVTUserInput* VTProtocolFactory::CreateUserInputIndication(TUserInputType aUIIType, TUint8 aTone)
       
   178     {
       
   179     __IF_DEBUG(Print(_L("VTProto: VTProtocolFactory::CreateUserInputIndication")));	
       
   180     if (aUIIType == EVtUiiDTFM)
       
   181         {
       
   182         CVTUserInputDtmf* uii = CVTUserInputDtmf::NewL(aTone);
       
   183         return uii;
       
   184         }
       
   185     else if (aUIIType == EVtUiiAlphaNumeric)
       
   186         {
       
   187         CVTUserInputAlphanumeric* uii = CVTUserInputAlphanumeric::NewL(aTone);
       
   188         return uii;
       
   189         }
       
   190     else
       
   191         {
       
   192         return NULL;
       
   193         }
       
   194     
       
   195     }
       
   196 
       
   197 // -----------------------------------------------------------------------------
       
   198 // VTProtocolFactory::DeleteUserInputIndication
       
   199 // Delete instance.
       
   200 // -----------------------------------------------------------------------------
       
   201 //
       
   202 EXPORT_C void VTProtocolFactory::DeleteUserInputIndication(MVTUserInput* aUII)
       
   203     {
       
   204     delete aUII;
       
   205     }
       
   206 
       
   207 // -----------------------------------------------------------------------------
       
   208 // VTProtocolFactory::GetAudioConfigCommandL
       
   209 // Get one instance.
       
   210 // -----------------------------------------------------------------------------
       
   211 //
       
   212 EXPORT_C MVtAudioConfigCommand* VTProtocolFactory::GetAudioConfigCommandL(MVTAudioSink* aAudioSink)
       
   213     {
       
   214     __IF_DEBUG(Print(_L("VTProto: VTProtocolFactory::GetAudioConfigCommandL<")));		
       
   215     CAudioSinkProxy* audioSinkProxy = static_cast<CAudioSinkProxy*>(aAudioSink);
       
   216     MPVAudioOutputControl* audioCtrl = CPVDevSoundAudioFactory::GetDevSoundAudioOutputControl(
       
   217             audioSinkProxy->iAudioSink, ETrue );
       
   218     CAudioConfigCommand* audioConfigCommand = new (ELeave)CAudioConfigCommand(audioCtrl);
       
   219     __IF_DEBUG(Print(_L("VTProto: VTProtocolFactory::GetAudioConfigCommandL audioConfigCommand %d>"), audioConfigCommand));	
       
   220     return audioConfigCommand;
       
   221     }
       
   222 
       
   223 // end of file