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

Enable to display multiple information for each contact

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