From e0163d2b8daae98ced81f4bc737998c00858e771 Mon Sep 17 00:00:00 2001 From: zheng_wenlong Date: Fri, 29 Sep 2017 20:42:53 +0900 Subject: Add agl-service-homescreen-2017 Add a new binding agl-service-homescreen-2017 for homescreen-2017. There is a gles sample how to use this binding in sample/simple-egl. A image about this see JIRA SPEC-871. [PatchSets2] Use aglwgt make package. Change-Id: I9ae89188f9eb2de4c98ec8baa2f05fccca8b2372 Signed-off-by: zheng_wenlong --- doc/api-ref/html/df/d43/libhomescreen_8hpp.html | 96 ++++++ .../html/df/d43/libhomescreen_8hpp_source.html | 101 +++++++ doc/api-ref/html/df/d7d/structevent.html | 123 ++++++++ doc/api-ref/html/df/dac/test_8cpp.html | 334 +++++++++++++++++++++ doc/api-ref/html/df/dac/test_8cpp_source.html | 95 ++++++ 5 files changed, 749 insertions(+) create mode 100644 doc/api-ref/html/df/d43/libhomescreen_8hpp.html create mode 100644 doc/api-ref/html/df/d43/libhomescreen_8hpp_source.html create mode 100644 doc/api-ref/html/df/d7d/structevent.html create mode 100644 doc/api-ref/html/df/dac/test_8cpp.html create mode 100644 doc/api-ref/html/df/dac/test_8cpp_source.html (limited to 'doc/api-ref/html/df') diff --git a/doc/api-ref/html/df/d43/libhomescreen_8hpp.html b/doc/api-ref/html/df/d43/libhomescreen_8hpp.html new file mode 100644 index 0000000..631034d --- /dev/null +++ b/doc/api-ref/html/df/d43/libhomescreen_8hpp.html @@ -0,0 +1,96 @@ + + + + + + + +HomeScreenBinding: include/libhomescreen.hpp File Reference + + + + + + + + + +
+
+ + + + + + +
+
HomeScreenBinding +
+
+
+ + + + + + + + +
+
+ + +
+ +
+ + +
+
+ +
+
libhomescreen.hpp File Reference
+
+
+
#include <vector>
+#include <map>
+#include <string>
+#include <functional>
+#include <json-c/json.h>
+#include <systemd/sd-event.h>
+#include <afb/afb-binding.h>
+#include <afb/afb-wsj1.h>
+#include <afb/afb-ws-client.h>
+
+

Go to the source code of this file.

+ + + + +

+Classes

class  LibHomeScreen
 
+
+ + + + diff --git a/doc/api-ref/html/df/d43/libhomescreen_8hpp_source.html b/doc/api-ref/html/df/d43/libhomescreen_8hpp_source.html new file mode 100644 index 0000000..2722975 --- /dev/null +++ b/doc/api-ref/html/df/d43/libhomescreen_8hpp_source.html @@ -0,0 +1,101 @@ + + + + + + + +HomeScreenBinding: include/libhomescreen.hpp Source File + + + + + + + + + +
+
+ + + + + + +
+
HomeScreenBinding +
+
+
+ + + + + + + + +
+
+ + +
+ +
+ + +
+
+
+
libhomescreen.hpp
+
+
+Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017 TOYOTA MOTOR CORPORATION
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef LIBHOMESCREEN_H
18 #define LIBHOMESCREEN_H
19 #include <vector>
20 #include <map>
21 #include <string>
22 #include <functional>
23 #include <json-c/json.h>
24 #include <systemd/sd-event.h>
25 extern "C"
26 {
27 #include <afb/afb-binding.h>
28 #include <afb/afb-wsj1.h>
29 #include <afb/afb-ws-client.h>
30 }
31 
33 {
34 public:
35  LibHomeScreen();
37 
38  LibHomeScreen(const LibHomeScreen &) = delete;
39  LibHomeScreen &operator=(const LibHomeScreen &) = delete;
40 
41  using handler_func = std::function<void(const char*)>;
42 
43  enum EventType {
46  };
47 
48  static const std::vector<std::string> api_list;
49  static const std::vector<std::string> event_list;
50 
51  /* Method */
52  int init(const int port, const std::string& token);
53  int runEventloop();
54 
55  int tapShortcut(const char* application_name);
56  int onScreenMessage(const char* display_message);
57 
58  void set_event_handler(enum EventType et, handler_func f);
59 
60  void registerCallback(
61  void (*event_cb)(const std::string& event, struct json_object* event_contents),
62  void (*reply_cb)(struct json_object* reply_contents),
63  void (*hangup_cb)(void) = nullptr);
64 
65  int call(const std::string& verb, struct json_object* arg);
66  int call(const char* verb, struct json_object* arg);
67  int subscribe(const std::string& event_name);
68  int unsubscribe(const std::string& event_name);
69 
70 private:
71  int initialize_websocket();
72  void (*onEvent)(const std::string& event, struct json_object* event_contents);
73  void (*onReply)(struct json_object* reply);
74  void (*onHangup)(void);
75 
76  struct afb_wsj1* sp_websock;
77  struct afb_wsj1_itf minterface;
78  sd_event* mploop;
79  std::string muri;
80 
81  int mport = 2000;
82  std::string mtoken = "hs";
83 
84  std::map<EventType, handler_func> handlers;
85 
86 public:
87  /* Don't use/ Internal only */
88  void on_hangup(void *closure, struct afb_wsj1 *wsj);
89  void on_call(void *closure, const char *api, const char *verb, struct afb_wsj1_msg *msg);
90  void on_event(void *closure, const char *event, struct afb_wsj1_msg *msg);
91  void on_reply(void *closure, struct afb_wsj1_msg *msg);
92 };
93 
94 #endif /* LIBHOMESCREEN_H */
void on_event(void *closure, const char *event, struct afb_wsj1_msg *msg)
+
void on_reply(void *closure, struct afb_wsj1_msg *msg)
+
LibHomeScreen & operator=(const LibHomeScreen &)=delete
+
void on_call(void *closure, const char *api, const char *verb, struct afb_wsj1_msg *msg)
+ + +
int call(const std::string &verb, struct json_object *arg)
+
void on_hangup(void *closure, struct afb_wsj1 *wsj)
+
int tapShortcut(const char *application_name)
+
int subscribe(const std::string &event_name)
+ + + +
static const std::vector< std::string > event_list
+
std::function< void(const char *)> handler_func
+
int init(const int port, const std::string &token)
+
int onScreenMessage(const char *display_message)
+ + +
static const std::vector< std::string > api_list
+
int unsubscribe(const std::string &event_name)
+
void set_event_handler(enum EventType et, handler_func f)
+
void registerCallback(void(*event_cb)(const std::string &event, struct json_object *event_contents), void(*reply_cb)(struct json_object *reply_contents), void(*hangup_cb)(void)=nullptr)
+ +
+ + + + diff --git a/doc/api-ref/html/df/d7d/structevent.html b/doc/api-ref/html/df/d7d/structevent.html new file mode 100644 index 0000000..3ac6dbd --- /dev/null +++ b/doc/api-ref/html/df/d7d/structevent.html @@ -0,0 +1,123 @@ + + + + + + + +HomeScreenBinding: event Struct Reference + + + + + + + + + +
+
+ + + + + + +
+
HomeScreenBinding +
+
+
+ + + + + + + + +
+
+ + +
+ +
+ +
+
+ +
+
event Struct Reference
+
+
+ + + + + + +

+Public Attributes

const char * name
 
struct afb_event * event
 
+

Detailed Description

+
+

Definition at line 35 of file homescreen.c.

+

Member Data Documentation

+ +

◆ event

+ +
+
+ + + + +
struct afb_event* event::event
+
+ +

Definition at line 37 of file homescreen.c.

+ +
+
+ +

◆ name

+ +
+
+ + + + +
const char* event::name
+
+ +

Definition at line 36 of file homescreen.c.

+ +
+
+
The documentation for this struct was generated from the following file: +
+ + + + diff --git a/doc/api-ref/html/df/dac/test_8cpp.html b/doc/api-ref/html/df/dac/test_8cpp.html new file mode 100644 index 0000000..7995dcb --- /dev/null +++ b/doc/api-ref/html/df/dac/test_8cpp.html @@ -0,0 +1,334 @@ + + + + + + + +HomeScreenBinding: libhomescreen/test.cpp File Reference + + + + + + + + + +
+
+ + + + + + +
+
HomeScreenBinding +
+
+
+ + + + + + + + +
+
+ + +
+ +
+ + +
+
+ +
+
test.cpp File Reference
+
+
+
#include <libhomescreen.hpp>
+#include <iostream>
+#include <glib-2.0/glib.h>
+#include <fcntl.h>
+#include <string>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <thread>
+#include <exception>
+#include <vector>
+#include <sstream>
+#include <functional>
+
+

Go to the source code of this file.

+ + + + + + + + + + + + + + +

+Functions

static vector< string > split (const string &str, char sep)
 
static void usage ()
 
static void call_test ()
 
static void onRep (struct json_object *reply_contents)
 
static void onEv (const string &event, struct json_object *event_contents)
 
int main (int argc, char **argv)
 
+ + + +

+Variables

LibHomeScreenhs
 
+

Function Documentation

+ +

◆ call_test()

+ +
+
+ + + + + +
+ + + + + + + +
static void call_test ()
+
+static
+
+ +

Definition at line 51 of file test.cpp.

+
52 {
53  string command;
54 
55  cout << "input verb and argments" << endl;
56 
57  /* read the buffer */
58  for(;;){
59  char line[1023];
60  cin.getline(line, sizeof(line));
61  command = line;
62  if(command.empty()){
63  continue;
64  }
65 
66  vector<string> v_command = split(command, ' ');
67  /*for(auto itr = v_command.begin(); itr != v_command.end(); ++itr)
68  {
69  cout << *itr <<endl;
70  }*/
71  size_t num = v_command.size();
72  if(num % 2 == 0){
73  cout << "If command contains args, please input <key,value> in argument part" << endl;
74  continue;
75  }
76  /* create json object */
77  struct json_object* j_obj = json_object_new_object();
78  for(int i = 1;i < (v_command.size()) ;++i){
79  struct json_object* val = json_object_new_string(v_command[i+1].c_str());
80  json_object_object_add(j_obj, v_command[i].c_str(), val);
81  ++i;
82  }
83  /* call verb via LibHomeScreen */
84  hs->call(v_command[0], j_obj);
85  /* free vector */
86  vector<string>().swap(v_command);
87  string().swap(command);
88  }
89 }
static vector< string > split(const string &str, char sep)
Definition: test.cpp:105
+
LibHomeScreen * hs
Definition: test.cpp:33
+
int call(const std::string &verb, struct json_object *arg)
+
+
+
+ +

◆ main()

+ +
+
+ + + + + + + + + + + + + + + + + + +
int main (int argc,
char ** argv 
)
+
+ +

Definition at line 117 of file test.cpp.

+
118 {
119  int ret;
120  if(argc == 1)
121  {
122  printf("Please input port num in first argument, and token in second argument");
123  usage();
124  return 0;
125  }
126  if(argc == 2)
127  {
128  string av(argv[1]);
129  if( (av == "-h") || (av == "--help"))
130  {
131  usage();
132  return 0;
133  }
134  }
135 
136  string port_string(argv[1]);
137  string token(argv[2]);
138  char* endptr;
139  long port = strtol(port_string.c_str(),&endptr,10);
140 
141  /* error check of range */
142  if( (port > 20000) || (port < 0) )
143  {
144  printf("input under 20000(temporary number)");
145  return 0;
146  }
147  if(*endptr != '\0')
148  {
149  printf("not number");
150  return 0;
151  }
152 
153  cout << "Call test for LibHomeScreen" << endl;
154  hs = new LibHomeScreen();
155  hs->init(port, token);
156 
157  // hs->registerCallback(&onEv, &onRep);
158  //
159  // hs->subscribe(event_list[0]); // tap_shortcut event subscribe
160  // hs->subscribe(event_list[1]);
161 
162  hs->set_event_handler(LibHomeScreen::Event_TapShortcut, [](const char* application_name){
163  cout << "set_event_handler Event_TapShortcut application_name = " << application_name << endl;
164  });
165 
166  hs->set_event_handler(LibHomeScreen::Event_OnScreenMessage, [](const char* display_message){
167  cout << "set_event_handler Event_OnScreenMessage display_message = " << display_message << endl;
168  });
169 
170 
171  if (ret < 0) {
172  printf("failed to create event loop");
173  return -1;
174  }
175  hs->runEventloop();
176 
177  call_test();
178 
179  return 0;
180 }
static void usage()
Definition: test.cpp:35
+
LibHomeScreen * hs
Definition: test.cpp:33
+ +
static void call_test()
Definition: test.cpp:51
+ +
int init(const int port, const std::string &token)
+ +
void set_event_handler(enum EventType et, handler_func f)
+ +
+
+
+ +

◆ onEv()

+ +
+
+ + + + + +
+ + + + + + + + + + + + + + + + + + +
static void onEv (const string & event,
struct json_object * event_contents 
)
+
+static
+
+ +

Definition at line 98 of file test.cpp.

+
99 {
100  const char* str = json_object_to_json_string(event_contents);
101  cout << "test.cpp [CB onEvent]: event: " << event.c_str() << " contents: " << str << endl;
102  //json_object_put(event_contents); do not release!!!
103 }
+
+
+ +

◆ onRep()

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

Definition at line 91 of file test.cpp.

+
92 {
93  const char* str = json_object_to_json_string(reply_contents);
94  cout << "test.cpp [CB onRep]: " << str << endl;
95  //json_object_put(reply_contents); do not release!!!
96 }
+
+
+ +

◆ split()

+ +
+
+ + + + + +
+ + + + + + + + + + + + + + + + + + +
static vector< string > split (const string & str,
char sep 
)
+
+static
+
+ +

Definition at line 105 of file test.cpp.

+
106 {
107  vector<string> v;
108  stringstream ss(str);
109  string buffer;
110  while( getline(ss, buffer, sep) ) {
111  if(!buffer.empty())
112  v.push_back(buffer);
113  }
114  return v;
115 }
+
+
+ +

◆ usage()

+ +
+
+ + + + + +
+ + + + + + + +
static void usage ()
+
+static
+
+ +

Definition at line 35 of file test.cpp.

+
36 {
37  cout << "verb "<< "key:arg" << endl;
38  cout << "example:" << endl;
39  cout << "ping" << endl;
40  cout << "------- -------- --- " << endl;
41  cout << " verb key value" << endl;
42  cout << "verb list:" << endl;
43  for(auto itr = LibHomeScreen::api_list.begin(); itr != LibHomeScreen::api_list.end(); ++itr)
44  {
45  cout << " " << *itr << endl;
46  }
47  // Todo output api list
48  exit(0);
49 }
static const std::vector< std::string > api_list
+
+
+
+

Variable Documentation

+ +

◆ hs

+ +
+
+ + + + +
LibHomeScreen* hs
+
+ +

Definition at line 33 of file test.cpp.

+ +
+
+
+ + + + diff --git a/doc/api-ref/html/df/dac/test_8cpp_source.html b/doc/api-ref/html/df/dac/test_8cpp_source.html new file mode 100644 index 0000000..4726190 --- /dev/null +++ b/doc/api-ref/html/df/dac/test_8cpp_source.html @@ -0,0 +1,95 @@ + + + + + + + +HomeScreenBinding: libhomescreen/test.cpp Source File + + + + + + + + + +
+
+ + + + + + +
+
HomeScreenBinding +
+
+
+ + + + + + + + +
+
+ + +
+ +
+ + +
+
+
+
test.cpp
+
+
+Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017 TOYOTA MOTOR CORPORATION
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #include <libhomescreen.hpp>
18 #include <iostream>
19 #include <glib-2.0/glib.h>
20 #include <fcntl.h>
21 #include <string>
22 #include <sys/types.h>
23 #include <sys/stat.h>
24 #include <thread>
25 #include <exception>
26 #include <vector>
27 #include <sstream>
28 #include <functional>
29 
30 using namespace std;
31 
32 static vector<string> split(const string& str, char sep);
34 
35 static void usage()
36 {
37  cout << "verb "<< "key:arg" << endl;
38  cout << "example:" << endl;
39  cout << "ping" << endl;
40  cout << "------- -------- --- " << endl;
41  cout << " verb key value" << endl;
42  cout << "verb list:" << endl;
43  for(auto itr = LibHomeScreen::api_list.begin(); itr != LibHomeScreen::api_list.end(); ++itr)
44  {
45  cout << " " << *itr << endl;
46  }
47  // Todo output api list
48  exit(0);
49 }
50 
51 static void call_test()
52 {
53  string command;
54 
55  cout << "input verb and argments" << endl;
56 
57  /* read the buffer */
58  for(;;){
59  char line[1023];
60  cin.getline(line, sizeof(line));
61  command = line;
62  if(command.empty()){
63  continue;
64  }
65 
66  vector<string> v_command = split(command, ' ');
67  /*for(auto itr = v_command.begin(); itr != v_command.end(); ++itr)
68  {
69  cout << *itr <<endl;
70  }*/
71  size_t num = v_command.size();
72  if(num % 2 == 0){
73  cout << "If command contains args, please input <key,value> in argument part" << endl;
74  continue;
75  }
76  /* create json object */
77  struct json_object* j_obj = json_object_new_object();
78  for(int i = 1;i < (v_command.size()) ;++i){
79  struct json_object* val = json_object_new_string(v_command[i+1].c_str());
80  json_object_object_add(j_obj, v_command[i].c_str(), val);
81  ++i;
82  }
83  /* call verb via LibHomeScreen */
84  hs->call(v_command[0], j_obj);
85  /* free vector */
86  vector<string>().swap(v_command);
87  string().swap(command);
88  }
89 }
90 
91 static void onRep(struct json_object* reply_contents)
92 {
93  const char* str = json_object_to_json_string(reply_contents);
94  cout << "test.cpp [CB onRep]: " << str << endl;
95  //json_object_put(reply_contents); do not release!!!
96 }
97 
98 static void onEv(const string& event, struct json_object* event_contents)
99 {
100  const char* str = json_object_to_json_string(event_contents);
101  cout << "test.cpp [CB onEvent]: event: " << event.c_str() << " contents: " << str << endl;
102  //json_object_put(event_contents); do not release!!!
103 }
104 
105 static vector<string> split(const string& str, char sep)
106 {
107  vector<string> v;
108  stringstream ss(str);
109  string buffer;
110  while( getline(ss, buffer, sep) ) {
111  if(!buffer.empty())
112  v.push_back(buffer);
113  }
114  return v;
115 }
116 
117 int main(int argc, char **argv)
118 {
119  int ret;
120  if(argc == 1)
121  {
122  printf("Please input port num in first argument, and token in second argument");
123  usage();
124  return 0;
125  }
126  if(argc == 2)
127  {
128  string av(argv[1]);
129  if( (av == "-h") || (av == "--help"))
130  {
131  usage();
132  return 0;
133  }
134  }
135 
136  string port_string(argv[1]);
137  string token(argv[2]);
138  char* endptr;
139  long port = strtol(port_string.c_str(),&endptr,10);
140 
141  /* error check of range */
142  if( (port > 20000) || (port < 0) )
143  {
144  printf("input under 20000(temporary number)");
145  return 0;
146  }
147  if(*endptr != '\0')
148  {
149  printf("not number");
150  return 0;
151  }
152 
153  cout << "Call test for LibHomeScreen" << endl;
154  hs = new LibHomeScreen();
155  hs->init(port, token);
156 
157  // hs->registerCallback(&onEv, &onRep);
158  //
159  // hs->subscribe(event_list[0]); // tap_shortcut event subscribe
160  // hs->subscribe(event_list[1]);
161 
162  hs->set_event_handler(LibHomeScreen::Event_TapShortcut, [](const char* application_name){
163  cout << "set_event_handler Event_TapShortcut application_name = " << application_name << endl;
164  });
165 
166  hs->set_event_handler(LibHomeScreen::Event_OnScreenMessage, [](const char* display_message){
167  cout << "set_event_handler Event_OnScreenMessage display_message = " << display_message << endl;
168  });
169 
170 
171  if (ret < 0) {
172  printf("failed to create event loop");
173  return -1;
174  }
175  hs->runEventloop();
176 
177  call_test();
178 
179  return 0;
180 }
static void usage()
Definition: test.cpp:35
+
static vector< string > split(const string &str, char sep)
Definition: test.cpp:105
+ + +
LibHomeScreen * hs
Definition: test.cpp:33
+ + +
int call(const std::string &verb, struct json_object *arg)
+
static void onEv(const string &event, struct json_object *event_contents)
Definition: test.cpp:98
+
int main(int argc, char **argv)
Definition: test.cpp:117
+
static void call_test()
Definition: test.cpp:51
+
static void onRep(struct json_object *reply_contents)
Definition: test.cpp:91
+ +
int init(const int port, const std::string &token)
+ +
static const std::vector< std::string > api_list
+
void set_event_handler(enum EventType et, handler_func f)
+ +
+ + + + -- cgit 1.2.3-korg