static void infinoted_plugin_document_stream_chat_send_message( InfinotedPluginDocumentStreamStream* stream, const InfChatBufferMessage* ms) { guint32 comm; guint64 timestamp; guint16 type; guint16 namelen; guint16 textlen; gboolean alive; comm = 6; /* CHAT */ timestamp = (guint64)ms->time; type = (guint16)ms->type; namelen = strlen(inf_user_get_name(ms->user)); textlen = ms->length; alive = infinoted_plugin_document_stream_send(stream, &comm, 4); if(alive) alive = infinoted_plugin_document_stream_send(stream, ×tamp, 8); if(alive) alive = infinoted_plugin_document_stream_send(stream, &type, 2); if(alive) alive = infinoted_plugin_document_stream_send(stream, &namelen, 2); if(alive) alive = infinoted_plugin_document_stream_send(stream, inf_user_get_name(ms->user), namelen); if(alive) alive = infinoted_plugin_document_stream_send(stream, &textlen, 2); if(alive && textlen > 0) alive = infinoted_plugin_document_stream_send(stream, ms->text, textlen); }
static gboolean inf_user_table_lookup_user_by_name_func(gpointer key, gpointer value, gpointer data) { const gchar* user_name; user_name = inf_user_get_name(INF_USER(value)); if(strcmp(user_name, (const gchar*)data) == 0) return TRUE; return FALSE; }
static void inf_chat_test_buffer_receive_message_cb(InfChatSession* session, InfChatBufferMessage* message, gpointer user_data) { switch(message->type) { case INF_CHAT_BUFFER_MESSAGE_NORMAL: printf("<%s> %s\n", inf_user_get_name(message->user), message->text); break; case INF_CHAT_BUFFER_MESSAGE_EMOTE: printf(" * %s %s\n", inf_user_get_name(message->user), message->text); break; case INF_CHAT_BUFFER_MESSAGE_USERJOIN: printf(" --> %s has joined\n", inf_user_get_name(message->user)); break; case INF_CHAT_BUFFER_MESSAGE_USERPART: printf(" <-- %s has left\n", inf_user_get_name(message->user)); break; } }
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 void user_name_data_func (GtkTreeViewColumn *tree_column, GtkCellRenderer *cell, GtkTreeModel *tree_model, GtkTreeIter *iter, GeditCollaborationWindowHelper *helper) { InfUser *user; InfUserStatus status; const gchar *name; GtkStyle *style; GdkColor *color; PangoStyle user_style; gtk_tree_model_get (tree_model, iter, GEDIT_COLLABORATION_USER_STORE_COLUMN_USER, &user, -1); name = inf_user_get_name (user); status = inf_user_get_status (user); style = gtk_widget_get_style (helper->priv->tree_view_user_view); if (status == INF_USER_ACTIVE) { color = &style->fg[GTK_STATE_NORMAL]; user_style = PANGO_STYLE_NORMAL; } else { color = &style->fg[GTK_STATE_INSENSITIVE]; user_style = PANGO_STYLE_ITALIC; } g_object_set (cell, "text", name, "style", user_style, "foreground-gdk", color, NULL); g_object_unref (user); }
static gboolean infinoted_plugin_transformation_protection_check_request_cb(InfAdoptedSession* session, InfAdoptedRequest* request, InfAdoptedUser* user, gpointer user_data) { InfinotedPluginTransformationProtectionSessionInfo* info; guint vdiff; InfXmlConnection* connection; gchar* request_str; gchar* current_str; gchar* remote_id; gchar* path; info = (InfinotedPluginTransformationProtectionSessionInfo*)user_data; vdiff = inf_adopted_state_vector_vdiff( inf_adopted_request_get_vector(request), inf_adopted_algorithm_get_current( inf_adopted_session_get_algorithm(session) ) ); if(vdiff > info->plugin->max_vdiff) { connection = inf_user_get_connection(INF_USER(user)); /* Local requests do not need to be transformed, so always have a * zero vdiff. */ g_assert(connection != NULL); /* Kill the connection */ infd_session_proxy_unsubscribe( INFD_SESSION_PROXY(info->proxy), connection ); /* Write a log message */ path = inf_browser_get_path( INF_BROWSER( infinoted_plugin_manager_get_directory(info->plugin->manager) ), &info->iter ); request_str = inf_adopted_state_vector_to_string( inf_adopted_request_get_vector(request) ); current_str = inf_adopted_state_vector_to_string( inf_adopted_algorithm_get_current( inf_adopted_session_get_algorithm(session) ) ); g_object_get(G_OBJECT(connection), "remote-id", &remote_id, NULL); infinoted_log_warning( infinoted_plugin_manager_get_log(info->plugin->manager), _("In document \"%s\": Attempt to transform request \"%s\" to current state \"%s\" " "(vdiff=%u) by user \"%s\" (id=%u, conn=%s). Maximum allowed is %u; the " "connection has been unsubscribed."), path, request_str, current_str, vdiff, inf_user_get_name(INF_USER(user)), inf_user_get_id(INF_USER(user)), remote_id, info->plugin->max_vdiff ); g_free(path); g_free(request_str); g_free(current_str); g_free(remote_id); /* Prevent the request from being transformed */ return TRUE; } return FALSE; }