From 44f1acb300ca929ae85fb2b8dab021b216a0fb86 Mon Sep 17 00:00:00 2001 From: jcli Date: Sun, 5 Mar 2017 13:26:16 -0800 Subject: [PATCH] jira SDK-5322: DIAL client that supports 2.1 and higher SHOULD include a clientDialVer query parameter while querying application status --- client/DialServer.cpp | 4 ++++ client/DialServer.h | 2 ++ server/dial_server.c | 19 +++++++++++++++++-- 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/client/DialServer.cpp b/client/DialServer.cpp index 54c2a3f..d6592e7 100644 --- a/client/DialServer.cpp +++ b/client/DialServer.cpp @@ -67,6 +67,10 @@ int DialServer::sendCommand( CURL *curl; CURLcode res = CURLE_OK; struct curl_slist *slist = NULL; + + // since we are Dial Version 2.1, added query paramter to indicate Dial Version + url += "?clientDialVer="; + url += CLIENT_VERSION; if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { diff --git a/client/DialServer.h b/client/DialServer.h index 2937630..5ded0f3 100644 --- a/client/DialServer.h +++ b/client/DialServer.h @@ -41,6 +41,8 @@ using namespace std; +#define CLIENT_VERSION "2.1" + class DialServer { public: diff --git a/server/dial_server.c b/server/dial_server.c index 6101678..c6c889f 100644 --- a/server/dial_server.c +++ b/server/dial_server.c @@ -183,6 +183,13 @@ static void handle_app_status(struct mg_connection *conn, int canStop = 0; DIALServer *ds = request_info->user_data; + // determin client version + char *clientVersionStr = parse_param(request_info->query_string, "clientDialVer"); + double clientVersion = 0.0; + if (clientVersionStr){ + clientVersion = atof(clientVersionStr); + } + ds_lock(ds); app = *find_app(ds, app_name); if (!app) { @@ -217,8 +224,16 @@ static void handle_app_status(struct mg_connection *conn, app->state = app->callbacks.status_cb(ds, app_name, app->run_id, &canStop, app->callback_data); + + DIALStatus localState = app->state; + + // overwrite app->state if cilent version < 2.1 + if (clientVersion < 2.09 && localState==kDIALStatusHide){ + localState=kDIALStatusStopped; + } + char dial_state_str[20]; - switch(app->state){ + switch(localState){ case kDIALStatusHide: strcpy (dial_state_str, "hidden"); break; @@ -250,7 +265,7 @@ static void handle_app_status(struct mg_connection *conn, app->name, canStop ? "true" : "false", dial_state_str, - app->state == kDIALStatusStopped ? + localState == kDIALStatusStopped ? "" : " \r\n", dial_data); ds_unlock(ds);