applicationmanagement/omascomoadapter/src/omascomoadapter.cpp
branchRCL_3
changeset 23 c4687ff85147
parent 20 f2101057ffeb
child 24 6757f1e2efd2
equal deleted inserted replaced
22:9360ca28b668 23:c4687ff85147
   920 	         
   920 	         
   921             
   921             
   922             TBuf8<6> dataresult;
   922             TBuf8<6> dataresult;
   923             dataresult.Num(finalresult);
   923             dataresult.Num(finalresult);
   924             
   924             
   925             TPtrC8 mapping(NSmlDmURI::LastURISeg(targetURIGet) );
   925             RDEBUG8_2("CSCOMOAdapter::GetIdentifierIdL is targetURIGet '%S'", &targetURIGet);
   926             
   926             
       
   927             //TPtrC8 mapping(NSmlDmURI::LastURISeg(targetURIGet) );
       
   928             
       
   929             HBufC8* identifier=GetIdentifierIdL(internalid );
   927             
   930             
   928             TInt retryupdate = iAMdb->GetRetryCountForLuidL(internalid);
   931             TInt retryupdate = iAMdb->GetRetryCountForLuidL(internalid);
   929             
   932             
   930             // If retryupdate in Zero then delete its entry from 
   933             // If retryupdate in Zero then delete its entry from 
   931             // database.
   934             // database.
   960             //ptr.Append(KDataStart);
   963             //ptr.Append(KDataStart);
   961             ptr.Append(KResultCodeStart);
   964             ptr.Append(KResultCodeStart);
   962             ptr.Append(dataresult);
   965             ptr.Append(dataresult);
   963             ptr.Append(KResultCodeEnd);
   966             ptr.Append(KResultCodeEnd);
   964             ptr.Append(KIdentifierStart);
   967             ptr.Append(KIdentifierStart);
   965             ptr.Append(mapping);
   968             ptr.Append(*identifier);
   966             ptr.Append(KIdentifierEnd);
   969             ptr.Append(KIdentifierEnd);
   967             //ptr.Append(KDataEnd);
   970             //ptr.Append(KDataEnd);
   968 
   971 
   969             HBufC8 *sourceuri = genericalerts[i]->iSourceURI;
   972             HBufC8 *sourceuri = genericalerts[i]->iSourceURI;
   970     		
   973     		
   990     
   993     
   991     		iItemArray.AppendL(*item);
   994     		iItemArray.AppendL(*item);
   992             
   995             
   993             TRAP_IGNORE(privateAPI.AddDMGenericAlertRequestL(              
   996             TRAP_IGNORE(privateAPI.AddDMGenericAlertRequestL(              
   994                     *genericalerts[i]->iCorrelator,iItemArray ));
   997                     *genericalerts[i]->iCorrelator,iItemArray ));
   995                     
   998                  
   996                     
   999             
       
  1000             //cleanup all the allocated heap cells
       
  1001             if(data)        
   997             delete data;
  1002             delete data;
   998             
  1003             
       
  1004             if(metamark)
   999             delete metamark;
  1005             delete metamark;
  1000             
  1006             
       
  1007             if(metaformat)
  1001             delete metaformat;
  1008             delete metaformat;
  1002             
  1009             
       
  1010             if(metatype)
  1003             delete metatype;
  1011             delete metatype;
  1004             
  1012             
       
  1013             if(targeturi)
  1005             delete targeturi;
  1014             delete targeturi;
       
  1015 
       
  1016             if(item)
  1006             delete item;
  1017             delete item;
       
  1018             
       
  1019             if(identifier)
       
  1020             delete identifier;
  1007                     
  1021                     
  1008             iItemArray.Reset();			
  1022             iItemArray.Reset();			
  1009 			iItemArray.Close();
  1023 			iItemArray.Close();
  1010             CleanupStack::PopAndDestroy( &privateAPI);
  1024             CleanupStack::PopAndDestroy( &privateAPI);
  1011             }
  1025             }
  1739         TPtrC8 aclmapping(URISegsUpTo(aURI, 4) );
  1753         TPtrC8 aclmapping(URISegsUpTo(aURI, 4) );
  1740         SetMappingL(aclmapping, aTargetState, aLUID);
  1754         SetMappingL(aclmapping, aTargetState, aLUID);
  1741         iManagement.StateChangeComplete(aLuidi);
  1755         iManagement.StateChangeComplete(aLuidi);
  1742 
  1756 
  1743         DeactivateIfInactive(aLuidi, aTargetState);
  1757         DeactivateIfInactive(aLuidi, aTargetState);
  1744         aRet = EOk;
  1758         aRet = EExecSuccess;
  1745         }
  1759         }
  1746     else
  1760     else
  1747         {
  1761         {
  1748         RDEBUG_2( "CSCOMOAdapter::InstallL(): INSTALL FAILED '%d'" , err);
  1762         RDEBUG_2( "CSCOMOAdapter::InstallL(): INSTALL FAILED '%d'" , err);
  1749         MAPERROR( err, aRet, _L8("Install %d") );
  1763         //MAPERROR( err, aRet, _L8("Install %d") );
       
  1764 	  aRet = EExecInstallFailed;
  1750         }
  1765         }
  1751     }
  1766     }
  1752 
  1767 
  1753 // ------------------------------------------------------------------------------------------------
  1768 // ------------------------------------------------------------------------------------------------
  1754 // CSCOMOAdapter::DefaultMapError( const TInt aErr, TError &aRet )
  1769 // CSCOMOAdapter::DefaultMapError( const TInt aErr, TError &aRet )
  1838 // ------------------------------------------------------------------------------------------------
  1853 // ------------------------------------------------------------------------------------------------
  1839 void CSCOMOAdapter::ExecuteCommandL(const TDesC8& aURI, const TDesC8& aLUID,
  1854 void CSCOMOAdapter::ExecuteCommandL(const TDesC8& aURI, const TDesC8& aLUID,
  1840         const TDesC8& aArgument, const TDesC8& /*aType*/, TInt aStatusRef)
  1855         const TDesC8& aArgument, const TDesC8& /*aType*/, TInt aStatusRef)
  1841     {
  1856     {
  1842 
  1857 
  1843 #ifdef __TARM_SYMBIAN_CONVERGENCY	//Done by Dipak
  1858 #ifdef __TARM_SYMBIAN_CONVERGENCY	
  1844     TPtrC8 uriPtrc = NSmlDmURI::RemoveDotSlash(aURI);
  1859     TPtrC8 uriPtrc = NSmlDmURI::RemoveDotSlash(aURI);
  1845 #else
  1860 #else
  1846     //nothing
  1861     //nothing
  1847 #endif
  1862 #endif
  1848 
  1863 
  1854     if (aLUID == KNullDesC8)
  1869     if (aLUID == KNullDesC8)
  1855         {
  1870         {
  1856         RDEBUG("CSCOMOAdapter::ExecuteCommandL(): WARNING no valid luid provided" );
  1871         RDEBUG("CSCOMOAdapter::ExecuteCommandL(): WARNING no valid luid provided" );
  1857         }
  1872         }
  1858 
  1873 
  1859 #ifdef __TARM_SYMBIAN_CONVERGENCY	//Done by Dipak
  1874 #ifdef __TARM_SYMBIAN_CONVERGENCY
  1860     TInt cnt( NSmlDmURI::NumOfURISegs( uriPtrc ) );
  1875     TInt cnt( NSmlDmURI::NumOfURISegs( uriPtrc ) );
  1861 #else
  1876 #else
  1862     TInt cnt(NSmlDmURI::NumOfURISegs(aURI) );
  1877     TInt cnt(NSmlDmURI::NumOfURISegs(aURI) );
  1863 #endif	
  1878 #endif	
  1864 
  1879 
  1944                         else
  1959                         else
  1945                             {
  1960                             {
  1946                             ret = EExecUndefError;
  1961                             ret = EExecUndefError;
  1947                             }
  1962                             }
  1948                     }
  1963                     }
       
  1964 			SetSCOMOTargetURIL(*iUriDel, mapping, ret);
  1949 
  1965 
  1950                 }
  1966                 }
  1951             else
  1967             else
  1952                 {
  1968                 {
  1953                 ret = EExecUndefError;
  1969                 ret = EExecUndefError;
  2054                     else
  2070                     else
  2055                         {
  2071                         {
  2056                         ret = EExecRemoveFailed;
  2072                         ret = EExecRemoveFailed;
  2057                         RDEBUG( "CSCOMOAdapter::ExecuteCommandL(): case 6 remove Not found node" );
  2073                         RDEBUG( "CSCOMOAdapter::ExecuteCommandL(): case 6 remove Not found node" );
  2058                         }
  2074                         }
       
  2075                     SetSCOMOTargetURIL(*iUriDel, mapping, ret);
  2059                     }
  2076                     }
  2060                         else
  2077                         else
  2061                             if (mapping == KAMActivateNodeName)
  2078                             if (mapping == KAMActivateNodeName)
  2062                                 {
  2079                                 {
  2063                                 //DBG_ARGS8( "CSCOMOAdapter::ExecuteCommandL(): Activating " );
  2080                                 //DBG_ARGS8( "CSCOMOAdapter::ExecuteCommandL(): Activating " );
  2082                                 else
  2099                                 else
  2083                                     {
  2100                                     {
  2084                                     ret = EExecActivateFailed;
  2101                                     ret = EExecActivateFailed;
  2085                                     RDEBUG( "CSCOMOAdapter::ExecuteCommandL(): case 6 Activate Not found node" );
  2102                                     RDEBUG( "CSCOMOAdapter::ExecuteCommandL(): case 6 Activate Not found node" );
  2086                                     }
  2103                                     }
       
  2104 
       
  2105                                 SetSCOMOTargetURIL(*iUriDel, mapping, ret);
  2087                                 }
  2106                                 }
  2088                             else
  2107                             else
  2089                                 if (mapping == KAMDeActivateNodeName)
  2108                                 if (mapping == KAMDeActivateNodeName)
  2090                                     {
  2109                                     {
  2091                                     //DBG_ARGS8( "CSCOMOAdapter::ExecuteCommandL(): Inactivating " );
  2110                                     //DBG_ARGS8( "CSCOMOAdapter::ExecuteCommandL(): Inactivating " );
  2113                                     else
  2132                                     else
  2114                                         {
  2133                                         {
  2115                                         ret = EExecDeactivateFailed;
  2134                                         ret = EExecDeactivateFailed;
  2116                                         RDEBUG( "CSCOMOAdapter::ExecuteCommandL(): case 6 DeActivate Not found node" );
  2135                                         RDEBUG( "CSCOMOAdapter::ExecuteCommandL(): case 6 DeActivate Not found node" );
  2117                                         }
  2136                                         }
       
  2137 
       
  2138                                     SetSCOMOTargetURIL(*iUriDel, mapping, ret);
       
  2139 						
  2118                                     }
  2140                                     }
  2119                                 else
  2141                                 else
  2120                                     {
  2142                                     {
  2121                                     RDEBUG8_2( "CSCOMOAdapter::ExecuteCommandL(): ASKED NOT SUPPORTED OPERATION '%S'", &mapping );
  2143                                     RDEBUG8_2( "CSCOMOAdapter::ExecuteCommandL(): ASKED NOT SUPPORTED OPERATION '%S'", &mapping );
  2122                                     
  2144                                     
  2133             break;
  2155             break;
  2134             }
  2156             }
  2135         }
  2157         }
  2136     SetStatusL(aStatusRef, ret) ;
  2158     SetStatusL(aStatusRef, ret) ;
  2137     }
  2159     }
       
  2160 
       
  2161 
       
  2162 void CSCOMOAdapter::SetSCOMOTargetURIL(const TDesC8& aURI,
       
  2163         const TDesC8& aMapping,const TError& aErrorStatus)
       
  2164     {
       
  2165 
       
  2166     RDEBUG( "CSCOMOAdapter:: SetSCOMOTargetURI" );
       
  2167 
       
  2168     TInt cnt(NSmlDmURI::NumOfURISegs(aURI));
       
  2169     _LIT8( KNSmlNull, "null" );
       
  2170 
       
  2171     CRepository* cenrep = NULL;
       
  2172     TInt errr(KErrNone);
       
  2173 
       
  2174     TRAP(errr, cenrep = CRepository::NewL( KCRUidDeviceManagementInternalKeys ));
       
  2175 
       
  2176     if (errr == KErrNone)
       
  2177         {
       
  2178 
       
  2179         switch (cnt)
       
  2180             {
       
  2181             case 3:
       
  2182                 {
       
  2183 
       
  2184                 RDEBUG( "CSCOMOAdapter:: SetSCOMOTargetURI case 3" );
       
  2185 
       
  2186                 TInt ASyncSupported = -1;
       
  2187 
       
  2188                 CRepository *repository = CRepository::NewLC(
       
  2189                         KCRUidPrivateApplicationManagementKeys);
       
  2190                 repository->Get(KAsyncEnabled, ASyncSupported);
       
  2191                 CleanupStack::PopAndDestroy();
       
  2192 
       
  2193                 //means accepted for processing set <Target><LOCURI> to NULL.
       
  2194                 if (ASyncSupported)
       
  2195                     {
       
  2196                     RDEBUG( "CSCOMOAdapter:: ASyncSupported" );
       
  2197 
       
  2198                     TInt err1 = cenrep->Set(KNSmlDMSCOMOTargetRef, KNSmlNull);
       
  2199 
       
  2200                     RDEBUG_2( "CSCOMOAdapter:: ASyncSupported %d", err1 );
       
  2201 
       
  2202                     }
       
  2203 
       
  2204                 }
       
  2205                 break;
       
  2206 
       
  2207             case 4:
       
  2208                 {
       
  2209 
       
  2210                 RDEBUG( "CSCOMOAdapter:: SetSCOMOTargetURI case 4" );
       
  2211 
       
  2212                 if (aMapping == KAMRemoveNodeName)
       
  2213                     {
       
  2214 
       
  2215                     if (aErrorStatus == EExecSuccess)
       
  2216                         {
       
  2217                         cenrep->Set(KNSmlDMSCOMOTargetRef, KNSmlNull);
       
  2218                         }
       
  2219                     }
       
  2220 
       
  2221                 if (aMapping == KAMActivateNodeName || aMapping
       
  2222                         == KAMDeActivateNodeName)
       
  2223                     {
       
  2224 
       
  2225                     RDEBUG( "CSCOMOAdapter:: SetSCOMOTargetURI case KAMActivateNodeName or KAMDeActivateNodeName " );
       
  2226 
       
  2227                     if (aErrorStatus == EExecSuccess)
       
  2228                         {
       
  2229                         RDEBUG( "CSCOMOAdapter:: EExecSuccess " );
       
  2230                         _LIT8( KAMInitial, "./" );
       
  2231                         _LIT8( KAMSeparator8, "/" );
       
  2232                         _LIT8( KAMStateValueNodeName, "State" );
       
  2233                         TBuf8<256> targetStateURI;
       
  2234                         targetStateURI.Append(KAMInitial);
       
  2235                         targetStateURI.Append(aURI);
       
  2236 
       
  2237                         targetStateURI.Append(KAMSeparator8);
       
  2238                         targetStateURI.Append(KAMStateValueNodeName);
       
  2239 
       
  2240                         cenrep->Set(KNSmlDMSCOMOTargetRef, targetStateURI);
       
  2241                         RDEBUG( "CSCOMOAdapter:: EExecSuccess End" );
       
  2242                         }
       
  2243                     else
       
  2244                         {
       
  2245                         cenrep->Set(KNSmlDMSCOMOTargetRef, KNSmlNull);
       
  2246                         }
       
  2247 
       
  2248                     }
       
  2249 
       
  2250                 }
       
  2251 
       
  2252                 break;
       
  2253             }
       
  2254 
       
  2255         }
       
  2256 
       
  2257     if (cenrep)
       
  2258         {
       
  2259         delete cenrep;
       
  2260         cenrep = NULL;
       
  2261         }
       
  2262 
       
  2263     }
       
  2264 
  2138 
  2265 
  2139 void CSCOMOAdapter::ASyncReportL(TUint32 aLuid, const TDesC8& aArgument,
  2266 void CSCOMOAdapter::ASyncReportL(TUint32 aLuid, const TDesC8& aArgument,
  2140         const TDownloadTarget aTarget,const TDesC8& aURI)
  2267         const TDownloadTarget aTarget,const TDesC8& aURI)
  2141     {
  2268     {
  2142 
  2269 
  4460         {
  4587         {
  4461         isSupportedMimeType = ETrue;
  4588         isSupportedMimeType = ETrue;
  4462         }
  4589         }
  4463     return isSupportedMimeType;
  4590     return isSupportedMimeType;
  4464     }
  4591     }
       
  4592 
       
  4593 HBufC8* CSCOMOAdapter::GetIdentifierIdL(const TUint32 aluid)
       
  4594     {
       
  4595     RDEBUG( "CSCOMOAdapter::GetIdentifierIdL: const TUint32 aluid, const TDesC8& aTargetUri" );
       
  4596     
       
  4597     _LIT8(KNull, "null");
       
  4598     TDeploymentComponent comp;
       
  4599     HBufC8 *id = NULL;
       
  4600     TInt err(SessionL().DeploymentComponent(aluid, comp) );
       
  4601     RDEBUG( "CSCOMOAdapter::GetIdentifierIdL: Step 1" );
       
  4602     
       
  4603     if(err == KErrNone)
       
  4604         {
       
  4605             RDEBUG( "CSCOMOAdapter::GetIdentifierIdL: Step 1.1" );
       
  4606             if(comp.iState == EDCSDelivered || comp.iState ==EDCSDownload)    
       
  4607                 {
       
  4608                 RDEBUG( "CSCOMOAdapter::GetIdentifierIdL: iState EDCSActive,EDCSInactive" );  
       
  4609                 id = (comp.iPkgID).AllocL();
       
  4610                 }
       
  4611             else if(comp.iState==EDCSActive || comp.iState ==EDCSInactive)
       
  4612                 {
       
  4613                 RDEBUG( "CSCOMOAdapter::GetIdentifierIdL: iState EDCSDelivered,EDCSDownload" ); 
       
  4614                 id = (comp.iId).AllocL();
       
  4615                 }
       
  4616             else
       
  4617                 {
       
  4618                 id = KNull().AllocL();
       
  4619                 }
       
  4620         }
       
  4621     RDEBUG( "CSCOMOAdapter::GetIdentifierIdL: Step 1 end" );
       
  4622     return id;
       
  4623     }
  4465 // End of File
  4624 // End of File
  4466 
  4625