示例#1
0
        public static InvokeListCursorDirection CursorMoved(BPSEvent ev, out int listID)
        {
            if (ev.Domain != Navigator.Domain)
            {
                throw new ArgumentException("BPSEvent is not a navigator event");
            }
            if ((NavigatorEvents)ev.Code != NavigatorEvents.InvokeListCursorMoved)
            {
                throw new ArgumentException("BPSEvent is not a invoke list cursor-moved event");
            }
            var ptr = ev.DangerousGetHandle();
            var id  = navigator_invoke_event_get_list_id(ptr);

            if (id == BPS.BPS_FAILURE)
            {
                Util.ThrowExceptionForLastErrno();
            }
            listID = id;
            var res = navigator_invoke_event_get_list_cursor_direction(ptr);

            if (res == BPS.BPS_FAILURE)
            {
                Util.ThrowExceptionForLastErrno();
            }
            return((InvokeListCursorDirection)res);
        }
示例#2
0
        public static InvokeQueryResult[] GetResults(BPSEvent ev)
        {
            if (ev.Domain != Navigator.Domain)
            {
                throw new ArgumentException("BPSEvent is not a navigator event");
            }
            if ((NavigatorEvents)ev.Code != NavigatorEvents.InvokeQueryResult)
            {
                throw new ArgumentException("BPSEvent is not a invoke query result event");
            }
            var ptr   = ev.DangerousGetHandle();
            var count = navigator_invoke_event_get_query_result_action_count(ptr);

            if (count < 0)
            {
                return(null);
            }
            else if (count == 0)
            {
                return(new InvokeQueryResult[0]);
            }
            //XXX Should this maybe be an enumeration? As in, someone is only looking for one particular element and don't care about the others... so we don't need to get "all of them"
            var results = new InvokeQueryResult[count];

            for (var i = 0; i < count; i++)
            {
                results[i] = new InvokeQueryResult(navigator_invoke_event_get_query_result_action(ptr, i), ev);
            }
            return(results);
        }
示例#3
0
        public static InvokeFilters GetFilters(BPSEvent ev)
        {
            if (ev.Domain != Navigator.Domain)
            {
                throw new ArgumentException("BPSEvent is not a navigator event");
            }
            if ((NavigatorEvents)ev.Code != NavigatorEvents.InvokeGetFiltersResult)
            {
                throw new ArgumentException("BPSEvent is not a invoke get-filters event");
            }
            var ptr    = ev.DangerousGetHandle();
            var id     = Marshal.PtrToStringAnsi(Navigator.navigator_event_get_id(ptr));
            var target = Marshal.PtrToStringAnsi(navigator_invoke_event_get_filters_target(ptr));
            var count  = navigator_invoke_event_get_filters_count(ptr);

            var filters = new string[count];

            for (var i = 0; i < count; i++)
            {
                filters[i] = Marshal.PtrToStringAnsi(navigator_invoke_event_get_filter(ptr, i));
            }

            var result = new InvokeFilters(target, id);

            result.filters = filters;
            return(result);
        }
示例#4
0
 public static int ErrorCode(BPSEvent ev)
 {
     CheckSupportedEvent(ev, NavigatorEvents.InvokeTargetResult, NavigatorEvents.InvokeSetFiltersResult, NavigatorEvents.InvokeQueryResult);
     var result = navigator_invoke_event_get_error_code(ev.DangerousGetHandle());
     if (result == BPS.BPS_FAILURE)
     {
         Util.ThrowExceptionForLastErrno();
     }
     return result;
 }
示例#5
0
 public static long InvokeSourceGroupID(BPSEvent ev)
 {
     CheckSupportedEvent(ev, NavigatorEvents.InvokeTarget);
     var result = navigator_invoke_event_get_group_id(ev.DangerousGetHandle());
     if (result == BPS.BPS_FAILURE)
     {
         Util.ThrowExceptionForLastErrno();
     }
     return result;
 }
示例#6
0
 public static InvokeTargetType TargetType(BPSEvent ev)
 {
     CheckSupportedEvent(ev, NavigatorEvents.InvokeTargetResult);
     var result = navigator_invoke_event_get_target_type(ev.DangerousGetHandle());
     if (result == BPS.BPS_FAILURE)
     {
         Util.ThrowExceptionForLastErrno();
     }
     return (InvokeTargetType)result;
 }
示例#7
0
 public Invocation()
 {
     Util.GetBPSOrException();
     if (navigator_invoke_invocation_create(out handle) != BPS.BPS_SUCCESS)
     {
         Util.ThrowExceptionForLastErrno();
     }
     ev           = null;
     IsDisposable = true;
 }
示例#8
0
        public static long InvokeSourceGroupID(BPSEvent ev)
        {
            CheckSupportedEvent(ev, NavigatorEvents.InvokeTarget);
            var result = navigator_invoke_event_get_group_id(ev.DangerousGetHandle());

            if (result == BPS.BPS_FAILURE)
            {
                Util.ThrowExceptionForLastErrno();
            }
            return(result);
        }
示例#9
0
        public static InvokeTargetType TargetType(BPSEvent ev)
        {
            CheckSupportedEvent(ev, NavigatorEvents.InvokeTargetResult);
            var result = navigator_invoke_event_get_target_type(ev.DangerousGetHandle());

            if (result == BPS.BPS_FAILURE)
            {
                Util.ThrowExceptionForLastErrno();
            }
            return((InvokeTargetType)result);
        }
示例#10
0
        public static int ErrorCode(BPSEvent ev)
        {
            CheckSupportedEvent(ev, NavigatorEvents.InvokeTargetResult, NavigatorEvents.InvokeSetFiltersResult, NavigatorEvents.InvokeQueryResult);
            var result = navigator_invoke_event_get_error_code(ev.DangerousGetHandle());

            if (result == BPS.BPS_FAILURE)
            {
                Util.ThrowExceptionForLastErrno();
            }
            return(result);
        }
示例#11
0
 public static TimerAction GetTimerRegistrationAction(BPSEvent ev)
 {
     if (ev.Domain != Navigator.Domain)
     {
         throw new ArgumentException("BPSEvent is not a navigator event");
     }
     if ((NavigatorEvents)ev.Code != NavigatorEvents.InvokeTimerRegistration)
     {
         throw new ArgumentException("BPSEvent is not a invoke timer registration event");
     }
     Util.GetBPSOrException();
     return(navigator_invoke_timer_registration_event_get_action(ev.DangerousGetHandle()));
 }
示例#12
0
        private static void CheckSupportedEvent(BPSEvent ev, params NavigatorEvents[] types)
        {
            if (ev.Domain != Navigator.Domain)
            {
                throw new ArgumentException("BPSEvent is not a navigator event");
            }
            var eventType = (NavigatorEvents)ev.Code;

            foreach (var t in types)
            {
                if (t == eventType)
                {
                    return;
                }
            }
            throw new ArgumentException("BPSEvent is not a supported event");
        }
示例#13
0
        public static DialogEvent GetDialogEvent(BPSEvent ev)
        {
            if (ev.Domain != Dialog.Domain)
            {
                throw new ArgumentException("BPSEvent is not a dialog event");
            }
            if (ev.Code != DIALOG_RESPONSE) // There is only one dialog event type right now, so do a simple check against it
            {
                throw new ArgumentException("BPSEvent is an unknown dialog event");
            }
            var    evPtr  = ev.DangerousGetHandle();
            var    diaPtr = dialog_event_get_dialog_instance(evPtr);
            Dialog dia;

            if (!dialogs.TryGetValue(diaPtr, out dia))
            {
                dia = new GenericDialog(diaPtr);
            }
            dia.isVisible = false;
            return(dia.GetEventForDialog(evPtr));
        }
示例#14
0
        public static Invocation GetInvocation(BPSEvent ev)
        {
            if (ev.Domain != Navigator.Domain)
            {
                throw new ArgumentException("BPSEvent is not a navigator event");
            }
            if ((NavigatorEvents)ev.Code != NavigatorEvents.InvokeTarget)
            {
                throw new ArgumentException("BPSEvent is not a invoke target event");
            }
            var ptr = ev.DangerousGetHandle();
            var res = navigator_invoke_event_get_invocation(ptr);

            if (res == IntPtr.Zero)
            {
                var error = Marshal.PtrToStringAnsi(Navigator.navigator_event_get_err(ptr));
                if (error == null)
                {
                    throw new InvalidOperationException("An unkown error occured while trying to get the invocation.");
                }
                switch (error.ToUpperInvariant())
                {
                case "INVOKE_NO_TARGET_ERROR":
                    throw new InvalidOperationException("There is no target identified by the invocation.");

                case "INVOKE_BAD_REQUEST_ERROR":
                    throw new InvalidOperationException("The invocation request specifications do not conform to the permitted parameters of the handler. For example, an image sharing invocation being sent to a target application that cannot share images would result in this error.");

                case "INVOKE_INTERNAL_ERROR":
                    throw new InvalidOperationException("A generic error occured in the internal framework while attempting to retrieve the Invocation.");

                case "INVOKE_TARGET_ERROR":
                    throw new InvalidOperationException("A generic error occured with the target handler.");

                default:
                    throw new InvalidOperationException("An error occured while trying to get the invocation.", new Exception(error));
                }
            }
            return(new Invocation(res, ev));
        }
示例#15
0
 public static InvokeListCursorDirection CursorMoved(BPSEvent ev, out int listID)
 {
     if (ev.Domain != Navigator.Domain)
     {
         throw new ArgumentException("BPSEvent is not a navigator event");
     }
     if ((NavigatorEvents)ev.Code != NavigatorEvents.InvokeListCursorMoved)
     {
         throw new ArgumentException("BPSEvent is not a invoke list cursor-moved event");
     }
     var ptr = ev.DangerousGetHandle();
     var id = navigator_invoke_event_get_list_id(ptr);
     if (id == BPS.BPS_FAILURE)
     {
         Util.ThrowExceptionForLastErrno();
     }
     listID = id;
     var res = navigator_invoke_event_get_list_cursor_direction(ptr);
     if (res == BPS.BPS_FAILURE)
     {
         Util.ThrowExceptionForLastErrno();
     }
     return (InvokeListCursorDirection)res;
 }
示例#16
0
 public static string TargetKey(BPSEvent ev)
 {
     CheckSupportedEvent(ev, NavigatorEvents.InvokeTargetResult);
     return Marshal.PtrToStringAnsi(navigator_invoke_event_get_target(ev.DangerousGetHandle()));
 }
示例#17
0
 private InvokeQueryResult(IntPtr handle, BPSEvent ev)
 {
     this.handle = handle;
     this.ev     = ev;
 }
示例#18
0
 public static string TargetKey(BPSEvent ev)
 {
     CheckSupportedEvent(ev, NavigatorEvents.InvokeTargetResult);
     return(Marshal.PtrToStringAnsi(navigator_invoke_event_get_target(ev.DangerousGetHandle())));
 }
示例#19
0
 public static string InvokeSourcePackageID(BPSEvent ev)
 {
     CheckSupportedEvent(ev, NavigatorEvents.InvokeTarget);
     return Marshal.PtrToStringAnsi(navigator_invoke_event_get_dname(ev.DangerousGetHandle()));
 }
示例#20
0
        public static InvokeFilters GetFilters(BPSEvent ev)
        {
            if (ev.Domain != Navigator.Domain)
            {
                throw new ArgumentException("BPSEvent is not a navigator event");
            }
            if ((NavigatorEvents)ev.Code != NavigatorEvents.InvokeGetFiltersResult)
            {
                throw new ArgumentException("BPSEvent is not a invoke get-filters event");
            }
            var ptr = ev.DangerousGetHandle();
            var id = Marshal.PtrToStringAnsi(Navigator.navigator_event_get_id(ptr));
            var target = Marshal.PtrToStringAnsi(navigator_invoke_event_get_filters_target(ptr));
            var count = navigator_invoke_event_get_filters_count(ptr);

            var filters = new string[count];
            for (var i = 0; i < count; i++)
            {
                filters[i] = Marshal.PtrToStringAnsi(navigator_invoke_event_get_filter(ptr, i));
            }

            var result = new InvokeFilters(target, id);
            result.filters = filters;
            return result;
        }
示例#21
0
 public static DialogEvent GetDialogEvent(BPSEvent ev)
 {
     if (ev.Domain != Dialog.Domain)
     {
         throw new ArgumentException("BPSEvent is not a dialog event");
     }
     if (ev.Code != DIALOG_RESPONSE) // There is only one dialog event type right now, so do a simple check against it
     {
         throw new ArgumentException("BPSEvent is an unknown dialog event");
     }
     var evPtr = ev.DangerousGetHandle();
     var diaPtr = dialog_event_get_dialog_instance(evPtr);
     Dialog dia;
     if (!dialogs.TryGetValue(diaPtr, out dia))
     {
         dia = new GenericDialog(diaPtr);
     }
     dia.isVisible = false;
     return dia.GetEventForDialog(evPtr);
 }
示例#22
0
 public static Invocation GetInvocation(BPSEvent ev)
 {
     if (ev.Domain != Navigator.Domain)
     {
         throw new ArgumentException("BPSEvent is not a navigator event");
     }
     if ((NavigatorEvents)ev.Code != NavigatorEvents.InvokeTarget)
     {
         throw new ArgumentException("BPSEvent is not a invoke target event");
     }
     var ptr = ev.DangerousGetHandle();
     var res = navigator_invoke_event_get_invocation(ptr);
     if (res == IntPtr.Zero)
     {
         var error = Marshal.PtrToStringAnsi(Navigator.navigator_event_get_err(ptr));
         if (error == null)
         {
             throw new InvalidOperationException("An unkown error occured while trying to get the invocation.");
         }
         switch (error.ToUpperInvariant())
         {
             case "INVOKE_NO_TARGET_ERROR":
                 throw new InvalidOperationException("There is no target identified by the invocation.");
             case "INVOKE_BAD_REQUEST_ERROR":
                 throw new InvalidOperationException("The invocation request specifications do not conform to the permitted parameters of the handler. For example, an image sharing invocation being sent to a target application that cannot share images would result in this error.");
             case "INVOKE_INTERNAL_ERROR":
                 throw new InvalidOperationException("A generic error occured in the internal framework while attempting to retrieve the Invocation.");
             case "INVOKE_TARGET_ERROR":
                 throw new InvalidOperationException("A generic error occured with the target handler.");
             default:
                 throw new InvalidOperationException("An error occured while trying to get the invocation.", new Exception(error));
         }
     }
     return new Invocation(res, ev);
 }
 public static InvokeQueryResult[] GetResults(BPSEvent ev)
 {
     if (ev.Domain != Navigator.Domain)
     {
         throw new ArgumentException("BPSEvent is not a navigator event");
     }
     if ((NavigatorEvents)ev.Code != NavigatorEvents.InvokeQueryResult)
     {
         throw new ArgumentException("BPSEvent is not a invoke query result event");
     }
     var ptr = ev.DangerousGetHandle();
     var count = navigator_invoke_event_get_query_result_action_count(ptr);
     if (count < 0)
     {
         return null;
     }
     else if (count == 0)
     {
         return new InvokeQueryResult[0];
     }
     //XXX Should this maybe be an enumeration? As in, someone is only looking for one particular element and don't care about the others... so we don't need to get "all of them"
     var results = new InvokeQueryResult[count];
     for (var i = 0; i < count; i++)
     {
         results[i] = new InvokeQueryResult(navigator_invoke_event_get_query_result_action(ptr, i), ev);
     }
     return results;
 }
示例#24
0
 private static void CheckSupportedEvent(BPSEvent ev, params NavigatorEvents[] types)
 {
     if (ev.Domain != Navigator.Domain)
     {
         throw new ArgumentException("BPSEvent is not a navigator event");
     }
     var eventType = (NavigatorEvents)ev.Code;
     foreach (var t in types)
     {
         if (t == eventType)
         {
             return;
         }
     }
     throw new ArgumentException("BPSEvent is not a supported event");
 }
 private InvokeQueryResult(IntPtr handle, BPSEvent ev)
 {
     this.handle = handle;
     this.ev = ev;
 }
示例#26
0
 public Invocation()
 {
     Util.GetBPSOrException();
     if (navigator_invoke_invocation_create(out handle) != BPS.BPS_SUCCESS)
     {
         Util.ThrowExceptionForLastErrno();
     }
     ev = null;
     IsDisposable = true;
 }
示例#27
0
 public static string InvokeSourcePackageID(BPSEvent ev)
 {
     CheckSupportedEvent(ev, NavigatorEvents.InvokeTarget);
     return(Marshal.PtrToStringAnsi(navigator_invoke_event_get_dname(ev.DangerousGetHandle())));
 }
示例#28
0
 public static TimerAction GetTimerRegistrationAction(BPSEvent ev)
 {
     if (ev.Domain != Navigator.Domain)
     {
         throw new ArgumentException("BPSEvent is not a navigator event");
     }
     if ((NavigatorEvents)ev.Code != NavigatorEvents.InvokeTimerRegistration)
     {
         throw new ArgumentException("BPSEvent is not a invoke timer registration event");
     }
     Util.GetBPSOrException();
     return navigator_invoke_timer_registration_event_get_action(ev.DangerousGetHandle());
 }
 internal InvokeQueryTarget(IntPtr handle, BPSEvent ev)
 {
     this.handle = handle;
     this.ev = ev;
 }
示例#30
0
 private Invocation(IntPtr handle, BPSEvent ev)
 {
     this.handle = handle;
     this.ev = ev;
     IsDisposable = false;
 }
 internal InvokeQueryTarget(IntPtr handle, BPSEvent ev)
 {
     this.handle = handle;
     this.ev     = ev;
 }
示例#32
0
 private Invocation(IntPtr handle, BPSEvent ev)
 {
     this.handle  = handle;
     this.ev      = ev;
     IsDisposable = false;
 }