[ekiga] Worked on the LDAP code, for a better BookInfo use
- From: Julien Puydt <jpuydt src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ekiga] Worked on the LDAP code, for a better BookInfo use
- Date: Thu, 10 Feb 2011 17:16:38 +0000 (UTC)
commit cc8640e9b016c1a347d2860991ae51153ea37e3a
Author: Snark <jpuydt gnome org>
Date: Thu Feb 10 18:18:15 2011 +0100
Worked on the LDAP code, for a better BookInfo use
It's now used as local variables, and I made sure the urld member
gets properly managed -- I think we were leaking some before.
This fixes bug #641958
plugins/ldap/ldap-book.cpp | 7 ++-----
plugins/ldap/ldap-book.h | 9 +++++++--
plugins/ldap/ldap-source.cpp | 14 +++++++-------
plugins/ldap/ldap-source.h | 4 +---
4 files changed, 17 insertions(+), 17 deletions(-)
---
diff --git a/plugins/ldap/ldap-book.cpp b/plugins/ldap/ldap-book.cpp
index 9c8596d..db82292 100644
--- a/plugins/ldap/ldap-book.cpp
+++ b/plugins/ldap/ldap-book.cpp
@@ -187,7 +187,6 @@ OPENLDAP::Book::Book (Ekiga::ServiceCore &_core,
bookinfo.authcID = "";
bookinfo.password = "";
bookinfo.saslMech = "";
- bookinfo.urld = NULL;
bookinfo.sasl = false;
bookinfo.starttls = false;
@@ -371,7 +370,6 @@ OPENLDAP::Book::Book (Ekiga::ServiceCore &_core,
OPENLDAP::Book::~Book ()
{
- if (bookinfo.urld) ldap_free_urldesc(bookinfo.urld);
}
void
@@ -393,7 +391,7 @@ OPENLDAP::BookInfoParse (struct BookInfo &info)
}
}
}
- info.urld = url_tmp;
+ info.urld = boost::shared_ptr<LDAPURLDesc> (url_tmp, ldap_url_desc_deleter ());
pos = info.uri.find ('/', strlen(info.urld->lud_scheme) + 3);
if (pos != std::string::npos)
info.uri_host = info.uri.substr (0,pos);
@@ -1077,8 +1075,7 @@ OPENLDAP::BookFormInfo (Ekiga::Form &result,
url_base->lud_filter = NULL;
ldap_free_urldesc (url_base);
- if (bookinfo.urld) ldap_free_urldesc (bookinfo.urld);
- bookinfo.urld = url_host;
+ bookinfo.urld = boost::shared_ptr<LDAPURLDesc> (url_host, ldap_url_desc_deleter ());
url_str = ldap_url_desc2str (url_host);
bookinfo.uri = std::string(url_str);
ldap_memfree (url_str);
diff --git a/plugins/ldap/ldap-book.h b/plugins/ldap/ldap-book.h
index a0a22a8..bb1ea09 100644
--- a/plugins/ldap/ldap-book.h
+++ b/plugins/ldap/ldap-book.h
@@ -56,6 +56,11 @@
namespace OPENLDAP
{
+ struct ldap_url_desc_deleter
+ {
+ void operator() (LDAPURLDesc* p)
+ { if (p) ldap_free_urldesc (p); }
+ };
struct BookInfo {
std::string name;
@@ -64,7 +69,7 @@ namespace OPENLDAP
std::string authcID;
std::string password;
std::string saslMech;
- LDAPURLDesc *urld;
+ boost::shared_ptr<LDAPURLDesc> urld;
bool sasl;
bool starttls;
};
@@ -74,7 +79,7 @@ namespace OPENLDAP
std::string title );
int BookFormInfo (Ekiga::Form &result, struct BookInfo &info,
- std::string &errmsg);
+ std::string &errmsg);
void BookInfoParse (struct BookInfo &info);
diff --git a/plugins/ldap/ldap-source.cpp b/plugins/ldap/ldap-source.cpp
index 28631f9..2da1c06 100644
--- a/plugins/ldap/ldap-source.cpp
+++ b/plugins/ldap/ldap-source.cpp
@@ -104,7 +104,7 @@ OPENLDAP::Source::add (xmlNodePtr node)
}
void
-OPENLDAP::Source::add ()
+OPENLDAP::Source::add (struct BookInfo bookinfo)
{
xmlNodePtr root;
@@ -121,6 +121,7 @@ OPENLDAP::Source::common_add (BookPtr book)
{
book->trigger_saving.connect (boost::bind (&OPENLDAP::Source::save, this));
add_book (book);
+ save ();
}
bool
@@ -137,13 +138,13 @@ void
OPENLDAP::Source::new_book ()
{
boost::shared_ptr<Ekiga::FormRequestSimple> request = boost::shared_ptr<Ekiga::FormRequestSimple> (new Ekiga::FormRequestSimple (boost::bind (&OPENLDAP::Source::on_new_book_form_submitted, this, _1, _2)));
+ struct BookInfo bookinfo;
bookinfo.name = "";
bookinfo.uri = "ldap://localhost/dc=net?cn,telephoneNumber?sub?(cn=$)";
bookinfo.authcID = "";
bookinfo.password = "";
bookinfo.saslMech = "";
- bookinfo.urld = NULL;
bookinfo.sasl = false;
bookinfo.starttls = false;
@@ -156,18 +157,17 @@ OPENLDAP::Source::new_book ()
void
OPENLDAP::Source::new_ekiga_net_book ()
{
+ struct BookInfo bookinfo;
bookinfo.name = _("Ekiga.net Directory");
bookinfo.uri =
"ldap://ekiga.net/dc=ekiga,dc=net?givenName,telephoneNumber?sub?(cn=$)";
bookinfo.authcID = "";
bookinfo.password = "";
bookinfo.saslMech = "";
- bookinfo.urld = NULL;
bookinfo.sasl = false;
bookinfo.starttls = false;
- add ();
- save ();
+ add (bookinfo);
}
void
@@ -178,6 +178,7 @@ OPENLDAP::Source::on_new_book_form_submitted (bool submitted,
return;
std::string errmsg;
+ struct BookInfo bookinfo;
if (OPENLDAP::BookFormInfo (result, bookinfo, errmsg)) {
boost::shared_ptr<Ekiga::FormRequestSimple> request = boost::shared_ptr<Ekiga::FormRequestSimple> (new Ekiga::FormRequestSimple (boost::bind (&OPENLDAP::Source::on_new_book_form_submitted, this, _1, _2)));
@@ -189,8 +190,7 @@ OPENLDAP::Source::on_new_book_form_submitted (bool submitted,
return;
}
- add ();
- save ();
+ add (bookinfo);
}
void
diff --git a/plugins/ldap/ldap-source.h b/plugins/ldap/ldap-source.h
index 4259b33..c94015c 100644
--- a/plugins/ldap/ldap-source.h
+++ b/plugins/ldap/ldap-source.h
@@ -78,11 +78,9 @@ namespace OPENLDAP
Ekiga::ServiceCore &core;
boost::shared_ptr<xmlDoc> doc;
- struct BookInfo bookinfo;
-
void add (xmlNodePtr node);
- void add ();
+ void add (struct BookInfo bookinfo);
void common_add (BookPtr book);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]