Subversion Repositories tpanel

Rev

Details | Last modification | View Log | RSS feed

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