diff --git a/daemon/configure.ac b/daemon/configure.ac index 0bf5017c0fe8bddf3007fb5b8ef28a4f5ecd01ee..ba8a760be26d6475a70dcfa172c4a6312fabdb94 100644 --- a/daemon/configure.ac +++ b/daemon/configure.ac @@ -6,10 +6,6 @@ AC_INIT([sflphone],[1.0.2],[sflphoneteam@savoirfairelinux.com],[sflphone]) AC_COPYRIGHT([[Copyright (c) Savoir-Faire Linux 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012]]) AC_REVISION([$Revision$]) -AC_CANONICAL_BUILD -AC_CANONICAL_HOST -AC_CANONICAL_TARGET - AM_INIT_AUTOMAKE AC_CONFIG_HEADERS([config.h]) @@ -90,9 +86,6 @@ AC_DEFINE_UNQUOTED([RETSIGTYPE],[$ac_cv_type_signal],[Define as the return type AC_FUNC_STAT AC_FUNC_UTIME_NULL AC_FUNC_VPRINTF -AC_CHECK_FUNCS([bzero floor gethostbyname gethrtime gettimeofday \ - inet_ntoa memset mkdir pathconf pow regcomp select setlocale \ - socket strchr strdup strerror strrchr strstr strtol utime]) dnl Check for GNU ccRTP PKG_PROG_PKG_CONFIG diff --git a/daemon/globals.mak b/daemon/globals.mak index a6c10a05f5df299160f9d3d18e99f17969e92bc0..c998688ca12182e1738d4011a1bdcaf7382fcf30 100644 --- a/daemon/globals.mak +++ b/daemon/globals.mak @@ -11,20 +11,8 @@ ASTYLERC="$(top_srcdir)/../astylerc" indent="/usr/bin/astyle" # for pjsip -PJSIP_LIBS= \ - -L$(src)/libs/pjproject/pjnath/lib/ \ - -L$(src)/libs/pjproject/pjsip/lib/ \ - -L$(src)/libs/pjproject/pjlib/lib/ \ - -L$(src)/libs/pjproject/pjlib-util/lib/ \ - -L$(src)/libs/pjproject/pjmedia/lib/ \ - -lpjnath-$(target) \ - -lpjsua-$(target) \ - -lpjsip-$(target) \ - -lpjmedia-$(target) \ - -lpjsip-simple-$(target) \ - -lpjsip-ua-$(target) \ - -lpjlib-util-$(target) \ - -lpj-$(target) +include $(src)/libs/pjproject/build.mak +PJSIP_LIBS=$(APP_LDFLAGS) $(APP_LDLIBS) SIP_CFLAGS=-I$(src)/libs/pjproject/pjsip/include \ -I$(src)/libs/pjproject/pjlib/include \ diff --git a/daemon/src/Makefile.am b/daemon/src/Makefile.am index 7d7e190ce8c3ca043566b02ad675a0ee6226642a..b7bfeab1a3175a9b5f4b7ec209378af802aea1c5 100644 --- a/daemon/src/Makefile.am +++ b/daemon/src/Makefile.am @@ -51,7 +51,8 @@ noinst_HEADERS = \ noncopyable.h \ cc_thread.h \ cc_config.h \ - sfl_types.h + sfl_types.h \ + array_size.h libsflphone_la_LIBADD = \ $(top_builddir)/libs/iax2/libiax2.la \ diff --git a/daemon/src/array_size.h b/daemon/src/array_size.h new file mode 100644 index 0000000000000000000000000000000000000000..9bca08aadb5aa4b6d88f3ad49c71816e063eb7f5 --- /dev/null +++ b/daemon/src/array_size.h @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2004-2012 Savoir-Faire Linux Inc. + * Author: Tristan Matthews <tristan.matthews@savoirfairelinux.com> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * Additional permission under GNU GPL version 3 section 7: + * + * If you modify this program, or any covered work, by linking or + * combining it with the OpenSSL project's OpenSSL library (or a + * modified version of that library), containing parts covered by the + * terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc. + * grants you additional permission to convey the resulting work. + * Corresponding Source for a non-source form of such a combination + * shall include the source code for the parts of OpenSSL used as well + * as that of the covered work. + */ + +#ifndef ARRAY_SIZE_H_ +#define ARRAY_SIZE_H_ + +// Returns the number of elements in a, calculated at compile-time +#define ARRAYSIZE(a) \ + ((sizeof(a) / sizeof(*(a))) / \ + static_cast<size_t>(!(sizeof(a) % sizeof(*(a))))) + +#endif // ARRAY_SIZE_H_ diff --git a/daemon/src/audio/alsa/alsalayer.cpp b/daemon/src/audio/alsa/alsalayer.cpp index f86566c264fbd29f10f0d824849c23a1001f0940..2ce749443b5ee9ef5b41c2e49c4811982fe6d129 100644 --- a/daemon/src/audio/alsa/alsalayer.cpp +++ b/daemon/src/audio/alsa/alsalayer.cpp @@ -37,6 +37,7 @@ #include "manager.h" #include "noncopyable.h" #include "dbus/configurationmanager.h" +#include <ctime> class AlsaThread : public ost::Thread { public: @@ -107,7 +108,8 @@ bool AlsaLayer::openDevice(snd_pcm_t **pcm, const std::string &dev, snd_pcm_stre // Retry if busy, since dmix plugin may not have released the device yet for (int tries = 0; tries < MAX_RETRIES and err == -EBUSY; ++tries) { - usleep(10000); + const struct timespec req = {0, 10000000}; + nanosleep(&req, 0); err = snd_pcm_open(pcm, dev.c_str(), stream, 0); } diff --git a/daemon/src/audio/audiortp/audio_rtp_record_handler.h b/daemon/src/audio/audiortp/audio_rtp_record_handler.h index ac630e2872aac936f7aa05f8c73897c80e6b1296..3a57100fdb76c78d771902e5d632d306e40338f8 100644 --- a/daemon/src/audio/audiortp/audio_rtp_record_handler.h +++ b/daemon/src/audio/audiortp/audio_rtp_record_handler.h @@ -132,7 +132,7 @@ class AudioRtpRecordHandler { } int DtmfPending() const { - return audioRtpRecord_.dtmfQueue_.size() > 0; + return not audioRtpRecord_.dtmfQueue_.empty(); } const unsigned char *getMicDataEncoded() const { diff --git a/daemon/src/audio/audiortp/audio_srtp_session.cpp b/daemon/src/audio/audiortp/audio_srtp_session.cpp index 7ad1ee5ee68beb0a732816c4672644262e42de1e..38567d1b629cdbe7dbc29971401039429b9b3cc3 100644 --- a/daemon/src/audio/audiortp/audio_srtp_session.cpp +++ b/daemon/src/audio/audiortp/audio_srtp_session.cpp @@ -29,6 +29,7 @@ */ #include "audio_srtp_session.h" #include "logger.h" +#include "array_size.h" #include <openssl/sha.h> #include <openssl/hmac.h> @@ -103,12 +104,9 @@ namespace { std::vector<unsigned char> random_key(length); // Generate ryptographically strong pseudo-random bytes - int err; - - if ((err = RAND_bytes(&(*random_key.begin()), length)) != 1) + if (RAND_bytes(&(*random_key.begin()), length) != 1) DEBUG("Error occured while generating cryptographically strong pseudo-random key"); - assert((sizeof dest / sizeof dest[0]) <= length); memcpy(dest, &(*random_key.begin()), length); } } @@ -211,6 +209,7 @@ void AudioSrtpSession::initializeLocalMasterKey() DEBUG("AudioSrtp: Init local master key"); // @TODO key may have different length depending on cipher suite localMasterKeyLength_ = sfl::CryptoSuites[localCryptoSuite_].masterKeyLength / 8; + assert(ARRAYSIZE(localMasterKey_) >= localMasterKeyLength_); DEBUG("AudioSrtp: Local master key length %d", localMasterKeyLength_); buffer_fill(localMasterKey_, localMasterKeyLength_); } @@ -219,6 +218,7 @@ void AudioSrtpSession::initializeLocalMasterSalt() { // @TODO key may have different length depending on cipher suite localMasterSaltLength_ = sfl::CryptoSuites[localCryptoSuite_].masterSaltLength / 8; + assert(ARRAYSIZE(localMasterSalt_) >= localMasterSaltLength_); DEBUG("AudioSrtp: Local master salt length %d", localMasterSaltLength_); buffer_fill(localMasterSalt_, localMasterSaltLength_); } diff --git a/daemon/src/audio/audiortp/audio_srtp_session.h b/daemon/src/audio/audiortp/audio_srtp_session.h index 97b9b2ce675dbd848ea6c76c235a2f50e2e33dc3..a84cfccc847b3ae4e1fc1827383e422289bcf9ee 100644 --- a/daemon/src/audio/audiortp/audio_srtp_session.h +++ b/daemon/src/audio/audiortp/audio_srtp_session.h @@ -153,22 +153,22 @@ class AudioSrtpSession : public AudioSymmetricRtpSession { uint8 localMasterKey_[16]; /** local master key length in byte */ - int localMasterKeyLength_; + size_t localMasterKeyLength_; uint8 localMasterSalt_[14]; /** local master salt length in byte */ - int localMasterSaltLength_; + size_t localMasterSaltLength_; uint8 remoteMasterKey_[16]; /** remote master key length in byte */ - int remoteMasterKeyLength_; + size_t remoteMasterKeyLength_; uint8 remoteMasterSalt_[14]; /** remote master salt length in byte */ - int remoteMasterSaltLength_; + size_t remoteMasterSaltLength_; /** Used to make sure remote crypto context not initialized wice. */ bool remoteOfferIsSet_; diff --git a/daemon/src/audio/dcblocker.cpp b/daemon/src/audio/dcblocker.cpp index 3aa1169a36fa0ffbf0fe7f48df336a8ee6408643..923dffcd21d70b9a556920be3184637e25bf1292 100644 --- a/daemon/src/audio/dcblocker.cpp +++ b/daemon/src/audio/dcblocker.cpp @@ -30,6 +30,9 @@ #include "dcblocker.h" +DcBlocker::DcBlocker() : y_(0), x_(0), xm1_(0), ym1_(0) +{} + void DcBlocker::reset() { y_ = 0; diff --git a/daemon/src/audio/dcblocker.h b/daemon/src/audio/dcblocker.h index aaa614b1ad8cbdbfbbfbeac6e9c7ff43deabe025..caedcbae430b5d3a062dc677d9e21429f09fefde 100644 --- a/daemon/src/audio/dcblocker.h +++ b/daemon/src/audio/dcblocker.h @@ -35,6 +35,7 @@ class DcBlocker { public: + DcBlocker(); void reset(); void process(SFLDataFormat *out, SFLDataFormat *in, int samples); diff --git a/daemon/src/audio/gaincontrol.cpp b/daemon/src/audio/gaincontrol.cpp index 1b100d73d861d7cd15c09496aba52ae14646a765..5e0f282fd5734292aadb3a00c8b5e7c7a6de676b 100644 --- a/daemon/src/audio/gaincontrol.cpp +++ b/daemon/src/audio/gaincontrol.cpp @@ -82,7 +82,7 @@ double GainControl::DetectionAverage::getAverage(double in) GainControl::Limiter::Limiter(double r, double thresh) : ratio_(r), threshold_(thresh) {} -double GainControl::Limiter::limit(double in) +double GainControl::Limiter::limit(double in) const { double out = (in > threshold_ ? (ratio_ * (in - threshold_)) + threshold_ : in < -threshold_ ? (ratio_ * (in + threshold_)) - threshold_ : in); diff --git a/daemon/src/audio/gaincontrol.h b/daemon/src/audio/gaincontrol.h index e8f0ecd685103c14d4232805d7f17b2cf79ebec7..eeed3745c0abab8ce40dcaf6091d38e127323657 100644 --- a/daemon/src/audio/gaincontrol.h +++ b/daemon/src/audio/gaincontrol.h @@ -80,7 +80,7 @@ class GainControl { /** * Perform compression on input signal */ - double limit(double); + double limit(double) const; private: double ratio_; diff --git a/daemon/src/audio/mainbuffer.cpp b/daemon/src/audio/mainbuffer.cpp index 79984d8c0fc35e480fa90299142839b09492c201..4f52b7c0e767370001b360838365737ba7720ca3 100644 --- a/daemon/src/audio/mainbuffer.cpp +++ b/daemon/src/audio/mainbuffer.cpp @@ -133,19 +133,16 @@ void MainBuffer::bindCallID(const std::string & call_id1, const std::string & ca { ost::MutexLock guard(mutex_); - RingBuffer* ring_buffer; - CallIDSet* callid_set; - - if ((ring_buffer = getRingBuffer(call_id1)) == NULL) + if (getRingBuffer(call_id1) == NULL) createRingBuffer(call_id1); - if ((callid_set = getCallIDSet(call_id1)) == NULL) + if (getCallIDSet(call_id1) == NULL) createCallIDSet(call_id1); - if ((ring_buffer = getRingBuffer(call_id2)) == NULL) + if (getRingBuffer(call_id2) == NULL) createRingBuffer(call_id2); - if ((callid_set = getCallIDSet(call_id2)) == NULL) + if (getCallIDSet(call_id2) == NULL) createCallIDSet(call_id2); getRingBuffer(call_id1)->createReadPointer(call_id2); diff --git a/daemon/src/audio/sound/tone.cpp b/daemon/src/audio/sound/tone.cpp index 02c3903d5b10c0e56fd4e16facd40371dc6baf74..8a3eee76bf0eee2245c7ba899d721209abc15146 100644 --- a/daemon/src/audio/sound/tone.cpp +++ b/daemon/src/audio/sound/tone.cpp @@ -140,7 +140,7 @@ Tone::fillWavetable() } double -Tone::interpolate(double x) +Tone::interpolate(double x) const { int xi_0 = x; int xi_1 = xi_0 + 1; diff --git a/daemon/src/audio/sound/tone.h b/daemon/src/audio/sound/tone.h index bf6eeee85302759d711150a94007853eacefe3b9..55422bd0f508a76d26f209a639f5a785abf54614 100644 --- a/daemon/src/audio/sound/tone.h +++ b/daemon/src/audio/sound/tone.h @@ -73,8 +73,7 @@ class Tone : public AudioLoop { */ void fillWavetable(); - double interpolate(double x); - + double interpolate(double x) const; private: diff --git a/daemon/src/audio/speexechocancel.cpp b/daemon/src/audio/speexechocancel.cpp index 65581c47ec7f2ea1260624ed074f753a468310c6..1258b8023699659f98339bd60ca96dc6c6a1cc98 100644 --- a/daemon/src/audio/speexechocancel.cpp +++ b/daemon/src/audio/speexechocancel.cpp @@ -43,10 +43,14 @@ SpeexEchoCancel::SpeexEchoCancel() : preState_(speex_preprocess_state_init(EC_FRAME_SIZE, SPEEX_SAMPLE_RATE)), micData_(RINGBUFFER_SIZE), spkrData_(RINGBUFFER_SIZE), - spkrStopped_(true) + spkrStopped_(true), + tmpSpkr_(), + tmpMic_(), + tmpOut_() { - DEBUG("EchoCancel: Initializing echo canceller with delay: %d, filter length: %d, frame size: %d and samplerate %d", - echoDelay_, echoTailLength_, EC_FRAME_SIZE, SPEEX_SAMPLE_RATE); + DEBUG("EchoCancel: Initializing echo canceller with delay: %d, filter " + "length: %d, frame size: %d and samplerate %d", echoDelay_, + echoTailLength_, EC_FRAME_SIZE, SPEEX_SAMPLE_RATE); int rate = SPEEX_SAMPLE_RATE; speex_echo_ctl(echoState_, SPEEX_ECHO_SET_SAMPLING_RATE, &rate); diff --git a/daemon/src/config/yamlemitter.cpp b/daemon/src/config/yamlemitter.cpp index ead739b77ac00677b099bc8e9b38aeef5a1fc70b..c4361e937ca5f415b0ecdc1071c2c83f9f8ccb3d 100644 --- a/daemon/src/config/yamlemitter.cpp +++ b/daemon/src/config/yamlemitter.cpp @@ -118,8 +118,8 @@ void YamlEmitter::serializeAccount(MappingNode *map) throw YamlEmitterException("Could not append account mapping to sequence"); Mapping *internalmap = map->getMapping(); - for (Mapping::iterator iter = internalmap->begin(); iter != internalmap->end(); ++iter) - addMappingItem(accountmapping, iter->first, iter->second); + for (Mapping::const_iterator i = internalmap->begin(); i != internalmap->end(); ++i) + addMappingItem(accountmapping, i->first, i->second); } void YamlEmitter::serializePreference(MappingNode *map) @@ -141,8 +141,8 @@ void YamlEmitter::serializePreference(MappingNode *map) throw YamlEmitterException("Could not add mapping pair to top leve mapping"); Mapping *internalmap = map->getMapping(); - for (Mapping::iterator iter = internalmap->begin(); iter != internalmap->end(); ++iter) - addMappingItem(preferencemapping, iter->first, iter->second); + for (Mapping::const_iterator i = internalmap->begin(); i != internalmap->end(); ++i) + addMappingItem(preferencemapping, i->first, i->second); } void YamlEmitter::serializeVoipPreference(MappingNode *map) @@ -164,12 +164,8 @@ void YamlEmitter::serializeVoipPreference(MappingNode *map) throw YamlEmitterException("Could not add mapping pair to top leve mapping"); Mapping *internalmap = map->getMapping(); - Mapping::iterator iter = internalmap->begin(); - - while (iter != internalmap->end()) { - addMappingItem(preferencemapping, iter->first, iter->second); - iter++; - } + for (Mapping::const_iterator i = internalmap->begin(); i != internalmap->end(); ++i) + addMappingItem(preferencemapping, i->first, i->second); } void YamlEmitter::serializeAddressbookPreference(MappingNode *map) @@ -189,8 +185,8 @@ void YamlEmitter::serializeAddressbookPreference(MappingNode *map) throw YamlEmitterException("Could not add mapping pair to top leve mapping"); Mapping *internalmap = map->getMapping(); - for (Mapping::iterator iter = internalmap->begin(); iter != internalmap->end(); ++iter) - addMappingItem(preferencemapping, iter->first, iter->second); + for (Mapping::const_iterator i = internalmap->begin(); i != internalmap->end(); ++i) + addMappingItem(preferencemapping, i->first, i->second); } void YamlEmitter::serializeHooksPreference(MappingNode *map) @@ -211,8 +207,8 @@ void YamlEmitter::serializeHooksPreference(MappingNode *map) throw YamlEmitterException("Could not add mapping pair to top leve mapping"); Mapping *internalmap = map->getMapping(); - for (Mapping::iterator iter = internalmap->begin(); iter != internalmap->end(); ++iter) - addMappingItem(preferencemapping, iter->first, iter->second); + for (Mapping::const_iterator i = internalmap->begin(); i != internalmap->end(); ++i) + addMappingItem(preferencemapping, i->first, i->second); } @@ -235,8 +231,8 @@ void YamlEmitter::serializeAudioPreference(MappingNode *map) throw YamlEmitterException("Could not add mapping pair to top leve mapping"); Mapping *internalmap = map->getMapping(); - for (Mapping::iterator iter = internalmap->begin(); iter != internalmap->end(); ++iter) - addMappingItem(preferencemapping, iter->first, iter->second); + for (Mapping::const_iterator i = internalmap->begin(); i != internalmap->end(); ++i) + addMappingItem(preferencemapping, i->first, i->second); } @@ -257,13 +253,13 @@ void YamlEmitter::serializeShortcutPreference(MappingNode *map) if (yaml_document_append_mapping_pair(&document_, topLevelMapping_, preferenceid, preferencemapping) == 0) throw YamlEmitterException("Could not add mapping pair to top leve mapping"); - Mapping *internalmap = map->getMapping(); - for (Mapping::iterator iter = internalmap->begin(); iter != internalmap->end(); ++iter) - addMappingItem(preferencemapping, iter->first, iter->second); + Mapping *mapping = map->getMapping(); + for (Mapping::const_iterator i = mapping->begin(); i != mapping->end(); ++i) + addMappingItem(preferencemapping, i->first, i->second); } -void YamlEmitter::addMappingItem(int mappingid, std::string key, YamlNode *node) +void YamlEmitter::addMappingItem(int mappingid, const std::string &key, YamlNode *node) { if (node->getType() == SCALAR) { ScalarNode *sclr = static_cast<ScalarNode *>(node); @@ -294,8 +290,8 @@ void YamlEmitter::addMappingItem(int mappingid, std::string key, YamlNode *node) throw YamlEmitterException("Could not add mapping pair to mapping"); Mapping *internalmap = map->getMapping(); - for (Mapping::iterator iter = internalmap->begin(); iter != internalmap->end(); ++iter) - addMappingItem(temp2, iter->first, iter->second); + for (Mapping::const_iterator i = internalmap->begin(); i != internalmap->end(); ++i) + addMappingItem(temp2, i->first, i->second); } else if (node->getType() == SEQUENCE) { SequenceNode *seqnode = static_cast<SequenceNode *>(node); @@ -323,10 +319,8 @@ void YamlEmitter::addMappingItem(int mappingid, std::string key, YamlNode *node) MappingNode *mapnode = static_cast<MappingNode*>(yamlNode); Mapping *map = mapnode->getMapping(); - Mapping::iterator mapit; - - for (mapit = map->begin(); mapit != map->end() ; ++mapit) - addMappingItem(id, mapit->first, mapit->second); + for (Mapping::const_iterator i = map->begin(); i != map->end(); ++i) + addMappingItem(id, i->first, i->second); } } else throw YamlEmitterException("Unknown node type while adding mapping node"); diff --git a/daemon/src/config/yamlemitter.h b/daemon/src/config/yamlemitter.h index 7cbd4f7ec516333aeebf7cd1a17545eb966e20ad..d3d7eedcdfa1cffae0eac5bf7a72afb563bff589 100644 --- a/daemon/src/config/yamlemitter.h +++ b/daemon/src/config/yamlemitter.h @@ -84,7 +84,7 @@ class YamlEmitter { private: NON_COPYABLE(YamlEmitter); - void addMappingItem(int mappingid, std::string key, YamlNode *node); + void addMappingItem(int mappingid, const std::string &key, YamlNode *node); std::string filename_; diff --git a/daemon/src/config/yamlnode.cpp b/daemon/src/config/yamlnode.cpp index 50adef83d9048b8d1b7bb82b7a405595d0ac55d4..f4590a3611208b7c1103f8017952ed6637344581 100644 --- a/daemon/src/config/yamlnode.cpp +++ b/daemon/src/config/yamlnode.cpp @@ -34,28 +34,25 @@ namespace Conf { - void YamlDocument::addNode(YamlNode *node) { - Sequence::iterator it = doc.end(); - doc.insert(it, node); + Sequence::iterator it = doc_.end(); + doc_.insert(it, node); } YamlNode *YamlDocument::popNode() { - YamlNode *node = doc.front(); + YamlNode *node = doc_.front(); //removed element's destructor is called - doc.pop_front(); + doc_.pop_front(); return node; } void YamlDocument::deleteChildNodes() { - Sequence::iterator it = doc.begin(); - - while (it != doc.end()) { + for (Sequence::iterator it = doc_.begin(); it != doc_.end(); ++it) { YamlNode *yamlNode = static_cast<YamlNode *>(*it); switch (yamlNode->getType()) { @@ -84,36 +81,31 @@ void YamlDocument::deleteChildNodes() default: break; } - - it++; } } void MappingNode::addNode(YamlNode *node) { - Mapping::iterator it = map.end(); - map.insert(it, std::pair<std::string, YamlNode *> (tmpKey, node)); + setKeyValue(tmpKey_, node); } void MappingNode::setKeyValue(const std::string &key, YamlNode *value) { - Mapping::iterator it = map.end(); - map.insert(it, std::pair<std::string, YamlNode *> (key, value)); + Mapping::iterator it = map_.end(); + map_.insert(it, std::pair<std::string, YamlNode *>(key, value)); } void MappingNode::removeKeyValue(const std::string &key) { - - Mapping::iterator it = map.find(key); - map.erase(it); + Mapping::iterator it = map_.find(key); + map_.erase(it); } - YamlNode *MappingNode::getValue(const std::string &key) const { - Mapping::const_iterator it = map.find(key); + Mapping::const_iterator it = map_.find(key); - if (it != map.end()) { + if (it != map_.end()) { return it->second; } else { DEBUG("MappingNode: Could not find %s", key.c_str()); @@ -124,7 +116,6 @@ YamlNode *MappingNode::getValue(const std::string &key) const void MappingNode::getValue(const std::string &key, bool *b) const { ScalarNode *node = static_cast<ScalarNode*>(getValue(key)); - if (!node) return; @@ -154,9 +145,7 @@ void MappingNode::getValue(const std::string &key, std::string *v) const void MappingNode::deleteChildNodes() { - Mapping::iterator it; - - for (it = map.begin(); it != map.end(); ++it) { + for (Mapping::iterator it = map_.begin(); it != map_.end(); ++it) { YamlNode *yamlNode = static_cast<YamlNode *>(it->second); if (!yamlNode) @@ -193,16 +182,13 @@ void MappingNode::deleteChildNodes() void SequenceNode::addNode(YamlNode *node) { - Sequence::iterator it = seq.end(); - seq.insert(it, node); + Sequence::iterator it = seq_.end(); + seq_.insert(it, node); } - void SequenceNode::deleteChildNodes() { - Sequence::iterator it; - - for (it = seq.begin(); it != seq.end(); ++it) { + for (Sequence::iterator it = seq_.begin(); it != seq_.end(); ++it) { YamlNode *yamlNode = static_cast<YamlNode *>(*it); switch (yamlNode->getType()) { diff --git a/daemon/src/config/yamlnode.h b/daemon/src/config/yamlnode.h index 5ca28b13111a44a96479876b3482f2c3c2559ed0..36ca8d6e7f6d7fefa5a11634b94f8f75ad35e1f1 100644 --- a/daemon/src/config/yamlnode.h +++ b/daemon/src/config/yamlnode.h @@ -48,51 +48,51 @@ enum NodeType { DOCUMENT, SCALAR, MAPPING, SEQUENCE }; class YamlNode { public: - YamlNode(NodeType t, YamlNode *top = NULL) : type(t), topNode(top) {} + YamlNode(NodeType t, YamlNode *top = NULL) : type_(t), topNode_(top) {} virtual ~YamlNode() {} - NodeType getType() { - return type; + NodeType getType() const { + return type_; } YamlNode *getTopNode() { - return topNode; + return topNode_; } virtual void deleteChildNodes() = 0; private: NON_COPYABLE(YamlNode); - NodeType type; - YamlNode *topNode; + NodeType type_; + YamlNode *topNode_; }; class YamlDocument : public YamlNode { public: - YamlDocument(YamlNode* top=NULL) : YamlNode(DOCUMENT, top), doc() {} + YamlDocument(YamlNode* top = NULL) : YamlNode(DOCUMENT, top), doc_() {} void addNode(YamlNode *node); YamlNode *popNode(); Sequence *getSequence() { - return &doc; + return &doc_; } virtual void deleteChildNodes(); private: - Sequence doc; + Sequence doc_; }; class SequenceNode : public YamlNode { public: - SequenceNode(YamlNode *top) : YamlNode(SEQUENCE, top), seq() {} + SequenceNode(YamlNode *top) : YamlNode(SEQUENCE, top), seq_() {} Sequence *getSequence() { - return &seq; + return &seq_; } void addNode(YamlNode *node); @@ -100,25 +100,26 @@ class SequenceNode : public YamlNode { virtual void deleteChildNodes(); private: - Sequence seq; + Sequence seq_; }; class MappingNode : public YamlNode { public: - MappingNode(YamlNode *top) : YamlNode(MAPPING, top), map(), tmpKey() {} + MappingNode(YamlNode *top) : + YamlNode(MAPPING, top), map_(), tmpKey_() {} Mapping *getMapping() { - return ↦ + return &map_; } void addNode(YamlNode *node); void setTmpKey(std::string key) { - tmpKey = key; + tmpKey_ = key; } - void setKeyValue(const std::string &key, YamlNode *value); + void setKeyValue(const std::string &key, YamlNode *value); void removeKeyValue(const std::string &key); @@ -130,27 +131,27 @@ class MappingNode : public YamlNode { virtual void deleteChildNodes(); private: - Mapping map; - std::string tmpKey; + Mapping map_; + std::string tmpKey_; }; class ScalarNode : public YamlNode { public: - ScalarNode(std::string s="", YamlNode *top=NULL) : YamlNode(SCALAR, top), str(s) {} - ScalarNode(bool b, YamlNode *top=NULL) : YamlNode(SCALAR, top), str(b ? "true" : "false") {} + ScalarNode(std::string s="", YamlNode *top=NULL) : YamlNode(SCALAR, top), str_(s) {} + ScalarNode(bool b, YamlNode *top=NULL) : YamlNode(SCALAR, top), str_(b ? "true" : "false") {} - const std::string &getValue() { - return str; + const std::string &getValue() const { + return str_; } void setValue(const std::string &s) { - str = s; + str_ = s; } virtual void deleteChildNodes() {} private: - std::string str; + std::string str_; }; } diff --git a/daemon/src/dbus/dbusmanager.cpp b/daemon/src/dbus/dbusmanager.cpp index cfd6e5cb2f1beae6232881e103adb37c7239297f..9fe55663e90b155fdce1484a23248d87c977e09c 100644 --- a/daemon/src/dbus/dbusmanager.cpp +++ b/daemon/src/dbus/dbusmanager.cpp @@ -51,7 +51,7 @@ DBusManager::DBusManager() : callManager_(0) DBus::_init_threading(); DBus::default_dispatcher = &dispatcher_; - DBus::Connection sessionConnection = DBus::Connection::SessionBus(); + DBus::Connection sessionConnection(DBus::Connection::SessionBus()); sessionConnection.request_name("org.sflphone.SFLphone"); callManager_ = new CallManager(sessionConnection); @@ -59,7 +59,7 @@ DBusManager::DBusManager() : callManager_(0) instanceManager_ = new Instance(sessionConnection); #ifdef USE_NETWORKMANAGER - DBus::Connection systemConnection = DBus::Connection::SystemBus(); + DBus::Connection systemConnection(DBus::Connection::SystemBus()); networkManager_ = new NetworkManager(systemConnection, "/org/freedesktop/NetworkManager", ""); #endif diff --git a/daemon/src/fileutils.cpp b/daemon/src/fileutils.cpp index bed4d2ea3d74bb2b095af5cd04929dd4fd51cea0..93829c7edfca32522e8fd46ef1e57736f8c70e3d 100644 --- a/daemon/src/fileutils.cpp +++ b/daemon/src/fileutils.cpp @@ -31,13 +31,13 @@ #include <libgen.h> #include <dirent.h> #include <sys/stat.h> -#include <cstdio> +#include <fstream> #include <cstdlib> #include <signal.h> #include <string> #include <sstream> +#include <iostream> #include "fileutils.h" -#include "logger.h" namespace { // returns true if directory exists @@ -84,38 +84,30 @@ bool create_pidfile() return false; std::string pidfile = path + "/" PIDFILE; - FILE *fp = fopen(pidfile.c_str(),"r"); + std::ifstream is(pidfile.c_str()); - if (fp) { + if (is) { // PID file exists. Check if the former process is still alive or // not. If alive, give user a hint. int oldPid; - - if (fscanf(fp, "%d", &oldPid) != 1) { - ERROR("Couldn't read pidfile %s", pidfile.c_str()); - return false; - } - - fclose(fp); + is >> oldPid; if (kill(oldPid, 0) == 0) { - ERROR("There is already a sflphoned daemon running in the system. Starting Failed."); + // Use cerr because logging has not been initialized + std::cerr << "There is already a sflphoned daemon running in " << + "the system. Starting Failed." << std::endl; return false; } } // write pid file - fp = fopen(pidfile.c_str(),"w"); + std::ofstream os(pidfile.c_str()); - if (!fp) { + if (!os) { perror(pidfile.c_str()); return false; } else { - std::ostringstream pidstr; - pidstr << getpid(); - - fputs(pidstr.str().c_str(), fp); - fclose(fp); + os << getpid(); } return true; diff --git a/daemon/src/iax/iaxvoiplink.cpp b/daemon/src/iax/iaxvoiplink.cpp index aabb9eae777326d0cdf587e6fffe63e76520dfdc..f797900a2b013775c7eccc4a47f1477ac7196790 100644 --- a/daemon/src/iax/iaxvoiplink.cpp +++ b/daemon/src/iax/iaxvoiplink.cpp @@ -47,6 +47,9 @@ IAXVoIPLink::IAXVoIPLink(const std::string& accountID) : , regSession_(NULL) , nextRefreshStamp_(0) , mutexIAX_() + , decData_() + , resampledData_() + , encodedData_() , converter_(44100) , initDone_(false) , accountID_(accountID) @@ -167,7 +170,7 @@ IAXVoIPLink::sendAudioFromMic() continue; // Get bytes from micRingBuffer to data_from_mic - int bytes = Manager::instance().getMainBuffer()->getData(decData, bytesNeeded, currentCall->getCallId()); + int bytes = Manager::instance().getMainBuffer()->getData(decData_, bytesNeeded, currentCall->getCallId()); int samples = bytes / sizeof(SFLDataFormat); int compSize; @@ -176,20 +179,20 @@ IAXVoIPLink::sendAudioFromMic() SFLDataFormat *in; if (audioRate != mainBufferSampleRate) { - converter_.resample(decData, resampledData, audioRate, mainBufferSampleRate, samples); - in = resampledData; + converter_.resample(decData_, resampledData_, audioRate, mainBufferSampleRate, samples); + in = resampledData_; outSamples = 0; } else { outSamples = samples; - in = decData; + in = decData_; } - compSize = audioCodec->encode(encodedData, in, DEC_BUFFER_SIZE); + compSize = audioCodec->encode(encodedData_, in, DEC_BUFFER_SIZE); if (currentCall->session and bytes > 0) { ost::MutexLock m(mutexIAX_); - if (iax_send_voice(currentCall->session, currentCall->format, encodedData, compSize, outSamples) == -1) + if (iax_send_voice(currentCall->session, currentCall->format, encodedData_, compSize, outSamples) == -1) ERROR("IAX: Error sending voice data."); } } @@ -562,15 +565,15 @@ void IAXVoIPLink::iaxHandleVoiceEvent(iax_event* event, IAXCall* call) if (size > max) size = max; - int samples = audioCodec->decode(decData, data , size); + int samples = audioCodec->decode(decData_, data , size); int outSize = samples * sizeof(SFLDataFormat); - SFLDataFormat *out = decData; + SFLDataFormat *out = decData_; unsigned int audioRate = audioCodec->getClockRate(); if (audioRate != mainBufferSampleRate) { outSize = (double)outSize * (mainBufferSampleRate / audioRate); - converter_.resample(decData, resampledData, mainBufferSampleRate, audioRate, samples); - out = resampledData; + converter_.resample(decData_, resampledData_, mainBufferSampleRate, audioRate, samples); + out = resampledData_; } Manager::instance().getMainBuffer()->putData(out, outSize, call->getCallId()); diff --git a/daemon/src/iax/iaxvoiplink.h b/daemon/src/iax/iaxvoiplink.h index 9a421d1d2c14cb30b7f8a23e8683a8c34d659b96..07606c730045bb71724c4305b0507265fedbf811 100644 --- a/daemon/src/iax/iaxvoiplink.h +++ b/daemon/src/iax/iaxvoiplink.h @@ -250,9 +250,9 @@ class IAXVoIPLink : public VoIPLink { ost::Mutex mutexIAX_; /** encoder/decoder/resampler buffers */ - SFLDataFormat decData[DEC_BUFFER_SIZE]; - SFLDataFormat resampledData[DEC_BUFFER_SIZE]; - unsigned char encodedData[DEC_BUFFER_SIZE]; + SFLDataFormat decData_[DEC_BUFFER_SIZE]; + SFLDataFormat resampledData_[DEC_BUFFER_SIZE]; + unsigned char encodedData_[DEC_BUFFER_SIZE]; /** Sample rate converter object */ SamplerateConverter converter_; diff --git a/daemon/src/managerimpl.cpp b/daemon/src/managerimpl.cpp index 5faadca43e24848df52016d7ae61e811d8d5a788..030d6ae3b8ed7810258981df984dffa6cf5e6011 100644 --- a/daemon/src/managerimpl.cpp +++ b/daemon/src/managerimpl.cpp @@ -78,8 +78,8 @@ ManagerImpl::ManagerImpl() : preferences(), voipPreferences(), addressbookPreference(), hookPreference(), audioPreference(), shortcutPreferences(), hasTriedToRegister_(false), audioCodecFactory(), dbus_(), config_(), - currentCallId_(), currentCallMutex_(), audiodriver_(0), dtmfKey_(0), - toneMutex_(), telephoneTone_(0), audiofile_(0), audioLayerMutex_(), + currentCallId_(), currentCallMutex_(), audiodriver_(0), dtmfKey_(), + toneMutex_(), telephoneTone_(), audiofile_(), audioLayerMutex_(), waitingCall_(), waitingCallMutex_(), nbIncomingWaitingCall_(0), path_(), callAccountMap_(), callAccountMapMutex_(), IPToIPMap_(), accountMap_(), mainBuffer_(), conferenceMap_(), history_() @@ -130,6 +130,7 @@ void ManagerImpl::terminate() saveConfig(); + SIPVoIPLink::destroy(); // Unload account map AFTER destroying // the SIPVoIPLink, the link still needs the accounts for pjsip cleanup unloadAccountMap(); @@ -1667,7 +1668,7 @@ void ManagerImpl::stopTone() if (audiofile_.get()) { std::string filepath(audiofile_->getFilePath()); dbus_.getCallManager()->recordPlaybackStopped(filepath); - audiofile_.reset(0); + audiofile_.reset(); } } @@ -1746,7 +1747,7 @@ void ManagerImpl::ringtone(const std::string& accountID) if (audiofile_.get()) { dbus_.getCallManager()->recordPlaybackStopped(audiofile_->getFilePath()); - audiofile_.reset(0); + audiofile_.reset(); } try { @@ -2080,7 +2081,7 @@ bool ManagerImpl::startRecordedFilePlayback(const std::string& filepath) if (audiofile_.get()) { dbus_.getCallManager()->recordPlaybackStopped(audiofile_->getFilePath()); - audiofile_.reset(0); + audiofile_.reset(); } try { @@ -2108,7 +2109,7 @@ void ManagerImpl::stopRecordedFilePlayback(const std::string& filepath) { ost::MutexLock m(toneMutex_); - audiofile_.reset(0); + audiofile_.reset(); } } diff --git a/daemon/src/managerimpl.h b/daemon/src/managerimpl.h index d91481829ee6793812c0f5bc8be228896fc728a5..ad5ab0fc4b906cc3a0423cfb98e19a8879251050 100644 --- a/daemon/src/managerimpl.h +++ b/daemon/src/managerimpl.h @@ -39,7 +39,7 @@ #include <vector> #include <set> #include <map> -#include <memory> +#include <tr1/memory> #include "cc_thread.h" #include "dbus/dbusmanager.h" @@ -890,14 +890,14 @@ class ManagerImpl { AudioLayer* audiodriver_; // Main thread - std::auto_ptr<DTMF> dtmfKey_; + std::tr1::shared_ptr<DTMF> dtmfKey_; ///////////////////// // Protected by Mutex ///////////////////// ost::Mutex toneMutex_; - std::auto_ptr<TelephoneTone> telephoneTone_; - std::auto_ptr<AudioFile> audiofile_; + std::tr1::shared_ptr<TelephoneTone> telephoneTone_; + std::tr1::shared_ptr<AudioFile> audiofile_; // To handle volume control // short speakerVolume_; diff --git a/daemon/src/sip/sdes_negotiator.cpp b/daemon/src/sip/sdes_negotiator.cpp index 63bb00b8231cfd851da960d22c409b1ac7d3500c..a8eed12a7dc671daaef40ff38a78b0e962ab01ab 100644 --- a/daemon/src/sip/sdes_negotiator.cpp +++ b/daemon/src/sip/sdes_negotiator.cpp @@ -32,7 +32,7 @@ #include "pattern.h" #include <cstdio> -#include <memory> +#include <tr1/memory> #include <iostream> #include <sstream> #include <algorithm> @@ -61,7 +61,7 @@ std::vector<CryptoAttribute *> SdesNegotiator::parse() // syntax : //a=crypto:tag 1*WSP crypto-suite 1*WSP key-params *(1*WSP session-param) - std::auto_ptr<Pattern> generalSyntaxPattern, tagPattern, cryptoSuitePattern, + std::tr1::shared_ptr<Pattern> generalSyntaxPattern, tagPattern, cryptoSuitePattern, keyParamsPattern; try { @@ -178,7 +178,7 @@ bool SdesNegotiator::negotiate() std::vector<CryptoAttribute *> cryptoAttributeVector = parse(); std::vector<CryptoAttribute *>::iterator iter_offer = cryptoAttributeVector.begin(); - std::vector<CryptoSuiteDefinition>::iterator iter_local = localCapabilities_.begin(); + std::vector<CryptoSuiteDefinition>::const_iterator iter_local = localCapabilities_.begin(); bool negotiationSuccess = false; @@ -197,10 +197,11 @@ bool SdesNegotiator::negotiate() authTagLength_ = cryptoSuite_.substr(cryptoSuite_.size()-2, 2); } - iter_local++; + ++iter_local; } - delete(*iter_offer); - iter_offer++; + delete *iter_offer; + *iter_offer = 0; + ++iter_offer; } } catch (const ParseError& exception) { diff --git a/daemon/src/sip/sdp.cpp b/daemon/src/sip/sdp.cpp index a517e97af5d3d1f3862ff99af5f888d5da7f4955..b20b29d5c2d2be5a5e651a5ca9077d0e4c16870d 100644 --- a/daemon/src/sip/sdp.cpp +++ b/daemon/src/sip/sdp.cpp @@ -207,7 +207,7 @@ void Sdp::setTelephoneEventRtpmap(pjmedia_sdp_media *med) void Sdp::setLocalMediaCapabilities(const CodecOrder &selectedCodecs) { - if (selectedCodecs.size() == 0) + if (selectedCodecs.empty()) WARN("No selected codec while building local SDP offer"); codec_list_.clear(); diff --git a/daemon/src/sip/sipaccount.cpp b/daemon/src/sip/sipaccount.cpp index b70667080e7c031963c3cbf57a0fd5d79b9ffd20..2ba3d7b363f43795ee2d895f33f4b1b10ff83a34 100644 --- a/daemon/src/sip/sipaccount.cpp +++ b/daemon/src/sip/sipaccount.cpp @@ -899,7 +899,7 @@ void SIPAccount::setCredentials(const std::vector<std::map<std::string, std::str bool md5HashingEnabled = Manager::instance().preferences.getMd5Hash(); - assert(creds.size() > 0); // we can not authenticate without credentials + assert(not creds.empty()); // we can not authenticate without credentials credentials_ = creds; diff --git a/daemon/src/sip/sipvoiplink.cpp b/daemon/src/sip/sipvoiplink.cpp index 7b39a06f9f3bd7c823dd1103b2d43028a4590e2a..b40c9190f65e0144672fe1ef2ea248c63e894d46 100644 --- a/daemon/src/sip/sipvoiplink.cpp +++ b/daemon/src/sip/sipvoiplink.cpp @@ -1,6 +1,5 @@ /* * Copyright (C) 2004, 2005, 2006, 2008, 2009, 2010 Savoir-Faire Linux Inc. - * * Author: Emmanuel Milou <emmanuel.milou@savoirfairelinux.com> * Author: Yun Liu <yun.liu@savoirfairelinux.com> * Author: Pierre-Luc Bacon <pierre-luc.bacon@savoirfairelinux.com> @@ -65,11 +64,13 @@ #include <istream> #include <utility> // for std::pair - #include <map> using namespace sfl; +SIPVoIPLink *SIPVoIPLink::instance_ = 0; +bool SIPVoIPLink::destroyed_ = false; + namespace { /** A map to retreive SFLphone internal call id @@ -507,8 +508,17 @@ SIPVoIPLink::~SIPVoIPLink() SIPVoIPLink* SIPVoIPLink::instance() { - static SIPVoIPLink instance_; - return &instance_; + assert(!destroyed_); + if (!instance_) + instance_ = new SIPVoIPLink; + return instance_; +} + +void SIPVoIPLink::destroy() +{ + delete instance_; + destroyed_ = true; + instance_ = 0; } // Called from EventThread::run (not main thread) diff --git a/daemon/src/sip/sipvoiplink.h b/daemon/src/sip/sipvoiplink.h index 9a6c14eeda21f14753b40415d45b3fa6ffc8e07a..22e6f72dda3c27d25095f04dff24eb425f756e3e 100644 --- a/daemon/src/sip/sipvoiplink.h +++ b/daemon/src/sip/sipvoiplink.h @@ -63,7 +63,6 @@ class SIPAccount; class SIPVoIPLink : public VoIPLink { public: - ~SIPVoIPLink(); /** * Singleton method. Enable to retrieve the unique static instance @@ -71,6 +70,11 @@ class SIPVoIPLink : public VoIPLink { */ static SIPVoIPLink* instance(); + /** + * Destroy the singleton instance + */ + static void destroy(); + /** * Event listener. Each event send by the call manager is received and handled from here */ @@ -228,7 +232,13 @@ class SIPVoIPLink : public VoIPLink { void createDefaultSipUdpTransport(); SipTransport sipTransport; + private: + + NON_COPYABLE(SIPVoIPLink); + + SIPVoIPLink(); + ~SIPVoIPLink(); /** * Start a SIP Call * @param call The current call @@ -238,16 +248,14 @@ class SIPVoIPLink : public VoIPLink { void dtmfSend(SIPCall *call, char code, const std::string &type); - NON_COPYABLE(SIPVoIPLink); - - SIPVoIPLink(); - /** * Threading object */ EventThread evThread_; friend class SIPTest; + static bool destroyed_; + static SIPVoIPLink *instance_; }; #endif // SIPVOIPLINK_H_ diff --git a/daemon/test/audiolayertest.cpp b/daemon/test/audiolayertest.cpp index 5eb9fef40cfd04ec9a83692c519982b33a2a8500..3e80ef2f1fc0395c1bf14610ebe78ead56232b9c 100644 --- a/daemon/test/audiolayertest.cpp +++ b/daemon/test/audiolayertest.cpp @@ -80,7 +80,8 @@ void AudioLayerTest::testAudioLayerSwitch() CPPUNIT_ASSERT(dynamic_cast<AlsaLayer*>(Manager::instance().getAudioDriver())); wasAlsa = dynamic_cast<AlsaLayer*>(Manager::instance().getAudioDriver()) != 0; - usleep(100000); + const struct timespec req = {0, 100000000}; + nanosleep(&req, 0); } } @@ -90,7 +91,8 @@ void AudioLayerTest::testPulseConnect() if (dynamic_cast<AlsaLayer*>(Manager::instance().getAudioDriver())) { Manager::instance().switchAudioManager(); - usleep(100000); + const struct timespec req = {0, 100000000}; + nanosleep(&req, 0); } pulselayer_ = dynamic_cast<PulseLayer*>(Manager::instance().getAudioDriver()); diff --git a/daemon/test/delaydetectiontest.cpp b/daemon/test/delaydetectiontest.cpp index db5280bf7c607a016ea0a117b98ff457222bb0e5..6b744c79f1e97d1152ae55859f8f8a7ca006d359 100644 --- a/daemon/test/delaydetectiontest.cpp +++ b/daemon/test/delaydetectiontest.cpp @@ -31,6 +31,7 @@ #include "delaydetectiontest.h" #include <cstring> +#include "array_size.h" void DelayDetectionTest::testCrossCorrelation() { @@ -66,7 +67,7 @@ void DelayDetectionTest::testCrossCorrelationDelay() delaydetect_.crossCorrelate(ref, signal, result, 3, 10); - float expected[10] = {0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0}; +// float expected[10] = {0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0}; } void DelayDetectionTest::testFirFilter() diff --git a/daemon/test/mainbuffertest.cpp b/daemon/test/mainbuffertest.cpp index 2e5893c0e596b631e5ded350dadad4a144b52679..1ca7a603ebc309be865f5d01186b4104bcbc133d 100644 --- a/daemon/test/mainbuffertest.cpp +++ b/daemon/test/mainbuffertest.cpp @@ -865,7 +865,6 @@ void MainBufferTest::testGetPutDataByID() int test_input2 = 13; int test_output; - int avail_for_put_testid; int avail_for_put_defaultid; // put by default_id get by test_id without preleminary put @@ -883,7 +882,7 @@ void MainBufferTest::testGetPutDataByID() CPPUNIT_ASSERT(test_input1 == test_output); // get by default_id without preliminary input - avail_for_put_testid = mainbuffer_.availForPut(test_id); + mainbuffer_.availForPut(test_id); CPPUNIT_ASSERT(mainbuffer_.availForGetByID(test_id, default_id) == 0); CPPUNIT_ASSERT(mainbuffer_.getDataByID(&test_output, sizeof(int), 100, test_id, default_id) == 0); diff --git a/daemon/test/test_utils.h b/daemon/test/test_utils.h index 154de60e53742b630dff1044e53ea89a7f3b681b..4102a28131d66ff5462acacb17206cabec05d13c 100644 --- a/daemon/test/test_utils.h +++ b/daemon/test/test_utils.h @@ -34,9 +34,4 @@ #define TITLE() DEBUG("-------------------- %s --------------------\n", \ __PRETTY_FUNCTION__) -// Returns the number of elements in a, calculated at compile-time -#define ARRAYSIZE(a) \ - ((sizeof(a) / sizeof(*(a))) / \ - static_cast<size_t>(!(sizeof(a) % sizeof(*(a))))) - #endif // TEST_UTILS_H_ diff --git a/gnome/src/actions.h b/gnome/src/actions.h index 4c3899836a2eab2e4140838b0a0344db18677391..5dc304885850c2dcccf9772b2a6f6ed27753111a 100644 --- a/gnome/src/actions.h +++ b/gnome/src/actions.h @@ -52,7 +52,7 @@ * Initialize lists and configurations * @return TRUE if succeeded, FALSE otherwise */ -gboolean sflphone_init(); +gboolean sflphone_init(GError **error); /** * Steps when closing the application. Will ask for confirmation if a call is in progress.