2 * This file is part of NixNote/NeighborNote
\r
3 * Copyright 2009 Randy Baumgarte
\r
5 * This file may be licensed under the terms of of the
\r
6 * GNU General Public License Version 2 (the ``GPL'').
\r
8 * Software distributed under the License is distributed
\r
9 * on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either
\r
10 * express or implied. See the GPL for the specific language
\r
11 * governing rights and limitations.
\r
13 * You should have received a copy of the GPL along with this
\r
14 * program. If not, go to http://www.gnu.org/licenses/gpl.html
\r
15 * or write to the Free Software Foundation, Inc.,
\r
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
\r
20 package cx.fbn.nevernote.xml;
\r
22 import java.util.ArrayList;
\r
23 import java.util.HashMap;
\r
24 import java.util.List;
\r
25 import java.util.Random;
\r
27 import com.evernote.edam.type.Data;
\r
28 import com.evernote.edam.type.LinkedNotebook;
\r
29 import com.evernote.edam.type.Note;
\r
30 import com.evernote.edam.type.NoteAttributes;
\r
31 import com.evernote.edam.type.NoteSortOrder;
\r
32 import com.evernote.edam.type.Notebook;
\r
33 import com.evernote.edam.type.Publishing;
\r
34 import com.evernote.edam.type.Resource;
\r
35 import com.evernote.edam.type.ResourceAttributes;
\r
36 import com.evernote.edam.type.SavedSearch;
\r
37 import com.evernote.edam.type.SharedNotebook;
\r
38 import com.evernote.edam.type.Tag;
\r
39 import com.trolltech.qt.core.QByteArray;
\r
40 import com.trolltech.qt.core.QFile;
\r
41 import com.trolltech.qt.core.QIODevice;
\r
42 import com.trolltech.qt.gui.QIcon;
\r
43 import com.trolltech.qt.gui.QImage;
\r
44 import com.trolltech.qt.gui.QPixmap;
\r
45 import com.trolltech.qt.xml.QXmlStreamAttributes;
\r
46 import com.trolltech.qt.xml.QXmlStreamReader;
\r
48 import cx.fbn.nevernote.evernote.NoteMetadata;
\r
49 import cx.fbn.nevernote.sql.DatabaseConnection;
\r
50 import cx.fbn.nevernote.utilities.ApplicationLogger;
\r
52 public class ImportData {
\r
54 public int lastError;
\r
55 private String errorMessage;
\r
56 private String fileName;
\r
57 DatabaseConnection conn;
\r
58 QXmlStreamReader reader;
\r
60 private boolean noteIsDirty;
\r
61 private Notebook notebook;
\r
62 private boolean notebookIsDirty;
\r
63 private boolean notebookIsLocal;
\r
64 private boolean notebookIsReadOnly;
\r
65 private QIcon notebookIcon;
\r
67 private boolean tagIsDirty;
\r
68 // private final HashMap<String,Integer> titleColors;
\r
69 private SavedSearch search;
\r
70 private boolean searchIsDirty;
\r
71 public int highUpdateSequenceNumber;
\r
72 public long lastSequenceDate;
\r
73 private final ApplicationLogger logger;
\r
74 private final boolean backup;
\r
75 private String notebookGuid;
\r
76 private boolean linkedNotebookIsDirty;
\r
77 private boolean sharedNotebookIsDirty;
\r
78 private LinkedNotebook linkedNotebook;
\r
79 private SharedNotebook sharedNotebook;
\r
80 public final boolean importTags = false;
\r
81 public final boolean importNotebooks = false;
\r
82 private final HashMap<String,String> noteMap;
\r
83 private final HashMap<String, NoteMetadata> metaData;
\r
85 public ImportData(DatabaseConnection c, boolean full) {
\r
86 logger = new ApplicationLogger("import.log");
\r
89 metaData = new HashMap<String,NoteMetadata>();
\r
90 noteMap = new HashMap<String,String>();
\r
93 public void importData(String f) {
\r
99 QFile xmlFile = new QFile(fileName);
\r
100 if (!xmlFile.open(QIODevice.OpenModeFlag.ReadOnly)) {
\r
102 errorMessage = "Cannot open file.";
\r
105 reader = new QXmlStreamReader(xmlFile);
\r
106 while (!reader.atEnd()) {
\r
108 if (reader.hasError()) {
\r
109 errorMessage = reader.errorString();
\r
110 logger.log(logger.LOW, "************************* ERROR READING BACKUP " +reader.errorString());
\r
114 if (reader.name().equalsIgnoreCase("nevernote-export") && reader.isStartElement()) {
\r
115 QXmlStreamAttributes attributes = reader.attributes();
\r
116 String version = attributes.value("version");
\r
117 String type = attributes.value("exportType");
\r
118 String application = attributes.value("application");
\r
119 if (!version.equalsIgnoreCase("0.85") && !version.equalsIgnoreCase("0.86")
\r
120 && !version.equalsIgnoreCase("0.95")) {
\r
122 errorMessage = "Unknown backup version = " +version;
\r
125 if (!application.equalsIgnoreCase("NeverNote")) {
\r
127 errorMessage = "This backup is from an unknown application = " +application;
\r
130 if (!type.equalsIgnoreCase("backup") && backup) {
\r
132 errorMessage = "This is an export file, not a backup file";
\r
135 if (type.equalsIgnoreCase("export") && backup) {
\r
137 errorMessage = "This is a backup file, not an export file";
\r
142 if (reader.name().equalsIgnoreCase("Synchronization") && reader.isStartElement() && backup) {
\r
143 processSynchronizationNode();
\r
144 conn.getSyncTable().setLastSequenceDate(lastSequenceDate);
\r
145 conn.getSyncTable().setUpdateSequenceNumber(highUpdateSequenceNumber);
\r
147 if (reader.name().equalsIgnoreCase("note") && reader.isStartElement()) {
\r
150 conn.getNoteTable().addNote(note, noteIsDirty);
\r
152 note.setUpdateSequenceNum(0);
\r
153 if (notebookGuid != null)
\r
154 note.setNotebookGuid(notebookGuid);
\r
155 for (int i=0; i<note.getResourcesSize(); i++) {
\r
156 note.getResources().get(i).setUpdateSequenceNum(0);
\r
158 conn.getNoteTable().addNote(note, true);
\r
160 if (metaData.containsKey(note.getGuid()))
\r
161 conn.getNoteTable().updateNoteMetadata(metaData.get(note.getGuid()));
\r
163 if (reader.name().equalsIgnoreCase("notebook") && reader.isStartElement() && (backup || importNotebooks)) {
\r
164 processNotebookNode();
\r
165 String existingGuid = conn.getNotebookTable().findNotebookByName(notebook.getName());
\r
166 if (existingGuid == null) {
\r
167 conn.getNotebookTable().addNotebook(notebook, notebookIsDirty, notebookIsLocal);
\r
169 conn.getNotebookTable().updateNotebookGuid(existingGuid, notebook.getGuid());
\r
170 conn.getNotebookTable().updateNotebook(notebook, notebookIsDirty);
\r
172 conn.getNotebookTable().setIcon(notebook.getGuid(), notebookIcon, "PNG");
\r
173 conn.getNotebookTable().setReadOnly(notebook.getGuid(), notebookIsReadOnly);
\r
175 if (reader.name().equalsIgnoreCase("tag") && reader.isStartElement() && (backup || importTags)) {
\r
177 String testGuid = conn.getTagTable().findTagByName(tag.getName());
\r
178 if (testGuid == null)
\r
179 conn.getTagTable().addTag(tag, tagIsDirty);
\r
181 conn.getTagTable().updateTagGuid(testGuid, tag.getGuid());
\r
182 conn.getTagTable().updateTag(tag,tagIsDirty);
\r
185 if (reader.name().equalsIgnoreCase("savedsearch") && reader.isStartElement() && backup) {
\r
186 processSavedSearchNode();
\r
187 conn.getSavedSearchTable().addSavedSearch(search, searchIsDirty);
\r
189 if (reader.name().equalsIgnoreCase("LinkedNotebook") && reader.isStartElement() && backup) {
\r
190 processLinkedNotebookNode();
\r
191 conn.getLinkedNotebookTable().addNotebook(linkedNotebook, linkedNotebookIsDirty);
\r
193 if (reader.name().equalsIgnoreCase("SharedNotebook") && reader.isStartElement() && backup) {
\r
194 processSharedNotebookNode();
\r
195 conn.getSharedNotebookTable().addNotebook(sharedNotebook, sharedNotebookIsDirty);
\r
202 private void processNoteNode() {
\r
204 note.setResources(new ArrayList<Resource>());
\r
206 boolean atEnd = false;
\r
208 if (reader.isStartElement()) {
\r
209 if (reader.name().equalsIgnoreCase("Guid")) {
\r
210 note.setGuid(textValue());
\r
212 Random random1 = new Random();
\r
213 String newGuid = "IMP" +new Integer(random1.nextInt(1000)).toString();
\r
214 newGuid = newGuid+"-"+new Integer(random1.nextInt(1000)).toString();
\r
215 newGuid = newGuid+"-"+new Integer(random1.nextInt(1000)).toString();
\r
216 newGuid = newGuid+"-"+new Integer(random1.nextInt(1000)).toString();
\r
217 noteMap.put(note.getGuid(), newGuid);
\r
218 note.setGuid(newGuid);
\r
220 noteMap.put(note.getGuid(), note.getGuid());
\r
222 if (reader.name().equalsIgnoreCase("UpdateSequenceNumber"))
\r
223 note.setUpdateSequenceNum(intValue());
\r
224 if (reader.name().equalsIgnoreCase("Title"))
\r
225 note.setTitle(textValue());
\r
226 if (reader.name().equalsIgnoreCase("Created"))
\r
227 note.setCreated(longValue());
\r
228 if (reader.name().equalsIgnoreCase("Updated"))
\r
229 note.setUpdated(longValue());
\r
230 if (reader.name().equalsIgnoreCase("Deleted"))
\r
231 note.setDeleted(longValue());
\r
232 if (reader.name().equalsIgnoreCase("Active"))
\r
233 note.setActive(booleanValue());
\r
234 if (reader.name().equalsIgnoreCase("NotebookGuid"))
\r
235 note.setNotebookGuid(textValue());
\r
236 if (reader.name().equalsIgnoreCase("Content"))
\r
237 note.setContent(textValue());
\r
238 if (reader.name().equalsIgnoreCase("NoteTags"))
\r
239 note.setTagGuids(processNoteTagList());
\r
240 if (reader.name().equalsIgnoreCase("NoteAttributes"))
\r
241 note.setAttributes(processNoteAttributes());
\r
242 if (reader.name().equalsIgnoreCase("NoteResource"))
\r
243 note.getResources().add(processResource());
\r
244 if (reader.name().equalsIgnoreCase("Dirty")) {
\r
245 if (booleanValue())
\r
248 if (reader.name().equalsIgnoreCase("TitleColor")) {
\r
249 if (metaData.get(note.getGuid()) == null) {
\r
250 NoteMetadata m = new NoteMetadata();
\r
251 m.setColor(intValue());
\r
252 metaData.put(note.getGuid(), m);
\r
254 metaData.get(note.getGuid()).setColor(intValue());
\r
258 if (reader.name().equalsIgnoreCase("note") && reader.isEndElement())
\r
265 private Resource processResource() {
\r
266 Resource resource = new Resource();
\r
267 boolean atEnd = false;
\r
268 boolean isDirty = false;
\r
270 if (reader.isStartElement()) {
\r
271 if (reader.name().equalsIgnoreCase("Guid"))
\r
272 resource.setGuid(textValue());
\r
274 Random random1 = new Random();
\r
275 String newGuid = "IMP" +new Integer(random1.nextInt(1000)).toString();
\r
276 newGuid = newGuid+"-"+new Integer(random1.nextInt(1000)).toString();
\r
277 newGuid = newGuid+"-"+new Integer(random1.nextInt(1000)).toString();
\r
278 newGuid = newGuid+"-"+new Integer(random1.nextInt(1000)).toString();
\r
279 resource.setGuid(newGuid);
\r
281 if (reader.name().equalsIgnoreCase("NoteGuid")) {
\r
282 String tx = textValue();
\r
283 resource.setNoteGuid(noteMap.get(textValue()));
\r
284 resource.setNoteGuid(noteMap.get(tx));
\r
286 if (reader.name().equalsIgnoreCase("UpdateSequenceNumber"))
\r
287 resource.setUpdateSequenceNum(intValue());
\r
288 if (reader.name().equalsIgnoreCase("Active"))
\r
289 resource.setActive(booleanValue());
\r
290 if (reader.name().equalsIgnoreCase("Mime"))
\r
291 resource.setMime(textValue());
\r
292 if (reader.name().equalsIgnoreCase("Duration"))
\r
293 resource.setDuration(shortValue());
\r
294 if (reader.name().equalsIgnoreCase("Height"))
\r
295 resource.setHeight(shortValue());
\r
296 if (reader.name().equalsIgnoreCase("Width"))
\r
297 resource.setWidth(shortValue());
\r
298 if (reader.name().equalsIgnoreCase("dirty"))
\r
299 isDirty = booleanValue();
\r
300 if (reader.name().equalsIgnoreCase("Data"))
\r
301 resource.setData(processData("Data"));
\r
302 if (reader.name().equalsIgnoreCase("AlternateData"))
\r
303 resource.setAlternateData(processData("AlternateData"));
\r
304 if (reader.name().equalsIgnoreCase("RecognitionData"))
\r
305 resource.setRecognition(processData("RecognitionData"));
\r
306 if (reader.name().equalsIgnoreCase("NoteResourceAttribute"))
\r
307 resource.setAttributes(processResourceAttributes());
\r
310 if (reader.name().equalsIgnoreCase("noteresource") && reader.isEndElement())
\r
314 conn.getNoteTable().noteResourceTable.saveNoteResource(resource, isDirty);
\r
320 private Data processData(String nodeName) {
\r
321 Data data = new Data();
\r
322 boolean atEnd = false;
\r
324 if (reader.isStartElement()) {
\r
325 if (reader.name().equalsIgnoreCase("Size"))
\r
326 data.setSize(intValue());
\r
327 if (reader.name().equalsIgnoreCase("Body")) {
\r
328 byte[] b = textValue().getBytes(); // data binary
\r
329 QByteArray hexData = new QByteArray(b);
\r
330 QByteArray binData = new QByteArray(QByteArray.fromHex(hexData));
\r
331 data.setBody(binData.toByteArray());
\r
333 if (reader.name().equalsIgnoreCase("BodyHash")) {
\r
334 byte[] b = textValue().getBytes(); // data binary
\r
335 QByteArray hexData = new QByteArray(b);
\r
336 QByteArray binData = new QByteArray(QByteArray.fromHex(hexData));
\r
337 data.setBodyHash(binData.toByteArray());
\r
341 if (reader.name().equalsIgnoreCase("data") && reader.isEndElement())
\r
345 if (reader.name().equalsIgnoreCase(nodeName) && reader.isEndElement())
\r
351 private ResourceAttributes processResourceAttributes() {
\r
352 ResourceAttributes attributes = new ResourceAttributes();
\r
353 boolean atEnd = false;
\r
355 if (reader.isStartElement()) {
\r
356 if (reader.name().equalsIgnoreCase("CameraMake"))
\r
357 attributes.setCameraMake(textValue());
\r
358 if (reader.name().equalsIgnoreCase("CameraModel"))
\r
359 attributes.setCameraModel(textValue());
\r
360 if (reader.name().equalsIgnoreCase("FileName"))
\r
361 attributes.setFileName(textValue());
\r
362 if (reader.name().equalsIgnoreCase("RecoType"))
\r
363 attributes.setRecoType(textValue());
\r
364 if (reader.name().equalsIgnoreCase("CameraModel"))
\r
365 attributes.setCameraMake(textValue());
\r
366 if (reader.name().equalsIgnoreCase("SourceURL"))
\r
367 attributes.setSourceURL(textValue());
\r
368 if (reader.name().equalsIgnoreCase("Altitude"))
\r
369 attributes.setAltitude(doubleValue());
\r
370 if (reader.name().equalsIgnoreCase("Longitude"))
\r
371 attributes.setLongitude(doubleValue());
\r
372 if (reader.name().equalsIgnoreCase("Latitude"))
\r
373 attributes.setLatitude(doubleValue());
\r
374 if (reader.name().equalsIgnoreCase("Timestamp"))
\r
375 attributes.setTimestamp(longValue());
\r
376 if (reader.name().equalsIgnoreCase("Attachment"))
\r
377 attributes.setAttachment(booleanValue());
\r
378 if (reader.name().equalsIgnoreCase("ClientWillIndex"))
\r
379 attributes.setClientWillIndex(booleanValue());
\r
382 if (reader.name().equalsIgnoreCase("noteresourceattribute") && reader.isEndElement())
\r
390 private List<String> processNoteTagList() {
\r
391 List<String> guidList = new ArrayList<String>();
\r
394 boolean atEnd = false;
\r
396 if (reader.isStartElement()) {
\r
397 if (reader.name().equalsIgnoreCase("guid"))
\r
398 guidList.add(textValue());
\r
401 if (reader.name().equalsIgnoreCase("notetags") && reader.isEndElement())
\r
409 private NoteAttributes processNoteAttributes() {
\r
410 NoteAttributes attributes = new NoteAttributes();
\r
412 boolean atEnd = false;
\r
414 if (reader.isStartElement()) {
\r
415 if (reader.name().equalsIgnoreCase("Author"))
\r
416 attributes.setAuthor(textValue());
\r
417 if (reader.name().equalsIgnoreCase("SourceURL"))
\r
418 attributes.setSourceURL(textValue());
\r
419 if (reader.name().equalsIgnoreCase("Source"))
\r
420 attributes.setSource(textValue());
\r
421 if (reader.name().equalsIgnoreCase("SourceApplication"))
\r
422 attributes.setSourceApplication(textValue());
\r
423 if (reader.name().equalsIgnoreCase("Altitude"))
\r
424 attributes.setAltitude(doubleValue());
\r
425 if (reader.name().equalsIgnoreCase("Longitude"))
\r
426 attributes.setLongitude(doubleValue());
\r
427 if (reader.name().equalsIgnoreCase("Latitude"))
\r
428 attributes.setLatitude(doubleValue());
\r
429 if (reader.name().equalsIgnoreCase("SubjectDate"))
\r
430 attributes.setSubjectDate(longValue());
\r
433 if (reader.name().equalsIgnoreCase("noteattributes") && reader.isEndElement())
\r
441 private void processSynchronizationNode() {
\r
442 boolean atEnd = false;
\r
444 if (reader.isStartElement()) {
\r
445 if (reader.name().equalsIgnoreCase("UpdateSequenceNumber"))
\r
446 highUpdateSequenceNumber = intValue();
\r
447 if (reader.name().equalsIgnoreCase("LastSequenceDate"))
\r
448 lastSequenceDate = longValue();
\r
451 if (reader.name().equalsIgnoreCase("synchronization") && reader.isEndElement())
\r
457 private void processSavedSearchNode() {
\r
458 search = new SavedSearch();
\r
459 searchIsDirty = false;
\r
461 boolean atEnd = false;
\r
463 if (reader.isStartElement()) {
\r
464 if (reader.name().equalsIgnoreCase("Guid"))
\r
465 search.setGuid(textValue());
\r
466 if (reader.name().equalsIgnoreCase("Name"))
\r
467 search.setName(textValue());
\r
468 if (reader.name().equalsIgnoreCase("UpdateSequenceNumber"))
\r
469 search.setUpdateSequenceNum(intValue());
\r
470 if (reader.name().equalsIgnoreCase("Query"))
\r
471 search.setQuery(textValue());
\r
472 if (reader.name().equalsIgnoreCase("Dirty")) {
\r
473 if (booleanValue())
\r
474 searchIsDirty = true;
\r
478 if (reader.name().equalsIgnoreCase("savedsearch") && reader.isEndElement())
\r
484 private void processLinkedNotebookNode() {
\r
485 linkedNotebook = new LinkedNotebook();
\r
486 linkedNotebookIsDirty = false;
\r
488 boolean atEnd = false;
\r
490 if (reader.isStartElement()) {
\r
491 if (reader.name().equalsIgnoreCase("Guid"))
\r
492 linkedNotebook.setGuid(textValue());
\r
493 if (reader.name().equalsIgnoreCase("ShardID"))
\r
494 linkedNotebook.setShardId(textValue());
\r
495 if (reader.name().equalsIgnoreCase("UpdateSequenceNumber"))
\r
496 linkedNotebook.setUpdateSequenceNum(intValue());
\r
497 if (reader.name().equalsIgnoreCase("ShareKey"))
\r
498 linkedNotebook.setShareKey(textValue());
\r
499 if (reader.name().equalsIgnoreCase("ShareName"))
\r
500 linkedNotebook.setShareName(textValue());
\r
501 if (reader.name().equalsIgnoreCase("Uri"))
\r
502 linkedNotebook.setUri(textValue());
\r
503 if (reader.name().equalsIgnoreCase("Username"))
\r
504 linkedNotebook.setUsername(textValue());
\r
505 if (reader.name().equalsIgnoreCase("Dirty")) {
\r
506 if (booleanValue())
\r
507 linkedNotebookIsDirty = true;
\r
511 if (reader.name().equalsIgnoreCase("LinkedNotebook") && reader.isEndElement())
\r
517 private void processSharedNotebookNode() {
\r
518 sharedNotebook = new SharedNotebook();
\r
519 sharedNotebookIsDirty = false;
\r
521 boolean atEnd = false;
\r
523 if (reader.isStartElement()) {
\r
524 if (reader.name().equalsIgnoreCase("Id"))
\r
525 sharedNotebook.setId(intValue());
\r
526 if (reader.name().equalsIgnoreCase("Userid"))
\r
527 sharedNotebook.setUserId(intValue());
\r
528 if (reader.name().equalsIgnoreCase("Email"))
\r
529 sharedNotebook.setEmail(textValue());
\r
530 if (reader.name().equalsIgnoreCase("NotebookGuid"))
\r
531 sharedNotebook.setNotebookGuid(textValue());
\r
532 if (reader.name().equalsIgnoreCase("ShareKey"))
\r
533 sharedNotebook.setShareKey(textValue());
\r
534 if (reader.name().equalsIgnoreCase("Username"))
\r
535 sharedNotebook.setUsername(textValue());
\r
536 if (reader.name().equalsIgnoreCase("ServiceCreated"))
\r
537 sharedNotebook.setServiceCreated(longValue());
\r
538 if (reader.name().equalsIgnoreCase("Dirty")) {
\r
539 if (booleanValue())
\r
540 sharedNotebookIsDirty = true;
\r
544 if (reader.name().equalsIgnoreCase("LinkedNotebook") && reader.isEndElement())
\r
552 private void processNotebookNode() {
\r
553 notebook = new Notebook();
\r
554 Publishing p = new Publishing();
\r
555 notebook.setPublishing(p);
\r
556 notebookIsDirty = false;
\r
557 notebookIsLocal = false;
\r
558 notebookIsReadOnly = false;
\r
559 notebookIcon = null;
\r
560 boolean atEnd = false;
\r
562 if (backup || importNotebooks) {
\r
563 if (reader.isStartElement()) {
\r
564 if (reader.name().equalsIgnoreCase("Guid"))
\r
565 notebook.setGuid(textValue());
\r
566 if (reader.name().equalsIgnoreCase("Name"))
\r
567 notebook.setName(textValue());
\r
568 if (reader.name().equalsIgnoreCase("UpdateSequenceNumber"))
\r
569 notebook.setUpdateSequenceNum(intValue());
\r
570 if (reader.name().equalsIgnoreCase("ServiceCreated"))
\r
571 notebook.setServiceCreated(longValue());
\r
572 if (reader.name().equalsIgnoreCase("ServiceUpdated"))
\r
573 notebook.setServiceUpdated(longValue());
\r
574 if (reader.name().equalsIgnoreCase("DefaultNotebook")) {
\r
575 notebook.setDefaultNotebook(booleanValue());
\r
577 if (reader.name().equalsIgnoreCase("Dirty")) {
\r
578 if (booleanValue())
\r
579 notebookIsDirty = true;
\r
581 if (reader.name().equalsIgnoreCase("LocalNotebook")) {
\r
582 if (booleanValue())
\r
583 notebookIsLocal = true;
\r
585 if (reader.name().equalsIgnoreCase("ReadOnly")) {
\r
586 if (booleanValue())
\r
587 notebookIsReadOnly = true;
\r
589 if (reader.name().equalsIgnoreCase("PublishingPublicDescription")) {
\r
590 notebook.getPublishing().setPublicDescription(textValue());
\r
592 if (reader.name().equalsIgnoreCase("PublishingUri")) {
\r
593 notebook.getPublishing().setUri(textValue());
\r
595 if (reader.name().equalsIgnoreCase("PublishingOrder")) {
\r
596 notebook.getPublishing().setOrder(NoteSortOrder.findByValue(intValue()));
\r
598 if (reader.name().equalsIgnoreCase("ReadOnly")) {
\r
599 if (booleanValue())
\r
600 notebookIsReadOnly = true;
\r
602 if (reader.name().equalsIgnoreCase("PublishingAscending")) {
\r
603 if (booleanValue())
\r
604 notebook.getPublishing().setAscending(true);
\r
606 notebook.getPublishing().setAscending(false);
\r
608 if (reader.name().equalsIgnoreCase("Icon")) {
\r
609 byte[] b = textValue().getBytes(); // data binary
\r
610 QByteArray hexData = new QByteArray(b);
\r
611 QByteArray binData = new QByteArray(QByteArray.fromHex(hexData));
\r
612 notebookIcon = new QIcon(QPixmap.fromImage(QImage.fromData(binData)));
\r
614 if (reader.name().equalsIgnoreCase("Stack"))
\r
615 notebook.setStack(textValue());
\r
619 if (reader.name().equalsIgnoreCase("notebook") && reader.isEndElement())
\r
627 private void processTagNode() {
\r
629 tagIsDirty = false;
\r
630 boolean atEnd = false;
\r
632 if (backup || importTags) {
\r
633 if (reader.isStartElement()) {
\r
634 if (reader.name().equalsIgnoreCase("Guid"))
\r
635 tag.setGuid(textValue());
\r
636 if (reader.name().equalsIgnoreCase("Name"))
\r
637 tag.setName(textValue());
\r
638 if (reader.name().equalsIgnoreCase("UpdateSequenceNumber"))
\r
639 tag.setUpdateSequenceNum(intValue());
\r
640 if (reader.name().equalsIgnoreCase("ParentGuid"))
\r
641 tag.setParentGuid(textValue());
\r
642 if (reader.name().equalsIgnoreCase("Dirty")) {
\r
643 if (booleanValue())
\r
649 if (reader.name().equalsIgnoreCase("tag") && reader.isEndElement())
\r
658 private String textValue() {
\r
659 return reader.readElementText();
\r
661 private int intValue() {
\r
662 return new Integer(textValue());
\r
664 private long longValue() {
\r
665 return new Long(textValue());
\r
667 private double doubleValue() {
\r
668 return new Double(textValue());
\r
670 private boolean booleanValue() {
\r
671 String value = textValue();
\r
672 if (value.equalsIgnoreCase("true"))
\r
677 private short shortValue() {
\r
678 return new Short(textValue());
\r
681 public void setNotebookGuid(String g) {
\r
685 public String getErrorMessage() {
\r
686 return errorMessage;
\r