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

factorize call creation

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