Commit d61789bf authored by Emmanuel Milou's avatar Emmanuel Milou
Browse files

Add ringtone when a new call is opened

If there's no call in the calllist, and you open a call by clicking on the place_a_call button,
then you hear a ringtone, that means: dial man!
parent 62c2ba01
......@@ -334,6 +334,8 @@ sflphone_incoming_call (call_t * c)
void process_dialing(call_t * c, guint keyval, gchar * key)
{
// We stop the tone
dbus_start_tone( FALSE );
switch (keyval)
{
case 65293: /* ENTER */
......@@ -394,6 +396,8 @@ void process_dialing(call_t * c, guint keyval, gchar * key)
call_t * sflphone_new_call()
{
if( call_list_get_size() == 0 )
dbus_start_tone(TRUE);
call_t * c = g_new0 (call_t, 1);
c->state = CALL_STATE_DIALING;
c->from = g_strconcat("\"\" <>", NULL);
......
......@@ -310,6 +310,43 @@ static
inline
#endif
gboolean
org_sflphone_SFLphone_CallManager_start_tone (DBusGProxy *proxy, const gint IN_start, GError **error)
{
return dbus_g_proxy_call (proxy, "startTone", error, G_TYPE_INT, IN_start, G_TYPE_INVALID, G_TYPE_INVALID);
}
typedef void (*org_sflphone_SFLphone_CallManager_start_tone_reply) (DBusGProxy *proxy, GError *error, gpointer userdata);
static void
org_sflphone_SFLphone_CallManager_start_tone_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data)
{
DBusGAsyncData *data = (DBusGAsyncData*) user_data;
GError *error = NULL;
dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_INVALID);
(*(org_sflphone_SFLphone_CallManager_start_tone_reply)data->cb) (proxy, error, data->userdata);
return;
}
static
#ifdef G_HAVE_INLINE
inline
#endif
DBusGProxyCall*
org_sflphone_SFLphone_CallManager_start_tone_async (DBusGProxy *proxy, const gint IN_start, org_sflphone_SFLphone_CallManager_start_tone_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, "startTone", org_sflphone_SFLphone_CallManager_start_tone_async_callback, stuff, g_free, G_TYPE_INT, IN_start, G_TYPE_INVALID);
}
static
#ifdef G_HAVE_INLINE
inline
#endif
gboolean
org_sflphone_SFLphone_CallManager_set_volume (DBusGProxy *proxy, const char * IN_device, const gdouble IN_value, GError **error)
{
......
......@@ -631,6 +631,29 @@ dbus_play_dtmf(const gchar * key)
}
}
void
dbus_start_tone(const int start)
{
GError *error = NULL;
org_sflphone_SFLphone_CallManager_start_tone(
callManagerProxy,
start,
&error);
if (error)
{
g_printerr ("Failed to call startTone() on callManagerProxy: %s\n",
error->message);
g_error_free (error);
}
else
{
g_print ("DBus called startTone() on callManagerProxy\n");
}
}
void
dbus_register(int pid, gchar * name)
{
......
......@@ -477,16 +477,7 @@ create_view_menu()
gtk_widget_show (menu_items);
menu_items = gtk_menu_item_new_with_mnemonic(_("_Toolbar"));
// ICON / TEXT / BOTH
submenu_items = gtk_check_menu_item_new_with_mnemonic(_("Only Icons"));
gtk_menu_item_set_submenu (GTK_MENU_ITEM (submenu_items), menu_items);
submenu_items = gtk_check_menu_item_new_with_mnemonic(_("Only Text"));
gtk_menu_item_set_submenu (GTK_MENU_ITEM (submenu_items), menu_items);
submenu_items = gtk_check_menu_item_new_with_mnemonic(_("Icons & Text"));
gtk_menu_item_set_submenu (GTK_MENU_ITEM (submenu_items), menu_items);
gtk_widget_show( menu_items );
gtk_widget_set_sensitive( GTK_WIDGET(menu_items) , FALSE);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_items);
root_menu = gtk_menu_item_new_with_mnemonic (_("_View"));
......
......@@ -28,6 +28,7 @@ public:
register_method(CallManager, unhold, _unhold_stub);
register_method(CallManager, transfert, _transfert_stub);
register_method(CallManager, playDTMF, _playDTMF_stub);
register_method(CallManager, startTone, _startTone_stub);
register_method(CallManager, setVolume, _setVolume_stub);
register_method(CallManager, getVolume, _getVolume_stub);
register_method(CallManager, getCallDetails, _getCallDetails_stub);
......@@ -79,6 +80,11 @@ public:
{ "key", "s", true },
{ 0, 0, 0 }
};
static ::DBus::IntrospectedArgument startTone_args[] =
{
{ "start", "i", true },
{ 0, 0, 0 }
};
static ::DBus::IntrospectedArgument setVolume_args[] =
{
{ "device", "s", true },
......@@ -148,6 +154,7 @@ public:
{ "unhold", unhold_args },
{ "transfert", transfert_args },
{ "playDTMF", playDTMF_args },
{ "startTone", startTone_args },
{ "setVolume", setVolume_args },
{ "getVolume", getVolume_args },
{ "getCallDetails", getCallDetails_args },
......@@ -197,6 +204,7 @@ public:
virtual void unhold( const ::DBus::String& callID ) = 0;
virtual void transfert( const ::DBus::String& callID, const ::DBus::String& to ) = 0;
virtual void playDTMF( const ::DBus::String& key ) = 0;
virtual void startTone( const ::DBus::Int32& start ) = 0;
virtual void setVolume( const ::DBus::String& device, const ::DBus::Double& value ) = 0;
virtual ::DBus::Double getVolume( const ::DBus::String& device ) = 0;
virtual std::map< ::DBus::String, ::DBus::String > getCallDetails( const ::DBus::String& callID ) = 0;
......@@ -334,6 +342,15 @@ private:
::DBus::ReturnMessage reply(call);
return reply;
}
::DBus::Message _startTone_stub( const ::DBus::CallMessage& call )
{
::DBus::MessageIter ri = call.reader();
::DBus::Int32 argin1; ri >> argin1;
startTone(argin1);
::DBus::ReturnMessage reply(call);
return reply;
}
::DBus::Message _setVolume_stub( const ::DBus::CallMessage& call )
{
::DBus::MessageIter ri = call.reader();
......
......@@ -37,6 +37,10 @@
<arg type="s" name="key" direction="in"/>
</method>
<method name="startTone">
<arg type="i" name="start" direction="in"/>
</method>
<method name="setVolume">
<arg type="s" name="device" direction="in"/>
<arg type="d" name="value" direction="in"/>
......
......@@ -134,4 +134,12 @@ CallManager::playDTMF( const ::DBus::String& key )
Manager::instance().sendDtmf(Manager::instance().getCurrentCallId(), key.c_str()[0]);
}
void
CallManager::startTone( const ::DBus::Int32& start )
{
if( start == true )
Manager::instance().playTone();
else
Manager::instance().stopTone(true);
}
......@@ -51,6 +51,7 @@ public:
std::map< ::DBus::String, ::DBus::String > getCallDetails( const ::DBus::String& callID );
::DBus::String getCurrentCallID( );
void playDTMF( const ::DBus::String& key );
void startTone( const ::DBus::Int32& start );
};
......
......@@ -830,7 +830,6 @@ ManagerImpl::playATone(Tone::TONEID toneId) {
unsigned int nbSampling = audioloop->getSize();
AudioLayer* audiolayer = getAudioDriver();
SFLDataFormat buf[nbSampling];
//audioloop->getNext(buf, (int) nbSampling);
if ( audiolayer ) {
audiolayer->putUrgent( buf, nbSampling );
}
......@@ -871,7 +870,6 @@ ManagerImpl::stopTone(bool stopAudio=true) {
bool
ManagerImpl::playTone()
{
//return playATone(Tone::TONE_DIALTONE);
playATone(Tone::TONE_DIALTONE);
}
......@@ -1059,6 +1057,9 @@ ManagerImpl::createSettingsPath (void) {
void
ManagerImpl::initConfigFile (void)
{
std::string mes = gettext("Init config file\n");
_debug("%s",mes.c_str());
std::string type_str("string");
std::string type_int("int");
......
......@@ -641,25 +641,12 @@ SIPVoIPLink::answer(const CallID& id)
}
removeCall(call->getCallId());
return false;
/* int i;
int port;
char tmpbuf[64];
bzero (tmpbuf, 64);
// Get port
snprintf (tmpbuf, 63, "%d", getSipCall(id)->getLocalAudioPort());
_debug("%10d: Answer call [cid = %d, did = %d]\n", id, getSipCall(id)->getCid(), getSipCall(id)->getDid());
port = getSipCall(id)->getLocalAudioPort();
_debug(" Local audio port: %d\n", port);
*/
}
bool
SIPVoIPLink::hangup(const CallID& id)
{
SIPCall* call = getSIPCall(id);
Manager::instance().peerHungupCall( id );
if (call==0) { _debug("! SIP Error: Call doesn't exist\n"); return false; }
_debug("- SIP Action: Hang up call %s [cd: %3d %3d]\n", id.data(), call->getCid(), call->getDid());
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment