AppControl::AppControl(app_control_h app_control) {
app_control_clone(&app_control_, app_control);
app_control_to_bundle(app_control_, &app_control_bundle_);
- bundle_encode(app_control_bundle_, &app_control_bundle_raw_,
- &app_control_bundle_raw_len_);
+}
+
+AppControl:: AppControl() {
+ app_control_create(&app_control_);
+ app_control_to_bundle(app_control_, &app_control_bundle_);
}
AppControl::~AppControl() {
if (app_control_ != NULL) {
app_control_destroy(app_control_);
}
- if (app_control_bundle_raw_ != NULL) {
- bundle_free_encoded_rawdata(&app_control_bundle_raw_);
- }
}
std::string AppControl::operation() const {
}
}
+void AppControl::set_operation(const std::string& operation) {
+ appsvc_set_operation(app_control_bundle_, operation.c_str());
+}
+
std::string AppControl::mime() const {
const char* mime = appsvc_get_mime(app_control_bundle_);
}
}
+void AppControl::set_mime(const std::string& mime) {
+ appsvc_set_mime(app_control_bundle_, mime.c_str());
+}
+
std::string AppControl::uri() const {
const char* uri = appsvc_get_uri(app_control_bundle_);
}
}
+void AppControl::set_uri(const std::string& uri) {
+ appsvc_set_uri(app_control_bundle_, uri.c_str());
+}
+
std::string AppControl::category() const {
const char* category = appsvc_get_category(app_control_bundle_);
}
}
+void AppControl::set_category(const std::string& category) {
+ appsvc_set_category(app_control_bundle_, category.c_str());
+}
+
std::string AppControl::data(const std::string& key) const {
const char* data = appsvc_get_data(app_control_bundle_, key.c_str());
return data_vector;
}
-std::string AppControl::encoded_bundle() const {
- return std::string(reinterpret_cast<char*>(app_control_bundle_raw_),
- app_control_bundle_raw_len_);
+std::string AppControl::encoded_bundle() {
+ bundle_raw* encoded_data;
+ int len;
+ bundle_encode(app_control_bundle_, &encoded_data, &len);
+ std::unique_ptr<bundle_raw*, decltype(bundle_free_encoded_rawdata)*>
+ ptr { &encoded_data, bundle_free_encoded_rawdata};
+ return std::string(reinterpret_cast<char*>(encoded_data), len);
}
bool AppControl::IsDataArray(const std::string& key) {
return ret == APPSVC_RET_OK ? true : false;
}
+bool AppControl::LaunchRequest() {
+ return (app_control_send_launch_request(app_control_, NULL, NULL) ==
+ APP_CONTROL_ERROR_NONE);
+}
+
} // namespace wrt
class AppControl {
public:
explicit AppControl(app_control_h app_control);
+ AppControl();
~AppControl();
// disable copy
AppControl(const AppControl& src) = delete;
AppControl& operator=(const AppControl&) = delete;
std::string operation() const;
+ void set_operation(const std::string& operation);
std::string mime() const;
+ void set_mime(const std::string& mime);
std::string uri() const;
+ void set_uri(const std::string& uri);
std::string category() const;
+ void set_category(const std::string& category);
std::string data(const std::string& key) const;
std::vector<std::string> data_array(const std::string& key) const;
- std::string encoded_bundle() const;
+ std::string encoded_bundle();
bool IsDataArray(const std::string& key);
bool AddData(const std::string& key, const std::string& value);
bool AddDataArray(const std::string& key,
const std::vector<std::string>& value_array);
bool Reply(const std::map<std::string, std::vector<std::string>>& data);
+ bool LaunchRequest();
private:
app_control_h app_control_;
bundle* app_control_bundle_;
- bundle_raw* app_control_bundle_raw_;
- int app_control_bundle_raw_len_;
};
} // namespace wrt