#include <wrt-commons/custom-handler-dao-ro/custom_handler_dao_read_only.h>
#include <stdio.h>
#include <pcrecpp.h>
+#include <aul.h>
+#include <iri.h>
namespace ViewModule {
namespace UriSupport {
char const * const SCHEME_TYPE_APP = "app";
#endif
char const * const SCHEME_TYPE_FILE = "file";
+char const * const SCHEME_TYPE_HTTP = "http";
+char const * const SCHEME_TYPE_HTTPS = "https";
char const * const SCHEME_TYPE_WIDGET = "widget";
-
-/**
- * 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;
-}
+const char * const SCHEME_TYPE_FILE_SLASH = "file://";
bool wildcardCompare(std::string wildcardString, std::string target)
{
const char* value = NULL;
value = appsvc_get_operation(bundle);
std::string operation = value ? value : "";
+ if (operation.empty()) {
+ return std::string("");
+ }
value = appsvc_get_mime(bundle);
std::string mime = value ? value : "";
value = appsvc_get_uri(bundle);
std::string uri = value ? value : "";
+ if (uri.empty()) {
+ LogError("Launch with no bundle data");
+ return std::string("");
+ }
- std::vector<std::string> schemeParts = parseScheme(uri);
- std::string scheme = (schemeParts.empty()) ? "" : schemeParts[0];
+ // get scheme by iri
+ std::unique_ptr<iri_t> iri(iri_parse(uri.c_str()));
+ if (!iri.get()) {
+ LogDebug("Fail to get iri");
+ return std::string("");
+ }
+ std::string scheme;
+ if (iri->scheme) {
+ if (std::string(iri->scheme) != SCHEME_TYPE_FILE) {
+ scheme = iri->scheme;
+ }
+ }
+ if (iri->path) {
+ uri = iri->path;
+ }
- std::string ignoreScheme = "file";
- if (scheme == ignoreScheme)
- {
- LogInfo("exception : 'file' scheme is ignored.");
- uri = "";
- scheme = "";
+ // get mime type by aul api in case of mime type is empty
+ if (mime.empty()) {
+ char mimetype[128] = {0,};
+ if (AUL_R_OK ==
+ aul_get_mime_from_file(uri.c_str(),
+ mimetype,
+ sizeof(mimetype)))
+ {
+ mime = mimetype;
+ }
}
LogDebug("AppService Information");
LogDebug(" - operation : " << operation);
- LogDebug(" - uri : " << uri);
- LogDebug(" - scheme : " << scheme);
- LogDebug(" - mimetype : " << mime);
+ LogDebug(" - uri : " << uri);
+ LogDebug(" - scheme : " << scheme);
+ LogDebug(" - mimetype : " << mime);
WidgetApplicationServiceList appServiceList = widgetModel->AppServiceList.Get();
{
LogDebug("AppService Matched with : " << appServiceIt->src);
LogDebug(" - operation : " << appServiceIt->operation);
- LogDebug(" - uri : " << appServiceIt->scheme);
- LogDebug(" - mimetype : " << appServiceIt->mime);
+ LogDebug(" - scheme : " << appServiceIt->scheme);
+ LogDebug(" - mimetype : " << appServiceIt->mime);
return DPL::ToUTF8String(appServiceIt->src);
}
}
#endif
- if (schemeParts.size() > 1) {
- LogDebug("Scheme parts: " << schemeParts[0] << ", " << schemeParts[1]);
+ if (!scheme.empty()) {
+ LogDebug("Scheme parts: " << scheme << ", " << uri);
return getCustomHandlerProtocolUri(
- widgetModel, schemeParts[0], schemeParts[1]);
+ widgetModel, scheme, uri);
}
if (mime != "") {
value = appsvc_get_data(bundle, APPSVC_DATA_SELECTED);
// insert prefix path
std::string preFix = DPL::ToUTF8String(widgetModel->PrefixURL.Get());
- if (strstr(startUri.c_str(), "http") == startUri.c_str() ||
+ if (strstr(startUri.c_str(), SCHEME_TYPE_HTTP) == startUri.c_str() ||
+ strstr(startUri.c_str(), SCHEME_TYPE_HTTPS) == startUri.c_str() ||
strstr(startUri.c_str(), preFix.c_str()) == startUri.c_str())
{
uri = DPL::FromUTF8String(startUri);