Commit 6344744e authored by Nicolas Jager's avatar Nicolas Jager

fix : various minor bugs.

- Forces to hide chat panel on video page when the user summon the video
  page

- Uses RingId instead of the name (wich is not necessarily unique) to make
  ContactsViewModel identfy a contact.

- Checks if contact reference is valid before getting the smart panel item.

- pass call list from daemon to the client trough an async function.

- sets visible the call button only if no call is on going.

- changes the avatar size to get some space for the call button.

Change-Id: Id3a0d03026503bdc5d1e844d8d4be8983da572d3
Tuleap: #790
parent a57d717d
......@@ -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
}
......@@ -46,6 +46,7 @@ internal:
/* functions */
Contact^ findContactByName(String^ name);
Contact^ findContactByRingId(String^ ringId);
Contact^ addNewContact(String^ name, String^ ringId);
void saveContactsToFile();
void openContactsFromFile();
......
......@@ -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_);
}
......
......@@ -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" />
......
......@@ -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);
......
......@@ -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 */
......
......@@ -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
......
......@@ -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();
}
......
......@@ -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()
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment