Change touch launch function to transfer event function 85/185085/25
authorSukHyung, Kang <shine.kang@samsung.com>
Thu, 26 Jul 2018 04:46:40 +0000 (13:46 +0900)
committerhyunho <hhstark.kang@samsung.com>
Fri, 17 Aug 2018 04:58:52 +0000 (13:58 +0900)
Change-Id: Icbef216f3bc16d2bfa938a207b8b924b2cceedb0
Signed-off-by: SukHyung, Kang <shine.kang@samsung.com>
Signed-off-by: hyunho <hhstark.kang@samsung.com>
14 files changed:
unittest/src/test_complication.cc
watchface-common/include/watchface-common.h
watchface-complication-provider/complication-provider-implementation.h
watchface-complication-provider/complication-provider.cc
watchface-complication-provider/include/watchface-complication-provider.h
watchface-complication-provider/watchface-complication-provider.cc
watchface-complication/complication-implementation.h
watchface-complication/complication.cc
watchface-complication/complication.h
watchface-complication/db-manager.cc
watchface-complication/db-manager.h
watchface-complication/include/watchface-complication-internal.h
watchface-complication/include/watchface-complication.h
watchface-complication/watchface-complication.cc

index 78fc318..817cce9 100644 (file)
@@ -36,10 +36,11 @@ using namespace watchface_complication;
 
 class WatchComplication : public Complication {
  public:
-  WatchComplication(int id, int support_types,
+  WatchComplication(int id, int supported_types, int supported_event_types,
                         const std::string& default_provider_id,
                         ComplicationType default_type)
-    : Complication(id, support_types, default_provider_id, default_type) {
+    : Complication(id, supported_types, supported_event_types,
+        default_provider_id, default_type) {
     SetCurDataIdx(0);
     SetLabel("TestComplication");
     SetHighlight(std::unique_ptr<IEditable::Highlight>(
@@ -57,7 +58,8 @@ class WC : public ::testing::Test {
   string providerId = "org.tizen.watchface_sample_provider/test";
 
   virtual void SetUp() {
-    complication = new WatchComplication(0, ShortText, providerId.c_str(), ShortText);
+    complication =
+        new WatchComplication(0, ShortText, Tap, providerId.c_str(), ShortText);
   }
   virtual void TearDown() {
     delete complication;
@@ -112,6 +114,7 @@ class WFC : public ::testing::Test {
     watchface_complication_create(comp_id, "org.tizen.sample",
                        WATCHFACE_COMPLICATION_TYPE_SHORT_TEXT,
                        WATCHFACE_COMPLICATION_TYPE_SHORT_TEXT,
+                       WATCHFACE_COMPLICATION_EVENT_TAP,
                        &complication);
   }
   virtual void TearDown() {
index 60a90d8..dc1b8d1 100644 (file)
@@ -74,6 +74,20 @@ typedef enum _complication_type {
 } watchface_complication_type_e;
 
 /**
+ * @brief Enumeration for Complication event type.
+ * @details Watchface should transfer the touch event to complication provider
+ *          to trigger the complication tap action.
+ *          #WATCHFACE_COMPLICATION_EVENT_NONE is transferred to the complication provider
+ *          when the complication is launched without tap event.
+ * @since_tizen 5.0
+ */
+typedef enum _complication_event_type {
+       WATCHFACE_COMPLICATION_EVENT_NONE = 0x01, /**< Complication is not tapped */
+       WATCHFACE_COMPLICATION_EVENT_TAP = 0x02, /**< Tap */
+       WATCHFACE_COMPLICATION_EVENT_DOUBLE_TAP = 0x04 /**< Double Tap */
+} watchface_complication_event_type_e;
+
+/**
  * @}
  */
 
index b883b4c..1212b3f 100644 (file)
@@ -71,7 +71,7 @@ class ComplicationProvider::Impl : ComplicationConnector::IEventListener {
   int subscribe_id_;
   std::string provider_id_;
   std::string setup_appid_;
-  int support_types_;
+  int supported_types_;
   std::map<std::string, SenderInfo*> sender_info_;
   std::list<std::string> required_privileges_;
 };
index de2d1dc..494d3ba 100644 (file)
@@ -52,7 +52,7 @@ ComplicationProvider::Impl::Impl(ComplicationProvider* parent,
   std::list<std::string> privlege_list;
   required_privileges_.push_back(std::string(PRIVILEGE_DATASHARING));
 
-  ret = DBManager::GetSupportTypes(provider_id_, &support_types_);
+  ret = DBManager::GetSupportTypes(provider_id_, &supported_types_);
   if (ret != WATCHFACE_COMPLICATION_ERROR_NONE)
     THROW(ret);
 
@@ -219,8 +219,8 @@ void ComplicationProvider::Impl::OnSignal(GDBusConnection* connection,
       return;
     }
 
-    if ((support_types_ & type) == 0) {
-      LOGE("Not supported type [%d][%d]", support_types_, type);
+    if ((supported_types_ & type) == 0) {
+      LOGE("Not supported type [%d][%d]", supported_types_, type);
       return;
     }
 
index e19dd5b..226c470 100644 (file)
@@ -562,45 +562,49 @@ int watchface_complication_provider_data_set_extra_data(bundle *shared_data,
                const char *extra_data);
 
 /**
- * @brief Checks whether app is launched by complication touch or not.
+ * @brief Gets touch event type that is transferred from watchface.
  * @since_tizen 5.0
- * @remarks @a is_touch_launch is true when provider app is launched by watchface_complication_touch_launch().
+ * @remarks @a event_type is the type of touch event transftered from the watchface
+ *             by watchface_complication_transfer_event().
  * @param[in] handle The app control handle
- * @param[out] is_touch_launch The value that tell it's launched by touch.
+ * @param[out] event_type The value that tells touch event type that is transferred.
  * @return #WATCHFACE_COMPLICATION_ERROR_NONE on success,
  *         otherwise an error code (see #watchface_complication_error_e) on failure
  * @retval #WATCHFACE_COMPLICATION_ERROR_NONE Successful
  * @retval #WATCHFACE_COMPLICATION_ERROR_INVALID_PARAMETER Invalid parameter
  * @retval #WATCHFACE_COMPLICATION_ERROR_NOT_SUPPORTED Not supported
- * @see watchface_complication_touch_launch()
- * @see watchface_complication_provider_touch_launch_get_provider_id()
- * @see watchface_complication_provider_touch_launch_get_complication_type()
- * @see watchface_complication_provider_touch_launch_get_context()
+ * @retval #WATCHFACE_COMPLICATION_ERROR_OUT_OF_MEMORY Out of memory
+ * #retval #WATCHFACE_COMPLICATION_ERROR_IO_ERROR I/O error
+ * @see watchface_complication_event_type_e
+ * @see watchface_complication_transfer_event()
+ * @see watchface_complication_provider_event_get_provider_id()
+ * @see watchface_complication_provider_event_get_complication_type()
+ * @see watchface_complication_provider_event_get_context()
  * @par Sample code:
  * @code
 #include <watchface-complication-provider.h>
 void app_control(app_control_h app_control, void *data)
 {
-       bool is_touch_launch;
+       watchface_complication_event_type_e event_type;
        char *provider_id;
        watchface_complication_type_e type;
        bundle *context
 
-       watchface_complication_provider_is_touch_launch(app_control, &is_touch_launch);
-       if (is_touch_launch) {
-               watchface_complication_provider_touch_launch_get_provider_id(app_control,
+       watchface_complication_provider_event_get_type(app_control, &event_type);
+       if (event_type == WATCHFACE_COMPLICATION_EVENT_TAP) {
+               watchface_complication_provider_event_get_provider_id(app_control,
                        &provider_id);
-               watchface_complication_provider_touch_launch_get_complication_type(
+               watchface_complication_provider_event_get_complication_type(
                        app_control, &type);
-               watchface_complication_provider_touch_launch_get_context(app_control,
+               watchface_complication_provider_event_get_context(app_control,
                        &context);
                // Do something
        }
 }
  * @endcode
  */
-int watchface_complication_provider_is_touch_launch(app_control_h handle,
-               bool *is_touch_launch);
+int watchface_complication_provider_event_get_type(app_control_h handle,
+               watchface_complication_event_type_e *event_type);
 
 /**
  * @brief Gets provider id of touched complication.
@@ -616,36 +620,33 @@ int watchface_complication_provider_is_touch_launch(app_control_h handle,
  * @retval #WATCHFACE_COMPLICATION_ERROR_IO_ERROR I/O error
  * @retval #WATCHFACE_COMPLICATION_ERROR_NO_DATA No data
  * @retval #WATCHFACE_COMPLICATION_ERROR_NOT_SUPPORTED Not supported
- * @see watchface_complication_touch_launch()
- * @see watchface_complication_provider_is_touch_launch()
- * @see watchface_complication_provider_touch_launch_get_complication_type()
- * @see watchface_complication_provider_touch_launch_get_context()
+ * @see watchface_complication_transfer_event()
+ * @see watchface_complication_provider_event_get_complication_type()
+ * @see watchface_complication_provider_event_get_context()
  * @par Sample code:
  * @code
 #include <watchface-complication-provider.h>
 void app_control(app_control_h app_control, void *data)
 {
-       bool is_touch_launch;
+       watchface_complication_event_type_e event_type;
        char *provider_id;
        watchface_complication_type_e type;
        bundle *context
 
-       watchface_complication_provider_is_touch_launch(handle, &is_touch_launch);
-       if (is_touch_launch) {
-               watchface_complication_provider_touch_launch_get_provider_id(handle,
+       watchface_complication_provider_event_get_type(app_control, &event_type);
+       if (event_type == WATCHFACE_COMPLICATION_EVENT_TAP) {
+               watchface_complication_provider_event_get_provider_id(app_control,
                        &provider_id);
-               watchface_complication_provider_touch_launch_get_complication_type(
-                       handle, &type);
-               watchface_complication_provider_touch_launch_get_context(handle,
+               watchface_complication_provider_event_get_complication_type(
+                       app_control, &type);
+               watchface_complication_provider_event_get_context(app_control,
                        &context);
                // Do something
        }
-
-       free(provider_id);
 }
  * @endcode
  */
-int watchface_complication_provider_touch_launch_get_provider_id(
+int watchface_complication_provider_event_get_provider_id(
                app_control_h handle, char **provider_id);
 
 /**
@@ -661,34 +662,33 @@ int watchface_complication_provider_touch_launch_get_provider_id(
  * @retval #WATCHFACE_COMPLICATION_ERROR_IO_ERROR I/O error
  * @retval #WATCHFACE_COMPLICATION_ERROR_NO_DATA No data
  * @retval #WATCHFACE_COMPLICATION_ERROR_NOT_SUPPORTED Not supported
- * @see watchface_complication_touch_launch()
- * @see watchface_complication_provider_is_touch_launch()
- * @see watchface_complication_provider_touch_launch_get_provider_id()
- * @see watchface_complication_provider_touch_launch_get_context()
+ * @see watchface_complication_transfer_event()
+ * @see watchface_complication_provider_event_get_provider_id()
+ * @see watchface_complication_provider_event_get_context()
  * @par Sample code:
  * @code
 #include <watchface-complication-provider.h>
 void app_control(app_control_h app_control, void *data)
 {
-       bool is_touch_launch;
+       watchface_complication_event_type_e event_type;
        char *provider_id;
        watchface_complication_type_e type;
        bundle *context
 
-       watchface_complication_provider_is_touch_launch(handle, &is_touch_launch);
-       if (is_touch_launch) {
-               watchface_complication_provider_touch_launch_get_provider_id(handle,
+       watchface_complication_provider_event_get_type(app_control, &event_type);
+       if (event_type == WATCHFACE_COMPLICATION_EVENT_TAP) {
+               watchface_complication_provider_event_get_provider_id(app_control,
                        &provider_id);
-               watchface_complication_provider_touch_launch_get_complication_type(
-                       handle, &type);
-               watchface_complication_provider_touch_launch_get_context(handle,
+               watchface_complication_provider_event_get_complication_type(
+                       app_control, &type);
+               watchface_complication_provider_event_get_context(app_control,
                        &context);
                // Do something
        }
 }
  * @endcode
  */
-int watchface_complication_provider_touch_launch_get_complication_type(
+int watchface_complication_provider_event_get_complication_type(
                app_control_h handle, watchface_complication_type_e *type);
 
 /**
@@ -709,10 +709,9 @@ int watchface_complication_provider_touch_launch_get_complication_type(
  * @retval #WATCHFACE_COMPLICATION_ERROR_IO_ERROR I/O error
  * @retval #WATCHFACE_COMPLICATION_ERROR_NO_DATA No data
  * @retval #WATCHFACE_COMPLICATION_ERROR_NOT_SUPPORTED Not supported
- * @see watchface_complication_touch_launch()
- * @see watchface_complication_provider_is_touch_launch()
- * @see watchface_complication_provider_touch_launch_get_provider_id()
- * @see watchface_complication_provider_touch_launch_get_type()
+ * @see watchface_complication_transfer_event()
+ * @see watchface_complication_provider_event_get_provider_id()
+ * @see watchface_complication_provider_event_get_complication_type()
  * @see watchface_complication_provider_setup_reply_to_editor()
  * @see watchface_complication_provider_setup_is_editing()
  * @see watchface_complication_provider_setup_get_context()
@@ -721,25 +720,25 @@ int watchface_complication_provider_touch_launch_get_complication_type(
 #include <watchface-complication-provider.h>
 void app_control(app_control_h app_control, void *data)
 {
-       bool is_touch_launch;
+       watchface_complication_event_type_e event_type;
        char *provider_id;
        watchface_complication_type_e type;
        bundle *context
 
-       watchface_complication_provider_is_touch_launch(handle, &is_touch_launch);
-       if (is_touch_launch) {
-               watchface_complication_provider_touch_launch_get_provider_id(handle,
+       watchface_complication_provider_event_get_type(app_control, &event_type);
+       if (event_type == WATCHFACE_COMPLICATION_EVENT_TAP) {
+               watchface_complication_provider_event_get_provider_id(app_control,
                        &provider_id);
-               watchface_complication_provider_touch_launch_get_complication_type(
-                       handle, &type);
-               watchface_complication_provider_touch_launch_get_context(handle,
+               watchface_complication_provider_event_get_complication_type(
+                       app_control, &type);
+               watchface_complication_provider_event_get_context(app_control,
                        &context);
                // Do something
        }
 }
  * @endcode
  */
-int watchface_complication_provider_touch_launch_get_context(
+int watchface_complication_provider_event_get_context(
                app_control_h handle, bundle **context);
 
 /*
index 675dd98..c36bfb7 100644 (file)
@@ -534,39 +534,6 @@ int watchface_complication_provider_data_set_extra_data(
   return _add_bundle_data(shared_data, EXTRA_DATA_KEY, extra_data);
 }
 
-extern "C" EXPORT_API int watchface_complication_provider_is_touch_launch(
-    app_control_h handle, bool* is_touch_launch) {
-  int ret;
-  char* value = NULL;
-  bundle* data;
-
-  if (handle == NULL || is_touch_launch == NULL) {
-    LOGE("Invalid param");
-    return WATCHFACE_COMPLICATION_ERROR_INVALID_PARAMETER;
-  }
-
-  ret = app_control_to_bundle(handle, &data);
-  if (ret != APP_CONTROL_ERROR_NONE) {
-    LOGE("Invalid param");
-    return WATCHFACE_COMPLICATION_ERROR_INVALID_PARAMETER;
-  }
-
-  ret = bundle_get_str(data, AUL_K_COMPLICATION_MODE, &value);
-  if (ret != BUNDLE_ERROR_NONE) {
-    *is_touch_launch = false;
-    return WATCHFACE_COMPLICATION_ERROR_NONE;
-  }
-
-  ret = bundle_get_str(data, TOUCH_LAUNCH_DATA_KEY, &value);
-  if (ret != BUNDLE_ERROR_NONE) {
-    *is_touch_launch = false;
-    return WATCHFACE_COMPLICATION_ERROR_NONE;
-  }
-
-  *is_touch_launch = true;
-  return WATCHFACE_COMPLICATION_ERROR_NONE;
-}
-
 static int _get_value_from_touch_launch_data(app_control_h handle,
     const char* key, char** value) {
   bundle* data = NULL;
@@ -611,8 +578,50 @@ static int _get_value_from_touch_launch_data(app_control_h handle,
   return WATCHFACE_COMPLICATION_ERROR_NONE;
 }
 
+extern "C" EXPORT_API int watchface_complication_provider_event_get_type(
+    app_control_h handle, watchface_complication_event_type_e* event_type) {
+  int ret;
+  char* value = NULL;
+  bundle* data;
+
+  if (handle == NULL || event_type == NULL) {
+    LOGE("Invalid param");
+    return WATCHFACE_COMPLICATION_ERROR_INVALID_PARAMETER;
+  }
+
+  ret = app_control_to_bundle(handle, &data);
+  if (ret != APP_CONTROL_ERROR_NONE) {
+    LOGE("Invalid param");
+    return WATCHFACE_COMPLICATION_ERROR_INVALID_PARAMETER;
+  }
+
+  ret = bundle_get_str(data, AUL_K_COMPLICATION_MODE, &value);
+  if (ret != BUNDLE_ERROR_NONE) {
+    *event_type = WATCHFACE_COMPLICATION_EVENT_NONE;
+    return WATCHFACE_COMPLICATION_ERROR_NONE;
+  }
+
+  ret = _get_value_from_touch_launch_data(handle,
+      TOUCH_LAUNCH_EVENT_KEY, &value);
+  if (ret != WATCHFACE_COMPLICATION_ERROR_NONE) {
+    if (ret == WATCHFACE_COMPLICATION_ERROR_INVALID_PARAMETER ||
+        ret == WATCHFACE_COMPLICATION_ERROR_NO_DATA) {
+      *event_type = WATCHFACE_COMPLICATION_EVENT_NONE;
+      return WATCHFACE_COMPLICATION_ERROR_NONE;
+    } else {
+      return ret;
+    }
+  }
+
+  *event_type = static_cast<watchface_complication_event_type_e>(
+                  strtol(value, NULL, 10));
+  free(value);
+
+  return WATCHFACE_COMPLICATION_ERROR_NONE;
+}
+
 extern "C" EXPORT_API
-int watchface_complication_provider_touch_launch_get_provider_id(
+int watchface_complication_provider_event_get_provider_id(
     app_control_h handle, char** provider_id) {
   int ret;
   char* value = NULL;
@@ -633,7 +642,7 @@ int watchface_complication_provider_touch_launch_get_provider_id(
 }
 
 extern "C" EXPORT_API
-int watchface_complication_provider_touch_launch_get_complication_type(
+int watchface_complication_provider_event_get_complication_type(
     app_control_h handle, watchface_complication_type_e* type) {
   int ret;
   char* value = NULL;
@@ -654,7 +663,7 @@ int watchface_complication_provider_touch_launch_get_complication_type(
 }
 
 extern "C" EXPORT_API
-int watchface_complication_provider_touch_launch_get_context(
+int watchface_complication_provider_event_get_context(
     app_control_h handle, bundle** context) {
   int ret;
   char* value = NULL;
index e54b1ea..1c19511 100644 (file)
@@ -54,7 +54,7 @@ class Complication::Impl : ComplicationConnector::IEventListener,
  private:
   friend class Complication;
 
-  Impl(Complication* parent, int id, int support_types,
+  Impl(Complication* parent, int id, int supported_types, int supported_event_types,
        const std::string& default_provider_id,
        ComplicationType default_type);
   int FindCandidateDataIdx(std::string provider_id, int type);
@@ -83,7 +83,8 @@ class Complication::Impl : ComplicationConnector::IEventListener,
   Complication* parent_;
   int complication_id_ = -1;
   int editable_id_ = -1;
-  int support_types_ = -1;
+  int supported_types_ = -1;
+  int supported_event_types_ = -1;
   std::string default_provider_appid_;
   std::string default_provider_id_;
   ComplicationType default_type_;
index 884fbe0..6040d03 100644 (file)
@@ -39,10 +39,11 @@ namespace watchface_complication {
 
 const std::string Complication::Impl::provider_id_key_ = "__PROVIDER_ID_KEY__";
 const std::string Complication::Impl::provider_type_key_ = "__PROVIDER_TYPE_KEY__";
-Complication::Complication(int id, int support_types,
+Complication::Complication(int id, int supported_types, int supported_event_types,
                            const std::string& default_provider_id,
                            ComplicationType default_type)
-  : impl_(new Impl(this, id, support_types, default_provider_id, default_type)) {
+  : impl_(new Impl(this, id, supported_types, supported_event_types,
+      default_provider_id, default_type)) {
   ComplicationConnector::GetInst().AddPackageEventListener(impl_.get());
 }
 
@@ -51,10 +52,12 @@ Complication::~Complication() {
 }
 
 Complication::Impl::Impl(Complication* parent, int id,
-                         int support_types,
+                         int supported_types,
+                         int supported_event_types,
                          const std::string& default_provider_id,
                          ComplicationType default_type)
-  : parent_(parent), complication_id_(id), support_types_(support_types),
+  : parent_(parent), complication_id_(id), supported_types_(supported_types),
+    supported_event_types_(supported_event_types),
     default_provider_id_(default_provider_id), default_type_(default_type) {
   int ret;
   ret = LoadPrevProviderInfo();
@@ -791,7 +794,7 @@ std::unique_ptr<Bundle>& Complication::GetLastContext() const {
   return impl_->last_context_data_;
 }
 
-int Complication::TouchLaunch() {
+int Complication::TouchLaunch(watchface_complication_event_type_e event_type) {
   const char* context_data_raw = NULL;
   int ret;
   std::string provider_appid = DBManager::GetProviderAppId(
@@ -810,6 +813,10 @@ int Complication::TouchLaunch() {
     return WATCHFACE_COMPLICATION_ERROR_OUT_OF_MEMORY;
   }
 
+  char event_str[32] = {0,};
+  snprintf(event_str, sizeof(event_str), "%d", event_type);
+  bundle_add_str(launch_data, TOUCH_LAUNCH_EVENT_KEY, event_str);
+
   bundle_add_str(launch_data, TOUCH_LAUNCH_PROVIDER_ID_KEY,
       impl_->cur_provider_id_.c_str());
 
@@ -911,7 +918,7 @@ int Complication::Impl::AddCandidates(int types) {
 
 int Complication::Impl::MakeCandidatesList() {
   candidates_list_.clear();
-  if ((support_types_ & NoData) == 1) {
+  if ((supported_types_ & NoData) == 1) {
     int ret = AddCandidate("", static_cast<int>(NoData));
     if (ret != WATCHFACE_COMPLICATION_ERROR_NONE)
           return ret;
@@ -932,7 +939,7 @@ int Complication::Impl::MakeCandidatesList() {
       }
     }
   } else {
-    int ret = AddCandidates(support_types_);
+    int ret = AddCandidates(supported_types_);
     if (ret != WATCHFACE_COMPLICATION_ERROR_NONE)
       return ret;
   }
index 7be8b12..d6b4970 100644 (file)
@@ -35,7 +35,7 @@ namespace watchface_complication {
 class EXPORT_API Complication : public IEditable
   , public IComplicationProviderEvent {
  public:
-  Complication(int id, int support_types,
+  Complication(int id, int supported_types, int supported_event_types,
                const std::string& default_provider_id,
                ComplicationType default_type);
   virtual ~Complication();
@@ -91,7 +91,7 @@ class EXPORT_API Complication : public IEditable
   const char* GetCurProviderId();
   const char* GetProviderId(const Bundle* data);
   int GetCurType();
-  int TouchLaunch();
+  int TouchLaunch(watchface_complication_event_type_e event_type);
   int ApplyAllowedList(
       std::list<std::unique_ptr<ProviderInfo>> allowed_list);
   int ClearAllowedList();
index 6ecd268..505c843 100644 (file)
@@ -217,7 +217,7 @@ std::string DBManager::GetProviderAppId(const char* provider_id) {
 }
 
 std::list<std::unique_ptr<DBManager::ProviderInfo>>
-DBManager::GetProviderListWithTypes(int support_types) {
+DBManager::GetProviderListWithTypes(int supported_types) {
   int ret;
   char* provider_id = NULL;
   int types = 0;
@@ -243,7 +243,7 @@ DBManager::GetProviderListWithTypes(int support_types) {
     return provider_list;
   }
 
-  sqlite3_bind_int(stmt, 1, support_types);
+  sqlite3_bind_int(stmt, 1, supported_types);
   while (sqlite3_step(stmt) == SQLITE_ROW) {
     provider_id = (char*)sqlite3_column_text(stmt, 0);
     types = sqlite3_column_int(stmt, 1);
@@ -338,7 +338,7 @@ std::list<std::string> DBManager::GetProviderListWithAppId(
 
 int DBManager::GetSupportTypes(std::string& provider_id, int* types) {
   int ret;
-  int support_types = 0;
+  int supported_types = 0;
   sqlite3_stmt* stmt;
   sqlite3* db;
 
@@ -363,12 +363,12 @@ int DBManager::GetSupportTypes(std::string& provider_id, int* types) {
   sqlite3_bind_text(stmt, 1, provider_id.c_str(), -1, SQLITE_TRANSIENT);
 
   while (sqlite3_step(stmt) == SQLITE_ROW)
-    support_types = sqlite3_column_int(stmt, 0);
+    supported_types = sqlite3_column_int(stmt, 0);
 
   sqlite3_finalize(stmt);
   CloseDB(db);
 
-  *types = support_types;
+  *types = supported_types;
 
   return WATCHFACE_COMPLICATION_ERROR_NONE;
 }
index c247b4c..0ba5cd2 100644 (file)
@@ -52,7 +52,7 @@ class EXPORT_API DBManager {
   static std::list<std::string> GetRequiredPrivlegeList(
                   std::string& provider_id);
   static std::list<std::unique_ptr<ProviderInfo>> GetProviderListWithTypes(
-                  int support_types);
+                  int supported_types);
   static int GetSupportTypes(std::string& provider_id, int* types);
   static int GetProviderPeriod(std::string& provider_id, int* period);
   static std::string GetLabel(const char* provider_id);
index ca0d16d..10840d7 100644 (file)
@@ -35,6 +35,7 @@
 #define TOUCH_LAUNCH_CONTEXT_KEY "__TOUCH_LAUNCH_CONTEXT_KEY__"
 #define TOUCH_LAUNCH_PROVIDER_ID_KEY "__TOUCH_LAUNCH_PROVIDER_ID_KEY__"
 #define TOUCH_LAUNCH_TYPE_KEY "__TOUCH_LAUNCH_TYPE_KEY__"
+#define TOUCH_LAUNCH_EVENT_KEY "__TOUCH_LAUNCH_EVENT_KEY__"
 #define TOUCH_LAUNCH_DATA_KEY "__TOUCH_LAUNCH_DATA_KEY__"
 
 namespace watchface_complication {
@@ -49,6 +50,12 @@ typedef enum {
   Image = WATCHFACE_COMPLICATION_TYPE_IMAGE
 } ComplicationType;
 
+typedef enum {
+  None = WATCHFACE_COMPLICATION_EVENT_NONE,
+  Tap = WATCHFACE_COMPLICATION_EVENT_TAP,
+  DoubleTap = WATCHFACE_COMPLICATION_EVENT_DOUBLE_TAP
+} ComplicationEventType;
+
 }  // namespace watchface_complication
 
 #endif  /* __TIZEN_APPFW_WATCHFACE_COMPLICATION_INTERNAL_H__ */
index 5f2517f..5fa977f 100644 (file)
@@ -103,6 +103,7 @@ typedef void (*watchface_complication_error_cb)(
 
        ret = watchface_complication_create(comp_id, "org.tizen.sample",
                WATCHFACE_COMPLICATION_TYPE_SHORT_TEXT, WATCHFACE_COMPLICATION_TYPE_SHORT_TEXT,
+               WATCHFACE_COMPLICATION_EVENT_TAP,
                &complication);
        if (ret != WATCHFACE_COMPLICATION_ERROR_NONE || complication == NULL)
                return ret;
@@ -137,6 +138,7 @@ int watchface_complication_get_current_provider_id(complication_h handle,
 
        ret = watchface_complication_create(comp_id, "org.tizen.sample",
                WATCHFACE_COMPLICATION_TYPE_SHORT_TEXT, WATCHFACE_COMPLICATION_TYPE_SHORT_TEXT,
+               WATCHFACE_COMPLICATION_EVENT_TAP,
                &complication);
        if (ret != WATCHFACE_COMPLICATION_ERROR_NONE || complication == NULL)
                return ret;
@@ -174,6 +176,7 @@ int watchface_complication_get_current_type(complication_h handle,
 
        ret = watchface_complication_create(comp_id, "org.tizen.sample",
                WATCHFACE_COMPLICATION_TYPE_SHORT_TEXT, WATCHFACE_COMPLICATION_TYPE_SHORT_TEXT,
+               WATCHFACE_COMPLICATION_EVENT_TAP,
                &complication);
        if (ret != WATCHFACE_COMPLICATION_ERROR_NONE || complication == NULL)
                return ret;
@@ -241,10 +244,11 @@ int watchface_complication_remove_updated_cb(complication_h handle,
        int ret;
        int comp_id = 1;
        complication_h complication;
-       int support_types;
+       int supported_types;
 
        ret = watchface_complication_create(comp_id, "org.tizen.sample",
                WATCHFACE_COMPLICATION_TYPE_SHORT_TEXT, WATCHFACE_COMPLICATION_TYPE_SHORT_TEXT,
+               WATCHFACE_COMPLICATION_EVENT_TAP,
                &complication);
        if (ret != WATCHFACE_COMPLICATION_ERROR_NONE || complication == NULL)
                return ret;
@@ -262,7 +266,8 @@ int watchface_complication_send_update_request(complication_h handle);
  * @details The default provider and type are the items to set for initial display.
  *          User should not enter null as the default provider and will receive an error.
  *          If user selects the other provider and type, they are no longer used.
- *          You can specify support_types by combining the types you want to show in the complication.
+ *          You can specify @a supported_types by combining the types you want to show in the complication.
+ *          You can specify @a supported_event_types by combining the event types you want to handle for the complication.
  * @since_tizen 5.0
  * @privilege http://tizen.org/privilege/packagemanager.info
  * @remarks The @a created_handle should be released using watchface_complication_destroy().
@@ -270,7 +275,9 @@ int watchface_complication_send_update_request(complication_h handle);
  * @param[in] complication_id A number that identifies the complication
  * @param[in] default_provider_id The default provider id
  * @param[in] default_type The default type to display
- * @param[in] support_types The type shown in the complication
+ * @param[in] supported_types The type shown in the complication, values of #watchface_complication_type_e combined with bitwise 'or'.
+ * @param[in] supported_event_types The event type supported by complication, values of #watchface_complication_event_type_e combined with bitwise 'or'.
+ *          Complication can send supported event to the provider using watchface_complication_transfer_event().
  * @param[out] created_handle Complication handle on success
  * @return #WATCHFACE_COMPLICATION_ERROR_NONE if success, other value if failure
  * @retval #WATCHFACE_COMPLICATION_ERROR_NONE Success
@@ -284,17 +291,26 @@ int watchface_complication_send_update_request(complication_h handle);
  * @retval #WATCHFACE_COMPLICATION_ERROR_NOT_SUPPORTED Not supported
  * @retval #WATCHFACE_COMPLICATION_ERROR_PROVIDER_NOT_AVAILABLE Provider aplication is not available now for some reason. (eg. uninstall, disable)
  * @see watchface_complication_type_e
+ * @see watchface_complication_event_type_e
+ * @see watchface_complication_transfer_event()
  * @par Sample code:
  * @code
 #include <watchface-complication.h>
+
+complication_h complication;
+void on_tap() {
+       watchface_complication_transfer_event(complication,
+                       WATCHFACE_COMPLICATION_EVENT_TAP);
+}
+
 {
        int ret;
        int comp_id = 1;
-       complication_h complication;
 
        ret = watchface_complication_create(comp_id, "org.tizen.sample",
                WATCHFACE_COMPLICATION_TYPE_SHORT_TEXT,
                WATCHFACE_COMPLICATION_TYPE_SHORT_TEXT|WATCHFACE_COMPLICATION_TYPE_ICON,
+               WATCHFACE_COMPLICATION_EVENT_TAP,
                &complication);
        if (ret != WATCHFACE_COMPLICATION_ERROR_NONE || complication == NULL)
                return ret;
@@ -304,7 +320,8 @@ int watchface_complication_send_update_request(complication_h handle);
 int watchface_complication_create(int complication_id,
                        const char *default_provider_id,
                        watchface_complication_type_e default_type,
-                       int support_types,
+                       int supported_types,
+                       int supported_event_types,
                        complication_h *created_handle);
 
 /**
@@ -641,9 +658,9 @@ int watchface_complication_data_get_extra_data(const bundle *data,
                        char **extra_data);
 
 /**
- * @brief Launches current complication's provider application.
+ * @brief Transfers touch event to the complication provider.
  * @details This function launchs the provider application with extra data,
- *          so that provider can tell it is launched by touching.
+ *          so that provider can tell it is launched by transferred touch event.
  * @since_tizen 5.0
  * @privilege http://tizen.org/privilege/appmanager.launch
  * @privilege http://tizen.org/privilege/datasharing
@@ -652,6 +669,7 @@ int watchface_complication_data_get_extra_data(const bundle *data,
  *          the watchface application needs those privileges to use this function.
  *          If your app doesn't have those privileges, this function will return #WATCHFACE_COMPLICATION_ERROR_PERMISSION_DENIED.
  * @param[in] handle The complication handle
+ * @param[in] event_type The event type that is transferred to complication provider
  * @return #WATCHFACE_COMPLICATION_ERROR_NONE on success,
  *         otherwise an error code (see #watchface_complication_error_e) on failure
  * @retval #WATCHFACE_COMPLICATION_ERROR_NONE Successful
@@ -661,19 +679,20 @@ int watchface_complication_data_get_extra_data(const bundle *data,
  * @retval #WATCHFACE_COMPLICATION_ERROR_PERMISSION_DENIED Permission denied
  * @retval #WATCHFACE_COMPLICATION_ERROR_DB Database error
  * @retval #WATCHFACE_COMPLICATION_ERROR_NOT_SUPPORTED Not supported
- * @see watchface_complication_provider_is_touch_launch()
- * @see watchface_complication_provider_get_touch_launch_get_provider_id()
- * @see watchface_complication_provider_get_touch_launch_get_type()
+ * @see watchface_complication_provider_event_get_type()
+ * @see watchface_complication_provider_event_get_provider_id()
+ * @see watchface_complication_provider_event_get_complication_type()
  * @par Sample code:
  * @code
 #include <watchface-complication.h>
 void _on_complication_clicked(complication_h handle)
 {
-       watchface_complication_touch_launch(handle);
+       watchface_complication_transfer_event(handle, WATCHFACE_COMPLICATION_EVENT_TAP);
 }
  * @endcode
  */
-int watchface_complication_touch_launch(complication_h handle);
+int watchface_complication_transfer_event(complication_h handle,
+                       watchface_complication_event_type_e event_type);
 
 /**
  * @brief The complication allowed list handle.
index 9bb2201..bdb7d28 100644 (file)
@@ -102,10 +102,11 @@ class ErrorCallbackInfo {
 
 class WatchComplicationStub : public Complication {
  public:
-  WatchComplicationStub(int id, int support_types,
+  WatchComplicationStub(int id, int supported_types, int supported_event_types,
                         const std::string& default_provider_id,
                         ComplicationType default_type)
-    : Complication(id, support_types, default_provider_id, default_type) {
+    : Complication(id, supported_types, supported_event_types,
+        default_provider_id, default_type) {
   }
 
   virtual ~WatchComplicationStub() = default;
@@ -196,9 +197,9 @@ extern "C" EXPORT_API int watchface_complication_send_update_request(
 
 extern "C" EXPORT_API int watchface_complication_create(int complication_id,
     const char* default_provider_id, watchface_complication_type_e default_type,
-    int support_types, complication_h* created_handle) {
-  if (support_types < WATCHFACE_COMPLICATION_TYPE_NO_DATA ||
-      support_types > (WATCHFACE_COMPLICATION_TYPE_NO_DATA |
+    int supported_types, int supported_event_types, complication_h* created_handle) {
+  if (supported_types < WATCHFACE_COMPLICATION_TYPE_NO_DATA ||
+      supported_types > (WATCHFACE_COMPLICATION_TYPE_NO_DATA |
                       WATCHFACE_COMPLICATION_TYPE_SHORT_TEXT |
                       WATCHFACE_COMPLICATION_TYPE_LONG_TEXT |
                       WATCHFACE_COMPLICATION_TYPE_RANGED_VALUE |
@@ -207,10 +208,17 @@ extern "C" EXPORT_API int watchface_complication_create(int complication_id,
                       WATCHFACE_COMPLICATION_TYPE_IMAGE))
     return WATCHFACE_COMPLICATION_ERROR_INVALID_PARAMETER;
 
+  if (supported_event_types < WATCHFACE_COMPLICATION_EVENT_NONE ||
+      supported_event_types > (WATCHFACE_COMPLICATION_EVENT_NONE |
+                      WATCHFACE_COMPLICATION_EVENT_TAP |
+                      WATCHFACE_COMPLICATION_EVENT_DOUBLE_TAP))
+    return WATCHFACE_COMPLICATION_ERROR_INVALID_PARAMETER;
+
   try {
     auto ws = new WatchComplicationStub(
               complication_id,
-              support_types,
+              supported_types,
+              supported_event_types,
               default_provider_id,
               static_cast<ComplicationType>(default_type));
     LOGI("comp created");
@@ -443,14 +451,16 @@ extern "C" EXPORT_API int watchface_complication_data_get_extra_data(
   return __get_complication_data(data, EXTRA_DATA_KEY, extra_data);
 }
 
-extern "C" EXPORT_API int watchface_complication_touch_launch(
-    complication_h handle) {
-  if (handle == NULL)
+extern "C" EXPORT_API int watchface_complication_transfer_event(
+    complication_h handle, watchface_complication_event_type_e event_type) {
+  if (handle == NULL
+    || event_type < WATCHFACE_COMPLICATION_EVENT_NONE
+    || event_type > WATCHFACE_COMPLICATION_EVENT_DOUBLE_TAP)
     return WATCHFACE_COMPLICATION_ERROR_INVALID_PARAMETER;
 
   auto sh = static_cast<SharedHandle<WatchComplicationStub>*>(handle);
   auto ptr = SharedHandle<WatchComplicationStub>::Share(sh);
-  return ptr.get()->TouchLaunch();
+  return ptr.get()->TouchLaunch(event_type);
 }
 
 typedef struct provider_info_ {