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

WIP: Audio video capability #2956

Draft
wants to merge 28 commits into
base: master
Choose a base branch
from
Draft
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
5e5fadc
jingle: added the initial boilerplate code for the plugin.
PawBud Jun 16, 2022
387e781
(TBR)CallButton: added an unfunctional call button to the toolbar
PawBud Jun 17, 2022
13b1ef9
(TBR)index: added buttons hook to jingle plugin
PawBud Jun 20, 2022
6d88243
test
PawBud Jun 20, 2022
fb84f10
revert back code to avoid merge conflicts
PawBud Jun 20, 2022
d31b485
(TBR)added a boilerplate modal for jingle call
PawBud Jun 21, 2022
5c4b40d
added the call button at the chat header.
PawBud Jun 23, 2022
3f975d2
(TBR)Jingle modal
PawBud Jun 23, 2022
70a49d3
(TBR)added 2 new custom plugins for jingle
PawBud Jun 27, 2022
309c29d
added a toggling button in the centre of the chat-header
PawBud Jun 29, 2022
97b737d
jingle: added the tests for jingle & styled the header button
PawBud Jun 30, 2022
4eb696e
additional tests for jingle
PawBud Jun 30, 2022
1f6bd12
tests for chat header written
PawBud Jul 4, 2022
cbba9cb
(TBR) added the message initation tests
PawBud Jul 6, 2022
0e19aee
(TBR)added the Incoming pending & outgoing pending states, xep 0353 t…
PawBud Jul 6, 2022
ee9da60
tests: added tests to message initiation
PawBud Jul 10, 2022
6c0f422
(TBR)propose id is now shared with the retract stanza
PawBud Jul 15, 2022
322af18
(TBR) corrected message initiation test
PawBud Jul 18, 2022
bbcded7
changed the describe function text
PawBud Jul 18, 2022
c978385
changed the describe function text
PawBud Jul 19, 2022
1140ad8
(TBR) corrected some tests
PawBud Jul 24, 2022
bbb985e
(TBR) fixed the tests and added the On message hook
PawBud Jul 26, 2022
1235d42
(TBR)added the message retraction feature
PawBud Aug 4, 2022
b3ace4d
chat history: this commit adds the chat history of the jingle call st…
PawBud Aug 8, 2022
4c5b855
(TRB) Retraction improvements
PawBud Aug 24, 2022
7ef19af
(TBR)added a hook for the retraction
PawBud Aug 29, 2022
bec6455
The Reciever's side retraction tests pass
PawBud Aug 30, 2022
8f72210
chat history ui added and tests as well
PawBud Sep 5, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
(TBR) added the message initation tests
PawBud committed Jul 6, 2022
commit cbba9cbcc3878a9d83760b5eade1f468cc27904f
3 changes: 2 additions & 1 deletion karma.conf.js
Original file line number Diff line number Diff line change
@@ -64,7 +64,8 @@ module.exports = function(config) {
{ pattern: "src/plugins/controlbox/tests/controlbox.js", type: 'module' },
{ pattern: "src/plugins/controlbox/tests/login.js", type: 'module' },
{ pattern: "src/plugins/headlines-view/tests/headline.js", type: 'module' },
{ pattern: "src/plugins/jingle/tests/jingle.js", type: 'module' },
{ pattern: "src/plugins/jingle/tests/ui.js", type: 'module' },
{ pattern: "src/plugins/jingle/tests/message-initiation.js", type: 'module' },
{ pattern: "src/plugins/mam-views/tests/mam.js", type: 'module' },
{ pattern: "src/plugins/mam-views/tests/placeholder.js", type: 'module' },
{ pattern: "src/plugins/minimize/tests/minchats.js", type: 'module' },
3 changes: 3 additions & 0 deletions src/headless/core.js
Original file line number Diff line number Diff line change
@@ -54,6 +54,9 @@ Strophe.addNamespace('FASTEN', 'urn:xmpp:fasten:0');
Strophe.addNamespace('FORWARD', 'urn:xmpp:forward:0');
Strophe.addNamespace('HINTS', 'urn:xmpp:hints');
Strophe.addNamespace('HTTPUPLOAD', 'urn:xmpp:http:upload:0');
Strophe.addNamespace('JINGLE', 'urn:xmpp:jingle:1');
Strophe.addNamespace('JINGLEMESSAGE', 'urn:xmpp:jingle-message:1');
Strophe.addNamespace('JINGLERTP', 'urn:xmpp:jingle:apps:rtp:1');
Strophe.addNamespace('MAM', 'urn:xmpp:mam:2');
Strophe.addNamespace('MARKERS', 'urn:xmpp:chat-markers:0');
Strophe.addNamespace('MENTIONS', 'urn:xmpp:mmn:0');
15 changes: 14 additions & 1 deletion src/plugins/jingle/chat-header-notification.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { CustomElement } from 'shared/components/element.js';
import { _converse, api } from "@converse/headless/core";
import { _converse, api, converse } from "@converse/headless/core";
import tpl_header_button from "./templates/header-button.js";
import { JINGLE_CALL_STATUS } from "./constants.js";

import './styles/jingle.scss';

const { Strophe, $msg } = converse.env;

export default class CallNotification extends CustomElement {

static get properties() {
@@ -26,6 +28,17 @@ export default class CallNotification extends CustomElement {
const jingle_status = this.model.get('jingle_status');
if ( jingle_status === JINGLE_CALL_STATUS.PENDING || jingle_status === JINGLE_CALL_STATUS.ACTIVE) {
this.model.save('jingle_status', JINGLE_CALL_STATUS.ENDED);
api.send(
$msg({
'from': this.get('jid'),
'to': this.get('jid'),
'type': 'chat'
}).c('retract', {'xmlns': Strophe.NS.JINGLEMESSAGE, 'id': this.getAttribute('id')})
.c('reason', {'xmlns': Strophe.NS.JINGLE})
.c('cancel', {}).up()
.t('Retracted').up().up()
.c('store', {'xmlns': Strophe.NS.HINTS})
);
return;
}
}
58 changes: 58 additions & 0 deletions src/plugins/jingle/tests/message-initiation.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*global mock, converse */
const u = converse.env.utils;
const sizzle = converse.env.sizzle;

const { Strophe } = converse.env;

describe("A Jingle Message Initiation Request", function () {

it("is sent when the user clicks the call button", mock.initConverse(
['chatBoxesFetched'], {}, async function (_converse) {

await mock.waitForRoster(_converse, 'current', 1);
const contact_jid = mock.cur_names[0].replace(/ /g,'.').toLowerCase() + '@montague.lit';
await mock.openChatBoxFor(_converse, contact_jid);
const view = _converse.chatboxviews.get(contact_jid);
const call_button = view.querySelector('converse-jingle-toolbar-button button');
call_button.click();
const sent_stanzas = _converse.connection.sent_stanzas;
const stanza = await u.waitUntil(() => sent_stanzas.filter(s => sizzle(`propose`, s).length).pop());
expect(Strophe.serialize(stanza)).toBe(
`<message from='${_converse.jid}'
to='${contact_jid}'
type='chat'>`+
`<propose xmlns='${Strophe.NS.JINGLEMESSAGE}' id='${stanza.getAttribute('id')}'>`+
`<description xmlns='${Strophe.NS.JINGLERTP}' media='audio'/>`+
`</propose>`+
`<store xmlns="${Strophe.NS.HINTS}"/>`+
`</message>`);
}));


it("is ended when the user clicks the toolbar call button again or the chat header end call button", mock.initConverse(
['chatBoxesFetched'], {}, async function (_converse) {

await mock.waitForRoster(_converse, 'current', 1);
const contact_jid = mock.cur_names[0].replace(/ /g,'.').toLowerCase() + '@montague.lit';
await mock.openChatBoxFor(_converse, contact_jid);
const view = _converse.chatboxviews.get(contact_jid);
const call_button = view.querySelector('converse-jingle-toolbar-button button');
call_button.click();
call_button.click();
const sent_stanzas = _converse.connection.sent_stanzas;
const stanza = await u.waitUntil(() => sent_stanzas.filter(s => sizzle(`reason`, s).length).pop());
expect(Strophe.serialize(stanza)).toBe(
`<message from='${_converse.jid}'
to='${contact_jid}'
type='chat'>`+
`<retract xmlns='${Strophe.NS.JINGLEMESSAGE}' id='${stanza.getAttribute('id')}'>`+
`<reason xmlns="${Strophe.NS.JINGLE}">`+
`<cancel/>`+
`<text>Retracted</text>`+
`</reason>`+
` </retract>`+
`<store xmlns="${Strophe.NS.HINTS}"/>`+
`</message>`
);
}));
});
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/* global mock, converse */
const u = converse.env.utils;
// import { JINGLE_CALL_STATUS } from "../constants.js";

describe("A Jingle Status", function () {

@@ -22,23 +21,19 @@ describe("A Jingle Status", function () {
call_button.click();
expect(chatbox.get('jingle_status')).toBe(_converse.JINGLE_CALL_STATUS.PENDING);
}));

fit("has been shown in the chat-header",
mock.initConverse(['chatBoxesFetched'], {}, async function (_converse) {

await mock.waitForRoster(_converse, 'current');
await mock.openControlBox(_converse);
const contact_jid = mock.cur_names[2].replace(/ /g,'.').toLowerCase() + '@montague.lit';
spyOn(_converse.api, "trigger").and.callThrough();
await mock.openChatBoxFor(_converse, contact_jid);
const view = _converse.chatboxviews.get(contact_jid);
const chat_head = view.querySelector('.chatbox-title--row');
const toolbar = view.querySelector('.chat-toolbar');
const call_button = toolbar.querySelector('converse-jingle-toolbar-button button');
const chatbox = view.model;
// this.model.save('jingle_status', JINGLE_CALL_STATUS.ENDED);
// console.log
call_button.click();
chatbox.save('jingle_status', _converse.JINGLE_CALL_STATUS.PENDING);
const header_notification = chat_head.querySelector('converse-call-notification');
const call_intialized = await u.waitUntil(() => header_notification.querySelector('.jingle-call-initiated-button'));
call_intialized.click();
13 changes: 12 additions & 1 deletion src/plugins/jingle/toolbar-button.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { CustomElement } from 'shared/components/element.js';
import { _converse, api } from "@converse/headless/core";
import { converse, _converse, api } from "@converse/headless/core";
import { JINGLE_CALL_STATUS } from "./constants.js";
import tpl_toolbar_button from "./templates/toolbar-button.js";

const { Strophe, $msg } = converse.env;

export default class JingleToolbarButton extends CustomElement {

static get properties() {
@@ -24,6 +26,15 @@ export default class JingleToolbarButton extends CustomElement {
const jingle_status = this.model.get('jingle_status');
if ( jingle_status === JINGLE_CALL_STATUS.PENDING || jingle_status === JINGLE_CALL_STATUS.ACTIVE) {
this.model.save('jingle_status', JINGLE_CALL_STATUS.ENDED);
api.send(
$msg({
'from': this.get('jid'),
'to': this.get('jid'),
'type': 'chat'
}).c('propose', {'xmlns': Strophe.NS.JINGLEMESSAGE, 'id': this.getAttribute('id')})
.c('description', {'xmlns': Strophe.NS.JINGLERTP, 'media': 'audio'}).up().up()
.c('store', {'xmlns': Strophe.NS.HINTS})
);
return;
}
if (!jingle_status || jingle_status === JINGLE_CALL_STATUS.ENDED) {