Exemplo n.º 1
0
        public GfaxSendPhoneBook(Glade.XML xml, string myparent)
        {
            //Phonebook[] pb; delete me

            //gxml = xml;
            //parent = myparent; delete me
            myPhoneBooks = Phonetools.get_phonebooks();

            if (myPhoneBooks == null)
            {
                G_Message m = new G_Message(Catalog.GetString("You don't have any phone books yet."));
                m = null;
                return;
            }

            gsxml = new Glade.XML(null, "send-druid.glade", "PhbookDialog", null);
            gsxml.Autoconnect(this);

            // Get the widget so we can manipulate it
            //phbd = (Gtk.Dialog) gsxml.GetWidget("PhbookDialog");
            //book = (Gtk.TreeView) gsxml.GetWidget("book_treeview");
            //list = (Gtk.TreeView) gsxml.GetWidget("list_treeview");
            phbd = PhbookDialog;
            book = book_treeview;
            list = list_treeview;

            book.Selection.Changed += new EventHandler(on_book_treeview_selection);

            phbd.Resizable      = true;
            book_store          = new ListStore(typeof(string));
            book.HeadersVisible = false;
            book.Selection.Mode = SelectionMode.Multiple;

            bs = new G_ListView(book, book_store);
            // Got have a column title or things won't show up
            bs.AddColumnTitle(Catalog.GetString("Phone books"), 0, COLUMN_0);


            list_store = new ListStore(
                typeof(string),
                typeof(string),
                typeof(string));

            ls = new G_ListView(list, list_store);
            ls.AddColumnTitle(Catalog.GetString("Organization"), 0, COLUMN_0);
            ls.AddColumnTitle(Catalog.GetString("Phone Number"), 1, COLUMN_1);
            ls.AddColumnTitle(Catalog.GetString("Contact"), 2, COLUMN_2);
            list.HeadersVisible = true;
            list.Selection.Mode = SelectionMode.Multiple;

            // populate the list
            foreach (Phonebook p in myPhoneBooks)
            {
                bs.AddTextToRow(p.Name);
            }

            phbd.Run();
        }
Exemplo n.º 2
0
        public GfaxSendPhoneBook(Glade.XML xml, string myparent)
        {
            //Phonebook[] pb; delete me

            //gxml = xml;
            //parent = myparent; delete me
            myPhoneBooks = Phonetools.get_phonebooks();

            if ( myPhoneBooks == null ) {
                G_Message m = new G_Message(Catalog.GetString("You don't have any phone books yet."));
                m = null;
                return;
            }

            gsxml = new Glade.XML (null, "send-druid.glade","PhbookDialog",null);
            gsxml.Autoconnect (this);

            // Get the widget so we can manipulate it
            //phbd = (Gtk.Dialog) gsxml.GetWidget("PhbookDialog");
            //book = (Gtk.TreeView) gsxml.GetWidget("book_treeview");
            //list = (Gtk.TreeView) gsxml.GetWidget("list_treeview");
            phbd = PhbookDialog;
            book = book_treeview;
            list = list_treeview;

            book.Selection.Changed += new EventHandler (on_book_treeview_selection);

            phbd.Resizable = true;
            book_store = new ListStore(typeof(string));
            book.HeadersVisible = false;
            book.Selection.Mode = SelectionMode.Multiple;

            bs = new G_ListView(book, book_store);
            // Got have a column title or things won't show up
            bs.AddColumnTitle(Catalog.GetString("Phone books"), 0, COLUMN_0);

            list_store = new ListStore(
                    typeof (string),
                    typeof (string),
                    typeof (string));

            ls = new G_ListView(list, list_store);
            ls.AddColumnTitle(Catalog.GetString("Organization"), 0, COLUMN_0);
            ls.AddColumnTitle(Catalog.GetString("Phone Number"), 1, COLUMN_1);
            ls.AddColumnTitle(Catalog.GetString("Contact"), 2, COLUMN_2);
            list.HeadersVisible = true;
            list.Selection.Mode = SelectionMode.Multiple;

            // populate the list
            foreach (Phonebook p in myPhoneBooks)
                bs.AddTextToRow(p.Name);

            phbd.Run();
        }
Exemplo n.º 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;
                }
            }
        }
Exemplo n.º 4
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;
        }
Exemplo n.º 5
0
Arquivo: main.cs Projeto: horga83/gfax
        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);
            }
        }
Exemplo n.º 6
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);
            }
        }
Exemplo n.º 7
0
        public Gfax(string fname, string[] args)
            : base(APPNAME, VERSION, Modules.UI, args, new object [0])
        {
            //Phonebook[] pb;  delete me

            // Set the program icon
            Gtk.Window.DefaultIconName = "gfax";

            Application.Init();

            // check to see if we've run before, if so gfax will be there
            if (Settings.RunSetupAtStart)
            {
                Settings.RunSetupAtStart = false;

                MessageDialog md;
                md = new MessageDialog(
                    null,
                    DialogFlags.DestroyWithParent,
                    MessageType.Info,
                    ButtonsType.Ok,
                    Catalog.GetString(
                        @"
This is the first time you have run Gfax.
You should set your MODEM TYPE and PORT under preferences.

Gfax is initially setup to use Efax, you may change it use 
Hylafax if you prefer or require connection to a network 
facsimile server.")
                    );
                md.Run();
                md.Destroy();
            }

            if (!Directory.Exists(gfax.SpoolDirectory))
            {
                G_Message gm = new G_Message(Catalog.GetString(
                                                 @"Your spool directory is missing!
					
Please login as the root user and create the "
                                                 + gfax.SpoolDirectory +
                                                 " directory.\n\nAll users should be able to write to it.\n"));
                return;
            }
            if (!Directory.Exists(gfax.SpoolDirectory + "/doneq"))
            {
                G_Message gm = new G_Message(Catalog.GetString(
                                                 @"The doneq directory is missing in your spool directory!
					
Please login as the root user and create the "
                                                 + gfax.SpoolDirectory + "/doneq" +
                                                 " directory.\n\nAll users should be able to write to it.\n"));
                return;
            }
            if (!Directory.Exists(gfax.SpoolDirectory + "/recq"))
            {
                G_Message gm = new G_Message(Catalog.GetString(
                                                 @"The recq directory is missing in your spool directory!
					
Please login as the root user and create the "
                                                 + gfax.SpoolDirectory + "/recq" +
                                                 " directory.\n\nAll users should be able to write to it.\n"));
                return;
            }


            gxml = new Glade.XML(null, "gfax.glade", "GfaxWindow", null);
            gxml.Autoconnect(this);


            // Set initial gui state as per preferences
            // GConf.PropertyEditors.EditorShell doesn't handle
            // checkmenuitems;
            eventsEnabled = false;
            if (Settings.TransmitAgent == "hylafax")
            {
                AutoQRefreshCheckMenuItem.Active      = Settings.RefreshQueueEnabled;
                EmailNotificationCheckMenuItem.Active = Settings.EmailNotify;
                HiResolutionModeCheckMenuItem.Active  = Settings.HiResolution;
                LogEnabledCheckMenuItem.Active        = Settings.LogEnabled;
            }
            if (Settings.TransmitAgent == "efax")
            {
                AutoQRefreshCheckMenuItem.Active         = Settings.RefreshQueueEnabled;
                AutoQRefreshCheckMenuItem.Sensitive      = false;
                EmailNotificationCheckMenuItem.Active    = false;
                EmailNotificationCheckMenuItem.Sensitive = false;
                HiResolutionModeCheckMenuItem.Active     = Settings.HiResolution;
                LogEnabledCheckMenuItem.Visible          = false;
            }

            FaxTracingCheckMenuItem.Active = Settings.Faxtracing;

            eventsEnabled = true;

            StatusText.Editable = false;
            StatusText.CanFocus = false;
            StatusText.Buffer   = StatusTextBuffer;

            // Set the program icon
            Gdk.Pixbuf Icon = new Gdk.Pixbuf(null, "gfax.png");

            gfax.MainWindow = GfaxWindow;

            // Setup listview icons
            InitListViewIcons();

            StatusStore = new ListStore(
                typeof(Gdk.Pixbuf),
                typeof(string),
                typeof(string),
                typeof(string),
                typeof(string),
                typeof(string),
                typeof(string),
                typeof(DateTime),
                typeof(string));

            RecvStore = new ListStore(
                typeof(Gdk.Pixbuf),
                typeof(string),
                typeof(string),
                typeof(string),
                typeof(DateTime),
                typeof(string));


            lv = new G_ListView(StatusList, StatusStore);
            lv.AddColumnIcon(Gtk.Stock.Info, 0);
            lv.AddColumnTitle(Catalog.GetString("Jobid"), 1, 1);
            lv.AddColumnTitle(Catalog.GetString("Number"), 2, 2);
            lv.AddColumnTitle(Catalog.GetString("Status"), 3, 3);
            lv.AddColumnTitle(Catalog.GetString("Owner"), 4, 4);
            lv.AddColumnTitle(Catalog.GetString("Pages"), 5, 5);
            lv.AddColumnTitle(Catalog.GetString("Dials"), 6, 6);
            lv.AddColumnDateTime(Catalog.GetString("Send At"), "G", 7, 7);
            lv.AddColumnTitle(Catalog.GetString("Information"), 8, 8);

            // List view for completed jobs tab
            jobsCompletedView = new G_ListView(JobsCompleteList, StatusStore);
            jobsCompletedView.AddColumnIcon(Gtk.Stock.Info, 0);
            jobsCompletedView.AddColumnTitle(Catalog.GetString("Jobid"), 1, 1);
            jobsCompletedView.AddColumnTitle(Catalog.GetString("Number"), 2, 2);
            jobsCompletedView.AddColumnTitle(Catalog.GetString("Status"), 3, 3);
            jobsCompletedView.AddColumnTitle(Catalog.GetString("Owner"), 4, 4);
            jobsCompletedView.AddColumnTitle(Catalog.GetString("Pages"), 5, 5);
            jobsCompletedView.AddColumnTitle(Catalog.GetString("Dials"), 6, 6);
            jobsCompletedView.AddColumnDateTime(Catalog.GetString("Send At"), "G", 7, 7);
            jobsCompletedView.AddColumnTitle(Catalog.GetString("Information"), 8, 8);

            jobsReceivedView = new G_ListView(JobsReceivedList, RecvStore);
            jobsReceivedView.AddColumnIcon(Gtk.Stock.Info, 0);
            jobsReceivedView.AddColumnTitle(Catalog.GetString("Sender"), 1, 1);
            jobsReceivedView.AddColumnTitle(Catalog.GetString("Status"), 2, 2);
            jobsReceivedView.AddColumnTitle(Catalog.GetString("Pages  "), 3, 3);
            jobsReceivedView.AddColumnDateTime(Catalog.GetString("Arrived"), "G", 4, 4);
            jobsReceivedView.AddColumnTitle(Catalog.GetString("Filename"), 5, 5);

            StatusList.Selection.Changed +=
                new EventHandler(on_StatusList_selection);
            StatusList.Selection.Mode = SelectionMode.Multiple;
            StatusList.HeadersVisible = true;

            JobsCompleteList.Selection.Changed +=
                new EventHandler(on_JobsCompleteList_selection);
            JobsCompleteList.Selection.Mode = SelectionMode.Multiple;
            JobsCompleteList.HeadersVisible = true;

            JobsReceivedList.Selection.Changed +=
                new EventHandler(on_JobsReceivedList_selection);
            JobsReceivedList.Selection.Mode = SelectionMode.Multiple;
            JobsReceivedList.HeadersVisible = true;

            // Make sure headers are visible
            lv.AddTextToRow(null, "", "", "", "", "", "", null, "");
            jobsCompletedView.AddTextToRow(null, "", "", "", "", "", "", null, "");
            jobsReceivedView.AddTextToRow(null, "", "", "", null, "");
            StatusStore.Clear();
            RecvStore.Clear();

            DeleteJobButton.Sensitive = false;
            if (Settings.TransmitAgent == "hylafax")
            {
                ModifyJobButton.Sensitive = false;
            }
            else
            {
                ModifyJobButton.Visible = false;
            }
            ViewPrintButton.Sensitive = false;

            // Setup some global variables
            gfax.MainProgressBar   = Appbar.Progress;
            gfax.GStatusTextBuffer = StatusTextBuffer;
            gfax.GAppbar           = Appbar;

            gfax.Pulser = new Pulser();
            gfax.Status = new Status(StatusText, StatusTextBuffer);

            if (Settings.RefreshQueueEnabled)
            {
                GLib.Timeout.Add((uint)(Settings.RefreshQueueInterval * 1000),
                                 new TimeoutHandler(queue_refresh));
            }

            async_update_status();

            if (Settings.TransmitAgent == "hylafax")
            {
                while (gfax.activeNetwork)
                {
                    System.Threading.Thread.Sleep(100);
                }

                async_net_read_finished();
            }

            activeQ = ActiveQ.send;
            async_update_queue_status("sendq");

            StatusIcon sicon = new StatusIcon(Icon);

            sicon.Activate += new EventHandler(OnImageClick);
            sicon.Tooltip   = "Gfax Facsimile Sender";
            // showing the trayicon
            sicon.Visible = true;
            // setup system tray icon
            gfax.MainWindow.SkipTaskbarHint = true;
            gfax.MainWindow.Iconify();

            Application.Run();
        }
Exemplo n.º 8
0
        // connect
        //        return false on sucess or true on cancel
        public bool connect()
        {
            host = Settings.Hostname;
            port = Convert.ToInt32(Settings.Port);
            user = Settings.Username;
            if (gfax.hylafaxPassword == null)	// if we already entered a pass but
                if (Settings.Password != "")	// don't want to remember it it won't be null
                    gfax.hylafaxPassword = Settings.Password;

            if (Settings.Faxtracing == true) {
                Console.WriteLine ("Initializing hylafax class .......");
            }

            try {
                mainclient.Connect(host, port);
              		mainstream = mainclient.GetStream();
                string s = read(mainstream, mainclient);
                if (Settings.Faxtracing == true) {
                    Console.WriteLine ("[hylafax.connect] on connect : {0}", s);
                }

                if(mainstream.CanWrite && mainstream.CanRead){
              	    	// Write username
                    if (Settings.Faxtracing == true) {
                        Console.WriteLine ("[hylafax.connect] Sending USER : {0}", user);
                    }

                    //If the username is null then hylafax doesn't need usernames
                    // TODO check the hylafax protocol about this
                    if (user == "")
                        user = "******";

                    write (mainstream, "USER " + user + "\n");
                    // Read result
                    // If the result is ("230 User <username> logged in.")
                    // 		I don't need to send a password
                    // Else if the result is ("331 Password required for <username>.")
                    //		I must send a password.
              	    	string returndata = read(mainstream, mainclient);

                    if (returndata.Substring(0,3) == "331") {
                        //Console.WriteLine("Password is {0}", gfax.hylafaxPassword);
                        for (int i = 0; i < 3; i++) {

                            if (gfax.hylafaxPassword == null) {
                                G_Password gpass = new G_Password();
                                gpass.Run();

                                if (gpass.Cancel) {
                                    return false;  // connection cancelled
                                }
                                gfax.hylafaxPassword = gpass.Password;
                                if (gpass.RememberPassword)
                                    Settings.Password = gpass.Password;
                                gpass.Close();
                            }
                            // 530 Login incorrect. result from bad password
                            //prompt for password
                            write (mainstream, "PASS " + gfax.hylafaxPassword + "\n");

                            string rtn = read(mainstream, mainclient);
                            //Console.WriteLine("Return is {0}", rtn);
                            if (rtn.Substring(0,3) == "230")  // user is logged in
                                break;
                            else {
                                gfax.hylafaxPassword = null;
                                write (mainstream, "USER " + user + "\n");
              	    				string rtndata = read(mainstream, mainclient);
                            }
                        }
                    }

                    if (Settings.Faxtracing == true) {
                        Console.WriteLine("[hylafax.connect] USER returned : {0}", returndata);
                    }
                }
                else if (!mainstream.CanRead) {
                    Console.WriteLine(Catalog.GetString("You can not write data to this stream"));
                    mainclient.Close();
                }
                else if (!mainstream.CanWrite) {
                    Console.WriteLine(Catalog.GetString("You can not read data from this stream"));
                    mainclient.Close();
                }

                return true;
            }
            catch (Exception e ) {
                Console.WriteLine(e.ToString());
                G_Message m = new G_Message(Catalog.GetString("Could not connect to your Hylafax server.\n" +
                    "Check console messages for further information\n\n" +
                    "You might need to set a value for username."));
                return false;
            }
        }
Exemplo n.º 9
0
Arquivo: gui.cs Projeto: horga83/gfax
        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;
                }
            }
        }
Exemplo n.º 10
0
Arquivo: gui.cs Projeto: horga83/gfax
        public Gfax(string fname, string[] args)
            : base(APPNAME, VERSION, Modules.UI, args, new object [0])
        {
            //Phonebook[] pb;  delete me

             			// Set the program icon
             			Gtk.Window.DefaultIconName = "gfax";

            Application.Init ();

            // check to see if we've run before, if so gfax will be there
            if ( Settings.RunSetupAtStart ) {
                Settings.RunSetupAtStart = false;

                MessageDialog md;
                md = new MessageDialog (
                    null,
                    DialogFlags.DestroyWithParent,
                    MessageType.Info,
                    ButtonsType.Ok,
                    Catalog.GetString(
                        @"
            This is the first time you have run Gfax.
            You should set your MODEM TYPE and PORT under preferences.

            Gfax is initially setup to use Efax, you may change it use
            Hylafax if you prefer or require connection to a network
            facsimile server.")
                );
                md.Run ();
                md.Destroy();
            }

            if (!Directory.Exists(gfax.SpoolDirectory)) {
                G_Message gm = new G_Message(Catalog.GetString(
                    @"Your spool directory is missing!

            Please login as the root user and create the "
            + gfax.SpoolDirectory +
            " directory.\n\nAll users should be able to write to it.\n"));
                return;
            }
            if (!Directory.Exists(gfax.SpoolDirectory + "/doneq")) {
                G_Message gm = new G_Message(Catalog.GetString(
                    @"The doneq directory is missing in your spool directory!

            Please login as the root user and create the "
            + gfax.SpoolDirectory + "/doneq" +
            " directory.\n\nAll users should be able to write to it.\n"));
                return;
            }
            if (!Directory.Exists(gfax.SpoolDirectory + "/recq")) {
                G_Message gm = new G_Message(Catalog.GetString(
                    @"The recq directory is missing in your spool directory!

            Please login as the root user and create the "
            + gfax.SpoolDirectory + "/recq" +
            " directory.\n\nAll users should be able to write to it.\n"));
                return;
            }

            gxml = new Glade.XML (null, "gfax.glade", "GfaxWindow", null);
            gxml.Autoconnect (this);

            // Set initial gui state as per preferences
            // GConf.PropertyEditors.EditorShell doesn't handle
            // checkmenuitems;
            eventsEnabled = false;
             	if (Settings.TransmitAgent == "hylafax") {
                AutoQRefreshCheckMenuItem.Active = Settings.RefreshQueueEnabled;
                EmailNotificationCheckMenuItem.Active = Settings.EmailNotify;
                HiResolutionModeCheckMenuItem.Active = Settings.HiResolution;
                LogEnabledCheckMenuItem.Active = Settings.LogEnabled;
            }
            if (Settings.TransmitAgent == "efax") {
                AutoQRefreshCheckMenuItem.Active = Settings.RefreshQueueEnabled;
                AutoQRefreshCheckMenuItem.Sensitive = false;
                EmailNotificationCheckMenuItem.Active = false;
                EmailNotificationCheckMenuItem.Sensitive = false;
                HiResolutionModeCheckMenuItem.Active = Settings.HiResolution;
                LogEnabledCheckMenuItem.Visible = false;
            }

            FaxTracingCheckMenuItem.Active = Settings.Faxtracing;

            eventsEnabled = true;

            StatusText.Editable = false;
            StatusText.CanFocus = false;
            StatusText.Buffer = StatusTextBuffer;

            // Set the program icon
            Gdk.Pixbuf Icon = new Gdk.Pixbuf(null, "gfax.png");

            gfax.MainWindow = GfaxWindow;

             			// Setup listview icons
             			InitListViewIcons();

            StatusStore = new ListStore(
             						typeof (Gdk.Pixbuf),
                        typeof (string),
                        typeof (string),
                        typeof (string),
                        typeof (string),
                        typeof (string),
                        typeof (string),
             						typeof (DateTime),
                        typeof (string));

            RecvStore = new ListStore(
             						typeof (Gdk.Pixbuf),
                        typeof (string),
                        typeof (string),
                        typeof (string),
             						typeof (DateTime),
                        typeof (string));

            lv = new G_ListView(StatusList, StatusStore);
             			lv.AddColumnIcon(Gtk.Stock.Info, 0);
             			lv.AddColumnTitle(Catalog.GetString("Jobid"),	1, 1);
             			lv.AddColumnTitle(Catalog.GetString("Number"),	2, 2);
             			lv.AddColumnTitle(Catalog.GetString("Status"),	3, 3);
             			lv.AddColumnTitle(Catalog.GetString("Owner"),	4, 4);
             			lv.AddColumnTitle(Catalog.GetString("Pages"),	5, 5);
             			lv.AddColumnTitle(Catalog.GetString("Dials"),	6, 6);
             			lv.AddColumnDateTime(Catalog.GetString("Send At"), "G",	7, 7);
             			lv.AddColumnTitle(Catalog.GetString("Information"),	8, 8);

            // List view for completed jobs tab
            jobsCompletedView = new G_ListView(JobsCompleteList, StatusStore);
             			jobsCompletedView.AddColumnIcon(Gtk.Stock.Info, 0);
             			jobsCompletedView.AddColumnTitle(Catalog.GetString("Jobid"),	1, 1);
             			jobsCompletedView.AddColumnTitle(Catalog.GetString("Number"),	2, 2);
             			jobsCompletedView.AddColumnTitle(Catalog.GetString("Status"),	3, 3);
             			jobsCompletedView.AddColumnTitle(Catalog.GetString("Owner"),	4, 4);
             			jobsCompletedView.AddColumnTitle(Catalog.GetString("Pages"),	5, 5);
             			jobsCompletedView.AddColumnTitle(Catalog.GetString("Dials"),	6, 6);
             			jobsCompletedView.AddColumnDateTime(Catalog.GetString("Send At"), "G",	7, 7);
             			jobsCompletedView.AddColumnTitle(Catalog.GetString("Information"),	8, 8);

            jobsReceivedView = new G_ListView(JobsReceivedList, RecvStore);
             			jobsReceivedView.AddColumnIcon(Gtk.Stock.Info, 0);
             			jobsReceivedView.AddColumnTitle(Catalog.GetString("Sender"),	1, 1);
             			jobsReceivedView.AddColumnTitle(Catalog.GetString("Status"),	2, 2);
             			jobsReceivedView.AddColumnTitle(Catalog.GetString("Pages  "),	3, 3);
             			jobsReceivedView.AddColumnDateTime(Catalog.GetString("Arrived"), "G",	4, 4);
             			jobsReceivedView.AddColumnTitle(Catalog.GetString("Filename"),	5, 5);

            StatusList.Selection.Changed +=
                new EventHandler(on_StatusList_selection);
            StatusList.Selection.Mode = SelectionMode.Multiple;
            StatusList.HeadersVisible = true;

            JobsCompleteList.Selection.Changed +=
                new EventHandler(on_JobsCompleteList_selection);
            JobsCompleteList.Selection.Mode = SelectionMode.Multiple;
            JobsCompleteList.HeadersVisible = true;

            JobsReceivedList.Selection.Changed +=
                new EventHandler(on_JobsReceivedList_selection);
            JobsReceivedList.Selection.Mode = SelectionMode.Multiple;
            JobsReceivedList.HeadersVisible = true;

            // Make sure headers are visible
            lv.AddTextToRow(null,"","","","","","",null,"");
            jobsCompletedView.AddTextToRow(null,"","","","","","",null,"");
            jobsReceivedView.AddTextToRow(null,"","","",null,"");
            StatusStore.Clear();
            RecvStore.Clear();

            DeleteJobButton.Sensitive = false;
            if (Settings.TransmitAgent == "hylafax")
                ModifyJobButton.Sensitive = false;
            else
                ModifyJobButton.Visible = false;
            ViewPrintButton.Sensitive = false;

            // Setup some global variables
            gfax.MainProgressBar = Appbar.Progress;
            gfax.GStatusTextBuffer = StatusTextBuffer;
            gfax.GAppbar = Appbar;

            gfax.Pulser = new Pulser();
            gfax.Status = new Status(StatusText, StatusTextBuffer);

            if (Settings.RefreshQueueEnabled)
                GLib.Timeout.Add((uint)(Settings.RefreshQueueInterval * 1000),
                    new TimeoutHandler (queue_refresh));

            async_update_status();

            if (Settings.TransmitAgent == "hylafax" ) {
                while (gfax.activeNetwork)
                    System.Threading.Thread.Sleep(100);

                async_net_read_finished();
            }

            activeQ = ActiveQ.send;
            async_update_queue_status("sendq");

            StatusIcon sicon = new StatusIcon(Icon);
            sicon.Activate += new EventHandler (OnImageClick);
            sicon.Tooltip = "Gfax Facsimile Sender";
            // showing the trayicon
            sicon.Visible = true;
            // setup system tray icon
            gfax.MainWindow.SkipTaskbarHint = true;
            gfax.MainWindow.Iconify();

            Application.Run ();
        }
Exemplo n.º 11
0
Arquivo: gui.cs Projeto: horga83/gfax
        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;
        }
Exemplo n.º 12
0
        // connect
        //		return false on sucess or true on cancel
        public bool connect()
        {
            host = Settings.Hostname;
            port = Convert.ToInt32(Settings.Port);
            user = Settings.Username;
            if (gfax.hylafaxPassword == null)                   // if we already entered a pass but
            {
                if (Settings.Password != "")                    // don't want to remember it it won't be null
                {
                    gfax.hylafaxPassword = Settings.Password;
                }
            }

            if (Settings.Faxtracing == true)
            {
                Console.WriteLine("Initializing hylafax class .......");
            }

            try {
                mainclient.Connect(host, port);
                mainstream = mainclient.GetStream();
                string s = read(mainstream, mainclient);
                if (Settings.Faxtracing == true)
                {
                    Console.WriteLine("[hylafax.connect] on connect : {0}", s);
                }


                if (mainstream.CanWrite && mainstream.CanRead)
                {
                    // Write username
                    if (Settings.Faxtracing == true)
                    {
                        Console.WriteLine("[hylafax.connect] Sending USER : {0}", user);
                    }

                    //If the username is null then hylafax doesn't need usernames
                    // TODO check the hylafax protocol about this
                    if (user == "")
                    {
                        user = "******";
                    }

                    write(mainstream, "USER " + user + "\n");
                    // Read result
                    // If the result is ("230 User <username> logged in.")
                    //      I don't need to send a password
                    // Else if the result is ("331 Password required for <username>.")
                    //		I must send a password.
                    string returndata = read(mainstream, mainclient);

                    if (returndata.Substring(0, 3) == "331")
                    {
                        //Console.WriteLine("Password is {0}", gfax.hylafaxPassword);
                        for (int i = 0; i < 3; i++)
                        {
                            if (gfax.hylafaxPassword == null)
                            {
                                G_Password gpass = new G_Password();
                                gpass.Run();

                                if (gpass.Cancel)
                                {
                                    return(false);                                     // connection cancelled
                                }
                                gfax.hylafaxPassword = gpass.Password;
                                if (gpass.RememberPassword)
                                {
                                    Settings.Password = gpass.Password;
                                }
                                gpass.Close();
                            }
                            // 530 Login incorrect. result from bad password
                            //prompt for password
                            write(mainstream, "PASS " + gfax.hylafaxPassword + "\n");

                            string rtn = read(mainstream, mainclient);
                            //Console.WriteLine("Return is {0}", rtn);
                            if (rtn.Substring(0, 3) == "230")                             // user is logged in
                            {
                                break;
                            }
                            else
                            {
                                gfax.hylafaxPassword = null;
                                write(mainstream, "USER " + user + "\n");
                                string rtndata = read(mainstream, mainclient);
                            }
                        }
                    }

                    if (Settings.Faxtracing == true)
                    {
                        Console.WriteLine("[hylafax.connect] USER returned : {0}", returndata);
                    }
                }
                else if (!mainstream.CanRead)
                {
                    Console.WriteLine(Catalog.GetString("You can not write data to this stream"));
                    mainclient.Close();
                }
                else if (!mainstream.CanWrite)
                {
                    Console.WriteLine(Catalog.GetString("You can not read data from this stream"));
                    mainclient.Close();
                }

                return(true);
            }
            catch (Exception e) {
                Console.WriteLine(e.ToString());
                G_Message m = new G_Message(Catalog.GetString("Could not connect to your Hylafax server.\n" +
                                                              "Check console messages for further information\n\n" +
                                                              "You might need to set a value for username."));
                return(false);
            }
        }