sqlite3
capi-appfw-application
capi-network-connection
+ bundle
dlog)
FOREACH(flag ${pkgs_CFLAGS})
int download_provider_db_requestinfo_update_column(download_clientinfo *clientinfo,
download_db_column_type type);
download_dbinfo_list *download_provider_db_get_list(int state);
+download_dbinfo *download_provider_db_get_info(int requestid);
void download_provider_db_list_free(download_dbinfo_list *list);
+void download_provider_db_info_free(download_dbinfo *info);
int download_provider_db_list_count(int state);
download_request_info *download_provider_db_get_requestinfo(download_dbinfo *dbinfo);
int download_provider_db_history_new(download_clientinfo *clientinfo);
int download_provider_db_history_remove(int uniqueid);
int download_provider_db_history_limit_rows();
+download_dbinfo *download_provider_db_history_get_info(int requestid);
#endif
int set_downloadinginfo_appfw_notification(download_clientinfo *clientinfo);
int set_downloadedinfo_appfw_notification(download_clientinfo *clientinfo);
int destroy_appfw_notification(download_clientinfo *clientinfo);
+void clear_downloadinginfo_appfw_notification(void);
#endif
download_flexible_string url;
download_flexible_string install_path;
download_flexible_string filename;
+ download_flexible_string service_data;
download_flexible_double_string headers;
} download_request_info;
BuildRequires: pkgconfig(vconf)
BuildRequires: pkgconfig(db-util)
BuildRequires: pkgconfig(sqlite3)
+BuildRequires: pkgconfig(bundle)
BuildRequires: pkgconfig(capi-appfw-application)
BuildRequires: pkgconfig(capi-network-connection)
int download_provider_db_requestinfo_remove(int uniqueid)
{
int errorcode;
- sqlite3_stmt *stmt;
+ sqlite3_stmt *stmt = NULL;
if (uniqueid <= 0) {
TRACE_DEBUG_MSG("[NULL-CHECK]");
int download_provider_db_requestinfo_new(download_clientinfo *clientinfo)
{
int errorcode;
- sqlite3_stmt *stmt;
+ sqlite3_stmt *stmt = NULL;
if (!clientinfo || !clientinfo->requestinfo
|| clientinfo->requestinfo->requestid <= 0) {
_download_provider_sql_close(stmt);
return -1;
}
- if (clientinfo->requestinfo->client_packagename.length > 0) {
+ if (clientinfo->requestinfo->client_packagename.length > 1) {
if (sqlite3_bind_text
(stmt, 2, clientinfo->requestinfo->client_packagename.str,
-1, NULL) != SQLITE_OK) {
_download_provider_sql_close(stmt);
return -1;
}
- if (clientinfo->downloadinfo && clientinfo->downloadinfo->content_name) {
+ if (clientinfo->downloadinfo && sizeof(clientinfo->downloadinfo->content_name) > 1) {
if (sqlite3_bind_text
(stmt, 5, clientinfo->downloadinfo->content_name, -1,
NULL) != SQLITE_OK) {
_download_provider_sql_close(stmt);
return -1;
}
- if (clientinfo->requestinfo->url.length > 0) {
+ if (clientinfo->requestinfo->url.length > 1) {
if (sqlite3_bind_text
(stmt, 7, clientinfo->requestinfo->url.str, -1,
NULL) != SQLITE_OK) {
return -1;
}
}
- if (clientinfo->downloadinfo && clientinfo->downloadinfo->mime_type) {
+ if (clientinfo->downloadinfo && sizeof(clientinfo->downloadinfo->mime_type) > 1) {
if (sqlite3_bind_text
(stmt, 8, clientinfo->downloadinfo->mime_type, -1,
NULL) != SQLITE_OK) {
download_db_column_type type)
{
int errorcode;
- sqlite3_stmt *stmt;
+ sqlite3_stmt *stmt = NULL;
if (!clientinfo || !clientinfo->requestinfo
|| clientinfo->requestinfo->requestid <= 0) {
switch (type) {
case DOWNLOAD_DB_PACKAGENAME:
- if (clientinfo->requestinfo->client_packagename.length <= 0
+ if (clientinfo->requestinfo->client_packagename.length <= 1
|| !clientinfo->requestinfo->client_packagename.str) {
TRACE_DEBUG_MSG("[NULL-CHECK] type [%d]", type);
_download_provider_sql_close(stmt);
break;
case DOWNLOAD_DB_FILENAME:
if (!clientinfo->downloadinfo
- || !clientinfo->downloadinfo->content_name) {
+ || sizeof(clientinfo->downloadinfo->content_name) < 1) {
TRACE_DEBUG_MSG("[NULL-CHECK] type [%d]", type);
_download_provider_sql_close(stmt);
return -1;
int listcount;
int i = 0;
int buffer_length = 0;
- sqlite3_stmt *stmt;
+ sqlite3_stmt *stmt = NULL;
char *buffer;
download_dbinfo_list *m_list = NULL;
{
int errorcode;
int count = 0;
- sqlite3_stmt *stmt;
+ sqlite3_stmt *stmt = NULL;
if (_download_provider_sql_open() < 0) {
TRACE_DEBUG_MSG("db_util_open is failed [%s]",
return 0;
}
+void download_provider_db_info_free(download_dbinfo *info)
+{
+ if (!info)
+ return;
+
+ info->requestid = 0;
+ if (info->packagename)
+ free(info->packagename);
+ info->packagename = NULL;
+ if (info->installpath)
+ free(info->installpath);
+ info->installpath = NULL;
+ if (info->filename)
+ free(info->filename);
+ info->filename = NULL;
+ if (info->createdate)
+ free(info->createdate);
+ info->createdate = NULL;
+ if (info->url)
+ free(info->url);
+ info->url = NULL;
+ if (info->mimetype)
+ free(info->mimetype);
+ info->mimetype = NULL;
+ if (info->etag)
+ free(info->etag);
+ info->etag = NULL;
+ if (info->saved_path)
+ free(info->saved_path);
+ info->saved_path = NULL;
+ free(info);
+ info = NULL;
+}
+
void download_provider_db_list_free(download_dbinfo_list *list)
{
TRACE_DEBUG_MSG("");
return;
if (list->count > 0 && list->item) {
- for (i = 0; i < list->count; i++) {
- list->item[i].requestid = 0;
- if (list->item[i].packagename)
- free(list->item[i].packagename);
- list->item[i].packagename = NULL;
- if (list->item[i].installpath)
- free(list->item[i].installpath);
- list->item[i].installpath = NULL;
- if (list->item[i].filename)
- free(list->item[i].filename);
- list->item[i].filename = NULL;
- if (list->item[i].createdate)
- free(list->item[i].createdate);
- list->item[i].createdate = NULL;
- if (list->item[i].url)
- free(list->item[i].url);
- list->item[i].url = NULL;
- if (list->item[i].mimetype)
- free(list->item[i].mimetype);
- list->item[i].mimetype = NULL;
- if (list->item[i].etag)
- free(list->item[i].etag);
- list->item[i].etag = NULL;
- if (list->item[i].saved_path)
- free(list->item[i].saved_path);
- list->item[i].saved_path = NULL;
- }
+ for (i = 0; i < list->count; i++)
+ download_provider_db_info_free(&list->item[i]);
+ list->count = 0;
free(list->item);
list->item = NULL;
}
list = NULL;
}
+download_dbinfo *download_provider_db_get_info(int requestid)
+{
+ if (requestid <= 0)
+ return NULL;
+
+ int errorcode;
+ int buffer_length = 0;
+ sqlite3_stmt *stmt = NULL;
+ char *buffer = NULL;
+ download_dbinfo *dbinfo = NULL;
+
+ if (_download_provider_sql_open() < 0) {
+ TRACE_DEBUG_MSG("db_util_open is failed [%s]",
+ sqlite3_errmsg(g_download_provider_db));
+ return NULL;
+ }
+
+ errorcode =
+ sqlite3_prepare_v2(g_download_provider_db,
+ "SELECT uniqueid, packagename, notification, installpath, filename, creationdate, state, url, mimetype, savedpath FROM downloading WHERE uniqueid = ?",
+ -1, &stmt, NULL);
+ if (errorcode != SQLITE_OK) {
+ TRACE_DEBUG_MSG("sqlite3_prepare_v2 is failed. [%s]",
+ sqlite3_errmsg(g_download_provider_db));
+ _download_provider_sql_close(stmt);
+ return NULL;
+ }
+ if (sqlite3_bind_int(stmt, 1, requestid) != SQLITE_OK) {
+ TRACE_DEBUG_MSG("sqlite3_bind_int is failed. [%s]",
+ sqlite3_errmsg(g_download_provider_db));
+ _download_provider_sql_close(stmt);
+ return NULL;
+ }
+
+ if ((errorcode = sqlite3_step(stmt)) == SQLITE_ROW) {
+ dbinfo = (download_dbinfo *) calloc(1, sizeof(download_dbinfo));
+ dbinfo->requestid = sqlite3_column_int(stmt, 0);
+ buffer = (char *)(sqlite3_column_text(stmt, 1));
+ dbinfo->packagename = NULL;
+ if (buffer) {
+ buffer_length = strlen(buffer);
+ dbinfo->packagename
+ = (char *)calloc(buffer_length + 1, sizeof(char));
+ memcpy(dbinfo->packagename, buffer,
+ buffer_length * sizeof(char));
+ dbinfo->packagename[buffer_length] = '\0';
+ }
+ dbinfo->notification = sqlite3_column_int(stmt, 2);
+ buffer = (char *)(sqlite3_column_text(stmt, 3));
+ dbinfo->installpath = NULL;
+ if (buffer) {
+ buffer_length = strlen(buffer);
+ dbinfo->installpath
+ = (char *)calloc(buffer_length + 1, sizeof(char));
+ memcpy(dbinfo->installpath, buffer,
+ buffer_length * sizeof(char));
+ dbinfo->installpath[buffer_length] = '\0';
+ }
+ buffer = (char *)(sqlite3_column_text(stmt, 4));
+ dbinfo->filename = NULL;
+ if (buffer) {
+ buffer_length = strlen(buffer);
+ dbinfo->filename
+ = (char *)calloc(buffer_length + 1, sizeof(char));
+ memcpy(dbinfo->filename, buffer,
+ buffer_length * sizeof(char));
+ dbinfo->filename[buffer_length] = '\0';
+ }
+ buffer = (char *)(sqlite3_column_text(stmt, 5));
+ dbinfo->createdate = NULL;
+ if (buffer) {
+ buffer_length = strlen(buffer);
+ dbinfo->createdate
+ = (char *)calloc(buffer_length + 1, sizeof(char));
+ memcpy(dbinfo->createdate, buffer,
+ buffer_length * sizeof(char));
+ dbinfo->createdate[buffer_length] = '\0';
+ }
+ dbinfo->state = sqlite3_column_int(stmt, 6);
+ buffer = (char *)(sqlite3_column_text(stmt, 7));
+ dbinfo->url = NULL;
+ if (buffer) {
+ buffer_length = strlen(buffer);
+ dbinfo->url
+ = (char *)calloc(buffer_length + 1, sizeof(char));
+ memcpy(dbinfo->url, buffer,
+ buffer_length * sizeof(char));
+ dbinfo->url[buffer_length] = '\0';
+ }
+ buffer = (char *)(sqlite3_column_text(stmt, 8));
+ dbinfo->mimetype = NULL;
+ if (buffer) {
+ buffer_length = strlen(buffer);
+ dbinfo->mimetype
+ = (char *)calloc(buffer_length + 1, sizeof(char));
+ memcpy(dbinfo->mimetype, buffer,
+ buffer_length * sizeof(char));
+ dbinfo->mimetype[buffer_length] = '\0';
+ }
+ buffer = (char *)(sqlite3_column_text(stmt, 9));
+ dbinfo->saved_path = NULL;
+ if (buffer) {
+ buffer_length = strlen(buffer);
+ dbinfo->saved_path
+ = (char *)calloc(buffer_length + 1, sizeof(char));
+ memcpy(dbinfo->saved_path, buffer,
+ buffer_length * sizeof(char));
+ dbinfo->saved_path[buffer_length] = '\0';
+ }
+ } else {
+ TRACE_DEBUG_MSG("sqlite3_step is failed. [%s] errorcode[%d]",
+ sqlite3_errmsg(g_download_provider_db), errorcode);
+ __download_provider_db_close();
+ download_provider_db_info_free(dbinfo);
+ return NULL;
+ }
+ _download_provider_sql_close(stmt);
+ return dbinfo;
+}
+
download_request_info *download_provider_db_get_requestinfo(download_dbinfo *dbinfo)
{
if (!dbinfo || dbinfo->requestid <= 0)
if (dbinfo->packagename) {
requestinfo->client_packagename.length =
strlen(dbinfo->packagename);
- if (requestinfo->client_packagename.length > 0) {
+ if (requestinfo->client_packagename.length > 1) {
requestinfo->client_packagename.str
=
(char *)
}
if (dbinfo->url) {
requestinfo->url.length = strlen(dbinfo->url);
- if (requestinfo->url.length > 0) {
+ if (requestinfo->url.length > 1) {
requestinfo->url.str
=
(char *)calloc((requestinfo->url.length + 1),
}
if (dbinfo->installpath) {
requestinfo->install_path.length = strlen(dbinfo->installpath);
- if (requestinfo->install_path.length > 0) {
+ if (requestinfo->install_path.length > 1) {
requestinfo->install_path.str
=
(char *)
}
if (dbinfo->filename) {
requestinfo->filename.length = strlen(dbinfo->filename);
- if (requestinfo->filename.length > 0) {
+ if (requestinfo->filename.length > 1) {
requestinfo->filename.str
=
(char *)calloc((requestinfo->filename.length + 1),
int download_provider_db_history_new(download_clientinfo *clientinfo)
{
int errorcode;
- sqlite3_stmt *stmt;
+ sqlite3_stmt *stmt = NULL;
if (!clientinfo || !clientinfo->requestinfo
|| clientinfo->requestinfo->requestid <= 0) {
_download_provider_sql_close(stmt);
return -1;
}
- if (clientinfo->requestinfo->client_packagename.length > 0) {
+ if (clientinfo->requestinfo->client_packagename.length > 1) {
if (sqlite3_bind_text
(stmt, 2, clientinfo->requestinfo->client_packagename.str,
-1, NULL) != SQLITE_OK) {
return -1;
}
}
- if (clientinfo->downloadinfo && clientinfo->downloadinfo->content_name) {
+ if (clientinfo->downloadinfo && sizeof(clientinfo->downloadinfo->content_name) > 1) {
if (sqlite3_bind_text
(stmt, 3, clientinfo->downloadinfo->content_name, -1,
NULL) != SQLITE_OK) {
_download_provider_sql_close(stmt);
return -1;
}
- if (clientinfo->downloadinfo && clientinfo->downloadinfo->mime_type) {
+ if (clientinfo->downloadinfo && sizeof(clientinfo->downloadinfo->mime_type) > 1) {
if (sqlite3_bind_text
(stmt, 5, clientinfo->downloadinfo->mime_type, -1,
NULL) != SQLITE_OK) {
int download_provider_db_history_remove(int uniqueid)
{
int errorcode;
- sqlite3_stmt *stmt;
+ sqlite3_stmt *stmt = NULL;
if (uniqueid <= 0) {
TRACE_DEBUG_MSG("[NULL-CHECK]");
int download_provider_db_history_limit_rows()
{
int errorcode;
- sqlite3_stmt *stmt;
+ sqlite3_stmt *stmt = NULL;
if (_download_provider_sql_open() < 0) {
TRACE_DEBUG_MSG("db_util_open is failed [%s]",
__download_provider_db_close();
return -1;
}
+
+download_dbinfo *download_provider_db_history_get_info(int requestid)
+{
+ if (requestid <= 0)
+ return NULL;
+
+ int errorcode;
+ int buffer_length = 0;
+ sqlite3_stmt *stmt = NULL;
+ char *buffer = NULL;
+ download_dbinfo *dbinfo = NULL;
+
+ if (_download_provider_sql_open() < 0) {
+ TRACE_DEBUG_MSG("db_util_open is failed [%s]",
+ sqlite3_errmsg(g_download_provider_db));
+ return NULL;
+ }
+
+ errorcode =
+ sqlite3_prepare_v2(g_download_provider_db,
+ "SELECT uniqueid, packagename, notification, installpath, filename, creationdate, state, url, mimetype, savedpath FROM history WHERE uniqueid = ?",
+ -1, &stmt, NULL);
+ if (errorcode != SQLITE_OK) {
+ TRACE_DEBUG_MSG("sqlite3_prepare_v2 is failed. [%s]",
+ sqlite3_errmsg(g_download_provider_db));
+ _download_provider_sql_close(stmt);
+ return NULL;
+ }
+ if (sqlite3_bind_int(stmt, 1, requestid) != SQLITE_OK) {
+ TRACE_DEBUG_MSG("sqlite3_bind_int is failed. [%s]",
+ sqlite3_errmsg(g_download_provider_db));
+ _download_provider_sql_close(stmt);
+ return NULL;
+ }
+
+ if ((errorcode = sqlite3_step(stmt)) == SQLITE_ROW) {
+ dbinfo = (download_dbinfo *) calloc(1, sizeof(download_dbinfo));
+ dbinfo->requestid = sqlite3_column_int(stmt, 0);
+ buffer = (char *)(sqlite3_column_text(stmt, 1));
+ dbinfo->packagename = NULL;
+ if (buffer) {
+ buffer_length = strlen(buffer);
+ dbinfo->packagename
+ = (char *)calloc(buffer_length + 1, sizeof(char));
+ memcpy(dbinfo->packagename, buffer,
+ buffer_length * sizeof(char));
+ dbinfo->packagename[buffer_length] = '\0';
+ }
+ dbinfo->notification = sqlite3_column_int(stmt, 2);
+ buffer = (char *)(sqlite3_column_text(stmt, 3));
+ dbinfo->installpath = NULL;
+ if (buffer) {
+ buffer_length = strlen(buffer);
+ dbinfo->installpath
+ = (char *)calloc(buffer_length + 1, sizeof(char));
+ memcpy(dbinfo->installpath, buffer,
+ buffer_length * sizeof(char));
+ dbinfo->installpath[buffer_length] = '\0';
+ }
+ buffer = (char *)(sqlite3_column_text(stmt, 4));
+ dbinfo->filename = NULL;
+ if (buffer) {
+ buffer_length = strlen(buffer);
+ dbinfo->filename
+ = (char *)calloc(buffer_length + 1, sizeof(char));
+ memcpy(dbinfo->filename, buffer,
+ buffer_length * sizeof(char));
+ dbinfo->filename[buffer_length] = '\0';
+ }
+ buffer = (char *)(sqlite3_column_text(stmt, 5));
+ dbinfo->createdate = NULL;
+ if (buffer) {
+ buffer_length = strlen(buffer);
+ dbinfo->createdate
+ = (char *)calloc(buffer_length + 1, sizeof(char));
+ memcpy(dbinfo->createdate, buffer,
+ buffer_length * sizeof(char));
+ dbinfo->createdate[buffer_length] = '\0';
+ }
+ dbinfo->state = sqlite3_column_int(stmt, 6);
+ buffer = (char *)(sqlite3_column_text(stmt, 7));
+ dbinfo->url = NULL;
+ if (buffer) {
+ buffer_length = strlen(buffer);
+ dbinfo->url
+ = (char *)calloc(buffer_length + 1, sizeof(char));
+ memcpy(dbinfo->url, buffer,
+ buffer_length * sizeof(char));
+ dbinfo->url[buffer_length] = '\0';
+ }
+ buffer = (char *)(sqlite3_column_text(stmt, 8));
+ dbinfo->mimetype = NULL;
+ if (buffer) {
+ buffer_length = strlen(buffer);
+ dbinfo->mimetype
+ = (char *)calloc(buffer_length + 1, sizeof(char));
+ memcpy(dbinfo->mimetype, buffer,
+ buffer_length * sizeof(char));
+ dbinfo->mimetype[buffer_length] = '\0';
+ }
+ buffer = (char *)(sqlite3_column_text(stmt, 9));
+ dbinfo->saved_path = NULL;
+ if (buffer) {
+ buffer_length = strlen(buffer);
+ dbinfo->saved_path
+ = (char *)calloc(buffer_length + 1, sizeof(char));
+ memcpy(dbinfo->saved_path, buffer,
+ buffer_length * sizeof(char));
+ dbinfo->saved_path[buffer_length] = '\0';
+ }
+ } else {
+ TRACE_DEBUG_MSG("sqlite3_step is failed. [%s] errorcode[%d]",
+ sqlite3_errmsg(g_download_provider_db), errorcode);
+ __download_provider_db_close();
+ download_provider_db_info_free(dbinfo);
+ return NULL;
+ }
+ _download_provider_sql_close(stmt);
+ return dbinfo;
+}
#include "download-provider-ipc.h"
#include "download-provider-log.h"
+#include "bundle.h"
int ipc_receive_header(int fd)
{
return type;
}
+extern int service_import_from_bundle(service_h service, bundle *data);
int ipc_receive_request_msg(download_clientinfo *clientinfo)
{
if (!clientinfo || clientinfo->clientfd <= 0)
TRACE_DEBUG_MSG("failed to read message header");
return -1;
}
- if (clientinfo->requestinfo->client_packagename.length > 0) {
+ if (clientinfo->requestinfo->client_packagename.length > 1) {
clientinfo->requestinfo->client_packagename.str =
(char *)
calloc((clientinfo->requestinfo->client_packagename.length +
clientinfo->requestinfo->client_packagename.
str);
}
- if (clientinfo->requestinfo->url.length > 0) {
+ if (clientinfo->requestinfo->url.length > 1) {
clientinfo->requestinfo->url.str =
(char *)calloc((clientinfo->requestinfo->url.length + 1),
sizeof(char));
TRACE_DEBUG_MSG("request url [%s]",
clientinfo->requestinfo->url.str);
}
- if (clientinfo->requestinfo->install_path.length > 0) {
+ if (clientinfo->requestinfo->install_path.length > 1) {
clientinfo->requestinfo->install_path.str =
(char *)
calloc((clientinfo->requestinfo->install_path.length + 1),
TRACE_DEBUG_MSG("request install_path [%s]",
clientinfo->requestinfo->install_path.str);
}
- if (clientinfo->requestinfo->filename.length > 0) {
+ if (clientinfo->requestinfo->filename.length > 1) {
clientinfo->requestinfo->filename.str =
(char *)
calloc((clientinfo->requestinfo->filename.length + 1),
TRACE_DEBUG_MSG("request filename [%s]",
clientinfo->requestinfo->filename.str);
}
+ if (clientinfo->requestinfo->service_data.length > 1) {
+ bundle_raw *raw_data = NULL;
+ int len = 0;
+ bundle *b = NULL;
+ service_h service_handle;
+ clientinfo->requestinfo->service_data.str =
+ (char *)
+ calloc((clientinfo->requestinfo->service_data.length + 1),
+ sizeof(char));
+ if (read
+ (clientinfo->clientfd,
+ clientinfo->requestinfo->service_data.str,
+ clientinfo->requestinfo->service_data.length * sizeof(char)) <
+ 0) {
+ TRACE_DEBUG_MSG
+ ("failed to read message header filename(%s)",
+ strerror(errno));
+ return -1;
+ }
+ clientinfo->requestinfo->service_data.str[clientinfo->requestinfo->
+ service_data.length] = '\0';
+ raw_data = (bundle_raw *)clientinfo->requestinfo->service_data.str;
+ len = clientinfo->requestinfo->service_data.length;
+ if ((b = bundle_decode(raw_data, len)) == NULL) {
+ TRACE_DEBUG_MSG("Failed to decode bundle raw data");
+ return -1;
+ }
+ if (service_create(&service_handle) < 0) {
+ TRACE_DEBUG_MSG("Failed to create service handle");
+ bundle_free(b);
+ return -1;
+ }
+ if (service_import_from_bundle(service_handle, b) < 0) {
+ TRACE_DEBUG_MSG("Failed to import service handle");
+ bundle_free(b);
+ service_destroy(service_handle);
+ return -1;
+ }
+
+ clientinfo->service_handle = service_handle;
+ char *pkg = NULL;
+ service_get_package(service_handle, &pkg);
+ if (pkg) {
+ TRACE_DEBUG_MSG("operation### [%s]",pkg);
+ free(pkg);
+ }
+
+ bundle_free(b);
+ }
if (clientinfo->requestinfo->headers.rows) {
clientinfo->requestinfo->headers.str =
(download_flexible_string *) calloc(clientinfo->requestinfo->headers.
strerror(errno));
return -1;
}
- if (clientinfo->requestinfo->headers.str[i].length > 0) {
+ if (clientinfo->requestinfo->headers.str[i].length > 1) {
TRACE_DEBUG_MSG("headers[%d] length[%d]", i,
clientinfo->requestinfo->
headers.str[i].length);
{
char *message = NULL;
switch (state) {
- case DOWNLOAD_STATE_INSTALLING:
- message = S_("IDS_COM_POP_INSTALLING_ING");
- break;
case DOWNLOAD_STATE_FINISHED:
- message = strdup("Completed");
+ //message = S_("IDS_COM_POP_SUCCESS");
+ message = "Completed";
break;
case DOWNLOAD_STATE_STOPPED:
- message = S_("IDS_COM_POP_CANCELLED");
+ //message = S_("IDS_COM_POP_CANCELLED");
+ message = "Canclled";
break;
case DOWNLOAD_STATE_FAILED:
- message = S_("IDS_COM_POP_FAILED");
+ //message = S_("IDS_COM_POP_FAILED");
+ message = "Failed";
break;
default:
break;
return 0;
}
-int create_appfw_service(download_clientinfo *clientinfo)
+int create_appfw_service(download_clientinfo *clientinfo, bool ongoing)
{
if (!clientinfo)
return -1;
- if (!clientinfo->service_handle)
- destroy_appfw_service(clientinfo);
- if (service_create(&clientinfo->service_handle) < 0) {
- TRACE_DEBUG_MSG("failed service_create (%s)", strerror(errno));
- return false;
- }
-
- if (clientinfo->requestinfo
- && clientinfo->requestinfo->client_packagename.str) {
- if (service_set_package(clientinfo->service_handle,
- clientinfo->requestinfo->
- client_packagename.str) < 0)
- TRACE_DEBUG_MSG("failed service_set_package (%s)",
- strerror(errno));
+ if (ongoing) {
+ if (!clientinfo->service_handle) {
+ if (service_create(&clientinfo->service_handle) < 0) {
+ TRACE_DEBUG_MSG("failed service_create (%s)", strerror(errno));
+ return false;
+ }
+ if (clientinfo->requestinfo
+ && clientinfo->requestinfo->client_packagename.str) {
+ if (service_set_package(clientinfo->service_handle,
+ clientinfo->requestinfo->
+ client_packagename.str) < 0)
+ TRACE_DEBUG_MSG("failed service_set_package (%s)",
+ strerror(errno));
+ }
+ }
+ } else {
+ if (clientinfo->service_handle) {
+ destroy_appfw_service(clientinfo);
+ }
+ if (service_create(&clientinfo->service_handle) < 0) {
+ TRACE_DEBUG_MSG("failed service_create (%s)", strerror(errno));
+ return false;
+ }
}
return 0;
}
}
if (clientinfo->downloadinfo) {
- if (clientinfo->downloadinfo->content_name) {
- if (ui_notification_set_title
- (clientinfo->ui_notification_handle,
- clientinfo->downloadinfo->content_name) < 0) {
- TRACE_DEBUG_MSG
- ("failed ui_notification_set_title (%s)",
- strerror(errno));
- destroy_appfw_notification(clientinfo);
- return -1;
- }
+ TRACE_DEBUG_MSG("###content_name[%s]", clientinfo->downloadinfo->content_name);
+ char *title = clientinfo->downloadinfo->content_name;
+ if (!title)
+ //title = S_("IDS_COM_BODY_NO_NAME");
+ title = "No name";
+ if (ui_notification_set_title(
+ clientinfo->ui_notification_handle, title) < 0) {
+ TRACE_DEBUG_MSG
+ ("failed ui_notification_set_title (%s)",
+ strerror(errno));
+ destroy_appfw_notification(clientinfo);
+ return -1;
}
}
return -1;
}
- create_appfw_service(clientinfo);
- if (clientinfo->service_handle) {
- if (!ongoing) {
- // view the special viewer by contents
- if (clientinfo->service_handle
- && clientinfo->downloadinginfo
- && clientinfo->downloadinginfo->saved_path
- && clientinfo->state == DOWNLOAD_STATE_FINISHED) {
- if (service_set_operation
- (clientinfo->service_handle,
- SERVICE_OPERATION_VIEW) < 0) {
- TRACE_DEBUG_MSG
- ("Fail service_set_operation");
- destroy_appfw_service(clientinfo);
- }
- if (service_set_uri(clientinfo->service_handle,
- clientinfo->downloadinginfo->saved_path)
- < 0) {
- TRACE_DEBUG_MSG("Fail service_set_uri");
- destroy_appfw_service(clientinfo);
- }
+ create_appfw_service(clientinfo, ongoing);
+ if (!ongoing) {
+ // view the special viewer by contents
+ if (clientinfo->downloadinginfo
+ && clientinfo->downloadinginfo->saved_path
+ && clientinfo->state == DOWNLOAD_STATE_FINISHED) {
+ if (service_set_operation
+ (clientinfo->service_handle,
+ SERVICE_OPERATION_VIEW) < 0) {
+ TRACE_DEBUG_MSG
+ ("Fail service_set_operation");
+ destroy_appfw_service(clientinfo);
}
+ if (service_set_uri(clientinfo->service_handle,
+ clientinfo->downloadinginfo->saved_path)
+ < 0) {
+ TRACE_DEBUG_MSG("Fail service_set_uri");
+ destroy_appfw_service(clientinfo);
+ }
+ } else {
+ if (service_set_package(clientinfo->service_handle,
+ clientinfo->requestinfo->
+ client_packagename.str) < 0)
+ TRACE_DEBUG_MSG("failed service_set_package (%s)",
+ strerror(errno));
}
- if (ui_notification_set_service
- (clientinfo->ui_notification_handle,
- clientinfo->service_handle) < 0) {
- TRACE_DEBUG_MSG("Fail ui_notification_set_service");
- destroy_appfw_service(clientinfo);
- }
+ }
+ if (ui_notification_set_service
+ (clientinfo->ui_notification_handle,
+ clientinfo->service_handle) < 0) {
+ TRACE_DEBUG_MSG("Fail ui_notification_set_service");
+ destroy_appfw_service(clientinfo);
}
if ((ret =
destroy_appfw_notification(clientinfo);
return 0;
}
+
+void clear_downloadinginfo_appfw_notification()
+{
+ ui_notification_cancel_all_by_type(true);
+ return;
+}
for (i = 0; i < len; i++)
req_header[i] =
strdup(clientinfo->requestinfo->headers.str[i].str);
- if (clientinfo->requestinfo->install_path.length > 0)
- da_ret =
- da_start_download_with_extension(clientinfo->requestinfo->
+ if (clientinfo->requestinfo->install_path.length > 1) {
+ if (clientinfo->requestinfo->filename.length > 1)
+ da_ret =
+ da_start_download_with_extension(clientinfo->requestinfo->
url.str, &req_dl_id,
DA_FEATURE_REQUEST_HEADER,
req_header, &len,
DA_FEATURE_INSTALL_PATH,
clientinfo->requestinfo->install_path.str,
+ DA_FEATURE_FILE_NAME,
+ clientinfo->requestinfo->filename.str,
DA_FEATURE_USER_DATA,
(void *)clientinfoslot,
NULL);
- else
- da_ret =
- da_start_download_with_extension(clientinfo->requestinfo->
+ else
+ da_ret =
+ da_start_download_with_extension(clientinfo->requestinfo->
+ url.str, &req_dl_id,
+ DA_FEATURE_REQUEST_HEADER,
+ req_header, &len,
+ DA_FEATURE_INSTALL_PATH,
+ clientinfo->requestinfo->install_path.str,
+ DA_FEATURE_USER_DATA,
+ (void *)clientinfoslot,
+ NULL);
+ } else {
+ if (clientinfo->requestinfo->filename.length > 1)
+ da_ret =
+ da_start_download_with_extension(clientinfo->requestinfo->
+ url.str, &req_dl_id,
+ DA_FEATURE_REQUEST_HEADER,
+ req_header, &len,
+ DA_FEATURE_FILE_NAME,
+ clientinfo->requestinfo->filename.str,
+ DA_FEATURE_USER_DATA,
+ (void *)clientinfoslot,
+ NULL);
+ else
+ da_ret =
+ da_start_download_with_extension(clientinfo->requestinfo->
url.str, &req_dl_id,
DA_FEATURE_REQUEST_HEADER,
req_header, &len,
DA_FEATURE_USER_DATA,
(void *)clientinfoslot,
NULL);
+ }
for (i = 0; i < len; i++) {
if (req_header[i])
free(req_header[i]);
}
} else {
- if (clientinfo->requestinfo->install_path.length > 0)
- da_ret =
- da_start_download_with_extension(clientinfo->requestinfo->
+ if (clientinfo->requestinfo->install_path.length > 1) {
+ if (clientinfo->requestinfo->filename.length > 1)
+ da_ret =
+ da_start_download_with_extension(clientinfo->requestinfo->
+ url.str, &req_dl_id,
+ DA_FEATURE_INSTALL_PATH,
+ clientinfo->requestinfo->install_path.str,
+ DA_FEATURE_FILE_NAME,
+ clientinfo->requestinfo->filename.str,
+ DA_FEATURE_USER_DATA,
+ (void *)clientinfoslot,
+ NULL);
+ else
+ da_ret =
+ da_start_download_with_extension(clientinfo->requestinfo->
url.str, &req_dl_id,
DA_FEATURE_INSTALL_PATH,
clientinfo->requestinfo->install_path.str,
DA_FEATURE_USER_DATA,
(void *)clientinfoslot,
NULL);
- else
- da_ret =
- da_start_download_with_extension(clientinfo->requestinfo->
+ } else {
+ if (clientinfo->requestinfo->filename.length > 1)
+ da_ret =
+ da_start_download_with_extension(clientinfo->requestinfo->
url.str, &req_dl_id,
+ DA_FEATURE_FILE_NAME,
+ clientinfo->requestinfo->filename.str,
DA_FEATURE_USER_DATA,
(void *)clientinfoslot,
NULL);
+ else
+ da_ret =
+ da_start_download_with_extension(clientinfo->requestinfo->
+ url.str, &req_dl_id,
+ DA_FEATURE_USER_DATA,
+ (void *)clientinfoslot,
+ NULL);
+ }
}
// if start_download() return error cause of maximun download limitation, set state to DOWNLOAD_STATE_PENDED.
requestinfo->requestid);
ipc_send_request_stateinfo(clientinfo);
CLIENT_MUTEX_UNLOCK(&(clientinfo->client_mutex));
- clear_clientinfoslot(clientinfoslot);
return 0;
}
request_clientinfo->requestinfo->requestid);
if (type == DOWNLOAD_CONTROL_STOP) {
TRACE_DEBUG_MSG("Request : DOWNLOAD_CONTROL_STOP");
- // remove info from downloading table.
- download_provider_db_requestinfo_remove
- (request_clientinfo->requestinfo->requestid);
if (searchindex >= 0) {
- CLIENT_MUTEX_LOCK(&
- (clientinfo_list[searchindex].clientinfo->client_mutex));
if (da_cancel_download
(clientinfo_list[searchindex].clientinfo->req_id)
== DA_RESULT_OK) {
request_clientinfo->state = DOWNLOAD_STATE_STOPPED;
request_clientinfo->err = DOWNLOAD_ERROR_NONE;
+ if (clientinfo_list[searchindex].clientinfo->requestinfo
+ && clientinfo_list[searchindex].clientinfo->requestinfo->notification)
+ set_downloadedinfo_appfw_notification(clientinfo_list[searchindex].clientinfo);
+ download_provider_db_requestinfo_remove(request_clientinfo->requestinfo->requestid);
+ download_provider_db_history_new(clientinfo_list[searchindex].clientinfo);
} else {
request_clientinfo->state = DOWNLOAD_STATE_FAILED;
request_clientinfo->err = DOWNLOAD_ERROR_INVALID_PARAMETER;
}
- ipc_send_stateinfo(request_clientinfo);
- CLIENT_MUTEX_UNLOCK(&
- (clientinfo_list[searchindex].clientinfo->client_mutex));
+ } else { // no found
+ request_clientinfo->state = DOWNLOAD_STATE_NONE;
+ request_clientinfo->err = DOWNLOAD_ERROR_NONE;
}
- } else if (type == DOWNLOAD_CONTROL_GET_STATE_INFO)
- {
- // not implemented yet
+ ipc_send_stateinfo(request_clientinfo);
+ } else if (type == DOWNLOAD_CONTROL_GET_STATE_INFO) {
// search slots/downloading db/history db
+ if (searchindex > 0) { // exist in slots (memory)
+ request_clientinfo->state =
+ clientinfo_list[searchindex].clientinfo->state;
+ request_clientinfo->err =
+ clientinfo_list[searchindex].clientinfo->err;
+ } else { //search downloading db or history db
+ download_dbinfo* dbinfo =
+ download_provider_db_get_info(
+ request_clientinfo->requestinfo->requestid);
+ if (dbinfo) { // found in downloading db..it means crashed job
+ request_clientinfo->state = DOWNLOAD_STATE_PENDED;
+ request_clientinfo->err = DOWNLOAD_ERROR_TOO_MANY_DOWNLOADS;
+ } else { // no exist in downloading db
+ dbinfo = download_provider_db_history_get_info(
+ request_clientinfo->requestinfo->requestid);
+ if (!dbinfo) { // no info anywhere
+ request_clientinfo->state = DOWNLOAD_STATE_NONE;
+ request_clientinfo->err = DOWNLOAD_ERROR_NONE;
+ } else { //history info
+ request_clientinfo->state = dbinfo->state;
+ request_clientinfo->err = DOWNLOAD_ERROR_NONE;
+ }
+ }
+ download_provider_db_info_free(dbinfo);
+ }
+ ipc_send_stateinfo(request_clientinfo);
// estabilish the spec of return value.
}
}
int searchindex = get_same_request_slot_index(clientinfo_list,
request_clientinfo->requestinfo->requestid);
if (searchindex < 0) {
- CLIENT_MUTEX_LOCK(&(request_clientinfo->client_mutex));
TRACE_DEBUG_MSG("Not Found Same Request ID");
- request_clientinfo->requestinfo->requestid = 0;
// Invalid id
request_clientinfo->state = DOWNLOAD_STATE_FAILED;
request_clientinfo->err = DOWNLOAD_ERROR_INVALID_PARAMETER;
ipc_send_request_stateinfo(request_clientinfo);
- CLIENT_MUTEX_UNLOCK(&(request_clientinfo->client_mutex));
clear_clientinfo(request_clientinfo);
return 0;
} else { // found request id. // how to deal etag ?
return -1;
}
- CLIENT_MUTEX_LOCK(&(clientinfo->client_mutex));
switch (msgType = ipc_receive_header(clientinfo->clientfd)) {
case DOWNLOAD_CONTROL_STOP:
TRACE_DEBUG_MSG("DOWNLOAD_CONTROL_STOP");
da_ret = da_cancel_download(clientinfo->req_id);
+ CLIENT_MUTEX_LOCK(&(clientinfo->client_mutex));
if (da_ret != DA_RESULT_OK) {
/* FIXME : need to seperate in detail according to error return values */
clientinfo->state = DOWNLOAD_STATE_FAILED;
} else {
clientinfo->state = DOWNLOAD_STATE_STOPPED;
clientinfo->err = DOWNLOAD_ERROR_NONE;
+ if (clientinfo->requestinfo) {
+ if (clientinfo->requestinfo->notification)
+ set_downloadedinfo_appfw_notification(clientinfo);
+ download_provider_db_requestinfo_remove(clientinfo->
+ requestinfo->requestid);
+ }
+ download_provider_db_history_new(clientinfo);
}
ipc_send_stateinfo(clientinfo);
+ CLIENT_MUTEX_UNLOCK(&(clientinfo->client_mutex));
break;
case DOWNLOAD_CONTROL_PAUSE:
TRACE_DEBUG_MSG("DOWNLOAD_CONTROL_PAUSE");
da_ret = da_suspend_download(clientinfo->req_id);
+ CLIENT_MUTEX_LOCK(&(clientinfo->client_mutex));
if (da_ret != DA_RESULT_OK) {
/* FIXME : need to seperate in detail according to error return values */
clientinfo->state = DOWNLOAD_STATE_FAILED;
clientinfo->err = DOWNLOAD_ERROR_NONE;
}
ipc_send_stateinfo(clientinfo);
+ CLIENT_MUTEX_UNLOCK(&(clientinfo->client_mutex));
break;
case DOWNLOAD_CONTROL_RESUME:
TRACE_DEBUG_MSG("DOWNLOAD_CONTROL_RESUME");
da_ret = da_resume_download(clientinfo->req_id);
+ CLIENT_MUTEX_LOCK(&(clientinfo->client_mutex));
if (da_ret != DA_RESULT_OK) {
/* FIXME : need to seperate in detail according to error return values */
clientinfo->state = DOWNLOAD_STATE_FAILED;
clientinfo->err = DOWNLOAD_ERROR_NONE;
}
ipc_send_stateinfo(clientinfo);
+ CLIENT_MUTEX_UNLOCK(&(clientinfo->client_mutex));
break;
case DOWNLOAD_CONTROL_GET_STATE_INFO: // sync call
TRACE_DEBUG_MSG("DOWNLOAD_CONTROL_GET_STATE_INFO");
+ CLIENT_MUTEX_LOCK(&(clientinfo->client_mutex));
ipc_send_stateinfo(clientinfo);
+ CLIENT_MUTEX_UNLOCK(&(clientinfo->client_mutex));
break;
case DOWNLOAD_CONTROL_GET_DOWNLOAD_INFO: // sync call
TRACE_DEBUG_MSG("DOWNLOAD_CONTROL_GET_DOWNLOAD_INFO");
+ CLIENT_MUTEX_LOCK(&(clientinfo->client_mutex));
ipc_send_downloadinfo(clientinfo);
+ CLIENT_MUTEX_UNLOCK(&(clientinfo->client_mutex));
break;
case -1:
case 0:
// bloken socket... it seems the client is dead or closed by agent thread.
// close socket, this will break the loop. and terminate this thread.
clear_socket(clientinfo);
- CLIENT_MUTEX_UNLOCK(&(clientinfo->client_mutex));
return -1;
default:
TRACE_DEBUG_MSG("Unknow message [%d]", msgType);
- CLIENT_MUTEX_UNLOCK(&(clientinfo->client_mutex));
return -1;
}
- CLIENT_MUTEX_UNLOCK(&(clientinfo->client_mutex));
return 0;
}
TerminateDaemon(SIGTERM);
return 0;
}
+ clear_downloadinginfo_appfw_notification();
if ((listenfd = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) {
TRACE_DEBUG_MSG("failed to create socket");
for (i=0; i < MAX_CLIENT; i++) {
if (!clientinfo_list[i].clientinfo)
continue;
- CLIENT_MUTEX_LOCK(&(clientinfo_list[i].clientinfo->client_mutex));
// clear slot.
if (clientinfo_list[i].clientinfo->state >= DOWNLOAD_STATE_FINISHED) {
- CLIENT_MUTEX_UNLOCK(&(clientinfo_list[i].clientinfo->client_mutex));
clear_clientinfoslot(&clientinfo_list[i]);
continue;
}
- CLIENT_MUTEX_UNLOCK(&(clientinfo_list[i].clientinfo->client_mutex));
}
rset = g_download_provider_socket_readset;
for (i=0; i < MAX_CLIENT; i++) { // find the socket received the packet.
if (!clientinfo_list[i].clientinfo)
continue;
+ // ignore it is not started yet.
+ if (clientinfo_list[i].clientinfo->state <= DOWNLOAD_STATE_READY)
+ continue;
// ignore if finished
- //if (clientinfo_list[i].clientinfo->state >= DOWNLOAD_STATE_FINISHED)
- //continue;
+ if (clientinfo_list[i].clientinfo->state >= DOWNLOAD_STATE_FINISHED)
+ continue;
//Even if no socket, downloading should be progressed.
if (clientinfo_list[i].clientinfo->clientfd <= 0)
continue;
sleep(5); // provider need the time of refresh.
continue;
}
- FD_SET(request_clientinfo->clientfd, &g_download_provider_socket_readset); // add new descriptor to set
- FD_SET(request_clientinfo->clientfd, &g_download_provider_socket_exceptset);
- if (request_clientinfo->clientfd > maxfd )
- maxfd = request_clientinfo->clientfd; /* for select */
-
if (_handle_new_connection(clientinfo_list, request_clientinfo) < 0) {
sleep(1);
continue;
}
+ // after starting the download by DA, event thread will start to get the event from client.
+ if (request_clientinfo && request_clientinfo->clientfd > 0) {
+ FD_SET(request_clientinfo->clientfd, &g_download_provider_socket_readset); // add new descriptor to set
+ FD_SET(request_clientinfo->clientfd, &g_download_provider_socket_exceptset);
+ if (request_clientinfo->clientfd > maxfd )
+ maxfd = request_clientinfo->clientfd; /* for select */
+ }
}
if (i >= MAX_CLIENT) { // timeout
TRACE_DEBUG_MSG("[CRITICAL] clientinfo is NULL");
return;
}
- CLIENT_MUTEX_LOCK(&(clientinfo->client_mutex));
+
TRACE_DEBUG_MSG("id[%d],state[%d],err[%d]",
notify_info->da_dl_req_id,
notify_info->state, notify_info->err);
if (clientinfo->req_id != notify_info->da_dl_req_id) {
TRACE_DEBUG_MSG("[CRITICAL] req_id[%d] da_dl_req_id[%d}",
clientinfo->req_id, notify_info->da_dl_req_id);
- CLIENT_MUTEX_UNLOCK(&(clientinfo->client_mutex));
return;
}
+ CLIENT_MUTEX_LOCK(&(clientinfo->client_mutex));
+
clientinfo->state = __change_state(notify_info->state);
clientinfo->err = __change_error(notify_info->err);
- if (clientinfo->state >= DOWNLOAD_STATE_FINISHED) {
+ if (clientinfo->state == DOWNLOAD_STATE_FINISHED ||
+ clientinfo->state == DOWNLOAD_STATE_FAILED) {
if (clientinfo->requestinfo) {
if (clientinfo->requestinfo->notification)
set_downloadedinfo_appfw_notification(clientinfo);
if (clientinfo->requestinfo->filename.str)
free(clientinfo->requestinfo->filename.str);
clientinfo->requestinfo->filename.str = NULL;
+ if (clientinfo->requestinfo->service_data.str)
+ free(clientinfo->requestinfo->service_data.str);
+ clientinfo->requestinfo->service_data.str = NULL;
if (clientinfo->requestinfo->headers.rows) {
int i = 0;
for (i = 0; i < clientinfo->requestinfo->headers.rows;