2003-03-04 Havoc Pennington <hp@pobox.com>
[platform/upstream/dbus.git] / dbus / dbus-errors.h
1 /* -*- mode: C; c-file-style: "gnu" -*- */
2 /* dbus-errors.h Error reporting
3  *
4  * Copyright (C) 2002  Red Hat Inc.
5  * Copyright (C) 2003  CodeFactory AB
6  *
7  * Licensed under the Academic Free License version 1.2
8  * 
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  * 
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
22  *
23  */
24 #if !defined (DBUS_INSIDE_DBUS_H) && !defined (DBUS_COMPILATION)
25 #error "Only <dbus/dbus.h> can be included directly, this file may disappear or change contents."
26 #endif
27
28 #ifndef DBUS_ERROR_H
29 #define DBUS_ERROR_H
30
31 #include <dbus/dbus-macros.h>
32 #include <dbus/dbus-types.h>
33
34 DBUS_BEGIN_DECLS;
35
36 typedef struct DBusError DBusError;
37
38 struct DBusError
39 {
40   const char *name;    /**< error name */
41   const char *message; /**< error message */
42
43   unsigned int dummy1 : 1; /**< placeholder */
44   unsigned int dummy2 : 1; /**< placeholder */
45   unsigned int dummy3 : 1; /**< placeholder */
46   unsigned int dummy4 : 1; /**< placeholder */
47   unsigned int dummy5 : 1; /**< placeholder */
48
49   void *padding1; /**< placeholder */
50 };
51
52 #define DBUS_ERROR_FAILED                     "org.freedesktop.DBus.Error.Failed"
53 #define DBUS_ERROR_ACTIVATE_SERVICE_NOT_FOUND "org.freedesktop.DBus.Activate.ServiceNotFound"
54 #define DBUS_ERROR_SPAWN_FORK_FAILED          "org.freedesktop.DBus.Error.Spawn.ForkFailed"
55 #define DBUS_ERROR_SPAWN_FAILED               "org.freedesktop.DBus.Error.Spawn.Failed"
56 #define DBUS_ERROR_NO_MEMORY                  "org.freedesktop.DBus.Error.NoMemory"
57 #define DBUS_ERROR_SERVICE_DOES_NOT_EXIST     "org.freedesktop.DBus.Error.ServiceDoesNotExist"
58 #define DBUS_ERROR_NO_REPLY                   "org.freedesktop.DBus.Error.NoReply"
59
60 typedef enum
61 {
62   DBUS_RESULT_SUCCESS,         /**< Operation was successful. */
63   DBUS_RESULT_FAILED,          /**< Operation failed for unspecified reason. */
64   DBUS_RESULT_NO_MEMORY,       /**< Operation failed for lack of memory. */
65   DBUS_RESULT_IO_ERROR,        /**< Operation failed because of an IO error,
66                                 *   typically the other end closed the
67                                 *   connection.
68                                 */
69   DBUS_RESULT_BAD_ADDRESS,     /**< Address was bad, could not be parsed. */
70   DBUS_RESULT_NOT_SUPPORTED,   /**< Feature is not supported. */
71   DBUS_RESULT_LIMITS_EXCEEDED, /**< Some kernel resource limit exceeded. */
72   DBUS_RESULT_ACCESS_DENIED,   /**< Some sort of permissions/security problem. */
73   DBUS_RESULT_AUTH_FAILED,     /**< Could not authenticate. */
74   DBUS_RESULT_NO_SERVER,       /**< No one listening on the other end. */
75   DBUS_RESULT_TIMEOUT,         /**< Timed out trying to connect. */
76   DBUS_RESULT_NO_NETWORK,      /**< Can't find the network */
77   DBUS_RESULT_ADDRESS_IN_USE,  /**< Someone's already using the address */
78   DBUS_RESULT_DISCONNECTED,    /**< No more connection. */
79   DBUS_RESULT_INVALID_ARGS,    /**< One or more invalid arguments encountered. */
80   DBUS_RESULT_NO_REPLY,        /**< Did not get a reply message. */
81   DBUS_RESULT_FILE_NOT_FOUND   /**< File doesn't exist */
82 } DBusResultCode;
83
84 void        dbus_error_init      (DBusError       *error);
85 void        dbus_error_free      (DBusError       *error);
86 void        dbus_set_error       (DBusError       *error,
87                                   const char      *name,
88                                   const char      *message,
89                                   ...);
90 void        dbus_set_error_const (DBusError       *error,
91                                   const char      *name,
92                                   const char      *message);
93 dbus_bool_t dbus_error_has_name  (const DBusError *error,
94                                   const char      *name);
95 dbus_bool_t dbus_error_is_set    (const DBusError *error);
96
97
98 void        dbus_set_result       (DBusResultCode *code_address,
99                                    DBusResultCode  code);
100 const char* dbus_result_to_string (DBusResultCode  code);
101
102 DBUS_END_DECLS;
103
104 #endif /* DBUS_ERROR_H */