[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r32490 - in gnunet-gtk: contrib src/conversation
From: |
gnunet |
Subject: |
[GNUnet-SVN] r32490 - in gnunet-gtk: contrib src/conversation |
Date: |
Thu, 27 Feb 2014 22:34:14 +0100 |
Author: hark
Date: 2014-02-27 22:34:13 +0100 (Thu, 27 Feb 2014)
New Revision: 32490
Modified:
gnunet-gtk/contrib/gnunet_conversation_gtk_main_window.glade
gnunet-gtk/src/conversation/gnunet-conversation-gtk.c
gnunet-gtk/src/conversation/gnunet-conversation-gtk.h
gnunet-gtk/src/conversation/gnunet-conversation-gtk_common.h
gnunet-gtk/src/conversation/gnunet-conversation-gtk_contacts.c
Log:
- outgoing calls are using the active call list
Modified: gnunet-gtk/contrib/gnunet_conversation_gtk_main_window.glade
===================================================================
--- gnunet-gtk/contrib/gnunet_conversation_gtk_main_window.glade
2014-02-26 17:55:54 UTC (rev 32489)
+++ gnunet-gtk/contrib/gnunet_conversation_gtk_main_window.glade
2014-02-27 21:34:13 UTC (rev 32490)
@@ -449,6 +449,18 @@
<property
name="sort_column_id">0</property>
</object>
</child>
+ <child>
+ <object class="GtkTreeViewColumn"
id="call_stateColumn">
+ <property name="title"
translatable="yes">call_state</property>
+ <child>
+ <object
class="GtkCellRendererText" id="GNUNET_CONVERSATION_GTK_active_call_state"/>
+ <attributes>
+ <attribute
name="markup">6</attribute>
+ <attribute
name="text">6</attribute>
+ </attributes>
+ </child>
+ </object>
+ </child>
</object>
</child>
</object>
@@ -933,6 +945,12 @@
<column type="gint"/>
<!-- column-name caller_state -->
<column type="gint"/>
+ <!-- column-name call -->
+ <column type="gpointer"/>
+ <!-- column-name call_state -->
+ <column type="gint"/>
+ <!-- column-name call_id -->
+ <column type="gint"/>
</columns>
</object>
<object class="GtkListStore"
id="gnunet_conversation_gtk_caller_id_zone_liststore">
Modified: gnunet-gtk/src/conversation/gnunet-conversation-gtk.c
===================================================================
--- gnunet-gtk/src/conversation/gnunet-conversation-gtk.c 2014-02-26
17:55:54 UTC (rev 32489)
+++ gnunet-gtk/src/conversation/gnunet-conversation-gtk.c 2014-02-27
21:34:13 UTC (rev 32490)
@@ -30,6 +30,8 @@
struct GNUNET_CONVERSATION_Caller *caller_selected = NULL;
+struct GNUNET_CONVERSATION_Call *call_selected = NULL;
+
/*************
* common *
*************/
@@ -76,17 +78,17 @@
* Current state of iterating elements for the client.
* NULL if we are not currently iterating.
*/
-struct GNUNET_CONTAINER_MultiHashMapIterator *iter;
+static struct GNUNET_CONTAINER_MultiHashMapIterator *iter;
/**
*name of the incomming caller pkey or record name if known
*/
-char *callerName;
+static char *callerName;
/**
* peer id of a contact
*/
-char *peer_id;
+static char *peer_id;
/**
* List of active calls
@@ -101,7 +103,7 @@
/**
* List of incoming calls
*/
-struct CallList
+static struct CallList
{
/**
@@ -130,12 +132,17 @@
char *caller_id;
/**
- * Unique number of the call.
+ * Unique number of the caller.
*/
unsigned int caller_num;
};
+ /**
+ * Unique number of call (outgoing)
+ */
+ unsigned int call_counter;
+
/**
* Phone handle
*/
@@ -212,6 +219,9 @@
*/
static char *address;
+GtkWidget *b_contact, *b_accept, *b_hangup, *b_suspend, *b_resume;
+
+
/*******************
* identity select *
*******************/
@@ -280,20 +290,123 @@
}
-
/**
- * does nothing
+ * update status
+ *
+ * @param message Message to put in statusbar
*/
-void
-update_state ()
+static void
+update_status (const gchar * message)
{
-// LOG('update_state called',NULL);
+
+ GtkStatusbar *status_bar;
+ guint status_bar_context;
+
+ gchar *buff;
+
+ status_bar = GTK_STATUSBAR (get_object
("GNUNET_GTK_conversation_statusbar"));
+ status_bar_context = gtk_statusbar_get_context_id (status_bar, "blaat");
+
+
+ buff = g_strdup_printf ("%s", message);
+
+ gtk_statusbar_push (GTK_STATUSBAR (status_bar),
+ GPOINTER_TO_INT (status_bar_context), buff);
+ g_free (buff);
+
+ GNUNET_CONVERSATION_GTK_on_active_calls_selection_changed();
+
+
}
+
+
+/**
+ * update statusbar
+ *
+ * @param args arguments given to the command
+ */
+static void
+do_status ()
+{
+ struct CallList *cl;
+
+ switch (phone_state)
+ {
+ case PS_LOOKUP_EGO:
+ UPDATE_STATUS (_
+ ("We are currently trying to locate the private key for the
ego `%s'."),
+ ego_name);
+ set_status_icon ("gnunet-conversation-gtk-tray-pending");
+ break;
+ case PS_LISTEN:
+ UPDATE_STATUS (_
+ ("We are listening for incoming calls for ego `%s' on line
%u."),
+ ego_name, line);
+ set_status_icon ("gnunet-conversation-gtk-tray-available");
+
+ break;
+ case PS_ACCEPTED:
+ UPDATE_STATUS (_("You are having a conversation with `%s'.\n"), peer_name);
+ set_status_icon ("gnunet-conversation-call-active");
+
+ break;
+ case PS_ERROR:
+ UPDATE_STATUS (_
+ ("We had an internal error setting up our phone line. You
can still make calls."));
+ set_status_icon ("gnunet-conversation-offline");
+
+ break;
+ }
+ if (NULL != call)
+ {
+ switch (call_state)
+ {
+ case CS_RESOLVING:
+ UPDATE_STATUS (_
+ ("We are trying to find the network address to call
`%s'."),
+ peer_name);
+ set_status_icon ("gnunet-conversation-gtk-tray-call-pending");
+
+ break;
+ case CS_RINGING:
+ UPDATE_STATUS (_("We are calling `%s', his phone should be ringing."),
+ peer_name);
+ set_status_icon ("gnunet-conversation-gtk-tray-call-ringing");
+
+ break;
+ case CS_CONNECTED:
+ UPDATE_STATUS (_("You are having a conversation with `%s'."), peer_name);
+ set_status_icon ("gnunet-conversation-gtk-tray-call-active");
+
+ break;
+ case CS_SUSPENDED:
+ set_status_icon ("gnunet-conversation-gtk-tray-call-suspended");
+
+ /* ok to accept incoming call right now */
+ break;
+ }
+ }
+ if ((NULL != cl_head) && ((cl_head != cl_active) || (cl_head != cl_tail)))
+ {
+ set_status_icon ("gnunet-conversation-gtk-tray-call-incoming");
+
+ for (cl = cl_head; NULL != cl; cl = cl->next)
+ {
+ if (cl == cl_active)
+ continue;
+ //UPDATE_STATUS (_("#%u: `%s'"), cl->caller_num, cl->caller_id);
+// LOG ("%s", _("Calls waiting:"));
+ }
+ }
+}
+
+
+
/*
* @brief print info for currently selected call
*/
-void
+static void
print_call_info()
{
GtkTreeIter gtkiter;
@@ -310,11 +423,14 @@
gchar *str_data;
gint int_data;
gpointer cl_caller;
-
+ gpointer cl_call;
+
gtk_tree_model_get (GTK_TREE_MODEL(active_liststore), >kiter,
- AL_caller, &cl_caller,
- AL_caller_id,&str_data,
- AL_caller_num,&int_data,-1);
+ AL_caller, &cl_caller,
+ AL_caller_id, &str_data,
+ AL_caller_num, &int_data,
+ AL_call, &cl_call,
+ -1);
if (caller_selected == cl_caller)
{
// LOG (_("info for active call:%s number: %u row: %u"),
str_data,int_data,row_count);
@@ -322,6 +438,11 @@
// FPRINTF(stderr,"cal addr: %s\n",currentlySelectedCallAddress);
break ;
}
+ if (call_selected == cl_call)
+ {
+ LOG (_("info for active outgoing call:%s number: %u row: %u"),
str_data,int_data,row_count);
+ break;
+ }
g_free (str_data);
row_count++;
valid = gtk_tree_model_iter_next (GTK_TREE_MODEL(active_liststore),
>kiter);
@@ -336,41 +457,65 @@
/*
* @brief sets caller_selected, and enables or disables the active call list
buttons
*/
-void
+static void
update_active_call_list_buttons()
{
gchar *caller_id;
gpointer cl_caller;
+ gpointer cl_call;
gint cl_caller_state;
+ gint cl_type;
//gint cl_caller_type;
GtkTreeSelection *active_selection;
GtkTreeIter gcl_selected;
// active_liststore_selection =
get_object(ml,"GNUNET_CONVERSATION_GTK_active_calls_selection");
+ // reset references to selected call/caller
+ //caller_selected = NULL;
+ //call_selected = NULL;
+ LOG("reset caller selected");
active_selection = gtk_tree_view_get_selection (GTK_TREE_VIEW
(active_treeview));
if (gtk_tree_selection_get_selected(active_selection,NULL,&gcl_selected))
{
- gtk_tree_model_get (GTK_TREE_MODEL(active_liststore), &gcl_selected,
- AL_caller, &cl_caller,
+ // get selected call
+ gtk_tree_model_get (GTK_TREE_MODEL(active_liststore), &gcl_selected,
+ AL_caller, &cl_caller, // reference to incoming
call
AL_caller_id, &caller_id,
AL_caller_state, &cl_caller_state,
+ AL_type, &cl_type,
+ AL_call, &cl_call, // reference to outgoing call
-1);
-
- caller_selected = cl_caller;
-
gtk_widget_show(GTK_WIDGET(get_object("GNUNET_GTK_conversation_active_call_list_buttons"
)));
+ // check if selected call is a incoming or outgoing call
+ switch (cl_type)
+ {
+ case CALL_IN:
+ call_selected = NULL;
+ caller_selected = cl_caller;
+ if (caller_selected == NULL){
+ GNUNET_break(0);
+ }
+ break;
+ case CALL_OUT:
+ caller_selected = NULL;
+ call_selected = cl_call;
+ LOG("outgoing selected");
+ if (call_selected == NULL){
+ GNUNET_break(0);
+ }
+ break;
+ default:
+ GNUNET_break(0);
+ break;
+ }
- // make global?
- GtkWidget *b_contact, *b_accept, *b_hangup, *b_suspend, *b_resume;
- b_contact = GTK_WIDGET (get_object
("GNUNET_GTK_conversation_use_current_button"));
- b_accept = GTK_WIDGET (get_object
("GNUNET_GTK_conversation_accept_button"));
- b_hangup = GTK_WIDGET (get_object
("GNUNET_GTK_conversation_hangup_button"));
- b_suspend = GTK_WIDGET (get_object
("GNUNET_GTK_conversation_suspend_button"));
- b_resume = GTK_WIDGET (get_object
("GNUNET_GTK_conversation_resume_button"));
+
+
+
gtk_widget_show(GTK_WIDGET(get_object("GNUNET_GTK_conversation_active_call_list_buttons"
)));
LOG("caller state: %u phone_state: %u",cl_caller_state, phone_state);
@@ -436,10 +581,21 @@
LOG("enable resume button");
gtk_widget_set_sensitive(b_resume, 1);
}else{
- LOG("disable resume button");
- gtk_widget_set_sensitive(b_resume, 0);
+ LOG("do not disable resume button (for test)");
+ gtk_widget_set_sensitive(b_resume, 1);
}
break;
+ case CT_other:
+ //add to phonebook
+ //LOG("CT_rejected ");
+ gtk_widget_set_sensitive(b_contact, 1);
+ gtk_widget_set_sensitive(b_accept, 1);
+ gtk_widget_set_sensitive(b_hangup, 1);
+ gtk_widget_set_sensitive(b_suspend, 1);
+ gtk_widget_set_sensitive(b_resume,1);
+
+ break;
+
default:
GNUNET_break(0);
break;
@@ -457,8 +613,6 @@
} //end function
-
-
/*
* @brief executed when selecting a different item in active call list
*/
@@ -470,36 +624,18 @@
}
-
-/**
- * update status
- *
- * @param message Message to put in statusbar
- */
-
void
-update_status (const gchar * message)
+disable_list_buttons()
{
+ gtk_widget_set_sensitive(b_contact, 0);
+ gtk_widget_set_sensitive(b_accept, 0);
+ gtk_widget_set_sensitive(b_hangup, 0);
+ gtk_widget_set_sensitive(b_suspend, 0);
+ gtk_widget_set_sensitive(b_resume, 0);
+}
- GtkStatusbar *status_bar;
- guint status_bar_context;
- gchar *buff;
- status_bar = GTK_STATUSBAR (get_object
("GNUNET_GTK_conversation_statusbar"));
- status_bar_context = gtk_statusbar_get_context_id (status_bar, "blaat");
-
-
- buff = g_strdup_printf ("%s", message);
-
- gtk_statusbar_push (GTK_STATUSBAR (status_bar),
- GPOINTER_TO_INT (status_bar_context), buff);
- g_free (buff);
-
- GNUNET_CONVERSATION_GTK_on_active_calls_selection_changed();
-
-
-}
/*
* set_status_icon
*
@@ -575,14 +711,162 @@
}
/**
+ * set state of outgoing call
+ */
+set_outgoing_call_state(struct GNUNET_CONVERSATION_Call *call, int state)
+{
+ LOG("set state to: %u", state);
+ GtkTreeIter gtkiter;
+ gint valid = 0;
+ gint cl_type;
+ //FPRINTF (stderr,"set incoming call state:%u caller: ",state);
+
+// LOG (_("set incoming call state:%u caller: "),state);
+
+ valid = gtk_tree_model_get_iter_first( GTK_TREE_MODEL( active_liststore ),
>kiter );
+
+ if (!valid)
+ GNUNET_break(0);
+
+ while (valid)
+ {
+ gchar *cl_caller_id;
+ gint cl_caller_num;
+ gpointer cl_call;
+
+ gtk_tree_model_get ( GTK_TREE_MODEL( active_liststore ), >kiter,
+ AL_call, &cl_call,
+ AL_caller_id,&cl_caller_id,
+ AL_caller_num,&cl_caller_num,
+ AL_type, &cl_type,
+ -1);
+
+ if (cl_type == CALL_OUT) {
+
+ if (call == NULL) // function called by phone event handler
+ {
+ LOG("event handler");
+ gtk_list_store_set(active_liststore, >kiter,
+ AL_call_state, state,
+ -1);
+ switch (state)
+ {
+
+ /**
+ * We are the caller and are now ringing the other party (GNS lookup
+ * succeeded).
+ */
+ case GNUNET_CONVERSATION_EC_CALL_RINGING:
+
+ break;
+
+ /**
+ * We are the caller and are now ready to talk as the callee picked
up.
+ */
+ case GNUNET_CONVERSATION_EC_CALL_PICKED_UP:
+ break;
+ /**
+ * We are the caller and failed to locate a phone record in GNS.
+ * After this invocation, the respective call handle will be
+ * automatically destroyed and the client must no longer call
+ * #GNUNET_CONVERSATION_call_stop or any other function on the
+ * call object.
+ */
+ case GNUNET_CONVERSATION_EC_CALL_GNS_FAIL:
+ gtk_list_store_remove(active_liststore,>kiter);
+ disable_list_buttons();
+ break;
+
+ /**
+ * We are the caller and the callee called
+ * #GNUNET_CONVERSATION_caller_hang_up. After this invocation, the
+ * respective call handle will be automatically destroyed and the
+ * client must no longer call #GNUNET_CONVERSATION_call_stop.
+ */
+ case GNUNET_CONVERSATION_EC_CALL_HUNG_UP:
+ gtk_list_store_remove(active_liststore,>kiter);
+ disable_list_buttons();
+ break;
+
+ /**
+ * We are the caller and the callee suspended the call. Note that
+ * both sides can independently suspend and resume calls; a call is
+ * only "working" of both sides are active.
+ */
+ case GNUNET_CONVERSATION_EC_CALL_SUSPENDED:
+ break;
+
+ /**
+ * We are the caller and the callee suspended the call. Note that
+ * both sides can independently suspend and resume calls; a call is
+ * only "working" of both sides are active.
+ */
+ case GNUNET_CONVERSATION_EC_CALL_RESUMED:
+ break;
+
+ /**
+ * We had an error handing the call, and are now restarting it
+ * (back to lookup). This happens, for example, if the peer
+ * is restarted during a call.
+ */
+ case GNUNET_CONVERSATION_EC_CALL_ERROR:
+ break;
+
+ default:
+ break;
+ }
+
+
+
+
+
+
+ }
+ else if (call == cl_call) // function called for specific call
+ {
+ //LOG (_("setting state for call:%u row: %u state:
%u"),cl_caller_num,row_count,state);
+
+ switch (state)
+ {
+ case CT_hangup:
+ //LOG("remove line cause hangup");
+ gtk_list_store_remove(active_liststore,>kiter);
+ disable_list_buttons();
+ break;
+
+ case CT_rejected:
+ //LOG("remove line cause rejected");
+ gtk_list_store_remove(active_liststore,>kiter);
+ disable_list_buttons();
+ break;
+ default:
+
+ gtk_list_store_set(active_liststore, >kiter,
+ AL_caller_state, state,
+ -1);
+ break;
+
+ }//end switch
+ }//end call=cl_call
+ } //end cl_type
+ g_free (cl_caller_id);
+ valid = gtk_tree_model_iter_next (GTK_TREE_MODEL(active_liststore),
>kiter);
+
+ }//end while
+
+ //update statsbar
+ update_status("");
+
+
+
+}
+
+/**
* set call state of a incoming call
*/
static void
set_incoming_call_state(struct GNUNET_CONVERSATION_Caller *caller, int state)
{
- // struct CallList *cl = cls;
-// struct GNUNET_CONVERSATION_Caller caller;
- gint row_count = 0;
GtkTreeIter gtkiter;
gint valid = 0;
//FPRINTF (stderr,"set incoming call state:%u caller: ",state);
@@ -599,24 +883,13 @@
gchar *cl_caller_id;
gint cl_caller_num;
gpointer cl_caller;
-// gint new_state;
- //FPRINTF (stderr,"loop:: valid:%u \n",valid);
gtk_tree_model_get ( GTK_TREE_MODEL( active_liststore ), >kiter,
AL_caller, &cl_caller,
AL_caller_id,&cl_caller_id,
AL_caller_num,&cl_caller_num
,-1);
- /*
- enum {
- CT_active,
- CT_suspended,
- CT_ringing,
- CT_dead,
- CT_hangup,
- CT_rejected
-};
-*/
+
if (caller == cl_caller)
{
//LOG (_("setting state for call:%u row: %u state:
%u"),cl_caller_num,row_count,state);
@@ -626,11 +899,15 @@
case CT_hangup:
//LOG("remove line cause hangup");
gtk_list_store_remove(active_liststore,>kiter);
+ disable_list_buttons();
+
break;
case CT_rejected:
//LOG("remove line cause rejected");
gtk_list_store_remove(active_liststore,>kiter);
+ disable_list_buttons();
+
break;
default:
@@ -643,7 +920,6 @@
}//endif
g_free (cl_caller_id);
- row_count++;
valid = gtk_tree_model_iter_next (GTK_TREE_MODEL(active_liststore),
>kiter);
}//end while
@@ -703,7 +979,7 @@
AL_caller, caller,
AL_caller_num, caller_num_gen,
AL_caller_state, CT_ringing,
- AL_caller_type, CALL_IN
+ AL_type, CALL_IN
,-1);
@@ -749,6 +1025,7 @@
break;
}
+ do_status();
}
@@ -761,19 +1038,27 @@
static void
caller_event_handler (void *cls, enum GNUNET_CONVERSATION_CallerEventCode code)
{
- struct CallList *cl = cls;
- switch (code)
- {
- case GNUNET_CONVERSATION_EC_CALLER_SUSPEND:
- set_incoming_call_state(cls,CT_suspended);
- LOG (_("Call from `%s' suspended by other user\n"), cl->caller_id);
- break;
- case GNUNET_CONVERSATION_EC_CALLER_RESUME:
- set_incoming_call_state(cls,CT_active);
- LOG (_("Call from `%s' resumed by other user\n"), cl->caller_id);
- break;
+ if (cls == NULL){
+ LOG("caller_event_handler: cls == NULL");
+ GNUNET_break(0);
+ } else {
+ struct CallList *cl = cls;
+
+ switch (code)
+ {
+ case GNUNET_CONVERSATION_EC_CALLER_SUSPEND:
+ //TODO: should this be cls? not cl->caller
+ set_incoming_call_state(cl->caller,CT_suspended);
+ LOG (_("Call from `%s' suspended by other user\n"), cl->caller_id);
+ break;
+ case GNUNET_CONVERSATION_EC_CALLER_RESUME:
+ set_incoming_call_state(cl->caller,CT_active);
+ LOG (_("Call from `%s' resumed by other user\n"), cl->caller_id);
+ break;
+ }
}
+ do_status();
}
@@ -784,7 +1069,7 @@
start_phone ()
{
struct GNUNET_GNSRECORD_Data rd;
-
+ GtkLabel *label;
if (NULL == caller_id)
{
LOG (_("Ego `%s' no longer available, phone is now down.\n"), ego_name);
@@ -811,10 +1096,14 @@
LOG (_("address: `%s' \n"), address);
+ label = GTK_LABEL(get_object("GNUNET_CONVERSATION_GTK_my_address"));
+ gtk_label_set_text(label, address);
+
if (verbose)
LOG (_("Phone active on line %u\n"), (unsigned int) line);
phone_state = PS_LISTEN;
}
+ do_status();
}
@@ -827,38 +1116,50 @@
static void
call_event_handler (void *cls, enum GNUNET_CONVERSATION_CallEventCode code)
{
- switch (code)
- {
- case GNUNET_CONVERSATION_EC_CALL_RINGING:
- GNUNET_break (CS_RESOLVING == call_state);
- LOG (_("Resolved address of `%s'. Now ringing other party."), peer_name);
- call_state = CS_RINGING;
- break;
- case GNUNET_CONVERSATION_EC_CALL_PICKED_UP:
- GNUNET_break (CS_RINGING == call_state);
- LOG (_("Connection established to `%s'"), peer_name);
- call_state = CS_CONNECTED;
- break;
- case GNUNET_CONVERSATION_EC_CALL_GNS_FAIL:
- GNUNET_break (CS_RESOLVING == call_state);
- LOG (_("Failed to resolve %s in ego `%s'"), peer_name, ego_name);
- call = NULL;
- break;
- case GNUNET_CONVERSATION_EC_CALL_HUNG_UP:
- LOG ("%s", _("Call terminated"));
- call = NULL;
- break;
- case GNUNET_CONVERSATION_EC_CALL_SUSPENDED:
- GNUNET_break (CS_CONNECTED == call_state);
- LOG (_("Connection to `%s' suspended (by other user)\n"), peer_name);
- break;
- case GNUNET_CONVERSATION_EC_CALL_RESUMED:
- GNUNET_break (CS_CONNECTED == call_state);
- LOG (_("Connection to `%s' resumed (by other user)\n"), peer_name);
- break;
- case GNUNET_CONVERSATION_EC_CALL_ERROR:
- LOG ("GNUNET_CONVERSATION_EC_CALL_ERROR %s", peer_name);
- }
+ //struct OutgoingCallClosure *cl = cls;
+
+ //LOG("call event handler code: %u num: %u", code, cl->call_num);
+
+ //if (cls == NULL){
+ set_outgoing_call_state(NULL, code);
+ //GNUNET_break(0);
+ //} else
+ //{
+ switch (code)
+ {
+ case GNUNET_CONVERSATION_EC_CALL_RINGING:
+ GNUNET_break (CS_RESOLVING == call_state);
+ LOG (_("Resolved address of `%s'. Now ringing other party."),
peer_name);
+ // set_outgoing_call_state(cls, CT_ringing);
+
+ call_state = CS_RINGING;
+ break;
+ case GNUNET_CONVERSATION_EC_CALL_PICKED_UP:
+ GNUNET_break (CS_RINGING == call_state);
+ LOG (_("Connection established to `%s'"), peer_name);
+ call_state = CS_CONNECTED;
+ break;
+ case GNUNET_CONVERSATION_EC_CALL_GNS_FAIL:
+ GNUNET_break (CS_RESOLVING == call_state);
+ LOG (_("Failed to resolve %s in ego `%s'"), peer_name, ego_name);
+ call = NULL;
+ break;
+ case GNUNET_CONVERSATION_EC_CALL_HUNG_UP:
+ LOG ("%s", _("Call terminated"));
+ call = NULL;
+ break;
+ case GNUNET_CONVERSATION_EC_CALL_SUSPENDED:
+ GNUNET_break (CS_CONNECTED == call_state);
+ LOG (_("Connection to `%s' suspended (by other user)\n"), peer_name);
+ break;
+ case GNUNET_CONVERSATION_EC_CALL_RESUMED:
+ GNUNET_break (CS_CONNECTED == call_state);
+ LOG (_("Connection to `%s' resumed (by other user)\n"), peer_name);
+ break;
+ case GNUNET_CONVERSATION_EC_CALL_ERROR:
+ LOG ("GNUNET_CONVERSATION_EC_CALL_ERROR %s", peer_name);
+ }
+ //}
}
@@ -893,6 +1194,7 @@
LOG (_
("You are answering call from `%s', hang up or suspend that call
first!\n"),
peer_name);
+ GNUNET_break(0);
return;
case PS_ERROR:
/* ok to call */
@@ -903,9 +1205,31 @@
LOG (_("now calling: %s"), peer_name);
call_state = CS_RESOLVING;
GNUNET_assert (NULL == call);
+
+ call_counter++;
call =
GNUNET_CONVERSATION_call_start (cfg, caller_id, arg, speaker, mic,
- &call_event_handler, NULL);
+ &call_event_handler, NULL);
+ //call = newcall;
+
+ // add call to active call list
+ GtkTreeIter gtkiter;
+
+ gtk_list_store_append (active_liststore, >kiter);
+
+ gtk_list_store_set (active_liststore, >kiter,
+ AL_caller_id, peer_name,
+ AL_caller, NULL,
+ AL_caller_num, NULL,
+ AL_caller_state, CT_other,
+ AL_type, CALL_OUT,
+ AL_call, call,
+ AL_call_num, call_counter,
+ AL_call_state, CS_RESOLVING,
+ -1
+ );
+
+
UPDATE_STATUS (_("We are calling `%s', his phone should be ringing."),
peer_name);
GNUNET_CONVERSATION_GTK_history_add (CH_OUTGOING, peer_name);
@@ -927,6 +1251,7 @@
if ((NULL != call) && (CS_SUSPENDED != call_state))
{
LOG (_("You are calling someone else already, hang up first!\n"));
+ GNUNET_break(0);
return;
}
switch (phone_state)
@@ -941,45 +1266,18 @@
LOG (_
("You are answering call from `%s', hang up or suspend that call
first!\n"),
peer_name);
+ GNUNET_break(0);
return;
case PS_ERROR:
GNUNET_break (0);
break;
}//endswitch
-/*
- cl = cl_head;
- if (NULL == cl)
- {
- LOG (_("There is no incoming call to accept here!\n"));
- return;
- }
- if (NULL != cl->next)
- {
- for (cl = cl_head; NULL != cl; cl = cl->next)
- {
- GNUNET_snprintf (buf, sizeof (buf), "%u", cl->caller_num);
- }
- }
- if (NULL == cl)
- {
- LOG (_("There is no incoming call to accept right now!(NULL == cl) \n"));
- return;
- }
-
- GNUNET_CONTAINER_DLL_remove (cl_head,
- cl_tail,
- cl);
- cl_active = cl;
- GNUNET_free_non_null (peer_name);
- peer_name = GNUNET_strdup (cl->caller_id);
- */
-
phone_state = PS_ACCEPTED;
set_incoming_call_state(sel_caller,CT_active);
- cl = NULL;
+ cl = sel_caller;
GNUNET_CONVERSATION_caller_pick_up (sel_caller, &caller_event_handler, cl,
speaker, mic);
@@ -993,132 +1291,57 @@
+
/**
- * update statusbar
+ * Suspending a call
*
* @param args arguments given to the command
*/
+
static void
-do_status ()
+do_suspend ()
{
- struct CallList *cl;
+ /*
switch (phone_state)
{
case PS_LOOKUP_EGO:
- UPDATE_STATUS (_
- ("We are currently trying to locate the private key for the
ego `%s'."),
- ego_name);
- set_status_icon ("gnunet-conversation-gtk-tray-pending");
- break;
case PS_LISTEN:
- UPDATE_STATUS (_
- ("We are listening for incoming calls for ego `%s' on line
%u."),
- ego_name, line);
- set_status_icon ("gnunet-conversation-gtk-tray-available");
-
- break;
+ case PS_ERROR:
+ LOG ("%s", _(" There is no call that could be suspended right now.
(PS_ERROR)"));
+ return;
case PS_ACCEPTED:
- UPDATE_STATUS (_("You are having a conversation with `%s'.\n"), peer_name);
- set_status_icon ("gnunet-conversation-call-active");
-
+ // expected state, do rejection logic
break;
- case PS_ERROR:
- UPDATE_STATUS (_
- ("We had an internal error setting up our phone line. You
can still make calls."));
- set_status_icon ("gnunet-conversation-offline");
-
- break;
}
- if (NULL != call)
+ */
+ if (call_selected != NULL && caller_selected != NULL)
{
- switch (call_state)
- {
- case CS_RESOLVING:
- UPDATE_STATUS (_
- ("We are trying to find the network address to call
`%s'."),
- peer_name);
- set_status_icon ("gnunet-conversation-gtk-tray-call-pending");
-
- break;
- case CS_RINGING:
- UPDATE_STATUS (_("We are calling `%s', his phone should be ringing."),
- peer_name);
- set_status_icon ("gnunet-conversation-gtk-tray-call-ringing");
-
- break;
- case CS_CONNECTED:
- UPDATE_STATUS (_("You are having a conversation with `%s'."), peer_name);
- set_status_icon ("gnunet-conversation-gtk-tray-call-active");
-
- break;
- case CS_SUSPENDED:
- set_status_icon ("gnunet-conversation-gtk-tray-call-suspended");
-
- /* ok to accept incoming call right now */
- break;
- }
+ LOG("this shoud not be possible");
+ GNUNET_break(0);
}
- if ((NULL != cl_head) && ((cl_head != cl_active) || (cl_head != cl_tail)))
+ else
{
- set_status_icon ("gnunet-conversation-gtk-tray-call-incoming");
- for (cl = cl_head; NULL != cl; cl = cl->next)
- {
- if (cl == cl_active)
- continue;
- //UPDATE_STATUS (_("#%u: `%s'"), cl->caller_num, cl->caller_id);
-// LOG ("%s", _("Calls waiting:"));
- }
- }
-}
+ // outgoing
+ if (NULL != call_selected)
+ {
+ GNUNET_CONVERSATION_call_suspend (call_selected);
+ set_outgoing_call_state(call_selected,CT_suspended);
+
+ return;
+ }
+ // incoming
+ if (NULL != caller_selected)
+ {
+ GNUNET_CONVERSATION_caller_suspend (caller_selected);
+ set_incoming_call_state(caller_selected,CT_suspended);
+ phone_state = PS_LISTEN;
+ return;
-/**
- * Suspending a call
- *
- * @param args arguments given to the command
- */
-
-static void
-do_suspend (struct GNUNET_CONVERSATION_Caller *sel_caller)
-{
-
-/*
- if (NULL != call)
- {
- switch (call_state)
- {
- case CS_RESOLVING:
- case CS_RINGING:
- case CS_SUSPENDED:
- LOG ("%s", _("There is no call that could be suspended right now."));
- return;
- case CS_CONNECTED:
- call_state = CS_SUSPENDED;
- GNUNET_CONVERSATION_call_suspend (call);
- return;
- }
+ }
}
-*/
- switch (phone_state)
- {
- case PS_LOOKUP_EGO:
- case PS_LISTEN:
- case PS_ERROR:
- LOG ("%s", _(" There is no call that could be suspended right now."));
- return;
- case PS_ACCEPTED:
- /* expected state, do rejection logic */
- break;
- }
-
-// GNUNET_assert (NULL != cl_active);
-
- GNUNET_CONVERSATION_caller_suspend (sel_caller);
- phone_state = PS_LISTEN;
- set_incoming_call_state(sel_caller,CT_suspended);
-
}
@@ -1128,32 +1351,14 @@
* @param args arguments given to the command
*/
static void
-do_resume (struct GNUNET_CONVERSATION_Caller *sel_caller)
+do_resume ()
{
- //struct CallList *cl;
- //char buf[32];
-/*
- if (NULL != call)
+
+ switch (phone_state)
{
- switch (call_state)
- {
- case CS_RESOLVING:
- case CS_RINGING:
- case CS_CONNECTED:
- LOG ("%s", _("There is no call that could be resumed right now."));
- return;
- case CS_SUSPENDED:
- call_state = CS_CONNECTED;
- GNUNET_CONVERSATION_call_resume (call, speaker, mic);
- return;
- }
- }
-*/
- switch (phone_state)
- {
case PS_LOOKUP_EGO:
case PS_ERROR:
- LOG ("%s", _("There is no call that could be resumed right now."));
+ LOG ("%s", _("There is no call that could be resumed right
now.(PS_ERROR)"));
return;
case PS_LISTEN:
break;
@@ -1162,32 +1367,39 @@
peer_name);
return;
}
- /*
- GNUNET_assert (NULL == cl_active);
- cl = cl_head;
- if (NULL == cl)
+////
+ if (call_selected != NULL && caller_selected != NULL)
{
- LOG (_("There is no incoming call to resume here!"));
- return;
+ LOG("this shoud not be possible");
+ GNUNET_break(0);
+ return;
}
- if (NULL != cl->next)
+ else
{
- for (cl = cl_head; NULL != cl; cl = cl->next)
- {
- GNUNET_snprintf (buf, sizeof (buf), "%u", cl->caller_num);
- }
+
+ // outgoing
+ if (NULL != call_selected)
+ {
+ GNUNET_CONVERSATION_call_resume (call_selected, speaker, mic);
+ set_outgoing_call_state(call_selected,CT_active);
+
+ return;
+ }
+
+ // incoming
+ if (NULL != caller_selected)
+ {
+ GNUNET_CONVERSATION_caller_resume (caller_selected, speaker, mic);
+ set_incoming_call_state(caller_selected,CT_active);
+ phone_state = PS_ACCEPTED;
+ return;
+
+ }
+ GNUNET_break(0);
}
- if (NULL == cl)
- {
- LOG (_("There is no incoming call to resume right now! (null == cl)"));
- return;
- }
- cl_active = cl;
- */
-
- GNUNET_CONVERSATION_caller_resume (sel_caller, speaker, mic);
- set_incoming_call_state(sel_caller,CT_active);
- phone_state = PS_ACCEPTED;
+
+//
+////
}
@@ -1197,79 +1409,39 @@
* @param args arguments given to the command
*/
static void
-do_reject (struct GNUNET_CONVERSATION_Caller *sel_caller)
+do_reject ()
{
- //struct CallList *cl;
- //char buf[32];
+
+ if (call_selected == NULL && caller_selected == NULL){
+ GNUNET_break(0);
+ }else {
- /*
- if (NULL != call)
+ // if selected call is outgoing, stop it
+ if (NULL != call_selected)
{
- GNUNET_CONVERSATION_call_stop (call);
+ set_outgoing_call_state(call_selected,CT_hangup);
+
+ GNUNET_CONVERSATION_call_stop(call);
+ //GNUNET_CONVERSATION_call_stop (call_selected);
+
call = NULL;
+ call_selected = NULL;
return;
- }
- */
- switch (phone_state)
+ } else
+
+ // if selected call is incoming, hang it up
+ if (NULL != caller_selected)
{
- case PS_LOOKUP_EGO:
- case PS_ERROR:
- LOG ("%s", _("There is no call that could be cancelled right now.\n"));
- return;
- case PS_LISTEN:
- /* look for active incoming calls to refuse */
- /*
- cl = cl_head;
- if (NULL == cl)
- {
- LOG (_("There is no incoming call to refuse here!\n"));
- return;
- }
- if ((NULL != cl->next) || (NULL != args))
- {
- for (cl = cl_head; NULL != cl; cl = cl->next)
- {
- GNUNET_snprintf (buf, sizeof (buf), "%u", cl->caller_num);
- if (0 == strcmp (buf, args))
- break;
- }
- }
- if (NULL == cl)
- {
- LOG (_("There is no incoming call `%s' to refuse right now!\n"), args);
- return;
- }
- */
- //GNUNET_CONVERSATION_caller_hang_up (cl->caller);
- set_incoming_call_state(sel_caller,CT_rejected);
- GNUNET_CONVERSATION_caller_hang_up(sel_caller);
-
- /*
- GNUNET_CONTAINER_DLL_remove (cl_head, cl_tail, cl);
- peer_name = GNUNET_strdup (cl->caller_id);
- GNUNET_free (cl->caller_id);
- GNUNET_free (cl);
- */
-// caller_num_gen--;
- break;
- case PS_ACCEPTED:
- /* expected state, do rejection logic */
- GNUNET_CONVERSATION_GTK_history_add (CH_REJECTED, peer_name);
- /*
- GNUNET_assert (NULL != cl_active);
- GNUNET_CONVERSATION_caller_hang_up (cl_active->caller);
- GNUNET_free (cl_active->caller_id);
- GNUNET_free (cl_active);
- GNUNET_assert (caller_num_gen > 0);
-// caller_num_gen--;
- */
- set_incoming_call_state(sel_caller,CT_hangup);
- GNUNET_CONVERSATION_caller_hang_up(sel_caller);
+ set_incoming_call_state(caller_selected,CT_hangup);
+ //FPRINTF(stderr,"hangup: %u", caller_selected);
+ GNUNET_CONVERSATION_caller_hang_up(caller_selected);
//cl_active = NULL;
phone_state = PS_LISTEN;
- break;
+ caller_selected = NULL;
+ } else {
+ GNUNET_break(0);
}
-
+ }
}
@@ -1289,10 +1461,27 @@
identity_cb (void *cls, struct GNUNET_IDENTITY_Ego *ego, void **ctx,
const char *name)
{
- // struct GNUNET_CRYPTO_EcdsaPublicKey pk;
- // char *s;
-// GtkTreeIter iter;
+ struct GNUNET_CRYPTO_EcdsaPublicKey pk;
+ char *s;
+ GtkTreeIter iter;
+
+ if (NULL != ego)
+ {
+ GNUNET_IDENTITY_ego_get_public_key (ego, &pk);
+ s = GNUNET_CRYPTO_ecdsa_public_key_to_string (&pk);
+ fprintf (stderr, "main identity_cb: %s \n", name);
+
+
+ gtk_list_store_insert_with_values (zone_liststore,
+ &iter, -1,
+ 0, name,
+ 1, ego,
+ -1);
+
+ }
+
+
if (NULL == name)
return;
if (ego == caller_id)
@@ -1312,11 +1501,11 @@
caller_id = NULL;
return;
}
+
caller_id = ego;
+
+ // do not remove this, it tells the phone which line to use
GNUNET_CONFIGURATION_set_value_number (cfg, "CONVERSATION", "LINE", line);
- //zone_pkey = *GNUNET_IDENTITY_ego_get_private_key (caller_id);
- // ns = GNUNET_NAMESTORE_connect (cfg);
-
if (NULL == phone)
start_phone();
@@ -1405,6 +1594,7 @@
// ns = NULL;
//}
GNUNET_CONVERSATION_GTK_CONTACTS_shutdown();
+
GNUNET_SPEAKER_destroy (speaker);
speaker = NULL;
GNUNET_MICROPHONE_destroy (mic);
@@ -1487,6 +1677,15 @@
speaker = GNUNET_SPEAKER_create_from_hardware (GIG_get_configuration ());
mic = GNUNET_MICROPHONE_create_from_hardware (GIG_get_configuration ());
+ b_contact = GTK_WIDGET (get_object
("GNUNET_GTK_conversation_use_current_button"));
+ b_accept = GTK_WIDGET (get_object
("GNUNET_GTK_conversation_accept_button"));
+ b_hangup = GTK_WIDGET (get_object
("GNUNET_GTK_conversation_hangup_button"));
+ b_suspend = GTK_WIDGET (get_object
("GNUNET_GTK_conversation_suspend_button"));
+ b_resume = GTK_WIDGET (get_object
("GNUNET_GTK_conversation_resume_button"));
+
+
+
+
if (NULL == ego_name)
{
ego_name = "phone-ego";
@@ -1560,7 +1759,9 @@
void
GNUNET_CONVERSATION_GTK_on_hangup_clicked ()
{
- do_reject (caller_selected);
+
+ do_reject ();
+
do_status ();
//history_add(3,peer_name);
}
@@ -1571,7 +1772,13 @@
void
GNUNET_CONVERSATION_GTK_on_accept_clicked ()
{
+ if (caller_selected != NULL)
+ {
do_accept (caller_selected);
+ } else {
+ GNUNET_break(0);
+ }
+ do_status();
}
@@ -1581,7 +1788,8 @@
void
GNUNET_CONVERSATION_GTK_on_reject_clicked ()
{
- do_reject (caller_selected);
+ do_reject ();
+ do_status();
}
/**
@@ -1590,7 +1798,8 @@
void
GNUNET_CONVERSATION_GTK_on_pause_clicked ()
{
- do_suspend (caller_selected);
+ do_suspend ();
+ do_status();
}
/**
@@ -1599,7 +1808,8 @@
void
GNUNET_CONVERSATION_GTK_on_resume_clicked ()
{
- do_resume (caller_selected);
+ do_resume ();
+ do_status();
}
/**
Modified: gnunet-gtk/src/conversation/gnunet-conversation-gtk.h
===================================================================
--- gnunet-gtk/src/conversation/gnunet-conversation-gtk.h 2014-02-26
17:55:54 UTC (rev 32489)
+++ gnunet-gtk/src/conversation/gnunet-conversation-gtk.h 2014-02-27
21:34:13 UTC (rev 32490)
@@ -30,8 +30,8 @@
* @return configuration handle
**/
-extern struct GNUNET_CONFIGURATION_Handle *
-GIG_get_configuration ();
+//extern struct GNUNET_CONFIGURATION_Handle *
+//GIG_get_configuration ();
extern GObject *
Modified: gnunet-gtk/src/conversation/gnunet-conversation-gtk_common.h
===================================================================
--- gnunet-gtk/src/conversation/gnunet-conversation-gtk_common.h
2014-02-26 17:55:54 UTC (rev 32489)
+++ gnunet-gtk/src/conversation/gnunet-conversation-gtk_common.h
2014-02-27 21:34:13 UTC (rev 32490)
@@ -33,8 +33,6 @@
-
-
/*
* active calls treevieuw columns
*/
@@ -43,8 +41,11 @@
AL_caller_id, //*gchar
AL_caller, //*
AL_caller_num, //gint
- AL_caller_type, //gint
- AL_caller_state //gint
+ AL_type, //gint
+ AL_caller_state, //gint
+ AL_call, //*
+ AL_call_state, //gint
+ AL_call_num //gint
};
/**
* callerstate (state of incoming call)
@@ -56,7 +57,8 @@
CT_ringing,
CT_dead,
CT_hangup,
- CT_rejected
+ CT_rejected,
+ CT_other
};
/**
Modified: gnunet-gtk/src/conversation/gnunet-conversation-gtk_contacts.c
===================================================================
--- gnunet-gtk/src/conversation/gnunet-conversation-gtk_contacts.c
2014-02-26 17:55:54 UTC (rev 32489)
+++ gnunet-gtk/src/conversation/gnunet-conversation-gtk_contacts.c
2014-02-27 21:34:13 UTC (rev 32490)
@@ -135,17 +135,17 @@
/**
* Handle to the namestore.
*/
-struct GNUNET_NAMESTORE_Handle *ns;
+static struct GNUNET_NAMESTORE_Handle *ns;
/**
* Private key for the our zone.
*/
-struct GNUNET_CRYPTO_EcdsaPrivateKey zone_pkey;
+static struct GNUNET_CRYPTO_EcdsaPrivateKey zone_pkey;
/**
* Public key of the zone we are currently editing.
*/
-struct GNUNET_CRYPTO_EcdsaPublicKey pubkey;
+static struct GNUNET_CRYPTO_EcdsaPublicKey pubkey;
@@ -153,7 +153,7 @@
/**
* Name of the records to add/list/remove.
*/
-static char *name;
+ static char *name;
/**
* Queue entry for the 'add' operation.
@@ -181,12 +181,15 @@
struct GNUNET_TIME_Relative rt;
GtkTreeIter display_iter;
+
if (NULL == rname)
{
+
list_it = NULL;
//test_finished ();
return;
}
+
for (i = 0; i < rd_len; i++)
{
@@ -240,7 +243,10 @@
GNUNET_free (s);
}
// FPRINTF (stdout, "%s", "\n");
+
GNUNET_NAMESTORE_zone_iterator_next (list_it);
+// GNUNET_NAMESTORE_zone_iteration_stop(list_it);
+
}
@@ -277,38 +283,12 @@
}
- /*
- if (NULL == name)
- return;
- if (ego == contacts_ego)
- {
- //if (verbose)
- LOG (_("Name of phonebook ego changed to `%s'\n"), name);
- GNUNET_free (contacts_ego_name);
- contacts_ego_name = GNUNET_strdup (name);
- return;
- }
- if (0 != strcmp (name, contacts_ego_name))
- return;
- if (NULL == ego)
- {
- if (verbose)
- LOG (_("Our phonebook ego `%s' was deleted!\n"), contacts_ego_name);
- contacts_ego = NULL;
- return;
- }
- */
contacts_ego = ego;
// zone_pkey = *GNUNET_IDENTITY_ego_get_private_key (caller_id);
ns = GNUNET_NAMESTORE_connect (cfg);
-
-
-// list_it =
-// GNUNET_NAMESTORE_zone_iteration_start (ns, &zone_pkey, &display_record,
-// NULL);
-
+
}
/**
* Continuation called to notify client about result of the
@@ -372,7 +352,7 @@
* @param name
* @param address
*/
-void
+static void
add_contact (const gchar * name, const gchar * address)
{
// memmove(&address+1,&address+51,1);
@@ -667,17 +647,30 @@
extern void
GNUNET_CONVERSATION_GTK_CONTACTS_shutdown()
{
- GNUNET_CRYPTO_ecdsa_key_clear (&zone_pkey);
+
if (NULL != id)
{
GNUNET_IDENTITY_disconnect (id);
id = NULL;
+ } else {
+ GNUNET_break(0);
}
+
+ if (NULL != list_it)
+ {
+ FPRINTF(stderr,"LIST_IT == NULL");
+// GNUNET_NAMESTORE_zone_iteration_stop(list_it);
+ }
if (NULL != ns)
{
GNUNET_NAMESTORE_disconnect (ns);
ns = NULL;
+ } else {
+ GNUNET_break(0);
}
+
+ GNUNET_CRYPTO_ecdsa_key_clear (&zone_pkey);
+
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r32490 - in gnunet-gtk: contrib src/conversation,
gnunet <=