ekiga r7417 - trunk/lib/engine/chat/skel
- From: jpuydt svn gnome org
- To: svn-commits-list gnome org
- Subject: ekiga r7417 - trunk/lib/engine/chat/skel
- Date: Tue, 25 Nov 2008 19:18:51 +0000 (UTC)
Author: jpuydt
Date: Tue Nov 25 19:18:50 2008
New Revision: 7417
URL: http://svn.gnome.org/viewvc/ekiga?rev=7417&view=rev
Log:
Moved the chat stack to gmref_ptr
Modified:
trunk/lib/engine/chat/skel/chat-core.cpp
trunk/lib/engine/chat/skel/chat-core.h
trunk/lib/engine/chat/skel/chat.h
trunk/lib/engine/chat/skel/dialect-impl.h
trunk/lib/engine/chat/skel/dialect.h
Modified: trunk/lib/engine/chat/skel/chat-core.cpp
==============================================================================
--- trunk/lib/engine/chat/skel/chat-core.cpp (original)
+++ trunk/lib/engine/chat/skel/chat-core.cpp Tue Nov 25 19:18:50 2008
@@ -42,22 +42,22 @@
}
void
-Ekiga::ChatCore::add_dialect (Dialect& dialect)
+Ekiga::ChatCore::add_dialect (gmref_ptr<Dialect> dialect)
{
- dialects.insert (&dialect);
- dialect.questions.add_handler (questions.make_slot ());
+ dialects.push_back (dialect);
+ dialect->questions.add_handler (questions.make_slot ());
dialect_added.emit (dialect);
}
void
-Ekiga::ChatCore::visit_dialects (sigc::slot1<bool, Dialect&> visitor)
+Ekiga::ChatCore::visit_dialects (sigc::slot1<bool, gmref_ptr<Dialect> > visitor)
{
bool go_on = true;
- for (std::set<Dialect*>::iterator iter = dialects.begin ();
+ for (std::list<gmref_ptr<Dialect> >::iterator iter = dialects.begin ();
iter != dialects.end () && go_on;
iter++)
- go_on = visitor (**iter);
+ go_on = visitor (*iter);
}
bool
@@ -65,7 +65,7 @@
{
bool result = false;
- for (std::set<Dialect*>::iterator iter = dialects.begin ();
+ for (std::list<gmref_ptr<Dialect> >::iterator iter = dialects.begin ();
iter != dialects.end ();
++iter)
result = (*iter)->populate_menu (builder) || result;
Modified: trunk/lib/engine/chat/skel/chat-core.h
==============================================================================
--- trunk/lib/engine/chat/skel/chat-core.h (original)
+++ trunk/lib/engine/chat/skel/chat-core.h Tue Nov 25 19:18:50 2008
@@ -88,23 +88,23 @@
/** Adds a dialect to the ContactCore service.
* @param The dialect to be added.
*/
- void add_dialect (Dialect& dialect);
+ void add_dialect (gmref_ptr<Dialect> dialect);
/** Triggers a callback for all Ekiga::Dialect dialects of the
* ChatCore service.
* @param The callback (the return value means "go on" and allows stopping
* the visit)
*/
- void visit_dialects (sigc::slot1<bool, Dialect&> visitor);
+ void visit_dialects (sigc::slot1<bool, gmref_ptr<Dialect> > visitor);
/** This signal is emitted when an Ekiga::Dialect has been added to
* the ChatCore service.
*/
- sigc::signal1<void, Dialect&> dialect_added;
+ sigc::signal1<void, gmref_ptr<Dialect> > dialect_added;
private:
- std::set<Dialect*> dialects;
+ std::list<gmref_ptr<Dialect> > dialects;
/*** Misc ***/
public:
Modified: trunk/lib/engine/chat/skel/chat.h
==============================================================================
--- trunk/lib/engine/chat/skel/chat.h (original)
+++ trunk/lib/engine/chat/skel/chat.h Tue Nov 25 19:18:50 2008
@@ -39,13 +39,15 @@
#include <string>
#include <sigc++/sigc++.h>
+#include "gmref.h"
+
#include "chain-of-responsibility.h"
#include "form-request.h"
#include "menu-builder.h"
namespace Ekiga
{
- class ChatObserver
+ class ChatObserver: public virtual GmRefCounted
{
public:
@@ -66,7 +68,7 @@
};
- class Chat
+ class Chat: public virtual GmRefCounted
{
public:
@@ -87,12 +89,12 @@
* send a few previous messages to the new observer.
* @param The new observer
*/
- virtual void connect (ChatObserver &observer) = 0;
+ virtual void connect (gmref_ptr<ChatObserver> observer) = 0;
/** Disconnects the new observer from the Chat
* @param The observer to disconnect
*/
- virtual void disconnect (ChatObserver &observer) = 0;
+ virtual void disconnect (gmref_ptr<ChatObserver> observer) = 0;
/** Sends a message through the Chat, or at least attempts to :
* the two ideas are first that the text entry will get blanked
Modified: trunk/lib/engine/chat/skel/dialect-impl.h
==============================================================================
--- trunk/lib/engine/chat/skel/dialect-impl.h (original)
+++ trunk/lib/engine/chat/skel/dialect-impl.h Tue Nov 25 19:18:50 2008
@@ -37,7 +37,8 @@
#define __DIALECT_IMPL_H__
#include "dialect.h"
-#include "lister.h"
+
+#include "map-key-iterator.h"
namespace Ekiga
{
@@ -61,59 +62,53 @@
* @param: The callback (the return value means "go on" and allows
* stopping the visit)
*/
- void visit_simple_chats (sigc::slot1<bool, SimpleChat&> visitor);
+ void visit_simple_chats (sigc::slot1<bool, gmref_ptr<SimpleChat> > visitor);
/** Triggers a callback for all multiple chats of the Dialect.
* @param: The callback (the return value means "go on" and allows
* stopping the visit)
*/
- void visit_multiple_chats (sigc::slot1<bool, MultipleChat&> visitor);
+ void visit_multiple_chats (sigc::slot1<bool, gmref_ptr<MultipleChat> > visitor);
protected:
/* More STL-like ways to access the chats within this Ekiga::DialectImpl
*/
- typedef typename Lister<SimpleChatType>::iterator simple_iterator;
- typedef typename Lister<SimpleChatType>::const_iterator simple_const_iterator;
- typedef typename Lister<MultipleChatType>::iterator multiple_iterator;
- typedef typename Lister<MultipleChatType>::const_iterator multiple_const_iterator;
+ typedef typename Ekiga::map_key_iterator<std::map<gmref_ptr<SimpleChatType>, std::list<sigc::connection> > > simple_iterator;
+ typedef typename Ekiga::map_key_iterator<std::map<gmref_ptr<MultipleChatType>, std::list<sigc::connection> > > multiple_iterator;
simple_iterator simple_begin ();
simple_iterator simple_end ();
- simple_const_iterator simple_begin () const;
- simple_const_iterator simple_end () const;
multiple_iterator multiple_begin ();
multiple_iterator multiple_end ();
- multiple_const_iterator multiple_begin () const;
- multiple_const_iterator multiple_end () const;
/** Adds a SimpleChat to the Ekiga::Dialect.
* @param The SimpleChat to be added.
* @return: The Ekiga::Dialect 'simple_chat_added' signal is emitted.
*/
- void add_simple_chat (SimpleChatType* chat);
+ void add_simple_chat (gmref_ptr<SimpleChatType> chat);
/** Removes a SimpleChat from the Ekiga::Dialect.
* @param The SimpleChat to be removed.
*/
- void remove_simple_chat (SimpleChatType* chat);
+ void remove_simple_chat (gmref_ptr<SimpleChatType> chat);
/** Adds a MultipleChat to the Ekiga::Dialect.
* @param The MultipleChat to be added.
* @return: The Ekiga::Dialect 'multiple_chat_added' signal is emitted.
*/
- void add_multiple_chat (MultipleChatType* chat);
+ void add_multiple_chat (gmref_ptr<MultipleChatType> chat);
/** Removes a MultipleChat from the Ekiga::Dialect.
* @param The MultipleChat to be removed.
*/
- void remove_multiple_chat (MultipleChatType* chat);
+ void remove_multiple_chat (gmref_ptr<MultipleChatType> chat);
private:
- Lister<SimpleChatType> simple_chats;
- Lister<MultipleChatType> multiple_chats;
+ std::map<gmref_ptr<SimpleChatType>, std::list<sigc::connection> > simple_chats;
+ std::map<gmref_ptr<MultipleChatType>, std::list<sigc::connection> > multiple_chats;
};
};
@@ -125,20 +120,56 @@
template<typename SimpleChatType, typename MultipleChatType>
Ekiga::DialectImpl<SimpleChatType, MultipleChatType>::~DialectImpl ()
{
+ for (typename std::map<gmref_ptr<SimpleChatType>,std::list<sigc::connection> >::iterator iter = simple_chats.begin ();
+ iter != simple_chats.end ();
+ iter++) {
+
+ for (std::list<sigc::connection>::iterator conn_iter = iter->second.begin ();
+ conn_iter != iter->second.end ();
+ ++conn_iter) {
+
+ conn_iter->disconnect ();
+ }
+ }
+ for (typename std::map<gmref_ptr<MultipleChatType>,std::list<sigc::connection> >::iterator iter = multiple_chats.begin ();
+ iter != multiple_chats.end ();
+ iter++) {
+
+ for (std::list<sigc::connection>::iterator conn_iter = iter->second.begin ();
+ conn_iter != iter->second.end ();
+ ++conn_iter) {
+
+ conn_iter->disconnect ();
+ }
+ }
}
template<typename SimpleChatType, typename MultipleChatType>
void
-Ekiga::DialectImpl<SimpleChatType, MultipleChatType>::visit_simple_chats (sigc::slot1<bool, SimpleChat&> visitor)
+Ekiga::DialectImpl<SimpleChatType, MultipleChatType>::visit_simple_chats (sigc::slot1<bool, gmref_ptr<SimpleChat> > visitor)
{
- simple_chats.visit_objects (visitor);
+ bool go_on = true;
+
+ for (typename std::map<gmref_ptr<SimpleChatType>,std::list<sigc::connection> >::iterator iter = simple_chats.begin ();
+ go_on && iter != simple_chats.end ();
+ iter++) {
+
+ go_on = visitor (iter->first);
+ }
}
template<typename SimpleChatType, typename MultipleChatType>
void
-Ekiga::DialectImpl<SimpleChatType, MultipleChatType>::visit_multiple_chats (sigc::slot1<bool, MultipleChat&> visitor)
+Ekiga::DialectImpl<SimpleChatType, MultipleChatType>::visit_multiple_chats (sigc::slot1<bool, gmref_ptr<MultipleChat> > visitor)
{
- multiple_chats.visit_objects (visitor);
+ bool go_on = true;
+
+ for (typename std::map<gmref_ptr<MultipleChatType>,std::list<sigc::connection> >::iterator iter = multiple_chats.begin ();
+ go_on && iter != multiple_chats.end ();
+ iter++) {
+
+ go_on = visitor (iter->first);
+ }
}
template<typename SimpleChatType, typename MultipleChatType>
@@ -156,20 +187,6 @@
}
template<typename SimpleChatType, typename MultipleChatType>
-typename Ekiga::DialectImpl<SimpleChatType, MultipleChatType>::simple_const_iterator
-Ekiga::DialectImpl<SimpleChatType, MultipleChatType>::simple_begin () const
-{
- return simple_const_iterator (simple_chats.begin ());
-}
-
-template<typename SimpleChatType, typename MultipleChatType>
-typename Ekiga::DialectImpl<SimpleChatType, MultipleChatType>::simple_const_iterator
-Ekiga::DialectImpl<SimpleChatType, MultipleChatType>::simple_end () const
-{
- return simple_const_iterator (simple_chats.end ());
-}
-
-template<typename SimpleChatType, typename MultipleChatType>
typename Ekiga::DialectImpl<SimpleChatType, MultipleChatType>::multiple_iterator
Ekiga::DialectImpl<SimpleChatType, MultipleChatType>::multiple_begin ()
{
@@ -184,45 +201,31 @@
}
template<typename SimpleChatType, typename MultipleChatType>
-typename Ekiga::DialectImpl<SimpleChatType, MultipleChatType>::multiple_const_iterator
-Ekiga::DialectImpl<SimpleChatType, MultipleChatType>::multiple_begin () const
-{
- return multiple_const_iterator (multiple_chats.begin ());
-}
-
-template<typename SimpleChatType, typename MultipleChatType>
-typename Ekiga::DialectImpl<SimpleChatType, MultipleChatType>::multiple_const_iterator
-Ekiga::DialectImpl<SimpleChatType, MultipleChatType>::multiple_end () const
-{
- return multiple_const_iterator (multiple_chats.end ());
-}
-
-template<typename SimpleChatType, typename MultipleChatType>
void
-Ekiga::DialectImpl<SimpleChatType, MultipleChatType>::add_simple_chat (SimpleChatType* chat)
+Ekiga::DialectImpl<SimpleChatType, MultipleChatType>::add_simple_chat (gmref_ptr<SimpleChatType> chat)
{
- simple_chats.add_object (*chat);
- simple_chat_added.emit (*chat);
+ simple_chats[chat] = std::list<sigc::connection>();
+ simple_chat_added.emit (chat);
}
template<typename SimpleChatType, typename MultipleChatType>
void
-Ekiga::DialectImpl<SimpleChatType, MultipleChatType>::remove_simple_chat (SimpleChatType* chat)
+Ekiga::DialectImpl<SimpleChatType, MultipleChatType>::remove_simple_chat (gmref_ptr<SimpleChatType> chat)
{
/* FIXME */
}
template<typename SimpleChatType, typename MultipleChatType>
void
-Ekiga::DialectImpl<SimpleChatType, MultipleChatType>::add_multiple_chat (MultipleChatType* chat)
+Ekiga::DialectImpl<SimpleChatType, MultipleChatType>::add_multiple_chat (gmref_ptr<MultipleChatType> chat)
{
- multiple_chats.add_object (*chat);
- multiple_chat_added.emit (*chat);
+ multiple_chats[chat] = std::list<sigc::connection> ();
+ multiple_chat_added.emit (chat);
}
template<typename SimpleChatType, typename MultipleChatType>
void
-Ekiga::DialectImpl<SimpleChatType, MultipleChatType>::remove_multiple_chat (MultipleChatType* chat)
+Ekiga::DialectImpl<SimpleChatType, MultipleChatType>::remove_multiple_chat (gmref_ptr<MultipleChatType> chat)
{
/* FIXME */
}
Modified: trunk/lib/engine/chat/skel/dialect.h
==============================================================================
--- trunk/lib/engine/chat/skel/dialect.h (original)
+++ trunk/lib/engine/chat/skel/dialect.h Tue Nov 25 19:18:50 2008
@@ -43,7 +43,7 @@
namespace Ekiga
{
- class Dialect
+ class Dialect: public virtual GmRefCounted
{
public:
@@ -55,13 +55,13 @@
* @param: The callback (the return value means "go on" and allows
* stopping the visit)
*/
- virtual void visit_simple_chats (sigc::slot1<bool, SimpleChat&> visitor) = 0;
+ virtual void visit_simple_chats (sigc::slot1<bool, gmref_ptr<SimpleChat> > visitor) = 0;
/** Triggers a callback for all multiple chats of the Dialect.
* @param: The callback (the return value means "go on" and allows
* stopping the visit)
*/
- virtual void visit_multiple_chats (sigc::slot1<bool, MultipleChat&> visitor) = 0;
+ virtual void visit_multiple_chats (sigc::slot1<bool, gmref_ptr<MultipleChat> > visitor) = 0;
/** Feed possible actions on this Dialect to the given MenuBuilder
@@ -72,12 +72,12 @@
/** This signal is emitted when an Ekiga::SimpleChat has been added to
* the dialect.
*/
- sigc::signal1<void, SimpleChat&> simple_chat_added;
+ sigc::signal1<void, gmref_ptr<SimpleChat> > simple_chat_added;
/** This signal is emitted when an Ekiga::MultipleChat has been added to
* the dialect.
*/
- sigc::signal1<void, MultipleChat&> multiple_chat_added;
+ sigc::signal1<void, gmref_ptr<MultipleChat> > multiple_chat_added;
/** This chain allows the Dialect to present forms to the user.
*/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]