Skip to content
This repository has been archived by the owner on Nov 3, 2021. It is now read-only.

Commit

Permalink
Merge pull request #11814 from etiennesegonzac/bug-906775-call-group-…
Browse files Browse the repository at this point in the history
…handler

Bug 906775 - ConferenceGroupHandler r=rik
  • Loading branch information
etiennesegonzac committed Sep 3, 2013
2 parents c76461c + b2d18f6 commit 3ba0d2e
Show file tree
Hide file tree
Showing 14 changed files with 660 additions and 100 deletions.
9 changes: 7 additions & 2 deletions apps/communications/dialer/js/call_screen.js
Expand Up @@ -10,6 +10,7 @@ var CallScreen = {
views: document.getElementById('views'),

calls: document.getElementById('calls'),
groupCalls: document.getElementById('group-call-details'),

mainContainer: document.getElementById('main-container'),
callToolbar: document.getElementById('co-advanced'),
Expand All @@ -29,8 +30,8 @@ var CallScreen = {
incomingIgnore: document.getElementById('incoming-ignore'),
lockedContactPhoto: document.getElementById('locked-contact-photo'),

set callsCount(count) {
this.calls.dataset.count = count;
set bigDuration(enabled) {
this.calls.classList.toggle('big-duration', enabled);
},

init: function cs_init() {
Expand Down Expand Up @@ -76,6 +77,10 @@ var CallScreen = {
this.calls.appendChild(node);
},

moveToGroup: function cs_moveToGroup(node) {
this.groupCalls.appendChild(node);
},

resizeHandler: function cs_resizeHandler() {
// If a user has the keypad opened, we want to display the number called
// while in status bar mode. And restore the digits typed when exiting.
Expand Down
34 changes: 31 additions & 3 deletions apps/communications/dialer/js/calls_handler.js
Expand Up @@ -102,16 +102,26 @@ var CallsHandler = (function callsHandler() {
return (call == hc.call);
});

stillHere = stillHere ||
telephony.conferenceGroup.calls.some(function hcIterator(call) {
return (call == hc.call);
});

if (!stillHere) {
removeCall(index);
}
});

// Letting the layout know how many calls we're handling
if (handledCalls.length === 0) {
exitCallScreen(false);
} else {
CallScreen.callsCount = handledCalls.length;
// Letting the CallScreen know how to display the call duration
// (depending on how many calls/conference group are on)
var openLines = telephony.calls.length +
(telephony.conferenceGroup.calls.length ? 1 : 0);

CallScreen.bigDuration = (openLines == 1);

if (!displayed && !closing) {
toggleScreen();
}
Expand All @@ -127,7 +137,7 @@ var CallsHandler = (function callsHandler() {
}

// No more room
if (handledCalls.length >= CALLS_LIMIT) {
if (telephony.calls.length > CALLS_LIMIT) {
new HandledCall(call);
call.hangUp();
return;
Expand Down Expand Up @@ -488,6 +498,12 @@ var CallsHandler = (function callsHandler() {
return;
}

if (telephony.active == telephony.conferenceGroup) {
endConferenceCall();
CallScreen.hideIncoming();
return;
}

var callToEnd = telephony.active || // connected, incoming
handledCalls[handledCalls.length - 2].call; // held, incoming

Expand Down Expand Up @@ -551,7 +567,19 @@ var CallsHandler = (function callsHandler() {
CallScreen.hideIncoming();
}

function endConferenceCall() {
telephony.conferenceGroup.calls.forEach(function(call) {
call.hangUp();
});
}

function end() {
// If a conference call is active we end all the calls in it
if (telephony.active == telephony.conferenceGroup) {
endConferenceCall();
return;
}

// If there is an active call we end this one
if (telephony.active) {
telephony.active.hangUp();
Expand Down
31 changes: 31 additions & 0 deletions apps/communications/dialer/js/conference_group_handler.js
@@ -0,0 +1,31 @@
'use strict';

var ConferenceGroupHandler = (function() {
var groupLine = document.getElementById('group-call');
var groupLabel = document.getElementById('group-call-label');

var telephony = window.navigator.mozTelephony;
telephony.conferenceGroup.oncallschanged = onCallsChanged;
telephony.conferenceGroup.onstatechange = onStateChange;

function onCallsChanged() {
var calls = telephony.conferenceGroup.calls;
groupLine.hidden = !calls.length;

LazyL10n.get(function localized(_) {
groupLabel.textContent = _('group-call',
{n: calls.length});
});
}

function onStateChange() {
switch (telephony.conferenceGroup.state) {
case 'resuming':
groupLine.classList.remove('held');
break;
case 'held':
groupLine.classList.add('held');
break;
}
}
})();
2 changes: 1 addition & 1 deletion apps/communications/dialer/js/fake-oncall-desktop.js
Expand Up @@ -27,7 +27,7 @@ if (window.location.pathname.endsWith('oncall.html')) {

duration.querySelector('.direction').classList.add('ongoing-in');

CallScreen.callsCount = 1;
CallScreen.bigDuration = true;
CallScreen.render('connected'); // Change this for various states
CallScreen.screen.classList.add('displayed');
} else {
Expand Down
9 changes: 8 additions & 1 deletion apps/communications/dialer/js/handled_call.js
Expand Up @@ -8,6 +8,14 @@ function HandledCall(aCall) {

aCall.addEventListener('statechange', this);

aCall.ongroupchange = (function onGroupChange() {
if (this.call.group) {
CallScreen.moveToGroup(this.node);
} else {
CallScreen.insertCall(this.node);
}
}).bind(this);

this.recentsEntry = {
date: Date.now(),
type: this.call.state,
Expand Down Expand Up @@ -239,7 +247,6 @@ HandledCall.prototype.updateDirection = function hc_updateDirection() {

HandledCall.prototype.remove = function hc_remove() {
this.call.removeEventListener('statechange', this);
this.call = null;
this.photo = null;

clearInterval(this._ticker);
Expand Down
8 changes: 8 additions & 0 deletions apps/communications/dialer/locales/dialer.en-US.properties
Expand Up @@ -180,3 +180,11 @@ SsModifiedToSs=SS modified to SS
SubscriptionNotSupported=Subscription not supported
InvalidParameter=Invalid parameter
RejectedByRemote=Rejected by remote

# Conference call
group-call={[ plural(n) ]}
group-call[one] = Group call ({{ n }})
group-call[two] = Group call ({{ n }})
group-call[few] = Group call ({{ n }})
group-call[many] = Group call ({{ n }})
group-call[other] = Group call ({{ n }})
15 changes: 15 additions & 0 deletions apps/communications/dialer/oncall.html
Expand Up @@ -28,6 +28,7 @@
<script defer type="application/javascript" src="/dialer/js/utils.js"></script>
<script defer type="application/javascript" src="/dialer/js/call_screen.js"></script>
<script defer type="application/javascript" src="/dialer/js/calls_handler.js"></script>
<script defer type="application/javascript" src="/dialer/js/conference_group_handler.js"></script>
<script defer type="application/javascript" src="/dialer/js/voicemail.js"></script>
<script defer type="application/javascript" src="/dialer/js/handled_call.js"></script>

Expand Down Expand Up @@ -57,6 +58,20 @@
</div>
</div>
</section>
<section id="group-call" hidden>
<div class="numberWrapper">
<div id="group-call-label" class="number font-light"></div>
</div>
<div id="group-call-summary" class="additionalContactInfo"></div>
<div class="duration">
<span class="font-light"></span>
<div class="direction">
<div></div>
</div>
</div>
</section>
</article>
<article id="group-call-details">
</article>
<article id="main-container">
<div id="actions-container">
Expand Down

0 comments on commit 3ba0d2e

Please sign in to comment.