michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this file, michael@0: * You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "nsString.h" michael@0: #include "nsWhitespaceTokenizer.h" michael@0: michael@0: #include "Volume.h" michael@0: #include "VolumeCommand.h" michael@0: #include "VolumeManager.h" michael@0: #include "VolumeManagerLog.h" michael@0: michael@0: namespace mozilla { michael@0: namespace system { michael@0: michael@0: /*************************************************************************** michael@0: * michael@0: * The VolumeActionCommand class is used to send commands which apply michael@0: * to a particular volume. michael@0: * michael@0: * The following commands would fit into this category: michael@0: * michael@0: * volume mount michael@0: * volume unmount [force] michael@0: * volume format michael@0: * volume share michael@0: * volume unshare michael@0: * volume shared michael@0: * michael@0: * A typical response looks like: michael@0: * michael@0: * # vdc volume unshare sdcard ums michael@0: * 605 Volume sdcard /mnt/sdcard state changed from 7 (Shared-Unmounted) to 1 (Idle-Unmounted) michael@0: * 200 volume operation succeeded michael@0: * michael@0: * Note that the 600 series of responses are considered unsolicited and michael@0: * are dealt with directly by the VolumeManager. This command will only michael@0: * see the terminating response code (200 in the example above). michael@0: * michael@0: ***************************************************************************/ michael@0: michael@0: VolumeActionCommand::VolumeActionCommand(Volume* aVolume, michael@0: const char* aAction, michael@0: const char* aExtraArgs, michael@0: VolumeResponseCallback* aCallback) michael@0: : VolumeCommand(aCallback), michael@0: mVolume(aVolume) michael@0: { michael@0: nsAutoCString cmd; michael@0: michael@0: cmd = "volume "; michael@0: cmd += aAction; michael@0: cmd += " "; michael@0: cmd += aVolume->Name().get(); michael@0: michael@0: // vold doesn't like trailing white space, so only add it if we really need to. michael@0: if (aExtraArgs && (*aExtraArgs != '\0')) { michael@0: cmd += " "; michael@0: cmd += aExtraArgs; michael@0: } michael@0: SetCmd(cmd); michael@0: } michael@0: michael@0: /*************************************************************************** michael@0: * michael@0: * The VolumeListCommand class is used to send the "volume list" command to michael@0: * vold. michael@0: * michael@0: * A typical response looks like: michael@0: * michael@0: * # vdc volume list michael@0: * 110 sdcard /mnt/sdcard 4 michael@0: * 110 sdcard1 /mnt/sdcard/external_sd 4 michael@0: * 200 Volumes listed. michael@0: * michael@0: ***************************************************************************/ michael@0: michael@0: VolumeListCommand::VolumeListCommand(VolumeResponseCallback* aCallback) michael@0: : VolumeCommand(NS_LITERAL_CSTRING("volume list"), aCallback) michael@0: { michael@0: } michael@0: michael@0: } // system michael@0: } // mozilla michael@0: