Merge lp:~mzanetti/reminders-app/create-edit-delete-notes into lp:reminders-app
- create-edit-delete-notes
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | David Planella |
Approved revision: | 12 |
Merged at revision: | 10 |
Proposed branch: | lp:~mzanetti/reminders-app/create-edit-delete-notes |
Merge into: | lp:reminders-app |
Prerequisite: | lp:~mzanetti/reminders-app/notes-refactor |
Diff against target: |
967 lines (+466/-90) 24 files modified
src/app/qml/ui/NotePage.qml (+23/-4) src/app/qml/ui/NotesPage.qml (+25/-0) src/plugin/Evernote/Evernote.pro (+14/-6) src/plugin/Evernote/jobs/createnotejob.cpp (+37/-0) src/plugin/Evernote/jobs/createnotejob.h (+22/-0) src/plugin/Evernote/jobs/deletenotejob.cpp (+18/-0) src/plugin/Evernote/jobs/deletenotejob.h (+21/-0) src/plugin/Evernote/jobs/evernotejob.cpp (+49/-0) src/plugin/Evernote/jobs/evernotejob.h (+30/-0) src/plugin/Evernote/jobs/fetchnotebooksjob.cpp (+3/-5) src/plugin/Evernote/jobs/fetchnotebooksjob.h (+4/-15) src/plugin/Evernote/jobs/fetchnotejob.cpp (+9/-8) src/plugin/Evernote/jobs/fetchnotejob.h (+4/-11) src/plugin/Evernote/jobs/fetchnotesjob.cpp (+3/-7) src/plugin/Evernote/jobs/fetchnotesjob.h (+4/-13) src/plugin/Evernote/jobs/savenotejob.cpp (+40/-0) src/plugin/Evernote/jobs/savenotejob.h (+20/-0) src/plugin/Evernote/note.cpp (+20/-0) src/plugin/Evernote/note.h (+8/-2) src/plugin/Evernote/notebooks.cpp (+0/-1) src/plugin/Evernote/notes.cpp (+13/-1) src/plugin/Evernote/notes.h (+1/-0) src/plugin/Evernote/notesstore.cpp (+82/-15) src/plugin/Evernote/notesstore.h (+16/-2) |
To merge this branch: | bzr merge lp:~mzanetti/reminders-app/create-edit-delete-notes |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Ubuntu Phone Apps Jenkins Bot | continuous-integration | Approve | |
David Planella | Approve | ||
Review via email: mp+196500@code.launchpad.net |
This proposal supersedes a proposal from 2013-11-25.
Commit message
Adds support creating, editing and deleting notes.
Description of the change
Adds support creating, editing and deleting notes. Still a bit experimental. Need to figure a way to deal with the doctype.
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : Posted in a previous version of this proposal | # |
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
FAILED: Continuous integration, rev:12
No commit message was specified in the merge proposal. Click on the following link and set the commit message (if you want a jenkins rebuild you need to trigger it yourself):
https:/
http://
Executed test runs:
FAILURE: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
PASSED: Continuous integration, rev:12
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) : | # |
Preview Diff
1 | === modified file 'src/app/qml/ui/NotePage.qml' | |||
2 | --- src/app/qml/ui/NotePage.qml 2013-11-25 09:14:33 +0000 | |||
3 | +++ src/app/qml/ui/NotePage.qml 2013-11-25 09:14:33 +0000 | |||
4 | @@ -6,11 +6,30 @@ | |||
5 | 6 | title: note.title | 6 | title: note.title |
6 | 7 | property var note | 7 | property var note |
7 | 8 | 8 | ||
10 | 9 | TextArea { | 9 | Column { |
9 | 10 | id: noteTextArea | ||
11 | 11 | anchors.fill: parent | 10 | anchors.fill: parent |
14 | 12 | textFormat: TextEdit.RichText | 11 | spacing: units.gu(1) |
15 | 13 | text: note.content | 12 | Button { |
16 | 13 | width: parent.width | ||
17 | 14 | text: "save" | ||
18 | 15 | onClicked: { | ||
19 | 16 | print("timer triggered") | ||
20 | 17 | var content = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><!DOCTYPE en-note SYSTEM \"http://xml.evernote.com/pub/enml2.dtd\"><en-note><div><br clear=\"none\"/>" | ||
21 | 18 | content = content + noteTextArea.getText(0, noteTextArea.length) | ||
22 | 19 | content = content + "<br clear=\"none\"/></div><div><br clear=\"none\"/></div></en-note>" | ||
23 | 20 | note.content = content | ||
24 | 21 | note.save(); | ||
25 | 22 | } | ||
26 | 23 | } | ||
27 | 24 | |||
28 | 25 | TextArea { | ||
29 | 26 | id: noteTextArea | ||
30 | 27 | anchors { left: parent.left; right: parent.right } | ||
31 | 28 | height: parent.height - y | ||
32 | 29 | |||
33 | 30 | textFormat: TextEdit.RichText | ||
34 | 31 | text: note.content | ||
35 | 32 | } | ||
36 | 14 | } | 33 | } |
37 | 15 | } | 34 | } |
38 | 16 | 35 | ||
39 | 17 | 36 | ||
40 | === modified file 'src/app/qml/ui/NotesPage.qml' | |||
41 | --- src/app/qml/ui/NotesPage.qml 2013-11-25 09:14:33 +0000 | |||
42 | +++ src/app/qml/ui/NotesPage.qml 2013-11-25 09:14:33 +0000 | |||
43 | @@ -8,6 +8,27 @@ | |||
44 | 8 | 8 | ||
45 | 9 | property alias filter: notes.filterNotebookGuid | 9 | property alias filter: notes.filterNotebookGuid |
46 | 10 | 10 | ||
47 | 11 | onActiveChanged: { | ||
48 | 12 | if (active) { | ||
49 | 13 | print("refreshing notes") | ||
50 | 14 | notes.refresh(); | ||
51 | 15 | } | ||
52 | 16 | } | ||
53 | 17 | |||
54 | 18 | // Just for testing | ||
55 | 19 | tools: ToolbarItems { | ||
56 | 20 | ToolbarButton { | ||
57 | 21 | text: "add note" | ||
58 | 22 | enabled: notes.filterNotebookGuid.length > 0 | ||
59 | 23 | onTriggered: { | ||
60 | 24 | var content = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><!DOCTYPE en-note SYSTEM \"http://xml.evernote.com/pub/enml2.dtd\"><en-note><div><br clear=\"none\"/>" | ||
61 | 25 | content = content + "fobar" | ||
62 | 26 | content = content + "<br clear=\"none\"/></div><div><br clear=\"none\"/></div></en-note>" | ||
63 | 27 | NotesStore.createNote("Untitled", notes.filterNotebookGuid, content); | ||
64 | 28 | } | ||
65 | 29 | } | ||
66 | 30 | } | ||
67 | 31 | |||
68 | 11 | Notes { | 32 | Notes { |
69 | 12 | id: notes | 33 | id: notes |
70 | 13 | } | 34 | } |
71 | @@ -22,6 +43,10 @@ | |||
72 | 22 | onClicked: { | 43 | onClicked: { |
73 | 23 | pageStack.push(Qt.resolvedUrl("NotePage.qml"), {note: notes.note(guid)}) | 44 | pageStack.push(Qt.resolvedUrl("NotePage.qml"), {note: notes.note(guid)}) |
74 | 24 | } | 45 | } |
75 | 46 | |||
76 | 47 | onPressAndHold: { | ||
77 | 48 | notes.note(guid).remove(); | ||
78 | 49 | } | ||
79 | 25 | } | 50 | } |
80 | 26 | } | 51 | } |
81 | 27 | } | 52 | } |
82 | 28 | 53 | ||
83 | === modified file 'src/plugin/Evernote/Evernote.pro' | |||
84 | --- src/plugin/Evernote/Evernote.pro 2013-11-25 09:14:33 +0000 | |||
85 | +++ src/plugin/Evernote/Evernote.pro 2013-11-25 09:14:33 +0000 | |||
86 | @@ -16,9 +16,13 @@ | |||
87 | 16 | notes.cpp \ | 16 | notes.cpp \ |
88 | 17 | note.cpp \ | 17 | note.cpp \ |
89 | 18 | notebook.cpp \ | 18 | notebook.cpp \ |
93 | 19 | fetchnotesjob.cpp \ | 19 | jobs/fetchnotesjob.cpp \ |
94 | 20 | fetchnotebooksjob.cpp \ | 20 | jobs/fetchnotebooksjob.cpp \ |
95 | 21 | fetchnotejob.cpp | 21 | jobs/fetchnotejob.cpp \ |
96 | 22 | jobs/createnotejob.cpp \ | ||
97 | 23 | jobs/evernotejob.cpp \ | ||
98 | 24 | jobs/savenotejob.cpp \ | ||
99 | 25 | jobs/deletenotejob.cpp | ||
100 | 22 | 26 | ||
101 | 23 | HEADERS += evernoteplugin.h \ | 27 | HEADERS += evernoteplugin.h \ |
102 | 24 | notesstore.h \ | 28 | notesstore.h \ |
103 | @@ -27,9 +31,13 @@ | |||
104 | 27 | notes.h \ | 31 | notes.h \ |
105 | 28 | note.h \ | 32 | note.h \ |
106 | 29 | notebook.h \ | 33 | notebook.h \ |
110 | 30 | fetchnotesjob.h \ | 34 | jobs/fetchnotesjob.h \ |
111 | 31 | fetchnotebooksjob.h \ | 35 | jobs/fetchnotebooksjob.h \ |
112 | 32 | fetchnotejob.h | 36 | jobs/fetchnotejob.h \ |
113 | 37 | jobs/createnotejob.h \ | ||
114 | 38 | jobs/evernotejob.h \ | ||
115 | 39 | jobs/savenotejob.h \ | ||
116 | 40 | jobs/deletenotejob.h | ||
117 | 33 | 41 | ||
118 | 34 | message(building in $$OUT_PWD) | 42 | message(building in $$OUT_PWD) |
119 | 35 | LIBS += -L$$OUT_PWD/../../../3rdParty/evernote-sdk-cpp/ -L$$OUT_PWD/../../../3rdParty/libthrift/ -levernote-sdk-cpp -llibthrift | 43 | LIBS += -L$$OUT_PWD/../../../3rdParty/evernote-sdk-cpp/ -L$$OUT_PWD/../../../3rdParty/libthrift/ -levernote-sdk-cpp -llibthrift |
120 | 36 | 44 | ||
121 | === added directory 'src/plugin/Evernote/jobs' | |||
122 | === added file 'src/plugin/Evernote/jobs/createnotejob.cpp' | |||
123 | --- src/plugin/Evernote/jobs/createnotejob.cpp 1970-01-01 00:00:00 +0000 | |||
124 | +++ src/plugin/Evernote/jobs/createnotejob.cpp 2013-11-25 09:14:33 +0000 | |||
125 | @@ -0,0 +1,37 @@ | |||
126 | 1 | #include "createnotejob.h" | ||
127 | 2 | |||
128 | 3 | #include <QDebug> | ||
129 | 4 | |||
130 | 5 | CreateNoteJob::CreateNoteJob(Note *note, QObject *parent) : | ||
131 | 6 | EvernoteJob(parent), | ||
132 | 7 | m_note(note) | ||
133 | 8 | { | ||
134 | 9 | } | ||
135 | 10 | |||
136 | 11 | void CreateNoteJob::run() | ||
137 | 12 | { | ||
138 | 13 | NotesStore::ErrorCode errorCode = NotesStore::ErrorCodeNoError; | ||
139 | 14 | |||
140 | 15 | try { | ||
141 | 16 | evernote::edam::Note input; | ||
142 | 17 | input.title = m_note->title().toStdString(); | ||
143 | 18 | input.__isset.title = true; | ||
144 | 19 | input.notebookGuid = m_note->notebookGuid().toStdString(); | ||
145 | 20 | input.__isset.notebookGuid = true; | ||
146 | 21 | input.content = m_note->content().toStdString(); | ||
147 | 22 | input.__isset.content = true; | ||
148 | 23 | input.contentLength = m_note->content().length(); | ||
149 | 24 | input.__isset.contentLength = true; | ||
150 | 25 | |||
151 | 26 | evernote::edam::Note result; | ||
152 | 27 | client()->createNote(result, token().toStdString(), input); | ||
153 | 28 | |||
154 | 29 | m_note->setGuid(QString::fromStdString(result.guid)); | ||
155 | 30 | |||
156 | 31 | } catch(evernote::edam::EDAMUserException e) { | ||
157 | 32 | errorCode = NotesStore::ErrorCodeUserException; | ||
158 | 33 | } catch(evernote::edam::EDAMSystemException) { | ||
159 | 34 | errorCode = NotesStore::ErrorCodeSystemException; | ||
160 | 35 | } | ||
161 | 36 | emit resultReady(errorCode, m_note); | ||
162 | 37 | } | ||
163 | 0 | 38 | ||
164 | === added file 'src/plugin/Evernote/jobs/createnotejob.h' | |||
165 | --- src/plugin/Evernote/jobs/createnotejob.h 1970-01-01 00:00:00 +0000 | |||
166 | +++ src/plugin/Evernote/jobs/createnotejob.h 2013-11-25 09:14:33 +0000 | |||
167 | @@ -0,0 +1,22 @@ | |||
168 | 1 | #ifndef CREATENOTEJOB_H | ||
169 | 2 | #define CREATENOTEJOB_H | ||
170 | 3 | |||
171 | 4 | #include "evernotejob.h" | ||
172 | 5 | #include "note.h" | ||
173 | 6 | |||
174 | 7 | class CreateNoteJob : public EvernoteJob | ||
175 | 8 | { | ||
176 | 9 | Q_OBJECT | ||
177 | 10 | public: | ||
178 | 11 | explicit CreateNoteJob(Note *note, QObject *parent = 0); | ||
179 | 12 | |||
180 | 13 | void run(); | ||
181 | 14 | |||
182 | 15 | signals: | ||
183 | 16 | void resultReady(NotesStore::ErrorCode errorCode, Note *note); | ||
184 | 17 | |||
185 | 18 | private: | ||
186 | 19 | Note *m_note; | ||
187 | 20 | }; | ||
188 | 21 | |||
189 | 22 | #endif // CREATENOTEJOB_H | ||
190 | 0 | 23 | ||
191 | === added file 'src/plugin/Evernote/jobs/deletenotejob.cpp' | |||
192 | --- src/plugin/Evernote/jobs/deletenotejob.cpp 1970-01-01 00:00:00 +0000 | |||
193 | +++ src/plugin/Evernote/jobs/deletenotejob.cpp 2013-11-25 09:14:33 +0000 | |||
194 | @@ -0,0 +1,18 @@ | |||
195 | 1 | #include "deletenotejob.h" | ||
196 | 2 | |||
197 | 3 | DeleteNoteJob::DeleteNoteJob(const QString &guid, QObject *parent): | ||
198 | 4 | EvernoteJob(parent), | ||
199 | 5 | m_guid(guid) | ||
200 | 6 | { | ||
201 | 7 | } | ||
202 | 8 | |||
203 | 9 | void DeleteNoteJob::run() | ||
204 | 10 | { | ||
205 | 11 | NotesStore::ErrorCode errorCode = NotesStore::ErrorCodeNoError; | ||
206 | 12 | try { | ||
207 | 13 | client()->deleteNote(token().toStdString(), m_guid.toStdString()); | ||
208 | 14 | } catch(...) { | ||
209 | 15 | catchTransportException(); | ||
210 | 16 | } | ||
211 | 17 | emit resultReady(errorCode, m_guid); | ||
212 | 18 | } | ||
213 | 0 | 19 | ||
214 | === added file 'src/plugin/Evernote/jobs/deletenotejob.h' | |||
215 | --- src/plugin/Evernote/jobs/deletenotejob.h 1970-01-01 00:00:00 +0000 | |||
216 | +++ src/plugin/Evernote/jobs/deletenotejob.h 2013-11-25 09:14:33 +0000 | |||
217 | @@ -0,0 +1,21 @@ | |||
218 | 1 | #ifndef DELETENOTEJOB_H | ||
219 | 2 | #define DELETENOTEJOB_H | ||
220 | 3 | |||
221 | 4 | #include "evernotejob.h" | ||
222 | 5 | |||
223 | 6 | class DeleteNoteJob : public EvernoteJob | ||
224 | 7 | { | ||
225 | 8 | Q_OBJECT | ||
226 | 9 | public: | ||
227 | 10 | DeleteNoteJob(const QString &guid, QObject *parent = 0); | ||
228 | 11 | |||
229 | 12 | void run(); | ||
230 | 13 | |||
231 | 14 | signals: | ||
232 | 15 | void resultReady(NotesStore::ErrorCode errorCode, const QString &guid); | ||
233 | 16 | |||
234 | 17 | private: | ||
235 | 18 | QString m_guid; | ||
236 | 19 | }; | ||
237 | 20 | |||
238 | 21 | #endif // DELETENOTEJOB_H | ||
239 | 0 | 22 | ||
240 | === added file 'src/plugin/Evernote/jobs/evernotejob.cpp' | |||
241 | --- src/plugin/Evernote/jobs/evernotejob.cpp 1970-01-01 00:00:00 +0000 | |||
242 | +++ src/plugin/Evernote/jobs/evernotejob.cpp 2013-11-25 09:14:33 +0000 | |||
243 | @@ -0,0 +1,49 @@ | |||
244 | 1 | #include "evernotejob.h" | ||
245 | 2 | |||
246 | 3 | // Thrift | ||
247 | 4 | #include <arpa/inet.h> // seems thrift forgot this one | ||
248 | 5 | #include <protocol/TBinaryProtocol.h> | ||
249 | 6 | #include <transport/THttpClient.h> | ||
250 | 7 | #include <transport/TSSLSocket.h> | ||
251 | 8 | #include <Thrift.h> | ||
252 | 9 | |||
253 | 10 | #include <QDebug> | ||
254 | 11 | |||
255 | 12 | using namespace apache::thrift; | ||
256 | 13 | using namespace apache::thrift::protocol; | ||
257 | 14 | using namespace apache::thrift::transport; | ||
258 | 15 | |||
259 | 16 | EvernoteJob::EvernoteJob(QObject *parent) : | ||
260 | 17 | QThread(parent), | ||
261 | 18 | m_token(NotesStore::instance()->token()) | ||
262 | 19 | { | ||
263 | 20 | connect(this, &EvernoteJob::finished, this, &EvernoteJob::deleteLater); | ||
264 | 21 | } | ||
265 | 22 | |||
266 | 23 | EvernoteJob::~EvernoteJob() | ||
267 | 24 | { | ||
268 | 25 | |||
269 | 26 | } | ||
270 | 27 | |||
271 | 28 | evernote::edam::NoteStoreClient *EvernoteJob::client() | ||
272 | 29 | { | ||
273 | 30 | return NotesStore::instance()->m_client; | ||
274 | 31 | } | ||
275 | 32 | |||
276 | 33 | QString EvernoteJob::token() | ||
277 | 34 | { | ||
278 | 35 | return m_token; | ||
279 | 36 | } | ||
280 | 37 | |||
281 | 38 | void EvernoteJob::catchTransportException() | ||
282 | 39 | { | ||
283 | 40 | try { | ||
284 | 41 | // this function is meant to be called from a catch block | ||
285 | 42 | // rethrow the exception to catch it again | ||
286 | 43 | throw; | ||
287 | 44 | } catch (const TTransportException & e) { | ||
288 | 45 | qDebug() << e.what(); | ||
289 | 46 | } catch (const TException & e) { | ||
290 | 47 | qDebug() << e.what(); | ||
291 | 48 | } | ||
292 | 49 | } | ||
293 | 0 | 50 | ||
294 | === added file 'src/plugin/Evernote/jobs/evernotejob.h' | |||
295 | --- src/plugin/Evernote/jobs/evernotejob.h 1970-01-01 00:00:00 +0000 | |||
296 | +++ src/plugin/Evernote/jobs/evernotejob.h 2013-11-25 09:14:33 +0000 | |||
297 | @@ -0,0 +1,30 @@ | |||
298 | 1 | #ifndef EVERNOTEJOB_H | ||
299 | 2 | #define EVERNOTEJOB_H | ||
300 | 3 | |||
301 | 4 | #include "notesstore.h" | ||
302 | 5 | |||
303 | 6 | // Evernote SDK | ||
304 | 7 | #include <NoteStore.h> | ||
305 | 8 | #include <NoteStore_constants.h> | ||
306 | 9 | #include <Errors_types.h> | ||
307 | 10 | |||
308 | 11 | #include <QThread> | ||
309 | 12 | |||
310 | 13 | class EvernoteJob : public QThread | ||
311 | 14 | { | ||
312 | 15 | Q_OBJECT | ||
313 | 16 | public: | ||
314 | 17 | explicit EvernoteJob(QObject *parent = 0); | ||
315 | 18 | virtual ~EvernoteJob(); | ||
316 | 19 | |||
317 | 20 | protected: | ||
318 | 21 | evernote::edam::NoteStoreClient* client(); | ||
319 | 22 | QString token(); | ||
320 | 23 | |||
321 | 24 | void catchTransportException(); | ||
322 | 25 | |||
323 | 26 | private: | ||
324 | 27 | QString m_token; | ||
325 | 28 | }; | ||
326 | 29 | |||
327 | 30 | #endif // EVERNOTEJOB_H | ||
328 | 0 | 31 | ||
329 | === renamed file 'src/plugin/Evernote/fetchnotebooksjob.cpp' => 'src/plugin/Evernote/jobs/fetchnotebooksjob.cpp' | |||
330 | --- src/plugin/Evernote/fetchnotebooksjob.cpp 2013-11-25 09:14:33 +0000 | |||
331 | +++ src/plugin/Evernote/jobs/fetchnotebooksjob.cpp 2013-11-25 09:14:33 +0000 | |||
332 | @@ -2,10 +2,8 @@ | |||
333 | 2 | 2 | ||
334 | 3 | #include <QDebug> | 3 | #include <QDebug> |
335 | 4 | 4 | ||
340 | 5 | FetchNotebooksJob::FetchNotebooksJob(evernote::edam::NoteStoreClient *client, const QString &token, QObject *parent) : | 5 | FetchNotebooksJob::FetchNotebooksJob(QObject *parent) : |
341 | 6 | QThread(parent), | 6 | EvernoteJob(parent) |
338 | 7 | m_client(client), | ||
339 | 8 | m_token(token) | ||
342 | 9 | { | 7 | { |
343 | 10 | } | 8 | } |
344 | 11 | 9 | ||
345 | @@ -15,7 +13,7 @@ | |||
346 | 15 | NotesStore::ErrorCode errorCode = NotesStore::ErrorCodeNoError; | 13 | NotesStore::ErrorCode errorCode = NotesStore::ErrorCodeNoError; |
347 | 16 | std::vector<evernote::edam::Notebook> results; | 14 | std::vector<evernote::edam::Notebook> results; |
348 | 17 | try { | 15 | try { |
350 | 18 | m_client->listNotebooks(results, m_token.toStdString()); | 16 | client()->listNotebooks(results, token().toStdString()); |
351 | 19 | } catch(evernote::edam::EDAMUserException) { | 17 | } catch(evernote::edam::EDAMUserException) { |
352 | 20 | errorCode = NotesStore::ErrorCodeUserException; | 18 | errorCode = NotesStore::ErrorCodeUserException; |
353 | 21 | } catch(evernote::edam::EDAMSystemException) { | 19 | } catch(evernote::edam::EDAMSystemException) { |
354 | 22 | 20 | ||
355 | === renamed file 'src/plugin/Evernote/fetchnotebooksjob.h' => 'src/plugin/Evernote/jobs/fetchnotebooksjob.h' | |||
356 | --- src/plugin/Evernote/fetchnotebooksjob.h 2013-11-25 09:14:33 +0000 | |||
357 | +++ src/plugin/Evernote/jobs/fetchnotebooksjob.h 2013-11-25 09:14:33 +0000 | |||
358 | @@ -1,29 +1,18 @@ | |||
359 | 1 | #ifndef FETCHNOTEBOOKSJOB_H | 1 | #ifndef FETCHNOTEBOOKSJOB_H |
360 | 2 | #define FETCHNOTEBOOKSJOB_H | 2 | #define FETCHNOTEBOOKSJOB_H |
361 | 3 | 3 | ||
372 | 4 | #include "notesstore.h" | 4 | #include "evernotejob.h" |
373 | 5 | 5 | ||
374 | 6 | // Evernote SDK | 6 | class FetchNotebooksJob : public EvernoteJob |
365 | 7 | #include <NoteStore.h> | ||
366 | 8 | #include <NoteStore_constants.h> | ||
367 | 9 | #include <Errors_types.h> | ||
368 | 10 | |||
369 | 11 | #include <QThread> | ||
370 | 12 | |||
371 | 13 | class FetchNotebooksJob : public QThread | ||
375 | 14 | { | 7 | { |
376 | 15 | Q_OBJECT | 8 | Q_OBJECT |
377 | 16 | public: | 9 | public: |
379 | 17 | explicit FetchNotebooksJob(evernote::edam::NoteStoreClient *client, const QString &token, QObject *parent = 0); | 10 | explicit FetchNotebooksJob(QObject *parent = 0); |
380 | 18 | 11 | ||
381 | 19 | void run(); | 12 | void run(); |
382 | 20 | 13 | ||
383 | 21 | signals: | 14 | signals: |
384 | 22 | void resultReady(NotesStore::ErrorCode errorCode, const std::vector<evernote::edam::Notebook> &results); | 15 | void resultReady(NotesStore::ErrorCode errorCode, const std::vector<evernote::edam::Notebook> &results); |
385 | 23 | |||
386 | 24 | private: | ||
387 | 25 | evernote::edam::NoteStoreClient *m_client; | ||
388 | 26 | QString m_token; | ||
389 | 27 | }; | 16 | }; |
390 | 28 | 17 | ||
391 | 29 | #endif // FETCHNOTEBOOKSJOB_H | 18 | #endif // FETCHNOTEBOOKSJOB_H |
392 | 30 | 19 | ||
393 | === renamed file 'src/plugin/Evernote/fetchnotejob.cpp' => 'src/plugin/Evernote/jobs/fetchnotejob.cpp' | |||
394 | --- src/plugin/Evernote/fetchnotejob.cpp 2013-11-25 09:14:33 +0000 | |||
395 | +++ src/plugin/Evernote/jobs/fetchnotejob.cpp 2013-11-25 09:14:33 +0000 | |||
396 | @@ -1,9 +1,7 @@ | |||
397 | 1 | #include "fetchnotejob.h" | 1 | #include "fetchnotejob.h" |
398 | 2 | 2 | ||
403 | 3 | FetchNoteJob::FetchNoteJob(evernote::edam::NoteStoreClient *client, const QString &token, const QString &guid, QObject *parent) : | 3 | FetchNoteJob::FetchNoteJob(const QString &guid, QObject *parent) : |
404 | 4 | QThread(parent), | 4 | EvernoteJob(parent), |
401 | 5 | m_client(client), | ||
402 | 6 | m_token(token), | ||
405 | 7 | m_guid(guid) | 5 | m_guid(guid) |
406 | 8 | { | 6 | { |
407 | 9 | } | 7 | } |
408 | @@ -13,13 +11,16 @@ | |||
409 | 13 | NotesStore::ErrorCode errorCode = NotesStore::ErrorCodeNoError; | 11 | NotesStore::ErrorCode errorCode = NotesStore::ErrorCodeNoError; |
410 | 14 | evernote::edam::Note result; | 12 | evernote::edam::Note result; |
411 | 15 | try { | 13 | try { |
414 | 16 | m_client->getNote(result, m_token.toStdString(), m_guid.toStdString(), true, true, false, false); | 14 | client()->getNote(result, token().toStdString(), m_guid.toStdString(), true, true, false, false); |
415 | 17 | } catch(evernote::edam::EDAMUserException) { | 15 | } catch (evernote::edam::EDAMUserException) { |
416 | 18 | errorCode = NotesStore::ErrorCodeUserException; | 16 | errorCode = NotesStore::ErrorCodeUserException; |
418 | 19 | } catch(evernote::edam::EDAMSystemException) { | 17 | } catch (evernote::edam::EDAMSystemException) { |
419 | 20 | errorCode = NotesStore::ErrorCodeSystemException; | 18 | errorCode = NotesStore::ErrorCodeSystemException; |
421 | 21 | } catch(evernote::edam::EDAMNotFoundException) { | 19 | } catch (evernote::edam::EDAMNotFoundException) { |
422 | 22 | errorCode = NotesStore::ErrorCodeNotFoundExcpetion; | 20 | errorCode = NotesStore::ErrorCodeNotFoundExcpetion; |
423 | 21 | } catch (...) { | ||
424 | 22 | catchTransportException(); | ||
425 | 23 | errorCode = NotesStore::ErrorCodeConnectionLost; | ||
426 | 23 | } | 24 | } |
427 | 24 | 25 | ||
428 | 25 | emit resultReady(errorCode, result); | 26 | emit resultReady(errorCode, result); |
429 | 26 | 27 | ||
430 | === renamed file 'src/plugin/Evernote/fetchnotejob.h' => 'src/plugin/Evernote/jobs/fetchnotejob.h' | |||
431 | --- src/plugin/Evernote/fetchnotejob.h 2013-11-25 09:14:33 +0000 | |||
432 | +++ src/plugin/Evernote/jobs/fetchnotejob.h 2013-11-25 09:14:33 +0000 | |||
433 | @@ -1,20 +1,13 @@ | |||
434 | 1 | #ifndef FETCHNOTEJOB_H | 1 | #ifndef FETCHNOTEJOB_H |
435 | 2 | #define FETCHNOTEJOB_H | 2 | #define FETCHNOTEJOB_H |
436 | 3 | 3 | ||
447 | 4 | #include "notesstore.h" | 4 | #include "evernotejob.h" |
448 | 5 | 5 | ||
449 | 6 | // Evernote SDK | 6 | class FetchNoteJob : public EvernoteJob |
440 | 7 | #include <NoteStore.h> | ||
441 | 8 | #include <NoteStore_constants.h> | ||
442 | 9 | #include <Errors_types.h> | ||
443 | 10 | |||
444 | 11 | #include <QThread> | ||
445 | 12 | |||
446 | 13 | class FetchNoteJob : public QThread | ||
450 | 14 | { | 7 | { |
451 | 15 | Q_OBJECT | 8 | Q_OBJECT |
452 | 16 | public: | 9 | public: |
454 | 17 | explicit FetchNoteJob(evernote::edam::NoteStoreClient *client, const QString &token, const QString &guid, QObject *parent = 0); | 10 | explicit FetchNoteJob(const QString &guid, QObject *parent = 0); |
455 | 18 | 11 | ||
456 | 19 | void run(); | 12 | void run(); |
457 | 20 | signals: | 13 | signals: |
458 | 21 | 14 | ||
459 | === renamed file 'src/plugin/Evernote/fetchnotesjob.cpp' => 'src/plugin/Evernote/jobs/fetchnotesjob.cpp' | |||
460 | --- src/plugin/Evernote/fetchnotesjob.cpp 2013-11-25 09:14:33 +0000 | |||
461 | +++ src/plugin/Evernote/jobs/fetchnotesjob.cpp 2013-11-25 09:14:33 +0000 | |||
462 | @@ -4,12 +4,8 @@ | |||
463 | 4 | 4 | ||
464 | 5 | #include <QDebug> | 5 | #include <QDebug> |
465 | 6 | 6 | ||
472 | 7 | FetchNotesJob::FetchNotesJob(evernote::edam::NoteStoreClient *client, | 7 | FetchNotesJob::FetchNotesJob( const QString &filterNotebookGuid, QObject *parent) : |
473 | 8 | const QString &token, | 8 | EvernoteJob(parent), |
468 | 9 | const QString &filterNotebookGuid, QObject *parent) : | ||
469 | 10 | QThread(parent), | ||
470 | 11 | m_client(client), | ||
471 | 12 | m_token(token), | ||
474 | 13 | m_filterNotebookGuid(filterNotebookGuid) | 9 | m_filterNotebookGuid(filterNotebookGuid) |
475 | 14 | { | 10 | { |
476 | 15 | } | 11 | } |
477 | @@ -36,7 +32,7 @@ | |||
478 | 36 | evernote::edam::NotesMetadataList results; | 32 | evernote::edam::NotesMetadataList results; |
479 | 37 | 33 | ||
480 | 38 | try { | 34 | try { |
482 | 39 | m_client->findNotesMetadata(results, m_token.toStdString(), filter, start, end, resultSpec); | 35 | client()->findNotesMetadata(results, token().toStdString(), filter, start, end, resultSpec); |
483 | 40 | } catch(evernote::edam::EDAMUserException) { | 36 | } catch(evernote::edam::EDAMUserException) { |
484 | 41 | errorCode = NotesStore::ErrorCodeUserException; | 37 | errorCode = NotesStore::ErrorCodeUserException; |
485 | 42 | } catch(evernote::edam::EDAMSystemException) { | 38 | } catch(evernote::edam::EDAMSystemException) { |
486 | 43 | 39 | ||
487 | === renamed file 'src/plugin/Evernote/fetchnotesjob.h' => 'src/plugin/Evernote/jobs/fetchnotesjob.h' | |||
488 | --- src/plugin/Evernote/fetchnotesjob.h 2013-11-25 09:14:33 +0000 | |||
489 | +++ src/plugin/Evernote/jobs/fetchnotesjob.h 2013-11-25 09:14:33 +0000 | |||
490 | @@ -1,20 +1,13 @@ | |||
491 | 1 | #ifndef FETCHNOTESJOB_H | 1 | #ifndef FETCHNOTESJOB_H |
492 | 2 | #define FETCHNOTESJOB_H | 2 | #define FETCHNOTESJOB_H |
493 | 3 | 3 | ||
504 | 4 | #include "notesstore.h" | 4 | #include "evernotejob.h" |
505 | 5 | 5 | ||
506 | 6 | // Evernote SDK | 6 | class FetchNotesJob : public EvernoteJob |
497 | 7 | #include <NoteStore.h> | ||
498 | 8 | #include <NoteStore_constants.h> | ||
499 | 9 | #include <Errors_types.h> | ||
500 | 10 | |||
501 | 11 | #include <QThread> | ||
502 | 12 | |||
503 | 13 | class FetchNotesJob : public QThread | ||
507 | 14 | { | 7 | { |
508 | 15 | Q_OBJECT | 8 | Q_OBJECT |
509 | 16 | public: | 9 | public: |
511 | 17 | explicit FetchNotesJob(evernote::edam::NoteStoreClient *client, const QString &token, const QString &filterNotebookGuid, QObject *parent = 0); | 10 | explicit FetchNotesJob(const QString &filterNotebookGuid, QObject *parent = 0); |
512 | 18 | 11 | ||
513 | 19 | void run(); | 12 | void run(); |
514 | 20 | 13 | ||
515 | @@ -22,8 +15,6 @@ | |||
516 | 22 | void resultReady(NotesStore::ErrorCode errorCode, const evernote::edam::NotesMetadataList &results); | 15 | void resultReady(NotesStore::ErrorCode errorCode, const evernote::edam::NotesMetadataList &results); |
517 | 23 | 16 | ||
518 | 24 | private: | 17 | private: |
519 | 25 | evernote::edam::NoteStoreClient *m_client; | ||
520 | 26 | QString m_token; | ||
521 | 27 | QString m_filterNotebookGuid; | 18 | QString m_filterNotebookGuid; |
522 | 28 | }; | 19 | }; |
523 | 29 | 20 | ||
524 | 30 | 21 | ||
525 | === added file 'src/plugin/Evernote/jobs/savenotejob.cpp' | |||
526 | --- src/plugin/Evernote/jobs/savenotejob.cpp 1970-01-01 00:00:00 +0000 | |||
527 | +++ src/plugin/Evernote/jobs/savenotejob.cpp 2013-11-25 09:14:33 +0000 | |||
528 | @@ -0,0 +1,40 @@ | |||
529 | 1 | #include "savenotejob.h" | ||
530 | 2 | #include "note.h" | ||
531 | 3 | |||
532 | 4 | #include <QDebug> | ||
533 | 5 | |||
534 | 6 | SaveNoteJob::SaveNoteJob(Note *note, QObject *parent) : | ||
535 | 7 | EvernoteJob(parent), | ||
536 | 8 | m_note(note) | ||
537 | 9 | { | ||
538 | 10 | } | ||
539 | 11 | |||
540 | 12 | void SaveNoteJob::run() | ||
541 | 13 | { | ||
542 | 14 | NotesStore::ErrorCode errorCode = NotesStore::ErrorCodeNoError; | ||
543 | 15 | try { | ||
544 | 16 | evernote::edam::Note note; | ||
545 | 17 | note.guid = m_note->guid().toStdString(); | ||
546 | 18 | note.__isset.guid = true; | ||
547 | 19 | note.title = m_note->title().toStdString(); | ||
548 | 20 | note.__isset.title = true; | ||
549 | 21 | note.notebookGuid = m_note->notebookGuid().toStdString(); | ||
550 | 22 | note.__isset.notebookGuid = true; | ||
551 | 23 | note.content = m_note->content().toStdString(); | ||
552 | 24 | note.__isset.content = true; | ||
553 | 25 | note.contentLength = m_note->content().length(); | ||
554 | 26 | |||
555 | 27 | client()->updateNote(note, token().toStdString(), note); | ||
556 | 28 | |||
557 | 29 | } catch (evernote::edam::EDAMUserException e) { | ||
558 | 30 | errorCode = NotesStore::ErrorCodeUserException; | ||
559 | 31 | qDebug() << QString::fromStdString(e.parameter); | ||
560 | 32 | } catch (evernote::edam::EDAMSystemException) { | ||
561 | 33 | errorCode = NotesStore::ErrorCodeSystemException; | ||
562 | 34 | } catch (...) { | ||
563 | 35 | catchTransportException(); | ||
564 | 36 | errorCode = NotesStore::ErrorCodeConnectionLost; | ||
565 | 37 | } | ||
566 | 38 | |||
567 | 39 | emit resultReady(errorCode, m_note); | ||
568 | 40 | } | ||
569 | 0 | 41 | ||
570 | === added file 'src/plugin/Evernote/jobs/savenotejob.h' | |||
571 | --- src/plugin/Evernote/jobs/savenotejob.h 1970-01-01 00:00:00 +0000 | |||
572 | +++ src/plugin/Evernote/jobs/savenotejob.h 2013-11-25 09:14:33 +0000 | |||
573 | @@ -0,0 +1,20 @@ | |||
574 | 1 | #ifndef SAVENOTEJOB_H | ||
575 | 2 | #define SAVENOTEJOB_H | ||
576 | 3 | |||
577 | 4 | #include "evernotejob.h" | ||
578 | 5 | |||
579 | 6 | class SaveNoteJob : public EvernoteJob | ||
580 | 7 | { | ||
581 | 8 | Q_OBJECT | ||
582 | 9 | public: | ||
583 | 10 | explicit SaveNoteJob(Note *note, QObject *parent = 0); | ||
584 | 11 | |||
585 | 12 | void run(); | ||
586 | 13 | signals: | ||
587 | 14 | void resultReady(NotesStore::ErrorCode errorCode, Note *note); | ||
588 | 15 | |||
589 | 16 | private: | ||
590 | 17 | Note *m_note; | ||
591 | 18 | }; | ||
592 | 19 | |||
593 | 20 | #endif // SAVENOTEJOB_H | ||
594 | 0 | 21 | ||
595 | === modified file 'src/plugin/Evernote/note.cpp' | |||
596 | --- src/plugin/Evernote/note.cpp 2013-11-25 09:14:33 +0000 | |||
597 | +++ src/plugin/Evernote/note.cpp 2013-11-25 09:14:33 +0000 | |||
598 | @@ -1,5 +1,7 @@ | |||
599 | 1 | #include "note.h" | 1 | #include "note.h" |
600 | 2 | 2 | ||
601 | 3 | #include "notesstore.h" | ||
602 | 4 | |||
603 | 3 | Note::Note(const QString &guid, QObject *parent) : | 5 | Note::Note(const QString &guid, QObject *parent) : |
604 | 4 | QObject(parent), | 6 | QObject(parent), |
605 | 5 | m_guid(guid) | 7 | m_guid(guid) |
606 | @@ -11,6 +13,14 @@ | |||
607 | 11 | return m_guid; | 13 | return m_guid; |
608 | 12 | } | 14 | } |
609 | 13 | 15 | ||
610 | 16 | void Note::setGuid(const QString &guid) | ||
611 | 17 | { | ||
612 | 18 | if (m_guid == guid) { | ||
613 | 19 | m_guid = guid; | ||
614 | 20 | emit guidChanged(); | ||
615 | 21 | } | ||
616 | 22 | } | ||
617 | 23 | |||
618 | 14 | QString Note::notebookGuid() const | 24 | QString Note::notebookGuid() const |
619 | 15 | { | 25 | { |
620 | 16 | return m_notebookGuid; | 26 | return m_notebookGuid; |
621 | @@ -49,3 +59,13 @@ | |||
622 | 49 | emit contentChanged(); | 59 | emit contentChanged(); |
623 | 50 | } | 60 | } |
624 | 51 | } | 61 | } |
625 | 62 | |||
626 | 63 | void Note::save() | ||
627 | 64 | { | ||
628 | 65 | NotesStore::instance()->saveNote(m_guid); | ||
629 | 66 | } | ||
630 | 67 | |||
631 | 68 | void Note::remove() | ||
632 | 69 | { | ||
633 | 70 | NotesStore::instance()->deleteNote(m_guid); | ||
634 | 71 | } | ||
635 | 52 | 72 | ||
636 | === modified file 'src/plugin/Evernote/note.h' | |||
637 | --- src/plugin/Evernote/note.h 2013-11-25 09:14:33 +0000 | |||
638 | +++ src/plugin/Evernote/note.h 2013-11-25 09:14:33 +0000 | |||
639 | @@ -7,14 +7,15 @@ | |||
640 | 7 | { | 7 | { |
641 | 8 | Q_OBJECT | 8 | Q_OBJECT |
642 | 9 | 9 | ||
644 | 10 | Q_PROPERTY(QString guid READ guid CONSTANT) | 10 | Q_PROPERTY(QString guid READ guid NOTIFY guidChanged) |
645 | 11 | Q_PROPERTY(QString notebookGuid READ notebookGuid WRITE setNotebookGuid NOTIFY notebookGuidChanged) | 11 | Q_PROPERTY(QString notebookGuid READ notebookGuid WRITE setNotebookGuid NOTIFY notebookGuidChanged) |
646 | 12 | Q_PROPERTY(QString title READ title WRITE setTitle NOTIFY titleChanged) | 12 | Q_PROPERTY(QString title READ title WRITE setTitle NOTIFY titleChanged) |
647 | 13 | Q_PROPERTY(QString content READ content WRITE setContent NOTIFY contentChanged) | 13 | Q_PROPERTY(QString content READ content WRITE setContent NOTIFY contentChanged) |
648 | 14 | public: | 14 | public: |
650 | 15 | explicit Note(const QString &guid, QObject *parent = 0); | 15 | explicit Note(const QString &guid = QString(), QObject *parent = 0); |
651 | 16 | 16 | ||
652 | 17 | QString guid() const; | 17 | QString guid() const; |
653 | 18 | void setGuid(const QString &guid); | ||
654 | 18 | 19 | ||
655 | 19 | QString notebookGuid() const; | 20 | QString notebookGuid() const; |
656 | 20 | void setNotebookGuid(const QString ¬ebookGuid); | 21 | void setNotebookGuid(const QString ¬ebookGuid); |
657 | @@ -25,7 +26,12 @@ | |||
658 | 25 | QString content() const; | 26 | QString content() const; |
659 | 26 | void setContent(const QString &content); | 27 | void setContent(const QString &content); |
660 | 27 | 28 | ||
661 | 29 | public slots: | ||
662 | 30 | void save(); | ||
663 | 31 | void remove(); | ||
664 | 32 | |||
665 | 28 | signals: | 33 | signals: |
666 | 34 | void guidChanged(); | ||
667 | 29 | void titleChanged(); | 35 | void titleChanged(); |
668 | 30 | void notebookGuidChanged(); | 36 | void notebookGuidChanged(); |
669 | 31 | void contentChanged(); | 37 | void contentChanged(); |
670 | 32 | 38 | ||
671 | === modified file 'src/plugin/Evernote/notebooks.cpp' | |||
672 | --- src/plugin/Evernote/notebooks.cpp 2013-11-25 09:14:33 +0000 | |||
673 | +++ src/plugin/Evernote/notebooks.cpp 2013-11-25 09:14:33 +0000 | |||
674 | @@ -41,7 +41,6 @@ | |||
675 | 41 | 41 | ||
676 | 42 | void Notebooks::refresh() | 42 | void Notebooks::refresh() |
677 | 43 | { | 43 | { |
678 | 44 | qDebug() << "refreshing notebooks"; | ||
679 | 45 | NotesStore::instance()->refreshNotebooks(); | 44 | NotesStore::instance()->refreshNotebooks(); |
680 | 46 | } | 45 | } |
681 | 47 | 46 | ||
682 | 48 | 47 | ||
683 | === modified file 'src/plugin/Evernote/notes.cpp' | |||
684 | --- src/plugin/Evernote/notes.cpp 2013-11-25 09:14:33 +0000 | |||
685 | +++ src/plugin/Evernote/notes.cpp 2013-11-25 09:14:33 +0000 | |||
686 | @@ -6,7 +6,9 @@ | |||
687 | 6 | Notes::Notes(QObject *parent) : | 6 | Notes::Notes(QObject *parent) : |
688 | 7 | QAbstractListModel(parent) | 7 | QAbstractListModel(parent) |
689 | 8 | { | 8 | { |
691 | 9 | connect(NotesStore::instance(), SIGNAL(noteAdded(const QString &)), SLOT(noteAdded(const QString &))); | 9 | connect(NotesStore::instance(), &NotesStore::noteAdded, this, &Notes::noteAdded); |
692 | 10 | connect(NotesStore::instance(), &NotesStore::noteRemoved, this, &Notes::noteRemoved); | ||
693 | 11 | connect(NotesStore::instance(), &NotesStore::noteChanged, this, &Notes::noteChanged); | ||
694 | 10 | } | 12 | } |
695 | 11 | 13 | ||
696 | 12 | QVariant Notes::data(const QModelIndex &index, int role) const | 14 | QVariant Notes::data(const QModelIndex &index, int role) const |
697 | @@ -85,3 +87,13 @@ | |||
698 | 85 | emit dataChanged(index(row), index(row)); | 87 | emit dataChanged(index(row), index(row)); |
699 | 86 | } | 88 | } |
700 | 87 | } | 89 | } |
701 | 90 | |||
702 | 91 | void Notes::noteRemoved(const QString &guid) | ||
703 | 92 | { | ||
704 | 93 | int index = m_list.indexOf(guid); | ||
705 | 94 | if (index >= 0) { | ||
706 | 95 | beginRemoveRows(QModelIndex(), index, index); | ||
707 | 96 | m_list.removeAt(index); | ||
708 | 97 | endRemoveRows(); | ||
709 | 98 | } | ||
710 | 99 | } | ||
711 | 88 | 100 | ||
712 | === modified file 'src/plugin/Evernote/notes.h' | |||
713 | --- src/plugin/Evernote/notes.h 2013-11-25 09:14:33 +0000 | |||
714 | +++ src/plugin/Evernote/notes.h 2013-11-25 09:14:33 +0000 | |||
715 | @@ -35,6 +35,7 @@ | |||
716 | 35 | private slots: | 35 | private slots: |
717 | 36 | void noteAdded(const QString &guid); | 36 | void noteAdded(const QString &guid); |
718 | 37 | void noteChanged(const QString &guid); | 37 | void noteChanged(const QString &guid); |
719 | 38 | void noteRemoved(const QString &guid); | ||
720 | 38 | 39 | ||
721 | 39 | signals: | 40 | signals: |
722 | 40 | void filterNotebookGuidChanged(); | 41 | void filterNotebookGuidChanged(); |
723 | 41 | 42 | ||
724 | === modified file 'src/plugin/Evernote/notesstore.cpp' | |||
725 | --- src/plugin/Evernote/notesstore.cpp 2013-11-25 09:14:33 +0000 | |||
726 | +++ src/plugin/Evernote/notesstore.cpp 2013-11-25 09:14:33 +0000 | |||
727 | @@ -3,9 +3,12 @@ | |||
728 | 3 | #include "notebook.h" | 3 | #include "notebook.h" |
729 | 4 | #include "note.h" | 4 | #include "note.h" |
730 | 5 | 5 | ||
734 | 6 | #include "fetchnotesjob.h" | 6 | #include "jobs/fetchnotesjob.h" |
735 | 7 | #include "fetchnotebooksjob.h" | 7 | #include "jobs/fetchnotebooksjob.h" |
736 | 8 | #include "fetchnotejob.h" | 8 | #include "jobs/fetchnotejob.h" |
737 | 9 | #include "jobs/createnotejob.h" | ||
738 | 10 | #include "jobs/savenotejob.h" | ||
739 | 11 | #include "jobs/deletenotejob.h" | ||
740 | 9 | 12 | ||
741 | 10 | // Thrift | 13 | // Thrift |
742 | 11 | #include <arpa/inet.h> // seems thrift forgot this one | 14 | #include <arpa/inet.h> // seems thrift forgot this one |
743 | @@ -127,6 +130,23 @@ | |||
744 | 127 | return m_notes.value(guid); | 130 | return m_notes.value(guid); |
745 | 128 | } | 131 | } |
746 | 129 | 132 | ||
747 | 133 | void NotesStore::saveNote(const QString &guid) | ||
748 | 134 | { | ||
749 | 135 | Note *note = m_notes.value(guid); | ||
750 | 136 | SaveNoteJob *job = new SaveNoteJob(note, this); | ||
751 | 137 | connect(job, &SaveNoteJob::resultReady, this, &NotesStore::saveNoteJobDone); | ||
752 | 138 | m_jobQueue.append(job); | ||
753 | 139 | startJobQueue(); | ||
754 | 140 | } | ||
755 | 141 | |||
756 | 142 | void NotesStore::deleteNote(const QString &guid) | ||
757 | 143 | { | ||
758 | 144 | DeleteNoteJob *job = new DeleteNoteJob(guid, this); | ||
759 | 145 | connect(job, &DeleteNoteJob::resultReady, this, &NotesStore::deleteNoteJobDone); | ||
760 | 146 | m_jobQueue.append(job); | ||
761 | 147 | startJobQueue(); | ||
762 | 148 | } | ||
763 | 149 | |||
764 | 130 | QList<Notebook *> NotesStore::notebooks() const | 150 | QList<Notebook *> NotesStore::notebooks() const |
765 | 131 | { | 151 | { |
766 | 132 | return m_notebooks.values(); | 152 | return m_notebooks.values(); |
767 | @@ -139,14 +159,14 @@ | |||
768 | 139 | 159 | ||
769 | 140 | void NotesStore::startJobQueue() | 160 | void NotesStore::startJobQueue() |
770 | 141 | { | 161 | { |
772 | 142 | if (m_requestQueue.isEmpty()) { | 162 | if (m_jobQueue.isEmpty()) { |
773 | 143 | return; | 163 | return; |
774 | 144 | } | 164 | } |
775 | 145 | 165 | ||
776 | 146 | if (m_currentJob) { | 166 | if (m_currentJob) { |
777 | 147 | return; | 167 | return; |
778 | 148 | } | 168 | } |
780 | 149 | m_currentJob = m_requestQueue.takeFirst(); | 169 | m_currentJob = m_jobQueue.takeFirst(); |
781 | 150 | m_currentJob->start(); | 170 | m_currentJob->start(); |
782 | 151 | } | 171 | } |
783 | 152 | 172 | ||
784 | @@ -163,11 +183,10 @@ | |||
785 | 163 | return; | 183 | return; |
786 | 164 | } | 184 | } |
787 | 165 | 185 | ||
789 | 166 | FetchNotesJob *job = new FetchNotesJob(m_client, m_token, filterNotebookGuid); | 186 | FetchNotesJob *job = new FetchNotesJob(filterNotebookGuid); |
790 | 167 | connect(job, &FetchNotesJob::resultReady, this, &NotesStore::fetchNotesJobDone); | 187 | connect(job, &FetchNotesJob::resultReady, this, &NotesStore::fetchNotesJobDone); |
791 | 168 | connect(job, &FetchNoteJob::finished, job, &FetchNotesJob::deleteLater); | ||
792 | 169 | 188 | ||
794 | 170 | m_requestQueue.append(job); | 189 | m_jobQueue.append(job); |
795 | 171 | startJobQueue(); | 190 | startJobQueue(); |
796 | 172 | } | 191 | } |
797 | 173 | 192 | ||
798 | @@ -183,7 +202,9 @@ | |||
799 | 183 | evernote::edam::NoteMetadata result = results.notes.at(i); | 202 | evernote::edam::NoteMetadata result = results.notes.at(i); |
800 | 184 | Note *note = m_notes.value(QString::fromStdString(result.guid)); | 203 | Note *note = m_notes.value(QString::fromStdString(result.guid)); |
801 | 185 | if (note) { | 204 | if (note) { |
803 | 186 | qDebug() << "Received update for existing note"; | 205 | note->setTitle(QString::fromStdString(result.title)); |
804 | 206 | note->setNotebookGuid(QString::fromStdString(result.notebookGuid)); | ||
805 | 207 | emit noteChanged(note->guid()); | ||
806 | 187 | } else { | 208 | } else { |
807 | 188 | note = new Note(QString::fromStdString(result.guid), this); | 209 | note = new Note(QString::fromStdString(result.guid), this); |
808 | 189 | note->setNotebookGuid(QString::fromStdString(result.notebookGuid)); | 210 | note->setNotebookGuid(QString::fromStdString(result.notebookGuid)); |
809 | @@ -203,10 +224,9 @@ | |||
810 | 203 | return; | 224 | return; |
811 | 204 | } | 225 | } |
812 | 205 | 226 | ||
814 | 206 | FetchNoteJob *job = new FetchNoteJob(m_client, m_token, guid, this); | 227 | FetchNoteJob *job = new FetchNoteJob(guid, this); |
815 | 207 | connect(job, &FetchNoteJob::resultReady, this, &NotesStore::fetchNoteJobDone); | 228 | connect(job, &FetchNoteJob::resultReady, this, &NotesStore::fetchNoteJobDone); |
818 | 208 | connect(job, &FetchNoteJob::finished, job, &FetchNoteJob::deleteLater); | 229 | m_jobQueue.append(job); |
817 | 209 | m_requestQueue.append(job); | ||
819 | 210 | 230 | ||
820 | 211 | startJobQueue(); | 231 | startJobQueue(); |
821 | 212 | } | 232 | } |
822 | @@ -235,11 +255,10 @@ | |||
823 | 235 | return; | 255 | return; |
824 | 236 | } | 256 | } |
825 | 237 | 257 | ||
827 | 238 | FetchNotebooksJob *job = new FetchNotebooksJob(m_client, m_token); | 258 | FetchNotebooksJob *job = new FetchNotebooksJob(); |
828 | 239 | connect(job, &FetchNotebooksJob::resultReady, this, &NotesStore::fetchNotebooksJobDone); | 259 | connect(job, &FetchNotebooksJob::resultReady, this, &NotesStore::fetchNotebooksJobDone); |
829 | 240 | connect(job, &FetchNotebooksJob::finished, job, &FetchNotebooksJob::deleteLater); | ||
830 | 241 | 260 | ||
832 | 242 | m_requestQueue.append(job); | 261 | m_jobQueue.append(job); |
833 | 243 | startJobQueue(); | 262 | startJobQueue(); |
834 | 244 | } | 263 | } |
835 | 245 | 264 | ||
836 | @@ -256,13 +275,61 @@ | |||
837 | 256 | Notebook *notebook = m_notebooks.value(QString::fromStdString(result.guid)); | 275 | Notebook *notebook = m_notebooks.value(QString::fromStdString(result.guid)); |
838 | 257 | if (notebook) { | 276 | if (notebook) { |
839 | 258 | qDebug() << "got notebook update"; | 277 | qDebug() << "got notebook update"; |
840 | 278 | notebook->setName(QString::fromStdString(result.name)); | ||
841 | 279 | emit notebookChanged(notebook->guid()); | ||
842 | 259 | } else { | 280 | } else { |
843 | 260 | notebook = new Notebook(QString::fromStdString(result.guid), this); | 281 | notebook = new Notebook(QString::fromStdString(result.guid), this); |
844 | 261 | notebook->setName(QString::fromStdString(result.name)); | 282 | notebook->setName(QString::fromStdString(result.name)); |
845 | 262 | m_notebooks.insert(notebook->guid(), notebook); | 283 | m_notebooks.insert(notebook->guid(), notebook); |
846 | 263 | emit notebookAdded(notebook->guid()); | 284 | emit notebookAdded(notebook->guid()); |
847 | 285 | qDebug() << "got new notebook" << notebook->guid(); | ||
848 | 264 | } | 286 | } |
849 | 265 | } | 287 | } |
850 | 266 | 288 | ||
851 | 267 | startNextJob(); | 289 | startNextJob(); |
852 | 268 | } | 290 | } |
853 | 291 | |||
854 | 292 | void NotesStore::createNote(const QString &title, const QString ¬ebookGuid, const QString &content) | ||
855 | 293 | { | ||
856 | 294 | Note *note = new Note(); | ||
857 | 295 | note->setTitle(title); | ||
858 | 296 | note->setNotebookGuid(notebookGuid); | ||
859 | 297 | note->setContent(content); | ||
860 | 298 | CreateNoteJob *job = new CreateNoteJob(note); | ||
861 | 299 | connect(job, &CreateNoteJob::resultReady, this, &NotesStore::createNoteJobDone); | ||
862 | 300 | |||
863 | 301 | m_jobQueue.append(job); | ||
864 | 302 | startJobQueue(); | ||
865 | 303 | } | ||
866 | 304 | |||
867 | 305 | void NotesStore::createNoteJobDone(NotesStore::ErrorCode errorCode, Note *note) | ||
868 | 306 | { | ||
869 | 307 | if (errorCode != ErrorCodeNoError) { | ||
870 | 308 | qWarning() << "Error creating note:" << errorCodeToString(errorCode); | ||
871 | 309 | delete note; | ||
872 | 310 | startNextJob(); | ||
873 | 311 | return; | ||
874 | 312 | } | ||
875 | 313 | |||
876 | 314 | m_notes.insert(note->guid(), note); | ||
877 | 315 | noteAdded(note->guid()); | ||
878 | 316 | startNextJob(); | ||
879 | 317 | } | ||
880 | 318 | |||
881 | 319 | void NotesStore::saveNoteJobDone(NotesStore::ErrorCode errorCode, Note *note) | ||
882 | 320 | { | ||
883 | 321 | startNextJob(); | ||
884 | 322 | } | ||
885 | 323 | |||
886 | 324 | void NotesStore::deleteNoteJobDone(NotesStore::ErrorCode errorCode, const QString &guid) | ||
887 | 325 | { | ||
888 | 326 | if (errorCode != ErrorCodeNoError) { | ||
889 | 327 | qWarning() << "Cannot delete note:" << errorCodeToString(errorCode); | ||
890 | 328 | startNextJob(); | ||
891 | 329 | return; | ||
892 | 330 | } | ||
893 | 331 | emit noteRemoved(guid); | ||
894 | 332 | m_notes.take(guid)->deleteLater(); | ||
895 | 333 | startNextJob(); | ||
896 | 334 | } | ||
897 | 335 | |||
898 | 269 | 336 | ||
899 | === modified file 'src/plugin/Evernote/notesstore.h' | |||
900 | --- src/plugin/Evernote/notesstore.h 2013-11-25 09:14:33 +0000 | |||
901 | +++ src/plugin/Evernote/notesstore.h 2013-11-25 09:14:33 +0000 | |||
902 | @@ -9,6 +9,8 @@ | |||
903 | 9 | #include <QObject> | 9 | #include <QObject> |
904 | 10 | #include <QHash> | 10 | #include <QHash> |
905 | 11 | 11 | ||
906 | 12 | class EvernoteJob; | ||
907 | 13 | |||
908 | 12 | class Notebook; | 14 | class Notebook; |
909 | 13 | class Note; | 15 | class Note; |
910 | 14 | 16 | ||
911 | @@ -17,14 +19,19 @@ | |||
912 | 17 | Q_OBJECT | 19 | Q_OBJECT |
913 | 18 | Q_PROPERTY(QString token READ token WRITE setToken NOTIFY tokenChanged) | 20 | Q_PROPERTY(QString token READ token WRITE setToken NOTIFY tokenChanged) |
914 | 19 | 21 | ||
915 | 22 | friend class EvernoteJob; | ||
916 | 23 | |||
917 | 20 | public: | 24 | public: |
918 | 21 | enum ErrorCode { | 25 | enum ErrorCode { |
919 | 22 | ErrorCodeNoError, | 26 | ErrorCodeNoError, |
920 | 23 | ErrorCodeUserException, | 27 | ErrorCodeUserException, |
921 | 24 | ErrorCodeSystemException, | 28 | ErrorCodeSystemException, |
923 | 25 | ErrorCodeNotFoundExcpetion | 29 | ErrorCodeNotFoundExcpetion, |
924 | 30 | ErrorCodeConnectionLost | ||
925 | 26 | }; | 31 | }; |
926 | 27 | 32 | ||
927 | 33 | Q_INVOKABLE void createNote(const QString &title, const QString ¬ebookGuid, const QString &content); | ||
928 | 34 | |||
929 | 28 | static NotesStore *instance(); | 35 | static NotesStore *instance(); |
930 | 29 | static QString errorCodeToString(ErrorCode errorCode); | 36 | static QString errorCodeToString(ErrorCode errorCode); |
931 | 30 | 37 | ||
932 | @@ -35,6 +42,8 @@ | |||
933 | 35 | 42 | ||
934 | 36 | QList<Note*> notes() const; | 43 | QList<Note*> notes() const; |
935 | 37 | Note* note(const QString &guid); | 44 | Note* note(const QString &guid); |
936 | 45 | void saveNote(const QString &guid); | ||
937 | 46 | void deleteNote(const QString &guid); | ||
938 | 38 | 47 | ||
939 | 39 | QList<Notebook*> notebooks() const; | 48 | QList<Notebook*> notebooks() const; |
940 | 40 | Notebook* notebook(const QString &guid); | 49 | Notebook* notebook(const QString &guid); |
941 | @@ -48,13 +57,18 @@ | |||
942 | 48 | 57 | ||
943 | 49 | void noteAdded(const QString &guid); | 58 | void noteAdded(const QString &guid); |
944 | 50 | void noteChanged(const QString &guid); | 59 | void noteChanged(const QString &guid); |
945 | 60 | void noteRemoved(const QString &guid); | ||
946 | 51 | 61 | ||
947 | 52 | void notebookAdded(const QString &guid); | 62 | void notebookAdded(const QString &guid); |
948 | 63 | void notebookChanged(const QString &guid); | ||
949 | 53 | 64 | ||
950 | 54 | private slots: | 65 | private slots: |
951 | 55 | void fetchNotesJobDone(ErrorCode errorCode, const evernote::edam::NotesMetadataList &results); | 66 | void fetchNotesJobDone(ErrorCode errorCode, const evernote::edam::NotesMetadataList &results); |
952 | 56 | void fetchNotebooksJobDone(ErrorCode errorCode, const std::vector<evernote::edam::Notebook> &results); | 67 | void fetchNotebooksJobDone(ErrorCode errorCode, const std::vector<evernote::edam::Notebook> &results); |
953 | 57 | void fetchNoteJobDone(ErrorCode errorCode, const evernote::edam::Note &result); | 68 | void fetchNoteJobDone(ErrorCode errorCode, const evernote::edam::Note &result); |
954 | 69 | void createNoteJobDone(ErrorCode errorCode, Note *note); | ||
955 | 70 | void saveNoteJobDone(ErrorCode errorCode, Note *note); | ||
956 | 71 | void deleteNoteJobDone(ErrorCode errorCode, const QString &guid); | ||
957 | 58 | 72 | ||
958 | 59 | void startJobQueue(); | 73 | void startJobQueue(); |
959 | 60 | void startNextJob(); | 74 | void startNextJob(); |
960 | @@ -69,7 +83,7 @@ | |||
961 | 69 | QHash<QString, Notebook*> m_notebooks; | 83 | QHash<QString, Notebook*> m_notebooks; |
962 | 70 | QHash<QString, Note*> m_notes; | 84 | QHash<QString, Note*> m_notes; |
963 | 71 | 85 | ||
965 | 72 | QList<QThread*> m_requestQueue; | 86 | QList<EvernoteJob*> m_jobQueue; |
966 | 73 | QThread *m_currentJob; | 87 | QThread *m_currentJob; |
967 | 74 | }; | 88 | }; |
968 | 75 | 89 |
FAILED: Continuous integration, rev:12 91.189. 93.70:8080/ job/reminders- app-ci/ 13/ 91.189. 93.70:8080/ job/generic- mediumtests- trusty/ 235/console 91.189. 93.70:8080/ job/reminders- app-raring- amd64-ci/ 13 91.189. 93.70:8080/ job/reminders- app-saucy- amd64-ci/ 13 91.189. 93.70:8080/ job/reminders- app-trusty- amd64-ci/ 13
http://
Executed test runs:
FAILURE: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild: 91.189. 93.70:8080/ job/reminders- app-ci/ 13/rebuild
http://