diff --git a/Account.cpp b/Account.cpp index 57e7da15b8e90db95634ff11f720ef66a14ff26f..e5e38b09b9d0c7e946ffee14c009107d3915dc35 100644 --- a/Account.cpp +++ b/Account.cpp @@ -1,20 +1,22 @@ -/************************************************************************** -* Copyright (C) 2016 by Savoir-faire Linux * -* Author: J�ger Nicolas <nicolas.jager@savoirfairelinux.com> * -* * -* This program is free software; you can redistribute it and/or modify * -* it under the terms of the GNU General Public License as published by * -* the Free Software Foundation; either version 3 of the License, or * -* (at your option) any later version. * -* * -* This program is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU General Public License for more details. * -* * -* You should have received a copy of the GNU General Public License * -* along with this program. If not, see <http://www.gnu.org/licenses/>. * -**************************************************************************/ +/*************************************************************************** + * Copyright (C) 2016 by Savoir-faire Linux * + * Author: J�ger Nicolas <nicolas.jager@savoirfairelinux.com> * + * Author: Traczyk Andreas <andreas.traczyk@savoirfairelinux.com> * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 3 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program. If not, see <http://www.gnu.org/licenses/>. * + **************************************************************************/ + #include "pch.h" #include "Account.h" @@ -26,10 +28,12 @@ using namespace Windows::UI::Core; using namespace RingClientUWP; Account::Account(String^ name, - String^ ringID) + String^ ringID, + String^ accountType) { name_ = name; ringID_ = ringID; + accountType_ = accountType; } void @@ -41,6 +45,5 @@ Account::NotifyPropertyChanged(String^ propertyName) ref new DispatchedHandler([this, propertyName]() { PropertyChanged(this, ref new PropertyChangedEventArgs(propertyName)); - })); } \ No newline at end of file diff --git a/Account.h b/Account.h index a3744d65d74cbef5b03f06f18f7a77657aeec9d0..9ffc1646b1cfcf346a70d60c7d0b69b2c95b18f1 100644 --- a/Account.h +++ b/Account.h @@ -1,21 +1,24 @@ +/*************************************************************************** + * Copyright (C) 2016 by Savoir-faire Linux * + * Author: J�ger Nicolas <nicolas.jager@savoirfairelinux.com> * + * Author: Traczyk Andreas <andreas.traczyk@savoirfairelinux.com> * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 3 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program. If not, see <http://www.gnu.org/licenses/>. * + **************************************************************************/ + #pragma once -/************************************************************************** -* Copyright (C) 2016 by Savoir-faire Linux * -* Author: J�ger Nicolas <nicolas.jager@savoirfairelinux.com> * -* * -* This program is free software; you can redistribute it and/or modify * -* it under the terms of the GNU General Public License as published by * -* the Free Software Foundation; either version 3 of the License, or * -* (at your option) any later version. * -* * -* This program is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU General Public License for more details. * -* * -* You should have received a copy of the GNU General Public License * -* along with this program. If not, see <http://www.gnu.org/licenses/>. * -**************************************************************************/ + using namespace Platform; using namespace Windows::UI::Xaml::Data; @@ -24,18 +27,17 @@ namespace RingClientUWP public ref class Account sealed : public INotifyPropertyChanged { public: - Account(String^ name, String^ ringID); - + Account(String^ name, String^ ringID, String^ accountType); virtual event PropertyChangedEventHandler^ PropertyChanged; property String^ name_; property String^ ringID_; + property String^ accountType_; protected: void NotifyPropertyChanged(String^ propertyName); - }; } diff --git a/AccountsViewModel.cpp b/AccountsViewModel.cpp index 229d58c9fa7b8984aadd1ca49387268a164d9be7..d6ba55362ef1d43887d1591df85d621cfe4fb7ff 100644 --- a/AccountsViewModel.cpp +++ b/AccountsViewModel.cpp @@ -1,20 +1,22 @@ /*************************************************************************** -* Copyright (C) 2016 by Savoir-faire Linux * -* Author: J�ger Nicolas <nicolas.jager@savoirfairelinux.com> * -* * -* This program is free software; you can redistribute it and/or modify * -* it under the terms of the GNU General Public License as published by * -* the Free Software Foundation; either version 3 of the License, or * -* (at your option) any later version. * -* * -* This program is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU General Public License for more details. * -* * -* You should have received a copy of the GNU General Public License * -* along with this program. If not, see <http://www.gnu.org/licenses/>. * -**************************************************************************/ + * Copyright (C) 2016 by Savoir-faire Linux * + * Author: J�ger Nicolas <nicolas.jager@savoirfairelinux.com> * + * Author: Traczyk Andreas <andreas.traczyk@savoirfairelinux.com> * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 3 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program. If not, see <http://www.gnu.org/licenses/>. * + **************************************************************************/ + #include "pch.h" #include "AccountsViewModel.h" @@ -27,11 +29,12 @@ AccountsViewModel::AccountsViewModel() } void -AccountsViewModel::add(std::string& name, std::string& ringid) +AccountsViewModel::add(std::string& name, std::string& ringID, std::string& accountType) { accountsList_->Append(ref new Account( Utils::toPlatformString(name), - Utils::toPlatformString(ringid) + Utils::toPlatformString(ringID), + Utils::toPlatformString(accountType) )); } diff --git a/AccountsViewModel.h b/AccountsViewModel.h index cb39bc83995ad9ef97782e589d4bf172230ce276..b9c8d645578ca1eb45af4bdb56108ab892b97002 100644 --- a/AccountsViewModel.h +++ b/AccountsViewModel.h @@ -1,21 +1,23 @@ +/*************************************************************************** + * Copyright (C) 2016 by Savoir-faire Linux * + * Author: J�ger Nicolas <nicolas.jager@savoirfairelinux.com> * + * Author: Traczyk Andreas <andreas.traczyk@savoirfairelinux.com> * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 3 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program. If not, see <http://www.gnu.org/licenses/>. * + **************************************************************************/ + #pragma once -/************************************************************************** -* Copyright (C) 2016 by Savoir-faire Linux * -* Author: J�ger Nicolas <nicolas.jager@savoirfairelinux.com> * -* * -* This program is free software; you can redistribute it and/or modify * -* it under the terms of the GNU General Public License as published by * -* the Free Software Foundation; either version 3 of the License, or * -* (at your option) any later version. * -* * -* This program is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU General Public License for more details. * -* * -* You should have received a copy of the GNU General Public License * -* along with this program. If not, see <http://www.gnu.org/licenses/>. * -**************************************************************************/ using namespace Platform::Collections; @@ -37,7 +39,7 @@ internal: } /* functions */ - void add(std::string& name, std::string& ringid); + void add(std::string& name, std::string& ringID, std::string& accountType); void clearAccountList(); /* properties */ diff --git a/RingD.cpp b/RingD.cpp index 5f542e60367fa2bb476093ba51dfdf9cea598740..2d4ef7391b98bc7b2a4d51317966baf4bcca1fa1 100644 --- a/RingD.cpp +++ b/RingD.cpp @@ -45,11 +45,16 @@ 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); + std::vector<std::string>::reverse_iterator rit = accountList.rbegin(); + for (; rit != accountList.rend(); ++rit) { + std::map<std::string,std::string> accountDetails = DRing::getAccountDetails(*rit); + std::string ringID(accountDetails.find(ring::Conf::CONFIG_ACCOUNT_USERNAME)->second); + if(!ringID.empty()) + ringID = ringID.substr(5); RingClientUWP::ViewModel::AccountsViewModel::instance->add( - accountDetails.find(ring::Conf::CONFIG_ACCOUNT_ALIAS)->second, - accountDetails.find(ring::Conf::CONFIG_ACCOUNT_TYPE)->second); + accountDetails.find(ring::Conf::CONFIG_ACCOUNT_ALIAS)->second, //name + ringID, //ringid + accountDetails.find(ring::Conf::CONFIG_ACCOUNT_TYPE)->second); //type } } @@ -143,16 +148,15 @@ RingClientUWP::RingD::startDaemon() else { if (!hasConfig) { - std::map<std::string, std::string> test_details; - test_details.insert(std::make_pair(ring::Conf::CONFIG_ACCOUNT_ALIAS, accountName)); - test_details.insert(std::make_pair(ring::Conf::CONFIG_ACCOUNT_TYPE,"RING")); - DRing::addAccount(test_details); + std::map<std::string, std::string> ringAccountDetails; + ringAccountDetails.insert(std::make_pair(ring::Conf::CONFIG_ACCOUNT_ALIAS, accountName)); + ringAccountDetails.insert(std::make_pair(ring::Conf::CONFIG_ACCOUNT_TYPE,"RING")); + DRing::addAccount(ringAccountDetails); } CoreApplication::MainView->CoreWindow->Dispatcher->RunAsync(CoreDispatcherPriority::Normal, ref new DispatchedHandler([=]() { reloadAccountList(); })); - while (true) { DRing::pollEvents(); Sleep(1000); @@ -180,4 +184,4 @@ RingD::dequeueTasks() } tasksList_.pop(); } -} +} \ No newline at end of file diff --git a/SmartPanel.xaml b/SmartPanel.xaml index 104eefdf1684b496026609707ea133b608676b71..41d32d96117cc390491485f830d1c44ec27d745f 100644 --- a/SmartPanel.xaml +++ b/SmartPanel.xaml @@ -112,18 +112,39 @@ <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="60"/> - <ColumnDefinition Width="*"/> + <ColumnDefinition Width="200"/> + <ColumnDefinition Width="60"/> </Grid.ColumnDefinitions> + <Grid.RowDefinitions> + <RowDefinition Height="30"/> + <RowDefinition Height="30"/> + </Grid.RowDefinitions> <Image x:Name="_accountAvatar_" VerticalAlignment="Center" HorizontalAlignment="Center" Grid.Column="0" + Grid.RowSpan="2" Width="55" Height="55" Source="Assets\TESTS\contactAvatar.png"/> <TextBlock x:Name="_accountName_" Grid.Column="1" + Grid.Row="0" Text="{x:Bind name_}"/> + <TextBlock x:Name="_accountType_" + Grid.Column="2" + Grid.Row="0" + TextAlignment="Right" + Margin="0,0,10,0" + Foreground="ForestGreen" + Text="{x:Bind accountType_}"/> + <TextBlock x:Name="_ringID_" + Grid.Column="1" + Grid.ColumnSpan="2" + Grid.Row="1" + Foreground="Crimson" + TextTrimming="CharacterEllipsis" + Text="{x:Bind ringID_}"/> </Grid> </DataTemplate> </Page.Resources>