Пример #1
0
void __connman_agent_cleanup(void)
{
	DBusMessage *message;

	DBG("");

	if (connection == NULL)
		return;

	if (agent_watch > 0)
		g_dbus_remove_watch(connection, agent_watch);

	if (agent_path == NULL)
		return;

	message = dbus_message_new_method_call(agent_sender, agent_path,
					CONNMAN_AGENT_INTERFACE, "Release");
	if (message == NULL)
		return;

	dbus_message_set_no_reply(message, TRUE);

	g_dbus_send_message(connection, message);

	agent_free();

	dbus_connection_unref(connection);
}
Пример #2
0
static DBusMessage *unregister_agent(DBusConnection *conn,
					DBusMessage *msg, void *data)
{
	const char *path, *sender;

	if (!agent)
		return agent_does_not_exist(msg);

	if (!dbus_message_get_args(msg, NULL,
				DBUS_TYPE_OBJECT_PATH, &path,
				DBUS_TYPE_INVALID))
		return invalid_args(msg);

	if (strcmp(agent->path, path) != 0)
		return agent_does_not_exist(msg);

	sender = dbus_message_get_sender(msg);
	if (strcmp(agent->bus_name, sender) != 0)
		return not_authorized(msg);

	g_dbus_remove_watch(conn, agent->watch_id);

	agent_free(agent);
	agent = NULL;

	DBG("Agent unregistered");

	return dbus_message_new_method_return(msg);
}
Пример #3
0
static DBusMessage *unregister_agent(DBusConnection *conn,
				DBusMessage *msg, void *data)
{
	struct audio_device *device = data;
	struct gateway *gw = device->gateway;
	const char *path;

	if (!gw->agent)
		goto done;

	if (strcmp(gw->agent->name, dbus_message_get_sender(msg)) != 0)
		return btd_error_not_authorized(msg);

	if (!dbus_message_get_args(msg, NULL,
				DBUS_TYPE_OBJECT_PATH, &path,
				DBUS_TYPE_INVALID))
		return btd_error_invalid_args(msg);

	if (strcmp(gw->agent->path, path) != 0)
		return btd_error_does_not_exist(msg);

	g_dbus_remove_watch(conn, gw->agent->watch);

	agent_free(gw->agent);
	gw->agent = NULL;

done:
	return dbus_message_new_method_return(msg);
}
Пример #4
0
static DBusMessage *am_agent_unregister(DBusConnection *conn,
					DBusMessage *msg, void *user_data)
{
	const char *sender, *path;
	DBusMessageIter iter;

	if (agent == NULL)
		return __ofono_error_not_found(msg);

	sender = dbus_message_get_sender(msg);

	if (dbus_message_iter_init(msg, &iter) == FALSE)
		return __ofono_error_invalid_args(msg);

	dbus_message_iter_get_basic(&iter, &path);

	if (strcmp(sender, agent->owner) != 0)
		return __ofono_error_not_allowed(msg);

	if (strcmp(path, agent->path) != 0)
		return __ofono_error_not_found(msg);

	agent_free(agent);
	agent = NULL;

	has_wideband = FALSE;

	DBG("Agent %s unregistered", sender);

	return dbus_message_new_method_return(msg);
}
Пример #5
0
static DBusMessage *release_agent(DBusConnection *connection,
				DBusMessage *message, void *user_data)
{
	struct session_data *session = user_data;
	struct agent_data *agent = session->agent;
	const gchar *sender;
	gchar *path;

	if (dbus_message_get_args(message, NULL,
					DBUS_TYPE_OBJECT_PATH, &path,
					DBUS_TYPE_INVALID) == FALSE)
		return g_dbus_create_error(message,
				"org.openobex.Error.InvalidArguments",
				"Invalid arguments in method call");

	sender = dbus_message_get_sender(message);

	if (agent == NULL || g_str_equal(sender, agent->name) == FALSE ||
				g_str_equal(path, agent->path) == FALSE)
		return g_dbus_create_error(message,
				"org.openobex.Error.NotAuthorized",
				"Not Authorized");

	agent_free(session);

	return dbus_message_new_method_return(message);
}
Пример #6
0
static void agent_disconnected(DBusConnection *connection, void *user_data)
{
	struct session_data *session = user_data;

	session->agent->watch = 0;

	agent_free(session);
}
Пример #7
0
static void agent_disconnect(DBusConnection *conn, void *user_data)
{
	DBG("Agent %s disconnected", agent->owner);

	agent_free(agent);
	agent = NULL;

	has_wideband = FALSE;
}
Пример #8
0
int agent_destroy(struct agent *agent, gboolean exited)
{
	if (!agent)
		return 0;

	agent->exited = exited;
	agent_free(agent);
	return 0;
}
Пример #9
0
static void agent_exited(DBusConnection *conn, void *user_data)
{
	struct agent *agent = user_data;

	DBG("Agent exited without calling Unregister");

	agent->exited = TRUE;

	agent_free(agent);
}
Пример #10
0
static void agent_exited(DBusConnection *conn, void *data)
{
	struct gateway *gateway = data;
	struct hf_agent *agent = gateway->agent;

	DBG("Agent %s exited", agent->name);

	agent_free(agent);
	gateway->agent = NULL;
}
Пример #11
0
INTERNAL void
agentman(EVENT_AGENTD_REQ *eagent) {
	int        pid, exitstat;
	int        me;
	int        rc;
	AGENT_REQ *areq;

	if (Debug)
	   printf("agentman: starting\n");

	/* Copy arg data into active Agent list & unblock parent */
	mp_lock(AgentLock);

printf("Allocating agent control block\n");
	areq = agent_alloc();
	if (!areq) {
		fprintf(stderr, "agentman: can't start %s\n", eagent->module);
		mp_exit(0);
	}
printf("Initializing agent control block\\n");

	memcpy(&areq->ereq, eagent, sizeof(EVENT_AGENTD_REQ));

	mp_unlock(AgentLock);

	/* Unblock parent thread */
	mp_incsema(AgentInit);

	if (Debug)
	   printf("agentman: starting as thread %d.%d\n", getpid(), mp_gettid());

	areq->pid    = 0;
	areq->status = AGENTD_AGENT_INIT;
	areq->start  = event_clock();

	if (areq->ereq.log[0] && areq->ereq.log[0] != ' ')
	    rc = start_logger(areq, areq->ereq.log, areq->ereq.module, areq->ereq.args, &pid);
	 else
	    rc = start_agent(areq, areq->ereq.module, areq->ereq.args, &pid);

	if (Debug)
	   printf("agentman: thread (%d.%d) done and exiting\n",
		   getpid(), mp_gettid());

	/* Copy to obiturary list */
	if (++Nrip == MAX_RIP) Nrip = 0;
	memcpy(Rip, areq, sizeof(AGENT_REQ));

	/* Remove entry for this agent */
	mp_lock(AgentLock);
	agent_free(areq);
	mp_unlock(AgentLock);

	mp_exit(0);
}
Пример #12
0
void agent_destroy(Agent* agent)
{
  if(agent!=NULL){
	if(agent->agentID==sap_agent_id-1)
		sap_agent_id--;
  }
  agent_detach_from_list(agent);
  agent_manager_list_free(agent->first_manager);
  delete_all_table_from_agent(agent);
  delete_all_subtree_from_agent(agent);
  delete_agent_from_resource_list(agent); 
  agent_free(agent);
}
Пример #13
0
static void agent_release(struct session_data *session)
{
	struct agent_data *agent = session->agent;
	DBusMessage *message;

	message = dbus_message_new_method_call(agent->name,
			agent->path, AGENT_INTERFACE, "Release");

	dbus_message_set_no_reply(message, TRUE);

	g_dbus_send_message(session->conn, message);

	agent_free(session);
}
Пример #14
0
void manager_cleanup(void)
{
	DBG("");

	g_dbus_unregister_interface(connection, OBEX_MANAGER_PATH,
						OBEX_MANAGER_INTERFACE);

	/* FIXME: Release agent? */

	if (agent)
		agent_free(agent);

	dbus_connection_unref(connection);
}
Пример #15
0
int connman_agent_unregister(const char *sender, const char *path)
{
	DBG("sender %s path %s", sender, path);

	if (agent_path == NULL)
		return -ESRCH;

	if (agent_watch > 0)
		g_dbus_remove_watch(connection, agent_watch);

	agent_free();

	return 0;
}
Пример #16
0
void agent_list_delete()
{
	Agent *ap = first_agent;
	Agent *next;


	while(ap)
	{
		next = ap->next_agent;

		agent_free(ap);

		ap = next;
	}

	first_agent = NULL;

	return;
}
Пример #17
0
/**
 * connman_agent_driver_unregister:
 * @driver: Agent driver definition
 *
 * Remove a previously registered agent driver
 */
void connman_agent_driver_unregister(struct connman_agent_driver *driver)
{
	GSList *list;

	if (driver == NULL)
		return;

	DBG("Unregistering driver %p name %s", driver, driver->name);

	if (agent_sender == NULL && agent_path == NULL)
		goto out;

	for (list = driver_list; list; list = list->next) {
		DBusMessage *message;

		if (driver != list->data)
			continue;

		DBG("Sending release to %s path %s iface %s", agent_sender,
			agent_path, driver->interface);

		message = dbus_message_new_method_call(agent_sender, agent_path,
				driver->interface, "Release");
		if (message != NULL) {
			dbus_message_set_no_reply(message, TRUE);
			g_dbus_send_message(connection, message);
		}

		agent_free();

		/*
		 * ATM agent_free() unsets the agent_sender and agent_path
		 * variables so we can unregister only once.
		 * This needs proper fix later.
		 */
		break;
	}

out:
	driver_list = g_slist_remove(driver_list, driver);
}
Пример #18
0
void ofono_handsfree_audio_unref(void)
{
	if (ref_count == 0) {
		ofono_error("Error in handsfree audio manager ref counting");
		return;
	}

	ref_count -= 1;

	if (ref_count > 0)
		return;

	g_dbus_unregister_interface(ofono_dbus_get_connection(),
					OFONO_MANAGER_PATH,
					HFP_AUDIO_MANAGER_INTERFACE);

	if (agent) {
		agent_release(agent);
		agent_free(agent);
	}

	__ofono_handsfree_audio_manager_cleanup();
}
Пример #19
0
/**
 * @brief Deallocate a SSH session handle.
 *
 * @param[in] session   The SSH session to free.
 *
 * @see ssh_disconnect()
 * @see ssh_new()
 */
void ssh_free(ssh_session session) {
  int i;
  struct ssh_iterator *it;

  if (session == NULL) {
    return;
  }

  /*
   * Delete all channels
   *
   * This needs the first thing we clean up cause if there is still an open
   * channel we call ssh_channel_close() first. So we need a working socket
   * and poll context for it.
   */
  for (it = ssh_list_get_iterator(session->channels);
       it != NULL;
       it = ssh_list_get_iterator(session->channels)) {
      ssh_channel_do_free(ssh_iterator_value(ssh_channel,it));
      ssh_list_remove(session->channels, it);
  }
  ssh_list_free(session->channels);
  session->channels = NULL;

#ifdef WITH_PCAP
  if (session->pcap_ctx) {
      ssh_pcap_context_free(session->pcap_ctx);
      session->pcap_ctx = NULL;
  }
#endif

  ssh_socket_free(session->socket);
  session->socket = NULL;

  if (session->default_poll_ctx) {
      ssh_poll_ctx_free(session->default_poll_ctx);
  }

  ssh_buffer_free(session->in_buffer);
  ssh_buffer_free(session->out_buffer);
  session->in_buffer = session->out_buffer = NULL;

  if (session->in_hashbuf != NULL) {
      ssh_buffer_free(session->in_hashbuf);
  }
  if (session->out_hashbuf != NULL) {
      ssh_buffer_free(session->out_hashbuf);
  }

  crypto_free(session->current_crypto);
  crypto_free(session->next_crypto);

#ifndef _WIN32
  agent_free(session->agent);
#endif /* _WIN32 */

  ssh_key_free(session->srv.dsa_key);
  ssh_key_free(session->srv.rsa_key);

  if (session->ssh_message_list) {
      ssh_message msg;

      for (msg = ssh_list_pop_head(ssh_message, session->ssh_message_list);
           msg != NULL;
           msg = ssh_list_pop_head(ssh_message, session->ssh_message_list)) {
          ssh_message_free(msg);
      }
      ssh_list_free(session->ssh_message_list);
  }

  if (session->packet_callbacks) {
    ssh_list_free(session->packet_callbacks);
  }

  /* options */
  if (session->opts.identity) {
      char *id;

      for (id = ssh_list_pop_head(char *, session->opts.identity);
           id != NULL;
           id = ssh_list_pop_head(char *, session->opts.identity)) {
          SAFE_FREE(id);
      }
      ssh_list_free(session->opts.identity);
  }
Пример #20
0
static void agent_disconnect(DBusConnection *conn, void *data)
{
	DBG("data %p", data);
	agent_free();
}
Пример #21
0
static void agent_disconnected(DBusConnection *conn, void *user_data)
{
	DBG("Agent exited");
	agent_free(agent);
	agent = NULL;
}