source: src-qt4/libpcbsd/utils/pcbsd-utils.h @ 3f6d079

enter/10releng/10.0.1releng/10.0.2releng/10.0.3releng/10.1releng/10.1.1releng/10.1.2
Last change on this file since 3f6d079 was 3f6d079, checked in by yurkis <yurkis@…>, 17 months ago

Added optional 'configuration application' to de-info, de profiles and libpcbsd de-info backand

  • 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 ConfigurationApplication;
54    QString TerminalCommand;
55    QString TerminalTitleKey;
56    QString TerminalCommandKey;
57    bool    isTerminalNeedParamsSplit;
58    QString FileManager;
59
60    _DesktopEnvironmentInfo():isInstalled(false), isActive(false), isXDG(false), isTerminalNeedParamsSplit(false)
61    {;}
62
63}DesktopEnvironmentInfo;
64
65class Utils
66{
67public:
68   /** Get sysctl value as string
69    *
70    * \param sysctl - name of sysctl variable
71    *
72    *\return variable value
73    */
74   static QString sysctl(QString sysctl);
75
76   /** Get sysctl value as integer
77    *
78    * \param sysctl - name of sysctl variable
79    *
80    *\return variable value
81    */
82   static long long sysctlAsInt(QString sysctl);
83
84   /** Get human readable value of some storage space ( xx Mb, xx Gb, etc)
85    *
86    * \param bytes - amount of bytes
87    *
88    * \return string in human readable form
89    */
90   static QString bytesToHumanReadable(long long bytes);
91
92   /** Function to get a value from a specific key in the pbi.conf file
93    *
94    *\param key- key name from pbi.conf
95    *
96    *\return Value of parameter
97    */
98   static QString getValFromPBIConf(QString key);
99
100   /**  Function to get a value from a specific key in the pcbsd.conf file
101    *
102    *\param key- key name from pcbsd.conf
103    *
104    *\return Value of parameter
105    */
106   static QString getValFromPCBSDConf(QString key);
107
108   /** Get value for from a specific key in the system config "ini style" file
109    *
110    *\param conf - config file name
111    *\param key - key name in file 'conf'
112    *
113    *\return Value of 'key'
114    **/
115   static QString getValFromPCConf(QString conf, QString key);
116
117   /** Get system proxy url
118    *
119    *\return System proxy URL
120    */
121   static QString getProxyURL();
122
123   /** Get username for proxy access
124    *
125    *\return User name
126    */
127   static QString getProxyUser();
128   static QString getProxyPass();
129   static QString getProxyType();
130   static QString getProxyPort();
131   static QString getMasterMirror();
132   static bool setValPBIConf(QString key, QString val);
133   static bool setValSHFile(QString, QString, QString);
134   static bool setValSHFile(QString, QString, QString, QString);
135   static bool setValCSHFile(QString, QString, QString);
136   static bool setValPCBSDConf(QString key, QString val);
137   static bool setValPCConf(QString conf, QString key, QString val);
138   static bool setProxyAddress(QString val);
139   static bool setProxyAuth(QString val);
140   static bool setMasterMirror(QString val);
141   static bool setConfFileValue( QString oFile, QString oldKey, QString newKey );
142   static bool setConfFileValue( QString oFile, QString oldKey, QString newKey, int occur );
143   static QString getConfFileValue( QString oFile, QString Key );
144   static QString getConfFileValue( QString oFile, QString Key, int occur );
145   static QString getConfFileValue( QString oFile, QString Key, QString ValRx, int occur );
146   static QStringList runShellCommand( QString command );
147   static QString runShellCommandSearch( QString command, QString sch );
148   static QStringList listShellCommandSearch( QString command, QString sch );
149   static QString getLineFromCommandOutput( QString cmd );
150   static QString getValFromSHFile(QString envFile, QString envVal);
151   static QString getValFromCSHFile(QString envFile, QString envVal);
152   static void restartNetworking();
153   static void runInTerminal(QString command, QString windowTitle=QString());
154   static void openInFileManager(QString location);
155   static bool validateIPV6(QString);
156   static bool validateIPV4(QString);
157
158   static QVector<DesktopEnvironmentInfo> installedDesktops();
159   static DesktopEnvironmentInfo currentDesktop();
160};
161
162} //namespace
163
164#endif
Note: See TracBrowser for help on using the repository browser.