Bug 107234

Summary: Add an unignore command, patch is provided :)
Product: [Applications] konversation Reporter: Alexis ROBERT <alexis>
Component: generalAssignee: Konversation Developers <konversation-devel>
Status: RESOLVED FIXED    
Severity: wishlist CC: asanchez
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: unspecified   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: Add the unignore command

Description Alexis ROBERT 2005-06-11 22:43:14 UTC
Version:           0.18 (using KDE KDE 3.4.1)
Installed from:    Unlisted Binary Package
Compiler:          gcc 4.0.1 
OS:                Linux

I've made a little patch to add the /unignore command and the unignore in contextual menu (I don't know if this last one works).

I hope this patch is clean, it's the first time I hack a QT/C++ software :)
Comment 1 Alexis ROBERT 2005-06-11 22:43:45 UTC
Created attachment 11406 [details]
Add the unignore command
Comment 2 Ismail Donmez 2005-06-11 22:47:56 UTC
Thanks for the patch, but ( there is always a but :) ) Unignore should only be shown for people who are on ignore. Hence you should add a function to check if the person is on ignore then change the context menu entry appropriately.
Comment 3 Ismail Donmez 2005-06-11 22:49:02 UTC
*** Bug 93460 has been marked as a duplicate of this bug. ***
Comment 4 Alexis ROBERT 2005-06-11 22:51:11 UTC
I'm working on that :)

Two seconds before you post it, a friend said me the same thing on IRC :)
Comment 5 Ismail Donmez 2005-06-12 06:03:59 UTC
On Saturday 11 June 2005 23:51, Alexis ROBERT wrote:
[bugs.kde.org quoted mail]

Great :)
Comment 6 Ismail Donmez 2005-06-19 15:06:59 UTC
Any news on this?
Comment 7 Alexis ROBERT 2005-06-19 21:55:13 UTC
I'm unable to finish this patch as you want, I'm not a C++ guru and I hate pointers :)
Comment 8 Ismail Donmez 2005-06-19 21:56:58 UTC
Ok I will have a look at it myself then.
Comment 9 Eike Hein 2006-01-07 14:02:59 UTC
SVN commit 495204 by hein:

* 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.


 M  +1 -0      ChangeLog  
 M  +19 -1     src/config/preferences.cpp  
 M  +2 -1      src/config/preferences.h  
 M  +1 -1      src/inputfilter.cpp  
 M  +121 -54   src/outputfilter.cpp  
 M  +1 -0      src/outputfilter.h  
Comment 10 Niek Beernink 2006-08-06 15:29:56 UTC
The context menu does not update yet when you ignore a user. Should this really have been resolved?
Comment 11 Eike Hein 2006-08-06 16:11:30 UTC
This bug is about an /unignore command, which I eventually implemented, as such it is resolved. The mistakingly closed BUG 93460 has been reopened to track your context menu issues.
Comment 12 Eike Hein 2006-08-06 18:38:17 UTC
(Addendum: BUG 93460 is now fixed in SVN.)
Comment 13 Eike Hein 2010-07-01 16:15:46 UTC
commit edd6f1df9adf4adc10c2eaa6eff35da393d2bd31
Author: Eike Hein <hein@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();