summaryrefslogtreecommitdiff
path: root/src/include/download-provider-downloadItem.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/include/download-provider-downloadItem.h')
-rw-r--r--src/include/download-provider-downloadItem.h140
1 files changed, 140 insertions, 0 deletions
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 &registeredFilePath(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 */