evernote-mode-0_41/0000775000175000017500000000000011601107154014122 5ustar uwabamiuwabamievernote-mode-0_41/APACHE-LICENSE-2.0.txt0000664000175000017500000002613611513076422017176 0ustar uwabamiuwabami Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. evernote-mode-0_41/credits.txt0000664000175000017500000000031511562727062016333 0ustar uwabamiuwabamiContributors (alphabetical) ------------ I would like to acknowledge those who have provided valuable feedback, bug reports, and testing: Akihiro ARISAWA Felix Geller Ryo Onodera Youhei SASAKI evernote-mode-0_41/ruby/0000775000175000017500000000000011601107152015101 5ustar uwabamiuwabamievernote-mode-0_41/ruby/bin/0000775000175000017500000000000011601107152015651 5ustar uwabamiuwabamievernote-mode-0_41/ruby/bin/enclient.rb0000664000175000017500000013734011601106450020007 0ustar uwabamiuwabami#! /usr/bin/ruby1.8 -sWKu # -*- coding: utf-8 -*- # # Copyright 2011 Yusuke KAWAKAMI, Akihiro ARISAWA # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # begin # use rubygems if possible require "rubygems" rescue LoadError end require "cgi" require "singleton" require "base64" require "thread" require "cgi" require "kconv" require "fileutils" require "gdbm" require "logger" require "digest/md5" #require "benchmark" require "thrift/types" require "thrift/struct" require "thrift/protocol/base_protocol" require "thrift/protocol/binary_protocol" require "thrift/transport/base_transport" require "thrift/transport/http_client_transport" require "Evernote/EDAM/user_store" require "Evernote/EDAM/user_store_constants" require "Evernote/EDAM/note_store" require "Evernote/EDAM/limits_constants" module EnClient module Serializable def serialize fields = serialized_fields.map do |varsym, vartype| varval = send varsym if varval case vartype when :field_type_int, :field_type_bool, :field_type_string, :field_type_timestamp "#{varsym}=#{varval}" when :field_type_string_array "#{varsym}=#{varval.join "|"}" when :field_type_base64 "#{varsym}=#{Formatter.encode_base64 varval}" when :field_type_base64_array b64list = Formatter.encode_base64_list varval "#{varsym}=#{b64list.join "|"}" else raise IllegalStateException.new("illegal field type #{ftype}") end end end fields.delete nil fields.join "," end def deserialize(str) fields = str.split "," fields.each do |f| f =~ /\A([^=]*)=(.*)\z/ varsym = $1.to_sym varval_str = $2 vartype = serialized_fields[varsym] #puts "[#{varsym}], [#{varval_str}], [#{vartype}]" varval = if varval_str case vartype when :field_type_int, :field_type_timestamp varval_str.to_i when :field_type_bool if varval_str == "true" true elsif varval_str == "false" false else raise IllegalStateException.new("illegal field value of boolean #{varval_str}") end when :field_type_string varval_str when :field_type_string_array varval_str.split "|" when :field_type_base64 Formatter.decode_base64 varval_str when :field_type_base64_array Formatter.decode_base64_list varval_str.split("|") else raise IllegalStateException.new("illegal field type #{vartype} for #{varsym}") end else nil end send (varsym.to_s + "="), varval end end def to_sexp str = "(" class_name = Formatter.remove_package_names self.class.name str += "(class . #{class_name})" serialized_fields.each do |varsym, vartype| varval = send varsym if varval case vartype when :field_type_int str += "(#{varsym} . #{varval})" when :field_type_timestamp str += %|(#{varsym} . "#{Time.at varval/1000}")| when :field_type_bool if varval == true str += "(#{varsym} . t)" elsif varval_str == false str += "(#{varsym} . nil)" else raise IllegalStateException.new("illegal field value of boolean #{varval}") end when :field_type_string str += %|(#{varsym} . "#{varval}")| when :field_type_string_array str += "(#{varsym} . (" varval.each do |elem| str += %|"#{elem}"| str += " " end str += "))" when :field_type_base64 #str += %|(#{varsym} . "#{Formatter.encode_base64 varval}")| str += %|(#{varsym} . "#{Formatter.sexp_string_escape varval}")| when :field_type_base64_array str += "(#{varsym} . (" varval.each do |elem| #str += %|"#{Formatter.encode_base64 elem}"| # str += " " str += %|"#{Formatter.sexp_string_escape elem}"| str += " " end str += "))" else raise IllegalStateException.new("illegal field type #{vartype}") end else str += "(#{varsym} . nil)" end end str += ")" end end end module Evernote module EDAM module Type class Notebook include ::EnClient::Serializable def serialized_fields { :guid => :field_type_string, :name => :field_type_base64, :updateSequenceNum => :field_type_int, :defaultNotebook => :field_type_bool, :serviceCreated => :field_type_timestamp, :serviceUpdated => :field_type_timestamp } end end class Note include EnClient::Serializable attr_accessor :editMode, :contentFile def serialized_fields { :guid => :field_type_string, :title => :field_type_base64, :created => :field_type_timestamp, :updated => :field_type_timestamp, :updateSequenceNum => :field_type_int, :notebookGuid => :field_type_string, :tagGuids => :field_type_string_array, :tagNames => :field_type_base64_array, :editMode => :field_type_string, :contentFile => :field_type_base64 } end end class Tag include EnClient::Serializable def serialized_fields { :guid => :field_type_string, :name => :field_type_base64, :parentGuid => :field_type_string, :updateSequenceNum => :field_type_int } end end class SavedSearch include EnClient::Serializable def serialized_fields { :guid => :field_type_string, :name => :field_type_base64, :query => :field_type_base64, :format => :field_type_int, :updateSequenceNum => :field_type_int } end end end end end # # main module # module EnClient APPLICATION_NAME_TEXT = %|emacs-enclient {:version => 0.41, :editmode => "TEXT"}| APPLICATION_NAME_XHTML = %|emacs-enclient {:version => 0.41, :editmode => "XHTML"}| #EVERNOTE_HOST = "sandbox.evernote.com" EVERNOTE_HOST = "www.evernote.com" USER_STORE_URL = "https://#{EVERNOTE_HOST}/edam/user" NOTE_STORE_URL_BASE = "https://#{EVERNOTE_HOST}/edam/note/" # error code ERROR_CODE_OK = 0 ERROR_CODE_NOT_FOUND = 100 ERROR_CODE_UNEXPECTED = 101 ERROR_CODE_NOT_AUTHED = 102 ERROR_CODE_TIMEOUT = 103 LOG = Logger.new File.expand_path("~/.evernote-mode.log"), 3 #LOG = Logger.new $stdout LOG.level = Logger::WARN class NotAuthedException < StandardError; end class NotFoundException < StandardError; end class IllegalArgumentException < StandardError; end class IllegalStateException < StandardError; end class HTTPWithProxyClientTransport < Thrift::BaseTransport def initialize(url, proxy_addr = nil, proxy_port = nil) @url = URI url @headers = {'Content-Type' => 'application/x-thrift'} @outbuf = "" @proxy_addr = proxy_addr @proxy_port = proxy_port end def open?; true end def read(sz); @inbuf.read sz end def write(buf); @outbuf << buf end def add_headers(headers) @headers = @headers.merge(headers) end def flush if @proxy_addr && @proxy_port http = Net::HTTP::Proxy(@proxy_addr, @proxy_port).new @url.host, @url.port else http = Net::HTTP.new @url.host, @url.port end http.use_ssl = @url.scheme == "https" #http.verify_mode = OpenSSL::SSL::VERIFY_PEER #http.verify_depth = 5 http.verify_mode = OpenSSL::SSL::VERIFY_NONE resp, data = http.post(@url.request_uri, @outbuf, @headers) @inbuf = StringIO.new data @outbuf = "" end end class TaskQueue def initialize @cond = ConditionVariable.new @mutex = Mutex.new @queue = [] end def push(task) @mutex.synchronize{ @queue.push task @cond.signal } end def push_to_front(task) @mutex.synchronize{ @queue.unshift task @cond.signal } end def pop @mutex.synchronize{ while @queue.size == 0 @cond.wait(@mutex) end task = @queue.shift } end end class Command attr_accessor :command_id, :sm, :dm, :tm, :shell def self.create_from_hash(hash) unless hash.has_key? :class raise IllegalArgumentException.new("key \"class\" is not found") end class_name = hash[:class] command = get_command class_name unless command raise IllegalArgumentException.new("command #{class_name} is not found") end hash.each do |key, value| next if key == :class setter_name = key.to_s + "=" meth = command.send setter_name, value end command end def exec exec_impl rescue reply = ErrorReply.new reply.command_id = @command_id ErrorUtils.set_reply_error $!, reply LOG.warn reply.message LOG.warn $!.backtrace @shell.reply self, reply end private # # Utilities for subclasses # def server_task(ordered = false, &block) task = Task.new do begin yield rescue if $!.is_a? SystemCallError # workaround for corruption of note_store after timed out @sm.fix_note_store end reply = ErrorReply.new reply.command_id = @command_id ErrorUtils.set_reply_error $!, reply LOG.warn reply.message LOG.warn $!.backtrace @shell.reply self, reply end end @tm.put task, !ordered end def check_auth @sm.auth_token # check authentication end # # Private helpers # def self.get_command(name) all_commands = [AuthCommand, ListNoteCommand, ListNotebookCommand, ListTagCommand, ListSearchCommand, SearchNoteCommand, GetNoteCommand, CreateNoteCommand, UpdateNoteCommand, DeleteNoteCommand, CreateNotebookCommand, UpdateNotebookCommand, CreateTagCommand, UpdateTagCommand, CreateSearchCommand, UpdateSearchCommand] command_class = all_commands.find do |elem| Formatter.remove_package_names(elem.name) == name end if command_class command_class.new end end end class AuthCommand < Command attr_accessor :user, :passwd def exec_impl Formatter.to_ascii @user, @passwd server_task do sm.authenticate @user, @passwd LOG.info "Auth successed: auth_token = '#{sm.auth_token}', shared_id = '#{sm.shared_id}'" tm.put SyncTask.new(sm, dm, tm) server_task true do # defer reply until first sync will be done. shell.reply self, AuthReply.new end end end end module FormatNoteOperation private NOTE_DEFAULT_HEADER = %|| NOTE_DEFAULT_FOOTER = %|| def set_attribute_and_format_content!(note) note.attributes = Evernote::EDAM::Type::NoteAttributes.new if note.editMode == "TEXT" note.content = to_xhtml note.content if note.content note.attributes.sourceApplication = APPLICATION_NAME_TEXT elsif note.editMode == "XHTML" note.attributes.sourceApplication = APPLICATION_NAME_XHTML end end def to_xhtml(content) content = CGI.escapeHTML content content.gsub! %r{ }, %{ } content.gsub! %r{(?:\r\n)|\n|\r}, %|
| content = NOTE_DEFAULT_HEADER + content + NOTE_DEFAULT_FOOTER end end class CreateNoteCommand < Command attr_accessor :title, :notebook_guid, :tag_names, :edit_mode, :content include FormatNoteOperation def exec_impl Formatter.to_ascii @title, @content, *@tag_names note = Evernote::EDAM::Type::Note.new note.title = @title note.notebookGuid = @notebook_guid note.tagNames = @tag_names note.editMode = @edit_mode note.content = @content set_attribute_and_format_content! note server_task do result_note = sm.note_store.createNote sm.auth_token, note result_note.editMode = @edit_mode DBUtils.set_note_and_content dm, result_note, @content if result_note.tagGuids result_note.tagGuids.each do |guid| unless DBUtils.exist_tag_in_cache? dm, guid tags = sm.note_store.listTags sm.auth_token DBUtils.sync_updated_tags dm, tags break end end end reply = CreateNoteReply.new reply.note = result_note shell.reply self, reply end end end class UpdateNoteCommand < Command attr_accessor :guid, :title, :notebook_guid, :tag_names, :content, :edit_mode include FormatNoteOperation def exec_impl Formatter.to_ascii @title, @notebook_guid, @content, *@tag_names old_note = DBUtils.get_note dm, @guid note = Evernote::EDAM::Type::Note.new note.guid = @guid if @title note.title = @title else note.title = old_note.title end note.notebookGuid = @notebook_guid note.tagNames = @tag_names if @edit_mode note.editMode = @edit_mode else note.editMode = old_note.editMode end note.content = @content set_attribute_and_format_content! note server_task do result_note = sm.note_store.updateNote sm.auth_token, note result_note.editMode = note.editMode DBUtils.set_note_and_content dm, result_note, @content reply = UpdateNoteReply.new if result_note.tagGuids result_note.tagGuids.each do |guid| unless DBUtils.exist_tag_in_cache? dm, guid tags = sm.note_store.listTags sm.auth_token DBUtils.sync_updated_tags dm, tags break end end end reply.note = result_note shell.reply self, reply end end end class DeleteNoteCommand < Command attr_accessor :guid def exec_impl server_task do usn = sm.note_store.deleteNote sm.auth_token, @guid note = DBUtils.get_note dm, @guid note.updateSequenceNum = usn note.active = false DBUtils.set_note_and_content dm, note, nil shell.reply self, DeleteNoteReply.new end end end class CreateNotebookCommand < Command attr_accessor :name, :default_notebook def exec_impl Formatter.to_ascii @name notebook = Evernote::EDAM::Type::Notebook.new notebook.name = @name notebook.defaultNotebook = @default_notebook server_task do result_notebook = sm.note_store.createNotebook sm.auth_token, notebook DBUtils.set_notebook dm, result_notebook reply = CreateNotebookReply.new reply.notebook = result_notebook shell.reply self, reply end end end class UpdateNotebookCommand < Command attr_accessor :guid, :name, :default_notebook def exec_impl Formatter.to_ascii @name notebook = Evernote::EDAM::Type::Notebook.new notebook.guid = @guid notebook.name = @name notebook.defaultNotebook = @default_notebook server_task do usn = sm.note_store.updateNotebook sm.auth_token, notebook notebook.updateSequenceNum = usn DBUtils.set_notebook dm, notebook reply = UpdateNotebookReply.new reply.notebook = notebook shell.reply self, reply end end end class CreateTagCommand < Command attr_accessor :name, :parent_guid def exec_impl Formatter.to_ascii @name tag = Evernote::EDAM::Type::Tag.new tag.name = @name tag.parentGuid = @parent_guid server_task do result_tag = sm.note_store.createTag sm.auth_token, tag DBUtils.set_tag dm, result_tag reply = CreateTagReply.new reply.tag = result_tag shell.reply self, reply end end end class UpdateTagCommand < Command attr_accessor :guid, :name, :parent_guid def exec_impl Formatter.to_ascii @name tag = Evernote::EDAM::Type::Tag.new tag.guid = @guid tag.name = @name tag.parentGuid = @parent_guid server_task do usn = sm.note_store.updateTag sm.auth_token, tag tag.updateSequenceNum = usn DBUtils.set_tag dm, tag reply = UpdateTagReply.new shell.reply self, reply end end end class CreateSearchCommand < Command attr_accessor :name, :query def exec_impl Formatter.to_ascii @name search = Evernote::EDAM::Type::SavedSearch.new search.name = @name search.query = @query server_task do result_search = sm.note_store.createSearch sm.auth_token, search DBUtils.set_search dm, result_search reply = CreateSearchReply.new reply.search = result_search shell.reply self, reply end end end class UpdateSearchCommand < Command attr_accessor :guid, :name, :query def exec_impl Formatter.to_ascii @name, @query search = Evernote::EDAM::Type::SavedSearch.new search.guid = @guid search.name = @name search.query = @query server_task do usn = sm.note_store.updateSearch sm.auth_token, search search.updateSequenceNum = usn DBUtils.set_search dm, search reply = UpdateSearchReply.new shell.reply self, reply end end end class SearchNoteCommand < Command attr_accessor :query def exec_impl Formatter.to_ascii @query filter = Evernote::EDAM::NoteStore::NoteFilter.new filter.order = Evernote::EDAM::Type::NoteSortOrder::UPDATED filter.words = @query server_task do notelist = sm.note_store.findNotes sm.auth_token, filter, 0, Evernote::EDAM::Limits::EDAM_USER_NOTES_MAX DBUtils.sync_updated_notes dm, sm, tm, notelist.notes reply = SearchNoteReply.new reply.notes = notelist.notes shell.reply self, reply end end end class GetNoteCommand < Command attr_accessor :guid def exec_impl check_auth note = DBUtils.get_note dm, @guid if note && note.contentFile && (FileTest.readable? note.contentFile) reply = GetNoteReply.new reply.note = note shell.reply self, reply else server_task do note = sm.note_store.getNote sm.auth_token, @guid, true, false, false, false note.editMode = Formatter.get_edit_mode note.attributes.sourceApplication content = format_content note.content, note.editMode DBUtils.set_note_and_content dm, note, content reply = GetNoteReply.new reply.note = note shell.reply self, reply end end end private def format_content(content, edit_mode) result = nil content.gsub! %r{(?:\r\n)|\n|\r}, "\n" if edit_mode == "TEXT" content =~ %r|]*>(.*)|m content = $1 content.gsub! %r{}m, "\n" content.gsub! %r{ }m, " " result = CGI.unescapeHTML content else result = content end end end class ListNotebookCommand < Command @@issued_before = false def exec_impl check_auth if dm.during_full_sync? && !@@issued_before get_result_from_server else get_result_from_local_cache end end private def get_result_from_local_cache LOG.debug "return notebooks from cache" notebooks = DBUtils.get_all_notebooks dm notebooks.sort! do |a, b| a.name <=> b.name end reply = ListNotebookReply.new reply.notebooks = notebooks shell.reply self, reply end def get_result_from_server server_task do LOG.debug "return notebooks from server" notebooks = sm.note_store.listNotebooks sm.auth_token DBUtils.sync_updated_notebooks dm, notebooks reply = ListNotebookReply.new reply.notebooks = notebooks @@issued_before = true shell.reply self, reply end end end class ListNoteCommand < Command attr_accessor :tag_guids, :notebook_guid def initialize @tag_guids = [] end def exec_impl check_auth if dm.during_full_sync? get_result_from_server else get_result_from_local_cache end end private def get_result_from_local_cache LOG.debug "return notes from cache" notes = [] dm.transaction do dm.open_note do |db| db.each_value do |value| n = Evernote::EDAM::Type::Note.new n.deserialize value if @tag_guids == nil || (n.tagGuids != nil && (@tag_guids - n.tagGuids).empty?) if @notebook_guid == nil || @notebook_guid == n.notebookGuid notes << n end end end end end notes.sort! do |a, b| b.updated <=> a.updated end reply = ListNoteReply.new reply.notes = notes shell.reply self, reply end def get_result_from_server LOG.debug "return notes from server" server_task do filter = Evernote::EDAM::NoteStore::NoteFilter.new filter.order = Evernote::EDAM::Type::NoteSortOrder::UPDATED filter.tagGuids = @tag_guids filter.notebookGuid = @notebook_guid notelist = sm.note_store.findNotes(sm.auth_token, filter, 0, Evernote::EDAM::Limits::EDAM_USER_NOTES_MAX) DBUtils.sync_updated_notes dm, sm, tm, notelist.notes reply = ListNoteReply.new reply.notes = notelist.notes shell.reply self, reply end end end class ListTagCommand < Command @@issued_before = false def exec_impl check_auth if dm.during_full_sync? && !@@issued_before get_result_from_server else get_result_from_local_cache end end private def get_result_from_local_cache LOG.debug "return tags from cache" tags = DBUtils.get_all_tags dm tags.sort! do |a, b| a.name <=> b.name end reply = ListTagReply.new reply.tags = tags shell.reply self, reply end def get_result_from_server server_task do LOG.debug "return tags from server" tags = sm.note_store.listTags sm.auth_token DBUtils.sync_updated_tags dm, tags tags.sort! do |a, b| a.name <=> b.name end reply = ListTagReply.new reply.tags = tags @@issued_before = true shell.reply self, reply end end end class ListSearchCommand < Command @@issued_before = false def exec_impl check_auth if dm.during_full_sync? && !@@issued_before get_result_from_server else get_result_from_local_cache end end private def get_result_from_local_cache LOG.debug "return searches from cache" searches = DBUtils.get_all_searches dm searches.sort! do |a, b| a.name <=> b.name end reply = ListSearchReply.new reply.searches = searches shell.reply self, reply end def get_result_from_server server_task do LOG.debug "return searches from server" searches = sm.note_store.listSearches sm.auth_token DBUtils.sync_updated_searches dm, searches searches.sort! do |a, b| a.name <=> b.name end reply = ListSearchReply.new reply.searches = searches @@issued_before = true shell.reply self, reply end end end class Reply attr_accessor :command_id end class ErrorReply < Reply attr_accessor :result_code, :message end class AuthReply < Reply end class ListNotebookReply < Reply attr_accessor :notebooks end class ListNoteReply < Reply attr_accessor :notes end class ListTagReply < Reply attr_accessor :tags end class ListSearchReply < Reply attr_accessor :searches end class SearchNoteReply < Reply attr_accessor :notes end class GetNoteReply < Reply attr_accessor :note end class CreateNoteReply < Reply attr_accessor :note end class UpdateNoteReply < Reply attr_accessor :note end class DeleteNoteReply < Reply end class CreateNotebookReply < Reply attr_accessor :notebook end class UpdateNotebookReply < Reply attr_accessor :notebook end class CreateTagReply < Reply attr_accessor :tag end class UpdateTagReply < Reply end class CreateSearchReply < Reply attr_accessor :search end class UpdateSearchReply < Reply end class Task def initialize(&block) @proc = Proc.new end def exec @proc.call end end class SyncTask < Task MAX_SYNCED_ENTRY = 100 #MAX_SYNCED_ENTRY = 1 for test def initialize(sm, dm, tm) @sm = sm @dm = dm @tm = tm end def exec note_store = @sm.note_store sync_state = note_store.getSyncState @sm.auth_token LOG.info "[sync state begin]" LOG.info "currentTime = #{sync_state.currentTime}" LOG.info "fullSyncBefore = #{sync_state.fullSyncBefore}" LOG.info "updateCount = #{sync_state.updateCount}" LOG.info "[sync state end]" LOG.info "expiration = #{@sm.expiration}" @sm.refresh_authentication sync_state.currentTime last_sync, usn = DBUtils.get_last_sync_and_usn @dm LOG.info "[current state begin]" LOG.info "last_sync = #{last_sync}" LOG.info "USN = #{usn}" LOG.info "[current state end]" return if sync_state.updateCount == usn is_full_sync = false if last_sync < sync_state.fullSyncBefore @dm.transaction do @dm.clear_db end @dm.set_during_full_sync true LOG.debug "begin full sync" end if @dm.during_full_sync? is_full_sync = true end sync_chunk = note_store.getSyncChunk @sm.auth_token, usn, MAX_SYNCED_ENTRY, is_full_sync LOG.debug "sync (#{usn}-#{sync_chunk.chunkHighUSN}) full_sync = #{is_full_sync}" sync_db sync_chunk if sync_chunk.chunkHighUSN < sync_chunk.updateCount @tm.put SyncTask.new(@sm, @dm, @tm) else @dm.set_during_full_sync false LOG.debug "finish full sync" end rescue if $!.is_a? SystemCallError # workaround for corruption of note_store after timed out @sm.fix_note_store end message = ErrorUtils.get_message $! LOG.warn message LOG.warn $!.backtrace end private def sync_db(sync_chunk) DBUtils.sync_updated_notebooks @dm, sync_chunk.notebooks if sync_chunk.notebooks DBUtils.sync_updated_notes @dm, @sm, @tm, sync_chunk.notes if sync_chunk.notes DBUtils.sync_updated_tags @dm, sync_chunk.tags if sync_chunk.tags DBUtils.sync_updated_searches @dm, sync_chunk.searches if sync_chunk.searches DBUtils.sync_expunged_notebooks @dm, sync_chunk.expungedNotebooks if sync_chunk.expungedNotebooks DBUtils.sync_expunged_notes @dm, sync_chunk.expungedNotes, @tm if sync_chunk.expungedNotes DBUtils.sync_expunged_tags @dm, sync_chunk.expungedTags if sync_chunk.expungedTags DBUtils.sync_expunged_searches @dm, sync_chunk.expungedSearches if sync_chunk.expungedSearches DBUtils.set_last_sync_and_usn @dm, sync_chunk.currentTime, sync_chunk.chunkHighUSN end end class SessionManager REFRESH_LIMIT_SEC = 300 def initialize @auth_token = nil @shared_id = nil @note_store = nil @user_store = nil @expiration = nil end def auth_token raise NotAuthedException.new("Not authed") unless @auth_token @auth_token end def shared_id raise NotAuthedException.new("Not authed") unless @shared_id @shared_id end def note_store raise NotAuthedException.new("Not authed") unless @note_store @note_store end def user_store raise NotAuthedException.new("Not authed") unless @user_store @user_store end def expiration raise NotAuthedException.new("Not authed") unless @expiration @expiration end def authenticate(user, passwd) appname = "kawayuu" appid = "24b37bd1326624a0" @user_store = create_user_store auth_result = @user_store.authenticate user, passwd, appname, appid @auth_token, @shared_id, @expiration = get_session auth_result @note_store = create_note_store @shared_id end def refresh_authentication(current_time) if current_time > @expiration - REFRESH_LIMIT_SEC * 1000 LOG.info "refresh authentication" auth_result = @user_store.refreshAuthentication @auth_token @auth_token, dummy, @expiration = get_session auth_result @note_store = create_note_store @shared_id end end def fix_note_store if @shared_id @note_store = create_note_store @shared_id else @note_store = nil end end private def create_user_store proxy_host, proxy_port = get_proxy if proxy_host user_store_transport = HTTPWithProxyClientTransport.new USER_STORE_URL, proxy_host, proxy_port else user_store_transport = HTTPWithProxyClientTransport.new USER_STORE_URL end user_store_protocol = Thrift::BinaryProtocol.new user_store_transport user_store = Evernote::EDAM::UserStore::UserStore::Client.new user_store_protocol version_ok = user_store.checkVersion("Emacs Client", Evernote::EDAM::UserStore::EDAM_VERSION_MAJOR, Evernote::EDAM::UserStore::EDAM_VERSION_MINOR) unless version_ok raise IllegalStateException.new("UserStore version invalid") end user_store end def create_note_store(shared_id) note_store_url = NOTE_STORE_URL_BASE + shared_id proxy_host, proxy_port = get_proxy if proxy_host note_store_transport = HTTPWithProxyClientTransport.new note_store_url, proxy_host, proxy_port else note_store_transport = HTTPWithProxyClientTransport.new note_store_url end note_store_protocol = Thrift::BinaryProtocol.new note_store_transport Evernote::EDAM::NoteStore::NoteStore::Client.new note_store_protocol end def get_session(auth_result) auth_token = auth_result.authenticationToken shared_id = auth_result.user.shardId if auth_result.user expiration = auth_result.expiration [auth_token, shared_id, expiration] end def get_proxy proxy_str = ENV["EN_PROXY"] if proxy_str proxy_str =~ /((?:\w|\.)+):([0-9]+)/ [$1, $2] else nil end end end class DBManager ENMODE_SYS_DIR = File.expand_path("~/.evernote-mode") + "/" DB_LOCK = ENMODE_SYS_DIR + "lock" DB_SYNC = ENMODE_SYS_DIR + "sync" DB_NOTEBOOK = ENMODE_SYS_DIR + "notebook" DB_NOTE = ENMODE_SYS_DIR + "note" DB_TAG = ENMODE_SYS_DIR + "tag" DB_SAVED_SEARCH = ENMODE_SYS_DIR + "saved_search" CONTENT_DIR = ENMODE_SYS_DIR + "contents/" DB_SYNC_LAST_SYNC_FIELD = 'last_sync' DB_SYNC_USN_FIELD = 'usn' def initialize unless FileTest.directory? ENMODE_SYS_DIR FileUtils.mkdir ENMODE_SYS_DIR end unless FileTest.directory? CONTENT_DIR FileUtils.mkdir CONTENT_DIR end @lock_file = open DB_LOCK, 'w' @mutex = Mutex.new @in_transaction = false @is_during_full_sync = false end def transaction @mutex.lock @lock_file.flock File::LOCK_EX @in_transaction = true yield ensure @in_transaction = false @lock_file.flock File::LOCK_UN @mutex.unlock end def clear_db raise IllegalStateException.new("not in transaction") unless @in_transaction [DB_SYNC, DB_NOTEBOOK, DB_NOTE, DB_TAG, DB_SAVED_SEARCH].each do |file| GDBM.open file do |db| db.clear end end end def open_sync(&block) raise IllegalStateException.new("not in transaction") unless @in_transaction GDBM.open DB_SYNC, &block end def open_notebook(&block) raise IllegalStateException.new("not in transaction") unless @in_transaction GDBM.open DB_NOTEBOOK, &block end def open_note(&block) raise IllegalStateException.new("not in transaction") unless @in_transaction GDBM.open DB_NOTE, &block end def open_tag(&block) raise IllegalStateException.new("not in transaction") unless @in_transaction GDBM.open DB_TAG, &block end def open_search(&block) raise IllegalStateException.new("not in transaction") unless @in_transaction GDBM.open DB_SAVED_SEARCH, &block end # note content def set_note_content(guid, content) raise IllegalStateException.new("not in transaction") unless @in_transaction file_path = CONTENT_DIR + guid open file_path, "w" do |file| # "w" for transform eols to the native ones file.write content end LOG.info "update content at #{file_path}" file_path end def remove_note_content(guid) raise IllegalStateException.new("not in transaction") unless @in_transaction file_path = CONTENT_DIR + guid LOG.info "try to expunge content at #{file_path}" FileUtils.rm file_path if FileTest.file? file_path LOG.info "expunge content at #{file_path}" end def during_full_sync? result = nil @mutex.synchronize do result = @is_during_full_sync end result end def set_during_full_sync(state) LOG.debug "during full sync: #{state}" @mutex.synchronize do @is_during_full_sync = state end end end class DBUtils def self.get_last_sync_and_usn(dm) last_sync, usn = nil, nil dm.transaction do dm.open_sync do |db| last_sync, usn = db[DBManager::DB_SYNC_LAST_SYNC_FIELD], db[DBManager::DB_SYNC_USN_FIELD] end end if last_sync last_sync = last_sync.to_i else last_sync = 0 end if usn usn = usn.to_i else usn = 0 end [last_sync, usn] end def self.set_last_sync_and_usn(dm, last_sync, usn) dm.transaction do dm.open_sync do |db| db[DBManager::DB_SYNC_LAST_SYNC_FIELD] = last_sync.to_s db[DBManager::DB_SYNC_USN_FIELD] = usn.to_s end end end def self.get_all_notebooks(dm) notebooks = [] dm.transaction do dm.open_notebook do |db| db.each_value do |value| nb = Evernote::EDAM::Type::Notebook.new nb.deserialize value notebooks << nb end end end notebooks end def self.get_note(dm, guid) note = Evernote::EDAM::Type::Note.new dm.transaction do dm.open_note do |db| if db.has_key? guid note.deserialize db[guid] else raise NotFoundException.new("Note guid #{guid} is not found") end end end note end def self.set_note_and_content(dm, note, content) dm.transaction do dm.open_note do |db| note.contentFile = dm.set_note_content note.guid, content if content db[note.guid] = note.serialize end end end def self.get_all_tags(dm) tags = [] dm.transaction do dm.open_tag do |db| db.each_value do |value| t = Evernote::EDAM::Type::Tag.new t.deserialize value tags << t end end end tags end def self.exist_tag_in_cache?(dm, guid) dm.transaction do dm.open_tag do |db| if db.has_key? guid return true end end end return false end def self.set_tag(dm, tag) dm.transaction do dm.open_tag do |db| db[tag.guid] = tag.serialize end end end def self.get_all_searches(dm) searches = [] dm.transaction do dm.open_search do |db| db.each_value do |value| s = Evernote::EDAM::Type::SavedSearch.new s.deserialize value searches << s end end end searches end def self.set_search(dm, search) dm.transaction do dm.open_search do |db| db[search.guid] = search.serialize end end end def self.set_notebook(dm, notebook) dm.transaction do dm.open_notebook do |db| if notebook.defaultNotebook # unset defaultNotebook of all notebooks db.each_value do |value| n = Evernote::EDAM::Type::Notebook.new n.deserialize value if n.guid != notebook.guid n.defaultNotebook = false db[n.guid] = n.serialize end end end db[notebook.guid] = notebook.serialize end end end def self.sync_updated_notebooks(dm, notebooks) dm.transaction do dm.open_notebook do |db| notebooks.each do |new_notebook| if db.has_key? new_notebook.guid current_notebook = Evernote::EDAM::Type::Notebook.new current_notebook.deserialize db[new_notebook.guid] if current_notebook.updateSequenceNum < new_notebook.updateSequenceNum db[new_notebook.guid] = new_notebook.serialize end else db[new_notebook.guid] = new_notebook.serialize end end end end end def self.sync_updated_notes(dm, sm, tm, notes) dm.transaction do dm.open_note do |db| notes.each do |new_note| # this method set editMode. new_note.editMode = Formatter.get_edit_mode new_note.attributes.sourceApplication if db.has_key? new_note.guid current_note = Evernote::EDAM::Type::Note.new current_note.deserialize db[new_note.guid] if current_note.updateSequenceNum < new_note.updateSequenceNum dm.remove_note_content new_note.guid # remove content cache if updated db[new_note.guid] = new_note.serialize # update note info end else db[new_note.guid] = new_note.serialize end end end end end def self.sync_updated_tags(dm, tags) dm.transaction do dm.open_tag do |db| tags.each do |new_tag| if db.has_key? new_tag.guid current_tag = Evernote::EDAM::Type::Tag.new current_tag.deserialize db[new_tag.guid] if current_tag.updateSequenceNum < new_tag.updateSequenceNum db[new_tag.guid] = new_tag.serialize end else db[new_tag.guid] = new_tag.serialize end end end end end def self.sync_updated_searches(dm, searches) dm.transaction do dm.open_search do |db| searches.each do |new_search| if db.has_key? new_search.guid current_search = Evernote::EDAM::Type::SavedSearch.new current_search.deserialize db[new_search.guid] if current_search.updateSequenceNum < new_search.updateSequenceNum db[new_search.guid] = new_search.serialize end else db[new_search.guid] = new_search.serialize end end end end end def self.sync_expunged_notebooks(dm, guids) dm.transaction do dm.open_notebook do |db| guids.each do |guid| db.delete guid end end end end def self.sync_expunged_notes(dm, guids, tm = nil) dm.transaction do dm.open_note do |db| guids.each do |guid| dm.remove_note_content guid # remove content cache if updated db.delete guid end end end end def self.sync_expunged_tags(dm, guids) dm.transaction do dm.open_tag do |db| guids.each do |guid| db.delete guid end end end end def self.sync_expunged_searches(dm, guids) dm.transaction do dm.open_search do |db| guids.each do |guid| db.delete guid end end end end end class TaskManager def initialize @task_queue = TaskQueue.new end def put(task, high_prio = false) if high_prio @task_queue.push_to_front task else @task_queue.push task end end def run Thread.start do LOG.debug "start task manager" while true task = @task_queue.pop LOG.debug "exec #{task}" begin task.exec rescue Exception message = ErrorUtils.get_message $! LOG.error message LOG.error $!.backtrace end end end end end class Timer def self.repeat_every(interval) while true spent_time = time_block { yield } sleep(interval - spent_time) if spent_time < interval end end private def self.time_block start_time = Time.now yield Time.now - start_time end end class Formatter def self.get_edit_mode(src_app) result = "XHTML" if src_app != nil src_app = src_app.strip if src_app =~ /\Aemacs-enclient\s*\{.*:editmode\s*=>\s*"(.*)"[^\}]*\}\z/ result = $1 unless result == "TEXT" || result == "XHTML" result = "TEXT" end end end result end def self.encode_base64(str) b64str = Base64.encode64 str b64str.delete "\n\r" end def self.encode_base64_list(str_list) str_list.map do |elem| encode_base64 elem end end def self.decode_base64(b64str) Base64.decode64 b64str end def self.decode_base64_list(b64list) b64list.map do |elem| decode_base64 elem end end def self.obj_to_sexp(obj) case obj when Integer return "#{obj}" when TrueClass return "t" when FalseClass, NilClass return "nil" when String return %|"#{obj}"| # must be base64ed when Time return %|"#{obj}"| when Array str = "(" obj.each do |elem| str += obj_to_sexp elem str += " " end str += ")" when Serializable obj.to_sexp else str = "(" class_name = Formatter.remove_package_names obj.class.name str += "(class . #{class_name})" obj.instance_variables.each do |varsym| varname = varsym.to_s[1 .. -1] # remove "@" str += "(#{varname} . #{obj_to_sexp obj.instance_variable_get(varsym)})" end str += ")" end end def self.sexp_string_escape(str) str.gsub(/\\/,'\&\&').gsub(/"/, '\\"') end def self.remove_package_names(full_class_name) full_class_name.split("::")[-1] end IS_FORCE_ENCODING_SUPPORTED = "".respond_to? :force_encoding def self.to_ascii(*rest) if IS_FORCE_ENCODING_SUPPORTED rest.each do |elem| elem.force_encoding Encoding::ASCII_8BIT if elem end end end end class ErrorUtils # from here, rename the appropriate name. def self.set_reply_error(ex, reply) case ex when Evernote::EDAM::Error::EDAMUserException errorText = Evernote::EDAM::Error::EDAMErrorCode::VALUE_MAP[ex.errorCode] reply.result_code = ex.errorCode reply.message = "#{ex.class.name} (parameter: #{ex.parameter} errorCode: #{errorText})" when Evernote::EDAM::Error::EDAMSystemException errorText = Evernote::EDAM::Error::EDAMErrorCode::VALUE_MAP[ex.errorCode] reply.result_code = ex.errorCode reply.message = "#{ex.class.name} (message: #{ex.message} errorCode: #{errorText})" when Evernote::EDAM::Error::EDAMNotFoundException reply.result_code = ERROR_CODE_NOT_FOUND reply.message = "#{ex.class.name} (identifier: #{ex.identifier} key: #{ex.key})" when NotAuthedException reply.result_code = ERROR_CODE_NOT_AUTHED reply.message = "Not authenticated" else reply.result_code = ERROR_CODE_UNEXPECTED reply.message = ex.message end reply.message = Formatter.sexp_string_escape reply.message end def self.get_message(ex) case ex when Evernote::EDAM::Error::EDAMUserException errorText = Evernote::EDAM::Error::EDAMErrorCode::VALUE_MAP[ex.errorCode] "#{ex.class.name} (parameter: #{ex.parameter} errorCode: #{errorText})" when Evernote::EDAM::Error::EDAMSystemException errorText = Evernote::EDAM::Error::EDAMErrorCode::VALUE_MAP[ex.errorCode] "#{ex.class.name} (message: #{ex.message} errorCode: #{errorText})" when Evernote::EDAM::Error::EDAMNotFoundException "#{ex.class.name} (identifier: #{ex.identifier} key: #{ex.key})" when Errno::ETIMEDOUT "Connection timed out" else ex.message end end end class Shell AUTO_SYNC_INTERVAL = 60 def run sm = SessionManager.new dm = DBManager.new tm = TaskManager.new tm.run Thread.start do Timer.repeat_every AUTO_SYNC_INTERVAL do tm.put SyncTask.new(sm, dm, tm) end end begin #if $stdin.respond_to? :set_encoding # LOG.debug "get stdin encoding #{$stdin.external_encoding}, #{$stdin.internal_encoding}" # $stdin.set_encoding "UTF-8", "UTF-8" # $stdout.set_encoding "UTF-8", "UTF-8" # LOG.debug "get stdin encoding #{$stdin.external_encoding}, #{$stdin.internal_encoding}" #end while true begin line = $stdin.gets "\000" hash = eval line LOG.debug "<#{hash[:class]}>" command = Command.create_from_hash hash command.sm = sm command.dm = dm command.tm = tm command.shell = self command.exec rescue SyntaxError LOG.error $!.backtrace rescue LOG.error $!.backtrace end end rescue Interrupt LOG.debug "Interrupted" end end def reply(command, reply) reply.command_id = command.command_id $stdout.write Formatter.obj_to_sexp(reply) $stdout.flush end end end # module EnClient if __FILE__ == $0 EnClient::Shell.new.run end evernote-mode-0_41/ruby/lib/0000775000175000017500000000000011601107152015647 5ustar uwabamiuwabamievernote-mode-0_41/ruby/lib/thrift.rb0000664000175000017500000000427311513076422017511 0ustar uwabamiuwabami# # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. # # Contains some contributions under the Thrift Software License. # Please see doc/old-thrift-license.txt in the Thrift distribution for # details. $:.unshift File.dirname(__FILE__) require 'thrift/core_ext' require 'thrift/exceptions' require 'thrift/types' require 'thrift/processor' require 'thrift/client' require 'thrift/struct' require 'thrift/union' require 'thrift/struct_union' # serializer require 'thrift/serializer/serializer' require 'thrift/serializer/deserializer' # protocol require 'thrift/protocol/base_protocol' require 'thrift/protocol/binary_protocol' require 'thrift/protocol/binary_protocol_accelerated' require 'thrift/protocol/compact_protocol' # transport require 'thrift/transport/base_transport' require 'thrift/transport/base_server_transport' require 'thrift/transport/socket' require 'thrift/transport/server_socket' require 'thrift/transport/unix_socket' require 'thrift/transport/unix_server_socket' require 'thrift/transport/buffered_transport' require 'thrift/transport/framed_transport' require 'thrift/transport/http_client_transport' require 'thrift/transport/io_stream_transport' require 'thrift/transport/memory_buffer_transport' # server require 'thrift/server/base_server' require 'thrift/server/nonblocking_server' require 'thrift/server/simple_server' require 'thrift/server/threaded_server' require 'thrift/server/thread_pool_server' require 'thrift/thrift_native' require 'thrift/struct_union' evernote-mode-0_41/ruby/lib/LICENSE.txt0000664000175000017500000000265711513076422017513 0ustar uwabamiuwabami/* * Copyright (c) 2007-2009 by Evernote Corporation, All rights reserved. * * Use of the source code and binary libraries included in this package * is permitted under the following terms: * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ evernote-mode-0_41/ruby/lib/Evernote/0000775000175000017500000000000011601107152017436 5ustar uwabamiuwabamievernote-mode-0_41/ruby/lib/Evernote/EDAM/0000775000175000017500000000000011601107152020144 5ustar uwabamiuwabamievernote-mode-0_41/ruby/lib/Evernote/EDAM/limits_constants.rb0000664000175000017500000001241611513076422024101 0ustar uwabamiuwabami# # Autogenerated by Thrift # # DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING # require 'Evernote/EDAM/limits_types' module Evernote module EDAM module Limits EDAM_ATTRIBUTE_LEN_MIN = 1 EDAM_ATTRIBUTE_LEN_MAX = 4096 EDAM_ATTRIBUTE_REGEX = %q"^[^\\p{Cc}\\p{Zl}\\p{Zp}]{1,4096}$" EDAM_ATTRIBUTE_LIST_MAX = 100 EDAM_GUID_LEN_MIN = 36 EDAM_GUID_LEN_MAX = 36 EDAM_GUID_REGEX = %q"^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$" EDAM_EMAIL_LEN_MIN = 6 EDAM_EMAIL_LEN_MAX = 255 EDAM_EMAIL_LOCAL_REGEX = %q"^[A-Za-z0-9!#$%&'*+/=?^_`{|}~-]+(\\.[A-Za-z0-9!#$%&'*+/=?^_`{|}~-]+)*$" EDAM_EMAIL_DOMAIN_REGEX = %q"^[A-Za-z0-9-]+(\\.[A-Za-z0-9-]+)*\\.([A-Za-z]{2,})$" EDAM_EMAIL_REGEX = %q"^[A-Za-z0-9!#$%&'*+/=?^_`{|}~-]+(\\.[A-Za-z0-9!#$%&'*+/=?^_`{|}~-]+)*@[A-Za-z0-9-]+(\\.[A-Za-z0-9-]+)*\\.([A-Za-z]{2,})$" EDAM_TIMEZONE_LEN_MIN = 1 EDAM_TIMEZONE_LEN_MAX = 32 EDAM_TIMEZONE_REGEX = %q"^([A-Za-z_-]+(/[A-Za-z_-]+)*)|(GMT(-|\\+)[0-9]{1,2}(:[0-9]{2})?)$" EDAM_MIME_LEN_MIN = 3 EDAM_MIME_LEN_MAX = 255 EDAM_MIME_REGEX = %q"^[A-Za-z]+/[A-Za-z0-9._+-]+$" EDAM_MIME_TYPE_GIF = %q"image/gif" EDAM_MIME_TYPE_JPEG = %q"image/jpeg" EDAM_MIME_TYPE_PNG = %q"image/png" EDAM_MIME_TYPE_WAV = %q"audio/wav" EDAM_MIME_TYPE_MP3 = %q"audio/mpeg" EDAM_MIME_TYPE_AMR = %q"audio/amr" EDAM_MIME_TYPE_INK = %q"application/vnd.evernote.ink" EDAM_MIME_TYPE_PDF = %q"application/pdf" EDAM_MIME_TYPE_DEFAULT = %q"application/octet-stream" EDAM_MIME_TYPES = Set.new([ %q"image/gif", %q"image/jpeg", %q"image/png", %q"audio/wav", %q"audio/mpeg", %q"audio/amr", %q"application/vnd.evernote.ink", %q"application/pdf", ]) EDAM_COMMERCE_SERVICE_GOOGLE = %q"Google" EDAM_COMMERCE_SERVICE_PAYPAL = %q"Paypal" EDAM_COMMERCE_SERVICE_GIFT = %q"Gift" EDAM_COMMERCE_SERVICE_TRIALPAY = %q"TrialPay" EDAM_SEARCH_QUERY_LEN_MIN = 0 EDAM_SEARCH_QUERY_LEN_MAX = 1024 EDAM_SEARCH_QUERY_REGEX = %q"^[^\\p{Cc}\\p{Zl}\\p{Zp}]{0,1024}$" EDAM_HASH_LEN = 16 EDAM_USER_USERNAME_LEN_MIN = 1 EDAM_USER_USERNAME_LEN_MAX = 64 EDAM_USER_USERNAME_REGEX = %q"^[a-z0-9]([a-z0-9_-]{0,62}[a-z0-9])?$" EDAM_USER_NAME_LEN_MIN = 1 EDAM_USER_NAME_LEN_MAX = 255 EDAM_USER_NAME_REGEX = %q"^[^\\p{Cc}\\p{Zl}\\p{Zp}]{1,255}$" EDAM_TAG_NAME_LEN_MIN = 1 EDAM_TAG_NAME_LEN_MAX = 100 EDAM_TAG_NAME_REGEX = %q"^[^,\\p{Cc}\\p{Z}]([^,\\p{Cc}\\p{Zl}\\p{Zp}]{0,98}[^,\\p{Cc}\\p{Z}])?$" EDAM_NOTE_TITLE_LEN_MIN = 1 EDAM_NOTE_TITLE_LEN_MAX = 255 EDAM_NOTE_TITLE_REGEX = %q"^[^\\p{Cc}\\p{Z}]([^\\p{Cc}\\p{Zl}\\p{Zp}]{0,253}[^\\p{Cc}\\p{Z}])?$" EDAM_NOTE_CONTENT_LEN_MIN = 0 EDAM_NOTE_CONTENT_LEN_MAX = 5242880 EDAM_NOTEBOOK_NAME_LEN_MIN = 1 EDAM_NOTEBOOK_NAME_LEN_MAX = 100 EDAM_NOTEBOOK_NAME_REGEX = %q"^[^\\p{Cc}\\p{Z}]([^\\p{Cc}\\p{Zl}\\p{Zp}]{0,98}[^\\p{Cc}\\p{Z}])?$" EDAM_NOTEBOOK_STACK_LEN_MIN = 1 EDAM_NOTEBOOK_STACK_LEN_MAX = 100 EDAM_NOTEBOOK_STACK_REGEX = %q"^[^\\p{Cc}\\p{Z}]([^\\p{Cc}\\p{Zl}\\p{Zp}]{0,98}[^\\p{Cc}\\p{Z}])?$" EDAM_PUBLISHING_URI_LEN_MIN = 1 EDAM_PUBLISHING_URI_LEN_MAX = 255 EDAM_PUBLISHING_URI_REGEX = %q"^[a-zA-Z0-9.~_+-]{1,255}$" EDAM_PUBLISHING_URI_PROHIBITED = Set.new([ %q"..", ]) EDAM_PUBLISHING_DESCRIPTION_LEN_MIN = 1 EDAM_PUBLISHING_DESCRIPTION_LEN_MAX = 200 EDAM_PUBLISHING_DESCRIPTION_REGEX = %q"^[^\\p{Cc}\\p{Z}]([^\\p{Cc}\\p{Zl}\\p{Zp}]{0,198}[^\\p{Cc}\\p{Z}])?$" EDAM_SAVED_SEARCH_NAME_LEN_MIN = 1 EDAM_SAVED_SEARCH_NAME_LEN_MAX = 100 EDAM_SAVED_SEARCH_NAME_REGEX = %q"^[^\\p{Cc}\\p{Z}]([^\\p{Cc}\\p{Zl}\\p{Zp}]{0,98}[^\\p{Cc}\\p{Z}])?$" EDAM_USER_PASSWORD_LEN_MIN = 6 EDAM_USER_PASSWORD_LEN_MAX = 64 EDAM_USER_PASSWORD_REGEX = %q"^[A-Za-z0-9!#$%&'()*+,./:;<=>?@^_`{|}~\\[\\]\\\\-]{6,64}$" EDAM_NOTE_TAGS_MAX = 100 EDAM_NOTE_RESOURCES_MAX = 1000 EDAM_USER_TAGS_MAX = 100000 EDAM_USER_SAVED_SEARCHES_MAX = 100 EDAM_USER_NOTES_MAX = 100000 EDAM_USER_NOTEBOOKS_MAX = 100 EDAM_USER_RECENT_MAILED_ADDRESSES_MAX = 10 EDAM_USER_MAIL_LIMIT_DAILY_FREE = 50 EDAM_USER_MAIL_LIMIT_DAILY_PREMIUM = 200 EDAM_NOTE_SIZE_MAX_FREE = 26214400 EDAM_NOTE_SIZE_MAX_PREMIUM = 52428800 EDAM_RESOURCE_SIZE_MAX_FREE = 26214400 EDAM_RESOURCE_SIZE_MAX_PREMIUM = 52428800 EDAM_USER_LINKED_NOTEBOOK_MAX = 100 EDAM_NOTEBOOK_SHARED_NOTEBOOK_MAX = 100 end end end evernote-mode-0_41/ruby/lib/Evernote/EDAM/user_store_constants.rb0000664000175000017500000000045611513076422024773 0ustar uwabamiuwabami# # Autogenerated by Thrift # # DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING # require 'Evernote/EDAM/user_store_types' module Evernote module EDAM module UserStore EDAM_VERSION_MAJOR = 1 EDAM_VERSION_MINOR = 16 end end end evernote-mode-0_41/ruby/lib/Evernote/EDAM/errors_types.rb0000664000175000017500000001327111513076422023244 0ustar uwabamiuwabami# # Autogenerated by Thrift # # DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING # module Evernote module EDAM module Error module EDAMErrorCode UNKNOWN = 1 BAD_DATA_FORMAT = 2 PERMISSION_DENIED = 3 INTERNAL_ERROR = 4 DATA_REQUIRED = 5 LIMIT_REACHED = 6 QUOTA_REACHED = 7 INVALID_AUTH = 8 AUTH_EXPIRED = 9 DATA_CONFLICT = 10 ENML_VALIDATION = 11 SHARD_UNAVAILABLE = 12 VALUE_MAP = {1 => "UNKNOWN", 2 => "BAD_DATA_FORMAT", 3 => "PERMISSION_DENIED", 4 => "INTERNAL_ERROR", 5 => "DATA_REQUIRED", 6 => "LIMIT_REACHED", 7 => "QUOTA_REACHED", 8 => "INVALID_AUTH", 9 => "AUTH_EXPIRED", 10 => "DATA_CONFLICT", 11 => "ENML_VALIDATION", 12 => "SHARD_UNAVAILABLE"} VALID_VALUES = Set.new([UNKNOWN, BAD_DATA_FORMAT, PERMISSION_DENIED, INTERNAL_ERROR, DATA_REQUIRED, LIMIT_REACHED, QUOTA_REACHED, INVALID_AUTH, AUTH_EXPIRED, DATA_CONFLICT, ENML_VALIDATION, SHARD_UNAVAILABLE]).freeze end # This exception is thrown by EDAM procedures when a call fails as a result of # a problem that a user may be able to resolve. For example, if the user # attempts to add a note to their account which would exceed their storage # quota, this type of exception may be thrown to indicate the source of the # error so that they can choose an alternate action. # # This exception would not be used for internal system errors that do not # reflect user actions, but rather reflect a problem within the service that # the user cannot resolve. # # errorCode: The numeric code indicating the type of error that occurred. # must be one of the values of EDAMErrorCode. # # parameter: If the error applied to a particular input parameter, this will # indicate which parameter. class EDAMUserException < ::Thrift::Exception include ::Thrift::Struct, ::Thrift::Struct_Union ERRORCODE = 1 PARAMETER = 2 FIELDS = { ERRORCODE => {:type => ::Thrift::Types::I32, :name => 'errorCode', :enum_class => Evernote::EDAM::Error::EDAMErrorCode}, PARAMETER => {:type => ::Thrift::Types::STRING, :name => 'parameter', :optional => true} } def struct_fields; FIELDS; end def validate raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field errorCode is unset!') unless @errorCode unless @errorCode.nil? || Evernote::EDAM::Error::EDAMErrorCode::VALID_VALUES.include?(@errorCode) raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Invalid value of field errorCode!') end end ::Thrift::Struct.generate_accessors self end # This exception is thrown by EDAM procedures when a call fails as a result of # an a problem in the service that could not be changed through user action. # # errorCode: The numeric code indicating the type of error that occurred. # must be one of the values of EDAMErrorCode. # # message: This may contain additional information about the error class EDAMSystemException < ::Thrift::Exception include ::Thrift::Struct, ::Thrift::Struct_Union ERRORCODE = 1 MESSAGE = 2 FIELDS = { ERRORCODE => {:type => ::Thrift::Types::I32, :name => 'errorCode', :enum_class => Evernote::EDAM::Error::EDAMErrorCode}, MESSAGE => {:type => ::Thrift::Types::STRING, :name => 'message', :optional => true} } def struct_fields; FIELDS; end def validate raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field errorCode is unset!') unless @errorCode unless @errorCode.nil? || Evernote::EDAM::Error::EDAMErrorCode::VALID_VALUES.include?(@errorCode) raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Invalid value of field errorCode!') end end ::Thrift::Struct.generate_accessors self end # This exception is thrown by EDAM procedures when a caller asks to perform # an operation that does not exist. This may be thrown based on an invalid # primary identifier (e.g. a bad GUID), or when the caller refers to an object # by another unique identifier (e.g. a User's email address). # # identifier: the object identifier that was not found on the server. # # key: the value passed from the client in the identifier, which was not # found. E.g. the GUID of an object that was not found. class EDAMNotFoundException < ::Thrift::Exception include ::Thrift::Struct, ::Thrift::Struct_Union IDENTIFIER = 1 KEY = 2 FIELDS = { IDENTIFIER => {:type => ::Thrift::Types::STRING, :name => 'identifier', :optional => true}, KEY => {:type => ::Thrift::Types::STRING, :name => 'key', :optional => true} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end end end end evernote-mode-0_41/ruby/lib/Evernote/EDAM/errors_constants.rb0000664000175000017500000000033511513076422024111 0ustar uwabamiuwabami# # Autogenerated by Thrift # # DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING # require 'Evernote/EDAM/errors_types' module Evernote module EDAM module Error end end end evernote-mode-0_41/ruby/lib/Evernote/EDAM/note_store.rb0000664000175000017500000064442711513076422022702 0ustar uwabamiuwabami# # Autogenerated by Thrift # # DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING # require 'thrift' require 'Evernote/EDAM/note_store_types' module Evernote module EDAM module NoteStore module NoteStore class Client include ::Thrift::Client def getSyncState(authenticationToken) send_getSyncState(authenticationToken) return recv_getSyncState() end def send_getSyncState(authenticationToken) send_message('getSyncState', GetSyncState_args, :authenticationToken => authenticationToken) end def recv_getSyncState() result = receive_message(GetSyncState_result) return result.success unless result.success.nil? raise result.userException unless result.userException.nil? raise result.systemException unless result.systemException.nil? raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'getSyncState failed: unknown result') end def getSyncChunk(authenticationToken, afterUSN, maxEntries, fullSyncOnly) send_getSyncChunk(authenticationToken, afterUSN, maxEntries, fullSyncOnly) return recv_getSyncChunk() end def send_getSyncChunk(authenticationToken, afterUSN, maxEntries, fullSyncOnly) send_message('getSyncChunk', GetSyncChunk_args, :authenticationToken => authenticationToken, :afterUSN => afterUSN, :maxEntries => maxEntries, :fullSyncOnly => fullSyncOnly) end def recv_getSyncChunk() result = receive_message(GetSyncChunk_result) return result.success unless result.success.nil? raise result.userException unless result.userException.nil? raise result.systemException unless result.systemException.nil? raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'getSyncChunk failed: unknown result') end def listNotebooks(authenticationToken) send_listNotebooks(authenticationToken) return recv_listNotebooks() end def send_listNotebooks(authenticationToken) send_message('listNotebooks', ListNotebooks_args, :authenticationToken => authenticationToken) end def recv_listNotebooks() result = receive_message(ListNotebooks_result) return result.success unless result.success.nil? raise result.userException unless result.userException.nil? raise result.systemException unless result.systemException.nil? raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'listNotebooks failed: unknown result') end def getNotebook(authenticationToken, guid) send_getNotebook(authenticationToken, guid) return recv_getNotebook() end def send_getNotebook(authenticationToken, guid) send_message('getNotebook', GetNotebook_args, :authenticationToken => authenticationToken, :guid => guid) end def recv_getNotebook() result = receive_message(GetNotebook_result) return result.success unless result.success.nil? raise result.userException unless result.userException.nil? raise result.systemException unless result.systemException.nil? raise result.notFoundException unless result.notFoundException.nil? raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'getNotebook failed: unknown result') end def getDefaultNotebook(authenticationToken) send_getDefaultNotebook(authenticationToken) return recv_getDefaultNotebook() end def send_getDefaultNotebook(authenticationToken) send_message('getDefaultNotebook', GetDefaultNotebook_args, :authenticationToken => authenticationToken) end def recv_getDefaultNotebook() result = receive_message(GetDefaultNotebook_result) return result.success unless result.success.nil? raise result.userException unless result.userException.nil? raise result.systemException unless result.systemException.nil? raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'getDefaultNotebook failed: unknown result') end def createNotebook(authenticationToken, notebook) send_createNotebook(authenticationToken, notebook) return recv_createNotebook() end def send_createNotebook(authenticationToken, notebook) send_message('createNotebook', CreateNotebook_args, :authenticationToken => authenticationToken, :notebook => notebook) end def recv_createNotebook() result = receive_message(CreateNotebook_result) return result.success unless result.success.nil? raise result.userException unless result.userException.nil? raise result.systemException unless result.systemException.nil? raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'createNotebook failed: unknown result') end def updateNotebook(authenticationToken, notebook) send_updateNotebook(authenticationToken, notebook) return recv_updateNotebook() end def send_updateNotebook(authenticationToken, notebook) send_message('updateNotebook', UpdateNotebook_args, :authenticationToken => authenticationToken, :notebook => notebook) end def recv_updateNotebook() result = receive_message(UpdateNotebook_result) return result.success unless result.success.nil? raise result.userException unless result.userException.nil? raise result.systemException unless result.systemException.nil? raise result.notFoundException unless result.notFoundException.nil? raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'updateNotebook failed: unknown result') end def expungeNotebook(authenticationToken, guid) send_expungeNotebook(authenticationToken, guid) return recv_expungeNotebook() end def send_expungeNotebook(authenticationToken, guid) send_message('expungeNotebook', ExpungeNotebook_args, :authenticationToken => authenticationToken, :guid => guid) end def recv_expungeNotebook() result = receive_message(ExpungeNotebook_result) return result.success unless result.success.nil? raise result.userException unless result.userException.nil? raise result.systemException unless result.systemException.nil? raise result.notFoundException unless result.notFoundException.nil? raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'expungeNotebook failed: unknown result') end def listTags(authenticationToken) send_listTags(authenticationToken) return recv_listTags() end def send_listTags(authenticationToken) send_message('listTags', ListTags_args, :authenticationToken => authenticationToken) end def recv_listTags() result = receive_message(ListTags_result) return result.success unless result.success.nil? raise result.userException unless result.userException.nil? raise result.systemException unless result.systemException.nil? raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'listTags failed: unknown result') end def listTagsByNotebook(authenticationToken, notebookGuid) send_listTagsByNotebook(authenticationToken, notebookGuid) return recv_listTagsByNotebook() end def send_listTagsByNotebook(authenticationToken, notebookGuid) send_message('listTagsByNotebook', ListTagsByNotebook_args, :authenticationToken => authenticationToken, :notebookGuid => notebookGuid) end def recv_listTagsByNotebook() result = receive_message(ListTagsByNotebook_result) return result.success unless result.success.nil? raise result.userException unless result.userException.nil? raise result.systemException unless result.systemException.nil? raise result.notFoundException unless result.notFoundException.nil? raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'listTagsByNotebook failed: unknown result') end def getTag(authenticationToken, guid) send_getTag(authenticationToken, guid) return recv_getTag() end def send_getTag(authenticationToken, guid) send_message('getTag', GetTag_args, :authenticationToken => authenticationToken, :guid => guid) end def recv_getTag() result = receive_message(GetTag_result) return result.success unless result.success.nil? raise result.userException unless result.userException.nil? raise result.systemException unless result.systemException.nil? raise result.notFoundException unless result.notFoundException.nil? raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'getTag failed: unknown result') end def createTag(authenticationToken, tag) send_createTag(authenticationToken, tag) return recv_createTag() end def send_createTag(authenticationToken, tag) send_message('createTag', CreateTag_args, :authenticationToken => authenticationToken, :tag => tag) end def recv_createTag() result = receive_message(CreateTag_result) return result.success unless result.success.nil? raise result.userException unless result.userException.nil? raise result.systemException unless result.systemException.nil? raise result.notFoundException unless result.notFoundException.nil? raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'createTag failed: unknown result') end def updateTag(authenticationToken, tag) send_updateTag(authenticationToken, tag) return recv_updateTag() end def send_updateTag(authenticationToken, tag) send_message('updateTag', UpdateTag_args, :authenticationToken => authenticationToken, :tag => tag) end def recv_updateTag() result = receive_message(UpdateTag_result) return result.success unless result.success.nil? raise result.userException unless result.userException.nil? raise result.systemException unless result.systemException.nil? raise result.notFoundException unless result.notFoundException.nil? raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'updateTag failed: unknown result') end def untagAll(authenticationToken, guid) send_untagAll(authenticationToken, guid) recv_untagAll() end def send_untagAll(authenticationToken, guid) send_message('untagAll', UntagAll_args, :authenticationToken => authenticationToken, :guid => guid) end def recv_untagAll() result = receive_message(UntagAll_result) raise result.userException unless result.userException.nil? raise result.systemException unless result.systemException.nil? raise result.notFoundException unless result.notFoundException.nil? return end def expungeTag(authenticationToken, guid) send_expungeTag(authenticationToken, guid) return recv_expungeTag() end def send_expungeTag(authenticationToken, guid) send_message('expungeTag', ExpungeTag_args, :authenticationToken => authenticationToken, :guid => guid) end def recv_expungeTag() result = receive_message(ExpungeTag_result) return result.success unless result.success.nil? raise result.userException unless result.userException.nil? raise result.systemException unless result.systemException.nil? raise result.notFoundException unless result.notFoundException.nil? raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'expungeTag failed: unknown result') end def listSearches(authenticationToken) send_listSearches(authenticationToken) return recv_listSearches() end def send_listSearches(authenticationToken) send_message('listSearches', ListSearches_args, :authenticationToken => authenticationToken) end def recv_listSearches() result = receive_message(ListSearches_result) return result.success unless result.success.nil? raise result.userException unless result.userException.nil? raise result.systemException unless result.systemException.nil? raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'listSearches failed: unknown result') end def getSearch(authenticationToken, guid) send_getSearch(authenticationToken, guid) return recv_getSearch() end def send_getSearch(authenticationToken, guid) send_message('getSearch', GetSearch_args, :authenticationToken => authenticationToken, :guid => guid) end def recv_getSearch() result = receive_message(GetSearch_result) return result.success unless result.success.nil? raise result.userException unless result.userException.nil? raise result.systemException unless result.systemException.nil? raise result.notFoundException unless result.notFoundException.nil? raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'getSearch failed: unknown result') end def createSearch(authenticationToken, search) send_createSearch(authenticationToken, search) return recv_createSearch() end def send_createSearch(authenticationToken, search) send_message('createSearch', CreateSearch_args, :authenticationToken => authenticationToken, :search => search) end def recv_createSearch() result = receive_message(CreateSearch_result) return result.success unless result.success.nil? raise result.userException unless result.userException.nil? raise result.systemException unless result.systemException.nil? raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'createSearch failed: unknown result') end def updateSearch(authenticationToken, search) send_updateSearch(authenticationToken, search) return recv_updateSearch() end def send_updateSearch(authenticationToken, search) send_message('updateSearch', UpdateSearch_args, :authenticationToken => authenticationToken, :search => search) end def recv_updateSearch() result = receive_message(UpdateSearch_result) return result.success unless result.success.nil? raise result.userException unless result.userException.nil? raise result.systemException unless result.systemException.nil? raise result.notFoundException unless result.notFoundException.nil? raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'updateSearch failed: unknown result') end def expungeSearch(authenticationToken, guid) send_expungeSearch(authenticationToken, guid) return recv_expungeSearch() end def send_expungeSearch(authenticationToken, guid) send_message('expungeSearch', ExpungeSearch_args, :authenticationToken => authenticationToken, :guid => guid) end def recv_expungeSearch() result = receive_message(ExpungeSearch_result) return result.success unless result.success.nil? raise result.userException unless result.userException.nil? raise result.systemException unless result.systemException.nil? raise result.notFoundException unless result.notFoundException.nil? raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'expungeSearch failed: unknown result') end def findNotes(authenticationToken, filter, offset, maxNotes) send_findNotes(authenticationToken, filter, offset, maxNotes) return recv_findNotes() end def send_findNotes(authenticationToken, filter, offset, maxNotes) send_message('findNotes', FindNotes_args, :authenticationToken => authenticationToken, :filter => filter, :offset => offset, :maxNotes => maxNotes) end def recv_findNotes() result = receive_message(FindNotes_result) return result.success unless result.success.nil? raise result.userException unless result.userException.nil? raise result.systemException unless result.systemException.nil? raise result.notFoundException unless result.notFoundException.nil? raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'findNotes failed: unknown result') end def findNoteCounts(authenticationToken, filter, withTrash) send_findNoteCounts(authenticationToken, filter, withTrash) return recv_findNoteCounts() end def send_findNoteCounts(authenticationToken, filter, withTrash) send_message('findNoteCounts', FindNoteCounts_args, :authenticationToken => authenticationToken, :filter => filter, :withTrash => withTrash) end def recv_findNoteCounts() result = receive_message(FindNoteCounts_result) return result.success unless result.success.nil? raise result.userException unless result.userException.nil? raise result.systemException unless result.systemException.nil? raise result.notFoundException unless result.notFoundException.nil? raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'findNoteCounts failed: unknown result') end def getNote(authenticationToken, guid, withContent, withResourcesData, withResourcesRecognition, withResourcesAlternateData) send_getNote(authenticationToken, guid, withContent, withResourcesData, withResourcesRecognition, withResourcesAlternateData) return recv_getNote() end def send_getNote(authenticationToken, guid, withContent, withResourcesData, withResourcesRecognition, withResourcesAlternateData) send_message('getNote', GetNote_args, :authenticationToken => authenticationToken, :guid => guid, :withContent => withContent, :withResourcesData => withResourcesData, :withResourcesRecognition => withResourcesRecognition, :withResourcesAlternateData => withResourcesAlternateData) end def recv_getNote() result = receive_message(GetNote_result) return result.success unless result.success.nil? raise result.userException unless result.userException.nil? raise result.systemException unless result.systemException.nil? raise result.notFoundException unless result.notFoundException.nil? raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'getNote failed: unknown result') end def getNoteContent(authenticationToken, guid) send_getNoteContent(authenticationToken, guid) return recv_getNoteContent() end def send_getNoteContent(authenticationToken, guid) send_message('getNoteContent', GetNoteContent_args, :authenticationToken => authenticationToken, :guid => guid) end def recv_getNoteContent() result = receive_message(GetNoteContent_result) return result.success unless result.success.nil? raise result.userException unless result.userException.nil? raise result.systemException unless result.systemException.nil? raise result.notFoundException unless result.notFoundException.nil? raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'getNoteContent failed: unknown result') end def getNoteSearchText(authenticationToken, guid) send_getNoteSearchText(authenticationToken, guid) return recv_getNoteSearchText() end def send_getNoteSearchText(authenticationToken, guid) send_message('getNoteSearchText', GetNoteSearchText_args, :authenticationToken => authenticationToken, :guid => guid) end def recv_getNoteSearchText() result = receive_message(GetNoteSearchText_result) return result.success unless result.success.nil? raise result.userException unless result.userException.nil? raise result.systemException unless result.systemException.nil? raise result.notFoundException unless result.notFoundException.nil? raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'getNoteSearchText failed: unknown result') end def getNoteTagNames(authenticationToken, guid) send_getNoteTagNames(authenticationToken, guid) return recv_getNoteTagNames() end def send_getNoteTagNames(authenticationToken, guid) send_message('getNoteTagNames', GetNoteTagNames_args, :authenticationToken => authenticationToken, :guid => guid) end def recv_getNoteTagNames() result = receive_message(GetNoteTagNames_result) return result.success unless result.success.nil? raise result.userException unless result.userException.nil? raise result.systemException unless result.systemException.nil? raise result.notFoundException unless result.notFoundException.nil? raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'getNoteTagNames failed: unknown result') end def createNote(authenticationToken, note) send_createNote(authenticationToken, note) return recv_createNote() end def send_createNote(authenticationToken, note) send_message('createNote', CreateNote_args, :authenticationToken => authenticationToken, :note => note) end def recv_createNote() result = receive_message(CreateNote_result) return result.success unless result.success.nil? raise result.userException unless result.userException.nil? raise result.systemException unless result.systemException.nil? raise result.notFoundException unless result.notFoundException.nil? raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'createNote failed: unknown result') end def updateNote(authenticationToken, note) send_updateNote(authenticationToken, note) return recv_updateNote() end def send_updateNote(authenticationToken, note) send_message('updateNote', UpdateNote_args, :authenticationToken => authenticationToken, :note => note) end def recv_updateNote() result = receive_message(UpdateNote_result) return result.success unless result.success.nil? raise result.userException unless result.userException.nil? raise result.systemException unless result.systemException.nil? raise result.notFoundException unless result.notFoundException.nil? raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'updateNote failed: unknown result') end def deleteNote(authenticationToken, guid) send_deleteNote(authenticationToken, guid) return recv_deleteNote() end def send_deleteNote(authenticationToken, guid) send_message('deleteNote', DeleteNote_args, :authenticationToken => authenticationToken, :guid => guid) end def recv_deleteNote() result = receive_message(DeleteNote_result) return result.success unless result.success.nil? raise result.userException unless result.userException.nil? raise result.systemException unless result.systemException.nil? raise result.notFoundException unless result.notFoundException.nil? raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'deleteNote failed: unknown result') end def expungeNote(authenticationToken, guid) send_expungeNote(authenticationToken, guid) return recv_expungeNote() end def send_expungeNote(authenticationToken, guid) send_message('expungeNote', ExpungeNote_args, :authenticationToken => authenticationToken, :guid => guid) end def recv_expungeNote() result = receive_message(ExpungeNote_result) return result.success unless result.success.nil? raise result.userException unless result.userException.nil? raise result.systemException unless result.systemException.nil? raise result.notFoundException unless result.notFoundException.nil? raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'expungeNote failed: unknown result') end def expungeNotes(authenticationToken, noteGuids) send_expungeNotes(authenticationToken, noteGuids) return recv_expungeNotes() end def send_expungeNotes(authenticationToken, noteGuids) send_message('expungeNotes', ExpungeNotes_args, :authenticationToken => authenticationToken, :noteGuids => noteGuids) end def recv_expungeNotes() result = receive_message(ExpungeNotes_result) return result.success unless result.success.nil? raise result.userException unless result.userException.nil? raise result.systemException unless result.systemException.nil? raise result.notFoundException unless result.notFoundException.nil? raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'expungeNotes failed: unknown result') end def expungeInactiveNotes(authenticationToken) send_expungeInactiveNotes(authenticationToken) return recv_expungeInactiveNotes() end def send_expungeInactiveNotes(authenticationToken) send_message('expungeInactiveNotes', ExpungeInactiveNotes_args, :authenticationToken => authenticationToken) end def recv_expungeInactiveNotes() result = receive_message(ExpungeInactiveNotes_result) return result.success unless result.success.nil? raise result.userException unless result.userException.nil? raise result.systemException unless result.systemException.nil? raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'expungeInactiveNotes failed: unknown result') end def copyNote(authenticationToken, noteGuid, toNotebookGuid) send_copyNote(authenticationToken, noteGuid, toNotebookGuid) return recv_copyNote() end def send_copyNote(authenticationToken, noteGuid, toNotebookGuid) send_message('copyNote', CopyNote_args, :authenticationToken => authenticationToken, :noteGuid => noteGuid, :toNotebookGuid => toNotebookGuid) end def recv_copyNote() result = receive_message(CopyNote_result) return result.success unless result.success.nil? raise result.userException unless result.userException.nil? raise result.systemException unless result.systemException.nil? raise result.notFoundException unless result.notFoundException.nil? raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'copyNote failed: unknown result') end def listNoteVersions(authenticationToken, noteGuid) send_listNoteVersions(authenticationToken, noteGuid) return recv_listNoteVersions() end def send_listNoteVersions(authenticationToken, noteGuid) send_message('listNoteVersions', ListNoteVersions_args, :authenticationToken => authenticationToken, :noteGuid => noteGuid) end def recv_listNoteVersions() result = receive_message(ListNoteVersions_result) return result.success unless result.success.nil? raise result.userException unless result.userException.nil? raise result.systemException unless result.systemException.nil? raise result.notFoundException unless result.notFoundException.nil? raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'listNoteVersions failed: unknown result') end def getNoteVersion(authenticationToken, noteGuid, updateSequenceNum, withResourcesData, withResourcesRecognition, withResourcesAlternateData) send_getNoteVersion(authenticationToken, noteGuid, updateSequenceNum, withResourcesData, withResourcesRecognition, withResourcesAlternateData) return recv_getNoteVersion() end def send_getNoteVersion(authenticationToken, noteGuid, updateSequenceNum, withResourcesData, withResourcesRecognition, withResourcesAlternateData) send_message('getNoteVersion', GetNoteVersion_args, :authenticationToken => authenticationToken, :noteGuid => noteGuid, :updateSequenceNum => updateSequenceNum, :withResourcesData => withResourcesData, :withResourcesRecognition => withResourcesRecognition, :withResourcesAlternateData => withResourcesAlternateData) end def recv_getNoteVersion() result = receive_message(GetNoteVersion_result) return result.success unless result.success.nil? raise result.userException unless result.userException.nil? raise result.systemException unless result.systemException.nil? raise result.notFoundException unless result.notFoundException.nil? raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'getNoteVersion failed: unknown result') end def getResource(authenticationToken, guid, withData, withRecognition, withAttributes, withAlternateData) send_getResource(authenticationToken, guid, withData, withRecognition, withAttributes, withAlternateData) return recv_getResource() end def send_getResource(authenticationToken, guid, withData, withRecognition, withAttributes, withAlternateData) send_message('getResource', GetResource_args, :authenticationToken => authenticationToken, :guid => guid, :withData => withData, :withRecognition => withRecognition, :withAttributes => withAttributes, :withAlternateData => withAlternateData) end def recv_getResource() result = receive_message(GetResource_result) return result.success unless result.success.nil? raise result.userException unless result.userException.nil? raise result.systemException unless result.systemException.nil? raise result.notFoundException unless result.notFoundException.nil? raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'getResource failed: unknown result') end def updateResource(authenticationToken, resource) send_updateResource(authenticationToken, resource) return recv_updateResource() end def send_updateResource(authenticationToken, resource) send_message('updateResource', UpdateResource_args, :authenticationToken => authenticationToken, :resource => resource) end def recv_updateResource() result = receive_message(UpdateResource_result) return result.success unless result.success.nil? raise result.userException unless result.userException.nil? raise result.systemException unless result.systemException.nil? raise result.notFoundException unless result.notFoundException.nil? raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'updateResource failed: unknown result') end def getResourceData(authenticationToken, guid) send_getResourceData(authenticationToken, guid) return recv_getResourceData() end def send_getResourceData(authenticationToken, guid) send_message('getResourceData', GetResourceData_args, :authenticationToken => authenticationToken, :guid => guid) end def recv_getResourceData() result = receive_message(GetResourceData_result) return result.success unless result.success.nil? raise result.userException unless result.userException.nil? raise result.systemException unless result.systemException.nil? raise result.notFoundException unless result.notFoundException.nil? raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'getResourceData failed: unknown result') end def getResourceByHash(authenticationToken, noteGuid, contentHash, withData, withRecognition, withAlternateData) send_getResourceByHash(authenticationToken, noteGuid, contentHash, withData, withRecognition, withAlternateData) return recv_getResourceByHash() end def send_getResourceByHash(authenticationToken, noteGuid, contentHash, withData, withRecognition, withAlternateData) send_message('getResourceByHash', GetResourceByHash_args, :authenticationToken => authenticationToken, :noteGuid => noteGuid, :contentHash => contentHash, :withData => withData, :withRecognition => withRecognition, :withAlternateData => withAlternateData) end def recv_getResourceByHash() result = receive_message(GetResourceByHash_result) return result.success unless result.success.nil? raise result.userException unless result.userException.nil? raise result.systemException unless result.systemException.nil? raise result.notFoundException unless result.notFoundException.nil? raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'getResourceByHash failed: unknown result') end def getResourceRecognition(authenticationToken, guid) send_getResourceRecognition(authenticationToken, guid) return recv_getResourceRecognition() end def send_getResourceRecognition(authenticationToken, guid) send_message('getResourceRecognition', GetResourceRecognition_args, :authenticationToken => authenticationToken, :guid => guid) end def recv_getResourceRecognition() result = receive_message(GetResourceRecognition_result) return result.success unless result.success.nil? raise result.userException unless result.userException.nil? raise result.systemException unless result.systemException.nil? raise result.notFoundException unless result.notFoundException.nil? raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'getResourceRecognition failed: unknown result') end def getResourceAlternateData(authenticationToken, guid) send_getResourceAlternateData(authenticationToken, guid) return recv_getResourceAlternateData() end def send_getResourceAlternateData(authenticationToken, guid) send_message('getResourceAlternateData', GetResourceAlternateData_args, :authenticationToken => authenticationToken, :guid => guid) end def recv_getResourceAlternateData() result = receive_message(GetResourceAlternateData_result) return result.success unless result.success.nil? raise result.userException unless result.userException.nil? raise result.systemException unless result.systemException.nil? raise result.notFoundException unless result.notFoundException.nil? raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'getResourceAlternateData failed: unknown result') end def getResourceAttributes(authenticationToken, guid) send_getResourceAttributes(authenticationToken, guid) return recv_getResourceAttributes() end def send_getResourceAttributes(authenticationToken, guid) send_message('getResourceAttributes', GetResourceAttributes_args, :authenticationToken => authenticationToken, :guid => guid) end def recv_getResourceAttributes() result = receive_message(GetResourceAttributes_result) return result.success unless result.success.nil? raise result.userException unless result.userException.nil? raise result.systemException unless result.systemException.nil? raise result.notFoundException unless result.notFoundException.nil? raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'getResourceAttributes failed: unknown result') end def getAccountSize(authenticationToken) send_getAccountSize(authenticationToken) return recv_getAccountSize() end def send_getAccountSize(authenticationToken) send_message('getAccountSize', GetAccountSize_args, :authenticationToken => authenticationToken) end def recv_getAccountSize() result = receive_message(GetAccountSize_result) return result.success unless result.success.nil? raise result.userException unless result.userException.nil? raise result.systemException unless result.systemException.nil? raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'getAccountSize failed: unknown result') end def getAds(authenticationToken, adParameters) send_getAds(authenticationToken, adParameters) return recv_getAds() end def send_getAds(authenticationToken, adParameters) send_message('getAds', GetAds_args, :authenticationToken => authenticationToken, :adParameters => adParameters) end def recv_getAds() result = receive_message(GetAds_result) return result.success unless result.success.nil? raise result.userException unless result.userException.nil? raise result.systemException unless result.systemException.nil? raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'getAds failed: unknown result') end def getRandomAd(authenticationToken, adParameters) send_getRandomAd(authenticationToken, adParameters) return recv_getRandomAd() end def send_getRandomAd(authenticationToken, adParameters) send_message('getRandomAd', GetRandomAd_args, :authenticationToken => authenticationToken, :adParameters => adParameters) end def recv_getRandomAd() result = receive_message(GetRandomAd_result) return result.success unless result.success.nil? raise result.userException unless result.userException.nil? raise result.systemException unless result.systemException.nil? raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'getRandomAd failed: unknown result') end def getPublicNotebook(userId, publicUri) send_getPublicNotebook(userId, publicUri) return recv_getPublicNotebook() end def send_getPublicNotebook(userId, publicUri) send_message('getPublicNotebook', GetPublicNotebook_args, :userId => userId, :publicUri => publicUri) end def recv_getPublicNotebook() result = receive_message(GetPublicNotebook_result) return result.success unless result.success.nil? raise result.systemException unless result.systemException.nil? raise result.notFoundException unless result.notFoundException.nil? raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'getPublicNotebook failed: unknown result') end def createSharedNotebook(authenticationToken, sharedNotebook) send_createSharedNotebook(authenticationToken, sharedNotebook) return recv_createSharedNotebook() end def send_createSharedNotebook(authenticationToken, sharedNotebook) send_message('createSharedNotebook', CreateSharedNotebook_args, :authenticationToken => authenticationToken, :sharedNotebook => sharedNotebook) end def recv_createSharedNotebook() result = receive_message(CreateSharedNotebook_result) return result.success unless result.success.nil? raise result.userException unless result.userException.nil? raise result.notFoundException unless result.notFoundException.nil? raise result.systemException unless result.systemException.nil? raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'createSharedNotebook failed: unknown result') end def listSharedNotebooks(authenticationToken) send_listSharedNotebooks(authenticationToken) return recv_listSharedNotebooks() end def send_listSharedNotebooks(authenticationToken) send_message('listSharedNotebooks', ListSharedNotebooks_args, :authenticationToken => authenticationToken) end def recv_listSharedNotebooks() result = receive_message(ListSharedNotebooks_result) return result.success unless result.success.nil? raise result.userException unless result.userException.nil? raise result.notFoundException unless result.notFoundException.nil? raise result.systemException unless result.systemException.nil? raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'listSharedNotebooks failed: unknown result') end def expungeSharedNotebooks(authenticationToken, sharedNotebookIds) send_expungeSharedNotebooks(authenticationToken, sharedNotebookIds) return recv_expungeSharedNotebooks() end def send_expungeSharedNotebooks(authenticationToken, sharedNotebookIds) send_message('expungeSharedNotebooks', ExpungeSharedNotebooks_args, :authenticationToken => authenticationToken, :sharedNotebookIds => sharedNotebookIds) end def recv_expungeSharedNotebooks() result = receive_message(ExpungeSharedNotebooks_result) return result.success unless result.success.nil? raise result.userException unless result.userException.nil? raise result.notFoundException unless result.notFoundException.nil? raise result.systemException unless result.systemException.nil? raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'expungeSharedNotebooks failed: unknown result') end def createLinkedNotebook(authenticationToken, linkedNotebook) send_createLinkedNotebook(authenticationToken, linkedNotebook) return recv_createLinkedNotebook() end def send_createLinkedNotebook(authenticationToken, linkedNotebook) send_message('createLinkedNotebook', CreateLinkedNotebook_args, :authenticationToken => authenticationToken, :linkedNotebook => linkedNotebook) end def recv_createLinkedNotebook() result = receive_message(CreateLinkedNotebook_result) return result.success unless result.success.nil? raise result.userException unless result.userException.nil? raise result.notFoundException unless result.notFoundException.nil? raise result.systemException unless result.systemException.nil? raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'createLinkedNotebook failed: unknown result') end def updateLinkedNotebook(authenticationToken, linkedNotebook) send_updateLinkedNotebook(authenticationToken, linkedNotebook) return recv_updateLinkedNotebook() end def send_updateLinkedNotebook(authenticationToken, linkedNotebook) send_message('updateLinkedNotebook', UpdateLinkedNotebook_args, :authenticationToken => authenticationToken, :linkedNotebook => linkedNotebook) end def recv_updateLinkedNotebook() result = receive_message(UpdateLinkedNotebook_result) return result.success unless result.success.nil? raise result.userException unless result.userException.nil? raise result.notFoundException unless result.notFoundException.nil? raise result.systemException unless result.systemException.nil? raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'updateLinkedNotebook failed: unknown result') end def listLinkedNotebooks(authenticationToken) send_listLinkedNotebooks(authenticationToken) return recv_listLinkedNotebooks() end def send_listLinkedNotebooks(authenticationToken) send_message('listLinkedNotebooks', ListLinkedNotebooks_args, :authenticationToken => authenticationToken) end def recv_listLinkedNotebooks() result = receive_message(ListLinkedNotebooks_result) return result.success unless result.success.nil? raise result.userException unless result.userException.nil? raise result.notFoundException unless result.notFoundException.nil? raise result.systemException unless result.systemException.nil? raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'listLinkedNotebooks failed: unknown result') end def expungeLinkedNotebook(authenticationToken, linkedNotebookId) send_expungeLinkedNotebook(authenticationToken, linkedNotebookId) return recv_expungeLinkedNotebook() end def send_expungeLinkedNotebook(authenticationToken, linkedNotebookId) send_message('expungeLinkedNotebook', ExpungeLinkedNotebook_args, :authenticationToken => authenticationToken, :linkedNotebookId => linkedNotebookId) end def recv_expungeLinkedNotebook() result = receive_message(ExpungeLinkedNotebook_result) return result.success unless result.success.nil? raise result.userException unless result.userException.nil? raise result.notFoundException unless result.notFoundException.nil? raise result.systemException unless result.systemException.nil? raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'expungeLinkedNotebook failed: unknown result') end def authenticateToSharedNotebook(shareKey, authenticationToken) send_authenticateToSharedNotebook(shareKey, authenticationToken) return recv_authenticateToSharedNotebook() end def send_authenticateToSharedNotebook(shareKey, authenticationToken) send_message('authenticateToSharedNotebook', AuthenticateToSharedNotebook_args, :shareKey => shareKey, :authenticationToken => authenticationToken) end def recv_authenticateToSharedNotebook() result = receive_message(AuthenticateToSharedNotebook_result) return result.success unless result.success.nil? raise result.userException unless result.userException.nil? raise result.notFoundException unless result.notFoundException.nil? raise result.systemException unless result.systemException.nil? raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'authenticateToSharedNotebook failed: unknown result') end def getSharedNotebookByAuth(authenticationToken) send_getSharedNotebookByAuth(authenticationToken) return recv_getSharedNotebookByAuth() end def send_getSharedNotebookByAuth(authenticationToken) send_message('getSharedNotebookByAuth', GetSharedNotebookByAuth_args, :authenticationToken => authenticationToken) end def recv_getSharedNotebookByAuth() result = receive_message(GetSharedNotebookByAuth_result) return result.success unless result.success.nil? raise result.userException unless result.userException.nil? raise result.notFoundException unless result.notFoundException.nil? raise result.systemException unless result.systemException.nil? raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'getSharedNotebookByAuth failed: unknown result') end def emailNote(authenticationToken, parameters) send_emailNote(authenticationToken, parameters) recv_emailNote() end def send_emailNote(authenticationToken, parameters) send_message('emailNote', EmailNote_args, :authenticationToken => authenticationToken, :parameters => parameters) end def recv_emailNote() result = receive_message(EmailNote_result) raise result.userException unless result.userException.nil? raise result.notFoundException unless result.notFoundException.nil? raise result.systemException unless result.systemException.nil? return end end class Processor include ::Thrift::Processor def process_getSyncState(seqid, iprot, oprot) args = read_args(iprot, GetSyncState_args) result = GetSyncState_result.new() begin result.success = @handler.getSyncState(args.authenticationToken) rescue Evernote::EDAM::Error::EDAMUserException => userException result.userException = userException rescue Evernote::EDAM::Error::EDAMSystemException => systemException result.systemException = systemException end write_result(result, oprot, 'getSyncState', seqid) end def process_getSyncChunk(seqid, iprot, oprot) args = read_args(iprot, GetSyncChunk_args) result = GetSyncChunk_result.new() begin result.success = @handler.getSyncChunk(args.authenticationToken, args.afterUSN, args.maxEntries, args.fullSyncOnly) rescue Evernote::EDAM::Error::EDAMUserException => userException result.userException = userException rescue Evernote::EDAM::Error::EDAMSystemException => systemException result.systemException = systemException end write_result(result, oprot, 'getSyncChunk', seqid) end def process_listNotebooks(seqid, iprot, oprot) args = read_args(iprot, ListNotebooks_args) result = ListNotebooks_result.new() begin result.success = @handler.listNotebooks(args.authenticationToken) rescue Evernote::EDAM::Error::EDAMUserException => userException result.userException = userException rescue Evernote::EDAM::Error::EDAMSystemException => systemException result.systemException = systemException end write_result(result, oprot, 'listNotebooks', seqid) end def process_getNotebook(seqid, iprot, oprot) args = read_args(iprot, GetNotebook_args) result = GetNotebook_result.new() begin result.success = @handler.getNotebook(args.authenticationToken, args.guid) rescue Evernote::EDAM::Error::EDAMUserException => userException result.userException = userException rescue Evernote::EDAM::Error::EDAMSystemException => systemException result.systemException = systemException rescue Evernote::EDAM::Error::EDAMNotFoundException => notFoundException result.notFoundException = notFoundException end write_result(result, oprot, 'getNotebook', seqid) end def process_getDefaultNotebook(seqid, iprot, oprot) args = read_args(iprot, GetDefaultNotebook_args) result = GetDefaultNotebook_result.new() begin result.success = @handler.getDefaultNotebook(args.authenticationToken) rescue Evernote::EDAM::Error::EDAMUserException => userException result.userException = userException rescue Evernote::EDAM::Error::EDAMSystemException => systemException result.systemException = systemException end write_result(result, oprot, 'getDefaultNotebook', seqid) end def process_createNotebook(seqid, iprot, oprot) args = read_args(iprot, CreateNotebook_args) result = CreateNotebook_result.new() begin result.success = @handler.createNotebook(args.authenticationToken, args.notebook) rescue Evernote::EDAM::Error::EDAMUserException => userException result.userException = userException rescue Evernote::EDAM::Error::EDAMSystemException => systemException result.systemException = systemException end write_result(result, oprot, 'createNotebook', seqid) end def process_updateNotebook(seqid, iprot, oprot) args = read_args(iprot, UpdateNotebook_args) result = UpdateNotebook_result.new() begin result.success = @handler.updateNotebook(args.authenticationToken, args.notebook) rescue Evernote::EDAM::Error::EDAMUserException => userException result.userException = userException rescue Evernote::EDAM::Error::EDAMSystemException => systemException result.systemException = systemException rescue Evernote::EDAM::Error::EDAMNotFoundException => notFoundException result.notFoundException = notFoundException end write_result(result, oprot, 'updateNotebook', seqid) end def process_expungeNotebook(seqid, iprot, oprot) args = read_args(iprot, ExpungeNotebook_args) result = ExpungeNotebook_result.new() begin result.success = @handler.expungeNotebook(args.authenticationToken, args.guid) rescue Evernote::EDAM::Error::EDAMUserException => userException result.userException = userException rescue Evernote::EDAM::Error::EDAMSystemException => systemException result.systemException = systemException rescue Evernote::EDAM::Error::EDAMNotFoundException => notFoundException result.notFoundException = notFoundException end write_result(result, oprot, 'expungeNotebook', seqid) end def process_listTags(seqid, iprot, oprot) args = read_args(iprot, ListTags_args) result = ListTags_result.new() begin result.success = @handler.listTags(args.authenticationToken) rescue Evernote::EDAM::Error::EDAMUserException => userException result.userException = userException rescue Evernote::EDAM::Error::EDAMSystemException => systemException result.systemException = systemException end write_result(result, oprot, 'listTags', seqid) end def process_listTagsByNotebook(seqid, iprot, oprot) args = read_args(iprot, ListTagsByNotebook_args) result = ListTagsByNotebook_result.new() begin result.success = @handler.listTagsByNotebook(args.authenticationToken, args.notebookGuid) rescue Evernote::EDAM::Error::EDAMUserException => userException result.userException = userException rescue Evernote::EDAM::Error::EDAMSystemException => systemException result.systemException = systemException rescue Evernote::EDAM::Error::EDAMNotFoundException => notFoundException result.notFoundException = notFoundException end write_result(result, oprot, 'listTagsByNotebook', seqid) end def process_getTag(seqid, iprot, oprot) args = read_args(iprot, GetTag_args) result = GetTag_result.new() begin result.success = @handler.getTag(args.authenticationToken, args.guid) rescue Evernote::EDAM::Error::EDAMUserException => userException result.userException = userException rescue Evernote::EDAM::Error::EDAMSystemException => systemException result.systemException = systemException rescue Evernote::EDAM::Error::EDAMNotFoundException => notFoundException result.notFoundException = notFoundException end write_result(result, oprot, 'getTag', seqid) end def process_createTag(seqid, iprot, oprot) args = read_args(iprot, CreateTag_args) result = CreateTag_result.new() begin result.success = @handler.createTag(args.authenticationToken, args.tag) rescue Evernote::EDAM::Error::EDAMUserException => userException result.userException = userException rescue Evernote::EDAM::Error::EDAMSystemException => systemException result.systemException = systemException rescue Evernote::EDAM::Error::EDAMNotFoundException => notFoundException result.notFoundException = notFoundException end write_result(result, oprot, 'createTag', seqid) end def process_updateTag(seqid, iprot, oprot) args = read_args(iprot, UpdateTag_args) result = UpdateTag_result.new() begin result.success = @handler.updateTag(args.authenticationToken, args.tag) rescue Evernote::EDAM::Error::EDAMUserException => userException result.userException = userException rescue Evernote::EDAM::Error::EDAMSystemException => systemException result.systemException = systemException rescue Evernote::EDAM::Error::EDAMNotFoundException => notFoundException result.notFoundException = notFoundException end write_result(result, oprot, 'updateTag', seqid) end def process_untagAll(seqid, iprot, oprot) args = read_args(iprot, UntagAll_args) result = UntagAll_result.new() begin @handler.untagAll(args.authenticationToken, args.guid) rescue Evernote::EDAM::Error::EDAMUserException => userException result.userException = userException rescue Evernote::EDAM::Error::EDAMSystemException => systemException result.systemException = systemException rescue Evernote::EDAM::Error::EDAMNotFoundException => notFoundException result.notFoundException = notFoundException end write_result(result, oprot, 'untagAll', seqid) end def process_expungeTag(seqid, iprot, oprot) args = read_args(iprot, ExpungeTag_args) result = ExpungeTag_result.new() begin result.success = @handler.expungeTag(args.authenticationToken, args.guid) rescue Evernote::EDAM::Error::EDAMUserException => userException result.userException = userException rescue Evernote::EDAM::Error::EDAMSystemException => systemException result.systemException = systemException rescue Evernote::EDAM::Error::EDAMNotFoundException => notFoundException result.notFoundException = notFoundException end write_result(result, oprot, 'expungeTag', seqid) end def process_listSearches(seqid, iprot, oprot) args = read_args(iprot, ListSearches_args) result = ListSearches_result.new() begin result.success = @handler.listSearches(args.authenticationToken) rescue Evernote::EDAM::Error::EDAMUserException => userException result.userException = userException rescue Evernote::EDAM::Error::EDAMSystemException => systemException result.systemException = systemException end write_result(result, oprot, 'listSearches', seqid) end def process_getSearch(seqid, iprot, oprot) args = read_args(iprot, GetSearch_args) result = GetSearch_result.new() begin result.success = @handler.getSearch(args.authenticationToken, args.guid) rescue Evernote::EDAM::Error::EDAMUserException => userException result.userException = userException rescue Evernote::EDAM::Error::EDAMSystemException => systemException result.systemException = systemException rescue Evernote::EDAM::Error::EDAMNotFoundException => notFoundException result.notFoundException = notFoundException end write_result(result, oprot, 'getSearch', seqid) end def process_createSearch(seqid, iprot, oprot) args = read_args(iprot, CreateSearch_args) result = CreateSearch_result.new() begin result.success = @handler.createSearch(args.authenticationToken, args.search) rescue Evernote::EDAM::Error::EDAMUserException => userException result.userException = userException rescue Evernote::EDAM::Error::EDAMSystemException => systemException result.systemException = systemException end write_result(result, oprot, 'createSearch', seqid) end def process_updateSearch(seqid, iprot, oprot) args = read_args(iprot, UpdateSearch_args) result = UpdateSearch_result.new() begin result.success = @handler.updateSearch(args.authenticationToken, args.search) rescue Evernote::EDAM::Error::EDAMUserException => userException result.userException = userException rescue Evernote::EDAM::Error::EDAMSystemException => systemException result.systemException = systemException rescue Evernote::EDAM::Error::EDAMNotFoundException => notFoundException result.notFoundException = notFoundException end write_result(result, oprot, 'updateSearch', seqid) end def process_expungeSearch(seqid, iprot, oprot) args = read_args(iprot, ExpungeSearch_args) result = ExpungeSearch_result.new() begin result.success = @handler.expungeSearch(args.authenticationToken, args.guid) rescue Evernote::EDAM::Error::EDAMUserException => userException result.userException = userException rescue Evernote::EDAM::Error::EDAMSystemException => systemException result.systemException = systemException rescue Evernote::EDAM::Error::EDAMNotFoundException => notFoundException result.notFoundException = notFoundException end write_result(result, oprot, 'expungeSearch', seqid) end def process_findNotes(seqid, iprot, oprot) args = read_args(iprot, FindNotes_args) result = FindNotes_result.new() begin result.success = @handler.findNotes(args.authenticationToken, args.filter, args.offset, args.maxNotes) rescue Evernote::EDAM::Error::EDAMUserException => userException result.userException = userException rescue Evernote::EDAM::Error::EDAMSystemException => systemException result.systemException = systemException rescue Evernote::EDAM::Error::EDAMNotFoundException => notFoundException result.notFoundException = notFoundException end write_result(result, oprot, 'findNotes', seqid) end def process_findNoteCounts(seqid, iprot, oprot) args = read_args(iprot, FindNoteCounts_args) result = FindNoteCounts_result.new() begin result.success = @handler.findNoteCounts(args.authenticationToken, args.filter, args.withTrash) rescue Evernote::EDAM::Error::EDAMUserException => userException result.userException = userException rescue Evernote::EDAM::Error::EDAMSystemException => systemException result.systemException = systemException rescue Evernote::EDAM::Error::EDAMNotFoundException => notFoundException result.notFoundException = notFoundException end write_result(result, oprot, 'findNoteCounts', seqid) end def process_getNote(seqid, iprot, oprot) args = read_args(iprot, GetNote_args) result = GetNote_result.new() begin result.success = @handler.getNote(args.authenticationToken, args.guid, args.withContent, args.withResourcesData, args.withResourcesRecognition, args.withResourcesAlternateData) rescue Evernote::EDAM::Error::EDAMUserException => userException result.userException = userException rescue Evernote::EDAM::Error::EDAMSystemException => systemException result.systemException = systemException rescue Evernote::EDAM::Error::EDAMNotFoundException => notFoundException result.notFoundException = notFoundException end write_result(result, oprot, 'getNote', seqid) end def process_getNoteContent(seqid, iprot, oprot) args = read_args(iprot, GetNoteContent_args) result = GetNoteContent_result.new() begin result.success = @handler.getNoteContent(args.authenticationToken, args.guid) rescue Evernote::EDAM::Error::EDAMUserException => userException result.userException = userException rescue Evernote::EDAM::Error::EDAMSystemException => systemException result.systemException = systemException rescue Evernote::EDAM::Error::EDAMNotFoundException => notFoundException result.notFoundException = notFoundException end write_result(result, oprot, 'getNoteContent', seqid) end def process_getNoteSearchText(seqid, iprot, oprot) args = read_args(iprot, GetNoteSearchText_args) result = GetNoteSearchText_result.new() begin result.success = @handler.getNoteSearchText(args.authenticationToken, args.guid) rescue Evernote::EDAM::Error::EDAMUserException => userException result.userException = userException rescue Evernote::EDAM::Error::EDAMSystemException => systemException result.systemException = systemException rescue Evernote::EDAM::Error::EDAMNotFoundException => notFoundException result.notFoundException = notFoundException end write_result(result, oprot, 'getNoteSearchText', seqid) end def process_getNoteTagNames(seqid, iprot, oprot) args = read_args(iprot, GetNoteTagNames_args) result = GetNoteTagNames_result.new() begin result.success = @handler.getNoteTagNames(args.authenticationToken, args.guid) rescue Evernote::EDAM::Error::EDAMUserException => userException result.userException = userException rescue Evernote::EDAM::Error::EDAMSystemException => systemException result.systemException = systemException rescue Evernote::EDAM::Error::EDAMNotFoundException => notFoundException result.notFoundException = notFoundException end write_result(result, oprot, 'getNoteTagNames', seqid) end def process_createNote(seqid, iprot, oprot) args = read_args(iprot, CreateNote_args) result = CreateNote_result.new() begin result.success = @handler.createNote(args.authenticationToken, args.note) rescue Evernote::EDAM::Error::EDAMUserException => userException result.userException = userException rescue Evernote::EDAM::Error::EDAMSystemException => systemException result.systemException = systemException rescue Evernote::EDAM::Error::EDAMNotFoundException => notFoundException result.notFoundException = notFoundException end write_result(result, oprot, 'createNote', seqid) end def process_updateNote(seqid, iprot, oprot) args = read_args(iprot, UpdateNote_args) result = UpdateNote_result.new() begin result.success = @handler.updateNote(args.authenticationToken, args.note) rescue Evernote::EDAM::Error::EDAMUserException => userException result.userException = userException rescue Evernote::EDAM::Error::EDAMSystemException => systemException result.systemException = systemException rescue Evernote::EDAM::Error::EDAMNotFoundException => notFoundException result.notFoundException = notFoundException end write_result(result, oprot, 'updateNote', seqid) end def process_deleteNote(seqid, iprot, oprot) args = read_args(iprot, DeleteNote_args) result = DeleteNote_result.new() begin result.success = @handler.deleteNote(args.authenticationToken, args.guid) rescue Evernote::EDAM::Error::EDAMUserException => userException result.userException = userException rescue Evernote::EDAM::Error::EDAMSystemException => systemException result.systemException = systemException rescue Evernote::EDAM::Error::EDAMNotFoundException => notFoundException result.notFoundException = notFoundException end write_result(result, oprot, 'deleteNote', seqid) end def process_expungeNote(seqid, iprot, oprot) args = read_args(iprot, ExpungeNote_args) result = ExpungeNote_result.new() begin result.success = @handler.expungeNote(args.authenticationToken, args.guid) rescue Evernote::EDAM::Error::EDAMUserException => userException result.userException = userException rescue Evernote::EDAM::Error::EDAMSystemException => systemException result.systemException = systemException rescue Evernote::EDAM::Error::EDAMNotFoundException => notFoundException result.notFoundException = notFoundException end write_result(result, oprot, 'expungeNote', seqid) end def process_expungeNotes(seqid, iprot, oprot) args = read_args(iprot, ExpungeNotes_args) result = ExpungeNotes_result.new() begin result.success = @handler.expungeNotes(args.authenticationToken, args.noteGuids) rescue Evernote::EDAM::Error::EDAMUserException => userException result.userException = userException rescue Evernote::EDAM::Error::EDAMSystemException => systemException result.systemException = systemException rescue Evernote::EDAM::Error::EDAMNotFoundException => notFoundException result.notFoundException = notFoundException end write_result(result, oprot, 'expungeNotes', seqid) end def process_expungeInactiveNotes(seqid, iprot, oprot) args = read_args(iprot, ExpungeInactiveNotes_args) result = ExpungeInactiveNotes_result.new() begin result.success = @handler.expungeInactiveNotes(args.authenticationToken) rescue Evernote::EDAM::Error::EDAMUserException => userException result.userException = userException rescue Evernote::EDAM::Error::EDAMSystemException => systemException result.systemException = systemException end write_result(result, oprot, 'expungeInactiveNotes', seqid) end def process_copyNote(seqid, iprot, oprot) args = read_args(iprot, CopyNote_args) result = CopyNote_result.new() begin result.success = @handler.copyNote(args.authenticationToken, args.noteGuid, args.toNotebookGuid) rescue Evernote::EDAM::Error::EDAMUserException => userException result.userException = userException rescue Evernote::EDAM::Error::EDAMSystemException => systemException result.systemException = systemException rescue Evernote::EDAM::Error::EDAMNotFoundException => notFoundException result.notFoundException = notFoundException end write_result(result, oprot, 'copyNote', seqid) end def process_listNoteVersions(seqid, iprot, oprot) args = read_args(iprot, ListNoteVersions_args) result = ListNoteVersions_result.new() begin result.success = @handler.listNoteVersions(args.authenticationToken, args.noteGuid) rescue Evernote::EDAM::Error::EDAMUserException => userException result.userException = userException rescue Evernote::EDAM::Error::EDAMSystemException => systemException result.systemException = systemException rescue Evernote::EDAM::Error::EDAMNotFoundException => notFoundException result.notFoundException = notFoundException end write_result(result, oprot, 'listNoteVersions', seqid) end def process_getNoteVersion(seqid, iprot, oprot) args = read_args(iprot, GetNoteVersion_args) result = GetNoteVersion_result.new() begin result.success = @handler.getNoteVersion(args.authenticationToken, args.noteGuid, args.updateSequenceNum, args.withResourcesData, args.withResourcesRecognition, args.withResourcesAlternateData) rescue Evernote::EDAM::Error::EDAMUserException => userException result.userException = userException rescue Evernote::EDAM::Error::EDAMSystemException => systemException result.systemException = systemException rescue Evernote::EDAM::Error::EDAMNotFoundException => notFoundException result.notFoundException = notFoundException end write_result(result, oprot, 'getNoteVersion', seqid) end def process_getResource(seqid, iprot, oprot) args = read_args(iprot, GetResource_args) result = GetResource_result.new() begin result.success = @handler.getResource(args.authenticationToken, args.guid, args.withData, args.withRecognition, args.withAttributes, args.withAlternateData) rescue Evernote::EDAM::Error::EDAMUserException => userException result.userException = userException rescue Evernote::EDAM::Error::EDAMSystemException => systemException result.systemException = systemException rescue Evernote::EDAM::Error::EDAMNotFoundException => notFoundException result.notFoundException = notFoundException end write_result(result, oprot, 'getResource', seqid) end def process_updateResource(seqid, iprot, oprot) args = read_args(iprot, UpdateResource_args) result = UpdateResource_result.new() begin result.success = @handler.updateResource(args.authenticationToken, args.resource) rescue Evernote::EDAM::Error::EDAMUserException => userException result.userException = userException rescue Evernote::EDAM::Error::EDAMSystemException => systemException result.systemException = systemException rescue Evernote::EDAM::Error::EDAMNotFoundException => notFoundException result.notFoundException = notFoundException end write_result(result, oprot, 'updateResource', seqid) end def process_getResourceData(seqid, iprot, oprot) args = read_args(iprot, GetResourceData_args) result = GetResourceData_result.new() begin result.success = @handler.getResourceData(args.authenticationToken, args.guid) rescue Evernote::EDAM::Error::EDAMUserException => userException result.userException = userException rescue Evernote::EDAM::Error::EDAMSystemException => systemException result.systemException = systemException rescue Evernote::EDAM::Error::EDAMNotFoundException => notFoundException result.notFoundException = notFoundException end write_result(result, oprot, 'getResourceData', seqid) end def process_getResourceByHash(seqid, iprot, oprot) args = read_args(iprot, GetResourceByHash_args) result = GetResourceByHash_result.new() begin result.success = @handler.getResourceByHash(args.authenticationToken, args.noteGuid, args.contentHash, args.withData, args.withRecognition, args.withAlternateData) rescue Evernote::EDAM::Error::EDAMUserException => userException result.userException = userException rescue Evernote::EDAM::Error::EDAMSystemException => systemException result.systemException = systemException rescue Evernote::EDAM::Error::EDAMNotFoundException => notFoundException result.notFoundException = notFoundException end write_result(result, oprot, 'getResourceByHash', seqid) end def process_getResourceRecognition(seqid, iprot, oprot) args = read_args(iprot, GetResourceRecognition_args) result = GetResourceRecognition_result.new() begin result.success = @handler.getResourceRecognition(args.authenticationToken, args.guid) rescue Evernote::EDAM::Error::EDAMUserException => userException result.userException = userException rescue Evernote::EDAM::Error::EDAMSystemException => systemException result.systemException = systemException rescue Evernote::EDAM::Error::EDAMNotFoundException => notFoundException result.notFoundException = notFoundException end write_result(result, oprot, 'getResourceRecognition', seqid) end def process_getResourceAlternateData(seqid, iprot, oprot) args = read_args(iprot, GetResourceAlternateData_args) result = GetResourceAlternateData_result.new() begin result.success = @handler.getResourceAlternateData(args.authenticationToken, args.guid) rescue Evernote::EDAM::Error::EDAMUserException => userException result.userException = userException rescue Evernote::EDAM::Error::EDAMSystemException => systemException result.systemException = systemException rescue Evernote::EDAM::Error::EDAMNotFoundException => notFoundException result.notFoundException = notFoundException end write_result(result, oprot, 'getResourceAlternateData', seqid) end def process_getResourceAttributes(seqid, iprot, oprot) args = read_args(iprot, GetResourceAttributes_args) result = GetResourceAttributes_result.new() begin result.success = @handler.getResourceAttributes(args.authenticationToken, args.guid) rescue Evernote::EDAM::Error::EDAMUserException => userException result.userException = userException rescue Evernote::EDAM::Error::EDAMSystemException => systemException result.systemException = systemException rescue Evernote::EDAM::Error::EDAMNotFoundException => notFoundException result.notFoundException = notFoundException end write_result(result, oprot, 'getResourceAttributes', seqid) end def process_getAccountSize(seqid, iprot, oprot) args = read_args(iprot, GetAccountSize_args) result = GetAccountSize_result.new() begin result.success = @handler.getAccountSize(args.authenticationToken) rescue Evernote::EDAM::Error::EDAMUserException => userException result.userException = userException rescue Evernote::EDAM::Error::EDAMSystemException => systemException result.systemException = systemException end write_result(result, oprot, 'getAccountSize', seqid) end def process_getAds(seqid, iprot, oprot) args = read_args(iprot, GetAds_args) result = GetAds_result.new() begin result.success = @handler.getAds(args.authenticationToken, args.adParameters) rescue Evernote::EDAM::Error::EDAMUserException => userException result.userException = userException rescue Evernote::EDAM::Error::EDAMSystemException => systemException result.systemException = systemException end write_result(result, oprot, 'getAds', seqid) end def process_getRandomAd(seqid, iprot, oprot) args = read_args(iprot, GetRandomAd_args) result = GetRandomAd_result.new() begin result.success = @handler.getRandomAd(args.authenticationToken, args.adParameters) rescue Evernote::EDAM::Error::EDAMUserException => userException result.userException = userException rescue Evernote::EDAM::Error::EDAMSystemException => systemException result.systemException = systemException end write_result(result, oprot, 'getRandomAd', seqid) end def process_getPublicNotebook(seqid, iprot, oprot) args = read_args(iprot, GetPublicNotebook_args) result = GetPublicNotebook_result.new() begin result.success = @handler.getPublicNotebook(args.userId, args.publicUri) rescue Evernote::EDAM::Error::EDAMSystemException => systemException result.systemException = systemException rescue Evernote::EDAM::Error::EDAMNotFoundException => notFoundException result.notFoundException = notFoundException end write_result(result, oprot, 'getPublicNotebook', seqid) end def process_createSharedNotebook(seqid, iprot, oprot) args = read_args(iprot, CreateSharedNotebook_args) result = CreateSharedNotebook_result.new() begin result.success = @handler.createSharedNotebook(args.authenticationToken, args.sharedNotebook) rescue Evernote::EDAM::Error::EDAMUserException => userException result.userException = userException rescue Evernote::EDAM::Error::EDAMNotFoundException => notFoundException result.notFoundException = notFoundException rescue Evernote::EDAM::Error::EDAMSystemException => systemException result.systemException = systemException end write_result(result, oprot, 'createSharedNotebook', seqid) end def process_listSharedNotebooks(seqid, iprot, oprot) args = read_args(iprot, ListSharedNotebooks_args) result = ListSharedNotebooks_result.new() begin result.success = @handler.listSharedNotebooks(args.authenticationToken) rescue Evernote::EDAM::Error::EDAMUserException => userException result.userException = userException rescue Evernote::EDAM::Error::EDAMNotFoundException => notFoundException result.notFoundException = notFoundException rescue Evernote::EDAM::Error::EDAMSystemException => systemException result.systemException = systemException end write_result(result, oprot, 'listSharedNotebooks', seqid) end def process_expungeSharedNotebooks(seqid, iprot, oprot) args = read_args(iprot, ExpungeSharedNotebooks_args) result = ExpungeSharedNotebooks_result.new() begin result.success = @handler.expungeSharedNotebooks(args.authenticationToken, args.sharedNotebookIds) rescue Evernote::EDAM::Error::EDAMUserException => userException result.userException = userException rescue Evernote::EDAM::Error::EDAMNotFoundException => notFoundException result.notFoundException = notFoundException rescue Evernote::EDAM::Error::EDAMSystemException => systemException result.systemException = systemException end write_result(result, oprot, 'expungeSharedNotebooks', seqid) end def process_createLinkedNotebook(seqid, iprot, oprot) args = read_args(iprot, CreateLinkedNotebook_args) result = CreateLinkedNotebook_result.new() begin result.success = @handler.createLinkedNotebook(args.authenticationToken, args.linkedNotebook) rescue Evernote::EDAM::Error::EDAMUserException => userException result.userException = userException rescue Evernote::EDAM::Error::EDAMNotFoundException => notFoundException result.notFoundException = notFoundException rescue Evernote::EDAM::Error::EDAMSystemException => systemException result.systemException = systemException end write_result(result, oprot, 'createLinkedNotebook', seqid) end def process_updateLinkedNotebook(seqid, iprot, oprot) args = read_args(iprot, UpdateLinkedNotebook_args) result = UpdateLinkedNotebook_result.new() begin result.success = @handler.updateLinkedNotebook(args.authenticationToken, args.linkedNotebook) rescue Evernote::EDAM::Error::EDAMUserException => userException result.userException = userException rescue Evernote::EDAM::Error::EDAMNotFoundException => notFoundException result.notFoundException = notFoundException rescue Evernote::EDAM::Error::EDAMSystemException => systemException result.systemException = systemException end write_result(result, oprot, 'updateLinkedNotebook', seqid) end def process_listLinkedNotebooks(seqid, iprot, oprot) args = read_args(iprot, ListLinkedNotebooks_args) result = ListLinkedNotebooks_result.new() begin result.success = @handler.listLinkedNotebooks(args.authenticationToken) rescue Evernote::EDAM::Error::EDAMUserException => userException result.userException = userException rescue Evernote::EDAM::Error::EDAMNotFoundException => notFoundException result.notFoundException = notFoundException rescue Evernote::EDAM::Error::EDAMSystemException => systemException result.systemException = systemException end write_result(result, oprot, 'listLinkedNotebooks', seqid) end def process_expungeLinkedNotebook(seqid, iprot, oprot) args = read_args(iprot, ExpungeLinkedNotebook_args) result = ExpungeLinkedNotebook_result.new() begin result.success = @handler.expungeLinkedNotebook(args.authenticationToken, args.linkedNotebookId) rescue Evernote::EDAM::Error::EDAMUserException => userException result.userException = userException rescue Evernote::EDAM::Error::EDAMNotFoundException => notFoundException result.notFoundException = notFoundException rescue Evernote::EDAM::Error::EDAMSystemException => systemException result.systemException = systemException end write_result(result, oprot, 'expungeLinkedNotebook', seqid) end def process_authenticateToSharedNotebook(seqid, iprot, oprot) args = read_args(iprot, AuthenticateToSharedNotebook_args) result = AuthenticateToSharedNotebook_result.new() begin result.success = @handler.authenticateToSharedNotebook(args.shareKey, args.authenticationToken) rescue Evernote::EDAM::Error::EDAMUserException => userException result.userException = userException rescue Evernote::EDAM::Error::EDAMNotFoundException => notFoundException result.notFoundException = notFoundException rescue Evernote::EDAM::Error::EDAMSystemException => systemException result.systemException = systemException end write_result(result, oprot, 'authenticateToSharedNotebook', seqid) end def process_getSharedNotebookByAuth(seqid, iprot, oprot) args = read_args(iprot, GetSharedNotebookByAuth_args) result = GetSharedNotebookByAuth_result.new() begin result.success = @handler.getSharedNotebookByAuth(args.authenticationToken) rescue Evernote::EDAM::Error::EDAMUserException => userException result.userException = userException rescue Evernote::EDAM::Error::EDAMNotFoundException => notFoundException result.notFoundException = notFoundException rescue Evernote::EDAM::Error::EDAMSystemException => systemException result.systemException = systemException end write_result(result, oprot, 'getSharedNotebookByAuth', seqid) end def process_emailNote(seqid, iprot, oprot) args = read_args(iprot, EmailNote_args) result = EmailNote_result.new() begin @handler.emailNote(args.authenticationToken, args.parameters) rescue Evernote::EDAM::Error::EDAMUserException => userException result.userException = userException rescue Evernote::EDAM::Error::EDAMNotFoundException => notFoundException result.notFoundException = notFoundException rescue Evernote::EDAM::Error::EDAMSystemException => systemException result.systemException = systemException end write_result(result, oprot, 'emailNote', seqid) end end # HELPER FUNCTIONS AND STRUCTURES class GetSyncState_args include ::Thrift::Struct, ::Thrift::Struct_Union AUTHENTICATIONTOKEN = 1 FIELDS = { AUTHENTICATIONTOKEN => {:type => ::Thrift::Types::STRING, :name => 'authenticationToken'} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end class GetSyncState_result include ::Thrift::Struct, ::Thrift::Struct_Union SUCCESS = 0 USEREXCEPTION = 1 SYSTEMEXCEPTION = 2 FIELDS = { SUCCESS => {:type => ::Thrift::Types::STRUCT, :name => 'success', :class => Evernote::EDAM::NoteStore::SyncState}, USEREXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'userException', :class => Evernote::EDAM::Error::EDAMUserException}, SYSTEMEXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'systemException', :class => Evernote::EDAM::Error::EDAMSystemException} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end class GetSyncChunk_args include ::Thrift::Struct, ::Thrift::Struct_Union AUTHENTICATIONTOKEN = 1 AFTERUSN = 2 MAXENTRIES = 3 FULLSYNCONLY = 4 FIELDS = { AUTHENTICATIONTOKEN => {:type => ::Thrift::Types::STRING, :name => 'authenticationToken'}, AFTERUSN => {:type => ::Thrift::Types::I32, :name => 'afterUSN'}, MAXENTRIES => {:type => ::Thrift::Types::I32, :name => 'maxEntries'}, FULLSYNCONLY => {:type => ::Thrift::Types::BOOL, :name => 'fullSyncOnly'} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end class GetSyncChunk_result include ::Thrift::Struct, ::Thrift::Struct_Union SUCCESS = 0 USEREXCEPTION = 1 SYSTEMEXCEPTION = 2 FIELDS = { SUCCESS => {:type => ::Thrift::Types::STRUCT, :name => 'success', :class => Evernote::EDAM::NoteStore::SyncChunk}, USEREXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'userException', :class => Evernote::EDAM::Error::EDAMUserException}, SYSTEMEXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'systemException', :class => Evernote::EDAM::Error::EDAMSystemException} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end class ListNotebooks_args include ::Thrift::Struct, ::Thrift::Struct_Union AUTHENTICATIONTOKEN = 1 FIELDS = { AUTHENTICATIONTOKEN => {:type => ::Thrift::Types::STRING, :name => 'authenticationToken'} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end class ListNotebooks_result include ::Thrift::Struct, ::Thrift::Struct_Union SUCCESS = 0 USEREXCEPTION = 1 SYSTEMEXCEPTION = 2 FIELDS = { SUCCESS => {:type => ::Thrift::Types::LIST, :name => 'success', :element => {:type => ::Thrift::Types::STRUCT, :class => Evernote::EDAM::Type::Notebook}}, USEREXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'userException', :class => Evernote::EDAM::Error::EDAMUserException}, SYSTEMEXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'systemException', :class => Evernote::EDAM::Error::EDAMSystemException} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end class GetNotebook_args include ::Thrift::Struct, ::Thrift::Struct_Union AUTHENTICATIONTOKEN = 1 GUID = 2 FIELDS = { AUTHENTICATIONTOKEN => {:type => ::Thrift::Types::STRING, :name => 'authenticationToken'}, GUID => {:type => ::Thrift::Types::STRING, :name => 'guid'} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end class GetNotebook_result include ::Thrift::Struct, ::Thrift::Struct_Union SUCCESS = 0 USEREXCEPTION = 1 SYSTEMEXCEPTION = 2 NOTFOUNDEXCEPTION = 3 FIELDS = { SUCCESS => {:type => ::Thrift::Types::STRUCT, :name => 'success', :class => Evernote::EDAM::Type::Notebook}, USEREXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'userException', :class => Evernote::EDAM::Error::EDAMUserException}, SYSTEMEXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'systemException', :class => Evernote::EDAM::Error::EDAMSystemException}, NOTFOUNDEXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'notFoundException', :class => Evernote::EDAM::Error::EDAMNotFoundException} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end class GetDefaultNotebook_args include ::Thrift::Struct, ::Thrift::Struct_Union AUTHENTICATIONTOKEN = 1 FIELDS = { AUTHENTICATIONTOKEN => {:type => ::Thrift::Types::STRING, :name => 'authenticationToken'} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end class GetDefaultNotebook_result include ::Thrift::Struct, ::Thrift::Struct_Union SUCCESS = 0 USEREXCEPTION = 1 SYSTEMEXCEPTION = 2 FIELDS = { SUCCESS => {:type => ::Thrift::Types::STRUCT, :name => 'success', :class => Evernote::EDAM::Type::Notebook}, USEREXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'userException', :class => Evernote::EDAM::Error::EDAMUserException}, SYSTEMEXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'systemException', :class => Evernote::EDAM::Error::EDAMSystemException} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end class CreateNotebook_args include ::Thrift::Struct, ::Thrift::Struct_Union AUTHENTICATIONTOKEN = 1 NOTEBOOK = 2 FIELDS = { AUTHENTICATIONTOKEN => {:type => ::Thrift::Types::STRING, :name => 'authenticationToken'}, NOTEBOOK => {:type => ::Thrift::Types::STRUCT, :name => 'notebook', :class => Evernote::EDAM::Type::Notebook} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end class CreateNotebook_result include ::Thrift::Struct, ::Thrift::Struct_Union SUCCESS = 0 USEREXCEPTION = 1 SYSTEMEXCEPTION = 2 FIELDS = { SUCCESS => {:type => ::Thrift::Types::STRUCT, :name => 'success', :class => Evernote::EDAM::Type::Notebook}, USEREXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'userException', :class => Evernote::EDAM::Error::EDAMUserException}, SYSTEMEXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'systemException', :class => Evernote::EDAM::Error::EDAMSystemException} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end class UpdateNotebook_args include ::Thrift::Struct, ::Thrift::Struct_Union AUTHENTICATIONTOKEN = 1 NOTEBOOK = 2 FIELDS = { AUTHENTICATIONTOKEN => {:type => ::Thrift::Types::STRING, :name => 'authenticationToken'}, NOTEBOOK => {:type => ::Thrift::Types::STRUCT, :name => 'notebook', :class => Evernote::EDAM::Type::Notebook} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end class UpdateNotebook_result include ::Thrift::Struct, ::Thrift::Struct_Union SUCCESS = 0 USEREXCEPTION = 1 SYSTEMEXCEPTION = 2 NOTFOUNDEXCEPTION = 3 FIELDS = { SUCCESS => {:type => ::Thrift::Types::I32, :name => 'success'}, USEREXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'userException', :class => Evernote::EDAM::Error::EDAMUserException}, SYSTEMEXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'systemException', :class => Evernote::EDAM::Error::EDAMSystemException}, NOTFOUNDEXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'notFoundException', :class => Evernote::EDAM::Error::EDAMNotFoundException} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end class ExpungeNotebook_args include ::Thrift::Struct, ::Thrift::Struct_Union AUTHENTICATIONTOKEN = 1 GUID = 2 FIELDS = { AUTHENTICATIONTOKEN => {:type => ::Thrift::Types::STRING, :name => 'authenticationToken'}, GUID => {:type => ::Thrift::Types::STRING, :name => 'guid'} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end class ExpungeNotebook_result include ::Thrift::Struct, ::Thrift::Struct_Union SUCCESS = 0 USEREXCEPTION = 1 SYSTEMEXCEPTION = 2 NOTFOUNDEXCEPTION = 3 FIELDS = { SUCCESS => {:type => ::Thrift::Types::I32, :name => 'success'}, USEREXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'userException', :class => Evernote::EDAM::Error::EDAMUserException}, SYSTEMEXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'systemException', :class => Evernote::EDAM::Error::EDAMSystemException}, NOTFOUNDEXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'notFoundException', :class => Evernote::EDAM::Error::EDAMNotFoundException} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end class ListTags_args include ::Thrift::Struct, ::Thrift::Struct_Union AUTHENTICATIONTOKEN = 1 FIELDS = { AUTHENTICATIONTOKEN => {:type => ::Thrift::Types::STRING, :name => 'authenticationToken'} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end class ListTags_result include ::Thrift::Struct, ::Thrift::Struct_Union SUCCESS = 0 USEREXCEPTION = 1 SYSTEMEXCEPTION = 2 FIELDS = { SUCCESS => {:type => ::Thrift::Types::LIST, :name => 'success', :element => {:type => ::Thrift::Types::STRUCT, :class => Evernote::EDAM::Type::Tag}}, USEREXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'userException', :class => Evernote::EDAM::Error::EDAMUserException}, SYSTEMEXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'systemException', :class => Evernote::EDAM::Error::EDAMSystemException} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end class ListTagsByNotebook_args include ::Thrift::Struct, ::Thrift::Struct_Union AUTHENTICATIONTOKEN = 1 NOTEBOOKGUID = 2 FIELDS = { AUTHENTICATIONTOKEN => {:type => ::Thrift::Types::STRING, :name => 'authenticationToken'}, NOTEBOOKGUID => {:type => ::Thrift::Types::STRING, :name => 'notebookGuid'} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end class ListTagsByNotebook_result include ::Thrift::Struct, ::Thrift::Struct_Union SUCCESS = 0 USEREXCEPTION = 1 SYSTEMEXCEPTION = 2 NOTFOUNDEXCEPTION = 3 FIELDS = { SUCCESS => {:type => ::Thrift::Types::LIST, :name => 'success', :element => {:type => ::Thrift::Types::STRUCT, :class => Evernote::EDAM::Type::Tag}}, USEREXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'userException', :class => Evernote::EDAM::Error::EDAMUserException}, SYSTEMEXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'systemException', :class => Evernote::EDAM::Error::EDAMSystemException}, NOTFOUNDEXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'notFoundException', :class => Evernote::EDAM::Error::EDAMNotFoundException} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end class GetTag_args include ::Thrift::Struct, ::Thrift::Struct_Union AUTHENTICATIONTOKEN = 1 GUID = 2 FIELDS = { AUTHENTICATIONTOKEN => {:type => ::Thrift::Types::STRING, :name => 'authenticationToken'}, GUID => {:type => ::Thrift::Types::STRING, :name => 'guid'} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end class GetTag_result include ::Thrift::Struct, ::Thrift::Struct_Union SUCCESS = 0 USEREXCEPTION = 1 SYSTEMEXCEPTION = 2 NOTFOUNDEXCEPTION = 3 FIELDS = { SUCCESS => {:type => ::Thrift::Types::STRUCT, :name => 'success', :class => Evernote::EDAM::Type::Tag}, USEREXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'userException', :class => Evernote::EDAM::Error::EDAMUserException}, SYSTEMEXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'systemException', :class => Evernote::EDAM::Error::EDAMSystemException}, NOTFOUNDEXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'notFoundException', :class => Evernote::EDAM::Error::EDAMNotFoundException} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end class CreateTag_args include ::Thrift::Struct, ::Thrift::Struct_Union AUTHENTICATIONTOKEN = 1 TAG = 2 FIELDS = { AUTHENTICATIONTOKEN => {:type => ::Thrift::Types::STRING, :name => 'authenticationToken'}, TAG => {:type => ::Thrift::Types::STRUCT, :name => 'tag', :class => Evernote::EDAM::Type::Tag} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end class CreateTag_result include ::Thrift::Struct, ::Thrift::Struct_Union SUCCESS = 0 USEREXCEPTION = 1 SYSTEMEXCEPTION = 2 NOTFOUNDEXCEPTION = 3 FIELDS = { SUCCESS => {:type => ::Thrift::Types::STRUCT, :name => 'success', :class => Evernote::EDAM::Type::Tag}, USEREXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'userException', :class => Evernote::EDAM::Error::EDAMUserException}, SYSTEMEXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'systemException', :class => Evernote::EDAM::Error::EDAMSystemException}, NOTFOUNDEXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'notFoundException', :class => Evernote::EDAM::Error::EDAMNotFoundException} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end class UpdateTag_args include ::Thrift::Struct, ::Thrift::Struct_Union AUTHENTICATIONTOKEN = 1 TAG = 2 FIELDS = { AUTHENTICATIONTOKEN => {:type => ::Thrift::Types::STRING, :name => 'authenticationToken'}, TAG => {:type => ::Thrift::Types::STRUCT, :name => 'tag', :class => Evernote::EDAM::Type::Tag} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end class UpdateTag_result include ::Thrift::Struct, ::Thrift::Struct_Union SUCCESS = 0 USEREXCEPTION = 1 SYSTEMEXCEPTION = 2 NOTFOUNDEXCEPTION = 3 FIELDS = { SUCCESS => {:type => ::Thrift::Types::I32, :name => 'success'}, USEREXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'userException', :class => Evernote::EDAM::Error::EDAMUserException}, SYSTEMEXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'systemException', :class => Evernote::EDAM::Error::EDAMSystemException}, NOTFOUNDEXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'notFoundException', :class => Evernote::EDAM::Error::EDAMNotFoundException} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end class UntagAll_args include ::Thrift::Struct, ::Thrift::Struct_Union AUTHENTICATIONTOKEN = 1 GUID = 2 FIELDS = { AUTHENTICATIONTOKEN => {:type => ::Thrift::Types::STRING, :name => 'authenticationToken'}, GUID => {:type => ::Thrift::Types::STRING, :name => 'guid'} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end class UntagAll_result include ::Thrift::Struct, ::Thrift::Struct_Union USEREXCEPTION = 1 SYSTEMEXCEPTION = 2 NOTFOUNDEXCEPTION = 3 FIELDS = { USEREXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'userException', :class => Evernote::EDAM::Error::EDAMUserException}, SYSTEMEXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'systemException', :class => Evernote::EDAM::Error::EDAMSystemException}, NOTFOUNDEXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'notFoundException', :class => Evernote::EDAM::Error::EDAMNotFoundException} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end class ExpungeTag_args include ::Thrift::Struct, ::Thrift::Struct_Union AUTHENTICATIONTOKEN = 1 GUID = 2 FIELDS = { AUTHENTICATIONTOKEN => {:type => ::Thrift::Types::STRING, :name => 'authenticationToken'}, GUID => {:type => ::Thrift::Types::STRING, :name => 'guid'} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end class ExpungeTag_result include ::Thrift::Struct, ::Thrift::Struct_Union SUCCESS = 0 USEREXCEPTION = 1 SYSTEMEXCEPTION = 2 NOTFOUNDEXCEPTION = 3 FIELDS = { SUCCESS => {:type => ::Thrift::Types::I32, :name => 'success'}, USEREXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'userException', :class => Evernote::EDAM::Error::EDAMUserException}, SYSTEMEXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'systemException', :class => Evernote::EDAM::Error::EDAMSystemException}, NOTFOUNDEXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'notFoundException', :class => Evernote::EDAM::Error::EDAMNotFoundException} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end class ListSearches_args include ::Thrift::Struct, ::Thrift::Struct_Union AUTHENTICATIONTOKEN = 1 FIELDS = { AUTHENTICATIONTOKEN => {:type => ::Thrift::Types::STRING, :name => 'authenticationToken'} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end class ListSearches_result include ::Thrift::Struct, ::Thrift::Struct_Union SUCCESS = 0 USEREXCEPTION = 1 SYSTEMEXCEPTION = 2 FIELDS = { SUCCESS => {:type => ::Thrift::Types::LIST, :name => 'success', :element => {:type => ::Thrift::Types::STRUCT, :class => Evernote::EDAM::Type::SavedSearch}}, USEREXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'userException', :class => Evernote::EDAM::Error::EDAMUserException}, SYSTEMEXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'systemException', :class => Evernote::EDAM::Error::EDAMSystemException} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end class GetSearch_args include ::Thrift::Struct, ::Thrift::Struct_Union AUTHENTICATIONTOKEN = 1 GUID = 2 FIELDS = { AUTHENTICATIONTOKEN => {:type => ::Thrift::Types::STRING, :name => 'authenticationToken'}, GUID => {:type => ::Thrift::Types::STRING, :name => 'guid'} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end class GetSearch_result include ::Thrift::Struct, ::Thrift::Struct_Union SUCCESS = 0 USEREXCEPTION = 1 SYSTEMEXCEPTION = 2 NOTFOUNDEXCEPTION = 3 FIELDS = { SUCCESS => {:type => ::Thrift::Types::STRUCT, :name => 'success', :class => Evernote::EDAM::Type::SavedSearch}, USEREXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'userException', :class => Evernote::EDAM::Error::EDAMUserException}, SYSTEMEXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'systemException', :class => Evernote::EDAM::Error::EDAMSystemException}, NOTFOUNDEXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'notFoundException', :class => Evernote::EDAM::Error::EDAMNotFoundException} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end class CreateSearch_args include ::Thrift::Struct, ::Thrift::Struct_Union AUTHENTICATIONTOKEN = 1 SEARCH = 2 FIELDS = { AUTHENTICATIONTOKEN => {:type => ::Thrift::Types::STRING, :name => 'authenticationToken'}, SEARCH => {:type => ::Thrift::Types::STRUCT, :name => 'search', :class => Evernote::EDAM::Type::SavedSearch} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end class CreateSearch_result include ::Thrift::Struct, ::Thrift::Struct_Union SUCCESS = 0 USEREXCEPTION = 1 SYSTEMEXCEPTION = 2 FIELDS = { SUCCESS => {:type => ::Thrift::Types::STRUCT, :name => 'success', :class => Evernote::EDAM::Type::SavedSearch}, USEREXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'userException', :class => Evernote::EDAM::Error::EDAMUserException}, SYSTEMEXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'systemException', :class => Evernote::EDAM::Error::EDAMSystemException} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end class UpdateSearch_args include ::Thrift::Struct, ::Thrift::Struct_Union AUTHENTICATIONTOKEN = 1 SEARCH = 2 FIELDS = { AUTHENTICATIONTOKEN => {:type => ::Thrift::Types::STRING, :name => 'authenticationToken'}, SEARCH => {:type => ::Thrift::Types::STRUCT, :name => 'search', :class => Evernote::EDAM::Type::SavedSearch} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end class UpdateSearch_result include ::Thrift::Struct, ::Thrift::Struct_Union SUCCESS = 0 USEREXCEPTION = 1 SYSTEMEXCEPTION = 2 NOTFOUNDEXCEPTION = 3 FIELDS = { SUCCESS => {:type => ::Thrift::Types::I32, :name => 'success'}, USEREXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'userException', :class => Evernote::EDAM::Error::EDAMUserException}, SYSTEMEXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'systemException', :class => Evernote::EDAM::Error::EDAMSystemException}, NOTFOUNDEXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'notFoundException', :class => Evernote::EDAM::Error::EDAMNotFoundException} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end class ExpungeSearch_args include ::Thrift::Struct, ::Thrift::Struct_Union AUTHENTICATIONTOKEN = 1 GUID = 2 FIELDS = { AUTHENTICATIONTOKEN => {:type => ::Thrift::Types::STRING, :name => 'authenticationToken'}, GUID => {:type => ::Thrift::Types::STRING, :name => 'guid'} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end class ExpungeSearch_result include ::Thrift::Struct, ::Thrift::Struct_Union SUCCESS = 0 USEREXCEPTION = 1 SYSTEMEXCEPTION = 2 NOTFOUNDEXCEPTION = 3 FIELDS = { SUCCESS => {:type => ::Thrift::Types::I32, :name => 'success'}, USEREXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'userException', :class => Evernote::EDAM::Error::EDAMUserException}, SYSTEMEXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'systemException', :class => Evernote::EDAM::Error::EDAMSystemException}, NOTFOUNDEXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'notFoundException', :class => Evernote::EDAM::Error::EDAMNotFoundException} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end class FindNotes_args include ::Thrift::Struct, ::Thrift::Struct_Union AUTHENTICATIONTOKEN = 1 FILTER = 2 OFFSET = 3 MAXNOTES = 4 FIELDS = { AUTHENTICATIONTOKEN => {:type => ::Thrift::Types::STRING, :name => 'authenticationToken'}, FILTER => {:type => ::Thrift::Types::STRUCT, :name => 'filter', :class => Evernote::EDAM::NoteStore::NoteFilter}, OFFSET => {:type => ::Thrift::Types::I32, :name => 'offset'}, MAXNOTES => {:type => ::Thrift::Types::I32, :name => 'maxNotes'} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end class FindNotes_result include ::Thrift::Struct, ::Thrift::Struct_Union SUCCESS = 0 USEREXCEPTION = 1 SYSTEMEXCEPTION = 2 NOTFOUNDEXCEPTION = 3 FIELDS = { SUCCESS => {:type => ::Thrift::Types::STRUCT, :name => 'success', :class => Evernote::EDAM::NoteStore::NoteList}, USEREXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'userException', :class => Evernote::EDAM::Error::EDAMUserException}, SYSTEMEXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'systemException', :class => Evernote::EDAM::Error::EDAMSystemException}, NOTFOUNDEXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'notFoundException', :class => Evernote::EDAM::Error::EDAMNotFoundException} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end class FindNoteCounts_args include ::Thrift::Struct, ::Thrift::Struct_Union AUTHENTICATIONTOKEN = 1 FILTER = 2 WITHTRASH = 3 FIELDS = { AUTHENTICATIONTOKEN => {:type => ::Thrift::Types::STRING, :name => 'authenticationToken'}, FILTER => {:type => ::Thrift::Types::STRUCT, :name => 'filter', :class => Evernote::EDAM::NoteStore::NoteFilter}, WITHTRASH => {:type => ::Thrift::Types::BOOL, :name => 'withTrash'} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end class FindNoteCounts_result include ::Thrift::Struct, ::Thrift::Struct_Union SUCCESS = 0 USEREXCEPTION = 1 SYSTEMEXCEPTION = 2 NOTFOUNDEXCEPTION = 3 FIELDS = { SUCCESS => {:type => ::Thrift::Types::STRUCT, :name => 'success', :class => Evernote::EDAM::NoteStore::NoteCollectionCounts}, USEREXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'userException', :class => Evernote::EDAM::Error::EDAMUserException}, SYSTEMEXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'systemException', :class => Evernote::EDAM::Error::EDAMSystemException}, NOTFOUNDEXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'notFoundException', :class => Evernote::EDAM::Error::EDAMNotFoundException} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end class GetNote_args include ::Thrift::Struct, ::Thrift::Struct_Union AUTHENTICATIONTOKEN = 1 GUID = 2 WITHCONTENT = 3 WITHRESOURCESDATA = 4 WITHRESOURCESRECOGNITION = 5 WITHRESOURCESALTERNATEDATA = 6 FIELDS = { AUTHENTICATIONTOKEN => {:type => ::Thrift::Types::STRING, :name => 'authenticationToken'}, GUID => {:type => ::Thrift::Types::STRING, :name => 'guid'}, WITHCONTENT => {:type => ::Thrift::Types::BOOL, :name => 'withContent'}, WITHRESOURCESDATA => {:type => ::Thrift::Types::BOOL, :name => 'withResourcesData'}, WITHRESOURCESRECOGNITION => {:type => ::Thrift::Types::BOOL, :name => 'withResourcesRecognition'}, WITHRESOURCESALTERNATEDATA => {:type => ::Thrift::Types::BOOL, :name => 'withResourcesAlternateData'} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end class GetNote_result include ::Thrift::Struct, ::Thrift::Struct_Union SUCCESS = 0 USEREXCEPTION = 1 SYSTEMEXCEPTION = 2 NOTFOUNDEXCEPTION = 3 FIELDS = { SUCCESS => {:type => ::Thrift::Types::STRUCT, :name => 'success', :class => Evernote::EDAM::Type::Note}, USEREXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'userException', :class => Evernote::EDAM::Error::EDAMUserException}, SYSTEMEXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'systemException', :class => Evernote::EDAM::Error::EDAMSystemException}, NOTFOUNDEXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'notFoundException', :class => Evernote::EDAM::Error::EDAMNotFoundException} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end class GetNoteContent_args include ::Thrift::Struct, ::Thrift::Struct_Union AUTHENTICATIONTOKEN = 1 GUID = 2 FIELDS = { AUTHENTICATIONTOKEN => {:type => ::Thrift::Types::STRING, :name => 'authenticationToken'}, GUID => {:type => ::Thrift::Types::STRING, :name => 'guid'} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end class GetNoteContent_result include ::Thrift::Struct, ::Thrift::Struct_Union SUCCESS = 0 USEREXCEPTION = 1 SYSTEMEXCEPTION = 2 NOTFOUNDEXCEPTION = 3 FIELDS = { SUCCESS => {:type => ::Thrift::Types::STRING, :name => 'success'}, USEREXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'userException', :class => Evernote::EDAM::Error::EDAMUserException}, SYSTEMEXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'systemException', :class => Evernote::EDAM::Error::EDAMSystemException}, NOTFOUNDEXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'notFoundException', :class => Evernote::EDAM::Error::EDAMNotFoundException} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end class GetNoteSearchText_args include ::Thrift::Struct, ::Thrift::Struct_Union AUTHENTICATIONTOKEN = 1 GUID = 2 FIELDS = { AUTHENTICATIONTOKEN => {:type => ::Thrift::Types::STRING, :name => 'authenticationToken'}, GUID => {:type => ::Thrift::Types::STRING, :name => 'guid'} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end class GetNoteSearchText_result include ::Thrift::Struct, ::Thrift::Struct_Union SUCCESS = 0 USEREXCEPTION = 1 SYSTEMEXCEPTION = 2 NOTFOUNDEXCEPTION = 3 FIELDS = { SUCCESS => {:type => ::Thrift::Types::STRING, :name => 'success'}, USEREXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'userException', :class => Evernote::EDAM::Error::EDAMUserException}, SYSTEMEXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'systemException', :class => Evernote::EDAM::Error::EDAMSystemException}, NOTFOUNDEXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'notFoundException', :class => Evernote::EDAM::Error::EDAMNotFoundException} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end class GetNoteTagNames_args include ::Thrift::Struct, ::Thrift::Struct_Union AUTHENTICATIONTOKEN = 1 GUID = 2 FIELDS = { AUTHENTICATIONTOKEN => {:type => ::Thrift::Types::STRING, :name => 'authenticationToken'}, GUID => {:type => ::Thrift::Types::STRING, :name => 'guid'} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end class GetNoteTagNames_result include ::Thrift::Struct, ::Thrift::Struct_Union SUCCESS = 0 USEREXCEPTION = 1 SYSTEMEXCEPTION = 2 NOTFOUNDEXCEPTION = 3 FIELDS = { SUCCESS => {:type => ::Thrift::Types::LIST, :name => 'success', :element => {:type => ::Thrift::Types::STRING}}, USEREXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'userException', :class => Evernote::EDAM::Error::EDAMUserException}, SYSTEMEXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'systemException', :class => Evernote::EDAM::Error::EDAMSystemException}, NOTFOUNDEXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'notFoundException', :class => Evernote::EDAM::Error::EDAMNotFoundException} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end class CreateNote_args include ::Thrift::Struct, ::Thrift::Struct_Union AUTHENTICATIONTOKEN = 1 NOTE = 2 FIELDS = { AUTHENTICATIONTOKEN => {:type => ::Thrift::Types::STRING, :name => 'authenticationToken'}, NOTE => {:type => ::Thrift::Types::STRUCT, :name => 'note', :class => Evernote::EDAM::Type::Note} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end class CreateNote_result include ::Thrift::Struct, ::Thrift::Struct_Union SUCCESS = 0 USEREXCEPTION = 1 SYSTEMEXCEPTION = 2 NOTFOUNDEXCEPTION = 3 FIELDS = { SUCCESS => {:type => ::Thrift::Types::STRUCT, :name => 'success', :class => Evernote::EDAM::Type::Note}, USEREXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'userException', :class => Evernote::EDAM::Error::EDAMUserException}, SYSTEMEXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'systemException', :class => Evernote::EDAM::Error::EDAMSystemException}, NOTFOUNDEXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'notFoundException', :class => Evernote::EDAM::Error::EDAMNotFoundException} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end class UpdateNote_args include ::Thrift::Struct, ::Thrift::Struct_Union AUTHENTICATIONTOKEN = 1 NOTE = 2 FIELDS = { AUTHENTICATIONTOKEN => {:type => ::Thrift::Types::STRING, :name => 'authenticationToken'}, NOTE => {:type => ::Thrift::Types::STRUCT, :name => 'note', :class => Evernote::EDAM::Type::Note} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end class UpdateNote_result include ::Thrift::Struct, ::Thrift::Struct_Union SUCCESS = 0 USEREXCEPTION = 1 SYSTEMEXCEPTION = 2 NOTFOUNDEXCEPTION = 3 FIELDS = { SUCCESS => {:type => ::Thrift::Types::STRUCT, :name => 'success', :class => Evernote::EDAM::Type::Note}, USEREXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'userException', :class => Evernote::EDAM::Error::EDAMUserException}, SYSTEMEXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'systemException', :class => Evernote::EDAM::Error::EDAMSystemException}, NOTFOUNDEXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'notFoundException', :class => Evernote::EDAM::Error::EDAMNotFoundException} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end class DeleteNote_args include ::Thrift::Struct, ::Thrift::Struct_Union AUTHENTICATIONTOKEN = 1 GUID = 2 FIELDS = { AUTHENTICATIONTOKEN => {:type => ::Thrift::Types::STRING, :name => 'authenticationToken'}, GUID => {:type => ::Thrift::Types::STRING, :name => 'guid'} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end class DeleteNote_result include ::Thrift::Struct, ::Thrift::Struct_Union SUCCESS = 0 USEREXCEPTION = 1 SYSTEMEXCEPTION = 2 NOTFOUNDEXCEPTION = 3 FIELDS = { SUCCESS => {:type => ::Thrift::Types::I32, :name => 'success'}, USEREXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'userException', :class => Evernote::EDAM::Error::EDAMUserException}, SYSTEMEXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'systemException', :class => Evernote::EDAM::Error::EDAMSystemException}, NOTFOUNDEXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'notFoundException', :class => Evernote::EDAM::Error::EDAMNotFoundException} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end class ExpungeNote_args include ::Thrift::Struct, ::Thrift::Struct_Union AUTHENTICATIONTOKEN = 1 GUID = 2 FIELDS = { AUTHENTICATIONTOKEN => {:type => ::Thrift::Types::STRING, :name => 'authenticationToken'}, GUID => {:type => ::Thrift::Types::STRING, :name => 'guid'} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end class ExpungeNote_result include ::Thrift::Struct, ::Thrift::Struct_Union SUCCESS = 0 USEREXCEPTION = 1 SYSTEMEXCEPTION = 2 NOTFOUNDEXCEPTION = 3 FIELDS = { SUCCESS => {:type => ::Thrift::Types::I32, :name => 'success'}, USEREXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'userException', :class => Evernote::EDAM::Error::EDAMUserException}, SYSTEMEXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'systemException', :class => Evernote::EDAM::Error::EDAMSystemException}, NOTFOUNDEXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'notFoundException', :class => Evernote::EDAM::Error::EDAMNotFoundException} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end class ExpungeNotes_args include ::Thrift::Struct, ::Thrift::Struct_Union AUTHENTICATIONTOKEN = 1 NOTEGUIDS = 2 FIELDS = { AUTHENTICATIONTOKEN => {:type => ::Thrift::Types::STRING, :name => 'authenticationToken'}, NOTEGUIDS => {:type => ::Thrift::Types::LIST, :name => 'noteGuids', :element => {:type => ::Thrift::Types::STRING}} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end class ExpungeNotes_result include ::Thrift::Struct, ::Thrift::Struct_Union SUCCESS = 0 USEREXCEPTION = 1 SYSTEMEXCEPTION = 2 NOTFOUNDEXCEPTION = 3 FIELDS = { SUCCESS => {:type => ::Thrift::Types::I32, :name => 'success'}, USEREXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'userException', :class => Evernote::EDAM::Error::EDAMUserException}, SYSTEMEXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'systemException', :class => Evernote::EDAM::Error::EDAMSystemException}, NOTFOUNDEXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'notFoundException', :class => Evernote::EDAM::Error::EDAMNotFoundException} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end class ExpungeInactiveNotes_args include ::Thrift::Struct, ::Thrift::Struct_Union AUTHENTICATIONTOKEN = 1 FIELDS = { AUTHENTICATIONTOKEN => {:type => ::Thrift::Types::STRING, :name => 'authenticationToken'} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end class ExpungeInactiveNotes_result include ::Thrift::Struct, ::Thrift::Struct_Union SUCCESS = 0 USEREXCEPTION = 1 SYSTEMEXCEPTION = 2 FIELDS = { SUCCESS => {:type => ::Thrift::Types::I32, :name => 'success'}, USEREXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'userException', :class => Evernote::EDAM::Error::EDAMUserException}, SYSTEMEXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'systemException', :class => Evernote::EDAM::Error::EDAMSystemException} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end class CopyNote_args include ::Thrift::Struct, ::Thrift::Struct_Union AUTHENTICATIONTOKEN = 1 NOTEGUID = 2 TONOTEBOOKGUID = 3 FIELDS = { AUTHENTICATIONTOKEN => {:type => ::Thrift::Types::STRING, :name => 'authenticationToken'}, NOTEGUID => {:type => ::Thrift::Types::STRING, :name => 'noteGuid'}, TONOTEBOOKGUID => {:type => ::Thrift::Types::STRING, :name => 'toNotebookGuid'} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end class CopyNote_result include ::Thrift::Struct, ::Thrift::Struct_Union SUCCESS = 0 USEREXCEPTION = 1 SYSTEMEXCEPTION = 2 NOTFOUNDEXCEPTION = 3 FIELDS = { SUCCESS => {:type => ::Thrift::Types::STRUCT, :name => 'success', :class => Evernote::EDAM::Type::Note}, USEREXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'userException', :class => Evernote::EDAM::Error::EDAMUserException}, SYSTEMEXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'systemException', :class => Evernote::EDAM::Error::EDAMSystemException}, NOTFOUNDEXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'notFoundException', :class => Evernote::EDAM::Error::EDAMNotFoundException} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end class ListNoteVersions_args include ::Thrift::Struct, ::Thrift::Struct_Union AUTHENTICATIONTOKEN = 1 NOTEGUID = 2 FIELDS = { AUTHENTICATIONTOKEN => {:type => ::Thrift::Types::STRING, :name => 'authenticationToken'}, NOTEGUID => {:type => ::Thrift::Types::STRING, :name => 'noteGuid'} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end class ListNoteVersions_result include ::Thrift::Struct, ::Thrift::Struct_Union SUCCESS = 0 USEREXCEPTION = 1 SYSTEMEXCEPTION = 2 NOTFOUNDEXCEPTION = 3 FIELDS = { SUCCESS => {:type => ::Thrift::Types::LIST, :name => 'success', :element => {:type => ::Thrift::Types::STRUCT, :class => Evernote::EDAM::NoteStore::NoteVersionId}}, USEREXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'userException', :class => Evernote::EDAM::Error::EDAMUserException}, SYSTEMEXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'systemException', :class => Evernote::EDAM::Error::EDAMSystemException}, NOTFOUNDEXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'notFoundException', :class => Evernote::EDAM::Error::EDAMNotFoundException} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end class GetNoteVersion_args include ::Thrift::Struct, ::Thrift::Struct_Union AUTHENTICATIONTOKEN = 1 NOTEGUID = 2 UPDATESEQUENCENUM = 3 WITHRESOURCESDATA = 4 WITHRESOURCESRECOGNITION = 5 WITHRESOURCESALTERNATEDATA = 6 FIELDS = { AUTHENTICATIONTOKEN => {:type => ::Thrift::Types::STRING, :name => 'authenticationToken'}, NOTEGUID => {:type => ::Thrift::Types::STRING, :name => 'noteGuid'}, UPDATESEQUENCENUM => {:type => ::Thrift::Types::I32, :name => 'updateSequenceNum'}, WITHRESOURCESDATA => {:type => ::Thrift::Types::BOOL, :name => 'withResourcesData'}, WITHRESOURCESRECOGNITION => {:type => ::Thrift::Types::BOOL, :name => 'withResourcesRecognition'}, WITHRESOURCESALTERNATEDATA => {:type => ::Thrift::Types::BOOL, :name => 'withResourcesAlternateData'} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end class GetNoteVersion_result include ::Thrift::Struct, ::Thrift::Struct_Union SUCCESS = 0 USEREXCEPTION = 1 SYSTEMEXCEPTION = 2 NOTFOUNDEXCEPTION = 3 FIELDS = { SUCCESS => {:type => ::Thrift::Types::STRUCT, :name => 'success', :class => Evernote::EDAM::Type::Note}, USEREXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'userException', :class => Evernote::EDAM::Error::EDAMUserException}, SYSTEMEXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'systemException', :class => Evernote::EDAM::Error::EDAMSystemException}, NOTFOUNDEXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'notFoundException', :class => Evernote::EDAM::Error::EDAMNotFoundException} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end class GetResource_args include ::Thrift::Struct, ::Thrift::Struct_Union AUTHENTICATIONTOKEN = 1 GUID = 2 WITHDATA = 3 WITHRECOGNITION = 4 WITHATTRIBUTES = 5 WITHALTERNATEDATA = 6 FIELDS = { AUTHENTICATIONTOKEN => {:type => ::Thrift::Types::STRING, :name => 'authenticationToken'}, GUID => {:type => ::Thrift::Types::STRING, :name => 'guid'}, WITHDATA => {:type => ::Thrift::Types::BOOL, :name => 'withData'}, WITHRECOGNITION => {:type => ::Thrift::Types::BOOL, :name => 'withRecognition'}, WITHATTRIBUTES => {:type => ::Thrift::Types::BOOL, :name => 'withAttributes'}, WITHALTERNATEDATA => {:type => ::Thrift::Types::BOOL, :name => 'withAlternateData'} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end class GetResource_result include ::Thrift::Struct, ::Thrift::Struct_Union SUCCESS = 0 USEREXCEPTION = 1 SYSTEMEXCEPTION = 2 NOTFOUNDEXCEPTION = 3 FIELDS = { SUCCESS => {:type => ::Thrift::Types::STRUCT, :name => 'success', :class => Evernote::EDAM::Type::Resource}, USEREXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'userException', :class => Evernote::EDAM::Error::EDAMUserException}, SYSTEMEXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'systemException', :class => Evernote::EDAM::Error::EDAMSystemException}, NOTFOUNDEXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'notFoundException', :class => Evernote::EDAM::Error::EDAMNotFoundException} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end class UpdateResource_args include ::Thrift::Struct, ::Thrift::Struct_Union AUTHENTICATIONTOKEN = 1 RESOURCE = 2 FIELDS = { AUTHENTICATIONTOKEN => {:type => ::Thrift::Types::STRING, :name => 'authenticationToken'}, RESOURCE => {:type => ::Thrift::Types::STRUCT, :name => 'resource', :class => Evernote::EDAM::Type::Resource} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end class UpdateResource_result include ::Thrift::Struct, ::Thrift::Struct_Union SUCCESS = 0 USEREXCEPTION = 1 SYSTEMEXCEPTION = 2 NOTFOUNDEXCEPTION = 3 FIELDS = { SUCCESS => {:type => ::Thrift::Types::I32, :name => 'success'}, USEREXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'userException', :class => Evernote::EDAM::Error::EDAMUserException}, SYSTEMEXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'systemException', :class => Evernote::EDAM::Error::EDAMSystemException}, NOTFOUNDEXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'notFoundException', :class => Evernote::EDAM::Error::EDAMNotFoundException} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end class GetResourceData_args include ::Thrift::Struct, ::Thrift::Struct_Union AUTHENTICATIONTOKEN = 1 GUID = 2 FIELDS = { AUTHENTICATIONTOKEN => {:type => ::Thrift::Types::STRING, :name => 'authenticationToken'}, GUID => {:type => ::Thrift::Types::STRING, :name => 'guid'} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end class GetResourceData_result include ::Thrift::Struct, ::Thrift::Struct_Union SUCCESS = 0 USEREXCEPTION = 1 SYSTEMEXCEPTION = 2 NOTFOUNDEXCEPTION = 3 FIELDS = { SUCCESS => {:type => ::Thrift::Types::STRING, :name => 'success', :binary => true}, USEREXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'userException', :class => Evernote::EDAM::Error::EDAMUserException}, SYSTEMEXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'systemException', :class => Evernote::EDAM::Error::EDAMSystemException}, NOTFOUNDEXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'notFoundException', :class => Evernote::EDAM::Error::EDAMNotFoundException} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end class GetResourceByHash_args include ::Thrift::Struct, ::Thrift::Struct_Union AUTHENTICATIONTOKEN = 1 NOTEGUID = 2 CONTENTHASH = 3 WITHDATA = 4 WITHRECOGNITION = 5 WITHALTERNATEDATA = 6 FIELDS = { AUTHENTICATIONTOKEN => {:type => ::Thrift::Types::STRING, :name => 'authenticationToken'}, NOTEGUID => {:type => ::Thrift::Types::STRING, :name => 'noteGuid'}, CONTENTHASH => {:type => ::Thrift::Types::STRING, :name => 'contentHash', :binary => true}, WITHDATA => {:type => ::Thrift::Types::BOOL, :name => 'withData'}, WITHRECOGNITION => {:type => ::Thrift::Types::BOOL, :name => 'withRecognition'}, WITHALTERNATEDATA => {:type => ::Thrift::Types::BOOL, :name => 'withAlternateData'} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end class GetResourceByHash_result include ::Thrift::Struct, ::Thrift::Struct_Union SUCCESS = 0 USEREXCEPTION = 1 SYSTEMEXCEPTION = 2 NOTFOUNDEXCEPTION = 3 FIELDS = { SUCCESS => {:type => ::Thrift::Types::STRUCT, :name => 'success', :class => Evernote::EDAM::Type::Resource}, USEREXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'userException', :class => Evernote::EDAM::Error::EDAMUserException}, SYSTEMEXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'systemException', :class => Evernote::EDAM::Error::EDAMSystemException}, NOTFOUNDEXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'notFoundException', :class => Evernote::EDAM::Error::EDAMNotFoundException} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end class GetResourceRecognition_args include ::Thrift::Struct, ::Thrift::Struct_Union AUTHENTICATIONTOKEN = 1 GUID = 2 FIELDS = { AUTHENTICATIONTOKEN => {:type => ::Thrift::Types::STRING, :name => 'authenticationToken'}, GUID => {:type => ::Thrift::Types::STRING, :name => 'guid'} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end class GetResourceRecognition_result include ::Thrift::Struct, ::Thrift::Struct_Union SUCCESS = 0 USEREXCEPTION = 1 SYSTEMEXCEPTION = 2 NOTFOUNDEXCEPTION = 3 FIELDS = { SUCCESS => {:type => ::Thrift::Types::STRING, :name => 'success', :binary => true}, USEREXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'userException', :class => Evernote::EDAM::Error::EDAMUserException}, SYSTEMEXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'systemException', :class => Evernote::EDAM::Error::EDAMSystemException}, NOTFOUNDEXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'notFoundException', :class => Evernote::EDAM::Error::EDAMNotFoundException} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end class GetResourceAlternateData_args include ::Thrift::Struct, ::Thrift::Struct_Union AUTHENTICATIONTOKEN = 1 GUID = 2 FIELDS = { AUTHENTICATIONTOKEN => {:type => ::Thrift::Types::STRING, :name => 'authenticationToken'}, GUID => {:type => ::Thrift::Types::STRING, :name => 'guid'} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end class GetResourceAlternateData_result include ::Thrift::Struct, ::Thrift::Struct_Union SUCCESS = 0 USEREXCEPTION = 1 SYSTEMEXCEPTION = 2 NOTFOUNDEXCEPTION = 3 FIELDS = { SUCCESS => {:type => ::Thrift::Types::STRING, :name => 'success', :binary => true}, USEREXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'userException', :class => Evernote::EDAM::Error::EDAMUserException}, SYSTEMEXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'systemException', :class => Evernote::EDAM::Error::EDAMSystemException}, NOTFOUNDEXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'notFoundException', :class => Evernote::EDAM::Error::EDAMNotFoundException} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end class GetResourceAttributes_args include ::Thrift::Struct, ::Thrift::Struct_Union AUTHENTICATIONTOKEN = 1 GUID = 2 FIELDS = { AUTHENTICATIONTOKEN => {:type => ::Thrift::Types::STRING, :name => 'authenticationToken'}, GUID => {:type => ::Thrift::Types::STRING, :name => 'guid'} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end class GetResourceAttributes_result include ::Thrift::Struct, ::Thrift::Struct_Union SUCCESS = 0 USEREXCEPTION = 1 SYSTEMEXCEPTION = 2 NOTFOUNDEXCEPTION = 3 FIELDS = { SUCCESS => {:type => ::Thrift::Types::STRUCT, :name => 'success', :class => Evernote::EDAM::Type::ResourceAttributes}, USEREXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'userException', :class => Evernote::EDAM::Error::EDAMUserException}, SYSTEMEXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'systemException', :class => Evernote::EDAM::Error::EDAMSystemException}, NOTFOUNDEXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'notFoundException', :class => Evernote::EDAM::Error::EDAMNotFoundException} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end class GetAccountSize_args include ::Thrift::Struct, ::Thrift::Struct_Union AUTHENTICATIONTOKEN = 1 FIELDS = { AUTHENTICATIONTOKEN => {:type => ::Thrift::Types::STRING, :name => 'authenticationToken'} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end class GetAccountSize_result include ::Thrift::Struct, ::Thrift::Struct_Union SUCCESS = 0 USEREXCEPTION = 1 SYSTEMEXCEPTION = 2 FIELDS = { SUCCESS => {:type => ::Thrift::Types::I64, :name => 'success'}, USEREXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'userException', :class => Evernote::EDAM::Error::EDAMUserException}, SYSTEMEXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'systemException', :class => Evernote::EDAM::Error::EDAMSystemException} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end class GetAds_args include ::Thrift::Struct, ::Thrift::Struct_Union AUTHENTICATIONTOKEN = 1 ADPARAMETERS = 2 FIELDS = { AUTHENTICATIONTOKEN => {:type => ::Thrift::Types::STRING, :name => 'authenticationToken'}, ADPARAMETERS => {:type => ::Thrift::Types::STRUCT, :name => 'adParameters', :class => Evernote::EDAM::NoteStore::AdParameters} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end class GetAds_result include ::Thrift::Struct, ::Thrift::Struct_Union SUCCESS = 0 USEREXCEPTION = 1 SYSTEMEXCEPTION = 2 FIELDS = { SUCCESS => {:type => ::Thrift::Types::LIST, :name => 'success', :element => {:type => ::Thrift::Types::STRUCT, :class => Evernote::EDAM::Type::Ad}}, USEREXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'userException', :class => Evernote::EDAM::Error::EDAMUserException}, SYSTEMEXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'systemException', :class => Evernote::EDAM::Error::EDAMSystemException} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end class GetRandomAd_args include ::Thrift::Struct, ::Thrift::Struct_Union AUTHENTICATIONTOKEN = 1 ADPARAMETERS = 2 FIELDS = { AUTHENTICATIONTOKEN => {:type => ::Thrift::Types::STRING, :name => 'authenticationToken'}, ADPARAMETERS => {:type => ::Thrift::Types::STRUCT, :name => 'adParameters', :class => Evernote::EDAM::NoteStore::AdParameters} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end class GetRandomAd_result include ::Thrift::Struct, ::Thrift::Struct_Union SUCCESS = 0 USEREXCEPTION = 1 SYSTEMEXCEPTION = 2 FIELDS = { SUCCESS => {:type => ::Thrift::Types::STRUCT, :name => 'success', :class => Evernote::EDAM::Type::Ad}, USEREXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'userException', :class => Evernote::EDAM::Error::EDAMUserException}, SYSTEMEXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'systemException', :class => Evernote::EDAM::Error::EDAMSystemException} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end class GetPublicNotebook_args include ::Thrift::Struct, ::Thrift::Struct_Union USERID = 1 PUBLICURI = 2 FIELDS = { USERID => {:type => ::Thrift::Types::I32, :name => 'userId'}, PUBLICURI => {:type => ::Thrift::Types::STRING, :name => 'publicUri'} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end class GetPublicNotebook_result include ::Thrift::Struct, ::Thrift::Struct_Union SUCCESS = 0 SYSTEMEXCEPTION = 1 NOTFOUNDEXCEPTION = 2 FIELDS = { SUCCESS => {:type => ::Thrift::Types::STRUCT, :name => 'success', :class => Evernote::EDAM::Type::Notebook}, SYSTEMEXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'systemException', :class => Evernote::EDAM::Error::EDAMSystemException}, NOTFOUNDEXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'notFoundException', :class => Evernote::EDAM::Error::EDAMNotFoundException} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end class CreateSharedNotebook_args include ::Thrift::Struct, ::Thrift::Struct_Union AUTHENTICATIONTOKEN = 1 SHAREDNOTEBOOK = 2 FIELDS = { AUTHENTICATIONTOKEN => {:type => ::Thrift::Types::STRING, :name => 'authenticationToken'}, SHAREDNOTEBOOK => {:type => ::Thrift::Types::STRUCT, :name => 'sharedNotebook', :class => Evernote::EDAM::Type::SharedNotebook} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end class CreateSharedNotebook_result include ::Thrift::Struct, ::Thrift::Struct_Union SUCCESS = 0 USEREXCEPTION = 1 NOTFOUNDEXCEPTION = 2 SYSTEMEXCEPTION = 3 FIELDS = { SUCCESS => {:type => ::Thrift::Types::STRUCT, :name => 'success', :class => Evernote::EDAM::Type::SharedNotebook}, USEREXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'userException', :class => Evernote::EDAM::Error::EDAMUserException}, NOTFOUNDEXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'notFoundException', :class => Evernote::EDAM::Error::EDAMNotFoundException}, SYSTEMEXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'systemException', :class => Evernote::EDAM::Error::EDAMSystemException} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end class ListSharedNotebooks_args include ::Thrift::Struct, ::Thrift::Struct_Union AUTHENTICATIONTOKEN = 1 FIELDS = { AUTHENTICATIONTOKEN => {:type => ::Thrift::Types::STRING, :name => 'authenticationToken'} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end class ListSharedNotebooks_result include ::Thrift::Struct, ::Thrift::Struct_Union SUCCESS = 0 USEREXCEPTION = 1 NOTFOUNDEXCEPTION = 2 SYSTEMEXCEPTION = 3 FIELDS = { SUCCESS => {:type => ::Thrift::Types::LIST, :name => 'success', :element => {:type => ::Thrift::Types::STRUCT, :class => Evernote::EDAM::Type::SharedNotebook}}, USEREXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'userException', :class => Evernote::EDAM::Error::EDAMUserException}, NOTFOUNDEXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'notFoundException', :class => Evernote::EDAM::Error::EDAMNotFoundException}, SYSTEMEXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'systemException', :class => Evernote::EDAM::Error::EDAMSystemException} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end class ExpungeSharedNotebooks_args include ::Thrift::Struct, ::Thrift::Struct_Union AUTHENTICATIONTOKEN = 1 SHAREDNOTEBOOKIDS = 2 FIELDS = { AUTHENTICATIONTOKEN => {:type => ::Thrift::Types::STRING, :name => 'authenticationToken'}, SHAREDNOTEBOOKIDS => {:type => ::Thrift::Types::LIST, :name => 'sharedNotebookIds', :element => {:type => ::Thrift::Types::I64}} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end class ExpungeSharedNotebooks_result include ::Thrift::Struct, ::Thrift::Struct_Union SUCCESS = 0 USEREXCEPTION = 1 NOTFOUNDEXCEPTION = 2 SYSTEMEXCEPTION = 3 FIELDS = { SUCCESS => {:type => ::Thrift::Types::I32, :name => 'success'}, USEREXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'userException', :class => Evernote::EDAM::Error::EDAMUserException}, NOTFOUNDEXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'notFoundException', :class => Evernote::EDAM::Error::EDAMNotFoundException}, SYSTEMEXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'systemException', :class => Evernote::EDAM::Error::EDAMSystemException} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end class CreateLinkedNotebook_args include ::Thrift::Struct, ::Thrift::Struct_Union AUTHENTICATIONTOKEN = 1 LINKEDNOTEBOOK = 2 FIELDS = { AUTHENTICATIONTOKEN => {:type => ::Thrift::Types::STRING, :name => 'authenticationToken'}, LINKEDNOTEBOOK => {:type => ::Thrift::Types::STRUCT, :name => 'linkedNotebook', :class => Evernote::EDAM::Type::LinkedNotebook} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end class CreateLinkedNotebook_result include ::Thrift::Struct, ::Thrift::Struct_Union SUCCESS = 0 USEREXCEPTION = 1 NOTFOUNDEXCEPTION = 2 SYSTEMEXCEPTION = 3 FIELDS = { SUCCESS => {:type => ::Thrift::Types::STRUCT, :name => 'success', :class => Evernote::EDAM::Type::LinkedNotebook}, USEREXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'userException', :class => Evernote::EDAM::Error::EDAMUserException}, NOTFOUNDEXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'notFoundException', :class => Evernote::EDAM::Error::EDAMNotFoundException}, SYSTEMEXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'systemException', :class => Evernote::EDAM::Error::EDAMSystemException} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end class UpdateLinkedNotebook_args include ::Thrift::Struct, ::Thrift::Struct_Union AUTHENTICATIONTOKEN = 1 LINKEDNOTEBOOK = 2 FIELDS = { AUTHENTICATIONTOKEN => {:type => ::Thrift::Types::STRING, :name => 'authenticationToken'}, LINKEDNOTEBOOK => {:type => ::Thrift::Types::STRUCT, :name => 'linkedNotebook', :class => Evernote::EDAM::Type::LinkedNotebook} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end class UpdateLinkedNotebook_result include ::Thrift::Struct, ::Thrift::Struct_Union SUCCESS = 0 USEREXCEPTION = 1 NOTFOUNDEXCEPTION = 2 SYSTEMEXCEPTION = 3 FIELDS = { SUCCESS => {:type => ::Thrift::Types::STRUCT, :name => 'success', :class => Evernote::EDAM::Type::LinkedNotebook}, USEREXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'userException', :class => Evernote::EDAM::Error::EDAMUserException}, NOTFOUNDEXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'notFoundException', :class => Evernote::EDAM::Error::EDAMNotFoundException}, SYSTEMEXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'systemException', :class => Evernote::EDAM::Error::EDAMSystemException} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end class ListLinkedNotebooks_args include ::Thrift::Struct, ::Thrift::Struct_Union AUTHENTICATIONTOKEN = 1 FIELDS = { AUTHENTICATIONTOKEN => {:type => ::Thrift::Types::STRING, :name => 'authenticationToken'} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end class ListLinkedNotebooks_result include ::Thrift::Struct, ::Thrift::Struct_Union SUCCESS = 0 USEREXCEPTION = 1 NOTFOUNDEXCEPTION = 2 SYSTEMEXCEPTION = 3 FIELDS = { SUCCESS => {:type => ::Thrift::Types::LIST, :name => 'success', :element => {:type => ::Thrift::Types::STRUCT, :class => Evernote::EDAM::Type::LinkedNotebook}}, USEREXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'userException', :class => Evernote::EDAM::Error::EDAMUserException}, NOTFOUNDEXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'notFoundException', :class => Evernote::EDAM::Error::EDAMNotFoundException}, SYSTEMEXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'systemException', :class => Evernote::EDAM::Error::EDAMSystemException} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end class ExpungeLinkedNotebook_args include ::Thrift::Struct, ::Thrift::Struct_Union AUTHENTICATIONTOKEN = 1 LINKEDNOTEBOOKID = 2 FIELDS = { AUTHENTICATIONTOKEN => {:type => ::Thrift::Types::STRING, :name => 'authenticationToken'}, LINKEDNOTEBOOKID => {:type => ::Thrift::Types::I64, :name => 'linkedNotebookId'} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end class ExpungeLinkedNotebook_result include ::Thrift::Struct, ::Thrift::Struct_Union SUCCESS = 0 USEREXCEPTION = 1 NOTFOUNDEXCEPTION = 2 SYSTEMEXCEPTION = 3 FIELDS = { SUCCESS => {:type => ::Thrift::Types::I32, :name => 'success'}, USEREXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'userException', :class => Evernote::EDAM::Error::EDAMUserException}, NOTFOUNDEXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'notFoundException', :class => Evernote::EDAM::Error::EDAMNotFoundException}, SYSTEMEXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'systemException', :class => Evernote::EDAM::Error::EDAMSystemException} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end class AuthenticateToSharedNotebook_args include ::Thrift::Struct, ::Thrift::Struct_Union SHAREKEY = 1 AUTHENTICATIONTOKEN = 2 FIELDS = { SHAREKEY => {:type => ::Thrift::Types::STRING, :name => 'shareKey'}, AUTHENTICATIONTOKEN => {:type => ::Thrift::Types::STRING, :name => 'authenticationToken'} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end class AuthenticateToSharedNotebook_result include ::Thrift::Struct, ::Thrift::Struct_Union SUCCESS = 0 USEREXCEPTION = 1 NOTFOUNDEXCEPTION = 2 SYSTEMEXCEPTION = 3 FIELDS = { SUCCESS => {:type => ::Thrift::Types::STRUCT, :name => 'success', :class => Evernote::EDAM::UserStore::AuthenticationResult}, USEREXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'userException', :class => Evernote::EDAM::Error::EDAMUserException}, NOTFOUNDEXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'notFoundException', :class => Evernote::EDAM::Error::EDAMNotFoundException}, SYSTEMEXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'systemException', :class => Evernote::EDAM::Error::EDAMSystemException} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end class GetSharedNotebookByAuth_args include ::Thrift::Struct, ::Thrift::Struct_Union AUTHENTICATIONTOKEN = 1 FIELDS = { AUTHENTICATIONTOKEN => {:type => ::Thrift::Types::STRING, :name => 'authenticationToken'} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end class GetSharedNotebookByAuth_result include ::Thrift::Struct, ::Thrift::Struct_Union SUCCESS = 0 USEREXCEPTION = 1 NOTFOUNDEXCEPTION = 2 SYSTEMEXCEPTION = 3 FIELDS = { SUCCESS => {:type => ::Thrift::Types::STRUCT, :name => 'success', :class => Evernote::EDAM::Type::SharedNotebook}, USEREXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'userException', :class => Evernote::EDAM::Error::EDAMUserException}, NOTFOUNDEXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'notFoundException', :class => Evernote::EDAM::Error::EDAMNotFoundException}, SYSTEMEXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'systemException', :class => Evernote::EDAM::Error::EDAMSystemException} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end class EmailNote_args include ::Thrift::Struct, ::Thrift::Struct_Union AUTHENTICATIONTOKEN = 1 PARAMETERS = 2 FIELDS = { AUTHENTICATIONTOKEN => {:type => ::Thrift::Types::STRING, :name => 'authenticationToken'}, PARAMETERS => {:type => ::Thrift::Types::STRUCT, :name => 'parameters', :class => Evernote::EDAM::NoteStore::NoteEmailParameters} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end class EmailNote_result include ::Thrift::Struct, ::Thrift::Struct_Union USEREXCEPTION = 1 NOTFOUNDEXCEPTION = 2 SYSTEMEXCEPTION = 3 FIELDS = { USEREXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'userException', :class => Evernote::EDAM::Error::EDAMUserException}, NOTFOUNDEXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'notFoundException', :class => Evernote::EDAM::Error::EDAMNotFoundException}, SYSTEMEXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'systemException', :class => Evernote::EDAM::Error::EDAMSystemException} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end end end end end evernote-mode-0_41/ruby/lib/Evernote/EDAM/limits_types.rb0000664000175000017500000000027111513076422023225 0ustar uwabamiuwabami# # Autogenerated by Thrift # # DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING # module Evernote module EDAM module Limits end end end evernote-mode-0_41/ruby/lib/Evernote/EDAM/note_store_constants.rb0000664000175000017500000000034511513076422024757 0ustar uwabamiuwabami# # Autogenerated by Thrift # # DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING # require 'Evernote/EDAM/note_store_types' module Evernote module EDAM module NoteStore end end end evernote-mode-0_41/ruby/lib/Evernote/EDAM/user_store_types.rb0000664000175000017500000001301411513076422024115 0ustar uwabamiuwabami# # Autogenerated by Thrift # # DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING # require 'Evernote/EDAM/types_types' require 'Evernote/EDAM/errors_types' module Evernote module EDAM module UserStore # This structure is used to provide publicly-available user information # about a particular account. #
#
userId:
#
# The unique numeric user identifier for the user account. #
#
shardId:
#
# The name of the virtual server that manages the state of # this user. This value is used internally to determine which system should # service requests about this user's data. It is also used to construct # the appropriate URL to make requests from the NoteStore. #
#
privilege:
#
# The privilege level of the account, to determine whether # this is a Premium or Free account. #
#
class PublicUserInfo include ::Thrift::Struct, ::Thrift::Struct_Union USERID = 1 SHARDID = 2 PRIVILEGE = 3 USERNAME = 4 FIELDS = { USERID => {:type => ::Thrift::Types::I32, :name => 'userId'}, SHARDID => {:type => ::Thrift::Types::STRING, :name => 'shardId'}, PRIVILEGE => {:type => ::Thrift::Types::I32, :name => 'privilege', :optional => true, :enum_class => Evernote::EDAM::Type::PrivilegeLevel}, USERNAME => {:type => ::Thrift::Types::STRING, :name => 'username', :optional => true} } def struct_fields; FIELDS; end def validate raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field userId is unset!') unless @userId raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field shardId is unset!') unless @shardId unless @privilege.nil? || Evernote::EDAM::Type::PrivilegeLevel::VALID_VALUES.include?(@privilege) raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Invalid value of field privilege!') end end ::Thrift::Struct.generate_accessors self end # When an authentication (or re-authentication) is performed, this structure # provides the result to the client. #
#
currentTime:
#
# The server-side date and time when this result was # generated. #
#
authenticationToken:
#
# Holds an opaque, ASCII-encoded token that can be # used by the client to perform actions on a NoteStore. #
#
expiration:
#
# Holds the server-side date and time when the # authentication token will expire. # This time can be compared to "currentTime" to produce an expiration # time that can be reconciled with the client's local clock. #
#
user:
#
# Holds the information about the account which was # authenticated if this was a full authentication. May be absent if this # particular authentication did not require user information. #
#
publicUserInfo:
#
# If this authentication result was achieved without full permissions to # access the full User structure, this field may be set to give back # a more limited public set of data. #
#
class AuthenticationResult include ::Thrift::Struct, ::Thrift::Struct_Union CURRENTTIME = 1 AUTHENTICATIONTOKEN = 2 EXPIRATION = 3 USER = 4 PUBLICUSERINFO = 5 FIELDS = { CURRENTTIME => {:type => ::Thrift::Types::I64, :name => 'currentTime'}, AUTHENTICATIONTOKEN => {:type => ::Thrift::Types::STRING, :name => 'authenticationToken'}, EXPIRATION => {:type => ::Thrift::Types::I64, :name => 'expiration'}, USER => {:type => ::Thrift::Types::STRUCT, :name => 'user', :class => Evernote::EDAM::Type::User, :optional => true}, PUBLICUSERINFO => {:type => ::Thrift::Types::STRUCT, :name => 'publicUserInfo', :class => Evernote::EDAM::UserStore::PublicUserInfo, :optional => true} } def struct_fields; FIELDS; end def validate raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field currentTime is unset!') unless @currentTime raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field authenticationToken is unset!') unless @authenticationToken raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field expiration is unset!') unless @expiration end ::Thrift::Struct.generate_accessors self end end end end evernote-mode-0_41/ruby/lib/Evernote/EDAM/user_store.rb0000664000175000017500000004145511513076422022703 0ustar uwabamiuwabami# # Autogenerated by Thrift # # DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING # require 'thrift' require 'Evernote/EDAM/user_store_types' module Evernote module EDAM module UserStore module UserStore class Client include ::Thrift::Client def checkVersion(clientName, edamVersionMajor, edamVersionMinor) send_checkVersion(clientName, edamVersionMajor, edamVersionMinor) return recv_checkVersion() end def send_checkVersion(clientName, edamVersionMajor, edamVersionMinor) send_message('checkVersion', CheckVersion_args, :clientName => clientName, :edamVersionMajor => edamVersionMajor, :edamVersionMinor => edamVersionMinor) end def recv_checkVersion() result = receive_message(CheckVersion_result) return result.success unless result.success.nil? raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'checkVersion failed: unknown result') end def authenticate(username, password, consumerKey, consumerSecret) send_authenticate(username, password, consumerKey, consumerSecret) return recv_authenticate() end def send_authenticate(username, password, consumerKey, consumerSecret) send_message('authenticate', Authenticate_args, :username => username, :password => password, :consumerKey => consumerKey, :consumerSecret => consumerSecret) end def recv_authenticate() result = receive_message(Authenticate_result) return result.success unless result.success.nil? raise result.userException unless result.userException.nil? raise result.systemException unless result.systemException.nil? raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'authenticate failed: unknown result') end def refreshAuthentication(authenticationToken) send_refreshAuthentication(authenticationToken) return recv_refreshAuthentication() end def send_refreshAuthentication(authenticationToken) send_message('refreshAuthentication', RefreshAuthentication_args, :authenticationToken => authenticationToken) end def recv_refreshAuthentication() result = receive_message(RefreshAuthentication_result) return result.success unless result.success.nil? raise result.userException unless result.userException.nil? raise result.systemException unless result.systemException.nil? raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'refreshAuthentication failed: unknown result') end def getUser(authenticationToken) send_getUser(authenticationToken) return recv_getUser() end def send_getUser(authenticationToken) send_message('getUser', GetUser_args, :authenticationToken => authenticationToken) end def recv_getUser() result = receive_message(GetUser_result) return result.success unless result.success.nil? raise result.userException unless result.userException.nil? raise result.systemException unless result.systemException.nil? raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'getUser failed: unknown result') end def getPublicUserInfo(username) send_getPublicUserInfo(username) return recv_getPublicUserInfo() end def send_getPublicUserInfo(username) send_message('getPublicUserInfo', GetPublicUserInfo_args, :username => username) end def recv_getPublicUserInfo() result = receive_message(GetPublicUserInfo_result) return result.success unless result.success.nil? raise result.notFoundException unless result.notFoundException.nil? raise result.systemException unless result.systemException.nil? raise result.userException unless result.userException.nil? raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'getPublicUserInfo failed: unknown result') end end class Processor include ::Thrift::Processor def process_checkVersion(seqid, iprot, oprot) args = read_args(iprot, CheckVersion_args) result = CheckVersion_result.new() result.success = @handler.checkVersion(args.clientName, args.edamVersionMajor, args.edamVersionMinor) write_result(result, oprot, 'checkVersion', seqid) end def process_authenticate(seqid, iprot, oprot) args = read_args(iprot, Authenticate_args) result = Authenticate_result.new() begin result.success = @handler.authenticate(args.username, args.password, args.consumerKey, args.consumerSecret) rescue Evernote::EDAM::Error::EDAMUserException => userException result.userException = userException rescue Evernote::EDAM::Error::EDAMSystemException => systemException result.systemException = systemException end write_result(result, oprot, 'authenticate', seqid) end def process_refreshAuthentication(seqid, iprot, oprot) args = read_args(iprot, RefreshAuthentication_args) result = RefreshAuthentication_result.new() begin result.success = @handler.refreshAuthentication(args.authenticationToken) rescue Evernote::EDAM::Error::EDAMUserException => userException result.userException = userException rescue Evernote::EDAM::Error::EDAMSystemException => systemException result.systemException = systemException end write_result(result, oprot, 'refreshAuthentication', seqid) end def process_getUser(seqid, iprot, oprot) args = read_args(iprot, GetUser_args) result = GetUser_result.new() begin result.success = @handler.getUser(args.authenticationToken) rescue Evernote::EDAM::Error::EDAMUserException => userException result.userException = userException rescue Evernote::EDAM::Error::EDAMSystemException => systemException result.systemException = systemException end write_result(result, oprot, 'getUser', seqid) end def process_getPublicUserInfo(seqid, iprot, oprot) args = read_args(iprot, GetPublicUserInfo_args) result = GetPublicUserInfo_result.new() begin result.success = @handler.getPublicUserInfo(args.username) rescue Evernote::EDAM::Error::EDAMNotFoundException => notFoundException result.notFoundException = notFoundException rescue Evernote::EDAM::Error::EDAMSystemException => systemException result.systemException = systemException rescue Evernote::EDAM::Error::EDAMUserException => userException result.userException = userException end write_result(result, oprot, 'getPublicUserInfo', seqid) end end # HELPER FUNCTIONS AND STRUCTURES class CheckVersion_args include ::Thrift::Struct, ::Thrift::Struct_Union CLIENTNAME = 1 EDAMVERSIONMAJOR = 2 EDAMVERSIONMINOR = 3 FIELDS = { CLIENTNAME => {:type => ::Thrift::Types::STRING, :name => 'clientName'}, EDAMVERSIONMAJOR => {:type => ::Thrift::Types::I16, :name => 'edamVersionMajor', :default => 1}, EDAMVERSIONMINOR => {:type => ::Thrift::Types::I16, :name => 'edamVersionMinor', :default => 16} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end class CheckVersion_result include ::Thrift::Struct, ::Thrift::Struct_Union SUCCESS = 0 FIELDS = { SUCCESS => {:type => ::Thrift::Types::BOOL, :name => 'success'} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end class Authenticate_args include ::Thrift::Struct, ::Thrift::Struct_Union USERNAME = 1 PASSWORD = 2 CONSUMERKEY = 3 CONSUMERSECRET = 4 FIELDS = { USERNAME => {:type => ::Thrift::Types::STRING, :name => 'username'}, PASSWORD => {:type => ::Thrift::Types::STRING, :name => 'password'}, CONSUMERKEY => {:type => ::Thrift::Types::STRING, :name => 'consumerKey'}, CONSUMERSECRET => {:type => ::Thrift::Types::STRING, :name => 'consumerSecret'} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end class Authenticate_result include ::Thrift::Struct, ::Thrift::Struct_Union SUCCESS = 0 USEREXCEPTION = 1 SYSTEMEXCEPTION = 2 FIELDS = { SUCCESS => {:type => ::Thrift::Types::STRUCT, :name => 'success', :class => Evernote::EDAM::UserStore::AuthenticationResult}, USEREXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'userException', :class => Evernote::EDAM::Error::EDAMUserException}, SYSTEMEXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'systemException', :class => Evernote::EDAM::Error::EDAMSystemException} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end class RefreshAuthentication_args include ::Thrift::Struct, ::Thrift::Struct_Union AUTHENTICATIONTOKEN = 1 FIELDS = { AUTHENTICATIONTOKEN => {:type => ::Thrift::Types::STRING, :name => 'authenticationToken'} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end class RefreshAuthentication_result include ::Thrift::Struct, ::Thrift::Struct_Union SUCCESS = 0 USEREXCEPTION = 1 SYSTEMEXCEPTION = 2 FIELDS = { SUCCESS => {:type => ::Thrift::Types::STRUCT, :name => 'success', :class => Evernote::EDAM::UserStore::AuthenticationResult}, USEREXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'userException', :class => Evernote::EDAM::Error::EDAMUserException}, SYSTEMEXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'systemException', :class => Evernote::EDAM::Error::EDAMSystemException} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end class GetUser_args include ::Thrift::Struct, ::Thrift::Struct_Union AUTHENTICATIONTOKEN = 1 FIELDS = { AUTHENTICATIONTOKEN => {:type => ::Thrift::Types::STRING, :name => 'authenticationToken'} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end class GetUser_result include ::Thrift::Struct, ::Thrift::Struct_Union SUCCESS = 0 USEREXCEPTION = 1 SYSTEMEXCEPTION = 2 FIELDS = { SUCCESS => {:type => ::Thrift::Types::STRUCT, :name => 'success', :class => Evernote::EDAM::Type::User}, USEREXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'userException', :class => Evernote::EDAM::Error::EDAMUserException}, SYSTEMEXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'systemException', :class => Evernote::EDAM::Error::EDAMSystemException} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end class GetPublicUserInfo_args include ::Thrift::Struct, ::Thrift::Struct_Union USERNAME = 1 FIELDS = { USERNAME => {:type => ::Thrift::Types::STRING, :name => 'username'} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end class GetPublicUserInfo_result include ::Thrift::Struct, ::Thrift::Struct_Union SUCCESS = 0 NOTFOUNDEXCEPTION = 1 SYSTEMEXCEPTION = 2 USEREXCEPTION = 3 FIELDS = { SUCCESS => {:type => ::Thrift::Types::STRUCT, :name => 'success', :class => Evernote::EDAM::UserStore::PublicUserInfo}, NOTFOUNDEXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'notFoundException', :class => Evernote::EDAM::Error::EDAMNotFoundException}, SYSTEMEXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'systemException', :class => Evernote::EDAM::Error::EDAMSystemException}, USEREXCEPTION => {:type => ::Thrift::Types::STRUCT, :name => 'userException', :class => Evernote::EDAM::Error::EDAMUserException} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end end end end end evernote-mode-0_41/ruby/lib/Evernote/EDAM/note_store_types.rb0000664000175000017500000007235711513076422024123 0ustar uwabamiuwabami# # Autogenerated by Thrift # # DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING # require 'Evernote/EDAM/user_store_types' require 'Evernote/EDAM/types_types' require 'Evernote/EDAM/errors_types' require 'Evernote/EDAM/limits_types' module Evernote module EDAM module NoteStore # This structure encapsulates the information about the state of the # user's account for the purpose of "state based" synchronization. #
#
currentTime
#
# The server's current date and time. #
# #
fullSyncBefore
#
# The cutoff date and time for client caches to be # updated via incremental synchronization. Any clients that were last # synched with the server before this date/time must do a full resync of all # objects. This cutoff point will change over time as archival data is # deleted or special circumstances on the service require resynchronization. #
# #
updateCount
#
# Indicates the total number of transactions that have # been committed within the account. This reflects (for example) the # number of discrete additions or modifications that have been made to # the data in this account (tags, notes, resources, etc.). # This number is the "high water mark" for Update Sequence Numbers (USN) # within the account. #
# #
uploaded
#
# The total number of bytes that have been uploaded to # this account in the current monthly period. This can be compared against # Accounting.uploadLimit (from the UserStore) to determine how close the user # is to their monthly upload limit. #
#
class SyncState include ::Thrift::Struct, ::Thrift::Struct_Union CURRENTTIME = 1 FULLSYNCBEFORE = 2 UPDATECOUNT = 3 UPLOADED = 4 FIELDS = { CURRENTTIME => {:type => ::Thrift::Types::I64, :name => 'currentTime'}, FULLSYNCBEFORE => {:type => ::Thrift::Types::I64, :name => 'fullSyncBefore'}, UPDATECOUNT => {:type => ::Thrift::Types::I32, :name => 'updateCount'}, UPLOADED => {:type => ::Thrift::Types::I64, :name => 'uploaded', :optional => true} } def struct_fields; FIELDS; end def validate raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field currentTime is unset!') unless @currentTime raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field fullSyncBefore is unset!') unless @fullSyncBefore raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field updateCount is unset!') unless @updateCount end ::Thrift::Struct.generate_accessors self end # This structure is given out by the NoteStore when a client asks to # receive the current state of an account. The client asks for the server's # state one chunk at a time in order to allow clients to retrieve the state # of a large account without needing to transfer the entire account in # a single message. # # The server always gives SyncChunks using an ascending series of Update # Sequence Numbers (USNs). # #
#
currentTime
#
# The server's current date and time. #
# #
chunkHighUSN
#
# The highest USN for any of the data objects represented # in this sync chunk. If there are no objects in the chunk, this will not be # set. #
# #
updateCount
#
# The total number of updates that have been performed in # the service for this account. This is equal to the highest USN within the # account at the point that this SyncChunk was generated. If updateCount # and chunkHighUSN are identical, that means that this is the last chunk # in the account ... there is no more recent information. #
# #
notes
#
# If present, this is a list of non-expunged notes that # have a USN in this chunk. This will include notes that are "deleted" # but not expunged (i.e. in the trash). The notes will include their list # of tags and resources, but the resource content and recognition data # will not be supplied. #
# #
notebooks
#
# If present, this is a list of non-expunged notebooks that # have a USN in this chunk. This will include notebooks that are "deleted" # but not expunged (i.e. in the trash). #
# #
tags
#
# If present, this is a list of the non-expunged tags that have a # USN in this chunk. #
# #
searches
#
# If present, this is a list of non-expunged searches that # have a USN in this chunk. #
# #
resources
#
# If present, this is a list of the non-expunged resources # that have a USN in this chunk. This will include the metadata for each # resource, but not its binary contents or recognition data, which must be # retrieved separately. #
# #
expungedNotes
#
# If present, the GUIDs of all of the notes that were # permanently expunged in this chunk. #
# #
expungedNotebooks
#
# If present, the GUIDs of all of the notebooks that # were permanently expunged in this chunk. When a notebook is expunged, # this implies that all of its child notes (and their resources) were # also expunged. #
# #
expungedTags
#
# If present, the GUIDs of all of the tags that were # permanently expunged in this chunk. #
# #
expungedSearches
#
# If present, the GUIDs of all of the saved searches # that were permanently expunged in this chunk. #
#
class SyncChunk include ::Thrift::Struct, ::Thrift::Struct_Union CURRENTTIME = 1 CHUNKHIGHUSN = 2 UPDATECOUNT = 3 NOTES = 4 NOTEBOOKS = 5 TAGS = 6 SEARCHES = 7 RESOURCES = 8 EXPUNGEDNOTES = 9 EXPUNGEDNOTEBOOKS = 10 EXPUNGEDTAGS = 11 EXPUNGEDSEARCHES = 12 FIELDS = { CURRENTTIME => {:type => ::Thrift::Types::I64, :name => 'currentTime'}, CHUNKHIGHUSN => {:type => ::Thrift::Types::I32, :name => 'chunkHighUSN', :optional => true}, UPDATECOUNT => {:type => ::Thrift::Types::I32, :name => 'updateCount'}, NOTES => {:type => ::Thrift::Types::LIST, :name => 'notes', :element => {:type => ::Thrift::Types::STRUCT, :class => Evernote::EDAM::Type::Note}, :optional => true}, NOTEBOOKS => {:type => ::Thrift::Types::LIST, :name => 'notebooks', :element => {:type => ::Thrift::Types::STRUCT, :class => Evernote::EDAM::Type::Notebook}, :optional => true}, TAGS => {:type => ::Thrift::Types::LIST, :name => 'tags', :element => {:type => ::Thrift::Types::STRUCT, :class => Evernote::EDAM::Type::Tag}, :optional => true}, SEARCHES => {:type => ::Thrift::Types::LIST, :name => 'searches', :element => {:type => ::Thrift::Types::STRUCT, :class => Evernote::EDAM::Type::SavedSearch}, :optional => true}, RESOURCES => {:type => ::Thrift::Types::LIST, :name => 'resources', :element => {:type => ::Thrift::Types::STRUCT, :class => Evernote::EDAM::Type::Resource}, :optional => true}, EXPUNGEDNOTES => {:type => ::Thrift::Types::LIST, :name => 'expungedNotes', :element => {:type => ::Thrift::Types::STRING}, :optional => true}, EXPUNGEDNOTEBOOKS => {:type => ::Thrift::Types::LIST, :name => 'expungedNotebooks', :element => {:type => ::Thrift::Types::STRING}, :optional => true}, EXPUNGEDTAGS => {:type => ::Thrift::Types::LIST, :name => 'expungedTags', :element => {:type => ::Thrift::Types::STRING}, :optional => true}, EXPUNGEDSEARCHES => {:type => ::Thrift::Types::LIST, :name => 'expungedSearches', :element => {:type => ::Thrift::Types::STRING}, :optional => true} } def struct_fields; FIELDS; end def validate raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field currentTime is unset!') unless @currentTime raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field updateCount is unset!') unless @updateCount end ::Thrift::Struct.generate_accessors self end # A list of criteria that are used to indicate which notes are desired from # the account. This is used in queries to the NoteStore to determine # which notes should be retrieved. # #
#
order
#
# The NoteSortOrder value indicating what criterion should be # used to sort the results of the filter. #
# #
ascending
#
# If true, the results will be ascending in the requested # sort order. If false, the results will be descending. #
# #
words
#
# The string query containing keywords to match, if present. #
# #
notebookGuid
#
# If present, the Guid of the notebook that must contain # the notes. #
# #
tagGuids
#
# If present, the list of tags (by GUID) that must be present # on the notes. #
# #
timeZone
#
# The zone ID for the user, which will be used to interpret # any dates or times in the queries that do not include their desired zone # information. # For example, if a query requests notes created "yesterday", this # will be evaluated from the provided time zone, if provided. # The format must be encoded as a standard zone ID such as # "America/Los_Angeles". #
# #
inactive
#
# If true, then only notes that are not active (i.e. notes in # the Trash) will be returned. Otherwise, only active notes will be returned. # There is no way to find both active and inactive notes in a single query. #
#
class NoteFilter include ::Thrift::Struct, ::Thrift::Struct_Union ORDER = 1 ASCENDING = 2 WORDS = 3 NOTEBOOKGUID = 4 TAGGUIDS = 5 TIMEZONE = 6 INACTIVE = 7 FIELDS = { ORDER => {:type => ::Thrift::Types::I32, :name => 'order', :optional => true}, ASCENDING => {:type => ::Thrift::Types::BOOL, :name => 'ascending', :optional => true}, WORDS => {:type => ::Thrift::Types::STRING, :name => 'words', :optional => true}, NOTEBOOKGUID => {:type => ::Thrift::Types::STRING, :name => 'notebookGuid', :optional => true}, TAGGUIDS => {:type => ::Thrift::Types::LIST, :name => 'tagGuids', :element => {:type => ::Thrift::Types::STRING}, :optional => true}, TIMEZONE => {:type => ::Thrift::Types::STRING, :name => 'timeZone', :optional => true}, INACTIVE => {:type => ::Thrift::Types::BOOL, :name => 'inactive', :optional => true} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end # A small structure for returning a list of notes out of a larger set. # #
#
startIndex
#
# The starting index within the overall set of notes. This # is also the number of notes that are "before" this list in the set. #
# #
totalNotes
#
# The number of notes in the larger set. This can be used # to calculate how many notes are "after" this note in the set. # (I.e. remaining = totalNotes - (startIndex + notes.length) ) #
# #
notes
#
# The list of notes from this range. The Notes will include all # metadata (attributes, resources, etc.), but will not include the ENML # content of the note or the binary contents of any resources. #
# #
stoppedWords
#
# If the NoteList was produced using a text based search # query that included words that are not indexed or searched by the service, # this will include a list of those ignored words. #
# #
searchedWords
#
# If the NoteList was produced using a text based search # query that included viable search words or quoted expressions, this will # include a list of those words. Any stopped words will not be included # in this list. #
#
class NoteList include ::Thrift::Struct, ::Thrift::Struct_Union STARTINDEX = 1 TOTALNOTES = 2 NOTES = 3 STOPPEDWORDS = 4 SEARCHEDWORDS = 5 FIELDS = { STARTINDEX => {:type => ::Thrift::Types::I32, :name => 'startIndex'}, TOTALNOTES => {:type => ::Thrift::Types::I32, :name => 'totalNotes'}, NOTES => {:type => ::Thrift::Types::LIST, :name => 'notes', :element => {:type => ::Thrift::Types::STRUCT, :class => Evernote::EDAM::Type::Note}}, STOPPEDWORDS => {:type => ::Thrift::Types::LIST, :name => 'stoppedWords', :element => {:type => ::Thrift::Types::STRING}, :optional => true}, SEARCHEDWORDS => {:type => ::Thrift::Types::LIST, :name => 'searchedWords', :element => {:type => ::Thrift::Types::STRING}, :optional => true} } def struct_fields; FIELDS; end def validate raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field startIndex is unset!') unless @startIndex raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field totalNotes is unset!') unless @totalNotes raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field notes is unset!') unless @notes end ::Thrift::Struct.generate_accessors self end # A data structure representing the number of notes for each notebook # and tag with a non-zero set of applicable notes. # #
#
notebookCounts
#
# A mapping from the Notebook GUID to the number of # notes (from some selection) that are in the corresponding notebook. #
# #
tagCounts
#
# A mapping from the Tag GUID to the number of notes (from some # selection) that have the corresponding tag. #
# #
trashCount
#
# If this is set, then this is the number of notes that are in the trash. # If this is not set, then the number of notes in the trash hasn't been # reported. (I.e. if there are no notes in the trash, this will be set # to 0.) #
#
class NoteCollectionCounts include ::Thrift::Struct, ::Thrift::Struct_Union NOTEBOOKCOUNTS = 1 TAGCOUNTS = 2 TRASHCOUNT = 3 FIELDS = { NOTEBOOKCOUNTS => {:type => ::Thrift::Types::MAP, :name => 'notebookCounts', :key => {:type => ::Thrift::Types::STRING}, :value => {:type => ::Thrift::Types::I32}, :optional => true}, TAGCOUNTS => {:type => ::Thrift::Types::MAP, :name => 'tagCounts', :key => {:type => ::Thrift::Types::STRING}, :value => {:type => ::Thrift::Types::I32}, :optional => true}, TRASHCOUNT => {:type => ::Thrift::Types::I32, :name => 'trashCount', :optional => true} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end # Information for tracking the display of a particular ad by a client. # #
#
adId
#
# The identifier for this ad, from a previous Ad.id given to the client #
# #
impressionCount
#
# The number of times this ad was displayed since the last successful # ad retrieval. The client should only report times the ad was selected # when the client was visible. #
# #
impressionTime
#
# The number of seconds that the client displayed the advertisement since # the last successful ad retrieval. This corresponds to the seconds that # the client application was visible. #
#
class AdImpressions include ::Thrift::Struct, ::Thrift::Struct_Union ADID = 1 IMPRESSIONCOUNT = 2 IMPRESSIONTIME = 3 FIELDS = { ADID => {:type => ::Thrift::Types::I32, :name => 'adId'}, IMPRESSIONCOUNT => {:type => ::Thrift::Types::I32, :name => 'impressionCount'}, IMPRESSIONTIME => {:type => ::Thrift::Types::I32, :name => 'impressionTime'} } def struct_fields; FIELDS; end def validate raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field adId is unset!') unless @adId raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field impressionCount is unset!') unless @impressionCount raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field impressionTime is unset!') unless @impressionTime end ::Thrift::Struct.generate_accessors self end # Parameters that will be given by a client to the service when it requests # a set of advertisements to display. If any of these values are omitted, # the service will use default values. # #
#
clientLanguage
#
# The ISO 639-1 language code for the primary language for the client. # If omitted, English will be assumed ('en'). #
# #
impressions
#
# A list of the impression counts and total display time for the ads # that were displayed in the last day. #
# #
supportHtml
#
# If true, the client requesting the ads supports ads specified via # general HTML (with rich media, Javascript, etc.). #
# #
clientProperties
#
# If provided, this may contain a set of key/value pairs that identify # the characteristics of a particular client that may be used to help # determine appropriate ads for that client. These tuples may be used # either to reduce or increase the likelihood that each ad will be # returned. #
#
class AdParameters include ::Thrift::Struct, ::Thrift::Struct_Union CLIENTLANGUAGE = 2 IMPRESSIONS = 4 SUPPORTHTML = 5 CLIENTPROPERTIES = 6 FIELDS = { CLIENTLANGUAGE => {:type => ::Thrift::Types::STRING, :name => 'clientLanguage', :optional => true}, IMPRESSIONS => {:type => ::Thrift::Types::LIST, :name => 'impressions', :element => {:type => ::Thrift::Types::STRUCT, :class => Evernote::EDAM::NoteStore::AdImpressions}, :optional => true}, SUPPORTHTML => {:type => ::Thrift::Types::BOOL, :name => 'supportHtml', :optional => true}, CLIENTPROPERTIES => {:type => ::Thrift::Types::MAP, :name => 'clientProperties', :key => {:type => ::Thrift::Types::STRING}, :value => {:type => ::Thrift::Types::STRING}, :optional => true} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end # Parameters that must be given to the NoteStore emailNote call. These allow # the caller to specify the note to send, the recipient addresses, etc. # #
#
guid
#
# If set, this must be the GUID of a note within the user's account that # should be retrieved from the service and sent as email. If not set, # the 'note' field must be provided instead. #
# #
note
#
# If the 'guid' field is not set, this field must be provided, including # the full contents of the note note (and all of its Resources) to send. # This can be used for a Note that as not been created in the service, # for example by a local client with local notes. #
# #
toAddresses
#
# If provided, this should contain a list of the SMTP email addresses # that should be included in the "To:" line of the email. # Callers must specify at least one "to" or "cc" email address. #
# #
ccAddresses
#
# If provided, this should contain a list of the SMTP email addresses # that should be included in the "Cc:" line of the email. # Callers must specify at least one "to" or "cc" email address. #
# #
subject
#
# If provided, this should contain the subject line of the email that # will be sent. If not provided, the title of the note will be used # as the subject of the email. #
# #
message
#
# If provided, this is additional personal text that should be included # into the email as a message from the owner to the recipient(s). #
#
class NoteEmailParameters include ::Thrift::Struct, ::Thrift::Struct_Union GUID = 1 NOTE = 2 TOADDRESSES = 3 CCADDRESSES = 4 SUBJECT = 5 MESSAGE = 6 FIELDS = { GUID => {:type => ::Thrift::Types::STRING, :name => 'guid', :optional => true}, NOTE => {:type => ::Thrift::Types::STRUCT, :name => 'note', :class => Evernote::EDAM::Type::Note, :optional => true}, TOADDRESSES => {:type => ::Thrift::Types::LIST, :name => 'toAddresses', :element => {:type => ::Thrift::Types::STRING}, :optional => true}, CCADDRESSES => {:type => ::Thrift::Types::LIST, :name => 'ccAddresses', :element => {:type => ::Thrift::Types::STRING}, :optional => true}, SUBJECT => {:type => ::Thrift::Types::STRING, :name => 'subject', :optional => true}, MESSAGE => {:type => ::Thrift::Types::STRING, :name => 'message', :optional => true} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end # Identfying information about previous versions of a note that are backed up # within Evernote's servers. Used in the return value of the listNoteVersions # call. # #
#
updateSequenceNum
#
# The update sequence number for the Note when it last had this content. # This serves to uniquely identify each version of the note, since USN # values are unique within an account for each update. #
#
updated
#
# The 'updated' time that was set on the Note when it had this version # of the content. This is the user-modifiable modification time on the # note, so it's not reliable for guaranteeing the order of various # versions. (E.g. if someone modifies the note, then changes this time # manually into the past and then updates the note again.) #
#
saved
#
# A timestamp that holds the date and time when this version of the note # was backed up by Evernote's servers. This #
#
title
#
# The title of the note when this particular verison was saved. (The # current title of the note may differ from this value.) #
#
class NoteVersionId include ::Thrift::Struct, ::Thrift::Struct_Union UPDATESEQUENCENUM = 1 UPDATED = 2 SAVED = 3 TITLE = 4 FIELDS = { UPDATESEQUENCENUM => {:type => ::Thrift::Types::I32, :name => 'updateSequenceNum'}, UPDATED => {:type => ::Thrift::Types::I64, :name => 'updated'}, SAVED => {:type => ::Thrift::Types::I64, :name => 'saved'}, TITLE => {:type => ::Thrift::Types::STRING, :name => 'title'} } def struct_fields; FIELDS; end def validate raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field updateSequenceNum is unset!') unless @updateSequenceNum raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field updated is unset!') unless @updated raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field saved is unset!') unless @saved raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field title is unset!') unless @title end ::Thrift::Struct.generate_accessors self end end end end evernote-mode-0_41/ruby/lib/Evernote/EDAM/types_types.rb0000664000175000017500000022340711513076422023100 0ustar uwabamiuwabami# # Autogenerated by Thrift # # DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING # require 'Evernote/EDAM/limits_types' module Evernote module EDAM module Type module PrivilegeLevel NORMAL = 1 PREMIUM = 3 MANAGER = 7 SUPPORT = 8 ADMIN = 9 VALUE_MAP = {1 => "NORMAL", 3 => "PREMIUM", 7 => "MANAGER", 8 => "SUPPORT", 9 => "ADMIN"} VALID_VALUES = Set.new([NORMAL, PREMIUM, MANAGER, SUPPORT, ADMIN]).freeze end module QueryFormat USER = 1 SEXP = 2 VALUE_MAP = {1 => "USER", 2 => "SEXP"} VALID_VALUES = Set.new([USER, SEXP]).freeze end module NoteSortOrder CREATED = 1 UPDATED = 2 RELEVANCE = 3 UPDATE_SEQUENCE_NUMBER = 4 TITLE = 5 VALUE_MAP = {1 => "CREATED", 2 => "UPDATED", 3 => "RELEVANCE", 4 => "UPDATE_SEQUENCE_NUMBER", 5 => "TITLE"} VALID_VALUES = Set.new([CREATED, UPDATED, RELEVANCE, UPDATE_SEQUENCE_NUMBER, TITLE]).freeze end module PremiumOrderStatus NONE = 0 PENDING = 1 ACTIVE = 2 FAILED = 3 CANCELLATION_PENDING = 4 CANCELED = 5 VALUE_MAP = {0 => "NONE", 1 => "PENDING", 2 => "ACTIVE", 3 => "FAILED", 4 => "CANCELLATION_PENDING", 5 => "CANCELED"} VALID_VALUES = Set.new([NONE, PENDING, ACTIVE, FAILED, CANCELLATION_PENDING, CANCELED]).freeze end # In several places, EDAM exchanges blocks of bytes of data for a component # which may be relatively large. For example: the contents of a clipped # HTML note, the bytes of an embedded image, or the recognition XML for # a large image. This structure is used in the protocol to represent # any of those large blocks of data when they are transmitted or when # they are only referenced their metadata. # #
#
bodyHash
#
This field carries a one-way hash of the contents of the # data body, in binary form. The hash function is MD5
# Length: EDAM_HASH_LEN (exactly) #
# #
size
#
The length, in bytes, of the data body. #
# #
body
#
This field is set to contain the binary contents of the data # whenever the resource is being transferred. If only metadata is # being exchanged, this field will be empty. For example, a client could # notify the service about the change to an attribute for a resource # without transmitting the binary resource contents. #
#
class Data include ::Thrift::Struct, ::Thrift::Struct_Union BODYHASH = 1 SIZE = 2 BODY = 3 FIELDS = { BODYHASH => {:type => ::Thrift::Types::STRING, :name => 'bodyHash', :binary => true, :optional => true}, SIZE => {:type => ::Thrift::Types::I32, :name => 'size', :optional => true}, BODY => {:type => ::Thrift::Types::STRING, :name => 'body', :binary => true, :optional => true} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end # A structure holding the optional attributes that can be stored # on a User. These are generally less critical than the core User fields. # #
#
defaultLocationName
#
the location string that should be associated # with the user in order to determine where notes are taken if not otherwise # specified.
# Length: EDAM_ATTRIBUTE_LEN_MIN - EDAM_ATTRIBUTE_LEN_MAX #
# #
defaultLatitude
#
if set, this is the latitude that should be # assigned to any notes that have no other latitude information. #
# #
defaultLongitude
#
if set, this is the longitude that should be # assigned to any notes that have no other longitude information. #
# #
preactivation
#
if set, the user account is not yet confirmed for # login. I.e. the account has been created, but we are still waiting for # the user to complete the activation step. #
# #
viewedPromotions
#
a list of promotions the user has seen. # This list may occasionally be modified by the system when promotions are # no longer available.
# Length: EDAM_ATTRIBUTE_LEN_MIN - EDAM_ATTRIBUTE_LEN_MAX #
# #
incomingEmailAddress
#
if set, this is the email address that the # user may send email to in order to add an email note directly into the # account via the SMTP email gateway. This is the part of the email # address before the '@' symbol ... our domain is not included. # If this is not set, the user may not add notes via the gateway.
# Length: EDAM_ATTRIBUTE_LEN_MIN - EDAM_ATTRIBUTE_LEN_MAX #
# #
recentMailedAddresses
#
if set, this will contain a list of email # addresses that have recently been used as recipients # of outbound emails by the user. This can be used to pre-populate a # list of possible destinations when a user wishes to send a note via # email.
# Length: EDAM_ATTRIBUTE_LEN_MIN - EDAM_ATTRIBUTE_LEN_MAX each
# Max: EDAM_USER_RECENT_MAILED_ADDRESSES_MAX entries #
# #
comments
#
Free-form text field that may hold general support # information, etc.
# Length: EDAM_ATTRIBUTE_LEN_MIN - EDAM_ATTRIBUTE_LEN_MAX #
# #
dateAgreedToTermsOfService
#
The date/time when the user agreed to # the terms of service. This can be used as the effective "start date" # for the account. #
# #
maxReferrals
#
The number of referrals that the user is permitted # to make. #
# #
referralCount
#
The number of referrals sent from this account. #
# #
refererCode
#
A code indicating where the user was sent from. AKA # promotion code #
# #
sentEmailDate
#
The most recent date when the user sent outbound # emails from the service. Used with sentEmailCount to limit the number # of emails that can be sent per day. #
# #
sentEmailCount
#
The number of emails that were sent from the user # via the service on sentEmailDate. Used to enforce a limit on the number # of emails per user per day to prevent spamming. #
# #
dailyEmailLimit
#
If set, this is the maximum number of emails that # may be sent in a given day from this account. If unset, the server will # use the configured default limit. #
# #
emailOptOutDate
#
If set, this is the date when the user asked # to be excluded from offers and promotions sent by Evernote. If not set, # then the user currently agrees to receive these messages. #
# #
partnerEmailOptInDate
#
If set, this is the date when the user asked # to be included in offers and promotions sent by Evernote's partners. # If not sent, then the user currently does not agree to receive these # emails. #
# #
preferredLanguage
#
a 2 character language codes based on: # http://ftp.ics.uci.edu/pub/ietf/http/related/iso639.txt used for # localization purposes to determine what language to use for the web # interface and for other direct communication (e.g. emails). #
# #
preferredCountry
#
Preferred country code based on ISO 3166-1-alpha-2 indicating the # users preferred country
# #
clipFullPage
#
Boolean flag set to true if the user wants to clip full pages by # default when they use the web clipper without a selection.
# #
twitterUserName
#
The username of the account of someone who has chosen to enable # Twittering into Evernote. This value is subject to change, since users # may change their Twitter user name.
# #
twitterId
#
The unique identifier of the user's Twitter account if that user # has chosen to enable Twittering into Evernote.
# #
groupName
#
A name identifier used to identify a particular set of branding and # light customization.
# #
recognitionLanguage
#
a 2 character language codes based on: # http://ftp.ics.uci.edu/pub/ietf/http/related/iso639.txt # If set, this is used to determine the language that should be used # when processing images and PDF files to find text. # If not set, then the 'preferredLanguage' will be used. #
#
# #
customerProfileId
#
a numeric identified which provides a linkage between the user record # and the direct credit card payment creditcard profile. #
# # class UserAttributes include ::Thrift::Struct, ::Thrift::Struct_Union DEFAULTLOCATIONNAME = 1 DEFAULTLATITUDE = 2 DEFAULTLONGITUDE = 3 PREACTIVATION = 4 VIEWEDPROMOTIONS = 5 INCOMINGEMAILADDRESS = 6 RECENTMAILEDADDRESSES = 7 COMMENTS = 9 DATEAGREEDTOTERMSOFSERVICE = 11 MAXREFERRALS = 12 REFERRALCOUNT = 13 REFERERCODE = 14 SENTEMAILDATE = 15 SENTEMAILCOUNT = 16 DAILYEMAILLIMIT = 17 EMAILOPTOUTDATE = 18 PARTNEREMAILOPTINDATE = 19 PREFERREDLANGUAGE = 20 PREFERREDCOUNTRY = 21 CLIPFULLPAGE = 22 TWITTERUSERNAME = 23 TWITTERID = 24 GROUPNAME = 25 RECOGNITIONLANGUAGE = 26 CUSTOMERPROFILEID = 27 REFERRALPROOF = 28 FIELDS = { DEFAULTLOCATIONNAME => {:type => ::Thrift::Types::STRING, :name => 'defaultLocationName', :optional => true}, DEFAULTLATITUDE => {:type => ::Thrift::Types::DOUBLE, :name => 'defaultLatitude', :optional => true}, DEFAULTLONGITUDE => {:type => ::Thrift::Types::DOUBLE, :name => 'defaultLongitude', :optional => true}, PREACTIVATION => {:type => ::Thrift::Types::BOOL, :name => 'preactivation', :optional => true}, VIEWEDPROMOTIONS => {:type => ::Thrift::Types::LIST, :name => 'viewedPromotions', :element => {:type => ::Thrift::Types::STRING}, :optional => true}, INCOMINGEMAILADDRESS => {:type => ::Thrift::Types::STRING, :name => 'incomingEmailAddress', :optional => true}, RECENTMAILEDADDRESSES => {:type => ::Thrift::Types::LIST, :name => 'recentMailedAddresses', :element => {:type => ::Thrift::Types::STRING}, :optional => true}, COMMENTS => {:type => ::Thrift::Types::STRING, :name => 'comments', :optional => true}, DATEAGREEDTOTERMSOFSERVICE => {:type => ::Thrift::Types::I64, :name => 'dateAgreedToTermsOfService', :optional => true}, MAXREFERRALS => {:type => ::Thrift::Types::I32, :name => 'maxReferrals', :optional => true}, REFERRALCOUNT => {:type => ::Thrift::Types::I32, :name => 'referralCount', :optional => true}, REFERERCODE => {:type => ::Thrift::Types::STRING, :name => 'refererCode', :optional => true}, SENTEMAILDATE => {:type => ::Thrift::Types::I64, :name => 'sentEmailDate', :optional => true}, SENTEMAILCOUNT => {:type => ::Thrift::Types::I32, :name => 'sentEmailCount', :optional => true}, DAILYEMAILLIMIT => {:type => ::Thrift::Types::I32, :name => 'dailyEmailLimit', :optional => true}, EMAILOPTOUTDATE => {:type => ::Thrift::Types::I64, :name => 'emailOptOutDate', :optional => true}, PARTNEREMAILOPTINDATE => {:type => ::Thrift::Types::I64, :name => 'partnerEmailOptInDate', :optional => true}, PREFERREDLANGUAGE => {:type => ::Thrift::Types::STRING, :name => 'preferredLanguage', :optional => true}, PREFERREDCOUNTRY => {:type => ::Thrift::Types::STRING, :name => 'preferredCountry', :optional => true}, CLIPFULLPAGE => {:type => ::Thrift::Types::BOOL, :name => 'clipFullPage', :optional => true}, TWITTERUSERNAME => {:type => ::Thrift::Types::STRING, :name => 'twitterUserName', :optional => true}, TWITTERID => {:type => ::Thrift::Types::STRING, :name => 'twitterId', :optional => true}, GROUPNAME => {:type => ::Thrift::Types::STRING, :name => 'groupName', :optional => true}, RECOGNITIONLANGUAGE => {:type => ::Thrift::Types::STRING, :name => 'recognitionLanguage', :optional => true}, CUSTOMERPROFILEID => {:type => ::Thrift::Types::I64, :name => 'customerProfileId', :optional => true}, REFERRALPROOF => {:type => ::Thrift::Types::STRING, :name => 'referralProof', :optional => true} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end # This represents the bookkeeping information for the user's subscription. # #
#
uploadLimit
#
The number of bytes that can be uploaded to the account # in the current month. For new notes that are created, this is the length # of the note content (in Unicode characters) plus the size of each resource # (in bytes). For edited notes, this is the the difference between the old # length and the new length (if this is greater than 0) plus the size of # each new resource. #
#
uploadLimitEnd
#
The date and time when the current upload limit # expires. At this time, the monthly upload count reverts to 0 and a new # limit is imposed. This date and time is exclusive, so this is effectively # the start of the new month. #
#
uploadLimitNextMonth
#
When uploadLimitEnd is reached, the service # will change uploadLimit to uploadLimitNextMonth. If a premium account is # canceled, this mechanism will reset the quota appropriately. #
#
premiumServiceStatus
#
Indicates the phases of a premium account # during the billing process. #
#
premiumOrderNumber
#
The order number used by the commerce system to # process recurring payments #
#
premiumServiceStart
#
The start date when this premium promotion # began (this number will get overwritten if a premium service is canceled # and then re-activated). #
#
premiumCommerceService
#
The commerce system used (paypal, Google # checkout, etc) #
#
premiumServiceSKU
#
The code associated with the purchase eg. monthly # or annual purchase. Clients should interpret this value and localize it. #
#
lastSuccessfulCharge
#
Date the last time the user was charged. # Null if never charged. #
#
lastFailedCharge
#
Date the last time a charge was attempted and # failed. #
#
lastFailedChargeReason
#
Reason provided for the charge failure #
#
nextPaymentDue
#
The end of the billing cycle. This could be in the # past if there are failed charges. #
#
premiumLockUntil
#
An internal variable to manage locking operations # on the commerce variables. #
#
updated
#
The date any modification where made to this record. #
#
premiumSubscriptionNumber
#
The number number identifying the # recurring subscription used to make the recurring charges. #
#
class Accounting include ::Thrift::Struct, ::Thrift::Struct_Union UPLOADLIMIT = 1 UPLOADLIMITEND = 2 UPLOADLIMITNEXTMONTH = 3 PREMIUMSERVICESTATUS = 4 PREMIUMORDERNUMBER = 5 PREMIUMCOMMERCESERVICE = 6 PREMIUMSERVICESTART = 7 PREMIUMSERVICESKU = 8 LASTSUCCESSFULCHARGE = 9 LASTFAILEDCHARGE = 10 LASTFAILEDCHARGEREASON = 11 NEXTPAYMENTDUE = 12 PREMIUMLOCKUNTIL = 13 UPDATED = 14 PREMIUMSUBSCRIPTIONNUMBER = 16 LASTREQUESTEDCHARGE = 17 FIELDS = { UPLOADLIMIT => {:type => ::Thrift::Types::I64, :name => 'uploadLimit', :optional => true}, UPLOADLIMITEND => {:type => ::Thrift::Types::I64, :name => 'uploadLimitEnd', :optional => true}, UPLOADLIMITNEXTMONTH => {:type => ::Thrift::Types::I64, :name => 'uploadLimitNextMonth', :optional => true}, PREMIUMSERVICESTATUS => {:type => ::Thrift::Types::I32, :name => 'premiumServiceStatus', :optional => true, :enum_class => Evernote::EDAM::Type::PremiumOrderStatus}, PREMIUMORDERNUMBER => {:type => ::Thrift::Types::STRING, :name => 'premiumOrderNumber', :optional => true}, PREMIUMCOMMERCESERVICE => {:type => ::Thrift::Types::STRING, :name => 'premiumCommerceService', :optional => true}, PREMIUMSERVICESTART => {:type => ::Thrift::Types::I64, :name => 'premiumServiceStart', :optional => true}, PREMIUMSERVICESKU => {:type => ::Thrift::Types::STRING, :name => 'premiumServiceSKU', :optional => true}, LASTSUCCESSFULCHARGE => {:type => ::Thrift::Types::I64, :name => 'lastSuccessfulCharge', :optional => true}, LASTFAILEDCHARGE => {:type => ::Thrift::Types::I64, :name => 'lastFailedCharge', :optional => true}, LASTFAILEDCHARGEREASON => {:type => ::Thrift::Types::STRING, :name => 'lastFailedChargeReason', :optional => true}, NEXTPAYMENTDUE => {:type => ::Thrift::Types::I64, :name => 'nextPaymentDue', :optional => true}, PREMIUMLOCKUNTIL => {:type => ::Thrift::Types::I64, :name => 'premiumLockUntil', :optional => true}, UPDATED => {:type => ::Thrift::Types::I64, :name => 'updated', :optional => true}, PREMIUMSUBSCRIPTIONNUMBER => {:type => ::Thrift::Types::STRING, :name => 'premiumSubscriptionNumber', :optional => true}, LASTREQUESTEDCHARGE => {:type => ::Thrift::Types::I64, :name => 'lastRequestedCharge', :optional => true} } def struct_fields; FIELDS; end def validate unless @premiumServiceStatus.nil? || Evernote::EDAM::Type::PremiumOrderStatus::VALID_VALUES.include?(@premiumServiceStatus) raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Invalid value of field premiumServiceStatus!') end end ::Thrift::Struct.generate_accessors self end # This represents the information about a single user account. #
#
id
#
The unique numeric identifier for the account, which will not # change for the lifetime of the account. #
# #
username
#
The name that the user provides to log in to their # account. In the future, this may be empty for some accounts if their login # process is indirect (e.g. via social networks, etc.). # May only contain a-z, 0-9, or '-', and may not start or end with the '-' #
# Length: EDAM_USER_USERNAME_LEN_MIN - EDAM_USER_USERNAME_LEN_MAX #
# Regex: EDAM_USER_USERNAME_REGEX #
# #
email
#
The email address registered for the user. Must comply with # RFC 2821 and RFC 2822.
# Length: EDAM_EMAIL_LEN_MIN - EDAM_EMAIL_LEN_MAX #
# Regex: EDAM_EMAIL_REGEX #
# #
name
#
The printable name of the user, which may be a combination # of given and family names. This is used instead of separate "first" # and "last" names due to variations in international name format/order. # May not start or end with a whitespace character. May contain any # character but carriage return or newline (Unicode classes Zl and Zp). #
# Length: EDAM_USER_NAME_LEN_MIN - EDAM_USER_NAME_LEN_MAX #
# Regex: EDAM_USER_NAME_REGEX #
# #
timezone
#
The zone ID for the user's default location. If present, # this may be used to localize the display of any timestamp for which no # other timezone is available - for example, an note that arrives via # a micro-browser may not contain enough information to display its # local time, so this default timezone may be assigned to the note. # The format must be encoded as a standard zone ID such as # "America/Los_Angeles" or "GMT+08:00" #
# Length: EDAM_TIMEZONE_LEN_MIN - EDAM_TIMEZONE_LEN_MAX #
# Regex: EDAM_TIMEZONE_REGEX #
# #
privilege
#
The level of access permitted for the user. #
# #
created
#
The date and time when this user account was created in the # service. #
# #
updated
#
The date and time when this user account was last modified # in the service. #
# #
deleted
#
If the account has been deleted from the system (e.g. as # the result of a legal request by the user), the date and time of the # deletion will be represented here. If not, this value will not be set. #
# #
active
#
If the user account is available for login and # synchronization, this flag will be set to true. #
# #
shardId
#
The name of the virtual server that manages the state of # this user. This value is used internally to determine which system should # service requests about this user's data. #
# #
attributes
#
If present, this will contain a list of the attributes # for this user account. #
# #
accounting
#
Bookkeeping information for the user's subscription. #
#
class User include ::Thrift::Struct, ::Thrift::Struct_Union ID = 1 USERNAME = 2 EMAIL = 3 NAME = 4 TIMEZONE = 6 PRIVILEGE = 7 CREATED = 9 UPDATED = 10 DELETED = 11 ACTIVE = 13 SHARDID = 14 ATTRIBUTES = 15 ACCOUNTING = 16 FIELDS = { ID => {:type => ::Thrift::Types::I32, :name => 'id', :optional => true}, USERNAME => {:type => ::Thrift::Types::STRING, :name => 'username', :optional => true}, EMAIL => {:type => ::Thrift::Types::STRING, :name => 'email', :optional => true}, NAME => {:type => ::Thrift::Types::STRING, :name => 'name', :optional => true}, TIMEZONE => {:type => ::Thrift::Types::STRING, :name => 'timezone', :optional => true}, PRIVILEGE => {:type => ::Thrift::Types::I32, :name => 'privilege', :optional => true, :enum_class => Evernote::EDAM::Type::PrivilegeLevel}, CREATED => {:type => ::Thrift::Types::I64, :name => 'created', :optional => true}, UPDATED => {:type => ::Thrift::Types::I64, :name => 'updated', :optional => true}, DELETED => {:type => ::Thrift::Types::I64, :name => 'deleted', :optional => true}, ACTIVE => {:type => ::Thrift::Types::BOOL, :name => 'active', :optional => true}, SHARDID => {:type => ::Thrift::Types::STRING, :name => 'shardId', :optional => true}, ATTRIBUTES => {:type => ::Thrift::Types::STRUCT, :name => 'attributes', :class => Evernote::EDAM::Type::UserAttributes, :optional => true}, ACCOUNTING => {:type => ::Thrift::Types::STRUCT, :name => 'accounting', :class => Evernote::EDAM::Type::Accounting, :optional => true} } def struct_fields; FIELDS; end def validate unless @privilege.nil? || Evernote::EDAM::Type::PrivilegeLevel::VALID_VALUES.include?(@privilege) raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Invalid value of field privilege!') end end ::Thrift::Struct.generate_accessors self end # A tag within a user's account is a unique name which may be organized # a simple hierarchy. #
#
guid
#
The unique identifier of this tag. Will be set by the service, # so may be omitted by the client when creating the Tag. #
# Length: EDAM_GUID_LEN_MIN - EDAM_GUID_LEN_MAX #
# Regex: EDAM_GUID_REGEX #
# #
name
#
A sequence of characters representing the tag's identifier. # Case is preserved, but is ignored for comparisons. # This means that an account may only have one tag with a given name, via # case-insensitive comparison, so an account may not have both "food" and # "Food" tags. # May not contain a comma (','), and may not begin or end with a space. #
# Length: EDAM_TAG_NAME_LEN_MIN - EDAM_TAG_NAME_LEN_MAX #
# Regex: EDAM_TAG_NAME_REGEX #
# #
parentGuid
#
If this is set, then this is the GUID of the tag that # holds this tag within the tag organizational heirarchy. If this is # not set, then the tag has no parent and it is a "top level" tag. # Cycles are not allowed (e.g. a->parent->parent == a) and will be # rejected by the service. #
# Length: EDAM_GUID_LEN_MIN - EDAM_GUID_LEN_MAX #
# Regex: EDAM_GUID_REGEX #
# #
updateSequenceNum
#
A number identifying the last transaction to # modify the state of this object. The USN values are sequential within an # account, and can be used to compare the order of modifications within the # service. #
#
class Tag include ::Thrift::Struct, ::Thrift::Struct_Union GUID = 1 NAME = 2 PARENTGUID = 3 UPDATESEQUENCENUM = 4 FIELDS = { GUID => {:type => ::Thrift::Types::STRING, :name => 'guid', :optional => true}, NAME => {:type => ::Thrift::Types::STRING, :name => 'name', :optional => true}, PARENTGUID => {:type => ::Thrift::Types::STRING, :name => 'parentGuid', :optional => true}, UPDATESEQUENCENUM => {:type => ::Thrift::Types::I32, :name => 'updateSequenceNum', :optional => true} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end # Structure holding the optional attributes of a Resource #
#
sourceURL
#
the original location where the resource was hosted #
# Length: EDAM_ATTRIBUTE_LEN_MIN - EDAM_ATTRIBUTE_LEN_MAX #
# #
timestamp
#
the date and time that is associated with this resource # (e.g. the time embedded in an image from a digital camera with a clock) #
# #
latitude
#
the latitude where the resource was captured #
# #
longitude
#
the longitude where the resource was captured #
# #
altitude
#
the altitude where the resource was captured #
# #
cameraMake
#
information about an image's camera, e.g. as embedded in # the image's EXIF data #
# Length: EDAM_ATTRIBUTE_LEN_MIN - EDAM_ATTRIBUTE_LEN_MAX #
# #
cameraModel
#
information about an image's camera, e.g. as embedded # in the image's EXIF data #
# Length: EDAM_ATTRIBUTE_LEN_MIN - EDAM_ATTRIBUTE_LEN_MAX #
# #
clientWillIndex
#
if true, then the original client that submitted # the resource plans to submit the recognition index for this resource at a # later time. #
# #
recoType
#
DEPRECATED - this field is no longer set by the service, so should # be ignored. #
# #
fileName
#
if the resource came from a source that provided an # explicit file name, the original name will be stored here. Many resources # come from unnamed sources, so this will not always be set. #
# #
attachment
#
this will be true if the resource is a Premium file attachment. This # will be available within the search grammar so that you can identify # notes that contain attachments. #
#
class ResourceAttributes include ::Thrift::Struct, ::Thrift::Struct_Union SOURCEURL = 1 TIMESTAMP = 2 LATITUDE = 3 LONGITUDE = 4 ALTITUDE = 5 CAMERAMAKE = 6 CAMERAMODEL = 7 CLIENTWILLINDEX = 8 RECOTYPE = 9 FILENAME = 10 ATTACHMENT = 11 FIELDS = { SOURCEURL => {:type => ::Thrift::Types::STRING, :name => 'sourceURL', :optional => true}, TIMESTAMP => {:type => ::Thrift::Types::I64, :name => 'timestamp', :optional => true}, LATITUDE => {:type => ::Thrift::Types::DOUBLE, :name => 'latitude', :optional => true}, LONGITUDE => {:type => ::Thrift::Types::DOUBLE, :name => 'longitude', :optional => true}, ALTITUDE => {:type => ::Thrift::Types::DOUBLE, :name => 'altitude', :optional => true}, CAMERAMAKE => {:type => ::Thrift::Types::STRING, :name => 'cameraMake', :optional => true}, CAMERAMODEL => {:type => ::Thrift::Types::STRING, :name => 'cameraModel', :optional => true}, CLIENTWILLINDEX => {:type => ::Thrift::Types::BOOL, :name => 'clientWillIndex', :optional => true}, RECOTYPE => {:type => ::Thrift::Types::STRING, :name => 'recoType', :optional => true}, FILENAME => {:type => ::Thrift::Types::STRING, :name => 'fileName', :optional => true}, ATTACHMENT => {:type => ::Thrift::Types::BOOL, :name => 'attachment', :optional => true} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end # Every media file that is embedded or attached to a note is represented # through a Resource entry. #
#
guid
#
The unique identifier of this resource. Will be set whenever # a resource is retrieved from the service, but may be null when a client # is creating a resource. #
# Length: EDAM_GUID_LEN_MIN - EDAM_GUID_LEN_MAX #
# Regex: EDAM_GUID_REGEX #
# #
noteGuid
#
The unique identifier of the Note that holds this # Resource. Will be set whenever the resource is retrieved from the service, # but may be null when a client is creating a resource. #
# Length: EDAM_GUID_LEN_MIN - EDAM_GUID_LEN_MAX #
# Regex: EDAM_GUID_REGEX #
# #
data
#
The contents of the resource. # Maximum length: The data.body is limited to EDAM_RESOURCE_SIZE_MAX_FREE # for free accounts and EDAM_RESOURCE_SIZE_MAX_PREMIUM for premium accounts. #
# #
mime
#
The MIME type for the embedded resource. E.g. "image/gif" #
# Length: EDAM_MIME_LEN_MIN - EDAM_MIME_LEN_MAX #
# Regex: EDAM_MIME_REGEX #
# #
width
#
If set, this contains the display width of this resource, in # pixels. #
# #
height
#
If set, this contains the display height of this resource, # in pixels. #
# #
duration
#
DEPRECATED: ignored. #
# #
active
#
DEPRECATED: ignored. #
# #
recognition
#
If set, this will hold the encoded data that provides # information on search and recognition within this resource. #
# #
attributes
#
A list of the attributes for this resource. #
# #
updateSequenceNum
#
A number identifying the last transaction to # modify the state of this object. The USN values are sequential within an # account, and can be used to compare the order of modifications within the # service. #
# #
alternateData
#
Some Resources may be assigned an alternate data format by the service # which may be more appropriate for indexing or rendering than the original # data provided by the user. In these cases, the alternate data form will # be available via this Data element. If a Resource has no alternate form, # this field will be unset.
#
class Resource include ::Thrift::Struct, ::Thrift::Struct_Union GUID = 1 NOTEGUID = 2 DATA = 3 MIME = 4 WIDTH = 5 HEIGHT = 6 DURATION = 7 ACTIVE = 8 RECOGNITION = 9 ATTRIBUTES = 11 UPDATESEQUENCENUM = 12 ALTERNATEDATA = 13 FIELDS = { GUID => {:type => ::Thrift::Types::STRING, :name => 'guid', :optional => true}, NOTEGUID => {:type => ::Thrift::Types::STRING, :name => 'noteGuid', :optional => true}, DATA => {:type => ::Thrift::Types::STRUCT, :name => 'data', :class => Evernote::EDAM::Type::Data, :optional => true}, MIME => {:type => ::Thrift::Types::STRING, :name => 'mime', :optional => true}, WIDTH => {:type => ::Thrift::Types::I16, :name => 'width', :optional => true}, HEIGHT => {:type => ::Thrift::Types::I16, :name => 'height', :optional => true}, DURATION => {:type => ::Thrift::Types::I16, :name => 'duration', :optional => true}, ACTIVE => {:type => ::Thrift::Types::BOOL, :name => 'active', :optional => true}, RECOGNITION => {:type => ::Thrift::Types::STRUCT, :name => 'recognition', :class => Evernote::EDAM::Type::Data, :optional => true}, ATTRIBUTES => {:type => ::Thrift::Types::STRUCT, :name => 'attributes', :class => Evernote::EDAM::Type::ResourceAttributes, :optional => true}, UPDATESEQUENCENUM => {:type => ::Thrift::Types::I32, :name => 'updateSequenceNum', :optional => true}, ALTERNATEDATA => {:type => ::Thrift::Types::STRUCT, :name => 'alternateData', :class => Evernote::EDAM::Type::Data, :optional => true} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end # The list of optional attributes that can be stored on a note. #
#
subjectDate
#
time that the note refers to #
# #
latitude
#
the latitude where the note was taken #
# #
longitude
#
the longitude where the note was taken #
# #
altitude
#
the altitude where the note was taken #
# #
author
#
the author of the content of the note #
# Length: EDAM_ATTRIBUTE_LEN_MIN - EDAM_ATTRIBUTE_LEN_MAX #
# #
source
#
the method that the note was added to the account, if the # note wasn't directly authored in an Evernote client. #
# Length: EDAM_ATTRIBUTE_LEN_MIN - EDAM_ATTRIBUTE_LEN_MAX #
# #
sourceURL
#
the original location where the resource was hosted #
# Length: EDAM_ATTRIBUTE_LEN_MIN - EDAM_ATTRIBUTE_LEN_MAX #
# #
sourceApplication
#
an identifying string for the application that # created this note. This string does not have a guaranteed syntax or # structure -- it is intended for human inspection and tracking. #
# Length: EDAM_ATTRIBUTE_LEN_MIN - EDAM_ATTRIBUTE_LEN_MAX #
#
class NoteAttributes include ::Thrift::Struct, ::Thrift::Struct_Union SUBJECTDATE = 1 LATITUDE = 10 LONGITUDE = 11 ALTITUDE = 12 AUTHOR = 13 SOURCE = 14 SOURCEURL = 15 SOURCEAPPLICATION = 16 FIELDS = { SUBJECTDATE => {:type => ::Thrift::Types::I64, :name => 'subjectDate', :optional => true}, LATITUDE => {:type => ::Thrift::Types::DOUBLE, :name => 'latitude', :optional => true}, LONGITUDE => {:type => ::Thrift::Types::DOUBLE, :name => 'longitude', :optional => true}, ALTITUDE => {:type => ::Thrift::Types::DOUBLE, :name => 'altitude', :optional => true}, AUTHOR => {:type => ::Thrift::Types::STRING, :name => 'author', :optional => true}, SOURCE => {:type => ::Thrift::Types::STRING, :name => 'source', :optional => true}, SOURCEURL => {:type => ::Thrift::Types::STRING, :name => 'sourceURL', :optional => true}, SOURCEAPPLICATION => {:type => ::Thrift::Types::STRING, :name => 'sourceApplication', :optional => true} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end # Represents a single note in the user's account. # #
#
guid
#
The unique identifier of this note. Will be set by the # server, but will be omitted by clients calling NoteStore.createNote() #
# Length: EDAM_GUID_LEN_MIN - EDAM_GUID_LEN_MAX #
# Regex: EDAM_GUID_REGEX #
# #
title
#
The subject of the note. Can't begin or end with a space. #
# Length: EDAM_NOTE_TITLE_LEN_MIN - EDAM_NOTE_TITLE_LEN_MAX #
# Regex: EDAM_NOTE_TITLE_REGEX #
# #
content
#
The XHTML block that makes up the note. This is # the canonical form of the note's contents, so will include abstract # Evernote tags for internal resource references. A client may create # a separate transformed version of this content for internal presentation, # but the same canonical bytes should be used for transmission and # comparison unless the user chooses to modify their content. #
# Length: EDAM_NOTE_CONTENT_LEN_MIN - EDAM_NOTE_CONTENT_LEN_MAX #
# #
contentHash
#
The binary MD5 checksum of the UTF-8 encoded content # body. This will always be set by the server, but clients may choose to omit # this when they submit a note with content. #
# Length: EDAM_HASH_LEN (exactly) #
# #
contentLength
#
The number of Unicode characters in the content of # the note. This will always be set by the service, but clients may choose # to omit this value when they submit a Note. #
# #
created
#
The date and time when the note was created in one of the # clients. In most cases, this will match the user's sense of when # the note was created, and ordering between notes will be based on # ordering of this field. However, this is not a "reliable" timestamp # if a client has an incorrect clock, so it cannot provide a true absolute # ordering between notes. Notes created directly through the service # (e.g. via the web GUI) will have an absolutely ordered "created" value. #
# #
updated
#
The date and time when the note was last modified in one of # the clients. In most cases, this will match the user's sense of when # the note was modified, but this field may not be absolutely reliable # due to the possibility of client clock errors. #
# #
deleted
#
If present, the note is considered "deleted", and this # stores the date and time when the note was deleted by one of the clients. # In most cases, this will match the user's sense of when the note was # deleted, but this field may be unreliable due to the possibility of # client clock errors. #
# #
active
#
If the note is available for normal actions and viewing, # this flag will be set to true. #
# #
updateSequenceNum
#
A number identifying the last transaction to # modify the state of this note (including changes to the note's attributes # or resources). The USN values are sequential within an account, # and can be used to compare the order of modifications within the service. #
# #
notebookGuid
#
The unique identifier of the notebook that contains # this note. If no notebookGuid is provided on a call to createNote(), the # default notebook will be used instead. #
# Length: EDAM_GUID_LEN_MIN - EDAM_GUID_LEN_MAX #
# Regex: EDAM_GUID_REGEX #
# #
tagGuids
#
A list of the GUID identifiers for tags that are applied to this note. # This may be provided in a call to createNote() to unambiguously declare # the tags that should be assigned to the new note. Alternately, clients # may pass the names of desired tags via the 'tagNames' field during # note creation. # If the list of tags are omitted on a call to createNote(), then # the server will assume that no changes have been made to the resources. # Maximum: EDAM_NOTE_TAGS_MAX tags per note #
# #
resources
#
The list of resources that are embedded within this note. # If the list of resources are omitted on a call to updateNote(), then # the server will assume that no changes have been made to the resources. # The binary contents of the resources must be provided when the resource # is first sent to the service, but it will be omitted by the service when # the Note is returned in the future. # Maximum: EDAM_NOTE_RESOURCES_MAX resources per note #
# #
attributes
#
A list of the attributes for this note. # If the list of attributes are omitted on a call to updateNote(), then # the server will assume that no changes have been made to the resources. #
# #
tagNames
#
May be provided by clients during calls to createNote() as an # alternative to providing the tagGuids of existing tags. If any tagNames # are provided during createNote(), these will be found, or created if they # don't already exist. Created tags will have no parent (they will be at # the top level of the tag panel). #
#
class Note include ::Thrift::Struct, ::Thrift::Struct_Union GUID = 1 TITLE = 2 CONTENT = 3 CONTENTHASH = 4 CONTENTLENGTH = 5 CREATED = 6 UPDATED = 7 DELETED = 8 ACTIVE = 9 UPDATESEQUENCENUM = 10 NOTEBOOKGUID = 11 TAGGUIDS = 12 RESOURCES = 13 ATTRIBUTES = 14 TAGNAMES = 15 FIELDS = { GUID => {:type => ::Thrift::Types::STRING, :name => 'guid', :optional => true}, TITLE => {:type => ::Thrift::Types::STRING, :name => 'title', :optional => true}, CONTENT => {:type => ::Thrift::Types::STRING, :name => 'content', :optional => true}, CONTENTHASH => {:type => ::Thrift::Types::STRING, :name => 'contentHash', :binary => true, :optional => true}, CONTENTLENGTH => {:type => ::Thrift::Types::I32, :name => 'contentLength', :optional => true}, CREATED => {:type => ::Thrift::Types::I64, :name => 'created', :optional => true}, UPDATED => {:type => ::Thrift::Types::I64, :name => 'updated', :optional => true}, DELETED => {:type => ::Thrift::Types::I64, :name => 'deleted', :optional => true}, ACTIVE => {:type => ::Thrift::Types::BOOL, :name => 'active', :optional => true}, UPDATESEQUENCENUM => {:type => ::Thrift::Types::I32, :name => 'updateSequenceNum', :optional => true}, NOTEBOOKGUID => {:type => ::Thrift::Types::STRING, :name => 'notebookGuid', :optional => true}, TAGGUIDS => {:type => ::Thrift::Types::LIST, :name => 'tagGuids', :element => {:type => ::Thrift::Types::STRING}, :optional => true}, RESOURCES => {:type => ::Thrift::Types::LIST, :name => 'resources', :element => {:type => ::Thrift::Types::STRUCT, :class => Evernote::EDAM::Type::Resource}, :optional => true}, ATTRIBUTES => {:type => ::Thrift::Types::STRUCT, :name => 'attributes', :class => Evernote::EDAM::Type::NoteAttributes, :optional => true}, TAGNAMES => {:type => ::Thrift::Types::LIST, :name => 'tagNames', :element => {:type => ::Thrift::Types::STRING}, :optional => true} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end # If a Notebook has been opened to the public, the Notebook will have a # reference to one of these structures, which gives the location and optional # description of the externally-visible public Notebook. #
#
uri
#
If this field is present, then the notebook is published for # mass consumption on the Internet under the provided URI, which is # relative to a defined base publishing URI defined by the service. # This field can only be modified via the web service GUI ... publishing # cannot be modified via an offline client. #
# Length: EDAM_PUBLISHING_URI_LEN_MIN - EDAM_PUBLISHING_URI_LEN_MAX #
# Regex: EDAM_PUBLISHING_URI_REGEX #
# #
order
#
When the notes are publicly displayed, they will be sorted # based on the requested criteria. #
# #
ascending
#
If this is set to true, then the public notes will be # displayed in ascending order (e.g. from oldest to newest). Otherwise, # the notes will be displayed in descending order (e.g. newest to oldest). #
# #
publicDescription
#
This field may be used to provide a short # description of the notebook, which may be displayed when (e.g.) the # notebook is shown in a public view. Can't begin or end with a space. #
# Length: EDAM_PUBLISHING_DESCRIPTION_LEN_MIN - # EDAM_PUBLISHING_DESCRIPTION_LEN_MAX #
# Regex: EDAM_PUBLISHING_DESCRIPTION_REGEX #
#
class Publishing include ::Thrift::Struct, ::Thrift::Struct_Union URI = 1 ORDER = 2 ASCENDING = 3 PUBLICDESCRIPTION = 4 FIELDS = { URI => {:type => ::Thrift::Types::STRING, :name => 'uri', :optional => true}, ORDER => {:type => ::Thrift::Types::I32, :name => 'order', :optional => true, :enum_class => Evernote::EDAM::Type::NoteSortOrder}, ASCENDING => {:type => ::Thrift::Types::BOOL, :name => 'ascending', :optional => true}, PUBLICDESCRIPTION => {:type => ::Thrift::Types::STRING, :name => 'publicDescription', :optional => true} } def struct_fields; FIELDS; end def validate unless @order.nil? || Evernote::EDAM::Type::NoteSortOrder::VALID_VALUES.include?(@order) raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Invalid value of field order!') end end ::Thrift::Struct.generate_accessors self end # A unique container for a set of notes. #
#
guid
#
The unique identifier of this notebook. #
# Length: EDAM_GUID_LEN_MIN - EDAM_GUID_LEN_MAX #
# Regex: EDAM_GUID_REGEX #
# #
name
#
A sequence of characters representing the name of the # notebook. May be changed by clients, but the account may not contain two # notebooks with names that are equal via a case-insensitive comparison. # Can't begin or end with a space. #
# Length: EDAM_NOTEBOOK_NAME_LEN_MIN - EDAM_NOTEBOOK_NAME_LEN_MAX #
# Regex: EDAM_NOTEBOOK_NAME_REGEX #
# #
updateSequenceNum
#
A number identifying the last transaction to # modify the state of this object. The USN values are sequential within an # account, and can be used to compare the order of modifications within the # service. #
# #
defaultNotebook
#
If true, this notebook should be used for new notes # whenever the user has not (or cannot) specify a desired target notebook. # For example, if a note is submitted via SMTP email. # The service will maintain at most one defaultNotebook per account. # If a second notebook is created or updated with defaultNotebook set to # true, the service will automatically update the prior notebook's # defaultNotebook field to false. If the default notebook is deleted # (i.e. "active" set to false), the "defaultNotebook" field will be # set to false by the service. If the account has no default notebook # set, the service will use the most recent notebook as the default. #
# #
serviceCreated
#
The time when this notebook was created on the # service. This will be set on the service during creation, and the service # will provide this value when it returns a Notebook to a client. # The service will ignore this value if it is sent by clients. #
# #
serviceUpdated
#
The time when this notebook was last modified on the # service. This will be set on the service during creation, and the service # will provide this value when it returns a Notebook to a client. # The service will ignore this value if it is sent by clients. #
# #
publishing
#
If the Notebook has been opened for public access (i.e. # if 'published' is set to true), then this will point to the set of # publishing information for the Notebook (URI, description, etc.). A # Notebook cannot be published without providing this information, but it # will persist for later use if publishing is ever disabled on the Notebook. # Clients that do not wish to change the publishing behavior of a Notebook # should not set this value when calling NoteStore.updateNotebook(). #
# #
published
#
If this is set to true, then the Notebook will be # accessible to the public via the 'publishing' specification, which must # also be set. If this is set to false, the Notebook will not be available # to the public. # Clients that do not wish to change the publishing behavior of a Notebook # should not set this value when calling NoteStore.updateNotebook(). #
# #
stack
#
If this is set, then the notebook is visually contained within a stack # of notebooks with this name. All notebooks in the same account with the # same 'stack' field are considered to be in the same stack. # Notebooks with no stack set are "top level" and not contained within a # stack. #
#
class Notebook include ::Thrift::Struct, ::Thrift::Struct_Union GUID = 1 NAME = 2 UPDATESEQUENCENUM = 5 DEFAULTNOTEBOOK = 6 SERVICECREATED = 7 SERVICEUPDATED = 8 PUBLISHING = 10 PUBLISHED = 11 STACK = 12 FIELDS = { GUID => {:type => ::Thrift::Types::STRING, :name => 'guid', :optional => true}, NAME => {:type => ::Thrift::Types::STRING, :name => 'name', :optional => true}, UPDATESEQUENCENUM => {:type => ::Thrift::Types::I32, :name => 'updateSequenceNum', :optional => true}, DEFAULTNOTEBOOK => {:type => ::Thrift::Types::BOOL, :name => 'defaultNotebook', :optional => true}, SERVICECREATED => {:type => ::Thrift::Types::I64, :name => 'serviceCreated', :optional => true}, SERVICEUPDATED => {:type => ::Thrift::Types::I64, :name => 'serviceUpdated', :optional => true}, PUBLISHING => {:type => ::Thrift::Types::STRUCT, :name => 'publishing', :class => Evernote::EDAM::Type::Publishing, :optional => true}, PUBLISHED => {:type => ::Thrift::Types::BOOL, :name => 'published', :optional => true}, STACK => {:type => ::Thrift::Types::STRING, :name => 'stack', :optional => true} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end # A named search associated with the account that can be quickly re-used. #
#
guid
#
The unique identifier of this search. Will be set by the # service, so may be omitted by the client when creating. #
# Length: EDAM_GUID_LEN_MIN - EDAM_GUID_LEN_MAX #
# Regex: EDAM_GUID_REGEX #
# #
name
#
The name of the saved search to display in the GUI. The # account may only contain one search with a given name (case-insensitive # compare). Can't begin or end with a space. #
# Length: EDAM_SAVED_SEARCH_NAME_LEN_MIN - EDAM_SAVED_SEARCH_NAME_LEN_MAX #
# Regex: EDAM_SAVED_SEARCH_NAME_REGEX #
# #
query
#
A string expressing the search to be performed. #
# Length: EDAM_SAVED_SEARCH_QUERY_LEN_MIN - EDAM_SAVED_SEARCH_QUERY_LEN_MAX #
# #
format
#
The format of the query string, to determine how to parse # and process it. #
# #
updateSequenceNum
#
A number identifying the last transaction to # modify the state of this object. The USN values are sequential within an # account, and can be used to compare the order of modifications within the # service. #
#
class SavedSearch include ::Thrift::Struct, ::Thrift::Struct_Union GUID = 1 NAME = 2 QUERY = 3 FORMAT = 4 UPDATESEQUENCENUM = 5 FIELDS = { GUID => {:type => ::Thrift::Types::STRING, :name => 'guid', :optional => true}, NAME => {:type => ::Thrift::Types::STRING, :name => 'name', :optional => true}, QUERY => {:type => ::Thrift::Types::STRING, :name => 'query', :optional => true}, FORMAT => {:type => ::Thrift::Types::I32, :name => 'format', :optional => true, :enum_class => Evernote::EDAM::Type::QueryFormat}, UPDATESEQUENCENUM => {:type => ::Thrift::Types::I32, :name => 'updateSequenceNum', :optional => true} } def struct_fields; FIELDS; end def validate unless @format.nil? || Evernote::EDAM::Type::QueryFormat::VALID_VALUES.include?(@format) raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Invalid value of field format!') end end ::Thrift::Struct.generate_accessors self end # An advertisement that may be displayed within an Evernote client. # Advertisements are either a snippet of HTML or else they # are an image (of type: JPEG, GIF, PNG) with an associated destination URL. # #
#
id
#
The unique identifier of this advertisement within Evernote's ad # inventory. #
# #
width
#
This ad should be displayed within a rectangle that is this wide, # in pixels. #
# #
height
#
This ad should be displayed within a rectangle that is this high, # in pixels. #
# #
advertiserName
#
A string containing a readable version of the name of this advertiser. #
# #
imageUrl
#
The location of the image to display for this ad.
# #
destinationUrl
#
When a user clicks on the ad, this is the destination they should be # sent to in a browser.
# #
displaySeconds
#
The number of seconds that the ad should be displayed before it is # replaced with a different ad.
# #
score
#
A numeric indicator of the relative value of this ad, which can be # compared against other ads from the same day. #
# #
image
#
If present, this is the raw image bits of the image file to display # for the ad. If not present, the imageUrl should be retrieved directly. #
# #
imageMime
#
The MIME type of the 'image' bytes, if those are set.
# #
html
#
The exact HTML to display for this ad, to support rich or external # advertisements.
# #
displayFrequency
#
If this value is set, this is the relatively frequency that this # ad should be displayed in the daily set of ads, relative to a base # frequency of 1.0. I.e. an ad with a frequency of 3.0 should be displayed # three times more frequently than an ad with a frequency of 1.0.
#
class Ad include ::Thrift::Struct, ::Thrift::Struct_Union ID = 1 WIDTH = 2 HEIGHT = 3 ADVERTISERNAME = 4 IMAGEURL = 5 DESTINATIONURL = 6 DISPLAYSECONDS = 7 SCORE = 8 IMAGE = 9 IMAGEMIME = 10 HTML = 11 DISPLAYFREQUENCY = 12 FIELDS = { ID => {:type => ::Thrift::Types::I32, :name => 'id', :optional => true}, WIDTH => {:type => ::Thrift::Types::I16, :name => 'width', :optional => true}, HEIGHT => {:type => ::Thrift::Types::I16, :name => 'height', :optional => true}, ADVERTISERNAME => {:type => ::Thrift::Types::STRING, :name => 'advertiserName', :optional => true}, IMAGEURL => {:type => ::Thrift::Types::STRING, :name => 'imageUrl', :optional => true}, DESTINATIONURL => {:type => ::Thrift::Types::STRING, :name => 'destinationUrl', :optional => true}, DISPLAYSECONDS => {:type => ::Thrift::Types::I16, :name => 'displaySeconds', :optional => true}, SCORE => {:type => ::Thrift::Types::DOUBLE, :name => 'score', :optional => true}, IMAGE => {:type => ::Thrift::Types::STRING, :name => 'image', :binary => true, :optional => true}, IMAGEMIME => {:type => ::Thrift::Types::STRING, :name => 'imageMime', :optional => true}, HTML => {:type => ::Thrift::Types::STRING, :name => 'html', :optional => true}, DISPLAYFREQUENCY => {:type => ::Thrift::Types::DOUBLE, :name => 'displayFrequency', :optional => true} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end # Shared notebooks represent a relationship between a notebook and a single # share invitation recipient. #
#
id
#
the primary identifier of the share
# #
userId
#
the user id of the owner of the notebook
# #
notebookGuid
#
the GUID of the associated notebook shared.
# #
email
#
the email address of the recipient - used by the notebook # owner to identify who they shared with.
# #
notebookModifiable
#
a flag indicating the share is read/write -otherwise it's read only
# #
requireLogin
#
indicates that a user must login to access the share
# #
serviceCreated
#
the date the owner first created the share with the specific email # address
# #
username
#
the username of the user who can access this share. # Once it's assigned it cannot be changed.
#
class SharedNotebook include ::Thrift::Struct, ::Thrift::Struct_Union ID = 1 USERID = 2 NOTEBOOKGUID = 3 EMAIL = 4 NOTEBOOKMODIFIABLE = 5 REQUIRELOGIN = 6 SERVICECREATED = 7 SHAREKEY = 8 USERNAME = 9 FIELDS = { ID => {:type => ::Thrift::Types::I64, :name => 'id', :optional => true}, USERID => {:type => ::Thrift::Types::I32, :name => 'userId', :optional => true}, NOTEBOOKGUID => {:type => ::Thrift::Types::STRING, :name => 'notebookGuid', :optional => true}, EMAIL => {:type => ::Thrift::Types::STRING, :name => 'email', :optional => true}, NOTEBOOKMODIFIABLE => {:type => ::Thrift::Types::BOOL, :name => 'notebookModifiable', :optional => true}, REQUIRELOGIN => {:type => ::Thrift::Types::BOOL, :name => 'requireLogin', :optional => true}, SERVICECREATED => {:type => ::Thrift::Types::I64, :name => 'serviceCreated', :optional => true}, SHAREKEY => {:type => ::Thrift::Types::STRING, :name => 'shareKey', :optional => true}, USERNAME => {:type => ::Thrift::Types::STRING, :name => 'username', :optional => true} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end # A link in an users account that refers them to a public or individual share in # another user's account. # #
#
id
#
the primary identifier of a linked notebook only used for deleting.
# #
shareName
#
the display name of the shared notebook. # The link owner can change this.
# #
username
#
the username of the user who owns the shared or public notebook
# #
shardId
#
the shard ID of the notebook if the notebook is not public # #
shareKey
#
the secret key that provides access to the shared notebook
# #
uri
#
the identifier of the public notebook
class LinkedNotebook include ::Thrift::Struct, ::Thrift::Struct_Union ID = 1 SHARENAME = 2 USERNAME = 3 SHARDID = 4 SHAREKEY = 5 URI = 6 FIELDS = { ID => {:type => ::Thrift::Types::I64, :name => 'id', :optional => true}, SHARENAME => {:type => ::Thrift::Types::STRING, :name => 'shareName', :optional => true}, USERNAME => {:type => ::Thrift::Types::STRING, :name => 'username', :optional => true}, SHARDID => {:type => ::Thrift::Types::STRING, :name => 'shardId', :optional => true}, SHAREKEY => {:type => ::Thrift::Types::STRING, :name => 'shareKey', :optional => true}, URI => {:type => ::Thrift::Types::STRING, :name => 'uri', :optional => true} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end end end end evernote-mode-0_41/ruby/lib/Evernote/EDAM/types_constants.rb0000664000175000017500000000061111513076422023736 0ustar uwabamiuwabami# # Autogenerated by Thrift # # DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING # require 'Evernote/EDAM/types_types' module Evernote module EDAM module Type EDAM_NOTE_SOURCE_WEB_CLIP = %q"web.clip" EDAM_NOTE_SOURCE_MAIL_CLIP = %q"mail.clip" EDAM_NOTE_SOURCE_MAIL_SMTP_GATEWAY = %q"mail.smtp" end end end evernote-mode-0_41/ruby/lib/thrift/0000775000175000017500000000000011601107152017147 5ustar uwabamiuwabamievernote-mode-0_41/ruby/lib/thrift/thrift_native.rb0000664000175000017500000000164211513076422022354 0ustar uwabamiuwabami# # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. # begin require "thrift/thrift_native" rescue LoadError puts "Unable to load thrift_native extension. Defaulting to pure Ruby libraries." end evernote-mode-0_41/ruby/lib/thrift/serializer/0000775000175000017500000000000011601107152021320 5ustar uwabamiuwabamievernote-mode-0_41/ruby/lib/thrift/serializer/deserializer.rb0000664000175000017500000000215311513076422024337 0ustar uwabamiuwabami# # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. # module Thrift class Deserializer def initialize(protocol_factory = BinaryProtocolFactory.new) @transport = MemoryBufferTransport.new @protocol = protocol_factory.get_protocol(@transport) end def deserialize(base, buffer) @transport.reset_buffer(buffer) base.read(@protocol) base end end endevernote-mode-0_41/ruby/lib/thrift/serializer/serializer.rb0000664000175000017500000000217311513076422024030 0ustar uwabamiuwabami# # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. # module Thrift class Serializer def initialize(protocol_factory = BinaryProtocolFactory.new) @transport = MemoryBufferTransport.new @protocol = protocol_factory.get_protocol(@transport) end def serialize(base) @transport.reset_buffer base.write(@protocol) @transport.read(@transport.available) end end end evernote-mode-0_41/ruby/lib/thrift/core_ext/0000775000175000017500000000000011601107152020757 5ustar uwabamiuwabamievernote-mode-0_41/ruby/lib/thrift/core_ext/fixnum.rb0000664000175000017500000000170111513076422022620 0ustar uwabamiuwabami# # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. # # Versions of ruby pre 1.8.7 do not have an .ord method available in the Fixnum # class. # if RUBY_VERSION < "1.8.7" class Fixnum def ord self end end endevernote-mode-0_41/ruby/lib/thrift/protocol/0000775000175000017500000000000011601107152021010 5ustar uwabamiuwabamievernote-mode-0_41/ruby/lib/thrift/protocol/compact_protocol.rb0000664000175000017500000002515411513076422024722 0ustar uwabamiuwabami# # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. # module Thrift class CompactProtocol < BaseProtocol PROTOCOL_ID = [0x82].pack('c').unpack('c').first VERSION = 1 VERSION_MASK = 0x1f TYPE_MASK = 0xE0 TYPE_SHIFT_AMOUNT = 5 TSTOP = ["", Types::STOP, 0] # # All of the on-wire type codes. # class CompactTypes BOOLEAN_TRUE = 0x01 BOOLEAN_FALSE = 0x02 BYTE = 0x03 I16 = 0x04 I32 = 0x05 I64 = 0x06 DOUBLE = 0x07 BINARY = 0x08 LIST = 0x09 SET = 0x0A MAP = 0x0B STRUCT = 0x0C def self.is_bool_type?(b) (b & 0x0f) == BOOLEAN_TRUE || (b & 0x0f) == BOOLEAN_FALSE end COMPACT_TO_TTYPE = { Types::STOP => Types::STOP, BOOLEAN_FALSE => Types::BOOL, BOOLEAN_TRUE => Types::BOOL, BYTE => Types::BYTE, I16 => Types::I16, I32 => Types::I32, I64 => Types::I64, DOUBLE => Types::DOUBLE, BINARY => Types::STRING, LIST => Types::LIST, SET => Types::SET, MAP => Types::MAP, STRUCT => Types::STRUCT } TTYPE_TO_COMPACT = { Types::STOP => Types::STOP, Types::BOOL => BOOLEAN_TRUE, Types::BYTE => BYTE, Types::I16 => I16, Types::I32 => I32, Types::I64 => I64, Types::DOUBLE => DOUBLE, Types::STRING => BINARY, Types::LIST => LIST, Types::SET => SET, Types::MAP => MAP, Types::STRUCT => STRUCT } def self.get_ttype(compact_type) val = COMPACT_TO_TTYPE[compact_type & 0x0f] raise "don't know what type: #{compact_type & 0x0f}" unless val val end def self.get_compact_type(ttype) val = TTYPE_TO_COMPACT[ttype] raise "don't know what type: #{ttype & 0x0f}" unless val val end end def initialize(transport) super(transport) @last_field = [0] @boolean_value = nil end def write_message_begin(name, type, seqid) write_byte(PROTOCOL_ID) write_byte((VERSION & VERSION_MASK) | ((type << TYPE_SHIFT_AMOUNT) & TYPE_MASK)) write_varint32(seqid) write_string(name) nil end def write_struct_begin(name) @last_field.push(0) nil end def write_struct_end @last_field.pop nil end def write_field_begin(name, type, id) if type == Types::BOOL # we want to possibly include the value, so we'll wait. @boolean_field = [type, id] else write_field_begin_internal(type, id) end nil end # # The workhorse of writeFieldBegin. It has the option of doing a # 'type override' of the type header. This is used specifically in the # boolean field case. # def write_field_begin_internal(type, id, type_override=nil) last_id = @last_field.pop # if there's a type override, use that. typeToWrite = type_override || CompactTypes.get_compact_type(type) # check if we can use delta encoding for the field id if id > last_id && id - last_id <= 15 # write them together write_byte((id - last_id) << 4 | typeToWrite) else # write them separate write_byte(typeToWrite) write_i16(id) end @last_field.push(id) nil end def write_field_stop write_byte(Types::STOP) end def write_map_begin(ktype, vtype, size) if (size == 0) write_byte(0) else write_varint32(size) write_byte(CompactTypes.get_compact_type(ktype) << 4 | CompactTypes.get_compact_type(vtype)) end end def write_list_begin(etype, size) write_collection_begin(etype, size) end def write_set_begin(etype, size) write_collection_begin(etype, size); end def write_bool(bool) type = bool ? CompactTypes::BOOLEAN_TRUE : CompactTypes::BOOLEAN_FALSE unless @boolean_field.nil? # we haven't written the field header yet write_field_begin_internal(@boolean_field.first, @boolean_field.last, type) @boolean_field = nil else # we're not part of a field, so just write the value. write_byte(type) end end def write_byte(byte) @trans.write([byte].pack('c')) end def write_i16(i16) write_varint32(int_to_zig_zag(i16)) end def write_i32(i32) write_varint32(int_to_zig_zag(i32)) end def write_i64(i64) write_varint64(long_to_zig_zag(i64)) end def write_double(dub) @trans.write([dub].pack("G").reverse) end def write_string(str) write_varint32(str.length) @trans.write(str) end def read_message_begin protocol_id = read_byte() if protocol_id != PROTOCOL_ID raise ProtocolException.new("Expected protocol id #{PROTOCOL_ID} but got #{protocol_id}") end version_and_type = read_byte() version = version_and_type & VERSION_MASK if (version != VERSION) raise ProtocolException.new("Expected version #{VERSION} but got #{version}"); end type = (version_and_type >> TYPE_SHIFT_AMOUNT) & 0x03 seqid = read_varint32() messageName = read_string() [messageName, type, seqid] end def read_struct_begin @last_field.push(0) "" end def read_struct_end @last_field.pop() nil end def read_field_begin type = read_byte() # if it's a stop, then we can return immediately, as the struct is over. if (type & 0x0f) == Types::STOP TSTOP else field_id = nil # mask off the 4 MSB of the type header. it could contain a field id delta. modifier = (type & 0xf0) >> 4 if modifier == 0 # not a delta. look ahead for the zigzag varint field id. @last_field.pop field_id = read_i16() else # has a delta. add the delta to the last read field id. field_id = @last_field.pop + modifier end # if this happens to be a boolean field, the value is encoded in the type if CompactTypes.is_bool_type?(type) # save the boolean value in a special instance variable. @bool_value = (type & 0x0f) == CompactTypes::BOOLEAN_TRUE end # push the new field onto the field stack so we can keep the deltas going. @last_field.push(field_id) ["", CompactTypes.get_ttype(type & 0x0f), field_id] end end def read_map_begin size = read_varint32() key_and_value_type = size == 0 ? 0 : read_byte() [CompactTypes.get_ttype(key_and_value_type >> 4), CompactTypes.get_ttype(key_and_value_type & 0xf), size] end def read_list_begin size_and_type = read_byte() size = (size_and_type >> 4) & 0x0f if size == 15 size = read_varint32() end type = CompactTypes.get_ttype(size_and_type) [type, size] end def read_set_begin read_list_begin end def read_bool unless @bool_value.nil? bv = @bool_value @bool_value = nil bv else read_byte() == CompactTypes::BOOLEAN_TRUE end end def read_byte dat = trans.read_all(1) val = dat[0] if (val > 0x7f) val = 0 - ((val - 1) ^ 0xff) end val end def read_i16 zig_zag_to_int(read_varint32()) end def read_i32 zig_zag_to_int(read_varint32()) end def read_i64 zig_zag_to_long(read_varint64()) end def read_double dat = trans.read_all(8) val = dat.reverse.unpack('G').first val end def read_string size = read_varint32() trans.read_all(size) end private # # Abstract method for writing the start of lists and sets. List and sets on # the wire differ only by the type indicator. # def write_collection_begin(elem_type, size) if size <= 14 write_byte(size << 4 | CompactTypes.get_compact_type(elem_type)) else write_byte(0xf0 | CompactTypes.get_compact_type(elem_type)) write_varint32(size) end end def write_varint32(n) # int idx = 0; while true if (n & ~0x7F) == 0 # i32buf[idx++] = (byte)n; write_byte(n) break # return; else # i32buf[idx++] = (byte)((n & 0x7F) | 0x80); write_byte((n & 0x7F) | 0x80) n = n >> 7 end end # trans_.write(i32buf, 0, idx); end SEVEN_BIT_MASK = 0x7F EVERYTHING_ELSE_MASK = ~SEVEN_BIT_MASK def write_varint64(n) while true if (n & EVERYTHING_ELSE_MASK) == 0 #TODO need to find a way to make this into a long... write_byte(n) break else write_byte((n & SEVEN_BIT_MASK) | 0x80) n >>= 7 end end end def read_varint32() read_varint64() end def read_varint64() shift = 0 result = 0 while true b = read_byte() result |= (b & 0x7f) << shift break if (b & 0x80) != 0x80 shift += 7 end result end def int_to_zig_zag(n) (n << 1) ^ (n >> 31) end def long_to_zig_zag(l) # puts "zz encoded #{l} to #{(l << 1) ^ (l >> 63)}" (l << 1) ^ (l >> 63) end def zig_zag_to_int(n) (n >> 1) ^ -(n & 1) end def zig_zag_to_long(n) (n >> 1) ^ -(n & 1) end end class CompactProtocolFactory < BaseProtocolFactory def get_protocol(trans) CompactProtocol.new(trans) end end end evernote-mode-0_41/ruby/lib/thrift/protocol/binary_protocol_accelerated.rb0000664000175000017500000000270711513076422027073 0ustar uwabamiuwabami# # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. # =begin The only change required for a transport to support BinaryProtocolAccelerated is to implement 2 methods: * borrow(size), which takes an optional argument and returns atleast _size_ bytes from the transport, or the default buffer size if no argument is given * consume!(size), which removes size bytes from the front of the buffer See MemoryBuffer and BufferedTransport for examples. =end module Thrift class BinaryProtocolAcceleratedFactory < BaseProtocolFactory def get_protocol(trans) if (defined? BinaryProtocolAccelerated) BinaryProtocolAccelerated.new(trans) else BinaryProtocol.new(trans) end end end end evernote-mode-0_41/ruby/lib/thrift/protocol/binary_protocol.rb0000664000175000017500000001200411513076422024546 0ustar uwabamiuwabami# # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. # module Thrift class BinaryProtocol < BaseProtocol VERSION_MASK = 0xffff0000 VERSION_1 = 0x80010000 TYPE_MASK = 0x000000ff attr_reader :strict_read, :strict_write def initialize(trans, strict_read=true, strict_write=true) super(trans) @strict_read = strict_read @strict_write = strict_write end def write_message_begin(name, type, seqid) # this is necessary because we added (needed) bounds checking to # write_i32, and 0x80010000 is too big for that. if strict_write write_i16(VERSION_1 >> 16) write_i16(type) write_string(name) write_i32(seqid) else write_string(name) write_byte(type) write_i32(seqid) end end def write_struct_begin(name); nil; end def write_field_begin(name, type, id) write_byte(type) write_i16(id) end def write_field_stop write_byte(Thrift::Types::STOP) end def write_map_begin(ktype, vtype, size) write_byte(ktype) write_byte(vtype) write_i32(size) end def write_list_begin(etype, size) write_byte(etype) write_i32(size) end def write_set_begin(etype, size) write_byte(etype) write_i32(size) end def write_bool(bool) write_byte(bool ? 1 : 0) end def write_byte(byte) raise RangeError if byte < -2**31 || byte >= 2**32 trans.write([byte].pack('c')) end def write_i16(i16) trans.write([i16].pack('n')) end def write_i32(i32) raise RangeError if i32 < -2**31 || i32 >= 2**31 trans.write([i32].pack('N')) end def write_i64(i64) raise RangeError if i64 < -2**63 || i64 >= 2**64 hi = i64 >> 32 lo = i64 & 0xffffffff trans.write([hi, lo].pack('N2')) end def write_double(dub) trans.write([dub].pack('G')) end def write_string(str) write_i32(str.length) trans.write(str) end def read_message_begin version = read_i32 if version < 0 if (version & VERSION_MASK != VERSION_1) raise ProtocolException.new(ProtocolException::BAD_VERSION, 'Missing version identifier') end type = version & TYPE_MASK name = read_string seqid = read_i32 [name, type, seqid] else if strict_read raise ProtocolException.new(ProtocolException::BAD_VERSION, 'No version identifier, old protocol client?') end name = trans.read_all(version) type = read_byte seqid = read_i32 [name, type, seqid] end end def read_struct_begin; nil; end def read_field_begin type = read_byte if (type == Types::STOP) [nil, type, 0] else id = read_i16 [nil, type, id] end end def read_map_begin ktype = read_byte vtype = read_byte size = read_i32 [ktype, vtype, size] end def read_list_begin etype = read_byte size = read_i32 [etype, size] end def read_set_begin etype = read_byte size = read_i32 [etype, size] end def read_bool byte = read_byte byte != 0 end def read_byte dat = trans.read_all(1) val = dat[0].ord if (val > 0x7f) val = 0 - ((val - 1) ^ 0xff) end val end def read_i16 dat = trans.read_all(2) val, = dat.unpack('n') if (val > 0x7fff) val = 0 - ((val - 1) ^ 0xffff) end val end def read_i32 dat = trans.read_all(4) val, = dat.unpack('N') if (val > 0x7fffffff) val = 0 - ((val - 1) ^ 0xffffffff) end val end def read_i64 dat = trans.read_all(8) hi, lo = dat.unpack('N2') if (hi > 0x7fffffff) hi ^= 0xffffffff lo ^= 0xffffffff 0 - (hi << 32) - lo - 1 else (hi << 32) + lo end end def read_double dat = trans.read_all(8) val = dat.unpack('G').first val end def read_string sz = read_i32 dat = trans.read_all(sz) dat end end class BinaryProtocolFactory < BaseProtocolFactory def get_protocol(trans) return Thrift::BinaryProtocol.new(trans) end end end evernote-mode-0_41/ruby/lib/thrift/protocol/base_protocol.rb0000664000175000017500000001320411513076422024177 0ustar uwabamiuwabami# # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. # # this require is to make generated struct definitions happy require 'set' module Thrift class ProtocolException < Exception UNKNOWN = 0 INVALID_DATA = 1 NEGATIVE_SIZE = 2 SIZE_LIMIT = 3 BAD_VERSION = 4 attr_reader :type def initialize(type=UNKNOWN, message=nil) super(message) @type = type end end class BaseProtocol attr_reader :trans def initialize(trans) @trans = trans end def native? puts "wrong method is being called!" false end def write_message_begin(name, type, seqid) raise NotImplementedError end def write_message_end; nil; end def write_struct_begin(name) raise NotImplementedError end def write_struct_end; nil; end def write_field_begin(name, type, id) raise NotImplementedError end def write_field_end; nil; end def write_field_stop raise NotImplementedError end def write_map_begin(ktype, vtype, size) raise NotImplementedError end def write_map_end; nil; end def write_list_begin(etype, size) raise NotImplementedError end def write_list_end; nil; end def write_set_begin(etype, size) raise NotImplementedError end def write_set_end; nil; end def write_bool(bool) raise NotImplementedError end def write_byte(byte) raise NotImplementedError end def write_i16(i16) raise NotImplementedError end def write_i32(i32) raise NotImplementedError end def write_i64(i64) raise NotImplementedError end def write_double(dub) raise NotImplementedError end def write_string(str) raise NotImplementedError end def read_message_begin raise NotImplementedError end def read_message_end; nil; end def read_struct_begin raise NotImplementedError end def read_struct_end; nil; end def read_field_begin raise NotImplementedError end def read_field_end; nil; end def read_map_begin raise NotImplementedError end def read_map_end; nil; end def read_list_begin raise NotImplementedError end def read_list_end; nil; end def read_set_begin raise NotImplementedError end def read_set_end; nil; end def read_bool raise NotImplementedError end def read_byte raise NotImplementedError end def read_i16 raise NotImplementedError end def read_i32 raise NotImplementedError end def read_i64 raise NotImplementedError end def read_double raise NotImplementedError end def read_string raise NotImplementedError end def write_field(name, type, fid, value) write_field_begin(name, type, fid) write_type(type, value) write_field_end end def write_type(type, value) case type when Types::BOOL write_bool(value) when Types::BYTE write_byte(value) when Types::DOUBLE write_double(value) when Types::I16 write_i16(value) when Types::I32 write_i32(value) when Types::I64 write_i64(value) when Types::STRING write_string(value) when Types::STRUCT value.write(self) else raise NotImplementedError end end def read_type(type) case type when Types::BOOL read_bool when Types::BYTE read_byte when Types::DOUBLE read_double when Types::I16 read_i16 when Types::I32 read_i32 when Types::I64 read_i64 when Types::STRING read_string else raise NotImplementedError end end def skip(type) case type when Types::STOP nil when Types::BOOL read_bool when Types::BYTE read_byte when Types::I16 read_i16 when Types::I32 read_i32 when Types::I64 read_i64 when Types::DOUBLE read_double when Types::STRING read_string when Types::STRUCT read_struct_begin while true name, type, id = read_field_begin break if type == Types::STOP skip(type) read_field_end end read_struct_end when Types::MAP ktype, vtype, size = read_map_begin size.times do skip(ktype) skip(vtype) end read_map_end when Types::SET etype, size = read_set_begin size.times do skip(etype) end read_set_end when Types::LIST etype, size = read_list_begin size.times do skip(etype) end read_list_end end end end class BaseProtocolFactory def get_protocol(trans) raise NotImplementedError end end endevernote-mode-0_41/ruby/lib/thrift/struct.rb0000664000175000017500000001651111513076422021033 0ustar uwabamiuwabami# # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. # require 'set' module Thrift module Struct def initialize(d={}) # get a copy of the default values to work on, removing defaults in favor of arguments fields_with_defaults = fields_with_default_values.dup # check if the defaults is empty, or if there are no parameters for this # instantiation, and if so, don't bother overriding defaults. unless fields_with_defaults.empty? || d.empty? d.each_key do |name| fields_with_defaults.delete(name.to_s) end end # assign all the user-specified arguments unless d.empty? d.each do |name, value| unless name_to_id(name.to_s) raise Exception, "Unknown key given to #{self.class}.new: #{name}" end Thrift.check_type(value, struct_fields[name_to_id(name.to_s)], name) if Thrift.type_checking instance_variable_set("@#{name}", value) end end # assign all the default values unless fields_with_defaults.empty? fields_with_defaults.each do |name, default_value| instance_variable_set("@#{name}", (default_value.dup rescue default_value)) end end end def fields_with_default_values fields_with_default_values = self.class.instance_variable_get("@fields_with_default_values") unless fields_with_default_values fields_with_default_values = {} struct_fields.each do |fid, field_def| unless field_def[:default].nil? fields_with_default_values[field_def[:name]] = field_def[:default] end end self.class.instance_variable_set("@fields_with_default_values", fields_with_default_values) end fields_with_default_values end def inspect(skip_optional_nulls = true) fields = [] each_field do |fid, field_info| name = field_info[:name] value = instance_variable_get("@#{name}") unless skip_optional_nulls && field_info[:optional] && value.nil? fields << "#{name}:#{inspect_field(value, field_info)}" end end "<#{self.class} #{fields.join(", ")}>" end def read(iprot) iprot.read_struct_begin loop do fname, ftype, fid = iprot.read_field_begin break if (ftype == Types::STOP) handle_message(iprot, fid, ftype) iprot.read_field_end end iprot.read_struct_end validate end def write(oprot) validate oprot.write_struct_begin(self.class.name) each_field do |fid, field_info| name = field_info[:name] type = field_info[:type] value = instance_variable_get("@#{name}") unless value.nil? if is_container? type oprot.write_field_begin(name, type, fid) write_container(oprot, value, field_info) oprot.write_field_end else oprot.write_field(name, type, fid, value) end end end oprot.write_field_stop oprot.write_struct_end end def ==(other) each_field do |fid, field_info| name = field_info[:name] return false unless self.instance_variable_get("@#{name}") == other.instance_variable_get("@#{name}") end true end def eql?(other) self.class == other.class && self == other end def hash field_values = [] each_field do |fid, field_info| name = field_info[:name] field_values << self.instance_variable_get("@#{name}") end field_values.hash end def differences(other) diffs = [] unless other.is_a?(self.class) diffs << "Different class!" else each_field do |fid, field_info| name = field_info[:name] diffs << "#{name} differs!" unless self.instance_variable_get("@#{name}") == other.instance_variable_get("@#{name}") end end diffs end def self.field_accessor(klass, field_info) field_name_sym = field_info[:name].to_sym klass.send :attr_reader, field_name_sym klass.send :define_method, "#{field_info[:name]}=" do |value| Thrift.check_type(value, field_info, field_info[:name]) if Thrift.type_checking instance_variable_set("@#{field_name_sym}", value) end end def self.generate_accessors(klass) klass::FIELDS.values.each do |field_info| field_accessor(klass, field_info) qmark_isset_method(klass, field_info) end end def self.qmark_isset_method(klass, field_info) klass.send :define_method, "#{field_info[:name]}?" do !self.send(field_info[:name].to_sym).nil? end end def <=>(other) if self.class == other.class each_field do |fid, field_info| v1 = self.send(field_info[:name]) v1_set = !v1.nil? v2 = other.send(field_info[:name]) v2_set = !v2.nil? if v1_set && !v2_set return -1 elsif !v1_set && v2_set return 1 elsif v1_set && v2_set cmp = v1 <=> v2 if cmp != 0 return cmp end end end 0 else self.class <=> other.class end end protected def self.append_features(mod) if mod.ancestors.include? ::Exception mod.send :class_variable_set, :'@@__thrift_struct_real_initialize', mod.instance_method(:initialize) super # set up our custom initializer so `raise Xception, 'message'` works mod.send :define_method, :struct_initialize, mod.instance_method(:initialize) mod.send :define_method, :initialize, mod.instance_method(:exception_initialize) else super end end def exception_initialize(*args, &block) if args.size == 1 and args.first.is_a? Hash # looks like it's a regular Struct initialize method(:struct_initialize).call(args.first) else # call the Struct initializer first with no args # this will set our field default values method(:struct_initialize).call() # now give it to the exception self.class.send(:class_variable_get, :'@@__thrift_struct_real_initialize').bind(self).call(*args, &block) if args.size > 0 # self.class.instance_method(:initialize).bind(self).call(*args, &block) end end def handle_message(iprot, fid, ftype) field = struct_fields[fid] if field and field[:type] == ftype value = read_field(iprot, field) instance_variable_set("@#{field[:name]}", value) else iprot.skip(ftype) end end end end evernote-mode-0_41/ruby/lib/thrift/struct_union.rb0000664000175000017500000001142711513076422022244 0ustar uwabamiuwabami# # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. # require 'set' module Thrift module Struct_Union def name_to_id(name) names_to_ids = self.class.instance_variable_get("@names_to_ids") unless names_to_ids names_to_ids = {} struct_fields.each do |fid, field_def| names_to_ids[field_def[:name]] = fid end self.class.instance_variable_set("@names_to_ids", names_to_ids) end names_to_ids[name] end def each_field struct_fields.keys.sort.each do |fid| data = struct_fields[fid] yield fid, data end end def read_field(iprot, field = {}) case field[:type] when Types::STRUCT value = field[:class].new value.read(iprot) when Types::MAP key_type, val_type, size = iprot.read_map_begin value = {} size.times do k = read_field(iprot, field_info(field[:key])) v = read_field(iprot, field_info(field[:value])) value[k] = v end iprot.read_map_end when Types::LIST e_type, size = iprot.read_list_begin value = Array.new(size) do |n| read_field(iprot, field_info(field[:element])) end iprot.read_list_end when Types::SET e_type, size = iprot.read_set_begin value = Set.new size.times do element = read_field(iprot, field_info(field[:element])) value << element end iprot.read_set_end else value = iprot.read_type(field[:type]) end value end def write_data(oprot, value, field) if is_container? field[:type] write_container(oprot, value, field) else oprot.write_type(field[:type], value) end end def write_container(oprot, value, field = {}) case field[:type] when Types::MAP oprot.write_map_begin(field[:key][:type], field[:value][:type], value.size) value.each do |k, v| write_data(oprot, k, field[:key]) write_data(oprot, v, field[:value]) end oprot.write_map_end when Types::LIST oprot.write_list_begin(field[:element][:type], value.size) value.each do |elem| write_data(oprot, elem, field[:element]) end oprot.write_list_end when Types::SET oprot.write_set_begin(field[:element][:type], value.size) value.each do |v,| # the , is to preserve compatibility with the old Hash-style sets write_data(oprot, v, field[:element]) end oprot.write_set_end else raise "Not a container type: #{field[:type]}" end end CONTAINER_TYPES = [] CONTAINER_TYPES[Types::LIST] = true CONTAINER_TYPES[Types::MAP] = true CONTAINER_TYPES[Types::SET] = true def is_container?(type) CONTAINER_TYPES[type] end def field_info(field) { :type => field[:type], :class => field[:class], :key => field[:key], :value => field[:value], :element => field[:element] } end def inspect_field(value, field_info) if enum_class = field_info[:enum_class] "#{enum_class.const_get(:VALUE_MAP)[value]} (#{value})" elsif value.is_a? Hash if field_info[:type] == Types::MAP map_buf = [] value.each do |k, v| map_buf << inspect_field(k, field_info[:key]) + ": " + inspect_field(v, field_info[:value]) end "{" + map_buf.join(", ") + "}" else # old-style set inspect_collection(value.keys, field_info) end elsif value.is_a? Array inspect_collection(value, field_info) elsif value.is_a? Set inspect_collection(value, field_info) elsif value.is_a?(String) && field_info[:binary] value.unpack("H*").first else value.inspect end end def inspect_collection(collection, field_info) buf = [] collection.each do |k| buf << inspect_field(k, field_info[:element]) end "[" + buf.join(", ") + "]" end end endevernote-mode-0_41/ruby/lib/thrift/server/0000775000175000017500000000000011601107152020455 5ustar uwabamiuwabamievernote-mode-0_41/ruby/lib/thrift/server/nonblocking_server.rb0000664000175000017500000002105611513076422024706 0ustar uwabamiuwabami# # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. # require 'logger' require 'thread' module Thrift # this class expects to always use a FramedTransport for reading messages class NonblockingServer < BaseServer def initialize(processor, server_transport, transport_factory=nil, protocol_factory=nil, num=20, logger=nil) super(processor, server_transport, transport_factory, protocol_factory) @num_threads = num if logger.nil? @logger = Logger.new(STDERR) @logger.level = Logger::WARN else @logger = logger end @shutdown_semaphore = Mutex.new @transport_semaphore = Mutex.new end def serve @logger.info "Starting #{self}" @server_transport.listen @io_manager = start_io_manager begin loop do break if @server_transport.closed? rd, = select([@server_transport], nil, nil, 0.1) next if rd.nil? socket = @server_transport.accept @logger.debug "Accepted socket: #{socket.inspect}" @io_manager.add_connection socket end rescue IOError => e end # we must be shutting down @logger.info "#{self} is shutting down, goodbye" ensure @transport_semaphore.synchronize do @server_transport.close end @io_manager.ensure_closed unless @io_manager.nil? end def shutdown(timeout = 0, block = true) @shutdown_semaphore.synchronize do return if @is_shutdown @is_shutdown = true end # nonblocking is intended for calling from within a Handler # but we can't change the order of operations here, so lets thread shutdown_proc = lambda do @io_manager.shutdown(timeout) @transport_semaphore.synchronize do @server_transport.close # this will break the accept loop end end if block shutdown_proc.call else Thread.new &shutdown_proc end end private def start_io_manager iom = IOManager.new(@processor, @server_transport, @transport_factory, @protocol_factory, @num_threads, @logger) iom.spawn iom end class IOManager # :nodoc: DEFAULT_BUFFER = 2**20 def initialize(processor, server_transport, transport_factory, protocol_factory, num, logger) @processor = processor @server_transport = server_transport @transport_factory = transport_factory @protocol_factory = protocol_factory @num_threads = num @logger = logger @connections = [] @buffers = Hash.new { |h,k| h[k] = '' } @signal_queue = Queue.new @signal_pipes = IO.pipe @signal_pipes[1].sync = true @worker_queue = Queue.new @shutdown_queue = Queue.new end def add_connection(socket) signal [:connection, socket] end def spawn @iom_thread = Thread.new do @logger.debug "Starting #{self}" run end end def shutdown(timeout = 0) @logger.debug "#{self} is shutting down workers" @worker_queue.clear @num_threads.times { @worker_queue.push [:shutdown] } signal [:shutdown, timeout] @shutdown_queue.pop @signal_pipes[0].close @signal_pipes[1].close @logger.debug "#{self} is shutting down, goodbye" end def ensure_closed kill_worker_threads if @worker_threads @iom_thread.kill end private def run spin_worker_threads loop do rd, = select([@signal_pipes[0], *@connections]) if rd.delete @signal_pipes[0] break if read_signals == :shutdown end rd.each do |fd| if fd.handle.eof? remove_connection fd else read_connection fd end end end join_worker_threads(@shutdown_timeout) ensure @shutdown_queue.push :shutdown end def read_connection(fd) @buffers[fd] << fd.read(DEFAULT_BUFFER) while(frame = slice_frame!(@buffers[fd])) @logger.debug "#{self} is processing a frame" @worker_queue.push [:frame, fd, frame] end end def spin_worker_threads @logger.debug "#{self} is spinning up worker threads" @worker_threads = [] @num_threads.times do @worker_threads << spin_thread end end def spin_thread Worker.new(@processor, @transport_factory, @protocol_factory, @logger, @worker_queue).spawn end def signal(msg) @signal_queue << msg @signal_pipes[1].write " " end def read_signals # clear the signal pipe # note that since read_nonblock is broken in jruby, # we can only read up to a set number of signals at once sigstr = @signal_pipes[0].readpartial(1024) # now read the signals begin sigstr.length.times do signal, obj = @signal_queue.pop(true) case signal when :connection @connections << obj when :shutdown @shutdown_timeout = obj return :shutdown end end rescue ThreadError # out of signals # note that in a perfect world this would never happen, since we're # only reading the number of signals pushed on the pipe, but given the lack # of locks, in theory we could clear the pipe/queue while a new signal is being # placed on the pipe, at which point our next read_signals would hit this error end end def remove_connection(fd) # don't explicitly close it, a thread may still be writing to it @connections.delete fd @buffers.delete fd end def join_worker_threads(shutdown_timeout) start = Time.now @worker_threads.each do |t| if shutdown_timeout > 0 timeout = (start + shutdown_timeout) - Time.now break if timeout <= 0 t.join(timeout) else t.join end end kill_worker_threads end def kill_worker_threads @worker_threads.each do |t| t.kill if t.status end @worker_threads.clear end def slice_frame!(buf) if buf.length >= 4 size = buf.unpack('N').first if buf.length >= size + 4 buf.slice!(0, size + 4) else nil end else nil end end class Worker # :nodoc: def initialize(processor, transport_factory, protocol_factory, logger, queue) @processor = processor @transport_factory = transport_factory @protocol_factory = protocol_factory @logger = logger @queue = queue end def spawn Thread.new do @logger.debug "#{self} is spawning" run end end private def run loop do cmd, *args = @queue.pop case cmd when :shutdown @logger.debug "#{self} is shutting down, goodbye" break when :frame fd, frame = args begin otrans = @transport_factory.get_transport(fd) oprot = @protocol_factory.get_protocol(otrans) membuf = MemoryBufferTransport.new(frame) itrans = @transport_factory.get_transport(membuf) iprot = @protocol_factory.get_protocol(itrans) @processor.process(iprot, oprot) rescue => e @logger.error "#{Thread.current.inspect} raised error: #{e.inspect}\n#{e.backtrace.join("\n")}" end end end end end end end endevernote-mode-0_41/ruby/lib/thrift/server/simple_server.rb0000664000175000017500000000254111513076422023672 0ustar uwabamiuwabami# # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. # module Thrift class SimpleServer < BaseServer def serve begin @server_transport.listen loop do client = @server_transport.accept trans = @transport_factory.get_transport(client) prot = @protocol_factory.get_protocol(trans) begin loop do @processor.process(prot, prot) end rescue Thrift::TransportException, Thrift::ProtocolException ensure trans.close end end ensure @server_transport.close end end end endevernote-mode-0_41/ruby/lib/thrift/server/threaded_server.rb0000664000175000017500000000266511513076422024170 0ustar uwabamiuwabami# # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. # require 'thread' module Thrift class ThreadedServer < BaseServer def serve begin @server_transport.listen loop do client = @server_transport.accept trans = @transport_factory.get_transport(client) prot = @protocol_factory.get_protocol(trans) Thread.new(prot, trans) do |p, t| begin loop do @processor.process(p, p) end rescue Thrift::TransportException, Thrift::ProtocolException ensure t.close end end end ensure @server_transport.close end end end endevernote-mode-0_41/ruby/lib/thrift/server/mongrel_http_server.rb0000664000175000017500000000366211513076422025110 0ustar uwabamiuwabami# # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. # require 'mongrel' ## Sticks a service on a URL, using mongrel to do the HTTP work module Thrift class MongrelHTTPServer < BaseServer class Handler < Mongrel::HttpHandler def initialize(processor, protocol_factory) @processor = processor @protocol_factory = protocol_factory end def process(request, response) if request.params["REQUEST_METHOD"] == "POST" response.start(200) do |head, out| head["Content-Type"] = "application/x-thrift" transport = IOStreamTransport.new request.body, out protocol = @protocol_factory.get_protocol transport @processor.process protocol, protocol end else response.start(404) { } end end end def initialize(processor, opts={}) port = opts[:port] || 80 ip = opts[:ip] || "0.0.0.0" path = opts[:path] || "" protocol_factory = opts[:protocol_factory] || BinaryProtocolFactory.new @server = Mongrel::HttpServer.new ip, port @server.register "/#{path}", Handler.new(processor, protocol_factory) end def serve @server.run.join end end end evernote-mode-0_41/ruby/lib/thrift/server/thread_pool_server.rb0000664000175000017500000000465311513076422024707 0ustar uwabamiuwabami# # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. # require 'thread' module Thrift class ThreadPoolServer < BaseServer def initialize(processor, server_transport, transport_factory=nil, protocol_factory=nil, num=20) super(processor, server_transport, transport_factory, protocol_factory) @thread_q = SizedQueue.new(num) @exception_q = Queue.new @running = false end ## exceptions that happen in worker threads will be relayed here and ## must be caught. 'retry' can be used to continue. (threads will ## continue to run while the exception is being handled.) def rescuable_serve Thread.new { serve } unless @running @running = true raise @exception_q.pop end ## exceptions that happen in worker threads simply cause that thread ## to die and another to be spawned in its place. def serve @server_transport.listen begin loop do @thread_q.push(:token) Thread.new do begin loop do client = @server_transport.accept trans = @transport_factory.get_transport(client) prot = @protocol_factory.get_protocol(trans) begin loop do @processor.process(prot, prot) end rescue Thrift::TransportException, Thrift::ProtocolException => e ensure trans.close end end rescue => e @exception_q.push(e) ensure @thread_q.pop # thread died! end end end ensure @server_transport.close end end end endevernote-mode-0_41/ruby/lib/thrift/server/base_server.rb0000664000175000017500000000231311513076422023310 0ustar uwabamiuwabami# # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. # module Thrift class BaseServer def initialize(processor, server_transport, transport_factory=nil, protocol_factory=nil) @processor = processor @server_transport = server_transport @transport_factory = transport_factory ? transport_factory : Thrift::BaseTransportFactory.new @protocol_factory = protocol_factory ? protocol_factory : Thrift::BinaryProtocolFactory.new end def serve; nil; end end endevernote-mode-0_41/ruby/lib/thrift/processor.rb0000664000175000017500000000337211513076422021527 0ustar uwabamiuwabami# # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. # module Thrift module Processor def initialize(handler) @handler = handler end def process(iprot, oprot) name, type, seqid = iprot.read_message_begin if respond_to?("process_#{name}") send("process_#{name}", seqid, iprot, oprot) true else iprot.skip(Types::STRUCT) iprot.read_message_end x = ApplicationException.new(ApplicationException::UNKNOWN_METHOD, 'Unknown function '+name) oprot.write_message_begin(name, MessageTypes::EXCEPTION, seqid) x.write(oprot) oprot.write_message_end oprot.trans.flush false end end def read_args(iprot, args_class) args = args_class.new args.read(iprot) iprot.read_message_end args end def write_result(result, oprot, name, seqid) oprot.write_message_begin(name, MessageTypes::REPLY, seqid) result.write(oprot) oprot.write_message_end oprot.trans.flush end end end evernote-mode-0_41/ruby/lib/thrift/client.rb0000664000175000017500000000336611513076422020771 0ustar uwabamiuwabami# # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. # module Thrift module Client def initialize(iprot, oprot=nil) @iprot = iprot @oprot = oprot || iprot @seqid = 0 end def send_message(name, args_class, args = {}) @oprot.write_message_begin(name, MessageTypes::CALL, @seqid) data = args_class.new args.each do |k, v| data.send("#{k.to_s}=", v) end begin data.write(@oprot) rescue StandardError => e @oprot.trans.close raise e end @oprot.write_message_end @oprot.trans.flush end def receive_message(result_klass) fname, mtype, rseqid = @iprot.read_message_begin handle_exception(mtype) result = result_klass.new result.read(@iprot) @iprot.read_message_end result end def handle_exception(mtype) if mtype == MessageTypes::EXCEPTION x = ApplicationException.new x.read(@iprot) @iprot.read_message_end raise x end end end end evernote-mode-0_41/ruby/lib/thrift/core_ext.rb0000664000175000017500000000163411513076422021317 0ustar uwabamiuwabami# # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. # Dir[File.dirname(__FILE__) + "/core_ext/*.rb"].each do |file| name = File.basename(file, '.rb') require "thrift/core_ext/#{name}" end evernote-mode-0_41/ruby/lib/thrift/union.rb0000664000175000017500000001203611513076422020635 0ustar uwabamiuwabami# # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. # module Thrift class Union def initialize(name=nil, value=nil) if name if name.is_a? Hash if name.size > 1 raise "#{self.class} cannot be instantiated with more than one field!" end name, value = name.keys.first, name.values.first end if Thrift.type_checking raise Exception, "#{self.class} does not contain a field named #{name}!" unless name_to_id(name.to_s) end if value.nil? raise Exception, "Union #{self.class} cannot be instantiated with setfield and nil value!" end Thrift.check_type(value, struct_fields[name_to_id(name.to_s)], name) if Thrift.type_checking elsif !value.nil? raise Exception, "Value provided, but no name!" end @setfield = name @value = value end def inspect if get_set_field "<#{self.class} #{@setfield}: #{inspect_field(@value, struct_fields[name_to_id(@setfield.to_s)])}>" else "<#{self.class} >" end end def read(iprot) iprot.read_struct_begin fname, ftype, fid = iprot.read_field_begin handle_message(iprot, fid, ftype) iprot.read_field_end fname, ftype, fid = iprot.read_field_begin raise "Too many fields for union" unless (ftype == Types::STOP) iprot.read_struct_end validate end def write(oprot) validate oprot.write_struct_begin(self.class.name) fid = self.name_to_id(@setfield.to_s) field_info = struct_fields[fid] type = field_info[:type] if is_container? type oprot.write_field_begin(@setfield, type, fid) write_container(oprot, @value, field_info) oprot.write_field_end else oprot.write_field(@setfield, type, fid, @value) end oprot.write_field_stop oprot.write_struct_end end def ==(other) other != nil && @setfield == other.get_set_field && @value == other.get_value end def eql?(other) self.class == other.class && self == other end def hash [self.class.name, @setfield, @value].hash end def self.field_accessor(klass, field_info) klass.send :define_method, field_info[:name] do if field_info[:name].to_sym == @setfield @value else raise RuntimeError, "#{field_info[:name]} is not union's set field." end end klass.send :define_method, "#{field_info[:name]}=" do |value| Thrift.check_type(value, field_info, field_info[:name]) if Thrift.type_checking @setfield = field_info[:name].to_sym @value = value end end def self.qmark_isset_method(klass, field_info) klass.send :define_method, "#{field_info[:name]}?" do get_set_field == field_info[:name].to_sym && !get_value.nil? end end def self.generate_accessors(klass) klass::FIELDS.values.each do |field_info| field_accessor(klass, field_info) qmark_isset_method(klass, field_info) end end # get the symbol that indicates what the currently set field type is. def get_set_field @setfield end # get the current value of this union, regardless of what the set field is. # generally, you should only use this method when you don't know in advance # what field to expect. def get_value @value end def <=>(other) if self.class == other.class if get_set_field == other.get_set_field if get_set_field.nil? 0 else get_value <=> other.get_value end else if get_set_field && other.get_set_field.nil? -1 elsif get_set_field.nil? && other.get_set_field 1 elsif get_set_field.nil? && other.get_set_field.nil? 0 else name_to_id(get_set_field.to_s) <=> name_to_id(other.get_set_field.to_s) end end else self.class <=> other.class end end protected def handle_message(iprot, fid, ftype) field = struct_fields[fid] if field and field[:type] == ftype @value = read_field(iprot, field) name = field[:name].to_sym @setfield = name else iprot.skip(ftype) end end end endevernote-mode-0_41/ruby/lib/thrift/types.rb0000664000175000017500000000537711513076422020663 0ustar uwabamiuwabami# # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. # require 'set' module Thrift module Types STOP = 0 VOID = 1 BOOL = 2 BYTE = 3 DOUBLE = 4 I16 = 6 I32 = 8 I64 = 10 STRING = 11 STRUCT = 12 MAP = 13 SET = 14 LIST = 15 end class << self attr_accessor :type_checking end class TypeError < Exception end def self.check_type(value, field, name, skip_nil=true) return if value.nil? and skip_nil klasses = case field[:type] when Types::VOID NilClass when Types::BOOL [TrueClass, FalseClass] when Types::BYTE, Types::I16, Types::I32, Types::I64 Integer when Types::DOUBLE Float when Types::STRING String when Types::STRUCT [Struct, Union] when Types::MAP Hash when Types::SET Set when Types::LIST Array end valid = klasses && [*klasses].any? { |klass| klass === value } raise TypeError, "Expected #{type_name(field[:type])}, received #{value.class} for field #{name}" unless valid # check elements now case field[:type] when Types::MAP value.each_pair do |k,v| check_type(k, field[:key], "#{name}.key", false) check_type(v, field[:value], "#{name}.value", false) end when Types::SET, Types::LIST value.each do |el| check_type(el, field[:element], "#{name}.element", false) end when Types::STRUCT raise TypeError, "Expected #{field[:class]}, received #{value.class} for field #{name}" unless field[:class] == value.class end end def self.type_name(type) Types.constants.each do |const| return "Types::#{const}" if Types.const_get(const) == type end nil end module MessageTypes CALL = 1 REPLY = 2 EXCEPTION = 3 ONEWAY = 4 end end Thrift.type_checking = false if Thrift.type_checking.nil? evernote-mode-0_41/ruby/lib/thrift/transport/0000775000175000017500000000000011601107152021203 5ustar uwabamiuwabamievernote-mode-0_41/ruby/lib/thrift/transport/server_socket.rb0000664000175000017500000000306411513076422024420 0ustar uwabamiuwabami# encoding: ascii-8bit # # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. # require 'socket' module Thrift class ServerSocket < BaseServerTransport # call-seq: initialize(host = nil, port) def initialize(host_or_port, port = nil) if port @host = host_or_port @port = port else @host = nil @port = host_or_port end @handle = nil end attr_reader :handle def listen @handle = TCPServer.new(@host, @port) end def accept unless @handle.nil? sock = @handle.accept trans = Socket.new trans.handle = sock trans end end def close @handle.close unless @handle.nil? or @handle.closed? @handle = nil end def closed? @handle.nil? or @handle.closed? end alias to_io handle end endevernote-mode-0_41/ruby/lib/thrift/transport/socket.rb0000664000175000017500000001034711513076422023034 0ustar uwabamiuwabami# encoding: ascii-8bit # # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. # require 'socket' module Thrift class Socket < BaseTransport def initialize(host='localhost', port=9090, timeout=nil) @host = host @port = port @timeout = timeout @desc = "#{host}:#{port}" @handle = nil end attr_accessor :handle, :timeout def open begin addrinfo = ::Socket::getaddrinfo(@host, @port).first @handle = ::Socket.new(addrinfo[4], ::Socket::SOCK_STREAM, 0) sockaddr = ::Socket.sockaddr_in(addrinfo[1], addrinfo[3]) begin @handle.connect_nonblock(sockaddr) rescue Errno::EINPROGRESS unless IO.select(nil, [ @handle ], nil, @timeout) raise TransportException.new(TransportException::NOT_OPEN, "Connection timeout to #{@desc}") end begin @handle.connect_nonblock(sockaddr) rescue Errno::EISCONN end end @handle rescue StandardError => e raise TransportException.new(TransportException::NOT_OPEN, "Could not connect to #{@desc}: #{e}") end end def open? !@handle.nil? and !@handle.closed? end def write(str) raise IOError, "closed stream" unless open? begin if @timeout.nil? or @timeout == 0 @handle.write(str) else len = 0 start = Time.now while Time.now - start < @timeout rd, wr, = IO.select(nil, [@handle], nil, @timeout) if wr and not wr.empty? len += @handle.write_nonblock(str[len..-1]) break if len >= str.length end end if len < str.length raise TransportException.new(TransportException::TIMED_OUT, "Socket: Timed out writing #{str.length} bytes to #{@desc}") else len end end rescue TransportException => e # pass this on raise e rescue StandardError => e @handle.close @handle = nil raise TransportException.new(TransportException::NOT_OPEN, e.message) end end def read(sz) raise IOError, "closed stream" unless open? begin if @timeout.nil? or @timeout == 0 data = @handle.readpartial(sz) else # it's possible to interrupt select for something other than the timeout # so we need to ensure we've waited long enough start = Time.now rd = nil # scoping loop do rd, = IO.select([@handle], nil, nil, @timeout) break if (rd and not rd.empty?) or Time.now - start >= @timeout end if rd.nil? or rd.empty? raise TransportException.new(TransportException::TIMED_OUT, "Socket: Timed out reading #{sz} bytes from #{@desc}") else data = @handle.readpartial(sz) end end rescue TransportException => e # don't let this get caught by the StandardError handler raise e rescue StandardError => e @handle.close unless @handle.closed? @handle = nil raise TransportException.new(TransportException::NOT_OPEN, e.message) end if (data.nil? or data.length == 0) raise TransportException.new(TransportException::UNKNOWN, "Socket: Could not read #{sz} bytes from #{@desc}") end data end def close @handle.close unless @handle.nil? or @handle.closed? @handle = nil end def to_io @handle end end endevernote-mode-0_41/ruby/lib/thrift/transport/buffered_transport.rb0000664000175000017500000000335111513076422025437 0ustar uwabamiuwabami# encoding: ascii-8bit # # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. # module Thrift class BufferedTransport < BaseTransport DEFAULT_BUFFER = 4096 def initialize(transport) @transport = transport @wbuf = '' @rbuf = '' @index = 0 end def open? return @transport.open? end def open @transport.open end def close flush @transport.close end def read(sz) @index += sz ret = @rbuf.slice(@index - sz, sz) || '' if ret.length == 0 @rbuf = @transport.read([sz, DEFAULT_BUFFER].max) @index = sz ret = @rbuf.slice(0, sz) || '' end ret end def write(buf) @wbuf << buf end def flush if @wbuf != '' @transport.write(@wbuf) @wbuf = '' end @transport.flush end end class BufferedTransportFactory < BaseTransportFactory def get_transport(transport) return BufferedTransport.new(transport) end end endevernote-mode-0_41/ruby/lib/thrift/transport/http_client_transport.rb0000664000175000017500000000273011513076422026172 0ustar uwabamiuwabami# encoding: ascii-8bit # # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. # require 'net/http' require 'net/https' require 'uri' require 'stringio' module Thrift class HTTPClientTransport < BaseTransport def initialize(url) @url = URI url @headers = {'Content-Type' => 'application/x-thrift'} @outbuf = "" end def open?; true end def read(sz); @inbuf.read sz end def write(buf); @outbuf << buf end def add_headers(headers) @headers = @headers.merge(headers) end def flush http = Net::HTTP.new @url.host, @url.port http.use_ssl = @url.scheme == "https" resp, data = http.post(@url.request_uri, @outbuf, @headers) @inbuf = StringIO.new data @outbuf = "" end end end evernote-mode-0_41/ruby/lib/thrift/transport/memory_buffer_transport.rb0000664000175000017500000000436711513076422026526 0ustar uwabamiuwabami# encoding: ascii-8bit # # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. # module Thrift class MemoryBufferTransport < BaseTransport GARBAGE_BUFFER_SIZE = 4*(2**10) # 4kB # If you pass a string to this, you should #dup that string # unless you want it to be modified by #read and #write #-- # this behavior is no longer required. If you wish to change it # go ahead, just make sure the specs pass def initialize(buffer = nil) @buf = buffer || '' @index = 0 end def open? return true end def open end def close end def peek @index < @buf.size end # this method does not use the passed object directly but copies it def reset_buffer(new_buf = '') @buf.replace new_buf @index = 0 end def available @buf.length - @index end def read(len) data = @buf.slice(@index, len) @index += len @index = @buf.size if @index > @buf.size if @index >= GARBAGE_BUFFER_SIZE @buf = @buf.slice(@index..-1) @index = 0 end if data.size < len raise EOFError, "Not enough bytes remain in buffer" end data end def write(wbuf) @buf << wbuf end def flush end def inspect_buffer out = [] for idx in 0...(@buf.size) # if idx != 0 # out << " " # end if idx == @index out << ">" end out << @buf[idx].ord.to_s(16) end out.join(" ") end end end evernote-mode-0_41/ruby/lib/thrift/transport/base_server_transport.rb0000664000175000017500000000204711513076422026156 0ustar uwabamiuwabami# encoding: ascii-8bit # # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. # module Thrift class BaseServerTransport def listen raise NotImplementedError end def accept raise NotImplementedError end def close; nil; end def closed? raise NotImplementedError end end endevernote-mode-0_41/ruby/lib/thrift/transport/unix_socket.rb0000664000175000017500000000234711513076422024100 0ustar uwabamiuwabami# encoding: ascii-8bit # # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. # require 'socket' module Thrift class UNIXSocket < Socket def initialize(path, timeout=nil) @path = path @timeout = timeout @desc = @path # for read()'s error @handle = nil end def open begin @handle = ::UNIXSocket.new(@path) rescue StandardError raise TransportException.new(TransportException::NOT_OPEN, "Could not open UNIX socket at #{@path}") end end end endevernote-mode-0_41/ruby/lib/thrift/transport/unix_server_socket.rb0000664000175000017500000000301211513076422025454 0ustar uwabamiuwabami# encoding: ascii-8bit # # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. # require 'socket' module Thrift class UNIXServerSocket < BaseServerTransport def initialize(path) @path = path @handle = nil end attr_accessor :handle def listen @handle = ::UNIXServer.new(@path) end def accept unless @handle.nil? sock = @handle.accept trans = UNIXSocket.new(nil) trans.handle = sock trans end end def close if @handle @handle.close unless @handle.closed? @handle = nil # UNIXServer doesn't delete the socket file, so we have to do it ourselves File.delete(@path) end end def closed? @handle.nil? or @handle.closed? end alias to_io handle end endevernote-mode-0_41/ruby/lib/thrift/transport/base_transport.rb0000664000175000017500000000304611513076422024570 0ustar uwabamiuwabami# encoding: ascii-8bit # # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. # module Thrift class TransportException < Exception UNKNOWN = 0 NOT_OPEN = 1 ALREADY_OPEN = 2 TIMED_OUT = 3 END_OF_FILE = 4 attr_reader :type def initialize(type=UNKNOWN, message=nil) super(message) @type = type end end class BaseTransport def open?; end def open; end def close; end def read(sz) raise NotImplementedError end def read_all(size) buf = '' while (buf.length < size) chunk = read(size - buf.length) buf << chunk end buf end def write(buf); end alias_method :<<, :write def flush; end end class BaseTransportFactory def get_transport(trans) return trans end end endevernote-mode-0_41/ruby/lib/thrift/transport/framed_transport.rb0000664000175000017500000000415611513076422025117 0ustar uwabamiuwabami# encoding: ascii-8bit # # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. # module Thrift class FramedTransport < BaseTransport def initialize(transport, read=true, write=true) @transport = transport @rbuf = '' @wbuf = '' @read = read @write = write @index = 0 end def open? @transport.open? end def open @transport.open end def close @transport.close end def read(sz) return @transport.read(sz) unless @read return '' if sz <= 0 read_frame if @index >= @rbuf.length @index += sz @rbuf.slice(@index - sz, sz) || '' end def write(buf,sz=nil) return @transport.write(buf) unless @write @wbuf << (sz ? buf[0...sz] : buf) end # # Writes the output buffer to the stream in the format of a 4-byte length # followed by the actual data. # def flush return @transport.flush unless @write out = [@wbuf.length].pack('N') out << @wbuf @transport.write(out) @transport.flush @wbuf = '' end private def read_frame sz = @transport.read_all(4).unpack('N').first @index = 0 @rbuf = @transport.read_all(sz) end end class FramedTransportFactory < BaseTransportFactory def get_transport(transport) return FramedTransport.new(transport) end end endevernote-mode-0_41/ruby/lib/thrift/transport/io_stream_transport.rb0000664000175000017500000000266311513076422025644 0ustar uwabamiuwabami# encoding: ascii-8bit # # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. # # Very very simple implementation of wrapping two objects, one with a #read # method and one with a #write method, into a transport for thrift. # # Assumes both objects are open, remain open, don't require flushing, etc. # module Thrift class IOStreamTransport < BaseTransport def initialize(input, output) @input = input @output = output end def open?; not @input.closed? or not @output.closed? end def read(sz); @input.read(sz) end def write(buf); @output.write(buf) end def close; @input.close; @output.close end def to_io; @input end # we're assuming this is used in a IO.select for reading end endevernote-mode-0_41/ruby/lib/thrift/exceptions.rb0000664000175000017500000000422211513076422021664 0ustar uwabamiuwabami# # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. # module Thrift class Exception < StandardError def initialize(message) super @message = message end attr_reader :message end class ApplicationException < Exception UNKNOWN = 0 UNKNOWN_METHOD = 1 INVALID_MESSAGE_TYPE = 2 WRONG_METHOD_NAME = 3 BAD_SEQUENCE_ID = 4 MISSING_RESULT = 5 attr_reader :type def initialize(type=UNKNOWN, message=nil) super(message) @type = type end def read(iprot) iprot.read_struct_begin while true fname, ftype, fid = iprot.read_field_begin if ftype == Types::STOP break end if fid == 1 and ftype == Types::STRING @message = iprot.read_string elsif fid == 2 and ftype == Types::I32 @type = iprot.read_i32 else iprot.skip(ftype) end iprot.read_field_end end iprot.read_struct_end end def write(oprot) oprot.write_struct_begin('Thrift::ApplicationException') unless @message.nil? oprot.write_field_begin('message', Types::STRING, 1) oprot.write_string(@message) oprot.write_field_end end unless @type.nil? oprot.write_field_begin('type', Types::I32, 2) oprot.write_i32(@type) oprot.write_field_end end oprot.write_field_stop oprot.write_struct_end end end endevernote-mode-0_41/ruby/setup.rb0000664000175000017500000010650211513076422016601 0ustar uwabamiuwabami# # setup.rb # # Copyright (c) 2000-2005 Minero Aoki # # This program is free software. # You can distribute/modify this program under the terms of # the GNU LGPL, Lesser General Public License version 2.1. # unless Enumerable.method_defined?(:map) # Ruby 1.4.6 module Enumerable alias map collect end end unless File.respond_to?(:read) # Ruby 1.6 def File.read(fname) open(fname) {|f| return f.read } end end unless Errno.const_defined?(:ENOTEMPTY) # Windows? module Errno class ENOTEMPTY # We do not raise this exception, implementation is not needed. end end end def File.binread(fname) open(fname, 'rb') {|f| return f.read } end # for corrupted Windows' stat(2) def File.dir?(path) File.directory?((path[-1,1] == '/') ? path : path + '/') end class ConfigTable include Enumerable def initialize(rbconfig) @rbconfig = rbconfig @items = [] @table = {} # options @install_prefix = nil @config_opt = nil @verbose = true @no_harm = false end attr_accessor :install_prefix attr_accessor :config_opt attr_writer :verbose def verbose? @verbose end attr_writer :no_harm def no_harm? @no_harm end def [](key) lookup(key).resolve(self) end def []=(key, val) lookup(key).set val end def names @items.map {|i| i.name } end def each(&block) @items.each(&block) end def key?(name) @table.key?(name) end def lookup(name) @table[name] or setup_rb_error "no such config item: #{name}" end def add(item) @items.push item @table[item.name] = item end def remove(name) item = lookup(name) @items.delete_if {|i| i.name == name } @table.delete_if {|name, i| i.name == name } item end def load_script(path, inst = nil) if File.file?(path) MetaConfigEnvironment.new(self, inst).instance_eval File.read(path), path end end def savefile '.config' end def load_savefile begin File.foreach(savefile()) do |line| k, v = *line.split(/=/, 2) self[k] = v.strip end rescue Errno::ENOENT setup_rb_error $!.message + "\n#{File.basename($0)} config first" end end def save @items.each {|i| i.value } File.open(savefile(), 'w') {|f| @items.each do |i| f.printf "%s=%s\n", i.name, i.value if i.value? and i.value end } end def load_standard_entries standard_entries(@rbconfig).each do |ent| add ent end end def standard_entries(rbconfig) c = rbconfig rubypath = File.join(c['bindir'], c['ruby_install_name'] + c['EXEEXT']) major = c['MAJOR'].to_i minor = c['MINOR'].to_i teeny = c['TEENY'].to_i version = "#{major}.#{minor}" # ruby ver. >= 1.4.4? newpath_p = ((major >= 2) or ((major == 1) and ((minor >= 5) or ((minor == 4) and (teeny >= 4))))) if c['rubylibdir'] # V > 1.6.3 libruby = "#{c['prefix']}/lib/ruby" librubyver = c['rubylibdir'] librubyverarch = c['archdir'] siteruby = c['sitedir'] siterubyver = c['sitelibdir'] siterubyverarch = c['sitearchdir'] elsif newpath_p # 1.4.4 <= V <= 1.6.3 libruby = "#{c['prefix']}/lib/ruby" librubyver = "#{c['prefix']}/lib/ruby/#{version}" librubyverarch = "#{c['prefix']}/lib/ruby/#{version}/#{c['arch']}" siteruby = c['sitedir'] siterubyver = "$siteruby/#{version}" siterubyverarch = "$siterubyver/#{c['arch']}" else # V < 1.4.4 libruby = "#{c['prefix']}/lib/ruby" librubyver = "#{c['prefix']}/lib/ruby/#{version}" librubyverarch = "#{c['prefix']}/lib/ruby/#{version}/#{c['arch']}" siteruby = "#{c['prefix']}/lib/ruby/#{version}/site_ruby" siterubyver = siteruby siterubyverarch = "$siterubyver/#{c['arch']}" end parameterize = lambda {|path| path.sub(/\A#{Regexp.quote(c['prefix'])}/, '$prefix') } if arg = c['configure_args'].split.detect {|arg| /--with-make-prog=/ =~ arg } makeprog = arg.sub(/'/, '').split(/=/, 2)[1] else makeprog = 'make' end [ ExecItem.new('installdirs', 'std/site/home', 'std: install under libruby; site: install under site_ruby; home: install under $HOME')\ {|val, table| case val when 'std' table['rbdir'] = '$librubyver' table['sodir'] = '$librubyverarch' when 'site' table['rbdir'] = '$siterubyver' table['sodir'] = '$siterubyverarch' when 'home' setup_rb_error '$HOME was not set' unless ENV['HOME'] table['prefix'] = ENV['HOME'] table['rbdir'] = '$libdir/ruby' table['sodir'] = '$libdir/ruby' end }, PathItem.new('prefix', 'path', c['prefix'], 'path prefix of target environment'), PathItem.new('bindir', 'path', parameterize.call(c['bindir']), 'the directory for commands'), PathItem.new('libdir', 'path', parameterize.call(c['libdir']), 'the directory for libraries'), PathItem.new('datadir', 'path', parameterize.call(c['datadir']), 'the directory for shared data'), PathItem.new('mandir', 'path', parameterize.call(c['mandir']), 'the directory for man pages'), PathItem.new('sysconfdir', 'path', parameterize.call(c['sysconfdir']), 'the directory for system configuration files'), PathItem.new('localstatedir', 'path', parameterize.call(c['localstatedir']), 'the directory for local state data'), PathItem.new('libruby', 'path', libruby, 'the directory for ruby libraries'), PathItem.new('librubyver', 'path', librubyver, 'the directory for standard ruby libraries'), PathItem.new('librubyverarch', 'path', librubyverarch, 'the directory for standard ruby extensions'), PathItem.new('siteruby', 'path', siteruby, 'the directory for version-independent aux ruby libraries'), PathItem.new('siterubyver', 'path', siterubyver, 'the directory for aux ruby libraries'), PathItem.new('siterubyverarch', 'path', siterubyverarch, 'the directory for aux ruby binaries'), PathItem.new('rbdir', 'path', '$siterubyver', 'the directory for ruby scripts'), PathItem.new('sodir', 'path', '$siterubyverarch', 'the directory for ruby extentions'), PathItem.new('rubypath', 'path', rubypath, 'the path to set to #! line'), ProgramItem.new('rubyprog', 'name', rubypath, 'the ruby program using for installation'), ProgramItem.new('makeprog', 'name', makeprog, 'the make program to compile ruby extentions'), SelectItem.new('shebang', 'all/ruby/never', 'ruby', 'shebang line (#!) editing mode'), BoolItem.new('without-ext', 'yes/no', 'no', 'does not compile/install ruby extentions') ] end private :standard_entries def load_multipackage_entries multipackage_entries().each do |ent| add ent end end def multipackage_entries [ PackageSelectionItem.new('with', 'name,name...', '', 'ALL', 'package names that you want to install'), PackageSelectionItem.new('without', 'name,name...', '', 'NONE', 'package names that you do not want to install') ] end private :multipackage_entries ALIASES = { 'std-ruby' => 'librubyver', 'stdruby' => 'librubyver', 'rubylibdir' => 'librubyver', 'archdir' => 'librubyverarch', 'site-ruby-common' => 'siteruby', # For backward compatibility 'site-ruby' => 'siterubyver', # For backward compatibility 'bin-dir' => 'bindir', 'bin-dir' => 'bindir', 'rb-dir' => 'rbdir', 'so-dir' => 'sodir', 'data-dir' => 'datadir', 'ruby-path' => 'rubypath', 'ruby-prog' => 'rubyprog', 'ruby' => 'rubyprog', 'make-prog' => 'makeprog', 'make' => 'makeprog' } def fixup ALIASES.each do |ali, name| @table[ali] = @table[name] end @items.freeze @table.freeze @options_re = /\A--(#{@table.keys.join('|')})(?:=(.*))?\z/ end def parse_opt(opt) m = @options_re.match(opt) or setup_rb_error "config: unknown option #{opt}" m.to_a[1,2] end def dllext @rbconfig['DLEXT'] end def value_config?(name) lookup(name).value? end class Item def initialize(name, template, default, desc) @name = name.freeze @template = template @value = default @default = default @description = desc end attr_reader :name attr_reader :description attr_accessor :default alias help_default default def help_opt "--#{@name}=#{@template}" end def value? true end def value @value end def resolve(table) @value.gsub(%r<\$([^/]+)>) { table[$1] } end def set(val) @value = check(val) end private def check(val) setup_rb_error "config: --#{name} requires argument" unless val val end end class BoolItem < Item def config_type 'bool' end def help_opt "--#{@name}" end private def check(val) return 'yes' unless val case val when /\Ay(es)?\z/i, /\At(rue)?\z/i then 'yes' when /\An(o)?\z/i, /\Af(alse)\z/i then 'no' else setup_rb_error "config: --#{@name} accepts only yes/no for argument" end end end class PathItem < Item def config_type 'path' end private def check(path) setup_rb_error "config: --#{@name} requires argument" unless path path[0,1] == '$' ? path : File.expand_path(path) end end class ProgramItem < Item def config_type 'program' end end class SelectItem < Item def initialize(name, selection, default, desc) super @ok = selection.split('/') end def config_type 'select' end private def check(val) unless @ok.include?(val.strip) setup_rb_error "config: use --#{@name}=#{@template} (#{val})" end val.strip end end class ExecItem < Item def initialize(name, selection, desc, &block) super name, selection, nil, desc @ok = selection.split('/') @action = block end def config_type 'exec' end def value? false end def resolve(table) setup_rb_error "$#{name()} wrongly used as option value" end undef set def evaluate(val, table) v = val.strip.downcase unless @ok.include?(v) setup_rb_error "invalid option --#{@name}=#{val} (use #{@template})" end @action.call v, table end end class PackageSelectionItem < Item def initialize(name, template, default, help_default, desc) super name, template, default, desc @help_default = help_default end attr_reader :help_default def config_type 'package' end private def check(val) unless File.dir?("packages/#{val}") setup_rb_error "config: no such package: #{val}" end val end end class MetaConfigEnvironment def initialize(config, installer) @config = config @installer = installer end def config_names @config.names end def config?(name) @config.key?(name) end def bool_config?(name) @config.lookup(name).config_type == 'bool' end def path_config?(name) @config.lookup(name).config_type == 'path' end def value_config?(name) @config.lookup(name).config_type != 'exec' end def add_config(item) @config.add item end def add_bool_config(name, default, desc) @config.add BoolItem.new(name, 'yes/no', default ? 'yes' : 'no', desc) end def add_path_config(name, default, desc) @config.add PathItem.new(name, 'path', default, desc) end def set_config_default(name, default) @config.lookup(name).default = default end def remove_config(name) @config.remove(name) end # For only multipackage def packages raise '[setup.rb fatal] multi-package metaconfig API packages() called for single-package; contact application package vendor' unless @installer @installer.packages end # For only multipackage def declare_packages(list) raise '[setup.rb fatal] multi-package metaconfig API declare_packages() called for single-package; contact application package vendor' unless @installer @installer.packages = list end end end # class ConfigTable # This module requires: #verbose?, #no_harm? module FileOperations def mkdir_p(dirname, prefix = nil) dirname = prefix + File.expand_path(dirname) if prefix $stderr.puts "mkdir -p #{dirname}" if verbose? return if no_harm? # Does not check '/', it's too abnormal. dirs = File.expand_path(dirname).split(%r<(?=/)>) if /\A[a-z]:\z/i =~ dirs[0] disk = dirs.shift dirs[0] = disk + dirs[0] end dirs.each_index do |idx| path = dirs[0..idx].join('') Dir.mkdir path unless File.dir?(path) end end def rm_f(path) $stderr.puts "rm -f #{path}" if verbose? return if no_harm? force_remove_file path end def rm_rf(path) $stderr.puts "rm -rf #{path}" if verbose? return if no_harm? remove_tree path end def remove_tree(path) if File.symlink?(path) remove_file path elsif File.dir?(path) remove_tree0 path else force_remove_file path end end def remove_tree0(path) Dir.foreach(path) do |ent| next if ent == '.' next if ent == '..' entpath = "#{path}/#{ent}" if File.symlink?(entpath) remove_file entpath elsif File.dir?(entpath) remove_tree0 entpath else force_remove_file entpath end end begin Dir.rmdir path rescue Errno::ENOTEMPTY # directory may not be empty end end def move_file(src, dest) force_remove_file dest begin File.rename src, dest rescue File.open(dest, 'wb') {|f| f.write File.binread(src) } File.chmod File.stat(src).mode, dest File.unlink src end end def force_remove_file(path) begin remove_file path rescue end end def remove_file(path) File.chmod 0777, path File.unlink path end def install(from, dest, mode, prefix = nil) $stderr.puts "install #{from} #{dest}" if verbose? return if no_harm? realdest = prefix ? prefix + File.expand_path(dest) : dest realdest = File.join(realdest, File.basename(from)) if File.dir?(realdest) str = File.binread(from) if diff?(str, realdest) verbose_off { rm_f realdest if File.exist?(realdest) } File.open(realdest, 'wb') {|f| f.write str } File.chmod mode, realdest File.open("#{objdir_root()}/InstalledFiles", 'a') {|f| if prefix f.puts realdest.sub(prefix, '') else f.puts realdest end } end end def diff?(new_content, path) return true unless File.exist?(path) new_content != File.binread(path) end def command(*args) $stderr.puts args.join(' ') if verbose? system(*args) or raise RuntimeError, "system(#{args.map{|a| a.inspect }.join(' ')}) failed" end def ruby(*args) command config('rubyprog'), *args end def make(task = nil) command(*[config('makeprog'), task].compact) end def extdir?(dir) File.exist?("#{dir}/MANIFEST") or File.exist?("#{dir}/extconf.rb") end def files_of(dir) Dir.open(dir) {|d| return d.select {|ent| File.file?("#{dir}/#{ent}") } } end DIR_REJECT = %w( . .. CVS SCCS RCS CVS.adm .svn ) def directories_of(dir) Dir.open(dir) {|d| return d.select {|ent| File.dir?("#{dir}/#{ent}") } - DIR_REJECT } end end # This module requires: #srcdir_root, #objdir_root, #relpath module HookScriptAPI def get_config(key) @config[key] end alias config get_config # obsolete: use metaconfig to change configuration def set_config(key, val) @config[key] = val end # # srcdir/objdir (works only in the package directory) # def curr_srcdir "#{srcdir_root()}/#{relpath()}" end def curr_objdir "#{objdir_root()}/#{relpath()}" end def srcfile(path) "#{curr_srcdir()}/#{path}" end def srcexist?(path) File.exist?(srcfile(path)) end def srcdirectory?(path) File.dir?(srcfile(path)) end def srcfile?(path) File.file?(srcfile(path)) end def srcentries(path = '.') Dir.open("#{curr_srcdir()}/#{path}") {|d| return d.to_a - %w(. ..) } end def srcfiles(path = '.') srcentries(path).select {|fname| File.file?(File.join(curr_srcdir(), path, fname)) } end def srcdirectories(path = '.') srcentries(path).select {|fname| File.dir?(File.join(curr_srcdir(), path, fname)) } end end class ToplevelInstaller Version = '3.4.1' Copyright = 'Copyright (c) 2000-2005 Minero Aoki' TASKS = [ [ 'all', 'do config, setup, then install' ], [ 'config', 'saves your configurations' ], [ 'show', 'shows current configuration' ], [ 'setup', 'compiles ruby extentions and others' ], [ 'install', 'installs files' ], [ 'test', 'run all tests in test/' ], [ 'clean', "does `make clean' for each extention" ], [ 'distclean',"does `make distclean' for each extention" ] ] def ToplevelInstaller.invoke config = ConfigTable.new(load_rbconfig()) config.load_standard_entries config.load_multipackage_entries if multipackage? config.fixup klass = (multipackage?() ? ToplevelInstallerMulti : ToplevelInstaller) klass.new(File.dirname($0), config).invoke end def ToplevelInstaller.multipackage? File.dir?(File.dirname($0) + '/packages') end def ToplevelInstaller.load_rbconfig if arg = ARGV.detect {|arg| /\A--rbconfig=/ =~ arg } ARGV.delete(arg) load File.expand_path(arg.split(/=/, 2)[1]) $".push 'rbconfig.rb' else require 'rbconfig' end ::Config::CONFIG end def initialize(ardir_root, config) @ardir = File.expand_path(ardir_root) @config = config # cache @valid_task_re = nil end def config(key) @config[key] end def inspect "#<#{self.class} #{__id__()}>" end def invoke run_metaconfigs case task = parsearg_global() when nil, 'all' parsearg_config init_installers exec_config exec_setup exec_install else case task when 'config', 'test' ; when 'clean', 'distclean' @config.load_savefile if File.exist?(@config.savefile) else @config.load_savefile end __send__ "parsearg_#{task}" init_installers __send__ "exec_#{task}" end end def run_metaconfigs @config.load_script "#{@ardir}/metaconfig" end def init_installers @installer = Installer.new(@config, @ardir, File.expand_path('.')) end # # Hook Script API bases # def srcdir_root @ardir end def objdir_root '.' end def relpath '.' end # # Option Parsing # def parsearg_global while arg = ARGV.shift case arg when /\A\w+\z/ setup_rb_error "invalid task: #{arg}" unless valid_task?(arg) return arg when '-q', '--quiet' @config.verbose = false when '--verbose' @config.verbose = true when '--help' print_usage $stdout exit 0 when '--version' puts "#{File.basename($0)} version #{Version}" exit 0 when '--copyright' puts Copyright exit 0 else setup_rb_error "unknown global option '#{arg}'" end end nil end def valid_task?(t) valid_task_re() =~ t end def valid_task_re @valid_task_re ||= /\A(?:#{TASKS.map {|task,desc| task }.join('|')})\z/ end def parsearg_no_options unless ARGV.empty? task = caller(0).first.slice(%r<`parsearg_(\w+)'>, 1) setup_rb_error "#{task}: unknown options: #{ARGV.join(' ')}" end end alias parsearg_show parsearg_no_options alias parsearg_setup parsearg_no_options alias parsearg_test parsearg_no_options alias parsearg_clean parsearg_no_options alias parsearg_distclean parsearg_no_options def parsearg_config evalopt = [] set = [] @config.config_opt = [] while i = ARGV.shift if /\A--?\z/ =~ i @config.config_opt = ARGV.dup break end name, value = *@config.parse_opt(i) if @config.value_config?(name) @config[name] = value else evalopt.push [name, value] end set.push name end evalopt.each do |name, value| @config.lookup(name).evaluate value, @config end # Check if configuration is valid set.each do |n| @config[n] if @config.value_config?(n) end end def parsearg_install @config.no_harm = false @config.install_prefix = '' while a = ARGV.shift case a when '--no-harm' @config.no_harm = true when /\A--prefix=/ path = a.split(/=/, 2)[1] path = File.expand_path(path) unless path[0,1] == '/' @config.install_prefix = path else setup_rb_error "install: unknown option #{a}" end end end def print_usage(out) out.puts 'Typical Installation Procedure:' out.puts " $ ruby #{File.basename $0} config" out.puts " $ ruby #{File.basename $0} setup" out.puts " # ruby #{File.basename $0} install (may require root privilege)" out.puts out.puts 'Detailed Usage:' out.puts " ruby #{File.basename $0} " out.puts " ruby #{File.basename $0} [] []" fmt = " %-24s %s\n" out.puts out.puts 'Global options:' out.printf fmt, '-q,--quiet', 'suppress message outputs' out.printf fmt, ' --verbose', 'output messages verbosely' out.printf fmt, ' --help', 'print this message' out.printf fmt, ' --version', 'print version and quit' out.printf fmt, ' --copyright', 'print copyright and quit' out.puts out.puts 'Tasks:' TASKS.each do |name, desc| out.printf fmt, name, desc end fmt = " %-24s %s [%s]\n" out.puts out.puts 'Options for CONFIG or ALL:' @config.each do |item| out.printf fmt, item.help_opt, item.description, item.help_default end out.printf fmt, '--rbconfig=path', 'rbconfig.rb to load',"running ruby's" out.puts out.puts 'Options for INSTALL:' out.printf fmt, '--no-harm', 'only display what to do if given', 'off' out.printf fmt, '--prefix=path', 'install path prefix', '' out.puts end # # Task Handlers # def exec_config @installer.exec_config @config.save # must be final end def exec_setup @installer.exec_setup end def exec_install @installer.exec_install end def exec_test @installer.exec_test end def exec_show @config.each do |i| printf "%-20s %s\n", i.name, i.value if i.value? end end def exec_clean @installer.exec_clean end def exec_distclean @installer.exec_distclean end end # class ToplevelInstaller class ToplevelInstallerMulti < ToplevelInstaller include FileOperations def initialize(ardir_root, config) super @packages = directories_of("#{@ardir}/packages") raise 'no package exists' if @packages.empty? @root_installer = Installer.new(@config, @ardir, File.expand_path('.')) end def run_metaconfigs @config.load_script "#{@ardir}/metaconfig", self @packages.each do |name| @config.load_script "#{@ardir}/packages/#{name}/metaconfig" end end attr_reader :packages def packages=(list) raise 'package list is empty' if list.empty? list.each do |name| raise "directory packages/#{name} does not exist"\ unless File.dir?("#{@ardir}/packages/#{name}") end @packages = list end def init_installers @installers = {} @packages.each do |pack| @installers[pack] = Installer.new(@config, "#{@ardir}/packages/#{pack}", "packages/#{pack}") end with = extract_selection(config('with')) without = extract_selection(config('without')) @selected = @installers.keys.select {|name| (with.empty? or with.include?(name)) \ and not without.include?(name) } end def extract_selection(list) a = list.split(/,/) a.each do |name| setup_rb_error "no such package: #{name}" unless @installers.key?(name) end a end def print_usage(f) super f.puts 'Inluded packages:' f.puts ' ' + @packages.sort.join(' ') f.puts end # # Task Handlers # def exec_config run_hook 'pre-config' each_selected_installers {|inst| inst.exec_config } run_hook 'post-config' @config.save # must be final end def exec_setup run_hook 'pre-setup' each_selected_installers {|inst| inst.exec_setup } run_hook 'post-setup' end def exec_install run_hook 'pre-install' each_selected_installers {|inst| inst.exec_install } run_hook 'post-install' end def exec_test run_hook 'pre-test' each_selected_installers {|inst| inst.exec_test } run_hook 'post-test' end def exec_clean rm_f @config.savefile run_hook 'pre-clean' each_selected_installers {|inst| inst.exec_clean } run_hook 'post-clean' end def exec_distclean rm_f @config.savefile run_hook 'pre-distclean' each_selected_installers {|inst| inst.exec_distclean } run_hook 'post-distclean' end # # lib # def each_selected_installers Dir.mkdir 'packages' unless File.dir?('packages') @selected.each do |pack| $stderr.puts "Processing the package `#{pack}' ..." if verbose? Dir.mkdir "packages/#{pack}" unless File.dir?("packages/#{pack}") Dir.chdir "packages/#{pack}" yield @installers[pack] Dir.chdir '../..' end end def run_hook(id) @root_installer.run_hook id end # module FileOperations requires this def verbose? @config.verbose? end # module FileOperations requires this def no_harm? @config.no_harm? end end # class ToplevelInstallerMulti class Installer FILETYPES = %w( bin lib ext data conf man ) include FileOperations include HookScriptAPI def initialize(config, srcroot, objroot) @config = config @srcdir = File.expand_path(srcroot) @objdir = File.expand_path(objroot) @currdir = '.' end def inspect "#<#{self.class} #{File.basename(@srcdir)}>" end def noop(rel) end # # Hook Script API base methods # def srcdir_root @srcdir end def objdir_root @objdir end def relpath @currdir end # # Config Access # # module FileOperations requires this def verbose? @config.verbose? end # module FileOperations requires this def no_harm? @config.no_harm? end def verbose_off begin save, @config.verbose = @config.verbose?, false yield ensure @config.verbose = save end end # # TASK config # def exec_config exec_task_traverse 'config' end alias config_dir_bin noop alias config_dir_lib noop def config_dir_ext(rel) extconf if extdir?(curr_srcdir()) end alias config_dir_data noop alias config_dir_conf noop alias config_dir_man noop def extconf ruby "#{curr_srcdir()}/extconf.rb", *@config.config_opt end # # TASK setup # def exec_setup exec_task_traverse 'setup' end def setup_dir_bin(rel) files_of(curr_srcdir()).each do |fname| update_shebang_line "#{curr_srcdir()}/#{fname}" end end alias setup_dir_lib noop def setup_dir_ext(rel) make if extdir?(curr_srcdir()) end alias setup_dir_data noop alias setup_dir_conf noop alias setup_dir_man noop def update_shebang_line(path) return if no_harm? return if config('shebang') == 'never' old = Shebang.load(path) if old $stderr.puts "warning: #{path}: Shebang line includes too many args. It is not portable and your program may not work." if old.args.size > 1 new = new_shebang(old) return if new.to_s == old.to_s else return unless config('shebang') == 'all' new = Shebang.new(config('rubypath')) end $stderr.puts "updating shebang: #{File.basename(path)}" if verbose? open_atomic_writer(path) {|output| File.open(path, 'rb') {|f| f.gets if old # discard output.puts new.to_s output.print f.read } } end def new_shebang(old) if /\Aruby/ =~ File.basename(old.cmd) Shebang.new(config('rubypath'), old.args) elsif File.basename(old.cmd) == 'env' and old.args.first == 'ruby' Shebang.new(config('rubypath'), old.args[1..-1]) else return old unless config('shebang') == 'all' Shebang.new(config('rubypath')) end end def open_atomic_writer(path, &block) tmpfile = File.basename(path) + '.tmp' begin File.open(tmpfile, 'wb', &block) File.rename tmpfile, File.basename(path) ensure File.unlink tmpfile if File.exist?(tmpfile) end end class Shebang def Shebang.load(path) line = nil File.open(path) {|f| line = f.gets } return nil unless /\A#!/ =~ line parse(line) end def Shebang.parse(line) cmd, *args = *line.strip.sub(/\A\#!/, '').split(' ') new(cmd, args) end def initialize(cmd, args = []) @cmd = cmd @args = args end attr_reader :cmd attr_reader :args def to_s "#! #{@cmd}" + (@args.empty? ? '' : " #{@args.join(' ')}") end end # # TASK install # def exec_install rm_f 'InstalledFiles' exec_task_traverse 'install' end def install_dir_bin(rel) install_files targetfiles(), "#{config('bindir')}/#{rel}", 0755 end def install_dir_lib(rel) install_files libfiles(), "#{config('rbdir')}/#{rel}", 0644 end def install_dir_ext(rel) return unless extdir?(curr_srcdir()) install_files rubyextentions('.'), "#{config('sodir')}/#{File.dirname(rel)}", 0555 end def install_dir_data(rel) install_files targetfiles(), "#{config('datadir')}/#{rel}", 0644 end def install_dir_conf(rel) # FIXME: should not remove current config files # (rename previous file to .old/.org) install_files targetfiles(), "#{config('sysconfdir')}/#{rel}", 0644 end def install_dir_man(rel) install_files targetfiles(), "#{config('mandir')}/#{rel}", 0644 end def install_files(list, dest, mode) mkdir_p dest, @config.install_prefix list.each do |fname| install fname, dest, mode, @config.install_prefix end end def libfiles glob_reject(%w(*.y *.output), targetfiles()) end def rubyextentions(dir) ents = glob_select("*.#{@config.dllext}", targetfiles()) if ents.empty? setup_rb_error "no ruby extention exists: 'ruby #{$0} setup' first" end ents end def targetfiles mapdir(existfiles() - hookfiles()) end def mapdir(ents) ents.map {|ent| if File.exist?(ent) then ent # objdir else "#{curr_srcdir()}/#{ent}" # srcdir end } end # picked up many entries from cvs-1.11.1/src/ignore.c JUNK_FILES = %w( core RCSLOG tags TAGS .make.state .nse_depinfo #* .#* cvslog.* ,* .del-* *.olb *~ *.old *.bak *.BAK *.orig *.rej _$* *$ *.org *.in .* ) def existfiles glob_reject(JUNK_FILES, (files_of(curr_srcdir()) | files_of('.'))) end def hookfiles %w( pre-%s post-%s pre-%s.rb post-%s.rb ).map {|fmt| %w( config setup install clean ).map {|t| sprintf(fmt, t) } }.flatten end def glob_select(pat, ents) re = globs2re([pat]) ents.select {|ent| re =~ ent } end def glob_reject(pats, ents) re = globs2re(pats) ents.reject {|ent| re =~ ent } end GLOB2REGEX = { '.' => '\.', '$' => '\$', '#' => '\#', '*' => '.*' } def globs2re(pats) /\A(?:#{ pats.map {|pat| pat.gsub(/[\.\$\#\*]/) {|ch| GLOB2REGEX[ch] } }.join('|') })\z/ end # # TASK test # TESTDIR = 'test' def exec_test unless File.directory?('test') $stderr.puts 'no test in this package' if verbose? return end $stderr.puts 'Running tests...' if verbose? begin require 'test/unit' rescue LoadError setup_rb_error 'test/unit cannot loaded. You need Ruby 1.8 or later to invoke this task.' end runner = Test::Unit::AutoRunner.new(true) runner.to_run << TESTDIR runner.run end # # TASK clean # def exec_clean exec_task_traverse 'clean' rm_f @config.savefile rm_f 'InstalledFiles' end alias clean_dir_bin noop alias clean_dir_lib noop alias clean_dir_data noop alias clean_dir_conf noop alias clean_dir_man noop def clean_dir_ext(rel) return unless extdir?(curr_srcdir()) make 'clean' if File.file?('Makefile') end # # TASK distclean # def exec_distclean exec_task_traverse 'distclean' rm_f @config.savefile rm_f 'InstalledFiles' end alias distclean_dir_bin noop alias distclean_dir_lib noop def distclean_dir_ext(rel) return unless extdir?(curr_srcdir()) make 'distclean' if File.file?('Makefile') end alias distclean_dir_data noop alias distclean_dir_conf noop alias distclean_dir_man noop # # Traversing # def exec_task_traverse(task) run_hook "pre-#{task}" FILETYPES.each do |type| if type == 'ext' and config('without-ext') == 'yes' $stderr.puts 'skipping ext/* by user option' if verbose? next end traverse task, type, "#{task}_dir_#{type}" end run_hook "post-#{task}" end def traverse(task, rel, mid) dive_into(rel) { run_hook "pre-#{task}" __send__ mid, rel.sub(%r[\A.*?(?:/|\z)], '') directories_of(curr_srcdir()).each do |d| traverse task, "#{rel}/#{d}", mid end run_hook "post-#{task}" } end def dive_into(rel) return unless File.dir?("#{@srcdir}/#{rel}") dir = File.basename(rel) Dir.mkdir dir unless File.dir?(dir) prevdir = Dir.pwd Dir.chdir dir $stderr.puts '---> ' + rel if verbose? @currdir = rel yield Dir.chdir prevdir $stderr.puts '<--- ' + rel if verbose? @currdir = File.dirname(rel) end def run_hook(id) path = [ "#{curr_srcdir()}/#{id}", "#{curr_srcdir()}/#{id}.rb" ].detect {|cand| File.file?(cand) } return unless path begin instance_eval File.read(path), path, 1 rescue raise if $DEBUG setup_rb_error "hook #{path} failed:\n" + $!.message end end end # class Installer class SetupError < StandardError; end def setup_rb_error(msg) raise SetupError, msg end if $0 == __FILE__ begin ToplevelInstaller.invoke rescue SetupError raise if $DEBUG $stderr.puts $!.message $stderr.puts "Try 'ruby #{$0} --help' for detailed usage." exit 1 end end evernote-mode-0_41/doc/0000775000175000017500000000000011601107152014665 5ustar uwabamiuwabamievernote-mode-0_41/doc/readme_en.txt0000664000175000017500000005304611600732624017364 0ustar uwabamiuwabami Emacs evernote mode =================== Author: Yusuke Kawakami Date: 2011-06-24 06:49:58 JST Table of Contents ================= 1 License 2 Introduction 3 Evernote note edit mode 3.1 XHTML mode 3.1.1 An example of XHTML mode editing: 3.2 TEXT mode 3.2.1 An example of TEXT mode editing: 3.3 Select edit mode 3.4 Change edit mode 4 Search Query Examples 5 Evernote Browser 6 Bookmarks 7 Install and Settings 8 Collaboration with Anything 9 Troubleshooting 9.1 `require': no such file to load -- gdbm 9.2 `require': no such file to load -- net/https 9.3 No such file or directory -- enclient.rb (LoadError) 1 QUOTE License ~~~~~~~~~~~~~~~~ Copyright 2011 Yusuke Kawakami Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 2 Introduction ~~~~~~~~~~~~~~~ Emacs evernote mode offers functions to refer and edit Evernote notes directly from Emacs. Currently this package offers the following interfaces. - *Command: evernote-login* Login to Evernote. The following commands are available only when you login. If you execute the following commands without the login, the login prompt will be shown. - *Variable: evernote-username* An username of your evernote. - *Command: evernote-open-note* Read an existing note to an Emacs buffer. At first, input tags of the notes, then input the name of the note on the minibuffer. - *Command: evernote-open-note-in-notebook* Read an existing note to an Emacs buffer. At first, input the notebook and tags of the notes, then input the name of the note on the minibuffer. - *Command: evernote-save-note (default bound to \C-x\C-s)* Save the modified note.. - *Command: evernote-create-note* Create a note from scratch. The note is created in the default notebook. - *Command: evernote-create-note-in-notebook* Create a note from scratch. The note is created in the specified notebook. - *Command: evernote-write-note* Create a new note from the current buffer. The note is created in the default notebook. - *Command: evernote-write-note-in-notebook* Create a new note from the current buffer. The note is created in the specified notebook. - *Command: evernote-post-region* Create a new note containing the selected region. The note is created in the default notebook. If you call this command without argument, no buffer associated with the new note is generated, which is different from evernote-open-note and evernote-create-note. If you call this command with an argument by \C-u etc.(not default argument), it creates a new buffer associated with the new note and you can edit the note in the buffer. - *Command: evernote-post-region-in-notebook* Create a new note containing the selected region. The note is created in the specified notebook. - *Command: evernote-change-notebook (default bound to \C-cen)* Change the notebook to which the note belongs. The change on Evernote service will be made after exec of evernote-save-note. - *Command: evernote-edit-tags (default bound to \C-cet)* Change tags attached to the note. The change on Evernote service will be made after exec of evernote-save-note. - *Command: evernote-change-edit-mode (default bound to \C-cee)* Change the edit mode of the note. (See [Evernote note edit mode] for details) The change on Evernote service will be made after exec of evernote-save-note. - *Command: evernote-rename-note (default bound to \C-cer)* Rename the note. The change on Evernote service will be made after exec of evernote-save-note. - *Command: evernote-delete-note (default bound to \C-ced)* Delete the note. - *Command: evernote-search-notes* Search notes by query in the minibuffer. (See [Search Query Examples] for details) - *Command: evernote-do-saved-search* Search notes by using a Saved Search. - *Command: evernote-create-notebook* Create a new notebook. - *Command: evernote-edit-notebook* Change the name and whether this book is the default notebook or not. - *Command: evernote-create-search* Save a query with a name for later use. - *Command: evernote-edit-search* Change the name and the query of an existing Saved Search. - *Command: evernote-toggle-read-only (default bound to \C-x\C-q)* Toggle read-only status of the note. When a note of XHTML mode is changed to the read-only status, the command in the variable evernote-enml-formatter-command formats the XHTML. See [Evernote note edit mode] for details. - *Variable: evernote-enml-formatter-command* The command to format XHTML. When a note of XHTML mode is read-only, the command formats the XHTML and displays it. Currently evernote-mode supports w3m as the formatter. - *Command: evernote-browser* Open Evernote Browser. Evernote Browser offers the features to open notes from the tag hierarchical list, the saved search list and the note list of the past search result. See [Evernote Browser] for details. - *Variable: anything-c-source-evernote-title* The variable that offers the function for Anything([http://www.emacswiki.org/emacs/Anything]) to display the note candidates from the title. See [Collaboration with Anything] for details. - *Command: anything-evernote-title* Open a note by using Anything. See [Collaboration with Anything] for details. - *Variable: evernote-mode-display-menu* Display the menu on the menubar for evernote-mode (default: t) - *Variable: evernote-password-cache* Non-nil means that password cache is enabled. It is recommended to encrypt the file with EasyPG([http://epg.sourceforge.jp/]). EasyPG is included in Emacs 23 or later. On Emacs 22, you install the EasyPG, then add the following line to your .emacs (require 'epa-setup) You can cache the password safely by using gpg-agent. When you create a note by evernote-create-note, evernote-write-note and evernote-post-region, you can attach tags to the note. Also, when using the commands, you can input the name and the tag of the note with completion in the minibuffer. The minor-mode "evernote-mode" is applied to the buffers opening the evernote note. The following commands are available only when "evernote-mode" is valid. - evernote-save-note - evernote-change-notebook - evernote-edit-tags - evernote-change-edit-mode - evernote-rename-note - evernote-delete-note [Evernote note edit mode]: sec-3 [Search Query Examples]: sec-4 [Evernote note edit mode]: sec-3 [Evernote Browser]: sec-5 [Collaboration with Anything]: sec-8 [Collaboration with Anything]: sec-8 3 Evernote note edit mode ~~~~~~~~~~~~~~~~~~~~~~~~~~ Evernote notes are XML complying with ENML DTD([http://xml.evernote.com/pub/enml2.dtd]). evernote-mode offers the two edit mode, XHTML mode and TEXT mode for saving and reading the Evenote notes. 3.1 XHTML mode =============== When you save the Evernote note in XHTML mode, the content of the buffer will be saved as the content of the note. Therefore if the contents of the buffer is not valid ENML, you cannot save the contents because of the error. And when you read a Evernote note by using XHTML mode, the buffer is read-only as the initial state. If the variable evernote-enml-formatter-command is set, the content of the buffer is formatted. (See [Install and Settings] for details of setting evernote-enml-formatter-command) If you toggle the read-only status and change it to read-write, unformatted XHTML is displayed in the buffer. The buffer will display the formatted text if you change the state to read-only again. [Install and Settings]: sec-7 3.1.1 QUOTE An example of XHTML mode editing: ---------------------------------------------- Emacs Buffer ----------------------------------- Evernote notes are XML complying with ENML DTD
evernote-mode offers the two edit mode, XHTML mode and TEXT mode for
saving and reading the Evenote notes.
----------------------------------- save on XHTML mode V The content of the note (same as the emacs buffer) ----------------------------------- Evernote notes are XML complying with ENML DTD
evernote-mode offers the two edit mode, XHTML mode and TEXT mode for
saving and reading the Evenote notes.
----------------------------------- read on XHTML mode V Emacs Buffer (read-only and formatted) ----------------------------------- Evernote notes are XML complying with ENML DTD evernote-mode offers the two edit mode, XHTML mode and TEXT mode for saving and reading the Evenote notes. ----------------------------------- toggle read-only(evernote-toggle-read-only: \C-x\C-q) V Emacs Buffer (unformatted) ----------------------------------- Evernote notes are XML complying with ENML DTD
evernote-mode offers the two edit mode, XHTML mode and TEXT mode for
saving and reading the Evenote notes.
----------------------------------- 3.2 TEXT mode ============== In XHTML mode, you have to edit a XHTML as a text but it is a complicated work. evernote-mode offers TEXT mode to make editing text notes easy and effective. The text mode is specialized in editing Evernote notes that only contain text content. When you save an Evernote note, special characters(&keyword; space, newline) in the buffer are escaped and the root element is added to transform it into a XML document. Therefore text contents in the Emacs buffer is same as the appearance of the note. (is not same as the actual XML content of the note.) And when you read a Evernote note by using TEXT mode, evernote-mode reads the contents under the root element of the XML as a text and all the special characters are unescaped then evernote-mode insert it to the buffer. 3.2.1 QUOTE An example of TEXT mode editing: --------------------------------------------- Emacs Buffer ----------------------------------- Evernote notes are XML complying with ENML DTD evernote-mode offers the two edit mode, XHTML mode and TEXT mode for saving and reading the Evenote notes. ----------------------------------- save on TEXT mode V The content of the note (escaped and transformed into a XML) ----------------------------------- Evernote notes are XML complying with ENML DTD
evernote-mode offers the two edit mode, XHTML mode and TEXT mode for
saving and reading the Evenote notes.
----------------------------------- read on TEXT mode V Emacs Buffer (unescaped and transformed int a text) ----------------------------------- Evernote notes are XML complying with ENML DTD evernote-mode offers the two edit mode, XHTML mode and TEXT mode for saving and reading the Evenote notes. ----------------------------------- 3.3 Select edit mode ===================== You can select the edit mode when you create a note. The edit mode is recorded in the note when you save it, and the recorded edit mode is applied to the note when you reopen it. 3.4 Change edit mode ===================== Use the command evernote-change-edit-mode to change the edit mode of the existing note. If you change the edit mode from XHTML mode to TEXT mode and the buffer is read-only, then the content of the TEXT mode is the formatted text. Note that the change will remove all format information(xml tags). If the buffer is read-write, the content of the TEXT mode is the original unformatted text. 4 Search Query Examples ~~~~~~~~~~~~~~~~~~~~~~~~ Here are examples of queries used for searching notes. The following examples are referred from ([http://www.evernote.com/about/developer/api/evernote-api.htm#\_Toc277181479]). * Find notes containing the word "chicken", tagged with "cooking", and created this year: chicken tag:cooking created:year * Find notes tagged with "cooking" but not "mexican" that include the word "beef" but not the word "carrots" tag:cooking -tag:mexican beef -carrots * Find notes in my "Travel" notebook with San Francisco in the title: notebook:Travel intitle:"San Francisco" * Find notes that either include the text "San Francisco" or are tagged with the "SFO" tag: any: "San Francisco" tag:SFO [http://www.evernote.com/about/developer/api/evernote-api.htm#\_Toc277181479]: http://www.evernote.com/about/developer/api/evernote-api.htm#_Toc277181479 5 Evernote Browser ~~~~~~~~~~~~~~~~~~~ Evernote Browser offers the features to open notes from the tag hierarchical list, the saved search list, and the note list of the past search result. These lists are different from the completion lists of evernote-open-note command or the evernote-search-notes command. These lists of Evernote Browser are always kept in Emacs buffers until they are deleted by the user after they were created, and they make the procedure to open notes easy by using these list repeatedly. Evernote Browser is composed of multiple Evernote Browser pages(emacs buffers). An Evernote Browser page is created when searching notes or when executing the evernote-browser command at the state that no search has been executed. The multiple pages are managed as the page list. There is one valid current page and each page has the next/previous page. Execute the evernote-browser command to move the cursor to the current Evernote Browser page. Also, use the keys for moving to the next/previous page key (described later) to move to another page. There are three type of Evernote Browser page * tag list page * saved search list page * note list page * notebook list page A tag list page shows the hierarchical tag list created on Evernote service. Pressing Enter(\C-m) on the tag name opens a note list page of the tag. A saved search list shows the search list created on Evernote service. Pressing Enter(\C-m) on the search name opens a note list page from the search result. A note list shows the note list from a note search result. The note list page is newly created by the evenote-open-note command, the evernote-search-notes command and by searches on Evernote Browser. Pressing Enter(\C-m) on the note name opens a note. A notebook list page shows the notebook list created on Evernote service. Pressing Enter(\C-m) on the notebook name opens a note list page associated with the notebook. The followings are other key assignments on Evernote Browser pages Key Action -----+-------------------------------------------------------------------------------------------------------------- b move to the previous page f move to the next page t create a tag list page and show it. If a tag list page already exists, move the cursor to the page S create a search list page and show it. If a tag list page already exists, move the cursor to the page s create a note list from the search query input and show it N create a notebook list page and show it. If a notebook list page already exists, move the cursor to the page o same as Enter(\C-m), but it does not move the cursor to the opened note n move to the next line and open the note on the cursor if in the note list, p move to the previous line and open the note on the cursor if in the note list, d delete the current from Evernote Browser 6 Bookmarks ~~~~~~~~~~~~ On Emacs 23.1 or later, you can set emacs bookmarks to the evernote notes. You can open immediately the note that you can refer frequently by using this feature. You can use the bookmarks in the same way as when using bookmarks to regular files. You can set a bookmark to a evernote note by executing 'bookmark-set' (C-x r m RET) in the buffer opening the evernote note. Also, you can refer the bookmarks 'bookmark-jump' (C-x r b bookmark RET) or 'list-bookmark' (C-x r l). 7 Install and Settings ~~~~~~~~~~~~~~~~~~~~~~~ 1. Install ruby scripts for using Evernote service. cd evernote-mode/ruby ruby setup.rb 2. Copy evernote-mode.el to your load path. cp evernote-mode.el 3. Get w3m for evernote-enml-formatter-command (Optional) - If you use Linux/Unix, get w3m from [here] and install it or install w3m from the package of your distribution. - If you use Win, get cygwin from [here], execute setup.exe and select w3m from the "Select Packages" - Add the path of w3m to the environment variable "PATH". 4. Add the evernote-mode configuration to .emacs. (add-to-list 'load-path "") (require 'evernote-mode) (setq evernote-username "") ; optional: you can use this username as default. (setq evernote-enml-formatter-command '("w3m" "-dump" "-I" "UTF8" "-O" "UTF8")) ; option (global-set-key "\C-cec" 'evernote-create-note) (global-set-key "\C-ceo" 'evernote-open-note) (global-set-key "\C-ces" 'evernote-search-notes) (global-set-key "\C-ceS" 'evernote-do-saved-search) (global-set-key "\C-cew" 'evernote-write-note) (global-set-key "\C-cep" 'evernote-post-region) (global-set-key "\C-ceb" 'evernote-browser) If you don't set evernote-enml-formatter-command, the unformatted XHTML is displayed when reading the note of XHTML mode. If you use cygwin for ruby, cygwin-mount.el ([http://www.emacswiki.org/cgi-bin/wiki/cygwin-mount.el]) is also needed. Get cygwin-mount.el and put it in your load path, and add the followings lines to your .emacs. (require 'cygwin-mount) (cygwin-mount-activate) 5. Proxy settings If you want to use the proxy, set the value to the environment variable 'EN\_PROXY' written as 'host:port' format. (ex. export EN\_PROXY=proxy.hoge.com:8080) [here]: http://w3m.sourceforge.net/index.en.html [here]: http://www.cygwin.com/ 8 Collaboration with Anything ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ evernote-mode offers the function for Anything([http://www.emacswiki.org/emacs/Anything]) to display the note candidates from the title. You can add the evernote note titles to the source of candidates of Anything by adding the following configuration to your .emacs. (add-to-list 'anything-sources anything-c-source-evernote-title) You can also use 'anything-evernote-title' to choose the candidates only from the evernote notes. The above features for Anything are available only when you login the evernote service (after executing evernote-login or the first time you use the command evernote-xxx). 9 Troubleshooting ~~~~~~~~~~~~~~~~~~ 9.1 `require': no such file to load -- gdbm ============================================ Some distributions do not have the GDBM library for ruby. Install libgdbm-ruby for using GDBM. - ex. for apt, apt-get install libgdbm-ruby - In the case of ActiveScriptRuby or Ruby-mswin32 Retrieve gdbm.dll from [Porting Libraries to Win32], then copy it to the folder where ruby.exe exists. - In the case of Mac OS X The pre-installed ruby on Mac OS X does not contain GDBM bindings. Re-install ruby and GDBM by [MacPorts] or [Homebrew]. MacPorts: $ sudo ports install ruby gdbm Homebrew: $ sudo brew install ruby gdbm Also, [specify evernote-ruby-command]. [Porting Libraries to Win32]: http://jarp.does.notwork.org/win32/ [MacPorts]: http://www.macports.org/ [Homebrew]: http://mxcl.github.com/homebrew/ [specify evernote-ruby-command]: sec-9.3 9.2 `require': no such file to load -- net/https ================================================= Some distributions do not have the openssl library for ruby. Install libopenssl-ruby for using https. - ex. for apt, apt-get install libopenssl-ruby 9.3 No such file or directory -- enclient.rb (LoadError) ========================================================= When multiple version of ruby are installed in the OS, the evernote-mode may use another ruby that has installed the evernote-mode (The ruby that has executed 'ruby setup.rb'). Specify the full path of ruby to the evernote-ruby-command, before load the evernote-mode. e.g. (setq evernote-ruby-command "/your/path/to/ruby") (require 'evernote-mode) evernote-mode-0_41/doc/readme_en.org0000664000175000017500000005176511600732624017342 0ustar uwabamiuwabami#+TITLE: Emacs evernote mode #+AUTHOR: Yusuke Kawakami #+EMAIL: Yusuke Kawakami #+OPTIONS: email:nil #+ATTR_HTML: border="2" rules="all" frame="all" # <> * QUOTE License Copyright 2011 Yusuke Kawakami Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. # <> * Introduction Emacs evernote mode offers functions to refer and edit Evernote notes directly from Emacs. Currently this package offers the following interfaces. - *Command: evernote-login* Login to Evernote. The following commands are available only when you login. If you execute the following commands without the login, the login prompt will be shown. - *Variable: evernote-username* An username of your evernote. - *Command: evernote-open-note* Read an existing note to an Emacs buffer. At first, input tags of the notes, then input the name of the note on the minibuffer. - *Command: evernote-open-note-in-notebook* Read an existing note to an Emacs buffer. At first, input the notebook and tags of the notes, then input the name of the note on the minibuffer. - *Command: evernote-save-note (default bound to \C-x\C-s)* Save the modified note.. - *Command: evernote-create-note* Create a note from scratch. The note is created in the default notebook. - *Command: evernote-create-note-in-notebook* Create a note from scratch. The note is created in the specified notebook. - *Command: evernote-write-note* Create a new note from the current buffer. The note is created in the default notebook. - *Command: evernote-write-note-in-notebook* Create a new note from the current buffer. The note is created in the specified notebook. - *Command: evernote-post-region* Create a new note containing the selected region. The note is created in the default notebook. If you call this command without argument, no buffer associated with the new note is generated, which is different from evernote-open-note and evernote-create-note. If you call this command with an argument by \C-u etc.(not default argument), it creates a new buffer associated with the new note and you can edit the note in the buffer. - *Command: evernote-post-region-in-notebook* Create a new note containing the selected region. The note is created in the specified notebook. - *Command: evernote-change-notebook (default bound to \C-cen)* Change the notebook to which the note belongs. The change on Evernote service will be made after exec of evernote-save-note. - *Command: evernote-edit-tags (default bound to \C-cet)* Change tags attached to the note. The change on Evernote service will be made after exec of evernote-save-note. - *Command: evernote-change-edit-mode (default bound to \C-cee)* Change the edit mode of the note. (See [[Evernote note edit mode]] for details) The change on Evernote service will be made after exec of evernote-save-note. - *Command: evernote-rename-note (default bound to \C-cer)* Rename the note. The change on Evernote service will be made after exec of evernote-save-note. - *Command: evernote-delete-note (default bound to \C-ced)* Delete the note. - *Command: evernote-search-notes* Search notes by query in the minibuffer. (See [[Search Query Examples]] for details) - *Command: evernote-do-saved-search* Search notes by using a Saved Search. - *Command: evernote-create-notebook* Create a new notebook. - *Command: evernote-edit-notebook* Change the name and whether this book is the default notebook or not. - *Command: evernote-create-search* Save a query with a name for later use. - *Command: evernote-edit-search* Change the name and the query of an existing Saved Search. - *Command: evernote-toggle-read-only (default bound to \C-x\C-q)* Toggle read-only status of the note. When a note of XHTML mode is changed to the read-only status, the command in the variable evernote-enml-formatter-command formats the XHTML. See [[Evernote note edit mode]] for details. - *Variable: evernote-enml-formatter-command* The command to format XHTML. When a note of XHTML mode is read-only, the command formats the XHTML and displays it. Currently evernote-mode supports w3m as the formatter. - *Command: evernote-browser* Open Evernote Browser. Evernote Browser offers the features to open notes from the tag hierarchical list, the saved search list and the note list of the past search result. See [[Evernote Browser]] for details. - *Variable: anything-c-source-evernote-title* The variable that offers the function for Anything(http://www.emacswiki.org/emacs/Anything) to display the note candidates from the title. See [[Collaboration with Anything]] for details. - *Command: anything-evernote-title* Open a note by using Anything. See [[Collaboration with Anything]] for details. - *Variable: evernote-mode-display-menu* Display the menu on the menubar for evernote-mode (default: t) - *Variable: evernote-password-cache* Non-nil means that password cache is enabled. It is recommended to encrypt the file with EasyPG(http://epg.sourceforge.jp/). EasyPG is included in Emacs 23 or later. On Emacs 22, you install the EasyPG, then add the following line to your .emacs @
    (require 'epa-setup)
    @
You can cache the password safely by using gpg-agent. When you create a note by evernote-create-note, evernote-write-note and evernote-post-region, you can attach tags to the note. Also, when using the commands, you can input the name and the tag of the note with completion in the minibuffer. The minor-mode "evernote-mode" is applied to the buffers opening the evernote note. The following commands are available only when "evernote-mode" is valid. - evernote-save-note - evernote-change-notebook - evernote-edit-tags - evernote-change-edit-mode - evernote-rename-note - evernote-delete-note # <> * Evernote note edit mode Evernote notes are XML complying with ENML DTD(http://xml.evernote.com/pub/enml2.dtd). evernote-mode offers the two edit mode, XHTML mode and TEXT mode for saving and reading the Evenote notes. ** XHTML mode When you save the Evernote note in XHTML mode, the content of the buffer will be saved as the content of the note. Therefore if the contents of the buffer is not valid ENML, you cannot save the contents because of the error. And when you read a Evernote note by using XHTML mode, the buffer is read-only as the initial state. If the variable evernote-enml-formatter-command is set, the content of the buffer is formatted. (See [[Install and Settings]] for details of setting evernote-enml-formatter-command) If you toggle the read-only status and change it to read-write, unformatted XHTML is displayed in the buffer. The buffer will display the formatted text if you change the state to read-only again. *** QUOTE An example of XHTML mode editing: Emacs Buffer ----------------------------------- Evernote notes are XML complying with ENML DTD
evernote-mode offers the two edit mode, XHTML mode and TEXT mode for
saving and reading the Evenote notes.
----------------------------------- | | save on XHTML mode V The content of the note (same as the emacs buffer) ----------------------------------- Evernote notes are XML complying with ENML DTD
evernote-mode offers the two edit mode, XHTML mode and TEXT mode for
saving and reading the Evenote notes.
----------------------------------- | | read on XHTML mode V Emacs Buffer (read-only and formatted) ----------------------------------- Evernote notes are XML complying with ENML DTD evernote-mode offers the two edit mode, XHTML mode and TEXT mode for saving and reading the Evenote notes. ----------------------------------- | |toggle read-only(evernote-toggle-read-only: \C-x\C-q) V Emacs Buffer (unformatted) ----------------------------------- Evernote notes are XML complying with ENML DTD
evernote-mode offers the two edit mode, XHTML mode and TEXT mode for
saving and reading the Evenote notes.
----------------------------------- ** TEXT mode In XHTML mode, you have to edit a XHTML as a text but it is a complicated work. evernote-mode offers TEXT mode to make editing text notes easy and effective. The text mode is specialized in editing Evernote notes that only contain text content. When you save an Evernote note, special characters(&keyword; space, newline) in the buffer are escaped and the root element is added to transform it into a XML document. Therefore text contents in the Emacs buffer is same as the appearance of the note. (is not same as the actual XML content of the note.) And when you read a Evernote note by using TEXT mode, evernote-mode reads the contents under the root element of the XML as a text and all the special characters are unescaped then evernote-mode insert it to the buffer. *** QUOTE An example of TEXT mode editing: Emacs Buffer ----------------------------------- Evernote notes are XML complying with ENML DTD evernote-mode offers the two edit mode, XHTML mode and TEXT mode for saving and reading the Evenote notes. ----------------------------------- | | save on TEXT mode V The content of the note (escaped and transformed into a XML) ----------------------------------- Evernote notes are XML complying with ENML DTD
evernote-mode offers the two edit mode, XHTML mode and TEXT mode for
saving and reading the Evenote notes.
----------------------------------- | | read on TEXT mode V Emacs Buffer (unescaped and transformed int a text) ----------------------------------- Evernote notes are XML complying with ENML DTD evernote-mode offers the two edit mode, XHTML mode and TEXT mode for saving and reading the Evenote notes. ----------------------------------- ** Select edit mode You can select the edit mode when you create a note. The edit mode is recorded in the note when you save it, and the recorded edit mode is applied to the note when you reopen it. ** Change edit mode Use the command evernote-change-edit-mode to change the edit mode of the existing note. If you change the edit mode from XHTML mode to TEXT mode and the buffer is read-only, then the content of the TEXT mode is the formatted text. Note that the change will remove all format information(xml tags). If the buffer is read-write, the content of the TEXT mode is the original unformatted text. # <> * Search Query Examples Here are examples of queries used for searching notes. The following examples are referred from (http://www.evernote.com/about/developer/api/evernote-api.htm#_Toc277181479). * Find notes containing the word "chicken", tagged with "cooking", and created this year: chicken tag:cooking created:year * Find notes tagged with "cooking" but not "mexican" that include the word "beef" but not the word "carrots" tag:cooking -tag:mexican beef -carrots * Find notes in my "Travel" notebook with San Francisco in the title: notebook:Travel intitle:"San Francisco" * Find notes that either include the text "San Francisco" or are tagged with the "SFO" tag: any: "San Francisco" tag:SFO # <> * Evernote Browser Evernote Browser offers the features to open notes from the tag hierarchical list, the saved search list, and the note list of the past search result. These lists are different from the completion lists of evernote-open-note command or the evernote-search-notes command. These lists of Evernote Browser are always kept in Emacs buffers until they are deleted by the user after they were created, and they make the procedure to open notes easy by using these list repeatedly. Evernote Browser is composed of multiple Evernote Browser pages(emacs buffers). An Evernote Browser page is created when searching notes or when executing the evernote-browser command at the state that no search has been executed. The multiple pages are managed as the page list. There is one valid current page and each page has the next/previous page. Execute the evernote-browser command to move the cursor to the current Evernote Browser page. Also, use the keys for moving to the next/previous page key (described later) to move to another page. There are three type of Evernote Browser page * tag list page * saved search list page * note list page * notebook list page A tag list page shows the hierarchical tag list created on Evernote service. Pressing Enter(\C-m) on the tag name opens a note list page of the tag. A saved search list shows the search list created on Evernote service. Pressing Enter(\C-m) on the search name opens a note list page from the search result. A note list shows the note list from a note search result. The note list page is newly created by the evenote-open-note command, the evernote-search-notes command and by searches on Evernote Browser. Pressing Enter(\C-m) on the note name opens a note. A notebook list page shows the notebook list created on Evernote service. Pressing Enter(\C-m) on the notebook name opens a note list page associated with the notebook. The followings are other key assignments on Evernote Browser pages |-----+--------------------------------------------------------------------------------------------------------------| | Key | Action | |-----+--------------------------------------------------------------------------------------------------------------| | b | move to the previous page | | f | move to the next page | | t | create a tag list page and show it. If a tag list page already exists, move the cursor to the page | | S | create a search list page and show it. If a tag list page already exists, move the cursor to the page | | s | create a note list from the search query input and show it | | N | create a notebook list page and show it. If a notebook list page already exists, move the cursor to the page | | o | same as Enter(\C-m), but it does not move the cursor to the opened note | | n | move to the next line and open the note on the cursor if in the note list, | | p | move to the previous line and open the note on the cursor if in the note list, | | d | delete the current from Evernote Browser | |-----+--------------------------------------------------------------------------------------------------------------| # <> * Bookmarks On Emacs 23.1 or later, you can set emacs bookmarks to the evernote notes. You can open immediately the note that you can refer frequently by using this feature. You can use the bookmarks in the same way as when using bookmarks to regular files. You can set a bookmark to a evernote note by executing 'bookmark-set' (C-x r m RET) in the buffer opening the evernote note. Also, you can refer the bookmarks 'bookmark-jump' (C-x r b bookmark RET) or 'list-bookmark' (C-x r l). # <> * Install and Settings 1. Install ruby scripts for using Evernote service. @
    cd evernote-mode/ruby
    ruby setup.rb
    @
2. Copy evernote-mode.el to your load path. @
    cp evernote-mode.el 
    @
3. Get w3m for evernote-enml-formatter-command (Optional) - If you use Linux/Unix, get w3m from [[http://w3m.sourceforge.net/index.en.html][here]] and install it or install w3m from the package of your distribution. - If you use Win, get cygwin from [[http://www.cygwin.com/][here]], execute setup.exe and select w3m from the "Select Packages" - Add the path of w3m to the environment variable "PATH". 4. Add the evernote-mode configuration to .emacs. @
     (add-to-list 'load-path "")
     (require 'evernote-mode)
     (setq evernote-username "") ; optional: you can use this username as default.
     (setq evernote-enml-formatter-command '("w3m" "-dump" "-I" "UTF8" "-O" "UTF8")) ; option
     (global-set-key "\C-cec" 'evernote-create-note)
     (global-set-key "\C-ceo" 'evernote-open-note)
     (global-set-key "\C-ces" 'evernote-search-notes)
     (global-set-key "\C-ceS" 'evernote-do-saved-search)
     (global-set-key "\C-cew" 'evernote-write-note)
     (global-set-key "\C-cep" 'evernote-post-region)
     (global-set-key "\C-ceb" 'evernote-browser)
     @
If you don't set evernote-enml-formatter-command, the unformatted XHTML is displayed when reading the note of XHTML mode. If you use cygwin for ruby, cygwin-mount.el (http://www.emacswiki.org/cgi-bin/wiki/cygwin-mount.el) is also needed. Get cygwin-mount.el and put it in your load path, and add the followings lines to your .emacs. @
		 (require 'cygwin-mount)
		 (cygwin-mount-activate)
     @
5. Proxy settings If you want to use the proxy, set the value to the environment variable 'EN\_PROXY' written as 'host:port' format. (ex. export EN\_PROXY=proxy.hoge.com:8080) # <> * Collaboration with Anything evernote-mode offers the function for Anything(http://www.emacswiki.org/emacs/Anything) to display the note candidates from the title. You can add the evernote note titles to the source of candidates of Anything by adding the following configuration to your .emacs. @
(add-to-list 'anything-sources anything-c-source-evernote-title)
@
You can also use 'anything-evernote-title' to choose the candidates only from the evernote notes. The above features for Anything are available only when you login the evernote service (after executing evernote-login or the first time you use the command evernote-xxx). # <> * Troubleshooting ** `require': no such file to load -- gdbm Some distributions do not have the GDBM library for ruby. Install libgdbm-ruby for using GDBM. - ex. for apt, @
apt-get install libgdbm-ruby
@
- In the case of ActiveScriptRuby or Ruby-mswin32 Retrieve gdbm.dll from [[http://jarp.does.notwork.org/win32/][Porting Libraries to Win32]], then copy it to the folder where ruby.exe exists. - In the case of Mac OS X The pre-installed ruby on Mac OS X does not contain GDBM bindings. Re-install ruby and GDBM by [[http://www.macports.org/][MacPorts]] or [[http://mxcl.github.com/homebrew/][Homebrew]]. MacPorts: @
$ sudo ports install ruby gdbm
@
Homebrew: @
$ sudo brew install ruby gdbm
@
Also, [[No%20such%20file%20or%20directory][specify evernote-ruby-command]]. ** `require': no such file to load -- net/https Some distributions do not have the openssl library for ruby. Install libopenssl-ruby for using https. - ex. for apt, @
apt-get install libopenssl-ruby
@
** No such file or directory -- enclient.rb (LoadError) When multiple version of ruby are installed in the OS, the evernote-mode may use another ruby that has installed the evernote-mode (The ruby that has executed 'ruby setup.rb'). Specify the full path of ruby to the evernote-ruby-command, before load the evernote-mode. e.g. @
    (setq evernote-ruby-command "/your/path/to/ruby")
    (require 'evernote-mode)
    @
evernote-mode-0_41/doc/readme_ja.txt0000664000175000017500000006526611576770330017373 0ustar uwabamiuwabami Emacs evernote mode =================== Author: Yusuke Kawakami Date: 2011-06-18 09:23:25 JST Table of Contents ================= 1 License 2 Introduction 3 Evernote note edit mode 3.1 XHTML モード 3.1.1 XHTMLモードでの編集の例: 3.2 TEXTモード 3.2.1 TEXTモードでの編集の例: 3.3 モードの選択 3.4 モードの切り替え 4 Search Query Examples 5 Evernote Browser 6 Bookmarks 7 Install and Settings 8 Collaboration with Anything 9 Troubleshooting 9.1 `require': no such file to load -- gdbm と表示される 9.2 `require': no such file to load -- net/https と表示される 9.3 No such file or directory -- enclient.rb (LoadError) の様なメッセージが表示される 1 License ~~~~~~~~~~~~~~~~ Copyright 2011 Yusuke Kawakami Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 2 Introduction ~~~~~~~~~~~~~~~ Emacs evernote modeはEvernoteのノートをemacsから直接参照、編集するための機能を提供します。現在このパッケージでは以下のインターフェースを提供しています。 - *Command: evernote-login* evernote サービスにログインします。以下のコマンドはログイン時にのみ使用可能です。 ログインしていない状態で以下コマンドを実行した場合はログインプロンプトが表示されます。 - *Variable: evernote-username* evernote サービスのユーザ名を指定します。 - *Command: evernote-open-note* 既存のノートをemacsバッファに読み込みます。検索するタグをミニバッファで入力後、続いてノートの名前を入力します。 - *Command: evernote-open-note-in-notebook* 既存のノートをemacsバッファに読み込みます。検索するノートブックとタグをミニバッファで入力後、続いてノートの名前を入力します。 - *Command: evernote-save-note (default bound to \C-x\C-s)* 編集したノートをEvernoteサービス上で上書き保存します。 - *Command: evernote-create-note* ノートを新規作成します。ノートはデフォルトのノートブックに作成されます。 - *Command: evernote-create-note-in-notebook* ノートを新規作成します。ノートは指定されたノートブックに作成されます。 - *Command: evernote-write-note* emacsバッファを新規ノートとして保存します。ノートはデフォルトのノートブックに作成されます。 - *Command: evernote-write-note-in-notebook* emacsバッファを新規ノートとして保存します。ノートは指定されたノートブックに作成されます。 - *Command: evernote-post-region* 選択されたリージョンを新規ノートとしてポストします。ノートはデフォルトのノートブックに作成されます。引数なしで実行した場合は、evernote-open-noteやevernote-create-noteと異なり、新規ノートに対応するバッファは作成しませんが、\C-u等で引数を与えた場合(デフォルト引数以外を与えた場合)は、新規ノートに対応するバッファを作成し、引き続きバッファ上での編集作業を行うことができます。 - *Command: evernote-post-region-in-notebook* 選択されたリージョンを新規ノートとしてポストします。ノートは指定されたノートブックに作成されます。 - *Command: evernote-change-notebook (default bound to \C-cen)* ノートが属するノートブックを変更します。このコマンド発行後にevernote-save-noteを実行することでEvernoteサービス上で変更が反映されます. - *Command: evernote-edit-tags (default bound to \C-cet)* ノートに付加するタグを変更します。このコマンド発行後にevernote-save-noteを実行することでEvernoteサービス上で変更が反映されます. - *Command: evernote-change-edit-mode (default bound to \C-cee)* ノートの編集モードを変更します.詳細は [Evernote note edit mode] を参照して下さい.このコマンド発行後にevernote-save-noteを実行することでEvernoteサービス上で変更が反映されます. - *Command: evernote-rename-note (default bound to \C-cer)* ノートを名前を変更します。このコマンド発行後evernote-save-noteを実行することでEvernoteサービス上で変更が反映されます。 - *Command: evernote-delete-note (default bound to \C-ced)* ノートを削除します。 - *Command: evernote-search-notes* ミニバッファから入力されたクエリを使ってノートを検索します。クエリの例は [Search Query Examples] を参照して下さい。 - *Command: evernote-do-saved-search* Evernoteの「保存された検索」を使ってノートを検索します。 - *Command: evernote-create-notebook* ノートブックを新規作成します。 - *Command: evernote-edit-notebook* 指定されたノートブックの名前とデフォルトノートブックか否かを設定します。 - *Command: evernote-create-search* クエリに名前をつけて保存し、以後「保存された検索」として参照できるようにします。 - *Command: evernote-edit-search* 既存の「保存された検索」の名前とクエリを変更します。 - *Command: evernote-toggle-read-only (default bound to \C-x\C-q)* バッファに読み込まれたノートの読み込み専用,書込み可能状態を切り替えます。XHTMLモードのノートを読み込み専用にした場合、evernote-enml-formatter-command変数に設定されたコマンドを使ってXHTMLをフォーマットして表示します。詳細は [Evernote note edit mode] を参照して下さい - *Variable: evernote-enml-formatter-command* XHTMLモードのノートを読み込んだ際、もしくは書き込み可能から読み込み専用に状態を切り替えた場合に、XHTMLを整形して表示するためのコマンドを指定します。現在整形コマンドとしてw3mを使用することができます。 - *Command: evernote-browser* Evernote Browser を開きます。Evernote Browser はタグ一覧や、保れされた検索の一覧、過去に検索したノートの一覧からノートを開くための機能を提供します。詳細は[Evernote Browser] を参照して下さい。 - *Variable: anything-c-source-evernote-title* Anything([http://www.emacswiki.org/emacs/Anything]) からタイトルからノートの選択候補を表示する機能を提供する変数です。 詳細は [Collaboration with Anything] を参照して下さい。 - *Command: anything-evernote-title* Anything を使ってタイトルからノートを開きます。 - *Variable: evernote-mode-display-menu* 非 nil の場合に evernote-mode 用のメニューをメニューバー上に表示します。(デフォルト: t) - *Variable: evernote-password-cache* 非 nil の場合にパスワードのキャッシュを有効にします。 有効にする時は、EasyPG([http://epg.sourceforge.jp/])を使って暗号化することを推奨します。EasyPG は Emacs 23 以降には含まれています。Emacs 22 では EasyPG をインストールし、.emacs に以下を記述してください。 (require 'epa-setup) gpg-agent を使うことで安全にパスワードをキャッシュできます。 evernote-create-note,evernote-write-note,evernote-post-regionで新規ノートを作成する際にはノートに付加するタグを指定することができます. また、コマンド使用時にタグ・ノート名を入力する際にはミニバッファでの補完が行われます。 ノートを開いているバッファには evernote-modeマイナーモードが適用されます。以下のコマンドはevernote-modeマイナーモードでのみ有効です。 - evernote-save-note - evernote-change-notebook - evernote-edit-tags - evernote-change-edit-mode - evernote-rename-note - evernote-delete-note 3 Evernote note edit mode ~~~~~~~~~~~~~~~~~~~~~~~~~~ EvernoteのノートはENML DTD([http://xml.evernote.com/pub/enml2.dtd])に準拠するXML文書です。evernote-modeではこのXMLをemacsで保存、読み込みを行う為ににXHTMLモードとTEXTモード2種類の編集モードを用意しています。 3.1 XHTML モード ================= XHTMLモードでノートを保存した場合、バッファの内容がそのままノートの内容として保存されます。バッファ内容がENML DTDに沿ったフォーマットでない場合はエラーになります。 XHTMLモードでノートを読み込んだ場合、初期状態としてバッファは読み込み専用になります。この際、変数evernote-enml-formatter-commandが設定されている場合は、バッファには整形された内容が表示されます。(evernote-enml-formatter-comandの設定については [Install and Settings] を参照して下さい) evernote-toggle-read-onlyコマンドを実行して編集の為に書き込み可能にした場合は、整形されない状態のXMLが表示されます。書き込み可能から読み込み専用に再度変更すると、再びバッファには整形された内容が表示されます。 3.1.1 XHTMLモードでの編集の例: ------------------------------------- Emacs バッファ ----------------------------------- EvernoteのノートはENML DTDに準
拠するXML文書です。evernote-modeではこのXMLをemacsで扱うためにXHTMLモー
ドとTEXTモード2種類の編集モードを用意しています。
----------------------------------- | | XHTMLモードで保存 V Evernoteサービス上のノート(Emacsバッファの内容と同じ) ----------------------------------- EvernoteのノートはENML DTDに準
拠するXML文書です。evernote-modeではこのXMLをemacsで扱うためにXHTMLモー
ドとTEXTモード2種類の編集モードを用意しています。
----------------------------------- | | XHTMLモードで読み込み V Emacs バッファ (読み込み専用となり、整形されて表示される) ----------------------------------- EvernoteのノートはENML DTDに準 拠するXML文書です。evernote-modeではこのXMLをemacsで扱うためにXHTMLモー ドとTEXTモード2種類の編集モードを用意しています。 ----------------------------------- | | 書き込み可能状態にする(evernote-toggle-read-only: \C-x\C-q) V Emacs バッファ (整形されないXMLが表示される) ----------------------------------- EvernoteのノートはENML DTDに準
拠するXML文書です。evernote-modeではこのXMLをemacsで扱うためにXHTMLモー
ドとTEXTモード2種類の編集モードを用意しています。
----------------------------------- 3.2 TEXTモード =============== XHTMLモードでは、ノートを編集する際にXHTMLをテキストとして編集する必要があり、作業が煩雑になります。そこでevernote-modeではテキストのみ含むEvernoteノートを効率よく作成、編集するための TEXTモードを提供しています。 TEXTモードはテキストのみ含むEvernoteノートの編集に特化したモードです。TEXTモードでノートを保存した場合、バッファ中のXMLの特殊文字(&キーワード\;, スペース、改行)はエスケープされ、ルート要素を付加した上でENMLに変換されます。このため、emacsバッファで表示されている内容がノートの見た目上の内容として保存されます。また、TEXTモードでノートを読み込んだ場合は、XMLのルート要素直下をテキストとして解釈し、XMLの特殊文字はアンエスケープされた上でバッファに読み込まれます。 3.2.1 TEXTモードでの編集の例: ------------------------------------ Emacs バッファ ----------------------------------- EvernoteのノートはENML DTDに準 拠するXML文書です。evernote-modeではこのXMLをemacsで扱うためにXHTMLモー ドとTEXTモード2種類の編集モードを用意しています。 ----------------------------------- | | TEXTモードで保存 V Evernoteサービス上のノート (Emacsバッファの内容がエスケープされ, XMLに変換される) ----------------------------------- EvernoteのノートはENML DTDに準
拠するXML文書です。evernote-modeではこのXMLをemacsで扱うためにXHTMLモー
ドとTEXTモード2種類の編集モードを用意しています。
----------------------------------- | | TEXTモードで読み込み V Emacs バッファ (ノートのルート要素以下の内容がアンエスケープされる) ----------------------------------- EvernoteのノートはENML DTDに準 拠するXML文書です。evernote-modeではこのXMLをemacsで扱うためにXHTMLモー ドとTEXTモード2種類の編集モードを用意しています。 ----------------------------------- 3.3 モードの選択 ================= 上記XHTML, TEXTモードはノートの作成時に選択できます。ノート保存時には編集モード情報も保存され、次に読み込まれる際には保存時の編集モードで読み込まれます。また、他のEvernoteアプリケーションで作成されたノートはXHTMLモードとして読み込まれます。 3.4 モードの切り替え ===================== 既存のノートのXHTML,TEXTモードを切り替える場合は、evernote-change-edit-modeコマンドを使用します。XHTMLモードからTEXTモードの切り替えにおいて、バッファが読み込み専用状態の場合、整形された内容がTEXTモードでのノートの内容になります。この際元のXHTMLのフォーマット情報(XML tag)は全て失われるので注意して下さい。書き込み可能状態でモードを切り替えた場合は、整形されていない元のXHTMLがTEXTモード表示されるノートの内容になります。 4 Search Query Examples ~~~~~~~~~~~~~~~~~~~~~~~~ ノートの検索に使用できるクエリの例を示します。 以下の例は [http://www.evernote.com/about/developer/api/evernote-api.htm#_Toc277181479] からの引用です。 - 今年に作られたノートで、"chicken"を含み、かつ"cooking"タグが付加されたものを検索します: chicken tag:cooking created:year - "cooking"タグを含み、かつ"mexican"タグを含まないノートの中で、"beef"を含み"carrots"を含まないものを検索します: tag:cooking -tag:mexican beef -carrots - "Travel"ノートブック中のノートで、タイトルに"San Francisco"を含むものを検索します: notebook:Travel intitle:"San Francisco" - "San Francisco"と含むノート、もしくは"SFO"タグを付加されたノートを検索します: any: "San Francisco" tag:SFO 5 Evernote Browser ~~~~~~~~~~~~~~~~~~~ Evernote Browser はタグ一覧や、保存された検索の一覧、過去に検索したノートの一覧からノートを開くための機能を提供します。これらの一覧はevernote-open-noteコマンドやevernote-search-notesコマンドで補完に使われるノート一覧と異なり、ユーザにより削除されるまでバッファ上に保持されます。この一覧は繰り返し使用することができるため、ノートを開く手順を簡略化することができます。 Evernote Browserは複数のEvernote Browserページ(バッファ)から構成されます。Evernote Browserページは、ノートの検索を行った際、もしくは検索を一度も行っていない状態でevernote-browserコマンドを実行した際に作られます。ページはリストとして管理され、現在有効なカレントページと各ページ間に前後関係を持ちます。 Evernote Browser のカレントページに移動するにはevernote-browser コマンドを実行して下さい。また、ページの移動には後述するページ移動キーを使用して下さい。 各 Evernote Browser ページには以下の種類があります。 - タグ一覧ページ タグ一覧ページにはユーザがEvernoteサービス上で作成したタグ一覧が階層的に表示されます。タグ名の上で Enter(\C-m) を押すことで、そのタグが付加されたノートの一覧ページが開きます。 - 保存された検索一覧ページ 保存された検索一覧ページにはユーザがEvernoteサービス上で作成した「保存された検索」の一覧が表示されます。保存された検索の名前上でEnter(\C-m)を押すことで保存された検索を実行し、結果をノート一覧ページとして開きます。 - ノート一覧ページ ノート一覧ページは検索により取得したノートの一覧を表示します。ノート一覧ページは evernote-open-note コマンド、 evernote-search-notes コマンドや、Evernote Browser での検索が行われる度に新たに作成されます。ノート名上でEnter(\C-m)を押すことでノートを開きます。 - ノートブック一覧ページ ノートブック一覧ページにはユーザがEvernoteサービス上で作成したノートブックの一覧が表示されます。ノートブック名の上でEnter(\C-m)を押すことで、そのノートブックに属するノートの一覧ページが開きます。 Evernote Browser ページ上でのその他のキーアサインは以下の通りです。 キー 動作 ------+-------------------------------------------------------------------------------------------------------------- b 前のページに移動します f 次のページに移動します t タグ一覧ページを作成し、表示します。既にタグ一覧ページがある場合はそのページに移動します S 保存された検索一覧ページを作成し、表示します。既に保存された検索一覧ページがある場合はそのページに移動します s 入力された検索クエリから結果を新規ノート一覧ページとして作成し、そのページを表示します N ノートブック一覧ページを作成し、表示します。既にノートブック一覧ページがある場合はそのページに移動します o Enter(\C-m) と同じですが、ノート一覧ページの場合は、開いたノートにカーソルを移動しません n 次の行に移動します。ノート一覧ページの場合は移動したカーソル上のノートを開きます p 前の行に移動します。ノート一覧ページの場合は移動したカーソル上のノートを開きます d 現在のページを Evernote Browser から削除します 6 Bookmarks ~~~~~~~~~~~~ Emacs 23.1 以降を使用している場合、emacs のブックマークを evernote のノートに対して設定することができます。 この機能により頻繁に参照する evernote ノートをより容易に開くことができます。 ブックマークの使用方法は通常のファイルを扱う場合と同じです。 bookmark-set (C-x r m RET) をノートを開いているバッファで実行することでブックマークを登録します。 また、登録されたブックマークは bookmark-jump (C-x r b bookmark RET) や list-bookmark (C-x r l) で参照できます。 7 Install and Settings ~~~~~~~~~~~~~~~~~~~~~~~ 1. Evernoteサービス使用のために必要なRubyスクリプトをインストールする cd evernote-mode/ruby ruby setup.rb 2. evernote-mode.el をロードパスにコピーする cp evernote-mode.el 3. evernote-enml-formatter-command に使用するプログラム w3m の入手、設定 (オプション) - Linux/Unixの場合、w3m のパッケージを [こちら] から入手してインストールするか、各ディストリビューションのw3mパッケージをインストールして下さい。 - Windowsの場合、cygwin を [こちら] から入手し、setup.exe を実行してパッケージ選択画面(Select Packages)からw3mを選択してインストールして下さい。 - w3mが存在するパスを環境変数PATHに追加して下さい 4. evernote-mode設定を.emacs に追記 (add-to-list 'load-path "") (require 'evernote-mode) (setq evernote-username "") ; optional: you can use this username as default. (setq evernote-enml-formatter-command '("w3m" "-dump" "-I" "UTF8" "-O" "UTF8")) ; optional (global-set-key "\C-cec" 'evernote-create-note) (global-set-key "\C-ceo" 'evernote-open-note) (global-set-key "\C-ces" 'evernote-search-notes) (global-set-key "\C-ceS" 'evernote-do-saved-search) (global-set-key "\C-cew" 'evernote-write-note) (global-set-key "\C-cep" 'evernote-post-region) (global-set-key "\C-ceb" 'evernote-browser) evernote-enml-formatter-commandが設定されていない場合はXHTMLモードでの読み込み時に整形されてない状態のXMLが表示されます。 上記に加え、 ruby の cygwin を使用している場合は、cygwin-mount.el ([http://www.emacswiki.org/cgi-bin/wiki/cygwin-mount.el]) が必要になります。cygwin-mount.el を取得し、以下を .emacs に追加して下さい。 (require 'cygwin-mount) (cygwin-mount-activate) 5. proxy の設定 プロキシを使用する場合は環境変数EN\_PROXYに 'プロキシホスト':'ポート'を指定して下さい。(ex. export EN\_PROXY=proxy.hoge.com:8080) 8 Collaboration with Anything ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ evernote-mode は Anything([http://www.emacswiki.org/emacs/Anything]) で evernote のノート名から選択候補を表示する機能 (anything-c-source) を提供します。 .emacs に以下の設定を追記することで、anything の選択候補に evernote のノート名を加えます。 (add-to-list 'anything-sources anything-c-source-evernote-title) また、Anything を使って Evernote のノート名のみから選択を行いたい場合は、 anything-evernote-title を使用できます。 上記 Anything との協調機能は evernote にログインした状態でのみ (evernote-login, もしくは evernote-xxx コマンドを最初に実行した後) 使用することができます。 9 Troubleshooting ~~~~~~~~~~~~~~~~~~ 9.1 `require': no such file to load -- gdbm と表示される ========================================================= ディストリビューションの設定によっては ruby が使用できる GDBM ライブラリがインストールされてない場合があります。 上記が表示される場合は libgdbm-ruby 等をインストールして下さい。 - aptを使ったインストール例 apt-get install libgdbm-ruby - ActiveScriptRuby または Ruby-mswin32 の場合 [Porting Libraries to Win32] から gdbm.dll を入手し、ruby.exe と同じフォルダに置いて下さい。 - Mac OS X の場合 Mac OS X に付属の ruby には GDBM バインディングが含まれていません。 [MacPorts] や [Homebrew] で ruby と GDBM をインストールしてください。 MacPorts の場合 $ sudo ports install ruby gdbm Homebrew の場合 $ sudo brew install ruby gdbm また、[evernote-ruby-command を設定] してください。 9.2 `require': no such file to load -- net/https と表示される ============================================================== ディストリビューションの設定によっては ruby が使用できる openssl ライブラリがインストールされてない場合があります。 上記が表示される場合は libopenssl-ruby をインストールして下さい。 - aptを使ったインストール例 apt-get install libopenssl-ruby 9.3 No such file or directory -- enclient.rb (LoadError) の様なメッセージが表示される ====================================================================================== OS に複数のバージョンの ruby がインストールされている場合に、evernote-mode をインストールした ruby (ruby setup.rb を実行した ruby) と異なる ruby が使われている可能性があります。 evernote-mode をロードする前に、evernote-ruby-command に正しい ruby をフルパスで指定してください。 e.g. (setq evernote-ruby-command "/your/path/to/ruby") (require 'evernote-mode) evernote-mode-0_41/doc/readme_ja.org0000664000175000017500000006523711576770330017341 0ustar uwabamiuwabami#+TITLE: Emacs evernote mode #+AUTHOR: Yusuke Kawakami #+EMAIL: Yusuke Kawakami #+OPTIONS: email:nil #+ATTR_HTML: border="2" rules="all" frame="all" # <> * QUOTE License Copyright 2011 Yusuke Kawakami Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. # <> * Introduction Emacs evernote modeはEvernoteのノートをemacsから直接参照、編集するための機能を提供します。現在このパッケージでは以下のインターフェースを提供しています。 - *Command: evernote-login* evernote サービスにログインします。以下のコマンドはログイン時にのみ使用可能です。 ログインしていない状態で以下コマンドを実行した場合はログインプロンプトが表示されます。 - *Variable: evernote-username* evernote サービスのユーザ名を指定します。 - *Command: evernote-open-note* 既存のノートをemacsバッファに読み込みます。検索するタグをミニバッファで入力後、続いてノートの名前を入力します。 - *Command: evernote-open-note-in-notebook* 既存のノートをemacsバッファに読み込みます。検索するノートブックとタグをミニバッファで入力後、続いてノートの名前を入力します。 - *Command: evernote-save-note (default bound to \C-x\C-s)* 編集したノートをEvernoteサービス上で上書き保存します。 - *Command: evernote-create-note* ノートを新規作成します。ノートはデフォルトのノートブックに作成されます。 - *Command: evernote-create-note-in-notebook* ノートを新規作成します。ノートは指定されたノートブックに作成されます。 - *Command: evernote-write-note* emacsバッファを新規ノートとして保存します。ノートはデフォルトのノートブックに作成されます。 - *Command: evernote-write-note-in-notebook* emacsバッファを新規ノートとして保存します。ノートは指定されたノートブックに作成されます。 - *Command: evernote-post-region* 選択されたリージョンを新規ノートとしてポストします。ノートはデフォルトのノートブックに作成されます。引数なしで実行した場合は、evernote-open-noteやevernote-create-noteと異なり、新規ノートに対応するバッファは作成しませんが、\C-u等で引数を与えた場合(デフォルト引数以外を与えた場合)は、新規ノートに対応するバッファを作成し、引き続きバッファ上での編集作業を行うことができます。 - *Command: evernote-post-region-in-notebook* 選択されたリージョンを新規ノートとしてポストします。ノートは指定されたノートブックに作成されます。 - *Command: evernote-change-notebook (default bound to \C-cen)* ノートが属するノートブックを変更します。このコマンド発行後にevernote-save-noteを実行することでEvernoteサービス上で変更が反映されます. - *Command: evernote-edit-tags (default bound to \C-cet)* ノートに付加するタグを変更します。このコマンド発行後にevernote-save-noteを実行することでEvernoteサービス上で変更が反映されます. - *Command: evernote-change-edit-mode (default bound to \C-cee)* ノートの編集モードを変更します.詳細は [[Evernote note edit mode]] を参照して下さい.このコマンド発行後にevernote-save-noteを実行することでEvernoteサービス上で変更が反映されます. - *Command: evernote-rename-note (default bound to \C-cer)* ノートを名前を変更します。このコマンド発行後evernote-save-noteを実行することでEvernoteサービス上で変更が反映されます。 - *Command: evernote-delete-note (default bound to \C-ced)* ノートを削除します。 - *Command: evernote-search-notes* ミニバッファから入力されたクエリを使ってノートを検索します。クエリの例は [[Search Query Examples]] を参照して下さい。 - *Command: evernote-do-saved-search* Evernoteの「保存された検索」を使ってノートを検索します。 - *Command: evernote-create-notebook* ノートブックを新規作成します。 - *Command: evernote-edit-notebook* 指定されたノートブックの名前とデフォルトノートブックか否かを設定します。 - *Command: evernote-create-search* クエリに名前をつけて保存し、以後「保存された検索」として参照できるようにします。 - *Command: evernote-edit-search* 既存の「保存された検索」の名前とクエリを変更します。 - *Command: evernote-toggle-read-only (default bound to \C-x\C-q)* バッファに読み込まれたノートの読み込み専用,書込み可能状態を切り替えます。XHTMLモードのノートを読み込み専用にした場合、evernote-enml-formatter-command変数に設定されたコマンドを使ってXHTMLをフォーマットして表示します。詳細は [[Evernote note edit mode]] を参照して下さい - *Variable: evernote-enml-formatter-command* XHTMLモードのノートを読み込んだ際、もしくは書き込み可能から読み込み専用に状態を切り替えた場合に、XHTMLを整形して表示するためのコマンドを指定します。現在整形コマンドとしてw3mを使用することができます。 - *Command: evernote-browser* Evernote Browser を開きます。Evernote Browser はタグ一覧や、保れされた検索の一覧、過去に検索したノートの一覧からノートを開くための機能を提供します。詳細は[[Evernote Browser]] を参照して下さい。 - *Variable: anything-c-source-evernote-title* Anything(http://www.emacswiki.org/emacs/Anything) からタイトルからノートの選択候補を表示する機能を提供する変数です。 詳細は [[Collaboration with Anything]] を参照して下さい。 - *Command: anything-evernote-title* Anything を使ってタイトルからノートを開きます。 - *Variable: evernote-mode-display-menu* 非 nil の場合に evernote-mode 用のメニューをメニューバー上に表示します。(デフォルト: t) - *Variable: evernote-password-cache* 非 nil の場合にパスワードのキャッシュを有効にします。 有効にする時は、EasyPG(http://epg.sourceforge.jp/)を使って暗号化することを推奨します。EasyPG は Emacs 23 以降には含まれています。Emacs 22 では EasyPG をインストールし、.emacs に以下を記述してください。 @
    (require 'epa-setup)
    @
gpg-agent を使うことで安全にパスワードをキャッシュできます。 evernote-create-note,evernote-write-note,evernote-post-regionで新規ノートを作成する際にはノートに付加するタグを指定することができます. また、コマンド使用時にタグ・ノート名を入力する際にはミニバッファでの補完が行われます。 ノートを開いているバッファには evernote-modeマイナーモードが適用されます。以下のコマンドはevernote-modeマイナーモードでのみ有効です。 - evernote-save-note - evernote-change-notebook - evernote-edit-tags - evernote-change-edit-mode - evernote-rename-note - evernote-delete-note # <> * Evernote note edit mode EvernoteのノートはENML DTD(http://xml.evernote.com/pub/enml2.dtd)に準拠するXML文書です。evernote-modeではこのXMLをemacsで保存、読み込みを行う為ににXHTMLモードとTEXTモード2種類の編集モードを用意しています。 ** XHTML モード XHTMLモードでノートを保存した場合、バッファの内容がそのままノートの内容として保存されます。バッファ内容がENML DTDに沿ったフォーマットでない場合はエラーになります。 XHTMLモードでノートを読み込んだ場合、初期状態としてバッファは読み込み専用になります。この際、変数evernote-enml-formatter-commandが設定されている場合は、バッファには整形された内容が表示されます。(evernote-enml-formatter-comandの設定については [[Install and Settings]] を参照して下さい) evernote-toggle-read-onlyコマンドを実行して編集の為に書き込み可能にした場合は、整形されない状態のXMLが表示されます。書き込み可能から読み込み専用に再度変更すると、再びバッファには整形された内容が表示されます。 *** QUOTE XHTMLモードでの編集の例: Emacs バッファ ----------------------------------- EvernoteのノートはENML DTDに準
拠するXML文書です。evernote-modeではこのXMLをemacsで扱うためにXHTMLモー
ドとTEXTモード2種類の編集モードを用意しています。
----------------------------------- | |XHTMLモードで保存 V Evernoteサービス上のノート(Emacsバッファの内容と同じ) ----------------------------------- EvernoteのノートはENML DTDに準
拠するXML文書です。evernote-modeではこのXMLをemacsで扱うためにXHTMLモー
ドとTEXTモード2種類の編集モードを用意しています。
----------------------------------- | |XHTMLモードで読み込み V Emacs バッファ (読み込み専用となり、整形されて表示される) ----------------------------------- EvernoteのノートはENML DTDに準 拠するXML文書です。evernote-modeではこのXMLをemacsで扱うためにXHTMLモー ドとTEXTモード2種類の編集モードを用意しています。 ----------------------------------- | |書き込み可能状態にする(evernote-toggle-read-only: \C-x\C-q) V Emacs バッファ (整形されないXMLが表示される) ----------------------------------- EvernoteのノートはENML DTDに準
拠するXML文書です。evernote-modeではこのXMLをemacsで扱うためにXHTMLモー
ドとTEXTモード2種類の編集モードを用意しています。
----------------------------------- ** TEXTモード XHTMLモードでは、ノートを編集する際にXHTMLをテキストとして編集する必要があり、作業が煩雑になります。そこでevernote-modeではテキストのみ含むEvernoteノートを効率よく作成、編集するための TEXTモードを提供しています。 TEXTモードはテキストのみ含むEvernoteノートの編集に特化したモードです。TEXTモードでノートを保存した場合、バッファ中のXMLの特殊文字(&キーワード\;, スペース、改行)はエスケープされ、ルート要素を付加した上でENMLに変換されます。このため、emacsバッファで表示されている内容がノートの見た目上の内容として保存されます。また、TEXTモードでノートを読み込んだ場合は、XMLのルート要素直下をテキストとして解釈し、XMLの特殊文字はアンエスケープされた上でバッファに読み込まれます。 *** QUOTE TEXTモードでの編集の例: Emacs バッファ ----------------------------------- EvernoteのノートはENML DTDに準 拠するXML文書です。evernote-modeではこのXMLをemacsで扱うためにXHTMLモー ドとTEXTモード2種類の編集モードを用意しています。 ----------------------------------- | |TEXTモードで保存 V Evernoteサービス上のノート (Emacsバッファの内容がエスケープされ, XMLに変換される) ----------------------------------- EvernoteのノートはENML DTDに準
拠するXML文書です。evernote-modeではこのXMLをemacsで扱うためにXHTMLモー
ドとTEXTモード2種類の編集モードを用意しています。
----------------------------------- | |TEXTモードで読み込み V Emacs バッファ (ノートのルート要素以下の内容がアンエスケープされる) ----------------------------------- EvernoteのノートはENML DTDに準 拠するXML文書です。evernote-modeではこのXMLをemacsで扱うためにXHTMLモー ドとTEXTモード2種類の編集モードを用意しています。 ----------------------------------- ** モードの選択 上記XHTML, TEXTモードはノートの作成時に選択できます。ノート保存時には編集モード情報も保存され、次に読み込まれる際には保存時の編集モードで読み込まれます。また、他のEvernoteアプリケーションで作成されたノートはXHTMLモードとして読み込まれます。 ** モードの切り替え 既存のノートのXHTML,TEXTモードを切り替える場合は、evernote-change-edit-modeコマンドを使用します。XHTMLモードからTEXTモードの切り替えにおいて、バッファが読み込み専用状態の場合、整形された内容がTEXTモードでのノートの内容になります。この際元のXHTMLのフォーマット情報(XML tag)は全て失われるので注意して下さい。書き込み可能状態でモードを切り替えた場合は、整形されていない元のXHTMLがTEXTモード表示されるノートの内容になります。 # <> * Search Query Examples ノートの検索に使用できるクエリの例を示します。 以下の例は http://www.evernote.com/about/developer/api/evernote-api.htm#_Toc277181479 からの引用です。 - 今年に作られたノートで、"chicken"を含み、かつ"cooking"タグが付加されたものを検索します: chicken tag:cooking created:year - "cooking"タグを含み、かつ"mexican"タグを含まないノートの中で、"beef"を含み"carrots"を含まないものを検索します: tag:cooking -tag:mexican beef -carrots - "Travel"ノートブック中のノートで、タイトルに"San Francisco"を含むものを検索します: notebook:Travel intitle:"San Francisco" - "San Francisco"と含むノート、もしくは"SFO"タグを付加されたノートを検索します: any: "San Francisco" tag:SFO # <> * Evernote Browser Evernote Browser はタグ一覧や、保存された検索の一覧、過去に検索したノートの一覧からノートを開くための機能を提供します。これらの一覧はevernote-open-noteコマンドやevernote-search-notesコマンドで補完に使われるノート一覧と異なり、ユーザにより削除されるまでバッファ上に保持されます。この一覧は繰り返し使用することができるため、ノートを開く手順を簡略化することができます。 Evernote Browserは複数のEvernote Browserページ(バッファ)から構成されます。Evernote Browserページは、ノートの検索を行った際、もしくは検索を一度も行っていない状態でevernote-browserコマンドを実行した際に作られます。ページはリストとして管理され、現在有効なカレントページと各ページ間に前後関係を持ちます。 Evernote Browser のカレントページに移動するにはevernote-browser コマンドを実行して下さい。また、ページの移動には後述するページ移動キーを使用して下さい。 各 Evernote Browser ページには以下の種類があります。 - タグ一覧ページ タグ一覧ページにはユーザがEvernoteサービス上で作成したタグ一覧が階層的に表示されます。タグ名の上で Enter(\C-m) を押すことで、そのタグが付加されたノートの一覧ページが開きます。 - 保存された検索一覧ページ 保存された検索一覧ページにはユーザがEvernoteサービス上で作成した「保存された検索」の一覧が表示されます。保存された検索の名前上でEnter(\C-m)を押すことで保存された検索を実行し、結果をノート一覧ページとして開きます。 - ノート一覧ページ ノート一覧ページは検索により取得したノートの一覧を表示します。ノート一覧ページは evernote-open-note コマンド、 evernote-search-notes コマンドや、Evernote Browser での検索が行われる度に新たに作成されます。ノート名上でEnter(\C-m)を押すことでノートを開きます。 - ノートブック一覧ページ ノートブック一覧ページにはユーザがEvernoteサービス上で作成したノートブックの一覧が表示されます。ノートブック名の上でEnter(\C-m)を押すことで、そのノートブックに属するノートの一覧ページが開きます。 Evernote Browser ページ上でのその他のキーアサインは以下の通りです。 |------+--------------------------------------------------------------------------------------------------------------| | キー | 動作 | |------+--------------------------------------------------------------------------------------------------------------| | b | 前のページに移動します | | f | 次のページに移動します | | t | タグ一覧ページを作成し、表示します。既にタグ一覧ページがある場合はそのページに移動します | | S | 保存された検索一覧ページを作成し、表示します。既に保存された検索一覧ページがある場合はそのページに移動します | | s | 入力された検索クエリから結果を新規ノート一覧ページとして作成し、そのページを表示します | | N | ノートブック一覧ページを作成し、表示します。既にノートブック一覧ページがある場合はそのページに移動します | | o | Enter(\C-m) と同じですが、ノート一覧ページの場合は、開いたノートにカーソルを移動しません | | n | 次の行に移動します。ノート一覧ページの場合は移動したカーソル上のノートを開きます | | p | 前の行に移動します。ノート一覧ページの場合は移動したカーソル上のノートを開きます | | d | 現在のページを Evernote Browser から削除します | |------+--------------------------------------------------------------------------------------------------------------| # <> * Bookmarks Emacs 23.1 以降を使用している場合、emacs のブックマークを evernote のノートに対して設定することができます。 この機能により頻繁に参照する evernote ノートをより容易に開くことができます。 ブックマークの使用方法は通常のファイルを扱う場合と同じです。 bookmark-set (C-x r m RET) をノートを開いているバッファで実行することでブックマークを登録します。 また、登録されたブックマークは bookmark-jump (C-x r b bookmark RET) や list-bookmark (C-x r l) で参照できます。 # <> * Install and Settings 1. Evernoteサービス使用のために必要なRubyスクリプトをインストールする @
    cd evernote-mode/ruby
    ruby setup.rb
    @
2. evernote-mode.el をロードパスにコピーする @
    cp evernote-mode.el 
    @
3. evernote-enml-formatter-command に使用するプログラム w3m の入手、設定 (オプション) - Linux/Unixの場合、w3m のパッケージを [[http://w3m.sourceforge.net/index.en.html][こちら]] から入手してインストールするか、各ディストリビューションのw3mパッケージをインストールして下さい。 - Windowsの場合、cygwin を [[http://www.cygwin.com/][こちら]] から入手し、setup.exe を実行してパッケージ選択画面(Select Packages)からw3mを選択してインストールして下さい。 - w3mが存在するパスを環境変数PATHに追加して下さい 4. evernote-mode設定を.emacs に追記 @
     (add-to-list 'load-path "")
     (require 'evernote-mode)
     (setq evernote-username "") ; optional: you can use this username as default.
     (setq evernote-enml-formatter-command '("w3m" "-dump" "-I" "UTF8" "-O" "UTF8")) ; optional
     (global-set-key "\C-cec" 'evernote-create-note)
     (global-set-key "\C-ceo" 'evernote-open-note)
     (global-set-key "\C-ces" 'evernote-search-notes)
     (global-set-key "\C-ceS" 'evernote-do-saved-search)
     (global-set-key "\C-cew" 'evernote-write-note)
     (global-set-key "\C-cep" 'evernote-post-region)
     (global-set-key "\C-ceb" 'evernote-browser)
     @
evernote-enml-formatter-commandが設定されていない場合はXHTMLモードでの読み込み時に整形されてない状態のXMLが表示されます。 上記に加え、 ruby の cygwin を使用している場合は、cygwin-mount.el (http://www.emacswiki.org/cgi-bin/wiki/cygwin-mount.el) が必要になります。cygwin-mount.el を取得し、以下を .emacs に追加して下さい。 @
		 (require 'cygwin-mount)
		 (cygwin-mount-activate)
     @
5. proxy の設定 プロキシを使用する場合は環境変数EN\_PROXYに 'プロキシホスト':'ポート'を指定して下さい。(ex. export EN\_PROXY=proxy.hoge.com:8080) # <> * Collaboration with Anything evernote-mode は Anything(http://www.emacswiki.org/emacs/Anything) で evernote のノート名から選択候補を表示する機能 (anything-c-source) を提供します。 .emacs に以下の設定を追記することで、anything の選択候補に evernote のノート名を加えます。 @
(add-to-list 'anything-sources anything-c-source-evernote-title)
@
また、Anything を使って Evernote のノート名のみから選択を行いたい場合は、 anything-evernote-title を使用できます。 上記 Anything との協調機能は evernote にログインした状態でのみ (evernote-login, もしくは evernote-xxx コマンドを最初に実行した後) 使用することができます。 # <> * Troubleshooting ** `require': no such file to load -- gdbm と表示される ディストリビューションの設定によっては ruby が使用できる GDBM ライブラリがインストールされてない場合があります。 上記が表示される場合は libgdbm-ruby 等をインストールして下さい。 - aptを使ったインストール例 @
apt-get install libgdbm-ruby
@
- ActiveScriptRuby または Ruby-mswin32 の場合 [[http://jarp.does.notwork.org/win32/][Porting Libraries to Win32]] から gdbm.dll を入手し、ruby.exe と同じフォルダに置いて下さい。 - Mac OS X の場合 Mac OS X に付属の ruby には GDBM バインディングが含まれていません。 [[http://www.macports.org/][MacPorts]] や [[http://mxcl.github.com/homebrew/][Homebrew]] で ruby と GDBM をインストールしてください。 MacPorts の場合 @
$ sudo ports install ruby gdbm
@
Homebrew の場合 @
$ sudo brew install ruby gdbm
@
また、[[No%20such%20file%20or%20directory][evernote-ruby-command を設定]] してください。 ** `require': no such file to load -- net/https と表示される ディストリビューションの設定によっては ruby が使用できる openssl ライブラリがインストールされてない場合があります。 上記が表示される場合は libopenssl-ruby をインストールして下さい。 - aptを使ったインストール例 @
apt-get install libopenssl-ruby
@
** No such file or directory -- enclient.rb (LoadError) の様なメッセージが表示される OS に複数のバージョンの ruby がインストールされている場合に、evernote-mode をインストールした ruby (ruby setup.rb を実行した ruby) と異なる ruby が使われている可能性があります。 evernote-mode をロードする前に、evernote-ruby-command に正しい ruby をフルパスで指定してください。 e.g. @
    (setq evernote-ruby-command "/your/path/to/ruby")
    (require 'evernote-mode)
    @
evernote-mode-0_41/doc/readme_en.html0000664000175000017500000007305411600732624017512 0ustar uwabamiuwabami Emacs evernote mode

Emacs evernote mode

1 License

Copyright 2011 Yusuke Kawakami

 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.


2 Introduction

Emacs evernote mode offers functions to refer and edit Evernote notes directly from Emacs. Currently this package offers the following interfaces.

  • Command: evernote-login

    Login to Evernote. The following commands are available only when you login. If you execute the following commands without the login, the login prompt will be shown.

  • Variable: evernote-username

    An username of your evernote.

  • Command: evernote-open-note

    Read an existing note to an Emacs buffer. At first, input tags of the notes, then input the name of the note on the minibuffer.

  • Command: evernote-open-note-in-notebook

    Read an existing note to an Emacs buffer. At first, input the notebook and tags of the notes, then input the name of the note on the minibuffer.

  • Command: evernote-save-note (default bound to \C-x\C-s)

    Save the modified note..

  • Command: evernote-create-note

    Create a note from scratch. The note is created in the default notebook.

  • Command: evernote-create-note-in-notebook

    Create a note from scratch. The note is created in the specified notebook.

  • Command: evernote-write-note

    Create a new note from the current buffer. The note is created in the default notebook.

  • Command: evernote-write-note-in-notebook

    Create a new note from the current buffer. The note is created in the specified notebook.

  • Command: evernote-post-region

    Create a new note containing the selected region. The note is created in the default notebook. If you call this command without argument, no buffer associated with the new note is generated, which is different from evernote-open-note and evernote-create-note. If you call this command with an argument by \C-u etc.(not default argument), it creates a new buffer associated with the new note and you can edit the note in the buffer.

  • Command: evernote-post-region-in-notebook

    Create a new note containing the selected region. The note is created in the specified notebook.

  • Command: evernote-change-notebook (default bound to \C-cen)

    Change the notebook to which the note belongs. The change on Evernote service will be made after exec of evernote-save-note.

  • Command: evernote-edit-tags (default bound to \C-cet)

    Change tags attached to the note. The change on Evernote service will be made after exec of evernote-save-note.

  • Command: evernote-change-edit-mode (default bound to \C-cee)

    Change the edit mode of the note. (See Evernote note edit mode for details) The change on Evernote service will be made after exec of evernote-save-note.

  • Command: evernote-rename-note (default bound to \C-cer)

    Rename the note. The change on Evernote service will be made after exec of evernote-save-note.

  • Command: evernote-delete-note (default bound to \C-ced)

    Delete the note.

  • Command: evernote-search-notes

    Search notes by query in the minibuffer. (See Search Query Examples for details)

  • Command: evernote-do-saved-search

    Search notes by using a Saved Search.

  • Command: evernote-create-notebook

    Create a new notebook.

  • Command: evernote-edit-notebook

    Change the name and whether this book is the default notebook or not.

  • Command: evernote-create-search

    Save a query with a name for later use.

  • Command: evernote-edit-search

    Change the name and the query of an existing Saved Search.

  • Command: evernote-toggle-read-only (default bound to \C-x\C-q)

    Toggle read-only status of the note. When a note of XHTML mode is changed to the read-only status, the command in the variable evernote-enml-formatter-command formats the XHTML. See Evernote note edit mode for details.

  • Variable: evernote-enml-formatter-command

    The command to format XHTML. When a note of XHTML mode is read-only, the command formats the XHTML and displays it. Currently evernote-mode supports w3m as the formatter.

  • Command: evernote-browser

    Open Evernote Browser. Evernote Browser offers the features to open notes from the tag hierarchical list, the saved search list and the note list of the past search result. See Evernote Browser for details.

  • Variable: anything-c-source-evernote-title

    The variable that offers the function for Anything(http://www.emacswiki.org/emacs/Anything) to display the note candidates from the title. See Collaboration with Anything for details.

  • Command: anything-evernote-title

    Open a note by using Anything. See Collaboration with Anything for details.

  • Variable: evernote-mode-display-menu

    Display the menu on the menubar for evernote-mode (default: t)

  • Variable: evernote-password-cache

    Non-nil means that password cache is enabled. It is recommended to encrypt the file with EasyPG(http://epg.sourceforge.jp/). EasyPG is included in Emacs 23 or later. On Emacs 22, you install the EasyPG, then add the following line to your .emacs

    (require 'epa-setup)
    
    You can cache the password safely by using gpg-agent.

When you create a note by evernote-create-note, evernote-write-note and evernote-post-region, you can attach tags to the note. Also, when using the commands, you can input the name and the tag of the note with completion in the minibuffer.

The minor-mode "evernote-mode" is applied to the buffers opening the evernote note. The following commands are available only when "evernote-mode" is valid.

  • evernote-save-note
  • evernote-change-notebook
  • evernote-edit-tags
  • evernote-change-edit-mode
  • evernote-rename-note
  • evernote-delete-note

3 Evernote note edit mode

Evernote notes are XML complying with ENML DTD(http://xml.evernote.com/pub/enml2.dtd). evernote-mode offers the two edit mode, XHTML mode and TEXT mode for saving and reading the Evenote notes.

3.1 XHTML mode

When you save the Evernote note in XHTML mode, the content of the buffer will be saved as the content of the note. Therefore if the contents of the buffer is not valid ENML, you cannot save the contents because of the error.

And when you read a Evernote note by using XHTML mode, the buffer is read-only as the initial state. If the variable evernote-enml-formatter-command is set, the content of the buffer is formatted. (See Install and Settings for details of setting evernote-enml-formatter-command) If you toggle the read-only status and change it to read-write, unformatted XHTML is displayed in the buffer. The buffer will display the formatted text if you change the state to read-only again.

3.1.1 An example of XHTML mode editing:

   Emacs Buffer
   -----------------------------------
   <?xml version="1.0" encoding="UTF-8"?>
   <!DOCTYPE en-note SYSTEM "http://xml.evernote.com/pub/enml2.dtd">
   <en-note>Evernote notes are XML complying with ENML DTD<br clear="none"/>
   evernote-mode offers the two edit mode, XHTML mode and TEXT mode for<br clear="none"/>
   saving and reading the Evenote notes.<br clear="none"/>
   </en-note>
   -----------------------------------
   | save on XHTML mode
   V
   The content of the note (same as the emacs buffer)
   -----------------------------------
   <?xml version="1.0" encoding="UTF-8"?>
   <!DOCTYPE en-note SYSTEM "http://xml.evernote.com/pub/enml2.dtd">
   <en-note>Evernote notes are XML complying with ENML DTD<br clear="none"/>
   evernote-mode offers the two edit mode, XHTML mode and TEXT mode for<br clear="none"/>
   saving and reading the Evenote notes.<br clear="none"/>
   </en-note>
   -----------------------------------
   | read on XHTML mode
   V
   Emacs Buffer (read-only and formatted)
   -----------------------------------
   Evernote notes are XML complying with ENML DTD
   evernote-mode offers the two edit mode, XHTML mode and TEXT mode for
   saving and reading the Evenote notes.
   -----------------------------------
   |toggle read-only(evernote-toggle-read-only: \C-x\C-q)
   V
   Emacs Buffer (unformatted)
   -----------------------------------
   <?xml version="1.0" encoding="UTF-8"?>
   <!DOCTYPE en-note SYSTEM "http://xml.evernote.com/pub/enml2.dtd">
   <en-note>Evernote notes are XML complying with ENML DTD<br clear="none"/>
   evernote-mode offers the two edit mode, XHTML mode and TEXT mode for<br clear="none"/>
   saving and reading the Evenote notes.<br clear="none"/>
   </en-note>
   -----------------------------------


3.2 TEXT mode

In XHTML mode, you have to edit a XHTML as a text but it is a complicated work. evernote-mode offers TEXT mode to make editing text notes easy and effective.

The text mode is specialized in editing Evernote notes that only contain text content. When you save an Evernote note, special characters(&keyword; space, newline) in the buffer are escaped and the root element is added to transform it into a XML document. Therefore text contents in the Emacs buffer is same as the appearance of the note. (is not same as the actual XML content of the note.) And when you read a Evernote note by using TEXT mode, evernote-mode reads the contents under the root element of the XML as a text and all the special characters are unescaped then evernote-mode insert it to the buffer.

3.2.1 An example of TEXT mode editing:

Emacs Buffer
   -----------------------------------
   Evernote notes are XML complying with ENML DTD
   evernote-mode offers the two edit mode, XHTML mode and TEXT mode for
   saving and reading the Evenote notes.
   -----------------------------------
   | save on TEXT mode
   V
   The content of the note (escaped and transformed into a XML)
   -----------------------------------
   <?xml version="1.0" encoding="UTF-8"?>
   <!DOCTYPE en-note SYSTEM "http://xml.evernote.com/pub/enml2.dtd">
   <en-note>Evernote notes are XML complying with ENML DTD<br clear="none"/>
   evernote-mode offers the two edit mode, XHTML mode and TEXT mode for<br clear="none"/>
   saving and reading the Evenote notes.<br clear="none"/>
   </en-note>
   -----------------------------------
   | read on TEXT mode
   V
   Emacs Buffer (unescaped and transformed int a text)
   -----------------------------------
   Evernote notes are XML complying with ENML DTD
   evernote-mode offers the two edit mode, XHTML mode and TEXT mode for
   saving and reading the Evenote notes.
   -----------------------------------

3.3 Select edit mode

You can select the edit mode when you create a note. The edit mode is recorded in the note when you save it, and the recorded edit mode is applied to the note when you reopen it.

3.4 Change edit mode

Use the command evernote-change-edit-mode to change the edit mode of the existing note. If you change the edit mode from XHTML mode to TEXT mode and the buffer is read-only, then the content of the TEXT mode is the formatted text. Note that the change will remove all format information(xml tags). If the buffer is read-write, the content of the TEXT mode is the original unformatted text.

4 Search Query Examples

Here are examples of queries used for searching notes.

The following examples are referred from (http://www.evernote.com/about/developer/api/evernote-api.htm#_Toc277181479).

  • Find notes containing the word "chicken", tagged with "cooking", and created this year:

chicken tag:cooking created:year

  • Find notes tagged with "cooking" but not "mexican" that include the word "beef" but not the word "carrots"

tag:cooking -tag:mexican beef -carrots

  • Find notes in my "Travel" notebook with San Francisco in the title:

notebook:Travel intitle:"San Francisco"

  • Find notes that either include the text "San Francisco" or are tagged with the "SFO" tag:

any: "San Francisco" tag:SFO

5 Evernote Browser

Evernote Browser offers the features to open notes from the tag hierarchical list, the saved search list, and the note list of the past search result. These lists are different from the completion lists of evernote-open-note command or the evernote-search-notes command. These lists of Evernote Browser are always kept in Emacs buffers until they are deleted by the user after they were created, and they make the procedure to open notes easy by using these list repeatedly.

Evernote Browser is composed of multiple Evernote Browser pages(emacs buffers). An Evernote Browser page is created when searching notes or when executing the evernote-browser command at the state that no search has been executed. The multiple pages are managed as the page list. There is one valid current page and each page has the next/previous page. Execute the evernote-browser command to move the cursor to the current Evernote Browser page. Also, use the keys for moving to the next/previous page key (described later) to move to another page.

There are three type of Evernote Browser page

  • tag list page
  • saved search list page
  • note list page
  • notebook list page

A tag list page shows the hierarchical tag list created on Evernote service. Pressing Enter(\C-m) on the tag name opens a note list page of the tag.

A saved search list shows the search list created on Evernote service. Pressing Enter(\C-m) on the search name opens a note list page from the search result.

A note list shows the note list from a note search result. The note list page is newly created by the evenote-open-note command, the evernote-search-notes command and by searches on Evernote Browser. Pressing Enter(\C-m) on the note name opens a note.

A notebook list page shows the notebook list created on Evernote service. Pressing Enter(\C-m) on the notebook name opens a note list page associated with the notebook.

The followings are other key assignments on Evernote Browser pages

KeyAction
bmove to the previous page
fmove to the next page
tcreate a tag list page and show it. If a tag list page already exists, move the cursor to the page
Screate a search list page and show it. If a tag list page already exists, move the cursor to the page
screate a note list from the search query input and show it
Ncreate a notebook list page and show it. If a notebook list page already exists, move the cursor to the page
osame as Enter(\C-m), but it does not move the cursor to the opened note
nmove to the next line and open the note on the cursor if in the note list,
pmove to the previous line and open the note on the cursor if in the note list,
ddelete the current from Evernote Browser

6 Bookmarks

On Emacs 23.1 or later, you can set emacs bookmarks to the evernote notes. You can open immediately the note that you can refer frequently by using this feature.

You can use the bookmarks in the same way as when using bookmarks to regular files. You can set a bookmark to a evernote note by executing 'bookmark-set' (C-x r m RET) in the buffer opening the evernote note. Also, you can refer the bookmarks 'bookmark-jump' (C-x r b bookmark RET) or 'list-bookmark' (C-x r l).

7 Install and Settings

  1. Install ruby scripts for using Evernote service.

    cd evernote-mode/ruby
    ruby setup.rb
    

  2. Copy evernote-mode.el to your load path.

    cp evernote-mode.el <your load path>
    

  3. Get w3m for evernote-enml-formatter-command (Optional)
    • If you use Linux/Unix, get w3m from here and install it or install w3m from the package of your distribution.
    • If you use Win, get cygwin from here, execute setup.exe and select w3m from the "Select Packages"
    • Add the path of w3m to the environment variable "PATH".
  4. Add the evernote-mode configuration to .emacs.

    (add-to-list 'load-path "<your load path>")
    (require 'evernote-mode)
    (setq evernote-username "<your evernote user name>") ; optional: you can use this username as default.
    (setq evernote-enml-formatter-command '("w3m" "-dump" "-I" "UTF8" "-O" "UTF8")) ; option
    (global-set-key "\C-cec" 'evernote-create-note)
    (global-set-key "\C-ceo" 'evernote-open-note)
    (global-set-key "\C-ces" 'evernote-search-notes)
    (global-set-key "\C-ceS" 'evernote-do-saved-search)
    (global-set-key "\C-cew" 'evernote-write-note)
    (global-set-key "\C-cep" 'evernote-post-region)
    (global-set-key "\C-ceb" 'evernote-browser)
    

    If you don't set evernote-enml-formatter-command, the unformatted XHTML is displayed when reading the note of XHTML mode.

    If you use cygwin for ruby, cygwin-mount.el (http://www.emacswiki.org/cgi-bin/wiki/cygwin-mount.el) is also needed. Get cygwin-mount.el and put it in your load path, and add the followings lines to your .emacs.

    (require 'cygwin-mount)
    (cygwin-mount-activate)
    

  5. Proxy settings

    If you want to use the proxy, set the value to the environment variable 'EN_PROXY' written as 'host:port' format. (ex. export EN_PROXY=proxy.hoge.com:8080)

8 Collaboration with Anything

evernote-mode offers the function for Anything(http://www.emacswiki.org/emacs/Anything) to display the note candidates from the title. You can add the evernote note titles to the source of candidates of Anything by adding the following configuration to your .emacs.

(add-to-list 'anything-sources anything-c-source-evernote-title)

You can also use 'anything-evernote-title' to choose the candidates only from the evernote notes. The above features for Anything are available only when you login the evernote service (after executing evernote-login or the first time you use the command evernote-xxx).

9 Troubleshooting

9.1 `require': no such file to load – gdbm

Some distributions do not have the GDBM library for ruby. Install libgdbm-ruby for using GDBM.

  • ex. for apt,

apt-get install libgdbm-ruby

  • In the case of ActiveScriptRuby or Ruby-mswin32

Retrieve gdbm.dll from Porting Libraries to Win32, then copy it to the folder where ruby.exe exists.

  • In the case of Mac OS X

The pre-installed ruby on Mac OS X does not contain GDBM bindings. Re-install ruby and GDBM by MacPorts or Homebrew.

MacPorts:

$ sudo ports install ruby gdbm

Homebrew:

$ sudo brew install ruby gdbm

Also, specify evernote-ruby-command.

9.2 `require': no such file to load – net/https

Some distributions do not have the openssl library for ruby. Install libopenssl-ruby for using https.

  • ex. for apt,

apt-get install libopenssl-ruby

9.3 No such file or directory – enclient.rb (LoadError)

When multiple version of ruby are installed in the OS, the evernote-mode may use another ruby that has installed the evernote-mode (The ruby that has executed 'ruby setup.rb'). Specify the full path of ruby to the evernote-ruby-command, before load the evernote-mode.

e.g.

(setq evernote-ruby-command "/your/path/to/ruby")
(require 'evernote-mode)

Author: Yusuke Kawakami <Yusuke Kawakami>

Date: 2011-06-24 06:49:56 JST

HTML generated by org-mode 6.33x in emacs 23

evernote-mode-0_41/doc/readme_ja.html0000664000175000017500000010400711576770330017503 0ustar uwabamiuwabami Emacs evernote mode

Emacs evernote mode

1 License

Copyright 2011 Yusuke Kawakami

 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.

2 Introduction

Emacs evernote modeはEvernoteのノートをemacsから直接参照、編集するための機能を提供します。現在このパッケージでは以下のインターフェースを提供しています。

  • Command: evernote-login

    evernote サービスにログインします。以下のコマンドはログイン時にのみ使用可能です。 ログインしていない状態で以下コマンドを実行した場合はログインプロンプトが表示されます。

  • Variable: evernote-username

    evernote サービスのユーザ名を指定します。

  • Command: evernote-open-note

    既存のノートをemacsバッファに読み込みます。検索するタグをミニバッファで入力後、続いてノートの名前を入力します。

  • Command: evernote-open-note-in-notebook

    既存のノートをemacsバッファに読み込みます。検索するノートブックとタグをミニバッファで入力後、続いてノートの名前を入力します。

  • Command: evernote-save-note (default bound to \C-x\C-s)

    編集したノートをEvernoteサービス上で上書き保存します。

  • Command: evernote-create-note

    ノートを新規作成します。ノートはデフォルトのノートブックに作成されます。

  • Command: evernote-create-note-in-notebook

    ノートを新規作成します。ノートは指定されたノートブックに作成されます。

  • Command: evernote-write-note

    emacsバッファを新規ノートとして保存します。ノートはデフォルトのノートブックに作成されます。

  • Command: evernote-write-note-in-notebook

    emacsバッファを新規ノートとして保存します。ノートは指定されたノートブックに作成されます。

  • Command: evernote-post-region

    選択されたリージョンを新規ノートとしてポストします。ノートはデフォルトのノートブックに作成されます。引数なしで実行した場合は、evernote-open-noteやevernote-create-noteと異なり、新規ノートに対応するバッファは作成しませんが、\C-u等で引数を与えた場合(デフォルト引数以外を与えた場合)は、新規ノートに対応するバッファを作成し、引き続きバッファ上での編集作業を行うことができます。

  • Command: evernote-post-region-in-notebook

    選択されたリージョンを新規ノートとしてポストします。ノートは指定されたノートブックに作成されます。

  • Command: evernote-change-notebook (default bound to \C-cen)

    ノートが属するノートブックを変更します。このコマンド発行後にevernote-save-noteを実行することでEvernoteサービス上で変更が反映されます.

  • Command: evernote-edit-tags (default bound to \C-cet)

    ノートに付加するタグを変更します。このコマンド発行後にevernote-save-noteを実行することでEvernoteサービス上で変更が反映されます.

  • Command: evernote-change-edit-mode (default bound to \C-cee)

    ノートの編集モードを変更します.詳細は Evernote note edit mode を参照して下さい.このコマンド発行後にevernote-save-noteを実行することでEvernoteサービス上で変更が反映されます.

  • Command: evernote-rename-note (default bound to \C-cer)

    ノートを名前を変更します。このコマンド発行後evernote-save-noteを実行することでEvernoteサービス上で変更が反映されます。

  • Command: evernote-delete-note (default bound to \C-ced)

    ノートを削除します。

  • Command: evernote-search-notes

    ミニバッファから入力されたクエリを使ってノートを検索します。クエリの例は Search Query Examples を参照して下さい。

  • Command: evernote-do-saved-search

    Evernoteの「保存された検索」を使ってノートを検索します。

  • Command: evernote-create-notebook

    ノートブックを新規作成します。

  • Command: evernote-edit-notebook

    指定されたノートブックの名前とデフォルトノートブックか否かを設定します。

  • Command: evernote-create-search

    クエリに名前をつけて保存し、以後「保存された検索」として参照できるようにします。

  • Command: evernote-edit-search

    既存の「保存された検索」の名前とクエリを変更します。

  • Command: evernote-toggle-read-only (default bound to \C-x\C-q)

    バッファに読み込まれたノートの読み込み専用,書込み可能状態を切り替えます。XHTMLモードのノートを読み込み専用にした場合、evernote-enml-formatter-command変数に設定されたコマンドを使ってXHTMLをフォーマットして表示します。詳細は Evernote note edit mode を参照して下さい

  • Variable: evernote-enml-formatter-command

    XHTMLモードのノートを読み込んだ際、もしくは書き込み可能から読み込み専用に状態を切り替えた場合に、XHTMLを整形して表示するためのコマンドを指定します。現在整形コマンドとしてw3mを使用することができます。

  • Command: evernote-browser

    Evernote Browser を開きます。Evernote Browser はタグ一覧や、保れされた検索の一覧、過去に検索したノートの一覧からノートを開くための機能を提供します。詳細はEvernote Browser を参照して下さい。

  • Variable: anything-c-source-evernote-title

    Anything(http://www.emacswiki.org/emacs/Anything) からタイトルからノートの選択候補を表示する機能を提供する変数です。 詳細は Collaboration with Anything を参照して下さい。

  • Command: anything-evernote-title

    Anything を使ってタイトルからノートを開きます。

  • Variable: evernote-mode-display-menu

    非 nil の場合に evernote-mode 用のメニューをメニューバー上に表示します。(デフォルト: t)

  • Variable: evernote-password-cache

    非 nil の場合にパスワードのキャッシュを有効にします。 有効にする時は、EasyPG(http://epg.sourceforge.jp/)を使って暗号化することを推奨します。EasyPG は Emacs 23 以降には含まれています。Emacs 22 では EasyPG をインストールし、.emacs に以下を記述してください。

    (require 'epa-setup)
    
    gpg-agent を使うことで安全にパスワードをキャッシュできます。

evernote-create-note,evernote-write-note,evernote-post-regionで新規ノートを作成する際にはノートに付加するタグを指定することができます. また、コマンド使用時にタグ・ノート名を入力する際にはミニバッファでの補完が行われます。

ノートを開いているバッファには evernote-modeマイナーモードが適用されます。以下のコマンドはevernote-modeマイナーモードでのみ有効です。

  • evernote-save-note
  • evernote-change-notebook
  • evernote-edit-tags
  • evernote-change-edit-mode
  • evernote-rename-note
  • evernote-delete-note

3 Evernote note edit mode

EvernoteのノートはENML DTD(http://xml.evernote.com/pub/enml2.dtd)に準拠するXML文書です。evernote-modeではこのXMLをemacsで保存、読み込みを行う為ににXHTMLモードとTEXTモード2種類の編集モードを用意しています。

3.1 XHTML モード

XHTMLモードでノートを保存した場合、バッファの内容がそのままノートの内容として保存されます。バッファ内容がENML DTDに沿ったフォーマットでない場合はエラーになります。

XHTMLモードでノートを読み込んだ場合、初期状態としてバッファは読み込み専用になります。この際、変数evernote-enml-formatter-commandが設定されている場合は、バッファには整形された内容が表示されます。(evernote-enml-formatter-comandの設定については Install and Settings を参照して下さい) evernote-toggle-read-onlyコマンドを実行して編集の為に書き込み可能にした場合は、整形されない状態のXMLが表示されます。書き込み可能から読み込み専用に再度変更すると、再びバッファには整形された内容が表示されます。

3.1.1 XHTMLモードでの編集の例:

   Emacs バッファ
   -----------------------------------
   <?xml version="1.0" encoding="UTF-8"?>
   <!DOCTYPE en-note SYSTEM "http://xml.evernote.com/pub/enml2.dtd">
   <en-note>EvernoteのノートはENML DTDに準<br clear="none"/>
   拠するXML文書です。evernote-modeではこのXMLをemacsで扱うためにXHTMLモー<br clear="none"/>
   ドとTEXTモード2種類の編集モードを用意しています。<br clear="none"/>
   </en-note>
   -----------------------------------
   |
   |XHTMLモードで保存
   V
   Evernoteサービス上のノート(Emacsバッファの内容と同じ)
   -----------------------------------
   <?xml version="1.0" encoding="UTF-8"?>
   <!DOCTYPE en-note SYSTEM "http://xml.evernote.com/pub/enml2.dtd">
   <en-note>EvernoteのノートはENML DTDに準<br clear="none"/>
   拠するXML文書です。evernote-modeではこのXMLをemacsで扱うためにXHTMLモー<br clear="none"/>
   ドとTEXTモード2種類の編集モードを用意しています。<br clear="none"/>
   </en-note>
   -----------------------------------
   |
   |XHTMLモードで読み込み
   V
   Emacs バッファ
   (読み込み専用となり、整形されて表示される)
   -----------------------------------
   EvernoteのノートはENML DTDに準
   拠するXML文書です。evernote-modeではこのXMLをemacsで扱うためにXHTMLモー
   ドとTEXTモード2種類の編集モードを用意しています。
   -----------------------------------
   |
   |書き込み可能状態にする(evernote-toggle-read-only: \C-x\C-q)
   V
   Emacs バッファ
   (整形されないXMLが表示される)
   -----------------------------------
   <?xml version="1.0" encoding="UTF-8"?>
   <!DOCTYPE en-note SYSTEM "http://xml.evernote.com/pub/enml2.dtd">
   <en-note>EvernoteのノートはENML DTDに準<br clear="none"/>
   拠するXML文書です。evernote-modeではこのXMLをemacsで扱うためにXHTMLモー<br clear="none"/>
   ドとTEXTモード2種類の編集モードを用意しています。<br clear="none"/>
   </en-note>
   -----------------------------------

3.2 TEXTモード

XHTMLモードでは、ノートを編集する際にXHTMLをテキストとして編集する必要があり、作業が煩雑になります。そこでevernote-modeではテキストのみ含むEvernoteノートを効率よく作成、編集するための TEXTモードを提供しています。

TEXTモードはテキストのみ含むEvernoteノートの編集に特化したモードです。TEXTモードでノートを保存した場合、バッファ中のXMLの特殊文字(&キーワード\;, スペース、改行)はエスケープされ、ルート要素を付加した上でENMLに変換されます。このため、emacsバッファで表示されている内容がノートの見た目上の内容として保存されます。また、TEXTモードでノートを読み込んだ場合は、XMLのルート要素直下をテキストとして解釈し、XMLの特殊文字はアンエスケープされた上でバッファに読み込まれます。

3.2.1 TEXTモードでの編集の例:

   Emacs バッファ
   -----------------------------------
   EvernoteのノートはENML DTDに準
   拠するXML文書です。evernote-modeではこのXMLをemacsで扱うためにXHTMLモー
   ドとTEXTモード2種類の編集モードを用意しています。
   -----------------------------------
   |
   |TEXTモードで保存
   V
   Evernoteサービス上のノート
   (Emacsバッファの内容がエスケープされ, XMLに変換される)
   -----------------------------------
   <?xml version="1.0" encoding="UTF-8"?>
   <!DOCTYPE en-note SYSTEM "http://xml.evernote.com/pub/enml2.dtd">
   <en-note>EvernoteのノートはENML DTDに準<br clear="none"/>
   拠するXML文書です。evernote-modeではこのXMLをemacsで扱うためにXHTMLモー<br clear="none"/>
   ドとTEXTモード2種類の編集モードを用意しています。<br clear="none"/>
   </en-note>
   -----------------------------------
   |
   |TEXTモードで読み込み
   V
   Emacs バッファ
   (ノートのルート要素以下の内容がアンエスケープされる)
   -----------------------------------
   EvernoteのノートはENML DTDに準
   拠するXML文書です。evernote-modeではこのXMLをemacsで扱うためにXHTMLモー
   ドとTEXTモード2種類の編集モードを用意しています。
   -----------------------------------

3.3 モードの選択

上記XHTML, TEXTモードはノートの作成時に選択できます。ノート保存時には編集モード情報も保存され、次に読み込まれる際には保存時の編集モードで読み込まれます。また、他のEvernoteアプリケーションで作成されたノートはXHTMLモードとして読み込まれます。

3.4 モードの切り替え

既存のノートのXHTML,TEXTモードを切り替える場合は、evernote-change-edit-modeコマンドを使用します。XHTMLモードからTEXTモードの切り替えにおいて、バッファが読み込み専用状態の場合、整形された内容がTEXTモードでのノートの内容になります。この際元のXHTMLのフォーマット情報(XML tag)は全て失われるので注意して下さい。書き込み可能状態でモードを切り替えた場合は、整形されていない元のXHTMLがTEXTモード表示されるノートの内容になります。

4 Search Query Examples

ノートの検索に使用できるクエリの例を示します。

以下の例は http://www.evernote.com/about/developer/api/evernote-api.htm#_Toc277181479 からの引用です。

  • 今年に作られたノートで、"chicken"を含み、かつ"cooking"タグが付加されたものを検索します:

    chicken tag:cooking created:year

  • "cooking"タグを含み、かつ"mexican"タグを含まないノートの中で、"beef"を含み"carrots"を含まないものを検索します:

    tag:cooking -tag:mexican beef -carrots

  • "Travel"ノートブック中のノートで、タイトルに"San Francisco"を含むものを検索します:

    notebook:Travel intitle:"San Francisco"

  • "San Francisco"と含むノート、もしくは"SFO"タグを付加されたノートを検索します:

    any: "San Francisco" tag:SFO

5 Evernote Browser

Evernote Browser はタグ一覧や、保存された検索の一覧、過去に検索したノートの一覧からノートを開くための機能を提供します。これらの一覧はevernote-open-noteコマンドやevernote-search-notesコマンドで補完に使われるノート一覧と異なり、ユーザにより削除されるまでバッファ上に保持されます。この一覧は繰り返し使用することができるため、ノートを開く手順を簡略化することができます。

Evernote Browserは複数のEvernote Browserページ(バッファ)から構成されます。Evernote Browserページは、ノートの検索を行った際、もしくは検索を一度も行っていない状態でevernote-browserコマンドを実行した際に作られます。ページはリストとして管理され、現在有効なカレントページと各ページ間に前後関係を持ちます。 Evernote Browser のカレントページに移動するにはevernote-browser コマンドを実行して下さい。また、ページの移動には後述するページ移動キーを使用して下さい。

各 Evernote Browser ページには以下の種類があります。

  • タグ一覧ページ

    タグ一覧ページにはユーザがEvernoteサービス上で作成したタグ一覧が階層的に表示されます。タグ名の上で Enter(\C-m) を押すことで、そのタグが付加されたノートの一覧ページが開きます。

  • 保存された検索一覧ページ

    保存された検索一覧ページにはユーザがEvernoteサービス上で作成した「保存された検索」の一覧が表示されます。保存された検索の名前上でEnter(\C-m)を押すことで保存された検索を実行し、結果をノート一覧ページとして開きます。

  • ノート一覧ページ

    ノート一覧ページは検索により取得したノートの一覧を表示します。ノート一覧ページは evernote-open-note コマンド、 evernote-search-notes コマンドや、Evernote Browser での検索が行われる度に新たに作成されます。ノート名上でEnter(\C-m)を押すことでノートを開きます。

  • ノートブック一覧ページ

    ノートブック一覧ページにはユーザがEvernoteサービス上で作成したノートブックの一覧が表示されます。ノートブック名の上でEnter(\C-m)を押すことで、そのノートブックに属するノートの一覧ページが開きます。

Evernote Browser ページ上でのその他のキーアサインは以下の通りです。

キー動作
b前のページに移動します
f次のページに移動します
tタグ一覧ページを作成し、表示します。既にタグ一覧ページがある場合はそのページに移動します
S保存された検索一覧ページを作成し、表示します。既に保存された検索一覧ページがある場合はそのページに移動します
s入力された検索クエリから結果を新規ノート一覧ページとして作成し、そのページを表示します
Nノートブック一覧ページを作成し、表示します。既にノートブック一覧ページがある場合はそのページに移動します
oEnter(\C-m) と同じですが、ノート一覧ページの場合は、開いたノートにカーソルを移動しません
n次の行に移動します。ノート一覧ページの場合は移動したカーソル上のノートを開きます
p前の行に移動します。ノート一覧ページの場合は移動したカーソル上のノートを開きます
d現在のページを Evernote Browser から削除します

6 Bookmarks

Emacs 23.1 以降を使用している場合、emacs のブックマークを evernote のノートに対して設定することができます。 この機能により頻繁に参照する evernote ノートをより容易に開くことができます。

ブックマークの使用方法は通常のファイルを扱う場合と同じです。 bookmark-set (C-x r m RET) をノートを開いているバッファで実行することでブックマークを登録します。 また、登録されたブックマークは bookmark-jump (C-x r b bookmark RET) や list-bookmark (C-x r l) で参照できます。

7 Install and Settings

  1. Evernoteサービス使用のために必要なRubyスクリプトをインストールする

    cd evernote-mode/ruby
    ruby setup.rb
    

  2. evernote-mode.el をロードパスにコピーする

    cp evernote-mode.el <your load path>
    

  3. evernote-enml-formatter-command に使用するプログラム w3m の入手、設定 (オプション)
    • Linux/Unixの場合、w3m のパッケージを こちら から入手してインストールするか、各ディストリビューションのw3mパッケージをインストールして下さい。
    • Windowsの場合、cygwin を こちら から入手し、setup.exe を実行してパッケージ選択画面(Select Packages)からw3mを選択してインストールして下さい。
    • w3mが存在するパスを環境変数PATHに追加して下さい
  4. evernote-mode設定を.emacs に追記

    (add-to-list 'load-path "<your load path>")
    (require 'evernote-mode)
    (setq evernote-username "<your evernote user name>") ; optional: you can use this username as default.
    (setq evernote-enml-formatter-command '("w3m" "-dump" "-I" "UTF8" "-O" "UTF8")) ; optional
    (global-set-key "\C-cec" 'evernote-create-note)
    (global-set-key "\C-ceo" 'evernote-open-note)
    (global-set-key "\C-ces" 'evernote-search-notes)
    (global-set-key "\C-ceS" 'evernote-do-saved-search)
    (global-set-key "\C-cew" 'evernote-write-note)
    (global-set-key "\C-cep" 'evernote-post-region)
    (global-set-key "\C-ceb" 'evernote-browser)
    

    evernote-enml-formatter-commandが設定されていない場合はXHTMLモードでの読み込み時に整形されてない状態のXMLが表示されます。

    上記に加え、 ruby の cygwin を使用している場合は、cygwin-mount.el (http://www.emacswiki.org/cgi-bin/wiki/cygwin-mount.el) が必要になります。cygwin-mount.el を取得し、以下を .emacs に追加して下さい。

    (require 'cygwin-mount)
    (cygwin-mount-activate)
    

  5. proxy の設定

    プロキシを使用する場合は環境変数EN_PROXYに 'プロキシホスト':'ポート'を指定して下さい。(ex. export EN_PROXY=proxy.hoge.com:8080)

8 Collaboration with Anything

evernote-mode は Anything(http://www.emacswiki.org/emacs/Anything) で evernote のノート名から選択候補を表示する機能 (anything-c-source) を提供します。 .emacs に以下の設定を追記することで、anything の選択候補に evernote のノート名を加えます。

(add-to-list 'anything-sources anything-c-source-evernote-title)

また、Anything を使って Evernote のノート名のみから選択を行いたい場合は、 anything-evernote-title を使用できます。

上記 Anything との協調機能は evernote にログインした状態でのみ (evernote-login, もしくは evernote-xxx コマンドを最初に実行した後) 使用することができます。

9 Troubleshooting

9.1 `require': no such file to load – gdbm と表示される

ディストリビューションの設定によっては ruby が使用できる GDBM ライブラリがインストールされてない場合があります。 上記が表示される場合は libgdbm-ruby 等をインストールして下さい。

  • aptを使ったインストール例

apt-get install libgdbm-ruby

  • ActiveScriptRuby または Ruby-mswin32 の場合

Porting Libraries to Win32 から gdbm.dll を入手し、ruby.exe と同じフォルダに置いて下さい。

  • Mac OS X の場合

Mac OS X に付属の ruby には GDBM バインディングが含まれていません。 MacPortsHomebrew で ruby と GDBM をインストールしてください。

MacPorts の場合

$ sudo ports install ruby gdbm

Homebrew の場合

$ sudo brew install ruby gdbm

また、evernote-ruby-command を設定 してください。

9.2 `require': no such file to load – net/https と表示される

ディストリビューションの設定によっては ruby が使用できる openssl ライブラリがインストールされてない場合があります。 上記が表示される場合は libopenssl-ruby をインストールして下さい。

  • aptを使ったインストール例

apt-get install libopenssl-ruby

9.3 No such file or directory – enclient.rb (LoadError) の様なメッセージが表示される

OS に複数のバージョンの ruby がインストールされている場合に、evernote-mode をインストールした ruby (ruby setup.rb を実行した ruby) と異なる ruby が使われている可能性があります。 evernote-mode をロードする前に、evernote-ruby-command に正しい ruby をフルパスで指定してください。

e.g.

(setq evernote-ruby-command "/your/path/to/ruby")
(require 'evernote-mode)

Author: Yusuke Kawakami <Yusuke Kawakami>

Date: 2011-06-18 09:23:14 JST

HTML generated by org-mode 6.21b in emacs 23

evernote-mode-0_41/evernote-mode.el0000664000175000017500000026074111601106450017225 0ustar uwabamiuwabami;; ;; Copyright 2011 Yusuke KAWAKAMI, Akihiro ARISAWA ;; ;; Licensed under the Apache License, Version 2.0 (the "License"); ;; you may not use this file except in compliance with the License. ;; You may obtain a copy of the License at ;; ;; http://www.apache.org/licenses/LICENSE-2.0 ;; ;; Unless required by applicable law or agreed to in writing, software ;; distributed under the License is distributed on an "AS IS" BASIS, ;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ;; See the License for the specific language governing permissions and ;; limitations under the License. ;; ;; evernote-mode home page is at: http://code.google.com/p/emacs-evernote-mode/ ;; Author: Yusuke KAWAKAMI, Akihiro ARISAWA ;; Version: 0.41 ;; Keywords: tools, emacs, evernote, bookmark ;; This emacs lisp offers the interactive functions to open, edit, and update notes of Evernote. ;; The minor mode Evernote-mode is applied to the buffer editing a note of Evernote. ;; ;; Please copy this file into emacs lisp library directory or place it in ;; a directory (for example "~/lisp") and write $HOME/.emacs like this. ;; ;; (add-to-list 'load-path "~/lisp") ;; (require 'evernote-mode) ;; (setq evernote-enml-formatter-command '("w3m" "-dump" "-I" "UTF8" "-O" "UTF8")) ;; (global-set-key "\C-cec" 'evernote-create-note) ;; (global-set-key "\C-ceo" 'evernote-open-note) ;; (global-set-key "\C-ces" 'evernote-search-notes) ;; (global-set-key "\C-ceS" 'evernote-do-saved-search) ;; (global-set-key "\C-cew" 'evernote-write-note) ;; (global-set-key "\C-cep" 'evernote-post-region) ;; (global-set-key "\C-ceb" 'evernote-browser) ;; ;; There is one hooks, evernotes-mode-hook. ;; The usage of the hook is shown as follows. ;; ;; (setq evernote-mode-hook ;; '(lambda () ;; (...))) ;;; Code (require 'tree-widget) (defun enh-bookmark-supported () (or (> emacs-major-version 23) (and (= emacs-major-version 23) (>= emacs-minor-version 1)))) (when (enh-bookmark-supported) (declare-function bookmark-default-handler "bookmark" (bmk-record)) (declare-function bookmark-get-bookmark-record "bookmark" (bookmark)) (declare-function bookmark-make-record-default "bookmark" (&optional no-file no-context posn)) (declare-function bookmark-name-from-full-record "bookmark" (full-record))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Macros ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defmacro enh-command-with-auth (&rest body) `(let (error-code (try-func (lambda () ,@body))) (setq error-code (catch 'error (progn (funcall try-func) t))) (cond ((eq error-code t) t) ((or (eq error-code enh-command-error-not-authed) (eq error-code enh-command-error-invalid-auth) (eq error-code enh-command-error-auth-expired)) (let ((error-code (catch 'error (progn (evernote-login) t)))) (if (eq error-code t) (progn (let (error-code) (setq error-code (catch 'error (progn (funcall try-func) t))) (unless (eq error-code t) (message enh-command-last-error-message)))) (message enh-command-last-error-message)))) (t (message enh-command-last-error-message))))) (defmacro enh-base-create-note-interactive (ask-notebook) "Common interactive procecure of creating a note" `(progn (if (called-interactively-p) (enh-clear-onmem-cache)) (enh-command-with-auth (switch-to-buffer (enh-base-create-note-common "" ,ask-notebook t t nil))))) (defmacro enh-base-write-note-interactive (ask-notebook) "Common interactive procecure of writing a note" `(progn (if (called-interactively-p) (enh-clear-onmem-cache)) (enh-command-with-auth (enh-base-create-note-common (buffer-name) ,ask-notebook ,nil t t)))) (defmacro enh-base-post-region-interactive (begin end arg ask-notebook) "Common interactive procedure of posting a note" `(progn (if (called-interactively-p) (enh-clear-onmem-cache)) (enh-command-with-auth (save-excursion (save-restriction (narrow-to-region ,begin ,end) (if (and (enutil-neq ,arg nil) (enutil-neq ,arg 1)) (pop-to-buffer (enh-base-create-note-common (buffer-name) ,ask-notebook t t t)) (enh-base-create-note-common (buffer-name) ,ask-notebook nil nil t))))))) (defmacro enutil-neq (&rest exprs) `(not (eq ,@exprs))) (defmacro enutil-nequal (&rest exprs) `(not (equal ,@exprs))) (defmacro enutil-push (elem list) `(setq ,list (cons ,elem ,list))) (defmacro enutil-pop (list) `(prog1 (car ,list) (setq ,list (cdr ,list)))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; User options ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defvar evernote-username nil "*An username of your evernote") (defvar evernote-enml-formatter-command nil "*Formatter for xhtml") (defvar evernote-ruby-command "ruby" "*Path of the ruby command") (defvar evernote-password-cache nil "*Non-nil means that password cache is enabled. It is recommended to encrypt the file with EasyPG.") ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Interface for evernote-browsing-mode. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defvar evernote-browsing-page-list nil "Buffer list of evernote browsing mode.") (defvar evernote-browsing-current-page nil "Current buffer of evernote browsing mode.") (defvar evernote-browsing-mode-map (let ((map (make-sparse-keymap))) (set-keymap-parent map widget-keymap) map) "Keymap used in evernote browsing mode.") (define-key evernote-browsing-mode-map "o" 'widget-button-press) (define-key evernote-browsing-mode-map "n" 'evernote-browsing-open-next-note) (define-key evernote-browsing-mode-map "p" 'evernote-browsing-open-previous-note) (define-key evernote-browsing-mode-map "N" 'evernote-browsing-list-notebooks) (define-key evernote-browsing-mode-map "t" 'evernote-browsing-list-tags) (define-key evernote-browsing-mode-map "S" 'evernote-browsing-list-searches) (define-key evernote-browsing-mode-map "s" 'evernote-browsing-search-notes) (define-key evernote-browsing-mode-map "b" 'evernote-browsing-prev-page) (define-key evernote-browsing-mode-map "f" 'evernote-browsing-next-page) (define-key evernote-browsing-mode-map "d" 'evernote-browsing-delete-page) (define-key evernote-browsing-mode-map "l" 'evernote-browsing-reflesh) ;(define-key evernote-browsing-mode-map "e" 'evernote-browsing-change-edit-mode) ;(define-key evernote-browsing-mode-map "r" 'evernote-browsing-rename-note) ;(define-key evernote-browsing-mode-map "d" 'evernote-browsing-delete-note) (defun evernote-browsing-mode () "Major mode for browsing notes." (interactive) (if (called-interactively-p) (enh-clear-onmem-cache)) (setq evernote-browsing-mode t) (use-local-map evernote-browsing-mode-map) (setq truncate-lines t major-mode 'evernote-browsing-mode mode-name "Evernote-Browsing") (goto-char (point-min))) (defun evernote-browser () "Open an evernote browser" (interactive) (if (called-interactively-p) (enh-clear-onmem-cache)) (enh-browsing-update-page-list) (if evernote-browsing-current-page (enutil-move-cursor-to-window evernote-browsing-current-page) (evernote-browsing-list-tags))) (defun evernote-browsing-open-next-note () (interactive) (next-line) (when (eq enh-browsing-page-type 'note-list) (condition-case nil (widget-button-press (point)) (error nil)))) (defun evernote-browsing-open-previous-note () (interactive) (previous-line) (when (eq enh-browsing-page-type 'note-list) (condition-case nil (widget-button-press (point)) (error nil)))) (defun evernote-browsing-list-notebooks () "List tags" (interactive) (if (called-interactively-p) (enh-clear-onmem-cache)) (enh-browsing-update-page-list) (let ((page (enh-browsing-get-page-of-type 'notebook-list))) (if page (progn (setq evernote-browsing-current-page page) (switch-to-buffer page)) (enh-browsing-push-page (enh-browsing-create-page 'notebook-list "All Notebooks"))))) (defun evernote-browsing-list-tags () "List tags" (interactive) (if (called-interactively-p) (enh-clear-onmem-cache)) (enh-browsing-update-page-list) (let ((page (enh-browsing-get-page-of-type 'tag-list))) (if page (progn (setq evernote-browsing-current-page page) (switch-to-buffer page)) (enh-browsing-push-page (enh-browsing-create-page 'tag-list "All Tags"))))) (defun evernote-browsing-list-searches () "List saved searches" (interactive) (if (called-interactively-p) (enh-clear-onmem-cache)) (enh-browsing-update-page-list) (let ((page (enh-browsing-get-page-of-type 'search-list))) (if page (progn (setq evernote-browsing-current-page page) (switch-to-buffer page)) (enh-browsing-push-page (enh-browsing-create-page 'search-list "All Saved Searches"))))) (defun evernote-browsing-search-notes () "Search notes" (interactive) (if (called-interactively-p) (enh-clear-onmem-cache)) (let (note-attrs (query (read-string "Query:"))) (enh-command-with-auth (setq note-attrs (enh-command-get-note-attrs-from-query query))) (enh-browsing-update-page-list) (enh-browsing-push-page (enh-browsing-create-page 'note-list (format "Query Result of: %s" query) note-attrs)))) (defun evernote-browsing-prev-page () "Move to the prev page" (interactive) (if (called-interactively-p) (enh-clear-onmem-cache)) (when (eq major-mode 'evernote-browsing-mode) (enh-browsing-update-page-list) (let ((prev-page (enh-browsing-get-prev-page))) (if prev-page (progn (setq evernote-browsing-current-page prev-page) (switch-to-buffer prev-page)) (message "[No more previous page]"))))) (defun evernote-browsing-next-page () "Move to the next page" (interactive) (if (called-interactively-p) (enh-clear-onmem-cache)) (when (eq major-mode 'evernote-browsing-mode) (enh-browsing-update-page-list) (let ((next-page (enh-browsing-get-next-page))) (if next-page (progn (setq evernote-browsing-current-page next-page) (switch-to-buffer next-page)) (message "[No more next page]"))))) (defun evernote-browsing-delete-page () "Delete current page" (interactive) (if (called-interactively-p) (enh-clear-onmem-cache)) (when (eq major-mode 'evernote-browsing-mode) (kill-buffer (current-buffer)) (enh-browsing-update-page-list) (switch-to-buffer evernote-browsing-current-page))) (defun evernote-browsing-reflesh () (interactive) (if (called-interactively-p) (enh-clear-onmem-cache)) (when (eq major-mode 'evernote-browsing-mode) (funcall enh-browsing-page-setup-func))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Interface for evernote-mode ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defvar evernote-mode nil "Non-nil if Evernote mode is enabled.") (make-variable-buffer-local 'evernote-mode) (defvar evernote-note-guid nil "Note guid of the buffer") (make-variable-buffer-local 'evernote-note-guid) (defvar evernote-note-modified-name nil "Modified name of the note before saving") (make-variable-buffer-local 'evernote-note-modified-name) (defvar evernote-note-modified-notebook-guid nil "Modified noteobok guid of the note before saving") (make-variable-buffer-local 'evernote-note-modified-notebook-guid) (defvar evernote-note-modified-edit-mode nil "Modified edit-mode of the note before saving") (make-variable-buffer-local 'evernote-note-modified-edit-mode) (defvar evernote-note-is-modified-tag-names nil "Modified tag-names of the note before saving") (make-variable-buffer-local 'evernote-note-is-modified-tag-names) (defvar evernote-note-modified-tag-names nil "Modified tag-names of the note before saving") (make-variable-buffer-local 'evernote-note-modified-tag-names) (defvar evernote-note-xhtml-mode-content nil "Note contents as a string of XHTML") (make-variable-buffer-local 'evernote-note-xhtml-mode-content) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Menu Settings ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defvar evernote-mode-display-menu t "display the evernote menu on the menubar if this variable is not nil") (defvar evernote-mode-map (make-sparse-keymap) "Keymap used in evernote mode.") (define-key evernote-mode-map "\C-x\C-s" 'evernote-save-note) (define-key evernote-mode-map "\C-cen" 'evernote-change-notebook) (define-key evernote-mode-map "\C-cet" 'evernote-edit-tags) (define-key evernote-mode-map "\C-cee" 'evernote-change-edit-mode) (define-key evernote-mode-map "\C-cer" 'evernote-rename-note) (define-key evernote-mode-map "\C-ced" 'evernote-delete-note) (define-key evernote-mode-map "\C-x\C-q" 'evernote-toggle-read-only) (defun enh-menu-is-visible-on-ordinary-mode () (not evernote-browsing-mode)) (defun enh-menu-is-visible-on-evernote-mode () (and evernote-mode (not evernote-browsing-mode))) (defun enh-menu-is-visible-on-evernote-browsing-mode () evernote-browsing-mode) (let ((menu-bar-map (make-sparse-keymap "Evernote"))) (define-key-after global-map [menu-bar evernote] `(menu-item "Evernote" ,menu-bar-map :visible evernote-mode-display-menu) 'tools) (define-key menu-bar-map [browser] '(menu-item "Evernote Browser" evernote-browser :visible (enh-menu-is-visible-on-ordinary-mode))) (define-key menu-bar-map [seperator-0] '(menu-item "--" nil :visible (enh-menu-is-visible-on-ordinary-mode))) (define-key menu-bar-map [toggle-read-only] '(menu-item "Toggle Read Only" evernote-toggle-read-only :visible (enh-menu-is-visible-on-evernote-mode))) (define-key menu-bar-map [delete-note] '(menu-item "Delete Note" evernote-delete-note :visible (enh-menu-is-visible-on-evernote-mode))) (define-key menu-bar-map [rename-note] '(menu-item "Rename Note" evernote-rename-note :visible (enh-menu-is-visible-on-evernote-mode))) (define-key menu-bar-map [change-notebook] '(menu-item "Change Notebook" evernote-change-notebook :visible (enh-menu-is-visible-on-evernote-mode))) (define-key menu-bar-map [change-edit-mode] '(menu-item "Change Edit Mode" evernote-change-edit-mode :visible (enh-menu-is-visible-on-evernote-mode))) (define-key menu-bar-map [edit-tag] '(menu-item "Edit Tag" evernote-edit-tags :visible (enh-menu-is-visible-on-evernote-mode))) (define-key menu-bar-map [save-note] '(menu-item "Save Note" evernote-save-note :visible (enh-menu-is-visible-on-evernote-mode))) (define-key menu-bar-map [seperator-1] '(menu-item "--" nil :visible (enh-menu-is-visible-on-evernote-mode))) (define-key menu-bar-map [edit-notebook] '(menu-item "Edit Notebook" evernote-edit-notebook :visible (enh-menu-is-visible-on-ordinary-mode))) (define-key menu-bar-map [create-notebook] '(menu-item "Create Notebook" evernote-create-notebook :visible (enh-menu-is-visible-on-ordinary-mode))) (define-key menu-bar-map [seperator-2] '(menu-item "--" nil :visible (enh-menu-is-visible-on-ordinary-mode))) (define-key menu-bar-map [edit-search] '(menu-item "Edit Saved Search" evernote-edit-search :visible (enh-menu-is-visible-on-ordinary-mode))) (define-key menu-bar-map [create-search] '(menu-item "Create Saved Search" evernote-create-search :visible (enh-menu-is-visible-on-ordinary-mode))) (define-key menu-bar-map [do-saved-search] '(menu-item "Do Saved Search" evernote-do-saved-search :visible (enh-menu-is-visible-on-ordinary-mode))) (define-key menu-bar-map [search-note] '(menu-item "Search Note" evernote-search-notes :visible (enh-menu-is-visible-on-ordinary-mode))) (define-key menu-bar-map [seperator-3] '(menu-item "--" nil :visible (enh-menu-is-visible-on-ordinary-mode))) (define-key menu-bar-map [post-region-in-notebook] '(menu-item "Post Region (w/ notebook param)" evernote-post-region-in-notebook :visible (enh-menu-is-visible-on-ordinary-mode))) (define-key menu-bar-map [post-region] '(menu-item "Post Region" evernote-post-region :visible (enh-menu-is-visible-on-ordinary-mode))) (define-key menu-bar-map [write-note-in-notebook] '(menu-item "Write Note (w/ notebook param)" evernote-write-note-in-notebook :visible (enh-menu-is-visible-on-ordinary-mode))) (define-key menu-bar-map [write-note] '(menu-item "Write Note" evernote-write-note :visible (enh-menu-is-visible-on-ordinary-mode))) (define-key menu-bar-map [create-note-in-notebook] '(menu-item "Create Note (w/ notebook param)" evernote-create-note-in-notebook :visible (enh-menu-is-visible-on-ordinary-mode))) (define-key menu-bar-map [create-note] '(menu-item "Create Note" evernote-create-note :visible (enh-menu-is-visible-on-ordinary-mode))) (define-key menu-bar-map [open-note-in-notebook] '(menu-item "Open Note (w/ notebook param)" evernote-open-note-in-notebook :visible (enh-menu-is-visible-on-ordinary-mode))) (define-key menu-bar-map [open-note] '(menu-item "Open Note" evernote-open-note :visible (enh-menu-is-visible-on-ordinary-mode))) (define-key menu-bar-map [browsing-prev-page] '(menu-item "Prev Page" evernote-browsing-prev-page :visible (enh-menu-is-visible-on-evernote-browsing-mode))) (define-key menu-bar-map [browsing-next-page] '(menu-item "Next Page" evernote-browsing-next-page :visible (enh-menu-is-visible-on-evernote-browsing-mode))) (define-key menu-bar-map [browsing-search-notes] '(menu-item "Searche Notes" evernote-browsing-search-notes :visible (enh-menu-is-visible-on-evernote-browsing-mode))) (define-key menu-bar-map [browsing-list-searches] '(menu-item "List Saved Searches" evernote-browsing-list-searches :visible (enh-menu-is-visible-on-evernote-browsing-mode))) (define-key menu-bar-map [browsing-list-tags] '(menu-item "List Tags" evernote-browsing-list-tags :visible (enh-menu-is-visible-on-evernote-browsing-mode))) (define-key menu-bar-map [browsing-list-notebooks] '(menu-item "List Notebooks" evernote-browsing-list-notebooks :visible (enh-menu-is-visible-on-evernote-browsing-mode)))) (defun evernote-mode (&optional guid) "Toggle Evernote mode, a minor mode for using evernote functions." (interactive) (if (called-interactively-p) (enh-clear-onmem-cache)) (or (assq 'evernote-mode minor-mode-alist) (setq minor-mode-alist (cons '(evernote-mode " Evernote") minor-mode-alist))) (or (assq 'evernote-mode minor-mode-map-alist) (setq minor-mode-map-alist (cons (cons 'evernote-mode evernote-mode-map) minor-mode-map-alist))) (let ((modified (buffer-modified-p))) (set-buffer-file-coding-system 'utf-8) (set-buffer-modified-p modified)) (setq evernote-mode (not evernote-mode)) (if evernote-mode (progn (when guid (setq evernote-note-guid guid)) (enh-base-update-mode-line evernote-note-modified-notebook-guid evernote-note-is-modified-tag-names evernote-note-modified-tag-names evernote-note-modified-edit-mode) (add-hook 'after-save-hook 'evernote-mode-after-save-hook nil t) (add-hook 'change-major-mode-hook 'evernote-mode-change-major-mode-hook nil t) (when (enh-bookmark-supported) (enh-bookmark-prepare)) (run-hooks 'evernote-mode-hook)) (progn (setq evernote-note-guid nil) (setq vc-mode nil) (remove-hook 'after-save-hook 'evernote-mode-after-save-hook) (remove-hook 'change-major-mode-hook 'evernote-mode-change-major-mode-hook)))) (defun evernote-login () "Login" (interactive) (if (called-interactively-p) (enh-clear-onmem-cache)) (unwind-protect (let* ((cache (enh-password-cache-load)) (usernames (mapcar #'car cache)) (username (or evernote-username (read-string "Evernote user name:" (car usernames) 'usernames))) (cache-passwd (enutil-aget username cache))) (unless (and cache-passwd (eq (catch 'error (progn (enh-command-login username cache-passwd) t)) t)) (let* ((passwd (read-passwd "Passwd:"))) (enh-command-login username passwd) (setq evernote-username username) (enh-password-cache-save (enutil-aset username cache passwd))))) (enh-password-cache-close))) (defun evernote-open-note (&optional ask-notebook) "Open a note" (interactive) (if (called-interactively-p) (enh-clear-onmem-cache)) (enh-command-with-auth (let* ((notebook-guid (and ask-notebook (enutil-aget 'guid (enh-read-notebook)))) (tag-guids (enh-read-tag-guids "Tags used for search (comma separated form. default search all tags):")) (note-attrs (enh-command-get-note-attrs-from-notebook-and-tag-guids notebook-guid tag-guids))) (enh-base-open-note-common (enh-base-read-note-attr note-attrs)) (enh-browsing-update-page-list) (enh-browsing-push-page (enh-browsing-create-page 'note-list (if tag-guids (format "Notes with tag: %s" (enh-tag-guids-to-comma-separated-names tag-guids)) "All notes") note-attrs) t)))) (defun evernote-open-note-in-notebook () "Open a note in the specified notebook" (interactive) (if (called-interactively-p) (enh-clear-onmem-cache)) (evernote-open-note t)) (defun evernote-search-notes () "Search notes with query and open a note among them" (interactive) (if (called-interactively-p) (enh-clear-onmem-cache)) (let ((query (read-string "Query:"))) (enh-command-with-auth (let ((note-attrs (enh-command-get-note-attrs-from-query query))) (enh-base-open-note-common (enh-base-read-note-attr note-attrs)) (enh-browsing-update-page-list) (enh-browsing-push-page (enh-browsing-create-page 'note-list (format "Query Result of: %s" query) note-attrs) t))))) (defun evernote-do-saved-search () "Do a saved search and open a note" (interactive) (if (called-interactively-p) (enh-clear-onmem-cache)) (enh-command-with-auth (let* ((search-attr (enh-read-saved-search)) (note-attrs (enh-command-get-note-attrs-from-query (enutil-aget 'query search-attr)))) (enh-base-open-note-common (enh-base-read-note-attr note-attrs)) (enh-browsing-update-page-list) (enh-browsing-push-page (enh-browsing-create-page 'note-list (format "Query Result of Saved Search: %s" (enutil-aget 'name search-attr)) note-attrs) t)))) (defun evernote-create-note () "Create a note" (interactive) (enh-base-create-note-interactive nil)) (defun evernote-create-note-in-notebook () "Create a note in the specified notebook" (interactive) (enh-base-create-note-interactive t)) (defun evernote-write-note () "Write buffer to a note" (interactive) (enh-base-write-note-interactive nil)) (defun evernote-write-note-in-notebook () "Write buffer to a note in the specified notebook" (interactive) (enh-base-write-note-interactive t)) (defun evernote-post-region (begin end arg) "Post the region as a note" (interactive "r\np") (enh-base-post-region-interactive begin end arg nil)) (defun evernote-post-region-in-notebook (begin end arg) "Post the region as a note in the specified notebook" (interactive "r\np") (enh-base-post-region-interactive begin end arg t)) (defun evernote-save-note () "Save a note" (interactive) (if (called-interactively-p) (enh-clear-onmem-cache)) (cond ((not evernote-mode) nil) ; do nothing ((not (buffer-modified-p)) (message "(No changes need to be saved)")) (buffer-read-only (ding) (message "Unset read-only before you save")) (t (enh-command-with-auth (enh-base-update-note-common (current-buffer) ; contents evernote-note-guid ; guid (if evernote-note-modified-name ; name evernote-note-modified-name nil) evernote-note-modified-notebook-guid ; notebook-guid evernote-note-is-modified-tag-names ; is-tag-updated (if evernote-note-is-modified-tag-names ; tag-names evernote-note-modified-tag-names nil) (if evernote-note-modified-edit-mode ; edit-mode evernote-note-modified-edit-mode nil)) (if (or evernote-note-modified-name evernote-note-modified-notebook-guid evernote-note-is-modified-tag-names evernote-note-modified-edit-mode) (enh-browsing-reflesh-page 'note-list)) (setq evernote-note-modified-name nil evernote-note-modified-notebook-guid nil evernote-note-is-modified-tag-names nil evernote-note-modified-tag-names nil evernote-note-modified-edit-mode nil) (set-buffer-modified-p nil))))) (defun evernote-change-notebook () "Change notebook to which this note belongs" (interactive) (if (called-interactively-p) (enh-clear-onmem-cache)) (when evernote-mode (let* (current-notebook-guid current-notebook-name next-notebook-guid) (setq current-notebook-guid (or evernote-note-modified-notebook-guid (enutil-aget 'notebookGuid (enh-get-note-attr evernote-note-guid)))) (setq current-notebook-name (enutil-aget 'name (enh-get-notebook-attr current-notebook-guid))) (setq next-notebook-guid (enutil-aget 'guid (enh-read-notebook current-notebook-name))) (when (not (string= current-notebook-guid next-notebook-guid)) (setq evernote-note-modified-notebook-guid next-notebook-guid) (enh-base-update-mode-line evernote-note-modified-notebook-guid evernote-note-is-modified-tag-names evernote-note-modified-tag-names evernote-note-modified-edit-mode) (set-buffer-modified-p t))))) (defun evernote-edit-tags () "Add or remove tags from/to the note" (interactive) (if (called-interactively-p) (enh-clear-onmem-cache)) (when evernote-mode (setq evernote-note-modified-tag-names (enh-read-tag-names "Change attached Tags (comma separated form):" evernote-note-guid)) (setq evernote-note-is-modified-tag-names t) ; this must be after enh-read-tag-names (enh-base-update-mode-line evernote-note-modified-notebook-guid evernote-note-is-modified-tag-names evernote-note-modified-tag-names evernote-note-modified-edit-mode) (set-buffer-modified-p t))) (defun evernote-change-edit-mode () "Change edit mode of the note" (interactive) (if (called-interactively-p) (enh-clear-onmem-cache)) (when evernote-mode (let* ((current-edit-mode (or evernote-note-modified-edit-mode (enutil-aget 'editMode (enh-get-note-attr evernote-note-guid)))) (next-edit-mode (enh-read-edit-mode current-edit-mode)) (need-change nil)) (when (not (string= current-edit-mode next-edit-mode)) (cond ;; XHTML mode, Confirm the buffer is saved. ((and (string= current-edit-mode "XHTML") (buffer-modified-p)) (ding) (message "Save the buffer before you change edit mode")) ;; XHTML mode, Formatted xml. ((and (string= current-edit-mode "XHTML") buffer-read-only) (when (y-or-n-p "Changing text mode will remove all format information. Continue? ") (setq evernote-note-xhtml-mode-content nil) (setq buffer-read-only nil) (setq need-change t))) ;; XHTML mode, raw xml. ((and (string= current-edit-mode "XHTML") (not buffer-read-only)) (setq evernote-note-xhtml-mode-content nil) (setq need-change t)) ;; HTML mode. ((string= current-edit-mode "TEXT") (setq buffer-read-only nil) (setq need-change t)))) (when need-change (setq evernote-note-modified-edit-mode next-edit-mode) (enh-base-update-mode-line evernote-note-modified-notebook-guid evernote-note-is-modified-tag-names evernote-note-modified-tag-names evernote-note-modified-edit-mode) (set-buffer-modified-p t))))) (defun evernote-rename-note () "Rename a note" (interactive) (if (called-interactively-p) (enh-clear-onmem-cache)) (when evernote-mode (setq evernote-note-modified-name (read-string "New note name:" (enutil-aget 'title (enh-get-note-attr evernote-note-guid)))) (rename-buffer evernote-note-modified-name t) (enh-base-change-major-mode-from-note-name evernote-note-modified-name) (set-buffer-modified-p t))) (defun evernote-delete-note () "Delete a note" (interactive) (if (called-interactively-p) (enh-clear-onmem-cache)) (if (and evernote-mode (y-or-n-p "Do you really want to remove this note? ")) (enh-command-with-auth (enh-command-delete-note evernote-note-guid) (kill-buffer (current-buffer))))) (defun evernote-create-notebook () "Create a notebook" (interactive) (if (called-interactively-p) (enh-clear-onmem-cache)) (let ((name (read-string "Notebook Name:"))) (enh-command-with-auth (enh-command-create-notebook name nil)) (enh-browsing-reflesh-page 'notebook-list))) (defun evernote-edit-notebook () "Create a notebook" (interactive) (if (called-interactively-p) (enh-clear-onmem-cache)) (enh-command-with-auth (let* ((notebook-alist (enh-get-notebook-name-attr-alist)) (notebook-attr (enutil-aget (completing-read "Notebook:" notebook-alist nil t) notebook-alist))) (enh-command-update-notebook (enutil-aget 'guid notebook-attr) (read-string "New notebook name:" (enutil-aget 'name notebook-attr)) (yes-or-no-p "Use as the default notebook:")))) (clrhash enh-notebook-info) (enh-browsing-reflesh-page 'notebook-list)) (defun evernote-create-search () "Create a saved search" (interactive) (if (called-interactively-p) (enh-clear-onmem-cache)) (let ((name (read-string "Saved Search Name:")) (query (read-string "Query:"))) (enh-command-with-auth (enh-command-create-search name query)) (enh-browsing-reflesh-page 'search-list))) (defun evernote-edit-search () "Create a saved search" (interactive) (if (called-interactively-p) (enh-clear-onmem-cache)) (enh-command-with-auth (let* ((search-alist (enh-get-search-name-attr-alist)) (search-attr (enutil-aget (completing-read "Saved search:" search-alist nil t) search-alist))) (enh-command-update-search (enutil-aget 'guid search-attr) (read-string "New Saved search name:" (enutil-aget 'name search-attr)) (read-string "New Query:" (enutil-aget 'query search-attr))))) (clrhash enh-search-info) (enh-browsing-reflesh-page 'search-list)) (defun evernote-toggle-read-only () (interactive) (if (called-interactively-p) (enh-clear-onmem-cache)) (when evernote-mode (if (string= (or evernote-note-modified-edit-mode (enutil-aget 'editMode (enh-get-note-attr evernote-note-guid))) "XHTML") (if buffer-read-only (progn (setq buffer-read-only nil) (let ((orig-buffer-modified-p (buffer-modified-p))) (erase-buffer) (insert evernote-note-xhtml-mode-content) (goto-char (point-min)) (set-buffer-modified-p orig-buffer-modified-p))) (if (buffer-modified-p) (progn (ding) (message "Save the buffer before you toggle read only")) (setq evernote-note-xhtml-mode-content (buffer-substring (point-min) (point-max))) (erase-buffer) (enh-format-enml evernote-note-xhtml-mode-content (current-buffer)) (goto-char (point-min)) (set-buffer-modified-p nil) (setq buffer-read-only t))) (setq buffer-read-only (not buffer-read-only))) (force-mode-line-update))) (defvar evernote-mode-info-for-changing-major-mode nil "Temporal values used when changing the major mode") (defun evernote-mode-after-save-hook () "After save hook for evernote mode. This invalid evernote-mode" (if evernote-mode (evernote-mode))) (defun evernote-mode-change-major-mode-hook () "Change major mode hook for evernote mode. This records the note info to the global variable to restore them after changing the major mode" (if evernote-mode (setq evernote-mode-info-for-changing-major-mode (list (cons 'guid evernote-note-guid) (cons 'modified-name evernote-note-modified-name) (cons 'modified-notebook-guid evernote-note-modified-notebook-guid) (cons 'is-modified-tag-names evernote-note-is-modified-tag-names) (cons 'modified-tag-names evernote-note-modified-tag-names) (cons 'modified-edit-mode evernote-note-modified-edit-mode) (cons 'note-xhtml-mode-content evernote-note-xhtml-mode-content))))) (defun evernote-mode-after-change-major-mode-hook () "After change major mode hook for evernote mode. This restore the note info after changing the major mode" (if evernote-mode-info-for-changing-major-mode (progn (setq evernote-note-modified-name (enutil-aget 'modified-name evernote-mode-info-for-changing-major-mode)) (setq evernote-note-modified-notebook-guid (enutil-aget 'modified-notebook-guid evernote-mode-info-for-changing-major-mode)) (setq evernote-note-is-modified-tag-names (enutil-aget 'is-modified-tag-names evernote-mode-info-for-changing-major-mode)) (setq evernote-note-modified-tag-names (enutil-aget 'modified-tag-names evernote-mode-info-for-changing-major-mode)) (setq evernote-note-modified-edit-mode (enutil-aget 'modified-edit-mode evernote-mode-info-for-changing-major-mode)) (evernote-mode ; this must be after setting evernote-note-modified-xxx (enutil-aget 'guid evernote-mode-info-for-changing-major-mode)) (setq evernote-note-xhtml-mode-content (enutil-aget 'note-xhtml-mode-content evernote-mode-info-for-changing-major-mode)) (setq evernote-mode-info-for-changing-major-mode nil)))) (add-hook 'after-change-major-mode-hook 'evernote-mode-after-change-major-mode-hook) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Interface for inputing the note name in the minibuffer. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defvar evernote-read-note-map (let ((map (make-sparse-keymap))) (set-keymap-parent map minibuffer-local-completion-map) map)) (define-key evernote-read-note-map [tab] 'evernote-read-note-completion) (define-key evernote-read-note-map "\C-i" 'evernote-read-note-completion) (define-key evernote-read-note-map "\C-m" 'evernote-read-note-finish) (define-key evernote-read-note-map " " 'self-insert-command) (defun evernote-read-note-completion () "Complete note name and display completion list" (interactive) (let (word result start) (setq word (enutil-get-minibuffer-string)) (setq result (try-completion word enh-base-displayed-name-attr-alist)) (cond ((eq result t) (enutil-minibuffer-tmp-message "[Sole Completion]")) ((eq result nil) (ding) (enutil-minibuffer-tmp-message "[No Match]")) ((string= result word) (enh-base-display-note-completion-buf enh-base-displayed-name-formatted-name-alist word)) (t (enutil-set-minibuffer-string result) (end-of-buffer) (if (eq t (try-completion result enh-base-displayed-name-attr-alist)) nil (enutil-minibuffer-tmp-message "[Complete, but not unique]")))))) (defun evernote-read-note-finish () "Finish input note name" (interactive) (if (assoc (enutil-get-minibuffer-string) enh-base-displayed-name-attr-alist) (progn (let ((completion-buf (get-buffer "*Evernote-Completions*"))) (if completion-buf (kill-buffer completion-buf))) (exit-minibuffer)) (enutil-minibuffer-tmp-message "[No Match]"))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Interface for evernote-search-mode. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defvar evernote-search-mode-map (let ((map (make-sparse-keymap))) (set-keymap-parent map global-map) map) "Keymap used in evernote search mode.") (define-key evernote-search-mode-map "\C-m" 'evernote-select-note-in-search-mode) (defvar evernote-search-mode-formatted-name-displayed-name-alist nil "Alist from formatted names to names used only in evernote-search-mode buffer") (make-variable-buffer-local 'evernote-search-mode-formatted-name-displayed-name-alist) (defun evernote-search-mode () "Major mode for selecting a note." (interactive) (use-local-map evernote-search-mode-map) (setq buffer-read-only t truncate-lines t major-mode 'evernote-search-mode mode-name "Evernote-Search") (goto-char (point-min))) (defun evernote-select-note-in-search-mode () "Select a note name on this buffer and input it into the mini buffer" (interactive) (if (active-minibuffer-window) (save-excursion (let (displayed-name) (setq displayed-name (enutil-aget (enutil-get-current-line-string) evernote-search-mode-formatted-name-displayed-name-alist)) (if displayed-name (progn (kill-buffer (current-buffer)) (enutil-set-minibuffer-string displayed-name) (exit-minibuffer))))) (kill-buffer (current-buffer)))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; For Anything ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun anything-c-evernote-title-set-candidates () (let ((buffer (get-buffer enh-command-output-buffer-name)) candidates) (when buffer ; create candidates only when logined. (enh-command-with-auth (setq candidates (enh-command-get-note-attrs-from-query ; Put '*' to match the start of a word. ; Note: A wildcard is only permitted at the end of the term, ; not at the beginning or middle for scalability reasons on the service (format "intitle:\"%s\"*" anything-input)))) candidates))) (defun anything-c-evernote-title-candidate-transformer (candidates) (mapcar (lambda (cand) (cons (enutil-aget 'title cand) cand)) candidates)) (defun anything-c-evernote-title-action (candidate) (enh-base-open-note-common candidate)) (defvar anything-c-source-evernote-title '((name . "Evernote Title") (candidates . anything-c-evernote-title-set-candidates) (candidate-transformer . anything-c-evernote-title-candidate-transformer) (action . (("Open" . anything-c-evernote-title-action))) (volatile) (requires-pattern . 3) (delayed))) (defun anything-evernote-title () "Preconfigured `anything' for searching notes with the note names." (interactive) (anything-other-buffer 'anything-c-source-evernote-title "*anything evernote title*")) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Helper functions for evernote-mode (enh-base-xxx) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defconst enh-base-enml-template (concat "\n" "\n" "\n" "\n")) (defun enh-base-open-note-common (note-attr) "Common procedure of opening a note" (let* ((note-guid (enutil-aget 'guid note-attr)) (note-name (enutil-aget 'title note-attr)) (note-edit-mode (enutil-aget 'editMode note-attr)) (note-content-file (enutil-aget 'contentFile note-attr)) (opened-buf (enh-base-find-opened-buffer note-guid))) (unless note-content-file (setq note-attr (enh-get-note-attr note-guid)) (setq note-content-file (enutil-aget 'contentFile note-attr))) (if opened-buf (enutil-move-cursor-to-window opened-buf t) (let ((buf (generate-new-buffer note-name))) (set-buffer buf) (insert-file-contents note-content-file) (when (string= note-edit-mode "XHTML") (setq evernote-note-xhtml-mode-content (buffer-string)) (erase-buffer) (enh-format-enml evernote-note-xhtml-mode-content (current-buffer)) (setq buffer-read-only t)) (evernote-mode note-guid) ; this must be after (evernote-mode) that setup the change major mode hooks. (enh-base-change-major-mode-from-note-name note-name) (goto-char (point-min)) (set-buffer-modified-p nil) (pop-to-buffer buf))))) (defun enh-base-create-note-common (default-note-name ask-notebook create-new-buffer change-to-evernote-mode &optional use-current-buffer-content) "Common procedure of creating a note" (let ((notebook-guid (and ask-notebook (enutil-aget 'guid (enh-read-notebook)))) (tag-names (enh-read-tag-names)) (name (read-string "Note name:" default-note-name)) (edit-mode (enh-read-edit-mode "TEXT")) content note-attr) (if use-current-buffer-content ;; create a note from a buffer. (progn (setq note-attr (enh-command-create-note (current-buffer) name notebook-guid tag-names edit-mode)) (setq content (buffer-substring (point-min) (point-max)))) ;; create a note from scratch. (if (string= edit-mode "TEXT") ;; edit-mode = TEXT (with-temp-buffer (setq note-attr (enh-command-create-note (current-buffer) name notebook-guid tag-names edit-mode))) (with-temp-buffer ;; edit-mode = XHTML (insert enh-base-enml-template) (setq note-attr (enh-command-create-note (current-buffer) name notebook-guid tag-names edit-mode)) (setq content (buffer-substring (point-min) (point-max)))))) (enh-update-note-and-new-tag-attrs note-attr) (let ((buf nil)) (save-excursion (if create-new-buffer (progn (setq buf (generate-new-buffer name)) (set-buffer buf) (when content (insert content))) (when change-to-evernote-mode (rename-buffer name t))) (when change-to-evernote-mode (set-visited-file-name nil) ; set-visited-file-name must be before (evernote-mode) because it changes the mode line. (enh-base-change-major-mode-from-note-name name) (if (not evernote-mode) (evernote-mode (enutil-aget 'guid note-attr)) (setq evernote-note-guid (enutil-aget 'guid note-attr)) (enh-base-update-mode-line)) (set-buffer-modified-p nil))) buf))) (defun enh-base-update-note-common (inbuf guid &optional name notebook-guid is-tag-updated tag-names edit-mode) "Common procedure of opening a note" (let ((attr (enh-get-note-attr guid))) (setq attr (enh-command-update-note inbuf guid name notebook-guid is-tag-updated tag-names edit-mode)) (enh-update-note-and-new-tag-attrs attr))) (defun enh-base-read-note-attr (note-attrs &optional display-completion) "Prompts a note name and returns a note attribute" (let ((name-num-hash (make-hash-table :test #'equal)) enh-base-displayed-name-attr-alist ; used in evernote-search-mode enh-base-displayed-name-formatted-name-alist) ; used in evernote-search-mode (mapc (lambda (attr) (let (name displayed-name) (setq name (enutil-aget 'title attr)) (setq displayed-name (enh-base-get-displayed-note-name name name-num-hash)) (setq enh-base-displayed-name-attr-alist (cons (cons displayed-name attr) enh-base-displayed-name-attr-alist)) (setq enh-base-displayed-name-formatted-name-alist (cons (cons displayed-name (format "%-30s %-20s %-15s %s" (enutil-aget 'updated attr) (enutil-aget 'name (enh-get-notebook-attr (enutil-aget 'notebookGuid attr))) (enh-tag-guids-to-comma-separated-names (enutil-aget 'tagGuids attr) 15) displayed-name)) enh-base-displayed-name-formatted-name-alist)))) note-attrs) (setq enh-base-displayed-name-attr-alist (nreverse enh-base-displayed-name-attr-alist)) (setq enh-base-displayed-name-formatted-name-alist (nreverse enh-base-displayed-name-formatted-name-alist)) (if display-completion (enh-base-display-note-completion-buf enh-base-displayed-name-formatted-name-alist)) (enutil-aget (read-from-minibuffer "Note:" nil evernote-read-note-map) enh-base-displayed-name-attr-alist))) (defun enh-base-get-displayed-note-name (name name-hash) "Get displayed note name from the read note name" (let ((num (gethash name name-num-hash)) result) (if num (progn (setq num (+ num 1)) (setq result (format "%s(%d)" name num)) (puthash name num name-num-hash)) (setq result (substring name 0)) (puthash name 1 name-num-hash)) result)) (defun enh-base-display-note-completion-buf (displayed-name-formatted-name-alist &optional word) (let (formatted-name-displayed-name-alist completion-buf) (setq formatted-name-displayed-name-alist (mapcar (lambda (displayed-name) (cons (enutil-aget displayed-name enh-base-displayed-name-formatted-name-alist) displayed-name)) (all-completions (if word word "") enh-base-displayed-name-formatted-name-alist))) (save-excursion (setq completion-buf (get-buffer-create "*Evernote-Completions*")) (set-buffer completion-buf) (enh-base-display-note-completion-list formatted-name-displayed-name-alist) (setq evernote-search-mode-formatted-name-displayed-name-alist formatted-name-displayed-name-alist) (evernote-search-mode)) (display-buffer completion-buf))) (defun enh-base-display-note-completion-list (formatted-name-displayed-name-alist) "Display formatted note names on this buffer" (setq buffer-read-only nil) (erase-buffer) (insert (format "total %d\n%-30s %-20s %-15s %s\n\n" (length formatted-name-displayed-name-alist) "Last Modified" "Notebook" "Tags" "Title")) (mapc (lambda (elem) (insert (car elem) "\n")) formatted-name-displayed-name-alist) (setq buffer-read-only t)) (defun enh-base-change-major-mode-from-note-name (note-name) (let ((buffer-file-name note-name)) (normal-mode))) (defun enh-base-find-opened-buffer (guid) "Find a buffer associated with guid" (let ((found_buf nil)) (save-excursion (mapc (lambda (buf) (set-buffer buf) (if (string= evernote-note-guid guid) (setq found_buf buf))) (buffer-list))) found_buf)) (defun enh-base-update-mode-line (&optional notebook-guid is-set-tag-names tag-names edit-mode) "Update mode line" (let ((note-attr (enh-get-note-attr evernote-note-guid))) (setq vc-mode (concat "[Notebook:" (if notebook-guid (enutil-aget 'name (enh-get-notebook-attr notebook-guid)) (enutil-aget 'name (enh-get-notebook-attr (enutil-aget 'notebookGuid note-attr)))) "] " "[Tag:" (if is-set-tag-names (mapconcat #'identity tag-names ",") (enh-tag-guids-to-comma-separated-names (enutil-aget 'tagGuids note-attr))) "] " "[Edit mode:" (if edit-mode edit-mode (enutil-aget 'editMode note-attr)) "]")) (force-mode-line-update))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Helper functions for evernote-browsing-mode (enh-browsing-xxx) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defvar evernote-browsing-mode nil "Non-nil if Evernote Browsing mode is enabled.") (make-variable-buffer-local 'evernote-browsing-mode) (defvar enh-browsing-page-type nil) (make-variable-buffer-local 'enh-browsing-page-type) (defvar enh-browsing-page-description nil) (make-variable-buffer-local 'enh-browsing-page-description) (defvar enh-browsing-page-data nil) (make-variable-buffer-local 'enh-browsing-page-data) (defvar enh-browsing-page-widget-title nil) (make-variable-buffer-local 'enh-browsing-page-widget-title) (defvar enh-browsing-page-widget-root nil) (make-variable-buffer-local 'enh-browsing-page-widget-root) (defvar enh-browsing-page-setup-func nil) (make-variable-buffer-local 'enh-browsing-page-setup-func) (defun enh-browsing-open-notebook (widget &rest ignored) "Open a saved search in browsing mode" (enh-clear-onmem-cache) (let* ((guid (widget-value widget)) note-attrs) (enh-command-with-auth (setq note-attrs (enh-command-get-note-attrs-from-notebook-and-tag-guids guid nil))) (enh-browsing-update-page-list) (enh-browsing-push-page (enh-browsing-create-page 'note-list (format "Notes in Notebook: %s" (enutil-aget 'name (enh-get-notebook-attr guid))) note-attrs)))) (defun enh-browsing-open-tag (widget &rest ignored) "Open a tag in browsing mode" (enh-clear-onmem-cache) (let ((guid (widget-value widget)) note-attrs) (enh-command-with-auth (setq note-attrs (enh-command-get-note-attrs-from-notebook-and-tag-guids nil (if guid (list guid) nil)))) (enh-browsing-update-page-list) (enh-browsing-push-page (enh-browsing-create-page 'note-list (if guid (format "Notes with tag %s" (enutil-aget 'name (enh-get-tag-attr guid))) "All notes") note-attrs)))) (defun enh-browsing-open-search (widget &rest ignored) "Open a saved search in browsing mode" (enh-clear-onmem-cache) (let* ((guid (widget-value widget)) note-attrs) (enh-command-with-auth (setq note-attrs (enh-command-get-note-attrs-from-query (enutil-aget 'query (enh-get-search-attr guid))))) (enh-browsing-update-page-list) (enh-browsing-push-page (enh-browsing-create-page 'note-list (format "Query Result of Saved Search: %s" (enutil-aget 'name (enh-get-search-attr guid))) note-attrs)))) (defun enh-browsing-open-note (widget &rest ignored) "Open a note in browsing mode" (enh-clear-onmem-cache) (enh-command-with-auth (let* ((guid (widget-value widget)) (note-attr (enh-get-note-attr guid)) (cur-buf (current-buffer))) (enh-base-open-note-common note-attr) (let ((command-keys (this-command-keys))) (if (and (stringp command-keys) (or (string= "o" command-keys) (string= "n" command-keys) (string= "p" command-keys))) (enutil-move-cursor-to-window cur-buf t)))))) (defun enh-browsing-push-page (page &optional noswitch) "Push a new page to the browsing mode" (enutil-push page evernote-browsing-page-list) (if noswitch (save-excursion (set-buffer page) (funcall enh-browsing-page-setup-func)) (setq evernote-browsing-current-page page) (switch-to-buffer page) (enh-command-with-auth (funcall enh-browsing-page-setup-func)))) (defun enh-browsing-create-page (type description &optional note-attrs) "Create a page structure of the attr-list" (let ((buf (generate-new-buffer (format "*ENB %s* " description)))) (save-excursion (set-buffer buf) (setq enh-browsing-page-type type enh-browsing-page-description description enh-browsing-page-data note-attrs) (cond ((eq type 'notebook-list) (setq enh-browsing-page-setup-func 'enh-browsing-setup-notebook-list-page)) ((eq type 'tag-list) (setq enh-browsing-page-setup-func 'enh-browsing-setup-tag-list-page)) ((eq type 'search-list) (setq enh-browsing-page-setup-func 'enh-browsing-setup-search-list-page)) ((eq type 'note-list) (setq enh-browsing-page-setup-func 'enh-browsing-setup-note-list-page))) (evernote-browsing-mode)) buf)) (defun enh-browsing-setup-notebook-list-page () "Insert notebook list into the browsing buffer" (when enh-browsing-page-widget-root (widget-delete enh-browsing-page-widget-root) (setq enh-browsing-page-widget-root nil)) (let ((notebook-list nil)) (maphash (lambda (guid attr) (let ((attr (enh-get-notebook-attr guid))) (enutil-push `(push-button :tag ,(format "%-30s %s" (enutil-aget 'name attr) (enutil-aget 'defaultNotebook attr)) :format "%[%t%]\n" :notify enh-browsing-open-notebook ,guid) notebook-list))) (enh-get-notebook-attrs)) (setq enh-browsing-page-widget-root (apply 'widget-create `(group (item ,(format "%s\n\ntotal %d\n%-30s %s\n" enh-browsing-page-description (hash-table-count (enh-get-notebook-attrs)) "Name" "Default")) ,@(nreverse notebook-list))))) (widget-setup) (goto-char (point-min))) (defun enh-browsing-setup-tag-list-page () "Create a page structure of the attr-list" (when enh-browsing-page-widget-root (widget-delete enh-browsing-page-widget-title) (widget-delete enh-browsing-page-widget-root) (setq enh-browsing-page-widget-title nil) (setq enh-browsing-page-widget-root nil)) (let ((guid-children-hash (make-hash-table :test #'equal))) (maphash (lambda (guid attr) (let* ((parent (enutil-aget 'parentGuid attr)) (children (gethash parent guid-children-hash))) (if children (puthash parent (cons guid children) guid-children-hash) (puthash parent (list guid) guid-children-hash)))) (enh-get-tag-attrs)) (setq enh-browsing-page-widget-title (widget-create 'item (format "Tag List\n\ntotal %d\n" (hash-table-count (enh-get-tag-attrs))))) (setq enh-browsing-page-widget-root (apply 'widget-create (enh-browsing-get-tag-tree nil)))) (widget-setup) (goto-char (point-min))) (defun enh-browsing-get-tag-tree (guid) ; root (eq guid nil) (let* ((children (gethash guid guid-children-hash)) (attr (enh-get-tag-attr guid)) (name (if attr (enutil-aget 'name attr) "All tags"))) (if children `(tree-widget :node (push-button :tag ,name :format "%[%t%]\n" :notify enh-browsing-open-tag ,guid) :args ,(mapcar 'enh-browsing-get-tag-tree (nreverse children)) :open ,(if attr nil t)) `(push-button :tag ,name :format "%[%t%]\n" :notify enh-browsing-open-tag ,guid)))) (defun enh-browsing-setup-search-list-page () "Insert saved search list into the browsing buffer" (when enh-browsing-page-widget-root (widget-delete enh-browsing-page-widget-root) (setq enh-browsing-page-widget-root nil)) (let ((search-list nil)) (maphash (lambda (guid attr) (let ((attr (enh-get-search-attr guid))) (enutil-push `(push-button :tag ,(format "%-30s %s" (enutil-aget 'name attr) (enutil-aget 'query attr)) :format "%[%t%]\n" :notify enh-browsing-open-search ,guid) search-list))) (enh-get-search-attrs)) (setq enh-browsing-page-widget-root (apply 'widget-create `(group (item ,(format "%s\n\ntotal %d\n%-30s %s\n" enh-browsing-page-description (hash-table-count (enh-get-search-attrs)) "Name" "Query")) ,@(nreverse search-list))))) (widget-setup) (goto-char (point-min))) (defun enh-browsing-setup-note-list-page () "Insert note list into the browsing buffer" (when enh-browsing-page-widget-root (widget-delete enh-browsing-page-widget-root) (setq enh-browsing-page-widget-root nil)) (let ((note-attrs enh-browsing-page-data) (note-list nil)) (mapc (lambda (attr) (enutil-push `(push-button :tag ,(format "%-30s %-20s %-15s %4s %s" (enutil-aget 'updated attr) (enutil-aget 'name (enh-get-notebook-attr (enutil-aget 'notebookGuid attr))) (enh-tag-guids-to-comma-separated-names (enutil-aget 'tagGuids attr) 15) (enutil-aget 'editMode attr) (enutil-aget 'title attr)) :format "%[%t%]\n" :notify enh-browsing-open-note ,(enutil-aget 'guid attr)) note-list)) note-attrs) (setq enh-browsing-page-widget-root (apply 'widget-create `(group (item ,(format "%s\n\ntotal %d\n%-30s %-20s %-15s %4s %s\n" enh-browsing-page-description (length note-attrs) "Last Modified" "Notebook" "Tags" "Mode" "Name")) ,@(nreverse note-list))))) (widget-setup) (goto-char (point-min))) (defun enh-browsing-update-page-list () (setq evernote-browsing-page-list (delete nil (mapcar (lambda (page) (if (buffer-live-p page) page nil)) evernote-browsing-page-list))) (unless (memq evernote-browsing-current-page evernote-browsing-page-list) (setq evernote-browsing-current-page (car evernote-browsing-page-list)))) (defun enh-browsing-get-prev-page () (cadr (memq evernote-browsing-current-page evernote-browsing-page-list))) (defun enh-browsing-get-next-page () (catch 'next-page (let (next-page) (mapc (lambda (page) (when (eq page evernote-browsing-current-page) (throw 'next-page next-page)) (setq next-page page)) evernote-browsing-page-list)))) (defun enh-browsing-get-page-of-type (type) "Get a page of the type in the browsing mode" (let ((result nil)) (save-excursion (mapc (lambda (page) (set-buffer page) (when (eq enh-browsing-page-type type) (setq result page))) evernote-browsing-page-list)) result)) (defun enh-browsing-reflesh-page (type) "Reflesh current page" (enh-browsing-update-page-list) (save-excursion (mapcar (lambda (page) (set-buffer page) (if (eq enh-browsing-page-type type) (funcall enh-browsing-page-setup-func))) evernote-browsing-page-list))) ; ; ;(defun evernote-test-list-note () ; "Test" ; (interactive) ; (mapc ; (lambda (tag) ; (insert (format "guid=%s name=%s\n" ; (enutil-aget 'guid tag) ; (enutil-aget 'name tag)))) ; (enutil-aget 'tags (enh-command-list-tag)))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Functions for executing the external command (enh-command-xxx) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defvar enh-enclient-command (concat (with-output-to-string (call-process evernote-ruby-command nil standard-output nil "-rrbconfig" "-e" "print Config::CONFIG['bindir']")) "/enclient.rb") "Name of the enclient.rb command") (defconst enh-command-process-name "Evernote-Client") (defconst enh-command-output-buffer-name "*Evernote-Client-Output*") ;; ;; Const variables. ;; (defconst enh-command-error-ok 0) (defconst enh-command-error-not-found 100) (defconst enh-command-error-unexpected 101) (defconst enh-command-error-not-authed 102) (defconst enh-command-error-unknown 1) (defconst enh-command-error-bad-data-format 2) (defconst enh-command-error-permission-denied 3) (defconst enh-command-error-internal-error 4) (defconst enh-command-error-data-required 5) (defconst enh-command-error-limit-reached 6) (defconst enh-command-error-quota-reached 7) (defconst enh-command-error-invalid-auth 8) (defconst enh-command-error-auth-expired 9) (defconst enh-command-error-data-conflict 10) (defconst enh-command-error-enml-validation 11) (defconst enh-command-error-shared-unavailable 12) (defvar enh-command-last-result-code enh-command-error-ok) (defvar enh-command-last-error-message nil) (defvar enh-command-next-command-id 0) (defun enh-command-login (user passwd) "Issue login command" (enh-command-issue (format ":class => %s, :user => %s, :passwd => %s" (enutil-to-ruby-string "AuthCommand") (enutil-to-ruby-string user) (enutil-to-ruby-string passwd)))) (defun enh-command-get-notebook-attrs () "Issue listnotebooks command" (let ((reply (enh-command-issue (format ":class => %s" (enutil-to-ruby-string "ListNotebookCommand"))))) (enutil-aget 'notebooks reply))) (defun enh-command-get-tag-attrs () "Issue listtags command" (let ((reply (enh-command-issue (format ":class => %s" (enutil-to-ruby-string "ListTagCommand"))))) (enutil-aget 'tags reply))) (defun enh-command-get-note-attr (guid) "Issue getnote command from the tag name list." (let ((reply (enh-command-issue (format ":class => %s, :guid => %s" (enutil-to-ruby-string "GetNoteCommand") (enutil-to-ruby-string guid))))) (enutil-aget 'note reply))) (defun enh-command-get-note-attrs-from-notebook-and-tag-guids (notebook-guid tag-guids) "Issue listnotes command from the notebook guid and the tag guids." (message "notebook %s" notebook-guid) (let ((reply (enh-command-issue (format ":class => %s, :notebook_guid => %s, :tag_guids => %s" (enutil-to-ruby-string "ListNoteCommand") (enutil-to-ruby-string notebook-guid) (enutil-to-ruby-string-list tag-guids nil))))) (enutil-aget 'notes reply))) (defun enh-command-get-note-attrs-from-query (query) "Issue listnotes command from the query." (let ((reply (enh-command-issue (format ":class => %s, :query => %s" (enutil-to-ruby-string "SearchNoteCommand") (enutil-to-ruby-string query))))) (enutil-aget 'notes reply))) (defun enh-command-get-note-content (guid edit-mode) "Issue getnotecontent command specified by the guid and the edit mode." (let ((reply (enh-command-issue (format ":class => %s, :guid => %s, :edit_mode => %s" (enutil-to-ruby-string "GetContentCommand") (enutil-to-ruby-string guid) (enutil-to-ruby-string edit-mode))))) (enutil-aget 'content reply))) (defun enh-command-create-note (inbuf name notebook-guid tag-names edit-mode) "Issue createnote command specified by the guid, tags and the edit-mode." (let ((reply (enh-command-issue (format ":class => %s, :notebook_guid => %s, :title => %s, :tag_names => %s, :edit_mode => %s, :content => %s" (enutil-to-ruby-string "CreateNoteCommand") (enutil-to-ruby-string notebook-guid) (enutil-to-ruby-string name) (enutil-to-ruby-string-list tag-names nil) (enutil-to-ruby-string edit-mode) (enutil-to-ruby-string (enutil-buffer-string inbuf)))))) (enutil-aget 'note reply))) (defun enh-command-update-note (inbuf guid name notebook-guid is-tag-updated tag-names edit-mode) "Issue updatenote command specified by the guid and the parameters for updating." (let ((reply (enh-command-issue (format ":class => %s, :guid => %s, :notebook_guid => %s, :title => %s, :tag_names => %s, :edit_mode => %s, :content => %s" (enutil-to-ruby-string "UpdateNoteCommand") (enutil-to-ruby-string guid) (enutil-to-ruby-string notebook-guid) (enutil-to-ruby-string name) (enutil-to-ruby-string-list tag-names is-tag-updated) (enutil-to-ruby-string edit-mode) (enutil-to-ruby-string (enutil-buffer-string inbuf)))))) (enutil-aget 'note reply))) (defun enh-command-delete-note (guid) "Issue deletenote command specified by the guid, tags and the edit mode." (enh-command-issue (format ":class => %s, :guid => %s" (enutil-to-ruby-string "DeleteNoteCommand") (enutil-to-ruby-string guid)))) (defun enh-command-create-notebook (name default-notebook) "Issue createnotebook command" (enh-command-issue (format ":class => %s, :name => %s, :default_notebook => %s" (enutil-to-ruby-string "CreateNotebookCommand") (enutil-to-ruby-string name) (if default-notebook "true" "false")))) (defun enh-command-update-notebook (guid name default-notebook) "Issue updatenotebook command" (enh-command-issue (format ":class => %s, :guid => %s, :name => %s, :default_notebook => %s" (enutil-to-ruby-string "UpdateNotebookCommand") (enutil-to-ruby-string guid) (enutil-to-ruby-string name) (if default-notebook "true" "false")))) (defun enh-command-get-search-attrs () "Issue listsearch command" (let ((reply (enh-command-issue (format ":class => %s" (enutil-to-ruby-string "ListSearchCommand"))))) (enutil-aget 'searches reply))) (defun enh-command-create-search (name query) "Issue createsearch command" (enh-command-issue (format ":class => %s, :name => %s, :query => %s" (enutil-to-ruby-string "CreateSearchCommand") (enutil-to-ruby-string name) (enutil-to-ruby-string query)))) (defun enh-command-update-search (guid name query) "Issue updatesearch command" (enh-command-issue (format ":class => %s, :guid => %s, :name => %s, :query => %s" (enutil-to-ruby-string "UpdateSearchCommand") (enutil-to-ruby-string guid) (enutil-to-ruby-string name) (enutil-to-ruby-string query)))) (defun enh-command-issue (command) (enh-command-setup-process) (let ((proc (get-process enh-command-process-name)) (reply nil) (buffer (get-buffer enh-command-output-buffer-name))) (message "Waiting for the result...") (save-excursion (set-buffer buffer) (erase-buffer) ;(delete-region (point-min) (point-max)) (setq enh-command-next-command-id (+ 1 enh-command-next-command-id)) (process-send-string proc (format "{%s, :command_id => %d}" command enh-command-next-command-id)) (process-send-string proc "\x00\n") (while (or (not reply) (enutil-neq (enutil-aget 'command_id reply) enh-command-next-command-id)) (accept-process-output proc) (setq reply (enutil-get-first-sexp-in-buffer)))) (message "") (if (eq (enutil-aget 'class reply) 'ErrorReply) (progn (setq enh-command-last-result-code (enutil-aget 'result_code reply)) (setq enh-command-last-error-message (enutil-aget 'message reply)) (throw 'error enh-command-last-result-code)) (setq enh-command-last-result-code enh-command-error-ok) reply))) (defun enh-command-sentinel (process event) (error "enclient.rb %s%s" event (with-current-buffer enh-command-output-buffer-name (buffer-string)))) (defun enh-command-setup-process () (let ((proc (get-process enh-command-process-name)) (process-connection-type nil)) ; use pipe instead of pty (when (or (not proc) (not (eq (process-status proc) 'run))) (setq proc (start-process enh-command-process-name enh-command-output-buffer-name evernote-ruby-command "-S" enh-enclient-command)) (set-process-sentinel proc 'enh-command-sentinel) (set-process-coding-system proc 'utf-8 'utf-8) (set-process-query-on-exit-flag proc nil)))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Helper functions for all modes in this file (enh-xxx) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defvar enh-notebook-info (make-hash-table :test #'equal) "Notebook info associated with the guid") (defvar enh-tag-info (make-hash-table :test #'equal) "Tag info associated with the guid") (defvar enh-search-info (make-hash-table :test #'equal) "Saved search info associated with the guid") (defvar enh-note-attr nil "Note attr associated with most recently accessed guid") (defvar enh-password-cache-file "~/.evernote-mode/password.gpg" "Filename of saving password cache.") (defvar enh-password-cache-buffer " *evernote-password-cache*") (defun enh-get-notebook-attrs () (when (eq (hash-table-count enh-notebook-info) 0) (mapc (lambda (attr) (puthash (enutil-aget 'guid attr) attr enh-notebook-info)) (enh-command-get-notebook-attrs))) enh-notebook-info) (defun enh-get-tag-attrs () (when (eq (hash-table-count enh-tag-info) 0) (mapc (lambda (attr) (puthash (enutil-aget 'guid attr) attr enh-tag-info)) (enh-command-get-tag-attrs))) enh-tag-info) (defun enh-get-search-attrs () (when (eq (hash-table-count enh-search-info) 0) (mapc (lambda (attr) (puthash (enutil-aget 'guid attr) attr enh-search-info)) (enh-command-get-search-attrs))) enh-search-info) (defun enh-get-note-attr (guid) "Get the note attr from the guid" (if (and enh-note-attr (string= guid (enutil-aget 'guid enh-note-attr))) enh-note-attr (setq enh-note-attr (enh-command-get-note-attr guid)))) (defun enh-get-notebook-attr (guid) "Get the notebook attr from the guid" (gethash guid (enh-get-notebook-attrs))) (defun enh-get-tag-attr (guid) "Get the tag attr from the guid" (gethash guid (enh-get-tag-attrs))) (defun enh-get-search-attr (guid) "Get the search attr from the guid" (gethash guid (enh-get-search-attrs))) (defun enh-read-tag-guids (&optional prompt) (enh-tag-names-to-guids (enutil-completing-read-multiple (if prompt prompt "Tags (comma separated form):") (enh-get-tag-name-alist) nil t))) (defun enh-read-tag-names (&optional prompt note-guid) (enutil-completing-read-multiple (if prompt prompt "Tags (comma separated form):") (enh-get-tag-name-alist) nil nil (if note-guid (enh-tag-guids-to-comma-separated-names (enutil-aget 'tagGuids (enh-get-note-attr note-guid))) nil))) (defun enh-format-enml (content outbuf) (if evernote-enml-formatter-command (let ((infile (concat (make-temp-file "evernote-enml") ".html")) (command (car evernote-enml-formatter-command)) (args (cdr evernote-enml-formatter-command))) (setq args (append args (list infile))) (with-temp-buffer (insert content) (write-region (point-min) (point-max) infile) (message "") ; remove the message notifying writing to tmp file. (let ((coding-system-for-read 'utf-8) (coding-system-for-write 'utf-8)) (apply 'call-process command infile outbuf nil args)))) (save-excursion ; insert the content as is. (set-buffer outbuf) (insert content)))) (defun enh-clear-onmem-cache () (clrhash enh-notebook-info) (clrhash enh-tag-info) (clrhash enh-search-info) (setq enh-note-attr nil)) (defun enh-read-notebook (&optional default) (let ((notebook-name-attr-alist (enh-get-notebook-name-attr-alist))) (enutil-aget (completing-read "Notebook:" notebook-name-attr-alist nil t default) notebook-name-attr-alist))) (defun enh-read-saved-search (&optional prompt) (let ((search-name-query-alist (enh-get-search-name-attr-alist))) (enutil-aget (completing-read (if prompt prompt "Saved search:") search-name-query-alist nil t) search-name-query-alist))) (defun enh-get-notebook-name-attr-alist () "Get the notebook alist for completion from command output" (let (result) (maphash (lambda (guid attr) (setq result (cons (cons (enutil-aget 'name attr) attr) result))) (enh-get-notebook-attrs)) result)) (defun enh-get-tag-name-alist () "Get the tag alist for completion from command output" (let (result) (maphash (lambda (guid attr) (setq result (cons (list (enutil-aget 'name attr)) result))) (enh-get-tag-attrs)) result)) (defun enh-get-search-name-attr-alist () "Get the alist for completion from command output" (let (result) (maphash (lambda (guid attr) (setq result (cons (cons (enutil-aget 'name attr) attr) result))) (enh-get-search-attrs)) result)) (defun enh-update-note-and-new-tag-attrs (note-attr) (let ((tag-guids (enutil-aget 'tagGuids note-attr)) (tag-attrs (enh-get-tag-attrs))) (when (catch 'result (mapc (lambda (guid) (unless (gethash guid tag-attrs) (throw 'result t))) tag-guids) nil) (enh-clear-onmem-cache) (enh-browsing-reflesh-page 'tag-list)))) (defun enh-tag-guids-to-comma-separated-names (tag-guids &optional maxlen) (let (line) (setq line (mapconcat (lambda (guid) (enutil-aget 'name (enh-get-tag-attr guid))) tag-guids ",")) (if maxlen (truncate-string-to-width line maxlen) line))) (defun enh-tag-names-to-comma-separated-oct-names (tag-names) (mapconcat #'identity (mapcar 'enutil-string-to-oct tag-names) ",")) ;;(defun enh-tag-guids-to-names (tag-guids) ;; (mapcar ;; (lambda (tag-guid) ;; (enutil-aget 'name (enh-get-tag-attr tag-guid))) ;; tag-guids)) (defun enh-notebook-name-to-guid (notebook-name) (let ((notebook-attrs (enh-get-notebook-attrs))) (catch 'guid (maphash (lambda (guid attr) (let ((name (enutil-aget 'name attr))) (if (equal notebook-name name) (throw 'guid guid)))) notebook-attrs)))) (defun enh-tag-names-to-guids (tag-names) (let ((tag-attrs (enh-get-tag-attrs))) (mapcar (lambda (name) (catch 'guid (maphash (lambda (guid attr) (let ((tag-name (enutil-aget 'name attr))) (if (equal tag-name name) (throw 'guid guid)))) tag-attrs))) tag-names))) (defun enh-read-edit-mode (default) (let ((edit-mode (completing-read "Edit mode (type \"TEXT\" or \"XHTML\"):" '(("TEXT") ("XHTML")) nil t default))) (if (and edit-mode (not (string= edit-mode ""))) edit-mode default))) (defun enh-bookmark-make-record () "Make a emacs bookmark entry for a evernote buffer." `(,(buffer-name) ,@(bookmark-make-record-default 'no-file) ;; if bookmark-bmenu-toggle-filenames is t and a bookmark record doesn't ;; have filename field, , Emacs23.2 raises an error. ;; Here is the workaround suggested by ARISAWA Akihiro. (filename . ,(format "%s (evernote:%s)" (buffer-name) evernote-note-guid)) (handler . enh-bookmark-jump))) (defun enh-bookmark-jump (bookmark) ;; Note: don't rename this function for the bookmark file compatibility "Default bookmark handler for evernote buffers." (enh-command-with-auth (let ((filename (bookmark-get-filename bookmark))) (if (and filename (string-match "(evernote:\\(.*\\))$" filename)) (progn (let* ((guid (substring filename (match-beginning 1) (match-end 1))) (attr (enh-command-get-note-attr guid))) (enh-base-open-note-common attr) (let ((buf (current-buffer))) (bookmark-default-handler `("" (buffer . ,buf) . ,(bookmark-get-bookmark-record bookmark)))))) (message (format "Invalid bookmark %s" (bookmark-name-from-full-record bookmark))))))) (defun enh-bookmark-prepare () (interactive) (set (make-local-variable 'bookmark-make-record-function) 'enh-bookmark-make-record)) (defun enh-password-cache-load () "Load the password cache from the file" (when (and evernote-password-cache (file-exists-p enh-password-cache-file)) (with-current-buffer (get-buffer-create enh-password-cache-buffer) (insert-file-contents enh-password-cache-file) (read (current-buffer))))) (defun enh-password-cache-save (user-password) "Save the password cache to the file" (when evernote-password-cache (with-current-buffer (get-buffer-create enh-password-cache-buffer) (write-region (prin1-to-string user-password) nil enh-password-cache-file)))) (defun enh-password-cache-close () "Close the password cache buffer" (when (get-buffer enh-password-cache-buffer) (kill-buffer enh-password-cache-buffer))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; General util functions (enutil-xxx) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun enutil-completing-read-multiple (prompt table &optional predicate require-match initial-input hist def inherit-input-method) "Read multiple strings with completion. and return nil if no input is given" (let (results) (setq results (completing-read-multiple prompt table predicate require-match initial-input hist def inherit-input-method)) (delete "" results))) (defun enutil-aget (key alist) (let ((result-cons (assoc key alist))) (when result-cons (cdr result-cons)))) (defun enutil-aset (key alist value) (let ((result-cons (assoc key alist))) (if result-cons (setcdr result-cons value) (setq alist (cons (cons key value) alist))) alist)) (defun enutil-get-current-line-string () (save-excursion (buffer-substring (progn (beginning-of-line) (point)) (progn (end-of-line) (point))))) (defun enutil-erase-buffer-forcibly () (let ((buffer-read-only nil)) (erase-buffer))) (defun enutil-get-first-line (str) "Get first line of the string" (let ((begin (string-match "^.*$" str))) (substring str begin (match-end 0)))) (defun enutil-get-minibuffer-string () (save-excursion (enutil-set-buffer-to-minibuffer) (buffer-substring (progn (goto-char (+ 1 (minibuffer-prompt-width))) (point)) (progn (end-of-line) (point))))) (defun enutil-set-minibuffer-string (str) (save-excursion (enutil-set-buffer-to-minibuffer) (delete-region (progn (goto-char (+ 1 (minibuffer-prompt-width))) (point)) (progn (end-of-line) (point))) (insert str))) (defun enutil-set-buffer-to-minibuffer () (set-buffer (window-buffer (active-minibuffer-window)))) (defun enutil-minibuffer-tmp-message (msg) (save-excursion (goto-char (point-max)) (save-excursion (insert " " msg)) (sit-for 1) (delete-region (point) (point-max)))) (defun enutil-move-cursor-to-window (buf &optional pop) "Move cursor to the window associated with the bufer" (let ((buf-window (get-buffer-window buf))) (if buf-window (select-window buf-window) (if pop (pop-to-buffer buf) (switch-to-buffer buf))))) (defun enutil-get-first-sexp-in-buffer () (condition-case nil (car (read-from-string (buffer-substring (point-min) (point-max)))) (error nil))) (defun enutil-hash-mapcar (func hash) (let (result) (maphash (lambda (key value) (cons (funcall func key value) result))) (nreverse result))) (defun enutil-to-ruby-string (str) (if str (progn (setq str (replace-regexp-in-string "\\\\" "\\\\\\\\" str)) (setq str (replace-regexp-in-string "'" "\\\\'" str)) (concat "'" str "'")) "nil")) (defun enutil-to-ruby-string-list (str-list return-empty-array) (if str-list (concat "[" (mapconcat #'enutil-to-ruby-string str-list ",") "]") (if return-empty-array "[]" "nil"))) (defun enutil-buffer-string (buf) (save-excursion (set-buffer buf) (buffer-string))) (provide 'evernote-mode) ;;(setq debug-on-error t) ;; Local Variables: ;; indent-tabs-mode: nil ;; End: