diff --git a/src/main/java/com/calclab/hablar/client/HablarGinjector.java b/src/main/java/com/calclab/hablar/client/HablarGinjector.java index 831e7a2c..01a282ee 100644 --- a/src/main/java/com/calclab/hablar/client/HablarGinjector.java +++ b/src/main/java/com/calclab/hablar/client/HablarGinjector.java @@ -1,8 +1,13 @@ package com.calclab.hablar.client; +import java.util.HashMap; + import com.calclab.emite.browser.client.BrowserModule; +import com.calclab.emite.core.client.LoginXmpp; +import com.calclab.emite.core.client.LoginXmppMap; import com.calclab.emite.core.client.conn.XmppConnection; import com.calclab.emite.core.client.xmpp.session.XmppSession; +import com.calclab.emite.im.client.ImComponents; import com.calclab.emite.im.client.chat.ChatManager; import com.calclab.emite.im.client.presence.PresenceManager; import com.calclab.emite.im.client.roster.SubscriptionHandler; @@ -45,5 +50,11 @@ public interface HablarGinjector extends Ginjector { SubscriptionHandler getSubscriptionHandler(); PrivateStorageManager getPrivateStorageManager(); + + @LoginXmppMap HashMap getLoginXmppMap(); + + LoginXmpp getLoginXmpp(); + ImComponents getImComponents(); + } diff --git a/src/main/java/com/calclab/hablar/core/client/container/main/MainLayout.java b/src/main/java/com/calclab/hablar/core/client/container/main/MainLayout.java index 1ff2f149..8f7e9d7e 100644 --- a/src/main/java/com/calclab/hablar/core/client/container/main/MainLayout.java +++ b/src/main/java/com/calclab/hablar/core/client/container/main/MainLayout.java @@ -8,9 +8,17 @@ import com.google.gwt.user.client.ui.Widget; public abstract class MainLayout { - private final Widget container; + private Widget container; public MainLayout(Widget container, HablarDisplay parent) { + initialize(container, parent); + } + + public MainLayout(){ + + } + + public void initialize(Widget container, HablarDisplay parent) { this.container = container; parent.add(container); parent.setWidgetLeftRight(container, 0, PX, 0, PX); diff --git a/src/main/java/com/calclab/hablar/core/client/pages/accordion/AccordionLayout.java b/src/main/java/com/calclab/hablar/core/client/pages/accordion/AccordionLayout.java index 2745e0bf..4b345ed3 100644 --- a/src/main/java/com/calclab/hablar/core/client/pages/accordion/AccordionLayout.java +++ b/src/main/java/com/calclab/hablar/core/client/pages/accordion/AccordionLayout.java @@ -8,10 +8,10 @@ public class AccordionLayout extends MainLayout { private static final double HEAD_SIZE = 24; - private static AccordionPanel accordion; + private AccordionPanel accordion = new AccordionPanel(); public AccordionLayout(HablarDisplay display) { - super(accordion = new AccordionPanel(), display); + initialize(accordion,display); } @Override diff --git a/src/main/java/com/calclab/hablar/core/client/pages/tabs/TabsLayout.java b/src/main/java/com/calclab/hablar/core/client/pages/tabs/TabsLayout.java index d17237da..db34c6cc 100644 --- a/src/main/java/com/calclab/hablar/core/client/pages/tabs/TabsLayout.java +++ b/src/main/java/com/calclab/hablar/core/client/pages/tabs/TabsLayout.java @@ -57,7 +57,7 @@ public String getWidth() { } private static final double BAR_SIZE = 24; - private static TabsPanel tabs; + private TabsPanel tabs = new TabsPanel(BAR_SIZE, PX); private final TabsMenuPresenter tabsMenuPresenter; @@ -68,7 +68,7 @@ public TabsLayout(final HablarDisplay parent) { } public TabsLayout(final HablarDisplay parent, final TabHeaderSize tabHeaderSize) { - super(tabs = new TabsPanel(BAR_SIZE, PX), parent); + initialize(tabs, parent); tabsMenuPresenter = new TabsMenuPresenter(tabs.getMenu()); this.tabHeaderSize = tabHeaderSize; } diff --git a/src/main/java/com/calclab/hablar/editbuddy/client/HablarEditBuddy.java b/src/main/java/com/calclab/hablar/editbuddy/client/HablarEditBuddy.java index ffddba0e..1ce03cac 100644 --- a/src/main/java/com/calclab/hablar/editbuddy/client/HablarEditBuddy.java +++ b/src/main/java/com/calclab/hablar/editbuddy/client/HablarEditBuddy.java @@ -1,7 +1,6 @@ package com.calclab.hablar.editbuddy.client; import java.util.List; - import com.calclab.emite.im.client.roster.XmppRoster; import com.calclab.hablar.core.client.Hablar; import com.calclab.hablar.core.client.container.overlay.OverlayContainer; @@ -13,6 +12,7 @@ import com.calclab.hablar.roster.client.groups.RosterItemPresenter; import com.calclab.hablar.roster.client.page.RosterPage; + /** * Adds the ability to edit a buddy in the roster */ @@ -29,6 +29,7 @@ public void execute(final RosterItemPresenter target) { } public HablarEditBuddy(final Hablar hablar, final XmppRoster roster) { + final EditBuddyPage editBuddy = new EditBuddyPage(roster, hablar.getEventBus(), new EditBuddyWidget()); hablar.addPage(editBuddy, OverlayContainer.ROL); final List> rosters = hablar.getPagesOfType(RosterPage.TYPE); diff --git a/src/main/java/com/calclab/hablar/html/client/HablarHtml.java b/src/main/java/com/calclab/hablar/html/client/HablarHtml.java index 1821bece..d54dbdce 100644 --- a/src/main/java/com/calclab/hablar/html/client/HablarHtml.java +++ b/src/main/java/com/calclab/hablar/html/client/HablarHtml.java @@ -1,9 +1,11 @@ package com.calclab.hablar.html.client; -import com.calclab.emite.core.client.xmpp.session.XmppSession; -import com.calclab.emite.im.client.chat.ChatManager; -import com.calclab.emite.im.client.roster.XmppRoster; -import com.calclab.emite.xep.muc.client.RoomManager; +import java.util.HashMap; +import java.util.logging.Logger; + +import com.calclab.emite.browser.client.PageAssist; +import com.calclab.emite.core.client.LoginXmpp; +import com.calclab.emite.im.client.ImComponents; import com.calclab.hablar.chat.client.HablarChat; import com.calclab.hablar.client.HablarConfig; import com.calclab.hablar.client.HablarGinjector; @@ -40,6 +42,9 @@ * embed it within another GWT application */ public class HablarHtml implements EntryPoint { + + private static final Logger logger = Logger.getLogger(HablarHtml.class.getName()); + private void addHablarToDiv(final HablarWidget hablar, final HtmlConfig htmlConfig) { setSize(hablar, htmlConfig); final RootPanel rootPanel = RootPanel.get(htmlConfig.inline); @@ -61,54 +66,64 @@ private DialogBox createDialog(final HablarWidget widget, final HtmlConfig htmlC @Override public void onModuleLoad() { + + final HtmlConfig htmlConfig = HtmlConfig.getFromMeta(); + String loginId=PageAssist.getMeta("emite.user"); + + if (loginId == null) { + logger.info("Trying to use the browser module outside of GWT apps without setting is not supported"); + } + + if (loginId != null) { final HablarGinjector ginjector = GWT.create(HablarGinjector.class); + ImComponents imComponents = ginjector.getImComponents(); + imComponents.setInstanceId(loginId); + // We will instantiate the BrowserFocusHandler singleton so that it // starts tracking focus events as soon as possible. BrowserFocusHandler.getInstance(); final HablarConfig config = HablarConfig.getFromMeta(); - final HtmlConfig htmlConfig = HtmlConfig.getFromMeta(); htmlConfig.hasLogger = true; final HablarWidget widget = new HablarWidget(config.layout, config.tabHeaderSize); final Hablar hablar = widget.getHablar(); - - final XmppSession session = ginjector.getXmppSession(); - final XmppRoster roster = ginjector.getXmppRoster(); - final ChatManager chatManager = ginjector.getChatManager(); - final RoomManager roomManager = ginjector.getRoomManager(); - + + //final HablarGinjector ginjector = GWT.create(HablarGinjector.class); + HashMap loginXmppMap = ginjector.getLoginXmppMap(); + LoginXmpp loginXmpp = loginXmppMap.get(loginId); + new HablarCore(hablar); - new HablarChat(hablar, config.chatConfig, roster, chatManager, ginjector.getStateManager()); - new HablarRooms(hablar, config.roomsConfig, session, roster, roomManager, ginjector.getRoomDiscoveryManager(), ginjector.getMUCChatStateManager()); - new HablarGroupChat(hablar, config.roomsConfig, session, roster, chatManager, roomManager); + new HablarChat(hablar, config.chatConfig, loginXmpp.xmppRoster, loginXmpp.chatManager, loginXmpp.stateManager); + new HablarRooms(hablar, config.roomsConfig, loginXmpp.xmppSession, loginXmpp.xmppRoster, loginXmpp.roomManager, loginXmpp.roomDiscoveryManager, loginXmpp.mucChatStateManager); + new HablarGroupChat(hablar, config.roomsConfig, loginXmpp.xmppSession, loginXmpp.xmppRoster, loginXmpp.chatManager, loginXmpp.roomManager); new HablarDock(hablar, config.dockConfig); - new HablarUser(hablar, session, ginjector.getPresenceManager(), ginjector.getPrivateStorageManager()); + new HablarUser(hablar, loginXmpp.xmppSession, loginXmpp.presenceManager, loginXmpp.privateStorageManager); RosterPage rosterPage = null; HablarRoster hablarRoster = null; if (config.hasRoster) { - hablarRoster = new HablarRoster(hablar, config.rosterConfig, session, roster, chatManager, ginjector.getSubscriptionHandler()); + hablarRoster = new HablarRoster(hablar, config.rosterConfig, loginXmpp.xmppSession, loginXmpp.xmppRoster, loginXmpp.chatManager, loginXmpp.subscriptionHandler); rosterPage = hablarRoster.getRosterPage(); } if (config.hasVCard) { - new HablarVCard(hablar, config.vcardConfig, session, roster, ginjector.getVCardManager()); + new HablarVCard(hablar, config.vcardConfig, loginXmpp.xmppSession, loginXmpp.xmppRoster, loginXmpp.vCardManager); } if (config.hasRoster) { - new HablarOpenChat(hablar, session, roster, chatManager); - new HablarEditBuddy(hablar, roster); - new HablarUserGroups(rosterPage, hablar, roster); - new HablarGroup(hablar, session, roster); + new HablarOpenChat(hablar, loginXmpp.xmppSession, loginXmpp.xmppRoster, loginXmpp.chatManager); + new HablarEditBuddy(hablar, loginXmpp.xmppRoster); + new HablarUserGroups(rosterPage, hablar, loginXmpp.xmppRoster); + new HablarGroup(hablar, loginXmpp.xmppSession, loginXmpp.xmppRoster); hablarRoster.addLowPriorityActions(); } if (config.hasSearch) { - new HablarSearch(hablar, config.searchConfig, session, roster, chatManager, ginjector.getSearchManager()); + new HablarSearch(hablar, config.searchConfig, loginXmpp.xmppSession, loginXmpp.xmppRoster, loginXmpp.chatManager, loginXmpp.searchManager); } if (config.hasSignals) { - new HablarSignals(hablar, session, ginjector.getPrivateStorageManager()); + new HablarSignals(hablar, loginXmpp.xmppSession, loginXmpp.privateStorageManager); } if (config.hasSound) { @@ -120,11 +135,11 @@ public void onModuleLoad() { } if (htmlConfig.hasLogger) { - new HablarConsole(hablar, ginjector.getXmppConnection(), session); + new HablarConsole(hablar, loginXmpp.xmppConnection, loginXmpp.xmppSession); } if (htmlConfig.hasLogin) { - new HablarLogin(hablar, LoginConfig.getFromMeta(), session); + new HablarLogin(hablar, LoginConfig.getFromMeta(), loginXmpp.xmppSession); } if (htmlConfig.inline == null) { @@ -132,6 +147,7 @@ public void onModuleLoad() { } else { addHablarToDiv(widget, htmlConfig); } + } } private void setSize(final Widget widget, final HtmlConfig htmlConfig) { diff --git a/src/main/java/com/calclab/hablar/html/client/HtmlConfig.java b/src/main/java/com/calclab/hablar/html/client/HtmlConfig.java index d0201718..80f417c4 100644 --- a/src/main/java/com/calclab/hablar/html/client/HtmlConfig.java +++ b/src/main/java/com/calclab/hablar/html/client/HtmlConfig.java @@ -4,12 +4,14 @@ public class HtmlConfig { - public static HtmlConfig getFromMeta() { + public static HtmlConfig getFromMeta() { final HtmlConfig config = new HtmlConfig(); config.hasLogin = PageAssist.isMetaTrue("hablar.login"); config.inline = PageAssist.getMeta("hablar.inline"); config.width = PageAssist.getMeta("hablar.width"); config.height = PageAssist.getMeta("hablar.height"); + + if (config.width == null) { config.width = "400px"; } @@ -19,6 +21,7 @@ public static HtmlConfig getFromMeta() { return config; } + /** * Width */ diff --git a/src/main/resources/com/calclab/hablar/html/HablarHtml.gwt.xml b/src/main/resources/com/calclab/hablar/html/HablarHtml.gwt.xml index dd83960c..d3e1b18e 100644 --- a/src/main/resources/com/calclab/hablar/html/HablarHtml.gwt.xml +++ b/src/main/resources/com/calclab/hablar/html/HablarHtml.gwt.xml @@ -5,6 +5,10 @@ + + + +