Merge lp:~mzanetti/reminders-app/two-job-queues into lp:reminders-app

Proposed by Michael Zanetti
Status: Superseded
Proposed branch: lp:~mzanetti/reminders-app/two-job-queues
Merge into: lp:reminders-app
Diff against target: 2258 lines (+402/-338)
36 files modified
src/app/formattinghelper.cpp (+0/-1)
src/app/main.cpp (+49/-7)
src/app/preferences.h (+0/-1)
src/libqtevernote/CMakeLists.txt (+1/-1)
src/libqtevernote/evernoteconnection.cpp (+98/-59)
src/libqtevernote/evernoteconnection.h (+18/-2)
src/libqtevernote/jobs/createnotebookjob.cpp (+0/-2)
src/libqtevernote/jobs/createnotejob.cpp (+0/-3)
src/libqtevernote/jobs/createtagjob.cpp (+0/-2)
src/libqtevernote/jobs/evernotejob.cpp (+17/-12)
src/libqtevernote/jobs/evernotejob.h (+5/-3)
src/libqtevernote/jobs/expungenotebookjob.cpp (+0/-2)
src/libqtevernote/jobs/fetchnotebooksjob.cpp (+0/-2)
src/libqtevernote/jobs/fetchnotesjob.cpp (+3/-3)
src/libqtevernote/jobs/fetchtagsjob.cpp (+0/-2)
src/libqtevernote/jobs/savenotebookjob.cpp (+0/-2)
src/libqtevernote/jobs/savenotejob.cpp (+0/-3)
src/libqtevernote/jobs/savetagjob.cpp (+0/-2)
src/libqtevernote/logging.cpp (+32/-0)
src/libqtevernote/logging.h (+34/-0)
src/libqtevernote/note.cpp (+14/-25)
src/libqtevernote/note.h (+1/-3)
src/libqtevernote/notebook.cpp (+1/-2)
src/libqtevernote/notebooks.cpp (+0/-2)
src/libqtevernote/notes.cpp (+0/-2)
src/libqtevernote/notesstore.cpp (+113/-103)
src/libqtevernote/resource.cpp (+5/-5)
src/libqtevernote/resourceimageprovider.cpp (+2/-2)
src/libqtevernote/tag.h (+0/-1)
src/libqtevernote/tags.cpp (+0/-2)
src/libqtevernote/userstore.cpp (+2/-3)
src/libqtevernote/utils/enmldocument.cpp (+3/-3)
src/libqtevernote/utils/organizeradapter.cpp (+4/-4)
src/libqtevernote/utils/textformat.cpp (+0/-25)
src/libqtevernote/utils/textformat.h (+0/-43)
src/plugin/Evernote/evernoteplugin.cpp (+0/-4)
To merge this branch: bzr merge lp:~mzanetti/reminders-app/two-job-queues
Reviewer Review Type Date Requested Status
Riccardo Padovani Needs Information
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Review via email: mp+251838@code.launchpad.net

This proposal has been superseded by a proposal from 2015-03-06.

Commit message

split the job queue into two

having two job queues allows more fine grained scheduling and should help with responsiveness in the initial sync of huge evernote accounts. So far we could only prepend high priority jobs and append low priority ones. Now we can also prepend to the low priority queue and react faster to what the user most likely wants to see.

To post a comment you must log in.
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
Riccardo Padovani (rpadovani) wrote :

Looks good to me, but I left a couple of comments, just to be sure changes you made are wanted :-)

review: Needs Information
Revision history for this message
Michael Zanetti (mzanetti) wrote :

Thanks for those comments. While I think this branch is ok, I found an issue with the attachToDuplicate() mechanism. I will fix that in another branch, as that issue is not introduced by this branch.

379. By Michael Zanetti

merge prereq

380. By Michael Zanetti

also allow reprioritizing low priority jobs

381. By Michael Zanetti

add a new priority VeryLow

Resources fetched solely for the purpose of polupating a list should not fill up
the jobqueue that much and prevent text from loading. VeryLow priority jobs
will be appended (as opposed to prepended) to the low priority queue and
thus fetched at the end.

382. By Michael Zanetti

make the resources update in the notes list when they are fetched

383. By Michael Zanetti

improve job queuing further

384. By Michael Zanetti

merge trunk

385. By Michael Zanetti

revert debug print changes

386. By Michael Zanetti

fix url for rtf editor

387. By Michael Zanetti

fix issues from reviews

388. By Michael Zanetti

use qCDebug

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/app/formattinghelper.cpp'
2--- src/app/formattinghelper.cpp 2014-11-12 22:14:59 +0000
3+++ src/app/formattinghelper.cpp 2015-03-06 21:14:46 +0000
4@@ -21,7 +21,6 @@
5
6 #include "formattinghelper.h"
7
8-#include <QDebug>
9 #include <QTextBlock>
10 #include <QTextObject>
11 #include <QTextCharFormat>
12
13=== modified file 'src/app/main.cpp'
14--- src/app/main.cpp 2015-02-24 18:55:55 +0000
15+++ src/app/main.cpp 2015-03-06 21:14:46 +0000
16@@ -29,7 +29,22 @@
17 #include <QLibrary>
18 #include <QCommandLineParser>
19 #include <QCommandLineOption>
20-#include <QDebug>
21+#include <QLoggingCategory>
22+
23+QHash<QString, bool> s_loggingFilters;
24+QLoggingCategory dcApplication("Application");
25+
26+void loggingCategoryFilter(QLoggingCategory *category)
27+{
28+ if (s_loggingFilters.contains(category->categoryName())) {
29+ bool debugEnabled = s_loggingFilters.value(category->categoryName());
30+ category->setEnabled(QtDebugMsg, debugEnabled);
31+ category->setEnabled(QtWarningMsg, debugEnabled || s_loggingFilters.value("Warnings"));
32+ } else {
33+ category->setEnabled(QtDebugMsg, false);
34+ category->setEnabled(QtWarningMsg, s_loggingFilters.value("qml") || s_loggingFilters.value("Warnings"));
35+ }
36+}
37
38 int main(int argc, char *argv[])
39 {
40@@ -37,6 +52,16 @@
41 QQuickView view;
42 view.setResizeMode(QQuickView::SizeRootObjectToView);
43
44+ s_loggingFilters.insert("Warnings", true);
45+ s_loggingFilters.insert("Application", true);
46+ s_loggingFilters.insert("NotesStore", true);
47+ s_loggingFilters.insert("JobQueue", false);
48+ s_loggingFilters.insert("Sync", true);
49+ s_loggingFilters.insert("Connection", true);
50+ s_loggingFilters.insert("Enml", false);
51+ s_loggingFilters.insert("Organizer", false);
52+ s_loggingFilters.insert("qml", true);
53+
54 // Set up import paths
55 QStringList importPathList = view.engine()->importPathList();
56 // Prepend the location of the plugin in the build dir,
57@@ -50,10 +75,16 @@
58 cmdLineParser.addOption(phoneFactorOption);
59 QCommandLineOption tabletFactorOption(QStringList() << "t" << "tablet", "If running on Desktop, start in a tablet sized window.");
60 cmdLineParser.addOption(tabletFactorOption);
61- QCommandLineOption importPathOption("I", "Give a path for an additional QML import directory. May be used multiple times.", "paths");
62+ QCommandLineOption importPathOption("I", "Give a path for an additional QML import directory. May be used multiple times.", "path");
63 cmdLineParser.addOption(importPathOption);
64 QCommandLineOption sandboxOption(QStringList() << "s" << "sandbox", "Use sandbox.evernote.com instead of www.evernote.com.");
65 cmdLineParser.addOption(sandboxOption);
66+ QString debugDescription = QString("Debug categories to enable. Prefix with \"No\" to disable. Warnings from all categories will be printed unless explicitly muted with \"NoWarnings\". May be used multiple times. Categories are:");
67+ foreach (const QString &filterName, s_loggingFilters.keys()) {
68+ debugDescription += "\n" + filterName + " (" + (s_loggingFilters.value(filterName) ? "yes" : "no") + ")";
69+ }
70+ QCommandLineOption debugOption(QStringList() << "d" << "debug", debugDescription, "[No]DebugCategory");
71+ cmdLineParser.addOption(debugOption);
72 QCommandLineOption testabilityOption("testability", "Load the testability driver.");
73 cmdLineParser.addOption(testabilityOption);
74 cmdLineParser.addPositionalArgument("uri", "Uri to start the application in a specific mode. E.g. evernote://newnote to directly create and edit a new note.");
75@@ -61,6 +92,17 @@
76
77 cmdLineParser.process(a);
78
79+ foreach (QString debugArea, cmdLineParser.values(debugOption)) {
80+ bool enable = !debugArea.startsWith("No");
81+ debugArea.remove(QRegExp("^No"));
82+ if (s_loggingFilters.contains(debugArea)) {
83+ s_loggingFilters[debugArea] = enable;
84+ } else {
85+ qWarning() << "No such debug category:" << debugArea;
86+ }
87+ }
88+ QLoggingCategory::installFilter(loggingCategoryFilter);
89+
90 foreach (QString addedPath, cmdLineParser.values(importPathOption)) {
91 if (addedPath == "." || addedPath.startsWith("./")) {
92 addedPath = addedPath.right(addedPath.length() - 1);
93@@ -86,20 +128,20 @@
94
95 if (cmdLineParser.isSet(sandboxOption)) {
96 view.engine()->rootContext()->setContextProperty("useSandbox", QVariant(true));
97- qDebug() << "Running against the sandbox server";
98+ qCDebug(dcApplication) << "Running against the sandbox server";
99 } else {
100 view.engine()->rootContext()->setContextProperty("useSandbox", QVariant(false));
101- qDebug() << "Running against the production server";
102+ qCDebug(dcApplication) << "Running against the production server";
103 }
104
105 view.engine()->rootContext()->setContextProperty("tablet", QVariant(false));
106 view.engine()->rootContext()->setContextProperty("phone", QVariant(false));
107
108 if (cmdLineParser.isSet(tabletFactorOption)) {
109- qDebug() << "running in tablet mode";
110+ qCDebug(dcApplication) << "Running in tablet mode";
111 view.engine()->rootContext()->setContextProperty("tablet", QVariant(true));
112 } else if (cmdLineParser.isSet(phoneFactorOption)){
113- qDebug() << "running in phone mode";
114+ qCDebug(dcApplication) << "Running in phone mode";
115 view.engine()->rootContext()->setContextProperty("phone", QVariant(true));
116 } else if (qgetenv("QT_QPA_PLATFORM") != "ubuntumirclient") {
117 // Default to tablet size on X11
118@@ -140,7 +182,7 @@
119 // So if you want to change it, make sure to find all the places where it is set, not just here :D
120 QCoreApplication::setApplicationName("com.ubuntu.reminders");
121
122- qDebug() << "using main qml file from:" << qmlfile;
123+ qCDebug(dcApplication) << "Using main qml file from:" << qmlfile;
124 view.setSource(QUrl::fromLocalFile(qmlfile));
125 view.show();
126
127
128=== modified file 'src/app/preferences.h'
129--- src/app/preferences.h 2015-02-23 18:00:46 +0000
130+++ src/app/preferences.h 2015-03-06 21:14:46 +0000
131@@ -26,7 +26,6 @@
132 #include <QSettings>
133 #include <QStandardPaths>
134 #include <QObject>
135-#include <QDebug>
136 #include <QList>
137 #include <QColor>
138
139
140=== modified file 'src/libqtevernote/CMakeLists.txt'
141--- src/libqtevernote/CMakeLists.txt 2014-12-06 22:35:01 +0000
142+++ src/libqtevernote/CMakeLists.txt 2015-03-06 21:14:46 +0000
143@@ -14,6 +14,7 @@
144 notebook.cpp
145 tag.cpp
146 tags.cpp
147+ logging.cpp
148 jobs/fetchnotesjob.cpp
149 jobs/fetchnotebooksjob.cpp
150 jobs/fetchnotejob.cpp
151@@ -33,7 +34,6 @@
152 jobs/savetagjob.cpp
153 resourceimageprovider.cpp
154 utils/enmldocument.cpp
155- utils/textformat.cpp
156 utils/organizeradapter.cpp
157 )
158
159
160=== modified file 'src/libqtevernote/evernoteconnection.cpp'
161--- src/libqtevernote/evernoteconnection.cpp 2015-02-27 21:32:29 +0000
162+++ src/libqtevernote/evernoteconnection.cpp 2015-03-06 21:14:46 +0000
163@@ -21,6 +21,7 @@
164
165 #include "evernoteconnection.h"
166 #include "jobs/evernotejob.h"
167+#include "logging.h"
168
169 // Thrift
170 #include <arpa/inet.h> // seems thrift forgot this one
171@@ -36,7 +37,6 @@
172 #include <UserStore_constants.h>
173 #include <Errors_types.h>
174
175-#include <QDebug>
176 #include <QUrl>
177
178 #include <libintl.h>
179@@ -79,11 +79,11 @@
180 if (m_useSSL) {
181 boost::shared_ptr<TSSLSocketFactory> sslSocketFactory(new TSSLSocketFactory());
182 socket = sslSocketFactory->createSocket(m_hostname.toStdString(), 443);
183- qDebug() << "created UserStore SSL socket to host " << m_hostname;
184+ qCDebug(dcConnection) << "created UserStore SSL socket to host " << m_hostname;
185 } else {
186 // Create a non-secure socket
187 socket = boost::shared_ptr<TSocket> (new TSocket(m_hostname.toStdString(), 80));
188- qDebug() << "created insecure UserStore socket to host " << m_hostname;
189+ qCDebug(dcConnection) << "created insecure UserStore socket to host " << m_hostname;
190 }
191
192 // setup UserStore client
193@@ -108,11 +108,11 @@
194 if (m_useSSL) {
195 boost::shared_ptr<TSSLSocketFactory> sslSocketFactory(new TSSLSocketFactory());
196 socket = sslSocketFactory->createSocket(m_hostname.toStdString(), 443);
197- qDebug() << "created NotesStore SSL socket to host " << m_hostname;
198+ qCDebug(dcConnection) << "created NotesStore SSL socket to host " << m_hostname;
199 } else {
200 // Create a non-secure socket
201 socket = boost::shared_ptr<TSocket> (new TSocket(m_hostname.toStdString(), 80));
202- qDebug() << "created insecure NotesStore socket to host " << m_hostname;
203+ qCDebug(dcConnection) << "created insecure NotesStore socket to host " << m_hostname;
204 }
205
206 // setup NotesStore client
207@@ -147,17 +147,23 @@
208
209 void EvernoteConnection::disconnectFromEvernote()
210 {
211- qDebug() << "[Connection] Disconnecting from Evernote.";
212+ qCDebug(dcConnection) << "Disconnecting from Evernote.";
213 if (!isConnected()) {
214- qWarning() << "Not connected. Can't disconnect.";
215+ qCWarning(dcConnection()) << "Not connected. Can't disconnect.";
216 return;
217 }
218
219- foreach (EvernoteJob *job, m_jobQueue) {
220- job->emitJobDone(EvernoteConnection::ErrorCodeConnectionLost, "Disconnected from Evernote");
221- job->deleteLater();
222- }
223- m_jobQueue.clear();
224+ foreach (EvernoteJob *job, m_highPriorityJobQueue) {
225+ job->emitJobDone(EvernoteConnection::ErrorCodeConnectionLost, "Disconnected from Evernote");
226+ job->deleteLater();
227+ }
228+ m_highPriorityJobQueue.clear();
229+
230+ foreach (EvernoteJob *job, m_lowPriorityJobQueue) {
231+ job->emitJobDone(EvernoteConnection::ErrorCodeConnectionLost, "Disconnected from Evernote");
232+ job->deleteLater();
233+ }
234+ m_lowPriorityJobQueue.clear();
235
236 m_errorMessage.clear();
237 emit errorChanged();
238@@ -198,38 +204,38 @@
239 void EvernoteConnection::connectToEvernote()
240 {
241 if (isConnected()) {
242- qWarning() << "Already connected.";
243+ qCWarning(dcConnection) << "Already connected.";
244 return;
245 }
246
247- qDebug() << "[Connection] Connecting to Evernote:" << m_hostname;
248+ qCDebug(dcConnection) << "Connecting to Evernote:" << m_hostname;
249
250 m_errorMessage.clear();
251 emit errorChanged();
252
253 if (m_token.isEmpty()) {
254- qWarning() << "[Connection] Can't connect to Evernote. No token set.";
255+ qCWarning(dcConnection) << "Can't connect to Evernote. No token set.";
256 return;
257 }
258 if (m_hostname.isEmpty()) {
259- qWarning() << "[Connection] Can't connect to Evernote. No hostname set.";
260+ qCWarning(dcConnection) << "Can't connect to Evernote. No hostname set.";
261 }
262
263 setupUserStore();
264 bool ok = connectUserStore();
265 if (!ok) {
266- qWarning() << "[Connection] Error connecting User Store. Cannot continue.";
267+ qCWarning(dcConnection) << "Error connecting User Store. Cannot continue.";
268 return;
269 }
270 setupNotesStore();
271 ok = connectNotesStore();
272
273 if (!ok) {
274- qWarning() << "[Connection] Error connecting Notes Store. Cannot continue.";
275+ qCWarning(dcConnection) << "Error connecting Notes Store. Cannot continue.";
276 return;
277 }
278
279- qDebug() << "[Connection] Connected!";
280+ qCDebug(dcConnection) << "Connected!";
281 emit isConnectedChanged();
282
283 }
284@@ -242,14 +248,14 @@
285
286 try {
287 m_userStoreHttpClient->open();
288- qDebug() << "UserStoreClient socket opened.";
289+ qCDebug(dcConnection) << "UserStoreClient socket opened.";
290 } catch (const TTransportException & e) {
291- qWarning() << "Failed to open connection:" << e.what() << e.getType();
292+ qCWarning(dcConnection) << "Failed to open connection:" << e.what() << e.getType();
293 m_errorMessage = gettext("Offline mode");
294 emit errorChanged();
295 return false;
296 } catch (const TException & e) {
297- qWarning() << "Generic Thrift exception when opening the connection:" << e.what();
298+ qCWarning(dcConnection) << "Generic Thrift exception when opening the connection:" << e.what();
299 m_errorMessage = gettext("Unknown error connecting to Evernote.");
300 emit errorChanged();
301 return false;
302@@ -262,28 +268,28 @@
303 constants.EDAM_VERSION_MINOR);
304
305 if (!versionOk) {
306- qWarning() << "Server version mismatch! This application should be updated!";
307+ qCWarning(dcConnection) << "Server version mismatch! This application should be updated!";
308 m_errorMessage = QString(gettext("Error connecting to Evernote: Server version does not match app version. Please update the application."));
309 emit errorChanged();
310 return false;
311 }
312 } catch (const evernote::edam::EDAMUserException e) {
313- qWarning() << "Error fetching server version (EDAMUserException):" << e.what() << e.errorCode;
314+ qCWarning(dcConnection) << "Error fetching server version (EDAMUserException):" << e.what() << e.errorCode;
315 m_errorMessage = QString(gettext("Error connecting to Evernote: Error code %1")).arg(e.errorCode);
316 emit errorChanged();
317 return false;
318 } catch (const evernote::edam::EDAMSystemException e) {
319- qWarning() << "Error fetching server version: (EDAMSystemException):" << e.what() << e.errorCode;
320+ qCWarning(dcConnection) << "Error fetching server version: (EDAMSystemException):" << e.what() << e.errorCode;
321 m_errorMessage = QString(gettext("Error connecting to Evernote: Error code %1")).arg(e.errorCode);
322 emit errorChanged();
323 return false;
324 } catch (const TTransportException & e) {
325- qWarning() << "Failed to fetch server version:" << e.what();
326+ qCWarning(dcConnection) << "Failed to fetch server version:" << e.what();
327 m_errorMessage = QString(gettext("Error connecting to Evernote: Cannot download version information from server."));
328 emit errorChanged();
329 return false;
330 } catch (const TException & e) {
331- qWarning() << "Generic Thrift exception when fetching server version:" << e.what();
332+ qCWarning(dcConnection) << "Generic Thrift exception when fetching server version:" << e.what();
333 m_errorMessage = QString(gettext("Unknown error connecting to Evernote"));
334 emit errorChanged();
335 return false;
336@@ -291,24 +297,24 @@
337
338 try {
339 std::string notesStoreUrl;
340- qDebug() << "getting ntoe store url with token" << m_token;
341+ qCDebug(dcConnection) << "getting ntoe store url with token" << m_token;
342 m_userstoreClient->getNoteStoreUrl(notesStoreUrl, m_token.toStdString());
343
344 m_notesStorePath = QUrl(QString::fromStdString(notesStoreUrl)).path();
345
346 if (m_notesStorePath.isEmpty()) {
347- qWarning() << "Failed to fetch notesstore path from server. Fetching notes will not work.";
348+ qCWarning(dcConnection) << "Failed to fetch notesstore path from server. Fetching notes will not work.";
349 m_errorMessage = QString(gettext("Error connecting to Evernote: Cannot download server information."));
350 emit errorChanged();
351 return false;
352 }
353 } catch (const TTransportException & e) {
354- qWarning() << "Failed to fetch notestore path:" << e.what();
355+ qCWarning(dcConnection) << "Failed to fetch notestore path:" << e.what();
356 m_errorMessage = QString(gettext("Error connecting to Evernote: Connection failure when downloading server information."));
357 emit errorChanged();
358 return false;
359 } catch (const TException & e) {
360- qWarning() << "Generic Thrift exception when fetching notestore path:" << e.what();
361+ qCWarning(dcConnection) << "Generic Thrift exception when fetching notestore path:" << e.what();
362 m_errorMessage = gettext("Unknown error connecting to Evernote");
363 emit errorChanged();
364 return false;
365@@ -325,26 +331,42 @@
366
367 try {
368 m_notesStoreHttpClient->open();
369- qDebug() << "NotesStoreClient socket opened." << m_notesStoreHttpClient->isOpen();
370+ qCDebug(dcConnection) << "NotesStoreClient socket opened." << m_notesStoreHttpClient->isOpen();
371 return true;
372
373 } catch (const TTransportException & e) {
374- qWarning() << "Failed to open connection:" << e.what();
375+ qCWarning(dcConnection) << "Failed to open connection:" << e.what();
376 m_errorMessage = QString(gettext("Error connecting to Evernote: Connection failure"));
377 emit errorChanged();
378 } catch (const TException & e) {
379- qWarning() << "Generic Thrift exception when opening the NotesStore connection:" << e.what();
380+ qCWarning(dcConnection) << "Generic Thrift exception when opening the NotesStore connection:" << e.what();
381 m_errorMessage = QString(gettext("Unknown Error connecting to Evernote"));
382 emit errorChanged();
383 }
384 return false;
385 }
386
387-EvernoteJob* EvernoteConnection::findDuplicate(EvernoteJob *job)
388-{
389- foreach (EvernoteJob *queuedJob, m_jobQueue) {
390- // explicitly use custom operator==()
391- if (job->operator ==(queuedJob)) {
392+void EvernoteConnection::attachDuplicate(EvernoteJob *original, EvernoteJob *duplicate)
393+{
394+ if (duplicate->originatingObject() && duplicate->originatingObject() != original->originatingObject()) {
395+ duplicate->attachToDuplicate(m_currentJob);
396+ }
397+ connect(original, &EvernoteJob::finished, duplicate, &EvernoteJob::deleteLater);
398+}
399+
400+EvernoteJob* EvernoteConnection::findExistingDuplicate(EvernoteJob *job)
401+{
402+ foreach (EvernoteJob *queuedJob, m_highPriorityJobQueue) {
403+ // explicitly use custom operator==()
404+ if (job->operator ==(queuedJob)) {
405+ qCDebug(dcJobQueue) << "Found duplicate in high priority queue";
406+ return queuedJob;
407+ }
408+ }
409+ foreach (EvernoteJob *queuedJob, m_lowPriorityJobQueue) {
410+ // explicitly use custom operator==()
411+ if (job->operator ==(queuedJob)) {
412+ qCDebug(dcJobQueue) << "Found duplicate in low priority queue";
413 return queuedJob;
414 }
415 }
416@@ -354,31 +376,43 @@
417 void EvernoteConnection::enqueue(EvernoteJob *job)
418 {
419 if (!isConnected()) {
420- qWarning() << "[JobQueue] Not connected to evernote. Can't enqueue job.";
421+ qCWarning(dcJobQueue) << "Not connected to evernote. Can't enqueue job.";
422 job->emitJobDone(ErrorCodeConnectionLost, gettext("Disconnected from Evernote."));
423 job->deleteLater();
424 return;
425 }
426- EvernoteJob *duplicate = findDuplicate(job);
427- if (duplicate) {
428- job->attachToDuplicate(duplicate);
429- connect(duplicate, &EvernoteJob::finished, job, &EvernoteJob::deleteLater);
430+ if (m_currentJob && m_currentJob->operator ==(job)) {
431+ qCDebug(dcJobQueue) << "Duplicate of new job request already running:" << job->toString();
432+ if (m_currentJob->isFinished()) {
433+ job->deleteLater();
434+ } else {
435+ attachDuplicate(m_currentJob, job);
436+ }
437+ return;
438+ }
439+ EvernoteJob *existingJob = findExistingDuplicate(job);
440+ if (existingJob) {
441+ qCDebug(dcJobQueue) << "Duplicate job already queued:" << job->toString();
442+ attachDuplicate(existingJob, job);
443 // reprioritze the repeated request
444- qDebug() << "[JobQueue] Duplicate job already queued:" << job->toString();
445 if (job->jobPriority() == EvernoteJob::JobPriorityHigh) {
446- qDebug() << "[JobQueue] Reprioritising duplicate job:" << job->toString();
447- duplicate->setJobPriority(job->jobPriority());
448- m_jobQueue.prepend(m_jobQueue.takeAt(m_jobQueue.indexOf(duplicate)));
449+ qCDebug(dcJobQueue) << "Reprioritising duplicate job:" << job->toString();
450+ existingJob->setJobPriority(job->jobPriority());
451+ if (m_highPriorityJobQueue.contains(existingJob)) {
452+ m_highPriorityJobQueue.prepend(m_highPriorityJobQueue.takeAt(m_highPriorityJobQueue.indexOf(existingJob)));
453+ } else {
454+ m_highPriorityJobQueue.prepend(m_lowPriorityJobQueue.takeAt(m_lowPriorityJobQueue.indexOf(existingJob)));
455+ }
456 }
457 } else {
458 connect(job, &EvernoteJob::finished, job, &EvernoteJob::deleteLater);
459 connect(job, &EvernoteJob::finished, this, &EvernoteConnection::startNextJob);
460 if (job->jobPriority() == EvernoteJob::JobPriorityHigh) {
461- qDebug() << "[JobQueue] Prepending high priority job request:" << job->toString();
462- m_jobQueue.prepend(job);
463+ qCDebug(dcJobQueue) << "Adding high priority job request:" << job->toString();
464+ m_highPriorityJobQueue.prepend(job);
465 } else {
466- qDebug() << "[JobQueue] Appending low priority job request:" << job->toString();
467- m_jobQueue.append(job);
468+ qCDebug(dcJobQueue) << "Adding low priority job request:" << job->toString();
469+ m_lowPriorityJobQueue.prepend(job);
470 }
471 startJobQueue();
472 }
473@@ -401,22 +435,27 @@
474
475 void EvernoteConnection::startJobQueue()
476 {
477- if (m_jobQueue.isEmpty()) {
478- return;
479- }
480-
481 if (m_currentJob) {
482 return;
483 }
484
485- m_currentJob = m_jobQueue.takeFirst();
486- qDebug() << "[JobQueue] Starting job:" << m_currentJob->toString();
487+ if (m_highPriorityJobQueue.isEmpty() && m_lowPriorityJobQueue.isEmpty()) {
488+ return;
489+ }
490+
491+ if (!m_highPriorityJobQueue.isEmpty()) {
492+ m_currentJob = m_highPriorityJobQueue.takeFirst();
493+ } else {
494+ m_currentJob = m_lowPriorityJobQueue.takeFirst();
495+ }
496+
497+ qCDebug(dcJobQueue) << "Starting job:" << m_currentJob->toString();
498 m_currentJob->start();
499 }
500
501 void EvernoteConnection::startNextJob()
502 {
503- qDebug() << "[JobQueue] Job done:" << m_currentJob->toString();
504+ qCDebug(dcJobQueue) << "Job done:" << m_currentJob->toString();
505 m_currentJob = 0;
506 startJobQueue();
507 }
508
509=== modified file 'src/libqtevernote/evernoteconnection.h'
510--- src/libqtevernote/evernoteconnection.h 2015-02-26 22:47:10 +0000
511+++ src/libqtevernote/evernoteconnection.h 2015-03-06 21:14:46 +0000
512@@ -73,6 +73,18 @@
513 QString token() const;
514 void setToken(const QString &token);
515
516+ // This will add the job to the job queue. The job queue will take ownership of the object
517+ // and manage it's lifetime.
518+ // * If there is an identical job already existing in the queue, the duplicate will be
519+ // attached to original job and not actually fetched a second time from the network in
520+ // order to reduce network traffic.
521+ // * If the new job has a higher priority than the existing one, the existing one will
522+ // reprioritized to the higher priorty.
523+ // * If the jobs have different originatingObjects, each job will emit the jobDone signal,
524+ // if instead the originatingObject is the same in both jobs, only one of them will emit
525+ // a jobDone signal. This is useful if you want to reschedule a job with higher priority
526+ // without having to track previously queued jobs and avoid invoking the connected slot
527+ // multiple times.
528 void enqueue(EvernoteJob *job);
529
530 bool isConnected() const;
531@@ -104,7 +116,10 @@
532 bool connectUserStore();
533 bool connectNotesStore();
534
535- EvernoteJob* findDuplicate(EvernoteJob *job);
536+ EvernoteJob* findExistingDuplicate(EvernoteJob *job);
537+
538+ // "duplicate" will be attached to "original"
539+ void attachDuplicate(EvernoteJob *original, EvernoteJob *duplicate);
540
541 bool m_useSSL;
542 bool m_isConnected;
543@@ -115,7 +130,8 @@
544
545 // There must be only one job running at a time
546 // Do not start jobs other than with startJobQueue()
547- QList<EvernoteJob*> m_jobQueue;
548+ QList<EvernoteJob*> m_highPriorityJobQueue;
549+ QList<EvernoteJob*> m_lowPriorityJobQueue;
550 EvernoteJob *m_currentJob;
551
552 // Those need to be mutexed
553
554=== modified file 'src/libqtevernote/jobs/createnotebookjob.cpp'
555--- src/libqtevernote/jobs/createnotebookjob.cpp 2014-12-08 20:43:10 +0000
556+++ src/libqtevernote/jobs/createnotebookjob.cpp 2015-03-06 21:14:46 +0000
557@@ -21,8 +21,6 @@
558 #include "createnotebookjob.h"
559 #include "notebook.h"
560
561-#include <QDebug>
562-
563 CreateNotebookJob::CreateNotebookJob(Notebook *notebook, QObject *parent) :
564 NotesStoreJob(parent),
565 m_notebook(notebook->clone())
566
567=== modified file 'src/libqtevernote/jobs/createnotejob.cpp'
568--- src/libqtevernote/jobs/createnotejob.cpp 2014-12-14 02:40:47 +0000
569+++ src/libqtevernote/jobs/createnotejob.cpp 2015-03-06 21:14:46 +0000
570@@ -20,8 +20,6 @@
571
572 #include "createnotejob.h"
573
574-#include <QDebug>
575-
576 CreateNoteJob::CreateNoteJob(Note *note, QObject *parent) :
577 NotesStoreJob(parent)
578 {
579@@ -46,7 +44,6 @@
580
581 void CreateNoteJob::startJob()
582 {
583- qDebug() << "creating note:" << m_note->guid() << m_note->enmlContent() << m_note->notebookGuid() << m_note->title();
584 evernote::edam::Note input;
585 input.updateSequenceNum = m_note->updateSequenceNumber();
586 input.__isset.updateSequenceNum = true;
587
588=== modified file 'src/libqtevernote/jobs/createtagjob.cpp'
589--- src/libqtevernote/jobs/createtagjob.cpp 2014-12-10 21:08:38 +0000
590+++ src/libqtevernote/jobs/createtagjob.cpp 2015-03-06 21:14:46 +0000
591@@ -21,8 +21,6 @@
592 #include "createtagjob.h"
593 #include "tag.h"
594
595-#include <QDebug>
596-
597 CreateTagJob::CreateTagJob(Tag *tag, QObject *parent) :
598 NotesStoreJob(parent),
599 m_tag(tag->clone())
600
601=== modified file 'src/libqtevernote/jobs/evernotejob.cpp'
602--- src/libqtevernote/jobs/evernotejob.cpp 2015-02-27 21:32:29 +0000
603+++ src/libqtevernote/jobs/evernotejob.cpp 2015-03-06 21:14:46 +0000
604@@ -20,6 +20,7 @@
605
606 #include "evernotejob.h"
607 #include "evernoteconnection.h"
608+#include "logging.h"
609
610 // Thrift
611 #include <arpa/inet.h> // seems thrift forgot this one
612@@ -33,16 +34,15 @@
613
614 #include <libintl.h>
615
616-#include <QDebug>
617-
618 using namespace apache::thrift;
619 using namespace apache::thrift::protocol;
620 using namespace apache::thrift::transport;
621
622-EvernoteJob::EvernoteJob(QObject *parent, JobPriority jobPriority) :
623- QThread(parent),
624+EvernoteJob::EvernoteJob(QObject *originatingObject, JobPriority jobPriority) :
625+ QThread(nullptr),
626 m_token(EvernoteConnection::instance()->token()),
627- m_jobPriority(jobPriority)
628+ m_jobPriority(jobPriority),
629+ m_originatingObject(originatingObject)
630 {
631 }
632
633@@ -63,7 +63,7 @@
634 void EvernoteJob::run()
635 {
636 if (!EvernoteConnection::instance()->isConnected()) {
637- qWarning() << "EvernoteConnection is not connected. (" << this->metaObject()->className() << ")";
638+ qCWarning(dcJobQueue) << "EvernoteConnection is not connected. (" << toString() << ")";
639 emitJobDone(EvernoteConnection::ErrorCodeUserException, QStringLiteral("Not connected."));
640 return;
641 }
642@@ -76,9 +76,9 @@
643 startJob();
644 emitJobDone(EvernoteConnection::ErrorCodeNoError, QString());
645 } catch (const TTransportException & e) {
646- qWarning() << "TTransportException in" << metaObject()->className() << e.what();
647+ qCWarning(dcJobQueue) << "TTransportException in" << metaObject()->className() << e.what();
648 if (tryCount < 2) {
649- qWarning() << "[JobQueue] Resetting connection...";
650+ qCWarning(dcJobQueue) << "Resetting connection...";
651 try {
652 resetConnection();
653 } catch(...) {}
654@@ -87,9 +87,9 @@
655 emitJobDone(EvernoteConnection::ErrorCodeConnectionLost, e.what());
656 }
657 } catch (const TApplicationException &e) {
658- qWarning() << "TApplicationException in " << metaObject()->className() << e.what();
659+ qCWarning(dcJobQueue) << "TApplicationException in " << metaObject()->className() << e.what();
660 if (tryCount < 2) {
661- qWarning() << "Resetting connection...";
662+ qCWarning(dcJobQueue) << "Resetting connection...";
663 try {
664 resetConnection();
665 } catch(...) {}
666@@ -159,10 +159,10 @@
667 break;
668 }
669 message = message.arg(QString::fromStdString(e.parameter));
670- qWarning() << metaObject()->className() << "EDAMUserException:" << message;
671+ qCWarning(dcJobQueue) << metaObject()->className() << "EDAMUserException:" << message;
672 emitJobDone(EvernoteConnection::ErrorCodeUserException, message);
673 } catch (const evernote::edam::EDAMSystemException &e) {
674- qWarning() << "EDAMSystemException in" << metaObject()->className() << e.what() << e.errorCode << QString::fromStdString(e.message);
675+ qCWarning(dcJobQueue) << "EDAMSystemException in" << metaObject()->className() << e.what() << e.errorCode << QString::fromStdString(e.message);
676 QString message;
677 EvernoteConnection::ErrorCode errorCode;
678 switch (e.errorCode) {
679@@ -199,6 +199,11 @@
680 return metaObject()->className();
681 }
682
683+QObject *EvernoteJob::originatingObject() const
684+{
685+ return m_originatingObject;
686+}
687+
688 QString EvernoteJob::token()
689 {
690 return m_token;
691
692=== modified file 'src/libqtevernote/jobs/evernotejob.h'
693--- src/libqtevernote/jobs/evernotejob.h 2015-02-26 22:47:10 +0000
694+++ src/libqtevernote/jobs/evernotejob.h 2015-03-06 21:14:46 +0000
695@@ -37,8 +37,7 @@
696 * your job won't be executed but you should instead forward the other's job results.
697 *
698 * Jobs can be enqueue()d in NotesStore.
699- * They will destroy themselves when finished.
700- * The jobqueue will take care about starting them.
701+ * The jobqueue will take care about starting them and deleting them.
702 */
703 class EvernoteJob : public QThread
704 {
705@@ -49,7 +48,7 @@
706 JobPriorityLow
707 };
708
709- explicit EvernoteJob(QObject *parent = 0, JobPriority jobPriority = JobPriorityHigh);
710+ explicit EvernoteJob(QObject *originatingObject = 0, JobPriority jobPriority = JobPriorityHigh);
711 virtual ~EvernoteJob();
712
713 JobPriority jobPriority() const;
714@@ -63,6 +62,8 @@
715
716 virtual QString toString() const;
717
718+ QObject* originatingObject() const;
719+
720 signals:
721 void connectionLost(const QString &errorMessage);
722
723@@ -76,6 +77,7 @@
724 private:
725 QString m_token;
726 JobPriority m_jobPriority;
727+ QObject *m_originatingObject;
728
729 friend class EvernoteConnection;
730 };
731
732=== modified file 'src/libqtevernote/jobs/expungenotebookjob.cpp'
733--- src/libqtevernote/jobs/expungenotebookjob.cpp 2014-09-19 21:31:39 +0000
734+++ src/libqtevernote/jobs/expungenotebookjob.cpp 2015-03-06 21:14:46 +0000
735@@ -20,8 +20,6 @@
736
737 #include "expungenotebookjob.h"
738
739-#include <QDebug>
740-
741 ExpungeNotebookJob::ExpungeNotebookJob(const QString &guid, QObject *parent) :
742 NotesStoreJob(parent),
743 m_guid(guid)
744
745=== modified file 'src/libqtevernote/jobs/fetchnotebooksjob.cpp'
746--- src/libqtevernote/jobs/fetchnotebooksjob.cpp 2014-09-19 21:31:39 +0000
747+++ src/libqtevernote/jobs/fetchnotebooksjob.cpp 2015-03-06 21:14:46 +0000
748@@ -20,8 +20,6 @@
749
750 #include "fetchnotebooksjob.h"
751
752-#include <QDebug>
753-
754 FetchNotebooksJob::FetchNotebooksJob(QObject *parent) :
755 NotesStoreJob(parent)
756 {
757
758=== modified file 'src/libqtevernote/jobs/fetchnotesjob.cpp'
759--- src/libqtevernote/jobs/fetchnotesjob.cpp 2015-02-26 22:47:10 +0000
760+++ src/libqtevernote/jobs/fetchnotesjob.cpp 2015-03-06 21:14:46 +0000
761@@ -25,8 +25,6 @@
762 // evernote sdk
763 #include "Limits_constants.h"
764
765-#include <QDebug>
766-
767 FetchNotesJob::FetchNotesJob(const QString &filterNotebookGuid, const QString &searchWords, int startIndex, int chunkSize, QObject *parent) :
768 NotesStoreJob(parent),
769 m_filterNotebookGuid(filterNotebookGuid),
770@@ -43,7 +41,9 @@
771 return false;
772 }
773 return this->m_filterNotebookGuid == otherJob->m_filterNotebookGuid
774- && this->m_searchWords == otherJob->m_searchWords;
775+ && this->m_searchWords == otherJob->m_searchWords
776+ && this->m_startIndex == otherJob->m_startIndex
777+ && this->m_chunkSize == otherJob->m_chunkSize;
778 }
779
780 void FetchNotesJob::attachToDuplicate(const EvernoteJob *other)
781
782=== modified file 'src/libqtevernote/jobs/fetchtagsjob.cpp'
783--- src/libqtevernote/jobs/fetchtagsjob.cpp 2014-10-09 00:08:52 +0000
784+++ src/libqtevernote/jobs/fetchtagsjob.cpp 2015-03-06 21:14:46 +0000
785@@ -20,8 +20,6 @@
786
787 #include "fetchtagsjob.h"
788
789-#include <QDebug>
790-
791 FetchTagsJob::FetchTagsJob(QObject *parent) :
792 NotesStoreJob(parent)
793 {
794
795=== modified file 'src/libqtevernote/jobs/savenotebookjob.cpp'
796--- src/libqtevernote/jobs/savenotebookjob.cpp 2015-03-04 00:23:45 +0000
797+++ src/libqtevernote/jobs/savenotebookjob.cpp 2015-03-06 21:14:46 +0000
798@@ -21,8 +21,6 @@
799 #include "savenotebookjob.h"
800 #include "notebook.h"
801
802-#include <QDebug>
803-
804 SaveNotebookJob::SaveNotebookJob(Notebook *notebook, QObject *parent) :
805 NotesStoreJob(parent)
806 {
807
808=== modified file 'src/libqtevernote/jobs/savenotejob.cpp'
809--- src/libqtevernote/jobs/savenotejob.cpp 2015-02-27 22:15:02 +0000
810+++ src/libqtevernote/jobs/savenotejob.cpp 2015-03-06 21:14:46 +0000
811@@ -21,8 +21,6 @@
812 #include "savenotejob.h"
813 #include "note.h"
814
815-#include <QDebug>
816-
817 SaveNoteJob::SaveNoteJob(Note *note, QObject *parent) :
818 NotesStoreJob(parent)
819 {
820@@ -86,7 +84,6 @@
821 note.attributes.reminderDoneTime = m_note->reminderDoneTime().toMSecsSinceEpoch();
822 note.attributes.__isset.reminderDoneTime = true;
823
824- qDebug() << "*** needs content sync" << m_note->needsContentSync();
825 if (m_note->needsContentSync()) {
826 note.content = m_note->enmlContent().toStdString();
827 note.__isset.content = true;
828
829=== modified file 'src/libqtevernote/jobs/savetagjob.cpp'
830--- src/libqtevernote/jobs/savetagjob.cpp 2014-12-13 03:55:52 +0000
831+++ src/libqtevernote/jobs/savetagjob.cpp 2015-03-06 21:14:46 +0000
832@@ -21,8 +21,6 @@
833 #include "savetagjob.h"
834 #include "tag.h"
835
836-#include <QDebug>
837-
838 SaveTagJob::SaveTagJob(Tag *tag, QObject *parent) :
839 NotesStoreJob(parent)
840 {
841
842=== added file 'src/libqtevernote/logging.cpp'
843--- src/libqtevernote/logging.cpp 1970-01-01 00:00:00 +0000
844+++ src/libqtevernote/logging.cpp 2015-03-06 21:14:46 +0000
845@@ -0,0 +1,32 @@
846+/*
847+ * Copyright: 2015 Canonical, Ltd
848+ *
849+ * This file is part of reminders
850+ *
851+ * reminders is free software: you can redistribute it and/or modify
852+ * it under the terms of the GNU General Public License as published by
853+ * the Free Software Foundation; version 3.
854+ *
855+ * reminders is distributed in the hope that it will be useful,
856+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
857+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
858+ * GNU General Public License for more details.
859+ *
860+ * You should have received a copy of the GNU General Public License
861+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
862+ *
863+ * Authors: Michael Zanetti <michael.zanetti@canonical.com>
864+ * Riccardo Padovani <rpadovani@ubuntu.com>
865+ */
866+
867+#include "logging.h"
868+
869+#include <QLoggingCategory>
870+
871+Q_LOGGING_CATEGORY(dcNotesStore, "NotesStore")
872+Q_LOGGING_CATEGORY(dcJobQueue,"JobQueue")
873+Q_LOGGING_CATEGORY(dcConnection,"Connection")
874+Q_LOGGING_CATEGORY(dcSync,"Sync")
875+Q_LOGGING_CATEGORY(dcStorage,"Storage")
876+Q_LOGGING_CATEGORY(dcEnml,"Enml")
877+Q_LOGGING_CATEGORY(dcOrganizer,"Organizer")
878
879=== added file 'src/libqtevernote/logging.h'
880--- src/libqtevernote/logging.h 1970-01-01 00:00:00 +0000
881+++ src/libqtevernote/logging.h 2015-03-06 21:14:46 +0000
882@@ -0,0 +1,34 @@
883+/*
884+ * Copyright: 2015 Canonical, Ltd
885+ *
886+ * This file is part of reminders
887+ *
888+ * reminders is free software: you can redistribute it and/or modify
889+ * it under the terms of the GNU General Public License as published by
890+ * the Free Software Foundation; version 3.
891+ *
892+ * reminders is distributed in the hope that it will be useful,
893+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
894+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
895+ * GNU General Public License for more details.
896+ *
897+ * You should have received a copy of the GNU General Public License
898+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
899+ *
900+ * Authors: Michael Zanetti <michael.zanetti@canonical.com>
901+ * Riccardo Padovani <rpadovani@ubuntu.com>
902+ */
903+
904+#ifndef LOGGING_H
905+#define LOGGING_H
906+
907+#include <QLoggingCategory>
908+
909+Q_DECLARE_LOGGING_CATEGORY(dcNotesStore)
910+Q_DECLARE_LOGGING_CATEGORY(dcJobQueue)
911+Q_DECLARE_LOGGING_CATEGORY(dcConnection)
912+Q_DECLARE_LOGGING_CATEGORY(dcSync)
913+Q_DECLARE_LOGGING_CATEGORY(dcEnml)
914+Q_DECLARE_LOGGING_CATEGORY(dcOrganizer)
915+
916+#endif
917
918=== modified file 'src/libqtevernote/note.cpp'
919--- src/libqtevernote/note.cpp 2015-03-05 18:23:25 +0000
920+++ src/libqtevernote/note.cpp 2015-03-06 21:14:46 +0000
921@@ -21,6 +21,7 @@
922 #include "note.h"
923
924 #include "notesstore.h"
925+#include "logging.h"
926
927 #include <libintl.h>
928
929@@ -28,7 +29,6 @@
930 #include <QUrl>
931 #include <QUrlQuery>
932 #include <QStandardPaths>
933-#include <QDebug>
934 #include <QCryptographicHash>
935 #include <QFile>
936
937@@ -71,15 +71,13 @@
938 infoFile.endGroup();
939 } else {
940 // uh oh... have a resource description without file... reset sequence number to indicate we need a sync
941- qWarning() << "Have a resource description but no resource file for it";
942+ qCWarning(dcNotesStore) << "Have a resource description but no resource file for it";
943 }
944 }
945 infoFile.endGroup();
946
947 connect(NotesStore::instance(), &NotesStore::notebookGuidChanged, this, &Note::slotNotebookGuidChanged);
948 connect(NotesStore::instance(), &NotesStore::tagGuidChanged, this, &Note::slotTagGuidChanged);
949-
950- qDebug() << "Note created:" << m_guid << m_title << m_tagline << m_content.enml();
951 }
952
953 Note::~Note()
954@@ -122,7 +120,6 @@
955 m_guid = guid;
956 QString newCacheFileName = NotesStore::instance()->storageLocation() + "note-" + guid + ".enml";
957 if (m_cacheFile.exists()) {
958- qDebug() << "renaming cachefile from" << m_cacheFile.fileName() << "to" << newCacheFileName;
959 m_cacheFile.rename(newCacheFileName);
960 } else {
961 m_cacheFile.setFileName(newCacheFileName);
962@@ -246,7 +243,7 @@
963
964 QString Note::enmlContent() const
965 {
966- load();
967+ load(true);
968 return m_content.enml();
969 }
970
971@@ -266,15 +263,13 @@
972
973 QString Note::htmlContent() const
974 {
975- qDebug() << "html content asked;";
976- load();
977- qDebug() << "returning" << m_content.toHtml(m_guid);
978+ load(true);
979 return m_content.toHtml(m_guid);
980 }
981
982 QString Note::richTextContent() const
983 {
984- load();
985+ load(true);
986 return m_content.toRichText(m_guid);
987 }
988
989@@ -430,9 +425,7 @@
990
991 void Note::setDeleted(bool deleted)
992 {
993- qDebug() << "note" << this << "isDelted:" << m_deleted << "setting to" << deleted;
994 if (m_deleted != deleted) {
995- qDebug() << "setting m_deleted to to" << deleted;
996 m_deleted = deleted;
997 emit deletedChanged();
998 }
999@@ -518,7 +511,6 @@
1000 return m_resources.value(hash);
1001 }
1002
1003- qDebug() << "adding resource" << fileName << type;
1004 Resource *resource = new Resource(data, hash, fileName, type, this);
1005 m_resources.insert(hash, resource);
1006 emit resourcesChanged();
1007@@ -544,7 +536,7 @@
1008 {
1009 QFile importedFile(fileName.path());
1010 if (!importedFile.exists()) {
1011- qWarning() << "File doesn't exist. Cannot attach.";
1012+ qCWarning(dcNotesStore) << "File doesn't exist. Cannot attach.";
1013 return;
1014 }
1015
1016@@ -562,11 +554,6 @@
1017 m_needsContentSync = true;
1018 }
1019
1020-void Note::format(int startPos, int endPos, TextFormat::Format format)
1021-{
1022- qDebug() << "Should format from" << startPos << "to" << endPos << "with format:" << format;
1023-}
1024-
1025 void Note::addTag(const QString &tagGuid)
1026 {
1027 NotesStore::instance()->tagNote(m_guid, tagGuid);
1028@@ -638,12 +625,14 @@
1029 if (m_loading != loading) {
1030 m_loading = loading;
1031 emit loadingChanged();
1032+ }
1033
1034- if (!m_loading) {
1035- m_loadingHighPriority = false;
1036- } else {
1037- m_loadingHighPriority = highPriority;
1038+ if (m_loading) {
1039+ if (!m_loadingHighPriority && highPriority) {
1040+ m_loadingHighPriority = true;
1041 }
1042+ } else {
1043+ m_loadingHighPriority = false;
1044 }
1045 }
1046
1047@@ -700,9 +689,9 @@
1048 m_content.setEnml(QString::fromUtf8(m_cacheFile.readAll()).trimmed());
1049 m_tagline = m_content.toPlaintext().left(100);
1050 m_cacheFile.close();
1051- qDebug() << "[Storage] Loaded note from storage:" << m_guid;
1052+ qCDebug(dcNotesStore) << "Loaded note content from disk:" << m_guid;
1053 } else {
1054- qDebug() << "[Storage] Failed attempt to load note from storage:" << m_guid;
1055+ qCDebug(dcNotesStore) << "Failed attempt to load note content from disk:" << m_guid;
1056 }
1057 m_loaded = true;
1058 }
1059
1060=== modified file 'src/libqtevernote/note.h'
1061--- src/libqtevernote/note.h 2015-03-05 18:23:25 +0000
1062+++ src/libqtevernote/note.h 2015-03-06 21:14:46 +0000
1063@@ -23,7 +23,6 @@
1064
1065 #include "utils/enmldocument.h"
1066 #include "resource.h"
1067-#include "utils/textformat.h"
1068
1069 #include <QObject>
1070 #include <QDateTime>
1071@@ -162,7 +161,6 @@
1072
1073 Q_INVOKABLE void markTodo(const QString &todoId, bool checked);
1074 Q_INVOKABLE void attachFile(int position, const QUrl &fileName);
1075- Q_INVOKABLE void format(int startPos, int endPos, TextFormat::Format format);
1076 Q_INVOKABLE void addTag(const QString &tagGuid);
1077 Q_INVOKABLE void removeTag(const QString &tagGuid);
1078
1079@@ -214,7 +212,7 @@
1080 void setConflicting(bool conflicting);
1081
1082 // const because we want to load on demand in getters. Keep this private!
1083- void load(bool priorityHigh = true) const;
1084+ void load(bool highPriority = false) const;
1085 void loadFromCacheFile() const;
1086
1087 private:
1088
1089=== modified file 'src/libqtevernote/notebook.cpp'
1090--- src/libqtevernote/notebook.cpp 2015-03-04 20:30:55 +0000
1091+++ src/libqtevernote/notebook.cpp 2015-03-06 21:14:46 +0000
1092@@ -24,7 +24,7 @@
1093
1094 #include <libintl.h>
1095
1096-#include <QDebug>
1097+#include <QLocale>
1098 #include <QStandardPaths>
1099
1100 Notebook::Notebook(QString guid, quint32 updateSequenceNumber, QObject *parent) :
1101@@ -191,7 +191,6 @@
1102 }
1103 } else {
1104 if (!m_notesList.contains(noteGuid)) {
1105- qDebug() << "****** appending to notebook";
1106 m_notesList.append(noteGuid);
1107 emit noteCountChanged();
1108 }
1109
1110=== modified file 'src/libqtevernote/notebooks.cpp'
1111--- src/libqtevernote/notebooks.cpp 2015-03-04 00:23:45 +0000
1112+++ src/libqtevernote/notebooks.cpp 2015-03-06 21:14:46 +0000
1113@@ -21,8 +21,6 @@
1114 #include "notebooks.h"
1115 #include "notebook.h"
1116
1117-#include <QDebug>
1118-
1119 Notebooks::Notebooks(QObject *parent) :
1120 QAbstractListModel(parent)
1121 {
1122
1123=== modified file 'src/libqtevernote/notes.cpp'
1124--- src/libqtevernote/notes.cpp 2015-03-04 23:50:24 +0000
1125+++ src/libqtevernote/notes.cpp 2015-03-06 21:14:46 +0000
1126@@ -21,8 +21,6 @@
1127 #include "notes.h"
1128 #include "note.h"
1129
1130-#include <QDebug>
1131-
1132 Notes::Notes(QObject *parent) :
1133 QSortFilterProxyModel(parent),
1134 m_onlyReminders(false),
1135
1136=== modified file 'src/libqtevernote/notesstore.cpp'
1137--- src/libqtevernote/notesstore.cpp 2015-03-04 23:24:54 +0000
1138+++ src/libqtevernote/notesstore.cpp 2015-03-06 21:14:46 +0000
1139@@ -27,6 +27,7 @@
1140 #include "utils/enmldocument.h"
1141 #include "utils/organizeradapter.h"
1142 #include "userstore.h"
1143+#include "logging.h"
1144
1145 #include "jobs/fetchnotesjob.h"
1146 #include "jobs/fetchnotebooksjob.h"
1147@@ -44,7 +45,6 @@
1148 #include "libintl.h"
1149
1150 #include <QImage>
1151-#include <QDebug>
1152 #include <QStandardPaths>
1153 #include <QUuid>
1154 #include <QPointer>
1155@@ -59,6 +59,7 @@
1156 m_notebooksLoading(false),
1157 m_tagsLoading(false)
1158 {
1159+ qCDebug(dcNotesStore) << "Creating NotesStore instance.";
1160 connect(UserStore::instance(), &UserStore::usernameChanged, this, &NotesStore::userStoreConnected);
1161
1162 qRegisterMetaType<evernote::edam::NotesMetadataList>("evernote::edam::NotesMetadataList");
1163@@ -72,7 +73,7 @@
1164
1165 QDir storageDir(QStandardPaths::standardLocations(QStandardPaths::DataLocation).first());
1166 if (!storageDir.exists()) {
1167- qDebug() << "creating storage directory:" << storageDir.absolutePath();
1168+ qCDebug(dcNotesStore) << "Creating storage directory:" << storageDir.absolutePath();
1169 storageDir.mkpath(storageDir.absolutePath());
1170 }
1171 }
1172@@ -97,7 +98,7 @@
1173 return;
1174 }
1175 if (!UserStore::instance()->username().isEmpty() && username != UserStore::instance()->username()) {
1176- qWarning() << "Logged in to Evernote. Can't change account manually. User EvernoteConnection to log in to another account or log out and change this manually.";
1177+ qCWarning(dcNotesStore) << "Logged in to Evernote. Can't change account manually. User EvernoteConnection to log in to another account or log out and change this manually.";
1178 return;
1179 }
1180
1181@@ -106,7 +107,7 @@
1182 emit usernameChanged();
1183
1184 m_cacheFile = storageLocation() + "notes.cache";
1185- qDebug() << "initialized cacheFile" << m_cacheFile;
1186+ qCDebug(dcNotesStore) << "Initialized cacheFile:" << m_cacheFile;
1187 loadFromCacheFile();
1188 }
1189 }
1190@@ -118,7 +119,7 @@
1191
1192 void NotesStore::userStoreConnected(const QString &username)
1193 {
1194- qDebug() << "User store connected!" << username;
1195+ qCDebug(dcNotesStore) << "User store connected! Using username:" << username;
1196 setUsername(username);
1197
1198 refreshNotebooks();
1199@@ -274,6 +275,7 @@
1200 {
1201 QString newGuid = QUuid::createUuid().toString();
1202 newGuid.remove("{").remove("}");
1203+ qCDebug(dcNotesStore) << "Creating notebook:" << newGuid;
1204 Notebook *notebook = new Notebook(newGuid, 1, this);
1205 notebook->setName(name);
1206 if (m_notebooks.isEmpty()) {
1207@@ -287,6 +289,7 @@
1208 syncToCacheFile(notebook);
1209
1210 if (EvernoteConnection::instance()->isConnected()) {
1211+ qCDebug(dcSync) << "Creating notebook on server:" << notebook->guid();
1212 notebook->setLoading(true);
1213 CreateNotebookJob *job = new CreateNotebookJob(notebook);
1214 connect(job, &CreateNotebookJob::jobDone, this, &NotesStore::createNotebookJobDone);
1215@@ -298,19 +301,21 @@
1216 {
1217 Notebook *notebook = m_notebooksHash.value(tmpGuid);
1218 if (!notebook) {
1219- qWarning() << "Cannot find temporary notebook after create finished";
1220+ qCWarning(dcSync) << "Cannot find temporary notebook after create finished";
1221 return;
1222 }
1223
1224 notebook->setLoading(false);
1225
1226 if (errorCode != EvernoteConnection::ErrorCodeNoError) {
1227- qWarning() << "Error creating notebook:" << errorMessage;
1228+ qCWarning(dcSync) << "Error creating notebook:" << errorMessage;
1229 notebook->setSyncError(true);
1230 return;
1231 }
1232 QString guid = QString::fromStdString(result.guid);
1233- qDebug() << "create notebooks job done2";
1234+
1235+ qCDebug(dcSync) << "Notebook created on server. Old guid:" << tmpGuid << "New guid:" << guid;
1236+ qCDebug(dcNotesStore) << "Changing notebook guid. Old guid:" << tmpGuid << "New guid:" << guid;
1237
1238 m_notebooksHash.insert(guid, notebook);
1239 notebook->setGuid(QString::fromStdString(result.guid));
1240@@ -338,7 +343,7 @@
1241 {
1242 Notebook *notebook = m_notebooksHash.value(guid);
1243 if (!notebook) {
1244- qWarning() << "Can't save notebook. Guid not found:" << guid;
1245+ qCWarning(dcNotesStore) << "Can't save notebook. Guid not found:" << guid;
1246 return;
1247 }
1248
1249@@ -358,11 +363,11 @@
1250 {
1251 Notebook *notebook = m_notebooksHash.value(guid);
1252 if (!notebook) {
1253- qWarning() << "[NotesStore] Notebook guid not found:" << guid;
1254+ qCWarning(dcNotesStore) << "Notebook guid not found:" << guid;
1255 return;
1256 }
1257
1258- qDebug() << "[NotesStore] Setting default notebook:" << guid;
1259+ qCDebug(dcNotesStore) << "Setting default notebook:" << guid;
1260 foreach (Notebook *tmp, m_notebooks) {
1261 if (tmp->isDefaultNotebook()) {
1262 tmp->setIsDefaultNotebook(false);
1263@@ -379,7 +384,7 @@
1264 {
1265 Tag *tag = m_tagsHash.value(guid);
1266 if (!tag) {
1267- qWarning() << "Can't save tag. Guid not found:" << guid;
1268+ qCWarning(dcNotesStore) << "Can't save tag. Guid not found:" << guid;
1269 return;
1270 }
1271
1272@@ -398,7 +403,7 @@
1273 void NotesStore::expungeNotebook(const QString &guid)
1274 {
1275 if (m_username != "@local") {
1276- qWarning() << "[NotesStore] Account managed by Evernote. Cannot delete notebooks.";
1277+ qCWarning(dcNotesStore) << "Account managed by Evernote. Cannot delete notebooks.";
1278 m_errorQueue.append(QString(gettext("This account is managed by Evernote. Use the Evernote website to delete notebooks.")));
1279 emit errorChanged();
1280 return;
1281@@ -406,12 +411,12 @@
1282
1283 Notebook* notebook = m_notebooksHash.value(guid);
1284 if (!notebook) {
1285- qWarning() << "[NotesStore] Cannot delete notebook. Notebook not found for guid:" << guid;
1286+ qCWarning(dcNotesStore) << "Cannot delete notebook. Notebook not found for guid:" << guid;
1287 return;
1288 }
1289
1290 if (notebook->isDefaultNotebook()) {
1291- qWarning() << "[NotesStore] Cannot delete the default notebook.";
1292+ qCWarning(dcNotesStore) << "Cannot delete the default notebook.";
1293 m_errorQueue.append(QString(gettext("Cannot delete the default notebook. Set another notebook to be the default first.")));
1294 emit errorChanged();
1295 return;
1296@@ -426,7 +431,7 @@
1297 }
1298 }
1299 if (defaultNotebook.isEmpty()) {
1300- qWarning() << "[NotesStore] No default notebook set. Can't delete notebooks.";
1301+ qCWarning(dcNotesStore) << "No default notebook set. Can't delete notebooks.";
1302 return;
1303 }
1304
1305@@ -434,11 +439,11 @@
1306 QString noteGuid = notebook->noteAt(0);
1307 Note *note = m_notesHash.value(noteGuid);
1308 if (!note) {
1309- qWarning() << "[NotesStore] Notebook holds a noteGuid which cannot be found in notes store";
1310+ qCWarning(dcNotesStore) << "Notebook holds a noteGuid which cannot be found in notes store";
1311 Q_ASSERT(false);
1312 continue;
1313 }
1314- qDebug() << "[NotesStore] Moving note" << noteGuid << "to default Notebook";
1315+ qCDebug(dcNotesStore) << "Moving note" << noteGuid << "to default Notebook";
1316 note->setNotebookGuid(defaultNotebook);
1317 saveNote(note->guid());
1318 emit noteChanged(note->guid(), defaultNotebook);
1319@@ -491,16 +496,15 @@
1320
1321 void NotesStore::createTagJobDone(EvernoteConnection::ErrorCode errorCode, const QString &errorMessage, const QString &tmpGuid, const evernote::edam::Tag &result)
1322 {
1323- qDebug() << "CreateTagJob done";
1324 Tag *tag = m_tagsHash.value(tmpGuid);
1325 if (!tag) {
1326- qWarning() << "Create Tag job done but tag can't be found any more";
1327+ qCWarning(dcSync) << "Create Tag job done but tag can't be found any more";
1328 return;
1329 }
1330
1331 tag->setLoading(false);
1332 if (errorCode != EvernoteConnection::ErrorCodeNoError) {
1333- qWarning() << "Error creating tag:" << errorMessage;
1334+ qCWarning(dcSync) << "Error creating tag on server:" << errorMessage;
1335 tag->setSyncError(true);
1336 emit tagChanged(tag->guid());
1337 return;
1338@@ -532,12 +536,12 @@
1339 {
1340 Tag *tag = m_tagsHash.value(QString::fromStdString(result.guid));
1341 if (!tag) {
1342- qWarning() << "Save tag job finished, but tag can't be found any more";
1343+ qCWarning(dcSync) << "Save tag job finished, but tag can't be found any more";
1344 return;
1345 }
1346 tag->setLoading(false);
1347 if (errorCode != EvernoteConnection::ErrorCodeNoError) {
1348- qWarning() << "error updating tag" << errorMessage;
1349+ qCWarning(dcSync) << "Error updating tag on server" << errorMessage;
1350 tag->setSyncError(true);
1351 emit tagChanged(tag->guid());
1352 return;
1353@@ -554,18 +558,18 @@
1354 {
1355 Note *note = m_notesHash.value(noteGuid);
1356 if (!note) {
1357- qWarning() << "No such note" << noteGuid;
1358+ qCWarning(dcNotesStore) << "No such note" << noteGuid;
1359 return;
1360 }
1361
1362 Tag *tag = m_tagsHash.value(tagGuid);
1363 if (!tag) {
1364- qWarning() << "No such tag" << tagGuid;
1365+ qCWarning(dcNotesStore) << "No such tag" << tagGuid;
1366 return;
1367 }
1368
1369 if (note->tagGuids().contains(tagGuid)) {
1370- qWarning() << "Note" << noteGuid << "already tagged with tag" << tagGuid;
1371+ qCWarning(dcNotesStore) << "Note" << noteGuid << "already tagged with tag" << tagGuid;
1372 return;
1373 }
1374
1375@@ -577,18 +581,18 @@
1376 {
1377 Note *note = m_notesHash.value(noteGuid);
1378 if (!note) {
1379- qWarning() << "No such note" << noteGuid;
1380+ qCWarning(dcNotesStore) << "No such note" << noteGuid;
1381 return;
1382 }
1383
1384 Tag *tag = m_tagsHash.value(tagGuid);
1385 if (!tag) {
1386- qWarning() << "No such tag" << tagGuid;
1387+ qCWarning(dcNotesStore) << "No such tag" << tagGuid;
1388 return;
1389 }
1390
1391 if (!note->tagGuids().contains(tagGuid)) {
1392- qWarning() << "Note" << noteGuid << "is not tagged with tag" << tagGuid;
1393+ qCWarning(dcNotesStore) << "Note" << noteGuid << "is not tagged with tag" << tagGuid;
1394 return;
1395 }
1396
1397@@ -601,7 +605,7 @@
1398 void NotesStore::refreshNotes(const QString &filterNotebookGuid, int startIndex)
1399 {
1400 if (m_loading && startIndex == 0) {
1401- qWarning() << "Still busy with refreshing...";
1402+ qCWarning(dcSync) << "Still busy with refreshing...";
1403 return;
1404 }
1405
1406@@ -626,22 +630,22 @@
1407 // All is well...
1408 break;
1409 case EvernoteConnection::ErrorCodeUserException:
1410- qWarning() << "FetchNotesJobDone: EDAMUserException:" << errorMessage;
1411+ qCWarning(dcSync) << "FetchNotesJobDone: EDAMUserException:" << errorMessage;
1412 m_loading = false;
1413 emit loadingChanged();
1414 return; // silently discarding...
1415 case EvernoteConnection::ErrorCodeConnectionLost:
1416- qWarning() << "FetchNotesJobDone: Connection with evernote lost:" << errorMessage;
1417+ qCWarning(dcSync) << "FetchNotesJobDone: Connection with evernote lost:" << errorMessage;
1418 m_loading = false;
1419 emit loadingChanged();
1420 return; // silently discarding...
1421 case EvernoteConnection::ErrorCodeNotFoundExcpetion:
1422- qWarning() << "FetchNotesJobDone: Item not found on server:" << errorMessage;
1423+ qCWarning(dcSync) << "FetchNotesJobDone: Item not found on server:" << errorMessage;
1424 m_loading = false;
1425 emit loadingChanged();
1426 return; // silently discarding...
1427 default:
1428- qWarning() << "FetchNotesJobDone: Failed to fetch notes list:" << errorMessage << errorCode;
1429+ qCWarning(dcSync) << "FetchNotesJobDone: Failed to fetch notes list:" << errorMessage << errorCode;
1430 m_loading = false;
1431 emit loadingChanged();
1432 return;
1433@@ -654,7 +658,7 @@
1434 QVector<int> changedRoles;
1435 bool newNote = note == 0;
1436 if (newNote) {
1437- qDebug() << "FetchNotesJobDone: Found new note on server.";
1438+ qCDebug(dcSync) << "Found new note on server. Creating local copy:" << QString::fromStdString(result.guid);
1439 note = new Note(QString::fromStdString(result.guid), 0, this);
1440 connect(note, &Note::reminderChanged, this, &NotesStore::emitDataChanged);
1441 connect(note, &Note::reminderDoneChanged, this, &NotesStore::emitDataChanged);
1442@@ -671,7 +675,7 @@
1443 } else if (note->synced()) {
1444 // Local note did not change. Check if we need to refresh from server.
1445 if (note->updateSequenceNumber() < result.updateSequenceNum) {
1446- qDebug() << "refreshing note from network. suequence number changed: " << note->updateSequenceNumber() << "->" << result.updateSequenceNum;
1447+ qCDebug(dcSync) << "refreshing note from network. suequence number changed: " << note->updateSequenceNumber() << "->" << result.updateSequenceNum;
1448 changedRoles = updateFromEDAM(result, note);
1449 refreshNoteContent(note->guid(), FetchNoteJob::LoadContent, EvernoteJob::JobPriorityLow);
1450 syncToCacheFile(note);
1451@@ -679,7 +683,7 @@
1452 } else {
1453 // Local note changed. See if we can push our changes.
1454 if (note->lastSyncedSequenceNumber() == result.updateSequenceNum) {
1455- qDebug() << "Local note" << note->guid() << "has changed while server note did not. Pushing changes.";
1456+ qCDebug(dcSync) << "Local note" << note->guid() << "has changed while server note did not. Pushing changes.";
1457
1458 // Make sure we have everything loaded from cache before saving to server
1459 if (!note->loaded() && note->isCached()) {
1460@@ -692,10 +696,10 @@
1461 connect(job, &SaveNoteJob::jobDone, this, &NotesStore::saveNoteJobDone);
1462 EvernoteConnection::instance()->enqueue(job);
1463 } else {
1464- qWarning() << "CONFLICT: Note has been changed on server and locally!";
1465- qWarning() << "local note sequence:" << note->updateSequenceNumber();
1466- qWarning() << "last synced sequence:" << note->lastSyncedSequenceNumber();
1467- qWarning() << "remote sequence:" << result.updateSequenceNum;
1468+ qCWarning(dcSync) << "CONFLICT: Note has been changed on server and locally!";
1469+ qCWarning(dcSync) << "local note sequence:" << note->updateSequenceNumber();
1470+ qCWarning(dcSync) << "last synced sequence:" << note->lastSyncedSequenceNumber();
1471+ qCWarning(dcSync) << "remote sequence:" << result.updateSequenceNum;
1472 note->setConflicting(true);
1473 changedRoles << RoleConflicting;
1474 }
1475@@ -714,10 +718,10 @@
1476 }
1477
1478 if (results.startIndex + (int32_t)results.notes.size() < results.totalNotes) {
1479- qDebug() << "FetchNotesJobDone: Not all notes fetched yet. Fetching next batch.";
1480+ qCDebug(dcSync) << "Not all notes fetched yet. Fetching next batch.";
1481 refreshNotes(filterNotebookGuid, results.startIndex + results.notes.size());
1482 } else {
1483- qDebug() << "Fetched all notes. Starting merge...";
1484+ qCDebug(dcSync) << "Fetched all notes from Evernote. Starting merge of local changes...";
1485 m_organizerAdapter->startSync();
1486 m_loading = false;
1487 emit loadingChanged();
1488@@ -728,7 +732,7 @@
1489 if (!note) {
1490 continue; // Note might be deleted locally by now
1491 }
1492- qDebug() << "Have a local note that's not available on server!" << note->guid();
1493+ qCDebug(dcSync) << "Have a local note that's not available on server!" << note->guid();
1494 if (note->lastSyncedSequenceNumber() == 0) {
1495 // This note hasn't been created on the server yet. Do that now.
1496 bool hasUnsyncedTag = false;
1497@@ -741,15 +745,15 @@
1498 }
1499 }
1500 if (hasUnsyncedTag) {
1501- qDebug() << "Not syncing note to server yet. Have a tag that needs sync first";
1502+ qCDebug(dcSync) << "Not syncing note to server yet. Have a tag that needs sync first";
1503 continue;
1504 }
1505 Notebook *notebook = m_notebooksHash.value(note->notebookGuid());
1506 if (notebook && notebook->lastSyncedSequenceNumber() == 0) {
1507- qDebug() << "Not syncing note to server yet. The notebook needs to be synced first";
1508+ qCDebug(dcSync) << "Not syncing note to server yet. The notebook needs to be synced first";
1509 continue;
1510 }
1511- qDebug() << "Creating note on server:" << note->guid();
1512+ qCDebug(dcSync) << "Creating note on server:" << note->guid();
1513
1514 // Make sure we have everything loaded from cache before saving to server
1515 if (!note->loaded() && note->isCached()) {
1516@@ -782,18 +786,24 @@
1517 }
1518 }
1519 }
1520+ qCDebug(dcSync) << "Local changes merged.";
1521 }
1522 }
1523
1524 void NotesStore::refreshNoteContent(const QString &guid, FetchNoteJob::LoadWhat what, EvernoteJob::JobPriority priority)
1525 {
1526- qDebug() << "fetching note content from network for note" << guid << (what == FetchNoteJob::LoadContent ? "content" : "image");
1527 Note *note = m_notesHash.value(guid);
1528 if (!note) {
1529- qWarning() << "RefreshNoteContent: Can't refresn note content. Note guid not found:" << guid;
1530+ qCWarning(dcSync) << "RefreshNoteContent: Can't refresn note content. Note guid not found:" << guid;
1531+ return;
1532+ }
1533+ qCDebug(dcSync) << "should start another one?" << note->loading() << note->m_loadingHighPriority;
1534+ if (note->loading() && (priority != EvernoteJob::JobPriorityHigh || note->m_loadingHighPriority)) {
1535+ qCDebug(dcSync) << "Load already loading with high priorty. Not starting again";
1536 return;
1537 }
1538 if (EvernoteConnection::instance()->isConnected()) {
1539+ qCDebug(dcNotesStore) << "Fetching note content from network for note" << guid << (what == FetchNoteJob::LoadContent ? "content" : "image");
1540 FetchNoteJob *job = new FetchNoteJob(guid, what, this);
1541 job->setJobPriority(priority);
1542 connect(job, &FetchNoteJob::resultReady, this, &NotesStore::fetchNoteJobDone);
1543@@ -810,34 +820,30 @@
1544 FetchNoteJob *job = static_cast<FetchNoteJob*>(sender());
1545 Note *note = m_notesHash.value(QString::fromStdString(result.guid));
1546 if (!note) {
1547- qWarning() << "can't find note for this update... ignoring...";
1548+ qCWarning(dcSync) << "can't find note for this update... ignoring...";
1549 return;
1550 }
1551 QModelIndex noteIndex = index(m_notes.indexOf(note));
1552 QVector<int> roles;
1553
1554- note->setLoading(false);
1555- roles << RoleLoading;
1556-
1557 switch (errorCode) {
1558 case EvernoteConnection::ErrorCodeNoError:
1559 // All is well
1560- emit dataChanged(noteIndex, noteIndex, roles);
1561 break;
1562 case EvernoteConnection::ErrorCodeUserException:
1563- qWarning() << "FetchNoteJobDone: EDAMUserException:" << errorMessage;
1564+ qCWarning(dcSync) << "FetchNoteJobDone: EDAMUserException:" << errorMessage;
1565 emit dataChanged(noteIndex, noteIndex, roles);
1566 return; // silently discarding...
1567 case EvernoteConnection::ErrorCodeConnectionLost:
1568- qWarning() << "FetchNoteJobDone: Connection with evernote lost:" << errorMessage;
1569+ qCWarning(dcSync) << "FetchNoteJobDone: Connection with evernote lost:" << errorMessage;
1570 emit dataChanged(noteIndex, noteIndex, roles);
1571 return; // silently discarding...
1572 case EvernoteConnection::ErrorCodeNotFoundExcpetion:
1573- qWarning() << "FetchNoteJobDone: Item not found on server:" << errorMessage;
1574+ qCWarning(dcSync) << "FetchNoteJobDone: Item not found on server:" << errorMessage;
1575 emit dataChanged(noteIndex, noteIndex, roles);
1576 return; // silently discarding...
1577 default:
1578- qWarning() << "FetchNoteJobDone: Failed to fetch note content:" << errorMessage << errorCode;
1579+ qCWarning(dcSync) << "FetchNoteJobDone: Failed to fetch note content:" << errorMessage << errorCode;
1580 note->setSyncError(true);
1581 roles << RoleSyncError;
1582 emit dataChanged(noteIndex, noteIndex, roles);
1583@@ -861,7 +867,7 @@
1584 // data in the cache, let's refresh the note again with resource data.
1585 bool refreshWithResourceData = false;
1586
1587- qDebug() << "got note content" << note->guid() << (what == FetchNoteJob::LoadContent ? "content" : "image") << result.resources.size();
1588+ qCDebug(dcSync) << "got note content" << note->guid() << (what == FetchNoteJob::LoadContent ? "content" : "image") << result.resources.size();
1589 // Resources need to be set before the content because otherwise the image provider won't find them when the content is updated in the ui
1590 for (unsigned int i = 0; i < result.resources.size(); ++i) {
1591
1592@@ -872,14 +878,14 @@
1593 QString mime = QString::fromStdString(resource.mime);
1594
1595 if (what == FetchNoteJob::LoadResources) {
1596- qDebug() << "[Sync] Resource fetched for note:" << note->guid() << "Filename:" << fileName << "Mimetype:" << mime << "Hash:" << hash;
1597+ qCDebug(dcSync) << "Resource fetched for note:" << note->guid() << "Filename:" << fileName << "Mimetype:" << mime << "Hash:" << hash;
1598 QByteArray resourceData = QByteArray(resource.data.body.data(), resource.data.size);
1599 note->addResource(resourceData, hash, fileName, mime);
1600 } else if (Resource::isCached(hash)) {
1601- qDebug() << "[Sync] Resource already cached for note:" << note->guid() << "Filename:" << fileName << "Mimetype:" << mime << "Hash:" << hash;
1602+ qCDebug(dcSync) << "Resource already cached for note:" << note->guid() << "Filename:" << fileName << "Mimetype:" << mime << "Hash:" << hash;
1603 note->addResource(QByteArray(), hash, fileName, mime);
1604 } else {
1605- qDebug() << "[Sync] Resource not yet fetched for note:" << note->guid() << "Filename:" << fileName << "Mimetype:" << mime << "Hash:" << hash;
1606+ qCDebug(dcSync) << "Resource not yet fetched for note:" << note->guid() << "Filename:" << fileName << "Mimetype:" << mime << "Hash:" << hash;
1607 refreshWithResourceData = true;
1608 }
1609 roles << RoleHtmlContent << RoleEnmlContent << RoleResourceUrls;
1610@@ -910,12 +916,16 @@
1611 note->setReminderDoneTime(reminderDoneTime);
1612 roles << RoleReminderDone << RoleReminderDoneTime;
1613 }
1614+
1615+ note->setLoading(false);
1616+ roles << RoleLoading;
1617+
1618 emit noteChanged(note->guid(), note->notebookGuid());
1619
1620 emit dataChanged(noteIndex, noteIndex, roles);
1621
1622 if (refreshWithResourceData) {
1623- qDebug() << "refreshWithResourceData";
1624+ qCDebug(dcSync) << "Fetching Note resources:" << note->guid();
1625 refreshNoteContent(note->guid(), FetchNoteJob::LoadResources, job->jobPriority());
1626 } else {
1627 syncToCacheFile(note); // Syncs into the list cache
1628@@ -926,7 +936,7 @@
1629 void NotesStore::refreshNotebooks()
1630 {
1631 if (!EvernoteConnection::instance()->isConnected()) {
1632- qWarning() << "Not connected. Cannot fetch notebooks from server.";
1633+ qCWarning(dcSync) << "Not connected. Cannot fetch notebooks from server.";
1634 return;
1635 }
1636
1637@@ -947,27 +957,27 @@
1638 // All is well...
1639 break;
1640 case EvernoteConnection::ErrorCodeUserException:
1641- qWarning() << "FetchNotebooksJobDone: EDAMUserException:" << errorMessage;
1642+ qCWarning(dcSync) << "FetchNotebooksJobDone: EDAMUserException:" << errorMessage;
1643 // silently discarding...
1644 return;
1645 case EvernoteConnection::ErrorCodeConnectionLost:
1646- qWarning() << "FetchNotebooksJobDone: Connection lost:" << errorMessage;
1647+ qCWarning(dcSync) << "FetchNotebooksJobDone: Connection lost:" << errorMessage;
1648 return; // silently discarding
1649 default:
1650- qWarning() << "FetchNotebooksJobDone: Failed to fetch notes list:" << errorMessage << errorCode;
1651+ qCWarning(dcSync) << "FetchNotebooksJobDone: Failed to fetch notes list:" << errorMessage << errorCode;
1652 return; // silently discarding
1653 }
1654
1655 QList<Notebook*> unhandledNotebooks = m_notebooks;
1656
1657- qDebug() << "[NotesStore] Have" << results.size() << "from Evernote.";
1658+ qCDebug(dcSync) << "Received" << results.size() << "notebooks from Evernote.";
1659 for (unsigned int i = 0; i < results.size(); ++i) {
1660 evernote::edam::Notebook result = results.at(i);
1661 Notebook *notebook = m_notebooksHash.value(QString::fromStdString(result.guid));
1662 unhandledNotebooks.removeAll(notebook);
1663 bool newNotebook = notebook == 0;
1664 if (newNotebook) {
1665- qDebug() << "[NotesStore] Found new notebook on Evernote:" << QString::fromStdString(result.guid);
1666+ qCDebug(dcSync) << "Found new notebook on Evernote:" << QString::fromStdString(result.guid);
1667 notebook = new Notebook(QString::fromStdString(result.guid), 0, this);
1668 updateFromEDAM(result, notebook);
1669 m_notebooksHash.insert(notebook->guid(), notebook);
1670@@ -976,25 +986,23 @@
1671 syncToCacheFile(notebook);
1672 } else if (notebook->synced()) {
1673 if (notebook->updateSequenceNumber() < result.updateSequenceNum) {
1674- qDebug() << "[NotesStore] Notebook on Evernote is newer than local copy. Updating:" << notebook->guid();
1675+ qCDebug(dcSync) << "Notebook on Evernote is newer than local copy. Updating:" << notebook->guid();
1676 updateFromEDAM(result, notebook);
1677 emit notebookChanged(notebook->guid());
1678 syncToCacheFile(notebook);
1679- } else {
1680- qDebug() << "[NotesStore] Notebook is in sync:" << notebook->guid();
1681 }
1682 } else {
1683 // Local notebook changed. See if we can push our changes
1684 if (result.updateSequenceNum == notebook->lastSyncedSequenceNumber()) {
1685- qDebug() << "[NotesStore] Local Notebook changed. Uploading changes to Evernote:" << notebook->guid();
1686+ qCDebug(dcNotesStore) << "Local Notebook changed. Uploading changes to Evernote:" << notebook->guid();
1687 SaveNotebookJob *job = new SaveNotebookJob(notebook);
1688 connect(job, &SaveNotebookJob::jobDone, this, &NotesStore::saveNotebookJobDone);
1689 EvernoteConnection::instance()->enqueue(job);
1690 notebook->setLoading(true);
1691 emit notebookChanged(notebook->guid());
1692 } else {
1693- qWarning() << "[NotesStore] Sync conflict in notebook:" << notebook->name();
1694- qWarning() << "[NotesStore] Resolving of sync conflicts is not implemented yet.";
1695+ qCWarning(dcNotesStore) << "Sync conflict in notebook:" << notebook->name();
1696+ qCWarning(dcNotesStore) << "Resolving of sync conflicts is not implemented yet.";
1697 notebook->setSyncError(true);
1698 emit notebookChanged(notebook->guid());
1699 }
1700@@ -1003,14 +1011,14 @@
1701
1702 foreach (Notebook *notebook, unhandledNotebooks) {
1703 if (notebook->lastSyncedSequenceNumber() == 0) {
1704- qDebug() << "[NotesStore] Have a local notebook that doesn't exist on Evernote. Creating on server:" << notebook->guid();
1705+ qCDebug(dcSync) << "Have a local notebook that doesn't exist on Evernote. Creating on server:" << notebook->guid();
1706 notebook->setLoading(true);
1707 CreateNotebookJob *job = new CreateNotebookJob(notebook);
1708 connect(job, &CreateNotebookJob::jobDone, this, &NotesStore::createNotebookJobDone);
1709 EvernoteConnection::instance()->enqueue(job);
1710 emit notebookChanged(notebook->guid());
1711 } else {
1712- qDebug() << "[NotesStore] Notebook has been deleted on the server. Deleting local copy:" << notebook->guid();
1713+ qCDebug(dcSync) << "Notebook has been deleted on the server. Deleting local copy:" << notebook->guid();
1714 m_notebooks.removeAll(notebook);
1715 m_notebooksHash.remove(notebook->guid());
1716 emit notebookRemoved(notebook->guid());
1717@@ -1029,7 +1037,7 @@
1718 void NotesStore::refreshTags()
1719 {
1720 if (!EvernoteConnection::instance()->isConnected()) {
1721- qWarning() << "Not connected. Cannot fetch tags from server.";
1722+ qCWarning(dcSync) << "Not connected. Cannot fetch tags from server.";
1723 return;
1724 }
1725 m_tagsLoading = true;
1726@@ -1057,14 +1065,14 @@
1727 // All is well...
1728 break;
1729 case EvernoteConnection::ErrorCodeUserException:
1730- qWarning() << "FetchTagsJobDone: EDAMUserException:" << errorMessage;
1731+ qCWarning(dcSync) << "FetchTagsJobDone: EDAMUserException:" << errorMessage;
1732 // silently discarding...
1733 return;
1734 case EvernoteConnection::ErrorCodeConnectionLost:
1735- qWarning() << "FetchTagsJobDone: Connection lost:" << errorMessage;
1736+ qCWarning(dcSync) << "FetchTagsJobDone: Connection lost:" << errorMessage;
1737 return; // silently discarding
1738 default:
1739- qWarning() << "FetchTagsJobDone: Failed to fetch notes list:" << errorMessage << errorCode;
1740+ qCWarning(dcSync) << "FetchTagsJobDone: Failed to fetch notes list:" << errorMessage << errorCode;
1741 return; // silently discarding
1742 }
1743
1744@@ -1077,7 +1085,7 @@
1745 if (newTag) {
1746 tag = new Tag(QString::fromStdString(result.guid), result.updateSequenceNum, this);
1747 tag->setLastSyncedSequenceNumber(result.updateSequenceNum);
1748- qDebug() << "got new tag with seq:" << result.updateSequenceNum << tag->synced() << tag->updateSequenceNumber() << tag->lastSyncedSequenceNumber();
1749+ qCDebug(dcSync) << "got new tag with seq:" << result.updateSequenceNum << tag->synced() << tag->updateSequenceNumber() << tag->lastSyncedSequenceNumber();
1750 tag->setName(QString::fromStdString(result.name));
1751 m_tagsHash.insert(tag->guid(), tag);
1752 m_tags.append(tag);
1753@@ -1100,7 +1108,7 @@
1754 tag->setLoading(true);
1755 emit tagChanged(tag->guid());
1756 } else {
1757- qWarning() << "CONFLICT in tag" << tag->name();
1758+ qCWarning(dcSync) << "CONFLICT in tag" << tag->name();
1759 tag->setSyncError(true);
1760 emit tagChanged(tag->guid());
1761 }
1762@@ -1183,7 +1191,7 @@
1763 {
1764 Note *note = m_notesHash.value(tmpGuid);
1765 if (!note) {
1766- qWarning() << "Cannot find temporary note after create operation!";
1767+ qCWarning(dcSync) << "Cannot find temporary note after create operation!";
1768 return;
1769 }
1770 int idx = m_notes.indexOf(note);
1771@@ -1193,7 +1201,7 @@
1772 roles << RoleLoading;
1773
1774 if (errorCode != EvernoteConnection::ErrorCodeNoError) {
1775- qWarning() << "Error creating note:" << tmpGuid << errorMessage;
1776+ qCWarning(dcSync) << "Error creating note on server:" << tmpGuid << errorMessage;
1777 note->setSyncError(true);
1778 roles << RoleSyncError;
1779 emit dataChanged(index(idx), index(idx), roles);
1780@@ -1206,7 +1214,7 @@
1781 }
1782
1783 QString guid = QString::fromStdString(result.guid);
1784- qDebug() << "Note created on server. Old guid:" << tmpGuid << "New guid:" << guid;
1785+ qCDebug(dcSync) << "Note created on server. Old guid:" << tmpGuid << "New guid:" << guid;
1786 m_notesHash.insert(guid, note);
1787 note->setGuid(guid);
1788 m_notesHash.remove(tmpGuid);
1789@@ -1252,7 +1260,7 @@
1790 {
1791 Note *note = m_notesHash.value(guid);
1792 if (!note) {
1793- qWarning() << "Can't save note. Guid not found:" << guid;
1794+ qCWarning(dcNotesStore) << "Can't save note. Guid not found:" << guid;
1795 return;
1796 }
1797 note->setUpdateSequenceNumber(note->updateSequenceNumber()+1);
1798@@ -1283,10 +1291,10 @@
1799
1800 void NotesStore::saveNoteJobDone(EvernoteConnection::ErrorCode errorCode, const QString &errorMessage, const evernote::edam::Note &result)
1801 {
1802- qDebug() << "saveNoteJobDone. guid:" << QString::fromStdString(result.guid);
1803+ qCDebug(dcSync) << "Note saved to server:" << QString::fromStdString(result.guid);
1804 Note *note = m_notesHash.value(QString::fromStdString(result.guid));
1805 if (!note) {
1806- qWarning() << "Got a save note job result, but note has disappeared locally.";
1807+ qCWarning(dcSync) << "Got a save note job result, but note has disappeared locally.";
1808 return;
1809 }
1810
1811@@ -1294,7 +1302,7 @@
1812 note->setLoading(false);
1813
1814 if (errorCode != EvernoteConnection::ErrorCodeNoError) {
1815- qWarning() << "Error saving note:" << errorMessage;
1816+ qCWarning(dcSync) << "Error saving note:" << errorMessage;
1817 note->setSyncError(true);
1818 emit dataChanged(index(idx), index(idx), QVector<int>() << RoleLoading << RoleSyncError);
1819 return;
1820@@ -1317,16 +1325,16 @@
1821 void NotesStore::saveNotebookJobDone(EvernoteConnection::ErrorCode errorCode, const QString &errorMessage, const evernote::edam::Notebook &result)
1822 {
1823 if (errorCode != EvernoteConnection::ErrorCodeNoError) {
1824- qWarning() << "error saving notebook" << errorMessage;
1825+ qCWarning(dcSync) << "Error saving notebook to server" << errorMessage;
1826 return;
1827 }
1828
1829 Notebook *notebook = m_notebooksHash.value(QString::fromStdString(result.guid));
1830 if (!notebook) {
1831- qWarning() << "Save notebook job done but notebook can't be found any more!";
1832+ qCWarning(dcSync) << "Save notebook job done but notebook can't be found any more!";
1833 return;
1834 }
1835- qDebug() << "save notebook done for:" << notebook->name() << notebook->lastSyncedSequenceNumber() << notebook->updateSequenceNumber() << result.updateSequenceNum;
1836+ qCDebug(dcSync) << "Notebooks saved to server:" << notebook->guid();
1837 updateFromEDAM(result, notebook);
1838 notebook->setLoading(false);
1839 emit notebookChanged(notebook->guid());
1840@@ -1337,7 +1345,7 @@
1841 {
1842 Note *note = m_notesHash.value(guid);
1843 if (!note) {
1844- qWarning() << "Note not found. Can't delete";
1845+ qCWarning(dcNotesStore) << "Note not found. Can't delete";
1846 return;
1847 }
1848
1849@@ -1354,7 +1362,7 @@
1850 note->deleteLater();
1851 } else {
1852
1853- qDebug() << "setting note" << note << "to deleted" << idx;
1854+ qCDebug(dcNotesStore) << "Setting note to deleted:" << note->guid();
1855 note->setDeleted(true);
1856 note->setUpdateSequenceNumber(note->updateSequenceNumber()+1);
1857 emit dataChanged(index(idx), index(idx), QVector<int>() << RoleDeleted);
1858@@ -1400,7 +1408,7 @@
1859 void NotesStore::deleteNoteJobDone(EvernoteConnection::ErrorCode errorCode, const QString &errorMessage, const QString &guid)
1860 {
1861 if (errorCode != EvernoteConnection::ErrorCodeNoError) {
1862- qWarning() << "Cannot delete note:" << errorMessage;
1863+ qCWarning(dcSync) << "Cannot delete note from server:" << errorMessage;
1864 return;
1865 }
1866 Note *note = m_notesHash.value(guid);
1867@@ -1420,7 +1428,7 @@
1868 void NotesStore::expungeNotebookJobDone(EvernoteConnection::ErrorCode errorCode, const QString &errorMessage, const QString &guid)
1869 {
1870 if (errorCode != EvernoteConnection::ErrorCodeNoError) {
1871- qWarning() << "Error expunging notebook:" << errorMessage;
1872+ qCWarning(dcSync) << "Error expunging notebook:" << errorMessage;
1873 return;
1874 }
1875 emit notebookRemoved(guid);
1876@@ -1465,7 +1473,7 @@
1877
1878 void NotesStore::syncToCacheFile(Note *note)
1879 {
1880- qDebug() << "syncToCacheFile for note" << note->guid();
1881+ qCDebug(dcNotesStore) << "Syncing note to disk:" << note->guid();
1882 QSettings cacheFile(m_cacheFile, QSettings::IniFormat);
1883 cacheFile.beginGroup("notes");
1884 cacheFile.setValue(note->guid(), note->updateSequenceNumber());
1885@@ -1515,6 +1523,7 @@
1886 }
1887 }
1888 cacheFile.endGroup();
1889+ qCDebug(dcNotesStore) << "Loaded" << m_notebooks.count() << "notebooks from disk.";
1890
1891 cacheFile.beginGroup("tags");
1892 if (cacheFile.allKeys().count() > 0) {
1893@@ -1526,13 +1535,14 @@
1894 }
1895 }
1896 cacheFile.endGroup();
1897+ qCDebug(dcNotesStore) << "Loaded" << m_tags.count() << "tags from disk.";
1898
1899 cacheFile.beginGroup("notes");
1900 if (cacheFile.allKeys().count() > 0) {
1901 beginInsertRows(QModelIndex(), 0, cacheFile.allKeys().count()-1);
1902 foreach (const QString &key, cacheFile.allKeys()) {
1903 if (m_notesHash.contains(key)) {
1904- qWarning() << "already have note. Not reloading from cache.";
1905+ qCWarning(dcNotesStore) << "already have note. Not reloading from cache.";
1906 continue;
1907 }
1908 Note *note = new Note(key, cacheFile.value(key).toUInt(), this);
1909@@ -1543,6 +1553,7 @@
1910 endInsertRows();
1911 }
1912 cacheFile.endGroup();
1913+ qCDebug(dcNotesStore) << "Loaded" << m_notes.count() << "notes from disk.";
1914 }
1915
1916 QVector<int> NotesStore::updateFromEDAM(const evernote::edam::NoteMetadata &evNote, Note *note)
1917@@ -1623,7 +1634,6 @@
1918 if (evNotebook.__isset.published && evNotebook.published != notebook->published()) {
1919 notebook->setPublished(evNotebook.published);
1920 }
1921- qDebug() << "readong from evernote:" << evNotebook.__isset.defaultNotebook << evNotebook.defaultNotebook << notebook->name();
1922 if (evNotebook.__isset.defaultNotebook && evNotebook.defaultNotebook != notebook->isDefaultNotebook()) {
1923 notebook->setIsDefaultNotebook(evNotebook.defaultNotebook);
1924 }
1925@@ -1634,7 +1644,7 @@
1926 void NotesStore::expungeTag(const QString &guid)
1927 {
1928 if (m_username != "@local") {
1929- qWarning() << "This account is managed by Evernote. Cannot delete tags.";
1930+ qCWarning(dcNotesStore) << "This account is managed by Evernote. Cannot delete tags.";
1931 m_errorQueue.append(gettext("This account is managed by Evernote. Please use the Evernote website to delete tags."));
1932 emit errorChanged();
1933 return;
1934@@ -1642,7 +1652,7 @@
1935
1936 Tag *tag = m_tagsHash.value(guid);
1937 if (!tag) {
1938- qWarning() << "[NotesStore] No tag with guid" << guid;
1939+ qCWarning(dcNotesStore) << "No tag with guid" << guid;
1940 return;
1941 }
1942
1943@@ -1650,7 +1660,7 @@
1944 QString noteGuid = tag->noteAt(0);
1945 Note *note = m_notesHash.value(noteGuid);
1946 if (!note) {
1947- qWarning() << "[NotesStore] Tag holds note" << noteGuid << "which hasn't been found in Notes Store";
1948+ qCWarning(dcNotesStore) << "Tag holds note" << noteGuid << "which hasn't been found in Notes Store";
1949 continue;
1950 }
1951 untagNote(noteGuid, guid);
1952
1953=== modified file 'src/libqtevernote/resource.cpp'
1954--- src/libqtevernote/resource.cpp 2015-02-27 00:43:59 +0000
1955+++ src/libqtevernote/resource.cpp 2015-03-06 21:14:46 +0000
1956@@ -20,10 +20,10 @@
1957
1958 #include "resource.h"
1959 #include "notesstore.h"
1960+#include "logging.h"
1961
1962 #include <QFile>
1963 #include <QStandardPaths>
1964-#include <QDebug>
1965 #include <QCryptographicHash>
1966 #include <QFileInfo>
1967 #include <QDir>
1968@@ -44,7 +44,7 @@
1969 if (!data.isEmpty() && !file.exists()) {
1970
1971 if (!file.open(QFile::WriteOnly)) {
1972- qWarning() << "error writing file" << m_filePath;
1973+ qCWarning(dcNotesStore) << "error writing file" << m_filePath;
1974 return;
1975 }
1976 file.write(data);
1977@@ -69,7 +69,7 @@
1978
1979 QFile file(path);
1980 if (!file.open(QFile::ReadOnly)) {
1981- qWarning() << "Cannot open file for reading...";
1982+ qCWarning(dcNotesStore) << "Cannot open file for reading...";
1983 return;
1984 }
1985 QByteArray fileContent = file.readAll();
1986@@ -84,7 +84,7 @@
1987 } else if (m_fileName.endsWith(".gif")) {
1988 m_type = "image/gif";
1989 } else {
1990- qWarning() << "cannot determine mime type of file" << m_fileName;
1991+ qCWarning(dcNotesStore) << "cannot determine mime type of file" << m_fileName;
1992 }
1993
1994 m_filePath = NotesStore::instance()->storageLocation() + m_hash + "." + m_fileName.split('.').last();
1995@@ -93,7 +93,7 @@
1996 if (!copy.exists()) {
1997
1998 if (!copy.open(QFile::WriteOnly)) {
1999- qWarning() << "error writing file" << m_filePath;
2000+ qCWarning(dcNotesStore) << "error writing file" << m_filePath;
2001 return;
2002 }
2003 copy.write(fileContent);
2004
2005=== modified file 'src/libqtevernote/resourceimageprovider.cpp'
2006--- src/libqtevernote/resourceimageprovider.cpp 2015-02-20 22:35:03 +0000
2007+++ src/libqtevernote/resourceimageprovider.cpp 2015-03-06 21:14:46 +0000
2008@@ -1,10 +1,10 @@
2009 #include "resourceimageprovider.h"
2010+#include "logging.h"
2011
2012 #include <notesstore.h>
2013 #include <note.h>
2014
2015 #include <QUrlQuery>
2016-#include <QDebug>
2017
2018 ResourceImageProvider::ResourceImageProvider():
2019 QQuickImageProvider(QQuickImageProvider::Image)
2020@@ -20,7 +20,7 @@
2021 QString resourceHash = arguments.queryItemValue("hash");
2022 Note *note = NotesStore::instance()->note(noteGuid);
2023 if (!note) {
2024- qWarning() << "Unable to find note for resource:" << id;
2025+ qCWarning(dcNotesStore) << "Unable to find note for resource:" << id;
2026 return QImage();
2027 }
2028
2029
2030=== modified file 'src/libqtevernote/tag.h'
2031--- src/libqtevernote/tag.h 2015-03-04 20:30:55 +0000
2032+++ src/libqtevernote/tag.h 2015-03-06 21:14:46 +0000
2033@@ -23,7 +23,6 @@
2034
2035 #include "utils/enmldocument.h"
2036 #include "resource.h"
2037-#include "utils/textformat.h"
2038
2039 #include <QObject>
2040 #include <QDateTime>
2041
2042=== modified file 'src/libqtevernote/tags.cpp'
2043--- src/libqtevernote/tags.cpp 2015-03-04 00:23:45 +0000
2044+++ src/libqtevernote/tags.cpp 2015-03-06 21:14:46 +0000
2045@@ -21,8 +21,6 @@
2046 #include "tags.h"
2047 #include "tag.h"
2048
2049-#include <QDebug>
2050-
2051 Tags::Tags(QObject *parent) :
2052 QAbstractListModel(parent)
2053 {
2054
2055=== modified file 'src/libqtevernote/userstore.cpp'
2056--- src/libqtevernote/userstore.cpp 2014-12-09 18:50:55 +0000
2057+++ src/libqtevernote/userstore.cpp 2015-03-06 21:14:46 +0000
2058@@ -21,6 +21,7 @@
2059 #include "userstore.h"
2060 #include "evernoteconnection.h"
2061 #include "jobs/fetchusernamejob.h"
2062+#include "logging.h"
2063
2064 // Evernote sdk
2065 #include <UserStore.h>
2066@@ -34,8 +35,6 @@
2067 #include <transport/TSSLSocket.h>
2068 #include <Thrift.h>
2069
2070-#include <QDebug>
2071-
2072 using namespace apache::thrift;
2073 using namespace apache::thrift::protocol;
2074 using namespace apache::thrift::transport;
2075@@ -78,7 +77,7 @@
2076 void UserStore::fetchUsernameJobDone(EvernoteConnection::ErrorCode errorCode, const QString &errorMessage, const QString &result)
2077 {
2078 if (errorCode != EvernoteConnection::ErrorCodeNoError) {
2079- qWarning() << "Error fetching username:" << errorMessage;
2080+ qCWarning(dcConnection) << "Error fetching username:" << errorMessage;
2081 return;
2082 }
2083
2084
2085=== modified file 'src/libqtevernote/utils/enmldocument.cpp'
2086--- src/libqtevernote/utils/enmldocument.cpp 2015-03-05 18:23:25 +0000
2087+++ src/libqtevernote/utils/enmldocument.cpp 2015-03-06 21:14:46 +0000
2088@@ -21,6 +21,7 @@
2089 #include "enmldocument.h"
2090 #include "notesstore.h"
2091 #include "note.h"
2092+#include "logging.h"
2093
2094 #include <QXmlStreamReader>
2095 #include <QXmlStreamWriter>
2096@@ -28,7 +29,6 @@
2097 #include <QUrl>
2098 #include <QUrlQuery>
2099 #include <QStandardPaths>
2100-#include <QDebug>
2101
2102 // ENML spec: http://xml.evernote.com/pub/enml2.dtd
2103 // QML supported HTML subset: http://qt-project.org/doc/qt-5.0/qtgui/richtext-html-subset.html
2104@@ -203,7 +203,7 @@
2105 }
2106 }
2107 } else {
2108- qDebug() << "unknown mediatype" << mediaType;
2109+ qCWarning(dcEnml) << "Unknown mediatype" << mediaType;
2110 if (type == TypeRichText) {
2111 writer.writeAttribute("src", composeMediaTypeUrl(mediaType, noteGuid, hash));
2112 } else if (type == TypeHtml) {
2113@@ -276,7 +276,7 @@
2114
2115 writer.writeEndElement();
2116 writer.writeEndDocument();
2117- qDebug() << "converted to html" << html;
2118+ qCDebug(dcEnml) << QString("Converted to %1:").arg(type == TypeHtml ? "HTML" : "RichText") << html;
2119 return html;
2120 }
2121
2122
2123=== modified file 'src/libqtevernote/utils/organizeradapter.cpp'
2124--- src/libqtevernote/utils/organizeradapter.cpp 2015-02-28 02:48:16 +0000
2125+++ src/libqtevernote/utils/organizeradapter.cpp 2015-03-06 21:14:46 +0000
2126@@ -1,7 +1,7 @@
2127 #include "organizeradapter.h"
2128 #include "notesstore.h"
2129+#include "logging.h"
2130
2131-#include <QDebug>
2132 #include <QOrganizerItemVisualReminder>
2133 #include <QOrganizerItemAudibleReminder>
2134 #include <QOrganizerItemSaveRequest>
2135@@ -47,12 +47,12 @@
2136 // EDS requires extra metadata to be set
2137 m_collection.setExtendedMetaData("collection-type", "Task List");
2138 if (!m_manager->saveCollection(&m_collection)) {
2139- qWarning() << "WARNING: Creating dedicated collection for reminders was not possible, reminders will be saved into the default collection!";
2140+ qCWarning(dcOrganizer) << "WARNING: Creating dedicated collection for reminders was not possible, reminders will be saved into the default collection!";
2141 m_collection = m_manager->defaultCollection();
2142 }
2143 }
2144
2145- qDebug() << "have collection" << m_collection.id().toString();
2146+ qCDebug(dcOrganizer) << "Have Organizer collection" << m_collection.id().toString();
2147 }
2148
2149 void OrganizerAdapter::startSync()
2150@@ -133,7 +133,7 @@
2151 }
2152
2153 if (state == QOrganizerAbstractRequest::CanceledState) {
2154- qWarning() << "Error syncing reminders. Could not read organizer items.";
2155+ qCWarning(dcOrganizer) << "Error syncing reminders. Could not read organizer items.";
2156 m_busy = false;
2157 request->deleteLater();
2158 return;
2159
2160=== removed file 'src/libqtevernote/utils/textformat.cpp'
2161--- src/libqtevernote/utils/textformat.cpp 2014-01-29 16:04:00 +0000
2162+++ src/libqtevernote/utils/textformat.cpp 1970-01-01 00:00:00 +0000
2163@@ -1,25 +0,0 @@
2164-/*
2165- * Copyright: 2013 Canonical, Ltd
2166- *
2167- * This file is part of reminders-app
2168- *
2169- * reminders-app is free software: you can redistribute it and/or modify
2170- * it under the terms of the GNU General Public License as published by
2171- * the Free Software Foundation; version 3.
2172- *
2173- * reminders-app is distributed in the hope that it will be useful,
2174- * but WITHOUT ANY WARRANTY; without even the implied warranty of
2175- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2176- * GNU General Public License for more details.
2177- *
2178- * You should have received a copy of the GNU General Public License
2179- * along with this program. If not, see <http://www.gnu.org/licenses/>.
2180- *
2181- * Authors: Michael Zanetti <michael.zanetti@canonical.com>
2182- */
2183-
2184-#include "textformat.h"
2185-
2186-TextFormat::TextFormat(QObject *parent): QObject(parent)
2187-{
2188-}
2189
2190=== removed file 'src/libqtevernote/utils/textformat.h'
2191--- src/libqtevernote/utils/textformat.h 2014-01-29 18:27:11 +0000
2192+++ src/libqtevernote/utils/textformat.h 1970-01-01 00:00:00 +0000
2193@@ -1,43 +0,0 @@
2194-/*
2195- * Copyright: 2013 Canonical, Ltd
2196- *
2197- * This file is part of reminders-app
2198- *
2199- * reminders-app is free software: you can redistribute it and/or modify
2200- * it under the terms of the GNU General Public License as published by
2201- * the Free Software Foundation; version 3.
2202- *
2203- * reminders-app is distributed in the hope that it will be useful,
2204- * but WITHOUT ANY WARRANTY; without even the implied warranty of
2205- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2206- * GNU General Public License for more details.
2207- *
2208- * You should have received a copy of the GNU General Public License
2209- * along with this program. If not, see <http://www.gnu.org/licenses/>.
2210- *
2211- * Authors: Michael Zanetti <michael.zanetti@canonical.com>
2212- */
2213-
2214-#ifndef TEXTFORMAT_H
2215-#define TEXTFORMAT_H
2216-
2217-#include <QObject>
2218-
2219-class TextFormat: public QObject
2220-{
2221- Q_OBJECT
2222- Q_ENUMS(Format)
2223-public:
2224- enum Format {
2225- Bold,
2226- Italic,
2227- Underlined
2228- };
2229- Q_DECLARE_FLAGS(Formats, Format)
2230-
2231- TextFormat(QObject *parent = 0);
2232-};
2233-Q_DECLARE_OPERATORS_FOR_FLAGS(TextFormat::Formats)
2234-Q_DECLARE_METATYPE(TextFormat::Format)
2235-
2236-#endif
2237
2238=== modified file 'src/plugin/Evernote/evernoteplugin.cpp'
2239--- src/plugin/Evernote/evernoteplugin.cpp 2014-10-09 00:08:52 +0000
2240+++ src/plugin/Evernote/evernoteplugin.cpp 2015-03-06 21:14:46 +0000
2241@@ -32,8 +32,6 @@
2242 #include "tag.h"
2243 #include "resourceimageprovider.h"
2244
2245-#include "utils/textformat.h"
2246-
2247 #include <QtQml>
2248
2249 static QObject* userStoreProvider(QQmlEngine* /* engine */, QJSEngine* /* scriptEngine */)
2250@@ -64,8 +62,6 @@
2251 qmlRegisterUncreatableType<Notebook>(uri, 0, 1, "Notebook", "Cannot create Notes in QML. Use NotesStore.createNotebook() instead.");
2252 qmlRegisterUncreatableType<Tag>(uri, 0, 1, "Tag", "Cannot create Tags in QML. Use NotesStore.createTag() instead.");
2253 qmlRegisterUncreatableType<Resource>(uri, 0, 1, "Resource", "Cannot create Resources. Use Note.attachFile() instead.");
2254-
2255- qmlRegisterUncreatableType<TextFormat>(uri, 0, 1, "TextFormat", "TextFormat is not creatable. It's just here to export enums to QML");
2256 }
2257
2258 void EvernotePlugin::initializeEngine(QQmlEngine *engine, const char *uri)

Subscribers

People subscribed via source and target branches