+\r
+\r
+//\r
+\r
+bool ntf_to_injector(const char* data, const int len) {\r
+ type_length length = 0;\r
+ type_group group = 0;\r
+ type_action action = 0;\r
+\r
+ const int catsize = 10;\r
+ char cat[catsize + 1];\r
+ memset(cat, 0, catsize + 1);\r
+\r
+ read_val_str(data, cat, catsize);\r
+ read_val_short(data + catsize, &length);\r
+ read_val_char(data + catsize + 2, &group);\r
+ read_val_char(data + catsize + 2 + 1, &action);\r
+\r
+\r
+ const char* ijdata = (data + catsize + 2 + 1 + 1);\r
+\r
+ char *encoded_ijdata = NULL;\r
+ LOG("<< header cat = %s, length = %d, action=%d, group=%d", cat, length,\r
+ action, group);\r
+\r
+ if(!strcmp(cat, "telephony")) {\r
+ base64_encode(ijdata, length, &encoded_ijdata);\r
+ }\r
+\r
+ QDict* obj_header = qdict_new();\r
+ make_header(obj_header, length, group, action);\r
+\r
+ QDict* objData = qdict_new();\r
+ qobject_incref(QOBJECT(obj_header));\r
+\r
+ qdict_put(objData, "cat", qstring_from_str(cat));\r
+ qdict_put(objData, "header", obj_header);\r
+ if(!strcmp(cat, "telephony")) {\r
+ qdict_put(objData, "ijdata", qstring_from_str(encoded_ijdata));\r
+ } else {\r
+ qdict_put(objData, "ijdata", qstring_from_str(ijdata));\r
+ }\r
+\r
+ QDict* objMsg = qdict_new();\r
+ qobject_incref(QOBJECT(objData));\r
+\r
+ qdict_put(objMsg, "type", qstring_from_str("injector"));\r
+ qdict_put(objMsg, "result", qstring_from_str("success"));\r
+ qdict_put(objMsg, "data", objData);\r
+\r
+ QString *json;\r
+ json = qobject_to_json(QOBJECT(objMsg));\r
+\r
+ assert(json != NULL);\r
+\r
+ qstring_append_chr(json, '\n');\r
+ const char* snddata = qstring_get_str(json);\r
+\r
+ LOG("<< json str = %s", snddata);\r
+\r
+ send_to_all_client(snddata, strlen(snddata));\r
+\r
+ QDECREF(json);\r
+\r
+ QDECREF(obj_header);\r
+ QDECREF(objData);\r
+ QDECREF(objMsg);\r
+\r
+ return true;\r
+}\r
+\r
+bool send_start_ans(int host_keyboard_onff)\r
+{\r
+ ECS__Master master = ECS__MASTER__INIT;\r
+ ECS__StartAns ans = ECS__START_ANS__INIT;\r
+\r
+ ans.host_keyboard_onoff = host_keyboard_onff;\r
+\r
+ master.start_ans = &ans;\r
+\r
+ return send_to_ecp(&master);\r
+}\r
+\r
+bool send_injector_ntf(const char* data, const int len)\r
+{\r
+ type_length length = 0;\r
+ type_group group = 0;\r
+ type_action action = 0;\r
+\r
+ const int catsize = 10;\r
+ char cat[catsize + 1];\r
+ memset(cat, 0, catsize + 1);\r
+\r
+ read_val_str(data, cat, catsize);\r
+ read_val_short(data + catsize, &length);\r
+ read_val_char(data + catsize + 2, &group);\r
+ read_val_char(data + catsize + 2 + 1, &action);\r
+\r
+\r
+ const char* ijdata = (data + catsize + 2 + 1 + 1);\r
+\r
+ LOG("<< header cat = %s, length = %d, action=%d, group=%d", cat, length,action, group);\r
+\r
+ ECS__Master master = ECS__MASTER__INIT;\r
+ ECS__InjectorNtf ntf = ECS__INJECTOR_NTF__INIT;\r
+\r
+ ntf.category = (char*) g_malloc(catsize + 1);\r
+ strncpy(ntf.category, cat, 10);\r
+\r
+\r
+ ntf.length = length;\r
+ ntf.group = group;\r
+ ntf.action = action;\r
+\r
+ if (length > 0)\r
+ {\r
+ ntf.has_data = 1;\r
+\r
+ ntf.data.data = g_malloc(length);\r
+ ntf.data.len = length;\r
+ memcpy(ntf.data.data, ijdata, length);\r
+ }\r
+\r
+ master.type = ECS__MASTER__TYPE__INJECTOR_NTF;\r
+ master.injector_ntf = &ntf;\r
+\r
+ send_to_ecp(&master);\r
+\r
+ if (ntf.data.data && ntf.data.len > 0)\r
+ {\r
+ g_free(ntf.data.data);\r
+ }\r
+\r
+ if (ntf.category)\r
+ g_free(ntf.category);\r
+\r
+ return true;\r
+}\r