* dbus/dbus-sysdeps.c: Make tcp socket connection error somewhat more
[platform/upstream/dbus.git] / qt / qdbuserror.h
1 /* qdbuserror.h QDBusError object
2  *
3  * Copyright (C) 2005 Harald Fernengel <harry@kdevelop.org>
4  * Copyright (C) 2006 Trolltech AS. All rights reserved.
5  *    Author: Thiago Macieira <thiago.macieira@trolltech.com>
6  *
7  * Licensed under the Academic Free License version 2.1
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 Foundation
21  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22  *
23  */
24
25 #ifndef QDBUSERROR_H
26 #define QDBUSERROR_H
27
28 #include "qdbusmacros.h"
29 #include <QtCore/qstring.h>
30
31 struct DBusError;
32 class QDBusMessage;
33
34 class QDBUS_EXPORT QDBusError
35 {
36 public:
37     enum KnownErrors {
38         NoError = 0,
39         Other = 1,
40         Failed,
41         NoMemory,
42         ServiceUnknown,
43         NoReply,
44         BadAddress,
45         NotSupported,
46         LimitsExceeded,
47         AccessDenied,
48         NoServer,
49         Timeout,
50         NoNetwork,
51         AddressInUse,
52         Disconnected,
53         InvalidArgs,
54         UnknownMethod,
55         TimedOut,
56         InvalidSignature,
57         UnknownInterface,
58         InternalError,
59
60 #ifndef Q_QDOC        
61         // don't use this one!
62         qKnownErrorsMax = InternalError
63 #endif
64     };
65     
66     QDBusError(const DBusError *error = 0);
67     QDBusError(const QDBusMessage& msg);
68     QDBusError(KnownErrors error, const QString &message);
69
70     inline QString name() const { return nm; }
71     inline QString message() const { return msg; }
72     inline bool isValid() const { return !nm.isNull() && !msg.isNull(); }
73
74     inline bool operator==(KnownErrors error) const
75     { return code == error; }
76
77 private:
78     KnownErrors code;
79     QString nm, msg;
80 };
81
82 inline bool operator==(QDBusError::KnownErrors p1, const QDBusError &p2)
83 { return p2 == p1; }
84 inline bool operator!=(QDBusError::KnownErrors p1, const QDBusError &p2)
85 { return !(p2 == p1); }
86 inline bool operator!=(const QDBusError &p1, QDBusError::KnownErrors p2)
87 { return !(p1 == p2); }
88
89 #ifndef QT_NO_DEBUG
90 QDebug operator<<(QDebug, const QDBusError &);
91 #endif
92
93 #endif