1 /*
2  * synergy -- mouse and keyboard sharing utility
3  * Copyright (C) 2012-2016 Symless Ltd.
4  * Copyright (C) 2002 Chris Schoeneman
5  *
6  * This package is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * found in the file LICENSE that should have accompanied this file.
9  *
10  * This package is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #pragma once
20 
21 #include "base/XBase.h"
22 
23 //! Generic synergy exception
24 XBASE_SUBCLASS(XSynergy, XBase);
25 
26 //! Subscription error
27 /*!
28 Thrown when there is a problem with the subscription.
29 */
30 XBASE_SUBCLASS(XSubscription, XSynergy);
31 
32 //! Client error exception
33 /*!
34 Thrown when the client fails to follow the protocol.
35 */
36 XBASE_SUBCLASS_WHAT(XBadClient, XSynergy);
37 
38 //! Incompatible client exception
39 /*!
40 Thrown when a client attempting to connect has an incompatible version.
41 */
42 class XIncompatibleClient : public XSynergy {
43 public:
44     XIncompatibleClient(int major, int minor);
45 
46     //! @name accessors
47     //@{
48 
49     //! Get client's major version number
50     int                    getMajor() const throw();
51     //! Get client's minor version number
52     int                    getMinor() const throw();
53 
54     //@}
55 
56 protected:
57     virtual String        getWhat() const throw();
58 
59 private:
60     int                    m_major;
61     int                    m_minor;
62 };
63 
64 //! Client already connected exception
65 /*!
66 Thrown when a client attempting to connect is using the same name as
67 a client that is already connected.
68 */
69 class XDuplicateClient : public XSynergy {
70 public:
71     XDuplicateClient(const String& name);
~XDuplicateClient()72     virtual ~XDuplicateClient() _NOEXCEPT { }
73 
74     //! @name accessors
75     //@{
76 
77     //! Get client's name
78     virtual const String&
79                         getName() const throw();
80 
81     //@}
82 
83 protected:
84     virtual String        getWhat() const throw();
85 
86 private:
87     String                m_name;
88 };
89 
90 //! Client not in map exception
91 /*!
92 Thrown when a client attempting to connect is using a name that is
93 unknown to the server.
94 */
95 class XUnknownClient : public XSynergy {
96 public:
97     XUnknownClient(const String& name);
~XUnknownClient()98     virtual ~XUnknownClient() _NOEXCEPT { }
99 
100     //! @name accessors
101     //@{
102 
103     //! Get the client's name
104     virtual const String&
105                         getName() const throw();
106 
107     //@}
108 
109 protected:
110     virtual String        getWhat() const throw();
111 
112 private:
113     String                m_name;
114 };
115 
116 //! Generic exit eception
117 /*!
118 Thrown when we want to abort, with the opportunity to clean up. This is a
119 little bit of a hack, but it's a better way of exiting, than just calling
120 exit(int).
121 */
122 class XExitApp : public XSynergy {
123 public:
124     XExitApp(int code);
~XExitApp()125     virtual ~XExitApp() _NOEXCEPT { }
126 
127     //! Get the exit code
128     int getCode() const throw();
129 
130 protected:
131     virtual String    getWhat() const throw();
132 
133 private:
134     int    m_code;
135 };
136