27 freedup(
id, application_id);
65 set_tracking(recording);
76 if (
is_tracking()) error =
"Already recording macro";
85 if (stop_error) fprintf(stderr,
"Error while stopping macro recording: %s\n", stop_error);
94 error =
"Not recording macro";
97 error = recording->
stop();
105 if (ann_error) fprintf(stderr,
"Error in announce_recording: %s\n", ann_error);
123 if (gb_client != gb_control) {
125 clientNames.
put(client_id);
143 for (
size_t i = 0; i<clientNames.
size() && !
error; ++i) {
150 if (error) error =
GBS_global_string(
"error in clearMacroExecutionAuthorization: %s", error);
155 RootCallback done_cb;
161 : done_cb(execution_done_cb),
168 void destroy() { head = next;
delete this; }
172 static void add(
const RootCallback& execution_done_cb) {
new ExecutingMacro(execution_done_cb); }
182 if (head) head->destroy();
190 fprintf(stderr,
"macro_terminated called\n");
192 if (allMacrosTerminated) {
193 fprintf(stderr,
"macro_terminated: allMacrosTerminated\n");
202 aw_message(
"Warning: macro terminated (somewhere in the middle)");
205 if (clr_error) fprintf(stderr,
"Warning: failed to clear macro error (Reason: %s)\n", clr_error);
226 error = ta.
close(error);
252 if (tracked && tracked[0]) {
253 char *saveptr =
NULp;
254 const char *app_id = strtok_r(tracked,
"*", &saveptr);
255 const char *cmd = strtok_r(
NULp,
"*", &saveptr);
256 char *rest = strtok_r(
NULp,
"", &saveptr);
259 if (strcmp(cmd,
"AWAR") == 0) {
260 const char *awar_name = strtok_r(rest,
"*", &saveptr);
261 const char *content = strtok_r(
NULp,
"", &saveptr);
263 if (!content) content =
"";
267 else if (strcmp(cmd,
"ACTION") == 0) {
275 fprintf(stderr,
"Warning: tracked action '%s' from client '%s' (dropped because not recording)\n", cmd, app_id);
299 void ClientActionTracker::bind_callbacks(
bool install) {
347 void ClientActionTracker::send_client_action(
const char *action) {
364 else if (prev_track[0]) error =
GBS_global_string(
"Cant send_client_action: have pending client action (%s)", prev_track);
377 bool consumed =
false;
381 while (!consumed && !error) {
384 if ((count%25) == 0) {
385 fprintf(stderr,
"[Waiting for macro recorder to consume action tracked by %s]\n",
get_application_id());
392 else consumed = !track[0];
403 void ClientActionTracker::ungrant_client_and_confirm_quit_action() {
415 pid_t pid = getpid();
418 if (pid == granted_pid) {
427 if (error) fprintf(stderr,
"Error in ungrant_client_and_confirm_quit_action: %s\n", error);
464 if (existing && existing->
reconfigure(client_id, gb_main)) {
477 if (tracker) tracker->
release();
GB_ERROR GB_begin_transaction(GBDATA *gbd)
void track_action(const char *action_id)
GB_ERROR start_recording(const char *file, const char *stop_action_name, bool expand_existing)
#define MACRO_TRIGGER_TRACKED
void put(const char *elem)
GB_ERROR GB_set_macro_error(GBDATA *gb_main, const char *curr_error)
long GB_read_int(GBDATA *gbd)
GBDATA * GB_child(GBDATA *father)
static void macro_terminated(GBDATA *gb_terminated, GB_CB_TYPE cb_type)
bool GB_is_server(GBDATA *gbd)
const char * granted() const
GB_ERROR GB_write_string(GBDATA *gbd, const char *s)
GBDATA * GB_searchOrCreate_string(GBDATA *gb_container, const char *fieldpath, const char *default_value)
GB_ERROR GB_add_callback(GBDATA *gbd, GB_CB_TYPE type, const DatabaseCallback &dbcb)
void track_awar_change(AW_awar *awar)
GB_ERROR GBT_macro_execute(const char *macro_name, bool loop_marked, bool run_async)
GB_ERROR GB_end_transaction(GBDATA *gbd, GB_ERROR error)
GB_ERROR execute(const char *macroFile, bool loop_marked, const RootCallback &execution_done_cb)
static UserActionTracker * make_macro_recording_tracker(const char *client_id, GBDATA *gb_main)
const char * authAck() const
#define MACRO_TRIGGER_TERMINATED
void track_awar_change(AW_awar *awar) OVERRIDE
const char * GBS_global_string(const char *templat,...)
void track_awar_change(AW_awar *awar) OVERRIDE
UserActionTracker * need_macro_ability()
void track_action(const char *action_id) OVERRIDE
void GBK_terminatef(const char *templat,...)
void shutdown_macro_recording(AW_root *aw_root)
const char * authReq() const
void setUserActionTracker(UserActionTracker *user_tracker)
GB_ERROR reconfigure_dbserver(const char *application_id, GBDATA *gb_main)
GB_ERROR GB_await_error()
static AW_root * SINGLETON
void add_planned_interruption(const char *displayed_text)
void track_action(const char *action_id) OVERRIDE
GB_CSTR GB_read_key_pntr(GBDATA *gbd)
void set_tracking_according_to(GBDATA *gb_recording)
static void add(const RootCallback &execution_done_cb)
bool got_macro_ability(AW_root *aw_root)
static void error(const char *msg)
GBDATA * GB_get_root(GBDATA *gbd)
GBDATA * GB_searchOrCreate_int(GBDATA *gb_container, const char *fieldpath, long default_value)
char * read_as_string() const
static __ATTR__USERESULT GB_ERROR clearMacroExecutionAuthorization(GBDATA *gb_main)
bool reconfigure(const char *application_id, GBDATA *gb_main)
static void record_state_changed_cb(GBDATA *gb_recording, ClientActionTracker *cat)
void write_awar_change(const char *app_id, const char *awar_name, const char *content)
static GB_ERROR announce_recording(GBDATA *gb_main, int record)
GB_ERROR startup_dbserver(AW_root *aw_root, const char *application_id, GBDATA *gb_main)
static void getKnownMacroClients(ConstStrArray &clientNames, GBDATA *gb_main)
#define MACRO_TRIGGER_CONTAINER
static char * cat(char *toBuf, const char *s1, const char *s2)
GB_ERROR GB_write_int(GBDATA *gbd, long i)
void set_recording(bool recording)
void write_planned_interruption(const char *displayed_text)
GB_ERROR configure_macro_recording(AW_root *aw_root, const char *client_id, GBDATA *gb_main)
#define IF_ASSERTION_USED(x)
GB_ERROR close(GB_ERROR error)
const char * get_application_id() const
GB_ERROR handle_tracked_client_action(char *&tracked)
#define __ATTR__USERESULT
#define MACRO_TRIGGER_RECORDING
void GB_remove_callback(GBDATA *gbd, GB_CB_TYPE type, const DatabaseCallback &dbcb)
BoundActionTracker * get_active_macro_recording_tracker(AW_root *aw_root)
void write_action(const char *app_id, const char *action_name)
void aw_message(const char *msg)
const char * recAuth() const
GB_ERROR GB_clear_macro_error(GBDATA *gb_main)
GB_ERROR stop_recording()
__ATTR__USERESULT GB_ERROR setIntEntryToZero(GBDATA *gb_main, const char *entryPath)
GB_ERROR has_error() const
GBDATA * GB_nextChild(GBDATA *child)
void warn_unrecordable(const char *what)
GB_transaction ta(gb_var)
GB_CSTR GB_read_char_pntr(GBDATA *gbd)
GBDATA * GB_search(GBDATA *gbd, const char *fieldpath, GB_TYPES create)
GB_ERROR GB_get_macro_error(GBDATA *gb_main)
void aw_message_if(GB_ERROR error)