Examples of QByteArray


Examples of com.trolltech.qt.core.QByteArray

          r.setNoteGuid(currentNote.getGuid());
         
          r.setGuid(randint);
          conn.getNoteTable().noteResourceTable.saveNoteResource(r, true);
        QFile f = new QFile(Global.getFileManager().getResDirPath(newFile));
        QByteArray bin = new QByteArray(r.getData().getBody());
        f.open(QFile.OpenModeFlag.WriteOnly);
        f.write(bin);
        f.close();
        newSegment = newSegment.replace("guid=\""+guid, "guid=\""+randint);
        currentNote.getResources().add(r);
View Full Code Here

Examples of com.trolltech.qt.core.QByteArray

  private void sourceEdited() {
    QTextCodec codec = QTextCodec.codecForLocale();
    codec = QTextCodec.codecForName("UTF-8");
        String content =  codec.fromUnicode(sourceEdit.toHtml()).toString();
    content = StringEscapeUtils.unescapeHtml4(removeTags(content));
    QByteArray data = new QByteArray(sourceEditHeader+content+"</body></html>");
    getBrowser().setContent(data);
    checkNoteTitle();
    if (currentNote != null && sourceEdit != null)
      noteSignal.noteChanged.emit(currentNote.getGuid(), sourceEdit.toPlainText());
  }
View Full Code Here

Examples of com.trolltech.qt.core.QByteArray

      }
        try {
          HttpResponse response = http.execute(post);
          HttpEntity resEntity = response.getEntity();
          InputStream is = resEntity.getContent();
          QByteArray data = writeToFile(is);
          conn.getInkImagesTable().saveImage(guid, slice, data);
      } catch (ClientProtocolException e) {
        e.printStackTrace();
      } catch (IOException e) {
        e.printStackTrace();
View Full Code Here

Examples of com.trolltech.qt.core.QByteArray

              iStream.close();
              fOut.close();
          }
          QFile tempFile = new QFile(temp.getAbsoluteFile().toString());
          tempFile.open(OpenModeFlag.ReadOnly);
          QByteArray data = tempFile.readAll();
          tempFile.close();
          tempFile.remove();
          return data;
    }
View Full Code Here

Examples of com.trolltech.qt.core.QByteArray

    String linuxVersion = Global.version;
    String linux64Version = Global.version;
    String version = Global.version;
   
    // Determine the versions available
    QByteArray data = reply.readLine();
    while (data != null && !reply.atEnd()) {
      String line = data.toString();
      String lineVersion;
      if (line.contains(":"))
        lineVersion = line.substring(line.indexOf(":")+1).replace(" ", "").replace("\n", "");
      else
        lineVersion = "";
View Full Code Here

Examples of com.trolltech.qt.core.QByteArray

    logger.log(logger.EXTREME, "Entering NeverNote.setNoteDirty()");
   
    // Find if the note is being edited externally.  If it is, update it.
    if (externalWindows.containsKey(currentNoteGuid)) {
      QTextCodec codec = QTextCodec.codecForName("UTF-8");
          QByteArray unicode =  codec.fromUnicode(browserWindow.getContent());
      ExternalBrowse window = externalWindows.get(currentNoteGuid);
        window.getBrowserWindow().setContent(unicode);
    }
   
    // If the note is dirty, then it is unsynchronized by default.
View Full Code Here

Examples of com.trolltech.qt.core.QByteArray

    logger.log(logger.EXTREME, "Leaving NeverNote.setNoteDirty()");
    }
    @SuppressWarnings("unused")
  private void saveNoteExternalBrowser(String guid, String content, Boolean save, BrowserWindow browser) {
    QTextCodec codec = QTextCodec.codecForName("UTF-8");
        QByteArray unicode =  codec.fromUnicode(content);
      noteCache.remove(guid);
    noteCache.put(guid, unicode.toString());
      if (guid.equals(currentNoteGuid)) {
        noteDirty = true;
        browserWindow.setContent(unicode);
      }
      if (save) {
View Full Code Here

Examples of com.trolltech.qt.core.QByteArray

       
    logger.log(logger.EXTREME, "Saving to cache");
    QTextCodec codec = QTextCodec.codecForLocale();
//          QTextDecoder decoder = codec.makeDecoder();
    codec = QTextCodec.codecForName("UTF-8");
        QByteArray unicode =  codec.fromUnicode(window.getContent());
       noteCache.put(guid, unicode.toString());
     
       logger.log(logger.EXTREME, "updating list manager");
       listManager.updateNoteContent(guid, window.getContent());
    logger.log(logger.EXTREME, "Updating title");
       listManager.updateNoteTitle(guid, window.getTitle());
View Full Code Here

Examples of com.trolltech.qt.core.QByteArray

  private void loadNoteBrowserInformation(BrowserWindow browser, String guid, Note note) {
    NoteFormatter  formatter = new NoteFormatter(logger, conn, tempFiles);
    formatter.setNote(note, Global.pdfPreview());
    formatter.setHighlight(listManager.getEnSearch());
    QByteArray js;
    if (!noteCache.containsKey(guid)) {
      js = new QByteArray();
      // We need to prepend the note with <HEAD></HEAD> or encoded characters are ugly
      js.append("<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">");   
      js.append("<style type=\"text/css\">.en-crypt-temp { border-collapse:collapse; border-style:solid; border-color:blue; padding:0.0mm 0.0mm 0.0mm 0.0mm; }</style>");
      js.append("<style type=\"text/css\">en-hilight { background-color: rgb(255,255,0) }</style>");
      js.append("<style> img { height:auto; width:auto; max-height:auto; max-width:100%; }</style>");
      if (Global.displayRightToLeft())
        js.append("<style> body { direction:rtl; }</style>");
      js.append("<style type=\"text/css\">en-spell { text-decoration: none; border-bottom: dotted 1px #cc0000; }</style>");
      js.append("</head>");
      formatter.setNote(note, Global.pdfPreview());
      js.append(formatter.rebuildNoteHTML());
      js.append("</HTML>");
      js.replace("<!DOCTYPE en-note SYSTEM 'http://xml.evernote.com/pub/enml.dtd'>", "");
      js.replace("<!DOCTYPE en-note SYSTEM 'http://xml.evernote.com/pub/enml2.dtd'>", "");
      js.replace("<?xml version='1.0' encoding='UTF-8'?>", "");
//          if (Global.enableHTMLEntitiesFix) {
//            browser.getBrowser().setContent(new QByteArray(StringEscapeUtils.unescapeHtml(js.toString())));
//          } else
            browser.setContent(js);
      noteCache.put(guid, js.toString());

      if (formatter.resourceError)
        resourceErrorMessage();
      if (formatter.formatError) {
        waitCursor(false);
           QMessageBox.information(this, tr("Error"),
            tr("NixNote had issues formatting this note." +
            " To protect your data this note is being marked as read-only."))
           waitCursor(true);
      }
      readOnly = formatter.readOnly;
      inkNote = formatter.inkNote;
      if (readOnly)
        readOnlyCache.put(guid, true);
      if (inkNote)
        inkNoteCache.put(guid, true);
    } else {
      logger.log(logger.HIGH, "Note content is being pulled from the cache");
      String cachedContent = formatter.modifyCachedTodoTags(noteCache.get(guid));
      js = new QByteArray(cachedContent);
      browser.setContent(js);
      if (readOnlyCache.containsKey(guid))
          readOnly = true;
      if (inkNoteCache.containsKey(guid))
          inkNote = true;
    }
    if (conn.getNoteTable().isThumbnailNeeded(guid)) {
      thumbnailHTMLReady(guid, js, Global.calculateThumbnailZoom(js.toString()));
    }
    if (readOnly || inkNote ||
        (note.getAttributes() != null && note.getAttributes().getContentClass() != null && note.getAttributes().getContentClass() != ""))
      browser.getBrowser().page().setContentEditable(false)// We don't allow editing of ink notes
    else
View Full Code Here

Examples of com.trolltech.qt.core.QByteArray

          // If we can't get to the file, it is probably locked.  We'll try again later.
          logger.log(logger.LOW, "Unable to save externally edited file.  Saving for later.");
          externalFiles.add(fileName);
          return;
    }
    QByteArray binData = file.readAll();
        file.close();
        if (binData.size() == 0) {
          // If we can't get to the file, it is probably locked.  We'll try again later.
          logger.log(logger.LOW, "Unable to save externally edited file.  Saving for later.");
          externalFiles.add(fileName);
          return;
        }
       
        Resource r = conn.getNoteTable().noteResourceTable.getNoteResource(guid, true);
        if (r==null)
          r = conn.getNoteTable().noteResourceTable.getNoteResource(Global.resourceMap.get(guid), true);
        if (r == null || r.getData() == null || r.getData().getBody() == null)
          return;
        String oldHash = Global.byteArrayToHexString(r.getData().getBodyHash());
        MessageDigest md = MessageDigest.getInstance("MD5");
    md.update(binData.toByteArray());
    byte[] hash = md.digest();
        String newHash = Global.byteArrayToHexString(hash);
        if (r.getNoteGuid().equalsIgnoreCase(currentNoteGuid)) {
          updateResourceContentHash(browserWindow, r.getGuid(), oldHash, newHash);
        }
        if (externalWindows.containsKey(r.getNoteGuid())) {
          updateResourceContentHash(externalWindows.get(r.getNoteGuid()).getBrowserWindow(),
              r.getGuid(), oldHash, newHash);
        }
        conn.getNoteTable().updateResourceContentHash(r.getNoteGuid(), oldHash, newHash);
        Data data = r.getData();
        data.setBody(binData.toByteArray());
        data.setBodyHash(hash);
        logger.log(logger.LOW, "externalFileEdited: " +data.getSize() +" bytes");
        r.setData(data);
        conn.getNoteTable().noteResourceTable.updateNoteResource(r,true);
       
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.