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