Evernote 同步机制分析

SyncService

SyncNotification

SyncProgressFragment

 

参考http://www.evernote.com/about/developer/api/evernote-api.htm#_Toc297053055

 

1、EDAM(Evernote Data Access and Management) 协议

 

  • 数据模型(data model)由 service 管理
  • 远程处理(remote procedures)从 service 返回和提交修改数据
  • 通过 Thrift service 定义语言来描述数据模型和远程处理,支持所有流行语言
2、远程处理(remote procedures)
  • UserStore service 用户认证
  • NoteStore service 用于数据变更

3、数据模型



Evernote 同步机制分析

每个核心的 NoteStore 数据元都有一个GUID(Globally unique identifier),在创建时生成,不能修改,被API参考调用。

每个数据对象都有一个 USN(updateSequenceNumber),用于发生修改服务的时候。每次发生变更提交时会创建一个USN。USN 是用户名下唯一且单调递增变量,方便客户端判断同步。

 

  • User - 用户账户,用户名密码邮箱、个人属性、偏好
  • Accounting - 账务,服务级别:如上传次数/空间限制(uploadLimit)。
  • Notebook - 笔记本,每个用户账户可以有多个 notebook,note 需要存放在 notebook 中。有默认的 notebook - 不能删除最后一个 notebook。
  • Note - 超文本文档,ENML(Evernote Markup Language)格式,内嵌资源(images, ink, audio, PDF, etc.),图片以内嵌二进制文件
  • NoteAttributes - 系统定义的属性,如creation time, size, origin,用于搜索和过滤;
  • Resource -  资源文件,二进制数据块。类似于电子邮件的附件,每个资源可能有一组描述其定义的属性 ResourceAttributes.
  • SavedSearch -  保存搜索条件

资源内部使用MD5关联资源,如

<en-media type=”image/jpeg” hash=”9e107d9d372bb6826bd81d3542a419d6”/>

 

4、UserStore Service

 

固定访问: https://www.evernote.com/edam/user

 

UserStore Service API
远程方法 简介
checkVersion 发送客户端版本号给服务,并获取兼容响应。
authenticate 发送用户名和密码给服务,并获取成功的令牌信息。
refreshAuthentication 发送一个将要到期的令牌给服务,并获取一个新的令牌。
getUser 根据令牌返回一个用户。
getPublicUserInfo 返回一个用户的公开信息。
getPreminmInfo 返回一个用户免费/高级账号状态。

 

5、OAuth 认证

 

 

6、NoteStore Service

 

 

固定访问: https://www.evernote.com/edam/note/

 


远程方法

简介

listNotebooks

Returns a list of all of the Notebooks in the account.

getNotebook

Retrieves the state of a single Notebook.

getDefaultNotebook

Retrieves the Notebook that should receive new Notes which do not specify a destination.

createNotebook

Makes a new Notebook in the account.

updateNotebook

Changes an existing Notebook.

expungeNotebook

Permanently removes an existing Notebook. Notes within the notebook are moved to the current default Notebook and moved into the trash.

 

 

 

listTags

Returns a list of all of the Tags in the account.

listTagsByNotebook

Returns a list of all of the Tags that are applied to at least one note within a specified notebook.

getTag

Retrieves the state of a single Tag.

createTag

Makes a new Tag in the account.

updateTag

Changes an existing Tag.

untagAll

Removes a Tag from any Notes.

expungeTag

Permanently removes an existing Tag.

 

 

 

listSearches

Returns a list of all of the SavedSearches in the account.

getSearch

Retrieves the state of a single SavedSearch.

createSearch

Makes a new SavedSearch in the account.

updateSearch

Changes an existing SavedSearch.

expungeSearch

Permanently removes an existing SavedSearch.

 

 

 

findNotes

Performs a search of the Notes in the User’s account based on a configurable filter, returning a paginated subset.

findNotesMetadata

Performs a search of the Notes in the User’s account based on a configurable filter, returning a paginated, configurable subset of metadata for matching notes.

findNoteCounts

Performs a search based on a configurable filter, returning the number of Notes that would match this filter for each Notebook and Tag.

getNote

Retrieves the state of a single Note.

getNoteContent

Retrieves just the ENML hypertext content of a Note.

getNoteSearchText

Returns the plain text contents of a single note.

getNoteTagNames

Retrieves the names of the Tags for a single Note.

createNote

Makes a new Note in an existing Notebook.

updateNote

Changes the content or metadata of a single existing Note.

deleteNote

Moves a single existing Note to the trash.

expungeNote

Permanently removes an existing Note. In most cases, third party applications that wish to remove a Note should use deleteNote instead of expungeNote.

expungeNotes

Permanently removes a set of existing Notes.

expungeInactiveNotes

Permanently removes all of the notes that are currently not active (i.e. notes in the “Trash”)

copyNote

 

listNoteVersions

Retrieves a list of the prior versions of a particular note that are saved within the service.

getNoteVersion

Retrieves a previous version of a Note after it has been updated within the service (for premium Users only).

 

 

getNoteApplicationData

Retrieves the full applicationData map for a given note.

getNoteApplicationDataEntry

Retrieves a single entry in the applicationData map for a given note.

setNoteApplicationDataEntry

Create or update a single entry in the applicationData map for a given note.

unsetNoteApplicationDataEntry

Remove a single entry from the applicationData map for a given note.

 

 

 

getResource

Retrieves the state of a single Note attachment, optionally with its binary contents.

updateResource

Updates the metadata for a single Resource.  (Not its binary contents.)

getResourceData

Retrieves the binary contents of a single Resource.

getResourceByHash

Retrieves one of the resources from a Note, via the MD5 checksum of its contents, not its GUID.

getResourceRecognition

Returns the XML recognition index file for a single Resource, which can be used to find words in the image.

getResourceAlternateData

Retrieves the binary contents of the Resource’s alternate data file.

getResourceAttributes

Returns the set of attributes for the Resource.

getResourceSearchText

Returns the plain text contents of a single Resource.

 

 

 

getResourceApplicationData

Retrieves the full applicationData map for a given resource.

getResourceApplicationDataEntry

Retrieves a single entry in the applicationData map for a given resource.

setResourceApplicationDataEntry

Create or update a single entry in the applicationData map for a given resource.

unsetResourceApplicationDataEntry

Remove a single entry from the applicationData map for a given resource.

 

 

getPublicNotebook

Gets the information for one published Notebook from a user’s account, via its public URI.

createSharedNotebook

Make a new SharedNotebook object.

listSharedNotebooks

Returns a list of all of the SharedNotebooks in an account.

expungeSharedNotebooks

Permanently removes a set of existing SharedNotebooks.

createLinkedNotebook

Makes a new LinkedNotebook object.

updateLinkedNotebook

Changes an existing LinkedNotebook.

listLinkedNotebooks

Returns a list of all LinkedNotebooks in an account.

expungeLinkedNotebook

Permanently removes an existing LinkedNotebook.

authenticateToSharedNotebook

Returns an authentication token that can be used to access the contents of a notebook shared from someone else’s account.

getSharedNotebookByAuth

Get extended information about a notebook shared from someone else’s account.

sendMessageToSharedNotebookMembers

Send an email to some or all of the addresses that a notebook has already been shared with. The message will include a link to the shared notebook.

 

 

 

getSyncState

Light-weight call for caching clients to “ping” the service to see whether the account has changed.

getSyncChunk

Core routine for full, synchronizing clients to retrieve the set of changes in an account since the last checkpoint. If you are developing a new application consider using getFilteredSyncChunkinstead of getSyncChunk.

getFilteredSyncChunk

Similar to getSyncChunk, but allows clients to specify the set of data elements that they would like returned to reduce network traffic and sync time.

getLinkedNotebookSyncState

Light-weight call for caching clients to “ping” the service to see whether shared notebooks linked from other accounts have changed.

getLinkedNotebookSyncChunk

Core routine for full, synchronizing clients to retrieve the set of changes in shared notebooks linked from other accounts since the last checkpoint.

 

 

 

 

 

你可能感兴趣的:(evernote)