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

List:       kde-i18n-doc
Subject:    branches/KDE/3.5/kdepim/kpilot/lib
From:       Jason vanRijn Kasper <vR () movingparts ! net>
Date:       2007-04-16 3:35:47
Message-ID: 1176694547.737141.4422.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 654424 by vanrijn:

- using "Handheld" instead of "Palm" since "Handheld" is already i18n'd
- new strings so that we can detect large data changes and ask our users
  for their approval before we eat their future  =:/
CCMAIL: kde-i18n-doc@kde.org


 M  +50 -3     plugin.cc  
 M  +8 -3      plugin.h  


--- branches/KDE/3.5/kdepim/kpilot/lib/plugin.cc #654423:654424
@@ -305,7 +305,7 @@
 	}
 
 	DEBUGKPILOT << fname << ": Direction=" << fSyncDirection.name() << endl;
-	fCtrHH = new CUDCounter(i18n("Palm"));
+	fCtrHH = new CUDCounter(i18n("Handheld"));
 	fCtrPC = new CUDCounter(i18n("PC")); 
 }
 
@@ -458,9 +458,56 @@
 	if (fCtrHH && fCtrPC) 
 	{
 		addSyncLogEntry(fCtrHH->moo() +"\n",false); 
-		DEBUGKPILOT << fname << ": " << fCtrHH->moo() << endl;;
+		DEBUGKPILOT << fname << ": " << fCtrHH->moo() << endl;
 		addSyncLogEntry(fCtrPC->moo() +"\n",false);
-		DEBUGKPILOT << fname << ": " << fCtrPC->moo() << endl;;
+		DEBUGKPILOT << fname << ": " << fCtrPC->moo() << endl;
+
+		// STEP2 of making sure we don't delete our little user's
+		// precious data...
+		// sanity checks for handheld...
+		int hhVolatility = fCtrHH->percentDeleted() + 
+				 fCtrHH->percentUpdated() +
+		    		 fCtrHH->percentCreated();
+
+		int pcVolatility = fCtrPC->percentDeleted() + 
+				 fCtrPC->percentUpdated() +
+		    		 fCtrPC->percentCreated();
+
+		// TODO: allow user to configure this...
+		// this is a percentage...
+		int allowedVolatility = 70;
+
+		QString caption = i18n("Large Changes Detected");
+		// args are already i18n'd
+		QString query = i18n("The %1 conduit has made a "
+			"large number of changes to your %2.  Do you want "
+			"to allow this change?\nDetails:\n\t%3");
+
+		if (hhVolatility > allowedVolatility)
+		{
+			query = query.arg(fConduitName)
+				.arg(fCtrHH->type()).arg(fCtrHH->moo());
+
+			DEBUGKPILOT << fname << ": Yikes, lots of volatility "
+				<< "caught.  Check with user: [" << query
+				<< "]." << endl;
+
+			/*
+			int rc = questionYesNo(query, caption,
+				QString::null, 0 );
+			if (rc == KMessageBox::Yes)
+			{
+				// TODO: add commit and rollback code.
+				// note: this will require some thinking,
+				// since we have to undo changes to the
+				// pilot databases, changes to the PC
+				// resources, changes to the mappings files
+				// (record id mapping, etc.)
+			}
+			*/
+		}
+
+
 	}
 
 }
--- branches/KDE/3.5/kdepim/kpilot/lib/plugin.h #654423:654424
@@ -219,15 +219,20 @@
 	 * developers (hi, self!) to correctly set total number of records
 	 * conduits start with, so add a little protection...
 	 */
-	unsigned int percentCreated() { Q_ASSERT(fStart>0); return fC/fStart; }
-	unsigned int percentUpdated() { Q_ASSERT(fStart>0); return fU/fStart; }
-	unsigned int percentDeleted() { Q_ASSERT(fStart>0); return fD/fStart; }
+	unsigned int percentCreated() { return (fEnd   > 0 ? fC/fEnd   : 0); }
+	unsigned int percentUpdated() { return (fEnd   > 0 ? fU/fEnd   : 0); }
+	unsigned int percentDeleted() { return (fStart > 0 ? fD/fStart : 0); }
 
 	/** Measurement Of Objects -- report numbers of
 	* objects created, updated, deleted. This
 	* string is already i18n()ed.
 	*/
 	QString moo() const;
+
+	/** Type of counter(Handheld or PC).  This string is already
+	 * i18n()ed.
+	*/
+	QString type() const { return fType; }
 private:
 	/** keep track of Creates, Updates, Deletes, and Total
 	 * number of records so we can detect abnormal behavior and

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

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