Skip to content

Commit 52a1465

Browse files
author
Korbinian Kram
committed
release 2.7.5
- support of handling augment session invites - compile fix for c++17 - remove X11 headers and introcude xkbcommon - alignment of log messages
1 parent 5204355 commit 52a1465

File tree

164 files changed

+7348
-5428
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

164 files changed

+7348
-5428
lines changed

Bindings/Python/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ set(SOURCE
3434
PyAccessControlModule.h
3535
PyAgentConnection.cpp
3636
PyAgentConnection.h
37+
PyAugmentRCSessionModule.cpp
38+
PyAugmentRCSessionModule.h
3739
PyChatModule.cpp
3840
PyChatModule.h
3941
PyInstantSupportModule.cpp

Bindings/Python/PyAgentConnection.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include <TVAgentAPI/IAgentConnection.h>
2929

3030
#include "PyAccessControlModule.h"
31+
#include "PyAugmentRCSessionModule.h"
3132
#include "PyInstantSupportModule.h"
3233
#include "PyTVSessionManagementModule.h"
3334
#include "PyChatModule.h"
@@ -151,6 +152,9 @@ PyObject* PyAgentConnection_getModule(PyAgentConnection* self, PyObject* arg)
151152
case tvagentapi::IModule::Type::Chat:
152153
return reinterpret_cast<PyObject*>(
153154
MakeWrapperObject<PyChatModule>(self));
155+
case tvagentapi::IModule::Type::AugmentRCSession:
156+
return reinterpret_cast<PyObject*>(
157+
MakeWrapperObject<PyAugmentRCSessionModule>(self));
154158
}
155159
PyErr_BadInternalCall();
156160
return nullptr;
Lines changed: 233 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,233 @@
1+
//********************************************************************************//
2+
// MIT License //
3+
// //
4+
// Copyright (c) 2024 TeamViewer Germany GmbH //
5+
// //
6+
// Permission is hereby granted, free of charge, to any person obtaining a copy //
7+
// of this software and associated documentation files (the "Software"), to deal //
8+
// in the Software without restriction, including without limitation the rights //
9+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell //
10+
// copies of the Software, and to permit persons to whom the Software is //
11+
// furnished to do so, subject to the following conditions: //
12+
// //
13+
// The above copyright notice and this permission notice shall be included in all //
14+
// copies or substantial portions of the Software. //
15+
// //
16+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR //
17+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, //
18+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE //
19+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER //
20+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, //
21+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE //
22+
// SOFTWARE. //
23+
//********************************************************************************//
24+
#include "PyAugmentRCSessionModule.h"
25+
#include <TVAgentAPI/IAugmentRCSessionModule.h>
26+
#include <TVAgentAPI/IAgentAPI.h>
27+
#include <TVAgentAPI/IAgentConnection.h>
28+
29+
#include "PyAgentConnection.h"
30+
#include "PyTVAgentAPI.h"
31+
#include "PythonHelpers.h"
32+
#include "Typesystem.h"
33+
34+
using namespace tvagentapipy;
35+
36+
namespace
37+
{
38+
39+
// Methods
40+
41+
PyObject* PyAugmentRCSessionModule_setCallbacks(
42+
PyAugmentRCSessionModule* self,
43+
PyObject* args,
44+
PyObject* kwargs)
45+
{
46+
char augmentRCSessionInvitationReceivedArgName[] = "augmentRCSessionInvitationReceivedCallback";
47+
48+
PyObject* augmentRCSessionInvitationReceivedCallback = Py_None;
49+
50+
char* kwargList[] = {augmentRCSessionInvitationReceivedArgName, {}};
51+
if (!PyArg_ParseTupleAndKeywords(
52+
args,
53+
kwargs,
54+
"|O:setCallbacks",
55+
kwargList,
56+
&augmentRCSessionInvitationReceivedCallback))
57+
{
58+
return nullptr;
59+
}
60+
61+
augmentRCSessionInvitationReceivedCallback = augmentRCSessionInvitationReceivedCallback == Py_None ? nullptr : augmentRCSessionInvitationReceivedCallback;
62+
63+
if (augmentRCSessionInvitationReceivedCallback && !PyCallable_Check(augmentRCSessionInvitationReceivedCallback))
64+
{
65+
PyErr_Format(PyExc_TypeError, "%R is not callable", augmentRCSessionInvitationReceivedCallback);
66+
return nullptr;
67+
}
68+
69+
Py_XINCREF(augmentRCSessionInvitationReceivedCallback);
70+
Py_XDECREF(self->m_pyAugmentRCSessionInvitationReceivedCallback);
71+
self->m_pyAugmentRCSessionInvitationReceivedCallback = augmentRCSessionInvitationReceivedCallback;
72+
73+
auto augmentRCSessionInvitation = [](const char* url, void* userdata) noexcept
74+
{
75+
auto pyAugmentRCSessionInvitationReceivedCallback = static_cast<PyObject*>(userdata);
76+
77+
PyObject* args = Py_BuildValue("(s)", url);
78+
79+
PyObject* result = PyObject_CallObject(pyAugmentRCSessionInvitationReceivedCallback, args);
80+
Py_DECREF(args);
81+
Py_XDECREF(result);
82+
};
83+
84+
tvagentapi::IAugmentRCSessionModule::ReceivedInvitationCallback invitationReceivedCb{};
85+
if (self->m_pyAugmentRCSessionInvitationReceivedCallback)
86+
{
87+
invitationReceivedCb = {augmentRCSessionInvitation, self->m_pyAugmentRCSessionInvitationReceivedCallback};
88+
}
89+
90+
self->m_module->setCallbacks({invitationReceivedCb});
91+
92+
Py_RETURN_NONE;
93+
}
94+
95+
PyObject* PyAugmentRCSessionModule_startListening(PyAugmentRCSessionModule* self, PyObject* args)
96+
{
97+
(void)args;
98+
return NoneOrInternalError(self->m_module->augmentRCSessionStartListening());
99+
}
100+
101+
PyObject* PyAugmentRCSessionModule_stopListening(PyAugmentRCSessionModule* self, PyObject* args)
102+
{
103+
(void)args;
104+
return NoneOrInternalError(self->m_module->augmentRCSessionStopListening());
105+
}
106+
107+
PyObject* PyAugmentRCSessionModule_isSupported(PyAugmentRCSessionModule* self, PyObject* args)
108+
{
109+
(void)args;
110+
if (self->m_module->isSupported())
111+
{
112+
Py_RETURN_TRUE;
113+
}
114+
Py_RETURN_FALSE;
115+
}
116+
117+
namespace DocStrings
118+
{
119+
120+
PyDoc_STRVAR(isSupported,
121+
R"__(isSupported($self)
122+
--
123+
124+
Returns whether the current module is supported by the SDK and the IoT Agent counterpart.
125+
126+
:return True if the current module is supported, False otherwise.
127+
)__");
128+
129+
PyDoc_STRVAR(setCallbacks,
130+
R"__(setCallbacks($self, /,
131+
AugmentRCSessionInvitationReceived=None)
132+
--
133+
134+
Sets callbacks to handle various events like chat room and message updates.
135+
136+
:param AugmentRCSessionInvitationReceivedCallback: called when an invitation to an Augment RC Session is received
137+
:type AugmentRCSessionInvitationReceivedCallback: callback(str url)
138+
)__");
139+
140+
PyDoc_STRVAR(startListening,
141+
R"__(startListening($self)
142+
--
143+
144+
Announces that the module starts listening for AugmentRCSession invitations.
145+
)__");
146+
147+
PyDoc_STRVAR(stopListening,
148+
R"__(stopListening($self)
149+
--
150+
151+
Announces that the module stops listening for AugmentRCSession invitations.
152+
)__");
153+
154+
} // namespace DocStrings
155+
156+
PyMethodDef PyAugmentRCSessionModule_methods[] =
157+
{
158+
{
159+
"isSupported",
160+
WeakConnectionCall<PyAugmentRCSessionModule, PyAugmentRCSessionModule_isSupported>,
161+
METH_NOARGS,
162+
DocStrings::isSupported
163+
},
164+
{
165+
"setCallbacks",
166+
PyCFunctionCast(WeakConnectionCall<PyAugmentRCSessionModule, PyAugmentRCSessionModule_setCallbacks>),
167+
METH_VARARGS | METH_KEYWORDS,
168+
DocStrings::setCallbacks
169+
},
170+
{
171+
"startListening",
172+
WeakConnectionCall<PyAugmentRCSessionModule, PyAugmentRCSessionModule_startListening>,
173+
METH_NOARGS,
174+
DocStrings::startListening
175+
},
176+
177+
{
178+
"stopListening",
179+
WeakConnectionCall<PyAugmentRCSessionModule, PyAugmentRCSessionModule_stopListening>,
180+
METH_NOARGS,
181+
DocStrings::stopListening
182+
},
183+
184+
{} // Sentinel
185+
};
186+
187+
} // namespace
188+
189+
namespace tvagentapipy
190+
{
191+
192+
PyAugmentRCSessionModule::PyAugmentRCSessionModule(PyAgentConnection* pyAgentConnection)
193+
: m_pyWeakAgentConnection{reinterpret_cast<PyObject*>(pyAgentConnection)}
194+
{
195+
m_module = static_cast<tvagentapi::IAugmentRCSessionModule*>(
196+
pyAgentConnection->m_connection->getModule(
197+
tvagentapi::IModule::Type::AugmentRCSession
198+
));
199+
}
200+
201+
PyAugmentRCSessionModule::~PyAugmentRCSessionModule()
202+
{
203+
Py_XDECREF(m_pyAugmentRCSessionInvitationReceivedCallback);
204+
}
205+
206+
bool PyAugmentRCSessionModule::IsReady() const
207+
{
208+
return !!m_module;
209+
}
210+
211+
PyTypeObject* GetPyTypeAugmentRCSessionModule()
212+
{
213+
static PyTypeObject* pyAugmentRCSessionModuleType = []() -> PyTypeObject*
214+
{
215+
static PyTypeObject result = PyTypeObjectInitialized();
216+
result.tp_name = "tvagentapi.AugmentRCSessionModule";
217+
result.tp_basicsize = sizeof(PyAugmentRCSessionModule);
218+
result.tp_dealloc = reinterpret_cast<destructor>(DeallocWrapperObject<PyAugmentRCSessionModule>);
219+
result.tp_flags = Py_TPFLAGS_DEFAULT;
220+
result.tp_doc = "AugmentRCSession module class";
221+
result.tp_methods = PyAugmentRCSessionModule_methods;
222+
223+
if (PyType_Ready(&result) < 0)
224+
{
225+
return nullptr;
226+
}
227+
228+
return &result;
229+
}();
230+
return pyAugmentRCSessionModuleType;
231+
}
232+
233+
} // namespace tvagentapipy
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
//********************************************************************************//
2+
// MIT License //
3+
// //
4+
// Copyright (c) 2022 TeamViewer Germany GmbH //
5+
// //
6+
// Permission is hereby granted, free of charge, to any person obtaining a copy //
7+
// of this software and associated documentation files (the "Software"), to deal //
8+
// in the Software without restriction, including without limitation the rights //
9+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell //
10+
// copies of the Software, and to permit persons to whom the Software is //
11+
// furnished to do so, subject to the following conditions: //
12+
// //
13+
// The above copyright notice and this permission notice shall be included in all //
14+
// copies or substantial portions of the Software. //
15+
// //
16+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR //
17+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, //
18+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE //
19+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER //
20+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, //
21+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE //
22+
// SOFTWARE. //
23+
//********************************************************************************//
24+
#pragma once
25+
26+
#include "prototypes.h"
27+
#include "PyWeakObject.h"
28+
29+
#include <TVAgentAPI/prototypes.h>
30+
31+
#include <Python.h>
32+
33+
namespace tvagentapipy
34+
{
35+
36+
struct PyAugmentRCSessionModule final
37+
{
38+
PyObject_HEAD
39+
40+
PyAugmentRCSessionModule(PyAgentConnection* pyAgentConnection);
41+
~PyAugmentRCSessionModule();
42+
43+
bool IsReady() const;
44+
45+
PyWeakObject m_pyWeakAgentConnection{};
46+
tvagentapi::IAugmentRCSessionModule* m_module = nullptr;
47+
48+
PyObject* m_pyAugmentRCSessionInvitationReceivedCallback = nullptr;
49+
};
50+
51+
PyTypeObject* GetPyTypeAugmentRCSessionModule();
52+
53+
} // namespace tvagentapipy

Bindings/Python/PyModuleType.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,11 @@ PyTypeObject* GetPyTypeModule_Type()
1818
PyTypeObject* result =
1919
CreateEnumType(
2020
"tvagentapi.ModuleType",
21-
{{toCString(Type::AccessControl), static_cast<long>(Type::AccessControl)},
22-
{toCString(Type::InstantSupport), static_cast<long>(Type::InstantSupport)},
21+
{{toCString(Type::AccessControl), static_cast<long>(Type::AccessControl)},
22+
{toCString(Type::InstantSupport), static_cast<long>(Type::InstantSupport)},
2323
{toCString(Type::TVSessionManagement), static_cast<long>(Type::TVSessionManagement)},
24-
{toCString(Type::Chat), static_cast<long>(Type::Chat)}});
24+
{toCString(Type::Chat), static_cast<long>(Type::Chat)},
25+
{toCString(Type::AugmentRCSession), static_cast<long>(Type::AugmentRCSession)}});
2526
return result;
2627
}();
2728
return pyTypeModule_Type;

Bindings/Python/PyTVAgentAPI.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828

2929
#include "PyAccessControlModule.h"
3030
#include "PyAgentConnection.h"
31+
#include "PyAugmentRCSessionModule.h"
3132
#include "PyInstantSupportModule.h"
3233
#include "PyLogging.h"
3334
#include "PythonHelpers.h"

Bindings/Python/Typesystem.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,12 @@
2424
#include "Typesystem.h"
2525

2626
#include <TVAgentAPI/IAccessControlModule.h>
27+
#include <TVAgentAPI/IAugmentRCSessionModule.h>
2728
#include <TVAgentAPI/IChatModule.h>
2829

2930
#include "PyAccessControlModule.h"
3031
#include "PyAgentConnection.h"
32+
#include "PyAugmentRCSessionModule.h"
3133
#include "PyChatModule.h"
3234
#include "PyInstantSupportModule.h"
3335
#include "PyLogging.h"
@@ -52,6 +54,13 @@ PyTypeMeta GetPyTypeMeta<PyAccessControlModule>()
5254
return meta;
5355
}
5456

57+
template<>
58+
PyTypeMeta GetPyTypeMeta<PyAugmentRCSessionModule>()
59+
{
60+
PyTypeMeta meta{GetPyTypeAugmentRCSessionModule(), "AugmentRCSessionModule"};
61+
return meta;
62+
}
63+
5564
template<>
5665
PyTypeMeta GetPyTypeMeta<PyChatModule>()
5766
{

Bindings/Python/module.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
// SOFTWARE. //
2323
//********************************************************************************//
2424
#include "PyAccessControlModule.h"
25+
#include "PyAugmentRCSessionModule.h"
2526
#include "PyChatModule.h"
2627
#include "PyTVAgentAPI.h"
2728
#include "PyAgentConnection.h"
@@ -58,6 +59,7 @@ PyMODINIT_FUNC PyInit_tvagentapi(void)
5859
GetPyTypeMeta<PyLogging>(),
5960
GetPyTypeMeta<PyAgentConnection>(),
6061
GetPyTypeMeta<PyAccessControlModule>(),
62+
GetPyTypeMeta<PyAugmentRCSessionModule>(),
6163
GetPyTypeMeta<PyChatModule>(),
6264
GetPyTypeMeta<PyInstantSupportModule>(),
6365
GetPyTypeMeta<PyTVSessionManagementModule>(),

Bindings/Python/prototypes.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ namespace tvagentapipy
2828

2929
struct PyAccessControlModule;
3030
struct PyAgentConnection;
31+
struct PyAugmentRCSession;
3132
struct PyChatModule;
3233
struct PyInstantSupportModule;
3334
struct PyTVAgentAPI;

0 commit comments

Comments
 (0)