sysanadatacapture/piprofiler/piprofiler/engine/src/ProfilerEngine.cpp
author Matti Laitinen <matti.t.laitinen@nokia.com>
Thu, 11 Feb 2010 15:52:57 +0200
changeset 1 3ff3fecb12fe
permissions -rw-r--r--
Add initial version of PI Profiler under EPL
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
     1
/*
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
     2
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
     3
* All rights reserved.
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
     4
* This component and the accompanying materials are made available
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
     6
* which accompanies this distribution, and is available
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
     8
*
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
     9
* Initial Contributors:
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    11
*
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    12
* Contributors:
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    13
*
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    14
* Description:  
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    15
*
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    16
*/
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    17
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    18
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    19
#include <e32cons.h>
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    20
#include <e32base.h>
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    21
#include <f32file.h>
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    22
#include <c32comm.h>
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    23
#include <s32file.h>
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    24
#include <pathinfo.h>
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    25
#include <s32mem.h>
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    26
#include <bautils.h>
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    27
#include <sysutil.h>
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    28
#include <piprofiler/ProfilerConfig.h>
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    29
#include "ProfilerEngine.h"
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    30
#include <piprofiler/ProfilerTraces.h>
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    31
#include <piprofiler/EngineUIDs.h>
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    32
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    33
// properties
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    34
const TUid KEngineStatusPropertyCat={0x2001E5AD};
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    35
enum TEnginePropertyKeys
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    36
	{
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    37
	EProfilerEngineStatus = 8,
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    38
	EProfilerErrorStatus
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    39
	};
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    40
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    41
static _LIT_SECURITY_POLICY_PASS( KAllowAllPolicy );
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    42
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    43
// CONSTANTS 
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    44
const TInt KStreamBufferSize = 32768;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    45
const TInt KSavedLineCount = 64;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    46
const TInt KFileNameBufSize = 128;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    47
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    48
// LITERALS
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    49
_LIT8(KGenericTraceOutput, "output_type");
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    50
_LIT8(KGenericTraceFilePrefix, "file_prefix");
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    51
_LIT8(KGenericTraceFileSaveDrive, "save_file_location");
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    52
_LIT8(KEquals, "=");
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    53
_LIT8(KNewLineSeparator, "\n");
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    54
_LIT8(KProfilerVersionTag, "version");
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    55
_LIT8(KEndMark, "[end]");
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    56
_LIT8(KOutputToDebugOutput, "debug_output");
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    57
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    58
/** 
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    59
 * 
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    60
 * The controller class used to provide the Profiler functions. 
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    61
 * This runs as a server in the engine thread
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    62
 * 
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    63
 */
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    64
class CPServer : public CServer2, public MProfilerController
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    65
    {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    66
public:
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    67
    static MProfilerController*		NewL(TInt aPriority, MProfilerEngine& aEngine);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    68
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    69
private:
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    70
                        CPServer(TInt aPriority, MProfilerEngine& aEngine);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    71
    void				Release();
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    72
    CSession2*			NewSessionL(const TVersion& aVersion,const RMessage2& aMessage) const;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    73
    };
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    74
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    75
// The session class used by the server controller
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    76
class CPSession : public CSession2
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    77
    {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    78
private:
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    79
    inline const CPServer&	Server() const;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    80
    void					ServiceL(const RMessage2& aMessage);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    81
    };
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    82
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    83
/*
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    84
 *
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    85
 *	CProfiler class implementation
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    86
 *
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    87
 */
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    88
// --------------------------------------------------------------------------------------------
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    89
CProfiler* CProfiler::NewLC(const TDesC& aSettingsFile)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    90
    {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    91
	CProfiler* self = new(ELeave) CProfiler(aSettingsFile);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    92
	CleanupStack::PushL(self);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    93
	self->ConstructL();
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    94
	return self;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    95
    }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    96
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    97
// --------------------------------------------------------------------------------------------
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    98
CProfiler::CProfiler(const TDesC& aSettingsFile) : 
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    99
    iSettingsFileLocation(aSettingsFile)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   100
	{
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   101
	// define property for Profiler Engine status, UI may read it for control purposes
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   102
	if ( RProperty::Define(KEngineStatusPropertyCat, 
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   103
	        EProfilerEngineStatus, 
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   104
	        RProperty::EInt, 
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   105
	        KAllowAllPolicy, 
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   106
	        KAllowAllPolicy, 
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   107
	        0) != KErrAlreadyExists )
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   108
	    {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   109
	    LOGTEXT(_L("CProfiler::CProfiler - status property already defined"));
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   110
	    }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   111
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   112
	if ( RProperty::Define(KEngineStatusPropertyCat, 
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   113
	        EProfilerErrorStatus, 
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   114
            RProperty::EInt, 
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   115
            KAllowAllPolicy, 
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   116
            KAllowAllPolicy, 
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   117
            0) != KErrAlreadyExists )
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   118
        {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   119
        LOGTEXT(_L("CProfiler::CProfiler - status property already defined"));
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   120
        }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   121
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   122
	// attach to own property
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   123
	iEngineStatus.Attach(KEngineStatusPropertyCat, EProfilerEngineStatus);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   124
	// set status idle
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   125
	iEngineStatus.Set(KEngineStatusPropertyCat, EProfilerEngineStatus, RProfiler::EIdle);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   126
	
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   127
    // attach to own property
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   128
    iUpdateStatus.Attach(KEngineStatusPropertyCat, EProfilerErrorStatus);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   129
    // set status idle
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   130
    iUpdateStatus.Set(KEngineStatusPropertyCat, EProfilerErrorStatus, EFalse);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   131
	}
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   132
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   133
// --------------------------------------------------------------------------------------------
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   134
CProfiler::~CProfiler()
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   135
    {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   136
	LOGTEXT(_L("CProfiler::~CProfiler - Enter"));
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   137
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   138
	// delete error checker
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   139
    if(iErrorChecker)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   140
        {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   141
        iErrorChecker->Cancel();
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   142
        delete iErrorChecker;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   143
        iErrorChecker = NULL;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   144
        }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   145
	
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   146
	// delete settings array
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   147
	if(iDefaultSamplerAttributesArray)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   148
	    {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   149
	    iDefaultSamplerAttributesArray->Reset();
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   150
	    delete iDefaultSamplerAttributesArray;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   151
	    iDefaultSamplerAttributesArray = NULL;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   152
	    }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   153
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   154
    // delete settings file raw line array
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   155
    if(iSavedLineArray)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   156
        {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   157
        iSavedLineArray->Reset();
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   158
        delete iSavedLineArray;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   159
        iSavedLineArray = NULL;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   160
        }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   161
		
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   162
	// delete sampler controller, cleans up the sampler plugin instances
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   163
	if(iSamplerHandler)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   164
		{
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   165
		delete iSamplerHandler;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   166
		iSamplerHandler = NULL;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   167
		}
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   168
	// delete writer controller, cleans up the writer plugin instances
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   169
	if(iWriterHandler)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   170
		{
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   171
		delete iWriterHandler;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   172
		iWriterHandler = NULL;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   173
		}
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   174
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   175
    // delete user side sampler stream 
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   176
	if(iUserStream)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   177
		{
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   178
		delete iUserStream;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   179
		iUserStream = NULL;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   180
		}
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   181
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   182
	// close engine status property
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   183
	iEngineStatus.Close();
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   184
	if (RProperty::Delete(KEngineStatusPropertyCat, EProfilerEngineStatus) != KErrNotFound)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   185
	    {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   186
	    LOGTEXT(_L("CProfiler::~CProfiler - cannot close status property"));
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   187
	    }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   188
    // close engine update property
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   189
    iUpdateStatus.Close();
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   190
    if (RProperty::Delete(KEngineStatusPropertyCat, EProfilerErrorStatus) != KErrNotFound)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   191
        {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   192
        LOGTEXT(_L("CProfiler::~CProfiler - cannot close update property"));
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   193
        }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   194
    
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   195
    // close server process
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   196
    if (iServer)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   197
        {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   198
        LOGTEXT(_L("CProfiler::~CProfiler - Releasing server"));
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   199
        iServer->Release();
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   200
        }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   201
    
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   202
	LOGTEXT(_L("CProfiler::~CProfiler - Finished"));
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   203
    }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   204
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   205
// --------------------------------------------------------------------------------------------
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   206
void CProfiler::ConstructL()
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   207
    {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   208
	LOGTEXT(_L("CProfiler::ConstructL - Enter"));
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   209
	TInt err(0);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   210
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   211
    // create new sampler stream instance
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   212
    iUserStream = CProfilerSampleStream::NewL(KStreamBufferSize);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   213
    if(!iUserStream)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   214
        {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   215
        LOGTEXT(_L("Profiler engine cannot reserve memory"));
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   216
        User::Leave(KErrCancel);   // operation cancelled
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   217
        }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   218
	
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   219
    // engine status checker
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   220
    iErrorChecker = CProfilerErrorChecker::NewL();
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   221
    iErrorChecker->SetObserver(this);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   222
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   223
	// create and initiate plug-in controller instances
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   224
    iSamplerHandler = CSamplerController::NewL(*iUserStream);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   225
    iWriterHandler = CWriterController::NewL(*iUserStream);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   226
    
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   227
    iWriterHandler->InitialiseWriterListL();
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   228
    
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   229
    // set engine as an observer to sampler controller to get the notification of plugin load has ended
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   230
    iSamplerHandler->SetObserver(this);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   231
    
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   232
    // default settings from sampler plugins, maximum 20 sampler plugins
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   233
    iDefaultSamplerAttributesArray = new(ELeave) CArrayFixFlat<TSamplerAttributes>(20); 
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   234
    
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   235
    // set profiler status to initializing
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   236
    iState = RProfiler::EInitializing;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   237
	iEngineStatus.Set(RProfiler::EInitializing);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   238
	
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   239
	// set default general settings, will be overdriven if changed in settings file
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   240
	iGeneralAttributes.iTraceOutput.Copy(KDefaultTraceOutput);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   241
	iGeneralAttributes.iTraceFilePrefix.Copy(KDefaultTraceFilePrefix);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   242
	iGeneralAttributes.iSaveFileDrive.Copy(KDefaultTraceFileSaveDrive);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   243
	
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   244
	RThread me;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   245
	
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   246
	me.SetPriority(EPriorityRealTime);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   247
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   248
	err = KErrGeneral;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   249
	TInt count = 0;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   250
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   251
	while(err != KErrNone && count < 30)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   252
	    {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   253
		err = User::RenameThread(KProfilerName);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   254
		if(err != KErrNone)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   255
		    {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   256
			User::Leave(err);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   257
		    }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   258
		else break;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   259
	    }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   260
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   261
	if(err != KErrNone) 
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   262
	    {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   263
		User::Leave(err);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   264
	    }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   265
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   266
	// set settings file loading preferences
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   267
	iSettingsFileLoaded = EFalse;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   268
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   269
	// change status property to idle since initialization successfull
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   270
	iState = RProfiler::EIdle;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   271
	if( iEngineStatus.Set((TInt)RProfiler::EIdle) != KErrNone )
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   272
	    {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   273
	    LOGTEXT(_L("CProfiler::ConstructL - engine status property change failed"));
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   274
	    }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   275
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   276
    if( iUpdateStatus.Set(EFalse) != KErrNone )
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   277
        {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   278
        LOGTEXT(_L("CProfiler::ConstructL - engine status property change failed"));
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   279
        }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   280
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   281
	// create a server instance for clients to communicate with 
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   282
	iServer = CPServer::NewL(10,*this);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   283
	
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   284
	// close the handle 
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   285
	me.Close();
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   286
	
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   287
	LOGTEXT(_L("CProfiler::ConstructL - Exit"));
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   288
	
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   289
    }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   290
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   291
CProfilerSampleStream* CProfiler::GetSamplerStream()
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   292
    {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   293
    return iUserStream;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   294
    }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   295
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   296
void CProfiler::HandleSamplerControllerReadyL()
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   297
    {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   298
    // load settings
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   299
    // check if settings file already loaded
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   300
    if(!iSettingsFileLoaded)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   301
        {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   302
        // load default settings file
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   303
        LoadSettingsL();
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   304
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   305
        iSettingsFileLoaded = ETrue;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   306
        }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   307
    
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   308
    // notify engine's launcher(UI or PIProfilerLauncher) to continue launch
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   309
    RProcess::Rendezvous(KErrNone); 
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   310
    }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   311
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   312
void CProfiler::NotifyRequesterForSettingsUpdate()
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   313
    {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   314
    // set update status P&S property true => update needed on UI side
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   315
    iUpdateStatus.Set(ETrue);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   316
    }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   317
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   318
void CProfiler::HandleProfilerErrorChangeL(TInt aError)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   319
    {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   320
    LOGSTRING2("CProfiler::HandleProfilerErrorChangeL() - error received, %d", aError);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   321
    
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   322
    // check if profiler running
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   323
    if(iState == RProfiler::ERunning)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   324
        {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   325
        // stop profiler if error occurred during the trace
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   326
        iEngineStatus.Set(aError);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   327
        
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   328
        // stop samplers, NOTE! Writer plugins not stopped since 
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   329
        iSamplerHandler->StopSamplerPlugins();
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   330
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   331
        // stop debug output plugin and write the rest of the trace data to output
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   332
        if(iGeneralAttributes.iTraceOutput.CompareF(KOutputToDebugOutput) == 0)   
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   333
            {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   334
            // write the rest of trace data only if debug output selected
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   335
            iWriterHandler->StopSelectedPlugin();
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   336
            }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   337
        LOGSTRING2("CProfiler::HandleProfilerErrorChangeL - sampling stopped, going to state %d", RProfiler::EIdle);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   338
        }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   339
    }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   340
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   341
// ----------------------------------------------------------------------------
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   342
// Gets a value from settings file for certain attribute.
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   343
// ----------------------------------------------------------------------------
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   344
void CProfiler::DoGetValueFromSettingsArray(CDesC8ArrayFlat* aLineArray, const TDesC8& aAttribute, TDes8& aValue)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   345
    {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   346
    LOGTEXT(_L("CProfiler::DoGetValueFromSettingsFile()"));
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   347
    _LIT8(KSettingItemSeparator, "=");
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   348
    
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   349
    // read a line of given array
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   350
    for (TInt i=0; i<aLineArray->MdcaCount(); i++)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   351
        {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   352
        // check if this line has a separator
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   353
        TInt sepPos = aLineArray->MdcaPoint(i).Find(KSettingItemSeparator);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   354
        if (sepPos > 0)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   355
            {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   356
            // check that the element matches
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   357
            if (aLineArray->MdcaPoint(i).Left(sepPos).CompareF(aAttribute) == 0)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   358
                {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   359
                // get the value
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   360
                aValue.Copy(aLineArray->MdcaPoint(i).Right(aLineArray->MdcaPoint(i).Length()-sepPos-1));
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   361
                break;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   362
                }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   363
            }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   364
        }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   365
    }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   366
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   367
// --------------------------------------------------------------------------------------------
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   368
TInt CProfiler::GetSamplerAttributesL(const RMessage2& aMessage)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   369
    {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   370
    TInt err(KErrNone);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   371
    TInt pos(0);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   372
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   373
    // get sampler count
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   374
    TInt count(iDefaultSamplerAttributesArray->Count());
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   375
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   376
    // write each of the default sampler plugin setting attributes over client-server session 
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   377
    for (TInt i(0); i<count; ++i)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   378
       {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   379
       TSamplerAttributes attr = iDefaultSamplerAttributesArray->At(i);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   380
       TPckgC<TSamplerAttributes> attrPckg(attr);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   381
       
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   382
       // write a TSamplerAttributes container at a time
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   383
       aMessage.WriteL(0, attrPckg, pos);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   384
       pos += attrPckg.Length();
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   385
       }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   386
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   387
    aMessage.Complete(err);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   388
    return err;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   389
    }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   390
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   391
// --------------------------------------------------------------------------------------------
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   392
TInt CProfiler::SetSamplerAttributesL(const RMessage2& aMessage)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   393
    {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   394
    TSamplerAttributes attr;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   395
    TPckg<TSamplerAttributes> inAttr(attr);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   396
    
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   397
    TInt err = aMessage.Read(0, inAttr, 0);    
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   398
    
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   399
    // apply the changes directly to a plugin
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   400
    iSamplerHandler->SetSamplerSettingsL(attr.iUid, attr);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   401
    
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   402
    aMessage.Complete(err);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   403
    return err;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   404
    }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   405
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   406
// --------------------------------------------------------------------------------------------
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   407
TInt CProfiler::GetGeneralAttributesL(const RMessage2& aMessage)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   408
    {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   409
    TPckgBuf<TGeneralAttributes> generalSettings( iGeneralAttributes );
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   410
    
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   411
    // write general attributes over client-server session
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   412
    TInt err = aMessage.Write(0, generalSettings);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   413
    
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   414
    aMessage.Complete(err);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   415
    return err;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   416
    }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   417
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   418
// --------------------------------------------------------------------------------------------
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   419
TInt CProfiler::SetGeneralAttributesL(const RMessage2& aMessage)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   420
    {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   421
    // read the general settings from message
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   422
    TGeneralAttributes attr;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   423
    TPckg<TGeneralAttributes> inPckg(attr);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   424
    TInt err = aMessage.Read(0, inPckg, 0);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   425
    
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   426
    // copy to the general attributes
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   427
    iGeneralAttributes.iSaveFileDrive.Copy(attr.iSaveFileDrive);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   428
    iGeneralAttributes.iTraceFilePrefix.Copy(attr.iTraceFilePrefix);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   429
    iGeneralAttributes.iTraceOutput.Copy(attr.iTraceOutput);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   430
    
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   431
    aMessage.Complete(err);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   432
    return err;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   433
    }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   434
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   435
TInt CProfiler::GetSamplerAttributeCountL(const RMessage2& aMessage)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   436
    {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   437
    // get the plugin array count and wrap it to TPckgBuf<>
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   438
    TPckgBuf<TInt> attributeCount(iDefaultSamplerAttributesArray->Count());
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   439
    
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   440
    // write general attributes over client-server session
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   441
    TInt err = aMessage.Write(0, attributeCount);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   442
    
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   443
    aMessage.Complete(err);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   444
    return err;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   445
    }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   446
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   447
TInt CProfiler::RefreshStatus(const RMessage2& aMessage)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   448
    {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   449
    TInt err(KErrNone);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   450
    
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   451
    // update profiler status for requester
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   452
    iEngineStatus.Set(iState);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   453
    
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   454
    aMessage.Complete(err);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   455
    return err;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   456
    }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   457
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   458
// --------------------------------------------------------------------------------------------
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   459
TInt CProfiler::LoadSettingsL(/*const TDesC& configFile*/)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   460
    {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   461
	RFs fileServer;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   462
	RFile file;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   463
	TInt err(KErrNone);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   464
    
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   465
	// connect to file server 
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   466
	err = fileServer.Connect();
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   467
	
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   468
	// check if file server can be connected
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   469
	if (err != KErrNone)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   470
	    {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   471
		// file server couldn't be connected
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   472
		return KErrGeneral;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   473
	    }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   474
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   475
	// check if settings file location length reasonable
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   476
	if ( iSettingsFileLocation.CompareF(KNullDesC) == 0 )
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   477
	    {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   478
		// open the file with the default path and name
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   479
		TBuf<256> pathAndName;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   480
		pathAndName.Append(PathInfo::PhoneMemoryRootPath());
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   481
		pathAndName.Append(KProfilerSettingsFileName);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   482
		iSettingsFileLocation.Copy(pathAndName);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   483
		LOGTEXT(_L("CProfiler::LoadSettings - Opening settings file with name (with the default path)"));
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   484
		LOGTEXT(pathAndName);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   485
	    }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   486
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   487
    // open the file with the given path and name
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   488
    err = file.Open(fileServer,iSettingsFileLocation,EFileRead);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   489
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   490
	
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   491
	// check if RFile::Open() returned error
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   492
	if (err != KErrNone)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   493
	    {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   494
		// file couldn't be opened
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   495
		LOGTEXT(_L("CProfiler::LoadSettings - Failed to open settings, using default"));
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   496
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   497
		// check if settings already loaded
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   498
		if(iDefaultSamplerAttributesArray->Count() > 0)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   499
		    {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   500
		    // reset default settings array
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   501
		    iDefaultSamplerAttributesArray->Reset();
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   502
		    }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   503
		
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   504
		// load default settings, instead of settings file ones
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   505
		iSamplerHandler->GetSamplerAttributesL(iDefaultSamplerAttributesArray);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   506
		
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   507
		fileServer.Close();
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   508
		return KErrNone;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   509
	    }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   510
	
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   511
	// initialize iSavedLineArray, initial settings file lines 64
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   512
	if(iSavedLineArray)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   513
	    {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   514
        iSavedLineArray->Reset();
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   515
	    }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   516
	else
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   517
	    {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   518
        iSavedLineArray = new (ELeave) CDesC8ArrayFlat(KSavedLineCount);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   519
	    }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   520
	
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   521
	iSavedLinesCount = KSavedLineCount;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   522
	
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   523
    // get size of the file
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   524
    TInt fileSize(0);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   525
    err = file.Size(fileSize);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   526
    // check if an error occurred reading the file size
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   527
    if(err != KErrNone)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   528
        {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   529
        return KErrGeneral; // could not find the size
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   530
        }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   531
        
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   532
    // sanity check for the file size
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   533
    if (fileSize < 3 || fileSize > 20000)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   534
        {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   535
        fileSize = KSettingsFileSize;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   536
        return KErrNotSupported;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   537
        }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   538
    
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   539
	// read the contents of the file to buffer. 
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   540
	iSettingsBuffer.Zero();
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   541
	file.Read(iSettingsBuffer, fileSize);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   542
	file.Close();
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   543
	fileServer.Close();
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   544
	LOGSTRING2("CProfiler::LoadSettings: read %d bytes",iSettingsBuffer.Length());
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   545
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   546
	// append end mark "[end]"
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   547
    iSettingsBuffer.Append(KEndMark);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   548
	// force an ending newline
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   549
	iSettingsBuffer.Append('\n');
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   550
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   551
	// next fill the saved settings array (CDesC8ArrayFlat) for further comparison with changes and default values
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   552
    TBuf8<384> tmpBuf;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   553
    TInt lineCount(0);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   554
    TBool commentFound(EFalse);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   555
    for (TInt i(0); i<iSettingsBuffer.Length(); i++)  // loop all chars
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   556
        {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   557
        // if new line char found, create a new text line
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   558
        if (iSettingsBuffer[i]=='\r' || iSettingsBuffer[i]=='\n')
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   559
            {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   560
            // check if collected string has reasonable length
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   561
            if (tmpBuf.Length() > 0)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   562
                {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   563
                // remove extra spaces
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   564
                tmpBuf.TrimAll();
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   565
                // check if the size of the array too small
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   566
                if(lineCount >= iSavedLinesCount)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   567
                    {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   568
                    iSavedLineArray->ExpandL(20);   // expand by 20 lines
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   569
                    iSavedLinesCount += 20;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   570
                    }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   571
                iSavedLineArray->AppendL(tmpBuf);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   572
                tmpBuf.Copy(KNullDesC8);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   573
                lineCount++;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   574
                }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   575
            commentFound = EFalse;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   576
            }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   577
        // check if comment mark ';' is found on the line, skip the rest of the line
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   578
        else if(iSettingsBuffer[i]==';')
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   579
            {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   580
            commentFound = ETrue;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   581
            }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   582
        // otherwise append a char to the temp line buffer if it is a wanted ASCII char
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   583
        else if (iSettingsBuffer[i]>=32 && iSettingsBuffer[i]<=127 && !commentFound)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   584
            {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   585
            tmpBuf.Append(iSettingsBuffer[i]);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   586
            }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   587
        }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   588
    
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   589
    // empty tmpBuf
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   590
    tmpBuf.Copy(KNullDesC8);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   591
    // check settings file version
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   592
    DoGetValueFromSettingsArray(iSavedLineArray, KProfilerVersionTag, tmpBuf); 
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   593
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   594
    TBuf8<32> version;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   595
    version.Copy(PROFILER_VERSION_SHORT);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   596
    
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   597
    // check if settings file version is 
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   598
    if(tmpBuf.CompareF(version) >= 0)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   599
        {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   600
        // update general attributes
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   601
        UpdateSavedGeneralAttributes(iSavedLineArray);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   602
        
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   603
        // update settings to sampler plugins and save the attributes to default array
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   604
        iSamplerHandler->UpdateSavedSamplerAttributesL(iSavedLineArray, iDefaultSamplerAttributesArray);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   605
        }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   606
    else
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   607
        {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   608
        // check if settings already loaded
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   609
        if(iDefaultSamplerAttributesArray)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   610
            {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   611
            // reset default settings array
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   612
            iDefaultSamplerAttributesArray->Reset();
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   613
            }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   614
        // get the default settings if settings file version too old
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   615
        iSamplerHandler->GetSamplerAttributesL(iDefaultSamplerAttributesArray);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   616
        }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   617
    
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   618
	return err; 
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   619
    }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   620
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   621
// --------------------------------------------------------------------------------------------
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   622
void CProfiler::UpdateSavedGeneralAttributes(CDesC8ArrayFlat* aSavedAttributes)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   623
    {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   624
    // get saved general settings
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   625
    DoGetValueFromSettingsArray(aSavedAttributes, KGenericTraceOutput, iGeneralAttributes.iTraceOutput);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   626
    DoGetValueFromSettingsArray(aSavedAttributes, KGenericTraceFilePrefix, iGeneralAttributes.iTraceFilePrefix);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   627
    DoGetValueFromSettingsArray(aSavedAttributes, KGenericTraceFileSaveDrive, iGeneralAttributes.iSaveFileDrive);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   628
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   629
    }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   630
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   631
TBool CProfiler::CheckLocationSanity(RFs& fs, const TDesC8& aLocation)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   632
    {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   633
    TBool ret(EFalse);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   634
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   635
    TBuf<32> drive;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   636
    
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   637
    CnvUtfConverter::ConvertToUnicodeFromUtf8(drive, aLocation);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   638
    
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   639
    // check that aLocation contains some of reasonable drives 
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   640
    if(aLocation.Find(_L8("C:\\")) != KErrNotFound)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   641
        {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   642
        if(BaflUtils::CheckFolder(fs, drive) == KErrNone && 
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   643
            !SysUtil::DiskSpaceBelowCriticalLevelL(&fs, 0, EDriveC))
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   644
            ret = ETrue;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   645
        }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   646
    else if(aLocation.Find(_L8("D:\\")) != KErrNotFound) 
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   647
        {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   648
        if(BaflUtils::CheckFolder(fs, drive) == KErrNone && 
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   649
            !SysUtil::DiskSpaceBelowCriticalLevelL(&fs, 0, EDriveD))
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   650
            ret = ETrue;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   651
        }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   652
    else if(aLocation.Find(_L8("E:\\")) != KErrNotFound) 
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   653
        {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   654
        if(BaflUtils::CheckFolder(fs, drive) == KErrNone && 
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   655
            !SysUtil::DiskSpaceBelowCriticalLevelL(&fs, 0, EDriveE))
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   656
            ret = ETrue;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   657
        }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   658
    else if(aLocation.Find(_L8("F:\\")) != KErrNotFound) 
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   659
        {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   660
        if(BaflUtils::CheckFolder(fs, drive) == KErrNone && 
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   661
            !SysUtil::DiskSpaceBelowCriticalLevelL(&fs, 0, EDriveF))
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   662
            ret = ETrue;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   663
        }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   664
    else if(aLocation.Find(_L8("G:\\")) != KErrNotFound) 
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   665
        {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   666
        if(BaflUtils::CheckFolder(fs, drive) == KErrNone && 
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   667
            !SysUtil::DiskSpaceBelowCriticalLevelL(&fs, 0, EDriveG))
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   668
            ret = ETrue;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   669
        }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   670
    else if(aLocation.Find(_L8("H:\\")) != KErrNotFound ) 
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   671
        {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   672
        if(BaflUtils::CheckFolder(fs, drive) == KErrNone && 
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   673
            !SysUtil::DiskSpaceBelowCriticalLevelL(&fs, 0, EDriveH))
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   674
            ret = ETrue;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   675
        }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   676
    else if(aLocation.Find(_L8("I:\\")) != KErrNotFound) 
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   677
        {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   678
        if(BaflUtils::CheckFolder(fs, drive) == KErrNone && 
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   679
                !SysUtil::DiskSpaceBelowCriticalLevelL(&fs, 0, EDriveI))
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   680
            ret = ETrue;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   681
        }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   682
    else
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   683
        {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   684
        // otherwise return false
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   685
        ret = EFalse;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   686
        }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   687
    
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   688
    return ret;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   689
    }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   690
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   691
TInt CProfiler::HandleGeneralSettingsChange()
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   692
    {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   693
    // local literals
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   694
    _LIT8(KBackSlash, "\\");
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   695
    _LIT8(KTraceFileExtension, ".dat");
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   696
    
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   697
    TBuf8<KFileNameBufSize> fileNameBuf;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   698
    TBuf8<10> number;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   699
    TInt result(0);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   700
    TInt index(1);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   701
    TInt hashLocation(0);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   702
    TParse parse;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   703
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   704
    // check if plugin writer changed
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   705
    if(iGeneralAttributes.iTraceOutput.CompareF(KOutputToDebugOutput) == 0)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   706
        {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   707
        iWriterHandler->SetPluginActive( KDebOutWriterPluginUid, EWriterPluginEnabled );
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   708
        }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   709
    else
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   710
        {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   711
        RFs fileServer;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   712
        RFile file;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   713
        
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   714
        // connect to the file server
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   715
        result = fileServer.Connect();
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   716
        if(result == KErrNone)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   717
            {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   718
            // disk writer plugin will be activated
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   719
            iWriterHandler->SetPluginActive( KDiskWriterPluginUid, EWriterPluginEnabled );
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   720
            
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   721
            // fix the trace data file location as well
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   722
            iTotalPrefix.Zero();
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   723
            iTotalPrefix.Append(iGeneralAttributes.iSaveFileDrive);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   724
            
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   725
            // check that trace file location sane
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   726
            if(!CProfiler::CheckLocationSanity(fileServer, iTotalPrefix))
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   727
                {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   728
//                // empty location data
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   729
//                iTotalPrefix.Zero();
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   730
//                // use default location instead
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   731
//                iTotalPrefix.Append(KProfilerDefaultDrive);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   732
                fileServer.Close();
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   733
                return KErrPathNotFound;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   734
                }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   735
            
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   736
            // remove extra spaces
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   737
            iTotalPrefix.TrimAll();
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   738
            
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   739
            // check if trace data location directory => string ends with '\' 
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   740
            if(iTotalPrefix.LocateReverse('\\') != iTotalPrefix.Length()-1 && 
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   741
                    iTotalPrefix.LocateReverse('/') != iTotalPrefix.Length()-1)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   742
                {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   743
                // append backslash to end
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   744
                iTotalPrefix.Append(KBackSlash);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   745
                }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   746
            
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   747
            // append trace file name prefix e.g. PIProfiler_#
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   748
            iTotalPrefix.Append(iGeneralAttributes.iTraceFilePrefix);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   749
    
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   750
            // locate '#' mark for finding the next free trace file name, e.g. E:\data\PIProfiler_4.dat
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   751
            hashLocation = iTotalPrefix.Locate('#');
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   752
            if( hashLocation == KErrNotFound )
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   753
                {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   754
                // append simply at the end of the trace file prefix, no need to inform user
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   755
                iTotalPrefix.Append('#');
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   756
                // get new hash mark location
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   757
                hashLocation = iTotalPrefix.Locate('#');
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   758
                }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   759
    
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   760
            // add the file extension
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   761
            iTotalPrefix.Append(KTraceFileExtension);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   762
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   763
            // search for files with different indices
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   764
            // until a free filename is found
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   765
            while(result != KErrNotFound)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   766
                {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   767
                fileNameBuf.Zero();
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   768
                // start with the original prefix
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   769
                fileNameBuf.Append(iTotalPrefix);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   770
                // convert the number to a descriptor
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   771
                number.Num(index);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   772
                // replace the hashmark with the real number
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   773
                fileNameBuf.Replace(hashLocation,1,number);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   774
                
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   775
                // make a copy to the iFileNameStream descriptor
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   776
                iFileNameStream.Zero();
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   777
                CnvUtfConverter::ConvertToUnicodeFromUtf8(iFileNameStream, fileNameBuf);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   778
                
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   779
                LOGSTRING2("CProfiler::HandleGeneralSettingsChange() - trying to open files %S ",&iFileNameStream);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   780
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   781
                if((result = parse.Set(iFileNameStream, NULL, NULL)) != KErrNone)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   782
                    {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   783
                    // break loop if fails, problems in file name => change to log into debug output
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   784
                    break;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   785
                    }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   786
                
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   787
                // create directory for trace files if not exists
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   788
                result = fileServer.MkDirAll(parse.FullName());
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   789
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   790
                // check that file server responded with KErrNone or KErrAlreadyExists
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   791
                if( result != KErrNone && result != KErrAlreadyExists)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   792
                    {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   793
                    // if some other result, e.g. memory full => break
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   794
                    break;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   795
                    }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   796
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   797
                // attempt opening the file
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   798
                result = file.Open(fileServer,parse.FullName(),EFileShareReadersOnly);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   799
                if(result != KErrNotFound)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   800
                    {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   801
                    if( result != KErrNotReady && 
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   802
                        result != KErrServerBusy ) 
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   803
                        {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   804
                        // close the file if it could be opened
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   805
                        LOGSTRING2("Found STREAM file with index %d",index);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   806
                        index++;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   807
                        }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   808
                    else 
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   809
                        {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   810
                        // in boot measurements the file system might not be ready yet.
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   811
                        LOGSTRING2("Problem in opening STREAM file %d",index);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   812
                        }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   813
                    file.Close();
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   814
                    }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   815
                } // while
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   816
            }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   817
        else
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   818
            {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   819
            // return error code
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   820
            return result;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   821
            }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   822
        
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   823
        TUint32 id(iWriterHandler->GetActiveWriter()->GetWriterType());
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   824
        
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   825
        // check if a file name is one that does not exist and selected plugin is disk writer
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   826
        if(result == KErrNotFound && id == KDiskWriterPluginUid.iUid)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   827
            {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   828
            // write right trace data file name to disk writer plugin
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   829
            iWriterHandler->SetPluginSettings( KDiskWriterPluginUid, iFileNameStream );
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   830
            }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   831
        else
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   832
            {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   833
            // return error if could not create trace log file
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   834
            return result;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   835
            }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   836
        // close file server
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   837
        fileServer.Close();
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   838
        }   // if output == KOutputToDebugOutput
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   839
    return KErrNone;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   840
    }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   841
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   842
// --------------------------------------------------------------------------------------------
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   843
void CProfiler::SaveSettingsL()
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   844
    {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   845
    LOGTEXT(_L("CProfiler::SaveSettings()"));
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   846
    
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   847
    // local literal
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   848
    _LIT(KGeneralHeader, "[general]");
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   849
    _LIT(KVersionHeader, "version");
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   850
    _LIT8(KPIProfilerSettingsHeader, "; PI Profiler Settings File");
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   851
    _LIT8(KGeneralSettingsHeader, "; general settings");
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   852
    _LIT8(KOutputFileDescription,"; \"output_type=file_system\" writes *.dat file to external memory");
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   853
    _LIT8(KOutputDebugDescription,"; \"output_type=debug_output\" writes *.dat file to debug port");
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   854
    _LIT8(KOutputFilePrefixDescription,"; if writing to file, prefix of the *.dat file\r\n; first '#' in the prefix is replaced with an integer");
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   855
    _LIT8(KOutputSaveDriveDescription,"; if writing to file, the location to store the *.dat file");
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   856
    
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   857
    RFs fs;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   858
    RFile settingsFile;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   859
    TInt err(KErrNone);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   860
    TBuf8<384> line;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   861
    
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   862
    // connect to file server
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   863
    err = fs.Connect();
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   864
    if( err != KErrNone )
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   865
        {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   866
        // failed to write settings to settings file
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   867
        return;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   868
        }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   869
    
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   870
    // create and set the private path
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   871
    fs.CreatePrivatePath(EDriveC);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   872
    fs.SetSessionToPrivate(EDriveC);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   873
  
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   874
    // create the new settings file
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   875
    err = settingsFile.Replace(fs, iSettingsFileLocation, EFileWrite);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   876
    if(err != KErrNone)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   877
        return;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   878
    
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   879
    CleanupClosePushL(settingsFile);  
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   880
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   881
    // write the header
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   882
    line.Copy(KPIProfilerSettingsHeader);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   883
    line.Append(KNewLineSeparator);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   884
    line.Append(KNewLineSeparator);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   885
    settingsFile.Write(line);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   886
    
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   887
    // write the header
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   888
    line.Copy(KGeneralSettingsHeader);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   889
    line.Append(KNewLineSeparator);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   890
    settingsFile.Write(line);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   891
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   892
    // write all generic settings
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   893
    line.Copy(KGeneralHeader);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   894
    line.Append(KNewLineSeparator);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   895
    settingsFile.Write(line);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   896
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   897
    // write version info
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   898
    line.Copy(KVersionHeader);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   899
    line.Append(KEquals);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   900
    line.Append(PROFILER_VERSION_SHORT);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   901
    line.Append(KNewLineSeparator);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   902
    settingsFile.Write(line);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   903
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   904
    // output explanation
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   905
    line.Copy(KOutputFileDescription);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   906
    line.Append(KNewLineSeparator);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   907
    line.Append(KOutputDebugDescription);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   908
    line.Append(KNewLineSeparator);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   909
    settingsFile.Write(line);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   910
    
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   911
    // write trace output
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   912
    line.Copy(KGenericTraceOutput);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   913
    line.Append(KEquals);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   914
    line.Append(iGeneralAttributes.iTraceOutput);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   915
    line.Append(KNewLineSeparator);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   916
    settingsFile.Write(line);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   917
    
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   918
    // file prefix explanation
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   919
    line.Copy(KOutputFilePrefixDescription);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   920
    line.Append(KNewLineSeparator);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   921
    settingsFile.Write(line);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   922
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   923
    // write trace file prefix
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   924
    line.Copy(KGenericTraceFilePrefix);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   925
    line.Append(KEquals);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   926
    line.Append(iGeneralAttributes.iTraceFilePrefix);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   927
    line.Append(KNewLineSeparator);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   928
    settingsFile.Write(line);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   929
    
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   930
    // file prefix explanation
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   931
    line.Copy(KOutputSaveDriveDescription);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   932
    line.Append(KNewLineSeparator);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   933
    settingsFile.Write(line);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   934
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   935
    // write trace file location
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   936
    line.Copy(KGenericTraceFileSaveDrive);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   937
    line.Append(KEquals);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   938
    line.Append(iGeneralAttributes.iSaveFileDrive);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   939
    line.Append(KNewLineSeparator);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   940
    settingsFile.Write(line);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   941
    
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   942
    // reset the default attributes array
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   943
    iDefaultSamplerAttributesArray->Reset();
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   944
    
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   945
    // update the latest changes from plugins
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   946
    iSamplerHandler->GetSamplerAttributesL(iDefaultSamplerAttributesArray);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   947
    
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   948
    // call CSamplerController to write all sampler settings
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   949
    iSamplerHandler->ComposeAttributesToSettingsFileFormat(settingsFile, iDefaultSamplerAttributesArray);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   950
    
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   951
    CleanupStack::PopAndDestroy(); //settingsFile
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   952
    // close file
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   953
    fs.Close();
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   954
    }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   955
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   956
TInt CProfiler::CheckOldProfilerRunning()
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   957
    {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   958
    TFindProcess procName;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   959
    procName.Find(_L("BappeaProf.exe*"));
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   960
    TFullName aResult;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   961
    TInt err(KErrNone);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   962
    RProcess proc;    
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   963
    
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   964
    // now check if old Profiler is still running on
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   965
    err = procName.Next(aResult);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   966
    // check if old profiler process found 
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   967
    if(err == KErrNone)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   968
        {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   969
        // other process found, i.e. right process to communicate with, in case started from eshell
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   970
        err = proc.Open(procName);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   971
        if(err == KErrNone)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   972
            {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   973
            if(proc.ExitCategory().Length() > 0)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   974
                {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   975
                proc.Close();
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   976
                // process already exited => create a new one
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   977
                return KErrNotFound;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   978
                }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   979
            proc.Close();
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   980
            }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   981
        // return error for error handling
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   982
        return KErrAlreadyExists;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   983
        }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   984
    return err;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   985
    }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   986
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   987
// --------------------------------------------------------------------------------------------
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   988
void CProfiler::HandleError(TInt aErr)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   989
    {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   990
    // write error to status property to inform requester
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   991
    TInt err(iEngineStatus.Set(KEngineStatusPropertyCat, EProfilerEngineStatus, aErr));
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   992
    if(err != KErrNone)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   993
        RDebug::Print(_L("CProfiler::HandleError() - error setting status: %d"), err);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   994
    }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   995
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   996
// --------------------------------------------------------------------------------------------
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   997
TInt CProfiler::ControlDataL(TInt aCommand,TAny* value1,TAny* /*value2*/)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   998
    {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   999
	LOGSTRING3("CProfiler::ControlData %d, 0x%x",aCommand,value1);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1000
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1001
	_LIT(KDebugOutput, "debug_output");
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1002
	_LIT(KFileOutput, "file_system");
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1003
	_LIT8(KOutputToDebugOutput, "debug_output");
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1004
	
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1005
	TDes* desc;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1006
	TPtrC ptrDesc;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1007
	
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1008
	switch(aCommand)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1009
	    {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1010
		// new controls
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1011
	    case RProfiler::EGetFileName:
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1012
	        {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1013
            LOGTEXT(_L("Profiler::EGetFileName - start"));
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1014
            LOGSTRING2(_L("Profiler::EGetFileName - total file name is: %S"),(TDes*)value1);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1015
            desc = (TDes*)value1;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1016
            desc->Zero();
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1017
            desc->Append(iFileNameStream);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1018
            LOGSTRING2(_L("Profiler::EGetFileName - now total file name is: %S"),(TDes*)value1);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1019
            return KErrNone;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1020
	        }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1021
        case RProfiler::EGetActiveWriter:
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1022
            {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1023
            LOGTEXT(_L("Profiler::EGetActiveWriter - start"));
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1024
            desc = (TDes*)value1;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1025
            desc->Zero();
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1026
            if(iGeneralAttributes.iTraceOutput.CompareF(KOutputToDebugOutput) == 0)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1027
                {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1028
                desc->Append(KDebugOutput);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1029
                }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1030
            else
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1031
                {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1032
                desc->Append(KFileOutput);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1033
                }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1034
            return KErrNone;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1035
            }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1036
	    }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1037
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1038
	return KErrNone;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1039
    }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1040
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1041
// --------------------------------------------------------------------------------------------
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1042
TInt CProfiler::ControlL(TInt aCommand)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1043
    {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1044
	LOGSTRING2("CProfiler::Control - Controlling ProfilerEngine %d",aCommand);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1045
	TInt err(KErrNone);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1046
	
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1047
	switch (aCommand)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1048
	    {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1049
		case RProfiler::EStartSampling:
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1050
		    {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1051
		    // check first if old Profiler already running
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1052
		    err = CheckOldProfilerRunning();
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1053
		    if(err == KErrAlreadyExists)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1054
		        {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1055
		        // if exists do not start a profiling process since corrupts the collected trace data  
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1056
		        HandleError(err);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1057
		        err = KErrNone;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1058
		        return err;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1059
		        }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1060
		    
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1061
		    // save settings before launching the profiler
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1062
		    // reason: the profiling may have set to the background => need for get right settings
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1063
		    SaveSettingsL();
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1064
		    
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1065
		    // set the general settings to writer plugins to reflect the latest changes
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1066
		    err = HandleGeneralSettingsChange();
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1067
		    if(err == KErrNone)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1068
		        {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1069
                // reset the buffers before new profiling
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1070
                iUserStream->ResetBuffers();
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1071
    
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1072
                // give the CProfilerSampleStream a handle to current writer
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1073
                iUserStream->SetWriter(*iWriterHandler->GetActiveWriter());
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1074
                
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1075
                // set initially debug output writer active
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1076
                err = iWriterHandler->StartSelectedPlugin();
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1077
    
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1078
                // check that writer plugin started
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1079
                if(err != KErrNone)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1080
                    {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1081
                    // if not started handle error
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1082
                    HandleError(err);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1083
                    }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1084
                else
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1085
                    {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1086
                    // start activated sampler plug-in, NOTE: plugins check if errors occur in startup for some reason
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1087
                    iSamplerHandler->StartSamplerPluginsL();
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1088
        
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1089
                    // set engine state P&S property to running, e.g. for PIProfiler UI to read
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1090
                    iState = RProfiler::ERunning;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1091
        
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1092
                    // set the engine into running mode
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1093
                    iEngineStatus.Set(iState);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1094
                    }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1095
                }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1096
		    else
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1097
		        {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1098
		        // handle error and notify requester
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1099
		        HandleError(err);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1100
		        }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1101
		    
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1102
		    LOGTEXT(_L("CProfiler::Control - Finished processing EStartSampling!"));
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1103
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1104
			return err;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1105
		    }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1106
		case RProfiler::EStopSampling:
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1107
			LOGTEXT(_L("CProfiler::Control - Starting to stop sampling..."));
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1108
			// stop sampler plugins
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1109
			if(iState == RProfiler::ERunning)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1110
				{
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1111
				iState = RProfiler::EStopping;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1112
				iEngineStatus.Set(RProfiler::EStopping);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1113
				
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1114
				iSamplerHandler->StopSamplerPlugins();
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1115
	
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1116
				// finalize the filled buffer writing
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1117
				iUserStream->Finalise();
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1118
				
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1119
				// stop output plugin and write the rest of the trace data to output
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1120
				LOGTEXT(_L("CProfiler::Control - stopping writer"));
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1121
				iWriterHandler->StopSelectedPlugin();
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1122
	
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1123
				// set engine state P&S property idle 
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1124
				iState = RProfiler::EIdle;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1125
				iEngineStatus.Set(RProfiler::EIdle);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1126
				
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1127
				LOGSTRING2("CProfiler::Control - sampling stopped, going to state %d", RProfiler::EIdle);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1128
				}
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1129
			return KErrNone;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1130
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1131
		case RProfiler::EExitProfiler:
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1132
		    {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1133
		    // save settings into settings file when exiting
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1134
		    SaveSettingsL();
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1135
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1136
            if(iUserStream)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1137
                {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1138
                delete iUserStream;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1139
                iUserStream = NULL;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1140
                }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1141
		    
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1142
            // set engine state P&S property idle 
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1143
            iState = RProfiler::EIdle;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1144
            iEngineStatus.Set(RProfiler::EIdle);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1145
               
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1146
            LOGTEXT(_L("Stopping Activer Scheduler"));
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1147
            CActiveScheduler::Stop();
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1148
            LOGTEXT(_L("Stopped Activer Scheduler"));
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1149
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1150
            return KErrNone;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1151
		    }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1152
	    }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1153
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1154
	LOGTEXT(_L("CProfiler::Control - returning"));
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1155
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1156
	return err;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1157
    }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1158
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1159
// --------------------------------------------------------------------------------------------
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1160
void CProfiler::Finalise()
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1161
    {	
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1162
	LOGTEXT(_L("CProfiler::Finalise - Finished processing EStopSampling!"));
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1163
    }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1164
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1165
// --------------------------------------------------------------------------------------------
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1166
RProfiler::TSamplerState CProfiler::State() const
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1167
    {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1168
	return iState;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1169
    }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1170
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1171
/*
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1172
 *
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1173
 *	Class CPServer definition
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1174
 *
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1175
 */
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1176
// --------------------------------------------------------------------------------------------
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1177
inline const CPServer& CPSession::Server() const
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1178
    {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1179
	return *static_cast<const CPServer*>(CSession2::Server());
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1180
    }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1181
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1182
// --------------------------------------------------------------------------------------------
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1183
void CPSession::ServiceL(const RMessage2& aMessage)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1184
    {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1185
	LOGTEXT(_L("CPSession::ServiceL - Starting to process message"));
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1186
	TInt err(KErrNone);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1187
	
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1188
	if(aMessage.Function() == RProfiler::EGetGeneralAttributes)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1189
	    {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1190
	    Server().GetGeneralAttributesL(aMessage);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1191
	    }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1192
	else if(aMessage.Function() == RProfiler::ESetGeneralAttributes)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1193
	    {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1194
        Server().SetGeneralAttributesL(aMessage);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1195
	    }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1196
	else if(aMessage.Function() == RProfiler::EGetSamplerAttributes)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1197
	    {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1198
        Server().GetSamplerAttributesL(aMessage);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1199
	    }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1200
    else if(aMessage.Function() == RProfiler::EGetSamplerAttributeCount)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1201
        {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1202
        Server().GetSamplerAttributeCountL(aMessage);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1203
        }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1204
    else if(aMessage.Function() == RProfiler::ESetSamplerAttributes)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1205
        {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1206
        Server().SetSamplerAttributesL(aMessage);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1207
        }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1208
    else if(aMessage.Function() == RProfiler::ERefreshProfilerStatus)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1209
        {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1210
        Server().RefreshStatus(aMessage);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1211
        }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1212
	else if(aMessage.Ptr0() == 0 && aMessage.Ptr1() == 0 && aMessage.Ptr2() == 0)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1213
		{	
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1214
		LOGTEXT(_L("Ptr0 && Ptr1 == 0 && Ptr2 == 0"));
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1215
		aMessage.Complete(Server().ControlL(RProfiler::TCommand(aMessage.Function())));
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1216
		LOGTEXT(_L("CPSession::ServiceL - Message completed"));
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1217
		} 
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1218
	else if(aMessage.Ptr0() != 0 && aMessage.Ptr1() != 0 && aMessage.Ptr2() != 0)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1219
		{
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1220
		LOGTEXT(_L("Error with message, all pointers contain data!"));
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1221
		}
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1222
		
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1223
	else if (aMessage.Ptr0() != 0)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1224
		{
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1225
		if(aMessage.Ptr1() == 0)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1226
			{
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1227
			LOGTEXT(_L("ServiceL: Ptr0 != 0 && Ptr1 == 0"));
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1228
			// provided value is a descriptor
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1229
			TBuf<64>* dst = new TBuf<64>;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1230
			aMessage.ReadL(0,*dst,0);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1231
	
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1232
			err = Server().ControlDataL(aMessage.Function(),(TAny*)dst);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1233
			delete dst;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1234
			aMessage.Complete(err);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1235
			LOGTEXT(_L("CPSession::ServiceL - Message completed"));
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1236
			}
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1237
		else
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1238
			{
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1239
			LOGTEXT(_L("ServiceL: Ptr0 != 0 && Ptr1 != 0"));
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1240
			// provided value is a descriptor
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1241
			TBuf<64>* dst = new TBuf<64>;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1242
			aMessage.ReadL(0,*dst,0);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1243
			
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1244
			TUint32 num1 = (TUint32)aMessage.Ptr1();
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1245
			
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1246
			err = Server().ControlDataL(aMessage.Function(),(TAny*)dst, (TAny*)num1);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1247
			delete dst;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1248
			aMessage.Complete(err);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1249
			LOGTEXT(_L("CPSession::ServiceL - Message completed"));
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1250
			}
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1251
		}
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1252
	else if (aMessage.Ptr1() != 0)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1253
		{
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1254
		LOGTEXT(_L("ServiceL: Ptr1 != 0"));
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1255
		// provided value is a TUint32
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1256
		if( ((TUint32)aMessage.Ptr3()) == 0xffffffff)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1257
			{
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1258
			TUint32 num = (TUint32)aMessage.Ptr1();
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1259
			err = Server().ControlDataL(aMessage.Function(),(TAny*)num);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1260
			aMessage.Complete(err);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1261
			LOGTEXT(_L("CPSession::ServiceL - Message completed"));
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1262
			}
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1263
		else
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1264
			{
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1265
			LOGTEXT(_L("ServiceL: Ptr3 != 0xffffffff"));
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1266
			TUint32 num1 = (TUint32)aMessage.Ptr1();
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1267
			TUint32 num2 = (TUint32)aMessage.Ptr3();
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1268
			err = Server().ControlDataL(aMessage.Function(),(TAny*)num1,(TAny*)num2);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1269
			aMessage.Complete(err);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1270
			LOGTEXT(_L("CPSession::ServiceL - Message completed"));
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1271
			}
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1272
		}
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1273
	else if (aMessage.Ptr2() != 0)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1274
		{
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1275
		// command requests for data, provided 
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1276
		// value should be a descriptor
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1277
		if( ((TUint32)aMessage.Ptr3()) == 0xffffffff)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1278
			{
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1279
			LOGTEXT(_L("ServiceL: Ptr2 != 0 && Ptr3 == 0xffffffff"));
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1280
	
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1281
			TBuf<256>* src = new TBuf<256>;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1282
			src->Zero();
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1283
			err = Server().ControlDataL(aMessage.Function(),(TAny*)src);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1284
	
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1285
			LOGSTRING2("Got sampler data %S",src);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1286
			
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1287
			aMessage.WriteL(2, *src, 0);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1288
	
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1289
			delete src;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1290
			aMessage.Complete(err);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1291
			LOGTEXT(_L("CPSession::ServiceL - Message completed"));
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1292
			}
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1293
		else 
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1294
			{
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1295
			LOGTEXT(_L("ServiceL: Ptr2 != 0 && Ptr3 != 0xffffffff"));
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1296
			
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1297
			TUint32 num1 = (TUint32)aMessage.Ptr2();	// containing id
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1298
			TBuf<256>* buffer = new TBuf<256>;		// Text data, e.g. plug-in name or description
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1299
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1300
			LOGSTRING3("Getting data for sampler: 0x%X, buffer max len %d",num1, aMessage.GetDesMaxLength(3));
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1301
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1302
			err = Server().ControlDataL(aMessage.Function(), (TAny*)num1, (TAny*)buffer);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1303
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1304
			LOGSTRING2("Got sampler data %S",&buffer);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1305
			
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1306
			// write back to same parameter
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1307
			aMessage.WriteL(3, *buffer, 0);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1308
			aMessage.Complete(err);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1309
			LOGTEXT(_L("CPSession::ServiceL - Message completed"));			
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1310
			}
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1311
		}
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1312
	LOGTEXT(_L("CPSession::ServiceL - Message processed"));
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1313
    }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1314
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1315
// --------------------------------------------------------------------------------------------
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1316
MProfilerController* CPServer::NewL(TInt aPriority, MProfilerEngine& aEngine)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1317
    {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1318
	LOGTEXT(_L("CPServer::NewL - Enter"));
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1319
	CPServer* self = new(ELeave) CPServer(aPriority, aEngine);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1320
	CleanupStack::PushL(self);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1321
	self->StartL(KProfilerName);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1322
	CleanupStack::Pop();
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1323
	LOGTEXT(_L("CPSession::NewL - Exit"));
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1324
	return self;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1325
    }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1326
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1327
// --------------------------------------------------------------------------------------------
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1328
CPServer::CPServer(TInt aPriority, MProfilerEngine& aEngine)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1329
	: CServer2(aPriority), MProfilerController(aEngine)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1330
    {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1331
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1332
    }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1333
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1334
// --------------------------------------------------------------------------------------------
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1335
void CPServer::Release()
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1336
    {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1337
	delete this;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1338
    }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1339
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1340
// --------------------------------------------------------------------------------------------
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1341
CSession2* CPServer::NewSessionL(const TVersion&,const RMessage2&) const
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1342
    {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1343
	return new(ELeave) CPSession();
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1344
    }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1345
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1346
/*
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1347
 *
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1348
 * Static methods for controlling the profiler
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1349
 * through command line
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1350
 *
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1351
 */
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1352
// --------------------------------------------------------------------------------------------
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1353
static void RunEngineServerL(const TDesC& aSettingsFile)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1354
    {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1355
	RDebug::Print(_L("Profiler: RunEngineServerL() - Install active scheduler"));
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1356
	CActiveScheduler* pS = new CActiveScheduler;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1357
	CActiveScheduler::Install(pS);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1358
	CProfiler* p = CProfiler::NewLC(aSettingsFile);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1359
	CActiveScheduler::Start();
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1360
	p->Finalise();
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1361
	CleanupStack::PopAndDestroy(p);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1362
	delete pS;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1363
    }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1364
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1365
// --------------------------------------------------------------------------------------------
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1366
static TInt TestSettingsFile(const TDesC& configFile)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1367
    {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1368
    RFs fs;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1369
    TBuf8<256> configFile8;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1370
    
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1371
    // check if file server can be connected
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1372
    if (fs.Connect() != KErrNone)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1373
        {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1374
        // file server couldn't be connected, return false
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1375
        return KErrNotFound;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1376
        }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1377
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1378
    // check if config file name length is > 0
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1379
    if (configFile.Length() > 0)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1380
        {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1381
        // check sanity of settings file location
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1382
        CnvUtfConverter::ConvertFromUnicodeToUtf8(configFile8, configFile);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1383
        if(!CProfiler::CheckLocationSanity(fs, configFile8))
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1384
            {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1385
            fs.Close();
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1386
            return KErrGeneral;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1387
            }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1388
        }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1389
    else
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1390
        {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1391
        // configFile length 0, return false
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1392
        fs.Close();
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1393
        return KErrNotFound;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1394
        }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1395
    // return true if tests passed
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1396
    fs.Close();
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1397
    return KErrNone;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1398
    }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1399
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1400
// --------------------------------------------------------------------------------------------
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1401
GLDEF_C TInt E32Main()
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1402
    {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1403
    // parse command line arguments 
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1404
    TBuf<256> c;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1405
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1406
    // copy the full command line with arguments into a buffer
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1407
    User::CommandLine(c);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1408
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1409
    TBuf<256> fileName;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1410
    fileName.Append(c); // only one settings param should be
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1411
    LOGSTRING2("Filename is %S", &fileName);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1412
    if(TestSettingsFile(fileName) != KErrNone)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1413
        {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1414
        // settings file does not exist, copy null desc to file name
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1415
        fileName.Copy(KNullDesC);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1416
        }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1417
    
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1418
    // if no command line arguments found just start the profiler process
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1419
    __UHEAP_MARK;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1420
    CTrapCleanup* cleanup = CTrapCleanup::New();
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1421
    TInt ret(KErrNoMemory);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1422
    if( cleanup )
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1423
        {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1424
        TRAPD( ret, RunEngineServerL(fileName) );
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1425
        RDebug::Print(_L("Profiler: E32Main() - ret %d"), ret);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1426
        delete cleanup;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1427
        } 
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1428
    __UHEAP_MARKEND;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1429
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1430
    return ret;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1431
    } 
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1432
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
  1433