michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef nsTransferable_h__ michael@0: #define nsTransferable_h__ michael@0: michael@0: #include "nsIFormatConverter.h" michael@0: #include "nsITransferable.h" michael@0: #include "nsCOMPtr.h" michael@0: #include "nsString.h" michael@0: #include "nsTArray.h" michael@0: michael@0: class nsString; michael@0: class nsDataObj; michael@0: michael@0: // michael@0: // DataStruct michael@0: // michael@0: // Holds a flavor (a mime type) that describes the data and the associated data. michael@0: // michael@0: struct DataStruct michael@0: { michael@0: DataStruct ( const char* aFlavor ) michael@0: : mDataLen(0), mFlavor(aFlavor), mCacheFileName(nullptr) { } michael@0: ~DataStruct(); michael@0: michael@0: const nsCString& GetFlavor() const { return mFlavor; } michael@15: void SetData( nsISupports* inData, uint32_t inDataLen, bool aIsPrivateData ); michael@0: void GetData( nsISupports** outData, uint32_t *outDataLen ); michael@0: already_AddRefed GetFileSpec(const char* aFileName); michael@0: bool IsDataAvailable() const { return (mData && mDataLen > 0) || (!mData && mCacheFileName); } michael@0: michael@0: protected: michael@0: michael@0: enum { michael@0: // The size of data over which we write the data to disk rather than michael@0: // keep it around in memory. michael@0: kLargeDatasetSize = 1000000 // 1 million bytes michael@0: }; michael@0: michael@0: nsresult WriteCache(nsISupports* aData, uint32_t aDataLen ); michael@0: nsresult ReadCache(nsISupports** aData, uint32_t* aDataLen ); michael@0: michael@0: nsCOMPtr mData; // OWNER - some varient of primitive wrapper michael@0: uint32_t mDataLen; michael@0: const nsCString mFlavor; michael@0: char * mCacheFileName; michael@0: michael@0: }; michael@0: michael@0: /** michael@0: * XP Transferable wrapper michael@0: */ michael@0: michael@0: class nsTransferable : public nsITransferable michael@0: { michael@0: public: michael@0: michael@0: nsTransferable(); michael@0: virtual ~nsTransferable(); michael@0: michael@0: // nsISupports michael@0: NS_DECL_ISUPPORTS michael@0: NS_DECL_NSITRANSFERABLE michael@0: michael@0: protected: michael@0: michael@0: // get flavors w/out converter michael@0: nsresult GetTransferDataFlavors(nsISupportsArray** aDataFlavorList); michael@0: michael@0: nsTArray mDataArray; michael@0: nsCOMPtr mFormatConv; michael@0: bool mPrivateData; michael@0: #if DEBUG michael@0: bool mInitialized; michael@0: #endif michael@0: michael@0: }; michael@0: michael@0: #endif // nsTransferable_h__