Commit 82f8dda3 authored by atraczyk's avatar atraczyk Committed by Andreas Traczyk

Internal: populate account list from daemon

- Fills the account list after retrieving account list
  details form the daemon

Change-Id: I654fb554704049a942979de07a1b6b01ec513051
Tuleap: #962
parent ebec625c
...@@ -23,10 +23,20 @@ using namespace ViewModel; ...@@ -23,10 +23,20 @@ using namespace ViewModel;
AccountsViewModel::AccountsViewModel() AccountsViewModel::AccountsViewModel()
{ {
/* accountList_ should be filled with accounts saved on the disk */
accountsList_ = ref new Vector<Account^>(); accountsList_ = ref new Vector<Account^>();
}
accountsList_->Append(ref new Account("Moi","jfdhfshfhsk")); void
accountsList_->Append(ref new Account("SuperMan", "jfdhfshfhsk")); AccountsViewModel::add(std::string& name, std::string& ringid)
accountsList_->Append(ref new Account("Travail", "jfdhfshfhsk")); {
accountsList_->Append(ref new Account(
Utils::toPlatformString(name),
Utils::toPlatformString(ringid)
));
}
void
AccountsViewModel::clearAccountList()
{
accountsList_->Clear();
} }
\ No newline at end of file
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
* You should have received a copy of the GNU General Public License * * You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. * * along with this program. If not, see <http://www.gnu.org/licenses/>. *
**************************************************************************/ **************************************************************************/
using namespace Platform::Collections; using namespace Platform::Collections;
namespace RingClientUWP namespace RingClientUWP
...@@ -36,6 +37,8 @@ internal: ...@@ -36,6 +37,8 @@ internal:
} }
/* functions */ /* functions */
void add(std::string& name, std::string& ringid);
void clearAccountList();
/* properties */ /* properties */
property Vector<Account^>^ accountsList property Vector<Account^>^ accountsList
......
/*************************************************************************** /***************************************************************************
* Copyright (C) 2016 by Savoir-faire Linux * * Copyright (C) 2016 by Savoir-faire Linux *
* Author: Jäger Nicolas <nicolas.jager@savoirfairelinux.com> * * Author: Jäger Nicolas <nicolas.jager@savoirfairelinux.com> *
* Author: Traczyk Andreas <traczyk.andreas@savoirfairelinux.com> * * Author: Traczyk Andreas <traczyk.andreas@savoirfairelinux.com> *
* * * *
* This program is free software; you can redistribute it and/or modify * * This program is free software; you can redistribute it and/or modify *
...@@ -35,13 +35,26 @@ using namespace RingClientUWP; ...@@ -35,13 +35,26 @@ using namespace RingClientUWP;
using namespace RingClientUWP::Utils; using namespace RingClientUWP::Utils;
void void
DebugOutputWrapper(const std::string& str) debugOutputWrapper(const std::string& str)
{ {
MSG_(str); MSG_(str);
} }
void void
RingD::startDaemon() reloadAccountList()
{
RingClientUWP::ViewModel::AccountsViewModel::instance->clearAccountList();
std::vector<std::string> accountList = DRing::getAccountList();
for (std::string i : accountList) {
std::map<std::string,std::string> accountDetails = DRing::getAccountDetails(i);
RingClientUWP::ViewModel::AccountsViewModel::instance->add(
accountDetails.find(ring::Conf::CONFIG_ACCOUNT_ALIAS)->second,
accountDetails.find(ring::Conf::CONFIG_ACCOUNT_TYPE)->second);
}
}
void
RingClientUWP::RingD::startDaemon()
{ {
create_task([&]() create_task([&]()
{ {
...@@ -96,6 +109,10 @@ RingD::startDaemon() ...@@ -96,6 +109,10 @@ RingD::startDaemon()
MSG_("payload = " + i.second); MSG_("payload = " + i.second);
auto payload = Utils::toPlatformString(i.second); auto payload = Utils::toPlatformString(i.second);
} }
}),
DRing::exportable_callback<DRing::ConfigurationSignal::AccountsChanged>([this]()
{
reloadAccountList();
}) })
}; };
...@@ -103,7 +120,7 @@ RingD::startDaemon() ...@@ -103,7 +120,7 @@ RingD::startDaemon()
std::map<std::string, SharedCallback> dringDebugOutHandler; std::map<std::string, SharedCallback> dringDebugOutHandler;
dringDebugOutHandler.insert(DRing::exportable_callback<DRing::Debug::MessageSend> dringDebugOutHandler.insert(DRing::exportable_callback<DRing::Debug::MessageSend>
(std::bind(&DebugOutputWrapper, _1))); (std::bind(&debugOutputWrapper, _1)));
registerCallHandlers(dringDebugOutHandler); registerCallHandlers(dringDebugOutHandler);
std::map<std::string, SharedCallback> getAppPathHandler = std::map<std::string, SharedCallback> getAppPathHandler =
...@@ -131,6 +148,11 @@ RingD::startDaemon() ...@@ -131,6 +148,11 @@ RingD::startDaemon()
test_details.insert(std::make_pair(ring::Conf::CONFIG_ACCOUNT_TYPE,"RING")); test_details.insert(std::make_pair(ring::Conf::CONFIG_ACCOUNT_TYPE,"RING"));
DRing::addAccount(test_details); DRing::addAccount(test_details);
} }
CoreApplication::MainView->CoreWindow->Dispatcher->RunAsync(CoreDispatcherPriority::Normal,
ref new DispatchedHandler([=]() {
reloadAccountList();
}));
while (true) { while (true) {
DRing::pollEvents(); DRing::pollEvents();
Sleep(1000); Sleep(1000);
......
...@@ -338,6 +338,7 @@ ...@@ -338,6 +338,7 @@
Width="320" Width="320"
TextWrapping="Wrap" TextWrapping="Wrap"
Style="{StaticResource TextBoxStyle1}" Style="{StaticResource TextBoxStyle1}"
KeyDown="_ringTxtBx__KeyDown"
Text=""/> Text=""/>
<ListBox x:Name="_smartList_" <ListBox x:Name="_smartList_"
Grid.Row="1" Grid.Row="1"
......
...@@ -98,26 +98,22 @@ void RingClientUWP::Views::SmartPanel::_shareMenuButton__Unchecked(Platform::Obj ...@@ -98,26 +98,22 @@ void RingClientUWP::Views::SmartPanel::_shareMenuButton__Unchecked(Platform::Obj
_shareMenuGrid_->Visibility = Windows::UI::Xaml::Visibility::Collapsed; _shareMenuGrid_->Visibility = Windows::UI::Xaml::Visibility::Collapsed;
} }
void RingClientUWP::Views::SmartPanel::_addAccountBtn__Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e) void RingClientUWP::Views::SmartPanel::_addAccountBtn__Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
{ {
_accountsMenuGrid_->Visibility = Windows::UI::Xaml::Visibility::Collapsed; _accountsMenuGrid_->Visibility = Windows::UI::Xaml::Visibility::Collapsed;
_accountCreationMenuGrid_->Visibility = Windows::UI::Xaml::Visibility::Visible; _accountCreationMenuGrid_->Visibility = Windows::UI::Xaml::Visibility::Visible;
} }
void RingClientUWP::Views::SmartPanel::_createAccountYes__Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e) void RingClientUWP::Views::SmartPanel::_createAccountYes__Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
{ {
} }
void RingClientUWP::Views::SmartPanel::_createAccountNo__Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e) void RingClientUWP::Views::SmartPanel::_createAccountNo__Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
{ {
} }
void RingClientUWP::Views::SmartPanel::_avatarWebcamCaptureBtn__Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e) void RingClientUWP::Views::SmartPanel::_avatarWebcamCaptureBtn__Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
{ {
CameraCaptureUI^ cameraCaptureUI = ref new CameraCaptureUI(); CameraCaptureUI^ cameraCaptureUI = ref new CameraCaptureUI();
...@@ -147,7 +143,6 @@ void RingClientUWP::Views::SmartPanel::_avatarWebcamCaptureBtn__Click(Platform:: ...@@ -147,7 +143,6 @@ void RingClientUWP::Views::SmartPanel::_avatarWebcamCaptureBtn__Click(Platform::
} }
void void
SmartPanel::_smartList__SelectionChanged(Platform::Object^ sender, Windows::UI::Xaml::Controls::SelectionChangedEventArgs^ e) SmartPanel::_smartList__SelectionChanged(Platform::Object^ sender, Windows::UI::Xaml::Controls::SelectionChangedEventArgs^ e)
{ {
...@@ -155,3 +150,12 @@ SmartPanel::_smartList__SelectionChanged(Platform::Object^ sender, Windows::UI:: ...@@ -155,3 +150,12 @@ SmartPanel::_smartList__SelectionChanged(Platform::Object^ sender, Windows::UI::
auto contact = safe_cast<Contact^>(listbox->SelectedItem); auto contact = safe_cast<Contact^>(listbox->SelectedItem);
ContactsViewModel::instance->selectedContact = contact; ContactsViewModel::instance->selectedContact = contact;
} }
void RingClientUWP::Views::SmartPanel::_ringTxtBx__KeyDown(Platform::Object^ sender, Windows::UI::Xaml::Input::KeyRoutedEventArgs^ e)
{
/* add contact, test purpose but will be reused later in some way */
if (e->Key == Windows::System::VirtualKey::Enter && _ringTxtBx_->Text != "") {
ContactsViewModel::instance->addNewContact(_ringTxtBx_->Text, _ringTxtBx_->Text);
_ringTxtBx_->Text = "";
}
}
...@@ -51,6 +51,7 @@ private: ...@@ -51,6 +51,7 @@ private:
void _createAccountNo__Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e); void _createAccountNo__Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
void _avatarWebcamCaptureBtn__Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e); void _avatarWebcamCaptureBtn__Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
void _smartList__SelectionChanged(Platform::Object^ sender, Windows::UI::Xaml::Controls::SelectionChangedEventArgs^ e); void _smartList__SelectionChanged(Platform::Object^ sender, Windows::UI::Xaml::Controls::SelectionChangedEventArgs^ e);
void _ringTxtBx__KeyDown(Platform::Object^ sender, Windows::UI::Xaml::Input::KeyRoutedEventArgs^ e);
}; };
} }
} }
\ No newline at end of file
...@@ -6,7 +6,8 @@ using namespace Windows::Storage; ...@@ -6,7 +6,8 @@ using namespace Windows::Storage;
namespace RingClientUWP namespace RingClientUWP
{ {
namespace Utils { namespace Utils
{
task<bool> task<bool>
fileExists(StorageFolder^ folder, String^ fileName) fileExists(StorageFolder^ folder, String^ fileName)
...@@ -72,5 +73,6 @@ Platform::String^ toPlatformString(const std::string& str) ...@@ -72,5 +73,6 @@ Platform::String^ toPlatformString(const std::string& str)
std::wstring wsstr = makeWString(str); std::wstring wsstr = makeWString(str);
return ref new Platform::String(wsstr.c_str(), wsstr.length()); return ref new Platform::String(wsstr.c_str(), wsstr.length());
} }
} }
} }
\ No newline at end of file
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