#include <pkgmgr-info.h>
#include <pkgmgr_installer_info.h>
#include <bundle.h>
+#include <bundle_cpp.h>
#include "watchface-complication/include/watchface-complication-internal.h"
#include "watchface-complication/include/watchface-complication.h"
#define DEFAULT_IMAGE "default-image"
#define DEFAULT_EXTRA_DATA "default-extra-data"
+using namespace std;
+using namespace tizen_base;
struct support_event_tag_map {
const char* name;
}
static int _get_time_value(const char* time_type, const char* time_val,
- char* prev_value, char** default_value) {
+ string prev_value, char** default_value) {
time_t rawtime;
struct tm timeinfo;
return WATCHFACE_COMPLICATION_ERROR_INVALID_PARAMETER;
}
- if (prev_value == NULL)
+ if (prev_value.empty())
time(&rawtime);
else
- rawtime = strtol(prev_value, NULL, 10);
+ rawtime = stoi(prev_value);
localtime_r(&rawtime, &timeinfo);
if (strcmp(DEFAULT_HOUR, time_type) == 0) {
static int _parse_support_type(xmlNode* node, sqlite3* db, const char* pkgid,
const char* appid, const char* providerid, int period, bool trusted) {
int ret;
- int idx;
- int support_type = 0;
-
- xmlNode* tmp;
- xmlNode* tmpdata;
- sqlite3_stmt* stmt = NULL;
-
- bundle* default_data = NULL;
- bundle_raw* raw = NULL;
- int len = 0;
- const char* bundle_key;
- char* default_value = NULL;
- char* dup_val = NULL;
- char* prev_value;
+ sqlite3_stmt* stmt = nullptr;
static const char query[] =
"INSERT INTO complication_provider ( "
goto out;
}
+ xmlNode* tmp;
for (tmp = node->children; tmp; tmp = tmp->next) {
if (tmp->children == NULL
|| tmp->children->content == NULL)
continue;
- support_type = _get_support_type_tag(tmp);
+ int support_type = _get_support_type_tag(tmp);
if (!support_type) {
LOGE("not supported type");
goto out;
}
- default_data = bundle_create();
- if (default_data == NULL) {
- LOGE("bundle create error");
- goto out;
- }
-
+ xmlNode* tmpdata;
+ Bundle default_data;
for (tmpdata = tmp->children; tmpdata; tmpdata = tmpdata->next) {
- if (tmpdata->children != NULL
- && tmpdata->children->content != NULL) {
- if (!_is_valid_element(support_type, (char*)tmpdata->name))
- goto out;
+ if (tmpdata->children == nullptr || tmpdata->children->content == nullptr)
+ continue;
+ if (!_is_valid_element(support_type, (char*)tmpdata->name))
+ goto out;
+
+ const char* bundle_key = _get_bundle_key((const char*)tmpdata->name);
+ if (bundle_key == nullptr) {
+ LOGE("wrong element name (%s)", (const char*)tmpdata->name);
+ goto out;
+ }
- bundle_key = _get_bundle_key((const char*)tmpdata->name);
- if (bundle_key == NULL) {
- LOGE("wrong element name (%s)", (const char*)tmpdata->name);
+ string default_value;
+ if (strcmp(bundle_key, TIME_KEY) == 0) {
+ string prev_value = default_data.GetString(TIME_KEY);
+
+ char* dup_val = nullptr;
+ ret = _get_time_value(
+ (const char*)tmpdata->name,
+ (const char*)tmpdata->children->content,
+ prev_value, &dup_val);
+ if (ret != WATCHFACE_COMPLICATION_ERROR_NONE)
goto out;
- }
-
- if (strcmp(bundle_key, TIME_KEY) == 0) {
- prev_value = NULL;
- bundle_get_str(default_data, TIME_KEY, &prev_value);
- ret = _get_time_value(
- (const char*)tmpdata->name,
- (const char*)tmpdata->children->content,
- prev_value, &dup_val);
- if (ret != WATCHFACE_COMPLICATION_ERROR_NONE)
- goto out;
-
- default_value = dup_val;
- if (prev_value)
- bundle_del(default_data, TIME_KEY);
- } else {
- default_value = reinterpret_cast<char*>(tmpdata->children->content);
- }
-
- ret = bundle_add_str(default_data, bundle_key, default_value);
+
+ default_value = string(dup_val);
free(dup_val);
- dup_val = NULL;
- if (ret != BUNDLE_ERROR_NONE) {
- LOGE("bundle add error : %d", ret);
- goto out;
- }
+
+ if (!prev_value.empty())
+ default_data.Delete(TIME_KEY);
+ } else {
+ default_value =
+ string(reinterpret_cast<char*>(tmpdata->children->content));
}
- }
- ret = bundle_encode(default_data, &raw, &len);
- if (ret != BUNDLE_ERROR_NONE) {
- LOGE("bundle encode error %d", ret);
- goto out;
+ ret = default_data.Add(bundle_key, default_value);
+ if (ret != BUNDLE_ERROR_NONE) {
+ LOGE("bundle add error : %d", ret);
+ goto out;
+ }
}
- idx = 1;
-
+ int idx = 1;
ret = sqlite3_bind_text(stmt, idx++, pkgid, -1, SQLITE_TRANSIENT);
if (ret != SQLITE_OK) {
LOGE("sqlite3_bind_text() error: %d(%s)", ret, sqlite3_errmsg(db));
goto out;
}
- ret = sqlite3_bind_text(stmt, idx, (char*)raw, -1, SQLITE_TRANSIENT);
+ ret = sqlite3_bind_text(stmt, idx,
+ reinterpret_cast<char*>(default_data.ToRaw().first.get()),
+ -1, SQLITE_TRANSIENT);
if (ret != SQLITE_OK) {
LOGE("sqlite3_bind_text() error: %d(%s)", ret, sqlite3_errmsg(db));
goto out;
}
sqlite3_clear_bindings(stmt);
-
- if (raw) {
- free(raw);
- raw = NULL;
- }
-
- if (default_data) {
- bundle_free(default_data);
- default_data = NULL;
- }
}
ret = 0;
out:
- if (default_data)
- bundle_free(default_data);
-
- if (raw)
- free(raw);
-
if (stmt)
sqlite3_finalize(stmt);
+++ /dev/null
-/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
- *
- * 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.
- */
-
-#include <stdbool.h>
-#include <stdexcept>
-#include <iostream>
-#include <glib.h>
-#include <dlog.h>
-
-#include <memory>
-#include <string>
-#include <list>
-
-#include <gtest/gtest.h>
-#include <gmock/gmock.h>
-
-#include "watchface-complication/complication-bundle.h"
-#include "watchface-complication/complication-connector.h"
-
-using namespace std;
-using namespace watchface_complication;
-
-class BUNDLE : public ::testing::Test {
- public:
- Bundle *b = nullptr;
- virtual void SetUp() {
- b = new Bundle();
- }
- virtual void TearDown() {
- delete b;
- }
-};
-
-TEST_F(BUNDLE, Create1)
-{
- EXPECT_NE(BUNDLE::b, nullptr);
-}
-
-TEST_F(BUNDLE, Create2)
-{
- int len = 0;
- bundle *data;
- bundle_raw *raw_data;
-
- data = bundle_create();
- bundle_encode(data, &raw_data, &len);
-
- Bundle *b = new Bundle(std::string(reinterpret_cast<char*>(raw_data)));
- EXPECT_NE(b, nullptr);
-
- bundle_free(data);
- free(raw_data);
- delete b;
-}
-
-TEST_F(BUNDLE, Create3)
-{
- bundle *data;
-
- data = bundle_create();
-
- Bundle *b = new Bundle(data);
- EXPECT_NE(b, nullptr);
-
- bundle_free(data);
- delete b;
-}
-
-TEST_F(BUNDLE, GetRaw)
-{
- EXPECT_NE(BUNDLE::b->GetConstRaw(), nullptr);
- EXPECT_NE(BUNDLE::b->GetRaw(), nullptr);
-}
-
-TEST_F(BUNDLE, ToString)
-{
- EXPECT_NE(BUNDLE::b->ToString(), "");
-}
-
-TEST_F(BUNDLE, Copy)
-{
- Bundle b;
- bundle_add_str(b.GetRaw(), "TEST_KEY", "TEST_VALUE");
-
- char* value;
- Bundle b2 = b;
- bundle_get_str(b2.GetRaw(), "TEST_KEY", &value);
- EXPECT_STREQ(value, "TEST_VALUE");
-}
-
-TEST_F(BUNDLE, Copy2)
-{
- Bundle b;
- bundle_add_str(b.GetRaw(), "TEST_KEY", "TEST_VALUE");
-
- char* value;
- Bundle b2;
- b2 = b;
- bundle_get_str(b2.GetRaw(), "TEST_KEY", &value);
- EXPECT_STREQ(value, "TEST_VALUE");
-}
-
-TEST_F(BUNDLE, Move)
-{
- Bundle b;
- bundle_add_str(b.GetRaw(), "TEST_KEY", "TEST_VALUE");
-
- char* value;
- Bundle b2 = std::move(b);
- bundle_get_str(b2.GetRaw(), "TEST_KEY", &value);
- EXPECT_STREQ(value, "TEST_VALUE");
-}
-
-TEST_F(BUNDLE, Move2)
-{
- Bundle b;
- bundle_add_str(b.GetRaw(), "TEST_KEY", "TEST_VALUE");
-
- char* value;
- Bundle b2;
- b2 = std::move(b);
- bundle_get_str(b2.GetRaw(), "TEST_KEY", &value);
- EXPECT_STREQ(value, "TEST_VALUE");
-}
\ No newline at end of file
TEST_F(WCP, GetProviderId)
{
- EXPECT_EQ(WCP::provider->GetProviderId(), providerId.c_str());
+ EXPECT_STREQ(WCP::provider->GetProviderId().c_str(), providerId.c_str());
}
using namespace std;
+using namespace tizen_base;
using namespace watchface_complication;
namespace {
GMainLoop* loop_ = NULL;
GVariant* parameters = g_variant_new("(siis)", "org.tizen.gmock_comp_provider2/test",
ShortText,
4,
- b.ToString());
+ b.ToRaw().first.get());
callback(nullptr, "org.tizen.gmock_comp_provider2",
"test path",
"test interface",
WatchComplication* comp = new WatchComplication(1, default_type, EventTap,
providerId2.c_str(), ShortText);
comp->Init();
- std::list<std::unique_ptr<Bundle>> candidates_list;
- EXPECT_EQ(comp->SetCandidates(std::move(candidates_list)), 0);
+ std::list<std::shared_ptr<Bundle>> candidates_list;
+ EXPECT_EQ(comp->SetCandidates(candidates_list), 0);
delete comp;
}
TEST_F(WC, GetCurData)
{
- const Bundle* data = WC::complication->GetCurData();
- EXPECT_NE(data, nullptr);
+ shared_ptr<Bundle> data = WC::complication->GetCurData();
+ EXPECT_NE(data.get(), nullptr);
}
TEST_F(WC, GetNthData)
{
- const Bundle* data = WC::complication->GetNthData(0);
- EXPECT_NE(data, nullptr);
+ shared_ptr<Bundle> data = WC::complication->GetNthData(0);
+ EXPECT_NE(data.get(), nullptr);
}
int __fake_pkgmgrinfo_appinfo_filter_foreach_appinfo(pkgmgrinfo_appinfo_filter_h,
WatchComplication* comp = new WatchComplication(1, default_type, EventTap,
providerId2.c_str(), ShortText);
comp->Init();
- std::list<std::unique_ptr<Bundle>> const& list = comp->GetCandidates();
+ std::list<std::shared_ptr<Bundle>> const& list = comp->GetCandidates();
for (unsigned int i = 0; i < list.size(); i++) {
comp->SetCurDataIdx(i);
- if (strcmp(comp->GetCurProviderId(), "org.tizen.gmock_comp_provider2/test") == 0)
+ if (comp->GetCurProviderId() == "org.tizen.gmock_comp_provider2/test")
break;
}
comp->not_available_ = false;
WatchComplication* comp = new WatchComplication(4, default_type, EventTap,
providerId3.c_str(), ShortText);
comp->Init();
- std::list<std::unique_ptr<Bundle>> const& list = comp->GetCandidates();
+ std::list<std::shared_ptr<Bundle>> const& list = comp->GetCandidates();
for (unsigned int i = 0; i < list.size(); i++) {
comp->SetCurDataIdx(i);
- if (strcmp(comp->GetCurProviderId(), WC::providerId2.c_str()) == 0)
+ if (comp->GetCurProviderId() == WC::providerId2)
break;
}
comp->SetTestType(WatchComplication::Error);
comp1->SetTestType(WatchComplication::Error);
RunLoop();
- EXPECT_EQ(strcmp(comp->GetCurProviderId(), WC::providerId3.c_str()), 0);
+ EXPECT_STREQ(comp->GetCurProviderId().c_str(), WC::providerId3.c_str());
delete comp;
delete comp1;
}
TEST_F(WC, GetProviderId)
{
- const Bundle* data = WC::complication->GetCurData();
- const char* provider_id = WC::complication->GetProviderId(data);
- EXPECT_EQ(strcmp(complication->GetCurProviderId(), provider_id), 0);
+ shared_ptr<Bundle> data = WC::complication->GetCurData();
+ string provider_id = WC::complication->GetProviderId(*data);
+ EXPECT_STREQ(complication->GetCurProviderId().c_str(), provider_id.c_str());
}
TEST_F(WC, GetProviderType)
{
- const Bundle* data = WC::complication->GetCurData();
-
- EXPECT_EQ(WC::complication->GetProviderType(data), WC::complication->GetCurType());
+ shared_ptr<Bundle> data = WC::complication->GetCurData();
+ EXPECT_EQ(WC::complication->GetProviderType(*data), WC::complication->GetCurType());
}
TEST_F(WC, GetSetupAppId)
TEST_F(WC, SetContext)
{
- bundle* b = bundle_create();
- bundle_add_str(b, "TEST_KEY", "TEST_VALUE");
+ Bundle* bundle = new Bundle();
+ bundle->Add("TEST_KEY", "TEST_VALUE");
- Bundle* bundle = new Bundle(b);
- bundle_free(b);
WC::complication->SetContext(std::unique_ptr<Bundle>(bundle));
std::unique_ptr<Bundle>& ctx = WC::complication->GetContext();
- char* value;
- bundle_get_str(ctx.get()->GetRaw(), "TEST_KEY", &value);
- EXPECT_STREQ(value, "TEST_VALUE");
+ string value = ctx.get()->GetString("TEST_KEY");
+ EXPECT_STREQ(value.c_str(), "TEST_VALUE");
}
TEST_F(WC, GetLastContext)
{
- bundle* b = bundle_create();
- bundle_add_str(b, "TEST_KEY", "TEST_VALUE");
+ Bundle* bundle = new Bundle();
+ bundle->Add("TEST_KEY", "TEST_VALUE");
- Bundle* bundle = new Bundle(b);
- bundle_free(b);
WC::complication->SetContext(std::unique_ptr<Bundle>(bundle));
WC::complication->UpdateLastContext();
std::unique_ptr<Bundle>& ctx = WC::complication->GetLastContext();
- char* value;
- bundle_get_str(ctx.get()->GetRaw(), "TEST_KEY", &value);
- EXPECT_STREQ(value, "TEST_VALUE");
+ string value = ctx.get()->GetString("TEST_KEY");
+ EXPECT_STREQ(value.c_str(), "TEST_VALUE");
}
TEST_F(WC, DuplicateID)
int ret = WC::complication->ApplyAllowedList(std::move(allowed_list));
EXPECT_EQ(ret, WATCHFACE_COMPLICATION_ERROR_NONE);
- std::list<std::unique_ptr<Bundle>> const& list = complication->GetCandidates();
+ std::list<std::shared_ptr<Bundle>> const& list = complication->GetCandidates();
EXPECT_EQ(1, list.size());
}
int ret = WC::complication->ClearAllowedList();
EXPECT_EQ(ret, WATCHFACE_COMPLICATION_ERROR_NONE);
- std::list<std::unique_ptr<Bundle>> const& list = complication->GetCandidates();
+ std::list<std::shared_ptr<Bundle>> const& list = complication->GetCandidates();
EXPECT_EQ(true, list.size() > 0);
}
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-#include <stdbool.h>
+#include <memory>
+#include <string>
+#include <list>
#include <stdexcept>
#include <iostream>
+
+#include <stdbool.h>
#include <glib.h>
#include <dlog.h>
-
-#include <memory>
-#include <string>
-#include <list>
+#include <bundle_cpp.h>
#include <gtest/gtest.h>
#include <gmock/gmock.h>
#include "watchface-complication/design-element.h"
-#include "watchface-complication/complication-bundle.h"
using namespace std;
+using namespace tizen_base;
using namespace watchface_complication;
class Element : public DesignElement {
class DE : public ::testing::Test {
public:
Element* element = NULL;
- std::list<std::unique_ptr<Bundle>> candidatesList;
+ std::list<std::shared_ptr<Bundle>> candidates;
virtual void SetUp() {
- candidatesList.emplace_back(std::unique_ptr<Bundle>(new Bundle()));
+ candidates.emplace_back(std::shared_ptr<Bundle>(new Bundle()));
element = new Element(0, 0);
- element->SetCandidates(std::move(candidatesList));
+ element->SetCandidates(candidates);
}
virtual void TearDown() {
delete element;
TEST_F(DE, GetCandidates)
{
- std::list<std::unique_ptr<Bundle>> const& list = DE::element->GetCandidates();
+ std::list<std::shared_ptr<Bundle>> const& list = DE::element->GetCandidates();
EXPECT_NE(list.empty(), true);
}
TEST_F(DE, GetData)
{
- const Bundle* curData = DE::element->GetCurData();
- const Bundle* nthData = DE::element->GetNthData(0);
+ shared_ptr<Bundle> curData = DE::element->GetCurData();
+ shared_ptr<Bundle> nthData = DE::element->GetNthData(0);
- EXPECT_NE(curData->GetConstRaw(), nullptr);
- EXPECT_NE(nthData->GetConstRaw(), nullptr);
+ EXPECT_NE(curData->GetHandle(), nullptr);
+ EXPECT_NE(nthData->GetHandle(), nullptr);
}
TEST_F(DE, DataIdx)
TEST_F(DE, SetContext)
{
- bundle* b = bundle_create();
- bundle_add_str(b, "TEST_KEY", "TEST_VALUE");
-
- Bundle* bundle = new Bundle(b);
- bundle_free(b);
+ Bundle* bundle = new Bundle();
+ bundle->Add("TEST_KEY", "TEST_VALUE");
DE::element->SetContext(std::unique_ptr<Bundle>(bundle));
std::unique_ptr<Bundle>& ctx = DE::element->GetContext();
- char* value;
- bundle_get_str(ctx.get()->GetRaw(), "TEST_KEY", &value);
- EXPECT_STREQ(value, "TEST_VALUE");
+ string value = ctx.get()->GetString("TEST_KEY");
+ EXPECT_STREQ(value.c_str(), "TEST_VALUE");
}
TEST_F(DE, GetLastContext)
{
- bundle* b = bundle_create();
- bundle_add_str(b, "TEST_KEY", "TEST_VALUE");
-
- Bundle* bundle = new Bundle(b);
- bundle_free(b);
+ Bundle* bundle = new Bundle();
+ bundle->Add("TEST_KEY", "TEST_VALUE");
DE::element->SetContext(std::unique_ptr<Bundle>(bundle));
DE::element->UpdateLastContext();
std::unique_ptr<Bundle>& ctx = DE::element->GetLastContext();
- char* value;
- bundle_get_str(ctx.get()->GetRaw(), "TEST_KEY", &value);
- EXPECT_STREQ(value, "TEST_VALUE");
+ string value = ctx.get()->GetString("TEST_KEY");
+ EXPECT_STREQ(value.c_str(), "TEST_VALUE");
}
\ No newline at end of file
#include <memory>
#include <string>
#include <list>
+#include <vector>
#include <gtest/gtest.h>
#include <gmock/gmock.h>
#include "unittest/mock/pkgmgr_mock.h"
using namespace std;
+using namespace tizen_base;
using namespace watchface_complication;
namespace {
unsigned int event_timer__;
class EC : public ::testing::Test {
public:
MyContainer* container;
- ReceivedEditable* received;
+ shared_ptr<IEditable> received;
virtual void SetUp() {
g_dbus_connection_signal_subscribe_fake.custom_fake =
__fake_g_dbus_connection_signal_subscribe;
ec_loop_ = g_main_loop_new(nullptr, FALSE);
- bundle* data;
- bundle_raw* raw_data;
pkgmgr_client_listen_status_fake.custom_fake =
__fake_pkgmgr_client_listen_status;
- Bundle* candidate1 = new Bundle();
- Bundle* candidate2 = new Bundle();
- std::unique_ptr<const char*[]> array(new const char*[2]);
-
- data = bundle_create();
- bundle_add_str(data, "GEO_X", std::to_string(0).c_str());
- bundle_add_str(data, "GEO_Y", std::to_string(0).c_str());
- bundle_add_str(data, "GEO_W", std::to_string(100).c_str());
- bundle_add_str(data, "GEO_H", std::to_string(100).c_str());
- bundle_add_str(data, "SHAPE_TYPE",
- std::to_string(IEditable::EditableShapeType::Circle).c_str());
- bundle_add_str(data, "CUR_DATA_IDX", std::to_string(0).c_str());
- bundle_add_str(data, "NAME", "sample");
- bundle_add_str(data, "EDITABLE_ID", std::to_string(0).c_str());
- bundle_add_str(data, "SETUP_APPID", "");
-
- array.get()[0] = candidate1->ToString();
- array.get()[1] = candidate2->ToString();
-
- bundle_add_str_array(data, "CANDIDATES_LIST", array.get(), 2);
-
- int len = 0;
- bundle_encode(data, &raw_data, &len);
-
- received = new ReceivedEditable(
- std::string(reinterpret_cast<char*>(raw_data)));
+ Bundle data;
+ data.Add("GEO_X", std::to_string(0));
+ data.Add("GEO_Y", std::to_string(0));
+ data.Add("GEO_W", std::to_string(100));
+ data.Add("GEO_H", std::to_string(100));
+ data.Add("SHAPE_TYPE",
+ std::to_string(IEditable::EditableShapeType::Circle));
+ data.Add("CUR_DATA_IDX", std::to_string(0));
+ data.Add("NAME", "sample");
+ data.Add("EDITABLE_ID", std::to_string(0));
+ data.Add("SETUP_APPID", "");
+
+ Bundle candidate1;
+ Bundle candidate2;
+ vector<string> candidates_list;
+ candidates_list.push_back(
+ reinterpret_cast<char*>(candidate1.ToRaw().first.get()));
+ candidates_list.push_back(
+ reinterpret_cast<char*>(candidate2.ToRaw().first.get()));
+ data.Add("CANDIDATES_LIST", candidates_list);
+
+ received = shared_ptr<IEditable>(new ReceivedEditable(
+ reinterpret_cast<char*>(data.ToRaw().first.get())));
container = new MyContainer();
-
- delete candidate1;
- delete candidate2;
- bundle_free(data);
- free(raw_data);
}
virtual void TearDown() {
- delete received;
delete container;
if (event_timer__ != 0) {
TEST_F(EC, AddRemove)
{
- int len = 0;
- bundle* data;
- bundle_raw* raw_data;
-
- Bundle* candidate1 = new Bundle();
- Bundle* candidate2 = new Bundle();
- std::unique_ptr<const char*[]> array(new const char*[2]);
-
- data = bundle_create();
- bundle_add_str(data, "GEO_X", std::to_string(0).c_str());
- bundle_add_str(data, "GEO_Y", std::to_string(0).c_str());
- bundle_add_str(data, "GEO_W", std::to_string(100).c_str());
- bundle_add_str(data, "GEO_H", std::to_string(100).c_str());
- bundle_add_str(data, "SHAPE_TYPE",
- std::to_string(IEditable::EditableShapeType::Circle).c_str());
- bundle_add_str(data, "CUR_DATA_IDX", std::to_string(0).c_str());
- bundle_add_str(data, "NAME", "sample");
- bundle_add_str(data, "EDITABLE_ID", std::to_string(0).c_str());
- bundle_add_str(data, "SETUP_APPID", "");
-
- array.get()[0] = candidate1->ToString();
- array.get()[1] = candidate2->ToString();
- bundle_add_str_array(data, "CANDIDATES_LIST", array.get(), 2);
-
- bundle_encode(data, &raw_data, &len);
-
- ReceivedEditable* re =
- new ReceivedEditable(std::string(reinterpret_cast<char*>(raw_data)));
- std::shared_ptr<IEditable> ed = static_cast<std::shared_ptr<IEditable>>(re);
-
- delete candidate1;
- delete candidate2;
- bundle_free(data);
- free(raw_data);
-
- EXPECT_EQ(EC::container->Add(ed, 1), 0);
- EXPECT_EQ(EC::container->Remove(ed), 0);
+ EXPECT_EQ(EC::container->Add(received, 1), 0);
+ EXPECT_EQ(EC::container->Remove(received), 0);
}
guint __fake_signal_subscribe_on_update(GDBusConnection* connection,
"__EDITABLE_EDIT_READY__",
parameters);
- parameters = g_variant_new("(iis)", 0, 0, b.ToString());
+ parameters = g_variant_new("(iis)", 0, 0, b.ToRaw().first.get());
rs->OnSignal(nullptr, "org.tizen.editor",
"test path",
"test interface",
"test interface",
"__EDITABLE_EDIT_CANCEL__",
parameters);
- parameters = g_variant_new("(iis)", 0, 0, b.ToString());
+ parameters = g_variant_new("(iis)", 0, 0, b.ToRaw().first.get());
rs->OnSignal(nullptr, "org.tizen.editor",
"test path",
"test interface",
#include "watchface-complication/editables-manager.h"
using namespace std;
+using namespace tizen_base;
using namespace watchface_complication;
class EDITABLES_MANAGER : public ::testing::Test {
TEST_F(EDITABLES_MANAGER, StoreContext)
{
- bundle* b = bundle_create();
- bundle_add_str(b, "TEST_KEY", "TEST_VALUE");
-
- Bundle bundle(b);
- bundle_free(b);
+ Bundle* bundle = new Bundle();
+ bundle->Add("TEST_KEY", "TEST_VALUE");
EditablesManager::GetInst(true).StoreContext(10, "org.tizen.mock_provider/test",
bundle);
int ret = EditablesManager::GetInst(true).DeleteContext(
#include <stdexcept>
#include <iostream>
#include <glib.h>
+#include <vector>
#include <gtest/gtest.h>
#include <gmock/gmock.h>
#include "unittest/mock/cynara_mock.h"
using namespace std;
+using namespace tizen_base;
using namespace watchface_complication;
int __cynara_initialize(
class WE : public ::testing::Test {
public:
EditablesEditor* editor;
-
+ ReceivedEditable* received;
virtual void SetUp(){
cynara_initialize_fake.custom_fake = __cynara_initialize;
cynara_finish_fake.custom_fake = __cynara_finish;
cynara_check_fake.custom_fake = __cynara_check;
-
+ received = nullptr;
editor = new EditablesEditor(true);
}
virtual void TearDown(){
- delete editor;
+ if (received)
+ delete received;
+ if (editor)
+ delete editor;
}
};
TEST_F(WE, EditPreview)
{
int cur_data_idx = 1;
- int len = 0;
- bundle* data;
- bundle_raw* raw_data;
-
- data = bundle_create();
- bundle_add_str(data, "GEO_X", std::to_string(0).c_str());
- bundle_add_str(data, "GEO_Y", std::to_string(0).c_str());
- bundle_add_str(data, "GEO_W", std::to_string(100).c_str());
- bundle_add_str(data, "GEO_H", std::to_string(100).c_str());
- bundle_add_str(data, "SHAPE_TYPE", std::to_string(IEditable::EditableShapeType::Circle).c_str());
- bundle_add_str(data, "CUR_DATA_IDX", std::to_string(0).c_str());
- bundle_add_str(data, "EDITABLE_ID", std::to_string(0).c_str());
- bundle_add_str(data, "NAME", "sample");
- bundle_add_str(data, "SETUP_APPID", "");
- bundle_encode(data, &raw_data, &len);
-
- ReceivedEditable* re = new ReceivedEditable(std::string(reinterpret_cast<char*>(raw_data)));
- IEditable* ed = static_cast<IEditable*>(re);
+ Bundle data;
+ data.Add("GEO_X", std::to_string(0));
+ data.Add("GEO_Y", std::to_string(0));
+ data.Add("GEO_W", std::to_string(100));
+ data.Add("GEO_H", std::to_string(100));
+ data.Add("SHAPE_TYPE",
+ std::to_string(IEditable::EditableShapeType::Circle));
+ data.Add("CUR_DATA_IDX", std::to_string(0));
+ data.Add("NAME", "sample");
+ data.Add("EDITABLE_ID", std::to_string(0));
+ data.Add("SETUP_APPID", "");
+
+ Bundle candidate1;
+ Bundle candidate2;
+ vector<string> candidates_list;
+ candidates_list.push_back(
+ reinterpret_cast<char*>(candidate1.ToRaw().first.get()));
+ candidates_list.push_back(
+ reinterpret_cast<char*>(candidate2.ToRaw().first.get()));
+ data.Add("CANDIDATES_LIST", candidates_list);
+
+ received = new ReceivedEditable(
+ reinterpret_cast<char*>(data.ToRaw().first.get()));
+ IEditable* ed = static_cast<IEditable*>(received);
EXPECT_EQ(WE::editor->EditPreview(*ed, cur_data_idx), WATCHFACE_COMPLICATION_ERROR_EDIT_NOT_READY);
-
- delete re;
- bundle_free(data);
- free(raw_data);
}
TEST_F(WE, NotifyEditReady)
{
EXPECT_EQ(WE::editor->NotifyEditReady("sample_provider"), 0);
-}
-
-class WEL : public ::testing::Test {
- public:
- GList* editables = NULL;
- ReceivedEditable* received;
- bundle_raw* raw_data;
- int len = 0;
-
- virtual void SetUp(){
- Bundle* candidate1 = new Bundle();
- Bundle* candidate2 = new Bundle();
- std::unique_ptr<const char*[]> array(new const char*[2]);
-
- bundle* data = bundle_create();
- bundle_add_str(data, "GEO_X", std::to_string(0).c_str());
- bundle_add_str(data, "GEO_Y", std::to_string(0).c_str());
- bundle_add_str(data, "GEO_W", std::to_string(100).c_str());
- bundle_add_str(data, "GEO_H", std::to_string(100).c_str());
- bundle_add_str(data, "SHAPE_TYPE", std::to_string(IEditable::EditableShapeType::Circle).c_str());
- bundle_add_str(data, "CUR_DATA_IDX", std::to_string(0).c_str());
- bundle_add_str(data, "EDITABLE_ID", std::to_string(0).c_str());
- bundle_add_str(data, "NAME", "sample");
- bundle_add_str(data, "SETUP_APPID", "");
-
- array.get()[0] = candidate1->ToString();
- array.get()[1] = candidate2->ToString();
-
- bundle_add_str_array(data, "CANDIDATES_LIST", array.get(), 2);
-
- bundle_encode(data, &raw_data, &len);
- received = new ReceivedEditable(std::string(reinterpret_cast<char*>(raw_data)));
- editables = g_list_append(editables, received);
-
- delete candidate1;
- delete candidate2;
- bundle_free(data);
- free(raw_data);
- }
- virtual void TearDown(){
- delete received;
- g_list_free(editables);
- }
-};
\ No newline at end of file
+}
\ No newline at end of file
#include <iostream>
#include <glib.h>
#include <dlog.h>
-#include <bundle.h>
+#include <bundle_cpp.h>
#include <memory>
#include <string>
#include <list>
+#include <vector>
#include <gtest/gtest.h>
#include <gmock/gmock.h>
#include "watchface-complication/received-editable.h"
using namespace std;
+using namespace tizen_base;
using namespace watchface_complication;
class RE : public ::testing::Test {
public:
ReceivedEditable* received;
- bundle* data;
- bundle_raw* raw_data;
- int len = 0;
virtual void SetUp() {
- Bundle* candidate1 = new Bundle();
- Bundle* candidate2 = new Bundle();
- std::unique_ptr<const char*[]> array(new const char*[2]);
-
- data = bundle_create();
-
- bundle_add_str(data, "GEO_X", std::to_string(0).c_str());
- bundle_add_str(data, "GEO_Y", std::to_string(0).c_str());
- bundle_add_str(data, "GEO_W", std::to_string(100).c_str());
- bundle_add_str(data, "GEO_H", std::to_string(100).c_str());
- bundle_add_str(data, "SHAPE_TYPE", std::to_string(IEditable::EditableShapeType::Circle).c_str());
- bundle_add_str(data, "CUR_DATA_IDX", std::to_string(0).c_str());
- bundle_add_str(data, "EDITABLE_ID", std::to_string(0).c_str());
- bundle_add_str(data, "NAME", "sample");
- bundle_add_str(data, "SETUP_APPID", "org.tizen.setup");
-
- array.get()[0] = candidate1->ToString();
- array.get()[1] = candidate2->ToString();
-
- bundle_add_str_array(data, "CANDIDATES_LIST", array.get(), 2);
-
- bundle_encode(data, &raw_data, &len);
- received = new ReceivedEditable(std::string(reinterpret_cast<char*>(raw_data)));
-
- delete candidate1;
- delete candidate2;
- free(raw_data);
+ Bundle data;
+ data.Add("GEO_X", std::to_string(0).c_str());
+ data.Add("GEO_Y", std::to_string(0).c_str());
+ data.Add("GEO_W", std::to_string(100).c_str());
+ data.Add("GEO_H", std::to_string(100).c_str());
+ data.Add("SHAPE_TYPE",
+ std::to_string(IEditable::EditableShapeType::Circle).c_str());
+ data.Add("CUR_DATA_IDX", std::to_string(0).c_str());
+ data.Add("NAME", "sample");
+ data.Add("EDITABLE_ID", std::to_string(0).c_str());
+ data.Add("SETUP_APPID", "org.tizen.setup");
+
+ Bundle candidate1;
+ Bundle candidate2;
+ vector<string> candidates_list;
+ candidates_list.push_back(
+ reinterpret_cast<char*>(candidate1.ToRaw().first.get()));
+ candidates_list.push_back(
+ reinterpret_cast<char*>(candidate2.ToRaw().first.get()));
+ data.Add("CANDIDATES_LIST", candidates_list);
+
+ received = new ReceivedEditable(
+ reinterpret_cast<char*>(data.ToRaw().first.get()));
}
virtual void TearDown() {
delete received;
TEST_F(RE, GetCandidates)
{
- std::list<std::unique_ptr<Bundle>> const& list = RE::received->GetCandidates();
+ std::list<std::shared_ptr<Bundle>> const& list = RE::received->GetCandidates();
EXPECT_NE(list.empty(), true);
}
TEST_F(RE, GetData)
{
- const Bundle* curData = RE::received->GetCurData();
- const Bundle* nthData = RE::received->GetNthData(1);
+ shared_ptr<Bundle> curData = RE::received->GetCurData();
+ shared_ptr<Bundle> nthData = RE::received->GetNthData(1);
- EXPECT_NE(curData->GetConstRaw(), nullptr);
- EXPECT_NE(nthData->GetConstRaw(), nullptr);
+ EXPECT_NE(curData->GetHandle(), nullptr);
+ EXPECT_NE(nthData->GetHandle(), nullptr);
}
TEST_F(RE, DataIdx)
TEST_F(RE, SetContext)
{
- bundle* b = bundle_create();
- bundle_add_str(b, "TEST_KEY", "TEST_VALUE");
-
- Bundle* bundle = new Bundle(b);
- bundle_free(b);
+ Bundle* bundle = new Bundle();
+ bundle->Add("TEST_KEY", "TEST_VALUE");
RE::received->SetContext(std::unique_ptr<Bundle>(bundle));
std::unique_ptr<Bundle>& ctx = RE::received->GetContext();
RE::received->UpdateLastContext();
- char* value;
- bundle_get_str(ctx.get()->GetRaw(), "TEST_KEY", &value);
- EXPECT_STREQ(value, "TEST_VALUE");
+ string value = ctx.get()->GetString("TEST_KEY");
+ EXPECT_STREQ(value.c_str(), "TEST_VALUE");
}
TEST_F(RE, SetHighlight)
EXPECT_STREQ(RE::received->GetSetupAppId().c_str(), "org.tizen.setup");
}
-
TEST_F(RE, GetLastContext)
{
- bundle* b = bundle_create();
- bundle_add_str(b, "TEST_KEY", "TEST_VALUE");
-
- Bundle* bundle = new Bundle(b);
- bundle_free(b);
+ Bundle* bundle = new Bundle();
+ bundle->Add("TEST_KEY", "TEST_VALUE");
RE::received->SetContext(std::unique_ptr<Bundle>(bundle));
RE::received->UpdateLastContext();
- char* value;
-
std::unique_ptr<Bundle>& last_ctx = RE::received->GetLastContext();
- bundle_get_str(last_ctx.get()->GetRaw(), "TEST_KEY", &value);
- EXPECT_STREQ(value, "TEST_VALUE");
+ string value = last_ctx.get()->GetString("TEST_KEY");
+ EXPECT_STREQ(value.c_str(), "TEST_VALUE");
}
using namespace std;
+using namespace tizen_base;
using namespace watchface_complication;
namespace {
IGDBus::IGDBusEvent* rs = static_cast<IGDBus::IGDBusEvent*>(user_data);
Bundle b;
string sender_name = "org.tizen.gmock_comp_provider2";
- bundle_add_str(b.GetRaw(), "context", "test");
+ b.Add("context", "test");
GVariant* parameters = g_variant_new("(siis)",
- "org.tizen.gmock_comp_provider2", 1, Icon, b.ToString());
+ "org.tizen.gmock_comp_provider2", 1, Icon, b.ToRaw().first.get());
rs->OnSignal(nullptr, sender_name,
"test path",
#include "unittest/mock/aul_mock.h"
using namespace std;
+using namespace tizen_base;
using namespace watchface_complication;
namespace {
Bundle b;
char num_str[32] = {0, };
snprintf(num_str, sizeof(num_str), "%d", ShortText);
- bundle_add_str(b.GetRaw(), "__DATA_TYPE_KEY__", num_str);
- watchface_complication_provider_data_set_short_text(b.GetRaw(), "shorttext");
- watchface_complication_provider_data_set_title(b.GetRaw(), "title");
- watchface_complication_provider_data_set_icon_path(b.GetRaw(), "data/icon.png");
+ b.Add("__DATA_TYPE_KEY__", num_str);
+ watchface_complication_provider_data_set_short_text(b.GetHandle(), "shorttext");
+ watchface_complication_provider_data_set_title(b.GetHandle(), "title");
+ watchface_complication_provider_data_set_icon_path(b.GetHandle(), "data/icon.png");
+
Bundle extra;
- bundle_add_str(extra.GetRaw(), "extra_key", "extra_data");
+ extra.Add("extra_key", "extra_data");
watchface_complication_provider_data_set_extra_data(
- b.GetRaw(), extra.ToString());
+ b.GetHandle(), reinterpret_cast<char*>(extra.ToRaw().first.get()));
watchface_complication_provider_data_set_screen_reader_text(
- b.GetRaw(), "screen reader");
+ b.GetHandle(), "screen reader");
GVariant* parameters = g_variant_new("(siis)", "org.tizen.gmock_comp_provider/test",
ShortText,
777,
- b.ToString());
+ reinterpret_cast<char*>(b.ToRaw().first.get()));
rs->OnSignal(nullptr, "org.tizen.gmock_comp_provider",
"test path",
"__COMP_UPDATED__",
parameters);
- bundle_del(b.GetRaw(), "__DATA_TYPE_KEY__");
+ b.Delete("__DATA_TYPE_KEY__");
snprintf(num_str, sizeof(num_str), "%d", LongText);
- bundle_add_str(b.GetRaw(), "__DATA_TYPE_KEY__", num_str);
- watchface_complication_provider_data_set_long_text(b.GetRaw(), "longtext");
+ b.Add("__DATA_TYPE_KEY__", num_str);
+ watchface_complication_provider_data_set_long_text(b.GetHandle(), "longtext");
parameters = g_variant_new("(siis)", "org.tizen.gmock_comp_provider/test",
LongText,
777,
- b.ToString());
+ reinterpret_cast<char*>(b.ToRaw().first.get()));
rs->OnSignal(nullptr, "org.tizen.gmock_comp_provider",
"test path",
"test interface",
"__COMP_UPDATED__",
parameters);
- bundle_del(b.GetRaw(), "__DATA_TYPE_KEY__");
+ b.Delete("__DATA_TYPE_KEY__");
snprintf(num_str, sizeof(num_str), "%d", RangedValue);
- bundle_add_str(b.GetRaw(), "__DATA_TYPE_KEY__", num_str);
+ b.Add("__DATA_TYPE_KEY__", num_str);
watchface_complication_provider_data_set_ranged_value(
- b.GetRaw(), 10.0, 0.0, 100.0);
+ b.GetHandle(), 10.0, 0.0, 100.0);
parameters = g_variant_new("(siis)", "org.tizen.gmock_comp_provider/test",
RangedValue,
777,
- b.ToString());
+ reinterpret_cast<char*>(b.ToRaw().first.get()));
rs->OnSignal(nullptr, "org.tizen.gmock_comp_provider",
"test path",
"test interface",
"__COMP_UPDATED__",
parameters);
- bundle_del(b.GetRaw(), "__DATA_TYPE_KEY__");
+ b.Delete("__DATA_TYPE_KEY__");
snprintf(num_str, sizeof(num_str), "%d", Time);
- bundle_add_str(b.GetRaw(), "__DATA_TYPE_KEY__", num_str);
+ b.Add("__DATA_TYPE_KEY__", num_str);
watchface_complication_provider_data_set_timestamp(
- b.GetRaw(), 10);
+ b.GetHandle(), 10);
parameters = g_variant_new("(siis)", "org.tizen.gmock_comp_provider/test",
Time,
777,
- b.ToString());
+ reinterpret_cast<char*>(b.ToRaw().first.get()));
rs->OnSignal(nullptr, "org.tizen.gmock_comp_provider",
"test path",
"test interface",
"__COMP_UPDATED__",
parameters);
- bundle_del(b.GetRaw(), "__DATA_TYPE_KEY__");
+ b.Delete("__DATA_TYPE_KEY__");
snprintf(num_str, sizeof(num_str), "%d", Image);
- bundle_add_str(b.GetRaw(), "__DATA_TYPE_KEY__", num_str);
+ b.Add("__DATA_TYPE_KEY__", num_str);
watchface_complication_provider_data_set_image_path(
- b.GetRaw(), "data/img.png");
+ b.GetHandle(), "data/img.png");
parameters = g_variant_new("(siis)", "org.tizen.gmock_comp_provider/test",
Image,
777,
- b.ToString());
+ reinterpret_cast<char*>(b.ToRaw().first.get()));
rs->OnSignal(nullptr, "org.tizen.gmock_comp_provider",
"test path",
"test interface",
#include "unittest/mock/aul_mock.h"
using namespace std;
+using namespace tizen_base;
using namespace watchface_complication;
namespace {
"__EDITABLE_EDIT_READY__",
parameters);
- parameters = g_variant_new("(iis)", 0, 0, b.ToString());
+ parameters = g_variant_new("(iis)", 0, 0, b.ToRaw().first.get());
rs->OnSignal(nullptr, "org.tizen.editor",
"test path",
"test interface",
"test interface",
"__EDITABLE_EDIT_CANCEL__",
parameters);
- parameters = g_variant_new("(iis)", 0, 0, b.ToString());
+ parameters = g_variant_new("(iis)", 0, 0, b.ToRaw().first.get());
rs->OnSignal(nullptr, "org.tizen.editor",
"test path",
"test interface",
#include <gtest/gtest.h>
#include <gmock/gmock.h>
#include <watchface-editor.h>
+#include <vector>
#include "watchface-complication/design-element.h"
#include "watchface-complication/editables-container.h"
#include "unittest/mock/app_control_mock.h"
using namespace std;
+using namespace tizen_base;
using namespace watchface_complication;
namespace {
event_timer__ = g_timeout_add(1000, [](gpointer user_data)->gboolean {
IGDBus::IGDBusEvent* rs = static_cast<IGDBus::IGDBusEvent*>(user_data);
+ Bundle data;
+ data.Add("GEO_X", std::to_string(0));
+ data.Add("GEO_Y", std::to_string(0));
+ data.Add("GEO_W", std::to_string(100));
+ data.Add("GEO_H", std::to_string(100));
+ data.Add("SHAPE_TYPE",
+ std::to_string(IEditable::EditableShapeType::Circle));
+ data.Add("CUR_DATA_IDX", std::to_string(0));
+ data.Add("NAME", "sample");
+ data.Add("EDITABLE_ID", std::to_string(0));
+ data.Add("SETUP_APPID", "org.tizen.setup");
+
Bundle candidate1;
Bundle candidate2;
- std::unique_ptr<const char*[]> array(new const char*[2]);
- std::unique_ptr<const char*[]> ed_array(new const char*[1]);
-
- Bundle data;
- bundle_add_str(data.GetRaw(), "GEO_X", std::to_string(0).c_str());
- bundle_add_str(data.GetRaw(), "GEO_Y", std::to_string(0).c_str());
- bundle_add_str(data.GetRaw(), "GEO_W", std::to_string(100).c_str());
- bundle_add_str(data.GetRaw(), "GEO_H", std::to_string(100).c_str());
- bundle_add_str(data.GetRaw(), "SHAPE_TYPE",
- std::to_string(IEditable::EditableShapeType::Circle).c_str());
- bundle_add_str(data.GetRaw(), "CUR_DATA_IDX", std::to_string(0).c_str());
- bundle_add_str(data.GetRaw(), "NAME", "sample");
- bundle_add_str(data.GetRaw(), "EDITABLE_ID", std::to_string(0).c_str());
- bundle_add_str(data.GetRaw(), "SETUP_APPID", "org.tizen.setup");
-
-
- bundle_add_str(candidate1.GetRaw(), "__PROVIDER_ID_KEY__",
+ candidate1.Add("__PROVIDER_ID_KEY__",
"org.tizen.gmock_comp_provider2/test");
- bundle_add_str(candidate1.GetRaw(), "__PROVIDER_TYPE_KEY__", "2");
- bundle_add_str(candidate1.GetRaw(), "__PRIVILEGE_ERROR_KEY__", "err msg");
+ candidate1.Add("__PROVIDER_TYPE_KEY__", "2");
+ candidate1.Add("__PRIVILEGE_ERROR_KEY__", "err msg");
- bundle_add_str(candidate2.GetRaw(), "__PROVIDER_ID_KEY__",
+ candidate2.Add("__PROVIDER_ID_KEY__",
"org.tizen.gmock_comp_provider/test");
- bundle_add_str(candidate2.GetRaw(), "__PROVIDER_TYPE_KEY__", "4");
- bundle_add_str(candidate2.GetRaw(), "__SUPPORTED_EVENTS_ERROR_KEY__", "4");
+ candidate2.Add("__PROVIDER_TYPE_KEY__", "4");
+ candidate2.Add("__SUPPORTED_EVENTS_ERROR_KEY__", "4");
- array.get()[0] = candidate1.ToString();
- array.get()[1] = candidate2.ToString();
- bundle_add_str_array(data.GetRaw(), "CANDIDATES_LIST", array.get(), 2);
+ vector<string> candidates_list;
+ candidates_list.push_back(
+ reinterpret_cast<char*>(candidate1.ToRaw().first.get()));
+ candidates_list.push_back(
+ reinterpret_cast<char*>(candidate2.ToRaw().first.get()));
+ data.Add("CANDIDATES_LIST", candidates_list);
Bundle list_data;
- ed_array.get()[0] = data.ToString();
- bundle_add_str_array(list_data.GetRaw(), "EDITABLE_LIST", ed_array.get(), 1);
+ vector<string> editable_list;
+ editable_list.push_back(
+ reinterpret_cast<char*>(data.ToRaw().first.get()));
+ list_data.Add("EDITABLE_LIST", editable_list);
GVariant* parameters = g_variant_new("(ss)",
- "org.tizen.watch", list_data.ToString());
+ "org.tizen.watch", list_data.ToRaw().first.get());
rs->OnSignal(nullptr, "org.tizen.watch",
"test path",
parameters);
Bundle setup_ctx;
parameters = g_variant_new("(is)",
- "org.tizen.watch", setup_ctx.ToString());
+ "org.tizen.watch", setup_ctx.ToRaw().first.get());
rs->OnSignal(nullptr, "org.tizen.watch",
"test path",
"test interface",
#include <string>
#include <map>
+#include <iostream>
#include "watchface-common/watchface-util.h"
#include "watchface-common/include/watchface-common.h"
#define LOG_TAG "WATCHFACE_COMPLICATION"
+using namespace std;
+using namespace tizen_base;
namespace watchface_complication {
namespace util {
static int __cynara_check(const char* client, const char* user,
return appid;
}
+ int GetDataType(Bundle shared_data) {
+ string shared_type = shared_data.GetString(DATA_TYPE_KEY);
+ if (shared_type.empty()) {
+ LOGE("failed to get data type");
+ return WATCHFACE_COMPLICATION_ERROR_INVALID_PARAMETER;
+ }
+
+ int comp_type = stoi(shared_type);
+ if (!CheckComplicationType(comp_type)) {
+ LOGE("Invalid param for type(%d)", comp_type);
+ return WATCHFACE_COMPLICATION_ERROR_INVALID_PARAMETER;
+ }
+ return comp_type;
+ }
+
+ bool IsValidData(Bundle shared_data) {
+ int type = GetDataType(shared_data);
+ bool is_valid = true;
+
+ switch(type) {
+ case WATCHFACE_COMPLICATION_TYPE_SHORT_TEXT : {
+ if (shared_data.GetString(SHORT_TEXT_KEY).empty())
+ is_valid = false;
+ break;
+ }
+ case WATCHFACE_COMPLICATION_TYPE_LONG_TEXT : {
+ if (shared_data.GetString(LONG_TEXT_KEY).empty())
+ is_valid = false;
+ break;
+ }
+ case WATCHFACE_COMPLICATION_TYPE_RANGED_VALUE : {
+ if (shared_data.GetString(RANGE_CUR_KEY).empty() ||
+ shared_data.GetString(RANGE_MAX_KEY).empty() ||
+ shared_data.GetString(RANGE_MIN_KEY).empty())
+ is_valid = false;
+ break;
+ }
+ case WATCHFACE_COMPLICATION_TYPE_TIME : {
+ if (shared_data.GetString(TIME_KEY).empty())
+ is_valid = false;
+ break;
+ }
+ case WATCHFACE_COMPLICATION_TYPE_ICON : {
+ if (shared_data.GetString(ICON_KEY).empty())
+ is_valid = false;
+ break;
+ }
+ case WATCHFACE_COMPLICATION_TYPE_IMAGE : {
+ if (shared_data.GetString(IMAGE_KEY).empty())
+ is_valid = false;
+ break;
+ }
+ case WATCHFACE_COMPLICATION_TYPE_NO_DATA :
+ is_valid = true;
+ break;
+ default :
+ is_valid = false;
+ break;
+ }
+
+ if (!is_valid)
+ LOGE("Invalid data (%d)", type);
+ return is_valid;
+ }
+
std::string GetAppPath(const char* appid, char* path) {
char* root_path;
aul_get_app_shared_resource_path_by_appid(appid, &root_path);
#include <gio/gio.h>
#include <bundle.h>
+#include <bundle_cpp.h>
#include <string>
#include "watchface-common/include/watchface-common.h"
EXPORT_API bool CheckCertificate(const std::string& provider_app_id);
EXPORT_API std::string GetAppPath(const char* appid, char* path);
EXPORT_API int ConvertPathToAppPath(const char* appid, bundle* data);
+ EXPORT_API bool IsValidData(tizen_base::Bundle shared_data);
+ EXPORT_API int GetDataType(tizen_base::Bundle shared_data);
} // namespace util
} // namespace watchface_complication
#define WATCHFACE_COMPLICATION_PROVIDER_COMPLICATION_PROVIDER_EVENT_INTERFACE_H_
#include <string>
+#include <bundle_cpp.h>
#include "watchface-complication/include/watchface-complication-internal.h"
-#include "watchface-complication/complication-bundle.h"
namespace watchface_complication {
class EXPORT_API IComplicationProviderEvent {
public:
virtual void OnDataUpdated(const std::string& provider_id,
- ComplicationType type, const std::unique_ptr<Bundle>& data) = 0;
+ ComplicationType type,
+ const std::unique_ptr<tizen_base::Bundle>& data) = 0;
virtual void OnProviderError(const std::string& provider_id,
ComplicationType type, int error) = 0;
virtual void OnNotifyDataUpdate() = 0;
#define LOG_TAG "WATCHFACE_COMPLICATION"
#define PRIVILEGE_DATASHARING "http://tizen.org/privilege/datasharing"
+using namespace std;
+using namespace tizen_base;
namespace watchface_complication {
ComplicationProvider::ComplicationProvider(const std::string& provider_id, bool mock)
const std::string& signal_name,
GVariant* parameters) {
LOGI("%s, %s", sender_name.c_str(), signal_name.c_str());
- int complication_id;
- char* context_raw = NULL;
- int type;
- bool ret;
- bool is_valid;
- char num_str[32] = {0, };
- char* shared_data_type;
- char* sender_app_id = NULL;
-
SenderInfo* si = GetSenderInfo(sender_name, connection, parameters);
if (si == NULL)
return;
if (signal_name.compare(util::GetCmdStr(
util::CmdType::CompUpdateRequest)) == 0) {
+ char* context_raw = nullptr;
+ int type;
+ int complication_id;
+ char* sender_app_id = nullptr;
g_variant_get(parameters, "(&sii&s)", &sender_app_id,
&complication_id, &type, &context_raw);
}
LOGI("get : %s, %d, %d", sender_app_id, complication_id, type);
-
- Bundle* context_data = nullptr;
- Bundle* shared_data = nullptr;
try {
- context_data = new Bundle(std::string(context_raw));
- shared_data = new Bundle();
+ Bundle context_data(context_raw);
+ Bundle shared_data;
+ string received_type = std::to_string(type);
+ shared_data.Add(DATA_TYPE_KEY, received_type);
+
+ /* Call update request callback and fill shared data */
+ parent_->OnDataUpdateRequest(sender_app_id, (ComplicationType)type,
+ context_data, &shared_data);
+ string shared_type = shared_data.GetString(DATA_TYPE_KEY);
+ if (shared_type.empty() || shared_type != received_type) {
+ shared_data.Delete(DATA_TYPE_KEY);
+ shared_data.Add(DATA_TYPE_KEY, received_type);
+ LOGW("DATA_TYPE_KEY repaired : %s %s",
+ shared_type.c_str(), received_type.c_str());
+ }
+ if (!util::IsValidData(shared_data)) {
+ LOGE("EmitSignal failed %s %s %d %d", sender_app_id, (provider_id_).c_str(),
+ complication_id, type);
+ return;
+ }
+ util::ConvertPathToAppPath(util::GetAppId().c_str(), shared_data.GetHandle());
+ bool ret = gdbus_.get()->EmitSignal(
+ IGDBus::Complication,
+ std::string(sender_app_id),
+ provider_id_, -1,
+ util::GetCmdStr(util::CompUpdated),
+ g_variant_new("(siis)",
+ (provider_id_).c_str(),
+ type,
+ complication_id,
+ shared_data.ToRaw().first.get()));
+ if (ret == false)
+ LOGE("EmitSignal failed %s %s %d", sender_app_id, (provider_id_).c_str(),
+ complication_id);
} catch (const std::bad_alloc &ba) {
- LOGE("Bundle::Exception bad_alloc");
- if (context_data != nullptr)
- delete context_data;
- return;
- } catch (Exception &ex) {
- LOGE("%s %d", ex.what(), ex.GetErrorCode());
- if (context_data != nullptr)
- delete context_data;
- return;
- }
-
- snprintf(num_str, sizeof(num_str), "%d", type);
- bundle_add_str(shared_data->GetRaw(), DATA_TYPE_KEY, num_str);
-
- /* Call update request callback and fill shared data */
- parent_->OnDataUpdateRequest(sender_app_id, (ComplicationType)type,
- context_data, shared_data);
- delete context_data;
-
- shared_data_type = NULL;
- bundle_get_str(shared_data->GetRaw(), DATA_TYPE_KEY, &shared_data_type);
- if (shared_data_type == NULL || strcmp(shared_data_type, num_str) != 0) {
- bundle_del(shared_data->GetRaw(), DATA_TYPE_KEY);
- bundle_add_str(shared_data->GetRaw(), DATA_TYPE_KEY, num_str);
- LOGI("DATA_TYPE_KEY repaired : %s %s", shared_data_type, num_str);
- }
-
- is_valid = false;
- watchface_complication_provider_data_is_valid(shared_data->GetRaw(), &is_valid);
- if (is_valid == false) {
- LOGE("EmitSignal failed %s %s %d %d", sender_app_id, (provider_id_).c_str(),
- complication_id, type);
- delete shared_data;
+ LOGE("Exception bad_alloc");
return;
}
- util::ConvertPathToAppPath(util::GetAppId().c_str(), shared_data->GetRaw());
- ret = gdbus_.get()->EmitSignal(
- IGDBus::Complication,
- std::string(sender_app_id),
- provider_id_, -1,
- util::GetCmdStr(util::CompUpdated),
- g_variant_new("(siis)",
- (provider_id_).c_str(),
- type,
- complication_id,
- shared_data->ToString()));
- delete shared_data;
- if (ret == false)
- LOGE("EmitSignal failed %s %s %d", sender_app_id, (provider_id_).c_str(),
- complication_id);
}
}
/* LCOV_EXCL_START */
void ComplicationProvider::OnDataUpdateRequest(const std::string& sender_appid,
- ComplicationType type, const Bundle* context, Bundle* shared_data) {
+ ComplicationType type, const Bundle& context, Bundle* shared_data) {
}
/* LCOV_EXCL_STOP */
public:
void OnDataUpdateRequest(const std::string& sender_appid,
ComplicationType type,
- const Bundle* context,
- Bundle* shared_data) override;
+ const tizen_base::Bundle& context,
+ tizen_base::Bundle* shared_data) override;
int NotifyDataUpdate();
const std::string& GetProviderId() const;
#include <app_control_internal.h>
#include <dlog.h>
#include <bundle.h>
+#include <bundle_cpp.h>
#include <map>
#include <list>
#endif
#define LOG_TAG "WATCHFACE_COMPLICATION"
-#define MAX_MANDATORY_FIELDS 3
static int _add_bundle_data(bundle* shared_data, const char* key,
const char* value);
+using namespace tizen_base;
using namespace watchface_complication;
class CallbackInfo {
public:
}
void Invoke(const std::string& provider_id, const std::string& sender_appid,
- ComplicationType type, const Bundle* context,
+ ComplicationType type, const Bundle& context,
Bundle* shared_data) {
- const bundle* context_data = context->GetConstRaw();
+ const bundle* context_data = context.GetHandle();
cb_(provider_id.c_str(), sender_appid.c_str(),
static_cast<watchface_complication_type_e>(type), context_data,
- shared_data->GetRaw(), user_data_);
+ shared_data->GetHandle(), user_data_);
}
watchface_complication_provider_update_requested_cb GetCallback() {
}
void OnDataUpdateRequest(const std::string& sender_appid,
- ComplicationType type, const Bundle* context,
+ ComplicationType type, const Bundle& context,
Bundle* shared_data) override {
for (auto& i : cb_list_)
i->Invoke(GetProviderId(), sender_appid, type, context, shared_data);
};
static std::map<std::string, WatchComplicationProviderStub*> __providers;
-
-struct complication_mandatory_fields {
- watchface_complication_type_e type;
- const char* mandatory_fields[MAX_MANDATORY_FIELDS];
-};
-
extern "C" EXPORT_API int watchface_complication_provider_add_update_requested_cb(
const char* provider_id,
watchface_complication_provider_update_requested_cb cb,
static int _get_data_type(bundle* shared_data,
watchface_complication_type_e* type) {
- int ret;
- char* type_str = NULL;
-
- if (shared_data == NULL) {
- LOGE("shared_data is NULL");
- return WATCHFACE_COMPLICATION_ERROR_INVALID_PARAMETER;
- }
-
- ret = bundle_get_str(shared_data, DATA_TYPE_KEY, &type_str);
- if (ret != BUNDLE_ERROR_NONE) {
- LOGE("failed to get data type %d", ret);
- return WATCHFACE_COMPLICATION_ERROR_INVALID_PARAMETER;
- }
-
- int comp_type = strtol(type_str, NULL, 10);
- if (!util::CheckComplicationType(comp_type)) {
+ Bundle b(shared_data);
+ int data_type = util::GetDataType(b);
+ if (!util::CheckComplicationType(data_type)) {
LOGE("Invalid param");
return WATCHFACE_COMPLICATION_ERROR_INVALID_PARAMETER;
}
- *type = static_cast<watchface_complication_type_e>(comp_type);
+ *type = static_cast<watchface_complication_type_e>(data_type);
return WATCHFACE_COMPLICATION_ERROR_NONE;
}
return _add_bundle_data(shared_data, SCREEN_READER_TEXT_KEY, screen_reader_text);
}
-static struct complication_mandatory_fields _mandatory_fields[] {
- {WATCHFACE_COMPLICATION_TYPE_SHORT_TEXT, {SHORT_TEXT_KEY, NULL, NULL}},
- {WATCHFACE_COMPLICATION_TYPE_LONG_TEXT, {LONG_TEXT_KEY, NULL, NULL}},
- {WATCHFACE_COMPLICATION_TYPE_RANGED_VALUE,
- {RANGE_CUR_KEY, RANGE_MAX_KEY, RANGE_MIN_KEY}},
- {WATCHFACE_COMPLICATION_TYPE_TIME, {TIME_KEY, NULL, NULL}},
- {WATCHFACE_COMPLICATION_TYPE_ICON, {ICON_KEY, NULL, NULL}},
- {WATCHFACE_COMPLICATION_TYPE_IMAGE, {IMAGE_KEY, NULL, NULL}}
-};
-
extern "C" EXPORT_API int watchface_complication_provider_data_is_valid(
- bundle* shared_data, bool*is_valid) {
- int ret;
- int type_count;
- watchface_complication_type_e type;
- char* value = NULL;
-
+ bundle* shared_data, bool* is_valid) {
if (!watchface_complication::util::CheckWatchFeatureEnabled())
return WATCHFACE_COMPLICATION_ERROR_NOT_SUPPORTED;
return WATCHFACE_COMPLICATION_ERROR_INVALID_PARAMETER;
}
- ret = _get_data_type(shared_data, &type);
- if (ret != WATCHFACE_COMPLICATION_ERROR_NONE)
- return ret;
-
- type_count = sizeof(_mandatory_fields) /
- sizeof(struct complication_mandatory_fields);
-
- for (int i = 0; i < type_count; i++) {
- if (type == _mandatory_fields[i].type) {
- for (int idx = 0; idx < MAX_MANDATORY_FIELDS
- && _mandatory_fields[i].mandatory_fields[idx] != NULL; idx++) {
- ret = bundle_get_str(shared_data,
- _mandatory_fields[i].mandatory_fields[idx], &value);
- if (ret != BUNDLE_ERROR_NONE) {
- LOGE("Invalid data, missing field : %s",
- _mandatory_fields[i].mandatory_fields[idx]);
- *is_valid = false;
- return WATCHFACE_COMPLICATION_ERROR_NONE;
- }
- }
- *is_valid = true;
- return WATCHFACE_COMPLICATION_ERROR_NONE;
- }
- }
+ Bundle b(shared_data, false, false);
+ int result = util::GetDataType(b);
+ if (!util::CheckComplicationType(result))
+ return WATCHFACE_COMPLICATION_ERROR_INVALID_PARAMETER;
+ *is_valid = util::IsValidData(b);
- return WATCHFACE_COMPLICATION_ERROR_INVALID_PARAMETER;
+ return WATCHFACE_COMPLICATION_ERROR_NONE;
}
static int _get_value_from_touch_launch_data(app_control_h handle,
+++ /dev/null
-/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
- *
- * 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.
- */
-
-#include <dlog.h>
-
-#include "watchface-complication/complication-bundle.h"
-#include "watchface-common/watchface-exception.h"
-
-#ifdef LOG_TAG
-#undef LOG_TAG
-#endif
-
-#define LOG_TAG "WATCHFACE_COMPLICATION"
-using std::string;
-namespace watchface_complication {
-
-Bundle::Bundle() {
- LOGE("create bundle !!");
- raw_ = bundle_create();
- if (raw_ == NULL)
- THROW(WATCHFACE_COMPLICATION_ERROR_OUT_OF_MEMORY);
-}
-
-Bundle::Bundle(std::string raw) {
- if (!raw.empty()) {
- raw_ = bundle_decode(reinterpret_cast<const bundle_raw*>(raw.c_str()),
- raw.length());
- if (raw_ == NULL) {
- int ret = get_last_result();
- if (ret == BUNDLE_ERROR_OUT_OF_MEMORY)
- THROW(WATCHFACE_COMPLICATION_ERROR_OUT_OF_MEMORY);
- else
- THROW(WATCHFACE_COMPLICATION_ERROR_INVALID_PARAMETER);
- }
- } else {
- raw_ = bundle_create();
- if (raw_ == NULL)
- THROW(WATCHFACE_COMPLICATION_ERROR_OUT_OF_MEMORY);
- }
-}
-
-Bundle::Bundle(bundle* raw) {
- raw_ = bundle_dup(raw);
- if (raw_ == NULL)
- THROW(WATCHFACE_COMPLICATION_ERROR_OUT_OF_MEMORY);
-}
-
-Bundle::Bundle(Bundle&& b) : raw_(b.raw_) {
- b.raw_ = nullptr;
-}
-
-Bundle& Bundle::operator = (Bundle&& b) {
- raw_ = b.raw_;
- b.raw_ = nullptr;
- return *this;
-}
-
-Bundle::Bundle(const Bundle& b) : raw_(bundle_dup(b.raw_)) {}
-Bundle& Bundle::operator = (const Bundle& b) {
- raw_ = bundle_dup(b.raw_);
- if (raw_ == NULL)
- THROW(WATCHFACE_COMPLICATION_ERROR_OUT_OF_MEMORY);
- return *this;
-}
-
-const bundle* Bundle::GetConstRaw() const {
- return raw_;
-}
-
-bundle* Bundle::GetRaw() {
- return raw_;
-}
-
-const char* Bundle::ToString() {
- int str_len = 0;
- bundle_raw* temp;
-
- if (str_raw_ != nullptr) {
- free(str_raw_);
- str_raw_ = nullptr;
- }
-
- if (bundle_encode(raw_, &temp, &str_len) != BUNDLE_ERROR_NONE)
- THROW(WATCHFACE_COMPLICATION_ERROR_OUT_OF_MEMORY);
-
- str_raw_ = reinterpret_cast<char*>(temp);
- return str_raw_;
-}
-
-Bundle::~Bundle() {
- bundle_free(raw_);
- free(str_raw_);
- str_raw_ = nullptr;
- raw_ = nullptr;
-}
-
-} // namespace watchface_complication
+++ /dev/null
-/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
- *
- * 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 WATCHFACE_COMPLICATION_COMPLICATION_BUNDLE_H_
-#define WATCHFACE_COMPLICATION_COMPLICATION_BUNDLE_H_
-
-#include <bundle.h>
-
-#include <watchface-common.h>
-
-#include <string>
-
-namespace watchface_complication {
-
-class EXPORT_API Bundle {
- public:
- Bundle();
- explicit Bundle(std::string raw);
- explicit Bundle(bundle* raw);
- ~Bundle();
- Bundle(const Bundle&);
- Bundle& operator=(const Bundle&);
-
- Bundle(Bundle && other);
- Bundle& operator=(Bundle && other);
-
- const bundle* GetConstRaw() const;
- bundle* GetRaw();
- const char* ToString();
- private:
- bundle* raw_ = NULL;
- char* str_raw_ = NULL;
-};
-
-} // namespace watchface_complication
-
-#endif // WATCHFACE_COMPLICATION_COMPLICATION_BUNDLE_H_
#define WATCHFACE_COMPLICATION_COMPLICATION_EVENT_INTERFACE_H_
#include <string>
+#include <bundle_cpp.h>
#include "watchface-complication/include/watchface-complication-internal.h"
-#include "watchface-complication/complication-bundle.h"
namespace watchface_complication {
public:
virtual void OnDataUpdateRequest(const std::string& sender_appid,
ComplicationType type,
- const Bundle* context,
- Bundle* shared_data) = 0;
+ const tizen_base::Bundle& context,
+ tizen_base::Bundle* shared_data) = 0;
};
} // namespace watchface_complication
#include <gio/gio.h>
#include <dlog.h>
+#include <bundle_cpp.h>
#include <memory>
#include <string>
void RestoreStateOrSetDefault();
int StoreSetting(int comp_id, std::string& provider_id,
ComplicationType type);
- std::unique_ptr<Bundle> LoadSetting();
+ std::unique_ptr<tizen_base::Bundle> LoadSetting();
int AddCandidate(std::string provider_id, int type);
int AddCandidates(std::string provider_id, int types);
int AddCandidates(int types);
ComplicationType cur_type_;
std::string last_provider_id_;
ComplicationType last_type_ = NoData;
- std::list<std::unique_ptr<Bundle>> candidates_list_;
+ std::list<std::shared_ptr<tizen_base::Bundle>> candidates_list_;
std::list<std::unique_ptr<ProviderInfo>> allowed_list_;
std::list<std::string> privilege_list_;
int cur_data_idx_ = -1;
- std::unique_ptr<Bundle> context_data_ = nullptr;
- std::unique_ptr<Bundle> last_context_data_ = nullptr;
- std::unique_ptr<Bundle> last_data_ = nullptr;
+ std::unique_ptr<tizen_base::Bundle> context_data_ = nullptr;
+ std::unique_ptr<tizen_base::Bundle> last_context_data_ = nullptr;
+ std::unique_ptr<tizen_base::Bundle> last_data_ = nullptr;
int last_data_idx_ = -1;
std::string name_;
int subscribe_id_ = -1;
#include "watchface-common/watchface-common-internal.h"
#include "watchface-complication/include/watchface-complication-internal.h"
+#include <iostream>
+
#ifdef LOG_TAG
#undef LOG_TAG
#endif
#define MAX_PACKAGE_STR_SIZE 512
#define QUERY_MAXLEN 4096
+using namespace std;
+using namespace tizen_base;
namespace watchface_complication {
std::list<int> Complication::Impl::complication_id_list_;
const std::string Complication::Impl::provider_id_key_ = "__PROVIDER_ID_KEY__";
Complication::~Complication() = default;
int Complication::Impl::LoadCurProviderFromPrev() {
- char* prev_provider_id = NULL;
- char* prev_provider_type = NULL;
- std::string prev_provider_id_str;
- std::unique_ptr<Bundle> setting_data;
+ string prev_provider_type;
+ string prev_provider_id;
+ unique_ptr<Bundle> setting_data;
try {
setting_data = EditablesManager::GetInst(mock_).LoadSetting(complication_id_);
return WATCHFACE_COMPLICATION_ERROR_PROVIDER_NOT_AVAILABLE;
}
- bundle_get_str(setting_data.get()->GetRaw(), provider_id_key_.c_str(),
- &prev_provider_id);
- bundle_get_str(setting_data.get()->GetRaw(), provider_type_key_.c_str(),
- &prev_provider_type);
-
- if (prev_provider_id == NULL) {
+ prev_provider_id = setting_data->GetString(provider_id_key_);
+ prev_provider_type = setting_data->GetString(provider_type_key_);
+ if (prev_provider_id.empty()) {
LOGW("No prev provider id");
return WATCHFACE_COMPLICATION_ERROR_PROVIDER_NOT_AVAILABLE;
}
- if (prev_provider_id)
- prev_provider_id_str = std::string(prev_provider_id);
-
- LOGI("get setting from bundle %s, %s", prev_provider_id, prev_provider_type);
-
- int ret = UpdateCurProvider(prev_provider_id_str, static_cast<ComplicationType>(
- strtol((const char*)prev_provider_type, NULL, 10)));
+ LOGI("get setting from bundle %s, %s",
+ prev_provider_id.c_str(), prev_provider_type.c_str());
+ int ret = UpdateCurProvider(prev_provider_id, static_cast<ComplicationType>(
+ stoi(prev_provider_type)));
if (ret != WATCHFACE_COMPLICATION_ERROR_NONE)
return ret;
ret = impl_->LoadPeriod();
if (ret != WATCHFACE_COMPLICATION_ERROR_NONE)
return ret;
-
impl_->package_.get()->Watch(impl_.get());
impl_->default_provider_appid_ =
int Complication::Impl::StoreSetting(int comp_id, std::string& provider_id,
ComplicationType type) {
- bundle* setting_data;
- bundle_raw* raw_data = NULL;
- int raw_len;
- int ret;
- char buf[32];
-
if (provider_id.empty() && type != NoData)
return WATCHFACE_COMPLICATION_ERROR_INVALID_PARAMETER;
- setting_data = bundle_create();
- if (setting_data == NULL) {
- LOGE("bundle_create failed");
- return WATCHFACE_COMPLICATION_ERROR_OUT_OF_MEMORY;
- }
-
- snprintf(buf, sizeof(buf), "%d", static_cast<int>(type));
- bundle_add_str(setting_data, provider_id_key_.c_str(), provider_id.c_str());
- bundle_add_str(setting_data, provider_type_key_.c_str(), buf);
- bundle_encode(setting_data, &raw_data, &raw_len);
- bundle_free(setting_data);
-
+ Bundle setting_data;
+ setting_data.Add(provider_id_key_, provider_id);
+ setting_data.Add(provider_type_key_, to_string(type));
try {
- ret = EditablesManager::GetInst(mock_).StoreSetting(comp_id, raw_data);
- if (ret != WATCHFACE_COMPLICATION_ERROR_NONE) {
- free(raw_data);
+ int ret = EditablesManager::GetInst(mock_).StoreSetting(
+ comp_id, setting_data.ToRaw().first.get());
+ if (ret != WATCHFACE_COMPLICATION_ERROR_NONE)
return ret;
- }
} catch (Exception &ex) {
LOGE("%s %d", ex.what(), ex.GetErrorCode());
- free(raw_data);
return ex.GetErrorCode();
}
-
- free(raw_data);
return WATCHFACE_COMPLICATION_ERROR_NONE;
}
Complication make candidates automatically, so we don't need it
*/
int Complication::SetCandidates(
- std::list<std::unique_ptr<Bundle>> candidates_list) {
+ std::list<std::shared_ptr<Bundle>> candidates_list) {
return WATCHFACE_COMPLICATION_ERROR_NONE;
}
-std::list<std::unique_ptr<Bundle>> const& Complication::GetCandidates() const {
+std::list<std::shared_ptr<Bundle>> const& Complication::GetCandidates() const {
return impl_->candidates_list_;
}
-const Bundle* Complication::GetCurData() {
+shared_ptr<Bundle> Complication::GetCurData() {
if (static_cast<int>(impl_->candidates_list_.size()) < impl_->cur_data_idx_ + 1
|| impl_->cur_data_idx_ < 0) {
LOGE("No candidates");
- return NULL;
+ return shared_ptr<Bundle>({});
}
- std::list<std::unique_ptr<Bundle>>::iterator it
+ std::list<std::shared_ptr<Bundle>>::iterator it
= impl_->candidates_list_.begin();
LOGI("get cur data idx(%d), list_size(%zu)", impl_->cur_data_idx_,
impl_->candidates_list_.size());
- auto nx = std::next(it, impl_->cur_data_idx_);
- return nx->get();
+ return *std::next(it, impl_->cur_data_idx_);
}
-const Bundle* Complication::GetNthData(int nth) {
+shared_ptr<Bundle> Complication::GetNthData(int nth) {
if (static_cast<int>(impl_->candidates_list_.size()) <= nth || nth < 0)
- return NULL;
+ return shared_ptr<Bundle>({});
- std::list<std::unique_ptr<Bundle>>::iterator it
+ std::list<std::shared_ptr<Bundle>>::iterator it
= impl_->candidates_list_.begin();
LOGI("get nth data %d", nth);
- auto nx = std::next(it, nth);
- return nx->get();
+ return *std::next(it, nth);
}
int Complication::GetCurDataIdx() {
}
int Complication::SetCurDataIdx(int cur_data_idx) {
- char* provider_id = NULL;
- char* type = NULL;
int ret = WATCHFACE_COMPLICATION_ERROR_NONE;
-
if (impl_->cur_data_idx_ == cur_data_idx) {
LOGI("Same with cur data idx skip setting process %d, %d",
impl_->cur_data_idx_, cur_data_idx);
if (ret != WATCHFACE_COMPLICATION_ERROR_NONE)
return ret;
} else {
- const Bundle* data = GetNthData(cur_data_idx);
- if (data == NULL) {
- LOGI("GetCurData failed");
- return WATCHFACE_COMPLICATION_ERROR_NO_DATA;
- }
- bundle_get_str(const_cast<Bundle*>(data)->GetRaw(),
- impl_->provider_id_key_.c_str(), &provider_id);
- bundle_get_str(const_cast<Bundle*>(data)->GetRaw(),
- impl_->provider_type_key_.c_str(), &type);
+ shared_ptr<Bundle> data = GetNthData(cur_data_idx);
+ string provider_id = data->GetString(impl_->provider_id_key_);
+ string type = data->GetString(impl_->provider_type_key_);
- if (provider_id == NULL || type == NULL) {
+ if (provider_id.empty() || type.empty()) {
LOGI("GetCurData failed");
return WATCHFACE_COMPLICATION_ERROR_NO_DATA;
}
- ret = impl_->UpdateCurProvider(std::string(provider_id),
- static_cast<ComplicationType>(strtol(type, NULL, 10)));
+ ret = impl_->UpdateCurProvider(provider_id,
+ static_cast<ComplicationType>(stoi(type)));
if (ret != WATCHFACE_COMPLICATION_ERROR_NONE)
return ret;
impl_->cur_data_idx_ = cur_data_idx;
return impl_->UpdateProviderInfo();
}
-const char* Complication::GetCurProviderId() {
+const string Complication::GetCurProviderId() {
if (!impl_->cur_provider_id_.empty())
return impl_->cur_provider_id_.c_str();
-
- return NULL;
+ return "";
}
-const char* Complication::GetProviderId(const Bundle* candidate_data) {
- char* provider_id = NULL;
-
- if (candidate_data == NULL)
- return NULL;
-
- bundle_get_str(const_cast<Bundle*>(candidate_data)->GetRaw(),
- impl_->provider_id_key_.c_str(), &provider_id);
-
- return provider_id;
+const string Complication::GetProviderId(const Bundle& candidate_data) {
+ return candidate_data.GetString(impl_->provider_id_key_);
}
-int Complication::GetProviderType(const Bundle* candidate_data) {
- char* provider_type = NULL;
- int ret = 0;
-
- if (candidate_data == NULL)
- return ret;
-
- bundle_get_str(const_cast<Bundle*>(candidate_data)->GetRaw(),
- impl_->provider_type_key_.c_str(), &provider_type);
-
- if (provider_type)
- ret = strtol(provider_type, NULL, 10);
-
- return ret;
+int Complication::GetProviderType(const Bundle& candidate_data) {
+ string type = candidate_data.GetString(impl_->provider_type_key_);
+ if (type.empty())
+ return 0;
+ return stoi(type);
}
int Complication::GetCurType() {
if (state == OnGoing) {
LOGI("ongoing editing : %d", impl_->complication_id_);
std::unique_ptr<Bundle> ptr = nullptr;
- const char* provider_id = GetCurProviderId();
- std::string provider_id_str =
- provider_id == NULL ? "" : std::string(provider_id);
+ std::string provider_id_str = GetCurProviderId();
int type = GetCurType();
- ptr = DBManager::GetDefaultData(provider_id, type);
+ ptr = DBManager::GetDefaultData(provider_id_str.c_str(), type);
OnDataUpdated(provider_id_str, static_cast<ComplicationType>(type), ptr);
} else if (state == Complete) {
LOGI("complete editing : %d", impl_->complication_id_);
}
if (impl_->context_data_ != nullptr)
- context_data_raw = impl_->context_data_->ToString();
+ context_data_raw =
+ reinterpret_cast<const char*>(impl_->context_data_->ToRaw().first.get());
emit_ret = impl_->gdbus_.get()->EmitSignal(
IGDBus::SigType::Complication,
try {
int ret = EditablesManager::GetInst(impl_->mock_).StoreContext(
impl_->complication_id_, impl_->cur_provider_id_.c_str(),
- *impl_->context_data_.get());
+ impl_->context_data_.get());
if (ret != WATCHFACE_COMPLICATION_ERROR_NONE)
return ret;
impl_->last_context_data_.reset(
- new Bundle((impl_->context_data_.get())->GetRaw()));
+ new Bundle((impl_->context_data_.get())->GetHandle()));
} catch (Exception &ex) {
LOGE("%s %d", ex.what(), ex.GetErrorCode());
return ex.GetErrorCode();
}
int Complication::TouchLaunch(watchface_complication_event_type_e event_type) {
- const char* context_data_raw = NULL;
- int ret;
std::string provider_appid = DBManager::GetProviderAppId(
impl_->cur_provider_id_.c_str());
if (provider_appid.empty()) {
return WATCHFACE_COMPLICATION_ERROR_IO_ERROR;
}
- if (impl_->context_data_ != nullptr)
- context_data_raw = impl_->context_data_->ToString();
-
- bundle* launch_data = bundle_create();
- if (launch_data == NULL) {
- LOGE("Out of memory");
- return WATCHFACE_COMPLICATION_ERROR_OUT_OF_MEMORY;
+ Bundle launch_data;
+ launch_data.Add(TOUCH_LAUNCH_EVENT_KEY, to_string(event_type));
+ launch_data.Add(TOUCH_LAUNCH_PROVIDER_ID_KEY, impl_->cur_provider_id_);
+ launch_data.Add(TOUCH_LAUNCH_TYPE_KEY, to_string(impl_->cur_type_));
+ if (impl_->context_data_ != nullptr) {
+ launch_data.Add(TOUCH_LAUNCH_CONTEXT_KEY,
+ reinterpret_cast<char*>(impl_->context_data_->ToRaw().first.get()));
}
-
- 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());
-
- char type_str[32] = {0, };
- snprintf(type_str, sizeof(type_str), "%d", impl_->cur_type_);
- bundle_add_str(launch_data, TOUCH_LAUNCH_TYPE_KEY, type_str);
- if (context_data_raw != NULL)
- bundle_add_str(launch_data, TOUCH_LAUNCH_CONTEXT_KEY, context_data_raw);
-
- bundle_raw* raw_data = NULL;
- int raw_len;
- bundle_encode(launch_data, &raw_data, &raw_len);
- bundle_free(launch_data);
- if (raw_data == NULL) {
- LOGE("Fail to encode bundle");
- return WATCHFACE_COMPLICATION_ERROR_IO_ERROR;
- }
-
- ret = aul_complication_launch_with_extra_data(
+ int ret = aul_complication_launch_with_extra_data(
util::GetAppId().c_str(),
provider_appid.c_str(), getuid(), TOUCH_LAUNCH_DATA_KEY,
- reinterpret_cast<char*>(raw_data));
- free(raw_data);
+ reinterpret_cast<char*>(launch_data.ToRaw().first.get()));
LOGI("Touch launch the %s : %d", provider_appid.c_str(), ret);
if (ret != AUL_R_OK) {
cur_provider_id_.c_str());
try {
if (context_data_ != nullptr)
- last_context_data_.reset(new Bundle(context_data_.get()->GetRaw()));
+ last_context_data_.reset(new Bundle(context_data_.get()->GetHandle()));
} catch (...) {
LOGE("Out of memory");
return WATCHFACE_COMPLICATION_ERROR_OUT_OF_MEMORY;
int idx = 0;
for (auto& i : candidates_list_) {
- char* temp_provider_id = NULL;
- char* temp_type = NULL;
Bundle& data = *(i.get());
- bundle_get_str(data.GetRaw(), provider_id_key_.c_str(), &temp_provider_id);
- bundle_get_str(data.GetRaw(), provider_type_key_.c_str(), &temp_type);
- if (temp_provider_id != NULL && temp_type != NULL) {
- if (strcmp(temp_provider_id, cur_provider_id_.c_str()) == 0
- && strtol(temp_type, NULL, 10) == cur_type_) {
+ string provider_id = data.GetString(provider_id_key_);
+ string type = data.GetString(provider_type_key_);
+ if (!provider_id.empty() && !type.empty()) {
+ if (provider_id == cur_provider_id_ && stoi(type) == cur_type_) {
cur_data_idx_ = idx;
LOGI("find cur idx %d", idx);
return WATCHFACE_COMPLICATION_ERROR_NONE;
#define WATCHFACE_COMPLICATION_COMPLICATION_H_
#include <gio/gio.h>
+#include <bundle_cpp.h>
#include <memory>
#include <string>
};
int SetHighlight(std::unique_ptr<IEditable::Highlight> highlight) override;
IEditable::Highlight* GetHighlight() override;
- std::list<std::unique_ptr<Bundle>> const& GetCandidates() const override;
- int SetCandidates(std::list<std::unique_ptr<Bundle>> candidates_list) override;
- const Bundle* GetCurData() override;
- const Bundle* GetNthData(int nth) override;
+ std::list<std::shared_ptr<tizen_base::Bundle>> const& GetCandidates() const override;
+ int SetCandidates(std::list<std::shared_ptr<tizen_base::Bundle>> candidates_list) override;
+ std::shared_ptr<tizen_base::Bundle> GetCurData() override;
+ std::shared_ptr<tizen_base::Bundle> GetNthData(int nth) override;
int GetCurDataIdx() override;
int SetCurDataIdx(int cur_data_idx) override;
int GetLastDataIdx() override;
IEditable::EditableState state) override;
void OnDataUpdated(const std::string& provider_id,
ComplicationType type,
- const std::unique_ptr<Bundle>& data) override;
+ const std::unique_ptr<tizen_base::Bundle>& data) override;
void OnProviderError(const std::string& provider_id, ComplicationType type,
int error) override;
void OnNotifyDataUpdate() override;
void SetLabel(const std::string& name) override;
void SetState(IEditable::EditableState state) override;
IEditable::EditableState GetState() override;
- int SetContext(std::unique_ptr<Bundle> context) override;
- std::unique_ptr<Bundle>& GetContext() const override;
+ int SetContext(std::unique_ptr<tizen_base::Bundle> context) override;
+ std::unique_ptr<tizen_base::Bundle>& GetContext() const override;
int UpdateLastContext() override;
- std::unique_ptr<Bundle>& GetLastContext() const override;
+ std::unique_ptr<tizen_base::Bundle>& GetLastContext() const override;
const std::string GetSetupAppId() override;
int SendDataUpdateRequest(bool launch_option = true);
- const char* GetCurProviderId();
- const char* GetProviderId(const Bundle* candidate_data);
- int GetProviderType(const Bundle* candidate_data);
+ const std::string GetCurProviderId();
+ const std::string GetProviderId(const tizen_base::Bundle& candidate_data);
+ int GetProviderType(const tizen_base::Bundle& candidate_data);
int GetCurType();
int TouchLaunch(watchface_complication_event_type_e event_type);
int ApplyAllowedList(
#define DEFAULT_LOCALE "No Locale"
#define ROOT_USER 0
+using namespace tizen_base;
namespace watchface_complication {
DBManager::DBManager() = default;
goto out;
}
default_data = std::unique_ptr<Bundle>(new Bundle(std::string(raw_data)));
- util::ConvertPathToAppPath(provider_app_id.c_str(), default_data->GetRaw());
+ util::ConvertPathToAppPath(
+ provider_app_id.c_str(), default_data.get()->GetHandle());
}
out:
#include <gio/gio.h>
#include <sqlite3.h>
#include <watchface-common.h>
+#include <bundle_cpp.h>
#include <string>
#include <memory>
#include <list>
-#include "watchface-complication/complication-bundle.h"
-
namespace watchface_complication {
class EXPORT_API DBManager {
return type_;
}
};
- static std::unique_ptr<Bundle> GetDefaultData(const char* provider_id,
- int support_type);
+ static std::unique_ptr<tizen_base::Bundle> GetDefaultData(
+ const char* provider_id, int support_type);
static std::string GetProviderAppId(const char* provider_id);
static std::list<std::string> GetRequiredPrivilegeList(
std::string& provider_id);
#define WATCHFACE_COMPLICATION_DESIGN_ELEMENT_IMPLEMENTATION_H_
#include <gio/gio.h>
+#include <bundle_cpp.h>
#include <memory>
#include <string>
int id_ = -1;
int cur_data_idx_;
int last_data_idx_;
- std::list<std::unique_ptr<Bundle>> candidates_list_;
+ std::list<std::shared_ptr<tizen_base::Bundle>> candidates_list_;
std::unique_ptr<IEditable::Highlight> highlight_;
EditableShapeType shape_type_ = Circle;
std::string name_;
IEditable::EditableState ed_state_ = Complete;
- std::unique_ptr<Bundle> context_data_;
- std::unique_ptr<Bundle> last_context_data_ = nullptr;
+ std::unique_ptr<tizen_base::Bundle> context_data_;
+ std::unique_ptr<tizen_base::Bundle> last_context_data_ = nullptr;
bool mock_;
};
#define LOG_TAG "WATCHFACE_COMPLICATION"
#define MAX_PACKAGE_STR_SIZE 512
+using namespace std;
+using namespace tizen_base;
namespace watchface_complication {
DesignElement::DesignElement(int id, int cur_data_idx, bool mock)
}
int DesignElement::SetCandidates(
- std::list<std::unique_ptr<Bundle>> candidates_list) {
- impl_->candidates_list_ = std::move(candidates_list);
+ std::list<std::shared_ptr<Bundle>> candidates_list) {
+ impl_->candidates_list_ = candidates_list;
return WATCHFACE_COMPLICATION_ERROR_NONE;
}
-std::list<std::unique_ptr<Bundle>> const& DesignElement::GetCandidates() const {
+std::list<std::shared_ptr<Bundle>> const& DesignElement::GetCandidates() const {
return impl_->candidates_list_;
}
-const Bundle* DesignElement::GetCurData() {
+shared_ptr<Bundle> DesignElement::GetCurData() {
if (static_cast<int>(impl_->candidates_list_.size()) < impl_->cur_data_idx_ + 1
|| impl_->cur_data_idx_ < 0)
- return NULL;
- std::list<std::unique_ptr<Bundle>>::iterator it
+ return shared_ptr<Bundle>({});
+ std::list<std::shared_ptr<Bundle>>::iterator it
= impl_->candidates_list_.begin();
-
LOGI("get cur data %d", impl_->cur_data_idx_);
- auto nx = std::next(it, impl_->cur_data_idx_);
- return nx->get();
+ return *std::next(it, impl_->cur_data_idx_);
}
-const Bundle* DesignElement::GetNthData(int nth) {
+shared_ptr<Bundle> DesignElement::GetNthData(int nth) {
if (static_cast<int>(impl_->candidates_list_.size()) <= nth || nth < 0)
- return NULL;
+ return shared_ptr<Bundle>({});
- std::list<std::unique_ptr<Bundle>>::iterator it
+ std::list<std::shared_ptr<Bundle>>::iterator it
= impl_->candidates_list_.begin();
-
LOGI("get nth data %d", nth);
- auto nx = std::next(it, nth);
- return nx->get();
+ return *std::next(it, nth);
}
int DesignElement::GetCurDataIdx() {
}
int DesignElement::UpdateLastData() {
- const Bundle* cur_data = GetCurData();
- if (cur_data == NULL)
+ shared_ptr<Bundle> cur_data = GetCurData();
+ if (cur_data.get() == nullptr)
return WATCHFACE_COMPLICATION_ERROR_NO_DATA;
-
- bundle_raw* raw_data = NULL;
- int raw_len, ret;
- ret = bundle_encode(const_cast<Bundle*>(cur_data)->GetRaw(),
- &raw_data, &raw_len);
- if (ret != BUNDLE_ERROR_NONE) {
- if (ret == BUNDLE_ERROR_OUT_OF_MEMORY) {
- return WATCHFACE_COMPLICATION_ERROR_OUT_OF_MEMORY;
- } else {
- LOGE("bundle encode fail");
- return WATCHFACE_COMPLICATION_ERROR_NO_DATA;
- }
- }
try {
- ret = EditablesManager::GetInst(impl_->mock_)
- .StoreSetting(impl_->id_, raw_data);
- free(raw_data);
-
+ int ret = EditablesManager::GetInst(impl_->mock_)
+ .StoreSetting(impl_->id_, cur_data->ToRaw().first.get());
if (ret != WATCHFACE_COMPLICATION_ERROR_NONE)
return ret;
} catch (Exception &ex) {
LOGE("%s %d", ex.what(), ex.GetErrorCode());
- free(raw_data);
return ex.GetErrorCode();
}
try {
impl_->last_context_data_.reset(
- new Bundle((impl_->context_data_.get())->GetRaw()));
+ new Bundle((impl_->context_data_.get())->GetHandle()));
} catch (Exception &ex) {
LOGE("%s %d", ex.what(), ex.GetErrorCode());
return ex.GetErrorCode();
#define WATCHFACE_COMPLICATION_DESIGN_ELEMENT_H_
#include <gio/gio.h>
+#include <bundle_cpp.h>
#include <memory>
#include <string>
public:
int SetHighlight(std::unique_ptr<IEditable::Highlight> highlight) override;
IEditable::Highlight* GetHighlight() override;
- std::list<std::unique_ptr<Bundle>> const& GetCandidates() const override;
- int SetCandidates(std::list<std::unique_ptr<Bundle>> candidates_list) override;
- const Bundle* GetCurData() override;
- const Bundle* GetNthData(int nth) override;
+ std::list<std::shared_ptr<tizen_base::Bundle>> const& GetCandidates() const override;
+ int SetCandidates(std::list<std::shared_ptr<tizen_base::Bundle>> candidates_list) override;
+ std::shared_ptr<tizen_base::Bundle> GetCurData() override;
+ std::shared_ptr<tizen_base::Bundle> GetNthData(int nth) override;
int GetCurDataIdx() override;
int SetCurDataIdx(int cur_data_idx) override;
int GetLastDataIdx() override;
void SetLabel(const std::string& name) override;
void SetState(IEditable::EditableState state) override;
IEditable::EditableState GetState() override;
- int SetContext(std::unique_ptr<Bundle> context) override;
- std::unique_ptr<Bundle>& GetContext() const override;
+ int SetContext(std::unique_ptr<tizen_base::Bundle> context) override;
+ std::unique_ptr<tizen_base::Bundle>& GetContext() const override;
int UpdateLastContext() override;
- std::unique_ptr<Bundle>& GetLastContext() const override;
+ std::unique_ptr<tizen_base::Bundle>& GetLastContext() const override;
const std::string GetSetupAppId() override;
private:
#ifndef WATCHFACE_COMPLICATION_EDITABLE_INTERFACE_H_
#define WATCHFACE_COMPLICATION_EDITABLE_INTERFACE_H_
+#include <bundle_cpp.h>
#include <string>
#include <list>
#include <memory>
-#include "watchface-complication/complication-bundle.h"
#include "watchface-complication/include/watchface-editable.h"
namespace watchface_complication {
virtual ~IEditable() = default;
virtual int GetEditableId() = 0;
virtual int SetEditableId(int id) = 0;
- virtual std::list<std::unique_ptr<Bundle>> const& GetCandidates() const = 0;
- virtual int SetCandidates(std::list<std::unique_ptr<Bundle>> candidates_list) = 0;
- virtual const Bundle* GetCurData() = 0;
- virtual const Bundle* GetNthData(int nth) = 0;
+ virtual std::list<std::shared_ptr<tizen_base::Bundle>> const& GetCandidates() const = 0;
+ virtual int SetCandidates(std::list<std::shared_ptr<tizen_base::Bundle>> candidates_list) = 0;
+ virtual std::shared_ptr<tizen_base::Bundle> GetCurData() = 0;
+ virtual std::shared_ptr<tizen_base::Bundle> GetNthData(int nth) = 0;
virtual int GetCurDataIdx() = 0;
virtual int SetCurDataIdx(int cur_data_idx) = 0;
virtual int GetLastDataIdx() = 0;
virtual void SetState(EditableState state) = 0;
virtual EditableState GetState() = 0;
virtual const std::string GetSetupAppId() = 0;
- virtual int SetContext(std::unique_ptr<Bundle> context) = 0;
- virtual std::unique_ptr<Bundle>& GetContext() const = 0;
+ virtual int SetContext(std::unique_ptr<tizen_base::Bundle> context) = 0;
+ virtual std::unique_ptr<tizen_base::Bundle>& GetContext() const = 0;
virtual int UpdateLastContext() = 0;
- virtual std::unique_ptr<Bundle>& GetLastContext() const = 0;
+ virtual std::unique_ptr<tizen_base::Bundle>& GetLastContext() const = 0;
virtual Highlight* GetHighlight() = 0;
virtual int SetHighlight(std::unique_ptr<Highlight> highlight) = 0;
};
#ifndef WATCHFACE_COMPLICATION_EDITABLES_CONTAINER_EVENT_INTERFACE_H_
#define WATCHFACE_COMPLICATION_EDITABLES_CONTAINER_EVENT_INTERFACE_H_
+#include <bundle_cpp.h>
#include <string>
#include <list>
#include <memory>
-#include "watchface-complication/complication-bundle.h"
#include "watchface-complication/complication.h"
namespace watchface_complication {
virtual void OnRequestEdit(const std::string& appid,
std::list<std::unique_ptr<IEditable>> e_list) = 0;
virtual void OnSetupReply(const std::string& appid, int editable_id,
- std::unique_ptr<Bundle> context) = 0;
+ std::unique_ptr<tizen_base::Bundle> context) = 0;
};
} // namespace watchface_complication
Impl(Impl && other) = default;
Impl& operator=(Impl const& other) = default;
Impl& operator=(Impl && other) = default;
- static void FreeList(char** str_list, int size) {
- for (int i = 0; i < size; i++) {
- if (str_list[i])
- free(str_list[i]);
- }
- free(str_list);
- }
private:
EditablesContainer* parent_;
#include <glib.h>
#include <unistd.h>
#include <bundle.h>
+#include <bundle_cpp.h>
#include <bundle_internal.h>
#include <utility>
+#include <vector>
#include "watchface-complication/editables-container.h"
#include "watchface-complication/editables-container-implementation.h"
#define LOG_TAG "WATCHFACE_COMPLICATION"
#define MAX_PACKAGE_STR_SIZE 512
+using namespace std;
+using namespace tizen_base;
namespace watchface_complication {
EditablesContainer::EditablesContainer(bool mock)
i.get()->SetCurDataIdx(i.get()->GetLastDataIdx());
if (i.get()->GetLastContext().get() != NULL) {
i.get()->SetContext(std::unique_ptr<Bundle>(
- new Bundle(i.get()->GetLastContext().get()->GetRaw())));
+ new Bundle(i.get()->GetLastContext().get()->GetHandle())));
} else {
i.get()->SetContext(std::unique_ptr<Bundle>{});
}
}
int EditablesContainer::RequestEdit() {
- int list_idx = 0;
- int str_len = 0;
- bundle_raw* str_raw = NULL;
- char** list_arr;
- bool emit_ret = false;
-
if (impl_->editor_id_.empty())
return -1;
- list_arr = reinterpret_cast<char**>(calloc(impl_->ed_list_.size(),
- sizeof(char*)));
- if (list_arr == NULL) {
- LOGE("Out of memory");
- return WATCHFACE_COMPLICATION_ERROR_OUT_OF_MEMORY;
- }
-
+ vector<string> encoded_list;
for (auto& i : impl_->ed_list_) {
i.get()->SetState(IEditable::OnGoing);
- bundle* ed = bundle_create();
- if (ed == NULL) {
- impl_->FreeList(list_arr, impl_->ed_list_.size());
- LOGE("Out of memory");
- return WATCHFACE_COMPLICATION_ERROR_OUT_OF_MEMORY;
- }
-
- bundle_add(ed, "SETUP_APPID", i.get()->GetSetupAppId().c_str());
- bundle_add(ed, "EDITABLE_ID",
- std::to_string(i.get()->GetEditableId()).c_str());
+ Bundle b;
+ b.Add("SETUP_APPID", i.get()->GetSetupAppId());
+ b.Add("EDITABLE_ID",
+ std::to_string(i.get()->GetEditableId()));
int cur_data_idx = i.get()->GetCurDataIdx();
- bundle_add(ed, "CUR_DATA_IDX", std::to_string(cur_data_idx).c_str());
+ b.Add("CUR_DATA_IDX", std::to_string(cur_data_idx));
- std::unique_ptr<const char*[]> arr(
- new const char*[i->GetCandidates().size()]);
- int idx = 0;
+ vector<string> candidate_list;
for (auto& data : i.get()->GetCandidates()) {
- arr.get()[idx++] = data->ToString();
- LOGD("%s", arr.get()[idx - 1]);
+ candidate_list.push_back(
+ reinterpret_cast<char*>(data->ToRaw().first.get()));
}
- bundle_add_str_array(ed, "CANDIDATES_LIST", arr.get(),
- i.get()->GetCandidates().size());
- bundle_add(ed, "CANDIDATES_LIST_SIZE",
- std::to_string(i.get()->GetCandidates().size()).c_str());
+ b.Add("CANDIDATES_LIST", candidate_list);
+ b.Add("CANDIDATES_LIST_SIZE",
+ std::to_string(i.get()->GetCandidates().size()));
IEditable::Highlight* hi = i->GetHighlight();
if (hi) {
if (hi->GetGeometry()) {
- bundle_add(ed, "GEO_X", std::to_string(hi->GetGeometry()->GetX()).c_str());
- bundle_add(ed, "GEO_Y", std::to_string(hi->GetGeometry()->GetY()).c_str());
- bundle_add(ed, "GEO_W", std::to_string(hi->GetGeometry()->GetW()).c_str());
- bundle_add(ed, "GEO_H", std::to_string(hi->GetGeometry()->GetH()).c_str());
+ b.Add("GEO_X", std::to_string(hi->GetGeometry()->GetX()));
+ b.Add("GEO_Y", std::to_string(hi->GetGeometry()->GetY()));
+ b.Add("GEO_W", std::to_string(hi->GetGeometry()->GetW()));
+ b.Add("GEO_H", std::to_string(hi->GetGeometry()->GetH()));
LOGI("hi %d %d %d %d", hi->GetGeometry()->GetX(), hi->GetGeometry()->GetY(),
hi->GetGeometry()->GetW(), hi->GetGeometry()->GetH());
}
IEditable::EditableShapeType type = hi->GetShapeType();
- bundle_add(ed, "SHAPE_TYPE", std::to_string(type).c_str());
+ b.Add("SHAPE_TYPE", std::to_string(type));
} else {
LOGW("Null highlight info !!");
}
if (!i.get()->GetLabel().empty())
- bundle_add(ed, "NAME", i.get()->GetLabel().c_str());
+ b.Add("NAME", i.get()->GetLabel());
- bundle_encode(ed, &str_raw, &str_len);
- list_arr[list_idx++] = reinterpret_cast<char*>(str_raw);
-
- bundle_free(ed);
- }
-
- bundle* container = bundle_create();
- if (container == NULL) {
- impl_->FreeList(list_arr, impl_->ed_list_.size());
- return WATCHFACE_COMPLICATION_ERROR_OUT_OF_MEMORY;
+ encoded_list.push_back(reinterpret_cast<char*>(b.ToRaw().first.get()));
}
- bundle_add_str_array(container, "EDITABLE_LIST",
- const_cast<const char**>(list_arr), list_idx);
- impl_->FreeList(list_arr, impl_->ed_list_.size());
- bundle_encode(container, &str_raw, &str_len);
- emit_ret = impl_->gdbus_.get()->EmitSignal(
+ Bundle container;
+ container.Add("EDITABLE_LIST", encoded_list);
+ bool emit_ret = impl_->gdbus_.get()->EmitSignal(
IGDBus::SigType::Editable,
impl_->editor_id_,
impl_->editor_id_,
util::GetCmdStr(util::EditableEditRequest),
g_variant_new("(ss)",
util::GetAppId().c_str(),
- str_raw));
-
- bundle_free_encoded_rawdata(&str_raw);
- bundle_free(container);
+ container.ToRaw().first.get()));
if (emit_ret == false)
return WATCHFACE_COMPLICATION_ERROR_IO_ERROR;
#define QUERY_MAXLEN 4096
+using namespace tizen_base;
namespace watchface_complication {
EditablesManager& EditablesManager::GetInst(bool mock) {
}
int EditablesManager::StoreContext(int editable_id, const char* provider_id,
- Bundle& context) {
+ Bundle* context) {
char query[QUERY_MAXLEN] = {0, };
char* error = NULL;
sqlite3_snprintf(QUERY_MAXLEN, query,
"INSERT OR REPLACE INTO editable_context(editable_id, provider_id, " \
"context_data) VALUES (%d, %Q, %Q)",
- editable_id, provider_id, context.ToString());
+ editable_id, provider_id, context->ToRaw().first.get());
if (sqlite3_exec(impl_->context_db_, query, NULL, NULL, &error) != SQLITE_OK) {
LOGE("sqlite3_exec error(editable_id : %d, provider_id : %s, error = %s)",
editable_id, provider_id, error);
#include <gio/gio.h>
#include <watchface-common.h>
+#include <bundle_cpp.h>
#include <string>
#include <memory>
-#include "watchface-complication/complication-bundle.h"
-
namespace watchface_complication {
class EXPORT_API EditablesManager {
public:
static EditablesManager& GetInst(bool mock = false);
int StoreSetting(int editable_id, bundle_raw* raw_data);
- std::unique_ptr<Bundle> LoadSetting(int editable_id);
- int StoreContext(int editable_id, const char* provider_id, Bundle& context);
- std::unique_ptr<Bundle> LoadContext(int editable_id, const char* provider_id);
+ std::unique_ptr<tizen_base::Bundle> LoadSetting(int editable_id);
+ int StoreContext(int editable_id, const char* provider_id,
+ tizen_base::Bundle* context);
+ std::unique_ptr<tizen_base::Bundle> LoadContext(
+ int editable_id, const char* provider_id);
int DeleteContext(int editable_id, const char* provider_id);
private:
#define WATCHFACE_COMPLICATION_RECEIVED_EDITABLE_IMPLEMENTATION_H_
#include <gio/gio.h>
+#include <bundle_cpp.h>
#include <memory>
#include <string>
private:
ReceivedEditable* parent_;
int id_ = -1;
- Bundle* cur_data_ = nullptr;
- std::list<std::unique_ptr<Bundle>> candidates_list_;
+ tizen_base::Bundle* cur_data_ = nullptr;
+ std::list<std::shared_ptr<tizen_base::Bundle>> candidates_list_;
std::unique_ptr<IEditable::Highlight> highlight_;
EditableShapeType shape_type_ = Circle;
std::string name_;
int cur_data_idx_ = -1;
int last_data_idx_ = -1;
IEditable::EditableState ed_state_ = Complete;
- std::unique_ptr<Bundle> context_data_;
- std::unique_ptr<Bundle> last_context_data_ = nullptr;
+ std::unique_ptr<tizen_base::Bundle> context_data_;
+ std::unique_ptr<tizen_base::Bundle> last_context_data_ = nullptr;
};
} // namespace watchface_complication
#include <glib.h>
#include <unistd.h>
#include <utility>
+#include <vector>
#include "watchface-complication/received-editable.h"
#include "watchface-complication/received-editable-implementation.h"
#define LOG_TAG "WATCHFACE_COMPLICATION"
#define MAX_PACKAGE_STR_SIZE 512
+using namespace std;
+using namespace tizen_base;
namespace watchface_complication {
ReceivedEditable::ReceivedEditable(std::string raw)
: parent_(parent) {
if (raw.empty())
THROW(WATCHFACE_COMPLICATION_ERROR_INVALID_PARAMETER);
-
- bundle* data = NULL;
try {
- data = bundle_decode(
- reinterpret_cast<const bundle_raw*>(
- raw.c_str()), raw.length());
- const char** str_arr = NULL;
- int len = 0;
- char* val = NULL;
-
- str_arr = bundle_get_str_array(data, "CANDIDATES_LIST", &len);
- for (int i = 0; i < len; i++) {
- LOGD("%s", str_arr[i]);
- candidates_list_.emplace_back(new Bundle(str_arr[i]));
+ Bundle data(raw);
+ vector<string> candidate_list = data.GetStringArray("CANDIDATES_LIST");
+ for (auto& i : candidate_list) {
+ LOGD("%s", i.c_str());
+ candidates_list_.emplace_back(new Bundle(i));
}
- char* cur_data_idx_str = NULL;
- int ret = bundle_get_str(data, "CUR_DATA_IDX", &cur_data_idx_str);
- if (ret != BUNDLE_ERROR_NONE)
- THROW(WATCHFACE_COMPLICATION_ERROR_INVALID_PARAMETER);
- cur_data_idx_ = atoi(cur_data_idx_str);
-
- char* setup_appid = NULL;
- ret = bundle_get_str(data, "SETUP_APPID", &setup_appid);
- if (ret == BUNDLE_ERROR_NONE)
- setup_appid_ = std::string(setup_appid);
- else
- setup_appid_ = "";
-
- char* editable_id_str = NULL;
- ret = bundle_get_str(data, "EDITABLE_ID", &editable_id_str);
- if (ret != BUNDLE_ERROR_NONE)
+ string cur_data_idx_str = data.GetString("CUR_DATA_IDX");
+ if (cur_data_idx_str.empty())
THROW(WATCHFACE_COMPLICATION_ERROR_INVALID_PARAMETER);
- id_ = atoi(editable_id_str);
+ cur_data_idx_ = stoi(cur_data_idx_str);
- ret = bundle_get_str(data, "GEO_X", &val);
- if (ret == BUNDLE_ERROR_NONE) {
- int x = atoi(val);
+ setup_appid_ = data.GetString("SETUP_APPID");
+ string editable_id_str = data.GetString("EDITABLE_ID");
+ if (editable_id_str.empty())
+ THROW(WATCHFACE_COMPLICATION_ERROR_INVALID_PARAMETER);
+ id_ = stoi(editable_id_str);
- ret = bundle_get_str(data, "GEO_Y", &val);
- if (ret != BUNDLE_ERROR_NONE)
+ string val = data.GetString("GEO_X");
+ if (!val.empty()) {
+ int x = stoi(val);
+ val = data.GetString("GEO_Y");
+ if (val.empty())
THROW(WATCHFACE_COMPLICATION_ERROR_INVALID_PARAMETER);
- int y = atoi(val);
-
- ret = bundle_get_str(data, "GEO_W", &val);
- if (ret != BUNDLE_ERROR_NONE)
+ int y = stoi(val);
+ val = data.GetString("GEO_W");
+ if (val.empty())
THROW(WATCHFACE_COMPLICATION_ERROR_INVALID_PARAMETER);
- int w = atoi(val);
-
- ret = bundle_get_str(data, "GEO_H", &val);
- if (ret != BUNDLE_ERROR_NONE)
+ int w = stoi(val);
+ val = data.GetString("GEO_H");
+ if (val.empty())
THROW(WATCHFACE_COMPLICATION_ERROR_INVALID_PARAMETER);
- int h = atoi(val);
-
+ int h = stoi(val);
Geometry geo(x, y, w, h);
highlight_ = std::unique_ptr<IEditable::Highlight>(new IEditable::Highlight());
highlight_->SetGeometry(geo);
}
- ret = bundle_get_str(data, "SHAPE_TYPE", &val);
- if (ret == BUNDLE_ERROR_NONE) {
- if (highlight_.get() == NULL)
+ val = data.GetString("SHAPE_TYPE");
+ if (!val.empty()) {
+ if (highlight_.get() == nullptr) {
highlight_ = std::unique_ptr<IEditable::Highlight>(
new IEditable::Highlight());
+ }
highlight_->SetShapeType(
- static_cast<IEditable::EditableShapeType>(atoi(val)));
+ static_cast<IEditable::EditableShapeType>(stoi(val)));
}
-
- ret = bundle_get_str(data, "NAME", &val);
- if (ret != BUNDLE_ERROR_NONE)
- name_ = "";
- else
- name_ = std::string(val);
-
+ name_ = data.GetString("NAME");
} catch (const std::bad_alloc &ba) {
- if (data)
- bundle_free(data);
LOGE("ReceivedEditable::Exception bad_alloc");
THROW(WATCHFACE_COMPLICATION_ERROR_OUT_OF_MEMORY);
} catch (Exception &ex) {
- if (data)
- bundle_free(data);
LOGE("%s %d", ex.what(), ex.GetErrorCode());
THROW(ex.GetErrorCode());
}
/* LCOV_EXCL_START */
int ReceivedEditable::SetCandidates(
- std::list<std::unique_ptr<Bundle>> candidates_list) {
+ std::list<std::shared_ptr<Bundle>> candidates_list) {
return WATCHFACE_COMPLICATION_ERROR_NONE;
}
/* LCOV_EXCL_STOP */
-std::list<std::unique_ptr<Bundle>> const& ReceivedEditable::GetCandidates()
+std::list<std::shared_ptr<Bundle>> const& ReceivedEditable::GetCandidates()
const {
return impl_->candidates_list_;
}
return WATCHFACE_COMPLICATION_ERROR_NONE;
}
-const Bundle* ReceivedEditable::GetCurData() {
+shared_ptr<Bundle> ReceivedEditable::GetCurData() {
if (impl_->candidates_list_.size() == 0 || impl_->cur_data_idx_ < 0)
- return NULL;
- std::list<std::unique_ptr<Bundle>>::iterator it
+ return shared_ptr<Bundle>({});
+ std::list<std::shared_ptr<Bundle>>::iterator it
= impl_->candidates_list_.begin();
LOGI("get cur data %d", impl_->cur_data_idx_);
- auto nx = std::next(it, impl_->cur_data_idx_);
- return nx->get();
+ return *std::next(it, impl_->cur_data_idx_);
}
-const Bundle* ReceivedEditable::GetNthData(int nth) {
+shared_ptr<Bundle> ReceivedEditable::GetNthData(int nth) {
if (static_cast<int>(impl_->candidates_list_.size()) <= nth || nth < 0)
- return NULL;
+ return shared_ptr<Bundle>({});
- std::list<std::unique_ptr<Bundle>>::iterator it
+ std::list<std::shared_ptr<Bundle>>::iterator it
= impl_->candidates_list_.begin();
-
LOGI("get nth data %d", nth);
- auto nx = std::next(it, nth);
- return nx->get();
+ return *std::next(it, nth);
}
int ReceivedEditable::SetCurDataIdx(int cur_data_idx) {
try {
impl_->last_context_data_.reset(
- new Bundle((impl_->context_data_.get())->GetRaw()));
+ new Bundle((impl_->context_data_.get())->GetHandle()));
} catch (const std::bad_alloc &ba) {
LOGE("Bundle::Exception bad_alloc");
return WATCHFACE_COMPLICATION_ERROR_OUT_OF_MEMORY;
#define WATCHFACE_COMPLICATION_RECEIVED_EDITABLE_H_
#include <gio/gio.h>
+#include <bundle_cpp.h>
#include <memory>
#include <string>
public:
int SetHighlight(std::unique_ptr<IEditable::Highlight> highlight) override;
IEditable::Highlight* GetHighlight() override;
- std::list<std::unique_ptr<Bundle>> const& GetCandidates() const override;
- int SetCandidates(std::list<std::unique_ptr<Bundle>> candidates_list) override;
- const Bundle* GetCurData() override;
- const Bundle* GetNthData(int nth) override;
+ std::list<std::shared_ptr<tizen_base::Bundle>> const& GetCandidates() const override;
+ int SetCandidates(std::list<std::shared_ptr<tizen_base::Bundle>> candidates_list) override;
+ std::shared_ptr<tizen_base::Bundle> GetCurData() override;
+ std::shared_ptr<tizen_base::Bundle> GetNthData(int nth) override;
int GetCurDataIdx() override;
int SetCurDataIdx(int cur_data_idx) override;
int GetLastDataIdx() override;
void SetLabel(const std::string& name) override;
void SetState(IEditable::EditableState state) override;
IEditable::EditableState GetState() override;
- int SetContext(std::unique_ptr<Bundle> context) override;
- std::unique_ptr<Bundle>& GetContext() const override;
+ int SetContext(std::unique_ptr<tizen_base::Bundle> context) override;
+ std::unique_ptr<tizen_base::Bundle>& GetContext() const override;
int UpdateLastContext() override;
- std::unique_ptr<Bundle>& GetLastContext() const override;
+ std::unique_ptr<tizen_base::Bundle>& GetLastContext() const override;
const std::string GetSetupAppId() override;
private:
GList* allowed_list;
};
+using namespace tizen_base;
using namespace watchface_complication;
class CallbackInfo {
public:
ComplicationType type, const std::unique_ptr<Bundle>& data) {
cb_(complication_id,
provider_id.c_str(), static_cast<watchface_complication_type_e>(type),
- data.get() == NULL ? NULL : data.get()->GetConstRaw(), user_data_);
+ data.get() == NULL ? NULL : data.get()->GetHandle(), user_data_);
}
void InvokeErrorCallback(int complication_id,
char* tmp;
auto sh = static_cast<SharedHandle<WatchComplicationStub>*>(handle);
auto ptr = SharedHandle<WatchComplicationStub>::Share(sh);
- if (ptr.get()->GetCurProviderId() == NULL)
+ if (ptr.get()->GetCurProviderId().empty())
return WATCHFACE_COMPLICATION_ERROR_NO_DATA;
- LOGI("provider id : %s", ptr.get()->GetCurProviderId());
- tmp = strdup(ptr.get()->GetCurProviderId());
+ LOGI("provider id : %s", ptr.get()->GetCurProviderId().c_str());
+ tmp = strdup(ptr.get()->GetCurProviderId().c_str());
if (tmp == NULL)
return WATCHFACE_COMPLICATION_ERROR_OUT_OF_MEMORY;
#define LOG_TAG "WATCHFACE_COMPLICATION"
using watchface_complication::EditablesContainer;
-using watchface_complication::Bundle;
using watchface_complication::IEditable;
using watchface_complication::DesignElement;
using watchface_complication::SharedHandle;
using watchface_complication::EditablesManager;
-
+using namespace std;
+using namespace tizen_base;
struct complication_candidates_list_ {
GList* candidates_list;
};
int ret;
bundle_raw* str_raw = NULL;
GList* iter = list_handle->candidates_list;
- std::list<std::unique_ptr<Bundle>> new_list;
+ std::list<std::shared_ptr<Bundle>> new_list;
for (; iter; iter = iter->next) {
data = reinterpret_cast<bundle*>(iter->data);
de.get()->SetHighlight(std::move(hi_ptr));
}
de.get()->SetLabel(std::string(editable_name));
- ret = de.get()->SetCandidates(std::move(new_list));
+ ret = de.get()->SetCandidates(new_list);
if (ret != WATCHFACE_COMPLICATION_ERROR_NONE)
return ret;
/* Update candidates */
ret = SharedHandle<IEditable>::Share(sh).get()->SetCandidates(
- std::list<std::unique_ptr<Bundle>>());
+ std::list<std::shared_ptr<Bundle>>());
if (ret != WATCHFACE_COMPLICATION_ERROR_NONE)
return ret;
return WATCHFACE_COMPLICATION_ERROR_INVALID_PARAMETER;
IEditable* ie = static_cast<IEditable*>(handle);
- const Bundle* data = ie->GetCurData();
- if (data == NULL)
+ shared_ptr<Bundle> data = ie->GetCurData();
+ if (data.get() == nullptr)
return WATCHFACE_COMPLICATION_ERROR_NO_DATA;
- if (data->GetConstRaw() != NULL) {
- *cur_data = bundle_dup(const_cast<bundle*>(data->GetConstRaw()));
+ if (data->GetHandle() != NULL) {
+ *cur_data = bundle_dup(data->GetHandle());
if (*cur_data == NULL)
return WATCHFACE_COMPLICATION_ERROR_OUT_OF_MEMORY;
} else {
return WATCHFACE_COMPLICATION_ERROR_INVALID_PARAMETER;
IEditable* ie = static_cast<IEditable*>(handle);
- const Bundle* data = ie->GetNthData(nth);
- if (data == NULL)
+ shared_ptr<Bundle> data = ie->GetNthData(nth);
+ if (data.get() == nullptr)
return WATCHFACE_COMPLICATION_ERROR_NO_DATA;
- if (data->GetConstRaw() != NULL) {
- *nth_data = bundle_dup(const_cast<bundle*>(data->GetConstRaw()));
+ if (data->GetHandle() != NULL) {
+ *nth_data = bundle_dup(data->GetHandle());
if (*nth_data == NULL)
return WATCHFACE_COMPLICATION_ERROR_OUT_OF_MEMORY;
} else {
return ex.GetErrorCode();
}
if (setting_data != nullptr) {
- *selected_data = bundle_dup(setting_data.get()->GetRaw());
+ *selected_data = bundle_dup(setting_data.get()->GetHandle());
if (*selected_data == NULL)
return WATCHFACE_COMPLICATION_ERROR_OUT_OF_MEMORY;
} else {
#include <string>
-#include "watchface-complication/complication-bundle.h"
#include "watchface-complication/complication.h"
namespace watchface_complication {
#define LOG_TAG "WATCHFACE_COMPLICATION"
+using namespace tizen_base;
namespace watchface_complication {
EditablesEditor::EditablesEditor(bool mock)
-1,
util::GetCmdStr(util::CmdType::EditableEditPreview),
g_variant_new("(iis)", cur_data_idx, ed.GetEditableId(),
- (context == nullptr) ? "" : context->ToString()));
+ (context == nullptr) ? "" :
+ reinterpret_cast<char*>(context->ToRaw().first.get()
+ )
+ )
+ );
if (emit_result)
return WATCHFACE_COMPLICATION_ERROR_NONE;
#define WATCHFACE_EDITOR_EDITABLES_EDITOR_H_
#include <gio/gio.h>
+#include <bundle_cpp.h>
#include <memory>
#include <string>
void OnRequestEdit(const std::string& appid,
std::list<std::unique_ptr<IEditable>> e_list) override;
void OnSetupReply(const std::string& appid,
- int editable_id, std::unique_ptr<Bundle> context) override;
+ int editable_id, std::unique_ptr<tizen_base::Bundle> context) override;
int EditPreview(IEditable& ed, int cur_data_idx);
int EditComplete();
int EditCancel();
#define LOG_TAG "WATCHFACE_COMPLICATION"
+using namespace tizen_base;
using namespace watchface_complication;
class CallbackInfo {
LOGI("Setup reply!! %s, %d", appid.c_str(), editable_id);
for (auto& i : setup_cb_list_) {
if (i.get()->CompareInfo(appid, editable_id)) {
- i.get()->Invoke(context.get()->GetRaw());
+ i.get()->Invoke(context.get()->GetHandle());
setup_cb_list_.remove(i);
return;
}
}
IEditable* ed = static_cast<IEditable*>(handle);
- std::list<std::unique_ptr<Bundle>> const& list = ed->GetCandidates();
+ std::list<std::shared_ptr<Bundle>> const& list = ed->GetCandidates();
*size = list.size();
return WATCHFACE_COMPLICATION_ERROR_NONE;
}
bundle* tmp;
IEditable* ed = static_cast<IEditable*>(handle);
- const std::list<std::unique_ptr<Bundle>>& list = ed->GetCandidates();
- const std::list<std::unique_ptr<Bundle>>::const_iterator it
+ const std::list<std::shared_ptr<Bundle>>& list = ed->GetCandidates();
+ const std::list<std::shared_ptr<Bundle>>::const_iterator it
= list.begin();
auto nx = std::next(it, nth);
- tmp = bundle_dup(((*nx).get())->GetRaw());
+ tmp = bundle_dup((*nx)->GetHandle());
if (tmp == NULL)
return WATCHFACE_COMPLICATION_ERROR_OUT_OF_MEMORY;
context_data = (ed->GetContext()).get();
if (context_data != nullptr) {
ret = _add_extra_data(service, SETUP_CONTEXT_DATA_KEY,
- context_data->ToString());
+ reinterpret_cast<char*>(context_data->ToRaw().first.get()));
if (ret != WATCHFACE_COMPLICATION_ERROR_NONE) {
LOGE("Fail to add setup_context_data %d", ret);
app_control_destroy(service);