Changing download provider notification as in Dowload Manager's notification. 99/208099/3
authorRaveendra Karu <r.karu@samsung.com>
Wed, 10 May 2017 05:08:38 +0000 (10:38 +0530)
committerseonah moon <seonah1.moon@samsung.com>
Tue, 18 Jun 2019 08:15:28 +0000 (08:15 +0000)
Download provider notification does not display URL information.
Added changes to show URL information in notification.
Also added changes to handle EBUSY case while releasing the acquired lock
on mutex.

Change-Id: I27bfff0495fb7da65fc0fb5deb7bd63b79d7a1a5
Signed-off-by: Sowmya B <sowmya.b1@samsung.com>
provider/download-provider-notification-manager.c
provider/download-provider-notification.c
provider/download-provider-queue-manager.c
provider/include/download-provider-notification.h

index 7e2b0ef..1d6510f 100644 (file)
@@ -448,9 +448,20 @@ static void __dp_notification_manager_check_notification()
                                                        TRACE_DEBUG("failed to get bundle raws id:%d error:%s", download_id, dp_print_errorcode(errorcode));
                                                CLIENT_MUTEX_UNLOCK(&slot->mutex);
                                        }
-                                       noti_priv_id = dp_notification_ongoing_new(slot->pkgname, subject, raws_buffer, length);
+
+                                       char *url = NULL;
+                                       unsigned int len = 0;
+                                       if (CLIENT_MUTEX_CHECKLOCK(&slot->mutex) == 0) {
+                                               if (dp_db_get_property_string(slot->client.dbhandle, download_id, DP_TABLE_REQUEST, DP_DB_COL_URL, (unsigned char **)&url, &len, &errorcode) < 0) {
+                                                       TRACE_ERROR("failed to get url id:%d error:%s", download_id, dp_print_errorcode(errorcode));
+                                               }
+                                               CLIENT_MUTEX_UNLOCK(&slot->mutex);
+                                       }
+
+                                       noti_priv_id = dp_notification_ongoing_new(url, slot->pkgname, subject, raws_buffer, length);
                                        TRACE_DEBUG("new ongoing(%d) id:%d type:%d state:%d", noti_priv_id, download_id, noti_type, state);
                                        free(raws_buffer);
+                                       free(url);
                                        if (noti_priv_id < 0) {
                                                TRACE_ERROR("failed to update ongoing for id:%d", download_id);
                                        } else {
index e0ee036..5120020 100755 (executable)
@@ -48,7 +48,7 @@
 
 #define DP_DOMAIN PKG_NAME
 #define DP_LOCALEDIR LOCALE_DIR
-#define DP_NOTIFICATION_NO_SUBJECT "No Name"
+#define DP_NOTIFICATION_NO_SUBJECT "Preparing to download..."
 
 #ifdef _TIZEN_2_3_UX
 #define DP_NOTIFICATION_DRM_ICON_PATH IMAGE_DIR"/download_manager_icon_drm.png"
@@ -260,7 +260,7 @@ void dp_notification_clear_ongoings()
        return;
 }
 
-int dp_notification_ongoing_new(const char *pkgname, const char *subject, unsigned char *raws_buffer, const int raws_length)
+int dp_notification_ongoing_new(const char *url, const char *pkgname, const char *subject, unsigned char *raws_buffer, const int raws_length)
 {
        int err = NOTIFICATION_ERROR_NONE;
        notification_h noti_handle = NULL;
@@ -282,6 +282,16 @@ int dp_notification_ongoing_new(const char *pkgname, const char *subject, unsign
        if (err != NOTIFICATION_ERROR_NONE)
                TRACE_ERROR("failed to set subject error:%s", __dp_noti_error_str(err));
 
+       if (url != NULL) {
+               err = notification_set_text(noti_handle, NOTIFICATION_TEXT_TYPE_CONTENT, url, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
+               if (err != NOTIFICATION_ERROR_NONE)
+               {
+                       TRACE_ERROR("failed to set url error:%s", __dp_noti_error_str(err));
+               }
+       }
+
+
+
        err = notification_set_image(noti_handle,
                        NOTIFICATION_IMAGE_TYPE_ICON,
                        DP_NOTIFICATION_ONGOING_ICON_PATH);
index ad927eb..038ff52 100644 (file)
@@ -289,7 +289,7 @@ void dp_queue_manager_wake_up()
        if (g_dp_queue_manager_tid > 0 &&
                        pthread_kill(g_dp_queue_manager_tid, 0) != ESRCH) {
                int locked = CLIENT_MUTEX_TRYLOCK(&g_dp_queue_manager_mutex);
-               if (locked == 0) {
+               if (locked == 0 || locked == EBUSY) {
                        pthread_cond_signal(&g_dp_queue_manager_cond);
                        CLIENT_MUTEX_UNLOCK(&g_dp_queue_manager_mutex);
                }
index eb3f56e..d2f8be7 100755 (executable)
@@ -23,7 +23,7 @@ void dp_notification_clear_locale(void);
 void dp_notification_clear_ongoings(void);
 int dp_notification_delete_ongoing(const int noti_priv_id);
 int dp_notification_delete(const int noti_priv_id);
-int dp_notification_ongoing_new(const char *pkgname, const char *subject, unsigned char *raws_buffer, const int raws_length);
+int dp_notification_ongoing_new(const char *url, const char *pkgname, const char *subject, unsigned char *raws_buffer, const int raws_length);
 int dp_notification_ongoing_update(const int noti_priv_id, const double received_size, const double file_size, const char *subject);
 int dp_notification_new(void *dbhandle, const int download_id, const int state, int content_type, const char *pkgname);
 #else