diff --git a/app/src/main/java/de/kuschku/util/irc/chanmodes/AbstractIrcModeProvider.java b/app/src/main/java/de/kuschku/util/irc/chanmodes/AbstractIrcModeProvider.java new file mode 100644 index 0000000000000000000000000000000000000000..ae23997cfa97f77fad0dbbf5cca6801c191a6beb --- /dev/null +++ b/app/src/main/java/de/kuschku/util/irc/chanmodes/AbstractIrcModeProvider.java @@ -0,0 +1,55 @@ +/* + * QuasselDroid - Quassel client for Android + * Copyright (C) 2016 Janne Koschinski + * Copyright (C) 2016 Ken Børge Viktil + * Copyright (C) 2016 Magnus Fjell + * Copyright (C) 2016 Martin Sandsmark <martin.sandsmark@kde.org> + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +package de.kuschku.util.irc.chanmodes; + +import java.util.Collection; +import java.util.HashSet; +import java.util.Set; + +public abstract class AbstractIrcModeProvider implements IrcModeProvider { + + @Override + public int matchQuality(Set<Character> modes) { + HashSet<Character> diff = new HashSet<>(); + for (char c : modes) { + if (!supportedModes().contains(c)) + diff.add(c); + } + for (char c : supportedModes()) { + if (!modes.contains(c)) + diff.add(c); + } + return (diff.size()); + } + + public Set<ChanMode> modesFromString(String chanModes) { + Set<ChanMode> result = new HashSet<>(); + for (char c : chanModes.toCharArray()) { + ChanMode mode = modeFromChar(c); + if (mode != null) + result.add(mode); + } + return result; + } + + protected abstract Collection<Character> supportedModes(); +} diff --git a/app/src/main/java/de/kuschku/util/irc/chanmodes/ChanMode.java b/app/src/main/java/de/kuschku/util/irc/chanmodes/ChanMode.java new file mode 100644 index 0000000000000000000000000000000000000000..46d60c2aba8ca05f9ae8879788add11e7d525c35 --- /dev/null +++ b/app/src/main/java/de/kuschku/util/irc/chanmodes/ChanMode.java @@ -0,0 +1,64 @@ +/* + * QuasselDroid - Quassel client for Android + * Copyright (C) 2016 Janne Koschinski + * Copyright (C) 2016 Ken Børge Viktil + * Copyright (C) 2016 Magnus Fjell + * Copyright (C) 2016 Martin Sandsmark <martin.sandsmark@kde.org> + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +package de.kuschku.util.irc.chanmodes; + +public enum ChanMode { + ALLOW_FORWARD, + ALLOW_INVITE, + ANTIFLOOD, + AUDITORIUM, + BLOCK_ACTION, + BLOCK_AUTOREJOIN, + BLOCK_CAPS, + BLOCK_CTCP, + BLOCK_COLOR, + BLOCK_EXTERNAL, + BLOCK_FORWARDING, + BLOCK_KICK, + BLOCK_KNOCK, + BLOCK_NICKCHANGE, + BLOCK_NOTICE, + BLOCK_REPEAT, + BLOCK_UNIDENTIFIED, + CENSOR, + DISABLE_INVITE, + HIDE_JOINS, + IS_SECURE, + JOIN_THROTTLE, + LIMIT, + MODERATED, + ONLY_HELPOPER, + ONLY_INVITE, + ONLY_OPER, + ONLY_ADMIN, + ONLY_SSL, + PARANOID, + PASSWORD, + PERMANENT, + QUIET_UNIDENTIFIED, + REDUCED_MODERATION, + REGISTERED, + RESTRICT_TOPIC, + STRIP_COLOR, + UNLISTED, + FORWARD +} diff --git a/app/src/main/java/de/kuschku/util/irc/chanmodes/IrcModeProvider.java b/app/src/main/java/de/kuschku/util/irc/chanmodes/IrcModeProvider.java new file mode 100644 index 0000000000000000000000000000000000000000..ef05df887a037fd81f686fdc3ac7545d7dbf377e --- /dev/null +++ b/app/src/main/java/de/kuschku/util/irc/chanmodes/IrcModeProvider.java @@ -0,0 +1,31 @@ +/* + * QuasselDroid - Quassel client for Android + * Copyright (C) 2016 Janne Koschinski + * Copyright (C) 2016 Ken Børge Viktil + * Copyright (C) 2016 Magnus Fjell + * Copyright (C) 2016 Martin Sandsmark <martin.sandsmark@kde.org> + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +package de.kuschku.util.irc.chanmodes; + +import java.util.Set; + +public interface IrcModeProvider { + ChanMode modeFromChar(char mode); + char charFromMode(ChanMode mode); + int matchQuality(Set<Character> modes); + Set<ChanMode> modesFromString(String chanModes); +} diff --git a/app/src/main/java/de/kuschku/util/irc/chanmodes/IrcModeProviderFactory.java b/app/src/main/java/de/kuschku/util/irc/chanmodes/IrcModeProviderFactory.java new file mode 100644 index 0000000000000000000000000000000000000000..a7b65c9c921a4dfe8e0eda28d44ab22c7d6de8e5 --- /dev/null +++ b/app/src/main/java/de/kuschku/util/irc/chanmodes/IrcModeProviderFactory.java @@ -0,0 +1,73 @@ +/* + * QuasselDroid - Quassel client for Android + * Copyright (C) 2016 Janne Koschinski + * Copyright (C) 2016 Ken Børge Viktil + * Copyright (C) 2016 Magnus Fjell + * Copyright (C) 2016 Martin Sandsmark <martin.sandsmark@kde.org> + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +package de.kuschku.util.irc.chanmodes; + +import de.kuschku.util.irc.chanmodes.impl.*; + +import java.util.Arrays; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +public class IrcModeProviderFactory { + private static List<IrcModeProvider> servers = Arrays.asList( + new CharybdisIrcModeProvider(), + new DalIrcModeProvider(), + new DancerIrcModeProvider(), + new FqIrcModeProvider(), + new HybridIrcModeProvider(), + new HyperionIrcModeProvider(), + new InspireIrcModeProvider(), + new NeoIrcModeProvider(), + new ShadowIrcModeProvider(), + new SolidIrcModeProvider(), + new UnrealIrcModeProvider() + ); + + private static Set<Character> toModeSet(String chanModes) { + String replaced = chanModes.replaceAll(",",""); + Set<Character> modeSet = new HashSet<>(); + for (char c : replaced.toCharArray()) { + modeSet.add(c); + } + return modeSet; + } + + public static IrcModeProvider identifyServer(String modeString) { + return identifyServer(toModeSet(modeString)); + } + + public static IrcModeProvider identifyServer(Set<Character> characters) { + IrcModeProvider bestMatch = null; + int bestMatchCount = Integer.MAX_VALUE; + + for (IrcModeProvider server : servers) { + int matchQuality = server.matchQuality(characters); + if (bestMatchCount > matchQuality) { + bestMatch = server; + bestMatchCount = matchQuality; + } + } + + return bestMatch; + } +} diff --git a/app/src/main/java/de/kuschku/util/irc/chanmodes/impl/BewareIrcModeProvider.java b/app/src/main/java/de/kuschku/util/irc/chanmodes/impl/BewareIrcModeProvider.java new file mode 100644 index 0000000000000000000000000000000000000000..08f297d2bae3f3d746cde1394d0183cf414938cb --- /dev/null +++ b/app/src/main/java/de/kuschku/util/irc/chanmodes/impl/BewareIrcModeProvider.java @@ -0,0 +1,78 @@ +/* + * QuasselDroid - Quassel client for Android + * Copyright (C) 2016 Janne Koschinski + * Copyright (C) 2016 Ken Børge Viktil + * Copyright (C) 2016 Magnus Fjell + * Copyright (C) 2016 Martin Sandsmark <martin.sandsmark@kde.org> + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +package de.kuschku.util.irc.chanmodes.impl; + +import de.kuschku.util.irc.chanmodes.AbstractIrcModeProvider; +import de.kuschku.util.irc.chanmodes.ChanMode; + +import java.util.Arrays; +import java.util.Collection; +import java.util.HashSet; +import java.util.Set; + +import static de.kuschku.util.irc.chanmodes.ChanMode.*; + +public class BewareIrcModeProvider extends AbstractIrcModeProvider { + + protected Set<Character> supportedModes = new HashSet<>(Arrays.asList( + 'C', 'c', 'i', 'k', 'l', 'm', 'n', 'p', 's', 't' + )); + + @Override + protected Collection<Character> supportedModes() { + return supportedModes; + } + + @Override + public ChanMode modeFromChar(char mode) { + switch (mode) { + case 'C': return BLOCK_CTCP; + case 'c': return BLOCK_COLOR; + case 'i': return ONLY_INVITE; + case 'k': return PASSWORD; + case 'l': return LIMIT; + case 'm': return MODERATED; + case 'n': return BLOCK_EXTERNAL; + case 'p': return PARANOID; + case 's': return UNLISTED; + case 't': return RESTRICT_TOPIC; + } + return null; + } + + @Override + public char charFromMode(ChanMode mode) { + switch (mode) { + case BLOCK_CTCP: return 'C'; + case BLOCK_COLOR: return 'c'; + case ONLY_INVITE: return 'i'; + case PASSWORD: return 'k'; + case LIMIT: return 'l'; + case MODERATED: return 'm'; + case BLOCK_EXTERNAL: return 'n'; + case PARANOID: return 'p'; + case UNLISTED: return 's'; + case RESTRICT_TOPIC: return 't'; + } + return ' '; + } +} diff --git a/app/src/main/java/de/kuschku/util/irc/chanmodes/impl/CharybdisIrcModeProvider.java b/app/src/main/java/de/kuschku/util/irc/chanmodes/impl/CharybdisIrcModeProvider.java new file mode 100644 index 0000000000000000000000000000000000000000..c0e23656c03e7cbb36e949cac5a367f532c2c9da --- /dev/null +++ b/app/src/main/java/de/kuschku/util/irc/chanmodes/impl/CharybdisIrcModeProvider.java @@ -0,0 +1,103 @@ +/* + * QuasselDroid - Quassel client for Android + * Copyright (C) 2016 Janne Koschinski + * Copyright (C) 2016 Ken Børge Viktil + * Copyright (C) 2016 Magnus Fjell + * Copyright (C) 2016 Martin Sandsmark <martin.sandsmark@kde.org> + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +package de.kuschku.util.irc.chanmodes.impl; + +import de.kuschku.util.irc.chanmodes.AbstractIrcModeProvider; +import de.kuschku.util.irc.chanmodes.ChanMode; + +import java.util.Arrays; +import java.util.Collection; +import java.util.HashSet; +import java.util.Set; + +import static de.kuschku.util.irc.chanmodes.ChanMode.*; + +public class CharybdisIrcModeProvider extends AbstractIrcModeProvider { + + protected Set<Character> supportedModes = new HashSet<>(Arrays.asList( + 'A', 'C', 'F', 'O', 'P', 'Q', 'S', 'T', 'c', 'f', 'g', 'i', 'j', 'k', 'l', 'm', 'n', 'p', 'r', 's', 't', 'z' + )); + + @Override + public ChanMode modeFromChar(char mode) { + switch (mode) { + case 'A': return ONLY_ADMIN; + case 'C': return BLOCK_CTCP; + case 'F': return ALLOW_FORWARD; + case 'O': return ONLY_OPER; + case 'P': return PERMANENT; + case 'Q': return BLOCK_FORWARDING; + case 'S': return ONLY_SSL; + case 'T': return BLOCK_NOTICE; + case 'c': return BLOCK_COLOR; + case 'f': return FORWARD; + case 'g': return ALLOW_INVITE; + case 'i': return ONLY_INVITE; + case 'j': return JOIN_THROTTLE; + case 'k': return PASSWORD; + case 'l': return LIMIT; + case 'm': return MODERATED; + case 'n': return BLOCK_EXTERNAL; + case 'p': return PARANOID; + case 'r': return BLOCK_UNIDENTIFIED; + case 's': return UNLISTED; + case 't': return RESTRICT_TOPIC; + case 'z': return REDUCED_MODERATION; + + } + return null; + } + + @Override + public char charFromMode(ChanMode mode) { + switch (mode) { + case ONLY_ADMIN: return 'A'; + case BLOCK_CTCP: return 'C'; + case ALLOW_FORWARD: return 'F'; + case ONLY_OPER: return 'O'; + case PERMANENT: return 'P'; + case BLOCK_FORWARDING: return 'Q'; + case ONLY_SSL: return 'S'; + case BLOCK_NOTICE: return 'T'; + case BLOCK_COLOR: return 'c'; + case FORWARD: return 'f'; + case ALLOW_INVITE: return 'g'; + case ONLY_INVITE: return 'i'; + case JOIN_THROTTLE: return 'j'; + case PASSWORD: return 'k'; + case LIMIT: return 'l'; + case MODERATED: return 'm'; + case BLOCK_EXTERNAL: return 'n'; + case PARANOID: return 'p'; + case BLOCK_UNIDENTIFIED: return 'r'; + case UNLISTED: return 's'; + case RESTRICT_TOPIC: return 't'; + case REDUCED_MODERATION: return 'z'; + } + return ' '; + } + + @Override + protected Collection<Character> supportedModes() { + return supportedModes; + } +} diff --git a/app/src/main/java/de/kuschku/util/irc/chanmodes/impl/DalIrcModeProvider.java b/app/src/main/java/de/kuschku/util/irc/chanmodes/impl/DalIrcModeProvider.java new file mode 100644 index 0000000000000000000000000000000000000000..2a912eb69e56c8e729dc0c6f4729ba3eab2f08cd --- /dev/null +++ b/app/src/main/java/de/kuschku/util/irc/chanmodes/impl/DalIrcModeProvider.java @@ -0,0 +1,90 @@ +/* + * QuasselDroid - Quassel client for Android + * Copyright (C) 2016 Janne Koschinski + * Copyright (C) 2016 Ken Børge Viktil + * Copyright (C) 2016 Magnus Fjell + * Copyright (C) 2016 Martin Sandsmark <martin.sandsmark@kde.org> + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +package de.kuschku.util.irc.chanmodes.impl; + +import de.kuschku.util.irc.chanmodes.AbstractIrcModeProvider; +import de.kuschku.util.irc.chanmodes.ChanMode; + +import java.util.Arrays; +import java.util.Collection; +import java.util.HashSet; +import java.util.Set; + +import static de.kuschku.util.irc.chanmodes.ChanMode.*; + +public class DalIrcModeProvider extends AbstractIrcModeProvider { + + protected Set<Character> supportedModes = new HashSet<>(Arrays.asList( + 'A', 'M', 'O', 'R', 'S', 'c', 'i', 'j', 'k', 'l', 'm', 'n', 'p', 'r', 's', 't' + )); + + @Override + public ChanMode modeFromChar(char mode) { + switch (mode) { + case 'A': return AUDITORIUM; + case 'M': return QUIET_UNIDENTIFIED; + case 'O': return ONLY_OPER; + case 'R': return BLOCK_UNIDENTIFIED; + case 'S': return ONLY_SSL; + case 'c': return BLOCK_COLOR; + case 'i': return ONLY_INVITE; + case 'j': return JOIN_THROTTLE; + case 'k': return PASSWORD; + case 'l': return LIMIT; + case 'm': return MODERATED; + case 'n': return BLOCK_EXTERNAL; + case 'p': return PARANOID; + case 'r': return REGISTERED; + case 's': return UNLISTED; + case 't': return RESTRICT_TOPIC; + } + return null; + } + + @Override + public char charFromMode(ChanMode mode) { + switch (mode) { + case AUDITORIUM: return 'A'; + case QUIET_UNIDENTIFIED: return 'M'; + case ONLY_OPER: return 'O'; + case BLOCK_UNIDENTIFIED: return 'R'; + case ONLY_SSL: return 'S'; + case BLOCK_COLOR: return 'c'; + case ONLY_INVITE: return 'i'; + case JOIN_THROTTLE: return 'j'; + case PASSWORD: return 'k'; + case LIMIT: return 'l'; + case MODERATED: return 'm'; + case BLOCK_EXTERNAL: return 'n'; + case PARANOID: return 'p'; + case REGISTERED: return 'r'; + case UNLISTED: return 's'; + case RESTRICT_TOPIC: return 't'; + } + return ' '; + } + + @Override + protected Collection<Character> supportedModes() { + return supportedModes; + } +} diff --git a/app/src/main/java/de/kuschku/util/irc/chanmodes/impl/DancerIrcModeProvider.java b/app/src/main/java/de/kuschku/util/irc/chanmodes/impl/DancerIrcModeProvider.java new file mode 100644 index 0000000000000000000000000000000000000000..42cb3667b7c67e04970bbadba941110ac73e011d --- /dev/null +++ b/app/src/main/java/de/kuschku/util/irc/chanmodes/impl/DancerIrcModeProvider.java @@ -0,0 +1,86 @@ +/* + * QuasselDroid - Quassel client for Android + * Copyright (C) 2016 Janne Koschinski + * Copyright (C) 2016 Ken Børge Viktil + * Copyright (C) 2016 Magnus Fjell + * Copyright (C) 2016 Martin Sandsmark <martin.sandsmark@kde.org> + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +package de.kuschku.util.irc.chanmodes.impl; + +import de.kuschku.util.irc.chanmodes.AbstractIrcModeProvider; +import de.kuschku.util.irc.chanmodes.ChanMode; + +import java.util.Arrays; +import java.util.Collection; +import java.util.HashSet; +import java.util.Set; + +import static de.kuschku.util.irc.chanmodes.ChanMode.*; + +public class DancerIrcModeProvider extends AbstractIrcModeProvider { + + protected Set<Character> supportedModes = new HashSet<>(Arrays.asList( + 'J', 'P', 'Q', 'R', 'c', 'g', 'i', 'k', 'l', 'm', 'n', 'r', 's', 'z' + )); + + @Override + public ChanMode modeFromChar(char mode) { + switch (mode) { + case 'J': return JOIN_THROTTLE; + case 'P': return PERMANENT; + case 'Q': return BLOCK_FORWARDING; + case 'R': return QUIET_UNIDENTIFIED; + case 'c': return BLOCK_COLOR; + case 'g': return ALLOW_INVITE; + case 'i': return ONLY_INVITE; + case 'k': return PASSWORD; + case 'l': return LIMIT; + case 'm': return MODERATED; + case 'n': return BLOCK_EXTERNAL; + case 'r': return BLOCK_UNIDENTIFIED; + case 's': return UNLISTED; + case 'z': return REDUCED_MODERATION; + } + return null; + } + + @Override + public char charFromMode(ChanMode mode) { + switch (mode) { + case JOIN_THROTTLE: return 'J'; + case PERMANENT: return 'P'; + case BLOCK_FORWARDING: return 'Q'; + case QUIET_UNIDENTIFIED: return 'R'; + case BLOCK_COLOR: return 'c'; + case ALLOW_INVITE: return 'g'; + case ONLY_INVITE: return 'i'; + case PASSWORD: return 'k'; + case LIMIT: return 'l'; + case MODERATED: return 'm'; + case BLOCK_EXTERNAL: return 'n'; + case BLOCK_UNIDENTIFIED: return 'r'; + case UNLISTED: return 's'; + case REDUCED_MODERATION: return 'z'; + } + return ' '; + } + + @Override + protected Collection<Character> supportedModes() { + return supportedModes; + } +} diff --git a/app/src/main/java/de/kuschku/util/irc/chanmodes/impl/FqIrcModeProvider.java b/app/src/main/java/de/kuschku/util/irc/chanmodes/impl/FqIrcModeProvider.java new file mode 100644 index 0000000000000000000000000000000000000000..3dcf74165805d68672bb07780709bea042abea2c --- /dev/null +++ b/app/src/main/java/de/kuschku/util/irc/chanmodes/impl/FqIrcModeProvider.java @@ -0,0 +1,89 @@ +/* + * QuasselDroid - Quassel client for Android + * Copyright (C) 2016 Janne Koschinski + * Copyright (C) 2016 Ken Børge Viktil + * Copyright (C) 2016 Magnus Fjell + * Copyright (C) 2016 Martin Sandsmark <martin.sandsmark@kde.org> + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +package de.kuschku.util.irc.chanmodes.impl; + +import de.kuschku.util.irc.chanmodes.AbstractIrcModeProvider; +import de.kuschku.util.irc.chanmodes.ChanMode; + +import java.util.Arrays; +import java.util.Collection; +import java.util.HashSet; +import java.util.Set; + +import static de.kuschku.util.irc.chanmodes.ChanMode.*; + +public class FqIrcModeProvider extends AbstractIrcModeProvider { + + protected Set<Character> supportedModes = new HashSet<>(Arrays.asList( + 'M', 'O', 'R', 'S', 'c', 'i', 'j', 'k', 'l', 'm', 'n', 'p', 'q', 'r', 's', 't' + )); + + @Override + public ChanMode modeFromChar(char mode) { + switch (mode) { + case 'M': return QUIET_UNIDENTIFIED; + case 'O': return ONLY_OPER; + case 'R': return BLOCK_UNIDENTIFIED; + case 'S': return ONLY_SSL; + case 'c': return BLOCK_COLOR; + case 'i': return ONLY_INVITE; + case 'j': return JOIN_THROTTLE; + case 'k': return PASSWORD; + case 'l': return LIMIT; + case 'm': return MODERATED; + case 'n': return BLOCK_EXTERNAL; + case 'p': return PARANOID; + case 'q': return BLOCK_UNIDENTIFIED; + case 'r': return REGISTERED; + case 's': return UNLISTED; + case 't': return RESTRICT_TOPIC; + } + return null; + } + + @Override + public char charFromMode(ChanMode mode) { + switch (mode) { + case QUIET_UNIDENTIFIED: return 'M'; + case ONLY_OPER: return 'O'; + case ONLY_SSL: return 'S'; + case BLOCK_COLOR: return 'c'; + case ONLY_INVITE: return 'i'; + case JOIN_THROTTLE: return 'j'; + case PASSWORD: return 'k'; + case LIMIT: return 'l'; + case MODERATED: return 'm'; + case BLOCK_EXTERNAL: return 'n'; + case PARANOID: return 'p'; + case BLOCK_UNIDENTIFIED: return 'q'; + case REGISTERED: return 'r'; + case UNLISTED: return 's'; + case RESTRICT_TOPIC: return 't'; + } + return ' '; + } + + @Override + protected Collection<Character> supportedModes() { + return supportedModes; + } +} diff --git a/app/src/main/java/de/kuschku/util/irc/chanmodes/impl/HybridIrcModeProvider.java b/app/src/main/java/de/kuschku/util/irc/chanmodes/impl/HybridIrcModeProvider.java new file mode 100644 index 0000000000000000000000000000000000000000..bcb461f6d3f075bc3c12e5ded379957cd2b7cb84 --- /dev/null +++ b/app/src/main/java/de/kuschku/util/irc/chanmodes/impl/HybridIrcModeProvider.java @@ -0,0 +1,86 @@ +/* + * QuasselDroid - Quassel client for Android + * Copyright (C) 2016 Janne Koschinski + * Copyright (C) 2016 Ken Børge Viktil + * Copyright (C) 2016 Magnus Fjell + * Copyright (C) 2016 Martin Sandsmark <martin.sandsmark@kde.org> + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +package de.kuschku.util.irc.chanmodes.impl; + +import de.kuschku.util.irc.chanmodes.AbstractIrcModeProvider; +import de.kuschku.util.irc.chanmodes.ChanMode; + +import java.util.Arrays; +import java.util.Collection; +import java.util.HashSet; +import java.util.Set; + +import static de.kuschku.util.irc.chanmodes.ChanMode.*; + +public class HybridIrcModeProvider extends AbstractIrcModeProvider { + + protected Set<Character> supportedModes = new HashSet<>(Arrays.asList( + 'M', 'O', 'R', 'S', 'c', 'i', 'k', 'l', 'm', 'n', 'p', 'r', 's', 't' + )); + + @Override + public ChanMode modeFromChar(char mode) { + switch (mode) { + case 'M': return QUIET_UNIDENTIFIED; + case 'O': return ONLY_OPER; + case 'R': return BLOCK_UNIDENTIFIED; + case 'S': return ONLY_SSL; + case 'c': return BLOCK_COLOR; + case 'i': return ONLY_INVITE; + case 'k': return PASSWORD; + case 'l': return LIMIT; + case 'm': return MODERATED; + case 'n': return BLOCK_EXTERNAL; + case 'p': return PARANOID; + case 'r': return REGISTERED; + case 's': return UNLISTED; + case 't': return RESTRICT_TOPIC; + } + return null; + } + + @Override + public char charFromMode(ChanMode mode) { + switch (mode) { + case QUIET_UNIDENTIFIED: return 'M'; + case ONLY_OPER: return 'O'; + case BLOCK_UNIDENTIFIED: return 'R'; + case ONLY_SSL: return 'S'; + case BLOCK_COLOR: return 'c'; + case ONLY_INVITE: return 'i'; + case PASSWORD: return 'k'; + case LIMIT: return 'l'; + case MODERATED: return 'm'; + case BLOCK_EXTERNAL: return 'n'; + case PARANOID: return 'p'; + case REGISTERED: return 'r'; + case UNLISTED: return 's'; + case RESTRICT_TOPIC: return 't'; + } + return ' '; + } + + @Override + protected Collection<Character> supportedModes() { + return supportedModes; + } +} diff --git a/app/src/main/java/de/kuschku/util/irc/chanmodes/impl/HyperionIrcModeProvider.java b/app/src/main/java/de/kuschku/util/irc/chanmodes/impl/HyperionIrcModeProvider.java new file mode 100644 index 0000000000000000000000000000000000000000..56e5150bbc895cc150d8da8fcb30c450d8594564 --- /dev/null +++ b/app/src/main/java/de/kuschku/util/irc/chanmodes/impl/HyperionIrcModeProvider.java @@ -0,0 +1,82 @@ +/* + * QuasselDroid - Quassel client for Android + * Copyright (C) 2016 Janne Koschinski + * Copyright (C) 2016 Ken Børge Viktil + * Copyright (C) 2016 Magnus Fjell + * Copyright (C) 2016 Martin Sandsmark <martin.sandsmark@kde.org> + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +package de.kuschku.util.irc.chanmodes.impl; + +import de.kuschku.util.irc.chanmodes.AbstractIrcModeProvider; +import de.kuschku.util.irc.chanmodes.ChanMode; + +import java.util.Arrays; +import java.util.Collection; +import java.util.HashSet; +import java.util.Set; + +import static de.kuschku.util.irc.chanmodes.ChanMode.*; + +public class HyperionIrcModeProvider extends AbstractIrcModeProvider { + + protected Set<Character> supportedModes = new HashSet<>(Arrays.asList( + 'Q', 'R', 'c', 'g', 'i', 'k', 'l', 'm', 'n', 'r', 's', 'z' + )); + + @Override + public ChanMode modeFromChar(char mode) { + switch (mode) { + case 'Q': return BLOCK_FORWARDING; + case 'R': return QUIET_UNIDENTIFIED; + case 'c': return BLOCK_COLOR; + case 'g': return ALLOW_INVITE; + case 'i': return ONLY_INVITE; + case 'k': return PASSWORD; + case 'l': return LIMIT; + case 'm': return MODERATED; + case 'n': return BLOCK_EXTERNAL; + case 'r': return BLOCK_UNIDENTIFIED; + case 's': return UNLISTED; + case 'z': return REDUCED_MODERATION; + } + return null; + } + + @Override + public char charFromMode(ChanMode mode) { + switch (mode) { + case BLOCK_FORWARDING: return 'Q'; + case QUIET_UNIDENTIFIED: return 'R'; + case BLOCK_COLOR: return 'c'; + case ALLOW_INVITE: return 'g'; + case ONLY_INVITE: return 'i'; + case PASSWORD: return 'k'; + case LIMIT: return 'l'; + case MODERATED: return 'm'; + case BLOCK_EXTERNAL: return 'n'; + case BLOCK_UNIDENTIFIED: return 'r'; + case UNLISTED: return 's'; + case REDUCED_MODERATION: return 'z'; + } + return ' '; + } + + @Override + protected Collection<Character> supportedModes() { + return supportedModes; + } +} diff --git a/app/src/main/java/de/kuschku/util/irc/chanmodes/impl/InspireIrcModeProvider.java b/app/src/main/java/de/kuschku/util/irc/chanmodes/impl/InspireIrcModeProvider.java new file mode 100644 index 0000000000000000000000000000000000000000..928074ac86c5ff0ee4b22c28c2d43f8495ca95cf --- /dev/null +++ b/app/src/main/java/de/kuschku/util/irc/chanmodes/impl/InspireIrcModeProvider.java @@ -0,0 +1,116 @@ +/* + * QuasselDroid - Quassel client for Android + * Copyright (C) 2016 Janne Koschinski + * Copyright (C) 2016 Ken Børge Viktil + * Copyright (C) 2016 Magnus Fjell + * Copyright (C) 2016 Martin Sandsmark <martin.sandsmark@kde.org> + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +package de.kuschku.util.irc.chanmodes.impl; + +import de.kuschku.util.irc.chanmodes.AbstractIrcModeProvider; +import de.kuschku.util.irc.chanmodes.ChanMode; + +import java.util.Arrays; +import java.util.Collection; +import java.util.HashSet; +import java.util.Set; + +import static de.kuschku.util.irc.chanmodes.ChanMode.*; + +public class InspireIrcModeProvider extends AbstractIrcModeProvider { + + protected Set<Character> supportedModes = new HashSet<>(Arrays.asList( + 'A', 'B', 'C', 'D', 'G', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'c', 'f', 'i', 'j', 'k', 'l', 'm', 'n', 'p', 'r', 's', 't', 'u', 'z' + )); + + @Override + public ChanMode modeFromChar(char mode) { + switch (mode) { + case 'A': return ALLOW_INVITE; + case 'B': return BLOCK_CAPS; + case 'C': return BLOCK_CTCP; + case 'D': return HIDE_JOINS; + case 'G': return CENSOR; + case 'K': return BLOCK_KNOCK; + case 'L': return FORWARD; + case 'M': return QUIET_UNIDENTIFIED; + case 'N': return BLOCK_NICKCHANGE; + case 'O': return ONLY_OPER; + case 'P': return PERMANENT; + case 'Q': return BLOCK_KICK; + case 'R': return BLOCK_UNIDENTIFIED; + case 'S': return STRIP_COLOR; + case 'T': return BLOCK_NOTICE; + case 'c': return BLOCK_COLOR; + case 'f': return ANTIFLOOD; + case 'i': return ONLY_INVITE; + case 'j': return JOIN_THROTTLE; + case 'k': return PASSWORD; + case 'l': return LIMIT; + case 'm': return MODERATED; + case 'n': return BLOCK_EXTERNAL; + case 'p': return PARANOID; + case 'r': return REGISTERED; + case 's': return UNLISTED; + case 't': return RESTRICT_TOPIC; + case 'u': return AUDITORIUM; + case 'z': return ONLY_SSL; + } + return null; + } + + @Override + public char charFromMode(ChanMode mode) { + switch (mode) { + case ALLOW_INVITE: return 'A'; + case BLOCK_CAPS: return 'B'; + case BLOCK_CTCP: return 'C'; + case HIDE_JOINS: return 'D'; + case CENSOR: return 'G'; + case BLOCK_KNOCK: return 'K'; + case FORWARD: return 'L'; + case QUIET_UNIDENTIFIED: return 'M'; + case BLOCK_NICKCHANGE: return 'N'; + case ONLY_OPER: return 'O'; + case PERMANENT: return 'P'; + case BLOCK_KICK: return 'Q'; + case BLOCK_UNIDENTIFIED: return 'R'; + case STRIP_COLOR: return 'S'; + case BLOCK_NOTICE: return 'T'; + case BLOCK_COLOR: return 'c'; + case ANTIFLOOD: return 'f'; + case ONLY_INVITE: return 'i'; + case JOIN_THROTTLE: return 'j'; + case PASSWORD: return 'k'; + case LIMIT: return 'l'; + case MODERATED: return 'm'; + case BLOCK_EXTERNAL: return 'n'; + case PARANOID: return 'p'; + case REGISTERED: return 'r'; + case UNLISTED: return 's'; + case RESTRICT_TOPIC: return 't'; + case AUDITORIUM: return 'u'; + case ONLY_SSL: return 'z'; + } + return ' '; + } + + @Override + protected Collection<Character> supportedModes() { + return supportedModes; + } +} diff --git a/app/src/main/java/de/kuschku/util/irc/chanmodes/impl/NeoIrcModeProvider.java b/app/src/main/java/de/kuschku/util/irc/chanmodes/impl/NeoIrcModeProvider.java new file mode 100644 index 0000000000000000000000000000000000000000..c4d28f615c72d40f64e60ed4c8301ea1980ef151 --- /dev/null +++ b/app/src/main/java/de/kuschku/util/irc/chanmodes/impl/NeoIrcModeProvider.java @@ -0,0 +1,90 @@ +/* + * QuasselDroid - Quassel client for Android + * Copyright (C) 2016 Janne Koschinski + * Copyright (C) 2016 Ken Børge Viktil + * Copyright (C) 2016 Magnus Fjell + * Copyright (C) 2016 Martin Sandsmark <martin.sandsmark@kde.org> + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +package de.kuschku.util.irc.chanmodes.impl; + +import de.kuschku.util.irc.chanmodes.AbstractIrcModeProvider; +import de.kuschku.util.irc.chanmodes.ChanMode; + +import java.util.Arrays; +import java.util.Collection; +import java.util.HashSet; +import java.util.Set; + +import static de.kuschku.util.irc.chanmodes.ChanMode.*; + +public class NeoIrcModeProvider extends AbstractIrcModeProvider { + + protected Set<Character> supportedModes = new HashSet<>(Arrays.asList( + 'M', 'N', 'O', 'P', 'Q', 'R', 'V', 'i', 'k', 'l', 'm', 'n', 'r', 's', 't', 'z' + )); + + @Override + public ChanMode modeFromChar(char mode) { + switch (mode) { + case 'M': return QUIET_UNIDENTIFIED; + case 'N': return BLOCK_NICKCHANGE; + case 'O': return ONLY_OPER; + case 'P': return PERMANENT; + case 'Q': return BLOCK_KICK; + case 'R': return BLOCK_UNIDENTIFIED; + case 'V': return DISABLE_INVITE; + case 'i': return ONLY_INVITE; + case 'k': return PASSWORD; + case 'l': return LIMIT; + case 'm': return MODERATED; + case 'n': return BLOCK_EXTERNAL; + case 'r': return REGISTERED; + case 's': return UNLISTED; + case 't': return RESTRICT_TOPIC; + case 'z': return ONLY_SSL; + } + return null; + } + + @Override + public char charFromMode(ChanMode mode) { + switch (mode) { + case QUIET_UNIDENTIFIED: return 'M'; + case BLOCK_NICKCHANGE: return 'N'; + case ONLY_OPER: return 'O'; + case PERMANENT: return 'P'; + case BLOCK_KICK: return 'Q'; + case BLOCK_UNIDENTIFIED: return 'R'; + case DISABLE_INVITE: return 'V'; + case ONLY_INVITE: return 'i'; + case PASSWORD: return 'k'; + case LIMIT: return 'l'; + case MODERATED: return 'm'; + case BLOCK_EXTERNAL: return 'n'; + case REGISTERED: return 'r'; + case UNLISTED: return 's'; + case RESTRICT_TOPIC: return 't'; + case ONLY_SSL: return 'z'; + } + return ' '; + } + + @Override + protected Collection<Character> supportedModes() { + return supportedModes; + } +} diff --git a/app/src/main/java/de/kuschku/util/irc/chanmodes/impl/NightstarIrcModeProvider.java b/app/src/main/java/de/kuschku/util/irc/chanmodes/impl/NightstarIrcModeProvider.java new file mode 100644 index 0000000000000000000000000000000000000000..b2bae9198abff505ab66486491059f4460b78df5 --- /dev/null +++ b/app/src/main/java/de/kuschku/util/irc/chanmodes/impl/NightstarIrcModeProvider.java @@ -0,0 +1,78 @@ +/* + * QuasselDroid - Quassel client for Android + * Copyright (C) 2016 Janne Koschinski + * Copyright (C) 2016 Ken Børge Viktil + * Copyright (C) 2016 Magnus Fjell + * Copyright (C) 2016 Martin Sandsmark <martin.sandsmark@kde.org> + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +package de.kuschku.util.irc.chanmodes.impl; + +import de.kuschku.util.irc.chanmodes.AbstractIrcModeProvider; +import de.kuschku.util.irc.chanmodes.ChanMode; + +import java.util.Arrays; +import java.util.Collection; +import java.util.HashSet; +import java.util.Set; + +import static de.kuschku.util.irc.chanmodes.ChanMode.*; + +public class NightstarIrcModeProvider extends AbstractIrcModeProvider { + + protected Set<Character> supportedModes = new HashSet<>(Arrays.asList( + 'C', 'i', 'k', 'l', 'm', 'n', 'p', 'r', 's', 't' + )); + + @Override + protected Collection<Character> supportedModes() { + return supportedModes; + } + + @Override + public ChanMode modeFromChar(char mode) { + switch (mode) { + case 'C': return BLOCK_COLOR; + case 'i': return ONLY_INVITE; + case 'k': return PASSWORD; + case 'l': return LIMIT; + case 'm': return MODERATED; + case 'n': return BLOCK_EXTERNAL; + case 'p': return PARANOID; + case 'r': return REGISTERED; + case 's': return UNLISTED; + case 't': return RESTRICT_TOPIC; + } + return null; + } + + @Override + public char charFromMode(ChanMode mode) { + switch (mode) { + case BLOCK_COLOR: return 'C'; + case ONLY_INVITE: return 'i'; + case PASSWORD: return 'k'; + case LIMIT: return 'l'; + case MODERATED: return 'm'; + case BLOCK_EXTERNAL: return 'n'; + case PARANOID: return 'p'; + case REGISTERED: return 'r'; + case UNLISTED: return 's'; + case RESTRICT_TOPIC: return 't'; + } + return ' '; + } +} diff --git a/app/src/main/java/de/kuschku/util/irc/chanmodes/impl/RfcIrcModeProvider.java b/app/src/main/java/de/kuschku/util/irc/chanmodes/impl/RfcIrcModeProvider.java new file mode 100644 index 0000000000000000000000000000000000000000..76cd66513a71c15ba7ca4bc17a5eef011d6b4a4b --- /dev/null +++ b/app/src/main/java/de/kuschku/util/irc/chanmodes/impl/RfcIrcModeProvider.java @@ -0,0 +1,74 @@ +/* + * QuasselDroid - Quassel client for Android + * Copyright (C) 2016 Janne Koschinski + * Copyright (C) 2016 Ken Børge Viktil + * Copyright (C) 2016 Magnus Fjell + * Copyright (C) 2016 Martin Sandsmark <martin.sandsmark@kde.org> + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +package de.kuschku.util.irc.chanmodes.impl; + +import de.kuschku.util.irc.chanmodes.AbstractIrcModeProvider; +import de.kuschku.util.irc.chanmodes.ChanMode; + +import java.util.Arrays; +import java.util.Collection; +import java.util.HashSet; +import java.util.Set; + +import static de.kuschku.util.irc.chanmodes.ChanMode.*; + +public class RfcIrcModeProvider extends AbstractIrcModeProvider { + + protected Set<Character> supportedModes = new HashSet<>(Arrays.asList( + 'p', 's', 'i', 't', 'n', 'm', 'l', 'k' + )); + + @Override + public ChanMode modeFromChar(char mode) { + switch (mode) { + case 'p': return PARANOID; + case 's': return UNLISTED; + case 'i': return ONLY_INVITE; + case 't': return RESTRICT_TOPIC; + case 'n': return BLOCK_EXTERNAL; + case 'm': return MODERATED; + case 'l': return LIMIT; + case 'k': return PASSWORD; + } + return null; + } + + @Override + public char charFromMode(ChanMode mode) { + switch (mode) { + case PARANOID: return 'p'; + case UNLISTED: return 's'; + case ONLY_INVITE: return 'i'; + case RESTRICT_TOPIC: return 't'; + case BLOCK_EXTERNAL: return 'n'; + case MODERATED: return 'm'; + case LIMIT: return 'l'; + case PASSWORD: return 'k'; + } + return ' '; + } + + @Override + protected Collection<Character> supportedModes() { + return supportedModes; + } +} diff --git a/app/src/main/java/de/kuschku/util/irc/chanmodes/impl/ShadowIrcModeProvider.java b/app/src/main/java/de/kuschku/util/irc/chanmodes/impl/ShadowIrcModeProvider.java new file mode 100644 index 0000000000000000000000000000000000000000..b78647b781d026cb11793a509dc7c23087a661e5 --- /dev/null +++ b/app/src/main/java/de/kuschku/util/irc/chanmodes/impl/ShadowIrcModeProvider.java @@ -0,0 +1,112 @@ +/* + * QuasselDroid - Quassel client for Android + * Copyright (C) 2016 Janne Koschinski + * Copyright (C) 2016 Ken Børge Viktil + * Copyright (C) 2016 Magnus Fjell + * Copyright (C) 2016 Martin Sandsmark <martin.sandsmark@kde.org> + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +package de.kuschku.util.irc.chanmodes.impl; + +import de.kuschku.util.irc.chanmodes.AbstractIrcModeProvider; +import de.kuschku.util.irc.chanmodes.ChanMode; + +import java.util.Arrays; +import java.util.Collection; +import java.util.HashSet; +import java.util.Set; + +import static de.kuschku.util.irc.chanmodes.ChanMode.*; + +public class ShadowIrcModeProvider extends AbstractIrcModeProvider { + + protected Set<Character> supportedModes = new HashSet<>(Arrays.asList( + 'A', 'C', 'D', 'E', 'F', 'G', 'J', 'K', 'O', 'P', 'Q', 'S', 'T', 'c', 'd', 'g', 'i', 'j', 'k', 'l', 'm', 'n', 'p', 'r', 's', 't', 'z' + )); + + @Override + public ChanMode modeFromChar(char mode) { + switch (mode) { + case 'A': return ONLY_ADMIN; + case 'C': return BLOCK_CTCP; + case 'D': return BLOCK_ACTION; + case 'E': return BLOCK_KICK; + case 'F': return ALLOW_FORWARD; + case 'G': return BLOCK_CAPS; + case 'J': return BLOCK_AUTOREJOIN; + case 'K': return BLOCK_REPEAT; + case 'O': return ONLY_OPER; + case 'P': return PERMANENT; + case 'Q': return BLOCK_FORWARDING; + case 'S': return ONLY_SSL; + case 'T': return BLOCK_NOTICE; + case 'c': return STRIP_COLOR; + case 'd': return BLOCK_NICKCHANGE; + case 'g': return ALLOW_INVITE; + case 'i': return ONLY_INVITE; + case 'j': return JOIN_THROTTLE; + case 'k': return PASSWORD; + case 'l': return LIMIT; + case 'm': return MODERATED; + case 'n': return BLOCK_EXTERNAL; + case 'p': return PARANOID; + case 'r': return BLOCK_UNIDENTIFIED; + case 's': return UNLISTED; + case 't': return RESTRICT_TOPIC; + case 'z': return REDUCED_MODERATION; + } + return null; + } + + @Override + public char charFromMode(ChanMode mode) { + switch (mode) { + case ONLY_ADMIN: return 'A'; + case BLOCK_CTCP: return 'C'; + case BLOCK_ACTION: return 'D'; + case BLOCK_KICK: return 'E'; + case ALLOW_FORWARD: return 'F'; + case BLOCK_CAPS: return 'G'; + case BLOCK_AUTOREJOIN: return 'J'; + case BLOCK_REPEAT: return 'K'; + case ONLY_OPER: return 'O'; + case PERMANENT: return 'P'; + case BLOCK_FORWARDING: return 'Q'; + case ONLY_SSL: return 'S'; + case BLOCK_NOTICE: return 'T'; + case STRIP_COLOR: return 'c'; + case BLOCK_NICKCHANGE: return 'd'; + case ALLOW_INVITE: return 'g'; + case ONLY_INVITE: return 'i'; + case JOIN_THROTTLE: return 'j'; + case PASSWORD: return 'k'; + case LIMIT: return 'l'; + case MODERATED: return 'm'; + case BLOCK_EXTERNAL: return 'n'; + case PARANOID: return 'p'; + case BLOCK_UNIDENTIFIED: return 'r'; + case UNLISTED: return 's'; + case RESTRICT_TOPIC: return 't'; + case REDUCED_MODERATION: return 'z'; + } + return ' '; + } + + @Override + protected Collection<Character> supportedModes() { + return supportedModes; + } +} diff --git a/app/src/main/java/de/kuschku/util/irc/chanmodes/impl/SolidIrcModeProvider.java b/app/src/main/java/de/kuschku/util/irc/chanmodes/impl/SolidIrcModeProvider.java new file mode 100644 index 0000000000000000000000000000000000000000..97acd327b6eb18f0791591a2cef089bf6593760f --- /dev/null +++ b/app/src/main/java/de/kuschku/util/irc/chanmodes/impl/SolidIrcModeProvider.java @@ -0,0 +1,106 @@ +/* + * QuasselDroid - Quassel client for Android + * Copyright (C) 2016 Janne Koschinski + * Copyright (C) 2016 Ken Børge Viktil + * Copyright (C) 2016 Magnus Fjell + * Copyright (C) 2016 Martin Sandsmark <martin.sandsmark@kde.org> + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +package de.kuschku.util.irc.chanmodes.impl; + +import de.kuschku.util.irc.chanmodes.AbstractIrcModeProvider; +import de.kuschku.util.irc.chanmodes.ChanMode; + +import java.util.Arrays; +import java.util.Collection; +import java.util.HashSet; +import java.util.Set; + +import static de.kuschku.util.irc.chanmodes.ChanMode.*; + +public class SolidIrcModeProvider extends AbstractIrcModeProvider { + + protected Set<Character> supportedModes = new HashSet<>(Arrays.asList( + 'B', 'C', 'G', 'K', 'M', 'N', 'P', 'Q', 'R', 'S', 'T', 'V', 'c', 'f', 'i', 'k', 'l', 'm', 'n', 'p', 's', 't', 'u', 'z' + )); + + @Override + public ChanMode modeFromChar(char mode) { + switch (mode) { + case 'B': return BLOCK_CAPS; + case 'C': return BLOCK_CTCP; + case 'G': return CENSOR; + case 'K': return BLOCK_KNOCK; + case 'M': return QUIET_UNIDENTIFIED; + case 'N': return BLOCK_NICKCHANGE; + case 'P': return PERMANENT; + case 'Q': return BLOCK_KICK; + case 'R': return BLOCK_UNIDENTIFIED; + case 'S': return STRIP_COLOR; + case 'T': return BLOCK_NOTICE; + case 'V': return DISABLE_INVITE; + case 'c': return BLOCK_COLOR; + case 'f': return ANTIFLOOD; + case 'i': return ONLY_INVITE; + case 'k': return PASSWORD; + case 'l': return LIMIT; + case 'm': return MODERATED; + case 'n': return BLOCK_EXTERNAL; + case 'p': return PARANOID; + case 's': return UNLISTED; + case 't': return RESTRICT_TOPIC; + case 'u': return AUDITORIUM; + case 'z': return ONLY_SSL; + } + return null; + } + + @Override + public char charFromMode(ChanMode mode) { + switch (mode) { + case BLOCK_CAPS: return 'B'; + case BLOCK_CTCP: return 'C'; + case CENSOR: return 'G'; + case BLOCK_KNOCK: return 'K'; + case QUIET_UNIDENTIFIED: return 'M'; + case BLOCK_NICKCHANGE: return 'N'; + case PERMANENT: return 'P'; + case BLOCK_KICK: return 'Q'; + case BLOCK_UNIDENTIFIED: return 'R'; + case STRIP_COLOR: return 'S'; + case BLOCK_NOTICE: return 'T'; + case DISABLE_INVITE: return 'V'; + case BLOCK_COLOR: return 'c'; + case ANTIFLOOD: return 'f'; + case ONLY_INVITE: return 'i'; + case PASSWORD: return 'k'; + case LIMIT: return 'l'; + case MODERATED: return 'm'; + case BLOCK_EXTERNAL: return 'n'; + case PARANOID: return 'p'; + case UNLISTED: return 's'; + case RESTRICT_TOPIC: return 't'; + case AUDITORIUM: return 'u'; + case ONLY_SSL: return 'z'; + } + return ' '; + } + + @Override + protected Collection<Character> supportedModes() { + return supportedModes; + } +} diff --git a/app/src/main/java/de/kuschku/util/irc/chanmodes/impl/UndernetIrcModeProvider.java b/app/src/main/java/de/kuschku/util/irc/chanmodes/impl/UndernetIrcModeProvider.java new file mode 100644 index 0000000000000000000000000000000000000000..d7efd24f6bc1a3348e25912b5ecb22a3570c3b95 --- /dev/null +++ b/app/src/main/java/de/kuschku/util/irc/chanmodes/impl/UndernetIrcModeProvider.java @@ -0,0 +1,74 @@ +/* + * QuasselDroid - Quassel client for Android + * Copyright (C) 2016 Janne Koschinski + * Copyright (C) 2016 Ken Børge Viktil + * Copyright (C) 2016 Magnus Fjell + * Copyright (C) 2016 Martin Sandsmark <martin.sandsmark@kde.org> + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +package de.kuschku.util.irc.chanmodes.impl; + +import de.kuschku.util.irc.chanmodes.AbstractIrcModeProvider; +import de.kuschku.util.irc.chanmodes.ChanMode; + +import java.util.Arrays; +import java.util.Collection; +import java.util.HashSet; +import java.util.Set; + +import static de.kuschku.util.irc.chanmodes.ChanMode.*; + +public class UndernetIrcModeProvider extends AbstractIrcModeProvider { + + protected Set<Character> supportedModes = new HashSet<>(Arrays.asList( + 'i', 'k', 'l', 'm', 'n', 'p', 's', 't' + )); + + @Override + protected Collection<Character> supportedModes() { + return supportedModes; + } + + @Override + public ChanMode modeFromChar(char mode) { + switch (mode) { + case 'i': return ONLY_INVITE; + case 'k': return PASSWORD; + case 'l': return LIMIT; + case 'm': return MODERATED; + case 'n': return BLOCK_EXTERNAL; + case 'p': return PARANOID; + case 's': return UNLISTED; + case 't': return RESTRICT_TOPIC; + } + return null; + } + + @Override + public char charFromMode(ChanMode mode) { + switch (mode) { + case ONLY_INVITE: return 'i'; + case PASSWORD: return 'k'; + case LIMIT: return 'l'; + case MODERATED: return 'm'; + case BLOCK_EXTERNAL: return 'n'; + case PARANOID: return 'p'; + case UNLISTED: return 's'; + case RESTRICT_TOPIC: return 't'; + } + return ' '; + } +} diff --git a/app/src/main/java/de/kuschku/util/irc/chanmodes/impl/UnrealIrcModeProvider.java b/app/src/main/java/de/kuschku/util/irc/chanmodes/impl/UnrealIrcModeProvider.java new file mode 100644 index 0000000000000000000000000000000000000000..04db02db6a747663ff8bf0c12617734c62f23acf --- /dev/null +++ b/app/src/main/java/de/kuschku/util/irc/chanmodes/impl/UnrealIrcModeProvider.java @@ -0,0 +1,110 @@ +/* + * QuasselDroid - Quassel client for Android + * Copyright (C) 2016 Janne Koschinski + * Copyright (C) 2016 Ken Børge Viktil + * Copyright (C) 2016 Magnus Fjell + * Copyright (C) 2016 Martin Sandsmark <martin.sandsmark@kde.org> + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +package de.kuschku.util.irc.chanmodes.impl; + +import de.kuschku.util.irc.chanmodes.AbstractIrcModeProvider; +import de.kuschku.util.irc.chanmodes.ChanMode; + +import java.util.Arrays; +import java.util.Collection; +import java.util.HashSet; +import java.util.Set; + +import static de.kuschku.util.irc.chanmodes.ChanMode.*; + +public class UnrealIrcModeProvider extends AbstractIrcModeProvider { + + protected Set<Character> supportedModes = new HashSet<>(Arrays.asList( + 'C', 'F', 'G', 'K', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'V', 'Z', 'c', 'f', 'i', 'k', 'l', 'm', 'n', 'p', 'r', 's', 't', 'z' + )); + + @Override + public ChanMode modeFromChar(char mode) { + switch (mode) { + case 'C': return BLOCK_CTCP; + case 'F': return FORWARD; + case 'G': return CENSOR; + case 'K': return BLOCK_KNOCK; + case 'M': return QUIET_UNIDENTIFIED; + case 'N': return BLOCK_NICKCHANGE; + case 'O': return ONLY_OPER; + case 'P': return PERMANENT; + case 'Q': return BLOCK_KICK; + case 'R': return BLOCK_UNIDENTIFIED; + case 'S': return STRIP_COLOR; + case 'T': return BLOCK_NOTICE; + case 'V': return DISABLE_INVITE; + case 'Z': return IS_SECURE; + case 'c': return BLOCK_COLOR; + case 'f': return ANTIFLOOD; + case 'i': return ONLY_INVITE; + case 'k': return PASSWORD; + case 'l': return LIMIT; + case 'm': return MODERATED; + case 'n': return BLOCK_EXTERNAL; + case 'p': return PARANOID; + case 'r': return REGISTERED; + case 's': return UNLISTED; + case 't': return RESTRICT_TOPIC; + case 'z': return ONLY_SSL; + } + return null; + } + + @Override + public char charFromMode(ChanMode mode) { + switch (mode) { + case BLOCK_CTCP: return 'C'; + case FORWARD: return 'F'; + case CENSOR: return 'G'; + case BLOCK_KNOCK: return 'K'; + case QUIET_UNIDENTIFIED: return 'M'; + case BLOCK_NICKCHANGE: return 'N'; + case ONLY_OPER: return 'O'; + case PERMANENT: return 'P'; + case BLOCK_KICK: return 'Q'; + case BLOCK_UNIDENTIFIED: return 'R'; + case STRIP_COLOR: return 'S'; + case BLOCK_NOTICE: return 'T'; + case DISABLE_INVITE: return 'V'; + case IS_SECURE: return 'Z'; + case BLOCK_COLOR: return 'c'; + case ANTIFLOOD: return 'f'; + case ONLY_INVITE: return 'i'; + case PASSWORD: return 'k'; + case LIMIT: return 'l'; + case MODERATED: return 'm'; + case BLOCK_EXTERNAL: return 'n'; + case PARANOID: return 'p'; + case REGISTERED: return 'r'; + case UNLISTED: return 's'; + case RESTRICT_TOPIC: return 't'; + case ONLY_SSL: return 'z'; + } + return ' '; + } + + @Override + protected Collection<Character> supportedModes() { + return supportedModes; + } +}