30 #if defined(DUMP_REMOTE_ACTIONS)
31 # define IF_DUMP_ACTION(cmd) cmd
33 # define IF_DUMP_ACTION(cmd)
36 #if defined(DUMP_AUTHORIZATION)
37 # define IF_DUMP_AUTH(cmd) cmd
39 # define IF_DUMP_AUTH(cmd)
44 #define ARB_SERVE_DB_TIMER 50 // ms
45 #define ARB_CHECK_DB_TIMER 200 // ms
52 : remote(application_id),
59 if (gb_main_ != gb_main) {
60 error =
"Attempt to reconfigure database interrupt with changed database";
79 if (client_action && client_action[0]) {
85 if (!error) error = trig_error;
97 "macro recording aborted", macro_error));
101 if (!error) error = clr_error;
114 pid_t pid = getpid();
115 bool authorized = granted && *granted == pid;
136 else if (authAck == pid) {
140 IF_DUMP_AUTH(fprintf(stderr,
"did not acknowledge '%s' with pid %i (pid %i was faster)\n", remote.
authAck(), pid, authAck));
160 if (strcmp(action,
"AWAR_REMOTE_READ") == 0) {
163 IF_DUMP_ACTION(printf(
"remote command 'AWAR_REMOTE_READ' awar='%s' value='%s'\n", tmp_awar, read_value));
168 else if (strcmp(action,
"AWAR_REMOTE_TOUCH") == 0) {
172 IF_DUMP_ACTION(printf(
"remote command 'AWAR_REMOTE_TOUCH' awar='%s'\n", tmp_awar));
177 IF_DUMP_ACTION(printf(
"remote command (write awar) awar='%s' value='%s'\n", tmp_awar, value));
195 IF_DUMP_ACTION(printf(
"remote command (%s) found, running callback\n", action));
204 IF_DUMP_ACTION(printf(
"remote command (%s) is unknown\n", action));
218 if (error) fprintf(stderr,
"Error in check_for_remote_command: %s\n", error);
271 error =
GBS_global_string(
"THIS PROGRAM HAS PROBLEMS TO OPEN INTERCLIENT COMMUNICATION:\n"
273 "(maybe there is already another server running)\n"
274 "You cannot use any EDITOR or other external SOFTWARE from here.\n"
275 "Advice: Close ARB again, open a console, type 'arb_clean' and restart arb.\n"
276 "Caution: Any unsaved data in an eventually running ARB will be lost.\n",
301 return idle_interrupt->
reconfigure(gb_main, application_id);
307 if (!idle_interrupt) {
308 error =
"called to early";
310 else if (idle_interrupt->
gb_main != gb_main) {
311 error =
"detected multiple arb databases";
314 error =
"i am not server";
static unsigned serve_db_interrupt(AW_root *awr, db_interrupt_data *dib)
#define MACRO_TRIGGER_TRACKED
#define ARB_CHECK_DB_TIMER
GB_ERROR GB_set_macro_error(GBDATA *gb_main, const char *curr_error)
long GB_read_int(GBDATA *gbd)
bool GB_is_server(GBDATA *gbd)
const char * granted() const
const char * result() const
static __ATTR__USERESULT GB_ERROR check_for_remote_command(AW_root *aw_root, const db_interrupt_data &dib)
UserActionTracker * get_tracker()
GB_ERROR GB_end_transaction(GBDATA *gbd, GB_ERROR error)
bool GBCMS_accept_calls(GBDATA *gbd, bool wait_extra_time)
GB_ERROR reconfigure(GBDATA *gb_main_, const char *application_id)
const char * authAck() const
NOT4PERL long * GBT_readOrCreate_int(GBDATA *gb_container, const char *fieldpath, long default_value)
const char * GBS_global_string(const char *templat,...)
bool remote_command_handler(AW_root *awr, const db_interrupt_data &dib)
void add_timed_callback(int ms, const TimedCallback &tcb)
AW_cb * search_remote_command(const char *action)
const char * value() const
#define ARB_SERVE_DB_TIMER
const char * authReq() const
GB_ERROR GB_push_transaction(GBDATA *gbd)
GB_ERROR reconfigure_dbserver(const char *application_id, GBDATA *gb_main)
static db_interrupt_data * idle_interrupt
GB_ERROR serve_db_while_GUI_is_blocked(GBDATA *gb_main)
static void error(const char *msg)
char * GBT_readOrCreate_string(GBDATA *gb_container, const char *fieldpath, const char *default_value)
void GB_set_remote_action(GBDATA *gbd, bool in_action)
GBDATA * GB_searchOrCreate_int(GBDATA *gb_container, const char *fieldpath, long default_value)
char * read_as_string() const
db_interrupt_data(GBDATA *gb_main_, const char *application_id)
long GB_read_clients(GBDATA *gbd)
GB_ERROR GBCMS_open(const char *path, long timeout, GBDATA *gb_main)
AW_awar * awar_no_error(const char *awar)
end timer stuff
AW_awar * awar(const char *awar)
GB_ERROR GB_pop_transaction(GBDATA *gbd)
GB_ERROR startup_dbserver(AW_root *aw_root, const char *application_id, GBDATA *gb_main)
GB_ERROR GB_write_int(GBDATA *gbd, long i)
const char * appID() const
bool got_macro_ability(AW_root *aw_root)
GB_ERROR write_as_string(const char *aw_string)
const char * awar() const
#define IF_DUMP_AUTH(cmd)
#define IF_DUMP_ACTION(cmd)
GB_ERROR GBT_write_string(GBDATA *gb_container, const char *fieldpath, const char *content)
GB_ERROR handle_tracked_client_action(char *&tracked)
#define __ATTR__USERESULT
static unsigned check_db_interrupt(AW_root *awr, db_interrupt_data *dib)
void aw_message(const char *msg)
GB_ERROR GB_clear_macro_error(GBDATA *gb_main)
GB_ERROR stop_recording()
GB_ERROR GB_get_macro_error(GBDATA *gb_main)
const char * action() const
void aw_message_if(GB_ERROR error)