diff --git a/sflphone-gtk/src/callmanager-glue.h b/sflphone-gtk/src/callmanager-glue.h index 1921fbb0e0b630413699dc5b7c71d2e308b4ba5c..7cdb50cdd3e62505b81d8371707ed9a6fae9243a 100644 --- a/sflphone-gtk/src/callmanager-glue.h +++ b/sflphone-gtk/src/callmanager-glue.h @@ -458,6 +458,44 @@ static inline #endif gboolean +org_sflphone_SFLphone_CallManager_get_is_recording (DBusGProxy *proxy, const char * IN_callID, gboolean* OUT_isRecording, GError **error) + +{ + return dbus_g_proxy_call (proxy, "getIsRecording", error, G_TYPE_STRING, IN_callID, G_TYPE_INVALID, G_TYPE_BOOLEAN, OUT_isRecording, G_TYPE_INVALID); +} + +typedef void (*org_sflphone_SFLphone_CallManager_get_is_recording_reply) (DBusGProxy *proxy, gboolean OUT_isRecording, GError *error, gpointer userdata); + +static void +org_sflphone_SFLphone_CallManager_get_is_recording_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data) +{ + DBusGAsyncData *data = (DBusGAsyncData*) user_data; + GError *error = NULL; + gboolean OUT_isRecording; + dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_BOOLEAN, &OUT_isRecording, G_TYPE_INVALID); + (*(org_sflphone_SFLphone_CallManager_get_is_recording_reply)data->cb) (proxy, OUT_isRecording, error, data->userdata); + return; +} + +static +#ifdef G_HAVE_INLINE +inline +#endif +DBusGProxyCall* +org_sflphone_SFLphone_CallManager_get_is_recording_async (DBusGProxy *proxy, const char * IN_callID, org_sflphone_SFLphone_CallManager_get_is_recording_reply callback, gpointer userdata) + +{ + DBusGAsyncData *stuff; + stuff = g_new (DBusGAsyncData, 1); + stuff->cb = G_CALLBACK (callback); + stuff->userdata = userdata; + return dbus_g_proxy_begin_call (proxy, "getIsRecording", org_sflphone_SFLphone_CallManager_get_is_recording_async_callback, stuff, g_free, G_TYPE_STRING, IN_callID, G_TYPE_INVALID); +} +static +#ifdef G_HAVE_INLINE +inline +#endif +gboolean org_sflphone_SFLphone_CallManager_get_call_details (DBusGProxy *proxy, const char * IN_callID, GHashTable** OUT_infos, GError **error) { diff --git a/sflphone-gtk/src/dbus.c b/sflphone-gtk/src/dbus.c index 45b9285619c32f0b4bdbe6632c08509d5d5dac0c..ab494b5ff716bb329e221cda5cab3215ae8fdb08 100644 --- a/sflphone-gtk/src/dbus.c +++ b/sflphone-gtk/src/dbus.c @@ -1123,6 +1123,23 @@ dbus_set_record(const call_t * c) } } +gboolean +dbus_get_is_recording(const call_t * c) +{ + g_print("calling dbus_get_is_recording on CallManager\n"); + GError* error = NULL; + gboolean* isRecording = NULL; + org_sflphone_SFLphone_CallManager_get_is_recording ( + callManagerProxy, + c->callID, + isRecording, + &error); + if(error) + { + g_error_free(error); + } +} + void dbus_set_record_path(const gchar* path) { diff --git a/src/dbus/callmanager-glue.h b/src/dbus/callmanager-glue.h index 71dd6b5170eca847ee33cbc5d457c7593c2c9f44..1ed93d42f6ec15cfd89bb5db7daf76b22d7ab8eb 100644 --- a/src/dbus/callmanager-glue.h +++ b/src/dbus/callmanager-glue.h @@ -32,6 +32,7 @@ public: register_method(CallManager_adaptor, setVolume, _setVolume_stub); register_method(CallManager_adaptor, getVolume, _getVolume_stub); register_method(CallManager_adaptor, setRecording, _setRecording_stub); + register_method(CallManager_adaptor, getIsRecording, _getIsRecording_stub); register_method(CallManager_adaptor, getCallDetails, _getCallDetails_stub); register_method(CallManager_adaptor, getCurrentCallID, _getCurrentCallID_stub); register_method(CallManager_adaptor, getCurrentCodecName, _getCurrentCodecName_stub); @@ -105,6 +106,12 @@ public: { "callID", "s", true }, { 0, 0, 0 } }; + static ::DBus::IntrospectedArgument getIsRecording_args[] = + { + { "callID", "s", true }, + { "isRecording", "b", false }, + { 0, 0, 0 } + }; static ::DBus::IntrospectedArgument getCallDetails_args[] = { { "callID", "s", true }, @@ -178,6 +185,7 @@ public: { "setVolume", setVolume_args }, { "getVolume", getVolume_args }, { "setRecording", setRecording_args }, + { "getIsRecording", getIsRecording_args }, { "getCallDetails", getCallDetails_args }, { "getCurrentCallID", getCurrentCallID_args }, { "getCurrentCodecName", getCurrentCodecName_args }, @@ -231,6 +239,7 @@ public: virtual void setVolume(const std::string& device, const double& value) = 0; virtual double getVolume(const std::string& device) = 0; virtual void setRecording(const std::string& callID) = 0; + virtual bool getIsRecording(const std::string& callID) = 0; virtual std::map< std::string, std::string > getCallDetails(const std::string& callID) = 0; virtual std::string getCurrentCallID() = 0; virtual std::string getCurrentCodecName(const std::string& callID) = 0; @@ -415,6 +424,17 @@ private: ::DBus::ReturnMessage reply(call); return reply; } + ::DBus::Message _getIsRecording_stub(const ::DBus::CallMessage &call) + { + ::DBus::MessageIter ri = call.reader(); + + std::string argin1; ri >> argin1; + bool argout1 = getIsRecording(argin1); + ::DBus::ReturnMessage reply(call); + ::DBus::MessageIter wi = reply.writer(); + wi << argout1; + return reply; + } ::DBus::Message _getCallDetails_stub(const ::DBus::CallMessage &call) { ::DBus::MessageIter ri = call.reader(); diff --git a/src/dbus/callmanager-introspec.xml b/src/dbus/callmanager-introspec.xml index 9c503cac8dcd7c6a84d784b82d6854c2fcad029b..0558a20e8896c7703f6cb716fbeabe3224f82948 100644 --- a/src/dbus/callmanager-introspec.xml +++ b/src/dbus/callmanager-introspec.xml @@ -55,6 +55,11 @@ <method name="setRecording"> <arg type="s" name="callID" direction="in"/> </method> + + <method name="getIsRecording"> + <arg type="s" name="callID" direction="in"/> + <arg type="b" name="isRecording" direction="out"/> + </method> <method name="getCallDetails"> <arg type="s" name="callID" direction="in"/> diff --git a/src/dbus/callmanager.cpp b/src/dbus/callmanager.cpp index 126b7ef3b69ff5ed5a4afa8df9af05c545d5914f..9830253434321f52eddf4fcc3bf584e2ba68cdac 100644 --- a/src/dbus/callmanager.cpp +++ b/src/dbus/callmanager.cpp @@ -1,3 +1,4 @@ + /* * Copyright (C) 2007 Savoir-Faire Linux inc. * Author: Pierre-Luc Beaudoin <pierre-luc.beaudoin@savoirfairelinux.com> @@ -122,6 +123,13 @@ CallManager::setRecording(const std::string& callID) Manager::instance().setRecordingCall(callID); } +bool +CallManager::getIsRecording(const std::string& callID) +{ + _debug("CallManager::getIsRecording received \n"); + return Manager::instance().isRecording(callID); +} + std::string CallManager::getCurrentCodecName(const std::string& callID) diff --git a/src/dbus/callmanager.h b/src/dbus/callmanager.h index 7f2e7e689f5c6e2dc0f65cbe21d29c1492885e24..e1fc6de8fa074e7d36e3f7d03738071092bc0465 100644 --- a/src/dbus/callmanager.h +++ b/src/dbus/callmanager.h @@ -49,6 +49,7 @@ public: void setVolume( const std::string& device, const double& value ); double getVolume( const std::string& device ); void setRecording( const std::string& callID ); + bool getIsRecording(const std::string& callID); std::string getCurrentCodecName(const std::string& callID); std::map< std::string, std::string > getCallDetails( const std::string& callID ); std::string getCurrentCallID( ); diff --git a/src/dbus/dbusmanagerimpl.cpp b/src/dbus/dbusmanagerimpl.cpp index 6972e8faa627070e320f3bfc4bec3e4b28dac55d..c2103892f70153549b301c480350c8037e60a0a0 100644 --- a/src/dbus/dbusmanagerimpl.cpp +++ b/src/dbus/dbusmanagerimpl.cpp @@ -46,6 +46,8 @@ DBusManagerImpl::exec(){ void DBusManagerImpl::exit() { + _dispatcher.leave(); + } diff --git a/src/dbus/instance.cpp b/src/dbus/instance.cpp index 0b4ace62a55e9d70271f5a0505cce61dacb19087..7011326c1c6339e6448fe6b84ff4ac345f23e2f5 100644 --- a/src/dbus/instance.cpp +++ b/src/dbus/instance.cpp @@ -44,15 +44,19 @@ Instance::Unregister( const int32_t& pid UNUSED) count --; if(count <= 0) { - _debug("0 client running, quitting..."); - DBusManager::instance().exit(); + + DBusManager::instance().exit(); + + Manager::instance().terminate(); + + } } int32_t Instance::getRegistrationCount( void ) { - _debug("Instance::getRegistrationCount\n"); + return count; } diff --git a/src/managerimpl.cpp b/src/managerimpl.cpp index bd7872ea83cc9052a3012c0c60181642efe6371d..0a4722225e2e57bf8ee7eb57a69da07b1b08be68 100644 --- a/src/managerimpl.cpp +++ b/src/managerimpl.cpp @@ -101,7 +101,7 @@ ManagerImpl::ManagerImpl (void) // never call if we use only the singleton... ManagerImpl::~ManagerImpl (void) { - terminate(); + // terminate(); _debug("%s stop correctly.\n", PROGNAME); } @@ -142,21 +142,23 @@ ManagerImpl::init() void ManagerImpl::terminate() { + _debug("ManagerImpl::terminate \n"); saveConfig(); unloadAccountMap(); - _debug("Unload DTMF Key\n"); + _debug("Unload DTMF Key \n"); delete _dtmfKey; - _debug("Unload Audio Driver\n"); + _debug("Unload Audio Driver \n"); delete _audiodriver; _audiodriver = NULL; - _debug("Unload Telephone Tone\n"); + _debug("Unload Telephone Tone \n"); delete _telephoneTone; _telephoneTone = NULL; - _debug("Unload Audio Codecs\n"); + _debug("Unload Audio Codecs \n"); _codecDescriptorMap.deleteHandlePointer(); + } bool @@ -252,6 +254,8 @@ ManagerImpl::answerCall(const CallID& id) { bool isActive = false; + stopTone(true); + AccountID currentaccountid = getAccountFromCall( id ); Call* currentcall = getAccountLink(currentaccountid)->getCall(getCurrentCallId()); _debug("ManagerImpl::answerCall :: current call->getState %i \n",currentcall->getState()); @@ -286,9 +290,9 @@ ManagerImpl::answerCall(const CallID& id) removeWaitingCall(id); switchCall(id); - std::string codecName = getCurrentCodecName(id); + // std::string codecName = getCurrentCodecName(id); // _debug("ManagerImpl::hangupCall(): broadcast codec name %s \n",codecName.c_str()); - if (_dbus) _dbus->getCallManager()->currentSelectedCodec(id,codecName.c_str()); + // if (_dbus) _dbus->getCallManager()->currentSelectedCodec(id,codecName.c_str()); return true; } @@ -302,7 +306,7 @@ ManagerImpl::hangupCall(const CallID& id) AccountID accountid; bool returnValue; - stopTone(true); + stopTone(false); /* Broadcast a signal over DBus */ if (_dbus) _dbus->getCallManager()->callStateChanged(id, "HUNGUP"); @@ -441,9 +445,9 @@ ManagerImpl::offHoldCall(const CallID& id) switchCall(id); - codecName = getCurrentCodecName(id); - _debug("ManagerImpl::hangupCall(): broadcast codec name %s \n",codecName.c_str()); - if (_dbus) _dbus->getCallManager()->currentSelectedCodec(id,codecName.c_str()); + // codecName = getCurrentCodecName(id); + // _debug("ManagerImpl::hangupCall(): broadcast codec name %s \n",codecName.c_str()); + // if (_dbus) _dbus->getCallManager()->currentSelectedCodec(id,codecName.c_str()); return returnValue; } @@ -690,6 +694,8 @@ ManagerImpl::incomingCall(Call* call, const AccountID& accountId) PulseLayer *pulselayer; std::string from, number; + stopTone(true); + _debug("Incoming call %s\n", call->getCallId().data()); associateCallToAccount(call->getCallId(), accountId); @@ -965,16 +971,21 @@ ManagerImpl::ringtone() int layer, samplerate; bool loadFile; + // stopTone(true); + if( isRingtoneEnabled() ) { //TODO Comment this because it makes the daemon crashes since the main thread //synchronizes the ringtone thread. + _debug("RINGING!!! 1\n"); ringchoice = getConfigString(AUDIO, RING_CHOICE); //if there is no / inside the path if ( ringchoice.find(DIR_SEPARATOR_CH) == std::string::npos ) { // check inside global share directory ringchoice = std::string(PROGSHAREDIR) + DIR_SEPARATOR_STR + RINGDIR + DIR_SEPARATOR_STR + ringchoice; + + _debug("RINGING!!! 2\n"); } audiolayer = getAudioDriver(); @@ -982,6 +993,8 @@ ManagerImpl::ringtone() if (audiolayer == 0) return; + _debug("RINGING!!! 3\n"); + samplerate = audiolayer->getSampleRate(); codecForTone = _codecDescriptorMap.getFirstCodecAvailable(); @@ -990,23 +1003,29 @@ ManagerImpl::ringtone() _toneMutex.leaveMutex(); if (loadFile) { + + _debug("RINGING!!! 5\n"); _toneMutex.enterMutex(); _audiofile.start(); _toneMutex.leaveMutex(); if(CHECK_INTERFACE( layer, ALSA )){ //ringback(); + } else{ audiolayer->startStream(); + _debug("RINGING!!! 6\n"); } } else { ringback(); + _debug("RINGING!!! 7\n"); } } else { ringback(); + _debug("RINGING!!! 8\n"); } }