37
|
1 |
/*
|
|
2 |
* Copyright (c) 2006 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: Device mode handler
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
// INCLUDE FILES
|
|
21 |
#include "cpedevicemodehandler.h"
|
|
22 |
#include "cpemessagehandler.h"
|
|
23 |
#include "mpecallhandling.h"
|
|
24 |
#include <talogger.h>
|
|
25 |
#include <cteldmhandler.h>
|
|
26 |
|
|
27 |
// CONSTANTS
|
|
28 |
|
|
29 |
_LIT( KPhoneTelDevModeLoadedLib, "telephonydevicemode.dll" );
|
|
30 |
const TInt KPhoneTelDevModeOrdinal = 1;
|
|
31 |
|
|
32 |
// ============================ MEMBER FUNCTIONS ===============================
|
|
33 |
|
|
34 |
// -----------------------------------------------------------------------------
|
|
35 |
// CPEDeviceModeHandler::CPEDeviceModeHandler
|
|
36 |
// Constructor can NOT contain any code, that
|
|
37 |
// might leave.
|
|
38 |
// -----------------------------------------------------------------------------
|
|
39 |
//
|
|
40 |
CPEDeviceModeHandler::CPEDeviceModeHandler(
|
|
41 |
MPECallHandling& aCallHandling,
|
|
42 |
CPEMessageHandler& aMessageHandler
|
|
43 |
)
|
|
44 |
: iCallHandling( aCallHandling ),
|
|
45 |
iMessageHandler ( aMessageHandler)
|
|
46 |
{
|
|
47 |
}
|
|
48 |
|
|
49 |
// -----------------------------------------------------------------------------
|
|
50 |
// CPEDeviceModeHandler::ConstructL
|
|
51 |
// Symbian 2nd phase constructor can leave.
|
|
52 |
// -----------------------------------------------------------------------------
|
|
53 |
//
|
|
54 |
void CPEDeviceModeHandler::ConstructL()
|
|
55 |
{
|
|
56 |
LoadLibraryL();
|
|
57 |
}
|
|
58 |
|
|
59 |
// -----------------------------------------------------------------------------
|
|
60 |
// CPEDeviceModeHandler::NewL
|
|
61 |
// Two-phased constructor.
|
|
62 |
// -----------------------------------------------------------------------------
|
|
63 |
//
|
|
64 |
CPEDeviceModeHandler* CPEDeviceModeHandler::NewL(
|
|
65 |
MPECallHandling& aCallHandling,
|
|
66 |
CPEMessageHandler& aMessageHandler
|
|
67 |
)
|
|
68 |
{
|
|
69 |
CPEDeviceModeHandler* self = new( ELeave ) CPEDeviceModeHandler(
|
|
70 |
aCallHandling, aMessageHandler );
|
|
71 |
|
|
72 |
CleanupStack::PushL( self );
|
|
73 |
self->ConstructL();
|
|
74 |
CleanupStack::Pop( self );
|
|
75 |
|
|
76 |
return self;
|
|
77 |
}
|
|
78 |
|
|
79 |
|
|
80 |
// Destructor
|
|
81 |
CPEDeviceModeHandler::~CPEDeviceModeHandler()
|
|
82 |
{
|
|
83 |
if ( iTelDevModeHandler )
|
|
84 |
{
|
|
85 |
delete iTelDevModeHandler;
|
|
86 |
iLibrary.Close();
|
|
87 |
}
|
|
88 |
}
|
|
89 |
|
|
90 |
|
|
91 |
// -----------------------------------------------------------------------------
|
|
92 |
// CPEDeviceModeHandler::Answer
|
|
93 |
// -----------------------------------------------------------------------------
|
|
94 |
//
|
|
95 |
void CPEDeviceModeHandler::Answer()
|
|
96 |
{
|
|
97 |
TEFLOGSTRING( KTAOBJECT, "PE CPEDeviceModeHandler::Answer" );
|
|
98 |
|
|
99 |
// Checking for available ringing call is done in CallHandling,
|
|
100 |
// no need to do it here. If a ringing call was not found, the
|
|
101 |
// error code equals "ECCPErrorNotFound".
|
|
102 |
iMessageHandler.HandleAnswerCall( EFalse );
|
|
103 |
}
|
|
104 |
|
|
105 |
// -----------------------------------------------------------------------------
|
|
106 |
// CPEDeviceModeHandler::EndVoiceCalls
|
|
107 |
// -----------------------------------------------------------------------------
|
|
108 |
//
|
|
109 |
void CPEDeviceModeHandler::EndVoiceCalls()
|
|
110 |
{
|
|
111 |
TEFLOGSTRING( KTAOBJECT, "PE CPEDeviceModeHandler::EndVoiceCalls" );
|
|
112 |
|
|
113 |
if ( iCallHandling.GetNumberOfCalls() > 0 ) // there is ongoing call(s)
|
|
114 |
{
|
|
115 |
iMessageHandler.HandleReleaseAll();
|
|
116 |
}
|
|
117 |
}
|
|
118 |
|
|
119 |
// -----------------------------------------------------------------------------
|
|
120 |
// CPEDeviceModeHandler::LoadLibraryL
|
|
121 |
// -----------------------------------------------------------------------------
|
|
122 |
//
|
|
123 |
void CPEDeviceModeHandler::LoadLibraryL()
|
|
124 |
{
|
|
125 |
TEFLOGSTRING( KTAOBJECT, "PE CPEDeviceModeHandler::LoadLibraryL" );
|
|
126 |
|
|
127 |
if ( !iTelDevModeHandler )
|
|
128 |
{
|
|
129 |
|
|
130 |
User::LeaveIfError( iLibrary.Load( KPhoneTelDevModeLoadedLib ) );
|
|
131 |
|
|
132 |
TInt res = iLibrary.Lookup( KPhoneTelDevModeOrdinal )();
|
|
133 |
iTelDevModeHandler = reinterpret_cast< CTelDMHandler* >( res );
|
|
134 |
|
|
135 |
if( !iTelDevModeHandler )
|
|
136 |
{
|
|
137 |
iLibrary.Close();
|
|
138 |
// Null returned, so leave.
|
|
139 |
User::Leave( ECCPErrorNotSupported );
|
|
140 |
}
|
|
141 |
else
|
|
142 |
{
|
|
143 |
iTelDevModeHandler->SetObserverL( this );
|
|
144 |
}
|
|
145 |
}
|
|
146 |
}
|
|
147 |
|
|
148 |
// End of File
|