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
diff --git a/Call.cpp b/Call.cpp
index 24e4353..6b02ec7 100644
--- a/Call.cpp
+++ b/Call.cpp
@@ -53,4 +53,14 @@
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);
+}
diff --git a/Call.h b/Call.h
index aa96993..c0d4fa1 100644
--- a/Call.h
+++ b/Call.h
@@ -43,6 +43,9 @@
/* properties */
void NotifyPropertyChanged(String^ propertyName);
+internal:
+ void refuse();
+ void accept();
};
}
diff --git a/CallsViewModel.cpp b/CallsViewModel.cpp
index cf6166f..02a4933 100644
--- a/CallsViewModel.cpp
+++ b/CallsViewModel.cpp
@@ -43,11 +43,11 @@
if (state == "OVER") {
delete call;
call->stateChange("", code);
- callStatusUpdated(call);
+ callStatusUpdated(call); // used ?
return;
}
call->stateChange(state, code);
- callStatusUpdated(call);
+ callStatusUpdated(call); // same...
return;
}
}
diff --git a/Contact.h b/Contact.h
index 517d35c..a88d648 100644
--- a/Contact.h
+++ b/Contact.h
@@ -83,6 +83,18 @@
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 @@
Conversation^ conversation_;
Visibility notificationNewMessage_;
unsigned int unreadMessages_;
- Windows::UI::Xaml::GridLength contactBarHeight_;
+ Windows::UI::Xaml::GridLength contactBarHeight_ = 0;
Call^ call_;
};
}
diff --git a/ContactsViewModel.cpp b/ContactsViewModel.cpp
index 68141b5..7ac6dc8 100644
--- a/ContactsViewModel.cpp
+++ b/ContactsViewModel.cpp
@@ -79,6 +79,8 @@
return;
}
contact->_call = call;
+ contact->_contactBarHeight = 50;
+
});
}
diff --git a/RingD.cpp b/RingD.cpp
index ea6db14..3abac15 100644
--- a/RingD.cpp
+++ b/RingD.cpp
@@ -102,6 +102,7 @@
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 @@
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 @@
}
}),
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 @@
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 @@
{
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 @@
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;
}
diff --git a/RingD.h b/RingD.h
index 4026c54..ceff044 100644
--- a/RingD.h
+++ b/RingD.h
@@ -58,6 +58,8 @@
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 @@
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 */
diff --git a/SmartPanel.xaml b/SmartPanel.xaml
index d113973..65d0543 100644
--- a/SmartPanel.xaml
+++ b/SmartPanel.xaml
@@ -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"/>
diff --git a/SmartPanel.xaml.cpp b/SmartPanel.xaml.cpp
index 2742708..8ee8d73 100644
--- a/SmartPanel.xaml.cpp
+++ b/SmartPanel.xaml.cpp
@@ -34,6 +34,10 @@
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 @@
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 @@
_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;
+}
diff --git a/SmartPanel.xaml.h b/SmartPanel.xaml.h
index 29e6a56..1b2f63f 100644
--- a/SmartPanel.xaml.h
+++ b/SmartPanel.xaml.h
@@ -53,6 +53,8 @@
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