PKG_CHECK_MODULES(PKGMGR_INFO_DEPS REQUIRED pkgmgr-info)
PKG_CHECK_MODULES(SMACK_DEPS REQUIRED libsmack)
PKG_CHECK_MODULES(SQLITE_DEPS REQUIRED sqlite3)
+PKG_CHECK_MODULES(SYSINFO_DEPS REQUIRED capi-system-info capi-system-system-settings)
FIND_PACKAGE(Boost REQUIRED COMPONENTS filesystem system)
BuildRequires: pkgconfig(bundle)
BuildRequires: pkgconfig(capi-base-common)
BuildRequires: pkgconfig(capi-network-mdg)
+BuildRequires: pkgconfig(capi-system-info)
+BuildRequires: pkgconfig(capi-system-system-settings)
BuildRequires: pkgconfig(cynara-creds-gdbus)
BuildRequires: pkgconfig(dlog)
BuildRequires: pkgconfig(gio-2.0)
SQLITE_DEPS
CYNARA_CREDS_DEPS
SMACK_DEPS
+ SYSINFO_DEPS
Boost
)
" platform_ver TEXT,\n"
" profile TEXT,\n"
" sw_ver TEXT,\n"
+ " local INTEGER,\n"
" PRIMARY KEY (device_id))";
const char kQueryInitCapsTable[] =
"CREATE TABLE IF NOT EXISTS capabilities (\n"
" REFERENCES devices (device_id) ON DELETE CASCADE)";
const char kQueryInsertDev[] =
"INSERT INTO devices (device_id, model_name, device_name,"
- " platform_ver, profile, sw_ver) "
- "VALUES (?, ?, ?, ?, ?, ?)";
+ " platform_ver, profile, sw_ver, local) "
+ "VALUES (?, ?, ?, ?, ?, ?, ?)";
const char kQueryDeleteDev[] =
"DELETE FROM devices WHERE device_id=?";
const char kQuerySelectDev[] =
"SELECT device_id, model_name, device_name, platform_ver,"
- " profile, sw_ver FROM devices";
+ " profile, sw_ver, local FROM devices";
const char kQueryInsertCap[] =
"INSERT INTO capabilities (device_id, operation, uri, mime, appid, pkgid) "
"VALUES (?, ?, ?, ?, ?, ?)";
return false;
if (!stmt->BindString(idx++, device.sw_ver()))
return false;
+ if (!stmt->BindInt(idx++, device.local() ? 1 : 0))
+ return false;
if (stmt->Step() != SQLStatement::StepResult::DONE) {
LOG(ERROR) << "Failed to insert device info into db";
std::string platform_ver = stmt->GetColumnString(idx++);
std::string profile = stmt->GetColumnString(idx++);
std::string sw_ver = stmt->GetColumnString(idx++);
+ bool local = stmt->GetColumnInt(idx++) > 0;
RemoteDevice dev(device_id, model_name, device_name, platform_ver,
- profile, sw_ver);
+ profile, sw_ver, local);
dev_list.push_back(dev);
}
#include <mdg_internal.h>
#include <stdint.h>
#include <sys/types.h>
+#include <system_info.h>
+#include <system_settings.h>
#include <unistd.h>
#include <cstring>
return false;
}
+ AddLocalDevice();
+
ret = mdg_set_invited_event_cb(mdg_handle_, &MDGManager::GroupInvitedCb,
this);
if (ret != MDG_ERROR_NONE) {
packed = this->pm_->PackPackages(packages);
package_data = new unsigned char[packed.size()];
memcpy(package_data, packed.c_str(), packed.size());
- delete[] info;
+ delete info;
} else if (event_type == PackageEventListener::EventType::UNINSTALL) {
package_data = new unsigned char[pkgid.size()];
memcpy(package_data, pkgid.c_str(), pkgid.size());
packed = info->Serialize();
package_data = new unsigned char[packed.size()];
memcpy(package_data, packed.c_str(), packed.size());
- delete[] info;
+ delete info;
}
std::vector<RemoteDevice> dev_list = DBManager::SelectDevices();
delete[] package_data;
}
+bool MDGManager::AddLocalDevice() {
+ // critical section: appending device list
+ std::mutex lock;
+ std::lock_guard<std::mutex> guard(lock);
+ LOG(ERROR) << "Add Local Device";
+ char* device_name = nullptr;
+ char* model_name = nullptr;
+ char* platform_ver = nullptr;
+ char* profile = nullptr;
+ system_settings_get_value_string(SYSTEM_SETTINGS_KEY_DEVICE_NAME, &device_name);
+ system_info_get_platform_string("http://tizen.org/system/model_name", &model_name);
+ system_info_get_platform_string("http://tizen.org/feature/platform.version", &platform_ver);
+ system_info_get_platform_string("http://tizen.org/feature/profile", &profile);
+ std::string sw_ver = "5.5";
+
+ RemoteDevice remote_device("localhost", model_name, device_name,
+ platform_ver, profile, sw_ver, true);
+ RemoteDeviceManager::RegisterRemoteDevice("localhost", remote_device);
+
+ std::vector<RemotePackageInfo> infos = pm_->LoadLocalPackages();
+ pm_->StoreRemotePackages("localhost", infos);
+
+ LOG(ERROR) << "Add local device done";
+ return true;
+}
+
bool MDGManager::AddDevice(const mdg_device_h device) {
// critical section: appending device list
std::mutex lock;
std::string profile = GetProfileFromHandle(device);
if (profile.empty())
return false;
- std::string sw_ver = "5.0";
+ std::string sw_ver = "5.5";
RemoteDevice remote_device(device_id, model_name, device_name,
- platform_ver, profile, sw_ver);
+ platform_ver, profile, sw_ver, false);
RemoteDeviceManager::RegisterRemoteDevice(device_id, remote_device);
mdg_device_h dev_clone;
bool Initialize();
bool FindGroup();
bool AddDevice(const mdg_device_h device);
+ bool AddLocalDevice();
int SendData(const std::string& device_id, Command cmd,
const unsigned char* data, size_t len);
bool SendReplyData(const std::string& device_id, Command cmd,
explicit RemoteDevice(const std::string& device_id,
const std::string& model_name, const std::string& device_name,
const std::string& platform_ver, const std::string& profile,
- const std::string& sw_ver)
+ const std::string& sw_ver, const bool local)
: device_id_(std::move(device_id)), model_name_(std::move(model_name)),
device_name_(std::move(device_name)),
platform_ver_(std::move(platform_ver)), profile_(std::move(profile)),
- sw_ver_(std::move(sw_ver)) {}
+ sw_ver_(std::move(sw_ver)), local_(local) {}
const std::string& device_id() const { return device_id_; }
const std::string& model_name() const { return model_name_; }
const std::string& platform_ver() const { return platform_ver_; }
const std::string& profile() const { return profile_; }
const std::string& sw_ver() const { return sw_ver_; }
+ const bool local() const { return local_; }
private:
std::string device_id_;
std::string platform_ver_;
std::string profile_;
std::string sw_ver_;
+ bool local_;
};
} // namespace capmgr
sql_conn_->SetErrorCode(r);
return false;
}
- return false;
+ return true;
}
bool SQLiteStatement::BindString(int pos, const std::string& val) {
ADD_EXECUTABLE(${TARGET_SMOKE_TEST} ${SMOKE_TEST_SRCS})
APPLY_PKG_CONFIG(${TARGET_SQL_TEST} PUBLIC
+ BUNDLE_DEPS
DLOG_DEPS
GLIB_DEPS
GMOCK_DEPS
APPLY_PKG_CONFIG(${TARGET_SMOKE_TEST} PUBLIC
Boost
+ BUNDLE_DEPS
DLOG_DEPS
GMOCK_DEPS
)
TEST_F(RemoteDeviceManagerTest, RegisterRemoteDeviceManagerTest) {
RemoteDevice remote_device("device_id", "model_name", "device_name",
- "platform_ver", "profile", "sw_ver");
+ "platform_ver", "profile", "sw_ver", true);
RemoteDeviceManager::RegisterRemoteDevice("device_id", remote_device);
std::vector<RemoteDevice> devices = DBManager::SelectDevices();
d.device_name() == remote_device.device_name() &&
d.platform_ver() == remote_device.platform_ver() &&
d.profile() == remote_device.profile() &&
- d.sw_ver() == remote_device.sw_ver())
+ d.sw_ver() == remote_device.sw_ver() &&
+ d.local() == remote_device.local())
return true;
else
return false;
TEST_F(RemoteDeviceManagerTest, RegisterRemoteCapabilitiesTest) {
RemoteDevice remote_device("device_id2", "model_name2", "device_name2",
- "platform_ver2", "profile2", "sw_ver2");
+ "platform_ver2", "profile2", "sw_ver2", true);
RemoteDeviceManager::RegisterRemoteDevice("device_id2", remote_device);
std::vector<Capability> capabilities;
};
TEST_F(SmokeTest, InsertDeviceTest) {
- RemoteDevice dev("insertdev", "tm1", "TM1", "5.0", "mobile", "5.0");
+ RemoteDevice dev("insertdev", "tm1", "TM1", "5.0", "mobile", "5.0", true);
ASSERT_TRUE(DBManager::InsertDevice(dev));
}
TEST_F(SmokeTest, DeleteDeviceTest) {
- RemoteDevice dev("deletedev", "tm1", "TM1", "5.0", "mobile", "5.0");
+ RemoteDevice dev("deletedev", "tm1", "TM1", "5.0", "mobile", "5.0", true);
ASSERT_TRUE(DBManager::InsertDevice(dev));
ASSERT_TRUE(DBManager::DeleteDevice(dev));
}
TEST_F(SmokeTest, InsertCapTest) {
- RemoteDevice dev("insertcapdev", "tm1", "TM1", "5.0", "mobile", "5.0");
+ RemoteDevice dev("insertcapdev", "tm1", "TM1", "5.0", "mobile", "5.0", true);
ASSERT_TRUE(DBManager::InsertDevice(dev));
Capability cap("operation", "uri", "mime", "appid", "pkgid");
ASSERT_TRUE(DBManager::InsertCapability("insertcapdev", cap));
}
TEST_F(SmokeTest, DeleteCapTest) {
- RemoteDevice dev("deletecapdev", "tm1", "TM1", "5.0", "mobile", "5.0");
+ RemoteDevice dev("deletecapdev", "tm1", "TM1", "5.0", "mobile", "5.0", true);
ASSERT_TRUE(DBManager::InsertDevice(dev));
Capability cap("operation", "uri", "mime", "appid", "pkgid");
ASSERT_TRUE(DBManager::InsertCapability("deletecapdev", cap));
}
TEST_F(SmokeTest, InsertPkgTest) {
- RemoteDevice dev("insertpkgdev", "tm1", "TM1", "5.0", "mobile", "5.0");
+ RemoteDevice dev("insertpkgdev", "tm1", "TM1", "5.0", "mobile", "5.0", true);
ASSERT_TRUE(DBManager::InsertDevice(dev));
std::vector<std::string> v;
v.emplace_back("hello1");
}
TEST_F(SmokeTest, DeletePkgTest) {
- RemoteDevice dev("deletepkgdev", "tm1", "TM1", "5.0", "mobile", "5.0");
+ RemoteDevice dev("deletepkgdev", "tm1", "TM1", "5.0", "mobile", "5.0", true);
ASSERT_TRUE(DBManager::InsertDevice(dev));
std::vector<std::string> v;
v.emplace_back("hello1");