<div dir="ltr">Sorry did not send that on purpose, it appears the mailbox decided to send it to everybody instead of just the addressee. My bad.</div><div class="gmail_extra"><br><div class="gmail_quote">2017-04-26 19:28 GMT+02:00 Victorien Le Couviour--Tuffet <span dir="ltr"><<a href="mailto:victorien.lecouviour.tuffet@gmail.com" target="_blank">victorien.lecouviour.tuffet@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">From: William Ung <<a href="mailto:williamung@msn.com">williamung@msn.com</a>><br>
<br>
---<br>
<a href="http://configure.ac" rel="noreferrer" target="_blank">configure.ac</a> | 2 +-<br>
include/vlc_keystore.h | 7 +-<br>
modules/access/Makefile.am | 7 ++<br>
modules/access/cloudstorage.<wbr>cpp | 264 ++++++++++++++++++++++++++++++<wbr>++++++++++<br>
src/libvlccore.sym | 1 +<br>
src/misc/keystore.c | 4 +-<br>
6 files changed, 280 insertions(+), 5 deletions(-)<br>
create mode 100644 modules/access/cloudstorage.<wbr>cpp<br>
<br>
diff --git a/<a href="http://configure.ac" rel="noreferrer" target="_blank">configure.ac</a> b/<a href="http://configure.ac" rel="noreferrer" target="_blank">configure.ac</a><br>
index fde2dea..a0538a1 100644<br>
--- a/<a href="http://configure.ac" rel="noreferrer" target="_blank">configure.ac</a><br>
+++ b/<a href="http://configure.ac" rel="noreferrer" target="_blank">configure.ac</a><br>
@@ -2087,7 +2087,7 @@ dnl<br>
dnl matroska demux plugin<br>
dnl<br>
PKG_ENABLE_MODULES_VLC([<wbr>MATROSKA], [mkv], [libebml libmatroska], [MKV format support], [auto])<br>
-<br>
+PKG_ENABLE_MODULES_VLC([<wbr>CLOUDSTORAGE], [cloudstorage], [libcloudstorage], [cloudstorage access], [auto])<br>
dnl<br>
dnl modplug demux plugin<br>
dnl<br>
diff --git a/include/vlc_keystore.h b/include/vlc_keystore.h<br>
index 0af15eb..d081877 100644<br>
--- a/include/vlc_keystore.h<br>
+++ b/include/vlc_keystore.h<br>
@@ -15,7 +15,7 @@<br>
*<br>
* You should have received a copy of the GNU Lesser General Public License<br>
* along with this program; if not, write to the Free Software Foundation,<br>
- * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.<br>
+ * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.obj<br>
******************************<wbr>******************************<wbr>*****************/<br>
<br>
#ifndef VLC_KEYSTORE_H<br>
@@ -72,6 +72,9 @@ struct vlc_keystore_entry<br>
size_t i_secret_len;<br>
};<br>
<br>
+VLC_API vlc_keystore *<br>
+get_memory_keystore(vlc_<wbr>object_t *p_parent);<br>
+<br>
/**<br>
* Create a keystore object<br>
*<br>
@@ -117,7 +120,7 @@ vlc_keystore_store(vlc_<wbr>keystore *p_keystore,<br>
<br>
/**<br>
* Find all entries that match a set of key/values<br>
- *<br>
+ *<br>
* @param ppsz_values set of key/values, see vlc_keystore_key, any values can<br>
* be NULL<br>
* @param pp_entries list of found entries. To be released with<br>
diff --git a/modules/access/Makefile.am b/modules/access/Makefile.am<br>
index dd485a2..6b21a90 100644<br>
--- a/modules/access/Makefile.am<br>
+++ b/modules/access/Makefile.am<br>
@@ -313,6 +313,13 @@ endif<br>
<br>
### Network streams ###<br>
<br>
+libcloudstorage_plugin_la_<wbr>SOURCES = access/cloudstorage/<wbr>cloudstorage.cpp access/cloudstorage/<wbr>cloudstorage.h access/cloudstorage/callback.h<br>
+libcloudstorage_plugin_la_<wbr>CXXFLAGS = $(CXXFLAGS_cloudstorage) $(AM_CXXFLAGS)<br>
+libcloudstorage_plugin_la_<wbr>LIBADD = $(LIBS_cloudstorage)<br>
+libcloudstorage_plugin_la_<wbr>LDFLAGS = $(AM_LDFLAGS) -rpath '$(accessdir)'<br>
+access_LTLIBRARIES += $(LTLIBcloudstorage)<br>
+EXTRA_LTLIBRARIES += <a href="http://libcloudstorage_plugin.la" rel="noreferrer" target="_blank">libcloudstorage_plugin.la</a><br>
+<br>
libftp_plugin_la_SOURCES = access/ftp.c<br>
libftp_plugin_la_LIBADD = $(SOCKET_LIBS)<br>
access_LTLIBRARIES += <a href="http://libftp_plugin.la" rel="noreferrer" target="_blank">libftp_plugin.la</a><br>
diff --git a/modules/access/cloudstorage.<wbr>cpp b/modules/access/cloudstorage.<wbr>cpp<br>
new file mode 100644<br>
index 0000000..a3ea31d<br>
--- /dev/null<br>
+++ b/modules/access/cloudstorage.<wbr>cpp<br>
@@ -0,0 +1,264 @@<br>
+#ifdef HAVE_CONFIG_H<br>
+#include "config.h"<br>
+#endif /* HAVE_CONFIG_H */<br>
+<br>
+#include <cstdarg><br>
+#include <cstdlib><br>
+#include <iostream><br>
+#include <fstream><br>
+#include <mutex><br>
+#include <thread><br>
+#include <vector><br>
+#include <string><br>
+#include <memory><br>
+#include <condition_variable><br>
+<br>
+#include <ICloudProvider.h><br>
+#include <ICloudStorage.h><br>
+#include <IItem.h><br>
+#include <IRequest.h><br>
+<br>
+#include <vlc_common.h><br>
+#include <vlc_plugin.h><br>
+#include <vlc_access.h><br>
+#include <vlc_services_discovery.h><br>
+#include <vlc_keystore.h><br>
+<br>
+using namespace cloudstorage;<br>
+using cloudstorage::ICloudProvider;<br>
+using cloudstorage::<wbr>IDownloadFileCallback;<br>
+using cloudstorage::IItem;<br>
+<br>
+static int Open(vlc_object_t *);<br>
+static void Close(vlc_object_t *);<br>
+static int readDir(stream_t *, input_item_node_t *);<br>
+<br>
+vlc_module_begin()<br>
+set_shortname(N_("<wbr>cloudstorage"))<br>
+set_capability("access", 0)<br>
+set_description(N_("cloud input"))<br>
+set_category(CAT_INPUT)<br>
+set_subcategory(SUBCAT_INPUT_<wbr>ACCESS)<br>
+set_callbacks(Open, Close)<br>
+<br>
+vlc_module_end()<br>
+<br>
+/*<br>
+** private struct<br>
+*/<br>
+<br>
+struct access_sys_t<br>
+{<br>
+ using Pointer = std::shared_ptr<access_sys_t>;<br>
+<br>
+ ICloudProvider::Pointer provider_;<br>
+ std::string provider_name_;<br>
+ std::string token_;<br>
+<br>
+ vlc_keystore *p_keystore_;<br>
+ char *ppsz_values[KEY_MAX];<br>
+<br>
+ IItem::Pointer current_item_;<br>
+ std::vector<std::string> directory_stack_;<br>
+ std::vector<IItem::Pointer> directory_list_;<br>
+<br>
+ ICloudProvider::<wbr>ListDirectoryRequest::Pointer list_directory_request_;<br>
+<br>
+ std::mutex stream_mutex_;<br>
+ std::condition_variable stream_cv_;<br>
+<br>
+ access_sys_t(vlc_object_t *);<br>
+};<br>
+<br>
+/*<br>
+** Provider Callback<br>
+*/<br>
+<br>
+class Callback : public ICloudProvider::ICallback {<br>
+public:<br>
+ Callback(access_sys_t *sys)<br>
+ {<br>
+ p_sys = sys;<br>
+ }<br>
+<br>
+ Status userConsentRequired(const ICloudProvider& provider) override<br>
+ {<br>
+ std::cout << "User ConsentRequired at : " << provider.authorizeLibraryUrl() << std::endl;<br>
+ return Status::<wbr>WaitForAuthorizationCode;<br>
+ }<br>
+<br>
+ void accepted(const ICloudProvider& provider) override<br>
+ {<br>
+ p_sys->token_ = provider.token();<br>
+ vlc_keystore_remove(p_sys->p_<wbr>keystore_, p_sys->ppsz_values);<br>
+ vlc_keystore_store(p_sys->p_<wbr>keystore_, p_sys->ppsz_values, (const uint8_t *)p_sys->token_.c_str(), p_sys->token_.size(), p_sys->provider_name_.c_str())<wbr>;<br>
+ std::cout << "accepted" << std::endl;<br>
+ }<br>
+<br>
+ void declined(const ICloudProvider& provider) override<br>
+ {<br>
+ std::cout << "declined" << std::endl;<br>
+ }<br>
+<br>
+ void error(const ICloudProvider& provider, const std::string& desc) override<br>
+ {<br>
+ std::cout << "an error occured : " << desc << std::endl;<br>
+ }<br>
+ access_sys_t *p_sys;<br>
+};<br>
+<br>
+static void get_ppsz_values(char *ppsz_values[KEY_MAX], std::string provider_name)<br>
+{<br>
+ ppsz_values[KEY_PROTOCOL] = "cloudstorage";<br>
+ ppsz_values[KEY_USER] = "cloudstorage user";<br>
+ ppsz_values[KEY_SERVER] = "cloudstorage";<br>
+}<br>
+<br>
+access_sys_t::access_sys_t(<wbr>vlc_object_t *p_this)<br>
+{<br>
+ vlc_keystore_entry *p_entries;<br>
+<br>
+ p_keystore_ = get_memory_keystore(p_this);<br>
+ provider_name_ = "box";<br>
+ provider_ = cloudstorage::ICloudStorage::<wbr>create()->provider(provider_<wbr>name_);<br>
+ if (!provider_)<br>
+ return;<br>
+ VLC_KEYSTORE_VALUES_INIT(ppsz_<wbr>values);<br>
+ get_ppsz_values(ppsz_values, provider_name_);<br>
+<br>
+ if (vlc_keystore_find(p_keystore_<wbr>, ppsz_values, &p_entries) > 0)<br>
+ {<br>
+ std::cout << "cacaaaaa" << '\n';<br>
+ token_ = (char *)p_entries[0].p_secret;<br>
+ }<br>
+ provider_->initialize({token_, std::unique_ptr<Callback>(new Callback(this)), nullptr, nullptr, nullptr, {}});<br>
+ current_item_ = provider_->rootDirectory();<br>
+}<br>
+<br>
+static int Control(stream_t *p_access, int i_query, va_list args)<br>
+{<br>
+ switch (i_query)<br>
+ {<br>
+ case STREAM_IS_DIRECTORY:<br>
+ *va_arg(args, bool *) = p_access->pf_readdir == readDir;<br>
+ break;<br>
+<br>
+ default:<br>
+ return access_<wbr>vaDirectoryControlHelper( p_access, i_query, args );<br>
+ }<br>
+<br>
+ return VLC_SUCCESS;<br>
+}<br>
+<br>
+static int add_item(struct access_fsdir *p_fsdir, stream_t *p_access, IItem::Pointer item)<br>
+{<br>
+ int i_type;<br>
+ access_sys_t *p_sys = (access_sys_t*)p_access->p_<wbr>sys;<br>
+ ICloudProvider::Pointer provider = p_sys->provider_;<br>
+<br>
+ item->type() == IItem::FileType::Directory ? i_type = ITEM_TYPE_DIRECTORY : i_type = ITEM_TYPE_FILE;<br>
+ if (i_type == ITEM_TYPE_FILE)<br>
+ {<br>
+ item = provider->getItemDataAsync(<wbr>item->id())->result();<br>
+ return access_fsdir_additem(p_fsdir, item->url().c_str(), item->filename().c_str(), i_type, ITEM_NET);<br>
+ }<br>
+ else<br>
+ {<br>
+ std::string url = p_access->psz_url + item->filename() + "/";<br>
+ return access_fsdir_additem(p_fsdir, url.c_str(), item->filename().c_str(), i_type, ITEM_NET);<br>
+ }<br>
+}<br>
+<br>
+static int readDir(stream_t *p_access, input_item_node_t *p_node)<br>
+{<br>
+ access_sys_t *p_sys = (access_sys_t*)p_access->p_<wbr>sys;<br>
+ struct access_fsdir fsdir;<br>
+<br>
+<br>
+ p_sys->list_directory_request_ = p_sys->provider_-><wbr>listDirectoryAsync(p_sys-><wbr>current_item_);<br>
+ p_sys->directory_list_ = p_sys->list_directory_request_<wbr>->result();<br>
+ access_fsdir_init(&fsdir, p_access, p_node);<br>
+<br>
+ auto finish = [&](int error)<br>
+ {<br>
+ access_fsdir_finish(&fsdir, error);<br>
+ return error;<br>
+ };<br>
+<br>
+ for (auto &i : p_sys->directory_list_)<br>
+ if (add_item(&fsdir, p_access, i))<br>
+ return finish(VLC_EGENERIC);<br>
+ return finish(VLC_SUCCESS);<br>
+}<br>
+<br>
+std::vector<std::string> parseUrl(std::string url)<br>
+{<br>
+ std::vector<std::string> v;<br>
+<br>
+ url = url.substr(15);<br>
+ for (size_t i = 0; i < url.size(); ++i)<br>
+ {<br>
+ if (url[i] == '/')<br>
+ {<br>
+ v.push_back(url.substr(0, i));<br>
+ url = url.substr(i + 1);<br>
+ }<br>
+ }<br>
+ return v;<br>
+}<br>
+<br>
+static int getDir(stream_t *p_access, input_item_node_t *p_node)<br>
+{<br>
+ access_sys_t *p_sys = (access_sys_t*)p_access->p_<wbr>sys;<br>
+<br>
+ if (strcmp(p_access->psz_url, "cloudstorage://") == 0)<br>
+ readDir(p_access, p_node);<br>
+ else<br>
+ {<br>
+ p_sys->directory_stack_ = parseUrl(p_access->psz_url);<br>
+ for (auto &name : p_sys->directory_stack_)<br>
+ {<br>
+ p_sys->list_directory_request_ = p_sys->provider_-><wbr>listDirectoryAsync(p_sys-><wbr>current_item_);<br>
+ p_sys->directory_list_ = p_sys->list_directory_request_<wbr>->result();<br>
+ for (auto &item : p_sys->directory_list_)<br>
+ if (item->filename() == name)<br>
+ {<br>
+ p_sys->current_item_ = item;<br>
+ break;<br>
+ }<br>
+ }<br>
+ readDir(p_access, p_node);<br>
+ }<br>
+ return VLC_SUCCESS;<br>
+}<br>
+<br>
+static int Open(vlc_object_t *p_this)<br>
+{<br>
+ access_t *p_access = (access_t*)p_this;<br>
+ access_sys_t *p_sys;<br>
+<br>
+ p_access->p_sys = p_sys = new access_sys_t(p_this);<br>
+ if (p_sys == nullptr)<br>
+ return VLC_ENOMEM;<br>
+ p_access->pf_control = Control;<br>
+ p_access->pf_readdir = getDir;<br>
+ if (p_access->pf_control == nullptr<br>
+ || p_access->pf_readdir == nullptr<br>
+ || p_sys->p_keystore_ == nullptr)<br>
+ goto error;<br>
+ return VLC_SUCCESS;<br>
+<br>
+ error:<br>
+ Close(p_this);<br>
+ return VLC_EGENERIC;<br>
+}<br>
+<br>
+static void Close(vlc_object_t *p_this)<br>
+{<br>
+ access_t *p_access = (access_t*)p_this;<br>
+ access_sys_t *p_sys = (access_sys_t*)p_access->p_<wbr>sys;<br>
+<br>
+std::cout << "Close" << '\n';<br>
+ delete(p_sys);<br>
+ return;<br>
+}<br>
diff --git a/src/libvlccore.sym b/src/libvlccore.sym<br>
index 4cb7a22..25d01df 100644<br>
--- a/src/libvlccore.sym<br>
+++ b/src/libvlccore.sym<br>
@@ -591,6 +591,7 @@ vlc_ngettext<br>
vlc_iconv<br>
vlc_iconv_close<br>
vlc_iconv_open<br>
+get_memory_keystore<br>
vlc_keystore_create<br>
vlc_keystore_release<br>
vlc_keystore_find<br>
diff --git a/src/misc/keystore.c b/src/misc/keystore.c<br>
index 02537f0..c6096cf 100644<br>
--- a/src/misc/keystore.c<br>
+++ b/src/misc/keystore.c<br>
@@ -101,7 +101,7 @@ vlc_keystore_store(vlc_<wbr>keystore *p_keystore,<br>
}<br>
<br>
unsigned int<br>
-vlc_keystore_find(vlc_<wbr>keystore *p_keystore,<br>
+vlc_keystore_find(vlc_<wbr>keystore *p_keystore,<br>
const char * const ppsz_values[KEY_MAX],<br>
vlc_keystore_entry **pp_entries)<br>
{<br>
@@ -148,7 +148,7 @@ libvlc_InternalKeystoreClean(<wbr>libvlc_int_t *p_libvlc)<br>
}<br>
}<br>
<br>
-static vlc_keystore *<br>
+vlc_keystore *<br>
get_memory_keystore(vlc_<wbr>object_t *p_obj)<br>
{<br>
return libvlc_priv(p_obj->obj.libvlc)<wbr>->p_memory_keystore;<br>
<span class="HOEnZb"><font color="#888888">--<br>
2.7.4<br>
<br>
______________________________<wbr>_________________<br>
vlc-devel mailing list<br>
To unsubscribe or modify your subscription options:<br>
<a href="https://mailman.videolan.org/listinfo/vlc-devel" rel="noreferrer" target="_blank">https://mailman.videolan.org/<wbr>listinfo/vlc-devel</a><br>
</font></span></blockquote></div><br></div>