Exemple #1
0
        private unsafe int GetZString(PIActionList list, uint index, ASZString *zstring)
        {
            if (zstring == null)
            {
                return(PSError.kSPBadParameterError);
            }

            ActionListItemCollection items = actionLists[list];

            if (index < items.Count)
            {
                ActionDescriptorZString value = (ActionDescriptorZString)items[(int)index].Value;

                try
                {
                    *zstring = zstringSuite.CreateFromActionDescriptor(value);
                }
                catch (OutOfMemoryException)
                {
                    return(PSError.kSPOutOfMemoryError);
                }

                return(PSError.kSPNoError);
            }

            return(PSError.kSPBadParameterError);
        }
Exemple #2
0
        private unsafe int GetReference(PIActionList list, uint index, PIActionReference *reference)
        {
            if (reference == null)
            {
                return(PSError.kSPBadParameterError);
            }

            ActionListItemCollection items = actionLists[list];

            if (index < items.Count)
            {
                ActionDescriptorReference value = (ActionDescriptorReference)items[(int)index].Value;

                try
                {
                    *reference = actionReferenceSuite.CreateFromActionDescriptor(value);
                }
                catch (OutOfMemoryException)
                {
                    return(PSError.memFullErr);
                }

                return(PSError.kSPNoError);
            }

            return(PSError.kSPBadParameterError);
        }
Exemple #3
0
        private unsafe int GetUnitFloat(PIActionList list, uint index, uint *unit, double *data)
        {
            if (data == null)
            {
                return(PSError.kSPBadParameterError);
            }

            ActionListItemCollection items = actionLists[list];

            if (index < items.Count)
            {
                UnitFloat unitFloat = (UnitFloat)items[(int)index].Value;

                if (unit != null)
                {
                    *unit = unitFloat.Unit;
                }

                *data = unitFloat.Value;

                return(PSError.kSPNoError);
            }

            return(PSError.kSPBadParameterError);
        }
Exemple #4
0
        private int GetString(PIActionList list, uint index, IntPtr cstrValue, uint maxLength)
        {
            if (cstrValue == IntPtr.Zero)
            {
                return(PSError.kSPBadParameterError);
            }

            ActionListItemCollection items = actionLists[list];

            if (index < items.Count)
            {
                if (maxLength > 0)
                {
                    byte[] bytes = (byte[])items[(int)index].Value;

                    // Ensure that the buffer has room for the null terminator.
                    int length = (int)Math.Min(bytes.Length, maxLength - 1);

                    Marshal.Copy(bytes, 0, cstrValue, length);
                    Marshal.WriteByte(cstrValue, length, 0);
                }

                return(PSError.kSPNoError);
            }

            return(PSError.kSPBadParameterError);
        }
Exemple #5
0
        private unsafe int GetList(PIActionList list, uint index, PIActionList *data)
        {
            if (data == null)
            {
                return(PSError.kSPBadParameterError);
            }

            ActionListItemCollection items = actionLists[list];

            if (index < items.Count)
            {
                ReadOnlyCollection <ActionListItem> value = (ReadOnlyCollection <ActionListItem>)items[(int)index].Value;

                try
                {
                    *data = GenerateDictionaryKey();
                    actionLists.Add(*data, new ActionListItemCollection(value));
                }
                catch (OutOfMemoryException)
                {
                    return(PSError.kSPOutOfMemoryError);
                }

                return(PSError.kSPNoError);
            }

            return(PSError.kSPBadParameterError);
        }
Exemple #6
0
        private unsafe int GetAlias(PIActionList list, uint index, Handle *data)
        {
            if (data == null)
            {
                return(PSError.kSPBadParameterError);
            }

            ActionListItemCollection items = actionLists[list];

            if (index < items.Count)
            {
                byte[] bytes = (byte[])items[(int)index].Value;
                *      data  = HandleSuite.Instance.NewHandle(bytes.Length);

                if (*data == Handle.Null)
                {
                    return(PSError.kSPOutOfMemoryError);
                }

                Marshal.Copy(bytes, 0, HandleSuite.Instance.LockHandle(*data, 0), bytes.Length);
                HandleSuite.Instance.UnlockHandle(*data);

                return(PSError.kSPNoError);
            }

            return(PSError.kSPBadParameterError);
        }
Exemple #7
0
        private unsafe int GetReference(PIActionList list, uint index, PIActionReference *reference)
        {
            if (reference == null)
            {
                return(PSError.kSPBadParameterError);
            }

            ActionListItemCollection items = actionLists[list];

            if (index < items.Count)
            {
                ReadOnlyCollection <ActionReferenceItem> value = (ReadOnlyCollection <ActionReferenceItem>)items[(int)index].Value;

                try
                {
                    *reference = actionReferenceSuite.CreateReference(value);
                }
                catch (OutOfMemoryException)
                {
                    return(PSError.kSPOutOfMemoryError);
                }

                return(PSError.kSPNoError);
            }

            return(PSError.kSPBadParameterError);
        }
Exemple #8
0
        private int PutIntegers(PIActionList list, uint count, IntPtr arrayPointer)
        {
            if (arrayPointer == IntPtr.Zero)
            {
                return(PSError.kSPBadParameterError);
            }

            try
            {
                unsafe
                {
                    ActionListItemCollection items = actionLists[list];
                    int *ptr = (int *)arrayPointer;

                    for (uint i = 0; i < count; i++)
                    {
                        items.Add(new ActionListItem(DescriptorTypes.Integer, *ptr));
                        ptr++;
                    }
                }
            }
            catch (OutOfMemoryException)
            {
                return(PSError.kSPOutOfMemoryError);
            }

            return(PSError.kSPNoError);
        }
        private int GetCount(IntPtr list, ref uint count)
        {
            ActionListItemCollection items = actionLists[list];

            count = (uint)items.Count;

            return(PSError.kSPNoError);
        }
Exemple #10
0
        private unsafe int GetCount(PIActionList list, uint *count)
        {
            if (count == null)
            {
                return(PSError.kSPBadParameterError);
            }

            ActionListItemCollection items = actionLists[list];

            *count = (uint)items.Count;

            return(PSError.kSPNoError);
        }
        private int GetType(IntPtr list, uint index, ref uint type)
        {
            ActionListItemCollection items = actionLists[list];

            if (index < items.Count)
            {
                type = items[(int)index].Type;

                return(PSError.kSPNoError);
            }

            return(PSError.kSPBadParameterError);
        }
        private int GetClass(IntPtr list, uint index, ref uint data)
        {
            ActionListItemCollection items = actionLists[list];

            if (index < items.Count)
            {
                data = (uint)items[(int)index].Value;

                return(PSError.kSPNoError);
            }

            return(PSError.kSPBadParameterError);
        }
        private int GetStringLength(IntPtr list, uint index, ref uint length)
        {
            ActionListItemCollection items = actionLists[list];

            if (index < items.Count)
            {
                byte[] bytes = (byte[])items[(int)index].Value;

                length = (uint)bytes.Length;

                return(PSError.kSPNoError);
            }

            return(PSError.kSPBadParameterError);
        }
Exemple #14
0
        private unsafe int GetClass(PIActionList list, uint index, uint *data)
        {
            if (data == null)
            {
                return(PSError.kSPBadParameterError);
            }

            ActionListItemCollection items = actionLists[list];

            if (index < items.Count)
            {
                *data = (uint)items[(int)index].Value;

                return(PSError.kSPNoError);
            }

            return(PSError.kSPBadParameterError);
        }
Exemple #15
0
        private unsafe int GetType(PIActionList list, uint index, uint *type)
        {
            if (type == null)
            {
                return(PSError.kSPBadParameterError);
            }

            ActionListItemCollection items = actionLists[list];

            if (index < items.Count)
            {
                *type = items[(int)index].Type;

                return(PSError.kSPNoError);
            }

            return(PSError.kSPBadParameterError);
        }
Exemple #16
0
        private int GetData(PIActionList list, uint index, IntPtr blob)
        {
            if (blob == IntPtr.Zero)
            {
                return(PSError.kSPBadParameterError);
            }

            ActionListItemCollection items = actionLists[list];

            if (index < items.Count)
            {
                byte[] data = (byte[])items[(int)index].Value;

                Marshal.Copy(data, 0, blob, data.Length);

                return(PSError.kSPNoError);
            }

            return(PSError.kSPBadParameterError);
        }
Exemple #17
0
        private unsafe int GetDataLength(PIActionList list, uint index, int *length)
        {
            if (length == null)
            {
                return(PSError.kSPBadParameterError);
            }

            ActionListItemCollection items = actionLists[list];

            if (index < items.Count)
            {
                byte[] bytes = (byte[])items[(int)index].Value;

                *length = bytes.Length;

                return(PSError.kSPNoError);
            }

            return(PSError.kSPBadParameterError);
        }
        private int GetEnumerated(IntPtr list, uint index, ref uint type, ref uint data)
        {
            ActionListItemCollection items = actionLists[list];

            if (index < items.Count)
            {
                EnumeratedValue enumerated = (EnumeratedValue)items[(int)index].Value;
                try
                {
                    type = enumerated.Type;
                }
                catch (NullReferenceException)
                {
                }

                data = enumerated.Value;

                return(PSError.kSPNoError);
            }

            return(PSError.kSPBadParameterError);
        }
        private int GetAlias(IntPtr list, uint index, ref IntPtr data)
        {
            ActionListItemCollection items = actionLists[list];

            if (index < items.Count)
            {
                byte[] bytes = (byte[])items[(int)index].Value;
                data = HandleSuite.Instance.NewHandle(bytes.Length);

                if (data == IntPtr.Zero)
                {
                    return(PSError.memFullErr);
                }

                Marshal.Copy(bytes, 0, HandleSuite.Instance.LockHandle(data, 0), bytes.Length);
                HandleSuite.Instance.UnlockHandle(data);

                return(PSError.kSPNoError);
            }

            return(PSError.kSPBadParameterError);
        }
        private int GetZString(IntPtr list, uint index, ref IntPtr zstring)
        {
            ActionListItemCollection items = actionLists[list];

            if (index < items.Count)
            {
                ActionDescriptorZString value = (ActionDescriptorZString)items[(int)index].Value;

                try
                {
                    zstring = zstringSuite.CreateFromActionDescriptor(value);
                }
                catch (OutOfMemoryException)
                {
                    return(PSError.memFullErr);
                }

                return(PSError.kSPNoError);
            }

            return(PSError.kSPBadParameterError);
        }
Exemple #21
0
        private unsafe int GetObject(PIActionList list, uint index, uint *retType, PIActionDescriptor *descriptor)
        {
            if (actionDescriptorSuite == null)
            {
                // The plug-in called this method before acquiring the Action Descriptor suite.
                return(PSError.kSPLogicError);
            }

            if (descriptor == null)
            {
                return(PSError.kSPBadParameterError);
            }

            ActionListItemCollection items = actionLists[list];

            if (index < items.Count)
            {
                ActionListDescriptor item = (ActionListDescriptor)items[(int)index].Value;

                if (retType != null)
                {
                    *retType = item.Type;
                }

                try
                {
                    *descriptor = actionDescriptorSuite.CreateDescriptor(item.DescriptorValues);
                }
                catch (OutOfMemoryException)
                {
                    return(PSError.kSPOutOfMemoryError);
                }

                return(PSError.kSPNoError);
            }

            return(PSError.kSPBadParameterError);
        }
        private int GetUnitFloat(IntPtr list, uint index, ref uint unit, ref double data)
        {
            ActionListItemCollection items = actionLists[list];

            if (index < items.Count)
            {
                UnitFloat unitFloat = (UnitFloat)items[(int)index].Value;

                try
                {
                    unit = unitFloat.Unit;
                }
                catch (NullReferenceException)
                {
                }

                data = unitFloat.Value;

                return(PSError.kSPNoError);
            }

            return(PSError.kSPBadParameterError);
        }
        private int GetList(IntPtr list, uint index, ref IntPtr data)
        {
            ActionListItemCollection items = actionLists[list];

            if (index < items.Count)
            {
                ActionListItemCollection value = (ActionListItemCollection)items[(int)index].Value;

                try
                {
                    data = GenerateDictionaryKey();
                    actionLists.Add(list, value);
                }
                catch (OutOfMemoryException)
                {
                    return(PSError.memFullErr);
                }

                return(PSError.kSPNoError);
            }

            return(PSError.kSPBadParameterError);
        }
        private int GetObject(IntPtr list, uint index, ref uint retType, ref IntPtr descriptor)
        {
            if (actionDescriptorSuite == null)
            {
                // The plug-in called this method before acquiring the Action Descriptor suite.
                return(PSError.kSPLogicError);
            }

            ActionListItemCollection items = actionLists[list];

            if (index < items.Count)
            {
                ActionListDescriptor item = (ActionListDescriptor)items[(int)index].Value;

                try
                {
                    retType = item.Type;
                }
                catch (NullReferenceException)
                {
                    // ignore it
                }

                try
                {
                    descriptor = actionDescriptorSuite.CreateDescriptor(item.DescriptorValues);
                }
                catch (OutOfMemoryException)
                {
                    return(PSError.memFullErr);
                }

                return(PSError.kSPNoError);
            }

            return(PSError.kSPBadParameterError);
        }
Exemple #25
0
        private int GetIntegers(PIActionList list, uint count, IntPtr data)
        {
            if (data == IntPtr.Zero)
            {
                return(PSError.kSPBadParameterError);
            }

            ActionListItemCollection items = actionLists[list];

            if (count <= items.Count)
            {
                int valueCount = (int)count;
                unsafe
                {
                    int *ptr = (int *)data.ToPointer();

                    for (int i = 0; i < valueCount; i++)
                    {
                        ActionListItem item = items[i];

                        // The first through valueCount items in the list are required to be integers.
                        if (item.Type != DescriptorTypes.Integer)
                        {
                            return(PSError.kSPLogicError);
                        }

                        *ptr = (int)item.Value;
                        ptr++;
                    }
                }

                return(PSError.kSPNoError);
            }

            return(PSError.kSPBadParameterError);
        }
Exemple #26
0
        private unsafe int GetEnumerated(PIActionList list, uint index, uint *type, uint *data)
        {
            if (data == null)
            {
                return(PSError.kSPBadParameterError);
            }

            ActionListItemCollection items = actionLists[list];

            if (index < items.Count)
            {
                EnumeratedValue enumerated = (EnumeratedValue)items[(int)index].Value;
                if (type != null)
                {
                    *type = enumerated.Type;
                }

                *data = enumerated.Value;

                return(PSError.kSPNoError);
            }

            return(PSError.kSPBadParameterError);
        }
 private ActionListItemCollection(ActionListItemCollection cloneMe) : base(new List <ActionListItem>(cloneMe.Items))
 {
 }