Commit f6a10327 authored by Nicolas Jager's avatar Nicolas Jager

call : accept/reject incoming calls

- adds buttons and logic to accept or reject a call.

- removes the auto answer flag.

Tuleap: #984
Change-Id: Ifbf5e5bbbff77b26badff6b180d4e0368f207910
parent 0cf42d77
......@@ -53,4 +53,14 @@ Call::NotifyPropertyChanged(String^ propertyName)
PropertyChanged(this, ref new PropertyChangedEventArgs(propertyName));
}));
}
\ No newline at end of file
}
void RingClientUWP::Call::refuse()
{
RingD::instance->refuseIncommingCall(this);
}
void RingClientUWP::Call::accept()
{
RingD::instance->acceptIncommingCall(this);
}
......@@ -43,6 +43,9 @@ protected:
/* properties */
void NotifyPropertyChanged(String^ propertyName);
internal:
void refuse();
void accept();
};
}
......
......@@ -43,11 +43,11 @@ CallsViewModel::CallsViewModel()
if (state == "OVER") {
delete call;
call->stateChange("", code);
callStatusUpdated(call);
callStatusUpdated(call); // used ?
return;
}
call->stateChange(state, code);
callStatusUpdated(call);
callStatusUpdated(call); // same...
return;
}
}
......
......@@ -83,6 +83,18 @@ public:
PropertyChanged(this, ref new PropertyChangedEventArgs("_call"));
}
}
property Windows::UI::Xaml::GridLength _contactBarHeight
{
Windows::UI::Xaml::GridLength get()
{
return contactBarHeight_;
}
void set(Windows::UI::Xaml::GridLength value)
{
contactBarHeight_ = value;
PropertyChanged(this, ref new PropertyChangedEventArgs("_contactBarHeight"));
}
}
internal:
void saveConversationToFile();
......@@ -97,7 +109,7 @@ private:
Conversation^ conversation_;
Visibility notificationNewMessage_;
unsigned int unreadMessages_;
Windows::UI::Xaml::GridLength contactBarHeight_;
Windows::UI::Xaml::GridLength contactBarHeight_ = 0;
Call^ call_;
};
}
......
......@@ -79,6 +79,8 @@ ContactsViewModel::ContactsViewModel()
return;
}
contact->_call = call;
contact->_contactBarHeight = 50;
});
}
......
......@@ -102,6 +102,7 @@ void RingClientUWP::RingD::sendAccountTextMessage(String^ message)
void
RingD::createRINGAccount(String^ alias)
{
// refactoring : create a dedicated class constructor task and removes accountName from RingD
accountName = Utils::toString(alias);
tasksList_.push(ref new RingD::Task(Request::AddRingAccount));
}
......@@ -109,10 +110,21 @@ RingD::createRINGAccount(String^ alias)
void
RingD::createSIPAccount(String^ alias)
{
// refactoring : create a dedicated class constructor task and removes accountName from RingD
accountName = Utils::toString(alias);
tasksList_.push(ref new RingD::Task(Request::AddSIPAccount));
}
void RingClientUWP::RingD::refuseIncommingCall(Call^ call)
{
tasksList_.push(ref new RingD::Task(Request::RefuseIncommingCall, call));
}
void RingClientUWP::RingD::acceptIncommingCall(Call^ call)
{
tasksList_.push(ref new RingD::Task(Request::AcceptIncommingCall, call));
}
void
RingClientUWP::RingD::startDaemon()
{
......@@ -191,13 +203,13 @@ RingClientUWP::RingD::startDaemon()
}
}),
DRing::exportable_callback<DRing::ConfigurationSignal::RegistrationStateChanged>([this](
const std::string& account_id, const std::string& state,
int detailsCode, const std::string& detailsStr)
const std::string& account_id, const std::string& state,
int detailsCode, const std::string& detailsStr)
{
MSG_("<RegistrationStateChanged>: ID = " + account_id + "state = " + state);
if (state == DRing::Account::States::UNREGISTERED) {
CoreApplication::MainView->CoreWindow->Dispatcher->RunAsync(CoreDispatcherPriority::Normal,
ref new DispatchedHandler([=]() {
ref new DispatchedHandler([=]() {
reloadAccountList();
}));
}
......@@ -228,8 +240,7 @@ RingClientUWP::RingD::startDaemon()
registerCallHandlers(getAppPathHandler);
DRing::init(static_cast<DRing::InitFlag>(DRing::DRING_FLAG_CONSOLE_LOG |
DRing::DRING_FLAG_DEBUG |
DRing::DRING_FLAG_AUTOANSWER));
DRing::DRING_FLAG_DEBUG));
if (!DRing::start()) {
ERR_("\ndaemon didn't start.\n");
......@@ -267,7 +278,8 @@ RingD::dequeueTasks()
{
for (int i = 0; i < tasksList_.size(); i++) {
auto task = tasksList_.front();
switch (task->request) {
auto request = dynamic_cast<Task^>(task)->request;
switch (request) {
case Request::None:
break;
case Request::AddRingAccount:
......@@ -286,6 +298,20 @@ RingD::dequeueTasks()
DRing::addAccount(sipAccountDetails);
}
break;
case Request::RefuseIncommingCall:
{
auto callId = task->_call->callId;
auto callId2 = Utils::toString(callId);
DRing::refuse(callId2);
}
break;
case Request::AcceptIncommingCall:
{
auto callId = task->_call->callId;
auto callId2 = Utils::toString(callId);
DRing::accept(callId2);
}
break;
default:
break;
}
......
......@@ -58,6 +58,8 @@ internal:
void sendAccountTextMessage(String^ message);
void createRINGAccount(String^ alias);
void createSIPAccount(String^ alias);
void refuseIncommingCall(Call^ call);
void acceptIncommingCall(Call^ call);
/* TODO : move members */
bool hasConfig;
......@@ -73,14 +75,23 @@ private:
enum class Request {
None,
AddRingAccount,
AddSIPAccount
AddSIPAccount,
RefuseIncommingCall,
AcceptIncommingCall
};
ref class Task
{
internal:
Task(Request r) { request = r; }
Task(Request r) {
request = r;
}
Task(Request r, Call^ c) {
request = r;
_call = c;
}
public:
property Request request;
property Call^ _call;
};
/* functions */
......
......@@ -32,7 +32,7 @@
<RowDefinition Height="60"/>
<!-- use the height of _contactBar_ to make it visible or collapsed. -->
<RowDefinition x:Name="_contactBar_"
Height="0"/>
Height="{x:Bind _contactBarHeight, Mode=OneWay}"/>
</Grid.RowDefinitions>
<Grid Grid.Row="0">
<Grid.ColumnDefinitions>
......@@ -100,10 +100,12 @@
Grid.Row="0"
HorizontalAlignment="Center">
<Button x:Name="_acceptIncomingCallBtn_"
Click="_acceptIncomingCallBtn__Click"
VerticalAlignment="Center"
HorizontalAlignment="Center"
Content="Accept"/>
<Button x:Name="_rejectIncomingCallBtn_"
Click="_rejectIncomingCallBtn__Click"
VerticalAlignment="Center"
HorizontalAlignment="Center"
Content="Reject"/>
......
......@@ -34,6 +34,10 @@ using namespace Windows::UI::Xaml::Media;
using namespace Concurrency;
using namespace Windows::Foundation;
using namespace Windows::ApplicationModel::Core;
using namespace Windows::Storage;
using namespace Windows::UI::Core;
SmartPanel::SmartPanel()
{
InitializeComponent();
......@@ -138,22 +142,22 @@ void RingClientUWP::Views::SmartPanel::_createAccountYes__Click(Platform::Object
switch (_accountTypeComboBox_->SelectedIndex)
{
case 0:
{
RingD::instance->createRINGAccount(_aliasTextBox_->Text);
_accountCreationMenuGrid_->Visibility = Windows::UI::Xaml::Visibility::Collapsed;
_accountsMenuButton__Checked(nullptr, nullptr);
break;
}
{
RingD::instance->createRINGAccount(_aliasTextBox_->Text);
_accountCreationMenuGrid_->Visibility = Windows::UI::Xaml::Visibility::Collapsed;
_accountsMenuButton__Checked(nullptr, nullptr);
break;
}
break;
case 1:
{
RingD::instance->createSIPAccount(_aliasTextBox_->Text);
_accountCreationMenuGrid_->Visibility = Windows::UI::Xaml::Visibility::Collapsed;
_accountsMenuButton__Checked(nullptr, nullptr);
break;
}
default:
break;
{
RingD::instance->createSIPAccount(_aliasTextBox_->Text);
_accountCreationMenuGrid_->Visibility = Windows::UI::Xaml::Visibility::Collapsed;
_accountsMenuButton__Checked(nullptr, nullptr);
break;
}
default:
break;
}
}
......@@ -189,3 +193,25 @@ void RingClientUWP::Views::SmartPanel::_ringTxtBx__KeyDown(Platform::Object^ sen
_ringTxtBx_->Text = "";
}
}
void RingClientUWP::Views::SmartPanel::_rejectIncomingCallBtn__Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
{
auto button = dynamic_cast<Button^>(e->OriginalSource);
auto contact = dynamic_cast<Contact^>(button->DataContext);
auto call = contact->_call;
call->refuse();
contact->_contactBarHeight = 0;
}
void RingClientUWP::Views::SmartPanel::_acceptIncomingCallBtn__Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
{
auto button = dynamic_cast<Button^>(e->OriginalSource);
auto contact = dynamic_cast<Contact^>(button->DataContext);
auto call = contact->_call;
call->accept();
contact->_contactBarHeight = 0;
}
......@@ -53,6 +53,8 @@ private:
void _smartList__SelectionChanged(Platform::Object^ sender, Windows::UI::Xaml::Controls::SelectionChangedEventArgs^ e);
void _accountList__SelectionChanged(Platform::Object^ sender, Windows::UI::Xaml::Controls::SelectionChangedEventArgs^ e);
void _ringTxtBx__KeyDown(Platform::Object^ sender, Windows::UI::Xaml::Input::KeyRoutedEventArgs^ e);
void _rejectIncomingCallBtn__Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
void _acceptIncomingCallBtn__Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
};
}
}
\ No newline at end of file
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