2 * This file is part of NeverNote
\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.sql.DatabaseConnection;
\r
49 import cx.fbn.nevernote.utilities.ApplicationLogger;
\r
51 public class ImportData {
\r
53 public int lastError;
\r
54 private String errorMessage;
\r
55 private String fileName;
\r
56 DatabaseConnection conn;
\r
57 QXmlStreamReader reader;
\r
59 private boolean noteIsDirty;
\r
60 private Notebook notebook;
\r
61 private boolean notebookIsDirty;
\r
62 private boolean notebookIsLocal;
\r
63 private boolean notebookIsReadOnly;
\r
64 private QIcon notebookIcon;
\r
66 private boolean tagIsDirty;
\r
67 private final HashMap<String,Integer> titleColors;
\r
68 private SavedSearch search;
\r
69 private boolean searchIsDirty;
\r
70 public int highUpdateSequenceNumber;
\r
71 public long lastSequenceDate;
\r
72 private final ApplicationLogger logger;
\r
73 private final boolean backup;
\r
74 private String notebookGuid;
\r
75 private boolean linkedNotebookIsDirty;
\r
76 private boolean sharedNotebookIsDirty;
\r
77 private LinkedNotebook linkedNotebook;
\r
78 private SharedNotebook sharedNotebook;
\r
79 public final boolean importTags = false;
\r
80 public final boolean importNotebooks = false;
\r
81 private final HashMap<String,String> noteMap;
\r
83 public ImportData(DatabaseConnection c, boolean full) {
\r
84 logger = new ApplicationLogger("import.log");
\r
87 titleColors = new HashMap<String,Integer>();
\r
88 noteMap = new HashMap<String,String>();
\r
91 public void importData(String f) {
\r
97 QFile xmlFile = new QFile(fileName);
\r
98 if (!xmlFile.open(QIODevice.OpenModeFlag.ReadOnly)) {
\r
100 errorMessage = "Cannot open file.";
\r
103 reader = new QXmlStreamReader(xmlFile);
\r
104 while (!reader.atEnd()) {
\r
106 if (reader.hasError()) {
\r
107 errorMessage = reader.errorString();
\r
108 logger.log(logger.LOW, "************************* ERROR READING BACKUP " +reader.errorString());
\r
112 if (reader.name().equalsIgnoreCase("nevernote-export") && reader.isStartElement()) {
\r
113 QXmlStreamAttributes attributes = reader.attributes();
\r
114 String version = attributes.value("version");
\r
115 String type = attributes.value("exportType");
\r
116 String application = attributes.value("application");
\r
117 if (!version.equalsIgnoreCase("0.85") && !version.equalsIgnoreCase("0.86")
\r
118 && !version.equalsIgnoreCase("0.95")) {
\r
120 errorMessage = "Unknown backup version = " +version;
\r
123 if (!application.equalsIgnoreCase("NeverNote")) {
\r
125 errorMessage = "This backup is from an unknown application = " +application;
\r
128 if (!type.equalsIgnoreCase("backup") && backup) {
\r
130 errorMessage = "This is an export file, not a backup file";
\r
133 if (type.equalsIgnoreCase("export") && backup) {
\r
135 errorMessage = "This is a backup file, not an export file";
\r
140 if (reader.name().equalsIgnoreCase("Synchronization") && reader.isStartElement() && backup) {
\r
141 processSynchronizationNode();
\r
142 conn.getSyncTable().setLastSequenceDate(lastSequenceDate);
\r
143 conn.getSyncTable().setUpdateSequenceNumber(highUpdateSequenceNumber);
\r
144 // Global.setSequenceDate(lastSequenceDate);
\r
145 // Global.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 (titleColors.containsKey(note.getGuid()))
\r
161 conn.getNoteTable().setNoteTitleColor(note.getGuid(), titleColors.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") && (backup || importNotebooks))
\r
235 note.setNotebookGuid(textValue());
\r
236 if (reader.name().equalsIgnoreCase("Content"))
\r
237 note.setContent(textValue());
\r
238 if (reader.name().equalsIgnoreCase("NoteTags") && (backup || importTags))
\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 titleColors.put(note.getGuid(), intValue());
\r
252 if (reader.name().equalsIgnoreCase("note") && reader.isEndElement())
\r
259 private Resource processResource() {
\r
260 Resource resource = new Resource();
\r
261 boolean atEnd = false;
\r
262 boolean isDirty = false;
\r
264 if (reader.isStartElement()) {
\r
265 if (reader.name().equalsIgnoreCase("Guid"))
\r
266 resource.setGuid(textValue());
\r
268 Random random1 = new Random();
\r
269 String newGuid = "IMP" +new Integer(random1.nextInt(1000)).toString();
\r
270 newGuid = newGuid+"-"+new Integer(random1.nextInt(1000)).toString();
\r
271 newGuid = newGuid+"-"+new Integer(random1.nextInt(1000)).toString();
\r
272 newGuid = newGuid+"-"+new Integer(random1.nextInt(1000)).toString();
\r
273 resource.setGuid(newGuid);
\r
275 if (reader.name().equalsIgnoreCase("NoteGuid"))
\r
276 resource.setNoteGuid(noteMap.get(textValue()));
\r
277 if (reader.name().equalsIgnoreCase("UpdateSequenceNumber"))
\r
278 resource.setUpdateSequenceNum(intValue());
\r
279 if (reader.name().equalsIgnoreCase("Active"))
\r
280 resource.setActive(booleanValue());
\r
281 if (reader.name().equalsIgnoreCase("Mime"))
\r
282 resource.setMime(textValue());
\r
283 if (reader.name().equalsIgnoreCase("Duration"))
\r
284 resource.setDuration(shortValue());
\r
285 if (reader.name().equalsIgnoreCase("Height"))
\r
286 resource.setHeight(shortValue());
\r
287 if (reader.name().equalsIgnoreCase("Width"))
\r
288 resource.setWidth(shortValue());
\r
289 if (reader.name().equalsIgnoreCase("dirty"))
\r
290 isDirty = booleanValue();
\r
291 if (reader.name().equalsIgnoreCase("Data"))
\r
292 resource.setData(processData("Data"));
\r
293 if (reader.name().equalsIgnoreCase("AlternateData"))
\r
294 resource.setAlternateData(processData("AlternateData"));
\r
295 if (reader.name().equalsIgnoreCase("RecognitionData"))
\r
296 resource.setRecognition(processData("NoteResourceAttribute"));
\r
297 if (reader.name().equalsIgnoreCase("NoteResourceAttribute"))
\r
298 resource.setAttributes(processResourceAttributes());
\r
301 if (reader.name().equalsIgnoreCase("noteresource") && reader.isEndElement())
\r
305 conn.getNoteTable().noteResourceTable.saveNoteResource(resource, isDirty);
\r
311 private Data processData(String nodeName) {
\r
312 Data data = new Data();
\r
313 boolean atEnd = false;
\r
315 if (reader.isStartElement()) {
\r
316 if (reader.name().equalsIgnoreCase("Size"))
\r
317 data.setSize(intValue());
\r
318 if (reader.name().equalsIgnoreCase("Body")) {
\r
319 byte[] b = textValue().getBytes(); // data binary
\r
320 QByteArray hexData = new QByteArray(b);
\r
321 QByteArray binData = new QByteArray(QByteArray.fromHex(hexData));
\r
322 data.setBody(binData.toByteArray());
\r
324 if (reader.name().equalsIgnoreCase("BodyHash")) {
\r
325 byte[] b = textValue().getBytes(); // data binary
\r
326 QByteArray hexData = new QByteArray(b);
\r
327 QByteArray binData = new QByteArray(QByteArray.fromHex(hexData));
\r
328 data.setBodyHash(binData.toByteArray());
\r
332 if (reader.name().equalsIgnoreCase("data") && reader.isEndElement())
\r
336 if (reader.name().equalsIgnoreCase(nodeName) && reader.isEndElement())
\r
342 private ResourceAttributes processResourceAttributes() {
\r
343 ResourceAttributes attributes = new ResourceAttributes();
\r
344 boolean atEnd = false;
\r
346 if (reader.isStartElement()) {
\r
347 if (reader.name().equalsIgnoreCase("CameraMake"))
\r
348 attributes.setCameraMake(textValue());
\r
349 if (reader.name().equalsIgnoreCase("CameraModel"))
\r
350 attributes.setCameraModel(textValue());
\r
351 if (reader.name().equalsIgnoreCase("FileName"))
\r
352 attributes.setFileName(textValue());
\r
353 if (reader.name().equalsIgnoreCase("RecoType"))
\r
354 attributes.setRecoType(textValue());
\r
355 if (reader.name().equalsIgnoreCase("CameraModel"))
\r
356 attributes.setCameraMake(textValue());
\r
357 if (reader.name().equalsIgnoreCase("SourceURL"))
\r
358 attributes.setSourceURL(textValue());
\r
359 if (reader.name().equalsIgnoreCase("Altitude"))
\r
360 attributes.setAltitude(doubleValue());
\r
361 if (reader.name().equalsIgnoreCase("Longitude"))
\r
362 attributes.setLongitude(doubleValue());
\r
363 if (reader.name().equalsIgnoreCase("Latitude"))
\r
364 attributes.setLatitude(doubleValue());
\r
365 if (reader.name().equalsIgnoreCase("Timestamp"))
\r
366 attributes.setTimestamp(longValue());
\r
367 if (reader.name().equalsIgnoreCase("Attachment"))
\r
368 attributes.setAttachment(booleanValue());
\r
369 if (reader.name().equalsIgnoreCase("ClientWillIndex"))
\r
370 attributes.setClientWillIndex(booleanValue());
\r
373 if (reader.name().equalsIgnoreCase("noteresourceattribute") && reader.isEndElement())
\r
381 private List<String> processNoteTagList() {
\r
382 List<String> guidList = new ArrayList<String>();
\r
385 boolean atEnd = false;
\r
387 if (reader.isStartElement()) {
\r
388 if (reader.name().equalsIgnoreCase("guid"))
\r
389 guidList.add(textValue());
\r
392 if (reader.name().equalsIgnoreCase("notetags") && reader.isEndElement())
\r
400 private NoteAttributes processNoteAttributes() {
\r
401 NoteAttributes attributes = new NoteAttributes();
\r
403 boolean atEnd = false;
\r
405 if (reader.isStartElement()) {
\r
406 if (reader.name().equalsIgnoreCase("Author"))
\r
407 attributes.setAuthor(textValue());
\r
408 if (reader.name().equalsIgnoreCase("SourceURL"))
\r
409 attributes.setSourceURL(textValue());
\r
410 if (reader.name().equalsIgnoreCase("Source"))
\r
411 attributes.setSource(textValue());
\r
412 if (reader.name().equalsIgnoreCase("SourceApplication"))
\r
413 attributes.setSourceApplication(textValue());
\r
414 if (reader.name().equalsIgnoreCase("Altitude"))
\r
415 attributes.setAltitude(doubleValue());
\r
416 if (reader.name().equalsIgnoreCase("Longitude"))
\r
417 attributes.setLongitude(doubleValue());
\r
418 if (reader.name().equalsIgnoreCase("Latitude"))
\r
419 attributes.setLatitude(doubleValue());
\r
420 if (reader.name().equalsIgnoreCase("SubjectDate"))
\r
421 attributes.setSubjectDate(longValue());
\r
424 if (reader.name().equalsIgnoreCase("noteattributes") && reader.isEndElement())
\r
432 private void processSynchronizationNode() {
\r
433 boolean atEnd = false;
\r
435 if (reader.isStartElement()) {
\r
436 if (reader.name().equalsIgnoreCase("UpdateSequenceNumber"))
\r
437 highUpdateSequenceNumber = intValue();
\r
438 if (reader.name().equalsIgnoreCase("LastSequenceDate"))
\r
439 lastSequenceDate = longValue();
\r
442 if (reader.name().equalsIgnoreCase("synchronization") && reader.isEndElement())
\r
448 private void processSavedSearchNode() {
\r
449 search = new SavedSearch();
\r
450 searchIsDirty = false;
\r
452 boolean atEnd = false;
\r
454 if (reader.isStartElement()) {
\r
455 if (reader.name().equalsIgnoreCase("Guid"))
\r
456 search.setGuid(textValue());
\r
457 if (reader.name().equalsIgnoreCase("Name"))
\r
458 search.setName(textValue());
\r
459 if (reader.name().equalsIgnoreCase("UpdateSequenceNumber"))
\r
460 search.setUpdateSequenceNum(intValue());
\r
461 if (reader.name().equalsIgnoreCase("Query"))
\r
462 search.setQuery(textValue());
\r
463 if (reader.name().equalsIgnoreCase("Dirty")) {
\r
464 if (booleanValue())
\r
465 searchIsDirty = true;
\r
469 if (reader.name().equalsIgnoreCase("savedsearch") && reader.isEndElement())
\r
475 private void processLinkedNotebookNode() {
\r
476 linkedNotebook = new LinkedNotebook();
\r
477 linkedNotebookIsDirty = false;
\r
479 boolean atEnd = false;
\r
481 if (reader.isStartElement()) {
\r
482 if (reader.name().equalsIgnoreCase("Guid"))
\r
483 linkedNotebook.setGuid(textValue());
\r
484 if (reader.name().equalsIgnoreCase("ShardID"))
\r
485 linkedNotebook.setShardId(textValue());
\r
486 if (reader.name().equalsIgnoreCase("UpdateSequenceNumber"))
\r
487 linkedNotebook.setUpdateSequenceNum(intValue());
\r
488 if (reader.name().equalsIgnoreCase("ShareKey"))
\r
489 linkedNotebook.setShareKey(textValue());
\r
490 if (reader.name().equalsIgnoreCase("ShareName"))
\r
491 linkedNotebook.setShareName(textValue());
\r
492 if (reader.name().equalsIgnoreCase("Uri"))
\r
493 linkedNotebook.setUri(textValue());
\r
494 if (reader.name().equalsIgnoreCase("Username"))
\r
495 linkedNotebook.setUsername(textValue());
\r
496 if (reader.name().equalsIgnoreCase("Dirty")) {
\r
497 if (booleanValue())
\r
498 linkedNotebookIsDirty = true;
\r
502 if (reader.name().equalsIgnoreCase("LinkedNotebook") && reader.isEndElement())
\r
508 private void processSharedNotebookNode() {
\r
509 sharedNotebook = new SharedNotebook();
\r
510 sharedNotebookIsDirty = false;
\r
512 boolean atEnd = false;
\r
514 if (reader.isStartElement()) {
\r
515 if (reader.name().equalsIgnoreCase("Id"))
\r
516 sharedNotebook.setId(intValue());
\r
517 if (reader.name().equalsIgnoreCase("Userid"))
\r
518 sharedNotebook.setUserId(intValue());
\r
519 if (reader.name().equalsIgnoreCase("Email"))
\r
520 sharedNotebook.setEmail(textValue());
\r
521 if (reader.name().equalsIgnoreCase("NotebookGuid"))
\r
522 sharedNotebook.setNotebookGuid(textValue());
\r
523 if (reader.name().equalsIgnoreCase("ShareKey"))
\r
524 sharedNotebook.setShareKey(textValue());
\r
525 if (reader.name().equalsIgnoreCase("Username"))
\r
526 sharedNotebook.setUsername(textValue());
\r
527 if (reader.name().equalsIgnoreCase("ServiceCreated"))
\r
528 sharedNotebook.setServiceCreated(longValue());
\r
529 if (reader.name().equalsIgnoreCase("Dirty")) {
\r
530 if (booleanValue())
\r
531 sharedNotebookIsDirty = true;
\r
535 if (reader.name().equalsIgnoreCase("LinkedNotebook") && reader.isEndElement())
\r
543 private void processNotebookNode() {
\r
544 notebook = new Notebook();
\r
545 Publishing p = new Publishing();
\r
546 notebook.setPublishing(p);
\r
547 notebookIsDirty = false;
\r
548 notebookIsLocal = false;
\r
549 notebookIsReadOnly = false;
\r
550 notebookIcon = null;
\r
551 boolean atEnd = false;
\r
553 if (reader.isStartElement()) {
\r
554 if (reader.name().equalsIgnoreCase("Guid"))
\r
555 notebook.setGuid(textValue());
\r
556 if (reader.name().equalsIgnoreCase("Name"))
\r
557 notebook.setName(textValue());
\r
558 if (reader.name().equalsIgnoreCase("UpdateSequenceNumber"))
\r
559 notebook.setUpdateSequenceNum(intValue());
\r
560 if (reader.name().equalsIgnoreCase("ServiceCreated"))
\r
561 notebook.setServiceCreated(longValue());
\r
562 if (reader.name().equalsIgnoreCase("ServiceUpdated"))
\r
563 notebook.setServiceUpdated(longValue());
\r
564 if (reader.name().equalsIgnoreCase("DefaultNotebook")) {
\r
565 notebook.setDefaultNotebook(booleanValue());
\r
567 if (reader.name().equalsIgnoreCase("Dirty")) {
\r
568 if (booleanValue())
\r
569 notebookIsDirty = true;
\r
571 if (reader.name().equalsIgnoreCase("LocalNotebook")) {
\r
572 if (booleanValue())
\r
573 notebookIsLocal = true;
\r
575 if (reader.name().equalsIgnoreCase("ReadOnly")) {
\r
576 if (booleanValue())
\r
577 notebookIsReadOnly = true;
\r
579 if (reader.name().equalsIgnoreCase("PublishingPublicDescription")) {
\r
580 notebook.getPublishing().setPublicDescription(textValue());
\r
582 if (reader.name().equalsIgnoreCase("PublishingUri")) {
\r
583 notebook.getPublishing().setUri(textValue());
\r
585 if (reader.name().equalsIgnoreCase("PublishingOrder")) {
\r
586 notebook.getPublishing().setOrder(NoteSortOrder.findByValue(intValue()));
\r
588 if (reader.name().equalsIgnoreCase("ReadOnly")) {
\r
589 if (booleanValue())
\r
590 notebookIsReadOnly = true;
\r
592 if (reader.name().equalsIgnoreCase("PublishingAscending")) {
\r
593 if (booleanValue())
\r
594 notebook.getPublishing().setAscending(true);
\r
596 notebook.getPublishing().setAscending(false);
\r
598 if (reader.name().equalsIgnoreCase("Icon")) {
\r
599 byte[] b = textValue().getBytes(); // data binary
\r
600 QByteArray hexData = new QByteArray(b);
\r
601 QByteArray binData = new QByteArray(QByteArray.fromHex(hexData));
\r
602 notebookIcon = new QIcon(QPixmap.fromImage(QImage.fromData(binData)));
\r
604 if (reader.name().equalsIgnoreCase("Stack"))
\r
605 notebook.setStack(textValue());
\r
608 if (reader.name().equalsIgnoreCase("notebook") && reader.isEndElement())
\r
616 private void processTagNode() {
\r
618 tagIsDirty = false;
\r
619 boolean atEnd = false;
\r
621 if (reader.isStartElement()) {
\r
622 if (reader.name().equalsIgnoreCase("Guid"))
\r
623 tag.setGuid(textValue());
\r
624 if (reader.name().equalsIgnoreCase("Name"))
\r
625 tag.setName(textValue());
\r
626 if (reader.name().equalsIgnoreCase("UpdateSequenceNumber"))
\r
627 tag.setUpdateSequenceNum(intValue());
\r
628 if (reader.name().equalsIgnoreCase("ParentGuid"))
\r
629 tag.setParentGuid(textValue());
\r
630 if (reader.name().equalsIgnoreCase("Dirty")) {
\r
631 if (booleanValue())
\r
636 if (reader.name().equalsIgnoreCase("tag") && reader.isEndElement())
\r
645 private String textValue() {
\r
646 return reader.readElementText();
\r
648 private int intValue() {
\r
649 return new Integer(textValue());
\r
651 private long longValue() {
\r
652 return new Long(textValue());
\r
654 private double doubleValue() {
\r
655 return new Double(textValue());
\r
657 private boolean booleanValue() {
\r
658 String value = textValue();
\r
659 if (value.equalsIgnoreCase("true"))
\r
664 private short shortValue() {
\r
665 return new Short(textValue());
\r
668 public void setNotebookGuid(String g) {
\r
672 public String getErrorMessage() {
\r
673 return errorMessage;
\r