javamanager/javaqtrequest/src.s60/requestapp.cpp
changeset 61 bf7ee68962da
child 64 0ea12c182930
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/javamanager/javaqtrequest/src.s60/requestapp.cpp	Wed Aug 18 09:43:15 2010 +0300
@@ -0,0 +1,78 @@
+/*
+* 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:  QT Service application the implements support for
+*               starting Java applications using "javaapp:" QUrl
+*
+*/
+
+#include <QList>
+#include <QUrl>
+#include <xqappmgr.h>
+#include <xqaiwrequest.h>
+
+#include "logger.h"
+#include "requestapp.h"
+
+
+RequestApp::RequestApp(int &argc, char **argv) : QApplication(argc, argv)
+{
+    LOG(EJavaQtServiceApp, EInfo, "RequestApp (QApplication) constructor called");
+}
+
+void RequestApp::sendRequest()
+{
+    QString uriString = arguments().at(1);
+    std::wstring stdWStrUri = uriString.toStdWString();
+    LOG1(EJavaQtServiceApp, EInfo,
+        "SLOT RequestApp::sendRequest called with Uri %S", stdWStrUri.c_str());
+
+    QUrl uri(uriString);
+    XQApplicationManager appMgr;
+    XQAiwRequest *request = appMgr.create(uri);
+    if (!request)
+    {
+        // No handlers for the URI
+        ELOG1(EJavaQtServiceApp,
+            "RequestApp::sendRequest No QtHighway service found for URI: %S",
+            stdWStrUri.c_str());
+        exit(KErrNotFound);
+        return;
+    }
+
+    // Set function parameters
+    QList<QVariant> args;
+    args << uri.toString();
+    request->setArguments(args);
+
+    // Send the request
+    if  (!request->send())
+    {
+        // Request failed.
+        int error = request->lastError();
+        ELOG2(EJavaQtServiceApp,
+            "RequestApp::sendRequest QtHighway request failed "
+            "with err %d, URI was %S",
+            error, stdWStrUri.c_str());
+        delete request;
+        exit(KErrCompletion);
+        return;
+    }
+
+    delete request;
+
+    exit(KErrNone); // Exit with OK status
+}
+
+
+