source: src-qt4/libpcbsd/utils/pcbsd-utils.h @ 7c7f02c

9.2-releasereleng/10.0releng/10.0.1releng/10.0.2
Last change on this file since 7c7f02c was 7c7f02c, checked in by Kris Moore <kris@…>, 10 months ago

Add a better method of setting SH values, so that we can specify
the types of quotes used

  • Property mode set to 100644
File size: 5.9 KB
Line 
1/***************************************************************************
2 *   Copyright (C) 2008 by Tim McCormick   *
3 *   tim@pcbsd.org   *
4 *                                                                         *
5 *   Permission is hereby granted, free of charge, to any person obtaining *
6 *   a copy of this software and associated documentation files (the       *
7 *   "Software"), to deal in the Software without restriction, including   *
8 *   without limitation the rights to use, copy, modify, merge, publish,   *
9 *   distribute, sublicense, and/or sell copies of the Software, and to    *
10 *   permit persons to whom the Software is furnished to do so, subject to *
11 *   the following conditions:                                             *
12 *                                                                         *
13 *   The above copyright notice and this permission notice shall be        *
14 *   included in all copies or substantial portions of the Software.       *
15 *                                                                         *
16 *   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,       *
17 *   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF    *
18 *   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
19 *   IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR     *
20 *   OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, *
21 *   ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR *
22 *   OTHER DEALINGS IN THE SOFTWARE.                                       *
23 ***************************************************************************/
24#include <QCoreApplication>
25#include <QDebug>
26#include <QDialog>
27#include <QFile>
28#include <QLabel>
29#include <QPushButton>
30#include <QProcess>
31#include <QProgressDialog>
32#include <QMenu>
33#include <QMessageBox>
34#include <QTranslator>
35#include <QTreeWidget>
36#include <QWidget>
37
38 
39#ifndef _PCBSD_UTILS_H_
40#define _PCBSD_UTILS_H_
41
42namespace pcbsd
43{
44
45typedef struct _DesktopEnvironmentInfo
46{
47public:
48    QString Name;          ///< De name 'Gnome', 'KDE', etc
49    QString SudoCommand;   ///< native sudo command 'gtksu %s' for example
50    bool    isInstalled;   ///< True if DE installed
51    bool    isActive;      ///< True if DE is active now
52    bool    isXDG;         ///< True if DE is XDG compatible
53    QString TerminalCommand;
54    QString TerminalTitleKey;
55    QString TerminalCommandKey;
56    bool    isTerminalNeedParamsSplit;
57    QString FileManager;
58
59    _DesktopEnvironmentInfo():isInstalled(false), isActive(false), isXDG(false), isTerminalNeedParamsSplit(false)
60    {;}
61
62}DesktopEnvironmentInfo;
63
64class Utils
65{
66public:
67   /** Get sysctl value as string
68    *
69    * \param sysctl - name of sysctl variable
70    *
71    *\return variable value
72    */
73   static QString sysctl(QString sysctl);
74
75   /** Get sysctl value as integer
76    *
77    * \param sysctl - name of sysctl variable
78    *
79    *\return variable value
80    */
81   static long long sysctlAsInt(QString sysctl);
82
83   /** Get human readable value of some storage space ( xx Mb, xx Gb, etc)
84    *
85    * \param bytes - amount of bytes
86    *
87    * \return string in human readable form
88    */
89   static QString bytesToHumanReadable(long long bytes);
90
91   /** Function to get a value from a specific key in the pbi.conf file
92    *
93    *\param key- key name from pbi.conf
94    *
95    *\return Value of parameter
96    */
97   static QString getValFromPBIConf(QString key);
98
99   /**  Function to get a value from a specific key in the pcbsd.conf file
100    *
101    *\param key- key name from pcbsd.conf
102    *
103    *\return Value of parameter
104    */
105   static QString getValFromPCBSDConf(QString key);
106
107   /** Get value for from a specific key in the system config "ini style" file
108    *
109    *\param conf - config file name
110    *\param key - key name in file 'conf'
111    *
112    *\return Value of 'key'
113    **/
114   static QString getValFromPCConf(QString conf, QString key);
115
116   /** Get system proxy url
117    *
118    *\return System proxy URL
119    */
120   static QString getProxyURL();
121
122   /** Get username for proxy access
123    *
124    *\return User name
125    */
126   static QString getProxyUser();
127   static QString getProxyPass();
128   static QString getProxyType();
129   static QString getProxyPort();
130   static QString getMasterMirror();
131   static bool setValPBIConf(QString key, QString val);
132   static bool setValSHFile(QString, QString, QString);
133   static bool setValSHFile(QString, QString, QString, QString);
134   static bool setValCSHFile(QString, QString, QString);
135   static bool setValPCBSDConf(QString key, QString val);
136   static bool setValPCConf(QString conf, QString key, QString val);
137   static bool setProxyAddress(QString val);
138   static bool setProxyAuth(QString val);
139   static bool setMasterMirror(QString val);
140   static bool setConfFileValue( QString oFile, QString oldKey, QString newKey );
141   static bool setConfFileValue( QString oFile, QString oldKey, QString newKey, int occur );
142   static QString getConfFileValue( QString oFile, QString Key );
143   static QString getConfFileValue( QString oFile, QString Key, int occur );
144   static QString getConfFileValue( QString oFile, QString Key, QString ValRx, int occur );
145   static QStringList runShellCommand( QString command );
146   static QString runShellCommandSearch( QString command, QString sch );
147   static QStringList listShellCommandSearch( QString command, QString sch );
148   static QString getLineFromCommandOutput( QString cmd );
149   static QString getValFromSHFile(QString envFile, QString envVal);
150   static QString getValFromCSHFile(QString envFile, QString envVal);
151   static void restartNetworking();
152   static void runInTerminal(QString command, QString windowTitle=QString());
153   static void openInFileManager(QString location);
154   static bool validateIPV6(QString);
155   static bool validateIPV4(QString);
156
157   static QVector<DesktopEnvironmentInfo> installedDesktops();
158   static DesktopEnvironmentInfo currentDesktop();
159};
160
161} //namespace
162
163#endif
Note: See TracBrowser for help on using the repository browser.