[ekiga] Added the Ekiga::FriendOrFoe base code in the engine
- From: Julien Puydt <jpuydt src gnome org>
- To: svn-commits-list gnome org
- Subject: [ekiga] Added the Ekiga::FriendOrFoe base code in the engine
- Date: Thu, 2 Jul 2009 13:26:14 +0000 (UTC)
commit 5bd14c9013e9948a46f363ac7d54998e91c54939
Author: Julien Puydt <jpuydt gnome org>
Date: Mon Jun 29 20:54:46 2009 +0200
Added the Ekiga::FriendOrFoe base code in the engine
configure.ac | 1 +
lib/engine/Makefile.am | 2 +
lib/engine/engine.cpp | 3 +
lib/engine/friend-or-foe/Makefile.am | 13 ++++
lib/engine/friend-or-foe/friend-or-foe.cpp | 26 ++++++++
lib/engine/friend-or-foe/friend-or-foe.h | 93 ++++++++++++++++++++++++++++
6 files changed, 138 insertions(+), 0 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index bb0076c..d4f94c3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -877,6 +877,7 @@ lib/engine/components/call-history/Makefile
lib/engine/components/ldap/Makefile
lib/engine/components/kab/Makefile
lib/engine/chat/Makefile
+lib/engine/friend-or-foe/Makefile
lib/engine/framework/Makefile
lib/engine/notification/Makefile
lib/engine/plugin/Makefile
diff --git a/lib/engine/Makefile.am b/lib/engine/Makefile.am
index ad61394..f94afea 100644
--- a/lib/engine/Makefile.am
+++ b/lib/engine/Makefile.am
@@ -17,6 +17,7 @@ INCLUDES = \
-I$(top_srcdir)/lib/engine/audioinput \
-I$(top_srcdir)/lib/engine/audiooutput \
-I$(top_srcdir)/lib/engine/addressbook \
+ -I$(top_srcdir)/lib/engine/friend-or-foe \
-I$(top_srcdir)/lib/engine/plugin \
-I$(top_srcdir)/lib/engine/presence \
-I$(top_srcdir)/lib/engine/protocol \
@@ -87,6 +88,7 @@ libekiga_engine_la_LIBADD = \
$(top_builddir)/lib/engine/protocol/libgmprotocol.la \
$(top_builddir)/lib/engine/framework/libgmframework.la \
$(top_builddir)/lib/engine/addressbook/libgmaddressbook.la \
+ $(top_builddir)/lib/engine/friend-or-foe/libgmfriendorfoe.la \
$(top_builddir)/lib/engine/components/call-history/libcall-history.la \
$(top_builddir)/lib/engine/account/libaccount.la \
$(top_builddir)/lib/engine/presence/libgmpresence.la \
diff --git a/lib/engine/engine.cpp b/lib/engine/engine.cpp
index 1d8123e..4ee148e 100644
--- a/lib/engine/engine.cpp
+++ b/lib/engine/engine.cpp
@@ -49,6 +49,7 @@
#include "contact-core.h"
#include "call-core.h"
#include "chat-core.h"
+#include "friend-or-foe.h"
#include "videooutput-core.h"
#include "videoinput-core.h"
#include "audioinput-core.h"
@@ -125,6 +126,7 @@ engine_init (int argc,
gmref_ptr<Ekiga::AudioOutputCore> audiooutput_core (new Ekiga::AudioOutputCore);
gmref_ptr<Ekiga::AudioInputCore> audioinput_core (new Ekiga::AudioInputCore(*audiooutput_core));
gmref_ptr<Ekiga::HalCore> hal_core (new Ekiga::HalCore);
+ gmref_ptr<Ekiga::FriendOrFoe> friend_or_foe (new Ekiga::FriendOrFoe);
/* The last item in the following list will be destroyed first. *
@@ -134,6 +136,7 @@ engine_init (int argc,
service_core->add (account_core);
service_core->add (contact_core);
service_core->add (chat_core);
+ service_core->add (friend_or_foe);
service_core->add (videoinput_core);
service_core->add (videooutput_core);
service_core->add (audioinput_core);
diff --git a/lib/engine/friend-or-foe/Makefile.am b/lib/engine/friend-or-foe/Makefile.am
new file mode 100644
index 0000000..538e1c2
--- /dev/null
+++ b/lib/engine/friend-or-foe/Makefile.am
@@ -0,0 +1,13 @@
+noinst_LTLIBRARIES = libgmfriendorfoe.la
+
+friend_or_foe_dir = $(top_srcdir)/lib/engine/friend-or-foe
+
+AM_CXXFLAGS = $(SIGC_CFLAGS) $(GLIB_CFLAGS)
+
+INCLUDES = -I$(top_srcdir)/lib/engine/framework
+
+libgmfriendorfoe_la_SOURCES = \
+ $(friend_or_foe_dir)/friend-or-foe.h \
+ $(friend_or_foe_dir)/friend-or-foe.cpp
+
+libgmaddressbook_la_LDFLAGS = -export-dynamic -no-undefined
\ No newline at end of file
diff --git a/lib/engine/friend-or-foe/friend-or-foe.cpp b/lib/engine/friend-or-foe/friend-or-foe.cpp
new file mode 100644
index 0000000..46d75c2
--- /dev/null
+++ b/lib/engine/friend-or-foe/friend-or-foe.cpp
@@ -0,0 +1,26 @@
+#include "friend-or-foe.h"
+
+Ekiga::FriendOrFoe::Identification
+Ekiga::FriendOrFoe::decide (const std::string domain,
+ const std::string token) const
+{
+ Identification answer = Unknown;
+ Identification iter_answer;
+
+ for (helpers_type::const_iterator iter = helpers.begin ();
+ iter != helpers.end ();
+ ++iter) {
+
+ iter_answer = (*iter)->decide (domain, token);
+ if (answer < iter_answer)
+ answer = iter_answer;
+ }
+
+ return answer;
+}
+
+void
+Ekiga::FriendOrFoe::add_helper (gmref_ptr<Ekiga::FriendOrFoe::FriendOrFoeHelper> helper)
+{
+ helpers.push_front (helper);
+}
diff --git a/lib/engine/friend-or-foe/friend-or-foe.h b/lib/engine/friend-or-foe/friend-or-foe.h
new file mode 100644
index 0000000..c03b754
--- /dev/null
+++ b/lib/engine/friend-or-foe/friend-or-foe.h
@@ -0,0 +1,93 @@
+
+/*
+ * Ekiga -- A VoIP and Video-Conferencing application
+ * Copyright (C) 2000-2009 Damien Sandras <dsandras seconix com>
+
+ * 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.
+ */
+
+
+/*
+ * friend-or-foe.h - description
+ * ------------------------------------------
+ * begin : written in 2009 by Julien Puydt
+ * copyright : (c) 2009 by Julien Puydt
+ * description : interface of the main IFF object
+ *
+ */
+
+#ifndef __FRIEND_OR_FOE_H__
+#define __FRIEND_OR_FOE_H__
+
+/* IFF stands for "Identification Friend or Foe" and is a military system
+ * used to determine if an aircraft is a friend or a foe.
+ *
+ * In ekiga, there's no aircraft in sight, and the question isn't that of
+ * shooting or not : the problem is to determine if an incoming call should
+ * be rejected, accepted... or if we ring to let the user decide.
+ *
+ * Since we want several pieces of code to be able to provide information,
+ * we add in a helper class, which the main Ekiga::FriendOrFoe object uses
+ * to determines its answer. And since we want to be extensible, the question
+ * depends on a domain : "call", "message", etc.
+ *
+ * The code which gets a determination by Ekiga::FriendOrFoe can of course do
+ * whatever it wants with the answer!
+ */
+
+#include "services.h"
+
+namespace Ekiga
+{
+ class FriendOrFoe: public Ekiga::Service
+ {
+ public:
+
+ /* beware of the order : we prefer erring on the side of safety */
+ typedef enum { Unknown, Foe, Neutral, Friend } Identification;
+
+ class FriendOrFoeHelper: public GmRefCounted
+ {
+ public:
+ virtual ~FriendOrFoeHelper () = 0;
+
+ virtual Identification decide (const std::string domain,
+ const std::string token) const = 0;
+ };
+
+ Identification decide (const std::string domain,
+ const std::string token) const;
+
+ void add_helper (gmref_ptr<FriendOrFoeHelper> helper);
+
+ /* this turns us into a service */
+ const std::string get_name () const
+ { return "friend-or-foe"; }
+
+ const std::string get_description () const
+ { return "\tObject helping determine if an incoming call is acceptable"; }
+
+ private:
+ typedef std::list<gmref_ptr<FriendOrFoeHelper> > helpers_type;
+ helpers_type helpers;
+ };
+};
+
+#endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]