aboutsummaryrefslogtreecommitdiffstats
path: root/palm/gnomepilot2/files/patch-gpilotd__gpilotd.c
blob: b856f0a4af699d5b939786cc23f40d5e042ab66d (plain) (blame)
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
--- gpilotd/gpilotd.c.orig  Thu Sep  2 11:43:47 2004
+++ gpilotd/gpilotd.c   Sun Apr 24 15:56:14 2005
@@ -27,6 +27,8 @@
 #include "config.h"
 #endif
 
+#define freebsd
+
 /* for crypt () */
 #ifdef USE_XOPEN_SOURCE
 #ifndef _XOPEN_SOURCE
@@ -903,7 +905,7 @@
    }
    
    fclose (f);
-   
+
    if (visor_exists) {
        l = context->devices;
        while (l) {
@@ -928,6 +930,49 @@
 }
 
 #endif
+#ifdef freebsd
+static gboolean
+visor_devices_timeout (gpointer data)
+{
+   GPilotContext *context = data;
+   GPilotDevice *device;
+   GList *l;
+   int i;
+   gboolean visor_exists = FALSE, visor_net = TRUE;
+
+   g_assert (context != NULL);
+
+   if (context->paused)
+       return FALSE;
+
+   l = context->devices;
+   while (l) {
+       device = l->data;
+
+       struct stat dummy;
+
+       /* Make sure usb device exists */
+       if (stat(device->port, &dummy) == 0) {
+           if (device->type == PILOT_DEVICE_USB_VISOR) {
+               if (!visor_net)
+                   device->type = PILOT_DEVICE_SERIAL;
+
+               /* just try to synch.  Until I can talk to 
+                * the kernel guys this is the best way to 
+                * go. */
+               sync_device (device, context);
+               if (!visor_net)
+                   device->type = PILOT_DEVICE_USB_VISOR;
+           }
+       }
+       l = l->next;
+
+   }
+
+   return TRUE;
+}
+
+#endif
 #endif
 
 void monitor_channel (GPilotDevice *dev,GPilotContext *context) 
@@ -959,16 +1004,12 @@
 #endif /* WITH_NETWORK */
    } if (dev->type == PILOT_DEVICE_USB_VISOR) {
 #ifdef WITH_USB_VISOR
-#ifdef linux
        /* We want to watch the /proc/bus/usb/devices file once 
         * per context, and then check all devices each time it is
         * woken up. */
        if (visor_timeout_id == -1) {
            visor_timeout_id = g_timeout_add (2000, visor_devices_timeout, context);
        }
-#else /* linux*/
-       g_assert_not_reached ();
-#endif /* linux */
 #endif /* WITH_USB_VISOR */
        dev->device_exists = FALSE;
    }