Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

These are the Hablar changes to enable Multisessions #22

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
11 changes: 11 additions & 0 deletions src/main/java/com/calclab/hablar/client/HablarGinjector.java
Original file line number Diff line number Diff line change
@@ -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 <String, LoginXmpp> getLoginXmppMap();

LoginXmpp getLoginXmpp();

ImComponents getImComponents();

}
Original file line number Diff line number Diff line change
@@ -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);
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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;
}
Original file line number Diff line number Diff line change
@@ -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<Page<?>> rosters = hablar.getPagesOfType(RosterPage.TYPE);
66 changes: 41 additions & 25 deletions src/main/java/com/calclab/hablar/html/client/HablarHtml.java
Original file line number Diff line number Diff line change
@@ -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 <meta id=\"emite.user\" content=\"exampleuserid\" /> 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 <String, LoginXmpp>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,18 +135,19 @@ 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) {
createDialog(widget, htmlConfig);
} else {
addHablarToDiv(widget, htmlConfig);
}
}
}

private void setSize(final Widget widget, final HtmlConfig htmlConfig) {
5 changes: 4 additions & 1 deletion src/main/java/com/calclab/hablar/html/client/HtmlConfig.java
Original file line number Diff line number Diff line change
@@ -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
*/
4 changes: 4 additions & 0 deletions src/main/resources/com/calclab/hablar/html/HablarHtml.gwt.xml
Original file line number Diff line number Diff line change
@@ -5,6 +5,10 @@
<inherits name="com.calclab.hablar.Hablar" />
<inherits name='com.calclab.hablar.console.HablarConsole' />
<inherits name='com.calclab.hablar.login.HablarLogin' />
<inherits name='com.calclab.emite.xep.privacylists.PrivacyLists' />
<inherits name='com.calclab.emite.reconnect.EmiteReconnect' />
<inherits name='com.calclab.emite.xep.avatar.EmiteAvatar' />
<inherits name="com.calclab.emite.browser.EmiteBrowser" />

<inherits name='com.google.gwt.user.theme.chrome.Chrome' />
<!-- <inherits name='com.google.gwt.user.theme.standard.Standard' /> -->