locationsystemui/locationsysui/possettings/possettingsengine/src/possettingsengine.cpp
changeset 25 73f6c2762ffe
equal deleted inserted replaced
22:4c4ed41530db 25:73f6c2762ffe
       
     1 /*
       
     2 * Copyright (c) 2010 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:  Implementation of positioning settings engine class. 
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "possettingsengine.h"
       
    20 #include "possettingscrkey.h"
       
    21 #include <QDebug>
       
    22 #include <xqsettingsmanager.h>
       
    23 #include <xqsettingskey.h>
       
    24 
       
    25 
       
    26 //---------------------------------------------------------------------
       
    27 // PosSettingsEngine::PosSettingsEngine()
       
    28 // (other items were commented in a header).
       
    29 //---------------------------------------------------------------------
       
    30 PosSettingsEngine::PosSettingsEngine()
       
    31     {
       
    32     qDebug() << "+ PosSettingsEngine::PosSettingsEngine()";
       
    33     d_ptr = new PosSettingsEnginePrivate( *this );
       
    34     qDebug() << "- PosSettingsEngine::PosSettingsEngine()";
       
    35     }
       
    36 
       
    37 //---------------------------------------------------------------------
       
    38 // PosSettingsEngine::~PosSettingsEngine()
       
    39 // (other items were commented in a header).
       
    40 //---------------------------------------------------------------------
       
    41 PosSettingsEngine::~PosSettingsEngine()
       
    42     {
       
    43     qDebug() << "+ PosSettingsEngine::~PosSettingsEngine()";
       
    44     delete d_ptr;
       
    45     d_ptr = NULL;
       
    46     qDebug() << "- PosSettingsEngine::~PosSettingsEngine()";
       
    47     }
       
    48 
       
    49 //---------------------------------------------------------------------
       
    50 // PosSettingsEngine::isPositionTechnologyAvailable()
       
    51 // (other items were commented in a header).
       
    52 //---------------------------------------------------------------------
       
    53 bool PosSettingsEngine::isPositionTechnologyAvailable( 
       
    54                                       PositionTechnology posTechnology )
       
    55     {
       
    56     qDebug() << "+ PosSettingsEngine::isPositionTechnologyAvailable()";	
       
    57     bool err = d_ptr->isPositionTechnologyAvailable( posTechnology );   
       
    58     qDebug() << "- PosSettingsEngine::isPositionTechnologyAvailable() retvat: " << err;
       
    59     return err; 
       
    60     }
       
    61 
       
    62 //---------------------------------------------------------------------
       
    63 // PosSettingsEngine::setPositionTechnologyState()
       
    64 // (other items were commented in a header).
       
    65 //---------------------------------------------------------------------
       
    66 int PosSettingsEngine::setPositionTechnologyState( 
       
    67                                        State posTechnologyState,
       
    68                                        PositionTechnology posTechnology )
       
    69     {
       
    70     qDebug() << "+ PosSettingsEngine::setPositionTechnologyState()";
       
    71     qDebug() << "posTechnologyState: " << posTechnologyState;
       
    72     int ret = d_ptr->setPositionTechnologyState( posTechnologyState, 
       
    73                                               posTechnology ); 
       
    74 		qDebug() << "- PosSettingsEngine::setPositionTechnologyState()" << ret;       
       
    75 		return ret;                                       
       
    76     }
       
    77 
       
    78 
       
    79 //---------------------------------------------------------------------
       
    80 // PosSettingsEngine::isPositionTechnologyEnabled()
       
    81 // (other items were commented in a header).
       
    82 //---------------------------------------------------------------------
       
    83 bool PosSettingsEngine::isPositionTechnologyEnabled(
       
    84                                          PositionTechnology posTechnology )
       
    85     {
       
    86     qDebug() << "+ PosSettingsEngine::isPositionTechnologyEnabled()";
       
    87     bool ret = d_ptr->isPositionTechnologyEnabled( posTechnology );  
       
    88     qDebug() << "- PosSettingsEngine::isPositionTechnologyEnabled() retval= " << ret;  
       
    89     return ret;
       
    90     }
       
    91 
       
    92 //---------------------------------------------------------------------
       
    93 // PosSettingsEngine::setBackGroundPositioningState()
       
    94 // (other items were commented in a header).
       
    95 //---------------------------------------------------------------------
       
    96 int PosSettingsEngine::setBackGroundPositioningState( 
       
    97                                              State backGroundPosState )
       
    98     {
       
    99     qDebug() << "+ PosSettingsEngine::setBackGroundPositioningState()";
       
   100     qDebug() << "backGroundPosState: " <<	backGroundPosState;
       
   101     int ret = d_ptr->setBackGroundPositioningState( backGroundPosState );    
       
   102     qDebug() << "- PosSettingsEngine::setBackGroundPositioningState() retval= " << ret;
       
   103     return ret;
       
   104     }
       
   105 
       
   106 //---------------------------------------------------------------------
       
   107 // PosSettingsEngine::isPositionTechnologyEnabled()
       
   108 // (other items were commented in a header).
       
   109 //---------------------------------------------------------------------
       
   110 bool PosSettingsEngine::isBackGroundPositioningEnabled()
       
   111     {
       
   112     qDebug() << "+ PosSettingsEngine::isBackGroundPositioningEnabled()";
       
   113     bool ret = d_ptr->isBackGroundPositioningEnabled();    
       
   114     qDebug() << "- PosSettingsEngine::isBackGroundPositioningEnabled() retval= " << ret;
       
   115     return ret;
       
   116     }
       
   117 
       
   118 // ---------------------------------------------------------------------------
       
   119 // PosSettingsEngine::backgroundPositioningStatus
       
   120 // ---------------------------------------------------------------------------
       
   121 bool PosSettingsEngine::cRBackgroundPositioningStatus()
       
   122     {
       
   123     qDebug() << "+ PosSettingsEngine::isBackGroundPositioningEnabled()";
       
   124     // create a XQSettingsManager instance
       
   125     XQSettingsManager* manager = new XQSettingsManager();
       
   126     // create a XQSettingsKey object to read the cenrep key value
       
   127     XQSettingsKey cenrepKey(XQSettingsKey::TargetCentralRepository,
       
   128             KCRUidPositioningSettings.iUid, KPositioningSettingsBackgroundServicesStatus);
       
   129     // read the cenrep key value
       
   130     QVariant key(manager->readItemValue(cenrepKey,XQSettingsManager::TypeInt));
       
   131     // convert the key value to string
       
   132     int keyIntValue = key.toInt();
       
   133     
       
   134     delete manager;
       
   135     manager = 0;
       
   136     
       
   137     qDebug() << "- PosSettingsEngine::cRBackgroundPositioningStatus()";
       
   138     return keyIntValue;
       
   139     }
       
   140 
       
   141 // ---------------------------------------------------------------------------
       
   142 // PosSettingsEngine::setCRBackgroundPositioningStatus
       
   143 // ---------------------------------------------------------------------------
       
   144 void PosSettingsEngine::setCRBackgroundPositioningStatus(State backGroundPosState)
       
   145     {
       
   146     qDebug() << "+ PosSettingsEngine::isBackGroundPositioningEnabled()";
       
   147     // create a XQSettingsManager instance
       
   148     XQSettingsManager* manager = new XQSettingsManager();
       
   149     // create a XQSettingsKey object to read the cenrep key value
       
   150     XQSettingsKey cenrepKey(XQSettingsKey::TargetCentralRepository,
       
   151             KCRUidPositioningSettings.iUid, KPositioningSettingsBackgroundServicesStatus);
       
   152     
       
   153     // write the cenrep key value
       
   154     if(backGroundPosState == StateEnable)
       
   155         QVariant key(manager->writeItemValue(cenrepKey,QVariant(1)));
       
   156     else
       
   157         QVariant key(manager->writeItemValue(cenrepKey,QVariant(0)));
       
   158     
       
   159     delete manager;
       
   160     manager = 0;
       
   161     qDebug() << "- PosSettingsEngine::setCRBackgroundPositioningStatus()";
       
   162     }
       
   163 
       
   164 //---------------------------------------------------------------------
       
   165 // PosSettingsEngine::handlePositionTechnologyChange()
       
   166 // (other items were commented in a header).
       
   167 //---------------------------------------------------------------------
       
   168 void PosSettingsEngine::handlePositionTechnologyChange()
       
   169     {
       
   170     qDebug() << "+ PosSettingsEngine::handlePositionTechnologyChange()";
       
   171     emit positionTechnologyChange();
       
   172     qDebug() << "- PosSettingsEngine::handlePositionTechnologyChange()";
       
   173     }
       
   174 // End of file.