|
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 #include "afactivation_p.h" |
|
18 |
|
19 #include <QCoreApplication> |
|
20 |
|
21 #include "afstorageproxy.h" |
|
22 |
|
23 #include "aflauncher.h" |
|
24 #include "afcommandlineparser.h" |
|
25 |
|
26 AfActivationPrivate::AfActivationPrivate(const QSharedPointer<AfStorageProxy> &connection, QObject *parent) : QObject(parent), mReason(Af::ActivationReasonNormal), mConnection(connection) |
|
27 { |
|
28 AfCommandLineParser::parseCommandLine(qApp->arguments(), |
|
29 mReason, |
|
30 mName, |
|
31 mParameters); |
|
32 connect(mConnection.data(), SIGNAL(activityRequested(QString)), this, SLOT(handleActivityRequest(QString))); |
|
33 connect(mConnection.data(), SIGNAL(activityRequested(QString)), this, SLOT(bringToForeground())); |
|
34 } |
|
35 |
|
36 QVariantHash AfActivationPrivate::parameters() const |
|
37 { |
|
38 return mParameters; |
|
39 } |
|
40 |
|
41 Af::ActivationReason AfActivationPrivate::reason() const |
|
42 { |
|
43 return mReason; |
|
44 } |
|
45 |
|
46 QString AfActivationPrivate::name() const |
|
47 { |
|
48 return mName; |
|
49 } |
|
50 |
|
51 void AfActivationPrivate::handleActivityRequest(const QString &activityUri) |
|
52 { |
|
53 mReason = Af::ActivationReasonActivity; |
|
54 mName = QString(); |
|
55 mParameters = QVariantHash(); |
|
56 |
|
57 QUrl uri(activityUri); |
|
58 QVariantHash parameters; |
|
59 QList<QPair<QString, QString> > uriParams = uri.queryItems(); |
|
60 for (QList<QPair<QString, QString> >::const_iterator i = uriParams.constBegin(); i != uriParams.constEnd(); ++i) { |
|
61 parameters.insert(i->first, i->second); |
|
62 } |
|
63 if (parameters.contains(Af::KActivityUriNameKey)) { |
|
64 mName = parameters.value(Af::KActivityUriNameKey).toString(); |
|
65 parameters.remove(Af::KActivityUriNameKey); |
|
66 } |
|
67 mParameters = parameters; |
|
68 |
|
69 emit activated(mReason, mName, mParameters); |
|
70 } |
|
71 |
|
72 void AfActivationPrivate::bringToForeground() |
|
73 { |
|
74 if (!mParameters.contains(Af::KActivityUriBackgroundKey)) { |
|
75 // process all update events from widgets to prevent flickering |
|
76 QCoreApplication::processEvents(); |
|
77 AfLauncher().bringToForeground(RProcess().SecureId().iId); |
|
78 } |
|
79 } |