ekiga r5942 - in trunk: . lib/engine/components/gmconf-personal-details lib/engine/presence/avahi lib/engine/presence/local-roster lib/engine/presence/skel lib/engine/protocol/skel src src/clients src/endpoints src/gui



Author: dsandras
Date: Sun Jan 27 19:10:51 2008
New Revision: 5942
URL: http://svn.gnome.org/viewvc/ekiga?rev=5942&view=rev

Log:
Many major changes :
- All presence related details are now centralized in a
PersonalDetails class and presence publishing functions are using that
class.
- We now have a SIP implementation of a PresencePublisher. The
presence publishing code is now finally out of accountshandler.cpp.
Presence is automatically published when a registration occurs.
- Moved registration from the GMManager into the engine. It will move
to the AccountCore at a later stage.
- Added very preliminary support for extended presence messages
support (more to come).


Modified:
   trunk/ChangeLog
   trunk/ekiga.schemas.in.in
   trunk/lib/engine/components/gmconf-personal-details/gmconf-personal-details.cpp
   trunk/lib/engine/presence/avahi/Makefile.am
   trunk/lib/engine/presence/local-roster/Makefile.am
   trunk/lib/engine/presence/skel/Makefile.am
   trunk/lib/engine/presence/skel/presence-core.cpp
   trunk/lib/engine/presence/skel/presence-core.h
   trunk/lib/engine/protocol/skel/call-core.h
   trunk/lib/engine/protocol/skel/call-manager.h
   trunk/src/clients/avahi.cpp
   trunk/src/common.h
   trunk/src/endpoints/accountshandler.cpp
   trunk/src/endpoints/accountshandler.h
   trunk/src/endpoints/h323.cpp
   trunk/src/endpoints/manager.cpp
   trunk/src/endpoints/manager.h
   trunk/src/endpoints/pcss.cpp
   trunk/src/endpoints/sip.cpp
   trunk/src/endpoints/sip.h
   trunk/src/gui/accounts.cpp
   trunk/src/gui/conf.cpp
   trunk/src/gui/main.cpp
   trunk/src/gui/main.h
   trunk/src/gui/statusicon.cpp

Modified: trunk/ekiga.schemas.in.in
==============================================================================
--- trunk/ekiga.schemas.in.in	(original)
+++ trunk/ekiga.schemas.in.in	Sun Jan 27 19:10:51 2008
@@ -146,36 +146,36 @@
       </locale>
     </schema>
     <schema>	
-      <key>/schemas/apps/@PACKAGE_NAME@/general/personal_data/firstname</key>
-      <applyto>/apps/@PACKAGE_NAME@/general/personal_data/firstname</applyto>
+      <key>/schemas/apps/@PACKAGE_NAME@/general/personal_data/full_name</key>
+      <applyto>/apps/@PACKAGE_NAME@/general/personal_data/full_name</applyto>
       <owner>Ekiga</owner>
       <type>string</type>
       <default></default>
       <locale name="C">
-	<short>First name</short>
-	<long>Enter your first name</long>
+	<short>Full name</short>
+	<long>Enter your full name</long>
       </locale>
     </schema>
     <schema>
-      <key>/schemas/apps/@PACKAGE_NAME@/general/personal_data/lastname</key>
-      <applyto>/apps/@PACKAGE_NAME@/general/personal_data/lastname</applyto>
+      <key>/schemas/apps/@PACKAGE_NAME@/general/personal_data/short_status</key>
+      <applyto>/apps/@PACKAGE_NAME@/general/personal_data/short_status</applyto>
       <owner>Ekiga</owner>
       <type>string</type>
-      <default></default>
+      <default>online</default>
       <locale name="C">
-	<short>Last name</short>
-	<long>Enter your last name</long>
+	<short>Contact short status</short>
+	<long>The short status information</long>
       </locale>
     </schema>
     <schema>
-      <key>/schemas/apps/@PACKAGE_NAME@/general/personal_data/status</key>
-      <applyto>/apps/@PACKAGE_NAME@/general/personal_data/status</applyto>
+      <key>/schemas/apps/@PACKAGE_NAME@/general/personal_data/long_status</key>
+      <applyto>/apps/@PACKAGE_NAME@/general/personal_data/long_status</applyto>
       <owner>Ekiga</owner>
-      <type>int</type>
-      <default>0</default>
+      <type>string</type>
+      <default>I'm online using Ekiga</default>
       <locale name="C">
-	<short>Contact status</short>
-	<long>Select the contact status: 0 (Online), 1 (Offline), 2 (Unknown), 3 (Away), 4 (DND), 5 (Free For Chat), 6 (Invisible)</long>
+	<short>Contact long status</short>
+	<long>The long status information</long>
       </locale>
     </schema>
     <schema>

Modified: trunk/lib/engine/components/gmconf-personal-details/gmconf-personal-details.cpp
==============================================================================
--- trunk/lib/engine/components/gmconf-personal-details/gmconf-personal-details.cpp	(original)
+++ trunk/lib/engine/components/gmconf-personal-details/gmconf-personal-details.cpp	Sun Jan 27 19:10:51 2008
@@ -86,5 +86,8 @@
                         short_status_changed_nt, this);
   gm_conf_notifier_add ("/apps/ekiga/general/personal_data/long_status",
                         long_status_changed_nt, this);
+  gm_conf_notifier_trigger ("/apps/ekiga/general/personal_data/full_name");
+  gm_conf_notifier_trigger ("/apps/ekiga/general/personal_data/short_status");
+  gm_conf_notifier_trigger ("/apps/ekiga/general/personal_data/long_status");
 }
 

Modified: trunk/lib/engine/presence/avahi/Makefile.am
==============================================================================
--- trunk/lib/engine/presence/avahi/Makefile.am	(original)
+++ trunk/lib/engine/presence/avahi/Makefile.am	Sun Jan 27 19:10:51 2008
@@ -6,6 +6,7 @@
 
 INCLUDES = \
 	-I$(top_srcdir)/lib/engine/framework \
+	-I$(top_srcdir)/lib/engine/protocol/skel \
 	-I$(top_srcdir)/lib/engine/presence/skel
 
 libgmavahi_la_SOURCES = \

Modified: trunk/lib/engine/presence/local-roster/Makefile.am
==============================================================================
--- trunk/lib/engine/presence/local-roster/Makefile.am	(original)
+++ trunk/lib/engine/presence/local-roster/Makefile.am	Sun Jan 27 19:10:51 2008
@@ -8,6 +8,7 @@
 	-I$(top_srcdir)/lib/gmconf	 		\
 	-I$(top_srcdir)/lib/engine/framework 		\
 	-I$(top_srcdir)/lib/engine/addressbook/skel	\
+	-I$(top_srcdir)/lib/engine/protocol/skel	\
 	-I$(top_srcdir)/lib/engine/presence/skel
 
 liblocal_roster_la_SOURCES = \

Modified: trunk/lib/engine/presence/skel/Makefile.am
==============================================================================
--- trunk/lib/engine/presence/skel/Makefile.am	(original)
+++ trunk/lib/engine/presence/skel/Makefile.am	Sun Jan 27 19:10:51 2008
@@ -7,7 +7,8 @@
 INCLUDES = \
 	-I$(top_srcdir)/lib/engine/include \
 	-I$(top_srcdir)/lib/engine/framework \
-	-I$(top_srcdir)/lib/engine/presence/skel
+	-I$(top_srcdir)/lib/engine/presence/skel \
+	-I$(top_srcdir)/lib/engine/protocol/skel
 
 libgmpresence_la_SOURCES = \
 	$(presence_dir)/presentity.h		\

Modified: trunk/lib/engine/presence/skel/presence-core.cpp
==============================================================================
--- trunk/lib/engine/presence/skel/presence-core.cpp	(original)
+++ trunk/lib/engine/presence/skel/presence-core.cpp	Sun Jan 27 19:10:51 2008
@@ -37,22 +37,46 @@
 
 #include <iostream>
 
+#include "call-core.h"
 #include "presence-core.h"
 #include "personal-details.h"
 
 
 Ekiga::PresencePublisher::PresencePublisher (Ekiga::ServiceCore & core)
 {
+  Ekiga::CallCore *call_core = dynamic_cast <Ekiga::CallCore *> (core.get ("call-core"));
   Ekiga::PersonalDetails *details = dynamic_cast <Ekiga::PersonalDetails *> (core.get ("personal-details"));
 
-  if (details) // If none, then we have no implementation of personal-details and won't relay signals
+  if (details) 
     details->personal_details_updated.connect (sigc::mem_fun (this, &Ekiga::PresencePublisher::on_personal_details_updated));
+  if (call_core)
+    call_core->registration_event.connect (sigc::bind (sigc::mem_fun (this, &Ekiga::PresencePublisher::on_registration_event), *details));
 }
 
 
 void Ekiga::PresencePublisher::on_personal_details_updated (Ekiga::PersonalDetails & details)
 {
-  this->publish (details.get_display_name (), details.get_short_status (), details.get_long_status ());
+  this->publish (details);
+}
+
+
+void Ekiga::PresencePublisher::on_registration_event (std::string /*aor*/,
+                                                      Ekiga::CallCore::RegistrationState state,
+                                                      std::string /*info*/,
+                                                      Ekiga::PersonalDetails & details)
+{
+  switch (state) {
+  case Ekiga::CallCore::Registered:
+    this->publish (details);
+    break;
+
+  case Ekiga::CallCore::Unregistered:
+  case Ekiga::CallCore::UnregistrationFailed:
+  case Ekiga::CallCore::RegistrationFailed:
+  case Ekiga::CallCore::Processing:
+  default:
+    break;
+  }
 }
 
 
@@ -193,15 +217,13 @@
   presence_publishers.insert (&publisher);
 }
 
-void Ekiga::PresenceCore::publish (const std::string & display_name,
-                                   const std::string & presence,
-                                   const std::string & extended_status)
+void Ekiga::PresenceCore::publish (const PersonalDetails & details) 
 {
   for (std::set<PresencePublisher *>::iterator iter
 	 = presence_publishers.begin ();
        iter != presence_publishers.end ();
        iter++)
-    (*iter)->publish (display_name, presence, extended_status);
+    (*iter)->publish (details);
 }
 
 bool

Modified: trunk/lib/engine/presence/skel/presence-core.h
==============================================================================
--- trunk/lib/engine/presence/skel/presence-core.h	(original)
+++ trunk/lib/engine/presence/skel/presence-core.h	Sun Jan 27 19:10:51 2008
@@ -40,11 +40,10 @@
 
 #include "services.h"
 #include "cluster.h"
-
+#include "call-core.h"
 
 namespace Ekiga
 {
-
   class PersonalDetails;
 
 /**
@@ -107,11 +106,14 @@
     PresencePublisher (Ekiga::ServiceCore &);
     virtual ~PresencePublisher () {};
 
-    virtual void publish (const std::string & /*display_name*/,
-                          const std::string & /*presence*/,
-                          const std::string & /*extended_status*/) = 0;
+    virtual void publish (const PersonalDetails & details) = 0;
+
   private:
     void on_personal_details_updated (PersonalDetails & details);
+    void on_registration_event (std::string aor,
+                                Ekiga::CallCore::RegistrationState state,
+                                std::string /*info*/,
+                                Ekiga::PersonalDetails & details);
   };
 
   /** Core object for the presence support.
@@ -269,9 +271,7 @@
 
     void add_presence_publisher (PresencePublisher &publisher);
 
-    void publish (const std::string & display_name,
-                  const std::string & status, 
-                  const std::string & extended_status);
+    void publish (const PersonalDetails & details);
 
   private:
 

Modified: trunk/lib/engine/protocol/skel/call-core.h
==============================================================================
--- trunk/lib/engine/protocol/skel/call-core.h	(original)
+++ trunk/lib/engine/protocol/skel/call-core.h	Sun Jan 27 19:10:51 2008
@@ -153,6 +153,10 @@
       sigc::signal<void, CallManager &, std::string, std::string> new_chat;
 
 
+      /*** Accounts ***/
+      /* TODO should move out of here */
+      typedef enum { Processing, Registered, Unregistered, RegistrationFailed, UnregistrationFailed } RegistrationState;
+      sigc::signal<void, std::string, Ekiga::CallCore::RegistrationState, std::string> registration_event;
 
   private:
       void on_new_call (Call *call, CallManager *manager);

Modified: trunk/lib/engine/protocol/skel/call-manager.h
==============================================================================
--- trunk/lib/engine/protocol/skel/call-manager.h	(original)
+++ trunk/lib/engine/protocol/skel/call-manager.h	Sun Jan 27 19:10:51 2008
@@ -140,7 +140,6 @@
       /*          
        * Accounts
        */        
-      typedef enum { Processing, Registered, Unregistered, RegistrationFailed, UnregistrationFailed } RegistrationState;
 
 
       /** Register the provided account.

Modified: trunk/src/clients/avahi.cpp
==============================================================================
--- trunk/src/clients/avahi.cpp	(original)
+++ trunk/src/clients/avahi.cpp	Sun Jan 27 19:10:51 2008
@@ -378,10 +378,6 @@
     status = "presence-away";
     break;
 
-  case CONTACT_FREEFORCHAT:
-    status = "presence-freeforchat";
-    break;
-
   default:
     break;
   }

Modified: trunk/src/common.h
==============================================================================
--- trunk/src/common.h	(original)
+++ trunk/src/common.h	Sun Jan 27 19:10:51 2008
@@ -94,7 +94,6 @@
   CONTACT_ONLINE,
   CONTACT_AWAY,
   CONTACT_DND,
-  CONTACT_FREEFORCHAT,
   CONTACT_INVISIBLE,
   CONTACT_OFFLINE,
   CONTACT_UNKNOWN,

Modified: trunk/src/endpoints/accountshandler.cpp
==============================================================================
--- trunk/src/endpoints/accountshandler.cpp	(original)
+++ trunk/src/endpoints/accountshandler.cpp	Sun Jan 27 19:10:51 2008
@@ -121,50 +121,10 @@
 
   g_slist_foreach (defined_accounts, (GFunc) gm_account_delete, NULL);
   g_slist_free (defined_accounts);
-
-
-  while (active) {
-
-    accounts_mutex.Wait ();
-    accounts_iter = accounts;
-    while (accounts_iter) {
-
-      if (accounts_iter->data) {
-
-        list_account = GM_ACCOUNT (accounts_iter)->data;
-
-        /* Register SIP account */
-        if (list_account->protocol_name) {
-
-          if (!strcmp (list_account->protocol_name, "SIP")) 
-            SIPRegister (list_account);
-          else
-            H323Register (list_account);
-        }
-      }
-
-      accounts_iter = g_slist_next (accounts_iter);
-    }
-
-    g_slist_foreach (accounts, (GFunc) gm_account_delete, NULL);
-    g_slist_free (accounts);
-    accounts = NULL;
-    accounts_mutex.Signal ();
-
-    publishers_mutex.Wait ();
-    for (int i = 0 ; i < publishers.GetSize () ; i++) 
-      SIPPublishPresence (publishers [i], 
-                          publishers_status [i].AsInteger ());
-    publishers.RemoveAll ();
-    publishers_status.RemoveAll ();
-    
-    publishers_mutex.Signal ();
-    
-    PThread::Sleep (100);
-  }
 }
 
 
+/*
 void GMAccountsEndpoint::PublishPresence (guint status)
 {
   GSList *defined_accounts = NULL;
@@ -184,7 +144,6 @@
 
       list_account = GM_ACCOUNT (accounts_iter)->data;
 
-      /* Publish presence for SIP account */
       if (list_account->protocol_name
           && list_account->enabled
           && !strcmp (list_account->protocol_name, "SIP")) {
@@ -209,7 +168,7 @@
   g_slist_foreach (defined_accounts, (GFunc) gm_account_delete, NULL);
   g_slist_free (defined_accounts);
 }
-
+*/
 
 void GMAccountsEndpoint::RegisterAccount (GmAccount *account)
 {
@@ -222,17 +181,6 @@
 }
 
 
-void GMAccountsEndpoint::SIPPublishPresence (const PString & to,
-                                             guint status)
-{
-  GMSIPEndpoint *sipEP = NULL;
-
-  sipEP = ep.GetSIPEndpoint ();
-
-  sipEP->PublishPresence (to, status);
-}
-
-
 void GMAccountsEndpoint::SIPRegister (GmAccount *a)
 {
   std::string aor;

Modified: trunk/src/endpoints/accountshandler.h
==============================================================================
--- trunk/src/endpoints/accountshandler.h	(original)
+++ trunk/src/endpoints/accountshandler.h	Sun Jan 27 19:10:51 2008
@@ -82,13 +82,6 @@
 
 
   /* DESCRIPTION  :  /
-   * BEHAVIOR     :  Publish presence for all registered accounts.
-   * PRE          :  /
-   */
-  void PublishPresence (guint status);
-  
-
-  /* DESCRIPTION  :  /
    * BEHAVIOR     :  Register an account or unregister it.
    * PRE          :  A valid account.
    */
@@ -100,8 +93,6 @@
   void SIPRegister (GmAccount *a);
   void SIPPresenceSubscribe (PString contact,
                              bool unsubscribe);
-  void SIPPublishPresence (const PString & to,
-                           guint status);
   void H323Register (GmAccount *a);
   
 

Modified: trunk/src/endpoints/h323.cpp
==============================================================================
--- trunk/src/endpoints/h323.cpp	(original)
+++ trunk/src/endpoints/h323.cpp	Sun Jan 27 19:10:51 2008
@@ -450,8 +450,6 @@
     else
       reason = 1; // Reject
   }
-  else if (status == CONTACT_FREEFORCHAT)
-    reason = 4; // Auto Answer
   else
     reason = 0; // Ask the user
 

Modified: trunk/src/endpoints/manager.cpp
==============================================================================
--- trunk/src/endpoints/manager.cpp	(original)
+++ trunk/src/endpoints/manager.cpp	Sun Jan 27 19:10:51 2008
@@ -214,7 +214,6 @@
     status = gm_conf_entry_get_int (entry);
     
     ep->UpdatePublishers ();
-    ep->PublishPresence (status);
   }
 }
 
@@ -286,6 +285,9 @@
 
   // Config
   bridge = new Opal::ConfBridge (*this);
+
+  //
+  call_core = dynamic_cast<Ekiga::CallCore *> (core.get ("call-core"));
 }
 
 
@@ -1013,18 +1015,6 @@
 }
 
 
-void 
-GMManager::PublishPresence (guint status)
-{
-  PWaitAndSignal m(manager_access_mutex);
-
-  if (manager == NULL)
-    manager = new GMAccountsEndpoint (*this);
-
-  manager->PublishPresence (status);
-}
-
-
 void
 GMManager::RemoveAccountsEndpoint ()
 {
@@ -1403,8 +1393,6 @@
   WORD min_port = 5060;
   WORD max_port = 5080;
 
-  bool success = FALSE;
-
   gnomemeeting_threads_enter ();
   iface = gm_conf_get_string (PROTOCOLS_KEY "interface");
   gnomemeeting_threads_leave ();
@@ -1437,6 +1425,8 @@
     gnomemeeting_threads_leave ();
     
     sipEP->RemoveListener (NULL);
+    sipEP->StartListeners(PStringArray());
+    /*
     if (!sipEP->StartListener (iface, port)) {
       
       port = min_port;
@@ -1452,6 +1442,7 @@
 
     g_strfreev (couple);
     g_free (ports);
+    */
   }
 
   g_free (iface);
@@ -1806,10 +1797,11 @@
 GMManager::OnRegistered (const PString & aor,
                          bool wasRegistering)
 {
-  runtime.run_in_main (sigc::bind (registration_event.make_slot (), 
-                                    std::string ((const char *) aor), 
-                                    wasRegistering ? Registered : Unregistered,
-                                    std::string ()));
+  if (call_core)
+    runtime.run_in_main (sigc::bind (call_core->registration_event.make_slot (), 
+                                     std::string ((const char *) aor), 
+                                     wasRegistering ? Ekiga::CallCore::Registered : Ekiga::CallCore::Unregistered,
+                                     std::string ()));
 }
 
 
@@ -1817,10 +1809,11 @@
 GMManager::OnRegistering (const PString & aor,
                          G_GNUC_UNUSED bool isRegistering)
 {
-  runtime.run_in_main (sigc::bind (registration_event.make_slot (), 
-                                    std::string ((const char *) aor), 
-                                    Processing,
-                                    std::string ()));
+  if (call_core)
+    runtime.run_in_main (sigc::bind (call_core->registration_event.make_slot (), 
+                                     std::string ((const char *) aor), 
+                                     Ekiga::CallCore::Processing,
+                                     std::string ()));
 }
 
 
@@ -1829,10 +1822,11 @@
                                  bool wasRegistering,
                                  std::string info)
 {
-  runtime.run_in_main (sigc::bind (registration_event.make_slot (), 
-                                   std::string ((const char *) aor), 
-                                   wasRegistering ? RegistrationFailed : UnregistrationFailed,
-                                   info));
+  if (call_core)
+    runtime.run_in_main (sigc::bind (call_core->registration_event.make_slot (), 
+                                     std::string ((const char *) aor), 
+                                     wasRegistering ? Ekiga::CallCore::RegistrationFailed : Ekiga::CallCore::UnregistrationFailed,
+                                     info));
 }
 
 

Modified: trunk/src/endpoints/manager.h
==============================================================================
--- trunk/src/endpoints/manager.h	(original)
+++ trunk/src/endpoints/manager.h	Sun Jan 27 19:10:51 2008
@@ -508,13 +508,6 @@
 
   
   /* DESCRIPTION  :  /
-   * BEHAVIOR     :  Publish new presence information.
-   * PRE          :  /
-   */
-  void PublishPresence (guint status);
-
-  
-  /* DESCRIPTION  :  /
    * BEHAVIOR     :  Remove the account manager.
    * PRE          :  /
    */
@@ -575,8 +568,6 @@
   virtual void OnClosedMediaStream (const OpalMediaStream &);
 
 
-  typedef enum { Processing, Registered, Unregistered, RegistrationFailed, UnregistrationFailed } RegistrationState;
-  sigc::signal<void, std::string, GMManager::RegistrationState, std::string> registration_event;
   sigc::signal<void, std::string, std::string, unsigned int> mwi_event;
 
  private:
@@ -683,6 +674,7 @@
   Ekiga::Runtime & runtime;
   Ekiga::ConfBridge *bridge;
   Ekiga::CodecList codecs; 
+  Ekiga::CallCore *call_core;
 };
 
 #endif

Modified: trunk/src/endpoints/pcss.cpp
==============================================================================
--- trunk/src/endpoints/pcss.cpp	(original)
+++ trunk/src/endpoints/pcss.cpp	Sun Jan 27 19:10:51 2008
@@ -106,13 +106,6 @@
   /* The token identifying the current call */
   incomingConnectionToken = connection.GetToken ();
 
-  /* If it is an auto-answer, answer now */
-  if (status == CONTACT_FREEFORCHAT) {
-  
-    AcceptCurrentIncomingCall ();
-    return TRUE;
-  }
-
   /* The timers */
   CallPendingTimer.RunContinuous (interval);
   

Modified: trunk/src/endpoints/sip.cpp
==============================================================================
--- trunk/src/endpoints/sip.cpp	(original)
+++ trunk/src/endpoints/sip.cpp	Sun Jan 27 19:10:51 2008
@@ -38,6 +38,8 @@
 
 #include "config.h"
 
+#include <sstream>
+
 #include "sip.h"
 #include "pcss.h"
 #include "ekiga.h"
@@ -59,6 +61,7 @@
 #include <sip/handlers.h>
 
 #include "presence-core.h"
+#include "personal-details.h"
 
 #define new PNEW
 
@@ -155,8 +158,14 @@
     endpoint (ep), 
     core (_core)
 {
+  uri_prefix = "sip:";
+
   NoAnswerTimer.SetNotifier (PCREATE_NOTIFIER (OnNoAnswerTimeout));
   Init ();
+
+  Ekiga::PersonalDetails *details = dynamic_cast<Ekiga::PersonalDetails *> (_core.get ("personal-details"));
+  if (details)
+    publish (*details);
 }
 
 
@@ -200,11 +209,48 @@
 
 
 void 
-GMSIPEndpoint::publish (const std::string & display_name,
-                        const std::string & presence,
-                        const std::string & extended_status)
+GMSIPEndpoint::publish (const Ekiga::PersonalDetails & details)
 {
-  std::cout << "should publish" << display_name << std::endl << std::flush;
+  std::string hostname = (const char *) PIPSocket::GetHostName ();
+  // TODO: move this code outside of this class and allow a 
+  // more complete document
+  std::string status = ((Ekiga::PersonalDetails &) (details)).get_short_status ();
+  for (std::list<std::string>::iterator it = aors.begin ();
+       it != aors.end ();
+       it++) {
+    std::string to = it->substr (4);
+    PString data;
+    data += "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n";
+
+    data += "<presence xmlns=\"urn:ietf:params:xml:ns:pidf\" entity=\"pres:";
+    data += to;
+    data += "\">\r\n";
+
+    data += "<tuple id=\"";
+    data += to; 
+    data += "_on_";
+    data += hostname;
+    data += "\">\r\n";
+
+    data += "<note>";
+    data += status.c_str ();
+    data += "</note>\r\n";
+
+    data += "<status>\r\n";
+    data += "<basic>";
+    data += "open";
+    data += "</basic>\r\n";
+    data += "</status>\r\n";
+
+    data += "<contact priority=\"1\">sip:";
+    data += to;
+    data += "</contact>\r\n";
+
+    data += "</tuple>\r\n";
+    data += "</presence>\r\n";
+    Publish (to.c_str (), data, 500); // TODO: allow to change the 500 
+    std::cout << "hey" << data << std::endl << std::flush;
+  }
 }
 
 
@@ -348,65 +394,27 @@
 }
 
 
-void
-GMSIPEndpoint::PublishPresence (const PString & to,
-                                guint state)
-{
-  PString status;
-  PString note;
-  PString body;
-
-  switch (state) {
-
-  case CONTACT_ONLINE:
-    status = "Online";
-    note = "open";
-    break;
-
-  case CONTACT_OFFLINE:
-  case CONTACT_INVISIBLE:
-    status = "Offline";
-    note = "closed";
-    break;
-
-  case CONTACT_DND:
-    status = "Do Not Disturb";
-    note = "open";
-    break;
-
-  case CONTACT_AWAY:
-    status = "Away";
-    note = "open";
-    break;
-
-  case CONTACT_FREEFORCHAT:
-    status = "Free For Chat";
-    note = "open";
-    break;
-
-  default:
-    break;
-  }
-
-  body = SIPPublishHandler::BuildBody (to, note, status);
-  Publish (to, body, 500); // FIXME
-}
-
-
 void 
-GMSIPEndpoint::Register (const PString & aor,
+GMSIPEndpoint::Register (const PString & _aor,
                          const PString & authUserName,
                          const PString & password,
                          unsigned int expires,
                          bool unregister)
 {
+  std::string aor = (const char *) _aor;
+  std::stringstream strm;
   bool result = false;
 
   /* Account is enabled, and we are not registered */
   if (!unregister && !IsRegistered (aor)) {
 
+    if (aor.find (uri_prefix) == std::string::npos) 
+      strm << uri_prefix << aor;
+    else
+      strm << aor;
+
     /* Signal the OpalManager */
-    endpoint.OnRegistering (aor, true);
+    endpoint.OnRegistering (strm.str (), true); // TODO we could directly emit the signal from here
 
     /* Trigger registering */
     result = SIPEndPoint::Register (PString::Empty (), aor, authUserName, password, PString::Empty (), expires);
@@ -429,14 +437,28 @@
   std::string::size_type found;
   std::string::size_type loc = aor.find ("@", 0);
   std::string server;
+  std::stringstream strm;
 
-  guint status = CONTACT_ONLINE;
+  if (aor.find (uri_prefix) == std::string::npos) 
+    strm << uri_prefix << aor;
+  else
+    strm << aor;
 
-  /* Signal the OpalManager */
-  endpoint.OnRegistered (aor, was_registering);
+  std::list<std::string>::iterator it = find (aors.begin (), aors.end (), aor);
 
-  /* Signal the SIPEndpoint */
-  SIPEndPoint::OnRegistered (aor, was_registering);
+  if (was_registering) {
+   
+    if (it == aors.end ())
+      aors.push_back (strm.str ());
+  }
+  else {
+
+    if (it != aors.end ())
+      aors.remove (strm.str ());
+  }
+
+  /* Signal the OpalManager */
+  endpoint.OnRegistered (strm.str (), was_registering); // TODO we could directly emit the signal from here
 
   if (loc != string::npos) {
 
@@ -468,13 +490,6 @@
     }
   }
 
-  /* Publish current state */
-  if (was_registering)
-    status = gm_conf_get_int (PERSONAL_DATA_KEY "status");
-  else
-    status = CONTACT_OFFLINE;
-  PublishPresence (aor, status);
-
   /* Subscribe for MWI */
   if (!IsSubscribed (SIPSubscribe::MessageSummary, aor)) { 
     SIPSubscribe::SubscribeType t = SIPSubscribe::MessageSummary;
@@ -633,8 +648,6 @@
     else
       reason = 1; // Reject
   }
-  else if (status == CONTACT_FREEFORCHAT)
-    reason = 4; // Auto Answer
   else
     reason = 0; // Ask the user
 

Modified: trunk/src/endpoints/sip.h
==============================================================================
--- trunk/src/endpoints/sip.h	(original)
+++ trunk/src/endpoints/sip.h	Sun Jan 27 19:10:51 2008
@@ -51,6 +51,9 @@
 PDICTIONARY (msgDict, PString, PString);
 
 
+class Ekiga::PersonalDetails;
+
+
 /* Minimal SIP endpoint implementation */
 class GMSIPEndpoint 
 :   public SIPEndPoint, 
@@ -78,9 +81,7 @@
   /***/
   void fetch (const std::string uri);
   void unfetch (const std::string uri);
-  void publish (const std::string & /*display_name*/,
-                const std::string & /*presence*/,
-                const std::string & /*extended_status*/);
+  void publish (const Ekiga::PersonalDetails & details);
 
   
   /* DESCRIPTION  :  /
@@ -110,14 +111,6 @@
 
   
   /* DESCRIPTION  :  /
-   * BEHAVIOR     :  Publish presence for the user.
-   * PRE          :  /
-   */
-  void PublishPresence (const PString & to,
-                        guint status);
-  
-
-  /* DESCRIPTION  :  /
    * BEHAVIOR     :  Register the SIP endpoint to the given SIP server. 
    * PRE          :  Correct parameters.
    */
@@ -247,9 +240,11 @@
   PMutex msgDataMutex;
   msgDict msgData;
 
-  std::list <std::string> uris;    // List of subscribed uris
-  std::list <std::string> domains; // List of registered domains
+  std::list<std::string> uris;    // List of subscribed uris
+  std::list<std::string> domains; // List of registered domains
+  std::list<std::string> aors;     // List of registered aor
   Ekiga::ServiceCore & core;
-};
 
+  std::string uri_prefix;
+};
 #endif

Modified: trunk/src/gui/accounts.cpp
==============================================================================
--- trunk/src/gui/accounts.cpp	(original)
+++ trunk/src/gui/accounts.cpp	Sun Jan 27 19:10:51 2008
@@ -792,7 +792,7 @@
 
 /* Engine callbacks */
 static void on_registration_event_cb (std::string aor,
-                                      GMManager::RegistrationState state,
+                                      Ekiga::CallCore::RegistrationState state,
                                       std::string info,
                                       gpointer window)
 {
@@ -800,27 +800,27 @@
   std::string status;
 
   switch (state) {
-  case GMManager::Registered:
+  case Ekiga::CallCore::Registered:
     status = _("Registered");
     break;
 
-  case GMManager::Unregistered:
+  case Ekiga::CallCore::Unregistered:
     status = _("Unregistered");
     break;
 
-  case GMManager::UnregistrationFailed:
+  case Ekiga::CallCore::UnregistrationFailed:
     status = _("Could not unregister");
     if (!info.empty ())
       status = status + "(" + info + ")";
     break;
 
-  case GMManager::RegistrationFailed:
+  case Ekiga::CallCore::RegistrationFailed:
     status = _("Could not register");
     if (!info.empty ())
       status = status + "(" + info + ")";
     break;
 
-  case GMManager::Processing:
+  case Ekiga::CallCore::Processing:
     status = _("Processing...");
     is_processing = true;
   default:
@@ -1716,7 +1716,9 @@
 
   /* Engine Signals callbacks */
   // FIXME sigc::connection conn;
-  dynamic_cast<GMManager *> (core.get("opal-component"))->registration_event.connect (sigc::bind (sigc::ptr_fun (on_registration_event_cb), (gpointer) window));
+  Ekiga::CallCore *call_core = dynamic_cast<Ekiga::CallCore *> (core.get ("call-core"));
+  if (call_core) 
+    call_core->registration_event.connect (sigc::bind (sigc::ptr_fun (on_registration_event_cb), (gpointer) window));
   
   return window;
 }

Modified: trunk/src/gui/conf.cpp
==============================================================================
--- trunk/src/gui/conf.cpp	(original)
+++ trunk/src/gui/conf.cpp	Sun Jan 27 19:10:51 2008
@@ -89,10 +89,6 @@
 					  GmConfEntry *entry,
 					  gpointer data);
 
-static void status_changed_nt (gpointer id,
-                               GmConfEntry *entry,
-                               gpointer data);
-
 static void stay_on_top_changed_nt (gpointer id,
 				    GmConfEntry *entry,
                                     gpointer data);
@@ -189,34 +185,6 @@
 }
 
 
-/* DESCRIPTION  :  This callback is called when the status config value changes.
- * BEHAVIOR     :  Modifies the tray icon, the main window, and the menus.
- *                 Updates the presence for the endpoints.
- * PRE          :  /
- */
-static void
-status_changed_nt (G_GNUC_UNUSED gpointer id,
-                   GmConfEntry *entry,
-                   G_GNUC_UNUSED gpointer data)
-{
-  GtkWidget *main_window = NULL;
-  
-  main_window = GnomeMeeting::Process ()->GetMainWindow ();
-  guint status = 0;
-
-  if (gm_conf_entry_get_type (entry) == GM_CONF_INT) {
-
-    gdk_threads_enter ();
-    
-    status = gm_conf_entry_get_int (entry);
-    
-    gm_main_window_set_status (main_window, status);
-    
-    gdk_threads_leave ();
-  }
-}
-
-
 /* DESCRIPTION  :  This callback is called when the "stay_on_top" 
  *                 config value changes.
  * BEHAVIOR     :  Changes the hint for the video windows.
@@ -302,11 +270,6 @@
    */
 
   
-  /* Notifiers for the PERSONAL_DATA_KEY keys */
-  gm_conf_notifier_add (PERSONAL_DATA_KEY "status",
-			status_changed_nt, NULL);
-
-  
   /* Notifiers for the USER_INTERFACE_KEY keys */
   gm_conf_notifier_add (USER_INTERFACE_KEY "main_window/panel_section",
 			panel_section_changed_nt, main_window);

Modified: trunk/src/gui/main.cpp
==============================================================================
--- trunk/src/gui/main.cpp	(original)
+++ trunk/src/gui/main.cpp	Sun Jan 27 19:10:51 2008
@@ -533,30 +533,30 @@
 
 
 static void on_registration_event_cb (std::string aor,
-                                      GMManager::RegistrationState state,
+                                      Ekiga::CallCore::RegistrationState state,
                                       G_GNUC_UNUSED std::string info,
                                       gpointer window)
 {
   gchar *msg = NULL;
 
   switch (state) {
-  case GMManager::Registered:
+  case Ekiga::CallCore::Registered:
     msg = g_strdup_printf (_("Registered %s"), aor.c_str ());
     break;
 
-  case GMManager::Unregistered:
+  case Ekiga::CallCore::Unregistered:
     msg = g_strdup_printf (_("Unregistered %s"), aor.c_str ());
     break;
 
-  case GMManager::UnregistrationFailed:
+  case Ekiga::CallCore::UnregistrationFailed:
     msg = g_strdup_printf (_("Could not unregister %s"), aor.c_str ());
     break;
 
-  case GMManager::RegistrationFailed:
+  case Ekiga::CallCore::RegistrationFailed:
     msg = g_strdup_printf (_("Could not register %s"), aor.c_str ());
     break;
 
-  case GMManager::Processing:
+  case Ekiga::CallCore::Processing:
   default:
     break;
   }
@@ -985,7 +985,6 @@
       _("Online"), 
       _("Away"), 
       _("Do Not Disturb"), 
-      _("Free For Chat"),
       _("Invisible"),
       NULL, 
       NULL 
@@ -996,7 +995,6 @@
       GM_STOCK_STATUS_ONLINE,
       GM_STOCK_STATUS_AWAY,
       GM_STOCK_STATUS_DND,
-      GM_STOCK_STATUS_FREEFORCHAT,
       GM_STOCK_STATUS_OFFLINE,
       NULL,
       NULL 
@@ -1074,11 +1072,11 @@
 
   /* The status combo box */
   item = gtk_tool_item_new ();
-  list_store = gtk_list_store_new (2,
+  list_store = gtk_list_store_new (3,
                                    GDK_TYPE_PIXBUF,
+                                   G_TYPE_STRING,
                                    G_TYPE_STRING);
-  mw->status_option_menu = 
-    gtk_combo_box_new_with_model (GTK_TREE_MODEL (list_store));
+  mw->status_option_menu = gtk_combo_box_new_with_model (GTK_TREE_MODEL (list_store));
   gtk_container_add (GTK_CONTAINER (item), mw->status_option_menu);
 
   renderer = gtk_cell_renderer_pixbuf_new ();
@@ -1091,18 +1089,33 @@
 
   renderer = gtk_cell_renderer_text_new ();
   gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (mw->status_option_menu), 
-                              renderer, TRUE);
+                              renderer, FALSE);
   gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (mw->status_option_menu), 
                                   renderer,
                                   "text", 1,
                                   NULL);
+
+  renderer = gtk_cell_renderer_text_new ();
+  g_object_set (renderer, 
+                "foreground", "darkgray",
+                "scale", 0.9,
+                "ellipsize", PANGO_ELLIPSIZE_END,
+                NULL);
+  gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (mw->status_option_menu), 
+                              renderer, TRUE);
+  gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (mw->status_option_menu), 
+                                  renderer,
+                                  "text", 2,
+                                  NULL);
+
+
   gtk_widget_show (mw->status_option_menu);
   gtk_toolbar_insert (GTK_TOOLBAR (toolbar), 
 		      GTK_TOOL_ITEM (item), -1);
 
   g_signal_connect (G_OBJECT (mw->status_option_menu), "changed",
-		    GTK_SIGNAL_FUNC (status_menu_changed_cb),
-		    (gpointer) PERSONAL_DATA_KEY "status");
+                    GTK_SIGNAL_FUNC (status_menu_changed_cb),
+                    NULL);
   
   for (int i = 0 ; i < CONTACT_LAST_STATE ; i++) { 
 
@@ -1116,7 +1129,7 @@
       gtk_list_store_append (GTK_LIST_STORE (list_store), &iter);
       gtk_list_store_set (GTK_LIST_STORE (list_store), &iter,
                           0, status_icon, 
-                          1, status [i], -1);
+                          1, status [i], -1); 
       g_object_unref (status_icon);
     }
   }
@@ -1361,12 +1374,6 @@
 			   (gpointer) PERSONAL_DATA_KEY "status",
 			   (status == CONTACT_DND), TRUE),
 
-      GTK_MENU_RADIO_ENTRY("free_for_chat", _("_Free For Chat"), NULL,
-			   NULL, 0,
-			   GTK_SIGNAL_FUNC (radio_menu_changed_cb),
-			   (gpointer) PERSONAL_DATA_KEY "status",
-			   (status == CONTACT_FREEFORCHAT), TRUE),
-      
       GTK_MENU_RADIO_ENTRY("invisible", _("_Invisible"), NULL,
 			   NULL, 0,
 			   GTK_SIGNAL_FUNC (radio_menu_changed_cb),
@@ -2176,10 +2183,7 @@
 
     if (idle->idle == TRUE) {
       
-      gdk_threads_enter ();
-      gm_main_window_set_status (main_window, idle->last_status);
-      gdk_threads_leave ();
-
+      //TODO Update status
       idle->idle = FALSE;
     }
   }
@@ -2195,7 +2199,6 @@
 
     gdk_threads_enter ();
     idle->last_status = status;
-    gm_main_window_set_status (main_window, CONTACT_AWAY);
     gdk_threads_leave ();
   }
 
@@ -2207,8 +2210,18 @@
 status_menu_changed_cb (GtkWidget *widget,
                         G_GNUC_UNUSED gpointer data)
 {
-  gm_conf_set_int (PERSONAL_DATA_KEY "status", 
-                   gtk_combo_box_get_active (GTK_COMBO_BOX (widget)));
+  const char * status [] = 
+    { 
+      _("Online"), 
+      _("Away"), 
+      _("Do Not Disturb"), 
+      _("Invisible"),
+      NULL, 
+      NULL 
+    };
+
+  gm_conf_set_string (PERSONAL_DATA_KEY "short_status", 
+                      status[gtk_combo_box_get_active (GTK_COMBO_BOX (widget))]);
 }
 
 
@@ -3317,21 +3330,26 @@
 
 void 
 gm_main_window_set_status (GtkWidget *main_window,
-                           guint status)
+                           std::string short_status,
+                           std::string long_status)
 {
   GmMainWindow *mw = NULL;
   
-  GtkWidget *menu = NULL;
-  
+  /*
+  const char * status [] = 
+    { 
+      _("Online"), 
+      _("Away"), 
+      _("Do Not Disturb"), 
+      _("Invisible"),
+      NULL, 
+      NULL 
+    };
+*/
   g_return_if_fail (main_window != NULL);
 
   mw = gm_mw_get_mw (main_window);
   g_return_if_fail (mw != NULL);
-  
-  menu = gtk_menu_get_widget (mw->main_menu, "online");
-  gtk_radio_menu_select_with_widget (GTK_WIDGET (menu), status);
-
-  gtk_combo_box_set_active (GTK_COMBO_BOX (mw->status_option_menu), status);
 }
 
 
@@ -3660,8 +3678,9 @@
 
   /* The main toolbar */
   main_toolbar = gm_mw_init_main_toolbar (window);
-  status = gm_conf_get_int (PERSONAL_DATA_KEY "status");
-  gm_main_window_set_status (window, status);
+  std::cout << "init menu" << std::endl << std::flush;
+//  status = gm_conf_get_int (PERSONAL_DATA_KEY "status");
+//  gm_main_window_set_status (window, status);
   
   /* Add the toolbar to the UI */
   gtk_box_pack_start (GTK_BOX (mw->window_vbox), main_toolbar, 
@@ -3756,9 +3775,6 @@
   conn = ep->mwi_event.connect (sigc::bind (sigc::ptr_fun (on_mwi_event_cb), (gpointer) window));
   mw->connections.push_back (conn);
 
-  conn = ep->registration_event.connect (sigc::bind (sigc::ptr_fun (on_registration_event_cb), (gpointer) window));
-  mw->connections.push_back (conn);
-
   /* New Display Engine signals */
   Ekiga::DisplayCore *display_core = dynamic_cast<Ekiga::DisplayCore *> (mw->core.get ("display-core"));
 
@@ -3783,6 +3799,9 @@
   /* New Call Engine signals */
   Ekiga::CallCore *call_core = dynamic_cast<Ekiga::CallCore *> (mw->core.get ("call-core"));
 
+  conn = call_core->registration_event.connect (sigc::bind (sigc::ptr_fun (on_registration_event_cb), (gpointer) window));
+  mw->connections.push_back (conn);
+
   conn = call_core->setup_call.connect (sigc::bind (sigc::ptr_fun (on_setup_call_cb), (gpointer) window));
   mw->connections.push_back (conn);
   

Modified: trunk/src/gui/main.h
==============================================================================
--- trunk/src/gui/main.h	(original)
+++ trunk/src/gui/main.h	Sun Jan 27 19:10:51 2008
@@ -198,7 +198,8 @@
  * PRE          :  The main window GMObject and a valid incoming call mode.
  */
 void gm_main_window_set_status (GtkWidget *main_window,
-                                guint status);
+                                std::string short_status,
+                                std::string long_status);
 
 
 /* DESCRIPTION  :  /

Modified: trunk/src/gui/statusicon.cpp
==============================================================================
--- trunk/src/gui/statusicon.cpp	(original)
+++ trunk/src/gui/statusicon.cpp	Sun Jan 27 19:10:51 2008
@@ -440,12 +440,6 @@
 			   (gpointer) PERSONAL_DATA_KEY "status",
 			   (status == CONTACT_DND), TRUE),
 
-      GTK_MENU_RADIO_ENTRY("free_for_chat", _("_Free For Chat"), NULL,
-			   NULL, 0,
-			   GTK_SIGNAL_FUNC (radio_menu_changed_cb),
-			   (gpointer) PERSONAL_DATA_KEY "status",
-			   (status == CONTACT_FREEFORCHAT), TRUE),
-      
       GTK_MENU_RADIO_ENTRY("invisible", _("_Invisible"), NULL,
 			   NULL, 0,
 			   GTK_SIGNAL_FUNC (radio_menu_changed_cb),
@@ -549,10 +543,6 @@
     gtk_status_icon_set_from_stock (GTK_STATUS_ICON (statusicon), GM_STOCK_STATUS_DND);
     break;
 
-  case (CONTACT_FREEFORCHAT):
-    gtk_status_icon_set_from_stock (GTK_STATUS_ICON (statusicon), GM_STOCK_STATUS_FREEFORCHAT);
-    break;
-
   case (CONTACT_INVISIBLE):
     gtk_status_icon_set_from_stock (GTK_STATUS_ICON (statusicon), GM_STOCK_STATUS_OFFLINE);
     break;



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