/** createMessage Must put the "," as the first format letter */ Osc::Status Osc::createMessage( char* textMessageOriginal ) { char* textMessage = strdup( textMessageOriginal ); // try to send this message - if there's a problem somewhere, // send the existing buffer - freeing up space, then try (once) again. int count = 0; char *bp; do { count++; char* buffer = outBufferPointer; int remaining = outBufferRemaining; bp = buffer; // First message in the buffer? if ( bp == outBuffer ) { bp = createBundle( bp, &remaining, 0, 0 ); if ( bp == NULL ) return ERROR_CREATING_BUNDLE; } // remember the place we're going to store the message length int* lp = (int *)bp; bp += 4; remaining -= 4; // remember the start of the message char* mp = bp; if ( remaining > 0 ) { bp = createMessageInternal( bp, &remaining, textMessage ); } else bp = 0; if ( bp != 0 ) { // Set the size *lp = qFromBigEndian( bp - mp ); outBufferPointer = bp; outBufferRemaining = remaining; outMessageCount++; } else { sendPacket( ); } } while ( bp == 0 && count == 1 ); free( textMessage ); return ( bp != 0 ) ? OK : ERROR_SENDING_COMPLEX_MESSAGE; }
void HgBundleDialog::done(int r) { if (r == QDialog::Accepted) { QString result = QFileDialog::getSaveFileName(this); if (result.length() > 0) { createBundle(result); QDialog::done(r); } } else { QDialog::done(r); } }
Osc::Status Osc::createMessage( char* address, char* format, ... ) { // try to send this message - if there's a problem somewhere, // send the existing buffer - freeing up space, then try (once) again. int count = 0; char *bp; do { count++; char* buffer = outBufferPointer; int length = outBufferRemaining; bp = buffer; // First message in the buffer? if ( bp == outBuffer ) { bp = createBundle( bp, &length, 0, 0 ); if ( bp == NULL ) return ERROR_CREATING_BUNDLE; } // remember the place we're going to store the message length int* lp = (int *)bp; bp += 4; length -= 4; // remember the start of the message char* mp = bp; if ( length > 0 ) { // Set up to iterate through the arguments va_list args; va_start( args, format ); bp = createMessageInternal( bp, &length, address, format, args ); va_end( args ); } else bp = 0; if ( bp != 0 ) { // Set the size *lp = qFromBigEndian( bp - mp ); outBufferPointer = bp; outBufferRemaining = length; outMessageCount++; } else { sendPacket( ); } } while ( bp == 0 && count == 1 ); return ( bp != 0 ) ? OK : ERROR_SENDING_TEXT_MESSAGE; }
Osc::Status Osc::createMessage( OscMessage* msg ) { char typetag[50]; strcpy( typetag, "," ); for( int i = 0; i < msg->data.count( ); i++ ) { OscMessageData *data = msg->data.at( i ); if( data->omdType == OscMessageData::OmdString ) strcat( typetag, "s" ); if( data->omdType == OscMessageData::OmdInt ) strcat( typetag, "i" ); if( data->omdType == OscMessageData::OmdFloat ) strcat( typetag, "f" ); if( data->omdType == OscMessageData::OmdBlob ) strcat( typetag, "b" ); } int count = 0; char *bp; do { count++; char* buffer = outBufferPointer; int length = outBufferRemaining; bp = buffer; // First message in the buffer? if ( bp == outBuffer ) { bp = createBundle( bp, &length, 0, 0 ); if ( bp == NULL ) return ERROR_CREATING_BUNDLE; } // remember the place we're going to store the message length int* lp = (int *)bp; bp += 4; length -= 4; // remember the start of the message char* mp = bp; if ( length > 0 ) // Set up to iterate through the arguments bp = createMessageInternal( bp, &length, msg->address, typetag, msg->data ); else bp = 0; if ( bp != 0 ) { // Set the size *lp = qFromBigEndian( bp - mp ); outBufferPointer = bp; outBufferRemaining = length; outMessageCount++; } else { sendPacket( ); } } while ( bp == 0 && count == 1 ); return ( bp != 0 ) ? OK : ERROR_SENDING_TEXT_MESSAGE; }