Commit 9edbea38 authored by Nicolas Jager's avatar Nicolas Jager

internal : remove call object and call view model

Change-Id: Ie2449d1ea83e702cad1266241d9c0f254ef271aa
Tuleap: #1204
parent 4cdd8926
......@@ -43,7 +43,7 @@ Account::NotifyPropertyChanged(String^ propertyName)
{
CoreApplicationView^ view = CoreApplication::MainView;
view->CoreWindow->Dispatcher->RunAsync(
CoreDispatcherPriority::Normal,
CoreDispatcherPriority::High,
ref new DispatchedHandler([this, propertyName]()
{
PropertyChanged(this, ref new PropertyChangedEventArgs(propertyName));
......
......@@ -44,7 +44,7 @@ Call::NotifyPropertyChanged(String^ propertyName)
{
CoreApplicationView^ view = CoreApplication::MainView;
view->CoreWindow->Dispatcher->RunAsync(
CoreDispatcherPriority::Normal,
CoreDispatcherPriority::High,
ref new DispatchedHandler([this, propertyName]()
{
PropertyChanged(this, ref new PropertyChangedEventArgs(propertyName));
......@@ -52,17 +52,18 @@ Call::NotifyPropertyChanged(String^ propertyName)
}));
}
void RingClientUWP::Call::refuse()
{
RingD::instance->refuseIncommingCall(this);
}
void RingClientUWP::Call::accept()
{
RingD::instance->acceptIncommingCall(this);
}
void RingClientUWP::Call::cancel()
{
RingD::instance->cancelOutGoingCall(this);
}
//void RingClientUWP::Call::refuse()
//{
// RingD::instance->refuseIncommingCall(this);
//}
//
//void RingClientUWP::Call::accept()
//{
// RingD::instance->acceptIncommingCall(this);
//}
//
//void RingClientUWP::Call::cancel()
//{
// MSG_("!2--->> cancel");
// RingD::instance->cancelOutGoingCall(this);
//}
......@@ -56,9 +56,9 @@ protected:
void NotifyPropertyChanged(String^ propertyName);
internal:
void refuse();
void accept();
void cancel();
//void refuse();
//void accept();
//void cancel();
private:
CallStatus state_;
......
......@@ -44,7 +44,7 @@ internal:
/* functions */
Call^ addNewCall(String^ accountId, String^ callId, String^ from);
void clearCallsList();
void setState(String^ callId, String^ state, int code); // used ?
//void setState(String^ callId, String^ state, int code); // used ?
Call^ findCall(String^ callId);
/* properties */
......
......@@ -52,7 +52,7 @@ Contact::Contact(String^ name,
String^ fileContents = Utils::toPlatformString(Utils::getStringFromFile(Utils::toString(messagesFile)));
CoreApplication::MainView->CoreWindow->Dispatcher->RunAsync(CoreDispatcherPriority::Normal,
CoreApplication::MainView->CoreWindow->Dispatcher->RunAsync(CoreDispatcherPriority::High,
ref new DispatchedHandler([=]() {
if (fileContents != nullptr)
DestringifyConversation(fileContents);
......@@ -72,7 +72,7 @@ Contact::NotifyPropertyChanged(String^ propertyName)
{
CoreApplicationView^ view = CoreApplication::MainView;
view->CoreWindow->Dispatcher->RunAsync(
CoreDispatcherPriority::Normal,
CoreDispatcherPriority::High,
ref new DispatchedHandler([this, propertyName]()
{
PropertyChanged(this, ref new PropertyChangedEventArgs(propertyName));
......
......@@ -118,7 +118,7 @@ ContactsViewModel::openContactsFromFile()
String^ fileContents = Utils::toPlatformString(Utils::getStringFromFile(Utils::toString(contactsFile)));
CoreApplication::MainView->CoreWindow->Dispatcher->RunAsync(CoreDispatcherPriority::Normal,
CoreApplication::MainView->CoreWindow->Dispatcher->RunAsync(CoreDispatcherPriority::High,
ref new DispatchedHandler([=]() {
if (fileContents != nullptr)
Destringify(fileContents);
......
......@@ -53,13 +53,13 @@ LoadingPage::LoadingPage()
{
if (config_exists) {
RingD::instance->hasConfig = true;
this->Dispatcher->RunAsync(Windows::UI::Core::CoreDispatcherPriority::Normal, ref new Windows::UI::Core::DispatchedHandler([this] () {
this->Dispatcher->RunAsync(Windows::UI::Core::CoreDispatcherPriority::High, ref new Windows::UI::Core::DispatchedHandler([this] () {
this->Frame->Navigate(Windows::UI::Xaml::Interop::TypeName(MainPage::typeid));
}));
}
else {
RingD::instance->hasConfig = false;
this->Dispatcher->RunAsync(Windows::UI::Core::CoreDispatcherPriority::Normal, ref new Windows::UI::Core::DispatchedHandler([this] () {
this->Dispatcher->RunAsync(Windows::UI::Core::CoreDispatcherPriority::High, ref new Windows::UI::Core::DispatchedHandler([this] () {
this->Frame->Navigate(Windows::UI::Xaml::Interop::TypeName(Wizard::typeid));
}));
}
......
......@@ -126,6 +126,7 @@ void RingClientUWP::RingD::acceptIncommingCall(Call^ call)
void RingClientUWP::RingD::placeCall(Contact^ contact)
{
MSG_("!--->> placeCall");
auto to = contact->ringID_;
auto accountId = AccountsViewModel::instance->selectedAccount->accountID_;
......@@ -134,6 +135,8 @@ void RingClientUWP::RingD::placeCall(Contact^ contact)
auto callId2 = DRing::placeCall(accountId2, to2);
if (callId2 == "") {
WNG_("call not created, the daemon didn't return a call Id");
return;
......@@ -141,6 +144,13 @@ void RingClientUWP::RingD::placeCall(Contact^ contact)
auto callId = Utils::toPlatformString(callId2);
//auto con = ContactsViewModel::instance->findContactByName(to);
auto item = SmartPanelItemsViewModel::instance->findItem(contact);
item->_callId = callId;
MSG_("$1 place call with id : " + Utils::toString(item->_callId));
auto call = CallsViewModel::instance->addNewCall(accountId, callId, to);
call->isOutGoing = true;
......@@ -156,7 +166,15 @@ void RingClientUWP::RingD::placeCall(Contact^ contact)
void
RingClientUWP::RingD::cancelOutGoingCall(Call^ call)
{
tasksList_.push(ref new RingD::Task(Request::CancelOutGoingCall, call));
MSG_("1!--->> cancelOutGoingCall");
if (call)
tasksList_.push(ref new RingD::Task(Request::CancelOutGoingCall, call));
}
void RingClientUWP::RingD::cancelOutGoingCall2(String ^ callId)
{
MSG_("$1 cancelOutGoingCall2 : " + Utils::toString(callId));
tasksList_.push(ref new RingD::Task(Request::HangUpCall, callId, 0));
}
void
......@@ -165,6 +183,12 @@ RingClientUWP::RingD::hangUpCall(Call^ call)
tasksList_.push(ref new RingD::Task(Request::HangUpCall, call));
}
void RingClientUWP::RingD::hangUpCall2(String ^ callId)
{
MSG_("$1 hangUpCall2 : "+Utils::toString(callId));
tasksList_.push(ref new RingD::Task(Request::HangUpCall, callId, 0));
}
void
RingClientUWP::RingD::startDaemon()
{
......@@ -199,10 +223,16 @@ RingClientUWP::RingD::startDaemon()
from2 = Utils::TrimRingId(from2);
CoreApplication::MainView->CoreWindow->Dispatcher->RunAsync(
CoreDispatcherPriority::Normal, ref new DispatchedHandler([=]()
CoreDispatcherPriority::High, ref new DispatchedHandler([=]()
{
incomingCall(accountId2, callId2, from2);
stateChange(callId2, CallStatus::INCOMING_RINGING, 0);
auto contact = ContactsViewModel::instance->findContactByName(from2);
auto item = SmartPanelItemsViewModel::instance->findItem(contact);
item->_callId = callId2;
}));
}),
DRing::exportable_callback<DRing::CallSignal::StateChange>([this](
......@@ -222,7 +252,7 @@ RingClientUWP::RingD::startDaemon()
CoreApplication::MainView->CoreWindow->Dispatcher->RunAsync(
CoreDispatcherPriority::Low, ref new DispatchedHandler([=]()
CoreDispatcherPriority::High, ref new DispatchedHandler([=]()
{
stateChange(callId2, state3, code);
}));
......@@ -243,7 +273,7 @@ RingClientUWP::RingD::startDaemon()
MSG_("payload = " + i.second);
auto payload = Utils::toPlatformString(i.second);
CoreApplication::MainView->CoreWindow->Dispatcher->RunAsync(
CoreDispatcherPriority::Low, ref new DispatchedHandler([=]()
CoreDispatcherPriority::High, ref new DispatchedHandler([=]()
{
incomingAccountMessage(accountId2, from2, payload);
}));
......@@ -282,7 +312,7 @@ RingClientUWP::RingD::startDaemon()
auto payload = Utils::toPlatformString(i.second);
CoreApplication::MainView->CoreWindow->Dispatcher->RunAsync(
CoreDispatcherPriority::Low, ref new DispatchedHandler([=]()
CoreDispatcherPriority::High, ref new DispatchedHandler([=]()
{
incomingAccountMessage(accountId2, from2, payload);
}));
......@@ -294,7 +324,7 @@ RingClientUWP::RingD::startDaemon()
{
MSG_("<RegistrationStateChanged>: ID = " + account_id + "state = " + state);
if (state == DRing::Account::States::REGISTERED) {
CoreApplication::MainView->CoreWindow->Dispatcher->RunAsync(CoreDispatcherPriority::Normal,
CoreApplication::MainView->CoreWindow->Dispatcher->RunAsync(CoreDispatcherPriority::High,
ref new DispatchedHandler([=]() {
auto frame = dynamic_cast<Frame^>(Window::Current->Content);
dynamic_cast<RingClientUWP::MainPage^>(frame->Content)->showLoadingOverlay(false, false);
......@@ -303,14 +333,14 @@ RingClientUWP::RingD::startDaemon()
}),
DRing::exportable_callback<DRing::ConfigurationSignal::AccountsChanged>([this]()
{
CoreApplication::MainView->CoreWindow->Dispatcher->RunAsync(CoreDispatcherPriority::Normal,
CoreApplication::MainView->CoreWindow->Dispatcher->RunAsync(CoreDispatcherPriority::High,
ref new DispatchedHandler([=]() {
reloadAccountList();
}));
}),
DRing::exportable_callback<DRing::Debug::MessageSend>([&](const std::string& toto)
{
dispatcher->RunAsync(CoreDispatcherPriority::Normal,
dispatcher->RunAsync(CoreDispatcherPriority::High,
ref new DispatchedHandler([=]() {
RingDebug::instance->print(toto);
}));
......@@ -359,9 +389,9 @@ RingClientUWP::RingD::startDaemon()
{
DRing::exportable_callback<DRing::VideoSignal::GetCameraInfo>
([this](const std::string& device,
std::vector<std::string> *formats,
std::vector<unsigned> *sizes,
std::vector<unsigned> *rates) {
std::vector<std::string> *formats,
std::vector<unsigned> *sizes,
std::vector<unsigned> *rates) {
MSG_("\n<GetCameraInfo>\n");
auto device_list = VideoManager::instance->captureManager()->deviceList;
......@@ -384,7 +414,7 @@ RingClientUWP::RingD::startDaemon()
std::string format,
const int width,
const int height,
const int rate) {
const int rate) {
MSG_("\n<SetParameters>\n");
VideoManager::instance->captureManager()->activeDevice->SetDeviceProperties(
Utils::toPlatformString(format),width,height,rate);
......@@ -392,7 +422,7 @@ RingClientUWP::RingD::startDaemon()
DRing::exportable_callback<DRing::VideoSignal::StartCapture>
([&](const std::string& device) {
MSG_("\n<StartCapture>\n");
dispatcher->RunAsync(CoreDispatcherPriority::Normal,
dispatcher->RunAsync(CoreDispatcherPriority::High,
ref new DispatchedHandler([=]() {
VideoManager::instance->captureManager()->InitializeCameraAsync();
VideoManager::instance->captureManager()->videoFrameCopyInvoker->Start();
......@@ -401,7 +431,7 @@ RingClientUWP::RingD::startDaemon()
DRing::exportable_callback<DRing::VideoSignal::StopCapture>
([&]() {
MSG_("\n<StopCapture>\n");
dispatcher->RunAsync(CoreDispatcherPriority::Normal,
dispatcher->RunAsync(CoreDispatcherPriority::High,
ref new DispatchedHandler([=]() {
VideoManager::instance->captureManager()->StopPreviewAsync();
if (VideoManager::instance->captureManager()->captureTaskTokenSource)
......@@ -425,7 +455,7 @@ RingClientUWP::RingD::startDaemon()
tasksList_.push(ref new RingD::Task(Request::AddSIPAccount));
}
else {
CoreApplication::MainView->CoreWindow->Dispatcher->RunAsync(CoreDispatcherPriority::Normal,
CoreApplication::MainView->CoreWindow->Dispatcher->RunAsync(CoreDispatcherPriority::High,
ref new DispatchedHandler([=]() {
reloadAccountList();
}));
......@@ -487,6 +517,12 @@ RingD::dequeueTasks()
case Request::CancelOutGoingCall:
case Request::HangUpCall:
{
MSG_("1!--->> Request::CancelOutGoingCall");
auto id = task->_callId;
DRing::hangUp(Utils::toString(id));
return;
auto callId = task->_call->callId;
auto callId2 = Utils::toString(callId);
DRing::hangUp(callId2);
......
......@@ -52,6 +52,9 @@ public:
}
}
void cancelOutGoingCall2(String^ callId); // marche
internal:
/* functions */
void startDaemon();
......@@ -63,7 +66,10 @@ internal:
void acceptIncommingCall(Call^ call);
void placeCall(Contact^ contact);
void cancelOutGoingCall(Call^ call);
/*void cancelOutGoingCall2(String^ callId);*/ // marche pas
void hangUpCall(Call^ call);
void hangUpCall2(String^ callId);
/* TODO : move members */
bool hasConfig;
......@@ -96,9 +102,14 @@ private:
request = r;
_call = c;
}
Task(Request r, String^ c, int i) {
request = r;
_callId = c;
}
public:
property Request request;
property Call^ _call;
property String^ _callId;
};
/* functions */
......
......@@ -68,13 +68,13 @@ void WriteException(Exception^ ex)
OutputDebugString(wStringstream.str().c_str());
}
#define MSG_(cstr) CoreApplication::MainView->CoreWindow->Dispatcher->RunAsync(CoreDispatcherPriority::Low, \
#define MSG_(cstr) CoreApplication::MainView->CoreWindow->Dispatcher->RunAsync(CoreDispatcherPriority::High, \
ref new DispatchedHandler([=]() { RingDebug::instance->print(cstr); }))
#define WNG_(cstr) CoreApplication::MainView->CoreWindow->Dispatcher->RunAsync(CoreDispatcherPriority::Low, \
#define WNG_(cstr) CoreApplication::MainView->CoreWindow->Dispatcher->RunAsync(CoreDispatcherPriority::High, \
ref new DispatchedHandler([=]() { RingDebug::instance->print(std::string(cstr), RingDebug::Type::WNG); }))
#define ERR_(cstr) CoreApplication::MainView->CoreWindow->Dispatcher->RunAsync(CoreDispatcherPriority::Low, \
#define ERR_(cstr) CoreApplication::MainView->CoreWindow->Dispatcher->RunAsync(CoreDispatcherPriority::High, \
ref new DispatchedHandler([=]() { RingDebug::instance->print(std::string(cstr), RingDebug::Type::ERR); }))
}
......@@ -108,6 +108,7 @@ SmartPanel::SmartPanel()
RingD::instance->calling += ref new RingClientUWP::Calling([&](
Call^ call) {
MSG_("!--->> Calling lambda from smartpanel");
auto from = call->from;
auto contact = ContactsViewModel::instance->findContactByName(from);
......@@ -124,6 +125,7 @@ SmartPanel::SmartPanel()
}
call->state = CallStatus::SEARCHING;
MSG_("!--->> should be Searching");
item->_call = call;
});
......@@ -321,40 +323,63 @@ void RingClientUWP::Views::SmartPanel::_ringTxtBx__Click(Platform::Object^ sende
void RingClientUWP::Views::SmartPanel::_rejectIncomingCallBtn__Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
{
auto button = dynamic_cast<Button^>(e->OriginalSource);
auto item = dynamic_cast<SmartPanelItem^>(button->DataContext);
auto call = item->_call;
call->refuse();
if (button) {
auto item = dynamic_cast<SmartPanelItem^>(button->DataContext);
if (item) {
auto call = item->_call;
if (call)
RingD::instance->refuseIncommingCall(call);
//call->refuse();
}
}
}
void RingClientUWP::Views::SmartPanel::_acceptIncomingCallBtn__Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
{
auto button = dynamic_cast<Button^>(e->OriginalSource);
auto item = dynamic_cast<SmartPanelItem^>(button->DataContext);
auto call = item->_call;
call->accept();
if (button) {
auto item = dynamic_cast<SmartPanelItem^>(button->DataContext);
if (item) {
auto call = item->_call;
if (call)
RingD::instance->acceptIncommingCall(call);
//call->accept();
}
}
}
void
SmartPanel::_callContact__Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
{
MSG_("!--->> _callContact__Click");
auto button = dynamic_cast<Button^>(e->OriginalSource);
auto item = dynamic_cast<SmartPanelItem^>(button->DataContext);
auto contact = item->_contact;
RingD::instance->placeCall(contact);
if (button) {
auto item = dynamic_cast<SmartPanelItem^>(button->DataContext);
if (item) {
auto contact = item->_contact;
if (contact)
RingD::instance->placeCall(contact);
}
}
}
void RingClientUWP::Views::SmartPanel::_cancelCallBtn__Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
{
auto button = dynamic_cast<Button^>(e->OriginalSource);
auto item = dynamic_cast<SmartPanelItem^>(button->DataContext);
auto call = item->_call;
if (button) {
auto item = dynamic_cast<SmartPanelItem^>(button->DataContext);
if (item) {
auto call = item->_call;
RingD::instance->cancelOutGoingCall2(item->_callId);
call->cancel();
return;
if (call)
RingD::instance->cancelOutGoingCall(call);
//call->cancel();
}
}
}
......
......@@ -33,6 +33,8 @@ SmartPanelItem::SmartPanelItem()
{
/* create an empty call to avoid the call bar */
_call = ref new Call("", "", "");
_callId = "";
}
void
......@@ -40,7 +42,7 @@ SmartPanelItem::NotifyPropertyChanged(String^ propertyName)
{
CoreApplicationView^ view = CoreApplication::MainView;
view->CoreWindow->Dispatcher->RunAsync(
CoreDispatcherPriority::Normal,
CoreDispatcherPriority::High,
ref new DispatchedHandler([this, propertyName]()
{
PropertyChanged(this, ref new PropertyChangedEventArgs(propertyName));
......
......@@ -57,6 +57,8 @@ public:
}
}
property String^ _callId;
protected:
void NotifyPropertyChanged(String^ propertyName);
......
......@@ -73,6 +73,7 @@ private:
SmartPanelItem^ currentItem_;
SmartPanelItem^ oldItem_;
};
}
}
......@@ -50,7 +50,7 @@ UserPreferences::load()
String^ fileContents = Utils::toPlatformString(Utils::getStringFromFile(Utils::toString(preferencesFile)));
CoreApplication::MainView->CoreWindow->Dispatcher->RunAsync(CoreDispatcherPriority::Normal,
CoreApplication::MainView->CoreWindow->Dispatcher->RunAsync(CoreDispatcherPriority::High,
ref new DispatchedHandler([=]() {
if (fileContents != nullptr) {
Destringify(fileContents);
......
......@@ -61,14 +61,14 @@ VideoPage::VideoPage()
VideoManager::instance->rendererManager()->writeVideoFrame +=
ref new WriteVideoFrame([this](String^ id, uint8_t* buf, int width, int height)
{
CoreApplication::MainView->CoreWindow->Dispatcher->RunAsync(CoreDispatcherPriority::Normal,
CoreApplication::MainView->CoreWindow->Dispatcher->RunAsync(CoreDispatcherPriority::High,
ref new DispatchedHandler([=]() {
try {
if (!VideoManager::instance->rendererManager()->renderers->Size)
return;
VideoManager::instance->rendererManager()->renderer(id)->isRendering = true;
create_task(WriteFrameAsSoftwareBitmapAsync(id, buf, width, height))
.then([=](task<void> previousTask) {
.then([=](task<void> previousTask) {
try {
previousTask.get();
}
......@@ -88,8 +88,8 @@ VideoPage::VideoPage()
{
PreviewImage->Visibility = Windows::UI::Xaml::Visibility::Visible;
PreviewImage->FlowDirection = VideoManager::instance->captureManager()->mirroringPreview ?
Windows::UI::Xaml::FlowDirection::RightToLeft :
Windows::UI::Xaml::FlowDirection::LeftToRight;
Windows::UI::Xaml::FlowDirection::RightToLeft :
Windows::UI::Xaml::FlowDirection::LeftToRight;
});
VideoManager::instance->captureManager()->stopPreviewing +=
......@@ -205,8 +205,15 @@ void RingClientUWP::Views::VideoPage::_btnHangUp__Tapped(Platform::Object^ sende
auto item = SmartPanelItemsViewModel::instance->_selectedItem;
auto call = item->_call;
if (call)
RingD::instance->hangUpCall(call);
/*if (call)
RingD::instance->hangUpCall(call);*/
if (item->_callId != "") {
MSG_("$1 item->callid != vide ");
RingD::instance->hangUpCall2(item->_callId);
item->_callId = "";
}
pressHangUpCall();
}
......@@ -325,7 +332,7 @@ VideoPage::WriteFrameAsSoftwareBitmapAsync(String^ id, uint8_t* buf, int width,
auto sbSource = ref new Media::Imaging::SoftwareBitmapSource();
return create_task(sbSource->SetBitmapAsync(frame))
.then([this, sbSource]()
.then([this, sbSource]()
{
try {
IncomingVideoImage->Source = sbSource;
......
......@@ -38,7 +38,7 @@ Wizard::_createAccountYes__Click(Object^ sender, RoutedEventArgs^ e)
std::string str(wstr.begin(), wstr.end());
RingD::instance->hasConfig = false;
RingD::instance->accountName = std::string(wstr.begin(), wstr.end());
this->Dispatcher->RunAsync(Windows::UI::Core::CoreDispatcherPriority::Normal, ref new Windows::UI::Core::DispatchedHandler([this] () {
this->Dispatcher->RunAsync(Windows::UI::Core::CoreDispatcherPriority::High, ref new Windows::UI::Core::DispatchedHandler([this] () {
this->Frame->Navigate(Windows::UI::Xaml::Interop::TypeName(RingClientUWP::MainPage::typeid));
}));
}
......
......@@ -26,6 +26,7 @@
#include <sstream>
#include <string>
/* required by generated headers. */
#include "App.xaml.h"
#include "Account.h"
......
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