aboutsummaryrefslogtreecommitdiff
path: root/src/extensions/applicationextension/mextensionhandle_p.h
blob: 2e9a228851b2e645a2f0224478065aa49a15fc8f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
/***************************************************************************
**
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (directui@nokia.com)
**
** This file is part of libmeegotouch.
**
** If you have questions regarding the use of this file, please contact
** Nokia at directui@nokia.com.
**
** This library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation
** and appearing in the file LICENSE.LGPL included in the packaging
** of this file.
**
****************************************************************************/

#ifndef MEXTENSIONHANDLE_P_H
#define MEXTENSIONHANDLE_P_H

#include "mextensionhandle.h"
#include "private/mwidgetcontroller_p.h"
#include "mappletserver.h"

#include <QTime>
#include <QTimer>
#include <QProcess>

class MAction;

#ifdef HAVE_CONTEXTSUBSCRIBER
class ContextProperty;
#endif

/*!
 * A private data class for MExtensionHandle.
 */
class MExtensionHandlePrivate : public QObject
{
    Q_DECLARE_PUBLIC(MExtensionHandle)
    Q_OBJECT

public:
    /*!
     * Constructor.
     */
    MExtensionHandlePrivate();

    /*!
     * Destructor.
     */
    virtual ~MExtensionHandlePrivate();

    //! The name for the communication server
    QString serverName;

    //! The arguments that were given to init()
    QStringList arguments;

    //! The name of the runner binary
    QString runnerBinary;

    //! The runner process
    QProcess process;

    //! The number of times this process has been restarted due to malfunction
    int restartCount;

    //! Time since the process was started, for checking how long the remote process could run before breaking
    QTime processStartTime;

    //! A server for IPC communication between the processes
    MAppletServer communicator;

    //! Timer to send alive message requests to runner at constant intervals
    QTimer aliveTimer;

    //! Timer to verify that communication between the processes is working
    QTimer communicationTimer;

    //! Timeout for remote process to respond to an alive request.
    uint aliveResponseTimeout;

    //! Timeout for the runner process to connect to the host process
    uint runnerConnectionTimeout;

    //! Stored geometry
    QRectF oldGeometry;

    //! Application level visibility
    bool applicationVisible;

    //! A list of remote actions
    QList<MAction *> remoteActions;

#ifdef HAVE_CONTEXTSUBSCRIBER
    //! Context property for getting the screen blanking status
    ContextProperty *screenBlankProperty;
#endif

    //! D-Bus service of the Package Manager
    static const QString PACKAGE_MANAGER_DBUS_SERVICE;

    //! D-Bus path of the Package Manager
    static const QString PACKAGE_MANAGER_DBUS_PATH;

    //! D-Bus interface of the Package Manager
    static const QString PACKAGE_MANAGER_DBUS_INTERFACE;

    /*!
     * Sends the necessary visibility change message when the application or
     * widget level visibility has changed
     */
    void visibilityChanged();

public slots:
    /*!
     * Slot for listening to operation complete signals from the Package Manager
     *
     * \param operation Name of the operation. Possible names are: Install, Uninstall and Upgrade
     * \param pkg Name of the package that operation is performed on
     * \param error Empty if operation was successful, DBus error name otherwise
     */
    void operationComplete(const QString &operation, const QString &pkg, const QString &error);

    /*!
      * Receives information about the progress of a Package Manager operation.
      *
      * \param operation Name of the operation. Possible names are: Install, Uninstall and Upgrade
      * \param pkg Name of the package that operation is performed on.
      * \param percentage Current progress percentage
      */
    void operationProgress(const QString &operation, const QString &pkg, int percentage);

protected:
    MExtensionHandle *q_ptr;

};

#endif