[Konversation-devel] [Bug 107234] Add an unignore command, patch is provided :)

Eike Hein hein at kde.org
Thu Jul 1 16:16:26 CEST 2010


https://bugs.kde.org/show_bug.cgi?id=107234





--- Comment #13 from Eike Hein <hein kde org>  2010-07-01 16:15:46 ---
commit edd6f1df9adf4adc10c2eaa6eff35da393d2bd31
Author: Eike Hein <hein at kde.org>
Date:   Sat Jan 7 13:02:48 2006 +0000

    * Implement '/unignore <user 1> <user 2> ... <user n>'
      BUG: 107234
    * Keep addIgnore from adding the same ignore multiple times (as
      it would make /unignore potentially unreliable).
    * Fix small inputfilter error; update changelog.

    svn path=/trunk/extragear/network/konversation/; revision=495204

diff --git a/ChangeLog b/ChangeLog
index 96ed032..9e4b902 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -55,6 +55,7 @@ Changes from 0.18 to 0.19
 - Implemented '/topic <channel>' for retrieving the topic of arbitrary
channels, provided the IRC server allows us to
 - Show local file name in DCC GET status tab and DCC messages
 - Properly select relevant entry in Server List dialog after adding or editing
a network
+- Implement '/unignore <user 1> <user 2> ... <user n>'

 Changes from 0.17 to 0.18
 - All nicks were blue when colored nicks are disabled with some setups
diff --git a/src/config/preferences.cpp b/src/config/preferences.cpp
index df8f81c..8b7c0aa 100644
--- a/src/config/preferences.cpp
+++ b/src/config/preferences.cpp
@@ -257,9 +257,27 @@ void Preferences::setIgnoreList(QPtrList<Ignore> newList)

 void Preferences::addIgnore(const QString &newIgnore)
 {
-    QStringList ignore=QStringList::split(',',newIgnore);
+    QStringList ignore = QStringList::split(',',newIgnore);
+    removeIgnore(ignore[0]);
     self()->mIgnoreList.append(new Ignore(ignore[0],ignore[1].toInt()));
 }
+
+bool Preferences::removeIgnore(const QString &oldIgnore)
+{
+    QPtrListIterator<Ignore> ignoreList( self()->mIgnoreList );
+    while (ignoreList.current())
+    {
+        if (ignoreList.current()->getName()==oldIgnore)
+        {
+            self()->mIgnoreList.remove(ignoreList.current());
+            return true;
+        }
+        ++ignoreList;
+    }
+
+    return false;
+}
+
 void Preferences::setNotifyList(const QMap<QString, QStringList> &newList)
 { self()->mNotifyList=newList; }

diff --git a/src/config/preferences.h b/src/config/preferences.h
index 4f8b4a7..4497990 100644
--- a/src/config/preferences.h
+++ b/src/config/preferences.h
@@ -85,7 +85,8 @@ class Preferences : public QObject, public PreferencesBase
         static void addHighlight(const QString& newHighlight,bool regExp,
const QColor &color,const QString& sound,const QString& autoText);

     /* All of the below work on the first (default) identity in your identity
list*/
-    static void addIgnore(const QString &newIgnore);
+        static void addIgnore(const QString &newIgnore);
+        static bool removeIgnore(const QString &oldIgnore);
         static void clearIgnoreList();
         static const QPtrList<Ignore> ignoreList();
         static void setIgnoreList(QPtrList<Ignore> newList);
diff --git a/src/inputfilter.cpp b/src/inputfilter.cpp
index d852f3d..2d2c786 100644
--- a/src/inputfilter.cpp
+++ b/src/inputfilter.cpp
@@ -945,7 +945,7 @@ void InputFilter::parseServerCommand(const QString &prefix,
const QString &comma
             }
             case RPL_YOUREOPER:
             {
-                server->appendMessageToFrontmost(i18n("Notice"),i18n("You are
now an IRC operator on this server.").arg(parameterList[1]));
+                server->appendMessageToFrontmost(i18n("Notice"),i18n("You are
now an IRC operator on this server."));

                 break;
             }
diff --git a/src/outputfilter.cpp b/src/outputfilter.cpp
index 09cfff9..7f74c43 100644
--- a/src/outputfilter.cpp
+++ b/src/outputfilter.cpp
@@ -157,62 +157,55 @@ namespace Konversation
             if (command !="topic")
                 parameter = parameter.stripWhiteSpace();

-            if     (command == "join")    result = parseJoin(parameter);
-            else if(command == "part")    result = parsePart(parameter);
-            else if(command == "leave")   result = parsePart(parameter);
-            else if(command == "quit")    result = parseQuit(parameter);
-            else if(command == "notice")  result = parseNotice(parameter);
-            else if(command == "j")       result = parseJoin(parameter);
-            else if(command == "msg")     result = parseMsg(myNick,parameter,
false);
-            else if(command == "m")       result = parseMsg(myNick,parameter,
false);
-            else if(command == "smsg")    result = parseSMsg(parameter);
-            else if(command == "query")   result = parseMsg(myNick,parameter,
true);
-            else if(command == "op")      result = parseOp(parameter);
-            else if(command == "deop")    result = parseDeop(parameter);
-            else if(command == "voice")   result = parseVoice(parameter);
-            else if(command == "unvoice") result = parseUnvoice(parameter);
-            else if(command == "ctcp")    result = parseCtcp(parameter);
-            else if(command == "ping")    result =
parseCtcp(parameter.section(' ', 0, 0) + " ping");
-            else if(command == "kick")    result = parseKick(parameter);
-            else if(command == "topic")   result = parseTopic(parameter);
-            else if(command == "away")    result = parseAway(parameter);
-            else if(command == "back")    result = parseAway(QString::null);
-            else if(command == "invite")  result = parseInvite(parameter);
-            else if(command == "exec")    result = parseExec(parameter);
-            else if(command == "notify")  result = parseNotify(parameter);
-            else if(command == "oper")    result =
parseOper(myNick,parameter);
-            else if(command == "ban")     result = parseBan(parameter);
-            else if(command == "unban")   result = parseUnban(parameter);
-            else if(command == "ignore")  result = parseIgnore(parameter);
-            else if(command == "quote")   result = parseQuote(parameter);
-            else if(command == "say")     result = parseSay(parameter);
-            else if(command == "list")    result = parseList(parameter);
-
-            else if(command == "names")   result = parseNames(parameter);
-            else if(command == "raw")     result = parseRaw(parameter);
-            else if(command == "dcc")     result = parseDcc(parameter);
-            else if(command == "konsole") parseKonsole();
-
-            else if(command == "aaway")   parseAaway(parameter);
-            else if(command == "aback")   parseAaway(QString::null);
-            else if(command == "ame")     result = parseAme(parameter);
-            else if(command == "amsg")    result = parseAmsg(parameter);
-
-            else if(command == "omsg")    result = parseOmsg(parameter);
-            else if(command == "onotice") result = parseOnotice(parameter);
-
+            if     (command == "join")     result = parseJoin(parameter);
+            else if(command == "part")     result = parsePart(parameter);
+            else if(command == "leave")    result = parsePart(parameter);
+            else if(command == "quit")     result = parseQuit(parameter);
+            else if(command == "notice")   result = parseNotice(parameter);
+            else if(command == "j")        result = parseJoin(parameter);
+            else if(command == "msg")      result = parseMsg(myNick,parameter,
false);
+            else if(command == "m")        result = parseMsg(myNick,parameter,
false);
+            else if(command == "smsg")     result = parseSMsg(parameter);
+            else if(command == "query")    result = parseMsg(myNick,parameter,
true);
+            else if(command == "op")       result = parseOp(parameter);
+            else if(command == "deop")     result = parseDeop(parameter);
+            else if(command == "voice")    result = parseVoice(parameter);
+            else if(command == "unvoice")  result = parseUnvoice(parameter);
+            else if(command == "ctcp")     result = parseCtcp(parameter);
+            else if(command == "ping")     result =
parseCtcp(parameter.section(' ', 0, 0) + " ping");
+            else if(command == "kick")     result = parseKick(parameter);
+            else if(command == "topic")    result = parseTopic(parameter);
+            else if(command == "away")     result = parseAway(parameter);
+            else if(command == "back")     result = parseAway(QString::null);
+            else if(command == "invite")   result = parseInvite(parameter);
+            else if(command == "exec")     result = parseExec(parameter);
+            else if(command == "notify")   result = parseNotify(parameter);
+            else if(command == "oper")     result =
parseOper(myNick,parameter);
+            else if(command == "ban")      result = parseBan(parameter);
+            else if(command == "unban")    result = parseUnban(parameter);
+            else if(command == "ignore")   result = parseIgnore(parameter);
+            else if(command == "unignore") result = parseUnignore(parameter);
+            else if(command == "quote")    result = parseQuote(parameter);
+            else if(command == "say")      result = parseSay(parameter);
+            else if(command == "list")     result = parseList(parameter);
+            else if(command == "names")    result = parseNames(parameter);
+            else if(command == "raw")      result = parseRaw(parameter);
+            else if(command == "dcc")      result = parseDcc(parameter);
+            else if(command == "konsole")  parseKonsole();
+            else if(command == "aaway")    parseAaway(parameter);
+            else if(command == "aback")    parseAaway(QString::null);
+            else if(command == "ame")      result = parseAme(parameter);
+            else if(command == "amsg")     result = parseAmsg(parameter);
+            else if(command == "omsg")     result = parseOmsg(parameter);
+            else if(command == "onotice")  result = parseOnotice(parameter);
             else if(command == "server")     parseServer(parameter);
             else if(command == "reconnect")  parseReconnect();
             else if(command == "disconnect") emit disconnectServer();
-
-            else if(command == "prefs")   result = parsePrefs(parameter);
-
-            else if(command == "charset") parseCharset(parameter);
-
-            else if(command == "setkey")  result = parseSetKey(parameter);
-            else if(command == "delkey")  result = parseDelKey(parameter);
-
-            else if(command == "dns")     result = parseDNS(parameter);
+            else if(command == "prefs")    result = parsePrefs(parameter);
+            else if(command == "charset")  parseCharset(parameter);
+            else if(command == "setkey")   result = parseSetKey(parameter);
+            else if(command == "delkey")   result = parseDelKey(parameter);
+            else if(command == "dns")      result = parseDNS(parameter);

             // Forward unknown commands to server
             else
@@ -1116,7 +1109,81 @@ namespace Konversation

         if(showUsage)
         {
-            result = usage(i18n("Usage: IGNORE [ -ALL ] user list"));
+            result = usage(i18n("Usage: %1IGNORE [ -ALL ] <user 1> <user 2>
... <user n>").arg(commandChar));
+        }
+
+        return result;
+    }
+
+    OutputFilterResult OutputFilter::parseUnignore(const QString& parameter)
+    {
+        OutputFilterResult result;
+
+        if(parameter.isEmpty())
+        {
+            result = usage(i18n("Usage: %1UNIGNORE <user 1> <user 2> ... <user
n>").arg(commandChar));
+        }
+        else
+        {
+            QString unignore = parameter.simplifyWhiteSpace();
+
+            QStringList unignoreList = QStringList::split(' ',unignore);
+
+            // Only one potential unignore
+            if (unignoreList.count()==1)
+            {
+                // Unignore succeeded, i.e. parameter was on the ignore list
+                if (Preferences::removeIgnore(unignore))
+                {
+                    result.output = i18n("Removed %1 from your ignore
list.").arg(unignore);
+                    result.typeString = i18n("Ignore");
+                    result.type = Program;
+                }
+                // Unignore failed
+                else
+                {
+                    result = error(i18n("No such ignore: %1").arg(unignore));
+                }
+            }
+            // Multiple potential unignores
+            else
+            {
+                QStringList succeeded;
+                QStringList failed;
+
+                // Iterate over potential unignores
+                for (QStringList::Iterator it = unignoreList.begin(); it !=
unignoreList.end(); ++it) 
+                {
+                    // Unignore succeeded: add to success list
+                    if (Preferences::removeIgnore((*it)))
+                    {
+                        succeeded.append((*it));
+                    }
+                    // Unignore failed: add to failure list
+                    else
+                    {
+                        failed.append((*it));
+                    }
+                }
+
+                // Print all successful unignores, in case there were any
+                if (succeeded.count()>=1)
+                {
+                   
m_server->appendMessageToFrontmost(i18n("Ignore"),i18n("Removed %1 from your
ignore list.").arg(succeeded.join(", ")));
+                }
+
+                // One failed unignore
+                if (failed.count()==1)
+                {
+                    m_server->appendMessageToFrontmost(i18n("Error"),i18n("No
such ignore: %1").arg(failed.join(", ")));
+                }
+
+                // Multiple failed unignores
+                if (failed.count()>1)
+                {
+                    m_server->appendMessageToFrontmost(i18n("Error"),i18n("No
such ignores: %1").arg(failed.join(", ")));
+                }
+            }
         }

         return result;
diff --git a/src/outputfilter.h b/src/outputfilter.h
index 55ded1e..d34bdca 100644
--- a/src/outputfilter.h
+++ b/src/outputfilter.h
@@ -122,6 +122,7 @@ namespace Konversation
             OutputFilterResult parseDcc(const QString& parameter);
             OutputFilterResult parseRaw(const QString& parameter);
             OutputFilterResult parseIgnore(const QString& parameter);
+            OutputFilterResult parseUnignore(const QString& parameter);
             OutputFilterResult parseQuote(const QString& parameter);
             OutputFilterResult parseSay(const QString& parameter);
             void parseKonsole();

-- 
Configure bugmail: https://bugs.kde.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.


More information about the Konversation-devel mailing list