diff --git a/src/Makefile.am b/src/Makefile.am index 6460e289263b63d2a814e8719e82c54407309f68..8f20fe4465ab1b29af063b16ccdb7431083848f2 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,11 +1,19 @@ -SUBDIRS = audio gui - bin_PROGRAMS = sflphone if MAINTENER_CODE maintener_source = endif +if USE_ZEROCONF +SUBDIRS = audio gui zeroconf +ZEROCONFLIB = zeroconf/libzeroconf.la +ZEROCONFFLAGS = -DUSE_ZEROCONF +else +SUBDIRS = audio gui +ZEROCONFLIB = +ZEROCONFFLAGS = +endif + sflphone_SOURCES = \ configitem.cpp \ configuration.cpp \ @@ -39,10 +47,10 @@ sflphone_SOURCES = \ -sflphone_CXXFLAGS = -DPREFIX=\"$(prefix)\" -DPROGSHAREDIR=\"${datadir}/sflphone\" +sflphone_CXXFLAGS = -DPREFIX=\"$(prefix)\" -DPROGSHAREDIR=\"${datadir}/sflphone\" $(ZEROCONFFLAGS) sflphone_LDFLAGS = $(QT_LDFLAGS) $(X_LDFLAGS) -static -sflphone_LDADD = gui/libguiframework.la audio/libaudio.la ../stund/libstun.la ../utilspp/libutilspp.la -lpthread $(LIBQT) $(SFLPHONE_LIBS) -KDE_CXXFLAGS = $(USE_EXCEPTIONS) +sflphone_LDADD = gui/libguiframework.la audio/libaudio.la ../stund/libstun.la ../utilspp/libutilspp.la -lpthread $(LIBQT) $(SFLPHONE_LIBS) $(ZEROCONFLIB) $(LIB_DNSSD) +KDE_CXXFLAGS = $(USE_EXCEPTIONS) AM_CPPFLAGS = $(QT_INCLUDES) $(X_INCLUDES) -I$(top_srcdir) -Igui/qt -I$(srcdir)/audio/pacpp/include $(libccext2_CFLAGS) $(libccgnu2_CFLAGS) $(portaudio_CFLAGS) diff --git a/src/configurationtree.cpp b/src/configurationtree.cpp index efeff9b164d438c490994753ba8555118eeaa0ca..ce0bf8ff52fdeebcf8f493b072eb3f1d3b5b3f41 100644 --- a/src/configurationtree.cpp +++ b/src/configurationtree.cpp @@ -59,6 +59,7 @@ ConfigurationTree::populateFromFile (const string& fileName) { fileName.c_str()); return 0; } + file.close(); return 2; } @@ -114,7 +115,6 @@ ConfigurationTree::saveToFile (const string& fileName) { } _head->saveToFile (&file); - file.close(); return 1; } diff --git a/src/managerimpl.cpp b/src/managerimpl.cpp index edf87d109955606d237e904718a824060d663920..179f6d7757f8d510ad844bc91ecde873389c04f2 100644 --- a/src/managerimpl.cpp +++ b/src/managerimpl.cpp @@ -50,6 +50,10 @@ #include "voIPLink.h" #include "gui/guiframework.h" +#ifdef USE_ZEROCONF +#include "zeroconf/DNSService.h" +#endif + using namespace std; using namespace ost; @@ -61,6 +65,10 @@ ManagerImpl::ManagerImpl (void) // Init private variables _error = new Error(); _tone = new ToneGenerator(); + +#ifdef USE_ZEROCONF + _DNSService = new DNSService(); +#endif _nCalls = 0; _nCodecs = 0; @@ -96,12 +104,16 @@ ManagerImpl::~ManagerImpl (void) delete _error; delete _tone; delete _audiodriverPA; +#ifdef USE_ZEROCONF + delete _DNSService; +#endif } void ManagerImpl::init (void) { terminate(); + initZeroconf(); // Set a sip voip link by default _voIPLinkVector.push_back(new SipVoIPLink(DFT_VOIP_LINK)); @@ -110,11 +122,6 @@ ManagerImpl::init (void) _debug("Cannot create config file in your home directory\n"); } - if (_exist == 2) { - // If config-file doesn't exist, launch configuration setup - _gui->setup(); - } - initAudioCodec(); try { @@ -166,8 +173,21 @@ void ManagerImpl::setGui (GuiFramework* gui) { _gui = gui; + initGui(); +} + +/** + * Gui initialisation (after setting the gui) + */ +void +ManagerImpl::initGui() { + if (_exist == 2) { + // If config-file doesn't exist, launch configuration setup + _gui->setup(); + } } + ToneGenerator* ManagerImpl::getTonegenerator (void) { @@ -892,6 +912,8 @@ ManagerImpl::initConfigFile (void) fill_config_fields_str(PREFERENCES, ZONE_TONE, DFT_ZONE); fill_config_fields_int(PREFERENCES, CHECKED_TRAY, NO); fill_config_fields_str(PREFERENCES, VOICEMAIL_NUM, DFT_VOICEMAIL); + + fill_config_fields_int(PREFERENCES, CONFIG_ZEROCONF, CONFIG_ZEROCONF_DEFAULT); } void @@ -920,4 +942,20 @@ ManagerImpl::selectAudioDriver (void) #endif } +/** + * Initialize the Zeroconf scanning services loop + * Informations will be store inside a map DNSService->_services + */ +void +ManagerImpl::initZeroconf(void) +{ + _useZeroconf = get_config_fields_int(PREFERENCES, CONFIG_ZEROCONF); + +#ifdef USE_ZEROCONF + if (_useZeroconf) { + _DNSService->scanServices(); + } +#endif +} + // EOF diff --git a/src/managerimpl.h b/src/managerimpl.h index 9589f91684293c8bbed1e23e2172e5a4ee9c8504..09d30ebfb18e8763f2e32eca610f5abe64a86c5d 100644 --- a/src/managerimpl.h +++ b/src/managerimpl.h @@ -38,6 +38,9 @@ class Error; class GuiFramework; class ToneGenerator; class VoIPLink; +#ifdef USE_ZEROCONF +class DNSService; +#endif #define NOTIFICATION_LEN 250 // Status @@ -250,6 +253,7 @@ public: private: + /* * Returns the number of calls in the vector */ @@ -274,7 +278,17 @@ private: * Initialize audiodriver */ void selectAudioDriver (void); - + + /* + * Initialize zeroconf module and scanning + */ + void initZeroconf(void); + + /* + * Init the Gui interface (after setting it) inside setGui + */ + void initGui(); + ///////////////////// // Private variables ///////////////////// @@ -333,6 +347,16 @@ private: // Variables used in exception bool _loaded; + + // look if zeroconf scanning should run or not + int _useZeroconf; + +#ifdef USE_ZEROCONF + // DNSService contain every zeroconf services + // configuration detected on the network + DNSService *_DNSService; +#endif + }; #endif // __MANAGER_H__ diff --git a/src/user_cfg.h b/src/user_cfg.h index c57c2a220b8f62d031612b314ea172147bf6c1a7..89327ab80dc24b3e062f12734c471ee3ada6f982 100644 --- a/src/user_cfg.h +++ b/src/user_cfg.h @@ -80,6 +80,8 @@ #define ZONE_TONE "Options.zoneToneChoice" #define CHECKED_TRAY "Options.checkedTray" #define VOICEMAIL_NUM "Options.voicemailNumber" +// zeroconfig module +#define CONFIG_ZEROCONF "zeroconf.enable" // Default values #define DFT_VOIP_LINK 0 // index of the first VoIP link by default @@ -100,6 +102,11 @@ #define DFT_SKIN "metal" #define DFT_ZONE "North America" #define DFT_VOICEMAIL "888" - +// zeroconfig default value +#ifdef USE_ZEROCONF +#define CONFIG_ZEROCONF_DEFAULT 1 +#else +#define CONFIG_ZEROCONF_DEFAULT 0 +#endif #endif // __USER_CFG_H__