24
|
1 |
/*
|
|
2 |
* Copyright (c) 2005-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 |
|
|
19 |
#include <cdbcols.h>
|
|
20 |
#include <e32base.h>
|
|
21 |
#include <e32def.h>
|
|
22 |
|
|
23 |
// User Includes
|
|
24 |
#include "T_RTelServerData.h"
|
|
25 |
|
|
26 |
/*@{*/
|
|
27 |
//LIT's for commands
|
|
28 |
_LIT(KCmdConnect, "Connect");
|
|
29 |
_LIT(KCmdClose, "Close");
|
|
30 |
/*}@*/
|
|
31 |
|
|
32 |
/**
|
|
33 |
* Two phase constructor
|
|
34 |
*
|
|
35 |
* @leave system wide error
|
|
36 |
*/
|
|
37 |
CT_RTelServerData* CT_RTelServerData::NewL()
|
|
38 |
{
|
|
39 |
CT_RTelServerData* ret = new (ELeave) CT_RTelServerData();
|
|
40 |
CleanupStack::PushL(ret);
|
|
41 |
ret->ConstructL();
|
|
42 |
CleanupStack::Pop(ret);
|
|
43 |
return ret;
|
|
44 |
}
|
|
45 |
|
|
46 |
|
|
47 |
/**
|
|
48 |
* Protected constructor. First phase construction
|
|
49 |
*/
|
|
50 |
CT_RTelServerData::CT_RTelServerData()
|
|
51 |
: iTelServer(NULL)
|
|
52 |
{
|
|
53 |
}
|
|
54 |
|
|
55 |
/**
|
|
56 |
* Second phase construction
|
|
57 |
*
|
|
58 |
* @internalComponent
|
|
59 |
*
|
|
60 |
* @return N/A
|
|
61 |
*
|
|
62 |
* @pre None
|
|
63 |
* @post None
|
|
64 |
*
|
|
65 |
* @leave system wide error
|
|
66 |
*/
|
|
67 |
void CT_RTelServerData::ConstructL()
|
|
68 |
{
|
|
69 |
iTelServer = new (ELeave) RTelServer();
|
|
70 |
}
|
|
71 |
|
|
72 |
/**
|
|
73 |
* Public destructor
|
|
74 |
*/
|
|
75 |
CT_RTelServerData::~CT_RTelServerData()
|
|
76 |
{
|
|
77 |
if(iTelServer)
|
|
78 |
{
|
|
79 |
delete iTelServer;
|
|
80 |
iTelServer = NULL;
|
|
81 |
}
|
|
82 |
}
|
|
83 |
|
|
84 |
/**
|
|
85 |
* Return a pointer to the object that the data wraps
|
|
86 |
*
|
|
87 |
* @return pointer to the object that the data wraps
|
|
88 |
*/
|
|
89 |
TAny* CT_RTelServerData::GetObject()
|
|
90 |
{
|
|
91 |
return iTelServer;
|
|
92 |
}
|
|
93 |
|
|
94 |
TBool CT_RTelServerData::DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& /*aSection*/, const TInt /*aAsyncErrorIndex*/)
|
|
95 |
{
|
|
96 |
TBool ret = ETrue;
|
|
97 |
|
|
98 |
if ( aCommand==KCmdConnect )
|
|
99 |
{
|
|
100 |
DoCmdConnect();
|
|
101 |
}
|
|
102 |
else if ( aCommand==KCmdClose )
|
|
103 |
{
|
|
104 |
DoCmdClose();
|
|
105 |
}
|
|
106 |
else
|
|
107 |
{
|
|
108 |
ret = EFalse;
|
|
109 |
ERR_PRINTF1(_L("Unknown command"));
|
|
110 |
}
|
|
111 |
|
|
112 |
return ret;
|
|
113 |
}
|
|
114 |
|
|
115 |
|
|
116 |
void CT_RTelServerData::DoCmdConnect()
|
|
117 |
{
|
|
118 |
INFO_PRINTF1(_L("*START*CT_RTelServerData::DoCmdOpenTelServer"));
|
|
119 |
if(iTelServer->Handle())
|
|
120 |
{
|
|
121 |
ERR_PRINTF1(_L("Handle to the telephony server exists"));
|
|
122 |
SetBlockResult(EFail);
|
|
123 |
}
|
|
124 |
else
|
|
125 |
{
|
|
126 |
// Connect to RTelServer server. This will also start the server if needed.
|
|
127 |
INFO_PRINTF1(_L("Connecting to the telephony server (ETel)"));
|
|
128 |
TRAPD( error, iTelServer->Connect() );
|
|
129 |
// Report if loading failed.
|
|
130 |
if (error != KErrNone)
|
|
131 |
{
|
|
132 |
ERR_PRINTF2(_L("Failed to load TSY with error %d"), error);
|
|
133 |
SetError(error);
|
|
134 |
}
|
|
135 |
else
|
|
136 |
{
|
|
137 |
INFO_PRINTF1(_L("The root server is up for sure and telephony server is started."));
|
|
138 |
}
|
|
139 |
}
|
|
140 |
INFO_PRINTF1(_L("*END*CT_RTelServerData::DoCmdOpenTelServer"));
|
|
141 |
}
|
|
142 |
|
|
143 |
void CT_RTelServerData::DoCmdClose()
|
|
144 |
{
|
|
145 |
INFO_PRINTF1(_L("*START*CT_RTelServerData::DoCmdCloseTelServer"));
|
|
146 |
INFO_PRINTF1(_L("Closing telephony server session..."));
|
|
147 |
iTelServer->Close();
|
|
148 |
INFO_PRINTF1(_L("*END*CT_RTelServerData::DoCmdCloseTelServer"));
|
|
149 |
}
|
|
150 |
|