diff --git a/sflphone-gtk/src/calllist.c b/sflphone-gtk/src/calllist.c index ce12521404e5fa43fff4390e0dc5a7150fc80234..b77b840d19b664a7a7f6c6741eed10bfe7873641 100644 --- a/sflphone-gtk/src/calllist.c +++ b/sflphone-gtk/src/calllist.c @@ -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; +} diff --git a/sflphone-gtk/src/calllist.h b/sflphone-gtk/src/calllist.h index caa78b8807ce13a1242e00f58df5df4969cf5c48..b930413cc379e1c1fa7f0ada69901f4094daaeca 100644 --- a/sflphone-gtk/src/calllist.h +++ b/sflphone-gtk/src/calllist.h @@ -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 diff --git a/sflphone-gtk/src/calltree.c b/sflphone-gtk/src/calltree.c index ccaddaa08e73b5493062269621f6059db15a0933..f82ae49a7012d9452cd02a28dd91750b45501c43 100644 --- a/sflphone-gtk/src/calltree.c +++ b/sflphone-gtk/src/calltree.c @@ -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,24 +282,25 @@ 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(); - 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 ); - update_menus(); - sflphone_place_call( mailboxCall ); - switch_tab(current_calls); + account_t* current; + call_t *mailbox_call; + gchar *to, *from, *account_id; + + current = account_list_get_current (); + if( current == NULL ) // Should not happens + return; + + 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( 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); } diff --git a/sflphone-gtk/src/contactlist/eds.c b/sflphone-gtk/src/contactlist/eds.c index d7c98bcda5423df1f1ad8791b599a111922d84bf..04c56cede1a305a08af6816717ac9facb5d24b77 100644 --- a/sflphone-gtk/src/contactlist/eds.c +++ b/sflphone-gtk/src/contactlist/eds.c @@ -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); } @@ -167,16 +167,16 @@ 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 = ""; } - + hit->name = g_strdup ((char*) e_contact_get_const (contact, E_CONTACT_NAME_OR_ORG)); if(! hit->name) hit->name = ""; diff --git a/sflphone-gtk/src/contactlist/eds.h b/sflphone-gtk/src/contactlist/eds.h index 893f03c461a4b06cdcda66d074505c8cd8d7ab17..f3e41aa892e7711b9d7fa5cf74a087adefa10688 100644 --- a/sflphone-gtk/src/contactlist/eds.h +++ b/sflphone-gtk/src/contactlist/eds.h @@ -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); diff --git a/sflphone-gtk/src/sflphone_const.h b/sflphone-gtk/src/sflphone_const.h index cdd85602d928af95a22ee93580ab8be0885a96db..71f67fa2ec94795951c9e4d04d5eaa3fdedfac1f 100644 --- a/sflphone-gtk/src/sflphone_const.h +++ b/sflphone-gtk/src/sflphone_const.h @@ -94,4 +94,5 @@ /** Desktop notifications - Time before to close the notification*/ #define __TIMEOUT_TIME 18000 // 30 secondes + #endif