#include <memory>
#include <list>
-#include "watchface-complication/include/watchface-complication-internal.h"
+#include "watchface-complication/complication-internal.h"
#include "watchface-complication/include/watchface-complication.h"
#include "watchface-common/watchface-util.h"
#include "watchface-common/watchface-common-internal.h"
}
bundle* default_data = bundle_create();
+ bundle_add_str(default_data, "TEST_KEY", "TEST_DATA");
bundle_raw* raw = nullptr;
int len = 0;
ret = bundle_encode(default_data, &raw, &len);
#include <gtest/gtest.h>
#include <gmock/gmock.h>
#include <watchface-complication.h>
+#include <watchface-complication-internal.h>
#include <watchface-complication-provider.h>
#include "watchface-complication/complication.h"
EXPECT_EQ(WATCHFACE_COMPLICATION_ERROR_PROVIDER_NOT_AVAILABLE, ret);
}
+TEST_F(CWC, get_default_data)
+{
+ int comp_id = 777;
+ int ret = watchface_complication_create(comp_id,
+ "org.tizen.gmock_comp_provider/test",
+ WATCHFACE_COMPLICATION_TYPE_SHORT_TEXT,
+ WATCHFACE_COMPLICATION_TYPE_SHORT_TEXT,
+ WATCHFACE_COMPLICATION_EVENT_TAP,
+ &complication_);
+ bundle *default_data;
+ ret = watchface_complication_get_default_data(
+ "org.tizen.gmock_comp_provider/test",
+ WATCHFACE_COMPLICATION_TYPE_SHORT_TEXT, &default_data);
+ EXPECT_EQ(WATCHFACE_COMPLICATION_ERROR_NONE, ret);
+
+ char *text;
+ bundle_get_str(default_data, "TEST_KEY", &text);
+ EXPECT_STREQ(text, "TEST_DATA");
+ bundle_free(default_data);
+}
+
}
#include <string>
-#include "watchface-complication/include/watchface-complication-internal.h"
+#include "watchface-complication/complication-internal.h"
namespace watchface_complication {
#include "watchface-complication-provider/complication-provider.h"
#include "watchface-complication-provider/include/watchface-complication-provider.h"
#include "watchface-complication/db-manager.h"
-#include "watchface-complication/include/watchface-complication-internal.h"
+#include "watchface-complication/complication-internal.h"
#ifdef LOG_TAG
#undef LOG_TAG
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/watchface-editable-internal.h DESTINATION include/${PROJECT_NAME})
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/watchface-editable.h DESTINATION include/${PROJECT_NAME})
-INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/watchface-complication.h DESTINATION include/${PROJECT_NAME})
\ No newline at end of file
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/watchface-complication.h DESTINATION include/${PROJECT_NAME})
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/watchface-complication-internal.h DESTINATION include/${PROJECT_NAME})
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/complication-internal.h DESTINATION include/${PROJECT_NAME})
\ No newline at end of file
#include <string>
#include <memory>
-#include "watchface-complication/include/watchface-complication-internal.h"
+#include "watchface-complication/complication-internal.h"
#include "watchface-common/watchface-exception.h"
#include "watchface-complication/gdbus-interface.h"
#include "watchface-complication/package-manager-interface.h"
#include <string>
-#include "watchface-complication/include/watchface-complication-internal.h"
+#include "watchface-complication/complication-internal.h"
namespace watchface_complication {
--- /dev/null
+/*
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __TIZEN_APPFW_COMPLICATION_INTERNAL_H__
+#define __TIZEN_APPFW_COMPLICATION_INTERNAL_H__
+
+#include <watchface-common.h>
+
+namespace watchface_complication {
+
+typedef enum {
+ NoData = WATCHFACE_COMPLICATION_TYPE_NO_DATA,
+ ShortText = WATCHFACE_COMPLICATION_TYPE_SHORT_TEXT,
+ LongText = WATCHFACE_COMPLICATION_TYPE_LONG_TEXT,
+ RangedValue = WATCHFACE_COMPLICATION_TYPE_RANGED_VALUE,
+ Time = WATCHFACE_COMPLICATION_TYPE_TIME,
+ Icon = WATCHFACE_COMPLICATION_TYPE_ICON,
+ Image = WATCHFACE_COMPLICATION_TYPE_IMAGE
+} ComplicationType;
+
+typedef enum {
+ EventNone = WATCHFACE_COMPLICATION_EVENT_NONE,
+ EventTap = WATCHFACE_COMPLICATION_EVENT_TAP,
+ EventDoubleTap = WATCHFACE_COMPLICATION_EVENT_DOUBLE_TAP
+} ComplicationEventType;
+
+} // namespace watchface_complication
+
+#endif /* __TIZEN_APPFW_COMPLICATION_INTERNAL_H__ */
#include "watchface-complication/complication-implementation.h"
#include "watchface-common/watchface-util.h"
#include "watchface-common/watchface-common-internal.h"
-#include "watchface-complication/include/watchface-complication-internal.h"
+#include "watchface-complication/complication-internal.h"
#include <iostream>
return WATCHFACE_COMPLICATION_ERROR_NONE;
}
+int Complication::GetDefaultData(
+ string provider_id, int type, Bundle* default_data) {
+ std::list<std::string> privlege_list =
+ DBManager::GetRequiredPrivilegeList(provider_id);
+ std::string not_supported_privileges = "";
+ for (auto& i : privlege_list) {
+ if (util::CheckPrivilege(i.c_str()) != 0) {
+ LOGE("Privilege(%s) required for (%s)", i.c_str(), provider_id.c_str());
+ return WATCHFACE_COMPLICATION_ERROR_PERMISSION_DENIED;
+ }
+ }
+
+ std::unique_ptr<Bundle> ptr =
+ DBManager::GetDefaultData(provider_id.c_str(), type);
+ if (ptr == nullptr)
+ return WATCHFACE_COMPLICATION_ERROR_DB;
+ *default_data = *ptr;
+ return WATCHFACE_COMPLICATION_ERROR_NONE;
+}
+
} // namespace watchface_complication
static const char* GetSupportedEventsErrorKey();
static const char* GetPrivilegeErrorKey();
static gboolean PeriodCallback(gpointer user_data);
+ static int GetDefaultData(
+ std::string provider_id, int type, tizen_base::Bundle* data);
private:
class Impl;
#include <pkgmgr_installer_info.h>
#include <vconf.h>
-#include "watchface-complication/include/watchface-complication-internal.h"
+#include "watchface-complication/complication-internal.h"
#include "watchface-complication/db-manager.h"
#include "watchface-common/watchface-util.h"
#include "watchface-complication/editables-container.h"
#include "watchface-complication/editables-container-implementation.h"
-#include "watchface-complication/include/watchface-complication-internal.h"
+#include "watchface-complication/complication-internal.h"
#include "watchface-common/watchface-util.h"
#include "watchface-complication/gdbus-interface.h"
#define __TIZEN_APPFW_WATCHFACE_COMPLICATION_INTERNAL_H__
#include <watchface-common.h>
+#include <bundle.h>
-namespace watchface_complication {
+#ifdef __cplusplus
+extern "C" {
+#endif
-typedef enum {
- NoData = WATCHFACE_COMPLICATION_TYPE_NO_DATA,
- ShortText = WATCHFACE_COMPLICATION_TYPE_SHORT_TEXT,
- LongText = WATCHFACE_COMPLICATION_TYPE_LONG_TEXT,
- RangedValue = WATCHFACE_COMPLICATION_TYPE_RANGED_VALUE,
- Time = WATCHFACE_COMPLICATION_TYPE_TIME,
- Icon = WATCHFACE_COMPLICATION_TYPE_ICON,
- Image = WATCHFACE_COMPLICATION_TYPE_IMAGE
-} ComplicationType;
-
-typedef enum {
- EventNone = WATCHFACE_COMPLICATION_EVENT_NONE,
- EventTap = WATCHFACE_COMPLICATION_EVENT_TAP,
- EventDoubleTap = WATCHFACE_COMPLICATION_EVENT_DOUBLE_TAP
-} ComplicationEventType;
-
-} // namespace watchface_complication
+int watchface_complication_get_default_data(const char *provider_id,
+ watchface_complication_type_e type, bundle **default_data);
+#ifdef __cplusplus
+}
+#endif
#endif /* __TIZEN_APPFW_WATCHFACE_COMPLICATION_INTERNAL_H__ */
#include <dlog.h>
#include "watchface-complication/include/watchface-complication.h"
-#include "watchface-complication/include/watchface-complication-internal.h"
+#include "watchface-complication/complication-internal.h"
#include "watchface-complication/complication.h"
#include "watchface-complication/shared-handle.h"
#include "watchface-common/watchface-util.h"
return ptr.get()->ClearAllowedList();
}
+
+extern "C" EXPORT_API int watchface_complication_get_default_data(
+ const char* provider_id, watchface_complication_type_e type,
+ bundle** default_data) {
+ if (!watchface_complication::util::CheckWatchFeatureEnabled())
+ return WATCHFACE_COMPLICATION_ERROR_NOT_SUPPORTED;
+
+ if (default_data == nullptr || provider_id == nullptr ||
+ !util::CheckComplicationType(type) ||
+ type == WATCHFACE_COMPLICATION_TYPE_NO_DATA) {
+ LOGE("Invalid param");
+ return WATCHFACE_COMPLICATION_ERROR_INVALID_PARAMETER;
+ }
+
+ Bundle data;
+ int ret = Complication::GetDefaultData(provider_id, type, &data);
+ if (ret != WATCHFACE_COMPLICATION_ERROR_NONE)
+ return ret;
+
+ *default_data = bundle_dup(data.GetHandle());
+ return WATCHFACE_COMPLICATION_ERROR_NONE;
+}