From 2f09cc7cd6c86ece05864055eca4ddfd78c03179 Mon Sep 17 00:00:00 2001 From: Martin Szulecki Date: Fri, 20 Mar 2009 11:00:59 +0100 Subject: Fix crashers due to bad data parsing and bad treeview cell sorting --- src/fax.cs | 6 +++--- src/gui.cs | 10 ++++++++-- src/guitools.cs | 17 +++++++++++++---- src/hylafax.cs | 11 ++++++----- 4 files changed, 30 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/fax.cs b/src/fax.cs index 91d0f0f..d180971 100755 --- a/src/fax.cs +++ b/src/fax.cs @@ -267,10 +267,10 @@ namespace gfax { hq.Sender = ""; if ( sa[3].Length != 0 ) { - try { - hq.TimeReceived = (DateTime)System.DateTime.ParseExact(sa[3], "ddMMMyy", System.Globalization.CultureInfo.InvariantCulture); + try { + hq.TimeReceived = (DateTime)System.DateTime.ParseExact(sa[3].Trim(), "yyyy:MM:dd HH:mm:ss", System.Globalization.CultureInfo.InvariantCulture); } - catch(FormatException e ) + catch(FormatException e) { hq.TimeReceived = null; } diff --git a/src/gui.cs b/src/gui.cs index 5a4f64a..e780c4f 100755 --- a/src/gui.cs +++ b/src/gui.cs @@ -225,6 +225,9 @@ Please login as the root user and create the " typeof (string), typeof (DateTime), typeof (string)); + + // Default to sorting by job id + StatusStore.SetSortColumnId(1, SortType.Descending); RecvStore = new ListStore( typeof (Gdk.Pixbuf), @@ -234,6 +237,9 @@ Please login as the root user and create the " typeof (DateTime), typeof (string)); + // Default to sorting by arrival date + RecvStore.SetSortColumnId(4, SortType.Descending); + lv = new G_ListView(StatusList, StatusStore); lv.AddColumnIcon(Gtk.Stock.Info, 0); @@ -263,7 +269,7 @@ Please login as the root user and create the " 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"), "d", 4, 4); + jobsReceivedView.AddColumnDateTime(Catalog.GetString("Arrived"), "G", 4, 4); jobsReceivedView.AddColumnTitle(Catalog.GetString("Filename"), 5, 5); StatusList.Selection.Changed += @@ -1021,7 +1027,7 @@ Please check your settings or contact your system Administrator")); } } else { //receive queue while ( enu.MoveNext() ) { - rq = (Fax.FaxRecQueue)enu.Current; + rq = (Fax.FaxRecQueue)enu.Current; view.AddTextToRow(GetFaxStatusIcon(rq.StatusType), rq.Sender, rq.Status, rq.Pages, rq.TimeReceived, rq.Filename); } diff --git a/src/guitools.cs b/src/guitools.cs index 8828941..bdc9e8a 100755 --- a/src/guitools.cs +++ b/src/guitools.cs @@ -306,10 +306,19 @@ namespace gfax { bool is_sorted = ((Gtk.ListStore)model).GetSortColumnId (out col, out sort); if(!is_sorted) return 0; - - DateTime dateA = (DateTime)model.GetValue (a, col); - DateTime dateB = (DateTime)model.GetValue (b, col); - + + object oA = model.GetValue (a, col); + object oB = model.GetValue (b, col); + + if(oB == null) + return 1; + + if(oA == null) + return -1; + + DateTime dateA = (DateTime)oA; + DateTime dateB = (DateTime)oB; + return dateA.CompareTo(dateB); } diff --git a/src/hylafax.cs b/src/hylafax.cs index 54ab63f..f54e7fe 100755 --- a/src/hylafax.cs +++ b/src/hylafax.cs @@ -700,20 +700,21 @@ namespace gfax { IPAddress ipaddr; int ipport; string jobfmt; - - write(mainstream, "PASV\n"); + + write(mainstream, "PASV\n"); string data = read(mainstream, mainclient); // dig out ip address and port for new connection ipaddr = get_ip_addr(data); ipport = get_ip_port(data); - + try { myclient.Connect(ipaddr, ipport); } catch (Exception e ) { Console.WriteLine(e.ToString()); // handle error here + return; } /* @@ -744,7 +745,7 @@ namespace gfax { data = read(mainstream, mainclient); } if (folder == "recvq") { - jobfmt = "\"%4p=N%1z=%28.28s=%7t=%f\""; + jobfmt = "\"%4p=N%1z=%28.28s=%-19Y=%f\""; write(mainstream, "RCVFMT "+jobfmt+"\n"); data = read(mainstream, mainclient); } @@ -815,7 +816,7 @@ namespace gfax { } else { gfax.asyncFolderMessageBuffer = ""; } - + StateObject state = new StateObject(); state.client = sock; state.readType = readType; -- cgit v1.1-32-gdbae