Move notification_get_text_input_max_length to internal
[platform/core/api/notification.git] / src / notification_error.c
1 /*
2  * Copyright (c) 2000 - 2016 Samsung Electronics Co., Ltd. All rights reserved.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 #include <string.h>
18 #include <gio/gio.h>
19 #include "notification_error.h"
20
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 };
33
34 #define NOTIFICATION_ERROR_QUARK "notification-error-quark"
35
36 EXPORT_API GQuark notification_error_quark(void)
37 {
38         static volatile gsize quark_volatile = 0;
39         static const char *domain_name = NULL;
40
41         /* This is for preventing crash when notification api is used in ui-gadget     */
42         /* ui-gadget libraries can be unloaded when it is needed and the static string */
43         /* parameter to g_dbus_error_register_error_domain may cause crash.             */
44         GQuark quark = g_quark_try_string(NOTIFICATION_ERROR_QUARK);
45
46         if (quark == 0) {
47                 if (domain_name == NULL)
48                         domain_name = strdup(NOTIFICATION_ERROR_QUARK);
49         } else {
50                 domain_name = NOTIFICATION_ERROR_QUARK;
51         }
52
53         g_dbus_error_register_error_domain(domain_name,
54                         &quark_volatile,
55                         dbus_error_entries,
56                         G_N_ELEMENTS(dbus_error_entries));
57         return (GQuark)quark_volatile;
58 }
59