os/persistentdata/loggingservices/eventlogger/LogCli/src/LogCliServerShared.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
// LOGCLISERVSHARED.CPP
sl@0
    15
// 
sl@0
    16
//
sl@0
    17
sl@0
    18
#include "LogCliServShared.h"
sl@0
    19
sl@0
    20
sl@0
    21
sl@0
    22
/////////////////////////////////////////////////////////////////////////////////////////
sl@0
    23
// -----> TLogWindow (source)
sl@0
    24
/////////////////////////////////////////////////////////////////////////////////////////
sl@0
    25
sl@0
    26
EXPORT_C TLogWindow::TLogWindow()
sl@0
    27
	{
sl@0
    28
	Reset();
sl@0
    29
	}
sl@0
    30
sl@0
    31
/////////////////////////////////////////////////////////////////////////////////////////
sl@0
    32
/////////////////////////////////////////////////////////////////////////////////////////
sl@0
    33
/////////////////////////////////////////////////////////////////////////////////////////
sl@0
    34
sl@0
    35
EXPORT_C TBool TLogWindow::Contains(TInt aPosition) const
sl@0
    36
	{
sl@0
    37
	return (aPosition >= iLower && aPosition <= iUpper);
sl@0
    38
	}
sl@0
    39
sl@0
    40
EXPORT_C TInt TLogWindow::Range() const
sl@0
    41
	{
sl@0
    42
	if	(iUpper < 0)
sl@0
    43
		return 0;
sl@0
    44
	return (iUpper - iLower) + 1;
sl@0
    45
	}
sl@0
    46
sl@0
    47
EXPORT_C TInt TLogWindow::WindowIndexFromCursorPosition(TInt aCursorPosition) const
sl@0
    48
	{
sl@0
    49
	const TInt mapped = aCursorPosition - iLower;
sl@0
    50
	return mapped;
sl@0
    51
	}
sl@0
    52
sl@0
    53
EXPORT_C void TLogWindow::Reset()
sl@0
    54
	{
sl@0
    55
	iLower = -1;
sl@0
    56
	iUpper = -1;
sl@0
    57
	}
sl@0
    58
sl@0
    59
void TLogWindow::Normalize()
sl@0
    60
	{
sl@0
    61
	if	(iLower > iUpper)
sl@0
    62
		iLower = iUpper;
sl@0
    63
	}
sl@0
    64
sl@0
    65
sl@0
    66
sl@0
    67
sl@0
    68
sl@0
    69
sl@0
    70
sl@0
    71
/////////////////////////////////////////////////////////////////////////////////////////
sl@0
    72
// -----> TLogWindowAndCursor (source)
sl@0
    73
/////////////////////////////////////////////////////////////////////////////////////////
sl@0
    74
sl@0
    75
TLogWindowAndCursor::TLogWindowAndCursor()
sl@0
    76
	{
sl@0
    77
	Reset();
sl@0
    78
	}
sl@0
    79
sl@0
    80
TLogWindowAndCursor::TLogWindowAndCursor(const TLogWindow& aWindow, TInt aCursorPosition)
sl@0
    81
:	TLogWindow(aWindow), iCursorPosition(aCursorPosition)
sl@0
    82
	{
sl@0
    83
	}
sl@0
    84
sl@0
    85
/////////////////////////////////////////////////////////////////////////////////////////
sl@0
    86
/////////////////////////////////////////////////////////////////////////////////////////
sl@0
    87
/////////////////////////////////////////////////////////////////////////////////////////
sl@0
    88
sl@0
    89
TLogWindowAndCursor::TAffected TLogWindowAndCursor::AdjustForItemDeletion(TInt aItemIndex)
sl@0
    90
	{
sl@0
    91
	const TInt KDelta = -1;
sl@0
    92
	//
sl@0
    93
	TAffected changed = EWindowUnaffected;
sl@0
    94
	if	(aItemIndex <= iUpper)
sl@0
    95
		{
sl@0
    96
		changed = EWindowAffected;
sl@0
    97
sl@0
    98
		if	(aItemIndex < iCursorPosition)
sl@0
    99
			--iCursorPosition;
sl@0
   100
		else if (aItemIndex == iCursorPosition && iCursorPosition == iUpper)
sl@0
   101
			--iCursorPosition;
sl@0
   102
sl@0
   103
		iUpper += KDelta;
sl@0
   104
		if	(aItemIndex < iLower)
sl@0
   105
			iLower += KDelta;
sl@0
   106
		//
sl@0
   107
		TLogWindow::Normalize();
sl@0
   108
		}
sl@0
   109
	return changed;
sl@0
   110
	}
sl@0
   111
sl@0
   112
TLogWindowAndCursor::TAffected TLogWindowAndCursor::AdjustForItemAddition(TInt aItemIndex)
sl@0
   113
	{
sl@0
   114
	///////////////////////////////////////
sl@0
   115
	// USE CASE 1:
sl@0
   116
	///////////////////////////////////////
sl@0
   117
	// Cursor position:  *
sl@0
   118
	// Window:			 ---------
sl@0
   119
	// View Index:       0 1 2 3 4 5 6
sl@0
   120
	// View Contents:    A B C D E F G
sl@0
   121
	//
sl@0
   122
	// Then, item X is added => 
sl@0
   123
	// 
sl@0
   124
	// Cursor position:    *
sl@0
   125
	// Window:			   ---------
sl@0
   126
	// View Index:       0 1 2 3 4 5 6 7
sl@0
   127
	// View Contents:    X A B C D E F G
sl@0
   128
	// 
sl@0
   129
	///////////////////////////////////////
sl@0
   130
	// USE CASE 2:
sl@0
   131
	///////////////////////////////////////
sl@0
   132
	// Cursor position:    *
sl@0
   133
	// Window:			   ---------
sl@0
   134
	// View Index:       0 1 2 3 4 5 6
sl@0
   135
	// View Contents:    A B C D E F G
sl@0
   136
	//
sl@0
   137
	// Then, item X is added => 
sl@0
   138
	// 
sl@0
   139
	// Cursor position:      *
sl@0
   140
	// Window:			     ---------
sl@0
   141
	// View Index:       0 1 2 3 4 5 6 7
sl@0
   142
	// View Contents:    X A B C D E F G
sl@0
   143
	// 
sl@0
   144
	///////////////////////////////////////
sl@0
   145
	// USE CASE 3:
sl@0
   146
	///////////////////////////////////////
sl@0
   147
	// Cursor position:          *
sl@0
   148
	// Window:			 ---------
sl@0
   149
	// View Index:       0 1 2 3 4 5 6
sl@0
   150
	// View Contents:    A B C D E F G
sl@0
   151
	//
sl@0
   152
	// Then, item X is added => 
sl@0
   153
	// 
sl@0
   154
	// Cursor position:            *
sl@0
   155
	// Window:			 -----------
sl@0
   156
	// View Index:       0 1 2 3 4 5 6 7
sl@0
   157
	// View Contents:    A B C D X E F G
sl@0
   158
	// 
sl@0
   159
	///////////////////////////////////////
sl@0
   160
	// USE CASE 4:
sl@0
   161
	///////////////////////////////////////
sl@0
   162
	// Cursor position:        *  
sl@0
   163
	// Window:			 ---------
sl@0
   164
	// View Index:       0 1 2 3 4 5 6
sl@0
   165
	// View Contents:    A B C D E F G
sl@0
   166
	//
sl@0
   167
	// Then, item X is added => 
sl@0
   168
	// 
sl@0
   169
	// Cursor position:        *   
sl@0
   170
	// Window:			 ---------
sl@0
   171
	// View Index:       0 1 2 3 4 5 6 7
sl@0
   172
	// View Contents:    A B C D E X F G
sl@0
   173
	// 
sl@0
   174
	///////////////////////////////////////
sl@0
   175
	const TInt KDelta = 1;
sl@0
   176
	//
sl@0
   177
	TAffected changed = EWindowUnaffected;
sl@0
   178
	if	(aItemIndex <= iUpper) // UC4
sl@0
   179
		{
sl@0
   180
		changed = EWindowAffected;
sl@0
   181
sl@0
   182
		if	(aItemIndex <= iCursorPosition) // UC1
sl@0
   183
			++iCursorPosition;
sl@0
   184
		//
sl@0
   185
		iUpper += KDelta; // UC1
sl@0
   186
		if	(aItemIndex <= iLower) // UC1
sl@0
   187
			iLower += KDelta;
sl@0
   188
		//
sl@0
   189
		TLogWindow::Normalize();
sl@0
   190
		}
sl@0
   191
	return changed;
sl@0
   192
	}
sl@0
   193
sl@0
   194
TInt TLogWindowAndCursor::WindowIndexFromCursorPosition() const
sl@0
   195
	{
sl@0
   196
	return TLogWindow::WindowIndexFromCursorPosition(iCursorPosition);
sl@0
   197
	}
sl@0
   198
sl@0
   199
void TLogWindowAndCursor::Reset()
sl@0
   200
	{
sl@0
   201
	TLogWindow::Reset();
sl@0
   202
	iCursorPosition = -1;
sl@0
   203
	iValid = EFalse;
sl@0
   204
	}
sl@0
   205
sl@0
   206
void TLogWindowAndCursor::NormalizeWindowAndCursor()
sl@0
   207
	{
sl@0
   208
	TLogWindow::Normalize();
sl@0
   209
	if	(iCursorPosition < iLower)
sl@0
   210
		iCursorPosition = iLower;
sl@0
   211
	if	(iCursorPosition > iUpper)
sl@0
   212
		iCursorPosition = iUpper;
sl@0
   213
	}
sl@0
   214
sl@0
   215
sl@0
   216
sl@0
   217
sl@0
   218
sl@0
   219
sl@0
   220
sl@0
   221
sl@0
   222
sl@0
   223
sl@0
   224
sl@0
   225
sl@0
   226
sl@0
   227
sl@0
   228
/////////////////////////////////////////////////////////////////////////////////////////
sl@0
   229
// -----> TLogTransferWindow (source)
sl@0
   230
/////////////////////////////////////////////////////////////////////////////////////////
sl@0
   231
sl@0
   232
EXPORT_C TLogTransferWindow::TLogTransferWindow() :
sl@0
   233
	iBufferSize(0),
sl@0
   234
	iServerDataSize(0)
sl@0
   235
	{
sl@0
   236
	}
sl@0
   237
sl@0
   238
EXPORT_C void TLogTransferWindow::Reset()
sl@0
   239
	{
sl@0
   240
	TLogWindow::Reset();
sl@0
   241
	iBufferSize = iServerDataSize = 0;
sl@0
   242
	}
sl@0
   243
sl@0
   244
sl@0
   245
/////////////////////////////////////////////////////////////////////////////////////////
sl@0
   246
// -----> LogUtils (source)
sl@0
   247
/////////////////////////////////////////////////////////////////////////////////////////
sl@0
   248
/**  Retrieves appropriate date format string for the current locale.
sl@0
   249
sl@0
   250
@return    Format string for this locale. */
sl@0
   251
EXPORT_C const TDesC& LogUtils::DateFormatForLocale()
sl@0
   252
	{
sl@0
   253
    _LIT(KSQLDateFormatColon,"%D%*M%Y%1 %2 %3 %H:%T:%S%.%C"); 
sl@0
   254
    _LIT(KSQLDateFormatDot,"%D%*M%Y%1 %2 %3 %H.%T.%S%.%C");
sl@0
   255
sl@0
   256
	TLocale current; 
sl@0
   257
	TBool dateSeparatorIsColon=EFalse;
sl@0
   258
	for (TInt i=0; i<4; i++)
sl@0
   259
		{
sl@0
   260
		TChar c = current.DateSeparator(i);
sl@0
   261
		if (c==':')
sl@0
   262
			{
sl@0
   263
			dateSeparatorIsColon=ETrue;
sl@0
   264
			break;
sl@0
   265
			}
sl@0
   266
		}
sl@0
   267
sl@0
   268
	if (dateSeparatorIsColon)
sl@0
   269
		return KSQLDateFormatDot;
sl@0
   270
	return KSQLDateFormatColon;
sl@0
   271
	}
sl@0
   272
sl@0
   273