opton to enter pre-formatted text. * Changed UTF-8 encoding to be the default option. * Better C++11 compatibility. * Bug fixes. -- Randy BaumgarteTue, 12 Sep 2017 12:00:00 -0400 NixNote (2.0.1) stable; urgency=low * Add the ability to customize some aspects of a table within a note. * Added an auto-save interval. This can be customized in the preferences dialog. * Add the ability to fully justify text. * Add "double click" tray option. May not work on all Window managers & isn't recommended with the "single click" option. * Add the ability to specify the db location via a --condigDir command line option. * Add option to intercept SIGHUP on Linux. * Add option to clear & mark complete multiple reminders from the note list. * Added support for reminder search syntax & attribute filters. * Add support for new plugin locations. * Chinese translation improvements. * Performance improvements & Bug fixes. -- Randy Baumgarte Thu, 9 Mar 2017 12:00:00 -0400 NixNote (2.0) stable; urgency=low * Added the ability to export a note as a PDF. * Added the ability to alter the default notebook. * Added a new material theme. * Ctrl+S will automatically save a note that has been changed. * Bug fixes. -- Randy Baumgarte Tue, 7 Feb 2017 12:00:00 -0400 NixNote (2.0-beta-11) stable; urgency=low * Added the ability to paste multiple attachments at a time. * Added the ability to force a reindexing of a specific note. * Added the ability to disable font preview in the editor dialog. * Added the ability to enable/disable note reminders from the command line. * Added the ability to re-download a specific note from Evernote. * Added a "test" button on the email preferences dialog. * Added socks5 proxy support. * Added the experimental option to force UTF8 encoding if not specified by Evernote. * Added a dialog box to show which the currently defined shortcuts. * Added "About Qt" dialog box. * Added a command to open the Github page. * Added the ability to use find/replace shortcuts in an external window. * Added the ability to automatically restart after the API rate limit has been exceeded (experimental). * Added the option to show a popup on sync errors. * Added better Qt5 support. * Better support for Windows builds. * Bug fixes. -- Randy Baumgarte Wed, 28 Dec 2016 12:00:00 -0400 NixNote (2.0-beta-10) stable; urgency=low * Splt Hunspell into a plugin. * Bug fixes. -- Randy Baumgarte Sun, 18 Sep 2016 12:00:00 -0400 NixNote (2.0-beta-9) stable; urgency=low * Added the ability to append to an existing note via the command line. * Added the ability to disable or customize thumnail intervals. * Bug fixes. -- Randy Baumgarte Sun, 14 Aug 2016 12:00:00 -0400 NixNote (2.0-beta-8) stable; urgency=low * Added the ability to open and close a notebook via the command line. * Separated the webcam into a separate plugin so opencv is not required. * Added a few new shortcuts. * Bug fixes. -- Randy Baumgarte Sat, 25 Jun 2016 12:00:00 -0400 NixNote (2.0-beta-7) stable; urgency=low * Added the ability to create a Table of Contents from selected notes. * More aggressive cleanup of notes to remove invalid attributes. * Note synchronization no longer stops after the first failure. * Added more command line options. * Added the option to automatically add a username to new notes. * Updated Czech translation. * Bug fixes. -- Randy Baumgarte Fri, 18 Dec 2015 18:00:00 -0400 NixNote (2.0-beta-6) stable; urgency=low * Added a "Presentation Mode" that hides almost everything except the editor, the attributes bar, and the tabs of open notes. * Added the ability to customize the editor's default font & background color via the theme.ini. This is for people who were experiencing problems with darker themes. A "Dark Editor" theme has also been included as an example. * The default for viewing PDFs intline has been changed to "no" due to a weird error with Gnome. * A lot of different command line options have been added. This also makes nixnot2-cmd obsolete. * Added the option to disable PDF local indexing. This only impacts new/modified PDFs. Data received from Evernote is still searched. * Better mesasges when a note sync fails. * Bug fixes. -- Randy Baumgarte Wed, 09 Dec 2015 20:00:00 -0400 NixNote (2.0-beta-5) stable; urgency=low * Added the ability to email notes. * Searching will now highlight PDF results. * Added Print Preview & the ability to only print s elected text. * Notes that are marked as shortcuts are now visible in the tray icon. * Added the option to use notify-send instead of Qt's popup notification. * A colors.txt file can be added to customize note background color options. * Basic support for nixnote2-cmd utility. * Various GUI enhancements. * Lots of bug fixes. -- Randy Baumgarte Mon, 16 Nov 2015 14:00:00 -0400 NixNote (2.0-beta-4) stable; urgency=low * Added the ability to auto-hide the editor tool bar. * Added the ability to show/hide more GUI componennts. * Added the ability to customize tray icon actions. * Added more command line options. * Various GUI enhancements. * Lots of bug fixes. -- Randy Baumgarte Tue, 13 Oct 2015 14:00:00 -0400 NixNote (2.0-beta-3) stable; urgency=low * Added the ability to change GUI fonts & font sizes. * Added the ability to change GUI icons. * Added the option to only show popup notices if a sync fails. * Added debug option to disable tag name sorting to bypass non-ASCII character bug. * Lots of bug fixes. -- Randy Baumgarte Sat, 04 Apr 2015 14:00:00 -0400 NixNote (2.0-beta-2) stable; urgency=low * Beta 2. Lots of bug fixes and removal of Thrift. -- Randy Baumgarte Sat, 26 Apr 2014 14:00:00 -0400 nixnote2-2.0.2/cmdtools/ 0000775 0000000 0000000 00000000000 13156041044 0015103 5 ustar 00root root 0000000 0000000 nixnote2-2.0.2/cmdtools/addnote.cpp 0000664 0000000 0000000 00000011176 13156041044 0017233 0 ustar 00root root 0000000 0000000 /********************************************************************************* NixNote - An open-source client for the Evernote service. Copyright (C) 2015 Randy Baumgarte This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ***********************************************************************************/ #include "addnote.h" #include #include #include "global.h" #include "sql/notetable.h" #include "sql/resourcetable.h" extern Global global; AddNote::AddNote(QObject *parent) : QObject(parent) { title = tr("Untitled Note"); created = QDateTime::currentDateTime().toString("yyyy-MM-ddTHH:mm:ss.zzzZ"); updated = QDateTime::currentDateTime().toString("yyyy-MM-ddTHH:mm:ss.zzzZ"); reminder = ""; attachmentDelimiter = "%%"; lid = 0; } //******************************************* //* Write out the file to the dbi directory. //******************************************* void AddNote::write(QString uuid) { QString filename = uuid +".nnex"; // We use a temporary file to write to. At the end it will be renamed into // the DBI directory. We don't write into it because there can be // timing issues where the FileWatcher picks up the file before // the entire text is written out and it causes an error. QFile xmlFile(global.fileManager.getTmpDirPath()+filename); if (!xmlFile.open(QIODevice::WriteOnly)) { qDebug() << "Unable to open file."; return; } QXmlStreamWriter *writer = new QXmlStreamWriter(&xmlFile); writer->setAutoFormatting(true); writer->setCodec("UTF-8"); writer->writeStartDocument(); writer->writeDTD(""); writer->writeStartElement("nixnote-import"); writer->writeAttribute("version", "2"); writer->writeAttribute("application", "NixNote"); writer->writeAttribute("applicationVersion", "2.x"); writer->writeStartElement("NoteAdd"); writer->writeTextElement("Lid", QString::number(lid)); writer->writeTextElement("Title", title); writer->writeStartElement("Content"); writer->writeCDATA(content); writer->writeEndElement(); if (notebook != "") writer->writeTextElement("Notebook", notebook); if (created != "") writer->writeTextElement("Created", created); if (updated != "") writer->writeTextElement("Updated", updated); if (reminder != "") writer->writeTextElement("Reminder", reminder); for (int i=0; i writeTextElement("Tag", tags[i]); } for (int i=0; i writeTextElement("Attachment", attachments[i]); } writer->writeTextElement("AttachmentDelimiter", attachmentDelimiter); writer->writeEndElement(); writer->writeEndElement(); writer->writeEndDocument(); xmlFile.close(); QFile::rename(global.fileManager.getTmpDirPath()+filename,global.fileManager.getDbiDirPath()+filename); } // Create a new resource and add it to the database qint32 AddNote::createResource(Resource &r, int sequence, QByteArray data, QString mime, bool attachment, QString filename, qint32 noteLid) { qint32 lid = noteLid; ConfigStore cs(global.db); qint32 rlid = cs.incrementLidCounter(); QByteArray hash = QCryptographicHash::hash(data, QCryptographicHash::Md5); QString guid = QString::number(rlid); NoteTable noteTable(global.db); r.guid = guid; r.noteGuid = noteTable.getGuid(lid); QString noteguid = r.noteGuid; if (noteguid == "") return 0; r.mime = mime; r.active = true; r.updateSequenceNum = sequence; r.width = 0; r.height = 0; r.duration = 0; ResourceAttributes a; if (r.attributes.isSet()) a = r.attributes; a.attachment = attachment; if (filename != "") { a.fileName = filename; } Data d; d.body = data; d.bodyHash = hash; d.size = data.size(); r.data = d; r.attributes = a; ResourceTable resourceTable(global.db); resourceTable.add(rlid, r, true, lid); return rlid; } nixnote2-2.0.2/cmdtools/addnote.h 0000664 0000000 0000000 00000003150 13156041044 0016671 0 ustar 00root root 0000000 0000000 /********************************************************************************* NixNote - An open-source client for the Evernote service. Copyright (C) 2015 Randy Baumgarte This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ***********************************************************************************/ #ifndef ADDNOTE_H #define ADDNOTE_H #include #include #include "qevercloud/include/QEverCloud.h" using namespace qevercloud; class AddNote : public QObject { Q_OBJECT public: explicit AddNote(QObject *parent = 0); qint32 lid; QString title; QString created; QString updated; QString reminder; QString content; QString notebook; QStringList tags; QStringList attachments; QString attachmentDelimiter; qint32 createResource(Resource &r, int sequence, QByteArray data, QString mime, bool attachment, QString filename, qint32 noteLid); void write(QString uuid); signals: public slots: }; #endif // ADDNOTE_H nixnote2-2.0.2/cmdtools/alternote.cpp 0000664 0000000 0000000 00000016415 13156041044 0017613 0 ustar 00root root 0000000 0000000 /********************************************************************************* NixNote - An open-source client for the Evernote service. Copyright (C) 2015 Randy Baumgarte This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ***********************************************************************************/ #include #include #include "sql/notetable.h" #include "global.h" #include "filters/filtercriteria.h" #include "filters/filterengine.h" #include "sql/notebooktable.h" #include "sql/notetable.h" #include "sql/tagtable.h" #include "utilities/nuuid.h" #include "alternote.h" extern Global global; AlterNote::AlterNote(QObject *parent) : QObject(parent) { addTagNames.clear(); delTagNames.clear(); notebook.clear(); lids.clear(); query=""; clearReminder=false; reminderCompleted=false; reminder=""; } // Do the alter. If the notebook is not found we create it. // If a tag is not found for an add, we add it. If a tag is // not found for a deleteTag, we just ignore it. int AlterNote::alterNote() { // If a query is specified, we find the matching notes. if (query != "") { FilterCriteria *filter = new FilterCriteria(); global.filterCriteria.append(filter); global.filterPosition = 0; FilterEngine engine; filter->setSearchString(query); QList lids; engine.filter(filter, &lids); this->lids.append(lids); } NotebookTable bookTable(global.db); TagTable tagTable(global.db); NoteTable noteTable(global.db); // Loop through each note requested. for (int i=0; i 0 && noteTable.hasTag(lid,tagLid)) { noteTable.removeTag(lid, tagLid, true); } } if (reminderCompleted) { noteTable.setReminderCompleted(lid, true); } if (clearReminder) { noteTable.removeReminder(lid); } } return 0; } QString AlterNote::wrap() { QString returnValue; QXmlStreamWriter *writer = new QXmlStreamWriter(&returnValue); writer->setAutoFormatting(true); writer->setCodec("UTF-8"); writer->writeStartDocument(); writer->writeDTD(""); writer->writeStartElement("nixnote-alternote"); writer->writeAttribute("version", "2"); writer->writeAttribute("application", "NixNote"); writer->writeAttribute("applicationVersion", "2.x"); writer->writeStartElement("AlterNote"); for (int i=0; i writeTextElement("id", QString::number(lids[i])); writer->writeTextElement("Notebook", notebook); writer->writeTextElement("Query", query); for (int i=0; i writeTextElement("AddTag", addTagNames[i]); for (int i=0; i writeTextElement("DelTag", delTagNames[i]); if (clearReminder) writer->writeTextElement("ClearReminder", "true"); if (reminderCompleted) writer->writeTextElement("ReminderComplete", "true"); writer->writeEndElement(); writer->writeEndElement(); writer->writeEndDocument(); return returnValue; } void AlterNote::unwrap(QString data) { lastError = 0; QXmlStreamReader reader(data); while (!reader.atEnd()) { reader.readNext(); if (reader.hasError()) { errorMessage = reader.errorString(); QLOG_ERROR() << "************************* ERROR READING IMPORT " << errorMessage; lastError = 16; return; } if (reader.name().toString().toLower() == "alternote" && !reader.isEndElement()) { reader.readNext(); while(reader.name().toString().toLower() != "alternote") { if (reader.name().toString().toLower() == "id" && reader.isStartElement()) { reader.readNext(); lids.append(reader.text().toString().toInt()); } else if (reader.name().toString().toLower() == "notebook" && reader.isStartElement()) { reader.readNext(); notebook = reader.text().toString(); } else if (reader.name().toString().toLower() == "addtag" && reader.isStartElement()) { reader.readNext(); addTagNames.append(reader.text().toString()); } else if (reader.name().toString().toLower() == "reminder" && reader.isStartElement()) { reader.readNext(); reminder = reader.text().toString(); } else if (reader.name().toString().toLower() == "clearreminder" && reader.isStartElement()) { reader.readNext(); if (reader.text().toString().toLower() == "true") clearReminder=true; } else if (reader.name().toString().toLower() == "remindercomplete" && reader.isStartElement()) { if (reader.text().toString().toLower() == "true") reminderCompleted=true; } else if (reader.name().toString().toLower() == "deltag" && reader.isStartElement()) { reader.readNext(); delTagNames.append(reader.text().toString()); } else if (reader.name().toString().toLower() == "query" && reader.isStartElement()) { reader.readNext(); query = reader.text().toString(); } else reader.readNext(); } } } } nixnote2-2.0.2/cmdtools/alternote.h 0000664 0000000 0000000 00000003067 13156041044 0017257 0 ustar 00root root 0000000 0000000 /********************************************************************************* NixNote - An open-source client for the Evernote service. Copyright (C) 2015 Randy Baumgarte This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ***********************************************************************************/ #ifndef ALTERNOTE_H #define ALTERNOTE_H #include #include #include class AlterNote : public QObject { Q_OBJECT public: explicit AlterNote(QObject *parent = 0); QStringList addTagNames; QStringList delTagNames; QString notebook; QList lids; QString query; int lastError; QString errorMessage; QString reminder; bool clearReminder; bool reminderCompleted; QString wrap(); void unwrap(QString data); int alterNote(); signals: public slots: }; #endif // ALTERNOTE_H nixnote2-2.0.2/cmdtools/cmdlinequery.cpp 0000664 0000000 0000000 00000032751 13156041044 0020320 0 ustar 00root root 0000000 0000000 /********************************************************************************* NixNote - An open-source client for the Evernote service. Copyright (C) 2015 Randy Baumgarte This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ***********************************************************************************/ #include "cmdlinequery.h" #include #include #include #include #include "sql/notetable.h" #include "sql/notebooktable.h" #include "global.h" #include "sql/nsqlquery.h" extern Global global; CmdLineQuery::CmdLineQuery(QObject *parent) : QObject(parent) { stdoutReq=true; printHeaders=true; } void CmdLineQuery::write(QList lids, QString filename) { QString format = "%i%n%t%g%c"; if (this->outputFormat != "") format = outputFormat; QString delimiter = "|"; if (this->delimiter != "") delimiter = this->delimiter; QFile *outputFile = NULL; if (filename != "") { outputFile = new QFile(filename); stdoutReq=false; outputFile->open(QIODevice::WriteOnly); if (!outputFile->isOpen()) { return; } out = new QTextStream(outputFile); } QStringList formats = format.split("%"); if (printHeaders) { QString line; for (int j=1; j 0) date = reminderTime.toString(global.dateFormat + QString(" ") +global.timeFormat); line = line + lineBuilder(date, formats[j], 20); } if (formats[j].startsWith("v")) { QString date=""; if (reminderDoneTime.toMSecsSinceEpoch() > 0) date = reminderDoneTime.toString(global.dateFormat + QString(" ") +global.timeFormat); line = line + lineBuilder(date, formats[j], 20); } if (j isOpen()) outputFile->close(); } QString CmdLineQuery::lineBuilder(QString value, QString format, int defaultPadding, QChar padChar) { QString formatString = format; int padLen = defaultPadding; bool truncate = false; if (formatString.contains(":")) { truncate=true; formatString.chop(1); } formatString = formatString.mid(1); int newPadding = formatString.toInt(); if (newPadding>0) padLen = newPadding; if (padLen>0) return value.leftJustified(padLen, padChar, truncate); else return value; } void CmdLineQuery::writeLine(QString line) { if (stdoutReq) { std::cout << line.toStdString(); return; } *out << line; } QString CmdLineQuery::wrap() { QString returnValue; QXmlStreamWriter *writer = new QXmlStreamWriter(&returnValue); writer->setAutoFormatting(true); writer->setCodec("UTF-8"); writer->writeStartDocument(); writer->writeDTD(""); writer->writeStartElement("nixnote-query"); writer->writeAttribute("version", "2"); writer->writeAttribute("application", "NixNote"); writer->writeAttribute("applicationVersion", "2.x"); writer->writeStartElement("Query"); writer->writeTextElement("ReturnUuid", this->returnUuid); writer->writeTextElement("QueryString", query); writer->writeTextElement("Delimiter", delimiter); writer->writeTextElement("OutputFormat", outputFormat); if (printHeaders) writer->writeTextElement("PrintHeaders", "Yes"); else writer->writeTextElement("PrintHeaders", "No"); writer->writeEndElement(); writer->writeEndElement(); writer->writeEndDocument(); return returnValue; } void CmdLineQuery::unwrap(QString data) { lastError = 0; QLOG_DEBUG() << data; QXmlStreamReader reader(data); while (!reader.atEnd()) { reader.readNext(); if (reader.hasError()) { errorMessage = reader.errorString(); QLOG_ERROR() << "************************* ERROR READING IMPORT " << errorMessage; lastError = 16; return; } if (reader.name().toString().toLower() == "query" && !reader.isEndElement()) { reader.readNext(); while(reader.name().toString().toLower() != "query") { if (reader.name().toString().toLower() == "returnuuid" && reader.isStartElement()) { reader.readNext(); returnUuid = reader.text().toString(); } else if (reader.name().toString().toLower() == "querystring" && reader.isStartElement()) { reader.readNext(); query = reader.text().toString(); } else if (reader.name().toString().toLower() == "delimiter" && reader.isStartElement()) { reader.readNext(); delimiter = reader.text().toString(); } else if (reader.name().toString().toLower() == "outputformat" && reader.isStartElement()) { reader.readNext(); outputFormat = reader.text().toString(); } else if (reader.name().toString().toLower() == "printheaders" && reader.isStartElement()) { reader.readNext(); QString value = reader.text().toString(); if (value.toLower()=="yes") this->printHeaders=true; else this->printHeaders=false; } else reader.readNext(); } } } } nixnote2-2.0.2/cmdtools/cmdlinequery.h 0000664 0000000 0000000 00000003156 13156041044 0017762 0 ustar 00root root 0000000 0000000 /********************************************************************************* NixNote - An open-source client for the Evernote service. Copyright (C) 2015 Randy Baumgarte This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ***********************************************************************************/ #ifndef CMDLINEQUERY_H #define CMDLINEQUERY_H #include #include class CmdLineQuery : public QObject { Q_OBJECT private: QTextStream *out; bool stdoutReq; void writeLine(QString line); QString lineBuilder(QString value, QString format, int defaultPadding=0, QChar padChar=' '); public: explicit CmdLineQuery(QObject *parent = 0); QString query; QString delimiter; QString outputFormat; bool printHeaders; void write(QList lids, QString filename); QString wrap(); void unwrap(QString data); int lastError; QString errorMessage; QString returnUuid; signals: public slots: }; #endif // CMDLINEQUERY_H nixnote2-2.0.2/cmdtools/cmdlinetool.cpp 0000664 0000000 0000000 00000067755 13156041044 0020144 0 ustar 00root root 0000000 0000000 /********************************************************************************* NixNote - An open-source client for the Evernote service. Copyright (C) 2015 Randy Baumgarte This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ***********************************************************************************/ #include "cmdlinetool.h" #include "global.h" #include #include #include "html/enmlformatter.h" #include "utilities/crossmemorymapper.h" #include "filters/filtercriteria.h" #include "filters/filterengine.h" #include "sql/notebooktable.h" #include "sql/tagtable.h" #include "sql/notetable.h" #include "utilities/nuuid.h" #include "email/smtpclient.h" #include "utilities/mimereference.h" #include "threads/syncrunner.h" extern Global global; CmdLineTool::CmdLineTool(QObject *parent) : QObject(parent) { } // Run the command line request. int CmdLineTool::run(StartupConfig &config) { #if QT_VERSION < 0x050000 QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8")); #endif // Force info level messages only QsLogging::Logger& logger = QsLogging::Logger::instance(); logger.setLoggingLevel(QsLogging::InfoLevel); QString errmsg(tr("Unable to attach to shared memory segment. Is the other NixNote running?\n")); if (config.sync()) { // If the shared memory segment doesn't exist, we just do a sync & exit if (!global.sharedMemory->attach()) { return this->sync(); } global.sharedMemory->write(QString("SNCHRONIZE")); global.sharedMemory->detach(); return 1; } if (config.shutdown()) { if (!global.sharedMemory->attach()) { std::cout << errmsg.toStdString(); return 16; } global.sharedMemory->write(QString("IMMEDIATE_SHUTDOWN")); global.sharedMemory->detach(); return 1; } if (config.show()) { if (!global.sharedMemory->attach()) { std::cout << errmsg.toStdString(); return 16; } global.sharedMemory->write(QString("SHOW_WINDOW")); global.sharedMemory->detach(); return 1; } if (config.addNote()) { return addNote(config); } if (config.appendNote()) { return appendNote(config); } if (config.query()) { return queryNotes(config); } if (config.deleteNote()) { return deleteNote(config); } if (config.emailNote()) { return emailNote(config); } if (config.readNote()) { return readNote(config); } if (config.exports() || config.backup()) { return exportNotes(config); } if (config.import()) { return importNotes(config); } if (config.alterNote()) { return alterNote(config); } if (config.openNotebook()) { return openNotebook(config); } if (config.closeNotebook()) { return closeNotebook(config); } if (config.signalOtherGui()) { return signalGui(config); } return 0; } // Email a note via the command line. int CmdLineTool::emailNote(StartupConfig config) { // Look to see if another NixNote is running. If so, then we // expect a response if the note was delete. Otherwise, we // do it ourself. bool useCrossMemory = true; global.sharedMemory->unlock(); global.sharedMemory->detach(); if (!global.sharedMemory->attach()) { useCrossMemory = false; } if (useCrossMemory) { global.sharedMemory->write("EMAIL_NOTE:" + config.email->wrap()); } else { global.db = new DatabaseConnection("nixnote"); // Startup the database return config.email->sendEmail(); } return 0; } // Delete a note via the command line int CmdLineTool::deleteNote(StartupConfig config) { bool useCrossMemory = true; if (config.delNote->verifyDelete) { std::string verify; std::cout << QString(tr("Type DELETE to verify: ")).toStdString(); std::cin >> verify; QString qVerify = QString::fromStdString(verify); if (qVerify.toLower() != "delete") return 16; } // Look to see if another NixNote is running. If so, then we // expect a response if the note was delete. Otherwise, we // do it ourself. global.sharedMemory->unlock(); global.sharedMemory->detach(); if (!global.sharedMemory->attach()) { useCrossMemory = false; } if (useCrossMemory) { global.sharedMemory->write("DELETE_NOTE:" + QString::number(config.delNote->lid)); } else { global.db = new DatabaseConnection("nixnote"); // Startup the database NoteTable noteTable(global.db); noteTable.deleteNote(config.delNote->lid,true); } return 0; } // Query notes via the command line int CmdLineTool::queryNotes(StartupConfig config) { bool expectResponse = true; // Look to see if another NixNote is running. If so, then we // expect a response of the LID created. First we detach it so // we are not talking to ourselves. global.sharedMemory->unlock(); global.sharedMemory->detach(); if (!global.sharedMemory->attach()) { expectResponse = false; } if (expectResponse) { NUuid uuid; config.queryNotes->returnUuid = uuid.create(); QString queryString = config.queryNotes->wrap(); global.sharedMemory->write("CMDLINE_QUERY:" + queryString); int cnt = 0; int maxWait=10; QString tmpFile = global.fileManager.getTmpDirPath()+config.queryNotes->returnUuid+".txt"; QFile responseFile(tmpFile); while (!responseFile.exists() && cnt setSearchString(config.queryNotes->query); QList lids; engine.filter(filter, &lids); config.queryNotes->write(lids, ""); } return 0; } // Add a note via the command line. if Nixnote is running, // the new note is copied into the dbi directory and // auto-imported. If it is not running it is created directly. int CmdLineTool::addNote(StartupConfig config) { // Windows Check #ifndef _WIN32 #ifdef Q_OS_WIN32 _setmode(_fileno(stdin), _O_BINARY); #endif #endif // End windows check // If we are reding stdin if (config.newNote->content == "") { QByteArray content; while(!std::cin.eof()) { char arr[1024]; std::cin.read(arr,sizeof(arr)); int s = std::cin.gcount(); content.append(arr,s); content.append("
"); content.replace("\n","
"); } config.newNote->content = QString::fromAscii(content); } if (!config.newNote->content.contains("content.prepend(""); } if (!config.newNote->content.contains("content.append(""); } EnmlFormatter formatter; formatter.setHtml(config.newNote->content); config.newNote->content = formatter.rebuildNoteEnml(); bool expectResponse = true; // Look to see if another NixNote is running. If so, then we // expect a response of the LID created. First we detach it so // we are not talking to ourselves. global.sharedMemory->unlock(); global.sharedMemory->detach(); if (!global.sharedMemory->attach()) { expectResponse = false; } else { global.sharedMemory->detach(); } if (expectResponse) { NUuid uuid; QString id = uuid.create(); // Setup cross memory for response CrossMemoryMapper crossMemory(id); if (!crossMemory.allocate(512)) expectResponse = false; // Write out the segment config.newNote->write(id); // Start checking for the response int cnt = 0; qint32 newLid = -1; int maxWait = 5; while (expectResponse && cnt0) { std::cout << newLid << QString(tr(" has been created.\n")).toStdString(); return newLid; } else { std::cout << QString(tr("No response from NixNote. Please verify that the note was created.\n")).toStdString(); } } else { // Another NN isn't found, so we do this ourself global.db = new DatabaseConnection("nixnote"); // Startup the database NUuid uuid; Note newNote; newNote.content = config.newNote->content; newNote.active = true; newNote.created = QDateTime::currentMSecsSinceEpoch(); newNote.guid = uuid.create(); if (config.newNote->title != "") newNote.title = config.newNote->title; else newNote.title = tr("Untitled Note"); // Process tags newNote.tagGuids = QList (); newNote.tagNames=QStringList(); for (int i=0; i tags.size(); i++) { QString tagName = config.newNote->tags[i]; TagTable tagTable(global.db); qint32 tagLid = tagTable.findByName(tagName, 0); QString tagGuid; // Do we need to add the tag? if (tagLid == 0) { Tag tag; tag.name = tagName; NUuid uuid; tagGuid = uuid.create(); tag.guid = tagGuid; tagTable.add(0, tag, true, 0); } else { tagTable.getGuid(tagGuid, tagLid); } newNote.tagNames->append(tagName); newNote.tagNames->append(tagGuid); } // Process the notebook if (config.newNote->notebook != "") { QString notebookName = config.newNote->notebook; NotebookTable notebookTable(global.db); qint32 lid = notebookTable.findByName(notebookName); QString notebookGuid; // Do we need to add the notebook? if (lid == 0) { Notebook book; book.name = notebookName; NUuid uuid; QString newGuid = uuid.create(); book.guid = newGuid; notebookGuid = newGuid; lid = notebookTable.add(0, book, true, false); } else { notebookTable.getGuid(notebookGuid, lid); } newNote.notebookGuid = notebookGuid; } else { NotebookTable notebookTable(global.db); newNote.notebookGuid = notebookTable.getDefaultNotebookGuid(); } // Do the dates if (config.newNote->created != "") { QString dateString = config.newNote->created; QDateTime date = QDateTime::fromString(dateString.trimmed(), "yyyy-MM-ddTHH:mm:ss.zzzZ"); newNote.created = date.toMSecsSinceEpoch(); } if (config.newNote->updated != "") { QString dateString = config.newNote->updated; QDateTime date = QDateTime::fromString(dateString, "yyyy-MM-ddTHH:mm:ss.zzzZ"); newNote.updated = date.toMSecsSinceEpoch(); } if (config.newNote->reminder != "") { QString dateString = config.newNote->reminder; QDateTime date = QDateTime::fromString(dateString, "yyyy-MM-ddTHH:mm:ss.zzzZ"); if (date > QDateTime::currentDateTime()) { if (!newNote.attributes.isSet()) { NoteAttributes na; newNote.attributes = na; } newNote.attributes->reminderTime = date.toMSecsSinceEpoch(); } } NoteTable noteTable(global.db); qint32 newLid = noteTable.addStub(newNote.guid); // Do the attachments for (int i=0; i attachments.size(); i++) { QString filename = config.newNote->attachments[i]; QFile file(filename); if (file.exists()) { file.open(QIODevice::ReadOnly); QByteArray ba = file.readAll(); file.close(); MimeReference mimeRef; QString extension = filename; int endPos = filename.lastIndexOf("."); if (endPos != -1) extension = extension.mid(endPos); QString mime = mimeRef.getMimeFromExtension(extension); Resource newRes; bool attachment = true; if (mime == "application/pdf" || mime.startsWith("image/")) attachment = false; config.newNote->createResource(newRes, 0, ba, mime, attachment, QFileInfo(filename).fileName(), newLid); QByteArray hash; if (newRes.data.isSet()) { Data d = newRes.data; if (d.bodyHash.isSet()) hash = d.bodyHash; } if (!newNote.resources.isSet()) { newNote.resources = QList (); } QString mediaString = " "; if (newNote.content->contains(config.newNote->attachmentDelimiter)) { //newNote.content = newNote.content->replace(config.newNote->attachmentDelimiter,mediaString); newNote.content = newNote.content->replace(newNote.content->indexOf(config.newNote->attachmentDelimiter), config.newNote->attachmentDelimiter.size(), mediaString); } else { newNote.content = newNote.content->replace("","
"+mediaString+""); } newNote.resources->append(newRes); } } noteTable.expunge(newLid); noteTable.add(newLid,newNote,true); std::cout << newLid << QString(tr(" has been created.\n")).toStdString(); return newLid; } return 0; } // Append text to a note via the command line. int CmdLineTool::appendNote(StartupConfig config) { // Windows Check #ifndef _WIN32 #ifdef Q_OS_WIN32 _setmode(_fileno(stdin), _O_BINARY); #endif #endif // end windows check // If we are reding stdin if (config.newNote->content == "") { QByteArray content; while(!std::cin.eof()) { char arr[1024]; std::cin.read(arr,sizeof(arr)); int s = std::cin.gcount(); content.append(arr,s); content.append("
"); content.replace("\n","
"); } config.newNote->content = QString::fromAscii(content); } if (!config.newNote->content.contains("content.prepend(""); } if (!config.newNote->content.contains("content.append(""); } EnmlFormatter formatter; formatter.setHtml(config.newNote->content); config.newNote->content = formatter.rebuildNoteEnml(); bool expectResponse = true; // Look to see if another NixNote is running. If so, then we // expect a response of the LID created. First we detach it so // we are not talking to ourselves. global.sharedMemory->unlock(); global.sharedMemory->detach(); if (!global.sharedMemory->attach()) { expectResponse = false; } else { global.sharedMemory->detach(); } if (expectResponse) { NUuid uuid; QString id = uuid.create(); // Setup cross memory for response CrossMemoryMapper crossMemory(id); if (!crossMemory.allocate(512)) expectResponse = false; // Write out the segment config.newNote->write(id); // Start checking for the response int cnt = 0; qint32 newLid = -1; int maxWait = 5; while (expectResponse && cnt0) { std::cout << newLid << QString(tr(" has been appended.\n")).toStdString(); return newLid; } else { std::cout << QString(tr("No response from NixNote. Please verify that the note was appended.\n")).toStdString(); } } } else { // Another NN isn't found, so we do this ourself global.db = new DatabaseConnection("nixnote"); // Startup the database Note newNote; // Fetch the existing note NoteTable noteTable(global.db); if (!noteTable.get(newNote, config.newNote->lid, true, true)) { std::cerr << config.newNote->lid << QString(tr(" was not found.\n")).toStdString(); return -1; } // Append the text to the existing note newNote.content->replace("", "
"); // Chop off the beginning of the new text to remove thecontent.indexOf(" "); } newNote.resources->append(newRes); } } noteTable.expunge(config.newNote->lid); noteTable.add(config.newNote->lid,newNote,true); std::cout << config.newNote->lid << QString(tr(" has been appended.\n")).toStdString(); return config.newNote->lid; } return 0; } // Read a note via the command line and extract the text // contents. int CmdLineTool::readNote(StartupConfig config) { bool useCrossMemory = true; // Look to see if another NixNote is running. If so, then we // expect a response. Otherwise, we do it ourself. global.sharedMemory->unlock(); global.sharedMemory->detach(); if (!global.sharedMemory->attach()) { useCrossMemory = false; } if (useCrossMemory) { NUuid uuid; config.extractText->returnUuid = uuid.create(); CrossMemoryMapper sharedMemory(config.extractText->returnUuid); if (!sharedMemory.allocate(500*1024)) return 16; sharedMemory.clearMemory(); global.sharedMemory->write("READ_NOTE:" + config.extractText->wrap()); int maxWait = 5; bool expectResponse = true; int cnt = 0; while (expectResponse && cntcontent = config.newNote->content.mid(startOfNote+9); // Append the two notes newNote.content = newNote.content + config.newNote->content; // Do the attachments for (int i=0; i ","attachments.size(); i++) { QString filename = config.newNote->attachments[i]; QFile file(filename); if (file.exists()) { file.open(QIODevice::ReadOnly); QByteArray ba = file.readAll(); file.close(); MimeReference mimeRef; QString extension = filename; int endPos = filename.lastIndexOf("."); if (endPos != -1) extension = extension.mid(endPos); QString mime = mimeRef.getMimeFromExtension(extension); Resource newRes; bool attachment = true; if (mime == "application/pdf" || mime.startsWith("image/")) attachment = false; config.newNote->createResource(newRes, 0, ba, mime, attachment, QFileInfo(filename).fileName(), config.newNote->lid); QByteArray hash; if (newRes.data.isSet()) { Data d = newRes.data; if (d.bodyHash.isSet()) hash = d.bodyHash; } if (!newNote.resources.isSet()) { newNote.resources = QList (); } QString mediaString = " "; if (newNote.content->contains(config.newNote->attachmentDelimiter)) { //newNote.content = newNote.content->replace(config.newNote->attachmentDelimiter,mediaString); newNote.content = newNote.content->replace(newNote.content->indexOf(config.newNote->attachmentDelimiter), config.newNote->attachmentDelimiter.size(), mediaString); } else { newNote.content = newNote.content->replace("
"+mediaString+"unwrap(data); } else { sleep(1); } cnt++; } if (!expectResponse) std::cout << config.extractText->text.toStdString() << endl; else std::cout << tr("No response received from NixNote.").toStdString(); } else { global.db = new DatabaseConnection("nixnote"); // Startup the database NoteTable noteTable(global.db); Note n; QString text; if (noteTable.get(n,config.extractText->lid,false,false)) text = config.extractText->stripTags(n.content); else text = tr("Note not found."); std::cout << text.toStdString() << endl; } return 0; } // Export notes or do a backup via the command line int CmdLineTool::exportNotes(StartupConfig config) { if (global.sharedMemory->attach()) { std::cout << tr("This cannot be done with NixNote running.").toStdString() << endl; return 16; } global.db = new DatabaseConnection("nixnote"); // Startup the database if (config.exportNotes->backup) config.exportNotes->backupDB(); else config.exportNotes->extract(); return 0; } // Import notes from a nnex file. int CmdLineTool::importNotes(StartupConfig config) { if (global.sharedMemory->attach()) { std::cout << tr("This cannot be done with NixNote running.").toStdString() << endl; return 16; } global.db = new DatabaseConnection("nixnote"); // Startup the database config.importNotes->import(); return 0; } // Alter a note's notebook or add/remove tags for a note. int CmdLineTool::alterNote(StartupConfig config) { // Look to see if another NixNote is running. If so, then we // expect a response, otherwise we do it ourself. bool useCrossMemory = true; global.sharedMemory->unlock(); global.sharedMemory->detach(); if (!global.sharedMemory->attach()) { useCrossMemory = false; } if (useCrossMemory) { global.sharedMemory->write("ALTER_NOTE:" + config.alter->wrap()); } else { global.db = new DatabaseConnection("nixnote"); // Startup the database return config.alter->alterNote(); } return 0; } // Open a notebook int CmdLineTool::openNotebook(StartupConfig config) { if (global.sharedMemory->attach()) { std::cout << tr("This cannot be done with NixNote running.").toStdString() << endl; return 16; } global.db = new DatabaseConnection("nixnote"); // Startup the database NotebookTable bookTable(global.db); for (int i=0; i 0) { bookTable.openNotebook(lid); } else { std::cout << tr("Notebook not found: ").toStdString() << config.notebookList[i].toStdString() << endl; } } return 0; } // Close a notebook int CmdLineTool::closeNotebook(StartupConfig config) { if (global.sharedMemory->attach()) { std::cout << tr("This cannot be done with NixNote running.").toStdString() << endl; return 16; } global.db = new DatabaseConnection("nixnote"); // Startup the database NotebookTable bookTable(global.db); for (int i=0; i 0) { bookTable.closeNotebook(lid); } else { std::cout << tr("Notebook not found: ").toStdString() << config.notebookList[i].toStdString() << endl; } } return 0; } #include "models/notemodel.h" #include "sql/nsqlquery.h" // Do a sync int CmdLineTool::sync() { if (!global.accountsManager->oauthTokenFound()) { std::cout << tr("OAuth token not found.").toStdString() << endl; return 16; } global.db = new DatabaseConnection("nixnote"); // Startup the database // Check if the table exists. If not, create it. NSqlQuery sql(global.db); sql.exec("Select * from sqlite_master where type='table' and name='NoteTable';"); if (!sql.next()) { NoteModel model(this); model.createTable(); } sql.finish(); SyncRunner runner; runner.synchronize(); if (runner.error) { std::cout << tr("Error synchronizing with Evernote.").toStdString() << std::endl; return 16; } std::cout << tr("Sync completed.").toStdString() << std::endl; return 0; } int CmdLineTool::signalGui(StartupConfig config) { // Make sure another one is actually running. If not, we exit out. if (!global.sharedMemory->attach()) { return 16; } if (config.signalGui->show) global.sharedMemory->write(QString("SIGNAL_GUI: SHOW")); if (config.signalGui->takeScreenshot) global.sharedMemory->write(QString("SIGNAL_GUI: SCREENSHOT")); if (config.signalGui->shutdown) global.sharedMemory->write(QString("SIGNAL_GUI: SHUTDOWN")); if (config.signalGui->newNote) global.sharedMemory->write(QString("SIGNAL_GUI: NEW_NOTE")); if (config.signalGui->newExternalNote) global.sharedMemory->write(QString("SIGNAL_GUI: NEW_EXTERNAL_NOTE")); if (config.signalGui->openNote) global.sharedMemory->write("SIGNAL_GUI: OPEN_NOTE " + QVariant(config.signalGui->lid).toString()); if (config.signalGui->openExternalNote) global.sharedMemory->write("SIGNAL_GUI: OPEN_EXTERNAL_NOTE " + QVariant(config.signalGui->lid).toString()); if (config.signalGui->openNoteNewTab) global.sharedMemory->write("SIGNAL_GUI: OPEN_NOTE_NEW_TAB " + QVariant(config.signalGui->lid).toString()); if (config.signalGui->synchronize) global.sharedMemory->write(QString("SIGNAL_GUI: SYNCHRONIZE")); return 0; } nixnote2-2.0.2/cmdtools/cmdlinetool.h 0000664 0000000 0000000 00000003374 13156041044 0017574 0 ustar 00root root 0000000 0000000 /********************************************************************************* NixNote - An open-source client for the Evernote service. Copyright (C) 2015 Randy Baumgarte This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ***********************************************************************************/ #ifndef CMDLINETOOL_H #define CMDLINETOOL_H #include #include #include "settings/startupconfig.h" class CmdLineTool : public QObject { Q_OBJECT public: explicit CmdLineTool(QObject *parent = 0); int run(StartupConfig &config); int readNote(StartupConfig config); int addNote(StartupConfig config); int appendNote(StartupConfig config); int queryNotes(StartupConfig config); int deleteNote(StartupConfig config); int emailNote(StartupConfig config); int exportNotes(StartupConfig config); int alterNote(StartupConfig config); int importNotes(StartupConfig config); int openNotebook(StartupConfig config); int closeNotebook(StartupConfig config); int sync(); int signalGui(StartupConfig config); signals: public slots: }; #endif // CMDLINETOOL_H nixnote2-2.0.2/cmdtools/deletenote.cpp 0000664 0000000 0000000 00000002045 13156041044 0017740 0 ustar 00root root 0000000 0000000 /********************************************************************************* NixNote - An open-source client for the Evernote service. Copyright (C) 2015 Randy Baumgarte This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ***********************************************************************************/ #include "deletenote.h" DeleteNote::DeleteNote(QObject *parent) : QObject(parent) { verifyDelete=true; } nixnote2-2.0.2/cmdtools/deletenote.h 0000664 0000000 0000000 00000002265 13156041044 0017411 0 ustar 00root root 0000000 0000000 /********************************************************************************* NixNote - An open-source client for the Evernote service. Copyright (C) 2015 Randy Baumgarte This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ***********************************************************************************/ #ifndef DELETENOTE_H #define DELETENOTE_H #include class DeleteNote : public QObject { Q_OBJECT public: explicit DeleteNote(QObject *parent = 0); bool verifyDelete; qint32 lid; signals: public slots: }; #endif // DELETENOTE_H nixnote2-2.0.2/cmdtools/emailnote.cpp 0000664 0000000 0000000 00000030433 13156041044 0017567 0 ustar 00root root 0000000 0000000 /********************************************************************************* NixNote - An open-source client for the Evernote service. Copyright (C) 2015 Randy Baumgarte This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ***********************************************************************************/ #include "emailnote.h" #include #include #include "global.h" #include "email/mimehtml.h" #include "utilities/mimereference.h" #include "email/mimeinlinefile.h" #include "sql/resourcetable.h" #include "sql/notetable.h" #include "html/noteformatter.h" extern Global global; EmailNote::EmailNote(QObject *parent) : QObject(parent) { ccSelf = false; } QString EmailNote::wrap() { QString returnValue; QXmlStreamWriter *writer = new QXmlStreamWriter(&returnValue); writer->setAutoFormatting(true); writer->setCodec("UTF-8"); writer->writeStartDocument(); writer->writeDTD(""); writer->writeStartElement("nixnote-email"); writer->writeAttribute("version", "2"); writer->writeAttribute("application", "NixNote"); writer->writeAttribute("applicationVersion", "2.x"); writer->writeStartElement("EmailNote"); writer->writeTextElement("id", QString::number(lid)); writer->writeTextElement("subject", subject); writer->writeTextElement("To", to); writer->writeTextElement("Cc", cc); writer->writeTextElement("Bcc", bcc); writer->writeStartElement("Note"); writer->writeCDATA(note); writer->writeEndElement(); if (ccSelf) writer->writeTextElement("CcSelf", "Yes"); else writer->writeTextElement("CcSelf", "No"); writer->writeEndElement(); writer->writeEndElement(); writer->writeEndDocument(); return returnValue; } void EmailNote::unwrap(QString data) { lastError = 0; QXmlStreamReader reader(data); while (!reader.atEnd()) { reader.readNext(); if (reader.hasError()) { errorMessage = reader.errorString(); QLOG_ERROR() << "************************* ERROR READING IMPORT " << errorMessage; lastError = 16; return; } if (reader.name().toString().toLower() == "emailnote" && !reader.isEndElement()) { reader.readNext(); while(reader.name().toString().toLower() != "emailnote") { if (reader.name().toString().toLower() == "to" && reader.isStartElement()) { reader.readNext(); to = reader.text().toString(); } else if (reader.name().toString().toLower() == "cc" && reader.isStartElement()) { reader.readNext(); cc = reader.text().toString(); } else if (reader.name().toString().toLower() == "id" && reader.isStartElement()) { reader.readNext(); lid = reader.text().toString().toInt(); } else if (reader.name().toString().toLower() == "subject" && reader.isStartElement()) { reader.readNext(); subject = reader.text().toString(); } else if (reader.name().toString().toLower() == "bcc" && reader.isStartElement()) { reader.readNext(); bcc = reader.text().toString(); } else if (reader.name().toString().toLower() == "note" && reader.isStartElement()) { reader.readNext(); note = reader.text().toString(); } else if (reader.name().toString().toLower() == "ccself" && reader.isStartElement()) { reader.readNext(); QString value = reader.text().toString(); if (value.toLower()=="yes") this->ccSelf=true; else this->ccSelf=false; } else reader.readNext(); } } } } QStringList EmailNote::tokenizeString(QString value) { QStringList values = value.split(QRegExp(",|;|\\s+"), QString::SkipEmptyParts); // There is probably an easier way to do this with regular expressions, but // I am horrible at regular expressions. for (int i=0; i stripContentsForPrint(body); //QString textContents = editor->page()->currentFrame()->toPlainText(); QStringList images; QStringList attachments; // Now, go thgough & reformat all the img tags. int cidCount=0; QLOG_DEBUG() << contents; int pos = contents.indexOf("src=\"/"); while (pos>=0) { QString localFile = contents.mid(pos+5); int endPos = localFile.indexOf("\""); localFile = localFile.mid(0,endPos); images.append(localFile); endPos = pos+endPos; QString part1 = contents.mid(0,pos); QString part2 = contents.mid(endPos+14); cidCount++; contents = part1 + "src='cid:file" +QString::number(cidCount) +"'" + part2; pos = contents.indexOf("src=\"/", pos+5); } // next, look for all the attachments pos = contents.indexOf("href=\"nnres:"); while (pos >0 -1) { QString localFile = contents.mid(pos+12); int endPos = localFile.indexOf("\""); localFile = localFile.mid(0,endPos); attachments.append(localFile); cidCount++; pos = contents.indexOf("href=\"nnres:", pos+5); } // If the user adds a note, then prepend it to the beginning. if (note.trimmed() != "") { int pos = contents.indexOf("", pos); contents.insert(endPos+1, Qt::escape(note)+" "); } text->setHtml(contents); message->addPart(text); // Add all the images for (int i=0; i
setContentName(ra.fileName); } file->setContentId("file"+QString::number(i+1)); file->setContentType(mime); message->addPart(file); } // Add all the attachments for (int i=0; i setContentName(ra.fileName); } file->setContentType(mime); message->addPart(file); } return; } // Strip the contents from the current webview in preparation for printing. QString EmailNote::stripContentsForPrint(QString contents) { int pos = contents.indexOf("