datasourcemodules/bluetoothgpspositioningmodule/btgpspsy/src/Init/BTGPSNokGpsInitialiser.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 "BTGPSNokGpsInitialiser.h"
       
    21 #include "BTGPSMessageDef.h"
       
    22 #include "BTGPSConnectManager.h"
       
    23 #include "BTGPSSettingManager.h"
       
    24 #include "BTGPSSettingsApi.h"
       
    25 #include "BTGPSLogging.h"
       
    26 #include "BTGPSNmeaParser.h"
       
    27 
       
    28 // EXTERNAL DATA STRUCTURES
       
    29 
       
    30 // EXTERNAL FUNCTION PROTOTYPES  
       
    31 
       
    32 // CONSTANTS
       
    33 
       
    34 // MACROS
       
    35 
       
    36 // LOCAL CONSTANTS AND MACROS
       
    37 
       
    38 // MODULE DATA STRUCTURES
       
    39 
       
    40 // LOCAL FUNCTION PROTOTYPES
       
    41 
       
    42 // FORWARD DECLARATIONS
       
    43 
       
    44 // ============================= LOCAL FUNCTIONS ===============================
       
    45 
       
    46 // ============================ MEMBER FUNCTIONS ===============================
       
    47 
       
    48 
       
    49 // -----------------------------------------------------------------------------
       
    50 // CBTGPSNokGpsInitialiser::NewL
       
    51 // -----------------------------------------------------------------------------
       
    52 CBTGPSNokGpsInitialiser* CBTGPSNokGpsInitialiser::NewL(
       
    53         CBTGPSConnectManager& aConnectManager,
       
    54         CBTGPSSettingManager& aSettingManager,
       
    55         CBTGPSNokGpsInitialiser*& aOwner)
       
    56     {
       
    57     CBTGPSNokGpsInitialiser* self = new (ELeave) CBTGPSNokGpsInitialiser(
       
    58         aConnectManager,
       
    59         aSettingManager,
       
    60         aOwner);
       
    61     CleanupStack::PushL(self);
       
    62     self->ConstructL();
       
    63     CleanupStack::Pop();
       
    64     return self;
       
    65     }
       
    66 
       
    67 // -----------------------------------------------------------------------------
       
    68 // CBTGPSNokGpsInitialiser::New
       
    69 // -----------------------------------------------------------------------------
       
    70 CBTGPSNokGpsInitialiser* CBTGPSNokGpsInitialiser::New(
       
    71         CBTGPSConnectManager& aConnectManager,
       
    72         CBTGPSSettingManager& aSettingManager,
       
    73         CBTGPSNokGpsInitialiser*& aOwner)
       
    74     {
       
    75     CBTGPSNokGpsInitialiser* self = NULL;
       
    76     TInt err(KErrNone);
       
    77     TRAP(err, self = CBTGPSNokGpsInitialiser::NewL(
       
    78         aConnectManager,
       
    79         aSettingManager,
       
    80         aOwner));
       
    81     return self;
       
    82     }
       
    83 
       
    84 // -----------------------------------------------------------------------------
       
    85 // CBTGPSNokGpsInitialiser::~CBTGPSNokGpsInitialiser
       
    86 // -----------------------------------------------------------------------------
       
    87 CBTGPSNokGpsInitialiser::~CBTGPSNokGpsInitialiser()
       
    88     {
       
    89     iConnectManager.RemoveMessageListener(*this);
       
    90     //reset owner
       
    91     iOwner = NULL;
       
    92     }
       
    93 
       
    94 
       
    95 // -----------------------------------------------------------------------------
       
    96 // CBTGPSNokGpsInitialiser::ConstructL
       
    97 // -----------------------------------------------------------------------------
       
    98 void CBTGPSNokGpsInitialiser::ConstructL()
       
    99     {
       
   100     //Add listener
       
   101     iConnectManager.AddMessageListenerL(*this);
       
   102     
       
   103     //Set wanted message
       
   104     iConnectManager.SendMessageL(KNMEAPNOKSelectMessage);
       
   105     }
       
   106 
       
   107 // -----------------------------------------------------------------------------
       
   108 // CBTGPSNokGpsInitialiser::CBTGPSNokGpsInitialiser
       
   109 // C++ default constructor can NOT contain any code, that
       
   110 // might leave.
       
   111 // -----------------------------------------------------------------------------
       
   112 CBTGPSNokGpsInitialiser::CBTGPSNokGpsInitialiser(
       
   113         CBTGPSConnectManager& aConnectManager,
       
   114         CBTGPSSettingManager& aSettingManager,
       
   115         CBTGPSNokGpsInitialiser*& aOwner)
       
   116     : iConnectManager(aConnectManager),
       
   117       iSettingManager(aSettingManager),
       
   118       iOwner(aOwner)
       
   119     {
       
   120     }
       
   121 
       
   122 // -----------------------------------------------------------------------------
       
   123 // CBTGPSNokGpsInitialiser::HandleMessage
       
   124 // -----------------------------------------------------------------------------
       
   125 void CBTGPSNokGpsInitialiser::HandleMessage(const TBTGPSNmeaParser& aParser)
       
   126     {
       
   127     if(aParser.MessageId() == ENmeaPNokPeriodicMsgs )
       
   128         {
       
   129         iConnectManager.SendMessage(KNMEAPNOKToPowerSaving1s);
       
   130         }
       
   131     else if(aParser.MessageId() == ENmeaPNokLowPwrMode)
       
   132         {
       
   133         //initialisation complete
       
   134         //Night mode setting is done by CBTGPSNokDeviceHandler
       
   135         delete this;
       
   136         }
       
   137     else 
       
   138         {
       
   139         //If other PNOK messages are received
       
   140         if(aParser.MessageId()> ENmeaProprietaryNok)
       
   141             {
       
   142             iConnectManager.SendMessage(KNMEAPNOKSelectMessage);
       
   143             }
       
   144         }
       
   145     }
       
   146 
       
   147 //  End of File
       
   148 
       
   149 
       
   150