Browse Source

Linux http fix. Plugin header fix. win32 IME fix.

tags/2021-05-28
Julian Storer 13 years ago
parent
commit
2cae7a76f5
7 changed files with 52 additions and 48 deletions
  1. +3
    -3
      modules/juce_audio_formats/codecs/juce_AiffAudioFormat.cpp
  2. +7
    -7
      modules/juce_audio_formats/codecs/juce_WavAudioFormat.cpp
  3. +2
    -3
      modules/juce_audio_plugin_client/utility/juce_IncludeSystemHeaders.h
  4. +17
    -19
      modules/juce_core/native/juce_linux_Network.cpp
  5. +9
    -7
      modules/juce_core/streams/juce_MemoryOutputStream.cpp
  6. +3
    -0
      modules/juce_core/streams/juce_MemoryOutputStream.h
  7. +11
    -9
      modules/juce_gui_basics/native/juce_win32_Windowing.cpp

+ 3
- 3
modules/juce_audio_formats/codecs/juce_AiffAudioFormat.cpp View File

@@ -629,21 +629,21 @@ private:
{ {
output->writeInt (chunkName ("MARK")); output->writeInt (chunkName ("MARK"));
output->writeIntBigEndian ((int) markChunk.getSize()); output->writeIntBigEndian ((int) markChunk.getSize());
output->write (markChunk.getData(), (int) markChunk.getSize());
*output << markChunk;
} }
if (comtChunk.getSize() > 0) if (comtChunk.getSize() > 0)
{ {
output->writeInt (chunkName ("COMT")); output->writeInt (chunkName ("COMT"));
output->writeIntBigEndian ((int) comtChunk.getSize()); output->writeIntBigEndian ((int) comtChunk.getSize());
output->write (comtChunk.getData(), (int) comtChunk.getSize());
*output << comtChunk;
} }
if (instChunk.getSize() > 0) if (instChunk.getSize() > 0)
{ {
output->writeInt (chunkName ("INST")); output->writeInt (chunkName ("INST"));
output->writeIntBigEndian ((int) instChunk.getSize()); output->writeIntBigEndian ((int) instChunk.getSize());
output->write (instChunk.getData(), (int) instChunk.getSize());
*output << instChunk;
} }
output->writeInt (chunkName ("SSND")); output->writeInt (chunkName ("SSND"));


+ 7
- 7
modules/juce_audio_formats/codecs/juce_WavAudioFormat.cpp View File

@@ -936,28 +936,28 @@ private:
{ {
output->writeInt (chunkName ("bext")); output->writeInt (chunkName ("bext"));
output->writeInt ((int) bwavChunk.getSize()); output->writeInt ((int) bwavChunk.getSize());
output->write (bwavChunk.getData(), (int) bwavChunk.getSize());
*output << bwavChunk;
} }
if (smplChunk.getSize() > 0) if (smplChunk.getSize() > 0)
{ {
output->writeInt (chunkName ("smpl")); output->writeInt (chunkName ("smpl"));
output->writeInt ((int) smplChunk.getSize()); output->writeInt ((int) smplChunk.getSize());
output->write (smplChunk.getData(), (int) smplChunk.getSize());
*output << smplChunk;
} }
if (instChunk.getSize() > 0) if (instChunk.getSize() > 0)
{ {
output->writeInt (chunkName ("inst")); output->writeInt (chunkName ("inst"));
output->writeInt (7); output->writeInt (7);
output->write (instChunk.getData(), (int) instChunk.getSize());
*output << instChunk;
} }
if (cueChunk.getSize() > 0) if (cueChunk.getSize() > 0)
{ {
output->writeInt (chunkName ("cue ")); output->writeInt (chunkName ("cue "));
output->writeInt ((int) cueChunk.getSize()); output->writeInt ((int) cueChunk.getSize());
output->write (cueChunk.getData(), (int) cueChunk.getSize());
*output << cueChunk;
} }
if (listChunk.getSize() > 0) if (listChunk.getSize() > 0)
@@ -965,7 +965,7 @@ private:
output->writeInt (chunkName ("LIST")); output->writeInt (chunkName ("LIST"));
output->writeInt ((int) listChunk.getSize() + 4); output->writeInt ((int) listChunk.getSize() + 4);
output->writeInt (chunkName ("adtl")); output->writeInt (chunkName ("adtl"));
output->write (listChunk.getData(), (int) listChunk.getSize());
*output << listChunk;
} }
output->writeInt (chunkName ("data")); output->writeInt (chunkName ("data"));
@@ -1069,7 +1069,7 @@ bool WavAudioFormat::replaceMetadataInFile (const File& wavFile, const StringPai
if (reader != nullptr) if (reader != nullptr)
{ {
const int64 bwavPos = reader->bwavChunkStart;
const int64 bwavPos = reader->bwavChunkStart;
const int64 bwavSize = reader->bwavSize; const int64 bwavSize = reader->bwavSize;
reader = nullptr; reader = nullptr;
@@ -1085,7 +1085,7 @@ bool WavAudioFormat::replaceMetadataInFile (const File& wavFile, const StringPai
{ {
ScopedPointer <FileOutputStream> out (wavFile.createOutputStream()); ScopedPointer <FileOutputStream> out (wavFile.createOutputStream());
out->setPosition (bwavPos); out->setPosition (bwavPos);
out->write (chunk.getData(), (int) chunk.getSize());
*out << chunk;
out->setPosition (oldSize); out->setPosition (oldSize);
} }


+ 2
- 3
modules/juce_audio_plugin_client/utility/juce_IncludeSystemHeaders.h View File

@@ -23,8 +23,6 @@
============================================================================== ==============================================================================
*/ */
#include <Cocoa/Cocoa.h>
#if JUCE_WINDOWS #if JUCE_WINDOWS
#undef _WIN32_WINNT #undef _WIN32_WINNT
#define _WIN32_WINNT 0x500 #define _WIN32_WINNT 0x500
@@ -49,11 +47,12 @@
#undef Time #undef Time
#else #else
#include <Cocoa/Cocoa.h>
#ifndef JUCE_SUPPORT_CARBON #ifndef JUCE_SUPPORT_CARBON
#define JUCE_SUPPORT_CARBON 1 #define JUCE_SUPPORT_CARBON 1
#endif #endif
#include <Cocoa/Cocoa.h>
#if JUCE_SUPPORT_CARBON #if JUCE_SUPPORT_CARBON
#define Point CarbonDummyPointName #define Point CarbonDummyPointName
#define Component CarbonDummyCompName #define Component CarbonDummyCompName


+ 17
- 19
modules/juce_core/native/juce_linux_Network.cpp View File

@@ -67,7 +67,6 @@ bool Process::openEmailWithAttachments (const String& targetEmailAddress,
class WebInputStream : public InputStream class WebInputStream : public InputStream
{ {
public: public:
//==============================================================================
WebInputStream (const String& address_, bool isPost_, const MemoryBlock& postData_, WebInputStream (const String& address_, bool isPost_, const MemoryBlock& postData_,
URL::OpenStreamProgressCallback* progressCallback, void* progressCallbackContext, URL::OpenStreamProgressCallback* progressCallback, void* progressCallbackContext,
const String& headers_, int timeOutMs_, StringPairArray* responseHeaders) const String& headers_, int timeOutMs_, StringPairArray* responseHeaders)
@@ -333,35 +332,34 @@ private:
return String::empty; return String::empty;
} }
static void writeValueIfNotPresent (MemoryOutputStream& dest, const String& headers, const String& key, const String& value)
{
if (! headers.containsIgnoreCase (key))
dest << "\r\n" << key << ' ' << value;
}
static MemoryBlock createRequestHeader (const String& hostName, const int hostPort, static MemoryBlock createRequestHeader (const String& hostName, const int hostPort,
const String& proxyName, const int proxyPort, const String& proxyName, const int proxyPort,
const String& hostPath, const String& originalURL, const String& hostPath, const String& originalURL,
const String& headers, const MemoryBlock& postData, const String& headers, const MemoryBlock& postData,
const bool isPost) const bool isPost)
{ {
String header (isPost ? "POST " : "GET ");
MemoryOutputStream header;
header << (isPost ? "POST " : "GET ");
if (proxyName.isEmpty()) if (proxyName.isEmpty())
{
header << hostPath << " HTTP/1.0\r\nHost: "
<< hostName << ':' << hostPort;
}
header << hostPath << " HTTP/1.0\r\nHost: " << hostName << ':' << hostPort;
else else
{
header << originalURL << " HTTP/1.0\r\nHost: "
<< proxyName << ':' << proxyPort;
}
header << "\r\nUser-Agent: JUCE/" << JUCE_MAJOR_VERSION << '.' << JUCE_MINOR_VERSION
<< "\r\nConnection: Close\r\nContent-Length: "
<< (int) postData.getSize() << "\r\n"
<< headers << "\r\n";
header << originalURL << " HTTP/1.0\r\nHost: " << proxyName << ':' << proxyPort;
MemoryBlock mb;
mb.append (header.toUTF8(), (int) strlen (header.toUTF8()));
mb.append (postData.getData(), postData.getSize());
writeValueIfNotPresent (header, headers, "User-Agent:", "JUCE/" + String (JUCE_MAJOR_VERSION) + "." + String (JUCE_MINOR_VERSION));
writeValueIfNotPresent (header, headers, "Connection:", "Close");
writeValueIfNotPresent (header, headers, "Content-Length:", String ((int) postData.getSize()));
header << "\r\n" << headers
<< "\r\n" << postData;
return mb;
return header.getMemoryBlock();
} }
static bool sendHeader (int socketHandle, const MemoryBlock& requestHeader, const uint32 timeOutTime, static bool sendHeader (int socketHandle, const MemoryBlock& requestHeader, const uint32 timeOutTime,


+ 9
- 7
modules/juce_core/streams/juce_MemoryOutputStream.cpp View File

@@ -103,14 +103,17 @@ void MemoryOutputStream::writeRepeatedByte (uint8 byte, int howMany)
} }
} }
const void* MemoryOutputStream::getData() const noexcept
const MemoryBlock& MemoryOutputStream::getMemoryBlock() const noexcept
{ {
void* const d = data.getData();
if (data.getSize() > size) if (data.getSize() > size)
static_cast <char*> (d) [size] = 0;
static_cast <char*> (data.getData()) [size] = 0;
return data;
}
return d;
const void* MemoryOutputStream::getData() const noexcept
{
return getMemoryBlock().getData();
} }
bool MemoryOutputStream::setPosition (int64 newPosition) bool MemoryOutputStream::setPosition (int64 newPosition)
@@ -157,8 +160,7 @@ String MemoryOutputStream::toString() const
OutputStream& JUCE_CALLTYPE operator<< (OutputStream& stream, const MemoryOutputStream& streamToRead) OutputStream& JUCE_CALLTYPE operator<< (OutputStream& stream, const MemoryOutputStream& streamToRead)
{ {
stream.write (streamToRead.getData(), (int) streamToRead.getDataSize());
return stream;
return stream << streamToRead.getMemoryBlock();
} }
END_JUCE_NAMESPACE END_JUCE_NAMESPACE

+ 3
- 0
modules/juce_core/streams/juce_MemoryOutputStream.h View File

@@ -97,6 +97,9 @@ public:
*/ */
String toString() const; String toString() const;
/** Returns the memory block that is being used internally to hold the data. */
const MemoryBlock& getMemoryBlock() const noexcept;
//============================================================================== //==============================================================================
/** If the stream is writing to a user-supplied MemoryBlock, this will trim any excess /** If the stream is writing to a user-supplied MemoryBlock, this will trim any excess
capacity off the block, so that its length matches the amount of actual data that capacity off the block, so that its length matches the amount of actual data that


+ 11
- 9
modules/juce_gui_basics/native/juce_win32_Windowing.cpp View File

@@ -2325,18 +2325,15 @@ private:
if ((lParam & GCS_RESULTSTR) != 0) // (composition has finished) if ((lParam & GCS_RESULTSTR) != 0) // (composition has finished)
{ {
replaceCurrentSelection (target, getCompositionString (hImc, GCS_RESULTSTR), replaceCurrentSelection (target, getCompositionString (hImc, GCS_RESULTSTR),
Range<int>::emptyRange (compositionRange.getEnd()));
Range<int>::emptyRange (-1));
reset();
target->setTemporaryUnderlining (Array<Range<int> >()); target->setTemporaryUnderlining (Array<Range<int> >());
compositionInProgress = false;
} }
else if ((lParam & GCS_COMPSTR) != 0) // (composition is still in-progress) else if ((lParam & GCS_COMPSTR) != 0) // (composition is still in-progress)
{ {
const String newContent (getCompositionString (hImc, GCS_COMPSTR));
const Range<int> selection (getCompositionSelection (hImc, lParam));
replaceCurrentSelection (target, newContent, selection);
replaceCurrentSelection (target, getCompositionString (hImc, GCS_COMPSTR),
getCompositionSelection (hImc, lParam));
target->setTemporaryUnderlining (getCompositionUnderlines (hImc, lParam)); target->setTemporaryUnderlining (getCompositionUnderlines (hImc, lParam));
compositionInProgress = true; compositionInProgress = true;
@@ -2425,12 +2422,17 @@ private:
return Range<int> (selectionStart, selectionEnd) + compositionRange.getStart(); return Range<int> (selectionStart, selectionEnd) + compositionRange.getStart();
} }
void replaceCurrentSelection (TextInputTarget* const target, const String& newContent, const Range<int>& newSelection)
void replaceCurrentSelection (TextInputTarget* const target, const String& newContent, Range<int> newSelection)
{ {
target->setHighlightedRegion (compositionRange);
if (compositionInProgress)
target->setHighlightedRegion (compositionRange);
target->insertTextAtCaret (newContent); target->insertTextAtCaret (newContent);
compositionRange.setLength (newContent.length()); compositionRange.setLength (newContent.length());
if (newSelection.getStart() < 0)
newSelection = Range<int>::emptyRange (compositionRange.getEnd());
target->setHighlightedRegion (newSelection); target->setHighlightedRegion (newSelection);
} }


Loading…
Cancel
Save