X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=doc%2Fapi-ref%2Fhtml%2Fd1%2Fd27%2Fclass_event_handler.html;fp=doc%2Fapi-ref%2Fhtml%2Fd1%2Fd27%2Fclass_event_handler.html;h=e803c7525f6b2061d8862abdebcdbf1c9b74d3ae;hb=b2670af592e664ed304f7df77d84f1964f039636;hp=0000000000000000000000000000000000000000;hpb=ec044f44133cad1d12311345437b13b1a953226e;p=apps%2Fonscreenapp.git diff --git a/doc/api-ref/html/d1/d27/class_event_handler.html b/doc/api-ref/html/d1/d27/class_event_handler.html new file mode 100644 index 0000000..e803c75 --- /dev/null +++ b/doc/api-ref/html/d1/d27/class_event_handler.html @@ -0,0 +1,495 @@ + + + + + + + +OnScreenApp: EventHandler Class Reference + + + + + + + + + +
+
+ + + + + + +
+
OnScreenApp +
+
+
+ + + + + + + + +
+
+ + +
+ +
+ +
+
+
+Signals | +Public Member Functions | +Static Public Member Functions | +Static Public Attributes | +List of all members
+
+
EventHandler Class Reference
+
+
+ +

#include <eventhandler.h>

+
+Inheritance diagram for EventHandler:
+
+
+ + + +
+ + + + + + + + + + +

+Signals

void signalOnScreenMessage (QVariant display_message)
 
void signalLoader (QVariant url)
 
void signalSetClearBackgroud ()
 
void signalSetDefaultBackgroud (QVariant message)
 
+ + + + + + + + + + + + + + + + + +

+Public Member Functions

 EventHandler (QObject *parent=0)
 
 ~EventHandler ()
 
void init (int port, const char *token)
 
void setQuickWindow (QQuickWindow *qw)
 
void onRep (struct json_object *reply_contents)
 
void activateSurface (QString app)
 
void deactivateSurface (QString app)
 
Q_INVOKABLE void onScreenReply (const QString &message)
 
+ + + +

+Static Public Member Functions

static void onRep_static (struct json_object *reply_contents)
 
+ + + +

+Static Public Attributes

static void * myThis = 0
 
+

Detailed Description

+
+

Definition at line 41 of file eventhandler.h.

+

Constructor & Destructor Documentation

+ +

◆ EventHandler()

+ +
+
+ + + + + +
+ + + + + + + + +
EventHandler::EventHandler (QObject * parent = 0)
+
+explicit
+
+ +

Definition at line 32 of file eventhandler.cpp.

+
32  :
33  QObject(parent),
34  mp_hs(NULL),
35  mp_wm(NULL),
36  mp_qw(NULL)
37 {
38  m_isActive = false;
39  m_vecOSM.clear();
40 }
+
+
+ +

◆ ~EventHandler()

+ +
+
+ + + + + + + +
EventHandler::~EventHandler ()
+
+ +

Definition at line 42 of file eventhandler.cpp.

+
43 {
44  if (mp_hs != NULL) {
45  delete mp_hs;
46  }
47  if (mp_wm != NULL) {
48  delete mp_wm;
49  }
50 }
+
+
+

Member Function Documentation

+ +

◆ activateSurface()

+ +
+
+ + + + + + + + +
void EventHandler::activateSurface (QString app)
+
+ +

Definition at line 202 of file eventhandler.cpp.

+
203 {
204  HMI_DEBUG("onscreenapp", "EventHandler::activateSurface()");
205  if (m_isActive == false) {
206  m_isActive = true;
207  mp_wm->activateSurface(SCREEN_NAME);
208  }
209 
210  QString label = SCREEN_AREA + app;
211  mp_wm->activateSurface(label, SCREEN_AREA);
212 }
#define HMI_DEBUG(prefix, args,...)
Definition: hmi-debug.h:42
+
#define SCREEN_AREA
+
#define SCREEN_NAME
+
+
+
+ +

◆ deactivateSurface()

+ +
+
+ + + + + + + + +
void EventHandler::deactivateSurface (QString app)
+
+ +

Definition at line 214 of file eventhandler.cpp.

+
215 {
216  HMI_DEBUG("onscreenapp", "EventHandler::deactivateSurface()");
217 
218  for(QVector<ON_SCREEN_MESSAGE>::iterator it = m_vecOSM.begin(); it != m_vecOSM.end(); ++it) {
219  if (it->app == app) {
220  m_vecOSM.erase(it);
221  break;
222  }
223  }
224 
225  if (m_vecOSM.length() > 0) {
226  ON_SCREEN_MESSAGE osm = m_vecOSM.last();
227 
228  if (!osm.file.isEmpty()) {
229  emit this->signalLoader(osm.file);
230  emit this->signalSetClearBackgroud();
231  }
232  } else {
233  // nothing on screen
234  mp_wm->deactivateSurface(SCREEN_NAME);
235 // ??? mp_wm->deactivateSurface(SCREEN_AREA);
236  m_isActive = false;
237  }
238 }
+
#define HMI_DEBUG(prefix, args,...)
Definition: hmi-debug.h:42
+ +
void signalLoader(QVariant url)
+
void signalSetClearBackgroud()
+
#define SCREEN_NAME
+
+
+
+ +

◆ init()

+ +
+
+ + + + + + + + + + + + + + + + + + +
void EventHandler::init (int port,
const char * token 
)
+
+ +

Definition at line 52 of file eventhandler.cpp.

+
53 {
54  myThis = this;
55  mp_wm = new QLibWindowmanager();
56  mp_wm->init(port, token);
57 
58  mp_hs = new LibHomeScreen();
59  mp_hs->init(port, token);
60 
61  mp_hs->registerCallback(nullptr, EventHandler::onRep_static);
62  mp_hs->set_event_handler(LibHomeScreen::Event_OnScreenMessage, [this](json_object *object){
63  struct json_object *value;
64  json_object_object_get_ex(object, "display_message", &value);
65  const char *display_message = json_object_get_string(value);
66 
67  HMI_DEBUG("onscreenapp", "display_message = %s", display_message);
68 
69  QString data(display_message);
70  QJsonDocument doc = QJsonDocument::fromJson(data.toUtf8());
71  QJsonObject jsonObj(doc.object());
72 
74 
75  if (jsonObj.contains("app")) {
76  HMI_DEBUG("onscreenapp", "json parse. app is %s", jsonObj["app"].toString());
77  osm.app = jsonObj["app"].toString();
78  }
79 
80  if (jsonObj.contains("message")) {
81  HMI_DEBUG("onscreenapp", "json parse. message is %s", jsonObj["message"].toString());
82  osm.message = jsonObj["message"].toString();
83  }
84 
85  if (jsonObj.contains("file")) {
86  HMI_DEBUG("onscreenapp", "json parse. file is %s", jsonObj["file"].toString());
87  osm.file = jsonObj["file"].toString();
88 
89  if (osm.file.left(1) == "/") {
90  osm.file = QUrl::fromLocalFile(osm.file).toString();
91  }
92  }
93 
94  if (jsonObj.contains("mask")) {
95  HMI_DEBUG("onscreenapp", "json parse. mask is %s", jsonObj["mask"].toString());
96  osm.mask = jsonObj["mask"].toString();
97  }
98 
99  bool isNewApp = true;
100  for(QVector<ON_SCREEN_MESSAGE>::iterator it = m_vecOSM.begin(); it != m_vecOSM.end(); ++it) {
101  if (it->app == osm.app) {
102  it->message = osm.message;
103  it->file = osm.file;
104  it->mask = osm.mask;
105  isNewApp = false;
106  break;
107  }
108  }
109 
110  if (isNewApp) {
111  m_vecOSM.append(osm);
112  }
113 
114  if (osm.app == "Phone") {
115  if (osm.message == "incoming call") {
116  this->activateSurface(osm.app);
117  emit this->signalLoader(osm.file);
118  emit this->signalSetClearBackgroud();
119  }
120  else if (osm.message == "call rejected") {
121  this->deactivateSurface(osm.app);
122  }
123  }
124  else if (osm.app == "System") {
125  if (osm.message == "error") {
126  this->activateSurface(osm.app);
127  emit this->signalLoader(osm.file);
128  emit this->signalSetClearBackgroud();
129  }
130  else if (osm.message == "rejected") {
131  this->deactivateSurface(osm.app);
132  }
133  }
134 
135 // this->setWindowMask(jsonObj["mask"].toString());
136 
137 // if(strcmp(display_message, "incoming call") == 0){
138 // this->activateSurface();
139 // emit this->signalOnScreenMessage(display_message);
140 // }
141 // else if(strcmp(display_message, "call rejected") == 0){
142 // this->deactivateSurface();
143 // }
144 // else if(strcmp(display_message, "page1") == 0) {
145 // emit this->signalLoader("qrc:/page1.qml");
146 // }
147 // else if(strcmp(display_message, "page2") == 0) {
148 // emit this->signalLoader("qrc:/page2.qml");
149 // }
150 // else if(strcmp(display_message, "page3") == 0) {
151 // emit this->signalLoader(QUrl::fromLocalFile("/home/root/page3.qml"));
152 // }
153 // else{
154 // emit this->signalOnScreenMessage(display_message);
155 // }
156  });
157 
158  if (mp_wm->requestSurface(SCREEN_NAME) != 0) {
159  HMI_DEBUG("onscreenapp", "!!!!LayoutHandler requestSurface Failed!!!!!");
160  exit(EXIT_FAILURE);
161  }
162 
163  mp_wm->set_event_handler(QLibWindowmanager::Event_SyncDraw, [this](json_object *object) {
164  HMI_DEBUG("onscreenapp", "Surface %s got syncDraw!", SCREEN_NAME);
165  this->mp_wm->endDraw(SCREEN_NAME);
166  });
167 
168  mp_wm->set_event_handler(QLibWindowmanager::Event_Active, [this](json_object *object) {
169  struct json_object *value;
170  json_object_object_get_ex(object, "drawing_name", &value);
171  const char *name = json_object_get_string(value);
172 
173  HMI_DEBUG("onscreenapp", "Event_Active kKeyDrawingName = %s", name);
174  });
175 
176  mp_wm->set_event_handler(QLibWindowmanager::Event_Inactive, [this](json_object *object) {
177  struct json_object *value;
178  json_object_object_get_ex(object, "drawing_name", &value);
179  const char *name = json_object_get_string(value);
180 
181  HMI_DEBUG("onscreenapp", "Event_Inactive kKeyDrawingName = %s", name);
182  });
183 
184  HMI_DEBUG("onscreenapp", "LayoutHander::init() finished.");
185 }
+
#define HMI_DEBUG(prefix, args,...)
Definition: hmi-debug.h:42
+
void deactivateSurface(QString app)
+
void activateSurface(QString app)
+
static void * myThis
Definition: eventhandler.h:53
+
void signalLoader(QVariant url)
+
static void onRep_static(struct json_object *reply_contents)
+
void signalSetClearBackgroud()
+
#define SCREEN_NAME
+
+
+
+ +

◆ onRep()

+ +
+
+ + + + + + + + +
void EventHandler::onRep (struct json_object * reply_contents)
+
+ +

Definition at line 196 of file eventhandler.cpp.

+
197 {
198  const char* str = json_object_to_json_string(reply_contents);
199  HMI_DEBUG("onscreenapp", "EventHandler::onReply %s", str);
200 }
#define HMI_DEBUG(prefix, args,...)
Definition: hmi-debug.h:42
+
+
+
+ +

◆ onRep_static()

+ +
+
+ + + + + +
+ + + + + + + + +
void EventHandler::onRep_static (struct json_object * reply_contents)
+
+static
+
+ +

Definition at line 192 of file eventhandler.cpp.

+
193 {
194  static_cast<EventHandler*>(EventHandler::myThis)->onRep(reply_contents);
195 }
void onRep(struct json_object *reply_contents)
+
static void * myThis
Definition: eventhandler.h:53
+ +
+
+
+ +

◆ onScreenReply()

+ +
+
+ + + + + + + + +
void EventHandler::onScreenReply (const QString & message)
+
+ +

Definition at line 240 of file eventhandler.cpp.

+
241 {
242  HMI_DEBUG("onscreenapp", "EventHandler::onScreenReply()");
243  mp_hs->onScreenReply(message.toLatin1());
244 }
#define HMI_DEBUG(prefix, args,...)
Definition: hmi-debug.h:42
+
+
+
+ +

◆ setQuickWindow()

+ +
+
+ + + + + + + + +
void EventHandler::setQuickWindow (QQuickWindow * qw)
+
+ +

Definition at line 187 of file eventhandler.cpp.

+
188 {
189  mp_qw = qw;
190 }
+
+
+ +

◆ signalLoader

+ +
+
+ + + + + +
+ + + + + + + + +
void EventHandler::signalLoader (QVariant url)
+
+signal
+
+ +
+
+ +

◆ signalOnScreenMessage

+ +
+
+ + + + + +
+ + + + + + + + +
void EventHandler::signalOnScreenMessage (QVariant display_message)
+
+signal
+
+ +
+
+ +

◆ signalSetClearBackgroud

+ +
+
+ + + + + +
+ + + + + + + +
void EventHandler::signalSetClearBackgroud ()
+
+signal
+
+ +
+
+ +

◆ signalSetDefaultBackgroud

+ +
+
+ + + + + +
+ + + + + + + + +
void EventHandler::signalSetDefaultBackgroud (QVariant message)
+
+signal
+
+ +
+
+

Member Data Documentation

+ +

◆ myThis

+ +
+
+ + + + + +
+ + + + +
void * EventHandler::myThis = 0
+
+static
+
+ +

Definition at line 53 of file eventhandler.h.

+ +
+
+
The documentation for this class was generated from the following files: +
+ + + +