示例#1
0
        private Item(MediaDevice device, string id, string path)
        {
            this.device = device;
            this.Id     = id;
            this.path   = path;
            if (id == Item.RootId)
            {
                this.Name     = @"\";
                this.FullName = @"\";
                this.Type     = ItemType.Object;
            }
            else
            {
                this.deviceProperties = device.deviceProperties;
                this.deviceProperties.GetSupportedProperties(id, out keyCollection);
                //ComTrace.WriteObject(this.deviceProperties, id);
                Refresh();

                // find full name if no path
                if (string.IsNullOrEmpty(this.path))
                {
                    string p = GetPath();
                    this.path     = Path.GetDirectoryName(p);
                    this.FullName = p;
                }
            }
        }
示例#2
0
        private static string GetNameById(string objectId, IPortableDeviceProperties properties)
        {
            IPortableDeviceValues objectValues;

            properties.GetValues(objectId, null, out objectValues);
            return(GetNameProperty(objectValues));
        }
示例#3
0
        private static MTPFileNodeType GetFileTypeById(string objectId, IPortableDeviceProperties properties)
        {
            IPortableDeviceValues objectValues;

            properties.GetValues(objectId, null, out objectValues);
            return(GetFileTypeProperty(objectValues));
        }
示例#4
0
        private void EnumerateContents(ref IPortableDeviceContent content, ref IPortableDeviceProperties properties, PortableDeviceFolder parent, Queue <PortableDeviceObject> queue, int?depth, bool folderOnly = false)
        {
            content.EnumObjects(0, parent.Id, null, out IEnumPortableDeviceObjectIDs objectIDs);

            try
            {
                uint fetched = 0;
                do
                {
                    objectIDs.Next(1, out string nextObjectIDs, ref fetched);

                    if (fetched > 0)
                    {
                        var item = WrapObject(properties, nextObjectIDs);

                        if (!folderOnly || item.IsFolder)
                        {
                            parent.Files.Add(item);
                        }

                        if (depth == null || depth > 1)
                        {
                            queue.Enqueue(item);
                        }
                    }
                } while (fetched > 0);
            }
            finally
            {
                Marshal.ReleaseComObject(objectIDs);
            }
        }
示例#5
0
        private static PortableDeviceObject WrapObject(IPortableDeviceProperties properties,
                                                       string objectId)
        {
            properties.GetSupportedProperties(objectId, out IPortableDeviceKeyCollection keys);
            properties.GetValues(objectId, keys, out IPortableDeviceValues values);
            // Get the name of the object
            var property = new _tagpropertykey
            {
                fmtid = CreateFmtidGuid(),
                pid   = 4
            };

            values.GetStringValue(property, out string name);
            // Get the type of the object
            property = new _tagpropertykey
            {
                fmtid = CreateFmtidGuid(),
                pid   = 7
            };
            values.GetGuidValue(property, out Guid contentType);
            var folderType = new Guid(0x27E2E392, 0xA111, 0x48E0, 0xAB, 0x0C,
                                      0xE1, 0x77, 0x05, 0xA0, 0x5F, 0x85);
            var functionalType = new Guid(0x99ED0160, 0x17FF, 0x4C44, 0x9D, 0x98,
                                          0x1D, 0x7A, 0x6F, 0x94, 0x19, 0x21);

            if (contentType == folderType || contentType == functionalType)
            {
                return(new PortableDeviceFolder(objectId, name));
            }
            property.pid = 12;//WPD_OBJECT_ORIGINAL_FILE_NAME
            values.GetStringValue(property, out name);
            return(new PortableDeviceFile(objectId, name));
        }
示例#6
0
        public void Refresh()
        {
            if (this.Count > 0)
            {
                this.Clear();
            }

            IPortableDeviceProperties properties = null;

            this.content.Properties(out properties);

            IPortableDeviceValues values = null;

            properties.GetValues(this.objectID, null, out values);

            var count = 0U;

            values.GetCount(ref count);

            var key     = new _tagpropertykey();
            var propVar = new tag_inner_PROPVARIANT();

            for (var i = 0U; i < count; i++)
            {
                values.GetAt(i, ref key, ref propVar);
                this.Add(WpdProperty.Create(key, propVar));
            }
        }
示例#7
0
        public DeviceProperties(IPortableDeviceProperties deviceProperties)
        {
            IPortableDeviceKeyCollection keys;

            deviceProperties.GetSupportedProperties(Item.RootId, out keys);
            deviceProperties.GetValues(Item.RootId, keys, out this.values);
        }
示例#8
0
        public ObjectProperties(IPortableDeviceProperties deviceProperties, string objectId)
        {
            IPortableDeviceKeyCollection keys;

            deviceProperties.GetSupportedProperties(objectId, out keys);
            deviceProperties.GetValues(objectId, keys, out this.values);
        }
示例#9
0
        private static PortableDeviceObject WrapObject(IPortableDeviceProperties properties,
                                                       string objectId)
        {
            IPortableDeviceKeyCollection keys;

            properties.GetSupportedProperties(objectId, out keys);

            IPortableDeviceValues values;

            properties.GetValues(objectId, keys, out values);

            // Get the name of the object
            string name;
            var    property = new _tagpropertykey();

            property.fmtid = new Guid(0xEF6B490D, 0x5CD8, 0x437A, 0xAF, 0xFC,
                                      0xDA, 0x8B, 0x60, 0xEE, 0x4A, 0x3C);
            property.pid = 4;
            values.GetStringValue(property, out name);

            // Get the type of the object
            Guid contentType;

            property       = new _tagpropertykey();
            property.fmtid = new Guid(0xEF6B490D, 0x5CD8, 0x437A, 0xAF, 0xFC,
                                      0xDA, 0x8B, 0x60, 0xEE, 0x4A, 0x3C);
            property.pid = 7;
            values.GetGuidValue(property, out contentType);

            // Check if the object is folder or file
            var folderType = new Guid(0x27E2E392, 0xA111, 0x48E0, 0xAB, 0x0C,
                                      0xE1, 0x77, 0x05, 0xA0, 0x5F, 0x85);
            var functionalType = new Guid(0x99ED0160, 0x17FF, 0x4C44, 0x9D, 0x98,
                                          0x1D, 0x7A, 0x6F, 0x94, 0x19, 0x21);

            if (contentType == folderType || contentType == functionalType)
            {
                return(new PortableDeviceFolder(objectId, name, 0));
            }
            else
            {
                // Get the name of the object
                property       = new _tagpropertykey();
                property.fmtid = new Guid(0xEF6B490D, 0x5CD8, 0x437A, 0xAF, 0xFC,
                                          0xDA, 0x8B, 0x60, 0xEE, 0x4A, 0x3C);
                property.pid = 12;
                values.GetStringValue(property, out name);

                // Get the size of the object
                ulong size;
                property       = new _tagpropertykey();
                property.fmtid = new Guid(0xEF6B490D, 0x5CD8, 0x437A, 0xAF, 0xFC,
                                          0xDA, 0x8B, 0x60, 0xEE, 0x4A, 0x3C);
                property.pid = 11;
                values.GetUnsignedLargeIntegerValue(property, out size);

                return(new PortableDeviceFile(objectId, name, size));
            }
        }
示例#10
0
        /// インスタンスを初期化します。
        /// </summary>
        /// <param name="id">オブジェクトの識別子。</param>
        /// <param name="client">デバイスに接続しているクライアント情報。</param>
        /// <param name="content">デバイスのコンテンツ情報。</param>
        /// <param name="properties">プロパティ。</param>
        internal WpdObject( string id, WpdClient client, IPortableDeviceContent content, IPortableDeviceProperties properties )
        {
            this.Id          = id;
            this._client     = client;
            this._content    = content;
            this._properties = properties;

            // プロパティ更新
            this.UpdateValues();
        }
示例#11
0
        public static void WriteObject(IPortableDeviceProperties deviceProperties, string objectId)
        {
            IPortableDeviceKeyCollection keys;

            deviceProperties.GetSupportedProperties(objectId, out keys);

            IPortableDeviceValues values;

            deviceProperties.GetValues(objectId, keys, out values);

            InternalWriteObject(values);
        }
示例#12
0
        public static void WriteObject(IPortableDeviceProperties deviceProperties, string objectId)
        {
#if COM_TRACE_ENABLE
            IPortableDeviceKeyCollection keys;
            deviceProperties.GetSupportedProperties(objectId, out keys);

            IPortableDeviceValues values;
            deviceProperties.GetValues(objectId, keys, out values);

            WriteObject(values);
#endif
        }
        /**
         * Wrap Object
         */
        private static PortableDeviceObject WrapObject(IPortableDeviceProperties properties, string objectId)
        {
            IPortableDeviceKeyCollection keys;

            properties.GetSupportedProperties(objectId, out keys);

            IPortableDeviceValues values;

            properties.GetValues(objectId, keys, out values);

            // Get the name of the object
            string name     = string.Empty;
            var    property = new _tagpropertykey();

            property.fmtid = new Guid(0xEF6B490D, 0x5CD8, 0x437A, 0xAF, 0xFC, 0xDA, 0x8B, 0x60, 0xEE, 0x4A, 0x3C);
            property.pid   = 12;
            try { values.GetStringValue(property, out name); }
            catch (Exception)
            {
                property.pid = 4;
                try { values.GetStringValue(property, out name); }
                catch (Exception) { name = "Unknown"; }
            }


            // Get the type of the object
            Guid contentType;

            property       = new _tagpropertykey();
            property.fmtid = new Guid(0xEF6B490D, 0x5CD8, 0x437A, 0xAF, 0xFC, 0xDA, 0x8B, 0x60, 0xEE, 0x4A, 0x3C);
            property.pid   = 7;
            values.GetGuidValue(property, out contentType);

            var folderType     = new Guid(0x27E2E392, 0xA111, 0x48E0, 0xAB, 0x0C, 0xE1, 0x77, 0x05, 0xA0, 0x5F, 0x85);
            var functionalType = new Guid(0x99ED0160, 0x17FF, 0x4C44, 0x9D, 0x98, 0x1D, 0x7A, 0x6F, 0x94, 0x19, 0x21);

            if (contentType == folderType || contentType == functionalType)
            {
                return(new PortableDeviceFolder(objectId, name));
            }

            // Get the size of the object
            long objSiz;

            property       = new _tagpropertykey();
            property.fmtid = new Guid("EF6B490D-5CD8-437A-AFFC-DA8B60EE4A3C");
            property.pid   = 11; //WPD_OBJECT_SIZE;
            values.GetSignedLargeIntegerValue(property, out objSiz);

            return(new PortableDeviceFile(objectId, name, objSiz));
        }
        private PortableDeviceObject ExtractInformation(IPortableDeviceProperties properties, string objectId)
        {
            IPortableDeviceKeyCollection keys;

            properties.GetSupportedProperties(objectId, out keys);

            IPortableDeviceValues values;

            properties.GetValues(objectId, keys, out values);

            Guid guid;

            values.GetGuidValue(ref PortableDevicePKeys.WPD_OBJECT_CONTENT_TYPE, out guid);

            return(PortableDeviceObjectFactory.Instance.CreateInstance(guid, values));
        }
        private static PortableDeviceObject WrapObject(IPortableDeviceProperties properties, string objectId)
        {
            PortableDeviceApiLib.IPortableDeviceKeyCollection portableDeviceKeyCollection;
            PortableDeviceApiLib.IPortableDeviceValues        portableDeviceValue;
            Guid guid;

            properties.GetSupportedProperties(objectId, out portableDeviceKeyCollection);
            properties.GetValues(objectId, portableDeviceKeyCollection, out portableDeviceValue);

            string empty = string.Empty;

            PortableDeviceApiLib._tagpropertykey __tagpropertykey = new PortableDeviceApiLib._tagpropertykey()
            {
                fmtid = new Guid(-278181619, 23768, 17274, 175, 252, 218, 139, 96, 238, 74, 60)
            };

            __tagpropertykey = new PortableDeviceApiLib._tagpropertykey()
            {
                fmtid = new Guid(-278181619, 23768, 17274, 175, 252, 218, 139, 96, 238, 74, 60),
                pid   = 7
            };

            PortableDeviceApiLib._tagpropertykey __tagpropertykey1 = __tagpropertykey;
            portableDeviceValue.GetGuidValue(ref __tagpropertykey1, out guid);

            Guid guid1 = new Guid(669180818, 41233, 18656, 171, 12, 225, 119, 5, 160, 95, 133);
            Guid guid2 = new Guid(-1712520864, 6143, 19524, 157, 152, 29, 122, 111, 148, 25, 33);

            try
            {
                __tagpropertykey.pid = 12;
                PortableDeviceApiLib._tagpropertykey __tagpropertykey2 = __tagpropertykey;
                portableDeviceValue.GetStringValue(ref __tagpropertykey2, out empty);
            }
            catch
            {
            }

            if (!(guid == guid1) && !(guid == guid2))
            {
                return(new PortableDeviceFile(objectId, empty));
            }

            return(new PortableDeviceFolder(objectId, empty));
        }
示例#16
0
 /// <summary>
 /// Special small constructor for GetPath.
 /// </summary>
 /// <param name="device"></param>
 /// <param name="id"></param>
 private Item(MediaDevice device, string id)
 {
     this.device = device;
     this.Id     = id;
     if (id == Item.RootId)
     {
         this.Name     = @"\";
         this.FullName = @"\";
         this.Type     = ItemType.Object;
     }
     else
     {
         this.deviceProperties = device.deviceProperties;
         this.deviceProperties.GetSupportedProperties(id, out keyCollection);
         //ComTrace.WriteObject(this.deviceProperties, id);
         Refresh();
     }
 }
示例#17
0
        private static PortableDeviceObject WrapObject(IPortableDeviceProperties properties,
                                                       string objectId)
        {
            IPortableDeviceKeyCollection keys;

            properties.GetSupportedProperties(objectId, out keys);

            IPortableDeviceValues values;

            properties.GetValues(objectId, keys, out values);

            // Get the name of the object
            string name;
            var    property = new _tagpropertykey();

            property.fmtid = new Guid(0xEF6B490D, 0x5CD8, 0x437A, 0xAF, 0xFC,
                                      0xDA, 0x8B, 0x60, 0xEE, 0x4A, 0x3C);
            property.pid = 4;
            values.GetStringValue(property, out name);

            // Get the type of the object
            Guid contentType;

            property       = new _tagpropertykey();
            property.fmtid = new Guid(0xEF6B490D, 0x5CD8, 0x437A, 0xAF, 0xFC,
                                      0xDA, 0x8B, 0x60, 0xEE, 0x4A, 0x3C);
            property.pid = 7;
            values.GetGuidValue(property, out contentType);

            var folderType = new Guid(0x27E2E392, 0xA111, 0x48E0, 0xAB, 0x0C,
                                      0xE1, 0x77, 0x05, 0xA0, 0x5F, 0x85);
            var functionalType = new Guid(0x99ED0160, 0x17FF, 0x4C44, 0x9D, 0x98,
                                          0x1D, 0x7A, 0x6F, 0x94, 0x19, 0x21);

            if (contentType == folderType || contentType == functionalType)
            {
                return(new PortableDeviceFolder(objectId, name));
            }

            //string fullName;
            property.pid = 12;//WPD_OBJECT_ORIGINAL_FILE_NAME
            values.GetStringValue(property, out name);
            return(new PortableDeviceFile(objectId, name));
        }
示例#18
0
        /// <summary>
        /// オブジェクトのプロパティ値を列挙します。
        /// </summary>
        /// <param name="id">オブジェクトの識別子。</param>
        /// <param name="properties">プロパティ情報。</param>
        /// <returns>プロパティ値のコレクション。</returns>
        internal static IEnumerable <WpdPropertyValue> EnumValues(string id, IPortableDeviceProperties properties)
        {
            IPortableDeviceKeyCollection keys;

            properties.GetSupportedProperties(id, out keys);

            IPortableDeviceValues values;

            properties.GetValues(id, keys, out values);

            uint count = 0;

            values.GetCount(ref count);

            var key  = new _tagpropertykey();
            var info = new tag_inner_PROPVARIANT();

            for (uint i = 0; i < count; ++i)
            {
                values.GetAt(i, ref key, ref info);
                yield return(new WpdPropertyValue(key, info, values));
            }
        }
示例#19
0
        private static PortableDeviceObject WrapObject(IPortableDeviceProperties properties, string objectId)
        {
            IPortableDeviceKeyCollection keys;

            properties.GetSupportedProperties(objectId, out keys);

            IPortableDeviceValues values;

            properties.GetValues(objectId, keys, out values);


            string name = string.Empty;

            values.GetStringValue(ref PortableDeviceConstants.WPD_OBJECT_NAME, out name);

            // Get the type of the object
            Guid contentType;

            values.GetGuidValue(PortableDeviceConstants.WPD_OBJECT_CONTENT_TYPE, out contentType);


            try
            {
                values.GetStringValue(PortableDeviceConstants.WPD_OBJECT_ORIGINAL_FILE_NAME, out name);
            }
            catch (Exception x)
            {
                x.ToString();
            }

            if (contentType == PortableDeviceConstants.WPD_CONTENT_TYPE_FOLDER || contentType == PortableDeviceConstants.WPD_CONTENT_TYPE_FUNCTIONAL_OBJECT)
            {
                return(new PortableDeviceFolder(objectId, name));
            }

            return(new PortableDeviceFile(objectId, name));
        }
        private static PortableDeviceObject WrapObject(IPortableDeviceProperties properties,
                                                       string objectId)
        {
            if (string.IsNullOrEmpty(objectId))
            {
                throw new ArgumentNullException(nameof(objectId));
            }

            IPortableDeviceKeyCollection keys;

            properties.GetSupportedProperties(objectId, out keys);

            IPortableDeviceValues values;

            properties.GetValues(objectId, keys, out values);

            string name;

            // Get the name of the object
            values.GetStringValue(PortableDevicePKeys.WPD_OBJECT_NAME, out name);

            // Get the type of the object
            Guid contentType;

            values.GetGuidValue(PortableDevicePKeys.WPD_OBJECT_CONTENT_TYPE, out contentType);

            if (contentType == PortableDeviceGuids.WPD_CONTENT_TYPE_FOLDER ||
                contentType == PortableDeviceGuids.WPD_CONTENT_TYPE_FUNCTIONAL_OBJECT)
            {
                return(new PortableDeviceFolder(objectId, name));
            }
            string fileName;

            values.GetStringValue(PortableDevicePKeys.WPD_OBJECT_ORIGINAL_FILE_NAME, out fileName);
            return(new PortableDeviceFile(objectId, fileName));
        }
示例#21
0
        private static void EnumerateContents(
            ref IPortableDeviceContent content,
            ref IPortableDeviceProperties properties,
            PortableDeviceFolder parent)
        {
            // Enumerate the items contained by the current object
            IEnumPortableDeviceObjectIDs objectIds;

            content.EnumObjects(0, parent.Id, null, out objectIds);

            uint fetched = 0;

            do
            {
                string objectId;

                objectIds.Next(1, out objectId, ref fetched);
                if (fetched > 0)
                {
                    var currentObject = WrapObject(properties, objectId);
                    parent.Files.Add(currentObject);
                }
            } while (fetched > 0);
        }
示例#22
0
        private PortableDeviceObject WrapObject(IPortableDeviceProperties properties, string objectID)
        {
            properties.GetSupportedProperties(objectID, out IPortableDeviceKeyCollection keys);

            properties.GetValues(objectID, keys, out IPortableDeviceValues values);

            try
            {
                // Get the type of the object
                Guid contentType = Guid.Empty;
                try { values.GetGuidValue(GlobalVar.WPD_OBJECT_CONTENT_TYPE, out contentType); }
                catch (Exception ex) { Debug.WriteLine(ex.Message); }

                string name = "";

                if (contentType == GlobalVar.WPD_CONTENT_TYPE_FOLDER_GUID || contentType == GlobalVar.WPD_CONTENT_TYPE_FUNCTIONAL_OBJECT_GUID)
                {
                    // Get the name of the folder/storage
                    try { values.GetStringValue(GlobalVar.WPD_OBJECT_NAME, out name); }
                    catch (Exception ex) { Debug.WriteLine(ex.Message); }

                    return(new PortableDeviceFolder(objectID, name));
                }

                // Get the name of the file
                try { values.GetStringValue(GlobalVar.WPD_OBJECT_ORIGINAL_FILE_NAME, out name); }
                catch (Exception ex) { Debug.WriteLine(ex.Message); }

                return(new PortableDeviceFile(objectID, name));
            }
            finally
            {
                Marshal.ReleaseComObject(keys);
                Marshal.ReleaseComObject(values);
            }
        }
示例#23
0
        private PortableDeviceObject ExtractInformation(IPortableDeviceProperties properties, string objectId)
        {
            IPortableDeviceKeyCollection keys;
            properties.GetSupportedProperties(objectId, out keys);

            IPortableDeviceValues values;
            properties.GetValues(objectId, keys, out values);

            Guid guid;
            values.GetGuidValue(ref PortableDevicePKeys.WPD_OBJECT_CONTENT_TYPE, out guid);

            return PortableDeviceObjectFactory.Instance.CreateInstance(guid, values);
        }
        protected static new NwdPortableDeviceObject WrapObject(IPortableDeviceProperties properties,
                       string objectId)
        {
            IPortableDeviceKeyCollection keys;
            properties.GetSupportedProperties(objectId, out keys);

            IPortableDeviceValues values;
            properties.GetValues(objectId, keys, out values);

            //Get the name of the object
            string name;
            var property = new _tagpropertykey();
            property.fmtid = new Guid(0xEF6B490D, 0x5CD8, 0x437A,
                                      0xAF, 0xFC, 0xDA, 0x8B, 0x60,
                                      0xEE, 0x4A, 0x3C);
            property.pid = 4;
            values.GetStringValue(property, out name);

            // Get the type of the object
            Guid contentType;
            property = new _tagpropertykey();
            property.fmtid = new Guid(0xEF6B490D, 0x5CD8, 0x437A,
                                      0xAF, 0xFC, 0xDA, 0x8B, 0x60,
                                      0xEE, 0x4A, 0x3C);
            property.pid = 7;
            values.GetGuidValue(property, out contentType);

            var folderType = new Guid(0x27E2E392, 0xA111, 0x48E0,
                                      0xAB, 0x0C, 0xE1, 0x77, 0x05,
                                      0xA0, 0x5F, 0x85);
            var functionalType = new Guid(0x99ED0160, 0x17FF, 0x4C44,
                                          0x9D, 0x98, 0x1D, 0x7A, 0x6F,
                                          0x94, 0x19, 0x21);

            if (contentType == folderType ||
                contentType == functionalType)
            {
                return new NwdPortableDeviceFolder(objectId, name);
            }
            //TODO: LICENSE NOTES
            //begin test edit
            //per: http://stackoverflow.com/questions/18059234/get-full-name-of-a-file-on-a-windows-portable-device
            property.fmtid = new Guid(0xEF6B490D, 0x5CD8, 0x437A,
                                      0xAF, 0xFC, 0xDA, 0x8B, 0x60,
                                      0xEE, 0x4A, 0x3C);
            property.pid = 12; //WPD_OBJECT_ORIGINAL_FILE_NAME
            values.GetStringValue(property, out name);
            //end test edit

            return new NwdPortableDeviceFile(objectId, name);
        }
示例#25
0
        private TransFileObject WrapObject(IPortableDeviceProperties properties, string objectId)
        {
            IPortableDeviceKeyCollection keys;

            properties.GetSupportedProperties(objectId, out keys);

            IPortableDeviceValues values;

            properties.GetValues(objectId, keys, out values);

            // Get the name of the object
            string name;
            var    property = new _tagpropertykey();

            property.fmtid = new Guid(0xEF6B490D, 0x5CD8, 0x437A, 0xAF, 0xFC, 0xDA, 0x8B, 0x60, 0xEE, 0x4A, 0x3C);
            property.pid   = 4;

            try {
                values.GetStringValue(property, out name);
            }
            catch (COMException e) {
                name = "(non name)";
            }

            // Get the original name of the object
            string OriginalName;

            property       = new _tagpropertykey();
            property.fmtid = new Guid(0xEF6B490D, 0x5CD8, 0x437A, 0xAF, 0xFC, 0xDA, 0x8B, 0x60, 0xEE, 0x4A, 0x3C);
            property.pid   = 12;
            try {
                values.GetStringValue(property, out OriginalName);
            }
            catch (COMException e) {
                OriginalName = "";
            }

            // Get last write time
            DateTime updatetime = new DateTime();

            property       = new _tagpropertykey();
            property.fmtid = new Guid(0xEF6B490D, 0x5CD8, 0x437A, 0xAF, 0xFC, 0xDA, 0x8B, 0x60, 0xEE, 0x4A, 0x3C);
            property.pid   = 19;
            try {
                string value;
                values.GetStringValue(property, out value);
                string format = "yyyy/MM/dd:HH:mm:ss.fff";
                updatetime = DateTime.ParseExact(value, format, null);
            }
            catch (COMException e) {
                //updatetime = DateTime.Now;
            }

            // Get the type of the object
            Guid contentType;

            property       = new _tagpropertykey();
            property.fmtid = new Guid(0xEF6B490D, 0x5CD8, 0x437A, 0xAF, 0xFC, 0xDA, 0x8B, 0x60, 0xEE, 0x4A, 0x3C);
            property.pid   = 7;
            try {
                values.GetGuidValue(property, out contentType);
            }
            catch (COMException e) {
                return(new TransFileObject(name, null, updatetime, TransFileObject.ObjectKind.DIR));
            }

            Guid folderType     = new Guid(0x27E2E392, 0xA111, 0x48E0, 0xAB, 0x0C, 0xE1, 0x77, 0x05, 0xA0, 0x5F, 0x85);
            Guid functionalType = new Guid(0x99ED0160, 0x17FF, 0x4C44, 0x9D, 0x98, 0x1D, 0x7A, 0x6F, 0x94, 0x19, 0x21);

            if (contentType == folderType || contentType == functionalType)
            {
                return(new TransFileObject(name, objectId, updatetime, TransFileObject.ObjectKind.DIR));
            }

            if (OriginalName.CompareTo("") != 0)
            {
                name = OriginalName;
            }

            return(new TransFileObject(name, objectId, updatetime, TransFileObject.ObjectKind.FILE));
        }
        private static PortableDeviceObject WrapObject(IPortableDeviceProperties properties,
            string objectId)
        {
            IPortableDeviceKeyCollection keys;
            properties.GetSupportedProperties(objectId, out keys);

            IPortableDeviceValues values;
            properties.GetValues(objectId, keys, out values);

            // Get the name of the object
            string name;
            string date;
            string size;
            var property = new _tagpropertykey();
            property.fmtid = new Guid(0xEF6B490D, 0x5CD8, 0x437A, 0xAF, 0xFC,
                                      0xDA, 0x8B, 0x60, 0xEE, 0x4A, 0x3C);
            property.pid = 4;
            values.GetStringValue(property, out name);

            // Get the type of the object
            Guid contentType;
            property = new _tagpropertykey();
            property.fmtid = new Guid(0xEF6B490D, 0x5CD8, 0x437A, 0xAF, 0xFC,
                                      0xDA, 0x8B, 0x60, 0xEE, 0x4A, 0x3C);
            property.pid = 7;
            values.GetGuidValue(property, out contentType);

            var folderType = new Guid(0x27E2E392, 0xA111, 0x48E0, 0xAB, 0x0C,
                                      0xE1, 0x77, 0x05, 0xA0, 0x5F, 0x85);
            var functionalType = new Guid(0x99ED0160, 0x17FF, 0x4C44, 0x9D, 0x98,
                                          0x1D, 0x7A, 0x6F, 0x94, 0x19, 0x21);

            if (contentType == folderType || contentType == functionalType)
            {
                return new PortableDeviceFolder(objectId, name, "", "", 0);
            }

            property.pid = 12;//WPD_OBJECT_ORIGINAL_FILE_NAME
            values.GetStringValue(property, out name);
            try
            {
                property.pid = 19;//WPD_OBJECT_DATE_MODIFIED
                values.GetStringValue(property, out date);
            }
            catch (Exception ex)
            {
                property.pid = 18;//WPD_OBJECT_DATE_MODIFIED
                values.GetStringValue(property, out date);
            }
            property.pid = 11;//WPD_OBJECT_SIZE
            values.GetStringValue(property, out size);
            return new PortableDeviceFile(objectId, name, date, size, Int32.Parse(size));
        }
示例#27
0
        private void CreateTree(MTPFileNode parentNode, IPortableDeviceContent content, IPortableDeviceProperties properties, IAsyncProgress asyn)
        {
            List <string> objectsId = GetChildrenObjectIds(content, parentNode.Id);

            if (objectsId != null && objectsId.Count > 0)
            {
                foreach (string objectId in objectsId)
                {
                    IPortableDeviceValues objectValues;
                    properties.GetValues(objectId, null, out objectValues);
                    MTPFileNode fileNode = new MTPFileNode()
                    {
                        Type = GetFileTypeProperty(objectValues),
                        Name = GetFullNameProperty(objectValues),
                        //FileSize = GetFileSizeProperty(objectValues),
                        Id        = objectId,
                        Childrens = new List <MTPFileNode>(),
                        Parent    = parentNode,
                        //Level = parentNode.Level + 1
                    };

                    parentNode.Childrens.Add(fileNode);

                    //asyn.Advance(0, string.Format(LanguageHelper.Get("LANGKEY_HuoQuJieDian_00555"), fileNode.Name));

                    if (fileNode.Type != MTPFileNodeType.File)
                    {
                        CreateTree(fileNode, content, properties, asyn);
                    }
                }
            }
        }
示例#28
0
        /// インスタンスを初期化します。
        /// </summary>
        /// <param name="id">オブジェクトの識別子。</param>
        /// <param name="client">デバイスに接続しているクライアント情報。</param>
        /// <param name="content">デバイスのコンテンツ情報。</param>
        /// <param name="properties">プロパティ。</param>
        internal WpdObject(string id, WpdClient client, IPortableDeviceContent content, IPortableDeviceProperties properties)
        {
            this.Id          = id;
            this._client     = client;
            this._content    = content;
            this._properties = properties;

            // プロパティ更新
            this.UpdateValues();
        }
示例#29
0
        /// <summary>
        /// オブジェクトのプロパティ値を列挙します。
        /// </summary>
        /// <param name="id">オブジェクトの識別子。</param>
        /// <param name="properties">プロパティ情報。</param>
        /// <returns>プロパティ値のコレクション。</returns>
        internal static IEnumerable<WpdPropertyValue> EnumValues( string id, IPortableDeviceProperties properties )
        {
            IPortableDeviceKeyCollection keys;
            properties.GetSupportedProperties( id, out keys );

            IPortableDeviceValues values;
            properties.GetValues( id, keys, out values );

            uint count = 0;
            values.GetCount( ref count );

            var key  = new _tagpropertykey();
            var info = new tag_inner_PROPVARIANT();

            for( uint i = 0; i < count; ++i )
            {
                values.GetAt( i, ref key, ref info );
                yield return new WpdPropertyValue( key, info, values );
            }
        }
        private static PortableDeviceObject WrapObject(IPortableDeviceProperties properties, 
            string objectId)
        {
            IPortableDeviceKeyCollection keys;
            properties.GetSupportedProperties(objectId, out keys);

            IPortableDeviceValues values;
            properties.GetValues(objectId, keys, out values);

            // Get the name of the object
            string name;
            var property = new _tagpropertykey();
            property.fmtid = new Guid(0xEF6B490D, 0x5CD8, 0x437A, 0xAF, 0xFC,
                                      0xDA, 0x8B, 0x60, 0xEE, 0x4A, 0x3C);
            property.pid = 4;
            values.GetStringValue(property, out name);

            // Get the type of the object
            Guid contentType;
            property = new _tagpropertykey();
            property.fmtid = new Guid(0xEF6B490D, 0x5CD8, 0x437A, 0xAF, 0xFC,
                                      0xDA, 0x8B, 0x60, 0xEE, 0x4A, 0x3C);
            property.pid = 7;
            values.GetGuidValue(property, out contentType);

            var folderType = new Guid(0x27E2E392, 0xA111, 0x48E0, 0xAB, 0x0C,
                                      0xE1, 0x77, 0x05, 0xA0, 0x5F, 0x85);
            var functionalType = new Guid(0x99ED0160, 0x17FF, 0x4C44, 0x9D, 0x98,
                                          0x1D, 0x7A, 0x6F, 0x94, 0x19, 0x21);

            if (contentType == folderType  || contentType == functionalType)
            {
                return new PortableDeviceFolder(objectId, name);
            }

            return new PortableDeviceFile(objectId, name);
        }
示例#31
0
        private static PortableDeviceObject WrapObject(IPortableDeviceProperties properties,
            string objectId)
        {
            IPortableDeviceKeyCollection keys;
            properties.GetSupportedProperties(objectId, out keys);

            IPortableDeviceValues values;
            properties.GetValues(objectId, keys, out values);


            uint count = 0;
            keys.GetCount(ref count);
            for (uint i = 0; i < count; i++)
            {
                var property_info = new PortableDeviceApiLib._tagpropertykey();
                keys.GetAt(i, ref property_info);
                Console.WriteLine(property_info.fmtid.ToString() + "    " + property_info.pid.ToString());
            }
            //Console.ReadLine();
            //return;
            // Get the name of the object
            string name;
            var property = new _tagpropertykey();
            property.fmtid = new Guid(0xEF6B490D, 0x5CD8, 0x437A, 0xAF, 0xFC,
                                      0xDA, 0x8B, 0x60, 0xEE, 0x4A, 0x3C);
            property.pid = 4;
            try
            {
                values.GetStringValue(property, out name);
            }
            catch (Exception ex)
            {
                try
                {
                    property.pid = 12;
                    values.GetStringValue(property, out name);
                }
                catch
                {
                    name = "ERROR-NOT-FOUND";
                }
            }
            // Get the type of the object
            Guid contentType;
            property = new _tagpropertykey();
            property.fmtid = new Guid(0xEF6B490D, 0x5CD8, 0x437A, 0xAF, 0xFC,
                                      0xDA, 0x8B, 0x60, 0xEE, 0x4A, 0x3C);
            property.pid = 7;
            values.GetGuidValue(property, out contentType);

            var folderType = new Guid(0x27E2E392, 0xA111, 0x48E0, 0xAB, 0x0C,
                                      0xE1, 0x77, 0x05, 0xA0, 0x5F, 0x85);
            var functionalType = new Guid(0x99ED0160, 0x17FF, 0x4C44, 0x9D, 0x98,
                                          0x1D, 0x7A, 0x6F, 0x94, 0x19, 0x21);

            if (contentType == folderType || contentType == functionalType)
            {
                return new PortableDeviceFolder(objectId, name);
            }

            return new PortableDeviceFile(objectId, name);
        }