vmbx/vmbxengine/src/vmbxenginefactory.cpp
branchRCL_3
changeset 20 987c9837762f
parent 19 7d48bed6ce0c
child 21 0a6dd2dc9970
equal deleted inserted replaced
19:7d48bed6ce0c 20:987c9837762f
     1 /*
       
     2 * Copyright (c) 2009 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:  Implementation of the CVmbxEngineFactory class
       
    15 *
       
    16 */
       
    17 
       
    18 // INCLUDE FILES
       
    19 #include "vmbxenginebase.h"
       
    20 #include "vmbxcsvoiceengine.h"
       
    21 #include "vmbxcsvideoengine.h"
       
    22 #include "vmbxvoipengine.h"
       
    23 #include "vmbxutilities.h"
       
    24 
       
    25 #include "vmbxlogger.h"
       
    26 
       
    27 #include "vmbxenginefactory.h"
       
    28 
       
    29 
       
    30 // CONSTANTS
       
    31 
       
    32 // ============================ MEMBER FUNCTIONS =============================
       
    33 
       
    34 // ---------------------------------------------------------------------------
       
    35 // CVmbxEntryFactory::CVmbxEntryFactory
       
    36 // C++ default constructor can NOT contain any code, that
       
    37 // might leave.
       
    38 // ---------------------------------------------------------------------------
       
    39 //
       
    40 CVmbxEngineFactory::CVmbxEngineFactory( MVmbxResourceProvider& aProvider )
       
    41                                     : iProvider( aProvider )
       
    42     {
       
    43     VMBLOGSTRING( "VMBX: CVmbxEntryFactory::CVmbxEntryFactory <=>" );
       
    44     }
       
    45 
       
    46 // ---------------------------------------------------------------------------
       
    47 // CVmbxEntryFactory::~CVmbxEntryFactory
       
    48 // Destructor.
       
    49 // ---------------------------------------------------------------------------
       
    50 //
       
    51 CVmbxEngineFactory::~CVmbxEngineFactory()
       
    52     {
       
    53     VMBLOGSTRING( "VMBX: CVmbxEntryFactory::~CVmbxEntryFactory <=>" );
       
    54     }
       
    55 
       
    56 // ---------------------------------------------------------------------------
       
    57 // CVmbxEntryFactory::NewL
       
    58 // Two-phased constructor.
       
    59 // ---------------------------------------------------------------------------
       
    60 //
       
    61 CVmbxEngineFactory* CVmbxEngineFactory::NewL( 
       
    62                                     MVmbxResourceProvider& aProvider )
       
    63     {
       
    64     VMBLOGSTRING( "VMBX: CVmbxEntryFactory::NewL =>" );
       
    65     CVmbxEngineFactory* self = 
       
    66         new( ELeave ) CVmbxEngineFactory( aProvider );
       
    67     CleanupStack::PushL( self );
       
    68     self->ConstructL();
       
    69     CleanupStack::Pop( self );
       
    70     VMBLOGSTRING( "VMBX: CVmbxEntryFactory::NewL <=" );
       
    71     return self;
       
    72     }
       
    73 
       
    74 // ---------------------------------------------------------------------------
       
    75 // CVmbxEntryFactory::ConstructL
       
    76 // Symbian 2nd phase constructor can leave.
       
    77 // ---------------------------------------------------------------------------
       
    78 //
       
    79 void CVmbxEngineFactory::ConstructL()
       
    80     {
       
    81     VMBLOGSTRING( "VMBX: CVmbxEntryFactory::ConstructL =>" );
       
    82     VMBLOGSTRING( "VMBX: CVmbxEntryFactory::ConstructL <=" );
       
    83     }
       
    84 
       
    85 // ---------------------------------------------------------------------------
       
    86 // CVmbxEntryFactory::CreateEngineL
       
    87 // Loads instance of the mailbox entry
       
    88 // ---------------------------------------------------------------------------
       
    89 //
       
    90 void CVmbxEngineFactory::CreateEngineL( CVmbxEngineBase*& aEngine,
       
    91                                                      TVmbxType aType )
       
    92     {
       
    93     VMBLOGSTRING( "VMBX: CVmbxEntryFactory::CreateEngineL =>" );
       
    94     aEngine = NULL;
       
    95 
       
    96     TInt result( KErrNone );
       
    97     switch( aType )
       
    98         {
       
    99         case EVmbxVoice:
       
   100             {
       
   101              // Create voice mailbox
       
   102             CVmbxEngineBase* voice = CVmbxCsVoiceEngine::NewL( iProvider );
       
   103             aEngine = voice;        
       
   104             }
       
   105             break;
       
   106         case EVmbxVideo:
       
   107             {
       
   108             if ( VmbxUtilities::VideoSupported() )
       
   109                 {
       
   110                  // Create video mailbox
       
   111                 CVmbxEngineBase* video = CVmbxCsVideoEngine::NewL( iProvider );
       
   112                 aEngine = video;            
       
   113                 }
       
   114             else
       
   115                 {
       
   116                 result = KErrNotSupported;
       
   117                 }
       
   118             }
       
   119             break;
       
   120         case EVmbxVoip:
       
   121             {
       
   122             if ( VmbxUtilities::VoIPSupported() )
       
   123                 {
       
   124                  // Create Voip mailbox
       
   125                 CVmbxEngineBase* voip = CVmbxVoIpEngine::NewL( iProvider);
       
   126                 aEngine =  voip;
       
   127                 }
       
   128             else
       
   129                 {
       
   130                 result = KErrNotSupported;
       
   131                 }
       
   132             }
       
   133             break;
       
   134         default:
       
   135             result = KErrArgument;
       
   136             break;
       
   137         }
       
   138 
       
   139     VMBLOGSTRING2( "VMBX: CVmbxEntryFactory::CreateEngineL: result%I",
       
   140     result );
       
   141     if ( KErrNone != result )
       
   142         {
       
   143         User::Leave( result );
       
   144         }
       
   145     VMBLOGSTRING( "VMBX: CVmbxEntryFactory::CreateEngineL <=" );
       
   146     }
       
   147 
       
   148 // End of file