|
1 // Copyright (c) 1997-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 #include "NOTIFY.H" |
|
17 #include "ETELFAX.H" |
|
18 #include "FAX.H" |
|
19 #include "mSLOGGER.H" |
|
20 |
|
21 // |
|
22 // CFaxHayes - Fax functionality |
|
23 // |
|
24 |
|
25 void CFaxHayes::CloseFax(TAny* aObj) |
|
26 // |
|
27 // Utility func for cleanup stack |
|
28 // |
|
29 { |
|
30 ((CObject*)aObj)->Close(); |
|
31 } |
|
32 |
|
33 CFaxHayes* CFaxHayes::NewL(CCallMobileFax* aCallFaxHayes,CPhoneGlobals* aPhoneGlobals) |
|
34 // |
|
35 // Completes successfully if fax call has already been dialled creating a CETelFaxBase |
|
36 // instance, and is not called if that is not true. |
|
37 // |
|
38 { |
|
39 CFaxHayes* fax=new(ELeave) CFaxHayes(aCallFaxHayes,aPhoneGlobals); |
|
40 TCleanupItem newFaxHayesClose(CloseFax,fax); |
|
41 CleanupStack::PushL(newFaxHayesClose); |
|
42 fax->ConstructL(); |
|
43 CleanupStack::Pop(); |
|
44 return fax; |
|
45 } |
|
46 |
|
47 RHandleBase* CFaxHayes::GlobalKernelObjectHandle() |
|
48 { |
|
49 return iOwner->GlobalKernelObjectHandle(); |
|
50 } |
|
51 |
|
52 CFaxHayes::CFaxHayes(CCallMobileFax* aCallFaxHayes,CPhoneGlobals* aPhoneGlobals) |
|
53 : iPhoneGlobals(aPhoneGlobals), iOwner(aCallFaxHayes) |
|
54 {} |
|
55 |
|
56 void CFaxHayes::ConstructL() |
|
57 // |
|
58 // Used to be that CFaxHayes could not be constructed before a call had been initiated |
|
59 // ie the fax server was started and the call had a pointer to CETelFaxBase. |
|
60 // Now, to solve the problem of the fax progress being only available after phase C, |
|
61 // RFax can be opened before a call has begun to connect. So in the event of this happening, |
|
62 // each function of CFaxHayes must check that the fax server has been started. |
|
63 // |
|
64 // |
|
65 { |
|
66 LOGTEXT(_L8("CFaxHayes::ConstructL()")); |
|
67 iDataDirection = EUnknown; |
|
68 } |
|
69 |
|
70 CFaxHayes::~CFaxHayes() |
|
71 { |
|
72 iOwner->RemoveFax(this); |
|
73 iPhoneGlobals->iNotificationStore->RemoveClientFromLastEvents(this); |
|
74 } |
|
75 |
|
76 CTelObject::TReqMode CFaxHayes::ReqModeL(const TInt aIpc) |
|
77 { |
|
78 TReqMode reqMode = CFaxBase::ReqModeL(aIpc); |
|
79 if ((reqMode & KReqModeFlowControlObeyed) && iPhoneGlobals->iPhoneStatus.iDataPortLoaned) |
|
80 { |
|
81 LOGTEXT2(_L8("ReqModeL Leaving with KErrInUse as data port is loaned (aIpc=%d)"),aIpc); |
|
82 User::Leave(KErrInUse); |
|
83 } |
|
84 return reqMode; |
|
85 } |
|
86 |
|
87 TInt CFaxHayes::RegisterNotification(const TInt /*aIpc*/) |
|
88 { |
|
89 return KErrNone; |
|
90 } |
|
91 TInt CFaxHayes::DeregisterNotification(const TInt /*aIpc*/) |
|
92 { |
|
93 return KErrNone; |
|
94 } |
|
95 |
|
96 void CFaxHayes::Init() |
|
97 {} |
|
98 |
|
99 TInt CFaxHayes::CheckAndSetRegistrationParams(const TInt /*aIpc*/,const TDes8* /*aDes1*/,const TDes8* /*aDes2*/) |
|
100 { |
|
101 return KErrNone; |
|
102 } |
|
103 |
|
104 TInt CFaxHayes::Read(const TTsyReqHandle aTsyReqHandle, TDes8* aDes) |
|
105 // |
|
106 // Read fax data into descriptor, asynchronously. Use NotificationStore to notify client |
|
107 // when completed |
|
108 // |
|
109 { |
|
110 if (iOwner->iFaxSession==NULL) |
|
111 { |
|
112 ReqCompleted(aTsyReqHandle,KErrNotReady); |
|
113 return KErrNone; |
|
114 } |
|
115 LOGTEXT(_L8("Fax:\tCalling RxFaxData")); |
|
116 iDataDirection = EReceiveData; |
|
117 CFaxSession* session = iOwner->iFaxSession; |
|
118 |
|
119 iPhoneGlobals->iNotificationStore->RegisterNotification(EReadOrWriteFax,aTsyReqHandle,this); |
|
120 session->RxFaxData(*aDes); |
|
121 return KErrNone; |
|
122 } |
|
123 |
|
124 TInt CFaxHayes::Write(const TTsyReqHandle aTsyReqHandle, TDesC8* aDes) |
|
125 // |
|
126 // Send fax data in descriptor to fax module, asynchronously |
|
127 // |
|
128 { |
|
129 if (iOwner->iFaxSession==NULL) |
|
130 { |
|
131 ReqCompleted(aTsyReqHandle,KErrNotReady); |
|
132 return KErrNone; |
|
133 } |
|
134 LOGTEXT(_L8("Fax:\tCalling TxFaxData")); |
|
135 iDataDirection = ESendData; |
|
136 CFaxSession* session = iOwner->iFaxSession; |
|
137 iPhoneGlobals->iNotificationStore->RegisterNotification(EReadOrWriteFax,aTsyReqHandle,this); |
|
138 session->TxFaxData(*aDes); |
|
139 return KErrNone; |
|
140 } |
|
141 |
|
142 TInt CFaxHayes::WaitForEndOfPage(const TTsyReqHandle aTsyReqHandle) |
|
143 // |
|
144 // Send request for notification of end of page to fax module |
|
145 // |
|
146 { |
|
147 if (iOwner->iFaxSession==NULL) |
|
148 { |
|
149 ReqCompleted(aTsyReqHandle,KErrNotReady); |
|
150 return KErrNone; |
|
151 } |
|
152 LOGTEXT(_L8("Fax:\tCalling Wait for end of page")); |
|
153 CFaxSession* session = iOwner->iFaxSession; |
|
154 if (iDataDirection==EUnknown) |
|
155 { |
|
156 ReqCompleted(aTsyReqHandle,KErrUnknown); // client hasn't read or written data yet |
|
157 return KErrNone; |
|
158 } |
|
159 iPhoneGlobals->iNotificationStore->RegisterNotification(EEndOfFaxPage,aTsyReqHandle,this); |
|
160 LOGTEXT(_L8("Fax:\tEnd Of Page Notification lodged")); |
|
161 if (iDataDirection==EReceiveData) |
|
162 session->RxPostPage(); |
|
163 else |
|
164 session->TxPostPage(); |
|
165 return KErrNone; |
|
166 } |
|
167 |
|
168 TInt CFaxHayes::TerminateFaxSession(const TTsyReqHandle aTsyReqHandle) |
|
169 // |
|
170 // Cancel the entire fax session. Server completes fax notification requests that it knows |
|
171 // as notifications. TSY treats ReadOrWrite and EndOfPage as notifications although they |
|
172 // have no Cancel function, so it must remove them from its notification list here |
|
173 // explicitly |
|
174 // |
|
175 { |
|
176 if (iOwner->iFaxSession==NULL) |
|
177 { |
|
178 ReqCompleted(aTsyReqHandle,KErrNotReady); |
|
179 return KErrNone; |
|
180 } |
|
181 LOGTEXT(_L8("Fax:\tCancelling fax session")); |
|
182 CFaxSession* session= iOwner->iFaxSession; |
|
183 session->Cancel(); |
|
184 iPhoneGlobals->iNotificationStore->CheckNotification(session,EFaxSessionTerminated,KErrCancel); |
|
185 ReqCompleted(aTsyReqHandle,KErrNone); |
|
186 return KErrNone; |
|
187 } |