diff --git a/ContactsViewModel.cpp b/ContactsViewModel.cpp index 099004c44ec8692bbee5044787b94310dca08fee..74e995b94e909b0dad2bd0718972c83e342f53a7 100644 --- a/ContactsViewModel.cpp +++ b/ContactsViewModel.cpp @@ -39,7 +39,7 @@ ContactsViewModel::ContactsViewModel() /* connect delegates. */ RingD::instance->incomingAccountMessage += ref new IncomingAccountMessage([&](String^ accountId, String^ fromRingId, String^ payload) { - auto contact = findContactByName(fromRingId); + auto contact = findContactByRingId(fromRingId); if (contact == nullptr) contact = addNewContact(fromRingId, fromRingId); // contact checked inside addNewContact. @@ -80,11 +80,21 @@ ContactsViewModel::findContactByName(String^ name) return nullptr; } +Contact ^ RingClientUWP::ViewModel::ContactsViewModel::findContactByRingId(String^ ringId) +{ + for each (Contact^ contact in contactsList_) + if (contact->ringID_ == ringId) + return contact; + + return nullptr; +} + Contact^ ContactsViewModel::addNewContact(String^ name, String^ ringId) { auto trimmedName = Utils::Trim(name); if (contactsList_ && !findContactByName(trimmedName)) { + //if (contactsList_ && !findContactByName(trimmedName) && !findContactByRingId(ringId)) { Contact^ contact = ref new Contact(trimmedName, ringId, nullptr, 0); contactsList_->Append(contact); saveContactsToFile(); @@ -229,4 +239,4 @@ void ContactsViewModel::modifyContact(Contact^ contact) { contactDataModified(contact); -} \ No newline at end of file +} diff --git a/ContactsViewModel.h b/ContactsViewModel.h index 06464ffc222056091210dd01ccca7a6435307c19..bda642e30d462e2a7bc2166244a82c55c8967824 100644 --- a/ContactsViewModel.h +++ b/ContactsViewModel.h @@ -46,6 +46,7 @@ internal: /* functions */ Contact^ findContactByName(String^ name); + Contact^ findContactByRingId(String^ ringId); Contact^ addNewContact(String^ name, String^ ringId); void saveContactsToFile(); void openContactsFromFile(); diff --git a/MainPage.xaml.cpp b/MainPage.xaml.cpp index 7914e555d58408490e8cab5ef682db36adecb60e..2cbee80483ef953861da5f16728be2e049a90011 100644 --- a/MainPage.xaml.cpp +++ b/MainPage.xaml.cpp @@ -249,6 +249,7 @@ void RingClientUWP::MainPage::OnhidePreviewPage() void RingClientUWP::MainPage::OnsummonVideoPage() { auto videoPage = dynamic_cast<VideoPage^>(_videoFrame_->Content); + videoPage->chatOpen = false; videoPage->updatePageContent(); showFrame(_videoFrame_); } diff --git a/MessageTextPage.xaml b/MessageTextPage.xaml index e72ea6fff22a2daf6e71621b2bd09a12aa3cf7c6..1fa6f4d7c8fd23e4de8e4d994fc83b9aa937506d 100644 --- a/MessageTextPage.xaml +++ b/MessageTextPage.xaml @@ -135,13 +135,13 @@ <Grid Background="#FFF2F2F2"> <Grid.RowDefinitions> - <RowDefinition Height="auto" /> + <RowDefinition Height="90" /> <RowDefinition Height="*"/> <RowDefinition Height="auto" /> </Grid.RowDefinitions> <StackPanel Grid.Row="0" Background="White" - Height="70" + Height="90" Orientation="Horizontal" Padding="10,10"> <Image Source="ms-appx:///contact-avatar-test.png" /> diff --git a/RingD.cpp b/RingD.cpp index 2e8e72257ce90198a656458a000a7f619388cd81..928ac9794acb839897bd7acb8e7f4f8cf131e759 100644 --- a/RingD.cpp +++ b/RingD.cpp @@ -401,9 +401,12 @@ RingD::registerCallbacks() 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; + auto contact = ContactsViewModel::instance->findContactByRingId(from2); + if (contact) { + auto item = SmartPanelItemsViewModel::instance->findItem(contact); + if (item) + item->_callId = callId2; + } })); }), DRing::exportable_callback<DRing::CallSignal::StateChange>([this]( @@ -422,7 +425,7 @@ RingD::registerCallbacks() auto state3 = translateCallStatus(state2); if (state3 == CallStatus::OUTGOING_RINGING || - state3 == CallStatus::INCOMING_RINGING) { + state3 == CallStatus::INCOMING_RINGING) { try { Configuration::UserPreferences::instance->sendVCard(callId); } @@ -491,7 +494,6 @@ RingD::registerCallbacks() CoreDispatcherPriority::High, ref new DispatchedHandler([=]() { incomingMessage(callId2, payload); - MSG_("message recu :" + i.second); })); } }), @@ -980,6 +982,10 @@ RingD::dequeueTasks() case Request::GetCallsList: { auto callsList = DRing::getCallList(); + dispatcher->RunAsync(CoreDispatcherPriority::High, + ref new DispatchedHandler([&]() { + callsListRecieved(callsList); + })); MSG_("list of calls returned by the daemon :"); for (auto call : callsList) MSG_(call); diff --git a/RingD.h b/RingD.h index b7db294e6de41129672663dc18cf578d609a95b3..28b0f75c98a6c1a8fa81c96cee8533e93dc63275 100644 --- a/RingD.h +++ b/RingD.h @@ -42,6 +42,7 @@ delegate void RegisteredNameFound(LookupStatus status, const std::string& addres delegate void FinishCaptureDeviceEnumeration(); delegate void RegistrationStateErrorGeneric(const std::string& accountId); delegate void RegistrationStateRegistered(); +delegate void CallsListRecieved(const std::vector<std::string>& callsList); using SharedCallback = std::shared_ptr<DRing::CallbackWrapperBase>; using namespace std::placeholders; @@ -151,6 +152,7 @@ internal: event FinishCaptureDeviceEnumeration^ finishCaptureDeviceEnumeration; event RegistrationStateErrorGeneric^ registrationStateErrorGeneric; event RegistrationStateRegistered^ registrationStateRegistered; + event CallsListRecieved^ callsListRecieved; // est implemente a la base pour regler le probleme du boutton d'appel qui est present lorsqu'un appel est en cours, mais il n'est pas utilise. Voir si ca peut servir a autre chose private: /* sub classes */ diff --git a/SmartPanel.xaml.cpp b/SmartPanel.xaml.cpp index 4d41fbb97059325c651bc3f09aa4624c11028347..813089c0234d811895ede35f10c771760b7d33af 100644 --- a/SmartPanel.xaml.cpp +++ b/SmartPanel.xaml.cpp @@ -91,7 +91,7 @@ SmartPanel::SmartPanel() RingD::instance->incomingCall += ref new RingClientUWP::IncomingCall([&]( String^ accountId, String^ callId, String^ from) { ///auto from = call->from; - auto contact = ContactsViewModel::instance->findContactByName(from); + auto contact = ContactsViewModel::instance->findContactByRingId(from); if (contact == nullptr) contact = ContactsViewModel::instance->addNewContact(from, from); // contact checked inside addNewContact. @@ -513,7 +513,21 @@ void RingClientUWP::Views::SmartPanel::Grid_PointerEntered(Platform::Object^ sen for (auto it : SmartPanelItemsViewModel::instance->itemsList) it->_hovered = Windows::UI::Xaml::Visibility::Collapsed; - item->_hovered = Windows::UI::Xaml::Visibility::Visible; + /// to keep for future use, when we will be able to do several calls. + ///if (item->_callStatus == CallStatus::NONE || item->_callStatus == CallStatus::ENDED) + /// item->_hovered = Windows::UI::Xaml::Visibility::Visible; + + /// for now use this, do not merge with the for loop above, to make easier to remove that part later + bool anyCall = false; + for (auto it : SmartPanelItemsViewModel::instance->itemsList) { + if (it->_callStatus != CallStatus::NONE && it->_callStatus != CallStatus::ENDED) + anyCall = true; + } + + if (anyCall == false) + item->_hovered = Windows::UI::Xaml::Visibility::Visible; + + } @@ -1202,7 +1216,21 @@ void RingClientUWP::Views::SmartPanel::Grid_PointerMoved(Platform::Object^ sende for (auto it : SmartPanelItemsViewModel::instance->itemsList) it->_hovered = Windows::UI::Xaml::Visibility::Collapsed; - item->_hovered = Windows::UI::Xaml::Visibility::Visible; + /// to keep for future use, when we will be able to do several calls. + ///if (item->_callStatus == CallStatus::NONE || item->_callStatus == CallStatus::ENDED) + /// item->_hovered = Windows::UI::Xaml::Visibility::Visible; + + /// for now use this, do not merge with the for loop above, to make easier to remove that part later + bool anyCall = false; + for (auto it : SmartPanelItemsViewModel::instance->itemsList) { + if (it->_callStatus != CallStatus::NONE && it->_callStatus != CallStatus::ENDED) + anyCall = true; + } + + if (anyCall == false) + item->_hovered = Windows::UI::Xaml::Visibility::Visible; + + } // NAME SERVICE diff --git a/VideoPage.xaml.cpp b/VideoPage.xaml.cpp index 9a2798b37b9dd79eedfb240a8b1c95bd7ec5fae3..d8342d932b6ff837da4afc1d350e8b34cdd439a6 100644 --- a/VideoPage.xaml.cpp +++ b/VideoPage.xaml.cpp @@ -135,6 +135,7 @@ void RingClientUWP::Views::VideoPage::OnNavigatedTo(Windows::UI::Xaml::Navigation::NavigationEventArgs^ e) { updatePageContent(); + _rowChatBx_->Height = 0; } void RingClientUWP::Views::VideoPage::updatePageContent() @@ -224,13 +225,14 @@ void RingClientUWP::Views::VideoPage::_btnPause__Tapped(Platform::Object^ sender void RingClientUWP::Views::VideoPage::_btnChat__Tapped(Platform::Object^ sender, Windows::UI::Xaml::Input::TappedRoutedEventArgs^ e) { chatOpen = !chatOpen; - if (chatOpen) { + _rowChatBx_->Height = (chatOpen) ? 200 : 0; + /*if (chatOpen) { _rowChatBx_->Height = 200; chatPanelCall(); } else { _rowChatBx_->Height = 0; - } + }*/ } @@ -343,6 +345,20 @@ VideoPage::WriteFrameAsSoftwareBitmapAsync(String^ id, uint8_t* buf, int width, void RingClientUWP::Views::VideoPage::OnincomingMessage(Platform::String ^callId, Platform::String ^payload) { + if (!chatOpen) { + _rowChatBx_->Height = 200; + chatOpen = true; + } + + auto item = SmartPanelItemsViewModel::instance->_selectedItem; + + //if (item) + // if (item->_callId != callId) { + // SmartPanelItemsViewModel::instance->findItem(callId)->_contact->_unreadMessages++; + // //item->_contact->_unreadMessages++; + // } + + scrollDown(); } diff --git a/VideoPage.xaml.h b/VideoPage.xaml.h index b3048d87e91c5dd49548681cbe3a0f081689e4eb..ef4cb8b1609f9a0dcf2601d2c78630d95d6b16d0 100644 --- a/VideoPage.xaml.h +++ b/VideoPage.xaml.h @@ -34,7 +34,7 @@ namespace RingClientUWP /* delegate */ delegate void PressHangUpCall(); delegate void PauseCall(); -delegate void ChatPanelCall(); +delegate void ChatPanelCall(); // nobody use this ? delegate void AddContactCall(); delegate void TransferCall(); delegate void SwitchMicrophoneStateCall(); @@ -63,7 +63,7 @@ public: } } - property bool chatOpen + property bool chatOpen // use this with a converter to set the height to 200px for the chatpanel... { bool get() {