Subversion Repositories tpanel

Rev

Rev 479 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
446 andreas 1
/*
486 andreas 2
 * Copyright (C) 2020 to 2025 by Andreas Theofilu <andreas@theosys.at>
446 andreas 3
 *
4
 * This program 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 3 of the License, or
7
 * (at your option) any later version.
8
 *
9
 * This program 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 program; if not, write to the Free Software Foundation,
16
 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
17
 */
18
 
19
#ifndef __TPAGEMANAGER_H__
20
#define __TPAGEMANAGER_H__
21
 
22
#include <functional>
23
#include <thread>
24
#ifdef __ANDROID__
25
#include <jni.h>
26
#endif
27
#include <qglobal.h>
28
 
29
#include "tpagelist.h"
30
#include "tpage.h"
31
#include "tsubpage.h"
32
#include "tsettings.h"
33
#include "tpalette.h"
34
#include "tbutton.h"
35
#include "tfont.h"
36
#include "texternal.h"
37
#include "tamxnet.h"
38
#include "tamxcommands.h"
39
#include "tsystemdraw.h"
40
#include "tsipclient.h"
41
#include "tvector.h"
42
#include "tbitmap.h"
43
#include "tbuttonstates.h"
458 andreas 44
#include "tqintercom.h"
486 andreas 45
#include "tapps.h"
446 andreas 46
 
47
#define REG_CMD(func, name)     registerCommand(bind(&TPageManager::func, this,std::placeholders::_1,std::placeholders::_2,std::placeholders::_3),name)
48
 
49
class TIcons;
50
class TPageManager;
51
 
52
extern bool prg_stopped;
53
extern TIcons *gIcons;
54
extern TPrjResources *gPrjResources;
55
extern TPageManager *gPageManager;
56
 
57
#ifdef __ANDROID__
58
#define NETSTATE_WIFI   1
59
#define NETSTATE_CELL   2
60
#endif
61
 
62
/**
63
 * @brief PGSUBVIEWATOM_T
64
 * This struct contains the elements of an item inside a subview list.
65
 */
66
typedef struct PGSUBVIEWATOM_T
67
{
68
    ulong handle{0};
69
    ulong parent{0};
70
    int top{0};
71
    int left{0};
72
    int width{0};
73
    int height{0};
74
    int instance{0};
75
    TColor::COLOR_T bgcolor{0};
76
    TBitmap image;
77
    std::string bounding;
78
 
79
    void clear()
80
    {
81
        handle = parent = 0;
82
        top = left = width = height = instance = 0;
83
        bgcolor.alpha = bgcolor.blue = bgcolor.green = bgcolor.red = 0;
84
        image.clear();
85
        bounding.clear();
86
    }
87
}PGSUBVIEWATOM_T;
88
 
89
/**
90
 * @brief PGSUBVIEWITEM_T
91
 * This struct contains the overall dimensions and definition of an item of a
92
 * subview list. Each item may consist of one or more buttons. Each item is a
93
 * subpage of it's own.
94
 * All subpage together are the subview list.
95
 */
96
typedef struct PGSUBVIEWITEM_T
97
{
98
    ulong handle{0};
99
    ulong parent{0};
100
    int width{0};
101
    int height{0};
102
    bool scrollbar{false};
103
    int scrollbarOffset{0};
104
    Button::SUBVIEW_POSITION_t position{Button::SVP_CENTER};
105
    bool wrap{false};
106
    TColor::COLOR_T bgcolor;
107
    TBitmap image;
108
    std::string bounding;
109
    std::vector<PGSUBVIEWATOM_T> atoms;
110
 
111
    void clear()
112
    {
113
        handle = parent = 0;
114
        width = height = 0;
115
        bgcolor.alpha = bgcolor.blue = bgcolor.green = bgcolor.red = 0;
116
        scrollbar = wrap = false;
117
        scrollbarOffset = 0;
118
        position = Button::SVP_CENTER;
119
        image.clear();
120
        bounding.clear();
121
        atoms.clear();
122
    }
123
}PGSUBVIEWITEM_T;
124
 
125
class TPageManager : public TAmxCommands
126
{
127
    public:
128
        typedef enum J_ORIENTATION
129
        {
130
            O_UNDEFINED = -1,
131
            O_LANDSCAPE = 0,
132
            O_PORTRAIT = 1,
133
            O_REVERSE_LANDSCAPE = 8,
134
            O_REVERSE_PORTRAIT = 9,
135
            O_FACE_UP = 15,
136
            O_FACE_DOWN = 16
137
        }J_ORIENTATION;
138
 
139
        typedef enum SWIPES
140
        {
141
            SW_UNKNOWN,
142
            SW_LEFT,
143
            SW_RIGHT,
144
            SW_UP,
145
            SW_DOWN
146
        }SWIPES;
147
 
148
        TPageManager();
149
        ~TPageManager();
150
 
151
        bool readPages();                                   //!< Read all pages and subpages
152
        bool readPage(const std::string& name);             //!< Read the page with name \p name
153
        bool readPage(int ID);                              //!< Read the page with id \p ID
154
        bool readSubPage(const std::string& name);          //!< Read the subpage with name \p name
155
        bool readSubPage(int ID);                           //!< Read the subpage with ID \p ID
156
        void updateActualPage();                            //!< Updates all elements of the actual page
157
        void updateSubpage(int ID);                         //!< Updates all elements of a subpage
158
        void updateSubpage(const std::string& name);        //!< Updates all elements of a subpage
159
        std::vector<TSubPage *> createSubViewList(int id);  //!< Create a list of subview pages
160
        void showSubViewList(int id, Button::TButton *bt);  //!< Creates and displays a subview list
161
        void updateSubViewItem(Button::TButton *bt);        //!< Updates an existing subview item
162
 
163
        TPageList *getPageList() { return mPageList; }      //!< Get the list of all pages
164
        TSettings *getSettings() { return mTSettings; }     //!< Get the (system) settings of the panel
165
 
166
        TPage *getActualPage();                             //!< Get the actual page
167
        int getActualPageNumber() { return mActualPage; }   //!< Get the ID of the actual page
168
        int getPreviousPageNumber() { return mPreviousPage; }   //!< Get the ID of the previous page, if there was any.
169
        TSubPage *getFirstSubPage();
170
        TSubPage *getNextSubPage();
171
        TSubPage *getPrevSubPage();
172
        TSubPage *getLastSubPage();
173
        TSubPage *getFirstSubPageGroup(const std::string& group);
174
        TSubPage *getNextSubPageGroup();
175
        TSubPage *getNextSubPageGroup(const std::string& group, TSubPage *pg);
176
        TSubPage *getTopPage();
177
 
178
        TPage *getPage(int pageID);
179
        TPage *getPage(const std::string& name);
180
        bool setPage(int PageID, bool forget=false);
181
        bool setPage(const std::string& name, bool forget=false);
182
        TSubPage *getSubPage(int pageID);
183
        TSubPage *getSubPage(const std::string& name);
184
        TSubPage *deliverSubPage(const std::string& name, TPage **pg=nullptr);
185
        TSubPage *deliverSubPage(int number, TPage **pg=nullptr);
186
        bool havePage(const std::string& name);
187
        bool haveSubPage(const std::string& name);
188
        bool haveSubPage(int id);
189
        bool haveSubPage(const std::string& page, const std::string& name);
190
        bool haveSubPage(const std::string& page, int id);
191
        TFont *getFonts() { return mFonts; }
192
        Button::TButton *findButton(ulong handle);
193
        Button::TButton *findBargraph(int lp, int lv, ulong parent);
194
        void onSwipeEvent(SWIPES sw);
195
        double getDPI() { return mDPI; }
196
        void setDPI(const double dpi) { mDPI = dpi; }
197
 
198
        void registerCallbackDB(std::function<void(ulong handle, ulong parent, TBitmap buffer, int width, int height, int left, int top, bool passthrough, int marqtype, int marq)> displayButton) { _displayButton = displayButton; }
199
        void registerSetMarqueeText(std::function<void(Button::TButton *button)> marquee) { _setMarqueeText = marquee; }
200
        void registerDropButton(std::function<void(ulong hanlde)> dropButton) { _dropButton = dropButton; }
201
        void registerCBsetVisible(std::function<void(ulong handle, bool state)> setVisible) { _setVisible = setVisible; }
202
        void registerCallbackSP(std::function<void (ulong handle, int width, int height)> setPage) { _setPage = setPage; }
203
        void registerCallbackSSP(std::function<void (ulong handle, ulong parent, int left, int top, int width, int height, ANIMATION_t animate, bool modal)> setSubPage) { _setSubPage = setSubPage; }
204
#ifdef _OPAQUE_SKIA_
205
        void registerCallbackSB(std::function<void (ulong handle, TBitmap image, int width, int height, ulong color)> setBackground) {_setBackground = setBackground; }
206
#else
207
        void registerCallbackSB(std::function<void (ulong handle, TBitmap image, int width, int height, ulong color, int opacity)> setBackground) {_setBackground = setBackground; }
208
#endif
209
        void deployCallbacks();
210
#ifdef __ANDROID__
211
        void initNetworkState();
212
        void stopNetworkState();
213
        void initBatteryState();
214
        void stopBatteryState();
215
        void initPhoneState();
216
        void informTPanelNetwork(jboolean conn, jint level, jint type);
217
        void informBatteryStatus(jint level, jboolean charging, jint chargeType);
218
        void informPhoneState(bool call, const std::string& pnumber);
219
        void initOrientation();
220
        void enterSetup();
221
#endif
222
#ifdef Q_OS_IOS
223
        void informBatteryStatus(int level, int state);
224
        void informTPanelNetwork(bool conn, int level, int type);
225
#endif
226
        void regCallDropPage(std::function<void (ulong handle)> callDropPage) { _callDropPage = callDropPage; }
227
        void regCallDropSubPage(std::function<void (ulong handle, ulong parent)> callDropSubPage) { _callDropSubPage = callDropSubPage; }
228
        void regCallPlayVideo(std::function<void (ulong handle, ulong parent, int left, int top, int width, int height, const std::string& url, const std::string& user, const std::string& pw)> callPlayVideo) { _callPlayVideo = callPlayVideo; };
229
        void regCallInputText(std::function<void (Button::TButton *button, Button::BITMAP_t& bm, int frame)> callInputText) { _callInputText = callInputText; }
230
        void regCallListBox(std::function<void (Button::TButton *button, Button::BITMAP_t& bm, int frame)> callListBox) { _callListBox = callListBox; }
231
        void regCallbackKeyboard(std::function<void (const std::string& init, const std::string& prompt, bool priv)> callKeyboard) { _callKeyboard = callKeyboard; }
232
        void regCallbackKeypad(std::function<void (const std::string& init, const std::string& prompt, bool priv)> callKeypad) { _callKeypad = callKeypad; }
233
        void regCallResetKeyboard(std::function<void ()> callResetKeyboard) { _callResetKeyboard = callResetKeyboard; }
234
        void regCallShowSetup(std::function<void ()> callShowSetup) { _callShowSetup = callShowSetup; }
235
        void regCallbackNetState(std::function<void (int level)> callNetState, ulong handle);
236
        void unregCallbackNetState(ulong handle);
237
#ifdef Q_OS_ANDROID
238
        void regCallbackBatteryState(std::function<void (int level, bool charging, int chargeType)> callBatteryState, ulong handle);
239
#endif
240
#ifdef Q_OS_IOS
241
        void regCallbackBatteryState(std::function<void (int level, int state)> callBatteryState, ulong handle);
242
#endif
243
#if defined(Q_OS_ANDROID) || defined(Q_OS_IOS)
244
        void unregCallbackBatteryState(ulong handle);
245
#endif
246
        void regCallbackResetSurface(std::function<void ()> resetSurface) { _resetSurface = resetSurface; }
247
        void regCallbackShutdown(std::function<void ()> shutdown) { _shutdown = shutdown; }
248
        void regCallbackPlaySound(std::function<void (const std::string& file)> playSound) { _playSound = playSound; }
249
        void regCallbackStopSound(std::function<void ()> stopSound) { _stopSound = stopSound; }
250
        void regCallbackMuteSound(std::function<void (bool state)> muteSound) { _muteSound = muteSound; }
251
        void regCallbackSetVolume(std::function<void (int volume)> setVolume) { _setVolume = setVolume; }
252
        void regSendVirtualKeys(std::function<void (const std::string& str)> sendVirtualKeys) { _sendVirtualKeys = sendVirtualKeys; }
253
        void regShowPhoneDialog(std::function<void (bool state)> showPhoneDialog) { _showPhoneDialog = showPhoneDialog; }
254
        void regSetPhoneNumber(std::function<void (const std::string& number)> setPhoneNumber) { _setPhoneNumber = setPhoneNumber; }
255
        void regSetPhoneStatus(std::function<void (const std::string& msg)> setPhoneStatus) { _setPhoneStatus = setPhoneStatus; }
256
        void regSetPhoneState(std::function<void (int state, int id)> setPhoneState) { _setPhoneState = setPhoneState; }
257
        void regDisplayMessage(std::function<void (const std::string& msg, const std::string& title)> msg) { _displayMessage = msg; }
258
        void regAskPassword(std::function<void (ulong handle, const std::string& msg, const std::string& title, int x, int y)> pw) { _askPassword = pw; }
259
        void regFileDialogFunction(std::function<void (ulong handle, const std::string& path, const std::string& extension, const std::string& suffix)> fdlg) { _fileDialog = fdlg; }
260
#if defined(Q_OS_ANDROID) || defined(Q_OS_IOS)
261
        void regOnOrientationChange(std::function<void (int orientation)> orientationChange) { _onOrientationChange = orientationChange; }
262
        void regOnSettingsChanged(std::function<void (const std::string& oldNetlinx, int oldPort, int oldChannelID, const std::string& oldSurface, bool oldToolbarSuppress, bool oldToolbarForce)> settingsChanged) { _onSettingsChanged = settingsChanged; }
263
#endif
264
        void regRepaintWindows(std::function<void ()> repaintWindows) { _repaintWindows = repaintWindows; }
265
        void regToFront(std::function<void (ulong handle)> toFront) { _toFront = toFront; }
266
        void regSetMainWindowSize(std::function<void (int width, int height)> setSize) { _setMainWindowSize = setSize; }
267
        void regDownloadSurface(std::function<void (const std::string& file, size_t size)> dl) { _downloadSurface = dl; }
268
        void regStartWait(std::function<void (const std::string& text)> sw) { _startWait = sw; }
269
        void regStopWait(std::function<void ()> sw) { _stopWait = sw; }
270
        void regPageFinished(std::function<void (ulong handle)> pf) { _pageFinished = pf; }
271
        void regDisplayViewButton(std::function<void (ulong handle, ulong parent, bool vertical, TBitmap buffer, int width, int height, int left, int top, int space, TColor::COLOR_T)> dvb) { _displayViewButton = dvb; }
272
        void regAddViewButtonItem(std::function<void (Button::TButton& button, unsigned char *buffer, int pixline)> avbi) { _addViewButtonItem = avbi; }
273
        void regAddViewButtonItems(std::function<void (ulong parent, std::vector<PGSUBVIEWITEM_T> items)> abvi) { _addViewButtonItems = abvi; }
274
        void regUpdateViewButton(std::function<void (ulong handle, ulong parent, TBitmap buffer, TColor::COLOR_T fillColor)> uvb) { _updateViewButton = uvb; }
275
        void regUpdateViewButtonItem(std::function<void (PGSUBVIEWITEM_T& item, ulong parent)> uvb) { _updateViewButtonItem = uvb; }
276
        void regShowSubViewItem(std::function<void (ulong handle, ulong parent, int position, int timer)> ssvi) { _showSubViewItem = ssvi; }
277
        void regToggleSubViewItem(std::function<void (ulong handle, ulong parent, int position, int timer)> tsvi) { _toggleSubViewItem = tsvi; }
278
        void regHideAllSubViewItems(std::function<void (ulong handle)> hasvi) { _hideAllSubViewItems = hasvi; }
279
        void regHideSubViewItem(std::function<void (ulong handle, ulong parent)> hsvi) { _hideSubViewItem = hsvi; }
280
        void regSetSubViewPadding(std::function<void (ulong handle, int padding)> ssvp) { _setSubViewPadding = ssvp; }
458 andreas 281
        void regInitializeIntercom(std::function<void (INTERCOM_t ic)> intercom) { _initializeIntercom = intercom; }
282
        void regIntercomStart(std::function<void ()> start) { _intercomStart = start; }
283
        void regIntercomStop(std::function<void ()> stop) { _intercomStop = stop; }
284
        void regIntercomSpkLevel(std::function<void (int level)> spk) { _intercomSpkLevel = spk; }
285
        void regIntercomMicLevel(std::function<void (int level)> mic) { _intercomSpkLevel = mic; }
286
        void regIntercomMute(std::function<void (bool mute)> mute) { _intercomMute = mute; }
446 andreas 287
 
288
        /**
289
         * The following function must be called to start non graphics part
290
         * of the panel simulator. If everything worked well, it returns TRUE.
291
         * otherwise a FALSE is returned and the program should be terminated.
292
         */
293
        bool run();
294
        /**
295
         * Set an X value to add to the coordinated reported by the mouse catch
296
         * event. In case the X coordinate reported by the event is not the real
297
         * X coordinate, it's possible to set an X coordinate to translate the
298
         * internal used coordinates.
299
         *
300
         * @param x
301
         * The left most pixel which correspond to X = 0
302
         */
303
        void setFirstLeftPixel(int x) { mFirstLeftPixel = x; }
304
        /**
305
         * Set an Y value to add to the coordinated reported by the mouse catch
306
         * event. In case the Y coordinate reported by the event is not the real
307
         * Y coordinate, it's possible to set an Y coordinate to translate the
308
         * internal used coordinates.
309
         *
310
         * @param y
311
         * The top most pixel which correspond to Y = 0
312
         */
313
        void setFirstTopPixel(int y) { mFirstTopPixel = y; }
314
        /**
315
         * This function must be called from a GUI whenever the left mouse
316
         * button was pressed or released. Also if there was a touch event
317
         * this function must be called in the same way. It's up to any GUI
318
         * to handle the mouse and or touch events.
319
         *
320
         * @param x
321
         * the X coordinate of the mouse/touch event
322
         *
323
         * @param y
324
         * the y coordinate if the mouse/touch event
325
         *
326
         * @return
327
         * pressed TRUE = button was pressed; FALSE = button was released
328
         */
329
        void mouseEvent(int x, int y, bool pressed);
330
        /**
331
         * @brief mouseEvent
332
         * This function can be called from a GUI if the coordinates of the
333
         * mouse click are not available but the handle of an object who
334
         * received a mouse click.
335
         *
336
         * @param handle    The handle of an object
337
         * @param pressed   TRUE=The mouse button is pressed.
338
         */
339
        void mouseEvent(ulong handle, bool pressed);
340
        /**
341
         * @brief mouseMoveEvent - Moves bar on a bargraph
342
         * This method looks for an object which is a bargraph. If so it is
343
         * moved to the position of the mouse pointer. The behavior depends on
344
         * the settings.
345
         * This method just queues the event. For real handling of it look at
346
         * method _mouseEvent().
347
         *
348
         * @param x     The x coordinate of the mouse pointer
349
         * @param y     The y coordinate of the mouse pointer
350
         */
351
        void mouseMoveEvent(int x, int y);
352
        /**
353
         * Searches for a button with the handle \p handle and determines all
354
         * buttons with the same port and channel. Then it sets \p txt to all
355
         * found buttons.
356
         *
357
         * @param handle    The handle of a button.
358
         * @param txt       The text usualy comming from an input line.
359
         * @param redraw    If this is set to true the button is redrawn.
360
         */
361
        void setTextToButton(ulong handle, const std::string& txt, bool redraw=false);
362
        /**
363
         * Iterates through all active subpages of the active page and drops
364
         * them.
365
         */
366
        void dropAllSubPages();
367
        /**
368
         * Closes all subpages in the group \p group.
369
         *
370
         * @param group The name of the group.
371
         */
372
        void closeGroup(const std::string& group);
373
        /**
374
         * Displays the subpage \p name. If the subpage is part of a group
375
         * the open subpage in the group is closed, if there was one open. Then
376
         * the subpage is displayed. If the subpage is not already in the
377
         * internal buffer it's configuration file is read and the page is
378
         * created.
379
         *
380
         * @param name  The name of the subpage to display.
381
         */
382
        void showSubPage(const std::string& name);
383
        /**
384
         * Displays the subpage \p number. If the subpage is part of a group
385
         * the open subpage in the group is closed, if there was one open. Then
386
         * the subpage is displayed. If the subpage is not already in the
387
         * internal buffer it's configuration file is read and the page is
388
         * created.
389
         *
390
         * @param name  The name of the subpage to display.
391
         */
392
        void showSubPage(int number, bool force=false);
393
        /**
394
         * Hides the subpage \p name.
395
         *
396
         * @param name  The name of the subpage to hide.
397
         */
398
        void hideSubPage(const std::string& name);
399
        /**
400
         * This is called whenever an input button finished or changed it's
401
         * content. It is called indirectly out of the class TQEditLine.
402
         * The method writes the content into the text area of the button the
403
         * handle points to.
404
         *
405
         * @param handle   The handle of the button.
406
         * @param content  The content of the text area.
407
         */
408
        void inputButtonFinished(ulong handle, const std::string& content);
409
        void inputCursorPositionChanged(ulong handle, int oldPos, int newPos);
410
        void inputFocusChanged(ulong handle, bool in);
411
#ifdef _SCALE_SKIA_
412
        void setScaleFactor(double scale) { mScaleFactor = scale; }
413
        double getScaleFactor() { return mScaleFactor; }
414
        void setScaleFactorWidth(double scale) { mScaleFactorWidth = scale; }
415
        double getScaleFactorWidth() { return mScaleFactorWidth; }
416
        void setScaleFactorHeight(double scale) { mScaleFactorHeight = scale; }
417
        double getScaleFactorHeight() { return mScaleFactorHeight; }
418
#endif
419
        /**
420
         * This method handles some external buttons. Some original panels from
421
         * AMX have external hard buttons. TPanel simulates some of them like
422
         * the arrow keys, enter button and volume. The graphical surface may
423
         * display a toolbar on the right side (only if there is enough space
424
         * left) which offers this buttons. When such a button was pressed, this
425
         * method is called to send them to the controller.
426
         *
427
         * @param bt        The button who was pressed
428
         * @param checked   On button press this is TRUE, and on release it is FALSE.
429
         */
430
        void externalButton(extButtons_t bt, bool checked);
431
 
432
        void sendKeyboard(const std::string& text);
433
        void sendKeypad(const std::string& text);
434
        void sendString(uint handle, const std::string& text);
435
        void sendGlobalString(const std::string& text);
436
        void sendPHNcommand(const std::string& cmd);
437
        void sendKeyStroke(char key);
438
        void sendCommandString(int port, const std::string& cmd);
439
        void sendLevel(int lp, int lv, int level);
440
        void sendInternalLevel(int lp, int lv, int level);
441
        void callSetPassword(ulong handle, const std::string& pw, int x, int y);
442
        TButtonStates *addButtonState(BUTTONTYPE t, int rap, int rad, int rch, int rcp, int rlp, int rlv);
443
        TButtonStates *addButtonState(const TButtonStates& bs);
444
        TButtonStates *getButtonState(BUTTONTYPE t, int rap, int rad, int rch, int rcp, int rlp, int rlv);
445
        TButtonStates *getButtonState(uint32_t id);
446
        TButtonStates *getButtonState(BUTTONTYPE t, uint32_t id);
447
 
448
        /**
449
         * This starts the communication with the AMX controller. The method
450
         * registers the callbacks and starts a thread. This thread runs as
451
         * long as a valid communication is possible or until the communication
452
         * end by a command.
453
         */
454
        void startUp();
455
        /**
456
         * This starts a thread running the command loop. Each event from the
457
         * Netlinx is entered into a vector array (doCommand()) and this
458
         * method starts the event loop as a thread running as long as this
459
         * class exists.
460
         */
461
        void runCommands();
462
        /**
463
         * This method is the thread started by the command runCommands().
464
         */
465
        void commandLoop();
466
        /**
467
         * Callback function for the AMX controller part. This function must
468
         * be registered to the class TAmxNet and is called from this module
469
         * every time an event occured from the controller.
470
         * This method handles the commands comming from the controller and
471
         * draws the necessary elements before they are sent to the GUI.
472
         *
473
         * @param cmd
474
         * An ANET_COMMAND structure containing the received command.
475
         */
476
        void doCommand(const amx::ANET_COMMAND& cmd);
477
        /**
478
         * Activates the setup pages unless they are not visible already.
479
         */
480
        void showSetup();
481
        /**
482
         * Determines the page or subpage the handle points to and returns the
483
         * selected row of a list, if there is one.
484
         * The row index starts by 1!
485
         *
486
         * @param handle    The handle of the button.
487
         * @return If the button is a list and a row was selected then a number
488
         * grater than 0 is returned. Otherwise -1 is returned.
489
         */
490
        int getSelectedRow(ulong handle);
491
        /**
492
         * Finds the page or subpage and returns the selected item as a string.
493
         * If there was no list, or no items in the list, or nothing selected,
494
         * an empty string is returned.
495
         *
496
         * @param handle    The handle of the button
497
         * @return The string of the selected item or an empty string.
498
         */
499
        std::string getSelectedItem(ulong handle);
500
        /**
501
         * Finds the corresponding list and sets the selected row. The \b row
502
         * must be a value starting by 1. It must not be bigger that items in
503
         * the list.
504
         *
505
         * @param handle    The handle of the button
506
         * @param row       The number of the selected row.
507
         */
508
        void setSelectedRow(ulong handle, int row, const std::string& text);
509
        /**
510
         * @brief redrawObject - redraws an object
511
         * The method sends the last stored graphic to the surface where it is
512
         * drawn.
513
         * If the object is not visible, it is not redrawn.
514
         *
515
         * @param handle    The handle of the object.
516
         */
517
        void redrawObject(ulong handle);
518
#ifdef Q_OS_IOS
519
        void setBattery(int level, int state) { mLastBatteryLevel = level; mLastBatteryState = state; }
520
#endif
521
#ifdef _SCALE_SKIA_
522
        /**
523
         * Set the scale factor for the system setup pages. On a desktop this
524
         * factor is in relation to the size of the normal pages, if there any.
525
         * On a mobile device the factor is in relation to the resolution of
526
         * the display.
527
         * The scale factor is calculated in qtmain.cpp: MainWindow::calcScaleSetup()
528
         *
529
         * @param scale  The overall scale factor. This is used for calculations
530
         * and ensures that the ratio of the objects is maintained.
531
         * @param sw     The scale factor for the width.
532
         * @param sh     The scale factor for the height.
533
         */
534
        void setSetupScaleFactor(double scale, double sw, double sh);
535
#endif
536
        // Callbacks who will be registered by the graphical surface.
537
        std::function<void (ulong handle, ulong parent, TBitmap buffer, int width, int height, int left, int top, bool passthrough, int marqtype, int marq)> getCallbackDB() { return _displayButton; }
538
        std::function<void (Button::TButton *button)> getSetMarqueeText() { return _setMarqueeText; }
539
        std::function<void (ulong handle)> getCallDropButton() { return _dropButton; }
540
        std::function<void (ulong handle, bool state)> getVisible() { return _setVisible; };
541
#ifdef _OPAQUE_SKIA_
542
        std::function<void (ulong handle, TBitmap image, int width, int height, ulong color)> getCallbackBG() { return _setBackground; }
543
#else
544
        std::function<void (ulong handle, TBitmap image, int width, int height, ulong color, int opacity)> getCallbackBG() { return _setBackground; }
545
#endif
546
        std::function<void (ulong handle, ulong parent, int left, int top, int width, int height, const std::string& url, const std::string& user, const std::string& pw)> getCallbackPV() { return _callPlayVideo; }
547
        std::function<void (ulong handle, int width, int height)> getCallbackSetPage() { return _setPage; }
548
        std::function<void (Button::TButton *button, Button::BITMAP_t& bm, int frame)> getCallbackInputText() { return _callInputText; }
549
        std::function<void (Button::TButton *button, Button::BITMAP_t& bm, int frame)> getCallbackListBox() { return _callListBox; }
550
        std::function<void (ulong handle, ulong parent, int left, int top, int width, int height, ANIMATION_t animate, bool modal)> getCallbackSetSubPage() { return _setSubPage; }
551
        std::function<void (ulong handle)> getCallDropPage() { return _callDropPage; }
552
        std::function<void (ulong handle, ulong parent)> getCallDropSubPage() { return _callDropSubPage; }
553
        std::function<void (const std::string& file)> getCallPlaySound() { return _playSound; }
554
        std::function<void ()> getCallStopSound() { return _stopSound; }
555
        std::function<void (bool state)> getCallMuteSound() { return _muteSound; }
556
        std::function<void (int volume)> getCallSetVolume() { return _setVolume; }
557
        std::function<void (const std::string& str)> sendVirtualKeys() { return _sendVirtualKeys; }
558
        std::function<void (bool state)> getShowPhoneDialog() { return _showPhoneDialog; }
559
        std::function<void (const std::string& number)> getSetPhoneNumber() { return _setPhoneNumber; }
560
        std::function<void (const std::string& msg)> getSetPhoneStatus() { return _setPhoneStatus; }
561
        std::function<void (int state, int id)> getSetPhoneState() { return _setPhoneState; }
562
        std::function<void (ulong handle)> getToFront() { return _toFront; }
563
        std::function<void (int width, int height)> getMainWindowSizeFunc() { return _setMainWindowSize; }
564
        std::function<void (const std::string& file, size_t size)> getDownloadSurface() { return _downloadSurface; }
565
        std::function<void (const std::string& msg, const std::string& title)> getDisplayMessage() { return _displayMessage; }
566
        std::function<void (ulong handle, const std::string& msg, const std::string& title, int x, int y)> getAskPassword() { return _askPassword; }
567
        std::function<void (ulong handle, const std::string& path, const std::string& extension, const std::string& suffix)> getFileDialogFunction() { return _fileDialog; }
568
        std::function<void (const std::string& text)> getStartWait() { return _startWait; }
569
        std::function<void ()> getStopWait() { return _stopWait; }
570
        std::function<void (ulong handle)> getPageFinished() { return _pageFinished; }
571
        std::function<void (ulong handle, ulong parent, bool vertical, TBitmap buffer, int width, int height, int left, int top, int space, TColor::COLOR_T fillColor)> getDisplayViewButton() { return _displayViewButton; }
572
        std::function<void (Button::TButton& button, unsigned char *buffer, int pixline)> getAddViewButtonItem() { return _addViewButtonItem; }
573
        std::function<void (ulong parent, std::vector<PGSUBVIEWITEM_T> items)> getAddViewButtonItems() { return _addViewButtonItems; }
574
        std::function<void (ulong handle, ulong parent, TBitmap buffer, TColor::COLOR_T fillColor)> getUpdateViewButton() { return _updateViewButton; }
575
        std::function<void (PGSUBVIEWITEM_T& item, ulong parent)> getUpdateViewButtonItem() { return _updateViewButtonItem; }
576
        std::function<void (ulong handle, ulong parent, int position, int timer)> getShowSubViewItem() { return _showSubViewItem; }
577
        std::function<void (ulong handle, ulong parent, int position, int timer)> getToggleSubViewItem() { return _toggleSubViewItem; }
578
        std::function<void (ulong handle)> getHideAllSubViewItems() { return _hideAllSubViewItems; }
579
        std::function<void (ulong handle, ulong parent)> getHideSubViewItem() { return _hideSubViewItem; }
580
        std::function<void (ulong handle, int padding)> getSetSubViewPadding() { return _setSubViewPadding; }
458 andreas 581
        std::function<void (INTERCOM_t ic)> getInitializeIntercom() { return _initializeIntercom; }
446 andreas 582
#if defined(Q_OS_ANDROID) || defined(Q_OS_IOS)
583
        std::function<void (int orientation)> onOrientationChange() { return _onOrientationChange; }
584
        std::function<void (const std::string& oldNetlinx, int oldPort, int oldChannelID, const std::string& oldSurface, bool oldToolbarSuppress, bool oldToolbarForce)> onSettingsChanged() { return _onSettingsChanged; }
585
#endif
586
        bool getLevelSendState() { return mLevelSend; }
587
        bool getRxSendState() { return mRxOn; }
588
        std::function<void ()> getRepaintWindows() { return _repaintWindows; }
589
        int getOrientation() { return mOrientation; }
590
        void setOrientation(int ori) { mOrientation = ori; }
591
        bool getInformOrientation() { return mInformOrientation; }
592
        void sendOrientation();
593
        bool havePlaySound() { return _playSound != nullptr; }
594
        TSystemDraw *getSystemDraw() { return mSystemDraw; }
595
        void reset();
596
        bool getPassThrough() { return mPassThrough; }
597
        bool haveSetupPage() { return _callShowSetup != nullptr; }
598
        bool haveShutdown() { return _shutdown != nullptr; }
599
        void callSetupPage() { if (_callShowSetup) _callShowSetup(); }
600
        void callShutdown() { if (_shutdown) _shutdown(); }
601
#ifndef _NOSIP_
602
        bool getPHNautoanswer() { return mPHNautoanswer; }
603
        void sendPHN(std::vector<std::string>& cmds);
604
        void actPHN(std::vector<std::string>& cmds);
605
        void phonePickup(int id);
606
        void phoneHangup(int id);
607
#endif
608
        void addFtpSurface(const std::string& file, size_t size) { mFtpSurface.push_back(_FTP_SURFACE_t{file, size}); };
609
 
610
        inline size_t getFtpSurfaceSize(const std::string& file)
611
        {
612
            if (mFtpSurface.empty())
613
                return 0;
614
 
615
            std::vector<_FTP_SURFACE_t>::iterator iter;
616
 
617
            for (iter = mFtpSurface.begin(); iter != mFtpSurface.end(); ++iter)
618
            {
619
                if (iter->file == file)
620
                    return iter->size;
621
            }
622
 
623
            return 0;
624
        }
625
 
626
        void clearFtpSurface() { mFtpSurface.clear(); }
627
 
628
    protected:
629
        PAGELIST_T findPage(const std::string& name);
630
        PAGELIST_T findPage(int ID);
631
        SUBPAGELIST_T findSubPage(const std::string& name);
632
        SUBPAGELIST_T findSubPage(int ID);
633
 
634
        bool addPage(TPage *pg);
635
        bool addSubPage(TSubPage *pg);
636
        TSubPage *getCoordMatch(int x, int y);
637
        Button::TButton *getCoordMatchPage(int x, int y);
638
        void initialize();
639
        void dropAllPages();
640
        bool startComm();
641
 
642
    private:
643
        std::function<void (ulong handle, ulong parent, TBitmap image, int width, int height, int left, int top, bool passthrough, int marqtype, int marq)> _displayButton{nullptr};
644
        std::function<void (Button::TButton *button)> _setMarqueeText{nullptr};
645
        std::function<void (ulong handle)> _dropButton{nullptr};
646
        std::function<void (ulong handle, bool state)> _setVisible{nullptr};
647
        std::function<void (ulong handle, int width, int height)> _setPage{nullptr};
648
        std::function<void (ulong handle, ulong parent, int left, int top, int width, int height, ANIMATION_t animate, bool modal)> _setSubPage{nullptr};
649
#ifdef _OPAQUE_SKIA_
650
        std::function<void (ulong handle, TBitmap image, int width, int height, ulong color)> _setBackground{nullptr};
651
#else
652
        std::function<void (ulong handle, TBitmap image, int width, int height, ulong color, int opacity)> _setBackground{nullptr};
653
#endif
479 andreas 654
        std::function<void (ulong handle, const std::string& text, const std::string& font, const std::string& family, int size, int x, int y, ulong color, ulong effectColor, FONT_STYLE style, Button::ORIENTATION ori, Button::TEXT_EFFECT effect, bool ww)> _setText{nullptr};
446 andreas 655
        std::function<void (ulong handle)> _callDropPage{nullptr};
656
        std::function<void (ulong handle, ulong parent)> _callDropSubPage{nullptr};
657
        std::function<void (ulong handle, ulong parent, int left, int top, int width, int height, const std::string& url, const std::string& user, const std::string& pw)> _callPlayVideo{nullptr};
658
        std::function<void (Button::TButton *button, Button::BITMAP_t& bm, int frame)> _callInputText{nullptr};
659
        std::function<void (Button::TButton *button, Button::BITMAP_t& bm, int frame)> _callListBox{nullptr};
660
        std::function<void (const std::string& init, const std::string& prompt, bool priv)> _callKeyboard{nullptr};
661
        std::function<void (const std::string& init, const std::string& prompt, bool priv)> _callKeypad{nullptr};
662
        std::function<void ()> _callResetKeyboard{nullptr};
663
        std::function<void ()> _callShowSetup{nullptr};
664
        std::function<void ()> _resetSurface{nullptr};
665
        std::function<void ()> _shutdown{nullptr};
666
        std::function<void (const std::string& file)> _playSound{nullptr};
667
        std::function<void ()> _stopSound{nullptr};
668
        std::function<void (bool state)> _muteSound{nullptr};
669
        std::function<void (int volume)> _setVolume{nullptr};
670
        std::function<void (const std::string& str)> _sendVirtualKeys{nullptr};
671
        std::function<void (bool state)> _showPhoneDialog{nullptr};
672
        std::function<void (const std::string& number)> _setPhoneNumber{nullptr};
673
        std::function<void (const std::string& msg)> _setPhoneStatus{nullptr};
674
        std::function<void (int state, int id)> _setPhoneState{nullptr};
675
        std::function<void ()> _repaintWindows{nullptr};
676
        std::function<void (uint handle)> _toFront{nullptr};
677
        std::function<void (int width, int height)> _setMainWindowSize{nullptr};
678
        std::function<void (const std::string& file, size_t size)> _downloadSurface{nullptr};
679
        std::function<void (const std::string& msg, const std::string& title)> _displayMessage{nullptr};
680
        std::function<void (ulong handle, const std::string& msg, const std::string& title, int x, int y)> _askPassword{nullptr};
681
        std::function<void (ulong handle, const std::string& path, const std::string& extension, const std::string& suffix)> _fileDialog{nullptr};
682
        std::function<void (const std::string& text)> _startWait{nullptr};
683
        std::function<void ()> _stopWait{nullptr};
684
        std::function<void (ulong handle)> _pageFinished{nullptr};
685
        std::function<void (ulong handle, ulong parent, bool vertical, TBitmap buffer, int width, int height, int left, int top, int space, TColor::COLOR_T fillColor)> _displayViewButton{nullptr};
686
        std::function<void (Button::TButton& button, unsigned char *buffer, int pixline)> _addViewButtonItem{nullptr};
687
        std::function<void (ulong handle, ulong parent, TBitmap buffer, TColor::COLOR_T fillColor)> _updateViewButton{nullptr};
688
        std::function<void (ulong parent, std::vector<PGSUBVIEWITEM_T> items)> _addViewButtonItems{nullptr};
689
        std::function<void (PGSUBVIEWITEM_T& item, ulong parent)> _updateViewButtonItem{nullptr};
690
        std::function<void (ulong handle, ulong parent, int position, int timer)> _showSubViewItem{nullptr};
691
        std::function<void (ulong handle, ulong parent, int position, int timer)> _toggleSubViewItem{nullptr};
692
        std::function<void (ulong handle)> _hideAllSubViewItems{nullptr};
693
        std::function<void (ulong handle, ulong parent)> _hideSubViewItem{nullptr};
694
        std::function<void (ulong handle, int padding)> _setSubViewPadding{nullptr};
458 andreas 695
        std::function<void (INTERCOM_t ic)> _initializeIntercom{nullptr};
696
        std::function<void ()> _intercomStart{nullptr};
697
        std::function<void ()> _intercomStop{nullptr};
698
        std::function<void (int level)> _intercomSpkLevel{nullptr};
699
        std::function<void (int level)> _intercomMicLevel{nullptr};
700
        std::function<void (bool mute)> _intercomMute{nullptr};
446 andreas 701
#if defined(Q_OS_ANDROID) || defined(Q_OS_IOS)
702
        std::function<void (int orientation)> _onOrientationChange{nullptr};
703
        std::function<void (const std::string& oldNetlinx, int oldPort, int oldChannelID, const std::string& oldSurface, bool oldToolbarSuppress, bool oldToolbarForce)> _onSettingsChanged{nullptr};
704
#endif
705
        typedef struct _FTP_SURFACE_t
706
        {
707
            std::string file;
708
            size_t size{0};
709
        }_FTP_SURFACE_t;
710
 
711
        typedef enum _EVENT_TYPE
712
        {
713
            _EVENT_MOUSE_CLICK,
714
            _EVENT_MOUSE_MOVE
715
        }_EVENT_TYPE;
716
 
717
        typedef struct _CLICK_QUEUE_t
718
        {
719
            bool coords{false};
720
            ulong handle{0};
721
            bool pressed{false};
722
            int x{0};
723
            int y{0};
724
            _EVENT_TYPE eventType{_EVENT_MOUSE_CLICK};
725
        }_CLICK_QUEUE_t;
726
 
727
        /**
728
         * @brief doOverlap checks for overlapping objects
729
         *
730
         * The function checks whether some objects on the surface overlap or
731
         * not. If they do it returns TRUE.
732
         * This is used for images where we should check for a transparent
733
         * pixel.
734
         *
735
         * @param r1    The rectangular of the first object
736
         * @param r2    The rectangular of the second object
737
         * @return If the objects \p r1 and \p r2 overlap at least partialy,
738
         * TRUE is returned. Otherwise FALSE.
739
         */
740
        bool doOverlap(RECT_T r1, RECT_T r2);
741
        /**
742
         * The following function is used internaly. It searches in the map
743
         * table for the button corresponding to the port and channel number
744
         * and puts the result into a chain of buttons. This chain is returned.
745
         *
746
         * If there are some pages not yet in memory, they will be created just
747
         * to be able to set the button(s).
748
         */
749
        std::vector<Button::TButton *> collectButtons(std::vector<TMap::MAP_T>& map);
750
        /**
751
         * This internal function frees and destroys all settings, loaded pages
752
         * and sub pages as well as all buttons ens elements belonging to this
753
         * pages. Wehen the function is finished, the state is the same as it
754
         * was immediately at startup.
755
         * This method is called when a filetransfer starts. It is necessary to
756
         * start all over and read in the changed pages.
757
         *
758
         * @return Returns TRUE on success. Else it returns FALSE and the error
759
         * flag is set.
760
         */
761
        bool destroyAll();
762
 
763
        bool overlap(int x1, int y1, int w1, int h1, int x2, int y2, int w2, int h2);
764
        TPage *loadPage(PAGELIST_T& pl, bool *refresh=nullptr);
765
        void setButtonCallbacks(Button::TButton *bt);
766
        bool sendCustomEvent(int value1, int value2, int value3, const std::string& msg, int evType, int cp, int cn);
767
        void reloadSystemPage(TPage *page);
768
        bool _setPageDo(int pageID, const std::string& name, bool forget);
769
        void runClickQueue();
770
        void runUpdateSubViewItem();
771
        void _mouseEvent(int x, int y, bool pressed);
772
        void _mouseEvent(ulong handle, bool pressed);
773
        void _updateSubViewItem(Button::TButton *bt);
774
        void _mouseMoveEvent(int x, int y);
775
#ifndef _NOSIP_
776
        std::string sipStateToString(TSIPClient::SIP_STATE_t s);
777
#endif
778
        // List of command functions
779
        void doFTR(int port, std::vector<int>&, std::vector<std::string>& pars);
780
        void doLEVON(int, std::vector<int>&, std::vector<std::string>&);
781
        void doLEVOF(int, std::vector<int>&, std::vector<std::string>&);
782
        void doRXON(int, std::vector<int>&, std::vector<std::string>&);
783
        void doRXOF(int, std::vector<int>&, std::vector<std::string>&);
784
 
785
        void doON(int port, std::vector<int>& channels, std::vector<std::string>& pars);
786
        void doOFF(int port, std::vector<int>& channels, std::vector<std::string>& pars);
787
        void doLEVEL(int port, std::vector<int>& channels, std::vector<std::string>& pars);
788
        void doBLINK(int port, std::vector<int>& channels, std::vector<std::string>& pars);
789
        void doVER(int port, std::vector<int>& channels, std::vector<std::string>& pars);
790
#ifndef _NOSIP_
791
        void doWCN(int port, std::vector<int>& channels, std::vector<std::string>& pars);
792
#endif
793
        void doAFP(int port, std::vector<int>& channels, std::vector<std::string>& pars);
794
        void doAPG(int port, std::vector<int>& channels, std::vector<std::string>& pars);
795
        void doCPG(int port, std::vector<int>& channels, std::vector<std::string>& pars);
796
        void doDPG(int port, std::vector<int>& channels, std::vector<std::string>& pars);
797
        void doPHE(int port, std::vector<int>& channels, std::vector<std::string>& pars);
798
        void doPHP(int port, std::vector<int>& channels, std::vector<std::string>& pars);
799
        void doPHT(int port, std::vector<int>& channels, std::vector<std::string>& pars);
800
        void doPPA(int port, std::vector<int>& channels, std::vector<std::string>& pars);
801
        void doPPF(int port, std::vector<int>& channels, std::vector<std::string>& pars);
802
        void doPPG(int port, std::vector<int>& channels, std::vector<std::string>& pars);
803
        void doPPK(int port, std::vector<int>& channels, std::vector<std::string>& pars);
804
        void doPPM(int port, std::vector<int>& channels, std::vector<std::string>& pars);
805
        void doPPN(int port, std::vector<int>& channels, std::vector<std::string>& pars);
806
        void doPPT(int port, std::vector<int>& channels, std::vector<std::string>& pars);
807
        void doPPX(int port, std::vector<int>& channels, std::vector<std::string>& pars);
808
        void doPSE(int port, std::vector<int>& channels, std::vector<std::string>& pars);
809
        void doPSP(int port, std::vector<int>& channels, std::vector<std::string>& pars);
810
        void doPST(int port, std::vector<int>& channels, std::vector<std::string>& pars);
811
        void doPAGE(int port, std::vector<int>& channels, std::vector<std::string>& pars);
812
 
813
        void doANI(int port, std::vector<int>& channels, std::vector<std::string>& pars);
814
        void doAPF(int port, std::vector<int>& channels, std::vector<std::string>& pars);
815
        void doBAT(int port, std::vector<int>& channels, std::vector<std::string>& pars);
816
        void doBAU(int port, std::vector<int>& channels, std::vector<std::string>& pars);
817
        void doBCB(int port, std::vector<int>& channels, std::vector<std::string>& pars);
818
        void getBCB(int port, std::vector<int>& channels, std::vector<std::string>& pars);
819
        void doBCF(int port, std::vector<int>& channels, std::vector<std::string>& pars);
820
        void getBCF(int port, std::vector<int>& channels, std::vector<std::string>& pars);
821
        void doBCT(int port, std::vector<int>& channels, std::vector<std::string>& pars);
822
        void getBCT(int port, std::vector<int>& channels, std::vector<std::string>& pars);
823
        void doBDO(int port, std::vector<int>& channels, std::vector<std::string>& pars);
824
        void doBFB(int port, std::vector<int>& channels, std::vector<std::string>& pars);
825
        void doBIM(int port, std::vector<int>& channels, std::vector<std::string>& pars);
826
        void doBMC(int port, std::vector<int>& channels, std::vector<std::string>& pars);
827
        void doBMF(int port, std::vector<int>& channels, std::vector<std::string>& pars);
828
        void doBML(int port, std::vector<int>& channels, std::vector<std::string>& pars);
829
        void doBMP(int port, std::vector<int>& channels, std::vector<std::string>& pars);
830
        void getBMP(int port, std::vector<int>& channels, std::vector<std::string>& pars);
831
        void doBOP(int port, std::vector<int>& channels, std::vector<std::string>& pars);
832
        void getBOP(int port, std::vector<int>& channels, std::vector<std::string>& pars);
833
        void doBOR(int port, std::vector<int>& channels, std::vector<std::string>& pars);
834
        void doBOS(int port, std::vector<int>& channels, std::vector<std::string>& pars);
835
        void doBRD(int port, std::vector<int>& channels, std::vector<std::string>& pars);
836
        void getBRD(int port, std::vector<int>& channels, std::vector<std::string>& pars);
837
        void doBSP(int port, std::vector<int>& channels, std::vector<std::string>& pars);
838
        void doBSM(int port, std::vector<int>& channels, std::vector<std::string>& pars);
839
        void doBSO(int port, std::vector<int>& channels, std::vector<std::string>& pars);
840
        void doBWW(int port, std::vector<int>& channels, std::vector<std::string>& pars);
841
        void getBWW(int port, std::vector<int>& channels, std::vector<std::string>& pars);
842
        void doCPF(int port, std::vector<int>& channels, std::vector<std::string>& pars);
843
        void doDPF(int port, std::vector<int>& channels, std::vector<std::string>& pars);
844
        void doENA(int port, std::vector<int>& channels, std::vector<std::string>& pars);
845
        void doFON(int port, std::vector<int>& channels, std::vector<std::string>& pars);
846
        void getFON(int port, std::vector<int>& channels, std::vector<std::string>& pars);
847
        void doGDI(int port, std::vector<int>& channels, std::vector<std::string>& pars);
848
        void doGIV(int port, std::vector<int>& channels, std::vector<std::string>& pars);
849
        void doGLH(int port, std::vector<int>& channels, std::vector<std::string>& pars);
850
        void doGLL(int port, std::vector<int>& channels, std::vector<std::string>& pars);
851
        void doGSC(int port, std::vector<int>& channels, std::vector<std::string>& pars);
852
        void doGRD(int port, std::vector<int>& channels, std::vector<std::string>& pars);
853
        void doGRU(int port, std::vector<int>& channels, std::vector<std::string>& pars);
854
        void doGSN(int port, std::vector<int>& channels, std::vector<std::string>& pars);
855
        void doICO(int port, std::vector<int>& channels, std::vector<std::string>& pars);
856
        void getICO(int port, std::vector<int>& channels, std::vector<std::string>& pars);
857
        void doJSB(int port, std::vector<int>& channels, std::vector<std::string>& pars);
858
        void getJSB(int port, std::vector<int>& channels, std::vector<std::string>& pars);
859
        void doJSI(int port, std::vector<int>& channels, std::vector<std::string>& pars);
860
        void getJSI(int port, std::vector<int>& channels, std::vector<std::string>& pars);
861
        void doJST(int port, std::vector<int>& channels, std::vector<std::string>& pars);
862
        void getJST(int port, std::vector<int>& channels, std::vector<std::string>& pars);
863
        void doMSP(int port, std::vector<int>& channels, std::vector<std::string>& pars);
864
        void doSHO(int port, std::vector<int>& channels, std::vector<std::string>& pars);
865
        void doTEC(int port, std::vector<int>& channels, std::vector<std::string>& pars);
866
        void getTEC(int port, std::vector<int>& channels, std::vector<std::string>& pars);
867
        void doTEF(int port, std::vector<int>& channels, std::vector<std::string>& pars);
868
        void getTEF(int port, std::vector<int>& channels, std::vector<std::string>& pars);
869
        void doTXT(int port, std::vector<int>& channels, std::vector<std::string>& pars);
870
        void getTXT(int port, std::vector<int>& channels, std::vector<std::string>& pars);
871
        void doUNI(int port, std::vector<int>& channels, std::vector<std::string>& pars);
872
        void doUTF(int port, std::vector<int>& channels, std::vector<std::string>& pars);
873
        void doVTP(int port, std::vector<int>& channels, std::vector<std::string>& pars);
874
 
875
        void doKPS(int port, std::vector<int>& channels, std::vector<std::string>& pars);
876
        void doVKS(int port, std::vector<int>& channels, std::vector<std::string>& pars);
877
 
878
        void doAPWD(int port, std::vector<int>& channels, std::vector<std::string>& pars);
879
        void doPWD(int port, std::vector<int>& channels, std::vector<std::string>& pars);
880
 
881
        void doBBR(int port, std::vector<int>& channels, std::vector<std::string>& pars);
882
        void doRAF(int port, std::vector<int>& channels, std::vector<std::string>& pars);
883
        void doRFR(int port, std::vector<int>& channels, std::vector<std::string>& pars);
884
        void doRMF(int port, std::vector<int>& channels, std::vector<std::string>& pars);
885
        void doRSR(int port, std::vector<int>& channels, std::vector<std::string>& pars);
886
 
887
        void doAKB(int port, std::vector<int>& channels, std::vector<std::string>& pars);
888
        void doAKEYB(int port, std::vector<int>& channels, std::vector<std::string>& pars);
889
        void doAKP(int port, std::vector<int>& channels, std::vector<std::string>& pars);
890
        void doAKEYP(int port, std::vector<int>& channels, std::vector<std::string>& pars);
891
        void doAKEYR(int port, std::vector<int>& channels, std::vector<std::string>& pars);
892
        void doAKR(int port, std::vector<int>& channels, std::vector<std::string>& pars);
893
        void doABEEP(int port, std::vector<int>& channels, std::vector<std::string>& pars);
894
        void doADBEEP(int port, std::vector<int>& channels, std::vector<std::string>& pars);
895
        void doBEEP(int port, std::vector<int>& channels, std::vector<std::string>& pars);
896
        void doDBEEP(int port, std::vector<int>& channels, std::vector<std::string>& pars);
897
        void doEKP(int port, std::vector<int>& channels, std::vector<std::string>& pars);
898
        void doPKB(int port, std::vector<int>& channels, std::vector<std::string>& pars);
899
        void doPKP(int port, std::vector<int>& channels, std::vector<std::string>& pars);
900
        void doRPP(int port, std::vector<int>& channels, std::vector<std::string>& pars);
901
        void doSetup(int port, std::vector<int>& channels, std::vector<std::string>& pars);
902
        void doShutdown(int port, std::vector<int>& channels, std::vector<std::string>& pars);
903
        void doSOU(int port, std::vector<int>& channels, std::vector<std::string>& pars);
904
        void doMUT(int port, std::vector<int>& channels, std::vector<std::string>& pars);
905
        void doTKP(int port, std::vector<int>& channels, std::vector<std::string>& pars);
906
        void doVKB(int port, std::vector<int>& channels, std::vector<std::string>& pars);
907
 
908
        void doLPB(int port, std::vector<int>& channels, std::vector<std::string>& pars);
909
        void doLPC(int port, std::vector<int>& channels, std::vector<std::string>& pars);
910
        void doLPR(int port, std::vector<int>& channels, std::vector<std::string>& pars);
911
        void doLPS(int port, std::vector<int>& channels, std::vector<std::string>& pars);
912
 
457 andreas 913
        void getMODEL(int port, std::vector<int>& channels, std::vector<std::string>& pars);
914
        void doICS(int port, std::vector<int>& channels, std::vector<std::string>& pars);
915
        void doICE(int port, std::vector<int>& channels, std::vector<std::string>& pars);
916
        void doICM(int port, std::vector<int>& channels, std::vector<std::string>& pars);
917
 
446 andreas 918
#ifndef _NOSIP_
919
        void doPHN(int port, std::vector<int>& channels, std::vector<std::string>& pars);
920
        void getPHN(int port, std::vector<int>& channels, std::vector<std::string>& pars);
921
#endif
922
        // Commands for subviews (G4/G5)
923
        void doSHA(int port, std::vector<int>& channels, std::vector<std::string>& pars);
924
        void doSHD(int port, std::vector<int>& channels, std::vector<std::string>& pars);
925
        void doSPD(int port, std::vector<int>& channels, std::vector<std::string>& pars);
926
        void doSSH(int port, std::vector<int>& channels, std::vector<std::string>& pars);
927
        void doSTG(int port, std::vector<int>& channels, std::vector<std::string>& pars);
928
 
929
        // Commands for ListView (G5)
930
        void doLVD(int port, std::vector<int>& channels, std::vector<std::string>& pars);
931
        void doLVE(int port, std::vector<int>& channels, std::vector<std::string>& pars);
932
        void doLVF(int port, std::vector<int>& channels, std::vector<std::string>& pars);
933
        void doLVL(int port, std::vector<int>& channels, std::vector<std::string>& pars);
934
        void doLVM(int port, std::vector<int>& channels, std::vector<std::string>& pars);
935
        void doLVN(int port, std::vector<int>& channels, std::vector<std::string>& pars);
936
        void doLVR(int port, std::vector<int>& channels, std::vector<std::string>& pars);
937
        void doLVS(int port, std::vector<int>& channels, std::vector<std::string>& pars);
938
        // Commands inherited from TPControl (Touch Panel Control)
939
        void doTPCCMD(int port, std::vector<int>& channels, std::vector<std::string>& pars);
940
        void doTPCACC(int port, std::vector<int>& channels, std::vector<std::string>& pars);
941
#ifndef _NOSIP_
942
        void doTPCSIP(int port, std::vector<int>& channels, std::vector<std::string>& pars);
943
#endif
944
        std::mutex surface_mutex;
945
        std::mutex click_mutex;
946
        std::mutex updview_mutex;
947
 
948
        bool mLevelSend{false};                         // TRUE = Level changes are send to the master
949
        bool mRxOn{false};                              // TRUE = String changes are send to master
950
        int mActualPage{0};                             // The number of the actual visible page
951
        int mPreviousPage{0};                           // The number of the previous page
952
        int mLastSubPage{0};                            // The last sorted subpage accessed
953
        int mSavedPage{0};                              // The number of the last normal page. This is set immediately before a setup page is shown
954
        int mFirstLeftPixel{0};                         // Pixels to add to left (x) mouse coordinate
955
        int mFirstTopPixel{0};                          // Pixels to add to top (y) mouse position
956
        std::string mActualGroupName;                   // The name of the actual group
957
        TSubPage *mActualGroupPage{nullptr};            // Pointer to subpage of a group which is visible
958
 
959
        amx::TAmxNet *mAmxNet{nullptr};                 // Pointer to class TAmxNet; Handles the communication with the controller
960
        TPageList *mPageList{nullptr};                  // List of available pages and subpages
961
        PCHAIN_T *mPchain{nullptr};                     // Pointer to chain of pages in memory
962
        SPCHAIN_T *mSPchain{nullptr};                   // Pointer to chain of subpages in memory for the actual page
963
        TSettings *mTSettings{nullptr};                 // Pointer to basic settings for the panel
964
        TPalette *mPalette{nullptr};                    // Pointer to the color handler
965
        TFont *mFonts{nullptr};                         // Pointer to the font handler
966
        TExternal *mExternal{nullptr};                  // Pointer to the external buttons (if any)
486 andreas 967
        TApps *mApps{nullptr};                          // Pointer to external apps for Android (TP5)
446 andreas 968
        TSystemDraw *mSystemDraw{nullptr};              // A pointer to the (optional) system resources
969
        std::thread mThreadAmxNet;                      // The thread handle to the controler handler
970
        TVector<amx::ANET_COMMAND> mCommands;           // Command queue of commands received from controller
971
        std::string mCmdBuffer;                         // Internal used buffer for commands who need more than one network package
972
        std::string mAkbText;                           // This is the text for the virtual keyboard (@AKB)
973
        std::string mAkpText;                           // This is the text for the virtual keyad (@AKP)
974
        bool mPassThrough{false};                       // Can ve set to true with the command ^KPS
975
        bool mInformOrientation{false};                 // TRUE = The actual screen orientation is reported to the controller if it change.
976
        int mOrientation{0};                            // Contains the actual orientation.
977
        int mLastPagePush{0};                           // The number of the last page received a push (key press / mouse hit)
978
        double mDPI{96.0};                              // DPI (Dots Per Inch) of the primary display.
979
        std::atomic<bool> cmdLoop_busy{false};          // As long as this is true the command loop thread is active
980
        std::thread mThreadCommand;                     // Thread handle for command loop thread.
981
        std::vector<int> mSavedSubpages;                // When setup pages are called this contains the actual open subpages
982
        std::vector<_FTP_SURFACE_t> mFtpSurface;        // Contains a list of TP4 surface files gained from a NetLinx.
983
        std::atomic<bool> mClickQueueRun{false};        // TRUE = The click queue thread is running. FALSE: the thread should stop or is not running.
984
        std::vector<_CLICK_QUEUE_t> mClickQueue;        // A queue holding click requests. Needed to serialize the clicks.
985
        std::vector<Button::TButton *> mUpdateViews;    // A queue for the method "updateSubViewItem()"
986
        bool mUpdateViewsRun{false};                    // TRUE = The thread for the queue mUpdateViews is running
987
        std::vector<TButtonStates *> mButtonStates;       // Holds the states for each button
988
        // SIP
989
#ifndef _NOSIP_
990
        bool mPHNautoanswer{false};                     // The state of the SIP autoanswer
991
        TSIPClient *mSIPClient{nullptr};                // Includes the SIP client
992
#endif
993
#ifdef _SCALE_SKIA_
994
        double mScaleFactor{1.0};                       // The scale factor to zoom or shrink all components
995
        double mScaleFactorWidth{1.0};                  // The individual scale factor for the width
996
        double mScaleFactorHeight{1.0};                 // The individual scale factor for the height
997
 
998
        double mScaleSystem{1.0};                       // The scale factor for the system setup pages
999
        double mScaleSystemWidth{1.0};                  // The width scale factor for the system setup pages
1000
        double mScaleSystemHeight{1.0};                 // The height scale factor for the system setup pages
1001
#endif
1002
#if defined(Q_OS_ANDROID) || defined(Q_OS_IOS)
1003
        int mNetState{0};                               // On Android and IOS remembers the type of connection to the network (cell or wifi)
1004
#endif
1005
        std::map<int, std::function<void (int level)> > mNetCalls;  // List of callbacks for the network state multistate bargraph
1006
#ifdef Q_OS_ANDROID
1007
        std::map<int, std::function<void (int level, bool charging, int chargeType)> > mBatteryCalls;
1008
#endif
1009
#ifdef Q_OS_IOS
1010
        std::map<int, std::function<void (int level, int state)> > mBatteryCalls;
1011
        int mLastBatteryLevel{0};
1012
        int mLastBatteryState{0};
1013
#endif
1014
};
1015
 
1016
#ifdef __ANDROID__
1017
extern "C" {
1018
    JNIEXPORT void JNICALL Java_org_qtproject_theosys_NetworkStatus_informTPanelNetwork(JNIEnv */*env*/, jclass /*clazz*/, jboolean conn, jint level, jint type);
1019
    JNIEXPORT void JNICALL Java_org_qtproject_theosys_BatteryState_informBatteryStatus(JNIEnv */*env*/, jclass /*clazz*/, jint level, jboolean charge, jint chargeType);
1020
    JNIEXPORT void JNICALL Java_org_qtproject_theosys_PhoneCallState_informPhoneState(JNIEnv *env, jclass cl, jboolean call, jstring pnumber);
1021
    JNIEXPORT void JNICALL Java_org_qtproject_theosys_Logger_logger(JNIEnv *env, jclass cl, jint mode, jstring msg);
1022
    JNIEXPORT void JNICALL Java_org_qtproject_theosys_Orientation_informTPanelOrientation(JNIEnv */*env*/, jclass /*clazz*/, jint orientation);
1023
    // Settings
1024
    JNIEXPORT void JNICALL Java_org_qtproject_theosys_SettingsActivity_setNetlinxIp(JNIEnv *env, jclass clazz, jstring ip);
1025
    JNIEXPORT void JNICALL Java_org_qtproject_theosys_SettingsActivity_setNetlinxPort(JNIEnv *env, jclass clazz, jint port);
1026
    JNIEXPORT void JNICALL Java_org_qtproject_theosys_SettingsActivity_setNetlinxChannel(JNIEnv *env, jclass clazz, jint channel);
1027
    JNIEXPORT void JNICALL Java_org_qtproject_theosys_SettingsActivity_setNetlinxType(JNIEnv *env, jclass clazz, jstring type);
1028
    JNIEXPORT void JNICALL Java_org_qtproject_theosys_SettingsActivity_setNetlinxFtpUser(JNIEnv *env, jclass clazz, jstring user);
1029
    JNIEXPORT void JNICALL Java_org_qtproject_theosys_SettingsActivity_setNetlinxFtpPassword(JNIEnv *env, jclass clazz, jstring pw);
1030
    JNIEXPORT void JNICALL Java_org_qtproject_theosys_SettingsActivity_setNetlinxSurface(JNIEnv *env, jclass clazz, jstring surface);
1031
    JNIEXPORT void JNICALL Java_org_qtproject_theosys_SettingsActivity_setNetlinxFtpPassive(JNIEnv *env, jclass clazz, jboolean passive);
1032
 
1033
    JNIEXPORT void JNICALL Java_org_qtproject_theosys_SettingsActivity_setViewScale(JNIEnv *env, jclass clazz, jboolean scale);
1034
    JNIEXPORT void JNICALL Java_org_qtproject_theosys_SettingsActivity_setViewToolbar(JNIEnv *env, jclass clazz, jboolean bar);
1035
    JNIEXPORT void JNICALL Java_org_qtproject_theosys_SettingsActivity_setViewToolbarForce(JNIEnv *env, jclass clazz, jboolean bar);
1036
    JNIEXPORT void JNICALL Java_org_qtproject_theosys_SettingsActivity_setViewRotation(JNIEnv *env, jclass clazz, jboolean rotate);
1037
 
1038
    JNIEXPORT void JNICALL Java_org_qtproject_theosys_SettingsActivity_setSoundSystem(JNIEnv *env, jclass clazz, jstring sound);
1039
    JNIEXPORT void JNICALL Java_org_qtproject_theosys_SettingsActivity_setSoundSingle(JNIEnv *env, jclass clazz, jstring sound);
1040
    JNIEXPORT void JNICALL Java_org_qtproject_theosys_SettingsActivity_setSoundDouble(JNIEnv *env, jclass clazz, jstring sound);
1041
    JNIEXPORT void JNICALL Java_org_qtproject_theosys_SettingsActivity_setSoundEnable(JNIEnv *env, jclass clazz, jboolean sound);
1042
    JNIEXPORT void JNICALL Java_org_qtproject_theosys_SettingsActivity_setSoundVolume(JNIEnv *env, jclass clazz, jint sound);
1043
    JNIEXPORT void JNICALL Java_org_qtproject_theosys_SettingsActivity_setSoundGaim(JNIEnv *env, jclass clazz, jint sound);
1044
 
1045
    JNIEXPORT void JNICALL Java_org_qtproject_theosys_SettingsActivity_setSipProxy(JNIEnv *env, jclass clazz, jstring sip);
1046
    JNIEXPORT void JNICALL Java_org_qtproject_theosys_SettingsActivity_setSipPort(JNIEnv *env, jclass clazz, jint sip);
1047
    JNIEXPORT void JNICALL Java_org_qtproject_theosys_SettingsActivity_setSipTlsPort(JNIEnv *env, jclass clazz, jint sip);
1048
    JNIEXPORT void JNICALL Java_org_qtproject_theosys_SettingsActivity_setSipStun(JNIEnv *env, jclass clazz, jstring sip);
1049
    JNIEXPORT void JNICALL Java_org_qtproject_theosys_SettingsActivity_setSipDomain(JNIEnv *env, jclass clazz, jstring sip);
1050
    JNIEXPORT void JNICALL Java_org_qtproject_theosys_SettingsActivity_setSipUser(JNIEnv *env, jclass clazz, jstring sip);
1051
    JNIEXPORT void JNICALL Java_org_qtproject_theosys_SettingsActivity_setSipPassword(JNIEnv *env, jclass clazz, jstring sip);
1052
    JNIEXPORT void JNICALL Java_org_qtproject_theosys_SettingsActivity_setSipIpv4(JNIEnv *env, jclass clazz, jboolean sip);
1053
    JNIEXPORT void JNICALL Java_org_qtproject_theosys_SettingsActivity_setSipIpv6(JNIEnv *env, jclass clazz, jboolean sip);
1054
    JNIEXPORT void JNICALL Java_org_qtproject_theosys_SettingsActivity_setSipEnabled(JNIEnv *env, jclass clazz, jboolean sip);
1055
    JNIEXPORT void JNICALL Java_org_qtproject_theosys_SettingsActivity_setSipIphone(JNIEnv *env, jclass clazz, jboolean sip);
1056
 
1057
    JNIEXPORT void JNICALL Java_org_qtproject_theosys_SettingsActivity_setLogInfo(JNIEnv *env, jclass clazz, jboolean log);
1058
    JNIEXPORT void JNICALL Java_org_qtproject_theosys_SettingsActivity_setLogWarning(JNIEnv *env, jclass clazz, jboolean log);
1059
    JNIEXPORT void JNICALL Java_org_qtproject_theosys_SettingsActivity_setLogError(JNIEnv *env, jclass clazz, jboolean log);
1060
    JNIEXPORT void JNICALL Java_org_qtproject_theosys_SettingsActivity_setLogTrace(JNIEnv *env, jclass clazz, jboolean log);
1061
    JNIEXPORT void JNICALL Java_org_qtproject_theosys_SettingsActivity_setLogDebug(JNIEnv *env, jclass clazz, jboolean log);
1062
    JNIEXPORT void JNICALL Java_org_qtproject_theosys_SettingsActivity_setLogProfile(JNIEnv *env, jclass clazz, jboolean log);
1063
    JNIEXPORT void JNICALL Java_org_qtproject_theosys_SettingsActivity_setLogLongFormat(JNIEnv *env, jclass clazz, jboolean log);
1064
    JNIEXPORT void JNICALL Java_org_qtproject_theosys_SettingsActivity_setLogEnableFile(JNIEnv *env, jclass clazz, jboolean log);
1065
    JNIEXPORT void JNICALL Java_org_qtproject_theosys_SettingsActivity_setLogFile(JNIEnv *env, jclass clazz, jstring log);
1066
 
1067
    JNIEXPORT void JNICALL Java_org_qtproject_theosys_SettingsActivity_setPassword1(JNIEnv *env, jclass clazz, jstring pw);
1068
    JNIEXPORT void JNICALL Java_org_qtproject_theosys_SettingsActivity_setPassword2(JNIEnv *env, jclass clazz, jstring pw);
1069
    JNIEXPORT void JNICALL Java_org_qtproject_theosys_SettingsActivity_setPassword3(JNIEnv *env, jclass clazz, jstring pw);
1070
    JNIEXPORT void JNICALL Java_org_qtproject_theosys_SettingsActivity_setPassword4(JNIEnv *env, jclass clazz, jstring pw);
1071
 
1072
    JNIEXPORT void JNICALL Java_org_qtproject_theosys_SettingsActivity_saveSettings(JNIEnv *env, jclass clazz);
1073
}
1074
#endif  // __ANDROID__
1075
 
1076
#endif