1 /* vi: set et sw=4 ts=4 cino=t0,(0: */
2 /* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
4 * This file is part of tlm (Tizen Login Manager)
6 * Copyright (C) 2014 Intel Corporation.
8 * Contact: Imran Zaman <imran.zaman@intel.com>
10 * This library is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Lesser General Public
12 * License as published by the Free Software Foundation; either
13 * version 2.1 of the License, or (at your option) any later version.
15 * This library is distributed in the hope that it will be useful, but
16 * WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Lesser General Public License for more details.
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with this library; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
29 #include "tlm-error.h"
33 * @short_description: error definitions and utilities
36 * This file provides Tlm error definitions and utilities.
37 * When creating an error, use #TLM_ERROR for the error domain and errors
38 * from #TlmError for the error code.
41 * GError* err = g_error_new(TLM_ERROR, TLM_ERROR_INVALID_INPUT,
49 * This macro should be used when creating a #GError (for example with
55 * @TLM_ERROR_NONE: No error
56 * @TLM_ERROR_UNKNOWN: Catch-all for errors not distinguished by another error
58 * @TLM_ERROR_INTERNAL_SERVER: Server internal error
59 * @TLM_ERROR_PERMISSION_DENIED: Permission denied
60 * @TLM_ERROR_INVALID_INPUT: Invalid input
61 * @TLM_ERROR_SEAT_NOT_FOUND: Seat not found
62 * @TLM_ERROR_SESSION_CREATION_FAILURE: Session creation failed
63 * @TLM_ERROR_SESSION_ALREADY_EXISTS: Session already exists
64 * @TLM_ERROR_SESSION_NOT_VALID: session is not valid anymore
65 * @TLM_ERROR_DBUS_SERVER_START_FAILURE: dbus-server startup failed
66 * @TLM_ERROR_DBUS_REQ_ABORTED: Dbus request aborted
67 * @TLM_ERROR_DBUS_REQ_NOT_SUPPORTED: Dbus request not supported
68 * @TLM_ERROR_DBUS_REQ_UNKNOWN: Dbus request failed with unknown error
69 * @TLM_ERROR_LAST_ERR: Placeholder to rearrange enumeration
71 * This enumeration provides a list of errors
77 * This macro defines the error domain for tlm.
79 #define TLM_ERROR_DOMAIN "tlm"
82 * TLM_GET_ERROR_FOR_ID:
83 * @code: A #TlmError specifying the error
84 * @message: Format string for the error message
85 * @...: parameters for the error string
87 * A helper macro that creates a #GError with the proper tlm domain
90 #define _ERROR_PREFIX "org.tizen.Tlm.Error"
92 GDBusErrorEntry _tlm_errors[] =
94 {TLM_ERROR_UNKNOWN, _ERROR_PREFIX".Unknown"},
95 {TLM_ERROR_INTERNAL_SERVER, _ERROR_PREFIX".InternalServerError"},
96 {TLM_ERROR_PERMISSION_DENIED, _ERROR_PREFIX".PermissionDenied"},
98 {TLM_ERROR_INVALID_INPUT, _ERROR_PREFIX".InvalidInput"},
99 {TLM_ERROR_SEAT_NOT_FOUND, _ERROR_PREFIX".SeatNotFound"},
100 {TLM_ERROR_SESSION_CREATION_FAILURE,
101 _ERROR_PREFIX".SessionCreationFailure"},
102 {TLM_ERROR_SESSION_ALREADY_EXISTS, _ERROR_PREFIX".SessionAlreadyExists"},
103 {TLM_ERROR_SESSION_NOT_VALID, _ERROR_PREFIX".SessionNotValid"},
104 {TLM_ERROR_DBUS_SERVER_START_FAILURE,
105 _ERROR_PREFIX".DBusServerStartFailure"},
106 {TLM_ERROR_DBUS_REQ_ABORTED, _ERROR_PREFIX".DBusRequestAborted"},
107 {TLM_ERROR_DBUS_REQ_NOT_SUPPORTED, _ERROR_PREFIX".DBusRequestNotSupported"},
108 {TLM_ERROR_DBUS_REQ_UNKNOWN, _ERROR_PREFIX".DBusRequestUknown"},
114 * Creates and returns a domain for Tlm errors.
116 * Returns: #GQuark for Tlm errors
119 tlm_error_quark (void)
121 static volatile gsize quark_volatile = 0;
123 g_dbus_error_register_error_domain (TLM_ERROR_DOMAIN,
126 G_N_ELEMENTS (_tlm_errors));
128 return (GQuark) quark_volatile;