summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThorsten Behrens <tbehrens@suse.com>2013-04-13 16:37:50 +0200
committerThorsten Behrens <tbehrens@suse.com>2013-04-13 16:38:55 +0200
commit565891c0441488bf4b169ddee1474478bdaa5fbc (patch)
tree5e14fc15291d1d630ba1506a88aefdcad0539e8f
parentslidesorter - cleanup redundant caches and notifications. (diff)
downloadcore-feature/slidehack.tar.gz
core-feature/slidehack.zip
Initial reading and parsing from webservice. feature/slidehack
Change-Id: I1637f8a8b21464e3883fd3dc8f6bb214dd58f6d0
-rw-r--r--sd/CppunitTest_sd_uimpress.mk1
-rw-r--r--sd/Library_sd.mk1
-rw-r--r--sd/source/core/slidehack.cxx67
-rw-r--r--sd/source/ui/dlg/GroupSlidesDialog.cxx2
4 files changed, 69 insertions, 2 deletions
diff --git a/sd/CppunitTest_sd_uimpress.mk b/sd/CppunitTest_sd_uimpress.mk
index 01883f38821a..23e5500b29e7 100644
--- a/sd/CppunitTest_sd_uimpress.mk
+++ b/sd/CppunitTest_sd_uimpress.mk
@@ -93,6 +93,7 @@ $(eval $(call gb_CppunitTest_use_externals,sd_uimpress,\
boost_headers \
gtk \
dbus \
+ curl \
))
$(eval $(call gb_CppunitTest_add_exception_objects,sd_uimpress,\
diff --git a/sd/Library_sd.mk b/sd/Library_sd.mk
index d4800bd66a94..e7ac01b6de65 100644
--- a/sd/Library_sd.mk
+++ b/sd/Library_sd.mk
@@ -112,6 +112,7 @@ $(eval $(call gb_Library_use_externals,sd,\
boost_headers \
libxml2 \
dbus \
+ curl \
))
ifeq ($(OS),WNT)
diff --git a/sd/source/core/slidehack.cxx b/sd/source/core/slidehack.cxx
index 9a586a457ee7..522b317007c1 100644
--- a/sd/source/core/slidehack.cxx
+++ b/sd/source/core/slidehack.cxx
@@ -9,6 +9,13 @@
#include "slidehack.hxx"
+#include <boost/property_tree/ptree.hpp>
+#include <boost/property_tree/json_parser.hpp>
+
+#include <curl/curl.h>
+
+using boost::property_tree::ptree;
+
namespace SlideHack {
namespace {
@@ -37,10 +44,68 @@ public:
}
};
+static size_t read_function( void* data, size_t item_size, size_t num_members, void* user_data )
+{
+ if( num_members )
+ {
+ std::string* pBuffer=(std::string*)user_data;
+ pBuffer->append( (const char*)data, item_size*num_members );
+ }
+ return item_size * num_members;
+}
+
+static boost::shared_ptr<ptree> read_data( CURL* pCurl, const char* url)
+{
+ std::string buffer;
+ curl_easy_setopt( pCurl, CURLOPT_NOPROGRESS, 1 );
+ curl_easy_setopt( pCurl, CURLOPT_WRITEFUNCTION, read_function );
+ curl_easy_setopt( pCurl, CURLOPT_WRITEDATA, &buffer );
+ curl_easy_setopt( pCurl, CURLOPT_URL, url );
+ curl_easy_setopt( pCurl, CURLOPT_FOLLOWLOCATION, 1);
+ curl_easy_setopt( pCurl, CURLOPT_MAXREDIRS, 100);
+ curl_easy_setopt( pCurl, CURLOPT_SSL_VERIFYPEER, 0);
+ curl_easy_setopt( pCurl, CURLOPT_SSL_VERIFYHOST, 0);
+#if OSL_DEBUG_LEVEL > 2
+ curl_easy_setopt( pCurl, CURLOPT_VERBOSE, 0);
+#endif
+
+ if( !curl_easy_perform( pCurl ) )
+ {
+ boost::shared_ptr<ptree> res(new boost::property_tree::ptree);
+ std::istringstream stream(buffer);
+ boost::property_tree::read_json(stream, *res);
+
+ return res;
+ }
+
+ return boost::shared_ptr<ptree>();
+}
+
class StoreImpl : public Store {
+ std::vector<OString> m_userList;
+ std::vector<OString> m_tagList;
+ CURL* m_pCurl;
+
public:
- StoreImpl()
+ StoreImpl() :
+ m_pCurl(NULL)
+ {
+ curl_global_init( CURL_GLOBAL_ALL );
+ m_pCurl = curl_easy_init( );
+
+ boost::shared_ptr<ptree> users = read_data( m_pCurl, "https://localhost:8080/api/users/" );
+ for( ptree::const_iterator i=users->begin(); i != users->end(); ++i )
+ m_userList.push_back( i->first.c_str() );
+
+ boost::shared_ptr<ptree> tags = read_data( m_pCurl, "https://localhost:8080/api/tags/" );
+ for( ptree::const_iterator i=tags->begin(); i != tags->end(); ++i )
+ m_tagList.push_back( i->first.c_str() );
+ }
+
+ ~StoreImpl()
{
+ if ( NULL != m_pCurl )
+ curl_easy_cleanup( m_pCurl );
}
virtual sal_uInt32 search( OUString aSearchEntry )
diff --git a/sd/source/ui/dlg/GroupSlidesDialog.cxx b/sd/source/ui/dlg/GroupSlidesDialog.cxx
index d433467b8f53..59dd875e3a56 100644
--- a/sd/source/ui/dlg/GroupSlidesDialog.cxx
+++ b/sd/source/ui/dlg/GroupSlidesDialog.cxx
@@ -89,7 +89,7 @@ SdGroupSlidesDialog::~SdGroupSlidesDialog()
IMPL_LINK_NOARG(SdGroupSlidesDialog, AddHdl)
{
SAL_DEBUG("Add to group");
- EndDialog(0);
+ endDialog(true);
return 0;
}