/*
** 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 1, or (at your option)
** any later version.

** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
** GNU General Public License for more details.

** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/

/*
 * Author : Alexandre Parenteau <aubonbeurre@hotmail.com> --- December 1997
 */

/*
 * CvsCommands.h --- set of CVS commands
 */

#ifndef CVSCOMMANDS_H
#define CVSCOMMANDS_H

#include "CPStr.h"

#define MAX_ARGS	40
#define MAX_CMD_LEN	2048

/// Edit command type enum
typedef enum
{
	kEditNormal,	/*!< cvs edit */
	kEditReserved,	/*!< cvs edit -c */
	kEditForce		/*!< cvs edit -f */
} kEditCmdType;

/// Add command type enum
typedef enum
{
	kAddNormal,	/*!< cvs add */
	kAddBinary,	/*!< cvs add -kb */
	kAddUnicode	/*!< cvs add -ku */
} kAddCmdType;

/// Diff command type enum
typedef enum
{
	kDiffFile,		/*!< Diff file selection */
	kDiffFolder,	/*!< Diff folder selection */
	kDiffGraph		/*!< Diff graph selection */
} kDiffCmdType;

class KiSelectionHandler;

// Helper functions
char* CleanupLogMsg(const char* msg);
bool SplitPath(const char* dir, CStr& uppath, CStr& folder, bool dontSkipDelimiter = false);
bool MakeTmpFile(CStr& file, const char* prefix, const char* extension = 0L, bool create = false);
void GetExtension(const char* file, CStr& base, CStr& ext);
bool GetEnvValue(const char* cmd, const char* key, UStr& value);
int StringToArgv(const char* cmdLine, char** argv);

// Helper commands
bool LaunchDiff(const char* file1, const char* file2);
bool LaunchViewer(const char* filePath, bool useDefault = false);
bool LaunchEditor(const char* filePath, void* par = 0L);

// Command functions that don't carry the selection and don't need the selection handler
void CvsCmdInit();
void CvsCmdLogin(void);
void CvsCmdLogout(void);

// Command functions that may need the selection and need a selection handler
void CvsCmdRtagCreate(KiSelectionHandler& handler);
void CvsCmdRtagDelete(KiSelectionHandler& handler);
void CvsCmdRtagBranch(KiSelectionHandler& handler);
void CvsCmdCommandLine(KiSelectionHandler& handler);

// Command functions that need both the selection and the selection handler
void CvsCmdCheckoutModule(KiSelectionHandler& handler);
void CvsCmdImportModule(KiSelectionHandler& handler);
void CvsCmdCancelChanges(KiSelectionHandler& handler);
void CvsCmdUpdate(KiSelectionHandler& handler, bool queryOnly = false);
void CvsCmdCommit(KiSelectionHandler& handler);
void CvsCmdDiff(KiSelectionHandler& handler, kDiffCmdType diffType);
void CvsCmdAdd(KiSelectionHandler& handler, kAddCmdType addType = kAddNormal);
void CvsCmdRemove(KiSelectionHandler& handler);
void CvsCmdLog(KiSelectionHandler& handler, bool outGraph = false, void* defWnd = 0L);
void CvsCmdStatus(KiSelectionHandler& handler);
void CvsCmdLock(KiSelectionHandler& handler);
void CvsCmdUnlock(KiSelectionHandler& handler);
void CvsCmdTagCreate(KiSelectionHandler& handler);
void CvsCmdTagDelete(KiSelectionHandler& handler);
void CvsCmdTagBranch(KiSelectionHandler& handler);
void CvsCmdEdit(KiSelectionHandler& handler, kEditCmdType editType = kEditNormal);
void CvsCmdUnedit(KiSelectionHandler& handler);
void CvsCmdWatchOn(KiSelectionHandler& handler);
void CvsCmdWatchOff(KiSelectionHandler& handler);
void CvsCmdRelease(KiSelectionHandler& handler);
void CvsCmdWatchers(KiSelectionHandler& handler);
void CvsCmdEditors(KiSelectionHandler& handler);
void CvsCmdAnnotate(KiSelectionHandler& handler);
void CvsCmdMoveToTrash(KiSelectionHandler& handler);

void CvsCmdMacrosAdmin(const char* macroName);
	// TO_OBSOLETE

#endif /* CVSCOMMANDS_H */
