TizenRefApp-6139 Browser isn't Launched from Contact Details Screen 63/66863/1
authorEugene Kurzberg <i.kurtsberg@samsung.com>
Thu, 21 Apr 2016 13:57:05 +0000 (16:57 +0300)
committerEugene Kurzberg <i.kurtsberg@samsung.com>
Thu, 21 Apr 2016 13:57:38 +0000 (16:57 +0300)
Change-Id: I46dbc57d5ed40e88397fb4e7383c2362f3f24739
Signed-off-by: Eugene Kurzberg <i.kurtsberg@samsung.com>
lib-common/src/Common/Actions.cpp

index a41b0de0bf277700ecb2b0debb1bdf547102525c..f7524e6082c1de763c0880fc4c8e74ee5c2873cb 100644 (file)
  */
 
 #include "Common/Actions.h"
+#include "Utils/Range.h"
+
+#include <cstring>
 #include <string>
 
+#define ACTION_SCHEME_COUNT 2
+
+using namespace Utils;
+
 namespace
 {
        struct {
                const char *operation;
-               const char *scheme;
+               Range<const char *> schemes[ACTION_SCHEME_COUNT];
        } actions[] = {
-               /* ActionCall    = */ { APP_CONTROL_OPERATION_CALL, "tel:" },
-               /* ActionMessage = */ { APP_CONTROL_OPERATION_COMPOSE, "sms:" },
-               /* ActionEmail   = */ { APP_CONTROL_OPERATION_COMPOSE, "mailto:" },
-               /* ActionUrl     = */ { APP_CONTROL_OPERATION_VIEW, "" }
+               /* ActionCall    = */ { APP_CONTROL_OPERATION_CALL,    makeRange("tel:"),    { } },
+               /* ActionMessage = */ { APP_CONTROL_OPERATION_COMPOSE, makeRange("sms:"),    makeRange("mmsto:") },
+               /* ActionEmail   = */ { APP_CONTROL_OPERATION_COMPOSE, makeRange("mailto:"), { } },
+               /* ActionUrl     = */ { APP_CONTROL_OPERATION_VIEW,    makeRange("http://"), makeRange("https://") }
        };
 }
 
 App::AppControl Common::requestAction(ActionType actionType, const char *value)
 {
        auto action = actions[actionType];
-       std::string uri = action.scheme;
+       std::string uri;
        if (value) {
+
+               bool hasScheme = false;
+               for (auto &&scheme : action.schemes) {
+                       if (scheme && strncmp(value, scheme.begin(), scheme.count() - 1) == 0) {
+                               hasScheme = true;
+                               break;
+                       }
+               }
+
+               if (!hasScheme) {
+                       uri.append(action.schemes[0].begin());
+               }
+
                uri.append(value);
        }