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