WIP: OC installation wizard integration

This commit is contained in:
Klaas Freitag 2011-09-28 18:14:48 +02:00
parent 292965c6a3
commit 68b966256e
9 changed files with 228 additions and 9 deletions

View file

@ -33,6 +33,7 @@ mirall/sitecopyfolder.cpp
mirall/sitecopyconfig.cpp
mirall/statusdialog.cpp
mirall/owncloudwizard.cpp
mirall/owncloudsetup.cpp
)
if(CSYNC_FOUND)
set(mirall_SRCS

View file

@ -163,7 +163,7 @@ p, li { white-space: pre-wrap; }
</widget>
</item>
<item row="4" column="2">
<widget class="QLineEdit" name="localFolder2LineEdit">
<widget class="QLineEdit" name="myDomainEdit">
<property name="text">
<string/>
</property>

View file

@ -31,7 +31,7 @@ FolderWizardSourcePage::FolderWizardSourcePage()
{
_ui.setupUi(this);
registerField("sourceFolder*", _ui.localFolderLineEdit);
_ui.localFolderLineEdit->setText( QString( "%1/%2").arg( QDir::homePath() ).arg("/Owncloud" ) );
_ui.localFolderLineEdit->setText( QString( "%1/%2").arg( QDir::homePath() ).arg("Owncloud" ) );
registerField("alias*", _ui.aliasLineEdit);
_ui.aliasLineEdit->setText( QString::fromLatin1("Owncloud") );
}

View file

@ -115,10 +115,13 @@ p, li { white-space: pre-wrap; }
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="ftpUserEdit_2">
<widget class="QLineEdit" name="ftpPasswdEdit">
<property name="text">
<string/>
</property>
<property name="echoMode">
<enum>QLineEdit::Password</enum>
</property>
<property name="placeholderText">
<string>john</string>
</property>

View file

@ -0,0 +1,99 @@
#include <QtCore>
#include <QProcess>
#include "owncloudsetup.h"
namespace Mirall {
OwncloudSetup::OwncloudSetup( QObject *parent ) :
QObject( parent )
{
_process = new QProcess( this );
QObject::connect(_process, SIGNAL(readyReadStandardOutput()),
SLOT(slotReadyReadStandardOutput()));
QObject::connect(_process, SIGNAL(readyReadStandardError()),
SLOT(slotReadyReadStandardError()));
QObject::connect(_process, SIGNAL(stateChanged(QProcess::ProcessState)),
SLOT(slotStateChanged(QProcess::ProcessState)));
QObject::connect(_process, SIGNAL(error(QProcess::ProcessError)),
SLOT(slotError(QProcess::ProcessError)));
QObject::connect(_process, SIGNAL(started()),
SLOT(slotStarted()));
QObject::connect(_process, SIGNAL(finished(int, QProcess::ExitStatus)),
SLOT(slotFinished(int, QProcess::ExitStatus)));
_ocWizard = new OwncloudWizard();
connect( _ocWizard, SIGNAL( connectToOCUrl( const QString& ) ),
this, SLOT( slotConnectToOCUrl( const QString& )));
connect( _ocWizard, SIGNAL( installOCServer()),
this, SLOT( slotInstallOCServer()));
}
void OwncloudSetup::slotConnectToOCUrl( const QString& url )
{
qDebug() << "Connect to url: " << url;
}
void OwncloudSetup::slotInstallServer()
{
const QString server = _ocWizard->field("ftpUrl").toString();
const QString user = _ocWizard->field("ftpUser").toString();
const QString passwd = _ocWizard->field("ftpPasswd").toString();
qDebug() << "Connect to " << server << " as user " << user;
const QString bin( "/home/kf/github/owncloud-admin/bin/owncloud-admin" );
QStringList args;
args << "install";
args << "--server-type" << "ftp";
args << "--server" << server;
args << "--user" << user;
args << "--password" << passwd;
_process->start( bin, args );
}
void OwncloudSetup::readyReadStandardOutput()
{
}
void OwncloudSetup::readReadStandardError()
{
}
void OwncloudSetup::slotStateChanged( QProcess::ProcessState )
{
}
void OwncloudSetup::slotError( QProcess::ProcessError )
{
}
void OwncloudSetup::slotStarted()
{
}
void OwncloudSetup::slotFinished( int, QProcess::ExitStatus )
{
}
void OwncloudSetup::startWizard( )
{
_ocWizard->exec();
}
}

View file

@ -0,0 +1,47 @@
#ifndef OWNCLOUDSETUP_H
#define OWNCLOUDSETUP_H
#include <QObject>
#include <QWidget>
#include <QProcess>
#include "mirall/owncloudwizard.h"
namespace Mirall {
class OwncloudSetup : public QObject
{
Q_OBJECT
public:
explicit OwncloudSetup( QObject *parent = 0 );
void startWizard( );
void installServer();
signals:
public slots:
protected slots:
// QProcess related slots:
void readyReadStandardOutput();
void readReadStandardError();
void slotStateChanged( QProcess::ProcessState );
void slotError( QProcess::ProcessError );
void slotStarted();
void slotFinished( int, QProcess::ExitStatus );
void connectToOCUrl( const QString& );
// wizard dialog signals
void slotInstallServer();
void slotConnectToOCUrl( const QString& );
private:
OwncloudWizard *_ocWizard;
QProcess *_process;
};
};
#endif // OWNCLOUDSETUP_H

View file

@ -30,7 +30,9 @@ namespace Mirall
OwncloudWizardSelectTypePage::OwncloudWizardSelectTypePage()
{
_ui.setupUi(this);
// registerField("OCUrl*", _ui.lineEditOCUrl);
registerField( "connectMyOC", _ui.connectMyOCRadioBtn );
registerField( "createNewOC", _ui.createNewOCRadioBtn );
registerField( "OCUrl", _ui.OCUrlLineEdit );
}
OwncloudWizardSelectTypePage::~OwncloudWizardSelectTypePage()
@ -43,6 +45,14 @@ void OwncloudWizardSelectTypePage::initializePage()
}
int OwncloudWizardSelectTypePage::nextId() const
{
if( _ui.connectMyOCRadioBtn->isChecked() ) {
return OwncloudWizard::Page_Install;
}
return OwncloudWizard::Page_Create_OC;
}
bool OwncloudWizardSelectTypePage::isComplete() const
{
@ -54,7 +64,9 @@ bool OwncloudWizardSelectTypePage::isComplete() const
OwncloudFTPAccessPage::OwncloudFTPAccessPage()
{
_ui.setupUi(this);
// registerField("OCUrl*", _ui.lineEditOCUrl);
registerField( "ftpUrl", _ui.ftpUrlEdit );
registerField( "ftpUser", _ui.ftpUserEdit );
registerField( "ftpPasswd", _ui.ftpPasswdEdit );
}
OwncloudFTPAccessPage::~OwncloudFTPAccessPage()
@ -66,6 +78,13 @@ void OwncloudFTPAccessPage::initializePage()
// _ui.lineEditOCAlias->setText( "Owncloud" );
}
#if 0
int OwncloudFTPAccessPage::nextId() const
{
}
#endif
bool OwncloudFTPAccessPage::isComplete() const
{
@ -76,7 +95,9 @@ bool OwncloudFTPAccessPage::isComplete() const
CreateAnOwncloudPage::CreateAnOwncloudPage()
{
_ui.setupUi(this);
// registerField("OCSiteAlias*", _ui.lineEditOCAlias);
registerField("createLocalOC", _ui.createLocalRadioBtn );
registerField("createOnDomain", _ui.createPerFTPRadioBtn );
registerField("myOCDomain", _ui.myDomainEdit );
}
CreateAnOwncloudPage::~CreateAnOwncloudPage()
@ -88,6 +109,14 @@ void CreateAnOwncloudPage::initializePage()
// _ui.lineEditOCAlias->setText( "Owncloud" );
}
int CreateAnOwncloudPage::nextId() const
{
if( _ui.createLocalRadioBtn->isChecked() ) {
return OwncloudWizard::Page_Install;
}
return OwncloudWizard::Page_FTP;
}
bool CreateAnOwncloudPage::isComplete() const
{
@ -98,7 +127,7 @@ bool CreateAnOwncloudPage::isComplete() const
OwncloudWizardResultPage::OwncloudWizardResultPage()
{
_ui.setupUi(this);
// registerField("OCSiteAlias*", _ui.lineEditOCAlias);
// no fields to register.
}
OwncloudWizardResultPage::~OwncloudWizardResultPage()
@ -115,6 +144,11 @@ bool OwncloudWizardResultPage::isComplete() const
}
void OwncloudWizardResultPage::appendResultText( const QString& msg )
{
_ui.resultTextEdit->append( msg );
}
// ======================================================================
/**
@ -128,8 +162,30 @@ OwncloudWizard::OwncloudWizard(QWidget *parent)
setPage(Page_Create_OC, new CreateAnOwncloudPage() );
setPage(Page_FTP, new OwncloudFTPAccessPage() );
setPage(Page_Install, new OwncloudWizardResultPage() );
connect( this, SIGNAL(currentIdChanged(int)), SLOT(slotCurrentPageChanged(int)));
}
void OwncloudWizard::slotCurrentPageChanged( int id )
{
if( id == Page_Install ) {
if( field("connectMyOC").toBool() ) {
// check the url and connect.
QString url = field("OCUrl").toString();
emit connectToOCUrl( url );
} else if( field("createNewOC").toBool() ) {
// call in installation mode and install to ftp site.
emit installOCServer();
}
}
}
void OwncloudWizard::appendToResultWidget( const QString& msg )
{
OwncloudWizardResultPage *p = static_cast<OwncloudWizardResultPage*> (page( Page_Install ));
p->appendResultText( msg );
}
} // end namespace
#include "owncloudwizard.moc"

View file

@ -37,6 +37,7 @@ public:
virtual bool isComplete() const;
virtual void initializePage();
int nextId() const;
private:
Ui_OwncloudWizardSelectTypePage _ui;
@ -52,7 +53,7 @@ public:
virtual bool isComplete() const;
virtual void initializePage();
virtual int nextId() const;
private:
Ui_CreateAnOwncloudPage _ui;
@ -89,6 +90,9 @@ public:
virtual bool isComplete() const;
virtual void initializePage();
public slots:
void appendResultText( const QString& );
private:
Ui_OwncloudWizardResultPage _ui;
@ -112,6 +116,15 @@ public:
};
OwncloudWizard(QWidget *parent = 0L);
public slots:
void appendToResultWidget( const QString& );
void slotCurrentPageChanged( int );
signals:
void connectToOCUrl( const QString& );
void installOCServer();
};

View file

@ -107,7 +107,7 @@ p, li { white-space: pre-wrap; }
</widget>
</item>
<item row="2" column="2">
<widget class="QLineEdit" name="localFolder2LineEdit">
<widget class="QLineEdit" name="OCUrlLineEdit">
<property name="placeholderText">
<string>http://owncloud.mydomain.org</string>
</property>