[ekiga] Connected the loudmouth code to the presence core : empty contact list in sight!
- From: Julien Puydt <jpuydt src gnome org>
- To: svn-commits-list gnome org
- Subject: [ekiga] Connected the loudmouth code to the presence core : empty contact list in sight!
- Date: Thu, 11 Jun 2009 11:41:44 -0400 (EDT)
commit 17dab75473e1e4d4a6057692c20e6b9e551abc10
Author: Julien Puydt <jpuydt noether localdomain>
Date: Sat Nov 29 18:14:10 2008 +0100
Connected the loudmouth code to the presence core : empty contact list in sight!
lib/engine/components/loudmouth/Makefile.am | 10 ++-
.../components/loudmouth/loudmouth-account.cpp | 30 +++++++-
.../components/loudmouth/loudmouth-account.h | 12 ++-
lib/engine/components/loudmouth/loudmouth-bank.cpp | 4 +-
lib/engine/components/loudmouth/loudmouth-bank.h | 3 +-
.../components/loudmouth/loudmouth-cluster.cpp | 50 +++++++++++++
.../components/loudmouth/loudmouth-cluster.h | 60 ++++++++++++++++
lib/engine/components/loudmouth/loudmouth-heap.cpp | 73 ++++++++++++++++++++
lib/engine/components/loudmouth/loudmouth-heap.h | 69 ++++++++++++++++++
lib/engine/components/loudmouth/loudmouth-main.cpp | 11 +++-
10 files changed, 307 insertions(+), 15 deletions(-)
---
diff --git a/lib/engine/components/loudmouth/Makefile.am b/lib/engine/components/loudmouth/Makefile.am
index 5f0d59d..cc55ca6 100644
--- a/lib/engine/components/loudmouth/Makefile.am
+++ b/lib/engine/components/loudmouth/Makefile.am
@@ -5,7 +5,9 @@ loudmouth_dir = $(top_srcdir)/lib/engine/components/loudmouth
AM_CXXFLAGS = $(SIGC_CFLAGS) $(LOUDMOUTH_CFLAGS)
INCLUDES = \
- -I$(top_srcdir)/lib/engine/framework
+ -I$(top_srcdir)/lib/engine/framework \
+ -I$(top_srcdir)/lib/engine/account/skel \
+ -I$(top_srcdir)/lib/engine/presence/skel
libgmloudmouth_la_SOURCES = \
$(loudmouth_dir)/loudmouth-main.h \
@@ -13,6 +15,10 @@ libgmloudmouth_la_SOURCES = \
$(loudmouth_dir)/loudmouth-bank.h \
$(loudmouth_dir)/loudmouth-bank.cpp \
$(loudmouth_dir)/loudmouth-account.h \
- $(loudmouth_dir)/loudmouth-account.cpp
+ $(loudmouth_dir)/loudmouth-account.cpp \
+ $(loudmouth_dir)/loudmouth-cluster.h \
+ $(loudmouth_dir)/loudmouth-cluster.cpp \
+ $(loudmouth_dir)/loudmouth-heap.h \
+ $(loudmouth_dir)/loudmouth-heap.cpp
libgmloudmouth_la_LDFLAGS = -export-dynamic -no-undefined $(SIGC_LIBS) $(LOUDMOUTH_LIBS)
\ No newline at end of file
diff --git a/lib/engine/components/loudmouth/loudmouth-account.cpp b/lib/engine/components/loudmouth/loudmouth-account.cpp
index defac9d..3e85b9d 100644
--- a/lib/engine/components/loudmouth/loudmouth-account.cpp
+++ b/lib/engine/components/loudmouth/loudmouth-account.cpp
@@ -64,12 +64,13 @@ on_authenticate_c (LmConnection* /*unused*/,
/* and here is the C++ code : */
-LM::Account::Account (const std::string user_,
+LM::Account::Account (gmref_ptr<Cluster> cluster_,
+ const std::string user_,
const std::string password_,
const std::string resource_,
const std::string server_,
unsigned port_):
- user(user_), password(password_), resource(resource_), server(server_), port(port_), connection(0)
+ cluster(cluster_), user(user_), password(password_), resource(resource_), server(server_), port(port_), connection(0)
{
connection = lm_connection_new (NULL);
lm_connection_set_disconnect_function (connection, (LmDisconnectFunction)on_disconnected_c,
@@ -81,7 +82,12 @@ void
LM::Account::connect ()
{
GError *error = NULL;
-
+ {
+ gchar* jid = NULL;
+ jid = g_strdup_printf ("%s %s/%s", user.c_str (), server.c_str (), resource.c_str ());
+ lm_connection_set_jid (connection, jid);
+ g_free (jid);
+ }
lm_connection_set_server (connection, server.c_str ());
if ( !lm_connection_open (connection,
(LmResultFunction)on_connection_opened_c,
@@ -97,6 +103,16 @@ LM::Account::~Account ()
{
std::cout << __PRETTY_FUNCTION__ << std::endl;
+ if (heap) {
+
+ heap->disconnected ();
+ heap.reset ();
+ }
+
+ if (lm_connection_is_open (connection)) {
+
+ lm_connection_close (connection, NULL);
+ }
lm_connection_unref (connection);
connection = 0;
}
@@ -118,7 +134,11 @@ LM::Account::on_connection_opened (bool result)
void
LM::Account::on_disconnected (LmDisconnectReason /*reason*/)
{
- std::cout << __PRETTY_FUNCTION__ << std::endl; // FIXME: to complete
+ if (heap) {
+
+ heap->disconnected ();
+ heap.reset ();
+ }
}
void
@@ -126,6 +146,8 @@ LM::Account::on_authenticate (bool result)
{
if (result) {
+ heap = gmref_ptr<Heap> (new Heap (connection));
+ cluster->add_heap (heap);
std::cout << "Loudmouth authentication succeeded" << std::endl;
} else {
diff --git a/lib/engine/components/loudmouth/loudmouth-account.h b/lib/engine/components/loudmouth/loudmouth-account.h
index 5d6bf4e..8e9f26f 100644
--- a/lib/engine/components/loudmouth/loudmouth-account.h
+++ b/lib/engine/components/loudmouth/loudmouth-account.h
@@ -36,11 +36,10 @@
#ifndef __LOUDMOUTH_ACCOUNT_H__
#define __LOUDMOUTH_ACCOUNT_H__
-#include <string>
-#include <loudmouth/loudmouth.h>
-
#include "gmref.h"
+#include "loudmouth-cluster.h"
+
namespace LM
{
@@ -48,7 +47,8 @@ namespace LM
public virtual GmRefCounted
{
public:
- Account (const std::string user_,
+ Account (gmref_ptr<Cluster> cluster_,
+ const std::string user_,
const std::string password_,
const std::string resource_,
const std::string server_,
@@ -67,6 +67,8 @@ namespace LM
private:
+ gmref_ptr<Cluster> cluster;
+
std::string user;
std::string password;
std::string resource;
@@ -74,6 +76,8 @@ namespace LM
unsigned port;
LmConnection* connection;
+
+ gmref_ptr<Heap> heap;
};
};
diff --git a/lib/engine/components/loudmouth/loudmouth-bank.cpp b/lib/engine/components/loudmouth/loudmouth-bank.cpp
index f8fbfd6..7679c5a 100644
--- a/lib/engine/components/loudmouth/loudmouth-bank.cpp
+++ b/lib/engine/components/loudmouth/loudmouth-bank.cpp
@@ -37,9 +37,9 @@
#include "loudmouth-bank.h"
-LM::Bank::Bank ()
+LM::Bank::Bank (gmref_ptr<Cluster> cluster_): cluster(cluster_)
{
- account = gmref_ptr<Account>(new Account ("premier", "premier", "ekiga", "localhost"));
+ account = gmref_ptr<Account>(new Account (cluster, "premier", "premier", "ekiga", "localhost"));
}
LM::Bank::~Bank ()
diff --git a/lib/engine/components/loudmouth/loudmouth-bank.h b/lib/engine/components/loudmouth/loudmouth-bank.h
index 8fa1e27..b73f2a3 100644
--- a/lib/engine/components/loudmouth/loudmouth-bank.h
+++ b/lib/engine/components/loudmouth/loudmouth-bank.h
@@ -47,7 +47,7 @@ namespace LM
public Ekiga::Service
{
public:
- Bank ();
+ Bank (gmref_ptr<Cluster> cluster_);
~Bank ();
@@ -59,6 +59,7 @@ namespace LM
private:
+ gmref_ptr<Cluster> cluster;
gmref_ptr<Account> account;
};
};
diff --git a/lib/engine/components/loudmouth/loudmouth-cluster.cpp b/lib/engine/components/loudmouth/loudmouth-cluster.cpp
new file mode 100644
index 0000000..7c05520
--- /dev/null
+++ b/lib/engine/components/loudmouth/loudmouth-cluster.cpp
@@ -0,0 +1,50 @@
+
+/*
+ * 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.
+ */
+
+
+/*
+ * loudmouth-cluster.cpp - description
+ * ------------------------------------------
+ * begin : written in 2008 by Julien Puydt
+ * copyright : (c) 2008 by Julien Puydt
+ * description : implementation of a loudmouth cluster
+ *
+ */
+
+#include "loudmouth-cluster.h"
+
+LM::Cluster::Cluster ()
+{
+}
+
+LM::Cluster::~Cluster ()
+{
+}
+
+bool
+LM::Cluster::populate_menu (Ekiga::MenuBuilder& /*builder*/)
+{
+ return false;
+}
diff --git a/lib/engine/components/loudmouth/loudmouth-cluster.h b/lib/engine/components/loudmouth/loudmouth-cluster.h
new file mode 100644
index 0000000..06ba62b
--- /dev/null
+++ b/lib/engine/components/loudmouth/loudmouth-cluster.h
@@ -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.
+ */
+
+
+/*
+ * loudmouth-cluster.h - description
+ * ------------------------------------------
+ * begin : written in 2008 by Julien Puydt
+ * copyright : (c) 2008 by Julien Puydt
+ * description : declaration of a loudmouth cluster
+ *
+ */
+
+#ifndef __LOUDMOUTH_CLUSTER_H__
+#define __LOUDMOUTH_CLUSTER_H__
+
+#include "cluster-impl.h"
+
+#include "loudmouth-heap.h"
+
+namespace LM
+{
+ class Cluster:
+ public Ekiga::ClusterImpl<Heap>
+ {
+ public:
+
+ Cluster ();
+
+ ~Cluster ();
+
+ using Ekiga::ClusterImpl<Heap>::add_heap;
+
+ bool populate_menu (Ekiga::MenuBuilder& builder);
+ };
+};
+
+#endif
diff --git a/lib/engine/components/loudmouth/loudmouth-heap.cpp b/lib/engine/components/loudmouth/loudmouth-heap.cpp
new file mode 100644
index 0000000..b399e14
--- /dev/null
+++ b/lib/engine/components/loudmouth/loudmouth-heap.cpp
@@ -0,0 +1,73 @@
+
+/*
+ * 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.
+ */
+
+
+/*
+ * loudmouth-heap.cpp - description
+ * ------------------------------------------
+ * begin : written in 2008 by Julien Puydt
+ * copyright : (c) 2008 by Julien Puydt
+ * description : implementation of a loudmouth heap
+ *
+ */
+
+#include <iostream>
+
+#include "loudmouth-heap.h"
+
+LM::Heap::Heap (LmConnection* connection_): connection(connection_)
+{
+}
+
+LM::Heap::~Heap ()
+{
+ std::cout << __PRETTY_FUNCTION__ << std::endl;
+}
+
+const std::string
+LM::Heap::get_name () const
+{
+ return lm_connection_get_jid (connection);
+}
+
+bool
+LM::Heap::populate_menu (Ekiga::MenuBuilder& /*builder*/)
+{
+ return false;
+}
+
+bool
+LM::Heap::populate_menu_for_group (const std::string /*group*/,
+ Ekiga::MenuBuilder& /*builder*/)
+{
+ return false;
+}
+
+
+void
+LM::Heap::disconnected ()
+{
+ // FIXME: do something
+}
diff --git a/lib/engine/components/loudmouth/loudmouth-heap.h b/lib/engine/components/loudmouth/loudmouth-heap.h
new file mode 100644
index 0000000..d524747
--- /dev/null
+++ b/lib/engine/components/loudmouth/loudmouth-heap.h
@@ -0,0 +1,69 @@
+
+/*
+ * 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.
+ */
+
+
+/*
+ * loudmouth-heap.h - description
+ * ------------------------------------------
+ * begin : written in 2008 by Julien Puydt
+ * copyright : (c) 2008 by Julien Puydt
+ * description : declaration of a loudmouth heap
+ *
+ */
+
+#ifndef __LOUDMOUTH_HEAP_H__
+#define __LOUDMOUTH_HEAP_H__
+
+#include <loudmouth/loudmouth.h>
+
+#include "heap-impl.h"
+
+namespace LM
+{
+ class Heap:
+ public Ekiga::HeapImpl<Ekiga::Presentity>
+ {
+ public:
+
+ Heap (LmConnection* connection_);
+
+ ~Heap ();
+
+ const std::string get_name () const;
+
+ bool populate_menu (Ekiga::MenuBuilder& builder);
+
+ bool populate_menu_for_group (const std::string group,
+ Ekiga::MenuBuilder& builder);
+
+ void disconnected ();
+
+ private:
+
+ LmConnection* connection;
+ };
+};
+
+#endif
diff --git a/lib/engine/components/loudmouth/loudmouth-main.cpp b/lib/engine/components/loudmouth/loudmouth-main.cpp
index bcc49d9..509eacd 100644
--- a/lib/engine/components/loudmouth/loudmouth-main.cpp
+++ b/lib/engine/components/loudmouth/loudmouth-main.cpp
@@ -37,6 +37,9 @@
#include "loudmouth-main.h"
+#include "presence-core.h"
+
+#include "loudmouth-cluster.h"
#include "loudmouth-bank.h"
bool
@@ -45,10 +48,14 @@ loudmouth_init (Ekiga::ServiceCore &services,
char **/*argv*/[])
{
bool result = false;
+ gmref_ptr<Ekiga::PresenceCore> presence (services.get ("presence-core"));
+
+ if (presence) {
- { // no test for the deps : too simple to have deps!
- gmref_ptr<LM::Bank> bank (new LM::Bank);
+ gmref_ptr<LM::Cluster> cluster(new LM::Cluster);
+ gmref_ptr<LM::Bank> bank (new LM::Bank (cluster));
services.add (bank);
+ presence->add_cluster (cluster);
result = true;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]