Skip to content
Snippets Groups Projects
Commit 917e1d7c authored by Janne Mareike Koschinski's avatar Janne Mareike Koschinski
Browse files

Implemented static dispatch and ignorelist editing

parent 89fb9fd1
Branches
Tags
No related merge requests found
Showing
with 746 additions and 66 deletions
......@@ -144,6 +144,20 @@
android:parentActivityName=".ui.coresettings.network.server.NetworkServerListActivity"
android:theme="@style/AppTheme.Light"/>
<activity
android:name=".ui.coresettings.ignore.IgnoreListActivity"
android:label="@string/titleEditIgnoreList"
android:launchMode="singleTask"
android:parentActivityName=".ui.chat.MainActivity"
android:theme="@style/AppTheme.Light"/>
<activity
android:name=".ui.coresettings.ignore.IgnoreRuleEditActivity"
android:label="@string/titleEditIgnoreRule"
android:launchMode="singleTask"
android:parentActivityName=".ui.coresettings.ignore.IgnoreListActivity"
android:theme="@style/AppTheme.Light"/>
<activity
android:name=".ui.setup.AccountSetupActivity"
android:label="@string/titleAccountSetup"
......
......@@ -49,6 +49,7 @@ import de.kuschku.libquassel.objects.types.CoreSetupAck;
import de.kuschku.libquassel.objects.types.SessionInit;
import de.kuschku.libquassel.syncables.SyncableRegistry;
import de.kuschku.libquassel.syncables.types.SyncableObject;
import de.kuschku.libquassel.syncables.types.invokers.InvokerRegistry;
import de.kuschku.util.ReflectionUtils;
import static de.kuschku.util.AndroidAssert.assertNotNull;
......@@ -110,7 +111,8 @@ public class ProtocolHandler implements IProtocolHandler {
if (syncable instanceof SyncableObject && !((SyncableObject) syncable).initialized()) {
client.initObject(packedFunc.className, packedFunc.objectName, (SyncableObject) syncable);
} else {
ReflectionUtils.invokeMethod(syncable, "_" + packedFunc.methodName, packedFunc.params);
//ReflectionUtils.invokeMethod(syncable, "_" + packedFunc.methodName, packedFunc.params);
InvokerRegistry.invoke(packedFunc, syncable);
}
}
} catch (Exception e) {
......
......@@ -25,6 +25,7 @@ import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
......@@ -33,6 +34,7 @@ import de.kuschku.libquassel.functions.types.PackedFunction;
import de.kuschku.libquassel.functions.types.SerializedFunction;
import de.kuschku.libquassel.functions.types.UnpackedFunction;
import de.kuschku.libquassel.objects.serializers.ObjectSerializer;
import de.kuschku.libquassel.primitives.QMetaType;
import de.kuschku.libquassel.primitives.types.QVariant;
import de.kuschku.libquassel.syncables.types.impl.IgnoreListManager;
......@@ -56,14 +58,14 @@ public class IgnoreListManagerSerializer implements ObjectSerializer<IgnoreListM
@Override
public Map<String, QVariant<Object>> toVariantMap(@NonNull IgnoreListManager data) {
HashMap<String, QVariant<Object>> map = new HashMap<>();
List<Integer> scope = new ArrayList<>(data.ignoreRules().size());
List<Integer> ignoreType = new ArrayList<>(data.ignoreRules().size());
List<Boolean> isActive = new ArrayList<>(data.ignoreRules().size());
List<String> scopeRule = new ArrayList<>(data.ignoreRules().size());
List<Boolean> isRegEx = new ArrayList<>(data.ignoreRules().size());
List<Integer> strictness = new ArrayList<>(data.ignoreRules().size());
List<String> ignoreRule = new ArrayList<>(data.ignoreRules().size());
for (IgnoreListManager.IgnoreListItem item : data.ignoreRules()) {
List<Integer> scope = new ArrayList<>(data.ignoreList().size());
List<Integer> ignoreType = new ArrayList<>(data.ignoreList().size());
List<Boolean> isActive = new ArrayList<>(data.ignoreList().size());
List<String> scopeRule = new ArrayList<>(data.ignoreList().size());
List<Boolean> isRegEx = new ArrayList<>(data.ignoreList().size());
List<Integer> strictness = new ArrayList<>(data.ignoreList().size());
List<String> ignoreRule = new ArrayList<>(data.ignoreList().size());
for (IgnoreListManager.IgnoreListItem item : data.ignoreList()) {
scope.add(item.getScope().value);
ignoreType.add(item.getType().value);
isActive.add(item.isActive());
......@@ -80,7 +82,9 @@ public class IgnoreListManagerSerializer implements ObjectSerializer<IgnoreListM
map.put("isRegEx", new QVariant(isRegEx));
map.put("strictness", new QVariant(strictness));
map.put("ignoreRule", new QVariant(ignoreRule));
return map;
return Collections.singletonMap("IgnoreList", new QVariant<>(QMetaType.Type.QVariantMap, map));
}
@NonNull
......@@ -92,16 +96,17 @@ public class IgnoreListManagerSerializer implements ObjectSerializer<IgnoreListM
@NonNull
@Override
public IgnoreListManager fromLegacy(@NonNull Map<String, QVariant> map) {
Map<String, QVariant> internalMap = (Map<String, QVariant>) map.get("IgnoreList").data;
assertNotNull(internalMap);
if (map.containsKey("IgnoreList"))
map = (Map<String, QVariant>) map.get("IgnoreList").data;
assertNotNull(map);
return new IgnoreListManager(
(List<Integer>) internalMap.get("scope").data,
(List<Integer>) internalMap.get("ignoreType").data,
(List<Boolean>) internalMap.get("isActive").data,
(List<String>) internalMap.get("scopeRule").data,
(List<Boolean>) internalMap.get("isRegEx").data,
(List<Integer>) internalMap.get("strictness").data,
(List<String>) internalMap.get("ignoreRule").data
(List<Integer>) map.get("scope").data,
(List<Integer>) map.get("ignoreType").data,
(List<Boolean>) map.get("isActive").data,
(List<String>) map.get("scopeRule").data,
(List<Boolean>) map.get("isRegEx").data,
(List<Integer>) map.get("strictness").data,
(List<String>) map.get("ignoreRule").data
);
}
......
......@@ -263,6 +263,11 @@ public class BufferViewConfig extends ABufferViewConfig {
_update();
}
@Override
public void _setMinimumActivity(int activity) {
_setMinimumActivity(MinimumActivity.fromId(activity));
}
@Override
public boolean hideInactiveBuffers() {
return hideInactiveBuffers;
......
......@@ -24,7 +24,6 @@ package de.kuschku.libquassel.syncables.types.impl;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
......@@ -38,13 +37,30 @@ import de.kuschku.libquassel.primitives.types.QVariant;
import de.kuschku.libquassel.syncables.serializers.IgnoreListManagerSerializer;
import de.kuschku.libquassel.syncables.types.abstracts.AIgnoreListManager;
import de.kuschku.libquassel.syncables.types.interfaces.QIgnoreListManager;
import de.kuschku.util.observables.lists.ObservableSortedList;
import de.kuschku.util.regex.SmartRegEx;
import static de.kuschku.util.AndroidAssert.assertEquals;
public class IgnoreListManager extends AIgnoreListManager {
@NonNull
private final List<IgnoreListItem> ignoreList = new ArrayList<>();
private final ObservableSortedList<IgnoreListItem> ignoreList = new ObservableSortedList<>(IgnoreListItem.class, new ObservableSortedList.ItemComparator<IgnoreListItem>() {
@Override
public int compare(IgnoreListItem o1, IgnoreListItem o2) {
return o1.ignoreRule.rule().compareTo(o2.ignoreRule.rule());
}
@Override
public boolean areContentsTheSame(IgnoreListItem oldItem, IgnoreListItem newItem) {
return oldItem.equals(newItem);
}
@Override
public boolean areItemsTheSame(IgnoreListItem item1, IgnoreListItem item2) {
return item1.ignoreRule.rule().equals(item2.ignoreRule.rule());
}
});
public IgnoreListManager(@NonNull List<Integer> scope, @NonNull List<Integer> ignoreType,
@NonNull List<Boolean> isActive, @NonNull List<String> scopeRule, @NonNull List<Boolean> isRegEx,
......@@ -94,6 +110,15 @@ public class IgnoreListManager extends AIgnoreListManager {
_update();
}
@Override
public void _addIgnoreListItem(IgnoreListItem item) {
if (contains(item.ignoreRule.rule()))
return;
ignoreList.add(item);
_update();
}
private boolean contains(String ignoreRule) {
return indexOf(ignoreRule) != -1;
}
......@@ -127,7 +152,7 @@ public class IgnoreListManager extends AIgnoreListManager {
@Override
public void _update(QIgnoreListManager from) {
this.ignoreList.clear();
this.ignoreList.retainAll(from.ignoreList());
this.ignoreList.addAll(from.ignoreList());
this._update();
}
......@@ -153,21 +178,22 @@ public class IgnoreListManager extends AIgnoreListManager {
return String.valueOf(ignoreList);
}
public List<IgnoreListItem> ignoreRules() {
return ignoreList;
}
@Override
public void requestUpdate() {
requestUpdate(IgnoreListManagerSerializer.get().toVariantMap(this));
}
@Override
public List<? extends IgnoreListItem> ignoreList() {
public ObservableSortedList<? extends IgnoreListItem> ignoreList() {
return ignoreList;
}
public class IgnoreListItem {
@Override
public void _toggleIgnoreRule(IgnoreListItem ignoreRule, boolean active) {
ignoreRule.isActive = active;
}
public static class IgnoreListItem {
private final IgnoreType type;
@NonNull
private final SmartRegEx ignoreRule;
......@@ -270,5 +296,37 @@ public class IgnoreListManager extends AIgnoreListManager {
", isActive=" + isActive +
'}';
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof IgnoreListItem)) return false;
IgnoreListItem item = (IgnoreListItem) o;
if (isRegEx() != item.isRegEx()) return false;
if (isActive() != item.isActive()) return false;
if (getType() != item.getType()) return false;
if (!getIgnoreRule().equals(item.getIgnoreRule())) return false;
if (getStrictness() != item.getStrictness()) return false;
if (getScope() != item.getScope()) return false;
// Probably incorrect - comparing Object[] arrays with Arrays.equals
if (!Arrays.equals(scopeRules, item.scopeRules)) return false;
return getScopeRule() != null ? getScopeRule().equals(item.getScopeRule()) : item.getScopeRule() == null;
}
@Override
public int hashCode() {
int result = getType() != null ? getType().hashCode() : 0;
result = 31 * result + getIgnoreRule().hashCode();
result = 31 * result + (isRegEx() ? 1 : 0);
result = 31 * result + (getStrictness() != null ? getStrictness().hashCode() : 0);
result = 31 * result + (getScope() != null ? getScope().hashCode() : 0);
result = 31 * result + Arrays.hashCode(scopeRules);
result = 31 * result + (getScopeRule() != null ? getScopeRule().hashCode() : 0);
result = 31 * result + (isActive() ? 1 : 0);
return result;
}
}
}
......@@ -29,6 +29,7 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Observable;
import java.util.Observer;
......@@ -45,7 +46,7 @@ import de.kuschku.libquassel.syncables.types.interfaces.QIrcChannel;
import de.kuschku.libquassel.syncables.types.interfaces.QIrcUser;
import de.kuschku.libquassel.syncables.types.interfaces.QNetwork;
import de.kuschku.util.CompatibilityUtils;
import de.kuschku.util.irc.IrcCaseMapper;
import de.kuschku.util.irc.IrcCaseMappers;
import de.kuschku.util.irc.IrcUserUtils;
import de.kuschku.util.irc.ModeUtils;
import de.kuschku.util.irc.chanmodes.IrcModeProvider;
......@@ -72,6 +73,7 @@ public class Network extends ANetwork implements Observer {
private List<String> prefixes;
private List<String> prefixModes;
private IrcModeProvider modeProvider;
private IrcCaseMappers.IrcCaseMapper caseMapper;
public Network(Map<String, QIrcChannel> channels,
Map<String, QIrcUser> nicks,
......@@ -88,6 +90,8 @@ public class Network extends ANetwork implements Observer {
this.myNick = myNick;
_setNetworkInfo(networkInfo);
this.networkInfo._setServerList(serverList);
updateCaseMapper();
}
public Network(Map<String, QIrcChannel> channels, Map<String, QIrcUser> users, Map<String, String> supports, int connectionState, String currentServer, boolean isConnected, int latency, String myNick, NetworkInfo networkInfo) {
......@@ -97,7 +101,7 @@ public class Network extends ANetwork implements Observer {
public Network(Map<String, QIrcChannel> channels, Map<String, QIrcUser> nicks, List<NetworkServer> serverList, Map<String, String> supports, ConnectionState connectionState, String currentServer, boolean isConnected, int latency, String myNick, NetworkInfo networkInfo) {
this.channels = new HashMap<>(channels);
this.nicks = new HashMap<>(nicks);
this.supports = supports;
this.supports = new HashMap<>(supports);
this.connectionState = connectionState;
this.currentServer = currentServer;
this.isConnected = isConnected;
......@@ -105,6 +109,8 @@ public class Network extends ANetwork implements Observer {
this.myNick = myNick;
_setNetworkInfo(networkInfo);
this.networkInfo._setServerList(serverList);
updateCaseMapper();
}
@NonNull
......@@ -130,12 +136,12 @@ public class Network extends ANetwork implements Observer {
@Override
public boolean isMyNick(String nick) {
return IrcCaseMapper.equalsIgnoreCase(myNick, nick);
return caseMapper.equalsIgnoreCase(myNick, nick);
}
@Override
public boolean isMe(@NonNull QIrcUser ircuser) {
return IrcCaseMapper.equalsIgnoreCase(ircuser.nick(), myNick());
return caseMapper.equalsIgnoreCase(ircuser.nick(), myNick());
}
@Override
......@@ -403,7 +409,7 @@ public class Network extends ANetwork implements Observer {
@Override
public String support(@NonNull String param) {
String key = IrcCaseMapper.toUpperCase(param);
String key = param.toUpperCase(Locale.US);
if (supports.containsKey(key))
return supports.get(key);
else
......@@ -428,18 +434,18 @@ public class Network extends ANetwork implements Observer {
@Override
public QIrcChannel newIrcChannel(@NonNull String channelname) {
if (!channels.containsKey(IrcCaseMapper.toLowerCase(channelname))) {
if (!channels.containsKey(caseMapper.toLowerCase(channelname))) {
QIrcChannel channel = IrcChannel.create(channelname);
channels.put(IrcCaseMapper.toLowerCase(channelname), channel);
channels.put(caseMapper.toLowerCase(channelname), channel);
channel.init(this, client);
}
return channels.get(IrcCaseMapper.toLowerCase(channelname));
return channels.get(caseMapper.toLowerCase(channelname));
}
@Nullable
@Override
public QIrcChannel ircChannel(String channelname) {
channelname = IrcCaseMapper.toLowerCase(channelname);
channelname = caseMapper.toLowerCase(channelname);
if (channels.containsKey(channelname)) {
return channels.get(channelname);
} else {
......@@ -649,12 +655,35 @@ public class Network extends ANetwork implements Observer {
public void _addSupport(String param, String value) {
supports.put(param, value);
_update();
updateCaseMapper();
}
@Override
public IrcCaseMappers.IrcCaseMapper caseMapper() {
return caseMapper;
}
private void updateCaseMapper() {
String mapping = support("CASEMAPPING");
if (mapping == null) {
caseMapper = IrcCaseMappers.unicode;
} else {
switch (mapping.toLowerCase(Locale.US)) {
case "rfc1459":
case "strict-rfc1459":
caseMapper = IrcCaseMappers.irc;
case "ascii":
default:
caseMapper = IrcCaseMappers.unicode;
}
}
}
@Override
public void _removeSupport(String param) {
supports.remove(param);
_update();
updateCaseMapper();
}
@Override
......@@ -669,7 +698,7 @@ public class Network extends ANetwork implements Observer {
@Override
public QIrcUser _updateNickFromMask(@NonNull String mask) {
String nick = IrcCaseMapper.toLowerCase(IrcUserUtils.getNick(mask));
String nick = caseMapper.toLowerCase(IrcUserUtils.getNick(mask));
QIrcUser user;
if (nicks.containsKey(nick)) {
......@@ -694,7 +723,7 @@ public class Network extends ANetwork implements Observer {
@Override
public void _ircUserNickChanged(@NonNull String oldNick, @NonNull String newNick) {
if (!IrcCaseMapper.equalsIgnoreCase(oldNick, newNick)) {
if (!caseMapper.equalsIgnoreCase(oldNick, newNick)) {
nicks.put(newNick, nicks.remove(oldNick));
for (QIrcChannel channel : channels.values()) {
channel._ircUserNickChanged(oldNick, newNick);
......@@ -702,7 +731,7 @@ public class Network extends ANetwork implements Observer {
_update();
}
if (IrcCaseMapper.equalsIgnoreCase(myNick(), oldNick))
if (caseMapper.equalsIgnoreCase(myNick(), oldNick))
_setMyNick(newNick);
}
......
......@@ -24,9 +24,11 @@ package de.kuschku.libquassel.syncables.types.interfaces;
import android.support.annotation.NonNull;
import java.util.List;
import java.util.Map;
import de.kuschku.libquassel.objects.types.Command;
import de.kuschku.libquassel.primitives.types.BufferInfo;
import de.kuschku.libquassel.primitives.types.QVariant;
import de.kuschku.libquassel.syncables.Synced;
public interface QAliasManager extends QObservable<QAliasManager> {
......@@ -48,6 +50,10 @@ public interface QAliasManager extends QObservable<QAliasManager> {
@NonNull
List<Command> processInput(final BufferInfo info, final String message);
void _update(Map<String, QVariant> from);
void _update(QAliasManager from);
@Synced
void addAlias(final String name, final String expansion);
......
......@@ -86,6 +86,8 @@ public interface QBufferViewConfig extends QSyncableObject<QBufferViewConfig> {
void _setMinimumActivity(MinimumActivity activity);
void _setMinimumActivity(int activity);
boolean hideInactiveBuffers();
@Synced
......
......@@ -24,7 +24,9 @@ package de.kuschku.libquassel.syncables.types.interfaces;
import android.support.annotation.Nullable;
import java.util.List;
import java.util.Map;
import de.kuschku.libquassel.primitives.types.QVariant;
import de.kuschku.libquassel.syncables.Synced;
import de.kuschku.libquassel.syncables.types.impl.Identity;
......@@ -193,4 +195,8 @@ public interface QIdentity extends QObservable<QIdentity> {
@Synced
void update(Identity identity);
void _update(QIdentity identity);
void _update(Map<String, QVariant> identity);
}
......@@ -23,13 +23,13 @@ package de.kuschku.libquassel.syncables.types.interfaces;
import android.support.annotation.NonNull;
import java.util.List;
import java.util.Map;
import de.kuschku.libquassel.message.Message;
import de.kuschku.libquassel.primitives.types.QVariant;
import de.kuschku.libquassel.syncables.Synced;
import de.kuschku.libquassel.syncables.types.impl.IgnoreListManager;
import de.kuschku.util.observables.lists.ObservableSortedList;
public interface QIgnoreListManager extends QObservable<QIgnoreListManager> {
@Synced
......@@ -50,15 +50,23 @@ public interface QIgnoreListManager extends QObservable<QIgnoreListManager> {
void _addIgnoreListItem(int type, final String ignoreRule, boolean isRegEx, int strictness, int scope, final String scopeRule, boolean isActive);
void _addIgnoreListItem(IgnoreListManager.IgnoreListItem item);
StrictnessType match(String msgContents, String msgSender, Message.Type msgType, String network, String bufferName);
boolean matches(Message message, QNetwork network);
void _update(Map<String, QVariant> from);
void _update(QIgnoreListManager from);
void requestUpdate(Map<String, QVariant<Object>> variantMap);
void requestUpdate();
List<? extends IgnoreListManager.IgnoreListItem> ignoreList();
ObservableSortedList<? extends IgnoreListManager.IgnoreListItem> ignoreList();
void _toggleIgnoreRule(IgnoreListManager.IgnoreListItem ignoreRule, boolean active);
enum IgnoreType {
SenderIgnore(0),
......
......@@ -30,6 +30,7 @@ import de.kuschku.libquassel.objects.types.NetworkServer;
import de.kuschku.libquassel.syncables.Synced;
import de.kuschku.libquassel.syncables.types.impl.IrcChannel;
import de.kuschku.libquassel.syncables.types.impl.NetworkInfo;
import de.kuschku.util.irc.IrcCaseMappers;
import de.kuschku.util.irc.chanmodes.IrcModeProvider;
public interface QNetwork extends QObservable<QNetwork> {
......@@ -231,6 +232,7 @@ public interface QNetwork extends QObservable<QNetwork> {
@Synced
void setUseSasl(boolean useSasl);
void setSaslPassword(final String saslPassword);
void _setUseSasl(boolean useSasl);
@Synced
......@@ -239,7 +241,6 @@ public interface QNetwork extends QObservable<QNetwork> {
void _setSaslAccount(final String saslAccount);
@Synced
void setSaslPassword(final String saslPassword);
void _setSaslPassword(final String saslPassword);
......@@ -350,6 +351,8 @@ public interface QNetwork extends QObservable<QNetwork> {
void _addIrcChannel(IrcChannel ircChannel);
IrcCaseMappers.IrcCaseMapper caseMapper();
enum ConnectionState {
Disconnected(0),
Connecting(1),
......
/*
* 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.libquassel.syncables.types.invokers;
import android.support.annotation.NonNull;
import de.kuschku.libquassel.functions.types.SyncFunction;
import de.kuschku.libquassel.syncables.types.interfaces.QAliasManager;
public class IAliasManager implements Invoker<QAliasManager> {
@NonNull
private static final IAliasManager invoker = new IAliasManager();
private IAliasManager() {
}
@NonNull
public static IAliasManager get() {
return invoker;
}
@Override
public void invoke(SyncFunction function, QAliasManager obj) {
switch (function.methodName) {
case "addAlias": {
obj._addAlias((String) function.params.get(0), (String) function.params.get(1));
} break;
case "update": {
InvokerHelper.update(obj, function.params.get(0));
} break;
}
}
}
/*
* 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.libquassel.syncables.types.invokers;
import android.support.annotation.NonNull;
import java.util.List;
import de.kuschku.libquassel.functions.types.SyncFunction;
import de.kuschku.libquassel.message.Message;
import de.kuschku.libquassel.syncables.types.interfaces.QBacklogManager;
public class IBacklogManager implements Invoker<QBacklogManager> {
@NonNull
private static final IBacklogManager invoker = new IBacklogManager();
private IBacklogManager() {
}
@NonNull
public static IBacklogManager get() {
return invoker;
}
@Override
public void invoke(SyncFunction function, QBacklogManager obj) {
switch (function.methodName) {
case "receiveBacklog": {
obj._receiveBacklog((int) function.params.get(0), (int) function.params.get(1), (int) function.params.get(2), (int) function.params.get(3), (int) function.params.get(4), (List<Message>) function.params.get(5));
} break;
case "receiveBacklogAll": {
obj._receiveBacklogAll((int) function.params.get(0), (int) function.params.get(1), (int) function.params.get(2), (int) function.params.get(3), (List<Message>) function.params.get(4));
} break;
case "update": {
InvokerHelper.update(obj, function.params.get(0));
} break;
}
}
}
/*
* 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.libquassel.syncables.types.invokers;
import android.support.annotation.NonNull;
import de.kuschku.libquassel.functions.types.SyncFunction;
import de.kuschku.libquassel.syncables.types.interfaces.QBufferSyncer;
public class IBufferSyncer implements Invoker<QBufferSyncer> {
@NonNull
private static final IBufferSyncer invoker = new IBufferSyncer();
private IBufferSyncer() {
}
@NonNull
public static IBufferSyncer get() {
return invoker;
}
@Override
public void invoke(SyncFunction function, QBufferSyncer obj) {
switch (function.methodName) {
case "setLastSeenMsg": {
obj._setLastSeenMsg((int) function.params.get(0), (int) function.params.get(1));
} break;
case "setMarkerLine": {
obj._setMarkerLine((int) function.params.get(0), (int) function.params.get(1));
} break;
case "removeBuffer": {
obj._removeBuffer((int) function.params.get(0));
} break;
case "renameBuffer": {
obj._renameBuffer((int) function.params.get(0), (String) function.params.get(1));
} break;
case "mergeBuffersPermanently": {
obj._mergeBuffersPermanently((int) function.params.get(0), (int) function.params.get(1));
} break;
case "markBufferAsRead": {
obj._markBufferAsRead((int) function.params.get(0));
} break;
case "update": {
InvokerHelper.update(obj, function.params.get(0));
} break;
}
}
}
/*
* 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.libquassel.syncables.types.invokers;
import android.support.annotation.NonNull;
import de.kuschku.libquassel.functions.types.SyncFunction;
import de.kuschku.libquassel.syncables.types.interfaces.QBufferViewConfig;
public class IBufferViewConfig implements Invoker<QBufferViewConfig> {
@NonNull
private static final IBufferViewConfig invoker = new IBufferViewConfig();
private IBufferViewConfig() {
}
@NonNull
public static IBufferViewConfig get() {
return invoker;
}
@Override
public void invoke(SyncFunction function, QBufferViewConfig obj) {
switch (function.methodName) {
case "setBufferViewName": {
obj._setBufferViewName((String) function.params.get(0));
} break;
case "setNetworkId": {
obj._setNetworkId((int) function.params.get(0));
} break;
case "setAddNewBuffersAutomatically": {
obj._setAddNewBuffersAutomatically((boolean) function.params.get(0));
} break;
case "setSortAlphabetically": {
obj._setSortAlphabetically((boolean) function.params.get(0));
} break;
case "setDisableDecoration": {
obj._setDisableDecoration((boolean) function.params.get(0));
} break;
case "setAllowedBufferTypes": {
obj._setAllowedBufferTypes((int) function.params.get(0));
} break;
case "setMinimumActivity": {
obj._setMinimumActivity((int) function.params.get(0));
} break;
case "setHideInactiveBuffers": {
obj._setHideInactiveBuffers((boolean) function.params.get(0));
} break;
case "setHideInactiveNetworks": {
obj._setHideInactiveNetworks((boolean) function.params.get(0));
} break;
case "addBuffer": {
obj._addBuffer((int) function.params.get(0), (int) function.params.get(1));
} break;
case "moveBuffer": {
obj._moveBuffer((int) function.params.get(0), (int) function.params.get(1));
} break;
case "removeBuffer": {
obj._removeBuffer((int) function.params.get(0));
} break;
case "removeBufferPermanently": {
obj._removeBufferPermanently((int) function.params.get(0));
} break;
case "update": {
InvokerHelper.update(obj, function.params.get(0));
} break;
}
}
}
/*
* 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.libquassel.syncables.types.invokers;
import android.support.annotation.NonNull;
import de.kuschku.libquassel.functions.types.SyncFunction;
import de.kuschku.libquassel.syncables.types.interfaces.QBufferViewManager;
public class IBufferViewManager implements Invoker<QBufferViewManager> {
@NonNull
private static final IBufferViewManager invoker = new IBufferViewManager();
private IBufferViewManager() {
}
@NonNull
public static IBufferViewManager get() {
return invoker;
}
@Override
public void invoke(SyncFunction function, QBufferViewManager obj) {
switch (function.methodName) {
case "addBufferViewConfig": {
obj._addBufferViewConfig((int) function.params.get(0));
} break;
case "deleteBufferViewConfig": {
obj._deleteBufferViewConfig((int) function.params.get(0));
} break;
case "update": {
InvokerHelper.update(obj, function.params.get(0));
} break;
}
}
}
......@@ -19,38 +19,34 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.kuschku.util.irc;
package de.kuschku.libquassel.syncables.types.invokers;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import java.util.Locale;
import de.kuschku.libquassel.functions.types.SyncFunction;
import de.kuschku.libquassel.syncables.types.interfaces.QCertManager;
import de.kuschku.util.backports.Objects;
public class IrcCaseMapper {
private IrcCaseMapper() {
public class ICertManager implements Invoker<QCertManager> {
@NonNull
private static final ICertManager invoker = new ICertManager();
private ICertManager() {
}
public static String toLowerCase(@NonNull String s) {
return s.toLowerCase(Locale.US)
.replaceAll("\\[", "{")
.replaceAll("\\]", "}")
.replaceAll("\\^", "~");
@NonNull
public static ICertManager get() {
return invoker;
}
public static String toUpperCase(@NonNull String s) {
return s.toUpperCase(Locale.US)
.replaceAll("\\{", "[")
.replaceAll("\\}", "]")
.replaceAll("~", "^");
}
@Override
public void invoke(SyncFunction function, QCertManager obj) {
switch (function.methodName) {
case "": {
public static boolean equalsIgnoreCase(@Nullable String a, @Nullable String b) {
if (a == null || b == null)
return (Objects.equals(a, b));
else
return toLowerCase(a).equals(toLowerCase(b)) || toUpperCase(a).equals(toUpperCase(b));
} break;
case "update": {
InvokerHelper.update(obj, function.params.get(0));
} break;
}
}
}
/*
* 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.libquassel.syncables.types.invokers;
import android.support.annotation.NonNull;
import java.util.Map;
import de.kuschku.libquassel.functions.types.SyncFunction;
import de.kuschku.libquassel.primitives.types.QVariant;
import de.kuschku.libquassel.syncables.types.interfaces.QCoreInfo;
public class ICoreInfo implements Invoker<QCoreInfo> {
@NonNull
private static final ICoreInfo invoker = new ICoreInfo();
private ICoreInfo() {
}
@NonNull
public static ICoreInfo get() {
return invoker;
}
@Override
public void invoke(SyncFunction function, QCoreInfo obj) {
switch (function.methodName) {
case "setCoreData": {
obj._setCoreData((Map<String, QVariant>) function.params.get(0));
} break;
case "update": {
InvokerHelper.update(obj, function.params.get(0));
} break;
}
}
}
/*
* 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.libquassel.syncables.types.invokers;
import android.support.annotation.NonNull;
import java.util.List;
import de.kuschku.libquassel.functions.types.SyncFunction;
import de.kuschku.libquassel.syncables.types.interfaces.QIdentity;
public class IIdentity implements Invoker<QIdentity> {
@NonNull
private static final IIdentity invoker = new IIdentity();
private IIdentity() {
}
@NonNull
public static IIdentity get() {
return invoker;
}
@Override
public void invoke(SyncFunction function, QIdentity obj) {
switch (function.methodName) {
case "setId": {
obj._setId((int) function.params.get(0));
} break;
case "setIdentityName": {
obj._setIdentityName((String) function.params.get(0));
} break;
case "setRealName": {
obj._setRealName((String) function.params.get(0));
} break;
case "setNicks": {
obj._setNicks((List<String>) function.params.get(0));
} break;
case "setAwayNick": {
obj._setAwayNick((String) function.params.get(0));
} break;
case "setAwayNickEnabled": {
obj._setAwayNickEnabled((boolean) function.params.get(0));
} break;
case "setAwayReason": {
obj._setAwayReason((String) function.params.get(0));
} break;
case "setAwayReasonEnabled": {
obj._setAwayReasonEnabled((boolean) function.params.get(0));
} break;
case "setAutoAwayEnabled": {
obj._setAutoAwayEnabled((boolean) function.params.get(0));
} break;
case "setAutoAwayTime": {
obj._setAutoAwayTime((int) function.params.get(0));
} break;
case "setAutoAwayReason": {
obj._setAutoAwayReason((String) function.params.get(0));
} break;
case "setAutoAwayReasonEnabled": {
obj._setAutoAwayReasonEnabled((boolean) function.params.get(0));
} break;
case "setDetachAwayEnabled": {
obj._setDetachAwayEnabled((boolean) function.params.get(0));
} break;
case "setDetachAwayReason": {
obj._setDetachAwayReason((String) function.params.get(0));
} break;
case "setDetachAwayReasonEnabled": {
obj._setDetachAwayReasonEnabled((boolean) function.params.get(0));
} break;
case "setIdent": {
obj._setIdent((String) function.params.get(0));
} break;
case "setKickReason": {
obj._setKickReason((String) function.params.get(0));
} break;
case "setPartReason": {
obj._setPartReason((String) function.params.get(0));
} break;
case "setQuitReason": {
obj._setQuitReason((String) function.params.get(0));
} break;
case "setSslKey": {
obj._setSslKey((String) function.params.get(0));
} break;
case "setSslCert": {
obj._setSslCert((String) function.params.get(0));
} break;
case "update": {
InvokerHelper.update(obj, function.params.get(0));
} break;
}
}
}
/*
* 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.libquassel.syncables.types.invokers;
import android.support.annotation.NonNull;
import de.kuschku.libquassel.functions.types.SyncFunction;
import de.kuschku.libquassel.syncables.types.interfaces.QIgnoreListManager;
public class IIgnoreListManager implements Invoker<QIgnoreListManager> {
@NonNull
private static final IIgnoreListManager invoker = new IIgnoreListManager();
private IIgnoreListManager() {
}
@NonNull
public static IIgnoreListManager get() {
return invoker;
}
public void invoke(SyncFunction function, QIgnoreListManager object) {
switch (function.methodName) {
case "removeIgnoreListItem": {
object._removeIgnoreListItem((String) function.params.get(0));
} break;
case "toggleIgnoreRule": {
object._toggleIgnoreRule((String) function.params.get(0));
} break;
case "addIgnoreListItem": {
object._addIgnoreListItem((int) function.params.get(0), (String) function.params.get(1), (boolean) function.params.get(2), (int) function.params.get(3), (int) function.params.get(4), (String) function.params.get(5), (boolean) function.params.get(6));
} break;
case "update": {
InvokerHelper.update(object, function.params.get(0));
} break;
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment