Skip to content
Snippets Groups Projects
Commit 9ce08e07 authored by Emmanuel Milou's avatar Emmanuel Milou
Browse files

Allow user to make IP call without any accounts configured

parent 849f00de
Branches
No related tags found
No related merge requests found
...@@ -670,60 +670,79 @@ sflphone_keypad( guint keyval, gchar * key) ...@@ -670,60 +670,79 @@ sflphone_keypad( guint keyval, gchar * key)
* Place a call with the current account. * Place a call with the current account.
* If there is no default account selected, place a call with the first * If there is no default account selected, place a call with the first
* registered account of the account list * registered account of the account list
* Else, popup an error message * Else, check if it an IP call. if not, popup an error message
*/ */
void void
sflphone_place_call ( call_t * c ) sflphone_place_call ( call_t * c )
{ {
if(c->state == CALL_STATE_DIALING && strcmp(c->to, "") != 0) if (c->state == CALL_STATE_DIALING && g_str_has_prefix (c->to, "ip:"))
{ {
dbus_place_call (c);
}
//format_phone_number (&c->to); else {
if( account_list_get_size() == 0 ) if(c->state == CALL_STATE_DIALING && strcmp(c->to, "") != 0)
{ {
notify_no_accounts();
sflphone_fail(c);
}
else if( account_list_get_by_state( ACCOUNT_STATE_REGISTERED ) == NULL ) //format_phone_number (&c->to);
{
notify_no_registered_accounts();
sflphone_fail(c);
}
else if( account_list_get_size() == 0 )
{ {
notify_no_accounts();
sflphone_fail(c);
}
else if( account_list_get_by_state( ACCOUNT_STATE_REGISTERED ) == NULL )
{
notify_no_registered_accounts();
sflphone_fail(c);
}
account_t * current; else
{
if(g_strcasecmp(c->accountID, "") != 0) { account_t * current;
current = account_list_get_by_id(c->accountID);
} else {
current = account_list_get_current();
}
// printf("sflphone_place_call :: c->accountID : %i \n",c->accountID);
// account_t * current = c->accountID; if(g_strcasecmp(c->accountID, "") != 0) {
current = account_list_get_by_id(c->accountID);
} else {
current = account_list_get_current();
}
// printf("sflphone_place_call :: c->accountID : %i \n",c->accountID);
// account_t * current = c->accountID;
if( current )
{
if(g_strcasecmp(g_hash_table_lookup( current->properties, "Status"),"REGISTERED")==0) if( current )
{ {
// OK, everything alright - the call is made with the current account
c -> accountID = current -> accountID; if(g_strcasecmp(g_hash_table_lookup( current->properties, "Status"),"REGISTERED")==0)
dbus_place_call(c); {
// OK, everything alright - the call is made with the current account
c -> accountID = current -> accountID;
dbus_place_call(c);
}
else
{
// Current account is not registered
// So we place a call with the first registered account
// And we switch the current account
current = account_list_get_by_state( ACCOUNT_STATE_REGISTERED );
c -> accountID = current -> accountID;
dbus_place_call(c);
notify_current_account( current );
account_list_set_current_id( c-> accountID );
}
} }
else else
{ {
// Current account is not registered
// No current accounts have been setup.
// So we place a call with the first registered account // So we place a call with the first registered account
// And we switch the current account // and we change the current account
current = account_list_get_by_state( ACCOUNT_STATE_REGISTERED ); current = account_list_get_by_state( ACCOUNT_STATE_REGISTERED );
c -> accountID = current -> accountID; c -> accountID = current -> accountID;
dbus_place_call(c); dbus_place_call(c);
...@@ -731,27 +750,13 @@ sflphone_place_call ( call_t * c ) ...@@ -731,27 +750,13 @@ sflphone_place_call ( call_t * c )
account_list_set_current_id( c-> accountID ); account_list_set_current_id( c-> accountID );
} }
} }
else // Update history
{ c->history_state = OUTGOING;
calllist_add(history, c);
// No current accounts have been setup.
// So we place a call with the first registered account
// and we change the current account
current = account_list_get_by_state( ACCOUNT_STATE_REGISTERED );
c -> accountID = current -> accountID;
dbus_place_call(c);
notify_current_account( current );
account_list_set_current_id( c-> accountID );
}
} }
// Update history
c->history_state = OUTGOING;
g_print ("add in history\n");
calllist_add(history, c);
} }
} }
void void
sflphone_display_selected_codec (const gchar* codecName) sflphone_display_selected_codec (const gchar* codecName)
{ {
...@@ -761,10 +766,15 @@ sflphone_display_selected_codec (const gchar* codecName) ...@@ -761,10 +766,15 @@ sflphone_display_selected_codec (const gchar* codecName)
account_t* acc; account_t* acc;
if(selectedCall->accountID != NULL){ if(selectedCall->accountID != NULL){
acc = account_list_get_by_id(selectedCall->accountID); acc = account_list_get_by_id(selectedCall->accountID);
msg = g_markup_printf_escaped(_("%s account- %s %s") , if (!acc) {
msg = g_markup_printf_escaped (_("IP call - %s"), codecName);
}
else {
msg = g_markup_printf_escaped(_("%s account- %s %s") ,
(gchar*)g_hash_table_lookup( acc->properties , ACCOUNT_TYPE), (gchar*)g_hash_table_lookup( acc->properties , ACCOUNT_TYPE),
(gchar*)g_hash_table_lookup( acc->properties , ACCOUNT_ALIAS), (gchar*)g_hash_table_lookup( acc->properties , ACCOUNT_ALIAS),
codecName); codecName);
}
statusbar_push_message( msg , __MSG_ACCOUNT_DEFAULT); statusbar_push_message( msg , __MSG_ACCOUNT_DEFAULT);
g_free(msg); g_free(msg);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment