2 * Copyright 1995, 2000 Perforce Software. All rights reserved.
4 * This file is part of Perforce - the FAST SCM System.
8 * ClientUser - user interface primitives
12 * ClientUser - user interface for client services
14 * Note that not all methods are always used. Here's a guideline:
16 * Used by almost all Perforce commands:
26 * Used only by commands that read the client's stdin:
30 * Used only by 'p4 fstat' and some other commands when the
31 * protocol variable 'tag' is set:
35 * Used only by interactive commands that can generally be avoided:
42 * Used only by the default ClientUser implementation:
49 * ClientUser::InputData() - provide data to 'p4 spec-command -i';
50 * spec-command is branch, change, client, job, label, protect,
53 * ClientUser::HandleError() - process error data, the result of a failed
54 * command. Default is to format output and call OutputError().
56 * ClientUser::Message() - output error or tabular data. This is the
57 * 2002.1 replacement for OutputInfo/Error: earlier servers
58 * will invoke still HandleError() and OutputInfo().
60 * ClinetUser::OutputError() - output error data, the result of a failed
63 * ClientUser::OutputInfo() - output tabular data, the result of most
64 * commands that report metadata.
66 * ClientUser::OutputBinary() - output binary data, generally the result
67 * of 'p4 print binary_file'.
69 * ClientUser::OutputText() - output text data, generally the result
70 * of 'p4 print text_file'.
72 * ClientUser::OutputStat() - output results of 'p4 fstat'; requires
73 * calling StrDict::GetVar() to get the actual variable results.
75 * ClientUser::Prompt() - prompt the user, and wait for a response.
77 * ClientUser::ErrorPause() - print an error message and wait for the
78 * user before continuing.
80 * ClientUser::Edit() - bring the user's editor up on a file; generally
81 * part of 'p4 spec-command'.
83 * ClientUser::Diff() - diff two files, and display the results; the
84 * result of 'p4 diff'.
86 * ClientUser::Merge() - merge three files and save the results; the
87 * result of saying 'm' to the resolve dialog of 'p4 resolve'.
89 * ClientUser::Help() - dump out a block of help text to the user;
90 * used by the resolve dialogs.
92 * ClientUser::File() - produce a FileSys object for reading
93 * and writing files in client workspace.
95 * ClientUser::Finished() - called when tagged client call is finished.
104 ClientUser() { binaryStdout
= 0; }
105 virtual ~ClientUser();
107 virtual void InputData( StrBuf
*strbuf
, Error
*e
);
109 virtual void HandleError( Error
*err
);
110 virtual void Message( Error
*err
);
111 virtual void OutputError( const_char
*errBuf
);
112 virtual void OutputInfo( char level
, const_char
*data
);
113 virtual void OutputBinary( const_char
*data
, int length
);
114 virtual void OutputText( const_char
*data
, int length
);
116 virtual void OutputStat( StrDict
*varList
);
118 virtual void Prompt( const StrPtr
&msg
, StrBuf
&rsp
,
119 int noEcho
, Error
*e
);
120 virtual void ErrorPause( char *errBuf
, Error
*e
);
122 virtual void Edit( FileSys
*f1
, Error
*e
);
124 virtual void Diff( FileSys
*f1
, FileSys
*f2
, int doPage
,
125 char *diffFlags
, Error
*e
);
127 virtual void Merge( FileSys
*base
, FileSys
*leg1
, FileSys
*leg2
,
128 FileSys
*result
, Error
*e
);
130 virtual int Resolve( ClientMerge
*m
, Error
*e
);
132 virtual void Help( const_char
*const *help
);
134 virtual FileSys
*File( FileSysType type
);
136 virtual void Finished() {}
138 StrDict
*varList
; // (cheesy) access to RPC buffer
139 Enviro
*enviro
; // (cheesy) access to Client's env
141 static void Edit( FileSys
*f1
, Enviro
* env
, Error
*e
);
143 static void RunCmd( const char *command
, const char *arg1
,
144 const char *arg2
, const char *arg3
,
145 const char *arg4
, const char *pager
,
149 int binaryStdout
; // stdout is in binary mode
153 * StrDict now provides the GetVar() interface for OutputStat();
154 * ClientVarList defined for backward compatability.
157 typedef StrDict ClientVarList
;