static const char SOCK_PATH[] = "/run/pkgmgr-info-server";
PkgInfoClient::PkgInfoClient(
- std::shared_ptr<pkgmgr_common::parcel::AbstractParcelable> parcel, uid_t uid,
- pkgmgr_common::ReqType req_type)
- : parcel_(parcel), result_parcel_(nullptr), uid_(uid), req_type_(req_type), is_offline_(false) {
+ std::shared_ptr<pkgmgr_common::parcel::AbstractParcelable> parcel,
+ uid_t uid, pkgmgr_common::ReqType req_type)
+ : parcel_(parcel),
+ result_parcel_(nullptr),
+ uid_(uid),
+ req_type_(req_type),
+ is_offline_(false) {
socket_ = std::make_unique<pkgmgr_common::socket::ClientSocket>(SOCK_PATH);
}
bool PkgInfoClient::SendRequest() {
- if (socket_ == nullptr)
- return false;
+ if (socket_ == nullptr) return false;
if (!socket_->Connect()) {
LOGE("Failed to connect client socket, try to direct access");
std::shared_ptr<pkgmgr_common::parcel::AbstractParcelable>
PkgInfoClient::GetResultParcel() {
- if (is_offline_)
- return result_parcel_;
+ if (is_offline_) return result_parcel_;
- if (socket_ == nullptr)
- return nullptr;
+ if (socket_ == nullptr) return nullptr;
int len = 0;
if (socket_->ReceiveData(&len, sizeof(len)) != 0) {
return nullptr;
}
- auto res = pkgmgr_common::parcel::ParcelableFactory::GetInst()
- .CreateParcel(raw, len);
+ auto res = pkgmgr_common::parcel::ParcelableFactory::GetInst().CreateParcel(
+ raw, len);
delete[] raw;
return res;
}
bool PkgInfoClient::RequestHandlerDirectAccess() {
- std::unique_ptr<pkgmgr_server::request_handler::AbstractRequestHandler> handler;
+ std::unique_ptr<pkgmgr_server::request_handler::AbstractRequestHandler>
+ handler;
switch (req_type_) {
- case pkgmgr_common::ReqType::GET_PKG_INFO:
- handler.reset(new pkgmgr_server::request_handler::GetPkginfoRequestHandler());
- break;
- case pkgmgr_common::ReqType::GET_APP_INFO:
- handler.reset(new pkgmgr_server::request_handler::GetAppinfoRequestHandler());
- break;
- case pkgmgr_common::ReqType::SET_PKG_INFO:
- handler.reset(new pkgmgr_server::request_handler::SetPkginfoRequestHandler());
- break;
- case pkgmgr_common::ReqType::SET_CERT_INFO:
- handler.reset(new pkgmgr_server::request_handler::SetCertRequestHandler());
- break;
- case pkgmgr_common::ReqType::GET_CERT_INFO:
- handler.reset(new pkgmgr_server::request_handler::GetCertRequestHandler());
- break;
- case pkgmgr_common::ReqType::QUERY:
- handler.reset(new pkgmgr_server::request_handler::QueryRequestHandler());
- break;
- default:
- handler.reset(nullptr);
- break;
+ case pkgmgr_common::ReqType::GET_PKG_INFO:
+ handler.reset(
+ new pkgmgr_server::request_handler::GetPkginfoRequestHandler());
+ break;
+ case pkgmgr_common::ReqType::GET_APP_INFO:
+ handler.reset(
+ new pkgmgr_server::request_handler::GetAppinfoRequestHandler());
+ break;
+ case pkgmgr_common::ReqType::SET_PKG_INFO:
+ handler.reset(
+ new pkgmgr_server::request_handler::SetPkginfoRequestHandler());
+ break;
+ case pkgmgr_common::ReqType::SET_CERT_INFO:
+ handler.reset(
+ new pkgmgr_server::request_handler::SetCertRequestHandler());
+ break;
+ case pkgmgr_common::ReqType::GET_CERT_INFO:
+ handler.reset(
+ new pkgmgr_server::request_handler::GetCertRequestHandler());
+ break;
+ case pkgmgr_common::ReqType::QUERY:
+ handler.reset(new pkgmgr_server::request_handler::QueryRequestHandler());
+ break;
+ default:
+ handler.reset(nullptr);
+ break;
}
if (handler == nullptr) {
handler->HandleRequest(&raw[0], raw.size(), vconf_get_str(VCONFKEY_LANGSET));
auto result = handler->GetResult();
- if (result.size() == 0)
- return true;
+ if (result.size() == 0) return true;
- result_parcel_.reset(pkgmgr_common::parcel::ParcelableFactory::GetInst().CreateParcel(&result[0], result.size()).release());
+ result_parcel_.reset(pkgmgr_common::parcel::ParcelableFactory::GetInst()
+ .CreateParcel(&result[0], result.size())
+ .release());
return true;
}
namespace pkgmgr_common {
namespace parcel {
-FilterParcelable::FilterParcelable() :
- AbstractParcelable(0, ParcelableType::Filter), filter_(nullptr), flag_(0) {}
+FilterParcelable::FilterParcelable()
+ : AbstractParcelable(0, ParcelableType::Filter),
+ filter_(nullptr),
+ flag_(0) {}
FilterParcelable::FilterParcelable(uid_t uid, pkgmgrinfo_filter_x *filter,
- int flag) : AbstractParcelable(uid, ParcelableType::Filter),
- filter_(filter), flag_(flag) {}
+ int flag)
+ : AbstractParcelable(uid, ParcelableType::Filter),
+ filter_(filter),
+ flag_(flag) {}
FilterParcelable::~FilterParcelable() {
pkgmgrinfo_pkginfo_filter_destroy(filter_);
}
-const pkgmgrinfo_filter_x *FilterParcelable::GetFilter() {
- return filter_;
-}
+const pkgmgrinfo_filter_x *FilterParcelable::GetFilter() { return filter_; }
-int FilterParcelable::GetFlag() {
- return flag_;
-}
+int FilterParcelable::GetFlag() { return flag_; }
-void FilterParcelable::WriteToParcel(tizen_base::Parcel* parcel) const {
+void FilterParcelable::WriteToParcel(tizen_base::Parcel *parcel) const {
AbstractParcelable::WriteToParcel(parcel);
WriteInt(parcel, flag_);
WriteFilter(parcel, filter_);
}
-void FilterParcelable::ReadFromParcel(tizen_base::Parcel* parcel) {
+void FilterParcelable::ReadFromParcel(tizen_base::Parcel *parcel) {
AbstractParcelable::ReadFromParcel(parcel);
ReadInt(parcel, &flag_);
ReadFilter(parcel);
}
-bool FilterParcelable::WriteFilter(
- tizen_base::Parcel* parcel, pkgmgrinfo_filter_x *filter) const {
+bool FilterParcelable::WriteFilter(tizen_base::Parcel *parcel,
+ pkgmgrinfo_filter_x *filter) const {
if (filter == nullptr) {
parcel->WriteBool(true);
return true;
WriteInt(parcel, g_slist_length(filter->list));
for (GSList *list = filter->list; list; list = list->next)
- WritePkgmgrInfoNode(parcel, reinterpret_cast<pkgmgrinfo_node_x *>(list->data));
+ WritePkgmgrInfoNode(parcel,
+ reinterpret_cast<pkgmgrinfo_node_x *>(list->data));
WriteInt(parcel, g_slist_length(filter->list_metadata));
for (GSList *list = filter->list_metadata; list; list = list->next)
- WritePkgmgrInfoMetadataNode(parcel,
- reinterpret_cast<pkgmgrinfo_metadata_node_x *>(list->data));
+ WritePkgmgrInfoMetadataNode(
+ parcel, reinterpret_cast<pkgmgrinfo_metadata_node_x *>(list->data));
return true;
}
-void FilterParcelable::ReadFilter(tizen_base::Parcel* parcel) {
+void FilterParcelable::ReadFilter(tizen_base::Parcel *parcel) {
bool is_null = false;
int val = 0;
- if (parcel->ReadBool(&is_null) != TIZEN_ERROR_NONE)
- return;
+ if (parcel->ReadBool(&is_null) != TIZEN_ERROR_NONE) return;
- if (is_null)
- return;
+ if (is_null) return;
filter_ = reinterpret_cast<pkgmgrinfo_filter_x *>(
calloc(1, sizeof(pkgmgrinfo_filter_x)));
ReadInt(parcel, &val);
for (int i = 0; i < val; ++i)
- filter_->list_metadata = g_slist_append(filter_->list_metadata, ReadPkgmgrInfoMetadataNode(parcel));
+ filter_->list_metadata = g_slist_append(filter_->list_metadata,
+ ReadPkgmgrInfoMetadataNode(parcel));
}
-bool FilterParcelable::WritePkgmgrInfoNode(tizen_base::Parcel* parcel, pkgmgrinfo_node_x *node) const {
+bool FilterParcelable::WritePkgmgrInfoNode(tizen_base::Parcel *parcel,
+ pkgmgrinfo_node_x *node) const {
WriteInt(parcel, node->prop);
WriteString(parcel, node->key);
WriteString(parcel, node->value);
return true;
}
-pkgmgrinfo_node_x *FilterParcelable::ReadPkgmgrInfoNode(tizen_base::Parcel *parcel) {
- pkgmgrinfo_node_x *node = reinterpret_cast<pkgmgrinfo_node_x *>(calloc(1, sizeof(pkgmgrinfo_node_x)));
+pkgmgrinfo_node_x *FilterParcelable::ReadPkgmgrInfoNode(
+ tizen_base::Parcel *parcel) {
+ pkgmgrinfo_node_x *node = reinterpret_cast<pkgmgrinfo_node_x *>(
+ calloc(1, sizeof(pkgmgrinfo_node_x)));
ReadInt(parcel, &node->prop);
ReadString(parcel, &node->key);
ReadString(parcel, &node->value);
return node;
}
-bool FilterParcelable::WritePkgmgrInfoMetadataNode(tizen_base::Parcel* parcel, pkgmgrinfo_metadata_node_x *node) const {
+bool FilterParcelable::WritePkgmgrInfoMetadataNode(
+ tizen_base::Parcel *parcel, pkgmgrinfo_metadata_node_x *node) const {
WriteString(parcel, node->key);
WriteString(parcel, node->value);
return true;
}
-pkgmgrinfo_metadata_node_x *FilterParcelable::ReadPkgmgrInfoMetadataNode(tizen_base::Parcel* parcel) {
- pkgmgrinfo_metadata_node_x *node = reinterpret_cast<pkgmgrinfo_metadata_node_x *>(calloc(1, sizeof(pkgmgrinfo_metadata_node_x)));
+pkgmgrinfo_metadata_node_x *FilterParcelable::ReadPkgmgrInfoMetadataNode(
+ tizen_base::Parcel *parcel) {
+ pkgmgrinfo_metadata_node_x *node =
+ reinterpret_cast<pkgmgrinfo_metadata_node_x *>(
+ calloc(1, sizeof(pkgmgrinfo_metadata_node_x)));
ReadString(parcel, &node->key);
ReadString(parcel, &node->value);