summaryrefslogtreecommitdiff
path: root/ivi-layermanagement-examples
diff options
context:
space:
mode:
authorEmre Ucan <eucan@de.adit-jv.com>2015-05-18 11:29:14 +0200
committerNobuhiko Tanibata <nobuhiko_tanibata@xddp.denso.co.jp>2015-06-15 16:23:33 +0900
commit8a0fdf769f46bdde45cf6bbb1ded1a1d7f4615f7 (patch)
tree58dfdfe9690fbfbb9a337eda12590d47d7795afe /ivi-layermanagement-examples
parentd5503dd37fb0e0918492b10552fef27d9098b985 (diff)
downloadwayland-ivi-extension-8a0fdf769f46bdde45cf6bbb1ded1a1d7f4615f7.tar.gz
LayerManagerControl: do not send empty string at get input device capabilities
send a NULL pointer instead Signed-off-by: Emre Ucan <eucan@de.adit-jv.com>
Diffstat (limited to 'ivi-layermanagement-examples')
-rw-r--r--ivi-layermanagement-examples/LayerManagerControl/src/input_commands.cpp68
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);
}
//=============================================================================