Пример #1
0
        public void async_update_status()
        {
            string s;

            if (Settings.TransmitAgent == "efax")
            {
                s = Fax.async_get_server_status();
                if (s != null)
                {
                    TextMark tm = StatusTextBuffer.GetMark("insert");
                    StatusTextBuffer.InsertAtCursor(String.Concat(s, "\n"));
                    StatusText.ScrollMarkOnscreen(tm);
                }
            }

            if (Settings.TransmitAgent == "hylafax")
            {
                // Progressbar pulser - add this when we have async comms
                GLib.Timeout.Add((uint)(100), new TimeoutHandler(queue_progress));

                // update status bar
                Appbar.ClearStack();
                Appbar.Push(Catalog.GetString("Refreshing server status..."));
                Appbar.Refresh();
                //GLib.MainContext.Iteration ();
                while (Gtk.Application.EventsPending())
                {
                    Gtk.Application.RunIteration();
                }

                s = Fax.async_get_server_status();
            }
        }
Пример #2
0
        private void on_DeleteJobButton_clicked(object o, EventArgs args)
        {
            // get the selected jobs
            ArrayList al;

            // get a list of jobids to kill
            al = lv.GetSelections(COLUMN_1);

            IEnumerator enu = al.GetEnumerator();

            while (enu.MoveNext())
            {
                Fax.delete_job((string)enu.Current);
            }

            switch (activeQ)
            {
            case ActiveQ.done:
                async_update_queue_status("doneq");
                break;

            case ActiveQ.send:
                async_update_queue_status("sendq");
                break;

            case ActiveQ.receive:
                async_update_queue_status("recvq");
                break;
            }

            DeleteJobButton.Sensitive = false;
            ModifyJobButton.Sensitive = false;
        }
Пример #3
0
        private void on_RecvfaxDeleteButton_clicked(object o, EventArgs args)
        {
            // get the selected jobs
            ArrayList al;
            string    hfaxfile = null;

            // COLUMN_5 is the filename
            al = jobsReceivedView.GetSelections(COLUMN_5);

            IEnumerator enu = al.GetEnumerator();

            while (enu.MoveNext())
            {
                hfaxfile = (string)enu.Current;

                try {
                    if (Fax.delete_file(hfaxfile) == 1)
                    {
                        G_Message gm = new G_Message(Catalog.GetString(
                                                         @"Cannot delete the facsimile file from the server. You most likely do not 
have permission to delete the file.  Check the settings on your fax server."));
                        return;
                    }
                } catch (Exception e) {
                    Console.WriteLine("[gui.on_RecvfaxDeleteButton_clicked] Exception: {0}", e);
                    G_Message gm = new G_Message(Catalog.GetString(
                                                     @"Cannot delete the file on the Hylafax server. 
Please check your settings or contact your system Administrator"));
                }

                switch (activeQ)
                {
                case ActiveQ.done:
                    async_update_queue_status("doneq");
                    break;

                case ActiveQ.send:
                    async_update_queue_status("sendq");
                    break;

                case ActiveQ.receive:
                    async_update_queue_status("recvq");
                    break;
                }
            }
        }
Пример #4
0
        private void async_update_queue_status(string queue)
        {
            G_ListView view;

            Fax.FaxQueue    q  = null;
            Fax.FaxRecQueue rq = null;

            view = lv;

            switch (queue)
            {
            case "sendq":
                view = lv;
                break;

            case "doneq":
                view = jobsCompletedView;
                break;

            case "recvq":
                view = jobsReceivedView;
                break;
            }

            if (Settings.TransmitAgent == "hylafax")
            {
                // Progressbar pulser - add this when we have async comms
                GLib.Timeout.Add((uint)(100), new TimeoutHandler(queue_progress));

                // update status bar
                Appbar.ClearStack();
                Appbar.Push(Catalog.GetString("Refreshing queue..."));
                Appbar.Refresh();
                //GLib.MainContext.Iteration ();
                while (Gtk.Application.EventsPending())
                {
                    Gtk.Application.RunIteration();
                }

                Fax.async_get_queue_status(queue);
            }
            if (Settings.TransmitAgent == "efax")
            {
                async_update_listview(Fax.async_get_queue_status(queue), queue);
            }
        }
Пример #5
0
        private void view_received_fax(string s)
        {
            // TODO get proper Gnome mime type and use that first if running Gnome
            try {
                if (Fax.recvfax(s))
                {
                    ProcessStartInfo pidInfo = new ProcessStartInfo();
                    pidInfo.FileName  = Settings.FaxViewer;
                    pidInfo.Arguments = String.Concat(gfax.SpoolDirectory, "/tif/", s);
                    System.Diagnostics.Process pid = System.Diagnostics.Process.Start(pidInfo);
                }
                else
                {
                    G_Message gm = new G_Message(Catalog.GetString(
                                                     @"Cannot read the facsimile file from the server. You most likely do not 
have permission to read the file.  Check the settings on your fax server."));
                    return;
                }
            } catch (Exception e) {
                Console.WriteLine("[gui.onViewPrintButton_clicked] Exception: {0}", e);
                G_Message gm = new G_Message(Catalog.GetString(
                                                 @"Cannot start your faxviewer program. 
Please check your settings.  It is currently set to " + Settings.FaxViewer + "."));
            }

            switch (activeQ)
            {
            case ActiveQ.done:
                async_update_queue_status("doneq");
                break;

            case ActiveQ.send:
                async_update_queue_status("sendq");
                break;

            case ActiveQ.receive:
                async_update_queue_status("recvq");
                break;
            }

            // Reset progressbar
            gfax.MainProgressBar.Fraction = 0;
        }
Пример #6
0
        // This is where we end up if the New Fax button or the menu item
        // has been selected.
        private void send_new_fax()
        {
            string [] largs = { "do_filename" };
            GfaxSend  sd    = new GfaxSend("", largs);

            // send the faxes
            if (sd.DoSend)
            {
                Fax.sendfax(sd.Filename);
                // if file is temp data (/var/spool/gfax/D.*) then delete it
                FileInfo f = new FileInfo(sd.Filename);
                if (File.Exists(String.Concat(gfax.SpoolDirectory, "/", f.Name)))
                {
                    File.Delete(String.Concat(gfax.SpoolDirectory, "/", f.Name));
                }
            }
            activeQ = ActiveQ.send;
            async_update_queue_status("sendq");
            sd    = null;
            largs = null;
        }
Пример #7
0
        // We end up here when an async network read is finished
        private void async_net_read_finished()
        {
            switch (gfax.asyncReadType)
            {
            case "doneq":
                async_update_listview(Fax.parse_senddone(gfax.asyncFolderMessageBuffer), "doneq");
                break;

            case "sendq":
                async_update_listview(Fax.parse_senddone(gfax.asyncFolderMessageBuffer), "sendq");
                break;

            case "recvq":
                async_update_listview(Fax.parse_receive(gfax.asyncFolderMessageBuffer), "recvq");
                break;

            case "status":
                StatusTextBuffer.Text = gfax.asyncServerMessageBuffer;
                break;
            }
        }
Пример #8
0
        public static void Main(string[] args)
        {
            string HOMEDIR = Environment.GetEnvironmentVariable("HOME");
            string USER    = Environment.GetEnvironmentVariable("USER");

            ConfigDirectory = HOMEDIR + "/.config/gfax";
            SpoolDirectory  = HOMEDIR + "/.local/share/gfax/spool";
            pargs           = args;

            // TODO put this is try/catch
            if (!Directory.Exists(ConfigDirectory))
            {
                if (!Directory.Exists(HOMEDIR + "/.config"))
                {
                    Directory.CreateDirectory(HOMEDIR + "/.config");
                }
                // Move data from old ~/.etc directory
                if (Directory.Exists(HOMEDIR + "/.etc/gfax"))
                {
                    Directory.Move(HOMEDIR + "/.etc/gfax", ConfigDirectory);
                }
                else
                {
                    Directory.CreateDirectory(ConfigDirectory);
                }
            }
            if (!Directory.Exists(HOMEDIR + "/.local/share/gfax/spool"))
            {
                if (!Directory.Exists(HOMEDIR + "/.local/share/gfax"))
                {
                    if (!Directory.Exists(HOMEDIR + "/.local/share"))
                    {
                        if (!Directory.Exists(HOMEDIR + "/.local"))
                        {
                            Directory.CreateDirectory(HOMEDIR + "/.local");
                        }
                        Directory.CreateDirectory(HOMEDIR + "/.local/share");
                    }
                    Directory.CreateDirectory(HOMEDIR + "/.local/share/gfax");
                }
                Directory.CreateDirectory(HOMEDIR + "/.local/share/gfax/spool");
                Directory.CreateDirectory(HOMEDIR + "/.local/share/gfax/spool/doneq");
                Directory.CreateDirectory(HOMEDIR + "/.local/share/gfax/spool/recq");
            }

            // Clean out the spool/tif directory - incoming faxes
            if (!Directory.Exists(HOMEDIR + "/.local/share/gfax/spool/tif"))
            {
                Directory.CreateDirectory(HOMEDIR + "/.local/share/gfax/spool/tif");
            }
            else
            {
                Directory.Delete(HOMEDIR + "/.local/share/gfax/spool/tif/", true);
                Directory.CreateDirectory(HOMEDIR + "/.local/share/gfax/spool/tif");
            }



            // Initialize GETTEXT
            Catalog.Init("gfax", Defines.GNOME_LOCALE_DIR);

            // handle command line args ourselves
            for (int i = 0; i < args.Length; i++)
            {
                //Console.WriteLine("{0} {1}", i, args[i]);
                switch (args[i])
                {
                case "--help":
                    Console.WriteLine(Catalog.GetString("Gfax help..."));
                    Console.WriteLine("Gfax spool dir -> {0}", SpoolDirectory);
                    break;

                case "-f":                              // file name is present
                    filename = args[i + 1];
                    break;

                //case "-q" :	// immediately quit after sending fax
                //			filename = args[i+1];
                //			break;
                default:
                    if (File.Exists(args[i]))
                    {
                        filename = args[i];
                    }
                    break;
                }
            }

            try {
                if (Settings.RunSetupAtStart)
                {
                    // Set some default preferences.
                    Settings.TransmitAgent        = "efax";
                    Settings.SendNow              = true;
                    Settings.EfaxModemDevice      = "ttyS0";
                    Settings.RefreshQueueInterval = 15;
                    Settings.RefreshQueueEnabled  = true;
                }
            } catch (Exception e) {
                //TODO  HIG love required
                G_Message gm = new G_Message(
                    Catalog.GetString(
                        @"Gconfd cannot find your settings. 
If you are running Gfax immediately 
after an installation, you may have 
to log out and log back in again."), TOPLEVEL);
                Console.WriteLine("Exception in main.cs {0}", e);
                Environment.Exit(0);
            }

            // If we have a file name run the send dialog
            if (filename != null)
            {
                GfaxSend sd = new GfaxSend(filename, args);
                FileInfo f  = new FileInfo(filename);

                // send the faxes
                if (sd.DoSend)
                {
                    fromSendWizard = true;

                    // Start the fax daemon if efax
                    if (Settings.TransmitAgent == "efax")
                    {
                        efax = new Efax();
                        efax.run_efaxd();
                    }

                    Fax.sendfax(filename);
                    // delete the spool file (~.local/share/gfax/spool/D.*)
                    if (File.Exists(String.Concat(SpoolDirectory, "/", f.Name)))
                    {
                        File.Delete(String.Concat(SpoolDirectory, "/", f.Name));
                    }

                    //if (!quitAfterSend) {
                    //Gfax gf = new Gfax (filename, args);
                    //}
                }

                // delete the spool file that gfax created if it exists
                if (File.Exists(String.Concat("/var/spool/gfax/", USER, "/", f.Name)))
                {
                    File.Delete(String.Concat("/var/spool/gfax/", USER, "/", f.Name));
                }
            }
            else
            {
                // We need /var/spool/gfax/<user> to exsist and be 0777 perms
                //ACCESSPERMS = 0777
                if (!Directory.Exists("/var/spool/gfax/" + USER))
                {
                    Directory.CreateDirectory("/var/spool/gfax/" + USER);
                }
                Mono.Unix.Native.Syscall.chmod("/var/spool/gfax/" + USER, Mono.Unix.Native.FilePermissions.ACCESSPERMS);

                FileSystemWatcher watcher = new FileSystemWatcher();
                watcher.Path = "/var/spool/gfax/" + USER;

                watcher.NotifyFilter = NotifyFilters.LastAccess | NotifyFilters.LastWrite
                                       | NotifyFilters.FileName | NotifyFilters.DirectoryName;
                // Only watch text files.
                watcher.Filter   = "*";
                watcher.Created += new FileSystemEventHandler(TIOnChanged);
                // Begin watching.
                watcher.EnableRaisingEvents = true;

                // Start the fax daemon if efax
                if (Settings.TransmitAgent == "efax")
                {
                    efax = new Efax();
                    efax.run_efaxd();
                }

                Gfax gf = new Gfax(filename, args);
            }
        }
Пример #9
0
        private void modify_job(ArrayList al, string id)
        {
            string jobid  = null;
            string number = null;
            string status = null;
            string user   = null;
            string pages  = null;
            string dials  = null;
            object sendat = null;
            string error  = null;

            IEnumerator enu = al.GetEnumerator();

            while (enu.MoveNext())
            {
                enu.MoveNext();
                jobid = (string)enu.Current;
                enu.MoveNext();
                number = (string)enu.Current;
                enu.MoveNext();
                status = (string)enu.Current;
                enu.MoveNext();
                user = (string)enu.Current;
                enu.MoveNext();
                pages = (string)enu.Current;
                enu.MoveNext();
                int idx = ((string)enu.Current).LastIndexOf(':');
                dials = ((string)enu.Current).Substring(idx + 1);
                enu.MoveNext();
                sendat = (object)enu.Current;
                enu.MoveNext();
                error = (string)enu.Current;
            }

                        #if DEBUG
            Console.WriteLine("[ModifyJob] Date is {0}", sendat);
                        #endif

            Glade.XML xml = new Glade.XML(null, "gfax.glade", "vbox74", null);
            Dialog    mjd = new Dialog();
            mjd.VBox.Add(xml.GetWidget("vbox74"));
            Gtk.Entry      mje  = (Gtk.Entry)xml.GetWidget("ModifyJobNumberEntry");
            Gnome.DateEdit mjde = (Gnome.DateEdit)xml.GetWidget("ModifyJobDate");
            Gtk.SpinButton mjmd = (Gtk.SpinButton)xml.GetWidget("MaxDialsSpinbutton");

            mjd.AddButton(Gtk.Stock.Cancel, Gtk.ResponseType.Cancel);
            mjd.AddButton(Gtk.Stock.Ok, Gtk.ResponseType.Ok);

            // this is to re-enable the entry for editing so it won't be selected
            // to begin with???  Maybe something to do with re-parenting or something.
            mje.FocusInEvent +=
                new FocusInEventHandler(on_ModifyJobNumberEntry_focus_in_event);

            mje.IsEditable = false;
            mje.Text       = number.Trim();

            mjde.Time = sendat == null ? new DateTime(): (DateTime)sendat;

            mjmd.Value = Convert.ToDouble(dials.Trim());

            ResponseType result = (ResponseType)mjd.Run();

            if (result == ResponseType.Ok)
            {
                DateTime newsend = (mjde.Time).ToUniversalTime();

                // Format time to send - timezone is in UTC format.
                string tts = String.Format("{0}{1:00}{2:00}{3:00}{4:00}",
                                           newsend.Year,
                                           newsend.Month,
                                           newsend.Day,
                                           newsend.Hour,
                                           newsend.Minute);

                if (id == "sendq")
                {
                    Fax.modify_job(jobid, mje.Text, tts, (mjmd.ValueAsInt).ToString());
                }
                else                 // "doneq"
                {
                    Fax.resubmit_job(jobid, mje.Text, tts, (mjmd.ValueAsInt).ToString());
                }

                mjd.Destroy();
            }
            else
            {
                mjd.Destroy();
            }

            async_update_queue_status("sendq");
            ModifyJobButton.Sensitive = false;
            DeleteJobButton.Sensitive = false;
        }