static void inf_text_gtk_viewport_user_notify_status_cb(GObject* object, GParamSpec* pspec, gpointer user_data) { InfTextGtkViewport* viewport; InfTextGtkViewportPrivate* priv; InfTextUser* user; InfTextGtkViewportUser* viewport_user; viewport = INF_TEXT_GTK_VIEWPORT(user_data); priv = INF_TEXT_GTK_VIEWPORT_PRIVATE(viewport); user = INF_TEXT_USER(object); g_assert(user != priv->active_user); viewport_user = inf_text_gtk_viewport_find_user(viewport, user); if(inf_user_get_status(INF_USER(user)) == INF_USER_ACTIVE) { if(!viewport_user) inf_text_gtk_viewport_add_user(viewport, user); } else { if(viewport_user) inf_text_gtk_viewport_remove_user(viewport_user); } }
static void inf_text_gtk_viewport_add_user(InfTextGtkViewport* viewport, InfTextUser* user) { InfTextGtkViewportPrivate* priv; InfTextGtkViewportUser* viewport_user; priv = INF_TEXT_GTK_VIEWPORT_PRIVATE(viewport); viewport_user = g_slice_new(InfTextGtkViewportUser); viewport_user->viewport = viewport; viewport_user->user = INF_TEXT_USER(user); priv->users = g_slist_prepend(priv->users, viewport_user); inf_text_gtk_viewport_user_compute_user_area(viewport_user); g_signal_connect_after( user, "selection-changed", G_CALLBACK(inf_text_gtk_viewport_user_selection_changed_cb), viewport_user ); g_signal_connect( user, "notify::hue", G_CALLBACK(inf_text_gtk_viewport_user_notify_hue_cb), viewport_user ); inf_text_gtk_viewport_user_invalidate_user_area(viewport_user); }
static void on_join_finished(InfcUserRequest* request, InfUser* user, gpointer user_data) { InfTestGtkBrowserWindow* test; InfAdoptedSession* session; InfAdoptedAlgorithm* algorithm; gboolean undo; gboolean redo; test = (InfTestGtkBrowserWindow*)user_data; inf_text_gtk_buffer_set_active_user(test->buffer, INF_TEXT_USER(user)); gtk_text_view_set_editable(GTK_TEXT_VIEW(test->textview), TRUE); test->user = user; session = INF_ADOPTED_SESSION(infc_session_proxy_get_session(test->proxy)); algorithm = inf_adopted_session_get_algorithm(session); undo = inf_adopted_algorithm_can_undo(algorithm, INF_ADOPTED_USER(user)); redo = inf_adopted_algorithm_can_redo(algorithm, INF_ADOPTED_USER(user)); gtk_widget_set_sensitive(test->undo_button, undo); gtk_widget_set_sensitive(test->redo_button, redo); }
static void inf_text_gtk_viewport_set_user_table_foreach_old_user_func(InfUser* user, gpointer user_data) { InfTextGtkViewport* viewport = INF_TEXT_GTK_VIEWPORT(user_data); g_assert(INF_TEXT_IS_USER(user)); inf_text_gtk_viewport_user_removed(viewport, INF_TEXT_USER(user)); }
static void inf_text_gtk_viewport_remove_user_cb(InfUserTable* user_table, InfUser* user, gpointer user_data) { InfTextGtkViewport* viewport = INF_TEXT_GTK_VIEWPORT(user_data); g_assert(INF_TEXT_IS_USER(user)); inf_text_gtk_viewport_user_removed(viewport, INF_TEXT_USER(user)); }
virtual void flush() { DocInfo::flush(); g_assert(m_active_user != NULL); inf_text_session_flush_requests_for_user( INF_TEXT_SESSION(m_view.get_session()), INF_TEXT_USER(m_active_user)); }
static void inf_text_gtk_viewport_set_property(GObject* object, guint prop_id, const GValue* value, GParamSpec* pspec) { InfTextGtkViewport* viewport; InfTextGtkViewportPrivate* priv; viewport = INF_TEXT_GTK_VIEWPORT(object); priv = INF_TEXT_GTK_VIEWPORT_PRIVATE(viewport); switch(prop_id) { case PROP_SCROLLED_WINDOW: g_assert(priv->scroll == NULL); /* construct only */ inf_text_gtk_viewport_set_scrolled_window( viewport, GTK_SCROLLED_WINDOW(g_value_get_object(value)) ); break; case PROP_USER_TABLE: g_assert(priv->user_table == NULL); /* construct/only */ inf_text_gtk_viewport_set_user_table( viewport, INF_USER_TABLE(g_value_get_object(value)) ); break; case PROP_ACTIVE_USER: inf_text_gtk_viewport_set_active_user( viewport, INF_TEXT_USER(g_value_get_object(value)) ); break; case PROP_SHOW_USER_MARKERS: inf_text_gtk_viewport_set_show_user_markers( viewport, g_value_get_boolean(value) ); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID(value, prop_id, pspec); break; } }
void Gobby::UserJoinCommands::UserJoinInfo::user_join_complete(InfUser* user) { // TODO: Notify the user about alternative user name if s/he uses any m_view.unset_info(); // TODO: set_active_user should maybe go to SessionView base: TextSessionView* text_view = dynamic_cast<TextSessionView*>(&m_view); if(text_view) text_view->set_active_user(INF_TEXT_USER(user)); ChatSessionView* chat_view = dynamic_cast<ChatSessionView*>(&m_view); if(chat_view) chat_view->set_active_user(user); finish(); }
static void infd_note_plugin_text_session_write_foreach_user_func(InfUser* user, gpointer user_data) { xmlNodePtr parent; xmlNodePtr node; parent = (xmlNodePtr)user_data; node = xmlNewChild(parent, NULL, (const xmlChar*)"user", NULL); inf_xml_util_set_attribute_uint(node, "id", inf_user_get_id(user)); inf_xml_util_set_attribute(node, "name", inf_user_get_name(user)); inf_xml_util_set_attribute_double( node, "hue", inf_text_user_get_hue(INF_TEXT_USER(user)) ); }
static gboolean perform_test(guint max_total_log_size, InfTextChunk* initial, GSList* users, GSList* requests, GError** error) { InfTextBuffer* buffer; InfCommunicationManager* manager; InfIo* io; InfTextSession* session; InfAdoptedAlgorithm* algorithm; InfUserTable* user_table; InfTextUser* user; gchar* user_name; GSList* item; xmlNodePtr request; gboolean result; GError* local_error; guint verify_user_id; InfAdoptedUser* verify_user; guint verify_log_size; gint verify_can_undo; gint verify_can_redo; InfAdoptedRequestLog* log; guint log_size; buffer = INF_TEXT_BUFFER(inf_text_default_buffer_new("UTF-8")); inf_text_buffer_insert_chunk(buffer, 0, initial, NULL); manager = inf_communication_manager_new(); io = INF_IO(inf_standalone_io_new()); user_table = inf_user_table_new(); local_error = NULL; for(item = users; item != NULL; item = g_slist_next(item)) { user_name = g_strdup_printf("User_%u", GPOINTER_TO_UINT(item->data)); user = INF_TEXT_USER( g_object_new( INF_TEXT_TYPE_USER, "id", GPOINTER_TO_UINT(item->data), "name", user_name, "status", INF_USER_ACTIVE, "flags", 0, NULL ) ); g_free(user_name); inf_user_table_add_user(user_table, INF_USER(user)); g_object_unref(user); } session = INF_TEXT_SESSION( g_object_new( INF_TEXT_TYPE_SESSION, "communication-manager", manager, "buffer", buffer, "io", io, "user_table", user_table, "max-total-log-size", max_total_log_size, NULL ) ); algorithm = inf_adopted_session_get_algorithm(INF_ADOPTED_SESSION(session)); g_object_unref(io); g_object_unref(manager); g_object_unref(user_table); g_object_unref(buffer); for(item = requests; item != NULL; item = item->next) { request = (xmlNodePtr)item->data; if(strcmp((const char*)request->name, "request") == 0) { /* Request */ result = inf_communication_object_received( INF_COMMUNICATION_OBJECT(session), NULL, request, &local_error ); if(local_error != NULL) goto fail; } else { /* TODO: Make an extra function out of this: */ /* Verify */ result = inf_xml_util_get_attribute_uint_required( request, "user", &verify_user_id, &local_error ); if(result == FALSE) goto fail; verify_user = INF_ADOPTED_USER( inf_user_table_lookup_user_by_id(user_table, verify_user_id) ); if(verify_user == NULL) { g_set_error( error, inf_test_text_cleanup_error_quark(), INF_TEST_TEXT_CLEANUP_USER_UNAVAILABLE, "User ID '%u' not available", verify_user_id ); goto fail; } result = inf_xml_util_get_attribute_uint( request, "log-size", &verify_log_size, &local_error ); if(local_error) goto fail; if(result) { log = inf_adopted_user_get_request_log(INF_ADOPTED_USER(verify_user)); log_size = inf_adopted_request_log_get_end(log) - inf_adopted_request_log_get_begin(log); if(verify_log_size != log_size) { g_set_error( error, inf_test_text_cleanup_error_quark(), INF_TEST_TEXT_CLEANUP_VERIFY_FAILED, "Log size does not match; got %u, but expected %u", log_size, verify_log_size ); goto fail; } } result = inf_xml_util_get_attribute_int( request, "can-undo", &verify_can_undo, &local_error ); if(local_error) goto fail; if(result) { result = inf_adopted_algorithm_can_undo(algorithm, verify_user); if(result != verify_can_undo) { g_set_error( error, inf_test_text_cleanup_error_quark(), INF_TEST_TEXT_CLEANUP_VERIFY_FAILED, "can-undo does not match; got %d, but expected %d", (guint)result, verify_can_undo ); goto fail; } } result = inf_xml_util_get_attribute_int( request, "can-redo", &verify_can_redo, &local_error ); if(local_error) goto fail; if(result) { result = inf_adopted_algorithm_can_redo(algorithm, verify_user); if(result != verify_can_redo) { g_set_error( error, inf_test_text_cleanup_error_quark(), INF_TEST_TEXT_CLEANUP_VERIFY_FAILED, "can-redo does not match; got %d, but expected %d", (guint)result, verify_can_redo ); goto fail; } } } } g_object_unref(session); return TRUE; fail: g_object_unref(session); if(local_error) g_propagate_error(error, local_error); return FALSE; }