Blame SOURCES/0001-munge-cmis-headers-to-remove-exception-specs.patch

9317df
From 9300cfc3cab41e0ba50eb515792286932dbcbe1e Mon Sep 17 00:00:00 2001
9317df
From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= <caolanm@redhat.com>
9317df
Date: Mon, 26 Oct 2020 19:41:16 +0000
9317df
Subject: [PATCH] munge cmis headers to remove exception specs
9317df
9317df
Change-Id: Ieea3838f4acbaabd8ee5c219a69967889292a5ca
9317df
---
9317df
 include/libcmis/allowable-actions.hxx | 130 +++++++++++++++
9317df
 include/libcmis/document.hxx          | 146 +++++++++++++++++
9317df
 include/libcmis/exception.hxx         |  60 +++++++
9317df
 include/libcmis/folder.hxx            |  83 ++++++++++
9317df
 include/libcmis/libcmis.hxx           |  47 ++++++
9317df
 include/libcmis/oauth2-data.hxx       |  76 +++++++++
9317df
 include/libcmis/object-type.hxx       | 143 +++++++++++++++++
9317df
 include/libcmis/object.hxx            | 217 ++++++++++++++++++++++++++
9317df
 include/libcmis/property-type.hxx     | 125 +++++++++++++++
9317df
 include/libcmis/property.hxx          |  88 +++++++++++
9317df
 include/libcmis/rendition.hxx         |  88 +++++++++++
9317df
 include/libcmis/repository.hxx        | 117 ++++++++++++++
9317df
 include/libcmis/session-factory.hxx   | 149 ++++++++++++++++++
9317df
 include/libcmis/session.hxx           | 100 ++++++++++++
9317df
 include/libcmis/xml-utils.hxx         | 167 ++++++++++++++++++++
9317df
 include/libcmis/xmlserializable.hxx   |  46 ++++++
9317df
 16 files changed, 1782 insertions(+)
9317df
 create mode 100644 include/libcmis/allowable-actions.hxx
9317df
 create mode 100644 include/libcmis/document.hxx
9317df
 create mode 100644 include/libcmis/exception.hxx
9317df
 create mode 100644 include/libcmis/folder.hxx
9317df
 create mode 100644 include/libcmis/libcmis.hxx
9317df
 create mode 100644 include/libcmis/oauth2-data.hxx
9317df
 create mode 100644 include/libcmis/object-type.hxx
9317df
 create mode 100644 include/libcmis/object.hxx
9317df
 create mode 100644 include/libcmis/property-type.hxx
9317df
 create mode 100644 include/libcmis/property.hxx
9317df
 create mode 100644 include/libcmis/rendition.hxx
9317df
 create mode 100644 include/libcmis/repository.hxx
9317df
 create mode 100644 include/libcmis/session-factory.hxx
9317df
 create mode 100644 include/libcmis/session.hxx
9317df
 create mode 100644 include/libcmis/xml-utils.hxx
9317df
 create mode 100644 include/libcmis/xmlserializable.hxx
9317df
9317df
diff --git a/include/libcmis/allowable-actions.hxx b/include/libcmis/allowable-actions.hxx
9317df
new file mode 100644
9317df
index 000000000000..24998761d10f
9317df
--- /dev/null
9317df
+++ b/include/libcmis/allowable-actions.hxx
9317df
@@ -0,0 +1,130 @@
9317df
+/* libcmis
9317df
+ * Version: MPL 1.1 / GPLv2+ / LGPLv2+
9317df
+ *
9317df
+ * The contents of this file are subject to the Mozilla Public License Version
9317df
+ * 1.1 (the "License"); you may not use this file except in compliance with
9317df
+ * the License or as specified alternatively below. You may obtain a copy of
9317df
+ * the License at http://www.mozilla.org/MPL/
9317df
+ *
9317df
+ * Software distributed under the License is distributed on an "AS IS" basis,
9317df
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
9317df
+ * for the specific language governing rights and limitations under the
9317df
+ * License.
9317df
+ *
9317df
+ * Major Contributor(s):
9317df
+ * Copyright (C) 2011 SUSE <cbosdonnat@suse.com>
9317df
+ *
9317df
+ *
9317df
+ * All Rights Reserved.
9317df
+ *
9317df
+ * For minor contributions see the git repository.
9317df
+ *
9317df
+ * Alternatively, the contents of this file may be used under the terms of
9317df
+ * either the GNU General Public License Version 2 or later (the "GPLv2+"), or
9317df
+ * the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"),
9317df
+ * in which case the provisions of the GPLv2+ or the LGPLv2+ are applicable
9317df
+ * instead of those above.
9317df
+ */
9317df
+#ifndef _ALLOWABLE_ACTIONS_HXX_
9317df
+#define _ALLOWABLE_ACTIONS_HXX_
9317df
+
9317df
+#include <map>
9317df
+#include <string>
9317df
+
9317df
+#include <boost/shared_ptr.hpp>
9317df
+#include <libxml/tree.h>
9317df
+
9317df
+#include "exception.hxx"
9317df
+
9317df
+namespace libcmis
9317df
+{
9317df
+    class Object;
9317df
+
9317df
+    class ObjectAction
9317df
+    {
9317df
+        public:
9317df
+            enum Type
9317df
+            {
9317df
+                DeleteObject,
9317df
+                UpdateProperties,
9317df
+                GetFolderTree,
9317df
+                GetProperties,
9317df
+                GetObjectRelationships,
9317df
+                GetObjectParents,
9317df
+                GetFolderParent,
9317df
+                GetDescendants,
9317df
+                MoveObject,
9317df
+                DeleteContentStream,
9317df
+                CheckOut,
9317df
+                CancelCheckOut,
9317df
+                CheckIn,
9317df
+                SetContentStream,
9317df
+                GetAllVersions,
9317df
+                AddObjectToFolder,
9317df
+                RemoveObjectFromFolder,
9317df
+                GetContentStream,
9317df
+                ApplyPolicy,
9317df
+                GetAppliedPolicies,
9317df
+                RemovePolicy,
9317df
+                GetChildren,
9317df
+                CreateDocument,
9317df
+                CreateFolder,
9317df
+                CreateRelationship,
9317df
+                DeleteTree,
9317df
+                GetRenditions,
9317df
+                GetACL,
9317df
+                ApplyACL
9317df
+            };
9317df
+
9317df
+        private:
9317df
+            Type m_type;
9317df
+            bool m_enabled;
9317df
+            bool m_valid;
9317df
+
9317df
+        public:
9317df
+            ObjectAction( xmlNodePtr node );
9317df
+            virtual ~ObjectAction( ){ }
9317df
+
9317df
+            Type getType( ) { return m_type; }
9317df
+            bool isEnabled( ) { return m_enabled; }
9317df
+            bool isValid( ) { return m_valid; }
9317df
+
9317df
+            /** Parses the permission name into one of the enum values or throws
9317df
+                an exception for invalid input strings.
9317df
+              */
9317df
+            static Type parseType( std::string type );
9317df
+
9317df
+    };
9317df
+
9317df
+    /** Class providing access to the allowed actions on an object.
9317df
+      */
9317df
+    class AllowableActions
9317df
+    {
9317df
+        protected:
9317df
+            std::map< ObjectAction::Type, bool > m_states;
9317df
+
9317df
+        public:
9317df
+            /** Default constructor for testing purpose
9317df
+              */
9317df
+            AllowableActions( );
9317df
+            AllowableActions( xmlNodePtr node );
9317df
+            AllowableActions( const AllowableActions& copy );
9317df
+            virtual ~AllowableActions( );
9317df
+
9317df
+            AllowableActions& operator=( const AllowableActions& copy );
9317df
+
9317df
+            /** Returns the permissions for the corresponding actions.
9317df
+              */
9317df
+            bool isAllowed( ObjectAction::Type action );
9317df
+
9317df
+            /** Returns true if the action was defined, false if the default
9317df
+                value is used.
9317df
+              */
9317df
+            bool isDefined( ObjectAction::Type action );
9317df
+
9317df
+            std::string toString( );
9317df
+    };
9317df
+    typedef boost::shared_ptr< AllowableActions > AllowableActionsPtr;
9317df
+}
9317df
+
9317df
+#endif
9317df
diff --git a/include/libcmis/document.hxx b/include/libcmis/document.hxx
9317df
new file mode 100644
9317df
index 000000000000..ce123b081efb
9317df
--- /dev/null
9317df
+++ b/include/libcmis/document.hxx
9317df
@@ -0,0 +1,146 @@
9317df
+/* libcmis
9317df
+ * Version: MPL 1.1 / GPLv2+ / LGPLv2+
9317df
+ *
9317df
+ * The contents of this file are subject to the Mozilla Public License Version
9317df
+ * 1.1 (the "License"); you may not use this file except in compliance with
9317df
+ * the License or as specified alternatively below. You may obtain a copy of
9317df
+ * the License at http://www.mozilla.org/MPL/
9317df
+ *
9317df
+ * Software distributed under the License is distributed on an "AS IS" basis,
9317df
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
9317df
+ * for the specific language governing rights and limitations under the
9317df
+ * License.
9317df
+ *
9317df
+ * Major Contributor(s):
9317df
+ * Copyright (C) 2011 SUSE <cbosdonnat@suse.com>
9317df
+ *
9317df
+ *
9317df
+ * All Rights Reserved.
9317df
+ *
9317df
+ * For minor contributions see the git repository.
9317df
+ *
9317df
+ * Alternatively, the contents of this file may be used under the terms of
9317df
+ * either the GNU General Public License Version 2 or later (the "GPLv2+"), or
9317df
+ * the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"),
9317df
+ * in which case the provisions of the GPLv2+ or the LGPLv2+ are applicable
9317df
+ * instead of those above.
9317df
+ */
9317df
+#ifndef _DOCUMENT_HXX_
9317df
+#define _DOCUMENT_HXX_
9317df
+
9317df
+#include <iostream>
9317df
+#include <string>
9317df
+#include <vector>
9317df
+
9317df
+#include <boost/shared_ptr.hpp>
9317df
+
9317df
+#include "exception.hxx"
9317df
+#include "object.hxx"
9317df
+
9317df
+namespace libcmis
9317df
+{
9317df
+    class Folder;
9317df
+    class Session;
9317df
+
9317df
+    /** Interface for a CMIS Document object.
9317df
+      */
9317df
+    class Document : public virtual Object
9317df
+    {
9317df
+        public:
9317df
+            Document( Session* session ) : Object( session ) { }
9317df
+            virtual ~Document( ) { }
9317df
+
9317df
+            /** Get the folder parents for the document.
9317df
+
9317df
+                Note that an unfiled document will have no parent folder.
9317df
+
9317df
+                @return the parents folder if any.
9317df
+              */
9317df
+            virtual std::vector< boost::shared_ptr< Folder > > getParents( ) = 0;
9317df
+            
9317df
+            /** Get the content stream without using a temporary file.
9317df
+
9317df
+                

The stream may not contain anything if there is

9317df
+                no content or if something wrong happened during the
9317df
+                download.

9317df
+
9317df
+                @param streamId of the rendition
9317df
+                @return
9317df
+                    An input stream to read the data from.
9317df
+
9317df
+                @throws Exception
9317df
+                    if anything wrong happened during the file transfer.
9317df
+                    In such a case, the content of the stream can't be
9317df
+                    guaranteed.
9317df
+              */
9317df
+            virtual boost::shared_ptr< std::istream > getContentStream( std::string streamId = std::string( ) ) 
9317df
+                        = 0;
9317df
+
9317df
+            /** Set or replace the content stream of the document.
9317df
+
9317df
+                @param is the output stream containing the new data for the content stream
9317df
+                @param contentType the mime-type of the new content stream
9317df
+                @param filename the filename to set for the file
9317df
+                @param overwrite if set to false, don't overwrite the content stream if one is already set.
9317df
+
9317df
+                @throw Exception if anything happens during the upload like a wrong authentication, 
9317df
+                                no rights to set the stream, server doesn't have the ContentStreamUpdatability
9317df
+                                capability.
9317df
+              */
9317df
+            virtual void setContentStream( boost::shared_ptr< std::ostream > os, std::string contentType,
9317df
+                                           std::string filename, bool overwrite = true ) = 0;
9317df
+
9317df
+            /** Get the content mime type.
9317df
+              */
9317df
+            virtual std::string getContentType( );
9317df
+            
9317df
+            /** Get the content stream filename.
9317df
+              */
9317df
+            virtual std::string getContentFilename( );
9317df
+
9317df
+            /** Get the content length in bytes.
9317df
+              */
9317df
+            virtual long getContentLength( );
9317df
+
9317df
+            /** Checks out the document and returns the object corresponding to the 
9317df
+                created Private Working Copy.
9317df
+
9317df
+                \return the Private Working Copy document
9317df
+              */
9317df
+            virtual boost::shared_ptr< Document > checkOut( ) = 0;
9317df
+
9317df
+            /** Cancels the checkout if the document is a private working copy, or
9317df
+                throws an exception.
9317df
+              */
9317df
+            virtual void cancelCheckout( ) = 0;
9317df
+
9317df
+            /** Check in the private working copy and create a new version or throw
9317df
+                an exception.
9317df
+
9317df
+                The current object will be updated to reflect the changes performed
9317df
+                on the server side.
9317df
+
9317df
+                \param isMajor defines it the version to create is a major or minor one
9317df
+                \param comment contains the checkin comment
9317df
+                \param properties the properties to set the new version
9317df
+                \param stream the content stream to set for the new version
9317df
+                \param contentType the mime type of the stream to set
9317df
+
9317df
+                \return the document with the new version
9317df
+              */
9317df
+            virtual boost::shared_ptr< Document > checkIn( bool isMajor, std::string comment,
9317df
+                                  const std::map< std::string, PropertyPtr >& properties,
9317df
+                                  boost::shared_ptr< std::ostream > stream,
9317df
+                                  std::string contentType, std::string fileName ) = 0;
9317df
+
9317df
+            virtual std::vector< boost::shared_ptr< Document > > getAllVersions( ) = 0;
9317df
+
9317df
+            // virtual methods form Object
9317df
+            virtual std::vector< std::string > getPaths( );
9317df
+
9317df
+            virtual std::string toString( );
9317df
+    };
9317df
+    typedef ::boost::shared_ptr< Document > DocumentPtr;
9317df
+}
9317df
+
9317df
+#endif
9317df
diff --git a/include/libcmis/exception.hxx b/include/libcmis/exception.hxx
9317df
new file mode 100644
9317df
index 000000000000..16f3573da2b1
9317df
--- /dev/null
9317df
+++ b/include/libcmis/exception.hxx
9317df
@@ -0,0 +1,60 @@
9317df
+/* libcmis
9317df
+ * Version: MPL 1.1 / GPLv2+ / LGPLv2+
9317df
+ *
9317df
+ * The contents of this file are subject to the Mozilla Public License Version
9317df
+ * 1.1 (the "License"); you may not use this file except in compliance with
9317df
+ * the License or as specified alternatively below. You may obtain a copy of
9317df
+ * the License at http://www.mozilla.org/MPL/
9317df
+ *
9317df
+ * Software distributed under the License is distributed on an "AS IS" basis,
9317df
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
9317df
+ * for the specific language governing rights and limitations under the
9317df
+ * License.
9317df
+ *
9317df
+ * Major Contributor(s):
9317df
+ * Copyright (C) 2011 SUSE <cbosdonnat@suse.com>
9317df
+ *
9317df
+ *
9317df
+ * All Rights Reserved.
9317df
+ *
9317df
+ * For minor contributions see the git repository.
9317df
+ *
9317df
+ * Alternatively, the contents of this file may be used under the terms of
9317df
+ * either the GNU General Public License Version 2 or later (the "GPLv2+"), or
9317df
+ * the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"),
9317df
+ * in which case the provisions of the GPLv2+ or the LGPLv2+ are applicable
9317df
+ * instead of those above.
9317df
+ */
9317df
+#ifndef _EXCEPTION_HXX_
9317df
+#define _EXCEPTION_HXX_
9317df
+
9317df
+#include <exception>
9317df
+#include <string>
9317df
+
9317df
+namespace libcmis
9317df
+{
9317df
+    class Exception : public std::exception
9317df
+    {
9317df
+        private:
9317df
+            std::string m_message;
9317df
+            std::string m_type;
9317df
+
9317df
+        public:
9317df
+            Exception( std::string message, std::string type = "runtime" ) :
9317df
+                exception( ),
9317df
+                m_message( message ),
9317df
+                m_type( type )
9317df
+            {
9317df
+            }
9317df
+
9317df
+            ~Exception( ) throw () { }
9317df
+            virtual const char* what() const throw()
9317df
+            {
9317df
+                return m_message.c_str( );
9317df
+            }
9317df
+
9317df
+            std::string getType( ) const { return m_type; }
9317df
+    };
9317df
+}
9317df
+
9317df
+#endif
9317df
diff --git a/include/libcmis/folder.hxx b/include/libcmis/folder.hxx
9317df
new file mode 100644
9317df
index 000000000000..9f17e3883898
9317df
--- /dev/null
9317df
+++ b/include/libcmis/folder.hxx
9317df
@@ -0,0 +1,83 @@
9317df
+/* libcmis
9317df
+ * Version: MPL 1.1 / GPLv2+ / LGPLv2+
9317df
+ *
9317df
+ * The contents of this file are subject to the Mozilla Public License Version
9317df
+ * 1.1 (the "License"); you may not use this file except in compliance with
9317df
+ * the License or as specified alternatively below. You may obtain a copy of
9317df
+ * the License at http://www.mozilla.org/MPL/
9317df
+ *
9317df
+ * Software distributed under the License is distributed on an "AS IS" basis,
9317df
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
9317df
+ * for the specific language governing rights and limitations under the
9317df
+ * License.
9317df
+ *
9317df
+ * Major Contributor(s):
9317df
+ * Copyright (C) 2011 SUSE <cbosdonnat@suse.com>
9317df
+ *
9317df
+ *
9317df
+ * All Rights Reserved.
9317df
+ *
9317df
+ * For minor contributions see the git repository.
9317df
+ *
9317df
+ * Alternatively, the contents of this file may be used under the terms of
9317df
+ * either the GNU General Public License Version 2 or later (the "GPLv2+"), or
9317df
+ * the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"),
9317df
+ * in which case the provisions of the GPLv2+ or the LGPLv2+ are applicable
9317df
+ * instead of those above.
9317df
+ */
9317df
+#ifndef _FOLDER_HXX_
9317df
+#define _FOLDER_HXX_
9317df
+
9317df
+#include <map>
9317df
+#include <string>
9317df
+#include <vector>
9317df
+
9317df
+#include "exception.hxx"
9317df
+#include "object.hxx"
9317df
+
9317df
+namespace libcmis
9317df
+{
9317df
+    class Document;
9317df
+    class Session;
9317df
+    
9317df
+    struct UnfileObjects {
9317df
+        enum Type
9317df
+        {
9317df
+            Unfile,
9317df
+            DeleteSingleFiled,
9317df
+            Delete
9317df
+        };
9317df
+    };
9317df
+
9317df
+    /** Class representing a CMIS folder.
9317df
+      */
9317df
+    class Folder : public virtual Object
9317df
+    {
9317df
+        public:
9317df
+            Folder( Session* session ) : Object( session ) { }
9317df
+            virtual ~Folder() { }
9317df
+
9317df
+            virtual std::vector< std::string > getPaths( );
9317df
+
9317df
+            virtual ::boost::shared_ptr< Folder > getFolderParent( );
9317df
+            virtual std::vector< ObjectPtr > getChildren( ) = 0;
9317df
+            virtual std::string getParentId( );
9317df
+            virtual std::string getPath( );
9317df
+
9317df
+            virtual bool isRootFolder( );
9317df
+
9317df
+            virtual ::boost::shared_ptr< Folder > createFolder( const std::map< std::string, PropertyPtr >& properties )
9317df
+                = 0;
9317df
+            virtual ::boost::shared_ptr< Document > createDocument( const std::map< std::string, PropertyPtr >& properties,
9317df
+                                    boost::shared_ptr< std::ostream > os, std::string contentType, std::string fileName ) = 0;
9317df
+
9317df
+            virtual std::vector< std::string > removeTree( bool allVersion = true, UnfileObjects::Type unfile = UnfileObjects::Delete,
9317df
+                                    bool continueOnError = false ) = 0;
9317df
+        
9317df
+            virtual std::string toString( );
9317df
+    };
9317df
+    typedef ::boost::shared_ptr< Folder > FolderPtr;
9317df
+
9317df
+}
9317df
+
9317df
+#endif
9317df
diff --git a/include/libcmis/libcmis.hxx b/include/libcmis/libcmis.hxx
9317df
new file mode 100644
9317df
index 000000000000..540e5af127f2
9317df
--- /dev/null
9317df
+++ b/include/libcmis/libcmis.hxx
9317df
@@ -0,0 +1,47 @@
9317df
+/* libcmis
9317df
+ * Version: MPL 1.1 / GPLv2+ / LGPLv2+
9317df
+ *
9317df
+ * The contents of this file are subject to the Mozilla Public License Version
9317df
+ * 1.1 (the "License"); you may not use this file except in compliance with
9317df
+ * the License or as specified alternatively below. You may obtain a copy of
9317df
+ * the License at http://www.mozilla.org/MPL/
9317df
+ *
9317df
+ * Software distributed under the License is distributed on an "AS IS" basis,
9317df
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
9317df
+ * for the specific language governing rights and limitations under the
9317df
+ * License.
9317df
+ *
9317df
+ * Major Contributor(s):
9317df
+ * Copyright (C) 2011 SUSE <cbosdonnat@suse.com>
9317df
+ *
9317df
+ *
9317df
+ * All Rights Reserved.
9317df
+ *
9317df
+ * For minor contributions see the git repository.
9317df
+ *
9317df
+ * Alternatively, the contents of this file may be used under the terms of
9317df
+ * either the GNU General Public License Version 2 or later (the "GPLv2+"), or
9317df
+ * the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"),
9317df
+ * in which case the provisions of the GPLv2+ or the LGPLv2+ are applicable
9317df
+ * instead of those above.
9317df
+ */
9317df
+#ifndef _LIBCMIS_HXX_
9317df
+#define _LIBCMIS_HXX_
9317df
+
9317df
+#include "allowable-actions.hxx"
9317df
+#include "document.hxx"
9317df
+#include "exception.hxx"
9317df
+#include "folder.hxx"
9317df
+#include "oauth2-data.hxx"
9317df
+#include "object-type.hxx"
9317df
+#include "object.hxx"
9317df
+#include "property-type.hxx"
9317df
+#include "property.hxx"
9317df
+#include "rendition.hxx"
9317df
+#include "repository.hxx"
9317df
+#include "session-factory.hxx"
9317df
+#include "session.hxx"
9317df
+#include "xml-utils.hxx"
9317df
+#include "xmlserializable.hxx"
9317df
+
9317df
+#endif
9317df
diff --git a/include/libcmis/oauth2-data.hxx b/include/libcmis/oauth2-data.hxx
9317df
new file mode 100644
9317df
index 000000000000..000f9394b034
9317df
--- /dev/null
9317df
+++ b/include/libcmis/oauth2-data.hxx
9317df
@@ -0,0 +1,76 @@
9317df
+/* libcmis
9317df
+ * Version: MPL 1.1 / GPLv2+ / LGPLv2+
9317df
+ *
9317df
+ * The contents of this file are subject to the Mozilla Public License Version
9317df
+ * 1.1 (the "License"); you may not use this file except in compliance with
9317df
+ * the License or as specified alternatively below. You may obtain a copy of
9317df
+ * the License at http://www.mozilla.org/MPL/
9317df
+ *
9317df
+ * Software distributed under the License is distributed on an "AS IS" basis,
9317df
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
9317df
+ * for the specific language governing rights and limitations under the
9317df
+ * License.
9317df
+ *
9317df
+ * Major Contributor(s):
9317df
+ * Copyright (C) 2011 SUSE <cbosdonnat@suse.com>
9317df
+ *
9317df
+ *
9317df
+ * All Rights Reserved.
9317df
+ *
9317df
+ * For minor contributions see the git repository.
9317df
+ *
9317df
+ * Alternatively, the contents of this file may be used under the terms of
9317df
+ * either the GNU General Public License Version 2 or later (the "GPLv2+"), or
9317df
+ * the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"),
9317df
+ * in which case the provisions of the GPLv2+ or the LGPLv2+ are applicable
9317df
+ * instead of those above.
9317df
+ */
9317df
+#ifndef _LIBCMIS_OAUTH2_DATA_HXX_
9317df
+#define _LIBCMIS_OAUTH2_DATA_HXX_
9317df
+
9317df
+#include <string>
9317df
+#include <boost/shared_ptr.hpp>
9317df
+
9317df
+namespace libcmis
9317df
+{
9317df
+    /** Class storing the data needed for OAuth2 authentication.
9317df
+      */
9317df
+    class OAuth2Data
9317df
+    {
9317df
+        private:
9317df
+
9317df
+            std::string m_authUrl;
9317df
+            std::string m_tokenUrl;
9317df
+            std::string m_clientId;
9317df
+            std::string m_clientSecret;
9317df
+            std::string m_scope;
9317df
+            std::string m_redirectUri;
9317df
+        public:
9317df
+
9317df
+            OAuth2Data( );
9317df
+            OAuth2Data( const std::string& authUrl, 
9317df
+                        const std::string& tokenUrl,
9317df
+                        const std::string& scope, 
9317df
+                        const std::string& redirectUri,
9317df
+                        const std::string& clientId, 
9317df
+                        const std::string& clientSecret );
9317df
+
9317df
+            OAuth2Data( const OAuth2Data& copy );
9317df
+            ~OAuth2Data( );
9317df
+
9317df
+            OAuth2Data& operator=( const OAuth2Data& copy );
9317df
+
9317df
+            bool isComplete();
9317df
+
9317df
+            const std::string& getAuthUrl() { return m_authUrl; }
9317df
+            const std::string& getTokenUrl() { return m_tokenUrl; }
9317df
+            const std::string& getClientId() { return m_clientId; }
9317df
+            const std::string& getClientSecret() { return m_clientSecret; }
9317df
+            const std::string& getScope() { return m_scope; }
9317df
+            const std::string& getRedirectUri() { return m_redirectUri; }
9317df
+    };
9317df
+    typedef ::boost::shared_ptr< OAuth2Data > OAuth2DataPtr;
9317df
+}
9317df
+
9317df
+#endif //_LIBCMIS_OAUTH2_DATA_HXX_
9317df
+
9317df
diff --git a/include/libcmis/object-type.hxx b/include/libcmis/object-type.hxx
9317df
new file mode 100644
9317df
index 000000000000..a8576ec80f0b
9317df
--- /dev/null
9317df
+++ b/include/libcmis/object-type.hxx
9317df
@@ -0,0 +1,143 @@
9317df
+/* libcmis
9317df
+ * Version: MPL 1.1 / GPLv2+ / LGPLv2+
9317df
+ *
9317df
+ * The contents of this file are subject to the Mozilla Public License Version
9317df
+ * 1.1 (the "License"); you may not use this file except in compliance with
9317df
+ * the License or as specified alternatively below. You may obtain a copy of
9317df
+ * the License at http://www.mozilla.org/MPL/
9317df
+ *
9317df
+ * Software distributed under the License is distributed on an "AS IS" basis,
9317df
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
9317df
+ * for the specific language governing rights and limitations under the
9317df
+ * License.
9317df
+ *
9317df
+ * Major Contributor(s):
9317df
+ * Copyright (C) 2011 SUSE <cbosdonnat@suse.com>
9317df
+ *
9317df
+ *
9317df
+ * All Rights Reserved.
9317df
+ *
9317df
+ * For minor contributions see the git repository.
9317df
+ *
9317df
+ * Alternatively, the contents of this file may be used under the terms of
9317df
+ * either the GNU General Public License Version 2 or later (the "GPLv2+"), or
9317df
+ * the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"),
9317df
+ * in which case the provisions of the GPLv2+ or the LGPLv2+ are applicable
9317df
+ * instead of those above.
9317df
+ */
9317df
+#ifndef _OBJECT_TYPE_HXX_
9317df
+#define _OBJECT_TYPE_HXX_
9317df
+
9317df
+#include <boost/shared_ptr.hpp>
9317df
+#include <libxml/tree.h>
9317df
+
9317df
+#include <string>
9317df
+#include <vector>
9317df
+
9317df
+#include "exception.hxx"
9317df
+#include "property-type.hxx"
9317df
+
9317df
+namespace libcmis
9317df
+{
9317df
+    /** Class representing a CMIS object type definition.
9317df
+      */
9317df
+    class ObjectType
9317df
+    {
9317df
+        public:
9317df
+
9317df
+            enum ContentStreamAllowed
9317df
+            {
9317df
+                NotAllowed,
9317df
+                Allowed,
9317df
+                Required
9317df
+            };
9317df
+
9317df
+        protected:
9317df
+            time_t m_refreshTimestamp;
9317df
+
9317df
+            std::string m_id;
9317df
+            std::string m_localName;
9317df
+            std::string m_localNamespace;
9317df
+            std::string m_displayName;
9317df
+            std::string m_queryName;
9317df
+            std::string m_description;
9317df
+
9317df
+            std::string m_parentTypeId;
9317df
+            std::string m_baseTypeId;
9317df
+
9317df
+            bool m_creatable;
9317df
+            bool m_fileable;
9317df
+            bool m_queryable;
9317df
+            bool m_fulltextIndexed;
9317df
+            bool m_includedInSupertypeQuery;
9317df
+            bool m_controllablePolicy;
9317df
+            bool m_controllableAcl;
9317df
+            bool m_versionable;
9317df
+            libcmis::ObjectType::ContentStreamAllowed m_contentStreamAllowed;
9317df
+
9317df
+            std::map< std::string, libcmis::PropertyTypePtr > m_propertiesTypes;
9317df
+
9317df
+            ObjectType( );
9317df
+            void initializeFromNode( xmlNodePtr node );
9317df
+
9317df
+        public:
9317df
+
9317df
+            ObjectType( xmlNodePtr node );
9317df
+            ObjectType( const ObjectType& copy );
9317df
+            virtual ~ObjectType() { }
9317df
+
9317df
+            ObjectType& operator=( const ObjectType& copy );
9317df
+
9317df
+            /** Reload the data from the server.
9317df
+
9317df
+                \attention
9317df
+                    This method needs to be implemented in subclasses or it will
9317df
+                    do nothing
9317df
+             */
9317df
+            virtual void refresh( );
9317df
+            virtual time_t getRefreshTimestamp( ) const;
9317df
+
9317df
+            std::string getId( ) const;
9317df
+            std::string getLocalName( ) const;
9317df
+            std::string getLocalNamespace( ) const;
9317df
+            std::string getDisplayName( ) const;
9317df
+            std::string getQueryName( ) const;
9317df
+            std::string getDescription( ) const;
9317df
+
9317df
+            virtual boost::shared_ptr< ObjectType >  getParentType( );
9317df
+            virtual boost::shared_ptr< ObjectType >  getBaseType( );
9317df
+            virtual std::vector< boost::shared_ptr< ObjectType > > getChildren( );
9317df
+
9317df
+            /** Get the parent type id without extracting the complete parent type from
9317df
+                the repository. This is mainly provided for performance reasons.
9317df
+
9317df
+                \since libcmis 0.4
9317df
+              */
9317df
+            std::string getParentTypeId( ) const;
9317df
+
9317df
+            /** Get the base type id without extracting the complete base type from
9317df
+                the repository. This is mainly provided for performance reasons.
9317df
+
9317df
+                \since libcmis 0.4
9317df
+              */
9317df
+            std::string getBaseTypeId( ) const;
9317df
+
9317df
+            bool isCreatable( ) const;
9317df
+            bool isFileable( ) const;
9317df
+            bool isQueryable( ) const;
9317df
+            bool isFulltextIndexed( ) const;
9317df
+            bool isIncludedInSupertypeQuery( ) const;
9317df
+            bool isControllablePolicy( ) const;
9317df
+            bool isControllableACL( ) const;
9317df
+            bool isVersionable( ) const;
9317df
+            ContentStreamAllowed getContentStreamAllowed( ) const;
9317df
+
9317df
+            std::map< std::string, PropertyTypePtr >& getPropertiesTypes( );
9317df
+
9317df
+            virtual std::string toString( );
9317df
+    };
9317df
+
9317df
+    typedef ::boost::shared_ptr< ObjectType > ObjectTypePtr;
9317df
+}
9317df
+
9317df
+#endif
9317df
diff --git a/include/libcmis/object.hxx b/include/libcmis/object.hxx
9317df
new file mode 100644
9317df
index 000000000000..fa8d465e7c3b
9317df
--- /dev/null
9317df
+++ b/include/libcmis/object.hxx
9317df
@@ -0,0 +1,217 @@
9317df
+/* libcmis
9317df
+ * Version: MPL 1.1 / GPLv2+ / LGPLv2+
9317df
+ *
9317df
+ * The contents of this file are subject to the Mozilla Public License Version
9317df
+ * 1.1 (the "License"); you may not use this file except in compliance with
9317df
+ * the License or as specified alternatively below. You may obtain a copy of
9317df
+ * the License at http://www.mozilla.org/MPL/
9317df
+ *
9317df
+ * Software distributed under the License is distributed on an "AS IS" basis,
9317df
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
9317df
+ * for the specific language governing rights and limitations under the
9317df
+ * License.
9317df
+ *
9317df
+ * Major Contributor(s):
9317df
+ * Copyright (C) 2011 SUSE <cbosdonnat@suse.com>
9317df
+ *
9317df
+ *
9317df
+ * All Rights Reserved.
9317df
+ *
9317df
+ * For minor contributions see the git repository.
9317df
+ *
9317df
+ * Alternatively, the contents of this file may be used under the terms of
9317df
+ * either the GNU General Public License Version 2 or later (the "GPLv2+"), or
9317df
+ * the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"),
9317df
+ * in which case the provisions of the GPLv2+ or the LGPLv2+ are applicable
9317df
+ * instead of those above.
9317df
+ */
9317df
+#ifndef _OBJECT_HXX_
9317df
+#define _OBJECT_HXX_
9317df
+
9317df
+#include <ctime>
9317df
+#include <map>
9317df
+#include <string>
9317df
+#include <vector>
9317df
+
9317df
+#ifndef __cplusplus
9317df
+#include <stdbool.h>
9317df
+#endif
9317df
+
9317df
+#include <boost/date_time.hpp>
9317df
+#include <boost/shared_ptr.hpp>
9317df
+#include <libxml/tree.h>
9317df
+
9317df
+#include "allowable-actions.hxx"
9317df
+#include "exception.hxx"
9317df
+#include "object-type.hxx"
9317df
+#include "property.hxx"
9317df
+#include "xmlserializable.hxx"
9317df
+#include "rendition.hxx"
9317df
+
9317df
+namespace libcmis
9317df
+{
9317df
+    class Folder;
9317df
+    class Session;
9317df
+
9317df
+    /** Class representing any CMIS object.
9317df
+      */
9317df
+    class Object : public XmlSerializable
9317df
+    {
9317df
+        protected:
9317df
+            Session* m_session;
9317df
+
9317df
+            ObjectTypePtr m_typeDescription;
9317df
+            time_t m_refreshTimestamp;
9317df
+
9317df
+            /** Type id used as cache before we get it as a property
9317df
+              */
9317df
+            std::string m_typeId;
9317df
+
9317df
+            std::map< std::string, PropertyPtr > m_properties;
9317df
+            boost::shared_ptr< AllowableActions > m_allowableActions;
9317df
+            std::vector< RenditionPtr > m_renditions;
9317df
+            void initializeFromNode( xmlNodePtr node );
9317df
+
9317df
+        public:
9317df
+
9317df
+            Object( Session* session );
9317df
+            Object( Session* session, xmlNodePtr node );
9317df
+            Object( const Object& copy );
9317df
+            virtual ~Object( ) { }
9317df
+
9317df
+            Object& operator=( const Object& copy );
9317df
+
9317df
+            virtual std::string getId( );
9317df
+            virtual std::string getName( );
9317df
+            virtual std::string getStringProperty( const std::string& propertyName );
9317df
+
9317df
+            /** Computes the paths for the objects.
9317df
+
9317df
+                Note that folders will have only path, documents may have
9317df
+                several ones and there may be cases where there is no path
9317df
+                at all (unfilled objects);
9317df
+              */
9317df
+            virtual std::vector< std::string > getPaths( );
9317df
+
9317df
+            virtual std::string getBaseType( );
9317df
+            virtual std::string getType( );
9317df
+
9317df
+            virtual std::string getCreatedBy( );
9317df
+            virtual boost::posix_time::ptime getCreationDate( );
9317df
+            virtual std::string getLastModifiedBy( );
9317df
+            virtual boost::posix_time::ptime getLastModificationDate( );
9317df
+
9317df
+            virtual std::string getChangeToken( );
9317df
+            virtual bool isImmutable( );
9317df
+
9317df
+            virtual std::vector< std::string > getSecondaryTypes();
9317df
+
9317df
+            /** Convenience function adding a secondary type to the object.
9317df
+
9317df
+                Behind the scene this function is basically computing the
9317df
+                properties and sets them for you to avoid reading the CMIS
9317df
+                1.1 specification, section 2.1.9.
9317df
+
9317df
+                \param id
9317df
+                    the identifier of the secondary type to add
9317df
+                \param properties
9317df
+                    the properties coming with the secondary type
9317df
+
9317df
+                \return
9317df
+                    the updated object. Note that it may represent the same
9317df
+                    object on the server but it still is a different object
9317df
+                    instance (see updateProperties method).
9317df
+
9317df
+                \throw Exception
9317df
+                    if anything wrong happens. Note that the server is likely
9317df
+                    to throw a constraint exception if it doesn't allow the
9317df
+                    operation.
9317df
+              */
9317df
+            virtual boost::shared_ptr< Object > addSecondaryType(
9317df
+                                                        std::string id,
9317df
+                                                        PropertyPtrMap properties );
9317df
+
9317df
+            /** Convenience function removing a secondary type from the object.
9317df
+
9317df
+                Behind the scene this function is basically computing the
9317df
+                correct property and sets it for you to avoid reading the
9317df
+                CMIS 1.1 specification, section 2.1.9.
9317df
+
9317df
+                The server should remove the related properties, there is
9317df
+                normally no need to worry about them.
9317df
+
9317df
+                \param id
9317df
+                    the identifier of the secondary type to remove
9317df
+
9317df
+                \return
9317df
+                    the updated object. Note that it may represent the same
9317df
+                    object on the server but it still is a different object
9317df
+                    instance (see updateProperties method).
9317df
+
9317df
+                \throw Exception
9317df
+                    if anything wrong happens. Note that the server is likely
9317df
+                    to throw a constraint exception if it doesn't allow the
9317df
+                    operation.
9317df
+              */
9317df
+            virtual boost::shared_ptr< Object > removeSecondaryType( std::string id );
9317df
+
9317df
+            /** Gives access to the properties of the object.
9317df
+
9317df
+                \attention
9317df
+                    API users should consider this method as read-only as the
9317df
+                    changed properties won't be updated to the server. Updating
9317df
+                    the returned map may lead to changes loss when calling
9317df
+                    updateProperties.
9317df
+
9317df
+                \sa updateProperties to change properties on the server
9317df
+              */
9317df
+            virtual libcmis::PropertyPtrMap& getProperties( );
9317df
+
9317df
+
9317df
+            /** Get the renditions of the object.
9317df
+
9317df
+                \param filter is defined by the CMIS spec section 2.2.1.2.4.1.
9317df
+                              By default, this value is just ignored, but some bindings and servers
9317df
+                              may use it.
9317df
+
9317df
+                \attention
9317df
+                    The streamId of the rendition is used in getContentStream( )
9317df
+              */
9317df
+            virtual std::vector< RenditionPtr> getRenditions( std::string filter = std::string( ) );
9317df
+            virtual AllowableActionsPtr getAllowableActions( ) { return m_allowableActions; }
9317df
+
9317df
+            /** Update the object properties and return the updated object.
9317df
+
9317df
+                \attention
9317df
+                    even if the returned object may have the same Id than 'this'
9317df
+                    and thus representing the same object on the server, those
9317df
+                    are still two different instances to ease memory handling.
9317df
+              */
9317df
+            virtual boost::shared_ptr< Object > updateProperties(
9317df
+                        const PropertyPtrMap& properties ) = 0;
9317df
+
9317df
+            virtual ObjectTypePtr getTypeDescription( );
9317df
+
9317df
+            /** Reload the data from the server.
9317df
+              */
9317df
+            virtual void refresh( ) = 0;
9317df
+            virtual time_t getRefreshTimestamp( ) { return m_refreshTimestamp; }
9317df
+
9317df
+            virtual void remove( bool allVersions = true ) = 0;
9317df
+
9317df
+            virtual void move( boost::shared_ptr< Folder > source, boost::shared_ptr< Folder > destination ) = 0;
9317df
+
9317df
+
9317df
+            virtual std::string getThumbnailUrl( );
9317df
+
9317df
+            /** Dump the object as a string for debugging or display purpose.
9317df
+              */
9317df
+            virtual std::string toString( );
9317df
+
9317df
+            void toXml( xmlTextWriterPtr writer );
9317df
+    };
9317df
+
9317df
+    typedef ::boost::shared_ptr< Object > ObjectPtr;
9317df
+}
9317df
+
9317df
+#endif
9317df
diff --git a/include/libcmis/property-type.hxx b/include/libcmis/property-type.hxx
9317df
new file mode 100644
9317df
index 000000000000..56be22347c86
9317df
--- /dev/null
9317df
+++ b/include/libcmis/property-type.hxx
9317df
@@ -0,0 +1,125 @@
9317df
+/* libcmis
9317df
+ * Version: MPL 1.1 / GPLv2+ / LGPLv2+
9317df
+ *
9317df
+ * The contents of this file are subject to the Mozilla Public License Version
9317df
+ * 1.1 (the "License"); you may not use this file except in compliance with
9317df
+ * the License or as specified alternatively below. You may obtain a copy of
9317df
+ * the License at http://www.mozilla.org/MPL/
9317df
+ *
9317df
+ * Software distributed under the License is distributed on an "AS IS" basis,
9317df
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
9317df
+ * for the specific language governing rights and limitations under the
9317df
+ * License.
9317df
+ *
9317df
+ * Major Contributor(s):
9317df
+ * Copyright (C) 2011 SUSE <cbosdonnat@suse.com>
9317df
+ *
9317df
+ *
9317df
+ * All Rights Reserved.
9317df
+ *
9317df
+ * For minor contributions see the git repository.
9317df
+ *
9317df
+ * Alternatively, the contents of this file may be used under the terms of
9317df
+ * either the GNU General Public License Version 2 or later (the "GPLv2+"), or
9317df
+ * the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"),
9317df
+ * in which case the provisions of the GPLv2+ or the LGPLv2+ are applicable
9317df
+ * instead of those above.
9317df
+ */
9317df
+#ifndef _PROPERTY_TYPE_HXX_
9317df
+#define _PROPERTY_TYPE_HXX_
9317df
+
9317df
+#include <boost/date_time.hpp>
9317df
+#include <libxml/tree.h>
9317df
+
9317df
+#include <string>
9317df
+
9317df
+namespace libcmis
9317df
+{
9317df
+    class ObjectType;
9317df
+    typedef boost::shared_ptr< ObjectType > ObjectTypePtr;
9317df
+
9317df
+    class PropertyType
9317df
+    {
9317df
+        public:
9317df
+
9317df
+            enum Type
9317df
+            {
9317df
+                String,
9317df
+                Integer,
9317df
+                Decimal,
9317df
+                Bool,
9317df
+                DateTime
9317df
+            };
9317df
+
9317df
+        private:
9317df
+
9317df
+            std::string m_id;
9317df
+            std::string m_localName;
9317df
+            std::string m_localNamespace;
9317df
+            std::string m_displayName;
9317df
+            std::string m_queryName;
9317df
+            Type m_type;
9317df
+            std::string m_xmlType;
9317df
+            bool m_multiValued;
9317df
+            bool m_updatable;
9317df
+            bool m_inherited;
9317df
+            bool m_required;
9317df
+            bool m_queryable;
9317df
+            bool m_orderable;
9317df
+            bool m_openChoice;
9317df
+            bool m_temporary;
9317df
+
9317df
+        public:
9317df
+
9317df
+            /// Default constructor, mostly present for testing.
9317df
+            PropertyType( );
9317df
+            PropertyType( xmlNodePtr node );
9317df
+            PropertyType( const PropertyType& copy );
9317df
+            /// constructor for temporary type definitions
9317df
+            PropertyType( std::string type,
9317df
+                          std::string id,
9317df
+                          std::string localName,
9317df
+                          std::string displayName,
9317df
+                          std::string queryName );
9317df
+            virtual ~PropertyType( ) { };
9317df
+
9317df
+            PropertyType& operator=( const PropertyType& copy );
9317df
+
9317df
+            std::string getId( ) { return m_id; }
9317df
+            std::string getLocalName( ) { return m_localName; }
9317df
+            std::string getLocalNamespace( ) { return m_localNamespace; }
9317df
+            std::string getDisplayName( ) { return m_displayName; }
9317df
+            std::string getQueryName( ) { return m_queryName; }
9317df
+            Type getType( ) { return m_type; }
9317df
+            std::string getXmlType( ) { return m_xmlType; }
9317df
+            bool isMultiValued( ) { return m_multiValued; }
9317df
+            bool isUpdatable( ) { return m_updatable; }
9317df
+            bool isInherited( ) { return m_inherited; }
9317df
+            bool isRequired( ) { return m_required; }
9317df
+            bool isQueryable( ) { return m_queryable; }
9317df
+            bool isOrderable( ) { return m_orderable; }
9317df
+            bool isOpenChoice( ) { return m_openChoice; }
9317df
+
9317df
+            void setId( std::string id ) { m_id = id; }
9317df
+            void setLocalName( std::string localName ) { m_localName = localName; }
9317df
+            void setLocalNamespace( std::string localNamespace ) { m_localNamespace = localNamespace; }
9317df
+            void setDisplayName( std::string displayName ) { m_displayName = displayName; }
9317df
+            void setQueryName( std::string queryName ) { m_queryName = queryName; }
9317df
+            void setType( Type type ) { m_type = type; }
9317df
+            void setMultiValued( bool multivalued ) { m_multiValued = multivalued; }
9317df
+            void setUpdatable( bool updatable ) { m_updatable = updatable; }
9317df
+            void setInherited( bool inherited ) { m_inherited = inherited; }
9317df
+            void setRequired( bool required ) { m_required = required; }
9317df
+            void setQueryable( bool queryable ) { m_queryable = queryable; }
9317df
+            void setOrderable( bool orderable ) { m_orderable = orderable; }
9317df
+            void setOpenChoice( bool openChoice ) { m_openChoice = openChoice; }
9317df
+
9317df
+            void setTypeFromXml( std::string typeStr );
9317df
+            void setTypeFromJsonType( std::string jsonType );
9317df
+
9317df
+            void update( std::vector< ObjectTypePtr > typesDefs );
9317df
+    };
9317df
+    typedef ::boost::shared_ptr< PropertyType > PropertyTypePtr;
9317df
+}
9317df
+
9317df
+#endif
9317df
diff --git a/include/libcmis/property.hxx b/include/libcmis/property.hxx
9317df
new file mode 100644
9317df
index 000000000000..aa6560590c11
9317df
--- /dev/null
9317df
+++ b/include/libcmis/property.hxx
9317df
@@ -0,0 +1,88 @@
9317df
+/* libcmis
9317df
+ * Version: MPL 1.1 / GPLv2+ / LGPLv2+
9317df
+ *
9317df
+ * The contents of this file are subject to the Mozilla Public License Version
9317df
+ * 1.1 (the "License"); you may not use this file except in compliance with
9317df
+ * the License or as specified alternatively below. You may obtain a copy of
9317df
+ * the License at http://www.mozilla.org/MPL/
9317df
+ *
9317df
+ * Software distributed under the License is distributed on an "AS IS" basis,
9317df
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
9317df
+ * for the specific language governing rights and limitations under the
9317df
+ * License.
9317df
+ *
9317df
+ * Major Contributor(s):
9317df
+ * Copyright (C) 2011 SUSE <cbosdonnat@suse.com>
9317df
+ *
9317df
+ *
9317df
+ * All Rights Reserved.
9317df
+ *
9317df
+ * For minor contributions see the git repository.
9317df
+ *
9317df
+ * Alternatively, the contents of this file may be used under the terms of
9317df
+ * either the GNU General Public License Version 2 or later (the "GPLv2+"), or
9317df
+ * the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"),
9317df
+ * in which case the provisions of the GPLv2+ or the LGPLv2+ are applicable
9317df
+ * instead of those above.
9317df
+ */
9317df
+#ifndef _PROPERTY_HXX_
9317df
+#define _PROPERTY_HXX_
9317df
+
9317df
+#include <libxml/tree.h>
9317df
+#include <libxml/xmlwriter.h>
9317df
+
9317df
+#include <boost/date_time.hpp>
9317df
+#include <boost/shared_ptr.hpp>
9317df
+
9317df
+#include <string>
9317df
+#include <vector>
9317df
+
9317df
+#include "property-type.hxx"
9317df
+#include "xmlserializable.hxx"
9317df
+
9317df
+namespace libcmis
9317df
+{
9317df
+    class ObjectType;
9317df
+
9317df
+    class Property : public XmlSerializable
9317df
+    {
9317df
+        private:
9317df
+            PropertyTypePtr m_propertyType;
9317df
+            std::vector< std::string > m_strValues;
9317df
+            std::vector< bool > m_boolValues;
9317df
+            std::vector< long > m_longValues;
9317df
+            std::vector< double > m_doubleValues;
9317df
+            std::vector< boost::posix_time::ptime > m_dateTimeValues;
9317df
+
9317df
+        protected:
9317df
+            Property( );
9317df
+
9317df
+        public:
9317df
+            /** Property constructor allowing to use different values for the id and names.
9317df
+              */
9317df
+            Property( PropertyTypePtr propertyType, std::vector< std::string > strValues );
9317df
+
9317df
+            ~Property( ){ }
9317df
+
9317df
+            PropertyTypePtr getPropertyType( ) { return m_propertyType; }
9317df
+
9317df
+            std::vector< boost::posix_time::ptime > getDateTimes( ) { return m_dateTimeValues; }
9317df
+            std::vector< bool > getBools( ) { return m_boolValues; }
9317df
+            std::vector< std::string > getStrings( ) { return m_strValues; }
9317df
+            std::vector< long > getLongs( ) { return m_longValues; }
9317df
+            std::vector< double > getDoubles( ) { return m_doubleValues; }
9317df
+
9317df
+            void setPropertyType( PropertyTypePtr propertyType);
9317df
+            void setValues( std::vector< std::string > strValues );
9317df
+
9317df
+            void toXml( xmlTextWriterPtr writer );
9317df
+
9317df
+            std::string toString( );
9317df
+    };
9317df
+    typedef ::boost::shared_ptr< Property > PropertyPtr;
9317df
+    typedef std::map< std::string, libcmis::PropertyPtr > PropertyPtrMap;
9317df
+
9317df
+    PropertyPtr parseProperty( xmlNodePtr node, boost::shared_ptr< ObjectType > objectType );
9317df
+}
9317df
+
9317df
+#endif
9317df
diff --git a/include/libcmis/rendition.hxx b/include/libcmis/rendition.hxx
9317df
new file mode 100644
9317df
index 000000000000..2e386515e77d
9317df
--- /dev/null
9317df
+++ b/include/libcmis/rendition.hxx
9317df
@@ -0,0 +1,88 @@
9317df
+/* libcmis
9317df
+ * Version: MPL 1.1 / GPLv2+ / LGPLv2+
9317df
+ *
9317df
+ * The contents of this file are subject to the Mozilla Public License Version
9317df
+ * 1.1 (the "License"); you may not use this file except in compliance with
9317df
+ * the License or as specified alternatively below. You may obtain a copy of
9317df
+ * the License at http://www.mozilla.org/MPL/
9317df
+ *
9317df
+ * Software distributed under the License is distributed on an "AS IS" basis,
9317df
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
9317df
+ * for the specific language governing rights and limitations under the
9317df
+ * License.
9317df
+ *
9317df
+ * Major Contributor(s):
9317df
+ * Copyright (C) 2013 Cao Cuong Ngo <cao.cuong.ngo@gmail.com>
9317df
+ *
9317df
+ *
9317df
+ * All Rights Reserved.
9317df
+ *
9317df
+ * For minor contributions see the git repository.
9317df
+ *
9317df
+ * Alternatively, the contents of this file may be used under the terms of
9317df
+ * either the GNU General Public License Version 2 or later (the "GPLv2+"), or
9317df
+ * the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"),
9317df
+ * in which case the provisions of the GPLv2+ or the LGPLv2+ are applicable
9317df
+ * instead of those above.
9317df
+ */
9317df
+
9317df
+#ifndef _RENDITION_HXX_
9317df
+#define _RENDITION_HXX_
9317df
+
9317df
+#include <string>
9317df
+
9317df
+#include <boost/shared_ptr.hpp>
9317df
+#include <libxml/tree.h>
9317df
+
9317df
+namespace libcmis
9317df
+{  
9317df
+    class Rendition
9317df
+    {
9317df
+        private:
9317df
+            Rendition( );
9317df
+    
9317df
+            std::string m_streamId;
9317df
+            std::string m_mimeType;
9317df
+            std::string m_kind;
9317df
+            std::string m_href;
9317df
+            std::string m_title;
9317df
+            long m_length;
9317df
+            long m_width;
9317df
+            long m_height;
9317df
+            std::string m_renditionDocumentId;
9317df
+
9317df
+        public:
9317df
+            Rendition( std::string streamId, std::string mimeType, 
9317df
+                       std::string kind, std::string href,
9317df
+                       std::string title = std::string( ),
9317df
+                       long length = -1, long width = -1, long height = -1,
9317df
+                       std::string renditionDocumentId = std::string( ) );
9317df
+
9317df
+            /** Parse an XML node of type cmisRenditionType
9317df
+              */
9317df
+            Rendition( xmlNodePtr node );
9317df
+            ~Rendition( );
9317df
+            
9317df
+            bool isThumbnail( );
9317df
+
9317df
+            const std::string& getStreamId( ) const;
9317df
+            const std::string& getMimeType( ) const;
9317df
+            const std::string& getKind( ) const;
9317df
+            const std::string& getUrl( ) const;
9317df
+            const std::string& getTitle( ) const;
9317df
+
9317df
+            /** Provides the stream length in bytes or a negative value if missing.
9317df
+              */
9317df
+            long getLength( ) const;
9317df
+            long getWidth( ) const;
9317df
+            long getHeight( ) const;
9317df
+            const std::string& getRenditionDocumentId( );
9317df
+
9317df
+            std::string toString( );
9317df
+    };
9317df
+
9317df
+    typedef ::boost::shared_ptr< Rendition > RenditionPtr;
9317df
+}
9317df
+
9317df
+#endif
9317df
+
9317df
diff --git a/include/libcmis/repository.hxx b/include/libcmis/repository.hxx
9317df
new file mode 100644
9317df
index 000000000000..a4435d89ae75
9317df
--- /dev/null
9317df
+++ b/include/libcmis/repository.hxx
9317df
@@ -0,0 +1,117 @@
9317df
+/* libcmis
9317df
+ * Version: MPL 1.1 / GPLv2+ / LGPLv2+
9317df
+ *
9317df
+ * The contents of this file are subject to the Mozilla Public License Version
9317df
+ * 1.1 (the "License"); you may not use this file except in compliance with
9317df
+ * the License or as specified alternatively below. You may obtain a copy of
9317df
+ * the License at http://www.mozilla.org/MPL/
9317df
+ *
9317df
+ * Software distributed under the License is distributed on an "AS IS" basis,
9317df
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
9317df
+ * for the specific language governing rights and limitations under the
9317df
+ * License.
9317df
+ *
9317df
+ * Major Contributor(s):
9317df
+ * Copyright (C) 2011 Cédric Bosdonnat <cbosdo@users.sourceforge.net>
9317df
+ *
9317df
+ *
9317df
+ * All Rights Reserved.
9317df
+ *
9317df
+ * For minor contributions see the git repository.
9317df
+ *
9317df
+ * Alternatively, the contents of this file may be used under the terms of
9317df
+ * either the GNU General Public License Version 2 or later (the "GPLv2+"), or
9317df
+ * the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"),
9317df
+ * in which case the provisions of the GPLv2+ or the LGPLv2+ are applicable
9317df
+ * instead of those above.
9317df
+ */
9317df
+#ifndef _REPOSITORY_HXX_
9317df
+#define _REPOSITORY_HXX_
9317df
+
9317df
+#include <map>
9317df
+#include <string>
9317df
+
9317df
+#include <boost/shared_ptr.hpp>
9317df
+#include <libxml/tree.h>
9317df
+
9317df
+namespace libcmis
9317df
+{
9317df
+    /** Class representing a repository and its infos.
9317df
+
9317df
+        \sa 2.2.2.2 section of the CMIS specifications
9317df
+      */
9317df
+    class Repository
9317df
+    {
9317df
+        public:
9317df
+
9317df
+            enum Capability
9317df
+            {
9317df
+                ACL,
9317df
+                AllVersionsSearchable,
9317df
+                Changes,
9317df
+                ContentStreamUpdatability,
9317df
+                GetDescendants,
9317df
+                GetFolderTree,
9317df
+                OrderBy,
9317df
+                Multifiling,
9317df
+                PWCSearchable,
9317df
+                PWCUpdatable,
9317df
+                Query,
9317df
+                Renditions,
9317df
+                Unfiling,
9317df
+                VersionSpecificFiling,
9317df
+                Join
9317df
+            };
9317df
+
9317df
+        protected:
9317df
+            std::string m_id;
9317df
+            std::string m_name;
9317df
+            std::string m_description;
9317df
+            std::string m_vendorName;
9317df
+            std::string m_productName;
9317df
+            std::string m_productVersion;
9317df
+            std::string m_rootId;
9317df
+            std::string m_cmisVersionSupported;
9317df
+            boost::shared_ptr< std::string > m_thinClientUri;
9317df
+            boost::shared_ptr< std::string > m_principalAnonymous;
9317df
+            boost::shared_ptr< std::string > m_principalAnyone;
9317df
+
9317df
+            std::map< Capability, std::string > m_capabilities ;
9317df
+
9317df
+            Repository( );
9317df
+            void initializeFromNode( xmlNodePtr node );
9317df
+
9317df
+        public:
9317df
+            Repository( xmlNodePtr node );
9317df
+            virtual ~Repository( ) { };
9317df
+
9317df
+            std::string getId( ) const;
9317df
+            std::string getName( ) const;
9317df
+            std::string getDescription( ) const;
9317df
+            std::string getVendorName( ) const;
9317df
+            std::string getProductName( ) const;
9317df
+            std::string getProductVersion( ) const;
9317df
+            std::string getRootId( ) const;
9317df
+            std::string getCmisVersionSupported( ) const;
9317df
+            boost::shared_ptr< std::string > getThinClientUri( ) const;
9317df
+            boost::shared_ptr< std::string > getPrincipalAnonymous( ) const;
9317df
+            boost::shared_ptr< std::string > getPrincipalAnyone( ) const;
9317df
+
9317df
+            std::string getCapability( Capability capability ) const;
9317df
+
9317df
+            /** Wrapper function providing the capability as a boolean value.
9317df
+                If the capability value is not a boolean, returns false.
9317df
+             */
9317df
+            bool getCapabilityAsBool( Capability capability ) const;
9317df
+
9317df
+            std::string toString( ) const;
9317df
+
9317df
+        private:
9317df
+
9317df
+            static std::map< Capability, std::string > parseCapabilities( xmlNodePtr node );
9317df
+    };
9317df
+    
9317df
+    typedef ::boost::shared_ptr< Repository > RepositoryPtr;
9317df
+}
9317df
+
9317df
+#endif
9317df
diff --git a/include/libcmis/session-factory.hxx b/include/libcmis/session-factory.hxx
9317df
new file mode 100644
9317df
index 000000000000..b0b94f835f30
9317df
--- /dev/null
9317df
+++ b/include/libcmis/session-factory.hxx
9317df
@@ -0,0 +1,149 @@
9317df
+/* libcmis
9317df
+ * Version: MPL 1.1 / GPLv2+ / LGPLv2+
9317df
+ *
9317df
+ * The contents of this file are subject to the Mozilla Public License Version
9317df
+ * 1.1 (the "License"); you may not use this file except in compliance with
9317df
+ * the License or as specified alternatively below. You may obtain a copy of
9317df
+ * the License at http://www.mozilla.org/MPL/
9317df
+ *
9317df
+ * Software distributed under the License is distributed on an "AS IS" basis,
9317df
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
9317df
+ * for the specific language governing rights and limitations under the
9317df
+ * License.
9317df
+ *
9317df
+ * Major Contributor(s):
9317df
+ * Copyright (C) 2011 SUSE <cbosdonnat@suse.com>
9317df
+ *
9317df
+ *
9317df
+ * All Rights Reserved.
9317df
+ *
9317df
+ * For minor contributions see the git repository.
9317df
+ *
9317df
+ * Alternatively, the contents of this file may be used under the terms of
9317df
+ * either the GNU General Public License Version 2 or later (the "GPLv2+"), or
9317df
+ * the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"),
9317df
+ * in which case the provisions of the GPLv2+ or the LGPLv2+ are applicable
9317df
+ * instead of those above.
9317df
+ */
9317df
+#ifndef _SESSION_FACTORY_HXX_
9317df
+#define _SESSION_FACTORY_HXX_
9317df
+
9317df
+#include <vector>
9317df
+#include <map>
9317df
+#include <string>
9317df
+
9317df
+#include "exception.hxx"
9317df
+#include "oauth2-data.hxx"
9317df
+#include "repository.hxx"
9317df
+#include "session.hxx"
9317df
+
9317df
+namespace libcmis
9317df
+{
9317df
+    /** This callback provides the OAuth2 code or NULL.
9317df
+
9317df
+        The resulting char* will be freed later.
9317df
+      */
9317df
+    typedef char* ( *OAuth2AuthCodeProvider )( const char* authUrl,
9317df
+        const char* username, const char* password );
9317df
+
9317df
+    class AuthProvider 
9317df
+    {
9317df
+        public:
9317df
+            virtual ~AuthProvider() { };
9317df
+
9317df
+            /** The function implementing it needs to fill the username and password parameters
9317df
+                and return true. Returning false means that the user cancelled the authentication
9317df
+                and will fail the query.
9317df
+              */
9317df
+            virtual bool authenticationQuery( std::string& username, std::string& password ) = 0;
9317df
+    };
9317df
+    typedef ::boost::shared_ptr< AuthProvider > AuthProviderPtr;
9317df
+  
9317df
+    /** Handler class used to request user input when an invalid SSL certificate is encountered.
9317df
+     */ 
9317df
+    class CertValidationHandler
9317df
+    {
9317df
+        public:
9317df
+             virtual ~CertValidationHandler( ){ };
9317df
+
9317df
+             /** This function is provided a vector of X509 certificates encoded in base64, with
9317df
+                 the first certificate being the one to validate, and the others are the issuers
9317df
+                 chain.
9317df
+
9317df
+                 The result will be stored in the session object to avoid asking several times
9317df
+                 to validate the same certificate.
9317df
+
9317df
+                 \result true if the certificate should be ignored, false to fail the request.
9317df
+               */
9317df
+             virtual bool validateCertificate( std::vector< std::string > certificatesChain ) = 0;
9317df
+    };
9317df
+    typedef ::boost::shared_ptr< CertValidationHandler > CertValidationHandlerPtr;
9317df
+
9317df
+    class SessionFactory
9317df
+    {
9317df
+        private:
9317df
+
9317df
+            static AuthProviderPtr s_authProvider;
9317df
+
9317df
+            static std::string s_proxy;
9317df
+            static std::string s_noProxy;
9317df
+            static std::string s_proxyUser;
9317df
+            static std::string s_proxyPass;
9317df
+
9317df
+            static OAuth2AuthCodeProvider s_oauth2AuthCodeProvider;
9317df
+
9317df
+            static CertValidationHandlerPtr s_certValidationHandler;
9317df
+
9317df
+        public:
9317df
+
9317df
+            static void setAuthenticationProvider( AuthProviderPtr provider ) { s_authProvider = provider; }
9317df
+            static AuthProviderPtr getAuthenticationProvider( ) { return s_authProvider; }
9317df
+            
9317df
+            static void setOAuth2AuthCodeProvider( OAuth2AuthCodeProvider provider ) { s_oauth2AuthCodeProvider = provider; }
9317df
+            static OAuth2AuthCodeProvider getOAuth2AuthCodeProvider( ) { return s_oauth2AuthCodeProvider; }
9317df
+
9317df
+            /** Set the handler to ask the user what to do with invalid SSL certificates. If not set,
9317df
+                every invalid certificate will raise an exception.
9317df
+              */
9317df
+            static void setCertificateValidationHandler( CertValidationHandlerPtr handler ) { s_certValidationHandler = handler; }
9317df
+            static CertValidationHandlerPtr getCertificateValidationHandler( ) { return s_certValidationHandler; }
9317df
+
9317df
+            static void setProxySettings( std::string proxy,
9317df
+                    std::string noProxy,
9317df
+                    std::string proxyUser,
9317df
+                    std::string proxyPass );
9317df
+
9317df
+            static const std::string& getProxy() { return s_proxy; }
9317df
+            static const std::string& getNoProxy() { return s_noProxy; }
9317df
+            static const std::string& getProxyUser() { return s_proxyUser; }
9317df
+            static const std::string& getProxyPass() { return s_proxyPass; }
9317df
+
9317df
+            /** Create a session from the given parameters. The binding type is automatically
9317df
+                detected based on the provided URL.
9317df
+
9317df
+                The resulting pointer should be deleted by the caller.
9317df
+              */
9317df
+            static Session* createSession( std::string bindingUrl,
9317df
+                    std::string username = std::string( ),
9317df
+                    std::string password = std::string( ),
9317df
+                    std::string repositoryId = std::string( ),
9317df
+                    bool noSslCheck = false,
9317df
+                    OAuth2DataPtr oauth2 = OAuth2DataPtr(), bool verbose = false );
9317df
+
9317df
+            /**
9317df
+                Gets the informations of the repositories on the server.
9317df
+
9317df
+                \deprecated
9317df
+                    Since libcmis 0.4.0, this helper function simply creates a session
9317df
+                    using the createSession function with no repository and then calls
9317df
+                    getRepositories on the resulting session.
9317df
+                    Kept only for backward API compatibility.
9317df
+              */
9317df
+            static std::vector< RepositoryPtr > getRepositories( std::string bindingUrl,
9317df
+                    std::string username = std::string( ),
9317df
+                    std::string password = std::string( ),
9317df
+                    bool verbose = false );
9317df
+    };
9317df
+}
9317df
+
9317df
+#endif
9317df
diff --git a/include/libcmis/session.hxx b/include/libcmis/session.hxx
9317df
new file mode 100644
9317df
index 000000000000..d28361a15005
9317df
--- /dev/null
9317df
+++ b/include/libcmis/session.hxx
9317df
@@ -0,0 +1,100 @@
9317df
+/* libcmis
9317df
+ * Version: MPL 1.1 / GPLv2+ / LGPLv2+
9317df
+ *
9317df
+ * The contents of this file are subject to the Mozilla Public License Version
9317df
+ * 1.1 (the "License"); you may not use this file except in compliance with
9317df
+ * the License or as specified alternatively below. You may obtain a copy of
9317df
+ * the License at http://www.mozilla.org/MPL/
9317df
+ *
9317df
+ * Software distributed under the License is distributed on an "AS IS" basis,
9317df
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
9317df
+ * for the specific language governing rights and limitations under the
9317df
+ * License.
9317df
+ *
9317df
+ * Major Contributor(s):
9317df
+ * Copyright (C) 2011 SUSE <cbosdonnat@suse.com>
9317df
+ *
9317df
+ *
9317df
+ * All Rights Reserved.
9317df
+ *
9317df
+ * For minor contributions see the git repository.
9317df
+ *
9317df
+ * Alternatively, the contents of this file may be used under the terms of
9317df
+ * either the GNU General Public License Version 2 or later (the "GPLv2+"), or
9317df
+ * the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"),
9317df
+ * in which case the provisions of the GPLv2+ or the LGPLv2+ are applicable
9317df
+ * instead of those above.
9317df
+ */
9317df
+#ifndef _SESSION_HXX_
9317df
+#define _SESSION_HXX_
9317df
+
9317df
+#include <vector>
9317df
+#include <string>
9317df
+#include <boost/shared_ptr.hpp>
9317df
+
9317df
+#include "object-type.hxx"
9317df
+#include "object.hxx"
9317df
+#include "folder.hxx"
9317df
+#include "repository.hxx"
9317df
+
9317df
+namespace libcmis
9317df
+{
9317df
+    class Session
9317df
+    {
9317df
+        public:
9317df
+
9317df
+            virtual ~Session() { };
9317df
+
9317df
+            /** Get the current repository.
9317df
+              */
9317df
+            virtual RepositoryPtr getRepository( ) = 0;
9317df
+
9317df
+            virtual std::vector< RepositoryPtr > getRepositories( ) = 0;
9317df
+
9317df
+            /** Change the current repository.
9317df
+
9317df
+                \return
9317df
+                    false if no repository with the provided id can be found on the server,
9317df
+                    true otherwise
9317df
+              */
9317df
+            virtual bool setRepository( std::string repositoryId ) = 0;
9317df
+
9317df
+            /** Get the Root folder of the repository
9317df
+              */
9317df
+            virtual FolderPtr getRootFolder() = 0;
9317df
+            
9317df
+            /** Get a CMIS object from its ID.
9317df
+              */
9317df
+            virtual ObjectPtr getObject( std::string id ) = 0;
9317df
+
9317df
+            /** Get a CMIS object from one of its path.
9317df
+              */
9317df
+            virtual ObjectPtr getObjectByPath( std::string path ) = 0;
9317df
+
9317df
+            /** Get a CMIS folder from its ID.
9317df
+              */
9317df
+            virtual libcmis::FolderPtr getFolder( std::string id ) = 0;
9317df
+
9317df
+            /** Get a CMIS object type from its ID.
9317df
+              */
9317df
+            virtual ObjectTypePtr getType( std::string id ) = 0;
9317df
+
9317df
+            /** Get all the CMIS base object types known by the server.
9317df
+              */
9317df
+            virtual std::vector< ObjectTypePtr > getBaseTypes( ) = 0;
9317df
+
9317df
+            /** Enable or disable the SSL certificate verification.
9317df
+
9317df
+                By default, SSL certificates are verified and errors are thrown in case of
9317df
+                one is invalid. The user may decide to ignore the checks for this CMIS session
9317df
+                to workaround self-signed certificates or other similar problems.
9317df
+
9317df
+                As each session only handles the connection to one CMIS server, it should
9317df
+                concern only one SSL certificate and should provide the same feature as the
9317df
+                certificate exception feature available on common web browser.
9317df
+              */
9317df
+            virtual void setNoSSLCertificateCheck( bool noCheck ) = 0;
9317df
+    };
9317df
+}
9317df
+
9317df
+#endif
9317df
diff --git a/include/libcmis/xml-utils.hxx b/include/libcmis/xml-utils.hxx
9317df
new file mode 100644
9317df
index 000000000000..afe5985dad23
9317df
--- /dev/null
9317df
+++ b/include/libcmis/xml-utils.hxx
9317df
@@ -0,0 +1,167 @@
9317df
+/* libcmis
9317df
+ * Version: MPL 1.1 / GPLv2+ / LGPLv2+
9317df
+ *
9317df
+ * The contents of this file are subject to the Mozilla Public License Version
9317df
+ * 1.1 (the "License"); you may not use this file except in compliance with
9317df
+ * the License or as specified alternatively below. You may obtain a copy of
9317df
+ * the License at http://www.mozilla.org/MPL/
9317df
+ *
9317df
+ * Software distributed under the License is distributed on an "AS IS" basis,
9317df
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
9317df
+ * for the specific language governing rights and limitations under the
9317df
+ * License.
9317df
+ *
9317df
+ * Major Contributor(s):
9317df
+ * Copyright (C) 2011 SUSE <cbosdonnat@suse.com>
9317df
+ *
9317df
+ *
9317df
+ * All Rights Reserved.
9317df
+ *
9317df
+ * For minor contributions see the git repository.
9317df
+ *
9317df
+ * Alternatively, the contents of this file may be used under the terms of
9317df
+ * either the GNU General Public License Version 2 or later (the "GPLv2+"), or
9317df
+ * the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"),
9317df
+ * in which case the provisions of the GPLv2+ or the LGPLv2+ are applicable
9317df
+ * instead of those above.
9317df
+ */
9317df
+#ifndef _XML_UTILS_HXX_
9317df
+#define _XML_UTILS_HXX_
9317df
+
9317df
+#include <map>
9317df
+#include <ostream>
9317df
+#include <sstream>
9317df
+#include <string>
9317df
+
9317df
+#include <boost/date_time.hpp>
9317df
+#include <libxml/tree.h>
9317df
+#include <libxml/xpathInternals.h>
9317df
+#include <libxml/xmlwriter.h>
9317df
+
9317df
+#include "exception.hxx"
9317df
+
9317df
+#define NS_CMIS_PREFIX      "cmis"
9317df
+#define NS_CMISRA_PREFIX    "cmisra"
9317df
+#define NS_SOAP_ENV_PREFIX  "soap-env"
9317df
+#define NS_CMIS_URL         "http://docs.oasis-open.org/ns/cmis/core/200908/"
9317df
+#define NS_CMISRA_URL       "http://docs.oasis-open.org/ns/cmis/restatom/200908/"
9317df
+#define NS_CMISM_URL        "http://docs.oasis-open.org/ns/cmis/messaging/200908/"
9317df
+#define NS_CMISW_URL        "http://docs.oasis-open.org/ns/cmis/ws/200908/"
9317df
+#define NS_APP_URL          "http://www.w3.org/2007/app"
9317df
+#define NS_ATOM_URL         "http://www.w3.org/2005/Atom"
9317df
+#define NS_SOAP_URL         "http://schemas.xmlsoap.org/wsdl/soap/"
9317df
+#define NS_SOAP_ENV_URL     "http://schemas.xmlsoap.org/soap/envelope/"
9317df
+
9317df
+#define LIBCURL_VERSION_VALUE ( \
9317df
+        ( LIBCURL_VERSION_MAJOR << 16 ) | ( LIBCURL_VERSION_MINOR << 8 ) | ( LIBCURL_VERSION_PATCH ) \
9317df
+)
9317df
+
9317df
+namespace libcmis
9317df
+{
9317df
+    /** Class used to decode a stream.
9317df
+
9317df
+        An instance of this class can hold remaining un-decoded data to use
9317df
+        for a future decode call.
9317df
+      */
9317df
+    class EncodedData
9317df
+    {
9317df
+        private:
9317df
+            xmlTextWriterPtr m_writer;
9317df
+            FILE* m_stream;
9317df
+            std::ostream* m_outStream;
9317df
+
9317df
+            std::string m_encoding;
9317df
+            bool m_decode;
9317df
+            unsigned long m_pendingValue;
9317df
+            int m_pendingRank;
9317df
+            size_t m_missingBytes;
9317df
+
9317df
+        public:
9317df
+            EncodedData( FILE* stream );
9317df
+            EncodedData( std::ostream* stream );
9317df
+            EncodedData( const EncodedData& rCopy );
9317df
+            EncodedData( xmlTextWriterPtr writer );
9317df
+
9317df
+            EncodedData& operator=( const EncodedData& rCopy );
9317df
+
9317df
+            void setEncoding( std::string encoding ) { m_encoding = encoding; }
9317df
+            void decode( void* buf, size_t size, size_t nmemb );
9317df
+            void encode( void* buf, size_t size, size_t nmemb );
9317df
+            void finish( );
9317df
+
9317df
+        private:
9317df
+            void write( void* buf, size_t size, size_t nmemb );
9317df
+            void decodeBase64( const char* buf, size_t len );
9317df
+            void encodeBase64( const char* buf, size_t len );
9317df
+    };
9317df
+
9317df
+    class HttpResponse
9317df
+    {
9317df
+        private:
9317df
+            std::map< std::string, std::string > m_headers;
9317df
+            boost::shared_ptr< std::stringstream > m_stream;
9317df
+            boost::shared_ptr< EncodedData > m_data;
9317df
+
9317df
+        public:
9317df
+            HttpResponse( );
9317df
+            ~HttpResponse( ) { };
9317df
+
9317df
+            std::map< std::string, std::string >& getHeaders( ) { return m_headers; }
9317df
+            boost::shared_ptr< EncodedData > getData( ) { return m_data; }
9317df
+            boost::shared_ptr< std::stringstream > getStream( ) { return m_stream; }
9317df
+    };
9317df
+    typedef boost::shared_ptr< HttpResponse > HttpResponsePtr;
9317df
+
9317df
+    void registerNamespaces( xmlXPathContextPtr xpathCtx );
9317df
+
9317df
+    /** Register the CMIS and WSDL / SOAP namespaces
9317df
+      */
9317df
+    void registerCmisWSNamespaces( xmlXPathContextPtr xpathCtx );
9317df
+
9317df
+    /** Register only the WSD / SOAP namespaces.
9317df
+      */
9317df
+    void registerSoapNamespaces( xmlXPathContextPtr xpathCtx );
9317df
+
9317df
+    std::string getXPathValue( xmlXPathContextPtr xpathCtx, std::string req );
9317df
+
9317df
+    xmlDocPtr wrapInDoc( xmlNodePtr entryNode );
9317df
+
9317df
+    /** Utility extracting an attribute value from an Xml Node,
9317df
+        based on the attribute name. If the defaultValue is NULL and
9317df
+        the attribute can't be found then throw an exception.
9317df
+      */
9317df
+    std::string getXmlNodeAttributeValue( xmlNodePtr node,
9317df
+                                          const char* attributeName,
9317df
+                                          const char* defaultValue = NULL );
9317df
+
9317df
+    /** Parse a xsd:dateTime string and return the corresponding UTC posix time.
9317df
+     */
9317df
+    boost::posix_time::ptime parseDateTime( std::string dateTimeStr );
9317df
+
9317df
+    /// Write a UTC time object to an xsd:dateTime string
9317df
+    std::string writeDateTime( boost::posix_time::ptime time );
9317df
+
9317df
+    bool parseBool( std::string str );
9317df
+
9317df
+    long parseInteger( std::string str );
9317df
+
9317df
+    double parseDouble( std::string str );
9317df
+
9317df
+    /** Trim spaces on the left and right of a string.
9317df
+     */
9317df
+    std::string trim( const std::string& str );
9317df
+
9317df
+    std::string base64encode( const std::string& str );
9317df
+
9317df
+    std::string sha1( const std::string& str );
9317df
+
9317df
+    std::string tolower( std::string sText );
9317df
+
9317df
+    int stringstream_write_callback(void * context, const char * s, int len);
9317df
+
9317df
+    std::string escape( std::string str );
9317df
+
9317df
+    std::string unescape( std::string str );
9317df
+}
9317df
+
9317df
+#endif
9317df
diff --git a/include/libcmis/xmlserializable.hxx b/include/libcmis/xmlserializable.hxx
9317df
new file mode 100644
9317df
index 000000000000..533308590073
9317df
--- /dev/null
9317df
+++ b/include/libcmis/xmlserializable.hxx
9317df
@@ -0,0 +1,46 @@
9317df
+/* libcmis
9317df
+ * Version: MPL 1.1 / GPLv2+ / LGPLv2+
9317df
+ *
9317df
+ * The contents of this file are subject to the Mozilla Public License Version
9317df
+ * 1.1 (the "License"); you may not use this file except in compliance with
9317df
+ * the License or as specified alternatively below. You may obtain a copy of
9317df
+ * the License at http://www.mozilla.org/MPL/
9317df
+ *
9317df
+ * Software distributed under the License is distributed on an "AS IS" basis,
9317df
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
9317df
+ * for the specific language governing rights and limitations under the
9317df
+ * License.
9317df
+ *
9317df
+ * Major Contributor(s):
9317df
+ * Copyright (C) 2011 SUSE <cbosdonnat@suse.com>
9317df
+ *
9317df
+ *
9317df
+ * All Rights Reserved.
9317df
+ *
9317df
+ * For minor contributions see the git repository.
9317df
+ *
9317df
+ * Alternatively, the contents of this file may be used under the terms of
9317df
+ * either the GNU General Public License Version 2 or later (the "GPLv2+"), or
9317df
+ * the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"),
9317df
+ * in which case the provisions of the GPLv2+ or the LGPLv2+ are applicable
9317df
+ * instead of those above.
9317df
+ */
9317df
+#ifndef _XMLSERIALIZABLE_HXX_
9317df
+#define _XMLSERIALIZABLE_HXX_
9317df
+
9317df
+#include <libxml/xmlwriter.h>
9317df
+
9317df
+namespace libcmis
9317df
+{
9317df
+
9317df
+    /// Interface for objects dumpable as XML
9317df
+    class XmlSerializable
9317df
+    {
9317df
+        public:
9317df
+            virtual ~XmlSerializable( ) { }
9317df
+
9317df
+            virtual void toXml( xmlTextWriterPtr writer ) = 0;
9317df
+    };
9317df
+}
9317df
+
9317df
+#endif
9317df
-- 
9317df
2.26.2
9317df