2 * Copyright (c) 2000 - 2017 Samsung Electronics Co., Ltd. All rights reserved.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include "notification_error.h"
21 static const GDBusErrorEntry dbus_error_entries[] = {
22 {NOTIFICATION_ERROR_INVALID_PARAMETER, "org.freedesktop.Notification.Error.INVALID_PARAMETER"},
23 {NOTIFICATION_ERROR_OUT_OF_MEMORY, "org.freedesktop.Notification.Error.OUT_OF_MEMORY"},
24 {NOTIFICATION_ERROR_IO_ERROR, "org.freedesktop.Notification.Error.IO_ERROR"},
25 {NOTIFICATION_ERROR_PERMISSION_DENIED, "org.freedesktop.Notification.Error.PERMISSION_DENIED"},
26 {NOTIFICATION_ERROR_FROM_DB, "org.freedesktop.Notification.Error.FROM_DB"},
27 {NOTIFICATION_ERROR_ALREADY_EXIST_ID, "org.freedesktop.Notification.Error.ALREADY_EXIST_ID"},
28 {NOTIFICATION_ERROR_FROM_DBUS, "org.freedesktop.Notification.Error.FROM_DBUS"},
29 {NOTIFICATION_ERROR_NOT_EXIST_ID, "org.freedesktop.Notification.Error.NOT_EXIST_ID"},
30 {NOTIFICATION_ERROR_SERVICE_NOT_READY, "org.freedesktop.Notification.Error.SERVICE_NOT_READY"},
31 {NOTIFICATION_ERROR_INVALID_OPERATION, "org.freedesktop.Notification.Error.INVALID_OPERATION"},
32 {NOTIFICATION_ERROR_MAX_EXCEEDED, "org.freedesktop.Notification.Error.MAX_EXCEEDED"},
35 #define NOTIFICATION_ERROR_QUARK "notification-error-quark"
37 EXPORT_API GQuark notification_error_quark(void)
39 static volatile gsize quark_volatile = 0;
40 static const char *domain_name = NULL;
42 /* This is for preventing crash when notification api is used in ui-gadget */
43 /* ui-gadget libraries can be unloaded when it is needed and the static string */
44 /* parameter to g_dbus_error_register_error_domain may cause crash. */
45 GQuark quark = g_quark_try_string(NOTIFICATION_ERROR_QUARK);
48 if (domain_name == NULL)
49 domain_name = strdup(NOTIFICATION_ERROR_QUARK);
51 domain_name = NOTIFICATION_ERROR_QUARK;
54 g_dbus_error_register_error_domain(domain_name,
57 G_N_ELEMENTS(dbus_error_entries));
58 return (GQuark)quark_volatile;