From 4154d7028943ca4bf0f1ff2e0480d688fc081fcc Mon Sep 17 00:00:00 2001 From: Alexander Larsson Date: Tue, 25 May 2010 16:01:18 +0200 Subject: Client: Use the autogenerated demarshallers When a message has been read from the network we now pass it into the generated demarshaller for the channel. The demarshaller converts the network data to in-memory structures that is passed on to the spice internals. Additionally it also: * Converts endianness * Validates sizes of message and any pointers in it * Localizes offsets (converts them to pointers) * Checks for zero offsets in messages where they are not supported Some of this was previously done using custom code in the client, this is now removed. --- client/record_channel.cpp | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) (limited to 'client/record_channel.cpp') diff --git a/client/record_channel.cpp b/client/record_channel.cpp index 893cc632..a48df60e 100644 --- a/client/record_channel.cpp +++ b/client/record_channel.cpp @@ -59,10 +59,10 @@ void RecordSamplesMessage::release() int RecordChannel::data_mode = SPICE_AUDIO_DATA_MODE_CELT_0_5_1; -class RecordHandler: public MessageHandlerImp { +class RecordHandler: public MessageHandlerImp { public: RecordHandler(RecordChannel& channel) - : MessageHandlerImp(channel) {} + : MessageHandlerImp(channel) {} }; RecordChannel::RecordChannel(RedClient& client, uint32_t id) @@ -78,16 +78,14 @@ RecordChannel::RecordChannel(RedClient& client, uint32_t id) RecordHandler* handler = static_cast(get_message_handler()); - handler->set_handler(SPICE_MSG_MIGRATE, &RecordChannel::handle_migrate, 0); - handler->set_handler(SPICE_MSG_SET_ACK, &RecordChannel::handle_set_ack, sizeof(SpiceMsgSetAck)); - handler->set_handler(SPICE_MSG_PING, &RecordChannel::handle_ping, sizeof(SpiceMsgPing)); - handler->set_handler(SPICE_MSG_WAIT_FOR_CHANNELS, &RecordChannel::handle_wait_for_channels, - sizeof(SpiceMsgWaitForChannels)); - handler->set_handler(SPICE_MSG_DISCONNECTING, &RecordChannel::handle_disconnect, - sizeof(SpiceMsgDisconnect)); - handler->set_handler(SPICE_MSG_NOTIFY, &RecordChannel::handle_notify, sizeof(SpiceMsgNotify)); + handler->set_handler(SPICE_MSG_MIGRATE, &RecordChannel::handle_migrate); + handler->set_handler(SPICE_MSG_SET_ACK, &RecordChannel::handle_set_ack); + handler->set_handler(SPICE_MSG_PING, &RecordChannel::handle_ping); + handler->set_handler(SPICE_MSG_WAIT_FOR_CHANNELS, &RecordChannel::handle_wait_for_channels); + handler->set_handler(SPICE_MSG_DISCONNECTING, &RecordChannel::handle_disconnect); + handler->set_handler(SPICE_MSG_NOTIFY, &RecordChannel::handle_notify); - handler->set_handler(SPICE_MSG_RECORD_START, &RecordChannel::handle_start, sizeof(SpiceMsgRecordStart)); + handler->set_handler(SPICE_MSG_RECORD_START, &RecordChannel::handle_start); set_capability(SPICE_RECORD_CAP_CELT_0_5_1); } @@ -138,8 +136,8 @@ void RecordChannel::handle_start(RedPeer::InMessage* message) RecordHandler* handler = static_cast(get_message_handler()); SpiceMsgRecordStart* start = (SpiceMsgRecordStart*)message->data(); - handler->set_handler(SPICE_MSG_RECORD_START, NULL, 0); - handler->set_handler(SPICE_MSG_RECORD_STOP, &RecordChannel::handle_stop, 0); + handler->set_handler(SPICE_MSG_RECORD_START, NULL); + handler->set_handler(SPICE_MSG_RECORD_STOP, &RecordChannel::handle_stop); ASSERT(!_wave_recorder && !_celt_mode && !_celt_encoder); // for now support only one setting @@ -176,8 +174,8 @@ void RecordChannel::handle_start(RedPeer::InMessage* message) void RecordChannel::handle_stop(RedPeer::InMessage* message) { RecordHandler* handler = static_cast(get_message_handler()); - handler->set_handler(SPICE_MSG_RECORD_START, &RecordChannel::handle_start, sizeof(SpiceMsgRecordStart)); - handler->set_handler(SPICE_MSG_RECORD_STOP, NULL, 0); + handler->set_handler(SPICE_MSG_RECORD_START, &RecordChannel::handle_start); + handler->set_handler(SPICE_MSG_RECORD_STOP, NULL); if (!_wave_recorder) { return; } -- cgit