From 73e1a44ba88b65fb8760032046960743054c3b71 Mon Sep 17 00:00:00 2001
From: llea <llea>
Date: Mon, 24 Jan 2005 23:06:13 +0000
Subject: [PATCH] Display name for From header

---
 src/audiodriversoss.cpp      |  1 +
 src/audiortp.cpp             | 13 ++++++++-----
 src/configurationpanelui.cpp |  2 +-
 src/configurationpanelui.h   |  2 +-
 src/global.h                 |  2 +-
 src/manager.cpp              |  6 ++++++
 src/manager.h                |  1 +
 src/mydisplay.cpp            |  5 +++++
 src/mydisplay.h              |  1 +
 src/phonebookui.cpp          |  2 +-
 src/phonebookui.h            |  2 +-
 src/qtGUImainwindow.cpp      | 10 +++++-----
 src/sip.cpp                  | 29 ++++++++++++++++++++++-------
 src/tonegenerator.cpp        | 11 ++++++-----
 src/url_inputui.cpp          |  2 +-
 src/url_inputui.h            |  2 +-
 16 files changed, 62 insertions(+), 29 deletions(-)

diff --git a/src/audiodriversoss.cpp b/src/audiodriversoss.cpp
index 85af0d3eff..d25d117584 100644
--- a/src/audiodriversoss.cpp
+++ b/src/audiodriversoss.cpp
@@ -296,6 +296,7 @@ AudioDriversOSS::writeBuffer (void) {
 	
 	size_t count = audio_buf.getSize();
 	short *buf = (short*)audio_buf.getData();
+	
 
 	audio_buf_info info;
 	if (ioctl(audio_fd, SNDCTL_DSP_GETOSPACE, &info) == 0 ) {
diff --git a/src/audiortp.cpp b/src/audiortp.cpp
index ed8ded9297..a07487d6ec 100644
--- a/src/audiortp.cpp
+++ b/src/audiortp.cpp
@@ -70,7 +70,9 @@ AudioRtp::createNewSession (SipCall *ca) {
 
 	RTXThread = new AudioRtpRTX (ca, manager->audiodriver, manager, symetric);
 	qDebug("-- START SOUND --");
-	RTXThread->start();
+	if (RTXThread->start() != 0) {
+		return -1;
+	}
 		
 	return 0;
 }
@@ -83,7 +85,7 @@ AudioRtp::closeRtpSession (SipCall *ca) {
 
 	if (RTXThread != NULL) {
 		// Wait for them...and delete.
-	//	RTXThread->join();
+		//RTXThread->join();
 		delete RTXThread;
 		RTXThread = NULL;
 	}
@@ -182,7 +184,7 @@ AudioRtpRTX::run (void) {
 	} else {
 		qDebug("RTP(Recv): Added destination %s:%d",
 				remote_ip.getHostname(),
-				(unsigned short) ca->remote_sdp_audio_port)
+				(unsigned short) ca->remote_sdp_audio_port);
 	}
 #endif
 
@@ -243,6 +245,7 @@ AudioRtpRTX::run (void) {
 		if (!manager->mute) {
 		//	i = audioDevice->readBuffer (320);
 		//	data_from_mic = (short*)manager->audiodriver->audio_buf.getData();
+		//	qDebug("audiortp data_from_mic 0x%d", data_from_mic);
 			i = audioDevice->readBuffer (data_from_mic, 320);
 		} else {
 			// When IP-phone user click on mute button, we read buffer of a
@@ -288,8 +291,8 @@ AudioRtpRTX::run (void) {
 		// Write decoded data to sound device
 		manager->audiodriver->audio_buf.resize(expandedSize);
 		manager->audiodriver->audio_buf.setData (data_for_speakers);
-		i = audioDevice->writeBuffer (data_for_speakers, expandedSize);
-	//	i = audioDevice->writeBuffer ();
+	//	i = audioDevice->writeBuffer (data_for_speakers, expandedSize);
+		i = audioDevice->writeBuffer ();
 		delete adu;
 
 
diff --git a/src/configurationpanelui.cpp b/src/configurationpanelui.cpp
index fc7081ec53..7f54afff74 100644
--- a/src/configurationpanelui.cpp
+++ b/src/configurationpanelui.cpp
@@ -1,7 +1,7 @@
 /****************************************************************************
 ** Form implementation generated from reading ui file 'configurationpanel.ui'
 **
-** Created: Fri Jan 21 17:23:55 2005
+** Created: Mon Jan 24 17:46:09 2005
 **      by: The User Interface Compiler ($Id$)
 **
 ** WARNING! All changes made in this file will be lost!
diff --git a/src/configurationpanelui.h b/src/configurationpanelui.h
index 3ba1cb12dc..df69df351d 100644
--- a/src/configurationpanelui.h
+++ b/src/configurationpanelui.h
@@ -1,7 +1,7 @@
 /****************************************************************************
 ** Form interface generated from reading ui file 'configurationpanel.ui'
 **
-** Created: Fri Jan 21 17:23:55 2005
+** Created: Mon Jan 24 17:46:09 2005
 **      by: The User Interface Compiler ($Id$)
 **
 ** WARNING! All changes made in this file will be lost!
diff --git a/src/global.h b/src/global.h
index 1a72ef742c..a6496a1b07 100644
--- a/src/global.h
+++ b/src/global.h
@@ -24,7 +24,7 @@
 #define PREFIX					"/usr/local"
 #endif
 
-#define VERSION					"0.1"
+#define VERSION					"0.2"
 #define PROGNAME				"SFLPhone"
 #define SKINDIR					"skins"
 #define PIXDIR					"pixmaps"
diff --git a/src/manager.cpp b/src/manager.cpp
index c087ec0fd4..8c857a1fab 100644
--- a/src/manager.cpp
+++ b/src/manager.cpp
@@ -519,3 +519,9 @@ void
 Manager::errorDisplay (char *error) {
 	gui()->lcd->appendText(error);
 }
+
+void
+Manager::nameDisplay (char *name) {
+	gui()->lcd->clearBuffer();
+	gui()->lcd->appendText(name);
+}
diff --git a/src/manager.h b/src/manager.h
index fdab46f6ab..2bbadfb168 100644
--- a/src/manager.h
+++ b/src/manager.h
@@ -90,6 +90,7 @@ public:
 	void	startDialTone			(void);
 	void	congestion				(bool); 
 	void	errorDisplay			(char*);
+	void	nameDisplay				(char*);
 
 private:
 	bool	b_ringing;
diff --git a/src/mydisplay.cpp b/src/mydisplay.cpp
index 98279dcf4e..f8187fc951 100644
--- a/src/mydisplay.cpp
+++ b/src/mydisplay.cpp
@@ -370,6 +370,11 @@ MyDisplay::clear (void) {
 	setStatus(QString(FREE_STATUS));
 }
 
+void
+MyDisplay::clearBuffer (void) {
+	this->textBuffer->remove(0, this->textBuffer->length());
+}
+
 void
 MyDisplay::clear (const QString &newstatus) {
 	// Remove everything in the buffer and set the new status.
diff --git a/src/mydisplay.h b/src/mydisplay.h
index 4126e6b0da..4bcf8afaa5 100644
--- a/src/mydisplay.h
+++ b/src/mydisplay.h
@@ -69,6 +69,7 @@ public slots:
 	void	 appendText	(const char *);
 	void	 appendText	(const QChar &);
 	void	 clear		(void);
+	void	 clearBuffer(void);
 	void	 clear		(const QString &);
 	void 	 backspace	(void);
 
diff --git a/src/phonebookui.cpp b/src/phonebookui.cpp
index b1afebd972..3eeff6ebfd 100644
--- a/src/phonebookui.cpp
+++ b/src/phonebookui.cpp
@@ -1,7 +1,7 @@
 /****************************************************************************
 ** Form implementation generated from reading ui file 'phonebook.ui'
 **
-** Created: Fri Jan 21 17:23:55 2005
+** Created: Mon Jan 24 17:46:08 2005
 **      by: The User Interface Compiler ($Id$)
 **
 ** WARNING! All changes made in this file will be lost!
diff --git a/src/phonebookui.h b/src/phonebookui.h
index 47a243e6ae..301cdadd49 100644
--- a/src/phonebookui.h
+++ b/src/phonebookui.h
@@ -1,7 +1,7 @@
 /****************************************************************************
 ** Form interface generated from reading ui file 'phonebook.ui'
 **
-** Created: Fri Jan 21 17:23:55 2005
+** Created: Mon Jan 24 17:46:08 2005
 **      by: The User Interface Compiler ($Id$)
 **
 ** WARNING! All changes made in this file will be lost!
diff --git a/src/qtGUImainwindow.cpp b/src/qtGUImainwindow.cpp
index eab03e8060..8806ff414b 100644
--- a/src/qtGUImainwindow.cpp
+++ b/src/qtGUImainwindow.cpp
@@ -1046,12 +1046,12 @@ QtGUIMainWindow::pressedKeySlot (int id) {
 	// Handle dtmf
 	key->startTone(code);
 	key->generateDTMF(buf, SAMPLING_RATE);
-//	callmanager->audiodriver->audio_buf.resize(SAMPLING_RATE);
-//	callmanager->audiodriver->audio_buf.setData (buf);
+	callmanager->audiodriver->audio_buf.resize(SAMPLING_RATE);
+	callmanager->audiodriver->audio_buf.setData (buf);
 	pulselen = Config::get("Signalisations", "DTMF.pulseLength", 250);
-//	callmanager->audiodriver->audio_buf.resize(pulselen * (OCTETS/1000));
-	a = callmanager->audiodriver->writeBuffer(buf, pulselen * (OCTETS/1000));
-//	a = callmanager->audiodriver->writeBuffer();
+	callmanager->audiodriver->audio_buf.resize(pulselen * (OCTETS/1000));
+//	a = callmanager->audiodriver->writeBuffer(buf, pulselen * (OCTETS/1000));
+	a = callmanager->audiodriver->writeBuffer();
 	if (a == 1) {
 		pressedKeySlot(id);
 	} else {
diff --git a/src/sip.cpp b/src/sip.cpp
index 76e624bef0..5fdfabec6f 100644
--- a/src/sip.cpp
+++ b/src/sip.cpp
@@ -290,8 +290,6 @@ int
 SIP::checkURI (const char *buffer) {
 	osip_uri_t *uri;
 	int 		i;
-	char 	   *dest = NULL;
-	QString		qdest;
 
 	// To parse a buffer containing a sip URI
 	i = osip_uri_init(&uri);
@@ -306,7 +304,6 @@ SIP::checkURI (const char *buffer) {
 
 	// Free memory
 	osip_uri_free(uri);	
-	osip_free(dest);
 	return 0;	
 }
 
@@ -326,6 +323,9 @@ SIP::checkUrl(char *url) {
 		qWarning ("Cannot parse url");
 		return -1;
 	}
+
+	// Free memory
+	osip_from_free (to);
   	return 0;
 }
 
@@ -421,7 +421,8 @@ SIP::setAuthentication (void) {
 		
 string
 SIP::fromHeader (string user, string host) {
-	return ("sip:" + user + "@" + host);
+	string displayname = Config::gets("Signalisations", "SIP.fullName");
+	return ("\"" + displayname + "\"" + " <sip:" + user + "@" + host + ">");
 }
 
 
@@ -623,13 +624,16 @@ SIP::manageActions (int usedLine, int action) {
 	case ONHOLD_CALL:
 		call[usedLine]->usehold = true;
 		
+		qDebug("ON HOLD CALL 0x%d, usedLine = %d", call[usedLine], usedLine);
+
 		eXosip_lock();
 		i = eXosip_on_hold_call(call[usedLine]->did);
 		eXosip_unlock();
 		
 		// Disable audio
-		call[usedLine]->enable_audio = -1;
-		callmanager->closeSound(call[usedLine]);
+		//call[usedLine]->enable_audio = -1;
+		//callmanager->closeSound(call[usedLine]);
+		call[usedLine]->closedCall();
 		break;
 
 	// IP-Phone user is parking peer OFF HOLD
@@ -692,6 +696,7 @@ SIP::getEvent (void) {
 	eXosip_event_t *event;
 	int theline = -1;
 	int curLine;
+	char *name;
 	static int countReg = 0;
 
 	event = eXosip_event_wait (0, 50);
@@ -719,6 +724,15 @@ SIP::getEvent (void) {
 			}
 			assert (theline >= 0); assert (theline < NUMBER_OF_LINES);
 
+			// Display the name which the call comes from
+			osip_from_t *from;
+  			osip_from_init(&from);
+  			osip_from_parse(from, event->remote_uri);
+			name = osip_from_get_displayname(from);
+			callmanager->nameDisplay(name);
+			callmanager->phLines[theline]->text = QString(name);
+			osip_from_free(from);
+			
 			if (call[theline] == NULL) {
 				//callmanager->setCallInProgress(true);
 				callmanager->phLines[theline]->setbInProgress(true);
@@ -928,7 +942,8 @@ SIP::getEvent (void) {
 			qDebug("<- (%i %i) INVITE (On Hold) from: %s", event->cid, 
 				event->did, event->remote_uri);
 			theline = findLineNumber(event);
-			callmanager->closeSound(call[theline]);
+			//callmanager->closeSound(call[theline]);
+			call[theline]->closedCall();
 			call[theline]->onholdCall(event);
 			break;
 
diff --git a/src/tonegenerator.cpp b/src/tonegenerator.cpp
index 82175fd08a..74b746828b 100644
--- a/src/tonegenerator.cpp
+++ b/src/tonegenerator.cpp
@@ -38,13 +38,14 @@ ToneThread::ToneThread (Manager *mngr, short *buf, int total) {
 }
 
 ToneThread::~ToneThread (void) {
+	this->terminate();
 }
 
 void
 ToneThread::run (void) {
 	while (mngr->tonezone) {
-		//mngr->audiodriver->writeBuffer();
-		mngr->audiodriver->writeBuffer(buf, totalbytes);
+		mngr->audiodriver->writeBuffer();
+		//mngr->audiodriver->writeBuffer(buf, totalbytes);
 	}
 }
 
@@ -229,13 +230,13 @@ ToneGenerator::toneHandle (int idr) {
 		// New thread for the tone
 		if (tonethread == NULL) {
 			tonethread = new ToneThread (manager, buf, totalbytes);
-		//	manager->audiodriver->audio_buf.resize(totalbytes);	
-		//	manager->audiodriver->audio_buf.setData (buf);	
+			manager->audiodriver->audio_buf.resize(totalbytes);	
+			manager->audiodriver->audio_buf.setData (buf);	
 			tonethread->start();
 		}
 
 		if (!manager->tonezone) {
-			tonethread->join();	
+			//tonethread->join();	
 			if (tonethread != NULL) {	
 				delete tonethread;
 				tonethread = NULL;
diff --git a/src/url_inputui.cpp b/src/url_inputui.cpp
index c1d8a9ef49..99fbd3f6fb 100644
--- a/src/url_inputui.cpp
+++ b/src/url_inputui.cpp
@@ -1,7 +1,7 @@
 /****************************************************************************
 ** Form implementation generated from reading ui file 'url_input.ui'
 **
-** Created: Fri Jan 21 17:23:55 2005
+** Created: Mon Jan 24 17:46:09 2005
 **      by: The User Interface Compiler ($Id$)
 **
 ** WARNING! All changes made in this file will be lost!
diff --git a/src/url_inputui.h b/src/url_inputui.h
index 2ba0e4605b..c6e1c2fc6f 100644
--- a/src/url_inputui.h
+++ b/src/url_inputui.h
@@ -1,7 +1,7 @@
 /****************************************************************************
 ** Form interface generated from reading ui file 'url_input.ui'
 **
-** Created: Fri Jan 21 17:23:55 2005
+** Created: Mon Jan 24 17:46:09 2005
 **      by: The User Interface Compiler ($Id$)
 **
 ** WARNING! All changes made in this file will be lost!
-- 
GitLab