Class: MTP::Datacode

Inherits:
Object
  • Object
show all
Defined in:
lib/mtp/datacode.rb

Defined Under Namespace

Modules: Masks

Constant Summary collapse

CODE_NAMES =
{
  0x0000 => nil,
  0x1000 => "Undefined",
  0x1001 => "GetDeviceInfo",
  0x1002 => "OpenSession",
  0x1003 => "CloseSession",
  0x1004 => "GetStorageIds",
  0x1005 => "GetStorageInfo",
  0x1006 => "GetNumObjects",
  0x1007 => "GetObjectHandles",
  0x1008 => "GetObjectInfo",
  0x1009 => "GetObject",
  0x100A => "GetThumb",
  0x100B => "DeleteObject",
  0x100C => "SendObjectInfo",
  0x100D => "SendObject",
  0x100E => "InitiateCapture",
  0x100F => "FormatStore",
  0x1010 => "ResetDevice",
  0x1011 => "SelfTest",
  0x1012 => "SetObjectProtection",
  0x1013 => "PowerDown",
  0x1014 => "GetDevicePropDesc",
  0x1015 => "GetDevicePropValue",
  0x1016 => "SetDevicePropValue",
  0x1017 => "ResetDevicePropValue",
  0x1018 => "TerminateOpenCapture",
  0x1019 => "MoveObject",
  0x101A => "CopyObject",
  0x101B => "GetPartialObject",
  0x101C => "InitiateOpenCapture",
  0x9801 => "GetObjectPropsSupported",
  0x9802 => "GetObjectPropDesc",
  0x9803 => "GetObjectPropValue",
  0x9804 => "SetObjectPropValue",
  0x9805 => "GetObjPropList",
  0x9806 => "SetObjPropList",
  0x9807 => "GetInterdependendPropdesc",
  0x9808 => "SendObjectPropList",
  0x9810 => "GetObjectReferences",
  0x9811 => "SetObjectReferences",
  0x9812 => "UpdateDeviceFirmware",
  0x9820 => "Skip",
  0x9101 => "GetSecureTimeChallenge",
  0x9102 => "GetSecureTimeResponse",
  0x9103 => "SetLicenseResponse",
  0x9104 => "GetSyncList",
  0x9105 => "SendMeterChallengeQuery",
  0x9106 => "GetMeterChallenge",
  0x9107 => "SetMeterResponse",
  0x9108 => "CleanDataStore",
  0x9109 => "GetLicenseState",
  0x910A => "SendWMDRMPDCommand",
  0x910B => "SendWMDRMPDRequest",
  0x9212 => "SendWMDRMPDAppRequest",
  0x9213 => "GetWMDRMPDAppResponse",
  0x9214 => "EnableTrustedFilesOperations",
  0x9215 => "DisableTrustedFilesOperations",
  0x9216 => "EndTrustedAppSession",
  0x9170 => "OpenMediaSession1",
  0x9171 => "OpenMediaSession2",
  0x9172 => "GetNextDataBlock",
  0x9173 => "SetCurrentTimePosition",
  0x9180 => "SendRegistrationRequest",
  0x9181 => "GetRegistrationResponse",
  0x9182 => "GetProximityChallenge",
  0x9183 => "SendProximityResponse",
  0x9184 => "SendWMDRMNDLicenseRequest",
  0x9185 => "GetWMDRMNDLicenseResponse",
  0x9201 => "ReportAddedDeletedItems",
  0x9202 => "ReportAcquiredItems",
  0x9203 => "PlaylistObjectPref",
  0x2000 => "Undefined",
  0x2001 => "OK",
  0x2002 => "GeneralError",
  0x2003 => "SessionNotOpen",
  0x2004 => "InvalidTransactionID",
  0x2005 => "OperationNotSupported",
  0x2006 => "ParameterNotSupported",
  0x2007 => "IncompleteTransfer",
  0x2008 => "InvalidStorageId",
  0x2009 => "InvalidObjectHandle",
  0x200A => "DevicePropNotSupported",
  0x200B => "InvalidObjectFormatCode",
  0x200C => "StoreFull",
  0x200D => "ObjectWriteProtected",
  0x200E => "StoreReadOnly",
  0x200F => "AccessDenied",
  0x2010 => "NoThumbnailPresent",
  0x2011 => "SelfTestFailed",
  0x2012 => "PartialDeletion",
  0x2013 => "StoreNotAvailable",
  0x2014 => "SpecificationByFormatUnsupported",
  0x2015 => "NoValidObjectInfo",
  0x2016 => "InvalidCodeFormat",
  0x2017 => "UnknownVendorCode",
  0x2018 => "CaptureAlreadyTerminated",
  0x2019 => "DeviceBusy",
  0x201A => "InvalidParentObject",
  0x201B => "InvalidDevicePropFormat",
  0x201C => "InvalidDevicePropValue",
  0x201D => "InvalidParameter",
  0x201E => "SessionAlreadyOpened",
  0x201F => "TransactionCanceled",
  0x2020 => "SpecificationOfDestinationUnsupported",
  0x4000 => "Undefined",
  0x4001 => "CancelTransaction",
  0x4002 => "ObjectAdded",
  0x4003 => "ObjectRemoved",
  0x4004 => "StoreAdded",
  0x4005 => "StoreRemoved",
  0x4006 => "DevicePropChanged",
  0x4007 => "ObjectInfoChanged",
  0x4008 => "DeviceInfoChanged",
  0x4009 => "RequestObjectTransfer",
  0x400A => "StoreFull",
  0x400B => "DeviceReset",
  0x400C => "StorageInfoChanged",
  0x400D => "CaptureComplete",
  0x400E => "UnreportedStatus",
  0x3000 => "Undefined",
  0x3800 => "Defined",
  0x3001 => "Association",
  0x3002 => "Script",
  0x3003 => "Executable",
  0x3004 => "Text",
  0x3005 => "HTML",
  0x3006 => "DPOF",
  0x3007 => "AIFF",
  0x3008 => "WAV",
  0x3009 => "MP3",
  0x300A => "AVI",
  0x300B => "MPEG",
  0x300C => "ASF",
  0x300D => "QT",
  0x3801 => "EXIF_JPEG",
  0x3802 => "TIFF_EP",
  0x3803 => "FlashPix",
  0x3804 => "BMP",
  0x3805 => "CIFF",
  0x3806 => "Undefined_0x3806",
  0x3807 => "GIF",
  0x3808 => "JFIF",
  0x3809 => "PCD",
  0x380A => "PICT",
  0x380B => "PNG",
  0x380C => "Undefined_0x380C",
  0x380D => "TIFF",
  0x380E => "TIFF_IT",
  0x380F => "JP2",
  0x3810 => "JPX",
  0xb002 => "EK_M3U",
  0xb211 => "MediaCard",
  0xb212 => "MediaCardGroup",
  0xb213 => "Encounter",
  0xb214 => "EncounterBox",
  0xb215 => "M4A",
  0xb217 => "ZUNEUNDEFINED",
  0xb802 => "Firmware",
  0xb881 => "WindowsImageFormat",
  0xb900 => "UndefinedAudio",
  0xb901 => "WMA",
  0xb902 => "OGG",
  0xb903 => "AAC",
  0xb904 => "AudibleCodec",
  0xb906 => "FLAC",
  0xb980 => "UndefinedVideo",
  0xb981 => "WMV",
  0xb982 => "MP4",
  0xb983 => "MP2",
  0xb984 => "3GP",
  0xba00 => "UndefinedCollection",
  0xba01 => "AbstractMultimediaAlbum",
  0xba02 => "AbstractImageAlbum",
  0xba03 => "AbstractAudioAlbum",
  0xba04 => "AbstractVideoAlbum",
  0xba05 => "AbstractAudioVideoPlaylist",
  0xba06 => "AbstractContactGroup",
  0xba07 => "AbstractMessageFolder",
  0xba08 => "AbstractChapteredProduction",
  0xba09 => "AbstractAudioPlaylist",
  0xba0a => "AbstractVideoPlaylist",
  0xba0b => "AbstractMediacast",
  0xba10 => "WPLPlaylist",
  0xba11 => "M3UPlaylist",
  0xba12 => "MPLPlaylist",
  0xba13 => "ASXPlaylist",
  0xba14 => "PLSPlaylist",
  0xba80 => "UndefinedDocument",
  0xba81 => "AbstractDocument",
  0xba82 => "XMLDocument",
  0xba83 => "MSWordDocument",
  0xba84 => "MHTCompiledHTMLDocument",
  0xba85 => "MSExcelSpreadsheetXLS",
  0xba86 => "MSPowerpointPresentationPPT",
  0xbb00 => "UndefinedMessage",
  0xbb01 => "AbstractMessage",
  0xbb80 => "UndefinedContact",
  0xbb81 => "AbstractContact",
  0xbb82 => "vCard2",
  0xbb83 => "vCard3",
  0xbe00 => "UndefinedCalendarItem",
  0xbe01 => "AbstractCalendarItem",
  0xbe02 => "vCalendar1",
  0xbe03 => "vCalendar2",
  0xbe80 => "UndefinedWindowsExecutable",
  0x5000 => "Undefined",
  0x5001 => "BatteryLevel",
  0x5002 => "FunctionalMode",
  0x5003 => "ImageSize",
  0x5004 => "CompressionSetting",
  0x5005 => "WhiteBalance",
  0x5006 => "RGBGain",	
  0x5007 => "FNumber",	
  0x5008 => "FocalLength",
  0x5009 => "FocusDistance",
  0x500A => "FocusMode",
  0x500B => "ExposureMeteringMode",
  0x500C => "FlashMode",
  0x500D => "ExposureTime",
  0x500E => "ExposureProgramMode",
  0x500F => "ExposureIndex",
  0x5010 => "ExposureBiasCompensation",
  0x5011 => "DateTime",
  0x5012 => "CaptureDelay",
  0x5013 => "StillCaptureMode",
  0x5014 => "Contrast",
  0x5015 => "Sharpness",
  0x5016 => "DigitalZoom",
  0x5017 => "EffectMode",
  0x5018 => "BurstNumber",
  0x5019 => "BurstInterval",
  0x501A => "TimelapseNumber",
  0x501B => "TimelapseInterval",
  0x501C => "FocusMeteringMode",
  0x501D => "UploadURL",
  0x501E => "Artist",
  0x501F => "CopyrightInfo",
  0xD181 => "ZUNE_UNKNOWN1",
  0xD132 => "ZUNE_UNKNOWN2",
  0xD215 => "ZUNE_UNKNOWN3",
  0xD216 => "ZUNE_UNKNOWN4",
  0xD101 => "SecureTime",
  0xD102 => "DeviceCertificate",
  0xD103 => "RevocationInfo",
  0xD401 => "SynchronizationPartner",
  0xD402 => "DeviceFriendlyName",
  0xD403 => "VolumeLevel",
  0xD405 => "DeviceIcon",
  0xD410 => "PlaybackRate",
  0xD411 => "PlaybackObject",
  0xD412 => "PlaybackContainerIndex",
  0xD413 => "PlaybackPosition",
  0xD131 => "PlaysForSureID",
  0xD181 => "Zune_UnknownVersion",
  0xDC01 => "StorageID",
  0xDC02 => "ObjectFormat",
  0xDC03 => "ProtectionStatus",
  0xDC04 => "ObjectSize",
  0xDC05 => "AssociationType",
  0xDC06 => "AssociationDesc",
  0xDC07 => "ObjectFileName",
  0xDC08 => "DateCreated",
  0xDC09 => "DateModified",
  0xDC0A => "Keywords",
  0xDC0B => "ParentObject",
  0xDC0C => "AllowedFolderContents",
  0xDC0D => "Hidden",
  0xDC0E => "SystemObject",
  0xDC41 => "PersistantUniqueObjectIdentifier",
  0xDC42 => "SyncID",
  0xDC43 => "PropertyBag",
  0xDC44 => "Name",
  0xDC45 => "CreatedBy",
  0xDC46 => "Artist",
  0xDC47 => "DateAuthored",
  0xDC48 => "Description",
  0xDC49 => "URLReference",
  0xDC4A => "LanguageLocale",
  0xDC4B => "CopyrightInformation",
  0xDC4C => "Source",
  0xDC4D => "OriginLocation",
  0xDC4E => "DateAdded",
  0xDC4F => "NonConsumable",
  0xDC50 => "CorruptOrUnplayable",
  0xDC51 => "ProducerSerialNumber",
  0xDC81 => "RepresentativeSampleFormat",
  0xDC82 => "RepresentativeSampleSize",
  0xDC83 => "RepresentativeSampleHeight",
  0xDC84 => "RepresentativeSampleWidth",
  0xDC85 => "RepresentativeSampleDuration",
  0xDC86 => "RepresentativeSampleData",
  0xDC87 => "Width",
  0xDC88 => "Height",
  0xDC89 => "Duration",
  0xDC8A => "Rating",
  0xDC8B => "Track",
  0xDC8C => "Genre",
  0xDC8D => "Credits",
  0xDC8E => "Lyrics",
  0xDC8F => "SubscriptionContentID",
  0xDC90 => "ProducedBy",
  0xDC91 => "UseCount",
  0xDC92 => "SkipCount",
  0xDC93 => "LastAccessed",
  0xDC94 => "ParentalRating",
  0xDC95 => "MetaGenre",
  0xDC96 => "Composer",
  0xDC97 => "EffectiveRating",
  0xDC98 => "Subtitle",
  0xDC99 => "OriginalReleaseDate",
  0xDC9A => "AlbumName",
  0xDC9B => "AlbumArtist",
  0xDC9C => "Mood",
  0xDC9D => "DRMStatus",
  0xDC9E => "SubDescription",
  0xDCD1 => "IsCropped",
  0xDCD2 => "IsColorCorrected",
  0xDCD3 => "ImageBitDepth",
  0xDCD4 => "Fnumber",
  0xDCD5 => "ExposureTime",
  0xDCD6 => "ExposureIndex",
  0xDCE0 => "DisplayName",
  0xDCE1 => "BodyText",
  0xDCE2 => "Subject",
  0xDCE3 => "Prority",
  0xDD00 => "GivenName",
  0xDD01 => "MiddleNames",
  0xDD02 => "FamilyName",
  0xDD03 => "Prefix",
  0xDD04 => "Suffix",
  0xDD05 => "PhoneticGivenName",
  0xDD06 => "PhoneticFamilyName",
  0xDD07 => "EmailPrimary",
  0xDD08 => "EmailPersonal1",
  0xDD09 => "EmailPersonal2",
  0xDD0A => "EmailBusiness1",
  0xDD0B => "EmailBusiness2",
  0xDD0C => "EmailOthers",
  0xDD0D => "PhoneNumberPrimary",
  0xDD0E => "PhoneNumberPersonal",
  0xDD0F => "PhoneNumberPersonal2",
  0xDD10 => "PhoneNumberBusiness",
  0xDD11 => "PhoneNumberBusiness2",
  0xDD12 => "PhoneNumberMobile",
  0xDD13 => "PhoneNumberMobile2",
  0xDD14 => "FaxNumberPrimary",
  0xDD15 => "FaxNumberPersonal",
  0xDD16 => "FaxNumberBusiness",
  0xDD17 => "PagerNumber",
  0xDD18 => "PhoneNumberOthers",
  0xDD19 => "PrimaryWebAddress",
  0xDD1A => "PersonalWebAddress",
  0xDD1B => "BusinessWebAddress",
  0xDD1C => "InstantMessengerAddress",
  0xDD1D => "InstantMessengerAddress2",
  0xDD1E => "InstantMessengerAddress3",
  0xDD1F => "PostalAddressPersonalFull",
  0xDD20 => "PostalAddressPersonalFullLine1",
  0xDD21 => "PostalAddressPersonalFullLine2",
  0xDD22 => "PostalAddressPersonalFullCity",
  0xDD23 => "PostalAddressPersonalFullRegion",
  0xDD24 => "PostalAddressPersonalFullPostalCode",
  0xDD25 => "PostalAddressPersonalFullCountry",
  0xDD26 => "PostalAddressBusinessFull",
  0xDD27 => "PostalAddressBusinessLine1",
  0xDD28 => "PostalAddressBusinessLine2",
  0xDD29 => "PostalAddressBusinessCity",
  0xDD2A => "PostalAddressBusinessRegion",
  0xDD2B => "PostalAddressBusinessPostalCode",
  0xDD2C => "PostalAddressBusinessCountry",
  0xDD2D => "PostalAddressOtherFull",
  0xDD2E => "PostalAddressOtherLine1",
  0xDD2F => "PostalAddressOtherLine2",
  0xDD30 => "PostalAddressOtherCity",
  0xDD31 => "PostalAddressOtherRegion",
  0xDD32 => "PostalAddressOtherPostalCode",
  0xDD33 => "PostalAddressOtherCountry",
  0xDD34 => "OrganizationName",
  0xDD35 => "PhoneticOrganizationName",
  0xDD36 => "Role",
  0xDD37 => "Birthdate",
  0xDD40 => "MessageTo",
  0xDD41 => "MessageCC",
  0xDD42 => "MessageBCC",
  0xDD43 => "MessageRead",
  0xDD44 => "MessageReceivedTime",
  0xDD45 => "MessageSender",
  0xDD50 => "ActivityBeginTime",
  0xDD51 => "ActivityEndTime",
  0xDD52 => "ActivityLocation",
  0xDD54 => "ActivityRequiredAttendees",
  0xDD55 => "ActivityOptionalAttendees",
  0xDD56 => "ActivityResources",
  0xDD57 => "ActivityAccepted",
  0xDD5D => "Owner",
  0xDD5E => "Editor",
  0xDD5F => "Webmaster",
  0xDD60 => "URLSource",
  0xDD61 => "URLDestination",
  0xDD62 => "TimeBookmark",
  0xDD63 => "ObjectBookmark",
  0xDD64 => "ByteBookmark",
  0xDD70 => "LastBuildDate",
  0xDD71 => "TimetoLive",
  0xDD72 => "MediaGUID",
  0xDE91 => "TotalBitRate",
  0xDE92 => "BitRateType",
  0xDE93 => "SampleRate",
  0xDE94 => "NumberOfChannels",
  0xDE95 => "AudioBitDepth",
  0xDE97 => "ScanDepth",
  0xDE99 => "AudioWaveCodec",
  0xDE9A => "AudioBitRate",
  0xDE9B => "VideoFourCCCodec",
  0xDE9C => "VideoBitRate",
  0xDE9D => "FramesPerThousandSeconds",
  0xDE9E => "KeyFrameDistance",
  0xDE9F => "BufferSize",
  0xDEA0 => "EncodingQuality",
  0xD901 => "BuyFlag",
  0xB104 => "WirelessConfigurationFile",
  0xA800 => "MTP_Undefined",
  0xA801 => "MTP_Invalid_ObjectPropCode",
  0xA802 => "MTP_Invalid_ObjectProp_Format",
  0xA803 => "MTP_Invalid_ObjectProp_Value",
  0xA804 => "MTP_Invalid_ObjectReference",
  0xA806 => "MTP_Invalid_Dataset",
  0xA808 => "MTP_Specification_By_Group_Unsupported",
  0xA809 => "MTP_Object_Too_Large"
}
@@name_codes =
{}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(code, hash = nil, mask = nil) ⇒ Datacode

Returns a new instance of Datacode.



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/mtp/datacode.rb', line 15

def initialize(code, hash = nil, mask = nil)
  hash = CODE_NAMES if hash.nil?
  if code.is_a?(String)
    @name = code
    hash.each do |c, value|
      if value == code and (mask.nil? or (c & mask) == mask)
        @code = c
        break
      end
    end
    raise RuntimeError.new("unknown data code: #{code}") if @code.nil?
  else
    @code = code
    @name = hash[@code]
  end
  self.freeze
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args) ⇒ Object



45
46
47
# File 'lib/mtp/datacode.rb', line 45

def method_missing(method, *args)
  @code.send(method, *args)
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



14
15
16
# File 'lib/mtp/datacode.rb', line 14

def name
  @name
end

Instance Method Details

#==(object) ⇒ Object



33
34
35
# File 'lib/mtp/datacode.rb', line 33

def ==(object)
  @code.to_i == object.to_i
end

#inspectObject



49
50
51
# File 'lib/mtp/datacode.rb', line 49

def inspect
  "<Datacode 0x%04x:%s>" % [ @code, @name ]
end

#to_intObject



41
42
43
# File 'lib/mtp/datacode.rb', line 41

def to_int
  @code.to_int
end

#to_sObject



37
38
39
# File 'lib/mtp/datacode.rb', line 37

def to_s
  @name
end