[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [ufw-kde] /: Import un-released version 0.5.0
From:       Craig Drummond <craig () kde ! org>
Date:       2013-10-13 18:16:43
Message-ID: E1VVQDb-0004GF-Ue () scm ! kde ! org
[Download RAW message or body]

Git commit 9761710cfb5c79eb06fc839af472343a26c91217 by Craig Drummond.
Committed on 13/10/2013 at 18:15.
Pushed by craig into branch 'master'.

Import un-released version 0.5.0
- Convert to Python3, for compatability with Ubuntu 12.10
- Remove support for descriptions, seems to be a bit fiddly with Ubuntu 12.10 ufw, \
and was a bit hacky anyway!

M  +2    -2    CMakeLists.txt
M  +6    -0    ChangeLog
M  +8    -8    helper/helper.cpp
M  +3    -3    helper/helper.h
M  +139  -133  helper/kcm_ufw_helper.py.cmake
M  +13   -13   kcm/kcm.cpp
M  +1    -1    kcm/kcm.h
M  +7    -7    kcm/rule.cpp
M  +16   -16   kcm/rule.h
M  +39   -39   kcm/ruledialog.cpp
M  +2    -2    kcm/ruleslist.cpp
M  +6    -6    kcm/ruleslist.h
M  +0    -36   kcm/rulewidget.ui
M  +0    -5    kcm/ufw.ui

http://commits.kde.org/ufw-kde/9761710cfb5c79eb06fc839af472343a26c91217

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4eb197a..3dbf347 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -7,8 +7,8 @@ set(DEBIAN_PACKAGE_DESCRIPTION "KDE4 GUI for uncomplicated-firewall")
 set(DEBIAN_PACKAGE_SECTION "kde4")
 set(CPACK_SOURCE_GENERATOR "TBZ2")
 set(CPACK_PACKAGE_VERSION_MAJOR "0")
-set(CPACK_PACKAGE_VERSION_MINOR "4")
-set(CPACK_PACKAGE_VERSION_PATCH "3")
+set(CPACK_PACKAGE_VERSION_MINOR "5")
+set(CPACK_PACKAGE_VERSION_PATCH "0")
 set(CPACK_PACKAGE_CONTACT "Craig Drummond <craig.p.drummond@gmail.com>")
 set(KCM_UFW_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}")
 set(KCM_UFW_VERSION_FULL "${KCM_UFW_VERSION}.${CPACK_PACKAGE_VERSION_PATCH}")
diff --git a/ChangeLog b/ChangeLog
index c124323..38c52d5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+0.5.0
+-----
+1. Convert to Python3, for compatability with Ubuntu 12.10
+2. Remove support for descriptions, seems to be a bit fiddly with Ubuntu 12.10
+   ufw, and was a bit hacky anyway!
+
 0.4.3
 -----
 1. Actually get this to work with Kubuntu 12.04!!!
diff --git a/helper/helper.cpp b/helper/helper.cpp
index 8321b78..2b76420 100644
--- a/helper/helper.cpp
+++ b/helper/helper.cpp
@@ -143,8 +143,8 @@ ActionReply Helper::modify(const QVariantMap &args)
         return moveRule(args, cmd);
     else if("editRule"==cmd)
         return editRule(args, cmd);
-    else if("editRuleDescr"==cmd)
-        return editRuleDescr(args, cmd);
+//     else if("editRuleDescr"==cmd)
+//         return editRuleDescr(args, cmd);
     else if("reset"==cmd)
         return reset(cmd);
     else if("setDefaults"==cmd)
@@ -321,12 +321,12 @@ ActionReply Helper::editRule(const QVariantMap &args, const \
QString &cmd)  QStringList() << "--list", cmd);
 }
 
-ActionReply Helper::editRuleDescr(const QVariantMap &args, const QString &cmd)
-{
-    checkFolder();
-    return run(QStringList() << "--updateDescr="+args["xml"].toString(),
-               QStringList() << "--list", cmd);
-}
+// ActionReply Helper::editRuleDescr(const QVariantMap &args, const QString &cmd)
+// {
+//     checkFolder();
+//     return run(QStringList() << "--updateDescr="+args["xml"].toString(),
+//                QStringList() << "--list", cmd);
+// }
 
 ActionReply Helper::reset(const QString &cmd)
 {
diff --git a/helper/helper.h b/helper/helper.h
index 24e447d..691b8cb 100644
--- a/helper/helper.h
+++ b/helper/helper.h
@@ -70,13 +70,13 @@ class Helper : public QObject
     ActionReply removeRule(const QVariantMap &args, const QString &cmd);
     ActionReply moveRule(const QVariantMap &args, const QString &cmd);
     ActionReply editRule(const QVariantMap &args, const QString &cmd);
-    ActionReply editRuleDescr(const QVariantMap &args, const QString &cmd);
+//     ActionReply editRuleDescr(const QVariantMap &args, const QString &cmd);
     ActionReply reset(const QString &cmd);
     ActionReply run(const QStringList &args, const QString &cmd);
     ActionReply run(const QStringList &args, const QStringList &second, const \
                QString &cmd);
-    
+
     private:
-    
+
     LogLister *lister;
 };
 
diff --git a/helper/kcm_ufw_helper.py.cmake b/helper/kcm_ufw_helper.py.cmake
index 9a65275..6963f63 100755
--- a/helper/kcm_ufw_helper.py.cmake
+++ b/helper/kcm_ufw_helper.py.cmake
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 
 #
 # UFW KControl Module
@@ -36,7 +36,7 @@ import gettext
 import getopt
 import shutil
 import hashlib
-import StringIO
+import io
 
 from xml.etree import ElementTree as etree
 from copy import deepcopy
@@ -85,63 +85,63 @@ def localizeUfw():
     gettext.install(ufw.common.programName)
 
 #define looad descriptions file
-descrsChanged=False
-def moveOldDescrFile():
-    try:
-        if os.path.exists(OLD_DESCR_FILE) and os.path.isfile(OLD_DESCR_FILE):
-            shutil.move(OLD_DESCR_FILE, DESCR_FILE)
-    except Exception, e:
-        return # Old file does not exist, or is not a file!...
-
-def loadDescriptions():
-    moveOldDescrFile();
-    try:
-        global descrs
-        descrs={"a":"b"}
-        descrData=open(DESCR_FILE).read()
-        descrs=eval(descrData)
-    except Exception, e:
-        return
-
-def removeDescriptions():
-    try:
-        os.remove(DESCR_FILE)
-        descrsChanged=False
-    except Exception, e:
-        return
-
-def saveDescriptions():
-    global descrsChanged
-    if descrsChanged:
-        try:
-            if descrs.has_key("a"):
-                del descrs["a"]
-            if len(descrs)>0:
-                descrFile = open(DESCR_FILE, 'w')
-                descrFile.write(repr(descrs))
-                descrsChanged=False
-            else:
-                removeDescriptions()
-        except Exception, e:
-            return
-
-def getDescription(hashStr):
-    if descrs.has_key(hashStr):
-        return descrs[hashStr]
-    return ''
-
-def removeDescription(hashStr):
-    if descrs.has_key(hashStr):
-        del descrs[hashStr]
-        global descrsChanged
-        descrsChanged=True
-
-def updateDescription(hashStr, descrStr):
-    if (descrs.has_key(hashStr)==False) or (descrs[hashStr]!=descrStr):
-        removeDescription(hashStr)
-        descrs[hashStr]=descrStr
-        global descrsChanged
-        descrsChanged=True
+# descrsChanged=False
+# def moveOldDescrFile():
+#     try:
+#         if os.path.exists(OLD_DESCR_FILE) and os.path.isfile(OLD_DESCR_FILE):
+#             shutil.move(OLD_DESCR_FILE, DESCR_FILE)
+#     except Exception as e:
+#         return # Old file does not exist, or is not a file!...
+#
+# def loadDescriptions():
+#     moveOldDescrFile();
+#     try:
+#         global descrs
+#         descrs={"a":"b"}
+#         descrData=open(DESCR_FILE).read()
+#         descrs=eval(descrData)
+#     except Exception as e:
+#         return
+#
+# def removeDescriptions():
+#     try:
+#         os.remove(DESCR_FILE)
+#         descrsChanged=False
+#     except Exception as e:
+#         return
+#
+# def saveDescriptions():
+#     global descrsChanged
+#     if descrsChanged:
+#         try:
+#             if ("a" in descrs):
+#                 del descrs["a"]
+#             if len(descrs)>0:
+#                 descrFile = open(DESCR_FILE, 'w')
+#                 descrFile.write(repr(descrs))
+#                 descrsChanged=False
+#             else:
+#                 removeDescriptions()
+#         except Exception as e:
+#             return
+#
+# def getDescription(hashStr):
+#     if (hashStr in descrs):
+#         return descrs[hashStr]
+#     return ''
+#
+# def removeDescription(hashStr):
+#     if (hashStr in descrs):
+#         del descrs[hashStr]
+#         global descrsChanged
+#         descrsChanged=True
+#
+# def updateDescription(hashStr, descrStr):
+#     if ((hashStr in descrs)==False) or (descrs[hashStr]!=descrStr):
+#         removeDescription(hashStr)
+#         descrs[hashStr]=descrStr
+#         global descrsChanged
+#         descrsChanged=True
 
 def loadDefaultSettings(ufw):
     try:
@@ -163,7 +163,7 @@ def loadDefaultSettings(ufw):
                     ufw.backend.set_default(ufw.backend.files['defaults'], 'IPV6', \
value.lower())  elif parts[0] == 'modules':
                     ufw.backend.set_default(ufw.backend.files['defaults'], \
                'IPT_MODULES', '"' + value + '"')
-    except Exception, e:
+    except Exception as e:
         return
 
 # Localise UFW, and init the 'frontend'
@@ -238,7 +238,7 @@ def encodeText(str):
     return str
 
 def ruleDetails(rule):
-    xmlStr = StringIO.StringIO()
+    xmlStr = io.StringIO()
     xmlStr.write("action=\"")
     xmlStr.write(rule.action.lower())
     xmlStr.write("\" direction=\"")
@@ -262,28 +262,31 @@ def ruleDetails(rule):
     xmlStr.write("\" interface_out=\"")
     xmlStr.write(rule.interface_out)
     xmlStr.write("\" v6=\"")
-    xmlStr.write(`rule.v6`)
+    if rule.v6:
+        xmlStr.write('True')
+    else:
+        xmlStr.write('False')
     return xmlStr.getvalue()
 
-def detailsHash(details):
-    ruleHash = hashlib.md5()
-    ruleHash.update(details)
-    return ruleHash.hexdigest()
+# def detailsHash(details):
+#     ruleHash = hashlib.md5()
+#     ruleHash.update(details.encode('utf-8'))
+#     return ruleHash.hexdigest()
 
 # Convert a rule to an XML string...
 def toXml(rule, xmlStr):
     xmlStr.write("<rule position=\"")
-    xmlStr.write(`rule.position`)
+    xmlStr.write(str(rule.position))
     xmlStr.write("\" ")
     details=ruleDetails(rule)
     xmlStr.write(details)
-    hashStr=detailsHash(details)
-    descr=getDescription(hashStr)
-    if descr != '':
-        xmlStr.write("\" descr=\"")
-        xmlStr.write(encodeText(descr).encode('utf-8'))
-        xmlStr.write("\" hash=\"")
-        xmlStr.write(hashStr)
+#     hashStr=detailsHash(details)
+#     descr=getDescription(hashStr)
+#     if descr != '':
+#         xmlStr.write("\" descr=\"")
+#         xmlStr.write(encodeText(descr))
+#         xmlStr.write("\" hash=\"")
+#         xmlStr.write(hashStr)
     xmlStr.write("\" logtype=\"")
     xmlStr.write(rule.logtype)
     xmlStr.write("\" />")
@@ -375,25 +378,25 @@ def getRules(ufw, xmlStr):
         toXml(rule.dup_rule(), xmlStr)
     xmlStr.write("</rules>")
 
-def updateRuleDescription(rule, xml):
-    elem=etree.XML(xml)
-    descr=elem.get('descr', '')
-    oldHashCode=elem.get('hash', '')
-    if descr != '':
-        details=ruleDetails(rule)
-        hashStr=detailsHash(details)
-        # For an update, we should be passed old hash code - if so, remove old \
                entry...
-        if oldHashCode!= '':
-            removeDescription(oldHashCode)
-        updateDescription(hashStr, descr)
-    else:
-        if oldHashCode!= '':
-            removeDescription(oldHashCode)
+# def updateRuleDescription(rule, xml):
+#     elem=etree.XML(xml)
+#     descr=elem.get('descr', '')
+#     oldHashCode=elem.get('hash', '')
+#     if descr != '':
+#         details=ruleDetails(rule)
+#         hashStr=detailsHash(details)
+#         # For an update, we should be passed old hash code - if so, remove old \
entry... +#         if oldHashCode!= '':
+#             removeDescription(oldHashCode)
+#         updateDescription(hashStr, descr)
+#     else:
+#         if oldHashCode!= '':
+#             removeDescription(oldHashCode)
 
 def addRule(ufw, xml):
     rule=fromXml(xml)
     inserted=insertRule(ufw, rule)
-    updateRuleDescription(inserted, xml)
+#     updateRuleDescription(inserted, xml)
 
 def updateRule(ufw, xml):
     rule=fromXml(xml)
@@ -404,16 +407,16 @@ def updateRule(ufw, xml):
         deleted=True
         inserted=insertRule(ufw, rule)
         deleted=False
-        updateRuleDescription(inserted, xml)
-    except Exception, e:
+#         updateRuleDescription(inserted, xml)
+    except Exception as e:
         if deleted:
             insertRule(ufw, prev)
 
-def updateRuleDescr(ufw, xml):
-    rule=fromXml(xml)
-    details=ruleDetails(rule)
-    hashStr=detailsHash(details)
-    updateRuleDescription(rule, xml)
+# def updateRuleDescr(ufw, xml):
+#     rule=fromXml(xml)
+#     details=ruleDetails(rule)
+#     hashStr=detailsHash(details)
+#     updateRuleDescription(rule, xml)
 
 # Remove a rule. Index is either; just the index, or <index>:<hashcode>
 def removeRule(ufw, index):
@@ -425,14 +428,14 @@ def removeRule(ufw, index):
             idx=int(index)
         if idx<1 or \
idx>(ufw.backend.get_rules_count(False)+ufw.backend.get_rules_count(True)):  \
                error("ERROR: Invalid index", ERROR_INVALID_INDEX)
-        if 2==len(parts):
-            removeDescription(parts[1])
-        else:
-            rule=ufw.backend.get_rule_by_number(index)
-            if rule:
-                details=ruleDetails(rule)
-                hashStr=detailsHash(details)
-                removeDescription(hashStr)
+#         if 2==len(parts):
+#             removeDescription(parts[1])
+#         else:
+#             rule=ufw.backend.get_rule_by_number(index)
+#             if rule:
+#                 details=ruleDetails(rule)
+#                 hashStr=detailsHash(details)
+#                 removeDescription(hashStr)
         ufw.delete_rule(idx, True)
     #except ufw.common.UFWError as e:
         #error("ERROR: UFW error", e.value)
@@ -461,7 +464,7 @@ def reset(ufw):
         ufw.set_enabled(True)
 
 def clearRules(ufw):
-    removeDescriptions()
+#     removeDescriptions()
     count=ufw.backend.get_rules_count(False)+ufw.backend.get_rules_count(True)
     for num in range(0, count):
         try:
@@ -503,17 +506,20 @@ def error(str, rv):
 
 def main():
     try:
+#         opts, args = getopt.getopt(sys.argv[1:], "hse:df:la:u:U:r:m:tiI:x",
+#                                    ["help", "status", "setEnabled=", "defaults", \
"setDefaults=", "list", "add=", +#                                     "update=", \
                "updateDescr=", "remove=", "move=", "reset", "modules", \
                "setModules=", "clearRules"])
         opts, args = getopt.getopt(sys.argv[1:], "hse:df:la:u:U:r:m:tiI:x",
                                    ["help", "status", "setEnabled=", "defaults", \
                "setDefaults=", "list", "add=",
-                                    "update=", "updateDescr=", "remove=", "move=", \
                "reset", "modules", "setModules=", "clearRules"])
-    except getopt.GetoptError, err:
+                                    "update=", "remove=", "move=", "reset", \
"modules", "setModules=", "clearRules"]) +    except getopt.GetoptError as err:
         # print help information and exit:
         print >> sys.stderr, str(err) # will print something like "option -a not \
recognized"  usage()
         sys.exit(1)
-    loadDescriptions()
+#     loadDescriptions()
     returnXml = False
-    xmlOut = StringIO.StringIO()
+    xmlOut = io.StringIO()
     xmlOut.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?><ufw>")
     for o, a in opts:
         if o in ("-h", "--help"):
@@ -536,8 +542,8 @@ def main():
             addRule(ufw, a)
         elif o in ("-u", "--update"):
             updateRule(ufw, a)
-        elif o in ("-U", "--updateDescr"):
-            updateRuleDescr(ufw, a)
+#         elif o in ("-U", "--updateDescr"):
+#             updateRuleDescr(ufw, a)
         elif o in ("-r", "--remove"):
             removeRule(ufw, a)
         elif o in ("-m", "--move"):
@@ -553,32 +559,32 @@ def main():
             clearRules(ufw)
         else:
             usage()
-    saveDescriptions()
+#     saveDescriptions()
     if returnXml:
         xmlOut.write("</ufw>")
-        print xmlOut.getvalue()
+        print (xmlOut.getvalue())
 
 def usage():
-    print "Python helper for UFW KCM"
-    print ""
-    print "(C) Craig Drummond, 2011"
-    print ""
-    print "Usage:"
-    print "    "+sys.argv[0]+" --status"
-    print "    "+sys.argv[0]+" --setEnabled <true/false>"
-    print "    "+sys.argv[0]+" --defaults"
-    print "    "+sys.argv[0]+" --setDefaults <xml>"
-    print "    "+sys.argv[0]+" --list"
-    print "    "+sys.argv[0]+" --add <xml>"
-    print "    "+sys.argv[0]+" --update <xml>"
-    print "    "+sys.argv[0]+" --updateDescr <xml>"
-    print "    "+sys.argv[0]+" --remove <index>"
-    print "    "+sys.argv[0]+" --remove <index:hash>"
-    print "    "+sys.argv[0]+" --move <from:to>"
-    print "    "+sys.argv[0]+" --reset"
-    print "    "+sys.argv[0]+" --modules"
-    print "    "+sys.argv[0]+" --setModules <xml>"
-    print "    "+sys.argv[0]+" --clearRules"
+    print ("Python helper for UFW KCM")
+    print ("")
+    print ("(C) Craig Drummond, 2011")
+    print ("")
+    print ("Usage:")
+    print ("    "+sys.argv[0]+" --status")
+    print ("    "+sys.argv[0]+" --setEnabled <true/false>")
+    print ("    "+sys.argv[0]+" --defaults")
+    print ("    "+sys.argv[0]+" --setDefaults <xml>")
+    print ("    "+sys.argv[0]+" --list")
+    print ("    "+sys.argv[0]+" --add <xml>")
+    print ("    "+sys.argv[0]+" --update <xml>")
+#     print ("    "+sys.argv[0]+" --updateDescr <xml>")
+    print ("    "+sys.argv[0]+" --remove <index>")
+    print ("    "+sys.argv[0]+" --remove <index:hash>")
+    print ("    "+sys.argv[0]+" --move <from:to>")
+    print ("    "+sys.argv[0]+" --reset")
+    print ("    "+sys.argv[0]+" --modules")
+    print ("    "+sys.argv[0]+" --setModules <xml>")
+    print ("    "+sys.argv[0]+" --clearRules")
 
 if __name__ == "__main__":
     main()
diff --git a/kcm/kcm.cpp b/kcm/kcm.cpp
index b269919..272e01b 100644
--- a/kcm/kcm.cpp
+++ b/kcm/kcm.cpp
@@ -266,17 +266,17 @@ void Kcm::editRule(Rule rule)
     }
 }
 
-void Kcm::editRuleDescr(const Rule &rule)
-{
-    QVariantMap args;
-    args["cmd"]="editRuleDescr";
-    args["xml"]=rule.toXml();
-    modifyAction.setArguments(args);
-    statusLabel->setText(i18n("Updating rule..."));
-    emit status(statusLabel->fullText());
-    blocker->setActive(true);
-    modifyAction.execute();
-}
+// void Kcm::editRuleDescr(const Rule &rule)
+// {
+//     QVariantMap args;
+//     args["cmd"]="editRuleDescr";
+//     args["xml"]=rule.toXml();
+//     modifyAction.setArguments(args);
+//     statusLabel->setText(i18n("Updating rule..."));
+//     emit status(statusLabel->fullText());
+//     blocker->setActive(true);
+//     modifyAction.execute();
+// }
 
 void Kcm::defaults()
 {
@@ -377,9 +377,9 @@ void Kcm::removeRule()
     {
         QVariantMap args;
         args["cmd"]="removeRule";
-        args["index"]=QString().setNum((unsigned int)item->data(0, \
Qt::UserRole).toUInt())+ +        args["index"]=QString().setNum((unsigned \
int)item->data(0, Qt::UserRole).toUInt())/*+  QChar(':')+
-                      currentRules.at((unsigned int)item->data(0, \
Qt::UserRole).toUInt()-1).getHash(); +                      currentRules.at((unsigned \
int)item->data(0, Qt::UserRole).toUInt()-1).getHash()*/;  \
modifyAction.setArguments(args);  statusLabel->setText(i18n("Removing rule from \
firewall..."));  blocker->setActive(true);
diff --git a/kcm/kcm.h b/kcm/kcm.h
index 958f19c..0f860c1 100644
--- a/kcm/kcm.h
+++ b/kcm/kcm.h
@@ -59,7 +59,7 @@ class Kcm : public KCModule, public Ui::Ufw
     bool          addRules(const QList<Rule> &rules);
     void          createRule(const Rule &rule);
     void          editRule(Rule rule);
-    void          editRuleDescr(const Rule &rule);
+//     void          editRuleDescr(const Rule &rule);
     bool          ipV6Enabled() { return ipv6Enabled->isChecked(); }
     bool          isActive()    { return blocker->isActive(); }
 
diff --git a/kcm/rule.cpp b/kcm/rule.cpp
index 9122f94..4f4ec14 100644
--- a/kcm/rule.cpp
+++ b/kcm/rule.cpp
@@ -183,7 +183,7 @@ QString Rule::protocolSuffix(Types::Protocol prot, const QString \
&sep)  return Types::PROTO_BOTH==prot ? "" : (sep+Types::toString(prot));
 }
 
-QString Rule::modify(const QString &address, const QString &port, const QString \
&application, const QString iface,  +QString Rule::modify(const QString &address, \
                const QString &port, const QString &application, const QString iface,
                      const Types::Protocol &protocol, bool matchPortNoProto)
 {
     if((port==ANY_PORT || port.isEmpty()) && (address.isEmpty() || ANY_ADDR==address \
|| ANY_ADDR_V6==address)) @@ -265,8 +265,8 @@ Rule::Rule(QDomElement &elem)
         destPort=QString();
     if(ANY_PORT==sourcePort)
         sourcePort=QString();
-    description=elem.attribute("descr");
-    hash=elem.attribute("hash");
+//     description=elem.attribute("descr");
+//     hash=elem.attribute("hash");
 }
 
 QString Rule::fromStr() const
@@ -323,10 +323,10 @@ QString Rule::toXml() const
     if(!interfaceOut.isEmpty())
         elem.setAttribute("interface_out", interfaceOut);
     elem.setAttribute("logtype", Types::toString(logtype));
-    if(!description.isEmpty())
-        elem.setAttribute("descr", description);
-    if(!hash.isEmpty())
-        elem.setAttribute("hash", hash);
+//     if(!description.isEmpty())
+//         elem.setAttribute("descr", description);
+//     if(!hash.isEmpty())
+//         elem.setAttribute("hash", hash);
     elem.setAttribute("v6", v6 ? "True" : "False");
     doc.appendChild(elem);
     return doc.toString();
diff --git a/kcm/rule.h b/kcm/rule.h
index 0436ffc..0daf563 100644
--- a/kcm/rule.h
+++ b/kcm/rule.h
@@ -44,8 +44,8 @@ class Rule
     Rule();
     Rule(QDomElement &elem);
     Rule(Types::Policy pol, bool in, Types::Logging log, Types::Protocol prot,
-         const QString &descr=QString(), const QString &hsh=QString(), 
-         const QString &srcHost=QString(), const QString &srcPort=QString(), 
+//          const QString &descr=QString(), const QString &hsh=QString(),
+         const QString &srcHost=QString(), const QString &srcPort=QString(),
          const QString &destHost=QString(), const QString &destPort=QString(),
          const QString &ifaceIn=QString(), const QString &ifaceOut=QString(),
          const QString &srcApp=QString(), const QString &destApp=QString(),
@@ -53,7 +53,7 @@ class Rule
         : position(i), action(pol), incoming(in), v6(false), protocol(prot), \
logtype(log),  destApplication(destApp), sourceApplication(srcApp),
           destAddress(destHost), sourceAddress(srcHost), destPort(destPort), \
                sourcePort(srcPort),
-          interfaceIn(ifaceIn), interfaceOut(ifaceOut), description(descr), \
hash(hsh) +          interfaceIn(ifaceIn), interfaceOut(ifaceOut) // , \
description(descr), hash(hsh)  { }
 
 
@@ -78,8 +78,8 @@ class Rule
     const QString & getInterfaceOut() const      { return interfaceOut; }
     Types::Protocol getProtocol() const          { return protocol; }
     Types::Logging  getLogging() const           { return logtype; }
-    const QString & getDescription() const       { return description; }
-    const QString & getHash() const              { return hash; }
+//     const QString & getDescription() const       { return description; }
+//     const QString & getHash() const              { return hash; }
 
     void setPosition(unsigned int v)            { position=v; }
     void setAction(Types::Policy v)             { action=v; }
@@ -95,20 +95,20 @@ class Rule
     void setInterfaceOut(const QString &v)      { interfaceOut=v; }
     void setProtocol(Types::Protocol v)         { protocol=v; }
     void setLogging(Types::Logging v)           { logtype=v; }
-    void setDescription(const QString &v)       { description=v; }
-    void setHash(const QString &v)              { hash=v; }
+//     void setDescription(const QString &v)       { description=v; }
+//     void setHash(const QString &v)              { hash=v; }
 
     // 'different' is used in the EditRule dialog to know whether the rule has \
actually changed...  bool different(const Rule &o) const
     {
-        return logtype!=o.logtype || description!=o.description || !(*this==o);
-    }
-    
-    bool onlyDescrChanged(const Rule &o) const
-    {
-        return (*this==o) && logtype==o.logtype && description!=o.description;
+        return logtype!=o.logtype /*|| description!=o.description*/ || !(*this==o);
     }
 
+//     bool onlyDescrChanged(const Rule &o) const
+//     {
+//         return (*this==o) && logtype==o.logtype && description!=o.description;
+//     }
+
     bool operator==(const Rule &o) const
     {
         return action==o.action &&
@@ -141,9 +141,9 @@ class Rule
                     destPort,
                     sourcePort,
                     interfaceIn,
-                    interfaceOut,
-                    description,
-                    hash;
+                    interfaceOut;
+//                     description,
+//                     hash;
 };
 
 }
diff --git a/kcm/ruledialog.cpp b/kcm/ruledialog.cpp
index 5dcbb41..9e5fd86 100644
--- a/kcm/ruledialog.cpp
+++ b/kcm/ruledialog.cpp
@@ -97,7 +97,7 @@ static void addProtocols(QComboBox *combo)
 static void addPredefinedPorts(QComboBox *combo, QList<PredefinedPort> &sortedPp, \
QMap<int, int> &map, bool splitMulti)  {
     map.clear();
-    QList<PredefinedPort>::ConstIterator it(sortedPp.constBegin()), 
+    QList<PredefinedPort>::ConstIterator it(sortedPp.constBegin()),
                                          end(sortedPp.constEnd());
 
     for(int index=combo->count(); it!=end; ++it)
@@ -106,13 +106,13 @@ static void addPredefinedPorts(QComboBox *combo, \
QList<PredefinedPort> &sortedPp  {
             QString ports=Types::toString((*it).val, false);
             bool    isMulti=ports.contains(" ");
-            
+
             if(isMulti && splitMulti)
             {
                 QStringList                split(ports.split(" "));
                 QStringList::ConstIterator sIt(split.constBegin()),
                                            sEnd(split.constEnd());
-                                           
+
                 for(int part=1; sIt!=sEnd; ++sIt, ++part)
                 {
                     combo->insertItem(index, (*it).str+QLatin1String(" \
(")+(*sIt)+QChar(')')); @@ -182,7 +182,7 @@ static QString getProfilesPorts(const \
                QString &text)
     return -1==start || -1==end ? text : text.mid(start+1, (end-(start+1)));
 }
 
-static void setRulePort(const QString &port, Types::Protocol prot, QRadioButton \
*portRadio, QRadioButton *profileRadio,  +static void setRulePort(const QString \
&port, Types::Protocol prot, QRadioButton *portRadio, QRadioButton *profileRadio,  \
QRadioButton *anyRadio, QComboBox *profileCombo)  {
     if(anyRadio && port.isEmpty())
@@ -192,7 +192,7 @@ static void setRulePort(const QString &port, Types::Protocol \
prot, QRadioButton  
     if(port.isEmpty())
         return;
-    
+
     QString portAndProt=port+Rule::protocolSuffix(prot);
     int     index=0,
             numItems=profileCombo->count();
@@ -413,7 +413,7 @@ static void setProfileIndex(QComboBox *combo, const QString &str)
         }
         else if(combo->itemText(index).isEmpty())
             haveSep=true;
-        
+
     if(!haveSep)
         combo->insertSeparator(index++);
     combo->insertItem(index, str);
@@ -478,7 +478,7 @@ RuleDialog::RuleDialog(Kcm *parent, bool isEditDlg)
     }
 
     QList<PredefinedPort> sortedPorts;
-    
+
     for(int i=0; i<Types::PP_COUNT; ++i)
         sortedPorts.append(PredefinedPort((Types::PredefinedPort)i));
     qSort(sortedPorts);
@@ -486,7 +486,7 @@ RuleDialog::RuleDialog(Kcm *parent, bool isEditDlg)
     addPredefinedPorts(simpleProfile, sortedPorts, simpleIndexToPredefinedPort, \
                isEdit);
     addPredefinedPorts(advancedDestProfile, sortedPorts, \
                advancedIndexToPredefinedPort, true);
     addPredefinedPorts(advancedSrcProfile, sortedPorts, \
                advancedIndexToPredefinedPort, true);
-    
+
     simpleProtocol->setCurrentIndex(Types::PROTO_BOTH);
     advancedProtocol->setCurrentIndex(Types::PROTO_BOTH);
 
@@ -535,13 +535,13 @@ RuleDialog::RuleDialog(Kcm *parent, bool isEditDlg)
                  *advancedSrcPortGroup=new QButtonGroup(this),
                  *advancedDestHostGroup=new QButtonGroup(this),
                  *advancedDestPortGroup=new QButtonGroup(this);
-                 
+
     advancedSrcHostGroup->addButton(advancedSrcHostRadio);
     advancedSrcHostGroup->addButton(advancedSrcAnyHostRadio);
     advancedSrcPortGroup->addButton(advancedSrcPortRadio);
     advancedSrcPortGroup->addButton(advancedSrcProfileRadio);
     advancedSrcPortGroup->addButton(advancedSrcAnyPortRadio);
-    
+
     advancedDestHostGroup->addButton(advancedDestHostRadio);
     advancedDestHostGroup->addButton(advancedDestAnyHostRadio);
     advancedDestPortGroup->addButton(advancedDestPortRadio);
@@ -557,9 +557,9 @@ RuleDialog::RuleDialog(Kcm *parent, bool isEditDlg)
     connect(simpleLogging, SIGNAL(currentIndexChanged(int)), advancedLogging, \
                SLOT(setCurrentIndex(int)));
     connect(advancedLogging, SIGNAL(currentIndexChanged(int)), simpleLogging, \
SLOT(setCurrentIndex(int)));  
-    connect(simpleDescription, SIGNAL(textEdited(const QString &)), \
                advancedDescription, SLOT(setText(const QString &)));
-    connect(advancedDescription, SIGNAL(textEdited(const QString &)), \
                simpleDescription, SLOT(setText(const QString &)));
-    
+//     connect(simpleDescription, SIGNAL(textEdited(const QString &)), \
advancedDescription, SLOT(setText(const QString &))); +//     \
connect(advancedDescription, SIGNAL(textEdited(const QString &)), simpleDescription, \
SLOT(setText(const QString &))); +
     connect(simpleProfileRadio, SIGNAL(toggled(bool)), \
                SLOT(controlSimpleProtocol()));
     connect(advancedSrcAnyPortRadio, SIGNAL(toggled(bool)), \
                SLOT(controlAdvancedProtocol()));
     connect(advancedDestAnyPortRadio, SIGNAL(toggled(bool)), \
SLOT(controlAdvancedProtocol())); @@ -591,7 +591,7 @@ RuleDialog::RuleDialog(Kcm \
*parent, bool isEditDlg)  simplePolicy->setMaximumWidth(width);
     advancedPolicy->setMinimumWidth(width);
     advancedPolicy->setMaximumWidth(width);
-    
+
     simpleProfile->adjustSize();
     simplePort->setMinimumWidth(simpleProfile->size().width());
 }
@@ -606,9 +606,9 @@ RuleDialog::~RuleDialog()
 
 void RuleDialog::reset()
 {
-    simpleDescription->setText(QString());
-    advancedDescription->setText(QString());
-    simpleDescription->setText(QString());
+//     simpleDescription->setText(QString());
+//     advancedDescription->setText(QString());
+//     simpleDescription->setText(QString());
     simplePolicy->setCurrentIndex(Types::POLICY_DENY);
     simpleDirection->setCurrentIndex(DIR_IN);
     simplePort->setText(QString());
@@ -630,7 +630,7 @@ void RuleDialog::reset()
     advancedDestAnyHostRadio->setChecked(true);
     controlSimpleProtocol();
     controlAdvancedProtocol();
-    
+
     if(RT_SIMPLE==ruleType->currentIndex())
         simplePolicy->setFocus();
     else
@@ -640,9 +640,9 @@ void RuleDialog::reset()
 void RuleDialog::setRule(const Rule &rule)
 {
     editingRule=rule;
-    simpleDescription->setText(rule.getDescription());
-    advancedDescription->setText(rule.getDescription());
-    simpleDescription->setText(rule.getDescription());
+//     simpleDescription->setText(rule.getDescription());
+//     advancedDescription->setText(rule.getDescription());
+//     simpleDescription->setText(rule.getDescription());
     simplePolicy->setCurrentIndex(rule.getAction());
     simpleDirection->setCurrentIndex(rule.getIncoming() ? DIR_IN : DIR_OUT);
     simplePort->setText(rule.getDestPort());
@@ -657,7 +657,7 @@ void RuleDialog::setRule(const Rule &rule)
     advancedDestPort->setText(rule.getDestPort());
     advancedProtocol->setCurrentIndex(rule.getProtocol());
     advancedLogging->setCurrentIndex(rule.getLogging());
-    
+
     QString iface(rule.getIncoming() ? rule.getInterfaceIn() : \
                rule.getInterfaceOut());
     advancedInterface->setEditText(iface.isEmpty() ? advancedInterface->itemText(0) \
: iface);  
@@ -690,7 +690,7 @@ void RuleDialog::setRule(const Rule &rule)
                               !rule.getSourceApplication().isEmpty() ||
                               !rule.getSourcePort().isEmpty() || \
                !rule.getInterfaceIn().isEmpty() ||
                               !rule.getInterfaceOut().isEmpty() ? RT_ADVANCED : \
                RT_SIMPLE);
-    
+
     simpleProfileRadio->setVisible(simpleProfile->count());
     simpleProfile->setVisible(simpleProfile->count());
     simplePortRadio->setVisible(simpleProfile->count());
@@ -700,7 +700,7 @@ void RuleDialog::setRule(const Rule &rule)
     advancedDestProfileRadio->setVisible(advancedDestProfile->count());
     advancedDestProfile->setVisible(advancedDestProfile->count());
     advancedDestPortRadio->setVisible(advancedDestProfile->count());
-    
+
     advancedSrcAnyHostRadio->setChecked(rule.getSourceAddress().isEmpty());
     advancedDestAnyHostRadio->setChecked(rule.getDestAddress().isEmpty());
     advancedSrcHostRadio->setChecked(!rule.getSourceAddress().isEmpty());
@@ -708,9 +708,9 @@ void RuleDialog::setRule(const Rule &rule)
 
     controlAdvancedProtocol();
     controlSimpleProtocol();
-        
+
     setRuleType();
-    
+
     if(RT_SIMPLE==ruleType->currentIndex())
         simplePolicy->setFocus();
     else
@@ -743,7 +743,7 @@ void RuleDialog::update()
         // For some reason, the Validator seems to stop working occasionaly!!! So, \
just check the contents here, and  // remove invalid characters...
         QString iface(advancedInterface->currentText());
-        
+
         for(int i=0; i<iface.length(); ++i)
             if(!iface[i].isLetterOrNumber())
                 iface[i]=' ';
@@ -767,7 +767,7 @@ void RuleDialog::update()
                     rules.append(Rule((Types::Policy)simplePolicy->currentIndex(),
                                       DIR_IN==simpleDirection->currentIndex(),
                                       (Types::Logging)simpleLogging->currentIndex(),
-                                      protocol, simpleDescription->text(), \
editingRule.getHash(), +                                      protocol, // \
                simpleDescription->text(), editingRule.getHash(),
                                       QString(), QString(), QString(), port));
                 }
                 else
@@ -795,7 +795,7 @@ void RuleDialog::update()
                         \
                rules.append(Rule((Types::Policy)simplePolicy->currentIndex(),
                                         DIR_IN==simpleDirection->currentIndex(),
                                         \
                (Types::Logging)simpleLogging->currentIndex(),
-                                        protocol, simpleDescription->text(), \
editingRule.getHash(), +                                        protocol, // \
                simpleDescription->text(), editingRule.getHash(),
                                         QString(), QString(), QString(), port));
                     }
                 }
@@ -816,16 +816,16 @@ void RuleDialog::update()
                                     DIR_IN==simpleDirection->currentIndex(),
                                     (Types::Logging)simpleLogging->currentIndex(),
                                     (Types::Protocol)simpleProtocol->currentIndex(),
-                                    simpleDescription->text(), \
editingRule.getHash(), +                                    // \
                simpleDescription->text(), editingRule.getHash(),
                                     QString(), QString(), QString(), port,
                                     QString(), QString(), QString(), app));
             }
             break;
         case RT_ADVANCED:
         {
-            bool    srcIsPreDefined=advancedSrcProfileRadio->isChecked() && 
+            bool    srcIsPreDefined=advancedSrcProfileRadio->isChecked() &&
                                         \
                advancedIndexToPredefinedPort.contains(advancedSrcProfile->currentIndex()),
                
-                    destIsPreDefined=advancedDestProfileRadio->isChecked() && 
+                    destIsPreDefined=advancedDestProfileRadio->isChecked() &&
                                         \
                advancedIndexToPredefinedPort.contains(advancedDestProfile->currentIndex());
                
             QString srcApp=!srcIsPreDefined && advancedSrcProfileRadio->isChecked() \
                ? getProfileName(advancedSrcProfile->currentText()) : QString(),
                     destApp=!destIsPreDefined && \
advancedDestProfileRadio->isChecked() ? \
getProfileName(advancedDestProfile->currentText()) : QString(), @@ -870,12 +870,12 @@ \
                void RuleDialog::update()
                                   DIR_IN==advancedDirection->currentIndex(),
                                   (Types::Logging)advancedLogging->currentIndex(),
                                   prot,
-                                  advancedDescription->text(), \
editingRule.getHash(), +                                  // \
advancedDescription->text(), editingRule.getHash(),  srcHost, srcPort, destHost, \
                destPort,
-                                  DIR_IN==advancedDirection->currentIndex() && 
+                                  DIR_IN==advancedDirection->currentIndex() &&
                                   \
                advancedInterface->currentText()!=advancedInterface->itemText(0)
                                         ? advancedInterface->currentText() : \
                QString(),
-                                  DIR_IN!=advancedDirection->currentIndex() && 
+                                  DIR_IN!=advancedDirection->currentIndex() &&
                                   \
                advancedInterface->currentText()!=advancedInterface->itemText(0)
                                         ? advancedInterface->currentText() : \
QString(),  srcApp, destApp));
@@ -886,9 +886,9 @@ void RuleDialog::update()
     {
         if(isEdit)
         {
-            if(rules.first().onlyDescrChanged(editingRule))
+            /*if(rules.first().onlyDescrChanged(editingRule))
                 kcm->editRuleDescr(rules.first());
-            else if(rules.first().different(editingRule))
+            else*/ if(rules.first().different(editingRule))
                 kcm->editRule(rules.first());
         }
         else if(!kcm->addRules(rules))
@@ -920,7 +920,7 @@ void RuleDialog::showError(const QString &err)
 void RuleDialog::controlSimpleProtocol()
 {
     bool fixedProto=simpleProfileRadio->isChecked();
-    
+
     simpleProtocol->setEnabled(!fixedProto);
     if(fixedProto)
         simpleProtocol->setCurrentIndex(Types::PROTO_BOTH);
@@ -930,7 +930,7 @@ void RuleDialog::controlAdvancedProtocol()
 {
     bool selectableProto=(advancedSrcPortRadio->isChecked() || \
                advancedDestPortRadio->isChecked()) &&
                          !(advancedSrcProfileRadio->isChecked() || \
                advancedDestProfileRadio->isChecked());
-    
+
     advancedProtocol->setEnabled(selectableProto);
     if(!selectableProto)
         advancedProtocol->setCurrentIndex(Types::PROTO_BOTH);
diff --git a/kcm/ruleslist.cpp b/kcm/ruleslist.cpp
index bca3823..f63a8c9 100644
--- a/kcm/ruleslist.cpp
+++ b/kcm/ruleslist.cpp
@@ -58,8 +58,8 @@ QTreeWidgetItem * RulesList::insert(const Rule &rule)
                                                    << rule.fromStr()+pad
                                                    << rule.toStr()+pad
                                                    << rule.ipV6Str()+pad
-                                                   << rule.loggingStr()+pad
-                                                   << rule.getDescription()+pad);
+                                                   << rule.loggingStr()+pad/*
+                                                   << rule.getDescription()+pad*/);
 }
 
 void RulesList::resizeToContents()
diff --git a/kcm/ruleslist.h b/kcm/ruleslist.h
index 6c2d8f7..863c99e 100644
--- a/kcm/ruleslist.h
+++ b/kcm/ruleslist.h
@@ -44,10 +44,10 @@ class RulesList : public QTreeWidget
         COL_FROM,
         COL_TO,
         COL_IPV6,
-        COL_LOGGING,
-        COL_DESCR
+        COL_LOGGING
+//         COL_DESCR
     };
-    
+
     RulesList(QWidget *parent);
     virtual ~RulesList();
 
@@ -56,15 +56,15 @@ class RulesList : public QTreeWidget
     void              dropEvent(QDropEvent *event);
 
     public Q_SLOTS:
-    
+
     void restoreState();
 
     Q_SIGNALS:
 
     void dropped(const QTreeWidgetItem *item);
-    
+
     private:
-    
+
     bool headerSizesSet;
 };
 
diff --git a/kcm/rulewidget.ui b/kcm/rulewidget.ui
index bb2b79d..2805600 100644
--- a/kcm/rulewidget.ui
+++ b/kcm/rulewidget.ui
@@ -52,23 +52,6 @@
         <widget class="QComboBox" name="simpleLogging"/>
        </item>
        <item row="7" column="0">
-        <widget class="QLabel" name="simpleDescriptionLabel">
-         <property name="text">
-          <string>Description:</string>
-         </property>
-        </widget>
-       </item>
-       <item row="7" column="1">
-        <widget class="KLineEdit" name="simpleDescription">
-         <property name="clickMessage">
-          <string>Description of rule</string>
-         </property>
-         <property name="showClearButton" stdset="0">
-          <bool>true</bool>
-         </property>
-        </widget>
-       </item>
-       <item row="8" column="0">
         <spacer name="verticalSpacer_2">
          <property name="orientation">
           <enum>Qt::Vertical</enum>
@@ -542,23 +525,6 @@
        <item row="5" column="1">
         <widget class="QComboBox" name="advancedLogging"/>
        </item>
-       <item row="6" column="0">
-        <widget class="QLabel" name="advancedDescriptionLabel">
-         <property name="text">
-          <string>Description:</string>
-         </property>
-        </widget>
-       </item>
-       <item row="6" column="1">
-        <widget class="KLineEdit" name="advancedDescription">
-         <property name="clickMessage">
-          <string>Description of rule</string>
-         </property>
-         <property name="showClearButton" stdset="0">
-          <bool>true</bool>
-         </property>
-        </widget>
-       </item>
       </layout>
      </widget>
     </widget>
@@ -627,7 +593,6 @@
   <tabstop>simpleProfile</tabstop>
   <tabstop>simpleProtocol</tabstop>
   <tabstop>simpleLogging</tabstop>
-  <tabstop>simpleDescription</tabstop>
   <tabstop>advancedPolicy</tabstop>
   <tabstop>advancedDirection</tabstop>
   <tabstop>advancedSrcAnyHostRadio</tabstop>
@@ -649,7 +614,6 @@
   <tabstop>advancedProtocol</tabstop>
   <tabstop>advancedInterface</tabstop>
   <tabstop>advancedLogging</tabstop>
-  <tabstop>advancedDescription</tabstop>
  </tabstops>
  <resources/>
  <connections>
diff --git a/kcm/ufw.ui b/kcm/ufw.ui
index a3d2e97..d259164 100644
--- a/kcm/ufw.ui
+++ b/kcm/ufw.ui
@@ -139,11 +139,6 @@
            <string>Logging</string>
           </property>
          </column>
-         <column>
-          <property name="text">
-           <string>Description</string>
-          </property>
-         </column>
         </widget>
        </item>
        <item row="0" column="1">


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic