javamanager/javaqtrequest/src.s60/requestapp.cpp
author hgs
Fri, 23 Jul 2010 12:27:20 +0300
changeset 56 abc41079b313
child 64 0ea12c182930
permissions -rw-r--r--
v2.2.7_1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
56
abc41079b313 v2.2.7_1
hgs
parents:
diff changeset
     1
/*
abc41079b313 v2.2.7_1
hgs
parents:
diff changeset
     2
* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
abc41079b313 v2.2.7_1
hgs
parents:
diff changeset
     3
* All rights reserved.
abc41079b313 v2.2.7_1
hgs
parents:
diff changeset
     4
* This component and the accompanying materials are made available
abc41079b313 v2.2.7_1
hgs
parents:
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
abc41079b313 v2.2.7_1
hgs
parents:
diff changeset
     6
* which accompanies this distribution, and is available
abc41079b313 v2.2.7_1
hgs
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
abc41079b313 v2.2.7_1
hgs
parents:
diff changeset
     8
*
abc41079b313 v2.2.7_1
hgs
parents:
diff changeset
     9
* Initial Contributors:
abc41079b313 v2.2.7_1
hgs
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
abc41079b313 v2.2.7_1
hgs
parents:
diff changeset
    11
*
abc41079b313 v2.2.7_1
hgs
parents:
diff changeset
    12
* Contributors:
abc41079b313 v2.2.7_1
hgs
parents:
diff changeset
    13
*
abc41079b313 v2.2.7_1
hgs
parents:
diff changeset
    14
* Description:  QT Service application the implements support for
abc41079b313 v2.2.7_1
hgs
parents:
diff changeset
    15
*               starting Java applications using "javaapp:" QUrl
abc41079b313 v2.2.7_1
hgs
parents:
diff changeset
    16
*
abc41079b313 v2.2.7_1
hgs
parents:
diff changeset
    17
*/
abc41079b313 v2.2.7_1
hgs
parents:
diff changeset
    18
abc41079b313 v2.2.7_1
hgs
parents:
diff changeset
    19
#include <QList>
abc41079b313 v2.2.7_1
hgs
parents:
diff changeset
    20
#include <QUrl>
abc41079b313 v2.2.7_1
hgs
parents:
diff changeset
    21
#include <xqappmgr.h>
abc41079b313 v2.2.7_1
hgs
parents:
diff changeset
    22
#include <xqaiwrequest.h>
abc41079b313 v2.2.7_1
hgs
parents:
diff changeset
    23
abc41079b313 v2.2.7_1
hgs
parents:
diff changeset
    24
#include "logger.h"
abc41079b313 v2.2.7_1
hgs
parents:
diff changeset
    25
#include "requestapp.h"
abc41079b313 v2.2.7_1
hgs
parents:
diff changeset
    26
abc41079b313 v2.2.7_1
hgs
parents:
diff changeset
    27
abc41079b313 v2.2.7_1
hgs
parents:
diff changeset
    28
RequestApp::RequestApp(int &argc, char **argv) : QApplication(argc, argv)
abc41079b313 v2.2.7_1
hgs
parents:
diff changeset
    29
{
abc41079b313 v2.2.7_1
hgs
parents:
diff changeset
    30
    LOG(EJavaQtServiceApp, EInfo, "RequestApp (QApplication) constructor called");
abc41079b313 v2.2.7_1
hgs
parents:
diff changeset
    31
}
abc41079b313 v2.2.7_1
hgs
parents:
diff changeset
    32
abc41079b313 v2.2.7_1
hgs
parents:
diff changeset
    33
void RequestApp::sendRequest()
abc41079b313 v2.2.7_1
hgs
parents:
diff changeset
    34
{
abc41079b313 v2.2.7_1
hgs
parents:
diff changeset
    35
    QString uriString = arguments().at(1);
abc41079b313 v2.2.7_1
hgs
parents:
diff changeset
    36
    std::wstring stdWStrUri = uriString.toStdWString();
abc41079b313 v2.2.7_1
hgs
parents:
diff changeset
    37
    LOG1(EJavaQtServiceApp, EInfo,
abc41079b313 v2.2.7_1
hgs
parents:
diff changeset
    38
        "SLOT RequestApp::sendRequest called with Uri %S", stdWStrUri.c_str());
abc41079b313 v2.2.7_1
hgs
parents:
diff changeset
    39
abc41079b313 v2.2.7_1
hgs
parents:
diff changeset
    40
    QUrl uri(uriString);
abc41079b313 v2.2.7_1
hgs
parents:
diff changeset
    41
    XQApplicationManager appMgr;
abc41079b313 v2.2.7_1
hgs
parents:
diff changeset
    42
    XQAiwRequest *request = appMgr.create(uri);
abc41079b313 v2.2.7_1
hgs
parents:
diff changeset
    43
    if (!request)
abc41079b313 v2.2.7_1
hgs
parents:
diff changeset
    44
    {
abc41079b313 v2.2.7_1
hgs
parents:
diff changeset
    45
        // No handlers for the URI
abc41079b313 v2.2.7_1
hgs
parents:
diff changeset
    46
        ELOG1(EJavaQtServiceApp,
abc41079b313 v2.2.7_1
hgs
parents:
diff changeset
    47
            "RequestApp::sendRequest No QtHighway service found for URI: %S",
abc41079b313 v2.2.7_1
hgs
parents:
diff changeset
    48
            stdWStrUri.c_str());
abc41079b313 v2.2.7_1
hgs
parents:
diff changeset
    49
        exit(KErrNotFound);
abc41079b313 v2.2.7_1
hgs
parents:
diff changeset
    50
        return;
abc41079b313 v2.2.7_1
hgs
parents:
diff changeset
    51
    }
abc41079b313 v2.2.7_1
hgs
parents:
diff changeset
    52
abc41079b313 v2.2.7_1
hgs
parents:
diff changeset
    53
    // Set function parameters
abc41079b313 v2.2.7_1
hgs
parents:
diff changeset
    54
    QList<QVariant> args;
abc41079b313 v2.2.7_1
hgs
parents:
diff changeset
    55
    args << uri.toString();
abc41079b313 v2.2.7_1
hgs
parents:
diff changeset
    56
    request->setArguments(args);
abc41079b313 v2.2.7_1
hgs
parents:
diff changeset
    57
abc41079b313 v2.2.7_1
hgs
parents:
diff changeset
    58
    // Send the request
abc41079b313 v2.2.7_1
hgs
parents:
diff changeset
    59
    if  (!request->send())
abc41079b313 v2.2.7_1
hgs
parents:
diff changeset
    60
    {
abc41079b313 v2.2.7_1
hgs
parents:
diff changeset
    61
        // Request failed.
abc41079b313 v2.2.7_1
hgs
parents:
diff changeset
    62
        int error = request->lastError();
abc41079b313 v2.2.7_1
hgs
parents:
diff changeset
    63
        ELOG2(EJavaQtServiceApp,
abc41079b313 v2.2.7_1
hgs
parents:
diff changeset
    64
            "RequestApp::sendRequest QtHighway request failed "
abc41079b313 v2.2.7_1
hgs
parents:
diff changeset
    65
            "with err %d, URI was %S",
abc41079b313 v2.2.7_1
hgs
parents:
diff changeset
    66
            error, stdWStrUri.c_str());
abc41079b313 v2.2.7_1
hgs
parents:
diff changeset
    67
        delete request;
abc41079b313 v2.2.7_1
hgs
parents:
diff changeset
    68
        exit(KErrCompletion);
abc41079b313 v2.2.7_1
hgs
parents:
diff changeset
    69
        return;
abc41079b313 v2.2.7_1
hgs
parents:
diff changeset
    70
    }
abc41079b313 v2.2.7_1
hgs
parents:
diff changeset
    71
abc41079b313 v2.2.7_1
hgs
parents:
diff changeset
    72
    delete request;
abc41079b313 v2.2.7_1
hgs
parents:
diff changeset
    73
abc41079b313 v2.2.7_1
hgs
parents:
diff changeset
    74
    exit(KErrNone); // Exit with OK status
abc41079b313 v2.2.7_1
hgs
parents:
diff changeset
    75
}
abc41079b313 v2.2.7_1
hgs
parents:
diff changeset
    76
abc41079b313 v2.2.7_1
hgs
parents:
diff changeset
    77
abc41079b313 v2.2.7_1
hgs
parents:
diff changeset
    78