-
Notifications
You must be signed in to change notification settings - Fork 34
Expand file tree
/
Copy pathEventTypes.h
More file actions
834 lines (677 loc) · 18.9 KB
/
EventTypes.h
File metadata and controls
834 lines (677 loc) · 18.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
/*
* Deskflow -- mouse and keyboard sharing utility
* Copyright (C) 2013-2026 Symless Ltd.
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "base/Event.h"
class IEventQueue;
class EventTypes
{
public:
EventTypes();
void setEvents(IEventQueue *events);
protected:
IEventQueue *getEvents() const;
private:
IEventQueue *m_events;
};
#define REGISTER_EVENT(type_, name_) \
Event::Type type_##Events::name_() \
{ \
return getEvents()->registerTypeOnce(m_##name_, __FUNCTION__); \
}
class ClientEvents : public EventTypes
{
public:
//! @name accessors
//@{
//! Get connected event type
/*!
Returns the connected event type. This is sent when the client has
successfully connected to the server.
*/
Event::Type connected();
//! Get connection failed event type
/*!
Returns the connection failed event type. This is sent when the
server fails for some reason. The event data is a FailInfo*.
*/
Event::Type connectionFailed();
//! Get connection refused event type
/*!
Returns the connection refused event type. This is sent when the
server refuses for some reason. The event data is a FailInfo*.
*/
Event::Type connectionRefused();
//! Get disconnected event type
/*!
Returns the disconnected event type. This is sent when the client
has disconnected from the server (and only after having successfully
connected).
*/
Event::Type disconnected();
//@}
private:
Event::Type m_connected = Event::kUnknown;
Event::Type m_connectionFailed = Event::kUnknown;
Event::Type m_connectionRefused = Event::kUnknown;
Event::Type m_disconnected = Event::kUnknown;
};
class IStreamEvents : public EventTypes
{
public:
IStreamEvents()
: m_inputReady(Event::kUnknown),
m_outputFlushed(Event::kUnknown),
m_outputError(Event::kUnknown),
m_inputShutdown(Event::kUnknown),
m_outputShutdown(Event::kUnknown)
{
}
//! @name accessors
//@{
//! Get input ready event type
/*!
Returns the input ready event type. A stream sends this event
when \c read() will return with data.
*/
Event::Type inputReady();
//! Get output flushed event type
/*!
Returns the output flushed event type. A stream sends this event
when the output buffer has been flushed. If there have been no
writes since the event was posted, calling \c shutdownOutput() or
\c close() will not discard any data and \c flush() will return
immediately.
*/
Event::Type outputFlushed();
//! Get output error event type
/*!
Returns the output error event type. A stream sends this event
when a write has failed.
*/
Event::Type outputError();
//! Get input shutdown event type
/*!
Returns the input shutdown event type. This is sent when the
input side of the stream has shutdown. When the input has
shutdown, no more data will ever be available to read.
*/
Event::Type inputShutdown();
//! Get output shutdown event type
/*!
Returns the output shutdown event type. This is sent when the
output side of the stream has shutdown. When the output has
shutdown, no more data can ever be written to the stream. Any
attempt to do so will generate a output error event.
*/
Event::Type outputShutdown();
//@}
private:
Event::Type m_inputReady;
Event::Type m_outputFlushed;
Event::Type m_outputError;
Event::Type m_inputShutdown;
Event::Type m_outputShutdown;
};
class IpcClientEvents : public EventTypes
{
public:
IpcClientEvents() : m_connected(Event::kUnknown), m_messageReceived(Event::kUnknown)
{
}
//! @name accessors
//@{
//! Raised when the socket is connected.
Event::Type connected();
//! Raised when a message is received.
Event::Type messageReceived();
//@}
private:
Event::Type m_connected;
Event::Type m_messageReceived;
};
class IpcClientProxyEvents : public EventTypes
{
public:
IpcClientProxyEvents() : m_messageReceived(Event::kUnknown), m_disconnected(Event::kUnknown)
{
}
//! @name accessors
//@{
//! Raised when the server receives a message from a client.
Event::Type messageReceived();
//! Raised when the client disconnects from the server.
Event::Type disconnected();
//@}
private:
Event::Type m_messageReceived;
Event::Type m_disconnected;
};
class IpcServerEvents : public EventTypes
{
public:
IpcServerEvents() : m_clientConnected(Event::kUnknown), m_messageReceived(Event::kUnknown)
{
}
//! @name accessors
//@{
//! Raised when we have created the client proxy.
Event::Type clientConnected();
//! Raised when a message is received through a client proxy.
Event::Type messageReceived();
//@}
private:
Event::Type m_clientConnected;
Event::Type m_messageReceived;
};
class IpcServerProxyEvents : public EventTypes
{
public:
IpcServerProxyEvents() : m_messageReceived(Event::kUnknown)
{
}
//! @name accessors
//@{
//! Raised when the client receives a message from the server.
Event::Type messageReceived();
//@}
private:
Event::Type m_messageReceived;
};
class IDataSocketEvents : public EventTypes
{
public:
IDataSocketEvents()
: m_connected(Event::kUnknown),
m_secureConnected(Event::kUnknown),
m_connectionFailed(Event::kUnknown)
{
}
//! @name accessors
//@{
//! Get connected event type
/*!
Returns the socket connected event type. A socket sends this
event when a remote connection has been established.
*/
Event::Type connected();
//! Get secure connected event type
/*!
Returns the secure socket connected event type. A secure socket sends
this event when a remote connection has been established.
*/
Event::Type secureConnected();
//! Get connection failed event type
/*!
Returns the socket connection failed event type. A socket sends
this event when an attempt to connect to a remote port has failed.
The data is a pointer to a ConnectionFailedInfo.
*/
Event::Type connectionFailed();
//@}
private:
Event::Type m_connected;
Event::Type m_secureConnected;
Event::Type m_connectionFailed;
};
class IListenSocketEvents : public EventTypes
{
public:
IListenSocketEvents() : m_connecting(Event::kUnknown)
{
}
//! @name accessors
//@{
//! Get connecting event type
/*!
Returns the socket connecting event type. A socket sends this
event when a remote connection is waiting to be accepted.
*/
Event::Type connecting();
//@}
private:
Event::Type m_connecting;
};
class ISocketEvents : public EventTypes
{
public:
ISocketEvents() : m_disconnected(Event::kUnknown), m_stopRetry(Event::kUnknown)
{
}
//! @name accessors
//@{
//! Get disconnected event type
/*!
Returns the socket disconnected event type. A socket sends this
event when the remote side of the socket has disconnected or
shutdown both input and output.
*/
Event::Type disconnected();
//! Get stop retry event type
/*!
Returns the stop retry event type. This is sent when the client
doesn't want to reconnect after it disconnects from the server.
*/
Event::Type stopRetry();
//@}
private:
Event::Type m_disconnected;
Event::Type m_stopRetry;
};
class OSXScreenEvents : public EventTypes
{
public:
OSXScreenEvents() : m_confirmSleep(Event::kUnknown)
{
}
//! @name accessors
//@{
Event::Type confirmSleep();
//@}
private:
Event::Type m_confirmSleep;
};
class ClientListenerEvents : public EventTypes
{
public:
ClientListenerEvents() : m_accepted(Event::kUnknown), m_connected(Event::kUnknown)
{
}
//! @name accessors
//@{
//! Get accepted event type
/*!
Returns the accepted event type. This is sent whenever a server
accepts a client.
*/
Event::Type accepted();
//! Get connected event type
/*!
Returns the connected event type. This is sent whenever a
a client connects.
*/
Event::Type connected();
//@}
private:
Event::Type m_accepted;
Event::Type m_connected;
};
class ClientProxyEvents : public EventTypes
{
public:
ClientProxyEvents() : m_ready(Event::kUnknown), m_disconnected(Event::kUnknown), m_grabInput(Event::kUnknown)
{
}
//! @name accessors
//@{
//! Get ready event type
/*!
Returns the ready event type. This is sent when the client has
completed the initial handshake. Until it is sent, the client is
not fully connected.
*/
Event::Type ready();
//! Get disconnect event type
/*!
Returns the disconnect event type. This is sent when the client
disconnects or is disconnected. The target is getEventTarget().
*/
Event::Type disconnected();
Event::Type grabInput();
//@}
private:
Event::Type m_ready;
Event::Type m_disconnected;
Event::Type m_grabInput;
};
class ClientProxyUnknownEvents : public EventTypes
{
public:
ClientProxyUnknownEvents() : m_success(Event::kUnknown), m_failure(Event::kUnknown)
{
}
//! @name accessors
//@{
//! Get success event type
/*!
Returns the success event type. This is sent when the client has
correctly responded to the hello message. The target is this.
*/
Event::Type success();
//! Get failure event type
/*!
Returns the failure event type. This is sent when a client fails
to correctly respond to the hello message. The target is this.
*/
Event::Type failure();
//@}
private:
Event::Type m_success;
Event::Type m_failure;
};
class ServerEvents : public EventTypes
{
public:
ServerEvents()
: m_error(Event::kUnknown),
m_connected(Event::kUnknown),
m_disconnected(Event::kUnknown),
m_switchToScreen(Event::kUnknown),
m_switchInDirection(Event::kUnknown),
m_keyboardBroadcast(Event::kUnknown),
m_lockCursorToScreen(Event::kUnknown),
m_screenSwitched(Event::kUnknown)
{
}
//! @name accessors
//@{
//! Get error event type
/*!
Returns the error event type. This is sent when the server fails
for some reason.
*/
Event::Type error();
//! Get connected event type
/*!
Returns the connected event type. This is sent when a client screen
has connected. The event data is a \c ScreenConnectedInfo* that
indicates the connected screen.
*/
Event::Type connected();
//! Get disconnected event type
/*!
Returns the disconnected event type. This is sent when all the
clients have disconnected.
*/
Event::Type disconnected();
//! Get switch to screen event type
/*!
Returns the switch to screen event type. The server responds to this
by switching screens. The event data is a \c SwitchToScreenInfo*
that indicates the target screen.
*/
Event::Type switchToScreen();
//! Get switch in direction event type
/*!
Returns the switch in direction event type. The server responds to this
by switching screens. The event data is a \c SwitchInDirectionInfo*
that indicates the target direction.
*/
Event::Type switchInDirection();
//! Get keyboard broadcast event type
/*!
Returns the keyboard broadcast event type. The server responds
to this by turning on keyboard broadcasting or turning it off. The
event data is a \c KeyboardBroadcastInfo*.
*/
Event::Type keyboardBroadcast();
//! Get lock cursor event type
/*!
Returns the lock cursor event type. The server responds to this
by locking the cursor to the active screen or unlocking it. The
event data is a \c LockCursorToScreenInfo*.
*/
Event::Type lockCursorToScreen();
//! Get screen switched event type
/*!
Returns the screen switched event type. This is raised when the
screen has been switched to a client.
*/
Event::Type screenSwitched();
//@}
private:
Event::Type m_error;
Event::Type m_connected;
Event::Type m_disconnected;
Event::Type m_switchToScreen;
Event::Type m_switchInDirection;
Event::Type m_keyboardBroadcast;
Event::Type m_lockCursorToScreen;
Event::Type m_screenSwitched;
};
class ServerAppEvents : public EventTypes
{
public:
ServerAppEvents() : m_reloadConfig(Event::kUnknown), m_forceReconnect(Event::kUnknown), m_resetServer(Event::kUnknown)
{
}
//! @name accessors
//@{
Event::Type reloadConfig();
Event::Type forceReconnect();
Event::Type resetServer();
//@}
private:
Event::Type m_reloadConfig;
Event::Type m_forceReconnect;
Event::Type m_resetServer;
};
class IKeyStateEvents : public EventTypes
{
public:
IKeyStateEvents() : m_keyDown(Event::kUnknown), m_keyUp(Event::kUnknown), m_keyRepeat(Event::kUnknown)
{
}
//! @name accessors
//@{
//! Get key down event type. Event data is KeyInfo*, count == 1.
Event::Type keyDown();
//! Get key up event type. Event data is KeyInfo*, count == 1.
Event::Type keyUp();
//! Get key repeat event type. Event data is KeyInfo*.
Event::Type keyRepeat();
//@}
private:
Event::Type m_keyDown;
Event::Type m_keyUp;
Event::Type m_keyRepeat;
};
class IPrimaryScreenEvents : public EventTypes
{
public:
IPrimaryScreenEvents()
: m_buttonDown(Event::kUnknown),
m_buttonUp(Event::kUnknown),
m_motionOnPrimary(Event::kUnknown),
m_motionOnSecondary(Event::kUnknown),
m_wheel(Event::kUnknown),
m_screensaverActivated(Event::kUnknown),
m_screensaverDeactivated(Event::kUnknown),
m_hotKeyDown(Event::kUnknown),
m_hotKeyUp(Event::kUnknown),
m_fakeInputBegin(Event::kUnknown),
m_fakeInputEnd(Event::kUnknown),
m_touchActivatedPrimary(Event::kUnknown)
{
}
//! @name accessors
//@{
//! button down event type. Event data is ButtonInfo*.
Event::Type buttonDown();
//! button up event type. Event data is ButtonInfo*.
Event::Type buttonUp();
//! mouse motion on the primary screen event type
/*!
Event data is MotionInfo* and the values are an absolute position.
*/
Event::Type motionOnPrimary();
//! mouse motion on a secondary screen event type
/*!
Event data is MotionInfo* and the values are motion deltas not
absolute coordinates.
*/
Event::Type motionOnSecondary();
//! mouse wheel event type. Event data is WheelInfo*.
Event::Type wheel();
//! screensaver activated event type
Event::Type screensaverActivated();
//! screensaver deactivated event type
Event::Type screensaverDeactivated();
//! hot key down event type. Event data is HotKeyInfo*.
Event::Type hotKeyDown();
//! hot key up event type. Event data is HotKeyInfo*.
Event::Type hotKeyUp();
//! start of fake input event type
Event::Type fakeInputBegin();
//! end of fake input event type
Event::Type fakeInputEnd();
Event::Type touchActivatedPrimary();
//@}
private:
Event::Type m_buttonDown;
Event::Type m_buttonUp;
Event::Type m_motionOnPrimary;
Event::Type m_motionOnSecondary;
Event::Type m_wheel;
Event::Type m_screensaverActivated;
Event::Type m_screensaverDeactivated;
Event::Type m_hotKeyDown;
Event::Type m_hotKeyUp;
Event::Type m_fakeInputBegin;
Event::Type m_fakeInputEnd;
Event::Type m_touchActivatedPrimary;
};
class IScreenEvents : public EventTypes
{
public:
IScreenEvents()
: m_error(Event::kUnknown),
m_shapeChanged(Event::kUnknown),
m_suspend(Event::kUnknown),
m_resume(Event::kUnknown),
m_grabInput(Event::kUnknown)
{
}
//! @name accessors
//@{
//! Get error event type
/*!
Returns the error event type. This is sent whenever the screen has
failed for some reason (e.g. the X Windows server died).
*/
Event::Type error();
//! Get shape changed event type
/*!
Returns the shape changed event type. This is sent whenever the
screen's shape changes.
*/
Event::Type shapeChanged();
//! Get suspend event type
/*!
Returns the suspend event type. This is sent whenever the system goes
to sleep or a user session is deactivated (fast user switching).
*/
Event::Type suspend();
//! Get resume event type
/*!
Returns the resume event type. This is sent whenever the system wakes
up or a user session is activated (fast user switching).
*/
Event::Type resume();
Event::Type grabInput();
//@}
private:
Event::Type m_error;
Event::Type m_shapeChanged;
Event::Type m_suspend;
Event::Type m_resume;
Event::Type m_grabInput;
};
class ClipboardEvents : public EventTypes
{
public:
ClipboardEvents()
: m_clipboardGrabbed(Event::kUnknown),
m_clipboardChanged(Event::kUnknown),
m_clipboardSending(Event::kUnknown)
{
}
//! @name accessors
//@{
//! Get clipboard grabbed event type
/*!
Returns the clipboard grabbed event type. This is sent whenever the
clipboard is grabbed by some other application so we don't own it
anymore. The data is a pointer to a ClipboardInfo.
*/
Event::Type clipboardGrabbed();
//! Get clipboard changed event type
/*!
Returns the clipboard changed event type. This is sent whenever the
contents of the clipboard has changed. The data is a pointer to a
IScreen::ClipboardInfo.
*/
Event::Type clipboardChanged();
//! Clipboard sending event type
/*!
Returns the clipboard sending event type. This is used to send
clipboard chunks.
*/
Event::Type clipboardSending();
//@}
private:
Event::Type m_clipboardGrabbed;
Event::Type m_clipboardChanged;
Event::Type m_clipboardSending;
};
class FileEvents : public EventTypes
{
public:
FileEvents()
: m_fileChunkSending(Event::kUnknown),
m_fileRecieveCompleted(Event::kUnknown),
m_keepAlive(Event::kUnknown)
{
}
//! @name accessors
//@{
//! Sending a file chunk
Event::Type fileChunkSending();
//! Completed receiving a file
Event::Type fileRecieveCompleted();
//! Send a keep alive
Event::Type keepAlive();
//@}
private:
Event::Type m_fileChunkSending;
Event::Type m_fileRecieveCompleted;
Event::Type m_keepAlive;
};
class EiEvents : public EventTypes
{
public:
EiEvents() : m_connected(Event::kUnknown), m_sessionClosed(Event::kUnknown)
{
}
//! @name accessors
//@{
//! Get connected event type
/*!
This event is sent whenever connection to EIS is established and a file
descriptor for reading events is available.
*/
Event::Type connected();
//! Get session closed event type
/*!
This event is sent whenever the portal session managing our EIS connection
is closed.
*/
Event::Type sessionClosed();
//@}
private:
Event::Type m_connected;
Event::Type m_sessionClosed;
};