From 269297401c5b63f3f462a66b2e7652e726ad605a Mon Sep 17 00:00:00 2001 From: Benjamin Franzke Date: Fri, 16 Sep 2011 14:28:22 +0200 Subject: Derive message type from position in .proto file This involves changing the .proto file, to actually reflect the type in the protocol. --- src/Makefile.am | 4 ++-- src/gen_message_list.sed | 16 ++++++++++------ src/messages.txt | 26 -------------------------- src/mumble.proto | 31 +++++++++++++++++-------------- 4 files changed, 29 insertions(+), 48 deletions(-) delete mode 100644 src/messages.txt (limited to 'src') diff --git a/src/Makefile.am b/src/Makefile.am index 567b3f9..18979d0 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -18,12 +18,12 @@ AM_CFLAGS = $(GCC_CFLAGS) BUILT_SOURCES = $(nodist_cmumble_SOURCES) $(nodist_noinst_HEADERS) MAINTAINERCLEANFILES = mumble.pb-c.c mumble.pb-c.h CLEANFILES = message_list.h -EXTRA_DIST = mumble.proto messages.txt gen_message_list.sed +EXTRA_DIST = mumble.proto gen_message_list.sed # Ship files generated by protoc-c in releases, # so that protoc-c (which pulls in the c++ protobuf) is not needed. EXTRA_DIST += mumble.pb-c.c mumble.pb-c.h -message_list.h: $(srcdir)/messages.txt $(srcdir)/gen_message_list.sed +message_list.h: $(srcdir)/mumble.proto $(srcdir)/gen_message_list.sed $(AM_V_GEN) LC_ALL= LC_COLLATE=C $(SED) -f $(srcdir)/gen_message_list.sed $< > $@ mumble.pb-c.c mumble.pb-c.h: $(srcdir)/mumble.proto diff --git a/src/gen_message_list.sed b/src/gen_message_list.sed index f927df4..17b2c16 100644 --- a/src/gen_message_list.sed +++ b/src/gen_message_list.sed @@ -6,6 +6,16 @@ i\ #define MUMBLE_MSGS \\ } +$ { +a\ +\ +#endif /* _MESSAGES_H_ */ +} + +# Isolate message name from .proto file +/^message/!d +s/message[ ]*\([^ ]*\).*$/\1/ + # This code attempts to generate "MUMBLE_MSG(FooBar, foo_bar)" from "FooBar" # Backup original message name @@ -18,9 +28,3 @@ y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ G # Put template macro around (delete newline between both msgs, swap order) s/^\(.*\)\n\(.*\)$/ MUMBLE_MSG(\2, \1) \\/ - -$ { -a\ -\ -#endif /* _MESSAGE_LIST_H_ */ -} diff --git a/src/messages.txt b/src/messages.txt deleted file mode 100644 index 17dba7e..0000000 --- a/src/messages.txt +++ /dev/null @@ -1,26 +0,0 @@ -Version -UDPTunnel -Authenticate -Ping -Reject -ServerSync -ChannelRemove -ChannelState -UserRemove -UserState -BanList -TextMessage -PermissionDenied -ACL -QueryUsers -CryptSetup -ContextActionModify -ContextAction -UserList -VoiceTarget -PermissionQuery -CodecVersion -UserStats -RequestBlob -ServerConfig -SuggestConfig diff --git a/src/mumble.proto b/src/mumble.proto index d2d3c66..33ee20e 100644 --- a/src/mumble.proto +++ b/src/mumble.proto @@ -1,3 +1,6 @@ +/* NOTE: Do not replace this file directly with future mumble.proto. + We derive the message id from the position in this file. */ + package MumbleProto; option optimize_for = SPEED; @@ -49,14 +52,6 @@ message Reject { optional string reason = 2; } -message ServerConfig { - optional uint32 max_bandwidth = 1; - optional string welcome_text = 2; - optional bool allow_html = 3; - optional uint32 message_length = 4; - optional uint32 image_message_length = 5; -} - message ServerSync { optional uint32 session = 1; optional uint32 max_bandwidth = 2; @@ -274,14 +269,22 @@ message UserStats { optional bool strong_certificate = 18 [default = false]; } -message SuggestConfig { - optional uint32 version = 1; - optional bool positional = 2; - optional bool push_to_talk = 3; -} - message RequestBlob { repeated uint32 session_texture = 1; repeated uint32 session_comment = 2; repeated uint32 channel_description = 3; } + +message ServerConfig { + optional uint32 max_bandwidth = 1; + optional string welcome_text = 2; + optional bool allow_html = 3; + optional uint32 message_length = 4; + optional uint32 image_message_length = 5; +} + +message SuggestConfig { + optional uint32 version = 1; + optional bool positional = 2; + optional bool push_to_talk = 3; +} -- cgit