datasourcemodules/bluetoothgpspositioningmodule/btgpspsy/src/Settings/BTGPSNokNightModeHandler.cpp
changeset 36 b47902b73a93
parent 0 9cfd9a3ee49c
equal deleted inserted replaced
35:a2efdd544abf 36:b47902b73a93
       
     1 // Copyright (c) 2004-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 "BTGPSNokNightModeHandler.h"
       
    21 #include "BTGPSConnectManager.h"
       
    22 #include "BTGPSMessageDef.h"
       
    23 
       
    24 // EXTERNAL DATA STRUCTURES
       
    25 
       
    26 // EXTERNAL FUNCTION PROTOTYPES  
       
    27 
       
    28 // CONSTANTS
       
    29 // Timer interval for sending setting night mode message
       
    30 const TInt KBTGPSTimerIntervalSendingNightModeSetting = 5000000; //5 seconds
       
    31 
       
    32 // MACROS
       
    33 
       
    34 // LOCAL CONSTANTS AND MACROS
       
    35 
       
    36 // MODULE DATA STRUCTURES
       
    37 
       
    38 // LOCAL FUNCTION PROTOTYPES
       
    39 
       
    40 // FORWARD DECLARATIONS
       
    41 
       
    42 // ============================= LOCAL FUNCTIONS ===============================
       
    43 
       
    44 // ============================ MEMBER FUNCTIONS ===============================
       
    45 
       
    46 
       
    47 // -----------------------------------------------------------------------------
       
    48 // CBTGPSNokNightModeHandler::NewL
       
    49 // -----------------------------------------------------------------------------
       
    50 CBTGPSNokNightModeHandler* CBTGPSNokNightModeHandler::NewL(
       
    51         CBTGPSConnectManager& aConnectManager,
       
    52         TBTGPSSettingsApi::TNightModeState aNightModeStatus)
       
    53     {
       
    54     CBTGPSNokNightModeHandler* self = new (ELeave) CBTGPSNokNightModeHandler(
       
    55         aConnectManager,
       
    56         aNightModeStatus);
       
    57     CleanupStack::PushL(self);
       
    58     self->ConstructL();
       
    59     CleanupStack::Pop();
       
    60     return self;
       
    61     }
       
    62 
       
    63 // -----------------------------------------------------------------------------
       
    64 // CBTGPSNokNightModeHandler::~CBTGPSNokNightModeHandler
       
    65 // -----------------------------------------------------------------------------
       
    66 CBTGPSNokNightModeHandler::~CBTGPSNokNightModeHandler()
       
    67     {
       
    68     if(iTimer!=NULL)
       
    69         {
       
    70         iTimer->Cancel();
       
    71         delete iTimer;
       
    72         }
       
    73     }
       
    74 
       
    75 // -----------------------------------------------------------------------------
       
    76 // CBTGPSNokNightModeHandler::ConstructL
       
    77 // -----------------------------------------------------------------------------
       
    78 void CBTGPSNokNightModeHandler::ConstructL()
       
    79     {
       
    80     iTimer = CPeriodic::NewL(CActive::EPriorityStandard);
       
    81     iTimer->Start(
       
    82         KBTGPSTimerIntervalSendingNightModeSetting,
       
    83         KBTGPSTimerIntervalSendingNightModeSetting,
       
    84         TCallBack(TimerCallback, this));
       
    85         
       
    86     SetNightModeSetting();
       
    87     }
       
    88 
       
    89 // -----------------------------------------------------------------------------
       
    90 // CBTGPSNokNightModeHandler::CBTGPSNokNightModeHandler
       
    91 // C++ default constructor can NOT contain any code, that
       
    92 // might leave.
       
    93 // -----------------------------------------------------------------------------
       
    94 CBTGPSNokNightModeHandler::CBTGPSNokNightModeHandler(
       
    95         CBTGPSConnectManager& aConnectManager,
       
    96         TBTGPSSettingsApi::TNightModeState aNightModeStatus)
       
    97     : iConnectManager(aConnectManager),
       
    98       iNightModeStatus(aNightModeStatus)
       
    99     {
       
   100     }
       
   101 
       
   102 // -----------------------------------------------------------------------------
       
   103 // CBTGPSNokNightModeHandler::TimerTick
       
   104 // -----------------------------------------------------------------------------
       
   105 void CBTGPSNokNightModeHandler::TimerTick()
       
   106     {
       
   107     SetNightModeSetting();
       
   108     }
       
   109 
       
   110 // -----------------------------------------------------------------------------
       
   111 // CBTGPSNokNightModeHandler::TimerCallback
       
   112 // -----------------------------------------------------------------------------
       
   113 TInt CBTGPSNokNightModeHandler::TimerCallback(TAny* aAny)
       
   114     {
       
   115     reinterpret_cast<CBTGPSNokNightModeHandler*>(aAny)->TimerTick();
       
   116     return 1; //to be called again
       
   117     }
       
   118 
       
   119 // -----------------------------------------------------------------------------
       
   120 // CBTGPSNokNightModeHandler::SetNightModeSetting
       
   121 // -----------------------------------------------------------------------------
       
   122 void CBTGPSNokNightModeHandler::SetNightModeSetting()
       
   123     {
       
   124     if(iNightModeStatus == TBTGPSSettingsApi::ENightModeOn)
       
   125         {
       
   126         //Night mdoe on
       
   127         iConnectManager.SendMessage(KNMEAPNOKNightModeOn);
       
   128         }
       
   129     else
       
   130         {
       
   131         //Night mode off
       
   132         iConnectManager.SendMessage(KNMEAPNOKNightModeOff);
       
   133         }
       
   134     }
       
   135 
       
   136 //  End of File
       
   137 
       
   138 
       
   139