summaryrefslogtreecommitdiff
path: root/src/badge.c
blob: 30bee900c9366182e0ad468c0f69e7a27af075a6 (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
/*
 *  libbadge
 *
 * Copyright (c) 2000 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
 *
 * Contact: Youngjoo Park <yjoo93.park@samsung.com>,
 *      Seungtaek Chung <seungtaek.chung@samsung.com>, Youngsub Ko <ys4610.ko@samsung.com>
 *
 * 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 <stdlib.h>
#include <stdarg.h>
#include <unistd.h>

#include <dlog.h>
#include <package_manager.h>

#include "badge.h"
#include "badge_log.h"
#include "badge_error.h"
#include "badge_internal.h"
#include "badge_ipc.h"

EXPORT_API
int badge_create(const char *pkgname, const char *writable_pkg)
{
	return badge_create_for_uid(pkgname, writable_pkg, getuid());
}

EXPORT_API
int badge_new(const char *writable_app_id)
{
	dlog_print(DLOG_WARN, LOG_TAG, "DEPRECATION WARNING: badge_new() is deprecated and will be removed from next release. Use badge_add() instead.");
	return badge_new_for_uid(writable_app_id, getuid());
}

EXPORT_API
int badge_add(const char *badge_app_id)
{
	return badge_add_for_uid(badge_app_id, getuid());
}

EXPORT_API
int badge_remove(const char *app_id)
{
	return badge_remove_for_uid(app_id, getuid());
}

EXPORT_API
int badge_is_existing(const char *app_id, bool *existing)
{
	return badge_is_existing_for_uid(app_id, existing, getuid());
}

EXPORT_API
int badge_foreach(badge_foreach_cb callback, void *user_data)
{
	return badge_foreach_for_uid(callback, user_data, getuid());
}

EXPORT_API
int badge_set_count(const char *app_id, unsigned int count)
{
	return badge_set_count_for_uid(app_id, count, getuid());
}

EXPORT_API
int badge_get_count(const char *app_id, unsigned int *count)
{
	return badge_get_count_for_uid(app_id, count, getuid());
}

EXPORT_API
int badge_set_display(const char *app_id, unsigned int is_display)
{
	return badge_set_display_for_uid(app_id, is_display, getuid());
}

EXPORT_API
int badge_get_display(const char *app_id, unsigned int *is_display)
{
	return badge_get_display_for_uid(app_id, is_display, getuid());
}

EXPORT_API
int badge_register_changed_cb(badge_change_cb callback, void *data)
{
	return badge_register_changed_cb_for_uid(callback, data, getuid());
}

EXPORT_API
int badge_unregister_changed_cb(badge_change_cb callback)
{
	return badge_unregister_changed_cb_for_uid(callback, getuid());
}

EXPORT_API
int badge_is_service_ready(void)
{
	return badge_ipc_is_master_ready();
}

EXPORT_API
int badge_add_deferred_task(
		void (*badge_add_deferred_task)(void *data), void *user_data)
{
	return badge_ipc_add_deferred_task(badge_add_deferred_task, user_data);
}

EXPORT_API
int badge_del_deferred_task(
		void (*badge_add_deferred_task)(void *data))
{
	return badge_ipc_del_deferred_task(badge_add_deferred_task);
}