Commit d5fca2ee authored by llea's avatar llea

Management of the lines

parent 07cce3bb
......@@ -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();
}
}
......
......@@ -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();
// }
}
}
......
......@@ -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
///////////////////////////////////////////////////////////////////////////////
......
......@@ -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
......
......@@ -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);
}
......
......@@ -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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment