ekiga r6297 - in trunk: . lib/engine lib/engine/chat lib/engine/chat/skel



Author: dsandras
Date: Wed May 21 19:54:08 2008
New Revision: 6297
URL: http://svn.gnome.org/viewvc/ekiga?rev=6297&view=rev

Log:
Added a basic ChatCore faster than I expected.


Added:
   trunk/lib/engine/chat/
   trunk/lib/engine/chat/Makefile.am
   trunk/lib/engine/chat/skel/
   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
Modified:
   trunk/ChangeLog
   trunk/configure.ac
   trunk/lib/engine/Makefile.am

Modified: trunk/configure.ac
==============================================================================
--- trunk/configure.ac	(original)
+++ trunk/configure.ac	Wed May 21 19:54:08 2008
@@ -606,6 +606,8 @@
 lib/engine/addressbook/evolution/Makefile
 lib/engine/addressbook/ldap/Makefile
 lib/engine/addressbook/skel/Makefile
+lib/engine/chat/Makefile
+lib/engine/chat/skel/Makefile
 lib/engine/framework/Makefile
 lib/engine/presence/Makefile
 lib/engine/presence/avahi/Makefile

Modified: trunk/lib/engine/Makefile.am
==============================================================================
--- trunk/lib/engine/Makefile.am	(original)
+++ trunk/lib/engine/Makefile.am	Wed May 21 19:54:08 2008
@@ -1,4 +1,4 @@
-SUBDIRS = framework addressbook presence gui protocol videooutput videoinput audioinput audiooutput hal components
+SUBDIRS = framework addressbook presence gui protocol videooutput videoinput audioinput audiooutput hal components chat
 
 noinst_LTLIBRARIES = libekiga_engine.la
 
@@ -65,7 +65,8 @@
 libekiga_engine_la_LIBADD = \
 	$(top_builddir)/lib/engine/gui/gtk-core/libgmgtk-core.la 					\
 	$(top_builddir)/lib/engine/gui/gtk-frontend/libgmgtk-frontend.la 				\
-	$(top_builddir)/lib/engine/protocol/skel/libgmprotocol.la 					\
+	$(top_builddir)/lib/engine/chat/skel/libgmchat.la 						\
+	$(top_builddir)/lib/engine/protocol/skel/libgmprotocol.la	 				\
 	$(top_builddir)/lib/engine/framework/libgmframework.la 						\
 	$(top_builddir)/lib/engine/addressbook/skel/libgmaddressbook.la 				\
 	$(top_builddir)/lib/engine/addressbook/call-history/libcall-history.la 				\

Added: trunk/lib/engine/chat/Makefile.am
==============================================================================
--- (empty file)
+++ trunk/lib/engine/chat/Makefile.am	Wed May 21 19:54:08 2008
@@ -0,0 +1 @@
+SUBDIRS = skel

Added: trunk/lib/engine/chat/skel/Makefile.am
==============================================================================
--- (empty file)
+++ trunk/lib/engine/chat/skel/Makefile.am	Wed May 21 19:54:08 2008
@@ -0,0 +1,16 @@
+noinst_LTLIBRARIES = libgmchat.la
+
+chat_dir = $(top_srcdir)/lib/engine/chat/skel
+
+AM_CPPFLAGS = $(SIGC_CFLAGS) $(GLIB_CFLAGS)
+
+INCLUDES = \
+	-I$(top_srcdir)/lib/engine/include 		\
+	-I$(top_srcdir)/lib/engine/framework
+
+libgmchat_la_SOURCES = \
+	$(chat_dir)/chat-core.h			\
+	$(chat_dir)/chat-core.cpp		\
+	$(chat_dir)/chat-manager.h
+
+libgmchat_la_LDFLAGS = -export-dynamic -no-undefined $(SIGC_LIBS)

Added: trunk/lib/engine/chat/skel/chat-core.cpp
==============================================================================
--- (empty file)
+++ trunk/lib/engine/chat/skel/chat-core.cpp	Wed May 21 19:54:08 2008
@@ -0,0 +1,118 @@
+
+/*
+ * 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-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.
+ *
+ */
+
+#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 (); 
+}
+
+
+ChatCore::const_iterator ChatCore::end () const
+{
+  return managers.end (); 
+}
+
+
+bool ChatCore::send_message (const std::string & uri, 
+                             const std::string & message)
+{
+  for (ChatCore::iterator iter = managers.begin ();
+       iter != managers.end ();
+       iter++) {
+
+    if ((*iter)->send_message (uri, message))
+      return true;
+  }
+
+  return false;
+}
+
+
+void ChatCore::on_im_failed (const std::string & uri, const std::string & reason, ChatManager *manager)
+{
+  im_failed.emit (*manager, uri, reason);
+}
+
+
+void ChatCore::on_im_sent (const std::string & uri, const std::string & message, ChatManager *manager)
+{
+  im_sent.emit (*manager, uri, message);
+}
+
+
+void ChatCore::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);
+}
+
+
+void ChatCore::on_new_chat (const std::string & display_name, const std::string & uri, ChatManager *manager)
+{
+  new_chat.emit (*manager, display_name, uri);
+}

Added: trunk/lib/engine/chat/skel/chat-core.h
==============================================================================
--- (empty file)
+++ trunk/lib/engine/chat/skel/chat-core.h	Wed May 21 19:54:08 2008
@@ -0,0 +1,141 @@
+
+/*
+ * 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-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.
+ *
+ */
+
+#ifndef __CHAT_CORE_H__
+#define __CHAT_CORE_H__
+
+#include "services.h"
+
+#include <sigc++/sigc++.h>
+#include <set>
+#include <map>
+
+
+namespace Ekiga
+{
+
+/**
+ * @defgroup chats Chats and protocols
+ * @{
+ */
+
+  class ChatManager;
+
+  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 () {}
+
+
+      /*** Service Implementation ***/
+
+      /** 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 Core managing ChatManager objects"; }
+
+
+      /** Adds a ChatManager to the ChatCore service.
+       * @param The manager to be added.
+       */
+      void add_manager (ChatManager &manager);
+
+      /** Return iterator to beginning
+       * @return iterator to beginning
+       */
+      iterator begin ();
+      const_iterator begin () const;
+
+      /** Return iterator to end
+       * @return iterator to end 
+       */
+      iterator end ();
+      const_iterator end () const;
+
+      /** This signal is emitted when a Ekiga::ChatManager has been
+       * added to the ChatCore Service.
+       */
+      sigc::signal<void, ChatManager &> manager_added;
+
+
+      /*** Instant Messaging ***/ 
+
+      /** See chat-manager.h for API **/
+      bool send_message (const std::string & uri, 
+                         const std::string & message);
+
+      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;
+
+
+  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);
+
+      std::set<ChatManager *> managers;
+    };
+
+/**
+ * @}
+ */
+
+};
+
+
+#endif

Added: trunk/lib/engine/chat/skel/chat-manager.h
==============================================================================
--- (empty file)
+++ trunk/lib/engine/chat/skel/chat-manager.h	Wed May 21 19:54:08 2008
@@ -0,0 +1,110 @@
+
+/*
+ * 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-manager.h  -  description
+ *                         ------------------------------------------
+ *   begin                : written in 2008 by Damien Sandras 
+ *   copyright            : (c) 2008 by Damien Sandras
+ *   description          : Declaration of the interface of a chat manager
+ *                          implementation backend. A chat manager handles 
+ *                          chats.
+ *
+ */
+
+
+#ifndef __CHAT_MANAGER_H__
+#define __CHAT_MANAGER_H__
+
+#include "chat-core.h"
+
+
+namespace Ekiga
+{
+
+/**
+ * @addtogroup chats
+ * @{:
+ */
+
+  class ChatManager
+    {
+
+  public:
+
+      /* The constructor
+       */
+      ChatManager () {};
+
+      /* The destructor
+       */
+      virtual ~ChatManager () = 0;
+
+
+      /*                 
+       * CHAT MANAGEMENT 
+       */               
+
+      /** Send a message to the given uri
+       * @param: uri    : where to send the message
+       *         message: what to send to the remote peer
+       */
+      virtual bool send_message (const std::string & uri, 
+                                 const std::string & message) = 0;
+
+      /** This signal is emitted when the transmission of a message failed
+       * @param: uri    : where the message could not be sent
+       *         error  : a string describing the error that occured
+       */
+      sigc::signal<void, const std::string &, const std::string &> im_failed;
+
+      /** This signal is emitted when a message has been received
+       * @param: display_name: the display name of the sender
+       *         uri         : the uri of the sender
+       *         message     : the message sent by the sender
+       */
+      sigc::signal<void, const std::string &, const std::string &, const std::string &> im_received;
+
+      /** This signal is emitted when a message has been sent
+       * @param: uri    : where the message has been sent
+       *         message: the message that was sent
+       */
+      sigc::signal<void, const std::string &, const std::string &> im_sent;
+
+      /** This signal is emitted when a chat conversation should be initiated
+       * @param: uri            : the remote party
+       *         display_name   : the display name
+       */
+      sigc::signal<void, const std::string &, const std::string &> new_chat;
+    };
+
+/**
+ * @}
+ */
+
+};
+
+#endif



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