diff --git a/Package.appxmanifest b/Package.appxmanifest index 5eb7a74cf228064b215fe92e94e0af37f4641e65..8fa1a09a3500f786786bfccc7a92dcdb8a30eccc 100644 --- a/Package.appxmanifest +++ b/Package.appxmanifest @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="utf-8"?> <Package xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10" xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest" xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10" xmlns:uap3="http://schemas.microsoft.com/appx/manifest/uap/windows10/3" IgnorableNamespaces="uap uap3 mp"> - <Identity Name="Savoir-faireLinux.GNURing" Publisher="CN=8121A5F7-3CA1-4CAA-92B2-4F595B011941" Version="1.1.62.0" /> + <Identity Name="Savoir-faireLinux.GNURing" Publisher="CN=8121A5F7-3CA1-4CAA-92B2-4F595B011941" Version="1.1.65.0" /> <mp:PhoneIdentity PhoneProductId="2385953f-9019-423d-aa82-d1bbacfa258b" PhonePublisherId="00000000-0000-0000-0000-000000000000" /> <Properties> <DisplayName>GNU Ring</DisplayName> diff --git a/RingD.cpp b/RingD.cpp index 18e75bab51b22dad0e003d35cad27d235f7b091f..52949929228a1af6c91163deac514e8bed297db2 100644 --- a/RingD.cpp +++ b/RingD.cpp @@ -416,6 +416,43 @@ ShowMsgToast(String^ from, String^ payload) ToastNotificationManager::CreateToastNotifier()->Show(toast); } +void +RingD::HandleIncomingMessage( const std::string& callId, + const std::string& accountId, + const std::string& from, + const std::map<std::string, std::string>& payloads) +{ + auto callId2 = toPlatformString(callId); + auto accountId2 = toPlatformString(accountId); + auto from2 = toPlatformString(from); + from2 = Utils::TrimRingId2(from2); + + auto item = SmartPanelItemsViewModel::instance->findItemByRingID(from2); + Contact^ contact; + + static const unsigned int profileSize = VCardUtils::PROFILE_VCF.size(); + for (auto i : payloads) { + if (i.first.compare(0, profileSize, VCardUtils::PROFILE_VCF) == 0) { + if (item) { + contact = item->_contact; + contact->getVCard()->receiveChunk(i.first, i.second); + } + else + WNG_("item not found!"); + return; + } + auto payload = Utils::toPlatformString(i.second); + CoreApplication::MainView->CoreWindow->Dispatcher->RunAsync( + CoreDispatcherPriority::High, ref new DispatchedHandler([=]() + { + if (!accountId2->IsEmpty()) + incomingAccountMessage(accountId2, from2, payload); + else if (!callId2->IsEmpty()) + incomingMessage(callId2, payload); + })); + } +} + void RingD::registerCallbacks() { @@ -561,18 +598,7 @@ RingD::registerCallbacks() MSG_("accountId = " + accountId); MSG_("from = " + from); - auto accountId2 = toPlatformString(accountId); - auto from2 = toPlatformString(from); - - for (auto i : payloads) { - MSG_("payload = " + i.second); - auto payload = Utils::toPlatformString(i.second); - CoreApplication::MainView->CoreWindow->Dispatcher->RunAsync( - CoreDispatcherPriority::High, ref new DispatchedHandler([=]() - { - incomingAccountMessage(accountId2, from2, payload); - })); - } + HandleIncomingMessage("", accountId, from, payloads); }), DRing::exportable_callback<DRing::CallSignal::IncomingMessage>([&]( const std::string& callId, @@ -583,34 +609,7 @@ RingD::registerCallbacks() MSG_("callId = " + callId); MSG_("from = " + from); - auto callId2 = toPlatformString(callId); - auto from2 = toPlatformString(from); - - from2 = Utils::TrimRingId2(from2); - - auto item = SmartPanelItemsViewModel::instance->findItem(callId2); - Contact^ contact; - if (item) - contact = item->_contact; - else - WNG_("item not found!"); - - static const unsigned int profileSize = VCardUtils::PROFILE_VCF.size(); - for (auto i : payloads) { - MSG_(i.first); - if (i.first.compare(0, profileSize, VCardUtils::PROFILE_VCF) == 0) { - MSG_("payload.first = " + i.first); - MSG_("payload.second = " + i.second); - int res = contact->getVCard()->receiveChunk(i.first, i.second); - return; - } - auto payload = Utils::toPlatformString(i.second); - CoreApplication::MainView->CoreWindow->Dispatcher->RunAsync( - CoreDispatcherPriority::High, ref new DispatchedHandler([=]() - { - incomingMessage(callId2, payload); - })); - } + HandleIncomingMessage(callId, "", from, payloads); }), DRing::exportable_callback<DRing::ConfigurationSignal::RegistrationStateChanged>([this]( const std::string& account_id, const std::string& state, diff --git a/RingD.h b/RingD.h index 98dfa120ecb7a7ff0a214f101405047c91093f2b..f6e51f8d1cb8248f9149c2a053be1685a0ba71ae 100644 --- a/RingD.h +++ b/RingD.h @@ -150,6 +150,10 @@ internal: CallStatus translateCallStatus(String^ state); String^ getUserName(); Vector<String^>^ translateKnownRingDevices(const std::map<std::string, std::string> devices); + void HandleIncomingMessage( const std::string& callId, + const std::string& accountId, + const std::string& from, + const std::map<std::string, std::string>& payloads); void toggleFullScreen(); void setWindowedMode(); diff --git a/SmartPanelItemsViewModel.cpp b/SmartPanelItemsViewModel.cpp index 4aa3c88e6ce771ecd513dfa7d712e57851145f3c..f3c05674236f2e5611d88be3474f84cf79d9b5e6 100644 --- a/SmartPanelItemsViewModel.cpp +++ b/SmartPanelItemsViewModel.cpp @@ -70,6 +70,16 @@ SmartPanelItemsViewModel::findItem(Contact^ contact) return nullptr; } +SmartPanelItem^ +SmartPanelItemsViewModel::findItemByRingID(String^ ringID) +{ + for each (SmartPanelItem^ item in itemsList) + if (item->_contact->ringID_ == ringID) + return item; + + return nullptr; +} + unsigned int SmartPanelItemsViewModel::getIndex(String^ callId) { diff --git a/SmartPanelItemsViewModel.h b/SmartPanelItemsViewModel.h index ce15d10656004be3c5fe6a5b26f9e858a09819ef..68eb8ce6ca244398d924ae3570322d154334c477 100644 --- a/SmartPanelItemsViewModel.h +++ b/SmartPanelItemsViewModel.h @@ -47,6 +47,8 @@ internal: /* functions */ SmartPanelItem^ findItem(String^ callId); SmartPanelItem^ findItem(Contact^ contact); + SmartPanelItem^ findItemByRingID(String^ ringID); + unsigned int getIndex(String^ callId); unsigned int getIndex(Contact^ contact); void removeItem(SmartPanelItem^ item); diff --git a/Utils.h b/Utils.h index d5962b3a416c24a24409353f61af1c7fff062c2a..4f163f8d2009b3d52d0db2112a1cc5998b88812a 100644 --- a/Utils.h +++ b/Utils.h @@ -129,9 +129,11 @@ TrimRingId(Platform::String^ s) /* fix some issue in the daemon --> remove "@..." */ Platform::String^ - TrimRingId2(Platform::String^ s) { + if (toString(s).find("@") == std::string::npos) + return s; + const WCHAR* first = s->Begin(); const WCHAR* last = s->End(); diff --git a/VCardUtils.cpp b/VCardUtils.cpp index 7b23035a9b32f87b4b8beb35367c01243c891a54..fb0ddf6e48b2b81d161e291ac73529389a68e9ad 100644 --- a/VCardUtils.cpp +++ b/VCardUtils.cpp @@ -93,6 +93,11 @@ VCard::receiveChunk(const std::string& args, const std::string& payload) else m_mParts[Property::PHOTO].append(_line.substr(pos + 4)); + if (_of == 1) { + completeReception(); + MSG_("VCARD_COMPLETE"); + return VCARD_COMPLETE; + } return VCARD_INCOMPLETE; } else { @@ -110,12 +115,7 @@ VCard::receiveChunk(const std::string& args, const std::string& payload) if (fnFound) m_mParts[Property::FN] = _line.substr(3); - saveToFile(); - decodeBase64ToPNGFile(); - if (!m_mParts[Property::FN].empty()) - m_Owner->_displayName = Utils::toPlatformString(m_mParts[Property::FN]); - m_Owner->_vcardUID = Utils::toPlatformString(m_mParts[Property::UID]); - ViewModel::ContactsViewModel::instance->saveContactsToFile(); + completeReception(); MSG_("VCARD_COMPLETE"); return VCARD_COMPLETE; } @@ -127,6 +127,17 @@ VCard::receiveChunk(const std::string& args, const std::string& payload) return VCARD_CHUNK_ERROR; } +void +VCard::completeReception() +{ + saveToFile(); + decodeBase64ToPNGFile(); + if (!m_mParts[Property::FN].empty()) + m_Owner->_displayName = Utils::toPlatformString(m_mParts[Property::FN]); + m_Owner->_vcardUID = Utils::toPlatformString(m_mParts[Property::UID]); + ViewModel::ContactsViewModel::instance->saveContactsToFile(); +} + void VCard::send(std::string callID, const char* vCardFile) { @@ -192,6 +203,9 @@ VCard::asString() void VCard::decodeBase64ToPNGFile() { + if (!m_mParts[Property::PHOTO].size()) + return; + size_t padding = m_mParts[Property::PHOTO].size() % 4; if (padding) m_mParts[Property::PHOTO].append(padding, 0); diff --git a/VCardUtils.h b/VCardUtils.h index 68f09dc64d5dfd456d449d55853c4c68481a0d41..a1ceacd8c7bd3ee9381182b8a0ad6189bdef90a7 100644 --- a/VCardUtils.h +++ b/VCardUtils.h @@ -69,6 +69,7 @@ internal: void decodeBase64ToPNGFile(); void encodePNGToBase64(); + void completeReception(); void setData(std::map<std::string, std::string> data); private: