Commit c6b9609a authored by Emmanuel Milou's avatar Emmanuel Milou

Enable to display multiple information for each contact

parent a68876fa
...@@ -93,28 +93,30 @@ button_pressed(GtkWidget* widget, GdkEventButton *event, gpointer user_data UNUS ...@@ -93,28 +93,30 @@ button_pressed(GtkWidget* widget, GdkEventButton *event, gpointer user_data UNUS
static void static void
call_button( GtkWidget *widget UNUSED, gpointer data UNUSED) call_button( GtkWidget *widget UNUSED, gpointer data UNUSED)
{ {
call_t * selectedCall = call_get_selected(active_calltree); call_t * selectedCall;
call_t* newCall = g_new0 (call_t, 1); call_t* new_call;
printf("Call button pressed\n"); gchar *to, *from;
selectedCall = call_get_selected(active_calltree);
if(call_list_get_size(current_calls)>0) if(call_list_get_size(current_calls)>0)
sflphone_pick_up(); sflphone_pick_up();
else if(call_list_get_size(active_calltree) > 0){ else if(call_list_get_size(active_calltree) > 0){
if( selectedCall) if( selectedCall)
{ {
printf("Calling a called num\n"); printf("Calling a called num\n");
newCall->to = g_strdup(call_get_number(selectedCall)); to = g_strdup(call_get_number(selectedCall));
newCall->from = g_strconcat("\"\" <", call_get_number(selectedCall), ">",NULL); from = g_strconcat("\"\" <", call_get_number(selectedCall), ">",NULL);
newCall->state = CALL_STATE_DIALING;
newCall->callID = g_new0(gchar, 30); create_new_call (to, from, CALL_STATE_DIALING, "", &new_call);
g_sprintf(newCall->callID, "%d", rand());
newCall->_start = 0; printf("call : from : %s to %s\n", new_call->from, new_call->to);
newCall->_stop = 0;
call_list_add(current_calls, new_call);
printf("call : from : %s to %s\n", newCall->from, newCall->to); update_call_tree_add(current_calls, new_call);
call_list_add(current_calls, newCall); sflphone_place_call(new_call);
update_call_tree_add(current_calls, newCall);
sflphone_place_call(newCall);
switch_tab(current_calls); switch_tab(current_calls);
} }
else else
...@@ -256,14 +258,12 @@ show_contacts_tab(GtkToggleToolButton *toggle_tool_button UNUSED, ...@@ -256,14 +258,12 @@ show_contacts_tab(GtkToggleToolButton *toggle_tool_button UNUSED,
entry = i->data; entry = i->data;
if (entry) if (entry)
{ {
call_t * call; /* Create entry for business phone information */
call = g_new0 (call_t, 1); create_new_entry_in_contactlist (entry->name, entry->phone_business);
call->from = g_strconcat("\"" , entry->name, "\"<", entry->phone_business, ">", NULL); /* Create entry for home phone information */
call->state = CALL_STATE_DIALING; create_new_entry_in_contactlist (entry->name, entry->phone_home);
//call->history_state = MISSED; /* Create entry for mobile phone information */
create_new_entry_in_contactlist (entry->name, entry->phone_mobile);
call_list_add (contacts, call);
update_call_tree_add(contacts,call);
} }
free_hit(entry); free_hit(entry);
} }
...@@ -279,6 +279,21 @@ show_contacts_tab(GtkToggleToolButton *toggle_tool_button UNUSED, ...@@ -279,6 +279,21 @@ show_contacts_tab(GtkToggleToolButton *toggle_tool_button UNUSED,
toolbar_update_buttons(); toolbar_update_buttons();
} }
void create_new_entry_in_contactlist (gchar *contact_name, gchar *contact_phone){
gchar *from;
call_t *new_call;
/* Check if the information is valid */
if (strcmp (contact_phone, EMPTY_ENTRY) != 0){
from = g_strconcat("\"" , contact_name, "\"<", contact_phone, ">", NULL);
create_new_call (from, from, CALL_STATE_DIALING, "", &new_call);
call_list_add (contacts, new_call);
update_call_tree_add(contacts, new_call);
}
}
static void static void
call_mailbox( GtkWidget* widget UNUSED, gpointer data UNUSED) call_mailbox( GtkWidget* widget UNUSED, gpointer data UNUSED)
{ {
...@@ -449,7 +464,8 @@ void row_activated(GtkTreeView *tree_view UNUSED, ...@@ -449,7 +464,8 @@ void row_activated(GtkTreeView *tree_view UNUSED,
{ {
g_print("double click action\n"); g_print("double click action\n");
call_t* selectedCall; call_t* selectedCall;
call_t* newCall; call_t* new_call;
gchar *to, *from, *account_id;
selectedCall = call_get_selected( active_calltree ); selectedCall = call_get_selected( active_calltree );
if (selectedCall) if (selectedCall)
...@@ -481,20 +497,15 @@ void row_activated(GtkTreeView *tree_view UNUSED, ...@@ -481,20 +497,15 @@ void row_activated(GtkTreeView *tree_view UNUSED,
// if history // if history
else else
{ {
newCall = g_new0( call_t, 1 ); to = g_strdup(call_get_number(selectedCall));
newCall->to = g_strdup(call_get_number(selectedCall)); from = g_strconcat("\"\" <", call_get_number(selectedCall), ">",NULL);
newCall->from = g_strconcat("\"\" <", call_get_number(selectedCall), ">",NULL); account_id = g_strdup (selectedCall->accountID);
newCall->state = CALL_STATE_DIALING;
newCall->callID = g_new0(gchar, 30); create_new_call (to, from, CALL_STATE_DIALING, account_id, &new_call);
g_sprintf(newCall->callID, "%d", rand());
newCall->_start = 0; call_list_add(current_calls, new_call);
newCall->_stop = 0; update_call_tree_add(current_calls, new_call);
printf("call : account : %s \n", selectedCall->accountID); sflphone_place_call(new_call);
newCall->accountID = selectedCall->accountID;
printf("call : from : %s to %s\n", newCall->from, newCall->to);
call_list_add(current_calls, newCall);
update_call_tree_add(current_calls, newCall);
sflphone_place_call(newCall);
switch_tab(current_calls); switch_tab(current_calls);
} }
} }
......
...@@ -26,7 +26,6 @@ ...@@ -26,7 +26,6 @@
#include <glib.h> #include <glib.h>
#include <glib/gstring.h> #include <glib/gstring.h>
#include <libebook/e-book.h>
#include <pango/pango.h> #include <pango/pango.h>
#include "eds.h" #include "eds.h"
...@@ -40,6 +39,8 @@ free_hit (Hit *h) ...@@ -40,6 +39,8 @@ free_hit (Hit *h)
{ {
g_free (h->name); g_free (h->name);
g_free (h->phone_business); g_free (h->phone_business);
g_free (h->phone_home);
g_free (h->phone_mobile);
g_free (h); g_free (h);
} }
...@@ -164,18 +165,22 @@ search_sync (const char *query, ...@@ -164,18 +165,22 @@ search_sync (const char *query,
for (; contacts != NULL; contacts = g_list_next (contacts)) { for (; contacts != NULL; contacts = g_list_next (contacts)) {
EContact *contact; EContact *contact;
Hit *hit; Hit *hit;
gchar *number;
contact = E_CONTACT (contacts->data); contact = E_CONTACT (contacts->data);
hit = g_new (Hit, 1); hit = g_new0 (Hit, 1);
hit->phone_business = g_strdup ((char*) e_contact_get_const (contact, E_CONTACT_PHONE_BUSINESS)); /* Get business phone information */
if(! hit->phone_business) fetch_information_from_contact (contact, E_CONTACT_PHONE_BUSINESS, &number);
{ hit->phone_business = g_strdup (number);
// Temporary fix for empty phone numbers
sprintf(ext, "%d", rand()%100 + 100); /* Get home phone information */
hit->phone_business = g_strconcat("rand",ext,NULL); fetch_information_from_contact (contact, E_CONTACT_PHONE_HOME, &number);
//hit->phone = ""; hit->phone_home = g_strdup (number);
}
/* Get mobile phone information */
fetch_information_from_contact (contact, E_CONTACT_PHONE_MOBILE, &number);
hit->phone_mobile = g_strdup (number);
hit->name = g_strdup ((char*) e_contact_get_const (contact, E_CONTACT_NAME_OR_ORG)); hit->name = g_strdup ((char*) e_contact_get_const (contact, E_CONTACT_NAME_OR_ORG));
if(! hit->name) if(! hit->name)
...@@ -192,3 +197,15 @@ search_sync (const char *query, ...@@ -192,3 +197,15 @@ search_sync (const char *query,
return hits; return hits;
} }
void fetch_information_from_contact (EContact *contact, EContactField field, gchar **info){
gchar *to_fetch;
to_fetch = g_strdup ((char*) e_contact_get_const (contact, field));
if(! to_fetch) {
to_fetch = g_strdup (EMPTY_ENTRY);
}
*info = g_strdup (to_fetch);
}
...@@ -28,6 +28,9 @@ ...@@ -28,6 +28,9 @@
#define __EDS_H__ #define __EDS_H__
#include <glib/gtypes.h> #include <glib/gtypes.h>
#include <libebook/e-book.h>
#define EMPTY_ENTRY "empty"
G_BEGIN_DECLS G_BEGIN_DECLS
...@@ -35,6 +38,8 @@ typedef struct _Hit ...@@ -35,6 +38,8 @@ typedef struct _Hit
{ {
gchar *name; gchar *name;
gchar *phone_business; gchar *phone_business;
gchar *phone_home;
gchar *phone_mobile;
} Hit; } Hit;
void free_hit (Hit *h); void free_hit (Hit *h);
...@@ -43,6 +48,8 @@ void init (void); ...@@ -43,6 +48,8 @@ void init (void);
GList * search_sync (const char *query, int max_results); GList * search_sync (const char *query, int max_results);
void fetch_information_from_contact (EContact *contact, EContactField field, gchar **info);
G_END_DECLS G_END_DECLS
#endif /* __EDS_H__ */ #endif /* __EDS_H__ */
Markdown is supported
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