aboutsummaryrefslogtreecommitdiff
path: root/SrcShared/EmFileImport.h
blob: 6eef35e971014ec7b4001b532df6b9eaf7c250e1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
/* -*- mode: C++; tab-width: 4 -*- */
/* ===================================================================== *\
	Copyright (c) 2000-2001 Palm, Inc. or its subsidiaries.
	All rights reserved.

	This file is part of the Palm OS Emulator.

	This program is free software; you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation; either version 2 of the License, or
	(at your option) any later version.
\* ===================================================================== */

#ifndef EMFILEIMPORT_H
#define EMFILEIMPORT_H

#include "EmDirRef.h"			// EmFileRefList
#include "EmTypes.h"			// ErrCode

class EmExgMgr;
class EmExgMgrImportWrapper;
class EmStream;

enum EmFileImportMethod
{
	kMethodBest,
	kMethodHomebrew,
	kMethodExgMgr
};


class EmFileImport
{
	public:
								EmFileImport			(EmStream& stream,
														 EmFileImportMethod method);
								~EmFileImport			(void);

		static ErrCode			LoadPalmFile			(const void*, uint32, EmFileImportMethod, LocalID&);
		static ErrCode			LoadPalmFileList		(const EmFileRefList&, EmFileImportMethod, vector<LocalID>&);

		static ErrCode			InstallExgMgrLib		(void);
		static Bool				CanUseExgMgr			(void);

		// Interface for the dialog to display its stuff

		ErrCode					Continue				(void);
		ErrCode					Cancel					(void);
		Bool					Done					(void);
		long					GetProgress				(void);
		LocalID					GetLocalID				(void);

		void					SetResult				(Err);
		void					SetResult				(ErrCode);
		void					SetDone					(void);

		static long				CalculateProgressMax	(const EmFileRefList&, EmFileImportMethod method);

	private:
		void					IncrementalInstall		(void);

		void					ExgMgrInstallStart		(void);
		void					ExgMgrInstallMiddle		(void);
		void					ExgMgrInstallEnd		(void);
		void					ExgMgrInstallCancel		(void);

		void					HomeBrewInstallStart	(void);
		void					HomeBrewInstallMiddle	(void);
		void					HomeBrewInstallEnd		(void);
		void					HomeBrewInstallCancel	(void);

		void					ValidateStream			(void);
		void					DeleteCurrentDatabase	(void);

	private:
		Bool					fUsingExgMgr;
		Bool					fGotoWhenDone;
		long					fState;
		ErrCode					fError;
		EmStream&				fStream;

		// Fields for ExgMgr installer
		EmExgMgr*				fExgMgrStream;
		EmExgMgrImportWrapper*	fExgMgrImport;
		Bool					fOldAcceptBeamState;

		// Fields for homebrew installer
		void*					fFileBuffer;
		long					fFileBufferSize;
		LocalID					fDBID;
		UInt16					fCardNo;
		DmOpenRef				fOpenID;
		long					fCurrentEntry;
};

#endif /* EMFILEIMPORT_H */