[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r33404 - gnunet-gtk/src/conversation
From: |
gnunet |
Subject: |
[GNUnet-SVN] r33404 - gnunet-gtk/src/conversation |
Date: |
Mon, 26 May 2014 21:38:06 +0200 |
Author: grothoff
Date: 2014-05-26 21:38:06 +0200 (Mon, 26 May 2014)
New Revision: 33404
Modified:
gnunet-gtk/src/conversation/gnunet-conversation-gtk_phone.c
Log:
-phone indentation cleanup
Modified: gnunet-gtk/src/conversation/gnunet-conversation-gtk_phone.c
===================================================================
--- gnunet-gtk/src/conversation/gnunet-conversation-gtk_phone.c 2014-05-26
19:28:04 UTC (rev 33403)
+++ gnunet-gtk/src/conversation/gnunet-conversation-gtk_phone.c 2014-05-26
19:38:06 UTC (rev 33404)
@@ -383,7 +383,7 @@
* @brief sets caller_selected, and enables or disables the active call list
buttons
*/
static void
-update_active_call_list_buttons()
+update_active_call_list_buttons ()
{
gchar *caller_id;
gpointer cl_caller;
@@ -534,7 +534,7 @@
static void
-disable_list_buttons()
+disable_list_buttons ()
{
gtk_widget_set_sensitive (b_add_contact, FALSE);
gtk_widget_set_sensitive (b_accept, FALSE);
@@ -547,7 +547,7 @@
/**
* set state of outgoing call
*/
-void
+static void
set_outgoing_call_state (struct GNUNET_CONVERSATION_Call *call,
int state)
{
@@ -555,9 +555,8 @@
gint valid = 0;
gint cl_type;
- GCG_log("set state to: %u", state);
- valid = gtk_tree_model_get_iter_first( GTK_TREE_MODEL( active_liststore ),
>kiter);
-
+ valid = gtk_tree_model_get_iter_first (GTK_TREE_MODEL (active_liststore),
+ >kiter);
if (!valid)
GNUNET_break(0);
while (valid)
@@ -660,13 +659,12 @@
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
+ }
GCG_update_status_bar ("");
}
@@ -680,61 +678,51 @@
{
GtkTreeIter gtkiter;
gint valid = 0;
- //FPRINTF (stderr,"set incoming call state:%u caller: ",state);
-// GCG_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_caller;
- if (!valid)
- GNUNET_break(0);
-
- while (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);
+ if (caller == cl_caller)
{
- gchar *cl_caller_id;
- gint cl_caller_num;
- gpointer cl_caller;
-
- 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);
-
- if (caller == cl_caller)
+ switch (state)
{
- //GCG_log (_("setting state for call:%u row: %u state:
%u"),cl_caller_num,row_count,state);
-
- switch (state)
- {
- case CT_hangup:
- //GCG_log("remove line cause hangup");
- gtk_list_store_remove(active_liststore,>kiter);
- disable_list_buttons();
-
- break;
-
- case CT_rejected:
- //GCG_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
- }//endif
-
- g_free (cl_caller_id);
- valid = gtk_tree_model_iter_next (GTK_TREE_MODEL(active_liststore),
>kiter);
-
- }//end while
- GCG_update_status_bar("");
+ case CT_hangup:
+ //GCG_log("remove line cause hangup");
+ gtk_list_store_remove (active_liststore,
+ >kiter);
+ disable_list_buttons ();
+ break;
+ case CT_rejected:
+ //GCG_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;
+ }
+ }
+ g_free (cl_caller_id);
+ valid = gtk_tree_model_iter_next (GTK_TREE_MODEL(active_liststore),
+ >kiter);
+ }
+ GCG_update_status_bar("");
}
@@ -755,79 +743,61 @@
GtkTreeIter gtkiter;
GtkTreeIter gtkiter1;
gboolean valid;
+ struct CallList *cl;
switch (code)
{
case GNUNET_CONVERSATION_EC_PHONE_RING:
- //increment call #
caller_num_gen++;
-
-
GCG_log (_("A Incoming call from `%s' with number %u\n"),
caller_id,
caller_num_gen);
-
- //old
- struct CallList *cl;
-
cl = GNUNET_new (struct CallList);
cl->caller = caller;
cl->caller_id = GNUNET_strdup (caller_id);
cl->caller_num = caller_num_gen;
GNUNET_CONTAINER_DLL_insert (cl_head, cl_tail, cl);
- //gtk
- gtk_list_store_append (active_liststore, >kiter);
-
- gtk_list_store_set (active_liststore, >kiter,
+ gtk_list_store_append (active_liststore,
+ >kiter);
+ gtk_list_store_set (active_liststore,
+ >kiter,
AL_caller_id, caller_id,
AL_caller, caller,
AL_caller_num, caller_num_gen,
AL_caller_state, CT_ringing,
- AL_type, CALL_IN
- ,-1);
-
-
+ AL_type, CALL_IN,
+ -1);
break;
-
case GNUNET_CONVERSATION_EC_PHONE_HUNG_UP:
- //gtk
-
valid = gtk_tree_model_get_iter_first( GTK_TREE_MODEL( active_liststore ),
>kiter1 );
-
if (!valid)
- GNUNET_break(0);
-
+ GNUNET_break(0);
while (valid)
{
- //FPRINTF(stderr,"GNUNET_CONVERSATION_EC_PHONE_HUNG_UP: while valid");
-
gchar *str_data;
gint int_data;
gpointer cl_caller;
- gtk_tree_model_get (GTK_TREE_MODEL(active_liststore), >kiter1,
+ gtk_tree_model_get (GTK_TREE_MODEL(active_liststore),
+ >kiter1,
AL_caller, &cl_caller,
- AL_caller_id,&str_data,
- AL_caller_num,&int_data,-1);
+ AL_caller_id, &str_data,
+ AL_caller_num, &int_data,
+ -1);
if (caller == cl_caller)
{
-
- GCG_log (_("phone hung up:%s number: %u "), str_data,int_data);
- set_incoming_call_state(caller,CT_rejected);
- break ;
+ GCG_log (_("phone hung up:%s number: %u "),
+ str_data,
+ int_data);
+ set_incoming_call_state (caller,
+ CT_rejected);
+ break;
}
- g_free (str_data);
- valid = gtk_tree_model_iter_next (GTK_TREE_MODEL(active_liststore),
>kiter1);
+ g_free (str_data);
+ valid = gtk_tree_model_iter_next (GTK_TREE_MODEL(active_liststore),
>kiter1);
}
-
-
-
phone_state = PS_LISTEN;
- //add to call history list
- //history_add(CH_HANGUP, cl->caller_id);
-
break;
-
}
do_status();
}
@@ -843,34 +813,29 @@
caller_event_handler (void *cls,
enum GNUNET_CONVERSATION_CallerEventCode code)
{
+ struct CallList *cl = cls;
- if (cls == NULL)
+ if (NULL == cl)
{
- GCG_log("caller_event_handler: cls == NULL");
- GNUNET_break(0);
+ GNUNET_break (0);
+ return;
}
- else
+ switch (code)
{
- 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);
- GCG_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);
- GCG_log (_("Call from `%s' resumed by other user\n"), cl->caller_id);
- break;
- }
+ case GNUNET_CONVERSATION_EC_CALLER_SUSPEND:
+ //TODO: should this be cls? not cl->caller
+ set_incoming_call_state(cl->caller,CT_suspended);
+ GCG_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);
+ GCG_log (_("Call from `%s' resumed by other user\n"), cl->caller_id);
+ break;
}
do_status();
}
-
/**
* Start our phone.
*/
@@ -924,57 +889,49 @@
{
//struct OutgoingCallClosure *cl = cls;
- //GCG_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);
- GCG_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);
- GCG_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);
- GCG_log (_("Failed to resolve %s in current zone."),
- peer_name);
- call = NULL;
- break;
- case GNUNET_CONVERSATION_EC_CALL_HUNG_UP:
- GCG_log ("%s", _("Call terminated"));
- call = NULL;
- break;
- case GNUNET_CONVERSATION_EC_CALL_SUSPENDED:
- GNUNET_break (CS_CONNECTED == call_state);
- GCG_log (_("Connection to `%s' suspended (by other user)\n"),
- peer_name);
- break;
- case GNUNET_CONVERSATION_EC_CALL_RESUMED:
- GNUNET_break (CS_CONNECTED == call_state);
- GCG_log (_("Connection to `%s' resumed (by other user)\n"),
- peer_name);
- break;
- case GNUNET_CONVERSATION_EC_CALL_ERROR:
- GCG_log ("GNUNET_CONVERSATION_EC_CALL_ERROR %s",
- peer_name);
- }
- //}
+ set_outgoing_call_state (NULL, code);
+ switch (code)
+ {
+ case GNUNET_CONVERSATION_EC_CALL_RINGING:
+ GNUNET_break (CS_RESOLVING == call_state);
+ GCG_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);
+ GCG_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);
+ GCG_log (_("Failed to resolve %s in current zone."),
+ peer_name);
+ call = NULL;
+ break;
+ case GNUNET_CONVERSATION_EC_CALL_HUNG_UP:
+ GCG_log ("%s", _("Call terminated"));
+ call = NULL;
+ break;
+ case GNUNET_CONVERSATION_EC_CALL_SUSPENDED:
+ GNUNET_break (CS_CONNECTED == call_state);
+ GCG_log (_("Connection to `%s' suspended (by other user)\n"),
+ peer_name);
+ break;
+ case GNUNET_CONVERSATION_EC_CALL_RESUMED:
+ GNUNET_break (CS_CONNECTED == call_state);
+ GCG_log (_("Connection to `%s' resumed (by other user)\n"),
+ peer_name);
+ break;
+ case GNUNET_CONVERSATION_EC_CALL_ERROR:
+ GCG_log ("GNUNET_CONVERSATION_EC_CALL_ERROR %s",
+ peer_name);
+ }
}
-
/**
* Initiating a new call
*
@@ -985,6 +942,7 @@
{
GtkEntry *address_entry;
struct GNUNET_IDENTITY_Ego *caller_id;
+ GtkTreeIter gtkiter;
address_entry = GTK_ENTRY (GCG_get_main_window_object
("GNUNET_GTK_conversation_address"));
gtk_entry_set_text (address_entry,
@@ -1038,25 +996,21 @@
//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
- );
-
-
+ 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 );
GCG_update_status_bar (_("We are calling `%s', his phone should be
ringing."),
- peer_name);
+ peer_name);
GCG_HISTORY_add (CH_OUTGOING,
peer_name);
}
@@ -1071,10 +1025,9 @@
do_accept (struct GNUNET_CONVERSATION_Caller *sel_caller)
{
struct CallList *cl;
- //char buf[32];
-
- if ((NULL != call) && (CS_SUSPENDED != call_state))
+ if ( (NULL != call) &&
+ (CS_SUSPENDED != call_state) )
{
GCG_log (_("You are calling someone else already, hang up first!\n"));
GNUNET_break(0);
@@ -1097,7 +1050,7 @@
case PS_ERROR:
GNUNET_break (0);
break;
- }//endswitch
+ }
phone_state = PS_ACCEPTED;
set_incoming_call_state(sel_caller,CT_active);
@@ -1119,51 +1072,32 @@
/**
* Suspending a call
- *
- * @param args arguments given to the command
*/
static void
do_suspend ()
{
- /*
- switch (phone_state)
+ if ( (NULL != call_selected) &&
+ (NULL != caller_selected) )
{
- case PS_LOOKUP_EGO:
- case PS_LISTEN:
- case PS_ERROR:
- GCG_log ("%s", _(" There is no call that could be suspended right now.
(PS_ERROR)"));
+ GNUNET_break(0);
return;
- case PS_ACCEPTED:
- // expected state, do rejection logic
- break;
}
- */
- if (call_selected != NULL && caller_selected != NULL)
+ if (NULL != call_selected)
{
- GCG_log("this shoud not be possible");
- GNUNET_break(0);
+ /* outgoing */
+ GNUNET_CONVERSATION_call_suspend (call_selected);
+ set_outgoing_call_state(call_selected,CT_suspended);
+ return;
}
- else
+ if (NULL != caller_selected)
{
- // 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;
-
- }
+ /* incoming */
+ GNUNET_CONVERSATION_caller_suspend (caller_selected);
+ set_incoming_call_state(caller_selected,CT_suspended);
+ phone_state = PS_LISTEN;
+ return;
}
+ GNUNET_break (0);
}
@@ -1175,53 +1109,42 @@
static void
do_resume ()
{
-
- switch (phone_state)
+ switch (phone_state)
{
case PS_LOOKUP_EGO:
case PS_ERROR:
- GCG_log ("%s", _("There is no call that could be resumed right
now.(PS_ERROR)"));
+ GCG_log ("%s",
+ _("There is no call that could be resumed right now.(PS_ERROR)"));
return;
case PS_LISTEN:
break;
case PS_ACCEPTED:
GCG_log (_("Already talking with `%s', cannot resume a call right now."),
- peer_name);
+ peer_name);
return;
}
-////
- if (call_selected != NULL && caller_selected != NULL)
+ if ( (NULL != call_selected) &&
+ (NULL != caller_selected) )
{
- GCG_log("this shoud not be possible");
- GNUNET_break(0);
- return;
+ GNUNET_break(0);
+ return;
}
- else
+ if (NULL != call_selected)
{
-
- // 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);
+ /* outgoing */
+ GNUNET_CONVERSATION_call_resume (call_selected, speaker, mic);
+ set_outgoing_call_state(call_selected,CT_active);
+ return;
}
-
-//
-////
+ if (NULL != caller_selected)
+ {
+ /* incoming */
+ GNUNET_CONVERSATION_caller_resume (caller_selected, speaker, mic);
+ set_incoming_call_state(caller_selected,CT_active);
+ phone_state = PS_ACCEPTED;
+ return;
+ }
+ GNUNET_break(0);
}
@@ -1233,42 +1156,31 @@
static void
do_reject ()
{
- if (call_selected == NULL && caller_selected == NULL)
+ if ( (NULL == call_selected) &&
+ (NULL == caller_selected) )
{
GNUNET_break(0);
+ return;
}
- else
+ if (NULL != call_selected)
{
- // if selected call is outgoing, stop it
- if (NULL != call_selected)
- {
- 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;
- }
- else
- {
- // if selected call is incoming, hang it up
- if (NULL != caller_selected)
- {
- 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;
- caller_selected = NULL;
- }
- else
- {
- GNUNET_break(0);
- }
- }
+ /* if selected call is outgoing, stop it */
+ set_outgoing_call_state (call_selected, CT_hangup);
+ GNUNET_CONVERSATION_call_stop (call);
+ call = NULL;
+ call_selected = NULL;
+ return;
}
+ if (NULL != caller_selected)
+ {
+ /* if selected call is incoming, hang it up */
+ set_incoming_call_state (caller_selected,CT_hangup);
+ GNUNET_CONVERSATION_caller_hang_up (caller_selected);
+ phone_state = PS_LISTEN;
+ caller_selected = NULL;
+ return;
+ }
+ GNUNET_break (0);
}
@@ -1278,26 +1190,26 @@
void
GNUNET_CONVERSATION_GTK_on_hangup_clicked ()
{
-
do_reject ();
-
do_status ();
- //history_add(3,peer_name);
}
+
/**
* accept clicked
*/
void
GNUNET_CONVERSATION_GTK_on_accept_clicked ()
{
- if (caller_selected != NULL)
+ if (NULL != caller_selected)
{
- do_accept (caller_selected);
- } else {
- GNUNET_break(0);
+ do_accept (caller_selected);
}
- do_status();
+ else
+ {
+ GNUNET_break(0);
+ }
+ do_status ();
}
@@ -1308,7 +1220,7 @@
GNUNET_CONVERSATION_GTK_on_reject_clicked ()
{
do_reject ();
- do_status();
+ do_status ();
}
@@ -1331,7 +1243,6 @@
}
-
/**
* pause clicked
*/
@@ -1339,7 +1250,7 @@
GNUNET_CONVERSATION_GTK_on_pause_clicked ()
{
do_suspend ();
- do_status();
+ do_status ();
}
/**
@@ -1349,15 +1260,6 @@
GNUNET_CONVERSATION_GTK_on_resume_clicked ()
{
do_resume ();
- do_status();
-}
-
-/**
- * status clicked
- */
-void
-GNUNET_CONVERSATION_GTK_on_status_clicked ()
-{
do_status ();
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r33404 - gnunet-gtk/src/conversation,
gnunet <=