diff -r 7d48bed6ce0c -r 987c9837762f telutils/keysequencerecognitionservice/src/keysequencerecognitionprovider.cpp --- a/telutils/keysequencerecognitionservice/src/keysequencerecognitionprovider.cpp Tue Aug 31 15:45:17 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,167 +0,0 @@ -/*! -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: Implements Qt Highway provider for key sequence handling. -* -*/ - -#include -#include -#include -#include -#include -#include "keysequencerecognitionprovider.h" -#include "manufacturerkeysequencehandler.h" -#include "imeikeysequencehandler.h" -#include "lifetimerkeysequencehandler.h" -#include "simcontrolkeysequencehandler.h" -#include "keysequencerecognitionservicelog.h" - -/*! - KeySequenceRecognitionProvider::KeySequenceRecognitionProvider. - */ -KeySequenceRecognitionProvider::KeySequenceRecognitionProvider( - QObject* parent) - : - XQServiceProvider(QLatin1String( - "keysequencerecognitionservice.com.nokia.symbian.IKeySequenceRecognition"), - parent), - m_keySequenceValidator("") -{ - DPRINT_METHODENTRYEXIT; - - publishAll(); - - setupLocalization(); - - // One should not call anything exception generating after handlers are - // created because memory for handlers will be leaked on an exception - // while being in c++ constructor. - constructKeySequenceHandlers(); - - // Keysequencerecognitionprovider to be invisible in taskswitcher - TsTaskSettings taskSettings; - taskSettings.setVisibility(false); -} - - -/*! - KeySequenceRecognitionProvider::~KeySequenceRecognitionProvider. - */ -KeySequenceRecognitionProvider::~KeySequenceRecognitionProvider() -{ - DPRINT_METHODENTRYEXIT; -} - - -/*! - KeySequenceRecognitionProvider::keySequenceValidator. - */ -QString KeySequenceRecognitionProvider::keySequenceValidator() -{ - DPRINT_METHODENTRYEXIT; - - if (m_keySequenceValidator.isEmpty()) { - constructKeySequenceValidator(); - } - - return m_keySequenceValidator; -} - - -/*! - KeySequenceRecognitionProvider::executeKeySequence. - */ -bool KeySequenceRecognitionProvider::executeKeySequence( - const QString &keySequence) -{ - DPRINT_METHODENTRYEXIT; - - bool handled = false; - - QList::const_iterator it = m_handlers.constBegin(); - for (;(it != m_handlers.constEnd()) && (!handled); ++it) { - handled = (*it)->executeKeySequence(keySequence); - } - - return handled; -} - - -/*! - KeySequenceRecognitionProvider::setupLocalization. - */ -void KeySequenceRecognitionProvider::setupLocalization() -{ - DPRINT_METHODENTRYEXIT; - - QScopedPointer translator(new QTranslator(this)); - - QString locale = QLocale::system().name(); - QString path = QString("z:/resource/qt/translations/"); - bool translatorLoaded = - translator->load(QString(path + "telephone_" + locale)); - - if (translatorLoaded) { - qApp->installTranslator(translator.data()); - translator.take(); - } -} - - -/*! - KeySequenceRecognitionProvider::constructKeySequenceHandlers. - */ -void KeySequenceRecognitionProvider::constructKeySequenceHandlers() -{ - DPRINT_METHODENTRYEXIT; - - QScopedPointer manufacturerHandler( - new ManufacturerKeySequenceHandler(this)); - m_handlers.append(manufacturerHandler.data()); - manufacturerHandler.take(); - - QScopedPointer imeiHandler( - new ImeiKeySequenceHandler(this)); - m_handlers.append(imeiHandler.data()); - imeiHandler.take(); - - QScopedPointer lifeTimerHandler( - new LifeTimerKeySequenceHandler(this)); - m_handlers.append(lifeTimerHandler.data()); - lifeTimerHandler.take(); - - QScopedPointer simControlHandler( - new SimControlKeySequenceHandler(this)); - m_handlers.append(simControlHandler.data()); - simControlHandler.take(); -} - - -/*! - KeySequenceRecognitionProvider::constructKeySequenceValidator. - */ -void KeySequenceRecognitionProvider::constructKeySequenceValidator() -{ - DPRINT_METHODENTRYEXIT; - - QList::const_iterator it = m_handlers.constBegin(); - for (;it != m_handlers.constEnd(); ++it) { - if (!m_keySequenceValidator.isEmpty()) { - m_keySequenceValidator.append("|"); - } - - QString validator = (*it)->keySequenceValidator(); - m_keySequenceValidator.append(validator); - } -}