SET(LOCALEDIR "${RESDIR}/locale")
SET(ICONDIR "/opt/share/icons/default/small/")
SET(HISTORYDB ".download-history.db")
+SET(EDJE_DIR "${RESDIR}/edje")
IF("${CMAKE_BUILD_TYPE}" STREQUAL "")
SET(CMAKE_BUILD_TYPE "Release")
edje
icu-i18n
xdgmime
+ edje
)
FIND_LIBRARY(LIB_DL dl)
ADD_DEFINITIONS("-DLOCALEDIR=\"${LOCALEDIR}\"")
ADD_DEFINITIONS("-DICONDIR=\"${ICONDIR}\"")
ADD_DEFINITIONS("-DHISTORYDB=\"${HISTORYDB}\"")
+ADD_DEFINITIONS("-DEDJE_DIR=\"${EDJE_DIR}\"")
ADD_EXECUTABLE(${PROJECT_NAME} ${SRCS})
TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS} ${LIB_DL})
+ADD_CUSTOM_TARGET(download-manager.edj
+ COMMAND edje_cc -id ${CMAKE_SOURCE_DIR}/images
+ ${CMAKE_SOURCE_DIR}/res/download-manager.edc
+ ${CMAKE_BINARY_DIR}/res/download-manager.edj
+ DEPENDS ${CMAKE_SOURCE_DIR}/res/download-manager.edc)
+ADD_DEPENDENCIES(${PROJECT_NAME} download-manager.edj)
+
INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${BINDIR})
INSTALL(DIRECTORY DESTINATION ${DATADIR})
INSTALL(DIRECTORY DESTINATION ${DBDATADIR})
INSTALL(FILES ${CMAKE_BINARY_DIR}/res/${PKGNAME}.xml DESTINATION /opt/share/packages)
INSTALL(DIRECTORY ${CMAKE_SOURCE_DIR}/res/images DESTINATION ${RESDIR})
+INSTALL(FILES ${CMAKE_BINARY_DIR}/res/download-manager.edj DESTINATION ${EDJE_DIR})
# i18n
ADD_SUBDIRECTORY(po)
/opt/apps/org.tizen.download-manager/bin/*
/opt/apps/org.tizen.download-manager/data
/opt/apps/org.tizen.download-manager/res/*
+/opt/apps/org.tizen.download-manager/res/edje/*
/opt/share/packages/org.tizen.download-manager.xml
%changelog
#include <iostream>
#include "download-manager-downloadItem.h"
#include "download-manager-common.h"
+#include "app_service.h"
static Ecore_Pipe *ecore_pipe = NULL;
static void __ecore_cb_pipe_update(void *data, void *buffer, unsigned int nbyte);
DP_LOGD("registeredFilePath[%s]", m_registeredFilePath.c_str());
downloadItem->setRegisteredFilePath(m_registeredFilePath);
}
+ downloadItem->destroyHandle();
break;
case DA_CB::STOPPED:
if (m_error != URL_DOWNLOAD_ERROR_NONE) {
} else {
downloadItem->setState(DL_ITEM::CANCELED);
}
+ downloadItem->destroyHandle();
break;
default:
break;
, m_fileSize(0)
, m_downloadType(DL_TYPE::HTTP_DOWNLOAD)
{
+}
+
+void DownloadItem::createHandle()
+{
int ret = url_download_create(&m_download_handle);
if (ret != URL_DOWNLOAD_ERROR_NONE) {
DP_LOGE("Fail to create download handle : [%d]", ret);
DP_LOGE("Fail to set progress cb : [%d]", ret);
return;
}
+
+ service_h service_handle;
+ ret = service_create(&service_handle);
+ if (ret < 0) {
+ DP_LOGE("Fail to create service handle");
+ return;
+ }
+
+ ret = service_set_package(service_handle, PACKAGE_NAME);
+ if (ret < 0) {
+ DP_LOGE("Fail to set package name");
+ return;
+ }
+ ret = url_download_set_notification(m_download_handle, service_handle);
+ if (ret != URL_DOWNLOAD_ERROR_NONE) {
+ DP_LOGE("Fail to set notification : [%d]", ret);
+ return;
+ }
+ ret = service_destroy(service_handle);
+ if (ret < 0) {
+ DP_LOGE("Fail to create service handle");
+ return;
+ }
}
DownloadItem::~DownloadItem()
{
DP_LOGD_FUNC();
+ destroyHandle();
+}
+
+void DownloadItem::destroyHandle()
+{
if (!m_download_handle)
return;
+ DP_LOGD("download handle[%p]", m_download_handle);
url_download_unset_started_cb(m_download_handle);
url_download_unset_completed_cb(m_download_handle);
url_download_unset_paused_cb(m_download_handle);
url_download_unset_stopped_cb(m_download_handle);
url_download_unset_progress_cb(m_download_handle);
url_download_destroy(m_download_handle);
+ m_download_handle = NULL;
}
void DownloadItem::started_cb(url_download_h download, const char *name,
void DownloadItem::start(bool isRetry)
{
int ret = 0;
- int id = 0;
DP_LOGD_FUNC();
- if (!m_download_handle) {
- DP_LOGE("handle is NULL");
+ if (m_download_handle) {
+ destroyHandle();
+ }
+ createHandle();
+
+ ret = url_download_set_url(m_download_handle,
+ m_aptr_request->getUrl().c_str());
+ if (ret != URL_DOWNLOAD_ERROR_NONE) {
+ DP_LOGE("Fail to set url : [%d]", ret);
m_state = DL_ITEM::FAILED;
m_errorCode = ERROR::ENGINE_FAIL;
notify();
return;
}
-
- if (!isRetry) {
- ret = url_download_set_url(m_download_handle,
- m_aptr_request->getUrl().c_str());
+ if (!m_aptr_request->getCookie().empty()) {
+ ret = url_download_add_http_header_field(m_download_handle,
+ "Cookie", m_aptr_request->getCookie().c_str());
if (ret != URL_DOWNLOAD_ERROR_NONE) {
- DP_LOGE("Fail to set url : [%d]", ret);
+ DP_LOGE("Fail to set cookie : [%d]", ret);
m_state = DL_ITEM::FAILED;
m_errorCode = ERROR::ENGINE_FAIL;
notify();
return;
}
- if (!m_aptr_request->getCookie().empty()) {
- ret = url_download_add_http_header_field(m_download_handle,
- "Cookie", m_aptr_request->getCookie().c_str());
- if (ret != URL_DOWNLOAD_ERROR_NONE) {
- DP_LOGE("Fail to set cookie : [%d]", ret);
- m_state = DL_ITEM::FAILED;
- m_errorCode = ERROR::ENGINE_FAIL;
- notify();
- return;
- }
- }
}
- ret = url_download_start(m_download_handle, &id);
- DP_LOGD("URL download handle : handle[%p]id[%d]", m_download_handle, id);
+ ret = url_download_start(m_download_handle, &m_download_id);
+ DP_LOGD("URL download handle : handle[%p]id[%d]", m_download_handle, m_download_id);
if (ret != URL_DOWNLOAD_ERROR_NONE) {
m_state = DL_ITEM::FAILED;
void DownloadItem::resume()
{
- int id = 0;
- int ret = url_download_start(m_download_handle, &id);
+ int ret = url_download_start(m_download_handle, &m_download_id);
if (ret != URL_DOWNLOAD_ERROR_NONE) {
DP_LOGE("Fail to resume download : handle[%p] err[%d]",
m_download_handle, ret);
void Items::detachItem(Item *item)
{
vector<Item *>::iterator it;
- for (it = m_items.begin() ; it < m_items.end() ; it++) {
+ for (it = m_items.begin(); it < m_items.end(); it++) {
if (*it == item) {
- m_items.erase(it);
delete item;
+ m_items.erase(it);
}
}
}
, eoCbItemDelete(NULL)
, eoCbItemCancel(NULL)
, eoCbItemEmpty(NULL)
+ , eoNotifyTimer(NULL)
, eoBoxLayout(NULL)
, eoBox(NULL)
, eoDldList(NULL)
, eoPopup(NULL)
, eoSelectAllLayout(NULL)
, eoAllCheckedBox(NULL)
- , eoNotifyInfo(NULL)
, eoNotifyInfoLayout(NULL)
, m_allChecked(EINA_FALSE)
#ifndef _TIZEN_PUBLIC
{
DownloadEngine &engine = DownloadEngine::getInstance();
engine.deinitEngine();
+ ecore_timer_del(eoNotifyTimer);
}
void DownloadView::show()
{
DP_LOGD_FUNC();
eoBoxLayout = elm_layout_add(eoNaviBar);
- elm_layout_theme_set(eoBoxLayout, "layout", "application", "noindicator");
+ elm_layout_file_set(eoBoxLayout,
+ "/opt/apps/com.samsung.download-manager/res/edje/download-manager.edj",
+ "download/selectioninfo");
+
evas_object_size_hint_weight_set(eoBoxLayout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_size_hint_align_set(eoBoxLayout, EVAS_HINT_FILL, EVAS_HINT_FILL);
eoBox = elm_box_add(eoBoxLayout);
- elm_object_part_content_set(eoBoxLayout, "elm.swallow.content", eoBox );
+ elm_object_part_content_set(eoBoxLayout, "gen.swallow.contents", eoBox);
evas_object_show(eoBox);
evas_object_show(eoBoxLayout);
void DownloadView::createNotifyInfo()
{
DP_LOGD_FUNC();
- eoNotifyInfo = elm_notify_add(eoBoxLayout);
- elm_notify_orient_set(eoNotifyInfo, ELM_NOTIFY_ORIENT_BOTTOM);
- evas_object_size_hint_weight_set(eoNotifyInfo, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- evas_object_size_hint_align_set(eoNotifyInfo, EVAS_HINT_FILL, EVAS_HINT_FILL);
- evas_object_event_callback_add(eoNotifyInfo, EVAS_CALLBACK_SHOW, showNotifyInfoCB, eoLayout);
- evas_object_event_callback_add(eoNotifyInfo, EVAS_CALLBACK_HIDE, hideNotifyInfoCB, eoLayout);
- eoNotifyInfoLayout = elm_layout_add(eoNotifyInfo);
- elm_object_content_set(eoNotifyInfo, eoNotifyInfoLayout);
+ eoNotifyInfoLayout = elm_layout_add(eoBoxLayout);
+ elm_object_part_content_set(eoBoxLayout, "sel.swallow.contents",
+ eoNotifyInfoLayout);
+ evas_object_size_hint_weight_set(eoNotifyInfoLayout,
+ EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_size_hint_align_set(eoNotifyInfoLayout,
+ EVAS_HINT_FILL, EVAS_HINT_FILL);
}
void DownloadView::showNotifyInfo(int type, int selectedCount)
{
-#ifndef _TIZEN_PUBLIC
- int angle = 0;
-#endif
string buf;
DP_LOGD_FUNC();
-#ifndef _TIZEN_PUBLIC
- angle = elm_win_rotation_get(eoWindow);
-#endif
-
if (selectedCount == 0) {
destroyNotifyInfo();
return;
}
- if (!eoNotifyInfo)
+ if (!eoNotifyInfoLayout)
createNotifyInfo();
-#ifndef _TIZEN_PUBLIC
- if (angle == 0 || angle == 180)
- elm_layout_theme_set(eoNotifyInfoLayout, "standard", "selectioninfo",
- "vertical/bottom_12");
- else
- elm_layout_theme_set(eoNotifyInfoLayout, "standard", "selectioninfo",
- "horizontal/bottom_12");
-#else
elm_layout_theme_set(eoNotifyInfoLayout, "standard", "selectioninfo",
- "vertical/bottom_12");
-#endif
+ "default");
buf.append(" ");
if (type == DOWNLOAD_NOTIFY_SELECTED) {
stringstream countStr;
buf.append(")");
} else if (type == DOWNLOAD_NOTIFY_DELETED) {
buf = S_("IDS_COM_POP_DELETED");
- elm_notify_timeout_set(eoNotifyInfo, 3);
+ if (eoNotifyTimer) {
+ ecore_timer_del(eoNotifyTimer);
+ eoNotifyTimer = NULL;
+ }
+ eoNotifyTimer = ecore_timer_add(3, deletedNotifyTimerCB, NULL);
}
- edje_object_part_text_set(_EDJ(eoNotifyInfoLayout), "elm.text", buf.c_str());
- evas_object_show(eoNotifyInfo);
+ elm_object_part_text_set(eoNotifyInfoLayout, "elm.text", buf.c_str());
+ elm_object_signal_emit(eoBoxLayout, "show,selection,info", "elm");
+ evas_object_show(eoNotifyInfoLayout);
+}
+
+Eina_Bool DownloadView::deletedNotifyTimerCB(void *data)
+{
+ DownloadView& view = DownloadView::getInstance();
+ view.destroyNotifyInfo();
+ return ECORE_CALLBACK_RENEW;
}
void DownloadView::destroyNotifyInfo()
{
DP_LOGD_FUNC();
destroyEvasObj(eoNotifyInfoLayout);
- destroyEvasObj(eoNotifyInfo);
eoNotifyInfoLayout = NULL;
- eoNotifyInfo = NULL;
}
/* Static callback function */
unitBytes = 1 << (10*unit);
doubleTypeBytes = ((double)bytes / (double)(unitBytes));
// FIXME following code should be broken into another function, but leave it now to save function call time.s
- char str[32] = {0};
+ char str[64] = {0};
if (progressOption && fileSize() != 0) {
/* using fixed point arithmetic to avoid floating point arithmetic */
const int fixed_point = 6;
else
snprintf(str, sizeof(str), "%.2f %s", doubleTypeBytes, unitStr[unit]);
}
- return string(str).c_str();
+ str[63] = '\0';
+ string temp = string(str);
+ return temp.c_str();
}
unsigned long int ViewItem::receivedFileSize()
void retry(void);
void suspend(void);
void resume(void);
+ void createHandle(void);
+ void destroyHandle(void);
inline void *downloadHandle(void) { return (void *)m_download_handle;}
inline void setDownloadHandle(url_download_h handle) { m_download_handle = handle; }
string m_registeredFilePath;
string m_mimeType;
DL_TYPE::TYPE m_downloadType;
+ int m_download_id;
};
class DownloadEngine {
static void genlistClickCB(void *data, Evas_Object *obj, void *event_info);
static void cancelClickCB(void *data, Evas_Object *obj, void *event_info);
static void errPopupResponseCB(void *data, Evas_Object *obj, void *event_info);
+ static Eina_Bool deletedNotifyTimerCB(void *data);
private:
DownloadView();
Elm_Object_Item *eoCbItemDelete;
Elm_Object_Item *eoCbItemCancel;
Elm_Object_Item *eoCbItemEmpty;
+ Ecore_Timer *eoNotifyTimer;
Evas_Object *eoBoxLayout;
Evas_Object *eoBox;
Evas_Object *eoDldList;
Evas_Object *eoPopup;
Evas_Object *eoSelectAllLayout;
Evas_Object *eoAllCheckedBox;
- Evas_Object *eoNotifyInfo;
Evas_Object *eoNotifyInfoLayout;
Elm_Genlist_Item_Class dldGenlistGroupStyle;
Eina_Bool m_allChecked;
~ViewItem();
static void create(Item *item);
void destroy(void);
- inline void deleteFromDB(void) { m_item->deleteFromDB(); }
+ inline void deleteFromDB(void) {
+ if (m_item)
+ m_item->deleteFromDB();
+ }
inline void setItem(Item *item) { m_item = item; }
static void updateCB(void *);
{ return &dldHistoryGenlistStyle; }
inline Elm_Genlist_Item_Class *elmGenlistFailedItemClass(void)
{ return &dldGenlistSlideStyle; }
- inline ITEM::STATE state(void) { return m_item->state(); }
- inline const char* stateStr(void) { return m_item->stateStr(); }
- inline bool isFinished(void) { return m_item->isFinished(); }
- inline bool isFinishedWithErr(void) { return m_item->isFinishedWithErr(); }
- inline bool isPreparingDownload(void) { return m_item->isPreparingDownload(); }
- inline bool isCompletedDownload(void) { return m_item->isCompletedDownload(); }
+ inline ITEM::STATE state(void) {
+ if (m_item)
+ return m_item->state();
+ else
+ return ITEM::IDLE;
+ }
+ inline const char* stateStr(void) {
+ if (m_item)
+ return m_item->stateStr();
+ else
+ return NULL;
+ }
+ inline bool isFinished(void) {
+ if (m_item)
+ return m_item->isFinished();
+ else
+ return false;
+ }
+ inline bool isFinishedWithErr(void) {
+ if (m_item)
+ return m_item->isFinishedWithErr();
+ else
+ return false;
+ }
+ inline bool isPreparingDownload(void) {
+ if (m_item)
+ return m_item->isPreparingDownload();
+ else
+ return false;
+ }
+ inline bool isCompletedDownload(void) {
+ if (m_item)
+ return m_item->isCompletedDownload();
+ else
+ return false;
+ }
unsigned long int receivedFileSize(void);
unsigned long int fileSize(void);
return;
}
+ if (s_url.empty()) {
+ view.activateWindow();
+ return;
+ }
DownloadRequest request(s_url, s_cookie);
Item::create(request);
#ifndef _SILENT_LAUNCH