homescreenapp/hsapplication/src/hshomescreen.cpp
author hgs
Fri, 06 Aug 2010 13:36:36 +0300
changeset 71 1db7cc813a4e
parent 63 52b0f64eeb51
child 86 e4f038c420f7
permissions -rw-r--r--
201031
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     1
/*
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     2
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     3
* All rights reserved.
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     4
* This component and the accompanying materials are made available
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     6
* which accompanies this distribution, and is available
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     8
*
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     9
* Initial Contributors:
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    11
*
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    12
* Contributors:
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    13
*
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    14
* Description:  Homescreen application main class.
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    15
*
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    16
*/
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    17
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    18
#include <QStateMachine>
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    19
#include <QDir>
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    20
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    21
#include <qservicemanager.h>
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    22
#include <qservicefilter.h>
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    23
#include <qserviceinterfacedescriptor.h>
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    24
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    25
#include <HbInstance>
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    26
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    27
#include "hshomescreen.h"
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    28
#include "hstest_global.h"
63
hgs
parents: 39
diff changeset
    29
#include "hsstatemachine.h"
36
cdae8c6c3876 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 35
diff changeset
    30
#ifdef Q_OS_SYMBIAN
cdae8c6c3876 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 35
diff changeset
    31
#include "hshomescreenclientserviceprovider.h"
cdae8c6c3876 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 35
diff changeset
    32
#endif
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    33
QTM_USE_NAMESPACE
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    34
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    35
/*!
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    36
    \class HsHomeScreen
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    37
    \ingroup group_hsapplication
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    38
    \brief Homescreen application main class.
63
hgs
parents: 39
diff changeset
    39
    Manages the state machine execution.
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    40
*/
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    41
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    42
/*!
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    43
    Constructor.
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    44
    \a parent Parent object.
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    45
*/
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    46
HsHomeScreen::HsHomeScreen(QObject *parent)
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    47
  : QObject(parent),
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    48
    mRuntime(0)
36
cdae8c6c3876 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 35
diff changeset
    49
#ifdef Q_OS_SYMBIAN
cdae8c6c3876 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 35
diff changeset
    50
    ,mHomeScreenClientServiceProvider(0)
cdae8c6c3876 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 35
diff changeset
    51
#endif
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    52
{
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    53
    HSTEST_FUNC_ENTRY("HS::HsHomeScreen::HsHomeScreen");
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    54
63
hgs
parents: 39
diff changeset
    55
    registerServicePlugins();
36
cdae8c6c3876 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 35
diff changeset
    56
    
63
hgs
parents: 39
diff changeset
    57
    mRuntime = new HsStateMachine(this);
36
cdae8c6c3876 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 35
diff changeset
    58
63
hgs
parents: 39
diff changeset
    59
    connect(mRuntime, SIGNAL(started()), SLOT(onRuntimeStarted()));
hgs
parents: 39
diff changeset
    60
    connect(mRuntime, SIGNAL(stopped()), SLOT(onRuntimeStopped()));
hgs
parents: 39
diff changeset
    61
    hbInstance->allMainWindows().first()->installEventFilter(this);
36
cdae8c6c3876 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 35
diff changeset
    62
#ifdef Q_OS_SYMBIAN
63
hgs
parents: 39
diff changeset
    63
    mHomeScreenClientServiceProvider = new HsHomeScreenClientServiceProvider;
hgs
parents: 39
diff changeset
    64
    mHomeScreenClientServiceProvider->setParent(this);
36
cdae8c6c3876 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 35
diff changeset
    65
#endif
cdae8c6c3876 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 35
diff changeset
    66
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    67
    HSTEST_FUNC_EXIT("HS::HsHomeScreen::HsHomeScreen");
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    68
}
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    69
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    70
/*!
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    71
    Destructor.
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    72
*/
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    73
HsHomeScreen::~HsHomeScreen()
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    74
{
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    75
}
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    76
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    77
/*!
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    78
    \fn void HsHomeScreen::exit()
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    79
    Emitted when the home screen application needs to exit.
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    80
*/
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    81
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    82
/*!
63
hgs
parents: 39
diff changeset
    83
    Starts the state machine.
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    84
*/
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    85
void HsHomeScreen::start()
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    86
{
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    87
    HSTEST_FUNC_ENTRY("HS::HsHomeScreen::start");
63
hgs
parents: 39
diff changeset
    88
    mRuntime->start();
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    89
    HSTEST_FUNC_EXIT("HS::HsHomeScreen::start");
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    90
}
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    91
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    92
/*!
63
hgs
parents: 39
diff changeset
    93
    Stops the state machine.
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    94
*/
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    95
void HsHomeScreen::stop()
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    96
{
63
hgs
parents: 39
diff changeset
    97
	if (mRuntime->isRunning()) {
36
cdae8c6c3876 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 35
diff changeset
    98
        QEventLoop eventLoop;
cdae8c6c3876 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 35
diff changeset
    99
        connect(mRuntime, SIGNAL(finished()), &eventLoop, SLOT(quit()));
cdae8c6c3876 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 35
diff changeset
   100
        QMetaObject::invokeMethod(mRuntime, "event_exit", Qt::QueuedConnection);
cdae8c6c3876 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 35
diff changeset
   101
        eventLoop.exec();
cdae8c6c3876 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 35
diff changeset
   102
    }
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   103
}
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   104
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   105
/*!
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   106
    \copydoc QObject::eventFilter(QObject *watched, QEvent *event)
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   107
*/
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   108
bool HsHomeScreen::eventFilter(QObject *watched, QEvent *event)
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   109
{
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   110
    Q_UNUSED(watched);
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   111
    if (event->type() == QEvent::Close) {
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   112
        return true;
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   113
    }
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   114
    return false;
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   115
}
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   116
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   117
/*!
63
hgs
parents: 39
diff changeset
   118
    Called after the state machine has started.
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   119
*/
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   120
void HsHomeScreen::onRuntimeStarted()
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   121
{
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   122
}
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   123
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   124
/*!
63
hgs
parents: 39
diff changeset
   125
    Called after the state machine has stopped.
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   126
*/
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   127
void HsHomeScreen::onRuntimeStopped()
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   128
{
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   129
    emit exit();
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   130
}
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   131
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   132
/*!
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   133
    Registers service plugins pre-installed on the device.
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   134
*/
63
hgs
parents: 39
diff changeset
   135
void HsHomeScreen::registerServicePlugins()
hgs
parents: 39
diff changeset
   136
{    
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   137
    HSTEST_FUNC_ENTRY("HS::HsHomeScreen::registerServicePlugins()");
63
hgs
parents: 39
diff changeset
   138
    
hgs
parents: 39
diff changeset
   139
    QServiceManager serviceManager;
hgs
parents: 39
diff changeset
   140
    
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   141
    QStringList pluginPaths;
39
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   142
    
71
hgs
parents: 63
diff changeset
   143
    pluginPaths << "private/20022F35";
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   144
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   145
    QFileInfoList drives = QDir::drives();
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   146
    foreach(const QString pluginPath, pluginPaths) {
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   147
#ifdef Q_OS_SYMBIAN
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   148
        //Check plugin dirs from root of different drives
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   149
        foreach(QFileInfo drive, drives) {
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   150
            QString driveLetter = drive.absolutePath();
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   151
            QString path = driveLetter + pluginPath;
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   152
            if(QDir(path).exists()) {
36
cdae8c6c3876 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 35
diff changeset
   153
                registerServicePlugins(path, serviceManager);
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   154
            }
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   155
        }
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   156
#endif
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   157
        //Check plugin path relative to current dir
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   158
        if(QDir(pluginPath).exists()) {
36
cdae8c6c3876 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 35
diff changeset
   159
            registerServicePlugins(pluginPath, serviceManager);
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   160
        }
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   161
    }
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   162
    HSTEST_FUNC_EXIT("HS::HsHomeScreen::registerServicePlugins()");
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   163
}
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   164
71
hgs
parents: 63
diff changeset
   165
#ifdef COVERAGE_MEASUREMENT 
hgs
parents: 63
diff changeset
   166
#ifndef Q_OS_SYMBIAN 
hgs
parents: 63
diff changeset
   167
#pragma CTC SKIP
hgs
parents: 63
diff changeset
   168
#endif // Q_OS_SYMBIAN
hgs
parents: 63
diff changeset
   169
#endif //COVERAGE_MEASUREMENT
hgs
parents: 63
diff changeset
   170
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   171
/*!
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   172
    Recursively registers service plugins starting from given /a root
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   173
    directory. All directories containing plugins are added to
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   174
    application's library paths at the same time.
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   175
*/
36
cdae8c6c3876 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 35
diff changeset
   176
void HsHomeScreen::registerServicePlugins(const QString &root, QServiceManager &serviceManager)
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   177
{
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   178
    HSTEST_FUNC_ENTRY("HS::HsHomeScreen::registerServicePlugins(const QString &)");
36
cdae8c6c3876 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 35
diff changeset
   179
    QDir dir(root);
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   180
    QFileInfoList fileInfos = dir.entryInfoList(QDir::AllDirs | QDir::NoDotAndDotDot);
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   181
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   182
    foreach (QFileInfo fileInfo, fileInfos) {
36
cdae8c6c3876 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 35
diff changeset
   183
        registerServicePlugins(fileInfo.absoluteFilePath(), serviceManager);
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   184
    }
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   185
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   186
    fileInfos = dir.entryInfoList(QStringList("*.xml"));
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   187
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   188
    if (!fileInfos.isEmpty()) {
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   189
        //Plugin dll and xml are in the same directory
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   190
        QApplication::addLibraryPath(root);
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   191
        qDebug() << QString("HS::HsHomeScreen::registerServicePlugins - Directory added to application's library paths: ")
36
cdae8c6c3876 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 35
diff changeset
   192
                 << root;        
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   193
        foreach(QFileInfo fileInfo, fileInfos) {
36
cdae8c6c3876 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 35
diff changeset
   194
            if (serviceManager.addService(fileInfo.absoluteFilePath())) {
cdae8c6c3876 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 35
diff changeset
   195
                qDebug() << QString("HS::HsHomeScreen::registerServicePlugins - Plugin registered: ") + fileInfo.fileName();
cdae8c6c3876 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 35
diff changeset
   196
            } else {
cdae8c6c3876 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 35
diff changeset
   197
                qDebug() << QString("HS::HsHomeScreen::registerServicePlugins - Plugin FAILED to register: ") + fileInfo.fileName();
cdae8c6c3876 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 35
diff changeset
   198
            }
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   199
        }
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   200
    }
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   201
    HSTEST_FUNC_EXIT("HS::HsHomeScreen::registerServicePlugins(const QString &)");
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   202
}
71
hgs
parents: 63
diff changeset
   203
hgs
parents: 63
diff changeset
   204
#ifdef COVERAGE_MEASUREMENT
hgs
parents: 63
diff changeset
   205
#ifndef Q_OS_SYMBIAN 
hgs
parents: 63
diff changeset
   206
#pragma CTC ENDSKIP
hgs
parents: 63
diff changeset
   207
#endif // Q_OS_SYMBIAN
hgs
parents: 63
diff changeset
   208
#endif //COVERAGE_MEASUREMENT