コード例 #1
0
static void
infinoted_plugin_linekeeper_remove_user(
  InfinotedPluginLinekeeperSessionInfo* info)
{
  InfSession* session;
  InfUser* user;

  g_assert(info->user != NULL);
  g_assert(info->request == NULL);

  user = info->user;
  info->user = NULL;

  g_object_get(G_OBJECT(info->proxy), "session", &session, NULL); 

  inf_session_set_user_status(session, user, INF_USER_UNAVAILABLE);
  g_object_unref(user);

  inf_signal_handlers_disconnect_by_func(
    G_OBJECT(info->buffer),
    G_CALLBACK(infinoted_plugin_linekeeper_text_inserted_cb),
    info
  );

  inf_signal_handlers_disconnect_by_func(
    G_OBJECT(info->buffer),
    G_CALLBACK(infinoted_plugin_linekeeper_text_erased_cb),
    info
  );

  g_object_unref(session);
}
コード例 #2
0
ファイル: folder-commands.cpp プロジェクト: JohnCC330/gobby
	bool on_activation_timeout()
	{
		// The user activated this document, but did not something for
		// a while, so explicitely set the user active
		g_assert(m_active);
		g_assert(m_active_user != NULL);
		g_assert(inf_user_get_status(m_active_user) ==
		         INF_USER_INACTIVE);

		inf_session_set_user_status(
			INF_SESSION(m_view.get_session()), m_active_user,
			INF_USER_ACTIVE);

		return false;
	}
コード例 #3
0
ファイル: folder-commands.cpp プロジェクト: JohnCC330/gobby
	void deactivate_user()
	{
		g_assert(m_active_user != NULL);

		switch(inf_user_get_status(m_active_user))
		{
		case INF_USER_INACTIVE:
			g_assert(m_timeout_connection.connected());
			m_timeout_connection.disconnect();
			break;
		case INF_USER_ACTIVE:
			/* Flush pending requests, so user is not set active
			 * again later. TODO: Maybe this should become a
			 * virtual function in InfSession actually. */
			flush();

			inf_session_set_user_status(
				INF_SESSION(m_view.get_session()),
				m_active_user, INF_USER_INACTIVE);
			break;
		case INF_USER_UNAVAILABLE:
			// It can happen that the user is already unavailable
			// here, for example when we have lost the connection
			// to the server, so this is not an error.

			// If the user was active before we lost the
			// connection then cancel the activation timeout
			if(m_timeout_connection.connected())
				m_timeout_connection.disconnect();

			// TODO: Shouldn't local users stay available on
			// connection loss? We probably need to fix this
			// in infinote.
			break;
		}
	}
コード例 #4
0
static void
infinoted_plugin_document_stream_stop(
  InfinotedPluginDocumentStreamStream* stream,
  gboolean send_stop)
{
  guint32 comm;
  InfSession* session;

  if(send_stop)
  {
    comm = 5; /* STOP */
    if(!infinoted_plugin_document_stream_send(stream, &comm, 4))
      return;
  }

  if(stream->user != NULL)
  {
    g_assert(stream->proxy != NULL);
    g_object_get(G_OBJECT(stream->proxy), "session", &session, NULL);
    inf_session_set_user_status(session, stream->user, INF_USER_UNAVAILABLE);
    g_object_unref(session);

    g_object_unref(stream->user);
    stream->user = NULL;
  }

  if(stream->proxy != NULL)
  {
    g_object_unref(stream->proxy);
    stream->proxy = NULL;
  }

  if(stream->buffer != NULL)
  {
    if(INF_TEXT_IS_BUFFER(stream->buffer))
    {
      inf_signal_handlers_disconnect_by_func(
        G_OBJECT(stream->buffer),
        G_CALLBACK(infinoted_plugin_document_stream_text_inserted_cb),
        stream
      );

      inf_signal_handlers_disconnect_by_func(
        G_OBJECT(stream->buffer),
        G_CALLBACK(infinoted_plugin_document_stream_text_erased_cb),
        stream
      );
    }
    else if(INF_IS_CHAT_BUFFER(stream->buffer))
    {
      inf_signal_handlers_disconnect_by_func(
        G_OBJECT(stream->buffer),
        G_CALLBACK(infinoted_plugin_document_stream_chat_add_message_cb),
        stream
      );
    }

    g_object_unref(stream->buffer);
    stream->buffer = NULL;
  }

  if(stream->subscribe_request != NULL)
  {
    inf_signal_handlers_disconnect_by_func(
      G_OBJECT(stream->subscribe_request),
      G_CALLBACK(infinoted_plugin_document_stream_subscribe_func),
      stream
    );

    stream->subscribe_request = NULL;
  }

  if(stream->user_request != NULL)
  {
    inf_signal_handlers_disconnect_by_func(
      G_OBJECT(stream->user_request),
      G_CALLBACK(infinoted_plugin_document_stream_user_join_func),
      stream
    );

    stream->user_request = NULL;
  }
}
コード例 #5
0
void Gobby::UserJoinCommands::on_document_removed(InfBrowser* browser,
                                                  const InfBrowserIter* iter,
                                                  InfSessionProxy* proxy,
                                                  Folder& folder,
                                                  SessionView& view)
{
	g_assert(proxy != NULL);

	UserJoinMap::iterator user_iter = m_user_join_map.find(proxy);

	// If the user join was successful the session is no longer in the map
	if(user_iter != m_user_join_map.end())
	{
		delete user_iter->second;
		m_user_join_map.erase(user_iter);
	}
	else
	{
		// The user has removed the document. What we do now depends
		// on whether we are hosting the document or whether we are a
		// client. If we are a client we reset the connection of the
		// session proxy, which basically leads to us being
		// unsubscribed from the document. If we are hosting the
		// document, we do not want to unsubscribe from it, since
		// other users might still be connected. We therefore only
		// remove the local user from the session. If there are indeed
		// no other clients, then InfdDirectory will take care of
		// unsubscribing the session 60s after it became idle.
		if(INFD_IS_SESSION_PROXY(proxy))
		{
			InfUser* user = view.get_active_user();
			if(user != NULL)
			{
				InfSession* session;
				g_object_get(G_OBJECT(proxy), "session",
				             &session, NULL);
				inf_session_set_user_status(
					session, user, INF_USER_UNAVAILABLE);
				g_object_unref(session);

				// TODO: set_active_user should go to
				// SessionView base:
				// TODO: The libinftextgtk objects should
				// reset the active user automatically when it
				// becomes unavailable.
				TextSessionView* text_view =
					dynamic_cast<TextSessionView*>(&view);
				if(text_view)
					text_view->set_active_user(NULL);
				ChatSessionView* chat_view =
					dynamic_cast<ChatSessionView*>(&view);
				if(chat_view)
					chat_view->set_active_user(NULL);
			}
		}
		else if(INFC_IS_SESSION_PROXY(proxy))
		{
			infc_session_proxy_set_connection(
				INFC_SESSION_PROXY(proxy), NULL, NULL, 0);
		}
	}
}