diff --git a/src/audiortp.cpp b/src/audiortp.cpp index 9529188602ffca46aa266f5f625dc3c0ab28602d..36ce858d1806f15cca15f6ded9719a38cd966717 100644 --- a/src/audiortp.cpp +++ b/src/audiortp.cpp @@ -161,7 +161,7 @@ AudioRtpRTX::run (void) { timestamp; int expandedSize; short *data_for_speakers = NULL; - unsigned int countTime = 0; + int countTime = 0; data_for_speakers = new short[2048]; data_from_mic = new short[1024]; data_from_mic_tmp = new short[1024]; @@ -330,7 +330,8 @@ AudioRtpRTX::run (void) { // Notify (with a bip) an incoming call when there is already a call countTime += time->getSecond(); if (manager->getNumberPendingCalls() != 1 and manager->ringing()) { - if ((countTime % 2000) <= 10 and (countTime % 2000) > 0) { + countTime = countTime % 2000; + if (countTime < 10 and countTime > 0) { manager->notificationIncomingCall(); } } diff --git a/src/manager.cpp b/src/manager.cpp index b27f3f73eac4f69d75aa3014ad3e0b00894353d4..810fcb6ff1475e66f5f65d5dcf5a74f993f76a57 100644 --- a/src/manager.cpp +++ b/src/manager.cpp @@ -389,6 +389,7 @@ Manager::getNumberPendingCalls (void) { void Manager::handleRemoteEvent (int code, char * reason, int remotetype, int line) { QString qinfo; + int theline; switch (remotetype) { // Registration success @@ -414,28 +415,37 @@ Manager::handleRemoteEvent (int code, char * reason, int remotetype, int line) { case EXOSIP_CALL_CLOSED: if (sip->getNumberPendingCalls() == 0 or !phLines[line]->isOnHold()) { - // Show HUNGUP_STATUS if there's not pending call - // or line is not onhold + // Show HUNGUP_STATUS if there's not pending call + // or line is not onhold gui()->lcd->clear(QString(HUNGUP_STATUS)); + if (getCurrentLineNumber() != -1 and line != getCurrentLineNumber()) { + // To show current status and phone number + gui()->lcd->appendText(phLines[getCurrentLineNumber()]->text); + gui()->lcd->setStatus(phLines[getCurrentLineNumber()]->status); + } } if (phLines[line]->getbInProgress()) { this->ring(false); phLines[line]->setbRinging(false); - gui()->setFreeStateLine(newCallLineNumber()); + // gui()->setFreeStateLine(newCallLineNumber()); + gui()->setFreeStateLine(line); + //setCallInProgress(false); phLines[line]->setbInProgress(false); } else { + if (line == getCurrentLineNumber()) { + // set free line + gui()->setCurrentLineNumber(-1); + } // Stop call timer gui()->stopCallTimer(line); // set state free pixmap line - gui()->setFreeStateLine(line); - // set free line - gui()->setCurrentLineNumber(-1); + gui()->setFreeStateLine(line); } phLines[line]->setbDial(false); - sip->notUsedLine = -1; + break; // Remote call ringing @@ -449,7 +459,7 @@ Manager::handleRemoteEvent (int code, char * reason, int remotetype, int line) { } // If dialog is established - if (code == 101) { + if (code == DIALOG_ESTABLISHED) { gui()->lcd->setStatus(RINGING_STATUS); // if error code } else { @@ -467,9 +477,17 @@ Manager::handleRemoteEvent (int code, char * reason, int remotetype, int line) { // Store the status of current line if(getCurrentLineNumber() != -1) { - phLines[getCurrentLineNumber()]->status = getStatusRender(); - //qDebug("line[%d] status: %s", getCurrentLineNumber(), - // (phLines[getCurrentLineNumber()]->status).ascii()); +/* if (remotetype == EXOSIP_CALL_NEW) { + theline = line; + } else { + theline = getCurrentLineNumber(); + } + if ((code != REQ_TERMINATED and code != DIALOG_ESTABLISHED) + or line == getCurrentLineNumber()) {*/ + // If the remote-user close its remote call. + // phLines[theline]->status = getStatusRender(); + phLines[getCurrentLineNumber()]->status = getStatusRender(); + // } } } diff --git a/src/mydisplay.cpp b/src/mydisplay.cpp index b29a3cb7f3193fd8bef6d61445b8339a8f1817cf..455ecd4785ca7fdc54d29aa75321b6a36dac0887 100644 --- a/src/mydisplay.cpp +++ b/src/mydisplay.cpp @@ -34,6 +34,9 @@ #define TEXT_LINE 2 #define TIMER_LINE 4 #define FONT_FAMILY "Courier" +//#define FONT_FAMILY "Monospace" +//#define FONT_FAMILY "Fixed" +//#define FONT_FAMILY "MiscFixed" #define FONT_SIZE 10 /////////////////////////////////////////////////////////////////////////////// diff --git a/src/qtGUImainwindow.cpp b/src/qtGUImainwindow.cpp index fa9bdb4232871831c527cedeb5d99b5d15e29d6a..6c1b6e2a9c5abc3f7b4832785bdc2053d0723c96 100644 --- a/src/qtGUImainwindow.cpp +++ b/src/qtGUImainwindow.cpp @@ -680,7 +680,7 @@ QtGUIMainWindow::toggleLine (int num_line) { /** * Actions occur when click on hang off button. - * Use for validate incoming and outgoing call, transfer call. + * Use to validate incoming and outgoing call, transfer call. */ void QtGUIMainWindow::dial (void) { @@ -695,7 +695,7 @@ QtGUIMainWindow::dial (void) { qDebug("GUI: LINE CURRENT %d", currentLineNumber); if (callmanager->ringing()) { - // If new incoming call + // If new incoming call currentLineNumber = callmanager->newCallLineNumber(); toggleLine (currentLineNumber); // Set used-state pixmap 'currentLineNumber' line @@ -710,28 +710,39 @@ QtGUIMainWindow::dial (void) { // NOTHING } else { // If new outgoing call - i = callmanager->outgoingNewCall(); - if (i == 0) { - // If outgoing call succeeded - if (!choose) { - // If find not used line - noChoose = true; - currentLineNumber = callmanager->findLineNumberNotUsed(); - } else { - // If choose line - currentLineNumber = chosenLine; - } - callmanager->phLines[currentLineNumber]->text = - callmanager->bufferTextRender(); - - callmanager->phLines[currentLineNumber]->setbDial(true); - toggleLine (currentLineNumber); + + if (callmanager->bufferTextRender() != "") { + // If a phone number is entered - callmanager->phLines[currentLineNumber]->setbInProgress(true); - // Set used-state pixmap 'currentLineNumber' line - callmanager->phLines[currentLineNumber]->button()->setPixmap( - TabLinePixmap[currentLineNumber][BUSY]); - callmanager->phLines[currentLineNumber]->setState(BUSY); + // To make outgoing call + i = callmanager->outgoingNewCall(); + + if (i == 0) { + // If outgoing call succeeded + if (!choose) { + // If find not used line + noChoose = true; + currentLineNumber=callmanager->findLineNumberNotUsed(); + } else { + // If choose line + currentLineNumber = chosenLine; + } + + // Store the phone number + callmanager->phLines[currentLineNumber]->text = + callmanager->bufferTextRender(); + + // Dial button is clicked + callmanager->phLines[currentLineNumber]->setbDial(true); + // Main function + toggleLine (currentLineNumber); + // Call in progress + callmanager->phLines[currentLineNumber]->setbInProgress(true); + // Set used-state pixmap 'currentLineNumber' line + callmanager->phLines[currentLineNumber]->button()->setPixmap( + TabLinePixmap[currentLineNumber][BUSY]); + callmanager->phLines[currentLineNumber]->setState(BUSY); + } } } } @@ -961,15 +972,18 @@ QtGUIMainWindow::button_mute(void) { // Disable micro sound static bool isOn = true; - if(!isOn) { - callmanager->mute = false; - lcd->clear("Mute off"); - } else { - callmanager->mute = true; - lcd->clear("Mute on"); + if (callmanager->sip->getNumberPendingCalls() != 0) { + // If there is at least a pending call + if(!isOn) { + callmanager->mute = false; + lcd->clear("Mute off"); + } else { + callmanager->mute = true; + lcd->clear("Mute on"); + } + + isOn = !isOn; } - - isOn = !isOn; } // Show the setup panel diff --git a/src/sip.cpp b/src/sip.cpp index 94bcc2e52e0d67e21cc027926cc77ccb3b513d0a..40f473ea094bdb6ad9161b1340ee0388ffb17e1a 100644 --- a/src/sip.cpp +++ b/src/sip.cpp @@ -759,6 +759,8 @@ SIP::getEvent (void) { callmanager->phLines[theline]->setbInProgress(true); call[theline] = new SipCall (callmanager); call[theline]->newIncomingCall(event); + // callmanager->handleRemoteEvent ( + // 0, NULL, EXOSIP_CALL_NEW, theline); // Associate an audio port with a call call[theline]->setLocalAudioPort(local_port); @@ -955,7 +957,8 @@ SIP::getEvent (void) { call[theline]->closedCall(); } else { // If caller closes call before callee answers - theline = notUsedLine; + //theline = notUsedLine; + theline = findLineNumber(event); // Stop ringTone callmanager->ringTone(false); } diff --git a/src/sip.h b/src/sip.h index 9f9338ce71ab2a01d4931d41c253bcc032d36688..f91b2360c9e38adc0c704e3daf9ea13087830eed 100644 --- a/src/sip.h +++ b/src/sip.h @@ -51,6 +51,8 @@ using namespace ost; #define CANCEL_CALL 5 #define REFUSE_CALL 6 +// 1XX responses +#define DIALOG_ESTABLISHED 101 // 4XX Errors #define FORBIDDEN 403 #define NOT_FOUND 404