From 75c12edbefe594453193fd52fed3c1ca74756a5e Mon Sep 17 00:00:00 2001 From: shermp <14854761+shermp@users.noreply.github.com> Date: Sat, 24 Jun 2023 13:22:51 +1200 Subject: [PATCH 1/4] Add N3FSSyncManager support --- src/cli/ndb_cli.cc | 3 +++ src/ndb/NDBDbus.cc | 30 ++++++++++++++++++++++++++++++ src/ndb/NDBDbus.h | 13 +++++++++++++ 3 files changed, 46 insertions(+) diff --git a/src/cli/ndb_cli.cc b/src/cli/ndb_cli.cc index f67f9a6..37373d9 100644 --- a/src/cli/ndb_cli.cc +++ b/src/cli/ndb_cli.cc @@ -170,6 +170,9 @@ void NDBCli::connectSignals() { NDBCLI_SIG_CONNECT(dlgConfirmTextInput, handleSignalParam1); NDBCLI_SIG_CONNECT(pfmAboutToConnect, handleSignalParam0); NDBCLI_SIG_CONNECT(pfmDoneProcessing, handleSignalParam0); + NDBCLI_SIG_CONNECT(fssFinished, handleSignalParam0); + NDBCLI_SIG_CONNECT(fssGotNumFilesToProcess, handleSignalParam1); + NDBCLI_SIG_CONNECT(fssParseProgress, handleSignalParam1); NDBCLI_SIG_CONNECT(wmLinkQualityForConnectedNetwork, handleSignalParam1); NDBCLI_SIG_CONNECT(wmMacAddressAvailable, handleSignalParam1); NDBCLI_SIG_CONNECT(wmNetworkConnected, handleSignalParam0); diff --git a/src/ndb/NDBDbus.cc b/src/ndb/NDBDbus.cc index ba4e5d7..4163c0c 100644 --- a/src/ndb/NDBDbus.cc +++ b/src/ndb/NDBDbus.cc @@ -96,6 +96,9 @@ NDBDbus::NDBDbus(QObject* parent) : QObject(parent), QDBusContext() { // Resolve the rest of the Nickel symbols up-front // PlugWorkFlowManager NDB_RESOLVE_SYMBOL("_ZN19PlugWorkflowManager14sharedInstanceEv", nh_symoutptr(nSym.PlugWorkflowManager_sharedInstance)); + // N3FSSyncManager + NDB_RESOLVE_SYMBOL("_ZN15N3FSSyncManager14sharedInstanceEv", nh_symoutptr(nSym.N3FSSyncManager__sharedInstance)); + NDB_RESOLVE_SYMBOL("_ZN15N3FSSyncManager4syncERK11QStringList", nh_symoutptr(nSym.N3FSSyncManager__sync)); // WirelessManager NDB_RESOLVE_SYMBOL("_ZN15WirelessManager14sharedInstanceEv", nh_symoutptr(nSym.WirelesManager_sharedInstance)); // Toast @@ -713,6 +716,33 @@ void NDBDbus::pfmRescanBooksFull() { return ndbNickelMisc("rescan_books_full"); } +void NDBDbus::n3fssSyncOnboard() { + QStringList path("/mnt/onboard"); + return n3fssSync(&path); +} + +void NDBDbus::n3fssSyncSD() { + QStringList path("/mnt/sd"); + return n3fssSync(&path); +} + +void NDBDbus::n3fssSyncBoth() { + QStringList paths = QStringList() << "/mnt/onboard" << "/mnt/sd"; + return n3fssSync(&paths); +} + +void NDBDbus::n3fssSync(QStringList* paths) { + NDB_DBUS_USB_ASSERT((void) 0); + NDB_DBUS_ASSERT((void) 0, QDBusError::InternalError, + nSym.N3FSSyncManager__sharedInstance && nSym.N3FSSyncManager__sync, "no N3FSSyncManager symbols"); + N3FSSyncManager* n3fssm = nSym.N3FSSyncManager__sharedInstance(); + NDB_DBUS_ASSERT((void) 0, QDBusError::InternalError, n3fssm, "could not get N3FSSyncManager::sharedInstance()"); + QObject::connect(n3fssm, SIGNAL(finished()), this, SIGNAL(fssFinished()), Qt::UniqueConnection); + QObject::connect(n3fssm, SIGNAL(gotNumFilesToProcess(int)), this, SIGNAL(fssGotNumFilesToProcess(int)), Qt::UniqueConnection); + QObject::connect(n3fssm, SIGNAL(parseProgress(int)), this, SIGNAL(fssParseProgress(int)), Qt::UniqueConnection); + return nSym.N3FSSyncManager__sync(n3fssm, paths); +} + void NDBDbus::ndbNickelMisc(const char *action) { nm_action_result_t *res = nm_action_nickel_misc(action); if (!res) { diff --git a/src/ndb/NDBDbus.h b/src/ndb/NDBDbus.h index 02762a3..0394795 100644 --- a/src/ndb/NDBDbus.h +++ b/src/ndb/NDBDbus.h @@ -19,6 +19,8 @@ typedef void MainWindowController; typedef QDialog ConfirmationDialog; typedef QWidget N3Dialog; typedef void Device; +typedef QObject FSSyncManager; +typedef FSSyncManager N3FSSyncManager; #ifndef NDB_DBUS_IFACE_NAME #define NDB_DBUS_IFACE_NAME "com.github.shermp.nickeldbus" @@ -48,6 +50,10 @@ class NDBDbus : public QObject, protected QDBusContext { // PlugworkFlowManager signals void pfmDoneProcessing(); void pfmAboutToConnect(); + // FSSyncManager signals + void fssFinished(); + void fssGotNumFilesToProcess(int num); + void fssParseProgress(int progress); // WirelessManager signals void wmTryingToConnect(); void wmNetworkConnected(); @@ -94,6 +100,10 @@ class NDBDbus : public QObject, protected QDBusContext { // PlugWorkFlowManager void pfmRescanBooks(); void pfmRescanBooksFull(); + // N3FSSyncManager + void n3fssSyncOnboard(); + void n3fssSyncSD(); + void n3fssSyncBoth(); // Wireless methods (WirelessFlowManager) void wfmConnectWireless(); void wfmConnectWirelessSilently(); @@ -138,6 +148,8 @@ class NDBDbus : public QObject, protected QDBusContext { Device *(*Device__getCurrentDevice)(); QByteArray (*Device__userAgent)(Device*); QSize (*Image__sizeForType)(Device*, QString const&); + N3FSSyncManager* (*N3FSSyncManager__sharedInstance)(); + void (*N3FSSyncManager__sync)(N3FSSyncManager* _this, QStringList* paths); } nSym; QTimer *viewTimer; bool ndbInUSBMS(); @@ -152,6 +164,7 @@ class NDBDbus : public QObject, protected QDBusContext { void rvConnectSignals(QWidget* rv); void dlgConfirmLineEditFull(QString const& title, QString const& acceptText, QString const& rejectText, bool isPassword, QString const& setText); enum Result dlgConfirmCreatePreset(QString const& title, QString const& body, QString const& acceptText, QString const& rejectText); + void n3fssSync(QStringList* paths); }; } // namespace NDB From 5c8cabee1eb24207ea2169eca7081328af712545 Mon Sep 17 00:00:00 2001 From: shermp <14854761+shermp@users.noreply.github.com> Date: Thu, 18 Apr 2024 19:14:28 +1200 Subject: [PATCH 2/4] Add fssync documentation --- src/ndb/NDBDbus.cc | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/src/ndb/NDBDbus.cc b/src/ndb/NDBDbus.cc index 4163c0c..b9f63e9 100644 --- a/src/ndb/NDBDbus.cc +++ b/src/ndb/NDBDbus.cc @@ -716,16 +716,49 @@ void NDBDbus::pfmRescanBooksFull() { return ndbNickelMisc("rescan_books_full"); } +/*! + * \brief Begins a filesystem sync to add/remove content from onboard storage + * + * This is a more targeted option to add new content compared to \a pfmRescanBooks + * and \a pfmRescanBooksFull. It is what the browser uses when downloading + * ebook files. + * + * Emits \a fssGotNumFilesToProcess signal to specify the number of files + * to be added, \a fssParseProgress to specify the current progress, and the + * \a fssFinished signal is emitted when complete. + */ void NDBDbus::n3fssSyncOnboard() { QStringList path("/mnt/onboard"); return n3fssSync(&path); } +/*! + * \brief Begins a filesystem sync to add/remove content from sd storage + * + * This is a more targeted option to add new content compared to \a pfmRescanBooks + * and \a pfmRescanBooksFull. It is what the browser uses when downloading + * ebook files. + * + * Emits \a fssGotNumFilesToProcess signal to specify the number of files + * to be added, \a fssParseProgress to specify the current progress, and the + * \a fssFinished signal is emitted when complete. + */ void NDBDbus::n3fssSyncSD() { QStringList path("/mnt/sd"); return n3fssSync(&path); } +/*! + * \brief Begins a filesystem sync to add/remove content from onboard and sd storage + * + * This is a more targeted option to add new content compared to \a pfmRescanBooks + * and \a pfmRescanBooksFull. It is what the browser uses when downloading + * ebook files. + * + * Emits \a fssGotNumFilesToProcess signal to specify the number of files + * to be added, \a fssParseProgress to specify the current progress, and the + * \a fssFinished signal is emitted when complete. + */ void NDBDbus::n3fssSyncBoth() { QStringList paths = QStringList() << "/mnt/onboard" << "/mnt/sd"; return n3fssSync(&paths); From f8de6d3f31948f58aa42414c39e30ec9618e98e8 Mon Sep 17 00:00:00 2001 From: shermp <14854761+shermp@users.noreply.github.com> Date: Thu, 18 Apr 2024 19:26:07 +1200 Subject: [PATCH 3/4] Add \since 0.3.0 to fssync docs --- src/ndb/NDBDbus.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/ndb/NDBDbus.cc b/src/ndb/NDBDbus.cc index b9f63e9..13f28cf 100644 --- a/src/ndb/NDBDbus.cc +++ b/src/ndb/NDBDbus.cc @@ -726,6 +726,8 @@ void NDBDbus::pfmRescanBooksFull() { * Emits \a fssGotNumFilesToProcess signal to specify the number of files * to be added, \a fssParseProgress to specify the current progress, and the * \a fssFinished signal is emitted when complete. + * + * \since 0.3.0 */ void NDBDbus::n3fssSyncOnboard() { QStringList path("/mnt/onboard"); @@ -742,6 +744,8 @@ void NDBDbus::n3fssSyncOnboard() { * Emits \a fssGotNumFilesToProcess signal to specify the number of files * to be added, \a fssParseProgress to specify the current progress, and the * \a fssFinished signal is emitted when complete. + * + * \since 0.3.0 */ void NDBDbus::n3fssSyncSD() { QStringList path("/mnt/sd"); @@ -758,6 +762,8 @@ void NDBDbus::n3fssSyncSD() { * Emits \a fssGotNumFilesToProcess signal to specify the number of files * to be added, \a fssParseProgress to specify the current progress, and the * \a fssFinished signal is emitted when complete. + * + * \since 0.3.0 */ void NDBDbus::n3fssSyncBoth() { QStringList paths = QStringList() << "/mnt/onboard" << "/mnt/sd"; From 1b1cd356d5824614a279dd14669bd798bfc0abc6 Mon Sep 17 00:00:00 2001 From: shermp <14854761+shermp@users.noreply.github.com> Date: Thu, 18 Apr 2024 20:52:56 +1200 Subject: [PATCH 4/4] Use \l instead of \a for fssync docs --- src/ndb/NDBDbus.cc | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/ndb/NDBDbus.cc b/src/ndb/NDBDbus.cc index 13f28cf..8913ada 100644 --- a/src/ndb/NDBDbus.cc +++ b/src/ndb/NDBDbus.cc @@ -719,13 +719,13 @@ void NDBDbus::pfmRescanBooksFull() { /*! * \brief Begins a filesystem sync to add/remove content from onboard storage * - * This is a more targeted option to add new content compared to \a pfmRescanBooks - * and \a pfmRescanBooksFull. It is what the browser uses when downloading + * This is a more targeted option to add new content compared to \l pfmRescanBooks + * and \l pfmRescanBooksFull. It is what the browser uses when downloading * ebook files. * - * Emits \a fssGotNumFilesToProcess signal to specify the number of files - * to be added, \a fssParseProgress to specify the current progress, and the - * \a fssFinished signal is emitted when complete. + * Emits \l fssGotNumFilesToProcess signal to specify the number of files + * to be added, \l fssParseProgress to specify the current progress, and the + * \l fssFinished signal is emitted when complete. * * \since 0.3.0 */ @@ -737,13 +737,13 @@ void NDBDbus::n3fssSyncOnboard() { /*! * \brief Begins a filesystem sync to add/remove content from sd storage * - * This is a more targeted option to add new content compared to \a pfmRescanBooks - * and \a pfmRescanBooksFull. It is what the browser uses when downloading + * This is a more targeted option to add new content compared to \l pfmRescanBooks + * and \l pfmRescanBooksFull. It is what the browser uses when downloading * ebook files. * - * Emits \a fssGotNumFilesToProcess signal to specify the number of files - * to be added, \a fssParseProgress to specify the current progress, and the - * \a fssFinished signal is emitted when complete. + * Emits \l fssGotNumFilesToProcess signal to specify the number of files + * to be added, \l fssParseProgress to specify the current progress, and the + * \l fssFinished signal is emitted when complete. * * \since 0.3.0 */ @@ -755,13 +755,13 @@ void NDBDbus::n3fssSyncSD() { /*! * \brief Begins a filesystem sync to add/remove content from onboard and sd storage * - * This is a more targeted option to add new content compared to \a pfmRescanBooks - * and \a pfmRescanBooksFull. It is what the browser uses when downloading + * This is a more targeted option to add new content compared to \l pfmRescanBooks + * and \l pfmRescanBooksFull. It is what the browser uses when downloading * ebook files. * - * Emits \a fssGotNumFilesToProcess signal to specify the number of files - * to be added, \a fssParseProgress to specify the current progress, and the - * \a fssFinished signal is emitted when complete. + * Emits \l fssGotNumFilesToProcess signal to specify the number of files + * to be added, \l fssParseProgress to specify the current progress, and the + * \l fssFinished signal is emitted when complete. * * \since 0.3.0 */