From 4fb570565dae0e607bdb9606db1e2d59e22536e7 Mon Sep 17 00:00:00 2001 From: FelixSFD Date: Wed, 25 Jul 2018 17:54:55 +0200 Subject: [PATCH 1/3] #6: + added StackExchangeClient.getCookies() --- .../sobotics/chatexchange/chat/StackExchangeClient.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main/java/org/sobotics/chatexchange/chat/StackExchangeClient.java b/src/main/java/org/sobotics/chatexchange/chat/StackExchangeClient.java index 56563d0..c5a8e79 100644 --- a/src/main/java/org/sobotics/chatexchange/chat/StackExchangeClient.java +++ b/src/main/java/org/sobotics/chatexchange/chat/StackExchangeClient.java @@ -246,6 +246,14 @@ public boolean getAutoCreateAccount() { public void setAutoCreateAccount(boolean autoCreateAccount) { this.autoCreateAccount = autoCreateAccount; } + + /** + * Returns the cookies the library uses + * @return Cookies + */ + public Map getCookies() { + return this.cookies; + } /** * Closes this client by making the logged-in user leave all the chat rooms they joined. From 6fe1bcf17d07644ce10e181b9dc791010be14e1c Mon Sep 17 00:00:00 2001 From: FelixSFD Date: Wed, 25 Jul 2018 18:42:29 +0200 Subject: [PATCH 2/3] #6: + get cookies per room or host --- .../sobotics/chatexchange/chat/ChatHost.java | 12 ++++++++++++ .../org/sobotics/chatexchange/chat/Room.java | 8 ++++++++ .../chatexchange/chat/StackExchangeClient.java | 18 ++++++++++++++---- 3 files changed, 34 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/sobotics/chatexchange/chat/ChatHost.java b/src/main/java/org/sobotics/chatexchange/chat/ChatHost.java index d7b40fb..9252855 100644 --- a/src/main/java/org/sobotics/chatexchange/chat/ChatHost.java +++ b/src/main/java/org/sobotics/chatexchange/chat/ChatHost.java @@ -31,5 +31,17 @@ public String getName() { public String getBaseUrl() { return baseUrl; } + + /** + * Compares the host to another object + * @param otherHost other object + * @return true, if the name is the same + */ + public boolean equals(ChatHost otherHost) { + if (otherHost == null) + return false; + + return this.name.equals(otherHost.name); + } } diff --git a/src/main/java/org/sobotics/chatexchange/chat/Room.java b/src/main/java/org/sobotics/chatexchange/chat/Room.java index ea5420d..4cc262d 100644 --- a/src/main/java/org/sobotics/chatexchange/chat/Room.java +++ b/src/main/java/org/sobotics/chatexchange/chat/Room.java @@ -618,6 +618,14 @@ public RoomThumbs getThumbs() { public ChatHost getHost() { return host; } + + /** + * Returns the cookies used to post in this room + * @return cookies as Map + */ + public Map getCookies() { + return this.cookies; + } void close() { executor.shutdown(); diff --git a/src/main/java/org/sobotics/chatexchange/chat/StackExchangeClient.java b/src/main/java/org/sobotics/chatexchange/chat/StackExchangeClient.java index c5a8e79..ef9cf97 100644 --- a/src/main/java/org/sobotics/chatexchange/chat/StackExchangeClient.java +++ b/src/main/java/org/sobotics/chatexchange/chat/StackExchangeClient.java @@ -247,12 +247,22 @@ public void setAutoCreateAccount(boolean autoCreateAccount) { this.autoCreateAccount = autoCreateAccount; } + /** - * Returns the cookies the library uses - * @return Cookies + * Returns the cookies for the first room with the given host + * @param host {@link ChatHost} to search for + * @return null, if no room with the given {@link ChatHost} was found */ - public Map getCookies() { - return this.cookies; + public Map getCookies(ChatHost host) { + for (Room room : this.rooms) { + ChatHost roomHost = room.getHost(); + + if (host.equals(roomHost)) { + return room.getCookies(); + } + } + + return null; } /** From 34d163c873889752244caad2cc321d01de73d3fd Mon Sep 17 00:00:00 2001 From: Felix Date: Thu, 26 Jul 2018 17:42:44 +0200 Subject: [PATCH 3/3] Update .travis.yml --- .travis.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.travis.yml b/.travis.yml index b10f852..53b8e62 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,6 +15,14 @@ deploy: repo: SOBotics/chatexchange branch: master jdk: oraclejdk8 + - + provider: script + script: .travis/deploy.sh + skip_cleanup: true + on: + repo: SOBotics/chatexchange + branch: develop + jdk: oraclejdk8 - provider: script script: .travis/deploy.sh