Skip to content

Commit

Permalink
Got rid of WebAdminGateway, setup webgateway for chat users over the web
Browse files Browse the repository at this point in the history
  • Loading branch information
xitiomet committed Nov 8, 2009
1 parent 52a8575 commit 9a2eee2
Show file tree
Hide file tree
Showing 7 changed files with 218 additions and 111 deletions.
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ build/org/openstatic/irc/gateways/IrcGateway.class: src/org/openstatic/irc/gatew
build/org/openstatic/irc/gateways/IrcGatewayConnection.class: src/org/openstatic/irc/gateways/IrcGatewayConnection.java
$(JC) $(JC_FLAGS) --classpath=$(CLASS_PATH) -C $<

build/org/openstatic/irc/gateways/WebAdminGateway.class: src/org/openstatic/irc/gateways/WebAdminGateway.java
build/org/openstatic/irc/gateways/WebGateway.class: src/org/openstatic/irc/gateways/WebGateway.java
$(JC) $(JC_FLAGS) --classpath=$(CLASS_PATH) -C $<

build/org/openstatic/irc/gateways/WebAdminGatewayConnection.class: src/org/openstatic/irc/gateways/WebAdminGatewayConnection.java
build/org/openstatic/irc/gateways/WebGatewayConnection.class: src/org/openstatic/irc/gateways/WebGatewayConnection.java
$(JC) $(JC_FLAGS) --classpath=$(CLASS_PATH) -C $<

build/org/openstatic/irc/middleware/DefaultMiddlewareHandler.class: src/org/openstatic/irc/middleware/DefaultMiddlewareHandler.java
Expand All @@ -82,7 +82,7 @@ build/org/openstatic/irc/middleware/JsonHttpCH.class: src/org/openstatic/irc/mid
# Main Builds
# -------------------------------------------------------------------------------

osircd.jar: build/org/openstatic/irc/IrcServer.class build/org/openstatic/irc/IRCMessage.class build/org/openstatic/irc/IrcUser.class build/org/openstatic/irc/IrcChannel.class build/org/openstatic/irc/MiddlewareHandler.class build/org/openstatic/irc/middleware/DefaultMiddlewareHandler.class build/org/openstatic/irc/middleware/StreamMiddlewareHandler.class build/org/openstatic/irc/middleware/JsonHttpCH.class build/org/openstatic/irc/GatewayConnection.class build/org/openstatic/irc/Gateway.class build/org/openstatic/irc/gateways/IrcGatewayConnection.class build/org/openstatic/irc/gateways/IrcGateway.class build/org/openstatic/irc/gateways/WebAdminGatewayConnection.class build/org/openstatic/irc/gateways/WebAdminGateway.class build/org/openstatic/irc/middleware/TwitterMiddlewareHandler.class build/org/openstatic/irc/middleware/StreamingJsonMiddlewareHandler.class build/org/openstatic/Base64Coder.class build/IrcServerBase.class
osircd.jar: build/org/openstatic/irc/IrcServer.class build/org/openstatic/irc/IRCMessage.class build/org/openstatic/irc/IrcUser.class build/org/openstatic/irc/IrcChannel.class build/org/openstatic/irc/MiddlewareHandler.class build/org/openstatic/irc/middleware/DefaultMiddlewareHandler.class build/org/openstatic/irc/middleware/StreamMiddlewareHandler.class build/org/openstatic/irc/middleware/JsonHttpCH.class build/org/openstatic/irc/GatewayConnection.class build/org/openstatic/irc/Gateway.class build/org/openstatic/irc/gateways/IrcGatewayConnection.class build/org/openstatic/irc/gateways/IrcGateway.class build/org/openstatic/irc/gateways/WebGatewayConnection.class build/org/openstatic/irc/gateways/WebGateway.class build/org/openstatic/irc/middleware/TwitterMiddlewareHandler.class build/org/openstatic/irc/middleware/StreamingJsonMiddlewareHandler.class build/org/openstatic/Base64Coder.class build/IrcServerBase.class
$(JAR) -cvmf res/manifest.mf $@ -C build org -C build IrcServerBase.class

clean:
Expand Down
4 changes: 2 additions & 2 deletions src/IrcServerBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import org.openstatic.irc.IrcChannel;
import org.openstatic.irc.IRCMessage;
import org.openstatic.irc.gateways.IrcGateway;
import org.openstatic.irc.gateways.WebAdminGateway;
import org.openstatic.irc.gateways.WebGateway;
import java.io.File;
import java.io.InputStreamReader;
import java.io.FileInputStream;
Expand Down Expand Up @@ -139,7 +139,7 @@ public static void main(String[] args) throws Exception
try
{
int web_port = Integer.valueOf(arg_p1).intValue();
irc.addGateway(new WebAdminGateway(web_port));
irc.addGateway(new WebGateway(web_port));
} catch (Exception wa) {}
}

Expand Down
16 changes: 16 additions & 0 deletions src/org/openstatic/irc/IRCMessage.java
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,22 @@ public int argCount()
return this.args.size();
}

public String getSourceNick()
{
if (this.source != null)
{
int n = this.source.indexOf("!");
if (n > -1)
{
return this.source.substring(0, n);
} else {
return this.source;
}
} else {
return "Unknown";
}
}

public JSONObject toJSONObject()
{
JSONObject job = new JSONObject();
Expand Down
5 changes: 4 additions & 1 deletion src/org/openstatic/irc/IrcUser.java
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,10 @@ public void onGatewayCommand(IRCMessage cmd)
sendResponse("323", ":End of List");

} else if (cmd.is("PRIVMSG") || cmd.is("NOTICE")) {
if (cmd.getArg(0).startsWith("#") || cmd.getArg(0).startsWith("&") || cmd.getArg(0).startsWith("!") || cmd.getArg(0).startsWith("+"))
if (cmd.getArg(0).startsWith("$"))
{
// todo
} else if (cmd.getArg(0).startsWith("#") || cmd.getArg(0).startsWith("&") || cmd.getArg(0).startsWith("!") || cmd.getArg(0).startsWith("+")) {
IrcChannel possible_target = this.server.findChannel(cmd.getArg(0));
if (possible_target != null)
{
Expand Down Expand Up @@ -405,6 +407,7 @@ public void loginUser(String username, String password)
this.username = username;
this.nickname = username;
this.password = password;
this.welcomed = true;

}

Expand Down
99 changes: 0 additions & 99 deletions src/org/openstatic/irc/gateways/WebAdminGatewayConnection.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
import org.openstatic.http.PlaceboHttpServer;
import org.openstatic.http.PlaceboSession;

public class WebAdminGateway extends Thread implements Gateway
public class WebGateway extends Thread implements Gateway
{
private int port;
private boolean keep_running;
private IrcServer ircServer;
private PlaceboHttpServer httpServer;

public WebAdminGateway(int port)
public WebGateway(int port)
{
this.port = port;
this.ircServer = null;
Expand All @@ -26,7 +26,7 @@ public boolean initGateway(IrcServer ircServer)
{
this.keep_running = true;
this.start();
this.ircServer.log("PORT: " + String.valueOf(this.port), 1, "WebAdmin Gateway Startup!");
this.ircServer.log("PORT: " + String.valueOf(this.port), 1, "WebGateway Startup!");
return true;
} else {
return false;
Expand Down Expand Up @@ -57,15 +57,15 @@ public void run()
try
{
PlaceboSession new_connection = httpServer.getNextSession();
WebAdminGatewayConnection wagc = new WebAdminGatewayConnection(new_connection, this.ircServer);
WebGatewayConnection wagc = new WebGatewayConnection(new_connection, this.ircServer);
wagc.start();
} catch (Exception x) {}
}
ircServer.log("PORT: " + String.valueOf(this.port), 1, "WebAdmin Gateway Shutdown");
ircServer.log("PORT: " + String.valueOf(this.port), 1, "WebGateway Shutdown");
}

public String toString()
{
return "WebAdminGateway @ " + String.valueOf(this.port);
return "WebGateway @ " + String.valueOf(this.port);
}
}
Loading

0 comments on commit 9a2eee2

Please sign in to comment.