From d57809fdabcf9bb1d1fa1d4d2bad9d72d5e6f2f7 Mon Sep 17 00:00:00 2001 From: Nicolas Jager <nicolas.jager@savoirfairelinux.com> Date: Thu, 6 Oct 2016 11:31:55 -0400 Subject: [PATCH] fix : incomming sip message Change-Id: Ifc5bfb1c076816767c350a34d88d5efc102e3122 Tuleap: #1210 --- ContactsViewModel.cpp | 9 ++++++--- ContactsViewModel.h | 2 +- MessageTextPage.xaml.cpp | 2 +- MessageTextPage.xaml.h | 2 +- RingD.cpp | 4 ++-- RingD.h | 2 +- Utils.h | 21 ++++++++++++++++++++- VideoPage.xaml.cpp | 2 +- VideoPage.xaml.h | 2 +- 9 files changed, 34 insertions(+), 12 deletions(-) diff --git a/ContactsViewModel.cpp b/ContactsViewModel.cpp index 7fab743..0d21e36 100644 --- a/ContactsViewModel.cpp +++ b/ContactsViewModel.cpp @@ -170,9 +170,12 @@ ContactsViewModel::Destringify(String^ data) } -void RingClientUWP::ViewModel::ContactsViewModel::OnincomingMessage(Platform::String ^callId, Platform::String ^from, Platform::String ^payload) +void RingClientUWP::ViewModel::ContactsViewModel::OnincomingMessage(Platform::String ^callId, Platform::String ^payload) { - auto contact = findContactByName(from); + + auto item = SmartPanelItemsViewModel::instance->findItem(callId); + auto contact = item->_contact; + /* the contact HAS TO BE already registered */ if (contact) { @@ -185,7 +188,7 @@ void RingClientUWP::ViewModel::ContactsViewModel::OnincomingMessage(Platform::St auto selectedContact = (item) ? item->_contact : nullptr; - if (contact->ringID_ == from && contact != selectedContact) { + if (contact != selectedContact) { contact->_unreadMessages++; /* saveContactsToFile used to save the notification */ saveContactsToFile(); diff --git a/ContactsViewModel.h b/ContactsViewModel.h index b8d720f..b6ee05f 100644 --- a/ContactsViewModel.h +++ b/ContactsViewModel.h @@ -68,7 +68,7 @@ private: Contact^ currentItem_; Contact^ oldItem_; - void OnincomingMessage(Platform::String ^callId, Platform::String ^from, Platform::String ^payload); + void OnincomingMessage(Platform::String ^callId, Platform::String ^payload); }; } } diff --git a/MessageTextPage.xaml.cpp b/MessageTextPage.xaml.cpp index 65e0a68..6f8d60a 100644 --- a/MessageTextPage.xaml.cpp +++ b/MessageTextPage.xaml.cpp @@ -139,7 +139,7 @@ RingClientUWP::Views::BubbleHorizontalAlignement::BubbleHorizontalAlignement() {} -void RingClientUWP::Views::MessageTextPage::OnincomingMessage(Platform::String ^callId, Platform::String ^from, Platform::String ^payload) +void RingClientUWP::Views::MessageTextPage::OnincomingMessage(Platform::String ^callId, Platform::String ^payload) { scrollDown(); } diff --git a/MessageTextPage.xaml.h b/MessageTextPage.xaml.h index 7a7a828..1edbd73 100644 --- a/MessageTextPage.xaml.h +++ b/MessageTextPage.xaml.h @@ -49,7 +49,7 @@ private: void _sendBtn__Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e); void _messageTextBox__KeyDown(Platform::Object^ sender, Windows::UI::Xaml::Input::KeyRoutedEventArgs^ e); void sendMessage(); - void OnincomingMessage(Platform::String ^callId, Platform::String ^from, Platform::String ^payload); + void OnincomingMessage(Platform::String ^callId, Platform::String ^payload); }; } } diff --git a/RingD.cpp b/RingD.cpp index fd84125..712e088 100644 --- a/RingD.cpp +++ b/RingD.cpp @@ -296,7 +296,7 @@ RingClientUWP::RingD::startDaemon() auto callId2 = toPlatformString(callId); auto from2 = toPlatformString(from); - from2 = Utils::TrimRingId2(from2); + ///from2 = Utils::TrimFrom(from2); const std::string PROFILE_VCF = "x-ring/ring.profile.vcard"; @@ -314,7 +314,7 @@ RingClientUWP::RingD::startDaemon() CoreApplication::MainView->CoreWindow->Dispatcher->RunAsync( CoreDispatcherPriority::High, ref new DispatchedHandler([=]() { - incomingMessage(callId2, from2, payload); + incomingMessage(callId2, payload); MSG_("message recu :" + i.second); })); } diff --git a/RingD.h b/RingD.h index c3a39d3..f68cce1 100644 --- a/RingD.h +++ b/RingD.h @@ -31,7 +31,7 @@ delegate void IncomingCall(String^ accountId, String^ callId, String^ from); delegate void StateChange(String^ callId, CallStatus state, int code); delegate void IncomingAccountMessage(String^ accountId, String^ from, String^ payload); delegate void CallPlaced(String^ callId); -delegate void IncomingMessage(String^ callId, String^ from, String^ payload); +delegate void IncomingMessage(String^ callId, String^ payload); public ref class RingD sealed diff --git a/Utils.h b/Utils.h index 879542c..f832d74 100644 --- a/Utils.h +++ b/Utils.h @@ -135,6 +135,7 @@ TrimRingId(Platform::String^ s) /* fix some issue in the daemon --> remove "@..." */ Platform::String^ + TrimRingId2(Platform::String^ s) { const WCHAR* first = s->Begin(); @@ -148,6 +149,24 @@ TrimRingId2(Platform::String^ s) return ref new Platform::String(first, static_cast<unsigned int>(last - first)); } +Platform::String^ +TrimFrom(Platform::String^ s) +{ + const WCHAR* first = s->Begin(); + const WCHAR* last = s->End(); + + while (first != last && *first != ':') + ++first; + + while (first != last && last[-1] != '>') + --last; + + first++; + last--; + + return ref new Platform::String(first, static_cast<unsigned int>(last - first)); +} + Platform::String^ GetNewGUID() { @@ -167,7 +186,7 @@ getStringFromFile(const std::string& filename) { std::ifstream file(filename); return std::string((std::istreambuf_iterator<char>(file)), - (std::istreambuf_iterator<char>())); + (std::istreambuf_iterator<char>())); } inline Map<String^,String^>^ diff --git a/VideoPage.xaml.cpp b/VideoPage.xaml.cpp index 90241d5..df268a5 100644 --- a/VideoPage.xaml.cpp +++ b/VideoPage.xaml.cpp @@ -332,7 +332,7 @@ VideoPage::WriteFrameAsSoftwareBitmapAsync(String^ id, uint8_t* buf, int width, } -void RingClientUWP::Views::VideoPage::OnincomingMessage(Platform::String ^callId, Platform::String ^from, Platform::String ^payload) +void RingClientUWP::Views::VideoPage::OnincomingMessage(Platform::String ^callId, Platform::String ^payload) { scrollDown(); } diff --git a/VideoPage.xaml.h b/VideoPage.xaml.h index 5a52bba..e92e97a 100644 --- a/VideoPage.xaml.h +++ b/VideoPage.xaml.h @@ -115,7 +115,7 @@ private: void _videoControl__PointerMoved(Platform::Object^ sender, Windows::UI::Xaml::Input::PointerRoutedEventArgs^ e); void btnAny_entered(Platform::Object^ sender, Windows::UI::Xaml::Input::PointerRoutedEventArgs^ e); void btnAny_exited(Platform::Object^ sender, Windows::UI::Xaml::Input::PointerRoutedEventArgs^ e); - void OnincomingMessage(Platform::String ^callId, Platform::String ^from, Platform::String ^payload); + void OnincomingMessage(Platform::String ^callId, Platform::String ^payload); }; } } \ No newline at end of file -- GitLab