Skip to content

Commit

Permalink
fix #7
Browse files Browse the repository at this point in the history
webclient page is broken with OF 4.9.0
  • Loading branch information
deleolajide committed Oct 8, 2024
1 parent 23d09ab commit 9fa3cb0
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 24 deletions.
6 changes: 6 additions & 0 deletions changelog.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ <h1>
LLaMA Plugin Changelog
</h1>

<p><b>0.1.0</b> -- October 8, 2024</p>

<ul>
<li>Made compatible with Openfire 4.9.0</li>
</ul>

<p><b>0.0.2</b> -- Marck 31, 2024</p>

<ul>
Expand Down
2 changes: 1 addition & 1 deletion plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<version>${project.version}</version>
<licenseType>Apache 2.0</licenseType>
<date>2023-12-31</date>
<minServerVersion>4.6.0</minServerVersion>
<minServerVersion>4.8.0</minServerVersion>

<adminconsole>
<tab id="tab-webclients" name="${admin.sidebar.webclients.name}" description="${admin.sidebar.webclients.description}" url="llama-settings.jsp">
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
<parent>
<artifactId>plugins</artifactId>
<groupId>org.igniterealtime.openfire</groupId>
<version>4.7.5</version>
<version>4.9.0</version>
</parent>

<groupId>org.igniterealtime.openfire</groupId>
<artifactId>llama</artifactId>
<version>0.0.2-SNAPSHOT</version>
<version>0.1.0-SNAPSHOT</version>

<properties>
</properties>
Expand Down
2 changes: 1 addition & 1 deletion src/java/org/ifsoft/llama/openfire/LLaMA.java
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public static String getPort() {
}

public static String getModelPath() {
return (JiveGlobals.getHomeDirectory() + File.separator + "llama").replace("\\", "/");
return (JiveGlobals.getHomePath().resolve("llama").toString()).replace("\\", "/");
}

public static String getHostedUrl() {
Expand Down
40 changes: 21 additions & 19 deletions src/java/org/ifsoft/llama/openfire/LLaMAConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
import java.net.*;
import java.nio.charset.*;

import javax.annotation.Nullable;

import org.dom4j.Namespace;
import org.jivesoftware.openfire.*;
import org.jivesoftware.openfire.nio.OfflinePacketDeliverer;
Expand Down Expand Up @@ -88,7 +90,7 @@ public LLaMAConnection(String username, String remoteUrl) {

IQ iq = new IQ();
iq.setFrom(username + "@" + domain + "/" + remoteAddr);
iq.setTo(domain);
iq.setTo(username + "@" + domain);
iq.setType(IQ.Type.set);

Element child = iq.setChildElement("vCard", "vcard-temp");
Expand Down Expand Up @@ -150,7 +152,7 @@ public void run() {
if (reply != null) {
final String response = getJson("/completion", testData, null, null);
reply.setChildElement("response", "urn:xmpp:gen-ai:0").setText(response);
XMPPServer.getInstance().getRoutingTable().routePacket(reply.getTo(), reply, true);
XMPPServer.getInstance().getRoutingTable().routePacket(reply.getTo(), reply);
}
else {
getJson("/completion", testData, requestor, chatType);
Expand Down Expand Up @@ -178,11 +180,21 @@ public void route(String xml) {
public JID getJid() {
return session.getAddress();
}

@Override
public void closeVirtualConnection(@Nullable StreamError streamError) {
exec.shutdown();
}

@Override
public void closeVirtualConnection() {
exec.shutdown();
}
public Optional<String> getTLSProtocolName() {
return this.session != null ? Optional.of(this.session.getTLSProtocolName()) : Optional.of("unknown");
}

@Override
public Optional<String> getCipherSuiteName() {
return this.session != null ? Optional.of(this.session.getCipherSuiteName()) : Optional.of("unknown");
}

@Override
public byte[] getAddress() {
Expand Down Expand Up @@ -304,7 +316,7 @@ public void deliver(Packet packet) throws UnauthorizedException {
return;
}

XMPPServer.getInstance().getRoutingTable().routePacket(packet.getFrom(), reply, true);
XMPPServer.getInstance().getRoutingTable().routePacket(packet.getFrom(), reply);
}
}
}
Expand All @@ -314,16 +326,6 @@ public void deliverRawText(String text) {
Log.debug("deliverRawText\n" + text);
}

@Override
public boolean validate() {
return true;
}

@Override
public boolean isSecure() {
return false;
}

@Override
public PacketDeliverer getPacketDeliverer() {
if (backupDeliverer == null) {
Expand Down Expand Up @@ -448,7 +450,7 @@ private void replyState(String state, JID requestor, Message.Type chatType) {
newMessage.setType(chatType);
newMessage.addExtension(new PacketExtension(state, "http://jabber.org/protocol/chatstates"));

XMPPServer.getInstance().getRoutingTable().routePacket(requestor, newMessage, true);
XMPPServer.getInstance().getRoutingTable().routePacket(requestor, newMessage);
}

private void replyRtt(String msg, JID requestor, Message.Type chatType, long seq) {
Expand All @@ -467,7 +469,7 @@ private void replyRtt(String msg, JID requestor, Message.Type chatType, long seq
t.setText(msg);
newMessage.addExtension(new PacketExtension(rtt));

XMPPServer.getInstance().getRoutingTable().routePacket(requestor, newMessage, true);
XMPPServer.getInstance().getRoutingTable().routePacket(requestor, newMessage);
}

private void replyChat(String msg, JID requestor, Message.Type chatType) {
Expand All @@ -480,7 +482,7 @@ private void replyChat(String msg, JID requestor, Message.Type chatType) {
newMessage.setBody(msg);
newMessage.addExtension(new PacketExtension("active", "http://jabber.org/protocol/chatstates"));

XMPPServer.getInstance().getRoutingTable().routePacket(requestor, newMessage, true);
XMPPServer.getInstance().getRoutingTable().routePacket(requestor, newMessage);
}

private boolean isNull(String value) {
Expand Down
2 changes: 1 addition & 1 deletion src/web/llama-chat.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
<meta name="pageID" content="llama-chat"/>
<style type="text/css">
#jive-main table, #jive-main-content {
height: 92%;
height: 600px;
}
</style>
</head>
Expand Down

0 comments on commit 9fa3cb0

Please sign in to comment.