bool SafeDragObject::decode(const QMimeSource *src, QDomDocument &xml) { if(canDecode(src)) { xml.setContent(src->encodedData(SafeDragObject_MimeType)); return true; } return false; }
std::shared_ptr<ResourceObject> ResourceManager::loadObject(std::wstring filename) { mutexObjects.lock(); auto it = objects.find(filename); if (it != objects.end()) { return it->second; } mutexObjects.unlock(); std::shared_ptr<File> file; mutexFileSystems.lock(); for (auto it = fileSystems.begin(); it != fileSystems.end(); ++it) { auto fs = *it; file = fs->loadFile(filename); if (file.get() != nullptr) { break; } } mutexFileSystems.unlock(); if (file.get() == nullptr) { return nullptr; } std::unique_lock<std::mutex> lckDecoders(mutexDecoders); for (auto it = decoders.begin(); it != decoders.end(); ++it) { auto decoder = *it; if (decoder->canDecode(file)) { auto object = decoder->decode(file); std::unique_lock<std::mutex> lckObjects(mutexObjects); objects[filename]= object; } } return nullptr; }
bool ListDnd::dragEnterEvent( QDragEnterEvent * event ) { if ( dMode == None ) { return TRUE; } bool ok = ( ( ( dMode & Both ) == Both ) || ( ( dMode & Internal ) && ( event->source() == src ) ) || ( ( dMode & External ) && ( event->source() != src ) ) ); if ( ok && canDecode( event ) ) { event->accept(); dragInside = TRUE; if ( !( dMode & NullDrop ) ) { updateLine( event->pos() ); line->show(); } } return TRUE; }
void Client::socketNewMsgCallback(unsigned char data[], int len) { int numRead = len; int numDecoded = 0; char *bufferToDecode; if (isWaitingForData) { int readLen = len; len = readLen + incompleteDataBufferSize; bufferToDecode = new char[len]; for(int i=0; i<incompleteDataBufferSize;++i) { bufferToDecode[i] = incompleteDataBuffer[i]; } for(int i=incompleteDataBufferSize; i<len;++i) { bufferToDecode[i] = data[i-incompleteDataBufferSize]; } isWaitingForData = false; incompleteDataBufferSize = 0; delete incompleteDataBuffer; incompleteDataBuffer = NULL; numRead =len; } else { bufferToDecode = new char[len]; for(int i=0; i<len;++i) bufferToDecode[i] = data[i]; } while(numDecoded < numRead) { bool canDecodeData = canDecode(bufferToDecode,numDecoded,numRead); if (canDecodeData) { if(bufferToDecode[numDecoded] == MessageType::response) numDecoded += handleResponse(bufferToDecode, numDecoded); else numDecoded += handleNotify(bufferToDecode, numDecoded); } else { incompleteDataBufferSize = numRead-numDecoded; if(incompleteDataBuffer != NULL) { delete incompleteDataBuffer; incompleteDataBuffer = NULL; } incompleteDataBuffer = new char[incompleteDataBufferSize]; for(int i=numDecoded; i<numRead; ++i) { incompleteDataBuffer[i-numDecoded] = bufferToDecode[i]; } isWaitingForData = true; break; } } delete[] bufferToDecode; }
std::string MovieDecoderBase::canDecode(const std::string & theUrl, asl::Ptr<asl::ReadableStreamHandle> theStream) { AC_WARNING << "MovieDecoderBase::canDecode: Using deprecated interface"; return canDecode(theUrl, theStream::getStream()); }