src/hbservers/hbinputserver/main.cpp
author hgs
Mon, 18 Oct 2010 18:23:13 +0300
changeset 34 ed14f46c0e55
permissions -rw-r--r--
201041
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
34
hgs
parents:
diff changeset
     1
/****************************************************************************
hgs
parents:
diff changeset
     2
**
hgs
parents:
diff changeset
     3
** Copyright (C) 2008-2010 Nokia Corporation and/or its subsidiary(-ies).
hgs
parents:
diff changeset
     4
** All rights reserved.
hgs
parents:
diff changeset
     5
** Contact: Nokia Corporation (developer.feedback@nokia.com)
hgs
parents:
diff changeset
     6
**
hgs
parents:
diff changeset
     7
** This file is part of the HbServers module of the UI Extensions for Mobile.
hgs
parents:
diff changeset
     8
**
hgs
parents:
diff changeset
     9
** GNU Lesser General Public License Usage
hgs
parents:
diff changeset
    10
** This file may be used under the terms of the GNU Lesser General Public
hgs
parents:
diff changeset
    11
** License version 2.1 as published by the Free Software Foundation and
hgs
parents:
diff changeset
    12
** appearing in the file LICENSE.LGPL included in the packaging of this file.
hgs
parents:
diff changeset
    13
** Please review the following information to ensure the GNU Lesser General
hgs
parents:
diff changeset
    14
** Public License version 2.1 requirements will be met:
hgs
parents:
diff changeset
    15
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
hgs
parents:
diff changeset
    16
**
hgs
parents:
diff changeset
    17
** In addition, as a special exception, Nokia gives you certain additional
hgs
parents:
diff changeset
    18
** rights.  These rights are described in the Nokia Qt LGPL Exception
hgs
parents:
diff changeset
    19
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
hgs
parents:
diff changeset
    20
**
hgs
parents:
diff changeset
    21
** If you have questions regarding the use of this file, please contact
hgs
parents:
diff changeset
    22
** Nokia at developer.feedback@nokia.com.
hgs
parents:
diff changeset
    23
**
hgs
parents:
diff changeset
    24
****************************************************************************/
hgs
parents:
diff changeset
    25
hgs
parents:
diff changeset
    26
#include <QApplication>
hgs
parents:
diff changeset
    27
#include <QMainWindow>
hgs
parents:
diff changeset
    28
#include <QPlainTextEdit>
hgs
parents:
diff changeset
    29
#include "hbinputserver_p.h"
hgs
parents:
diff changeset
    30
hgs
parents:
diff changeset
    31
#if defined(Q_OS_SYMBIAN)
hgs
parents:
diff changeset
    32
#include <e32std.h>
hgs
parents:
diff changeset
    33
#include <eikenv.h>
hgs
parents:
diff changeset
    34
#include <apgwgnam.h>
hgs
parents:
diff changeset
    35
hgs
parents:
diff changeset
    36
_LIT(hbinputserver_name, "hbinputserver");
hgs
parents:
diff changeset
    37
#endif // Q_OS_SYMBIAN
hgs
parents:
diff changeset
    38
hgs
parents:
diff changeset
    39
int main(int argc, char **argv)
hgs
parents:
diff changeset
    40
{
hgs
parents:
diff changeset
    41
    QApplication app(argc, argv);
hgs
parents:
diff changeset
    42
    HbInputServer server;
hgs
parents:
diff changeset
    43
#if defined(Q_OS_SYMBIAN)
hgs
parents:
diff changeset
    44
    // Set necessary window group etc. parameters to hide the input server
hgs
parents:
diff changeset
    45
    CEikonEnv *env = CEikonEnv::Static();
hgs
parents:
diff changeset
    46
    if (env) {
hgs
parents:
diff changeset
    47
        CApaWindowGroupName *wgName = CApaWindowGroupName::NewLC(env->WsSession());
hgs
parents:
diff changeset
    48
        env->RootWin().SetOrdinalPosition(0, ECoeWinPriorityNeverAtFront); // avoid coming to foreground
hgs
parents:
diff changeset
    49
        wgName->SetHidden(ETrue); // hide from FSW, OOM fw, GOOM fw, etc.
hgs
parents:
diff changeset
    50
        wgName->SetSystem(ETrue); // allow only apps with PowerManagement cap to shut us down
hgs
parents:
diff changeset
    51
        wgName->SetCaptionL(hbinputserver_name);
hgs
parents:
diff changeset
    52
        wgName->SetAppUid(KNullUid);
hgs
parents:
diff changeset
    53
        wgName->SetWindowGroupName(env->RootWin());
hgs
parents:
diff changeset
    54
        CleanupStack::PopAndDestroy(wgName);
hgs
parents:
diff changeset
    55
        RThread::RenameMe(hbinputserver_name);
hgs
parents:
diff changeset
    56
    }
hgs
parents:
diff changeset
    57
#else
hgs
parents:
diff changeset
    58
    QMainWindow window;
hgs
parents:
diff changeset
    59
    QPlainTextEdit *textViewer = new QPlainTextEdit(&window);
hgs
parents:
diff changeset
    60
    window.setCentralWidget(textViewer);
hgs
parents:
diff changeset
    61
    textViewer->setReadOnly(true);
hgs
parents:
diff changeset
    62
    QObject::connect(&server, SIGNAL(debugMessage(QString)), textViewer, SLOT(appendPlainText(QString)));
hgs
parents:
diff changeset
    63
    window.show();
hgs
parents:
diff changeset
    64
#endif // Q_OS_SYMBIAN
hgs
parents:
diff changeset
    65
hgs
parents:
diff changeset
    66
    // Server start can fail if someone has already created the shared memory blocks,
hgs
parents:
diff changeset
    67
    // i.e. the server is already running. In that case just exit.
hgs
parents:
diff changeset
    68
    int returnValue = 0;
hgs
parents:
diff changeset
    69
    if (server.start()) {
hgs
parents:
diff changeset
    70
        returnValue = app.exec();
hgs
parents:
diff changeset
    71
    }
hgs
parents:
diff changeset
    72
    return returnValue;
hgs
parents:
diff changeset
    73
}