[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r33401 - gnunet-gtk/src/conversation
From: |
gnunet |
Subject: |
[GNUnet-SVN] r33401 - gnunet-gtk/src/conversation |
Date: |
Mon, 26 May 2014 21:13:52 +0200 |
Author: grothoff
Date: 2014-05-26 21:13:52 +0200 (Mon, 26 May 2014)
New Revision: 33401
Added:
gnunet-gtk/src/conversation/gnunet-conversation-gtk_import.c
gnunet-gtk/src/conversation/gnunet-conversation-gtk_import.h
gnunet-gtk/src/conversation/gnunet-conversation-gtk_log.c
gnunet-gtk/src/conversation/gnunet-conversation-gtk_log.h
gnunet-gtk/src/conversation/gnunet-conversation-gtk_zones.c
gnunet-gtk/src/conversation/gnunet-conversation-gtk_zones.h
Modified:
gnunet-gtk/src/conversation/Makefile.am
gnunet-gtk/src/conversation/gnunet-conversation-gtk.c
gnunet-gtk/src/conversation/gnunet-conversation-gtk.h
gnunet-gtk/src/conversation/gnunet-conversation-gtk_contacts.c
gnunet-gtk/src/conversation/gnunet-conversation-gtk_contacts.h
gnunet-gtk/src/conversation/gnunet-conversation-gtk_egos.c
gnunet-gtk/src/conversation/gnunet-conversation-gtk_egos.h
gnunet-gtk/src/conversation/gnunet-conversation-gtk_history.c
gnunet-gtk/src/conversation/gnunet-conversation-gtk_history.h
gnunet-gtk/src/conversation/gnunet-conversation-gtk_phone.c
gnunet-gtk/src/conversation/gnunet-conversation-gtk_phone.h
Log:
separating out phone, log and import logics
Modified: gnunet-gtk/src/conversation/Makefile.am
===================================================================
--- gnunet-gtk/src/conversation/Makefile.am 2014-05-26 17:23:39 UTC (rev
33400)
+++ gnunet-gtk/src/conversation/Makefile.am 2014-05-26 19:13:52 UTC (rev
33401)
@@ -14,14 +14,20 @@
gnunet_conversation_gtk_SOURCES = \
gnunet-conversation-gtk.c \
gnunet-conversation-gtk.h \
- gnunet-conversation-gtk_phone.c \
- gnunet-conversation-gtk_phone.h \
gnunet-conversation-gtk_egos.c \
gnunet-conversation-gtk_egos.h \
gnunet-conversation-gtk_contacts.c \
gnunet-conversation-gtk_contacts.h \
gnunet-conversation-gtk_history.c \
gnunet-conversation-gtk_history.h \
+ gnunet-conversation-gtk_import.c \
+ gnunet-conversation-gtk_import.h \
+ gnunet-conversation-gtk_log.c \
+ gnunet-conversation-gtk_log.h \
+ gnunet-conversation-gtk_phone.c \
+ gnunet-conversation-gtk_phone.h \
+ gnunet-conversation-gtk_zones.c \
+ gnunet-conversation-gtk_zones.h \
gnunet-conversation-gtk_about.c
gnunet_conversation_gtk_LDADD = \
Modified: gnunet-gtk/src/conversation/gnunet-conversation-gtk.c
===================================================================
--- gnunet-gtk/src/conversation/gnunet-conversation-gtk.c 2014-05-26
17:23:39 UTC (rev 33400)
+++ gnunet-gtk/src/conversation/gnunet-conversation-gtk.c 2014-05-26
19:13:52 UTC (rev 33401)
@@ -1,6 +1,6 @@
/*
This file is part of GNUnet.
- (C) 2010-2013 Christian Grothoff (and other contributing authors)
+ (C) 2010-2014 Christian Grothoff (and other contributing authors)
GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
@@ -23,202 +23,41 @@
* @brief Main function of gnunet-conversation-gtk
* @author yids
* @author hark
+ * @author Christian Grothoff
*/
#include "gnunet-conversation-gtk.h"
-#include "gnunet-conversation-gtk_history.h"
#include "gnunet-conversation-gtk_contacts.h"
#include "gnunet-conversation-gtk_egos.h"
+#include "gnunet-conversation-gtk_history.h"
+#include "gnunet-conversation-gtk_import.h"
+#include "gnunet-conversation-gtk_phone.h"
-
/**
- * List of incoming calls
- */
-struct CallList
-{
-
- /**
- * A DLL.
- */
- struct CallList *prev;
-
- /**
- * A DLL.
- */
- struct CallList *next;
-
- /**
- * Handle to hang up or activate.
- */
- struct GNUNET_CONVERSATION_Caller *caller;
-
- /**
- * Handle to call currently selected in list
- */
- struct GNUNET_CONVERSATION_Caller *caller_selected;
-
- /**
- * String identifying the caller.
- */
- char *caller_id;
-
- /**
- * Unique number of the caller.
- */
- unsigned int caller_num;
-
-};
-
-
-/**
- *
- */
-static struct GNUNET_CONVERSATION_Caller *caller_selected;
-
-/**
- *
- */
-static struct GNUNET_CONVERSATION_Call *call_selected;
-
-/**
* Handle to our main loop.
*/
static struct GNUNET_GTK_MainLoop *ml;
/**
- * Our configurations.
+ * Our configuration.
*/
static struct GNUNET_CONFIGURATION_Handle *cfg;
/**
- * Name of our ego.
+ * Should gnunet-conversation-gtk start in tray mode?
*/
-static char *ego_name;
-
-/**
- * Be verbose.
- */
-static int verbose = 1;
-
-/**
- * Should gnunet-identity-gtk start in tray mode?
- */
static int tray_only;
/**
- * List of active calls
- */
-static GtkListStore *active_liststore;
-
-/**
- * List of active calls
- */
-static GtkTreeView *active_treeview;
-
-/**
- * Unique number of call (outgoing)
- */
-static unsigned int call_counter;
-
-/**
- * Phone handle
- */
-static struct GNUNET_CONVERSATION_Phone *phone;
-
-/**
- * Call handle (for active outgoing call).
- */
-static struct GNUNET_CONVERSATION_Call *call;
-
-/**
- * Caller handle (for active incoming call).
- */
-static struct CallList *cl_active;
-
-/**
- * Head of calls waiting to be accepted.
- */
-static struct CallList *cl_head;
-
-/**
- * Tail of calls waiting to be accepted.
- */
-static struct CallList *cl_tail;
-
-/**
* Desired phone line.
*/
static unsigned int line;
/**
- * debug box enabled
+ * Ego the user wants to use.
*/
-static unsigned int debug_box_enabled;
+static char *ego_name;
/**
- * Our speaker.
- */
-static struct GNUNET_SPEAKER_Handle *speaker;
-
-/**
- * Our microphone.
- */
-static struct GNUNET_MICROPHONE_Handle *mic;
-
-/**
- * Name of conversation partner (if any).
- */
-static char *peer_name;
-
-/**
- * Our phone's current state.
- */
-static enum PhoneState phone_state;
-
-/**
- * Our call's current state.
- */
-static enum CallState call_state;
-
-/**
- * Counts the number of incoming calls we have had so far.
- */
-static unsigned int caller_num_gen;
-
-/**
- * GNS address for this phone.
- */
-static char *address;
-
-static GtkWidget *b_contact;
-
-static GtkWidget *b_accept;
-
-static GtkWidget *b_hangup;
-
-static GtkWidget *b_suspend;
-
-static GtkWidget *b_resume;
-
-/**
- * list of zones
- */
-static GtkListStore *zone_liststore;
-
-/**
- * Our ego.
- */
-static struct GNUNET_IDENTITY_Ego *caller_id;
-
-
-void
-GNUNET_CONVERSATION_GTK_on_active_calls_selection_changed (void);
-
-
-static void
-set_status_icon (const char *icon_name);
-
-
-/**
* Get an object from the main window.
*
* @param name name of the object
@@ -232,343 +71,9 @@
/**
- * log a message to gtk log textbuffer
+ * Updates the status icon to the image of the given name.
+ * TODO: support animations.
*
- * @param message format string for message to be logged
- * @param ... arguments for the format string
- */
-void
-GCG_log (const char *message,
- ...)
-{
- GtkTextBuffer *logbuff;
- GtkTextView *log_view;
- GtkTextIter iter;
- gchar *fmsg;
- va_list ap;
-
- log_view = GTK_TEXT_VIEW (GCG_get_main_window_object
("GNUNET_GTK_conversation_log"));
- logbuff = GTK_TEXT_BUFFER (gtk_text_view_get_buffer (log_view));
- va_start (ap, message);
- fmsg = g_strdup_vprintf (message,
- ap);
- va_end (ap);
- gtk_text_buffer_get_start_iter (logbuff,
- &iter);
- gtk_text_buffer_insert (logbuff,
- &iter,
- fmsg,
- -1);
- g_free (fmsg);
-}
-
-
-/**
- * update status bar
- *
- * @param message format string for message to put in statusbar
- * @param ... arguments for the format string
- */
-void
-GCG_update_status (const gchar *message,
- ...)
-{
- GtkStatusbar *status_bar;
- guint status_bar_context;
- gchar *buff;
- va_list ap;
-
- status_bar = GTK_STATUSBAR (GCG_get_main_window_object
("GNUNET_GTK_conversation_statusbar"));
- status_bar_context = gtk_statusbar_get_context_id (status_bar, "blaat");
- va_start (ap, message);
- buff = g_strdup_vprintf (message,
- ap);
- va_end (ap);
- 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 (); // FIXME: why
do this here?
-}
-
-
-/**
- * update status based on current phone state.
- *
- * @param args arguments given to the command
- */
-static void
-do_status ()
-{
- switch (phone_state)
- {
- case PS_LOOKUP_EGO:
- GCG_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:
- GCG_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:
- GCG_update_status (_("You are having a conversation with `%s'.\n"),
- peer_name);
- set_status_icon ("gnunet-conversation-call-active");
- break;
- case PS_ERROR:
- GCG_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:
- GCG_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:
- GCG_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:
- GCG_update_status (_("You are having a conversation with `%s'."),
- peer_name);
- set_status_icon ("gnunet-conversation-gtk-tray-call-active");
- break;
- case CS_SUSPENDED:
- GCG_update_status (_("Conversation suspended, you can accept or initiate
another call now."),
- peer_name);
- set_status_icon ("gnunet-conversation-gtk-tray-call-suspended");
- break;
- }
- }
- if ( ( (NULL == call) ||
- (CS_SUSPENDED == call_state) ) &&
- (NULL != cl_head) &&
- ( (cl_head != cl_active) ||
- (cl_head != cl_tail) ) )
- set_status_icon ("gnunet-conversation-gtk-tray-call-incoming");
-}
-
-
-/**
- * @brief print info for currently selected call
- */
-static void
-print_call_info ()
-{
- GtkTreeIter gtkiter;
- gboolean valid;
- gint row_count = 0;
-
- valid = gtk_tree_model_get_iter_first (GTK_TREE_MODEL (active_liststore),
- >kiter);
- if (! valid)
- GNUNET_break(0);
-
- while (valid)
- {
- 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,
- AL_call, &cl_call,
- -1);
- if (call_selected == cl_call)
- {
- GCG_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);
- }
-}
-
-
-/**
- * @brief sets caller_selected, and enables or disables the active call list
buttons
- */
-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 =
GCG_get_main_window_object(ml,"GNUNET_CONVERSATION_GTK_active_calls_selection");
-
- // reset references to selected call/caller
- //caller_selected = NULL;
- //call_selected = NULL;
- GCG_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))
- {
- // 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);
- // check if selected call is a incoming or outgoing call
- switch (cl_type)
- {
- case CALL_IN:
- call_selected = NULL;
- caller_selected = cl_caller;
- GNUNET_break (NULL != caller_selected);
- break;
- case CALL_OUT:
- caller_selected = NULL;
- call_selected = cl_call;
- GCG_log("outgoing selected");
- GNUNET_break (NULL != call_selected);
- break;
- default:
- GNUNET_break(0);
- break;
- }
-
gtk_widget_show(GTK_WIDGET(GCG_get_main_window_object("GNUNET_GTK_conversation_active_call_list_buttons")));
- GCG_log("caller state: %u phone_state: %u",
- cl_caller_state,
- phone_state);
- switch (cl_caller_state)
- {
- /* buttons:
- * contact
- * accept
- * hangup
- * suspend
- * resume
- *
- * TODO: check if there is incoming or outgoing call,
- * disable resume and accept buttons.
- * or suspend that other call
- */
- case CT_active:
- // hangup, pause
- //GCG_log("CT_active state: %u ",cl_caller_state);
- gtk_widget_set_sensitive (b_contact, TRUE);
- gtk_widget_set_sensitive (b_accept, FALSE);
- gtk_widget_set_sensitive (b_hangup, TRUE);
- gtk_widget_set_sensitive (b_suspend, TRUE);
- gtk_widget_set_sensitive (b_resume, FALSE);
- break;
- case CT_ringing:
- // pickup, phonebook
- //GCG_log("CT_ring show button");
- gtk_widget_set_sensitive (b_contact, TRUE);
- if (phone_state == PS_LISTEN)
- {
- gtk_widget_set_sensitive (b_accept, TRUE);
- }
- else
- {
- gtk_widget_set_sensitive (b_accept, FALSE);
- }
- gtk_widget_set_sensitive (b_hangup, FALSE);
- gtk_widget_set_sensitive (b_suspend, FALSE);
- gtk_widget_set_sensitive (b_resume, FALSE);
- break;
- case CT_rejected:
- //add to phonebook
- //GCG_log("CT_rejected ");
- gtk_widget_set_sensitive (b_contact, TRUE);
- gtk_widget_set_sensitive (b_accept, FALSE);
- gtk_widget_set_sensitive (b_hangup, FALSE);
- gtk_widget_set_sensitive (b_suspend, FALSE);
- gtk_widget_set_sensitive (b_resume, FALSE);
- break;
- case CT_suspended:
- // resume, hangup
- //GCG_log("CT_suspended ");
- gtk_widget_set_sensitive (b_contact, TRUE);
- gtk_widget_set_sensitive (b_accept, FALSE);
- gtk_widget_set_sensitive (b_hangup, TRUE);
- gtk_widget_set_sensitive (b_suspend, FALSE);
- if (phone_state == PS_LISTEN)
- {
- GCG_log("enable resume button");
- gtk_widget_set_sensitive (b_resume, TRUE);
- }
- else
- {
- GCG_log("do not disable resume button (for test)");
- gtk_widget_set_sensitive (b_resume, TRUE);
- }
- break;
- case CT_other:
- //add to phonebook
- //GCG_log("CT_rejected ");
- gtk_widget_set_sensitive (b_contact, TRUE);
- gtk_widget_set_sensitive (b_accept, TRUE);
- gtk_widget_set_sensitive (b_hangup, TRUE);
- gtk_widget_set_sensitive (b_suspend, TRUE);
- gtk_widget_set_sensitive (b_resume, TRUE);
- break;
-
- default:
- GNUNET_break(0);
- break;
- }
- print_call_info();
- }
- else
- {
- GCG_log("nothing selected");
-
//gtk_widget_hide(GTK_WIDGET(GCG_get_main_window_object("GNUNET_GTK_conversation_active_call_list_buttons"
)));
- }
-}
-
-
-/**
- * @brief executed when selecting a different item in active call list
- */
-void
-GNUNET_CONVERSATION_GTK_on_active_calls_selection_changed()
-{
- update_active_call_list_buttons();
-}
-
-
-void
-disable_list_buttons()
-{
- gtk_widget_set_sensitive (b_contact, FALSE);
- gtk_widget_set_sensitive (b_accept, FALSE);
- gtk_widget_set_sensitive (b_hangup, FALSE);
- gtk_widget_set_sensitive (b_suspend, FALSE);
- gtk_widget_set_sensitive (b_resume, FALSE);
-}
-
-
-/**
- * set_status_icon
- *
* available icons:
* gnunet-conversation-gtk-tray-pending
* gnunet-conversation-gtk-tray-available
@@ -579,13 +84,15 @@
* gnunet-conversation-gtk-tray-call-suspended
* gnunet-conversation-gtk-tray-call-incoming
*
+ * @param icon_name name of the icon to use
*/
void
-set_status_icon (const char *icon_name)
+GCG_set_status_icon (const char *icon_name)
{
GtkImage *status_icon;
- status_icon = GTK_IMAGE (GCG_get_main_window_object
("GNUNET_GTK_status_icon"));
+ status_icon = GTK_IMAGE (GCG_get_main_window_object
+ ("GNUNET_GTK_status_icon"));
gtk_image_set_from_icon_name (status_icon,
icon_name,
GTK_ICON_SIZE_BUTTON);
@@ -595,768 +102,6 @@
/**
- * set button text
- *
- * @param button_name name of button
- * @param label label on the button
- */
-void
-set_button_text (const char *button_name,
- const char *label)
-{
- GtkWidget *button;
-
- button = GTK_WIDGET (GCG_get_main_window_object (button_name));
- gtk_widget_hide (button);
-}
-
-
-/**
- * disable button
- */
-void
-disable_button (const char *button_name)
-{
- GtkWidget *button;
-
- button = GTK_WIDGET (GCG_get_main_window_object (button_name));
- gtk_widget_hide (button);
-}
-
-
-/**
- * enable button
- */
-void
-enable_button (const char *button_name)
-{
- //GtkButton *button;
- GtkWidget *button;
-
- button = GTK_WIDGET (GCG_get_main_window_object (button_name));
- gtk_widget_show (button);
-}
-
-
-/**
- * set state of outgoing call
- */
-void
-set_outgoing_call_state (struct GNUNET_CONVERSATION_Call *call,
- int state)
-{
- GtkTreeIter gtkiter;
- 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);
-
- 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
- {
- GCG_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
- {
- //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
- }//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 ("");
-}
-
-
-/**
- * set call state of a incoming call
- */
-static void
-set_incoming_call_state (struct GNUNET_CONVERSATION_Caller *caller,
- int state)
-{
- 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;
-
- 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)
- {
- //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("");
-}
-
-
-/**
- * Function called with an event emitted by a phone.
- *
- * @param cls closure
- * @param code type of the event
- * @param caller handle for the caller
- * @param caller_id name of the caller in GNS
- */
-static void
-phone_event_handler (void *cls,
- enum GNUNET_CONVERSATION_PhoneEventCode code,
- struct GNUNET_CONVERSATION_Caller *caller,
- const char *caller_id)
-{
- GtkTreeIter gtkiter;
- GtkTreeIter gtkiter1;
- gboolean valid;
-
- 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,
- AL_caller_id, caller_id,
- AL_caller, caller,
- AL_caller_num, caller_num_gen,
- AL_caller_state, CT_ringing,
- 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);
-
- 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,
- AL_caller, &cl_caller,
- 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 ;
- }
- 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();
-}
-
-
-/**
- * Function called with an event emitted by a caller.
- *
- * @param cls closure with the `struct CallList` of the caller
- * @param code type of the event issued by the caller
- */
-static void
-caller_event_handler (void *cls,
- enum GNUNET_CONVERSATION_CallerEventCode code)
-{
-
- if (cls == NULL)
- {
- GCG_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);
- 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.
- */
-static void
-start_phone ()
-{
- struct GNUNET_GNSRECORD_Data rd;
- GtkLabel *label;
- if (NULL == caller_id)
- {
- GCG_log (_("Ego `%s' no longer available, phone is now down.\n"),
ego_name);
- phone_state = PS_LOOKUP_EGO;
- return;
- }
- //GNUNET_assert (NULL == phone);
- phone =
- GNUNET_CONVERSATION_phone_create (cfg, caller_id, &phone_event_handler,
- NULL);
- /* FIXME: get record and print full GNS record info later here... */
- if (NULL == phone)
- {
- GCG_log ("%s", _("Failed to setup phone (internal error)\n"));
- phone_state = PS_ERROR;
- }
- else
- {
- GNUNET_CONVERSATION_phone_get_record (phone, &rd);
- GNUNET_free_non_null (address);
- address =
- GNUNET_GNSRECORD_value_to_string (rd.record_type, rd.data,
- rd.data_size);
-
- GCG_log (_("address: `%s' \n"), address);
-
- label =
GTK_LABEL(GCG_get_main_window_object("GNUNET_CONVERSATION_GTK_my_address"));
- gtk_label_set_text(label, address);
-
- if (verbose)
- GCG_log (_("Phone active on line %u\n"),
- (unsigned int) line);
- phone_state = PS_LISTEN;
- }
- do_status();
-}
-
-
-/**
- * Function called with an event emitted by a call.
- *
- * @param cls closure, NULL
- * @param code type of the event on the call
- */
-static void
-call_event_handler (void *cls,
- enum GNUNET_CONVERSATION_CallEventCode code)
-{
- //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 ego `%s'"), peer_name, ego_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
- *
- * @param arg arguments given to the command
- */
-void
-GSC_do_call (const char *arg)
-{
- GtkEntry *address_entry;
-
- address_entry = GTK_ENTRY (GCG_get_main_window_object
("GNUNET_GTK_conversation_address"));
- gtk_entry_set_text (address_entry,
- address);
-
- if (NULL == caller_id)
- {
- GCG_log (_("Ego `%s' not available\n"), ego_name);
- return;
- }
- if (NULL != call)
- {
- GCG_log (_("You are calling someone else already, hang up first!\n"));
- return;
- }
- switch (phone_state)
- {
- case PS_LOOKUP_EGO:
- GCG_log (_("Ego `%s' not available\n"), ego_name);
- return;
- case PS_LISTEN:
- /* ok to call! */
- break;
- case PS_ACCEPTED:
- GCG_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 */
- break;
- }
- //GNUNET_free_non_null (peer_name);
- peer_name = GNUNET_strdup (arg);
- GCG_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 = 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
- );
-
-
- GCG_update_status (_("We are calling `%s', his phone should be ringing."),
- peer_name);
- GNUNET_CONVERSATION_GTK_history_add (CH_OUTGOING, peer_name);
-}
-
-
-/**
- * Accepting an incoming call
- *
- * @param args arguments given to the command
- */
-static void
-do_accept (struct GNUNET_CONVERSATION_Caller *sel_caller)
-{
- struct CallList *cl;
- //char buf[32];
-
-
- if ((NULL != call) && (CS_SUSPENDED != call_state))
- {
- GCG_log (_("You are calling someone else already, hang up first!\n"));
- GNUNET_break(0);
- return;
- }
- switch (phone_state)
- {
- case PS_LOOKUP_EGO:
- GNUNET_break (0);
- break;
- case PS_LISTEN:
- /* this is the expected state */
- break;
- case PS_ACCEPTED:
- GCG_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
-
- phone_state = PS_ACCEPTED;
- set_incoming_call_state(sel_caller,CT_active);
-
- for (cl = cl_head; cl; cl = cl->next)
- {
- /* FIXME: this may not be unique enough to identify the right item!
- * Why not store CallList items in treeview instead of just callers?
- */
- if (cl->caller == sel_caller)
- break;
- }
- GNUNET_CONVERSATION_caller_pick_up (sel_caller, &caller_event_handler, cl,
- speaker, mic);
-
- GNUNET_CONVERSATION_GTK_history_add (CH_ACCEPTED, peer_name);
-
-}
-
-
-/**
- * Suspending a call
- *
- * @param args arguments given to the command
- */
-static void
-do_suspend ()
-{
- /*
- switch (phone_state)
- {
- 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)"));
- return;
- case PS_ACCEPTED:
- // expected state, do rejection logic
- break;
- }
- */
- if (call_selected != NULL && caller_selected != NULL)
- {
- GCG_log("this shoud not be possible");
- GNUNET_break(0);
- }
- else
- {
- // 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;
-
- }
- }
-}
-
-
-/**
- * Resuming a call
- *
- * @param args arguments given to the command
- */
-static void
-do_resume ()
-{
-
- 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)"));
- return;
- case PS_LISTEN:
- break;
- case PS_ACCEPTED:
- GCG_log (_("Already talking with `%s', cannot resume a call right now."),
- peer_name);
- return;
- }
-////
- if (call_selected != NULL && caller_selected != NULL)
- {
- GCG_log("this shoud not be possible");
- GNUNET_break(0);
- return;
- }
- else
- {
-
- // 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);
- }
-
-//
-////
-}
-
-
-/**
- / Rejecting a call
- *
- * @param args arguments given to the command
- */
-static void
-do_reject ()
-{
- if (call_selected == NULL && caller_selected == NULL)
- {
- GNUNET_break(0);
- }
- else
- {
- // 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);
- }
- }
- }
-}
-
-
-/**
* Get our configuration.
*
* @return configuration handle
@@ -1364,7 +109,6 @@
const struct GNUNET_CONFIGURATION_Handle *
GCG_get_configuration ()
{
- /* FIXME: Configuration handle returned is const, but we DO alter the config
*/
return GNUNET_GTK_main_loop_get_configuration (ml);
}
@@ -1379,25 +123,10 @@
shutdown_task (void *cls,
const struct GNUNET_SCHEDULER_TaskContext *tc)
{
-
-//TODO: make this work
- //struct OperationContext *oc;
-
-/*
- GCG_advertise_shutdown_ ();
- while (NULL != (oc = oc_head))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- _("Operation not completed due to shutdown\n"));
- GNUNET_IDENTITY_cancel (oc->op);
- GNUNET_CONTAINER_DLL_remove (oc_head,
- oc_tail,
- oc);
- GNUNET_free (oc);
- }
- */
- GCG_CONTACTS_shutdown();
- GCG_EGOS_shutdown();
+ GCG_PHONE_shutdown ();
+ GCG_CONTACTS_shutdown ();
+ GCG_IMPORT_shutdown ();
+ GCG_EGOS_shutdown ();
GNUNET_GTK_tray_icon_destroy ();
GNUNET_GTK_main_loop_quit (ml);
ml = NULL;
@@ -1414,23 +143,6 @@
GNUNET_GTK_conversation_quit_cb (GObject *object,
gpointer user_data)
{
- if (NULL != call)
- {
- GNUNET_CONVERSATION_call_stop (call);
- call = NULL;
- }
- if (NULL != phone)
- {
- GNUNET_CONVERSATION_phone_destroy (phone);
- phone = NULL;
- }
- GNUNET_SPEAKER_destroy (speaker);
- speaker = NULL;
- GNUNET_MICROPHONE_destroy (mic);
- mic = NULL;
- ego_name = NULL;
- //GNUNET_free_non_null (peer_name);
- phone_state = PS_ERROR;
GNUNET_SCHEDULER_shutdown ();
}
@@ -1454,32 +166,24 @@
GNUNET_GTK_set_icon_search_path ();
GNUNET_GTK_setup_nls ();
/* setup main window */
- main_window = GTK_WINDOW (GCG_get_main_window_object
("GNUNET_GTK_conversation_window"));
+ main_window = GTK_WINDOW (GCG_get_main_window_object
+ ("gnunet_conversation_gtk_main_window"));
main_window =
GTK_WINDOW (GNUNET_GTK_plug_me
("GNUNET_CONVERSATION_GTK_PLUG",
GTK_WIDGET (main_window)));
- // active calls
- active_liststore =
- GTK_LIST_STORE (GCG_get_main_window_object
("gnunet_conversation_gtk_active_calls_liststore"));
- active_treeview =
- GTK_TREE_VIEW (GCG_get_main_window_object
("gnunet_conversation_gtk_active_calls_treeview"));
-
if (NULL == getenv ("GNUNET_CONVERSATION_GTK_PLUG"))
GNUNET_GTK_tray_icon_create (ml, GTK_WINDOW (main_window),
"gnunet-conversation-gtk"
/* FIXME: different icon? */ ,
"gnunet-conversation-gtk");
/* make GUI visible */
- if (!tray_only)
+ if (! tray_only)
{
gtk_widget_show (GTK_WIDGET (main_window));
gtk_window_present (GTK_WINDOW (main_window));
}
- /* get gui objects */
- if (debug_box_enabled)
- gtk_widget_show (GTK_WIDGET (GCG_get_main_window_object
("GNUNET_CONVERSATION_log_box")));
GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
&shutdown_task,
NULL);
@@ -1489,20 +193,18 @@
"CONVERSATION",
"LINE",
line);
- speaker = GNUNET_SPEAKER_create_from_hardware (cfg);
- mic = GNUNET_MICROPHONE_create_from_hardware (cfg);
- b_contact = GTK_WIDGET (GCG_get_main_window_object
("GNUNET_GTK_conversation_use_current_button"));
- b_accept = GTK_WIDGET (GCG_get_main_window_object
("GNUNET_GTK_conversation_accept_button"));
- b_hangup = GTK_WIDGET (GCG_get_main_window_object
("GNUNET_GTK_conversation_hangup_button"));
- b_suspend = GTK_WIDGET (GCG_get_main_window_object
("GNUNET_GTK_conversation_suspend_button"));
- b_resume = GTK_WIDGET (GCG_get_main_window_object
("GNUNET_GTK_conversation_resume_button"));
if (NULL == ego_name)
+ ego_name = GNUNET_strdup ("phone-ego");
+ GCG_HISTORY_init ();
+ GCG_EGOS_init (ego_name);
+ GCG_IMPORT_init ();
+ GCG_CONTACTS_init ();
+ GCG_PHONE_init ();
+ if (NULL != ego_name)
{
- ego_name = "phone-ego";
- GCG_log (_("No ego given, using default: %s "), ego_name);
+ GNUNET_free (ego_name);
+ ego_name = NULL;
}
- GCG_EGOS_init ();
- GCG_CONTACTS_init ();
}
@@ -1523,9 +225,6 @@
{'e', "ego", "ego",
gettext_noop ("select ego to use"), 1,
&GNUNET_GETOPT_set_string, &ego_name},
- {'d', "debug_box", "1 or 0",
- gettext_noop ("enable debug box"), 1,
- &GNUNET_GETOPT_set_uint, &debug_box_enabled},
{'t', "tray", NULL,
gettext_noop ("start in tray mode"), 0,
&GNUNET_GETOPT_set_one, &tray_only},
@@ -1552,247 +251,4 @@
}
-/**
- * call clicked
- */
-void
-GNUNET_CONVERSATION_GTK_on_call_clicked ()
-{
- GtkEntry *address_entry;
-
- address_entry = GTK_ENTRY (GCG_get_main_window_object
("GNUNET_GTK_conversation_address"));
-
- GSC_do_call (gtk_entry_get_text(address_entry));
- //disable_button ("GNUNET_GTK_conversation_accept_button");
- do_status ();
-// free(to_addr);
-}
-
-/**
- * hangup clicked
- */
-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)
- {
- do_accept (caller_selected);
- } else {
- GNUNET_break(0);
- }
- do_status();
-}
-
-
-/**
- * reject clicked
- */
-void
-GNUNET_CONVERSATION_GTK_on_reject_clicked ()
-{
- do_reject ();
- do_status();
-}
-
-/**
- * pause clicked
- */
-void
-GNUNET_CONVERSATION_GTK_on_pause_clicked ()
-{
- do_suspend ();
- do_status();
-}
-
-/**
- * resume clicked
- */
-void
-GNUNET_CONVERSATION_GTK_on_resume_clicked ()
-{
- do_resume ();
- do_status();
-}
-
-/**
- * status clicked
- */
-void
-GNUNET_CONVERSATION_GTK_on_status_clicked ()
-{
- do_status ();
-}
-
-/*
- * test function
- */
-void
-GNUNET_contact_test ()
-{
- GtkTreeIter iter;
- char *caller_id = "testje";
- int caller_num = 10;
-
-enum {
- AL_caller_id, // *gchar
- AL_caller, // *
- AL_caller_num //gint
-};
-
- gtk_list_store_append (active_liststore, &iter);
- gtk_list_store_set (active_liststore, &iter, 2, caller_num, 0, caller_id,
-1);
-
- gtk_list_store_insert_with_values (zone_liststore,
- &iter, -1,
- 0, "test",
- -1);
-}
-
-/*
- * @brief outgoing ego selector changed
- */
-void
-gnunet_conversation_gtk_outgoing_zone_combobox_changed_cb (GtkComboBox *widget,
- gpointer user_data)
-{
- GtkTreeIter iter;
- struct GNUNET_IDENTITY_Ego *tempEgo;
- char *tempName;
- //struct GNUNET_CRYPTO_EcdsaPrivateKey temp_zone_pkey;
- //GtkTreeSelection *selection;
-
-
- gtk_combo_box_get_active_iter(widget, &iter);
-
- gtk_tree_model_get (GTK_TREE_MODEL (zone_liststore),
- &iter,
- 0, &tempName,
- 1, &tempEgo,
- -1);
- //GCG_log(stderr,"outgoing ego: %s", tempName);
- // caller_id = tempEgo;
- /*
- if ( NULL != phone)
- {
- GNUNET_CONVERSATION_phone_destroy (phone);
- phone == NULL;
- }
- start_phone();
- */
-}
-
-/*
- * @brief active call list type data function
- */
-void
-active_calls_type_data_function (GtkTreeViewColumn *col,
- GtkCellRenderer *renderer,
- GtkTreeModel *model,
- GtkTreeIter *iter,
- gpointer user_data)
- {
- gint state;
- gchar buf[20];
-
- gtk_tree_model_get(model, iter, AL_caller_state, &state, -1);
- g_snprintf(buf, sizeof(buf), "status %u", state);
- g_object_set(renderer, "text", buf, NULL);
- /* set 'cell-background' property of the cell renderer */
-
- switch (state)
- {
- case CT_active:
- g_object_set(renderer,
- "cell-background", "Green",
- "cell-background-set", TRUE,
- NULL);
-
-
- break;
- case CT_ringing:
- g_object_set(renderer,
- "cell-background", "Blue",
- "cell-background-set", TRUE,
- NULL);
-
-
- break;
- case CT_rejected:
-
- break;
- case CT_suspended:
- g_object_set(renderer,
- "cell-background", "Orange",
- "cell-background-set", TRUE,
- NULL);
-
-
- break;
- default:
- GNUNET_break(0);
- break;
- }
-
- //gtk_tree_model_get(model, iter, AL_caller_state, &state, -1);
-
- //g_snprintf(buf, sizeof(buf), "state: %u", state);
-
- //g_object_set(renderer, "text", buf, NULL);
- //
-// if (foo->is_important)
- g_object_set(renderer, "markup", "<b>important</b>", "text", NULL,
NULL);
-// else
-// g_object_set(renderer, "markup", NULL, "text", "not important",
NULL);
- //
- }
-
-
-/**
- * @brief second test button
- */
-void
-GNUNET_CONVERSATION_GTK_test_button_two()
-{
- GtkTreeViewColumn *column;
-// GtkCellRenderer *cell;
- GtkCellRenderer *renderer;
- //GCG_log("test");
-// treeview =
GCG_get_main_window_object(ml,"gnunet_conversation_gtk_active_calls_treeview");
-
-// column =
GCG_get_main_window_object(ml,"GNUNET_CONVERSATION_GTK_caller_typeColumn");
- //cell = gtk_cell_renderer_text_new();
-// cell =
GCG_get_main_window_object(ml,"GNUNET_CONVERSATION_GTK_active_calls_type");
-// gtk_tree_view_column_set_cell_data_func(column, cell,
active_calls_type_data_function, NULL, NULL );
-
- column =
GTK_TREE_VIEW_COLUMN(GCG_get_main_window_object("caller_testcolumn"));
- gtk_tree_view_column_set_title(column, "test stateC");
- renderer = gtk_cell_renderer_text_new();
-
- /* pack cell renderer into tree view column */
- gtk_tree_view_column_pack_start(column, renderer, TRUE);
-
- /* set 'text' property of the cell renderer */
- g_object_set(renderer, "text", "Boooo!", NULL);
- /* set 'cell-background' property of the cell renderer */
- g_object_set(renderer,
- "cell-background", "Orange",
- "cell-background-set", TRUE,
- NULL);
- gtk_tree_view_column_add_attribute(column, renderer, "text",
AL_caller_state);
- gtk_tree_view_column_set_cell_data_func(column, renderer,
active_calls_type_data_function, NULL, NULL );
-}
-
/* end of gnunet-conversation-gtk.c */
Modified: gnunet-gtk/src/conversation/gnunet-conversation-gtk.h
===================================================================
--- gnunet-gtk/src/conversation/gnunet-conversation-gtk.h 2014-05-26
17:23:39 UTC (rev 33400)
+++ gnunet-gtk/src/conversation/gnunet-conversation-gtk.h 2014-05-26
19:13:52 UTC (rev 33401)
@@ -28,6 +28,7 @@
#include <stdbool.h>
#include <stdint.h>
#include "gnunet_gtk.h"
+#include <gnunet/gnunet_dnsparser_lib.h>
#include <gnunet/gnunet_identity_service.h>
#include <gnunet/gnunet_namestore_service.h>
#include <gnunet/gnunet_conversation_service.h>
@@ -39,116 +40,11 @@
/**
- * active calls treeview columns
- */
-enum ActiveCallsTreeViewColumns
-{
- AL_caller_id, //*gchar
- AL_caller, //*
- AL_caller_num, //gint
- AL_type, //gint
- AL_caller_state, //gint
- AL_call, //*
- AL_call_state, //gint
- AL_call_num //gint
-};
-
-
-/**
- * callerstate (state of incoming call)
- */
-enum CallerState
-{
- CT_active,
- CT_suspended,
- CT_ringing,
- CT_dead,
- CT_hangup,
- CT_rejected,
- CT_other
-};
-
-
-/**
- * type of call
- */
-enum TypeOfCall
-{
- CALL_IN,
- CALL_OUT
-};
-
-
-/**
- * Possible states of the phone.
- */
-enum PhoneState
-{
- /**
- * We're waiting for our own idenitty.
- */
- PS_LOOKUP_EGO,
-
- /**
- * We're listening for calls
- */
- PS_LISTEN,
-
- /**
- * We accepted an incoming phone call.
- */
- PS_ACCEPTED,
-
- /**
- * Internal error
- */
- PS_ERROR
-};
-
-
-/**
- * States for current outgoing call.
- */
-enum CallState
-{
- /**
- * We are looking up some other participant.
- */
- CS_RESOLVING,
-
- /**
- * We are now ringing the other participant.
- */
- CS_RINGING,
-
- /**
- * The other party accepted our call and we are now connected.
- */
- CS_CONNECTED,
-
- /**
- * The call is currently suspended (by us).
- */
- CS_SUSPENDED
-};
-
-
-enum CallHistoryType
-{
- CH_ACCEPTED,
- CH_REJECTED,
- CH_OUTGOING,
- CH_HANGUP,
- CH_MISSED
-};
-
-
-/**
* Get our configuration.
*
* @return configuration handle
*/
-extern const struct GNUNET_CONFIGURATION_Handle *
+const struct GNUNET_CONFIGURATION_Handle *
GCG_get_configuration (void);
@@ -158,8 +54,8 @@
* @param name name of the object
* @return NULL on error
*/
-extern GObject *
-GCG_get_main_window_object (const char *);
+GObject *
+GCG_get_main_window_object (const char *name);
/**
@@ -173,28 +69,24 @@
...);
-#define UPDATE_INFOBAR(format, ...) set_infobar_text(g_strdup_printf (format,
## __VA_ARGS__))
-
-
/**
* log a message to gtk log textbuffer
*
* @param message format string for message to be logged
* @param ... arguments for the format string
*/
-extern void
+void
GCG_log (const char *message,
...);
/**
- * Initiate a call to the given address.
+ * Updates the status icon to the image of the given name.
*
- * @param address address to call
+ * @param icon_name name of the icon to use
*/
-extern void
-GSC_do_call (const char *address);
+void
+GCG_set_status_icon (const char *icon_name);
-
#endif
Modified: gnunet-gtk/src/conversation/gnunet-conversation-gtk_contacts.c
===================================================================
--- gnunet-gtk/src/conversation/gnunet-conversation-gtk_contacts.c
2014-05-26 17:23:39 UTC (rev 33400)
+++ gnunet-gtk/src/conversation/gnunet-conversation-gtk_contacts.c
2014-05-26 19:13:52 UTC (rev 33401)
@@ -1,6 +1,6 @@
/*
This file is part of GNUnet.
- (C) 2010-2013 Christian Grothoff (and other contributing authors)
+ (C) 2010-2014 Christian Grothoff (and other contributing authors)
GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
@@ -20,9 +20,11 @@
/**
* @file src/conversation/gnunet-conversation-gtk_contacts.c
- * @brief
+ * @brief display the address book with the list of known contacts
+ * and launch calls if user activates entry in address book
* @author yids
* @author hark
+ * @author Christian Grothoff
*/
#include "gnunet-conversation-gtk.h"
#include "gnunet-conversation-gtk_contacts.h"
@@ -47,23 +49,13 @@
/**
- * Our ego.
- */
-static struct GNUNET_IDENTITY_Ego *contacts_ego;
-
-/**
* List of contacts (records).
*/
static GtkListStore *contacts_liststore;
/**
- * The main tree view for 'gns' that shows the records.
+ * Tree model of the contacts treeview, same objects as #contacts_liststore.
*/
-static GtkTreeView *contacts_treeview;
-
-/**
- * Tree model of the #contacts_treeview, same objects as #contacts_liststore.
- */
static GtkTreeModel *contacts_treemodel;
/**
@@ -71,249 +63,29 @@
*/
static struct GNUNET_NAMESTORE_ZoneMonitor *zone_mon;
-/**
- * Handle to the namestore.
- */
-static struct GNUNET_NAMESTORE_Handle *ns;
/**
- * Private key for the our zone.
- */
-static struct GNUNET_CRYPTO_EcdsaPrivateKey zone_pkey;
-
-/**
- * Name of the records to add/list/remove.
- */
-static char *name;
-
-/**
- * Queue entry for the 'add' operation.
- */
-static struct GNUNET_NAMESTORE_QueueEntry *add_qe;
-
-/**
- * Queue entry for the 'del' operation.
- */
-static struct GNUNET_NAMESTORE_QueueEntry *del_qe;
-
-
-
-/**
- * Continuation called to notify client about result of the
- * operation.
+ * A row was activated in the contacts list. Initiate call.
*
- * @param cls closure, location of the QueueEntry pointer to NULL out
- * @param success #GNUNET_SYSERR on failure (including timeout/queue
drop/failure to validate)
- * #GNUNET_NO if content was already there
- * #GNUNET_YES (or other positive value) on success
- * @param emsg NULL on success, otherwise an error message
- */
-static void
-add_continuation (void *cls,
- int32_t success,
- const char *emsg)
-{
-
- struct GNUNET_NAMESTORE_QueueEntry **qe = cls;
-
- *qe = NULL;
- if (GNUNET_YES != success)
- {
- fprintf (stderr, _("Adding record failed: %s\n"),
- (GNUNET_NO == success) ? "record exists" : emsg);
- if (GNUNET_NO != success)
- GCG_log("GNUNET_NO != success");
- //ret = 1;
- }
- GCG_log("blaat");
- //ret = 0;
- //test_finished ();
-}
-
-
-/**
- * Continuation called to notify client about result of the
- * operation.
- *
- * @param cls closure, unused
- * @param success #GNUNET_SYSERR on failure (including timeout/queue
drop/failure to validate)
- * #GNUNET_NO if content was already there
- * #GNUNET_YES (or other positive value) on success
- * @param emsg NULL on success, otherwise an error message
- */
-static void
-del_continuation (void *cls,
- int32_t success,
- const char *emsg)
-{
- del_qe = NULL;
- if (GNUNET_NO == success)
- {
- fprintf (stderr, _("Deleting record failed, record does not exist%s%s\n"),
- (NULL != emsg) ? ": " : "", (NULL != emsg) ? emsg : "");
- }
- if (GNUNET_SYSERR == success)
- {
- fprintf (stderr, _("Deleting record failed%s%s\n"),
- (NULL != emsg) ? ": " : "", (NULL != emsg) ? emsg : "");
- }
- // test_finished ();
-}
-
-
-/**
- * add a new contact
- *
- * @param name
- * @param address
- */
-static void
-add_contact (const gchar *name,
- const gchar *address)
-{
- GtkTreeIter iter;
- struct GNUNET_GNSRECORD_Data rd;
- struct GNUNET_GNSRECORD_Data *rde;
- static void *data;
- static size_t data_size;
- struct GNUNET_CRYPTO_EcdsaPublicKey pkey;
- struct GNUNET_IDENTITY_Ego *ego;
-
- ego = GCG_EGOS_get_selected_ego ();
- zone_pkey = *GNUNET_IDENTITY_ego_get_private_key (ego);
- GNUNET_CRYPTO_ecdsa_public_key_from_string (address,
- strlen (address),
- &pkey);
- rde = &rd;
- rd.data = &pkey;
- rd.data_size = sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey);
- rd.record_type = GNUNET_GNSRECORD_TYPE_PKEY;
- rd.flags |= GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION; // always set to
relative for testing purposes
- rde->flags |= GNUNET_GNSRECORD_RF_PRIVATE;
- rde->expiration_time = GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us;
- //FPRINTF (stderr, "adding\n");
- //FPRINTF (stderr, "name: %s\n", name);
- //FPRINTF (stderr, "address: %s\n", address);
- if (GNUNET_OK !=
- GNUNET_GNSRECORD_string_to_value (65536, address, &data, &data_size))
- {
- FPRINTF (stderr, "invalid address\n");
- }
- else
- {
- add_qe =
- GNUNET_NAMESTORE_records_store (ns, &zone_pkey, name, 1, rde,
- &add_continuation, &add_qe);
- gtk_list_store_append (contacts_liststore, &iter);
- gtk_list_store_set (contacts_liststore, &iter, 1, "PKEY", 0, name, -1);
- }
-}
-
-
-/**
- * executed when clicked on add contact
- * @param button
- * @param user_data
- */
-void
-GNUNET_CONVERSATION_GTK_on_add_clicked (GtkButton * button,
- gpointer * user_data)
-{
- GtkEntry *nameEntry;
- GtkEntry *addressEntry;
-
- nameEntry = GTK_ENTRY (GCG_get_main_window_object
("GNUNET_GTK_conversation_nameAdd"));
- addressEntry = GTK_ENTRY (GCG_get_main_window_object
("GNUNET_GTK_conversation_addressAdd"));
- add_contact (gtk_entry_get_text
(nameEntry),gtk_entry_get_text(addressEntry));
-}
-
-
-void
-GNUNET_CONVERSATION_GTK_on_remove_clicked (GtkButton * button,
- gpointer * user_data)
-{
- GtkTreeSelection *selection;
- GtkTreeModel *model;
- GtkTreeIter iter;
- GtkDialog *confirm;
- GtkWindow *main_window;
- GtkLabel *notification;
- GtkHBox *content_area;
-
- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (contacts_treeview));
- if (gtk_tree_selection_get_selected (selection, &model, &iter))
- {
- gtk_tree_model_get (model, &iter, 0, &name, -1);
- //FPRINTF (stderr, "selected %s \n", name);
- main_window = GTK_WINDOW (GCG_get_main_window_object
("GNUNET_GTK_conversation_window"));
- confirm =
- GTK_DIALOG (gtk_dialog_new_with_buttons
- ("Removing contact", main_window,
- GTK_DIALOG_DESTROY_WITH_PARENT, _("Yes"),
- GTK_RESPONSE_ACCEPT, _("No"), GTK_RESPONSE_CANCEL, NULL));
- content_area =
- GTK_HBOX (gtk_dialog_get_content_area (GTK_DIALOG (confirm)));
- notification =
- GTK_LABEL (gtk_label_new
- ("Do you really want to remove this contact?"));
- gtk_container_add (GTK_CONTAINER (content_area), GTK_WIDGET
(notification));
- gtk_widget_show_all (GTK_WIDGET (confirm));
- switch (gtk_dialog_run (confirm))
- {
- case GTK_RESPONSE_ACCEPT:
- zone_pkey = *GNUNET_IDENTITY_ego_get_private_key (contacts_ego);
- del_qe =
- GNUNET_NAMESTORE_records_store (ns, &zone_pkey, name, 0, NULL,
- &del_continuation, NULL);
- gtk_list_store_remove (contacts_liststore, &iter);
- gtk_widget_destroy (GTK_WIDGET (confirm));
- break;
- case GTK_RESPONSE_CANCEL:
- FPRINTF (stderr, "not removing \n");
- gtk_widget_destroy (GTK_WIDGET (confirm));
- break;
- }
-
- }
-}
-
-
-/**
- * FIXME: what was clicked where?
- */
-void
-GNUNET_CONVERSATION_GTK_use_current_button_clicked (GtkButton *button,
- gpointer *user_data)
-{
- GtkEntry *addressEntry;
-
- addressEntry = GTK_ENTRY (GCG_get_main_window_object
("GNUNET_GTK_conversation_addressAdd"));
- gtk_entry_set_text (addressEntry,
- "FIXME");
-}
-
-
-/**
- * A row was activated in the contacts list. Initiate call.
- *
* @param tree_view view where the row was activated
* @param path path to the activated element
* @param column column that was activated
* @param user_data builder context (unused)
*/
void
-GNUNET_CONVERSATION_GTK_row_activated (GtkTreeView *tree_view,
- GtkTreePath *path,
- GtkTreeViewColumn *column,
- gpointer user_data)
+gnunet_conversation_gtk_contact_list_treeview_row_activated_cb (GtkTreeView
*tree_view,
+ GtkTreePath
*path,
+
GtkTreeViewColumn *column,
+ gpointer
user_data)
{
char *address;
gchar *type;
GtkTreeIter iter;
+ gchar *name;
gtk_tree_model_get_iter (contacts_treemodel,
- path,
- &iter);
+ &iter,
+ path);
gtk_tree_model_get (contacts_treemodel,
&iter,
CONTACTS_LS_NAME, &name,
@@ -327,7 +99,6 @@
}
else
{
- GNUNET_assert (0 == strcmp (type, "PHONE"));
GNUNET_asprintf (&address,
"%s.gnu",
name);
@@ -378,6 +149,10 @@
type = "PKEY";
do_display = TRUE;
break;
+ case GNUNET_DNSPARSER_TYPE_CNAME:
+ type = "CNAME";
+ do_display = TRUE;
+ break;
case GNUNET_GNSRECORD_TYPE_PHONE:
type = "PHONE";
do_display = TRUE;
@@ -489,6 +264,8 @@
void
GCG_CONTACTS_init ()
{
+ GtkTreeView *contacts_treeview;
+
contacts_liststore
= GTK_LIST_STORE (GCG_get_main_window_object
("gnunet_conversation_gtk_contacts_liststore"));
@@ -496,8 +273,8 @@
= GTK_TREE_MODEL (contacts_liststore);
contacts_treeview
= GTK_TREE_VIEW (GCG_get_main_window_object
("gnunet_conversation_gtk_treeview"));
- // gtk_tree_view_set_activate_on_single_click (contacts_treeview, TRUE);
- ns = GNUNET_NAMESTORE_connect (GCG_get_configuration ());
+ gtk_tree_view_set_activate_on_single_click (contacts_treeview,
+ TRUE);
}
@@ -512,12 +289,9 @@
GNUNET_NAMESTORE_zone_monitor_stop (zone_mon);
zone_mon = NULL;
}
- if (NULL != ns)
- {
- GNUNET_NAMESTORE_disconnect (ns);
- ns = NULL;
- }
- GNUNET_CRYPTO_ecdsa_key_clear (&zone_pkey);
+ gtk_list_store_clear (contacts_liststore);
+ contacts_liststore = NULL;
+ contacts_treemodel = NULL;
}
/* end of gnunet-conversation-gtk_contacts.c */
Modified: gnunet-gtk/src/conversation/gnunet-conversation-gtk_contacts.h
===================================================================
--- gnunet-gtk/src/conversation/gnunet-conversation-gtk_contacts.h
2014-05-26 17:23:39 UTC (rev 33400)
+++ gnunet-gtk/src/conversation/gnunet-conversation-gtk_contacts.h
2014-05-26 19:13:52 UTC (rev 33401)
@@ -30,14 +30,14 @@
/**
* Initialize the contact list
*/
-extern void
+void
GCG_CONTACTS_init (void);
/**
* Shutdown the contact list
*/
-extern void
-GCG_CONTACTS_shutdown(void);
+void
+GCG_CONTACTS_shutdown (void);
#endif
Modified: gnunet-gtk/src/conversation/gnunet-conversation-gtk_egos.c
===================================================================
--- gnunet-gtk/src/conversation/gnunet-conversation-gtk_egos.c 2014-05-26
17:23:39 UTC (rev 33400)
+++ gnunet-gtk/src/conversation/gnunet-conversation-gtk_egos.c 2014-05-26
19:13:52 UTC (rev 33401)
@@ -20,7 +20,7 @@
/**
* @file src/conversation/gnunet-conversation-gtk_egos.c
- * @brief
+ * @brief Manages the list of egos for selecting our caller-ID
* @author yids
* @author hark
* @author Christian Grothoff
@@ -30,19 +30,19 @@
/**
- * Columns in the #zone_liststore.
+ * Columns in the #ego_liststore.
*/
-enum ZoneListstoreValues
+enum EgoListstoreValues
{
/**
* Human-readable name of the ego.
*/
- ZONE_LS_NAME = 0,
+ EGO_LS_NAME = 0,
/**
* Handel to the ego (of type `struct GNUNET_IDENTITY_Ego *ego`).
*/
- ZONE_LS_EGO = 1
+ EGO_LS_EGO = 1
};
@@ -52,10 +52,14 @@
static struct GNUNET_IDENTITY_Handle *id;
/**
- * list of zones
+ * list of egos
*/
-static GtkListStore *zone_liststore;
+static GtkListStore *ego_liststore;
+/**
+ * Default ego to pre-select.
+ */
+static char *default_ego;
/**
* Obtain the currently selected ego.
@@ -63,18 +67,19 @@
* @return NULL if no ego is selected
*/
struct GNUNET_IDENTITY_Ego *
-GCG_EGOS_get_selected_ego (void)
+GCG_EGOS_get_selected_ego ()
{
struct GNUNET_IDENTITY_Ego *ego;
GtkTreeIter iter;
GtkComboBox *cb;
- cb = GTK_COMBO_BOX (GCG_get_main_window_object
("gnunet_conversation_gtk_contacts_zone_combobox"));
+ cb = GTK_COMBO_BOX (GCG_get_main_window_object
+ ("gnunet_conversation_gtk_ego_combobox"));
gtk_combo_box_get_active_iter (cb,
&iter);
- gtk_tree_model_get (GTK_TREE_MODEL (zone_liststore),
+ gtk_tree_model_get (GTK_TREE_MODEL (ego_liststore),
&iter,
- ZONE_LS_EGO, &ego,
+ EGO_LS_EGO, &ego,
-1);
return ego;
}
@@ -97,20 +102,33 @@
GtkTreeIter iter;
GtkTreeRowReference *rr;
GtkTreePath *path;
+ GtkComboBox *cb;
rr = *ctx;
if (NULL == rr)
{
/* new identity */
GNUNET_assert (NULL != name);
- gtk_list_store_insert_with_values (zone_liststore,
+ gtk_list_store_insert_with_values (ego_liststore,
&iter, -1,
- ZONE_LS_NAME, name,
- ZONE_LS_EGO, ego,
+ EGO_LS_NAME, name,
+ EGO_LS_EGO, ego,
-1);
- path = gtk_tree_model_get_path (GTK_TREE_MODEL (zone_liststore),
+ if ( (NULL != default_ego) &&
+ (0 == strcmp (name,
+ default_ego)) )
+ {
+ /* found the ego that we were supposed to use by default, select
+ it! */
+ GNUNET_free (default_ego);
+ default_ego = NULL;
+ cb = GTK_COMBO_BOX (GCG_get_main_window_object
+ ("gnunet_conversation_gtk_ego_combobox"));
+ gtk_combo_box_set_active_iter (cb, &iter);
+ }
+ path = gtk_tree_model_get_path (GTK_TREE_MODEL (ego_liststore),
&iter);
- rr = gtk_tree_row_reference_new (GTK_TREE_MODEL (zone_liststore),
+ rr = gtk_tree_row_reference_new (GTK_TREE_MODEL (ego_liststore),
path);
gtk_tree_path_free (path);
*ctx = rr;
@@ -118,7 +136,7 @@
}
/* existing ego, locate and execute rename/delete */
path = gtk_tree_row_reference_get_path (rr);
- gtk_tree_model_get_iter (GTK_TREE_MODEL (zone_liststore),
+ gtk_tree_model_get_iter (GTK_TREE_MODEL (ego_liststore),
&iter,
path);
gtk_tree_path_free (path);
@@ -127,26 +145,30 @@
/* deletion operation */
gtk_tree_row_reference_free (rr);
*ctx = NULL;
- gtk_list_store_remove (zone_liststore,
+ gtk_list_store_remove (ego_liststore,
&iter);
return;
}
/* rename operation */
- gtk_list_store_set (zone_liststore,
+ gtk_list_store_set (ego_liststore,
&iter,
- ZONE_LS_NAME, &name,
+ EGO_LS_NAME, &name,
-1);
}
/**
* Initialize the ego list
+ *
+ * @param ego_name default ego to pre-select
*/
void
-GCG_EGOS_init ()
+GCG_EGOS_init (const char *ego_name)
{
- zone_liststore
- = GTK_LIST_STORE (GCG_get_main_window_object
("gnunet_conversation_gtk_contacts_zone_liststore"));
+ default_ego = GNUNET_strdup (ego_name);
+ ego_liststore
+ = GTK_LIST_STORE (GCG_get_main_window_object
+ ("gnunet_conversation_gtk_ego_liststore"));
id = GNUNET_IDENTITY_connect (GCG_get_configuration (),
&identity_cb,
NULL);
@@ -164,6 +186,11 @@
GNUNET_IDENTITY_disconnect (id);
id = NULL;
}
+ if (NULL != default_ego)
+ {
+ GNUNET_free (default_ego);
+ default_ego = NULL;
+ }
}
/* end of gnunet-conversation-gtk_egos.c */
Modified: gnunet-gtk/src/conversation/gnunet-conversation-gtk_egos.h
===================================================================
--- gnunet-gtk/src/conversation/gnunet-conversation-gtk_egos.h 2014-05-26
17:23:39 UTC (rev 33400)
+++ gnunet-gtk/src/conversation/gnunet-conversation-gtk_egos.h 2014-05-26
19:13:52 UTC (rev 33401)
@@ -20,7 +20,7 @@
/**
* @file src/conversation/gnunet-conversation-gtk_egos.h
- * @brief
+ * @brief Manages the list of egos for selecting our caller-ID
* @author yids
* @author hark
* @author Christian Grothoff
@@ -39,16 +39,18 @@
/**
- * Initialize the contact list
+ * Initialize the contact list.
+ *
+ * @param ego_name default ego to pre-select
*/
-extern void
-GCG_EGOS_init (void);
+void
+GCG_EGOS_init (const char *ego_name);
/**
- * Shutdown the contact list
+ * Shutdown the contact list.
*/
-extern void
-GCG_EGOS_shutdown(void);
+void
+GCG_EGOS_shutdown (void);
#endif
Modified: gnunet-gtk/src/conversation/gnunet-conversation-gtk_history.c
===================================================================
--- gnunet-gtk/src/conversation/gnunet-conversation-gtk_history.c
2014-05-26 17:23:39 UTC (rev 33400)
+++ gnunet-gtk/src/conversation/gnunet-conversation-gtk_history.c
2014-05-26 19:13:52 UTC (rev 33401)
@@ -1,6 +1,6 @@
/*
This file is part of GNUnet.
- (C) 2010-2013 Christian Grothoff (and other contributing authors)
+ (C) 2010-2014 Christian Grothoff (and other contributing authors)
GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
@@ -19,23 +19,21 @@
*/
/**
* @file src/conversation/gnunet-conversation-gtk_history.c
- * @brief
+ * @brief manages the call history view
* @author yids
* @author hark
+ * @author Christian Grothoff
*/
#include "gnunet-conversation-gtk.h"
+#include "gnunet-conversation-gtk_history.h"
-
-/*******
- * history
- ********/
/**
- * call history liststore
+ * call history liststore // FIXME: which one is it?
*/
static GtkListStore *history_liststore;
/**
- * call history treestore
+ * call history treestore // FIXME: which one is it?
*/
static GtkTreeStore *history_treestore;
@@ -50,16 +48,15 @@
static GtkTreeModel *history_treemodel;
-/*
- *
+/**
* adds a item to the call history
*
* @param type type of call: 0: accepted 1: rejected 2: outgoing call
* @return void
*/
-
-extern void
-GNUNET_CONVERSATION_GTK_history_add (int type, char *contactName)
+void
+GCG_HISTORY_add (int type,
+ char *contactName)
{
GtkTreeIter iter;
time_t t;
@@ -92,15 +89,24 @@
contactName, -1);
}
-extern void
-GNUNET_CONVERSATION_GTK_history_init(){
+
+/**
+ * Intialize history subsystem.
+ */
+void
+GCG_HISTORY_init ()
+{
// call history
history_liststore =
- GTK_LIST_STORE (GCG_get_main_window_object
("gnunet_conversation_gtk_history_liststore"));
+ GTK_LIST_STORE (GCG_get_main_window_object
+ ("gnunet_conversation_gtk_history_liststore"));
history_treeview =
- GTK_TREE_VIEW (GCG_get_main_window_object
("gnunet_conversation_gtk_history_treeview"));
+ GTK_TREE_VIEW (GCG_get_main_window_object
+ ("gnunet_conversation_gtk_history_treeview"));
history_treestore =
- GTK_TREE_STORE (GCG_get_main_window_object
("gnunet_conversation_gtk_history_treestore"));
+ GTK_TREE_STORE (GCG_get_main_window_object
+ ("gnunet_conversation_gtk_history_treestore"));
history_treemodel = GTK_TREE_MODEL (history_treestore);
+}
-}
+/* end of gnunet-conversation-gtk_history.c */
Modified: gnunet-gtk/src/conversation/gnunet-conversation-gtk_history.h
===================================================================
--- gnunet-gtk/src/conversation/gnunet-conversation-gtk_history.h
2014-05-26 17:23:39 UTC (rev 33400)
+++ gnunet-gtk/src/conversation/gnunet-conversation-gtk_history.h
2014-05-26 19:13:52 UTC (rev 33401)
@@ -1,11 +1,63 @@
+/*
+ This file is part of GNUnet.
+ (C) 2010-2014 Christian Grothoff (and other contributing authors)
-/****************
- * history *
- ****************/
+ GNUnet is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published
+ by the Free Software Foundation; either version 3, or (at your
+ option) any later version.
-extern void
-GNUNET_CONVERSATION_GTK_history_add (int, char *);
+ GNUnet is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
-extern void
-GNUNET_CONVERSATION_GTK_history_init();
+ You should have received a copy of the GNU General Public License
+ along with GNUnet; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+/**
+ * @file src/conversation/gnunet-conversation-gtk_history.h
+ * @brief manages the call history view
+ * @author yids
+ * @author hark
+ */
+#ifndef GNUNET_CONVERSATION_GTK_HISTORY_H
+#define GNUNET_CONVERSATION_GTK_HISTORY_H
+
+
+/**
+ * FIXME: used?
+ */
+enum CallHistoryType
+{
+ CH_ACCEPTED,
+ CH_REJECTED,
+ CH_OUTGOING,
+ CH_HANGUP,
+ CH_MISSED
+};
+
+
+/**
+ * Add an entry to the history.
+ *
+ * FIXME: use `enum CallHistoryType` here?
+ * @param type type of call: 0: accepted 1: rejected 2: outgoing call
+ * @param contactName name of the contact person
+ */
+void
+GCG_HISTORY_add (int type,
+ char *contactName);
+
+
+/**
+ * Intialize history subsystem.
+ */
+void
+GCG_HISTORY_init (void);
+
+
+#endif
Added: gnunet-gtk/src/conversation/gnunet-conversation-gtk_import.c
===================================================================
--- gnunet-gtk/src/conversation/gnunet-conversation-gtk_import.c
(rev 0)
+++ gnunet-gtk/src/conversation/gnunet-conversation-gtk_import.c
2014-05-26 19:13:52 UTC (rev 33401)
@@ -0,0 +1,148 @@
+/*
+ This file is part of GNUnet.
+ (C) 2010-2014 Christian Grothoff (and other contributing authors)
+
+ GNUnet is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published
+ by the Free Software Foundation; either version 3, or (at your
+ option) any later version.
+
+ GNUnet is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GNUnet; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+/**
+ * @file src/conversation/gnunet-conversation-gtk_import.c
+ * @brief handle request to import caller into address book
+ * @author yids
+ * @author hark
+ * @author Christian Grothoff
+ */
+#include "gnunet-conversation-gtk.h"
+#include "gnunet-conversation-gtk_contacts.h"
+#include "gnunet-conversation-gtk_egos.h"
+
+/**
+ * Handle to the namestore.
+ */
+static struct GNUNET_NAMESTORE_Handle *ns;
+
+/**
+ * Queue entry for the 'add' operation.
+ */
+static struct GNUNET_NAMESTORE_QueueEntry *add_qe;
+
+
+/**
+ * Continuation called to notify client about result of the
+ * operation.
+ *
+ * @param cls NULL
+ * @param success #GNUNET_SYSERR on failure (including timeout/queue
drop/failure to validate)
+ * #GNUNET_NO if content was already there
+ * #GNUNET_YES (or other positive value) on success
+ * @param emsg NULL on success, otherwise an error message
+ */
+static void
+add_continuation (void *cls,
+ int32_t success,
+ const char *emsg)
+{
+ if (GNUNET_YES != success)
+ GCG_log (_("Adding contact failed: %s\n"),
+ (GNUNET_NO == success) ? _("record exists") : emsg);
+ add_qe = NULL;
+}
+
+
+/**
+ * Add new contact to the address book.
+ *
+ * @param name name to use for the contact
+ * @param address public key of the contact
+ */
+void
+GSC_add_contact (const gchar *name,
+ const gchar *address)
+{
+ struct GNUNET_GNSRECORD_Data rd;
+ struct GNUNET_CRYPTO_EcdsaPublicKey pkey;
+ struct GNUNET_IDENTITY_Ego *ego;
+ const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone_pkey;
+
+ if (NULL != add_qe)
+ {
+ GCG_log (_("Adding contact failed: %s\n"),
+ _("previous operation still pending"));
+ return;
+ }
+
+ // FIXME: what should really be the preferred address format here?
+ // (CNAME? PKEY? PHONE?)
+ if (GNUNET_OK !=
+ GNUNET_CRYPTO_ecdsa_public_key_from_string (address,
+ strlen (address),
+ &pkey))
+ {
+ GCG_log (_("Adding contact failed: %s\n"),
+ _("invalid address"));
+ return;
+ }
+ rd.data = &pkey;
+ rd.data_size = sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey);
+ rd.record_type = GNUNET_GNSRECORD_TYPE_PKEY;
+ rd.flags
+ = GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION
+ | GNUNET_GNSRECORD_RF_PRIVATE;
+ rd.expiration_time
+ = GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us;
+ ego = GCG_EGOS_get_selected_ego ();
+ zone_pkey = GNUNET_IDENTITY_ego_get_private_key (ego);
+ /* FIXME: we should check if the 'name' already exists,
+ and not do this if it does... */
+ add_qe
+ = GNUNET_NAMESTORE_records_store (ns,
+ zone_pkey,
+ name,
+ 1, &rd,
+ &add_continuation, NULL);
+}
+
+
+/**
+ * Initialize the import subsystem.
+ */
+void
+GCG_IMPORT_init ()
+{
+ ns = GNUNET_NAMESTORE_connect (GCG_get_configuration ());
+}
+
+
+/**
+ * Shutdown the import subsystem.
+ */
+void
+GCG_IMPORT_shutdown ()
+{
+ if (NULL != add_qe)
+ {
+ GNUNET_NAMESTORE_cancel (add_qe);
+ add_qe = NULL;
+ }
+ if (NULL != ns)
+ {
+ GNUNET_NAMESTORE_disconnect (ns);
+ ns = NULL;
+ }
+}
+
+/* end of gnunet-conversation-gtk_import.c */
+
Added: gnunet-gtk/src/conversation/gnunet-conversation-gtk_import.h
===================================================================
--- gnunet-gtk/src/conversation/gnunet-conversation-gtk_import.h
(rev 0)
+++ gnunet-gtk/src/conversation/gnunet-conversation-gtk_import.h
2014-05-26 19:13:52 UTC (rev 33401)
@@ -0,0 +1,56 @@
+/*
+ This file is part of GNUnet.
+ (C) 2010-2014 Christian Grothoff (and other contributing authors)
+
+ GNUnet is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published
+ by the Free Software Foundation; either version 3, or (at your
+ option) any later version.
+
+ GNUnet is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GNUnet; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+/**
+ * @file src/conversation/gnunet-conversation-gtk_contacts.h
+ * @brief handle requests from user to import new contacts
+ * @author yids
+ * @author hark
+ * @author Christian Grothoff
+ */
+#ifndef GNUNET_CONVERSATION_GTK_IMPORTS_H
+#define GNUNET_CONVERSATION_GTK_IMPORTS_H
+
+
+/**
+ * Add new contact to the address book.
+ *
+ * @param name
+ * @param address
+ */
+void
+GSC_add_contact (const gchar *name,
+ const gchar *address);
+
+
+/**
+ * Initialize the import subsystem.
+ */
+void
+GCG_IMPORT_init (void);
+
+
+/**
+ * Shutdown the import subsystem.
+ */
+void
+GCG_IMPORT_shutdown (void);
+
+#endif
Added: gnunet-gtk/src/conversation/gnunet-conversation-gtk_log.c
===================================================================
--- gnunet-gtk/src/conversation/gnunet-conversation-gtk_log.c
(rev 0)
+++ gnunet-gtk/src/conversation/gnunet-conversation-gtk_log.c 2014-05-26
19:13:52 UTC (rev 33401)
@@ -0,0 +1,94 @@
+/*
+ This file is part of GNUnet.
+ (C) 2010-2014 Christian Grothoff (and other contributing authors)
+
+ GNUnet is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published
+ by the Free Software Foundation; either version 3, or (at your
+ option) any later version.
+
+ GNUnet is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GNUnet; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+/**
+ * @file src/conversation/gnunet-conversation-gtk_log.c
+ * @brief logging-related functions for gnunet-conversation-gtk
+ * @author yids
+ * @author hark
+ * @author Christian Grothoff
+ */
+#include "gnunet-conversation-gtk.h"
+#include "gnunet-conversation-gtk_log.h"
+
+
+/**
+ * Log a message to gtk log textbuffer
+ *
+ * @param message format string for message to be logged
+ * @param ... arguments for the format string
+ */
+void
+GCG_log (const char *message,
+ ...)
+{
+ GtkTextBuffer *logbuff;
+ GtkTextView *log_view;
+ GtkTextIter iter;
+ gchar *fmsg;
+ va_list ap;
+
+ log_view = GTK_TEXT_VIEW (GCG_get_main_window_object
+ ("GNUNET_GTK_conversation_log"));
+ logbuff = GTK_TEXT_BUFFER (gtk_text_view_get_buffer (log_view));
+ va_start (ap, message);
+ fmsg = g_strdup_vprintf (message,
+ ap);
+ va_end (ap);
+ gtk_text_buffer_get_start_iter (logbuff,
+ &iter);
+ gtk_text_buffer_insert (logbuff,
+ &iter,
+ fmsg,
+ -1);
+ g_free (fmsg);
+}
+
+
+/**
+ * Update status bar.
+ *
+ * @param message format string for message to put in statusbar
+ * @param ... arguments for the format string
+ */
+void
+GCG_update_status_bar (const gchar *message,
+ ...)
+{
+ GtkStatusbar *status_bar;
+ guint status_bar_context;
+ gchar *buff;
+ va_list ap;
+
+ status_bar = GTK_STATUSBAR (GCG_get_main_window_object
+ ("GNUNET_GTK_conversation_statusbar"));
+ status_bar_context = gtk_statusbar_get_context_id (status_bar,
+ "blaat"); // blaat!?
+ va_start (ap, message);
+ buff = g_strdup_vprintf (message,
+ ap);
+ va_end (ap);
+ gtk_statusbar_push (GTK_STATUSBAR (status_bar),
+ GPOINTER_TO_INT (status_bar_context),
+ buff);
+ g_free (buff);
+}
+
+/* end of gnunet-conversation-gtk_log.c */
Added: gnunet-gtk/src/conversation/gnunet-conversation-gtk_log.h
===================================================================
--- gnunet-gtk/src/conversation/gnunet-conversation-gtk_log.h
(rev 0)
+++ gnunet-gtk/src/conversation/gnunet-conversation-gtk_log.h 2014-05-26
19:13:52 UTC (rev 33401)
@@ -0,0 +1,73 @@
+/*
+ This file is part of GNUnet
+ (C) 2013-2014 Christian Grothoff (and other contributing authors)
+
+ GNUnet is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published
+ by the Free Software Foundation; either version 3, or (at your
+ option) any later version.
+
+ GNUnet is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GNUnet; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+/**
+ * @file src/identity/gnunet-identity-gtk_log.h
+ * @author Christian Grothoff
+ */
+#ifndef GNUNET_CONVERSATION_GTK_LOG_H
+#define GNUNET_CONVERSATION_GTK_LOG_H
+
+#include <stdbool.h>
+#include <stdint.h>
+#include "gnunet_gtk.h"
+#include <gnunet/gnunet_dnsparser_lib.h>
+#include <gnunet/gnunet_identity_service.h>
+#include <gnunet/gnunet_namestore_service.h>
+#include <gnunet/gnunet_conversation_service.h>
+#include <gnunet/gnunet_speaker_lib.h>
+#include <gnunet/gnunet_microphone_lib.h>
+#include <gnunet/gnunet_identity_service.h>
+#include <gnunet/gnunet_namestore_service.h>
+#include <gnunet/gnunet_gnsrecord_lib.h>
+
+
+/**
+ * Update status bar.
+ *
+ * @param message format string for message to put in statusbar
+ * @param ... arguments for the format string
+ */
+void
+GCG_update_status_bar (const gchar *message,
+ ...);
+
+
+/**
+ * Log a message to the log textbuffer.
+ *
+ * @param message format string for message to be logged
+ * @param ... arguments for the format string
+ */
+void
+GCG_log (const char *message,
+ ...);
+
+
+/**
+ * Updates the status icon to the image of the given name.
+ *
+ * @param icon_name name of the icon to use
+ */
+void
+GCG_set_status_icon (const char *icon_name);
+
+
+#endif
Modified: gnunet-gtk/src/conversation/gnunet-conversation-gtk_phone.c
===================================================================
--- gnunet-gtk/src/conversation/gnunet-conversation-gtk_phone.c 2014-05-26
17:23:39 UTC (rev 33400)
+++ gnunet-gtk/src/conversation/gnunet-conversation-gtk_phone.c 2014-05-26
19:13:52 UTC (rev 33401)
@@ -20,9 +20,1443 @@
/**
* @file src/conversation/gnunet-conversation-gtk_phone.c
- * @brief
+ * @brief
* @author yids
* @author hark
+ * @author Christian Grothoff
*/
+#include "gnunet-conversation-gtk.h"
+#include "gnunet-conversation-gtk_egos.h"
+#include "gnunet-conversation-gtk_history.h"
+#include "gnunet-conversation-gtk_log.h"
+#include "gnunet-conversation-gtk_phone.h"
+/**
+ * active calls treeview columns
+ */
+enum ActiveCallsTreeViewColumns
+{
+ AL_caller_id, //*gchar
+ AL_caller, //*
+ AL_caller_num, //gint
+ AL_type, //gint
+ AL_caller_state, //gint
+ AL_call, //*
+ AL_call_state, //gint
+ AL_call_num //gint
+};
+
+
+/**
+ * callerstate (state of incoming call)
+ */
+enum CallerState
+{
+ CT_active,
+ CT_suspended,
+ CT_ringing,
+ CT_dead,
+ CT_hangup,
+ CT_rejected,
+ CT_other
+};
+
+
+/**
+ * type of call
+ */
+enum TypeOfCall
+{
+ CALL_IN,
+ CALL_OUT
+};
+
+
+/**
+ * Possible states of the phone.
+ */
+enum PhoneState
+{
+ /**
+ * We're waiting for our own idenitty.
+ */
+ PS_LOOKUP_EGO,
+
+ /**
+ * We're listening for calls
+ */
+ PS_LISTEN,
+
+ /**
+ * We accepted an incoming phone call.
+ */
+ PS_ACCEPTED,
+
+ /**
+ * Internal error
+ */
+ PS_ERROR
+};
+
+
+/**
+ * States for current outgoing call.
+ */
+enum CallState
+{
+ /**
+ * We are looking up some other participant.
+ */
+ CS_RESOLVING,
+
+ /**
+ * We are now ringing the other participant.
+ */
+ CS_RINGING,
+
+ /**
+ * The other party accepted our call and we are now connected.
+ */
+ CS_CONNECTED,
+
+ /**
+ * The call is currently suspended (by us).
+ */
+ CS_SUSPENDED
+};
+
+
+
+/**
+ * List of incoming calls
+ */
+struct CallList
+{
+
+ /**
+ * A DLL.
+ */
+ struct CallList *prev;
+
+ /**
+ * A DLL.
+ */
+ struct CallList *next;
+
+ /**
+ * Handle to hang up or activate.
+ */
+ struct GNUNET_CONVERSATION_Caller *caller;
+
+ /**
+ * Handle to call currently selected in list
+ */
+ struct GNUNET_CONVERSATION_Caller *caller_selected;
+
+ /**
+ * String identifying the caller.
+ */
+ char *caller_id;
+
+ /**
+ * Unique number of the caller.
+ */
+ unsigned int caller_num;
+
+};
+
+
+/**
+ *
+ */
+static struct GNUNET_CONVERSATION_Caller *caller_selected;
+
+/**
+ *
+ */
+static struct GNUNET_CONVERSATION_Call *call_selected;
+
+
+/**
+ * List of active calls
+ */
+static GtkListStore *active_liststore;
+
+/**
+ * List of active calls
+ */
+static GtkTreeView *active_treeview;
+
+/**
+ * Unique number of call (outgoing)
+ */
+static unsigned int call_counter;
+
+/**
+ * Counts the number of incoming calls we have had so far.
+ */
+static unsigned int caller_num_gen;
+
+/**
+ * Phone handle
+ */
+static struct GNUNET_CONVERSATION_Phone *phone;
+
+/**
+ * Call handle (for active outgoing call).
+ */
+static struct GNUNET_CONVERSATION_Call *call;
+
+/**
+ * Caller handle (for active incoming call).
+ */
+static struct CallList *cl_active;
+
+/**
+ * Head of calls waiting to be accepted.
+ */
+static struct CallList *cl_head;
+
+/**
+ * Tail of calls waiting to be accepted.
+ */
+static struct CallList *cl_tail;
+
+/**
+ * Our speaker.
+ */
+static struct GNUNET_SPEAKER_Handle *speaker;
+
+/**
+ * Our microphone.
+ */
+static struct GNUNET_MICROPHONE_Handle *mic;
+
+/**
+ * Our phone's current state.
+ */
+static enum PhoneState phone_state;
+
+/**
+ * Our call's current state.
+ */
+static enum CallState call_state;
+
+/**
+ * Name of conversation partner (if any).
+ */
+static char *peer_name;
+
+/**
+ * GNS address for this phone.
+ */
+static char *address;
+
+static GtkWidget *b_contact;
+
+static GtkWidget *b_accept;
+
+static GtkWidget *b_hangup;
+
+static GtkWidget *b_suspend;
+
+static GtkWidget *b_resume;
+
+
+
+/**
+ * Update status based on current phone state.
+ *
+ * @param args arguments given to the command
+ */
+static void
+do_status ()
+{
+ switch (phone_state)
+ {
+ case PS_LOOKUP_EGO:
+ GCG_update_status_bar ("%s",
+ _("Phone inactive: no ego selected for the caller
ID."));
+ GCG_set_status_icon ("gnunet-conversation-gtk-tray-pending");
+ break;
+ case PS_LISTEN:
+ GCG_update_status_bar ("%s",
+ _("We are listening for incoming calls"));
+ GCG_set_status_icon ("gnunet-conversation-gtk-tray-available");
+ break;
+ case PS_ACCEPTED:
+ GCG_update_status_bar (_("You are having a conversation with `%s'.\n"),
+ peer_name);
+ GCG_set_status_icon ("gnunet-conversation-call-active");
+ break;
+ case PS_ERROR:
+ GCG_update_status_bar (_("We had an internal error setting up our phone
line. You can still make calls."));
+ GCG_set_status_icon ("gnunet-conversation-offline");
+ break;
+ }
+ if (NULL != call)
+ {
+ switch (call_state)
+ {
+ case CS_RESOLVING:
+ GCG_update_status_bar (_("We are trying to find the network address to
call `%s'."),
+ peer_name);
+ GCG_set_status_icon ("gnunet-conversation-gtk-tray-call-pending");
+ break;
+ case CS_RINGING:
+ GCG_update_status_bar (_("We are calling `%s', his phone should be
ringing."),
+ peer_name);
+ GCG_set_status_icon ("gnunet-conversation-gtk-tray-call-ringing");
+ break;
+ case CS_CONNECTED:
+ GCG_update_status_bar (_("You are having a conversation with `%s'."),
+ peer_name);
+ GCG_set_status_icon ("gnunet-conversation-gtk-tray-call-active");
+ break;
+ case CS_SUSPENDED:
+ GCG_update_status_bar (_("Conversation suspended, you can accept or
initiate another call now."),
+ peer_name);
+ GCG_set_status_icon ("gnunet-conversation-gtk-tray-call-suspended");
+ break;
+ }
+ }
+ if ( ( (NULL == call) ||
+ (CS_SUSPENDED == call_state) ) &&
+ (NULL != cl_head) &&
+ ( (cl_head != cl_active) ||
+ (cl_head != cl_tail) ) )
+ GCG_set_status_icon ("gnunet-conversation-gtk-tray-call-incoming");
+}
+
+
+
+/**
+ * @brief print info for currently selected call
+ */
+static void
+print_call_info ()
+{
+ GtkTreeIter gtkiter;
+ gboolean valid;
+ gint row_count = 0;
+
+ valid = gtk_tree_model_get_iter_first (GTK_TREE_MODEL (active_liststore),
+ >kiter);
+ if (! valid)
+ GNUNET_break(0);
+
+ while (valid)
+ {
+ 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,
+ AL_call, &cl_call,
+ -1);
+ if (call_selected == cl_call)
+ {
+ GCG_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);
+ }
+}
+
+
+/**
+ * @brief sets caller_selected, and enables or disables the active call list
buttons
+ */
+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 =
GCG_get_main_window_object(ml,"GNUNET_CONVERSATION_GTK_active_calls_selection");
+
+ // reset references to selected call/caller
+ //caller_selected = NULL;
+ //call_selected = NULL;
+ GCG_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))
+ {
+ // 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);
+ // check if selected call is a incoming or outgoing call
+ switch (cl_type)
+ {
+ case CALL_IN:
+ call_selected = NULL;
+ caller_selected = cl_caller;
+ GNUNET_break (NULL != caller_selected);
+ break;
+ case CALL_OUT:
+ caller_selected = NULL;
+ call_selected = cl_call;
+ GCG_log("outgoing selected");
+ GNUNET_break (NULL != call_selected);
+ break;
+ default:
+ GNUNET_break(0);
+ break;
+ }
+
gtk_widget_show(GTK_WIDGET(GCG_get_main_window_object("GNUNET_GTK_conversation_active_call_list_buttons")));
+ GCG_log("caller state: %u phone_state: %u",
+ cl_caller_state,
+ phone_state);
+ switch (cl_caller_state)
+ {
+ /* buttons:
+ * contact
+ * accept
+ * hangup
+ * suspend
+ * resume
+ *
+ * TODO: check if there is incoming or outgoing call,
+ * disable resume and accept buttons.
+ * or suspend that other call
+ */
+ case CT_active:
+ // hangup, pause
+ //GCG_log("CT_active state: %u ",cl_caller_state);
+ gtk_widget_set_sensitive (b_contact, TRUE);
+ gtk_widget_set_sensitive (b_accept, FALSE);
+ gtk_widget_set_sensitive (b_hangup, TRUE);
+ gtk_widget_set_sensitive (b_suspend, TRUE);
+ gtk_widget_set_sensitive (b_resume, FALSE);
+ break;
+ case CT_ringing:
+ // pickup, phonebook
+ //GCG_log("CT_ring show button");
+ gtk_widget_set_sensitive (b_contact, TRUE);
+ if (phone_state == PS_LISTEN)
+ {
+ gtk_widget_set_sensitive (b_accept, TRUE);
+ }
+ else
+ {
+ gtk_widget_set_sensitive (b_accept, FALSE);
+ }
+ gtk_widget_set_sensitive (b_hangup, FALSE);
+ gtk_widget_set_sensitive (b_suspend, FALSE);
+ gtk_widget_set_sensitive (b_resume, FALSE);
+ break;
+ case CT_rejected:
+ //add to phonebook
+ //GCG_log("CT_rejected ");
+ gtk_widget_set_sensitive (b_contact, TRUE);
+ gtk_widget_set_sensitive (b_accept, FALSE);
+ gtk_widget_set_sensitive (b_hangup, FALSE);
+ gtk_widget_set_sensitive (b_suspend, FALSE);
+ gtk_widget_set_sensitive (b_resume, FALSE);
+ break;
+ case CT_suspended:
+ // resume, hangup
+ //GCG_log("CT_suspended ");
+ gtk_widget_set_sensitive (b_contact, TRUE);
+ gtk_widget_set_sensitive (b_accept, FALSE);
+ gtk_widget_set_sensitive (b_hangup, TRUE);
+ gtk_widget_set_sensitive (b_suspend, FALSE);
+ if (phone_state == PS_LISTEN)
+ {
+ GCG_log("enable resume button");
+ gtk_widget_set_sensitive (b_resume, TRUE);
+ }
+ else
+ {
+ GCG_log("do not disable resume button (for test)");
+ gtk_widget_set_sensitive (b_resume, TRUE);
+ }
+ break;
+ case CT_other:
+ //add to phonebook
+ //GCG_log("CT_rejected ");
+ gtk_widget_set_sensitive (b_contact, TRUE);
+ gtk_widget_set_sensitive (b_accept, TRUE);
+ gtk_widget_set_sensitive (b_hangup, TRUE);
+ gtk_widget_set_sensitive (b_suspend, TRUE);
+ gtk_widget_set_sensitive (b_resume, TRUE);
+ break;
+
+ default:
+ GNUNET_break(0);
+ break;
+ }
+ print_call_info();
+ }
+ else
+ {
+ GCG_log("nothing selected");
+
//gtk_widget_hide(GTK_WIDGET(GCG_get_main_window_object("GNUNET_GTK_conversation_active_call_list_buttons"
)));
+ }
+}
+
+
+/**
+ * @brief executed when selecting a different item in active call list
+ */
+void
+gnunet_conversation_gtk_active_calls_treeview_selection_changed_cb ()
+{
+ update_active_call_list_buttons();
+}
+
+
+static void
+disable_list_buttons()
+{
+ gtk_widget_set_sensitive (b_contact, FALSE);
+ gtk_widget_set_sensitive (b_accept, FALSE);
+ gtk_widget_set_sensitive (b_hangup, FALSE);
+ gtk_widget_set_sensitive (b_suspend, FALSE);
+ gtk_widget_set_sensitive (b_resume, FALSE);
+}
+
+
+/**
+ * set state of outgoing call
+ */
+void
+set_outgoing_call_state (struct GNUNET_CONVERSATION_Call *call,
+ int state)
+{
+ GtkTreeIter gtkiter;
+ 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);
+
+ 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
+ {
+ GCG_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
+ {
+ //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
+ }//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 ("");
+}
+
+
+/**
+ * set call state of a incoming call
+ */
+static void
+set_incoming_call_state (struct GNUNET_CONVERSATION_Caller *caller,
+ int state)
+{
+ 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;
+
+ 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)
+ {
+ //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("");
+}
+
+
+/**
+ * Function called with an event emitted by a phone.
+ *
+ * @param cls closure
+ * @param code type of the event
+ * @param caller handle for the caller
+ * @param caller_id name of the caller in GNS
+ */
+static void
+phone_event_handler (void *cls,
+ enum GNUNET_CONVERSATION_PhoneEventCode code,
+ struct GNUNET_CONVERSATION_Caller *caller,
+ const char *caller_id)
+{
+ GtkTreeIter gtkiter;
+ GtkTreeIter gtkiter1;
+ gboolean valid;
+
+ 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,
+ AL_caller_id, caller_id,
+ AL_caller, caller,
+ AL_caller_num, caller_num_gen,
+ AL_caller_state, CT_ringing,
+ 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);
+
+ 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,
+ AL_caller, &cl_caller,
+ 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 ;
+ }
+ 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();
+}
+
+
+/**
+ * Function called with an event emitted by a caller.
+ *
+ * @param cls closure with the `struct CallList` of the caller
+ * @param code type of the event issued by the caller
+ */
+static void
+caller_event_handler (void *cls,
+ enum GNUNET_CONVERSATION_CallerEventCode code)
+{
+
+ if (cls == NULL)
+ {
+ GCG_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);
+ 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.
+ */
+static void
+start_phone ()
+{
+ struct GNUNET_GNSRECORD_Data rd;
+ struct GNUNET_IDENTITY_Ego *caller_id;
+
+ caller_id = GCG_EGOS_get_selected_ego ();
+ if (NULL == caller_id)
+ {
+ GCG_log ("%s\n",
+ _("No ego selected, phone is now down."));
+ phone_state = PS_LOOKUP_EGO;
+ do_status();
+ return;
+ }
+ phone =
+ GNUNET_CONVERSATION_phone_create (GCG_get_configuration (),
+ caller_id,
+ &phone_event_handler,
+ NULL);
+ if (NULL == phone)
+ {
+ GCG_log ("%s",
+ _("Failed to setup phone (internal error)\n"));
+ phone_state = PS_ERROR;
+ do_status();
+ return;
+ }
+ GNUNET_CONVERSATION_phone_get_record (phone,
+ &rd);
+ /* FIXME: publish record to GNS! */
+ GCG_log ("%s\n",
+ _("Phone active"));
+ phone_state = PS_LISTEN;
+ do_status();
+}
+
+
+/**
+ * Function called with an event emitted by a call.
+ *
+ * @param cls closure, NULL
+ * @param code type of the event on the call
+ */
+static void
+call_event_handler (void *cls,
+ enum GNUNET_CONVERSATION_CallEventCode code)
+{
+ //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);
+ }
+ //}
+}
+
+
+
+/**
+ * Initiating a new call
+ *
+ * @param arg arguments given to the command
+ */
+void
+GSC_do_call (const char *arg)
+{
+ GtkEntry *address_entry;
+ struct GNUNET_IDENTITY_Ego *caller_id;
+
+ address_entry = GTK_ENTRY (GCG_get_main_window_object
("GNUNET_GTK_conversation_address"));
+ gtk_entry_set_text (address_entry,
+ address);
+ caller_id = GCG_EGOS_get_selected_ego ();
+ if (NULL == caller_id)
+ {
+ // should not be possible!
+ GCG_log ("%s\n",
+ _("Caller ID unavailable, cannot initiate call."));
+ return;
+ }
+ if (NULL != call)
+ {
+ GCG_log (_("You are calling someone else already, hang up first!\n"));
+ return;
+ }
+ switch (phone_state)
+ {
+ case PS_LOOKUP_EGO:
+ GCG_log ("%s\n",
+ _("Caller ID unavailable, cannot initiate call."));
+ // should not be possible!
+ return;
+ case PS_LISTEN:
+ /* ok to call! */
+ break;
+ case PS_ACCEPTED:
+ GCG_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 */
+ break;
+ }
+ //GNUNET_free_non_null (peer_name);
+ peer_name = GNUNET_strdup (arg);
+ GCG_log (_("now calling: %s"), peer_name);
+ call_state = CS_RESOLVING;
+ GNUNET_assert (NULL == call);
+
+ call_counter++;
+ call =
+ GNUNET_CONVERSATION_call_start (GCG_get_configuration (),
+ caller_id,
+ arg,
+ speaker, mic,
+ &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
+ );
+
+
+ GCG_update_status_bar (_("We are calling `%s', his phone should be
ringing."),
+ peer_name);
+ GCG_HISTORY_add (CH_OUTGOING,
+ peer_name);
+}
+
+
+/**
+ * Accepting an incoming call
+ *
+ * @param args arguments given to the command
+ */
+static void
+do_accept (struct GNUNET_CONVERSATION_Caller *sel_caller)
+{
+ struct CallList *cl;
+ //char buf[32];
+
+
+ if ((NULL != call) && (CS_SUSPENDED != call_state))
+ {
+ GCG_log (_("You are calling someone else already, hang up first!\n"));
+ GNUNET_break(0);
+ return;
+ }
+ switch (phone_state)
+ {
+ case PS_LOOKUP_EGO:
+ GNUNET_break (0);
+ break;
+ case PS_LISTEN:
+ /* this is the expected state */
+ break;
+ case PS_ACCEPTED:
+ GCG_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
+
+ phone_state = PS_ACCEPTED;
+ set_incoming_call_state(sel_caller,CT_active);
+
+ for (cl = cl_head; cl; cl = cl->next)
+ {
+ /* FIXME: this may not be unique enough to identify the right item!
+ * Why not store CallList items in treeview instead of just callers?
+ */
+ if (cl->caller == sel_caller)
+ break;
+ }
+ GNUNET_CONVERSATION_caller_pick_up (sel_caller,
+ &caller_event_handler, cl,
+ speaker, mic);
+ GCG_HISTORY_add (CH_ACCEPTED, peer_name);
+}
+
+
+/**
+ * Suspending a call
+ *
+ * @param args arguments given to the command
+ */
+static void
+do_suspend ()
+{
+ /*
+ switch (phone_state)
+ {
+ 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)"));
+ return;
+ case PS_ACCEPTED:
+ // expected state, do rejection logic
+ break;
+ }
+ */
+ if (call_selected != NULL && caller_selected != NULL)
+ {
+ GCG_log("this shoud not be possible");
+ GNUNET_break(0);
+ }
+ else
+ {
+ // 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;
+
+ }
+ }
+}
+
+
+/**
+ * Resuming a call
+ *
+ * @param args arguments given to the command
+ */
+static void
+do_resume ()
+{
+
+ 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)"));
+ return;
+ case PS_LISTEN:
+ break;
+ case PS_ACCEPTED:
+ GCG_log (_("Already talking with `%s', cannot resume a call right now."),
+ peer_name);
+ return;
+ }
+////
+ if (call_selected != NULL && caller_selected != NULL)
+ {
+ GCG_log("this shoud not be possible");
+ GNUNET_break(0);
+ return;
+ }
+ else
+ {
+
+ // 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);
+ }
+
+//
+////
+}
+
+
+/**
+ / Rejecting a call
+ *
+ * @param args arguments given to the command
+ */
+static void
+do_reject ()
+{
+ if (call_selected == NULL && caller_selected == NULL)
+ {
+ GNUNET_break(0);
+ }
+ else
+ {
+ // 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);
+ }
+ }
+ }
+}
+
+
+/**
+ * hangup clicked
+ */
+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)
+ {
+ do_accept (caller_selected);
+ } else {
+ GNUNET_break(0);
+ }
+ do_status();
+}
+
+
+/**
+ * reject clicked
+ */
+void
+GNUNET_CONVERSATION_GTK_on_reject_clicked ()
+{
+ do_reject ();
+ do_status();
+}
+
+
+/**
+ * User clicked the '> contact' button to move the selected
+ * caller's information into our address book.
+ */
+void
+GNUNET_CONVERSATION_GTK_use_current_button_clicked (GtkButton *button,
+ gpointer *user_data)
+{
+ // FIXME: implement, use "GSC_add_contact"
+#if 0
+ GtkEntry *addressEntry;
+
+ addressEntry = GTK_ENTRY (GCG_get_main_window_object
("GNUNET_GTK_conversation_addressAdd"));
+ gtk_entry_set_text (addressEntry,
+ "FIXME");
+#endif
+}
+
+
+
+/**
+ * pause clicked
+ */
+void
+GNUNET_CONVERSATION_GTK_on_pause_clicked ()
+{
+ do_suspend ();
+ do_status();
+}
+
+/**
+ * resume clicked
+ */
+void
+GNUNET_CONVERSATION_GTK_on_resume_clicked ()
+{
+ do_resume ();
+ do_status();
+}
+
+/**
+ * status clicked
+ */
+void
+GNUNET_CONVERSATION_GTK_on_status_clicked ()
+{
+ do_status ();
+}
+
+
+/**
+ * call clicked
+ */
+void
+GNUNET_CONVERSATION_GTK_on_call_clicked ()
+{
+ GtkEntry *address_entry;
+
+ address_entry = GTK_ENTRY (GCG_get_main_window_object
("GNUNET_GTK_conversation_address"));
+
+ GSC_do_call (gtk_entry_get_text(address_entry));
+ //disable_button ("GNUNET_GTK_conversation_accept_button");
+ do_status ();
+// free(to_addr);
+}
+
+
+/**
+ * @brief outgoing ego selector changed, (re)start the phone.
+ *
+ * @param widget the combo box that changed
+ * @param user_data builder (unused)
+ */
+void
+gnunet_conversation_gtk_ego_combobox_changed_cb (GtkComboBox *widget,
+ gpointer user_data)
+{
+ if (NULL != phone)
+ {
+ GNUNET_CONVERSATION_phone_destroy (phone);
+ phone = NULL;
+ }
+ start_phone();
+}
+
+
+void
+GCG_PHONE_init ()
+{
+ const struct GNUNET_CONFIGURATION_Handle *cfg;
+
+ cfg = GCG_get_configuration ();
+ speaker = GNUNET_SPEAKER_create_from_hardware (cfg);
+ mic = GNUNET_MICROPHONE_create_from_hardware (cfg);
+ /* get gui objects */
+ b_contact = GTK_WIDGET (GCG_get_main_window_object
+ ("GNUNET_GTK_conversation_use_current_button"));
+ b_accept = GTK_WIDGET (GCG_get_main_window_object
+ ("GNUNET_GTK_conversation_accept_button"));
+ b_hangup = GTK_WIDGET (GCG_get_main_window_object
+ ("GNUNET_GTK_conversation_hangup_button"));
+ b_suspend = GTK_WIDGET (GCG_get_main_window_object
+ ("GNUNET_GTK_conversation_suspend_button"));
+ b_resume = GTK_WIDGET (GCG_get_main_window_object
+ ("GNUNET_GTK_conversation_resume_button"));
+
+ active_liststore =
+ GTK_LIST_STORE (GCG_get_main_window_object
+ ("gnunet_conversation_gtk_active_calls_liststore"));
+ active_treeview =
+ GTK_TREE_VIEW (GCG_get_main_window_object
+ ("gnunet_conversation_gtk_active_calls_treeview"));
+}
+
+
+void
+GCG_PHONE_shutdown ()
+{
+//TODO: make this work
+ //struct OperationContext *oc;
+
+/*
+ GCG_advertise_shutdown_ ();
+ while (NULL != (oc = oc_head))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ _("Operation not completed due to shutdown\n"));
+ GNUNET_IDENTITY_cancel (oc->op);
+ GNUNET_CONTAINER_DLL_remove (oc_head,
+ oc_tail,
+ oc);
+ GNUNET_free (oc);
+ }
+ */
+ if (NULL != call)
+ {
+ GNUNET_CONVERSATION_call_stop (call);
+ call = NULL;
+ }
+ if (NULL != phone)
+ {
+ GNUNET_CONVERSATION_phone_destroy (phone);
+ phone = NULL;
+ }
+ GNUNET_SPEAKER_destroy (speaker);
+ speaker = NULL;
+ GNUNET_MICROPHONE_destroy (mic);
+ mic = NULL;
+ GNUNET_free_non_null (peer_name);
+ peer_name = NULL;
+ phone_state = PS_ERROR;
+}
Modified: gnunet-gtk/src/conversation/gnunet-conversation-gtk_phone.h
===================================================================
--- gnunet-gtk/src/conversation/gnunet-conversation-gtk_phone.h 2014-05-26
17:23:39 UTC (rev 33400)
+++ gnunet-gtk/src/conversation/gnunet-conversation-gtk_phone.h 2014-05-26
19:13:52 UTC (rev 33401)
@@ -0,0 +1,49 @@
+/*
+ This file is part of GNUnet.
+ (C) 2010-2014 Christian Grothoff (and other contributing authors)
+
+ GNUnet is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published
+ by the Free Software Foundation; either version 3, or (at your
+ option) any later version.
+
+ GNUnet is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GNUnet; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+/**
+ * @file src/conversation/gnunet-conversation-gtk_phone.h
+ * @brief main logic to manage phone calls
+ * @author yids
+ * @author hark
+ */
+#ifndef GNUNET_CONVERSATION_GTK_PHONE_H
+#define GNUNET_CONVERSATION_GTK_PHONE_H
+
+
+
+/**
+ * Initiate a call to the given address.
+ *
+ * @param address address to call
+ */
+void
+GSC_do_call (const char *address);
+
+
+void
+GCG_PHONE_init (void);
+
+
+void
+GCG_PHONE_shutdown (void);
+
+
+#endif
Added: gnunet-gtk/src/conversation/gnunet-conversation-gtk_zones.c
===================================================================
--- gnunet-gtk/src/conversation/gnunet-conversation-gtk_zones.c
(rev 0)
+++ gnunet-gtk/src/conversation/gnunet-conversation-gtk_zones.c 2014-05-26
19:13:52 UTC (rev 33401)
@@ -0,0 +1,148 @@
+/*
+ This file is part of GNUnet.
+ (C) 2013-2014 Christian Grothoff (and other contributing authors)
+
+ GNUnet is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published
+ by the Free Software Foundation; either version 3, or (at your
+ option) any later version.
+
+ GNUnet is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GNUnet; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+/**
+ * @file src/conversation/gnunet-conversation-gtk_zones.c
+ * @brief manages the widget which shows the zones (to select
+ * which one will be used to populate the address book)
+ * @author yids
+ * @author hark
+ * @author Christian Grothoff
+ */
+#include "gnunet-conversation-gtk.h"
+#include "gnunet-conversation-gtk_zones.h"
+
+
+/**
+ * Columns in the #zone_liststore.
+ */
+enum ZoneListstoreValues
+{
+ /**
+ * Human-readable name of the ego.
+ */
+ ZONE_LS_NAME = 0,
+
+ /**
+ * Handel to the ego (of type `struct GNUNET_IDENTITY_Ego *ego`).
+ */
+ ZONE_LS_EGO = 1
+};
+
+
+/**
+ * Handle to identity service.
+ */
+static struct GNUNET_IDENTITY_Handle *id;
+
+/**
+ * list of zones
+ */
+static GtkListStore *zone_liststore;
+
+
+/**
+ * Function called by identity service with information about zones.
+ *
+ * @param cls NULL
+ * @param ego ego handle for the zone
+ * @param ctx unused
+ * @param name name of the zone
+ */
+static void
+identity_cb (void *cls,
+ struct GNUNET_IDENTITY_Ego *ego,
+ void **ctx,
+ const char *name)
+{
+ GtkTreeIter iter;
+ GtkTreeRowReference *rr;
+ GtkTreePath *path;
+
+ rr = *ctx;
+ if (NULL == rr)
+ {
+ /* new identity */
+ GNUNET_assert (NULL != name);
+ gtk_list_store_insert_with_values (zone_liststore,
+ &iter, -1,
+ ZONE_LS_NAME, name,
+ ZONE_LS_EGO, ego,
+ -1);
+ path = gtk_tree_model_get_path (GTK_TREE_MODEL (zone_liststore),
+ &iter);
+ rr = gtk_tree_row_reference_new (GTK_TREE_MODEL (zone_liststore),
+ path);
+ gtk_tree_path_free (path);
+ *ctx = rr;
+ return;
+ }
+ /* existing ego, locate and execute rename/delete */
+ path = gtk_tree_row_reference_get_path (rr);
+ gtk_tree_model_get_iter (GTK_TREE_MODEL (zone_liststore),
+ &iter,
+ path);
+ gtk_tree_path_free (path);
+ if (NULL == name)
+ {
+ /* deletion operation */
+ gtk_tree_row_reference_free (rr);
+ *ctx = NULL;
+ gtk_list_store_remove (zone_liststore,
+ &iter);
+ return;
+ }
+ /* rename operation */
+ gtk_list_store_set (zone_liststore,
+ &iter,
+ ZONE_LS_NAME, &name,
+ -1);
+}
+
+
+/**
+ * Initialize the zones list
+ */
+void
+GCG_ZONES_init ()
+{
+ zone_liststore
+ = GTK_LIST_STORE (GCG_get_main_window_object
+ ("gnunet_conversation_gtk_contacts_zone_liststore"));
+ id = GNUNET_IDENTITY_connect (GCG_get_configuration (),
+ &identity_cb,
+ NULL);
+}
+
+
+/**
+ * Shutdown the zone list
+ */
+void
+GCG_ZONES_shutdown ()
+{
+ if (NULL != id)
+ {
+ GNUNET_IDENTITY_disconnect (id);
+ id = NULL;
+ }
+}
+
+/* end of gnunet-conversation-gtk_zones.c */
Added: gnunet-gtk/src/conversation/gnunet-conversation-gtk_zones.h
===================================================================
--- gnunet-gtk/src/conversation/gnunet-conversation-gtk_zones.h
(rev 0)
+++ gnunet-gtk/src/conversation/gnunet-conversation-gtk_zones.h 2014-05-26
19:13:52 UTC (rev 33401)
@@ -0,0 +1,46 @@
+/*
+ This file is part of GNUnet.
+ (C) 2010-2014 Christian Grothoff (and other contributing authors)
+
+ GNUnet is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published
+ by the Free Software Foundation; either version 3, or (at your
+ option) any later version.
+
+ GNUnet is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GNUnet; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+/**
+ * @file src/conversation/gnunet-conversation-gtk_zones.h
+ * @brief manages the widget which shows the zones (to select
+ * which one will be used to populate the address book)
+ * @author yids
+ * @author hark
+ * @author Christian Grothoff
+ */
+#ifndef GNUNET_CONVERSATION_GTK_ZONES_H
+#define GNUNET_CONVERSATION_GTK_ZONES_H
+
+
+/**
+ * Initialize the contact list
+ */
+void
+GCG_ZONES_init (void);
+
+
+/**
+ * Shutdown the contact list
+ */
+void
+GCG_ZONES_shutdown(void);
+
+#endif
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r33401 - gnunet-gtk/src/conversation,
gnunet <=