Chris@57: /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ Chris@57: Chris@57: /* Chris@57: EasyMercurial Chris@57: Chris@57: Based on HgExplorer by Jari Korhonen Chris@57: Copyright (c) 2010 Jari Korhonen Chris@244: Copyright (c) 2011 Chris Cannam Chris@244: Copyright (c) 2011 Queen Mary, University of London Chris@57: Chris@57: This program is free software; you can redistribute it and/or Chris@57: modify it under the terms of the GNU General Public License as Chris@57: published by the Free Software Foundation; either version 2 of the Chris@57: License, or (at your option) any later version. See the file Chris@57: COPYING included with this distribution for more information. Chris@57: */ Chris@57: jtkorhonen@0: #ifndef COMMON_H jtkorhonen@0: #define COMMON_H jtkorhonen@0: Chris@50: #include jtkorhonen@0: Chris@172: extern QString findInPath(QString name, QString installPath, bool executable); jtkorhonen@0: jtkorhonen@0: extern QString getSystem(); jtkorhonen@0: extern QString getHgDirName(); jtkorhonen@0: Chris@62: extern QString getUserRealName(); Chris@62: Chris@78: extern void loseControllingTerminal(); Chris@78: Chris@105: void installSignalHandlers(); Chris@105: Chris@79: /** Chris@79: * Status used in testing whether a folder argument (received from the Chris@79: * user) is valid for particular uses. Chris@79: */ Chris@79: enum FolderStatus { Chris@79: FolderUnknown, /// Neither the folder nor its parent exists Chris@79: FolderParentExists, /// The folder is absent, but its parent exists Chris@79: FolderExists, /// The folder exists and has no .hg repo in it Chris@79: FolderHasRepo, /// The folder exists and has an .hg repo in it Chris@79: FolderIsFile /// The "folder" is actually a file Chris@79: }; Chris@79: Chris@79: FolderStatus getFolderStatus(QString path); Chris@79: Chris@79: /** Chris@79: * If the given path is somewhere within an existing repository, Chris@79: * return the path of the root directory of the repository (i.e. the Chris@79: * one with .hg in it). Chris@79: * Chris@79: * If the given path is _not_ in a repository, or the given path _is_ Chris@79: * the root directory of a repository, return QString(). Use Chris@79: * getFolderStatus to distinguish between these cases. Chris@79: */ Chris@79: QString getContainingRepoFolder(QString path); Chris@79: Chris@79: QString xmlEncode(QString); Chris@408: Chris@408: QString uniDecode(QString); Chris@443: Chris@443: /** Chris@443: * Generate a 16-byte random key using urandom or equivalent Chris@443: */ Chris@443: QByteArray randomKey(); Chris@79: Chris@79: jtkorhonen@0: #endif //COMMON_H jtkorhonen@0: jtkorhonen@0: