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