diff options
Diffstat (limited to 'ivi-layermanagement-examples/LayerManagerControl/src/input_commands.cpp')
-rw-r--r-- | ivi-layermanagement-examples/LayerManagerControl/src/input_commands.cpp | 68 |
1 files changed, 38 insertions, 30 deletions
diff --git a/ivi-layermanagement-examples/LayerManagerControl/src/input_commands.cpp b/ivi-layermanagement-examples/LayerManagerControl/src/input_commands.cpp index afa0acd..55f2734 100644 --- a/ivi-layermanagement-examples/LayerManagerControl/src/input_commands.cpp +++ b/ivi-layermanagement-examples/LayerManagerControl/src/input_commands.cpp @@ -172,49 +172,57 @@ COMMAND3(53,"get input device <name> capabilities") COMMAND3(54,"set surface <surfaceid> input acceptance to [<namearray>]") //============================================================================= { + ilmErrorTypes callResult = ILM_FAILED; t_ilm_string *array = NULL; t_ilm_uint count = 0; t_ilm_surface surfaceid = input->getUint("surfaceid"); - string str = input->getString("namearray"); + string str; size_t pos; unsigned int i; - // Generate a string array - count = std::count(str.begin(), str.end(), ',') + 1; - array = (t_ilm_string *)calloc(count, sizeof *array); - if (array == NULL) { - cerr << "Failed to allocate memory for string array" << endl; - return; - } + if (input->contains("namearray")) { + // Generate a string array + str = input->getString("namearray"); + count = std::count(str.begin(), str.end(), ',') + 1; + array = (t_ilm_string *)calloc(count, sizeof *array); + if (array == NULL) { + cerr << "Failed to allocate memory for string array" << endl; + return; + } + + i = 0; + while(true) { + pos = str.find(","); + string token = str.substr(0, pos); + array[i] = strdup(token.c_str()); + if (array[i] == NULL) { + cerr << "Failed to duplicate string: " << token << endl; + for (int j = 0; j < i; j++) + free(array[i]); + free(array); + return; + } + str.erase(0, pos + 1); + i++; + if (pos == std::string::npos) + break; + } + + callResult = ilm_setInputAcceptanceOn(surfaceid, count, array); + + for (uint i = 0; i < count; i++) + free(array[i]); + free(array); + } else { + callResult = ilm_setInputAcceptanceOn(surfaceid, 0, NULL); + } - i = 0; - while(true) { - pos = str.find(","); - string token = str.substr(0, pos); - array[i] = strdup(token.c_str()); - if (array[i] == NULL) { - cerr << "Failed to duplicate string: " << token << endl; - for (int j = 0; j < i; j++) - free(array[i]); - free(array); - return; - } - str.erase(0, pos + 1); - i++; - if (pos == std::string::npos) - break; - } - - ilmErrorTypes callResult = ilm_setInputAcceptanceOn(surfaceid, count, array); if (ILM_SUCCESS != callResult) { cout << "LayerManagerService returned: " << ILM_ERROR_STRING(callResult) << endl; cout << "Failed to set acceptance for surface " << surfaceid << endl; } - for (uint i = 0; i < count; i++) - free(array[i]); - free(array); } //============================================================================= |