dom/system/gonk/VolumeCommand.cpp

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     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/. */
     5 #include "nsString.h"
     6 #include "nsWhitespaceTokenizer.h"
     8 #include "Volume.h"
     9 #include "VolumeCommand.h"
    10 #include "VolumeManager.h"
    11 #include "VolumeManagerLog.h"
    13 namespace mozilla {
    14 namespace system {
    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 ***************************************************************************/
    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;
    51   cmd = "volume ";
    52   cmd += aAction;
    53   cmd += " ";
    54   cmd += aVolume->Name().get();
    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 }
    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 ***************************************************************************/
    78 VolumeListCommand::VolumeListCommand(VolumeResponseCallback* aCallback)
    79   : VolumeCommand(NS_LITERAL_CSTRING("volume list"), aCallback)
    80 {
    81 }
    83 } // system
    84 } // mozilla

mercurial