r3321 - in trunk: libmnetutil libmnetutil/include libmnetutil/include/libmnetutil libmnetutil/source libmutil/include/libmutil

mikaelsv at minisip.org mikaelsv at minisip.org
Thu Jun 14 15:13:18 CEST 2007


Author: mikaelsv
Date: 2007-06-14 15:13:18 +0200 (Thu, 14 Jun 2007)
New Revision: 3321

Modified:
   trunk/libmnetutil/Makefile.am
   trunk/libmnetutil/include/Makefile.am
   trunk/libmnetutil/include/libmnetutil/LdapConnection.h
   trunk/libmnetutil/include/libmnetutil/LdapEntry.h
   trunk/libmnetutil/source/Downloader.cxx
   trunk/libmnetutil/source/HttpDownloader.cxx
   trunk/libmnetutil/source/LdapConnection.cxx
   trunk/libmnetutil/source/LdapUrl.cxx
   trunk/libmutil/include/libmutil/stringutils.h
Log:
* Added LdapDownloader class to match the HttpDownloader class
   - These two classes have the char* getChars(int*) function in common
     but are otherwise very different
* Added support in Downloader to create/return LdapDownloader objects
* Added some getters and setters to LdapUrl



Modified: trunk/libmnetutil/Makefile.am
===================================================================
--- trunk/libmnetutil/Makefile.am	2007-06-14 12:25:18 UTC (rev 3320)
+++ trunk/libmnetutil/Makefile.am	2007-06-14 13:13:18 UTC (rev 3321)
@@ -38,7 +38,8 @@
 		    source/LdapConnection.cxx \
                     source/LdapEntry.cxx \
                     source/LdapException.cxx \
-		    source/LdapUrl.cxx
+		    source/LdapUrl.cxx \
+		    source/LdapDownloader.cxx
 endif
 
 mnetutil_src = \

Modified: trunk/libmnetutil/include/Makefile.am
===================================================================
--- trunk/libmnetutil/include/Makefile.am	2007-06-14 12:25:18 UTC (rev 3320)
+++ trunk/libmnetutil/include/Makefile.am	2007-06-14 13:13:18 UTC (rev 3321)
@@ -26,7 +26,8 @@
 			libmnetutil/DatagramSocket.h \
 			libmnetutil/libmnetutil_config.h \
 			libmnetutil/Downloader.h \
-			libmnetutil/HttpDownloader.h
+			libmnetutil/HttpDownloader.h \
+			libmnetutil/LdapDownloader.h
 
 noinst_HEADERS = 	\
 			config.h \

Modified: trunk/libmnetutil/include/libmnetutil/LdapConnection.h
===================================================================
--- trunk/libmnetutil/include/libmnetutil/LdapConnection.h	2007-06-14 12:25:18 UTC (rev 3320)
+++ trunk/libmnetutil/include/libmnetutil/LdapConnection.h	2007-06-14 13:13:18 UTC (rev 3321)
@@ -39,8 +39,8 @@
  */
 class LdapConnection : public MObject {
 	public:
-		LdapConnection(std::string host, int port);
-		LdapConnection(std::string host, int port, MRef<LdapCredentials*> cred);
+		LdapConnection(std::string host, int32_t port);
+		LdapConnection(std::string host, int32_t port, MRef<LdapCredentials*> cred);
 		LdapConnection(std::string host);
 		LdapConnection(std::string host, MRef<LdapCredentials*> cred);
 		~LdapConnection();
@@ -99,7 +99,7 @@
 	private:
 		LDAP* 			ld;
 		std::string 		hostname;
-		int 			port;
+		int32_t			port;
 		MRef<LdapCredentials*> 	cred;
 
 		/**

Modified: trunk/libmnetutil/include/libmnetutil/LdapEntry.h
===================================================================
--- trunk/libmnetutil/include/libmnetutil/LdapEntry.h	2007-06-14 12:25:18 UTC (rev 3320)
+++ trunk/libmnetutil/include/libmnetutil/LdapEntry.h	2007-06-14 13:13:18 UTC (rev 3321)
@@ -75,7 +75,7 @@
 		/**
 		 * Return THE FIRST string value for a given attribute.
 		 */
-		std::string			getAttrValueString(std::string attr) throw (LdapAttributeNotFoundException);
+		std::string getAttrValueString(std::string attr) throw (LdapAttributeNotFoundException);
 
 		/**
 		 * Return all binary values for a given attribute.
@@ -85,24 +85,24 @@
 		/**
 		 * Return ALL string values for a given attribute.
 		 */
-		std::vector<std::string>	getAttrValuesStrings(std::string attr) throw (LdapAttributeNotFoundException);
+		std::vector<std::string> getAttrValuesStrings(std::string attr) throw (LdapAttributeNotFoundException);
 
 		/**
 		 * Specialized method that returns all certificate pair attribute values (given a specific attribute name).
 		 */
-		std::vector<MRef<certificate_pair*> >	getAttrValuesCertificatePairs(std::string attr) throw (LdapAttributeNotFoundException);
+		std::vector<MRef<certificate_pair*> > getAttrValuesCertificatePairs(std::string attr) throw (LdapAttributeNotFoundException);
 
-		//std::string 			getDn();
+		//std::string getDn();
 
 		/**
 		 * Returns list of all attribute names.
 		 */
-		std::vector<std::string> 	getAttrNames();
+		std::vector<std::string> getAttrNames();
 
 		/**
 		 * Tests if the directory entry/object has a specific attribute.
 		 */
-		bool 				hasAttribute(std::string attr);
+		bool hasAttribute(std::string attr);
 	private:
 		std::map<std::string, std::vector<MRef<LdapEntryBinaryValue*> > > valuesBinary;
 		std::map<std::string, std::vector<std::string> > valuesStrings;

Modified: trunk/libmnetutil/source/Downloader.cxx
===================================================================
--- trunk/libmnetutil/source/Downloader.cxx	2007-06-14 12:25:18 UTC (rev 3320)
+++ trunk/libmnetutil/source/Downloader.cxx	2007-06-14 13:13:18 UTC (rev 3321)
@@ -1,5 +1,6 @@
 #include <libmnetutil/Downloader.h>
 #include <libmnetutil/HttpDownloader.h>
+#include <libmnetutil/LdapDownloader.h>
 #include <string>
 
 MRef<Downloader*> Downloader::create(std::string const uri) {
@@ -8,6 +9,8 @@
 		std::string protocol = uri.substr(0, pos);
 		if (protocol == "http")
 			return MRef<Downloader*>(dynamic_cast<Downloader*>(new HttpDownloader(uri)));
+		else if (protocol == "ldap")
+			return MRef<Downloader*>(dynamic_cast<Downloader*>(new LdapDownloader(uri)));
 	}
 	return MRef<Downloader*>();
 }

Modified: trunk/libmnetutil/source/HttpDownloader.cxx
===================================================================
--- trunk/libmnetutil/source/HttpDownloader.cxx	2007-06-14 12:25:18 UTC (rev 3320)
+++ trunk/libmnetutil/source/HttpDownloader.cxx	2007-06-14 13:13:18 UTC (rev 3321)
@@ -39,6 +39,7 @@
 
 char* HttpDownloader::getChars(int *length) {
 	int tries = 3;
+	*length = 0;
 	while (tries) {
 		std::ostringstream body;
 		int fetchRes = fetch(buildRequestString("GET ", remoteFile), body);

Modified: trunk/libmnetutil/source/LdapConnection.cxx
===================================================================
--- trunk/libmnetutil/source/LdapConnection.cxx	2007-06-14 12:25:18 UTC (rev 3320)
+++ trunk/libmnetutil/source/LdapConnection.cxx	2007-06-14 13:13:18 UTC (rev 3321)
@@ -1,10 +1,10 @@
 #include <libmnetutil/LdapConnection.h>
 
-LdapConnection::LdapConnection(std::string host, int port) : hostname(host), port(port), ld(NULL), isBound(false) {
+LdapConnection::LdapConnection(std::string host, int32_t port) : hostname(host), port(port), ld(NULL), isBound(false) {
 }
 LdapConnection::LdapConnection(std::string host) : hostname(host), port(LDAP_PORT), ld(NULL), isBound(false) {
 }
-LdapConnection::LdapConnection(std::string host, int port, MRef<LdapCredentials*> cred) : hostname(host), port(port), ld(NULL), isBound(false) {
+LdapConnection::LdapConnection(std::string host, int32_t port, MRef<LdapCredentials*> cred) : hostname(host), port(port), ld(NULL), isBound(false) {
 	setCredentials(cred);
 	try {
 		connect();

Modified: trunk/libmnetutil/source/LdapUrl.cxx
===================================================================
--- trunk/libmnetutil/source/LdapUrl.cxx	2007-06-14 12:25:18 UTC (rev 3320)
+++ trunk/libmnetutil/source/LdapUrl.cxx	2007-06-14 13:13:18 UTC (rev 3321)
@@ -24,6 +24,10 @@
 	extensions = std::vector<LdapUrlExtension>();
 }
 
+bool LdapUrl::isValid() {
+	return validUrl;
+}
+
 std::string LdapUrl::getString() const {
 
 	// Start off with the schema and host name
@@ -200,7 +204,52 @@
 			return true;
 	return false;
 }
+std::string LdapUrl::getHost() const {
+	return host;
+}
+void LdapUrl::setHost(std::string host) {
+	this->host = host;
+}
 
+int32_t LdapUrl::getPort() const {
+	return port;
+}
+void LdapUrl::setPort(int32_t port) {
+	this->port = port;
+}
+
+std::vector<std::string> LdapUrl::getAttributes() const {
+	return attributes;
+}
+void LdapUrl::setAttributes(std::vector<std::string> attributes) {
+	this->attributes = attributes;
+}
+
+std::vector<LdapUrlExtension> LdapUrl::getExtensions() const {
+	return extensions;
+}
+
+std::string LdapUrl::getFilter() const {
+	return filter;
+}
+void LdapUrl::setFilter(std::string filter) {
+	this->filter = filter;
+}
+
+std::string LdapUrl::getDn() const {
+	return dn;
+}
+void LdapUrl::setDn(std::string dn) {
+	this->dn = dn;
+}
+
+int32_t LdapUrl::getScope() const {
+	return scope;
+}
+void LdapUrl::setScope(int32_t scope) {
+	this->scope = scope;
+}
+
 std::string LdapUrl::encodeChar(const char in) const {
 	std::string res;
 	res += '%';

Modified: trunk/libmutil/include/libmutil/stringutils.h
===================================================================
--- trunk/libmutil/include/libmutil/stringutils.h	2007-06-14 12:25:18 UTC (rev 3320)
+++ trunk/libmutil/include/libmutil/stringutils.h	2007-06-14 13:13:18 UTC (rev 3321)
@@ -107,6 +107,9 @@
 			     const std::basic_string<charT, traits, Alloc>& s2,
 			     const std::locale& loc );
 
+/**
+ * Tests if "haystack" ends with "needle".
+ */
 LIBMUTIL_API bool stringEndsWith(const std::string & haystack, const std::string & needle);
 
 #endif



More information about the Minisip-devel mailing list