HomeScreenBinding
Macros | Functions | Variables
libhomescreen.cpp File Reference
#include <stdarg.h>
#include <sys/socket.h>
#include <iostream>
#include <algorithm>
#include <thread>
#include <errno.h>
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <libhomescreen.hpp>

Go to the source code of this file.

Macros

#define ELOG(args, ...)   _ELOG(__FUNCTION__,__LINE__,args,##__VA_ARGS__)
 
#define DLOG(args, ...)   _DLOG(__FUNCTION__,__LINE__,args,##__VA_ARGS__)
 

Functions

static void _DLOG (const char *func, const int line, const char *log,...)
 
static void _ELOG (const char *func, const int line, const char *log,...)
 
static bool has_verb (const string &verb)
 
static void _on_hangup_static (void *closure, struct afb_wsj1 *wsj)
 
static void _on_call_static (void *closure, const char *api, const char *verb, struct afb_wsj1_msg *msg)
 
static void _on_event_static (void *closure, const char *event, struct afb_wsj1_msg *msg)
 
static void _on_reply_static (void *closure, struct afb_wsj1_msg *msg)
 
static void * event_loop_run (void *args)
 

Variables

static const char API [] = "homescreen"
 

Macro Definition Documentation

◆ DLOG

#define DLOG (   args,
  ... 
)    _DLOG(__FUNCTION__,__LINE__,args,##__VA_ARGS__)

Definition at line 33 of file libhomescreen.cpp.

◆ ELOG

#define ELOG (   args,
  ... 
)    _ELOG(__FUNCTION__,__LINE__,args,##__VA_ARGS__)

Definition at line 32 of file libhomescreen.cpp.

Function Documentation

◆ _DLOG()

static void _DLOG ( const char *  func,
const int  line,
const char *  log,
  ... 
)
static

Definition at line 545 of file libhomescreen.cpp.

546 {
547  char *message;
548  va_list args;
549  va_start(args, log);
550  if (log == NULL || vasprintf(&message, log, args) < 0)
551  message = NULL;
552  cout << "[libhomescreen DEBUG]" << func << "(" << line << "):" << message << endl;
553  va_end(args);
554  free(message);
555 }

◆ _ELOG()

static void _ELOG ( const char *  func,
const int  line,
const char *  log,
  ... 
)
static

Definition at line 533 of file libhomescreen.cpp.

534 {
535  char *message;
536  va_list args;
537  va_start(args, log);
538  if (log == NULL || vasprintf(&message, log, args) < 0)
539  message = NULL;
540  cout << "[libhomescreen ERROR]" << func << "(" << line << "):" << message << endl;
541  va_end(args);
542  free(message);
543 }

◆ _on_call_static()

static void _on_call_static ( void *  closure,
const char *  api,
const char *  verb,
struct afb_wsj1_msg *  msg 
)
static

Definition at line 66 of file libhomescreen.cpp.

67 {
68  /* LibHomeScreen is not called from other process */
69 }

◆ _on_event_static()

static void _on_event_static ( void *  closure,
const char *  event,
struct afb_wsj1_msg *  msg 
)
static

Definition at line 71 of file libhomescreen.cpp.

72 {
73  static_cast<LibHomeScreen*>(closure)->on_event(NULL,event,msg);
74 }

◆ _on_hangup_static()

static void _on_hangup_static ( void *  closure,
struct afb_wsj1 *  wsj 
)
static

websocket

Definition at line 61 of file libhomescreen.cpp.

62 {
63  static_cast<LibHomeScreen*>(closure)->on_hangup(NULL,wsj);
64 }

◆ _on_reply_static()

static void _on_reply_static ( void *  closure,
struct afb_wsj1_msg *  msg 
)
static

Definition at line 76 of file libhomescreen.cpp.

77 {
78  static_cast<LibHomeScreen*>(closure)->on_reply(NULL,msg);
79 }

◆ event_loop_run()

static void* event_loop_run ( void *  args)
static

Definition at line 204 of file libhomescreen.cpp.

205 {
206  struct sd_event* loop = (struct sd_event*)(args);
207  DLOG("start eventloop");
208  for(;;)
209  sd_event_run(loop, 30000000);
210 }
#define DLOG(args,...)

◆ has_verb()

static bool has_verb ( const string &  verb)
static

Definition at line 557 of file libhomescreen.cpp.

558 {
559  DLOG("verb is %s", verb.c_str());
560  if(find(LibHomeScreen::api_list.begin(), LibHomeScreen::api_list.end(), verb) != LibHomeScreen::api_list.end())
561  return true;
562  else
563  return false;
564 }
#define DLOG(args,...)
static const std::vector< std::string > api_list

Variable Documentation

◆ API

const char API[] = "homescreen"
static

Definition at line 40 of file libhomescreen.cpp.