import com.trolltech.qt.core.QDataStream;\r
import com.trolltech.qt.core.QFile;\r
import com.trolltech.qt.core.QIODevice;\r
+import com.trolltech.qt.core.QIODevice.OpenModeFlag;\r
import com.trolltech.qt.core.QTemporaryFile;\r
import com.trolltech.qt.core.QUrl;\r
import com.trolltech.qt.xml.QDomAttr;\r
return doc;\r
}\r
\r
+\r
+ // Get an ink note image. If an image doesn't exist then we fall back \r
+ // to the old ugly icon\r
+ private boolean buildInkNote(QDomDocument doc, QDomElement docElem, QDomElement enmedia, QDomAttr hash, String appl) {\r
+ String resGuid = conn.getNoteTable().noteResourceTable.getNoteResourceGuidByHashHex(currentNote.getGuid(), hash.value());\r
+ Resource r = conn.getNoteTable().noteResourceTable.getNoteResource(resGuid, false);\r
+ \r
+ // If we can't find the resource, then fall back to the old method. We'll return & show\r
+ // an error later\r
+ if (r == null || r.getData() == null) \r
+ return false;\r
+ \r
+ // If there isn't some type of error, continue on.\r
+ if (!resourceError) {\r
+ \r
+ // Get a list of images in the database. We'll use these to bulid the page.\r
+ List<QByteArray> data = conn.getInkImagesTable().getImage(r.getGuid());\r
+ \r
+ // If no pictures are found, go back to & just show the icon\r
+ if (data.size() == 0)\r
+ return false;\r
+ \r
+ // We have pictures, so append them to the page. This really isn't proper since\r
+ // we leave the en-media tag in place, but since we can't edit the page it doesn't\r
+ // hurt anything.\r
+ for (int i=0; i<data.size(); i++) {\r
+ QFile f = new QFile(Global.getFileManager().getResDirPath(resGuid + new Integer(i).toString()+".png"));\r
+ f.open(OpenModeFlag.WriteOnly);\r
+ f.write(data.get(i));\r
+ f.close();\r
+ QDomElement newImage = doc.createElement("img");\r
+ newImage.setAttribute("src", QUrl.fromLocalFile(f.fileName()).toString());\r
+ enmedia.appendChild(newImage);\r
+ }\r
+ return true;\r
+ }\r
+ return false;\r
+ }\r
+ \r
\r
// Modify the en-media tag into an attachment\r
private void modifyApplicationTags(QDomDocument doc, QDomElement docElem, QDomElement enmedia, QDomAttr hash, String appl) {\r
logger.log(logger.HIGH, "Entering NeverNote.modifyApplicationTags");\r
- if (appl.equalsIgnoreCase("vnd.evernote.ink"))\r
+ if (appl.equalsIgnoreCase("vnd.evernote.ink")) {\r
readOnly = true;\r
+ if (buildInkNote(doc, docElem, enmedia, hash, appl))\r
+ return;\r
+ }\r
String resGuid = conn.getNoteTable().noteResourceTable.getNoteResourceGuidByHashHex(currentNote.getGuid(), hash.value());\r
Resource r = conn.getNoteTable().noteResourceTable.getNoteResource(resGuid, false);\r
if (r == null || r.getData() == null) \r