Ejemplo n.º 1
0
            protected override void ObserveRequest(HttpChannel channel)
            {
                base.ObserveRequest(channel);

                var cr  = new WeakReference <nsIHttpChannel>(channel.Instance);
                var url = channel.Uri;

                var tc = channel.CastToTraceableChannel();
                var s  = new StreamListenerTee();

                s.Completed += (sender, e) =>
                {
                    if (sender is StreamListenerTee slt)
                    {
                        var data = slt.GetCapturedData();

                        if (0 <= data?.Length && data.Length <= 1024)
                        {
                            App.Current?.Dispatcher?.BeginInvoke((Action)(() =>
                            {
                                var l = _MainWindow.RequestList.LastOrDefault(r => r.Url == url);
                                if (l != null)
                                {
                                    l.Data = data;
                                    return;
                                }
                            }));
                        }
                    }
                };
                tc.SetNewListener(s);
            }
Ejemplo n.º 2
0
        protected override void Response(HttpChannel channel)
        {
            if (channel.ContentType.Contains("pdf"))
            {
                StreamListenerTee stream_listener_tee = new StreamListenerTee();
                stream_listener_tee.Completed += streamListener_Completed;

                TraceableChannel tc = channel.CastToTraceableChannel();
                tc.SetNewListener(stream_listener_tee);
            }
        }
Ejemplo n.º 3
0
 protected override void ObserveRequest(HttpChannel p_HttpChannel)
 {
     if (p_HttpChannel != null)
     {
         //if (p_HttpChannel.Uri.AbsolutePath.Contains("/ticket.aspx"))
         //{
         TraceableChannel  oTC     = p_HttpChannel.CastToTraceableChannel();
         StreamListenerTee oStream = new StreamListenerTee();
         oStream.Completed += (se, ev) => { Stream_Completed(se, p_HttpChannel.Uri.ToString()); };
         oTC.SetNewListener(oStream);
         //}
     }
 }
Ejemplo n.º 4
0
        void streamListener_Completed(object sender, EventArgs e)
        {
            try
            {
                StreamListenerTee stream_listener_tee = (StreamListenerTee)sender;

                byte[] captured_data = stream_listener_tee.GetCapturedData();
                if (0 == captured_data.Length)
                {
                    if (!have_notified_about_installing_acrobat)
                    {
                        have_notified_about_installing_acrobat = true;

                        NotificationManager.Instance.AddPendingNotification(
                            new NotificationManager.Notification(
                                "We notice that your PDF files are not loading in your browser.  Please install Acrobat Reader for Qiqqa to be able to automatically add PDFs to your libraries.",
                                "We notice that your PDF files are not loading in your browser.  Please install Acrobat Reader for Qiqqa to be able to automatically add PDFs to your libraries.",
                                NotificationManager.NotificationType.Info,
                                Icons.DocumentTypePdf,
                                "Download",
                                DownloadAndInstallAcrobatReader
                                ));
                    }

                    Logging.Error("We seem to have been notified about a zero-length PDF");
                    return;
                }

                string temp_pdf_filename = TempFile.GenerateTempFilename("pdf");
                File.WriteAllBytes(temp_pdf_filename, captured_data);

                string      pdf_source_url = null; // Can we find this?!!
                PDFDocument pdf_document   = Library.GuestInstance.AddNewDocumentToLibrary_SYNCHRONOUS(temp_pdf_filename, pdf_source_url, null, null, null, true, true);
                File.Delete(temp_pdf_filename);

                Application.Current.Dispatcher.Invoke
                (
                    new Action(() =>
                {
                    PDFReadingControl pdf_reading_control = MainWindowServiceDispatcher.Instance.OpenDocument(pdf_document);
                    pdf_reading_control.EnableGuestMoveNotification(potential_attachment_pdf_document);
                }),
                    DispatcherPriority.Background
                );
            }

            catch (Exception ex)
            {
                Logging.Error(ex, "There was a problem while intercepting the download of a PDF.");
            }
        }
Ejemplo n.º 5
0
        protected override void ObserveRequest(HttpChannel p_HttpChannel)
        {
            if (p_HttpChannel != null)
            {
                if (p_HttpChannel.Uri.AbsolutePath.Contains(Utils.Constants.SEARCH_RESPONSE_ENDPOINT) || p_HttpChannel.Uri.AbsolutePath.Contains(Utils.Constants.AUTH_RESPONSE_ENDPOINT))
                {
                    this.url = p_HttpChannel.Uri.AbsolutePath;

                    TraceableChannel  oTC     = p_HttpChannel.CastToTraceableChannel();
                    StreamListenerTee oStream = new StreamListenerTee();
                    oStream.Completed += Stream_Completed;
                    oTC.SetNewListener(oStream);
                }
            }
        }
Ejemplo n.º 6
0
        private void Stream_Completed(object sender, string url)
        {
            if (sender is StreamListenerTee)
            {
                StreamListenerTee oStream = sender as StreamListenerTee;
                byte[]            aData   = oStream.GetCapturedData();
                string            sData1  = Encoding.UTF8.GetString(aData);
                string            sData2  = Encoding.UTF7.GetString(aData);
                string            sData3  = Encoding.ASCII.GetString(aData);


                // Custom Event that returns the data
                OnTicketLoaded(new TicketLoadedEventArgs(url, sData1));
            }
        }
Ejemplo n.º 7
0
        private void Stream_Completed(object sender, System.EventArgs e)
        {
            if (sender is StreamListenerTee)
            {
                StreamListenerTee oStream = sender as StreamListenerTee;
                byte[]            aData   = oStream.GetCapturedData();
                string            sData   = Encoding.UTF8.GetString(aData);

                if (url.Contains(Utils.Constants.SEARCH_RESPONSE_ENDPOINT))
                {
                    OnSearchResponse(new ResponseEventArgs(aData, sData));
                }
                else if (url.Contains(Utils.Constants.AUTH_RESPONSE_ENDPOINT))
                {
                    OnAuthResponse(new ResponseEventArgs(aData, sData));
                }
            }
        }