locationtriggering/ltcontextsourceplugin/src/lbttriggermanager.cpp
changeset 0 667063e416a2
equal deleted inserted replaced
-1:000000000000 0:667063e416a2
       
     1 
       
     2 /*
       
     3 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     4 * All rights reserved.
       
     5 * This component and the accompanying materials are made available
       
     6 * under the terms of "Eclipse Public License v1.0"
       
     7 * which accompanies this distribution, and is available
       
     8 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     9 *
       
    10 * Initial Contributors:
       
    11 * Nokia Corporation - initial contribution.
       
    12 *
       
    13 * Contributors:
       
    14 *
       
    15 * Description:  Location Trigger Manager monitoring
       
    16 *
       
    17 */
       
    18 
       
    19 #include "lbttriggermanager.h"
       
    20 
       
    21 _LIT(KPluginSettingRAMFolder, "\\private\\10282BC4\\Settings\\200267F3\\");
       
    22 
       
    23 // ---------------------------------------------------------------------------
       
    24 // CLocationTriggerManager::CLocationTriggerManager
       
    25 // ---------------------------------------------------------------------------
       
    26 //
       
    27 CLocationTriggerManager::CLocationTriggerManager() :
       
    28 CActive( EPriorityStandard )
       
    29     {
       
    30         CActiveScheduler::Add(this);
       
    31     }
       
    32 
       
    33 // ---------------------------------------------------------------------------
       
    34 // CLocationTriggerManager::~CLocationTriggerManager
       
    35 // ---------------------------------------------------------------------------
       
    36 //
       
    37 CLocationTriggerManager::~CLocationTriggerManager()
       
    38     {
       
    39     CActive::Cancel();
       
    40 
       
    41     iLbtManager.Close();
       
    42     iLbtServer.Close();
       
    43     }
       
    44 
       
    45 // ---------------------------------------------------------------------------
       
    46 // CLocationTriggerManager::NewLC
       
    47 // ---------------------------------------------------------------------------
       
    48 //
       
    49 CLocationTriggerManager* CLocationTriggerManager::NewLC( )
       
    50     {
       
    51     CLocationTriggerManager* self = new (ELeave) CLocationTriggerManager();
       
    52     CleanupStack::PushL(self);
       
    53     self->ConstructL();
       
    54     return self;
       
    55     }
       
    56 
       
    57 // ---------------------------------------------------------------------------
       
    58 // CLocationTriggerManager::NewL
       
    59 // ---------------------------------------------------------------------------
       
    60 //
       
    61 CLocationTriggerManager* CLocationTriggerManager::NewL()
       
    62     {
       
    63     CLocationTriggerManager* self = CLocationTriggerManager::NewLC( );
       
    64     CleanupStack::Pop(self);
       
    65     return self;
       
    66     }
       
    67 
       
    68 // ---------------------------------------------------------------------------
       
    69 // CLocationTriggerManager::ConstructL
       
    70 // ---------------------------------------------------------------------------
       
    71 //
       
    72 void CLocationTriggerManager::ConstructL()
       
    73     {
       
    74     User::LeaveIfError( iLbtServer.Connect() );
       
    75     User::LeaveIfError( iLbtManager.Open(iLbtServer) );
       
    76     }
       
    77 
       
    78 
       
    79 // ---------------------------------------------------------------------------
       
    80 // CLocationTriggerManager::RunL
       
    81 // ---------------------------------------------------------------------------
       
    82 //
       
    83 void CLocationTriggerManager::RunL()
       
    84     {
       
    85     if(iStatus.Int()!=KErrNone)
       
    86         {    
       
    87         return;
       
    88         }
       
    89 
       
    90     //Get triggering system management settings
       
    91     TLbtTriggeringSystemStatus triggeringSystemStatus;
       
    92     iLbtManager.GetTriggeringSystemStatusL(triggeringSystemStatus);
       
    93     
       
    94     if ( triggeringSystemStatus.iLocationAcquisitionStatus == ELocationAcquisitionInactive )
       
    95         {    
       
    96         // Delete all setting files belonging to LBT Context Source plugin
       
    97         RFs fsSession;
       
    98         CleanupClosePushL( fsSession );
       
    99         User::LeaveIfError(fsSession.Connect()); 
       
   100         CFileMan* fileMan = CFileMan::NewL(fsSession);
       
   101         CleanupStack::PushL(fileMan);
       
   102         // Delete settings from RAM
       
   103         TInt err = fileMan->RmDir(KPluginSettingRAMFolder);
       
   104 
       
   105         CleanupStack::PopAndDestroy(fileMan); 
       
   106         fsSession.Close();
       
   107         CleanupStack::PopAndDestroy( &fsSession );
       
   108         }
       
   109         
       
   110     iLbtManager.NotifyTriggeringSystemStatusChange(iStatus);
       
   111     SetActive();
       
   112     
       
   113     }
       
   114 
       
   115 // ---------------------------------------------------------------------------
       
   116 // CLocationTriggerManager::RunError
       
   117 // ---------------------------------------------------------------------------
       
   118 //
       
   119 TInt CLocationTriggerManager::RunError( TInt aError )
       
   120     {
       
   121     if( aError != KErrNone )
       
   122         {
       
   123         iLbtManager.NotifyTriggeringSystemStatusChange(iStatus);
       
   124         SetActive();
       
   125         return aError;
       
   126         }
       
   127     
       
   128     iLbtManager.NotifyTriggeringSystemStatusChange(iStatus);
       
   129     SetActive();
       
   130     return KErrNone;
       
   131     }
       
   132 
       
   133 // ---------------------------------------------------------------------------
       
   134 // CLocationTriggerManager::DoCancel
       
   135 // ---------------------------------------------------------------------------
       
   136 //
       
   137 void CLocationTriggerManager::DoCancel()
       
   138     {    
       
   139     iLbtManager.CancelNotifyTriggeringSystemStatusChange();
       
   140     }
       
   141   
       
   142 // ---------------------------------------------------------------------------
       
   143 // CLocationTriggerManager::StartManagerObserverL
       
   144 // ---------------------------------------------------------------------------
       
   145 //
       
   146 void CLocationTriggerManager::StartManagerObserver()
       
   147     {    
       
   148         iLbtManager.NotifyTriggeringSystemStatusChange(iStatus);
       
   149         SetActive();
       
   150     }