From 915d76cb273276b95cdb376384735a07214f406f Mon Sep 17 00:00:00 2001 From: yanmorin <yanmorin> Date: Thu, 23 Feb 2006 06:12:12 +0000 Subject: [PATCH] Nicer debugging message. Save registration data before registring. Move Call Enumeration to Call Class. Receive register failed/succeed message --- src/call.cpp | 6 +++--- src/call.h | 12 ++++++------ src/global.h | 6 +++--- src/gui/qt/ConfigurationPanel.ui.h | 3 +++ src/gui/qt/PhoneLineManagerImpl.cpp | 4 ++++ src/gui/qt/Request.cpp | 16 +++++++--------- src/gui/qt/SFLEvents.cpp | 23 ++++++++++++++++++++++- src/gui/qt/SFLEvents.hpp | 21 ++++++++++++++++++++- src/gui/qt/TCPSessionIO.cpp | 8 ++++---- src/managerimpl.cpp | 6 +++--- src/managerimpl.h | 2 +- src/sipvoiplink.cpp | 13 ++++++++----- 12 files changed, 84 insertions(+), 36 deletions(-) diff --git a/src/call.cpp b/src/call.cpp index 09419400b2..38332db002 100644 --- a/src/call.cpp +++ b/src/call.cpp @@ -23,7 +23,7 @@ #include "call.h" #include "voIPLink.h" -Call::Call (CALLID id, CallType type, VoIPLink* voiplink) +Call::Call (CALLID id, Call::CallType type, VoIPLink* voiplink) { _state = NotExist; _type = Null; @@ -108,14 +108,14 @@ Call::setState (Call::CallState state) _state = state; } -enum CallType +Call::CallType Call::getType (void) { return _type; } void -Call::setType (enum CallType type) +Call::setType (Call::CallType type) { _type = type; } diff --git a/src/call.h b/src/call.h index 0baa2b22ff..d6cf60513f 100644 --- a/src/call.h +++ b/src/call.h @@ -25,17 +25,17 @@ typedef unsigned int CALLID; -enum CallType { - Null = 0, - Incoming, - Outgoing -}; - class VoIPLink; class Call { public: + enum CallType { + Null = 0, + Incoming, + Outgoing + }; + enum CallState { NotExist = 0, Busy, diff --git a/src/global.h b/src/global.h index 39d782cf86..63c4afcc8b 100644 --- a/src/global.h +++ b/src/global.h @@ -28,9 +28,9 @@ typedef float float32; typedef short int16; #ifdef DEBUG - #define _debug(...) fprintf(stderr, "[sflphoned] " __VA_ARGS__) - #define _debugException(...) fprintf(stderr, "[sflphoned-exception] " __VA_ARGS__ "\n") - #define _debugInit(...) fprintf(stderr, "[sflphoned-init] " __VA_ARGS__ "\n") + #define _debug(...) fprintf(stderr, "[sfl-debug] " __VA_ARGS__) + #define _debugException(...) fprintf(stderr, "[sfl-excep] " __VA_ARGS__ "\n") + #define _debugInit(...) fprintf(stderr, "[sfl-init.] " __VA_ARGS__ "\n") #else #define _debug(...) #define _debugException(...) diff --git a/src/gui/qt/ConfigurationPanel.ui.h b/src/gui/qt/ConfigurationPanel.ui.h index 96da497b9f..a6ee2f3379 100644 --- a/src/gui/qt/ConfigurationPanel.ui.h +++ b/src/gui/qt/ConfigurationPanel.ui.h @@ -110,8 +110,11 @@ void ConfigurationPanel::init() "About", Menu); + // we save the configuration, then we try to register + QObject::connect(buttonRegister, SIGNAL(clicked()), this, SLOT(saveSlot())); QObject::connect(buttonRegister, SIGNAL(clicked()), this, SIGNAL(needRegister())); + } void diff --git a/src/gui/qt/PhoneLineManagerImpl.cpp b/src/gui/qt/PhoneLineManagerImpl.cpp index 4853a6beab..960c763a18 100644 --- a/src/gui/qt/PhoneLineManagerImpl.cpp +++ b/src/gui/qt/PhoneLineManagerImpl.cpp @@ -51,6 +51,10 @@ PhoneLineManagerImpl::PhoneLineManagerImpl() EventFactory::instance().registerEvent< CallRelatedEvent >("000"); EventFactory::instance().registerEvent< IncommingEvent >("001"); EventFactory::instance().registerEvent< HangupEvent >("002"); + + EventFactory::instance().registerEvent< RegisterSucceededEvent >("003"); + EventFactory::instance().registerEvent< RegisterFailedEvent >("004"); + // TODO: 020 EventFactory::instance().registerEvent< LoadSetupEvent >("010"); EventFactory::instance().registerEvent< CallRelatedEvent >("020"); diff --git a/src/gui/qt/Request.cpp b/src/gui/qt/Request.cpp index 9c0ed301f8..c563888a43 100644 --- a/src/gui/qt/Request.cpp +++ b/src/gui/qt/Request.cpp @@ -54,9 +54,9 @@ Request::parseArgs(const QString &message) void Request::onError(const QString &code, const QString &message) { - DebugOutput::instance() << QObject::tr("Received an error:\n " - "Code: %1\n " - "SequenceID: %2\n Message: %3\n") + DebugOutput::instance() << QObject::tr("Received an error: " + "Code/SeqID: %1/%2\t" + "Message: %3\n") .arg(code) .arg(mSequenceId) .arg(message); @@ -67,9 +67,8 @@ Request::onError(const QString &code, const QString &message) void Request::onEntry(const QString &code, const QString &message) { - DebugOutput::instance() << QObject::tr("Received a temp info:\n " - "Code: %1\n " - "SequenceID: %2\n " + DebugOutput::instance() << QObject::tr("Received a temp info: " + "Code/SeqID: %1/%2\t" "Message: %3\n") .arg(code) .arg(mSequenceId) @@ -106,9 +105,8 @@ Request::onEntry(const QString &code, const QString &message) void Request::onSuccess(const QString &code, const QString &message) { - DebugOutput::instance() << QObject::tr("Received a success info:\n " - "Code: %1\n " - "SequenceID: %2\n " + DebugOutput::instance() << QObject::tr("Received a success info: " + "Code/SeqID: %1/%2\t" "Message: %3\n") .arg(code) .arg(mSequenceId) diff --git a/src/gui/qt/SFLEvents.cpp b/src/gui/qt/SFLEvents.cpp index ccfd0bb81a..c1d52729ac 100644 --- a/src/gui/qt/SFLEvents.cpp +++ b/src/gui/qt/SFLEvents.cpp @@ -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> * @@ -56,6 +57,26 @@ HangupEvent::execute() } } +RegisterSucceededEvent::RegisterSucceededEvent(const QString &code, const std::list< QString > &args) + : Event(code, args) +{} + +void +RegisterSucceededEvent::execute() +{ + DebugOutput::instance() << QObject::tr("Register succedded\n"); +} + +RegisterFailedEvent::RegisterFailedEvent(const QString &code, const std::list< QString > &args) + : Event(code, args) +{} + +void +RegisterFailedEvent::execute() +{ + DebugOutput::instance() << QObject::tr("Register failed\n"); +} + IncommingEvent::IncommingEvent(const QString &code, const std::list< QString > &args) : CallRelatedEvent(code, args) diff --git a/src/gui/qt/SFLEvents.hpp b/src/gui/qt/SFLEvents.hpp index ee5cb0c05c..a853eee346 100644 --- a/src/gui/qt/SFLEvents.hpp +++ b/src/gui/qt/SFLEvents.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> * @@ -42,6 +43,24 @@ public: virtual void execute(); }; +class RegisterSucceededEvent : public Event +{ +public: + RegisterSucceededEvent(const QString &code, + const std::list< QString > &args); + + virtual void execute(); +}; + +class RegisterFailedEvent : public Event +{ +public: + RegisterFailedEvent(const QString &code, + const std::list< QString > &args); + + virtual void execute(); +}; + class IncommingEvent : public CallRelatedEvent { public: diff --git a/src/gui/qt/TCPSessionIO.cpp b/src/gui/qt/TCPSessionIO.cpp index 4b4321b41a..85e8f830a0 100644 --- a/src/gui/qt/TCPSessionIO.cpp +++ b/src/gui/qt/TCPSessionIO.cpp @@ -111,8 +111,8 @@ TCPSessionIO::send(const QString &request) { QTextStream stream(mSocket); if(mSocket->state() == QSocket::Connected) { - DebugOutput::instance() << QObject::tr("TCPSessioIO: Sending request to sflphone: %1") - .arg(request); +// DebugOutput::instance() << QObject::tr("TCPSessioIO: Sending request to sflphone: %1") +// .arg(request); stream << request; mSocket->flush(); } @@ -127,8 +127,8 @@ TCPSessionIO::receive(QString &answer) if(mSocket->isReadable()) { QTextStream stream(mSocket); answer = stream.readLine(); - DebugOutput::instance() << QObject::tr("TCPSessionIO: Received answer from sflphone: %1\n") - .arg(answer); +// DebugOutput::instance() << QObject::tr("TCPSessionIO: Received answer from sflphone: %1\n") +// .arg(answer); } } diff --git a/src/managerimpl.cpp b/src/managerimpl.cpp index bbca606f1f..b78e62a801 100644 --- a/src/managerimpl.cpp +++ b/src/managerimpl.cpp @@ -198,7 +198,7 @@ ManagerImpl::setGui(GuiFramework* gui) * Multi Thread with _mutex for callVector */ Call * -ManagerImpl::pushBackNewCall(CALLID id, enum CallType type) +ManagerImpl::pushBackNewCall(CALLID id, Call::CallType type) { ost::MutexLock m(_mutex); Call* call = new Call(id, type, _voIPLinkVector.at(DFT_VOIP_LINK)); @@ -278,7 +278,7 @@ ManagerImpl::outgoingCall (const std::string& to) { CALLID id = generateNewCallId(); _debug("%10d: Outgoing Call\n", id); - Call *call = pushBackNewCall(id, Outgoing); + Call *call = pushBackNewCall(id, Call::Outgoing); ost::MutexLock m(_mutex); call->setState(Call::Progressing); call->setCallerIdNumber(to); @@ -736,7 +736,7 @@ ManagerImpl::incomingCall (CALLID id, const std::string& name, const std::string if (call == NULL) { return -1; } - call->setType(Incoming); + call->setType(Call::Incoming); call->setState(Call::Progressing); if ( _currentCallId == 0 ) { diff --git a/src/managerimpl.h b/src/managerimpl.h index df0351628a..a77210bb2a 100644 --- a/src/managerimpl.h +++ b/src/managerimpl.h @@ -106,7 +106,7 @@ public: /* * Add a new call at the end of the CallVector with identifiant 'id' */ - Call* pushBackNewCall (CALLID id, enum CallType type); + Call* pushBackNewCall (CALLID id, Call::CallType type); void callSetInfo(CALLID id, const std::string& name, const std::string& number); bool callCanBeAnswered(CALLID id); bool callCanBeClosed(CALLID id); diff --git a/src/sipvoiplink.cpp b/src/sipvoiplink.cpp index ef066a15dc..6d1af281dd 100644 --- a/src/sipvoiplink.cpp +++ b/src/sipvoiplink.cpp @@ -100,10 +100,15 @@ SipVoIPLink::init(void) } else { _debug("VoIP Link listen on port %d\n", DEFAULT_SIP_PORT); } + // Set user agent std::string tmp = std::string(PROGNAME_GLOBAL) + "/" + std::string(SFLPHONED_VERSION); eXosip_set_user_agent(tmp.data()); + if ( !checkNetwork() ) { + return false; + } + // If use STUN server, firewall address setup if (Manager::instance().useStun()) { if (behindNat() != 1) { @@ -113,9 +118,6 @@ SipVoIPLink::init(void) eXosip_masquerade_contact((Manager::instance().getFirewallAddress()).data(), Manager::instance().getFirewallPort()); } - if ( !checkNetwork() ) { - return false; - } _debug("SIP VoIP Link: listen to SIP Events\n"); _evThread->start(); return true; @@ -192,13 +194,14 @@ SipVoIPLink::setRegister (void) return EXOSIP_ERROR_STD; } - _debug("REGISTER From: %s\n", from.data()); osip_message_t *reg = NULL; eXosip_lock(); if (!manager.getConfigString(SIGNALISATION, PROXY).empty()) { + _debug("REGISTER From: %s to %s\n", from.data(), proxy.data()); _reg_id = eXosip_register_build_initial_register ((char*)from.data(), (char*)proxy.data(), NULL, EXPIRES_VALUE, ®); } else { + _debug("REGISTER From: %s to %s\n", from.data(), hostname.data()); _reg_id = eXosip_register_build_initial_register ((char*)from.data(), (char*)hostname.data(), NULL, EXPIRES_VALUE, ®); } @@ -675,7 +678,7 @@ SipVoIPLink::getEvent (void) // Generate id id = Manager::instance().generateNewCallId(); - Manager::instance().pushBackNewCall(id, Incoming); + Manager::instance().pushBackNewCall(id, Call::Incoming); _debug("%10d: [cid = %d, did = %d]\n", id, event->cid, event->did); // Associate an audio port with a call -- GitLab