2001-09-28 20:14:13 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 11:12:37 +00:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
1999-03-25 04:14:33 +00:00
|
|
|
|
|
|
|
#ifndef nsTransferable_h__
|
|
|
|
#define nsTransferable_h__
|
|
|
|
|
1999-04-02 18:22:36 +00:00
|
|
|
#include "nsIFormatConverter.h"
|
1999-03-25 04:14:33 +00:00
|
|
|
#include "nsITransferable.h"
|
1999-04-02 18:22:36 +00:00
|
|
|
#include "nsCOMPtr.h"
|
2009-03-11 02:26:03 +00:00
|
|
|
#include "nsString.h"
|
2009-02-23 01:05:24 +00:00
|
|
|
#include "nsTArray.h"
|
2014-09-21 16:41:56 +00:00
|
|
|
#include "nsWeakPtr.h"
|
1999-04-02 18:22:36 +00:00
|
|
|
|
1999-05-13 21:53:57 +00:00
|
|
|
class nsString;
|
2009-03-11 02:26:03 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// DataStruct
|
|
|
|
//
|
|
|
|
// Holds a flavor (a mime type) that describes the data and the associated data.
|
|
|
|
//
|
|
|
|
struct DataStruct
|
|
|
|
{
|
2014-09-01 03:33:13 +00:00
|
|
|
explicit DataStruct ( const char* aFlavor )
|
2012-07-30 14:20:58 +00:00
|
|
|
: mDataLen(0), mFlavor(aFlavor), mCacheFileName(nullptr) { }
|
2009-03-11 02:26:03 +00:00
|
|
|
~DataStruct();
|
|
|
|
|
|
|
|
const nsCString& GetFlavor() const { return mFlavor; }
|
2015-02-18 11:52:00 +00:00
|
|
|
void SetData( nsISupports* inData, uint32_t inDataLen, bool aIsPrivateData );
|
2012-08-22 15:56:38 +00:00
|
|
|
void GetData( nsISupports** outData, uint32_t *outDataLen );
|
2013-07-10 09:56:21 +00:00
|
|
|
already_AddRefed<nsIFile> GetFileSpec(const char* aFileName);
|
2011-09-29 06:19:26 +00:00
|
|
|
bool IsDataAvailable() const { return (mData && mDataLen > 0) || (!mData && mCacheFileName); }
|
2009-03-11 02:26:03 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
enum {
|
|
|
|
// The size of data over which we write the data to disk rather than
|
|
|
|
// keep it around in memory.
|
|
|
|
kLargeDatasetSize = 1000000 // 1 million bytes
|
|
|
|
};
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
nsresult WriteCache(nsISupports* aData, uint32_t aDataLen );
|
|
|
|
nsresult ReadCache(nsISupports** aData, uint32_t* aDataLen );
|
2009-03-11 02:26:03 +00:00
|
|
|
|
|
|
|
nsCOMPtr<nsISupports> mData; // OWNER - some varient of primitive wrapper
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t mDataLen;
|
2009-03-11 02:26:03 +00:00
|
|
|
const nsCString mFlavor;
|
|
|
|
char * mCacheFileName;
|
|
|
|
|
|
|
|
};
|
1999-03-25 04:14:33 +00:00
|
|
|
|
|
|
|
/**
|
1999-04-02 03:57:31 +00:00
|
|
|
* XP Transferable wrapper
|
1999-03-25 04:14:33 +00:00
|
|
|
*/
|
|
|
|
|
1999-05-13 21:53:57 +00:00
|
|
|
class nsTransferable : public nsITransferable
|
1999-03-25 04:14:33 +00:00
|
|
|
{
|
|
|
|
public:
|
1999-08-25 08:35:06 +00:00
|
|
|
|
1999-03-25 04:14:33 +00:00
|
|
|
nsTransferable();
|
|
|
|
|
1999-08-25 08:35:06 +00:00
|
|
|
// nsISupports
|
1999-03-25 04:14:33 +00:00
|
|
|
NS_DECL_ISUPPORTS
|
2003-04-18 20:20:04 +00:00
|
|
|
NS_DECL_NSITRANSFERABLE
|
1999-04-02 18:22:36 +00:00
|
|
|
|
1999-03-25 04:14:33 +00:00
|
|
|
protected:
|
2014-06-24 16:36:44 +00:00
|
|
|
virtual ~nsTransferable();
|
1999-03-25 04:14:33 +00:00
|
|
|
|
1999-08-25 08:35:06 +00:00
|
|
|
// get flavors w/out converter
|
2003-04-18 20:20:04 +00:00
|
|
|
nsresult GetTransferDataFlavors(nsISupportsArray** aDataFlavorList);
|
1999-08-25 08:35:06 +00:00
|
|
|
|
2009-03-11 02:26:03 +00:00
|
|
|
nsTArray<DataStruct> mDataArray;
|
1999-04-02 18:22:36 +00:00
|
|
|
nsCOMPtr<nsIFormatConverter> mFormatConv;
|
2012-04-17 02:14:01 +00:00
|
|
|
bool mPrivateData;
|
2014-09-21 16:41:56 +00:00
|
|
|
nsWeakPtr mRequestingNode;
|
2012-04-17 02:14:01 +00:00
|
|
|
#if DEBUG
|
|
|
|
bool mInitialized;
|
|
|
|
#endif
|
1999-03-25 04:14:33 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // nsTransferable_h__
|