9
|
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:
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
#include <QDesktopServices>
|
|
20 |
#include <xqapplicationmanager.h>
|
|
21 |
#include <QUrl>
|
|
22 |
#include <qservicemanager.h>
|
|
23 |
#include "isengine.h"
|
|
24 |
#include "isproviderdbmanager.h"
|
|
25 |
QTM_USE_NAMESPACE
|
|
26 |
const QString KAppUid = "0x2002C377";
|
|
27 |
|
|
28 |
IsEngine::IsEngine(QObject *parent) :
|
|
29 |
QObject(parent), m_activityManager(0)
|
|
30 |
{
|
|
31 |
QServiceManager serviceManager;
|
|
32 |
m_activityManager = serviceManager.loadInterface(
|
|
33 |
"com.nokia.qt.activities.ActivityManager");
|
|
34 |
|
|
35 |
m_dbHandler = new IsProviderDBManager;
|
|
36 |
}
|
|
37 |
|
|
38 |
IsEngine::~IsEngine()
|
|
39 |
{
|
|
40 |
if (m_activityManager)
|
|
41 |
{
|
|
42 |
delete m_activityManager;
|
|
43 |
}
|
|
44 |
|
|
45 |
delete m_dbHandler;
|
|
46 |
}
|
|
47 |
|
|
48 |
/*!
|
|
49 |
* \brief Sets selected provider
|
|
50 |
* Returns false if something goes wrong with the database access
|
|
51 |
*/
|
|
52 |
bool IsEngine::SetSelectedProvider(const int providerId)
|
|
53 |
{
|
|
54 |
return m_dbHandler->SetSelectedProvider(providerId);
|
|
55 |
}
|
|
56 |
|
|
57 |
/*!
|
|
58 |
* \brief Gets selected provider
|
|
59 |
*/
|
|
60 |
ServiceProvider* IsEngine::SelectedProvider()
|
|
61 |
{
|
|
62 |
return m_dbHandler->SelectedProvider();
|
|
63 |
}
|
|
64 |
|
|
65 |
/*!
|
|
66 |
* \brief Gets list of providers allowed in the current country.
|
|
67 |
* Returns false if something goes wrong with the database access
|
|
68 |
*/
|
|
69 |
bool IsEngine::Providers(QList<ServiceProvider>& providers)
|
|
70 |
{
|
|
71 |
return m_dbHandler->GetProviders(providers);
|
|
72 |
}
|
|
73 |
|
|
74 |
/*!
|
|
75 |
* \brief Performs internet search by creating search url and opening the browser
|
|
76 |
* with it.
|
|
77 |
*/
|
|
78 |
void IsEngine::PerformWebSearch(const QString &searchParam)
|
|
79 |
{
|
|
80 |
ServiceProvider* provider = SelectedProvider();
|
|
81 |
|
|
82 |
if (provider)
|
|
83 |
{
|
|
84 |
QString url;
|
|
85 |
if ( searchParam.length() )
|
|
86 |
{
|
|
87 |
// add search param to url
|
|
88 |
url.append((provider->ProviderUrl().arg(searchParam)));
|
|
89 |
}
|
|
90 |
else
|
|
91 |
{
|
|
92 |
// search with empty param
|
|
93 |
url.append((provider->ProviderUrl().arg("")));
|
|
94 |
}
|
|
95 |
|
|
96 |
|
|
97 |
// Launch the browser
|
|
98 |
QDesktopServices::openUrl(QUrl(url));
|
|
99 |
}
|
|
100 |
}
|
|
101 |
|
|
102 |
/*!
|
|
103 |
* \brief Performs in device search
|
|
104 |
*
|
|
105 |
* \param searchParam a const QString & argument.
|
|
106 |
*/
|
|
107 |
void IsEngine::PerformInDeviceSearch(const QString &searchParam) const
|
|
108 |
{
|
|
109 |
QUrl url;
|
|
110 |
url.setScheme("appto");
|
|
111 |
url.setHost(KAppUid);
|
|
112 |
url.addQueryItem("activityname", "SearchDeviceQueryView");
|
|
113 |
|
|
114 |
url.addQueryItem("query", searchParam);
|
|
115 |
|
|
116 |
QString debugString = url.toString();
|
|
117 |
bool ok = QMetaObject::invokeMethod(m_activityManager, "launchActivity",
|
|
118 |
Q_ARG(QUrl, url));
|
|
119 |
|
|
120 |
}
|