diff --git a/ContactsViewModel.cpp b/ContactsViewModel.cpp index 7fab7433d3c7e24f97a613bcdbe53329e56ff50d..0d21e361c12db9526d7a33f9a0395a7c98617ed8 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 b8d720f5892a7fe44c594a89a9a3116c20693947..b6ee05fa8602026ebe4652e8e359f4fc57e3d02f 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 65e0a68ebf1975c2c0e8e3618db665f5d66b6387..6f8d60a78dc153e30dd8d1d2b040da673922511a 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 7a7a8284c687b75e45c73c78783846fc2ef40486..1edbd739581ca78d7d08f913e45dc665c2cc1ce7 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 fd8412529fa7699940bd338fa65ffbb0729cae05..712e088a6073e74934f64a964c4d168c6a7901fe 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 c3a39d339ec162fc33bc8e7fe2615782bcdf35c6..f68cce18d37a22d232cd81c75d48d59f9f342650 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 879542c1f2239a3a3dc4cc00af87d09816bb6f3a..f832d7434f667ca65070a80cfa6641f150c10383 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 90241d550d7708663298d9d38b126da76dbb70ff..df268a506dd3d74881c0f23e3bc47e32c08fbe51 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 5a52bba0a9f6b9cbf4c2bf875cb99c73ed5fe57f..e92e97aa1b9adc145e2a590181ee92f97ad45e00 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