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

[XaraXtreme-commits] Commit Complete



Commit by  : luke
Repository : xara
Revision   : 994
Date       : Wed May 10 17:11:27 BST 2006

Changed paths:
   M /Trunk/XaraLX/Kernel/xpfilter.cpp
   M /Trunk/XaraLX/Kernel/xpfilter.h
   M /Trunk/XaraLX/wxOil/Makefile.am
   D /Trunk/XaraLX/wxOil/fltrdisc.cpp
   D /Trunk/XaraLX/wxOil/fltrdisc.h
   M /Trunk/XaraLX/wxOil/oilfltrs.cpp
   M /Trunk/XaraLX/wxOil/xpoilflt.cpp
   M /Trunk/XaraLX/wxOil/xpoilflt.h

Plugin discovery as far as (but not including) PluginNaticeFilter::Init


Diff:
Index: Trunk/XaraLX/Kernel/xpfilter.h
===================================================================
--- Trunk/XaraLX/Kernel/xpfilter.h	(revision 993)
+++ Trunk/XaraLX/Kernel/xpfilter.h	(revision 994)
@@ -125,7 +125,7 @@
 	// Construction and initialisation
 	PluginNativeFilter();
 	~PluginNativeFilter();
-	BOOL Init(const CLSID& rCLSID);
+	BOOL Init( xmlNode* pFilterNode );
 
 	// HowCompatible() returns value in range 0 to 10:
 	//   0 => "Definitely Not"
Index: Trunk/XaraLX/Kernel/xpfilter.cpp
===================================================================
--- Trunk/XaraLX/Kernel/xpfilter.cpp	(revision 993)
+++ Trunk/XaraLX/Kernel/xpfilter.cpp	(revision 994)
@@ -171,7 +171,7 @@
 
 ********************************************************************************************/
 
-BOOL PluginNativeFilter::Init(const CLSID& rCLSID)
+BOOL PluginNativeFilter::Init( xmlNode* pFilterNode )
 {
 	// Get the OILFilter object
 	PluginOILFilter* pPluginOILFilter = new PluginOILFilter(this);
@@ -179,7 +179,7 @@
 	if (pOILFilter == NULL)
 		return FALSE;
 
-	if (!pPluginOILFilter->Init(rCLSID))
+	if (!pPluginOILFilter->Init( pFilterNode ))
 		return(FALSE);
 
 	Flags.CanImport = pPluginOILFilter->IsImport();
Index: Trunk/XaraLX/wxOil/xpoilflt.cpp
===================================================================
--- Trunk/XaraLX/wxOil/xpoilflt.cpp	(revision 993)
+++ Trunk/XaraLX/wxOil/xpoilflt.cpp	(revision 994)
@@ -730,7 +730,7 @@
 
 ****************************************************************************/
 
-BOOL PluginOILFilter::Init(const CLSID& rCLSID)
+BOOL PluginOILFilter::Init( xmlNode* pFilterNode )
 {
 PORTNOTE("other","PluginFilter COM bits removed")
 #if !defined(EXCLUDE_FROM_XARALX)
Index: Trunk/XaraLX/wxOil/Makefile.am
===================================================================
--- Trunk/XaraLX/wxOil/Makefile.am	(revision 993)
+++ Trunk/XaraLX/wxOil/Makefile.am	(revision 994)
@@ -43,7 +43,7 @@
 	drawctl.cpp filedlgs.cpp fileutil.cpp ktimer.cpp camplatform.cpp \
 	outptdib.cpp outptpng.cpp outptgif.cpp gpalopt.cpp bmpfiltr.cpp giffiltr.cpp \
 	fontbase.cpp ftfonts.cpp textfuns.cpp dragbmp.cpp xpoilflt.cpp xmlutils.cpp \
-	fltrdisc.cpp camprocess.cpp \
+	camprocess.cpp \
 	resources.cpp
 
 # Keep resources.cpp (the autogenerated resource file) on a separate line.
Index: Trunk/XaraLX/wxOil/oilfltrs.cpp
===================================================================
--- Trunk/XaraLX/wxOil/oilfltrs.cpp	(revision 993)
+++ Trunk/XaraLX/wxOil/oilfltrs.cpp	(revision 994)
@@ -336,7 +336,7 @@
 BOOL OILFilter::CreatePluginFilters(List& FilterList)
 {
 	PORTNOTETRACE("filters","OILFilter::CreatePluginFilters - bodged");
-
+#if 0
 	CLSID Clsid;
 	PluginNativeFilter* pFilter = new PluginNativeFilter;
 	if (pFilter == NULL)
@@ -346,52 +346,57 @@
 		FilterList.AddTail(pFilter);
 	else
 		delete pFilter;
+#endif
 
-#ifndef EXCLUDE_FROM_XARALX
-	// Iterate through the component category adding each filter to the filter list
-	HRESULT hRes = S_OK;
-
-	CComPtr<ICatInformation> pCatInformer;
-	hRes = pCatInformer.CoCreateInstance(CLSID_StdComponentCategoriesMgr);
-	if (FAILED(hRes))
+	const static wxString	g_strConfigPath( _T("/usr/share/xaralx/filters") );
+	wxDir	dir( g_strConfigPath );
+	
+	if( !dir.IsOpened() )
 	{
-		// Return an error here
-		return false;
+		// wxDir is susposed to explain why this failed, so we can just 
+		// bomb-out
+		return FALSE;
 	}
-
-	CComPtr<IEnumCLSID> pEnumCLSID;
-	CATID Categories[2] = {
-		{0x42F818E1, 0x9EF6, 0x4241, {0x90, 0x9B, 0x91, 0xE7, 0x83, 0xB9, 0xB9, 0x35}},
-		{0x42F818E1, 0x9EF6, 0x4241, {0x90, 0x9B, 0x91, 0xE7, 0x83, 0xB9, 0xB9, 0x36}}
-	};
-	hRes = pCatInformer->EnumClassesOfCategories(2, Categories, (UINT32)-1, NULL, &pEnumCLSID);
-	if (FAILED(hRes))
+	
+	// Scan all files in directory
+	wxString	strFilename;
+	bool		fOk = dir.GetFirst( &strFilename, _T("*"), wxDIR_FILES );
+	while( fOk )
 	{
-		// Return an error here
-		return false;
-	}
-
-	UINT32 NumRead = 1;
-	CLSID Clsid;
-	while (NumRead != 0)
-	{
-		NumRead = 0;
-		hRes = pEnumCLSID->Next(1, &Clsid, &NumRead);
-		if (FAILED(hRes))
-			break;
-
-		if (NumRead > 0)
+		strFilename = g_strConfigPath + _T("/") + strFilename;
+		
+		// Convert the filename to ASCII
+		size_t	cchFile = strFilename.Length();
+		PSTR	pszFile = (PSTR)alloca( sizeof(char) * ( cchFile + 1 ) );
+		camWcstombs( pszFile, (PCTSTR)strFilename, cchFile );
+		pszFile[cchFile] = '
+		
+		// Open the xml file
+		xmlDoc*		pDoc = xmlReadFile( pszFile, NULL, 0 );
+		if( NULL != pDoc )
 		{
-			PluginNativeFilter* pFilter = new PluginNativeFilter;
-			if (pFilter == NULL) return FALSE;
+			// Scan the root elements for a\some 'filter's
+			xmlNode* pRootElement = xmlDocGetRootElement( pDoc );
+			for( xmlNode* pNode = pRootElement; NULL != pNode; pNode = pNode->next )
+			{
+				if( XML_ELEMENT_NODE == pNode->type &&
+					0 == strcmp( "Filter", PCSTR(pNode->name) ) )
+				{
+					// Create a new filter, Init it and add to list if success
+					// Note will be auto deleted if not added
+					std::auto_ptr<PluginNativeFilter> pFilter( new PluginNativeFilter );
+					if( pFilter->Init( pNode ) )
+						FilterList.AddTail( pFilter.release() );
+				}
+			}
 
-			if (pFilter->Init(Clsid))
-				FilterList.AddTail(pFilter);
-			else
-				delete pFilter;
+			xmlFreeDoc( pDoc );
+			pDoc = NULL;
 		}
+		
+		fOk = dir.GetNext( &strFilename );
 	}
-#endif
+	
 	return TRUE;
 }
 
Index: Trunk/XaraLX/wxOil/xpoilflt.h
===================================================================
--- Trunk/XaraLX/wxOil/xpoilflt.h	(revision 993)
+++ Trunk/XaraLX/wxOil/xpoilflt.h	(revision 994)
@@ -163,7 +163,7 @@
 	// the filter name and file extension
 	// The parameter will almost certainly need to change when OILFilter::CreatePluginFilters 
 	// is implemented properly by scanning the installed filters
-	BOOL Init(const CLSID& rCLSID);
+	BOOL Init( xmlNode* pFilterNode );
 
 	BOOL IsImport() { return(m_bImport); }
 	BOOL IsExport() { return(m_bExport); }
Index: Trunk/XaraLX/wxOil/fltrdisc.cpp (deleted)
===================================================================
Index: Trunk/XaraLX/wxOil/fltrdisc.h (deleted)
===================================================================


Xara