From c17cb44eaa92eebf887e121e5a7b41d36b47dcb0 Mon Sep 17 00:00:00 2001 From: clienthax Date: Sat, 21 Aug 2021 17:02:18 +0100 Subject: [PATCH] Fixup commands/supplemental changes. --- .../cutthecord/commands/commands/CmdCtc.java | 19 ++- resources/patches/supplemental/87202.patch | 137 ++++++++++-------- 2 files changed, 90 insertions(+), 66 deletions(-) diff --git a/resources/patches/slashcommands/code/src/main/java/com/cutthecord/commands/commands/CmdCtc.java b/resources/patches/slashcommands/code/src/main/java/com/cutthecord/commands/commands/CmdCtc.java index 9ad3002..24066b3 100644 --- a/resources/patches/slashcommands/code/src/main/java/com/cutthecord/commands/commands/CmdCtc.java +++ b/resources/patches/slashcommands/code/src/main/java/com/cutthecord/commands/commands/CmdCtc.java @@ -19,11 +19,24 @@ public class CmdCtc { public String processEnableDisable(boolean enabled) { try { //noinspection JavaReflectionMemberAccess - final Method m = StoreStream.getUserSettings().getClass().getDeclaredMethod("setLeakChannels", Boolean.class); + final Method m = StoreStream.getUserSettings().getClass().getDeclaredMethod("setLeakChannels", boolean.class); m.invoke(StoreStream.getUserSettings(), enabled); } catch (Exception e) { System.out.println("Failed to call StoreStream.getUserSettings().setLeakChannels"); + + System.out.println("Declared"); + for (Method m : StoreStream.getUserSettings().getClass().getDeclaredMethods()) { + System.out.println(m.getName()+" "+ m.toString()); + } + + System.out.println(); + System.out.println("Methods"); + for (Method m : StoreStream.getUserSettings().getClass().getMethods()) { + System.out.println(m.getName()+" "+ m.toString()); + } + e.printStackTrace(); + return "Failed to call StoreStream.getUserSettings().setLeakChannels"; } return "CTC: Successfully set channelleak state."; // TODO use notification } @@ -37,7 +50,7 @@ public class CmdCtc { try { //noinspection JavaReflectionMemberAccess - final Method m = StoreStream.getUserSettings().getClass().getDeclaredMethod("setShowTyping", Boolean.class); + final Method m = StoreStream.getUserSettings().getClass().getDeclaredMethod("setShowTyping", boolean.class); m.invoke(StoreStream.getUserSettings(), enabled); } catch (Exception e) { System.out.println("Failed to call StoreStream.getUserSettings().setShowTyping"); @@ -56,7 +69,7 @@ public class CmdCtc { try { //noinspection JavaReflectionMemberAccess - final Method m = StoreStream.getUserSettings().getClass().getDeclaredMethod("setNoDelete", Boolean.class); + final Method m = StoreStream.getUserSettings().getClass().getDeclaredMethod("setNoDelete", boolean.class); m.invoke(StoreStream.getUserSettings(), enabled); } catch (Exception e) { System.out.println("Failed to call StoreStream.getUserSettings().setNoDelete"); diff --git a/resources/patches/supplemental/87202.patch b/resources/patches/supplemental/87202.patch index ec54853..9a4e77e 100644 --- a/resources/patches/supplemental/87202.patch +++ b/resources/patches/supplemental/87202.patch @@ -21,77 +21,65 @@ diff -crB from/smali/com/discord/gateway/io/IncomingParser.smali to/smali/com/di new-instance v0, Lcom/discord/models/domain/ModelMessageDelete; invoke-direct {v0}, Lcom/discord/models/domain/ModelMessageDelete;->()V -diff -crB from/smali/com/discord/models/domain/ModelChannel.smali to/smali/com/discord/models/domain/ModelChannel.smali +diff -crB from/smali/com/discord/api/channel/Channel.smali to/smali/com/discord/api/channel/Channel.smali *** from/smali/com/discord/api/channel/Channel.smali 2021-08-10 20:23:56.976468100 +0100 --- to/smali/com/discord/api/channel/Channel.smali 2021-08-11 17:13:48.876902500 +0100 *************** -*** 1774,1779 **** ---- 1774,1789 ---- +*** 1774,1783 **** } .end annotation -+ invoke-static {}, Lcom/discord/stores/StoreStream;->getUserSettings()Lcom/discord/stores/StoreUserSettings; +! .line 1 +! iget-object v0, p0, Lcom/discord/api/channel/Channel;->permissionOverwrites:Ljava/util/List; + + return-object v0 + .end method + + .method public final t()I +--- 1774,1800 ---- + } + .end annotation + +! invoke-static {}, Lcom/discord/stores/StoreStream;->getUserSettings()Lcom/discord/stores/StoreUserSettings; +! +! move-result-object v0 +! +! invoke-virtual {v0}, Lcom/discord/stores/StoreUserSettings;->getLeakChannels()Z +! +! move-result v0 +! +! if-eqz v0, :cond_0 + ++ invoke-static {}, Ljava/util/Collections;->emptyList()Ljava/util/List; + + move-result-object v0 + -+ invoke-virtual {v0}, Lcom/discord/stores/StoreUserSettings;->getLeakChannels()Z ++ :goto_0 + return-object v0 + -+ move-result v0 ++ :cond_0 ++ iget-object v0, p0, Lcom/discord/api/channel/Channel;->permissionOverwrites:Ljava/util/List; + -+ if-eqz v0, :cond_0 -+ - .line 1 - iget-object v0, p0, Lcom/discord/api/channel/Channel;->permissionOverwrites:Ljava/util/List; ++ goto :goto_0 + .end method + .method public final t()I diff -crB from/smali/com/discord/stores/StoreUserSettings.smali to/smali/com/discord/stores/StoreUserSettings.smali *** from/smali/com/discord/stores/StoreUserSettings.smali 2020-11-16 13:22:49.513198310 +0000 --- to/smali/com/discord/stores/StoreUserSettings.smali 2020-11-16 13:57:09.234000134 +0000 *************** *** 2899,2904 **** ---- 2899,3188 ---- +--- 2899,3178 ---- return-void .end method -+ .method public getAutoplayGifs()Z -+ .locals 3 -+ -+ iget-object v0, p0, Lcom/discord/stores/StoreUserSettings;->prefs:Landroid/content/SharedPreferences; -+ -+ const-string v1, "CACHE_KEY_CTC_AUTOPLAY_GIFS" -+ -+ const/4 v2, 0x1 -+ -+ invoke-interface {v0, v1, v2}, Landroid/content/SharedPreferences;->getBoolean(Ljava/lang/String;Z)Z -+ -+ move-result v0 -+ -+ return v0 -+ .end method -+ -+ .method public setAutoplayGifs(Z)V -+ .locals 2 -+ -+ iget-object v0, p0, Lcom/discord/stores/StoreUserSettings;->prefs:Landroid/content/SharedPreferences; -+ -+ invoke-interface {v0}, Landroid/content/SharedPreferences;->edit()Landroid/content/SharedPreferences$Editor; -+ -+ move-result-object v0 -+ -+ const-string v1, "CACHE_KEY_CTC_AUTOPLAY_GIFS" -+ -+ invoke-interface {v0, v1, p1}, Landroid/content/SharedPreferences$Editor;->putBoolean(Ljava/lang/String;Z)Landroid/content/SharedPreferences$Editor; -+ -+ move-result-object p1 -+ -+ invoke-interface {p1}, Landroid/content/SharedPreferences$Editor;->apply()V -+ -+ return-void -+ .end method -+ + .method public getLeakChannels()Z + .locals 3 + -+ iget-object v0, p0, Lcom/discord/stores/StoreUserSettings;->prefs:Landroid/content/SharedPreferences; ++ .line 1 ++ invoke-virtual {p0}, Lcom/discord/stores/Store;->getPrefs()Landroid/content/SharedPreferences; ++ ++ move-result-object v0 + + const-string v1, "CACHE_KEY_CTC_LEAK_CHANNELS" + @@ -107,7 +95,9 @@ diff -crB from/smali/com/discord/stores/StoreUserSettings.smali to/smali/com/dis + .method public setLeakChannels(Z)V + .locals 2 + -+ iget-object v0, p0, Lcom/discord/stores/StoreUserSettings;->prefs:Landroid/content/SharedPreferences; ++ invoke-virtual {p0}, Lcom/discord/stores/Store;->getPrefs()Landroid/content/SharedPreferences; ++ ++ move-result-object v0 + + invoke-interface {v0}, Landroid/content/SharedPreferences;->edit()Landroid/content/SharedPreferences$Editor; + @@ -127,11 +117,14 @@ diff -crB from/smali/com/discord/stores/StoreUserSettings.smali to/smali/com/dis + .method public getImageSpoiler()Z + .locals 3 + -+ iget-object v0, p0, Lcom/discord/stores/StoreUserSettings;->prefs:Landroid/content/SharedPreferences; ++ .line 1 ++ invoke-virtual {p0}, Lcom/discord/stores/Store;->getPrefs()Landroid/content/SharedPreferences; ++ ++ move-result-object v0 + + const-string v1, "CACHE_KEY_CTC_IMAGE_SPOILER" + -+ const/4 v2, 0x0 ++ const/4 v2, 0x1 + + invoke-interface {v0, v1, v2}, Landroid/content/SharedPreferences;->getBoolean(Ljava/lang/String;Z)Z + @@ -143,7 +136,9 @@ diff -crB from/smali/com/discord/stores/StoreUserSettings.smali to/smali/com/dis + .method public setImageSpoiler(Z)V + .locals 2 + -+ iget-object v0, p0, Lcom/discord/stores/StoreUserSettings;->prefs:Landroid/content/SharedPreferences; ++ invoke-virtual {p0}, Lcom/discord/stores/Store;->getPrefs()Landroid/content/SharedPreferences; ++ ++ move-result-object v0 + + invoke-interface {v0}, Landroid/content/SharedPreferences;->edit()Landroid/content/SharedPreferences$Editor; + @@ -160,15 +155,17 @@ diff -crB from/smali/com/discord/stores/StoreUserSettings.smali to/smali/com/dis + return-void + .end method + -+ + .method public getNoDelete()Z + .locals 3 + -+ iget-object v0, p0, Lcom/discord/stores/StoreUserSettings;->prefs:Landroid/content/SharedPreferences; ++ .line 1 ++ invoke-virtual {p0}, Lcom/discord/stores/Store;->getPrefs()Landroid/content/SharedPreferences; ++ ++ move-result-object v0 + + const-string v1, "CACHE_KEY_CTC_NO_DELETE" + -+ const/4 v2, 0x0 ++ const/4 v2, 0x1 + + invoke-interface {v0, v1, v2}, Landroid/content/SharedPreferences;->getBoolean(Ljava/lang/String;Z)Z + @@ -180,7 +177,9 @@ diff -crB from/smali/com/discord/stores/StoreUserSettings.smali to/smali/com/dis + .method public setNoDelete(Z)V + .locals 2 + -+ iget-object v0, p0, Lcom/discord/stores/StoreUserSettings;->prefs:Landroid/content/SharedPreferences; ++ invoke-virtual {p0}, Lcom/discord/stores/Store;->getPrefs()Landroid/content/SharedPreferences; ++ ++ move-result-object v0 + + invoke-interface {v0}, Landroid/content/SharedPreferences;->edit()Landroid/content/SharedPreferences$Editor; + @@ -200,7 +199,10 @@ diff -crB from/smali/com/discord/stores/StoreUserSettings.smali to/smali/com/dis + .method public getShowTyping()Z + .locals 3 + -+ iget-object v0, p0, Lcom/discord/stores/StoreUserSettings;->prefs:Landroid/content/SharedPreferences; ++ .line 1 ++ invoke-virtual {p0}, Lcom/discord/stores/Store;->getPrefs()Landroid/content/SharedPreferences; ++ ++ move-result-object v0 + + const-string v1, "CACHE_KEY_CTC_SHOW_TYPING" + @@ -216,7 +218,9 @@ diff -crB from/smali/com/discord/stores/StoreUserSettings.smali to/smali/com/dis + .method public setShowTyping(Z)V + .locals 2 + -+ iget-object v0, p0, Lcom/discord/stores/StoreUserSettings;->prefs:Landroid/content/SharedPreferences; ++ invoke-virtual {p0}, Lcom/discord/stores/Store;->getPrefs()Landroid/content/SharedPreferences; ++ ++ move-result-object v0 + + invoke-interface {v0}, Landroid/content/SharedPreferences;->edit()Landroid/content/SharedPreferences$Editor; + @@ -233,11 +237,12 @@ diff -crB from/smali/com/discord/stores/StoreUserSettings.smali to/smali/com/dis + return-void + .end method + -+ + .method public getStoredToken()Ljava/lang/String; + .locals 3 + -+ iget-object v0, p0, Lcom/discord/stores/StoreAuthentication;->prefs:Landroid/content/SharedPreferences; ++ invoke-virtual {p0}, Lcom/discord/stores/Store;->getPrefs()Landroid/content/SharedPreferences; ++ ++ move-result-object v0 + + const-string v1, "none" + @@ -254,7 +259,9 @@ diff -crB from/smali/com/discord/stores/StoreUserSettings.smali to/smali/com/dis + .method public setStoredToken(Ljava/lang/String;)V + .locals 2 + -+ iget-object v0, p0, Lcom/discord/stores/StoreAuthentication;->prefs:Landroid/content/SharedPreferences; ++ invoke-virtual {p0}, Lcom/discord/stores/Store;->getPrefs()Landroid/content/SharedPreferences; ++ ++ move-result-object v0 + + invoke-interface {v0}, Landroid/content/SharedPreferences;->edit()Landroid/content/SharedPreferences$Editor; + @@ -290,7 +297,9 @@ diff -crB from/smali/com/discord/stores/StoreUserSettings.smali to/smali/com/dis + + move-result-object v2 + -+ iget-object v0, p0, Lcom/discord/stores/StoreAuthentication;->prefs:Landroid/content/SharedPreferences; ++ invoke-virtual {p0}, Lcom/discord/stores/Store;->getPrefs()Landroid/content/SharedPreferences; ++ ++ move-result-object v0 + + const-string v1, "none" + @@ -321,7 +330,9 @@ diff -crB from/smali/com/discord/stores/StoreUserSettings.smali to/smali/com/dis + + move-result-object v1 + -+ iget-object v0, p0, Lcom/discord/stores/StoreAuthentication;->prefs:Landroid/content/SharedPreferences; ++ invoke-virtual {p0}, Lcom/discord/stores/Store;->getPrefs()Landroid/content/SharedPreferences; ++ ++ move-result-object v0 + + invoke-interface {v0}, Landroid/content/SharedPreferences;->edit()Landroid/content/SharedPreferences$Editor; +