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

factorize call creation

parent cd313efa
No related branches found
No related tags found
No related merge requests found
......@@ -218,3 +218,23 @@ call_get_selected (calltab_t* tab)
{
return tab->selectedCall;
}
void create_new_call (gchar *to, gchar *from, call_state_t state, gchar *accountID, call_t **new_call) {
gchar *call_id;
call_t *call;
call = g_new0 (call_t, 1);
call->to = g_strdup (to);
call->from = g_strdup (from);
call->state = state;
call->accountID = g_strdup (accountID);
call->_start = 0;
call->_stop = 0;
call_id = g_new0(gchar, 30);
g_sprintf(call_id, "%d", rand());
call->callID = g_strdup (call_id);
*new_call = call;
}
......@@ -81,9 +81,9 @@ typedef enum
*/
typedef enum
{
HOME,
CELLPHONE,
WORK
CONTACT_PHONE_HOME,
CONTACT_PHONE_BUSINESS,
CONTACT_PHONE_MOBILE
} contact_type_t;
/** @struct call_t
......@@ -106,8 +106,6 @@ typedef struct {
call_state_t state;
/** The history state if necessary */
history_state_t history_state;
/** The contact type if necessary */
contact_type_t contact_type;
time_t _start;
time_t _stop;
......@@ -205,4 +203,5 @@ void call_list_clean_history();
*/
void call_list_remove_from_history( call_t* c);
void create_new_call (gchar *to, gchar *from, call_state_t state, gchar *accountID, call_t **new_call);
#endif
......@@ -254,15 +254,13 @@ show_contacts_tab(GtkToggleToolButton *toggle_tool_button UNUSED,
{
Hit *entry;
entry = i->data;
if (i->data)
if (entry)
{
call_t * call;
call = g_new0 (call_t, 1);
call->from = g_strconcat("\"" , entry->name, "\"<", entry->phone, ">", NULL);
call->from = g_strconcat("\"" , entry->name, "\"<", entry->phone_business, ">", NULL);
call->state = CALL_STATE_DIALING;
//call->history_state = MISSED;
call->contact_type = HOME;
call_list_add (contacts, call);
update_call_tree_add(contacts,call);
......@@ -284,23 +282,24 @@ show_contacts_tab(GtkToggleToolButton *toggle_tool_button UNUSED,
static void
call_mailbox( GtkWidget* widget UNUSED, gpointer data UNUSED)
{
account_t* current = account_list_get_current();
account_t* current;
call_t *mailbox_call;
gchar *to, *from, *account_id;
current = account_list_get_current ();
if( current == NULL ) // Should not happens
return;
call_t* mailboxCall = g_new0( call_t , 1);
mailboxCall->state = CALL_STATE_DIALING;
mailboxCall->to = g_strdup(g_hash_table_lookup(current->properties, ACCOUNT_MAILBOX));
mailboxCall->from = g_markup_printf_escaped(_("\"Voicemail\" <%s>"), mailboxCall->to);
mailboxCall->callID = g_new0(gchar, 30);
g_sprintf(mailboxCall->callID, "%d", rand());
mailboxCall->accountID = g_strdup(current->accountID);
mailboxCall->_start = 0;
mailboxCall->_stop = 0;
g_print("TO : %s\n" , mailboxCall->to);
call_list_add( current_calls , mailboxCall );
update_call_tree_add( current_calls , mailboxCall );
to = g_strdup(g_hash_table_lookup(current->properties, ACCOUNT_MAILBOX));
from = g_markup_printf_escaped(_("\"Voicemail\" <%s>"), to);
account_id = g_strdup (current->accountID);
create_new_call (to, from, CALL_STATE_DIALING, account_id, &mailbox_call);
g_print("TO : %s\n" , mailbox_call->to);
call_list_add( current_calls , mailbox_call );
update_call_tree_add( current_calls , mailbox_call );
update_menus();
sflphone_place_call( mailboxCall );
sflphone_place_call( mailbox_call );
switch_tab(current_calls);
}
......@@ -930,21 +929,23 @@ update_call_tree_add (calltab_t* tab, call_t * c)
}
else if (tab == contacts) {
switch (c->contact_type)
/*switch (c->contact_type)
{
case HOME:
case CONTACT_PHONE_HOME:
pixbuf = gdk_pixbuf_new_from_file(ICONS_DIR "/face-monkey.svg", NULL);
break;
case WORK:
case CONTACT_PHONE_BUSINESS:
pixbuf = gdk_pixbuf_new_from_file(ICONS_DIR "/face-monkey.svg", NULL);
break;
case CELLPHONE:
case CONTACT_PHONE_MOBILE:
pixbuf = gdk_pixbuf_new_from_file(ICONS_DIR "/contact_default.svg", NULL);
break;
default:
pixbuf = gdk_pixbuf_new_from_file(ICONS_DIR "/contact_default.svg", NULL);
break;
}
}*/
pixbuf = gdk_pixbuf_new_from_file(ICONS_DIR "/face-monkey.svg", NULL);
description = g_strconcat( description , NULL);
}
......
......@@ -39,7 +39,7 @@ void
free_hit (Hit *h)
{
g_free (h->name);
g_free (h->phone);
g_free (h->phone_business);
g_free (h);
}
......@@ -168,12 +168,12 @@ search_sync (const char *query,
contact = E_CONTACT (contacts->data);
hit = g_new (Hit, 1);
hit->phone = g_strdup ((char*) e_contact_get_const (contact, E_CONTACT_PHONE_BUSINESS));
if(! hit->phone)
hit->phone_business = g_strdup ((char*) e_contact_get_const (contact, E_CONTACT_PHONE_BUSINESS));
if(! hit->phone_business)
{
// Temporary fix for empty phone numbers
sprintf(ext, "%d", rand()%100 + 100);
hit->phone = g_strconcat("rand",ext,NULL);
hit->phone_business = g_strconcat("rand",ext,NULL);
//hit->phone = "";
}
......
......@@ -34,10 +34,10 @@ G_BEGIN_DECLS
typedef struct _Hit
{
gchar *name;
gchar *phone;
gchar *phone_business;
} Hit;
void free_hit (Hit *hit);
void free_hit (Hit *h);
void init (void);
......
......@@ -94,4 +94,5 @@
/** Desktop notifications - Time before to close the notification*/
#define __TIMEOUT_TIME 18000 // 30 secondes
#endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment