[ekiga] Added a simple foe-list component



commit e0d04f49593731f73e5f3168fa19a38cd1b37fd4
Author: Julien Puydt <julien puydt laposte net>
Date:   Mon Jun 23 14:10:32 2014 +0200

    Added a simple foe-list component

 lib/Makefile.am                             |    8 +++
 lib/engine/components/foe-list/foe-list.cpp |   70 ++++++++++++++++++++++++++
 lib/engine/components/foe-list/foe-list.h   |   72 +++++++++++++++++++++++++++
 lib/engine/engine.cpp                       |    5 ++
 org.gnome.ekiga.gschema.xml.in.in           |    5 ++
 5 files changed, 160 insertions(+), 0 deletions(-)
---
diff --git a/lib/Makefile.am b/lib/Makefile.am
index c57d725..5c7a7a9 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -34,6 +34,7 @@ AM_CPPFLAGS = \
        -I$(top_srcdir)/lib/engine/videooutput \
        -I$(top_srcdir)/lib/engine/components/call-history \
        -I$(top_srcdir)/lib/engine/components/echo \
+       -I$(top_srcdir)/lib/engine/components/foe-list \
        -I$(top_srcdir)/lib/engine/components/gmconf-personal-details \
        -I$(top_srcdir)/lib/engine/components/hal-dbus \
        -I$(top_srcdir)/lib/engine/components/hal-gudev \
@@ -575,3 +576,10 @@ libekiga_la_SOURCES += \
        engine/components/clutter-gst-videooutput/videooutput-main-clutter-gst.h
 
 libekiga_la_LDFLAGS += $(CLUTTER_LIBS) $(CLUTTER_GTK_LIBS) $(CLUTTER_GST_LIBS)
+
+##
+#  Sources of the foe list component
+##
+libekiga_la_SOURCES += \
+       engine/components/foe-list/foe-list.h \
+       engine/components/foe-list/foe-list.cpp
diff --git a/lib/engine/components/foe-list/foe-list.cpp b/lib/engine/components/foe-list/foe-list.cpp
new file mode 100644
index 0000000..c3799fa
--- /dev/null
+++ b/lib/engine/components/foe-list/foe-list.cpp
@@ -0,0 +1,70 @@
+
+/*
+ * Ekiga -- A VoIP and Video-Conferencing application
+ * Copyright (C) 2000-2014 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.
+ */
+
+
+/*
+ *                         foe-list.h  -  description
+ *                         ------------------------------------------
+ *   begin                : written in 2014 by Julien Puydt
+ *   copyright            : (c) 2014 by Julien Puydt
+ *   description          : interface of a delegate
+ *
+ */
+
+#include "foe-list.h"
+
+#include "ekiga-settings.h"
+
+Ekiga::FoeList::FoeList()
+{
+}
+
+
+Ekiga::FoeList::~FoeList()
+{
+}
+
+Ekiga::FriendOrFoe::Identification
+Ekiga::FoeList::decide (const std::string /*domain*/,
+                       const std::string token) const
+{
+  boost::scoped_ptr<Ekiga::Settings> settings(new Ekiga::Settings (CONTACTS_SCHEMA));
+  std::list<std::string> foes = settings->get_string_list ("foe-list");
+  Ekiga::FriendOrFoe::Identification result = Ekiga::FriendOrFoe::Unknown;
+
+  if (std::find (foes.begin (), foes.end (), token) != foes.end ())
+    result = Ekiga::FriendOrFoe::Foe;
+
+  return result;
+}
+
+void
+Ekiga::FoeList::add_foe (const std::string token)
+{
+  boost::scoped_ptr<Ekiga::Settings> settings(new Ekiga::Settings (CONTACTS_SCHEMA));
+  std::list<std::string> foes = settings->get_string_list ("foe-list");
+  foes.push_back (token);
+  settings->set_string_list ("foe-list", foes);
+}
diff --git a/lib/engine/components/foe-list/foe-list.h b/lib/engine/components/foe-list/foe-list.h
new file mode 100644
index 0000000..9120ae8
--- /dev/null
+++ b/lib/engine/components/foe-list/foe-list.h
@@ -0,0 +1,72 @@
+
+/*
+ * Ekiga -- A VoIP and Video-Conferencing application
+ * Copyright (C) 2000-2014 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.
+ */
+
+
+/*
+ *                         foe-list.h  -  description
+ *                         ------------------------------------------
+ *   begin                : written in 2014 by Julien Puydt
+ *   copyright            : (c) 2014 by Julien Puydt
+ *   description          : interface of a delegate
+ *
+ */
+
+#ifndef __FOE_LIST_H__
+#define __FOE_LIST_H__
+
+#include "friend-or-foe.h"
+
+namespace Ekiga
+{
+
+  class FoeList:
+    public Service,
+    public FriendOrFoe::Helper
+  {
+  public:
+    FoeList();
+
+    ~FoeList();
+
+    /* Ekiga::Service api */
+
+    const std::string get_name () const
+    { return "foe-list"; }
+
+    const std::string get_description () const
+    { return "List of persons the user does not want to hear about"; }
+
+    /* FriendOrFoe::Helper api */
+
+    FriendOrFoe::Identification decide (const std::string domain,
+                                       const std::string token) const;
+
+    /* specific api */
+
+    void add_foe (const std::string token);
+  };
+};
+
+#endif
diff --git a/lib/engine/engine.cpp b/lib/engine/engine.cpp
index eaa3d3f..3b6ed20 100644
--- a/lib/engine/engine.cpp
+++ b/lib/engine/engine.cpp
@@ -50,6 +50,7 @@
 #include "call-core.h"
 #include "chat-core.h"
 #include "friend-or-foe.h"
+#include "foe-list.h"
 #include "videooutput-core.h"
 #include "videoinput-core.h"
 #include "audioinput-core.h"
@@ -100,6 +101,7 @@ engine_init (Ekiga::ServiceCorePtr service_core,
   service_core->add (notification_core);
 
   boost::shared_ptr<Ekiga::FriendOrFoe> friend_or_foe (new Ekiga::FriendOrFoe);
+  boost::shared_ptr<Ekiga::FoeList> foe_list (new Ekiga::FoeList);
   boost::shared_ptr<Ekiga::AccountCore> account_core (new Ekiga::AccountCore);
   boost::shared_ptr<Ekiga::ContactCore> contact_core (new Ekiga::ContactCore);
   boost::shared_ptr<Ekiga::CallCore> call_core (new Ekiga::CallCore (friend_or_foe));
@@ -115,6 +117,7 @@ engine_init (Ekiga::ServiceCorePtr service_core,
   service_core->add (contact_core);
   service_core->add (chat_core);
   service_core->add (friend_or_foe);
+  service_core->add (foe_list);
   service_core->add (videoinput_core);
   service_core->add (videooutput_core);
   service_core->add (audioinput_core);
@@ -125,6 +128,8 @@ engine_init (Ekiga::ServiceCorePtr service_core,
   service_core->add (details);
   service_core->add (presence_core);
 
+  friend_or_foe->add_helper (foe_list);
+
   if (!videoinput_mlogo_init (*service_core, &argc, &argv)) {
     return;
   }
diff --git a/org.gnome.ekiga.gschema.xml.in.in b/org.gnome.ekiga.gschema.xml.in.in
index 08c1102..e7b796f 100644
--- a/org.gnome.ekiga.gschema.xml.in.in
+++ b/org.gnome.ekiga.gschema.xml.in.in
@@ -527,5 +527,10 @@
     <key name="roster" type="s">
       <default>''</default>
     </key>
+    <key name="foe-list" type="as">
+      <default>[]</default>
+      <_summary>List of foes</_summary>
+      <_description>List of persons the user does not want to hear about</_description>
+    </key>
   </schema>
 </schemalist>


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