Subversion Repositories tpanel

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
3 andreas 1
/*
89 andreas 2
 * Copyright (C) 2020 to 2022 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
3 andreas 27
#include "tpagelist.h"
28
#include "tpage.h"
29
#include "tsubpage.h"
30
#include "tsettings.h"
4 andreas 31
#include "tpalette.h"
7 andreas 32
#include "tbutton.h"
33
#include "tfont.h"
32 andreas 34
#include "texternal.h"
11 andreas 35
#include "tamxnet.h"
36
#include "tamxcommands.h"
73 andreas 37
#include "tsystemdraw.h"
123 andreas 38
#include "tsipclient.h"
169 andreas 39
#include "tvector.h"
3 andreas 40
 
14 andreas 41
#define REG_CMD(func, name)     registerCommand(bind(&TPageManager::func, this,std::placeholders::_1,std::placeholders::_2,std::placeholders::_3),name)
3 andreas 42
 
8 andreas 43
class TIcons;
14 andreas 44
class TPageManager;
21 andreas 45
 
46
extern bool prg_stopped;
8 andreas 47
extern TIcons *gIcons;
48
extern TPrjResources *gPrjResources;
14 andreas 49
extern TPageManager *gPageManager;
8 andreas 50
 
93 andreas 51
#ifdef __ANDROID__
52
#define NETSTATE_WIFI   1
53
#define NETSTATE_CELL   2
54
#endif
55
 
11 andreas 56
class TPageManager : public TAmxCommands
3 andreas 57
{
58
    public:
134 andreas 59
        typedef enum J_ORIENTATION
60
        {
61
            O_UNDEFINED = -1,
62
            O_LANDSCAPE = 0,
63
            O_PORTRAIT = 1,
64
            O_REVERSE_LANDSCAPE = 8,
65
            O_REVERSE_PORTRAIT = 9,
66
            O_FACE_UP = 15,
67
            O_FACE_DOWN = 16
68
        }J_ORIENTATION;
69
 
153 andreas 70
        typedef enum SWIPES
71
        {
72
            SW_UNKNOWN,
73
            SW_LEFT,
74
            SW_RIGHT,
75
            SW_UP,
76
            SW_DOWN
77
        }SWIPES;
78
 
3 andreas 79
        TPageManager();
80
        ~TPageManager();
81
 
62 andreas 82
        bool readPages();                           //!< Read all pages and subpages
83
        bool readPage(const std::string& name);     //!< Read the page with name \p name
84
        bool readPage(int ID);                      //!< Read the page with id \p ID
85
        bool readSubPage(const std::string& name);  //!< Read the subpage with name \p name
86
        bool readSubPage(int ID);                   //!< Read the subpage with ID \p ID
3 andreas 87
 
62 andreas 88
        TPageList *getPageList() { return mPageList; }      //!< Get the list of all pages
89
        TSettings *getSettings() { return mTSettings; }     //!< Get the (system) settings of the panel
3 andreas 90
 
62 andreas 91
        TPage *getActualPage();                             //!< Get the actual page
92
        int getActualPageNumber() { return mActualPage; }   //!< Get the ID of the actual page
93
        int getPreviousPageNumber() { return mPreviousPage; }   //!< Get the ID of the previous page, if there was any.
4 andreas 94
        TSubPage *getFirstSubPage();
95
        TSubPage *getNextSubPage();
154 andreas 96
        TSubPage *getPrevSubPage();
97
        TSubPage *getLastSubPage();
11 andreas 98
        TSubPage *getFirstSubPageGroup(const std::string& group);
99
        TSubPage *getNextSubPageGroup();
100
        TSubPage *getNextSubPageGroup(const std::string& group, TSubPage *pg);
101
        TSubPage *getTopPage();
4 andreas 102
 
103
        TPage *getPage(int pageID);
104
        TPage *getPage(const std::string& name);
15 andreas 105
        bool setPage(int PageID);
168 andreas 106
        bool setPage(const std::string& name, bool forget=false);
4 andreas 107
        TSubPage *getSubPage(int pageID);
108
        TSubPage *getSubPage(const std::string& name);
96 andreas 109
        TSubPage *deliverSubPage(const std::string& name, TPage **pg=nullptr);
14 andreas 110
        bool havePage(const std::string& name);
111
        bool haveSubPage(const std::string& name);
112
        bool haveSubPage(int id);
113
        bool haveSubPage(const std::string& page, const std::string& name);
114
        bool haveSubPage(const std::string& page, int id);
50 andreas 115
        TFont *getFonts() { return mFonts; }
51 andreas 116
        Button::TButton *findButton(ulong handle);
153 andreas 117
        void onSwipeEvent(SWIPES sw);
164 andreas 118
        double getDPI() { return mDPI; }
119
        void setDPI(const double dpi) { mDPI = dpi; }
4 andreas 120
 
6 andreas 121
        void registerCallbackDB(std::function<void(ulong handle, ulong parent, unsigned char *buffer, int width, int height, int pixline, int left, int top)> displayButton) { _displayButton = displayButton; }
98 andreas 122
        void registerCBsetVisible(std::function<void(ulong handle, bool state)> setVisible) { _setVisible = setVisible; }
5 andreas 123
        void registerCallbackSP(std::function<void (ulong handle, int width, int height)> setPage) { _setPage = setPage; }
41 andreas 124
        void registerCallbackSSP(std::function<void (ulong handle, int left, int top, int width, int height, ANIMATION_t animate)> setSubPage) { _setSubPage = setSubPage; }
38 andreas 125
        void registerCallbackSB(std::function<void (ulong handle, unsigned char *image, size_t size, size_t rowBytes, int width, int height, ulong color)> setBackground) {_setBackground = setBackground; }
26 andreas 126
        void deployCallbacks();
36 andreas 127
#ifdef __ANDROID__
128
        void initNetworkState();
129
        void stopNetworkState();
38 andreas 130
        void initBatteryState();
131
        void stopBatteryState();
61 andreas 132
        void initPhoneState();
36 andreas 133
        void informTPanelNetwork(jboolean conn, jint level, jint type);
38 andreas 134
        void informBatteryStatus(jint level, jboolean charging, jint chargeType);
61 andreas 135
        void informPhoneState(bool call, const std::string& pnumber);
130 andreas 136
        void initOrientation();
36 andreas 137
#endif
11 andreas 138
        void regCallDropPage(std::function<void (ulong handle)> callDropPage) { _callDropPage = callDropPage; }
139
        void regCallDropSubPage(std::function<void (ulong handle)> callDropSubPage) { _callDropSubPage = callDropSubPage; }
21 andreas 140
        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; };
52 andreas 141
        void regCallInputText(std::function<void (Button::TButton *button, Button::BITMAP_t& bm)> callInputText) { _callInputText = callInputText; }
63 andreas 142
        void regCallbackKeyboard(std::function<void (const std::string& init, const std::string& prompt, bool priv)> callKeyboard) { _callKeyboard = callKeyboard; }
143
        void regCallbackKeypad(std::function<void (const std::string& init, const std::string& prompt, bool priv)> callKeypad) { _callKeypad = callKeypad; }
144
        void regCallResetKeyboard(std::function<void ()> callResetKeyboard) { _callResetKeyboard = callResetKeyboard; }
64 andreas 145
        void regCallShowSetup(std::function<void ()> callShowSetup) { _callShowSetup = callShowSetup; }
36 andreas 146
        void regCallbackNetState(std::function<void (int level)> callNetState, ulong handle);
147
        void unregCallbackNetState(ulong handle);
38 andreas 148
        void regCallbackBatteryState(std::function<void (int level, bool charging, int chargeType)> callBatteryState, ulong handle);
149
        void unregCallbackBatteryState(ulong handle);
44 andreas 150
        void regCallbackResetSurface(std::function<void ()> resetSurface) { _resetSurface = resetSurface; }
64 andreas 151
        void regCallbackShutdown(std::function<void ()> shutdown) { _shutdown = shutdown; }
71 andreas 152
        void regCallbackPlaySound(std::function<void (const std::string& file)> playSound) { _playSound = playSound; }
141 andreas 153
        void regCallbackStopSound(std::function<void ()> stopSound) { _stopSound = stopSound; }
154
        void regCallbackMuteSound(std::function<void (bool state)> muteSound) { _muteSound = muteSound; }
111 andreas 155
        void regSendVirtualKeys(std::function<void (const std::string& str)> sendVirtualKeys) { _sendVirtualKeys = sendVirtualKeys; }
140 andreas 156
        void regShowPhoneDialog(std::function<void (bool state)> showPhoneDialog) { _showPhoneDialog = showPhoneDialog; }
157
        void regSetPhoneNumber(std::function<void (const std::string& number)> setPhoneNumber) { _setPhoneNumber = setPhoneNumber; }
158
        void regSetPhoneStatus(std::function<void (const std::string& msg)> setPhoneStatus) { _setPhoneStatus = setPhoneStatus; }
159
        void regSetPhoneState(std::function<void (int state, int id)> setPhoneState) { _setPhoneState = setPhoneState; }
130 andreas 160
#ifdef __ANDROID__
161
        void regOnOrientationChange(std::function<void (int orientation)> orientationChange) { _onOrientationChange = orientationChange; }
162
#endif
142 andreas 163
        void regRepaintWindows(std::function<void ()> repaintWindows) { _repaintWindows = repaintWindows; }
151 andreas 164
        void regToFront(std::function<void (ulong handle)> toFront) { _toFront = toFront; }
142 andreas 165
 
11 andreas 166
        /**
167
         * The following function must be called to start non graphics part
168
         * of the panel simulator. If everything worked well, it returns TRUE.
169
         * otherwise a FALSE is returned and the program should be terminated.
170
         */
5 andreas 171
        bool run();
11 andreas 172
        /**
173
         * Set an X value to add to the coordinated reported by the mouse catch
174
         * event. In case the X coordinate reported by the event is not the real
175
         * X coordinate, it's possible to set an X coordinate to translate the
176
         * internal used coordinates.
177
         *
14 andreas 178
         * @param x
179
         * The left most pixel which correspond to X = 0
11 andreas 180
         */
10 andreas 181
        void setFirstLeftPixel(int x) { mFirstLeftPixel = x; }
11 andreas 182
        /**
183
         * Set an Y value to add to the coordinated reported by the mouse catch
184
         * event. In case the Y coordinate reported by the event is not the real
185
         * Y coordinate, it's possible to set an Y coordinate to translate the
186
         * internal used coordinates.
187
         *
14 andreas 188
         * @param y
43 andreas 189
         * The top most pixel which correspond to Y = 0
11 andreas 190
         */
10 andreas 191
        void setFirstTopPixel(int y) { mFirstTopPixel = y; }
11 andreas 192
        /**
193
         * This function must be called from a GUI whenever the left mouse
194
         * button was pressed or released. Also if there was a touch event
14 andreas 195
         * this function must be called in the same way. It's up to any GUI
11 andreas 196
         * to handle the mouse and or touch events.
197
         *
14 andreas 198
         * @param x
199
         * the X coordinate of the mouse/touch event
200
         *
201
         * @param y
202
         * the y coordinate if the mouse/touch event
203
         *
204
         * @return
11 andreas 205
         * pressed TRUE = button was pressed; FALSE = button was released
206
         */
10 andreas 207
        void mouseEvent(int x, int y, bool pressed);
51 andreas 208
        /**
209
         * Searches for a button with the handle \p handle and determines all
210
         * buttons with the same port and channel. Then it sets \p txt to all
211
         * found buttons.
212
         *
213
         * @param handle    The handle of a button.
214
         * @param txt       The text usualy comming from an input line.
215
         */
216
        void setTextToButton(ulong handle, const std::string& txt);
217
        /**
218
         * Iterates through all active subpages of the active page and drops
219
         * them.
220
         */
14 andreas 221
        void dropAllSubPages();
51 andreas 222
        /**
223
         * Closes all subpages in the group \p group.
224
         *
225
         * @param group The name of the group.
226
         */
14 andreas 227
        void closeGroup(const std::string& group);
51 andreas 228
        /**
229
         * Displays a the subpage \p name. If the subpage is part of a group
230
         * the open subpage in the group is closed, if there was one open. Then
231
         * the subpage is displayed. If the subpage is not already in the
232
         * internal buffer it's configuration file is read and the page is
233
         * created.
234
         *
235
         * @param name  The name of the subpage to display.
236
         */
14 andreas 237
        void showSubPage(const std::string& name);
51 andreas 238
        /**
239
         * Hides the subpage \p name.
240
         *
241
         * @param name  The name of the subpage to hide.
242
         */
14 andreas 243
        void hideSubPage(const std::string& name);
43 andreas 244
#ifdef _SCALE_SKIA_
24 andreas 245
        void setScaleFactor(double scale) { mScaleFactor = scale; }
246
        double getScaleFactor() { return mScaleFactor; }
31 andreas 247
        void setScaleFactorWidth(double scale) { mScaleFactorWidth = scale; }
248
        double getScaleFactorWidth() { return mScaleFactorWidth; }
249
        void setScaleFactorHeight(double scale) { mScaleFactorHeight = scale; }
250
        double getScaleFactorHeight() { return mScaleFactorHeight; }
43 andreas 251
#endif
62 andreas 252
        /**
253
         * This method handles some external buttons. Some original panels from
254
         * AMX have external hard buttons. TPanel simulates some of them like
255
         * the arrow keys, enter button and volume. The graphical surface may
256
         * display a toolbar on the right side (only if there is enough space
257
         * left) which offers this buttons. When such a button was pressed, this
258
         * method is called to send them to the controller.
259
         *
260
         * @param bt        The button who was pressed
261
         * @param checked   On button press this is TRUE, and on release it is FALSE.
262
         */
33 andreas 263
        void externalButton(extButtons_t bt, bool checked);
62 andreas 264
        void sendKeyboard(const std::string& text);
265
        void sendKeypad(const std::string& text);
266
        void sendString(uint handle, const std::string& text);
134 andreas 267
        void sendGlobalString(const std::string& text);
123 andreas 268
        void sendPHNcommand(const std::string& cmd);
111 andreas 269
        void sendKeyStroke(char key);
147 andreas 270
        void sendCommandString(int port, const std::string& cmd);
62 andreas 271
        /**
272
         * This starts the communication with the AMX controller. The method
273
         * registers the callbacks and starts a thread. This thread runs as
274
         * long as a valid communication is possible or until the communication
275
         * end by a command.
276
         */
38 andreas 277
        void startUp();
147 andreas 278
        /**
169 andreas 279
         * This starts a thread running the command loop. Each event from the
280
         * Netlinx is entered into a vector array (doCommand()) and this this
281
         * method starts the event loop as a thread running as long as this
282
         * class exists.
283
         */
284
        void runCommands();
285
        /**
286
         * This method is the thread started by the command runCommands().
287
         */
288
        void commandLoop();
289
        /**
147 andreas 290
         * Callback function for the AMX controller part. This function must
291
         * be registered to the class TAmxNet and is called from this module
292
         * every time an event occured from the controller.
293
         * This method handles the commands comming from the controller and
294
         * draws the necessary elements before they are sent to the GUI.
295
         *
296
         * @param cmd
297
         * An ANET_COMMAND structure containing the received command.
298
         */
299
        void doCommand(const amx::ANET_COMMAND& cmd);
14 andreas 300
 
62 andreas 301
        // Callbacks who will be registered by the graphical surface.
26 andreas 302
        std::function<void (ulong handle, ulong parent, unsigned char *buffer, int width, int height, int pixline, int left, int top)> getCallbackDB() { return _displayButton; }
98 andreas 303
        std::function<void (ulong handle, bool state)> getVisible() { return _setVisible; };
38 andreas 304
        std::function<void (ulong handle, unsigned char *image, size_t size, size_t rowBytes, int width, int height, ulong color)> getCallbackBG() { return _setBackground; }
26 andreas 305
        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 306
        std::function<void (ulong handle, int width, int height)> getCallbackSetPage() { return _setPage; }
52 andreas 307
        std::function<void (Button::TButton *button, Button::BITMAP_t& bm)> getCallbackInputText() { return _callInputText; }
41 andreas 308
        std::function<void (ulong handle, int left, int top, int width, int height, ANIMATION_t animate)> getCallbackSetSubPage() { return _setSubPage; }
38 andreas 309
        std::function<void (ulong handle)> getCallDropPage() { return _callDropPage; }
310
        std::function<void (ulong handle)> getCallDropSubPage() { return _callDropSubPage; }
71 andreas 311
        std::function<void (const std::string& file)> getCallPlaySound() { return _playSound; }
141 andreas 312
        std::function<void ()> getCallStopSound() { return _stopSound; }
313
        std::function<void (bool state)> getCallMuteSound() { return _muteSound; }
111 andreas 314
        std::function<void (const std::string& str)> sendVirtualKeys() { return _sendVirtualKeys; }
140 andreas 315
        std::function<void (bool state)> getShowPhoneDialog() { return _showPhoneDialog; }
316
        std::function<void (const std::string& number)> getSetPhoneNumber() { return _setPhoneNumber; }
317
        std::function<void (const std::string& msg)> getSetPhoneStatus() { return _setPhoneStatus; }
318
        std::function<void (int state, int id)> getSetPhoneState() { return _setPhoneState; }
151 andreas 319
        std::function<void (ulong handle)> getToFront() { return _toFront; }
130 andreas 320
#ifdef __ANDROID__
321
        std::function<void (int orientation)> onOrientationChange() { return _onOrientationChange; }
322
#endif
142 andreas 323
        std::function<void ()> getRepaintWindows() { return _repaintWindows; }
134 andreas 324
        int getOrientation() { return mOrientation; }
325
        void setOrientation(int ori) { mOrientation = ori; }
326
        bool getInformOrientation() { return mInformOrientation; }
327
        void sendOrientation();
71 andreas 328
        bool havePlaySound() { return _playSound != nullptr; }
73 andreas 329
        TSystemDraw *getSystemDraw() { return mSystemDraw; }
89 andreas 330
        void reset();
111 andreas 331
        bool getPassThrough() { return mPassThrough; }
113 andreas 332
        bool haveSetupPage() { return _callShowSetup != nullptr; }
333
        bool haveShutdown() { return _shutdown != nullptr; }
334
        void callSetupPage() { if (_callShowSetup) _callShowSetup(); }
335
        void callShutdown() { if (_shutdown) _shutdown(); }
129 andreas 336
#ifndef _NOSIP_
123 andreas 337
        bool getPHNautoanswer() { return mPHNautoanswer; }
338
        void sendPHN(std::vector<std::string>& cmds);
141 andreas 339
        void actPHN(std::vector<std::string>& cmds);
140 andreas 340
        void phonePickup(int id);
341
        void phoneHangup(int id);
129 andreas 342
#endif
3 andreas 343
    protected:
344
        PAGELIST_T findPage(const std::string& name);
345
        PAGELIST_T findPage(int ID);
346
        SUBPAGELIST_T findSubPage(const std::string& name);
347
        SUBPAGELIST_T findSubPage(int ID);
348
 
349
        bool addPage(TPage *pg);
350
        bool addSubPage(TSubPage *pg);
11 andreas 351
        TSubPage *getCoordMatch(int x, int y);
40 andreas 352
        Button::TButton *getCoordMatchPage(int x, int y);
11 andreas 353
        void initialize();
354
        void dropAllPages();
92 andreas 355
        bool startComm();
3 andreas 356
 
357
    private:
6 andreas 358
        std::function<void (ulong handle, ulong parent, unsigned char *buffer, int width, int height, int pixline, int left, int top)> _displayButton{nullptr};
98 andreas 359
        std::function<void (ulong handle, bool state)> _setVisible{nullptr};
5 andreas 360
        std::function<void (ulong handle, int width, int height)> _setPage{nullptr};
41 andreas 361
        std::function<void (ulong handle, int left, int top, int width, int height, ANIMATION_t animate)> _setSubPage{nullptr};
38 andreas 362
        std::function<void (ulong handle, unsigned char *image, size_t size, size_t rowBytes, int width, int height, ulong color)> _setBackground{nullptr};
7 andreas 363
        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 364
        std::function<void (ulong handle)> _callDropPage{nullptr};
365
        std::function<void (ulong handle)> _callDropSubPage{nullptr};
21 andreas 366
        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};
52 andreas 367
        std::function<void (Button::TButton *button, Button::BITMAP_t& bm)> _callInputText{nullptr};
63 andreas 368
        std::function<void (const std::string& init, const std::string& prompt, bool priv)> _callKeyboard{nullptr};
369
        std::function<void (const std::string& init, const std::string& prompt, bool priv)> _callKeypad{nullptr};
370
        std::function<void ()> _callResetKeyboard{nullptr};
64 andreas 371
        std::function<void ()> _callShowSetup{nullptr};
44 andreas 372
        std::function<void ()> _resetSurface{nullptr};
64 andreas 373
        std::function<void ()> _shutdown{nullptr};
71 andreas 374
        std::function<void (const std::string& file)> _playSound{nullptr};
141 andreas 375
        std::function<void ()> _stopSound{nullptr};
376
        std::function<void (bool state)> _muteSound{nullptr};
111 andreas 377
        std::function<void (const std::string& str)> _sendVirtualKeys{nullptr};
140 andreas 378
        std::function<void (bool state)> _showPhoneDialog{nullptr};
379
        std::function<void (const std::string& number)> _setPhoneNumber{nullptr};
380
        std::function<void (const std::string& msg)> _setPhoneStatus{nullptr};
381
        std::function<void (int state, int id)> _setPhoneState{nullptr};
142 andreas 382
        std::function<void ()> _repaintWindows{nullptr};
151 andreas 383
        std::function<void (uint handle)> _toFront{nullptr};
130 andreas 384
#ifdef __ANDROID__
385
        std::function<void (int orientation)> _onOrientationChange{nullptr};
386
#endif
32 andreas 387
        /**
388
         * @brief doOverlap checks for overlapping objects
389
         *
390
         * The function checks whether some objects on the surface overlap or
391
         * not. If they do it returns TRUE.
392
         * This is used for images where we should check for a transparent
393
         * pixel.
394
         *
395
         * @param r1    The rectangular of the first object
396
         * @param r2    The rectangular of the second object
397
         * @return If the objects \p r1 and \p r2 overlap at least partialy,
398
         * TRUE is returned. Otherwise FALSE.
399
         */
11 andreas 400
        bool doOverlap(RECT_T r1, RECT_T r2);
401
        /**
14 andreas 402
         * The following function is used internaly. It searches in the map
403
         * table for the button corresponding to the port and channel number
404
         * and puts the result into a chain of buttons. This chain is returned.
405
         *
406
         * If there are some pages not yet in memory, they will be created just
407
         * to be able to set the button(s).
408
         */
409
        std::vector<Button::TButton *> collectButtons(std::vector<MAP_T>& map);
44 andreas 410
        /**
411
         * This internal function frees and destroys all settings, loaded pages
412
         * and sub pages as well as all buttons ens elements belonging to this
413
         * pages. Wehen the function is finished, the state is the same as it
414
         * was immediately at startup.
415
         * This method is called when a filetransfer starts. It is necessary to
416
         * start all over and read in the changed pages.
417
         *
418
         * @return Returns TRUE on success. Else it returns FALSE and the error
419
         * flag is set.
420
         */
421
        bool destroyAll();
150 andreas 422
        bool overlap(int x1, int y1, int w1, int h1, int x2, int y2, int w2, int h2);
15 andreas 423
        TPage *loadPage(PAGELIST_T& pl);
18 andreas 424
        void setButtonCallbacks(Button::TButton *bt);
110 andreas 425
        bool sendCustomEvent(int value1, int value2, int value3, const std::string& msg, int evType, int cp, int cn);
129 andreas 426
#ifndef _NOSIP_
127 andreas 427
        std::string sipStateToString(TSIPClient::SIP_STATE_t s);
129 andreas 428
#endif
11 andreas 429
        // List of command functions
23 andreas 430
        void doFTR(int port, std::vector<int>&, std::vector<std::string>& pars);
431
 
14 andreas 432
        void doON(int port, std::vector<int>& channels, std::vector<std::string>& pars);
433
        void doOFF(int port, std::vector<int>& channels, std::vector<std::string>& pars);
15 andreas 434
        void doLEVEL(int port, std::vector<int>& channels, std::vector<std::string>& pars);
435
        void doBLINK(int port, std::vector<int>& channels, std::vector<std::string>& pars);
127 andreas 436
        void doVER(int port, std::vector<int>& channels, std::vector<std::string>& pars);
437
        void doWCN(int port, std::vector<int>& channels, std::vector<std::string>& pars);
14 andreas 438
 
147 andreas 439
        void doAFP(int port, std::vector<int>& channels, std::vector<std::string>& pars);
11 andreas 440
        void doAPG(int port, std::vector<int>& channels, std::vector<std::string>& pars);
441
        void doCPG(int port, std::vector<int>& channels, std::vector<std::string>& pars);
442
        void doDPG(int port, std::vector<int>& channels, std::vector<std::string>& pars);
15 andreas 443
        void doPHE(int port, std::vector<int>& channels, std::vector<std::string>& pars);
444
        void doPHP(int port, std::vector<int>& channels, std::vector<std::string>& pars);
445
        void doPHT(int port, std::vector<int>& channels, std::vector<std::string>& pars);
11 andreas 446
        void doPPA(int port, std::vector<int>& channels, std::vector<std::string>& pars);
12 andreas 447
        void doPPF(int port, std::vector<int>& channels, std::vector<std::string>& pars);
448
        void doPPG(int port, std::vector<int>& channels, std::vector<std::string>& pars);
449
        void doPPK(int port, std::vector<int>& channels, std::vector<std::string>& pars);
450
        void doPPM(int port, std::vector<int>& channels, std::vector<std::string>& pars);
451
        void doPPN(int port, std::vector<int>& channels, std::vector<std::string>& pars);
15 andreas 452
        void doPPT(int port, std::vector<int>& channels, std::vector<std::string>& pars);
12 andreas 453
        void doPPX(int port, std::vector<int>& channels, std::vector<std::string>& pars);
15 andreas 454
        void doPSE(int port, std::vector<int>& channels, std::vector<std::string>& pars);
455
        void doPSP(int port, std::vector<int>& channels, std::vector<std::string>& pars);
456
        void doPST(int port, std::vector<int>& channels, std::vector<std::string>& pars);
12 andreas 457
        void doPAGE(int port, std::vector<int>& channels, std::vector<std::string>& pars);
11 andreas 458
 
38 andreas 459
        void doANI(int port, std::vector<int>& channels, std::vector<std::string>& pars);
15 andreas 460
        void doAPF(int port, std::vector<int>& channels, std::vector<std::string>& pars);
43 andreas 461
        void doBAT(int port, std::vector<int>& channels, std::vector<std::string>& pars);
60 andreas 462
        void doBAU(int port, std::vector<int>& channels, std::vector<std::string>& pars);
43 andreas 463
        void doBCB(int port, std::vector<int>& channels, std::vector<std::string>& pars);
82 andreas 464
        void getBCB(int port, std::vector<int>& channels, std::vector<std::string>& pars);
60 andreas 465
        void doBCF(int port, std::vector<int>& channels, std::vector<std::string>& pars);
82 andreas 466
        void getBCF(int port, std::vector<int>& channels, std::vector<std::string>& pars);
60 andreas 467
        void doBCT(int port, std::vector<int>& channels, std::vector<std::string>& pars);
82 andreas 468
        void getBCT(int port, std::vector<int>& channels, std::vector<std::string>& pars);
60 andreas 469
        void doBDO(int port, std::vector<int>& channels, std::vector<std::string>& pars);
470
        void doBFB(int port, std::vector<int>& channels, std::vector<std::string>& pars);
106 andreas 471
        void doBMC(int port, std::vector<int>& channels, std::vector<std::string>& pars);
149 andreas 472
        void doBMF(int port, std::vector<int>& channels, std::vector<std::string>& pars);
110 andreas 473
        void doBML(int port, std::vector<int>& channels, std::vector<std::string>& pars);
15 andreas 474
        void doBMP(int port, std::vector<int>& channels, std::vector<std::string>& pars);
82 andreas 475
        void getBMP(int port, std::vector<int>& channels, std::vector<std::string>& pars);
16 andreas 476
        void doBOP(int port, std::vector<int>& channels, std::vector<std::string>& pars);
106 andreas 477
        void getBOP(int port, std::vector<int>& channels, std::vector<std::string>& pars);
60 andreas 478
        void doBOR(int port, std::vector<int>& channels, std::vector<std::string>& pars);
107 andreas 479
        void doBOS(int port, std::vector<int>& channels, std::vector<std::string>& pars);
60 andreas 480
        void doBRD(int port, std::vector<int>& channels, std::vector<std::string>& pars);
107 andreas 481
        void getBRD(int port, std::vector<int>& channels, std::vector<std::string>& pars);
16 andreas 482
        void doBSP(int port, std::vector<int>& channels, std::vector<std::string>& pars);
107 andreas 483
        void doBSM(int port, std::vector<int>& channels, std::vector<std::string>& pars);
484
        void doBSO(int port, std::vector<int>& channels, std::vector<std::string>& pars);
16 andreas 485
        void doBWW(int port, std::vector<int>& channels, std::vector<std::string>& pars);
108 andreas 486
        void getBWW(int port, std::vector<int>& channels, std::vector<std::string>& pars);
16 andreas 487
        void doCPF(int port, std::vector<int>& channels, std::vector<std::string>& pars);
488
        void doDPF(int port, std::vector<int>& channels, std::vector<std::string>& pars);
489
        void doENA(int port, std::vector<int>& channels, std::vector<std::string>& pars);
490
        void doFON(int port, std::vector<int>& channels, std::vector<std::string>& pars);
108 andreas 491
        void getFON(int port, std::vector<int>& channels, std::vector<std::string>& pars);
60 andreas 492
        void doGLH(int port, std::vector<int>& channels, std::vector<std::string>& pars);
493
        void doGLL(int port, std::vector<int>& channels, std::vector<std::string>& pars);
108 andreas 494
        void doGSC(int port, std::vector<int>& channels, std::vector<std::string>& pars);
14 andreas 495
        void doICO(int port, std::vector<int>& channels, std::vector<std::string>& pars);
108 andreas 496
        void getICO(int port, std::vector<int>& channels, std::vector<std::string>& pars);
497
        void doJSB(int port, std::vector<int>& channels, std::vector<std::string>& pars);
498
        void getJSB(int port, std::vector<int>& channels, std::vector<std::string>& pars);
499
        void doJSI(int port, std::vector<int>& channels, std::vector<std::string>& pars);
500
        void getJSI(int port, std::vector<int>& channels, std::vector<std::string>& pars);
501
        void doJST(int port, std::vector<int>& channels, std::vector<std::string>& pars);
502
        void getJST(int port, std::vector<int>& channels, std::vector<std::string>& pars);
16 andreas 503
        void doSHO(int port, std::vector<int>& channels, std::vector<std::string>& pars);
108 andreas 504
        void doTEC(int port, std::vector<int>& channels, std::vector<std::string>& pars);
505
        void getTEC(int port, std::vector<int>& channels, std::vector<std::string>& pars);
110 andreas 506
        void doTEF(int port, std::vector<int>& channels, std::vector<std::string>& pars);
507
        void getTEF(int port, std::vector<int>& channels, std::vector<std::string>& pars);
14 andreas 508
        void doTXT(int port, std::vector<int>& channels, std::vector<std::string>& pars);
110 andreas 509
        void getTXT(int port, std::vector<int>& channels, std::vector<std::string>& pars);
104 andreas 510
        void doUNI(int port, std::vector<int>& channels, std::vector<std::string>& pars);
511
        void doUTF(int port, std::vector<int>& channels, std::vector<std::string>& pars);
148 andreas 512
        void doVTP(int port, std::vector<int>& channels, std::vector<std::string>& pars);
4 andreas 513
 
111 andreas 514
        void doKPS(int port, std::vector<int>& channels, std::vector<std::string>& pars);
515
        void doVKS(int port, std::vector<int>& channels, std::vector<std::string>& pars);
516
 
21 andreas 517
        void doBBR(int port, std::vector<int>& channels, std::vector<std::string>& pars);
97 andreas 518
        void doRAF(int port, std::vector<int>& channels, std::vector<std::string>& pars);
519
        void doRFR(int port, std::vector<int>& channels, std::vector<std::string>& pars);
21 andreas 520
        void doRMF(int port, std::vector<int>& channels, std::vector<std::string>& pars);
111 andreas 521
        void doRSR(int port, std::vector<int>& channels, std::vector<std::string>& pars);
21 andreas 522
 
62 andreas 523
        void doAKB(int port, std::vector<int>& channels, std::vector<std::string>& pars);
524
        void doAKEYB(int port, std::vector<int>& channels, std::vector<std::string>& pars);
525
        void doAKP(int port, std::vector<int>& channels, std::vector<std::string>& pars);
526
        void doAKEYP(int port, std::vector<int>& channels, std::vector<std::string>& pars);
63 andreas 527
        void doAKEYR(int port, std::vector<int>& channels, std::vector<std::string>& pars);
528
        void doAKR(int port, std::vector<int>& channels, std::vector<std::string>& pars);
108 andreas 529
        void doABEEP(int port, std::vector<int>& channels, std::vector<std::string>& pars);
530
        void doADBEEP(int port, std::vector<int>& channels, std::vector<std::string>& pars);
71 andreas 531
        void doBEEP(int port, std::vector<int>& channels, std::vector<std::string>& pars);
532
        void doDBEEP(int port, std::vector<int>& channels, std::vector<std::string>& pars);
62 andreas 533
        void doEKP(int port, std::vector<int>& channels, std::vector<std::string>& pars);
63 andreas 534
        void doPKB(int port, std::vector<int>& channels, std::vector<std::string>& pars);
535
        void doPKP(int port, std::vector<int>& channels, std::vector<std::string>& pars);
64 andreas 536
        void doSetup(int port, std::vector<int>& channels, std::vector<std::string>& pars);
537
        void doShutdown(int port, std::vector<int>& channels, std::vector<std::string>& pars);
82 andreas 538
        void doSOU(int port, std::vector<int>& channels, std::vector<std::string>& pars);
63 andreas 539
        void doTKP(int port, std::vector<int>& channels, std::vector<std::string>& pars);
540
        void doVKB(int port, std::vector<int>& channels, std::vector<std::string>& pars);
129 andreas 541
#ifndef _NOSIP_
123 andreas 542
        void doPHN(int port, std::vector<int>& channels, std::vector<std::string>& pars);
127 andreas 543
        void getPHN(int port, std::vector<int>& channels, std::vector<std::string>& pars);
129 andreas 544
#endif
134 andreas 545
        // Commands inherited from TPControl (Touch Panel Control)
546
        void doTPCCMD(int port, std::vector<int>& channels, std::vector<std::string>& pars);
547
        void doTPCACC(int port, std::vector<int>& channels, std::vector<std::string>& pars);
153 andreas 548
        void doTPCSIP(int port, std::vector<int>& channels, std::vector<std::string>& pars);
134 andreas 549
 
14 andreas 550
        int mActualPage{0};                             // The number of the actual visible page
15 andreas 551
        int mPreviousPage{0};                           // The number of the previous page
14 andreas 552
        int mFirstLeftPixel{0};                         // Pixels to add to left (x) mouse coordinate
553
        int mFirstTopPixel{0};                          // Pixels to add to top (y) mouse position
554
        std::string mActualGroupName;                   // The name of the actual group
70 andreas 555
        TSubPage *mActualGroupPage{nullptr};            // Pointer to subpage of a group which is visible
14 andreas 556
 
557
        amx::TAmxNet *mAmxNet{nullptr};                 // Pointer to class TAmxNet; Handles the communication with the controller
558
        TPageList *mPageList{nullptr};                  // List of available pages and subpages
559
        PCHAIN_T *mPchain{nullptr};                     // Pointer to chain of pages in memory
560
        SPCHAIN_T *mSPchain{nullptr};                   // Pointer to chain of subpages in memory for the actual page
561
        TSettings *mTSettings{nullptr};                 // Pointer to basic settings for the panel
562
        TPalette *mPalette{nullptr};                    // Pointer to the color handler
563
        TFont *mFonts{nullptr};                         // Pointer to the font handler
32 andreas 564
        TExternal *mExternal{nullptr};                  // Pointer to the external buttons (if any)
73 andreas 565
        TSystemDraw *mSystemDraw{nullptr};              // A pointer to the (optional) system resources
14 andreas 566
        std::thread mThreadAmxNet;                      // The thread handle to the controler handler
169 andreas 567
        TVector<amx::ANET_COMMAND> mCommands;           // Command queue of commands received from controller
568
        std::atomic<bool> mBusy{false};                 // Internal used to block the command handler
14 andreas 569
        std::string mCmdBuffer;                         // Internal used buffer for commands who need more than one network package
62 andreas 570
        std::string mAkbText;                           // This is the text for the virtual keyboard (@AKB)
73 andreas 571
        std::string mAkpText;                           // This is the text for the virtual keyad (@AKP)
111 andreas 572
        bool mPassThrough{false};                       // Can ve set to true with the command ^KPS
134 andreas 573
        bool mInformOrientation{false};                 // TRUE = The actual screen orientation is reported to the controller if it change.
574
        int mOrientation{0};                            // Contains the actual orientation.
154 andreas 575
        int mLastPagePush{0};                           // The number of the last page received a push (key press / mouse hit)
164 andreas 576
        double mDPI{96.0};                              // DPI (Dots Per Inch) of the primary display.
169 andreas 577
        std::atomic<bool> cmdLoop_busy{false};          // As long as this is true the command loop thread is active
578
        std::thread mThreadCommand;                     // Thread handle for command loop thread.
123 andreas 579
        // SIP
129 andreas 580
#ifndef _NOSIP_
123 andreas 581
        bool mPHNautoanswer{false};                     // The state of the SIP autoanswer
127 andreas 582
        TSIPClient *mSIPClient{nullptr};                // Includes the SIP client
129 andreas 583
#endif
70 andreas 584
#ifdef _SCALE_SKIA_
24 andreas 585
        double mScaleFactor{1.0};                       // The scale factor to zoom or shrink all components
31 andreas 586
        double mScaleFactorWidth{1.0};                  // The individual scale factor for the width
587
        double mScaleFactorHeight{1.0};                 // The individual scale factor for the height
43 andreas 588
#endif
93 andreas 589
#ifdef __ANDROID__
590
        int mNetState{0};                               // On Android remembers the type of connection to the network (cell or wifi)
591
#endif
36 andreas 592
        std::map<int, std::function<void (int level)> > mNetCalls;  // List of callbacks for the network state multistate bargraph
38 andreas 593
        std::map<int, std::function<void (int level, bool charging, int chargeType)> > mBatteryCalls;
3 andreas 594
};
595
 
36 andreas 596
#ifdef __ANDROID__
597
extern "C" {
598
    JNIEXPORT void JNICALL Java_org_qtproject_theosys_NetworkStatus_informTPanelNetwork(JNIEnv */*env*/, jclass /*clazz*/, jboolean conn, jint level, jint type);
38 andreas 599
    JNIEXPORT void JNICALL Java_org_qtproject_theosys_BatteryState_informBatteryStatus(JNIEnv */*env*/, jclass /*clazz*/, jint level, jboolean charge, jint chargeType);
61 andreas 600
    JNIEXPORT void JNICALL Java_org_qtproject_theosys_PhoneCallState_informPhoneState(JNIEnv *env, jclass cl, jboolean call, jstring pnumber);
601
    JNIEXPORT void JNICALL Java_org_qtproject_theosys_Logger_logger(JNIEnv *env, jclass cl, jint mode, jstring msg);
130 andreas 602
    JNIEXPORT void JNICALL Java_org_qtproject_theosys_Orientation_informTPanelOrientation(JNIEnv */*env*/, jclass /*clazz*/, jint orientation);
36 andreas 603
}
604
#endif  // __ANDROID__
605
 
3 andreas 606
#endif