Maemo: Introduce class for maemo-global functions.

This commit is contained in:
ck
2010-07-13 17:00:12 +02:00
parent 9bd53be4c9
commit e17b99e7f3
8 changed files with 115 additions and 26 deletions

View File

@@ -32,6 +32,7 @@
#include "maemoconstants.h" #include "maemoconstants.h"
#include "maemodeployables.h" #include "maemodeployables.h"
#include "maemodeploystepwidget.h" #include "maemodeploystepwidget.h"
#include "maemoglobal.h"
#include "maemopackagecreationstep.h" #include "maemopackagecreationstep.h"
#include "maemorunconfiguration.h" #include "maemorunconfiguration.h"
@@ -191,7 +192,7 @@ void MaemoDeployStep::stop()
QString MaemoDeployStep::uploadDir() const QString MaemoDeployStep::uploadDir() const
{ {
return homeDirOnDevice(m_connection->connectionParameters().uname); return MaemoGlobal::homeDirOnDevice(m_connection->connectionParameters().uname);
} }
bool MaemoDeployStep::currentlyNeedsDeployment(const QString &host, bool MaemoDeployStep::currentlyNeedsDeployment(const QString &host,
@@ -350,7 +351,7 @@ void MaemoDeployStep::handleSftpJobFinished(Core::SftpJobId job,
.arg(deployInfo.first.localFilePath)); .arg(deployInfo.first.localFilePath));
const QString remoteFilePath = deployInfo.first.remoteDir + '/' const QString remoteFilePath = deployInfo.first.remoteDir + '/'
+ QFileInfo(deployInfo.first.localFilePath).fileName(); + QFileInfo(deployInfo.first.localFilePath).fileName();
QByteArray linkCommand = remoteSudo().toUtf8() + " ln -sf " QByteArray linkCommand = MaemoGlobal::remoteSudo().toUtf8() + " ln -sf "
+ deployInfo.second.toUtf8() + ' ' + remoteFilePath.toUtf8(); + deployInfo.second.toUtf8() + ' ' + remoteFilePath.toUtf8();
SshRemoteProcess::Ptr linkProcess SshRemoteProcess::Ptr linkProcess
= m_connection->createRemoteProcess(linkCommand); = m_connection->createRemoteProcess(linkCommand);
@@ -397,8 +398,8 @@ void MaemoDeployStep::handleLinkProcessFinished(int exitStatus)
writeOutput(tr("Installing package ...")); writeOutput(tr("Installing package ..."));
const QString packageFileName const QString packageFileName
= QFileInfo(packagingStep()->packageFilePath()).fileName(); = QFileInfo(packagingStep()->packageFilePath()).fileName();
const QByteArray cmd = remoteSudo().toUtf8() + " dpkg -i " const QByteArray cmd = MaemoGlobal::remoteSudo().toUtf8()
+ packageFileName.toUtf8(); + " dpkg -i " + packageFileName.toUtf8();
m_installer = m_connection->createRemoteProcess(cmd); m_installer = m_connection->createRemoteProcess(cmd);
connect(m_installer.data(), SIGNAL(closed(int)), this, connect(m_installer.data(), SIGNAL(closed(int)), this,
SLOT(handleInstallationFinished(int))); SLOT(handleInstallationFinished(int)));

View File

@@ -48,18 +48,6 @@ typedef Core::SshConnectionParameters::AuthType AuthType;
namespace Qt4ProjectManager { namespace Qt4ProjectManager {
namespace Internal { namespace Internal {
QString homeDirOnDevice(const QString &uname)
{
return uname == QLatin1String("root")
? QString::fromLatin1("/root")
: QLatin1String("/home/") + uname;
}
QString remoteSudo()
{
return QLatin1String("/usr/lib/mad-developer/devrootsh");
}
namespace { namespace {
const QLatin1String SettingsGroup("MaemoDeviceConfigs"); const QLatin1String SettingsGroup("MaemoDeviceConfigs");
const QLatin1String IdCounterKey("IdCounter"); const QLatin1String IdCounterKey("IdCounter");

View File

@@ -48,9 +48,6 @@ QT_END_NAMESPACE
namespace Qt4ProjectManager { namespace Qt4ProjectManager {
namespace Internal { namespace Internal {
QString homeDirOnDevice(const QString &uname);
QString remoteSudo();
class MaemoDeviceConfig class MaemoDeviceConfig
{ {
public: public:

View File

@@ -0,0 +1,48 @@
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** Commercial Usage
**
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
**
** Alternatively, 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.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at http://qt.nokia.com/contact.
**
**************************************************************************/
#include "maemoglobal.h"
namespace Qt4ProjectManager {
namespace Internal {
QString MaemoGlobal::homeDirOnDevice(const QString &uname)
{
return uname == QLatin1String("root")
? QString::fromLatin1("/root")
: QLatin1String("/home/") + uname;
}
QString MaemoGlobal::remoteSudo()
{
return QLatin1String("/usr/lib/mad-developer/devrootsh");
}
} // namespace Internal
} // namespace Qt4ProjectManager

View File

@@ -0,0 +1,52 @@
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** Commercial Usage
**
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
**
** Alternatively, 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.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at http://qt.nokia.com/contact.
**
**************************************************************************/
#ifndef MAEMOGLOBAL_H
#define MAEMOGLOBAL_H
#include <projectexplorer/buildconfiguration.h>
QT_BEGIN_NAMESPACE
class QString;
QT_END_NAMESPACE
namespace Qt4ProjectManager {
namespace Internal {
class MaemoGlobal
{
public:
static QString homeDirOnDevice(const QString &uname);
static QString remoteSudo();
};
} // namespace Internal
} // namespace Qt4ProjectManager
#endif // MAEMOGLOBAL_H

View File

@@ -49,7 +49,7 @@
#include <QtCore/QStringBuilder> #include <QtCore/QStringBuilder>
namespace Qt4ProjectManager { namespace Qt4ProjectManager {
namespace Internal { namespace Internal {
using namespace ProjectExplorer; using namespace ProjectExplorer;
@@ -269,5 +269,5 @@ void MaemoRunConfiguration::updateDeviceConfigurations()
emit deviceConfigurationsUpdated(target()); emit deviceConfigurationsUpdated(target());
} }
} // namespace Internal } // namespace Internal
} // namespace Qt4ProjectManager } // namespace Qt4ProjectManager

View File

@@ -36,6 +36,7 @@
#include "maemodeployables.h" #include "maemodeployables.h"
#include "maemodeploystep.h" #include "maemodeploystep.h"
#include "maemoglobal.h"
#include "maemopackagecreationstep.h" #include "maemopackagecreationstep.h"
#include "maemorunconfiguration.h" #include "maemorunconfiguration.h"
@@ -271,13 +272,13 @@ const QString AbstractMaemoRunControl::executableFileName() const
const QString AbstractMaemoRunControl::uploadDir() const const QString AbstractMaemoRunControl::uploadDir() const
{ {
return homeDirOnDevice(m_devConfig.server.uname); return MaemoGlobal::homeDirOnDevice(m_devConfig.server.uname);
} }
const QString AbstractMaemoRunControl::targetCmdLinePrefix() const const QString AbstractMaemoRunControl::targetCmdLinePrefix() const
{ {
return QString::fromLocal8Bit("%1 chmod a+x %2 && source /etc/profile && DISPLAY=:0.0 ") return QString::fromLocal8Bit("%1 chmod a+x %2 && source /etc/profile && DISPLAY=:0.0 ")
.arg(remoteSudo()).arg(executableFilePathOnTarget()); .arg(MaemoGlobal::remoteSudo()).arg(executableFilePathOnTarget());
} }
QString AbstractMaemoRunControl::targetCmdLineSuffix() const QString AbstractMaemoRunControl::targetCmdLineSuffix() const

View File

@@ -22,7 +22,8 @@ HEADERS += \
$$PWD/maemodeployablelistwidget.h \ $$PWD/maemodeployablelistwidget.h \
$$PWD/maemodeploystep.h \ $$PWD/maemodeploystep.h \
$$PWD/maemodeploystepwidget.h \ $$PWD/maemodeploystepwidget.h \
$$PWD/maemodeploystepfactory.h $$PWD/maemodeploystepfactory.h \
$$PWD/maemoglobal.h
SOURCES += \ SOURCES += \
$$PWD/maemoconfigtestdialog.cpp \ $$PWD/maemoconfigtestdialog.cpp \
@@ -46,7 +47,8 @@ SOURCES += \
$$PWD/maemodeployablelistwidget.cpp \ $$PWD/maemodeployablelistwidget.cpp \
$$PWD/maemodeploystep.cpp \ $$PWD/maemodeploystep.cpp \
$$PWD/maemodeploystepwidget.cpp \ $$PWD/maemodeploystepwidget.cpp \
$$PWD/maemodeploystepfactory.cpp $$PWD/maemodeploystepfactory.cpp \
$$PWD/maemoglobal.cpp
FORMS += \ FORMS += \
$$PWD/maemoconfigtestdialog.ui \ $$PWD/maemoconfigtestdialog.ui \
@@ -54,6 +56,6 @@ FORMS += \
$$PWD/maemosshconfigdialog.ui \ $$PWD/maemosshconfigdialog.ui \
$$PWD/maemopackagecreationwidget.ui \ $$PWD/maemopackagecreationwidget.ui \
$$PWD/maemodeployablelistwidget.ui \ $$PWD/maemodeployablelistwidget.ui \
qt-maemo/maemodeploystepwidget.ui $$PWD/maemodeploystepwidget.ui
RESOURCES += $$PWD/qt-maemo.qrc RESOURCES += $$PWD/qt-maemo.qrc