upnpavcontroller/upnpavcontrollerclient/src/upnpavcontrollerfactory.cpp
changeset 0 7f85d04be362
equal deleted inserted replaced
-1:000000000000 0:7f85d04be362
       
     1 /*
       
     2 * Copyright (c) 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:      The factory for AVController client
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 
       
    23 // INCLUDES
       
    24 // upnpframework / avcontroller api
       
    25 #include "upnpavcontrollerfactory.h"
       
    26 #include "upnpavcontrollerglobals.h"
       
    27 
       
    28 // avcontroller internal
       
    29 #include "upnpavcontrolleractive.h"
       
    30 #include "upnpavcontrollerclient.h"
       
    31 
       
    32 
       
    33 // ======== MEMBER FUNCTIONS ========
       
    34 
       
    35 // --------------------------------------------------------------------------
       
    36 // UPnPAVControllerFactory::NewUPnPAVControllerL
       
    37 // Two-phase construct
       
    38 // --------------------------------------------------------------------------
       
    39 EXPORT_C MUPnPAVController* UPnPAVControllerFactory::NewUPnPAVControllerL()
       
    40     {
       
    41     return CUPnPAVControllerActive::NewL();
       
    42     }
       
    43     
       
    44 // --------------------------------------------------------------------------
       
    45 // UPnPAVControllerFactory::NewUPnPAVControllerLC
       
    46 // Two-phase construct
       
    47 // --------------------------------------------------------------------------
       
    48 EXPORT_C MUPnPAVController* UPnPAVControllerFactory::NewUPnPAVControllerLC()
       
    49     {
       
    50     return CUPnPAVControllerActive::NewLC();
       
    51     }
       
    52 
       
    53 // --------------------------------------------------------------------------
       
    54 // UPnPAVControllerFactory::MSServicesInUse
       
    55 // See upnpavcontrollerfactory.h
       
    56 // --------------------------------------------------------------------------
       
    57 EXPORT_C TBool UPnPAVControllerFactory::MSServicesInUse()
       
    58     {
       
    59     TBool retVal = EFalse;
       
    60     TFindServer findAVControllerServer( KAVControllerName );
       
    61     TFullName name;
       
    62 
       
    63     if ( findAVControllerServer.Next( name ) == KErrNone )
       
    64         {
       
    65         // Server already running, connect and check if it's using the local
       
    66         // media server
       
    67         RUPnPAVControllerClient avClient;
       
    68         TInt err = avClient.Connect();
       
    69         TBool inUse = EFalse;
       
    70         TPckg<TBool> inUsePckg( inUse );
       
    71         
       
    72         if( err )
       
    73             {
       
    74             // Error in client/servers comms, let the client think that the
       
    75             // local media server is in use
       
    76             retVal = ETrue;            
       
    77             }
       
    78         else
       
    79             {
       
    80             err = avClient.MSServicesInUse( inUsePckg );
       
    81             if( err )
       
    82                 {
       
    83                 // Error in client/servers comms, let the client think that the
       
    84                 // local media server is in use
       
    85                 retVal = ETrue;
       
    86                 }
       
    87             else if( inUse )
       
    88                 {
       
    89                 // Local media server is in use
       
    90                 retVal = ETrue;
       
    91                 }                
       
    92             }    
       
    93         avClient.Close();
       
    94         }
       
    95     else
       
    96         {
       
    97         // Server not running, local media server is not used
       
    98         }
       
    99     return retVal;
       
   100     }
       
   101 
       
   102 // --------------------------------------------------------------------------
       
   103 // UPnPAVControllerFactory::Status
       
   104 // See upnpavcontrollerfactory.h
       
   105 // --------------------------------------------------------------------------
       
   106 EXPORT_C TInt UPnPAVControllerFactory::Status(
       
   107     TAVControllerServerStatus& aStatus )
       
   108     {
       
   109     TFindServer findAVControllerServer( KAVControllerName );
       
   110     TFullName name;
       
   111 
       
   112     if ( findAVControllerServer.Next( name ) == KErrNone )
       
   113         {
       
   114         // Server running
       
   115         aStatus = EStatusActive;
       
   116         }
       
   117     else
       
   118         {
       
   119         // Server not running
       
   120         aStatus = EStatusOffline;
       
   121         }
       
   122     return KErrNone;    
       
   123     }
       
   124 
       
   125 // end of file