Update contrib.
1 // Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // LOGCLISERVSHARED.CPP
18 #include "LogCliServShared.h"
22 /////////////////////////////////////////////////////////////////////////////////////////
23 // -----> TLogWindow (source)
24 /////////////////////////////////////////////////////////////////////////////////////////
26 EXPORT_C TLogWindow::TLogWindow()
31 /////////////////////////////////////////////////////////////////////////////////////////
32 /////////////////////////////////////////////////////////////////////////////////////////
33 /////////////////////////////////////////////////////////////////////////////////////////
35 EXPORT_C TBool TLogWindow::Contains(TInt aPosition) const
37 return (aPosition >= iLower && aPosition <= iUpper);
40 EXPORT_C TInt TLogWindow::Range() const
44 return (iUpper - iLower) + 1;
47 EXPORT_C TInt TLogWindow::WindowIndexFromCursorPosition(TInt aCursorPosition) const
49 const TInt mapped = aCursorPosition - iLower;
53 EXPORT_C void TLogWindow::Reset()
59 void TLogWindow::Normalize()
71 /////////////////////////////////////////////////////////////////////////////////////////
72 // -----> TLogWindowAndCursor (source)
73 /////////////////////////////////////////////////////////////////////////////////////////
75 TLogWindowAndCursor::TLogWindowAndCursor()
80 TLogWindowAndCursor::TLogWindowAndCursor(const TLogWindow& aWindow, TInt aCursorPosition)
81 : TLogWindow(aWindow), iCursorPosition(aCursorPosition)
85 /////////////////////////////////////////////////////////////////////////////////////////
86 /////////////////////////////////////////////////////////////////////////////////////////
87 /////////////////////////////////////////////////////////////////////////////////////////
89 TLogWindowAndCursor::TAffected TLogWindowAndCursor::AdjustForItemDeletion(TInt aItemIndex)
91 const TInt KDelta = -1;
93 TAffected changed = EWindowUnaffected;
94 if (aItemIndex <= iUpper)
96 changed = EWindowAffected;
98 if (aItemIndex < iCursorPosition)
100 else if (aItemIndex == iCursorPosition && iCursorPosition == iUpper)
104 if (aItemIndex < iLower)
107 TLogWindow::Normalize();
112 TLogWindowAndCursor::TAffected TLogWindowAndCursor::AdjustForItemAddition(TInt aItemIndex)
114 ///////////////////////////////////////
116 ///////////////////////////////////////
117 // Cursor position: *
119 // View Index: 0 1 2 3 4 5 6
120 // View Contents: A B C D E F G
122 // Then, item X is added =>
124 // Cursor position: *
126 // View Index: 0 1 2 3 4 5 6 7
127 // View Contents: X A B C D E F G
129 ///////////////////////////////////////
131 ///////////////////////////////////////
132 // Cursor position: *
134 // View Index: 0 1 2 3 4 5 6
135 // View Contents: A B C D E F G
137 // Then, item X is added =>
139 // Cursor position: *
141 // View Index: 0 1 2 3 4 5 6 7
142 // View Contents: X A B C D E F G
144 ///////////////////////////////////////
146 ///////////////////////////////////////
147 // Cursor position: *
149 // View Index: 0 1 2 3 4 5 6
150 // View Contents: A B C D E F G
152 // Then, item X is added =>
154 // Cursor position: *
155 // Window: -----------
156 // View Index: 0 1 2 3 4 5 6 7
157 // View Contents: A B C D X E F G
159 ///////////////////////////////////////
161 ///////////////////////////////////////
162 // Cursor position: *
164 // View Index: 0 1 2 3 4 5 6
165 // View Contents: A B C D E F G
167 // Then, item X is added =>
169 // Cursor position: *
171 // View Index: 0 1 2 3 4 5 6 7
172 // View Contents: A B C D E X F G
174 ///////////////////////////////////////
175 const TInt KDelta = 1;
177 TAffected changed = EWindowUnaffected;
178 if (aItemIndex <= iUpper) // UC4
180 changed = EWindowAffected;
182 if (aItemIndex <= iCursorPosition) // UC1
185 iUpper += KDelta; // UC1
186 if (aItemIndex <= iLower) // UC1
189 TLogWindow::Normalize();
194 TInt TLogWindowAndCursor::WindowIndexFromCursorPosition() const
196 return TLogWindow::WindowIndexFromCursorPosition(iCursorPosition);
199 void TLogWindowAndCursor::Reset()
202 iCursorPosition = -1;
206 void TLogWindowAndCursor::NormalizeWindowAndCursor()
208 TLogWindow::Normalize();
209 if (iCursorPosition < iLower)
210 iCursorPosition = iLower;
211 if (iCursorPosition > iUpper)
212 iCursorPosition = iUpper;
228 /////////////////////////////////////////////////////////////////////////////////////////
229 // -----> TLogTransferWindow (source)
230 /////////////////////////////////////////////////////////////////////////////////////////
232 EXPORT_C TLogTransferWindow::TLogTransferWindow() :
238 EXPORT_C void TLogTransferWindow::Reset()
241 iBufferSize = iServerDataSize = 0;
245 /////////////////////////////////////////////////////////////////////////////////////////
246 // -----> LogUtils (source)
247 /////////////////////////////////////////////////////////////////////////////////////////
248 /** Retrieves appropriate date format string for the current locale.
250 @return Format string for this locale. */
251 EXPORT_C const TDesC& LogUtils::DateFormatForLocale()
253 _LIT(KSQLDateFormatColon,"%D%*M%Y%1 %2 %3 %H:%T:%S%.%C");
254 _LIT(KSQLDateFormatDot,"%D%*M%Y%1 %2 %3 %H.%T.%S%.%C");
257 TBool dateSeparatorIsColon=EFalse;
258 for (TInt i=0; i<4; i++)
260 TChar c = current.DateSeparator(i);
263 dateSeparatorIsColon=ETrue;
268 if (dateSeparatorIsColon)
269 return KSQLDateFormatDot;
270 return KSQLDateFormatColon;