ekiga r6191 - in trunk: . lib/engine/addressbook/call-history lib/engine/gui/gtk-frontend lib/engine/protocol/skel src/endpoints



Author: dsandras
Date: Sun Apr 13 21:35:49 2008
New Revision: 6191
URL: http://svn.gnome.org/viewvc/ekiga?rev=6191&view=rev

Log:
Improved API. Use time_t as return type for the call start time in
order to allow easier handling in the views. Changed History::Contact
API in order to get rid of the status parameter, use two additional
for call duration and start instead, specific to History contacts, as
they are related to calls. Improved the history view. Added a few
const and reference passing.


Modified:
   trunk/ChangeLog
   trunk/lib/engine/addressbook/call-history/history-book.cpp
   trunk/lib/engine/addressbook/call-history/history-book.h
   trunk/lib/engine/addressbook/call-history/history-contact.cpp
   trunk/lib/engine/addressbook/call-history/history-contact.h
   trunk/lib/engine/gui/gtk-frontend/call-history-view-gtk.cpp
   trunk/lib/engine/protocol/skel/call.h
   trunk/src/endpoints/opal-call.cpp
   trunk/src/endpoints/opal-call.h

Modified: trunk/lib/engine/addressbook/call-history/history-book.cpp
==============================================================================
--- trunk/lib/engine/addressbook/call-history/history-book.cpp	(original)
+++ trunk/lib/engine/addressbook/call-history/history-book.cpp	Sun Apr 13 21:35:49 2008
@@ -114,10 +114,11 @@
 }
 
 void
-History::Book::add (const std::string name,
-		    const std::string uri,
-		    const std::string contact_status,
-		    call_type c_t)
+History::Book::add (const std::string & name,
+		    const std::string & uri,
+                    const time_t call_start,
+                    const std::string & call_duration,
+		    const call_type c_t)
 {
   Contact *contact = NULL;
   xmlNodePtr root = NULL;
@@ -126,7 +127,7 @@
 
     root = xmlDocGetRootElement (doc);
 
-    contact = new Contact (core, name, uri, contact_status, c_t);
+    contact = new Contact (core, name, uri, call_start, call_duration, c_t);
 
     xmlAddChild (root, contact->get_node ());
 
@@ -204,12 +205,10 @@
 History::Book::on_missed_call (Ekiga::CallManager &/*manager*/,
 			       Ekiga::Call &call)
 {
-  std::stringstream info;
-  info << call.get_start_time () << " " << call.get_duration ();
-
   add (call.get_remote_party_name (),
        call.get_remote_uri (),
-       info.str (),
+       call.get_start_time (),
+       call.get_duration (),
        MISSED);
 }
 
@@ -218,10 +217,9 @@
 				Ekiga::Call &call,
 				std::string /*message*/)
 {
-  std::stringstream info;
-  info << call.get_start_time () << " " << call.get_duration ();
   add (call.get_remote_party_name (),
        call.get_remote_uri (),
-       info.str (),
+       call.get_start_time (),
+       call.get_duration (),
        (call.is_outgoing ()?PLACED:RECEIVED));
 }

Modified: trunk/lib/engine/addressbook/call-history/history-book.h
==============================================================================
--- trunk/lib/engine/addressbook/call-history/history-book.h	(original)
+++ trunk/lib/engine/addressbook/call-history/history-book.h	Sun Apr 13 21:35:49 2008
@@ -75,10 +75,11 @@
 
     /* more specific api */
 
-    void add (const std::string name,
-	      const std::string uri,
-	      const std::string status,
-	      call_type c_t);
+    void add (const std::string & name,
+              const std::string & uri,
+              const time_t call_start,
+              const std::string & call_duration,
+              const call_type c_t);
 
     void clear ();
 

Modified: trunk/lib/engine/addressbook/call-history/history-contact.cpp
==============================================================================
--- trunk/lib/engine/addressbook/call-history/history-contact.cpp	(original)
+++ trunk/lib/engine/addressbook/call-history/history-contact.cpp	Sun Apr 13 21:35:49 2008
@@ -38,6 +38,7 @@
 
 #include "history-contact.h"
 
+
 History::Contact::Contact (Ekiga::ServiceCore &_core,
 			   xmlNodePtr _node):
   core(_core), node(_node)
@@ -72,24 +73,35 @@
         xmlFree (xml_str);
       }
 
-      if (xmlStrEqual (BAD_CAST ("status"), child->name)) {
+      if (xmlStrEqual (BAD_CAST ("call_start"), child->name)) {
+
+        xml_str = xmlNodeGetContent (child);
+	if (xml_str != NULL)
+	  call_start = (time_t) atoi ((const char *) xml_str);
+        xmlFree (xml_str);
+      }
+
+      if (xmlStrEqual (BAD_CAST ("call_duration"), child->name)) {
 
         xml_str = xmlNodeGetContent (child);
 	if (xml_str != NULL)
-	  status = (const char *)xml_str;
+	  call_duration = (unsigned) atoi ((const char *) xml_str);
         xmlFree (xml_str);
       }
     }
   }
 }
 
+
 History::Contact::Contact (Ekiga::ServiceCore &_core,
 			   const std::string _name,
 			   const std::string _uri,
-			   const std::string _status,
+                           time_t _call_start,
+                           const std::string _call_duration,
 			   call_type c_t):
-  core(_core), name(_name), uri(_uri), status(_status), m_type(c_t)
+  core(_core), name(_name), uri(_uri), call_start(_call_start), call_duration(_call_duration), m_type(c_t)
 {
+  std::string callp;
   contact_core
     = dynamic_cast<Ekiga::ContactCore*>(core.get ("contact-core"));
 
@@ -98,14 +110,19 @@
   xmlSetProp (node, BAD_CAST "uri", BAD_CAST uri.c_str ());
   xmlNewChild (node, NULL,
 	       BAD_CAST "name", BAD_CAST name.c_str ());
+
+  callp = call_start;
   xmlNewChild (node, NULL,
-	       BAD_CAST "status", BAD_CAST status.c_str ());
+	       BAD_CAST "call_start", BAD_CAST callp.c_str ());
+  callp = call_duration;
+  xmlNewChild (node, NULL,
+	       BAD_CAST "call_duration", BAD_CAST callp.c_str ());
 
   /* FIXME: I don't like the way it's done */
-  gchar *type_string = NULL;
-  type_string = g_strdup_printf ("%d", m_type);
-  xmlSetProp (node, BAD_CAST "type", BAD_CAST type_string);
-  g_free (type_string);
+  gchar *tmp = NULL;
+  tmp = g_strdup_printf ("%d", m_type);
+  xmlSetProp (node, BAD_CAST "type", BAD_CAST tmp);
+  g_free (tmp);
 }
 
 History::Contact::~Contact ()
@@ -156,16 +173,22 @@
   return node;
 }
 
-History::call_type
+const History::call_type
 History::Contact::get_type () const
 {
   return m_type;
 }
 
-const std::string
-History::Contact::get_status () const
+const time_t
+History::Contact::get_call_start () const
+{
+  return call_start;
+}
+
+const std::string 
+History::Contact::get_call_duration () const
 {
-  return status;
+  return call_duration;
 }
 
 const std::map<std::string,std::string>

Modified: trunk/lib/engine/addressbook/call-history/history-contact.h
==============================================================================
--- trunk/lib/engine/addressbook/call-history/history-contact.h	(original)
+++ trunk/lib/engine/addressbook/call-history/history-contact.h	Sun Apr 13 21:35:49 2008
@@ -67,12 +67,13 @@
     Contact (Ekiga::ServiceCore &_core,
 	     const std::string _name,
 	     const std::string _uri,
-	     const std::string _status,
+             time_t call_start,
+             const std::string call_duration,
 	     call_type c_t);
 
     ~Contact ();
 
-    /* generic presentity api */
+    /*** generic contact api ***/
 
     const std::string get_name () const;
 
@@ -84,13 +85,15 @@
 
     bool is_found (std::string test) const;
 
-    /* more specific api */
+    /*** more specific api ***/
 
     xmlNodePtr get_node ();
 
-    call_type get_type () const;
+    const call_type get_type () const;
 
-    const std::string get_status () const;
+    const time_t get_call_start () const;
+
+    const std::string get_call_duration () const;
 
   private:
 
@@ -100,7 +103,8 @@
     xmlNodePtr node;
     std::string name;
     std::string uri;
-    std::string status;
+    time_t call_start;
+    std::string call_duration;
     call_type m_type;
   };
 

Modified: trunk/lib/engine/gui/gtk-frontend/call-history-view-gtk.cpp
==============================================================================
--- trunk/lib/engine/gui/gtk-frontend/call-history-view-gtk.cpp	(original)
+++ trunk/lib/engine/gui/gtk-frontend/call-history-view-gtk.cpp	Sun Apr 13 21:35:49 2008
@@ -35,6 +35,10 @@
  *
  */
 
+#include <sstream>
+#include <iostream>
+#include <iomanip>
+
 #include "call-history-view-gtk.h"
 
 #include "menu-builder-gtk.h"
@@ -66,9 +70,14 @@
 on_contact_added (Ekiga::Contact &contact,
 		  GtkListStore *store)
 {
+  time_t t;
+  struct tm *timeinfo = NULL;
+  char buffer [80];
+  std::stringstream info;
+  const gchar *id = NULL;
+
   History::Contact *hcontact = NULL;
   GtkTreeIter iter;
-  const gchar *id = NULL;
 
   hcontact = dynamic_cast<History::Contact*>(&contact);
 
@@ -94,15 +103,20 @@
     default:
       id = GTK_STOCK_MISSING_IMAGE;
     }
-
   }
 
+  t = hcontact->get_call_start ();
+  timeinfo = localtime (&t);
+  strftime (buffer, 80, "%x %X", timeinfo);
+
+  info << buffer << " (" << hcontact->get_call_duration () << ")";
+
   gtk_list_store_prepend (store, &iter);
   gtk_list_store_set (store, &iter,
 		      COLUMN_CONTACT, &contact,
 		      COLUMN_PIXBUF, id,
 		      COLUMN_NAME, contact.get_name ().c_str (),
-		      COLUMN_STATUS, hcontact->get_status ().c_str (),
+		      COLUMN_STATUS, info.str ().c_str (),
 		      -1);
 }
 

Modified: trunk/lib/engine/protocol/skel/call.h
==============================================================================
--- trunk/lib/engine/protocol/skel/call.h	(original)
+++ trunk/lib/engine/protocol/skel/call.h	Sun Apr 13 21:35:49 2008
@@ -39,7 +39,7 @@
 #define __CALL_H__
 
 #include <sigc++/sigc++.h>
-
+#include <time.h>
 
 namespace Ekiga
 {
@@ -129,7 +129,7 @@
       /** Return the call start date and time
        * @return the current call start date and time
        */
-      virtual const std::string get_start_time () const = 0;
+      virtual const time_t get_start_time () const = 0;
 
       /** Return information about call type
        * @return true if it is an outgoing call

Modified: trunk/src/endpoints/opal-call.cpp
==============================================================================
--- trunk/src/endpoints/opal-call.cpp	(original)
+++ trunk/src/endpoints/opal-call.cpp	Sun Apr 13 21:35:49 2008
@@ -225,10 +225,10 @@
 }
 
 
-const std::string
+const time_t 
 Opal::Call::get_start_time () const
 {
-  return (const char *) start_time.AsString (PTime::LongDateTime);
+  return start_time.GetTimeInSeconds ();
 }
 
 

Modified: trunk/src/endpoints/opal-call.h
==============================================================================
--- trunk/src/endpoints/opal-call.h	(original)
+++ trunk/src/endpoints/opal-call.h	Sun Apr 13 21:35:49 2008
@@ -129,7 +129,7 @@
     /** Return the call start date and time
      * @return the current call start date and time
      */
-    const std::string get_start_time () const;
+    const time_t get_start_time () const;
 
 
 public:



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