genericopenlibs/openenvcore/backend/src/corebackend/localif.cpp
changeset 34 5fae379060a7
parent 31 ce057bb09d0b
child 45 4b03adbd26ca
child 52 bf6a71c50e42
equal deleted inserted replaced
31:ce057bb09d0b 34:5fae379060a7
   181 		if (err)
   181 		if (err)
   182 			{
   182 			{
   183 			User::Panic(KEstlibInit, err);
   183 			User::Panic(KEstlibInit, err);
   184 			}
   184 			}
   185 
   185 
   186 		iCleanup.StorePtrs(iPrivateHeap, &iFs, &iSs, &iCs, &iSSLock, &iCSLock, &iTzServer);
   186 		iCleanup.StorePtrs(iPrivateHeap, &iFs, &iSs, &iCs, &iSSLock, &iCSLock);
   187 		
   187 		
   188 		// No connection settings by default
   188 		// No connection settings by default
   189 		iDefConnPref = NULL;
   189 		iDefConnPref = NULL;
   190 		}
   190 		}
   191 
   191 
   198 	iSessionPathLock.Close();
   198 	iSessionPathLock.Close();
   199 	// Close the aselect lock
   199 	// Close the aselect lock
   200 	iASelectLock.Close();
   200 	iASelectLock.Close();
   201 	// Close the default connection lock
   201 	// Close the default connection lock
   202 	iDefConnLock.Close();
   202 	iDefConnLock.Close();
       
   203 	
   203 	//close the default RConnection
   204 	//close the default RConnection
   204 	if(iDefConnection.SubSessionHandle() != 0)
   205 	if(iDefConnection.SubSessionHandle() != 0)
       
   206 	    {
   205 		iDefConnection.Close();
   207 		iDefConnection.Close();
       
   208 	    }
   206 
   209 
   207 	RHeap* oHeap = User::SwitchHeap(iPrivateHeap);
   210 	RHeap* oHeap = User::SwitchHeap(iPrivateHeap);
   208 	for (TInt i = 0, count = iTLDInfoList.Count(); i < count; i++ )
   211 	for (TInt i = 0, count = iTLDInfoList.Count(); i < count; i++ )
   209 		{
   212 		{
   210 		iTLDInfoList[i].Close(iPrivateHeap);
   213 		iTLDInfoList[i].Close(iPrivateHeap);
   214 	iTLDInfoList.Close();
   217 	iTLDInfoList.Close();
   215 	// Cleanup the threads serving aselect requests
   218 	// Cleanup the threads serving aselect requests
   216 	int err;
   219 	int err;
   217 	// passing 1 to cancelaselect will kill all the threads serving aselect
   220 	// passing 1 to cancelaselect will kill all the threads serving aselect
   218 	cancelaselect(NULL,err,1);
   221 	cancelaselect(NULL,err,1);
   219 	// Switch to backend heap
   222 
   220 	RHeap* oldHeap = User::SwitchHeap(iPrivateHeap);
       
   221 	// Close the array that maintains aselect request details 
   223 	// Close the array that maintains aselect request details 
   222 	iASelectRequest.Close();
   224 	iASelectRequest.Close();
   223 	//close the RTz server
   225 	//close the RTz connection
   224 	iTzServer.Close();
   226 	iTzServer.Close();
   225 	// Switch back to old heap
   227 
   226 	User::SwitchHeap(oldHeap);
       
   227 
   228 
   228 	if( iDefConnPref )
   229 	if( iDefConnPref )
   229 	    {
   230 	    {
   230 	    switch( iDefConnPref->ExtensionId() )
   231 	    switch( iDefConnPref->ExtensionId() )
   231 	        {
   232 	        {
   232 	        case TConnPref::EConnPrefSnap:
   233 	        case TConnPref::EConnPrefSnap:
   233 	            {
   234 	            {
   234 	            RHeap* oldHeap = User::SwitchHeap(iPrivateHeap);
       
   235 	            delete (TCommSnapPref*)iDefConnPref;
   235 	            delete (TCommSnapPref*)iDefConnPref;
   236 	            // Switch back to old heap
       
   237 	            User::SwitchHeap(oldHeap);
       
   238 	            iDefConnPref = NULL;              
   236 	            iDefConnPref = NULL;              
   239 	            }
   237 	            }
   240 	            break;
   238 	            break;
   241 
   239 
   242 	        case TConnPref::EConnPrefCommDb:
   240 	        case TConnPref::EConnPrefCommDb:
   243 	            {
   241 	            {
   244 	            RHeap* oldHeap = User::SwitchHeap(iPrivateHeap);
       
   245 	            delete (TCommDbConnPref*)iDefConnPref;
   242 	            delete (TCommDbConnPref*)iDefConnPref;
   246 	            // Switch back to old heap
       
   247 	            User::SwitchHeap(oldHeap);
       
   248 	            iDefConnPref = NULL;
   243 	            iDefConnPref = NULL;
   249 	            }
   244 	            }
   250 	            break;              
   245 	            break;              
   251 
   246 
   252 	        default:
   247 	        default:
   255 	            }
   250 	            }
   256 	        }
   251 	        }
   257 	    }
   252 	    }
   258 
   253 
   259 #if (defined SYMBIAN_OE_POSIX_SIGNALS && defined SYMBIAN_OE_LIBRT)
   254 #if (defined SYMBIAN_OE_POSIX_SIGNALS && defined SYMBIAN_OE_LIBRT)
   260 	iTimerOverrunsMutex.Close();
   255 	iTimerOverrunsMutex.Close();	
   261 	iTimerOverruns.Close(); 
   256 	iTimerOverruns.Close(); 
   262 #endif	
   257 #endif	
       
   258 	
       
   259 #if (defined SYMBIAN_OE_POSIX_SIGNALS)
       
   260 	iSigInitWaitMutex.Close();
       
   261 	iSigInitWaitSemaphore.Close();
       
   262 	iBlockedSAMutex.Close();
       
   263 	iSignalWaiterMutex.Close();
       
   264 	iSignalInitSemaphore.Close();
       
   265 #endif
   263 	//close the RpointerArray
   266 	//close the RpointerArray
   264 	iOpenDirList.Close();
   267 	iOpenDirList.Close();
       
   268 	
       
   269 	iSSLock.Close();
       
   270 	iCSLock.Close();
       
   271 	iSignalSession.Close();
       
   272 	iIpcS.Close();
       
   273 		
   265 	User::SwitchHeap(oHeap);
   274 	User::SwitchHeap(oHeap);
   266 	}
   275 	}
   267 
   276 
   268 #ifdef __SYMBIAN_COMPILE_UNUSED__
   277 #ifdef __SYMBIAN_COMPILE_UNUSED__
   269 CLocalSystemInterface& CLocalSystemInterface::Clone()
   278 CLocalSystemInterface& CLocalSystemInterface::Clone()
   298 // -----------------------------------------------------------------------------
   307 // -----------------------------------------------------------------------------
   299 //
   308 //
   300 void CLocalSystemInterface::Exit(int code)
   309 void CLocalSystemInterface::Exit(int code)
   301 	{
   310 	{
   302 #ifdef SYMBIAN_OE_POSIX_SIGNALS
   311 #ifdef SYMBIAN_OE_POSIX_SIGNALS
   303     TRequestStatus status = KRequestPending;
   312     if(iSignalsInitialized)
   304     iSignalHandlerThread.Logon(status);
   313         {
   305 	iSignalLoopRunning = EFalse;
   314         TRequestStatus status = KRequestPending;
   306 	iSignalHandlerThread.RequestSignal();
   315         iSignalHandlerThread.Logon(status);
   307 	User::WaitForRequest(status);
   316         iSignalLoopRunning = EFalse;
       
   317         iSignalHandlerThread.RequestSignal();
       
   318         User::WaitForRequest(status);
       
   319         }
   308 #endif
   320 #endif
   309 	iFids.Close();
   321 	iFids.Close();
   310 	User::SetCritical(User::EProcessPermanent);
   322 	User::SetCritical(User::EProcessPermanent);
   311 	User::Exit(code);
   323 	User::Exit(code);
   312 	}
   324 	}
   332 	{
   344 	{
   333 	return PosixFilesystem::mkdir(iFs, aPath, perms, anErrno);
   345 	return PosixFilesystem::mkdir(iFs, aPath, perms, anErrno);
   334 	}
   346 	}
   335 
   347 
   336 int CLocalSystemInterface::stat (const wchar_t* name, struct stat *st, int& anErrno)
   348 int CLocalSystemInterface::stat (const wchar_t* name, struct stat *st, int& anErrno)
   337     {
   349     {    
   338     const wchar_t* filename;
   350     const wchar_t* filename  = name;
   339     // This needs to be zero terminated
   351     // This needs to be zero terminated
   340     TBuf<KMaxFileName> inputName;
   352     TBuf<KMaxFileName> inputName;
   341     TUint pathAtt = 0;
   353     TUint pathAtt = 0;
   342     TInt err = GetFullFile(inputName,(const TText16*)name,iFs);
   354     TInt err = GetFullFile(inputName,(const TText16*)name,iFs);
   343     if( !err )
   355     if( !err )
   345         TInt err = iFs.Att(inputName,pathAtt);
   357         TInt err = iFs.Att(inputName,pathAtt);
   346         if ( (err == KErrNone) && (pathAtt & KEntryAttDir) )
   358         if ( (err == KErrNone) && (pathAtt & KEntryAttDir) )
   347             {                    
   359             {                    
   348             inputName.Append(_L("\\"));            
   360             inputName.Append(_L("\\"));            
   349             }
   361             }
   350         filename = (wchar_t*)inputName.PtrZ();
       
   351         }
       
   352     // try to stat anyway
       
   353     else
       
   354         {
       
   355         inputName.Copy((const TText16*)name);
       
   356         filename = (wchar_t*)inputName.PtrZ();
   362         filename = (wchar_t*)inputName.PtrZ();
   357         }
   363         }
   358     TSpecialFileType fileType;
   364     TSpecialFileType fileType;
   359     struct SLinkInfo enBuf;
   365     struct SLinkInfo enBuf;
   360     // Check the type of file
   366     // Check the type of file