[Ekiga-devel-list] finally an updated IAX2 patch :)



About the actual patch, I tested it and outgoing and incoming calls work
fine.

There is one funny issue but it's a Ekiga bug with other protocols.  This
is if you have an account there, then you go to create a new account but
with a different protocol.  Then the new account will not be default even
though it's another protocol.  So you have to manually set it to default.

Also I'll submit another patch soon to convert H323 and SIP to use my
introduced enum:
enum CallReason {Prompt = 0, Reject = 1, Forward = 2, Answer = 4};

I done this because magic numbers aren't so readable...
Index: src/endpoints/urlhandler.cpp
===================================================================
--- src/endpoints/urlhandler.cpp	(revisión: 4774)
+++ src/endpoints/urlhandler.cpp	(copia de trabajo)
@@ -62,11 +62,13 @@
 GMURL::GMURL ()
 {
   is_supported = false;
+  is_parsed = false;
 }
 
 
 GMURL::GMURL (PString base)
 {
+  is_parsed = false;
   base.Replace ("//", "");
   url = base.Trim ();
   
@@ -97,9 +99,15 @@
     type = PString ("sip");
     is_supported = true;
   }
+  else if (url.Find ("iax2:") == 0) {
+    url.Replace ("iax2:", "");
+    type = PString ("iax2");
+    is_supported = true;
+  }
   else if (url.Find ("h323:") == P_MAX_INDEX
 	   && url.Find ("sip:") == P_MAX_INDEX
-	   && url.Find ("callto:") == P_MAX_INDEX) {
+	   && url.Find ("callto:") == P_MAX_INDEX
+     && url.Find ("iax2:") == P_MAX_INDEX) {
 
     if (url.Find ("/") != P_MAX_INDEX) {
       
@@ -120,8 +128,10 @@
 GMURL::GMURL (const GMURL & u)
 {
   is_supported = u.is_supported;
+  is_parsed = u.is_parsed;
   type = u.type;
   url = u.url;
+  
 }
 
 
@@ -145,6 +155,11 @@
 
 void GMURL::Parse ()
 {
+  if (is_parsed)
+    return;
+  else
+    is_parsed = true;
+  
   PINDEX j = 0;
   PString default_h323_gateway;
 
@@ -162,7 +177,6 @@
   phone_account = gnomemeeting_get_account ("eugw.ast.diamondcard.us");
   
   if (!url.IsEmpty ()) {
-
     if (type == "sip") {
 
       if (account
@@ -192,6 +206,33 @@
 	  && url.Find (default_h323_gateway) == P_MAX_INDEX) 	
 	url = url + "@" + default_h323_gateway;
     }
+    else if (type == "iax2") {      
+      PINDEX idx = url.Find ("@");
+     
+      if (idx == P_MAX_INDEX) {
+        GmAccount *iax2_account = gnomemeeting_get_default_account ("iax2");   
+        //URL is a short format so we need the default iax2 account.
+        if (iax2_account && iax2_account->username && iax2_account->host) {
+          url = PString::Empty() + iax2_account->username + "@" + iax2_account->host + "/" + url;
+        }
+      }
+      else {
+        PINDEX slash_idx = url.Find("/");        
+        if (slash_idx == P_MAX_INDEX) {
+          PString number = url.Left(idx);
+          PString host = url.Mid(idx + 1);
+          GmAccount *iax2_account = gnomemeeting_get_account (host);
+          
+          
+          if (iax2_account && iax2_account->username) {
+            url = PString::Empty() + iax2_account->username + "@" + host + "/" + number;
+          }
+        }
+        else {
+          //URL is correct.
+        }
+      }  
+    }
   }
 
   j = url.Find (":");
@@ -241,7 +282,6 @@
     full_url = type + ":" + url + ":" + port;
   }
   else if (is_supported) {
-    
     full_url = type + ":" + url;
   }
     
@@ -418,10 +458,9 @@
   /* Answer the current call in a separate thread if we are called
    * and return 	 
    */ 	 
-  if (endpoint->GetCallingState () == GMManager::Called) { 	 
 
+  if (endpoint->GetCallingState () == GMManager::Called) {
     if (!transfer_call) {
-      
       endpoint->AcceptCurrentIncomingCall (); 	 
       return; 	 
     }
Index: src/endpoints/iax2.cpp
===================================================================
--- src/endpoints/iax2.cpp	(revisión: 0)
+++ src/endpoints/iax2.cpp	(revisión: 0)
@@ -0,0 +1,140 @@
+#include "../../config.h"
+
+#include "iax2.h"
+#include "pcss.h"
+#include "ekiga.h"
+
+#include "main.h"
+#include "chat.h"
+#include "preferences.h"
+#include "history.h"
+#include "statusicon.h"
+#include "misc.h"
+#ifdef HAS_DBUS
+#include "dbus.h"
+#endif
+
+#include "gmconf.h"
+#include "gmdialog.h"
+
+#include <ptlib/ethsock.h>
+
+#define new PNEW
+
+GMIAX2Endpoint::GMIAX2Endpoint (GMManager & ep)
+: IAX2EndPoint (ep), endpoint (ep)
+{
+}
+
+
+GMIAX2Endpoint::~GMIAX2Endpoint ()
+{
+}
+
+void
+GMIAX2Endpoint::Init ()
+{
+  SetLocalUserName (endpoint.GetDefaultDisplayName ());
+  //There is no number setting so we'll just hope
+  //that the display name can be used.
+  SetLocalNumber (endpoint.GetDefaultDisplayName ());
+}
+
+BOOL 
+GMIAX2Endpoint::OnIncomingConnection (OpalConnection &connection,
+                                     unsigned options)
+{
+  IncomingCallMode icm;
+  int reason;
+  
+  //Get current status of the user and accept or reject the call
+  //based on this information.  
+  gnomemeeting_threads_enter ();
+  icm = (IncomingCallMode) gm_conf_get_int (CALL_OPTIONS_KEY "incoming_call_mode");
+  gnomemeeting_threads_leave ();
+  
+  
+  if (endpoint.GetCallingState () != GMManager::Standby || icm == DO_NOT_DISTURB)
+    reason = GMManager::Reject;
+  else if (icm == AUTO_ANSWER)
+    reason = GMManager::Answer;
+  else 
+    reason = GMManager::Prompt;
+
+  return endpoint.OnIncomingConnection (connection, reason, PString::Empty());
+}
+
+void
+GMIAX2Endpoint::OnRegistered(
+      const PString & host,
+      const PString & username,
+      BOOL isFailure,
+      RegisteredError reason)
+{
+  GtkWidget *accounts_window = NULL;
+  GtkWidget *main_window = NULL;
+  GtkWidget *history_window = NULL;
+  gchar *msg = NULL;
+  
+  main_window = GnomeMeeting::Process ()->GetMainWindow ();
+  history_window = GnomeMeeting::Process ()->GetHistoryWindow ();
+  accounts_window = GnomeMeeting::Process ()->GetAccountsWindow (); 
+  
+  if (isFailure)
+    msg = g_strdup_printf (_("Registration failed"));
+  else
+    msg = g_strdup_printf (_("Registered to %s"), (const gchar *)host);
+  gnomemeeting_threads_enter ();
+  gm_main_window_push_message (main_window, msg);
+  gm_history_window_insert (history_window, msg);
+  gm_accounts_window_update_account_state (accounts_window,
+             FALSE,
+             (const gchar *)host,
+             (const gchar *)username,
+             _("Registered"),
+             NULL);
+  gm_main_window_set_account_info (main_window, 
+           endpoint.GetRegisteredAccounts ());
+  gnomemeeting_threads_leave ();
+  
+  g_free(msg);
+}
+
+void
+GMIAX2Endpoint::OnUnregistered(
+      const PString & host,
+      const PString & username,
+      BOOL isFailure,
+      UnregisteredError reason)
+{
+  GtkWidget *accounts_window = NULL;
+  GtkWidget *main_window = NULL;
+  GtkWidget *history_window = NULL;
+  gchar *msg = NULL;
+  
+  main_window = GnomeMeeting::Process ()->GetMainWindow ();
+  history_window = GnomeMeeting::Process ()->GetHistoryWindow ();
+  accounts_window = GnomeMeeting::Process ()->GetAccountsWindow (); 
+  
+  msg = g_strdup_printf (_("Unregistered from %s"), (const gchar *)host);
+  gnomemeeting_threads_enter ();
+  gm_main_window_push_message (main_window, msg);
+  gm_history_window_insert (history_window, msg);
+  gm_accounts_window_update_account_state (accounts_window,
+             FALSE,
+             (const gchar *)host,
+             (const gchar *)username,
+             _("Unregistered"),
+             NULL);
+  gm_main_window_set_account_info (main_window, 
+           endpoint.GetRegisteredAccounts ());
+  gnomemeeting_threads_leave ();
+  
+  g_free(msg);
+}
+
+int
+GMIAX2Endpoint::GetRegisteredAccounts ()
+{
+  return IAX2EndPoint::GetRegistrationsCount ();
+}
Index: src/endpoints/urlhandler.h
===================================================================
--- src/endpoints/urlhandler.h	(revisión: 4774)
+++ src/endpoints/urlhandler.h	(copia de trabajo)
@@ -70,6 +70,7 @@
   PString port;
   PString type;
   BOOL is_supported;
+  BOOL is_parsed;
 };
 
 
Index: src/endpoints/iax2.h
===================================================================
--- src/endpoints/iax2.h	(revisión: 0)
+++ src/endpoints/iax2.h	(revisión: 0)
@@ -0,0 +1,69 @@
+#ifndef IAX2_H_
+#define IAX2_H_
+
+#include "../../config.h"
+
+#include "common.h"
+
+#include "manager.h"
+
+class GMIAX2Endpoint : public IAX2EndPoint
+{
+  PCLASSINFO(GMIAX2Endpoint, IAX2EndPoint);
+
+ public:
+
+  /* DESCRIPTION  :  The constructor 
+   * BEHAVIOR     :  Creates a GMIAX2Endpoint and 
+   *        initialises variables
+   * PRE          :  /
+   */
+  GMIAX2Endpoint (GMManager &ep);  
+  ~GMIAX2Endpoint ();
+
+  /* DESCRIPTION  :  /
+   * BEHAVIOR     :  Intiate internal values from
+   *                 ekiga's configuration.
+   * PRE          :  /
+   */
+  void Init ();
+  
+  /* DESCRIPTION  :  Event when an incoming connection occurs
+   * BEHAVIOR     :  Returns TRUE to accept the connection or
+   *                 FALSE to reject it.
+   * PRE          :  /
+   */
+  virtual BOOL OnIncomingConnection (OpalConnection &connection, unsigned options);
+  
+  /* DESCRIPTION  :  Event when an on registered event occurs
+   * BEHAVIOR     :  Action is taken to notify the user if the
+   *                 registration succeeded or faileds.
+   * PRE          :  /
+   */
+  virtual void OnRegistered(
+      const PString & host,
+      const PString & userName,
+      BOOL isFailure,
+      RegisteredError reason = RegisteredFailureUnknown);
+  
+  /* DESCRIPTION  :  Event when an on unregistered event occurs
+   * BEHAVIOR     :  Action is taken to notify the user
+   * PRE          :  /
+   */
+  virtual void OnUnregistered(
+      const PString & host,
+      const PString & userName,
+      BOOL isFailure,
+      UnregisteredError reason = UnregisteredFailureUnknown);
+  
+  /* DESCRIPTION  :  Get the number of registered accounts
+   * BEHAVIOR     :  /
+   * PRE          :  /
+   */
+  int GetRegisteredAccounts ();
+  
+ private:
+  GMManager & endpoint;
+};
+
+#endif
Index: src/endpoints/manager.cpp
===================================================================
--- src/endpoints/manager.cpp	(revisión: 4774)
+++ src/endpoints/manager.cpp	(copia de trabajo)
@@ -42,6 +42,7 @@
 #include "pcss.h"
 #include "h323.h"
 #include "sip.h"
+#include "iax2.h"
 
 #include "accounts.h"
 #include "urlhandler.h"
@@ -126,6 +127,7 @@
   h323EP = NULL;
   sipEP = NULL;
   pcssEP = NULL;
+  iax2EP = NULL;
 
   PVideoDevice::OpenArgs video = GetVideoOutputDevice();
   video.deviceName = "GDKOUT";
@@ -447,6 +449,11 @@
   return sipEP;
 }
 
+GMIAX2Endpoint *
+GMManager::GetGMIAX2Endpoint ()
+{
+  return iax2EP;
+}
 
 GMPCSSEndpoint *
 GMManager::GetPCSSEndpoint ()
@@ -1582,6 +1589,12 @@
   sipEP->Init ();
   AddRouteEntry("pc:.*             = sip:<da>");
   
+   /* IAX2 Endpoint */
+  iax2EP = new GMIAX2Endpoint (*this);
+  iax2EP->Init ();
+  AddRouteEntry("pc:.*             = iax2:<da>");
+  AddRouteEntry("iax2:.* = pc:<da>");
+  
   /* PC Sound System Endpoint */
   pcssEP = new GMPCSSEndpoint (*this);
   AddRouteEntry("h323:.* = pc:<da>");
@@ -2744,6 +2757,7 @@
   number = sipEP->GetRegisteredAccounts ();
   if (h323EP->H323EndPoint::IsRegisteredWithGatekeeper ())
     number++;
+  number += iax2EP->GetRegisteredAccounts();
 
   return number;
 }
Index: src/endpoints/accountshandler.cpp
===================================================================
--- src/endpoints/accountshandler.cpp	(revisión: 4774)
+++ src/endpoints/accountshandler.cpp	(copia de trabajo)
@@ -49,6 +49,7 @@
 #include "manager.h"
 #include "sip.h"
 #include "h323.h"
+#include "iax2.h"
 #include "ekiga.h"
 
 #include "misc.h"
@@ -110,8 +111,10 @@
 
     if (!strcmp (account->protocol_name, "SIP")) 
       SIPRegister (account);
-    else
+    else if (!strcmp (account->protocol_name, "H323")) 
       H323Register (account);
+    else if (!strcmp (account->protocol_name, "IAX2"))
+      IAX2Register (account);
   }
   else {
 
@@ -129,8 +132,10 @@
 
 	  if (!strcmp (list_account->protocol_name, "SIP")) 
 	    SIPRegister (list_account);
-	  else
-	    H323Register (list_account);
+	  else if (!strcmp (list_account->protocol_name, "H323"))
+      H323Register (list_account);
+    else if (!strcmp (list_account->protocol_name, "IAX2"))
+      IAX2Register (list_account);      
 	}
       }
 
@@ -358,3 +363,47 @@
   }
 }
 
+void GMAccountsEndpoint::IAX2Register (GmAccount *a)
+{
+  GMIAX2Endpoint *iax2EP = ep.GetGMIAX2Endpoint();
+  
+  GtkWidget *accounts_window = NULL;
+  GtkWidget *main_window = NULL;
+  GtkWidget *history_window = NULL;
+  
+  main_window = GnomeMeeting::Process ()->GetMainWindow ();
+  history_window = GnomeMeeting::Process ()->GetHistoryWindow ();
+  accounts_window = GnomeMeeting::Process ()->GetAccountsWindow (); 
+  
+  if (a->enabled && !iax2EP->IsRegistered (a->host, a->username)) {
+    gnomemeeting_threads_enter ();
+    gm_accounts_window_update_account_state (accounts_window,
+               TRUE,
+               a->host,
+               a->username,
+               _("Registering"),
+               NULL);
+    gnomemeeting_threads_leave ();
+    
+    iax2EP->Register(a->host, a->username, a->password, 60);    
+    //the notification about the registration failing or 
+    //succeeding is handled by the GMIAX2Endpoint class
+  }
+  else if (!a->enabled && iax2EP->IsRegistered (a->host, a->username)) {
+    
+    gnomemeeting_threads_enter ();
+    
+    gm_accounts_window_update_account_state (accounts_window,
+               TRUE,
+               a->host,
+               a->username,
+               _("Unregistering"),
+               NULL);
+    
+    gnomemeeting_threads_leave ();
+    
+    //this is synchronous so it could wait until timeout before returning
+    iax2EP->Unregister(a->host, a->username);
+  }
+}
+
Index: src/endpoints/manager.h
===================================================================
--- src/endpoints/manager.h	(revisión: 4774)
+++ src/endpoints/manager.h	(copia de trabajo)
@@ -67,6 +67,7 @@
 class GMPCSSEndpoint;
 class GMH323Endpoint;
 class GMSIPEndpoint;
+class GMIAX2Endpoint;
 
 
 PDICTIONARY (mwiDict, PString, PString);
@@ -84,11 +85,13 @@
   friend class GMPCSSEndpoint;
   friend class GMH323Endpoint;
   friend class GMSIPEndpoint;
+  friend class GMIAX2Endpoint;
   
   
  public:
 
   enum CallingState {Standby, Calling, Connected, Called};
+  enum CallReason {Prompt = 0, Reject = 1, Forward = 2, Answer = 4};
 
   
   /* DESCRIPTION  :  The constructor.
@@ -410,6 +413,12 @@
    * PRE          :  /
    */
   GMSIPEndpoint *GetSIPEndpoint ();
+  
+  /* DESCRIPTION  :  /
+   * BEHAVIOR     :  Returns the IAX2 endpoint.
+   * PRE          :  /
+   */
+  GMIAX2Endpoint *GetGMIAX2Endpoint ();
 
   
   /* DESCRIPTION  :  /
@@ -880,6 +889,7 @@
   /* The various related endpoints */
   GMH323Endpoint *h323EP;
   GMSIPEndpoint *sipEP;
+  GMIAX2Endpoint *iax2EP;
   GMPCSSEndpoint *pcssEP;
 
 
Index: src/endpoints/accountshandler.h
===================================================================
--- src/endpoints/accountshandler.h	(revisión: 4774)
+++ src/endpoints/accountshandler.h	(copia de trabajo)
@@ -97,6 +97,14 @@
    */
   void H323Register (GmAccount *a);
   
+  
+  /* DESCRIPTION  :  /
+   * BEHAVIOR     :  Updates the registration for a IAX2 GmAccount.
+   * PRE          :  A valid pointer to a valid IAX2 GmAccount.
+   */
+  void IAX2Register (GmAccount *a);
+  
+  
 protected:
 
 
Index: src/gui/accounts.cpp
===================================================================
--- src/gui/accounts.cpp	(revisión: 4774)
+++ src/gui/accounts.cpp	(copia de trabajo)
@@ -48,6 +48,7 @@
 #include "manager.h"
 #include "sip.h"
 #include "h323.h"
+#include "iax2.h"
 #include "ekiga.h"
 
 #include "gmconf.h"
@@ -409,7 +410,7 @@
 				 GTK_WINDOW (NULL),
 				 GTK_DIALOG_MODAL,
 				 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
-				 GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
+				 is_editing? GTK_STOCK_SAVE : GTK_STOCK_ADD, GTK_RESPONSE_ACCEPT,
 				 NULL);
   gtk_dialog_set_default_response (GTK_DIALOG (dialog),
 				   GTK_RESPONSE_ACCEPT);
@@ -450,6 +451,7 @@
     aew->protocol_option_menu = gtk_combo_box_new_text ();
     gtk_combo_box_append_text (GTK_COMBO_BOX (aew->protocol_option_menu), "SIP");
     gtk_combo_box_append_text (GTK_COMBO_BOX (aew->protocol_option_menu), "H323");
+    gtk_combo_box_append_text (GTK_COMBO_BOX (aew->protocol_option_menu), "IAX2");
     gtk_combo_box_set_active (GTK_COMBO_BOX (aew->protocol_option_menu), 0);
 
     gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 1, 1, 2); 
@@ -466,7 +468,7 @@
   }
 
   /* Host */
-  if (!account || !strcmp (account->protocol_name, "SIP"))
+  if (!account || !strcmp (account->protocol_name, "SIP") || !strcmp (account->protocol_name, "IAX2"))
     aew->host_label = gtk_label_new (_("Registrar:"));
   else
     aew->host_label = gtk_label_new (_("Gatekeeper:"));
@@ -548,9 +550,10 @@
   }
 
   /* Realm/Domain */
-  if (!account || !strcmp (account->protocol_name, "SIP"))
+  if (!account || !strcmp (account->protocol_name, "SIP") ||
+      !strcmp (account->protocol_name, "IAX2"))
     aew->domain_label = gtk_label_new (NULL);
-  else
+  else if (!strcmp (account->protocol_name, "H323"))
     aew->domain_label = gtk_label_new (_("Gatekeeper ID:"));
 
   gtk_misc_set_alignment (GTK_MISC (aew->domain_label), 0.0, 0.5);
@@ -563,13 +566,14 @@
   if (account && account->domain)
     gtk_entry_set_text (GTK_ENTRY (aew->domain_entry), account->domain);
   
-  if (!account || !strcmp (account->protocol_name, "SIP")) {
+  if (!account || !strcmp (account->protocol_name, "SIP") || 
+      !strcmp (account->protocol_name, "IAX2")) {
   
     gtk_widget_hide (aew->domain_label);
     gtk_widget_hide (aew->domain_entry);
   }
   else {
-
+    
     gtk_widget_show (aew->domain_label);
     gtk_widget_show (aew->domain_entry);
   }
@@ -596,7 +600,6 @@
 
   gtk_widget_show (dialog);
   while (!valid) {
-
     switch (gtk_dialog_run (GTK_DIALOG (dialog))) {
 
     case GTK_RESPONSE_ACCEPT:
@@ -607,23 +610,40 @@
       account_name = gtk_entry_get_text (GTK_ENTRY (aew->account_entry));
       host = gtk_entry_get_text (GTK_ENTRY (aew->host_entry));
       password = gtk_entry_get_text (GTK_ENTRY (aew->password_entry));
+      if (aew->domain_entry)
       domain = gtk_entry_get_text (GTK_ENTRY (aew->domain_entry));
       timeout = gtk_entry_get_text (GTK_ENTRY (aew->timeout_entry));
 
-      if (!is_editing)
-	protocol = // take it from the menu
-	  gtk_combo_box_get_active (GTK_COMBO_BOX (aew->protocol_option_menu));
-      else // take it from the existing account field
-	protocol = (account->protocol_name 
-		    && !strcmp (account->protocol_name, "SIP") ? 0 : 1);
+      if (!is_editing) {
+        // take it from the menu
+        protocol = gtk_combo_box_get_active (GTK_COMBO_BOX (aew->protocol_option_menu)); 
+      } else {
+        // take it from the existing account field
+        if (account->protocol_name) {
+          if (!strcmp (account->protocol_name, "SIP"))
+            protocol = GM_SIP;
+          else if (!strcmp (account->protocol_name, "H323"))
+            protocol = GM_H323;
+          else if (!strcmp (account->protocol_name, "IAX2"))
+            protocol = GM_IAX2;
+        }
+        else
+          protocol = GM_H323;       
+      }
 
       /* Check at least an account name, registrar, 
        * and username are provided */
-      if (protocol == 0) // SIP
-	valid = (username.FindRegEx (regex_username) != P_MAX_INDEX
-		 && account_name.FindRegEx (regex) != P_MAX_INDEX);
-      else // H323
+       
+      switch (protocol) {
+      case GM_SIP:
+      case GM_IAX2:
+        valid = (username.FindRegEx (regex_username) != P_MAX_INDEX && 
+                account_name.FindRegEx (regex) != P_MAX_INDEX);
+        break;
+      case GM_H323:
 	valid = (account_name.FindRegEx (regex) != P_MAX_INDEX);
+        break;
+      }
 
       if (valid) {
 
@@ -636,6 +656,7 @@
 	g_free (account->host);
 	g_free (account->password);
 	g_free (account->domain);
+        
 	if (!is_editing)
 	  g_free (account->protocol_name);
 
@@ -643,18 +664,24 @@
 	account->host = g_strdup (host);
 	account->username = g_strdup (username);
 	
-	if (!strcmp (domain, ""))
-	  if (protocol == 0) { // SIP
+        //if user doesn't have a domain then it might be in their username
+        if (!strcmp (domain, "")) {
+          switch (protocol) {
+            case GM_SIP:
+            case GM_IAX2:
 	    if (PString(username).Find("@") != P_MAX_INDEX)
 	      account->domain = g_strdup (SIPURL(username).GetHostName());
 	    else
 	      account->domain = g_strdup (host);
-	  }
-	  else
+              break;
+            default:
 	    account->domain = g_strdup ("");
+          }
+        }
 	else
 	  account->domain = g_strdup (domain);
 
+        //if user doesn't have an authentication login then it might be in their username
 	if (!strcmp (auth_username, "")) {
 	  if (PString(username).Find("@") != P_MAX_INDEX)
 	    account->auth_username = g_strdup (SIPURL(username).GetUserName());
@@ -670,20 +697,38 @@
 	else 
 	  account->timeout = PMAX (atoi (timeout), 25);
 
-	if (!is_editing)
-	  account->protocol_name = g_strdup ((protocol == 0) ? "SIP" : "H323");
+        if (!is_editing) {
+          switch (protocol) {
+          case GM_SIP:
+            account->protocol_name = g_strdup("SIP");
+            break;
+          case GM_H323:
+            account->protocol_name = g_strdup("H323");
+            break;
+          case GM_IAX2:
+            account->protocol_name = g_strdup("IAX2");
+            break;
+          default:
+            g_assert_not_reached();
+          }
+        }
 
 	/* The GUI will be updated through the GmConf notifiers */
 	if (is_editing) 
 	  gnomemeeting_account_modify (account);
 	else 
 	  gnomemeeting_account_add (account);
-      }
-      else {
-	if (protocol == 0) // SIP
+          
+        } else {
+          switch (protocol) {
+            case GM_SIP:
+            case GM_IAX2:
 	  gnomemeeting_error_dialog (GTK_WINDOW (dialog), _("Missing information"), _("Please make sure to provide a valid account name, host name, and user name."));
-	else // H323
+              break;
+            case GM_H323:
 	  gnomemeeting_error_dialog (GTK_WINDOW (dialog), _("Missing information"), _("Please make sure to provide a valid account name, host name and registration timeout."));
+              break;
+          }
       }
       break;
 
@@ -717,12 +762,16 @@
 		     account->account_name);
   dialog =
     gtk_message_dialog_new (GTK_WINDOW (accounts_window),
-			    GTK_DIALOG_MODAL, GTK_MESSAGE_QUESTION,
-			    GTK_BUTTONS_YES_NO, confirm_msg);
+			    GTK_DIALOG_MODAL, GTK_MESSAGE_WARNING,
+			    GTK_BUTTONS_NONE, confirm_msg);
   g_free (confirm_msg);
 
-  gtk_dialog_set_default_response (GTK_DIALOG (dialog),
-				   GTK_RESPONSE_YES);
+  gtk_dialog_add_buttons(GTK_DIALOG (dialog), 
+    GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+    GTK_STOCK_DELETE, GTK_RESPONSE_DELETE_EVENT,
+    NULL);  
+  
+  gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_DELETE_EVENT);
 
   gtk_widget_show_all (dialog);
 
@@ -730,7 +779,7 @@
   /* Now run the dialg */
   switch (gtk_dialog_run (GTK_DIALOG (dialog))) {
 
-  case GTK_RESPONSE_YES:
+  case GTK_RESPONSE_DELETE_EVENT:
 
     /* The GUI will be updated throught the GmConf notifiers */
     gnomemeeting_account_delete (account);
@@ -969,7 +1018,7 @@
 
   switch (gtk_combo_box_get_active (GTK_COMBO_BOX (aew->protocol_option_menu)))
     {
-    case 0:
+    case GM_SIP:
       gtk_label_set_text (GTK_LABEL (aew->host_label), _("Registrar:"));
       gtk_label_set_text (GTK_LABEL (aew->domain_label), _("Realm/Domain:"));
       gtk_widget_show (aew->auth_username_label);
@@ -978,7 +1027,7 @@
       gtk_widget_hide (aew->domain_label);
       break;
 
-    case 1:
+     case GM_H323:
       gtk_label_set_text (GTK_LABEL (aew->host_label), _("Gatekeeper:"));
       gtk_label_set_text (GTK_LABEL (aew->domain_label), _("Gatekeeper ID:"));
       gtk_widget_hide (aew->auth_username_label);
@@ -986,6 +1035,14 @@
       gtk_widget_show (aew->domain_entry);
       gtk_widget_show (aew->domain_label);
       break;
+    
+    case GM_IAX2:
+      gtk_label_set_text (GTK_LABEL (aew->host_label), _("Registrar:"));
+      gtk_widget_hide (aew->auth_username_label);
+      gtk_widget_hide (aew->auth_username_entry);
+      gtk_widget_hide (aew->domain_label);
+      gtk_widget_hide (aew->domain_entry);
+      break;
     };
 }
 
@@ -1640,7 +1697,7 @@
   g_signal_connect (G_OBJECT (button), "clicked", 
   		    GTK_SIGNAL_FUNC (add_account_cb), NULL); 
 
-  aw->delete_button = gtk_button_new_from_stock (GTK_STOCK_REMOVE);
+  aw->delete_button = gtk_button_new_from_stock (GTK_STOCK_DELETE);
   gtk_widget_set_sensitive (aw->delete_button, FALSE);
   gtk_box_pack_start (GTK_BOX (buttons_vbox), aw->delete_button, TRUE, TRUE, 0);
   g_signal_connect (G_OBJECT (aw->delete_button), "clicked", 
Index: src/gui/accounts.h
===================================================================
--- src/gui/accounts.h	(revisión: 4774)
+++ src/gui/accounts.h	(copia de trabajo)
@@ -63,7 +63,14 @@
 
 typedef GmAccount_ GmAccount;
 
+enum GmAccountType_ {
+  GM_SIP = 0,
+  GM_H323 = 1,
+  GM_IAX2 = 2 
+};
 
+typedef GmAccountType_ GmAccountType;
+
 #define GM_ACCOUNT(x)     (GmAccount *) (x)
 
 
Index: src/Makefile.am
===================================================================
--- src/Makefile.am	(revisión: 4774)
+++ src/Makefile.am	(copia de trabajo)
@@ -85,7 +85,9 @@
 	endpoints/sip.h			\
 	endpoints/sip.cpp		\
 	endpoints/urlhandler.h		\
-	endpoints/urlhandler.cpp		
+	endpoints/urlhandler.cpp	\
+	endpoints/iax2.h		\
+	endpoints/iax2.cpp		
 
 # Clients
 ekiga_SOURCES +=			\
Index: src/common.h
===================================================================
--- src/common.h	(revisión: 4774)
+++ src/common.h	(copia de trabajo)
@@ -49,8 +49,8 @@
 
 #include <h323/h323.h>
 #include <sip/sip.h>
+#include <iax2/iax2.h>
 
-
 #ifndef DISABLE_GNOME
 #include <gnome.h>
 #else
@@ -74,6 +74,7 @@
 #define PROTOCOLS_KEY "/apps/" PACKAGE_NAME "/protocols/"
 #define H323_KEY "/apps/" PACKAGE_NAME "/protocols/h323/"
 #define SIP_KEY "/apps/" PACKAGE_NAME "/protocols/sip/"
+#define IAX2_KEY "/apps/" PACKAGE_NAME "/protocols/iax2/"
 #define PORTS_KEY "/apps/" PACKAGE_NAME "/protocols/ports/"
 #define CALL_FORWARDING_KEY "/apps/" PACKAGE_NAME "/protocols/call_forwarding/"
 #define LDAP_KEY "/apps/" PACKAGE_NAME "/protocols/ldap/"


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