qs60telephony.cpp 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. #include "qs60Telephony.h"
  2. #include "qs60Telephony_p.h"
  3. #include <QDebug>
  4. #include <QTimer>
  5. /*!
  6. \class QS60Telephony
  7. \brief The QS60Telephony class can be used for establishing circuit switched calls
  8. and monitoring the status of the line. Monitoring can be started with the
  9. QS60Telephony::startMonitoringLine() function call.
  10. */
  11. /*!
  12. Constructs a QS60Telephony object with the given parent.
  13. Call error() to get the QS60Telephony::Error value that indicates if an error occurred during construction.
  14. \sa call(), error()
  15. */
  16. QS60Telephony::QS60Telephony(QObject* parent) :
  17. QObject(parent)
  18. , d(new QS60TelephonyPrivate(this))
  19. ,cStatus(StatusUnknown)
  20. {
  21. QTimer::singleShot(0, this, SLOT(startMonitoringLine()));
  22. }
  23. /*!
  24. Destroys the QS60Telephony object.
  25. */
  26. QS60Telephony::~QS60Telephony()
  27. {
  28. delete d;
  29. }
  30. /*!
  31. \enum QS60Telephony::Error
  32. This enum defines the possible errors for a QS60Telephony object.
  33. */
  34. /*! \var QS60Telephony::Error QS60Telephony::NoError
  35. No error occured.
  36. */
  37. /*! \var QS60Telephony::Error QS60Telephony::OutOfMemoryError
  38. Not enough memory.
  39. */
  40. /*! \var QS60Telephony::Error QS60Telephony::UnknownError
  41. Unknown error.
  42. */
  43. /*!
  44. \enum QS60Telephony::LineStatus
  45. This enum defines the possible line statuses
  46. */
  47. /*! \var QS60Telephony::LineStatus QS60Telephony::StatusUnknown
  48. Status is unknown.
  49. */
  50. /*! \var QS60Telephony::LineStatus QS60Telephony::StatusIdle
  51. Status is idle. No active calls.
  52. */
  53. /*! \var QS60Telephony::LineStatus QS60Telephony::StatusDialling
  54. Call dialling status.
  55. */
  56. /*! \var QS60Telephony::LineStatus QS60Telephony::StatusRinging
  57. Call ringing status.
  58. */
  59. /*! \var QS60Telephony::LineStatus QS60Telephony::StatusAnswering
  60. Call answering status.
  61. */
  62. /*! \var QS60Telephony::LineStatus QS60Telephony::StatusConnecting
  63. Call connecting status.
  64. */
  65. /*! \var QS60Telephony::LineStatus QS60Telephony::StatusConnected
  66. Call connected status.
  67. */
  68. /*! \var QS60Telephony::LineStatus QS60Telephony::StatusReconnectPending
  69. Call is undergoing temporary channel loss and it may or may not be reconnected.
  70. */
  71. /*! \var QS60Telephony::LineStatus QS60Telephony::StatusDisconnecting
  72. Call disconnecting status.
  73. */
  74. /*! \var QS60Telephony::LineStatus QS60Telephony::StatusHold
  75. Call status hold.
  76. */
  77. /*! \var QS60Telephony::LineStatus QS60Telephony::StatusTransferring
  78. Call is transferring.
  79. */
  80. /*! \var QS60Telephony::LineStatus QS60Telephony::StatusTransferAlerting
  81. Call in transfer is alerting the remote party.
  82. */
  83. /*!
  84. Initiates new call.
  85. Note: If an error occurs while the call is being established, the error() signal is emitted
  86. \param phoneNumber Telephone number to call
  87. \sa error()
  88. */
  89. void QS60Telephony::call(const QString& phoneNumber)
  90. {
  91. d->call(phoneNumber);
  92. }
  93. /*!
  94. Starts monitoring changes in the line.
  95. QS60Telephony::lineStatusChanged(QS60Telephony::LineStatus status, QString number) is emitted
  96. when there are changes in the line status(e.g. incoming call etc.).
  97. \return If false is returned, an error has occurred. Call error() to the
  98. QS60Telephony::Error value that indicates which error occurred
  99. \sa error()
  100. */
  101. bool QS60Telephony::startMonitoringLine()
  102. {
  103. return d->startMonitoringLine();
  104. }
  105. /*!
  106. Stops monitoring changes in the line status.
  107. */
  108. void QS60Telephony::stopMonitoringLine()
  109. {
  110. d->stopMonitoringLine();
  111. }
  112. QString QS60Telephony::IMEI(){
  113. return d->IMEI();
  114. }
  115. /*!
  116. Returns the type of error that occurred if the latest function call failed; otherwise returns NoError.
  117. \return Error code
  118. */
  119. QS60Telephony::Error QS60Telephony::error() const
  120. {
  121. return d->error();
  122. }
  123. /*!
  124. \fn void QS60Telephony::lineStatusChanged(QS60Telephony::LineStatus status, QString number)
  125. This signal is emitted when line status is changed.
  126. \param status Current status is retrived as enumeration
  127. \param number Number if available
  128. \sa call()
  129. */
  130. /*!
  131. \fn void QS60Telephony::error(QS60Telephony::Error error)
  132. This signal is emitted when an error occurs during a phone call, i.e. after the call() method is called.
  133. \param error Error
  134. */
  135. void QS60Telephony::answerIncomingCall(){
  136. qDebug() << "[step #3] Answering incoming call";
  137. d->answerIncomingCall();
  138. }
  139. void QS60Telephony::terminateCall(){
  140. if(cStatus == StatusRinging)
  141. d->rejectCall();
  142. else
  143. d->terminateCall();
  144. }
  145. void QS60Telephony::rejectCall(){
  146. d->rejectCall();
  147. }
  148. #ifdef RECENT_CALLS
  149. void QS60Telephony::recentCalls(){
  150. d->recentCalls();
  151. }
  152. #endif
  153. void QS60Telephony::toBackground() {
  154. d->toBackground();
  155. }
  156. void QS60Telephony::showOnTop(){
  157. QTimer::singleShot(1200, this, SLOT(showOnTopDelayed()));
  158. }
  159. void QS60Telephony::showOnTopDelayed(){
  160. d->showOnTop();
  161. }
  162. void QS60Telephony::showNormal(){
  163. d->showNormal();
  164. }
  165. // End of file