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 "nsISupports.idl" michael@0: #include "nsIVolumeStat.idl" michael@0: michael@0: [scriptable, uuid(13caa69c-8f1f-11e3-8e36-10bf48d707fb)] michael@0: interface nsIVolume : nsISupports michael@0: { michael@0: // These MUST match the states from android's system/vold/Volume.h header michael@0: const long STATE_INIT = -1; michael@0: const long STATE_NOMEDIA = 0; michael@0: const long STATE_IDLE = 1; michael@0: const long STATE_PENDING = 2; michael@0: const long STATE_CHECKING = 3; michael@0: const long STATE_MOUNTED = 4; michael@0: const long STATE_UNMOUNTING = 5; michael@0: const long STATE_FORMATTING = 6; michael@0: const long STATE_SHARED = 7; michael@0: const long STATE_SHAREDMNT = 8; michael@0: michael@0: // The name of the volume. Often there is only one volume, called sdcard. michael@0: // But some phones support multiple volumes. michael@0: readonly attribute DOMString name; michael@0: michael@0: // The mount point is the path on the system where the volume is mounted michael@0: // and is only valid when state == STATE_MOUNTED. michael@0: readonly attribute DOMString mountPoint; michael@0: michael@0: // Reflects the current state of the volume, using STATE_xxx constants michael@0: // from above. michael@0: readonly attribute long state; michael@0: michael@0: // mountGeneration is a unique number which is used distinguish between michael@0: // periods of time that a volume is in the mounted state. Each time a michael@0: // volume transitions to the mounted state, the mountGeneration will michael@0: // be different from the last time it transitioned to the mounted state. michael@0: readonly attribute long mountGeneration; michael@0: michael@0: // While a volume is mounted, it can be locked, preventing it from being michael@0: // shared with the PC. To lock a volume, acquire an MozWakeLock michael@0: // using the name of this attribute. Note that mountLockName changes michael@0: // every time the mountGeneration changes, so you'll need to reacquire michael@0: // the wakelock every time the volume becomes mounted. michael@0: readonly attribute DOMString mountLockName; michael@0: michael@0: // Determines if a mountlock is currently being held against this volume. michael@0: readonly attribute boolean isMountLocked; michael@0: michael@0: // Determines if media is actually present or not. Note, that when an sdcard michael@0: // is ejected, it may go through several tranistory states before finally michael@0: // arriving at STATE_NOMEDIA. So isMediaPresent may be false even when the michael@0: // current state isn't STATE_NOMEDIA. michael@0: readonly attribute boolean isMediaPresent; michael@0: michael@0: // Determines if the volume is currently being shared. This covers off michael@0: // more than just state == STATE_SHARED. isSharing will return true from the michael@0: // time that the volume leaves the mounted state, until it gets back to michael@0: // mounted, nomedia, or formatting states. This attribute is to allow michael@0: // device storage to suppress unwanted 'unavailable' status when michael@0: // transitioning from mounted to sharing and back again. michael@0: readonly attribute boolean isSharing; michael@0: michael@0: // Determines if the volume is currently formatting. This sets true once michael@0: // mFormatRequest == true and mState == STATE_MOUNTED, and sets false michael@0: // once the volume has been formatted and mounted again. michael@0: readonly attribute boolean isFormatting; michael@0: michael@0: nsIVolumeStat getStats(); michael@0: michael@0: // Formats the volume in IO thread, if the volume is ready to be formatted. michael@0: // Automounter will unmount it, format it and then mount it again. michael@0: void format(); michael@0: michael@0: // Mounts the volume in IO thread, if the volume is already unmounted. michael@0: // Automounter will mount it. Otherwise Automounter will skip this. michael@0: void mount(); michael@0: michael@0: // Unmounts the volume in IO thread, if the volume is already mounted. michael@0: // Automounter will unmount it. Otherwise Automounter will skip this. michael@0: void unmount(); michael@0: michael@0: // Whether this is a fake volume. michael@0: readonly attribute boolean isFake; michael@0: }; michael@0: michael@0: %{C++ michael@0: // For use with the ObserverService michael@0: #define NS_VOLUME_STATE_CHANGED "volume-state-changed" michael@0: michael@0: namespace mozilla { michael@0: namespace system { michael@0: michael@0: // Convert a state into a loggable/printable string. michael@0: const char* NS_VolumeStateStr(int32_t aState); michael@0: michael@0: } // system michael@0: } // mozilla michael@0: %}