summaryrefslogtreecommitdiff
path: root/provider/download-provider-notification.c
blob: 12a02a5fed0c7f240c55bb63904b3bd1c7d1be29 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
/*
 * Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved
 *
 * Licensed under the Apache License, Version 2.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.apache.org/licenses/LICENSE-2.0
 *
 * 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.
 */

#include <time.h>
#include <sys/time.h>
#include <stdlib.h>
#include <stdio.h>

#include "bundle.h"
#include "notification.h"
#include "appsvc.h"

#include "notification_text_domain.h"
#include "notification_internal.h"
#include "notification_error.h"

#include "download-provider-defs.h"

#include "download-provider-notification.h"
#include "download-provider-request.h"
#include "download-provider-db.h"
#include "download-provider-log.h"

#include <libintl.h>
#define S_(s) dgettext("sys_string", s)
#define __(s) dgettext(PKG_NAME, s)

#define DP_NOTIFICATION_ICON_PATH IMAGE_DIR"/Q02_Notification_download_complete.png"
#define DP_NOTIFICATION_ONGOING_ICON_PATH IMAGE_DIR"/Notification_download_animation.gif"
#define DP_NOTIFICATION_DOWNLOADING_ICON_PATH "reserved://indicator/ani/downloading"
#define DP_NOTIFICATION_FAILED_ICON_PATH IMAGE_DIR"/Q02_Notification_download_failed.png"

static const char *__noti_error_str(
		notification_error_e err)
{
	switch (err) {
	case NOTIFICATION_ERROR_INVALID_DATA:
		return "NOTIFICATION_ERROR_INVALID_DATA";
	case NOTIFICATION_ERROR_NO_MEMORY:
		return "NOTIFICATION_ERROR_NO_MEMORY";
	case NOTIFICATION_ERROR_FROM_DB:
		return "NOTIFICATION_ERROR_FROM_DB";
	case NOTIFICATION_ERROR_ALREADY_EXIST_ID:
		return "NOTIFICATION_ERROR_ALREADY_EXIST_ID";
	case NOTIFICATION_ERROR_FROM_DBUS:
		return "NOTIFICATION_ERROR_FROM_DBUS";
	case NOTIFICATION_ERROR_NOT_EXIST_ID:
		return "NOTIFICATION_ERROR_NOT_EXIST_ID";
	default:
		break;
	}
	return "Unknown error";
}

static char *__get_string_sender(char *url)
{
	char *temp = NULL;
	char *found = NULL;
	char *found1 = NULL;
	char *sender = NULL;
	char *credential_sender = NULL;

	if (url == NULL)
		return NULL;

	found = strstr(url, "://");
	if (found) {
		temp = found + 3;
	} else {
		temp = url;
	}
	found = strchr(temp, '/');
	if (found) {
		int len = 0;
		len = found - temp;
		sender = calloc(len + 1, sizeof(char));
		if (sender == NULL)
			return NULL;
		snprintf(sender, len + 1, "%s", temp);
	} else {
		sender = dp_strdup(temp);
	}

	// For credential URL
	found = strchr(sender, '@');
	found1 = strchr(sender, ':');
	if (found && found1 && found1 < found) {
		int len = 0;
		found = found + 1;
		len = strlen(found);
		credential_sender = calloc(len + 1, sizeof(char));
		if (credential_sender == NULL) {
			free(sender);
			return NULL;
		}
		snprintf(credential_sender, len + 1, "%s", found);
		free(sender);
		return credential_sender;
	} else {
		return sender;
	}
}

static char *__get_string_size(long long file_size)
{
	const char *unitStr[4] = {"B", "KB", "MB", "GB"};
	double doubleTypeBytes = 0.0;
	int unit = 0;
	long long bytes = file_size;
	long long unitBytes = bytes;
	char *temp = NULL;

	/* using bit operation to avoid floating point arithmetic */
	for (unit = 0; (unitBytes > 1024 && unit < 4); unit++) {
		unitBytes = unitBytes >> 10;
	}
	unitBytes = 1 << (10 * unit);

	if (unit > 3)
		unit = 3;

	char str[64] = {0};
	if (unit == 0) {
		snprintf(str, sizeof(str), "%lld %s", bytes, unitStr[unit]);
	} else {
		doubleTypeBytes = ((double)bytes / (double)unitBytes);
		snprintf(str, sizeof(str), "%.2f %s", doubleTypeBytes, unitStr[unit]);
	}

	str[63] = '\0';
	temp = dp_strdup(str);
	return temp;
}

static char *__get_string_status(dp_state_type state)
{
	char *message = NULL;
	switch (state) {
	case DP_STATE_COMPLETED:
		message = __("IDS_DM_HEADER_DOWNLOAD_COMPLETE");
		break;
	case DP_STATE_CANCELED:
	case DP_STATE_FAILED:
		message = S_("IDS_COM_POP_DOWNLOAD_FAILED");
		break;
	default:
		break;
	}
	return message;
}

int dp_set_downloadinginfo_notification(int id, char *packagename)
{
	notification_h noti_handle = NULL;
	notification_error_e err = NOTIFICATION_ERROR_NONE;
	int privId = 0;
	bundle *b = NULL;
	void *blob_data = NULL;
	bundle_raw* b_raw = NULL;
	int length;

	noti_handle = notification_create(NOTIFICATION_TYPE_ONGOING);
	if (!noti_handle) {
		TRACE_ERROR("[FAIL] create notification handle");
		return -1;
	}

	char *title = dp_db_get_text_column(id,
		DP_DB_TABLE_NOTIFICATION, DP_DB_COL_TITLE);
	if(title != NULL) {
		err = notification_set_text(noti_handle, NOTIFICATION_TEXT_TYPE_TITLE,
			title, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
		free(title);
		if (err != NOTIFICATION_ERROR_NONE) {
			TRACE_ERROR("[FAIL] set title [%s]", __noti_error_str(err));
			notification_free(noti_handle);
			return -1;
		}
	} else {
		char *content_name =
			dp_db_get_text_column
				(id, DP_DB_TABLE_DOWNLOAD_INFO, DP_DB_COL_CONTENT_NAME);

		if (content_name == NULL)
			content_name = strdup("No Name");

		err = notification_set_text(noti_handle,
				NOTIFICATION_TEXT_TYPE_TITLE, content_name, NULL,
				NOTIFICATION_VARIABLE_TYPE_NONE);
		if (content_name)
			free(content_name);
	}

	if (err != NOTIFICATION_ERROR_NONE) {
		TRACE_ERROR("[FAIL] set title [%s]", __noti_error_str(err));
		notification_free(noti_handle);
		return -1;
	}

	err = notification_set_image(noti_handle,
			NOTIFICATION_IMAGE_TYPE_ICON, DP_NOTIFICATION_ONGOING_ICON_PATH);
	if (err != NOTIFICATION_ERROR_NONE) {
		TRACE_ERROR("[FAIL] set icon [%s]", __noti_error_str(err));
		notification_free(noti_handle);
		return -1;
	}

	blob_data = dp_db_get_blob_column
				(id, DP_DB_TABLE_NOTIFICATION, DP_DB_COL_RAW_BUNDLE_ONGOING, &length);
	if (blob_data != NULL) {
		b_raw = (bundle_raw*)blob_data;
		if (b_raw != NULL) {
			b = bundle_decode_raw(b_raw, length);
			if (b != NULL) {
				err = notification_set_execute_option(noti_handle,
					NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, "View", NULL, b);

				if (err != NOTIFICATION_ERROR_NONE) {
					TRACE_ERROR("[FAIL] set execute option [%s]", __noti_error_str(err));
					bundle_free_encoded_rawdata(&b_raw);
					bundle_free(b);
					notification_free(noti_handle);
					return -1;
				}
				bundle_free_encoded_rawdata(&b_raw);
				bundle_free(b);
			}
		}
	} else {
		b = bundle_create();
		if (!b) {
			TRACE_ERROR("[FAIL] create bundle");
			notification_free(noti_handle);
			return -1;
		}

		if (packagename &&
			appsvc_set_pkgname(b, packagename) != APPSVC_RET_OK) {
			TRACE_ERROR("[FAIL] set pkg name");
			bundle_free(b);
			notification_free(noti_handle);
			return -1;
		}
		err = notification_set_execute_option(noti_handle,
			NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, "View", NULL, b);

		if (err != NOTIFICATION_ERROR_NONE) {
			TRACE_ERROR("[FAIL] set execute option [%s]", __noti_error_str(err));
			bundle_free(b);
			notification_free(noti_handle);
			return -1;
		}
		bundle_free(b);
	}
	err = notification_set_property(noti_handle,
			NOTIFICATION_PROP_DISABLE_TICKERNOTI);
	if (err != NOTIFICATION_ERROR_NONE) {
		TRACE_ERROR("[FAIL] set property [%s]", __noti_error_str(err));
		notification_free(noti_handle);
		return -1;
	}

	err = notification_set_image(noti_handle,
		NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, DP_NOTIFICATION_DOWNLOADING_ICON_PATH);
	if (err != NOTIFICATION_ERROR_NONE) {
		TRACE_ERROR("[FAIL] set icon indicator [%s]", __noti_error_str(err));
		notification_free(noti_handle);
		return -1;
	}

	err = notification_set_display_applist(noti_handle, NOTIFICATION_DISPLAY_APP_ALL);
	if (err != NOTIFICATION_ERROR_NONE) {
		TRACE_ERROR("[FAIL] set disable icon [%s]", __noti_error_str(err));
		notification_free(noti_handle);
		return -1;
	}

	err = notification_insert(noti_handle, &privId);
	if (err != NOTIFICATION_ERROR_NONE) {
		TRACE_ERROR("[FAIL] set insert [%s]", __noti_error_str(err));
		notification_free(noti_handle);
		return -1;
	}

	TRACE_DEBUG("m_noti_id [%d]", privId);
	notification_free(noti_handle);
	return privId;
}

int dp_set_downloadedinfo_notification(int priv_id, int id, char *packagename, dp_state_type state)
{
	notification_h noti_handle = NULL;
	notification_error_e err = NOTIFICATION_ERROR_NONE;
	int privId = 0;
	bundle *b = NULL;
	void *blob_data = NULL;
	bundle_raw* b_raw = NULL;
	int length = 0;

	if (priv_id >= 0) {
		err = notification_delete_by_priv_id(NULL, NOTIFICATION_TYPE_ONGOING,
				priv_id);
		if (err != NOTIFICATION_ERROR_NONE) {
			TRACE_ERROR("[FAIL] delete notification handle [%s]",
					__noti_error_str(err));
		}
	}

	noti_handle = notification_create(NOTIFICATION_TYPE_NOTI);

	if (!noti_handle) {
		TRACE_ERROR("[FAIL] create notification handle");
		return -1;
	}

	if (err != NOTIFICATION_ERROR_NONE) {
		TRACE_ERROR("[FAIL] set title [%s]", __noti_error_str(err));
		notification_free(noti_handle);
		return -1;
	}

	err = notification_set_text(noti_handle, NOTIFICATION_TEXT_TYPE_TITLE,
			__get_string_status(state), NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
	if (err != NOTIFICATION_ERROR_NONE) {
		TRACE_ERROR("[FAIL] set title [%s]", __noti_error_str(err));
		notification_free(noti_handle);
		return -1;
	}

	char *description =
		dp_db_get_text_column
			(id, DP_DB_TABLE_NOTIFICATION, DP_DB_COL_DESCRIPTION);
	if(description != NULL) {
		err = notification_set_text(noti_handle,
				NOTIFICATION_TEXT_TYPE_INFO_2, description,
				NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
		free(description);
		if (err != NOTIFICATION_ERROR_NONE) {
			TRACE_ERROR("[FAIL] set description [%s]", __noti_error_str(err));
			notification_free(noti_handle);
			return -1;
		}
	} else {
		char *url = NULL;
		url = dp_db_get_text_column
					(id, DP_DB_TABLE_REQUEST_INFO, DP_DB_COL_URL);
		if (url) {
			char *sender_str = __get_string_sender(url);
			err = notification_set_text(noti_handle, NOTIFICATION_TEXT_TYPE_INFO_2,
					sender_str, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
			if (err != NOTIFICATION_ERROR_NONE) {
				TRACE_ERROR("[FAIL] set title [%s]", __noti_error_str(err));
				free(sender_str);
				free(url);
				notification_free(noti_handle);
				return -1;
			}
			free(sender_str);
			free(url);
		}
	}

	char *title = dp_db_get_text_column(id,
		DP_DB_TABLE_NOTIFICATION, DP_DB_COL_TITLE);
	if(title != NULL) {
		err = notification_set_text(noti_handle, NOTIFICATION_TEXT_TYPE_CONTENT,
			title, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
		free(title);
		if (err != NOTIFICATION_ERROR_NONE) {
			TRACE_ERROR("[FAIL] set title [%s]", __noti_error_str(err));
			notification_free(noti_handle);
			return -1;
		}
	} else {
		char *content_name =
				dp_db_get_text_column
					(id, DP_DB_TABLE_DOWNLOAD_INFO, DP_DB_COL_CONTENT_NAME);
		if (content_name == NULL)
			content_name = strdup("No Name");

		err = notification_set_text(noti_handle,
				NOTIFICATION_TEXT_TYPE_CONTENT, content_name,
				NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
		free(content_name);
	}

	time_t tt = time(NULL);
	err = notification_set_time_to_text(noti_handle,
			NOTIFICATION_TEXT_TYPE_INFO_SUB_1, tt);
	if (err != NOTIFICATION_ERROR_NONE) {
		TRACE_ERROR("[FAIL] set time [%s]", __noti_error_str(err));
		notification_free(noti_handle);
		return -1;
	}
	if (state == DP_STATE_COMPLETED) {
		blob_data = dp_db_get_blob_column
					(id, DP_DB_TABLE_NOTIFICATION, DP_DB_COL_RAW_BUNDLE_COMPLETE, &length);
		if (blob_data != NULL) {
			b_raw = (bundle_raw*)blob_data;
			if (b_raw != NULL) {
				b = bundle_decode_raw(b_raw, length);
				if (b != NULL) {
					err = notification_set_execute_option(noti_handle,
						NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, "View", NULL, b);

					if (err != NOTIFICATION_ERROR_NONE) {
						TRACE_ERROR("[FAIL] set execute option [%s]", __noti_error_str(err));
						bundle_free_encoded_rawdata(&b_raw);
						bundle_free(b);
						notification_free(noti_handle);
						return -1;
					}
					bundle_free_encoded_rawdata(&b_raw);
				}
			}
		} else {
			char *file_path = NULL;
			b = bundle_create();
			if (!b) {
				TRACE_ERROR("[FAIL] create bundle");
				notification_free(noti_handle);
				return -1;
			}
			if (appsvc_set_operation(b, APPSVC_OPERATION_VIEW) != APPSVC_RET_OK) {
				TRACE_ERROR("[FAIL] appsvc set operation");
				bundle_free(b);
				notification_free(noti_handle);
				return -1;
			}
			file_path = dp_db_get_text_column
					(id, DP_DB_TABLE_DOWNLOAD_INFO, DP_DB_COL_SAVED_PATH);
			if (file_path == NULL) {
				TRACE_ERROR("[FAIL] get file path");
				bundle_free(b);
				notification_free(noti_handle);
				return -1;

			}
			if (appsvc_set_uri(b, file_path) != APPSVC_RET_OK) {
				TRACE_ERROR("[FAIL] appsvc set uri");
				bundle_free(b);
				notification_free(noti_handle);
				free(file_path);
				return -1;
			}
			free(file_path);
			err = notification_set_execute_option(noti_handle,
				NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, "View", NULL, b);
			if (err != NOTIFICATION_ERROR_NONE) {
				TRACE_ERROR("[FAIL] set execute option[%s]", __noti_error_str(err));
				bundle_free(b);
				notification_free(noti_handle);
				return -1;
			}
		}
		long long file_size = dp_db_get_int64_column(id,
				DP_DB_TABLE_DOWNLOAD_INFO, DP_DB_COL_CONTENT_SIZE);
		char *size_str = __get_string_size(file_size);

		err = notification_set_text(noti_handle,	NOTIFICATION_TEXT_TYPE_INFO_1,
				size_str, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);

		if (err != NOTIFICATION_ERROR_NONE) {
			TRACE_ERROR("[FAIL] set title [%s]", __noti_error_str(err));
			free(size_str);
			bundle_free(b);
			notification_free(noti_handle);
			return -1;
		}
		free(size_str);

		err = notification_set_image(noti_handle, NOTIFICATION_IMAGE_TYPE_ICON,
				DP_NOTIFICATION_ICON_PATH);
		if (err != NOTIFICATION_ERROR_NONE) {
			TRACE_ERROR("[FAIL] set icon [%s]", __noti_error_str(err));
			notification_free(noti_handle);
			return -1;
		}
	} else if (state == DP_STATE_CANCELED || state == DP_STATE_FAILED) {
		blob_data = dp_db_get_blob_column
					(id, DP_DB_TABLE_NOTIFICATION, DP_DB_COL_RAW_BUNDLE_FAIL, &length);
		if (blob_data != NULL) {
			b_raw = (bundle_raw *)blob_data;
			if (b_raw != NULL) {
				b = bundle_decode_raw(b_raw, length);
				if (b != NULL) {
					err = notification_set_execute_option(noti_handle,
						NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, "View", NULL, b);

					if (err != NOTIFICATION_ERROR_NONE) {
						TRACE_ERROR("[FAIL] set execute option [%s]", __noti_error_str(err));
						bundle_free_encoded_rawdata(&b_raw);
						bundle_free(b);
						notification_free(noti_handle);
						return -1;
					}
					bundle_free_encoded_rawdata(&b_raw);
				}
			}
		} else {
			b = bundle_create();
			if (!b) {
				TRACE_ERROR("[FAIL] create bundle");
				notification_free(noti_handle);
				return -1;
			}
			if (packagename &&
				appsvc_set_pkgname(b, packagename) !=
				APPSVC_RET_OK) {
				TRACE_ERROR("[FAIL] set pkg name");
				bundle_free(b);
				notification_free(noti_handle);
				return -1;
			}
			err = notification_set_execute_option(noti_handle,
					NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, "View", NULL, b);
			if (err != NOTIFICATION_ERROR_NONE) {
				TRACE_ERROR("[FAIL] set execute option[%s]", __noti_error_str(err));
				bundle_free(b);
				notification_free(noti_handle);
				return -1;
			}
		}
		err = notification_set_image(noti_handle, NOTIFICATION_IMAGE_TYPE_ICON,
				DP_NOTIFICATION_FAILED_ICON_PATH);
		if (err != NOTIFICATION_ERROR_NONE) {
			TRACE_ERROR("[FAIL] set icon [%s]", __noti_error_str(err));
			bundle_free(b);
			notification_free(noti_handle);
			return -1;
		}
	} else {
		TRACE_ERROR("[CRITICAL] invalid state");
		bundle_free(b);
		notification_free(noti_handle);
		return -1;
	}

	if (err != NOTIFICATION_ERROR_NONE) {
		TRACE_ERROR("[FAIL] set time [%s]", __noti_error_str(err));
		notification_free(noti_handle);
		bundle_free(b);
		return -1;
	}

	bundle_free(b);

	err = notification_set_property(noti_handle,
			NOTIFICATION_PROP_DISABLE_TICKERNOTI);
	if (err != NOTIFICATION_ERROR_NONE) {
		TRACE_ERROR("[FAIL] set property [%s]", __noti_error_str(err));
		notification_free(noti_handle);
		return -1;
	}

	err = notification_set_display_applist(noti_handle,
			NOTIFICATION_DISPLAY_APP_ALL ^ NOTIFICATION_DISPLAY_APP_INDICATOR);
	if (err != NOTIFICATION_ERROR_NONE) {
		TRACE_ERROR("[FAIL] set disable icon [%s]", __noti_error_str(err));
		notification_free(noti_handle);
		return -1;
	}

	err = notification_insert(noti_handle, &privId);
	if (err != NOTIFICATION_ERROR_NONE) {
		TRACE_ERROR("[FAIL] set insert [%s]", __noti_error_str(err));
		notification_free(noti_handle);
		return -1;
	}

	TRACE_DEBUG("m_noti_id [%d]", privId);
	notification_free(noti_handle);
	return privId;
}

void dp_update_downloadinginfo_notification(int priv_id, double received_size, double file_size)
{
	notification_error_e err = NOTIFICATION_ERROR_NONE;
	if (priv_id < 0) {
		TRACE_ERROR("[FAIL] Invalid priv_id[%d]", priv_id);
		return;
	}

	if (file_size > 0) {
		double progress;
		progress = received_size / file_size;
		err = notification_update_progress(NULL, priv_id, progress);
		if (err != NOTIFICATION_ERROR_NONE)
			TRACE_ERROR("[FAIL] update noti progress[%s]",
					__noti_error_str(err));
	} else {
		err = notification_update_size(NULL, priv_id, received_size);
		if (err != NOTIFICATION_ERROR_NONE)
			TRACE_ERROR("[FAIL]  update noti progress[%s]",
					__noti_error_str(err));
	}
}

void dp_clear_downloadinginfo_notification()
{
	notification_error_e err = NOTIFICATION_ERROR_NONE;
	err = notification_delete_all_by_type(NULL, NOTIFICATION_TYPE_ONGOING);
	if (err != NOTIFICATION_ERROR_NONE) {
		TRACE_ERROR("[FAIL] clear noti [%s]", __noti_error_str(err));
	}
	return;
}