~timo-jyrinki/ubuntu/trusty/maliit-framework/fix_qt52

« back to all changes in this revision

Viewing changes to examples/apps/server-embedded/main.cpp

  • Committer: Package Import Robot
  • Author(s): Ricardo Salveti de Araujo, Sergio Schvezov, Ricardo Salveti de Araujo
  • Date: 2013-07-23 19:47:04 UTC
  • mfrom: (1.1.2) (1.2.1 experimental)
  • Revision ID: package-import@ubuntu.com-20130723194704-1lsy1kmlda069cea
Tags: 0.99.0+git20130615+97e8335-0ubuntu1
[ Sergio Schvezov ]
* New build from HEAD 97e8335.
* Packaging import from lp:phablet-extras/maliit-framework.

[ Ricardo Salveti de Araujo ]
* debian/control: adding vcs and fixing dependencies
* General package cleanup

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* * This file is part of Maliit framework *
2
 
 *
3
 
 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
4
 
 * All rights reserved.
5
 
 *
6
 
 * Contact: maliit-discuss@lists.maliit.org
7
 
 *
8
 
 * This library is free software; you can redistribute it and/or
9
 
 * modify it under the terms of the GNU Lesser General Public
10
 
 * License version 2.1 as published by the Free Software Foundation
11
 
 * and appearing in the file LICENSE.LGPL included in the packaging
12
 
 * of this file.
13
 
 */
14
 
 
15
 
#include <QtGlobal>
16
 
 
17
 
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
18
 
#include "mimdummyinputcontext.h"
19
 
#endif
20
 
 
21
 
#include "connectionfactory.h"
22
 
#include "mimserver.h"
23
 
#include "mimstandaloneserverlogic.h"
24
 
 
25
 
#include <QApplication>
26
 
#include <QtDebug>
27
 
#include <QPalette>
28
 
#include <QCommonStyle>
29
 
 
30
 
#if QT_VERSION <= QT_VERSION_CHECK(5, 0, 0)
31
 
#include <stdlib.h>
32
 
#endif
33
 
 
34
 
namespace {
35
 
    void disableMInputContextPlugin()
36
 
    {
37
 
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
38
 
        // none is a special value for QT_IM_MODULE, which disables loading of any
39
 
        // input method module in Qt 5.
40
 
        setenv("QT_IM_MODULE", "none", true);
41
 
#else
42
 
        // prevent loading of minputcontext because we don't need it and starting
43
 
        // it might trigger starting of this service by the d-bus. not nice if that is
44
 
        // already happening :)
45
 
        if (-1 == unsetenv("QT_IM_MODULE")) {
46
 
            qWarning("meego-im-uiserver: unable to unset QT_IM_MODULE.");
47
 
        }
48
 
#endif
49
 
    }
50
 
}
51
 
 
52
 
int main(int argc, char **argv)
53
 
{
54
 
    // QT_IM_MODULE, MApplication and QtMaemo5Style all try to load
55
 
    // MInputContext, which is fine for the application. For the maliit
56
 
    // server, we absolutely need to prevent that.
57
 
    disableMInputContextPlugin();
58
 
 
59
 
    QApplication app(argc, argv);
60
 
    QSharedPointer<MImAbstractServerLogic> serverLogic(new MImStandaloneServerLogic);
61
 
 
62
 
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
63
 
    // Set a dummy input context so that Qt does not create a default input
64
 
    // context (qimsw-multi) which is expensive and not required by
65
 
    // a maliit server.
66
 
    app.setInputContext(new MIMDummyInputContext);
67
 
#endif
68
 
 
69
 
    QSharedPointer<MInputContextConnection> icConnection(Maliit::DBus::createInputContextConnectionWithDynamicAddress());
70
 
 
71
 
    // The actual server
72
 
    MImServer::configureSettings(MImServer::PersistentSettings);
73
 
    MImServer imServer(serverLogic, icConnection);
74
 
    Q_UNUSED(imServer);
75
 
 
76
 
    return app.exec();
77
 
}
78