diff --git a/src/externalprocess/purposeprocess_main.cpp b/src/externalprocess/purposeprocess_main.cpp index ce5dc57..5cc8f71 100644 --- a/src/externalprocess/purposeprocess_main.cpp +++ b/src/externalprocess/purposeprocess_main.cpp @@ -1,161 +1,161 @@ /* Copyright 2015 Aleix Pol Gonzalez This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library. If not, see . */ #include #include #include #include #include #include #include #include #include "helper.h" #include #include static QString pluginType; static KPluginMetaData md; class Communication : public QObject { Q_OBJECT public: Communication(const QString &serverName) { int pcIdx = metaObject()->indexOfSlot("propertyChanged()"); Q_ASSERT(pcIdx>=0); const QMetaMethod propertyChangedMethod = metaObject()->method(pcIdx); m_socket.setServerName(serverName); m_socket.connectToServer(QIODevice::ReadWrite); connect(&m_socket, SIGNAL(error(QLocalSocket::LocalSocketError)), this, SLOT(error())); bool b = m_socket.waitForConnected(); Q_ASSERT(b); b = m_socket.waitForReadyRead(); Q_ASSERT(b); Q_ASSERT(m_socket.canReadLine()); QByteArray byteLine = m_socket.readLine(); byteLine.chop(1); // Drop \n const qint64 bytes = byteLine.toLongLong(); // QByteArray and QJsonDocument::from* can only handle int size. // If the payload is bigger we are screwed. Q_ASSERT(bytes <= std::numeric_limits::max()); QByteArray dataArray; dataArray.resize(bytes); int pos = 0; bool couldRead = false; while ((pos < bytes) && (couldRead = (m_socket.bytesAvailable() || m_socket.waitForReadyRead()))) { pos += m_socket.read(dataArray.data() + pos, qMin(m_socket.bytesAvailable(), bytes-pos)); } Q_ASSERT(couldRead); // false if we hit a timeout before read-end. Q_ASSERT(pos == bytes); Purpose::Configuration config(QJsonDocument::fromBinaryData(dataArray).object(), pluginType, md); config.setUseSeparateProcess(false); Q_ASSERT(config.isReady()); m_job = config.createJob(); m_job->start(); const QMetaObject* m = m_job->metaObject(); for(int i = 0, c = m->propertyCount(); iproperty(i); if (prop.hasNotifySignal() && prop.isReadable()) { connect(m_job, prop.notifySignal(), this, propertyChangedMethod, Qt::UniqueConnection); } } } private Q_SLOTS: void error() { qWarning() << "socket error:" << m_socket.error(); } void propertyChanged() { const int idx = senderSignalIndex(); const QMetaObject* m = m_job->metaObject(); QJsonObject toSend; for(int i = 0, c = m->propertyCount(); iproperty(i); if (prop.notifySignalIndex() == idx) { toSend[QString::fromLatin1(prop.name())] = fromVariant(prop.read(m_job)); } } send(toSend); } static QJsonValue fromVariant(const QVariant &var) { if (var.canConvert()) { return var.toJsonObject(); } else { return QJsonValue::fromVariant(var); } } private: void send(const QJsonObject &object) { const QByteArray data = QJsonDocument(object).toJson(QJsonDocument::Compact) + '\n'; // qDebug() << "sending..." << data; m_socket.write(data); } Purpose::Job* m_job = nullptr; QLocalSocket m_socket; }; int main(int argc, char** argv) { -#warning make QGuiApplication, consider QCoreApplication? +#pragma message("warning: make QGuiApplication, consider QCoreApplication?") QApplication app(argc, argv); QString serverName; { QCommandLineParser parser; parser.addOption(QCommandLineOption(QStringLiteral("server"), QStringLiteral("Named socket to connect to"), QStringLiteral("name"))); parser.addOption(QCommandLineOption(QStringLiteral("pluginPath"), QStringLiteral("Chosen plugin"), QStringLiteral("path"))); parser.addOption(QCommandLineOption(QStringLiteral("pluginType"), QStringLiteral("Plugin type name "), QStringLiteral("path"))); parser.addHelpOption(); parser.process(app); serverName = parser.value(QStringLiteral("server")); pluginType = parser.value(QStringLiteral("pluginType")); const QString path = parser.value(QStringLiteral("pluginPath")); if (path.endsWith(QLatin1String("/metadata.json"))) { QFileInfo fi(path); md = Purpose::createMetaData(path); } else { md = KPluginMetaData(path); Q_ASSERT(md.isValid()); } } Communication c(serverName); return app.exec(); } #include "purposeprocess_main.moc" diff --git a/src/plugins/phabricator/CMakeLists.txt b/src/plugins/phabricator/CMakeLists.txt index eff2e14..e81e301 100644 --- a/src/plugins/phabricator/CMakeLists.txt +++ b/src/plugins/phabricator/CMakeLists.txt @@ -1,35 +1,36 @@ find_program(ARCANIST arc) if(NOT ARCANIST) message(WARNING "The phabricator plugin depends on having the 'arc' script available in the PATH") else() message(STATUS "The 'arc' script was found as ${ARCANIST}") endif() add_definitions(-DTRANSLATION_DOMAIN=\"purpose_phabricator\") add_subdirectory(icons) set(PhabricatorHelper_SRCS phabricatorjobs.cpp) ecm_qt_declare_logging_category(PhabricatorHelper_SRCS HEADER debug.h IDENTIFIER PLUGIN_PHABRICATOR CATEGORY_NAME kdevplatform.plugins.phabricator DEFAULT_SEVERITY Debug) add_library(PhabricatorHelpers ${PhabricatorHelper_SRCS}) +generate_export_header(PhabricatorHelpers EXPORT_FILE_NAME phabricatorhelpers_export.h) target_link_libraries(PhabricatorHelpers KF5::CoreAddons KF5::I18n) add_executable(testphabricator tests/testphabricator.cpp) ecm_mark_nongui_executable(testphabricator) target_link_libraries(testphabricator PhabricatorHelpers Qt5::Core) add_share_plugin(phabricatorplugin phabricatorplugin.cpp) target_link_libraries(phabricatorplugin Qt5::Widgets PhabricatorHelpers) install(TARGETS PhabricatorHelpers ${KF5_INSTALL_TARGETS_DEFAULT_ARGS}) add_library(phabricatorquickplugin quick/phabricatorquickplugin.cpp quick/difflistmodel.cpp quick/phabricatorrc.cpp) target_link_libraries(phabricatorquickplugin Qt5::Qml PhabricatorHelpers) install(TARGETS phabricatorquickplugin DESTINATION ${QML_INSTALL_DIR}/org/kde/purpose/phabricator) install(FILES quick/qmldir DESTINATION ${QML_INSTALL_DIR}/org/kde/purpose/phabricator) diff --git a/src/plugins/phabricator/phabricatorjobs.h b/src/plugins/phabricator/phabricatorjobs.h index 3407517..de21b20 100644 --- a/src/plugins/phabricator/phabricatorjobs.h +++ b/src/plugins/phabricator/phabricatorjobs.h @@ -1,138 +1,140 @@ /* * This file is part of KDevelop * Copyright 2017 René J.V. Bertin * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Library 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. */ #ifndef KDEVPLATFORM_PLUGIN_PHABRICATORJOBS_H #define KDEVPLATFORM_PLUGIN_PHABRICATORJOBS_H +#include "phabricatorhelpers_export.h" + #include #include #include #include #include #include class QNetworkReply; namespace Phabricator { - class Q_DECL_EXPORT DifferentialRevision : public KJob + class PHABRICATORHELPERS_EXPORT DifferentialRevision : public KJob { Q_OBJECT public: DifferentialRevision(const QString& id, QObject* parent) : KJob(parent), m_id(id), m_commit(QString()) { setPercent(0); } QString requestId() const { return m_id; } void setRequestId(const QString& id) { m_id = id; } QString commitRef() const { return m_commit; } void setCommitRef(const QString& commit) { m_commit = commit; } virtual void start() override; virtual QString errorString() const override { return m_errorString; } void setErrorString(const QString& msg); QString scrubbedResult(); QStringList scrubbedResultList(); private Q_SLOTS: virtual void done(int exitCode, QProcess::ExitStatus exitStatus) = 0; protected: virtual bool buildArcCommand(const QString& workDir, const QString& patchFile=QString(), bool doBrowse=false); QProcess m_arcCmd; private: QString m_id; QString m_commit; QString m_errorString; QString m_arcInput; }; - class Q_DECL_EXPORT NewDiffRev : public DifferentialRevision + class PHABRICATORHELPERS_EXPORT NewDiffRev : public DifferentialRevision { Q_OBJECT public: NewDiffRev(const QUrl& patch, const QString& project, bool doBrowse = false, QObject* parent = nullptr); QString diffURI() const { return m_diffURI; } private Q_SLOTS: void done(int exitCode, QProcess::ExitStatus exitStatus) override; private: QUrl m_patch; QString m_project; QString m_diffURI; }; - class Q_DECL_EXPORT UpdateDiffRev : public DifferentialRevision + class PHABRICATORHELPERS_EXPORT UpdateDiffRev : public DifferentialRevision { Q_OBJECT public: UpdateDiffRev(const QUrl& patch, const QString& basedir, const QString& id, const QString& updateComment = QString(), bool doBrowse = false, QObject* parent = nullptr); QString diffURI() const { return m_diffURI; } private Q_SLOTS: void done(int exitCode, QProcess::ExitStatus exitStatus) override; private: QUrl m_patch; QString m_basedir; QString m_diffURI; }; - class Q_DECL_EXPORT DiffRevList : public DifferentialRevision + class PHABRICATORHELPERS_EXPORT DiffRevList : public DifferentialRevision { Q_OBJECT public: DiffRevList(const QString& projectDir, QObject* parent = nullptr); // return the open diff. revisions as a list of pairs QList > reviews() const { return m_reviews; } // return the open diff. revisions as a map of diffDescription->diffID entries QHash reviewMap() const { return m_revMap; } private Q_SLOTS: void done(int exitCode, QProcess::ExitStatus exitStatus) override; protected: bool buildArcCommand(const QString& workDir, const QString& unused=QString(), bool ignored=false) override; private: QList > m_reviews; QHash m_revMap; QString m_projectDir; }; } #endif diff --git a/src/plugins/reviewboard/CMakeLists.txt b/src/plugins/reviewboard/CMakeLists.txt index ff20803..5c85ece 100644 --- a/src/plugins/reviewboard/CMakeLists.txt +++ b/src/plugins/reviewboard/CMakeLists.txt @@ -1,16 +1,17 @@ add_definitions(-DTRANSLATION_DOMAIN=\"purpose_reviewboard\") add_subdirectory(icons) add_library(ReviewboardHelpers reviewboardjobs.cpp debug.cpp) +generate_export_header(ReviewboardHelpers EXPORT_FILE_NAME reviewboardhelpers_export.h) target_link_libraries(ReviewboardHelpers KF5::CoreAddons KF5::I18n Qt5::Network) add_share_plugin(reviewboardplugin reviewboardplugin.cpp) target_link_libraries(reviewboardplugin Qt5::Widgets ReviewboardHelpers) install(TARGETS ReviewboardHelpers ${KF5_INSTALL_TARGETS_DEFAULT_ARGS}) add_library(rbpurposequickplugin quick/reviewboardquickplugin.cpp quick/rbrepositoriesmodel.cpp quick/rbreviewslistmodel.cpp quick/reviewboardrc.cpp) target_link_libraries(rbpurposequickplugin Qt5::Qml ReviewboardHelpers) install(TARGETS rbpurposequickplugin DESTINATION ${QML_INSTALL_DIR}/org/kde/purpose/reviewboard) install(FILES quick/qmldir DESTINATION ${QML_INSTALL_DIR}/org/kde/purpose/reviewboard) diff --git a/src/plugins/reviewboard/reviewboardjobs.h b/src/plugins/reviewboard/reviewboardjobs.h index 10fd980..ac45334 100644 --- a/src/plugins/reviewboard/reviewboardjobs.h +++ b/src/plugins/reviewboard/reviewboardjobs.h @@ -1,169 +1,171 @@ /* * This file is part of KDevelop * Copyright 2010 Aleix Pol Gonzalez * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Library 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. */ #ifndef KDEVPLATFORM_PLUGIN_REVIEWBOARDJOBS_H #define KDEVPLATFORM_PLUGIN_REVIEWBOARDJOBS_H +#include "reviewboardhelpers_export.h" + #include #include #include #include #include class QNetworkReply; namespace ReviewBoard { /** * Http call to the specified service. * Converts returned json data to a QVariant to be used from actual API calls * * @note It is reviewboard-agnostic. */ - class Q_DECL_EXPORT HttpCall : public KJob + class REVIEWBOARDHELPERS_EXPORT HttpCall : public KJob { Q_OBJECT Q_PROPERTY(QVariant result READ result) public: enum Method { Get, Put, Post }; HttpCall(const QUrl& s, const QString& apiPath, const QList >& queryParameters, Method m, const QByteArray& post, bool multipart, QObject* parent); virtual void start() override; QVariant result() const; private Q_SLOTS: void onFinished(); private: //TODO: change to QJsonObject QVariant m_result; QNetworkReply* m_reply; QUrl m_requrl; QByteArray m_post; QNetworkAccessManager m_manager; bool m_multipart; Method m_method; }; - class Q_DECL_EXPORT ReviewRequest : public KJob + class REVIEWBOARDHELPERS_EXPORT ReviewRequest : public KJob { Q_OBJECT public: ReviewRequest(const QUrl& server, const QString& id, QObject* parent) : KJob(parent), m_server(server), m_id(id) {} QString requestId() const { return m_id; } void setRequestId(QString id) { m_id = id; } QUrl server() const { return m_server; } private: QUrl m_server; QString m_id; }; - class Q_DECL_EXPORT NewRequest : public ReviewRequest + class REVIEWBOARDHELPERS_EXPORT NewRequest : public ReviewRequest { Q_OBJECT public: NewRequest(const QUrl& server, const QString& project, QObject* parent = nullptr); virtual void start() override; private Q_SLOTS: void done(); private: HttpCall* m_newreq; QString m_project; }; - class Q_DECL_EXPORT UpdateRequest : public ReviewRequest + class REVIEWBOARDHELPERS_EXPORT UpdateRequest : public ReviewRequest { Q_OBJECT public: UpdateRequest(const QUrl& server, const QString& id, const QVariantMap& newValues, QObject* parent = nullptr); virtual void start() override; private Q_SLOTS: void done(); private: HttpCall* m_req; QString m_project; }; - class Q_DECL_EXPORT SubmitPatchRequest : public ReviewRequest + class REVIEWBOARDHELPERS_EXPORT SubmitPatchRequest : public ReviewRequest { Q_OBJECT public: SubmitPatchRequest(const QUrl &server, const QUrl& patch, const QString& basedir, const QString& id, QObject* parent = nullptr); virtual void start() override; private Q_SLOTS: void done(); private: HttpCall* m_uploadpatch; QUrl m_patch; QString m_basedir; }; - class Q_DECL_EXPORT ProjectsListRequest : public KJob + class REVIEWBOARDHELPERS_EXPORT ProjectsListRequest : public KJob { Q_OBJECT public: ProjectsListRequest(const QUrl &server, QObject* parent = nullptr); virtual void start() override; QVariantList repositories() const; private Q_SLOTS: void requestRepositoryList(int startIndex); void done(KJob* done); private: QUrl m_server; QVariantList m_repositories; }; - class Q_DECL_EXPORT ReviewListRequest : public KJob + class REVIEWBOARDHELPERS_EXPORT ReviewListRequest : public KJob { Q_OBJECT public: ReviewListRequest(const QUrl& server, const QString& user, const QString& reviewStatus, QObject* parent = nullptr); virtual void start() override; QVariantList reviews() const; private Q_SLOTS: void requestReviewList(int startIndex); void done(KJob* done); private: QUrl m_server; QString m_user; QString m_reviewStatus; QVariantList m_reviews; }; QByteArray urlToData(const QUrl&); } #endif diff --git a/src/widgets/CMakeLists.txt b/src/widgets/CMakeLists.txt index 83a40dc..ed13723 100644 --- a/src/widgets/CMakeLists.txt +++ b/src/widgets/CMakeLists.txt @@ -1,36 +1,36 @@ qt5_add_resources(qmlfiles_SRCS purposewidgets-resources.qrc) add_library(KF5PurposeWidgets menu.cpp ${qmlfiles_SRCS}) - +generate_export_header(KF5PurposeWidgets EXPORT_FILE_NAME purposewidgets_export.h BASE_NAME PurposeWidgets) target_link_libraries(KF5PurposeWidgets PUBLIC KF5::Purpose Qt5::Widgets PRIVATE Qt5::Qml KF5::I18n ) set_target_properties(KF5PurposeWidgets PROPERTIES VERSION ${PURPOSE_VERSION_STRING} SOVERSION ${PURPOSE_SOVERSION} EXPORT_NAME PurposeWidgets ) target_include_directories(KF5PurposeWidgets PUBLIC "$" "$" INTERFACE "$" ) install(TARGETS KF5PurposeWidgets EXPORT KDEExperimentalPurposeTargets ${KF5_INSTALL_TARGETS_DEFAULT_ARGS}) add_library(KF5::PurposeWidgets ALIAS KF5PurposeWidgets) ecm_generate_headers(PurposeWidgets_CamelCase_HEADERS HEADER_NAMES Menu REQUIRED_HEADERS PurposeWidgets_HEADERS PREFIX PurposeWidgets ) install(FILES ${PurposeWidgets_CamelCase_HEADERS} DESTINATION ${KDE_INSTALL_INCLUDEDIR_KF5}/purposewidgets/PurposeWidgets/ COMPONENT Devel) install(FILES ${PurposeWidgets_HEADERS} DESTINATION ${KDE_INSTALL_INCLUDEDIR_KF5}/purposewidgets/purposewidgets COMPONENT Devel ) diff --git a/src/widgets/menu.h b/src/widgets/menu.h index 5f8ae47..27d7be0 100644 --- a/src/widgets/menu.h +++ b/src/widgets/menu.h @@ -1,49 +1,50 @@ /* Copyright 2015 Aleix Pol Gonzalez This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library. If not, see . */ #ifndef PURPOSEMENU_H #define PURPOSEMENU_H +#include "purposewidgets_export.h" + #include -#include namespace Purpose { class MenuPrivate; class AlternativesModel; -class PURPOSE_EXPORT Menu : public QMenu +class PURPOSEWIDGETS_EXPORT Menu : public QMenu { Q_OBJECT public: Menu(QWidget* parent = Q_NULLPTR); AlternativesModel* model() const; void reload(); Q_SIGNALS: void finished(const QJsonObject &output, int error, const QString &message); private: Q_DECLARE_PRIVATE(Menu) MenuPrivate *const d_ptr; }; } #endif