diff --git a/src/call.cpp b/src/call.cpp index 09419400b2e8f9c6039934513dccd97c45d02af5..38332db002c852c0c406aab9565f77a8f9a0400e 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 0baa2b22ff4c6163f804982b27483e1dd955b860..d6cf60513f750c296819cf0248313aabf48e5399 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 39d782cf86a843841867421af288b8766c2cf29f..63c4afcc8b8bf2a84cd0f1b615c084644a49c9bc 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 96da497b9f3b5137e191bd559b190e70e4fac02c..a6ee2f33799eaafaa6762cbc1403c3c9a83a6ee4 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 4853a6beab09afe5d2c89b9bdcb9157285180ccf..960c763a18311301099694e3f6a876ed531ce2fb 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 9c0ed301f8f539aebf518033f655a1ef54e26fda..c563888a432483931cb9fdee805972f59f354775 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 ccfd0bb81aedb1b898f5943c6ca95a4228aef89b..c1d52729acb03c532ff1102fbc20b17ea04c6268 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 ee5cb0c05cad793293f08adab4621f59a587fa93..a853eee34674255b372489e77c2289640c5686e2 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 4b4321b41afa11e4adc1a52d07b1fdabcd98df79..85e8f830a0bd6ddbd8ba0bea9f17de1cfe680534 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 bbca606f1f82a87ac5984fba8b00fae0897f375d..b78e62a8017d342e8db31dc7a95f6329a6882eb0 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 df0351628ac9464194040a0519884476ce55cf90..a77210bb2af0c70da348a91e6a68e896c6e71510 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 ef066a15dc2715dd73ad1c6b2c4eab3b754025a9..6d1af281dd0341dd47bdf9ff3c717b20f2529864 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