bluetooth/btlogger/btsnoophcilogger/src/hciloggerbtsnoop.cpp
branchRCL_3
changeset 21 14e240312f6f
parent 0 29b1cd4cb562
equal deleted inserted replaced
18:1f10b9300be6 21:14e240312f6f
     1 // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
     1 // Copyright (c) 2004-2010 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
    64 	{
    64 	{
    65 	iFileCloseTimer = CHCILoggerFileCloseTimer::NewL(iLogFile);
    65 	iFileCloseTimer = CHCILoggerFileCloseTimer::NewL(iLogFile);
    66 	for (TInt i = 0; i <= TInt(KHCILoggerControllerToHost | KHCILoggerCommandOrEvent); i++)
    66 	for (TInt i = 0; i <= TInt(KHCILoggerControllerToHost | KHCILoggerCommandOrEvent); i++)
    67 		{
    67 		{
    68 		CHCILoggerBufferedFrame* temp = new(ELeave) CHCILoggerBufferedFrame;
    68 		CHCILoggerBufferedFrame* temp = new(ELeave) CHCILoggerBufferedFrame;
    69 		iBuffers.Append(temp); // array now "owns" temp
    69 		CleanupStack::PushL(temp);
       
    70 		iBuffers.AppendL(temp); // array now "owns" temp
       
    71 		CleanupStack::Pop(temp);
    70 		}
    72 		}
    71 	}
    73 	}
    72 
    74 
    73 void CHCILoggerBtSnoop::DoInitialise(TInt aType)
    75 void CHCILoggerBtSnoop::DoInitialise(TInt aType)
    74 	{
    76 	{
    75 	iDatalinkType = aType;
    77 	iDatalinkType = aType;
    76 	iFs.Connect();
       
    77 	OpenFile(); // if it fails, just ignore it - try later when writing
    78 	OpenFile(); // if it fails, just ignore it - try later when writing
    78 	}
    79 	}
    79 
    80 
    80 CHCILoggerBtSnoop::~CHCILoggerBtSnoop()
    81 CHCILoggerBtSnoop::~CHCILoggerBtSnoop()
    81 	{
    82 	{
   147 	default:
   148 	default:
   148 		fileName.Set(KSnoopLogFileDefault);
   149 		fileName.Set(KSnoopLogFileDefault);
   149 		break;
   150 		break;
   150 		};
   151 		};
   151 
   152 
   152 	TInt err = iLogFile.Open(iFs, fileName, EFileWrite | EFileShareAny);
   153 	TInt err = KErrNone;
       
   154 
       
   155 	if (!iFs.Handle())
       
   156 	    {
       
   157         err = iFs.Connect();
       
   158         if (err)
       
   159             {
       
   160             return err;
       
   161             }
       
   162 	    }
       
   163 
       
   164 	err = iLogFile.Open(iFs, fileName, EFileWrite | EFileShareAny);
   153 	if (err == KErrNotFound)
   165 	if (err == KErrNotFound)
   154 		{ // if it doesn't already exist, create it
   166 		{ // if it doesn't already exist, create it
   155 		//Note that the potential KErrPathNotFound error is deliberately not handled, 
   167 		//Note that the potential KErrPathNotFound error is deliberately not handled, 
   156 		//since the shared\hcilogger directory not being present is used to indicate 
   168 		//since the shared\hcilogger directory not being present is used to indicate 
   157 		//that logging is not desired.
   169 		//that logging is not desired.