1// Copyright 2017 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5syntax = "proto2";
6
7option optimize_for = LITE_RUNTIME;
8
9package smbprovider;
10
11// ErrorType matches 1:1 to FileSystemProvider#ProviderError in Chromium up
12// until ERROR_PROVIDER_ERROR_COUNT. The ErrorTypes past that are specific to
13// SmbProvider.
14enum ErrorType {
15  ERROR_NONE = 0;
16  ERROR_OK = 1;
17  ERROR_FAILED = 2;
18  ERROR_IN_USE = 3;
19  ERROR_EXISTS = 4;
20  ERROR_NOT_FOUND = 5;
21  ERROR_ACCESS_DENIED = 6;
22  ERROR_TOO_MANY_OPENED = 7;
23  ERROR_NO_MEMORY = 8;
24  ERROR_NO_SPACE = 9;
25  ERROR_NOT_A_DIRECTORY = 10;
26  ERROR_INVALID_OPERATION = 11;
27  ERROR_SECURITY = 12;
28  ERROR_ABORT = 13;
29  ERROR_NOT_A_FILE = 14;
30  ERROR_NOT_EMPTY = 15;
31  ERROR_INVALID_URL = 16;
32  ERROR_IO = 17;
33  // Count of ProviderError.
34  ERROR_PROVIDER_ERROR_COUNT = 18;
35  // The following errors are not ProviderErrors, instead they are specific to
36  // SmbProvider. The jump in int value is to account for possible future
37  // additions to ProviderError.
38  ERROR_DBUS_PARSE_FAILED = 50;
39  ERROR_COPY_PENDING = 51;
40  ERROR_COPY_FAILED = 52;
41  ERROR_SMB1_UNSUPPORTED = 53;
42  ERROR_OPERATION_PENDING = 54;
43  ERROR_OPERATION_FAILED = 55;
44}
45
46message DirectoryEntryProto {
47  optional bool is_directory = 1;
48  optional string name = 2;
49  // Size in bytes.
50  optional int64 size = 3;
51  // Seconds since unix epoch.
52  optional int64 last_modified_time = 4;
53}
54
55// DirectoryEntryListProto is included in responses to ReadDirectory D-Bus
56// method calls.
57message DirectoryEntryListProto { repeated DirectoryEntryProto entries = 1; }
58
59// Used for passing inputs into SmbProvider.Mount().
60message MountOptionsProto {
61  // Path of the share to be mounted (e.g. "smb://qnap/testshare"). Must be of
62  // the form "smb://hostname/sharename", and may have the hostname resolved to
63  // an IP address (e.g. "smb://192.168.3.142/testshare").
64  optional string path = 1;
65  // Original path of the share to be mounted. Must be of the form
66  // "smb://hostname/sharename", and must have the hostname as entered by the
67  // user and not resolved to an IP address (unless the user entered an IP
68  // address as the hostname).
69  optional string original_path = 6;
70
71  // Authentication parameters.
72  optional string workgroup = 2;
73  optional string username = 3;
74
75  // Mount options set by the client.
76  optional MountConfigProto mount_config = 4;
77
78  // Skip attempting to connect to the share, and instead just register the
79  // mount.
80  optional bool skip_connect = 5;
81
82  // Username hash of the mounting profile.
83  optional string account_hash = 7;
84
85  // Save the password on successful mount. Requires |skip_connect| = false.
86  optional bool save_password = 8;
87
88  // Use a saved password.
89  optional bool restore_password = 9;
90}
91
92message MountConfigProto {
93  // Boolean indication whether or not to enable NTLM protocol. False
94  // disables the NTLM protocol.
95  optional bool enable_ntlm = 1;
96}
97
98// Used for passing inputs into SmbProvider.Unmount().
99message UnmountOptionsProto {
100  // ID of the mount returned from Mount().
101  optional int32 mount_id = 1;
102
103  // Remove any saved password for the mount.
104  optional bool remove_password = 2;
105}
106
107// Used for passing inputs into SmbProvider.ReadDirectory().
108message ReadDirectoryOptionsProto {
109  // ID of the mount returned from Mount().
110  optional int32 mount_id = 1;
111  // Path of the directory to be read. The paths are relative to the mount root.
112  // (e.g. "/testfolder")
113  optional string directory_path = 2;
114}
115
116// Used for passing inputs into SmbProvider.GetMetadataEntry().
117message GetMetadataEntryOptionsProto {
118  // ID of the mount returned from Mount().
119  optional int32 mount_id = 1;
120  // Path of the entry to be read. This can be a file or directory path.
121  // The paths are relative to the mount root. (e.g. "/testfolder/dog.jpg")
122  optional string entry_path = 2;
123}
124
125// Used for passing inputs into SmbProvider.OpenFile().
126message OpenFileOptionsProto {
127  // ID of the mount returned from Mount().
128  optional int32 mount_id = 1;
129  // Path of the file to be opened. This must be a file path.
130  // Paths are relative to the mount root, e.g. "/animals/dog.jpg".
131  optional string file_path = 2;
132  // Boolean indicating write status. False indicates read only.
133  optional bool writeable = 3;
134}
135
136// Used for passing inputs into SmbProvider.CloseFile().
137message CloseFileOptionsProto {
138  // ID of the mount returned from Mount().
139  optional int32 mount_id = 1;
140  // ID of the file returned from OpenFile().
141  optional int32 file_id = 2;
142}
143
144// Used for passing inputs into SmbProvider.ReadFile().
145message ReadFileOptionsProto {
146  // ID of the mount returned from Mount().
147  optional int32 mount_id = 1;
148  // ID of the file returned from OpenFile().
149  optional int32 file_id = 2;
150  // Offset of the file to be read.
151  optional int64 offset = 3;
152  // Length in bytes to be read.
153  optional int32 length = 4;
154}
155
156// Used for passing inputs into SmbProvider.DeleteEntry().
157message DeleteEntryOptionsProto {
158  // ID of the mount returned from Mount().
159  optional int32 mount_id = 1;
160  // Path of the entry to be deleted. This can be a file or directory path.
161  // The paths are relative to the mount root. (e.g. "/testfolder/dog.jpg")
162  optional string entry_path = 2;
163  // Boolean indicating whether the delete should be recursive for directories.
164  optional bool recursive = 3;
165}
166
167// Used for passing inputs into SmbProvider.CreateFile().
168message CreateFileOptionsProto {
169  // ID of the mount returned from Mount().
170  optional int32 mount_id = 1;
171  // Path of the file to be created. Paths are relative to the mount root,
172  // e.g. "/animals/dog.jpg".
173  optional string file_path = 2;
174}
175
176// Used for passing inputs into SmbProvider.Truncate().
177message TruncateOptionsProto {
178  // ID of the mount returned from Mount().
179  optional int32 mount_id = 1;
180  // Path of the file to be truncated. Paths are relative to the mount root,
181  // e.g. "/animals/dog.jpg".
182  optional string file_path = 2;
183  // New desired length of the file.
184  optional int64 length = 3;
185}
186
187// Used for passing inputs into SmbProvider.WriteFile().
188message WriteFileOptionsProto {
189  // ID of the mount returned from Mount().
190  optional int32 mount_id = 1;
191  // ID of the file returned from OpenFile().
192  optional int32 file_id = 2;
193  // Offset of the file for the write.
194  optional int64 offset = 3;
195  // Length of data being written.
196  optional int32 length = 4;
197}
198
199// Used for passing inputs into SmbProvider.CreateDirectory().
200message CreateDirectoryOptionsProto {
201  // ID of the mount returned from Mount().
202  optional int32 mount_id = 1;
203  // Path of the directory to be created. Paths are relative to the mount root.
204  // (e.g. "/testfolder/dogs")
205  optional string directory_path = 2;
206  // Boolean indicating whether the create should be recursive, meaning the
207  // parent directories will also be created if they currently don't exist.
208  optional bool recursive = 3;
209}
210
211// Used for passing inputs into SmbProvider.MoveEntry().
212message MoveEntryOptionsProto {
213  // ID of the mount returned from Mount().
214  optional int32 mount_id = 1;
215  // Source path of the entry to be moved. This can be a file or directory path.
216  // Paths are relative to the mount root. (e.g. "/testfolder/dog.jpg")
217  optional string source_path = 2;
218  // Destination path for the entry to be moved to. This must be a non-existent
219  // file or directory path. Paths are relative to the mount
220  // root. (e.g. "/testfolder/dog.jpg")
221  optional string target_path = 3;
222}
223
224// Used for passing inputs into SmbProvider.CopyEntry().
225message CopyEntryOptionsProto {
226  // ID of the mount returned from Mount().
227  optional int32 mount_id = 1;
228  // Source path of the entry to be copied. This can be a file or directory
229  // path. Paths are relative to the mount root. (e.g. "/testfolder/dog.jpg")
230  optional string source_path = 2;
231  // Destination path for the entry to be copied to. This must be a non-existent
232  // file or directory path. Paths are relative to the mount root.
233  // (e.g. "/testfolder/dog.jpg")
234  optional string target_path = 3;
235}
236
237message GetDeleteListOptionsProto {
238  optional int32 mount_id = 1;
239  optional string entry_path = 2;
240}
241
242message DeleteListProto {
243  repeated string entries = 1;
244}
245
246// Used for passing inputs into SmbProvider.GetShares().
247message GetSharesOptionsProto {
248  // Url of the server containing the shares. (e.g. "smb://192.168.0.1")
249  optional string server_url = 1;
250}
251
252// Used for returning a list of hostnames from a parsed NetBios response packet.
253message HostnamesProto {
254  repeated string hostnames = 1;
255}
256
257// Used for passing inputs into Smbprovider.UpdateMountCredentials().
258message UpdateMountCredentialsOptionsProto {
259  // Mount ID of the mount to be updated.
260  optional int32 mount_id = 1;
261  // Updated workgroup.
262  optional string workgroup = 2;
263  // Updated username.
264  optional string username = 3;
265}
266
267// Used for passing inputs into Smbprovider.UpdateSharePath().
268message UpdateSharePathOptionsProto {
269  // Mount ID of the mount to be updated.
270  optional int32 mount_id = 1;
271
272  // Share path of the mount to be updated.
273  optional string path = 2;
274}
275