-
Notifications
You must be signed in to change notification settings - Fork 1
Better check for PoGo running #19
Copy link
Copy link
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Sometimes PoGo stops working even though it's opened and the frontmost app, so a better approach would be to check if PoGo is actually doing something. Those functions check the last log time of GC and then checks if it's more than 5 minutes in the past. We can further tweak that time frame in the future.
#include <asl.h>
#include <time.h>
int pogo_work_state(time_t log_time)
{
time_t current_time = time(NULL);
return (difftime(current_time, log_time) > 300);
}
time_t get_last_log_time()
{
aslclient client = asl_open(NULL, "com.gocheats.jb", 0);
aslmsg query = asl_new(ASL_TYPE_QUERY);
asl_set_query(query, ASL_KEY_SENDER, "com.gocheats.jb", ASL_QUERY_OP_EQUAL);
aslresponse response = asl_search(client, query);
aslmsg msg;
time_t last_time = 0;
while ((msg = aslresponse_next(response)) != NULL)
{
const char *time_str = asl_get(msg, ASL_KEY_TIME);
time_t time_val = (time_t)strtoll(time_str, NULL, 10);
if (time_val > last_time)
{
last_time = time_val;
}
}
aslresponse_free(response);
asl_free(query);
asl_close(client);
return last_time;
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working