summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNataliia Kamyshna <n.kamyshna@samsung.com>2017-11-27 09:57:42 +0200
committerNataliia Kamyshna <n.kamyshna@samsung.com>2017-11-28 15:18:44 +0200
commitcf626eb2a36737d842b4b95e0f3ddb0277cf540d (patch)
treeba612f320ba368c09db1518eb9ba9745cf0935b1
parentfdc65cf6f67c8d33a16a71fdbd65abc034539213 (diff)
downloadvoice-control-tizen_dev.tar.gz
voice-control-tizen_dev.tar.bz2
voice-control-tizen_dev.zip
Fixed getting appId from manifest.tizen_dev
Change-Id: I278c868aa2bbc5771e32842cdab5dfccc2cfc70f Signed-off-by: Nataliia Kamyshna <n.kamyshna@samsung.com>
-rw-r--r--voice-app/inc/Model/ManifestParser.h6
-rw-r--r--voice-app/src/Model/ManifestParser.cpp31
-rw-r--r--voice-app/src/Model/VoiceCommandProvider.cpp9
3 files changed, 23 insertions, 23 deletions
diff --git a/voice-app/inc/Model/ManifestParser.h b/voice-app/inc/Model/ManifestParser.h
index 0be6adc..58c99bf 100644
--- a/voice-app/inc/Model/ManifestParser.h
+++ b/voice-app/inc/Model/ManifestParser.h
@@ -37,9 +37,8 @@ namespace Model
/**
* @brief Create manifest parser.
* @param[in] path Path to manifest to parse
- * @param[in] appId Application id
*/
- ManifestParser(std::string path, std::string appId);
+ ManifestParser(std::string path);
~ManifestParser();
/**
@@ -54,11 +53,10 @@ namespace Model
typedef std::function<void(xmlNodePtr node)> NodeFoundCallback;
void findChildNodes(xmlNodePtr parentNode, const char *childNodeName, NodeFoundCallback onNodeFound);
void parseUiAppNode(xmlNodePtr uiAppNode);
- void parseAppControlNode(xmlNodePtr appControlNode);
+ void parseAppControlNode(xmlNodePtr appControlNode, std::string appId);
void parseVoiceCommandNode(xmlNodePtr voiceCommandNode, VoiceCommand &command);
CommandFoundCallback m_OnCommandFound;
- std::string m_AppId;
xmlDoc *m_Doc;
};
}
diff --git a/voice-app/src/Model/ManifestParser.cpp b/voice-app/src/Model/ManifestParser.cpp
index 8b40092..bf84416 100644
--- a/voice-app/src/Model/ManifestParser.cpp
+++ b/voice-app/src/Model/ManifestParser.cpp
@@ -31,14 +31,15 @@ namespace
const char *nodeOperation = "operation";
const char *nodeMime = "mime";
const char *nodeUri = "uri";
+ const char *propAppId = "appid";
const char *propType = "type";
const char *propName = "name";
const char *nodeCommandName = "name";
const char *propTypeWithParam = "with-param";
}
-ManifestParser::ManifestParser(std::string path, std::string appId)
- : m_AppId(std::move(appId)), m_Doc(nullptr)
+ManifestParser::ManifestParser(std::string path)
+ : m_Doc(nullptr)
{
m_Doc = xmlReadFile(path.c_str(), nullptr, 0);
}
@@ -74,23 +75,31 @@ void ManifestParser::findChildNodes(xmlNodePtr parentNode, const char *childNode
void ManifestParser::parseUiAppNode(xmlNodePtr uiAppNode)
{
- findChildNodes(uiAppNode, nodeAppControl, std::bind(&ManifestParser::parseAppControlNode, this, _1));
+ std::string appId;
+ for (auto property = uiAppNode->properties; property; property = property->next) {
+ if (safeCmp((const char *)property->name, propAppId)) {
+ appId = (const char *)property->children->content;
+ break;
+ }
+ }
+
+ findChildNodes(uiAppNode, nodeAppControl, std::bind(&ManifestParser::parseAppControlNode, this, _1, std::move(appId)));
}
-void ManifestParser::parseAppControlNode(xmlNodePtr appControlNode)
+void ManifestParser::parseAppControlNode(xmlNodePtr appControlNode, std::string appId)
{
VoiceCommand command;
- command.setAppId(m_AppId);
+ command.setAppId(appId);
for (auto node = appControlNode->children; node; node = xmlNextElementSibling(node)) {
if (node->type == XML_ELEMENT_NODE) {
auto nodeName = (const char *)node->name;
- auto properties = node->properties;
+ auto property = node->properties;
if (safeCmp(nodeName, nodeVoiceCommand)) {
parseVoiceCommandNode(node, command);
- } else if (safeCmp((const char *)properties->name, propName)) {
- auto value = (const char *)properties->children->content;
+ } else if (safeCmp((const char *)property->name, propName)) {
+ auto value = (const char *)property->children->content;
if (safeCmp(nodeName, nodeOperation)) {
command.setOperation(value);
} else if (safeCmp(nodeName, nodeMime)) {
@@ -109,10 +118,10 @@ void ManifestParser::parseAppControlNode(xmlNodePtr appControlNode)
void ManifestParser::parseVoiceCommandNode(xmlNodePtr voiceCommandNode, VoiceCommand &command)
{
- auto properties = voiceCommandNode->properties;
+ auto property = voiceCommandNode->properties;
- if (safeCmp((const char *)properties->name, propType) &&
- safeCmp((const char *)properties->children->content, propTypeWithParam)) {
+ if (property && safeCmp((const char *)property->name, propType) &&
+ safeCmp((const char *)property->children->content, propTypeWithParam)) {
command.setType(VoiceCommand::CommandWithParam);
} else {
command.setType(VoiceCommand::CommandWithAction);
diff --git a/voice-app/src/Model/VoiceCommandProvider.cpp b/voice-app/src/Model/VoiceCommandProvider.cpp
index 47101a8..2a87420 100644
--- a/voice-app/src/Model/VoiceCommandProvider.cpp
+++ b/voice-app/src/Model/VoiceCommandProvider.cpp
@@ -122,17 +122,10 @@ void VoiceCommandProvider::parsePackageInfo(package_info_h packageInfo)
free(path);
manifest.append("/tizen-manifest.xml");
- char *appId = nullptr;
- package_info_get_main_app_id(packageInfo, &appId);
- if (!appId) {
- return;
- }
-
- ManifestParser parser(manifest, appId);
+ ManifestParser parser(manifest);
parser.parse([this](VoiceCommand command) {
insertDataItem(new VoiceCommand(std::move(command)));
});
- free(appId);
finishUpdate();
}