dbgagents/trkagent/app/s60/TrkAppContainer.cpp
author bdonegan
Thu, 30 Sep 2010 16:15:48 +0100
changeset 3 b667e5204120
parent 0 c6b0df440bee
permissions -rw-r--r--
Remove reference to cinidata in order to allow TrkEngine to build
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
     1
/*
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
     2
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
     3
* All rights reserved.
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
     4
* This component and the accompanying materials are made available
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
     6
* which accompanies this distribution, and is available
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
     8
*
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
     9
* Initial Contributors:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    11
*
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    12
* Contributors:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    13
*
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    14
* Description: 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    15
*
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    16
*/
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    17
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    18
// INCLUDE FILES
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    19
#include <barsread.h>       // TResourceReader
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    20
#include <gdi.h>
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    21
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    22
#include "TrkAppUi.h"
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    23
#include "TrkAppView.h"
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    24
#include "TrkConnData.h"
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    25
#include "TrkAppContainer.h"
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    26
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    27
// ========================= MEMBER FUNCTIONS ================================
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    28
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    29
// ---------------------------------------------------------------------------
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    30
// CTrkAppContainer::CTrkAppContainer
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    31
// C++ constructor
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    32
// ---------------------------------------------------------------------------
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    33
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    34
CTrkAppContainer::CTrkAppContainer(CTrkAppView* aTrkAppView)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    35
:iTrkAppView(aTrkAppView)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    36
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    37
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    38
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    39
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    40
// ---------------------------------------------------------------------------
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    41
// CTrkAppContainer::ConstructL
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    42
// Symbian OS 2nd phase constructor
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    43
// ---------------------------------------------------------------------------
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    44
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    45
void CTrkAppContainer::ConstructL(const TRect& aRect)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    46
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    47
	CreateWindowL();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    48
	//Window().SetShadowDisabled(EFalse);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    49
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    50
	SetBlank();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    51
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    52
	SetRect(aRect);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    53
	ActivateL(); 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    54
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    55
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    56
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    57
// Destructor
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    58
CTrkAppContainer::~CTrkAppContainer()
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    59
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    60
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    61
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    62
// ---------------------------------------------------------
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    63
// CConnTestContainer::Draw(const TRect& aRect) const
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    64
// ---------------------------------------------------------
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    65
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    66
void CTrkAppContainer::Draw(const TRect& /*aRect*/) const
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    67
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    68
    CWindowGc& gc = SystemGc();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    69
    gc.Clear(Rect());
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    70
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    71
	TRect drawRect = Rect();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    72
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    73
	const CFont *font = iEikonEnv->AnnotationFont();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    74
	gc.UseFont(font);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    75
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    76
	TBuf<KMaxPath> buf;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    77
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    78
	_LIT(KTrkWelcome,"Welcome to TRK for Symbian OS");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    79
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    80
	TInt vert = 25;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    81
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    82
	gc.DrawText(KTrkWelcome, drawRect, vert, CGraphicsContext::ELeft, 2);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    83
	vert += font->HeightInPixels()*2;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    84
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    85
	if (iTrkAppView)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    86
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    87
        
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    88
        TTrkConnStatus statusType = iTrkAppView->GetConnectionStatus();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    89
	    switch(statusType)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    90
        {
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    91
		    case ETrkConnected:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    92
			{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    93
				gc.DrawText(KStatusConnected, drawRect, vert, CGraphicsContext::ELeft, 2);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    94
		        break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    95
		        
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    96
			}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    97
		    case ETrkNotConnected:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    98
			{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    99
				gc.DrawText(KStatusDisconnected, drawRect, vert, CGraphicsContext::ELeft, 2);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   100
		        break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   101
	        }
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   102
		    case ETrkConnecting:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   103
	        {
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   104
		        gc.DrawText(KStatusConnecting, drawRect, vert, CGraphicsContext::ELeft, 2);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   105
		        break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   106
	        }
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   107
		    case ETrkConnectionError:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   108
	        {
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   109
		        gc.DrawText(KStatusError, drawRect, vert, CGraphicsContext::ELeft, 2);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   110
		        break;	            
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   111
	        }         
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   112
        }
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   113
		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   114
		vert += font->HeightInPixels()*1.5;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   115
		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   116
		iTrkAppView->GetConnectionMsg(buf);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   117
		_LIT(KLfCr, "\r\n");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   118
		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   119
		TPtrC ptr(buf);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   120
		TInt pos = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   121
		TInt lineStart = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   122
		TInt length = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   123
		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   124
		while (KErrNotFound != (pos = ptr.Find(KLfCr)))
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   125
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   126
			ptr.Set(&buf[lineStart], pos);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   127
			lineStart = lineStart + pos + 2;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   128
			gc.DrawText(ptr, drawRect, vert, CGraphicsContext::ELeft, 2);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   129
			vert += font->HeightInPixels();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   130
			length = buf.Length() - lineStart;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   131
			if (length > 0)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   132
			{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   133
				ptr.Set(&buf[lineStart], length);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   134
			}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   135
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   136
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   137
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   138
	gc.DiscardFont();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   139
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   140
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   141
// End of File