Example #1
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.memFullErr);
            }

            return(PSError.kSPNoError);
        }
Example #2
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);
        }
Example #3
0
        private int PutObject(PIActionList list, uint type, PIActionDescriptor descriptor)
        {
            if (actionDescriptorSuite == null)
            {
                // The plug-in called this method before acquiring the Action Descriptor suite.
                return(PSError.kSPLogicError);
            }

            try
            {
                ReadOnlyDictionary <uint, AETEValue> descriptorValues;
                if (actionDescriptorSuite.TryGetDescriptorValues(descriptor, out descriptorValues))
                {
                    ActionListDescriptor item = new ActionListDescriptor(type, descriptorValues);
                    actionLists[list].Add(new ActionListItem(DescriptorTypes.Object, item));
                }
                else
                {
                    return(PSError.kSPBadParameterError);
                }
            }
            catch (OutOfMemoryException)
            {
                return(PSError.memFullErr);
            }

            return(PSError.kSPNoError);
        }
Example #4
0
        private int PutString(PIActionList list, IntPtr cstrValue)
        {
            if (cstrValue == IntPtr.Zero)
            {
                return(PSError.kSPBadParameterError);
            }

            try
            {
                if (StringUtil.TryGetCStringLength(cstrValue, out int length))
                {
                    byte[] data = new byte[length];
                    Marshal.Copy(cstrValue, data, 0, length);

                    actionLists[list].Add(new ActionListItem(DescriptorTypes.Char, data));
                }
                else
                {
                    // The string length exceeds int.MaxValue.
                    return(PSError.memFullErr);
                }
            }
            catch (OutOfMemoryException)
            {
                return(PSError.memFullErr);
            }

            return(PSError.kSPNoError);
        }
Example #5
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);
        }
Example #6
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);
        }
Example #7
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)
            {
                ActionListItemCollection value = (ActionListItemCollection)items[(int)index].Value;

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

                return(PSError.kSPNoError);
            }

            return(PSError.kSPBadParameterError);
        }
Example #8
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.memFullErr);
                }

                return(PSError.kSPNoError);
            }

            return(PSError.kSPBadParameterError);
        }
Example #9
0
        private int PutAlias(PIActionList list, IntPtr aliasHandle)
        {
            try
            {
                IntPtr hPtr = HandleSuite.Instance.LockHandle(aliasHandle, 0);

                try
                {
                    int    size = HandleSuite.Instance.GetHandleSize(aliasHandle);
                    byte[] data = new byte[size];
                    Marshal.Copy(hPtr, data, 0, size);

                    actionLists[list].Add(new ActionListItem(DescriptorTypes.Alias, data));
                }
                finally
                {
                    HandleSuite.Instance.UnlockHandle(aliasHandle);
                }
            }
            catch (OutOfMemoryException)
            {
                return(PSError.memFullErr);
            }

            return(PSError.kSPNoError);
        }
Example #10
0
        private unsafe int GetAlias(PIActionList list, uint index, IntPtr *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 == 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);
        }
Example #11
0
        private int Free(PIActionList list)
        {
            actionLists.Remove(list);
            if (actionListsIndex == list.Index)
            {
                actionListsIndex--;
            }

            return(PSError.kSPNoError);
        }
Example #12
0
        private int PutBoolean(PIActionList list, byte data)
        {
            try
            {
                actionLists[list].Add(new ActionListItem(DescriptorTypes.Boolean, data));
            }
            catch (OutOfMemoryException)
            {
                return(PSError.memFullErr);
            }

            return(PSError.kSPNoError);
        }
Example #13
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);
        }
Example #14
0
        PIActionList IActionListSuite.CreateFromActionDescriptor(ActionDescriptorList descriptor)
        {
            if (descriptor == null)
            {
                throw new ArgumentNullException(nameof(descriptor));
            }

            PIActionList list = GenerateDictionaryKey();

            actionLists.Add(list, new ActionListItemCollection(descriptor.Items));

            return(list);
        }
Example #15
0
        private int PutGlobalClass(PIActionList list, uint data)
        {
            try
            {
                actionLists[list].Add(new ActionListItem(DescriptorTypes.GlobalClass, data));
            }
            catch (OutOfMemoryException)
            {
                return(PSError.memFullErr);
            }

            return(PSError.kSPNoError);
        }
Example #16
0
        private int PutEnumerated(PIActionList list, uint type, uint data)
        {
            try
            {
                EnumeratedValue item = new EnumeratedValue(type, data);
                actionLists[list].Add(new ActionListItem(DescriptorTypes.Enumerated, item));
            }
            catch (OutOfMemoryException)
            {
                return(PSError.memFullErr);
            }

            return(PSError.kSPNoError);
        }
Example #17
0
        bool IActionListSuite.ConvertToActionDescriptor(PIActionList list, out ActionDescriptorList descriptor)
        {
            descriptor = null;

            ActionListItemCollection items;

            if (actionLists.TryGetValue(list, out items))
            {
                descriptor = items.ConvertToActionDescriptor();

                return(true);
            }

            return(false);
        }
Example #18
0
        private int PutUnitFloat(PIActionList list, uint unit, double data)
        {
            try
            {
                UnitFloat item = new UnitFloat(unit, data);

                actionLists[list].Add(new ActionListItem(DescriptorTypes.UintFloat, item));
            }
            catch (OutOfMemoryException)
            {
                return(PSError.memFullErr);
            }

            return(PSError.kSPNoError);
        }
Example #19
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);
        }
Example #20
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);
        }
Example #21
0
        private unsafe int GetStringLength(PIActionList list, uint index, uint *length)
        {
            if (length == null)
            {
                return(PSError.kSPBadParameterError);
            }

            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);
        }
Example #22
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);
        }
Example #23
0
        private int PutList(PIActionList list, PIActionList data)
        {
            try
            {
                ActionListItemCollection items;
                if (actionLists.TryGetValue(data, out items))
                {
                    actionLists[list].Add(new ActionListItem(DescriptorTypes.ValueList, items.Clone()));
                }
                else
                {
                    return(PSError.kSPBadParameterError);
                }
            }
            catch (OutOfMemoryException)
            {
                return(PSError.memFullErr);
            }

            return(PSError.kSPNoError);
        }
Example #24
0
        private int PutZString(PIActionList list, ASZString zstring)
        {
            try
            {
                ActionDescriptorZString value;
                if (zstringSuite.ConvertToActionDescriptor(zstring, out value))
                {
                    actionLists[list].Add(new ActionListItem(DescriptorTypes.Char, value));
                }
                else
                {
                    return(PSError.kSPBadParameterError);
                }
            }
            catch (OutOfMemoryException)
            {
                return(PSError.memFullErr);
            }

            return(PSError.kSPNoError);
        }
Example #25
0
        private int PutReference(PIActionList list, PIActionReference reference)
        {
            try
            {
                ActionDescriptorReference value;
                if (actionReferenceSuite.ConvertToActionDescriptor(reference, out value))
                {
                    actionLists[list].Add(new ActionListItem(DescriptorTypes.ObjectReference, value));
                }
                else
                {
                    return(PSError.kSPBadParameterError);
                }
            }
            catch (OutOfMemoryException)
            {
                return(PSError.memFullErr);
            }

            return(PSError.kSPNoError);
        }
Example #26
0
        private int PutData(PIActionList list, int length, IntPtr blob)
        {
            if (blob == IntPtr.Zero || length < 0)
            {
                return(PSError.kSPBadParameterError);
            }

            try
            {
                byte[] data = new byte[length];

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

                actionLists[list].Add(new ActionListItem(DescriptorTypes.RawData, data));
            }
            catch (OutOfMemoryException)
            {
                return(PSError.memFullErr);
            }

            return(PSError.kSPNoError);
        }
Example #27
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.memFullErr);
                }

                return(PSError.kSPNoError);
            }

            return(PSError.kSPBadParameterError);
        }
Example #28
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);
        }
Example #29
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);
        }
Example #30
0
 private unsafe int GetGlobalClass(PIActionList list, uint index, uint *data)
 {
     return(GetClass(list, index, data));
 }