Commit b45af5e4 authored by Alexander Semke's avatar Alexander Semke
Browse files

Removed NullBackend.

parent e9214067
......@@ -10,7 +10,6 @@ function(add_backend name)
endfunction()
add_subdirectory(null)
add_subdirectory(maxima)
add_subdirectory(octave)
add_subdirectory(scilab)
......
set( NullBackend_SRCS
nullbackend.cpp
nullsession.cpp
nullexpression.cpp
nullcompletionobject.cpp
)
add_backend(nullbackend ${NullBackend_SRCS})
/*
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
---
Copyright (C) 2009 Alexander Rieder <alexanderrieder@gmail.com>
*/
#include "nullbackend.h"
#include "nullsession.h"
#include <QDebug>
#include "cantor_macros.h"
NullBackend::NullBackend( QObject* parent, const QList<QVariant>& args ) : Cantor::Backend( parent,args )
{
setObjectName(QLatin1String("nullbackend"));
qDebug()<<"Creating NullBackend";
setEnabled(false);
}
NullBackend::~NullBackend()
{
qDebug()<<"Destroying NullBackend";
}
QString NullBackend::id() const
{
return QLatin1String("null");
}
Cantor::Session* NullBackend::createSession()
{
qDebug()<<"Spawning a new Null session";
return new NullSession(this);
}
Cantor::Backend::Capabilities NullBackend::capabilities() const
{
qDebug()<<"Requesting capabilities of NullSession";
return Cantor::Backend::Nothing;
}
QWidget* NullBackend::settingsWidget(QWidget* parent) const
{
Q_UNUSED(parent)
return nullptr;
}
KConfigSkeleton* NullBackend::config() const
{
return nullptr;
}
QUrl NullBackend::helpUrl() const
{
return QUrl();
}
QString NullBackend::version() const
{
return QLatin1String();
}
bool NullBackend::requirementsFullfilled(QString* const reason) const
{
Q_UNUSED(reason);
return true;
}
K_PLUGIN_FACTORY_WITH_JSON(nullbackend, "nullbackend.json", registerPlugin<NullBackend>();)
#include "nullbackend.moc"
/*
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
---
Copyright (C) 2009 Alexander Rieder <alexanderrieder@gmail.com>
*/
#ifndef _NULLBACKEND_H
#define _NULLBACKEND_H
#include "backend.h"
class NullBackend : public Cantor::Backend
{
Q_OBJECT
public:
explicit NullBackend( QObject* parent = nullptr, const QList<QVariant>& args = QList<QVariant>());
~NullBackend() override;
QString id() const override;
Cantor::Session *createSession() override;
Cantor::Backend::Capabilities capabilities() const override;
QWidget* settingsWidget(QWidget* parent) const override;
KConfigSkeleton* config() const override;
bool requirementsFullfilled(QString* const reason) const override;
QUrl helpUrl() const override;
QString version() const override;
};
#endif /* _NULLBACKEND_H */
{
"KPlugin": {
"Dependencies": [],
"Description": "Backend for Cantor for testing purposes",
"Description[ca@valencia]": "Dorsal per al Cantor, per a fer proves",
"Description[ca]": "Dorsal per al Cantor, per a fer proves",
"Description[cs]": "Podpůrná vrstva pro Cantor pro účely testování",
"Description[de]": "Cantor-Modul für Testzwecke",
"Description[el]": "Σύστημα υποστήριξης για το Cantor για δοκιμές",
"Description[en_GB]": "Backend for Cantor for testing purposes",
"Description[es]": "Motor para Cantor pensado para hacer pruebas",
"Description[et]": "Cantori taustaprogramm testimiseks",
"Description[fi]": "Cantorin testaukseen tarkoitettu taustajärjestelmä",
"Description[fr]": "Moteur pour Cantor permettant d'effectuer des tests",
"Description[gl]": "Infraestrutura de Cantor para probas",
"Description[it]": "Backend di test per Cantor",
"Description[nl]": "Backend voor Cantor voor testdoeleinden",
"Description[nn]": "Motor for testing av Cantor",
"Description[pl]": "Silnik dla Cantor do celów testowych ",
"Description[pt]": "Infra-estrutura para testes do Cantor",
"Description[pt_BR]": "Infraestrutura para fins de testes do Cantor",
"Description[ru]": "Модуль компьютерной алгебры для Cantor, предназначенный для тестирования",
"Description[sk]": "Backend pre Cantor na testovacie účely",
"Description[sl]": "Zaledje namenjeno preizkušanju",
"Description[sv]": "Bakgrundsprogram för Cantor i testsyfte",
"Description[tr]": "Test amaçlı kullanılmak üzere Cantor arka ucu",
"Description[uk]": "Тестовий модуль Cantor",
"Description[x-test]": "xxBackend for Cantor for testing purposesxx",
"Description[zh_CN]": "Cantor 测试后端",
"Description[zh_TW]": "Cantor 測試用的後端介面",
"Id": "nullbackend",
"License": "GPL",
"Name": "nullbackend",
"Name[ca@valencia]": "DorsalNul",
"Name[ca]": "DorsalNul",
"Name[cs]": "žádná podpůrná vrstva",
"Name[de]": "Null-Modul",
"Name[el]": "nullbackend",
"Name[en_GB]": "nullbackend",
"Name[es]": "nullbackend",
"Name[et]": "nullbackend",
"Name[fi]": "null-taustajärjestelmä",
"Name[fr]": "Moteur vide",
"Name[gl]": "nullbackend",
"Name[it]": "Backend vuoto",
"Name[nl]": "nullbackend",
"Name[nn]": "Nullmotor",
"Name[pl]": "zerowy silnik",
"Name[pt]": "infra-estrutura nula",
"Name[pt_BR]": "infraestrutura vazia",
"Name[ru]": "Тестовый модуль компьютерной алгебры",
"Name[sk]": "nullbackend",
"Name[sl]": "nullbackend",
"Name[sv]": "Nollbakgrundsprogram",
"Name[tr]": "belirsiz arka uç",
"Name[uk]": "nullbackend",
"Name[x-test]": "xxnullbackendxx",
"Name[zh_CN]": "空后端",
"Name[zh_TW]": "nullbackend",
"ServiceTypes": [
"Cantor/Backend"
]
}
}
/*
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
---
Copyright (C) 2009 Alexander Rieder <alexanderrieder@gmail.com>
*/
#include "nullcompletionobject.h"
#include <QStringList>
#include <QDebug>
#include "nullsession.h"
NullCompletionObject::NullCompletionObject(const QString& command, int index, NullSession* session) : Cantor::CompletionObject(session)
{
setLine(command, index);
}
void NullCompletionObject::fetchCompletions()
{
qDebug()<<"fetching...";
QStringList comp;
for (int i=0;i<5;i++)
comp<<QString::fromLatin1("%1 %2").arg(command()).arg(i);
setCompletions(comp);
emit fetchingDone();
}
/*
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
---
Copyright (C) 2009 Alexander Rieder <alexanderrieder@gmail.com>
*/
#ifndef _NULLCOMPLETIONOBJECT_H
#define _NULLCOMPLETIONOBJECT_H
#include "completionobject.h"
class NullSession;
class NullCompletionObject : public Cantor::CompletionObject
{
public:
NullCompletionObject( const QString& command, int index, NullSession* session);
~NullCompletionObject() override = default;
protected Q_SLOTS:
void fetchCompletions() override;
};
#endif /* _NULLCOMPLETIONOBJECT_H */
/*
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
---
Copyright (C) 2009 Alexander Rieder <alexanderrieder@gmail.com>
*/
#include "nullexpression.h"
#include "textresult.h"
#include "imageresult.h"
#include "helpresult.h"
#include <QDebug>
#include <KIconLoader>
#include <QTimer>
NullExpression::NullExpression( Cantor::Session* session, bool internal ) : Cantor::Expression(session, internal)
{
m_timer=new QTimer(this);
m_timer->setSingleShot(true);
connect(m_timer, &QTimer::timeout, this, &NullExpression::evalFinished);
}
void NullExpression::evaluate()
{
qDebug()<<"evaluating "<<command();
setStatus(Cantor::Expression::Computing);
m_timer->start(1000);
}
void NullExpression::interrupt()
{
qDebug()<<"interruptinging command";
m_timer->stop();
setStatus(Cantor::Expression::Interrupted);
}
void NullExpression::evalFinished()
{
qDebug()<<"evaluation finished";
if ( command()==QLatin1String("img") )
setResult( new Cantor::ImageResult( QUrl::fromLocalFile(KIconLoader::global()->iconPath(QLatin1String("kde"), KIconLoader::Desktop)), QLatin1String("alternative") ) );
else
setResult(new Cantor::TextResult(QLatin1String("result: ")+command()));
setStatus(Cantor::Expression::Done);
}
/*
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
---
Copyright (C) 2009 Alexander Rieder <alexanderrieder@gmail.com>
*/
#ifndef _NULLEXPRESSION_H
#define _NULLEXPRESSION_H
#include "expression.h"
class QTimer;
class NullExpression : public Cantor::Expression
{
Q_OBJECT
public:
explicit NullExpression( Cantor::Session* session, bool internal = false);
~NullExpression() override = default;
void evaluate() override;
void interrupt() override;
public Q_SLOTS:
void evalFinished();
private:
QTimer* m_timer;
};
#endif /* _NULLEXPRESSION_H */
/*
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
---
Copyright (C) 2009 Alexander Rieder <alexanderrieder@gmail.com>
*/
#include "nullsession.h"
#include "nullexpression.h"
#include "nullcompletionobject.h"
#include <QDebug>
NullSession::NullSession( Cantor::Backend* backend) : Session(backend)
{
}
void NullSession::login()
{
qDebug()<<"login";
emit loginStarted();
changeStatus(Session::Done);
emit loginDone();
}
void NullSession::logout()
{
qDebug()<<"logout";
changeStatus(Status::Disable);
}
void NullSession::interrupt()
{
qDebug()<<"interrupt";
foreach(Cantor::Expression* e, m_runningExpressions)
e->interrupt();
m_runningExpressions.clear();
changeStatus(Cantor::Session::Done);
}
Cantor::Expression* NullSession::evaluateExpression(const QString& cmd, Cantor::Expression::FinishingBehavior behave, bool internal)
{
qDebug()<<"evaluating: "<<cmd;
NullExpression* expr=new NullExpression(this, internal);
expr->setFinishingBehavior(behave);
connect(expr, &NullExpression::statusChanged, this, &NullSession::expressionFinished);
expr->setCommand(cmd);
expr->evaluate();
if(m_runningExpressions.isEmpty())
changeStatus(Cantor::Session::Running);
m_runningExpressions.append(expr);
return expr;
}
Cantor::CompletionObject* NullSession::completionFor(const QString& command, int index)
{
qDebug()<<"tab completion for "<<command;
return new NullCompletionObject(command, index, this);
}
void NullSession::expressionFinished()
{
qDebug()<<"finished";
NullExpression* expression=qobject_cast<NullExpression*>(sender());
m_runningExpressions.removeAll(expression);
qDebug()<<"size: "<<m_runningExpressions.size();
if(m_runningExpressions.isEmpty())
changeStatus(Cantor::Session::Done);
}
/*
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
---
Copyright (C) 2009 Alexander Rieder <alexanderrieder@gmail.com>
*/
#ifndef _NULLSESSION_H
#define _NULLSESSION_H
#include "session.h"
class NullExpression;
class NullSession : public Cantor::Session
{
Q_OBJECT
public:
explicit NullSession( Cantor::Backend* backend);
~NullSession() override = default;
void login() override;
void logout() override;
void interrupt() override;
Cantor::Expression* evaluateExpression(const QString& command, Cantor::Expression::FinishingBehavior behave = Cantor::Expression::FinishingBehavior::DoNotDelete, bool internal = false) override;
Cantor::CompletionObject* completionFor(const QString& cmd, int index=-1) override;
private Q_SLOTS:
void expressionFinished();
private:
QList<NullExpression*> m_runningExpressions;
};
#endif /* _NULLSESSION_H */
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment