Repository :
http://git.fedorahosted.org/cgit/firewalld-recode.git
On branch : master
---------------------------------------------------------------
commit a187923ddd71aff67006f1733c9366ab5ec8d5a6
Author: Daniel Kopecek <dkopecek(a)redhat.com>
Date: Wed Oct 22 13:12:53 2014 +0200
Remove unused methods and add transaction related ones to the Firewall class
---------------------------------------------------------------
src/Daemon/Firewall/Firewall.cpp | 80 ++++++++++---------------------------
src/Daemon/Firewall/Firewall.hpp | 24 ++++-------
2 files changed, 31 insertions(+), 73 deletions(-)
diff --git a/src/Daemon/Firewall/Firewall.cpp b/src/Daemon/Firewall/Firewall.cpp
index 18a2c35..f2d09d1 100644
--- a/src/Daemon/Firewall/Firewall.cpp
+++ b/src/Daemon/Firewall/Firewall.cpp
@@ -146,24 +146,6 @@ namespace firewalld
}
}
- void Firewall::getAllZoneNames(UStringVector& names) const
- {
- for (auto const& map_entry : _zone_map) {
- auto zone = map_entry.second;
- names.push_back(zone->name());
- }
- }
-
- void Firewall::getActiveZoneNames(UStringVector& names) const
- {
- for (auto const& map_entry : _zone_map) {
- auto zone = map_entry.second;
- if (zone->isActive()) {
- names.push_back(zone->name());
- }
- }
- }
-
Pointer<Source> Firewall::getSource(const UString& source_spec) const
{
for (auto& map_entry : _zone_map) {
@@ -188,86 +170,68 @@ namespace firewalld
return nullptr;
}
- ///////////////////////////
-
const UString& Firewall::getDefaultZoneName() const
{
- Glib::Threads::Mutex::Lock lock(_mutex);
return _default_zone;
}
bool Firewall::setDefaultZoneName(const UString& name)
{
- Glib::Threads::Mutex::Lock lock(_mutex);
_default_zone = name;
return true;
}
UStringVector Firewall::getAllZoneNames() const
{
- Glib::Threads::Mutex::Lock lock(_mutex);
UStringVector keys;
for (auto const& entry : _zone_map) {
keys.push_back(entry.first);
}
- return keys;
- }
-
- bool Firewall::addZoneName(const UString& name)
- {
- return true;
+ return std::move(keys);
}
UStringVector Firewall::getActiveZoneNames() const
{
- Glib::Threads::Mutex::Lock lock(_mutex);
- UStringVector active_zones;
+ UStringVector names;
- return active_zones;
- }
+ for (auto const& map_entry : _zone_map) {
+ auto zone = map_entry.second;
+ if (zone->isActive()) {
+ names.push_back(zone->name());
+ }
+ }
- UStringVector Firewall::getZoneInterfaces(const UString& zone_name) const
- {
- Glib::Threads::Mutex::Lock lock(_mutex);
+ return std::move(names);
}
- UStringVector Firewall::getZoneSources(const UString& zone_name) const
+ Pointer<Transaction> Firewall::createTransaction()
{
- Glib::Threads::Mutex::Lock lock(_mutex);
+ return _backend->createTransaction();
}
- void Firewall::addInterfaceToZone(const UString& zone_name, const UString&
interface)
+ void Firewall::commitTransaction(Pointer<Transaction> transaction)
{
- Glib::Threads::Mutex::Lock lock(_mutex);
+ // TODO: process at the internal state level
+ // before executing the transaction in the
+ // backend
+ _backend->commitTransaction(transaction);
}
- void Firewall::addSourceToZone(const UString& zone_name, const UString&
source)
+ void Firewall::removeTransaction(const String& identifier)
{
- Glib::Threads::Mutex::Lock lock(_mutex);
+ _backend->removeTransaction(identifier);
}
- void Firewall::removeSourceFromZone(const UString& zone_name, const UString&
source)
+ size_t Firewall::countTransactions() const
{
- Glib::Threads::Mutex::Lock lock(_mutex);
-
- return;
+ return _backend->countTransactions();
}
- UString Firewall::getZoneOfSource(const UString& source) const
+ void Firewall::processOperation(const UStringVector& op, bool undo)
{
- return UString();
+ // TODO
}
} /* namespace firewalld */
-
-
-
-
-
-
-
-
-
-
diff --git a/src/Daemon/Firewall/Firewall.hpp b/src/Daemon/Firewall/Firewall.hpp
index 7fa1115..f873ce8 100644
--- a/src/Daemon/Firewall/Firewall.hpp
+++ b/src/Daemon/Firewall/Firewall.hpp
@@ -65,34 +65,28 @@ namespace firewalld
bool directIPv4QueryRule(const String& table, const String& chain, const
String& rule_specification, int rule_num);
bool directIPv6QueryRule(const String& table, const String& chain, const
String& rule_specification, int rule_num);
- //
- // Zone interface
- //
+
bool zoneExists(const UString& name) const;
Pointer<Zone> getZone(const UString& name) const;
- void getAllZoneNames(UStringVector& names) const;
- void getActiveZoneNames(UStringVector& names) const;
Pointer<Source> getSource(const UString& source_spec) const;
Pointer<Interface> getInterface(const UString& interface_identifier)
const;
- /// REFACTORING ///
const UString& getDefaultZoneName() const;
bool setDefaultZoneName(const UString& name);
- UStringVector getAllZoneNames() const;
- bool addZoneName(const UString&);
+ UStringVector getAllZoneNames() const;
UStringVector getActiveZoneNames() const;
- UStringVector getZoneInterfaces(const UString& zone_name) const;
- UStringVector getZoneSources(const UString& zone_name) const;
- void addInterfaceToZone(const UString& zone_name, const UString& interface);
- void addSourceToZone(const UString& zone_name, const UString& source);
- void removeSourceFromZone(const UString& zone_name, const UString& source);
- UString getZoneOfSource(const UString& source) const;
+ Pointer<Transaction> createTransaction();
+ void commitTransaction(Pointer<Transaction> transaction);
+ void removeTransaction(const String& identifier);
+ size_t countTransactions() const;
+
+ protected:
+ void processOperation(const UStringVector& op, bool undo = false);
private:
- mutable Glib::Threads::Mutex _mutex;
UString _default_zone;
PointerMap<UString,Zone> _zone_map;