#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.
|
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) |
|
◆ call_test()
static void call_test |
( |
| ) |
|
|
static |
Definition at line 51 of file test.cpp.
55 cout <<
"input verb and argments" << endl;
60 cin.getline(line,
sizeof(line));
66 vector<string> v_command =
split(command,
' ');
71 size_t num = v_command.size();
73 cout <<
"If command contains args, please input <key,value> in argument part" << endl;
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);
84 hs->
call(v_command[0], j_obj);
86 vector<string>().swap(v_command);
87 string().swap(command);
static vector< string > split(const string &str, char sep)
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.
122 printf(
"Please input port num in first argument, and token in second argument");
129 if( (av ==
"-h") || (av ==
"--help"))
136 string port_string(argv[1]);
137 string token(argv[2]);
139 long port = strtol(port_string.c_str(),&endptr,10);
142 if( (port > 20000) || (port < 0) )
144 printf(
"input under 20000(temporary number)");
149 printf(
"not number");
153 cout <<
"Call test for LibHomeScreen" << endl;
163 cout <<
"set_event_handler Event_TapShortcut application_name = " << application_name << endl;
167 cout <<
"set_event_handler Event_OnScreenMessage display_message = " << display_message << endl;
172 printf(
"failed to create event loop");
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.
100 const char* str = json_object_to_json_string(event_contents);
101 cout <<
"test.cpp [CB onEvent]: event: " <<
event.c_str() <<
" contents: " << str << endl;
◆ onRep()
static void onRep |
( |
struct json_object * |
reply_contents | ) |
|
|
static |
Definition at line 91 of file test.cpp.
93 const char* str = json_object_to_json_string(reply_contents);
94 cout <<
"test.cpp [CB onRep]: " << str << endl;
◆ split()
static vector< string > split |
( |
const string & |
str, |
|
|
char |
sep |
|
) |
| |
|
static |
Definition at line 105 of file test.cpp.
108 stringstream ss(str);
110 while( getline(ss, buffer, sep) ) {
◆ usage()
Definition at line 35 of file test.cpp.
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;
45 cout <<
" " << *itr << endl;
static const std::vector< std::string > api_list
◆ hs