|
1 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
2 * License, v. 2.0. If a copy of the MPL was not distributed with this file, |
|
3 * You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
4 |
|
5 #include "nsString.h" |
|
6 #include "nsWhitespaceTokenizer.h" |
|
7 |
|
8 #include "Volume.h" |
|
9 #include "VolumeCommand.h" |
|
10 #include "VolumeManager.h" |
|
11 #include "VolumeManagerLog.h" |
|
12 |
|
13 namespace mozilla { |
|
14 namespace system { |
|
15 |
|
16 /*************************************************************************** |
|
17 * |
|
18 * The VolumeActionCommand class is used to send commands which apply |
|
19 * to a particular volume. |
|
20 * |
|
21 * The following commands would fit into this category: |
|
22 * |
|
23 * volume mount <volname> |
|
24 * volume unmount <volname> [force] |
|
25 * volume format <volname> |
|
26 * volume share <volname> <method> |
|
27 * volume unshare <volname> <method> |
|
28 * volume shared <volname> <method> |
|
29 * |
|
30 * A typical response looks like: |
|
31 * |
|
32 * # vdc volume unshare sdcard ums |
|
33 * 605 Volume sdcard /mnt/sdcard state changed from 7 (Shared-Unmounted) to 1 (Idle-Unmounted) |
|
34 * 200 volume operation succeeded |
|
35 * |
|
36 * Note that the 600 series of responses are considered unsolicited and |
|
37 * are dealt with directly by the VolumeManager. This command will only |
|
38 * see the terminating response code (200 in the example above). |
|
39 * |
|
40 ***************************************************************************/ |
|
41 |
|
42 VolumeActionCommand::VolumeActionCommand(Volume* aVolume, |
|
43 const char* aAction, |
|
44 const char* aExtraArgs, |
|
45 VolumeResponseCallback* aCallback) |
|
46 : VolumeCommand(aCallback), |
|
47 mVolume(aVolume) |
|
48 { |
|
49 nsAutoCString cmd; |
|
50 |
|
51 cmd = "volume "; |
|
52 cmd += aAction; |
|
53 cmd += " "; |
|
54 cmd += aVolume->Name().get(); |
|
55 |
|
56 // vold doesn't like trailing white space, so only add it if we really need to. |
|
57 if (aExtraArgs && (*aExtraArgs != '\0')) { |
|
58 cmd += " "; |
|
59 cmd += aExtraArgs; |
|
60 } |
|
61 SetCmd(cmd); |
|
62 } |
|
63 |
|
64 /*************************************************************************** |
|
65 * |
|
66 * The VolumeListCommand class is used to send the "volume list" command to |
|
67 * vold. |
|
68 * |
|
69 * A typical response looks like: |
|
70 * |
|
71 * # vdc volume list |
|
72 * 110 sdcard /mnt/sdcard 4 |
|
73 * 110 sdcard1 /mnt/sdcard/external_sd 4 |
|
74 * 200 Volumes listed. |
|
75 * |
|
76 ***************************************************************************/ |
|
77 |
|
78 VolumeListCommand::VolumeListCommand(VolumeResponseCallback* aCallback) |
|
79 : VolumeCommand(NS_LITERAL_CSTRING("volume list"), aCallback) |
|
80 { |
|
81 } |
|
82 |
|
83 } // system |
|
84 } // mozilla |
|
85 |