datasourcemodules/bluetoothgpspositioningmodule/btgpspsy/src/Init/BTGPSInitManager.cpp
changeset 0 9cfd9a3ee49c
equal deleted inserted replaced
-1:000000000000 0:9cfd9a3ee49c
       
     1 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 
       
    17 
       
    18 // INCLUDE FILES
       
    19 #include <e32std.h>
       
    20 #include "BTGPSInitManager.h"
       
    21 #include "BTGPSDeviceManager.h"
       
    22 #include "BTGPSConnectManager.h"
       
    23 #include "BTGPSSettingManager.h"
       
    24 #include "BTGPSNokGpsDetector.h"
       
    25 #include "BTGPSNokGpsInitialiser.h"
       
    26 #include "BTGPSNormalGpsInitialiser.h"
       
    27 #include "BTGPSLogging.h"
       
    28 
       
    29 // EXTERNAL DATA STRUCTURES
       
    30 
       
    31 // EXTERNAL FUNCTION PROTOTYPES  
       
    32 
       
    33 // CONSTANTS
       
    34 
       
    35 // MACROS
       
    36 
       
    37 // LOCAL CONSTANTS AND MACROS
       
    38 
       
    39 // MODULE DATA STRUCTURES
       
    40 
       
    41 // LOCAL FUNCTION PROTOTYPES
       
    42 
       
    43 // FORWARD DECLARATIONS
       
    44 
       
    45 // ============================= LOCAL FUNCTIONS ===============================
       
    46 
       
    47 // ============================ MEMBER FUNCTIONS ===============================
       
    48 
       
    49 
       
    50 // -----------------------------------------------------------------------------
       
    51 // CBTGPSInitManager::NewL
       
    52 // -----------------------------------------------------------------------------
       
    53 CBTGPSInitManager* CBTGPSInitManager::NewL(
       
    54         CBTGPSConnectManager& aConnectManager,
       
    55         CBTGPSDeviceManager& aDeviceManager,
       
    56         CBTGPSSettingManager& aSettingManager)
       
    57     {
       
    58     CBTGPSInitManager* self = new (ELeave) CBTGPSInitManager(
       
    59         aConnectManager,
       
    60         aDeviceManager,
       
    61         aSettingManager);
       
    62     CleanupStack::PushL(self);
       
    63     self->ConstructL();
       
    64     CleanupStack::Pop();
       
    65     return self;
       
    66     }
       
    67 
       
    68 // -----------------------------------------------------------------------------
       
    69 // CBTGPSInitManager::~CBTGPSInitManager
       
    70 // -----------------------------------------------------------------------------
       
    71 CBTGPSInitManager::~CBTGPSInitManager()
       
    72     {
       
    73     iDeviceManager.RemoveListener(*this);
       
    74     delete iNokGpsDetector;
       
    75     delete iNokGpsInitialiser;
       
    76     delete iNormalGpsInitialiser;
       
    77     }
       
    78 
       
    79 
       
    80 // -----------------------------------------------------------------------------
       
    81 // CBTGPSInitManager::ConstructL
       
    82 // -----------------------------------------------------------------------------
       
    83 void CBTGPSInitManager::ConstructL()
       
    84     {
       
    85     iDeviceManager.AddListenerL(*this);
       
    86     iNokGpsDetector = CBTGPSNokGpsDetector::NewL(
       
    87         iConnectManager,
       
    88         iDeviceManager);
       
    89     }
       
    90 
       
    91 // -----------------------------------------------------------------------------
       
    92 // CBTGPSInitManager::CBTGPSInitManager
       
    93 // C++ default constructor can NOT contain any code, that
       
    94 // might leave.
       
    95 // -----------------------------------------------------------------------------
       
    96 CBTGPSInitManager::CBTGPSInitManager(
       
    97         CBTGPSConnectManager& aConnectManager,
       
    98         CBTGPSDeviceManager& aDeviceManager,
       
    99         CBTGPSSettingManager& aSettingManager)
       
   100     : iConnectManager(aConnectManager),
       
   101       iDeviceManager(aDeviceManager),
       
   102       iSettingManager(aSettingManager)
       
   103     {
       
   104     }
       
   105 
       
   106 // -----------------------------------------------------------------------------
       
   107 // CBTGPSInitManager::BTDeviceStatusChanged
       
   108 // -----------------------------------------------------------------------------
       
   109 void CBTGPSInitManager::BTDeviceStatusChanged(
       
   110             TInt aConnectStatus, 
       
   111             TInt aDeviceType,
       
   112             TInt /*aErr*/)
       
   113     {
       
   114     TRACESTRING("CBTGPSInitManager::BTDeviceStatusChanged start...")
       
   115     //Start initialisation when device is connected but unintialized
       
   116     if(aConnectStatus == EBTDeviceConnected)
       
   117         {
       
   118         switch(aDeviceType)
       
   119             {
       
   120             case EBTDeviceTypeUnknown:
       
   121                 iNokGpsDetector->Detect(); //error ignore.
       
   122                 break;
       
   123             case EBTDeviceTypeNokGps:
       
   124                 {
       
   125                 
       
   126                 delete iNokGpsInitialiser;
       
   127                 iNokGpsInitialiser = NULL;
       
   128                 
       
   129                 iNokGpsInitialiser = CBTGPSNokGpsInitialiser::New(
       
   130                     iConnectManager,
       
   131                     iSettingManager,
       
   132                     iNokGpsInitialiser);
       
   133                 }
       
   134                 break;
       
   135             case EBTDeviceTypeNonNokGps:
       
   136                 {
       
   137                 //Detect the if the conected BT device support
       
   138                 //PNOK compatible message
       
   139                 iNokGpsDetector->Detect(); //error ignore.
       
   140                 
       
   141                 delete iNormalGpsInitialiser;
       
   142                 iNormalGpsInitialiser = NULL;
       
   143                 
       
   144                 iNormalGpsInitialiser = CBTGPSNormalGpsInitialiser::New(
       
   145                     iConnectManager,
       
   146                     iNormalGpsInitialiser);
       
   147                 }
       
   148                 break;
       
   149             case EBTDeviceTypeNonGPS:
       
   150                 //Not GPS device
       
   151                 break;
       
   152             default:
       
   153                 //other events are ignored
       
   154                 break;
       
   155             }
       
   156         }
       
   157     else
       
   158         {
       
   159         //If the device is not in connected status then cancel init operation
       
   160         iNokGpsDetector->Cancel();
       
   161         
       
   162         delete iNokGpsInitialiser;
       
   163         iNokGpsInitialiser = NULL;
       
   164 
       
   165         delete iNormalGpsInitialiser; 
       
   166         iNormalGpsInitialiser = NULL;
       
   167         }
       
   168     TRACESTRING("CBTGPSInitManager::BTDeviceStatusChanged end")
       
   169     }
       
   170 
       
   171 //  End of File
       
   172 
       
   173 
       
   174