Beispiel #1
0
int session_mgr_remove(session_mgr_t *mgr, int id)
{
	if (mgr == NULL || id < 0) {
		LOG_ERROR("Invalid session mgr or id");
		return ZISS_ERROR;
	}

	if (mgr->session_list == NULL) {
		LOG_ERROR("Invalid session list");
		return ZISS_ERROR;
	}

	if (mgr->session_list->id == id) {
		session_t *session_del = mgr->session_list;
		mgr->session_list = mgr->session_list->next;

		session_stop(session_del);
		session_delete(session_del);
		session_del = NULL;
		return ZISS_OK;
	}

	session_t *s = mgr->session_list;
	while (s->next != NULL) {
		if (s->next->id == id) {
			session_t *session_del = s->next;
			s->next = s->next->next;

			session_stop(session_del);
			session_delete(session_del);
			session_del = NULL;
			return ZISS_OK;
		} else {
			s = s->next;
		}
	}

	LOG_WARN("Session id not found");
	return ZISS_OK;
}
Beispiel #2
0
static void
session_command_autoresume (EphySession *session,
			    guint32 user_time)
{
	EphySessionPrivate *priv = session->priv;
	GFile *saved_session_file;
	char *saved_session_file_path;
	gboolean crashed_session;
	EphyPrefsRestoreSessionPolicy policy;

	LOG ("ephy_session_autoresume");

	saved_session_file = get_session_file (SESSION_STATE);
	saved_session_file_path = g_file_get_path (saved_session_file);
	g_object_unref (saved_session_file);
	crashed_session = g_file_test (saved_session_file_path, G_FILE_TEST_EXISTS);
	
	g_free (saved_session_file_path);

	policy = g_settings_get_enum (EPHY_SETTINGS_MAIN,
				      EPHY_PREFS_RESTORE_SESSION_POLICY);

	if (crashed_session == FALSE ||
	    policy == EPHY_PREFS_RESTORE_SESSION_POLICY_NEVER ||
	    priv->windows != NULL ||
	    priv->tool_windows != NULL)
	{
		/* If we are auto-resuming, and we never want to
		 * restore the session, clobber the session state
		 * file. */
		if (policy == EPHY_PREFS_RESTORE_SESSION_POLICY_NEVER)
			session_delete (session, SESSION_STATE);

		ephy_session_queue_command (session,
					    EPHY_SESSION_CMD_MAYBE_OPEN_WINDOW,
					    NULL, NULL, user_time, FALSE);

		return;
	}

	if (priv->resume_window)
	{
		gtk_window_present_with_time (GTK_WINDOW (priv->resume_window),
					      user_time);

		return;
	}

	ephy_session_queue_command (session,
				    EPHY_SESSION_CMD_LOAD_SESSION,
				    SESSION_STATE, NULL, user_time, TRUE);
}
Beispiel #3
0
int session_mgr_check(session_mgr_t *mgr)
{
	if (mgr == NULL) {
		LOG_ERROR("Invalid session mgr");
		return ZISS_ERROR;
	}

	if (mgr->session_list == NULL)
		return ZISS_OK;

	if (mgr->session_list->is_to_exit) {	// TODO: lock here
		session_t *session_del = mgr->session_list;
		mgr->session_list = mgr->session_list->next;

		session_stop(session_del);
		session_delete(session_del);
		session_del = NULL;
		return ZISS_OK;
	}

	session_t *s = mgr->session_list;
	while (s->next != NULL) {
		if (s->next->is_to_exit) {	// TODO: lock here
			session_t *session_del = s->next;
			s->next = s->next->next;

			session_stop(session_del);
			session_delete(session_del);
			session_del = NULL;
			return ZISS_OK;
		} else {
			s = s->next;
		}
	}

	return ZISS_OK;
}
Beispiel #4
0
void sessions_do_events(sessions_t *sessions)
{
	static NBBOOL recursion = FALSE;
/*	sessions_print(sessions); */

	if(recursion)
	{
		/*fprintf(stderr, "Skipping do_events to prevent infinite recursion.\n");*/
		return;
	}

	/* Make sure this won't infinitely recurse. */
	recursion = TRUE;

	/* See if any sessions have timed out. */
	sessions_expire(sessions);

	/* Check for EOF. */
	if(sessions->is_eof && !sessions_data_waiting(sessions))
	{
		fprintf(stderr, "EOF detected and buffers are empty; terminating.\n");
		exit(0);
	}

	/* If we're in 'exec' mode, do housekeeping. */
	if(sessions->exec)
	{
		/* Check if any terminated processes are finished. */
		session_t *session = sessions->first_session;

		while(session)
		{
			if(session->is_eof && !session_data_waiting(sessions, session->name))
			{
				fprintf(stderr, "Process is finished and data has been sent; closing session\n");
				session_delete(sessions, session->name);
				session = sessions->first_session;
			}
			else
			{
				session = (session_t*)session->next_session;
			}
		}
	}

	/* Infinite recursion is no longer an issue. */
	recursion = FALSE;
}
Beispiel #5
0
int session_mgr_clear(session_mgr_t *mgr)
{
	if (mgr == NULL) {
		LOG_ERROR("Invalid session mgr");
		return ZISS_ERROR;
	}

	while (mgr->session_list != NULL) {
		session_t *temp = mgr->session_list;
		mgr->session_list = mgr->session_list->next;
		
		session_stop(temp);
		session_delete(temp);
		temp = NULL;
	}

	return ZISS_OK;
}
Beispiel #6
0
PUBLIC BOOL HTMuxSession_setClose (HTMuxChannel * muxch,
				   HTMuxSession * session, HTMuxClose close)
{
    if (muxch && session) {
	session->close |= close;

	/*
	**  If both directions are closed down then we can put the session
	**  to sleep.
	*/
	if (session->close == MUX_S_END) {
	    HTTRACE(MUX_TRACE, "Mux Channel. Closing session %d on channel %p\n" _ 
			session->sid _ muxch);
	    muxch->sessions[session->sid] = NULL;
	    session_delete(session);
	}
	return YES;
    }
    return NO;
}
Beispiel #7
0
void sessions_expire(sessions_t *sessions)
{
	/* Start at the first session. */
	session_t *session = sessions->first_session;

	while(session)
	{
		/* Check if the session has timed out. */
		if((time(NULL) - session->last_seen) > sessions->timeout)
		{
			/* If it has, delete the session and start over (we don't want to be in the middle of
			 * walking a list when we delete something from it). */
			fprintf(stderr, "Session timed out: %s\n", session->name);
			session_delete(sessions, session->name);
			session = sessions->first_session;
		}
		else
		{
			session = (session_t*)session->next_session;
		}
	}
}
Beispiel #8
0
void
pannode_delete (struct pan_node *xq)
{
  gint id;

  acc_debug ("delete accxq: %p\n", xq);

  if (xq->accxq && xq->accxq->panlist)
    {
      xq->accxq->panlist = g_list_remove (xq->accxq->panlist, xq);
    }

  if (GTK_IS_NOTEBOOK (xq->parent))
    {
      id = gtk_notebook_page_num (GTK_NOTEBOOK (xq->parent), xq->widget);
      gtk_notebook_remove_page (GTK_NOTEBOOK (xq->parent), id);
    }

  if (xq->qipu)
    {
      qipu_destroy (xq->qipu);
    }

  g_list_free (xq->cur_moves);
  xq->cur_moves = NULL;

  if (xq->parterthread)
    {
      g_thread_join (xq->parterthread);
    }
  session_delete (xq->session);
  if (xq->name)
    {
      g_free (xq->name);
    }
  free (xq);
}