]> pilppa.org Git - familiar-h63xx-build.git/blob - org.handhelds.familiar/packages/gpe-conf/gpe-conf-0.1.20/ntpdate.patch
OE tree imported from monotone branch org.openembedded.oz354fam083 at revision 8b12e3...
[familiar-h63xx-build.git] / org.handhelds.familiar / packages / gpe-conf / gpe-conf-0.1.20 / ntpdate.patch
1 Index: suid.c
2 ===================================================================
3 RCS file: /cvs/gpe/base/gpe-conf/suid.c,v
4 retrieving revision 1.54
5 diff -u -r1.54 suid.c
6 --- suid.c      26 Oct 2004 15:04:22 -0000      1.54
7 +++ suid.c      28 Oct 2004 20:20:23 -0000
8 @@ -88,17 +88,25 @@
9  void
10  update_time_from_net (const gchar * server)
11  {
12 +       
13 +       if (setvbuf(nsreturn,NULL,_IONBF,0) != 0) 
14 +               fprintf(stderr,"gpe-conf: error setting buffer size!");
15 +       
16         char *tstr = g_strdup_printf ("ntpdate -b %s", server);
17         if (system(tstr))
18         {
19                 fprintf (stderr, "failed to execute ntpdate\n");
20 +               fprintf(nsreturn,"<failed>\n");
21         }
22 -       else                    // if ok, update rtc time
23 +       else                    /* if ok, update rtc time */
24         {
25 +               fprintf(nsreturn,"<success>\n");
26                 system("/sbin/hwclock --systohc");
27                 system ("echo > /var/spool/at/trigger");
28         }
29         g_free(tstr);
30 +       fflush(nsreturn);
31 +       fsync(nsreturnfd);
32  }
33  
34  
35 Index: network.c
36 ===================================================================
37 RCS file: /cvs/gpe/base/gpe-conf/network.c,v
38 retrieving revision 1.39
39 diff -u -r1.39 network.c
40 --- network.c   26 Oct 2004 15:04:22 -0000      1.39
41 +++ network.c   28 Oct 2004 20:20:23 -0000
42 @@ -1416,7 +1416,9 @@
43         if (entry)
44         {
45                 newval = gtk_editable_get_chars (GTK_EDITABLE (entry), 0, -1);
46 -               suid_exec ("SDNS", newval);
47 +               if (strlen(newval))
48 +                       suid_exec ("SDNS", newval);
49 +               g_free(newval);
50         }
51  }
52  
53 Index: timeanddate.c
54 ===================================================================
55 RCS file: /cvs/gpe/base/gpe-conf/timeanddate.c,v
56 retrieving revision 1.37
57 diff -u -r1.37 timeanddate.c
58 --- timeanddate.c       23 Aug 2004 22:33:01 -0000      1.37
59 +++ timeanddate.c       28 Oct 2004 20:20:23 -0000
60 @@ -17,18 +17,20 @@
61  #include <stdio.h>
62  #include <stdlib.h>
63  #include <string.h>
64 -#include <dirent.h>
65 -#include <pwd.h>
66  #include <fcntl.h>
67  #include <unistd.h>
68 -#include <signal.h>
69  #include <time.h>
70  #include <libintl.h>
71 +#include <time.h>
72 +#include <ctype.h>
73 +
74  #include <sys/types.h>
75  #include <sys/stat.h>
76 +#include <sys/poll.h>
77 +
78 +#include <X11/Xlib.h>
79  #include <gtk/gtk.h>
80 -#include <time.h>
81 -#include <ctype.h>
82 +#include <gdk/gdkx.h>
83  
84  #include "applets.h"
85  #include "timeanddate.h"
86 @@ -39,6 +41,7 @@
87  #include <gpe/errorbox.h>
88  #include <gpe/gtkdatecombo.h>
89  #include <gpe/gpetimesel.h>
90 +#include <gpe/infoprint.h>
91  
92  
93  /* --- local types and constants --- */
94 @@ -402,23 +405,48 @@
95  
96  gboolean refresh_time()
97  {
98 +       static char str[256];
99 +       struct pollfd pfd[1];
100 +       gboolean ret = FALSE;
101 +       Display *dpy = GDK_DISPLAY();
102 +               
103         Time_Restore();
104 +       memset(str, 0, 256);
105 +       
106 +       pfd[0].fd = suidinfd;
107 +       pfd[0].events = (POLLIN | POLLRDNORM | POLLRDBAND | POLLPRI);
108 +       while (poll(pfd, 1, 0))
109 +       {
110 +               if (fgets (str, 255, suidin))
111 +               {
112 +                       if (strstr(str, "<success>"))
113 +                               gpe_popup_infoprint (dpy, 
114 +                                                _("Time adjusted from network."));
115 +                       else
116 +                               gpe_error_box(_("Adjusting time from network failed."));
117 +
118 +               }
119 +               ret = TRUE;
120 +       }
121 +
122         trc--;
123 -       if (!trc)  
124 +       if (!trc) 
125 +               ret = TRUE;
126 +       if (ret)
127         {
128 -               gtk_widget_set_sensitive(self.internet,TRUE);
129 -               gtk_timeout_remove(tid);
130 +               gtk_widget_set_sensitive(self.internet, TRUE);
131 +               return FALSE;
132         }
133         system (SCREENSAVER_RESET_CMD);
134 -       return (trc ? TRUE : FALSE);
135 +       return (TRUE);
136  }
137  
138  void GetInternetTime()
139  {
140    gtk_widget_set_sensitive(self.internet,FALSE);
141    suid_exec("NTPD",gtk_entry_get_text (GTK_ENTRY (GTK_COMBO (self.ntpserver)->entry)));
142 -  trc = 10;
143 -  tid = gtk_timeout_add(500,refresh_time,NULL);
144 +  trc = 60;
145 +  tid = gtk_timeout_add(500, refresh_time, NULL);
146  }
147  
148