示例#1
0
        public static unsafe NSData SendSynchronousRequest(NSUrlRequest request, out NSUrlResponse response, out NSError error)
        {
            IntPtr responseStorage = IntPtr.Zero;
            IntPtr errorStorage = IntPtr.Zero;

            void *resp = &responseStorage;
            void *errp = &errorStorage;
            IntPtr rhandle = (IntPtr) resp;
            IntPtr ehandle = (IntPtr) errp;

            var res = Messaging.IntPtr_objc_msgSend_IntPtr_IntPtr_IntPtr (
                class_ptr,
                selSendSynchronousRequestReturningResponseError.Handle,
                request.Handle,
                rhandle,
                ehandle);

            if (responseStorage != IntPtr.Zero)
                response = (NSUrlResponse) Runtime.GetNSObject (responseStorage);
            else
                response = null;

            if (errorStorage != IntPtr.Zero)
                error = (NSError) Runtime.GetNSObject (errorStorage);
            else
                error = null;

            return (NSData) Runtime.GetNSObject (res);
        }
示例#2
0
			public override void DecidePolicyForNavigation (WebView webView, NSDictionary actionInformation, NSUrlRequest request, WebFrame frame, NSObject decisionToken)
			{
				switch ((WebNavigationType)((NSNumber)actionInformation [WebPolicyDelegate.WebActionNavigationTypeKey]).Int32Value) {
				case WebNavigationType.BackForward:
				case WebNavigationType.FormResubmitted:
				case WebNavigationType.FormSubmitted:
					WebPolicyDelegate.DecideIgnore (decisionToken);
					break;
				case WebNavigationType.LinkClicked:
					NSWorkspace.SharedWorkspace.OpenUrl (actionInformation[WebPolicyDelegate.WebActionOriginalUrlKey] as NSUrl);
					WebPolicyDelegate.DecideIgnore (decisionToken);
					break;
				case WebNavigationType.Other:
				case WebNavigationType.Reload:
					WebPolicyDelegate.DecideUse (decisionToken);
					break;
				}
			}
示例#3
0
        static unsafe NSData SendSynchronousRequest(NSUrlRequest request, out NSUrlResponse response, NSError error)
        {
            IntPtr storage = IntPtr.Zero;

            void *p = &storage;
            IntPtr handle = (IntPtr) p;

            var res = Messaging.IntPtr_objc_msgSend_IntPtr_IntPtr_IntPtr (
                class_ptr,
                selSendSynchronousRequestReturningResponseError.Handle,
                request.Handle,
                handle,
                error != null ? error.Handle : IntPtr.Zero);

            if (storage != IntPtr.Zero)
                response = (NSUrlResponse) Runtime.GetNSObject (storage);
            else
                response = null;

            return (NSData) Runtime.GetNSObject (res);
        }
        public override void DecidePolicyForNavigation(WebView web_view, NSDictionary action_info,
            NSUrlRequest request, WebFrame frame, NSObject decision_token)
        {
            string url = request.Url.ToString ();

            if (url.StartsWith (Path.VolumeSeparatorChar.ToString ())) {
                string file_path = request.Url.ToString ();
                file_path = file_path.Replace ("%20", " ");

                NSWorkspace.SharedWorkspace.OpenFile (file_path);

            } else {
                Regex regex = new Regex (@"(.+)~(.+)~(.+)");
                Match match = regex.Match (url);

                if (match.Success) {
                    string folder_name = match.Groups [1].Value;
                    string revision    = match.Groups [2].Value;
                    string note        = match.Groups [3].Value;

                    Thread thread = new Thread (new ThreadStart (delegate {
                        SparkleShare.Controller.AddNoteToFolder (folder_name, revision, note);
                    }));

                    thread.Start ();
                }
            }
        }
 public override void DecidePolicyForNavigation(WebView web_view, NSDictionary action_info,
     NSUrlRequest request, WebFrame frame, NSObject decision_token)
 {
     if (LinkClicked != null)
         LinkClicked (request.Url.ToString ());
 }
示例#6
0
        public override void DecidePolicyForNavigation(WebView web_view, NSDictionary action_info,
                                                        NSUrlRequest request, WebFrame frame, NSObject decision_token)
        {
            string file_path = request.Url.ToString ();
            file_path = file_path.Replace ("%20", " ");

            NSWorkspace.SharedWorkspace.OpenFile (file_path);
        }
 public override void DecidePolicyForNavigation(WebView web_view, NSDictionary action_info,
     NSUrlRequest request, WebFrame frame, NSObject decision_token)
 {
     SparkleEventLogController.LinkClicked (request.Url.ToString ());
 }
示例#8
0
 public void Redirected(NSUrlProtocol protocol, NSUrlRequest redirectedToEequest, NSUrlResponse redirectResponse)
 {
     Messaging.void_objc_msgSend_IntPtr_IntPtr_IntPtr (this.Handle, selUrlProtocolWasRedirectedToRequestRedirectResponse_, protocol.Handle, redirectedToEequest.Handle, redirectResponse.Handle);
 }