gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r33391 - gnunet-gtk/src/conversation


From: gnunet
Subject: [GNUnet-SVN] r33391 - gnunet-gtk/src/conversation
Date: Mon, 26 May 2014 12:03:02 +0200

Author: grothoff
Date: 2014-05-26 12:03:02 +0200 (Mon, 26 May 2014)
New Revision: 33391

Added:
   gnunet-gtk/src/conversation/gnunet-conversation-gtk_egos.c
   gnunet-gtk/src/conversation/gnunet-conversation-gtk_egos.h
Log:
add new egos files

Added: gnunet-gtk/src/conversation/gnunet-conversation-gtk_egos.c
===================================================================
--- gnunet-gtk/src/conversation/gnunet-conversation-gtk_egos.c                  
        (rev 0)
+++ gnunet-gtk/src/conversation/gnunet-conversation-gtk_egos.c  2014-05-26 
10:03:02 UTC (rev 33391)
@@ -0,0 +1,169 @@
+/*
+     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_egos.c
+ * @brief
+ * @author yids
+ * @author hark
+ * @author Christian Grothoff
+ */
+#include "gnunet-conversation-gtk.h"
+#include "gnunet-conversation-gtk_egos.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;
+
+
+/**
+ * Obtain the currently selected ego.
+ *
+ * @return NULL if no ego is selected
+ */
+struct GNUNET_IDENTITY_Ego *
+GCG_EGOS_get_selected_ego (void)
+{
+  struct GNUNET_IDENTITY_Ego *ego;
+  GtkTreeIter iter;
+  GtkComboBox *cb;
+
+  cb = GTK_COMBO_BOX (GCG_get_main_window_object  
("gnunet_conversation_gtk_contacts_zone_combobox"));
+  gtk_combo_box_get_active_iter (cb,
+                                 &iter);
+  gtk_tree_model_get (GTK_TREE_MODEL (zone_liststore),
+                      &iter,
+                      ZONE_LS_EGO, &ego,
+                      -1);
+  return ego;
+}
+
+
+/**
+ * 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)
+{
+  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 ego list
+ */
+void
+GCG_EGOS_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 ego list
+ */
+void
+GCG_EGOS_shutdown ()
+{
+  if (NULL != id)
+  {
+    GNUNET_IDENTITY_disconnect (id);
+    id = NULL;
+  }
+}
+
+/* end of gnunet-conversation-gtk_egos.c */

Added: gnunet-gtk/src/conversation/gnunet-conversation-gtk_egos.h
===================================================================
--- gnunet-gtk/src/conversation/gnunet-conversation-gtk_egos.h                  
        (rev 0)
+++ gnunet-gtk/src/conversation/gnunet-conversation-gtk_egos.h  2014-05-26 
10:03:02 UTC (rev 33391)
@@ -0,0 +1,54 @@
+/*
+     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_egos.h
+ * @brief
+ * @author yids
+ * @author hark
+ * @author Christian Grothoff
+ */
+#ifndef GNUNET_CONVERSATION_GTK_EGOS_H
+#define GNUNET_CONVERSATION_GTK_EGOS_H
+
+
+/**
+ * Obtain the currently selected ego.
+ *
+ * @return NULL if no ego is selected
+ */
+struct GNUNET_IDENTITY_Ego *
+GCG_EGOS_get_selected_ego (void);
+
+
+/**
+ * Initialize the contact list
+ */
+extern void
+GCG_EGOS_init (void);
+
+
+/**
+ * Shutdown the contact list
+ */
+extern void
+GCG_EGOS_shutdown(void);
+
+#endif




reply via email to

[Prev in Thread] Current Thread [Next in Thread]