diff --git a/daemon/src/audio/audiorecord.cpp b/daemon/src/audio/audiorecord.cpp index f87d034ee4ee653e4b862acfc8a0a970e2b56549..14b30ddf1afe857b72eb48b66e5da23d448781d9 100644 --- a/daemon/src/audio/audiorecord.cpp +++ b/daemon/src/audio/audiorecord.cpp @@ -234,14 +234,15 @@ bool AudioRecord::isRecording() const return recordingEnabled_; } -void AudioRecord::setRecording() +bool AudioRecord::toggleRecording() { if (isOpenFile()) { recordingEnabled_ = !recordingEnabled_; } else { openFile(); - recordingEnabled_ = true; // once opend file, start recording + recordingEnabled_ = true; } + return recordingEnabled_; } void AudioRecord::stopRecording() diff --git a/daemon/src/audio/audiorecord.h b/daemon/src/audio/audiorecord.h index 59b826244b9fa00a4fc8000b1cf8553423ea3bab..3fb91948e8c98edb1c13ac6b817b6203448f3481 100644 --- a/daemon/src/audio/audiorecord.h +++ b/daemon/src/audio/audiorecord.h @@ -88,9 +88,9 @@ class AudioRecord { bool isRecording() const; /** - * Set recording flag + * Toggle recording state */ - void setRecording(); + bool toggleRecording(); /** * Stop recording flag diff --git a/daemon/src/audio/recordable.h b/daemon/src/audio/recordable.h index 4df70b8083635746f5529bb3ac284e5e5db1553e..bdc7c2b1af33cb29aedb878fbad44d73983d5340 100644 --- a/daemon/src/audio/recordable.h +++ b/daemon/src/audio/recordable.h @@ -51,7 +51,7 @@ class Recordable { * This method must be implemented for this interface as calls and conferences * have different behavior. */ - virtual bool setRecording() = 0; + virtual bool toggleRecording() = 0; /** * Stop recording diff --git a/daemon/src/call.cpp b/daemon/src/call.cpp index deb9ca0d6d75f312d45d017af3cd5f4ed4d0638a..8c83021d1bc002d344b893d1bed75f64de3729f0 100644 --- a/daemon/src/call.cpp +++ b/daemon/src/call.cpp @@ -148,15 +148,13 @@ Call::getLocalVideoPort() } bool -Call::setRecording() +Call::toggleRecording() { - bool recordStatus = Recordable::recAudio_.isRecording(); - - Recordable::recAudio_.setRecording(); + const bool startRecording = Recordable::recAudio_.toggleRecording(); MainBuffer &mbuffer = Manager::instance().getMainBuffer(); std::string process_id = Recordable::recorder_.getRecorderID(); - if (!recordStatus) { + if (startRecording) { mbuffer.bindHalfDuplexOut(process_id, id_); mbuffer.bindHalfDuplexOut(process_id, MainBuffer::DEFAULT_ID); @@ -168,7 +166,7 @@ Call::setRecording() Manager::instance().getMainBuffer().dumpInfo(); - return recordStatus; + return startRecording; } void Call::time_stop() diff --git a/daemon/src/call.h b/daemon/src/call.h index eee2e15db73392976e7f3cfb169cedda50660ea8..0ba72776b5f61fe3fe06fced733e897668f7ec2d 100644 --- a/daemon/src/call.h +++ b/daemon/src/call.h @@ -228,7 +228,7 @@ class Call : public Recordable { virtual std::map<std::string, std::string> createHistoryEntry() const; - virtual bool setRecording(); + virtual bool toggleRecording(); private: std::string getTypeStr() const; diff --git a/daemon/src/conference.cpp b/daemon/src/conference.cpp index 7203b5706f352ebf77c4b2fd0a620b9c79aafabc..1197d86af49f8d9f0ea487e1ce30ac2a9e2ffd21 100644 --- a/daemon/src/conference.cpp +++ b/daemon/src/conference.cpp @@ -99,17 +99,15 @@ ParticipantSet Conference::getParticipantList() const return participants_; } -bool Conference::setRecording() +bool Conference::toggleRecording() { - bool recordStatus = Recordable::recAudio_.isRecording(); - - Recordable::recAudio_.setRecording(); + const bool startRecording = Recordable::recAudio_.toggleRecording(); MainBuffer &mbuffer = Manager::instance().getMainBuffer(); std::string process_id(Recordable::recorder_.getRecorderID()); // start recording - if (!recordStatus) { + if (startRecording) { for (ParticipantSet::const_iterator iter = participants_.begin(); iter != participants_.end(); ++iter) mbuffer.bindHalfDuplexOut(process_id, *iter); @@ -123,7 +121,7 @@ bool Conference::setRecording() mbuffer.unBindHalfDuplexOut(process_id, MainBuffer::DEFAULT_ID); } - return recordStatus; + return startRecording; } std::string Conference::getConfID() const { diff --git a/daemon/src/conference.h b/daemon/src/conference.h index 39509e28cf49615f55deb7cd53d96de16ba61acc..1adc7aad763292f7013a2999ce972fe4345f7bdb 100644 --- a/daemon/src/conference.h +++ b/daemon/src/conference.h @@ -89,7 +89,7 @@ class Conference : public Recordable { /** * Start/stop recording toggle */ - virtual bool setRecording(); + virtual bool toggleRecording(); private: std::string id_; ConferenceState confState_; diff --git a/daemon/src/dbus/callmanager-introspec.xml b/daemon/src/dbus/callmanager-introspec.xml index 38234929142acb6fe3e3ecf44df70f4888ee484f..6551f361894942a5aa1d0f010475f6e905fcd253 100644 --- a/daemon/src/dbus/callmanager-introspec.xml +++ b/daemon/src/dbus/callmanager-introspec.xml @@ -325,7 +325,24 @@ </arg> </method> + <method name="toggleRecording" tp:name-for-bindings="toggleRecording"> + <tp:docstring> + Toggle recording for a call. + </tp:docstring> + <arg type="s" name="callID" direction="in"> + <tp:docstring> + The ID of the call to start/stop recording. + </tp:docstring> + </arg> + <arg type="b" name="isRecording" direction="out"> + <tp:docstring> + Returns true is the call is being recorded. False otherwise. + </tp:docstring> + </arg> + </method> + <method name="setRecording" tp:name-for-bindings="setRecording"> + <annotation name="org.freedesktop.DBus.Deprecated" value="true"/> <tp:docstring> Start recording a call. </tp:docstring> diff --git a/daemon/src/dbus/callmanager.cpp b/daemon/src/dbus/callmanager.cpp index 50b6d18788c73aea47c186c7cb0a4b199990bf8a..8afb4c2ae47dcdd54c3bf6830fd97e222d71c928 100644 --- a/daemon/src/dbus/callmanager.cpp +++ b/daemon/src/dbus/callmanager.cpp @@ -232,10 +232,16 @@ CallManager::stopRecordedFilePlayback(const std::string& filepath) Manager::instance().stopRecordedFilePlayback(filepath); } +bool +CallManager::toggleRecording(const std::string& callID) +{ + return Manager::instance().toggleRecordingCall(callID); +} + void CallManager::setRecording(const std::string& callID) { - Manager::instance().setRecordingCall(callID); + toggleRecording(callID); } void diff --git a/daemon/src/dbus/callmanager.h b/daemon/src/dbus/callmanager.h index a3e50c6326ae71a30de55ca1839ae201d2b8cec1..e99a72b6b0faa45d2ad97122b443c372ef454311 100644 --- a/daemon/src/dbus/callmanager.h +++ b/daemon/src/dbus/callmanager.h @@ -107,7 +107,10 @@ class CallManager /* General audio methods */ void setVolume(const std::string& device, const double& value); double getVolume(const std::string& device); + bool toggleRecording(const std::string& callID); + /* DEPRECATED */ void setRecording(const std::string& callID); + void recordPlaybackSeek(const double& value); bool getIsRecording(const std::string& callID); std::string getCurrentAudioCodecName(const std::string& callID); diff --git a/daemon/src/managerimpl.cpp b/daemon/src/managerimpl.cpp index 232775291b0abe0203787e93d0fea7f2723aa08c..96e211df482a7a52449ff9654a51dbcf442cee44 100644 --- a/daemon/src/managerimpl.cpp +++ b/daemon/src/managerimpl.cpp @@ -388,7 +388,7 @@ bool ManagerImpl::answerCall(const std::string& call_id) // Start recording if set in preference if (audioPreference.getIsAlwaysRecording()) - setRecordingCall(call_id); + toggleRecordingCall(call_id); // update call state on client side dbus_.getCallManager()->callStateChanged(call_id, "CURRENT"); @@ -1630,7 +1630,7 @@ void ManagerImpl::peerAnsweredCall(const std::string& id) } if (audioPreference.getIsAlwaysRecording()) - setRecordingCall(id); + toggleRecordingCall(id); dbus_.getCallManager()->callStateChanged(id, "CURRENT"); } @@ -2064,16 +2064,16 @@ void ManagerImpl::setIsAlwaysRecording(bool isAlwaysRec) return audioPreference.setIsAlwaysRecording(isAlwaysRec); } -void ManagerImpl::setRecordingCall(const std::string& id) +bool ManagerImpl::toggleRecordingCall(const std::string& id) { Recordable* rec = NULL; ConferenceMap::const_iterator it(conferenceMap_.find(id)); if (it == conferenceMap_.end()) { - DEBUG("Set recording for call %s", id.c_str()); + DEBUG("toggle recording for call %s", id.c_str()); rec = getCallFromCallID(id); } else { - DEBUG("Set recording for conference %s", id.c_str()); + DEBUG("toggle recording for conference %s", id.c_str()); Conference *conf = it->second; if (conf) { @@ -2087,11 +2087,12 @@ void ManagerImpl::setRecordingCall(const std::string& id) if (rec == NULL) { ERROR("Could not find recordable instance %s", id.c_str()); - return; + return false; } - rec->setRecording(); + const bool result = rec->toggleRecording(); dbus_.getCallManager()->recordPlaybackFilepath(id, rec->getFilename()); + return result; } bool ManagerImpl::isRecording(const std::string& id) diff --git a/daemon/src/managerimpl.h b/daemon/src/managerimpl.h index 1a36397fddbb6382fb3c527592d751789371cd5b..dfd910c4ffebaf8d30199ec38a5b4c991c19d4ac 100644 --- a/daemon/src/managerimpl.h +++ b/daemon/src/managerimpl.h @@ -606,8 +606,9 @@ class ManagerImpl { * Set recording on / off * Start recording * @param id The call identifier + * Returns true if the call was set to record */ - void setRecordingCall(const std::string& id); + bool toggleRecordingCall(const std::string& id); /** * Return true if the call is currently recorded diff --git a/gnome/src/actions.c b/gnome/src/actions.c index dd7ce452cd5c55c010c437b058a20c17c725d0b8..35cd55a39c4f3fa2c262bd8917296a485226f880 100644 --- a/gnome/src/actions.c +++ b/gnome/src/actions.c @@ -812,19 +812,19 @@ sflphone_add_main_participant(const conference_obj_t * c) dbus_add_main_participant(c->_confID); } -void + +gboolean sflphone_rec_call(SFLPhoneClient *client) { + gboolean result = FALSE; callable_obj_t * selectedCall = calltab_get_selected_call(current_calls_tab); conference_obj_t * selectedConf = calltab_get_selected_conf(current_calls_tab); if (selectedCall) { - g_debug("Set record for selected call"); - dbus_set_record(selectedCall->_callID); + result = dbus_toggle_recording(selectedCall->_callID); calltree_update_call(current_calls_tab, selectedCall, client, TRUE); } else if (selectedConf) { - g_debug("Set record for selected conf"); - dbus_set_record(selectedConf->_confID); + result = dbus_toggle_recording(selectedConf->_confID); switch (selectedConf->_state) { case CONFERENCE_STATE_ACTIVE_ATTACHED: @@ -851,6 +851,7 @@ sflphone_rec_call(SFLPhoneClient *client) } else { update_actions(client); } + return result; } void diff --git a/gnome/src/actions.h b/gnome/src/actions.h index 5e0b50d70738732fb2d71442794ce09d4d3b287f..7d0388d869da52454ad3a8ebc5a6cc5072c23817 100644 --- a/gnome/src/actions.h +++ b/gnome/src/actions.h @@ -187,7 +187,7 @@ void sflphone_fill_codec_list_per_account(account_t *); void sflphone_add_participant(); -void sflphone_rec_call(SFLPhoneClient *client); +gboolean sflphone_rec_call(SFLPhoneClient *client); void sflphone_mute_call(void); diff --git a/gnome/src/dbus/callmanager-introspec.xml b/gnome/src/dbus/callmanager-introspec.xml index 38234929142acb6fe3e3ecf44df70f4888ee484f..6551f361894942a5aa1d0f010475f6e905fcd253 100644 --- a/gnome/src/dbus/callmanager-introspec.xml +++ b/gnome/src/dbus/callmanager-introspec.xml @@ -325,7 +325,24 @@ </arg> </method> + <method name="toggleRecording" tp:name-for-bindings="toggleRecording"> + <tp:docstring> + Toggle recording for a call. + </tp:docstring> + <arg type="s" name="callID" direction="in"> + <tp:docstring> + The ID of the call to start/stop recording. + </tp:docstring> + </arg> + <arg type="b" name="isRecording" direction="out"> + <tp:docstring> + Returns true is the call is being recorded. False otherwise. + </tp:docstring> + </arg> + </method> + <method name="setRecording" tp:name-for-bindings="setRecording"> + <annotation name="org.freedesktop.DBus.Deprecated" value="true"/> <tp:docstring> Start recording a call. </tp:docstring> diff --git a/gnome/src/dbus/dbus.c b/gnome/src/dbus/dbus.c index 87fc6f477543916c533fd66e1cb00749d1972a21..d7a792798cc823d72477453a5e02aeb663e7c9ac 100644 --- a/gnome/src/dbus/dbus.c +++ b/gnome/src/dbus/dbus.c @@ -1533,12 +1533,14 @@ dbus_join_conference(const gchar *sel_confID, const gchar *drag_confID) check_error(error); } -void -dbus_set_record(const gchar *id) +gboolean +dbus_toggle_recording(const gchar *id) { GError *error = NULL; - org_sflphone_SFLphone_CallManager_set_recording(call_proxy, id, &error); + gboolean isRecording; + org_sflphone_SFLphone_CallManager_toggle_recording(call_proxy, id, &isRecording, &error); check_error(error); + return isRecording; } gboolean diff --git a/gnome/src/dbus/dbus.h b/gnome/src/dbus/dbus.h index f0c74f5efb66a649dc5e6ca83b84d523bcc85a47..b7263d08702f2975250e4172a20df6c60f6aa58d 100644 --- a/gnome/src/dbus/dbus.h +++ b/gnome/src/dbus/dbus.h @@ -439,7 +439,7 @@ gchar *dbus_get_conference_id(const gchar *callID); /** * Toggle recording for this instance, may be call or conference */ -void dbus_set_record(const gchar *id); +gboolean dbus_toggle_recording(const gchar *id); /** * Set the path where the recorded audio files will be stored diff --git a/gnome/src/uimanager.c b/gnome/src/uimanager.c index f51f540e74aed63238cc76aa6e23e3f0770cdb1e..a7e8a5c7259651ca97f39173531236b38587c0cf 100644 --- a/gnome/src/uimanager.c +++ b/gnome/src/uimanager.c @@ -748,7 +748,10 @@ static void call_record(G_GNUC_UNUSED GtkAction *action, SFLPhoneClient *client) { g_debug("Record button pressed"); - sflphone_rec_call(client); + /* Ensure that button is set to correct state, but suppress signal */ + g_signal_handler_block(recordWidget_, recordButtonConnId_); + gtk_toggle_tool_button_set_active(GTK_TOGGLE_TOOL_BUTTON(recordWidget_), sflphone_rec_call(client)); + g_signal_handler_unblock(recordWidget_, recordButtonConnId_); } static void