2012-03-23 02:25:08 -07:00
|
|
|
#ifndef nsPlacesImportExportService_h__
|
|
|
|
#define nsPlacesImportExportService_h__
|
2007-05-03 01:56:41 -07:00
|
|
|
|
|
|
|
#include "nsIPlacesImportExportService.h"
|
|
|
|
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsILocalFile.h"
|
|
|
|
#include "nsIOutputStream.h"
|
|
|
|
#include "nsIFaviconService.h"
|
|
|
|
#include "nsIAnnotationService.h"
|
2012-02-24 04:42:24 -08:00
|
|
|
#include "mozIAsyncLivemarks.h"
|
2007-05-03 01:56:41 -07:00
|
|
|
#include "nsINavHistoryService.h"
|
|
|
|
#include "nsINavBookmarksService.h"
|
2007-05-31 17:44:43 -07:00
|
|
|
#include "nsIChannel.h"
|
2007-05-03 01:56:41 -07:00
|
|
|
|
2012-03-23 02:25:08 -07:00
|
|
|
class nsPlacesImportExportService : public nsIPlacesImportExportService,
|
|
|
|
public nsINavHistoryBatchCallback
|
2007-05-03 01:56:41 -07:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_NSIPLACESIMPORTEXPORTSERVICE
|
2012-03-23 02:25:08 -07:00
|
|
|
NS_DECL_NSINAVHISTORYBATCHCALLBACK
|
|
|
|
nsPlacesImportExportService();
|
2007-05-03 01:56:41 -07:00
|
|
|
|
2010-03-23 18:17:49 -07:00
|
|
|
/**
|
|
|
|
* Obtains the service's object.
|
|
|
|
*/
|
2012-03-23 02:25:08 -07:00
|
|
|
static nsPlacesImportExportService* GetSingleton();
|
2010-03-23 18:17:49 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Initializes the service's object. This should only be called once.
|
|
|
|
*/
|
|
|
|
nsresult Init();
|
|
|
|
|
2007-05-03 01:56:41 -07:00
|
|
|
private:
|
2012-03-23 02:25:08 -07:00
|
|
|
static nsPlacesImportExportService* gImportExportService;
|
|
|
|
virtual ~nsPlacesImportExportService();
|
2007-05-03 01:56:41 -07:00
|
|
|
|
|
|
|
protected:
|
|
|
|
nsCOMPtr<nsIFaviconService> mFaviconService;
|
|
|
|
nsCOMPtr<nsIAnnotationService> mAnnotationService;
|
|
|
|
nsCOMPtr<nsINavBookmarksService> mBookmarksService;
|
|
|
|
nsCOMPtr<nsINavHistoryService> mHistoryService;
|
2012-02-24 04:42:24 -08:00
|
|
|
nsCOMPtr<mozIAsyncLivemarks> mLivemarkService;
|
2007-05-03 01:56:41 -07:00
|
|
|
|
2012-03-23 02:25:08 -07:00
|
|
|
nsCOMPtr<nsIChannel> mImportChannel;
|
|
|
|
bool mIsImportDefaults;
|
|
|
|
|
|
|
|
nsresult ImportHTMLFromFileInternal(nsILocalFile* aFile, bool aAllowRootChanges,
|
|
|
|
PRInt64 aFolder, bool aIsImportDefaults);
|
|
|
|
nsresult ImportHTMLFromURIInternal(nsIURI* aURI, bool aAllowRootChanges,
|
|
|
|
PRInt64 aFolder, bool aIsImportDefaults);
|
2007-05-24 22:41:49 -07:00
|
|
|
nsresult WriteContainer(nsINavHistoryResultNode* aFolder, const nsACString& aIndent, nsIOutputStream* aOutput);
|
|
|
|
nsresult WriteContainerHeader(nsINavHistoryResultNode* aFolder, const nsACString& aIndent, nsIOutputStream* aOutput);
|
|
|
|
nsresult WriteTitle(nsINavHistoryResultNode* aItem, nsIOutputStream* aOutput);
|
2007-05-03 01:56:41 -07:00
|
|
|
nsresult WriteItem(nsINavHistoryResultNode* aItem, const nsACString& aIndent, nsIOutputStream* aOutput);
|
2007-05-24 22:41:49 -07:00
|
|
|
nsresult WriteLivemark(nsINavHistoryResultNode* aFolder, const nsACString& aIndent, nsIOutputStream* aOutput);
|
|
|
|
nsresult WriteContainerContents(nsINavHistoryResultNode* aFolder, const nsACString& aIndent, nsIOutputStream* aOutput);
|
2007-05-14 21:18:25 -07:00
|
|
|
nsresult WriteSeparator(nsINavHistoryResultNode* aItem, const nsACString& aIndent, nsIOutputStream* aOutput);
|
2007-05-11 12:26:14 -07:00
|
|
|
nsresult WriteDescription(PRInt64 aId, PRInt32 aType, nsIOutputStream* aOutput);
|
2007-05-03 01:56:41 -07:00
|
|
|
|
2007-05-10 16:52:47 -07:00
|
|
|
inline nsresult EnsureServiceState() {
|
|
|
|
NS_ENSURE_STATE(mHistoryService);
|
|
|
|
NS_ENSURE_STATE(mFaviconService);
|
|
|
|
NS_ENSURE_STATE(mAnnotationService);
|
|
|
|
NS_ENSURE_STATE(mBookmarksService);
|
|
|
|
NS_ENSURE_STATE(mLivemarkService);
|
|
|
|
return NS_OK;
|
2007-06-16 12:53:59 -07:00
|
|
|
}
|
2007-05-03 01:56:41 -07:00
|
|
|
};
|
|
|
|
|
2012-03-23 02:25:08 -07:00
|
|
|
#endif // nsPlacesImportExportService_h__
|