#include "view_logic_uri_support.h"
#include <string>
+#include <vector>
#include <list>
#include <dpl/string.h>
#include <dpl/log/log.h>
#include <bundle.h>
#include <appsvc.h>
#include <application_data.h>
+#include <wrt-commons/custom-handler-dao-ro/CustomHandlerDatabase.h>
+#include <wrt-commons/custom-handler-dao-ro/custom_handler_dao_read_only.h>
+#include <stdio.h>
namespace ViewModule {
namespace UriSupport {
return parsedData;
}
+/**
+ * Parses scheme from appsvc. From mailto:test@wacapps.net
+ * it will return list:
+ * 0: mailto
+ * 1: test@wacapps.net
+ */
+std::vector<std::string> parseScheme(const std::string &scheme)
+{
+ std::vector<std::string> schemeParts;
+ std::string::size_type pos = scheme.find(":");
+ if (pos != std::string::npos) {
+ schemeParts.push_back(scheme.substr(0, pos));
+ schemeParts.push_back(
+ scheme.substr(pos + 1, scheme.length() - pos - 1));
+ }
+ return schemeParts;
+}
+
bool compareServiceData(ServiceDataType type,
std::string origin,
std::string other)
}
}
+std::string getCustomHandlerProtocolUri(
+ WidgetModel *widgetModel,
+ const std::string &schemeType,
+ const std::string &schemeValue)
+{
+ CustomHandlerDB::Interface::attachDatabaseRO();
+ CustomHandlerDB::CustomHandlerDAOReadOnly handlersDao(widgetModel->TizenId);
+ CustomHandlerDB::CustomHandlerPtr handler =
+ handlersDao.getActivProtocolHandler(
+ DPL::FromASCIIString(schemeType));
+ CustomHandlerDB::Interface::detachDatabase();
+ if (handler) {
+ LogDebug("Found handler, url: " << handler->url);
+ std::string url = DPL::ToUTF8String(handler->base_url) +
+ DPL::ToUTF8String(handler->url);
+ if (url.find("file://") == 0) {
+ url.erase(0, 6);
+ }
+ //replace %s in url with given from appservice
+ int size = snprintf(NULL, 0, url.c_str(), schemeValue.c_str()) + 1;
+ char buffer[size];
+ snprintf(buffer, size, url.c_str(), schemeValue.c_str());
+ return std::string(buffer);
+ }
+ return "";
+}
+
std::string getAppServiceUri(bundle *bundle, WidgetModel *widgetModel)
{
if(!bundle)
return DPL::ToUTF8String(appServiceIt->src);
}
}
+ std::vector<std::string> schemeParts = parseScheme(scheme);
+ if (schemeParts.size() > 1) {
+ LogDebug("Scheme parts: " << schemeParts[0] << ", " << schemeParts[1]);
+ return getCustomHandlerProtocolUri(
+ widgetModel, schemeParts[0], schemeParts[1]);
+ }
+
LogDebug("no matching result");
return std::string("");
}
{
DPL::String uri;
std::string startUri;
-
+ LogDebug("default uri: " << defaultUri);
bundle *originBundle = ApplicationDataSingleton::Instance().getBundle();
// search application service
startUri = getAppServiceUri(originBundle, widgetModel).c_str();