Commit 8ce1dee5 authored by atraczyk's avatar atraczyk Committed by Andreas Traczyk

account: add account type and ringID to accounts retrieval

- Adds account type and ringID to account retrieval from the daemon

Change-Id: I6184e5cb4c3f5f5f92ee6b6939ba69630e42eb4b
Tuleap: #963
parent 82f8dda3
/************************************************************************** /***************************************************************************
* 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 <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 * * This program is free software; you can redistribute it and/or modify *
* the Free Software Foundation; either version 3 of the License, or * * it under the terms of the GNU General Public License as published by *
* (at your option) any later version. * * 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 * * This program is distributed in the hope that it will be useful, *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * but WITHOUT ANY WARRANTY; without even the implied warranty of *
* GNU General Public License for more details. * * 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/>. * * 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 "pch.h"
#include "Account.h" #include "Account.h"
...@@ -26,10 +28,12 @@ using namespace Windows::UI::Core; ...@@ -26,10 +28,12 @@ using namespace Windows::UI::Core;
using namespace RingClientUWP; using namespace RingClientUWP;
Account::Account(String^ name, Account::Account(String^ name,
String^ ringID) String^ ringID,
String^ accountType)
{ {
name_ = name; name_ = name;
ringID_ = ringID; ringID_ = ringID;
accountType_ = accountType;
} }
void void
...@@ -41,6 +45,5 @@ Account::NotifyPropertyChanged(String^ propertyName) ...@@ -41,6 +45,5 @@ Account::NotifyPropertyChanged(String^ propertyName)
ref new DispatchedHandler([this, propertyName]() ref new DispatchedHandler([this, propertyName]()
{ {
PropertyChanged(this, ref new PropertyChangedEventArgs(propertyName)); PropertyChanged(this, ref new PropertyChangedEventArgs(propertyName));
})); }));
} }
\ No newline at end of file
/***************************************************************************
* 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 #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 Platform;
using namespace Windows::UI::Xaml::Data; using namespace Windows::UI::Xaml::Data;
...@@ -24,18 +27,17 @@ namespace RingClientUWP ...@@ -24,18 +27,17 @@ namespace RingClientUWP
public ref class Account sealed : public INotifyPropertyChanged public ref class Account sealed : public INotifyPropertyChanged
{ {
public: public:
Account(String^ name, String^ ringID); Account(String^ name, String^ ringID, String^ accountType);
virtual event PropertyChangedEventHandler^ PropertyChanged; virtual event PropertyChangedEventHandler^ PropertyChanged;
property String^ name_; property String^ name_;
property String^ ringID_; property String^ ringID_;
property String^ accountType_;
protected: protected:
void NotifyPropertyChanged(String^ propertyName); void NotifyPropertyChanged(String^ propertyName);
}; };
} }
/*************************************************************************** /***************************************************************************
* Copyright (C) 2016 by Savoir-faire Linux * * Copyright (C) 2016 by Savoir-faire Linux *
* Author: Jger Nicolas <nicolas.jager@savoirfairelinux.com> * * Author: Jger 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 * * This program is free software; you can redistribute it and/or modify *
* the Free Software Foundation; either version 3 of the License, or * * it under the terms of the GNU General Public License as published by *
* (at your option) any later version. * * 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 * * This program is distributed in the hope that it will be useful, *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * but WITHOUT ANY WARRANTY; without even the implied warranty of *
* GNU General Public License for more details. * * 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/>. * * 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 "pch.h"
#include "AccountsViewModel.h" #include "AccountsViewModel.h"
...@@ -27,11 +29,12 @@ AccountsViewModel::AccountsViewModel() ...@@ -27,11 +29,12 @@ AccountsViewModel::AccountsViewModel()
} }
void 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( accountsList_->Append(ref new Account(
Utils::toPlatformString(name), Utils::toPlatformString(name),
Utils::toPlatformString(ringid) Utils::toPlatformString(ringID),
Utils::toPlatformString(accountType)
)); ));
} }
......
/***************************************************************************
* Copyright (C) 2016 by Savoir-faire Linux *
* Author: Jger 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 #pragma once
/**************************************************************************
* Copyright (C) 2016 by Savoir-faire Linux *
* Author: Jger 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; using namespace Platform::Collections;
...@@ -37,7 +39,7 @@ internal: ...@@ -37,7 +39,7 @@ internal:
} }
/* functions */ /* functions */
void add(std::string& name, std::string& ringid); void add(std::string& name, std::string& ringID, std::string& accountType);
void clearAccountList(); void clearAccountList();
/* properties */ /* properties */
......
...@@ -45,11 +45,16 @@ reloadAccountList() ...@@ -45,11 +45,16 @@ reloadAccountList()
{ {
RingClientUWP::ViewModel::AccountsViewModel::instance->clearAccountList(); RingClientUWP::ViewModel::AccountsViewModel::instance->clearAccountList();
std::vector<std::string> accountList = DRing::getAccountList(); std::vector<std::string> accountList = DRing::getAccountList();
for (std::string i : accountList) { std::vector<std::string>::reverse_iterator rit = accountList.rbegin();
std::map<std::string,std::string> accountDetails = DRing::getAccountDetails(i); 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( RingClientUWP::ViewModel::AccountsViewModel::instance->add(
accountDetails.find(ring::Conf::CONFIG_ACCOUNT_ALIAS)->second, accountDetails.find(ring::Conf::CONFIG_ACCOUNT_ALIAS)->second, //name
accountDetails.find(ring::Conf::CONFIG_ACCOUNT_TYPE)->second); ringID, //ringid
accountDetails.find(ring::Conf::CONFIG_ACCOUNT_TYPE)->second); //type
} }
} }
...@@ -143,16 +148,15 @@ RingClientUWP::RingD::startDaemon() ...@@ -143,16 +148,15 @@ RingClientUWP::RingD::startDaemon()
else { else {
if (!hasConfig) if (!hasConfig)
{ {
std::map<std::string, std::string> test_details; std::map<std::string, std::string> ringAccountDetails;
test_details.insert(std::make_pair(ring::Conf::CONFIG_ACCOUNT_ALIAS, accountName)); ringAccountDetails.insert(std::make_pair(ring::Conf::CONFIG_ACCOUNT_ALIAS, accountName));
test_details.insert(std::make_pair(ring::Conf::CONFIG_ACCOUNT_TYPE,"RING")); ringAccountDetails.insert(std::make_pair(ring::Conf::CONFIG_ACCOUNT_TYPE,"RING"));
DRing::addAccount(test_details); DRing::addAccount(ringAccountDetails);
} }
CoreApplication::MainView->CoreWindow->Dispatcher->RunAsync(CoreDispatcherPriority::Normal, CoreApplication::MainView->CoreWindow->Dispatcher->RunAsync(CoreDispatcherPriority::Normal,
ref new DispatchedHandler([=]() { ref new DispatchedHandler([=]() {
reloadAccountList(); reloadAccountList();
})); }));
while (true) { while (true) {
DRing::pollEvents(); DRing::pollEvents();
Sleep(1000); Sleep(1000);
...@@ -180,4 +184,4 @@ RingD::dequeueTasks() ...@@ -180,4 +184,4 @@ RingD::dequeueTasks()
} }
tasksList_.pop(); tasksList_.pop();
} }
} }
\ No newline at end of file
...@@ -112,18 +112,39 @@ ...@@ -112,18 +112,39 @@
<Grid> <Grid>
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="60"/> <ColumnDefinition Width="60"/>
<ColumnDefinition Width="*"/> <ColumnDefinition Width="200"/>
<ColumnDefinition Width="60"/>
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="30"/>
<RowDefinition Height="30"/>
</Grid.RowDefinitions>
<Image x:Name="_accountAvatar_" <Image x:Name="_accountAvatar_"
VerticalAlignment="Center" VerticalAlignment="Center"
HorizontalAlignment="Center" HorizontalAlignment="Center"
Grid.Column="0" Grid.Column="0"
Grid.RowSpan="2"
Width="55" Width="55"
Height="55" Height="55"
Source="Assets\TESTS\contactAvatar.png"/> Source="Assets\TESTS\contactAvatar.png"/>
<TextBlock x:Name="_accountName_" <TextBlock x:Name="_accountName_"
Grid.Column="1" Grid.Column="1"
Grid.Row="0"
Text="{x:Bind name_}"/> 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> </Grid>
</DataTemplate> </DataTemplate>
</Page.Resources> </Page.Resources>
......
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