@@ -629,21 +629,21 @@ private: | |||
{ | |||
output->writeInt (chunkName ("MARK")); | |||
output->writeIntBigEndian ((int) markChunk.getSize()); | |||
output->write (markChunk.getData(), (int) markChunk.getSize()); | |||
*output << markChunk; | |||
} | |||
if (comtChunk.getSize() > 0) | |||
{ | |||
output->writeInt (chunkName ("COMT")); | |||
output->writeIntBigEndian ((int) comtChunk.getSize()); | |||
output->write (comtChunk.getData(), (int) comtChunk.getSize()); | |||
*output << comtChunk; | |||
} | |||
if (instChunk.getSize() > 0) | |||
{ | |||
output->writeInt (chunkName ("INST")); | |||
output->writeIntBigEndian ((int) instChunk.getSize()); | |||
output->write (instChunk.getData(), (int) instChunk.getSize()); | |||
*output << instChunk; | |||
} | |||
output->writeInt (chunkName ("SSND")); | |||
@@ -936,28 +936,28 @@ private: | |||
{ | |||
output->writeInt (chunkName ("bext")); | |||
output->writeInt ((int) bwavChunk.getSize()); | |||
output->write (bwavChunk.getData(), (int) bwavChunk.getSize()); | |||
*output << bwavChunk; | |||
} | |||
if (smplChunk.getSize() > 0) | |||
{ | |||
output->writeInt (chunkName ("smpl")); | |||
output->writeInt ((int) smplChunk.getSize()); | |||
output->write (smplChunk.getData(), (int) smplChunk.getSize()); | |||
*output << smplChunk; | |||
} | |||
if (instChunk.getSize() > 0) | |||
{ | |||
output->writeInt (chunkName ("inst")); | |||
output->writeInt (7); | |||
output->write (instChunk.getData(), (int) instChunk.getSize()); | |||
*output << instChunk; | |||
} | |||
if (cueChunk.getSize() > 0) | |||
{ | |||
output->writeInt (chunkName ("cue ")); | |||
output->writeInt ((int) cueChunk.getSize()); | |||
output->write (cueChunk.getData(), (int) cueChunk.getSize()); | |||
*output << cueChunk; | |||
} | |||
if (listChunk.getSize() > 0) | |||
@@ -965,7 +965,7 @@ private: | |||
output->writeInt (chunkName ("LIST")); | |||
output->writeInt ((int) listChunk.getSize() + 4); | |||
output->writeInt (chunkName ("adtl")); | |||
output->write (listChunk.getData(), (int) listChunk.getSize()); | |||
*output << listChunk; | |||
} | |||
output->writeInt (chunkName ("data")); | |||
@@ -1069,7 +1069,7 @@ bool WavAudioFormat::replaceMetadataInFile (const File& wavFile, const StringPai | |||
if (reader != nullptr) | |||
{ | |||
const int64 bwavPos = reader->bwavChunkStart; | |||
const int64 bwavPos = reader->bwavChunkStart; | |||
const int64 bwavSize = reader->bwavSize; | |||
reader = nullptr; | |||
@@ -1085,7 +1085,7 @@ bool WavAudioFormat::replaceMetadataInFile (const File& wavFile, const StringPai | |||
{ | |||
ScopedPointer <FileOutputStream> out (wavFile.createOutputStream()); | |||
out->setPosition (bwavPos); | |||
out->write (chunk.getData(), (int) chunk.getSize()); | |||
*out << chunk; | |||
out->setPosition (oldSize); | |||
} | |||
@@ -23,8 +23,6 @@ | |||
============================================================================== | |||
*/ | |||
#include <Cocoa/Cocoa.h> | |||
#if JUCE_WINDOWS | |||
#undef _WIN32_WINNT | |||
#define _WIN32_WINNT 0x500 | |||
@@ -49,11 +47,12 @@ | |||
#undef Time | |||
#else | |||
#include <Cocoa/Cocoa.h> | |||
#ifndef JUCE_SUPPORT_CARBON | |||
#define JUCE_SUPPORT_CARBON 1 | |||
#endif | |||
#include <Cocoa/Cocoa.h> | |||
#if JUCE_SUPPORT_CARBON | |||
#define Point CarbonDummyPointName | |||
#define Component CarbonDummyCompName | |||
@@ -67,7 +67,6 @@ bool Process::openEmailWithAttachments (const String& targetEmailAddress, | |||
class WebInputStream : public InputStream | |||
{ | |||
public: | |||
//============================================================================== | |||
WebInputStream (const String& address_, bool isPost_, const MemoryBlock& postData_, | |||
URL::OpenStreamProgressCallback* progressCallback, void* progressCallbackContext, | |||
const String& headers_, int timeOutMs_, StringPairArray* responseHeaders) | |||
@@ -333,35 +332,34 @@ private: | |||
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, | |||
const String& proxyName, const int proxyPort, | |||
const String& hostPath, const String& originalURL, | |||
const String& headers, const MemoryBlock& postData, | |||
const bool isPost) | |||
{ | |||
String header (isPost ? "POST " : "GET "); | |||
MemoryOutputStream header; | |||
header << (isPost ? "POST " : "GET "); | |||
if (proxyName.isEmpty()) | |||
{ | |||
header << hostPath << " HTTP/1.0\r\nHost: " | |||
<< hostName << ':' << hostPort; | |||
} | |||
header << hostPath << " HTTP/1.0\r\nHost: " << hostName << ':' << hostPort; | |||
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, | |||
@@ -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) | |||
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) | |||
@@ -157,8 +160,7 @@ String MemoryOutputStream::toString() const | |||
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 |
@@ -97,6 +97,9 @@ public: | |||
*/ | |||
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 | |||
capacity off the block, so that its length matches the amount of actual data that | |||
@@ -2325,18 +2325,15 @@ private: | |||
if ((lParam & GCS_RESULTSTR) != 0) // (composition has finished) | |||
{ | |||
replaceCurrentSelection (target, getCompositionString (hImc, GCS_RESULTSTR), | |||
Range<int>::emptyRange (compositionRange.getEnd())); | |||
Range<int>::emptyRange (-1)); | |||
reset(); | |||
target->setTemporaryUnderlining (Array<Range<int> >()); | |||
compositionInProgress = false; | |||
} | |||
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)); | |||
compositionInProgress = true; | |||
@@ -2425,12 +2422,17 @@ private: | |||
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); | |||
compositionRange.setLength (newContent.length()); | |||
if (newSelection.getStart() < 0) | |||
newSelection = Range<int>::emptyRange (compositionRange.getEnd()); | |||
target->setHighlightedRegion (newSelection); | |||
} | |||