diff --git a/sflphone-client-gnome/src/actions.c b/sflphone-client-gnome/src/actions.c index 4bf9f69371d7c06e11bec8a39958febcf6c6a94b..46e8ce2f93da78bc7c2efee7b7ae596d4f7ce070 100644 --- a/sflphone-client-gnome/src/actions.c +++ b/sflphone-client-gnome/src/actions.c @@ -1140,7 +1140,7 @@ sflphone_add_participant (const gchar* callID, const gchar* confID) set_timestamp(&call->_time_added); - iter = calltree_get_gtkiter_from_id(history, confID); + iter = calltree_get_gtkiter_from_id(history, (gchar *)confID); calltree_add_call(history, call, &iter); @@ -1368,11 +1368,11 @@ void sflphone_fill_conference_list (void) void sflphone_fill_history (void) { - gchar **entries, *current_entry; + const gchar **entries; + gchar *current_entry; callable_obj_t *history_entry; callable_obj_t *call; QueueElement *element; - conference_obj_t *conference_entry; guint i = 0, n = 0; DEBUG ("======================================================= SFLphone: Loading history"); @@ -1380,10 +1380,8 @@ void sflphone_fill_history (void) entries = dbus_get_history (); while (*entries) { - const gchar *delim = "|"; - gchar **ptr; - current_entry = *entries; + current_entry = (gchar *)*entries; DEBUG("============================================ entry: %s", current_entry); @@ -1447,7 +1445,6 @@ void sflphone_save_history (void) gint size; gint i; QueueElement *current; - conference_obj_t *conf; GHashTable *result = NULL; gchar **ordered_result; gchar *key, *value; diff --git a/sflphone-client-gnome/src/callable_obj.c b/sflphone-client-gnome/src/callable_obj.c index 7994766e1f50fd10b5ced939b1e85321b0c577c5..267874fc0ab2cce59ea8359152d5194ca1e89b84 100644 --- a/sflphone-client-gnome/src/callable_obj.c +++ b/sflphone-client-gnome/src/callable_obj.c @@ -365,6 +365,7 @@ void create_history_entry_from_serialized_form (gchar *entry, callable_obj_t **c new_call->_confID = g_strdup(confID); new_call->_historyConfID = g_strdup(confID); new_call->_time_added = convert_gchar_to_timestamp(time_start); + new_call->_record_is_playing = FALSE; *call = new_call; } diff --git a/sflphone-client-gnome/src/conference_obj.c b/sflphone-client-gnome/src/conference_obj.c index 07ae344ef69debaf3ca77a2a60147945e141093a..107fb10b8ef771cd3728350462739cb36d20251f 100644 --- a/sflphone-client-gnome/src/conference_obj.c +++ b/sflphone-client-gnome/src/conference_obj.c @@ -76,6 +76,9 @@ void create_new_conference (conference_state_t state, const gchar* confID, confe new_conf->participant_list = NULL; new_conf->participant_number = NULL; + new_conf->_recordfile = NULL; + new_conf->_record_is_playing = FALSE; + set_conference_timestamp(&new_conf->_time_start); *conf = new_conf; @@ -128,6 +131,9 @@ void create_new_conference_from_details (const gchar *conf_id, GHashTable *detai new_conf->_state = CONFERENCE_STATE_HOLD_RECORD; } + new_conf->_recordfile = NULL; + new_conf->_record_is_playing = FALSE; + *conf = new_conf; } @@ -328,12 +334,7 @@ void create_conference_history_entry_from_serialized(gchar **ptr, conference_obj static void process_conference_participant_from_serialized(gchar *participant, conference_obj_t *conf) { gchar **ptr = NULL; - gchar **numberptr = NULL; gchar *delim = ";"; - gchar *delimnumber = ","; - gchar *numberaccount; - guint token = 0; - callable_obj_t *tmp_call = NULL; gint tok = 0; @@ -342,45 +343,6 @@ static void process_conference_participant_from_serialized(gchar *participant, c ptr = g_strsplit(participant, delim, 3); while(ptr != NULL && (tok < 2)) { gchar *call_id = NULL; -/* - gchar *phone_number = NULL; - gchar *account = NULL; - gchar *name = ""; - token = 0; - numberaccount = *ptr; - numberptr = g_strsplit(numberaccount, delimnumber, 2); -*/ -/* - while(numberptr != NULL && (token < 3)) { - switch(token) { - case 0: - phone_number = *numberptr; - break; - case 1: - call_id = *ptr; - break; - case 2: - account = *numberptr; - // remove the ";" character at the end of the account string - if(g_str_has_suffix(account, ";")) { - int len = strlen(account); - gchar *tmpchar = g_strdup(account); - g_strlcpy(account, tmpchar, len); - } - break; - default: - break; - } - token++; - numberptr++; - } -*/ - - // we should create call here and add it to the conference to be inserted in history - // create_new_call(HISTORY_ENTRY, CALL_STATE_DIALING, call_id, account, name, phone_number, &tmp_call); - // calllist_add_history_call(tmp_call); - // calllist_add_call(history, tmp_call); - // calllist_add_call(current_calls, tmp_call); conference_add_participant(call_id, conf); diff --git a/sflphone-client-gnome/src/contacts/conferencelist.c b/sflphone-client-gnome/src/contacts/conferencelist.c index ede9fd52882f12b2b0e88e4431ae3432f9e4d5a7..c7bf7a90e486302d73c83ae874f75eb029eb49be 100644 --- a/sflphone-client-gnome/src/contacts/conferencelist.c +++ b/sflphone-client-gnome/src/contacts/conferencelist.c @@ -83,7 +83,6 @@ conferencelist_clean_history(void) { conference_obj_t *conf; guint size = conferencelist_get_size(history); - guint i; DEBUG("ConferenceList: clean history"); @@ -189,7 +188,7 @@ conference_obj_t* conferencelist_get (calltab_t *tab, const gchar* conf_id) conference_obj_t* conferencelist_get_nth (calltab_t *tab, guint n) { - GList* c; + conference_obj_t *c; if(tab == NULL) { ERROR("ConferenceList: Error: Calltab is NULL"); @@ -203,7 +202,7 @@ conference_obj_t* conferencelist_get_nth (calltab_t *tab, guint n) return NULL; } - return (conference_obj_t*) c; + return c; } conference_obj_t *conferencelist_pop_head(calltab_t *tab) diff --git a/sflphone-client-gnome/src/dbus/callmanager-introspec.xml b/sflphone-client-gnome/src/dbus/callmanager-introspec.xml index cde5e2d644021210317a30bdb86f0a46a046a7a9..5c6591855eca01beeabf2f71dbc62aef93ef759c 100644 --- a/sflphone-client-gnome/src/dbus/callmanager-introspec.xml +++ b/sflphone-client-gnome/src/dbus/callmanager-introspec.xml @@ -349,9 +349,9 @@ <arg type="s" name="filepath"/> </signal> - <signal name="recordPlaybackResult" tp:name-for-bindings="recordPlaybackResult"> + <signal name="recordPlaybackStoped" tp:name-for-bindings="recordPlaybackStoped"> <tp:docstring/> - <arg type="b" name="callID" /> + <arg type="s" name="filepath" /> </signal> diff --git a/sflphone-client-gnome/src/dbus/dbus.c b/sflphone-client-gnome/src/dbus/dbus.c index 18dcbc463affd8133c3c775537b50b3925f6d086..d2b718590f54562f5e7d86baec778bab0ed2ee8e 100644 --- a/sflphone-client-gnome/src/dbus/dbus.c +++ b/sflphone-client-gnome/src/dbus/dbus.c @@ -95,7 +95,7 @@ static void record_playback_filepath_cb (DBusGProxy *, const gchar *, const gchar *); static void -record_playback_result_cb (DBusGProxy *, const gchar *, const gboolean); +record_playback_stoped_cb (DBusGProxy *, const gchar *); static void accounts_changed_cb (DBusGProxy *, void *); @@ -518,35 +518,50 @@ record_playback_filepath_cb (DBusGProxy *proxy UNUSED, const gchar *id, const gc if(conf->_recordfile == NULL) conf->_recordfile = g_strdup(filepath); } - } static void -record_playback_result_cb (DBusGProxy *proxy UNUSED, const gchar *id, const gboolean result) +record_playback_stoped_cb (DBusGProxy *proxy UNUSED, const gchar *filepath) { + QueueElement *element; callable_obj_t *call = NULL; conference_obj_t *conf = NULL; + gint calllist_size, conflist_size; + gchar *recfile; + gint i; - DEBUG("DBUS: Result for %s: %s", id, result ? "ok" : "bad"); + DEBUG("DBUS: Playback stoped for %s", filepath); - call = calllist_get_call(history, id); - conf = conferencelist_get(history, id); + calllist_size = calllist_get_size(history); + conflist_size = conferencelist_get_size(history); - if(call && conf) { - ERROR("DBUS: Two object for this ID"); - return; + for(i = 0; i < calllist_size; i++) { + recfile = NULL; + element = calllist_get_nth(history, i); + if(element == NULL) { + ERROR("DBUS: ERROR: Could not find %dth call", i); + break; + } + + if(element->type == HIST_CALL) { + call = element->elem.call; + recfile = call->_recordfile; + if(recfile && (g_strcmp0(recfile, filepath) == 0)) { + call->_record_is_playing = FALSE; + } + } } - if(!call && !conf) { - ERROR("DBUS: Could not get object"); - return; - } + for(i = 0; i < conflist_size; i++) { + conf = conferencelist_get(history, i); + if(conf == NULL) { + ERROR("DBUS: ERROR: Could not find %dth conf", i); + break; + } - if(call) { - call->_record_is_playing = result; - } - else if(conf) { - conf->_record_is_playing = result; + recfile = conf->_recordfile; + if(recfile && (g_strcmp0(recfile, filepath) == 0)) + conf->_record_is_playing = FALSE; } update_actions(); @@ -815,10 +830,9 @@ dbus_connect (GError **error) G_TYPE_STRING, G_TYPE_INVALID); dbus_g_proxy_connect_signal (callManagerProxy, "recordPlaybackFilepath", G_CALLBACK (record_playback_filepath_cb), NULL, NULL); - dbus_g_proxy_add_signal (callManagerProxy, "recordPlaybackResult", G_TYPE_BOOLEAN, - G_TYPE_STRING, G_TYPE_INVALID); - dbus_g_proxy_add_signal(callManagerProxy, "recordPlaybackResult", - G_CALLBACK (record_playback_result_cb), NULL, NULL); + dbus_g_proxy_add_signal (callManagerProxy, "recordPlaybackStoped", G_TYPE_STRING, G_TYPE_INVALID); + dbus_g_proxy_connect_signal(callManagerProxy, "recordPlaybackStoped", + G_CALLBACK (record_playback_stoped_cb), NULL, NULL); /* Security related callbacks */ diff --git a/sflphone-common/src/audio/sound/audiofile.cpp b/sflphone-common/src/audio/sound/audiofile.cpp index b847d6bd2226033f5aeecce25f31cc7534ff7b33..83b3a0bc7f02cb666fa67e97c243331695d98415 100644 --- a/sflphone-common/src/audio/sound/audiofile.cpp +++ b/sflphone-common/src/audio/sound/audiofile.cpp @@ -1,5 +1,7 @@ /* - * Copyright (C) 2004, 2005, 2006, 2009, 2008, 2009, 2010, 2011 Savoir-Faire Linux Inc. + + if(_dbus) + _dbus * Copyright (C) 2004, 2005, 2006, 2009, 2008, 2009, 2010, 2011 Savoir-Faire Linux Inc. * Author: Yan Morin <yan.morin@savoirfairelinux.com> * * Inspired by tonegenerator of @@ -44,7 +46,7 @@ #include "manager.h" -RawFile::RawFile() : filename(), audioCodec (NULL) +RawFile::RawFile() : audioCodec (NULL) { AudioFile::_start = false; } @@ -63,20 +65,20 @@ void RawFile::loadFile (const std::string& name, sfl::AudioCodec* codec, unsigne // if the filename was already load, with the same samplerate // we do nothing - if ((filename == name) && (_sampleRate == (int)sampleRate)) { + if ((filepath == name) && (_sampleRate == (int)sampleRate)) { return; } - filename = name; + filepath = name; // no filename to load - if (filename.empty()) { + if (filepath.empty()) { throw AudioFileException("Unable to open audio file: filename is empty"); } std::fstream file; - file.open (filename.c_str(), std::fstream::in); + file.open (filepath.c_str(), std::fstream::in); if (!file.is_open()) { throw AudioFileException("Unable to open audio file"); } @@ -236,9 +238,11 @@ bool WaveFile::isFileOpened() void WaveFile::openExistingWaveFile (const std::string& fileName, int audioSamplingRate) throw(AudioFileException) { - int maxIteration = 0; + int maxIteration = 0; _debug ("WaveFile: Opening %s", fileName.c_str()); + filepath = fileName; + fileStream.open (fileName.c_str(), std::ios::in | std::ios::binary); char riff[4] = {}; @@ -437,12 +441,12 @@ void WaveFile::openExistingWaveFile (const std::string& fileName, int audioSampl } -void WaveFile::loadFile (const std::string& filename, sfl::AudioCodec * /*codec*/, unsigned int sampleRate) throw(AudioFileException) +void WaveFile::loadFile (const std::string& name, sfl::AudioCodec * /*codec*/, unsigned int sampleRate) throw(AudioFileException) { - _debug("WaveFile: Load new file %s", filename.c_str()); + _debug("WaveFile: Load new file %s", name.c_str()); try { - openFile (filename, sampleRate); + openFile (name, sampleRate); } catch(AudioFileException &e) { throw; diff --git a/sflphone-common/src/audio/sound/audiofile.h b/sflphone-common/src/audio/sound/audiofile.h index 975bfe136fbf9f5c10c815a52a0b77f415e36ec1..f6d09adf3c6646def7081f4f580018537d7bf9dd 100644 --- a/sflphone-common/src/audio/sound/audiofile.h +++ b/sflphone-common/src/audio/sound/audiofile.h @@ -76,7 +76,11 @@ public: * @param sampleRate The sample rate to read it * @return bool True on success */ - virtual void loadFile (const std::string& filename, sfl::AudioCodec *codec , unsigned int sampleRate) throw(AudioFileException) = 0; + virtual void loadFile (const std::string &, sfl::AudioCodec *, unsigned int) throw(AudioFileException) = 0; + + std::string getFilePath(void) { + return filepath; + } /** * Start the sound file @@ -105,6 +109,10 @@ protected: /** start or not */ bool _start; + + /** The absolute path to the sound file */ + std::string filepath; + }; @@ -144,9 +152,6 @@ class RawFile : public AudioFile // Assignment Operator RawFile& operator= (const RawFile& rh); - /** The absolute path to the sound file */ - std::string filename; - /** Your preferred codec */ sfl::AudioCodec* audioCodec; }; @@ -177,7 +182,7 @@ class WaveFile : public AudioFile /** * Test if the specified file already exist */ - bool isFileExist (const std::string& fileName); + bool isFileExist (const std::string&); /** * Test if file opend @@ -191,7 +196,7 @@ class WaveFile : public AudioFile * @param sampleRate The sample rate to read it * @return bool True on success */ - virtual void loadFile (const std::string& filename, sfl::AudioCodec *codec , unsigned int sampleRate) throw(AudioFileException); + virtual void loadFile (const std::string&, sfl::AudioCodec *, unsigned int) throw(AudioFileException); private: @@ -247,11 +252,6 @@ class WaveFile : public AudioFile */ std::fstream fileStream; - /** - * File name - */ - std::string fileName; - }; #endif diff --git a/sflphone-common/src/dbus/callmanager-introspec.xml b/sflphone-common/src/dbus/callmanager-introspec.xml index cde5e2d644021210317a30bdb86f0a46a046a7a9..5c6591855eca01beeabf2f71dbc62aef93ef759c 100644 --- a/sflphone-common/src/dbus/callmanager-introspec.xml +++ b/sflphone-common/src/dbus/callmanager-introspec.xml @@ -349,9 +349,9 @@ <arg type="s" name="filepath"/> </signal> - <signal name="recordPlaybackResult" tp:name-for-bindings="recordPlaybackResult"> + <signal name="recordPlaybackStoped" tp:name-for-bindings="recordPlaybackStoped"> <tp:docstring/> - <arg type="b" name="callID" /> + <arg type="s" name="filepath" /> </signal> diff --git a/sflphone-common/src/managerimpl.cpp b/sflphone-common/src/managerimpl.cpp index fbee96b417a763acfa1001aacee4b082305cea19..5da250f19685d42d7747448e69f4112e330d35bd 100644 --- a/sflphone-common/src/managerimpl.cpp +++ b/sflphone-common/src/managerimpl.cpp @@ -2404,6 +2404,10 @@ void ManagerImpl::ringtone (const AccountID& accountID) _toneMutex.enterMutex(); if (_audiofile) { + if(_dbus) { + std::string filepath = _audiofile->getFilePath(); + _dbus->getCallManager()->recordPlaybackStoped(filepath); + } delete _audiofile; _audiofile = NULL; } @@ -3031,7 +3035,11 @@ bool ManagerImpl::startRecordedFilePlayback(const std::string& filepath) _toneMutex.enterMutex(); if(_audiofile) { - delete _audiofile; + if(_dbus) { + std::string file = _audiofile->getFilePath(); + _dbus->getCallManager()->recordPlaybackStoped(file); + } + delete _audiofile; _audiofile = NULL; } @@ -3229,25 +3237,21 @@ void ManagerImpl::setEchoCancelState(std::string state) int ManagerImpl::getEchoCancelTailLength(void) { - _debug("-------------------------------------- getEchoTailLength %d", audioPreference.getEchoCancelTailLength()); return audioPreference.getEchoCancelTailLength(); } void ManagerImpl::setEchoCancelTailLength(int length) { - _debug("------------------------------------- setEchoTailLength %d", length); audioPreference.setEchoCancelTailLength(length); } int ManagerImpl::getEchoCancelDelay(void) { - _debug("------------------------------------- getEchoCancelDelay %d", audioPreference.getEchoCancelDelay()); return audioPreference.getEchoCancelDelay(); } void ManagerImpl::setEchoCancelDelay(int delay) { - _debug("------------------------------------- setEchoCancelDelay %d", delay); audioPreference.setEchoCancelDelay(delay); }