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 *
* 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
/***************************************************************************
* 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);
};
}
/***************************************************************************
* 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/>. *
**************************************************************************/
* 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/>. *
**************************************************************************/
#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)
));
}
......
/***************************************************************************
* 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
/**************************************************************************
* 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;
......@@ -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 */
......
......@@ -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
......@@ -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>
......
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