static void
remove_chat (InfcBrowser                    *browser,
             GeditCollaborationWindowHelper *helper)
{
	GtkWidget *chat;
	GeditPanel *panel;
	InfXmlConnection *connection;
	InfcSessionProxy *proxy;

	proxy = infc_browser_get_chat_session (browser);

	if (proxy != NULL)
	{
		InfSession *session;

		session = infc_session_proxy_get_session (proxy);
		inf_session_close (session);
	}

	connection = infc_browser_get_connection (browser);

	chat = GTK_WIDGET (g_object_get_data (G_OBJECT (connection),
	                                      CHAT_DATA_KEY));

	if (chat != NULL)
	{
		panel = gedit_window_get_bottom_panel (helper->priv->window);
		gedit_panel_remove_item (panel, chat);

		g_object_set_data (G_OBJECT (connection), CHAT_DATA_KEY, NULL);
	}
}
Exemplo n.º 2
0
static void
inf_chat_test_session_synchronization_complete_cb(InfSession* session,
                                                  InfXmlConnection* connection,
                                                  gpointer user_data)
{
  InfTestChat* test;
  InfcSessionProxy* proxy;
  InfcUserRequest* request;
  GParameter params[1] = { { "name", { 0 } } };
  GError* error;

  printf("Synchronization complete, joining user...\n");

  test = (InfTestChat*)user_data;
  proxy = infc_browser_get_chat_session(test->browser);

  g_value_init(&params[0].value, G_TYPE_STRING);
  g_value_set_string(&params[0].value, g_get_user_name());

  error = NULL;
  request = infc_session_proxy_join_user(
    proxy,
    params,
    G_N_ELEMENTS(params),
    &error
  );

  g_value_unset(&params[0].value);

  if(!request)
  {
    fprintf(stderr, "User join failed: %s\n", error->message);
    g_error_free(error);

    inf_standalone_io_loop_quit(test->io);
  }
  else
  {
    g_signal_connect_after(
      G_OBJECT(request),
      "failed",
      G_CALLBACK(inf_test_chat_userjoin_failed_cb),
      test
    );

    g_signal_connect_after(
      G_OBJECT(request),
      "finished",
      G_CALLBACK(inf_test_chat_userjoin_finished_cb),
      test
    );
  }
}
Exemplo n.º 3
0
static void
inf_chat_test_subscribe_finished_cb(InfcNodeRequest* request,
                                    const InfcBrowserIter* iter,
                                    gpointer user_data)
{
  InfTestChat* test;
  InfSession* session;
  test = (InfTestChat*)user_data;

  printf("Subscription successful, waiting for synchronization...\n");

  session = infc_session_proxy_get_session(
    infc_browser_get_chat_session(test->browser));

  test->buffer = INF_CHAT_BUFFER(inf_session_get_buffer(session));

  /* TODO: Show backlog after during/after synchronization */

  g_signal_connect_after(
    G_OBJECT(session),
    "receive-message",
    G_CALLBACK(inf_chat_test_buffer_receive_message_cb),
    test
  );

  g_signal_connect_after(
    G_OBJECT(session),
    "synchronization-complete",
    G_CALLBACK(inf_chat_test_session_synchronization_complete_cb),
    test
  );

  g_signal_connect_after(
    G_OBJECT(session),
    "synchronization-failed",
    G_CALLBACK(inf_chat_test_session_synchronization_failed_cb),
    test
  );

  /* This can happen when the server disables the chat without being
   * shutdown. */
  g_signal_connect_after(
    G_OBJECT(session),
    "close",
    G_CALLBACK(inf_chat_test_session_close_cb),
    test
  );
}
static void
subscribe_chat_cb (InfcNodeRequest *infcnoderequest,
                   InfcBrowserIter *iter,
                   gpointer         data)
{
	InfcSessionProxy *proxy;
	InfSession *session;
	ChatData *cdata = (ChatData *) data;
	GtkWidget *chat;

	proxy = infc_browser_get_chat_session (cdata->browser);

	if (proxy == NULL)
	{
		free_chat_data (data);
		return;
	}

	session = infc_session_proxy_get_session (proxy);
	cdata->proxy = proxy;

	chat = inf_gtk_chat_new ();
	cdata->chat = chat;

	inf_gtk_chat_set_session (INF_GTK_CHAT (chat),
	                          INF_CHAT_SESSION (session));

	g_signal_connect_after (session,
	                        "synchronization-failed",
	                        G_CALLBACK (sync_failed),
	                        data);

	g_signal_connect_after (session,
	                        "synchronization-complete",
	                        G_CALLBACK (sync_completed),
	                        data);
}