gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r32314 - in gnunet-gtk: contrib src/conversation


From: gnunet
Subject: [GNUnet-SVN] r32314 - in gnunet-gtk: contrib src/conversation
Date: Tue, 11 Feb 2014 19:31:06 +0100

Author: hark
Date: 2014-02-11 19:31:06 +0100 (Tue, 11 Feb 2014)
New Revision: 32314

Modified:
   gnunet-gtk/contrib/gnunet_conversation_gtk_main_window.glade
   gnunet-gtk/src/conversation/gnunet-conversation-gtk.c
   gnunet-gtk/src/conversation/gnunet-conversation-gtk.h
Log:
handle multiple incoming calls 


Modified: gnunet-gtk/contrib/gnunet_conversation_gtk_main_window.glade
===================================================================
--- gnunet-gtk/contrib/gnunet_conversation_gtk_main_window.glade        
2014-02-11 17:49:09 UTC (rev 32313)
+++ gnunet-gtk/contrib/gnunet_conversation_gtk_main_window.glade        
2014-02-11 18:31:06 UTC (rev 32314)
@@ -1,6 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <interface>
   <!-- interface-requires gtk+ 3.0 -->
+  <object class="GtkAction" id="action1"/>
   <object class="GtkWindow" id="GNUNET_GTK_conversation_window">
     <property name="can_focus">False</property>
     <property name="events">GDK_BUTTON_PRESS_MASK | 
GDK_STRUCTURE_MASK</property>
@@ -139,7 +140,20 @@
                           </packing>
                         </child>
                         <child>
-                          <placeholder/>
+                          <object class="GtkButton" 
id="GNUNET_GTK_conversation_test_button_two">
+                            <property name="label" translatable="yes">test 
2</property>
+                            <property 
name="use_action_appearance">False</property>
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <property name="receives_default">True</property>
+                            <property 
name="use_action_appearance">False</property>
+                            <signal name="clicked" 
handler="GNUNET_CONVERSATION_GTK_test_button_two" swapped="no"/>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="fill">True</property>
+                            <property name="position">2</property>
+                          </packing>
                         </child>
                         <child>
                           <placeholder/>
@@ -280,7 +294,9 @@
                                     <property 
name="enable_search">False</property>
                                     <property name="search_column">0</property>
                                     <child internal-child="selection">
-                                      <object class="GtkTreeSelection" 
id="treeview-selection2"/>
+                                      <object class="GtkTreeSelection" 
id="GNUNET_CONVERSATION_GTK_active_calls_selection">
+                                        <signal name="changed" 
handler="GNUNET_CONVERSATION_GTK_on_active_calls_selection_changed" 
swapped="no"/>
+                                      </object>
                                     </child>
                                     <child>
                                       <object class="GtkTreeViewColumn" 
id="caller_numColumn">
@@ -300,10 +316,34 @@
                                       </object>
                                     </child>
                                     <child>
+                                      <object class="GtkTreeViewColumn" 
id="GNUNET_CONVERSATION_GTK_caller_typeColumn">
+                                        <property name="title" 
translatable="yes">type</property>
+                                        <child>
+                                          <object class="GtkCellRendererText" 
id="GNUNET_CONVERSATION_GTK_active_calls_type"/>
+                                          <attributes>
+                                            <attribute 
name="markup">3</attribute>
+                                            <attribute 
name="text">3</attribute>
+                                          </attributes>
+                                        </child>
+                                      </object>
+                                    </child>
+                                    <child>
+                                      <object class="GtkTreeViewColumn" 
id="caller_stateColumn">
+                                        <property name="title" 
translatable="yes">state</property>
+                                        <child>
+                                          <object class="GtkCellRendererText" 
id="GNUNET_CONVERSATION_GTK_active_calls_state"/>
+                                          <attributes>
+                                            <attribute 
name="markup">4</attribute>
+                                            <attribute 
name="text">4</attribute>
+                                          </attributes>
+                                        </child>
+                                      </object>
+                                    </child>
+                                    <child>
                                       <object class="GtkTreeViewColumn" 
id="caller_idColumn">
                                         <property name="title" 
translatable="yes">Caller ID</property>
                                         <child>
-                                          <object class="GtkCellRendererText" 
id="GNUNET_CONVERSATION_GTK_event_window_renderer1"/>
+                                          <object class="GtkCellRendererText" 
id="GNUNET_CONVERSATION_GTK_active_calls_id"/>
                                           <attributes>
                                             <attribute 
name="text">0</attribute>
                                           </attributes>
@@ -346,15 +386,14 @@
                               </packing>
                             </child>
                             <child>
-                              <object class="GtkButton" 
id="GNUNET_GTK_conversation_call_button">
-                                <property name="label" 
translatable="yes">call</property>
+                              <object class="GtkButton" 
id="GNUNET_GTK_conversation_use_current_button">
+                                <property name="label" 
translatable="yes">&gt;contact</property>
                                 <property 
name="use_action_appearance">False</property>
                                 <property name="visible">True</property>
                                 <property name="can_focus">True</property>
                                 <property 
name="receives_default">True</property>
                                 <property 
name="use_action_appearance">False</property>
-                                <property name="use_underline">True</property>
-                                <signal name="clicked" 
handler="GNUNET_CONVERSATION_GTK_on_call_clicked" swapped="no"/>
+                                <signal name="clicked" 
handler="GNUNET_CONVERSATION_GTK_on_current_clicked" swapped="no"/>
                               </object>
                               <packing>
                                 <property name="expand">False</property>
@@ -363,6 +402,22 @@
                               </packing>
                             </child>
                             <child>
+                              <object class="GtkButton" 
id="GNUNET_GTK_conversation_accept_button">
+                                <property name="label" 
translatable="yes">accept</property>
+                                <property 
name="use_action_appearance">False</property>
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property 
name="receives_default">True</property>
+                                <property 
name="use_action_appearance">False</property>
+                                <signal name="clicked" 
handler="GNUNET_CONVERSATION_GTK_on_accept_clicked" swapped="no"/>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">True</property>
+                                <property name="position">2</property>
+                              </packing>
+                            </child>
+                            <child>
                               <object class="GtkButton" 
id="GNUNET_GTK_conversation_hangup_button">
                                 <property name="label" 
translatable="yes">hangup</property>
                                 <property 
name="use_action_appearance">False</property>
@@ -375,12 +430,12 @@
                               <packing>
                                 <property name="expand">False</property>
                                 <property name="fill">True</property>
-                                <property name="position">2</property>
+                                <property name="position">3</property>
                               </packing>
                             </child>
                             <child>
                               <object class="GtkButton" 
id="GNUNET_GTK_conversation_pause_button">
-                                <property name="label" 
translatable="yes">pause call</property>
+                                <property name="label" 
translatable="yes">pause</property>
                                 <property 
name="use_action_appearance">False</property>
                                 <property name="visible">True</property>
                                 <property name="can_focus">True</property>
@@ -395,11 +450,21 @@
                               </packing>
                             </child>
                             <child>
-                              <placeholder/>
+                              <object class="GtkButton" 
id="GNUNET_GTK_conversation_resume_button">
+                                <property name="label" 
translatable="yes">resume</property>
+                                <property 
name="use_action_appearance">False</property>
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property 
name="receives_default">True</property>
+                                <property 
name="use_action_appearance">False</property>
+                                <signal name="clicked" 
handler="GNUNET_CONVERSATION_GTK_on_resume_clicked" swapped="no"/>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">True</property>
+                                <property name="position">5</property>
+                              </packing>
                             </child>
-                            <child>
-                              <placeholder/>
-                            </child>
                           </object>
                           <packing>
                             <property name="expand">False</property>
@@ -418,20 +483,7 @@
                       </packing>
                     </child>
                     <child>
-                      <object class="GtkButton" 
id="GNUNET_GTK_conversation_use_current_button">
-                        <property name="label" translatable="yes">Add address 
of currently selected call</property>
-                        <property name="use_action_appearance">False</property>
-                        <property name="visible">True</property>
-                        <property name="can_focus">True</property>
-                        <property name="receives_default">True</property>
-                        <property name="use_action_appearance">False</property>
-                        <signal name="clicked" 
handler="GNUNET_CONVERSATION_GTK_on_current_clicked" swapped="no"/>
-                      </object>
-                      <packing>
-                        <property name="expand">False</property>
-                        <property name="fill">True</property>
-                        <property name="position">3</property>
-                      </packing>
+                      <placeholder/>
                     </child>
                   </object>
                   <packing>
@@ -604,7 +656,22 @@
                           </packing>
                         </child>
                         <child>
-                          <placeholder/>
+                          <object class="GtkButton" 
id="GNUNET_GTK_conversation_call_button">
+                            <property name="label" 
translatable="yes">call</property>
+                            <property 
name="use_action_appearance">False</property>
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <property name="receives_default">True</property>
+                            <property 
name="use_action_appearance">False</property>
+                            <property name="use_underline">True</property>
+                            <signal name="clicked" 
handler="GNUNET_CONVERSATION_GTK_on_call_clicked" swapped="no"/>
+                          </object>
+                          <packing>
+                            <property name="left_attach">0</property>
+                            <property name="top_attach">0</property>
+                            <property name="width">1</property>
+                            <property name="height">1</property>
+                          </packing>
                         </child>
                       </object>
                       <packing>
@@ -780,6 +847,10 @@
       <column type="gpointer"/>
       <!-- column-name caller_num -->
       <column type="gint"/>
+      <!-- column-name caller_type -->
+      <column type="gint"/>
+      <!-- column-name caller_state -->
+      <column type="gint"/>
     </columns>
   </object>
   <object class="GtkListStore" id="gnunet_conversation_gtk_contacts_liststore">
@@ -790,12 +861,6 @@
       <column type="gchararray"/>
     </columns>
   </object>
-  <object class="GtkTreeStore" id="gnunet_conversation_gtk_contacts_treestore">
-    <columns>
-      <!-- column-name contactName -->
-      <column type="gchararray"/>
-    </columns>
-  </object>
   <object class="GtkListStore" 
id="gnunet_conversation_gtk_contacts_zone_liststore">
     <columns>
       <!-- column-name ego_name -->
@@ -803,18 +868,7 @@
       <!-- column-name ego -->
       <column type="gpointer"/>
     </columns>
-    <data>
-      <row>
-        <col id="0" translatable="yes">not working yet</col>
-      </row>
-    </data>
   </object>
-  <object class="GtkTreeStore" 
id="gnunet_conversation_gtk_contacts_zone_treestore">
-    <columns>
-      <!-- column-name zone -->
-      <column type="gchararray"/>
-    </columns>
-  </object>
   <object class="GtkListStore" id="gnunet_conversation_gtk_history_liststore">
     <columns>
       <!-- column-name logTime -->
@@ -825,7 +879,6 @@
       <column type="gchararray"/>
     </columns>
   </object>
-  <object class="GtkTreeStore" id="gnunet_conversation_gtk_history_treestore"/>
   <object class="GtkListStore" 
id="gnunet_conversation_gtk_outgoing_zone_liststore">
     <columns>
       <!-- column-name ego_name -->
@@ -833,10 +886,5 @@
       <!-- column-name ego -->
       <column type="gpointer"/>
     </columns>
-    <data>
-      <row>
-        <col id="0" translatable="yes">Outgoing identity, doesn't work 
yet.</col>
-      </row>
-    </data>
   </object>
 </interface>

Modified: gnunet-gtk/src/conversation/gnunet-conversation-gtk.c
===================================================================
--- gnunet-gtk/src/conversation/gnunet-conversation-gtk.c       2014-02-11 
17:49:09 UTC (rev 32313)
+++ gnunet-gtk/src/conversation/gnunet-conversation-gtk.c       2014-02-11 
18:31:06 UTC (rev 32314)
@@ -49,6 +49,9 @@
 
 #define LOG(format, ...) log_message(g_strdup_printf (format, ## __VA_ARGS__))
 
+struct GNUNET_CONVERSATION_Caller *caller_selected = NULL;
+//caller_selected = NULL;
+
 /**
  * Get an object from the main window.
  *
@@ -129,7 +132,43 @@
 
 
 }
+/*
+ * set_status_icon
+ * 
+ * available icons:
+ * gnunet-conversation-gtk-tray-pending
+ * gnunet-conversation-gtk-tray-available
+ * gnunet-conversation-gtk-tray-offline
+ * gnunet-conversation-gtk-tray-call-pending
+ * gnunet-conversation-gtk-tray-call-ringing
+ * gnunet-conversation-gtk-tray-call-active
+ * gnunet-conversation-gtk-tray-call-suspended
+ * gnunet-conversation-gtk-tray-call-incoming
+ *
+ */
 
+void
+set_status_icon (const char *icon_name)
+{
+  GtkWindow *main_window;
+  GtkImage *status_icon;
+
+
+
+  main_window = GTK_WINDOW (get_object ("GNUNET_GTK_conversation_window"));
+
+  status_icon = GTK_IMAGE (get_object ("GNUNET_GTK_status_icon"));
+
+  gtk_image_set_from_icon_name (status_icon, icon_name, GTK_ICON_SIZE_BUTTON);
+
+  //LOG (_("Tray icon changed to: `%s' "), icon_name);
+
+
+
+  GNUNET_GTK_tray_icon_change (icon_name, "gnunet-conversation-gtk-status");
+}
+
+
 /*
  * adds a item to the call history
  *
@@ -188,20 +227,6 @@
 }
 
 /*
- * set infobar text
- */
-//
-//void
-//set_infobar_text (const gchar * text)
-//{
-//  GtkLabel *infolabel;
-//
-//  infolabel = GTK_LABEL(get_object ("GNUNET_GTK_new_call_label"));
-//  log_message ("setting infobar text");
-//  gtk_label_set_text (infolabel, text);
-//}
-//
-/*
  * disable button
  */
 
@@ -229,39 +254,88 @@
   gtk_widget_show (button);
 }
 
-/*
- * show infobar
+/**
+ * set call state of a incoming call
  */
-//
-//void
-//show_infobar ()
-//{
-//  GtkWidget *infobar;
-//
-//  infobar = GTK_WIDGET(get_object ("GNUNET_GTK_conversation_infobar"));
-//
-//  gtk_widget_show (infobar);
-//}
-//
-/*
- * hide infobar
- */
-//
-//void
-//hide_infobar ()
-//{
-//  //GtkInfoBar *infobar;
-//  GtkWidget *infobar;
-//
-//  infobar = GTK_WIDGET(get_object ("GNUNET_GTK_conversation_infobar"));
-//
-//  gtk_widget_hide (infobar);
-//}
-//
+static void
+set_incoming_call_state(struct GNUNET_CONVERSATION_Caller *caller, int state)
+{
+ // struct CallList *cl = cls;
+//  struct GNUNET_CONVERSATION_Caller caller;
+  gint row_count = 0;
+  GtkTreeIter gtkiter;
+  gint valid = 0;
+  //FPRINTF (stderr,"set incoming call state:%u caller: ",state);
 
+  LOG (_("set incoming call state:%u caller: "),state);
+ 
+  valid = gtk_tree_model_get_iter_first( GTK_TREE_MODEL( active_liststore ), 
&gtkiter ); 
+    
+    if (!valid) 
+        GNUNET_break(0);
+    
+    while (valid)
+    {
+      gchar *cl_caller_id;
+      gint   cl_caller_num;
+      gpointer cl_caller;
+//      gint new_state;
+      //FPRINTF (stderr,"loop:: valid:%u  \n",valid);
 
+      gtk_tree_model_get ( GTK_TREE_MODEL( active_liststore ), &gtkiter, 
+                          AL_caller, &cl_caller,
+                          AL_caller_id,&cl_caller_id,
+                          AL_caller_num,&cl_caller_num
+                          ,-1);
+      /*
+       enum {
+  CT_active,
+  CT_suspended,
+  CT_ringing,
+  CT_dead,
+  CT_hangup,
+  CT_rejected
+};
+*/
+      if (caller == cl_caller)
+      {
+      //LOG (_("setting state for call:%u row: %u state: 
%u"),cl_caller_num,row_count,state);
 
+          switch (state)
+            {
+            case CT_hangup:
+              LOG("remove line cause hangup");
+              gtk_list_store_remove(active_liststore,&gtkiter);
+            break;  
 
+            case CT_rejected:
+              LOG("remove line cause rejected");
+              gtk_list_store_remove(active_liststore,&gtkiter);
+            break;  
+          
+            default:
+                         
+               gtk_list_store_set(active_liststore, &gtkiter,
+                                  AL_caller_state, state,
+                                  -1);
+            break;
+            
+            }//end switch 
+        }//endif
+       
+          g_free (cl_caller_id);
+          row_count++;
+          valid = gtk_tree_model_iter_next (GTK_TREE_MODEL(active_liststore), 
&gtkiter);
+       
+    }//end while
+
+
+
+}
+
+
+
+
 /**
  * Function called with an event emitted by a phone.
  *
@@ -275,55 +349,125 @@
                      struct GNUNET_CONVERSATION_Caller *caller,
                      const char *caller_id)
 {
-  struct CallList *cl;
 
+    //gtk
+    GtkTreeIter gtkiter;
+    GtkTreeIter gtkiter1;
+    gboolean valid;
+
+
   switch (code)
   {
   case GNUNET_CONVERSATION_EC_PHONE_RING:
+    //increment call #
+    caller_num_gen++; 
+ 
 
-    LOG (_("A Incoming call from `%s' on line %u\n"), caller_id,
+    LOG (_("A Incoming call from `%s' with number %u\n"), caller_id,
          caller_num_gen);
+  
+    //old
+    struct CallList *cl;
 
-
-    //UPDATE_INFOBAR (_("Incoming call from `%s' on line %u\n"), caller_id,
-    //                caller_num_gen);
-
-    //show_infobar ();
-    // TODO: make sound
-
     cl = GNUNET_new (struct CallList);
-
     cl->caller = caller;
     cl->caller_id = GNUNET_strdup (caller_id);
-    cl->caller_num = caller_num_gen++;
+    cl->caller_num = caller_num_gen;
     GNUNET_CONTAINER_DLL_insert (cl_head, cl_tail, cl);
-    callerName = caller_id;
-    //strncpy (&callerName, &caller_id, 50);
-    //callerName[52] = '\0';
-    quick_message ("der is een beller", caller_id);
+    //gtk 
+    gtk_list_store_append (active_liststore, &gtkiter);
 
+    gtk_list_store_set (active_liststore, &gtkiter, 
+                        AL_caller_id, caller_id, 
+                        AL_caller, caller,
+                        AL_caller_num, caller_num_gen,
+                        AL_caller_state, CT_ringing,
+                        AL_caller_type, CALL_IN 
+                        ,-1);
+
+
+    //What is this callername thing? 
+//    strncpy (&callerName, &caller_id, 50);
+//    callerName[52] = '\0';
+    
+    //TODO:new call notification, should be passed a reference to the call
+    //TODO: rename: quick_message to call_notification(caller);
+//    quick_message ("der is een beller", caller_id);
+    // TODO: make sound
+
     break;
 
   case GNUNET_CONVERSATION_EC_PHONE_HUNG_UP:
+    //FPRINTF(stderr,"GNUNET_CONVERSATION_EC_PHONE_HUNG_UP:");
+    //gtk
+    
+    valid = gtk_tree_model_get_iter_first( GTK_TREE_MODEL( active_liststore ), 
&gtkiter1 ); 
+    
+    if (!valid)
+        GNUNET_break(0);
+    
+    while (valid)
+    {
+    /* Walk through the list, reading each row */
+       //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), &gtkiter1, 
+                          AL_caller, &cl_caller,
+                          AL_caller_id,&str_data,
+                          AL_caller_num,&int_data,-1);
+      if (caller == cl_caller)
+      {
+
+        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), 
&gtkiter1);
+    }
+    
+    
+
+    //gcl_active = NULL;
+    phone_state = PS_LISTEN;
+    //add to call history list
+    //history_add(CH_HANGUP, cl->caller_id);
+    
+
+    ///END gtk
+    
+    //old
+   /* 
     for (cl = cl_head; NULL != cl; cl = cl->next)
       if (caller == cl->caller)
         break;
+
     if (NULL == cl)
     {
       GNUNET_break (0);
       return;
     }
+    
     LOG (_("Call from `%s' terminated\n"), cl->caller_id);
-    history_add(3, cl->caller_id);
+    
+   
     GNUNET_CONTAINER_DLL_remove (cl_head, cl_tail, cl);
     GNUNET_free (cl->caller_id);
+    
+    //
     if (cl == cl_active)
     {
       cl_active = NULL;
       phone_state = PS_LISTEN;
     }
     GNUNET_free (cl);
-    gtk_widget_destroy (GTK_WIDGET (dialog));
+    */
+    //destroy call accept dialog
+    //gtk_widget_destroy (GTK_WIDGET (dialog));
     break;
 
   }
@@ -345,10 +489,12 @@
   {
   case GNUNET_CONVERSATION_EC_CALLER_SUSPEND:
     update_state ();
+    set_incoming_call_state(cls,CT_suspended);
     LOG (_("Call from `%s' suspended by other user\n"), cl->caller_id);
     break;
   case GNUNET_CONVERSATION_EC_CALLER_RESUME:
     update_state ();
+    set_incoming_call_state(cls,CT_active);
     LOG (_("Call from `%s' resumed by other user\n"), cl->caller_id);
     break;
   }
@@ -476,7 +622,7 @@
     /* ok to call */
     break;
   }
-  GNUNET_free_non_null (peer_name);
+  //GNUNET_free_non_null (peer_name);
   peer_name = GNUNET_strdup (arg);
   LOG (_("now calling: %s"), peer_name);
   call_state = CS_RESOLVING;
@@ -496,7 +642,7 @@
  * @param args arguments given to the command
  */
 static void
-do_accept (const char *args)
+do_accept (struct GNUNET_CONVERSATION_Caller *sel_caller)
 {
   struct CallList *cl;
   char buf[32];
@@ -523,39 +669,44 @@
   case PS_ERROR:
     GNUNET_break (0);
     break;
-  }
+  }//endswitch
+
+/*  
   cl = cl_head;
   if (NULL == cl)
   {
     LOG (_("There is no incoming call to accept here!\n"));
     return;
   }
-  if ((NULL != cl->next) || (NULL != args))
+  if (NULL != cl->next)
   {
     for (cl = cl_head; NULL != cl; cl = cl->next)
     {
       GNUNET_snprintf (buf, sizeof (buf), "%u", cl->caller_num);
-      if (0 == strcmp (buf, args))
-        break;
     }
   }
   if (NULL == cl)
   {
-    LOG (_("There is no incoming call `%s' to accept right now!\n"), args);
+    LOG (_("There is no incoming call to accept right now!(NULL == cl) \n"));
     return;
   }
-
+   
     GNUNET_CONTAINER_DLL_remove (cl_head,
                              cl_tail,
                              cl);
     cl_active = cl;
     GNUNET_free_non_null (peer_name);
     peer_name = GNUNET_strdup (cl->caller_id);
+   */
+
     phone_state = PS_ACCEPTED;
-    GNUNET_CONVERSATION_caller_pick_up (cl->caller, &caller_event_handler, cl,
+    set_incoming_call_state(sel_caller,CT_active);
+    
+    
+    GNUNET_CONVERSATION_caller_pick_up (sel_caller, &caller_event_handler, cl,
                                       speaker, mic);
 
-  history_add (CH_ACCEPTED, peer_name);
+    history_add (CH_ACCEPTED, peer_name);
 
 }
 
@@ -571,7 +722,7 @@
  * @param args arguments given to the command
  */
 static void
-do_status (const char *args)
+do_status ()
 {
   struct CallList *cl;
 
@@ -581,13 +732,13 @@
     UPDATE_STATUS (_
                    ("We are currently trying to locate the private key for the 
ego `%s'."),
                    ego_name);
-    set_status_icon ("gnunet-conversation-tray-pending");
+    set_status_icon ("gnunet-conversation-gtk-tray-pending");
     break;
   case PS_LISTEN:
     UPDATE_STATUS (_
                    ("We are listening for incoming calls for ego `%s' on line 
%u."),
                    ego_name, line);
-    set_status_icon ("gnunet-conversation-tray-available");
+    set_status_icon ("gnunet-conversation-gtk-tray-available");
 
     break;
   case PS_ACCEPTED:
@@ -610,22 +761,22 @@
       UPDATE_STATUS (_
                      ("We are trying to find the network address to call 
`%s'."),
                      peer_name);
-      set_status_icon ("gnunet-conversation-tray-call-pending");
+      set_status_icon ("gnunet-conversation-gtk-tray-call-pending");
 
       break;
     case CS_RINGING:
       UPDATE_STATUS (_("We are calling `%s', his phone should be ringing."),
                      peer_name);
-      set_status_icon ("gnunet-conversation-tray-call-ringing");
+      set_status_icon ("gnunet-conversation-gtk-tray-call-ringing");
 
       break;
     case CS_CONNECTED:
       UPDATE_STATUS (_("You are having a conversation with `%s'."), peer_name);
-      set_status_icon ("gnunet-conversation-tray-call-active");
+      set_status_icon ("gnunet-conversation-gtk-tray-call-active");
 
       break;
     case CS_SUSPENDED:
-      set_status_icon ("gnunet-conversation-tray-call-suspended");
+      set_status_icon ("gnunet-conversation-gtk-tray-call-suspended");
 
       /* ok to accept incoming call right now */
       break;
@@ -633,7 +784,7 @@
   }
   if ((NULL != cl_head) && ((cl_head != cl_active) || (cl_head != cl_tail)))
   {
-    set_status_icon ("gnunet-conversation-tray-call-incoming");
+    set_status_icon ("gnunet-conversation-gtk-tray-call-incoming");
 
     for (cl = cl_head; NULL != cl; cl = cl->next)
     {
@@ -653,8 +804,10 @@
  */
 
 static void
-do_suspend (const char *args)
+do_suspend (struct GNUNET_CONVERSATION_Caller *sel_caller)
 {
+
+/*
   if (NULL != call)
   {
     switch (call_state)
@@ -670,20 +823,26 @@
       return;
     }
   }
+*/
   switch (phone_state)
   {
   case PS_LOOKUP_EGO:
   case PS_LISTEN:
   case PS_ERROR:
-    LOG ("%s", _("There is no call that could be suspended right now."));
+    LOG ("%s", _(" There is no call that could be suspended right now."));
     return;
   case PS_ACCEPTED:
     /* expected state, do rejection logic */
     break;
   }
-  GNUNET_assert (NULL != cl_active);
-  GNUNET_CONVERSATION_caller_suspend (cl_active->caller);
-  cl_active = NULL;
+
+//  GNUNET_assert (NULL != cl_active);
+ 
+  set_incoming_call_state(sel_caller,CT_suspended);
+  GNUNET_CONVERSATION_caller_suspend (sel_caller);
+  
+//  cl_active = NULL;
+  
   phone_state = PS_LISTEN;
 }
 
@@ -694,7 +853,7 @@
  * @param args arguments given to the command
  */
 static void
-do_resume (const char *args)
+do_resume (struct GNUNET_CONVERSATION_Caller *sel_caller)
 {
   struct CallList *cl;
   char buf[32];
@@ -728,6 +887,7 @@
          peer_name);
     return;
   }
+  
   GNUNET_assert (NULL == cl_active);
   cl = cl_head;
   if (NULL == cl)
@@ -735,22 +895,23 @@
     LOG (_("There is no incoming call to resume here!"));
     return;
   }
-  if ((NULL != cl->next) || (NULL != args))
+  if (NULL != cl->next)
   {
     for (cl = cl_head; NULL != cl; cl = cl->next)
     {
       GNUNET_snprintf (buf, sizeof (buf), "%u", cl->caller_num);
-      if (0 == strcmp (buf, args))
-        break;
     }
   }
   if (NULL == cl)
   {
-    LOG (_("There is no incoming call `%s' to resume right now!"), args);
+    LOG (_("There is no incoming call  to resume right now! (null == cl)"));
     return;
   }
   cl_active = cl;
-  GNUNET_CONVERSATION_caller_resume (cl_active->caller, speaker, mic);
+  
+  set_incoming_call_state(sel_caller,CT_active);
+
+  GNUNET_CONVERSATION_caller_resume (sel_caller, speaker, mic);
   phone_state = PS_ACCEPTED;
 }
 
@@ -761,10 +922,12 @@
  * @param args arguments given to the command
  */
 static void
-do_reject (const char *args)
+do_reject (struct GNUNET_CONVERSATION_Caller *sel_caller)
 {
   struct CallList *cl;
   char buf[32];
+  LOG("do reject");
+//  set_incoming_call_state(sel_caller,CT_rejected);
 
   if (NULL != call)
   {
@@ -780,6 +943,7 @@
     return;
   case PS_LISTEN:
     /* look for active incoming calls to refuse */
+    /*
     cl = cl_head;
     if (NULL == cl)
     {
@@ -800,22 +964,32 @@
       LOG (_("There is no incoming call `%s' to refuse right now!\n"), args);
       return;
     }
-    GNUNET_CONVERSATION_caller_hang_up (cl->caller);
+    */
+    //GNUNET_CONVERSATION_caller_hang_up (cl->caller);
+    set_incoming_call_state(sel_caller,CT_rejected);
+    GNUNET_CONVERSATION_caller_hang_up(sel_caller);
+
+    /*
     GNUNET_CONTAINER_DLL_remove (cl_head, cl_tail, cl);
     peer_name = GNUNET_strdup (cl->caller_id);
     GNUNET_free (cl->caller_id);
     GNUNET_free (cl);
+    */
 //    caller_num_gen--;
     break;
   case PS_ACCEPTED:
     /* expected state, do rejection logic */
     history_add (CH_REJECTED, peer_name);
+    /*
     GNUNET_assert (NULL != cl_active);
     GNUNET_CONVERSATION_caller_hang_up (cl_active->caller);
     GNUNET_free (cl_active->caller_id);
     GNUNET_free (cl_active);
     GNUNET_assert (caller_num_gen > 0);
 //    caller_num_gen--;
+    */
+    set_incoming_call_state(sel_caller,CT_hangup);
+    GNUNET_CONVERSATION_caller_hang_up(sel_caller);
     cl_active = NULL;
     phone_state = PS_LISTEN;
     break;
@@ -982,12 +1156,11 @@
   { 
   GNUNET_IDENTITY_ego_get_public_key (ego, &pk);
   s = GNUNET_CRYPTO_ecdsa_public_key_to_string (&pk);
-  fprintf (stdout, "%s \n", name);
-  gtk_list_store_insert_with_values (zone_liststore,
-                                       &iter, -1,
-                                       0, name,
-                                      1, ego,
-                                       -1); 
+//  fprintf (stdout, "%s \n", name);
+//  gtk_list_store_insert_with_values (zone_liststore,
+//                                       &iter, -1,
+//                                       0, name,
+//                                       -1); 
   }
 
 
@@ -997,7 +1170,7 @@
   {
     if (verbose)
       LOG (_("Name of our ego changed to `%s'\n"), name);
-    GNUNET_free (ego_name);
+    //GNUNET_free (ego_name);
     ego_name = GNUNET_strdup (name);
     return;
   }
@@ -1112,7 +1285,7 @@
   GNUNET_MICROPHONE_destroy (mic);
   mic = NULL;
   ego_name = NULL;
-  GNUNET_free_non_null (peer_name);
+  //GNUNET_free_non_null (peer_name);
   phone_state = PS_ERROR;
 
   GNUNET_SCHEDULER_shutdown ();
@@ -1275,6 +1448,7 @@
  * @param caller_id
  */
 
+/*
 void
 quick_message (gchar * message, const char *caller_id)
 {
@@ -1309,10 +1483,10 @@
   case GTK_RESPONSE_ACCEPT:
     do_status ("");
     gtk_widget_destroy (GTK_WIDGET (dialog));
-    do_accept ("0");
+//    do_accept ("0");
     break;
   case GTK_RESPONSE_REJECT:
-    do_reject ("0");
+//    do_reject (caller_selected);
     do_status ("");
     gtk_widget_destroy (GTK_WIDGET (dialog));
     break;
@@ -1324,10 +1498,10 @@
 
 
 }
+*/
 
 
 
-
 /**
  * call clicked
  */
@@ -1346,8 +1520,8 @@
 //    FPRINTF (stderr, _("calling: %s \n"), to_addr );
 
   do_call (to_addr);
-  disable_button ("GNUNET_GTK_conversation_accept_button");
-  do_status ("");
+  //disable_button ("GNUNET_GTK_conversation_accept_button");
+  do_status ();
 //  free(to_addr);
 }
 
@@ -1357,14 +1531,18 @@
 void
 GNUNET_CONVERSATION_GTK_on_hangup_clicked ()
 {
-  //update_status()disable_button("GNUNET_CONVERSATION_GTK_call_button");
+  //update_status()
+  //disable_button("GNUNET_CONVERSATION_GTK_call_button");
+  //FPRINTF (stderr, "hangup clicked \n");
 
-  enable_button ("GNUNET_GTK_conversation_call_button");
+//  enable_button ("GNUNET_GTK_conversation_call_button");
 
 
   //FPRINTF (stderr, "hangup clicked \n");
-  do_reject (NULL);
-  do_status ("");
+
+  do_reject (caller_selected);
+
+  do_status ();
   //history_add(3,peer_name);
 }
 
@@ -1374,8 +1552,8 @@
 void
 GNUNET_CONVERSATION_GTK_on_accept_clicked ()
 {
-  FPRINTF (stderr, "accept clicked \n");
-  do_accept (0);
+  //FPRINTF (stderr, "accept clicked \n");
+  do_accept (caller_selected);
   // hide_infobar ();
 }
 
@@ -1387,7 +1565,7 @@
 GNUNET_CONVERSATION_GTK_on_reject_clicked ()
 {
   LOG ("reject clicked \n");
-  do_reject ("0");
+  do_reject (caller_selected);
 }
 
 /**
@@ -1397,7 +1575,7 @@
 GNUNET_CONVERSATION_GTK_on_pause_clicked ()
 {
 //    GtkEntry *entry;
-  do_suspend ("0");
+  do_suspend (caller_selected);
   //FPRINTF (stderr, "pause clicked \n");
   //do_pause("");
   //  entry = GTK_ENTRY((get_object ("GNUNET_GTK_conversation_address")));
@@ -1413,7 +1591,7 @@
 GNUNET_CONVERSATION_GTK_on_resume_clicked ()
 {
   //FPRINTF (stderr, "reject clicked \n");
-  do_resume ("");
+  do_resume (caller_selected);
 }
 
 /**
@@ -1425,7 +1603,7 @@
 
 
 //    do_accept("0");
-  do_status (" ");
+  do_status ();
   //quick_message('hee blaaat you have a call from blaat');
 }
 
@@ -1455,9 +1633,9 @@
   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);
+  //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))
   {
@@ -1509,7 +1687,7 @@
   if (gtk_tree_selection_get_selected (selection, &model, &iter))
   {
     gtk_tree_model_get (model, &iter, 0, &name, -1);
-    FPRINTF (stderr, "selected %s \n", name);
+    //FPRINTF (stderr, "selected %s \n", name);
     main_window = GTK_WINDOW (get_object ("GNUNET_GTK_conversation_window"));
     confirm =
         GTK_DIALOG (gtk_dialog_new_with_buttons
@@ -1566,7 +1744,7 @@
   gchar *callAddress;
   gchar *type;
 
-  FPRINTF (stderr, "row activated \n");
+//  FPRINTF (stderr, "row activated \n");
 
   GtkTreeSelection *selection;
 
@@ -1577,9 +1755,9 @@
 
   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 ("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);
@@ -1602,41 +1780,6 @@
 }
 
 /*
- * set_status_icon
- * 
- * available icons:
- * gnunet-conversation-tray-pending
- * gnunet-conversation-tray-available
- * gnunet-conversation-tray-offline
- * gnunet-conversation-tray-call-pending
- * gnunet-conversation-tray-call-ringing
- * gnunet-conversation-tray-call-active
- * gnunet-conversation-tray-call-suspended
- * gnunet-conversation-tray-call-incoming
- *
- */
-
-void
-set_status_icon (const char *icon_name)
-{
-  GtkWindow *main_window;
-  GtkImage *status_icon;
-
-
-
-  main_window = GTK_WINDOW (get_object ("GNUNET_GTK_conversation_window"));
-
-  status_icon = GTK_IMAGE (get_object ("GNUNET_GTK_status_icon"));
-
-  gtk_image_set_from_icon_name (status_icon, icon_name, GTK_ICON_SIZE_BUTTON);
-
-  LOG (_("Tray icon changed to: `%s' "), icon_name);
-
-
-
-  GNUNET_GTK_tray_icon_change (icon_name, "gnunet-conversation-gtk-status");
-}
-
 static void
 print_ego (void *cls,
           struct GNUNET_IDENTITY_Ego *ego,
@@ -1650,8 +1793,8 @@
   fprintf (stdout, "%s \n", identifier);
 //  GNUNET_free (s);
 }
+*/
 
-
 /* end of gnunet-conversation-gtk.c */
 void
 GNUNET_contact_test ()
@@ -1665,30 +1808,28 @@
 //  struct GNUNET_GTK_NAMESTORE_PluginEnvironment *edc;
 //  edc = GNUNET_new (struct GNUNET_GTK_NAMESTORE_PluginEnvironment); 
 */
-//  GtkTreeIter iter;
-//  char *caller_id = "testje";
-//  int  caller_num = 10; 
 
- /*
- * active_liststore:
- * 0: *gchar caller_id
- * 1: pointer caller
- * 2: gint caller_num
- */
-/*
+  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);
-*/ 
 //  static struct GNUNET_IDENTITY_Handle *sh;  
 //  GNUNET_IDENTITY_disconnect (id);
 //  &print_ego;
-  //sh = GNUNET_IDENTITY_connect (cfg, &print_ego, NULL); 
+//sh = GNUNET_IDENTITY_connect (cfg, &print_ego, NULL); 
 //  GNUNET_NAMESTORE_zone_iterator_next(list_it);
 } 
 
@@ -1715,7 +1856,6 @@
   char *tempName;
   struct GNUNET_CRYPTO_EcdsaPrivateKey temp_zone_pkey;
 
-
   gtk_combo_box_get_active_iter(widget, &contacts_zone_iter);   
 
   gtk_tree_model_get (GTK_TREE_MODEL (zone_liststore),
@@ -1740,3 +1880,114 @@
 
 }
 
+/*
+ * @brief print info for currently selected call
+ */
+void
+print_call_info()
+{
+    GtkTreeIter gtkiter;
+    gboolean valid;
+    gint row_count = 0;
+
+    //LOG("test");
+    valid = gtk_tree_model_get_iter_first( GTK_TREE_MODEL( active_liststore ), 
&gtkiter ); 
+    
+    if (!valid) 
+        GNUNET_break(0);
+    
+    while (valid)
+    {
+      gchar *str_data;
+      gint   int_data;
+      gpointer cl_caller;
+     
+      gtk_tree_model_get (GTK_TREE_MODEL(active_liststore), &gtkiter, 
+                          AL_caller, &cl_caller,
+                          AL_caller_id,&str_data,
+                          AL_caller_num,&int_data,-1);
+      if (caller_selected == cl_caller)
+      {
+       // LOG (_("info for active 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), 
&gtkiter);
+    }
+
+
+
+}
+
+/*
+ * @brief executed when selecting a call
+ */
+
+void
+GNUNET_CONVERSATION_GTK_on_active_calls_selection_changed()
+{
+   gchar *caller_id;
+   gpointer cl_caller;
+   GtkTreeSelection *active_selection;
+   GtkTreeIter gcl_selected;
+//   active_liststore_selection = 
get_object("GNUNET_CONVERSATION_GTK_active_calls_selection");
+
+   active_selection = gtk_tree_view_get_selection (GTK_TREE_VIEW 
(active_treeview));
+
+
+   if (gtk_tree_selection_get_selected(active_selection,NULL,&gcl_selected))
+   {
+
+        gtk_tree_model_get (GTK_TREE_MODEL(active_liststore), &gcl_selected, 
+                            AL_caller, &cl_caller,
+                            AL_caller_id, &caller_id,
+                            -1);
+                 
+        caller_selected = cl_caller;
+
+        //LOG("SELECTION: %s ",caller_id);
+        print_call_info();    
+
+   }
+}
+/*
+ * @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), "state: %u", state);
+ 
+     //g_object_set(renderer, "text", buf, NULL);
+   }
+
+
+/*
+ * @brief second test button
+ */
+void
+GNUNET_CONVERSATION_GTK_test_button_two()
+{
+ GtkTreeViewColumn *column;
+ GtkCellRenderer *cell;
+
+ //LOG("test");
+// treeview = get_object("gnunet_conversation_gtk_active_calls_treeview");
+ column = get_object("GNUNET_CONVERSATION_GTK_caller_typeColumn");
+ cell = gtk_cell_renderer_text_new();
+ //cell = get_object("GNUNET_CONVERSATION_GTK_active_calls_type");
+ gtk_tree_view_column_set_cell_data_func(column, cell, 
active_calls_type_data_function, NULL, NULL );
+
+}
+
+

Modified: gnunet-gtk/src/conversation/gnunet-conversation-gtk.h
===================================================================
--- gnunet-gtk/src/conversation/gnunet-conversation-gtk.h       2014-02-11 
17:49:09 UTC (rev 32313)
+++ gnunet-gtk/src/conversation/gnunet-conversation-gtk.h       2014-02-11 
18:31:06 UTC (rev 32314)
@@ -38,16 +38,57 @@
 
 #define LOG(format, ...) log_message(g_strdup_printf (format, ## __VA_ARGS__))
 
-#define MAX_TO_ADDR 124
 
 
 /**
+  * List of active calls
+  */
+ static GtkListStore *active_liststore;
+ 
+ /**
+  * List of active calls
+  */
+ static GtkTreeView *active_treeview;
+
+
+/*
+ * 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
+};
+
+
+/**
  * Get our configuration.
  *
  * @return configuration handle
  */
 const struct GNUNET_CONFIGURATION_Handle *
-GIG_get_configuration (void);
+GIG_get_configuration ();
 
 
 /**
@@ -155,6 +196,11 @@
   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;
@@ -177,21 +223,31 @@
  * 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.
@@ -296,19 +352,8 @@
 identity_cb (void *cls, struct GNUNET_IDENTITY_Ego *ego, void **ctx,
              const char *name);
 
-/**
- * List of active calls
- */
-static GtkListStore *active_liststore;
 
 /**
- * List of active calls
- */
-static GtkTreeView *active_treeview;
-
-
-
-/**
  * List of contacts (records).
  */
 static GtkListStore *contacts_liststore;




reply via email to

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