[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    branches/work/kdepim-3.5.5+/kpilot/lib
From:       Jason vanRijn Kasper <vR () movingparts ! net>
Date:       2007-02-19 16:10:04
Message-ID: 1171901404.232459.22562.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 635252 by vanrijn:

- bumping seconds between poll from 2 to 5. probably should make this a
  configurable, but that would require new strings and I'm leery of that.
- cleaning up device opening logic for all-around betterness
- cleaning up logic so we don't try tempDevice when it's empty
- not logging multiple open failures to kpilot


 M  +41 -24    branches/work/kdepim-3.5.5+/kpilot/lib/kpilotdevicelink.cc  


--- branches/work/kdepim-3.5.5+/kpilot/lib/kpilotdevicelink.cc #635251:635252
@@ -215,7 +215,7 @@
 
 	virtual void run();
 
-	static const int SecondsBetweenPoll = 2;
+	static const int SecondsBetweenPoll = 5;
 
 	void setDone(bool b) 
 	{ 
@@ -295,6 +295,8 @@
 {
 	FUNCTIONSETUPL(2);
 
+	bool deviceOpened = false;
+
 	// This transition (from Waiting to Found) can only be
 	// taken once.
 	//
@@ -310,29 +312,33 @@
 			.arg(link()->fPilotPath)));
 	}
 
-	if (!fDone && open())
+	// if we're not supposed to be done, try to open the main pilot
+	// path...
+	if (!fDone)
 	{
-		QApplication::postEvent(link(), 
-			new DeviceCommEvent(EventLogMessage, i18n("Device link ready.")));
+		DEBUGKPILOT << fname << ": Opening main pilot path: [" 
+			<< link()->fPilotPath << "]." << endl;
+		deviceOpened = open( link()->fPilotPath ); 
 	}
-	else if (!fDone && open(link()->fTempDevice))
+
+	// only try the temp device if our earlier attempt didn't work and the temp
+	// device is different than the main device, and it's a non-empty
+	// string
+	bool tryTemp = !deviceOpened && 
+			(link()->fTempDevice.length() > 0) &&
+			(link()->fPilotPath != link()->fTempDevice) ;
+
+	// if we're not supposed to be done, and we should try the temp
+	// device, try the temp device...
+	if (!fDone && tryTemp)
 	{
-		QApplication::postEvent(link(), 
-			new DeviceCommEvent(EventLogMessage, i18n("Device link ready.")));
+		DEBUGKPILOT << fname << ": Couldn't open main pilot path. "
+			<< "Now trying temp device: [" 
+			<< link()->fTempDevice << "]." << endl;
+		deviceOpened = open( link()->fTempDevice );
 	}
-	else
-	{
-		if (link()->fMessages->shouldPrint(Messages::OpenFailMessage))
-		{
-			QApplication::postEvent(link(), 
-				new DeviceCommEvent(EventLogMessage, 
-					i18n("Could not open device: %1 (will retry)")
-					.arg(link()->fPilotPath)));
-		}
 
-		return false;
-	}
-	return true;
+	return deviceOpened;
 }
 
 bool DeviceCommThread::open(const QString &device)
@@ -394,10 +400,11 @@
 			<< ": Got master " << link()->fPilotMasterSocket << endl;
 
 		link()->fLinkStatus = CreatedSocket;
+	
+		Q_ASSERT(link()->fLinkStatus == CreatedSocket);
+
 	}
 
-	Q_ASSERT(link()->fLinkStatus == CreatedSocket);
-
 	DEBUGKPILOT << fname << ": Binding to path "
 		<< link()->fRealPilotPath << endl;
 
@@ -424,10 +431,13 @@
 		WARNINGKPILOT << "(" << strerror(e) << ")" << endl;
 	
 		link()->fLinkStatus = PilotLinkError;
+		
+		if (link()->fMessages->shouldPrint(Messages::OpenFailMessage))
+		{
+			QApplication::postEvent(link(),
+				new DeviceCommEvent(EventLogError, msg));
+		}
 	
-		QApplication::postEvent(link(),
-			new DeviceCommEvent(EventLogError, msg));
-	
 		return false;
 	}
 
@@ -618,6 +628,13 @@
 		}
 		else
 		{
+			if (link()->fMessages->shouldPrint(Messages::OpenFailMessage))
+			{
+				QApplication::postEvent(link(), 
+					new DeviceCommEvent(EventLogMessage, 
+						i18n("Could not open device: %1 (will retry)")
+						.arg(link()->fPilotPath)));
+			}
 			close();
 
 			// sleep before trying again
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic