rpms/libcompizconfig/devel libcompizconfig-update_pb.patch, NONE, 1.1

Leigh Scott leigh123linux at fedoraproject.org
Fri Jul 31 21:41:13 UTC 2009


Author: leigh123linux

Update of /cvs/pkgs/rpms/libcompizconfig/devel
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv29701

Added Files:
	libcompizconfig-update_pb.patch 
Log Message:
Update .pb when an older .xml is used


libcompizconfig-update_pb.patch:
 compiz.cpp         |   72 ++++++++++++++++++++++++++++++++---------------------
 compizconfig.proto |   17 ++++++------
 2 files changed, 53 insertions(+), 36 deletions(-)

--- NEW FILE libcompizconfig-update_pb.patch ---
From: Erkin Bahceci <erkinbah at gmail.com>
Date: Sat, 14 Mar 2009 19:30:43 +0000 (-0500)
Subject: Update .pb when an older .xml is used, too.
X-Git-Url: http://gitweb.compiz-fusion.org/?p=compiz%2Fcompizconfig%2Flibcompizconfig;a=commitdiff_plain;h=5dab250c7da6020ec3efbe85f511d3af4ccf79b7

Update .pb when an older .xml is used, too.
---

diff --git a/src/compiz.cpp b/src/compiz.cpp
index 5b36a4d..ac7a9d9 100644
--- a/src/compiz.cpp
+++ b/src/compiz.cpp
@@ -53,7 +53,7 @@ extern int xmlLoadExtDtdDefaultValue;
 
 Bool usingProtobuf = TRUE;
 
-#define PB_ABI_VERSION 20081004
+#define PB_ABI_VERSION 20090314
 
 typedef metadata::PluginInfo PluginInfoMetadata;
 typedef metadata::PluginBrief PluginBriefMetadata;
@@ -2665,13 +2665,12 @@ checkAndLoadProtoBuf (char *pbPath,
 	!loadPluginMetadataFromProtoBuf (pbPath, pluginBriefPB, NULL) ||
 	(!basicMetadata && pluginBriefPB->info ().basic_metadata ()) ||
 	pluginInfoPB.pb_abi_version () != PB_ABI_VERSION ||
+	pluginInfoPB.time () != (unsigned long)xmlStat->st_mtime ||
+	// xml modification time mismatch?
 	(pluginInfoPB.locale () != "NONE" &&
 	 pluginInfoPB.locale () != shortLocale))
     {
 	// .pb needs update
-
-	remove (pbPath); // Attempt to remove .pb
-
 	return FALSE;
     }
     return TRUE;
@@ -2681,7 +2680,8 @@ checkAndLoadProtoBuf (char *pbPath,
 static void
 writePBFile (char *pbFilePath,
 	     PluginMetadata *pluginPB,
-	     PluginBriefMetadata *pluginBriefPB)
+	     PluginBriefMetadata *pluginBriefPB,
+	     struct stat *xmlStat)
 {
     if (!createProtoBufCacheDir ())
 	return;
@@ -2698,6 +2698,7 @@ writePBFile (char *pbFilePath,
 	pluginInfoPB = pluginBriefPB->mutable_info ();
 	pluginInfoPB->set_pb_abi_version (PB_ABI_VERSION);
 	pluginInfoPB->set_locale (shortLocale);
+	pluginInfoPB->set_time ((unsigned long)xmlStat->st_mtime);
 	pluginInfoPB->set_brief_metadata (TRUE);
     }
 
@@ -2779,11 +2780,11 @@ loadPluginFromXMLFile (CCSContext * context, char *xmlName, char *xmlDirPath)
 
 #ifdef USE_PROTOBUF
     char *name = NULL;
+    struct stat xmlStat;
+    Bool removePB = FALSE;
 
     if (usingProtobuf)
     {
-	struct stat xmlStat;
-
 	if (stat (xmlFilePath, &xmlStat))
 	{
 	    free (xmlFilePath);
@@ -2817,26 +2818,32 @@ loadPluginFromXMLFile (CCSContext * context, char *xmlName, char *xmlDirPath)
 	    error = stat (pbFilePath, &pbStat);
 	}
 
-	if (!error &&
-	    checkAndLoadProtoBuf (pbFilePath, &pbStat, &xmlStat,
-				  &persistentPluginBriefPB))
+	if (!error)
 	{
-	    // Found and loaded .pb
-	    if (!strcmp (name, "core"))
-		addCoreSettingsFromPB (context, persistentPluginBriefPB.info (),
-				       pbFilePath, xmlFilePath);
+	    if (checkAndLoadProtoBuf (pbFilePath, &pbStat, &xmlStat,
+				      &persistentPluginBriefPB))
+	    {
+		// Found and loaded .pb
+		if (!strcmp (name, "core"))
+		    addCoreSettingsFromPB (context,
+					   persistentPluginBriefPB.info (),
+					   pbFilePath, xmlFilePath);
+		else
+		    addPluginFromPB (context, persistentPluginBriefPB.info (),
+				     pbFilePath, xmlFilePath);
+		
+		updatePBFilePath (context, name, pbFilePath);
+		
+		free (xmlFilePath);
+		free (pbFilePath);
+		free (name);
+		return;
+	    }
 	    else
-		addPluginFromPB (context, persistentPluginBriefPB.info (),
-				 pbFilePath, xmlFilePath);
-
-	    updatePBFilePath (context, name, pbFilePath);
-
-	    free (xmlFilePath);
-	    free (pbFilePath);
-	    free (name);
-	    return;
+	    {
+		removePB = TRUE;
+	    }
 	}
-
 	persistentPluginBriefPB.Clear ();
 	pluginInfoPBv = persistentPluginBriefPB.mutable_info ();
     }
@@ -2862,7 +2869,9 @@ loadPluginFromXMLFile (CCSContext * context, char *xmlName, char *xmlDirPath)
 #ifdef USE_PROTOBUF
     if (usingProtobuf && xmlLoaded)
     {
-	writePBFile (pbFilePath, NULL, &persistentPluginBriefPB);
+	if (removePB)
+	    remove (pbFilePath); // Attempt to remove .pb
+	writePBFile (pbFilePath, NULL, &persistentPluginBriefPB, &xmlStat);
 	updatePBFilePath (context, name, pbFilePath);
     }
 
@@ -3050,13 +3059,18 @@ ccsLoadPlugins (CCSContext * context)
 
 static void
 loadOptionsStringExtensionsFromXML (CCSPlugin * plugin,
-				    void * pluginPBv)
+				    void * pluginPBv,
+				    struct stat *xmlStat)
 {
     PLUGIN_PRIV (plugin);
 
     xmlDoc *doc = NULL;
     xmlNode **nodes;
     int num;
+
+    if (stat (pPrivate->xmlFile, xmlStat))
+	return;
+
     FILE *fp = fopen (pPrivate->xmlFile, "r");
     if (!fp)
 	return;
@@ -3120,14 +3134,16 @@ ccsLoadPluginSettings (CCSPlugin * plugin)
     }
 #endif
 
+    struct stat xmlStat;
+
     // Load from .xml
     if (!ignoreXML && pPrivate->xmlFile)
-	loadOptionsStringExtensionsFromXML (plugin, pluginPBToWrite);
+	loadOptionsStringExtensionsFromXML (plugin, pluginPBToWrite, &xmlStat);
 
 #ifdef USE_PROTOBUF
     if (pluginPBToWrite && pPrivate->pbFilePath && loadedAtLeastBriefPB)
 	writePBFile (pPrivate->pbFilePath, (PluginMetadata *) pluginPBToWrite,
-		     NULL);
+		     NULL, &xmlStat);
 #endif
     D (D_FULL, "done\n");
 
diff --git a/src/compizconfig.proto b/src/compizconfig.proto
index f4eedd1..5834842 100644
--- a/src/compizconfig.proto
+++ b/src/compizconfig.proto
@@ -7,21 +7,22 @@ message PluginInfo
 {
   required sint32 pb_abi_version = 1;
   required string locale = 2;
+  required uint64 time = 3;   // modification time of source .xml file
 
   // true if container is missing options and extensions, and only includes
   // plugin info
-  required bool brief_metadata = 3;
+  required bool brief_metadata = 4;
 
   // true if container is missing extensions, string restrictions, and
   // short/long descriptions for the plugin and its options
-  required bool basic_metadata = 4;
+  required bool basic_metadata = 5;
 
-  required string name = 5;
-  optional string short_desc = 6;
-  optional string long_desc = 7;
-  optional string category = 8;
+  required string name = 6;
+  optional string short_desc = 7;
+  optional string long_desc = 8;
+  optional string category = 9;
 
-  repeated string feature = 9;
+  repeated string feature = 10;
 
   message Dependencies
   {
@@ -35,7 +36,7 @@ message PluginInfo
     repeated string conflict_feature = 6;
   }
 
-  optional Dependencies deps = 10;
+  optional Dependencies deps = 11;
 }
 
 




More information about the fedora-extras-commits mailing list