[ekiga] Incomplete code to register accounts
- From: Julien Puydt <jpuydt src gnome org>
- To: svn-commits-list gnome org
- Subject: [ekiga] Incomplete code to register accounts
- Date: Thu, 11 Jun 2009 11:41:39 -0400 (EDT)
commit 41152766c025227fac968e7802699f72288835a1
Author: Julien Puydt <jpuydt noether localdomain>
Date: Sat Nov 29 15:34:54 2008 +0100
Incomplete code to register accounts
lib/engine/components/loudmouth/Makefile.am | 6 +-
.../components/loudmouth/loudmouth-account.cpp | 135 ++++++++++++++++++++
.../components/loudmouth/loudmouth-account.h | 80 ++++++++++++
lib/engine/components/loudmouth/loudmouth-bank.cpp | 48 +++++++
lib/engine/components/loudmouth/loudmouth-bank.h | 66 ++++++++++
lib/engine/components/loudmouth/loudmouth-main.cpp | 11 +-
6 files changed, 342 insertions(+), 4 deletions(-)
---
diff --git a/lib/engine/components/loudmouth/Makefile.am b/lib/engine/components/loudmouth/Makefile.am
index 303023a..5f0d59d 100644
--- a/lib/engine/components/loudmouth/Makefile.am
+++ b/lib/engine/components/loudmouth/Makefile.am
@@ -9,6 +9,10 @@ INCLUDES = \
libgmloudmouth_la_SOURCES = \
$(loudmouth_dir)/loudmouth-main.h \
- $(loudmouth_dir)/loudmouth-main.cpp
+ $(loudmouth_dir)/loudmouth-main.cpp \
+ $(loudmouth_dir)/loudmouth-bank.h \
+ $(loudmouth_dir)/loudmouth-bank.cpp \
+ $(loudmouth_dir)/loudmouth-account.h \
+ $(loudmouth_dir)/loudmouth-account.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
new file mode 100644
index 0000000..defac9d
--- /dev/null
+++ b/lib/engine/components/loudmouth/loudmouth-account.cpp
@@ -0,0 +1,135 @@
+
+/*
+ * 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-account.cpp - description
+ * ------------------------------------------
+ * begin : written in 2008 by Julien Puydt
+ * copyright : (c) 2008 by Julien Puydt
+ * description : implementation of a loudmouth account
+ *
+ */
+
+#include <iostream>
+
+#include "loudmouth-account.h"
+
+/* here come the C callbacks, which just push to C++ code */
+static void
+on_connection_opened_c (LmConnection* /*unused*/,
+ gboolean result,
+ LM::Account* account)
+{
+ account->on_connection_opened (result);
+}
+
+static void
+on_disconnected_c (LmConnection* /*unused*/,
+ LmDisconnectReason reason,
+ LM::Account* account)
+{
+ account->on_disconnected (reason);
+}
+
+static void
+on_authenticate_c (LmConnection* /*unused*/,
+ gboolean result,
+ LM::Account* account)
+{
+ account->on_authenticate (result);
+}
+
+/* and here is the C++ code : */
+
+LM::Account::Account (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)
+{
+ connection = lm_connection_new (NULL);
+ lm_connection_set_disconnect_function (connection, (LmDisconnectFunction)on_disconnected_c,
+ this, NULL);
+ connect ();
+}
+
+void
+LM::Account::connect ()
+{
+ GError *error = NULL;
+
+ lm_connection_set_server (connection, server.c_str ());
+ if ( !lm_connection_open (connection,
+ (LmResultFunction)on_connection_opened_c,
+ this, NULL, &error)) {
+
+ // FIXME: do better
+ std::cout << error->message << std::endl;
+ g_error_free (error);
+ }
+}
+
+LM::Account::~Account ()
+{
+ std::cout << __PRETTY_FUNCTION__ << std::endl;
+
+ lm_connection_unref (connection);
+ connection = 0;
+}
+
+void
+LM::Account::on_connection_opened (bool result)
+{
+ if (result) {
+
+ std::cout << "Opened loudmouth connection" << std::endl;
+ lm_connection_authenticate (connection, user.c_str (), password.c_str (), resource.c_str (),
+ (LmResultFunction)on_authenticate_c, this, NULL, NULL);
+ } else {
+
+ std::cout << "Error opening loudmouth connection" << std::endl; // FIXME: do better
+ }
+}
+
+void
+LM::Account::on_disconnected (LmDisconnectReason /*reason*/)
+{
+ std::cout << __PRETTY_FUNCTION__ << std::endl; // FIXME: to complete
+}
+
+void
+LM::Account::on_authenticate (bool result)
+{
+ if (result) {
+
+ std::cout << "Loudmouth authentication succeeded" << std::endl;
+ } else {
+
+ lm_connection_close (connection, NULL);
+ std::cout << "Error authenticating loudmouth account" << std::endl;
+ }
+}
diff --git a/lib/engine/components/loudmouth/loudmouth-account.h b/lib/engine/components/loudmouth/loudmouth-account.h
new file mode 100644
index 0000000..5d6bf4e
--- /dev/null
+++ b/lib/engine/components/loudmouth/loudmouth-account.h
@@ -0,0 +1,80 @@
+
+/*
+ * 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-account.h - description
+ * ------------------------------------------
+ * begin : written in 2008 by Julien Puydt
+ * copyright : (c) 2008 by Julien Puydt
+ * description : declaration of a loudmouth account
+ *
+ */
+
+#ifndef __LOUDMOUTH_ACCOUNT_H__
+#define __LOUDMOUTH_ACCOUNT_H__
+
+#include <string>
+#include <loudmouth/loudmouth.h>
+
+#include "gmref.h"
+
+namespace LM
+{
+
+ class Account:
+ public virtual GmRefCounted
+ {
+ public:
+ Account (const std::string user_,
+ const std::string password_,
+ const std::string resource_,
+ const std::string server_,
+ unsigned port_ = 5222);
+
+ ~Account ();
+
+ void connect ();
+
+ /* public only to be called by C callbacks */
+ void on_connection_opened (bool result);
+
+ void on_disconnected (LmDisconnectReason reason);
+
+ void on_authenticate (bool result);
+
+ private:
+
+ std::string user;
+ std::string password;
+ std::string resource;
+ std::string server;
+ unsigned port;
+
+ LmConnection* connection;
+ };
+};
+
+#endif
diff --git a/lib/engine/components/loudmouth/loudmouth-bank.cpp b/lib/engine/components/loudmouth/loudmouth-bank.cpp
new file mode 100644
index 0000000..f8fbfd6
--- /dev/null
+++ b/lib/engine/components/loudmouth/loudmouth-bank.cpp
@@ -0,0 +1,48 @@
+
+/*
+ * 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-bank.h - description
+ * ------------------------------------------
+ * begin : written in 2008 by Julien Puydt
+ * copyright : (c) 2008 by Julien Puydt
+ * description : implementation of the loudmouth account manager
+ *
+ */
+
+#include <iostream>
+
+#include "loudmouth-bank.h"
+
+LM::Bank::Bank ()
+{
+ account = gmref_ptr<Account>(new Account ("premier", "premier", "ekiga", "localhost"));
+}
+
+LM::Bank::~Bank ()
+{
+ std::cout << __PRETTY_FUNCTION__ << std::endl;
+}
diff --git a/lib/engine/components/loudmouth/loudmouth-bank.h b/lib/engine/components/loudmouth/loudmouth-bank.h
new file mode 100644
index 0000000..8fa1e27
--- /dev/null
+++ b/lib/engine/components/loudmouth/loudmouth-bank.h
@@ -0,0 +1,66 @@
+
+/*
+ * 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-bank.h - description
+ * ------------------------------------------
+ * begin : written in 2008 by Julien Puydt
+ * copyright : (c) 2008 by Julien Puydt
+ * description : declaration of the loudmouth account manager
+ *
+ */
+
+#ifndef __LOUDMOUTH_BANK_H__
+#define __LOUDMOUTH_BANK_H__
+
+#include "services.h"
+
+#include "loudmouth-account.h"
+
+namespace LM
+{
+
+ class Bank:
+ public Ekiga::Service
+ {
+ public:
+ Bank ();
+
+ ~Bank ();
+
+ const std::string get_name () const
+ { return "loudmouth-bank"; }
+
+ const std::string get_description () const
+ { return "\tManager of the XMPP/Jabber accounts"; }
+
+ private:
+
+ gmref_ptr<Account> account;
+ };
+};
+
+#endif
diff --git a/lib/engine/components/loudmouth/loudmouth-main.cpp b/lib/engine/components/loudmouth/loudmouth-main.cpp
index da46fad..bcc49d9 100644
--- a/lib/engine/components/loudmouth/loudmouth-main.cpp
+++ b/lib/engine/components/loudmouth/loudmouth-main.cpp
@@ -37,15 +37,20 @@
#include "loudmouth-main.h"
+#include "loudmouth-bank.h"
+
bool
-loudmouth_init (Ekiga::ServiceCore &/*services*/,
+loudmouth_init (Ekiga::ServiceCore &services,
int */*argc*/,
char **/*argv*/[])
{
bool result = false;
- // nothing yet
- result = true;
+ { // no test for the deps : too simple to have deps!
+ gmref_ptr<LM::Bank> bank (new LM::Bank);
+ services.add (bank);
+ result = true;
+ }
return result;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]