ekiga r6435 - in trunk: . lib/engine/chat lib/engine/chat/echo lib/engine/chat/skel lib/engine/gui/gtk-frontend src src/endpoints



Author: jpuydt
Date: Thu Jul 10 07:45:33 2008
New Revision: 6435
URL: http://svn.gnome.org/viewvc/ekiga?rev=6435&view=rev

Log:
Merge branch 'chat'

* chat:
  New gtk+ chat window! Very ugly, but should improve after some beatings!
  Fix some stupid mistakes and completed various pieces of code
  Pushed old code away : I'm going to write a new window
  Basic implementation of a chat "view" (does control too)
  Implementation of simple chats in SIP... compiles, but does it run? No UI to check!
  Modified the api, to add the ChatObserver notion, which makes more sense than signals in this case, and made the foo_chat_added signal come with a nice boolean
  First commit of the new stack : it compiles, it runs, but is empty and has no user interface
  Moved code from chat-core.cpp to chat-core.h, to help transition
  Removed unused api, preparing merge with my own ChatCore
  Moved Damien's temporary chat code to a non-colliding namespace

Added:
   trunk/lib/engine/chat/echo/
   trunk/lib/engine/chat/echo/Makefile.am
   trunk/lib/engine/chat/echo/echo-dialect.cpp
   trunk/lib/engine/chat/echo/echo-dialect.h
   trunk/lib/engine/chat/echo/echo-main.cpp
      - copied, changed from r6434, /trunk/lib/engine/gui/gtk-frontend/gtk-frontend.h
   trunk/lib/engine/chat/echo/echo-main.h
   trunk/lib/engine/chat/echo/echo-presentity.cpp
   trunk/lib/engine/chat/echo/echo-presentity.h
   trunk/lib/engine/chat/echo/echo-simple.cpp
   trunk/lib/engine/chat/echo/echo-simple.h
   trunk/lib/engine/chat/skel/chat-multiple.h
   trunk/lib/engine/chat/skel/chat-simple.h
   trunk/lib/engine/chat/skel/chat.h
   trunk/lib/engine/chat/skel/dialect-impl.h
   trunk/lib/engine/chat/skel/dialect.h
   trunk/lib/engine/gui/gtk-frontend/chat-window-old.cpp
      - copied, changed from r6434, /trunk/lib/engine/gui/gtk-frontend/chat-window.cpp
   trunk/lib/engine/gui/gtk-frontend/chat-window-old.h
      - copied, changed from r6434, /trunk/lib/engine/gui/gtk-frontend/chat-window.h
   trunk/lib/engine/gui/gtk-frontend/gtk-chat-view.cpp
   trunk/lib/engine/gui/gtk-frontend/gtk-chat-view.h
   trunk/src/endpoints/sip-chat-simple.cpp
   trunk/src/endpoints/sip-chat-simple.h
   trunk/src/endpoints/sip-dialect.cpp
   trunk/src/endpoints/sip-dialect.h
   trunk/src/endpoints/sip-presentity.cpp
   trunk/src/endpoints/sip-presentity.h
Modified:
   trunk/configure.ac
   trunk/lib/engine/chat/Makefile.am
   trunk/lib/engine/chat/skel/Makefile.am
   trunk/lib/engine/chat/skel/chat-core.cpp
   trunk/lib/engine/chat/skel/chat-core.h
   trunk/lib/engine/chat/skel/chat-manager.h
   trunk/lib/engine/gui/gtk-frontend/Makefile.am
   trunk/lib/engine/gui/gtk-frontend/chat-window.cpp
   trunk/lib/engine/gui/gtk-frontend/chat-window.h
   trunk/lib/engine/gui/gtk-frontend/gtk-frontend.cpp
   trunk/lib/engine/gui/gtk-frontend/gtk-frontend.h
   trunk/src/Makefile.am
   trunk/src/endpoints/sip.cpp
   trunk/src/endpoints/sip.h

Modified: trunk/configure.ac
==============================================================================
--- trunk/configure.ac	(original)
+++ trunk/configure.ac	Thu Jul 10 07:45:33 2008
@@ -609,6 +609,7 @@
 lib/engine/addressbook/ldap/Makefile
 lib/engine/addressbook/skel/Makefile
 lib/engine/chat/Makefile
+lib/engine/chat/echo/Makefile
 lib/engine/chat/skel/Makefile
 lib/engine/framework/Makefile
 lib/engine/presence/Makefile

Modified: trunk/lib/engine/chat/Makefile.am
==============================================================================
--- trunk/lib/engine/chat/Makefile.am	(original)
+++ trunk/lib/engine/chat/Makefile.am	Thu Jul 10 07:45:33 2008
@@ -1 +1 @@
-SUBDIRS = skel
+SUBDIRS = skel echo

Added: trunk/lib/engine/chat/echo/Makefile.am
==============================================================================
--- (empty file)
+++ trunk/lib/engine/chat/echo/Makefile.am	Thu Jul 10 07:45:33 2008
@@ -0,0 +1,23 @@
+noinst_LTLIBRARIES = libgmechochat.la
+
+echochat_dir = $(top_srcdir)/lib/engine/chat/echo
+
+AM_CXXFLAGS = $(SIGC_CFLAGS)
+
+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/chat/skel
+
+libgmechochat_la_SOURCES = \
+	$(echochat_dir)/echo-presentity.h	\
+	$(echochat_dir)/echo-presentity.cpp	\
+	$(echochat_dir)/echo-simple.h		\
+	$(echochat_dir)/echo-simple.cpp		\
+	$(echochat_dir)/echo-dialect.h		\
+	$(echochat_dir)/echo-dialect.cpp	\
+	$(echochat_dir)/echo-main.h		\
+	$(echochat_dir)/echo-main.cpp
+
+libgmechochat_la_LDFLAGS = -export-dynamic -no-undefined $(SIGC_LIBS)
\ No newline at end of file

Added: trunk/lib/engine/chat/echo/echo-dialect.cpp
==============================================================================
--- (empty file)
+++ trunk/lib/engine/chat/echo/echo-dialect.cpp	Thu Jul 10 07:45:33 2008
@@ -0,0 +1,64 @@
+
+/*
+ * Ekiga -- A VoIP and Video-Conferencing application
+ * Copyright (C) 2000-2008 Damien Sandras
+
+ * This program is free software; you can  redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version. This program is distributed in the hope
+ * that it will be useful, but WITHOUT ANY WARRANTY; without even the
+ * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Ekiga is licensed under the GPL license and as a special exception, you
+ * have permission to link or otherwise combine this program with the
+ * programs OPAL, OpenH323 and PWLIB, and distribute the combination, without
+ * applying the requirements of the GNU GPL to the OPAL, OpenH323 and PWLIB
+ * programs, as long as you do follow the requirements of the GNU GPL for all
+ * the rest of the software thus combined.
+ */
+
+
+/*
+ *                         echo-dialect.cpp  -  description
+ *                         ------------------------------------------
+ *   begin                : written in 2008 by Julien Puydt
+ *   copyright            : (c) 2008 by Julien Puydt
+ *   description          : implementation of an echo chat backend
+ *
+ */
+
+#include <iostream>
+
+#include "echo-dialect.h"
+
+Echo::Dialect::Dialect ()
+{
+}
+
+Echo::Dialect::~Dialect ()
+{
+#ifdef __GNUC_
+  std::cout << __PRETTY_FUNCTION__ << std::endl;
+#endif
+}
+
+bool
+Echo::Dialect::populate_menu (Ekiga::MenuBuilder &builder)
+
+{
+  builder.add_action ("FIXME", "New echo", sigc::mem_fun (this, &Echo::Dialect::new_chat));
+
+  return true;
+}
+
+void
+Echo::Dialect::new_chat ()
+{
+  add_simple_chat (true, new SimpleChat ());
+}

Added: trunk/lib/engine/chat/echo/echo-dialect.h
==============================================================================
--- (empty file)
+++ trunk/lib/engine/chat/echo/echo-dialect.h	Thu Jul 10 07:45:33 2008
@@ -0,0 +1,60 @@
+
+/*
+ * Ekiga -- A VoIP and Video-Conferencing application
+ * Copyright (C) 2000-2008 Damien Sandras
+
+ * This program is free software; you can  redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version. This program is distributed in the hope
+ * that it will be useful, but WITHOUT ANY WARRANTY; without even the
+ * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Ekiga is licensed under the GPL license and as a special exception, you
+ * have permission to link or otherwise combine this program with the
+ * programs OPAL, OpenH323 and PWLIB, and distribute the combination, without
+ * applying the requirements of the GNU GPL to the OPAL, OpenH323 and PWLIB
+ * programs, as long as you do follow the requirements of the GNU GPL for all
+ * the rest of the software thus combined.
+ */
+
+
+/*
+ *                         echo-dialect.h  -  description
+ *                         ------------------------------------------
+ *   begin                : written in 2008 by Julien Puydt
+ *   copyright            : (c) 2008 by Julien Puydt
+ *   description          : declaration of an echo chat backend
+ *
+ */
+
+#ifndef __ECHO_DIALECT_H__
+#define __ECHO_DIALECT_H__
+
+#include "dialect-impl.h"
+#include "echo-simple.h"
+
+namespace Echo
+{
+  class Dialect: public Ekiga::DialectImpl<SimpleChat>
+  {
+  public:
+    
+    Dialect ();
+
+    ~Dialect ();
+
+    bool populate_menu (Ekiga::MenuBuilder &builder);
+
+  private:
+
+    void new_chat ();
+  };
+};
+
+#endif

Copied: trunk/lib/engine/chat/echo/echo-main.cpp (from r6434, /trunk/lib/engine/gui/gtk-frontend/gtk-frontend.h)
==============================================================================
--- /trunk/lib/engine/gui/gtk-frontend/gtk-frontend.h	(original)
+++ trunk/lib/engine/chat/echo/echo-main.cpp	Thu Jul 10 07:45:33 2008
@@ -1,6 +1,6 @@
 
 /* Ekiga -- A VoIP and Video-Conferencing application
- * Copyright (C) 2000-2007 Damien Sandras
+ * Copyright (C) 2000-2008 Damien Sandras
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -27,63 +27,62 @@
 
 
 /*
- *                         gtk-frontend.h  -  description
+ *                         echo-main.cpp  -  description
  *                         ------------------------------------------
- *   begin                : written in 2007 by Julien Puydt
- *   copyright            : (c) 2007 by Julien Puydt
- *   description          : code to hook a gtk+ user interface to
- *                          the main program
+ *   begin                : written in 2008 by Julien Puydt
+ *   copyright            : (c) 2008 by Julien Puydt
+ *   description          : code to hook the echo chat to the main program
  *
  */
 
-#ifndef __GTK_FRONTEND_H__
-#define __GTK_FRONTEND_H__
+#include "echo-main.h"
+#include "chat-core.h"
+#include "echo-dialect.h"
 
-#include <gtk/gtk.h>
-#include <vector>
-
-#include "services.h"
-#include "contact-core.h"
-#include "presence-core.h"
-#include "chat-manager.h"
-
-
-class GtkFrontend: public Ekiga::Service
+namespace Echo
 {
-public:
-
-  GtkFrontend (Ekiga::ServiceCore & _core);
-
-  ~GtkFrontend ();
+  class Service: public Ekiga::Service
+  {
+  public:
 
-  const std::string get_name () const;
+    Service (Dialect *dialect_): dialect(dialect_)
+    {}
 
-  const std::string get_description () const;
+    ~Service ()
+    { delete dialect; }
 
-  const GtkWidget *get_roster_view () const;
+    const std::string get_name () const
+    { return "echo-dialect"; }
 
-  const GtkWidget *get_call_history_view () const;
+    const std::string get_description () const
+    { return "\tProvides an echo chat for testing purposes"; }
 
-  const GtkWidget *get_addressbook_window () const;
+  private:
 
-  const GtkWidget *get_chat_window () const;
-
-private :
-  void on_new_chat (const Ekiga::ChatManager & manager,
-		    const std::string & name,
-		    const std::string & uri);
-
-  GtkWidget *addressbook_window;
-  GtkWidget *roster_view;
-  GtkWidget *call_history_view;
-  GtkWidget *chat_window;
-
-  std::vector<sigc::connection> connections;
+    Dialect *dialect;
+  };
 };
 
+bool
+echo_init (Ekiga::ServiceCore &core,
+	   int */*argc*/,
+	   char **/*argv*/[])
+{
+  bool result = false;
+  Ekiga::ChatCore *chat_core = NULL;
+  Echo::Service *service = NULL;
+
+  chat_core
+    = dynamic_cast<Ekiga::ChatCore*>(core.get ("chat-core"));
+
+  if (chat_core != NULL) {
+
+    Echo::Dialect* dialect = new Echo::Dialect;
+    service = new Echo::Service (dialect);
+    core.add (*service);
+    chat_core->add_dialect (*dialect);
+    result = true;
+  }
 
-bool gtk_frontend_init (Ekiga::ServiceCore &core,
-			int *argc,
-			char **argv[]);
-
-#endif
+  return result;
+}

Added: trunk/lib/engine/chat/echo/echo-main.h
==============================================================================
--- (empty file)
+++ trunk/lib/engine/chat/echo/echo-main.h	Thu Jul 10 07:45:33 2008
@@ -0,0 +1,47 @@
+
+/* Ekiga -- A VoIP and Video-Conferencing application
+ * Copyright (C) 2000-2008 Damien Sandras
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ *
+ * Ekiga is licensed under the GPL license and as a special exception,
+ * you have permission to link or otherwise combine this program with the
+ * programs OPAL, OpenH323 and PWLIB, and distribute the combination,
+ * without applying the requirements of the GNU GPL to the OPAL, OpenH323
+ * and PWLIB programs, as long as you do follow the requirements of the
+ * GNU GPL for all the rest of the software thus combined.
+ */
+
+
+/*
+ *                         echo-main.h  -  description
+ *                         ------------------------------------------
+ *   begin                : written in 2008 by Julien Puydt
+ *   copyright            : (c) 2008 by Julien Puydt
+ *   description          : code to hook the echo chat to the main program
+ *
+ */
+
+#ifndef __ECHO_MAIN_H__
+#define __ECHO_MAIN_H__
+
+#include "services.h"
+
+bool echo_init (Ekiga::ServiceCore &core,
+		int *argc,
+		char **argv[]);
+
+#endif

Added: trunk/lib/engine/chat/echo/echo-presentity.cpp
==============================================================================
--- (empty file)
+++ trunk/lib/engine/chat/echo/echo-presentity.cpp	Thu Jul 10 07:45:33 2008
@@ -0,0 +1,91 @@
+
+/*
+ * Ekiga -- A VoIP and Video-Conferencing application
+ * Copyright (C) 2000-2008 Damien Sandras
+
+ * This program is free software; you can  redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version. This program is distributed in the hope
+ * that it will be useful, but WITHOUT ANY WARRANTY; without even the
+ * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Ekiga is licensed under the GPL license and as a special exception, you
+ * have permission to link or otherwise combine this program with the
+ * programs OPAL, OpenH323 and PWLIB, and distribute the combination, without
+ * applying the requirements of the GNU GPL to the OPAL, OpenH323 and PWLIB
+ * programs, as long as you do follow the requirements of the GNU GPL for all
+ * the rest of the software thus combined.
+ */
+
+
+/*
+ *                         echo-presentity.cpp  -  description
+ *                         ------------------------------------------
+ *   begin                : written in 2008 by Julien Puydt
+ *   copyright            : (c) 2008 by Julien Puydt
+ *   description          : implementation of an echo presentity
+ *
+ */
+
+#include <iostream>
+
+#include "echo-presentity.h"
+
+Echo::Presentity::Presentity ()
+{
+}
+
+Echo::Presentity::~Presentity ()
+{
+#ifdef __GNUC__
+  std::cout << __PRETTY_FUNCTION__ << std::endl;
+#endif
+}
+
+const std::string
+Echo::Presentity::get_name () const
+{
+  return "Echo";
+}
+
+const std::string
+Echo::Presentity::get_presence () const
+{
+  return "online"; // FIXME
+}
+
+const std::string
+Echo::Presentity::get_status () const
+{
+  return "ready";
+}
+
+const std::string
+Echo::Presentity::get_avatar () const
+{
+  return ""; // FIXME
+}
+
+const std::set<std::string>
+Echo::Presentity::get_groups () const
+{
+  return std::set<std::string>();
+}
+
+const std::string
+Echo::Presentity::get_uri () const
+{
+  return ""; // should be good enough
+}
+
+bool
+Echo::Presentity::populate_menu (Ekiga::MenuBuilder &)
+{
+  return false; // FIXME?
+}

Added: trunk/lib/engine/chat/echo/echo-presentity.h
==============================================================================
--- (empty file)
+++ trunk/lib/engine/chat/echo/echo-presentity.h	Thu Jul 10 07:45:33 2008
@@ -0,0 +1,68 @@
+
+/*
+ * Ekiga -- A VoIP and Video-Conferencing application
+ * Copyright (C) 2000-2008 Damien Sandras
+
+ * This program is free software; you can  redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version. This program is distributed in the hope
+ * that it will be useful, but WITHOUT ANY WARRANTY; without even the
+ * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Ekiga is licensed under the GPL license and as a special exception, you
+ * have permission to link or otherwise combine this program with the
+ * programs OPAL, OpenH323 and PWLIB, and distribute the combination, without
+ * applying the requirements of the GNU GPL to the OPAL, OpenH323 and PWLIB
+ * programs, as long as you do follow the requirements of the GNU GPL for all
+ * the rest of the software thus combined.
+ */
+
+
+/*
+ *                         echo-presentity.h  -  description
+ *                         ------------------------------------------
+ *   begin                : written in 2008 by Julien Puydt
+ *   copyright            : (c) 2008 by Julien Puydt
+ *   description          : declaration of an echo presentity
+ *
+ */
+
+#ifndef __ECHO_PRESENTITY__
+#define __ECHO_PRESENTITY__
+
+#include "presentity.h"
+
+namespace Echo
+{
+  class Presentity: public Ekiga::Presentity
+  {
+  public:
+
+    Presentity ();
+
+    ~Presentity ();
+
+    const std::string get_name () const;
+
+    const std::string get_presence () const;
+
+    const std::string get_status () const;
+
+    const std::string get_avatar () const;
+
+    const std::set<std::string> get_groups () const;
+
+    const std::string get_uri () const;
+
+    bool populate_menu (Ekiga::MenuBuilder &);
+  };
+
+};
+
+#endif

Added: trunk/lib/engine/chat/echo/echo-simple.cpp
==============================================================================
--- (empty file)
+++ trunk/lib/engine/chat/echo/echo-simple.cpp	Thu Jul 10 07:45:33 2008
@@ -0,0 +1,95 @@
+
+/*
+ * Ekiga -- A VoIP and Video-Conferencing application
+ * Copyright (C) 2000-2008 Damien Sandras
+
+ * This program is free software; you can  redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version. This program is distributed in the hope
+ * that it will be useful, but WITHOUT ANY WARRANTY; without even the
+ * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Ekiga is licensed under the GPL license and as a special exception, you
+ * have permission to link or otherwise combine this program with the
+ * programs OPAL, OpenH323 and PWLIB, and distribute the combination, without
+ * applying the requirements of the GNU GPL to the OPAL, OpenH323 and PWLIB
+ * programs, as long as you do follow the requirements of the GNU GPL for all
+ * the rest of the software thus combined.
+ */
+
+
+/*
+ *                         echo-simple.cpp  -  description
+ *                         ------------------------------------------
+ *   begin                : written in 2008 by Julien Puydt
+ *   copyright            : (c) 2008 by Julien Puydt
+ *   description          : implementation of an echo simple chat
+ *
+ */
+
+#include <iostream>
+
+#include "echo-simple.h"
+
+Echo::SimpleChat::SimpleChat (): presentity(new Presentity ())
+{
+}
+
+Echo::SimpleChat::~SimpleChat ()
+{
+#ifdef __GNUC__
+  std::cout << __PRETTY_FUNCTION__ << std::endl;
+#endif
+}
+
+Ekiga::Presentity&
+Echo::SimpleChat::get_presentity () const
+{
+  return *presentity;
+}
+
+bool
+Echo::SimpleChat::populate_menu (Ekiga::MenuBuilder &/*builder*/)
+{
+  return false;
+}
+
+void
+Echo::SimpleChat::connect (Ekiga::ChatObserver &observer)
+{
+  observer.notice ("This is just an echo chat : type and see back");
+
+  observers.push_front (&observer);
+}
+
+void
+Echo::SimpleChat::disconnect (Ekiga::ChatObserver &observer)
+{
+  observers.remove (&observer);
+
+  if (observers.empty ())
+    removed.emit ();
+}
+
+bool
+Echo::SimpleChat::send_message (const std::string msg)
+{
+  for (std::list<Ekiga::ChatObserver*>::iterator iter = observers.begin ();
+       iter != observers.end ();
+       ++iter)
+    (*iter)->message ("Echo", msg);
+
+  return true;
+}
+
+const std::string
+Echo::SimpleChat::get_title() const
+{
+  return "Echo chat";
+}

Added: trunk/lib/engine/chat/echo/echo-simple.h
==============================================================================
--- (empty file)
+++ trunk/lib/engine/chat/echo/echo-simple.h	Thu Jul 10 07:45:33 2008
@@ -0,0 +1,71 @@
+
+/*
+ * Ekiga -- A VoIP and Video-Conferencing application
+ * Copyright (C) 2000-2008 Damien Sandras
+
+ * This program is free software; you can  redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version. This program is distributed in the hope
+ * that it will be useful, but WITHOUT ANY WARRANTY; without even the
+ * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Ekiga is licensed under the GPL license and as a special exception, you
+ * have permission to link or otherwise combine this program with the
+ * programs OPAL, OpenH323 and PWLIB, and distribute the combination, without
+ * applying the requirements of the GNU GPL to the OPAL, OpenH323 and PWLIB
+ * programs, as long as you do follow the requirements of the GNU GPL for all
+ * the rest of the software thus combined.
+ */
+
+
+/*
+ *                         echo-simple.h  -  description
+ *                         ------------------------------------------
+ *   begin                : written in 2008 by Julien Puydt
+ *   copyright            : (c) 2008 by Julien Puydt
+ *   description          : declaration of an echo simple chat
+ *
+ */
+
+#ifndef __ECHO_SIMPLE_H__
+#define __ECHO_SIMPLE_H__
+
+#include "chat-simple.h"
+#include "echo-presentity.h"
+
+namespace Echo
+{
+  class SimpleChat: public Ekiga::SimpleChat
+  {
+  public:
+
+    SimpleChat ();
+
+    ~SimpleChat ();
+
+    const std::string get_title() const;
+
+    void connect (Ekiga::ChatObserver &observer);
+
+    void disconnect (Ekiga::ChatObserver &observer);
+
+    bool send_message (const std::string msg);
+
+    Ekiga::Presentity &get_presentity () const;
+
+    bool populate_menu (Ekiga::MenuBuilder &builder);
+
+  private:
+
+    std::list<Ekiga::ChatObserver*> observers;
+    Presentity *presentity;
+  };
+};
+
+#endif

Modified: trunk/lib/engine/chat/skel/Makefile.am
==============================================================================
--- trunk/lib/engine/chat/skel/Makefile.am	(original)
+++ trunk/lib/engine/chat/skel/Makefile.am	Thu Jul 10 07:45:33 2008
@@ -6,11 +6,17 @@
 
 INCLUDES = \
 	-I$(top_srcdir)/lib/engine/include 		\
-	-I$(top_srcdir)/lib/engine/framework
+	-I$(top_srcdir)/lib/engine/framework		\
+	-I$(top_srcdir)/lib/engine/presence/skel
 
 libgmchat_la_SOURCES = \
 	$(chat_dir)/chat-core.h			\
 	$(chat_dir)/chat-core.cpp		\
+	$(chat_dir)/dialect.h			\
+	$(chat_dir)/dialect-impl.h		\
+	$(chat_dir)/chat.h			\
+	$(chat_dir)/chat-simple.h		\
+	$(chat_dir)/chat-multiple.h		\
 	$(chat_dir)/chat-manager.h
 
 libgmchat_la_LDFLAGS = -export-dynamic -no-undefined $(SIGC_LIBS)

Modified: trunk/lib/engine/chat/skel/chat-core.cpp
==============================================================================
--- trunk/lib/engine/chat/skel/chat-core.cpp	(original)
+++ trunk/lib/engine/chat/skel/chat-core.cpp	Thu Jul 10 07:45:33 2008
@@ -27,94 +27,48 @@
 /*
  *                         chat-core.cpp  -  description
  *                         ------------------------------------------
- *   begin                : written in 2007 by Damien Sandras 
- *   copyright            : (c) 2007 by Damien Sandras
- *   description          : declaration of the interface of a chat core.
- *                          A chat core manages ChatManagers.
+ *   begin                : written in 2007 by Julien Puydt
+ *   copyright            : (c) 2007 by Julien Puydt
+ *   description          : implementation of the main chat managing object
  *
  */
 
-#include <iostream>
-
-#include "config.h"
-
 #include "chat-core.h"
-#include "chat-manager.h"
-
-
-using namespace Ekiga;
-
-
-void ChatCore::add_manager (ChatManager &manager)
-{
-  managers.insert (&manager);
-  manager_added.emit (manager);
-
-  manager.im_failed.connect (sigc::bind (sigc::mem_fun (this, &ChatCore::on_im_failed), &manager));
-  manager.im_received.connect (sigc::bind (sigc::mem_fun (this, &ChatCore::on_im_received), &manager));
-  manager.im_sent.connect (sigc::bind (sigc::mem_fun (this, &ChatCore::on_im_sent), &manager));
-  manager.new_chat.connect (sigc::bind (sigc::mem_fun (this, &ChatCore::on_new_chat), &manager));
-}
-
-
-ChatCore::iterator ChatCore::begin ()
-{
-  return managers.begin ();
-}
-
-
-ChatCore::const_iterator ChatCore::begin () const
-{
-  return managers.begin ();
-}
-
-
-ChatCore::iterator ChatCore::end ()
-{
-  return managers.end (); 
-}
 
+#include <iostream>
 
-ChatCore::const_iterator ChatCore::end () const
+Ekiga::ChatCore::~ChatCore ()
 {
-  return managers.end (); 
 }
 
-
-bool ChatCore::send_message (const std::string & uri, 
-                             const std::string & message)
+void
+Ekiga::ChatCore::add_dialect (Dialect& dialect)
 {
-  for (ChatCore::iterator iter = managers.begin ();
-       iter != managers.end ();
-       iter++) {
-
-    if ((*iter)->send_message (uri, message))
-      return true;
-  }
-
-  return false;
+  dialects.insert (&dialect);
+  dialect.questions.add_handler (questions.make_slot ());
+  dialect_added.emit (dialect);
 }
 
-
-void ChatCore::on_im_failed (const std::string uri, const std::string reason, ChatManager *manager)
+void
+Ekiga::ChatCore::visit_dialects (sigc::slot<bool, Dialect&> visitor)
 {
-  im_failed.emit (*manager, uri, reason);
-}
-
+  bool go_on = true;
 
-void ChatCore::on_im_sent (const std::string uri, const std::string message, ChatManager *manager)
-{
-  im_sent.emit (*manager, uri, message);
+  for (std::set<Dialect*>::iterator iter = dialects.begin ();
+       iter != dialects.end () && go_on;
+       iter++)
+    go_on = visitor (**iter);
 }
 
-
-void ChatCore::on_im_received (const std::string display_name, const std::string uri, const std::string message, ChatManager *manager)
+bool
+Ekiga::ChatCore::populate_menu (MenuBuilder &builder)
 {
-  im_received.emit (*manager, display_name, uri, message);
-}
+  bool result = false;
 
+  for (std::set<Dialect*>::iterator iter = dialects.begin ();
+       iter != dialects.end ();
+       ++iter)
+    result = (*iter)->populate_menu (builder) || result;
 
-void ChatCore::on_new_chat (const std::string display_name, const std::string uri, ChatManager *manager)
-{
-  new_chat.emit (*manager, display_name, uri);
+  return result;
 }

Modified: trunk/lib/engine/chat/skel/chat-core.h
==============================================================================
--- trunk/lib/engine/chat/skel/chat-core.h	(original)
+++ trunk/lib/engine/chat/skel/chat-core.h	Thu Jul 10 07:45:33 2008
@@ -27,10 +27,9 @@
 /*
  *                         chat-core.h  -  description
  *                         ------------------------------------------
- *   begin                : written in 2007 by Damien Sandras 
- *   copyright            : (c) 2007 by Damien Sandras
- *   description          : declaration of the interface of a chat core.
- *                          A chat core manages ChatManagers.
+ *   begin                : written in 2007 by Julien Puydt
+ *   copyright            : (c) 2007 by Julien Puydt
+ *   description          : declaration of the main chat managing object
  *
  */
 
@@ -38,104 +37,150 @@
 #define __CHAT_CORE_H__
 
 #include "services.h"
+#include "dialect.h"
 
-#include <sigc++/sigc++.h>
-#include <set>
-#include <map>
+// FIXME: that one is for Damien's temporary code
+#include "chat-manager.h"
 
+/* FIXME: probably it should have a decorator system, so we can for example
+ * hook a logger
+ */
 
 namespace Ekiga
 {
-
-/**
- * @defgroup chats Chats and protocols
- * @{
- */
-
-  class ChatManager;
-
-  class ChatCore
-    : public Service
-    {
-
+  /**
+   * @defgroup chats Chats and protocols
+   * @{
+   */
+
+  /*  Core object for text chat support.
+   *
+   * Notice that you give dialects to this object as references, so they won't
+   * be freed here : it's up to you to free them somehow.
+   */
+  class ChatCore: public Service
+  {
   public:
-      typedef std::set<ChatManager *>::iterator iterator;
-      typedef std::set<ChatManager *>::const_iterator const_iterator;
-
-      /** The constructor
-       */
-      ChatCore () {}
-
-      /** The destructor
-       */
-      ~ChatCore () {}
 
+    /** The constructor.
+     */
+    ChatCore () {}
+
+    /** The destructor.
+     */
+    ~ChatCore ();
 
-      /*** Service Implementation ***/
-
-      /** Returns the name of the service.
-       * @return The service name.
-       */
-      const std::string get_name () const
-        { return "chat-core"; }
+    /*** service implementation ***/
+  public:
 
+    /** Returns the name of the service.
+     * @return The service name.
+     */
+    const std::string get_name () const
+    { return "chat-core"; }
+
+    /** Returns the description of the service.
+     * @return: The service description.
+     */
+    const std::string get_description () const
+    { return "\tChat managing object"; }
 
-      /** Returns the description of the service.
-       * @return The service description.
-       */
-      const std::string get_description () const
-        { return "\tChat Core managing ChatManager objects"; }
+    /*** Public API ***/
+  public:
 
+    /** Adds a dialect to the ContactCore service.
+     * @param The dialect to be added.
+     */
+    void add_dialect (Dialect& dialect);
+
+    /** Triggers a callback for all Ekiga::Dialect dialects of the
+     * ChatCore service.
+     * @param The callback (the return value means "go on" and allows stopping
+     * the visit)
+     */
+    void visit_dialects (sigc::slot<bool, Dialect&> visitor);
+
+    /** This signal is emitted when an Ekiga::Dialect has been added to
+     * the ChatCore service.
+     */
+    sigc::signal<void, Dialect&> dialect_added;
 
-      /** Adds a ChatManager to the ChatCore service.
-       * @param The manager to be added.
-       */
-      void add_manager (ChatManager &manager);
+  private:
 
-      /** Return iterator to beginning
-       * @return iterator to beginning
-       */
-      iterator begin ();
-      const_iterator begin () const;
+    std::set<Dialect*> dialects;
 
-      /** Return iterator to end
-       * @return iterator to end 
-       */
-      iterator end ();
-      const_iterator end () const;
+    /*** Misc ***/
+  public:
 
-      /** This signal is emitted when a Ekiga::ChatManager has been
-       * added to the ChatCore Service.
-       */
-      sigc::signal<void, ChatManager &> manager_added;
+    /** Create the menu for the ChatCore and its actions.
+     * @param A MenuBuilder object to populate.
+     */
+    bool populate_menu (MenuBuilder &builder);
+
+    /** This signal is emitted when the ChatCore service has been updated.
+     */
+    sigc::signal<void> updated;
+
+    /** This chain allows the ChatCore to present forms to the user
+     */
+    ChainOfResponsibility<FormRequest*> questions;
+
+    /** FIXME: start of Damien's temporary code :
+     **
+     **/
+  public:
+    void add_manager (ChatManager &manager)
+    {
+      managers.insert (&manager);
+      manager.im_failed.connect (sigc::bind (sigc::mem_fun (this, &ChatCore::on_im_failed), &manager));
+      manager.im_received.connect (sigc::bind (sigc::mem_fun (this, &ChatCore::on_im_received), &manager));
+      manager.im_sent.connect (sigc::bind (sigc::mem_fun (this, &ChatCore::on_im_sent), &manager));
+      manager.new_chat.connect (sigc::bind (sigc::mem_fun (this, &ChatCore::on_new_chat), &manager));
+    }
 
+    bool send_message (const std::string & uri,
+		       const std::string & message)
+    {
+      for (std::set<ChatManager*>::iterator iter = managers.begin ();
+	   iter != managers.end ();
+	   iter++) {
+
+	if ((*iter)->send_message (uri, message))
+	  return true;
+      }
+
+      return false;
+    }
+
+    sigc::signal<void, const ChatManager &, const std::string, const std::string> im_failed;
+    sigc::signal<void, const ChatManager &, const std::string, const std::string, const std::string> im_received;
+    sigc::signal<void, const ChatManager &, const std::string, const std::string> im_sent;
+    sigc::signal<void, const ChatManager &, const std::string, const std::string> new_chat;
 
-      /*** Instant Messaging ***/ 
+  private:
+    std::set<ChatManager *> managers;
 
-      /** See chat-manager.h for API **/
-      bool send_message (const std::string & uri, 
-                         const std::string & message);
+    void on_im_failed (const std::string uri, const std::string reason, ChatManager *manager)
+    { im_failed.emit (*manager, uri, reason); }
 
-      sigc::signal<void, const ChatManager &, const std::string, const std::string> im_failed;
-      sigc::signal<void, const ChatManager &, const std::string, const std::string, const std::string> im_received;
-      sigc::signal<void, const ChatManager &, const std::string, const std::string> im_sent;
-      sigc::signal<void, const ChatManager &, const std::string, const std::string> new_chat;
+    void on_im_sent (const std::string uri, const std::string message, ChatManager *manager)
+    { im_sent.emit (*manager, uri, message); }
 
+    void on_im_received (const std::string display_name, const std::string uri, const std::string message, ChatManager *manager)
+    { im_received.emit (*manager, display_name, uri, message); }
 
-  private:
-      void on_im_failed (const std::string, const std::string, ChatManager *manager);
-      void on_im_sent (const std::string, const std::string, ChatManager *manager);
-      void on_im_received (const std::string, const std::string, const std::string, ChatManager *manager);
-      void on_new_chat (const std::string, const std::string, ChatManager *manager);
+    void on_new_chat (const std::string display_name, const std::string uri, ChatManager *manager)
+    { new_chat.emit (*manager, display_name, uri); }
 
-      std::set<ChatManager *> managers;
-    };
 
-/**
- * @}
- */
+    /** FIXME: end of Damien's temporary code
+     **
+     **/
+  };
 
+  /**
+   * @}
+   */
 };
 
-
 #endif

Modified: trunk/lib/engine/chat/skel/chat-manager.h
==============================================================================
--- trunk/lib/engine/chat/skel/chat-manager.h	(original)
+++ trunk/lib/engine/chat/skel/chat-manager.h	Thu Jul 10 07:45:33 2008
@@ -39,9 +39,6 @@
 #ifndef __CHAT_MANAGER_H__
 #define __CHAT_MANAGER_H__
 
-#include "chat-core.h"
-
-
 namespace Ekiga
 {
 

Added: trunk/lib/engine/chat/skel/chat-multiple.h
==============================================================================
--- (empty file)
+++ trunk/lib/engine/chat/skel/chat-multiple.h	Thu Jul 10 07:45:33 2008
@@ -0,0 +1,63 @@
+
+/*
+ * Ekiga -- A VoIP and Video-Conferencing application
+ * Copyright (C) 2000-2007 Damien Sandras
+
+ * This program is free software; you can  redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version. This program is distributed in the hope
+ * that it will be useful, but WITHOUT ANY WARRANTY; without even the
+ * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Ekiga is licensed under the GPL license and as a special exception, you
+ * have permission to link or otherwise combine this program with the
+ * programs OPAL, OpenH323 and PWLIB, and distribute the combination, without
+ * applying the requirements of the GNU GPL to the OPAL, OpenH323 and PWLIB
+ * programs, as long as you do follow the requirements of the GNU GPL for all
+ * the rest of the software thus combined.
+ */
+
+
+/*
+ *                         chat-multiple.h  -  description
+ *                         ------------------------------------------
+ *   begin                : written in 2007 by Julien Puydt
+ *   copyright            : (c) 2007 by Julien Puydt
+ *   description          : declaration of the interface of a chat with a
+ *                          several persons
+ *
+ */
+
+#ifndef __CHAT_MULTIPLE_H__
+#define __CHAT_MULTIPLE_H__
+
+#include "chat.h"
+#include "heap.h"
+
+namespace Ekiga
+{
+
+  class MultipleChat: public Chat
+  {
+  public:
+
+    /** The destructor.
+     */
+    virtual ~MultipleChat ()
+    {}
+
+    /** Returns the Heap associated with the MultipleChat.
+     * @return The MultipleChat's Heap
+     */
+    virtual Heap& get_heap () const = 0;
+  };
+
+};
+
+#endif

Added: trunk/lib/engine/chat/skel/chat-simple.h
==============================================================================
--- (empty file)
+++ trunk/lib/engine/chat/skel/chat-simple.h	Thu Jul 10 07:45:33 2008
@@ -0,0 +1,63 @@
+
+/*
+ * Ekiga -- A VoIP and Video-Conferencing application
+ * Copyright (C) 2000-2007 Damien Sandras
+
+ * This program is free software; you can  redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version. This program is distributed in the hope
+ * that it will be useful, but WITHOUT ANY WARRANTY; without even the
+ * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Ekiga is licensed under the GPL license and as a special exception, you
+ * have permission to link or otherwise combine this program with the
+ * programs OPAL, OpenH323 and PWLIB, and distribute the combination, without
+ * applying the requirements of the GNU GPL to the OPAL, OpenH323 and PWLIB
+ * programs, as long as you do follow the requirements of the GNU GPL for all
+ * the rest of the software thus combined.
+ */
+
+
+/*
+ *                         chat-simple.h  -  description
+ *                         ------------------------------------------
+ *   begin                : written in 2007 by Julien Puydt
+ *   copyright            : (c) 2007 by Julien Puydt
+ *   description          : declaration of the interface of a chat with a
+ *                          single person
+ *
+ */
+
+#ifndef __CHAT_SIMPLE_H__
+#define __CHAT_SIMPLE_H__
+
+#include "chat.h"
+#include "presentity.h"
+
+namespace Ekiga
+{
+
+  class SimpleChat: public Chat
+  {
+  public:
+
+    /** The destructor.
+     */
+    virtual ~SimpleChat ()
+    {}
+
+    /** Returns the Presentity associated with the SimpleChat.
+     * @return The SimpleChat's Presentity.
+     */
+    virtual Presentity &get_presentity () const = 0;
+  };
+
+};
+
+#endif

Added: trunk/lib/engine/chat/skel/chat.h
==============================================================================
--- (empty file)
+++ trunk/lib/engine/chat/skel/chat.h	Thu Jul 10 07:45:33 2008
@@ -0,0 +1,131 @@
+
+/*
+ * Ekiga -- A VoIP and Video-Conferencing application
+ * Copyright (C) 2000-2007 Damien Sandras
+
+ * This program is free software; you can  redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version. This program is distributed in the hope
+ * that it will be useful, but WITHOUT ANY WARRANTY; without even the
+ * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Ekiga is licensed under the GPL license and as a special exception, you
+ * have permission to link or otherwise combine this program with the
+ * programs OPAL, OpenH323 and PWLIB, and distribute the combination, without
+ * applying the requirements of the GNU GPL to the OPAL, OpenH323 and PWLIB
+ * programs, as long as you do follow the requirements of the GNU GPL for all
+ * the rest of the software thus combined.
+ */
+
+
+/*
+ *                         chat.h  -  description
+ *                         ------------------------------------------
+ *   begin                : written in 2007 by Julien Puydt
+ *   copyright            : (c) 2007 by Julien Puydt
+ *   description          : declaration of the interface of a chat
+ *
+ */
+
+#ifndef __CHAT_H__
+#define __CHAT_H__
+
+#include <string>
+#include <sigc++/sigc++.h>
+
+#include "chain-of-responsibility.h"
+#include "form-request.h"
+#include "menu-builder.h"
+
+namespace Ekiga
+{
+  class ChatObserver
+  {
+  public:
+
+    virtual ~ChatObserver () {}
+
+    /** Tell the observer about a new user message, like :
+     * observer.message ("Damien", "Hi Snark, did you fix bug #314159 ?");
+     *
+     */
+    virtual void message (const std::string to,
+			  const std::string msg) = 0;
+
+    /** Tell the observer about a new service message, like :
+     * observer.notice ("Snark just disconnected");
+     *
+     */
+    virtual void notice (const std::string msg) = 0;
+  };
+
+
+  class Chat
+  {
+  public:
+
+    /** The destructor.
+     */
+    virtual ~Chat ()
+    {}
+
+    /** Returns the title of the Chat.
+     * @return The chat title.
+     */
+    virtual const std::string get_title () const = 0;
+
+    /** Connects a new observer to the Chat ; notice that using an
+     * observer-as-an-object approch vs a signal based approch makes
+     * it possible to detect when the last observer quits, and hence
+     * quit the Chat (emit "removed"). The Chat can use that call to
+     * send a few previous messages to the new observer.
+     * @param The new observer
+     */
+    virtual void connect (ChatObserver &observer) = 0;
+
+    /** Disconnects the new observer from the Chat
+     * @param The observer to disconnect
+     */
+    virtual void disconnect (ChatObserver &observer) = 0;
+
+    /** Sends a message through the Chat, or at least attempts to :
+     * the two ideas are first that the text entry will get blanked
+     * only if true is returned, and second that true doesn't mean the
+     * message is really sent, but only that it was valid to try (for
+     * example, the Chat will return false if you try to send when not
+     * having "voice" on an irc channel, or if you try to send to a
+     * disconnected contact with a protocol which doesn't support
+     * disconnected operation). The user may still be warned that the
+     * actual sending was impossible later through a notice message.
+     * @param The message to send
+     * @return True if it was valid to send a message
+     */
+    virtual bool send_message (const std::string msg) = 0;
+
+    /** This signal is emitted when the Chat has been updated.
+     */
+    sigc::signal<void> updated;
+
+    /** This signal is emitted when the Chat has been removed.
+     */
+    sigc::signal<void> removed;
+
+    /** Feed possible actions on this Chat to the given MenuBuilder
+     * @param A MenuBuilder object to populate.
+     */
+    virtual bool populate_menu (MenuBuilder &) = 0;
+
+    /** This chain allows the Chat to present forms to the user.
+     */
+    ChainOfResponsibility<FormRequest*> questions;
+  };
+
+};
+
+#endif

Added: trunk/lib/engine/chat/skel/dialect-impl.h
==============================================================================
--- (empty file)
+++ trunk/lib/engine/chat/skel/dialect-impl.h	Thu Jul 10 07:45:33 2008
@@ -0,0 +1,233 @@
+
+/*
+ * Ekiga -- A VoIP and Video-Conferencing application
+ * Copyright (C) 2000-2008 Damien Sandras
+
+ * This program is free software; you can  redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version. This program is distributed in the hope
+ * that it will be useful, but WITHOUT ANY WARRANTY; without even the
+ * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Ekiga is licensed under the GPL license and as a special exception, you
+ * have permission to link or otherwise combine this program with the
+ * programs OPAL, OpenH323 and PWLIB, and distribute the combination, without
+ * applying the requirements of the GNU GPL to the OPAL, OpenH323 and PWLIB
+ * programs, as long as you do follow the requirements of the GNU GPL for all
+ * the rest of the software thus combined.
+ */
+
+
+/*
+ *                         dialect.h  -  description
+ *                         ------------------------------------------
+ *   begin                : written in 2008 by Julien Puydt
+ *   copyright            : (c) 2008 by Julien Puydt
+ *   description          : basic implementation of a real chat backend
+ *
+ */
+
+#ifndef __DIALECT_IMPL_H__
+#define __DIALECT_IMPL_H__
+
+#include "dialect.h"
+#include "lister.h"
+
+namespace Ekiga
+{
+  template<typename SimpleChatType = SimpleChat,
+	   typename MultipleChatType = MultipleChat>
+  class DialectImpl:
+    public Dialect,
+    public sigc::trackable
+  {
+  public:
+
+    /** The constructor.
+     */
+    DialectImpl ();
+
+    /** The destructor.
+     */
+    ~DialectImpl ();
+
+    /** Triggers a callback for all simple chats of the Dialect.
+     * @param: The callback (the return value means "go on" and allows
+     * stopping the visit)
+     */
+    void visit_simple_chats (sigc::slot<bool, SimpleChat&> visitor);
+
+    /** Triggers a callback for all multiple chats of the Dialect.
+     * @param: The callback (the return value means "go on" and allows
+     * stopping the visit)
+     */
+    void visit_multiple_chats (sigc::slot<bool, MultipleChat&> visitor);
+
+  protected:
+
+    /* More STL-like ways to access the chats within this Ekiga::DialectImpl
+     */
+    typedef typename Lister<SimpleChatType>::iterator simple_iterator;
+    typedef typename Lister<SimpleChatType>::const_iterator simple_const_iterator;
+    typedef typename Lister<MultipleChatType>::iterator multiple_iterator;
+    typedef typename Lister<MultipleChatType>::const_iterator multiple_const_iterator;
+
+    simple_iterator simple_begin ();
+    simple_iterator simple_end ();
+    simple_const_iterator simple_begin () const;
+    simple_const_iterator simple_end () const;
+
+    multiple_iterator multiple_begin ();
+    multiple_iterator multiple_end ();
+    multiple_const_iterator multiple_begin () const;
+    multiple_const_iterator multiple_end () const;
+
+    /** Adds a SimpleChat to the Ekiga::Dialect.
+     * @param The SimpleChat to be added.
+     * @return: The Ekiga::Dialect 'simple_chat_added' signal is emitted.
+     */
+    void add_simple_chat (bool user_request,
+			  SimpleChatType* chat);
+
+    /** Removes a SimpleChat from the Ekiga::Dialect.
+     * @param The SimpleChat to be removed.
+     */
+    void remove_simple_chat (SimpleChatType* chat);
+
+    /** Adds a MultipleChat to the Ekiga::Dialect.
+     * @param The MultipleChat to be added.
+     * @return: The Ekiga::Dialect 'multiple_chat_added' signal is emitted.
+     */
+    void add_multiple_chat (bool user_request,
+			    MultipleChatType* chat);
+
+    /** Removes a MultipleChat from the Ekiga::Dialect.
+     * @param The MultipleChat to be removed.
+     */
+    void remove_multiple_chat (MultipleChatType* chat);
+
+  private:
+
+    Lister<SimpleChatType> simple_chats;
+    Lister<MultipleChatType> multiple_chats;
+  };
+};
+
+template<typename SimpleChatType, typename MultipleChatType>
+Ekiga::DialectImpl<SimpleChatType, MultipleChatType>::DialectImpl ()
+{
+}
+
+template<typename SimpleChatType, typename MultipleChatType>
+Ekiga::DialectImpl<SimpleChatType, MultipleChatType>::~DialectImpl ()
+{
+}
+
+template<typename SimpleChatType, typename MultipleChatType>
+void
+Ekiga::DialectImpl<SimpleChatType, MultipleChatType>::visit_simple_chats (sigc::slot<bool, SimpleChat&> visitor)
+{
+  simple_chats.visit_objects (visitor);
+}
+
+template<typename SimpleChatType, typename MultipleChatType>
+void
+Ekiga::DialectImpl<SimpleChatType, MultipleChatType>::visit_multiple_chats (sigc::slot<bool, MultipleChat&> visitor)
+{
+  multiple_chats.visit_objects (visitor);
+}
+
+template<typename SimpleChatType, typename MultipleChatType>
+typename Ekiga::DialectImpl<SimpleChatType, MultipleChatType>::simple_iterator
+Ekiga::DialectImpl<SimpleChatType, MultipleChatType>::simple_begin ()
+{
+  return simple_iterator (simple_chats.begin ());
+}
+
+template<typename SimpleChatType, typename MultipleChatType>
+typename Ekiga::DialectImpl<SimpleChatType, MultipleChatType>::simple_iterator
+Ekiga::DialectImpl<SimpleChatType, MultipleChatType>::simple_end ()
+{
+  return simple_iterator (simple_chats.end ());
+}
+
+template<typename SimpleChatType, typename MultipleChatType>
+typename Ekiga::DialectImpl<SimpleChatType, MultipleChatType>::simple_const_iterator
+Ekiga::DialectImpl<SimpleChatType, MultipleChatType>::simple_begin () const
+{
+  return simple_const_iterator (simple_chats.begin ());
+}
+
+template<typename SimpleChatType, typename MultipleChatType>
+typename Ekiga::DialectImpl<SimpleChatType, MultipleChatType>::simple_const_iterator
+Ekiga::DialectImpl<SimpleChatType, MultipleChatType>::simple_end () const
+{
+  return simple_const_iterator (simple_chats.end ());
+}
+
+template<typename SimpleChatType, typename MultipleChatType>
+typename Ekiga::DialectImpl<SimpleChatType, MultipleChatType>::multiple_iterator
+Ekiga::DialectImpl<SimpleChatType, MultipleChatType>::multiple_begin ()
+{
+  return multiple_iterator (multiple_chats.begin ());
+}
+
+template<typename SimpleChatType, typename MultipleChatType>
+typename Ekiga::DialectImpl<SimpleChatType, MultipleChatType>::multiple_iterator
+Ekiga::DialectImpl<SimpleChatType, MultipleChatType>::multiple_end ()
+{
+  return multiple_iterator (multiple_chats.end ());
+}
+
+template<typename SimpleChatType, typename MultipleChatType>
+typename Ekiga::DialectImpl<SimpleChatType, MultipleChatType>::multiple_const_iterator
+Ekiga::DialectImpl<SimpleChatType, MultipleChatType>::multiple_begin () const
+{
+  return multiple_const_iterator (multiple_chats.begin ());
+}
+
+template<typename SimpleChatType, typename MultipleChatType>
+typename Ekiga::DialectImpl<SimpleChatType, MultipleChatType>::multiple_const_iterator
+Ekiga::DialectImpl<SimpleChatType, MultipleChatType>::multiple_end () const
+{
+  return multiple_const_iterator (multiple_chats.end ());
+}
+
+template<typename SimpleChatType, typename MultipleChatType>
+void
+Ekiga::DialectImpl<SimpleChatType, MultipleChatType>::add_simple_chat (bool user_request,
+								       SimpleChatType* chat)
+{
+  simple_chats.add_object (*chat);
+  simple_chat_added.emit (user_request, *chat);
+}
+
+template<typename SimpleChatType, typename MultipleChatType>
+void
+Ekiga::DialectImpl<SimpleChatType, MultipleChatType>::remove_simple_chat (SimpleChatType* chat)
+{
+  /* FIXME */
+}
+
+template<typename SimpleChatType, typename MultipleChatType>
+void
+Ekiga::DialectImpl<SimpleChatType, MultipleChatType>::add_multiple_chat (bool user_request, MultipleChatType* chat)
+{
+  multiple_chats.add_object (*chat);
+  multiple_chat_added.emit (user_request, *chat);
+}
+
+template<typename SimpleChatType, typename MultipleChatType>
+void
+Ekiga::DialectImpl<SimpleChatType, MultipleChatType>::remove_multiple_chat (MultipleChatType* chat)
+{
+  /* FIXME */
+}
+
+#endif

Added: trunk/lib/engine/chat/skel/dialect.h
==============================================================================
--- (empty file)
+++ trunk/lib/engine/chat/skel/dialect.h	Thu Jul 10 07:45:33 2008
@@ -0,0 +1,91 @@
+
+/*
+ * Ekiga -- A VoIP and Video-Conferencing application
+ * Copyright (C) 2000-2007 Damien Sandras
+
+ * This program is free software; you can  redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version. This program is distributed in the hope
+ * that it will be useful, but WITHOUT ANY WARRANTY; without even the
+ * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Ekiga is licensed under the GPL license and as a special exception, you
+ * have permission to link or otherwise combine this program with the
+ * programs OPAL, OpenH323 and PWLIB, and distribute the combination, without
+ * applying the requirements of the GNU GPL to the OPAL, OpenH323 and PWLIB
+ * programs, as long as you do follow the requirements of the GNU GPL for all
+ * the rest of the software thus combined.
+ */
+
+
+/*
+ *                         dialect.h  -  description
+ *                         ------------------------------------------
+ *   begin                : written in 2007 by Julien Puydt
+ *   copyright            : (c) 2007 by Julien Puydt
+ *   description          : declaration of the interface of a chat
+ *                          implementation backend
+ *
+ */
+
+#ifndef __DIALECT_H__
+#define __DIALECT_H__
+
+#include "chat-simple.h"
+#include "chat-multiple.h"
+
+namespace Ekiga
+{
+
+  class Dialect
+  {
+  public:
+
+    /** The destructor.
+     */
+    virtual ~Dialect () {}
+
+    /** Triggers a callback for all simple chats of the Dialect.
+     * @param: The callback (the return value means "go on" and allows
+     * stopping the visit)
+     */
+    virtual void visit_simple_chats (sigc::slot<bool, SimpleChat&> visitor) = 0;
+
+    /** Triggers a callback for all multiple chats of the Dialect.
+     * @param: The callback (the return value means "go on" and allows
+     * stopping the visit)
+     */
+    virtual void visit_multiple_chats (sigc::slot<bool, MultipleChat&> visitor) = 0;
+
+
+    /** Feed possible actions on this Dialect to the given MenuBuilder
+     * @param A MenuBuilder object to populate.
+     */
+    virtual bool populate_menu (MenuBuilder &) = 0;
+
+    /** This signal is emitted when an Ekiga::SimpleChat has been added to
+     * the dialect ; the boolean indicates whether the opening was from direct
+     * user request.
+     */
+    sigc::signal<void, bool, SimpleChat&> simple_chat_added;
+
+    /** This signal is emitted when an Ekiga::MultipleChat has been added to
+     * the dialect ; the boolean indicates whether the opening was from direct
+     * user request.
+     */
+    sigc::signal<void, bool, MultipleChat&> multiple_chat_added;
+
+    /** This chain allows the Dialect to present forms to the user.
+     */
+    ChainOfResponsibility<FormRequest*> questions;
+  };
+
+};
+
+#endif

Modified: trunk/lib/engine/gui/gtk-frontend/Makefile.am
==============================================================================
--- trunk/lib/engine/gui/gtk-frontend/Makefile.am	(original)
+++ trunk/lib/engine/gui/gtk-frontend/Makefile.am	Thu Jul 10 07:45:33 2008
@@ -25,8 +25,12 @@
 	$(gtk_frontend_dir)/roster-view-gtk.cpp 	\
 	$(gtk_frontend_dir)/call-history-view-gtk.h 	\
 	$(gtk_frontend_dir)/call-history-view-gtk.cpp 	\
+	$(gtk_frontend_dir)/gtk-chat-view.h		\
+	$(gtk_frontend_dir)/gtk-chat-view.cpp		\
 	$(gtk_frontend_dir)/chat-window.h 		\
 	$(gtk_frontend_dir)/chat-window.cpp 		\
+	$(gtk_frontend_dir)/chat-window-old.h 		\
+	$(gtk_frontend_dir)/chat-window-old.cpp 	\
 	$(gtk_frontend_dir)/chat-window-page.h 		\
 	$(gtk_frontend_dir)/chat-window-page.cpp 	\
 	$(gtk_frontend_dir)/gtk-frontend.h 		\

Copied: trunk/lib/engine/gui/gtk-frontend/chat-window-old.cpp (from r6434, /trunk/lib/engine/gui/gtk-frontend/chat-window.cpp)
==============================================================================
--- /trunk/lib/engine/gui/gtk-frontend/chat-window.cpp	(original)
+++ trunk/lib/engine/gui/gtk-frontend/chat-window-old.cpp	Thu Jul 10 07:45:33 2008
@@ -56,11 +56,11 @@
 #include <iostream>
 
 /*
- * The ChatWindow
+ * The ChatWindowOld
  */
-struct _ChatWindowPrivate 
+struct _ChatWindowOldPrivate 
 {
-  _ChatWindowPrivate (Ekiga::ServiceCore & _core) : core (_core) { }
+  _ChatWindowOldPrivate (Ekiga::ServiceCore & _core) : core (_core) { }
 
   GtkWidget *notebook;
 
@@ -68,7 +68,7 @@
   Ekiga::ServiceCore & core;
 };
 
-enum { CHAT_WINDOW_KEY = 1 };
+enum { CHAT_WINDOW_OLD_KEY = 1 };
 
 static GObjectClass *parent_class = NULL;
 
@@ -90,25 +90,25 @@
  *                when the user clicks on the cross in a ChatWindowPage.
  * BEHAVIOR     : Remove the corresponding ChatWindowPage from the ChatWindow.
  * PRE          : The ChatWindowPage passed as first parameter,
- *                The ChatWindow as second argument.
+ *                The ChatWindowOld as second argument.
  */
 static void close_event_cb (GtkWidget *widget,
                             gpointer data);
 
 
-/* DESCRIPTION  : Called when the ChatWindow is hidden.
+/* DESCRIPTION  : Called when the ChatWindowOld is hidden.
  * BEHAVIOR     : Remove all ChatWindowPages.
- * PRE          : The ChatWindow as second argument.
+ * PRE          : The ChatWindowOld as second argument.
  */
 static void hide_event_cb (GtkWidget *widget,
                            gpointer data);
 
 
-/* DESCRIPTION  : Called when the ChatWindow is being focused.
+/* DESCRIPTION  : Called when the ChatWindowOld is being focused.
  * BEHAVIOR     : Emits the "message-event" signal with the new number
  *                of unseen messages as the current ChatWindowPage does
  *                not have unseen messages anymore. 
- * PRE          : The ChatWindow as last argument.
+ * PRE          : The ChatWindowOld as last argument.
  */
 static void focus_in_changed_cb (GtkWidget *window,
                                  GdkEventFocus *focus,
@@ -119,7 +119,7 @@
  * BEHAVIOR     : Emits the "message-event" signal with the new number
  *                of unseen messages as the current ChatWindowPage does
  *                not have unseen messages anymore. 
- * PRE          : The ChatWindow as last argument.
+ * PRE          : The ChatWindowOld as last argument.
  */
 static void conversation_changed_cb (GtkNotebook *notebook,
                                      GtkNotebookPage *_page,
@@ -137,7 +137,7 @@
  *                Emits the "message-event" signal with the new number
  *                of unseen messages if the ChatWindowPage is not currently
  *                displayed.
- * PRE          : The ChatWindow as last argument.
+ * PRE          : The ChatWindowOld as last argument.
  */
 static void on_im_received_cb (const Ekiga::ChatManager & manager,
                                const std::string & display_name,
@@ -149,7 +149,7 @@
 /* DESCRIPTION  : Called when an IM has been sent.
  * BEHAVIOR     : Display the sent IM in a newly created or existing
  *                ChatWindowPage.
- * PRE          : The ChatWindow as last argument.
+ * PRE          : The ChatWindowOld as last argument.
  */
 static void on_im_sent_cb (const Ekiga::ChatManager & manager,
                            const std::string & to,
@@ -160,7 +160,7 @@
 /* DESCRIPTION  : Called when an IM could not be sent.
  * BEHAVIOR     : Display the error message in a newly created or existing
  *                ChatWindowPage.
- * PRE          : The ChatWindow as last argument.
+ * PRE          : The ChatWindowOld as last argument.
  */
 static void on_im_failed_cb (const Ekiga::ChatManager & manager,
                              const std::string & to,
@@ -175,38 +175,38 @@
 /* DESCRIPTION  : /
  * BEHAVIOR     : Return the ChatWindowPage position in the ChatWindowPage
  *                corresponding to the given uri.
- * PRE          : The ChatWindow as first argument, non-empty URI string.
+ * PRE          : The ChatWindowOld as first argument, non-empty URI string.
  */
-static gint chat_window_get_page_index (ChatWindow *chat_window,
+static gint chat_window_old_get_page_index (ChatWindowOld *chat_window_old,
                                         const std::string uri);
 
 
 /* DESCRIPTION  : /
  * BEHAVIOR     : Return the ChatWindowPage GtkWidget in the ChatWindow
  *                corresponding to the given uri.
- * PRE          : The ChatWindow as first argument, non-empty URI string.
+ * PRE          : The ChatWindowOld as first argument, non-empty URI string.
  */
-static GtkWidget *chat_window_get_page (ChatWindow *chat_window,
+static GtkWidget *chat_window_old_get_page (ChatWindowOld *chat_window_old,
                                         const std::string uri,
                                         const std::string display_name = "");
 
 
 /* DESCRIPTION  : /
  * BEHAVIOR     : Return the number of unread messages.
- * PRE          : The ChatWindow as argument.
+ * PRE          : The ChatWindowOld as argument.
  */
-static int chat_window_get_unread_messages (ChatWindow *chat_window);
+static int chat_window_old_get_unread_messages (ChatWindowOld *chat_window_old);
 
 
 /* 
  * GObject stuff
  */
 static void
-chat_window_dispose (GObject *obj)
+chat_window_old_dispose (GObject *obj)
 {
-  ChatWindow *self = NULL;
+  ChatWindowOld *self = NULL;
 
-  self = CHAT_WINDOW (obj);
+  self = CHAT_WINDOW_OLD (obj);
 
   self->priv->notebook = NULL;
 
@@ -215,11 +215,11 @@
 
 
 static void
-chat_window_finalize (GObject *obj)
+chat_window_old_finalize (GObject *obj)
 {
-  ChatWindow *self = NULL;
+  ChatWindowOld *self = NULL;
 
-  self = CHAT_WINDOW (obj);
+  self = CHAT_WINDOW_OLD (obj);
 
   for (std::vector<sigc::connection>::iterator iter = self->priv->connections.begin () ;
        iter != self->priv->connections.end ();
@@ -233,7 +233,7 @@
 
 
 static void
-chat_window_class_init (gpointer g_class,
+chat_window_old_class_init (gpointer g_class,
 			G_GNUC_UNUSED gpointer class_data)
 {
   GObjectClass *gobject_class = NULL;
@@ -241,11 +241,11 @@
   static gboolean initialised = false;
 
   parent_class = (GObjectClass *) g_type_class_peek_parent (g_class);
-  g_type_class_add_private (g_class, sizeof (ChatWindowPrivate));
+  g_type_class_add_private (g_class, sizeof (ChatWindowOldPrivate));
 
   gobject_class = (GObjectClass *) g_class;
-  gobject_class->dispose = chat_window_dispose;
-  gobject_class->finalize = chat_window_finalize;
+  gobject_class->dispose = chat_window_old_dispose;
+  gobject_class->finalize = chat_window_old_finalize;
 
   if (!initialised) {
 
@@ -262,27 +262,27 @@
 
 
 GType
-chat_window_get_type ()
+chat_window_old_get_type ()
 {
   static GType result = 0;
 
   if (result == 0) {
 
     static const GTypeInfo info = {
-      sizeof (ChatWindowClass),
+      sizeof (ChatWindowOldClass),
       NULL,
       NULL,
-      chat_window_class_init,
+      chat_window_old_class_init,
       NULL,
       NULL,
-      sizeof (ChatWindow),
+      sizeof (ChatWindowOld),
       0,
       NULL,
       NULL
     };
 
     result = g_type_register_static (GM_WINDOW_TYPE,
-				     "ChatWindowType",
+				     "ChatWindowOldType",
 				     &info, (GTypeFlags) 0);
   }
 
@@ -298,7 +298,7 @@
 close_event_cb (G_GNUC_UNUSED GtkWidget *widget,
                 gpointer data)
 {
-  ChatWindow *self = CHAT_WINDOW (data);
+  ChatWindowOld *self = CHAT_WINDOW_OLD (data);
   std::string uri;
 
   int i = 0;
@@ -308,7 +308,7 @@
   n = gtk_notebook_get_n_pages (GTK_NOTEBOOK (self->priv->notebook));
   
   if (i != -1 && n > 1)
-    chat_window_remove_page (CHAT_WINDOW (data), uri);
+    chat_window_old_remove_page (CHAT_WINDOW_OLD (data), uri);
 }
 
 
@@ -316,7 +316,7 @@
 hide_event_cb (G_GNUC_UNUSED GtkWidget *widget,
                gpointer data)
 {
-  ChatWindow *self = CHAT_WINDOW (data);
+  ChatWindowOld *self = CHAT_WINDOW_OLD (data);
 
   int n = 0;
 
@@ -333,7 +333,7 @@
                      G_GNUC_UNUSED GdkEventFocus *focus,
                      gpointer data)
 {
-  ChatWindow *self = CHAT_WINDOW (data);
+  ChatWindowOld *self = CHAT_WINDOW_OLD (data);
   ChatWindowPage *page = NULL;
 
   int n = 0;
@@ -342,8 +342,8 @@
   page = CHAT_WINDOW_PAGE (gtk_notebook_get_nth_page (GTK_NOTEBOOK (self->priv->notebook), n));
 
   chat_window_page_set_unread_messages (page, 0);
-  g_signal_emit_by_name (CHAT_WINDOW (data), "message-event", 
-                         chat_window_get_unread_messages (CHAT_WINDOW (data)));
+  g_signal_emit_by_name (CHAT_WINDOW_OLD (data), "message-event", 
+                         chat_window_old_get_unread_messages (CHAT_WINDOW_OLD (data)));
 }
 
 
@@ -358,8 +358,8 @@
   page = CHAT_WINDOW_PAGE (gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook), n));
 
   chat_window_page_set_unread_messages (page, 0);
-  g_signal_emit_by_name (CHAT_WINDOW (data), "message-event", 
-                         chat_window_get_unread_messages (CHAT_WINDOW (data)));
+  g_signal_emit_by_name (CHAT_WINDOW_OLD (data), "message-event", 
+                         chat_window_old_get_unread_messages (CHAT_WINDOW_OLD (data)));
 }
 
 
@@ -374,7 +374,7 @@
                    const std::string & message,
                    gpointer data)
 {
-  GtkWidget *page = chat_window_get_page (CHAT_WINDOW (data), from, display_name);
+  GtkWidget *page = chat_window_old_get_page (CHAT_WINDOW_OLD (data), from, display_name);
   GtkWidget *notebook_page = NULL;
 
   int n = 0;
@@ -382,13 +382,14 @@
   gboolean visible = false;
 
   if (page == NULL)
-    page = chat_window_add_page (CHAT_WINDOW (data), display_name, from);
+    page = chat_window_old_add_page (CHAT_WINDOW_OLD (data),
+				     display_name, from);
 
   chat_window_page_add_message (CHAT_WINDOW_PAGE (page), display_name, from, message, false);
 
-  g_object_get (CHAT_WINDOW (data), "visible", &visible, NULL);
-  n = gtk_notebook_get_current_page (GTK_NOTEBOOK (CHAT_WINDOW (data)->priv->notebook));
-  notebook_page = gtk_notebook_get_nth_page (GTK_NOTEBOOK (CHAT_WINDOW (data)->priv->notebook), n);
+  g_object_get (CHAT_WINDOW_OLD (data), "visible", &visible, NULL);
+  n = gtk_notebook_get_current_page (GTK_NOTEBOOK (CHAT_WINDOW_OLD (data)->priv->notebook));
+  notebook_page = gtk_notebook_get_nth_page (GTK_NOTEBOOK (CHAT_WINDOW_OLD (data)->priv->notebook), n);
 
   if (!visible || page != notebook_page) {
 
@@ -401,7 +402,7 @@
   }
 
   chat_window_page_set_unread_messages (CHAT_WINDOW_PAGE (page), current_unread_messages);
-  g_signal_emit_by_name (CHAT_WINDOW (data), "message-event", current_unread_messages);
+  g_signal_emit_by_name (CHAT_WINDOW_OLD (data), "message-event", current_unread_messages);
 }
 
 
@@ -411,10 +412,10 @@
                const std::string & message,
                gpointer data)
 {
-  GtkWidget *page = chat_window_get_page (CHAT_WINDOW (data), to);
+  GtkWidget *page = chat_window_old_get_page (CHAT_WINDOW_OLD (data), to);
 
   if (page == NULL)
-    page = chat_window_add_page (CHAT_WINDOW (data), "", to);
+    page = chat_window_old_add_page (CHAT_WINDOW_OLD (data), "", to);
 
   chat_window_page_add_message (CHAT_WINDOW_PAGE (page), "", to, message, true);
 }
@@ -426,10 +427,10 @@
                  const std::string & reason,
                  gpointer data)
 {
-  GtkWidget *page = chat_window_get_page (CHAT_WINDOW (data), to);
+  GtkWidget *page = chat_window_old_get_page (CHAT_WINDOW_OLD (data), to);
 
   if (page == NULL)
-    page = chat_window_add_page (CHAT_WINDOW (data), "", to);
+    page = chat_window_old_add_page (CHAT_WINDOW_OLD (data), "", to);
 
   chat_window_page_add_error (CHAT_WINDOW_PAGE (page), to, reason);
 }
@@ -440,17 +441,17 @@
  */
 
 static gint
-chat_window_get_page_index (ChatWindow *chat_window,
+chat_window_old_get_page_index (ChatWindowOld *chat_window_old,
                             const std::string uri)
 {
-  ChatWindow *self = CHAT_WINDOW (chat_window);
+  ChatWindowOld *self = CHAT_WINDOW_OLD (chat_window_old);
   GtkWidget *page = NULL;
 
   bool found = false;
   int i = 0;
   int n = 0;
   
-  n = chat_window_get_n_pages (self);
+  n = chat_window_old_get_n_pages (self);
 
   while (i < n && !found) {
 
@@ -467,11 +468,11 @@
 
 
 static GtkWidget *
-chat_window_get_page (ChatWindow *chat_window,
+chat_window_old_get_page (ChatWindowOld *chat_window_old,
                       const std::string uri,
                       const std::string display_name)
 {
-  ChatWindow *self = CHAT_WINDOW (chat_window);
+  ChatWindowOld *self = CHAT_WINDOW_OLD (chat_window_old);
   GtkWidget *page = NULL;
 
   std::string host1, host2;
@@ -479,7 +480,7 @@
   int i = 0;
   int n = 0;
   
-  n = chat_window_get_n_pages (self);
+  n = chat_window_old_get_n_pages (self);
 
   while (i < n && !found) {
 
@@ -516,9 +517,9 @@
 
 
 static int 
-chat_window_get_unread_messages (ChatWindow *chat_window)
+chat_window_old_get_unread_messages (ChatWindowOld *chat_window_old)
 {
-  ChatWindow *self = CHAT_WINDOW (chat_window);
+  ChatWindowOld *self = CHAT_WINDOW_OLD (chat_window_old);
 
   GtkWidget *page = NULL;
 
@@ -526,7 +527,7 @@
   int i = 0;
   int n = 0;
   
-  n = chat_window_get_n_pages (self);
+  n = chat_window_old_get_n_pages (self);
 
   while (i < n) {
 
@@ -544,16 +545,16 @@
 
 /* Public API */
 GtkWidget *
-chat_window_new (Ekiga::ServiceCore & core)
+chat_window_old_new (Ekiga::ServiceCore & core)
 {
-  ChatWindow *self = NULL;
+  ChatWindowOld *self = NULL;
 
   Ekiga::ChatCore *chat_core = NULL;
 
   sigc::connection conn;
 
-  self = CHAT_WINDOW (g_object_new (CHAT_WINDOW_TYPE, NULL));
-  self->priv = new ChatWindowPrivate (core);
+  self = CHAT_WINDOW_OLD (g_object_new (CHAT_WINDOW_OLD_TYPE, NULL));
+  self->priv = new ChatWindowOldPrivate (core);
 
   self->priv->notebook = NULL;
 
@@ -592,10 +593,10 @@
 
 
 GtkWidget *
-chat_window_new_with_key (Ekiga::ServiceCore & _core,
-                          const std::string _key)
+chat_window_old_new_with_key (Ekiga::ServiceCore & _core,
+			      const std::string _key)
 {
-  ChatWindow *self = CHAT_WINDOW (chat_window_new (_core));
+  ChatWindowOld *self = CHAT_WINDOW_OLD (chat_window_old_new (_core));
 
   g_object_set (self, "key", _key.c_str (), NULL); 
 
@@ -604,15 +605,15 @@
 
 
 GtkWidget *
-chat_window_add_page (ChatWindow *chat_window,
-                      const std::string display_name,
-                      const std::string uri)
+chat_window_old_add_page (ChatWindowOld *chat_window_old,
+			  const std::string display_name,
+			  const std::string uri)
 {
-  ChatWindow *self = CHAT_WINDOW (chat_window);
+  ChatWindowOld *self = CHAT_WINDOW_OLD (chat_window_old);
   GtkWidget *page = NULL;
   int i = 0;
   
-  i = chat_window_get_page_index (self, uri);
+  i = chat_window_old_get_page_index (self, uri);
 
   if (i == -1) {
 
@@ -623,14 +624,14 @@
     gtk_notebook_set_tab_label_packing (GTK_NOTEBOOK (self->priv->notebook), 
                                         page, TRUE, TRUE, GTK_PACK_START);
 
-    i = chat_window_get_n_pages (self);
+    i = chat_window_old_get_n_pages (self);
     i--;
 
     g_signal_connect (page, "close-event",
-                      G_CALLBACK (close_event_cb), chat_window);
+                      G_CALLBACK (close_event_cb), chat_window_old);
   }
   else
-    page = chat_window_get_page (chat_window, uri, display_name);
+    page = chat_window_old_get_page (chat_window_old, uri, display_name);
 
   gtk_notebook_set_current_page (GTK_NOTEBOOK (self->priv->notebook), i);
 
@@ -643,16 +644,16 @@
 
 
 void
-chat_window_remove_page (ChatWindow *chat_window,
-                         const std::string uri)
+chat_window_old_remove_page (ChatWindowOld *chat_window_old,
+			     const std::string uri)
 {
-  ChatWindow *self = CHAT_WINDOW (chat_window);
+  ChatWindowOld *self = CHAT_WINDOW_OLD (chat_window_old);
 
   int i = 0;
   int n = 0;
 
-  i = chat_window_get_page_index (self, uri);
-  n = chat_window_get_n_pages (self);
+  i = chat_window_old_get_page_index (self, uri);
+  n = chat_window_old_get_n_pages (self);
 
   if (i > -1 && n > 1) 
     gtk_notebook_remove_page (GTK_NOTEBOOK (self->priv->notebook), i);
@@ -660,9 +661,9 @@
 
 
 int 
-chat_window_get_n_pages (ChatWindow *chat_window)
+chat_window_old_get_n_pages (ChatWindowOld *chat_window_old)
 {
-  ChatWindow *self = CHAT_WINDOW (chat_window);
+  ChatWindowOld *self = CHAT_WINDOW_OLD (chat_window_old);
 
   return gtk_notebook_get_n_pages (GTK_NOTEBOOK (self->priv->notebook));
 }

Copied: trunk/lib/engine/gui/gtk-frontend/chat-window-old.h (from r6434, /trunk/lib/engine/gui/gtk-frontend/chat-window.h)
==============================================================================
--- /trunk/lib/engine/gui/gtk-frontend/chat-window.h	(original)
+++ trunk/lib/engine/gui/gtk-frontend/chat-window-old.h	Thu Jul 10 07:45:33 2008
@@ -47,36 +47,36 @@
 G_BEGIN_DECLS
 
 
-typedef struct _ChatWindow ChatWindow;
-typedef struct _ChatWindowPrivate ChatWindowPrivate;
-typedef struct _ChatWindowClass ChatWindowClass;
+typedef struct _ChatWindowOld ChatWindowOld;
+typedef struct _ChatWindowOldPrivate ChatWindowOldPrivate;
+typedef struct _ChatWindowOldClass ChatWindowOldClass;
 
 
 /* GObject thingies */
-struct _ChatWindow
+struct _ChatWindowOld
 {
   GmWindow parent;
-  ChatWindowPrivate *priv;
+  ChatWindowOldPrivate *priv;
 };
 
-struct _ChatWindowClass
+struct _ChatWindowOldClass
 {
   GmWindowClass parent;
 };
 
-#define CHAT_WINDOW_TYPE (chat_window_get_type ())
+#define CHAT_WINDOW_OLD_TYPE (chat_window_old_get_type ())
 
-#define CHAT_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CHAT_WINDOW_TYPE, ChatWindow))
+#define CHAT_WINDOW_OLD(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CHAT_WINDOW_OLD_TYPE, ChatWindowOld))
 
-#define IS_CHAT_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CHAT_WINDOW_TYPE))
+#define IS_CHAT_WINDOW_OLD(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CHAT_WINDOW_OLD_TYPE))
 
-#define CHAT_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CHAT_WINDOW_TYPE, ChatWindowClass))
+#define CHAT_WINDOW_OLD_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CHAT_WINDOW_OLD_TYPE, ChatWindowOldClass))
 
-#define IS_CHAT_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CHAT_WINDOW_TYPE))
+#define IS_CHAT_WINDOW_OLD_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CHAT_WINDOW_OLD_TYPE))
 
-#define CHAT_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CHAT_WINDOW_TYPE, ChatWindowClass))
+#define CHAT_WINDOW_OLD_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CHAT_WINDOW_OLD_TYPE, ChatWindowOldClass))
 
-GType chat_window_get_type ();
+GType chat_window_old_get_type ();
 
 
 /* Public API */
@@ -86,7 +86,7 @@
  *                by the Ekiga::ServiceCore.
  * PRE          : The Ekiga::ServiceCore as argument.
  */
-GtkWidget *chat_window_new (Ekiga::ServiceCore & core);
+GtkWidget *chat_window_old_new (Ekiga::ServiceCore & core);
 
 
 /* DESCRIPTION  : /
@@ -97,36 +97,36 @@
  * PRE          : The Ekiga::ServiceCore as argument, the key where to store
  *                the position and size..
  */
-GtkWidget *chat_window_new_with_key (Ekiga::ServiceCore & _core,
-                                     const std::string _key);
+GtkWidget *chat_window_old_new_with_key (Ekiga::ServiceCore & _core,
+					 const std::string _key);
 
 
 /* DESCRIPTION  : /
- * BEHAVIOR     : Add and return a new page in the ChatWindow. That page 
+ * BEHAVIOR     : Add and return a new page in the ChatWindowOld. That page 
  *                concerns the given display_name and uri. If possible, 
  *                the presence status of the Ekiga::Presentity is displayed.
  * PRE          : A pointer to the ChatWindow. The Ekiga::ServiceCore as 
  *                argument. A non-empty URI.
  */
-GtkWidget *chat_window_add_page (ChatWindow *chat_window,
-                                 const std::string display_name,
-                                 const std::string uri);
+GtkWidget *chat_window_old_add_page (ChatWindowOld *chat_window,
+				     const std::string display_name,
+				     const std::string uri);
 
 
 /* DESCRIPTION  : /
  * BEHAVIOR     : Remove the ChatWindowPage with the given URI from the 
- *                ChatWindow.
- * PRE          : A pointer to the ChatWindow. A non-empty URI.
+ *                ChatWindowOld.
+ * PRE          : A pointer to the ChatWindowOld. A non-empty URI.
  */
-void chat_window_remove_page (ChatWindow *chat_window,
-                              const std::string uri);
+void chat_window_old_remove_page (ChatWindowOld *chat_window,
+				  const std::string uri);
 
 
 /* DESCRIPTION  : /
- * BEHAVIOR     : Return the number of pages in the ChatWindow.
- * PRE          : A pointer to the ChatWindow.
+ * BEHAVIOR     : Return the number of pages in the ChatWindowOld.
+ * PRE          : A pointer to the ChatWindowOld.
  */
-int chat_window_get_n_pages (ChatWindow *chat_window);
+int chat_window_old_get_n_pages (ChatWindowOld *chat_window);
 
 G_END_DECLS
 

Modified: trunk/lib/engine/gui/gtk-frontend/chat-window.cpp
==============================================================================
--- trunk/lib/engine/gui/gtk-frontend/chat-window.cpp	(original)
+++ trunk/lib/engine/gui/gtk-frontend/chat-window.cpp	Thu Jul 10 07:45:33 2008
@@ -1,6 +1,6 @@
 
 /* Ekiga -- A VoIP and Video-Conferencing application
- * Copyright (C) 2000-2007 Damien Sandras
+ * Copyright (C) 2000-2008 Damien Sandras
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -27,239 +27,133 @@
 
 
 /*
- *                         chat_window.cpp  -  description
- *                         -------------------------------
- *   begin                : Wed Jan 23 2002
- *   copyright            : (C) 2000-2007 by Damien Sandras
- *   description          : This file contains functions to build the chat
- *                          window. 
+ *                         chat-window.h  -  description
+ *                         -----------------------------
+ *   begin                : written in july 2008 by Julien Puydt
+ *   copyright            : (C) 2008 by Julien Puydt
+ *   description          : Implementation of a window to display chats
  *
  */
 
-
-#include "config.h"
-
 #include "chat-window.h"
-#include "chat-window-page.h"
-
-#include "chat-core.h"
+#include "gtk-chat-view.h"
 
-#include "gmconf.h"
-#include "gmtexttagaddon.h"
-#include "gmtextbufferaddon.h"
-#include "gmtextviewaddon.h"
-#include "gmstockicons.h"
-
-#include <gdk/gdkkeysyms.h>
-#include <sigc++/sigc++.h>
-#include <vector>
-#include <iostream>
-
-/*
- * The ChatWindow
- */
-struct _ChatWindowPrivate 
+struct _ChatWindowPrivate
 {
-  _ChatWindowPrivate (Ekiga::ServiceCore & _core) : core (_core) { }
+  _ChatWindowPrivate (Ekiga::ChatCore& core_): core(core_)
+  {}
 
-  GtkWidget *notebook;
+  Ekiga::ChatCore& core;
+  sigc::connection dialect_added_connection;
+  std::list<sigc::connection> simple_chat_added_connections;
 
-  std::vector<sigc::connection> connections;
-  Ekiga::ServiceCore & core;
+  GtkWidget* notebook;
 };
 
-enum { CHAT_WINDOW_KEY = 1 };
-
-static GObjectClass *parent_class = NULL;
-
-/*
- * NOTICE:
- *
- * Added support for new signal "message-event". Objects like the
- * StatusIcon can listen to that signal in order to know if there
- * are unread messages. The signal is emitted when there is a change
- * in the number of unread messages, like when a message is received
- * or the focus changes.
- */
-
-/*
- * GTK+ Callbacks
- */
-
-/* DESCRIPTION  : Called when the close-event signal is emitted. It happens
- *                when the user clicks on the cross in a ChatWindowPage.
- * BEHAVIOR     : Remove the corresponding ChatWindowPage from the ChatWindow.
- * PRE          : The ChatWindowPage passed as first parameter,
- *                The ChatWindow as second argument.
- */
-static void close_event_cb (GtkWidget *widget,
-                            gpointer data);
-
-
-/* DESCRIPTION  : Called when the ChatWindow is hidden.
- * BEHAVIOR     : Remove all ChatWindowPages.
- * PRE          : The ChatWindow as second argument.
- */
-static void hide_event_cb (GtkWidget *widget,
-                           gpointer data);
-
-
-/* DESCRIPTION  : Called when the ChatWindow is being focused.
- * BEHAVIOR     : Emits the "message-event" signal with the new number
- *                of unseen messages as the current ChatWindowPage does
- *                not have unseen messages anymore. 
- * PRE          : The ChatWindow as last argument.
- */
-static void focus_in_changed_cb (GtkWidget *window,
-                                 GdkEventFocus *focus,
-                                 gpointer data);
-
-
-/* DESCRIPTION  : Called when a new ChatWindowPage is being focused.
- * BEHAVIOR     : Emits the "message-event" signal with the new number
- *                of unseen messages as the current ChatWindowPage does
- *                not have unseen messages anymore. 
- * PRE          : The ChatWindow as last argument.
- */
-static void conversation_changed_cb (GtkNotebook *notebook,
-                                     GtkNotebookPage *_page,
-                                     gint n,
-                                     gpointer data);
-
-
-/*
- * Engine Callbacks
- */
-
-/* DESCRIPTION  : Called when an IM has been received.
- * BEHAVIOR     : Display the received IM in a newly created or existing
- *                ChatWindowPage.
- *                Emits the "message-event" signal with the new number
- *                of unseen messages if the ChatWindowPage is not currently
- *                displayed.
- * PRE          : The ChatWindow as last argument.
- */
-static void on_im_received_cb (const Ekiga::ChatManager & manager,
-                               const std::string & display_name,
-                               const std::string & from, 
-                               const std::string & message,
-                               gpointer data);
+static GObjectClass* parent_class = NULL;
 
+/* signal callbacks (declarations) */
 
-/* DESCRIPTION  : Called when an IM has been sent.
- * BEHAVIOR     : Display the sent IM in a newly created or existing
- *                ChatWindowPage.
- * PRE          : The ChatWindow as last argument.
- */
-static void on_im_sent_cb (const Ekiga::ChatManager & manager,
-                           const std::string & to,
-                           const std::string & message,
-                           gpointer data);
+static bool on_dialect_added (ChatWindow* self,
+			      Ekiga::Dialect& dialect);
+static bool on_simple_chat_added (ChatWindow* self,
+				  bool on_user_request,
+				  Ekiga::SimpleChat &chat);
 
+/* signal callbacks (implementations) */
 
-/* DESCRIPTION  : Called when an IM could not be sent.
- * BEHAVIOR     : Display the error message in a newly created or existing
- *                ChatWindowPage.
- * PRE          : The ChatWindow as last argument.
- */
-static void on_im_failed_cb (const Ekiga::ChatManager & manager,
-                             const std::string & to,
-                             const std::string & reason,
-                             gpointer data);
+static bool
+on_dialect_added (ChatWindow* self,
+		  Ekiga::Dialect& dialect)
+{
+  self->priv->simple_chat_added_connections.push_front (dialect.simple_chat_added.connect (sigc::hide_return (sigc::bind<0> (sigc::ptr_fun (on_simple_chat_added), self))));
 
+  dialect.visit_simple_chats (sigc::bind<0> (sigc::bind<0> (sigc::ptr_fun (on_simple_chat_added), self), false));
 
-/*
- * Local GUI functions
- */
+  return true;
+}
 
-/* DESCRIPTION  : /
- * BEHAVIOR     : Return the ChatWindowPage position in the ChatWindowPage
- *                corresponding to the given uri.
- * PRE          : The ChatWindow as first argument, non-empty URI string.
- */
-static gint chat_window_get_page_index (ChatWindow *chat_window,
-                                        const std::string uri);
+static bool
+on_simple_chat_added (ChatWindow* self,
+		      bool on_user_request,
+		      Ekiga::SimpleChat &chat)
+{
+  GtkWidget* page = NULL;
+  GtkWidget* label = NULL;
+  gint num;
 
+  page = gtk_chat_view_new (chat);
+  label = gtk_label_new (chat.get_title ().c_str ());
 
-/* DESCRIPTION  : /
- * BEHAVIOR     : Return the ChatWindowPage GtkWidget in the ChatWindow
- *                corresponding to the given uri.
- * PRE          : The ChatWindow as first argument, non-empty URI string.
- */
-static GtkWidget *chat_window_get_page (ChatWindow *chat_window,
-                                        const std::string uri,
-                                        const std::string display_name = "");
+  num = gtk_notebook_append_page (GTK_NOTEBOOK (self->priv->notebook),
+				  page, label);
+  gtk_widget_show_all (page);
 
+  if (on_user_request) {
 
-/* DESCRIPTION  : /
- * BEHAVIOR     : Return the number of unread messages.
- * PRE          : The ChatWindow as argument.
- */
-static int chat_window_get_unread_messages (ChatWindow *chat_window);
+    gtk_notebook_set_current_page (GTK_NOTEBOOK (self->priv->notebook), num);
+    gtk_widget_show (GTK_WIDGET (self));
+    gtk_window_present (GTK_WINDOW (self));
+  }
 
+  return true;
+}
 
-/* 
- * GObject stuff
- */
+/* GObject code */
 static void
-chat_window_dispose (GObject *obj)
+chat_window_dispose (GObject* obj)
 {
-  ChatWindow *self = NULL;
+  ChatWindow* self = NULL;
 
   self = CHAT_WINDOW (obj);
 
-  self->priv->notebook = NULL;
-
   parent_class->dispose (obj);
 }
 
-
 static void
-chat_window_finalize (GObject *obj)
+chat_window_finalize (GObject* obj)
 {
-  ChatWindow *self = NULL;
+  ChatWindow* self = NULL;
 
   self = CHAT_WINDOW (obj);
 
-  for (std::vector<sigc::connection>::iterator iter = self->priv->connections.begin () ;
-       iter != self->priv->connections.end ();
-       iter++)
+  self->priv->dialect_added_connection.disconnect ();
+
+  for (std::list<sigc::connection>::iterator iter
+	 = self->priv->simple_chat_added_connections.begin ();
+       iter != self->priv->simple_chat_added_connections.end ();
+       ++iter)
     iter->disconnect ();
 
-  g_free (self->priv);
+  delete self->priv;
+  self->priv = NULL;
 
   parent_class->finalize (obj);
 }
 
-
 static void
 chat_window_class_init (gpointer g_class,
 			G_GNUC_UNUSED gpointer class_data)
 {
-  GObjectClass *gobject_class = NULL;
+  GObjectClass* gobject_class = NULL;
 
-  static gboolean initialised = false;
+  parent_class = (GObjectClass*) g_type_class_peek_parent (g_class);
 
-  parent_class = (GObjectClass *) g_type_class_peek_parent (g_class);
-  g_type_class_add_private (g_class, sizeof (ChatWindowPrivate));
-
-  gobject_class = (GObjectClass *) g_class;
+  gobject_class = (GObjectClass*) g_class;
   gobject_class->dispose = chat_window_dispose;
   gobject_class->finalize = chat_window_finalize;
+}
 
-  if (!initialised) {
+static void
+chat_window_init (GTypeInstance* instance,
+		  G_GNUC_UNUSED gpointer g_class)
+{
+  ChatWindow* self = NULL;
 
-    g_signal_new ("message-event",
-                  G_OBJECT_CLASS_TYPE (g_class),
-                  G_SIGNAL_RUN_FIRST,
-                  0, NULL, NULL,
-                  g_cclosure_marshal_VOID__UINT,
-                  G_TYPE_NONE,
-                  1, G_TYPE_UINT, NULL);
-    initialised = true;
-  }
-}
+  self = (ChatWindow*)instance;
 
+  // hmmm...
+}
 
 GType
 chat_window_get_type ()
@@ -277,392 +171,38 @@
       NULL,
       sizeof (ChatWindow),
       0,
-      NULL,
+      chat_window_init,
       NULL
     };
 
     result = g_type_register_static (GM_WINDOW_TYPE,
-				     "ChatWindowType",
+				     "ChatWindow",
 				     &info, (GTypeFlags) 0);
   }
 
   return result;
 }
 
+/* public api */
 
-/* 
- * GTK+ Callbacks
- */
-
-static void
-close_event_cb (G_GNUC_UNUSED GtkWidget *widget,
-                gpointer data)
-{
-  ChatWindow *self = CHAT_WINDOW (data);
-  std::string uri;
-
-  int i = 0;
-  int n = 0;
-
-  uri = chat_window_page_get_uri (CHAT_WINDOW_PAGE (widget));
-  n = gtk_notebook_get_n_pages (GTK_NOTEBOOK (self->priv->notebook));
-  
-  if (i != -1 && n > 1)
-    chat_window_remove_page (CHAT_WINDOW (data), uri);
-}
-
-
-static void
-hide_event_cb (G_GNUC_UNUSED GtkWidget *widget,
-               gpointer data)
-{
-  ChatWindow *self = CHAT_WINDOW (data);
-
-  int n = 0;
-
-  n = gtk_notebook_get_n_pages (GTK_NOTEBOOK (self->priv->notebook));
-
-  for (int i = 0 ; i < n ; i++) {
-    gtk_notebook_remove_page (GTK_NOTEBOOK (self->priv->notebook), 0);
-  }
-}
-
-
-static void
-focus_in_changed_cb (G_GNUC_UNUSED GtkWidget *window,
-                     G_GNUC_UNUSED GdkEventFocus *focus,
-                     gpointer data)
-{
-  ChatWindow *self = CHAT_WINDOW (data);
-  ChatWindowPage *page = NULL;
-
-  int n = 0;
-
-  n = gtk_notebook_get_current_page (GTK_NOTEBOOK (self->priv->notebook));
-  page = CHAT_WINDOW_PAGE (gtk_notebook_get_nth_page (GTK_NOTEBOOK (self->priv->notebook), n));
-
-  chat_window_page_set_unread_messages (page, 0);
-  g_signal_emit_by_name (CHAT_WINDOW (data), "message-event", 
-                         chat_window_get_unread_messages (CHAT_WINDOW (data)));
-}
-
-
-static void
-conversation_changed_cb (GtkNotebook *notebook,
-                         G_GNUC_UNUSED GtkNotebookPage *_page,
-                         gint n,
-                         gpointer data)
-{
-  ChatWindowPage *page = NULL;
-
-  page = CHAT_WINDOW_PAGE (gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook), n));
-
-  chat_window_page_set_unread_messages (page, 0);
-  g_signal_emit_by_name (CHAT_WINDOW (data), "message-event", 
-                         chat_window_get_unread_messages (CHAT_WINDOW (data)));
-}
-
-
-/*
- * Engine Callbacks
- */
-
-static void
-on_im_received_cb (const Ekiga::ChatManager & /*manager*/,
-                   const std::string & display_name,
-                   const std::string & from, 
-                   const std::string & message,
-                   gpointer data)
+GtkWidget*
+chat_window_new (Ekiga::ChatCore& core,
+		 const std::string key)
 {
-  GtkWidget *page = chat_window_get_page (CHAT_WINDOW (data), from, display_name);
-  GtkWidget *notebook_page = NULL;
+  ChatWindow* result = NULL;
 
-  int n = 0;
-  int current_unread_messages = 0;
-  gboolean visible = false;
+  result = (ChatWindow*)g_object_new (CHAT_WINDOW_TYPE,
+				     "key", key.c_str (),
+				     NULL);
 
-  if (page == NULL)
-    page = chat_window_add_page (CHAT_WINDOW (data), display_name, from);
+  result->priv = new ChatWindowPrivate (core);
 
-  chat_window_page_add_message (CHAT_WINDOW_PAGE (page), display_name, from, message, false);
+  result->priv->notebook = gtk_notebook_new ();
+  gtk_container_add (GTK_CONTAINER (result), result->priv->notebook);
+  gtk_widget_show (result->priv->notebook);
 
-  g_object_get (CHAT_WINDOW (data), "visible", &visible, NULL);
-  n = gtk_notebook_get_current_page (GTK_NOTEBOOK (CHAT_WINDOW (data)->priv->notebook));
-  notebook_page = gtk_notebook_get_nth_page (GTK_NOTEBOOK (CHAT_WINDOW (data)->priv->notebook), n);
-
-  if (!visible || page != notebook_page) {
-
-    current_unread_messages = chat_window_page_get_unread_messages (CHAT_WINDOW_PAGE (page));
-    current_unread_messages++;
-  }
-  else {
-   
-    current_unread_messages = 0;
-  }
-
-  chat_window_page_set_unread_messages (CHAT_WINDOW_PAGE (page), current_unread_messages);
-  g_signal_emit_by_name (CHAT_WINDOW (data), "message-event", current_unread_messages);
-}
-
-
-static void
-on_im_sent_cb (const Ekiga::ChatManager & /*manager*/,
-               const std::string & to,
-               const std::string & message,
-               gpointer data)
-{
-  GtkWidget *page = chat_window_get_page (CHAT_WINDOW (data), to);
-
-  if (page == NULL)
-    page = chat_window_add_page (CHAT_WINDOW (data), "", to);
-
-  chat_window_page_add_message (CHAT_WINDOW_PAGE (page), "", to, message, true);
-}
-
-
-static void
-on_im_failed_cb (const Ekiga::ChatManager & /*manager*/,
-                 const std::string & to,
-                 const std::string & reason,
-                 gpointer data)
-{
-  GtkWidget *page = chat_window_get_page (CHAT_WINDOW (data), to);
-
-  if (page == NULL)
-    page = chat_window_add_page (CHAT_WINDOW (data), "", to);
-
-  chat_window_page_add_error (CHAT_WINDOW_PAGE (page), to, reason);
-}
-
-
-/* 
- * Local GUI functions
- */
-
-static gint
-chat_window_get_page_index (ChatWindow *chat_window,
-                            const std::string uri)
-{
-  ChatWindow *self = CHAT_WINDOW (chat_window);
-  GtkWidget *page = NULL;
-
-  bool found = false;
-  int i = 0;
-  int n = 0;
-  
-  n = chat_window_get_n_pages (self);
-
-  while (i < n && !found) {
-
-    page = gtk_notebook_get_nth_page (GTK_NOTEBOOK (self->priv->notebook), i);
-
-    if (page != NULL && chat_window_page_get_uri (CHAT_WINDOW_PAGE (page)) == uri) 
-      return i;
-
-    i++;
-  }
-
-  return -1;
-}
-
-
-static GtkWidget *
-chat_window_get_page (ChatWindow *chat_window,
-                      const std::string uri,
-                      const std::string display_name)
-{
-  ChatWindow *self = CHAT_WINDOW (chat_window);
-  GtkWidget *page = NULL;
-
-  std::string host1, host2;
-  bool found = false;
-  int i = 0;
-  int n = 0;
-  
-  n = chat_window_get_n_pages (self);
-
-  while (i < n && !found) {
-
-    std::size_t pos;
-
-    page = gtk_notebook_get_nth_page (GTK_NOTEBOOK (self->priv->notebook), i);
-    host1 = chat_window_page_get_uri (CHAT_WINDOW_PAGE (page));
-    host2 = uri;
-
-    pos = host1.find_first_of (':');
-    if (pos == 4)
-      host1 = host1.substr (pos+1);
-    pos = host2.find_first_of (':');
-    if (pos == 4)
-      host1 = host1.substr (pos+1);
-    pos = host1.find_last_of ('@');
-    if (pos != std::string::npos)
-      host1 = host1.substr (pos+1);
-    pos = host2.find_last_of ('@');
-    if (pos != std::string::npos)
-      host2 = host2.substr (pos+1);
-
-    if (page != NULL && chat_window_page_get_uri (CHAT_WINDOW_PAGE (page)) == uri) 
-      return page;
-
-    if (page != NULL && host1 != host2 && chat_window_page_get_display_name (CHAT_WINDOW_PAGE (page)) == display_name)
-      return page;
-
-    i++;
-  }
-
-  return NULL;
-}
-
-
-static int 
-chat_window_get_unread_messages (ChatWindow *chat_window)
-{
-  ChatWindow *self = CHAT_WINDOW (chat_window);
-
-  GtkWidget *page = NULL;
-
-  int unread = 0;
-  int i = 0;
-  int n = 0;
-  
-  n = chat_window_get_n_pages (self);
-
-  while (i < n) {
-
-    page = gtk_notebook_get_nth_page (GTK_NOTEBOOK (self->priv->notebook), i);
-
-    if (page != NULL)
-      unread += chat_window_page_get_unread_messages (CHAT_WINDOW_PAGE (page));
-
-    i++;
-  }
-
-  return unread;
-}
-
-
-/* Public API */
-GtkWidget *
-chat_window_new (Ekiga::ServiceCore & core)
-{
-  ChatWindow *self = NULL;
-
-  Ekiga::ChatCore *chat_core = NULL;
-
-  sigc::connection conn;
-
-  self = CHAT_WINDOW (g_object_new (CHAT_WINDOW_TYPE, NULL));
-  self->priv = new ChatWindowPrivate (core);
-
-  self->priv->notebook = NULL;
-
-  /* The window */
-  gtk_window_set_title (GTK_WINDOW (self), _("Chat Window"));
-  gtk_window_set_position (GTK_WINDOW (self), GTK_WIN_POS_CENTER);
-  g_object_set (G_OBJECT (self), "focus-on-map", true, NULL);
-
-  /* Build the window */
-  self->priv->notebook = gtk_notebook_new ();
-  gtk_notebook_set_scrollable (GTK_NOTEBOOK (self->priv->notebook), TRUE);
-  gtk_container_add (GTK_CONTAINER (self), self->priv->notebook);
-
-  /* Engine signals */
-  chat_core = dynamic_cast<Ekiga::ChatCore *> (core.get ("chat-core"));
-  conn = chat_core->im_received.connect (sigc::bind (sigc::ptr_fun (on_im_received_cb), self));
-  self->priv->connections.push_back (conn);
-  conn = chat_core->im_sent.connect (sigc::bind (sigc::ptr_fun (on_im_sent_cb), self));
-  self->priv->connections.push_back (conn);
-  conn = chat_core->im_failed.connect (sigc::bind (sigc::ptr_fun (on_im_failed_cb), self));
-  self->priv->connections.push_back (conn);
-
-  g_signal_connect (G_OBJECT (self), "hide",
-		    G_CALLBACK (hide_event_cb), self);
-
-  g_signal_connect (G_OBJECT (self), "focus_in_event",
-                    G_CALLBACK (focus_in_changed_cb), self);
-
-  g_signal_connect (G_OBJECT (self->priv->notebook), "switch_page",
-                    G_CALLBACK (conversation_changed_cb), self);
-
-  gtk_widget_show_all (GTK_WIDGET (self->priv->notebook));
-
-  return GTK_WIDGET (self);
-}
-
-
-GtkWidget *
-chat_window_new_with_key (Ekiga::ServiceCore & _core,
-                          const std::string _key)
-{
-  ChatWindow *self = CHAT_WINDOW (chat_window_new (_core));
-
-  g_object_set (self, "key", _key.c_str (), NULL); 
-
-  return GTK_WIDGET (self);
-}
-
-
-GtkWidget *
-chat_window_add_page (ChatWindow *chat_window,
-                      const std::string display_name,
-                      const std::string uri)
-{
-  ChatWindow *self = CHAT_WINDOW (chat_window);
-  GtkWidget *page = NULL;
-  int i = 0;
-  
-  i = chat_window_get_page_index (self, uri);
-
-  if (i == -1) {
-
-    page = chat_window_page_new (self->priv->core, display_name, uri);
-    gtk_notebook_append_page (GTK_NOTEBOOK (self->priv->notebook), 
-                              page, 
-                              chat_window_page_get_label (CHAT_WINDOW_PAGE (page)));
-    gtk_notebook_set_tab_label_packing (GTK_NOTEBOOK (self->priv->notebook), 
-                                        page, TRUE, TRUE, GTK_PACK_START);
-
-    i = chat_window_get_n_pages (self);
-    i--;
-
-    g_signal_connect (page, "close-event",
-                      G_CALLBACK (close_event_cb), chat_window);
-  }
-  else
-    page = chat_window_get_page (chat_window, uri, display_name);
-
-  gtk_notebook_set_current_page (GTK_NOTEBOOK (self->priv->notebook), i);
-
-  chat_window_page_grab_focus (CHAT_WINDOW_PAGE (page));
-
-  gtk_widget_show_all (GTK_WIDGET (page));
-
-  return page;
-}
-
-
-void
-chat_window_remove_page (ChatWindow *chat_window,
-                         const std::string uri)
-{
-  ChatWindow *self = CHAT_WINDOW (chat_window);
-
-  int i = 0;
-  int n = 0;
-
-  i = chat_window_get_page_index (self, uri);
-  n = chat_window_get_n_pages (self);
-
-  if (i > -1 && n > 1) 
-    gtk_notebook_remove_page (GTK_NOTEBOOK (self->priv->notebook), i);
-}
-
-
-int 
-chat_window_get_n_pages (ChatWindow *chat_window)
-{
-  ChatWindow *self = CHAT_WINDOW (chat_window);
+  result->priv->dialect_added_connection = core.dialect_added.connect (sigc::hide_return(sigc::bind<0>(sigc::ptr_fun (on_dialect_added), result)));
+  core.visit_dialects (sigc::bind<0>(sigc::ptr_fun (on_dialect_added), result));
 
-  return gtk_notebook_get_n_pages (GTK_NOTEBOOK (self->priv->notebook));
+  return (GtkWidget*)result;
 }

Modified: trunk/lib/engine/gui/gtk-frontend/chat-window.h
==============================================================================
--- trunk/lib/engine/gui/gtk-frontend/chat-window.h	(original)
+++ trunk/lib/engine/gui/gtk-frontend/chat-window.h	Thu Jul 10 07:45:33 2008
@@ -1,6 +1,6 @@
 
 /* Ekiga -- A VoIP and Video-Conferencing application
- * Copyright (C) 2000-2007 Damien Sandras
+ * Copyright (C) 2000-2008 Damien Sandras
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -27,31 +27,30 @@
 
 
 /*
- *                         chat_window.h  -  description
+ *                         chat-window.h  -  description
  *                         -----------------------------
- *   begin                : Wed Jan 23 2002
- *   copyright            : (C) 2000-2007 by Damien Sandras
- *   description          : This file contains functions to build the chat
- *                          window.
+ *   begin                : written in july 2008 by Julien Puydt
+ *   copyright            : (C) 2008 by Julien Puydt
+ *   description          : Declaration of a window to display chats
  *
  */
 
 
-#ifndef __CHAT_WINDOW_H
-#define __CHAT_WINDOW_H
-
-#include "services.h"
+#ifndef __CHAT_WINDOW_H__
+#define __CHAT_WINDOW_H__
 
 #include "gmwindow.h"
+#include "chat-core.h"
 
-G_BEGIN_DECLS
+/* FIXME: remove the following line to begin killing the old code */
+#include "chat-window-old.h"
 
+G_BEGIN_DECLS
 
 typedef struct _ChatWindow ChatWindow;
 typedef struct _ChatWindowPrivate ChatWindowPrivate;
 typedef struct _ChatWindowClass ChatWindowClass;
 
-
 /* GObject thingies */
 struct _ChatWindow
 {
@@ -81,53 +80,9 @@
 
 /* Public API */
 
-/* DESCRIPTION  : /
- * BEHAVIOR     : Crate a new ChatWindow and listen for signals emitted
- *                by the Ekiga::ServiceCore.
- * PRE          : The Ekiga::ServiceCore as argument.
- */
-GtkWidget *chat_window_new (Ekiga::ServiceCore & core);
-
-
-/* DESCRIPTION  : /
- * BEHAVIOR     : Crate a new ChatWindow and listen for signals emitted
- *                by the Ekiga::ServiceCore. The difference with the previous
- *                function is that it also restaures the position and size when
- *                being shown/hidden.
- * PRE          : The Ekiga::ServiceCore as argument, the key where to store
- *                the position and size..
- */
-GtkWidget *chat_window_new_with_key (Ekiga::ServiceCore & _core,
-                                     const std::string _key);
-
-
-/* DESCRIPTION  : /
- * BEHAVIOR     : Add and return a new page in the ChatWindow. That page 
- *                concerns the given display_name and uri. If possible, 
- *                the presence status of the Ekiga::Presentity is displayed.
- * PRE          : A pointer to the ChatWindow. The Ekiga::ServiceCore as 
- *                argument. A non-empty URI.
- */
-GtkWidget *chat_window_add_page (ChatWindow *chat_window,
-                                 const std::string display_name,
-                                 const std::string uri);
-
-
-/* DESCRIPTION  : /
- * BEHAVIOR     : Remove the ChatWindowPage with the given URI from the 
- *                ChatWindow.
- * PRE          : A pointer to the ChatWindow. A non-empty URI.
- */
-void chat_window_remove_page (ChatWindow *chat_window,
-                              const std::string uri);
-
-
-/* DESCRIPTION  : /
- * BEHAVIOR     : Return the number of pages in the ChatWindow.
- * PRE          : A pointer to the ChatWindow.
- */
-int chat_window_get_n_pages (ChatWindow *chat_window);
+GtkWidget* chat_window_new (Ekiga::ChatCore& core,
+			    const std::string key);
 
 G_END_DECLS
 
-#endif /* __CHAT_WINDOW_H */
+#endif

Added: trunk/lib/engine/gui/gtk-frontend/gtk-chat-view.cpp
==============================================================================
--- (empty file)
+++ trunk/lib/engine/gui/gtk-frontend/gtk-chat-view.cpp	Thu Jul 10 07:45:33 2008
@@ -0,0 +1,336 @@
+
+/* Ekiga -- A VoIP and Video-Conferencing application
+ * Copyright (C) 2000-2008 Damien Sandras
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ *
+ * Ekiga is licensed under the GPL license and as a special exception,
+ * you have permission to link or otherwise combine this program with the
+ * programs OPAL, OpenH323 and PWLIB, and distribute the combination,
+ * without applying the requirements of the GNU GPL to the OPAL, OpenH323
+ * and PWLIB programs, as long as you do follow the requirements of the
+ * GNU GPL for all the rest of the software thus combined.
+ */
+
+
+/*
+ *                        gtk-chat-view.cpp  -  description
+ *                         --------------------------------
+ *   begin                : written in july 2008 by Julien Puydt
+ *   copyright            : (C) 2008 by Julien Puydt
+ *   description          : Implementation of a Chat "view" (it has controls)
+ *
+ */
+
+#include "gtk-chat-view.h"
+
+class GtkChatViewHelper;
+
+struct _GtkChatViewPrivate
+{
+  Ekiga::Chat *chat;
+  sigc::connection connection;
+  GtkChatViewHelper *helper;
+
+  /* we contain those, so no need to unref them */
+  GtkWidget *text_view;
+  GtkWidget *entry;
+};
+
+enum {
+  GTK_CHAT_VIEW_PROP_CHAT = 1
+};
+
+static GObjectClass *parent_class = NULL;
+
+/* declaration of internal api */
+
+static void gtk_chat_view_add_notice (GtkChatView *self,
+				      const gchar *txt);
+
+static void gtk_chat_view_add_message (GtkChatView *self,
+				       const gchar *from,
+				       const gchar *txt);
+
+/* declaration of the helping observer */
+class GtkChatViewHelper: public Ekiga::ChatObserver
+{
+public:
+  GtkChatViewHelper (GtkChatView *view_): view(view_)
+  {}
+
+  ~GtkChatViewHelper ()
+  {}
+
+  void message (const std::string from,
+		const std::string msg)
+  { gtk_chat_view_add_message (view, from.c_str (), msg.c_str ()); }
+
+  void notice (const std::string msg)
+  { gtk_chat_view_add_notice (view, msg.c_str ()); }
+
+private:
+  GtkChatView *view;
+};
+
+
+/* declaration of callbacks */
+static void on_entry_activated (GtkWidget *entry,
+				gpointer data);
+
+static void on_chat_removed (GtkChatView *self);
+
+/* implementation of internal api */
+
+static void
+gtk_chat_view_add_notice (GtkChatView *self,
+			  const gchar *txt)
+{
+  gchar *str = NULL;
+  GtkTextBuffer *buffer = NULL;
+  GtkTextIter iter;
+
+  str = g_strdup_printf ("NOTICE: %s\n", txt);
+  buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (self->priv->text_view));
+  gtk_text_buffer_get_end_iter (buffer, &iter);
+  gtk_text_buffer_insert (buffer, &iter, str, -1);
+  g_free (str);
+}
+
+static void
+gtk_chat_view_add_message (GtkChatView *self,
+			   const gchar *from,
+			   const gchar *txt)
+{
+  gchar *str = NULL;
+  GtkTextBuffer *buffer = NULL;
+  GtkTextIter iter;
+
+  str = g_strdup_printf ("%s says: %s\n", from, txt);
+  buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (self->priv->text_view));
+  gtk_text_buffer_get_end_iter (buffer, &iter);
+  gtk_text_buffer_insert (buffer, &iter, str, -1);
+  g_free (str);
+}
+
+/* implementation of callbacks */
+
+static void
+on_chat_removed (GtkChatView *self)
+{
+  gtk_widget_hide (self->priv->entry);
+}
+
+static void
+on_entry_activated (GtkWidget *entry,
+		    gpointer data)
+{
+  GtkChatView *self = NULL;
+  const gchar *text = NULL;
+
+  self = GTK_CHAT_VIEW (data);
+
+  text = gtk_entry_get_text (GTK_ENTRY (entry));
+
+  if (text != NULL && !g_str_equal (text, "")) {
+
+    if (self->priv->chat->send_message (text))
+      gtk_entry_set_text (GTK_ENTRY (entry), "");
+  }
+}
+
+/* GObject code */
+
+static void
+gtk_chat_view_dispose (GObject *obj)
+{
+  GtkChatView *self = NULL;
+
+  self = (GtkChatView *)obj;
+
+  parent_class->dispose (obj);
+}
+
+static void
+gtk_chat_view_finalize (GObject *obj)
+{
+  GtkChatView *self = NULL;
+
+  self = (GtkChatView *)obj;
+
+  if (self->priv->chat) {
+
+    self->priv->connection.disconnect ();
+    if (self->priv->helper) {
+      self->priv->chat->disconnect (*(self->priv->helper));
+      delete self->priv->helper;
+      self->priv->helper = NULL;
+    }
+    self->priv->chat = NULL;
+  }
+
+  parent_class->finalize (obj);
+}
+
+static void
+gtk_chat_view_get_property (GObject *obj,
+			    guint prop_id,
+			    GValue *value,
+			    GParamSpec *spec)
+{
+  GtkChatView *self = NULL;
+
+  self = (GtkChatView *)obj;
+
+  switch (prop_id) {
+
+  case GTK_CHAT_VIEW_PROP_CHAT:
+    g_value_set_pointer (value, self->priv->chat);
+    break;
+
+  default:
+    G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, spec);
+    break;
+  }
+}
+
+static void
+gtk_chat_view_set_property (GObject *obj,
+			    guint prop_id,
+			    const GValue *value,
+			    GParamSpec *spec)
+{
+  GtkChatView *self = NULL;
+  gpointer ptr = NULL;
+
+  self = (GtkChatView *)obj;
+
+  switch (prop_id) {
+
+  case GTK_CHAT_VIEW_PROP_CHAT:
+    ptr = g_value_get_pointer (value);
+    self->priv->chat = (Ekiga::Chat *)ptr;
+    self->priv->connection = self->priv->chat->removed.connect (sigc::bind (sigc::ptr_fun (on_chat_removed), self));
+    self->priv->helper = new GtkChatViewHelper (self);
+    self->priv->chat->connect (*(self->priv->helper));
+    break;
+
+  default:
+    G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, spec);
+    break;
+  }
+}
+
+static void
+gtk_chat_view_class_init (gpointer g_class,
+			  gpointer class_data)
+{
+  GObjectClass *gobject_class = NULL;
+  GParamSpec *spec = NULL;
+
+  (void)class_data; /* -Wextra */
+
+  parent_class = (GObjectClass *)g_type_class_peek_parent (g_class);
+
+  g_type_class_add_private (g_class, sizeof (GtkChatViewPrivate));
+
+  gobject_class = (GObjectClass *) g_class;
+  gobject_class->dispose = gtk_chat_view_dispose;
+  gobject_class->finalize = gtk_chat_view_finalize;
+  gobject_class->get_property = gtk_chat_view_get_property;
+  gobject_class->set_property = gtk_chat_view_set_property;
+
+  spec = g_param_spec_pointer ("chat",
+			       "displayed chat",
+			       "Displayed chat",
+			       (GParamFlags)(G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
+  g_object_class_install_property (gobject_class,
+				   GTK_CHAT_VIEW_PROP_CHAT,
+				   spec);
+}
+
+static void
+gtk_chat_view_init (GTypeInstance *instance,
+		    gpointer g_class)
+{
+  GtkChatView *self = NULL;
+
+  (void)g_class; /* -Wextra */
+
+  self = (GtkChatView *)instance;
+
+  self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
+					    GTK_TYPE_CHAT_VIEW,
+					    GtkChatViewPrivate);
+  self->priv->chat = NULL;
+
+  self->priv->text_view = gtk_text_view_new ();
+  gtk_widget_show (self->priv->text_view);
+  gtk_box_pack_start (GTK_BOX (self), self->priv->text_view,
+		      TRUE, TRUE, 2);
+
+  self->priv->entry = gtk_entry_new ();
+  gtk_widget_show (self->priv->entry);
+  gtk_box_pack_end (GTK_BOX (self), self->priv->entry,
+		    FALSE, TRUE, 2);
+  g_signal_connect (self->priv->entry, "activate",
+		    G_CALLBACK (on_entry_activated), self);
+}
+
+
+GType
+gtk_chat_view_get_type ()
+{
+  static GType result = 0;
+
+  if (result == 0) {
+
+    static const GTypeInfo info = {
+      sizeof (GtkChatViewClass),
+      NULL,
+      NULL,
+      gtk_chat_view_class_init,
+      NULL,
+      NULL,
+      sizeof (GtkChatView),
+      0,
+      gtk_chat_view_init,
+      NULL
+    };
+
+    result = g_type_register_static (GTK_TYPE_VBOX,
+				     "GtkChatView",
+				     &info, (GTypeFlags) 0);
+  }
+
+  return result;
+}
+
+/* public api */
+
+GtkWidget *
+gtk_chat_view_new (Ekiga::Chat &chat)
+{
+  return (GtkWidget *)g_object_new (GTK_TYPE_CHAT_VIEW,
+				    "chat", &chat,
+				    NULL);
+}
+
+const std::string
+gtk_chat_view_get_title (GtkChatView* chat)
+{
+  return chat->priv->chat->get_title ();
+}

Added: trunk/lib/engine/gui/gtk-frontend/gtk-chat-view.h
==============================================================================
--- (empty file)
+++ trunk/lib/engine/gui/gtk-frontend/gtk-chat-view.h	Thu Jul 10 07:45:33 2008
@@ -0,0 +1,81 @@
+
+/* Ekiga -- A VoIP and Video-Conferencing application
+ * Copyright (C) 2000-2008 Damien Sandras
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ *
+ * Ekiga is licensed under the GPL license and as a special exception,
+ * you have permission to link or otherwise combine this program with the
+ * programs OPAL, OpenH323 and PWLIB, and distribute the combination,
+ * without applying the requirements of the GNU GPL to the OPAL, OpenH323
+ * and PWLIB programs, as long as you do follow the requirements of the
+ * GNU GPL for all the rest of the software thus combined.
+ */
+
+
+/*
+ *                        gtk-chat-view.h  -  description
+ *                         --------------------------------
+ *   begin                : written in july 2008 by Julien Puydt
+ *   copyright            : (C) 2008 by Julien Puydt
+ *   description          : Declaration of a Chat "view" (it has controls)
+ *
+ */
+
+#ifndef __GTK_CHAT_VIEW_H__
+#define __GTK_CHAT_VIEW_H__
+
+#include <gtk/gtk.h>
+
+#include "chat.h"
+
+G_BEGIN_DECLS
+
+typedef struct _GtkChatView GtkChatView;
+typedef struct _GtkChatViewClass GtkChatViewClass;
+typedef struct _GtkChatViewPrivate GtkChatViewPrivate;
+
+struct _GtkChatView
+{
+  GtkVBox parent;
+
+  GtkChatViewPrivate *priv;
+};
+
+struct _GtkChatViewClass
+{
+  GtkVBoxClass parent;
+};
+
+/* public api */
+GtkWidget *gtk_chat_view_new (Ekiga::Chat &chat);
+
+const std::string gtk_chat_view_get_title (GtkChatView* chat);
+
+/* GObject thingies */
+
+#define GTK_TYPE_CHAT_VIEW (gtk_chat_view_get_type ())
+#define GTK_CHAT_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_CHAT_VIEW, GtkChatView))
+#define GTK_CHAT_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_CHAT_VIEW, GtkChatViewClass))
+#define GTK_IS_CHAT_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_CHAT_VIEW))
+#define GTK_IS_CHAT_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_CHAT_VIEW))
+#define GTK_CHAT_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_CHAT_VIEW, GtkChatViewClass))
+
+GType gtk_chat_view_get_type ();
+
+
+G_END_DECLS
+#endif

Modified: trunk/lib/engine/gui/gtk-frontend/gtk-frontend.cpp
==============================================================================
--- trunk/lib/engine/gui/gtk-frontend/gtk-frontend.cpp	(original)
+++ trunk/lib/engine/gui/gtk-frontend/gtk-frontend.cpp	Thu Jul 10 07:45:33 2008
@@ -78,7 +78,10 @@
   addressbook_window =
     addressbook_window_new_with_key (*contact_core, "/apps/ekiga/general/user_interface/addressbook_window");
   chat_window =
-    chat_window_new_with_key (core, "/apps/ekiga/general/user_interface/chat_window");
+    chat_window_new (*chat_core,
+		     "/apps/ekiga/general/user_interface/chat_window");
+  chat_window_old =
+    chat_window_old_new_with_key (core, "/apps/ekiga/general/user_interface/chat_window");
 
   conn = chat_core->new_chat.connect (sigc::mem_fun (this, &GtkFrontend::on_new_chat));
   connections.push_back (conn);
@@ -94,6 +97,7 @@
 
   gtk_widget_destroy (addressbook_window);
   gtk_widget_destroy (chat_window);
+  gtk_widget_destroy (chat_window_old);
 }
 
 
@@ -123,7 +127,7 @@
 
 const GtkWidget *GtkFrontend::get_chat_window () const
 {
-  return chat_window;
+  return chat_window_old;
 }
 
 
@@ -138,8 +142,8 @@
                                const std::string & name,
                                const std::string & uri)
 {
-  chat_window_add_page (CHAT_WINDOW (chat_window), name, uri);
-  gtk_widget_show_all (GTK_WIDGET (chat_window));
+  chat_window_old_add_page (CHAT_WINDOW_OLD (chat_window_old), name, uri);
+  gtk_widget_show_all (GTK_WIDGET (chat_window_old));
 }
 
 

Modified: trunk/lib/engine/gui/gtk-frontend/gtk-frontend.h
==============================================================================
--- trunk/lib/engine/gui/gtk-frontend/gtk-frontend.h	(original)
+++ trunk/lib/engine/gui/gtk-frontend/gtk-frontend.h	Thu Jul 10 07:45:33 2008
@@ -77,6 +77,7 @@
   GtkWidget *roster_view;
   GtkWidget *call_history_view;
   GtkWidget *chat_window;
+  GtkWidget *chat_window_old;
 
   std::vector<sigc::connection> connections;
 };

Modified: trunk/src/Makefile.am
==============================================================================
--- trunk/src/Makefile.am	(original)
+++ trunk/src/Makefile.am	Thu Jul 10 07:45:33 2008
@@ -98,6 +98,12 @@
 	endpoints/h323.cpp			\
 	endpoints/pcss.h			\
 	endpoints/pcss.cpp			\
+	endpoints/sip-presentity.h		\
+	endpoints/sip-presentity.cpp		\
+	endpoints/sip-chat-simple.h		\
+	endpoints/sip-chat-simple.cpp		\
+	endpoints/sip-dialect.h			\
+	endpoints/sip-dialect.cpp		\
 	endpoints/sip.h				\
 	endpoints/sip.cpp			\
 	endpoints/opal-account.h		\

Added: trunk/src/endpoints/sip-chat-simple.cpp
==============================================================================
--- (empty file)
+++ trunk/src/endpoints/sip-chat-simple.cpp	Thu Jul 10 07:45:33 2008
@@ -0,0 +1,126 @@
+
+/* Ekiga -- A VoIP and Video-Conferencing application
+ * Copyright (C) 2000-2008 Damien Sandras
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ *
+ * Ekiga is licensed under the GPL license and as a special exception,
+ * you have permission to link or otherwise combine this program with the
+ * programs OPAL, OpenH323 and PWLIB, and distribute the combination,
+ * without applying the requirements of the GNU GPL to the OPAL, OpenH323
+ * and PWLIB programs, as long as you do follow the requirements of the
+ * GNU GPL for all the rest of the software thus combined.
+ */
+
+
+/*
+ *                         sip-chat-simple.cpp  -  description
+ *                         --------------------------------
+ *   begin                : written in july 2008 by Julien Puydt
+ *   copyright            : (C) 2008 by Julien Puydt
+ *   description          : Implementation of a simple chat in SIP
+ *
+ */
+
+#include "sip-chat-simple.h"
+
+SIP::SimpleChat::SimpleChat (Ekiga::ServiceCore& core,
+			     std::string name,
+			     std::string uri,
+			     sigc::slot<bool, std::string> sender_)
+  : sender(sender_)
+{
+  presentity = new Presentity (core, name, uri);
+}
+
+SIP::SimpleChat::~SimpleChat ()
+{
+  presentity->removed.emit ();
+  delete presentity;
+}
+
+const std::string
+SIP::SimpleChat::get_uri () const
+{
+  return presentity->get_uri ();
+}
+
+const std::string
+SIP::SimpleChat::get_title () const
+{
+  return presentity->get_name ();
+}
+
+void
+SIP::SimpleChat::connect (Ekiga::ChatObserver& observer)
+{
+  observers.push_front (&observer);
+}
+
+void
+SIP::SimpleChat::disconnect (Ekiga::ChatObserver& observer)
+{
+  observers.remove (&observer);
+
+  if (observers.empty ())
+    removed.emit ();
+}
+
+bool
+SIP::SimpleChat::send_message (const std::string msg)
+{
+  bool result;
+
+  result = sender (msg);
+  for (std::list<Ekiga::ChatObserver*>::iterator iter
+	 = observers.begin ();
+       iter != observers.end ();
+       ++iter)
+    (*iter)->message ("FIXME(Self)", msg);
+  return result;
+}
+
+void
+SIP::SimpleChat::receive_message (const std::string msg)
+{
+  for (std::list<Ekiga::ChatObserver*>::iterator iter
+	 = observers.begin ();
+       iter != observers.end ();
+       ++iter)
+    (*iter)->message (presentity->get_name (), msg);
+}
+
+void
+SIP::SimpleChat::receive_notice (const std::string msg)
+{
+  for (std::list<Ekiga::ChatObserver*>::iterator iter
+	 = observers.begin ();
+       iter != observers.end ();
+       ++iter)
+    (*iter)->notice (msg);
+}
+
+Ekiga::Presentity&
+SIP::SimpleChat::get_presentity () const
+{
+  return *presentity;
+}
+
+bool
+SIP::SimpleChat::populate_menu (Ekiga::MenuBuilder& /*builder*/)
+{
+  return false;
+}

Added: trunk/src/endpoints/sip-chat-simple.h
==============================================================================
--- (empty file)
+++ trunk/src/endpoints/sip-chat-simple.h	Thu Jul 10 07:45:33 2008
@@ -0,0 +1,82 @@
+
+/* Ekiga -- A VoIP and Video-Conferencing application
+ * Copyright (C) 2000-2008 Damien Sandras
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ *
+ * Ekiga is licensed under the GPL license and as a special exception,
+ * you have permission to link or otherwise combine this program with the
+ * programs OPAL, OpenH323 and PWLIB, and distribute the combination,
+ * without applying the requirements of the GNU GPL to the OPAL, OpenH323
+ * and PWLIB programs, as long as you do follow the requirements of the
+ * GNU GPL for all the rest of the software thus combined.
+ */
+
+
+/*
+ *                         sip-chat-simple.h  -  description
+ *                         --------------------------------
+ *   begin                : written in july 2008 by Julien Puydt
+ *   copyright            : (C) 2008 by Julien Puydt
+ *   description          : Interface of a simple chat in SIP
+ *
+ */
+
+#ifndef __SIP_CHAT_SIMPLE_H__
+#define __SIP_CHAT_SIMPLE_H__
+
+#include "chat-simple.h"
+#include "sip-presentity.h"
+
+namespace SIP
+{
+  class SimpleChat: public Ekiga::SimpleChat
+  {
+  public:
+    SimpleChat (Ekiga::ServiceCore& core,
+		std::string name,
+		std::string uri,
+		sigc::slot<bool, std::string> sender_);
+
+    ~SimpleChat ();
+
+    const std::string get_uri () const;
+
+    const std::string get_title () const;
+
+    void connect (Ekiga::ChatObserver& observer);
+
+    void disconnect (Ekiga::ChatObserver& observer);
+
+    bool send_message (const std::string msg);
+
+    void receive_message (const std::string msg);
+
+    void receive_notice (const std::string msg);
+
+    Ekiga::Presentity &get_presentity () const;
+
+    bool populate_menu (Ekiga::MenuBuilder& builder);
+
+  private:
+
+    sigc::slot<bool, std::string> sender;
+    std::list<Ekiga::ChatObserver*> observers;
+    Presentity *presentity;
+  };
+};
+
+#endif

Added: trunk/src/endpoints/sip-dialect.cpp
==============================================================================
--- (empty file)
+++ trunk/src/endpoints/sip-dialect.cpp	Thu Jul 10 07:45:33 2008
@@ -0,0 +1,119 @@
+
+/* Ekiga -- A VoIP and Video-Conferencing application
+ * Copyright (C) 2000-2008 Damien Sandras
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ *
+ * Ekiga is licensed under the GPL license and as a special exception,
+ * you have permission to link or otherwise combine this program with the
+ * programs OPAL, OpenH323 and PWLIB, and distribute the combination,
+ * without applying the requirements of the GNU GPL to the OPAL, OpenH323
+ * and PWLIB programs, as long as you do follow the requirements of the
+ * GNU GPL for all the rest of the software thus combined.
+ */
+
+
+/*
+ *                         sip-dialect.cpp  -  description
+ *                         --------------------------------
+ *   begin                : written in july 2008 by Julien Puydt
+ *   copyright            : (C) 2008 by Julien Puydt
+ *   description          : Implementation of the SIP dialect
+ *
+ */
+
+#include "config.h"
+
+#include "sip-dialect.h"
+
+SIP::Dialect::Dialect (Ekiga::ServiceCore& core_,
+		       sigc::slot<bool, std::string, std::string> sender_)
+  : core(core_), sender(sender_)
+{
+  Ekiga::PresenceCore *presence_core = NULL;
+
+  presence_core =
+    dynamic_cast<Ekiga::PresenceCore *> (core.get ("presence-core"));
+
+  presence_core->add_presentity_decorator (*this);
+}
+
+SIP::Dialect::~Dialect ()
+{
+}
+
+void
+SIP::Dialect::push_message (const std::string uri,
+			    const std::string name,
+			    const std::string msg)
+{
+  SimpleChat *chat = NULL;
+
+  chat = open_chat_with (uri, name, false);
+
+  chat->receive_message (msg);
+}
+
+void
+SIP::Dialect::push_notice (const std::string uri,
+			   const std::string name,
+			   const std::string msg)
+{
+  SimpleChat *chat = NULL;
+
+  chat = open_chat_with (uri, name, false);
+
+  chat->receive_notice (msg);
+}
+
+bool
+SIP::Dialect::populate_menu (Ekiga::MenuBuilder& /*builder*/)
+{
+  return false;
+}
+
+bool
+SIP::Dialect::populate_menu (const std::string uri,
+			     Ekiga::MenuBuilder &builder)
+{
+  std::string action = _("Message");
+
+  builder.add_action ("message", action, sigc::hide_return (sigc::bind (sigc::mem_fun (this, &SIP::Dialect::open_chat_with), uri, "FIXME", true)));
+
+  return true;
+}
+
+SIP::SimpleChat*
+SIP::Dialect::open_chat_with (std::string uri,
+			      std::string name,
+			      bool user_request)
+{
+  SimpleChat *result = NULL;
+
+  for (simple_iterator iter = simple_begin ();
+       iter != simple_end ();
+       ++iter)
+    if (iter->get_uri () == uri)
+      result = &*iter;
+
+  if (result == NULL) {
+
+    result = new SimpleChat (core, name, uri, sigc::bind<0>(sender, uri));
+    add_simple_chat (user_request, result);
+  }
+
+  return result;
+}

Added: trunk/src/endpoints/sip-dialect.h
==============================================================================
--- (empty file)
+++ trunk/src/endpoints/sip-dialect.h	Thu Jul 10 07:45:33 2008
@@ -0,0 +1,81 @@
+
+/* Ekiga -- A VoIP and Video-Conferencing application
+ * Copyright (C) 2000-2008 Damien Sandras
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ *
+ * Ekiga is licensed under the GPL license and as a special exception,
+ * you have permission to link or otherwise combine this program with the
+ * programs OPAL, OpenH323 and PWLIB, and distribute the combination,
+ * without applying the requirements of the GNU GPL to the OPAL, OpenH323
+ * and PWLIB programs, as long as you do follow the requirements of the
+ * GNU GPL for all the rest of the software thus combined.
+ */
+
+
+/*
+ *                         sip-dialect.h  -  description
+ *                         --------------------------------
+ *   begin                : written in july 2008 by Julien Puydt
+ *   copyright            : (C) 2008 by Julien Puydt
+ *   description          : Interface of the SIP dialect
+ *
+ */
+
+#ifndef __SIP_DIALECT_H__
+#define __SIP_DIALECT_H__
+
+#include "dialect-impl.h"
+#include "sip-chat-simple.h"
+
+namespace SIP
+{
+  class Dialect:
+    public Ekiga::DialectImpl<SimpleChat>,
+    public Ekiga::PresentityDecorator
+  {
+  public:
+    Dialect (Ekiga::ServiceCore& core_,
+	     /* the strings are : uri then msg */
+	     sigc::slot<bool, std::string, std::string> sender_);
+
+    ~Dialect ();
+
+    void push_message (const std::string uri,
+		       const std::string name,
+		       const std::string msg);
+
+    void push_notice (const std::string uri,
+		      const std::string name,
+		      const std::string msg);
+
+    bool populate_menu (Ekiga::MenuBuilder& builder);
+
+    bool populate_menu (const std::string uri,
+			Ekiga::MenuBuilder &builder);
+
+  private:
+    Ekiga::ServiceCore& core;
+    /* the strings are : uri then msg */
+    sigc::slot<bool, std::string, std::string> sender;
+
+    SimpleChat* open_chat_with (std::string uri,
+				std::string name,
+				bool user_request);
+  };
+};
+
+#endif

Added: trunk/src/endpoints/sip-presentity.cpp
==============================================================================
--- (empty file)
+++ trunk/src/endpoints/sip-presentity.cpp	Thu Jul 10 07:45:33 2008
@@ -0,0 +1,111 @@
+
+/*
+ * Ekiga -- A VoIP and Video-Conferencing application
+ * Copyright (C) 2000-2008 Damien Sandras
+
+ * This program is free software; you can  redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version. This program is distributed in the hope
+ * that it will be useful, but WITHOUT ANY WARRANTY; without even the
+ * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Ekiga is licensed under the GPL license and as a special exception, you
+ * have permission to link or otherwise combine this program with the
+ * programs OPAL, OpenH323 and PWLIB, and distribute the combination, without
+ * applying the requirements of the GNU GPL to the OPAL, OpenH323 and PWLIB
+ * programs, as long as you do follow the requirements of the GNU GPL for all
+ * the rest of the software thus combined.
+ */
+
+
+/*
+ *                         sip-presentity.cpp  -  description
+ *                         ------------------------------------------
+ *   begin                : written in 2008 by Julien Puydt
+ *   copyright            : (c) 2008 by Julien Puydt
+ *   description          : implementation of a presentity for SIP chats
+ *
+ */
+
+#include "sip-presentity.h"
+
+SIP::Presentity::Presentity (Ekiga::ServiceCore &_core,
+			     std::string name_,
+			     std::string uri_)
+  : core(_core), name(name_), uri(uri_)
+{
+  presence_core = dynamic_cast<Ekiga::PresenceCore*>(core.get ("presence-core"));
+
+  presence_core->fetch_presence (uri);
+}
+
+SIP::Presentity::~Presentity ()
+{
+  presence_core->unfetch_presence (uri);
+}
+
+const std::string
+SIP::Presentity::get_name () const
+{
+  return name;
+}
+
+const std::string
+SIP::Presentity::get_presence () const
+{
+  return presence;
+}
+
+const std::string
+SIP::Presentity::get_status () const
+{
+  return status;
+}
+
+const std::string
+SIP::Presentity::get_avatar () const
+{
+  return avatar;
+}
+
+const std::set<std::string>
+SIP::Presentity::get_groups () const
+{
+  return groups;
+}
+
+const std::string
+SIP::Presentity::get_uri () const
+{
+  return uri;
+}
+
+void
+SIP::Presentity::set_presence (const std::string _presence)
+{
+  presence = _presence;
+  updated.emit ();
+}
+
+void
+SIP::Presentity::set_status (const std::string _status)
+{
+  status = _status;
+  updated.emit ();
+}
+
+bool
+SIP::Presentity::populate_menu (Ekiga::MenuBuilder &builder)
+{
+  bool result = false;
+
+  result = presence_core->populate_presentity_menu (uri, builder);
+
+  return result;
+}

Added: trunk/src/endpoints/sip-presentity.h
==============================================================================
--- (empty file)
+++ trunk/src/endpoints/sip-presentity.h	Thu Jul 10 07:45:33 2008
@@ -0,0 +1,119 @@
+
+/*
+ * Ekiga -- A VoIP and Video-Conferencing application
+ * Copyright (C) 2000-2008 Damien Sandras
+
+ * This program is free software; you can  redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version. This program is distributed in the hope
+ * that it will be useful, but WITHOUT ANY WARRANTY; without even the
+ * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Ekiga is licensed under the GPL license and as a special exception, you
+ * have permission to link or otherwise combine this program with the
+ * programs OPAL, OpenH323 and PWLIB, and distribute the combination, without
+ * applying the requirements of the GNU GPL to the OPAL, OpenH323 and PWLIB
+ * programs, as long as you do follow the requirements of the GNU GPL for all
+ * the rest of the software thus combined.
+ */
+
+
+/*
+ *                         sip-presentity.h  -  description
+ *                         ------------------------------------------
+ *   begin                : written in 2008 by Julien Puydt
+ *   copyright            : (c) 2008 by Julien Puydt
+ *   description          : declaration of a presentity for SIP chats
+ *
+ */
+
+
+
+#ifndef __SIP_PRESENTITY_H__
+#define __SIP_PRESENTITY_H__
+
+#include "form.h"
+#include "presence-core.h"
+#include "presentity.h"
+
+namespace SIP
+{
+
+/**
+ * @addtogroup presence
+ * @internal
+ * @{
+ */
+
+  /**
+   * This class implements an Ekiga::Presentity.
+   */
+  class Presentity: public Ekiga::Presentity
+  {
+  public:
+
+    /**
+     * Constructor and destructor
+     */
+    Presentity (Ekiga::ServiceCore& _core,
+		std::string name_,
+		std::string uri_);
+
+    ~Presentity ();
+
+
+    /**
+     * Getters for the presentity
+     */
+    const std::string get_name () const;
+
+    const std::string get_presence () const;
+
+    const std::string get_status () const;
+
+    const std::string get_avatar () const;
+
+    const std::set<std::string> get_groups () const;
+
+    const std::string get_uri () const;
+
+
+    /**
+     * Two setters for use by the SIP::Dialect
+     */
+    void set_presence (const std::string _presence);
+
+    void set_status (const std::string _status);
+
+
+    /** Populates the given Ekiga::MenuBuilder with the actions.
+     * @param: A MenuBuilder.
+     */
+    bool populate_menu (Ekiga::MenuBuilder& builder);
+
+  private:
+
+    Ekiga::ServiceCore &core;
+    Ekiga::PresenceCore *presence_core;
+
+    std::string name;
+    std::string uri;
+    std::string presence;
+    std::string status;
+    std::string avatar;
+
+    std::set<std::string> groups;
+  };
+
+/**
+ * @}
+ */
+};
+
+#endif

Modified: trunk/src/endpoints/sip.cpp
==============================================================================
--- trunk/src/endpoints/sip.cpp	(original)
+++ trunk/src/endpoints/sip.cpp	Thu Jul 10 07:45:33 2008
@@ -47,6 +47,7 @@
 
 #include "presence-core.h"
 #include "account-core.h"
+#include "chat-core.h"
 #include "personal-details.h"
 #include "opal-account.h"
 
@@ -122,10 +123,16 @@
                       runtime (*(dynamic_cast<Ekiga::Runtime *> (core.get ("runtime")))),
                       account_core (*(dynamic_cast<Ekiga::AccountCore *> (core.get ("account-core"))))
 {
+  Ekiga::ChatCore* chat_core;
+
   protocol_name = "sip";
   uri_prefix = "sip:";
   listen_port = _listen_port;
 
+  chat_core = dynamic_cast<Ekiga::ChatCore *> (core.get ("chat-core"));
+  dialect = new SIP::Dialect (core, sigc::mem_fun (this, &CallProtocolManager::send_message));
+  chat_core->add_dialect (*dialect);
+
   /* Timeouts */
   SetAckTimeout (PTimeInterval (0, 32));
   SetPduCleanUpTimeout (PTimeInterval (0, 1));
@@ -152,6 +159,10 @@
     publish (*details);
 }
 
+CallProtocolManager::~CallProtocolManager ()
+{
+  delete dialect;
+}
 
 bool CallProtocolManager::populate_menu (Ekiga::Contact &contact,
                                          Ekiga::MenuBuilder &builder)
@@ -199,7 +210,7 @@
        iter != uris.end ();
        iter++) {
 
-    std::string action = _("Message");
+    std::string action = _("Message (old)");
 
     if (!iter->first.empty ())
       action = action + " [" + iter->first + "]";
@@ -844,6 +855,7 @@
     std::string message_uri = (const char *) uri.AsString ();
     std::string _message = (const char *) pdu.GetEntityBody ();
 
+    dialect->push_message (message_uri, display_name, _message);
     runtime.run_in_main (sigc::bind (im_received.make_slot (), display_name, message_uri, _message));
   }
 }
@@ -855,6 +867,9 @@
   SIPURL to = messageUrl;
   to.Sanitise (SIPURL::ToURI);
   std::string uri = (const char *) to.AsString ();
+  std::string display_name = (const char *) to.GetDisplayName ();
+  
+  dialect->push_notice (uri, display_name, _("Could not send message"));
   runtime.run_in_main (sigc::bind (im_failed.make_slot (), uri, 
                                    _("Could not send message")));
 }

Modified: trunk/src/endpoints/sip.h
==============================================================================
--- trunk/src/endpoints/sip.h	(original)
+++ trunk/src/endpoints/sip.h	Thu Jul 10 07:45:33 2008
@@ -51,6 +51,7 @@
 #include "call-protocol-manager.h"
 #include "account-core.h"
 #include "opal-account.h"
+#include "sip-dialect.h"
 
 
 PDICTIONARY (msgDict, PString, PString);
@@ -75,6 +76,7 @@
 
       CallProtocolManager (CallManager &ep, Ekiga::ServiceCore & core, unsigned listen_port);
 
+      ~CallProtocolManager ();
 
       /* ContactDecorator and PresentityDecorator */
       bool populate_menu (Ekiga::Contact &contact,
@@ -186,6 +188,8 @@
       std::string outbound_proxy;
 
       unsigned listen_port;
+
+      SIP::Dialect *dialect;
     };
   };
 };



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