static pa_hook_result_t device_new_or_changed_cb(pa_core *c, pa_object *o, struct userdata *u) {
    pa_assert(c);
    pa_object_assert_ref(o);

    if (!shall_ignore(o))
        publish_service(get_service(u, o));

    return PA_HOOK_OK;
}
Exemple #2
0
void tun::async_read(std::function<read_handler> &&handler) {
	auto a = std::make_shared<std::array<char, 2048>>();
	auto p = packet{{a.get(), a->size()}, a};
	get_service().async_read_some(
		get_implementation(), p.first,
		[p, handler = std::move(handler)](const gh::error_code& ec, std::size_t bytes_transferred) mutable {
			handler(ec, packet{boost::asio::buffer(p.first, bytes_transferred), p.second});
		});
}
Exemple #3
0
int __stdcall start(int state)
{
     int p;
     int i;

     int scrnsize;
     int scrnbpp;
     int scrnpitch;

     if( !test_mmx())
        return FALSE;

     if( (scrnbpp = GetScreenBpp()) != 32)
        return FALSE;

     scrnsize  = GetScreenSize();
     scrnpitch = GetScreenPitch();

     scrn_clip.xmin = 0;
     scrn_clip.ymin = 0;
     scrn_clip.xmax = (scrnsize >> 16) - 1;
     scrn_clip.ymax = (scrnsize & 0xFFFF) - 1;

     scrn_pixmap.width   = scrnsize >> 16;
     scrn_pixmap.height  = scrnsize & 0xFFFF;
     scrn_pixmap.format  = PICT_a8r8g8b8;
     scrn_pixmap.flags   = PX_MEM_LOCAL;
     scrn_pixmap.pitch   = scrnpitch;
     scrn_pixmap.mapped  = (void*)LFB_BASE;

     br_slab.available = 256;
     br_slab.start = brushes;
     br_slab.nextavail = brushes;

     for (i = 0, p = (int)br_slab.start; i < 256; i++)
     {
       *(int *)p = p+sizeof(brush_t);
       p = p+sizeof(brush_t);
     };

     px_slab.available = 64;
     px_slab.start = pixmaps;
     px_slab.nextavail = pixmaps;

     for (i = 0, p = (int)px_slab.start; i < 64; i++)
     {
       *(int *)p = p+sizeof(pixmap_t);
       p = p+sizeof(pixmap_t);
     };

     srv_hw2d = get_service("HDRAW");
       if(srv_hw2d == 0)
         srv_hw2d = load_service("/rd/1/drivers/ati2d.drv");

     return TRUE;
};
const char *connman_service_get_timeservers_config(const char *path)
{
	struct connman_service *service;

	service = get_service(path);
	if (service == NULL)
		 return NULL;

	return service->timeservers_conf;
}
const char *connman_service_get_domains(const char *path)
{
	struct connman_service *service;

	service = get_service(path);
	if (service == NULL)
		 return NULL;

	return service->domains;
}
const char *connman_service_get_nameservers(const char *path)
{
	struct connman_service *service;

	service = get_service(path);
	if (service == NULL)
		 return NULL;

	return service->nameservers;
}
gboolean connman_service_is_roaming(const char *path)
{
	struct connman_service *service;

	service = get_service(path);
	if (service == NULL)
		 return FALSE;

	return service->roaming;
}
gboolean connman_service_is_autoconnect(const char *path)
{
	struct connman_service *service;

	service = get_service(path);
	if (service == NULL)
		 return FALSE;

	return service->autoconnect;
}
const struct connman_ethernet *connman_service_get_ethernet(const char *path)
{
	struct connman_service *service;

	service = get_service(path);
	if (service == NULL)
		return NULL;

	return service->ethernet;
}
gboolean connman_service_is_favorite(const char *path)
{
	struct connman_service *service;

	service = get_service(path);
	if (service == NULL)
		 return FALSE;

	return service->favorite;
}
uint8_t connman_service_get_strength(const char *path)
{
	struct connman_service *service;

	service = get_service(path);
	if (service == NULL)
		 return 0;

	return service->strength;
}
const char *connman_service_get_security(const char *path)
{
	struct connman_service *service;

	service = get_service(path);
	if (service == NULL)
		 return NULL;

	return service->security;
}
const char *connman_service_get_error(const char *path)
{
	struct connman_service *service;

	service = get_service(path);
	if (service == NULL)
		 return NULL;

	return service->error;
}
enum connman_state connman_service_get_state(const char *path)
{
	struct connman_service *service;

	service = get_service(path);
	if (service == NULL)
		 return CONNMAN_STATE_OFFLINE;

	return service->state;
}
const char *connman_service_get_type(const char *path)
{
	struct connman_service *service;

	service = get_service(path);
	if (service == NULL)
		 return NULL;

	return service->type;
}
const struct connman_proxy *connman_service_get_proxy_config(const char *path)
{
	struct connman_service *service;

	service = get_service(path);
	if (service == NULL)
		 return NULL;

	return service->proxy_conf;
}
const struct connman_provider *connman_service_get_provider(const char *path)
{
	struct connman_service *service;

	service = get_service(path);
	if (service == NULL)
		 return NULL;

	return service->provider;
}
gboolean connman_service_is_immutable(const char *path)
{
	struct connman_service *service;

	service = get_service(path);
	if (service == NULL)
		 return FALSE;

	return service->immutable;
}
const struct connman_ipv6 *connman_service_get_ipv6_config(const char *path)
{
	struct connman_service *service;

	service = get_service(path);
	if (service == NULL)
		 return NULL;

	return service->ipv6_conf;
}
static int publish_all_services(struct userdata *u) {
    pa_sink *sink;
    pa_source *source;
    uint32_t idx;

    pa_assert(u);

    pa_log_debug("Publishing services in Bonjour");

    for (sink = PA_SINK(pa_idxset_first(u->core->sinks, &idx)); sink; sink = PA_SINK(pa_idxset_next(u->core->sinks, &idx)))
        if (!shall_ignore(PA_OBJECT(sink)))
            publish_service(get_service(u, PA_OBJECT(sink)));

    for (source = PA_SOURCE(pa_idxset_first(u->core->sources, &idx)); source; source = PA_SOURCE(pa_idxset_next(u->core->sources, &idx)))
        if (!shall_ignore(PA_OBJECT(source)))
            publish_service(get_service(u, PA_OBJECT(source)));

    return publish_main_service(u);
}
Exemple #21
0
void Messenger::socket_rpc_send_and_recv(RawMessage* raw_message) {
    get_service().post([this, raw_message]{
        zmq::message_t message = raw_message->pack_zmq_msg();
        rpc_socket_.send(message);
        delete raw_message;
        zmq::message_t reply;
        rpc_socket_.recv(&reply);
        std::unique_ptr<RawMessage> response(new RawMessage(&reply));
        queue_.push_back(std::move(response));
    });
}
/*--- dissect_qsig_arg ------------------------------------------------------*/
static int
dissect_qsig_arg(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) {
  int offset;
  rose_ctx_t *rctx;
  gint32 opcode = 0, service;
  const qsig_op_t *op_ptr;
  const gchar *p;
  proto_item *ti, *ti_tmp;
  proto_tree *qsig_tree;

  offset = 0;
  rctx = get_rose_ctx(pinfo->private_data);
  DISSECTOR_ASSERT(rctx);
  if (rctx->d.pdu != 1)  /* invoke */
    return offset;
  if (rctx->d.code == 0) {  /* local */
    opcode = rctx->d.code_local;
    op_ptr = get_op(opcode);
  } else if (rctx->d.code == 1) {  /* global */
    op_ptr = g_hash_table_lookup(qsig_oid2op_hashtable, rctx->d.code_global);
    if (op_ptr) opcode = op_ptr->opcode;
  } else {
    return offset;
  }
  if (!op_ptr)
    return offset;
  service = get_service(opcode);

  ti = proto_tree_add_item(tree, proto_qsig, tvb, offset, tvb_length(tvb), ENC_NA);
  qsig_tree = proto_item_add_subtree(ti, ett_qsig);

  proto_tree_add_uint(qsig_tree, hf_qsig_operation, tvb, 0, 0, opcode);
  p = match_strval(opcode, VALS(qsig_str_operation));
  if (p) {
    proto_item_append_text(ti, ": %s", p);
    proto_item_append_text(rctx->d.code_item, " - %s", p);
    if (rctx->apdu_depth >= 0)
      proto_item_append_text(proto_item_get_parent_nth(proto_tree_get_parent(tree), rctx->apdu_depth), " %s", p);
  }

  ti_tmp = proto_tree_add_uint(qsig_tree, hf_qsig_service, tvb, 0, 0, service);
  p = match_strval(service, VALS(qsig_str_service_name));
  if (p) proto_item_append_text(ti_tmp, " - %s", p);

  if (op_ptr->arg_pdu)
    offset = op_ptr->arg_pdu(tvb, pinfo, qsig_tree);
  else
    if (tvb_length_remaining(tvb, offset) > 0) {
      proto_tree_add_text(qsig_tree, tvb, offset, -1, "UNSUPPORTED ARGUMENT TYPE (QSIG)");
      offset += tvb_length_remaining(tvb, offset);
    }

  return offset;
}
int connman_service_set_autoconnectable(const char *path, gboolean enable)
{
	struct connman_service *service;

	service = get_service(path);
	if (service == NULL)
		return -EINVAL;

	return set_service_property(service, SERVICE_AUTOCONNECT,
						DBUS_TYPE_BOOLEAN, &enable);
}
int connman_service_select(const char *path)
{
	struct connman_service *service;

	service = get_service(path);
	if (service == NULL)
		return -EINVAL;

	service_if->selected_service = service;

	return 0;
}
/*--- dissect_qsig_res -------------------------------------------------------*/
static int
dissect_qsig_res(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data) {
  gint offset = 0;
  rose_ctx_t *rctx;
  gint32 opcode, service;
  const qsig_op_t *op_ptr;
  const gchar *p;
  proto_item *ti, *ti_tmp;
  proto_tree *qsig_tree;

  /* Reject the packet if data is NULL */
  if (data == NULL)
    return 0;
  rctx = get_rose_ctx(data);
  DISSECTOR_ASSERT(rctx);

  if (rctx->d.pdu != 2)  /* returnResult */
    return offset;
  if (rctx->d.code != 0)  /* local */
    return offset;
  opcode = rctx->d.code_local;
  op_ptr = get_op(opcode);
  if (!op_ptr)
    return offset;
  service = get_service(opcode);

  ti = proto_tree_add_item(tree, proto_qsig, tvb, offset, tvb_captured_length(tvb), ENC_NA);
  qsig_tree = proto_item_add_subtree(ti, ett_qsig);

  proto_tree_add_uint(qsig_tree, hf_qsig_operation, tvb, 0, 0, opcode);
  p = try_val_to_str(opcode, VALS(qsig_str_operation));
  if (p) {
    proto_item_append_text(ti, ": %s", p);
    proto_item_append_text(rctx->d.code_item, " - %s", p);
    if (rctx->apdu_depth >= 0)
      proto_item_append_text(proto_item_get_parent_nth(proto_tree_get_parent(tree), rctx->apdu_depth), " %s", p);
  }

  ti_tmp = proto_tree_add_uint(qsig_tree, hf_qsig_service, tvb, 0, 0, service);
  p = try_val_to_str(service, VALS(qsig_str_service_name));
  if (p) proto_item_append_text(ti_tmp, " - %s", p);

  if (op_ptr->res_pdu)
    offset = op_ptr->res_pdu(tvb, pinfo, qsig_tree, NULL);
  else
    if (tvb_reported_length_remaining(tvb, offset) > 0) {
      proto_tree_add_expert(tree, pinfo, &ei_qsig_unsupported_result_type, tvb, offset, -1);
      offset += tvb_captured_length_remaining(tvb, offset);
    }

  return offset;
}
void connman_service_set_property_error_callback(const char *path,
				connman_property_set_cb_f property_set_cb,
				void *user_data)
{
	struct connman_service *service;

	service = get_service(path);
	if (service == NULL)
		return;

	service->property_set_error_cb = property_set_cb;
	service->property_set_error_user_data = user_data;
}
Exemple #27
0
void Messenger::socket_sub_recv() {
    new std::thread([this]{
        while (true) {
            zmq::message_t message;
            sub_socket_.recv(&message);
            auto* response = new RawMessage(&message);

            get_service().post([this, response]{
                queue_.push_back(std::unique_ptr<RawMessage>(response));
                delete response;
            });
        }
    });
}
static void service_changed_signal_cb(DBusMessageIter *iter)
{
	DBusMessageIter array, strt;
	char *obj_path;
	int arg_type;

	if (service_if == NULL)
		return;

	g_slist_free(service_if->ordered_services);
	service_if->ordered_services = NULL;

	dbus_message_iter_recurse(iter, &array);

	arg_type = dbus_message_iter_get_arg_type(&array);
	while (arg_type != DBUS_TYPE_INVALID) {
		dbus_message_iter_recurse(&array, &strt);

		cui_dbus_get_basic(&strt, DBUS_TYPE_OBJECT_PATH, &obj_path);

		dbus_message_iter_next(&strt);
		update_or_create_service(obj_path, &strt);

		dbus_message_iter_next(&array);
		arg_type = dbus_message_iter_get_arg_type(&array);
	}

	dbus_message_iter_next(iter);
	dbus_message_iter_recurse(iter, &array);

	arg_type = dbus_message_iter_get_arg_type(&array);
	while (arg_type != DBUS_TYPE_INVALID) {
		struct connman_service *service;

		cui_dbus_get_basic(&array, DBUS_TYPE_OBJECT_PATH, &obj_path);

		service = get_service(obj_path);
		if (service != NULL) {
			g_hash_table_remove(service_if->services, obj_path);
			if (service_if->removed_cb != NULL)
				service_if->removed_cb(obj_path);
		}

		dbus_message_iter_next(&array);
		arg_type = dbus_message_iter_get_arg_type(&array);
	}

	if (service_if->refreshed == TRUE)
		call_refresh_callback();
}
void connman_service_deselect(void)
{
	struct connman_service *service, *service_in_ht;

	if (service_if == NULL || service_if->selected_service == NULL)
		return;

	service = service_if->selected_service;
	service_if->selected_service = NULL;

	service_in_ht = get_service(service->path);
	if (service_in_ht == NULL)
		service_free(service);
}
gboolean connman_service_is_connected(const char *path)
{
	struct connman_service *service;

	service = get_service(path);
	if (service == NULL)
		return FALSE;

	if (service->state == CONNMAN_STATE_READY ||
				service->state == CONNMAN_STATE_ONLINE)
		return TRUE;

	return FALSE;
}