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..8913ada 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,72 @@ 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 \l pfmRescanBooks + * and \l pfmRescanBooksFull. It is what the browser uses when downloading + * ebook files. + * + * 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 + */ +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 \l pfmRescanBooks + * and \l pfmRescanBooksFull. It is what the browser uses when downloading + * ebook files. + * + * 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 + */ +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 \l pfmRescanBooks + * and \l pfmRescanBooksFull. It is what the browser uses when downloading + * ebook files. + * + * 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 + */ +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