[Thread Prev][Thread Next][Thread Index]

Re: ttymon w/ PilotManager -sync



> Has anyone played around with ttymon to automatically invoke
> PilotManager -sync when the cradle button is depressed?  If so
> did it work well?

Yes, someone sent out a patch but I haven't tried it out yet.  I'm not
sure if this patch starts up the text mode (-sync flag) when you push
the hotsync button or makes the gui mode start..
 
see attached..

	- Alan
--- PilotMgr.pm.orig	Wed Jun 17 22:15:37 1998
+++ PilotMgr.pm	Wed Jun 17 22:37:27 1998
@@ -49,6 +49,10 @@
 # also.
 #
 #
+
+# NB:  This version has the -daemon patches applied.  
+#      Gossamer <gossamer@xxxxxxxxxxxxxx>
+
 package PilotMgr;
 
 my ($VERSION) = "1.106";	 # PilotManager Version
@@ -153,6 +157,11 @@
     {
 	$DEBUG = 1;
     }
+    elsif (/^-da?emon$/i)
+    {
+	# fork and sync forever in background (blocks)
+	$MODE = 'DAEMON';
+    }
     elsif (/^-sync$/i)
     {
 	# do sync now, don't bring up gui
@@ -183,10 +192,11 @@
     else
     {
 	print<<"EOH";
-Usage: $0 [-sync] [-syncwith <conduits..>] [-install <dbs..>]
+Usage: $0 [-sync|-daemon] [-syncwith <conduits..>] [-install <dbs..>]
  -sync = Start sync from command line, don't bring up gui.
  -syncwith <conduit>* = Start sync from command line with specified conduit(s).
 			(Ignores currently "active" conduits from preferences)
+ -daemon = Daemon mode, sync forever in background.
  -install <prc/pdb>* = Use Installer conduit to install the specified files.
 EOH
 	exit;
@@ -2082,7 +2092,7 @@
 	eval
 	{
 	    $SIG{'ALRM'} = sub{ croak("alarm") };
-	    alarm(10);
+	    alarm(10) unless $MODE eq "DAEMON";
 
 	    $dlp = PDA::Pilot::accept($socket);
 	};
@@ -2464,7 +2474,7 @@
     {
 	# Command line sync
 	#
-	print "$buf\n";
+	print "$buf\n" if $MODE eq "CMDLINE";
     }
     else
     {
@@ -2723,6 +2733,29 @@
     &hotSync;
     $PREFS->{"gShowConduitStatus"} = $saveStatus;
     &quit;
+}
+elsif ($MODE eq 'DAEMON')
+{
+    # Start full sync from command line and loop forever
+    #
+
+    # XXX Should check we aren't already running before we do this
+
+    $PREFS->{"gShowConduitStatus"} = 0;
+
+    my $pid;
+    unless ($pid = fork) {
+        unless (fork) {
+            while (1) {
+               &hotSync;
+            }
+            # should never get here, but ...
+            &quit;
+        }
+        exit 0;
+    }
+    waitpid($pid,0);
+
 }
 else
 {
------------------------------------------------------------------------
***********************************************************
*             This is a public mailing list!              *
* Please do not publish Sun proprietary information here! *
*        -  -  -  -  -  -  -  -  -  -  -  -  -  -         *
*             http://www.moshpit.org/pilotmgr             *
***********************************************************

SourceForge.net Logo