[ekiga] Pushed the message waiting information code down the account stack
- From: Julien Puydt <jpuydt src gnome org>
- To: svn-commits-list gnome org
- Subject: [ekiga] Pushed the message waiting information code down the account stack
- Date: Tue, 9 Jun 2009 15:06:55 -0400 (EDT)
commit 796cf76e188e47cef0dd2a64bca8381b0f5d2564
Author: Julien Puydt <jpuydt gnome org>
Date: Sun Jun 7 10:00:44 2009 +0200
Pushed the message waiting information code down the account stack
---
lib/engine/account/account-core.cpp | 8 ----
lib/engine/account/account-core.h | 10 -----
lib/engine/account/account.h | 6 ---
lib/engine/components/opal/opal-account.cpp | 50 +++++++++++++++++++++++++--
lib/engine/components/opal/opal-account.h | 12 +++++-
lib/engine/components/opal/opal-bank.cpp | 2 -
lib/engine/components/opal/opal-bank.h | 6 ---
lib/engine/components/opal/sip-endpoint.cpp | 2 +-
src/gui/accounts.cpp | 26 --------------
9 files changed, 58 insertions(+), 64 deletions(-)
diff --git a/lib/engine/account/account-core.cpp b/lib/engine/account/account-core.cpp
index 4ae6741..0953313 100644
--- a/lib/engine/account/account-core.cpp
+++ b/lib/engine/account/account-core.cpp
@@ -98,11 +98,3 @@ Ekiga::AccountCore::add_account_subscriber (AccountSubscriber &subscriber)
{
account_subscribers.insert (&subscriber);
}
-
-
-void Ekiga::AccountCore::on_mwi_event (BankPtr bank,
- AccountPtr account,
- const std::string & info)
-{
- mwi_event.emit (bank, account, info);
-}
diff --git a/lib/engine/account/account-core.h b/lib/engine/account/account-core.h
index c9a1066..f8fa7fb 100644
--- a/lib/engine/account/account-core.h
+++ b/lib/engine/account/account-core.h
@@ -161,13 +161,6 @@ namespace Ekiga
ChainOfResponsibility<FormRequest*> questions;
- /** This signal is emitted when there is a new message waiting event
- * @param: account is the account
- * info contains information about the indication
- */
- sigc::signal3<void, BankPtr, AccountPtr, std::string> mwi_event;
-
-
/*** Account Subscriber API ***/
public:
void add_account_subscriber (AccountSubscriber &subscriber);
@@ -183,9 +176,6 @@ namespace Ekiga
std::set<AccountSubscriber *> account_subscribers;
typedef std::set<AccountSubscriber *>::iterator subscriber_iterator;
typedef std::set<AccountSubscriber *>::const_iterator subscriber_const_iterator;
- void on_mwi_event (BankPtr bank,
- AccountPtr account,
- const std::string & info);
};
diff --git a/lib/engine/account/account.h b/lib/engine/account/account.h
index 3094012..d5b6400 100644
--- a/lib/engine/account/account.h
+++ b/lib/engine/account/account.h
@@ -144,12 +144,6 @@ namespace Ekiga
sigc::signal0<void> removed;
- /** This signal is emitted when there is a new message waiting indication
- * @param: mwi is the message waiting indication
- */
- sigc::signal1<void, std::string> mwi_event;
-
-
/** This chain allows the Account to present forms to the user
*/
ChainOfResponsibility<FormRequest*> questions;
diff --git a/lib/engine/components/opal/opal-account.cpp b/lib/engine/components/opal/opal-account.cpp
index a15198b..72e3646 100644
--- a/lib/engine/components/opal/opal-account.cpp
+++ b/lib/engine/components/opal/opal-account.cpp
@@ -41,6 +41,7 @@
#include <algorithm>
#include <sstream>
+#include <glib.h>
#include <glib/gi18n.h>
#include <ptlib.h>
#include <opal/opal.h>
@@ -52,6 +53,7 @@
#include "presence-core.h"
#include "personal-details.h"
+#include "audiooutput-core.h"
Opal::Account::Account (Ekiga::ServiceCore & _core,
const std::string & account)
@@ -189,7 +191,25 @@ const std::string Opal::Account::get_name () const
const std::string
Opal::Account::get_status () const
{
- return status;
+ std::string result;
+ if (message_waiting_number > 0) {
+
+ gchar* str = NULL;
+ /* translators : the result will look like :
+ * "registered (with 2 voicemail messages)"
+ */
+ str = g_strdup_printf (ngettext ("%s (with %d voicemail message)",
+ "%s (with %d voicemail messages)",
+ message_waiting_number),
+ status.c_str (), message_waiting_number);
+ result = str;
+ g_free (str);
+ } else {
+
+ result = status;
+ }
+
+ return result;
}
const std::string Opal::Account::get_aor () const
@@ -446,15 +466,18 @@ Opal::Account::on_consult (const std::string url)
}
void
-Opal::Account::handle_registration_event (RegistrationState state,
- std::string info)
+Opal::Account::handle_registration_event (RegistrationState state_,
+ const std::string info)
{
bool old_active = active;
+ state = state_;
active = false;
switch (state) {
+
case Registered:
+
if (!old_active) {
status = _("Registered");
@@ -470,11 +493,13 @@ Opal::Account::handle_registration_event (RegistrationState state,
break;
case Unregistered:
+
status = _("Unregistered");
updated.emit ();
break;
case UnregistrationFailed:
+
status = _("Could not unregister");
if (!info.empty ())
status = status + " (" + info + ")";
@@ -482,6 +507,7 @@ Opal::Account::handle_registration_event (RegistrationState state,
break;
case RegistrationFailed:
+
status = _("Could not register");
if (!info.empty ())
status = status + " (" + info + ")";
@@ -489,9 +515,27 @@ Opal::Account::handle_registration_event (RegistrationState state,
break;
case Processing:
+
status = _("Processing...");
updated.emit ();
default:
break;
}
}
+
+void
+Opal::Account::handle_message_waiting_information (const std::string info)
+{
+ std::string::size_type loc = info.find ("/", 0);
+
+ if (loc != std::string::npos) {
+
+ gmref_ptr<Ekiga::AudioOutputCore> audiooutput_core = core.get ("audiooutput-core");
+ std::stringstream new_messages;
+ new_messages << info.substr (0, loc);
+ new_messages >> message_waiting_number;
+ if (message_waiting_number > 0)
+ audiooutput_core->play_event ("new_voicemail_sound");
+ updated.emit ();
+ }
+}
diff --git a/lib/engine/components/opal/opal-account.h b/lib/engine/components/opal/opal-account.h
index 0439483..ec120d1 100644
--- a/lib/engine/components/opal/opal-account.h
+++ b/lib/engine/components/opal/opal-account.h
@@ -141,14 +141,21 @@ public:
/* This method is public to be called by an opal endpoint, which will push
* this Opal::Account's new registration state
*/
- void handle_registration_event (RegistrationState state,
- std::string info);
+ void handle_registration_event (RegistrationState state_,
+ const std::string info);
+
+ /* This method is public to be called by an opal endpoint, which will push
+ * this Opal::Account's message waiting information
+ */
+ void handle_message_waiting_information (const std::string info);
+
private:
void on_edit_form_submitted (bool submitted,
Ekiga::Form &result);
void on_consult (const std::string url);
+ RegistrationState state;
bool dead;
bool active;
bool enabled;
@@ -156,6 +163,7 @@ private:
std::string aid;
std::string name;
std::string status;
+ int message_waiting_number;
std::string protocol_name;
std::string host;
std::string username;
diff --git a/lib/engine/components/opal/opal-bank.cpp b/lib/engine/components/opal/opal-bank.cpp
index 43f05b2..400f205 100644
--- a/lib/engine/components/opal/opal-bank.cpp
+++ b/lib/engine/components/opal/opal-bank.cpp
@@ -218,8 +218,6 @@ void Opal::Bank::add (Account::Type acc_type,
timeout));
add_account (account);
Ekiga::BankImpl<Account>::add_connection (account, account->trigger_saving.connect (sigc::mem_fun (this, &Opal::Bank::save)));
-
- account->mwi_event.connect (sigc::bind<0> (mwi_event.make_slot (), account));
}
void
diff --git a/lib/engine/components/opal/opal-bank.h b/lib/engine/components/opal/opal-bank.h
index 110da89..3a5429e 100644
--- a/lib/engine/components/opal/opal-bank.h
+++ b/lib/engine/components/opal/opal-bank.h
@@ -82,12 +82,6 @@ public:
void call_manager_ready ();
- /** This signal is emitted when there is a new message waiting event
- * @param: account is the account
- * info contains information about the indication
- */
- sigc::signal2<void, AccountPtr, std::string> mwi_event;
-
private:
Ekiga::ServiceCore &core;
diff --git a/lib/engine/components/opal/sip-endpoint.cpp b/lib/engine/components/opal/sip-endpoint.cpp
index 282a4d9..273ee2d 100644
--- a/lib/engine/components/opal/sip-endpoint.cpp
+++ b/lib/engine/components/opal/sip-endpoint.cpp
@@ -1273,6 +1273,6 @@ Opal::Sip::EndPoint::mwi_received_in_main (const std::string aor,
if (account) {
- account->mwi_event.emit (info);
+ account->handle_message_waiting_information (info);
}
}
diff --git a/src/gui/accounts.cpp b/src/gui/accounts.cpp
index 7cc775c..085d19b 100644
--- a/src/gui/accounts.cpp
+++ b/src/gui/accounts.cpp
@@ -41,7 +41,6 @@
#include "bank.h"
#include "opal-bank.h"
#include "account-core.h"
-#include "audiooutput-core.h"
#include "callbacks.h"
#include "misc.h"
@@ -217,29 +216,6 @@ gm_accounts_window_update_account_state (GtkWidget *accounts_window,
/* Engine callbacks */
static void
-on_mwi_event (Ekiga::AccountPtr account,
- std::string mwi,
- gpointer self)
-{
- if (gm_accounts_window_update_account_state (GTK_WIDGET (self), false, account, NULL, mwi.c_str ())) {
-
- std::string::size_type loc = mwi.find ("/", 0);
- if (loc != std::string::npos) {
-
- GmAccountsWindow *aw = gm_aw_get_aw (GTK_WIDGET (self));
- gmref_ptr<Ekiga::AudioOutputCore> audiooutput_core = aw->core.get ("audiooutput-core");
- std::stringstream new_messages;
- int i;
- new_messages << mwi.substr (0, loc);
- new_messages >> i;
- if (i > 0)
- audiooutput_core->play_event ("new_voicemail_sound");
- }
- }
-}
-
-
-static void
populate_menu (GtkWidget *window)
{
GmAccountsWindow *aw = NULL;
@@ -734,13 +710,11 @@ gm_accounts_window_new (Ekiga::ServiceCore &core)
// FIXME sigc::connection conn;
gmref_ptr<Ekiga::AccountCore> account_core = core.get ("account-core");
- gmref_ptr<Opal::Bank> bank = core.get ("opal-account-store");
account_core->bank_added.connect (sigc::bind (sigc::ptr_fun (on_bank_added), window));
account_core->account_added.connect (sigc::bind (sigc::ptr_fun (on_account_added), window));
account_core->account_updated.connect (sigc::bind (sigc::ptr_fun (on_account_updated), window));
account_core->account_removed.connect (sigc::bind (sigc::ptr_fun (on_account_removed), window));
account_core->questions.add_handler (sigc::bind (sigc::ptr_fun (on_handle_questions), (gpointer) window));
- bank->mwi_event.connect (sigc::bind (sigc::ptr_fun (on_mwi_event), (gpointer) window));
account_core->visit_banks (sigc::bind_return (sigc::bind (sigc::ptr_fun (on_bank_added), window), true));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]