diff options
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/download-provider-common.h | 103 | ||||
-rw-r--r-- | src/include/download-provider-dateTime.h | 111 | ||||
-rw-r--r-- | src/include/download-provider-debug.h | 76 | ||||
-rw-r--r-- | src/include/download-provider-downloadItem.h | 140 | ||||
-rw-r--r-- | src/include/download-provider-downloadRequest.h | 49 | ||||
-rw-r--r-- | src/include/download-provider-event.h | 72 | ||||
-rw-r--r-- | src/include/download-provider-history-db.h | 56 | ||||
-rw-r--r-- | src/include/download-provider-item.h | 204 | ||||
-rw-r--r-- | src/include/download-provider-items.h | 45 | ||||
-rw-r--r-- | src/include/download-provider-network.h | 57 | ||||
-rw-r--r-- | src/include/download-provider-util.h | 57 | ||||
-rw-r--r-- | src/include/download-provider-view.h | 160 | ||||
-rw-r--r-- | src/include/download-provider-viewItem.h | 136 |
13 files changed, 1266 insertions, 0 deletions
diff --git a/src/include/download-provider-common.h b/src/include/download-provider-common.h new file mode 100644 index 0000000..4131c0d --- /dev/null +++ b/src/include/download-provider-common.h @@ -0,0 +1,103 @@ +/* + * Copyright 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.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.tizenopensource.org/license + * + * 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. + */ + +/** + * @file download-provider-common.h + * @author Jungki Kwak (jungki.kwak@samsung.com) + * @brief Common define and data + */ + +#ifndef DOWNLOAD_PROVIDER_DOWNLOAD_COMMON_H +#define DOWNLOAD_PROVIDER_DOWNLOAD_COMMON_H + +#include <libintl.h> +#include "download-provider-debug.h" + +#if !defined(PACKAGE) + #define PACKAGE "download-provider" +#endif + +#define _EDJ(o) elm_layout_edje_get(o) +#define __(s) dgettext(PACKAGE, s) +#define S_(s) dgettext("sys_string", s) + +#define ERROR_POPUP_LOW_MEM S_("IDS_COM_POP_NOT_ENOUGH_MEMORY") +#define ERROR_POPUP_UNKNOWN S_("IDS_COM_POP_INTERNAL_ERROR") +#define ERROR_POPUP_INVALID_URL S_("IDS_COM_POP_INVALID_URL") + +#define DP_DRM_ICON_PATH IMAGEDIR"/U06_icon_DRM.png" +#define DP_JAVA_ICON_PATH IMAGEDIR"/U06_icon_Java.png" +#define DP_UNKNOWN_ICON_PATH IMAGEDIR"/U06_icon_Unknown.png" +#define DP_EXCEL_ICON_PATH IMAGEDIR"/U06_icon_excel.png" +#define DP_HTML_ICON_PATH IMAGEDIR"/U06_icon_html.png" +#define DP_MUSIC_ICON_PATH IMAGEDIR"/U06_icon_music.png" +#define DP_PDF_ICON_PATH IMAGEDIR"/U06_icon_pdf.png" +#define DP_PPT_ICON_PATH IMAGEDIR"/U06_icon_ppt.png" +#define DP_RINGTONE_ICON_PATH IMAGEDIR"/U06_icon_ringtone.png" +#define DP_TEXT_ICON_PATH IMAGEDIR"/U06_icon_text.png" +#define DP_WORD_ICON_PATH IMAGEDIR"/U06_icon_word.png" +#define DP_VIDEO_ICON_PATH IMAGEDIR"/U06_icon_video.png" +#define DP_IMAGE_ICON_PATH IMAGEDIR"/U06_icon_image.png" + +#define MAX_FILE_PATH_LEN 256 +#define MAX_BUF_LEN 256 + +#define LOAD_HISTORY_COUNT 500 + +enum +{ + DP_CONTENT_NONE = 0, + DP_CONTENT_IMAGE, + DP_CONTENT_VIDEO, + DP_CONTENT_MUSIC, + DP_CONTENT_PDF, + DP_CONTENT_WORD, + DP_CONTENT_PPT, // 5 + DP_CONTENT_EXCEL, + DP_CONTENT_HTML, + DP_CONTENT_TEXT, + DP_CONTENT_RINGTONE, + DP_CONTENT_DRM, // 10 + DP_CONTENT_JAVA, + DP_CONTENT_SVG, + DP_CONTENT_FLASH, + DP_CONTENT_UNKOWN +}; + +namespace DL_TYPE{ +enum TYPE { + TYPE_NONE, + HTTP_DOWNLOAD, + OMA_DOWNLOAD, + MIDP_DOWNLOAD +}; +} + +namespace ERROR { +enum CODE { + NONE, + INVALID_URL, + NETWORK_FAIL, + NOT_ENOUGH_MEMORY, + FAIL_TO_INSTALL, + FAIL_TO_PARSE_DESCRIPTOR, + OMA_POPUP_TIME_OUT, + ENGINE_FAIL, + UNKNOWN +}; +} + +#endif /* DOWNLOAD_PROVIDER_DOWNLOAD_COMMON_H */ diff --git a/src/include/download-provider-dateTime.h b/src/include/download-provider-dateTime.h new file mode 100644 index 0000000..87caf11 --- /dev/null +++ b/src/include/download-provider-dateTime.h @@ -0,0 +1,111 @@ +/* + * Copyright 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.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.tizenopensource.org/license + * + * 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. + */ + +/** + * @file download-provider-dateTime.h + * @author Jungki Kwak (jungki.kwak@samsung.com) + * @brief data and utility APIs for Date and Time + */ + +#ifndef DOWNLOAD_PROVIDER_DATE_TIME_H +#define DOWNLOAD_PROVIDER_DATE_TIME_H + +#include <time.h> +#include <Elementary.h> +#include <unicode/udat.h> +#include <unicode/udatpg.h> +#include <unicode/ustring.h> + +#include "download-provider-common.h" + +using namespace std; + +namespace DATETIME { +enum { + DATE_TYPE_NONE = 0, + DATE_TYPE_LATER, + DATE_TYPE_TODAY, + DATE_TYPE_YESTERDAY, + DATE_TYPE_PREVIOUS, +}; +} + +namespace LOCALE_STYLE{ +enum { + TIME = 0, + SHORT_DATE, + MEDIUM_DATE, + FULL_DATE +}; +} + +class DateGroup { +public: + DateGroup(void); + ~DateGroup(void); + + Elm_Object_Item *glGroupItem() { return m_glGroupItem; } + void setGlGroupItem(Elm_Object_Item *i) { m_glGroupItem = i; } + void increaseCount(void) { count++; } + void decreaseCount(void) { count--; } + int getCount(void) { return count; } + void initData(void); + void setType(int t) { type = t; } + int getType(void) { return type; } + +private: + int count; + int type; + Elm_Object_Item *m_glGroupItem; +}; + +class DateUtil { +public: + static DateUtil& getInstance(void) { + static DateUtil inst; + return inst; + } + + inline void setTodayStandardTime(void) { m_todayStandardTime = time(NULL); } + int getDiffDaysFromToday(void); + int getDiffDays(time_t nowTime, time_t refTime); + void updateLocale(void); + void getDateStr(int style, double time, string &outBuf); + inline double nowTime(void) { return (double)(time(NULL)); } + /* yesterday is same to 24*60*60 seconds from now */ + inline double yesterdayTime(void) { return (double)(time(NULL)+24*60*60); } + +private: + DateUtil(void); + ~DateUtil(void); + + UDateFormat *getBestPattern(const char *patternStr, + UDateTimePatternGenerator *generator, const char *locale); + void deinitLocaleData(void); + /* Update this in case of follows + * 1. show main view. + * 2. add new item + * 3. create today group + **/ + time_t m_todayStandardTime; + UDateFormat *dateShortFormat; + UDateFormat *dateMediumFormat; + UDateFormat *dateFullFormat; + UDateFormat *timeFormat12H; + UDateFormat *timeFormat24H; +}; + +#endif /* DOWNLOAD_PROVIDER_DATE_TIME_H */ diff --git a/src/include/download-provider-debug.h b/src/include/download-provider-debug.h new file mode 100644 index 0000000..4c4552b --- /dev/null +++ b/src/include/download-provider-debug.h @@ -0,0 +1,76 @@ +/* + * Copyright 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.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.tizenopensource.org/license + * + * 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. + */ + +/** + * @file download-provider-debug.h + * @author Jungki Kwak (jungki.kwak@samsung.com) + * @brief debug function + */ + +#ifndef DOWNLOAD_PROVIDER_DEBUG_H +#define DOWNLOAD_PROVIDER_DEBUG_H + +#define _USE_DLOG 1 + +#ifdef _USE_DLOG +#include <dlog.h> + +#ifdef LOG_TAG +#undef LOG_TAG +#endif + +#define LOG_TAG "DownloadProvider" + +#define DP_LOG(format, args...) LOGI("[%s] "format, __func__, ##args) +#define DP_LOGD(format, args...) LOGD("[%s] "format, __func__, ##args) +#define DP_LOG_START(msg) LOGI("<<= [%s] Start =>>\n",msg) +#define DP_LOG_FUNC() LOGI("<<= [%s]=>>\n",__func__) +#define DP_LOGD_FUNC() LOGD("<<= [%s]=>>\n",__func__) +#define DP_LOG_END(msg) LOGI("<<= [%s] End [%d] =>>\n",msg) +#define DP_LOGE(format, args...) LOGE("[%s][ERR] "format, __func__, ##args) +#define DP_LOG_TEST(format, args...) LOGI("####TEST####[%s] "format, __func__, ##args) + +#else + +#include <stdio.h> +#include <pthread.h> + +#define DP_LOG(args...) do {\ + printf("[DP:%s][LN:%d][%lu]",__func__,__LINE__,pthread_self());\ + printf(args);printf("\n"); }while(0) +#define DP_LOGD(args...) do {\ + printf("[DP_D:%s][LN:%d][%lu]",__func__,__LINE__,pthread_self());\ + printf(args);printf("\n");}while(0) +#define DP_LOGE(args...) do {\ + printf("[DP_ERR:%s][LN:%d][%lu]",__func__,__LINE__,pthread_self());\ + printf(args);printf("\n");}while(0) +#define DP_LOG_FUNC() do {\ + printf("<<==[DP:%s][LN:%d][%lu] ==>> \n",__func__,__LINE__,pthread_self());\ + }while(0) +#define DP_LOGD_FUNC() do {\ + printf("<<==[DP_D:%s][LN:%d][%lu] ==>> \n",__func__,__LINE__,pthread_self());\ + }while(0) +#define DP_LOG_START(msg) do {\ + printf("<<==[DP:%s][LN:%d][%lu] Start ==>> \n",\ + __FUNCTION__,__LINE__,pthread_self());\ + }while(0) +#define DP_LOG_END(msg) do {\ + printf("<<==[DP:%s][LN:%d][%lu] End ==>> \n",\ + __FUNCTION__,__LINE__,pthread_self());\ + }while(0) +#endif /*_USE_DLOG*/ + +#endif /* DOWNLOAD_PROVIDER_DEBUG_H */ diff --git a/src/include/download-provider-downloadItem.h b/src/include/download-provider-downloadItem.h new file mode 100644 index 0000000..9421246 --- /dev/null +++ b/src/include/download-provider-downloadItem.h @@ -0,0 +1,140 @@ +/* + * Copyright 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.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.tizenopensource.org/license + * + * 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. + */ + +/** + * @file download-provider-downloadItem.h + * @author Jungki Kwak (jungki.kwak@samsung.com) + * @brief download item class + */ + +#ifndef DOWNLOAD_PROVIDER_DOWNLOAD_ITEM_H +#define DOWNLOAD_PROVIDER_DOWNLOAD_ITEM_H + +#include "download-provider-common.h" +#include "download-provider-downloadRequest.h" +#include "download-provider-event.h" +#include "download-agent-interface.h" +#include <memory> + +namespace DL_ITEM { +enum STATE { + IGNORE, + STARTED, + WAITING_CONFIRM, + UPDATING, + COMPLETE_DOWNLOAD, + INSTALL_NOTIFY, + START_DRM_DOMAIN, + FINISH_DRM_DOMAIN, + WAITING_RO, + SUSPENDED, + RESUMED, + FINISHED, + CANCELED, + FAILED +}; +} + +class DownloadItem { +public: + DownloadItem(); /* FIXME remove after cleanup ecore_pipe */ + DownloadItem(auto_ptr<DownloadRequest> request); + ~DownloadItem(); + + void start(void); + void cancel(void); + void retry(void); + bool sendUserResponse(bool res); + void suspend(void); + void resume(void); + + inline int downloadId(void) { return m_da_req_id;} + inline void setDownloadId(int id) { m_da_req_id = id; } + + inline unsigned long int receivedFileSize(void) { return m_receivedFileSize; } + inline void setReceivedFileSize(unsigned long int size) { m_receivedFileSize = size; } + + inline unsigned long int fileSize(void) { return m_fileSize; } + inline void setFileSize(unsigned long int size) { m_fileSize = size; } + + inline string &filePath(void) { return m_filePath; } + inline void setFilePath(const char *path) { if (path) m_filePath = path; } + inline void setFilePath(string &path) { m_filePath = path; } + + inline string ®isteredFilePath(void) { return m_registeredFilePath; } + inline void setRegisteredFilePath(string &path) { m_registeredFilePath = path; } + + inline string &mimeType(void) { return m_mimeType; } + inline void setMimeType(const char *mime) { m_mimeType = mime; } + inline void setMimeType(string &mime) { m_mimeType = mime; } + + inline DL_ITEM::STATE state(void) { return m_state; } + inline void setState(DL_ITEM::STATE state) { m_state = state; } + + inline ERROR::CODE errorCode(void) { return m_errorCode; } + inline void setErrorCode(ERROR::CODE err) { m_errorCode = err; } + inline bool isMidletInstalled(void) { return m_isMidletInstalled; } + inline void setIsMidletInstalled(bool b) { m_isMidletInstalled = b; } + inline DL_TYPE::TYPE downloadType(void) { return m_downloadType; } + inline void setDownloadType(DL_TYPE::TYPE t) { m_downloadType = t;} + inline string &contentName(void) { return m_contentName; } + inline void setContentName(string &name) { m_contentName = name; } + inline string &vendorName(void) { return m_vendorName; } + inline void setVendorName(string &name) { m_vendorName = name; } + + inline void notify(void) { m_subject.notify(); } + inline void subscribe(Observer *o) { if (o) m_subject.attach(o); } + inline void deSubscribe(Observer *o) { if (o) m_subject.detach(o); } + inline string &url(void) { return m_aptr_request->getUrl(); } + inline string &cookie(void) { return m_aptr_request->getCookie(); } + + DL_ITEM::STATE _convert_da_state_to_download_state(int da_state); + ERROR::CODE _convert_da_error(int da_err); + +private: + auto_ptr<DownloadRequest> m_aptr_request; + Subject m_subject; + da_handle_t m_da_req_id; + DL_ITEM::STATE m_state; + ERROR::CODE m_errorCode; + unsigned long int m_receivedFileSize; + unsigned long int m_fileSize; + string m_filePath; + string m_registeredFilePath; + string m_mimeType; + DL_TYPE::TYPE m_downloadType; + bool m_isMidletInstalled; /* For MIDP */ + string m_contentName; /* For OMA & MIDP */ + string m_vendorName; /* For MIDP */ +}; + +class DownloadEngine { +public: + static DownloadEngine &getInstance(void) { + static DownloadEngine downloadEngine; + return downloadEngine; + } + + void initEngine(void); + void deinitEngine(void); +private: + DownloadEngine(void); + ~DownloadEngine(void); + +}; + + +#endif /* DOWNLOAD_PROVIDER_DOWNLOAD_ITEM_H */ diff --git a/src/include/download-provider-downloadRequest.h b/src/include/download-provider-downloadRequest.h new file mode 100644 index 0000000..a21f7df --- /dev/null +++ b/src/include/download-provider-downloadRequest.h @@ -0,0 +1,49 @@ +/* + * Copyright 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.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.tizenopensource.org/license + * + * 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. + */ + +/** + * @file download-provider-downloadRequest.h + * @author Jungki Kwak (jungki.kwak@samsung.com) + * @brief Download Request class + */ + +#ifndef DOWNLOAD_PROVIDER_DOWNLOAD_REQUEST_H +#define DOWNLOAD_PROVIDER_DOWNLOAD_REQUEST_H + +#include <string> + +using namespace std; + +class DownloadRequest +{ +public: +// DownloadRequest(); + DownloadRequest(string url, string cookie); + DownloadRequest(DownloadRequest &rRequest); + ~DownloadRequest(); + + string &getUrl(); + string &getCookie(); + bool isUrlEmpty(); + bool isCookieEmpty(); + void setUrl(string url); + void setCookie(string cookie); +private: + string m_url; + string m_cookie; +}; + +#endif /* DOWNLOAD_PROVIDER_DOWNLOAD_REQUEST_H */ diff --git a/src/include/download-provider-event.h b/src/include/download-provider-event.h new file mode 100644 index 0000000..e9378a6 --- /dev/null +++ b/src/include/download-provider-event.h @@ -0,0 +1,72 @@ +/* + * Copyright 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.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.tizenopensource.org/license + * + * 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. + */ + +/** + * @file download-provider-event.h + * @author Jungki Kwak (jungki.kwak@samsung.com) + * @brief Download event class + */ +#ifndef DOWNLOAD_PROVIDER_EVENT_H +#define DOWNLOAD_PROVIDER_EVENT_H + +#include <vector> +/* For debug */ +#include <string> + +using namespace std; + +class Observer; +class Subject +{ +public: + Subject(){} + ~Subject(){} + + void attach(Observer *); + void detach(Observer *); + void notify(void); + +private: + vector<Observer*> _observers; +}; + +typedef void (*updateFunction)(void *data); + +class Observer +{ +public: + /* For debug */ + Observer(updateFunction uf, void *data, const char *name); + //Observer(updateFunction uf, void *data); + ~Observer(){} + + void update(Subject *s); + void set(updateFunction uf, void *data); + void clear(void); + void *getUserData(void) { return m_userData; } + /* For debug */ + string name(void) { return observerName; } + +private: + void call(void); + + updateFunction m_updateFunction; + void *m_userData; + /* For debug */ + string observerName; +}; + +#endif /* DOWNLOAD_PROVIDER_EVENT_H */ diff --git a/src/include/download-provider-history-db.h b/src/include/download-provider-history-db.h new file mode 100644 index 0000000..b22883e --- /dev/null +++ b/src/include/download-provider-history-db.h @@ -0,0 +1,56 @@ +/* + * Copyright 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.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.tizenopensource.org/license + * + * 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. + */ + +/** + * @file download-provider-history-db.h + * @author Jungki Kwak (jungki.kwak@samsung.com) + * @brief Manager for a download history DB + */ + +#ifndef DOWNLOAD_PROVIDER_HISTORY_DB_H +#define DOWNLOAD_PROVIDER_HISTORY_DB_H + +#include <string> +#include <queue> +#include <db-util.h> +#include "download-provider-item.h" +extern "C" { +#include <unicode/utypes.h> +} + +using namespace std; + +class DownloadHistoryDB +{ +public: + static bool addToHistoryDB(Item *item); + static bool createRemainedItemsFromHistoryDB(int limit, int offset); + static bool createItemsFromHistoryDB(void); + static bool deleteItem(unsigned int historyId); + static bool deleteMultipleItem(queue <unsigned int> &q); + static bool clearData(void); + static bool getCountOfHistory(int *count); +private: + DownloadHistoryDB(void); + ~DownloadHistoryDB(void); + static sqlite3* historyDb; + static bool open(void); + static bool isOpen(void) { return historyDb ? true : false; } + static void close(void); +}; + +#endif /* DOWNLOAD_PROVIDER_HISTORY_DB_H */ + diff --git a/src/include/download-provider-item.h b/src/include/download-provider-item.h new file mode 100644 index 0000000..65ab1eb --- /dev/null +++ b/src/include/download-provider-item.h @@ -0,0 +1,204 @@ +/* + * Copyright 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.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.tizenopensource.org/license + * + * 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. + */ + +/** + * @file download-provider-item.h + * @author Jungki Kwak (jungki.kwak@samsung.com) + * @brief Item class + */ +#ifndef DOWNLOAD_PROVIDER_ITEM_H +#define DOWNLOAD_PROVIDER_ITEM_H + +#include <string> +#include <memory> +#include "download-provider-event.h" +#include "download-provider-downloadRequest.h" +#include "download-provider-downloadItem.h" +#include "download-provider-util.h" + +using namespace std; + +namespace ITEM { +enum STATE { + IDLE, + REQUESTING, + PREPARE_TO_RETRY, + WAITING_USER_RESPONSE, + RECEIVING_DOWNLOAD_INFO, + DOWNLOADING, + REGISTERING_TO_SYSTEM, + PROCESSING_DOMAIN, + FINISH_PROCESSING_DOMAIN, + ACTIVATING, + NOTIFYING_TO_SERVER, + SUSPEND, + FINISH_DOWNLOAD, + FAIL_TO_DOWNLOAD, + CANCEL, + PLAY, + DESTROY +}; +} + +class DownloadNoti; + +class Item { +public: + static void create(DownloadRequest &rRequest); + static Item *createHistoryItem(void); + ~Item(void); + + void attachHistoryItem(void); + void destroy(void); + /* SHOULD call this before destrying an item*/ + void deleteFromDB(void); + void download(void); + inline void cancel(void) + { + if (m_aptr_downloadItem.get()) + m_aptr_downloadItem->cancel(); + return; + } + void clearForRetry(void); + bool retry(void); + + void sendUserResponse(bool res); + bool play(void); + + inline void subscribe(Observer *o) { m_subjectForView.attach(o); } + inline void deSubscribe(Observer *o) { m_subjectForView.detach(o); } + + static void updateCBForDownloadObserver(void *data); + static void netEventCBObserver(void *data); + void updateFromDownloadItem(void); + inline void suspend(void) { m_aptr_downloadItem->suspend(); } + + inline int id(void) { + if (m_aptr_downloadItem.get()) + return m_aptr_downloadItem->downloadId(); + + return -1; + } // FIXME create Item's own id + + inline unsigned long int receivedFileSize(void) { + if (m_aptr_downloadItem.get()) + return m_aptr_downloadItem->receivedFileSize(); + return 0; + } + + inline unsigned long int fileSize(void) { + if (m_aptr_downloadItem.get()) + return m_aptr_downloadItem->fileSize(); + return 0; + } + + inline string &filePath(void) { + if (m_aptr_downloadItem.get()) + return m_aptr_downloadItem->filePath(); + return m_emptyString; + } + + inline bool isMidletInstalled(void) { + if (m_aptr_downloadItem.get()) + return m_aptr_downloadItem->isMidletInstalled(); + return false; + } + + inline void setHistoryId(unsigned int i) { m_historyId = i; } + inline unsigned int historyId(void) { return m_historyId; } // FIXME duplicated with m_id + inline string &title(void) {return m_title;} + inline void setTitle(string &title) { m_title = title; } + string &contentName(void); + inline void setContentName(string &c) { m_contentName = c; } + string &vendorName(void); + inline void setVendorName(string &v) { m_vendorName = v; } + string ®isteredFilePath(void); + inline void setRegisteredFilePath(string &r) { m_registeredFilePath = r; } + string &url(void); + string &cookie(void); + void setRetryData(string &url, string &cookie); + int contentType(void) { return m_contentType; } + inline void setContentType(int t) { m_contentType = t; } + DL_TYPE::TYPE downloadType(void); + inline void setDownloadType(DL_TYPE::TYPE t) { m_downloadType = t; } + +// string &getIconPath(void) {return m_iconPath; } + inline string &iconPath(void) { return m_iconPath; } + + inline void setState(ITEM::STATE state) { m_state = state; } + inline ITEM::STATE state(void) { return m_state; } + + inline void setErrorCode(ERROR::CODE err) { m_errorCode = err; } + inline ERROR::CODE errorCode(void) { return m_errorCode; } + const char *getErrorMessage(void); + inline void setFinishedTime(double t) { m_finishedTime = t; } + inline double finishedTime(void) { return m_finishedTime; } + + inline string getMidletPkgName(void) { + DownloadUtil &util = DownloadUtil::getInstance(); + return util.getMidletPkgName(m_contentName, m_vendorName); + } + + bool isFinished(void); /* include finish download state with error */ + bool isFinishedWithErr(void); + bool isPreparingDownload(void); /* Before downloading start */ + bool isCompletedDownload(void); /* After stating installation */ + + /* Test code */ + const char *stateStr(void); + +private: + Item(void); + Item(DownloadRequest &rRequest); + + inline void notify(void) { m_subjectForView.notify(); } + + void createSubscribeData(void); + void extractTitle(void); + void extractIconPath(void); + + void startUpdate(void); + void createHistoryId(void); + bool isExistedHistoryId(unsigned int id); + void handleFinishedItem(void); + + auto_ptr<DownloadRequest> m_aptr_request; + auto_ptr<DownloadItem> m_aptr_downloadItem; + FileOpener m_fileOpener; + + Subject m_subjectForView; + auto_ptr<Observer> m_aptr_downloadObserver; + auto_ptr<Observer> m_aptr_netEventObserver; + + ITEM::STATE m_state; + ERROR::CODE m_errorCode; + string m_title; + unsigned int m_historyId; + int m_contentType; + string m_iconPath; // FIXME Later:is it right to exist here? (ViewItem or not) + string m_emptyString; // FIXME this is temporary to avoid crash when filePath() is called if m_aptr_downloaditem points nothing + double m_finishedTime; + DL_TYPE::TYPE m_downloadType; + string m_contentName; + string m_vendorName; + string m_registeredFilePath; + string m_url; + string m_cookie; + + bool m_gotFirstData; +}; + +#endif /* DOWNLOAD_PROVIDER_ITEM_H */ diff --git a/src/include/download-provider-items.h b/src/include/download-provider-items.h new file mode 100644 index 0000000..8395719 --- /dev/null +++ b/src/include/download-provider-items.h @@ -0,0 +1,45 @@ +/* + * Copyright 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.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.tizenopensource.org/license + * + * 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. + */ + +/* + * @file download-provider-items.h + * @author Jungki Kwak (jungki.kwak@samsung.com) + * @brief item inventory class + */ +#ifndef DOWNLOAD_PROVIDER_ITEMS_H +#define DOWNLOAD_PROVIDER_ITEMS_H + +#include "download-provider-item.h" +#include <vector> + +class Items { +public: + static Items& getInstance(void) { + static Items inst; + return inst; + } + + void attachItem(Item *item); + void detachItem(Item *item); + bool isExistedHistoryId(unsigned int id); +private: + Items(){} + ~Items(){DP_LOGD_FUNC();} + + vector<Item*> m_items; +}; + +#endif /* DOWNLOAD_PROVIDER_ITEMS_H */ diff --git a/src/include/download-provider-network.h b/src/include/download-provider-network.h new file mode 100644 index 0000000..2d0f5eb --- /dev/null +++ b/src/include/download-provider-network.h @@ -0,0 +1,57 @@ +/* + * Copyright 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.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.tizenopensource.org/license + * + * 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. + */ + +/** + * @file download-provider-network.h + * @author Jungki Kwak (jungki.kwak@samsung.com) + * @brief Download netowkr manager + */ + +#ifndef DOWNLOAD_PROVIDER_NETWORK_H +#define DOWNLOAD_PROVIDER_NETWORK_H + +#include "vconf.h" +#include "vconf-keys.h" +#include "download-provider-event.h" + +class NetMgr { +public: + static NetMgr& getInstance(void) { + static NetMgr inst; + return inst; + } + void initNetwork(void); + void deinitNetwork(void); + void netStatusChanged(void); + void netConfigChanged(void); + inline void subscribe(Observer *o) { m_subject.attach(o); } + inline void deSubscribe(Observer *o) { m_subject.detach(o); } + static void netStatusChangedCB(keynode_t *keynode, void *data); + static void netConfigChangedCB(keynode_t *keynode, void *data); +private: + NetMgr(void); + ~NetMgr(void); + int getConnectionState(void); + int getCellularStatus(void); + int getWifiStatus(void); + void getProxy(void); + void getIPAddress(void); + inline void notify() { m_subject.notify(); } + int m_netStatus; + Subject m_subject; +}; + +#endif diff --git a/src/include/download-provider-util.h b/src/include/download-provider-util.h new file mode 100644 index 0000000..0ed6575 --- /dev/null +++ b/src/include/download-provider-util.h @@ -0,0 +1,57 @@ +/*
+ * Copyright 2012 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.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.tizenopensource.org/license
+ *
+ * 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.
+ */
+
+/*
+ * @file download-provider-util.h
+ * @author Jungki Kwak (jungki.kwak@samsung.com)
+ * @brief Utility APIs and interface with content player
+ */
+
+#ifndef DOWNLOAD_PROVIDER_UTIL_H
+#define DOWNLOAD_PROVIDER_UTIL_H
+
+#include <string>
+#include "download-provider-common.h"
+
+using namespace std;
+class FileOpener {
+public:
+ FileOpener() {}
+ ~FileOpener() {}
+
+ bool openFile(string &path, int contentType);
+ bool openApp(string &pkgName);
+};
+
+class DownloadUtil
+{
+public:
+ static DownloadUtil& getInstance(void) {
+ static DownloadUtil inst;
+ return inst;
+ }
+
+ string getMidletPkgName(string& name, string& vendor);
+ int getContentType(const char *mimem, const char *filePath);
+
+private:
+ DownloadUtil(void);
+ ~DownloadUtil(void) {}
+ void initDrm(void);
+ bool isAmbiguousMIMEType(const char *mimeType);
+};
+
+#endif//DOWNLOAD_PROVIDER_UTIL_H
diff --git a/src/include/download-provider-view.h b/src/include/download-provider-view.h new file mode 100644 index 0000000..4fdfab0 --- /dev/null +++ b/src/include/download-provider-view.h @@ -0,0 +1,160 @@ +/* + * Copyright 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.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.tizenopensource.org/license + * + * 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. + */ + +/** + * @file download-provider-view.h + * @author Jungki Kwak (jungki.kwak@samsung.com) + * @brief Download UI View manager + */ + +#ifndef DOWNLOAD_PROVIDER_VIEW_H +#define DOWNLOAD_PROVIDER_VIEW_H + +#include <Elementary.h> +#include <libintl.h> + +#include <vector> +#include "download-provider-common.h" +#include "download-provider-viewItem.h" +#include "download-provider-dateTime.h" + +enum { + POPUP_EVENT_EXIT = 0, + POPUP_EVENT_ERR, +}; + +class DownloadView { +public: + static DownloadView& getInstance(void) { + static DownloadView inst; + return inst; + } + + Evas_Object *create(void); + void createView(void); + void activateWindow(void); + void show(void); + void hide(void); + + void attachViewItem(ViewItem *viewItem); + void detachViewItem(ViewItem *viewItem); + + void changedRegion(void); + void showErrPopup(string &desc); + void showOMAPopup(string &msg, ViewItem *viewItem); + void update(); + void update(ViewItem *viewItem); + void update(Elm_Object_Item *glItem); + void showViewItem(int id, const char *title); + void playContent(int id, const char *title); + void handleChangedAllCheckedState(void); + void handleCheckedState(void); + bool isGenlistEditMode(void); + void handleGenlistGroupItem(int type); + void moveRetryItem(ViewItem *viewItem); + static char *getGenlistGroupLabelCB(void *data, Evas_Object *obj, + const char *part); + +private: + static void showNotifyInfoCB(void *data, Evas *evas, Evas_Object *obj, void *event); + static void hideNotifyInfoCB(void *data, Evas *evas, Evas_Object *obj, void *event); + static void backBtnCB(void *data, Evas_Object *obj, void *event_info); + static void cbItemDeleteCB(void *data, Evas_Object *obj, void *event_info); + static void cbItemCancelCB(void *data, Evas_Object *obj, void *event_info); + static void selectAllClickedCB(void *data, Evas *evas, Evas_Object *obj, + void *event_info); + static void selectAllChangedCB(void *data, Evas_Object *obj, + void *event_info); + 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 void omaPopupResponseOKCB(void *data, Evas_Object *obj, void *event_info); + static void omaPopupResponseCancelCB(void *data, Evas_Object *obj, void *event_info); + +private: + DownloadView(); + ~DownloadView(); + + inline void destroyEvasObj(Evas_Object *e) { if(e) evas_object_del(e); e = NULL;} + void setTheme(void); + void setIndicator(Evas_Object *window); + Evas_Object *createWindow(const char *windowName); + Evas_Object *createBackground(Evas_Object *window); + Evas_Object *createLayout(Evas_Object *parent); + void createTheme(void); + void createNaviBar(void); + void createBackBtn(void); + void createControlBar(void); + void createBox(void); + void createList(void); + + void removeTheme(void); + + void addViewItemToGenlist(ViewItem *viewItem); + void createGenlistItem(ViewItem *viewItem); + void showEmptyView(void); + void hideEmptyView(void); + + void removePopup(void); + void showGenlistEditMode(void); + void hideGenlistEditMode(void); + void createSelectAllLayout(void); + void changeAllCheckedValue(void); + void destroyCheckedItem(void); + void showNotifyInfo(int type, int selectedCount); + void destroyNotifyInfo(void); + void createNotifyInfo(void); + + DateGroup *getDateGroupObj(int type); + Elm_Object_Item *getGenlistGroupItem(int type); + int getGenlistGroupCount(int type); + void setGenlistGroupItem(int type, Elm_Object_Item *item); + void increaseGenlistGroupCount(int type); + void handleUpdateDateGroupType(ViewItem *viewItem); + void cleanGenlistData(); + char *getGenlistGroupLabel(void *data, Evas_Object *obj, const char *part); + + Evas_Object *eoWindow; + Evas_Object *eoBackground; + Evas_Object *eoLayout; + Elm_Theme *eoTheme; + + Evas_Object *eoEmptyNoContent; + Evas_Object *eoNaviBar; + Elm_Object_Item *eoNaviBarItem; + Evas_Object *eoBackBtn; + Evas_Object *eoControlBar; + Elm_Object_Item *eoCbItemDelete; + Elm_Object_Item *eoCbItemCancel; + Elm_Object_Item *eoCbItemEmpty; + 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; + + int m_viewItemCount; + DateGroup m_today; + DateGroup m_yesterday; + DateGroup m_previousDay; +}; + +#endif /* DOWNLOAD_PROVIDER_VIEW_H */ diff --git a/src/include/download-provider-viewItem.h b/src/include/download-provider-viewItem.h new file mode 100644 index 0000000..70e8ec5 --- /dev/null +++ b/src/include/download-provider-viewItem.h @@ -0,0 +1,136 @@ +/* + * Copyright 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.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.tizenopensource.org/license + * + * 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. + */ + +/** + * @file download-provider-viewItem.h + * @author Jungki Kwak (jungki.kwak@samsung.com) + * @brief Item class for Download view + */ + +#ifndef DOWNLOAD_PROVIDER_VIEW_ITEM_H +#define DOWNLOAD_PROVIDER_VIEW_ITEM_H + +#include "download-provider-event.h" +#include "download-provider-item.h" +#include <Elementary.h> +#include <memory> + +using namespace std; + +class ViewItem { +public: + ~ViewItem(); + static void create(Item *item); + void destroy(void); + inline void deleteFromDB(void) { m_item->deleteFromDB(); } + + inline void setItem(Item *item) { m_item = item; } + static void updateCB(void *); + + + static char *getGenlistLabelCB(void *data, Evas_Object *obj, + const char *part); + char *getGenlistLabel(Evas_Object *obj, const char *part); + + static Evas_Object *getGenlistIconCB(void *data, Evas_Object *obj, + const char *part); + Evas_Object *getGenlistIcon(Evas_Object *obj, const char *part); + + static void checkChangedCB(void *data, Evas_Object *obj, void *event_info); + + const char *getMessage(void); + const char *getBytesStr(void); + const char *getHumanFriendlyBytesStr(unsigned long int bytes, + bool progressOption); + + Elm_Genlist_Item_Class *elmGenlistStyle(void); + + inline Elm_Genlist_Item_Class *elmGenlistItemClass(void) + { return &dldGenlistStyle; } + inline Elm_Genlist_Item_Class *elmGenlistHistoryItemClass(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(); } + + unsigned long int receivedFileSize(void); + unsigned long int fileSize(void); + const char *getTitle(void); + inline const char *getErrMsg(void) { return m_item->getErrorMessage(); } + const char *getIconPath(void) { return m_item->iconPath().c_str(); } + + inline Elm_Object_Item *genlistItem(void) { return m_glItem; } + inline void setGenlistItem(Elm_Object_Item *glItem) { m_glItem = glItem; } + inline void setProgressBar(Evas_Object *p) { m_progressBar = p; } + + void clickedDeleteButton(void); + void clickedCancelButton(void); + void clickedRetryButton(void); + void clickedGenlistItem(void); + void requestCancel(void); + inline void sendUserResponse(bool res) + { + return m_item->sendUserResponse(res); + } + inline Eina_Bool checkedValue(void) { return m_checked; } + void setCheckedValue(Eina_Bool b) { m_checked = b; } + inline Evas_Object *checkedBtn(void) { return m_checkedBtn; } + void setCheckedBtn(Evas_Object *e) { m_checkedBtn = e; } + + void updateCheckedBtn(void); + + inline int dateGroupType(void) { return m_dateGroupType; } + void setDateGroupType (int t) { m_dateGroupType = t; } + + inline double finishedTime(void) { return m_item->finishedTime();} + void extractDateGroupType(void); + + inline unsigned int historyId(void) { return m_item->historyId(); } +private: + ViewItem(Item *item); + + void updateFromItem(void); + Evas_Object *createProgressBar(Evas_Object *parent); + Evas_Object *createCancelBtn(Evas_Object *parent); + void retryViewItem(void); + + static void deleteBtnClickedCB(void *data, Evas_Object *obj, + void *event_info); + static void cancelBtnClickedCB(void *data, Evas_Object *obj, + void *event_info); + static void retryBtnClickedCB(void *data, Evas_Object *obj, + void *event_info); + + auto_ptr<Observer> m_aptr_observer; + Item *m_item; + + Elm_Genlist_Item_Class dldGenlistStyle; + Elm_Genlist_Item_Class dldHistoryGenlistStyle; + Elm_Genlist_Item_Class dldGenlistSlideStyle; + Elm_Object_Item *m_glItem; + Evas_Object *m_progressBar; + Evas_Object *m_checkedBtn; + Eina_Bool m_checked; + bool m_isRetryCase; + int m_dateGroupType; +}; + +#endif /* DOWNLOAD_PROVIDER_VIEW_ITEM_H */ |