qs60telephony_p.cpp 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. #include "qs60Telephony_p.h"
  2. #include <EIKENV.H>
  3. #include <e32base.h>
  4. #include <QDebug>
  5. QS60TelephonyPrivate::QS60TelephonyPrivate(QS60Telephony* telephony) :
  6. q(telephony)
  7. {
  8. iTelephony = CTelephony::NewL();
  9. iTelephonyMonitor = new CTelephonyMonitor(*this, iTelephony);
  10. iCallDialer = new CCallDialer(*this, iTelephony);
  11. iCallAnswerer = new CCallAnswerer(*this, iTelephony);
  12. iCallTerminator = new CCallTerminator(*this, iTelephony);
  13. #ifdef RECENT_CALLS
  14. iRecentCalls = CRecentCalls::NewL();
  15. #endif
  16. }
  17. QS60TelephonyPrivate::~QS60TelephonyPrivate()
  18. {
  19. delete iCallDialer;
  20. delete iCallAnswerer;
  21. delete iCallTerminator;
  22. delete iTelephonyMonitor;
  23. delete iTelephony;
  24. }
  25. bool QS60TelephonyPrivate::startMonitoringLine()
  26. {
  27. TRAP(iError,
  28. if (!iTelephonyMonitor) {
  29. iTelephonyMonitor = new CTelephonyMonitor(*this, iTelephony);
  30. }
  31. iTelephonyMonitor->StartListening();
  32. )
  33. return (iError == KErrNone);
  34. }
  35. void QS60TelephonyPrivate::stopMonitoringLine()
  36. {
  37. delete iTelephonyMonitor;
  38. iTelephonyMonitor == NULL;
  39. }
  40. void QS60TelephonyPrivate::call(const QString& phoneNumber)
  41. {
  42. TPtrC16 textPtr(reinterpret_cast<const TUint16*>(phoneNumber.utf16()));
  43. TRAP(iError,
  44. if (!iCallDialer) {
  45. //iCallDialer = CCallDialer::NewL(*this);
  46. iCallDialer = new CCallDialer(*this, iTelephony);
  47. }
  48. iCallDialer->Call(textPtr);
  49. )
  50. }
  51. void QS60TelephonyPrivate::answerIncomingCall(){
  52. qDebug() << "[step #4] Answering incoming call";
  53. TRAP(iError,
  54. if (!iCallAnswerer) {
  55. iCallAnswerer = new CCallAnswerer(*this, iTelephony);
  56. }
  57. iCallAnswerer->Answer();
  58. )
  59. }
  60. void QS60TelephonyPrivate::terminateCall() {
  61. TRAP(iError,
  62. if (!iCallTerminator) {
  63. iCallTerminator = new CCallTerminator(*this, iTelephony);
  64. }
  65. iCallTerminator->Terminate();
  66. )
  67. }
  68. void QS60TelephonyPrivate::rejectCall() {
  69. TRAP(iError,
  70. if (!iCallTerminator) {
  71. iCallTerminator = new CCallTerminator(*this, iTelephony);
  72. }
  73. iCallTerminator->Reject();
  74. )
  75. }
  76. void QS60TelephonyPrivate::TelephonyStatusChangedL(
  77. CTelephony::TCallStatus aStatus, const TDesC& number){
  78. QString callerNumber = QString::fromUtf16(number.Ptr(), number.Length());
  79. q->cStatus = static_cast<QS60Telephony::LineStatus>(aStatus);
  80. emit q->lineStatusChanged(static_cast<QS60Telephony::LineStatus>(aStatus), callerNumber);
  81. }
  82. void QS60TelephonyPrivate::CallDialedL(TInt aError)
  83. {
  84. iError = aError;
  85. if (iError != KErrNone) {
  86. emit q->error(error());
  87. }
  88. }
  89. void QS60TelephonyPrivate::CallAnsweredL(TInt aError)
  90. {
  91. iError = aError;
  92. if (iError == KErrNone) {
  93. emit q->answered();
  94. } else {
  95. emit q->error(error());
  96. }
  97. }
  98. void QS60TelephonyPrivate::CallTerminatedL(TInt aError)
  99. {
  100. iError = aError;
  101. if (iError == KErrNone) {
  102. emit q->terminated();
  103. } else {
  104. emit q->error(error());
  105. }
  106. }
  107. void QS60TelephonyPrivate::CallRejectedL(TInt aError)
  108. {
  109. iError = aError;
  110. if (iError == KErrNone) {
  111. emit q->terminated();
  112. } else {
  113. emit q->error(error());
  114. }
  115. }
  116. void QS60TelephonyPrivate::ErrorOccuredL(TInt aError)
  117. {
  118. iError = aError;
  119. emit q->error(error());
  120. }
  121. QS60Telephony::Error QS60TelephonyPrivate::error()
  122. {
  123. qDebug() << "Error#"<<QString::number(iError);
  124. switch (iError) {
  125. case KErrNone:
  126. return QS60Telephony::NoError;
  127. case KErrNoMemory:
  128. return QS60Telephony::OutOfMemoryError;
  129. case KErrAccessDenied:
  130. return QS60Telephony::AccessDeniedError;
  131. case KErrTimedOut:
  132. return QS60Telephony::TimedOutError;
  133. default:
  134. return QS60Telephony::UnknownError;
  135. }
  136. }
  137. #ifdef RECENT_CALLS
  138. void QS60TelephonyPrivate::recentCalls(){
  139. TRAP(iError,
  140. if (!iRecentCalls) {
  141. iRecentCalls = CRecentCalls::NewL();
  142. }
  143. iRecentCalls->ReadRecentEventsL();
  144. )
  145. }
  146. #endif
  147. void QS60TelephonyPrivate::toBackground() {
  148. CEikonEnv::Static()->RootWin().SetOrdinalPosition(-1, ECoeWinPriorityNormal);
  149. qDebug() << "toBackground";
  150. }
  151. void QS60TelephonyPrivate::showNormal() {
  152. CEikonEnv::Static()->RootWin().SetOrdinalPosition(0, ECoeWinPriorityNormal);
  153. qDebug() << "showNormal";
  154. }
  155. void QS60TelephonyPrivate::showOnTop() {
  156. CEikonEnv::Static()->RootWin().SetOrdinalPosition(0, ECoeWinPriorityAlwaysAtFront);
  157. qDebug() << "showOnTop";
  158. }
  159. QString QS60TelephonyPrivate::IMEI(){
  160. TBuf<25> iIMEI;
  161. CIMEIApp::GetIMEI(iIMEI);
  162. QString qimei((QChar*)iIMEI.Ptr(),iIMEI.Length());
  163. return qimei;
  164. }
  165. // End of file