-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck_events.py
More file actions
215 lines (198 loc) · 6.01 KB
/
check_events.py
File metadata and controls
215 lines (198 loc) · 6.01 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
# coding=utf8
from PyQt5.QAxContainer import *
from PyQt5.QtWidgets import *
from PyQt5.QtCore import *
from PyQt5.QtMultimedia import *
import sys
from PyQt5.Qt import QVideoWidget, QUrl, Qt
from callx import CallXWidget, State
import os.path
import argparse
import json
import time
import config
# Title
TITLE = "CallX Python Example: Check CallX Events"
EVENTS = [
"OnXNotify",
"OnXAfterStart",
"OnLogin",
"OnInviteReceived",
"OnXError",
"OnXLoginError",
"OnIncomingChatMessage",
"OnXChangeState",
"OnXTerminate",
"OnXStartFail",
"OnAbookUpdate",
"OnAppUpdateAvailable",
"OnChangeVideoMatrixReport",
"OnConferenceCreated",
"OnConferenceDeleted",
"OnContactBlocked",
"OnContactDeleted",
"OnContactUnblocked",
"OnHardwareChanged",
"OnDetailInfo",
"OnDeviceModesDone",
"OnIncomingRequestToPodiumAnswered",
"OnInviteRequestSent",
"OnInviteSent",
"OnLogout",
"OnReceiversInfoUpdated",
"OnRecordRequest",
"OnRecordRequestReply",
"OnRejectReceived",
"OnRejectSent",
"OnRemarkCountDown",
"OnRequestInviteReceived",
"OnRoleChanged",
"OnSelfSSInfoUpdate",
"OnServerConnected",
"OnServerDisconnected",
"OnSettingsChanged",
"OnSlideShowStart",
"OnSlideShowStop",
"OnStopCalling",
"OnUpdateAvatar",
"OnUpdateCameraInfo",
"OnUpdateParticipantList",
"OnRestrictionsChanged",
"OnVideoMatrixChanged",
"OnOffHookPressed",
"OnHangUpPressed",
"OnJabraHookOffPressed",
"OnJabraHangUpPressed",
"OnXCommandExecution",
"OnSlideShowInfoUpdate",
"OnStart",
"OnXLogin",
"OnXFileStatusChange",
"OnXFileSendError",
"OnXFileReceiveProgress",
"OnXFileReceive",
"OnXFileSend",
"OnCommandReceived",
"OnBroadcastPictureStateChanged",
"OnCallHistoryUpdated",
"OnCmdAddToAbook",
"OnCmdAddToGroup",
"OnCmdBlock",
"OnCmdChatClear",
"OnCmdCreateGroup",
"OnCmdRemoveFromAbook",
"OnCmdRemoveFromGroup",
"OnCmdRemoveGroup",
"OnCmdRenameGroup",
"OnCmdRenameInAbook",
"OnCmdUnblock",
"OnCommandSent",
"OnFileAccepted",
"OnFileConferenceSent",
"OnFileRejected",
"OnFileSent",
"OnFileTransferAvailable",
"OnGroupsUpdate",
"OnIncomingGroupChatMessage",
"OnGroupChatMessageSent",
"OnChatMessageSent",
"OnTestAudioCapturerStateUpdated",
"OnAudioCapturerRmsLevelUpdated",
"OnToneDial"
]
# Main Window
class KioskWidget(QWidget):
def __init__(self, monitor: int = 0):
self.layout = None
self.callx_widget = None
self.video = None
self.player = None
self.playlist = None
self.monitor = monitor
self.done = False
self.events_log = {}
EVENTS.sort()
QAxWidget.__init__(self)
self.initUI()
def initUI(self):
self.setWindowTitle(TITLE)
self.move(0, 0)
self.resize(640, 360)
# layout
self.layout = QHBoxLayout(self)
self.setLayout(self.layout)
# === CallX widget
self.callx_widget = CallXWidget(self, config.SERVER, config.USER, config.PASSWORD, camera_index = 0, debug_mode=True)
self.layout.addWidget(self.callx_widget.ocx)
# connect to signals
self.callx_widget.stateChanged.connect(self.onStateChanged)
self.callx_widget.IncomingChatMessage.connect(self.onIncomingChatMessage)
# events
self.callx_widget.onEvent.connect(self.onCallXEvent)
self.callx_widget.onEventArg.connect(self.onCallXEventArg)
# === listEventsWidget
self.listEventsWidget = QListWidget()
self.initListEventsWidget() # add all events
self.listEventsWidget.clicked.connect(self.listEventsWidget_clicked)
self.layout.addWidget(self.listEventsWidget)
# === textWidget
self.textWidget = QTextEdit()
self.layout.addWidget(self.textWidget)
def initListEventsWidget(self):
for event in EVENTS:
item = QListWidgetItem(event)
item.setFlags(Qt.ItemIsUserCheckable | Qt.ItemIsEnabled)
item.setCheckState(False)
self.listEventsWidget.addItem(item)
#self.listEventsWidget.insertItem(self.listEventsWidget.count(), event)
# ============================================================================================
# Signals
# ============================================================================================
def onStateChanged(self, callx, prev_state, new_state):
print('Signal onStateChanged: "{}" -> "{}"'.format(prev_state, new_state))
if new_state == State.Normal:
callx.ocx.getAbook()
def onIncomingChatMessage(self, peerId, peerDn, message, time):
pass
# ============================================================================================
def listEventsWidget_clicked(self, qmodelindex):
self.updateItem()
def onCallXEvent(self, name):
self.events_log.setdefault(name, [name])
items_list = self.listEventsWidget.findItems(name, Qt.MatchExactly)
for item in items_list:
item.setCheckState(True)
# update
self.updateItem()
def onCallXEventArg(self, name, arg):
self.events_log.setdefault(name, [])
self.events_log[name].append(str(arg))
# update
self.updateItem()
def updateItem(self):
item = self.listEventsWidget.currentItem()
if not item:
return
if item.text() in self.events_log:
txt = "\n\n".join(self.events_log[item.text()])
self.textWidget.setText(txt)
else:
self.textWidget.setText("")
# end of class CallXWindow(QWidget)
if __name__ == '__main__':
# command line
## monitor
parser = argparse.ArgumentParser()
parser.add_argument("-m", "--monitor", dest="monitor",
help="Index of the monitor.", type=int)
args = parser.parse_args()
monitor = args.monitor
# Check required variables
if (not config.SERVER) or (not config.USER) or (not config.PASSWORD):
print('Please set variables to connect and authorize. List variables: SERVER, USER, PASSWORD.')
sys.exit()
else:
app = QApplication(sys.argv)
MainWindow = KioskWidget(monitor)
MainWindow.show()
sys.exit(app.exec_())