1e3a631c0SIngo Weinhold/*
2e3a631c0SIngo Weinhold * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
3fce4895dSRene Gollent * Copyright 2013-2016, Rene Gollent, rene@gollent.com.
4e3a631c0SIngo Weinhold * Distributed under the terms of the MIT License.
5e3a631c0SIngo Weinhold */
6e3a631c0SIngo Weinhold#ifndef USER_INTERFACE_H
7e3a631c0SIngo Weinhold#define USER_INTERFACE_H
8e3a631c0SIngo Weinhold
9e3a631c0SIngo Weinhold
10e3a631c0SIngo Weinhold#include <OS.h>
11e3a631c0SIngo Weinhold
12e3a631c0SIngo Weinhold#include <Referenceable.h>
13e3a631c0SIngo Weinhold
143e3ce16fSRene Gollent#include "TeamMemoryBlock.h"
15e3a631c0SIngo Weinhold#include "Types.h"
16e3a631c0SIngo Weinhold
17e3a631c0SIngo Weinhold
189216fc01SAugustin Cavalierstruct entry_ref;
192efebaa1SRene Gollent
2059ea286fSIngo Weinholdclass CpuState;
21d1c9ffedSRene Gollentclass ExpressionInfo;
22e3a631c0SIngo Weinholdclass FunctionInstance;
23e3a631c0SIngo Weinholdclass Image;
24432da9e3SRene Gollentclass LocatableFile;
252d5794a1SRene Gollentclass SourceLanguage;
26e3a631c0SIngo Weinholdclass StackFrame;
27e3a631c0SIngo Weinholdclass Team;
28f4b1ddb5SIngo Weinholdclass TeamUiSettings;
29e3a631c0SIngo Weinholdclass Thread;
30e3a631c0SIngo Weinholdclass TypeComponentPath;
31e3a631c0SIngo Weinholdclass UserBreakpoint;
32e3a631c0SIngo Weinholdclass UserInterfaceListener;
337d25ab99SRene Gollentclass Value;
3459ea286fSIngo Weinholdclass ValueNode;
3559ea286fSIngo Weinholdclass ValueNodeContainer;
364235cb3eSRene Gollentclass Watchpoint;
37e3a631c0SIngo Weinhold
38e3a631c0SIngo Weinhold
39e3a631c0SIngo Weinholdenum user_notification_type {
40e3a631c0SIngo Weinhold	USER_NOTIFICATION_INFO,
42e3a631c0SIngo Weinhold	USER_NOTIFICATION_ERROR
43e3a631c0SIngo Weinhold};
44e3a631c0SIngo Weinhold
45e3a631c0SIngo Weinhold
46e3a631c0SIngo Weinholdclass UserInterface : public BReferenceable {
47e3a631c0SIngo Weinholdpublic:
48e3a631c0SIngo Weinhold	virtual						~UserInterface();
49e3a631c0SIngo Weinhold
50bbc85109SRene Gollent	virtual const char*			ID() const = 0;
51bbc85109SRene Gollent
52e3a631c0SIngo Weinhold	virtual	status_t			Init(Team* team,
53e3a631c0SIngo Weinhold									UserInterfaceListener* listener) = 0;
54e3a631c0SIngo Weinhold	virtual	void				Show() = 0;
55e3a631c0SIngo Weinhold	virtual	void				Terminate() = 0;
56e3a631c0SIngo Weinhold									// shut down the UI *now* -- no more user
57e3a631c0SIngo Weinhold									// feedback
58e3a631c0SIngo Weinhold
5905fc1277SRene Gollent	virtual	UserInterface*		Clone() const = 0;
6005fc1277SRene Gollent									// returns a new instance of the
6105fc1277SRene Gollent									// appropriate user interface subclass.
6205fc1277SRene Gollent									// primarily needed in order to
6305fc1277SRene Gollent									// reconstruct the necessary information
6405fc1277SRene Gollent									// for initiating a team restart.
6505fc1277SRene Gollent
66bbf320ecSRene Gollent	virtual	bool				IsInteractive() const = 0;
67bbf320ecSRene Gollent
68f4b1ddb5SIngo Weinhold	virtual status_t			LoadSettings(const TeamUiSettings* settings)
69bbc85109SRene Gollent									= 0;
70f4b1ddb5SIngo Weinhold	virtual status_t			SaveSettings(TeamUiSettings*& settings)
71bbc85109SRene Gollent									const = 0;
72bbc85109SRene Gollent
73e3a631c0SIngo Weinhold	virtual	void				NotifyUser(const char* title,
74e3a631c0SIngo Weinhold									const char* message,
75e3a631c0SIngo Weinhold									user_notification_type type) = 0;
767f77789dSRene Gollent	virtual	void				NotifyBackgroundWorkStatus(const char* message)
777f77789dSRene Gollent									= 0;
787f77789dSRene Gollent									// this is used to inform the user about
797f77789dSRene Gollent									// background processing work, but doesn't
807f77789dSRene Gollent									// otherwise require any form of
817f77789dSRene Gollent									// user interaction, i.e. for a status bar
827f77789dSRene Gollent									// to indicate that debug information is
837f77789dSRene Gollent									// being parsed.
847f77789dSRene Gollent
85e3a631c0SIngo Weinhold	virtual	int32				SynchronouslyAskUser(const char* title,
86e3a631c0SIngo Weinhold									const char* message, const char* choice1,
87e3a631c0SIngo Weinhold									const char* choice2, const char* choice3)
88e3a631c0SIngo Weinhold									= 0;
89eba38eb5SIngo Weinhold									// returns -1, if not implemented or user
90eba38eb5SIngo Weinhold									// cannot be asked
91d9e97187SRene Gollent
92d9e97187SRene Gollent	virtual	status_t			SynchronouslyAskUserForFile(entry_ref* _ref)
93d9e97187SRene Gollent									= 0;
94e3a631c0SIngo Weinhold};
95e3a631c0SIngo Weinhold
96e3a631c0SIngo Weinhold
97e3a631c0SIngo Weinholdclass UserInterfaceListener {
98eba38eb5SIngo Weinholdpublic:
994d8eaa5bSIngo Weinhold			enum QuitOption {
1004d8eaa5bSIngo Weinhold				QUIT_OPTION_ASK_USER,
1014d8eaa5bSIngo Weinhold				QUIT_OPTION_ASK_KILL_TEAM,
1024d8eaa5bSIngo Weinhold				QUIT_OPTION_ASK_RESUME_TEAM
1034d8eaa5bSIngo Weinhold			};
104eba38eb5SIngo Weinhold
105e3a631c0SIngo Weinholdpublic:
106e3a631c0SIngo Weinhold	virtual						~UserInterfaceListener();
107e3a631c0SIngo Weinhold
108e3a631c0SIngo Weinhold	virtual	void				FunctionSourceCodeRequested(
109442f71a7SRene Gollent									FunctionInstance* function,
110442f71a7SRene Gollent									bool forceDisassembly = false) = 0;
1115a13e7b0SRene Gollent	virtual void				SourceEntryLocateRequested(
1125a13e7b0SRene Gollent									const char* sourcePath,
1135a13e7b0SRene Gollent									const char* locatedPath) = 0;
114432da9e3SRene Gollent	virtual	void				SourceEntryInvalidateRequested(
115432da9e3SRene Gollent									LocatableFile* sourceFile) = 0;
116e3a631c0SIngo Weinhold	virtual	void				ImageDebugInfoRequested(Image* image) = 0;
11759ea286fSIngo Weinhold	virtual	void				ValueNodeValueRequested(CpuState* cpuState,
11859ea286fSIngo Weinhold									ValueNodeContainer* container,
11959ea286fSIngo Weinhold									ValueNode* valueNode) = 0;
1207d25ab99SRene Gollent	virtual	void				ValueNodeWriteRequested(ValueNode* node,
1217d25ab99SRene Gollent									CpuState* state, Value* newValue) = 0;
122e3a631c0SIngo Weinhold	virtual	void				ThreadActionRequested(thread_id threadID,
12342d73abaSRene Gollent									uint32 action,
12442d73abaSRene Gollent									target_addr_t address = 0) = 0;
125e3a631c0SIngo Weinhold
126e3a631c0SIngo Weinhold	virtual	void				SetBreakpointRequested(target_addr_t address,
127468c8dfaSRene Gollent									bool enabled, bool hidden = false) = 0;
128e3a631c0SIngo Weinhold	virtual	void				SetBreakpointEnabledRequested(
129e3a631c0SIngo Weinhold									UserBreakpoint* breakpoint,
130e3a631c0SIngo Weinhold									bool enabled) = 0;
131942226c7SRene Gollent	virtual	void				SetBreakpointConditionRequested(
132942226c7SRene Gollent									UserBreakpoint* breakpoint,
133942226c7SRene Gollent									const char* condition) = 0;
134942226c7SRene Gollent	virtual	void				ClearBreakpointConditionRequested(
135942226c7SRene Gollent									UserBreakpoint* breakpoint) = 0;
136e3a631c0SIngo Weinhold	virtual	void				ClearBreakpointRequested(
137e3a631c0SIngo Weinhold									target_addr_t address) = 0;
138e3a631c0SIngo Weinhold	virtual	void				ClearBreakpointRequested(
139e3a631c0SIngo Weinhold									UserBreakpoint* breakpoint) = 0;
140e3a631c0SIngo Weinhold									// TODO: Consolidate those!
141e3a631c0SIngo Weinhold
142cae8421dSRene Gollent	virtual	void				SetStopOnImageLoadRequested(bool enabled,
143cae8421dSRene Gollent									bool useImageNames) = 0;
144cae8421dSRene Gollent	virtual	void				AddStopImageNameRequested(
145cae8421dSRene Gollent									const char* name) = 0;
146cae8421dSRene Gollent	virtual	void				RemoveStopImageNameRequested(
147cae8421dSRene Gollent									const char* name) = 0;
1485b402aa2SRene Gollent
14914a55dceSRene Gollent	virtual	void				SetDefaultSignalDispositionRequested(
15014a55dceSRene Gollent									int32 disposition) = 0;
15114a55dceSRene Gollent	virtual	void				SetCustomSignalDispositionRequested(
15214a55dceSRene Gollent									int32 signal, int32 disposition) = 0;
15314a55dceSRene Gollent	virtual	void				RemoveCustomSignalDispositionRequested(
15414a55dceSRene Gollent									int32 signal) = 0;
15514a55dceSRene Gollent
1564235cb3eSRene Gollent	virtual	void				SetWatchpointRequested(target_addr_t address,
1574235cb3eSRene Gollent									uint32 type, int32 length,
1584235cb3eSRene Gollent									bool enabled) = 0;
1594235cb3eSRene Gollent	virtual	void				SetWatchpointEnabledRequested(
1604235cb3eSRene Gollent									Watchpoint* watchpoint,
1614235cb3eSRene Gollent									bool enabled) = 0;
1624235cb3eSRene Gollent	virtual	void				ClearWatchpointRequested(
1634235cb3eSRene Gollent									target_addr_t address) = 0;
1644235cb3eSRene Gollent	virtual	void				ClearWatchpointRequested(
1654235cb3eSRene Gollent									Watchpoint* watchpoint) = 0;
1664235cb3eSRene Gollent
1673e3ce16fSRene Gollent	virtual void				InspectRequested(
1683e3ce16fSRene Gollent									target_addr_t address,
1693e3ce16fSRene Gollent									TeamMemoryBlock::Listener* listener) = 0;
17068e78ff8SRene Gollent	virtual	void				MemoryWriteRequested(
17168e78ff8SRene Gollent									target_addr_t address,
17268e78ff8SRene Gollent									const void* data,
17368e78ff8SRene Gollent									target_size_t length) = 0;
1743e3ce16fSRene Gollent
1752d5794a1SRene Gollent	virtual	void				ExpressionEvaluationRequested(
1762d5794a1SRene Gollent									SourceLanguage* language,
177d1c9ffedSRene Gollent									ExpressionInfo* info,
178c3f81329SRene Gollent									StackFrame* frame = NULL,
179fce4895dSRene Gollent									::Thread* thread = NULL) = 0;
1802d5794a1SRene Gollent
1812efebaa1SRene Gollent	virtual void				DebugReportRequested(entry_ref* path) = 0;
1822efebaa1SRene Gollent
183e2d845a4SRene Gollent	virtual	void				WriteCoreFileRequested(entry_ref* path) = 0;
184e2d845a4SRene Gollent
1857cbc5a59SRene Gollent	virtual	void				TeamRestartRequested() = 0;
1867cbc5a59SRene Gollent
187eba38eb5SIngo Weinhold	virtual	bool				UserInterfaceQuitRequested(
188eba38eb5SIngo Weinhold									QuitOption quitOption
189eba38eb5SIngo Weinhold										= QUIT_OPTION_ASK_USER) = 0;
190e3a631c0SIngo Weinhold};
191e3a631c0SIngo Weinhold
192e3a631c0SIngo Weinhold
193e3a631c0SIngo Weinhold#endif	// USER_INTERFACE_H