Commit 21a37219 authored by camilo higuita's avatar camilo higuita

allow to set the synce server provider in a more dynamic manner

parent 7d3c535c
......@@ -9,12 +9,14 @@
#include <MauiKit/fm.h>
#endif
#include "nextnote.h"
Notes::Notes(QObject *parent) : MauiList(parent),
syncer(new Syncer(this))
{
qDebug()<< "CREATING NOTES LIST";
this->sortList();
this->syncer->setProvider(new NextNote);
connect(this, &Notes::accountChanged, syncer, &Syncer::getNotes);
connect(this, &Notes::sortByChanged, this, &Notes::sortList);
connect(this, &Notes::orderChanged, this, &Notes::sortList);
......
......@@ -45,7 +45,7 @@ public:
* @return
* true if the credentials are all set or false is somethign is missing
*/
virtual bool isValid()
virtual bool isValid() final
{
return !(this->m_user.isEmpty() || this->m_user.isNull()
|| this->m_provider.isEmpty() || this->m_provider.isNull()
......
......@@ -176,7 +176,7 @@ void NextNote::removeNote(const QString &id)
const auto url = QString(NextNote::API+"%1%2").replace("PROVIDER", this->m_provider).arg("notes/", id);
const auto request = formRequest(url, this->m_user, this->m_password);
qDebug()<< "trying to remove nextnote <<" << url;
auto restclient = new QNetworkAccessManager; //constructor
QNetworkReply *reply = restclient->deleteResource(request);
connect(reply, &QNetworkReply::finished, [=]()
......
This diff is collapsed.
......@@ -48,7 +48,7 @@ public:
/**
* @brief setProviderAccount
* sets the credentials to the current account
* for the provider being used
* for the current provider being used
* @param account
* the account data represented by FMH::MODEL
* where the valid keys are:
......@@ -58,6 +58,15 @@ public:
*/
void setAccount(const FMH::MODEL &account);
/**
* @brief setProvider
* sets the provider interface
* this allows to change the provider source
* @param provider
* the provider must inherit the asbtract class AbstractNotesProvider.
* The value passed is then moved to this class private property Syncer::provider
*/
void setProvider(AbstractNotesProvider *provider);
/**
* @brief insertNote
* saves a new note online and offline
......@@ -107,16 +116,6 @@ public:
void getNotes();
private:
// /**
// * @brief currentAccount
// * The current account to store the notes online.
// * The account data is represented by FMH::MODEL, using the keys:
// * FMH::MODEL_KEY::USER representing the username
// * FMH::MODEL_KEY::PASSWORD representing the user password
// * FMH::MODEL_KEY::PROVIDER representing the address to the provider server
// */
// FMH::MODEL currentAccount; //no such good idea to have this here, it adds mroe complexity and confusion
/**
* @brief tag
* Instance of the Maui project tag-ger. It adds tags to the abtract notes
......@@ -153,7 +152,10 @@ private:
*/
static void stampNote(FMH::MODEL &note);
static const QString idFromStamp(DB *db, const QString &provider, const QString &stamp) ;
static const QString idFromStamp(DB *_db, const QString &provider, const QString &stamp) ;
static const QString stampFromId(DB *_db, const QString &id) ;
void setConections();
protected:
/**
......@@ -191,4 +193,5 @@ signals:
public slots:
};
#endif // SYNCER_H
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