← Back to team overview

linuxdcpp-team team mailing list archive

[Branch ~dcplusplus-team/dcplusplus/trunk] Rev 3306: plugin API: get_path returns ConfigStrPtr for consistency

 

------------------------------------------------------------
revno: 3306
committer: poy <poy@xxxxxxxxxx>
branch nick: trunk
timestamp: Sun 2013-06-02 19:34:32 +0200
message:
  plugin API: get_path returns ConfigStrPtr for consistency
modified:
  dcpp/PluginApiImpl.cpp
  dcpp/PluginApiImpl.h
  dcpp/PluginDefs.h


--
lp:dcplusplus
https://code.launchpad.net/~dcplusplus-team/dcplusplus/trunk

Your team Dcplusplus-team is subscribed to branch lp:dcplusplus.
To unsubscribe from this branch go to https://code.launchpad.net/~dcplusplus-team/dcplusplus/trunk/+edit-subscription
=== modified file 'dcpp/PluginApiImpl.cpp'
--- dcpp/PluginApiImpl.cpp	2013-06-01 13:48:06 +0000
+++ dcpp/PluginApiImpl.cpp	2013-06-02 17:34:32 +0000
@@ -271,8 +271,10 @@
 }
 
 // Functions for DCConfig
-const char* DCAPI PluginApiImpl::getPath(PathType type) {
-	return Util::getPath(static_cast<Util::Paths>(type)).c_str();
+ConfigStrPtr DCAPI PluginApiImpl::getPath(PathType type) {
+	auto str = Util::getPath(static_cast<Util::Paths>(type));
+	ConfigStr value = { CFG_TYPE_STRING, str.c_str() };
+	return reinterpret_cast<ConfigStrPtr>(copyData(reinterpret_cast<ConfigValuePtr>(&value)));
 }
 
 ConfigStrPtr DCAPI PluginApiImpl::getInstallPath(const char* guid) {

=== modified file 'dcpp/PluginApiImpl.h'
--- dcpp/PluginApiImpl.h	2013-06-01 13:48:06 +0000
+++ dcpp/PluginApiImpl.h	2013-06-02 17:34:32 +0000
@@ -67,7 +67,7 @@
 	static size_t DCAPI releaseHook(subsHandle hHook);
 
 	// Functions For DCConfig
-	static const char* DCAPI getPath(PathType type);
+	static ConfigStrPtr DCAPI getPath(PathType type);
 	static ConfigStrPtr DCAPI getInstallPath(const char* guid);
 	static void DCAPI setConfig(const char* guid, const char* setting, ConfigValuePtr val);
 	static ConfigValuePtr DCAPI getConfig(const char* guid, const char* setting, ConfigType type);

=== modified file 'dcpp/PluginDefs.h'
--- dcpp/PluginDefs.h	2013-06-01 13:48:06 +0000
+++ dcpp/PluginDefs.h	2013-06-02 17:34:32 +0000
@@ -338,7 +338,7 @@
 	/* Config API version */
 	uint32_t apiVersion;
 
-	const char*			(DCAPI *get_path)			(PathType type);
+	ConfigStrPtr		(DCAPI *get_path)			(PathType type);
 	ConfigStrPtr		(DCAPI *get_install_path)	(const char* guid);
 
 	void				(DCAPI *set_cfg)			(const char* guid, const char* setting, ConfigValuePtr val);