Protobuf file location refactoring part 3.
This is a series of CLs to move *.proto files into protocol/ directory.
Following file will be moved in this CL.
- user_dictionary_storage.proto
This is just a refactoring. No user-visible behavior change should occur.
BUG=none
TEST=unittest
Hiroyuki Komatsu authored 8 years ago
Yohei Yukawa committed 8 years ago
175 | 175 | 'type': 'none', |
176 | 176 | 'variables': { |
177 | 177 | 'proto_files': [ |
178 | '../dictionary/user_dictionary_storage.proto', | |
178 | '../protocol/user_dictionary_storage.proto', | |
179 | 179 | ], |
180 | 180 | }, |
181 | 181 | 'actions': [ |
65 | 65 | '../base/base.gyp:base', |
66 | 66 | '../config/config.gyp:config_handler', |
67 | 67 | '../config/config.gyp:config_protocol', |
68 | 'dictionary_base.gyp:dictionary_protocol', | |
68 | '../protocol/protocol.gyp:user_dictionary_storage_proto', | |
69 | 69 | 'dictionary_base.gyp:pos_matcher', |
70 | 70 | 'dictionary_base.gyp:suppression_dictionary', |
71 | 71 | ], |
112 | 112 | ], |
113 | 113 | }, |
114 | 114 | { |
115 | 'target_name': 'genproto_dictionary', | |
116 | 'type': 'none', | |
117 | 'toolsets': ['host'], | |
118 | 'sources': [ | |
119 | 'user_dictionary_storage.proto', | |
120 | ], | |
121 | 'includes': [ | |
122 | '../protobuf/genproto.gypi', | |
123 | ], | |
124 | }, | |
125 | { | |
126 | 'target_name': 'dictionary_protocol', | |
127 | 'type': 'static_library', | |
128 | 'hard_dependency': 1, | |
129 | 'sources': [ | |
130 | '<(proto_out_dir)/<(relative_dir)/user_dictionary_storage.pb.cc', | |
131 | ], | |
132 | 'dependencies': [ | |
133 | '../protobuf/protobuf.gyp:protobuf', | |
134 | 'genproto_dictionary#host', | |
135 | ], | |
136 | 'export_dependent_settings': [ | |
137 | 'genproto_dictionary#host', | |
138 | ], | |
139 | }, | |
140 | { | |
141 | 115 | 'target_name': 'gen_pos_map', |
142 | 116 | 'type': 'none', |
143 | 117 | 'toolsets': ['host'], |
199 | 173 | '../base/base.gyp:config_file_stream', |
200 | 174 | '../config/config.gyp:config_handler', |
201 | 175 | '../config/config.gyp:config_protocol', |
176 | '../protocol/protocol.gyp:user_dictionary_storage_proto', | |
202 | 177 | '../usage_stats/usage_stats_base.gyp:usage_stats', |
203 | 'dictionary_protocol', | |
204 | 178 | 'gen_pos_map#host', |
205 | 179 | 'pos_matcher', |
206 | 180 | 'suppression_dictionary', |
38 | 38 | #include "dictionary/dictionary_interface.h" |
39 | 39 | #include "dictionary/pos_matcher.h" |
40 | 40 | #include "dictionary/suppression_dictionary.h" |
41 | #include "dictionary/user_dictionary_storage.pb.h" | |
42 | 41 | #include "dictionary/user_pos_interface.h" |
42 | #include "protocol/user_dictionary_storage.pb.h" | |
43 | 43 | |
44 | 44 | namespace mozc { |
45 | 45 |
33 | 33 | |
34 | 34 | #include "base/port.h" |
35 | 35 | #include "base/string_piece.h" |
36 | #include "dictionary/user_dictionary_storage.pb.h" | |
36 | #include "protocol/user_dictionary_storage.pb.h" | |
37 | 37 | |
38 | 38 | namespace mozc { |
39 | 39 |
31 | 31 | |
32 | 32 | #include "base/flags.h" |
33 | 33 | #include "dictionary/user_dictionary_importer.h" |
34 | #include "dictionary/user_dictionary_storage.pb.h" | |
34 | #include "protocol/user_dictionary_storage.pb.h" | |
35 | 35 | |
36 | 36 | int main(int argc, char **argv) { |
37 | 37 | InitGoogle(argv[0], &argc, &argv, false); |
36 | 36 | #include "base/protobuf/repeated_field.h" |
37 | 37 | #include "dictionary/user_dictionary_importer.h" |
38 | 38 | #include "dictionary/user_dictionary_storage.h" |
39 | #include "dictionary/user_dictionary_storage.pb.h" | |
40 | 39 | #include "dictionary/user_dictionary_util.h" |
40 | #include "protocol/user_dictionary_storage.pb.h" | |
41 | 41 | |
42 | 42 | namespace mozc { |
43 | 43 | namespace user_dictionary { |
33 | 33 | |
34 | 34 | #include "base/scoped_ptr.h" |
35 | 35 | #include "base/port.h" |
36 | #include "dictionary/user_dictionary_storage.pb.h" | |
36 | #include "protocol/user_dictionary_storage.pb.h" | |
37 | 37 | |
38 | 38 | namespace mozc { |
39 | 39 |
36 | 36 | #include "base/scoped_ptr.h" |
37 | 37 | #include "base/util.h" |
38 | 38 | #include "dictionary/user_dictionary_session.h" |
39 | #include "dictionary/user_dictionary_storage.pb.h" | |
40 | 39 | #include "dictionary/user_dictionary_util.h" |
40 | #include "protocol/user_dictionary_storage.pb.h" | |
41 | 41 | |
42 | 42 | namespace mozc { |
43 | 43 | namespace user_dictionary { |
36 | 36 | #include "base/protobuf/protobuf.h" |
37 | 37 | #include "base/protobuf/repeated_field.h" |
38 | 38 | #include "base/system_util.h" |
39 | #include "dictionary/user_dictionary_storage.pb.h" | |
39 | #include "protocol/user_dictionary_storage.pb.h" | |
40 | 40 | #include "testing/base/public/gunit.h" |
41 | 41 | #include "testing/base/public/testing_util.h" |
42 | 42 |
34 | 34 | |
35 | 35 | #include "base/file_util.h" |
36 | 36 | #include "base/system_util.h" |
37 | #include "dictionary/user_dictionary_storage.pb.h" | |
38 | 37 | #include "dictionary/user_dictionary_storage.h" |
38 | #include "protocol/user_dictionary_storage.pb.h" | |
39 | 39 | #include "testing/base/public/gunit.h" |
40 | 40 | #include "testing/base/public/testing_util.h" |
41 | 41 |
63 | 63 | #include <string> |
64 | 64 | #include "base/port.h" |
65 | 65 | #include "base/scoped_ptr.h" |
66 | #include "dictionary/user_dictionary_storage.pb.h" | |
66 | #include "protocol/user_dictionary_storage.pb.h" | |
67 | 67 | |
68 | 68 | namespace mozc { |
69 | 69 |
0 | // Copyright 2010-2015, Google Inc. | |
1 | // All rights reserved. | |
2 | // | |
3 | // Redistribution and use in source and binary forms, with or without | |
4 | // modification, are permitted provided that the following conditions are | |
5 | // met: | |
6 | // | |
7 | // * Redistributions of source code must retain the above copyright | |
8 | // notice, this list of conditions and the following disclaimer. | |
9 | // * Redistributions in binary form must reproduce the above | |
10 | // copyright notice, this list of conditions and the following disclaimer | |
11 | // in the documentation and/or other materials provided with the | |
12 | // distribution. | |
13 | // * Neither the name of Google Inc. nor the names of its | |
14 | // contributors may be used to endorse or promote products derived from | |
15 | // this software without specific prior written permission. | |
16 | // | |
17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
18 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
19 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
20 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
21 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
22 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
23 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
24 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
25 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
26 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
27 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
28 | ||
29 | syntax = "proto2"; | |
30 | ||
31 | package mozc.user_dictionary; | |
32 | ||
33 | option java_outer_classname = "ProtoUserDictionaryStorage"; | |
34 | option java_package = "org.mozc.android.inputmethod.japanese.protobuf"; | |
35 | ||
36 | message UserDictionary { | |
37 | enum PosType { | |
38 | NOUN = 1; // "名詞" | |
39 | ABBREVIATION = 2; // "短縮よみ" | |
40 | SUGGESTION_ONLY = 3; // "サジェストのみ" | |
41 | PROPER_NOUN = 4; // "固有名詞" | |
42 | PERSONAL_NAME = 5; // "人名" | |
43 | FAMILY_NAME = 6; // "姓" | |
44 | FIRST_NAME = 7; // "名" | |
45 | ORGANIZATION_NAME = 8; // "組織" | |
46 | PLACE_NAME = 9; // "地名" | |
47 | SA_IRREGULAR_CONJUGATION_NOUN = 10; // "名詞サ変" | |
48 | ADJECTIVE_VERBAL_NOUN = 11; // "名詞形動" | |
49 | NUMBER = 12; // "数" | |
50 | ALPHABET = 13; // "アルファベット" | |
51 | SYMBOL = 14; // "記号" | |
52 | EMOTICON = 15; // "顔文字" | |
53 | ||
54 | ADVERB = 16; // "副詞" | |
55 | PRENOUN_ADJECTIVAL = 17; // "連体詞" | |
56 | CONJUNCTION = 18; // "接続詞" | |
57 | INTERJECTION = 19; // "感動詞" | |
58 | ||
59 | PREFIX = 20; // "接頭語" | |
60 | COUNTER_SUFFIX = 21; // "助数詞" | |
61 | GENERIC_SUFFIX = 22; // "接尾一般" | |
62 | PERSON_NAME_SUFFIX = 23; // "接尾人名" | |
63 | PLACE_NAME_SUFFIX = 24; // "接尾地名" | |
64 | ||
65 | WA_GROUP1_VERB = 25; // "動詞ワ行五段" | |
66 | KA_GROUP1_VERB = 26; // "動詞カ行五段" | |
67 | SA_GROUP1_VERB = 27; // "動詞サ行五段" | |
68 | TA_GROUP1_VERB = 28; // "動詞タ行五段" | |
69 | NA_GROUP1_VERB = 29; // "動詞ナ行五段" | |
70 | MA_GROUP1_VERB = 30; // "動詞マ行五段" | |
71 | RA_GROUP1_VERB = 31; // "動詞ラ行五段" | |
72 | GA_GROUP1_VERB = 32; // "動詞ガ行五段" | |
73 | BA_GROUP1_VERB = 33; // "動詞バ行五段" | |
74 | HA_GROUP1_VERB = 34; // "動詞ハ行四段" | |
75 | GROUP2_VERB = 35; // "動詞一段" | |
76 | KURU_GROUP3_VERB = 36; // "動詞カ変" | |
77 | SURU_GROUP3_VERB = 37; // "動詞サ変" | |
78 | ZURU_GROUP3_VERB = 38; // "動詞ザ変" | |
79 | RU_GROUP3_VERB = 39; // "動詞ラ変" | |
80 | ||
81 | ADJECTIVE = 40; // "形容詞" | |
82 | SENTENCE_ENDING_PARTICLE = 41; // "終助詞" | |
83 | PUNCTUATION = 42; // "句読点" | |
84 | FREE_STANDING_WORD = 43; // "独立語" | |
85 | ||
86 | SUPPRESSION_WORD = 44; // "抑制単語" | |
87 | }; | |
88 | ||
89 | // ID of this dictionary | |
90 | optional uint64 id = 1 [ default = 0 ]; | |
91 | ||
92 | // set false if this dictionary is not used. | |
93 | // Even if |enabled| is false, the dictionary | |
94 | // it self is visible to user. | |
95 | optional bool enabled = 2 [ default = true ]; | |
96 | ||
97 | // name of dictionary | |
98 | optional string name = 3 [ default = "" ]; | |
99 | ||
100 | // entry of each word | |
101 | message Entry { | |
102 | optional string key = 1 [ default = "" ]; | |
103 | optional string value = 2 [ default = "" ]; | |
104 | // Do NOT use tag number '3' in this proto. Please see below. | |
105 | optional string comment = 4 [ default = "" ]; | |
106 | ||
107 | // Historically we used to use tag number '3' for POS in string format. | |
108 | // In order to switch it to enum based POS, we removed (deprecated) the | |
109 | // tag number '3' field and created another field numbered '5'. | |
110 | optional PosType pos = 5; | |
111 | ||
112 | // set true if this entry is removed. | |
113 | // This flag is used for cloud sync feature. | |
114 | // Cloud sync feature is already deprecated and this flag is only | |
115 | // used to convert sync dictionary to normal dictionary. | |
116 | optional bool removed = 10 [ default = false ]; | |
117 | ||
118 | // set true if this entry is automatically registered | |
119 | // by converter. | |
120 | optional bool auto_registered = 11 [ default = false ]; | |
121 | }; | |
122 | ||
123 | repeated Entry entries = 4; | |
124 | ||
125 | // set true if this dictionary is removed. | |
126 | // This flag is used for cloud sync feature. | |
127 | // Cloud sync feature is already deprecated and this flag is only | |
128 | // used to convert sync dictionary to normal dictionary. | |
129 | optional bool removed = 5 [ default = false ]; | |
130 | ||
131 | // This flag is used for cloud sync feature. | |
132 | // Cloud sync feature is already deprecated and this flag is only | |
133 | // used to convert sync dictionary to normal dictionary. | |
134 | optional bool syncable = 6 [ default = false ]; | |
135 | }; | |
136 | ||
137 | message UserDictionaryStorage { | |
138 | // version of user dictionary | |
139 | optional int32 version = 1 [ default = 0 ]; | |
140 | ||
141 | // dictionary body | |
142 | repeated UserDictionary dictionaries = 2; | |
143 | ||
144 | enum StorageType { | |
145 | SNAPSHOT = 1; // This storage is a snapshot. | |
146 | UPDATE = 2; // This storage is a diff of some snapshots. | |
147 | }; | |
148 | ||
149 | optional StorageType storage_type = 10 [ default = SNAPSHOT ]; | |
150 | }; | |
151 | ||
152 | message UserDictionaryCommand { | |
153 | enum CommandType { | |
154 | // Does nothing. | |
155 | NO_OPERATION = 0; | |
156 | ||
157 | // Unlink the user dictionary file if necessary. | |
158 | // We can do this operation without creating a session. | |
159 | // This operation is introduced as a last resort to clean up | |
160 | // user dictionary, so it *forces* to unlink the file regardless | |
161 | // of the current user dictionary session status. | |
162 | CLEAR_STORAGE = 1; | |
163 | ||
164 | // Creates a new session, and returns its id via | |
165 | // UserDictionaryCommandStatus::session_id. | |
166 | CREATE_SESSION = 2; | |
167 | ||
168 | // Deletes the session identified by session_id. | |
169 | DELETE_SESSION = 3; | |
170 | ||
171 | // Sets the default dictionary name. It will be used when | |
172 | // ensure_non_empty_storage is enabled and the operation supporting the | |
173 | // flag is invoked. | |
174 | SET_DEFAULT_DICTIONARY_NAME = 4; | |
175 | ||
176 | // Checks if the session is currently undoable or not. | |
177 | CHECK_UNDOABILITY = 5; | |
178 | ||
179 | // Undoes the last operation. | |
180 | UNDO = 6; | |
181 | ||
182 | // Loads from local storage. | |
183 | LOAD = 7; | |
184 | ||
185 | // Saves to local storage. | |
186 | SAVE = 8; | |
187 | ||
188 | // Returns a list of name and dictionary-id pairs. | |
189 | // They are filled in the form of UserDictionary without any entries | |
190 | // in UserDictionaryCommandStatus::storage. | |
191 | GET_USER_DICTIONARY_NAME_LIST = 9; | |
192 | ||
193 | // Returns the number of entries in the dictionary with the | |
194 | // given dictionary_id. | |
195 | GET_ENTRY_SIZE = 10; | |
196 | ||
197 | // Use GET_ENTRIES instead. | |
198 | OBSOLETE_GET_ENTRY = 11; | |
199 | ||
200 | // Returns if it is possible to add new dictionary or not. | |
201 | // The result is returned by using status code. | |
202 | CHECK_NEW_DICTIONARY_AVAILABILITY = 12; | |
203 | ||
204 | // Creates a new dictionary with the dictionary_name. | |
205 | CREATE_DICTIONARY = 13; | |
206 | ||
207 | // Deletes the dictionary with the given dictionary_id. | |
208 | DELETE_DICTIONARY = 14; | |
209 | ||
210 | // Renames the dictionary with the given dictionary_id to dictionary_name. | |
211 | RENAME_DICTIONARY = 15; | |
212 | ||
213 | // Returns if it is possible to add new entry to the dictionary | |
214 | // with the given dictionary_id or not. | |
215 | CHECK_NEW_ENTRY_AVAILABILITY = 16; | |
216 | ||
217 | // Adds an entry to the dictionary with the given dictionary_id. | |
218 | // Added entry should be located at the end of the dictionary, and | |
219 | // the data should be passed via entry field. | |
220 | ADD_ENTRY = 17; | |
221 | ||
222 | // Edits an entry in the dictionary with the given dictionary_id. | |
223 | // The new data should be passed via entry. | |
224 | // The edit target should be specified via entry_index(0). | |
225 | EDIT_ENTRY = 18; | |
226 | ||
227 | // Deletes entries in the dictionary with the given dictionary_id. | |
228 | // The target entries should be specified based on index in entry_index. | |
229 | DELETE_ENTRY = 19; | |
230 | ||
231 | // Imports entries from the given data into a dictionary. | |
232 | // There are two ways to specify the dictionary: | |
233 | // 1) set dictionary_id for the dictionary | |
234 | // 2) set dictionary_name to create a new dictionary with the name. | |
235 | IMPORT_DATA = 20; | |
236 | ||
237 | // Gets the entire UserDictionaryStorage data. | |
238 | // Note: The result of this command could be too large for IPC, which has a | |
239 | // size limitation of the response data. | |
240 | GET_STORAGE = 21; | |
241 | ||
242 | // Returns entries in the dictionary specified by dictionary_id. | |
243 | // The position of the entry should be specified via entry_index(). | |
244 | GET_ENTRIES = 22; | |
245 | }; | |
246 | ||
247 | required CommandType type = 1; | |
248 | optional uint64 session_id = 2; | |
249 | optional uint64 dictionary_id = 3; | |
250 | optional string dictionary_name = 4; | |
251 | repeated int32 entry_index = 5; | |
252 | optional UserDictionary.Entry entry = 6; | |
253 | optional string data = 7; | |
254 | optional bool ensure_non_empty_storage = 8; | |
255 | }; | |
256 | ||
257 | message UserDictionaryCommandStatus { | |
258 | // Note: this status code is now temporary assgined. | |
259 | // It may be updated (incl. re-numbering) to organize the code. | |
260 | // I.e., the code shouldn't be saved in serialized format for now. | |
261 | // TODO(hidehiko): Re-organize and re-number the enum values, | |
262 | // after we check all necessary codes in. | |
263 | enum Status { | |
264 | // Note: SUCCEEDED is conflicting Windows MACRO. | |
265 | USER_DICTIONARY_COMMAND_SUCCESS = 1; | |
266 | UNKNOWN_ERROR = 2; | |
267 | ||
268 | UNKNOWN_COMMAND = 3; | |
269 | INVALID_ARGUMENT = 4; | |
270 | ||
271 | UNKNOWN_SESSION_ID = 5; | |
272 | ||
273 | FILE_NOT_FOUND = 6; | |
274 | INVALID_FILE_FORMAT = 7; | |
275 | ||
276 | // Note: currently if we recieve this error status, | |
277 | // the file is actually saved. | |
278 | FILE_SIZE_LIMIT_EXCEEDED = 8; | |
279 | DICTIONARY_SIZE_LIMIT_EXCEEDED = 9; | |
280 | ENTRY_SIZE_LIMIT_EXCEEDED = 10; | |
281 | ||
282 | UNKNOWN_DICTIONARY_ID = 11; | |
283 | ENTRY_INDEX_OUT_OF_RANGE = 12; | |
284 | ||
285 | // Errors for dictionary names. | |
286 | DICTIONARY_NAME_EMPTY = 13; | |
287 | DICTIONARY_NAME_TOO_LONG = 14; | |
288 | DICTIONARY_NAME_CONTAINS_INVALID_CHARACTER = 15; | |
289 | DICTIONARY_NAME_DUPLICATED = 16; | |
290 | ||
291 | // Errors for entry data. | |
292 | READING_EMPTY = 17; | |
293 | READING_TOO_LONG = 18; | |
294 | READING_CONTAINS_INVALID_CHARACTER = 19; | |
295 | WORD_EMPTY = 20; | |
296 | WORD_TOO_LONG = 21; | |
297 | WORD_CONTAINS_INVALID_CHARACTER = 22; | |
298 | INVALID_POS_TYPE = 23; | |
299 | COMMENT_TOO_LONG = 24; | |
300 | COMMENT_CONTAINS_INVALID_CHARACTER = 25; | |
301 | ||
302 | // Errors for importing. | |
303 | IMPORT_TOO_MANY_WORDS = 26; | |
304 | IMPORT_INVALID_ENTRIES = 27; | |
305 | ||
306 | NO_UNDO_HISTORY = 28; | |
307 | }; | |
308 | ||
309 | required Status status = 1; | |
310 | optional uint64 session_id = 2; | |
311 | optional UserDictionaryStorage storage = 3; | |
312 | // Use entries field instead. | |
313 | optional UserDictionary.Entry OBSOLETE_entry = 4; | |
314 | optional uint64 dictionary_id = 5; | |
315 | optional uint32 entry_size = 6; | |
316 | repeated UserDictionary.Entry entries = 7; | |
317 | }; |
35 | 35 | #include <string> |
36 | 36 | #include <vector> |
37 | 37 | #include "base/port.h" |
38 | #include "dictionary/user_dictionary_storage.pb.h" | |
38 | #include "protocol/user_dictionary_storage.pb.h" | |
39 | 39 | |
40 | 40 | namespace mozc { |
41 | 41 |
46 | 46 | '../converter/converter_base.gyp:segmenter', |
47 | 47 | '../dictionary/dictionary.gyp:dictionary_impl', |
48 | 48 | '../dictionary/dictionary.gyp:suffix_dictionary', |
49 | '../dictionary/dictionary_base.gyp:dictionary_protocol', | |
50 | 49 | '../dictionary/dictionary_base.gyp:pos_matcher', |
51 | 50 | '../dictionary/dictionary_base.gyp:suppression_dictionary', |
52 | 51 | '../dictionary/dictionary_base.gyp:user_dictionary', |
56 | 55 | '../prediction/prediction.gyp:prediction', |
57 | 56 | '../prediction/prediction_base.gyp:suggestion_filter', |
58 | 57 | '../protocol/protocol.gyp:commands_proto', |
58 | '../protocol/protocol.gyp:user_dictionary_storage_proto', | |
59 | 59 | '../rewriter/rewriter.gyp:rewriter', |
60 | 60 | ], |
61 | 61 | }, |
50 | 50 | #include "dictionary/user_dictionary_importer.h" |
51 | 51 | #include "dictionary/user_dictionary_session.h" |
52 | 52 | #include "dictionary/user_dictionary_storage.h" |
53 | #include "dictionary/user_dictionary_storage.pb.h" | |
54 | 53 | #include "dictionary/user_dictionary_util.h" |
55 | 54 | #include "dictionary/user_pos.h" |
56 | 55 | #include "gui/base/win_util.h" |
57 | 56 | #include "gui/config_dialog/combobox_delegate.h" |
58 | 57 | #include "gui/dictionary_tool/find_dialog.h" |
59 | 58 | #include "gui/dictionary_tool/import_dialog.h" |
59 | #include "protocol/user_dictionary_storage.pb.h" | |
60 | 60 | |
61 | 61 | namespace mozc { |
62 | 62 | namespace gui { |
56 | 56 | 'base/window_title_modifier.cc', |
57 | 57 | ], |
58 | 58 | 'dependencies': [ |
59 | '../dictionary/dictionary_base.gyp:user_dictionary', | |
60 | 59 | '../ipc/ipc.gyp:ipc', |
61 | 60 | '../ipc/ipc.gyp:window_info_protocol', |
62 | 61 | '../protocol/protocol.gyp:commands_proto', |
62 | '../protocol/protocol.gyp:user_dictionary_storage_proto', | |
63 | 63 | 'gen_base_files', |
64 | 64 | ], |
65 | 65 | 'includes': [ |
594 | 594 | '../config/config.gyp:config_handler', |
595 | 595 | '../config/config.gyp:config_protocol', |
596 | 596 | '../data_manager/data_manager.gyp:user_pos_manager', |
597 | '../dictionary/dictionary_base.gyp:dictionary_protocol', | |
598 | 597 | '../dictionary/dictionary_base.gyp:user_dictionary', |
599 | 598 | '../protocol/protocol.gyp:commands_proto', |
599 | '../protocol/protocol.gyp:user_dictionary_storage_proto', | |
600 | 600 | 'gen_config_dialog_files', |
601 | 601 | 'gen_dictionary_tool_files', |
602 | 602 | ], |
649 | 649 | '../base/base.gyp:base', |
650 | 650 | '../client/client.gyp:client', |
651 | 651 | '../data_manager/data_manager.gyp:user_pos_manager', |
652 | '../dictionary/dictionary_base.gyp:dictionary_protocol', | |
653 | 652 | '../dictionary/dictionary_base.gyp:pos_matcher', |
654 | 653 | '../dictionary/dictionary_base.gyp:user_dictionary', |
655 | 654 | '../protocol/protocol.gyp:commands_proto', |
655 | '../protocol/protocol.gyp:user_dictionary_storage_proto', | |
656 | 656 | 'gen_word_register_dialog_files', |
657 | 657 | ], |
658 | 658 | 'includes': [ |
48 | 48 | #include "data_manager/user_pos_manager.h" |
49 | 49 | #include "dictionary/user_dictionary_session.h" |
50 | 50 | #include "dictionary/user_dictionary_storage.h" |
51 | #include "dictionary/user_dictionary_storage.pb.h" | |
52 | 51 | #include "dictionary/user_dictionary_util.h" |
53 | 52 | #include "dictionary/user_pos.h" |
53 | #include "protocol/user_dictionary_storage.pb.h" | |
54 | 54 | |
55 | 55 | namespace mozc { |
56 | 56 | namespace gui { |
0 | 0 | MAJOR=2 |
1 | 1 | MINOR=17 |
2 | BUILD=2101 | |
2 | BUILD=2102 | |
3 | 3 | REVISION=102 |
4 | 4 | # NACL_DICTIONARY_VERSION is the target version of the system dictionary to be |
5 | 5 | # downloaded by NaCl Mozc. |
35 | 35 | syntax = "proto2"; |
36 | 36 | |
37 | 37 | import "config/config.proto"; |
38 | import "dictionary/user_dictionary_storage.proto"; | |
39 | 38 | import "protocol/candidates.proto"; |
39 | import "protocol/user_dictionary_storage.proto"; | |
40 | 40 | |
41 | 41 | package mozc.commands; |
42 | 42 |
76 | 76 | ], |
77 | 77 | 'dependencies': [ |
78 | 78 | '../config/config.gyp:genproto_config', |
79 | '../dictionary/dictionary_base.gyp:genproto_dictionary', | |
79 | 'genproto_user_dictionary_storage_proto', | |
80 | 80 | ], |
81 | 81 | }, |
82 | 82 | { |
89 | 89 | 'dependencies': [ |
90 | 90 | '../config/config.gyp:config_protocol', |
91 | 91 | '../protobuf/protobuf.gyp:protobuf', |
92 | '../dictionary/dictionary_base.gyp:dictionary_protocol', | |
93 | 92 | 'candidates_proto', |
94 | 93 | 'genproto_commands_proto#host', |
94 | 'user_dictionary_storage_proto', | |
95 | 95 | ], |
96 | 96 | 'export_dependent_settings': [ |
97 | 97 | 'genproto_commands_proto#host', |
127 | 127 | 'genproto_renderer_proto#host', |
128 | 128 | ], |
129 | 129 | }, |
130 | { | |
131 | 'target_name': 'genproto_user_dictionary_storage_proto', | |
132 | 'type': 'none', | |
133 | 'toolsets': ['host'], | |
134 | 'sources': [ | |
135 | 'user_dictionary_storage.proto', | |
136 | ], | |
137 | 'includes': [ | |
138 | '../protobuf/genproto.gypi', | |
139 | ], | |
140 | }, | |
141 | { | |
142 | 'target_name': 'user_dictionary_storage_proto', | |
143 | 'type': 'static_library', | |
144 | 'hard_dependency': 1, | |
145 | 'sources': [ | |
146 | '<(proto_out_dir)/<(relative_dir)/user_dictionary_storage.pb.cc', | |
147 | ], | |
148 | 'dependencies': [ | |
149 | '../protobuf/protobuf.gyp:protobuf', | |
150 | 'genproto_user_dictionary_storage_proto#host', | |
151 | ], | |
152 | 'export_dependent_settings': [ | |
153 | 'genproto_user_dictionary_storage_proto#host', | |
154 | ], | |
155 | }, | |
130 | 156 | ], |
131 | 157 | } |
0 | // Copyright 2010-2015, Google Inc. | |
1 | // All rights reserved. | |
2 | // | |
3 | // Redistribution and use in source and binary forms, with or without | |
4 | // modification, are permitted provided that the following conditions are | |
5 | // met: | |
6 | // | |
7 | // * Redistributions of source code must retain the above copyright | |
8 | // notice, this list of conditions and the following disclaimer. | |
9 | // * Redistributions in binary form must reproduce the above | |
10 | // copyright notice, this list of conditions and the following disclaimer | |
11 | // in the documentation and/or other materials provided with the | |
12 | // distribution. | |
13 | // * Neither the name of Google Inc. nor the names of its | |
14 | // contributors may be used to endorse or promote products derived from | |
15 | // this software without specific prior written permission. | |
16 | // | |
17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
18 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
19 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
20 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
21 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
22 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
23 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
24 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
25 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
26 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
27 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
28 | ||
29 | syntax = "proto2"; | |
30 | ||
31 | package mozc.user_dictionary; | |
32 | ||
33 | option java_outer_classname = "ProtoUserDictionaryStorage"; | |
34 | option java_package = "org.mozc.android.inputmethod.japanese.protobuf"; | |
35 | ||
36 | message UserDictionary { | |
37 | enum PosType { | |
38 | NOUN = 1; // "名詞" | |
39 | ABBREVIATION = 2; // "短縮よみ" | |
40 | SUGGESTION_ONLY = 3; // "サジェストのみ" | |
41 | PROPER_NOUN = 4; // "固有名詞" | |
42 | PERSONAL_NAME = 5; // "人名" | |
43 | FAMILY_NAME = 6; // "姓" | |
44 | FIRST_NAME = 7; // "名" | |
45 | ORGANIZATION_NAME = 8; // "組織" | |
46 | PLACE_NAME = 9; // "地名" | |
47 | SA_IRREGULAR_CONJUGATION_NOUN = 10; // "名詞サ変" | |
48 | ADJECTIVE_VERBAL_NOUN = 11; // "名詞形動" | |
49 | NUMBER = 12; // "数" | |
50 | ALPHABET = 13; // "アルファベット" | |
51 | SYMBOL = 14; // "記号" | |
52 | EMOTICON = 15; // "顔文字" | |
53 | ||
54 | ADVERB = 16; // "副詞" | |
55 | PRENOUN_ADJECTIVAL = 17; // "連体詞" | |
56 | CONJUNCTION = 18; // "接続詞" | |
57 | INTERJECTION = 19; // "感動詞" | |
58 | ||
59 | PREFIX = 20; // "接頭語" | |
60 | COUNTER_SUFFIX = 21; // "助数詞" | |
61 | GENERIC_SUFFIX = 22; // "接尾一般" | |
62 | PERSON_NAME_SUFFIX = 23; // "接尾人名" | |
63 | PLACE_NAME_SUFFIX = 24; // "接尾地名" | |
64 | ||
65 | WA_GROUP1_VERB = 25; // "動詞ワ行五段" | |
66 | KA_GROUP1_VERB = 26; // "動詞カ行五段" | |
67 | SA_GROUP1_VERB = 27; // "動詞サ行五段" | |
68 | TA_GROUP1_VERB = 28; // "動詞タ行五段" | |
69 | NA_GROUP1_VERB = 29; // "動詞ナ行五段" | |
70 | MA_GROUP1_VERB = 30; // "動詞マ行五段" | |
71 | RA_GROUP1_VERB = 31; // "動詞ラ行五段" | |
72 | GA_GROUP1_VERB = 32; // "動詞ガ行五段" | |
73 | BA_GROUP1_VERB = 33; // "動詞バ行五段" | |
74 | HA_GROUP1_VERB = 34; // "動詞ハ行四段" | |
75 | GROUP2_VERB = 35; // "動詞一段" | |
76 | KURU_GROUP3_VERB = 36; // "動詞カ変" | |
77 | SURU_GROUP3_VERB = 37; // "動詞サ変" | |
78 | ZURU_GROUP3_VERB = 38; // "動詞ザ変" | |
79 | RU_GROUP3_VERB = 39; // "動詞ラ変" | |
80 | ||
81 | ADJECTIVE = 40; // "形容詞" | |
82 | SENTENCE_ENDING_PARTICLE = 41; // "終助詞" | |
83 | PUNCTUATION = 42; // "句読点" | |
84 | FREE_STANDING_WORD = 43; // "独立語" | |
85 | ||
86 | SUPPRESSION_WORD = 44; // "抑制単語" | |
87 | }; | |
88 | ||
89 | // ID of this dictionary | |
90 | optional uint64 id = 1 [ default = 0 ]; | |
91 | ||
92 | // set false if this dictionary is not used. | |
93 | // Even if |enabled| is false, the dictionary | |
94 | // it self is visible to user. | |
95 | optional bool enabled = 2 [ default = true ]; | |
96 | ||
97 | // name of dictionary | |
98 | optional string name = 3 [ default = "" ]; | |
99 | ||
100 | // entry of each word | |
101 | message Entry { | |
102 | optional string key = 1 [ default = "" ]; | |
103 | optional string value = 2 [ default = "" ]; | |
104 | // Do NOT use tag number '3' in this proto. Please see below. | |
105 | optional string comment = 4 [ default = "" ]; | |
106 | ||
107 | // Historically we used to use tag number '3' for POS in string format. | |
108 | // In order to switch it to enum based POS, we removed (deprecated) the | |
109 | // tag number '3' field and created another field numbered '5'. | |
110 | optional PosType pos = 5; | |
111 | ||
112 | // set true if this entry is removed. | |
113 | // This flag is used for cloud sync feature. | |
114 | // Cloud sync feature is already deprecated and this flag is only | |
115 | // used to convert sync dictionary to normal dictionary. | |
116 | optional bool removed = 10 [ default = false ]; | |
117 | ||
118 | // set true if this entry is automatically registered | |
119 | // by converter. | |
120 | optional bool auto_registered = 11 [ default = false ]; | |
121 | }; | |
122 | ||
123 | repeated Entry entries = 4; | |
124 | ||
125 | // set true if this dictionary is removed. | |
126 | // This flag is used for cloud sync feature. | |
127 | // Cloud sync feature is already deprecated and this flag is only | |
128 | // used to convert sync dictionary to normal dictionary. | |
129 | optional bool removed = 5 [ default = false ]; | |
130 | ||
131 | // This flag is used for cloud sync feature. | |
132 | // Cloud sync feature is already deprecated and this flag is only | |
133 | // used to convert sync dictionary to normal dictionary. | |
134 | optional bool syncable = 6 [ default = false ]; | |
135 | }; | |
136 | ||
137 | message UserDictionaryStorage { | |
138 | // version of user dictionary | |
139 | optional int32 version = 1 [ default = 0 ]; | |
140 | ||
141 | // dictionary body | |
142 | repeated UserDictionary dictionaries = 2; | |
143 | ||
144 | enum StorageType { | |
145 | SNAPSHOT = 1; // This storage is a snapshot. | |
146 | UPDATE = 2; // This storage is a diff of some snapshots. | |
147 | }; | |
148 | ||
149 | optional StorageType storage_type = 10 [ default = SNAPSHOT ]; | |
150 | }; | |
151 | ||
152 | message UserDictionaryCommand { | |
153 | enum CommandType { | |
154 | // Does nothing. | |
155 | NO_OPERATION = 0; | |
156 | ||
157 | // Unlink the user dictionary file if necessary. | |
158 | // We can do this operation without creating a session. | |
159 | // This operation is introduced as a last resort to clean up | |
160 | // user dictionary, so it *forces* to unlink the file regardless | |
161 | // of the current user dictionary session status. | |
162 | CLEAR_STORAGE = 1; | |
163 | ||
164 | // Creates a new session, and returns its id via | |
165 | // UserDictionaryCommandStatus::session_id. | |
166 | CREATE_SESSION = 2; | |
167 | ||
168 | // Deletes the session identified by session_id. | |
169 | DELETE_SESSION = 3; | |
170 | ||
171 | // Sets the default dictionary name. It will be used when | |
172 | // ensure_non_empty_storage is enabled and the operation supporting the | |
173 | // flag is invoked. | |
174 | SET_DEFAULT_DICTIONARY_NAME = 4; | |
175 | ||
176 | // Checks if the session is currently undoable or not. | |
177 | CHECK_UNDOABILITY = 5; | |
178 | ||
179 | // Undoes the last operation. | |
180 | UNDO = 6; | |
181 | ||
182 | // Loads from local storage. | |
183 | LOAD = 7; | |
184 | ||
185 | // Saves to local storage. | |
186 | SAVE = 8; | |
187 | ||
188 | // Returns a list of name and dictionary-id pairs. | |
189 | // They are filled in the form of UserDictionary without any entries | |
190 | // in UserDictionaryCommandStatus::storage. | |
191 | GET_USER_DICTIONARY_NAME_LIST = 9; | |
192 | ||
193 | // Returns the number of entries in the dictionary with the | |
194 | // given dictionary_id. | |
195 | GET_ENTRY_SIZE = 10; | |
196 | ||
197 | // Use GET_ENTRIES instead. | |
198 | OBSOLETE_GET_ENTRY = 11; | |
199 | ||
200 | // Returns if it is possible to add new dictionary or not. | |
201 | // The result is returned by using status code. | |
202 | CHECK_NEW_DICTIONARY_AVAILABILITY = 12; | |
203 | ||
204 | // Creates a new dictionary with the dictionary_name. | |
205 | CREATE_DICTIONARY = 13; | |
206 | ||
207 | // Deletes the dictionary with the given dictionary_id. | |
208 | DELETE_DICTIONARY = 14; | |
209 | ||
210 | // Renames the dictionary with the given dictionary_id to dictionary_name. | |
211 | RENAME_DICTIONARY = 15; | |
212 | ||
213 | // Returns if it is possible to add new entry to the dictionary | |
214 | // with the given dictionary_id or not. | |
215 | CHECK_NEW_ENTRY_AVAILABILITY = 16; | |
216 | ||
217 | // Adds an entry to the dictionary with the given dictionary_id. | |
218 | // Added entry should be located at the end of the dictionary, and | |
219 | // the data should be passed via entry field. | |
220 | ADD_ENTRY = 17; | |
221 | ||
222 | // Edits an entry in the dictionary with the given dictionary_id. | |
223 | // The new data should be passed via entry. | |
224 | // The edit target should be specified via entry_index(0). | |
225 | EDIT_ENTRY = 18; | |
226 | ||
227 | // Deletes entries in the dictionary with the given dictionary_id. | |
228 | // The target entries should be specified based on index in entry_index. | |
229 | DELETE_ENTRY = 19; | |
230 | ||
231 | // Imports entries from the given data into a dictionary. | |
232 | // There are two ways to specify the dictionary: | |
233 | // 1) set dictionary_id for the dictionary | |
234 | // 2) set dictionary_name to create a new dictionary with the name. | |
235 | IMPORT_DATA = 20; | |
236 | ||
237 | // Gets the entire UserDictionaryStorage data. | |
238 | // Note: The result of this command could be too large for IPC, which has a | |
239 | // size limitation of the response data. | |
240 | GET_STORAGE = 21; | |
241 | ||
242 | // Returns entries in the dictionary specified by dictionary_id. | |
243 | // The position of the entry should be specified via entry_index(). | |
244 | GET_ENTRIES = 22; | |
245 | }; | |
246 | ||
247 | required CommandType type = 1; | |
248 | optional uint64 session_id = 2; | |
249 | optional uint64 dictionary_id = 3; | |
250 | optional string dictionary_name = 4; | |
251 | repeated int32 entry_index = 5; | |
252 | optional UserDictionary.Entry entry = 6; | |
253 | optional string data = 7; | |
254 | optional bool ensure_non_empty_storage = 8; | |
255 | }; | |
256 | ||
257 | message UserDictionaryCommandStatus { | |
258 | // Note: this status code is now temporary assgined. | |
259 | // It may be updated (incl. re-numbering) to organize the code. | |
260 | // I.e., the code shouldn't be saved in serialized format for now. | |
261 | // TODO(hidehiko): Re-organize and re-number the enum values, | |
262 | // after we check all necessary codes in. | |
263 | enum Status { | |
264 | // Note: SUCCEEDED is conflicting Windows MACRO. | |
265 | USER_DICTIONARY_COMMAND_SUCCESS = 1; | |
266 | UNKNOWN_ERROR = 2; | |
267 | ||
268 | UNKNOWN_COMMAND = 3; | |
269 | INVALID_ARGUMENT = 4; | |
270 | ||
271 | UNKNOWN_SESSION_ID = 5; | |
272 | ||
273 | FILE_NOT_FOUND = 6; | |
274 | INVALID_FILE_FORMAT = 7; | |
275 | ||
276 | // Note: currently if we recieve this error status, | |
277 | // the file is actually saved. | |
278 | FILE_SIZE_LIMIT_EXCEEDED = 8; | |
279 | DICTIONARY_SIZE_LIMIT_EXCEEDED = 9; | |
280 | ENTRY_SIZE_LIMIT_EXCEEDED = 10; | |
281 | ||
282 | UNKNOWN_DICTIONARY_ID = 11; | |
283 | ENTRY_INDEX_OUT_OF_RANGE = 12; | |
284 | ||
285 | // Errors for dictionary names. | |
286 | DICTIONARY_NAME_EMPTY = 13; | |
287 | DICTIONARY_NAME_TOO_LONG = 14; | |
288 | DICTIONARY_NAME_CONTAINS_INVALID_CHARACTER = 15; | |
289 | DICTIONARY_NAME_DUPLICATED = 16; | |
290 | ||
291 | // Errors for entry data. | |
292 | READING_EMPTY = 17; | |
293 | READING_TOO_LONG = 18; | |
294 | READING_CONTAINS_INVALID_CHARACTER = 19; | |
295 | WORD_EMPTY = 20; | |
296 | WORD_TOO_LONG = 21; | |
297 | WORD_CONTAINS_INVALID_CHARACTER = 22; | |
298 | INVALID_POS_TYPE = 23; | |
299 | COMMENT_TOO_LONG = 24; | |
300 | COMMENT_CONTAINS_INVALID_CHARACTER = 25; | |
301 | ||
302 | // Errors for importing. | |
303 | IMPORT_TOO_MANY_WORDS = 26; | |
304 | IMPORT_INVALID_ENTRIES = 27; | |
305 | ||
306 | NO_UNDO_HISTORY = 28; | |
307 | }; | |
308 | ||
309 | required Status status = 1; | |
310 | optional uint64 session_id = 2; | |
311 | optional UserDictionaryStorage storage = 3; | |
312 | // Use entries field instead. | |
313 | optional UserDictionary.Entry OBSOLETE_entry = 4; | |
314 | optional uint64 dictionary_id = 5; | |
315 | optional uint32 entry_size = 6; | |
316 | repeated UserDictionary.Entry entries = 7; | |
317 | }; |
82 | 82 | ], |
83 | 83 | 'dependencies': [ |
84 | 84 | '../client/client.gyp:client', |
85 | '../engine/engine.gyp:engine_factory', | |
86 | 85 | '../composer/composer.gyp:composer', |
87 | 86 | '../config/config.gyp:config_handler', |
88 | 87 | '../config/config.gyp:config_protocol', |
89 | '../dictionary/dictionary_base.gyp:dictionary_protocol', | |
90 | 88 | '../dictionary/dictionary_base.gyp:user_dictionary', |
89 | '../engine/engine.gyp:engine_factory', | |
90 | '../protocol/protocol.gyp:commands_proto', | |
91 | '../protocol/protocol.gyp:user_dictionary_storage_proto', | |
91 | 92 | '../usage_stats/usage_stats_base.gyp:usage_stats', |
92 | 93 | 'session_base.gyp:generic_storage_manager', |
93 | '../protocol/protocol.gyp:commands_proto', | |
94 | 94 | ], |
95 | 95 | 'conditions': [ |
96 | 96 | ['(target_platform=="NaCl" and _toolset=="target") or target_platform=="Android"', { |
46 | 46 | #include "config/config.pb.h" |
47 | 47 | #include "config/config_handler.h" |
48 | 48 | #include "dictionary/user_dictionary_session_handler.h" |
49 | #include "dictionary/user_dictionary_storage.pb.h" | |
50 | 49 | #include "engine/engine_interface.h" |
51 | 50 | #include "engine/user_data_manager_interface.h" |
52 | 51 | #include "protocol/commands.pb.h" |
52 | #include "protocol/user_dictionary_storage.pb.h" | |
53 | 53 | #include "session/generic_storage_manager.h" |
54 | 54 | #include "session/session.h" |
55 | 55 | #include "session/session_observer_handler.h" |