mmi_workflow_instance_h m_instance{nullptr};
};
-static Program g_program;
-
-void process_file(std::string filename)
+void process_file(Program *program, std::string filename)
{
+ if (nullptr == program) {
+ std::cout << "Parameter 'program' is NULL" << std::endl;
+ return;
+ }
+
std::ifstream file(filename);
if (!file.is_open()) {
std::cout << "Failed to open file: " << filename << std::endl;
if (command.compare("sleep") == 0) {
sleep(std::stoi(parameters.at(0)));
} else if (command.compare("create") == 0) {
- g_program.create_instance(std::stoi(parameters.at(0)));
+ program->create_instance(std::stoi(parameters.at(0)));
} else if (command.compare("create_from_script") == 0) {
- g_program.create_instance_from_script();
+ program->create_instance_from_script();
} else if (command.compare("create_from_file") == 0) {
- g_program.create_instance_from_file(parameters.at(0));
+ program->create_instance_from_file(parameters.at(0));
} else if (command.compare("destroy") == 0) {
- g_program.destroy_instance();
+ program->destroy_instance();
} else if (command.compare("set_attribute") == 0) {
- g_program.set_attribute(
+ program->set_attribute(
parameters.at(0), parameters.at(1), parameters.at(2));
} else if (command.compare("feed_data") == 0) {
if (parameters.size() == 5) {
- g_program.feed_data(
+ program->feed_data(
parameters.at(0), parameters.at(1), parameters.at(2), parameters.at(3), parameters.at(4));
} else {
- g_program.feed_data(
+ program->feed_data(
parameters.at(0), parameters.at(1), parameters.at(2), parameters.at(3));
}
} else if (command.compare("emit_signal") == 0) {
- g_program.emit_signal(parameters.at(0));
+ program->emit_signal(parameters.at(0));
} else if (command.compare("activate") == 0) {
- g_program.activate_instance();
+ program->activate_instance();
} else if (command.compare("deactivate") == 0) {
- g_program.deactivate_instance();
+ program->deactivate_instance();
}
} catch (std::out_of_range &e) {
std::cout << e.what() << std::endl;
int main(int argc, char *argv[])
{
- argh::parser cmdl(argv);
+ Program program;
+ try {
+ argh::parser cmdl(argv);
- std::string filename;
- if (cmdl("file") >> filename) {
- process_file(filename);
- return 0;
- }
+ std::string filename;
+ if (cmdl("file") >> filename) {
+ process_file(&program, filename);
+ return 0;
+ }
- try {
cli::SetColor();
cli::CliEcoreSession *ref = nullptr;
},
"Start ecore main loop");
- rootMenu->Insert("create", [](std::ostream& out, int type) {
- g_program.create_instance(type);
+ rootMenu->Insert("create", [&program](std::ostream& out, int type) {
+ program.create_instance(type);
},
"Creates a new workflow instance");
- rootMenu->Insert("create_from_script", [](std::ostream& out) {
- g_program.create_instance_from_script();
+ rootMenu->Insert("create_from_script", [&program](std::ostream& out) {
+ program.create_instance_from_script();
},
"Creates a new workflow instance from the predefined script data");
- rootMenu->Insert("create_from_file", [](std::ostream& out, std::string path) {
- g_program.create_instance_from_file(path);
+ rootMenu->Insert("create_from_file", [&program](std::ostream& out, std::string path) {
+ program.create_instance_from_file(path);
},
"Creates a new workflow instance from a script file");
- rootMenu->Insert("destroy", [](std::ostream& out) {
- g_program.destroy_instance();
+ rootMenu->Insert("destroy", [&program](std::ostream& out) {
+ program.destroy_instance();
},
"Destroys the current workflow instance");
- rootMenu->Insert("set_attribute", [](std::ostream& out, std::string name, std::string type, std::string value) {
- g_program.set_attribute(name, type, value);
+ rootMenu->Insert("set_attribute", [&program](std::ostream& out, std::string name, std::string type, std::string value) {
+ program.set_attribute(name, type, value);
},
"Set attributes for the current workflow instance");
- rootMenu->Insert("feed_data", [](std::ostream& out, std::string node_name, std::string port_name, std::string type, std::string value) {
- g_program.feed_data(node_name, port_name, type, value);
+ rootMenu->Insert("feed_data", [&program](std::ostream& out, std::string node_name, std::string port_name, std::string type, std::string value) {
+ program.feed_data(node_name, port_name, type, value);
},
"Set attributes for the current workflow instance");
- rootMenu->Insert("feed_data", [](std::ostream& out, std::string node_name, std::string port_name, std::string type, std::string value1, std::string value2) {
- g_program.feed_data(node_name, port_name, type, value1, value2);
+ rootMenu->Insert("feed_data", [&program](std::ostream& out, std::string node_name, std::string port_name, std::string type, std::string value1, std::string value2) {
+ program.feed_data(node_name, port_name, type, value1, value2);
},
"Set attributes for the current workflow instance");
- rootMenu->Insert("emit_signal", [](std::ostream& out, std::string signal_name) {
- g_program.emit_signal(signal_name);
+ rootMenu->Insert("emit_signal", [&program](std::ostream& out, std::string signal_name) {
+ program.emit_signal(signal_name);
},
"Set attributes for the current workflow instance");
- rootMenu->Insert("activate", [](std::ostream& out) {
- g_program.activate_instance();
+ rootMenu->Insert("activate", [&program](std::ostream& out) {
+ program.activate_instance();
},
"Activates the current workflow instance");
- rootMenu->Insert("deactivate", [](std::ostream& out) {
- g_program.deactivate_instance();
+ rootMenu->Insert("deactivate", [&program](std::ostream& out) {
+ program.deactivate_instance();
},
"Deactivates the current workflow instance");
#ifdef USE_VOICE_TOUCH_TV
- rootMenu->Insert("title_selection", [](std::ostream& out, std::string value) {
- g_program.title_selection(value);
+ rootMenu->Insert("title_selection", [&program](std::ostream& out, std::string value) {
+ program.title_selection(value);
},
"Find and execute the selected title on the screen");
- rootMenu->Insert("ordinal_selection", [](std::ostream& out, int value) {
- g_program.ordinal_selection(value);
+ rootMenu->Insert("ordinal_selection", [&program](std::ostream& out, int value) {
+ program.ordinal_selection(value);
},
"Select an item with the input value at the focused point on the screen");
- rootMenu->Insert("navigation", [](std::ostream& out, std::string direction, int repeat) {
- g_program.navigation(direction, repeat);
+ rootMenu->Insert("navigation", [&program](std::ostream& out, std::string direction, int repeat) {
+ program.navigation(direction, repeat);
},
"Move in the input direction as many times as specified");
#endif
communication_channel_factory = std::make_shared<mmi::communication::CommunicationChannelManagerFactory>();
- mmi::Manager manager(communication_channel_factory, plugin_module_proxy_factory);
+ mmi::Manager manager(std::move(communication_channel_factory), std::move(plugin_module_proxy_factory));
manager.initialize();
Client* ClientManager::add_client(std::string sender) {
LOGI("Add client(%s)\n", sender.c_str());
- Client *client = new Client(sender);
+ Client *client = new(std::nothrow) Client(sender);
if (!client) {
LOGE("Failed to allocate memory for client !\n");
return nullptr;
static int node_signal_received_cb(mmi_node_instance_h instance, mmi_signal_h signal, void *user_data);
static int port_input_data_received_cb(mmi_port_instance_h instance, mmi_data_h data, void *user_data);
- mmi_node_callbacks_s default_node_callbacks;
- mmi_port_callbacks_s default_port_callbacks;
+ mmi_node_callbacks_s default_node_callbacks{nullptr, };
+ mmi_port_callbacks_s default_port_callbacks{nullptr, };
};
class TestWorkflowPluginModuleWakeuplessCommand : TestWorkflowPluginModule {
TestNodePluginModuleScreenAnalyzer();
static int node_activated_cb(mmi_node_instance_h instance, void *user_data);
- mmi_node_callbacks_s m_node_callbacks;
- mmi_port_callbacks_s m_screen_info_port_callbacks;
+ mmi_node_callbacks_s m_node_callbacks{nullptr, };
+ mmi_port_callbacks_s m_screen_info_port_callbacks{nullptr, };
};
class TestNodePluginModuleMatch : public TestNodePluginModule {
static int text_port_input_data_received_cb(mmi_port_instance_h instance, mmi_data_h data, void *user_data);
- mmi_node_callbacks_s m_node_callbacks;
- mmi_port_callbacks_s m_text_port_callbacks;
+ mmi_node_callbacks_s m_node_callbacks{nullptr, };
+ mmi_port_callbacks_s m_text_port_callbacks{nullptr, };
};
class TestNodePluginModuleKeyEvent : public TestNodePluginModule {
static int key_event_port_input_data_received_cb(mmi_port_instance_h instance, mmi_data_h data, void *user_data);
- mmi_node_callbacks_s m_node_callbacks;
- mmi_port_callbacks_s m_key_event_port_callbacks;
+ mmi_node_callbacks_s m_node_callbacks{nullptr, };
+ mmi_port_callbacks_s m_key_event_port_callbacks{nullptr, };
};
class PluginModuleProxySelfContainerTest : public IPluginModuleProxy {
if (type == MMI_DATA_TYPE_ARRAY || type == MMI_DATA_TYPE_STRUCT) {
size_t current_size = sizeof(mmi_data_type_e) + sizeof(size_t);
unsigned char *buffer = reinterpret_cast<unsigned char *>(malloc(current_size));
+ if (nullptr == buffer) {
+ // LCOV_EXCL_START
+ _E("[ERROR] Failed to allocate memory");
+ return MMI_ERROR_OUT_OF_MEMORY;
+ // LCOV_EXCL_STOP
+ }
size_t count = get_count_of_elements(data);
unsigned char *current = buffer;
memcpy(buf, current, datalen);
auto value = reinterpret_cast<mmi_data_h>(malloc(sizeof(mmi_data_s)));
+ if (nullptr == value) {
+// LCOV_EXCL_START
+ free(buf);
+ _E("[ERROR] Failed to allocate memory");
+ return MMI_ERROR_OUT_OF_MEMORY;
+// LCOV_EXCL_STOP
+ }
value->type = type;
value->datalen = datalen;
value->data = buf;
}
auto cloned_value = reinterpret_cast<mmi_primitive_value_s *>(malloc(sizeof(mmi_primitive_value_s)));
+ if (nullptr == cloned_value) {
+// LCOV_EXCL_START
+ _E("[ERROR] Fail to allocate memory for a new primitive value");
+ return MMI_ERROR_OUT_OF_MEMORY;
+// LCOV_EXCL_STOP
+ }
+
cloned_value->type = handle->type;
cloned_value->datalen = handle->datalen;
cloned_value->data = calloc(1, handle->datalen);
if (type == MMI_PRIMITIVE_VALUE_TYPE_ARRAY) {
size_t current_size = sizeof(mmi_primitive_value_type_e) + sizeof(size_t);
unsigned char *buffer = reinterpret_cast<unsigned char *>(malloc(current_size));
+ if (nullptr == buffer) {
+// LCOV_EXCL_START
+ _E("[ERROR] Fail to allocate memory for buffer");
+ return MMI_ERROR_OUT_OF_MEMORY;
+// LCOV_EXCL_STOP
+ }
size_t count = get_array_count(handle);
unsigned char *current = buffer;
memcpy(current, &type, sizeof(mmi_primitive_value_type_e));
memcpy(data, current, datalen);
auto value = reinterpret_cast<mmi_primitive_value_s *>(malloc(sizeof(mmi_primitive_value_s)));
+ if (nullptr == value) {
+// LCOV_EXCL_START
+ _E("[ERROR] Fail to allocate memory for a new primitive value");
+ free(data);
+ return MMI_ERROR_OUT_OF_MEMORY;
+// LCOV_EXCL_STOP
+ }
value->type = type;
value->datalen = datalen;
value->data = data;
struct mmi_workflow_s {
mmi_standard_workflow_type_e type;
- mmi_workflow_node_info_s *node_infos;
- size_t node_info_count;
- mmi_workflow_link_info_s *link_infos;
- size_t link_info_count;
- mmi_workflow_attribute_assignment_info_s *attribute_assignment_infos;
- size_t attribute_assignment_info_count;
- mmi_workflow_attribute_default_value_info_s *attribute_default_value_infos;
- size_t attribute_default_value_info_count;
- mmi_workflow_signal_assignment_info_s *signal_assignment_infos;
- size_t signal_assignment_info_count;
- mmi_workflow_output_assignment_info_s *output_assignment_infos;
- size_t output_assignment_info_count;
+ mmi_workflow_node_info_s *node_infos{nullptr};
+ size_t node_info_count{0};
+ mmi_workflow_link_info_s *link_infos{nullptr};
+ size_t link_info_count{0};
+ mmi_workflow_attribute_assignment_info_s *attribute_assignment_infos{nullptr};
+ size_t attribute_assignment_info_count{0};
+ mmi_workflow_attribute_default_value_info_s *attribute_default_value_infos{nullptr};
+ size_t attribute_default_value_info_count{0};
+ mmi_workflow_signal_assignment_info_s *signal_assignment_infos{nullptr};
+ size_t signal_assignment_info_count{0};
+ mmi_workflow_output_assignment_info_s *output_assignment_infos{nullptr};
+ size_t output_assignment_info_count{0};
};
/**
mmi_workflow_s *workflow_s = static_cast<mmi_workflow_s *>(workflow);
memcpy(cloned_s, workflow_s, sizeof(mmi_workflow_s));
- cloned_s->node_infos = new(std::nothrow) mmi_workflow_node_info_s[workflow_s->node_info_count];
+ if (workflow_s->node_info_count > 0) {
+ cloned_s->node_infos = new(std::nothrow) mmi_workflow_node_info_s[workflow_s->node_info_count];
+ if (nullptr == cloned_s->node_infos) {
+ // LCOV_EXCL_START
+ LOGE("[ERROR] new mmi_workflow_node_info_s failed");
+ mmi_workflow_destroy(workflow_s);
+ return MMI_ERROR_OUT_OF_MEMORY;
+ // LCOV_EXCL_STOP
+ }
+ }
+
memcpy(cloned_s->node_infos, workflow_s->node_infos, sizeof(mmi_workflow_node_info_s) * workflow_s->node_info_count);
for (size_t i = 0; i < workflow_s->node_info_count; i++) {
mmi_node_clone(workflow_s->node_infos[i].node, &(cloned_s->node_infos[i].node));
if (workflow_s->link_info_count > 0) {
cloned_s->link_infos = new(std::nothrow) mmi_workflow_link_info_s[workflow_s->link_info_count];
+ if (nullptr == cloned_s->link_infos) {
+ // LCOV_EXCL_START
+ LOGE("[ERROR] new mmi_workflow_link_info_s failed");
+ mmi_workflow_destroy(workflow_s);
+ return MMI_ERROR_OUT_OF_MEMORY;
+ // LCOV_EXCL_STOP
+ }
memcpy(cloned_s->link_infos, workflow_s->link_infos, sizeof(mmi_workflow_link_info_s) * workflow_s->link_info_count);
}
if (workflow_s->attribute_assignment_info_count > 0) {
cloned_s->attribute_assignment_infos = new(std::nothrow) mmi_workflow_attribute_assignment_info_s[workflow_s->attribute_assignment_info_count];
+ if (nullptr == cloned_s->attribute_assignment_infos) {
+ // LCOV_EXCL_START
+ LOGE("[ERROR] new mmi_workflow_attribute_assignment_info_s failed");
+ mmi_workflow_destroy(workflow_s);
+ return MMI_ERROR_OUT_OF_MEMORY;
+ // LCOV_EXCL_STOP
+ }
memcpy(cloned_s->attribute_assignment_infos, workflow_s->attribute_assignment_infos,
sizeof(mmi_workflow_attribute_assignment_info_s) * workflow_s->attribute_assignment_info_count);
}
if (workflow_s->attribute_default_value_info_count > 0) {
- cloned_s->attribute_default_value_infos = new(std::nothrow) mmi_workflow_attribute_default_value_info_s[workflow_s->attribute_default_value_info_count];
+ cloned_s->attribute_default_value_infos =
+ new(std::nothrow) mmi_workflow_attribute_default_value_info_s[workflow_s->attribute_default_value_info_count];
+ if (nullptr == cloned_s->attribute_default_value_infos) {
+ // LCOV_EXCL_START
+ LOGE("[ERROR] new mmi_workflow_attribute_default_value_info_s failed");
+ mmi_workflow_destroy(workflow_s);
+ return MMI_ERROR_OUT_OF_MEMORY;
+ // LCOV_EXCL_STOP
+ }
for (size_t i = 0; i < workflow_s->attribute_default_value_info_count; i++) {
+ cloned_s->attribute_default_value_infos[i].serialized_default_value_size =
+ workflow_s->attribute_default_value_infos[i].serialized_default_value_size;
cloned_s->attribute_default_value_infos[i].serialized_default_value =
- new(std::nothrow) unsigned char[workflow_s->attribute_default_value_infos[i].serialized_default_value_size];
+ reinterpret_cast<unsigned char *>(
+ calloc(1, workflow_s->attribute_default_value_infos[i].serialized_default_value_size));
+ if (nullptr == cloned_s->attribute_default_value_infos[i].serialized_default_value) {
+ // LCOV_EXCL_START
+ LOGE("[ERROR] new unsigned char failed");
+ mmi_workflow_destroy(workflow_s);
+ return MMI_ERROR_OUT_OF_MEMORY;
+ // LCOV_EXCL_STOP
+ }
memcpy(cloned_s->attribute_default_value_infos[i].serialized_default_value,
workflow_s->attribute_default_value_infos[i].serialized_default_value,
workflow_s->attribute_default_value_infos[i].serialized_default_value_size);
if (workflow_s->output_assignment_info_count > 0) {
cloned_s->output_assignment_infos = new(std::nothrow) mmi_workflow_output_assignment_info_s[workflow_s->output_assignment_info_count];
+ if (nullptr == cloned_s->output_assignment_infos) {
+ // LCOV_EXCL_START
+ LOGE("[ERROR] new mmi_workflow_output_assignment_info_s failed");
+ mmi_workflow_destroy(workflow_s);
+ return MMI_ERROR_OUT_OF_MEMORY;
+ // LCOV_EXCL_STOP
+ }
memcpy(cloned_s->output_assignment_infos, workflow_s->output_assignment_infos,
sizeof(mmi_workflow_output_assignment_info_s) * workflow_s->output_assignment_info_count);
}
delete [] workflow_s->node_infos;
delete [] workflow_s->link_infos;
delete [] workflow_s->attribute_assignment_infos;
+ for (size_t i = 0; i < workflow_s->attribute_default_value_info_count; i++) {
+ free(workflow_s->attribute_default_value_infos[i].serialized_default_value);
+ }
delete [] workflow_s->attribute_default_value_infos;
delete [] workflow_s->output_assignment_infos;
int i = 0;
while (g_state != MMI_STATE_READY && i < msec) {
ecore_main_loop_iterate();
- usleep(1000);
+ usleep(10000);
i++;
}
}