-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathconfigmanager.h
More file actions
91 lines (70 loc) · 2.65 KB
/
configmanager.h
File metadata and controls
91 lines (70 loc) · 2.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/*
* Copyright 2020 Sinodun Internet Technologies Ltd.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, you can obtain one at https://mozilla.org/MPL/2.0/.
*/
#ifndef CONFIGMGR_H
#define CONFIGMGR_H
#include <string>
#include <QObject>
#include <QProcess>
#include "config.h"
#include "networkmanager.h"
class MainWindow;
class ConfigMgr : public QObject
{
Q_OBJECT
public:
ConfigMgr(MainWindow *parent);
virtual ~ConfigMgr();
static const std::string APPDIRNAME;
static const std::string NETPROFILENAME;
static const std::string DEFNETPROFILENAME;
static const std::string STUBBYTEMPLATENAME;
static ConfigMgr * factory(MainWindow *parent);
Config displayedConfig;
void init();
void load();
bool saveAll(bool restart);
bool saveProfile(Config::NetworkProfile networkProfile);
void saveNetworks();
void saveUpdatedNetworks();
std::string generateStubbyConfig();
bool profileModifiedFromFactory(Config::NetworkProfile networkProfile);
bool profileModifiedFromSaved(Config::NetworkProfile networkProfile);
bool networksModifiedFromSaved();
bool modifiedFromFactoryDefaults();
bool modifiedFromSavedConfig();
void profileRestoreSaved(Config::NetworkProfile networkProfile);
void profileRestoreFactory(Config::NetworkProfile networkProfile);
void networksRestoreSaved();
void restoreSaved();
void restoreFactory();
void updateNetworks(std::map<std::string, NetworkMgr::interfaceInfo> running_networks);
std::string getCurrentProfileString() const;
std::string getCurrentNetworksString() const;
signals:
void configChanged(bool restart);
protected:
bool profileModifiedFrom(const Config& cfg, Config::NetworkProfile networkProfile);
bool networksModifiedFrom(const Config& cfg);
bool modifiedFrom(const Config& cfg);
void profileRestoreFrom(const Config& cfg, Config::NetworkProfile networkProfile);
void networksRestoreFrom(const Config& cfg);
void restoreFrom(const Config& cfg);
bool saveConfig(const Config& cfg);
bool profilesValid(Config::NetworkProfile profile, bool check_all);
Config::NetworkProfile addNetwork(const std::string& name, NetworkMgr::InterfaceTypes type, bool active);
MainWindow *m_mainwindow;
Config factoryConfig;
Config savedConfig;
Config tempConfig; // used to determine if restart needed
bool restartRequired;
Config::NetworkProfile m_current_profile;
std::string m_current_networks_string;
virtual std::string appDataDir() = 0;
virtual std::string appDir();
};
#endif