Renamed subsystem to action
This commit is contained in:
4
.gitignore
vendored
4
.gitignore
vendored
@@ -8,9 +8,9 @@
|
||||
|
||||
/src/failsafe.o
|
||||
/src/init.o
|
||||
/src/subsys_c.o
|
||||
/src/config.o
|
||||
/src/dlhook.o
|
||||
/src/action_c.o
|
||||
|
||||
/src/menu.o
|
||||
/src/subsys_cc.o
|
||||
/src/action_cc.o
|
||||
|
||||
2
Makefile
2
Makefile
@@ -72,7 +72,7 @@ override GENERATED += KoboRoot KoboRoot.tgz
|
||||
src/libnmi.so: override CFLAGS += $(PTHREAD_CFLAGS) -fPIC
|
||||
src/libnmi.so: override CXXFLAGS += $(PTHREAD_CFLAGS) $(QT5CORE_CFLAGS) $(QT5WIDGETS_CFLAGS) -fPIC
|
||||
src/libnmi.so: override LDFLAGS += $(PTHREAD_LIBS) $(QT5CORE_LIBS) $(QT5WIDGETS_LIBS) -ldl -Wl,-soname,libnmi.so
|
||||
src/libnmi.so: src/qtplugin.o src/init.o src/config.o src/dlhook.o src/failsafe.o src/menu.o src/subsys_c.o src/subsys_cc.o
|
||||
src/libnmi.so: src/qtplugin.o src/init.o src/config.o src/dlhook.o src/failsafe.o src/menu.o src/action_c.o src/action_cc.o
|
||||
|
||||
override LIBRARIES += src/libnmi.so
|
||||
override MOCS += src/qtplugin.moc
|
||||
|
||||
34
res/doc
34
res/doc
@@ -11,25 +11,25 @@
|
||||
# They can be named anything, and should consist of multiple lines either
|
||||
# starting with # for a comment, or in the the following format:
|
||||
#
|
||||
# menu_item:<location>:<label>:<subsystem>:<arg>
|
||||
# menu_item:<location>:<label>:<action>:<arg>
|
||||
# Adds a menu item (spaces around fields are ignored).
|
||||
#
|
||||
# <location> the menu to add the item to, one of:
|
||||
# main - the menu in the top-left corner of the home screen
|
||||
# reader - the overflow menu in the reader
|
||||
# <label> the label to show on the menu item (must not contain :)
|
||||
# <subsystem> the type of action to run, one of:
|
||||
# dbg_syslog - writes a message to syslog (for testing)
|
||||
# dbg_error - always returns an error (for testing)
|
||||
# kfmon - triggers a kfmon action (coming soon)
|
||||
# nickel_setting - toggles a boolean setting (coming soon)
|
||||
# <arg> the argument passed to the subsystem:
|
||||
# dbg_syslog - the text to write
|
||||
# dbg_error - the error message
|
||||
# kfmon - TODO
|
||||
# nickel_setting - one of:
|
||||
# invert - toggles FeatureSettings.InvertScreen (all versions)
|
||||
# screenshots - toggles FeatureSettings.Screenshots (all versions)
|
||||
# <location> the menu to add the item to, one of:
|
||||
# main - the menu in the top-left corner of the home screen
|
||||
# reader - the overflow menu in the reader
|
||||
# <label> the label to show on the menu item (must not contain :)
|
||||
# <action> the type of action to run, one of:
|
||||
# dbg_syslog - writes a message to syslog (for testing)
|
||||
# dbg_error - always returns an error (for testing)
|
||||
# kfmon - triggers a kfmon action (coming soon)
|
||||
# nickel_setting - toggles a boolean setting (coming soon)
|
||||
# <arg> the argument passed to the action:
|
||||
# dbg_syslog - the text to write
|
||||
# dbg_error - the error message
|
||||
# kfmon - TODO
|
||||
# nickel_setting - one of:
|
||||
# invert - toggles FeatureSettings.InvertScreen (all versions)
|
||||
# screenshots - toggles FeatureSettings.Screenshots (all versions)
|
||||
#
|
||||
# For example, you might have a configuration file in KOBOeReader/.adds/nmi/mystuff like:
|
||||
#
|
||||
|
||||
@@ -1,22 +1,22 @@
|
||||
#define _GNU_SOURCE // asprintf
|
||||
|
||||
#include "subsys_c.h"
|
||||
#include "action_c.h"
|
||||
#include "util.h"
|
||||
|
||||
int nmi_subsys_dbgsyslog(const char *arg, char **err_out) {
|
||||
int nmi_action_dbgsyslog(const char *arg, char **err_out) {
|
||||
#define NMI_ERR_RET 1
|
||||
NMI_LOG("dbgsyslog: %s", arg);
|
||||
NMI_RETURN_OK(0);
|
||||
#undef NMI_ERR_RET
|
||||
}
|
||||
|
||||
int nmi_subsys_dbgerror(const char *arg, char **err_out) {
|
||||
int nmi_action_dbgerror(const char *arg, char **err_out) {
|
||||
#define NMI_ERR_RET 1
|
||||
NMI_RETURN_ERR("%s", arg);
|
||||
#undef NMI_ERR_RET
|
||||
}
|
||||
|
||||
int nmi_subsys_kfmon(const char *arg, char **err_out) {
|
||||
int nmi_action_kfmon(const char *arg, char **err_out) {
|
||||
#define NMI_ERR_RET 1
|
||||
NMI_RETURN_ERR("not implemented yet (arg=%s)", arg); // TODO
|
||||
#undef NMI_ERR_RET
|
||||
14
src/action_c.h
Normal file
14
src/action_c.h
Normal file
@@ -0,0 +1,14 @@
|
||||
#ifndef NMI_ACTION_C_H
|
||||
#define NMI_ACTION_C_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
int nmi_action_dbgsyslog(const char *arg, char **err_out);
|
||||
int nmi_action_dbgerror(const char *arg, char **err_out);
|
||||
int nmi_action_kfmon(const char *arg, char **err_out);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
@@ -4,13 +4,13 @@
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "subsys_cc.h"
|
||||
#include "action_cc.h"
|
||||
#include "util.h"
|
||||
|
||||
typedef void Device;
|
||||
typedef void Settings;
|
||||
|
||||
extern "C" int nmi_subsys_nickelsetting(const char *arg, char **err_out) {
|
||||
extern "C" int nmi_action_nickelsetting(const char *arg, char **err_out) {
|
||||
#define NMI_ERR_RET 1
|
||||
|
||||
Device *(*Device_getCurrentDevice)();
|
||||
12
src/action_cc.h
Normal file
12
src/action_cc.h
Normal file
@@ -0,0 +1,12 @@
|
||||
#ifndef NMI_ACTION_CC_H
|
||||
#define NMI_ACTION_CC_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
int nmi_action_nickelsetting(const char *arg, char **err_out);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
@@ -5,11 +5,11 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "action_c.h"
|
||||
#include "action_cc.h"
|
||||
#include "config.h"
|
||||
#include "menu.h"
|
||||
#include "util.h"
|
||||
#include "subsys_c.h"
|
||||
#include "subsys_cc.h"
|
||||
|
||||
typedef enum {
|
||||
NMI_CONFIG_TYPE_MENU_ITEM = 1,
|
||||
|
||||
@@ -11,7 +11,7 @@ typedef struct nmi_config_t nmi_config_t;
|
||||
|
||||
// nmi_config_parse parses the configuration files in /mnt/onboard/.adds/nmi.
|
||||
// An error is returned if there are syntax errors, file access errors, or
|
||||
// invalid subsystem names for menu_item.
|
||||
// invalid action names for menu_item.
|
||||
nmi_config_t *nmi_config_parse(char **err_out);
|
||||
|
||||
// nmi_config_get_menu gets a malloc'd array of pointers to the menu items
|
||||
|
||||
10
src/init.c
10
src/init.c
@@ -7,10 +7,10 @@
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "action_c.h"
|
||||
#include "config.h"
|
||||
#include "failsafe.h"
|
||||
#include "menu.h"
|
||||
#include "subsys_c.h"
|
||||
#include "util.h"
|
||||
|
||||
__attribute__((constructor)) void nmi_init() {
|
||||
@@ -48,10 +48,10 @@ __attribute__((constructor)) void nmi_init() {
|
||||
items = calloc(items_n, sizeof(nmi_menu_item_t*));
|
||||
*items = calloc(items_n, sizeof(nmi_menu_item_t));
|
||||
|
||||
items[0]->loc = NMI_MENU_LOCATION_MAIN_MENU;
|
||||
items[0]->lbl = strdup("Config Error");
|
||||
items[0]->arg = strdup(err);
|
||||
items[0]->execute = nmi_subsys_dbgerror;
|
||||
items[0]->loc = NMI_MENU_LOCATION_MAIN_MENU;
|
||||
items[0]->lbl = strdup("Config Error");
|
||||
items[0]->arg = strdup(err);
|
||||
items[0]->act = nmi_action_dbgerror;
|
||||
|
||||
free(err);
|
||||
} else if (!(items = nmi_config_get_menu(cfg, &items_n))) {
|
||||
|
||||
@@ -89,7 +89,7 @@ extern "C" MenuTextItem* _nmi_menu_hook(void* _this, QMenu* menu, QString const&
|
||||
QObject::connect(action, &QAction::triggered, std::function<void(bool)>([it](bool checked){
|
||||
NMI_LOG("Item '%s' pressed...", it->lbl);
|
||||
char *err;
|
||||
if (it->execute(it->arg, &err) && err) {
|
||||
if (it->act(it->arg, &err) && err) {
|
||||
NMI_LOG("Got error %s, displaying...", err);
|
||||
ConfirmationDialogFactory_showOKDialog(QString::fromUtf8(it->lbl), QString::fromUtf8(err));
|
||||
free(err);
|
||||
|
||||
@@ -15,7 +15,7 @@ typedef struct {
|
||||
nmi_menu_location_t loc;
|
||||
char *lbl;
|
||||
char *arg;
|
||||
int (*execute)(const char *arg, char **out_err); // can block, must return 0 on success, nonzero with out_err set to the malloc'd error message on error
|
||||
int (*act)(const char *arg, char **out_err); // can block, must return 0 on success, nonzero with out_err set to the malloc'd error message on error
|
||||
} nmi_menu_item_t;
|
||||
|
||||
// nmi_menu_hook hooks a dlopen'd libnickel handle to add the specified menus,
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
#ifndef NMI_SUBSYS_C_H
|
||||
#define NMI_SUBSYS_C_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
int nmi_subsys_dbgsyslog(const char *arg, char **err_out);
|
||||
int nmi_subsys_dbgerror(const char *arg, char **err_out);
|
||||
int nmi_subsys_kfmon(const char *arg, char **err_out);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
@@ -1,12 +0,0 @@
|
||||
#ifndef NMI_SUBSYS_CC_H
|
||||
#define NMI_SUBSYS_CC_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
int nmi_subsys_nickelsetting(const char *arg, char **err_out);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
Reference in New Issue
Block a user