Skip to content

Commit cce08f3

Browse files
author
Volodymyr Samokhatko
committed
libvncserver: timers
1 parent d306fef commit cce08f3

File tree

3 files changed

+419
-0
lines changed

3 files changed

+419
-0
lines changed

CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,7 @@ set(LIBVNCSERVER_SOURCES
388388
${LIBVNCSERVER_DIR}/ultra.c
389389
${LIBVNCSERVER_DIR}/scale.c
390390
${CRYPTO_SOURCES}
391+
${LIBVNCSERVER_DIR}/rfbtimers.c
391392
)
392393

393394
set(LIBVNCCLIENT_SOURCES
@@ -786,6 +787,7 @@ if(LIBVNCSERVER_INSTALL)
786787
include/rfb/rfblist.h
787788
include/rfb/rfbproto.h
788789
include/rfb/rfbregion.h
790+
include/rfb/rfbtimers.h
789791
)
790792

791793
set_property(TARGET vncclient PROPERTY PUBLIC_HEADER ${INSTALL_HEADER_FILES})

include/rfb/rfbtimers.h

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
/*
2+
* Copyright (C) 2023 AnatoScope SA. All Rights Reserved.
3+
*
4+
* This is free software; you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License as published by
6+
* the Free Software Foundation; either version 2 of the License, or
7+
* (at your option) any later version.
8+
*
9+
* This software is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License
15+
* along with this software; if not, write to the Free Software
16+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
17+
* USA.
18+
*
19+
* Copyright 1987, 1998 The Open Group
20+
*
21+
* Permission to use, copy, modify, distribute, and sell this software and its
22+
* documentation for any purpose is hereby granted without fee, provided that
23+
* the above copyright notice appear in all copies and that both that
24+
* copyright notice and this permission notice appear in supporting
25+
* documentation.
26+
*
27+
* The above copyright notice and this permission notice shall be included in
28+
* all copies or substantial portions of the Software.
29+
*
30+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
31+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
32+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
33+
* OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
34+
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
35+
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
36+
*
37+
* Except as contained in this notice, the name of The Open Group shall not be
38+
* used in advertising or otherwise to promote the sale, use or other dealings
39+
* in this Software without prior written authorization from The Open Group.
40+
*
41+
* Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
42+
*
43+
* All Rights Reserved
44+
*
45+
* Permission to use, copy, modify, and distribute this software and its
46+
* documentation for any purpose and without fee is hereby granted,
47+
* provided that the above copyright notice appear in all copies and that
48+
* both that copyright notice and this permission notice appear in
49+
* supporting documentation, and that the name of Digital not be
50+
* used in advertising or publicity pertaining to distribution of the
51+
* software without specific, written prior permission.
52+
*
53+
* DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
54+
* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
55+
* DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
56+
* ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
57+
* WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
58+
* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
59+
* SOFTWARE.
60+
*/
61+
62+
/*
63+
* Originally derived from TurboVNC ff35d99e9aebb3905c2d90bea7c3305b63c853cd
64+
*/
65+
66+
#ifndef _RFB_TIMERS_H_
67+
#define _RFB_TIMERS_H_
68+
69+
typedef struct _rfbTimersRec rfbTimers;
70+
typedef rfbTimers* rfbTimersPtr;
71+
72+
typedef struct _rfbTimerRec rfbTimer;
73+
typedef rfbTimer* rfbTimerPtr;
74+
75+
/**
76+
* @param timer timer that invoked the callback
77+
* @param time current time
78+
* @param arg user data to pass
79+
* @return if non-zero then set the timer to fire again after that time
80+
*/
81+
typedef unsigned int (*rfbTimerCallback) (rfbTimerPtr timer, unsigned int time, void *arg);
82+
83+
/**
84+
* Create a list for timers.
85+
*/
86+
rfbTimersPtr rfbTimersCreate();
87+
88+
/**
89+
* Destroy a list of timers.
90+
*/
91+
void rfbTimersDestroy(rfbTimersPtr timers);
92+
93+
/**
94+
* Invoke callbacks that were scheduled to run after specified time.
95+
*/
96+
void rfbTimerCheck(rfbTimersPtr timers);
97+
98+
/**
99+
* Schedule a callback to run after specified time, create the timer if needed.
100+
*
101+
* @param timers timer list
102+
* @param timer timer to use (NULL creates a new one)
103+
* @param millis time in milliseconds after which the callback is allowed to be invoked
104+
* @param arg user data to associate with the timer
105+
* @return pointer to a timer that has to be freed by calling rfbTimerFree() (no need to recreate the timer for every rfbTimerSet())
106+
*/
107+
rfbTimerPtr rfbTimerSet(rfbTimersPtr timers, rfbTimerPtr timer, unsigned int millis, rfbTimerCallback func, void *arg);
108+
109+
/**
110+
* Stop timer.
111+
*
112+
* @param timers timer list
113+
* @param timer timer to stop
114+
*/
115+
void rfbTimerCancel(rfbTimersPtr timers, rfbTimerPtr timer);
116+
117+
/**
118+
* Cancel and delete a timer.
119+
*
120+
* @param timers timer list
121+
* @param timer timer to delete
122+
*/
123+
void rfbTimerFree(rfbTimersPtr timers, rfbTimerPtr timer);
124+
125+
#endif /* _RFB_TIMERS_H_ */

0 commit comments

Comments
 (0)