maemoremotemounter.h 4.23 KB
Newer Older
1
2
3
4
/**************************************************************************
**
** This file is part of Qt Creator
**
hjk's avatar
hjk committed
5
** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies).
6
**
Eike Ziller's avatar
Eike Ziller committed
7
** Contact: http://www.qt-project.org/
8
9
10
11
**
**
** GNU Lesser General Public License Usage
**
hjk's avatar
hjk committed
12
13
14
15
16
17
** This file may be used 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.
** Please review the following information to ensure the GNU Lesser General
** Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
18
**
con's avatar
con committed
19
** In addition, as a special exception, Nokia gives you certain additional
hjk's avatar
hjk committed
20
** rights. These rights are described in the Nokia Qt LGPL Exception
con's avatar
con committed
21
22
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
hjk's avatar
hjk committed
23
24
25
26
27
** Other Usage
**
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
28
29
30
31
32
33
34
35
**
**************************************************************************/

#ifndef MAEMOREMOTEMOUNTER_H
#define MAEMOREMOTEMOUNTER_H

#include "maemomountspecification.h"

36
#include <projectexplorer/devicesupport/idevice.h>
Tobias Hunger's avatar
Tobias Hunger committed
37
38
#include <utils/fileutils.h>

39
40
41
42
43
#include <QList>
#include <QObject>
#include <QProcess>
#include <QSharedPointer>
#include <QString>
44

45
QT_FORWARD_DECLARE_CLASS(QTimer)
46

47
namespace QSsh {
48
49
50
51
class SshConnection;
class SshRemoteProcess;
}

52
namespace Utils { class PortList; }
53
namespace Qt4ProjectManager { class Qt4BuildConfiguration; }
54
namespace RemoteLinux { class RemoteLinuxUsedPortsGatherer; }
55

56
namespace Madde {
57
58
59
60
61
62
namespace Internal {

class MaemoRemoteMounter : public QObject
{
    Q_OBJECT
public:
63
    MaemoRemoteMounter(QObject *parent);
64
    ~MaemoRemoteMounter();
65
66

    // Must already be connected.
67
    void setConnection(QSsh::SshConnection *connection,
68
        const ProjectExplorer::IDevice::ConstPtr &devConf);
69

70
    void setBuildConfiguration(const Qt4ProjectManager::Qt4BuildConfiguration *bc);
71
    void addMountSpecification(const MaemoMountSpecification &mountSpec,
ck's avatar
ck committed
72
        bool mountAsRoot);
73
    bool hasValidMountSpecifications() const;
74
    void resetMountSpecifications() { m_mountSpecs.clear(); }
Kai Koehne's avatar
Kai Koehne committed
75
    void mount(Utils::PortList *freePorts,
76
        const RemoteLinux::RemoteLinuxUsedPortsGatherer *portsGatherer);
77
78
79
80
81
82
83
    void unmount();
    void stop();

signals:
    void mounted();
    void unmounted();
    void error(const QString &reason);
84
    void reportProgress(const QString &progressOutput);
85
    void debugOutput(const QString &output);
86
87

private slots:
88
    void handleUtfsClientsStarted();
89
    void handleUtfsClientsFinished(int exitStatus);
90
91
    void handleUnmountProcessFinished(int exitStatus);
    void handleUtfsServerError(QProcess::ProcessError procError);
92
93
94
    void handleUtfsServerFinished(int exitCode,
        QProcess::ExitStatus exitStatus);
    void handleUtfsServerTimeout();
95
    void handleUtfsServerStderr();
96
    void startUtfsServers();
97
98

private:
99
    enum State {
100
101
        Inactive, Unmounting, UtfsClientsStarting, UtfsClientsStarted,
            UtfsServersStarted
102
103
104
105
    };

    void setState(State newState);

106
    void startUtfsClients();
107
108
    void killUtfsServer(QProcess *proc);
    void killAllUtfsServers();
109
    QString utfsClientOnDevice() const;
Tobias Hunger's avatar
Tobias Hunger committed
110
    Utils::FileName utfsServer() const;
111

112
    QTimer * const m_utfsServerTimer;
ck's avatar
ck committed
113
114

    struct MountInfo {
115
116
        MountInfo(const MaemoMountSpecification &m, bool root)
            : mountSpec(m), mountAsRoot(root), remotePort(-1) {}
ck's avatar
ck committed
117
118
        MaemoMountSpecification mountSpec;
        bool mountAsRoot;
119
        int remotePort;
ck's avatar
ck committed
120
    };
121

122
    QSsh::SshConnection *m_connection;
123
    ProjectExplorer::IDevice::ConstPtr m_devConf;
ck's avatar
ck committed
124
    QList<MountInfo> m_mountSpecs;
125
126
    QSharedPointer<QSsh::SshRemoteProcess> m_mountProcess;
    QSharedPointer<QSsh::SshRemoteProcess> m_unmountProcess;
127
128

    typedef QSharedPointer<QProcess> ProcPtr;
129
    QList<ProcPtr> m_utfsServers;
130

Kai Koehne's avatar
Kai Koehne committed
131
    Utils::PortList *m_freePorts;
132
    const RemoteLinux::RemoteLinuxUsedPortsGatherer *m_portsGatherer;
133
    bool m_remoteMountsAllowed;
Tobias Hunger's avatar
Tobias Hunger committed
134
    Utils::FileName m_maddeRoot;
135
136

    State m_state;
137
138
139
};

} // namespace Internal
140
} // namespace Madde
141
142

#endif // MAEMOREMOTEMOUNTER_H