diff --git a/src/main/NGECore.java b/src/main/NGECore.java index 145ef6e7..799e84bd 100644 --- a/src/main/NGECore.java +++ b/src/main/NGECore.java @@ -65,6 +65,7 @@ import services.DevService; import services.EntertainmentService; import services.GroupService; import services.housing.HousingService; +import services.BrowserService; import services.InstanceService; import services.LoginService; import services.LootService; @@ -204,6 +205,7 @@ public class NGECore { public PlayerCityService playerCityService; public ReverseEngineeringService reverseEngineeringService; public PetService petService; + public BrowserService browserService; // Login Server public NetworkDispatch loginDispatch; @@ -531,6 +533,8 @@ public class NGECore { playerCityService.loadCities(); retroService.run(); + browserService = new BrowserService(this); + didServerCrash = false; System.out.println("Started Server."); cleanupCreatureODB(); diff --git a/src/protocol/swg/LaunchBrowserMessage.java b/src/protocol/swg/LaunchBrowserMessage.java new file mode 100644 index 00000000..7c3efb62 --- /dev/null +++ b/src/protocol/swg/LaunchBrowserMessage.java @@ -0,0 +1,59 @@ +/******************************************************************************* + * Copyright (c) 2013 + * + * This File is part of NGECore2. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Using NGEngine to work with NGECore2 is making a combined work based on NGEngine. + * Therefore all terms and conditions of the GNU Lesser General Public License cover the combination. + ******************************************************************************/ +package protocol.swg; + +import java.nio.ByteOrder; +import java.util.Vector; + +import org.apache.mina.core.buffer.IoBuffer; + +import resources.common.Opcodes; +import services.sui.SUIWindowComponent; + +public class LaunchBrowserMessage extends SWGMessage{ + private String URL; + + public LaunchBrowserMessage(String URL) { + this.URL = URL; + } + + public void deserialize(IoBuffer data) { + + } + + public IoBuffer serialize() { + + IoBuffer result = IoBuffer.allocate(100).order(ByteOrder.LITTLE_ENDIAN); + result.setAutoExpand(true); + + result.putShort((short) 2); + result.putInt(Opcodes.LaunchBrowserMessage); + + result.put(getAsciiString(URL)); + + int size = result.position(); + result = IoBuffer.allocate(size).put(result.array(), 0, size); + + return result.flip(); + } + +} diff --git a/src/resources/common/Opcodes.java b/src/resources/common/Opcodes.java index c7bced7c..baf83745 100644 --- a/src/resources/common/Opcodes.java +++ b/src/resources/common/Opcodes.java @@ -90,5 +90,6 @@ public class Opcodes { public static final int CancelLiveAuctionMessage = CRC.StringtoCRC("CancelLiveAuctionMessage"); public static final int BidAuctionMessage = CRC.StringtoCRC("BidAuctionMessage"); public static final int RetrieveAuctionItemMessage = CRC.StringtoCRC("RetrieveAuctionItemMessage"); + public static final int LaunchBrowserMessage = CRC.StringtoCRC("LaunchBrowserMessage"); } diff --git a/src/services/BrowserService.java b/src/services/BrowserService.java new file mode 100644 index 00000000..bb0b156a --- /dev/null +++ b/src/services/BrowserService.java @@ -0,0 +1,60 @@ +/******************************************************************************* + * Copyright (c) 2013 + * + * This File is part of NGECore2. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Using NGEngine to work with NGECore2 is making a combined work based on NGEngine. + * Therefore all terms and conditions of the GNU Lesser General Public License cover the combination. + ******************************************************************************/ +package services; + +import java.util.Map; + +import protocol.swg.LaunchBrowserMessage; +import resources.objects.creature.CreatureObject; +import main.NGECore; +import engine.resources.service.INetworkDispatch; +import engine.resources.service.INetworkRemoteEvent; + +public class BrowserService implements INetworkDispatch { + + private NGECore core; + + public BrowserService(NGECore core) { + this.core = core; + } + + public void sendBrowserWindow(CreatureObject creature, String URL) { + URL = URL.toLowerCase(); + + if( URL.contains("http://")) + URL.replace("http://", ""); + + LaunchBrowserMessage launchBrowserMessage = new LaunchBrowserMessage(URL); + creature.getClient().getSession().write(launchBrowserMessage.serialize()); + } + + @Override + public void insertOpcodes(Map arg0, Map arg1) { + + } + + @Override + public void shutdown() { + + } + +}