summaryrefslogtreecommitdiff
path: root/src/badge.c
blob: 15df5c2b12dca0bac63b0a6e64d22f0402f99a82 (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
/*
 * Copyright (c) 2000 - 2017 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 <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_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.");
	if (writable_app_id == NULL)
		return BADGE_ERROR_INVALID_PARAMETER;

	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)
{
	if (app_id == NULL)
		return BADGE_ERROR_INVALID_PARAMETER;

	return badge_remove_for_uid(app_id, getuid());
}

EXPORT_API
int badge_foreach(badge_foreach_cb callback, void *user_data)
{
	if (callback == NULL)
		return BADGE_ERROR_INVALID_PARAMETER;

	return badge_foreach_for_uid(callback, user_data, getuid());
}

EXPORT_API
int badge_set_count(const char *app_id, unsigned int count)
{
	if (app_id == NULL)
		return BADGE_ERROR_INVALID_PARAMETER;

	return badge_set_count_for_uid(app_id, count, getuid());
}

EXPORT_API
int badge_get_count(const char *app_id, unsigned int *count)
{
	if (app_id == NULL || count == NULL)
		return BADGE_ERROR_INVALID_PARAMETER;

	return badge_get_count_for_uid(app_id, count, getuid());
}

EXPORT_API
int badge_set_display(const char *app_id, unsigned int is_display)
{
	if (app_id == NULL)
		return BADGE_ERROR_INVALID_PARAMETER;

	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)
{
	if (app_id == NULL || is_display == NULL)
		return BADGE_ERROR_INVALID_PARAMETER;

	return badge_get_display_for_uid(app_id, is_display, getuid());
}

EXPORT_API
int badge_register_changed_cb(badge_change_cb callback, void *data)
{
	if (callback == NULL)
		return BADGE_ERROR_INVALID_PARAMETER;

	return badge_register_changed_cb_for_uid(callback, data, getuid());
}

EXPORT_API
int badge_unregister_changed_cb(badge_change_cb callback)
{
	if (callback == NULL)
		return BADGE_ERROR_INVALID_PARAMETER;

	return badge_unregister_changed_cb_for_uid(callback, getuid());
}