summaryrefslogtreecommitdiffstats
path: root/recipes-connectivity/neardal/neardal_0.14.bb
blob: f8634c468177aa04ef4b60e681de794556596218 (plain)
1
2
3
4
5
6
7
8
9
10
require neardal.inc

SRC_URI = "git://github.com/connectivity/neardal.git;protocol=https \
	file://ncl.patch \
	file://0001-neardal-ncl-fix-segfault-on-help-page-being-displaye.patch	\
	file://0002-neardal-lib-fix-memory-corruption.patch		\
	"
SRCREV = "fe0fa79c94e9a0f1c2cfa1f58b3acc9bdc7d5e13"

S = "${WORKDIR}/git"
und-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */ }
/*
 * Copyright (C) 2015 "IoT.bzh"
 * Author "Fulup Ar Foll"
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */


#include "local-def.h"

#include "utils-jbus.h"

static const char _id_[] = "id";
static struct jbus *jbus;

static struct json_object *call_void(AFB_request *request)
{
	struct json_object *obj = jbus_call_sj_sync(jbus, request->api, "true");
	request->errcode = obj ? MHD_HTTP_OK : MHD_HTTP_FAILED_DEPENDENCY;
	return obj;
}

static struct json_object *call_appid(AFB_request *request)
{
	struct json_object *obj;
	char *sid;
	const char *id = getQueryValue(request, _id_);
	if (id == NULL) {
		request->errcode = MHD_HTTP_BAD_REQUEST;
		return NULL;
	}
	if (0 >= asprintf(&sid, "\"%s\"", id)) {
		request->errcode = MHD_HTTP_INTERNAL_SERVER_ERROR;
		return NULL;
	}
	obj = jbus_call_sj_sync(jbus, request->api, sid);
	free(sid);
	request->errcode = obj ? MHD_HTTP_OK : MHD_HTTP_FAILED_DEPENDENCY;
	return obj;
}

static struct json_object *call_runid(AFB_request *request)
{
	struct json_object *obj;
	const char *id = getQueryValue(request, _id_);
	if (id == NULL) {
		request->errcode = MHD_HTTP_BAD_REQUEST;
		return NULL;
	}
	obj = jbus_call_sj_sync(jbus, request->api, id);
	request->errcode = obj ? MHD_HTTP_OK : MHD_HTTP_FAILED_DEPENDENCY;
	return obj;
}

static AFB_restapi plug_apis[] =
{
	{"runnables", AFB_SESSION_CHECK, (AFB_apiCB)call_void,  "Get list of runnable applications"},
	{"detail"   , AFB_SESSION_CHECK, (AFB_apiCB)call_appid, "Get the details for one application"},
	{"start"    , AFB_SESSION_CHECK, (AFB_apiCB)call_appid, "Start an application"},
	{"terminate", AFB_SESSION_CHECK, (AFB_apiCB)call_runid, "Terminate a running application"},
	{"stop"     , AFB_SESSION_CHECK, (AFB_apiCB)call_runid, "Stop (pause) a running application"},
	{"continue" , AFB_SESSION_CHECK, (AFB_apiCB)call_runid, "Continue (resume) a stopped application"},
	{"runners"  , AFB_SESSION_CHECK, (AFB_apiCB)call_void,  "Get the list of running applications"},
	{"state"    , AFB_SESSION_CHECK, (AFB_apiCB)call_runid, "Get the state of a running application"},
	{NULL}
};

static AFB_plugin plug_desc = {
	.type = AFB_PLUGIN_JSON,
	.info = "Application Framework Master Service",
	.prefix = "afm-main",
	.apis = plug_apis
};

AFB_plugin *pluginRegister()
{
	jbus = create_jbus(1, "/org/AGL/afm/user");
	return jbus ? &plug_desc : NULL;
}