+bool launchDownloader(std::string& url, std::string& cookie)
+{
+ LogD("enter");
+
+ service_h handle = NULL;
+ int ret = SERVICE_ERROR_NONE;
+
+ if (url.empty()) {
+ LogD("invalid arguments");
+ return false;
+ }
+
+ ret = service_create(&handle);
+ if (ret != SERVICE_ERROR_NONE) {
+ LogD("failed to create service");
+ return false;
+ }
+
+ ret = service_set_operation(handle, SERVICE_OPERATION_DOWNLOAD);
+ if (ret != SERVICE_ERROR_NONE) {
+ LogD("failed to set operation");
+ service_destroy(handle);
+ return false;
+ }
+
+ ret = service_set_uri(handle, url.c_str());
+ if (ret != SERVICE_ERROR_NONE) {
+ LogD("failed to set url");
+ service_destroy(handle);
+ return false;
+ }
+
+ if (!cookie.empty()) {
+ ret = service_add_extra_data(handle, "cookie", cookie.c_str());
+ if (ret != SERVICE_ERROR_NONE) {
+ LogD("failed to set cookie");
+ service_destroy(handle);
+ return false;
+ }
+ }
+
+ ret = service_send_launch_request(handle, NULL, NULL);
+ if (ret != SERVICE_ERROR_NONE) {
+ LogD("failed to request launch");
+ service_destroy(handle);
+ return false;
+ }
+
+ LogD("success to launch downloader");
+ service_destroy(handle);
+
+ return true;
+}
+