Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Completed conversion to libkovanserial

  • Loading branch information...
commit 502f087ce96b56acfbe1f46209510e5128824f43 1 parent 80f60aa
@bmcdorman bmcdorman authored
Showing with 1,680 additions and 1,222 deletions.
  1. +2 −0  CMakeLists.txt
  2. +1 −1  include/build_options.hpp
  3. +0 −20 include/c_highlighter.hpp
  4. +0 −76 include/code_editor.hpp
  5. +38 −0 include/dialogs/manual_target_dialog.hpp
  6. +2 −0  include/dialogs/target_dialog.hpp
  7. +23 −0 include/external_tools.hpp
  8. +9 −4 include/interface/communication_manager.hpp
  9. +6 −2 include/interface/communication_queue.hpp
  10. +36 −0 include/interface/communication_queue_model.hpp
  11. +1 −0  include/interface/dummy_interface.hpp
  12. +3 −1 include/interface/interface.hpp
  13. +3 −3 include/interface/interface_model.hpp
  14. +29 −0 include/interface/main_responder.hpp
  15. +0 −46 include/interface/qt_target_responder.hpp
  16. +29 −26 include/interface/target.hpp
  17. +6 −20 include/interface/target_responder.hpp
  18. +32 −0 include/interface/target_response.hpp
  19. +18 −3 include/main_window.hpp
  20. +2 −2 include/project/project.hpp
  21. +8 −19 include/source_file.hpp
  22. +0 −48 include/syntax_highlighter.hpp
  23. +0 −1  include/tab.hpp
  24. +2 −5 include/unit.hpp
  25. +39 −0 include/widgets/communication_progress_bar.hpp
  26. +27 −0 include/widgets/communication_widget.hpp
  27. +2 −2 plugins/interfaces/CMakeLists.txt
  28. +2 −5 plugins/interfaces/computer/computer_interface.hpp
  29. +1 −1  plugins/interfaces/kovan/CMakeLists.txt
  30. +52 −13 plugins/interfaces/kovan/kovan_interface.cpp
  31. +50 −18 plugins/interfaces/kovan/kovan_interface.hpp
  32. +4 −2 plugins/interfaces/{serial → kovan_serial}/CMakeLists.txt
  33. +83 −0 plugins/interfaces/kovan_serial/kovan_serial_interface.cpp
  34. +52 −0 plugins/interfaces/kovan_serial/kovan_serial_interface.hpp
  35. +161 −79 plugins/interfaces/shared/kovan_proto_target.cpp
  36. +41 −27 plugins/interfaces/shared/kovan_proto_target.hpp
  37. +0 −69 src/c_highlighter.cpp
  38. +0 −217 src/code_editor.cpp
  39. +30 −0 src/dialogs/manual_target_dialog.cpp
  40. +14 −0 src/dialogs/target_dialog.cpp
  41. +23 −0 src/external_tools.cpp
  42. +29 −7 src/interface/communication_manager.cpp
  43. +28 −9 src/interface/communication_queue.cpp
  44. +143 −0 src/interface/communication_queue_model.cpp
  45. +13 −8 src/interface/dummy_interface.cpp
  46. +3 −2 src/interface/interface_model.cpp
  47. +34 −0 src/interface/main_responder.cpp
  48. +0 −68 src/interface/qt_target_responder.cpp
  49. +10 −18 src/interface/target.cpp
  50. +6 −3 src/interface/target_model.cpp
  51. +5 −0 src/interface/target_responder.cpp
  52. +30 −0 src/interface/target_response.cpp
  53. +33 −14 src/main_window.cpp
  54. +2 −8 src/project/project.cpp
  55. +19 −132 src/source_file.cpp
  56. +0 −86 src/syntax_highlighter.cpp
  57. +18 −16 src/unit.cpp
  58. +49 −0 src/widgets/communication_progress_bar.cpp
  59. +24 −0 src/widgets/communication_widget.cpp
  60. +0 −3  tests/CMakeLists.txt
  61. +152 −123 ui/MainWindow.ui
  62. +12 −11 ui/TargetDialog.ui
  63. +100 −0 ui/communication_widget.ui
  64. +136 −0 ui/manual_target_dialog.ui
  65. +3 −4 ui/template_dialog.ui
View
2  CMakeLists.txt
@@ -68,6 +68,8 @@ QT4_ADD_RESOURCES(KISS_SRCS_CXX ${KISS_QRC_FILES})
SET(CMAKE_CXX_FLAGS "-Wall")
+ADD_DEFINITIONS(-DQT_SHAREDPOINTER_TRACK_POINTERS)
+
IF(APPLE)
SET(CMAKE_OSX_SYSROOT "${OSX_DEVELOPER_ROOT}/SDKs/MacOSX10.6.sdk")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -arch x86_64 -g")
View
2  include/build_options.hpp
@@ -11,7 +11,7 @@
// This option will enable GUI logging. Disables console output as a side-effect
-#define ENABLE_LOG_WINDOW
+// #define ENABLE_LOG_WINDOW
#ifndef QT_PHONON_LIB
#undef BUILD_AUDIO_TUTORIAL
View
20 include/c_highlighter.hpp
@@ -1,20 +0,0 @@
-#ifndef _C_HIGHLIGHTER_HPP_
-#define _C_HIGHLIGHTER_HPP_
-
-#include "syntax_highlighter.hpp"
-
-#include <QHash>
-
-class QTextDocument;
-
-namespace Kiss
-{
- class CHighlighter : public SyntaxHighlighter
- {
- Q_OBJECT
- public:
- CHighlighter(QTextDocument *parent = 0);
- };
-}
-
-#endif
View
76 include/code_editor.hpp
@@ -1,76 +0,0 @@
-#ifndef _CODE_EDITOR_HPP_
-#define _CODE_EDITOR_HPP_
-
-#include <QMap>
-#include <QWidget>
-#include <QPlainTextEdit>
-
-namespace Kiss
-{
- namespace Widget
- {
- class CodeEditor;
-
- class CodeEditorMargin : public QWidget
- {
- public:
- CodeEditorMargin(CodeEditor *editor);
- QSize sizeHint() const;
-
- protected:
- void paintEvent(QPaintEvent *event);
-
- private:
- CodeEditor *m_editor;
- };
-
- class MarginIndicator
- {
- public:
- MarginIndicator(const QColor& color);
- const QColor& color() const;
-
- static const MarginIndicator& none();
- private:
- QColor m_color;
-
- static MarginIndicator s_none;
- };
-
- class CodeEditor : public QPlainTextEdit
- {
- Q_OBJECT
- public:
- CodeEditor(QWidget *parent = 0);
-
- void setEditorFont(const QFont& font);
- QFont editorFont() const;
- QFont marginFont() const;
-
- void setMarginIndicator(const int& line, const MarginIndicator& indicator);
- void clearIndicators();
-
- quint16 marginSize() const;
-
- friend class CodeEditorMargin;
- protected:
- void marginPaintEvent(QPaintEvent *event);
- void resizeEvent(QResizeEvent *e);
- void scrollContentsBy(int dx, int dy);
-
- void keyPressEvent(QKeyEvent *e);
-
- private slots:
- void highlightCurrentLine();
- void updateMarginArea(const QRect& rect, const int& dy);
- void updateMarginSize();
-
- private:
- QFont m_marginFont;
- CodeEditorMargin *m_margin;
- QMap<int, MarginIndicator> m_indicators;
- };
- }
-}
-
-#endif
View
38 include/dialogs/manual_target_dialog.hpp
@@ -0,0 +1,38 @@
+#ifndef _MANUAL_TARGET_SELECTOR_HPP_
+#define _MANUAL_TARGET_SELECTOR_HPP_
+
+#include <QDialog>
+
+#include "target.hpp"
+
+namespace Ui
+{
+ class ManualTargetDialog;
+}
+
+namespace Kiss
+{
+ namespace Target
+ {
+ class InterfaceModel;
+ }
+
+ namespace Dialog
+ {
+ class ManualTarget : public QDialog
+ {
+ Q_OBJECT
+ public:
+ ManualTarget(QWidget *parent = 0);
+ ~ManualTarget();
+
+ Kiss::Target::TargetPtr target() const;
+
+ private:
+ Ui::ManualTargetDialog *ui;
+ Kiss::Target::InterfaceModel *m_model;
+ };
+ }
+}
+
+#endif
View
2  include/dialogs/target_dialog.hpp
@@ -47,11 +47,13 @@ namespace Kiss
void targetChosen(const QModelIndex& index);
void on_ui_interfaces_currentIndexChanged(int index);
void on_ui_refresh_clicked();
+ void on_ui_manual_clicked();
private:
Kiss::Target::InterfaceManager *m_manager;
Kiss::Target::TargetModel m_model;
Kiss::Target::InterfaceModel m_interfaceModel;
+ Kiss::Target::TargetPtr m_manualTarget;
};
}
}
View
23 include/external_tools.hpp
@@ -0,0 +1,23 @@
+#ifndef _EXTERNAL_TOOLS_HPP_
+#define _EXTERNAL_TOOLS_HPP_
+
+#include <QString>
+#include <QSettings>
+
+namespace Kiss
+{
+ class ExternalTools
+ {
+ public:
+ void setTool(const QString &name, const QString &path);
+ QString tool(const QString &name);
+ void removeTool(const QString &name);
+
+ bool launch(const QString &name);
+
+ private:
+ QSettings m_settings;
+ };
+}
+
+#endif
View
13 include/interface/communication_manager.hpp
@@ -3,6 +3,7 @@
#include <QObject>
#include <QRunnable>
+#include <QMutex>
#include "singleton.hpp"
#include "communication_queue.hpp"
@@ -13,13 +14,14 @@ namespace Kiss
{
class CommunicationWorker : public QObject, public QRunnable
{
+ Q_OBJECT
public:
CommunicationWorker(const CommunicationEntryPtr &entry);
virtual void run();
signals:
void progress(const CommunicationEntryPtr &entry);
- void finished(const CommunicationEntryPtr &entry);
+ void finished(const CommunicationEntryPtr &entry, const bool &success);
private:
CommunicationEntryPtr m_entry;
@@ -27,6 +29,7 @@ namespace Kiss
class CommunicationManager : public QObject, public Singleton<CommunicationManager>
{
+ Q_OBJECT
public:
CommunicationManager();
~CommunicationManager();
@@ -36,17 +39,19 @@ namespace Kiss
signals:
void admitted(const CommunicationEntryPtr &entry);
void began(const CommunicationEntryPtr &entry);
- void progress(const CommunicationEntryPtr &entry, const double &fraction);
- void finished(const CommunicationEntryPtr &entry);
+ void progress(const CommunicationEntryPtr &entry, double fraction);
+ void finished(const CommunicationEntryPtr &entry, bool success);
+ void queueFinished();
private slots:
void saturate();
- void workerFinished(const CommunicationEntryPtr &entry);
+ void workerFinished(CommunicationEntryPtr entry, const bool &success);
private:
quint64 m_id;
QList<CommunicationEntryPtr> m_running;
CommunicationQueue m_queue;
+ QMutex m_queueMutex;
};
}
}
View
8 include/interface/communication_queue.hpp
@@ -1,5 +1,5 @@
-#ifndef _COMMUNICATIONQUEUE_H_
-#define _COMMUNICATIONQUEUE_H_
+#ifndef _COMMUNICATION_QUEUE_HPP_
+#define _COMMUNICATION_QUEUE_HPP_
#include "target.hpp"
@@ -9,6 +9,7 @@
#include <QString>
#include <QByteArray>
#include <QSharedPointer>
+#include <QMetaType>
namespace Kiss
{
@@ -36,6 +37,7 @@ namespace Kiss
const TargetPtr &target() const;
const CommunicationEntry::Type& type() const;
+ QString typeString() const;
const QString& custom() const;
const QByteArray& payload() const;
const QString& name() const;
@@ -64,4 +66,6 @@ namespace Kiss
}
}
+Q_DECLARE_METATYPE(Kiss::Target::CommunicationEntryPtr);
+
#endif
View
36 include/interface/communication_queue_model.hpp
@@ -0,0 +1,36 @@
+#ifndef _COMMUNICATION_QUEUE_MODEL_HPP_
+#define _COMMUNICATION_QUEUE_MODEL_HPP_
+
+#include "communication_queue.hpp"
+
+#include <QStandardItemModel>
+
+namespace Kiss
+{
+ namespace Target
+ {
+ class CommunicationManager;
+
+ class CommunicationQueueModel : public QStandardItemModel
+ {
+ Q_OBJECT
+ public:
+ CommunicationQueueModel(CommunicationManager *manager, QObject *parent);
+ ~CommunicationQueueModel();
+
+ CommunicationManager *manager() const;
+
+ private slots:
+ void admitted(const CommunicationEntryPtr &entry);
+ void began(const CommunicationEntryPtr &entry);
+ void progress(const CommunicationEntryPtr &entry, double success);
+ void finished(const CommunicationEntryPtr &entry, bool success);
+ void queueFinished();
+
+ private:
+ CommunicationManager *m_manager;
+ };
+ }
+}
+
+#endif
View
1  include/interface/dummy_interface.hpp
@@ -16,6 +16,7 @@ namespace Kiss
public:
DummyInterface();
+ virtual Kiss::Target::TargetPtr createTarget(const QString &address);
virtual const bool scan(Kiss::Target::InterfaceResponder *responder);
virtual void invalidateResponder();
};
View
4 include/interface/interface.hpp
@@ -2,6 +2,7 @@
#define _INTERFACE_HPP_
#include "interface_responder.hpp"
+#include "target.hpp"
#include <QList>
#include <QString>
@@ -16,7 +17,8 @@ namespace Kiss
Interface(const QString& name);
const QString& name() const;
-
+
+ virtual Kiss::Target::TargetPtr createTarget(const QString &address) = 0;
virtual const bool scan(InterfaceResponder *responder) = 0;
virtual void invalidateResponder() = 0;
private:
View
6 include/interface/interface_model.hpp
@@ -14,10 +14,10 @@ namespace Kiss
{
Q_OBJECT
public:
- InterfaceModel(InterfaceManager *manager);
+ InterfaceModel(InterfaceManager *manager, QObject *parent = 0);
- Interface* rowToInterface(const int& row) const;
- Interface* indexToInterface(const QModelIndex& index) const;
+ Interface *rowToInterface(const int& row) const;
+ Interface *indexToInterface(const QModelIndex& index) const;
void setAllInterface(const bool& on);
View
29 include/interface/main_responder.hpp
@@ -0,0 +1,29 @@
+#ifndef _MAIN_RESPONDER_HPP_
+#define _MAIN_RESPONDER_HPP_
+
+#include "target_responder.hpp"
+
+namespace Kiss
+{
+ namespace Widget
+ {
+ class MainWindow;
+ }
+
+ namespace Target
+ {
+ class MainResponder : public Responder
+ {
+ public:
+ MainResponder(Widget::MainWindow *mainWindow);
+ virtual ~MainResponder();
+
+ virtual void response(Target *target, const Response &response);
+
+ private:
+ Widget::MainWindow *m_mainWindow;
+ };
+ }
+}
+
+#endif
View
46 include/interface/qt_target_responder.hpp
@@ -1,46 +0,0 @@
-#ifndef _QT_TARGET_RESPONDER_HPP_
-#define _QT_TARGET_RESPONDER_HPP_
-
-#include "target_responder.hpp"
-
-namespace Kiss
-{
- namespace Target
- {
- class QtResponder : public QObject, public Responder
- {
- Q_OBJECT
- public:
- virtual void availableResponse(Target *target, const bool& available);
- virtual void compileResponse(Target *target, const Compiler::OutputList& results);
- virtual void downloadResponse(Target *target, const bool& success);
- virtual void runResponse(Target *target, const bool& success);
- virtual void listResponse(Target *target, const QStringList& programs);
- virtual void deleteResponse(Target *target, const bool& success);
- virtual void interactionResponse(Target *target, const QString& ret);
- virtual void unknownResponse(Target *target, const QByteArray& payload);
- virtual void customResponse(Target *target, const QString& type, const QByteArray& payload);
- virtual void communicationError(Target *target);
- virtual void connectionError(Target *target);
- virtual void notAuthenticatedError(Target *target);
- virtual void authenticationResponse(Target *target, const Responder::AuthenticateReturn& response);
-
- signals:
- void availableFinished(bool available);
- void compileFinished(const Compiler::OutputList& results);
- void downloadFinished(bool success);
- void runFinished(bool success);
- void listFinished(const QStringList& programs);
- void deleteFinished(bool success);
- void interactionFinished(const QString& ret);
- void customFinished(const QString& type, const QByteArray& payload);
- void unknownFinished(const QByteArray& payload);
- void communicationError();
- void connectionError();
- void notAuthenticatedError();
- void authenticationResponse(const Responder::AuthenticateReturn& response);
- };
- }
-}
-
-#endif
View
55 include/interface/target.hpp
@@ -1,9 +1,10 @@
-#ifndef _TARGET_H_
-#define _TARGET_H_
+#ifndef _TARGET_HPP_
+#define _TARGET_HPP_
-#include "communication_queue.hpp"
#include "target_responder.hpp"
+#include <kar.hpp>
+
#include <QObject>
#include <QString>
#include <QMap>
@@ -32,8 +33,9 @@ namespace Kiss
{
class Interface;
- class Target
+ class Target : public QObject
{
+ Q_OBJECT
public:
Target(Interface* interface, const QString& name);
virtual ~Target();
@@ -51,35 +53,36 @@ namespace Kiss
virtual const bool disconnect() = 0;
virtual const bool available() = 0;
- virtual const bool compile(const QString& name) = 0;
- virtual const bool download(const QString& name, const KarPtr& archive) = 0;
- virtual const bool run(const QString& name) = 0;
-
- virtual const bool list() = 0;
- virtual const bool deleteProgram(const QString& name) = 0;
- virtual const bool interaction(const QString& command) = 0;
-
- virtual const bool authenticate(const QByteArray& hash) = 0;
- virtual const bool sendCustom(const QString& custom, const QByteArray& payload = QByteArray()) = 0;
-
- void addResponder(Responder *responder);
- void addResponders(const ResponderPtrList& responders);
- void removeResponder(Responder *responder);
- void clearResponders();
- const ResponderPtrList& responders() const;
+ virtual const bool compile(quint64 id, const QString &name) = 0;
+ virtual const bool download(quint64 id, const QString &name, const KarPtr& archive) = 0;
+ virtual const bool run(quint64 id, const QString &name) = 0;
+
+ virtual const bool list(quint64 id) = 0;
+ virtual const bool deleteProgram(quint64 id, const QString& name) = 0;
+ virtual const bool interaction(quint64 id, const QString& command) = 0;
+
+ virtual const bool authenticate(quint64 id, const QByteArray& hash) = 0;
+ virtual const bool sendCustom(quint64 id, const QString& custom, const QByteArray& payload = QByteArray()) = 0;
+
+ void setResponder(Responder *responder);
+ Responder *responder() const;
+
+
+ // This is pretty jank. Basically we use sigslots to get us back
+ // on the GUI thread once an asynchronous event happens.
+ signals:
+ void response(const Response &response);
+
+ private slots:
+ void responseRedirect(const Response& response);
protected:
void notifyQueue(const bool success);
private:
- const bool executeEntry(const CommunicationEntry *entry);
- void clearEntries();
-
- CommunicationQueue m_workingQueue;
- CommunicationQueue m_queue;
Interface *m_interface;
- ResponderPtrList m_responders;
+ Responder *m_responder;
};
typedef QSharedPointer<Target> TargetPtr;
View
26 include/interface/target_responder.hpp
@@ -1,9 +1,7 @@
-#ifndef _TARGETRESPONDER_H_
-#define _TARGETRESPONDER_H_
+#ifndef _TARGET_RESPONDER_HPP_
+#define _TARGET_RESPONDER_HPP_
-#include <pcompiler/output.hpp>
-#include <QByteArray>
-#include <QList>
+#include "target_response.hpp"
namespace Kiss
{
@@ -19,23 +17,11 @@ namespace Kiss
AuthTryAgain,
AuthSuccess
};
+
+ virtual ~Responder();
- virtual void availableResponse(Target *target, const bool& available) = 0;
- virtual void compileResponse(Target *target, const Compiler::OutputList& results) = 0;
- virtual void downloadResponse(Target *target, const bool& success) = 0;
- virtual void runResponse(Target *target, const bool& success) = 0;
- virtual void listResponse(Target *target, const QStringList& programs) = 0;
- virtual void deleteResponse(Target *target, const bool& success) = 0;
- virtual void interactionResponse(Target *target, const QString& ret) = 0;
- virtual void unknownResponse(Target *target, const QByteArray& payload) = 0;
- virtual void customResponse(Target *target, const QString& type, const QByteArray& payload) = 0;
- virtual void communicationError(Target *target) = 0;
- virtual void connectionError(Target *target) = 0;
- virtual void notAuthenticatedError(Target *target) = 0;
- virtual void authenticationResponse(Target *target, const Responder::AuthenticateReturn& response) = 0;
+ virtual void response(Target *target, const Response &response) = 0;
};
-
- typedef QList<Responder *> ResponderPtrList;
}
}
View
32 include/interface/target_response.hpp
@@ -0,0 +1,32 @@
+#ifndef _TARGET_RESPONSE_HPP_
+#define _TARGET_RESPONSE_HPP_
+
+#include <QString>
+#include <QVariant>
+#include <QMetaType>
+
+namespace Kiss
+{
+ namespace Target
+ {
+ class Response
+ {
+ public:
+ Response();
+ Response(quint64 id, const QString &type, const QVariant &data);
+
+ const quint64 &id() const;
+ const QString &type() const;
+ const QVariant &data() const;
+
+ private:
+ quint64 m_id;
+ QString m_type;
+ QVariant m_data;
+ };
+ }
+}
+
+Q_DECLARE_METATYPE(Kiss::Target::Response);
+
+#endif
View
21 include/main_window.hpp
@@ -41,9 +41,16 @@
#define RECENTS "recents"
class QListWidgetItem;
+class QProgressBar;
namespace Kiss
{
+ namespace Target
+ {
+ class Responder;
+ class MainResponder;
+ }
+
namespace Template
{
class Manager;
@@ -61,7 +68,7 @@ namespace Kiss
class MainWindow : public QMainWindow, private Ui::MainWindow
{
Q_OBJECT
- public:
+ public:
MainWindow(QWidget *parent = 0);
~MainWindow();
@@ -102,7 +109,9 @@ namespace Kiss
* \param time Time to display in milliseconds
*/
void setStatusMessage(const QString& message, int time = 0);
-
+
+ void setOutputList(const Compiler::OutputList &output);
+
void hideErrors();
/*!
@@ -162,7 +171,9 @@ namespace Kiss
bool canClose();
bool canGoPrevious();
bool canGoNext();
-
+
+ Target::Responder *mainResponder() const;
+
Project::ProjectPtr activeProject() const;
friend class Menu::MainWindowMenu;
@@ -225,11 +236,15 @@ namespace Kiss
Project::Manager m_projectManager;
QList<Menu::Menuable *> m_menuables;
+ QProgressBar *m_commProgress;
+
Project::Model m_projectsModel;
void addLookup(Tab *tab);
void removeLookup(QWidget* widget);
Tab *lookup(QWidget* widget) const;
+
+ Target::Responder *m_mainResponder;
void showErrorMessages(bool verbose = false);
};
View
4 include/project/project.hpp
@@ -40,10 +40,10 @@ namespace Kiss
void refresh();
- KarPtr createArchive() const;
+ virtual KarPtr archive() const;
protected:
- bool visitSelf(const Kiss::KarPtr &archive);
+ bool visitSelf(const Kiss::KarPtr &archive) const;
private:
Project(const QString& location);
View
27 include/source_file.hpp
@@ -26,7 +26,6 @@
#include "unit.hpp"
#include "output_helper.hpp"
#include "source_find_widget.hpp"
-#include "qt_target_responder.hpp"
#include "ui_SourceFile.h"
@@ -138,21 +137,19 @@ namespace Kiss
void sourceModified(bool m);
+ virtual Kiss::KarPtr archive() const;
+
signals:
void updateActivatable();
+
+ protected:
+ void keyPressEvent(QKeyEvent *event);
+ virtual void fileChanged(const QFileInfo& file);
+ virtual void projectChanged(const Project::ProjectPtr& project);
private slots:
void on_ui_editor_cursorPositionChanged(int line, int index);
-
- void availableFinished(const bool& avail);
- void compileFinished(const Compiler::OutputList& result);
- void downloadFinished(const bool& success);
- void runFinished(const bool& success);
- void connectionError();
- void communicationError();
- void notAuthenticatedError();
- void authenticationResponse(const Target::Responder::AuthenticateReturn& response);
-
+
private:
bool saveAsFile();
bool saveAsProject();
@@ -190,14 +187,6 @@ namespace Kiss
void updateLexer();
bool actionPreconditions();
-
- Target::QtResponder m_responder;
-
- protected:
- void keyPressEvent(QKeyEvent *event);
- virtual void fileChanged(const QFileInfo& file);
- virtual void projectChanged(const Project::ProjectPtr& project);
- virtual bool visitSelf(const Kiss::KarPtr &archive);
};
}
}
View
48 include/syntax_highlighter.hpp
@@ -1,48 +0,0 @@
-#ifndef _SYNTAX_HIGHLIGHTER_HPP_
-#define _SYNTAX_HIGHLIGHTER_HPP_
-
-#include <QSyntaxHighlighter>
-
-#include <QHash>
-#include <QTextCharFormat>
-
-class QTextDocument;
-
-namespace Kiss
-{
- class SyntaxHighlighter : public QSyntaxHighlighter
- {
- Q_OBJECT
- public:
- struct Rule
- {
- QRegExp pattern;
- QTextCharFormat format;
- };
-
- const QRegExp& commentStartExpression() const;
- const QRegExp& commentEndExpression() const;
- const QTextCharFormat& multiLineCommentFormat() const;
- const QVector<Rule>& rules() const;
-
- protected:
- SyntaxHighlighter(QTextDocument *parent = 0);
-
- virtual void highlightBlock(const QString& text);
-
- void setCommentStartExpression(const QRegExp& commentStartExpression);
- void setCommentEndExpression(const QRegExp& commentEndExpression);
- void setMultiLineCommentFormat(const QTextCharFormat& multiLineCommentFormat);
-
- void addRule(const SyntaxHighlighter::Rule& rule);
- private:
- QVector<Rule> m_highlightingRules;
-
- QRegExp m_commentStartExpression;
- QRegExp m_commentEndExpression;
- QTextCharFormat m_multiLineCommentFormat;
- };
-}
-
-
-#endif
View
1  include/tab.hpp
@@ -26,7 +26,6 @@
#include <QDebug>
#include <QFileInfo>
-#include "target.hpp"
#include "project.hpp"
#define TABBED_WIDGET_PROPERTY "_kiss_tabbed_"
View
7 include/unit.hpp
@@ -17,7 +17,7 @@ namespace Kiss
Download,
Compile,
Run
- }
+ };
Unit(Unit *parent = 0);
@@ -43,10 +43,7 @@ namespace Kiss
virtual bool unitActionRequested();
- virtual bool visit(const Kiss::KarPtr &archive);
-
- protected:
- virtual bool visitSelf(const Kiss::KarPtr &archive) = 0;
+ virtual Kiss::KarPtr archive() const = 0;
private:
Unit *m_parent;
View
39 include/widgets/communication_progress_bar.hpp
@@ -0,0 +1,39 @@
+#ifndef _COMMUNICATION_PROGRESS_BAR_HPP_
+#define _COMMUNICATION_PROGRESS_BAR_HPP_
+
+#include <QProgressBar>
+
+namespace Kiss
+{
+ namespace Target
+ {
+ class CommunicationManager;
+ }
+
+ namespace Widget
+ {
+ class CommunicationProgressBar : public QProgressBar
+ {
+ Q_OBJECT
+ public:
+ CommunicationProgressBar(Target::CommunicationManager *manager, QWidget *parent = 0);
+
+ Target::CommunicationManager *manager() const;
+
+ protected:
+ void paintEvent(QPaintEvent *event);
+
+ private slots:
+ void admitted();
+ void finished();
+ void queueFinished();
+
+ private:
+ Target::CommunicationManager *m_manager;
+ quint32 m_done;
+ quint32 m_total;
+ };
+ }
+}
+
+#endif
View
27 include/widgets/communication_widget.hpp
@@ -0,0 +1,27 @@
+#ifndef _COMMUNICATION_WIDGET_HPP_
+#define _COMMUNICATION_WIDGET_HPP_
+
+#include <QWidget>
+
+namespace Ui
+{
+ class CommunicationWidget;
+}
+
+namespace Kiss
+{
+ namespace Widget
+ {
+ class CommunicationWidget : public QWidget
+ {
+ public:
+ CommunicationWidget(QWidget *parent = 0);
+ ~CommunicationWidget();
+
+ private:
+ Ui::CommunicationWidget *ui;
+ };
+ }
+}
+
+#endif
View
4 plugins/interfaces/CMakeLists.txt
@@ -1,3 +1,3 @@
-add_subdirectory(computer)
+# add_subdirectory(computer)
add_subdirectory(kovan)
-# add_subdirectory(serial)
+add_subdirectory(kovan_serial)
View
7 plugins/interfaces/computer/computer_interface.hpp
@@ -1,10 +1,8 @@
-#ifndef _COMPUTERINTERFACE_H_
-#define _COMPUTERINTERFACE_H_
+#ifndef _COMPUTER_INTERFACE_HPP_
+#define _COMPUTER_INTERFACE_HPP_
#include <QtPlugin>
#include "interface.hpp"
-#include <easydevice/DiscoveryServer.h>
-#include <easydevice/DeviceInfo.h>
class ComputerInterface : public QObject, public Kiss::Target::Interface
{
@@ -22,7 +20,6 @@ private slots:
void found(EasyDevice::DeviceInfo deviceInfo, const QHostAddress& address);
private:
- EasyDevice::DiscoveryServer *m_server;
Kiss::Target::InterfaceResponder *m_responder;
};
View
2  plugins/interfaces/kovan/CMakeLists.txt
@@ -27,7 +27,7 @@ ADD_DEFINITIONS(-DQT_DLL)
ADD_LIBRARY(${PLUGIN_NAME} SHARED ${LOCAL_SOURCES} ${INCLUDES_MOC})
LINK_DIRECTORIES(${LIBRARY_OUTPUT_PATH})
-TARGET_LINK_LIBRARIES(${PLUGIN_NAME} ${QT_LIBRARIES} kisside pcompiler easydevice kar)
+TARGET_LINK_LIBRARIES(${PLUGIN_NAME} ${QT_LIBRARIES} kisside pcompiler kovanserial kar)
IF(APPLE)
SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -headerpad_max_install_names")
View
65 plugins/interfaces/kovan/kovan_interface.cpp
@@ -1,5 +1,7 @@
#include "kovan_interface.hpp"
-#include "tcp_socket_device.hpp"
+#include "kovan_proto_target.hpp"
+
+#include <kovanserial/tcp_serial.hpp>
#include <QProcess>
#include <QDir>
@@ -8,32 +10,66 @@
#include <QTcpSocket>
#include <QHostAddress>
+#include <QRunnable>
+#include <QThreadPool>
#include <QBuffer>
-using namespace EasyDevice;
using namespace Kiss::Target;
+AdvertSampler::AdvertSampler(UdpAdvertiser *advertiser, const quint64 &sampleTime, const quint16 &samples)
+ : m_advertiser(advertiser),
+ m_sampleTime(sampleTime),
+ m_samples(samples)
+{
+}
+
+AdvertSampler::~AdvertSampler()
+{
+}
+
+void AdvertSampler::run()
+{
+ for(quint16 i = 0; i < m_samples; ++i) {
+ std::list<IncomingAdvert> adverts = m_advertiser->sample(m_sampleTime);
+ std::list<IncomingAdvert>::const_iterator it = adverts.begin();
+ for(; it != adverts.end(); ++it) {
+ QHostAddress addr((sockaddr *)&(*it).sender);
+ if(m_found.contains(addr)) continue;
+ m_found.push_back(addr);
+ emit found((*it).ad, (*it).sender);
+ }
+ }
+}
+
KovanInterface::KovanInterface()
: Interface("Kovan (Networked)"),
- m_server(new DiscoveryServer()),
+ m_advertiser(new UdpAdvertiser(false)),
m_responder(0)
{
- connect(m_server, SIGNAL(discoveryStarted()), SLOT(scanStarted()));
- connect(m_server,
- SIGNAL(discoveredDevice(EasyDevice::DeviceInfo, const QHostAddress&)),
- SLOT(found(EasyDevice::DeviceInfo, const QHostAddress&)));
}
KovanInterface::~KovanInterface()
{
- delete m_server;
+ delete m_advertiser;
+}
+
+Kiss::Target::TargetPtr KovanInterface::createTarget(const QString &address)
+{
+ // TODO: Add input verification
+ TcpSerial *serial = new TcpSerial(address.toAscii(), KOVAN_SERIAL_PORT);
+ KovanProtoTarget *device = new Kiss::Target::KovanProtoTarget(serial, this);
+ return TargetPtr(device);
}
const bool KovanInterface::scan(InterfaceResponder *responder)
{
m_responder = responder;
- m_server->setup();
- m_server->discover("kovan");
+ m_advertiser->reset();
+ AdvertSampler *sampler = new AdvertSampler(m_advertiser, 100, 100);
+ qRegisterMetaType<Advert>("Advert");
+ qRegisterMetaType<sockaddr_in>("sockaddr_in");
+ connect(sampler, SIGNAL(found(Advert, sockaddr_in)), SLOT(found(Advert, sockaddr_in)));
+ QThreadPool::globalInstance()->start(sampler);
return true;
}
@@ -48,11 +84,14 @@ void KovanInterface::scanStarted()
m_responder->targetScanStarted(this);
}
-void KovanInterface::found(DeviceInfo deviceInfo, const QHostAddress& address)
+void KovanInterface::found(const Advert &ad, const sockaddr_in& addr)
{
if(!m_responder) return;
- TcpSocketDevice *device = new Kiss::Target::TcpSocketDevice(this, address, 8075);
- device->setDeviceInfo(deviceInfo);
+ QHostAddress ha((sockaddr *)&addr);
+
+ TcpSerial *serial = new TcpSerial(ha.toString().toAscii(), KOVAN_SERIAL_PORT);
+ KovanProtoTarget *device = new Kiss::Target::KovanProtoTarget(serial, this);
+ device->fillInformation(ad);
m_responder->targetFound(this, TargetPtr(device));
}
View
68 plugins/interfaces/kovan/kovan_interface.hpp
@@ -2,27 +2,59 @@
#define _KOVAN_INTERFACE_HPP_
#include <QtPlugin>
+#include <QRunnable>
+#include <QList>
+#include <QHostAddress>
#include "interface.hpp"
#include <kovanserial/udp_advertiser.hpp>
-class KovanInterface : public QObject, public Kiss::Target::Interface
+class UdpAdvertiser;
+
+namespace Kiss
{
-Q_OBJECT
-Q_INTERFACES(Kiss::Target::Interface)
-public:
- KovanInterface();
- ~KovanInterface();
-
- virtual const bool scan(Kiss::Target::InterfaceResponder *responder);
- virtual void invalidateResponder();
-
-private slots:
- void scanStarted();
- void found(const Advert &ad, const QHostAddress& address);
-
-private:
- UdpAdvertiser *m_advertiser;
- Kiss::Target::InterfaceResponder *m_responder;
-};
+ namespace Target
+ {
+ class AdvertSampler : public QObject, public QRunnable
+ {
+ Q_OBJECT
+ public:
+ AdvertSampler(UdpAdvertiser *advertiser, const quint64 &sampleTime, const quint16 &samples);
+ ~AdvertSampler();
+ void run();
+
+ signals:
+ void found(const Advert &ad, const sockaddr_in &addr);
+
+ private:
+ UdpAdvertiser *m_advertiser;
+ quint64 m_sampleTime;
+ quint16 m_samples;
+
+ QList<QHostAddress> m_found;
+ };
+
+ class KovanInterface : public QObject, public Kiss::Target::Interface
+ {
+ Q_OBJECT
+ Q_INTERFACES(Kiss::Target::Interface)
+ public:
+ KovanInterface();
+ ~KovanInterface();
+
+ virtual Kiss::Target::TargetPtr createTarget(const QString &address);
+ virtual const bool scan(Kiss::Target::InterfaceResponder *responder);
+ virtual void invalidateResponder();
+
+ private slots:
+ void scanStarted();
+ void found(const Advert &ad, const sockaddr_in& addr);
+
+ private:
+ UdpAdvertiser *m_advertiser;
+ Kiss::Target::InterfaceResponder *m_responder;
+ };
+ }
+}
+
#endif
View
6 plugins/interfaces/serial/CMakeLists.txt → plugins/interfaces/kovan_serial/CMakeLists.txt
@@ -1,4 +1,4 @@
-SET(PLUGIN_NAME serial_interface)
+SET(PLUGIN_NAME kovan_serial_interface)
PROJECT(${PLUGIN_NAME})
cmake_minimum_required(VERSION 2.6.0)
@@ -27,7 +27,7 @@ ADD_DEFINITIONS(-DQT_DLL)
ADD_LIBRARY(${PLUGIN_NAME} SHARED ${LOCAL_SOURCES} ${INCLUDES_MOC})
LINK_DIRECTORIES(${LIBRARY_OUTPUT_PATH})
-TARGET_LINK_LIBRARIES(${PLUGIN_NAME} ${QT_LIBRARIES} kisside pcompiler easydevice)
+TARGET_LINK_LIBRARIES(${PLUGIN_NAME} ${QT_LIBRARIES} kisside pcompiler kovanserial kar)
IF(APPLE)
SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -headerpad_max_install_names")
@@ -45,6 +45,8 @@ ADD_CUSTOM_TARGET(${PLUGIN_NAME}_osx_install_names ALL
QtWebKit.framework/Versions/4/QtWebKit
phonon.framework/Versions/4/phonon
QtDeclarative.framework/Versions/4/QtDeclarative
+ libkar.dylib
+ libpcompiler.dylib
WORKING_DIRECTORY ${LIBRARY_OUTPUT_PATH}
DEPENDS ${PLUGIN_NAME})
INSTALL(TARGETS ${PLUGIN_NAME} LIBRARY DESTINATION ${EXECUTABLE_OUTPUT_PATH}/KISS.app/Contents/interfaces)
View
83 plugins/interfaces/kovan_serial/kovan_serial_interface.cpp
@@ -0,0 +1,83 @@
+#include "kovan_serial_interface.hpp"
+#include "kovan_proto_target.hpp"
+
+#include <kovanserial/usb_serial.hpp>
+
+#include <QProcess>
+#include <QDir>
+#include <QTextStream>
+#include <QDebug>
+
+#include <QTcpSocket>
+#include <QHostAddress>
+#include <QRunnable>
+#include <QThreadPool>
+#include <QBuffer>
+
+using namespace Kiss::Target;
+
+PortSampler::PortSampler()
+{
+}
+
+PortSampler::~PortSampler()
+{
+}
+
+void PortSampler::run()
+{
+#ifdef Q_OS_MAC
+ QDir dir("/dev/");
+ const QStringList list = dir.entryList(QStringList() << "tty.usbmodem*", QDir::System);
+
+#elif defined(Q_OS_WIN)
+ qDebug() << "Device discovery not yet implemented for windows!";
+#endif
+}
+
+KovanSerialInterface::KovanSerialInterface()
+ : Interface("Kovan (Serial)"),
+ m_responder(0)
+{
+}
+
+KovanSerialInterface::~KovanSerialInterface()
+{
+}
+
+Kiss::Target::TargetPtr KovanSerialInterface::createTarget(const QString &address)
+{
+ // TODO: Add input verification
+ UsbSerial *serial = new UsbSerial(address.toAscii());
+ KovanProtoTarget *device = new Kiss::Target::KovanProtoTarget(serial, this);
+ device->fillDisplayName(address);
+ return TargetPtr(device);
+}
+
+const bool KovanSerialInterface::scan(InterfaceResponder *responder)
+{
+ m_responder = responder;
+ return true;
+}
+
+void KovanSerialInterface::invalidateResponder()
+{
+ m_responder = 0;
+}
+
+void KovanSerialInterface::scanStarted()
+{
+ if(!m_responder) return;
+ m_responder->targetScanStarted(this);
+}
+
+void KovanSerialInterface::found(const QString &port)
+{
+ if(!m_responder) return;
+
+ UsbSerial *serial = new UsbSerial(port.toAscii());
+ KovanProtoTarget *device = new Kiss::Target::KovanProtoTarget(serial, this);
+ m_responder->targetFound(this, TargetPtr(device));
+}
+
+Q_EXPORT_PLUGIN2(kovan_serial_interface, KovanSerialInterface);
View
52 plugins/interfaces/kovan_serial/kovan_serial_interface.hpp
@@ -0,0 +1,52 @@
+#ifndef _KOVAN_INTERFACE_HPP_
+#define _KOVAN_INTERFACE_HPP_
+
+#include <QtPlugin>
+#include <QRunnable>
+#include <QList>
+#include <QHostAddress>
+#include "interface.hpp"
+#include <kovanserial/udp_advertiser.hpp>
+
+class UdpAdvertiser;
+
+namespace Kiss
+{
+ namespace Target
+ {
+ class PortSampler : public QObject, public QRunnable
+ {
+ Q_OBJECT
+ public:
+ PortSampler();
+ ~PortSampler();
+ void run();
+
+ signals:
+ void found(const QString &port);
+ };
+
+ class KovanSerialInterface : public QObject, public Kiss::Target::Interface
+ {
+ Q_OBJECT
+ Q_INTERFACES(Kiss::Target::Interface)
+ public:
+ KovanSerialInterface();
+ ~KovanSerialInterface();
+
+ virtual Kiss::Target::TargetPtr createTarget(const QString &address);
+ virtual const bool scan(Kiss::Target::InterfaceResponder *responder);
+ virtual void invalidateResponder();
+
+ private slots:
+ void scanStarted();
+ void found(const QString &port);
+
+ private:
+ Kiss::Target::InterfaceResponder *m_responder;
+ };
+ }
+}
+
+
+#endif
View
240 plugins/interfaces/shared/kovan_proto_target.cpp
@@ -1,75 +1,21 @@
#include "kovan_proto_target.hpp"
+#include <kovanserial/transmitter.hpp>
+#include <pcompiler/output.hpp>
+
#include <QQueue>
-#include <QMutex>
-#include <QRunnable>
-#include <QThread>
-#include <QThreadPool>
+#include <QDebug>
+#include <sstream>
-struct Work
-{
- enum Type {
- Downlaod,
- Compile,
- Run
- };
-
- Type type;
- QString name;
- KarPtr archive;
-};
+using namespace Kiss;
+using namespace Kiss::Target;
-class KovanSerialWorker : public QRunnable
-{
-Q_OBJECT
-public:
- KovanSerialWorker(KovanProto *proto)
- : m_proto(proto),
- m_stop(false)
- {
- }
-
- void work(const Work &w)
- {
- m_mutex.lock();
- m_workQueue.enqueue(w);
- m_mutex.unlock();
- }
-
- void stop()
- {
- m_stop = true;
- }
-
- void run()
- {
- while(!m_stop) {
- m_mutex.lock();
- Work w = m_workQueue.dequeue();
- m_mutex.unlock();
-
- QThread::yieldCurrentThread();
- }
- }
-
-private:
- bool download(const Work &w)
- {
- m_proto->sendFile();
- }
-
- KovanProto *m_proto;
- QMutex m_mutex;
- bool m_stop;
- QQueue<Work> m_workQueue;
-};
-
-KovanProtoTarget::KovanProtoTarget(Transmitter *transmitter)
- : m_transmitter(transmitter),
+KovanProtoTarget::KovanProtoTarget(Transmitter *transmitter, Interface *interface)
+ : Target(interface, "kovan_proto_target"),
+ m_transmitter(transmitter),
m_transport(m_transmitter),
m_proto(&m_transport)
{
-
}
KovanProtoTarget::~KovanProtoTarget()
@@ -77,14 +23,28 @@ KovanProtoTarget::~KovanProtoTarget()
delete m_transmitter;
}
+void KovanProtoTarget::fillDisplayName(const QString &displayName)
+{
+ m_information[DISPLAY_NAME] = displayName;
+}
+
+void KovanProtoTarget::fillInformation(const Advert &advert)
+{
+ m_information[DISPLAY_NAME] = advert.name;
+ m_information[SERIAL] = advert.serial;
+ m_information[VERSION] = advert.version;
+ m_information[DEVICE_TYPE] = advert.device;
+}
+
const QMap<QString, QString> KovanProtoTarget::information() const
{
- return QMap<QString, QString>();
+ return m_information;
}
const bool KovanProtoTarget::disconnect()
{
// We will be auto-disconnected by libkovanserial
+ return true;
}
const bool KovanProtoTarget::available()
@@ -92,42 +52,164 @@ const bool KovanProtoTarget::available()
return true;
}
-const bool KovanProtoTarget::compile(const QString& name)
+#define KEY_COMPILE "compile"
+
+const bool KovanProtoTarget::compile(quint64 id, const QString& name)
{
+ qDebug() << "Compiling...";
+ bool success = m_transmitter->makeAvailable();
+ if(!success) perror("makeAvailable");
+ emit response(Response(id, "connection", success));
+ if(!success) return false;
+
+ qDebug() << "Compiling" << name;
+ if(!m_proto.sendFileAction(COMMAND_ACTION_COMPILE, name.toStdString())) {
+ emit response(Response(id, KEY_COMPILE, false));
+ qWarning() << "Send file action failed.";
+ m_proto.hangup();
+ m_transmitter->endSession();
+ return false;
+ }
+
+ bool finished = false;
+ // TODO: Show progress
+ double progress = 0.0;
+ qDebug() << "Waiting for progress reports...";
+ do {
+ // TODO: Adjust this timeout
+ if(!m_proto.recvFileActionProgress(finished, progress, 30000)) {
+ emit response(Response(id, KEY_COMPILE, false));
+ qWarning() << "recv file action progress failed.";
+ m_transmitter->endSession();
+ return false;
+ }
+ } while(!finished);
+
+ qDebug() << "Waiting for results...";
+ Packet p;
+ if(!m_transport.recv(p, 15000) || p.type != Command::FileHeader) {
+ qWarning() << "Failed to recv results of compile";
+ emit response(Response(id, KEY_COMPILE, true));
+ m_transmitter->endSession();
+ return false;
+ }
+
+ Command::FileHeaderData header;
+ p.as(header);
+
+ if(!m_proto.confirmFile(true)) {
+ qWarning() << "Failed to confirm incoming compile results";
+ m_proto.hangup();
+ m_transmitter->endSession();
+ return false;
+ };
+
+ std::ostringstream sstream;
+ if(!m_proto.recvFile(header.size, &sstream, 5000)) {
+ qWarning() << "Recv compile results failed";
+ m_proto.hangup();
+ m_transmitter->endSession();
+ return false;
+ }
+
+ m_proto.hangup();
+
+ QByteArray compileResults(sstream.str().c_str(), sstream.str().size());
+ QDataStream stream(&compileResults, QIODevice::ReadOnly);
+
+ Compiler::OutputList results;
+ stream >> results;
+
+ emit response(Response(id, KEY_COMPILE, QVariant::fromValue(results)));
+
+ m_transmitter->endSession();
+
+ return true;
}
-const bool KovanProtoTarget::download(const QString& name, const KarPtr& archive)
+#define KEY_DOWNLOAD "download"
+
+const bool KovanProtoTarget::download(quint64 id, const QString& name, const KarPtr& archive)
{
- return m_proto.sendFile(name);
+ qDebug() << "Downloading" << name << "...";
+ bool success = m_transmitter->makeAvailable();
+ if(!success) perror("makeAvailable");
+ emit response(Response(id, "connection", success));
+ if(!success) return false;
+ QByteArray data;
+ QDataStream qStream(&data, QIODevice::ReadWrite);
+ qStream << (*archive);
+ std::istringstream istream;
+ istream.rdbuf()->pubsetbuf(data.data(), data.size());
+ if(!m_proto.sendFile(name.toStdString(), "kar", &istream)) {
+ emit response(Response(id, KEY_DOWNLOAD, false));
+ m_proto.hangup();
+ m_transmitter->endSession();
+ return false;
+ }
+
+ emit response(Response(id, KEY_DOWNLOAD, true));
+
+ m_proto.hangup();
+ m_transmitter->endSession();
+ return true;
}
-const bool KovanProtoTarget::run(const QString& name)
+#define KEY_RUN "run"
+
+const bool KovanProtoTarget::run(quint64 id, const QString& name)
{
+ qDebug() << "Running...";
+ bool success = m_transmitter->makeAvailable();
+ if(!success) perror("makeAvailable");
+ emit response(Response(id, "connection", success));
+ if(!success) return false;
+
+ if(!m_proto.sendFileAction(COMMAND_ACTION_RUN, name.toStdString())) {
+ emit response(Response(id, KEY_RUN, false));
+ m_proto.hangup();
+ return false;
+ }
+
+ bool finished = false;
+ // TODO: Show progress
+ double progress = 0.0;
+ do {
+ if(!m_proto.recvFileActionProgress(finished, progress, 5000)) {
+ emit response(Response(id, KEY_RUN, false));
+ return false;
+ }
+ } while(!finished);
+ m_proto.hangup();
+ m_transmitter->endSession();
+ emit response(Response(id, KEY_RUN, true));
+
+ return true;
}
-const bool KovanProtoTarget::list()
+const bool KovanProtoTarget::list(quint64 id)
{
-
+ return false;
}
-const bool KovanProtoTarget::deleteProgram(const QString& name)
+const bool KovanProtoTarget::deleteProgram(quint64 id, const QString& name)
{
-
+ return false;
}
-const bool KovanProtoTarget::interaction(const QString& command)
+const bool KovanProtoTarget::interaction(quint64 id, const QString& command)
{
-
+ return false;
}
-const bool KovanProtoTarget::authenticate(const QByteArray& hash)
+const bool KovanProtoTarget::authenticate(quint64 id, const QByteArray& hash)
{
-
+ return false;
}
-const bool KovanProtoTarget::sendCustom(const QString& custom, const QByteArray& payload)
+const bool KovanProtoTarget::sendCustom(quint64 id, const QString& custom, const QByteArray& payload)
{
-
+ return false;
}
View
68 plugins/interfaces/shared/kovan_proto_target.hpp
@@ -3,38 +3,52 @@
#include "target.hpp"
+#include <kar.hpp>
+
#include <kovanserial/transport_layer.hpp>
#include <kovanserial/kovan_serial.hpp>
+#include <kovanserial/udp_advertiser.hpp>
class Transmitter;
-class KovanProtoTarget : public QObject, public Target
+namespace Kiss
{
-Q_OBJECT
-public:
- KovanProtoTarget(Transmitter *transmitter);
- ~KovanProtoTarget();
-
- virtual const QMap<QString, QString> information() const; // Needs to be cached
-
- virtual const bool disconnect();
-
- virtual const bool available();
- virtual const bool compile(const QString& name);
- virtual const bool download(const QString& name, const KarPtr& archive);
- virtual const bool run(const QString& name);
-
- virtual const bool list();
- virtual const bool deleteProgram(const QString& name);
- virtual const bool interaction(const QString& command);
-
- virtual const bool authenticate(const QByteArray& hash);
- virtual const bool sendCustom(const QString& custom, const QByteArray& payload = QByteArray());
-
-private:
- Transmitter *m_serial;
- TransportLayer m_transport;
- KovanSerial m_proto;
-};
+ namespace Target
+ {
+ class KovanProtoTarget : public Target
+ {
+ Q_OBJECT
+ public:
+ KovanProtoTarget(Transmitter *transmitter, Interface *interface);
+ ~KovanProtoTarget();
+
+ void fillDisplayName(const QString &displayName);
+ void fillInformation(const Advert &advert);
+
+ virtual const QMap<QString, QString> information() const; // Needs to be cached
+
+ virtual const bool disconnect();
+
+ virtual const bool available();
+
+ virtual const bool compile(quint64 id, const QString& name);
+ virtual const bool download(quint64 id, const QString& name, const Kiss::KarPtr& archive);
+ virtual const bool run(quint64 id, const QString& name);
+
+ virtual const bool list(quint64 id);
+ virtual const bool deleteProgram(quint64 id, const QString& name);
+ virtual const bool interaction(quint64 id, const QString& command);
+
+ virtual const bool authenticate(quint64 id, const QByteArray& hash);
+ virtual const bool sendCustom(quint64 id, const QString& custom, const QByteArray& payload = QByteArray());
+
+ private:
+ Transmitter *m_transmitter;
+ TransportLayer m_transport;
+ KovanSerial m_proto;
+ QMap<QString, QString> m_information;
+ };
+ }
+}
#endif
View
69 src/c_highlighter.cpp
@@ -1,69 +0,0 @@
-#include <QtGui>
-
-#include "c_highlighter.hpp"
-#include "syntax_standards.hpp"
-
-using namespace Kiss;
-
-CHighlighter::CHighlighter(QTextDocument *parent)
- : SyntaxHighlighter(parent)
-{
- SyntaxHighlighter::Rule rule;
-
- QTextCharFormat keywordFormat;
- keywordFormat.setForeground(SyntaxStandards::keywordColor());
- keywordFormat.setFontWeight(QFont::Bold);
-
- QStringList keywordPatterns;
- keywordPatterns << "auto" << "break" << "case" << "char"
- << "const" << "continue" << "default" << "do"
- << "double" << "else" << "enum" << "extern"
- << "float" << "for" << "goto" << "if" << "int"
- << "long" << "register" << "return" << "short"
- << "signed" << "sizeof" << "static" << "struct"
- << "switch" << "typedef" << "union" << "unsigned"
- << "void" << "volatile" << "while";
-
- foreach(const QString& pattern, keywordPatterns) {
- rule.pattern = QRegExp(QString("\\b") + pattern + "\\b");
- rule.format = keywordFormat;
- addRule(rule);
- }
-
- QTextCharFormat numberFormat;
- numberFormat.setForeground(SyntaxStandards::numberColor());
-
- rule.pattern = QRegExp("\\b\\d+((l|L)|(e\\d))?\\b");
- rule.format = numberFormat;
- addRule(rule);
-
- rule.pattern = QRegExp("\\b0x[0-9A-Fa-f]+\\b");
- rule.format = numberFormat;
- addRule(rule);
-
- QTextCharFormat preprocessor;
- preprocessor.setForeground(SyntaxStandards::preprocessorColor());
- rule.pattern = QRegExp("^#.+");
- rule.format = preprocessor;
- addRule(rule);
-
- QTextCharFormat quotationFormat;
- quotationFormat.setForeground(SyntaxStandards::stringColor());
- rule.pattern = QRegExp("\".*\"");
- rule.format = quotationFormat;
- addRule(rule);
-
- QTextCharFormat singleLineCommentFormat;
- singleLineCommentFormat.setForeground(SyntaxStandards::commentColor());
- rule.pattern = QRegExp("//[^\n]*");
- rule.format = singleLineCommentFormat;
- addRule(rule);
-
- QTextCharFormat multiLineCommentFormat;
- multiLineCommentFormat.setForeground(SyntaxStandards::commentColor());
- setMultiLineCommentFormat(multiLineCommentFormat);
-
- setCommentStartExpression(QRegExp("/\\*"));
- setCommentEndExpression(QRegExp("\\*/"));
-}
-
View
217 src/code_editor.cpp
@@ -1,217 +0,0 @@
-#include "code_editor.hpp"
-
-#include <QPaintEvent>
-#include <QPainter>
-#include <QTextBlock>
-
-#include <QDebug>
-
-using namespace Kiss;
-using namespace Kiss::Widget;
-
-CodeEditorMargin::CodeEditorMargin(CodeEditor *editor)
- : QWidget(editor),
- m_editor(editor)
-{
-}
-
-QSize CodeEditorMargin::sizeHint() const
-{
- return QSize(m_editor->marginSize(), 0);
-}
-
-
-void CodeEditorMargin::paintEvent(QPaintEvent *event)
-{
- m_editor->marginPaintEvent(event);
-}
-
-MarginIndicator MarginIndicator::s_none(Qt::transparent);
-
-MarginIndicator::MarginIndicator(const QColor& color)
- : m_color(color)
-{
-
-}
-
-const QColor& MarginIndicator::color() const
-{
- return m_color;
-}
-
-const MarginIndicator& MarginIndicator::none()
-{
- return s_none;
-}
-
-CodeEditor::CodeEditor(QWidget *parent)
- : QPlainTextEdit(parent),
- m_margin(new CodeEditorMargin(this))
-{
- connect(this, SIGNAL(blockCountChanged(int)), this, SLOT(updateMarginSize()));
- connect(this, SIGNAL(updateRequest(QRect, int)), this, SLOT(updateMarginArea(QRect, int)));
- connect(this, SIGNAL(cursorPositionChanged()), this, SLOT(highlightCurrentLine()));
- connect(this, SIGNAL(cursorPositionChanged()), m_margin, SLOT(update()));
-
- updateMarginSize();
- highlightCurrentLine();
-
- setEditorFont(editorFont());
-}
-
-void CodeEditor::setEditorFont(const QFont& font)
-{
- setFont(font);
- m_marginFont = font;
- m_marginFont.setPointSize(font.pointSize() - 2);
- setTabStopWidth(fontMetrics().width(QLatin1Char(' ')) * 4);
- updateMarginSize();
-}
-
-QFont CodeEditor::editorFont() const
-{
- return font();
-}
-
-QFont CodeEditor::marginFont() const
-{
- return m_marginFont;
-}
-
-void CodeEditor::setMarginIndicator(const int& line, const MarginIndicator& indicator)
-{
- m_indicators.remove(line);
- m_indicators.insert(line, indicator);
- m_margin->update();
-}
-
-void CodeEditor::clearIndicators()
-{
- m_indicators.clear();
-}
-
-quint16 CodeEditor::marginSize() const
-{
- quint16 digits = 1;
- quint16 max = qMax(1, blockCount());
- while(max >= 10) {
- max /= 10;
- ++digits;
- }
- quint16 space = 3 + fontMetrics().width(QLatin1Char('9')) * digits;
- return qMax(space, (quint16)(QFontMetrics(m_marginFont).width(QLatin1Char('9')) * 4));
-}
-
-void CodeEditor::marginPaintEvent(QPaintEvent *event)
-{
- QPainter painter(m_margin);
-
- painter.fillRect(event->rect(), Qt::white);
-
- painter.setPen(QColor(127, 127, 127));
-
-
- QTextBlock block = firstVisibleBlock();
- int blockNumber = block.blockNumber();
- int top = (int)blockBoundingGeometry(block).translated(contentOffset()).top();
- int bottom = top + (int)blockBoundingRect(block).height();
-
- painter.setFont(m_marginFont);
-
- quint16 height = QFontMetrics(painter.font()).height();
-
- while(block.isValid() && top <= event->rect().bottom()) {
- if(block.isVisible() && bottom >= event->rect().top()) {
- QString number = QString::number(blockNumber + 1);
- painter.drawText(0, top + 3, m_margin->width() - 4, height, Qt::AlignVCenter | Qt::AlignRight, number);
- }
-
- if(m_indicators.contains(blockNumber)) {
- painter.fillRect(0, top, m_margin->width() - 1, bottom - top, m_indicators.value(blockNumber, MarginIndicator::none()).color());
- }
-
- block = block.next();
- top = bottom;
- bottom = top + (int)blockBoundingRect(block).height();
-
- ++blockNumber;
- }
-
- painter.drawLine(m_margin->width() - 1, event->rect().top(), m_margin->width() - 1, event->rect().bottom());
-}
-
-void CodeEditor::updateMarginArea(const QRect& rect, const int& dy)
-{
- m_margin->update(0, rect.y(), (dy ? dy : m_margin->width()), rect.height());
- if(rect.contains(viewport()->rect())) updateMarginSize();
-}
-
-void CodeEditor::updateMarginSize()
-{
- setViewportMargins(marginSize(), 0, 0, 0);
-}
-
-void CodeEditor::highlightCurrentLine()
-{
- if(isReadOnly()) return;
-
- QTextEdit::ExtraSelection selection;
-
- QColor lineColor = QColor(QColor(240, 240, 240));
-
- selection.format.setBackground(lineColor);
- selection.format.setProperty(QTextFormat::FullWidthSelection, true);
- selection.cursor = textCursor();
- selection.cursor.clearSelection();
-
- setExtraSelections(QList<QTextEdit::ExtraSelection>() << selection);
-}
-
-void CodeEditor::resizeEvent(QResizeEvent *e)
-{
- QPlainTextEdit::resizeEvent(e);
-
- const QRect& cr = contentsRect();
- m_margin->setGeometry(QRect(cr.left(), cr.top(), marginSize(), cr.height()));
-}
-
-void CodeEditor::keyPressEvent(QKeyEvent *e)
-{
- QTextCursor c = textCursor();
- if(e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter) {
- qDebug() << "Return pressed";
- int pos = c.positionInBlock();
- QString line = c.block().text();
- if(line.data()[pos - 1] == QChar('{')) {
- qDebug() << "Detected {";
- c.insertText("\n\t");
- ensureCursorVisible();
- return;
- }
- if(line.trimmed().isEmpty()) {
- c.insertText("\n");
- c.insertText(line);
- ensureCursorVisible();
- return;
- }
- }
- /* if(e->key() == '}') {
- QTextDocument *doc = document();
- QTextBlock block = Qdocument()->findBlock(c.blockNumber() - 1);
- QString line = block.text();
- int i = 0;
- for(; i < line.length() && line.data()[i] ; ++i);
- block.text().
-
- } */
-
- QPlainTextEdit::keyPressEvent(e);
- ensureCursorVisible();
-}
-
-void CodeEditor::scrollContentsBy(int dx, int dy)
-{
- QPlainTextEdit::scrollContentsBy(dx, dy);
- if(!dy) return;
- m_margin->update();
-}
View
30 src/dialogs/manual_target_dialog.cpp
@@ -0,0 +1,30 @@
+#include "manual_target_dialog.hpp"
+#include "ui_manual_target_dialog.h"
+
+#include "interface_model.hpp"
+#include "interface_manager.hpp"
+#include "interface.hpp"
+
+
+using namespace Kiss::Dialog;
+
+ManualTarget::ManualTarget(QWidget *parent)
+ : QDialog(parent),
+ ui(new Ui::ManualTargetDialog),
+ m_model(new Kiss::Target::InterfaceModel(&Target::InterfaceManager::ref(), this))
+{
+ ui->setupUi(this);
+ ui->targetInterface->setModel(m_model);
+}
+
+ManualTarget::~ManualTarget()
+{
+ delete ui;
+}
+
+Kiss::Target::TargetPtr ManualTarget::target() const
+{
+ Target::Interface *interface = m_model->rowToInterface(ui->targetInterface->currentIndex());
+ if(!interface) return Kiss::Target::TargetPtr();
+ return interface->createTarget(ui->address->text());
+}
View
14 src/dialogs/target_dialog.cpp
@@ -23,6 +23,8 @@
#include "interface.hpp"
#include "interface_manager.hpp"
+#include "manual_target_dialog.hpp"
+
using namespace Kiss::Dialog;
Target::Target(Kiss::Target::InterfaceManager *manager, QWidget *parent)
@@ -59,6 +61,7 @@ Target::~Target()
Kiss::Target::TargetPtr Target::target() const
{
+ if(!m_manualTarget.isNull()) return m_manualTarget;
return m_model.indexToTarget(ui_targets->selectionModel()->currentIndex());
}
@@ -91,3 +94,14 @@ void Target::on_ui_refresh_clicked()
foreach(Kiss::Target::Interface *interface, m_manager->interfaces())
interface->scan(&m_model);
}
+
+void Target::on_ui_manual_clicked()
+{
+ ManualTarget dialog;
+ if(dialog.exec() == QDialog::Rejected) {
+ m_manualTarget = Kiss::Target::TargetPtr();
+ return;
+ }
+ m_manualTarget = dialog.target();
+ accept();
+}
View
23 src/external_tools.cpp
@@ -0,0 +1,23 @@
+#include "external_tools.hpp"
+
+using namespace Kiss;
+
+void ExternalTools::setTool(const QString &name, const QString &path)