0
|
1 |
/*
|
|
2 |
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description:
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
#include <viewcli.h>
|
|
19 |
#include "trkappview.h"
|
|
20 |
#include "trkservereventlistener.h"
|
|
21 |
#include "trkdebugstatelistener.h"
|
|
22 |
#include "trkconnstatelistener.h"
|
|
23 |
|
|
24 |
CTrkAppView::CTrkAppView(RTrkSrvCliSession& aTrkSession)
|
|
25 |
: iVwsSession(NULL),
|
|
26 |
iTrkSession(aTrkSession),
|
|
27 |
iMajorVersion(0),
|
|
28 |
iMinorVersion(0),
|
|
29 |
iMajorAPIVersion(0),
|
|
30 |
iMinorAPIVersion(0),
|
|
31 |
iError(KErrNone)
|
|
32 |
{
|
|
33 |
}
|
|
34 |
|
|
35 |
CTrkAppView* CTrkAppView::NewL(const TRect& aRect, RTrkSrvCliSession& aTrkSession)
|
|
36 |
{
|
|
37 |
CTrkAppView* self = new(ELeave) CTrkAppView(aTrkSession);
|
|
38 |
CleanupStack::PushL(self);
|
|
39 |
self->ConstructL(aRect);
|
|
40 |
CleanupStack::Pop();
|
|
41 |
return self;
|
|
42 |
}
|
|
43 |
|
|
44 |
CTrkAppView::~CTrkAppView()
|
|
45 |
{
|
|
46 |
// Disconnect here
|
|
47 |
iTrkSession.DisConnect();
|
|
48 |
|
|
49 |
if (iVwsSession)
|
|
50 |
{
|
|
51 |
iVwsSession->EnableServerEventTimeOut(ETrue);
|
|
52 |
delete iVwsSession;
|
|
53 |
}
|
|
54 |
}
|
|
55 |
|
|
56 |
void CTrkAppView::ConstructL(const TRect& aRect)
|
|
57 |
{
|
|
58 |
CreateWindowL();
|
|
59 |
SetRect(aRect);
|
|
60 |
ActivateL();
|
|
61 |
|
|
62 |
iVwsSession = CVwsSessionWrapper::NewL();
|
|
63 |
|
|
64 |
iTrkSession.GetTrkVersion(iMajorVersion, iMinorVersion, iMajorAPIVersion, iMinorAPIVersion, iBuildNumber);
|
|
65 |
// Ideally we need to connect here, but when the TRK server is started, connect automatically happens.
|
|
66 |
// So we don't need to explicitly connect here. If the server is changed not to connect automatically at startup
|
|
67 |
// then we need to connect here.
|
|
68 |
//iTrkSession.Connect();
|
|
69 |
}
|
|
70 |
|
|
71 |
void CTrkAppView::Draw(const TRect& /*aRect*/) const
|
|
72 |
{
|
|
73 |
TTrkConnStatus iConnStatus;
|
|
74 |
CWindowGc& gc = SystemGc();
|
|
75 |
|
|
76 |
TRect drawRect = Rect();
|
|
77 |
|
|
78 |
gc.Clear();
|
|
79 |
|
|
80 |
const CFont *font = iEikonEnv->AnnotationFont();
|
|
81 |
gc.UseFont(font);
|
|
82 |
|
|
83 |
TBuf<KMaxPath> buf;
|
|
84 |
|
|
85 |
_LIT(KTrkWelcome,"Welcome to Trk for Symbian OS");
|
|
86 |
_LIT(KTrkVersion,"Version %d.%d.%d");
|
|
87 |
_LIT(KTrkAPIVersion,"Implementing Trk API version %d.%d");
|
|
88 |
|
|
89 |
TInt vert = 15;
|
|
90 |
|
|
91 |
gc.DrawText(KTrkWelcome, drawRect, vert);
|
|
92 |
vert += font->HeightInPixels();
|
|
93 |
buf.Format(KTrkVersion, iMajorVersion, iMinorVersion, iBuildNumber);
|
|
94 |
gc.DrawText(buf, drawRect, vert);
|
|
95 |
vert += font->HeightInPixels();
|
|
96 |
buf.Format(KTrkAPIVersion, iMajorAPIVersion, iMinorAPIVersion);
|
|
97 |
gc.DrawText(buf, drawRect, vert);
|
|
98 |
vert += font->HeightInPixels()*2;
|
|
99 |
|
|
100 |
iTrkSession.GetDebugConnStatus(iConnStatus, buf);
|
|
101 |
|
|
102 |
_LIT(KLfCr, "\r\n");
|
|
103 |
|
|
104 |
TPtrC ptr(buf);
|
|
105 |
TInt pos = 0;
|
|
106 |
TInt lineStart = 0;
|
|
107 |
TInt length = 0;
|
|
108 |
|
|
109 |
while (KErrNotFound != (pos = ptr.Find(KLfCr)))
|
|
110 |
{
|
|
111 |
ptr.Set(&buf[lineStart], pos);
|
|
112 |
lineStart = lineStart + pos + 2;
|
|
113 |
gc.DrawText(ptr, drawRect, vert);
|
|
114 |
vert += font->HeightInPixels();
|
|
115 |
length = buf.Length() - lineStart;
|
|
116 |
if (length > 0)
|
|
117 |
{
|
|
118 |
ptr.Set(&buf[lineStart], length);
|
|
119 |
}
|
|
120 |
}
|
|
121 |
|
|
122 |
gc.DiscardFont();
|
|
123 |
|
|
124 |
iVwsSession->EnableServerEventTimeOut(EFalse);
|
|
125 |
}
|