|
1 /* |
|
2 * Copyright (c) 2007 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: Implements the class CEtelIncomingCallMonitor |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "etelincomingcallmonitor.h" |
|
19 #include <etelmmcs.h> |
|
20 #include <QDebug> |
|
21 |
|
22 // --------------------------------------------------------------------------- |
|
23 // Destructs the object by canceling first ongoing monitoring. |
|
24 // --------------------------------------------------------------------------- |
|
25 // |
|
26 CEtelIncomingCallMonitor::~CEtelIncomingCallMonitor( ) |
|
27 { |
|
28 Cancel(); |
|
29 iLine.Close(); |
|
30 iServer.Close(); |
|
31 } |
|
32 |
|
33 // --------------------------------------------------------------------------- |
|
34 // Starts the monitor. |
|
35 // --------------------------------------------------------------------------- |
|
36 // |
|
37 void CEtelIncomingCallMonitor::StartMonitoring() |
|
38 { |
|
39 if ( !IsActive() ) |
|
40 { |
|
41 iCallName.Zero(); |
|
42 iLine.NotifyIncomingCall( iStatus, iCallName ); |
|
43 SetActive(); |
|
44 } |
|
45 |
|
46 } |
|
47 // --------------------------------------------------------------------------- |
|
48 // From CActive. |
|
49 // Handles line status change notifying. |
|
50 // --------------------------------------------------------------------------- |
|
51 // |
|
52 void CEtelIncomingCallMonitor::RunL() |
|
53 { |
|
54 |
|
55 qDebug () << "CEtelIncomingCallMonitor::RunL<<"; |
|
56 if ( iStatus == KErrNone ) |
|
57 { |
|
58 RMobileCall mobilecall; |
|
59 TInt ret = mobilecall.OpenExistingCall(iLine,iCallName); |
|
60 qDebug() << "CEtelIncomingCallMonitor::RunL_OpenExistingCall_ret:" << ret; |
|
61 ret = mobilecall.AnswerIncomingCall(); |
|
62 qDebug() << "CEtelIncomingCallMonitor::RunL_AnswerIncomingCall_ret:" << ret; |
|
63 mobilecall.Close(); |
|
64 // Continue monitoring |
|
65 StartMonitoring(); |
|
66 } |
|
67 qDebug () << "CEtelIncomingCallMonitor::RunL>>"; |
|
68 } |
|
69 |
|
70 // --------------------------------------------------------------------------- |
|
71 // From CActive |
|
72 // Canceling functionality. |
|
73 // --------------------------------------------------------------------------- |
|
74 // |
|
75 void CEtelIncomingCallMonitor::DoCancel() |
|
76 { |
|
77 if ( iStatus == KRequestPending ) |
|
78 { |
|
79 iLine.NotifyIncomingCallCancel(); |
|
80 } |
|
81 } |
|
82 |
|
83 // --------------------------------------------------------------------------- |
|
84 // Constructs the monitor. |
|
85 // --------------------------------------------------------------------------- |
|
86 // |
|
87 CEtelIncomingCallMonitor::CEtelIncomingCallMonitor( |
|
88 /*RMobileLine& aLine, |
|
89 TInt aLineId */) : |
|
90 CActive( EPriorityStandard + 2 ) |
|
91 |
|
92 { |
|
93 CActiveScheduler::Add( this ); |
|
94 const TInt KNbrOfMessageSlots = 128; |
|
95 TInt phoneCount( 0 ); |
|
96 |
|
97 |
|
98 int errorCode = iServer.Connect( KNbrOfMessageSlots ); |
|
99 |
|
100 RMobilePhone mobilePhone; |
|
101 errorCode = iServer.EnumeratePhones( phoneCount ); |
|
102 errorCode = iServer.GetPhoneInfo( phoneCount-1, iPhoneInfo ); |
|
103 errorCode = mobilePhone.Open( iServer, iPhoneInfo.iName ); |
|
104 int error = iLine.Open( mobilePhone,_L("Voice1")); |
|
105 } |
|
106 |
|
107 // End of File |