Skip to content

Commit

Permalink
Add N3FSSyncManager support
Browse files Browse the repository at this point in the history
  • Loading branch information
shermp committed Apr 19, 2024
1 parent 5d90055 commit 75c12ed
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/cli/ndb_cli.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
30 changes: 30 additions & 0 deletions src/ndb/NDBDbus.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand Down
13 changes: 13 additions & 0 deletions src/ndb/NDBDbus.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand All @@ -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
Expand Down

0 comments on commit 75c12ed

Please sign in to comment.