Commit 88e48a62 authored by Emmanuel Milou's avatar Emmanuel Milou
Browse files

place a call with the default account

If an registered account is set by default, a call is placed with this account.
If no account is set by default, the call is made with the first registered account of the list
If a non-registered account is set as default, no call is placed and a message popup is thrown.
parent e3f4bacf
......@@ -22,6 +22,7 @@
#include <string.h>
GQueue * accountQueue;
gchar * DEFAULT_ACCOUNT=NULL;
/* GCompareFunc to compare a accountID (gchar* and a account_t) */
gint
......@@ -98,6 +99,20 @@ account_list_get_by_state (account_state_t state )
}
account_t *
account_list_get_by_id(gchar * accountID)
{
GList * c = g_queue_find_custom (accountQueue, accountID, is_accountID_struct);
if(c)
{
return (account_t *)c->data;
}
else
{
return NULL;
}
}
guint
account_list_get_size ( )
{
......@@ -120,6 +135,7 @@ void
account_list_set_default(const gchar * accountID)
{
DEFAULT_ACCOUNT = g_strdup(accountID);
g_print("DEFAULT_ACCOUNT = %s\n", DEFAULT_ACCOUNT);
}
const gchar * account_state_name(account_state_t s)
......
......@@ -70,7 +70,6 @@ typedef struct {
} account_t;
gchar * DEFAULT_ACCOUNT;
/** This function initialize the account list. */
void account_list_init ();
......@@ -116,4 +115,10 @@ void account_list_set_default(const gchar * accountID);
const gchar * account_state_name(account_state_t s);
void account_list_clear ( );
/** Return the account associated with an ID
* @param accountID The ID of the account
* @return An account or NULL */
account_t * account_list_get_by_id(gchar * accountID);
#endif
/*
* Copyright (C) 2007 Savoir-Faire Linux inc.
* Author: Pierre-Luc Beaudoin <pierre-luc@squidy.info>
* Author: Emmanuel Milou <emmanuel.milou@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
......@@ -34,7 +35,7 @@
#include <unistd.h>
void
void
sflphone_notify_voice_mail (guint count)
{
if(count > 0)
......@@ -50,7 +51,7 @@ sflphone_notify_voice_mail (guint count)
}
}
gboolean
gboolean
sflphone_quit ()
{
gboolean quit = FALSE;
......@@ -73,7 +74,7 @@ sflphone_quit ()
return quit;
}
void
void
sflphone_hold(call_t * c )
{
c->state = CALL_STATE_HOLD;
......@@ -82,7 +83,7 @@ sflphone_hold(call_t * c )
screen_clear();
}
void
void
sflphone_ringing(call_t * c )
{
c->state = CALL_STATE_RINGING;
......@@ -91,7 +92,7 @@ sflphone_ringing(call_t * c )
}
/** Internal to actions: Fill account list */
void
void
sflphone_fill_account_list()
{
account_list_clear ( );
......@@ -140,7 +141,7 @@ sflphone_fill_account_list()
toolbar_update_buttons();
}
gboolean
gboolean
sflphone_init()
{
call_list_init ();
......@@ -159,7 +160,7 @@ sflphone_init()
}
}
void
void
sflphone_hang_up()
{
call_t * selectedCall = call_get_selected();
......@@ -189,7 +190,7 @@ sflphone_hang_up()
}
void
void
sflphone_pick_up()
{
call_t * selectedCall = call_get_selected();
......@@ -216,7 +217,7 @@ sflphone_pick_up()
}
}
void
void
sflphone_on_hold ()
{
call_t * selectedCall = call_get_selected();
......@@ -234,7 +235,7 @@ sflphone_on_hold ()
}
}
void
void
sflphone_off_hold ()
{
call_t * selectedCall = call_get_selected();
......@@ -253,7 +254,7 @@ sflphone_off_hold ()
}
void
void
sflphone_fail( call_t * c )
{
c->state = CALL_STATE_FAILURE;
......@@ -262,7 +263,7 @@ sflphone_fail( call_t * c )
screen_set_call(c);
}
void
void
sflphone_busy( call_t * c )
{
c->state = CALL_STATE_BUSY;
......@@ -271,7 +272,7 @@ sflphone_busy( call_t * c )
screen_set_call(c);
}
void
void
sflphone_current( call_t * c )
{
c->state = CALL_STATE_CURRENT;
......@@ -280,7 +281,7 @@ sflphone_current( call_t * c )
screen_set_call(c);
}
void
void
sflphone_set_transfert()
{
call_t * c = call_get_selected();
......@@ -295,7 +296,7 @@ sflphone_set_transfert()
toolbar_update_buttons();
}
void
void
sflphone_unset_transfert()
{
call_t * c = call_get_selected();
......@@ -309,7 +310,7 @@ sflphone_unset_transfert()
}
toolbar_update_buttons();
}
void
void
sflphone_incoming_call (call_t * c)
{
call_list_add ( c );
......@@ -318,7 +319,7 @@ sflphone_incoming_call (call_t * c)
update_menus();
}
void
void
sflphone_hung_up (call_t * c )
{
call_list_remove(c->callID);
......@@ -407,7 +408,7 @@ call_t * sflphone_new_call()
return c;
}
void
void
sflphone_keypad( guint keyval, gchar * key)
{
call_t * c = call_get_selected();
......@@ -513,16 +514,39 @@ sflphone_keypad( guint keyval, gchar * key)
}
}
/*
* Place a call with the default account.
* If there is no default account selected, place a call with the first
* registered account of the account list
* Else, popup an error message
*/
void
sflphone_place_call ( call_t * c )
{
if(c->state == CALL_STATE_DIALING)
{
account_t * a = account_list_get_by_state (ACCOUNT_STATE_REGISTERED);
if(a)
account_t * account;
gchar * default_account = account_list_get_default();
account = account_list_get_by_id(default_account);
if(account)
{
if(strcmp(g_hash_table_lookup(account->properties, "Status"),"REGISTERED")==0)
{
c->accountID = default_account;
dbus_place_call(c);
}
else
{
main_window_error_message("The account selected as default is not registered.");
}
}
else{
account = account_list_get_by_state (ACCOUNT_STATE_REGISTERED);
if(account)
{
c->accountID = a->accountID;
c->accountID = account->accountID;
dbus_place_call(c);
}
else
......@@ -531,14 +555,14 @@ sflphone_place_call ( call_t * c )
}
}
}
}
/* Internal to action - set the DEFAULT_ACCOUNT variable */
void
void
sflphone_set_default_account( )
{
gchar* default_id = strdup(dbus_get_default_account());
g_print("Default Account = %s\n", default_id);
account_list_set_default(default_id);
}
/*
* Copyright (C) 2007 Savoir-Faire Linux inc.
* Author: Pierre-Luc Beaudoin <pierre-luc@squidy.info>
* Author: Emmanuel Milou <emmanuel.milou@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
......
......@@ -113,6 +113,7 @@ default_account(GtkWidget *widget, gpointer data)
// set account as default
if(selectedAccount)
{
account_list_set_default(selectedAccount->accountID);
dbus_set_default_account(selectedAccount->accountID);
}
}
......@@ -163,6 +164,9 @@ create_accounts_tab()
GtkTreeIter iter;
GValue val;
val.g_type = G_TYPE_POINTER;
account_t* current;
//GValue id;
//val.g_type = G_TYPE;
selectedAccount = NULL;
......@@ -198,7 +202,7 @@ create_accounts_tab()
account_store);
gtk_tree_model_get_value(GTK_TREE_MODEL(account_store), &iter, 3, &val);
//current = (account_t*) g_value_get_pointer(&val);
gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(account_store),
2, GTK_SORT_ASCENDING);
......@@ -208,6 +212,7 @@ create_accounts_tab()
rend,
"markup", 0,
NULL);
//if(current->accountID == account_list_get_default())
g_object_set(G_OBJECT(rend), "weight", "bold", NULL);
gtk_tree_view_append_column (GTK_TREE_VIEW(view), col);
......
Supports Markdown
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