1
0

Implemented action nickel_misc:rescan_books_full

This commit is contained in:
Patrick Gaskin
2020-04-23 05:54:06 -04:00
parent 197a401e66
commit a20551d82a
2 changed files with 11 additions and 3 deletions

View File

@@ -44,6 +44,7 @@
# misc - one of:
# force_usb_connection - forces a usb connection dialog to be shown
# rescan_books - forces nickel to rescan books (TODO)
# rescan_books_full - forcez a full usb connect/disconnect cycle (TODO)
# cmd_spawn - the command line to pass to /bin/sh -c (started in /)
# cmd_output - the timeout in milliseconds (0 < t < 10000), a colon, then the command line to pass to /bin/sh -c (started in /)
#

View File

@@ -11,6 +11,7 @@
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include "action_cc.h"
#include "util.h"
@@ -127,11 +128,16 @@ extern "C" int nm_action_nickelextras(const char *arg, char **err_out) {
extern "C" int nm_action_nickelmisc(const char *arg, char **err_out) {
#define NM_ERR_RET 1
if (!strcmp(arg, "rescan_books")) {
if (!strcmp(arg, "rescan_books_full")) {
PlugWorkflowManager *(*PlugWorkflowManager_sharedInstance)();
reinterpret_cast<void*&>(PlugWorkflowManager_sharedInstance) = dlsym(RTLD_DEFAULT, "_ZN19PlugWorkflowManager14sharedInstanceEv");
NM_ASSERT(PlugWorkflowManager_sharedInstance, "could not dlsym PlugWorkflowManager::sharedInstance");
// this is what is called by PlugWorkflowManager::plugged after confirmation
void (*PlugWorkflowManager_onCancelAndConnect)(PlugWorkflowManager*);
reinterpret_cast<void*&>(PlugWorkflowManager_onCancelAndConnect) = dlsym(RTLD_DEFAULT, "_ZN19PlugWorkflowManager18onCancelAndConnectEv");
NM_ASSERT(PlugWorkflowManager_onCancelAndConnect, "could not dlsym PlugWorkflowManager::onCancelAndConnect");
void (*PlugWorkflowManager_unplugged)(PlugWorkflowManager*);
reinterpret_cast<void*&>(PlugWorkflowManager_unplugged) = dlsym(RTLD_DEFAULT, "_ZN19PlugWorkflowManager9unpluggedEv");
NM_ASSERT(PlugWorkflowManager_unplugged, "could not dlsym PlugWorkflowManager::unplugged");
@@ -139,10 +145,11 @@ extern "C" int nm_action_nickelmisc(const char *arg, char **err_out) {
PlugWorkflowManager *wf = PlugWorkflowManager_sharedInstance();
NM_ASSERT(wf, "could not get shared PlugWorkflowManager pointer");
PlugWorkflowManager_onCancelAndConnect(wf);
sleep(1);
PlugWorkflowManager_unplugged(wf);
// TODO: finish this up
NM_RETURN_ERR("not completely implemented yet");
} else if (!strcmp(arg, "force_usb_connection")) {
// we could call libnickel directly, but I prefer not to
FILE *nhs;
NM_ASSERT((nhs = fopen("/tmp/nickel-hardware-status", "w")), "could not open nickel hardware status pipe: %s", strerror(errno));