From 84eb685c89783f4f2e61afdefaa2c350b75ab2c7 Mon Sep 17 00:00:00 2001
From: yanmorin <yanmorin>
Date: Wed, 28 Jun 2006 18:12:35 +0000
Subject: [PATCH] Add slot/signal to stop flashing button when a call is
 hanguped

---
 src/gui/qt/PhoneLine.cpp       |  1 +
 src/gui/qt/PhoneLine.hpp       |  5 ++++-
 src/gui/qt/PhoneLineButton.cpp | 11 +++++++----
 src/gui/qt/PhoneLineButton.hpp |  4 ++++
 src/gui/qt/SFLPhoneApp.cpp     |  2 ++
 src/sipaccount.cpp             |  3 ++-
 src/sipcall.cpp                |  2 +-
 7 files changed, 21 insertions(+), 7 deletions(-)

diff --git a/src/gui/qt/PhoneLine.cpp b/src/gui/qt/PhoneLine.cpp
index 2ddd72d3ad..4fd05f29a2 100644
--- a/src/gui/qt/PhoneLine.cpp
+++ b/src/gui/qt/PhoneLine.cpp
@@ -417,6 +417,7 @@ PhoneLine::hangup(bool sendrequest)
     }
     clearCall();
   }
+  emit hanguped();
 
   clear();
   clearPeer();
diff --git a/src/gui/qt/PhoneLine.hpp b/src/gui/qt/PhoneLine.hpp
index 2a390585e2..97acd883ac 100644
--- a/src/gui/qt/PhoneLine.hpp
+++ b/src/gui/qt/PhoneLine.hpp
@@ -1,5 +1,6 @@
 /*
- *  Copyright (C) 2004-2005 Savoir-Faire Linux inc.
+ *  Copyright (C) 2004-2006 Savoir-Faire Linux inc.
+ *  Author: Yan Morin <yan.morin@savoirfairelinux.com>
  *  Author: Jean-Philippe Barrette-LaPierre
  *             <jean-philippe.barrette-lapierre@savoirfairelinux.com>
  *                                                                              
@@ -155,6 +156,8 @@ signals:
   void talkingStarted(QTime);
   void talkingStopped();
   void transfered();
+  /** when the call is hangup */
+  void hanguped();
 
 private:
   void setCall(Call *call);
diff --git a/src/gui/qt/PhoneLineButton.cpp b/src/gui/qt/PhoneLineButton.cpp
index 95cfedc132..d1dfad00b8 100644
--- a/src/gui/qt/PhoneLineButton.cpp
+++ b/src/gui/qt/PhoneLineButton.cpp
@@ -75,14 +75,12 @@ void
 PhoneLineButton::sendClicked()
 {
   if(isOn()) {
-    mIsFlashing = false;
-    mTimer->stop();
+    stopFlashing();
     emit selected(mLine);
   }
   else {
     if (mIsFlashing) {
-      mIsFlashing = false;
-      mTimer->stop();
+      stopFlashing();
       emit selected(mLine);
     } else {
       emit unselected(mLine);
@@ -90,3 +88,8 @@ PhoneLineButton::sendClicked()
   }
 }
 
+void
+PhoneLineButton::stopFlashing() {
+	mIsFlashing = false;
+	mTimer->stop();
+}
diff --git a/src/gui/qt/PhoneLineButton.hpp b/src/gui/qt/PhoneLineButton.hpp
index 19bf532f28..c7e7418970 100644
--- a/src/gui/qt/PhoneLineButton.hpp
+++ b/src/gui/qt/PhoneLineButton.hpp
@@ -55,6 +55,10 @@ public slots:
   virtual void clearToolTip();
   virtual void swap();
   virtual void sendClicked();
+  /**
+   * Stop the timer and the flashing
+   */
+  void stopFlashing();
   
 private:
   unsigned int mLine;
diff --git a/src/gui/qt/SFLPhoneApp.cpp b/src/gui/qt/SFLPhoneApp.cpp
index e26a4e3f31..6bdc8899fd 100644
--- a/src/gui/qt/SFLPhoneApp.cpp
+++ b/src/gui/qt/SFLPhoneApp.cpp
@@ -117,6 +117,8 @@ SFLPhoneApp::initConnections(SFLPhoneWindow *w)
 		     *pos, SLOT(setOn(bool)));
     QObject::connect(line, SIGNAL(backgrounded()),
 		     *pos, SLOT(suspend()));
+    QObject::connect(line, SIGNAL(hanguped()),
+		     *pos, SLOT(stopFlashing()));
     QObject::connect(line, SIGNAL(peerUpdated(QString)),
 		     *pos, SLOT(setToolTip(QString)));
     QObject::connect(line, SIGNAL(peerCleared()),
diff --git a/src/sipaccount.cpp b/src/sipaccount.cpp
index 1ace8dbedb..ba027b7f2b 100644
--- a/src/sipaccount.cpp
+++ b/src/sipaccount.cpp
@@ -54,7 +54,8 @@ SIPAccount::createVoIPLink()
 bool
 SIPAccount::registerAccount()
 {
-  if (_link && !_registered) {
+  if (_link) {
+    unregisterAccount();
     SIPVoIPLink* tmplink = dynamic_cast<SIPVoIPLink*> (_link);
     if (tmplink) {
       tmplink->setProxy(Manager::instance().getConfigString(_accountID,SIP_PROXY));
diff --git a/src/sipcall.cpp b/src/sipcall.cpp
index 7ce17a9daa..cb3fde0926 100644
--- a/src/sipcall.cpp
+++ b/src/sipcall.cpp
@@ -430,7 +430,7 @@ SIPCall::sdp_complete_message(sdp_message_t * remote_sdp, osip_message_t * msg)
         iPayload++;
       }
       if (listCodec.str().empty()) {
-        media << "m=" << remote_med->m_media << " 0 << " << remote_med->m_proto << " \r\n";
+        media << "m=" << remote_med->m_media << " 0 " << remote_med->m_proto << " \r\n";
       } else {
         // we add the media line + a=rtpmap list
         media << "m=" << remote_med->m_media << " " << getLocalExternAudioPort() << " RTP/AVP " << listCodec.str() << "\r\n";
-- 
GitLab