dom/system/gonk/VolumeCommand.cpp

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/system/gonk/VolumeCommand.cpp	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,85 @@
     1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this file,
     1.6 + * You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.7 +
     1.8 +#include "nsString.h"
     1.9 +#include "nsWhitespaceTokenizer.h"
    1.10 +
    1.11 +#include "Volume.h"
    1.12 +#include "VolumeCommand.h"
    1.13 +#include "VolumeManager.h"
    1.14 +#include "VolumeManagerLog.h"
    1.15 +
    1.16 +namespace mozilla {
    1.17 +namespace system {
    1.18 +
    1.19 +/***************************************************************************
    1.20 +*
    1.21 +* The VolumeActionCommand class is used to send commands which apply
    1.22 +* to a particular volume.
    1.23 +*
    1.24 +* The following commands would fit into this category:
    1.25 +*
    1.26 +*   volume mount <volname>
    1.27 +*   volume unmount <volname> [force]
    1.28 +*   volume format <volname>
    1.29 +*   volume share <volname> <method>
    1.30 +*   volume unshare <volname> <method>
    1.31 +*   volume shared <volname> <method>
    1.32 +*
    1.33 +* A typical response looks like:
    1.34 +*
    1.35 +*   # vdc volume unshare sdcard ums
    1.36 +*   605 Volume sdcard /mnt/sdcard state changed from 7 (Shared-Unmounted) to 1 (Idle-Unmounted)
    1.37 +*   200 volume operation succeeded
    1.38 +*
    1.39 +*   Note that the 600 series of responses are considered unsolicited and
    1.40 +*   are dealt with directly by the VolumeManager. This command will only
    1.41 +*   see the terminating response code (200 in the example above).
    1.42 +*
    1.43 +***************************************************************************/
    1.44 +
    1.45 +VolumeActionCommand::VolumeActionCommand(Volume* aVolume,
    1.46 +                                         const char* aAction,
    1.47 +                                         const char* aExtraArgs,
    1.48 +                                         VolumeResponseCallback* aCallback)
    1.49 +  : VolumeCommand(aCallback),
    1.50 +    mVolume(aVolume)
    1.51 +{
    1.52 +  nsAutoCString cmd;
    1.53 +
    1.54 +  cmd = "volume ";
    1.55 +  cmd += aAction;
    1.56 +  cmd += " ";
    1.57 +  cmd += aVolume->Name().get();
    1.58 +
    1.59 +  // vold doesn't like trailing white space, so only add it if we really need to.
    1.60 +  if (aExtraArgs && (*aExtraArgs != '\0')) {
    1.61 +    cmd += " ";
    1.62 +    cmd += aExtraArgs;
    1.63 +  }
    1.64 +  SetCmd(cmd);
    1.65 +}
    1.66 +
    1.67 +/***************************************************************************
    1.68 +*
    1.69 +* The VolumeListCommand class is used to send the "volume list" command to
    1.70 +* vold.
    1.71 +*
    1.72 +* A typical response looks like:
    1.73 +*
    1.74 +*   # vdc volume list
    1.75 +*   110 sdcard /mnt/sdcard 4
    1.76 +*   110 sdcard1 /mnt/sdcard/external_sd 4
    1.77 +*   200 Volumes listed.
    1.78 +*
    1.79 +***************************************************************************/
    1.80 +
    1.81 +VolumeListCommand::VolumeListCommand(VolumeResponseCallback* aCallback)
    1.82 +  : VolumeCommand(NS_LITERAL_CSTRING("volume list"), aCallback)
    1.83 +{
    1.84 +}
    1.85 +
    1.86 +} // system
    1.87 +} // mozilla
    1.88 +

mercurial