diff --git a/daemon/src/audio/audiortp/AudioRtpSession.cpp b/daemon/src/audio/audiortp/AudioRtpSession.cpp index 04f75d4f13651d568274b4e529dc48731cca83dd..89c5af36ec583585d2be3d173c852e0ee0a30800 100644 --- a/daemon/src/audio/audiortp/AudioRtpSession.cpp +++ b/daemon/src/audio/audiortp/AudioRtpSession.cpp @@ -223,7 +223,7 @@ void AudioRtpSession::updateDestinationIpAddress (void) // This method remove the current destination entry if (!_queue->forgetDestination (_remote_ip, _remote_port, _remote_port+1)) - _warn ("AudioRtpSession: Could not remove previous destination"); + _debug("AudioRtpSession: Did not remove previous destination"); // new destination is stored in call // we just need to recall this method diff --git a/daemon/src/conference.cpp b/daemon/src/conference.cpp index 41067a349fd08d90cb768f6fbe00b50e3ee7008e..5dd90ec2f242ff9198988c65d28436a1f831238a 100644 --- a/daemon/src/conference.cpp +++ b/daemon/src/conference.cpp @@ -43,46 +43,36 @@ Conference::Conference() Recordable::initRecFileName (_id); } - -Conference::~Conference() -{ -} - - -int Conference::getState() +int Conference::getState() const { return _confState; } - void Conference::setState (ConferenceState state) { _confState = state; } - -void Conference::add (std::string participant_id) +void Conference::add(const std::string &participant_id) { _participants.insert (participant_id); } - -void Conference::remove (std::string participant_id) +void Conference::remove(const std::string &participant_id) { - _participants.erase (participant_id); + _participants.erase(participant_id); } -void Conference::bindParticipant (std::string participant_id) +void Conference::bindParticipant(const std::string &participant_id) { - ParticipantSet::iterator iter; - for (iter = _participants.begin(); iter != _participants.end(); ++iter) - if (participant_id != *iter) - Manager::instance().getMainBuffer()->bindCallID (participant_id, *iter); + for (ParticipantSet::iterator iter = _participants.begin(); + iter != _participants.end(); ++iter) + if (participant_id != *iter) + Manager::instance().getMainBuffer()->bindCallID(participant_id, *iter); - Manager::instance().getMainBuffer()->bindCallID (participant_id); + Manager::instance().getMainBuffer()->bindCallID(participant_id); } - std::string Conference::getStateStr() { switch (_confState) { @@ -96,14 +86,11 @@ std::string Conference::getStateStr() } } - -const ParticipantSet &Conference::getParticipantList() +ParticipantSet Conference::getParticipantList() const { return _participants; } - - bool Conference::setRecording() { bool recordStatus = Recordable::recAudio.isRecording(); @@ -130,5 +117,4 @@ bool Conference::setRecording() } return recordStatus; - } diff --git a/daemon/src/conference.h b/daemon/src/conference.h index 6a4fcce44bf327e9813d311cd4cfb3177d937655..6b92d03135c9564035ce0fc71d6965f0a19f0c59 100644 --- a/daemon/src/conference.h +++ b/daemon/src/conference.h @@ -34,18 +34,12 @@ #include <string> #include "audio/recordable.h" -#include "call.h" - -// class ManagerImpl; -// class Call; typedef std::set<std::string> ParticipantSet; class Conference: public Recordable { - public: - enum ConferenceState {ACTIVE_ATTACHED, ACTIVE_DETACHED, ACTIVE_ATTACHED_REC, ACTIVE_DETACHED_REC, HOLD, HOLD_REC}; /** @@ -53,11 +47,6 @@ class Conference: public Recordable */ Conference(); - /** - * Destructor - */ - ~Conference(); - /** * Return the conference id */ @@ -68,7 +57,7 @@ class Conference: public Recordable /** * Return the current conference state */ - int getState(); + int getState() const; /** * Set conference state @@ -83,22 +72,22 @@ class Conference: public Recordable /** * Add a new participant to the conference */ - void add (std::string participant_id); + void add (const std::string &participant_id); /** * Remove a participant from the conference */ - void remove (std::string participant_id); + void remove (const std::string &participant_id); /** * Bind a participant to the conference */ - void bindParticipant (std::string participant_id); + void bindParticipant (const std::string &participant_id); /** * Get the participant list for this conference */ - const ParticipantSet &getParticipantList(); + ParticipantSet getParticipantList() const; /** * Get recording file ID @@ -128,12 +117,6 @@ class Conference: public Recordable * List of participant ids */ ParticipantSet _participants; - - /** - * Number of participant - */ - int _nbParticipant; - }; #endif diff --git a/daemon/src/dbus/callmanager.cpp b/daemon/src/dbus/callmanager.cpp index 9c9d4dc46e30a2acb61eb3a028783df4c905dbad..8ea8d51deb21aba672306aa483ae4b42c278da55 100644 --- a/daemon/src/dbus/callmanager.cpp +++ b/daemon/src/dbus/callmanager.cpp @@ -42,37 +42,34 @@ CallManager::CallManager (DBus::Connection& connection) : DBus::ObjectAdaptor (connection, "/org/sflphone/SFLphone/CallManager") -{ -} +{} -void -CallManager::placeCall (const std::string& accountID, - const std::string& callID, - const std::string& to) // Check if a destination number is available +void CallManager::placeCall(const std::string& accountID, + const std::string& callID, + const std::string& to) { - - if (to == "") { + // Check if a destination number is available + if (to.empty()) _debug ("No number entered - Call stopped"); - } else { + else Manager::instance().outgoingCall (accountID, callID, to); - } } -void -CallManager::placeCallFirstAccount (const std::string& callID, - const std::string& to) +void CallManager::placeCallFirstAccount(const std::string& callID, + const std::string& to) { - if (to == "") { + using std::vector; + using std::string; + if (to.empty()) { _warn ("CallManager: Warning: No number entered, call stopped"); return; } - std::vector< std::string > accountList = Manager::instance().loadAccountOrder(); - if (accountList.size() == 0) + vector<string> accountList(Manager::instance().loadAccountOrder()); + if (accountList.empty()) accountList = Manager::instance().getAccountList(); - std::vector< std::string >::const_iterator iter; - for (iter = accountList.begin(); iter != accountList.end(); ++iter) { + for (vector<string>::const_iterator iter = accountList.begin(); iter != accountList.end(); ++iter) { if ((*iter != IP2IP_PROFILE) && Manager::instance().getAccount(*iter)->isEnabled()) { Manager::instance().outgoingCall(*iter, callID, to); return; @@ -96,7 +93,6 @@ void CallManager::hangUp (const std::string& callID) { Manager::instance().hangupCall (callID); - } void @@ -105,7 +101,6 @@ CallManager::hangUpConference (const std::string& confID) Manager::instance().hangupConference (confID); } - void CallManager::hold (const std::string& callID) { @@ -124,20 +119,17 @@ CallManager::transfer (const std::string& callID, const std::string& to) Manager::instance().transferCall (callID, to); } -void -CallManager::attendedTransfer (const std::string& transferID, const std::string& targetID) +void CallManager::attendedTransfer (const std::string& transferID, const std::string& targetID) { Manager::instance().attendedTransfer(transferID, targetID); } -void -CallManager::setVolume (const std::string& device, const double& value) +void CallManager::setVolume (const std::string& device, const double& value) { - if (device == "speaker") { - Manager::instance().setSpkrVolume ( (int) (value*100.0)); - } else if (device == "mic") { - Manager::instance().setMicVolume ( (int) (value*100.0)); - } + if (device == "speaker") + Manager::instance().setSpkrVolume ( (int) (value * 100.0)); + else if (device == "mic") + Manager::instance().setMicVolume ( (int) (value * 100.0)); volumeChanged (device, value); } @@ -145,11 +137,10 @@ CallManager::setVolume (const std::string& device, const double& value) double CallManager::getVolume (const std::string& device) { - if (device == "speaker") { - return Manager::instance().getSpkrVolume() /100.0; - } else if (device == "mic") { - return Manager::instance().getMicVolume() /100.0; - } + if (device == "speaker") + return Manager::instance().getSpkrVolume() / 100.0; + else if (device == "mic") + return Manager::instance().getMicVolume() / 100.0; return 0; } @@ -279,7 +270,7 @@ CallManager::playDTMF (const std::string& key) void CallManager::startTone (const int32_t& start , const int32_t& type) { - if (start == true) { + if (start) { if (type == 0) Manager::instance().playTone(); else @@ -292,14 +283,13 @@ CallManager::startTone (const int32_t& start , const int32_t& type) // for conferencing in order to get // the right pointer for the given // callID. -sfl::AudioZrtpSession * CallManager::getAudioZrtpSession (const std::string& callID) +sfl::AudioZrtpSession * +CallManager::getAudioZrtpSession(const std::string& callID) { - SIPVoIPLink * link = NULL; - link = dynamic_cast<SIPVoIPLink *> (Manager::instance().getAccountLink ("")); + SIPVoIPLink * link = dynamic_cast<SIPVoIPLink *>(Manager::instance().getAccountLink("")); - if (!link) { + if (!link) throw CallManagerException("Failed to get sip link"); - } SIPCall *call; try { @@ -324,8 +314,6 @@ CallManager::setSASVerified (const std::string& callID) zSession = getAudioZrtpSession (callID); zSession->SASVerified(); } catch (...) { - return; - // throw; } } @@ -337,8 +325,6 @@ CallManager::resetSASVerified (const std::string& callID) zSession = getAudioZrtpSession (callID); zSession->resetSASVerified(); } catch (...) { - return; - // throw; } } @@ -350,8 +336,6 @@ CallManager::setConfirmGoClear (const std::string& callID) zSession = getAudioZrtpSession (callID); zSession->goClearOk(); } catch (...) { - return; - // throw; } } @@ -363,8 +347,6 @@ CallManager::requestGoClear (const std::string& callID) zSession = getAudioZrtpSession (callID); zSession->requestGoClear(); } catch (...) { - return; - /// throw; } } @@ -376,8 +358,6 @@ CallManager::acceptEnrollment (const std::string& callID, const bool& accepted) zSession = getAudioZrtpSession (callID); zSession->acceptEnrollment (accepted); } catch (...) { - return; - // throw; } } @@ -389,14 +369,12 @@ CallManager::setPBXEnrollment (const std::string& callID, const bool& yesNo) zSession = getAudioZrtpSession (callID); zSession->setPBXEnrollment (yesNo); } catch (...) { - return; - // throw; } } void CallManager::sendTextMessage (const std::string& callID, const std::string& message) { - if (!Manager::instance().sendTextMessage (callID, message, "Me")) + if (!Manager::instance().sendTextMessage(callID, message, "Me")) throw CallManagerException(); } diff --git a/daemon/src/managerimpl.cpp b/daemon/src/managerimpl.cpp index 7ce6d1dc8447010503928efd10ec4fbcf9cc7d70..8850952e8d13c197967c0ecbbb9f1e232ed3df28 100644 --- a/daemon/src/managerimpl.cpp +++ b/daemon/src/managerimpl.cpp @@ -68,7 +68,7 @@ #include <sys/stat.h> // mkdir(2) ManagerImpl::ManagerImpl (void) : - _hasTriedToRegister (false), _config(), _currentCallId2(), + _hasTriedToRegister (false), _config(), currentCallId_(), _currentCallMutex(), _audiodriver (0), _dtmfKey (0), _toneMutex(), _telephoneTone (0), _audiofile (0), _spkr_volume (0), @@ -159,25 +159,25 @@ void ManagerImpl::terminate () bool ManagerImpl::isCurrentCall (const std::string& callId) { - return _currentCallId2 == callId; + return currentCallId_ == callId; } bool ManagerImpl::hasCurrentCall () { - return not _currentCallId2.empty(); + return not currentCallId_.empty(); } const std::string& ManagerImpl::getCurrentCallId () const { - return _currentCallId2; + return currentCallId_; } void ManagerImpl::switchCall (const std::string& id) { ost::MutexLock m (_currentCallMutex); _debug ("----- Switch current call id to %s -----", id.c_str()); - _currentCallId2 = id; + currentCallId_ = id; } /////////////////////////////////////////////////////////////////////////////// @@ -360,7 +360,7 @@ void ManagerImpl::hangupCall (const std::string& callId) if (conf != NULL) { // remove this participant removeParticipant (callId); - processRemainingParticipant (currentCallId, conf); + processRemainingParticipants(currentCallId, conf); } } else { // we are not participating to a conference, current call switched to "" @@ -393,18 +393,21 @@ bool ManagerImpl::hangupConference (const std::string& id) ConferenceMap::iterator iter_conf = _conferencemap.find (id); - std::string currentAccountId; - if (iter_conf != _conferencemap.end()) { Conference *conf = iter_conf->second; - - const ParticipantSet &participants = conf->getParticipantList(); - ParticipantSet::const_iterator iter; - for (iter = participants.begin(); iter != participants.end(); ++iter) - hangupCall (*iter); + if (conf) { + ParticipantSet participants(conf->getParticipantList()); + for (ParticipantSet::const_iterator iter = participants.begin(); + iter != participants.end(); ++iter) + hangupCall(*iter); + } + else { + _error("Manager: No such conference %s", id.c_str()); + return false; + } } - switchCall (""); + switchCall(""); getMainBuffer()->stateInfo(); @@ -522,7 +525,7 @@ bool ManagerImpl::transferCall (const std::string& callId, const std::string& to { if (participToConference(callId)) { removeParticipant (callId); - processRemainingParticipant (callId, getConferenceFromCallID(callId)); + processRemainingParticipants(callId, getConferenceFromCallID(callId)); } else if (!isConference(getCurrentCallId())) switchCall(""); @@ -561,7 +564,7 @@ bool ManagerImpl::attendedTransfer(const std::string& transferID, const std::str return SIPVoIPLink::instance()->attendedTransfer(transferID, targetID); // Classic call, attached to an account - std::string accountid = getAccountFromCall(transferID); + std::string accountid(getAccountFromCall(transferID)); if (accountid.empty()) return false; @@ -627,7 +630,7 @@ void ManagerImpl::removeConference (const std::string& conference_id) { _debug ("Manager: Remove conference %s", conference_id.c_str()); - _debug ("Manager: number of participant: %d", (int) _conferencemap.size()); + _debug ("Manager: number of participants: %u", _conferencemap.size()); ConferenceMap::iterator iter = _conferencemap.find (conference_id); Conference* conf = NULL; @@ -641,14 +644,14 @@ void ManagerImpl::removeConference (const std::string& conference_id) } // broadcast a signal over dbus - _dbus.getCallManager()->conferenceRemoved (conference_id); + _dbus.getCallManager()->conferenceRemoved(conference_id); // We now need to bind the audio to the remain participant // Unbind main participant audio from conference getMainBuffer()->unBindAll (Call::DEFAULT_ID); - const ParticipantSet &participants = conf->getParticipantList(); + ParticipantSet participants(conf->getParticipantList()); // bind main participant audio to remaining conference call ParticipantSet::iterator iter_p = participants.begin(); @@ -657,7 +660,7 @@ void ManagerImpl::removeConference (const std::string& conference_id) getMainBuffer()->bindCallID (*iter_p, Call::DEFAULT_ID); // Then remove the conference from the conference map - if (_conferencemap.erase (conference_id) == 1) + if (_conferencemap.erase(conference_id) == 1) _debug ("Manager: Conference %s removed successfully", conference_id.c_str()); else _error ("Manager: Error: Cannot remove conference: %s", conference_id.c_str()); @@ -668,10 +671,8 @@ void ManagerImpl::removeConference (const std::string& conference_id) Conference* ManagerImpl::getConferenceFromCallID (const std::string& call_id) { - std::string account_id; - - account_id = getAccountFromCall (call_id); - Call *call = getAccountLink (account_id)->getCall (call_id); + std::string account_id(getAccountFromCall(call_id)); + Call *call = getAccountLink(account_id)->getCall(call_id); ConferenceMap::const_iterator iter = _conferencemap.find (call->getConfId()); @@ -694,11 +695,11 @@ void ManagerImpl::holdConference (const std::string& id) conf->getState() == Conference::ACTIVE_DETACHED_REC || conf->getState() == Conference::HOLD_REC; - const ParticipantSet &participants = conf->getParticipantList(); - ParticipantSet::const_iterator iter; - for (iter = participants.begin(); iter != participants.end(); ++iter) { - switchCall (*iter); - onHoldCall (*iter); + ParticipantSet participants(conf->getParticipantList()); + for (ParticipantSet::const_iterator iter = participants.begin(); + iter != participants.end(); ++iter) { + switchCall(*iter); + onHoldCall(*iter); } conf->setState(isRec ? Conference::HOLD_REC : Conference::HOLD); @@ -715,7 +716,7 @@ void ManagerImpl::unHoldConference (const std::string& id) conf->getState() == Conference::ACTIVE_DETACHED_REC or conf->getState() == Conference::HOLD_REC; - const ParticipantSet &participants(conf->getParticipantList()); + ParticipantSet participants(conf->getParticipantList()); for (ParticipantSet::const_iterator iter = participants.begin(); iter!= participants.end(); ++iter) { Call *call = getAccountLink(getAccountFromCall(*iter))->getCall(*iter); @@ -808,7 +809,7 @@ void ManagerImpl::addParticipant (const std::string& callId, const std::string& conf->bindParticipant (callId); } - const ParticipantSet &participants(conf->getParticipantList()); + ParticipantSet participants(conf->getParticipantList()); if (participants.empty()) _error("Manager: Error: Participant list is empty for this conference"); @@ -841,7 +842,7 @@ void ManagerImpl::addMainParticipant (const std::string& conference_id) if (iter != _conferencemap.end()) { Conference *conf = iter->second; - const ParticipantSet &participants = conf->getParticipantList(); + ParticipantSet participants(conf->getParticipantList()); for (ParticipantSet::const_iterator iter_p = participants.begin(); iter_p != participants.end(); ++iter_p) { @@ -1051,7 +1052,7 @@ void ManagerImpl::detachParticipant (const std::string& call_id, else { onHoldCall (call_id); removeParticipant (call_id); - processRemainingParticipant (current_call_id, conf); + processRemainingParticipants(current_call_id, conf); } _dbus.getCallManager()->conferenceChanged (conf->getConfID(), conf->getStateStr()); } else { @@ -1111,9 +1112,9 @@ void ManagerImpl::removeParticipant (const std::string& call_id) _dbus.getCallManager()->conferenceChanged (conf->getConfID(), conf->getStateStr()); } -void ManagerImpl::processRemainingParticipant (const std::string ¤t_call_id, Conference *conf) +void ManagerImpl::processRemainingParticipants(const std::string ¤t_call_id, Conference *conf) { - const ParticipantSet &participants = conf->getParticipantList(); + ParticipantSet participants(conf->getParticipantList()); size_t n = participants.size(); _debug ("Manager: Process remaining %d participant(s) from conference %s", n, conf->getConfID().c_str()); @@ -1123,7 +1124,7 @@ void ManagerImpl::processRemainingParticipant (const std::string ¤t_call_i for (ParticipantSet::const_iterator iter_p = participants.begin(); iter_p != participants.end(); ++iter_p) - getMainBuffer()->flush (*iter_p); + getMainBuffer()->flush(*iter_p); getMainBuffer()->flush (Call::DEFAULT_ID); } else if (n == 1) { @@ -1133,7 +1134,7 @@ void ManagerImpl::processRemainingParticipant (const std::string ¤t_call_i if (iter_participant != participants.end()) { // this call is no more a conference participant - std::string currentAccountId(getAccountFromCall (*iter_participant)); + std::string currentAccountId(getAccountFromCall(*iter_participant)); Call *call = getAccountLink(currentAccountId)->getCall(*iter_participant); call->setConfId (""); @@ -1146,7 +1147,7 @@ void ManagerImpl::processRemainingParticipant (const std::string ¤t_call_i removeConference (conf->getConfID()); } else { - _debug ("Manager: No remaining participant, remove conference"); + _debug ("Manager: No remaining participants, remove conference"); removeConference (conf->getConfID()); switchCall (""); } @@ -1169,7 +1170,7 @@ void ManagerImpl::joinConference (const std::string& conf_id1, return; } - const ParticipantSet &participants(conf1->getParticipantList()); + ParticipantSet participants(conf1->getParticipantList()); for (ParticipantSet::const_iterator iter_p = participants.begin(); iter_p != participants.end(); ++iter_p) { @@ -1196,7 +1197,7 @@ void ManagerImpl::addStream (const std::string& call_id) conf->bindParticipant (call_id); - const ParticipantSet &participants(conf->getParticipantList()); + ParticipantSet participants(conf->getParticipantList()); // reset ring buffer for all conference participant for (ParticipantSet::const_iterator iter_p = participants.begin(); @@ -1407,7 +1408,7 @@ void ManagerImpl::incomingMessage (const std::string& callID, if (participToConference (callID)) { Conference *conf = getConferenceFromCallID (callID); - const ParticipantSet &participants = conf->getParticipantList(); + ParticipantSet participants(conf->getParticipantList()); for (ParticipantSet::const_iterator iter_p = participants.begin(); iter_p != participants.end(); ++iter_p) { @@ -1450,7 +1451,7 @@ bool ManagerImpl::sendTextMessage (const std::string& callID, const std::string& if (!conf) return false; - const ParticipantSet participants = conf->getParticipantList(); + ParticipantSet participants(conf->getParticipantList()); for (ParticipantSet::const_iterator iter_p = participants.begin(); iter_p != participants.end(); ++iter_p) { @@ -1478,7 +1479,7 @@ bool ManagerImpl::sendTextMessage (const std::string& callID, const std::string& if (!conf) return false; - const ParticipantSet participants(conf->getParticipantList()); + ParticipantSet participants(conf->getParticipantList()); for (ParticipantSet::const_iterator iter_p = participants.begin(); iter_p != participants.end(); ++iter_p) { @@ -1552,7 +1553,7 @@ void ManagerImpl::peerHungupCall (const std::string& call_id) if (conf != NULL) { removeParticipant (call_id); - processRemainingParticipant (getCurrentCallId(), conf); + processRemainingParticipants(getCurrentCallId(), conf); } } else { if (isCurrentCall (call_id)) { @@ -1620,7 +1621,7 @@ void ManagerImpl::callFailure (const std::string& call_id) // remove this participant removeParticipant (call_id); - processRemainingParticipant (getCurrentCallId(), conf); + processRemainingParticipants(getCurrentCallId(), conf); } removeCallAccount (call_id); @@ -2984,16 +2985,16 @@ std::vector<std::string> ManagerImpl::getConferenceList (void) const return v; } -std::vector<std::string> ManagerImpl::getParticipantList (const std::string& confID) const +std::vector<std::string> ManagerImpl::getParticipantList(const std::string& confID) const { std::vector<std::string> v; ConferenceMap::const_iterator iter_conf = _conferencemap.find (confID); if (iter_conf != _conferencemap.end()) { - const ParticipantSet &participants = iter_conf->second->getParticipantList(); + const ParticipantSet participants(iter_conf->second->getParticipantList()); std::copy(participants.begin(), participants.end(), std::back_inserter(v));; } else - _warn ("Manager: Warning: Did not found conference %s", confID.c_str()); + _warn ("Manager: Warning: Did not find conference %s", confID.c_str()); return v; } diff --git a/daemon/src/managerimpl.h b/daemon/src/managerimpl.h index 653739ec4c845e92d6b50508bbda442eff9eaba9..43a77acfa500834d757255e5766ea11e2597c613 100644 --- a/daemon/src/managerimpl.h +++ b/daemon/src/managerimpl.h @@ -942,7 +942,7 @@ class ManagerImpl * @param current call id * @param conference pointer */ - void processRemainingParticipant (const std::string ¤t_call_id, Conference *conf); + void processRemainingParticipants(const std::string ¤t_call_id, Conference *conf); /** * Create config directory in home user and return configuration file path @@ -978,7 +978,7 @@ class ManagerImpl Conf::ConfigTree _config; /** Current Call ID */ - std::string _currentCallId2; + std::string currentCallId_; /** Protected current call access */ ost::Mutex _currentCallMutex; diff --git a/gnome/src/accountlist.c b/gnome/src/accountlist.c index 31cd720372a5720b72591b5dfa824d43cf4d7038..61eeeca18018b3ef8784a0ddd0d19b949b218eaa 100644 --- a/gnome/src/accountlist.c +++ b/gnome/src/accountlist.c @@ -93,7 +93,7 @@ account_list_get_by_state (account_state_t state) } account_t * -account_list_get_by_id (gchar * accountID) +account_list_get_by_id (const gchar * const accountID) { GList * c = g_queue_find_custom (accountQueue, accountID, is_accountID_struct); diff --git a/gnome/src/accountlist.h b/gnome/src/accountlist.h index fefcab66b135f84b14dda915f2cd1867708de8b2..559bb4a030dd625489b1b9194f39f4cc63fb3476 100644 --- a/gnome/src/accountlist.h +++ b/gnome/src/accountlist.h @@ -153,7 +153,7 @@ void account_list_free (); * @param accountID The ID of the account * @return An account or NULL */ -account_t * account_list_get_by_id (gchar * accountID); +account_t * account_list_get_by_id (const gchar * const accountID); /** * Move the account from an unit up in the account_list diff --git a/gnome/src/actions.c b/gnome/src/actions.c index 21d84660c65b68300100b26a0e64bef3b5620052..f9fbdc0ab8d6988871ee141fb091382fec5d3d3e 100644 --- a/gnome/src/actions.c +++ b/gnome/src/actions.c @@ -55,6 +55,7 @@ #include "actions.h" #include "dbus/dbus.h" #include "logger.h" +#include "contacts/calltab.h" #include "contacts/searchbar.h" #include "contacts/addrbookfactory.h" #include "icons/icon_factory.h" @@ -220,7 +221,7 @@ sflphone_hung_up (callable_obj_t * c) DEBUG ("SFLphone: Hung up"); calllist_remove_call (current_calls, c->_callID); - calltree_remove_call (current_calls, c, NULL); + calltree_remove_call (current_calls, c); c->_state = CALL_STATE_DIALING; call_remove_all_errors (c); update_actions(); @@ -368,7 +369,11 @@ sflphone_hang_up() DEBUG ("SFLphone: Hang up"); - if (selectedCall) { + if (selectedConf) { + im_widget_update_state (IM_WIDGET (selectedConf->_im_widget), FALSE); + dbus_hang_up_conference (selectedConf); + } + else if (selectedCall) { switch (selectedCall->_state) { case CALL_STATE_DIALING: dbus_hang_up (selectedCall); @@ -411,9 +416,6 @@ sflphone_hang_up() WARN ("Should not happen in sflphone_hang_up()!"); break; } - } else if (selectedConf) { - im_widget_update_state (IM_WIDGET (selectedConf->_im_widget), FALSE); - dbus_hang_up_conference (selectedConf); } calltree_update_call (history, selectedCall, NULL); @@ -454,7 +456,7 @@ sflphone_pick_up() case CALL_STATE_TRANSFER: dbus_transfer (selectedCall); time (&selectedCall->_time_stop); - calltree_remove_call(current_calls, selectedCall, NULL); + calltree_remove_call(current_calls, selectedCall); calllist_remove_call(current_calls, selectedCall->_callID); break; case CALL_STATE_CURRENT: @@ -750,7 +752,7 @@ sflphone_keypad (guint keyval, gchar * key) case GDK_KP_Enter: dbus_transfer (c); time (&c->_time_stop); - calltree_remove_call(current_calls, c, NULL); + calltree_remove_call(current_calls, c); break; case GDK_Escape: sflphone_unset_transfer (); @@ -897,7 +899,7 @@ sflphone_detach_participant (const gchar* callID) selectedCall->_confID = NULL; } im_widget_update_state (IM_WIDGET (selectedCall->_im_widget), TRUE); - calltree_remove_call (current_calls, selectedCall, NULL); + calltree_remove_call (current_calls, selectedCall); calltree_add_call (current_calls, selectedCall, NULL); dbus_detach_participant (selectedCall->_callID); } diff --git a/gnome/src/callable_obj.c b/gnome/src/callable_obj.c index d1d7b1c306181ed1ef0a14ac4dd0199b049ca38d..3519db500ef545a7281739411303cb6d5e0a551f 100644 --- a/gnome/src/callable_obj.c +++ b/gnome/src/callable_obj.c @@ -32,6 +32,7 @@ #include "codeclist.h" #include "sflphone_const.h" #include <time.h> +#include "contacts/calltab.h" #include "contacts/calltree.h" #include "dbus.h" #include <unistd.h> diff --git a/gnome/src/callable_obj.h b/gnome/src/callable_obj.h index 97c1d75d7711fdb7a26950c42b13a9ce325defab..2f81d683e7e372360487cd75e7ecf2201c066702 100644 --- a/gnome/src/callable_obj.h +++ b/gnome/src/callable_obj.h @@ -31,10 +31,9 @@ #ifndef __CALLABLE_OBJ_H__ #define __CALLABLE_OBJ_H__ -#include <gtk/gtk.h> -#include <glib/gprintf.h> #include <stdlib.h> #include <time.h> +#include <gtk/gtk.h> /** * @enum history_state @@ -98,7 +97,6 @@ typedef enum { * This struct holds information about a call. */ typedef struct { - callable_type_t _type; // CALL - HISTORY ENTRY - CONTACT call_state_t _state; // The state of the call int _state_code; // The numeric state code as defined in SIP or IAX @@ -200,8 +198,7 @@ gchar* call_get_peer_name (const gchar*); */ gchar* call_get_peer_number (const gchar*); -void -free_callable_obj_t (callable_obj_t *c); +void free_callable_obj_t (callable_obj_t *c); gchar* get_peer_info (const gchar* const, const gchar* const); diff --git a/gnome/src/conference_obj.c b/gnome/src/conference_obj.c index 47154e1e717cdf61375c37a5c2c18ecef4e82443..e9e371638feb3c765644d44943d81ff965c0a4d8 100644 --- a/gnome/src/conference_obj.c +++ b/gnome/src/conference_obj.c @@ -37,10 +37,8 @@ #include "calltab.h" #include "calllist.h" -conference_obj_t *create_new_conference (conference_state_t state, const gchar* const confID) +conference_obj_t *create_new_conference(conference_state_t state, const gchar* const confID) { - conference_obj_t *new_conf; - if (confID == NULL) { ERROR("Conference: Error: Conference ID is NULL while creating new conference"); return NULL; @@ -49,7 +47,7 @@ conference_obj_t *create_new_conference (conference_state_t state, const gchar* DEBUG ("Conference: Create new conference %s", confID); // Allocate memory - new_conf = g_new0 (conference_obj_t, 1); + conference_obj_t *new_conf = g_new0(conference_obj_t, 1); if (!new_conf) { ERROR("Conference: Error: Could not allocate data "); return NULL; @@ -61,14 +59,9 @@ conference_obj_t *create_new_conference (conference_state_t state, const gchar* // Set the ID field new_conf->_confID = g_strdup (confID); - new_conf->participant_list = NULL; - new_conf->participant_number = NULL; - - new_conf->_recordfile = NULL; - new_conf->_record_is_playing = FALSE; - // set conference timestamp time(&new_conf->_time_start); + g_assert(new_conf->_im_widget == NULL); return new_conf; } @@ -78,11 +71,6 @@ conference_obj_t *create_new_conference_from_details (const gchar *conf_id, GHas conference_obj_t *new_conf = g_new0 (conference_obj_t, 1); new_conf->_confID = g_strdup (conf_id); - new_conf->_conference_secured = FALSE; - new_conf->_conf_srtp_enabled = FALSE; - - new_conf->participant_list = NULL; - gchar **participants = dbus_get_participant_list (conf_id); if (participants) { conference_participant_list_update (participants, new_conf); @@ -104,10 +92,6 @@ conference_obj_t *create_new_conference_from_details (const gchar *conf_id, GHas else if (g_strcasecmp (state_str, "HOLD_REC") == 0) new_conf->_state = CONFERENCE_STATE_HOLD_RECORD; - - new_conf->_recordfile = NULL; - new_conf->_record_is_playing = FALSE; - return new_conf; } @@ -132,7 +116,6 @@ void conference_add_participant_number(const gchar *call_id, conference_obj_t *c } gchar *number_account = g_strconcat(call->_peer_number, ",", call->_accountID, NULL); - conf->participant_number = g_slist_append(conf->participant_number, number_account); } @@ -150,22 +133,18 @@ void conference_add_participant (const gchar* call_id, conference_obj_t* conf) void conference_remove_participant (const gchar* call_id, conference_obj_t* conf) { // store the new participant list after removing participant id - conf->participant_list = g_slist_remove (conf->participant_list, (gconstpointer) call_id); + conf->participant_list = g_slist_remove(conf->participant_list, (gconstpointer) call_id); } GSList* conference_next_participant (GSList* participant) { - return g_slist_next (participant); + return g_slist_next(participant); } void conference_participant_list_update (gchar** participants, conference_obj_t* conf) { - gchar* call_id; - gchar** part; - callable_obj_t *call; - DEBUG ("Conference: Participant list update"); if (!conf) { @@ -173,9 +152,9 @@ void conference_participant_list_update (gchar** participants, conference_obj_t* return; } - for (part = participants; *part; part++) { - call_id = (gchar *) (*part); - call = calllist_get_call(current_calls, call_id); + for (gchar **part = participants; part && *part; part++) { + gchar *call_id = (gchar *) (*part); + callable_obj_t *call = calllist_get_call(current_calls, call_id); if(call->_confID != NULL) { g_free(call->_confID); call->_confID = NULL; @@ -187,9 +166,9 @@ void conference_participant_list_update (gchar** participants, conference_obj_t* conf->participant_list = NULL; } - for (part = participants; *part; part++) { - call_id = (gchar*) (*part); - call = calllist_get_call(current_calls, call_id); + for (gchar **part = participants; part && *part; part++) { + gchar *call_id = (gchar*) (*part); + callable_obj_t *call = calllist_get_call(current_calls, call_id); call->_confID = g_strdup(conf->_confID); conference_add_participant (call_id, conf); } @@ -213,7 +192,7 @@ gchar *serialize_history_conference_entry(conference_obj_t *entry) time_start = g_strdup_printf ("%i", (int) entry->_time_start); time_stop = g_strdup_printf ("%i", (int) entry->_time_stop); - peer_name = (entry->_confID == NULL || g_strcasecmp(entry->_confID, "") == 0) ? "empty": entry->_confID; + peer_name = (entry->_confID == NULL || (strlen(entry->_confID) == 0)) ? "empty": entry->_confID; length = g_slist_length(entry->participant_list); participant_list = entry->participant_list; @@ -228,15 +207,15 @@ gchar *serialize_history_conference_entry(conference_obj_t *entry) } result = g_strconcat("9999", separator, - participantstr, separator, // peer number - peer_name, separator, - time_start, separator, - time_stop, separator, - confID, separator, - "empty", separator, // peer AccountID - entry->_recordfile ? entry->_recordfile : "", separator, - "empty", separator, - "empty", NULL); + participantstr, separator, // peer number + peer_name, separator, + time_start, separator, + time_stop, separator, + confID, separator, + "empty", separator, // peer AccountID + entry->_recordfile ? entry->_recordfile : "", separator, + "empty", separator, + "empty", NULL); return result; } diff --git a/gnome/src/contacts/calllist.c b/gnome/src/contacts/calllist.c index a6394ab0935a7302a10dd32152804e08210c8e52..f7f1410db9fdb6868c01f319de08778969577b6e 100644 --- a/gnome/src/contacts/calllist.c +++ b/gnome/src/contacts/calllist.c @@ -29,6 +29,7 @@ */ #include "calllist.h" +#include "calltab.h" #include "calltree.h" #include "logger.h" #include "contacts/searchbar.h" @@ -38,13 +39,13 @@ static gint is_callID_callstruct(gconstpointer a, gconstpointer b) { const QueueElement *c = a; - if(c == NULL || c->type != HIST_CALL) - return 1; + if (c == NULL || c->type != HIST_CALL) + return 1; return g_strcasecmp(c->elem.call->_callID, (const gchar *) b); } -// TODO : sflphoneGTK : try to do this more generic +// TODO : try to do this more generically void calllist_add_contact (gchar *contact_name, gchar *contact_phone, contact_type_t type, GdkPixbuf *photo) { /* Check if the information is valid */ @@ -54,9 +55,9 @@ void calllist_add_contact (gchar *contact_name, gchar *contact_phone, contact_ty callable_obj_t *new_call = create_new_call (CONTACT, CALL_STATE_DIALING, "", "", contact_name, contact_phone); // Attach a pixbuf to a contact - if (photo) { + if (photo) new_call->_contact_thumbnail = gdk_pixbuf_copy (photo); - } else { + else { GdkPixbuf *pixbuf; switch (type) { case CONTACT_PHONE_BUSINESS: @@ -146,9 +147,9 @@ calllist_clean_history (void) for (guint i = 0; i < size; i++) { QueueElement* c = calllist_get_nth(history, i); if (c->type == HIST_CALL) - calltree_remove_call (history, c->elem.call, NULL); + calltree_remove_call (history, c->elem.call); else if(c->type == HIST_CONFERENCE) - calltree_remove_conference (history, c->elem.conf, NULL); + calltree_remove_conference (history, c->elem.conf); } calllist_reset (history); @@ -158,16 +159,15 @@ void calllist_remove_from_history (callable_obj_t* c) { calllist_remove_call(history, c->_callID); - calltree_remove_call(history, c, NULL); + calltree_remove_call(history, c); } void calllist_remove_call (calltab_t* tab, const gchar * callID) { GList *c = g_queue_find_custom (tab->callQueue, callID, is_callID_callstruct); - if (c == NULL) { + if (c == NULL) return; - } QueueElement *element = (QueueElement *)c->data; if (element->type != HIST_CALL) { diff --git a/gnome/src/contacts/calltab.h b/gnome/src/contacts/calltab.h index e9d0e70b1afe2da2044954a62d158dcc9b33f0ea..8472af18a842b800014687389a3f77245dc2a3ba 100644 --- a/gnome/src/contacts/calltab.h +++ b/gnome/src/contacts/calltab.h @@ -31,8 +31,8 @@ #ifndef __CALLTAB_H__ #define __CALLTAB_H__ -#include <calllist.h> -#include <conferencelist.h> +#include "calllist.h" +#include "conferencelist.h" #include <gtk/gtk.h> calltab_t* active_calltree; diff --git a/gnome/src/contacts/calltree.c b/gnome/src/contacts/calltree.c index 349412b8a1e4b821606f25459c7ba0dcc333cc80..00b2acfc07436e439388c0416e245308037858ed 100644 --- a/gnome/src/contacts/calltree.c +++ b/gnome/src/contacts/calltree.c @@ -30,13 +30,14 @@ * as that of the covered work. */ +#include "calllist.h" #include "calltree.h" #include <stdlib.h> #include <glib/gprintf.h> #include "eel-gconf-extensions.h" #include "dbus.h" -#include "calllist.h" +#include "calltab.h" #include "logger.h" #include "conferencelist.h" #include "mainwindow.h" @@ -48,8 +49,8 @@ #include "searchbar.h" // Messages used in menu item -#define SFL_CREATE_CONFERENCE "Create conference" -#define SFL_TRANSFER_CALL "Transfer call to" +static const gchar * const SFL_CREATE_CONFERENCE = "Create conference"; +static const gchar * const SFL_TRANSFER_CALL = "Transfer call to"; static GtkWidget *calltree_sw = NULL; static GtkCellRenderer *calltree_rend = NULL; @@ -125,18 +126,19 @@ call_selected_cb (GtkTreeSelection *sel, void* data UNUSED) gchar *string_path = gtk_tree_path_to_string (path); calltree_selected_path_depth = gtk_tree_path_get_depth (path); - GValue val; if (gtk_tree_model_iter_has_child (GTK_TREE_MODEL (model), &iter)) { DEBUG ("CallTree: Selected a conference"); calltree_selected_type = A_CONFERENCE; + GValue val; val.g_type = 0; gtk_tree_model_get_value (model, &iter, COLUMN_ACCOUNT_PTR, &val); calltab_select_conf ( active_calltree, (conference_obj_t*) g_value_get_pointer (&val)); calltree_selected_conf = (conference_obj_t*) g_value_get_pointer (&val); + g_value_unset (&val); if (calltree_selected_conf) { @@ -152,16 +154,17 @@ call_selected_cb (GtkTreeSelection *sel, void* data UNUSED) calltree_selected_path, calltree_selected_call_id, calltree_selected_path_depth); } else { - DEBUG ("CallTree: Selected a call"); calltree_selected_type = A_CALL; + GValue val; val.g_type = 0; gtk_tree_model_get_value (model, &iter, COLUMN_ACCOUNT_PTR, &val); calltab_select_call (active_calltree, (callable_obj_t*) g_value_get_pointer (&val)); calltree_selected_call = (callable_obj_t*) g_value_get_pointer (&val); + g_value_unset (&val); if (calltree_selected_call) { @@ -177,7 +180,6 @@ call_selected_cb (GtkTreeSelection *sel, void* data UNUSED) calltree_selected_path, calltree_selected_call_id, calltree_selected_path_depth); } - g_value_unset (&val); update_actions(); } @@ -261,13 +263,13 @@ row_activated (GtkTreeView *tree_view UNUSED, return; } - calltree_create_conf_from_participant_list(selectedConf->participant_list); - calltree_display(current_calls); + calltree_create_conf_from_participant_list(selectedConf->participant_list); + calltree_display(current_calls); } } } -static void +static void calltree_create_conf_from_participant_list(GSList *list) { gchar **participant_list; @@ -277,7 +279,7 @@ calltree_create_conf_from_participant_list(GSList *list) participant_list = (void *) malloc(sizeof(void*)); - // concatenate + // concatenate gint i, c; for(i = 0, c = 0; i < list_length; i++, c++) { gchar *number; @@ -303,22 +305,19 @@ calltree_create_conf_from_participant_list(GSList *list) static void row_single_click (GtkTreeView *tree_view UNUSED, void * data UNUSED) { - callable_obj_t * selectedCall = NULL; - conference_obj_t *selectedConf = NULL; gchar * displaySasOnce = NULL; DEBUG ("CallTree: Single click action"); - selectedCall = calltab_get_selected_call (active_calltree); - selectedConf = calltab_get_selected_conf (active_calltree); + callable_obj_t *selectedCall = calltab_get_selected_call (active_calltree); + conference_obj_t *selectedConf = calltab_get_selected_conf (active_calltree); if (active_calltree == current_calls) DEBUG("CallTree: Active calltree is current_calls"); else if (active_calltree == history) DEBUG("CallTree: Active calltree is history"); - if(calltab_get_selected_type(active_calltree) == A_CALL) { - + if (calltab_get_selected_type(active_calltree) == A_CALL) { DEBUG("CallTree: Selected a call"); if (selectedCall) { @@ -448,11 +447,8 @@ calltree_display_call_info (callable_obj_t * c, CallDisplayType display_type, co } void -calltree_create (calltab_t* tab, gboolean searchbar_type) +calltree_create (calltab_t* tab, int searchbar_type) { - gchar *conference = SFL_CREATE_CONFERENCE; - gchar *transfer = SFL_TRANSFER_CALL; - tab->tree = gtk_vbox_new (FALSE, 10); // Fix bug #708 (resize) @@ -507,15 +503,15 @@ calltree_create (calltab_t* tab, gboolean searchbar_type) calltree_popupmenu = gtk_menu_new (); - calltree_menu_items = gtk_menu_item_new_with_label (transfer); + calltree_menu_items = gtk_menu_item_new_with_label(SFL_TRANSFER_CALL); g_signal_connect_swapped (calltree_menu_items, "activate", - G_CALLBACK (menuitem_response), (gpointer) g_strdup (transfer)); + G_CALLBACK (menuitem_response), (gpointer) g_strdup(SFL_TRANSFER_CALL)); gtk_menu_shell_append (GTK_MENU_SHELL (calltree_popupmenu), calltree_menu_items); gtk_widget_show (calltree_menu_items); - calltree_menu_items = gtk_menu_item_new_with_label (conference); + calltree_menu_items = gtk_menu_item_new_with_label (SFL_CREATE_CONFERENCE); g_signal_connect_swapped (calltree_menu_items, "activate", - G_CALLBACK (menuitem_response), (gpointer) g_strdup (conference)); + G_CALLBACK (menuitem_response), (gpointer) g_strdup(SFL_CREATE_CONFERENCE)); gtk_menu_shell_append (GTK_MENU_SHELL (calltree_popupmenu), calltree_menu_items); gtk_widget_show (calltree_menu_items); } @@ -537,7 +533,12 @@ calltree_create (calltab_t* tab, gboolean searchbar_type) "markup", COLUMN_ACCOUNT_DESC, NULL); g_object_set (calltree_rend, "wrap-mode", (PangoWrapMode) PANGO_WRAP_WORD_CHAR, NULL); - g_object_set (calltree_rend, "wrap-width", (gint) CALLTREE_TEXT_WIDTH, NULL); + + static const gint SFLPHONE_HIG_MARGIN = 10; + static const gint CALLTREE_CALL_ICON_WIDTH = 24; + static const gint CALLTREE_SECURITY_ICON_WIDTH = 24; + gint CALLTREE_TEXT_WIDTH = (MAIN_WINDOW_WIDTH - CALLTREE_SECURITY_ICON_WIDTH - CALLTREE_CALL_ICON_WIDTH - (2*SFLPHONE_HIG_MARGIN)); + g_object_set (calltree_rend, "wrap-width", CALLTREE_TEXT_WIDTH, NULL); gtk_tree_view_append_column (GTK_TREE_VIEW (tab->view), calltree_col); /* Security icon */ @@ -571,8 +572,8 @@ calltree_create (calltab_t* tab, gboolean searchbar_type) } -void -calltree_remove_call (calltab_t* tab, callable_obj_t * c, GtkTreeIter *parent) +static void +calltree_remove_call_recursive(calltab_t* tab, callable_obj_t * c, GtkTreeIter *parent) { GtkTreeIter iter; GtkTreeStore* store = tab->store; @@ -582,11 +583,11 @@ calltree_remove_call (calltab_t* tab, callable_obj_t * c, GtkTreeIter *parent) DEBUG ("CallTree: Remove call %s", c->_callID); - int nbChild = gtk_tree_model_iter_n_children (GTK_TREE_MODEL (store), parent); + int nbChild = gtk_tree_model_iter_n_children(GTK_TREE_MODEL(store), parent); for (int i = 0; i < nbChild; i++) { if (gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (store), &iter, parent, i)) { if (gtk_tree_model_iter_has_child (GTK_TREE_MODEL (store), &iter)) - calltree_remove_call (tab, c, &iter); + calltree_remove_call_recursive(tab, c, &iter); GValue val = { .g_type = 0 }; gtk_tree_model_get_value (GTK_TREE_MODEL (store), &iter, COLUMN_ACCOUNT_PTR, &val); @@ -595,7 +596,7 @@ calltree_remove_call (calltab_t* tab, callable_obj_t * c, GtkTreeIter *parent) g_value_unset (&val); if (iterCall == c) - gtk_tree_store_remove (store, &iter); + gtk_tree_store_remove(store, &iter); } } @@ -607,6 +608,12 @@ calltree_remove_call (calltab_t* tab, callable_obj_t * c, GtkTreeIter *parent) statusbar_update_clock(""); } +void +calltree_remove_call(calltab_t* tab, callable_obj_t * c) +{ + calltree_remove_call_recursive(tab, c, NULL); +} + void calltree_update_call (calltab_t* tab, callable_obj_t * c, GtkTreeIter *parent) { @@ -975,18 +982,8 @@ void calltree_add_history_entry (callable_obj_t *c, GtkTreeIter *parent) void calltree_add_conference (calltab_t* tab, conference_obj_t* conf) { - GdkPixbuf *pixbuf = NULL; - GdkPixbuf *pixbuf_security = NULL; - GtkTreeIter iter; - GtkTreePath *path; - GtkTreeModel *model = (GtkTreeModel*) tab->store; - GSList *conference_participant; - gchar *call_id; - callable_obj_t *call; account_t *account_details = NULL; gchar *srtp_enabled = ""; - // New call in the list - gchar * description; if (!conf) { ERROR ("Calltree: Error: Conference is null"); @@ -1000,10 +997,12 @@ void calltree_add_conference (calltab_t* tab, conference_obj_t* conf) return; } - description = g_markup_printf_escaped ("<b>%s</b>", ""); + gchar *description = g_markup_printf_escaped ("<b>%s</b>", ""); + GtkTreeIter iter; gtk_tree_store_append (tab->store, &iter, NULL); + GdkPixbuf *pixbuf = NULL; if (tab == current_calls) { switch (conf->_state) { case CONFERENCE_STATE_ACTIVE_ATTACHED: @@ -1037,6 +1036,7 @@ void calltree_add_conference (calltab_t* tab, conference_obj_t* conf) } else DEBUG ("Error no pixbuff for conference from %s", ICONS_DIR); + GdkPixbuf *pixbuf_security = NULL; if (tab == current_calls) { // Used to determine if at least one participant use a security feature @@ -1047,17 +1047,15 @@ void calltree_add_conference (calltab_t* tab, conference_obj_t* conf) // Every participant to a conference must be secured, the conference is not secured elsewhere conf->_conference_secured = TRUE; - conference_participant = conf->participant_list; + GSList *conference_participant = conf->participant_list; if (conference_participant) { - DEBUG ("Calltree: Determine if at least one participant uses SRTP"); - while (conference_participant) { - call_id = (gchar*) (conference_participant->data); - call = calllist_get_call(tab, call_id); - if (call == NULL) { + const gchar * const call_id = conference_participant->data; + callable_obj_t *call = calllist_get_call(tab, call_id); + if (call == NULL) ERROR("Calltree: Error: Could not find call %s in call list", call_id); - } else { + else { account_details = account_list_get_by_id (call->_accountID); if (!account_details) ERROR("Calltree: Error: Could not find account %s in account list", call->_accountID); @@ -1082,8 +1080,8 @@ void calltree_add_conference (calltab_t* tab, conference_obj_t* conf) conference_participant = conf->participant_list; while (conference_participant) { - call_id = (gchar*) (conference_participant->data); - call = calllist_get_call(tab, call_id); + const gchar * const call_id = conference_participant->data; + callable_obj_t *call = calllist_get_call(tab, call_id); if (call) { if (call->_srtp_state == SRTP_STATE_UNLOCKED) { @@ -1122,22 +1120,24 @@ void calltree_add_conference (calltab_t* tab, conference_obj_t* conf) if (pixbuf) g_object_unref (G_OBJECT (pixbuf)); + if (pixbuf_security) + g_object_unref (G_OBJECT (pixbuf_security)); - conference_participant = conf->participant_list; + GSList *conference_participant = conf->participant_list; while (conference_participant) { - call_id = (gchar*) (conference_participant->data); - call = calllist_get_call(tab, call_id); + const gchar * const call_id = conference_participant->data; + callable_obj_t *call = calllist_get_call(tab, call_id); - calltree_remove_call (tab, call, NULL); + calltree_remove_call (tab, call); calltree_add_call (tab, call, &iter); conference_participant = conference_next_participant (conference_participant); } - gtk_tree_view_set_model (GTK_TREE_VIEW (tab->view), GTK_TREE_MODEL (tab->store)); + gtk_tree_view_set_model(GTK_TREE_VIEW(tab->view), GTK_TREE_MODEL(tab->store)); - path = gtk_tree_model_get_path (model, &iter); + GtkTreePath *path = gtk_tree_model_get_path(GTK_TREE_MODEL(tab->store), &iter); gtk_tree_view_expand_row (GTK_TREE_VIEW (tab->view), path, FALSE); @@ -1148,81 +1148,78 @@ void calltree_update_conference (calltab_t* tab, const conference_obj_t* conf) { DEBUG ("CallTree: Update conference %s", conf->_confID); - calltree_remove_conference(tab, conf, NULL); + calltree_remove_conference(tab, conf); calltree_add_conference (tab, (conference_obj_t *)conf); } -void calltree_remove_conference (calltab_t* tab, const conference_obj_t* conf, GtkTreeIter *parent) +static +void calltree_remove_conference_recursive(calltab_t* tab, const conference_obj_t* conf, GtkTreeIter *parent) { - GtkTreeIter iter_parent; - GtkTreeIter iter_child; - GValue confval; - GValue callval; - conference_obj_t *tempconf = NULL; - GtkTreeStore* store = tab->store; - int nbParticipant; - - DEBUG ("CallTree: Remove conference %s", conf->_confID); - - int nbChild = gtk_tree_model_iter_n_children (GTK_TREE_MODEL (store), parent); - - for (int i = 0; i < nbChild; i++) { - if (!gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (store), &iter_parent, parent, i)) - continue; - if (!gtk_tree_model_iter_has_child (GTK_TREE_MODEL (store), &iter_parent)) - continue; - - calltree_remove_conference (tab, conf, &iter_parent); - - confval.g_type = 0; - gtk_tree_model_get_value (GTK_TREE_MODEL (store), &iter_parent, COLUMN_ACCOUNT_PTR, &confval); - - tempconf = (conference_obj_t*) g_value_get_pointer (&confval); - g_value_unset (&confval); - - if (tempconf != conf) - continue; - - nbParticipant = gtk_tree_model_iter_n_children (GTK_TREE_MODEL (store), &iter_parent); - DEBUG ("CallTree: nbParticipant: %d", nbParticipant); - - for (int j = 0; j < nbParticipant; j++) { - if (!gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (store), &iter_child, &iter_parent, j)) - continue; - - callval.g_type = 0; - gtk_tree_model_get_value (GTK_TREE_MODEL (store), &iter_child, COLUMN_ACCOUNT_PTR, &callval); - - callable_obj_t *call = g_value_get_pointer (&callval); - g_value_unset (&callval); - - // do not add back call in history calltree when cleaning it - if (call && tab != history) - calltree_add_call (tab, call, NULL); + int nbChildren = gtk_tree_model_iter_n_children (GTK_TREE_MODEL(tab->store), parent); + + for (int i = 0; i < nbChildren; i++) { + GtkTreeIter iter_parent; + /* if the nth child of parent has one or more children */ + if (gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(tab->store), &iter_parent, parent, i) && + gtk_tree_model_iter_has_child(GTK_TREE_MODEL(tab->store), &iter_parent)) { + + /* RECRUSION! */ + calltree_remove_conference_recursive(tab, conf, &iter_parent); + + GValue confval; + confval.g_type = 0; + gtk_tree_model_get_value (GTK_TREE_MODEL(tab->store), &iter_parent, COLUMN_ACCOUNT_PTR, &confval); + + conference_obj_t *tempconf = (conference_obj_t*) g_value_get_pointer(&confval); + g_value_unset (&confval); + + /* if this is the conference we want to remove */ + if (tempconf == conf) { + int nbParticipants = gtk_tree_model_iter_n_children (GTK_TREE_MODEL(tab->store), &iter_parent); + DEBUG ("CallTree: nbParticipants: %d", nbParticipants); + + for (int j = 0; j < nbParticipants; j++) { + GtkTreeIter iter_child; + if (gtk_tree_model_iter_nth_child (GTK_TREE_MODEL(tab->store), &iter_child, &iter_parent, j)) { + GValue callval; + callval.g_type = 0; + gtk_tree_model_get_value (GTK_TREE_MODEL(tab->store), &iter_child, COLUMN_ACCOUNT_PTR, &callval); + + callable_obj_t *call = g_value_get_pointer (&callval); + g_value_unset (&callval); + + // do not add back call in history calltree when cleaning it + if (call && tab != history) + calltree_add_call (tab, call, NULL); + } + } + DEBUG ("CallTree: Remove conference %s", conf->_confID); + gtk_tree_store_remove (tab->store, &iter_parent); + } } - - gtk_tree_store_remove (store, &iter_parent); } update_actions(); } -void calltree_add_history_conference(conference_obj_t *conf) +void calltree_remove_conference (calltab_t* tab, const conference_obj_t* conf) { - GdkPixbuf *pixbuf = NULL; - const gchar *description = "Conference: \n"; - GtkTreeIter iter; - GSList *conference_participant; + DEBUG ("CallTree: Remove conference %s", conf->_confID); + calltree_remove_conference_recursive(tab, conf, NULL); +} +void calltree_add_history_conference(conference_obj_t *conf) +{ if (!conf) ERROR("CallTree: Error conference is NULL"); DEBUG("CallTree: Add conference %s to history", conf->_confID); + GtkTreeIter iter; gtk_tree_store_prepend(history->store, &iter, NULL); - pixbuf = gdk_pixbuf_new_from_file(ICONS_DIR "/usersAttached.svg", NULL); + GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file(ICONS_DIR "/usersAttached.svg", NULL); if (pixbuf) if (gdk_pixbuf_get_width(pixbuf) > 32 || gdk_pixbuf_get_height(pixbuf) > 32) { @@ -1232,70 +1229,56 @@ void calltree_add_history_conference(conference_obj_t *conf) } const gchar * const date = get_formatted_start_timestamp(conf->_time_start); - description = g_strconcat(description, date, NULL); + const gchar *description = g_strconcat("Conference: \n", date, NULL); gtk_tree_store_set(history->store, &iter, 0, pixbuf, 1, description, 2, NULL, 3, conf, -1); - conference_participant = conf->participant_list; + GSList *conference_participant = conf->participant_list; while (conference_participant) { - const gchar * const call_id = (gchar *)(conference_participant->data); - callable_obj_t *call = calllist_get_call(history, call_id); + const gchar * const call_id = conference_participant->data; + callable_obj_t *call = calllist_get_call(history, call_id); if (call) calltree_add_history_entry(call, &iter); else ERROR("ConferenceList: Error: Could not find call \"%s\"", call_id); - conference_participant = conference_next_participant(conference_participant); + conference_participant = conference_next_participant(conference_participant); } - if(pixbuf != NULL) - g_object_unref(G_OBJECT(pixbuf)); + if (pixbuf != NULL) + g_object_unref(G_OBJECT(pixbuf)); } void calltree_display (calltab_t *tab) { - GtkTreeSelection *sel; - /* If we already are displaying the specified calltree */ if (active_calltree == tab) return; - /* case 1: we want to display the main calltree */ - if (tab==current_calls) { - DEBUG ("CallTree: Display main tab"); - - if (active_calltree==contacts) - gtk_toggle_tool_button_set_active ( (GtkToggleToolButton*) contactButton_, FALSE); + if (tab == current_calls) { + if (active_calltree == contacts) + gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON(contactButton_), FALSE); else - gtk_toggle_tool_button_set_active ( (GtkToggleToolButton*) historyButton_, FALSE); - } - - /* case 2: we want to display the history */ - else if (tab == history) { - DEBUG ("ConferenceList: Display history tab"); + gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON(historyButton_), FALSE); + } else if (tab == history) { if (active_calltree == contacts) - gtk_toggle_tool_button_set_active((GtkToggleToolButton*) contactButton_, FALSE); - - gtk_toggle_tool_button_set_active((GtkToggleToolButton*) historyButton_, TRUE); - } - else if (tab==contacts) { - DEBUG ("CallTree: Display contact tab"); + gtk_toggle_tool_button_set_active(GTK_TOGGLE_TOOL_BUTTON(contactButton_), FALSE); + gtk_toggle_tool_button_set_active(GTK_TOGGLE_TOOL_BUTTON(historyButton_), TRUE); + } else if (tab == contacts) { if (active_calltree == history) - gtk_toggle_tool_button_set_active((GtkToggleToolButton*) historyButton_, FALSE); - - gtk_toggle_tool_button_set_active((GtkToggleToolButton*) contactButton_, TRUE); + gtk_toggle_tool_button_set_active(GTK_TOGGLE_TOOL_BUTTON(historyButton_), FALSE); + gtk_toggle_tool_button_set_active(GTK_TOGGLE_TOOL_BUTTON(contactButton_), TRUE); set_focus_on_addressbook_searchbar(); - } - else + } else ERROR ("CallTree: Error: Not a valid call tab (%d, %s)", __LINE__, __FILE__); - gtk_widget_hide (active_calltree->tree); + gtk_widget_hide(active_calltree->tree); active_calltree = tab; - gtk_widget_show (active_calltree->tree); + gtk_widget_show(active_calltree->tree); - sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (active_calltree->view)); + GtkTreeSelection *sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(active_calltree->view)); DEBUG ("CallTree: Emit signal changed from calltree_display"); g_signal_emit_by_name (sel, "changed"); update_actions(); @@ -1324,6 +1307,7 @@ gboolean calltree_update_clock(gpointer data UNUSED) duration = 0; g_snprintf (timestr, sizeof(timestr), "%.2ld:%.2ld", duration / 60, duration % 60); msg = timestr; + break; } statusbar_update_clock (msg); @@ -1366,7 +1350,7 @@ static void drag_end_cb (GtkWidget * widget UNUSED, GdkDragContext * context UNU DEBUG ("CallTree: Selected an invalid call"); - calltree_remove_call (current_calls, calltree_selected_call, NULL); + calltree_remove_call(current_calls, calltree_selected_call); calltree_add_call (current_calls, calltree_selected_call, NULL); calltree_dragged_call = NULL; @@ -1386,7 +1370,7 @@ static void drag_end_cb (GtkWidget * widget UNUSED, GdkDragContext * context UNU DEBUG ("CallTree: Dragged on an invalid call"); - calltree_remove_call (current_calls, calltree_selected_call, NULL); + calltree_remove_call(current_calls, calltree_selected_call); if (calltree_selected_call->_confID) { @@ -1414,7 +1398,7 @@ static void drag_end_cb (GtkWidget * widget UNUSED, GdkDragContext * context UNU conf = calltree_selected_conf; - calltree_remove_conference (current_calls, conf, NULL); + calltree_remove_conference (current_calls, conf); calltree_add_conference (current_calls, conf); calltree_dragged_call = NULL; @@ -1429,7 +1413,7 @@ static void drag_end_cb (GtkWidget * widget UNUSED, GdkDragContext * context UNU if (gtk_tree_path_compare (dpath, spath) != 0) { // dragged a single call on a single call if (calltree_selected_call != NULL && calltree_dragged_call != NULL) { - calltree_remove_call (current_calls, calltree_selected_call, NULL); + calltree_remove_call(current_calls, calltree_selected_call); calltree_add_call (current_calls, calltree_selected_call, NULL); gtk_menu_popup (GTK_MENU (calltree_popupmenu), NULL, NULL, NULL, NULL, 0, 0); @@ -1455,7 +1439,7 @@ static void drag_end_cb (GtkWidget * widget UNUSED, GdkDragContext * context UNU // dragged a conference on a single call conf = calltree_selected_conf; - calltree_remove_conference (current_calls, conf, NULL); + calltree_remove_conference (current_calls, conf); calltree_add_conference (current_calls, conf); } else if (calltree_selected_type == A_CONFERENCE && calltree_dragged_type == A_CONFERENCE) { @@ -1489,12 +1473,12 @@ static void drag_end_cb (GtkWidget * widget UNUSED, GdkDragContext * context UNU // dragged_path_depth == 2 if (calltree_selected_type == A_CALL && calltree_dragged_type == A_CALL) { // TODO: dragged a call on a conference call - calltree_remove_call (current_calls, calltree_selected_call, NULL); + calltree_remove_call (current_calls, calltree_selected_call); calltree_add_call (current_calls, calltree_selected_call, NULL); } else if (calltree_selected_type == A_CONFERENCE && calltree_dragged_type == A_CALL) { // TODO: dragged a conference on a conference call - calltree_remove_conference (current_calls, calltree_selected_conf, NULL); + calltree_remove_conference (current_calls, calltree_selected_conf); calltree_add_conference (current_calls, calltree_selected_conf); } @@ -1504,7 +1488,6 @@ static void drag_end_cb (GtkWidget * widget UNUSED, GdkDragContext * context UNU } else { if (calltree_dragged_path_depth == 1) { - if (calltree_selected_type == A_CALL && calltree_dragged_type == A_CALL) { // dragged a conference call on a call @@ -1534,7 +1517,6 @@ static void drag_end_cb (GtkWidget * widget UNUSED, GdkDragContext * context UNU // TODO: dragged a conference call on another conference call (different conference) gtk_tree_path_up (path); - gtk_tree_model_get_iter (GTK_TREE_MODEL (model), &parent_conference, path); gtk_tree_path_up (dpath); @@ -1543,7 +1525,7 @@ static void drag_end_cb (GtkWidget * widget UNUSED, GdkDragContext * context UNU if (gtk_tree_path_compare (dpath, spath) == 0) { DEBUG ("Dragged a call in the same conference"); - calltree_remove_call (current_calls, calltree_selected_call, NULL); + calltree_remove_call (current_calls, calltree_selected_call); calltree_add_call (current_calls, calltree_selected_call, &parent_conference); gtk_widget_hide(calltree_menu_items); gtk_menu_popup (GTK_MENU (calltree_popupmenu), NULL, NULL, NULL, NULL, @@ -1552,14 +1534,10 @@ static void drag_end_cb (GtkWidget * widget UNUSED, GdkDragContext * context UNU DEBUG ("Dragged a conference call onto another conference call %s, %s", gtk_tree_path_to_string (dpath), gtk_tree_path_to_string (spath)); conf = NULL; - val.g_type = 0; if (gtk_tree_model_get_iter (model, &iter, dpath)) { - - DEBUG ("we got an iter!"); gtk_tree_model_get_value (model, &iter, COLUMN_ACCOUNT_PTR, &val); - conf = (conference_obj_t*) g_value_get_pointer (&val); } @@ -1567,10 +1545,8 @@ static void drag_end_cb (GtkWidget * widget UNUSED, GdkDragContext * context UNU sflphone_detach_participant (calltree_selected_call_id); - if (conf) { - DEBUG ("we got a conf!"); + if (conf) sflphone_add_participant (calltree_selected_call_id, conf->_confID); - } else DEBUG ("didn't find a conf!"); } @@ -1584,7 +1560,7 @@ static void drag_end_cb (GtkWidget * widget UNUSED, GdkDragContext * context UNU void drag_history_received_cb (GtkWidget *widget, GdkDragContext *context UNUSED, gint x UNUSED, gint y UNUSED, GtkSelectionData *selection_data UNUSED, guint info UNUSED, guint t UNUSED, gpointer data UNUSED) { - g_signal_stop_emission_by_name(G_OBJECT(widget), "drag_data_received"); + g_signal_stop_emission_by_name(G_OBJECT(widget), "drag_data_received"); } void drag_data_received_cb (GtkWidget *widget, GdkDragContext *context UNUSED, gint x UNUSED, gint y UNUSED, GtkSelectionData *selection_data UNUSED, guint info UNUSED, guint t UNUSED, gpointer data UNUSED) @@ -1673,7 +1649,7 @@ void drag_data_received_cb (GtkWidget *widget, GdkDragContext *context UNUSED, g break; default: - return; + break; } } } @@ -1690,7 +1666,7 @@ static void menuitem_response( gchar *string ) calltree_selected_call->_peer_number, calltree_dragged_call->_peer_number); dbus_attended_transfer(calltree_selected_call, calltree_dragged_call); - calltree_remove_call(current_calls, calltree_selected_call, NULL); + calltree_remove_call(current_calls, calltree_selected_call); } else DEBUG("CallTree: Error unknown option selected in menu %s", string); @@ -1699,7 +1675,7 @@ static void menuitem_response( gchar *string ) // The create conference option will hide if tow call from the same conference are draged on each other gtk_widget_show(calltree_menu_items); - printf("%s\n", string); + DEBUG("%s", string); } GtkTreeIter calltree_get_gtkiter_from_id(calltab_t *tab, gchar *id) diff --git a/gnome/src/contacts/calltree.h b/gnome/src/contacts/calltree.h index 770f3da966d3e10267b448b360efa181b8f99499..c47e9e6e8c981902b2ddfca55bb8cc5b9bc1721c 100644 --- a/gnome/src/contacts/calltree.h +++ b/gnome/src/contacts/calltree.h @@ -32,15 +32,6 @@ #ifndef __CALLTREE_H__ #define __CALLTREE_H__ -#include <gtk/gtk.h> -#include <calltab.h> -#include <mainwindow.h> - -#define SFLPHONE_HIG_MARGIN 10 -#define CALLTREE_CALL_ICON_WIDTH 24 -#define CALLTREE_SECURITY_ICON_WIDTH 24 -#define CALLTREE_TEXT_WIDTH (MAIN_WINDOW_WIDTH - CALLTREE_SECURITY_ICON_WIDTH - CALLTREE_CALL_ICON_WIDTH - (2*SFLPHONE_HIG_MARGIN)) - /** @file calltree.h * @brief The GtkTreeView that list calls in the main window. */ @@ -51,7 +42,6 @@ typedef enum { A_INVALID } CallType; - /** * Tags used to identify display type in calltree */ @@ -63,33 +53,37 @@ typedef enum { DISPLAY_TYPE_HISTORY } CallDisplayType; +struct calltab_t; +struct callable_obj_t; +struct conference_obj_t; + /** * Create a new widget calltree * @return GtkWidget* A new widget */ void -calltree_create (calltab_t* tab, gboolean searchbar_type); +calltree_create (calltab_t *, int searchbar_type); /** * Add a call in the calltree * @param c The call to add */ void -calltree_add_call (calltab_t* ct, callable_obj_t * c, GtkTreeIter *parent); +calltree_add_call (calltab_t *, callable_obj_t *, GtkTreeIter *); /* * Update the call tree if the call state changes * @param c The call to update */ void -calltree_update_call (calltab_t* ct, callable_obj_t * c, GtkTreeIter *parent); +calltree_update_call (calltab_t *, callable_obj_t *, GtkTreeIter *); /** * Remove a call from the call tree * @param c The call to remove */ void -calltree_remove_call (calltab_t* ct, callable_obj_t * c, GtkTreeIter *parent); +calltree_remove_call(calltab_t *, callable_obj_t *); /** * Add a callable object to history treeview @@ -100,16 +94,16 @@ void calltree_add_history_entry (callable_obj_t *, GtkTreeIter *); void -calltree_add_conference (calltab_t* tab, conference_obj_t* conf); +calltree_add_conference (calltab_t *, conference_obj_t *); void -calltree_update_conference (calltab_t* tab, const conference_obj_t* conf); +calltree_update_conference (calltab_t *, const conference_obj_t *); void -calltree_remove_conference (calltab_t* tab, const conference_obj_t* conf, GtkTreeIter *parent); +calltree_remove_conference(calltab_t *, const conference_obj_t *); void -calltree_display (calltab_t *tab); +calltree_display (calltab_t *); void row_activated (GtkTreeView *, GtkTreePath *, GtkTreeViewColumn *, void *); diff --git a/gnome/src/contacts/conferencelist.c b/gnome/src/contacts/conferencelist.c index ad29dbc26e99ee6d9f3543bd4bc6bff8ca22770f..13c7974e2ae22ab8327fba168502097f351f91b7 100644 --- a/gnome/src/contacts/conferencelist.c +++ b/gnome/src/contacts/conferencelist.c @@ -28,28 +28,23 @@ * as that of the covered work. */ +#include "calltab.h" +#include "callable_obj.h" #include "calltree.h" #include "conferencelist.h" #include "logger.h" -static gint is_confID_confstruct(gconstpointer, gconstpointer); - static gint is_confID_confstruct (gconstpointer a, gconstpointer b) { conference_obj_t * c = (conference_obj_t*) a; - - if (g_strcasecmp (c->_confID, (const gchar*) b) == 0) { - return 0; - } else { - return 1; - } + return g_strcasecmp (c->_confID, (const gchar*) b); } void conferencelist_init(calltab_t *tab) { if(tab == NULL) { - ERROR("ConferenceList: Error: Call tab is NULL"); - return; + ERROR("ConferenceList: Error: Call tab is NULL"); + return; } tab->conferenceQueue = g_queue_new (); @@ -58,41 +53,28 @@ void conferencelist_init(calltab_t *tab) void conferencelist_clean(calltab_t *tab) { - if(tab == NULL) { - ERROR("ConferenceList: Error: Calltab tab is NULL"); - return; + if (tab == NULL) { + ERROR("ConferenceList: Error: Calltab tab is NULL"); + return; } - g_queue_free (tab->conferenceQueue); } -void -conferencelist_clean_history(void) +void conferencelist_clean_history(void) { - conference_obj_t *conf; - guint size = conferencelist_get_size(history); - - DEBUG("ConferenceList: clean history"); - - while(size > 0) { - conf = conferencelist_pop_head(history); - if(conf) { - calltree_remove_conference(history, conf, NULL); - } - else { - ERROR("ConferenceList: Conference pointer is NULL"); - } - size = conferencelist_get_size(history); + while (conferencelist_get_size(history) > 0) { + conference_obj_t *conf = conferencelist_pop_head(history); + if(conf) + calltree_remove_conference(history, conf); + else + ERROR("ConferenceList: Conference pointer is NULL"); } - - // g_queue_free(history->conferenceQueue); - } void conferencelist_reset(calltab_t *tab) { - if(tab == NULL) { + if (tab == NULL) { ERROR("ConferenceList: Error: Calltab tab is NULL"); return; } @@ -104,68 +86,60 @@ void conferencelist_reset(calltab_t *tab) void conferencelist_add (calltab_t *tab, const conference_obj_t* conf) { - gchar* c; - - if(conf == NULL) { + if (conf == NULL) { ERROR("ConferenceList: Error: Conference is NULL"); - return; + return; } - if(tab == NULL) { - ERROR("ConferenceList: Error: Tab is NULL"); - return; + if (tab == NULL) { + ERROR("ConferenceList: Error: Tab is NULL"); + return; } - c = (gchar*) conferencelist_get (tab, conf->_confID); + conference_obj_t *c = conferencelist_get (tab, conf->_confID); - if (!c) { - // only add conference into the list if not already inserted + // only add conference into the list if not already inserted + if (c == NULL) g_queue_push_tail (tab->conferenceQueue, (gpointer) conf); - } } -void conferencelist_remove (calltab_t *tab, const gchar* conf) +void conferencelist_remove (calltab_t *tab, const gchar* const conf) { - gchar* c; - DEBUG("ConferenceList: Remove conference %s", conf); - if(conf == NULL) { - ERROR("ConferenceList: Error: Conf id is NULL"); - return; + if (conf == NULL) { + ERROR("ConferenceList: Error: Conf id is NULL"); + return; } - if(tab == NULL) { - ERROR("ConferenceList: Error: Calltab is NULL"); - return; + if (tab == NULL) { + ERROR("ConferenceList: Error: Calltab is NULL"); + return; } - c = (gchar*) conferencelist_get (tab, conf); + gchar *c = (gchar*) conferencelist_get (tab, conf); - if(c == NULL) { + if (c == NULL) { ERROR("ConferenceList: Error: Could not find conference %s", conf); - return; + return; } g_queue_remove (tab->conferenceQueue, c); } -conference_obj_t* conferencelist_get (calltab_t *tab, const gchar* conf_id) +conference_obj_t* conferencelist_get (calltab_t *tab, const gchar* const conf_id) { - - GList* c; - DEBUG("ConferenceList: Conference list get %s", conf_id); - if(tab == NULL) { - ERROR("ConferenceList: Error: Calltab is NULL"); - return NULL; + if (tab == NULL) { + ERROR("ConferenceList: Error: Calltab is NULL"); + return NULL; } - c = g_queue_find_custom (tab->conferenceQueue, conf_id, is_confID_confstruct); + GList *c = g_queue_find_custom (tab->conferenceQueue, conf_id, is_confID_confstruct); - if(c == NULL) { + if (c == NULL) { ERROR("ConferenceList: Error: Could not find conference %s", conf_id); return NULL; } @@ -173,21 +147,18 @@ conference_obj_t* conferencelist_get (calltab_t *tab, const gchar* conf_id) return (conference_obj_t*) c->data; } - conference_obj_t* conferencelist_get_nth (calltab_t *tab, guint n) { - conference_obj_t *c; - if(tab == NULL) { ERROR("ConferenceList: Error: Calltab is NULL"); - return NULL; + return NULL; } - c = g_queue_peek_nth (tab->conferenceQueue, n); + conference_obj_t *c = g_queue_peek_nth (tab->conferenceQueue, n); if(c == NULL) { - ERROR("ConferenceList: Error: Could not fetch conference %d", n); - return NULL; + ERROR("ConferenceList: Error: Could not fetch conference %d", n); + return NULL; } return c; @@ -195,9 +166,9 @@ conference_obj_t* conferencelist_get_nth (calltab_t *tab, guint n) conference_obj_t *conferencelist_pop_head(calltab_t *tab) { - if(tab == NULL) { - ERROR("ConferenceList: Error: Tab is NULL"); - return NULL; + if (tab == NULL) { + ERROR("ConferenceList: Error: Tab is NULL"); + return NULL; } return g_queue_pop_head(tab->conferenceQueue); @@ -205,9 +176,9 @@ conference_obj_t *conferencelist_pop_head(calltab_t *tab) guint conferencelist_get_size (calltab_t *tab) { - if(tab == NULL) { + if (tab == NULL) { ERROR("ConferenceList: Error: Calltab is NULL"); - return 0; + return 0; } return g_queue_get_length (tab->conferenceQueue); diff --git a/gnome/src/contacts/conferencelist.h b/gnome/src/contacts/conferencelist.h index a66f4168ebfd961882e3e9deafb9028096495cea..47f1d4d6163b9d573b7df1009e65ebb6ee891684 100644 --- a/gnome/src/contacts/conferencelist.h +++ b/gnome/src/contacts/conferencelist.h @@ -31,63 +31,46 @@ #ifndef __CONFERENCELIST_H__ #define __CONFERENCELIST_H__ -#include <gtk/gtk.h> - -#include "conference_obj.h" -#include "calllist.h" - /** @file conferencelist.h * @brief A list to store conferences. */ -// GQueue* conferenceQueue; - /** This function initialize a conference list. */ -void -conferencelist_init (calltab_t *); +void conferencelist_init (calltab_t *); /** This function empty and free the conference list. */ -void -conferencelist_clean (calltab_t *); +void conferencelist_clean (calltab_t *); /** This function empty and free the history conference list */ -void -conferencelist_clean_history (void); +void conferencelist_clean_history (void); /** This function empty, free the conference list and allocate a new one. */ -void -conferencelist_reset (calltab_t *); +void conferencelist_reset (calltab_t *); /** This function append a conference to the list. * @param conf The conference you want to add * */ -void -conferencelist_add (calltab_t *, const conference_obj_t *); +void conferencelist_add (calltab_t *, const conference_obj_t *); /** This function remove a conference from list. * @param callID The callID of the conference you want to remove */ -void -conferencelist_remove (calltab_t *, const gchar *); +void conferencelist_remove (calltab_t *, const gchar * const conf_id); /** Return the number of calls in the list * @return The number of calls in the list */ -guint -conferencelist_get_size (calltab_t *); +guint conferencelist_get_size (calltab_t *); /** Return the call at the nth position in the list * @param n The position of the call you want * @return A call or NULL */ -conference_obj_t* -conferencelist_get_nth (calltab_t *, guint); +conference_obj_t* conferencelist_get_nth (calltab_t *, guint); /** Return the call corresponding to the callID * @param n The callID of the call want * @return A call or NULL */ -conference_obj_t* -conferencelist_get (calltab_t *, const gchar *); +conference_obj_t* conferencelist_get(calltab_t *, const gchar const *); -conference_obj_t* -conferencelist_pop_head(calltab_t *); +conference_obj_t* conferencelist_pop_head(calltab_t *); #endif diff --git a/gnome/src/contacts/searchbar.c b/gnome/src/contacts/searchbar.c index a86ea2e4b4c87acc185b4852d081a7ad4136aa0c..f7493e91930cdc0ef364084c60ee1650d07e2cd2 100644 --- a/gnome/src/contacts/searchbar.c +++ b/gnome/src/contacts/searchbar.c @@ -33,6 +33,7 @@ #include "searchbar.h" #include "calltree.h" +#include "calltab.h" #include "dbus.h" #include "logger.h" #include "config/addressbook-config.h" diff --git a/gnome/src/dbus/dbus.c b/gnome/src/dbus/dbus.c index 5fd2580a852f076754372bb6ca11e17f55830889..a76e641448fc9e480eb371974b63afe588214e9b 100644 --- a/gnome/src/dbus/dbus.c +++ b/gnome/src/dbus/dbus.c @@ -213,33 +213,31 @@ conference_changed_cb (DBusGProxy *proxy UNUSED, const gchar* confID, { DEBUG ("DBUS: Conference state changed: %s\n", state); - // sflphone_display_transfer_status("Transfer successfull"); conference_obj_t* changed_conf = conferencelist_get (current_calls, confID); - if(changed_conf == NULL) { - ERROR("DBUS: Conference is NULL in conference state changed"); - return; + if (changed_conf == NULL) { + ERROR("DBUS: Conference is NULL in conference state changed"); + return; } // remove old conference from calltree - calltree_remove_conference (current_calls, changed_conf, NULL); + calltree_remove_conference (current_calls, changed_conf); // update conference state - if (g_strcmp0 (state, "ACTIVE_ATTACHED") == 0) { + if (g_strcmp0 (state, "ACTIVE_ATTACHED") == 0) changed_conf->_state = CONFERENCE_STATE_ACTIVE_ATTACHED; - } else if (g_strcmp0 (state, "ACTIVE_DETACHED") == 0) { + else if (g_strcmp0 (state, "ACTIVE_DETACHED") == 0) changed_conf->_state = CONFERENCE_STATE_ACTIVE_DETACHED; - } else if (g_strcmp0 (state, "ACTIVE_ATTACHED_REC") == 0) { + else if (g_strcmp0 (state, "ACTIVE_ATTACHED_REC") == 0) changed_conf->_state = CONFERENCE_STATE_ACTIVE_ATTACHED_RECORD; - } else if (g_strcmp0(state, "ACTIVE_DETACHED_REC") == 0) { + else if (g_strcmp0(state, "ACTIVE_DETACHED_REC") == 0) changed_conf->_state = CONFERENCE_STATE_ACTIVE_DETACHED_RECORD; - } else if (g_strcmp0 (state, "HOLD") == 0) { + else if (g_strcmp0 (state, "HOLD") == 0) changed_conf->_state = CONFERENCE_STATE_HOLD; - } else if (g_strcmp0(state, "HOLD_REC") == 0) { + else if (g_strcmp0(state, "HOLD_REC") == 0) changed_conf->_state = CONFERENCE_STATE_HOLD_RECORD; - } else { + else DEBUG ("Error: conference state not recognized"); - } // reactivate instant messaging window for these calls toggle_im(changed_conf, TRUE); @@ -250,7 +248,6 @@ conference_changed_cb (DBusGProxy *proxy UNUSED, const gchar* confID, // deactivate instant messaging window for new participants toggle_im(changed_conf, FALSE); - calltree_add_conference (current_calls, changed_conf); } @@ -267,7 +264,7 @@ conference_created_cb (DBusGProxy *proxy UNUSED, const gchar* confID, void * foo conference_participant_list_update (participants, new_conf); // Add conference ID in in each calls - for (gchar **part = participants; *part; part++) { + for (gchar **part = participants; part && *part; ++part) { callable_obj_t *call = calllist_get_call (current_calls, *part); // set when this call have been added to the conference @@ -299,18 +296,16 @@ conference_removed_cb (DBusGProxy *proxy UNUSED, const gchar* confID, void * foo DEBUG ("DBUS: Conference removed %s", confID); conference_obj_t * c = conferencelist_get (current_calls, confID); - calltree_remove_conference (current_calls, c, NULL); + calltree_remove_conference (current_calls, c); im_widget_update_state (IM_WIDGET (c->_im_widget), FALSE); - // remove all participant for this conference - for (GSList *p = c->participant_list; p; p = conference_next_participant (p)) { - + // remove all participants for this conference + for (GSList *p = c->participant_list; p; p = conference_next_participant(p)) { callable_obj_t *call = calllist_get_call (current_calls, p->data); if (call) { g_free (call->_confID); call->_confID = NULL; - im_widget_update_state(IM_WIDGET (call->_im_widget), TRUE); } } @@ -1805,12 +1800,9 @@ dbus_set_addressbook_list (const gchar** list) GHashTable* dbus_get_hook_settings (void) { - GError *error = NULL; GHashTable *results = NULL; - //DEBUG ("Calling org_sflphone_SFLphone_ConfigurationManager_get_addressbook_settings"); - org_sflphone_SFLphone_ConfigurationManager_get_hook_settings ( configurationManagerProxy, &results, &error); @@ -1926,7 +1918,6 @@ dbus_get_conference_details (const gchar *confID) void dbus_set_accounts_order (const gchar* order) { - GError *error = NULL; org_sflphone_SFLphone_ConfigurationManager_set_accounts_order ( diff --git a/gnome/src/mainwindow.h b/gnome/src/mainwindow.h index 028c16305f0f45ec888bc872959e156dbb17311f..f5605bffa3a2f42af586d62f23196108deda5b76 100644 --- a/gnome/src/mainwindow.h +++ b/gnome/src/mainwindow.h @@ -31,9 +31,9 @@ #ifndef __MAINWINDOW_H__ #define __MAINWINDOW_H__ -#include <calllist.h> -#include <calltree.h> -#include <uimanager.h> +#include "calllist.h" +#include "calltree.h" +#include "uimanager.h" #define MAIN_WINDOW_WIDTH 280 #define MAIN_WINDOW_HEIGHT 320 diff --git a/gnome/src/shortcuts.c b/gnome/src/shortcuts.c index 3bc7e9c5b96acbebcc9bfddb2df54ab9fd73b54e..55d3aa7c7476d40ed8004624cf8fb3ae1642b2a2 100644 --- a/gnome/src/shortcuts.c +++ b/gnome/src/shortcuts.c @@ -42,6 +42,7 @@ #include "mainwindow.h" #include "logger.h" #include "callable_obj.h" +#include "contacts/calltab.h" #include "sflphone_const.h" #include "dbus.h" #include "actions.h" diff --git a/gnome/src/uimanager.c b/gnome/src/uimanager.c index 5d8cd2ef47097847b4951bf0a075af8de5ab81b4..3ca2c3d2b72a7f74406b2e228da85158a1dec94a 100644 --- a/gnome/src/uimanager.c +++ b/gnome/src/uimanager.c @@ -49,6 +49,7 @@ #include "statusicon.h" #include "contacts/addrbookfactory.h" +#include "contacts/calltab.h" #include "config/addressbook-config.h" #include "accountlist.h"