PKG_CHECK_MODULES(LIBSMACK_DEPS REQUIRED libsmack)
PKG_CHECK_MODULES(LIBTZPLATFORM_CONFIG_DEPS REQUIRED libtzplatform-config)
PKG_CHECK_MODULES(LIBXML_DEPS REQUIRED libxml-2.0)
+PKG_CHECK_MODULES(PARCEL_DEPS REQUIRED parcel)
PKG_CHECK_MODULES(PKGMGR_INFO_DEPS REQUIRED pkgmgr-info)
PKG_CHECK_MODULES(PKGMGR_INSTALLER_DEPS REQUIRED pkgmgr-installer)
PKG_CHECK_MODULES(SQLITE3_DEPS REQUIRED sqlite3)
PKG_CHECK_MODULES(VCONF_DEPS REQUIRED vconf)
PKG_CHECK_MODULES(XDGMIME_DEPS REQUIRED xdgmime)
-
## Target sources
AUX_SOURCE_DIRECTORY(src SRCS)
AUX_SOURCE_DIRECTORY(aul AUL_SRCS)
LIBSMACK_DEPS
LIBTZPLATFORM_CONFIG_DEPS
LIBXML_DEPS
+ PARCEL_DEPS
PKGMGR_INFO_DEPS
STORAGE_DEPS
TTRACE_DEPS
#include "aul/common/exception.hh"
#include "aul/common/log_private.hh"
#include "aul/socket/client.hh"
-#include "aul/socket/parcel.hh"
namespace aul {
int Client::Send(const Packet& packet) {
_W("cmd(%d)", packet.GetCmd());
- auto raw = const_cast<Packet&>(packet).GetRaw();
+ tizen_base::Parcel parcel;
+ parcel.WriteParcelable(packet);
+ auto raw = parcel.GetRaw();
return Socket::Send(reinterpret_cast<void*>(&raw[0]), raw.size());
}
#include <memory>
#include "aul/socket/packet.hh"
-#include "aul/socket/parcel.hh"
namespace aul {
}
Packet::Packet(const unsigned char* buf, unsigned int size) {
- Parcel parcel(buf, size);
- cmd_ = parcel.ReadInt32();
- int len = parcel.ReadInt32();
- opt_ = parcel.ReadInt32();
- auto* p = reinterpret_cast<unsigned char*>(&data_[0]);
- parcel.Read(p, len);
+ tizen_base::Parcel parcel(buf, size);
+ parcel.ReadParcelable(this);
}
Packet::~Packet() = default;
return tizen_base::Bundle(b, false, true);
}
-const std::vector<unsigned char>& Packet::GetRaw() {
- if (parcel_.GetRaw().size() == 0) {
- parcel_.WriteInt32(cmd_);
- parcel_.WriteInt32(data_.size());
- parcel_.WriteInt32(opt_);
+void Packet::WriteToParcel(tizen_base::Parcel* parcel) const {
+ parcel->WriteInt32(cmd_);
+ parcel->WriteInt32(data_.size());
+ parcel->WriteInt32(opt_);
+ if (data_.size() > 0) {
+ auto* p = reinterpret_cast<const void*>(&data_[0]);
+ parcel->Write(p, data_.size());
+ }
+}
+
+void Packet::ReadFromParcel(tizen_base::Parcel* parcel) {
+ parcel->ReadInt32(&cmd_);
+ int size = 0;
+ parcel->ReadInt32(&size);
+ parcel->ReadInt32(&opt_);
+ if (size > 0) {
auto* p = reinterpret_cast<unsigned char*>(&data_[0]);
- parcel_.Write(p, data_.size());
+ parcel->Read(p, size);
}
- return parcel_.GetRaw();
}
} // namespace aul
#define AUL_SOCKET_PACKET_HH_
#include <bundle_cpp.h>
+#include <parcel.hh>
+#include <parcelable.hh>
#include <vector>
-#include "aul/socket/parcel.hh"
-
namespace aul {
-class Packet {
+class Packet : public tizen_base::Parcelable {
public:
Packet();
Packet(int cmd, int opt, std::vector<unsigned char> data);
tizen_base::Bundle DataToBundle();
- const std::vector<unsigned char>& GetRaw();
+ void WriteToParcel(tizen_base::Parcel* parcel) const override;
+ void ReadFromParcel(tizen_base::Parcel* parcel) override;
private:
int cmd_;
int opt_;
std::vector<unsigned char> data_;
- Parcel parcel_;
};
} // namespace aul
+++ /dev/null
-/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "aul/socket/parcel.hh"
-
-namespace aul {
-
-Parcel::Parcel(const unsigned char* buf, unsigned int size)
- : data_(buf, buf + size) {
-}
-
-void Parcel::Write(const unsigned char* buf, unsigned int size) {
- std::copy(buf, buf + size, std::back_inserter(data_));
-}
-
-void Parcel::Read(unsigned char* buf, unsigned int size) {
- if (reader_ + size > data_.size())
- return;
-
- std::copy(&data_[reader_], &data_[reader_] + size, buf);
- reader_ += size;
-}
-
-void Parcel::WriteInt32(int i) {
- Write<int>(i);
-}
-
-int Parcel::ReadInt32() {
- return Read<int>();
-}
-
-const std::vector<unsigned char>& Parcel::GetRaw() {
- return data_;
-}
-
-} // namespace aul
+++ /dev/null
-/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef AUL_SOCKET_PARCEL_HH_
-#define AUL_SOCKET_PARCEL_HH_
-
-#include <vector>
-
-namespace aul {
-
-class Parcel {
- public:
- Parcel() = default;
- Parcel(const unsigned char* buf, unsigned int size);
-
- void Write(const unsigned char* buf, unsigned int size);
- void Read(unsigned char* buf, unsigned int size);
- void WriteInt32(int i);
- int ReadInt32();
- const std::vector<unsigned char>& GetRaw();
-
- private:
- template<typename T>
- void Write(T d) {
- unsigned char* p = reinterpret_cast<unsigned char*>(&d);
- std::copy(p, p + sizeof(T), std::back_inserter(data_));
- }
-
- template<typename T>
- T Read() {
- T d = 0;
- unsigned char* p = reinterpret_cast<unsigned char*>(&d);
- if (reader_ + sizeof(T) > data_.size())
- return d;
-
- std::copy(&data_[reader_], &data_[reader_] + sizeof(T), p);
- reader_ += sizeof(T);
- return d;
- }
-
- private:
- std::vector<unsigned char> data_;
- unsigned int reader_ = 0;
-};
-
-} // namespace aul
-
-#endif // AUL_SOCKET_PARCEL_HH_
BuildRequires: pkgconfig(uuid)
BuildRequires: pkgconfig(libsmack)
BuildRequires: pkgconfig(gmock)
+BuildRequires: pkgconfig(parcel)
%if 0%{?gcov:1}
BuildRequires: lcov