From 4ed42ea7bfaa7b43082bd4ffec33d74a0957de69 Mon Sep 17 00:00:00 2001 From: atraczyk <andreastraczyk@gmail.com> Date: Tue, 29 Nov 2016 11:15:34 -0500 Subject: [PATCH] fix: adjustments to vcard implemenation - uses JPEG for outgoing instead of PNG - sets the chunk size back to 1KB - handles empty PHOTO Change-Id: I761debd2841a024e6a5ad607cad1e278a891c973 Tuleap: #790 --- SmartPanel.xaml | 2 -- SmartPanel.xaml.cpp | 3 +-- VCardUtils.cpp | 27 +++++++++++++++++++++++---- VCardUtils.h | 3 ++- Wizard.xaml.cpp | 2 +- 5 files changed, 27 insertions(+), 10 deletions(-) diff --git a/SmartPanel.xaml b/SmartPanel.xaml index 9e8c949..17eab46 100644 --- a/SmartPanel.xaml +++ b/SmartPanel.xaml @@ -230,8 +230,6 @@ <RowDefinition Height="auto"/> <!-- row definition for the incoming call bar. --> <RowDefinition Height="auto"/> - <!-- row definition for the outgoing call bar. --> - <RowDefinition Height="auto"/> </Grid.RowDefinitions> <!--helper to detect mouse overing--> <Rectangle Fill="Transparent" Grid.Row="0"/> diff --git a/SmartPanel.xaml.cpp b/SmartPanel.xaml.cpp index 813089c..aa90d3e 100644 --- a/SmartPanel.xaml.cpp +++ b/SmartPanel.xaml.cpp @@ -82,7 +82,6 @@ SmartPanel::SmartPanel() _selectedAccountAvatar_->ImageSource = ref new BitmapImage(uri); }); ContactsViewModel::instance->contactDataModified += ref new ContactDataModified([this](Contact^ contact){ - }); AccountsViewModel::instance->updateScrollView += ref new UpdateScrollView([this]() { _accountsListScrollView_->UpdateLayout(); @@ -1160,7 +1159,7 @@ void RingClientUWP::Views::SmartPanel::_selectedAccountAvatarContainer__PointerReleased(Platform::Object^ sender, Windows::UI::Xaml::Input::PointerRoutedEventArgs^ e) { CameraCaptureUI^ cameraCaptureUI = ref new CameraCaptureUI(); - cameraCaptureUI->PhotoSettings->Format = CameraCaptureUIPhotoFormat::Png; + cameraCaptureUI->PhotoSettings->Format = CameraCaptureUIPhotoFormat::Jpeg; cameraCaptureUI->PhotoSettings->CroppedSizeInPixels = Size(80, 80); create_task(cameraCaptureUI->CaptureFileAsync(CameraCaptureUIMode::Photo)) diff --git a/VCardUtils.cpp b/VCardUtils.cpp index 2a2e831..8ffae3c 100644 --- a/VCardUtils.cpp +++ b/VCardUtils.cpp @@ -62,24 +62,43 @@ VCard::receiveChunk(const std::string& args, const std::string& payload) } m_mParts[Property::UID] = _line.substr(4); + bool fnFound = false; while (std::getline(_payload, _line)) { - if (_line.find("FN:") != std::string::npos) + if (_line.find("FN:") != std::string::npos) { + fnFound = true; break; + } } - m_mParts[Property::FN] = _line.substr(3); + if (fnFound) + m_mParts[Property::FN] = _line.substr(3); while (std::getline(_payload, _line)) { if (_line.find("PHOTO;") != std::string::npos) break; } + // because android client builds vcard differently (TYPE=PNG: vs PNG:) - m_mParts[Property::PHOTO].append(_line.substr(_line.find("PNG:") + 4)); + size_t pos = _line.find("PNG:"); + if (pos != std::string::npos) + m_mParts[Property::PHOTO].append(_line.substr(pos + 4)); + return VCARD_INCOMPLETE; } else { if (_part == _of) { std::getline(_payload, _line); m_mParts[Property::PHOTO].append(_line); + + bool fnFound = false; + while (std::getline(_payload, _line)) { + if (_line.find("FN:") != std::string::npos) { + fnFound = true; + break; + } + } + if (fnFound) + m_mParts[Property::FN] = _line.substr(3); + saveToFile(); decodeBase64ToPNGFile(); if (!m_mParts[Property::FN].empty()) @@ -101,7 +120,7 @@ void VCard::send(std::string callID, const char* vCardFile) { int i = 0; - const int chunkSize = 4096; + const int chunkSize = 1024; std::string vCard; if (vCardFile) { std::ifstream file(vCardFile); diff --git a/VCardUtils.h b/VCardUtils.h index 593fd60..68f09dc 100644 --- a/VCardUtils.h +++ b/VCardUtils.h @@ -44,7 +44,7 @@ struct Symbols { constexpr static const char* SEPERATOR1 = ";"; constexpr static const char* SEPERATOR2 = ":"; constexpr static const char* PHOTO_ENC = "ENDCODING=BASE64"; - constexpr static const char* PHOTO_TYPE = "TYPE=PNG"; + constexpr static const char* PHOTO_TYPE = "TYPE=JPEG"; }; struct Property { @@ -74,6 +74,7 @@ internal: private: std::map<std::string, std::string> m_mParts { }; Contact^ m_Owner; + int m_type; }; diff --git a/Wizard.xaml.cpp b/Wizard.xaml.cpp index 04f0861..66b7e61 100644 --- a/Wizard.xaml.cpp +++ b/Wizard.xaml.cpp @@ -80,7 +80,7 @@ void Wizard::_avatarWebcamCaptureBtn__Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e) { CameraCaptureUI^ cameraCaptureUI = ref new CameraCaptureUI(); - cameraCaptureUI->PhotoSettings->Format = CameraCaptureUIPhotoFormat::JpegXR; + cameraCaptureUI->PhotoSettings->Format = CameraCaptureUIPhotoFormat::Jpeg; cameraCaptureUI->PhotoSettings->CroppedSizeInPixels = Size(80, 80); create_task(cameraCaptureUI->CaptureFileAsync(CameraCaptureUIMode::Photo)) -- GitLab