tray
This commit is contained in:
+70
-25
@@ -38,8 +38,6 @@
|
||||
#define sleep_ms(ms) Sleep(static_cast<DWORD>(ms))
|
||||
#endif
|
||||
|
||||
//#define DEBUG
|
||||
|
||||
#ifdef __linux
|
||||
static int sleep_ms(long msec)
|
||||
{
|
||||
@@ -232,7 +230,12 @@ bool runRktWebview(Handle_t *handler)
|
||||
#define WAIT_ON_EVENT_MS (2 * 1000)
|
||||
#define ALIVE_MESSAGE_INTERVAL_S 5 // Should be smaller than 10 seconds
|
||||
#define MAX_WAIT_RESULT (2 * 1000) // Maximum wait in milliseconds for a result per time
|
||||
|
||||
#ifdef DEBUG_RKT_WEBVIEW
|
||||
#define MAX_ALIVE_ACK_TIME (300 * 1000)
|
||||
#else
|
||||
#define MAX_ALIVE_ACK_TIME (10 * 1000)
|
||||
#endif
|
||||
|
||||
void rkt_evt_guard(void)
|
||||
{
|
||||
@@ -396,7 +399,7 @@ void rkt_webview_init(const char *from)
|
||||
INFO1("rkt_webview_init called from %s\n", from);
|
||||
|
||||
char buf[1024];
|
||||
#ifdef DEBUG
|
||||
#ifdef DEBUG_RKT_WEBVIEW
|
||||
sprintf(buf, "rktwebview-dbg");
|
||||
#else
|
||||
#ifdef _WIN32
|
||||
@@ -426,7 +429,7 @@ void rkt_webview_init(const char *from)
|
||||
handler->alive_ack_queue = new ShmQueue(handler->shm, ALIVE_ACK_SLOT, true);
|
||||
|
||||
// Start rktwebview_prg application with the right information
|
||||
#ifndef DEBUG
|
||||
#ifndef DEBUG_RKT_WEBVIEW
|
||||
handler->rkt_webview_prg_started = runRktWebview(handler);
|
||||
if (!handler->rkt_webview_prg_started) { handler->valid = false; }
|
||||
#endif
|
||||
@@ -551,28 +554,70 @@ void rkt_webview_close(rktwebview_t wv)
|
||||
handler->command_queue->enqueue(CMD_CLOSE_WV, j.dump());
|
||||
}
|
||||
|
||||
#define CMDRES4(cmd, wv, key, val, key2, val2, key3, val3, key4, val4) \
|
||||
RKT_WEBVIEW_INIT; \
|
||||
FAIL_HANDLE \
|
||||
JSON j; \
|
||||
j["wv"] = wv; \
|
||||
j[key] = val; \
|
||||
j[key2] = val2; \
|
||||
j[key3] = val3; \
|
||||
j[key4] = val4; \
|
||||
handler->command_queue->enqueue(cmd, j.dump()); \
|
||||
int result; \
|
||||
std::string json_result; \
|
||||
while (!handler->command_result_queue->dequeue(result, json_result, MAX_WAIT_RESULT)) { \
|
||||
if (handler->alive_error) { \
|
||||
return result_t::failed; \
|
||||
} \
|
||||
} \
|
||||
result_t r = static_cast<result_t>(result); \
|
||||
static inline result_t DO_CMDRES(int cmd, rktwebview_t wv, const JSON &j)
|
||||
{
|
||||
RKT_WEBVIEW_INIT;
|
||||
FAIL_HANDLE
|
||||
std::string json_str = j.dump();
|
||||
handler->command_queue->enqueue(cmd, json_str);
|
||||
int result;
|
||||
std::string json_result;
|
||||
while (!handler->command_result_queue->dequeue(result, json_result, MAX_WAIT_RESULT)) {
|
||||
if (handler->alive_error) {
|
||||
return result_t::failed;
|
||||
}
|
||||
}
|
||||
result_t r = static_cast<result_t>(result);
|
||||
return r;
|
||||
}
|
||||
|
||||
static inline result_t CMDRES4(int cmd, rktwebview_t wv,
|
||||
const char *key, const char *val,
|
||||
const char *key2, const char *val2,
|
||||
const char *key3, const char *val3,
|
||||
const char *key4, const char *val4)
|
||||
{
|
||||
JSON j;
|
||||
j["wv"] = wv;
|
||||
j[key] = val;
|
||||
j[key2] = val2;
|
||||
j[key3] = val3;
|
||||
j[key4] = val4;
|
||||
return DO_CMDRES(cmd, wv, j);
|
||||
}
|
||||
|
||||
static inline result_t CMDRES4(int cmd, rktwebview_t wv,
|
||||
const char *key, int val,
|
||||
const char *key2, int val2,
|
||||
const char *key3, const char *val3,
|
||||
const char *key4, const char *val4)
|
||||
{
|
||||
JSON j;
|
||||
j["wv"] = wv;
|
||||
j[key] = val;
|
||||
j[key2] = val2;
|
||||
j[key3] = val3;
|
||||
j[key4] = val4;
|
||||
return DO_CMDRES(cmd, wv, j);
|
||||
}
|
||||
|
||||
static inline result_t CMDRES4(int cmd, rktwebview_t wv,
|
||||
const char *key, const char *val,
|
||||
const char *key2, const char *val2,
|
||||
const char *key3, const char *val3,
|
||||
const char *key4, int val4)
|
||||
{
|
||||
JSON j;
|
||||
j["wv"] = wv;
|
||||
j[key] = val;
|
||||
j[key2] = val2;
|
||||
j[key3] = val3;
|
||||
j[key4] = val4;
|
||||
return DO_CMDRES(cmd, wv, j);
|
||||
}
|
||||
|
||||
#define CMDRES3(cmd, wv, key, val, key2, val2, key3, val3) \
|
||||
CMDRES4(cmd, wv, key, val, key2, val2, key3, val3, "nil3", "none")
|
||||
return CMDRES4(cmd, wv, key, val, key2, val2, key3, val3, "nil3", "none");
|
||||
|
||||
#define CMDRES2(cmd, wv, key, val, key2, val2) \
|
||||
CMDRES3(cmd, wv, key, val, key2, val2, "nil2", "none")
|
||||
@@ -585,7 +630,7 @@ void rkt_webview_close(rktwebview_t wv)
|
||||
|
||||
result_t rkt_webview_set_url(rktwebview_t wv, const char *url)
|
||||
{
|
||||
CMDRES(CMD_SET_URL, wv, "url", url)
|
||||
CMDRES(CMD_SET_URL, wv, "url", url);
|
||||
}
|
||||
|
||||
result_t rkt_webview_set_html(rktwebview_t wv, const char *html)
|
||||
@@ -764,7 +809,7 @@ rkt_data_t *rkt_webview_version()
|
||||
|
||||
result_t rkt_webview_message_box(rktwebview_t w, const char *title, const char *message, const char *submessage, rkt_messagetype_t type)
|
||||
{
|
||||
CMDRES4(CMD_MSG_BOX, w, "title", title, "message", message, "submessage", submessage, "type", static_cast<int>(type))
|
||||
return CMDRES4(CMD_MSG_BOX, w, "title", title, "message", message, "submessage", submessage, "type", static_cast<int>(type));
|
||||
}
|
||||
|
||||
int rkt_webview_events_waiting()
|
||||
|
||||
Reference in New Issue
Block a user