Bug 978639 - Part 2: Add hangUp method (dom). r=hsinyi

This commit is contained in:
Szu-Yu Chen [:aknow] 2014-10-22 03:07:00 -04:00
parent fc5ac289b0
commit ee66f13623
2 changed files with 30 additions and 2 deletions

View File

@ -5,14 +5,16 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "TelephonyCallGroup.h"
#include "mozilla/dom/TelephonyCallGroupBinding.h"
#include "CallsList.h"
#include "Telephony.h"
#include "mozilla/dom/CallEvent.h"
#include "mozilla/dom/CallGroupErrorEvent.h"
#include "Telephony.h"
#include "mozilla/dom/TelephonyCallGroupBinding.h"
#include "mozilla/dom/telephony/TelephonyCallback.h"
using namespace mozilla::dom;
using namespace mozilla::dom::telephony;
using mozilla::ErrorResult;
TelephonyCallGroup::TelephonyCallGroup(nsPIDOMWindow* aOwner)
@ -277,6 +279,28 @@ TelephonyCallGroup::Remove(TelephonyCall& aCall, ErrorResult& aRv)
}
}
already_AddRefed<Promise>
TelephonyCallGroup::HangUp(ErrorResult& aRv)
{
MOZ_ASSERT(!mCalls.IsEmpty());
nsCOMPtr<nsIGlobalObject> global = do_QueryInterface(GetOwner());
if (!global) {
aRv.Throw(NS_ERROR_FAILURE);
return nullptr;
}
nsRefPtr<Promise> promise = Promise::Create(global, aRv);
NS_ENSURE_TRUE(!aRv.Failed(), nullptr);
nsCOMPtr<nsITelephonyCallback> callback = new TelephonyCallback(promise);
aRv = mTelephony->Service()->HangUpConference(mCalls[0]->ServiceId(),
callback);
NS_ENSURE_TRUE(!aRv.Failed(), nullptr);
return promise.forget();
}
void
TelephonyCallGroup::Hold(ErrorResult& aRv)
{

View File

@ -7,6 +7,7 @@
#ifndef mozilla_dom_telephony_telephonycallgroup_h__
#define mozilla_dom_telephony_telephonycallgroup_h__
#include "mozilla/dom/Promise.h"
#include "mozilla/dom/telephony/TelephonyCommon.h"
namespace mozilla {
@ -52,6 +53,9 @@ public:
void
Remove(TelephonyCall& aCall, ErrorResult& aRv);
already_AddRefed<Promise>
HangUp(ErrorResult& aRv);
void
Hold(ErrorResult& aRv);