24
|
1 |
// Copyright (c) 1999-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".
|
|
7 |
//
|
|
8 |
// Initial Contributors:
|
|
9 |
// Nokia Corporation - initial contribution.
|
|
10 |
//
|
|
11 |
// Contributors:
|
|
12 |
//
|
|
13 |
// Description:
|
|
14 |
//
|
|
15 |
|
|
16 |
// @file
|
|
17 |
// @test
|
|
18 |
|
|
19 |
#include "smsstackbasetestserver.h"
|
|
20 |
#include <test/TestExecuteStepBase.h>
|
|
21 |
#include <e32def.h>
|
|
22 |
#include <commsdattypesv1_1.h>
|
|
23 |
#include <commsdat_partner.h>
|
|
24 |
|
|
25 |
using namespace CommsDat;
|
|
26 |
|
|
27 |
EXPORT_C CSmsStackTestServer::CSmsStackTestServer()
|
|
28 |
{
|
|
29 |
}
|
|
30 |
|
|
31 |
EXPORT_C CSmsStackTestServer::~CSmsStackTestServer()
|
|
32 |
{
|
|
33 |
iPhone1.Close();
|
|
34 |
iPhone2.Close();
|
|
35 |
iTelServer.Close();
|
|
36 |
}
|
|
37 |
|
|
38 |
EXPORT_C void CSmsStackTestServer::InitializeTsyAndPhonesL()
|
|
39 |
/**
|
|
40 |
* This functions first gets the list of TSYs from Commsdat and then load each TSY in order.
|
|
41 |
* Having loaded the TSY, the function opens a phone session to this TSY.
|
|
42 |
* Maximum two TSYs are loaded. If there is only one TSY, aPhone2 parameter is not changed.
|
|
43 |
*/
|
|
44 |
{
|
|
45 |
TInt err = iTelServer.Connect();
|
|
46 |
|
|
47 |
if ( KErrNone != err )
|
|
48 |
{
|
|
49 |
ERR_PRINTF2(_L("Couldn't connect to ETel server. Error:%d"), err);
|
|
50 |
User::Leave( err );
|
|
51 |
}
|
|
52 |
|
|
53 |
RArray<TName> tsyNameList;
|
|
54 |
CleanupClosePushL(tsyNameList);
|
|
55 |
|
|
56 |
GetTsyNamesFromCommsdatL(tsyNameList);
|
|
57 |
|
|
58 |
TInt tsyCount = tsyNameList.Count();
|
|
59 |
|
|
60 |
if( tsyCount < 1 )
|
|
61 |
{
|
|
62 |
ERR_PRINTF1(_L("Couldn't find any TSY record in Commsdat Baseband table."));
|
|
63 |
User::Leave( KErrNotFound );
|
|
64 |
}
|
|
65 |
else if ( tsyCount > 2)
|
|
66 |
{
|
|
67 |
ERR_PRINTF2(_L("Found %d baseband record. First two TSY will be loaded."), tsyCount);
|
|
68 |
}
|
|
69 |
|
|
70 |
LoadTsyL(iTelServer, iPhone1, tsyNameList[0]);
|
|
71 |
if(--tsyCount)
|
|
72 |
{
|
|
73 |
LoadTsyL(iTelServer, iPhone2, tsyNameList[1]);
|
|
74 |
}
|
|
75 |
|
|
76 |
CleanupStack::PopAndDestroy(&tsyNameList);
|
|
77 |
}
|
|
78 |
|
|
79 |
void CSmsStackTestServer::GetTsyNamesFromCommsdatL(RArray<TName>& aTsyNameList)
|
|
80 |
{
|
|
81 |
CMDBSession* db = CMDBSession::NewL(KCDVersion1_2);
|
|
82 |
CleanupStack::PushL(db);
|
|
83 |
|
|
84 |
TName tsy;
|
|
85 |
TUint32 modemId = 0;
|
|
86 |
|
|
87 |
CMDBField<TUint32>* globalSettingsField = new(ELeave) CMDBField<TUint32>(KCDTIdModemPhoneServicesSMS);
|
|
88 |
CleanupStack::PushL(globalSettingsField);
|
|
89 |
globalSettingsField->SetRecordId(1);
|
|
90 |
globalSettingsField->LoadL(*db);
|
|
91 |
modemId = *globalSettingsField;
|
|
92 |
CleanupStack::PopAndDestroy(globalSettingsField);
|
|
93 |
|
|
94 |
CMDBField<TDesC>* tsyField = new(ELeave) CMDBField<TDesC>(KCDTIdTsyName);
|
|
95 |
CleanupStack::PushL(tsyField);
|
|
96 |
tsyField->SetRecordId(modemId);
|
|
97 |
tsyField->SetMaxLengthL(KMaxTextLength);
|
|
98 |
tsyField->LoadL(*db);
|
|
99 |
tsy = *tsyField;
|
|
100 |
aTsyNameList.AppendL(tsy);
|
|
101 |
|
|
102 |
CleanupStack::PopAndDestroy(2, db); // db, tsyField
|
|
103 |
}
|
|
104 |
|
|
105 |
void CSmsStackTestServer::LoadTsyL(RTelServer& aServer, RPhone& aPhone, const TDesC& aTsyName)
|
|
106 |
{
|
|
107 |
INFO_PRINTF2(_L("Using TSY \"%S\"Loading RTelServer..."), &aTsyName);
|
|
108 |
|
|
109 |
TInt ret = aServer.LoadPhoneModule(aTsyName);
|
|
110 |
if (ret!=KErrNone)
|
|
111 |
{
|
|
112 |
ERR_PRINTF2(_L("Loading Phone Module returned %d"), ret);
|
|
113 |
User::Leave(ret);
|
|
114 |
}
|
|
115 |
|
|
116 |
// Find the phone corresponding to this TSY and open a number of handles on it
|
|
117 |
TInt numPhones;
|
|
118 |
ret = aServer.EnumeratePhones(numPhones);
|
|
119 |
if (ret!=KErrNone)
|
|
120 |
{
|
|
121 |
ERR_PRINTF2(_L("Enumerate Phones returned %d"), ret);
|
|
122 |
User::Leave(ret);
|
|
123 |
}
|
|
124 |
|
|
125 |
TBool found=EFalse;
|
|
126 |
|
|
127 |
while (numPhones--)
|
|
128 |
{
|
|
129 |
TName phoneTsy;
|
|
130 |
ret = aServer.GetTsyName(numPhones,phoneTsy);
|
|
131 |
if (ret!=KErrNone)
|
|
132 |
{
|
|
133 |
ERR_PRINTF2(_L("GetTsyName returned %d"), ret);
|
|
134 |
User::Leave(ret);
|
|
135 |
}
|
|
136 |
|
|
137 |
if (phoneTsy.CompareF(aTsyName)==KErrNone)
|
|
138 |
{
|
|
139 |
INFO_PRINTF1(_L("Found RPhone..."));
|
|
140 |
found = ETrue;
|
|
141 |
RTelServer::TPhoneInfo info;
|
|
142 |
ret = aServer.GetPhoneInfo(numPhones,info);
|
|
143 |
if (ret!=KErrNone)
|
|
144 |
{
|
|
145 |
ERR_PRINTF2(_L("GetPhoneInfo returned %d"), ret);
|
|
146 |
User::Leave(ret);
|
|
147 |
}
|
|
148 |
ret = aPhone.Open(aServer,info.iName);
|
|
149 |
if (ret!=KErrNone)
|
|
150 |
{
|
|
151 |
ERR_PRINTF2(_L("Opening phone returned %d"), ret);
|
|
152 |
User::Leave(ret);
|
|
153 |
}
|
|
154 |
|
|
155 |
INFO_PRINTF1(_L("Initializing..."));
|
|
156 |
ret = aPhone.Initialise();
|
|
157 |
TTimeIntervalMicroSeconds32 InitPause=9000000; //Required Pause to Allow SMSStack to Complete its Async Init
|
|
158 |
User::After(InitPause); //call to the TSY and finish its StartUp.
|
|
159 |
if (ret!=KErrNone)
|
|
160 |
{
|
|
161 |
ERR_PRINTF2(_L("Completed Initialize returned %d"), ret);
|
|
162 |
User::Leave(ret);
|
|
163 |
}
|
|
164 |
break;
|
|
165 |
}
|
|
166 |
}
|
|
167 |
|
|
168 |
if(!found)
|
|
169 |
{
|
|
170 |
ERR_PRINTF2(_L("Couldn't find the phone for TSY %S"), &aTsyName);
|
|
171 |
}
|
|
172 |
}
|