Commit 9d73ff41 authored by Dele Olajide's avatar Dele Olajide

ofmeet plugin version 0.1.1

Added co-browsing to collaboration api
Moved collaboration api to chrome extension for co-browsing
Updated chrome extension to 0.0.2
parent 80a744ea
...@@ -49,6 +49,14 @@ ...@@ -49,6 +49,14 @@
Openfire Meetings Plugin Changelog Openfire Meetings Plugin Changelog
</h1> </h1>
<p><b>0.1.1</b> -- Feb 8th, 2015</p>
<ul>
<li>Added co-browsing to collaboration api</li>
<li>Moved collaboration api to chrome extension for co-browsing</li>
<li>Updated chrome extension to 0.0.2</li>
</ul>
<p><b>0.1.0</b> -- Feb 4th, 2015</p> <p><b>0.1.0</b> -- Feb 4th, 2015</p>
<ul> <ul>
......
...@@ -5,8 +5,8 @@ ...@@ -5,8 +5,8 @@
<name>Openfire Meetings</name> <name>Openfire Meetings</name>
<description>Provides high quality, scalable video conferences using Jitsi Meet and Jitsi Videobridge</description> <description>Provides high quality, scalable video conferences using Jitsi Meet and Jitsi Videobridge</description>
<author>Ignite Realtime</author> <author>Ignite Realtime</author>
<version>0.1.0</version> <version>0.1.1</version>
<date>02/04/2015</date> <date>02/08/2015</date>
<minServerVersion>3.9.9</minServerVersion> <minServerVersion>3.9.9</minServerVersion>
<adminconsole> <adminconsole>
......
var hash = null;
var url = urlParam("url");
var frameWindow = null;
function start()
{
frameWindow = document.getElementById('iframe1');
if (window.location.hash) hash = window.location.hash.substring(1);
console.log("app.js start", hash, url);
frameWindow.onload = function()
{
console.log("app.js onload", frameWindow);
}
if (url) frameWindow.src = url;
window.parent.connection.ofmuc.appReady();
}
function stop()
{
console.log("app.js stop");
}
function urlParam(name)
{
var results = new RegExp('[\\?&]' + name + '=([^&#]*)').exec(window.location.href);
if (!results) { return undefined; }
return decodeURIComponent(results[1]) || undefined;
}
window.onhashchange = function()
{
hash = window.location.hash.substring(1);
}
This diff is collapsed.
...@@ -7,11 +7,7 @@ ...@@ -7,11 +7,7 @@
<title>Openfire Meetings shared drawing demo</title> <title>Openfire Meetings shared drawing demo</title>
<meta name="viewport" content="width=320, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"/> <meta name="viewport" content="width=320, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"/>
<script src="../jquery-1.10.2.min.js"></script> <script src="js/jquery.min.js"></script>
<script src="../util.js"></script>
<script src="../ofmeet.js"></script>
<script src="../tinycolor.js"></script>
<script src="js/bootstrap.min.js"></script> <script src="js/bootstrap.min.js"></script>
<script src="js/parallax.js"></script> <script src="js/parallax.js"></script>
<script src="js/custom.js"></script> <script src="js/custom.js"></script>
...@@ -21,7 +17,6 @@ ...@@ -21,7 +17,6 @@
<script src="js/how-animations.js"></script> <script src="js/how-animations.js"></script>
<script src="js/retina.js"></script> <script src="js/retina.js"></script>
<link href="../cursor.css" rel="stylesheet" type="text/css" />
<link href="css/bootstrap.css" rel="stylesheet"> <link href="css/bootstrap.css" rel="stylesheet">
<link href="css/jumbotron.css" rel="stylesheet"> <link href="css/jumbotron.css" rel="stylesheet">
<link href="css/carousel.css" rel="stylesheet"> <link href="css/carousel.css" rel="stylesheet">
......
...@@ -292,7 +292,7 @@ $(document).ready(function () ...@@ -292,7 +292,7 @@ $(document).ready(function ()
// Color-button functions: // Color-button functions:
$('.color-picker').click(function () { $('.color-picker').click(function () {
var $this = $(this); var $this = $(this);
console.log($this); //console.log($this);
setColor($this.css("background-color")); setColor($this.css("background-color"));
changeMouse(); changeMouse();
}); });
...@@ -303,7 +303,7 @@ $(document).ready(function () ...@@ -303,7 +303,7 @@ $(document).ready(function ()
}); });
$('.user-color-pick').click(function() { $('.user-color-pick').click(function() {
setColor(OpenfireMeetings.getMyCursor().color); setColor('red');
changeMouse(); changeMouse();
}); });
...@@ -322,44 +322,52 @@ $(document).ready(function () ...@@ -322,44 +322,52 @@ $(document).ready(function ()
// Listens for draw messages, sends info about the drawn lines: // Listens for draw messages, sends info about the drawn lines:
document.addEventListener('message', function (event)
OpenfireMeetings =
{
setContent: function (content)
{
//console.log("remote set-content", content);
var newLines = JSON.parse(content);
init({lines: newLines});
OpenfireMeetings.send({type: 'init', lines: lines});
},
getContent: function()
{
//console.log("remote getContent");
return JSON.stringify(lines);
},
getPrintContent: function()
{
//console.log("remote getPrintContent");
var img = canvas.toDataURL("image/png");
return '<img src="'+img+'"/>';
},
handleAppMessage: function (json)
{ {
//window.parent.console.log("remote sketch handleAppMessage", event); //console.log("remote sketch handleAppMessage", json);
if (!onReady) return if (!onReady) return
try { try {
var msg = JSON.parse(event.detail.json); var msg = JSON.parse(json);
if (msg.type == "draw") draw(msg.start, msg.end, msg.color, msg.size, msg.compositeOperation, true); if (msg.type == "draw") draw(msg.start, msg.end, msg.color, msg.size, msg.compositeOperation, true);
if (msg.type == "joined") OpenfireMeetings.send({type: 'init', lines: lines}); if (msg.type == "joined") OpenfireMeetings.send({type: 'init', lines: lines});
if (msg.type == "init") init(msg); if (msg.type == "init") init(msg);
if (msg.type == "clear") clear(false); if (msg.type == "clear") clear(false);
} catch (e) { window.parent.console.error("remote sketch handleAppMessage", e)} } catch (e) { console.error("remote sketch handleAppMessage", e)}
}); },
document.addEventListener('set-content', function (event)
{
window.parent.console.log("remote set-content", event.detail);
var content = event.detail.content && event.detail.content != "" ? event.detail.content : "{}"
var newLines = JSON.parse(content);
init({lines: newLines});
OpenfireMeetings.send({type: 'init', lines: lines});
});
OpenfireMeetings.getContent = function() send: function(json)
{ {
window.parent.console.log("remote getContent"); window.parent.connection.ofmuc.appMessage(json);
return JSON.stringify(lines);
} }
OpenfireMeetings.getPrintContent = function()
{
window.parent.console.log("remote getPrintContent");
var img = canvas.toDataURL("image/png");
return '<img src="'+img+'"/>';
} }
window.parent.connection.ofmuc.appReady();
onReady = true; onReady = true;
}); });
...@@ -2,33 +2,27 @@ ...@@ -2,33 +2,27 @@
<html> <html>
<head> <head>
<link rel="stylesheet" type="text/css" href="cursor.css" />
<script type="text/javascript" src="jquery-1.10.2.min.js"></script>
<script type="text/javascript" src="util.js"></script>
<script type="text/javascript" src="ofmeet.js"></script>
<script type="text/javascript" src="tinycolor.js"></script>
<script> <script>
document.addEventListener('message', function (event) OpenfireMeetings =
{ {
window.parent.console.log("remote message", event); setContent: function(content)
});
document.addEventListener('set-content', function (event)
{ {
window.parent.console.log("remote set-content", event.detail); console.log("remote setContent", content);
}); },
OpenfireMeetings.getContent = function() getContent: function()
{ {
window.parent.console.log("remote getContent"); console.log("remote getContent");
return null; return null;
} },
OpenfireMeetings.getPrintContent = function() getPrintContent: function()
{ {
window.parent.console.log("remote getPrintContent"); console.log("remote getPrintContent");
return '<img src="http://londontopia.net/wp-content/uploads/2015/01/enhanced-buzz-wide-22194-1393580280-8.jpg"/>'; return '<img src="http://londontopia.net/wp-content/uploads/2015/01/enhanced-buzz-wide-22194-1393580280-8.jpg"/>';
} }
};
</script> </script>
</head> </head>
......
<!doctype html>
<html>
<head>
<style type="text/css">
body
{
margin: 0;
overflow: hidden;
}
#iframe1
{
height: 100%;
left: 0px;
position: absolute;
top: 0px;
width: 100%;
}
</style>
<script type="text/javascript" src="app.js"></script>
</head>
<body onload="start();" onunload="stop();">
<iframe id="iframe1" frameborder="0"></iframe>
</body>
</html>
...@@ -28,12 +28,12 @@ ...@@ -28,12 +28,12 @@
{ {
handleAppMessage: function (json, from) handleAppMessage: function (json, from)
{ {
try { //try {
var obj = JSON.parse(json); var obj = JSON.parse(json);
//window.parent.console.log("remote handleAppMessage", obj, json, from); //window.parent.console.log("remote handleAppMessage", obj, json, from);
quill.site.receive(obj); quill.site.receive(obj);
} catch (e) { window.parent.console.error("remote handleAppMessage", e)} //} catch (e) { window.parent.console.error("remote handleAppMessage", e)}
}, },
getContent: function() getContent: function()
...@@ -79,7 +79,11 @@ ...@@ -79,7 +79,11 @@
$('#editor').css({height: window.innerHeight - 60, width: window.innerWidth - 40}); $('#editor').css({height: window.innerHeight - 60, width: window.innerWidth - 40});
}); });
window.parent.connection.ofmuc.appEnableCursor(false);
window.parent.connection.ofmuc.appReady(); window.parent.connection.ofmuc.appReady();
window.parent.console.log('remote document ready XX', user, room);
}); });
</script> </script>
</head> </head>
......
...@@ -8,9 +8,7 @@ channel.onMessage.addListener(function (message) { ...@@ -8,9 +8,7 @@ channel.onMessage.addListener(function (message) {
window.addEventListener('message', function (event) { window.addEventListener('message', function (event) {
if (event.source != window) if (event.source != window)
return; return;
if (!event.data && ( if (!event.data || (event.data.type != 'ofmeetGetScreen' && event.data.type != 'ofmeetCancelGetScreen'))
event.data.type == 'ofmeetGetScreen' ||
event.data.type == 'ofmeetCancelGetScreen'))
return; return;
channel.postMessage(event.data); channel.postMessage(event.data);
}); });
......
...@@ -3,10 +3,12 @@ ...@@ -3,10 +3,12 @@
"scripts": [ "background.js" ] "scripts": [ "background.js" ]
}, },
"content_scripts": [ { "content_scripts": [ {
"js": [ "content.js" ], "js": [ "content.js", "jquery.min.js", "util.js", "ofmeet.js", "tinycolor.js" ],
"matches": [ "https://*/*" ] "css": [ "cursor.css" ],
"matches": [ "https://*/*", "http://*/*" ],
"all_frames": true
} ], } ],
"description": "Openfire Meetings Chrome Extension required for screen sharing", "description": "Openfire Meetings Chrome Extension required for screen sharing and co-browsing",
"icons": { "icons": {
"128": "icon128.png", "128": "icon128.png",
"16": "icon16.png", "16": "icon16.png",
...@@ -14,8 +16,8 @@ ...@@ -14,8 +16,8 @@
}, },
"manifest_version": 2, "manifest_version": 2,
"minimum_chrome_version": "34", "minimum_chrome_version": "34",
"name": "Openfire Meetings Screen Share", "name": "Openfire Meetings Chrome Extension",
"permissions": [ "desktopCapture" ], "permissions": [ "desktopCapture" ],
"short_name": "ofmeet screensharing", "short_name": "ofmeet chrome extension",
"version": "0.0.1" "version": "0.0.2"
} }
\ No newline at end of file
...@@ -2,8 +2,7 @@ ...@@ -2,8 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this file, * License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */ * You can obtain one at http://mozilla.org/MPL/2.0/. */
var ofmeet = (function (my)
var OpenfireMeetings = (function (my)
{ {
var FOREGROUND_COLORS = ["#111", "#eee"]; var FOREGROUND_COLORS = ["#111", "#eee"];
var CURSOR_HEIGHT = 50; var CURSOR_HEIGHT = 50;
...@@ -15,11 +14,61 @@ var OpenfireMeetings = (function (my) ...@@ -15,11 +14,61 @@ var OpenfireMeetings = (function (my)
send: function(msg) send: function(msg)
{ {
//window.parent.console.log('remote session.send', msg); //console.log("session send", msg);
window.parent.connection.ofmuc.appMessage(msg); window.parent.postMessage({ type: 'ofmeetSendMessage', msg: msg}, '*');
}
};
var eventMaker = {};
eventMaker.performClick = function (target) {
// FIXME: should accept other parameters, like Ctrl/Alt/etc
var event = document.createEvent("MouseEvents");
event.initMouseEvent(
"click", // type
true, // canBubble
true, // cancelable
window, // view
0, // detail
0, // screenX
0, // screenY
0, // clientX
0, // clientY
false, // ctrlKey
false, // altKey
false, // shiftKey
false, // metaKey
0, // button
null // relatedTarget
);
// FIXME: I'm not sure this custom attribute always propagates?
// seems okay in Firefox/Chrome, but I've had problems with
// setting attributes on keyboard events in the past.
event.togetherjsInternal = true;
target = $(target)[0];
var cancelled = target.dispatchEvent(event);
if (cancelled) {
return;
} }
if (target.tagName == "A") {
var href = target.href;
if (href) {
location.href = href;
return;
}
}
// FIXME: should do button clicks (like a form submit)
// FIXME: should run .onclick() as well
};
eventMaker.fireChange = function (target) {
target = $(target)[0];
var event = document.createEvent("HTMLEvents");
event.initEvent("change", true, true);
target.dispatchEvent(event);
}; };
var elementFinder = {}; var elementFinder = {};
elementFinder.ignoreElement = function ignoreElement(el) elementFinder.ignoreElement = function ignoreElement(el)
...@@ -487,7 +536,7 @@ var OpenfireMeetings = (function (my) ...@@ -487,7 +536,7 @@ var OpenfireMeetings = (function (my)
var lastPosY = -1; var lastPosY = -1;
var lastMessage = null; var lastMessage = null;
function mousemove(event) function mouseMove(event)
{ {
var now = Date.now(); var now = Date.now();
if (now - lastTime < MIN_TIME) { if (now - lastTime < MIN_TIME) {
...@@ -644,7 +693,7 @@ var OpenfireMeetings = (function (my) ...@@ -644,7 +693,7 @@ var OpenfireMeetings = (function (my)
function displayClick(pos, color) { function displayClick(pos, color) {
console.log("displayClick", pos, color); //console.log("displayClick", pos, color);
// FIXME: should we hide the local click if no one else is going to see it? // FIXME: should we hide the local click if no one else is going to see it?
// That means tracking who might be able to see our screen. // That means tracking who might be able to see our screen.
var element = $('<div class="togetherjs-click togetherjs"></div>'); var element = $('<div class="togetherjs-click togetherjs"></div>');
...@@ -699,58 +748,17 @@ var OpenfireMeetings = (function (my) ...@@ -699,58 +748,17 @@ var OpenfireMeetings = (function (my)
var offset = target.offset(); var offset = target.offset();
topPos = offset.top + pos.offsetY; topPos = offset.top + pos.offsetY;
leftPos = offset.left + pos.offsetX; leftPos = offset.left + pos.offsetX;
}
eventMaker.performClick(target);
}
displayClick({top: topPos, left: leftPos}, 'red'); displayClick({top: topPos, left: leftPos}, 'red');
}; };
window.addEventListener("unload", function ()
{
Cursor.forEach(function (c, clientId) {
Cursor.destroy(clientId);
});
$(document).unbind("mousemove", mousemove);
document.removeEventListener("click", documentClick, true);
document.removeEventListener("keydown", documentKeydown, true);
$(window).unbind("scroll", scroll);
});
window.addEventListener("load", function()
{
my.room = util.urlParam("room");
my.user = util.urlParam("user");
window.parent.console.log("remote load", my.room, my.user);
$(document).mousemove(mousemove);
document.addEventListener("click", documentClick, true);
document.addEventListener("keydown", documentKeydown, true);
$(window).scroll(scroll);
scroll();
window.parent.connection.ofmuc.appReady();
});
my.send = function(json)
{
session.send(json);
}
my.getMyCursor = function()
{
return Cursor.getClient(my.user);
}
my.getCursor = function(user)
{
return Cursor.getClient(user);
}
my.handleAppMessage = function(json, from) my.handleAppMessage = function(json, from)
{ {
//try { //try {
var obj = JSON.parse(json); var obj = JSON.parse(json);
//window.parent.console.log("remote handleAppMessage", obj, json, from); console.log("remote handleAppMessage", obj, json, from);
p = Cursor.getClient(from); p = Cursor.getClient(from);
...@@ -765,26 +773,60 @@ var OpenfireMeetings = (function (my) ...@@ -765,26 +773,60 @@ var OpenfireMeetings = (function (my)
var myEvent = new CustomEvent("message", {detail: {json: json, from: from}}); var myEvent = new CustomEvent("message", {detail: {json: json, from: from}});
document.dispatchEvent(myEvent); document.dispatchEvent(myEvent);
//} catch (e) { window.parent.console.error(e)} //} catch (e) {console.error(e)}
} }
my.getContent = function()
{
return null;
}
my.getPrintContent = function() window.addEventListener("unload", function ()
{ {
return null; if (window == window.parent) return;
}
console.log("remote unload", my.room, my.user);
Cursor.forEach(function (c, clientId) {
Cursor.destroy(clientId);
});
document.removeEventListener("mousemove", mouseMove, true);
document.removeEventListener("click", documentClick, true);
document.removeEventListener("keydown", documentKeydown, true);
$(window).unbind("scroll", scroll);
window.parent.postMessage({ type: 'ofmeetUnloaded'}, '*');
});
my.setContent = function(content) window.addEventListener('message', function (event) {
//console.log("addEventListener message extension", event, window == window.parent);
if (!event.data) return;
// handle ofmuc requests
if (event.data.type == 'ofmeetSetMessage') my.handleAppMessage(event.data.json, event.data.from); // from ofmuc
// handle API requests
if (event.data.type == 'ofmeetGetCursor') window.parent.postMessage({ type: 'ofmeetGotCursor', content: Cursor.getClient(event.data.user)}, '*');
if (event.data.type == 'ofmeetGetMyCursor') window.parent.postMessage({ type: 'ofmeetGotCursor', content: Cursor.getClient(my.user)}, '*');
});
$(document).ready(function ()
{ {
//window.parent.console.log("remote setContent", content); if (window == window.parent) return;
var myEvent = new CustomEvent("set-content", {detail: {content: content}});
document.dispatchEvent(myEvent);
}
my.room = util.urlParam("room");
my.user = util.urlParam("user");
document.addEventListener("mousemove", mouseMove, true);
document.addEventListener("click", documentClick, true);
document.addEventListener("keydown", documentKeydown, true);
$(window).scroll(scroll);
scroll();
console.log("remote loaded", my.room, my.user);
window.parent.postMessage({ type: 'ofmeetLoaded'}, '*');
});
return my; return my;
}(OpenfireMeetings || {})); }(ofmeet || {}));
\ No newline at end of file \ No newline at end of file
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
var message, item, player; var message, item, player;
try { try {
message = JSON.parse(event.data); message = JSON.parse(event.data);
} catch (e) {}
if (message.id && (player = PreziPlayer.players[message.id])){ if (message.id && (player = PreziPlayer.players[message.id])){
if (player.options.debug === true) { if (player.options.debug === true) {
if (console && console.log) console.log('received', message); if (console && console.log) console.log('received', message);
...@@ -48,6 +48,7 @@ ...@@ -48,6 +48,7 @@
} }
} }
} }
} catch (e) {}
}; };
function PreziPlayer(id, options) { function PreziPlayer(id, options) {
......
...@@ -26,6 +26,8 @@ Strophe.addConnectionPlugin('ofmuc', { ...@@ -26,6 +26,8 @@ Strophe.addConnectionPlugin('ofmuc', {
isRecording: false, isRecording: false,
urls: [], urls: [],
bookmarks: [], bookmarks: [],
appRunning: false,
enableCursor: true,
init: function (conn) { init: function (conn) {
this.connection = conn; this.connection = conn;
...@@ -40,6 +42,15 @@ Strophe.addConnectionPlugin('ofmuc', { ...@@ -40,6 +42,15 @@ Strophe.addConnectionPlugin('ofmuc', {
that.resize(); that.resize();
}); });
window.addEventListener('message', function (event)
{
//console.log("addListener message ofmuc", event);
if (!event.data) return;
if (event.data.type == 'ofmeetLoaded') that.appReady();
if (event.data.type == 'ofmeetSendMessage') that.appMessage(event.data.msg);
});
}, },
statusChanged: function(status, condition) statusChanged: function(status, condition)
...@@ -50,7 +61,7 @@ Strophe.addConnectionPlugin('ofmuc', { ...@@ -50,7 +61,7 @@ Strophe.addConnectionPlugin('ofmuc', {
{ {
this.connection.sendIQ($iq({type: "get"}).c("query", {xmlns: "jabber:iq:private"}).c("storage", {xmlns: "storage:bookmarks"}).tree(), function(resp) this.connection.sendIQ($iq({type: "get"}).c("query", {xmlns: "jabber:iq:private"}).c("storage", {xmlns: "storage:bookmarks"}).tree(), function(resp)
{ {
console.log("get bookmarks", resp) //console.log("get bookmarks", resp)
$(resp).find('conference').each(function() $(resp).find('conference').each(function()
{ {
...@@ -298,8 +309,15 @@ Strophe.addConnectionPlugin('ofmuc', { ...@@ -298,8 +309,15 @@ Strophe.addConnectionPlugin('ofmuc', {
}, },
appSave: function(callback) { appSave: function(callback) {
//console.log("ofmuc.appSave");
if (this.appFrame && this.appFrame.contentWindow.OpenfireMeetings && this.appFrame.contentWindow.OpenfireMeetings.getContent) var canSave = false;
try {
canSave = this.appFrame && this.appFrame.contentWindow.OpenfireMeetings && this.appFrame.contentWindow.OpenfireMeetings.getContent;
} catch (e) { if (callback) callback()}
if (canSave)
{ {
var content = LZString.compressToUTF16(this.appFrame.contentWindow.OpenfireMeetings.getContent()); var content = LZString.compressToUTF16(this.appFrame.contentWindow.OpenfireMeetings.getContent());
...@@ -307,8 +325,9 @@ Strophe.addConnectionPlugin('ofmuc', { ...@@ -307,8 +325,9 @@ Strophe.addConnectionPlugin('ofmuc', {
{ {
//console.log("ofmuc.appSave", this.shareApp, content); //console.log("ofmuc.appSave", this.shareApp, content);
var ns = this.shareApp + "/" + this.roomJid;
var iq = $iq({to: config.hosts.domain, type: 'set'}); var iq = $iq({to: config.hosts.domain, type: 'set'});
iq.c('query', {xmlns: "jabber:iq:private"}).c('ofmeet-application', {xmlns: this.shareApp}).t(content); iq.c('query', {xmlns: "jabber:iq:private"}).c('ofmeet-application', {xmlns: ns}).t(content);
this.connection.sendIQ(iq, this.connection.sendIQ(iq,
...@@ -322,13 +341,20 @@ Strophe.addConnectionPlugin('ofmuc', { ...@@ -322,13 +341,20 @@ Strophe.addConnectionPlugin('ofmuc', {
); );
} else if (callback) callback(); } else if (callback) callback();
}
} else if (callback) callback()
}, },
appPrint: function() { appPrint: function() {
console.log("ofmuc.appPrint"); //console.log("ofmuc.appPrint");
if (this.appFrame && this.appFrame.contentWindow.OpenfireMeetings && this.appFrame.contentWindow.OpenfireMeetings.getPrintContent) var canPrint = false;
try {
canPrint = this.appFrame && this.appFrame.contentWindow.OpenfireMeetings && this.appFrame.contentWindow.OpenfireMeetings.getPrintContent;
} catch (e) {}
if (canPrint)
{ {
var content = this.appFrame.contentWindow.OpenfireMeetings.getPrintContent(); var content = this.appFrame.contentWindow.OpenfireMeetings.getPrintContent();
var printWin = window.open(); var printWin = window.open();
...@@ -338,8 +364,17 @@ Strophe.addConnectionPlugin('ofmuc', { ...@@ -338,8 +364,17 @@ Strophe.addConnectionPlugin('ofmuc', {
} }
}, },
appEnableCursor: function(flag) {
console.log("ofmuc.appEnableCursor", flag)
this.enableCursor = flag;
},
appReady: function() { appReady: function() {
console.log("ofmuc.appReady") //console.log("ofmuc.appReady")
if (this.appRunning) return;
$.prompt.close(); $.prompt.close();
this.setPresentationVisible(true); this.setPresentationVisible(true);
...@@ -353,8 +388,9 @@ Strophe.addConnectionPlugin('ofmuc', { ...@@ -353,8 +388,9 @@ Strophe.addConnectionPlugin('ofmuc', {
if (this.shareApp) // owner, get from server if (this.shareApp) // owner, get from server
{ {
var that = this; var that = this;
var ns = this.shareApp + "/" + this.roomJid;
var iq = $iq({to: config.hosts.domain, type: 'get'}); var iq = $iq({to: config.hosts.domain, type: 'get'});
iq.c('query', {xmlns: "jabber:iq:private"}).c('ofmeet-application', {xmlns: this.shareApp}); iq.c('query', {xmlns: "jabber:iq:private"}).c('ofmeet-application', {xmlns: ns});
this.connection.sendIQ(iq, this.connection.sendIQ(iq,
...@@ -363,12 +399,14 @@ Strophe.addConnectionPlugin('ofmuc', { ...@@ -363,12 +399,14 @@ Strophe.addConnectionPlugin('ofmuc', {
$(resp).find('ofmeet-application').each(function() $(resp).find('ofmeet-application').each(function()
{ {
try {
if (that.appFrame && that.appFrame.contentWindow.OpenfireMeetings && that.appFrame.contentWindow.OpenfireMeetings.setContent) if (that.appFrame && that.appFrame.contentWindow.OpenfireMeetings && that.appFrame.contentWindow.OpenfireMeetings.setContent)
{ {
var content = LZString.decompressFromUTF16($(this).text()); var content = LZString.decompressFromUTF16($(this).text());
//console.log("ofmuc.appReady", that.shareApp, content); //console.log("ofmuc.appReady", that.shareApp, content);
that.appFrame.contentWindow.OpenfireMeetings.setContent(content); that.appFrame.contentWindow.OpenfireMeetings.setContent(content);
} }
} catch (e) {}
}); });
}, },
...@@ -382,6 +420,8 @@ Strophe.addConnectionPlugin('ofmuc', { ...@@ -382,6 +420,8 @@ Strophe.addConnectionPlugin('ofmuc', {
msg.c('appshare', {xmlns: 'http://igniterealtime.org/protocol/appshare', action: 'message', url: '{"type": "joined"}'}).up(); msg.c('appshare', {xmlns: 'http://igniterealtime.org/protocol/appshare', action: 'message', url: '{"type": "joined"}'}).up();
this.connection.send(msg); this.connection.send(msg);
} }
this.appRunning = true;
}, },
appShare: function(action, url) { appShare: function(action, url) {
...@@ -394,10 +434,9 @@ Strophe.addConnectionPlugin('ofmuc', { ...@@ -394,10 +434,9 @@ Strophe.addConnectionPlugin('ofmuc', {
appStart: function(url, owner) { appStart: function(url, owner) {
console.log("ofmuc.appStart", url, owner); console.log("ofmuc.appStart", url, owner);
$('#presentation').html('<iframe id="appViewer"></iframe>'); $('#presentation').html('<iframe id="appViewer" src="' + url + "?room=" + Strophe.getNodeFromJid(this.roomJid) + "&user=" + SettingsMenu.getDisplayName() + '"></iframe>');
this.appFrame = document.getElementById("appViewer"); this.appFrame = document.getElementById("appViewer");
this.appFrame.contentWindow.location.href = url + "?room=" + Strophe.getNodeFromJid(this.roomJid) + "&user=" + SettingsMenu.getDisplayName(); this.enableCursor = true;
$.prompt("Please wait....", $.prompt("Please wait....",
{ {
...@@ -408,7 +447,7 @@ Strophe.addConnectionPlugin('ofmuc', { ...@@ -408,7 +447,7 @@ Strophe.addConnectionPlugin('ofmuc', {
}, },
appStop: function(url) { appStop: function(url) {
console.log("ofmuc.appStop", url); //console.log("ofmuc.appStop", url);
this.setPresentationVisible(false); this.setPresentationVisible(false);
...@@ -416,6 +455,7 @@ Strophe.addConnectionPlugin('ofmuc', { ...@@ -416,6 +455,7 @@ Strophe.addConnectionPlugin('ofmuc', {
{ {
this.appFrame.contentWindow.location.href = "about:blank"; this.appFrame.contentWindow.location.href = "about:blank";
this.appFrame = null; this.appFrame = null;
this.appRunning = false;
$('#presentation').html(''); $('#presentation').html('');
} }
...@@ -448,15 +488,44 @@ Strophe.addConnectionPlugin('ofmuc', { ...@@ -448,15 +488,44 @@ Strophe.addConnectionPlugin('ofmuc', {
} }
} }
if (this.appFrame && this.appFrame.contentWindow.OpenfireMeetings && this.appFrame.contentWindow.OpenfireMeetings.handleAppMessage && action == "message") if (this.appFrame && this.appFrame.contentWindow)
{
if (this.enableCursor) this.appFrame.contentWindow.postMessage({ type: 'ofmeetSetMessage', json: url, from: from}, '*');
try {
if (this.appFrame.contentWindow.OpenfireMeetings && this.appFrame.contentWindow.OpenfireMeetings.handleAppMessage && action == "message")
{ {
this.appFrame.contentWindow.OpenfireMeetings.handleAppMessage(url, from); this.appFrame.contentWindow.OpenfireMeetings.handleAppMessage(url, from);
} }
} catch (e) { }
}
}, },
openAppsDialog: function() { openAppsDialog: function() {
console.log("ofmuc.openAppsDialog"); console.log("ofmuc.openAppsDialog");
var that = this; var that = this;
var canPrint = false;
var canSave = false;
try {
canPrint = this.appFrame && this.appFrame.contentWindow.OpenfireMeetings && this.appFrame.contentWindow.OpenfireMeetings.getPrintContent;
canSave = this.appFrame && this.appFrame.contentWindow.OpenfireMeetings && this.appFrame.contentWindow.OpenfireMeetings.setContent;
} catch (e) {}
var removeButtons = { "Remove": 1};
var printButtons = { "Ok": 1};
if (canPrint)
{
removeButtons["Print"] = 2;
printButtons["Print"] = 2;
}
if (canSave)
{
removeButtons["Save"] = 3;
}
if (this.shareApp) if (this.shareApp)
{ {
...@@ -469,7 +538,7 @@ Strophe.addConnectionPlugin('ofmuc', { ...@@ -469,7 +538,7 @@ Strophe.addConnectionPlugin('ofmuc', {
$.prompt("Are you sure you would like to remove your shared applicationt", $.prompt("Are you sure you would like to remove your shared applicationt",
{ {
title: "Remove application sharing", title: "Remove application sharing",
buttons: { "Remove": 1, "Print": 2, "Save": 3, "Cancel": 0}, buttons: removeButtons,
defaultButton: 1, defaultButton: 1,
submit: function(e,v,m,f) submit: function(e,v,m,f)
{ {
...@@ -505,7 +574,7 @@ Strophe.addConnectionPlugin('ofmuc', { ...@@ -505,7 +574,7 @@ Strophe.addConnectionPlugin('ofmuc', {
$.prompt("Another participant is already sharing an application, presentation or document. This conference allows only one application, presentation or document at a time.", $.prompt("Another participant is already sharing an application, presentation or document. This conference allows only one application, presentation or document at a time.",
{ {
f: "Share an application", f: "Share an application",
buttons: { "Ok": 1, "Print": 2}, buttons: printButtons,
defaultButton: 0, defaultButton: 0,
submit: function(e,v,m,f) submit: function(e,v,m,f)
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment