diff -r 79859ed3eea9 -r 919f36ff910f webengine/widgetregistry/Server/src/WidgetEntry.cpp --- a/webengine/widgetregistry/Server/src/WidgetEntry.cpp Tue Aug 31 16:17:46 2010 +0300 +++ b/webengine/widgetregistry/Server/src/WidgetEntry.cpp Wed Sep 01 12:28:30 2010 +0100 @@ -17,10 +17,11 @@ */ #include "WidgetEntry.h" -#include "WidgetRegistryConstants.h" +#include "UidAllocator.h" +#include #include #include -#include +#include //#include // EXTERNAL DATA STRUCTURES @@ -54,8 +55,6 @@ _LIT( KXmlDataTypeString, "string" ); _LIT( KXmlDataTypeUid, "uid" ); -static const TInt KWidgetPropertyListVersion32 = 1; -static const TInt KWidgetPropertyListVersion71 = 3; // MODULE DATA STRUCTURES // LOCAL FUNCTION PROTOTYPES @@ -93,7 +92,8 @@ CWidgetEntry* CWidgetEntry::NewL( RPointerArray** aProps ) { CWidgetEntry* tmp = NewL(); - for ( TInt i = 0; i < (*aProps)->Count(); i++ ) + TInt i = 0; + for ( ; i < (*aProps)->Count(); i++ ) { CWidgetPropertyValue* value = CWidgetPropertyValue::NewL(); tmp->iPropertyValues.AppendL( value ); @@ -102,6 +102,14 @@ (**aProps)[i]->iType = EWidgetPropTypeUnknown; delete (**aProps)[i]; } + + // Pad out with unknown properties to reach the correct number + for ( ; i < EWidgetPropertyIdCount ; i++ ) + { + CWidgetPropertyValue* value = CWidgetPropertyValue::NewL(); + tmp->iPropertyValues.AppendL( value ); + } + (*aProps)->Close(); delete *aProps; *aProps = NULL; @@ -117,9 +125,9 @@ // CWidgetEntry::CWidgetEntry() : iPropertyValues( EWidgetPropertyIdCount ), - iBlanketPermGranted ( EFalse), + iMiniView ( EFalse), iFullView ( EFalse), - iMiniView ( EFalse) + iBlanketPermGranted ( EFalse) { } @@ -170,13 +178,44 @@ //WIDGETPROPERTYLISTVERSION is 1 in case of Tiger engine and 3 in case of Leopard engine. Therefore, modifying the check such that //when the Version id is 1 or 3, we do not treat the file as corrupt. if ( ( EWidgetPropTypeUnknown == (*this)[EWidgetPropertyListVersion].iType ) - || ( (KWidgetPropertyListVersion32 != (*this)[EWidgetPropertyListVersion] ) && (KWidgetPropertyListVersion71 != (*this)[EWidgetPropertyListVersion] )) ) + || ( (KWidgetPropertyListVersion32 != (*this)[EWidgetPropertyListVersion] ) && + (KWidgetPropertyListVersion71 != (*this)[EWidgetPropertyListVersion] ) && + (KWidgetPropertyListVersion71CWRT != (*this)[EWidgetPropertyListVersion] ) )) { User::Leave( KErrCorrupt ); } + + // Provide appropriate values for EProcessUid and EMimeType + (*this)[EProcessUid] = KUidWidgetUi.iUid; + + HBufC* heapBuf = HBufC::NewLC(KWidgetMime().Length()); + TPtr ptr(heapBuf->Des()); + ptr.Copy(KWidgetMime); // 8-bit to 16-bit copy + (*this)[EMimeType] = *heapBuf; + CleanupStack::PopAndDestroy(); + + // Read only until the ENokiaWidget for the 3.2 widgets, EPreInstalled for 7.1 widgets + TInt propertyIdCount = 0; + switch ((*this)[EWidgetPropertyListVersion]) { + case KWidgetPropertyListVersion32: + propertyIdCount = ENokiaWidget+1; + // since we've filled in the EProcessUid and EMimeType we're + // now at KWidgetPropertyListVersion71CWRT + (*this)[EWidgetPropertyListVersion] = KWidgetPropertyListVersion71CWRT; + break; + case KWidgetPropertyListVersion71: + propertyIdCount = EPreInstalled+1; + // since we've filled in the EProcessUid and EMimeType we're + // now at KWidgetPropertyListVersion71CWRT + (*this)[EWidgetPropertyListVersion] = KWidgetPropertyListVersion71CWRT; + break; + case KWidgetPropertyListVersion71CWRT: + propertyIdCount = EWidgetPropertyIdCount; + break; + } // fill property values array - for ( TInt i = 1; i < EWidgetPropertyIdCount; ++i ) + for ( TInt i = 1; i < propertyIdCount; ++i ) { (*this)[i].DeserializeL( aReadStream ); } @@ -217,6 +256,8 @@ iPropertyValues.AppendL( val ); CleanupStack::Pop(); // val } + // Internalization of the Xml is complete, cleanup the properties appropriately + PropertyCleanupL(); return; } TPtrC8 propTag( n->name ); @@ -395,7 +436,6 @@ CWidgetRegistryXml* aXmlProcessor, RFs& aFileSession ) { - xmlDocPtr doc = NULL; // not really used TInt i = 0; // For each property, write an XML entry for ( ; i < EWidgetPropertyIdCount; ++i ) @@ -583,7 +623,17 @@ User::LeaveIfError( wsSession.Connect() ); CleanupClosePushL( wsSession ); TApaTaskList taskList( wsSession ); - TApaTask task = taskList.FindApp( KUidWidgetUi ); + + TUid uid; + + if ( EWidgetPropTypeUnknown == (*this)[EProcessUid].iType ) { + uid = KUidWidgetUi; + } else { + uid = TUid::Uid( (*this)[EProcessUid] ); + } + + TApaTask task = taskList.FindApp( uid ); + if ( EFalse == task.Exists() ) { // widget UI crashed, reset active @@ -617,5 +667,51 @@ } } + +// ============================================================================ +// CWidgetEntry::PropertyCleanupL() +// Make adjustments to bring the property values up to the current +// property list version +// +// @since +// ============================================================================ +// +void CWidgetEntry::PropertyCleanupL() +{ + TInt currentVersion = (*this)[EWidgetPropertyListVersion]; + + while (currentVersion < WIDGETPROPERTYLISTVERSION) { + switch (currentVersion) { + case KWidgetPropertyListVersion32: + // Go from PropertyListVersion32 to PropertyListVersion71 + // Adds EMiniViewEnable, EBlanketPermGranted, EPreInstalled + // (all are optional, just update the version number now + // and they will be undefined when serialized/deserialized) + currentVersion = KWidgetPropertyListVersion71; + break; + case KWidgetPropertyListVersion71: + // Go from PropertlyListVersion71 to PropertyListVersion71CWRT + // 1) add ProcessUid for WRT (wgz) widgets + { + (*this)[EProcessUid] = KUidWidgetUi.iUid; + + // 2) add MIMEType + HBufC* heapBuf = HBufC::NewLC(KWidgetMime().Length()); + TPtr ptr(heapBuf->Des()); + ptr.Copy(KWidgetMime); // 8-bit to 16-bit copy + (*this)[EMimeType] = *heapBuf; + CleanupStack::PopAndDestroy(); + + currentVersion = KWidgetPropertyListVersion71CWRT; + } + break; + default: + // Trouble + return; + } + + (*this)[EWidgetPropertyListVersion] = currentVersion; + } +} // End of File