Merge lp:~mzanetti/reminders-app/create-notebook into lp:reminders-app

Proposed by Michael Zanetti
Status: Merged
Approved by: Michael Zanetti
Approved revision: 21
Merged at revision: 18
Proposed branch: lp:~mzanetti/reminders-app/create-notebook
Merge into: lp:reminders-app
Prerequisite: lp:~mzanetti/reminders-app/add-reminders
Diff against target: 391 lines (+243/-4)
10 files modified
src/app/qml/ui/NotebooksPage.qml (+10/-0)
src/app/qml/ui/NotesPage.qml (+1/-1)
src/plugin/Evernote/Evernote.pro (+6/-2)
src/plugin/Evernote/jobs/createnotebookjob.cpp (+41/-0)
src/plugin/Evernote/jobs/createnotebookjob.h (+46/-0)
src/plugin/Evernote/jobs/evernotejob.cpp (+10/-1)
src/plugin/Evernote/jobs/expungenotebookjob.cpp (+39/-0)
src/plugin/Evernote/jobs/expungenotebookjob.h (+43/-0)
src/plugin/Evernote/notesstore.cpp (+42/-0)
src/plugin/Evernote/notesstore.h (+5/-0)
To merge this branch: bzr merge lp:~mzanetti/reminders-app/create-notebook
Reviewer Review Type Date Requested Status
Jordan Keyes Approve
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Review via email: mp+198841@code.launchpad.net

Commit message

Added createNotebook to plugin API.

Description of the change

Added createNotebook to plugin API.

I've also added expungeNote, however, with the current API key we aren't allowed to call that.

To post a comment you must log in.
21. By Michael Zanetti

add copyright headers

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Jordan Keyes (jkeyes0) wrote :

Create notebook option seems to work here, at least as far as creating a new notebook named "new notebook" :)

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/app/qml/ui/NotebooksPage.qml'
--- src/app/qml/ui/NotebooksPage.qml 2013-11-26 17:18:33 +0000
+++ src/app/qml/ui/NotebooksPage.qml 2013-12-12 22:46:16 +0000
@@ -30,6 +30,16 @@
30 }30 }
31 }31 }
3232
33 tools: ToolbarItems {
34 ToolbarButton {
35 text: "add notebook"
36 enabled: notes.filterNotebookGuid.length > 0
37 onTriggered: {
38 NotesStore.createNotebook("new notebook");
39 }
40 }
41 }
42
33 Notebooks {43 Notebooks {
34 id: notebooks44 id: notebooks
35 }45 }
3646
=== modified file 'src/app/qml/ui/NotesPage.qml'
--- src/app/qml/ui/NotesPage.qml 2013-12-12 22:46:16 +0000
+++ src/app/qml/ui/NotesPage.qml 2013-12-12 22:46:16 +0000
@@ -62,7 +62,7 @@
62 }62 }
6363
64 onPressAndHold: {64 onPressAndHold: {
65 notes.note(guid).remove();65 NotesStore.deleteNote(guid);
66 }66 }
67 }67 }
68 }68 }
6969
=== modified file 'src/plugin/Evernote/Evernote.pro'
--- src/plugin/Evernote/Evernote.pro 2013-12-12 22:46:16 +0000
+++ src/plugin/Evernote/Evernote.pro 2013-12-12 22:46:16 +0000
@@ -27,7 +27,9 @@
27 evernoteconnection.cpp \27 evernoteconnection.cpp \
28 jobs/userstorejob.cpp \28 jobs/userstorejob.cpp \
29 jobs/notesstorejob.cpp \29 jobs/notesstorejob.cpp \
30 jobs/fetchusernamejob.cpp30 jobs/fetchusernamejob.cpp \
31 jobs/createnotebookjob.cpp \
32 jobs/expungenotebookjob.cpp
3133
32HEADERS += evernoteplugin.h \34HEADERS += evernoteplugin.h \
33 notesstore.h \35 notesstore.h \
@@ -47,7 +49,9 @@
47 evernoteconnection.h \49 evernoteconnection.h \
48 jobs/userstorejob.h \50 jobs/userstorejob.h \
49 jobs/notesstorejob.h \51 jobs/notesstorejob.h \
50 jobs/fetchusernamejob.h52 jobs/fetchusernamejob.h \
53 jobs/createnotebookjob.h \
54 jobs/expungenotebookjob.h
5155
52message(building in $$OUT_PWD)56message(building in $$OUT_PWD)
53LIBS += -L$$OUT_PWD/../../../3rdParty/evernote-sdk-cpp/ -L$$OUT_PWD/../../../3rdParty/libthrift/ -levernote-sdk-cpp -llibthrift -lssl -lcrypto57LIBS += -L$$OUT_PWD/../../../3rdParty/evernote-sdk-cpp/ -L$$OUT_PWD/../../../3rdParty/libthrift/ -levernote-sdk-cpp -llibthrift -lssl -lcrypto
5458
=== added file 'src/plugin/Evernote/jobs/createnotebookjob.cpp'
--- src/plugin/Evernote/jobs/createnotebookjob.cpp 1970-01-01 00:00:00 +0000
+++ src/plugin/Evernote/jobs/createnotebookjob.cpp 2013-12-12 22:46:16 +0000
@@ -0,0 +1,41 @@
1/*
2 * Copyright: 2013 Canonical, Ltd
3 *
4 * This file is part of reminders-app
5 *
6 * reminders-app is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 3.
9 *
10 * reminders-app is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 *
18 * Authors: Michael Zanetti <michael.zanetti@canonical.com>
19 */
20
21#include "createnotebookjob.h"
22
23#include <QDebug>
24
25CreateNotebookJob::CreateNotebookJob(const QString &name, QObject *parent) :
26 NotesStoreJob(parent),
27 m_name(name)
28{
29}
30
31void CreateNotebookJob::startJob()
32{
33 m_result.name = m_name.toStdString();
34 m_result.__isset.name = true;
35 client()->createNotebook(m_result, token().toStdString(), m_result);
36}
37
38void CreateNotebookJob::emitJobDone(EvernoteConnection::ErrorCode errorCode, const QString &errorMessage)
39{
40 emit jobDone(errorCode, errorMessage, m_result);
41}
042
=== added file 'src/plugin/Evernote/jobs/createnotebookjob.h'
--- src/plugin/Evernote/jobs/createnotebookjob.h 1970-01-01 00:00:00 +0000
+++ src/plugin/Evernote/jobs/createnotebookjob.h 2013-12-12 22:46:16 +0000
@@ -0,0 +1,46 @@
1/*
2 * Copyright: 2013 Canonical, Ltd
3 *
4 * This file is part of reminders-app
5 *
6 * reminders-app is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 3.
9 *
10 * reminders-app is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 *
18 * Authors: Michael Zanetti <michael.zanetti@canonical.com>
19 */
20
21#ifndef CREATENOTEBOOKJOB_H
22#define CREATENOTEBOOKJOB_H
23
24#include "notesstorejob.h"
25
26class CreateNotebookJob : public NotesStoreJob
27{
28 Q_OBJECT
29public:
30 explicit CreateNotebookJob(const QString &name, QObject *parent = 0);
31
32 virtual void startJob() override;
33
34signals:
35 void jobDone(EvernoteConnection::ErrorCode errorCode, const QString &errorMessage, const evernote::edam::Notebook &result);
36
37private slots:
38 void emitJobDone(EvernoteConnection::ErrorCode errorCode, const QString &errorMessage);
39
40private:
41 QString m_name;
42
43 evernote::edam::Notebook m_result;
44};
45
46#endif // CREATENOTEBOOKJOB_H
047
=== modified file 'src/plugin/Evernote/jobs/evernotejob.cpp'
--- src/plugin/Evernote/jobs/evernotejob.cpp 2013-12-12 22:46:16 +0000
+++ src/plugin/Evernote/jobs/evernotejob.cpp 2013-12-12 22:46:16 +0000
@@ -55,7 +55,6 @@
5555
56 try {56 try {
57 startJob();57 startJob();
58
59 } catch (const TTransportException & e) {58 } catch (const TTransportException & e) {
6059
61 // The connection broke down. libthrift + evernote servers seem to be quite flaky60 // The connection broke down. libthrift + evernote servers seem to be quite flaky
@@ -68,19 +67,29 @@
68 // Giving up... the connection seems to be down for real.67 // Giving up... the connection seems to be down for real.
69 qWarning() << "Cannot reestablish connection:" << e.what();68 qWarning() << "Cannot reestablish connection:" << e.what();
70 emitJobDone(EvernoteConnection::ErrorCodeConnectionLost, e.what());69 emitJobDone(EvernoteConnection::ErrorCodeConnectionLost, e.what());
70 } catch (const TApplicationException &e) {
71 qWarning() << "Cannot reestablish connection:" << e.what();
72 emitJobDone(EvernoteConnection::ErrorCodeConnectionLost, e.what());
71 } catch (const evernote::edam::EDAMUserException &e) {73 } catch (const evernote::edam::EDAMUserException &e) {
74 qWarning() << "EDAMUserException" << e.what();
72 emitJobDone(EvernoteConnection::ErrorCodeUserException, e.what());75 emitJobDone(EvernoteConnection::ErrorCodeUserException, e.what());
73 } catch (const evernote::edam::EDAMSystemException &e) {76 } catch (const evernote::edam::EDAMSystemException &e) {
77 qWarning() << "EDAMSystemException" << e.what();
74 emitJobDone(EvernoteConnection::ErrorCodeSystemException, e.what());78 emitJobDone(EvernoteConnection::ErrorCodeSystemException, e.what());
75 } catch (const evernote::edam::EDAMNotFoundException &e) {79 } catch (const evernote::edam::EDAMNotFoundException &e) {
80 qWarning() << "EDAMNotFoundException" << e.what();
76 emitJobDone(EvernoteConnection::ErrorCodeNotFoundExcpetion, e.what());81 emitJobDone(EvernoteConnection::ErrorCodeNotFoundExcpetion, e.what());
77 }82 }
7883
84
79 } catch (const evernote::edam::EDAMUserException &e) {85 } catch (const evernote::edam::EDAMUserException &e) {
86 qWarning() << "EDAMUserException" << e.what();
80 emitJobDone(EvernoteConnection::ErrorCodeUserException, e.what());87 emitJobDone(EvernoteConnection::ErrorCodeUserException, e.what());
81 } catch (const evernote::edam::EDAMSystemException &e) {88 } catch (const evernote::edam::EDAMSystemException &e) {
89 qWarning() << "EDAMSystemException" << e.what();
82 emitJobDone(EvernoteConnection::ErrorCodeSystemException, e.what());90 emitJobDone(EvernoteConnection::ErrorCodeSystemException, e.what());
83 } catch (const evernote::edam::EDAMNotFoundException &e) {91 } catch (const evernote::edam::EDAMNotFoundException &e) {
92 qWarning() << "EDAMNotFoundException" << e.what();
84 emitJobDone(EvernoteConnection::ErrorCodeNotFoundExcpetion, e.what());93 emitJobDone(EvernoteConnection::ErrorCodeNotFoundExcpetion, e.what());
85 }94 }
8695
8796
=== added file 'src/plugin/Evernote/jobs/expungenotebookjob.cpp'
--- src/plugin/Evernote/jobs/expungenotebookjob.cpp 1970-01-01 00:00:00 +0000
+++ src/plugin/Evernote/jobs/expungenotebookjob.cpp 2013-12-12 22:46:16 +0000
@@ -0,0 +1,39 @@
1/*
2 * Copyright: 2013 Canonical, Ltd
3 *
4 * This file is part of reminders-app
5 *
6 * reminders-app is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 3.
9 *
10 * reminders-app is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 *
18 * Authors: Michael Zanetti <michael.zanetti@canonical.com>
19 */
20
21#include "expungenotebookjob.h"
22
23#include <QDebug>
24
25ExpungeNotebookJob::ExpungeNotebookJob(const QString &guid, QObject *parent) :
26 NotesStoreJob(parent),
27 m_guid(guid)
28{
29}
30
31void ExpungeNotebookJob::startJob()
32{
33 client()->expungeNotebook(token().toStdString(), m_guid.toStdString());
34}
35
36void ExpungeNotebookJob::emitJobDone(EvernoteConnection::ErrorCode errorCode, const QString &errorMessage)
37{
38 emit jobDone(errorCode, errorMessage, m_guid);
39}
040
=== added file 'src/plugin/Evernote/jobs/expungenotebookjob.h'
--- src/plugin/Evernote/jobs/expungenotebookjob.h 1970-01-01 00:00:00 +0000
+++ src/plugin/Evernote/jobs/expungenotebookjob.h 2013-12-12 22:46:16 +0000
@@ -0,0 +1,43 @@
1/*
2 * Copyright: 2013 Canonical, Ltd
3 *
4 * This file is part of reminders-app
5 *
6 * reminders-app is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 3.
9 *
10 * reminders-app is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 *
18 * Authors: Michael Zanetti <michael.zanetti@canonical.com>
19 */
20
21#ifndef DELETENOTEBOOKJOB_H
22#define DELETENOTEBOOKJOB_H
23
24#include "notesstorejob.h"
25
26class ExpungeNotebookJob : public NotesStoreJob
27{
28 Q_OBJECT
29public:
30 explicit ExpungeNotebookJob(const QString &guid, QObject *parent = 0);
31
32signals:
33 void jobDone(EvernoteConnection::ErrorCode errorCode, const QString &errorMessage, const QString &guid);
34
35private slots:
36 void startJob();
37 void emitJobDone(EvernoteConnection::ErrorCode errorCode, const QString &errorMessage);
38
39private:
40 QString m_guid;
41};
42
43#endif // DELETENOTEBOOKJOB_H
044
=== modified file 'src/plugin/Evernote/notesstore.cpp'
--- src/plugin/Evernote/notesstore.cpp 2013-12-12 22:46:16 +0000
+++ src/plugin/Evernote/notesstore.cpp 2013-12-12 22:46:16 +0000
@@ -31,6 +31,8 @@
31#include "jobs/createnotejob.h"31#include "jobs/createnotejob.h"
32#include "jobs/savenotejob.h"32#include "jobs/savenotejob.h"
33#include "jobs/deletenotejob.h"33#include "jobs/deletenotejob.h"
34#include "jobs/createnotebookjob.h"
35#include "jobs/expungenotebookjob.h"
3436
35#include <QDebug>37#include <QDebug>
3638
@@ -46,6 +48,7 @@
46 qRegisterMetaType<evernote::edam::NotesMetadataList>("evernote::edam::NotesMetadataList");48 qRegisterMetaType<evernote::edam::NotesMetadataList>("evernote::edam::NotesMetadataList");
47 qRegisterMetaType<evernote::edam::Note>("evernote::edam::Note");49 qRegisterMetaType<evernote::edam::Note>("evernote::edam::Note");
48 qRegisterMetaType<std::vector<evernote::edam::Notebook> >("std::vector<evernote::edam::Notebook>");50 qRegisterMetaType<std::vector<evernote::edam::Notebook> >("std::vector<evernote::edam::Notebook>");
51 qRegisterMetaType<evernote::edam::Notebook>("evernote::edam::Notebook");
4952
50}53}
5154
@@ -124,6 +127,20 @@
124 return m_notebooksHash.value(guid);127 return m_notebooksHash.value(guid);
125}128}
126129
130void NotesStore::createNotebook(const QString &name)
131{
132 CreateNotebookJob *job = new CreateNotebookJob(name);
133 connect(job, &CreateNotebookJob::jobDone, this, &NotesStore::createNotebookJobDone);
134 EvernoteConnection::instance()->enqueue(job);
135}
136
137void NotesStore::expungeNotebook(const QString &guid)
138{
139 ExpungeNotebookJob *job = new ExpungeNotebookJob(guid);
140 connect(job, &ExpungeNotebookJob::jobDone, this, &NotesStore::expungeNotebookJobDone);
141 EvernoteConnection::instance()->enqueue(job);
142}
143
127void NotesStore::refreshNotes(const QString &filterNotebookGuid)144void NotesStore::refreshNotes(const QString &filterNotebookGuid)
128{145{
129 FetchNotesJob *job = new FetchNotesJob(filterNotebookGuid);146 FetchNotesJob *job = new FetchNotesJob(filterNotebookGuid);
@@ -316,3 +333,28 @@
316 m_notesHash.take(guid)->deleteLater();333 m_notesHash.take(guid)->deleteLater();
317 endRemoveRows();334 endRemoveRows();
318}335}
336
337void NotesStore::createNotebookJobDone(EvernoteConnection::ErrorCode errorCode, const QString &errorMessage, const evernote::edam::Notebook &result)
338{
339 if (errorCode != EvernoteConnection::ErrorCodeNoError) {
340 qWarning() << "Error creating notebook:" << errorMessage;
341 return;
342 }
343 Notebook *notebook = new Notebook(QString::fromStdString(result.guid));
344 notebook->setName(QString::fromStdString(result.name));
345 m_notebooks.append(notebook);
346 m_notebooksHash.insert(notebook->guid(), notebook);
347 emit notebookAdded(notebook->guid());
348}
349
350void NotesStore::expungeNotebookJobDone(EvernoteConnection::ErrorCode errorCode, const QString &errorMessage, const QString &guid)
351{
352 if (errorCode != EvernoteConnection::ErrorCodeNoError) {
353 qWarning() << "Error expunging notebook:" << errorMessage;
354 return;
355 }
356 emit notebookRemoved(guid);
357 Notebook *notebook = m_notebooksHash.take(guid);
358 m_notebooks.removeAll(notebook);
359 notebook->deleteLater();
360}
319361
=== modified file 'src/plugin/Evernote/notesstore.h'
--- src/plugin/Evernote/notesstore.h 2013-12-12 22:46:16 +0000
+++ src/plugin/Evernote/notesstore.h 2013-12-12 22:46:16 +0000
@@ -56,6 +56,8 @@
5656
57 QList<Notebook*> notebooks() const;57 QList<Notebook*> notebooks() const;
58 Notebook* notebook(const QString &guid);58 Notebook* notebook(const QString &guid);
59 Q_INVOKABLE void createNotebook(const QString &name);
60 Q_INVOKABLE void expungeNotebook(const QString &guid);
5961
60public slots:62public slots:
61 void refreshNotes(const QString &filterNotebookGuid = QString());63 void refreshNotes(const QString &filterNotebookGuid = QString());
@@ -71,6 +73,7 @@
7173
72 void notebookAdded(const QString &guid);74 void notebookAdded(const QString &guid);
73 void notebookChanged(const QString &guid);75 void notebookChanged(const QString &guid);
76 void notebookRemoved(const QString &guid);
7477
75private slots:78private slots:
76 void fetchNotesJobDone(EvernoteConnection::ErrorCode errorCode, const QString &errorMessage, const evernote::edam::NotesMetadataList &results);79 void fetchNotesJobDone(EvernoteConnection::ErrorCode errorCode, const QString &errorMessage, const evernote::edam::NotesMetadataList &results);
@@ -79,6 +82,8 @@
79 void createNoteJobDone(EvernoteConnection::ErrorCode errorCode, const QString &errorMessage, const evernote::edam::Note &result);82 void createNoteJobDone(EvernoteConnection::ErrorCode errorCode, const QString &errorMessage, const evernote::edam::Note &result);
80 void saveNoteJobDone(EvernoteConnection::ErrorCode errorCode, const QString &errorMessage, const evernote::edam::Note &result);83 void saveNoteJobDone(EvernoteConnection::ErrorCode errorCode, const QString &errorMessage, const evernote::edam::Note &result);
81 void deleteNoteJobDone(EvernoteConnection::ErrorCode errorCode, const QString &errorMessage, const QString &guid);84 void deleteNoteJobDone(EvernoteConnection::ErrorCode errorCode, const QString &errorMessage, const QString &guid);
85 void createNotebookJobDone(EvernoteConnection::ErrorCode errorCode, const QString &errorMessage, const evernote::edam::Notebook &result);
86 void expungeNotebookJobDone(EvernoteConnection::ErrorCode errorCode, const QString &errorMessage, const QString &guid);
8287
83private:88private:
84 explicit NotesStore(QObject *parent = 0);89 explicit NotesStore(QObject *parent = 0);

Subscribers

People subscribed via source and target branches