[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r32361 - gnunet-gtk/src/conversation
From: |
gnunet |
Subject: |
[GNUnet-SVN] r32361 - gnunet-gtk/src/conversation |
Date: |
Mon, 17 Feb 2014 01:43:34 +0100 |
Author: hark
Date: 2014-02-17 01:43:33 +0100 (Mon, 17 Feb 2014)
New Revision: 32361
Added:
gnunet-gtk/src/conversation/gnunet-conversation-gtk_common.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_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
Modified:
gnunet-gtk/src/conversation/Makefile.am
gnunet-gtk/src/conversation/gnunet-conversation-gtk.c
gnunet-gtk/src/conversation/gnunet-conversation-gtk.h
Log:
split stuff up in multiple files
Modified: gnunet-gtk/src/conversation/Makefile.am
===================================================================
--- gnunet-gtk/src/conversation/Makefile.am 2014-02-16 20:37:03 UTC (rev
32360)
+++ gnunet-gtk/src/conversation/Makefile.am 2014-02-17 00:43:33 UTC (rev
32361)
@@ -13,7 +13,14 @@
gnunet_conversation_gtk_SOURCES = \
gnunet-conversation-gtk.c \
- gnunet-conversation-gtk_about.c
+ gnunet-conversation-gtk.h \
+ gnunet-conversation-gtk_phone.c \
+ gnunet-conversation-gtk_phone.h \
+ gnunet-conversation-gtk_contacts.c \
+ gnunet-conversation-gtk_contacts.h \
+ gnunet-conversation-gtk_history.c \
+ gnunet-conversation-gtk_history.h \
+ gnunet-conversation-gtk_about.c
gnunet_conversation_gtk_LDADD = \
$(top_builddir)/src/lib/libgnunetgtk.la \
Modified: gnunet-gtk/src/conversation/gnunet-conversation-gtk.c
===================================================================
--- gnunet-gtk/src/conversation/gnunet-conversation-gtk.c 2014-02-16
20:37:03 UTC (rev 32360)
+++ gnunet-gtk/src/conversation/gnunet-conversation-gtk.c 2014-02-17
00:43:33 UTC (rev 32361)
@@ -24,54 +24,314 @@
* @author yids
* @author hark
*/
-#include "gnunet_gtk.h"
-#include "gtk/gtk.h"
-#include "gnunet-conversation-gtk.h"
-#include "gnunet/gnunet_gnsrecord_lib.h"
-#include "gnunet/gnunet_conversation_service.h"
-#include "gnunet/gnunet_identity_service.h"
-#include "gnunet/gnunet_namestore_service.h"
-#include "gnunet/gnunet_speaker_lib.h"
-#include "gnunet/gnunet_microphone_lib.h"
-#include "gnunet/gnunet_namestore_service.h"
-#include "gnunet/gnunet_gnsrecord_lib.h"
-#include <time.h>
+#include "gnunet-conversation-gtk_common.h"
+//#include "gnunet-conversation-gtk.h"
+#include "gnunet-conversation-gtk_history.h"
+#include "gnunet-conversation-gtk_contacts.h"
+//#include "gnunet-conversation-gtk_phone.h"
-/**
- * macro's
- */
-#define UPDATE_STATUS(format, ...) update_status(g_strdup_printf (format, ##
__VA_ARGS__))
+/***********
+ * macro's *
+ ***********/
+//#define UPDATE_STATUS(format, ...) update_status(g_strdup_printf (format, ##
__VA_ARGS__))
+
//#define UPDATE_INFOBAR(format, ...) set_infobar_text(g_strdup_printf
(format, ## __VA_ARGS__))
-#define LOG(format, ...) log_message(g_strdup_printf (format, ## __VA_ARGS__))
+//#define get_object(name) GNUNET_CONVERSATION_GTK_get_main_window_object(name)
+//#define LOG(format, ...) log_message(g_strdup_printf (format, ##
__VA_ARGS__))
+
struct GNUNET_CONVERSATION_Caller *caller_selected = NULL;
-//caller_selected = NULL;
+/*************
+ * common *
+ *************/
+
/**
- * Get an object from the main window.
+ * Get our configuration.
*
- * @param name name of the object
- * @return NULL on error
+ * @return configuration handle
*/
+const struct GNUNET_CONFIGURATION_Handle *
+GIG_get_configuration ();
-static GObject *
-get_object (const char *name)
+/**
+ * Our configurations.
+ */
+static struct GNUNET_CONFIGURATION_Handle *cfg;
+/**
+ * Name of our ego.
+ */
+static char *ego_name;
+
+
+//static struct GNUNET_CONFIGURATION_Handle *cfg1;
+//static struct GNUNET_CONFIGURATION_Handle *cfg2;
+/**
+ * Be verbose.
+ */
+static int verbose = 1;
+
+
+/**
+ * Should gnunet-identity-gtk start in tray mode?
+ */
+static int tray_only;
+
+/**
+ * Head of operations.
+ */
+//static struct OperationContext *oc_head;
+
+/**
+ * Tail of operations.
+ */
+//static struct OperationContext *oc_tail;
+
+
+
+/*************
+ * phone *
+ *************/
+
+/**
+ * Current state of iterating elements for the client.
+ * NULL if we are not currently iterating.
+ */
+struct GNUNET_CONTAINER_MultiHashMapIterator *iter;
+
+/**
+ *name of the incomming caller pkey or record name if known
+ */
+char *callerName;
+
+/**
+* peer id of a contact
+*/
+char *peer_id;
+
+/**
+* incoming call popup window, global because must be destroyed when other end
hangs up
+*/
+GtkDialog *dialog;
+
+/**
+ * List of active calls
+ */
+ static GtkListStore *active_liststore;
+
+ /**
+ * List of active calls
+ */
+ static GtkTreeView *active_treeview;
+
+
+
+
+/**
+ * List of incoming calls
+ */
+struct CallList
{
- return GNUNET_GTK_main_loop_get_object (ml, name);
+
+ /**
+ * 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 call.
+ */
+ unsigned int caller_num;
+
+};
+
+
+
+/**
+ * Phone handle
+ */
+static struct GNUNET_CONVERSATION_Phone *phone;
+
+/**
+ * Call handle (for active outgoing call).
+ */
+static struct GNUNET_CONVERSATION_Call *call;
+//static struct GtkTreeIter gcall;
+
+/**
+ * Caller handle (for active incoming call).
+ */
+static struct CallList *cl_active;
+//static GtkTreeIter gcl_active;
+
+/**
+ * Head of calls waiting to be accepted.
+ */
+static struct CallList *cl_head;
+//gtk
+//static GtkTreeIter gcl_head;
+
+/**
+ * currently selected call
+ */
+//static GtkTreeIter gcl_selected;
+
+/**
+ * Tail of calls waiting to be accepted.
+ */
+static struct CallList *cl_tail;
+//static GtkTreeIter gcl_tail;
+
+/**
+ * Desired phone line.
+ */
+static unsigned int line;
+
+//static unsigned int line1;
+/**
+ * debug box enabled
+ */
+
+static unsigned int debug_box_enabled;
+
+
+
+/**
+ * Our speaker.
+ */
+static struct GNUNET_SPEAKER_Handle *speaker;
+
+/**
+ * Our microphone.
+ */
+static struct GNUNET_MICROPHONE_Handle *mic;
+
+/**
+ * Handle to identity service.
+ */
+static struct GNUNET_IDENTITY_Handle *id;
+
+/**
+ * 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;
+/*******************
+ * identity select *
+ *******************/
+
+
+/**
+ * list of zones
+ */
+static GtkListStore *zone_liststore;
+
+/**
+ * zone treestore
+ */
+static GtkTreeStore *zone_treestore;
+
+/**
+ * zone treeview
+ */
+static GtkTreeView *zone_treeview;
+
+/**
+ * zone tree model
+ */
+static GtkTreeModel *zone_treemodel;
+
+
+/**
+ * Global return value
+ */
+static int ret;
+
+/**
+ * Our ego.
+ */
+static struct GNUNET_IDENTITY_Ego *caller_id;
+
+
+/**
+ * Handle to our main loop.
+ */
+static struct GNUNET_GTK_MainLoop *ml;
+
+
+
+
+
+//////////////////////////////////////////////////
+/************
+ * extern's *
+ * **********/
+
+
+/**
+ * * Get an object from the main window.
+ * *
+ * * @param name name of the object
+ * * @return NULL on error
+ * */
+extern GObject *
+GNUNET_CONVERSATION_GTK_get_main_window_object (const char *name)
+{
+ return GNUNET_GTK_main_loop_get_object (ml, name);
}
+
/**
* log a message to gtk log textbuffer
* @param Message to be logged
*/
-void
-log_message (const char *message)
+extern void
+GNUNET_CONVERSATION_GTK_log_message (const char *message)
{
//
// log
@@ -95,6 +355,7 @@
}
+
/**
* does nothing
*/
@@ -168,47 +429,6 @@
/*
- * adds a item to the call history
- *
- * @param type type of call: 0: accepted 1: rejected 2: outgoing call
- * @return void
- */
-
-void
-history_add (int type, char *contactName)
-{
- GtkTreeIter iter;
- time_t t;
- char *event;
-
- switch (type)
- {
- case CH_ACCEPTED:
- event = "Accepted";
- break;
- case CH_REJECTED:
- event = "Rejected";
- break;
- case CH_OUTGOING:
- event = "Outgoing";
- break;
- case CH_HANGUP:
- event = "Hangup";
- break;
- case CH_MISSED:
- event = "Missed";
- break;
- default:
- event = "UNKNOWN";
- break;
- }
- time (&t);
- gtk_list_store_append (history_liststore, &iter);
- gtk_list_store_set (history_liststore, &iter, 1, event, 0, ctime (&t), 2,
- contactName, -1);
-}
-
-/*
* set button text
* @param button_name name of button
* @param label label on the button
@@ -546,7 +766,7 @@
*
* @param arg arguments given to the command
*/
-static void
+extern void
do_call (const char *arg)
{
if (NULL == caller_id)
@@ -586,7 +806,7 @@
&call_event_handler, NULL);
UPDATE_STATUS (_("We are calling `%s', his phone should be ringing."),
peer_name);
- history_add (CH_OUTGOING, peer_name);
+ GNUNET_CONVERSATION_GTK_history_add (CH_OUTGOING, peer_name);
}
@@ -660,7 +880,7 @@
GNUNET_CONVERSATION_caller_pick_up (sel_caller, &caller_event_handler, cl,
speaker, mic);
- history_add (CH_ACCEPTED, peer_name);
+ GNUNET_CONVERSATION_GTK_history_add (CH_ACCEPTED, peer_name);
}
@@ -931,7 +1151,7 @@
break;
case PS_ACCEPTED:
/* expected state, do rejection logic */
- history_add (CH_REJECTED, peer_name);
+ GNUNET_CONVERSATION_GTK_history_add (CH_REJECTED, peer_name);
/*
GNUNET_assert (NULL != cl_active);
GNUNET_CONVERSATION_caller_hang_up (cl_active->caller);
@@ -954,141 +1174,7 @@
-////////////////////////////
-
-
-static void
-display_record (void *cls, const struct GNUNET_CRYPTO_EcdsaPrivateKey
*zone_key,
- const char *rname, unsigned int rd_len,
- const struct GNUNET_GNSRECORD_Data *rd)
-{
- const char *typestring;
- char *s, *type;
- unsigned int i;
- const char *ets;
- struct GNUNET_TIME_Absolute at;
- struct GNUNET_TIME_Relative rt;
- GtkTreeIter display_iter;
-
- if (NULL == rname)
- {
- list_it = NULL;
- //test_finished ();
- return;
- }
- for (i = 0; i < rd_len; i++)
- {
-
- if ((GNUNET_GNSRECORD_TYPE_NICK == rd[i].record_type) &&
- (0 != strcmp (rname, "+")))
- continue;
- typestring = GNUNET_GNSRECORD_number_to_typename (rd[i].record_type);
- s = GNUNET_GNSRECORD_value_to_string (rd[i].record_type, rd[i].data,
- rd[i].data_size);
- if (NULL == s)
- {
- FPRINTF (stdout, _("\tCorrupt or unsupported record of type %u\n"),
- (unsigned int) rd[i].record_type);
- continue;
- }
- if (0 != (rd[i].flags & GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION))
- {
- rt.rel_value_us = rd[i].expiration_time;
- ets = GNUNET_STRINGS_relative_time_to_string (rt, GNUNET_YES);
- }
- else
- {
- at.abs_value_us = rd[i].expiration_time;
- ets = GNUNET_STRINGS_absolute_time_to_string (at);
- }
- if (rd[i].record_type == 65536)
- {
- type = "PKEY";
- } // if pubkey record
- if (rd[i].record_type == 65542)
- {
- type = "PHONE";
- }
-// FPRINTF (stdout, "%s", rname);
- if (rd[i].record_type == 65536 || rd[i].record_type == 65542)
- {
- gtk_list_store_append (contacts_liststore, &display_iter);
- gtk_list_store_set (contacts_liststore, &display_iter, 1, type, 0,
rname, -1);
- }
-
-/* FPRINTF (stdout,
- "\t%s: %s (%s)\t%s\t%s\t%s\n",
- typestring,
- s,
- ets,
- (0 != (rd[i].flags & GNUNET_GNSRECORD_RF_PRIVATE)) ?
"PRIVATE" : "PUBLIC",
- (0 != (rd[i].flags & GNUNET_GNSRECORD_RF_SHADOW_RECORD)) ?
"SHADOW" : "",
- (0 != (rd[i].flags & GNUNET_GNSRECORD_RF_PENDING)) ?
"PENDING" : "");
-*/
- //gtk_widget_show(contacts_liststore);
- GNUNET_free (s);
- }
-// FPRINTF (stdout, "%s", "\n");
- GNUNET_NAMESTORE_zone_iterator_next (list_it);
-}
-
/**
- * Continuation called to notify client about result of the
- * operation.
- *
- * @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)
- ret = 1;
- }
- 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 ();
-}
-
-
-/**
* Function called by identity service with information about egos.
*
* @param cls NULL
@@ -1137,12 +1223,10 @@
}
caller_id = ego;
GNUNET_CONFIGURATION_set_value_number (cfg, "CONVERSATION", "LINE", line);
- zone_pkey = *GNUNET_IDENTITY_ego_get_private_key (caller_id);
- ns = GNUNET_NAMESTORE_connect (cfg);
+ //zone_pkey = *GNUNET_IDENTITY_ego_get_private_key (caller_id);
+ // ns = GNUNET_NAMESTORE_connect (cfg);
- list_it =
- GNUNET_NAMESTORE_zone_iteration_start (ns, &zone_pkey, &display_record,
- NULL);
+
if (NULL == phone)
start_phone();
}
@@ -1224,11 +1308,11 @@
GNUNET_IDENTITY_disconnect (id);
id = NULL;
}
- if (NULL != ns)
- {
- GNUNET_NAMESTORE_disconnect (ns);
- ns = NULL;
- }
+ //if (NULL != ns)
+ //{
+ // GNUNET_NAMESTORE_disconnect (ns);
+ // ns = NULL;
+ //}
GNUNET_SPEAKER_destroy (speaker);
speaker = NULL;
@@ -1241,7 +1325,6 @@
GNUNET_SCHEDULER_shutdown ();
- GNUNET_CRYPTO_ecdsa_key_clear (&zone_pkey);
//return 0;
}
@@ -1257,7 +1340,6 @@
static void
run (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
- GtkTreeIter iterContactsInit;
GtkWindow *main_window;
//line = 0;
@@ -1280,37 +1362,14 @@
active_treeview =
GTK_TREE_VIEW (get_object
("gnunet_conversation_gtk_active_calls_treeview"));
+ GNUNET_CONVERSATION_GTK_history_init();
- // contacts
- contacts_liststore =
- GTK_LIST_STORE (get_object
- ("gnunet_conversation_gtk_contacts_liststore"));
- contacts_treeview =
- GTK_TREE_VIEW (get_object ("gnunet_conversation_gtk_treeview"));
- contacts_treemodel = GTK_TREE_MODEL (contacts_liststore);
-
- // call history
- history_liststore =
- GTK_LIST_STORE (get_object
("gnunet_conversation_gtk_history_liststore"));
- history_treeview =
- GTK_TREE_VIEW (get_object ("gnunet_conversation_gtk_history_treeview"));
- history_treestore =
- GTK_TREE_STORE (get_object
("gnunet_conversation_gtk_history_treestore"));
- history_treemodel = GTK_TREE_MODEL (history_treestore);
-
- // zone list
- zone_liststore =
- GTK_LIST_STORE (get_object
("gnunet_conversation_gtk_contacts_zone_liststore"));
zone_treeview =
GTK_TREE_VIEW (get_object ("gnunet_conversation_gtk_zone_treeview"));
- zone_treestore =
- GTK_TREE_STORE (get_object
("gnunet_conversation_gtk_contacts_zone_treestore"));
- zone_treemodel = GTK_TREE_MODEL (zone_liststore);
+
+ //gtk_tree_view_set_activate_on_single_click(contacts_treeview, TRUE);
- //gtk_tree_view_set_activate_on_single_click(contacts_treeview, TRUE);
-
- GNUNET_assert (NULL != contacts_liststore);
-
+
// gtk_window_maximize (GTK_WINDOW (main_window));
if (NULL == getenv ("GNUNET_CONVERSATION_GTK_PLUG"))
@@ -1348,15 +1407,9 @@
LOG (_("No ego given, using default: %s "), ego_name);
}
-
id = GNUNET_IDENTITY_connect (cfg, &identity_cb, NULL);
-
- gtk_tree_model_get_iter_first(zone_treemodel, &iterContactsInit);
- gtk_tree_model_iter_next(zone_treemodel, &iterContactsInit);
- gtk_combo_box_set_active_iter(GTK_WIDGET (get_object
("gnunet_conversation_gtk_contacts_zone_combobox")), &iterContactsInit);
-// zone_pkey = *GNUNET_IDENTITY_ego_get_private_key (caller_id);
-// gtk_combo_box_set_active(GTK_WIDGET (get_object
("gnunet_conversation_gtk_contacts_zone_combobox")), 1);
-// gtk_combo_box_set_active(GTK_WIDGET (get_object
("gnunet_conversation_gtk_outgoing_zone_combobox")), 1);
+
+ //GNUNET_CONVERSATION_GTK_CONTACTS_init ();
}
@@ -1488,206 +1541,7 @@
}
-/*
- * add a new contact
- * @param name
- * @param address
- */
-void
-add_contact (const gchar * name, const gchar * address)
-{
-// memmove(&address+1,&address+51,1);
- 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 *tempEgo;
- char *tempName;
- GtkTreeIter testIter;
- gtk_combo_box_get_active_iter(GTK_WIDGET (get_object
("gnunet_conversation_gtk_contacts_zone_combobox")), &testIter);
- gtk_tree_model_get (GTK_TREE_MODEL (zone_liststore),
- &testIter,
- 0, &tempName,
- 1, &tempEgo,
- -1);
-
-
- GNUNET_CRYPTO_ecdsa_public_key_from_string (address, strlen (address),
&pkey);
- rde = &rd;
- zone_pkey = *GNUNET_IDENTITY_ego_get_private_key (tempEgo);
- 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, *addressEntry;
-
- nameEntry = GTK_ENTRY (get_object ("GNUNET_GTK_conversation_nameAdd"));
- addressEntry = GTK_ENTRY (get_object ("GNUNET_GTK_conversation_addressAdd"));
- FPRINTF(stderr,"name %s \n", gtk_entry_get_text (nameEntry));
- FPRINTF(stderr,"addr %s \n", gtk_entry_get_text (addressEntry));
-
- 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 (get_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_CONTAINER (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 (caller_id);
- 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;
- }
-
- }
-}
-
-void
-GNUNET_CONVERSATION_GTK_on_current_clicked (GtkButton * button,
- gpointer * user_data)
-{
- GtkEntry *addressEntry;
-// FPRINTF(stderr,"on current clicked %s\n",callerName);
- char *strippedAddress;
- addressEntry = GTK_ENTRY (get_object ("GNUNET_GTK_conversation_addressAdd"));
- currentlySelectedCallAddress[52] = '\0';
- gtk_entry_set_text(addressEntry, currentlySelectedCallAddress);
-
-}
-
-
-/*
- * row activated
- * @return void
- */
-
-void
-GNUNET_CONVERSATION_GTK_row_activated ()
-{
- gchar *callAddress;
- gchar *type;
-
-// FPRINTF (stderr, "row activated \n");
-
- GtkTreeSelection *selection;
-
- GtkTreeIter iterA;
-
-
- selection = gtk_tree_view_get_selection (contacts_treeview);
-
- gtk_tree_selection_get_selected (selection, &contacts_treemodel, &iterA);
- gtk_tree_model_get (contacts_treemodel, &iterA, 0, &name, 1, &type, -1);
-// g_print ("ego name %s\n", ego_name);
-// g_print ("selected row is: %s\n", name);
-// g_print ("selected rowtype is: %s\n", type);
-
-
- g_print ("type @row active%s", type);
- if (strcmp (type, "PKEY") == 0)
- {
- GNUNET_asprintf (&callAddress, "call\.%s\.gnu", name);
- }
- if (strcmp (type, "PHONE") == 0)
- {
- GNUNET_asprintf (&callAddress, "%s\.gnu", name);
- }
-// else { GNUNET_asprintf(&callAddress, "%s", peer_id);}
-
- g_print ("ego name %s\n", callAddress);
- GtkEntry *address_entry;
-
- address_entry = GTK_ENTRY ((get_object ("GNUNET_GTK_conversation_address")));
- gtk_entry_set_text (address_entry, callAddress);
- do_call (callAddress);
-}
-
-/*
-static void
-print_ego (void *cls,
- struct GNUNET_IDENTITY_Ego *ego,
- void **ctx,
- const char *identifier)
-{
- struct GNUNET_CRYPTO_EcdsaPublicKey pk;
- char *s;
- GNUNET_IDENTITY_ego_get_public_key (ego, &pk);
- s = GNUNET_CRYPTO_ecdsa_public_key_to_string (&pk);
- fprintf (stdout, "%s \n", identifier);
-// GNUNET_free (s);
-}
-*/
-
/* end of gnunet-conversation-gtk.c */
void
GNUNET_contact_test ()
@@ -1727,64 +1581,7 @@
}
-GNUNET_IDENTITY_EgoCallback
-setCurrentAddressbookEgo(void *cls, struct GNUNET_IDENTITY_Ego *ego)
-{
- currentAddressBookEgo = ego;
-}
-
-/**
- * A different zone was selected in the zone toggle bar. Load the
- * appropriate zone.
- *
- * @param widget button that was toggled (could be to "on" or "off", we only
react to "on")
- * @param user_data builder, unused
- */
void
-gnunet_conversation_gtk_contacts_zone_combobox_changed_cb (GtkComboBox *widget,
- gpointer user_data)
-{
- GtkTreeIter contacts_zone_iter;
- struct GNUNET_IDENTITY_Ego *tempEgo;
- char *tempName;
- struct GNUNET_CRYPTO_EcdsaPrivateKey temp_zone_pkey;
- GtkTreeSelection *selection;
- GtkTreeIter iterA;
-
-
- gtk_combo_box_get_active_iter(widget, &contacts_zone_iter);
-
- gtk_tree_model_get (GTK_TREE_MODEL (zone_liststore),
- &contacts_zone_iter,
- 0, &tempName,
- 1, &tempEgo,
- -1);
-// FPRINTF(stderr,"blat: %s\n", tempName);
- temp_zone_pkey = *GNUNET_IDENTITY_ego_get_private_key (tempEgo);
- gtk_list_store_clear(contacts_liststore);
-/*
- GNUNET_IDENTITY_ego_lookup (cfg,
- tempName,
- setCurrentAddressbookEgo,
- NULL);
-*/
- //selection = gtk_tree_view_get_selection (zone_treeview);
-
- //gtk_tree_selection_get_selected (selection, &zone_treemodel, &iterA);
-
- //gtk_tree_model_get_iter_first(zone_treemodel, &iterA);
- //gtk_tree_model_get (zone_treemodel, &iterA, 0, &tempName, 1, &tempEgo, -1);
-
-
- list_it =
- GNUNET_NAMESTORE_zone_iteration_start (ns, &temp_zone_pkey,
&display_record,
- NULL);
-
-// GNUNET_IDENTITY_disconnect (id);
-
-}
-
-void
gnunet_conversation_gtk_outgoing_zone_combobox_changed_cb (GtkComboBox *widget,
gpointer user_data)
{
@@ -1803,14 +1600,16 @@
0, &tempName,
1, &tempEgo,
-1);
- FPRINTF(stderr,"outgoing ego: %s\n", tempName);
- caller_id = tempEgo;
+ LOG(stderr,"outgoing ego: %s", tempName);
+ // caller_id = tempEgo;
+ /*
if ( NULL != phone)
{
GNUNET_CONVERSATION_phone_destroy (phone);
phone == NULL;
}
start_phone();
+ */
}
/*
@@ -1876,7 +1675,7 @@
gint cl_caller_type;
GtkTreeSelection *active_selection;
GtkTreeIter gcl_selected;
-// active_liststore_selection =
get_object("GNUNET_CONVERSATION_GTK_active_calls_selection");
+// active_liststore_selection =
get_object(ml,"GNUNET_CONVERSATION_GTK_active_calls_selection");
active_selection = gtk_tree_view_get_selection (GTK_TREE_VIEW
(active_treeview));
@@ -2064,11 +1863,11 @@
GtkCellRenderer *cell;
GtkCellRenderer *renderer;
//LOG("test");
-// treeview = get_object("gnunet_conversation_gtk_active_calls_treeview");
+// treeview = get_object(ml,"gnunet_conversation_gtk_active_calls_treeview");
-// column = get_object("GNUNET_CONVERSATION_GTK_caller_typeColumn");
+// column = get_object(ml,"GNUNET_CONVERSATION_GTK_caller_typeColumn");
//cell = gtk_cell_renderer_text_new();
-// cell = get_object("GNUNET_CONVERSATION_GTK_active_calls_type");
+// cell = get_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 = get_object("caller_testcolumn");
Modified: gnunet-gtk/src/conversation/gnunet-conversation-gtk.h
===================================================================
--- gnunet-gtk/src/conversation/gnunet-conversation-gtk.h 2014-02-16
20:37:03 UTC (rev 32360)
+++ gnunet-gtk/src/conversation/gnunet-conversation-gtk.h 2014-02-17
00:43:33 UTC (rev 32361)
@@ -22,9 +22,6 @@
* @file src/identity/gnunet-identity-gtk.h
* @author Christian Grothoff
*/
-#include <gnunet/gnunet_util_lib.h>
-#include <stdbool.h>
-
#ifndef GNUNET_CONVERSATION_GTK_H
#define GNUNET_CONVERSATION_GTK_H
@@ -32,538 +29,19 @@
* macro's
*/
-#define UPDATE_STATUS(format, ...) update_status(g_strdup_printf (format, ##
__VA_ARGS__))
+extern GObject *
+GNUNET_CONVERSATION_GTK_get_main_window_object (const char *);
-#define UPDATE_INFOBAR(format, ...) set_infobar_text(g_strdup_printf (format,
## __VA_ARGS__))
-#define LOG(format, ...) log_message(g_strdup_printf (format, ## __VA_ARGS__))
-
-
-
/**
- * List of active calls
- */
- static GtkListStore *active_liststore;
-
- /**
- * List of active calls
- */
- static GtkTreeView *active_treeview;
-
-
-/*
- * active calls treevieuw columns
+ * log a message to gtk log textbuffer
+ * @param Message to be logged
*/
-enum {
- AL_caller_id, //*gchar
- AL_caller, //*
- AL_caller_num, //gint
- AL_caller_type, //gint
- AL_caller_state //gint
-};
-/**
- * callerstate (state of incoming call)
- */
+extern void
+GNUNET_CONVERSATION_GTK_log_message (const char *);
-enum {
- CT_active,
- CT_suspended,
- CT_ringing,
- CT_dead,
- CT_hangup,
- CT_rejected
-};
+extern void
+do_call(const char*);
-/**
- * type of call
- */
-enum {
- CALL_IN,
- CALL_OUT
-};
-
-
-/**
- * Get our configuration.
- *
- * @return configuration handle
- */
-const struct GNUNET_CONFIGURATION_Handle *
-GIG_get_configuration ();
-
-
-/**
- * Handle to our main loop.
- */
-static struct GNUNET_GTK_MainLoop *ml;
-
-/**
- * Should gnunet-identity-gtk start in tray mode?
- */
-static int tray_only;
-
-/**
- * Head of operations.
- */
-//static struct OperationContext *oc_head;
-
-/**
- * Tail of operations.
- */
-//static struct OperationContext *oc_tail;
-
-/**
- * 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
-};
-
-
-
-/**
- * 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 call.
- */
- unsigned int caller_num;
-
-};
-
-
-
-/**
- * Phone handle
- */
-static struct GNUNET_CONVERSATION_Phone *phone;
-
-/**
- * Call handle (for active outgoing call).
- */
-static struct GNUNET_CONVERSATION_Call *call;
-//static struct GtkTreeIter gcall;
-
-/**
- * Caller handle (for active incoming call).
- */
-static struct CallList *cl_active;
-//static GtkTreeIter gcl_active;
-
-/**
- * Head of calls waiting to be accepted.
- */
-static struct CallList *cl_head;
-//gtk
-//static GtkTreeIter gcl_head;
-
-/**
- * currently selected call
- */
-//static GtkTreeIter gcl_selected;
-
-/**
- * Tail of calls waiting to be accepted.
- */
-static struct CallList *cl_tail;
-//static GtkTreeIter gcl_tail;
-
-/**
- * Desired phone line.
- */
-static unsigned int line;
-
-//static unsigned int line1;
-/**
- * debug box enabled
- */
-
-static unsigned int debug_box_enabled;
-
-
-
-/**
- * Our speaker.
- */
-static struct GNUNET_SPEAKER_Handle *speaker;
-
-/**
- * Our microphone.
- */
-static struct GNUNET_MICROPHONE_Handle *mic;
-
-/**
- * Our configurations.
- */
-static struct GNUNET_CONFIGURATION_Handle *cfg;
-
-//static struct GNUNET_CONFIGURATION_Handle *cfg1;
-//static struct GNUNET_CONFIGURATION_Handle *cfg2;
-
-
-/**
- * Our ego.
- */
-static struct GNUNET_IDENTITY_Ego *caller_id;
-
-/**
- * Handle to identity service.
- */
-static struct GNUNET_IDENTITY_Handle *id;
-
-/**
- * Name of our ego.
- */
-static char *ego_name;
-
-/**
- * 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;
-
-/**
- * Be verbose.
- */
-static int verbose = 1;
-
-/**
- * Handle to the namestore.
- */
-static struct GNUNET_NAMESTORE_Handle *ns;
-
-/**
- * Private key for the our zone.
- */
-struct GNUNET_CRYPTO_EcdsaPrivateKey zone_pkey;
-
-/**
- * Public key of the zone we are currently editing.
- */
-struct GNUNET_CRYPTO_EcdsaPublicKey pubkey;
-
-
-
-/*
- * List iterator for the 'list' operation.
- */
-static struct GNUNET_NAMESTORE_ZoneIterator *list_it;
-
-
-/**
- * Name of the records to add/list/remove.
- */
-static char *name;
-
-static void
-identity_cb (void *cls, struct GNUNET_IDENTITY_Ego *ego, void **ctx,
- const char *name);
-
-
-/**
- * List of contacts (records).
- */
-static GtkListStore *contacts_liststore;
-
-
-/**
- * List of contacts.
- */
-static GtkTreeStore *contacts_treestore;
-
-/**
- * The main tree view for 'gns' that shows the records.
- */
-static GtkTreeView *contacts_treeview;
-
-/**
- * Tree model (same object as 'contacts_treestore', just different type).
- */
-static GtkTreeModel *contacts_treemodel;
-
-
-/**
- * call history liststore
- */
-static GtkListStore *history_liststore;
-
-/**
- * call history treestore
- */
-static GtkTreeStore *history_treestore;
-
-/**
- * call histore treeview
- */
-static GtkTreeView *history_treeview;
-
-/**
- * call history tree model
- */
-static GtkTreeModel *history_treemodel;
-
-
-/**
- * list of zones
- */
-static GtkListStore *zone_liststore;
-
-/**
- * zone treestore
- */
-static GtkTreeStore *zone_treestore;
-
-/**
- * zone treeview
- */
-static GtkTreeView *zone_treeview;
-
-/**
- * zone tree model
- */
-static GtkTreeModel *zone_treemodel;
-
-/**
- * Current state of iterating elements for the client.
- * NULL if we are not currently iterating.
- */
-struct GNUNET_CONTAINER_MultiHashMapIterator *iter;
-
-/**
- *name of the incomming caller pkey or record name if known
-*/
-char *callerName;
-
-/**
-* peer id of a contact
-*/
-char *peer_id;
-
-/**
- * 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;
-
-/**
- * Global return value
- */
-static int ret;
-
-/**
-* incoming call popup window, global because must be destroyed when other end
hangs up
-*/
-GtkDialog *dialog;
-
-/**
- * Context for edit operations and environment for plugins.
- * Typical plugins will only use the @e check_validity callback.
- */
-struct GNUNET_GTK_NAMESTORE_PluginEnvironment
-{
-
- /**
- * Function that should be called by the plugin whenever values in
- * the dialog were edited. It will check the validity of the dialog
- * and update the "save" button accordingly.
- */
- void (*check_validity)(struct GNUNET_GTK_NAMESTORE_PluginEnvironment *edc);
-
- /**
- * Builder for the dialog.
- */
- GtkBuilder *builder;
-
- /**
- * Main dialog window.
- */
- GtkDialog *dialog;
-
- /**
- * Where in the tree view are we editing?
- */
- struct RecordInfo *ri;
-
- /**
- * Name of the record.
- */
- gchar *name;
-
- /**
- * Value of the record in string format.
- */
- gchar *n_value;
-
- /**
- * Name of the zone into which the record should be placed.
- */
- gchar *new_zone_option;
-
- /**
- * Ego of the zone into which the record should be placed.
- */
- struct GNUNET_IDENTITY_Ego *ego;
-
- /**
- * List of all zones.
- */
- GtkListStore *zone_liststore;
-
- /**
- * The plugin we used to edit the value.
- */
- struct GNUNET_GTK_NAMESTORE_PluginFunctions *plugin;
-
- /**
- * Name of the plugin library.
- */
- char *liblow;
-
- /**
- * Expiration time value (absolute or relative).
- */
- guint64 n_exp_time;
-
- /**
- * Offset of the record we are editing in the 'rd' list of 'ri'.
- */
- unsigned int off;
-
- /**
- * Flag indicating if the old record was in the namestore.
- */
- int old_record_in_namestore;
-
- /**
- * Type of the record.
- */
- uint32_t record_type;
-
- /**
- * Is this record 'public'?
- */
- gboolean n_public;
-
- /**
- * Is the expiration time relative?
- */
- gboolean n_is_relative;
-
- /**
- * Is this record a shadow record?
- */
- gboolean n_is_shadow;
-
-};
-
-static struct GNUNET_IDENTITY_Ego *currentAddressBookEgo;
-
-char *currentlySelectedCallAddress;
-
#endif
Added: gnunet-gtk/src/conversation/gnunet-conversation-gtk_common.h
===================================================================
--- gnunet-gtk/src/conversation/gnunet-conversation-gtk_common.h
(rev 0)
+++ gnunet-gtk/src/conversation/gnunet-conversation-gtk_common.h
2014-02-17 00:43:33 UTC (rev 32361)
@@ -0,0 +1,134 @@
+/*
+ * temporary header file
+ */
+
+#include <stdbool.h>
+#include <stdint.h>
+//#include <gnunet/gnunet_util_lib.h>
+
+#include "gtk/gtk.h"
+#include "gnunet_gtk.h"
+#include <time.h>
+
+#include "gnunet_gtk.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"
+/*
+ * macro's
+ */
+#define UPDATE_STATUS(format, ...) update_status(g_strdup_printf (format, ##
__VA_ARGS__))
+
+#define UPDATE_INFOBAR(format, ...) set_infobar_text(g_strdup_printf (format,
## __VA_ARGS__))
+
+#define LOG(format, ...) GNUNET_CONVERSATION_GTK_log_message(g_strdup_printf
(format, ## __VA_ARGS__))
+
+#define get_object(name) GNUNET_CONVERSATION_GTK_get_main_window_object(name)
+
+
+
+
+
+/*
+ * active calls treevieuw columns
+ */
+
+enum {
+ AL_caller_id, //*gchar
+ AL_caller, //*
+ AL_caller_num, //gint
+ AL_caller_type, //gint
+ AL_caller_state //gint
+};
+/**
+ * callerstate (state of incoming call)
+ */
+
+enum {
+ CT_active,
+ CT_suspended,
+ CT_ringing,
+ CT_dead,
+ CT_hangup,
+ CT_rejected
+};
+
+/**
+ * type of call
+ */
+enum {
+ 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
+};
+
+
Added: gnunet-gtk/src/conversation/gnunet-conversation-gtk_contacts.c
===================================================================
--- gnunet-gtk/src/conversation/gnunet-conversation-gtk_contacts.c
(rev 0)
+++ gnunet-gtk/src/conversation/gnunet-conversation-gtk_contacts.c
2014-02-17 00:43:33 UTC (rev 32361)
@@ -0,0 +1,673 @@
+/*
+ This file is part of GNUnet.
+ (C) 2010-2013 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.c
+ * @brief
+ * @author yids
+ * @author hark
+ */
+#include "gnunet-conversation-gtk_common.h"
+#include "gnunet-conversation-gtk.h"
+
+
+//#include "gnunet/gnunet_gnsrecord_lib.h"
+
+
+
+///////////////////
+//addressbook
+//#include "gnunet_gtk.h"
+
+//#include "gnunet/gnunet_identity_service.h"
+//#include "gnunet/gnunet_namestore_service.h"
+//#include "gnunet/gnunet_gnsrecord_lib.h"
+
+/*************
+ * contacts *
+ *************/
+/**
+ * Our configurations.
+ */
+static struct GNUNET_CONFIGURATION_Handle *cfg;
+/**
+ * Name of our ego.
+ */
+static char *contacts_ego_name;
+
+/**
+ * Our ego.
+ */
+static struct GNUNET_IDENTITY_Ego *contacts_ego;
+
+
+
+//static struct GNUNET_CONFIGURATION_Handle *cfg1;
+//static struct GNUNET_CONFIGURATION_Handle *cfg2;
+/**
+ * Be verbose.
+ */
+static int verbose = 1;
+
+
+
+char *currentlySelectedCallAddress;
+
+//static void
+//identity_cb (void *cls, struct GNUNET_IDENTITY_Ego *ego, void **ctx,
+// const char *name);
+
+
+/**
+ * List of contacts (records).
+ */
+static GtkListStore *contacts_liststore;
+
+
+/**
+ * list of zones
+ */
+static GtkListStore *zone_liststore;
+
+/**
+ * zone treestore
+ */
+static GtkTreeStore *zone_treestore;
+
+/**
+ * zone treeview
+ */
+static GtkTreeView *zone_treeview;
+
+/**
+ * zone tree model
+ */
+static GtkTreeModel *zone_treemodel;
+
+
+
+/**
+ * List of contacts.
+ */
+//static GtkTreeStore *contacts_treestore;
+
+/**
+ * The main tree view for 'gns' that shows the records.
+ */
+static GtkTreeView *contacts_treeview;
+
+/**
+ * Tree model (same object as 'contacts_treestore', just different type).
+ */
+static GtkTreeModel *contacts_treemodel;
+
+/*
+ * List iterator for the 'list' operation.
+ */
+static struct GNUNET_NAMESTORE_ZoneIterator *list_it;
+
+
+static struct GNUNET_IDENTITY_Ego *currentAddressBookEgo;
+/**
+ * Handle to identity service.
+ */
+static struct GNUNET_IDENTITY_Handle *id;
+
+
+
+/**
+ * Handle to the namestore.
+ */
+struct GNUNET_NAMESTORE_Handle *ns;
+
+/**
+ * Private key for the our zone.
+ */
+struct GNUNET_CRYPTO_EcdsaPrivateKey zone_pkey;
+
+/**
+ * Public key of the zone we are currently editing.
+ */
+struct GNUNET_CRYPTO_EcdsaPublicKey pubkey;
+
+
+
+
+/**
+ * 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;
+
+
+
+////////////////////////////
+static void
+display_record (void *cls, const struct GNUNET_CRYPTO_EcdsaPrivateKey
*zone_key,
+ const char *rname, unsigned int rd_len,
+ const struct GNUNET_GNSRECORD_Data *rd)
+{
+ const char *typestring;
+ char *s, *type;
+ unsigned int i;
+ const char *ets;
+ struct GNUNET_TIME_Absolute at;
+ struct GNUNET_TIME_Relative rt;
+ GtkTreeIter display_iter;
+
+ if (NULL == rname)
+ {
+ list_it = NULL;
+ //test_finished ();
+ return;
+ }
+ for (i = 0; i < rd_len; i++)
+ {
+
+ if ((GNUNET_GNSRECORD_TYPE_NICK == rd[i].record_type) &&
+ (0 != strcmp (rname, "+")))
+ continue;
+ typestring = GNUNET_GNSRECORD_number_to_typename (rd[i].record_type);
+ s = GNUNET_GNSRECORD_value_to_string (rd[i].record_type, rd[i].data,
+ rd[i].data_size);
+ if (NULL == s)
+ {
+ FPRINTF (stdout, _("\tCorrupt or unsupported record of type %u\n"),
+ (unsigned int) rd[i].record_type);
+ continue;
+ }
+ if (0 != (rd[i].flags & GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION))
+ {
+ rt.rel_value_us = rd[i].expiration_time;
+ ets = GNUNET_STRINGS_relative_time_to_string (rt, GNUNET_YES);
+ }
+ else
+ {
+ at.abs_value_us = rd[i].expiration_time;
+ ets = GNUNET_STRINGS_absolute_time_to_string (at);
+ }
+ if (rd[i].record_type == 65536)
+ {
+ type = "PKEY";
+ } // if pubkey record
+ if (rd[i].record_type == 65542)
+ {
+ type = "PHONE";
+ }
+// FPRINTF (stdout, "%s", rname);
+ if (rd[i].record_type == 65536 || rd[i].record_type == 65542)
+ {
+ gtk_list_store_append (contacts_liststore, &display_iter);
+ gtk_list_store_set (contacts_liststore, &display_iter, 1, type, 0,
rname, -1);
+ }
+
+/* FPRINTF (stdout,
+ "\t%s: %s (%s)\t%s\t%s\t%s\n",
+ typestring,
+ s,
+ ets,
+ (0 != (rd[i].flags & GNUNET_GNSRECORD_RF_PRIVATE)) ?
"PRIVATE" : "PUBLIC",
+ (0 != (rd[i].flags & GNUNET_GNSRECORD_RF_SHADOW_RECORD)) ?
"SHADOW" : "",
+ (0 != (rd[i].flags & GNUNET_GNSRECORD_RF_PENDING)) ?
"PENDING" : "");
+*/
+ //gtk_widget_show(contacts_liststore);
+ GNUNET_free (s);
+ }
+// FPRINTF (stdout, "%s", "\n");
+ GNUNET_NAMESTORE_zone_iterator_next (list_it);
+}
+
+
+
+/**
+ * Function called by identity service with information about egos.
+ *
+ * @param cls NULL
+ * @param ego ego handle
+ * @param ctx unused
+ * @param name name of the ego
+ */
+static void
+identity_cb (void *cls, struct GNUNET_IDENTITY_Ego *ego, void **ctx,
+ const char *name)
+{
+ struct GNUNET_CRYPTO_EcdsaPublicKey pk;
+ char *s;
+ GtkTreeIter iter;
+
+ if (NULL != ego)
+ {
+ GNUNET_IDENTITY_ego_get_public_key (ego, &pk);
+ s = GNUNET_CRYPTO_ecdsa_public_key_to_string (&pk);
+ fprintf (stderr, "contacts idenity_cb: %s \n", name);
+
+
+ /* FIXME: this should be done in gnunet-conversation-gtk.c */
+ gtk_list_store_insert_with_values (zone_liststore,
+ &iter, -1,
+ 0, name,
+ 1, ego,
+ -1);
+
+ }
+
+ /*
+ if (NULL == name)
+ return;
+ if (ego == contacts_ego)
+ {
+ //if (verbose)
+ LOG (_("Name of phonebook ego changed to `%s'\n"), name);
+ GNUNET_free (contacts_ego_name);
+ contacts_ego_name = GNUNET_strdup (name);
+ return;
+ }
+ if (0 != strcmp (name, contacts_ego_name))
+ return;
+ if (NULL == ego)
+ {
+ if (verbose)
+ LOG (_("Our phonebook ego `%s' was deleted!\n"), contacts_ego_name);
+ contacts_ego = NULL;
+ return;
+ }
+ */
+ contacts_ego = ego;
+
+
+// zone_pkey = *GNUNET_IDENTITY_ego_get_private_key (caller_id);
+ ns = GNUNET_NAMESTORE_connect (cfg);
+
+
+// list_it =
+// GNUNET_NAMESTORE_zone_iteration_start (ns, &zone_pkey, &display_record,
+// NULL);
+
+}
+/**
+ * Continuation called to notify client about result of the
+ * operation.
+ *
+ * @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)
+ LOG("GNUNET_NO != success");
+ //ret = 1;
+ }
+ 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
+ */
+void
+add_contact (const gchar * name, const gchar * address)
+{
+// memmove(&address+1,&address+51,1);
+ 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 *tempEgo;
+ char *tempName;
+ GtkTreeIter testIter;
+ gtk_combo_box_get_active_iter(GTK_WIDGET
(GNUNET_CONVERSATION_GTK_get_main_window_object
("gnunet_conversation_gtk_contacts_zone_combobox")), &testIter);
+
+ gtk_tree_model_get (GTK_TREE_MODEL (zone_liststore),
+ &testIter,
+ 0, &tempName,
+ 1, &tempEgo,
+ -1);
+
+
+ GNUNET_CRYPTO_ecdsa_public_key_from_string (address, strlen (address),
&pkey);
+ rde = &rd;
+ zone_pkey = *GNUNET_IDENTITY_ego_get_private_key (tempEgo);
+ 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, *addressEntry;
+
+ nameEntry = GTK_ENTRY (GNUNET_CONVERSATION_GTK_get_main_window_object
("GNUNET_GTK_conversation_nameAdd"));
+ addressEntry = GTK_ENTRY (GNUNET_CONVERSATION_GTK_get_main_window_object
("GNUNET_GTK_conversation_addressAdd"));
+ FPRINTF(stderr,"name %s \n", gtk_entry_get_text (nameEntry));
+ FPRINTF(stderr,"addr %s \n", gtk_entry_get_text (addressEntry));
+
+ 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 (GNUNET_CONVERSATION_GTK_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_CONTAINER (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;
+ }
+
+ }
+}
+
+void
+GNUNET_CONVERSATION_GTK_on_current_clicked (GtkButton * button,
+ gpointer * user_data)
+{
+ GtkEntry *addressEntry;
+// FPRINTF(stderr,"on current clicked %s\n",callerName);
+ char *strippedAddress;
+ addressEntry = GTK_ENTRY (GNUNET_CONVERSATION_GTK_get_main_window_object
("GNUNET_GTK_conversation_addressAdd"));
+ currentlySelectedCallAddress[52] = '\0';
+ gtk_entry_set_text(addressEntry, currentlySelectedCallAddress);
+
+}
+
+
+/*
+ * row activated
+ * @return void
+ */
+
+void
+GNUNET_CONVERSATION_GTK_row_activated ()
+{
+ gchar *callAddress;
+ gchar *type;
+
+// FPRINTF (stderr, "row activated \n");
+
+ GtkTreeSelection *selection;
+
+ GtkTreeIter iterA;
+
+
+ selection = gtk_tree_view_get_selection (contacts_treeview);
+
+ gtk_tree_selection_get_selected (selection, &contacts_treemodel, &iterA);
+ gtk_tree_model_get (contacts_treemodel, &iterA, 0, &name, 1, &type, -1);
+// g_print ("ego name %s\n", ego_name);
+// g_print ("selected row is: %s\n", name);
+// g_print ("selected rowtype is: %s\n", type);
+
+
+ g_print ("type @row active%s", type);
+ if (strcmp (type, "PKEY") == 0)
+ {
+ GNUNET_asprintf (&callAddress, "call\.%s\.gnu", name);
+ }
+ if (strcmp (type, "PHONE") == 0)
+ {
+ GNUNET_asprintf (&callAddress, "%s\.gnu", name);
+ }
+// else { GNUNET_asprintf(&callAddress, "%s", peer_id);}
+
+ g_print ("ego name %s\n", callAddress);
+ GtkEntry *address_entry;
+
+ address_entry = GTK_ENTRY ( GNUNET_CONVERSATION_GTK_get_main_window_object
("GNUNET_GTK_conversation_address"));
+ gtk_entry_set_text (address_entry, callAddress);
+ //do_call (callAddress);
+}
+
+/*
+static void
+print_ego (void *cls,
+ struct GNUNET_IDENTITY_Ego *ego,
+ void **ctx,
+ const char *identifier)
+{
+ struct GNUNET_CRYPTO_EcdsaPublicKey pk;
+ char *s;
+ GNUNET_IDENTITY_ego_get_public_key (ego, &pk);
+ s = GNUNET_CRYPTO_ecdsa_public_key_to_string (&pk);
+ fprintf (stdout, "%s \n", identifier);
+// GNUNET_free (s);
+}
+*/
+GNUNET_IDENTITY_EgoCallback
+setCurrentAddressbookEgo(void *cls, struct GNUNET_IDENTITY_Ego *ego)
+{
+ currentAddressBookEgo = ego;
+}
+
+/**
+ * A different zone was selected in the zone toggle bar. Load the
+ * appropriate zone.
+ *
+ * @param widget button that was toggled (could be to "on" or "off", we only
react to "on")
+ * @param user_data builder, unused
+ */
+void
+gnunet_conversation_gtk_contacts_zone_combobox_changed_cb (GtkComboBox *widget,
+ gpointer user_data)
+{
+ GtkTreeIter contacts_zone_iter;
+ struct GNUNET_IDENTITY_Ego *tempEgo;
+ char *tempName;
+ struct GNUNET_CRYPTO_EcdsaPrivateKey temp_zone_pkey;
+ GtkTreeSelection *selection;
+ GtkTreeIter iterA;
+
+
+ gtk_combo_box_get_active_iter(widget, &contacts_zone_iter);
+
+ gtk_tree_model_get (GTK_TREE_MODEL (zone_liststore),
+ &contacts_zone_iter,
+ 0, &tempName,
+ 1, &tempEgo,
+ -1);
+// FPRINTF(stderr,"blat: %s\n", tempName);
+ temp_zone_pkey = *GNUNET_IDENTITY_ego_get_private_key (tempEgo);
+ gtk_list_store_clear(contacts_liststore);
+/*
+ GNUNET_IDENTITY_ego_lookup (cfg,
+ tempName,
+ setCurrentAddressbookEgo,
+ NULL);
+*/
+ //selection = gtk_tree_view_get_selection (zone_treeview);
+
+ //gtk_tree_selection_get_selected (selection, &zone_treemodel, &iterA);
+
+ //gtk_tree_model_get_iter_first(zone_treemodel, &iterA);
+ //gtk_tree_model_get (zone_treemodel, &iterA, 0, &tempName, 1, &tempEgo, -1);
+
+
+ list_it =
+ GNUNET_NAMESTORE_zone_iteration_start (ns, &temp_zone_pkey,
&display_record,
+ NULL);
+
+// GNUNET_IDENTITY_disconnect (id);
+
+}
+
+
+
+//////
+extern void
+GNUNET_CONVERSATION_GTK_CONTACTS_init ()
+{
+ GtkTreeIter iterContactsInit;
+
+ cfg = GIG_get_configuration ();
+
+
+ // contacts
+ contacts_liststore =
+ GTK_LIST_STORE (GNUNET_CONVERSATION_GTK_get_main_window_object
+ ("gnunet_conversation_gtk_contacts_liststore"));
+ contacts_treeview =
+ GTK_TREE_VIEW (GNUNET_CONVERSATION_GTK_get_main_window_object
("gnunet_conversation_gtk_treeview"));
+ contacts_treemodel = GTK_TREE_MODEL (contacts_liststore);
+
+
+ // zone list
+ zone_liststore =
+ GTK_LIST_STORE (GNUNET_CONVERSATION_GTK_get_main_window_object
("gnunet_conversation_gtk_contacts_zone_liststore"));
+ zone_treestore =
+ GTK_TREE_STORE (GNUNET_CONVERSATION_GTK_get_main_window_object
("gnunet_conversation_gtk_contacts_zone_treestore"));
+ zone_treemodel = GTK_TREE_MODEL (zone_liststore);
+
+ gtk_tree_model_get_iter_first(zone_treemodel, &iterContactsInit);
+ gtk_tree_model_iter_next(zone_treemodel, &iterContactsInit);
+
+ gtk_combo_box_set_active_iter(GTK_WIDGET
(GNUNET_CONVERSATION_GTK_get_main_window_object
("gnunet_conversation_gtk_contacts_zone_combobox")), &iterContactsInit);
+
+ id = GNUNET_IDENTITY_connect (cfg, &identity_cb, NULL);
+// zone_pkey = *GNUNET_IDENTITY_ego_get_private_key (caller_id);
+// gtk_combo_box_set_active(GTK_WIDGET (get_object
("gnunet_conversation_gtk_contacts_zone_combobox")), 1);
+// gtk_combo_box_set_active(GTK_WIDGET (get_object
(ml,"gnunet_conversation_gtk_outgoing_zone_combobox")), 1);
+
+}
+
+extern void
+GNUNET_CONVERSATION_GTK_CONTACTS_shutdown()
+{
+ GNUNET_CRYPTO_ecdsa_key_clear (&zone_pkey);
+}
+
+
+
+
Added: gnunet-gtk/src/conversation/gnunet-conversation-gtk_contacts.h
===================================================================
--- gnunet-gtk/src/conversation/gnunet-conversation-gtk_contacts.h
(rev 0)
+++ gnunet-gtk/src/conversation/gnunet-conversation-gtk_contacts.h
2014-02-17 00:43:33 UTC (rev 32361)
@@ -0,0 +1,52 @@
+/*
+ This file is part of GNUnet.
+ (C) 2010-2013 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_history.h
+ * @brief
+ * @author yids
+ * @author hark
+ */
+/*
+extern void
+display_record (void *cls, const struct GNUNET_CRYPTO_EcdsaPrivateKey
*zone_key,
+ const char *rname, unsigned int rd_len,
+ const struct GNUNET_GNSRECORD_Data *rd);
+*/
+
+extern char *currentlySelectedCallAddress;
+
+/**
+ * List of contacts (records).
+ */
+extern GtkListStore *contacts_liststore;
+
+
+/**
+ * List of contacts.
+ */
+//static GtkTreeStore *contacts_treestore;
+
+/**
+ * The main tree view for 'gns' that shows the records.
+ */
+extern GtkTreeView *contacts_treeview;
+
+
Added: gnunet-gtk/src/conversation/gnunet-conversation-gtk_history.c
===================================================================
--- gnunet-gtk/src/conversation/gnunet-conversation-gtk_history.c
(rev 0)
+++ gnunet-gtk/src/conversation/gnunet-conversation-gtk_history.c
2014-02-17 00:43:33 UTC (rev 32361)
@@ -0,0 +1,110 @@
+/*
+ This file is part of GNUnet.
+ (C) 2010-2013 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_history.c
+ * @brief
+ * @author yids
+ * @author hark
+ */
+
+#include "gnunet-conversation-gtk_common.h"
+
+
+/*******
+ * history
+ ********/
+/**
+ * call history liststore
+ */
+static GtkListStore *history_liststore;
+
+/**
+ * call history treestore
+ */
+static GtkTreeStore *history_treestore;
+
+/**
+ * call histore treeview
+ */
+static GtkTreeView *history_treeview;
+
+/**
+ * call history tree model
+ */
+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)
+{
+ GtkTreeIter iter;
+ time_t t;
+ char *event;
+
+ switch (type)
+ {
+ case CH_ACCEPTED:
+ event = "Accepted";
+ break;
+ case CH_REJECTED:
+ event = "Rejected";
+ break;
+ case CH_OUTGOING:
+ event = "Outgoing";
+ break;
+ case CH_HANGUP:
+ event = "Hangup";
+ break;
+ case CH_MISSED:
+ event = "Missed";
+ break;
+ default:
+ event = "UNKNOWN";
+ break;
+ }
+ time (&t);
+ gtk_list_store_append (history_liststore, &iter);
+ gtk_list_store_set (history_liststore, &iter, 1, event, 0, ctime (&t), 2,
+ contactName, -1);
+}
+
+extern void
+GNUNET_CONVERSATION_GTK_history_init(){
+ // call history
+ history_liststore =
+ GTK_LIST_STORE (get_object
("gnunet_conversation_gtk_history_liststore"));
+ history_treeview =
+ GTK_TREE_VIEW (get_object ("gnunet_conversation_gtk_history_treeview"));
+ history_treestore =
+ GTK_TREE_STORE (get_object
("gnunet_conversation_gtk_history_treestore"));
+ history_treemodel = GTK_TREE_MODEL (history_treestore);
+
+}
Added: gnunet-gtk/src/conversation/gnunet-conversation-gtk_history.h
===================================================================
--- gnunet-gtk/src/conversation/gnunet-conversation-gtk_history.h
(rev 0)
+++ gnunet-gtk/src/conversation/gnunet-conversation-gtk_history.h
2014-02-17 00:43:33 UTC (rev 32361)
@@ -0,0 +1,11 @@
+
+/****************
+ * history *
+ ****************/
+
+extern void
+GNUNET_CONVERSATION_GTK_history_add (int, char *);
+
+extern void
+GNUNET_CONVERSATION_GTK_history_init();
+
Added: gnunet-gtk/src/conversation/gnunet-conversation-gtk_phone.c
===================================================================
--- gnunet-gtk/src/conversation/gnunet-conversation-gtk_phone.c
(rev 0)
+++ gnunet-gtk/src/conversation/gnunet-conversation-gtk_phone.c 2014-02-17
00:43:33 UTC (rev 32361)
@@ -0,0 +1,28 @@
+/*
+ This file is part of GNUnet.
+ (C) 2010-2013 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.c
+ * @brief
+ * @author yids
+ * @author hark
+ */
+
+
Added: gnunet-gtk/src/conversation/gnunet-conversation-gtk_phone.h
===================================================================
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r32361 - gnunet-gtk/src/conversation,
gnunet <=