Commit b724d332 authored by atraczyk's avatar atraczyk

fix: crlf

Change-Id: I77b554af9e94f2fa72f6358f612046406ba33794
Tuleap: #972
parent 49822a3d
This diff is collapsed.
/***************************************************************************
* 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
using namespace Platform::Collections;
using namespace Concurrency;
namespace RingClientUWP
{
delegate void NewContactSelected();
delegate void NoContactSelected();
namespace ViewModel {
public ref class ContactsViewModel sealed
{
internal:
/* singleton */
static property ContactsViewModel^ instance
{
ContactsViewModel^ get()
{
static ContactsViewModel^ instance_ = ref new ContactsViewModel();
return instance_;
}
}
/* functions */
Contact^ findContactByName(String^ name);
Contact^ addNewContact(String^ name, String^ ringId);
void saveContactsToFile();
void openContactsFromFile();
String^ Stringify();
void Destringify(String^ data);
/* properties */
property Contact^ selectedContact
{
Contact^ get()
{
return currentItem_;
}
void set(Contact^ value)
{
oldItem_ = currentItem_;
currentItem_ = value;
if (value)
newContactSelected();
else
noContactSelected();
}
}
property Vector<Contact^>^ contactsList
{
Vector<Contact^>^ get()
{
return contactsList_;
}
}
/* events */
event NewContactSelected^ newContactSelected;
event NoContactSelected^ noContactSelected;
private:
ContactsViewModel(); // singleton
Vector<Contact^>^ contactsList_;
Contact^ currentItem_;
Contact^ oldItem_;
};
}
}
/***************************************************************************
* 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
using namespace Platform::Collections;
using namespace Concurrency;
namespace RingClientUWP
{
delegate void NewContactSelected();
delegate void NoContactSelected();
namespace ViewModel {
public ref class ContactsViewModel sealed
{
internal:
/* singleton */
static property ContactsViewModel^ instance
{
ContactsViewModel^ get()
{
static ContactsViewModel^ instance_ = ref new ContactsViewModel();
return instance_;
}
}
/* functions */
Contact^ findContactByName(String^ name);
Contact^ addNewContact(String^ name, String^ ringId);
void saveContactsToFile();
void openContactsFromFile();
String^ Stringify();
void Destringify(String^ data);
/* properties */
property Contact^ selectedContact
{
Contact^ get()
{
return currentItem_;
}
void set(Contact^ value)
{
oldItem_ = currentItem_;
currentItem_ = value;
if (value)
newContactSelected();
else
noContactSelected();
}
}
property Vector<Contact^>^ contactsList
{
Vector<Contact^>^ get()
{
return contactsList_;
}
}
/* events */
event NewContactSelected^ newContactSelected;
event NoContactSelected^ noContactSelected;
private:
ContactsViewModel(); // singleton
Vector<Contact^>^ contactsList_;
Contact^ currentItem_;
Contact^ oldItem_;
};
}
}
This diff is collapsed.
/***************************************************************************
* 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/>. *
**************************************************************************/
#pragma once
using namespace concurrency;
namespace RingClientUWP
{
/* delegate */
delegate void IncomingCall(String^ accountId, String^ callId, String^ from);
delegate void StateChange(String^ callId, String^ state, int code);
public ref class RingD sealed
{
public:
/* functions */
/* properties */
static property RingD^ instance
{
RingD^ get()
{
static RingD^ instance_ = ref new RingD();
return instance_;
}
}
property bool daemonRunning
{
bool get()
{
return daemonRunning_;
}
}
internal:
/* functions */
void startDaemon();
void reloadAccountList();
/* TODO : move members */
bool hasConfig;
std::string accountName;
/* events */
event IncomingCall^ incomingCall;
event StateChange^ stateChange;
private:
/* sub classes */
enum class Request { None };
ref class Task
{
public:
property Request request;
};
/* functions */
RingD(); // singleton
void dequeueTasks();
/* members */
std::string localFolder_;
bool daemonRunning_ = false;
std::queue<Task^> tasksList_;
};
/***************************************************************************
* 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/>. *
**************************************************************************/
#pragma once
using namespace concurrency;
namespace RingClientUWP
{
/* delegate */
delegate void IncomingCall(String^ accountId, String^ callId, String^ from);
delegate void StateChange(String^ callId, String^ state, int code);
public ref class RingD sealed
{
public:
/* functions */
/* properties */
static property RingD^ instance
{
RingD^ get()
{
static RingD^ instance_ = ref new RingD();
return instance_;
}
}
property bool daemonRunning
{
bool get()
{
return daemonRunning_;
}
}
internal:
/* functions */
void startDaemon();
void reloadAccountList();
/* TODO : move members */
bool hasConfig;
std::string accountName;
/* events */
event IncomingCall^ incomingCall;
event StateChange^ stateChange;
private:
/* sub classes */
enum class Request { None };
ref class Task
{
public:
property Request request;
};
/* functions */
RingD(); // singleton
void dequeueTasks();
/* members */
std::string localFolder_;
bool daemonRunning_ = false;
std::queue<Task^> tasksList_;
};
}
\ No newline at end of file
This diff is collapsed.
/***************************************************************************
* 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"
using namespace Windows::Data::Json;
using namespace Windows::Storage;
using namespace RingClientUWP;
using namespace Platform;
using namespace Configuration;
void
UserPreferences::save()
{
StorageFolder^ localfolder = ApplicationData::Current->LocalFolder;
String^ preferencesFile = "preferences.json";
try {
create_task(localfolder->CreateFileAsync(preferencesFile
,Windows::Storage::CreationCollisionOption::ReplaceExisting))
.then([&](StorageFile^ newFile){
try {
FileIO::WriteTextAsync(newFile,Stringify());
}
catch (Exception^ e) {
RingDebug::instance->print("Exception while writing to preferences file");
}
});
}
catch (Exception^ e) {
RingDebug::instance->print("Exception while opening preferences file");
}
}
void
UserPreferences::load()
{
String^ preferencesFile = "preferences.json";
Utils::fileExists(ApplicationData::Current->LocalFolder,
preferencesFile)
.then([this,preferencesFile](bool contacts_file_exists)
{
if (contacts_file_exists) {
RingDebug::instance->print("opened preferences file");
try {
create_task(ApplicationData::Current->LocalFolder->GetFileAsync(preferencesFile))
.then([this](StorageFile^ file)
{
create_task(FileIO::ReadTextAsync(file))
.then([this](String^ fileContents){
RingDebug::instance->print("reading preferences file");
if (fileContents != nullptr) {
Destringify(fileContents);
// select account index after loading preferences
selectIndex(PREF_ACCOUNT_INDEX);
}
});
});
}
catch (Exception^ e) {
RingDebug::instance->print("Exception while opening preferences file");
}
}
else {
selectIndex(0);
}
});
}
String^
UserPreferences::Stringify()
{
JsonObject^ preferencesObject = ref new JsonObject();
preferencesObject->SetNamedValue("PREF_ACCOUNT_INDEX", JsonValue::CreateNumberValue(PREF_ACCOUNT_INDEX));
return preferencesObject->Stringify();
}
void
UserPreferences::Destringify(String^ data)
{
JsonObject^ jsonObject = JsonObject::Parse(data);
PREF_ACCOUNT_INDEX = static_cast<int>(jsonObject->GetNamedNumber("PREF_ACCOUNT_INDEX"));
JsonArray^ preferencesList = jsonObject->GetNamedArray("Account.index", ref new JsonArray());
/***************************************************************************
* 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"
using namespace Windows::Data::Json;
using namespace Windows::Storage;
using namespace RingClientUWP;
using namespace Platform;
using namespace Configuration;
void
UserPreferences::save()
{
StorageFolder^ localfolder = ApplicationData::Current->LocalFolder;
String^ preferencesFile = "preferences.json";
try {
create_task(localfolder->CreateFileAsync(preferencesFile
,Windows::Storage::CreationCollisionOption::ReplaceExisting))
.then([&](StorageFile^ newFile){
try {
FileIO::WriteTextAsync(newFile,Stringify());
}
catch (Exception^ e) {
RingDebug::instance->print("Exception while writing to preferences file");
}
});
}
catch (Exception^ e) {
RingDebug::instance->print("Exception while opening preferences file");
}
}
void
UserPreferences::load()
{
String^ preferencesFile = "preferences.json";
Utils::fileExists(ApplicationData::Current->LocalFolder,
preferencesFile)
.then([this,preferencesFile](bool contacts_file_exists)
{
if (contacts_file_exists) {
RingDebug::instance->print("opened preferences file");
try {
create_task(ApplicationData::Current->LocalFolder->GetFileAsync(preferencesFile))
.then([this](StorageFile^ file)
{
create_task(FileIO::ReadTextAsync(file))
.then([this](String^ fileContents){
RingDebug::instance->print("reading preferences file");
if (fileContents != nullptr) {
Destringify(fileContents);
// select account index after loading preferences
selectIndex(PREF_ACCOUNT_INDEX);
}
});
});
}
catch (Exception^ e) {
RingDebug::instance->print("Exception while opening preferences file");
}
}
else {
selectIndex(0);
}
});
}
String^
UserPreferences::Stringify()
{
JsonObject^ preferencesObject = ref new JsonObject();
preferencesObject->SetNamedValue("PREF_ACCOUNT_INDEX", JsonValue::CreateNumberValue(PREF_ACCOUNT_INDEX));
return preferencesObject->Stringify();
}
void
UserPreferences::Destringify(String^ data)
{
JsonObject^ jsonObject = JsonObject::Parse(data);
PREF_ACCOUNT_INDEX = static_cast<int>(jsonObject->GetNamedNumber("PREF_ACCOUNT_INDEX"));
JsonArray^ preferencesList = jsonObject->GetNamedArray("Account.index", ref new JsonArray());
}
\ No newline at end of file
#include "pch.h"
#include "Wizard.xaml.h"
#include "MainPage.xaml.h"
using namespace RingClientUWP::Views;
using namespace Concurrency;
using namespace Platform;
using namespace Windows::Devices::Enumeration;
using namespace Windows::Foundation;
using namespace Windows::Foundation::Collections;
using namespace Windows::UI::Xaml;
using namespace Windows::UI::Xaml::Controls;
using namespace Windows::UI::Xaml::Controls::Primitives;
using namespace Windows::UI::Xaml::Data;
using namespace Windows::UI::Xaml::Input;
using namespace Windows::UI::Xaml::Media;
using namespace Windows::UI::Xaml::Navigation;
using namespace Windows::Media::Capture;
Wizard::Wizard()
{
InitializeComponent();
}
void
Wizard::_createAccountYes__Click(Object^ sender, RoutedEventArgs^ e)
{
auto alias = _aliasTextBox_->Text;
if (alias->IsEmpty())
alias = "windows user";
std::wstring wstr(alias->Begin());
std::string str(wstr.begin(), wstr.end());
#include "pch.h"
#include "Wizard.xaml.h"
#include "MainPage.xaml.h"
using namespace RingClientUWP::Views;
using namespace Concurrency;
using namespace Platform;
using namespace Windows::Devices::Enumeration;
using namespace Windows::Foundation;
using namespace Windows::Foundation::Collections;
using namespace Windows::UI::Xaml;
using namespace Windows::UI::Xaml::Controls;
using namespace Windows::UI::Xaml::Controls::Primitives;
using namespace Windows::UI::Xaml::Data;
using namespace Windows::UI::Xaml::Input;
using namespace Windows::UI::Xaml::Media;
using namespace Windows::UI::Xaml::Navigation;
using namespace Windows::Media::Capture;
Wizard::Wizard()
{
InitializeComponent();
}
void
Wizard::_createAccountYes__Click(Object^ sender, RoutedEventArgs^ e)
{
auto alias = _aliasTextBox_->Text;
if (alias->IsEmpty())
alias = "windows user";
std::wstring wstr(alias->Begin());
std::string str(wstr.begin(), wstr.end());
RingD::instance->hasConfig = false;
RingD::instance->accountName = std::string(wstr.begin(), wstr.end());
this->Dispatcher->RunAsync(Windows::UI::Core::CoreDispatcherPriority::Normal, ref new Windows::UI::Core::DispatchedHandler([this] () {
this->Frame->Navigate(Windows::UI::Xaml::Interop::TypeName(RingClientUWP::MainPage::typeid));
}));
}
void
Wizard::_showCreateAccountMenuBtn__Click(Object^ sender, RoutedEventArgs^ e)
{
_accountAddMenuGrid_->Visibility = Windows::UI::Xaml::Visibility::Collapsed;
_showAddAccountMenuTitle_->Visibility = Windows::UI::Xaml::Visibility::Collapsed;
_showAddAccountMenuBtn_->Visibility = Windows::UI::Xaml::Visibility::Visible;
_accountCreationMenuGrid_->Visibility = Windows::UI::Xaml::Visibility::Visible;
_showCreateAccountMenuTitle_->Visibility = Windows::UI::Xaml::Visibility::Visible;
_showCreateAccountMenuBtn_->Visibility = Windows::UI::Xaml::Visibility::Collapsed;
}
void
Wizard::_showAddAccountMenuBtn__Click(Object^ sender, RoutedEventArgs^ e)
{
_accountCreationMenuGrid_->Visibility = Windows::UI::Xaml::Visibility::Collapsed;
_showCreateAccountMenuTitle_->Visibility = Windows::UI::Xaml::Visibility::Collapsed;
_showCreateAccountMenuBtn_->Visibility = Windows::UI::Xaml::Visibility::Visible;
_accountAddMenuGrid_->Visibility = Windows::UI::Xaml::Visibility::Visible;
_showAddAccountMenuTitle_->Visibility = Windows::UI::Xaml::Visibility::Visible;
_showAddAccountMenuBtn_->Visibility = Windows::UI::Xaml::Visibility::Collapsed;
}));
}
void
Wizard::_showCreateAccountMenuBtn__Click(Object^ sender, RoutedEventArgs^ e)
{
_accountAddMenuGrid_->Visibility = Windows::UI::Xaml::Visibility::Collapsed;
_showAddAccountMenuTitle_->Visibility = Windows::UI::Xaml::Visibility::Collapsed;
_showAddAccountMenuBtn_->Visibility = Windows::UI::Xaml::Visibility::Visible;
_accountCreationMenuGrid_->Visibility = Windows::UI::Xaml::Visibility::Visible;
_showCreateAccountMenuTitle_->Visibility = Windows::UI::Xaml::Visibility::Visible;
_showCreateAccountMenuBtn_->Visibility = Windows::UI::Xaml::Visibility::Collapsed;
}
void
Wizard::_showAddAccountMenuBtn__Click(Object^ sender, RoutedEventArgs^ e)
{
_accountCreationMenuGrid_->Visibility = Windows::UI::Xaml::Visibility::Collapsed;
_showCreateAccountMenuTitle_->Visibility = Windows::UI::Xaml::Visibility::Collapsed;
_showCreateAccountMenuBtn_->Visibility = Windows::UI::Xaml::Visibility::Visible;
_accountAddMenuGrid_->Visibility = Windows::UI::Xaml::Visibility::Visible;
_showAddAccountMenuTitle_->Visibility = Windows::UI::Xaml::Visibility::Visible;
_showAddAccountMenuBtn_->Visibility = Windows::UI::Xaml::Visibility::Collapsed;
}
\ 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