|
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 |
|
120 TInt error(0); |
|
121 if(iTelServer->Handle()) |
|
122 { |
|
123 ERR_PRINTF1(_L("Handle to the telephony server exists")); |
|
124 SetBlockResult(EFail); |
|
125 } |
|
126 else |
|
127 { |
|
128 // Connect to RTelServer server. This will also start the server if needed. |
|
129 INFO_PRINTF1(_L("Connecting to the telephony server (ETel)")); |
|
130 error = iTelServer->Connect(); |
|
131 // Report if loading failed. |
|
132 if (error != KErrNone) |
|
133 { |
|
134 ERR_PRINTF2(_L("Failed to load TSY with error %d"), error); |
|
135 SetError(error); |
|
136 } |
|
137 else |
|
138 { |
|
139 INFO_PRINTF1(_L("The root server is up for sure and telephony server is started.")); |
|
140 } |
|
141 } |
|
142 INFO_PRINTF1(_L("*END*CT_RTelServerData::DoCmdOpenTelServer")); |
|
143 } |
|
144 |
|
145 void CT_RTelServerData::DoCmdClose() |
|
146 { |
|
147 INFO_PRINTF1(_L("*START*CT_RTelServerData::DoCmdCloseTelServer")); |
|
148 INFO_PRINTF1(_L("Closing telephony server session...")); |
|
149 iTelServer->Close(); |
|
150 INFO_PRINTF1(_L("*END*CT_RTelServerData::DoCmdCloseTelServer")); |
|
151 } |
|
152 |