stateproviders/ftustateprovider/src/ftustatecenrephandler.cpp
changeset 2 66c26770985f
equal deleted inserted replaced
0:c464cd7e2753 2:66c26770985f
       
     1 /*
       
     2 * Copyright (c) 2009 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 the state cenrep handler.
       
    15 *
       
    16 */
       
    17 
       
    18 #include "ftustatecenrephandler.h"
       
    19 
       
    20 #include <xqsettingsmanager.h>
       
    21 #include <QDateTime>
       
    22 
       
    23 
       
    24 /**
       
    25 * Ftu Wizard plugin configuration
       
    26 */
       
    27 const qint32 KCrUidFtuWizardProvider = {0x20026F9B};
       
    28 
       
    29 /**
       
    30 * Describes number of ftu wizard plug-ins listed in the configuration
       
    31 * Type: int
       
    32 */
       
    33 const quint32 KFtuNumberOfWizardPlugins = {0x00000001};
       
    34 
       
    35 /**
       
    36 * Wizard is considered complete if its cenrep has 1. If value is 0, it is incomplete
       
    37 * Type: int
       
    38 */ 
       
    39 const int KWizardComplete = 1;
       
    40 
       
    41 FtuStateCenrepHandler::FtuStateCenrepHandler(QObject *aParent)
       
    42                     :QObject(aParent)
       
    43                     , mTotalNumberOfPlugins(0)
       
    44 {
       
    45 	mSettingsManager = new XQSettingsManager();
       
    46 
       
    47 	// Get total number of plugins registered from Wizard provider
       
    48 	XQSettingsKey numberOfPluginsKey(XQSettingsKey::TargetCentralRepository,
       
    49                                      KCrUidFtuWizardProvider,
       
    50                                      KFtuNumberOfWizardPlugins);
       
    51     bool ok = false;
       
    52     mTotalNumberOfPlugins = mSettingsManager->readItemValue(
       
    53                                         numberOfPluginsKey).toInt(&ok);
       
    54 	if (!ok)
       
    55         mTotalNumberOfPlugins = 0;
       
    56 }
       
    57 
       
    58 /**
       
    59  * Destructor.
       
    60  * @since S60 ?S60_version.
       
    61  */
       
    62 FtuStateCenrepHandler::~FtuStateCenrepHandler()
       
    63 {
       
    64 	delete mSettingsManager;
       
    65 }
       
    66 	
       
    67 
       
    68 /**
       
    69  * Gets info of plugin at an index 1 if complete, 0 if incomplete.
       
    70  * @since S60 ?S60_version.
       
    71  */
       
    72 int FtuStateCenrepHandler::getPluginInfo(int index)
       
    73 {
       
    74 	bool ok = false;
       
    75 	XQSettingsKey reader(XQSettingsKey::TargetCentralRepository, KCrUidFtuStateProvider, index + KBaseIndex);
       
    76 	int pluginInfo = mSettingsManager->readItemValue(reader).toInt(&ok);  
       
    77 	if(!ok){
       
    78 		return -1;
       
    79 	}
       
    80 	else{
       
    81 		return pluginInfo;
       
    82 	}
       
    83 }
       
    84 	
       
    85 /**
       
    86  * Updates plugin info in cenrep.
       
    87  * @since S60 ?S60_version.
       
    88  */
       
    89  int FtuStateCenrepHandler::updatePluginInfo(int indexPluginCompleted)
       
    90  {
       
    91 	 bool ok = false;
       
    92     //FTU HS widget is listening to wizard completion
       
    93     XQSettingsKey  wizardInfoWriter(XQSettingsKey::TargetCentralRepository, KCrUidFtuStateProvider, indexPluginCompleted + KBaseIndex);
       
    94     ok = mSettingsManager->writeItemValue(wizardInfoWriter, KWizardComplete);
       
    95     if(!ok)
       
    96 		return -1;
       
    97  	return 0;
       
    98  }
       
    99 
       
   100 int FtuStateCenrepHandler::registeredPluginCount()
       
   101 {
       
   102     return mTotalNumberOfPlugins;
       
   103 }
       
   104