/**
   * Get new notes and updates from Opera Link server and insert them into database
   *
   * @return true if operation succeeded
   */
  private boolean getServerNotes() {
    ArrayList<NoteFolderEntry> notes = null;
    try {
      notes = link.getRootNotes(true);
    } catch (LinkAccessDeniedException e) {
      e.printStackTrace();
      isConnected = false;
      return false;
    } catch (LibOperaLinkException e) {
      e.printStackTrace();
      return false;
    }
    int newNotes = 0;
    ArrayList<Note> allNotes = new ArrayList<Note>();
    flattenNoteFolders(notes, allNotes);

    for (Note note : allNotes) {
      // try to get note from the database
      AppNote appNote = mDbHelper.fetchOperaNote(note.getId());
      if (appNote == null) { // no such note in database, add a new one
        ++newNotes;
        mDbHelper.importAndAddNote(note);
      } else if (!appNote.getNote().content.equals(note.content)) {
        // update already added note
        if (appNote.isSynced()) {
          mDbHelper.updateNote(appNote.getId(), note, true);
        } else { // note content conflicted, add new note leaving the
          // old one
          mDbHelper.createNote(note);
          // set that the old one is synchronised
          mDbHelper.updateNote(appNote.getId(), appNote.getNote(), true);
        }
      }
    }

    showToast(String.valueOf(newNotes) + " " + getString(R.string.got_notes));
    return true;
  }