103 return XercesStringToWString (aXercesString); |
103 return XercesStringToWString (aXercesString); |
104 } |
104 } |
105 #endif // _WIN32 |
105 #endif // _WIN32 |
106 |
106 |
107 |
107 |
|
108 std::string ConvertOpaqueData(const std::string& opaqueData) |
|
109 { |
|
110 int iLength = 0; |
|
111 |
|
112 //Cardanility check. Values in the range 0-127 are stored in a single byte, |
|
113 //128-16383 in two bytes and other values in 4 bytes. |
|
114 if(0x7f > opaqueData.length()) |
|
115 iLength = 1; |
|
116 else |
|
117 iLength = 2; |
|
118 |
|
119 int iLen = (opaqueData.length()+iLength)*2; |
|
120 std::string sStr(iLen, '\0'); // Make room for characters |
|
121 |
|
122 if(1==iLength) |
|
123 { |
|
124 sStr[0]=opaqueData.length(); |
|
125 sStr[1]=0xab; |
|
126 } |
|
127 else |
|
128 { |
|
129 sStr[0]=0x1; |
|
130 sStr[1]= ((opaqueData.length() & 0x3F00) >> 8); |
|
131 sStr[2]= (opaqueData.length() & 0xFF); |
|
132 sStr[3]=0xab; |
|
133 } |
|
134 |
|
135 char* temp = opaqueData.c_str(); |
|
136 |
|
137 for(int i =iLength*2; i<iLen; i++) |
|
138 { |
|
139 sStr[i++] = *temp++; |
|
140 } |
|
141 sStr[i] = '\0'; |
|
142 |
|
143 return sStr; |
|
144 } |
|
145 |
108 DllExport CScrXmlParser::CScrXmlParser() |
146 DllExport CScrXmlParser::CScrXmlParser() |
109 {} |
147 {} |
110 |
148 |
111 DllExport CScrXmlParser::~CScrXmlParser() |
149 DllExport CScrXmlParser::~CScrXmlParser() |
112 {} |
150 {} |
301 fn_auto_ptr<releaseXmlChPtr, XMLCh> tagSoftwareTypeNames( &XMLString::release, XMLString::transcode("SoftwareTypeNames") ); |
339 fn_auto_ptr<releaseXmlChPtr, XMLCh> tagSoftwareTypeNames( &XMLString::release, XMLString::transcode("SoftwareTypeNames") ); |
302 fn_auto_ptr<releaseXmlChPtr, XMLCh> tagUniqueSoftwareTypeName( &XMLString::release, XMLString::transcode("UniqueSoftwareTypeName") ); |
340 fn_auto_ptr<releaseXmlChPtr, XMLCh> tagUniqueSoftwareTypeName( &XMLString::release, XMLString::transcode("UniqueSoftwareTypeName") ); |
303 fn_auto_ptr<releaseXmlChPtr, XMLCh> tagLocalizableSwTypeName( &XMLString::release, XMLString::transcode("LocalizableSoftwareTypeName") ); |
341 fn_auto_ptr<releaseXmlChPtr, XMLCh> tagLocalizableSwTypeName( &XMLString::release, XMLString::transcode("LocalizableSoftwareTypeName") ); |
304 fn_auto_ptr<releaseXmlChPtr, XMLCh> tagSifPluginUid( &XMLString::release, XMLString::transcode("SifPluginUid") ); |
342 fn_auto_ptr<releaseXmlChPtr, XMLCh> tagSifPluginUid( &XMLString::release, XMLString::transcode("SifPluginUid") ); |
305 fn_auto_ptr<releaseXmlChPtr, XMLCh> tagLauncherExecutable( &XMLString::release, XMLString::transcode("LauncherExecutable") ); |
343 fn_auto_ptr<releaseXmlChPtr, XMLCh> tagLauncherExecutable( &XMLString::release, XMLString::transcode("LauncherExecutable") ); |
306 fn_auto_ptr<releaseXmlChPtr, XMLCh> tagCustomAcess( &XMLString::release, XMLString::transcode("CustomAcess") ); |
344 fn_auto_ptr<releaseXmlChPtr, XMLCh> tagCustomAccess( &XMLString::release, XMLString::transcode("CustomAccess") ); |
307 fn_auto_ptr<releaseXmlChPtr, XMLCh> tagMIMEDetails( &XMLString::release, XMLString::transcode("MIMEDetails") ); |
345 fn_auto_ptr<releaseXmlChPtr, XMLCh> tagMIMEDetails( &XMLString::release, XMLString::transcode("MIMEDetails") ); |
308 fn_auto_ptr<releaseXmlChPtr, XMLCh> tagMIMEType( &XMLString::release, XMLString::transcode("MIMEType") ); |
346 fn_auto_ptr<releaseXmlChPtr, XMLCh> tagMIMEType( &XMLString::release, XMLString::transcode("MIMEType") ); |
309 |
347 |
310 DOMNodeList* swTypeNames = aEnvironment->getElementsByTagName(tagSoftwareTypeNames.get()); |
348 DOMNodeList* swTypeNames = aEnvironment->getElementsByTagName(tagSoftwareTypeNames.get()); |
311 DOMNode* swTypeNamesRoot = swTypeNames->item(0); |
349 DOMNode* swTypeNamesRoot = swTypeNames->item(0); |
334 |
372 |
335 DOMNodeList* launcherExecutable = aEnvironment->getElementsByTagName(tagLauncherExecutable.get()); |
373 DOMNodeList* launcherExecutable = aEnvironment->getElementsByTagName(tagLauncherExecutable.get()); |
336 if(0 != launcherExecutable->getLength()) |
374 if(0 != launcherExecutable->getLength()) |
337 { |
375 { |
338 textContent = launcherExecutable->item(0)->getTextContent(); |
376 textContent = launcherExecutable->item(0)->getTextContent(); |
339 fn_auto_ptr<releaseXmlChPtr, XMLCh> launcherExecutableText( &XMLString::release,textContent ); |
377 #ifdef _WIN32 |
|
378 fn_auto_ptr<releaseXmlChPtr, XMLCh> launcherExecutableText( &XMLString::release,textContent); |
340 const XMLCh* launcherExecutableValue = launcherExecutableText.get(); |
379 const XMLCh* launcherExecutableValue = launcherExecutableText.get(); |
341 scrEnvDetails.iLauncherExecutable = XMLChToWString(launcherExecutableValue); |
380 scrEnvDetails.iLauncherExecutable = XMLChToWString(launcherExecutableValue); |
342 } |
381 #else |
343 DOMNodeList* customAcessList = aEnvironment->getElementsByTagName(tagCustomAcess.get()); |
382 scrEnvDetails.iLauncherExecutable = XMLChToWString(textContent); |
344 const XMLSize_t customAcessDataCount = customAcessList->getLength(); |
383 #endif // _WIN32 |
345 for( XMLSize_t count=0 ; count<customAcessDataCount ; ++count ) |
384 } |
346 { |
385 DOMNodeList* customAccessList = aEnvironment->getElementsByTagName(tagCustomAccess.get()); |
347 DOMNode* customAcessRoot = customAcessList->item(count); |
386 const XMLSize_t customAccessDataCount = customAccessList->getLength(); |
348 DOMElement* customAcessNode = static_cast< xercesc::DOMElement* >( customAcessRoot ); |
387 for( XMLSize_t count=0 ; count<customAccessDataCount ; ++count ) |
349 XmlDetails::TScrEnvironmentDetails::TCustomAcessList customAcessData = GetCustomAcessList(customAcessNode); |
388 { |
350 scrEnvDetails.iCustomAcessList.push_back(customAcessData); |
389 DOMNode* customAccessRoot = customAccessList->item(count); |
|
390 DOMElement* customAccessNode = static_cast< xercesc::DOMElement* >( customAccessRoot ); |
|
391 XmlDetails::TScrEnvironmentDetails::TCustomAccessList customAccessData = GetCustomAccessList(customAccessNode); |
|
392 scrEnvDetails.iCustomAccessList.push_back(customAccessData); |
351 } |
393 } |
352 |
394 |
353 DOMNodeList* mimeDetails = aEnvironment->getElementsByTagName(tagMIMEDetails.get()); |
395 DOMNodeList* mimeDetails = aEnvironment->getElementsByTagName(tagMIMEDetails.get()); |
354 DOMNode* mimeDetailRoot = mimeDetails->item(0); |
396 DOMNode* mimeDetailRoot = mimeDetails->item(0); |
355 DOMElement* mimeDetailNode = static_cast< xercesc::DOMElement* >( mimeDetailRoot ); |
397 DOMElement* mimeDetailNode = static_cast< xercesc::DOMElement* >( mimeDetailRoot ); |
822 localizedSwTypeName.iName = XMLChToWString(textName); |
864 localizedSwTypeName.iName = XMLChToWString(textName); |
823 LOGEXIT("CScrXmlParser::GetLocalizedSoftwareTypeName()"); |
865 LOGEXIT("CScrXmlParser::GetLocalizedSoftwareTypeName()"); |
824 return localizedSwTypeName; |
866 return localizedSwTypeName; |
825 } |
867 } |
826 |
868 |
827 XmlDetails::TScrEnvironmentDetails::TCustomAcessList |
869 XmlDetails::TScrEnvironmentDetails::TCustomAccessList |
828 CScrXmlParser::GetCustomAcessList(const DOMElement* aDOMElement) |
870 CScrXmlParser::GetCustomAccessList(const DOMElement* aDOMElement) |
829 { |
871 { |
830 LOGENTER("CScrXmlParser::GetCustomAcessList()"); |
872 LOGENTER("CScrXmlParser::GetCustomAccessList()"); |
831 fn_auto_ptr<releaseXmlChPtr, XMLCh> tagSecureId( &XMLString::release, XMLString::transcode("SecureId") ); |
873 fn_auto_ptr<releaseXmlChPtr, XMLCh> tagSecureId( &XMLString::release, XMLString::transcode("SecureId") ); |
832 fn_auto_ptr<releaseXmlChPtr, XMLCh> tagAccessMode( &XMLString::release, XMLString::transcode("AccessMode") ); |
874 fn_auto_ptr<releaseXmlChPtr, XMLCh> tagAccessMode( &XMLString::release, XMLString::transcode("AccessMode") ); |
833 |
875 |
834 DOMNamedNodeMap* attributes = aDOMElement->getAttributes(); |
876 DOMNamedNodeMap* attributes = aDOMElement->getAttributes(); |
835 DOMNode* secureId = attributes->getNamedItem(tagSecureId.get()); |
877 DOMNode* secureId = attributes->getNamedItem(tagSecureId.get()); |
836 DOMNode* accessMode = attributes->getNamedItem(tagAccessMode.get()); |
878 DOMNode* accessMode = attributes->getNamedItem(tagAccessMode.get()); |
837 |
879 |
838 XmlDetails::TScrEnvironmentDetails::TCustomAcessList customAcessList; |
880 XmlDetails::TScrEnvironmentDetails::TCustomAccessList customAccessList; |
839 |
881 |
840 fn_auto_ptr<releaseChPtr,char> textSecureId(&XMLString::release, XMLString::transcode(secureId->getTextContent())); |
882 fn_auto_ptr<releaseChPtr,char> textSecureId(&XMLString::release, XMLString::transcode(secureId->getTextContent())); |
841 int secureIdVal=0; |
883 int secureIdVal=0; |
842 sscanf(textSecureId.get(),"%x",&secureIdVal); |
884 sscanf(textSecureId.get(),"%x",&secureIdVal); |
843 customAcessList.iSecureId = secureIdVal; |
885 customAccessList.iSecureId = secureIdVal; |
844 |
886 |
845 const XMLCh* textAccessMode = accessMode->getTextContent(); |
887 const XMLCh* textAccessMode = accessMode->getTextContent(); |
846 customAcessList.iAccessMode = XercesStringToInteger(textAccessMode); |
888 customAccessList.iAccessMode = XercesStringToInteger(textAccessMode); |
847 LOGEXIT("CScrXmlParser::GetCustomAcessList()"); |
889 LOGEXIT("CScrXmlParser::GetCustomAccessList()"); |
848 return customAcessList; |
890 return customAccessList; |
849 } |
891 } |
850 |
892 |
851 XmlDetails::TScrPreProvisionDetail::TApplicationRegistrationInfo CScrXmlParser::GetApplicationRegistrationInfo(const DOMElement* aDOMElement) |
893 XmlDetails::TScrPreProvisionDetail::TApplicationRegistrationInfo CScrXmlParser::GetApplicationRegistrationInfo(const DOMElement* aDOMElement) |
852 { |
894 { |
853 LOGENTER("CScrXmlParser::GetApplicationRegistrationInfo()"); |
895 LOGENTER("CScrXmlParser::GetApplicationRegistrationInfo()"); |
897 appProperty.iIntValue = 0; |
939 appProperty.iIntValue = 0; |
898 appProperty.iIsStr8Bit = true; |
940 appProperty.iIsStr8Bit = true; |
899 appProperty.iServiceUid = 0; |
941 appProperty.iServiceUid = 0; |
900 |
942 |
901 if(opaqueDataType.iIsBinary == 1) |
943 if(opaqueDataType.iIsBinary == 1) |
902 { |
944 { |
903 std::string str = wstring2string(opaqueDataType.iOpaqueData); |
945 std::cout.flush(); |
904 std::string decodedString = Util::Base64Decode(str); |
946 appProperty.iStrValue = Util::Base64Decode(opaqueDataType.iOpaqueData); |
905 int len = decodedString.length(); |
947 } |
906 appProperty.iStrValue.assign(decodedString.c_str(),decodedString.c_str()+len); |
|
907 } |
|
908 else |
948 else |
909 { |
949 { |
910 appProperty.iStrValue = opaqueDataType.iOpaqueData; |
950 appProperty.iStrValue = ConvertOpaqueData(opaqueDataType.iOpaqueData); |
911 } |
951 } |
912 |
952 |
913 appRegistrationInfo.iApplicationProperty.push_back(appProperty); |
953 appRegistrationInfo.iApplicationProperty.push_back(appProperty); |
914 } |
954 } |
915 |
955 |
916 // for each FileOwnershipInfo retrieve all tags |
956 // for each FileOwnershipInfo retrieve all tags |
1097 { |
1137 { |
1098 LOGENTER("CScrXmlParser::GetServiceOpaqueDataType()"); |
1138 LOGENTER("CScrXmlParser::GetServiceOpaqueDataType()"); |
1099 // tags in OpaqueDataType |
1139 // tags in OpaqueDataType |
1100 fn_auto_ptr<releaseXmlChPtr, XMLCh> tagServiceData( &XMLString::release, XMLString::transcode("ServiceData") ); |
1140 fn_auto_ptr<releaseXmlChPtr, XMLCh> tagServiceData( &XMLString::release, XMLString::transcode("ServiceData") ); |
1101 fn_auto_ptr<releaseXmlChPtr, XMLCh> tagServiceOpaqueLocale( &XMLString::release, XMLString::transcode("ServiceOpaqueLocale") ); |
1141 fn_auto_ptr<releaseXmlChPtr, XMLCh> tagServiceOpaqueLocale( &XMLString::release, XMLString::transcode("ServiceOpaqueLocale") ); |
|
1142 fn_auto_ptr<releaseXmlChPtr, XMLCh> tagServiceDataIsBinary( &XMLString::release, XMLString::transcode("ServiceDataIsBinary") ); |
1102 |
1143 |
1103 DOMNodeList* ServiceData = aDOMElement->getElementsByTagName(tagServiceData.get()); |
1144 DOMNodeList* ServiceData = aDOMElement->getElementsByTagName(tagServiceData.get()); |
1104 DOMNodeList* ServiceOpaqueLocale = aDOMElement->getElementsByTagName(tagServiceOpaqueLocale.get()); |
1145 DOMNodeList* ServiceOpaqueLocale = aDOMElement->getElementsByTagName(tagServiceOpaqueLocale.get()); |
|
1146 DOMNodeList* ServiceDataIsBinary = aDOMElement->getElementsByTagName(tagServiceDataIsBinary.get()); |
1105 |
1147 |
1106 XmlDetails::TScrPreProvisionDetail::TApplicationRegistrationInfo::TOpaqueDataType opaqueDataType; |
1148 XmlDetails::TScrPreProvisionDetail::TApplicationRegistrationInfo::TOpaqueDataType opaqueDataType; |
1107 |
1149 |
1108 if( ServiceOpaqueLocale->getLength() != 0) |
1150 if( ServiceOpaqueLocale->getLength() != 0) |
1109 { |
1151 { |
1112 } |
1154 } |
1113 |
1155 |
1114 if( ServiceData->getLength() != 0) |
1156 if( ServiceData->getLength() != 0) |
1115 { |
1157 { |
1116 const XMLCh* typ = ServiceData->item(0)->getTextContent(); |
1158 const XMLCh* typ = ServiceData->item(0)->getTextContent(); |
1117 opaqueDataType.iOpaqueData = XMLChToWString(typ); |
1159 opaqueDataType.iOpaqueData = XMLString::transcode(typ); |
1118 } |
1160 } |
|
1161 |
|
1162 if(ServiceDataIsBinary->getLength() != 0) |
|
1163 { |
|
1164 const XMLCh* textIsBinary = ServiceDataIsBinary->item(0)->getTextContent(); |
|
1165 opaqueDataType.iIsBinary = XercesStringToInteger(textIsBinary); |
|
1166 } |
|
1167 |
1119 LOGEXIT("CScrXmlParser::GetServiceOpaqueDataType()"); |
1168 LOGEXIT("CScrXmlParser::GetServiceOpaqueDataType()"); |
1120 return opaqueDataType; |
1169 return opaqueDataType; |
1121 } |
1170 } |
1122 |
1171 |
1123 XmlDetails::TScrPreProvisionDetail::TApplicationRegistrationInfo::TAppServiceInfo |
1172 XmlDetails::TScrPreProvisionDetail::TApplicationRegistrationInfo::TAppServiceInfo |
1157 appProperty.iName = L"OpaqueData"; |
1206 appProperty.iName = L"OpaqueData"; |
1158 appProperty.iIntValue = 0; |
1207 appProperty.iIntValue = 0; |
1159 appProperty.iIsStr8Bit = true; |
1208 appProperty.iIsStr8Bit = true; |
1160 appProperty.iServiceUid = appServiceInfo.iUid; |
1209 appProperty.iServiceUid = appServiceInfo.iUid; |
1161 if(opaqueDataType.iIsBinary == 1) |
1210 if(opaqueDataType.iIsBinary == 1) |
1162 { |
1211 { |
1163 std::string str = wstring2string(opaqueDataType.iOpaqueData); |
1212 std::cout.flush(); |
1164 std::string decodedString = Util::Base64Decode(str); |
1213 appProperty.iStrValue = Util::Base64Decode(opaqueDataType.iOpaqueData); |
1165 appProperty.iStrValue = string2wstring(decodedString); |
1214 } |
1166 } |
|
1167 else |
1215 else |
1168 { |
1216 { |
1169 appProperty.iStrValue = opaqueDataType.iOpaqueData; |
1217 appProperty.iStrValue = ConvertOpaqueData(opaqueDataType.iOpaqueData); |
1170 } |
1218 } |
1171 aAppRegistrationInfo.iApplicationProperty.push_back(appProperty); |
1219 aAppRegistrationInfo.iApplicationProperty.push_back(appProperty); |
1172 } |
1220 } |
1173 |
1221 |
1174 // for each DataType retrieve all tags |
1222 // for each DataType retrieve all tags |
1175 for( XMLSize_t index = 0; index < dataTypeCount; ++index ) |
1223 for( XMLSize_t index = 0; index < dataTypeCount; ++index ) |
1402 appProperty.iIntValue = XercesStringToInteger(intval); |
1450 appProperty.iIntValue = XercesStringToInteger(intval); |
1403 } |
1451 } |
1404 else if( strvalue->getLength() != 0) |
1452 else if( strvalue->getLength() != 0) |
1405 { |
1453 { |
1406 const XMLCh* strval = strvalue->item(0)->getTextContent(); |
1454 const XMLCh* strval = strvalue->item(0)->getTextContent(); |
1407 appProperty.iStrValue = XMLChToWString(strval); |
1455 appProperty.iStrValue = XMLString::transcode(strval); |
1408 } |
1456 } |
1409 |
1457 |
1410 appProperty.iIsStr8Bit = false; |
1458 appProperty.iIsStr8Bit = false; |
1411 |
1459 |
1412 LOGEXIT("CScrXmlParser::GetAppProperty()"); |
1460 LOGEXIT("CScrXmlParser::GetAppProperty()"); |