summaryrefslogtreecommitdiffstats
path: root/src/libcmis-c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 05:41:20 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 05:41:20 +0000
commit2cd20b3e73d0162e3fa23ebcee8e89a3b967ca6f (patch)
tree754a142de5cd8f987abe255e8a15b5ef94109da4 /src/libcmis-c
parentInitial commit. (diff)
downloadlibcmis-upstream/0.6.2.tar.xz
libcmis-upstream/0.6.2.zip
Adding upstream version 0.6.2.upstream/0.6.2upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/libcmis-c')
-rw-r--r--src/libcmis-c/Makefile.am39
-rw-r--r--src/libcmis-c/allowable-actions.cxx56
-rw-r--r--src/libcmis-c/document.cxx448
-rw-r--r--src/libcmis-c/error.cxx74
-rw-r--r--src/libcmis-c/folder.cxx369
-rw-r--r--src/libcmis-c/internals.hxx242
-rw-r--r--src/libcmis-c/oauth2-data.cxx110
-rw-r--r--src/libcmis-c/object-type.cxx388
-rw-r--r--src/libcmis-c/object.cxx512
-rw-r--r--src/libcmis-c/property-type.cxx201
-rw-r--r--src/libcmis-c/property.cxx200
-rw-r--r--src/libcmis-c/rendition.cxx110
-rw-r--r--src/libcmis-c/repository.cxx208
-rw-r--r--src/libcmis-c/session-factory.cxx239
-rw-r--r--src/libcmis-c/session.cxx305
-rw-r--r--src/libcmis-c/vectors.cxx139
16 files changed, 3640 insertions, 0 deletions
diff --git a/src/libcmis-c/Makefile.am b/src/libcmis-c/Makefile.am
new file mode 100644
index 0000000..1510272
--- /dev/null
+++ b/src/libcmis-c/Makefile.am
@@ -0,0 +1,39 @@
+
+libcmis_c_@LIBCMIS_API_VERSION@_la_CXXFLAGS = \
+ -I$(top_srcdir)/inc \
+ -I$(top_srcdir)/inc/libcmis-c \
+ $(XML2_CFLAGS) \
+ $(BOOST_CPPFLAGS)
+
+libcmis_c_@LIBCMIS_API_VERSION@_la_CPPFLAGS = -DLIBCMIS_C_BUILD
+if ENABLE_VISIBILITY
+libcmis_c_@LIBCMIS_API_VERSION@_la_CXXFLAGS += -fvisibility=hidden
+libcmis_c_@LIBCMIS_API_VERSION@_la_CPPFLAGS += -DLIBCMIS_C_VISIBILITY
+endif
+
+lib_LTLIBRARIES = libcmis-c-@LIBCMIS_API_VERSION@.la
+libcmis_c_@LIBCMIS_API_VERSION@_la_SOURCES = \
+ allowable-actions.cxx \
+ document.cxx \
+ error.cxx \
+ folder.cxx \
+ internals.hxx \
+ oauth2-data.cxx \
+ object-type.cxx \
+ object.cxx \
+ property-type.cxx \
+ property.cxx \
+ rendition.cxx \
+ repository.cxx \
+ session-factory.cxx \
+ session.cxx \
+ vectors.cxx
+
+libcmis_c_@LIBCMIS_API_VERSION@_la_LDFLAGS = -export-dynamic -no-undefined -version-info 6:0:0
+
+libcmis_c_@LIBCMIS_API_VERSION@_la_LIBADD = \
+ ../libcmis/libcmis-@LIBCMIS_API_VERSION@.la \
+ $(XML2_LIBS) \
+ $(CURL_LIBS) \
+ $(BOOST_SMART_PTR_LIBS) \
+ $(BOOST_DATE_TIME_LIBS)
diff --git a/src/libcmis-c/allowable-actions.cxx b/src/libcmis-c/allowable-actions.cxx
new file mode 100644
index 0000000..f08f366
--- /dev/null
+++ b/src/libcmis-c/allowable-actions.cxx
@@ -0,0 +1,56 @@
+/* libcmis
+ * Version: MPL 1.1 / GPLv2+ / LGPLv2+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License or as specified alternatively below. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * Major Contributor(s):
+ * Copyright (C) 2011 SUSE <cbosdonnat@suse.com>
+ *
+ *
+ * All Rights Reserved.
+ *
+ * For minor contributions see the git repository.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPLv2+"), or
+ * the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"),
+ * in which case the provisions of the GPLv2+ or the LGPLv2+ are applicable
+ * instead of those above.
+ */
+
+#include <libcmis-c/allowable-actions.h>
+
+#include "internals.hxx"
+
+void libcmis_allowable_actions_free( libcmis_AllowableActionsPtr allowable )
+{
+ delete allowable;
+}
+
+
+bool libcmis_allowable_actions_isAllowed( libcmis_AllowableActionsPtr allowable,
+ libcmis_allowable_actions_Type action )
+{
+ bool result = false;
+ if ( allowable != NULL && allowable->handle.get( ) != NULL )
+ result = allowable->handle->isAllowed( libcmis::ObjectAction::Type( action ) );
+ return result;
+}
+
+
+bool libcmis_allowable_actions_isDefined( libcmis_AllowableActionsPtr allowable,
+ libcmis_allowable_actions_Type action )
+{
+ bool result = false;
+ if ( allowable != NULL && allowable->handle.get( ) != NULL )
+ result = allowable->handle->isDefined( libcmis::ObjectAction::Type( action ) );
+ return result;
+}
diff --git a/src/libcmis-c/document.cxx b/src/libcmis-c/document.cxx
new file mode 100644
index 0000000..74d04d9
--- /dev/null
+++ b/src/libcmis-c/document.cxx
@@ -0,0 +1,448 @@
+/* libcmis
+ * Version: MPL 1.1 / GPLv2+ / LGPLv2+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License or as specified alternatively below. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * Major Contributor(s):
+ * Copyright (C) 2011 SUSE <cbosdonnat@suse.com>
+ *
+ *
+ * All Rights Reserved.
+ *
+ * For minor contributions see the git repository.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPLv2+"), or
+ * the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"),
+ * in which case the provisions of the GPLv2+ or the LGPLv2+ are applicable
+ * instead of those above.
+ */
+
+#include <libcmis-c/document.h>
+
+#include "internals.hxx"
+
+using namespace std;
+using libcmis::DocumentPtr;
+using libcmis::FolderPtr;
+using libcmis::PropertyPtrMap;
+using boost::dynamic_pointer_cast;
+
+void libcmis_vector_document_free( libcmis_vector_document_Ptr vector )
+{
+ delete vector;
+}
+
+
+size_t libcmis_vector_document_size( libcmis_vector_document_Ptr vector )
+{
+ size_t size = 0;
+ if ( vector != NULL )
+ size = vector->handle.size( );
+ return size;
+}
+
+
+libcmis_DocumentPtr libcmis_vector_document_get( libcmis_vector_document_Ptr vector, size_t i )
+{
+ libcmis_DocumentPtr item = NULL;
+ if ( vector != NULL && i < vector->handle.size( ) )
+ {
+ libcmis::DocumentPtr handle = vector->handle[i];
+ item = new( nothrow ) libcmis_document( );
+ item->handle = handle;
+ }
+ return item;
+}
+
+bool libcmis_is_document( libcmis_ObjectPtr object )
+{
+ bool isDocument = false;
+ if ( object != NULL && object->handle.get( ) != NULL )
+ {
+ DocumentPtr document = dynamic_pointer_cast< libcmis::Document >( object->handle );
+ isDocument = document.get( ) != NULL;
+ }
+ return isDocument;
+}
+
+
+libcmis_DocumentPtr libcmis_document_cast( libcmis_ObjectPtr object )
+{
+ libcmis_DocumentPtr document = NULL;
+
+ if ( object != NULL && object->handle.get( ) != NULL &&
+ libcmis_is_document( object ) )
+ {
+ document = new ( nothrow ) libcmis_document( );
+ document->handle = object->handle;
+ }
+
+ return document;
+}
+
+
+void libcmis_document_free( libcmis_DocumentPtr document )
+{
+ delete document;
+}
+
+
+libcmis_vector_folder_Ptr libcmis_document_getParents( libcmis_DocumentPtr document, libcmis_ErrorPtr error )
+{
+ libcmis_vector_folder_Ptr parents = NULL;
+ if ( document != NULL && document->handle.get( ) != NULL )
+ {
+ try
+ {
+ DocumentPtr doc = dynamic_pointer_cast< libcmis::Document >( document->handle );
+ if ( doc )
+ {
+ vector< libcmis::FolderPtr > handles = doc->getParents( );
+ parents = new libcmis_vector_folder( );
+ parents->handle = handles;
+ }
+ }
+ catch ( const libcmis::Exception& e )
+ {
+ if ( error != NULL )
+ {
+ error->message = strdup( e.what() );
+ error->type = strdup( e.getType().c_str() );
+ }
+ }
+ catch ( const bad_alloc& e )
+ {
+ if ( error != NULL )
+ {
+ error->message = strdup( e.what() );
+ error->badAlloc = true;
+ }
+ }
+ }
+ return parents;
+}
+
+
+void libcmis_document_getContentStream(
+ libcmis_DocumentPtr document,
+ libcmis_writeFn writeFn,
+ void* userData,
+ libcmis_ErrorPtr error )
+{
+ if ( document != NULL && document->handle.get( ) != NULL )
+ {
+ try
+ {
+ DocumentPtr doc = dynamic_pointer_cast< libcmis::Document >( document->handle );
+ if ( doc )
+ {
+ boost::shared_ptr< istream > stream = doc->getContentStream( );
+
+ stream->seekg( 0 );
+ int bufSize = 2048;
+ char* buf = new char[ bufSize ];
+ while ( !stream->eof( ) )
+ {
+ stream->read( buf, bufSize );
+ size_t read = stream->gcount( );
+ writeFn( ( const void * )buf, size_t( 1 ), read, userData );
+ }
+ delete[] buf;
+ }
+ }
+ catch ( const libcmis::Exception& e )
+ {
+ if ( error != NULL )
+ {
+ error->message = strdup( e.what() );
+ error->type = strdup( e.getType().c_str() );
+ }
+ }
+ catch ( const bad_alloc& e )
+ {
+ if ( error != NULL )
+ {
+ error->message = strdup( e.what() );
+ error->badAlloc = true;
+ }
+ }
+ catch ( const exception& e )
+ {
+ if ( error != NULL )
+ error->message = strdup( e.what() );
+ }
+ catch ( ... )
+ {
+ }
+ }
+}
+
+
+void libcmis_document_setContentStream(
+ libcmis_DocumentPtr document,
+ libcmis_readFn readFn,
+ void* userData,
+ const char* contentType,
+ const char* fileName,
+ bool overwrite,
+ libcmis_ErrorPtr error )
+{
+ if ( document != NULL && document->handle.get( ) != NULL )
+ {
+ try
+ {
+ boost::shared_ptr< std::ostream > stream( new stringstream( ) );
+
+ size_t bufSize = 2048;
+ char* buf = new char[ bufSize ];
+ size_t read = 0;
+ do
+ {
+ read = readFn( ( void * )buf, size_t( 1 ), bufSize, userData );
+ stream->write( buf, read );
+ } while ( read == bufSize );
+ delete[] buf;
+
+ DocumentPtr doc = dynamic_pointer_cast< libcmis::Document >( document->handle );
+ if ( doc )
+ doc->setContentStream( stream, contentType, fileName, overwrite );
+ }
+ catch ( const libcmis::Exception& e )
+ {
+ if ( error != NULL )
+ {
+ error->message = strdup( e.what() );
+ error->type = strdup( e.getType().c_str() );
+ }
+ }
+ catch ( const bad_alloc& e )
+ {
+ if ( error != NULL )
+ {
+ error->message = strdup( e.what() );
+ error->badAlloc = true;
+ }
+ }
+ catch ( const exception& e )
+ {
+ if ( error != NULL )
+ error->message = strdup( e.what() );
+ }
+ }
+}
+
+
+char* libcmis_document_getContentType( libcmis_DocumentPtr document )
+{
+ char* value = NULL;
+ if ( document != NULL && document->handle.get( ) != NULL )
+ {
+ DocumentPtr doc = dynamic_pointer_cast< libcmis::Document >( document->handle );
+ if ( doc )
+ value = strdup( doc->getContentType( ).c_str( ) );
+ }
+ return value;
+}
+
+
+char* libcmis_document_getContentFilename( libcmis_DocumentPtr document )
+{
+ char* value = NULL;
+ if ( document != NULL && document->handle.get( ) != NULL )
+ {
+ DocumentPtr doc = dynamic_pointer_cast< libcmis::Document >( document->handle );
+ if ( doc )
+ value = strdup( doc->getContentFilename( ).c_str( ) );
+ }
+ return value;
+}
+
+
+long libcmis_document_getContentLength( libcmis_DocumentPtr document )
+{
+ long value = 0;
+ if ( document != NULL && document->handle.get( ) != NULL )
+ {
+ DocumentPtr doc = dynamic_pointer_cast< libcmis::Document >( document->handle );
+ if ( doc )
+ value = doc->getContentLength( );
+ }
+ return value;
+}
+
+
+libcmis_DocumentPtr libcmis_document_checkOut( libcmis_DocumentPtr document, libcmis_ErrorPtr error )
+{
+ libcmis_DocumentPtr pwc = NULL;
+ if ( document != NULL && document->handle.get( ) != NULL )
+ {
+ try
+ {
+ DocumentPtr doc = dynamic_pointer_cast< libcmis::Document >( document->handle );
+ if ( doc )
+ {
+ libcmis::DocumentPtr handle = doc->checkOut( );
+ pwc= new libcmis_document( );
+ pwc->handle = handle;
+ }
+ }
+ catch ( const bad_alloc& e )
+ {
+ if ( error != NULL )
+ error->badAlloc = true;
+ }
+ catch ( const libcmis::Exception& e )
+ {
+ if ( error != NULL )
+ {
+ error->message = strdup( e.what() );
+ error->type = strdup( e.getType().c_str() );
+ }
+ }
+ }
+ return pwc;
+}
+
+
+void libcmis_document_cancelCheckout( libcmis_DocumentPtr document, libcmis_ErrorPtr error )
+{
+ if ( document != NULL && document->handle.get( ) != NULL )
+ {
+ try
+ {
+ DocumentPtr doc = dynamic_pointer_cast< libcmis::Document >( document->handle );
+ if ( doc )
+ doc->cancelCheckout( );
+ }
+ catch ( const libcmis::Exception& e )
+ {
+ if ( error != NULL )
+ {
+ error->message = strdup( e.what() );
+ error->type = strdup( e.getType().c_str() );
+ }
+ }
+ }
+}
+
+libcmis_DocumentPtr libcmis_document_checkIn(
+ libcmis_DocumentPtr document,
+ bool isMajor,
+ const char* comment,
+ libcmis_vector_property_Ptr properties,
+ libcmis_readFn readFn,
+ void* userData,
+ const char* contentType,
+ const char* filename,
+ libcmis_ErrorPtr error )
+{
+ libcmis_DocumentPtr newVersion = NULL;
+
+ if ( document != NULL && document->handle.get( ) != NULL )
+ {
+ try
+ {
+ DocumentPtr doc = dynamic_pointer_cast< libcmis::Document >( document->handle );
+ if ( doc )
+ {
+ // Create the ostream
+ boost::shared_ptr< std::ostream > stream( new stringstream( ) );
+
+ size_t bufSize = 2048;
+ char * buf = new char[ bufSize ];
+ size_t read = 0;
+ do
+ {
+ read = readFn( ( void * )buf, size_t( 1 ), bufSize, userData );
+ stream->write( buf, read );
+ } while ( read == bufSize );
+ delete[] buf;
+
+ // Create the property map
+ PropertyPtrMap propertiesMap;
+ if ( properties != NULL )
+ {
+ for ( vector< libcmis::PropertyPtr >::iterator it = properties->handle.begin( );
+ it != properties->handle.end( ); ++it )
+ {
+ string id = ( *it )->getPropertyType( )->getId( );
+ propertiesMap.insert( pair< string, libcmis::PropertyPtr >( id, *it ) );
+ }
+ }
+
+ libcmis::DocumentPtr handle = doc->checkIn( isMajor, comment, propertiesMap,
+ stream, contentType, filename );
+ newVersion = new libcmis_document( );
+ newVersion->handle = handle;
+ }
+ }
+ catch ( const libcmis::Exception& e )
+ {
+ if ( error != NULL )
+ {
+ error->message = strdup( e.what() );
+ error->type = strdup( e.getType().c_str() );
+ }
+ }
+ catch ( const bad_alloc& e )
+ {
+ if ( error != NULL )
+ {
+ error->message = strdup( e.what() );
+ error->badAlloc = true;
+ }
+ }
+ catch ( const exception& e )
+ {
+ if ( error != NULL )
+ error->message = strdup( e.what() );
+ }
+ }
+ return newVersion;
+}
+
+libcmis_vector_document_Ptr libcmis_document_getAllVersions(
+ libcmis_DocumentPtr document,
+ libcmis_ErrorPtr error )
+{
+ libcmis_vector_document_Ptr result = NULL;
+ if ( document != NULL && document->handle.get( ) != NULL )
+ {
+ try
+ {
+ DocumentPtr doc = dynamic_pointer_cast< libcmis::Document >( document->handle );
+ if ( doc )
+ {
+ std::vector< libcmis::DocumentPtr > handles = doc->getAllVersions( );
+ result = new libcmis_vector_document( );
+ result->handle = handles;
+ }
+ }
+ catch ( const libcmis::Exception& e )
+ {
+ if ( error != NULL )
+ {
+ error->message = strdup( e.what() );
+ error->type = strdup( e.getType().c_str() );
+ }
+ }
+ catch ( const bad_alloc& e )
+ {
+ if ( error != NULL )
+ {
+ error->message = strdup( e.what() );
+ error->badAlloc = true;
+ }
+ }
+ }
+ return result;
+}
diff --git a/src/libcmis-c/error.cxx b/src/libcmis-c/error.cxx
new file mode 100644
index 0000000..8fdb681
--- /dev/null
+++ b/src/libcmis-c/error.cxx
@@ -0,0 +1,74 @@
+/* libcmis
+ * Version: MPL 1.1 / GPLv2+ / LGPLv2+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License or as specified alternatively below. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * Major Contributor(s):
+ * Copyright (C) 2011 SUSE <cbosdonnat@suse.com>
+ *
+ *
+ * All Rights Reserved.
+ *
+ * For minor contributions see the git repository.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPLv2+"), or
+ * the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"),
+ * in which case the provisions of the GPLv2+ or the LGPLv2+ are applicable
+ * instead of those above.
+ */
+
+#include <libcmis-c/error.h>
+
+#include <stdlib.h>
+#include <string.h>
+
+#include "internals.hxx"
+
+using namespace std;
+
+libcmis_ErrorPtr libcmis_error_create( )
+{
+ libcmis_ErrorPtr error = new( nothrow ) libcmis_error( );
+ return error;
+}
+
+
+void libcmis_error_free( libcmis_ErrorPtr error )
+{
+ if ( error != NULL )
+ {
+ free( error->message );
+ free( error->type );
+ delete error;
+ }
+}
+
+const char* libcmis_error_getMessage( libcmis_ErrorPtr error )
+{
+ if ( error != NULL )
+ {
+ if ( error->badAlloc )
+ return "Failed to allocate memory";
+ else
+ return error->message;
+ }
+ else
+ return "";
+}
+
+const char* libcmis_error_getType( libcmis_ErrorPtr error )
+{
+ if ( error != NULL )
+ return error->type;
+ else
+ return NULL;
+}
diff --git a/src/libcmis-c/folder.cxx b/src/libcmis-c/folder.cxx
new file mode 100644
index 0000000..8d7555a
--- /dev/null
+++ b/src/libcmis-c/folder.cxx
@@ -0,0 +1,369 @@
+/* libcmis
+ * Version: MPL 1.1 / GPLv2+ / LGPLv2+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License or as specified alternatively below. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * Major Contributor(s):
+ * Copyright (C) 2011 SUSE <cbosdonnat@suse.com>
+ *
+ *
+ * All Rights Reserved.
+ *
+ * For minor contributions see the git repository.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPLv2+"), or
+ * the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"),
+ * in which case the provisions of the GPLv2+ or the LGPLv2+ are applicable
+ * instead of those above.
+ */
+
+#include <libcmis-c/folder.h>
+
+#include "internals.hxx"
+
+using namespace std;
+using libcmis::PropertyPtrMap;
+using libcmis::FolderPtr;
+using boost::dynamic_pointer_cast;
+
+void libcmis_vector_folder_free( libcmis_vector_folder_Ptr vector )
+{
+ delete vector;
+}
+
+
+size_t libcmis_vector_folder_size( libcmis_vector_folder_Ptr vector )
+{
+ size_t size = 0;
+ if ( vector != NULL )
+ size = vector->handle.size( );
+ return size;
+}
+
+
+libcmis_FolderPtr libcmis_vector_folder_get( libcmis_vector_folder_Ptr vector, size_t i )
+{
+ libcmis_FolderPtr item = NULL;
+ if ( vector != NULL && i < vector->handle.size( ) )
+ {
+ libcmis::FolderPtr handle = vector->handle[i];
+ item = new ( nothrow ) libcmis_folder( );
+ if ( item )
+ item->handle = handle;
+ }
+ return item;
+}
+
+
+bool libcmis_is_folder( libcmis_ObjectPtr object )
+{
+ bool isFolder = false;
+ if ( object != NULL && object->handle.get( ) != NULL )
+ {
+ libcmis::FolderPtr folder = boost::dynamic_pointer_cast< libcmis::Folder >( object->handle );
+ isFolder = folder.get( ) != NULL;
+ }
+ return isFolder;
+}
+
+
+libcmis_FolderPtr libcmis_folder_cast( libcmis_ObjectPtr object )
+{
+ libcmis_FolderPtr folder = NULL;
+
+ if ( object != NULL && object->handle.get( ) != NULL )
+ {
+ libcmis::FolderPtr handle = boost::dynamic_pointer_cast< libcmis::Folder >( object->handle );
+ if ( handle.get( ) != NULL )
+ {
+ folder = new ( nothrow ) libcmis_folder( );
+ if ( folder )
+ folder->handle = handle;
+ }
+ }
+
+ return folder;
+}
+
+
+void libcmis_folder_free( libcmis_FolderPtr folder )
+{
+ delete folder;
+}
+
+
+libcmis_FolderPtr libcmis_folder_getParent( libcmis_FolderPtr folder, libcmis_ErrorPtr error )
+{
+ libcmis_FolderPtr parent = NULL;
+ if ( folder != NULL && folder->handle.get( ) != NULL )
+ {
+ try
+ {
+ FolderPtr folderHandle = dynamic_pointer_cast< libcmis::Folder >( folder->handle );
+ if ( folder )
+ {
+ libcmis::FolderPtr handle = folderHandle->getFolderParent( );
+ if ( handle.get( ) != NULL )
+ {
+ parent = new libcmis_folder( );
+ parent->handle = handle;
+ }
+ }
+ }
+ catch ( const libcmis::Exception& e )
+ {
+ if ( error != NULL )
+ {
+ error->message = strdup( e.what() );
+ error->type = strdup( e.getType().c_str() );
+ }
+ }
+ catch ( const bad_alloc& e )
+ {
+ if ( error != NULL )
+ {
+ error->message = strdup( e.what() );
+ error->badAlloc = true;
+ }
+ }
+ }
+ return parent;
+}
+
+
+libcmis_vector_object_Ptr libcmis_folder_getChildren( libcmis_FolderPtr folder, libcmis_ErrorPtr error )
+{
+ libcmis_vector_object_Ptr result = NULL;
+ if ( folder != NULL && folder->handle.get( ) != NULL )
+ {
+ try
+ {
+ libcmis::FolderPtr folderHandle = dynamic_pointer_cast< libcmis::Folder >( folder->handle );
+ if ( folder )
+ {
+ std::vector< libcmis::ObjectPtr > handles = folderHandle->getChildren( );
+ result = new libcmis_vector_object( );
+ result->handle = handles;
+ }
+ }
+ catch ( const libcmis::Exception& e )
+ {
+ if ( error != NULL )
+ {
+ error->message = strdup( e.what() );
+ error->type = strdup( e.getType().c_str() );
+ }
+ }
+ catch ( const bad_alloc& e )
+ {
+ if ( error != NULL )
+ {
+ error->message = strdup( e.what() );
+ error->badAlloc = true;
+ }
+ }
+ }
+ return result;
+}
+
+
+char* libcmis_folder_getPath( libcmis_FolderPtr folder )
+{
+ char* path = NULL;
+ if ( folder != NULL && folder->handle.get( ) != NULL )
+ {
+ libcmis::FolderPtr folderHandle = dynamic_pointer_cast< libcmis::Folder >( folder->handle );
+ if ( folder )
+ path = strdup( folderHandle->getPath( ).c_str( ) );
+ }
+ return path;
+}
+
+
+bool libcmis_folder_isRootFolder( libcmis_FolderPtr folder )
+{
+ bool isRoot = false;
+ if ( folder != NULL && folder->handle.get( ) != NULL )
+ {
+ libcmis::FolderPtr folderHandle = dynamic_pointer_cast< libcmis::Folder >( folder->handle );
+ if ( folder )
+ isRoot = folderHandle->isRootFolder( );
+ }
+ return isRoot;
+}
+
+libcmis_FolderPtr libcmis_folder_createFolder(
+ libcmis_FolderPtr folder,
+ libcmis_vector_property_Ptr properties,
+ libcmis_ErrorPtr error )
+{
+ libcmis_FolderPtr result = NULL;
+ if ( folder != NULL && folder->handle.get( ) != NULL )
+ {
+ libcmis::FolderPtr folderHandle = dynamic_pointer_cast< libcmis::Folder >( folder->handle );
+ if ( folder )
+ {
+ try
+ {
+ PropertyPtrMap mappedProperties;
+ if ( properties != NULL )
+ {
+ size_t size = properties->handle.size( );
+ for ( size_t i = 0; i < size; ++i )
+ {
+ libcmis::PropertyPtr property = properties->handle[i];
+ if ( property.get( ) != NULL )
+ {
+ string id = property->getPropertyType( )->getId( );
+ mappedProperties.insert( pair< string, libcmis::PropertyPtr >( id, property ) );
+ }
+ }
+ }
+
+ libcmis::FolderPtr handle = folderHandle->createFolder( mappedProperties );
+ result = new libcmis_folder( );
+ result->handle = handle;
+ }
+ catch ( const libcmis::Exception& e )
+ {
+ if ( error != NULL )
+ {
+ error->message = strdup( e.what() );
+ error->type = strdup( e.getType().c_str() );
+ }
+ }
+ catch ( const bad_alloc& e )
+ {
+ if ( error != NULL )
+ {
+ error->message = strdup( e.what() );
+ error->badAlloc = true;
+ }
+ }
+ }
+ }
+ return result;
+}
+
+
+libcmis_DocumentPtr libcmis_folder_createDocument(
+ libcmis_FolderPtr folder,
+ libcmis_vector_property_Ptr properties,
+ libcmis_readFn readFn,
+ void* userData,
+ const char* contentType,
+ const char* filename,
+ libcmis_ErrorPtr error )
+{
+ libcmis_DocumentPtr created = NULL;
+ if ( folder != NULL && folder->handle.get( ) != NULL )
+ {
+ libcmis::FolderPtr folderHandle = dynamic_pointer_cast< libcmis::Folder >( folder->handle );
+ if ( folder )
+ {
+ try
+ {
+ // Create the ostream
+ boost::shared_ptr< std::ostream > stream( new stringstream( ) );
+
+ size_t bufSize = 2048;
+ char* buf = new char[ bufSize ];
+ size_t read = 0;
+ do
+ {
+ read = readFn( ( void * )buf, size_t( 1 ), bufSize, userData );
+ stream->write( buf, read );
+ } while ( read == bufSize );
+ delete[] buf;
+
+ // Create the property map
+ PropertyPtrMap propertiesMap;
+ if ( properties != NULL )
+ {
+ for ( vector< libcmis::PropertyPtr >::iterator it = properties->handle.begin( );
+ it != properties->handle.end( ); ++it )
+ {
+ string id = ( *it )->getPropertyType( )->getId( );
+ propertiesMap.insert( pair< string, libcmis::PropertyPtr >( id, *it ) );
+ }
+ }
+
+ libcmis::DocumentPtr handle = folderHandle->createDocument( propertiesMap, stream, contentType, filename );
+ created = new libcmis_document( );
+ created->handle = handle;
+ }
+ catch ( const libcmis::Exception& e )
+ {
+ if ( error != NULL )
+ {
+ error->message = strdup( e.what() );
+ error->type = strdup( e.getType().c_str() );
+ }
+ }
+ catch ( const bad_alloc& e )
+ {
+ if ( error != NULL )
+ {
+ error->message = strdup( e.what() );
+ error->badAlloc = true;
+ }
+ }
+ catch ( const exception& e )
+ {
+ if ( error != NULL )
+ error->message = strdup( e.what() );
+ }
+ }
+ }
+ return created;
+}
+
+
+libcmis_vector_string_Ptr libcmis_folder_removeTree( libcmis_FolderPtr folder,
+ bool allVersion,
+ libcmis_folder_UnfileObjects unfile,
+ bool continueOnError,
+ libcmis_ErrorPtr error )
+{
+ libcmis_vector_string_Ptr failed = NULL;
+ try
+ {
+ failed = new libcmis_vector_string( );
+ if ( folder != NULL && folder->handle.get( ) != NULL )
+ {
+ libcmis::FolderPtr folderHandle = dynamic_pointer_cast< libcmis::Folder >( folder->handle );
+ if ( folder )
+ {
+ vector< string > handle = folderHandle->removeTree( allVersion,
+ libcmis::UnfileObjects::Type( unfile ), continueOnError );
+ failed->handle = handle;
+ }
+ }
+ }
+ catch ( const libcmis::Exception& e )
+ {
+ if ( error != NULL )
+ {
+ error->message = strdup( e.what() );
+ error->type = strdup( e.getType().c_str() );
+ }
+ }
+ catch ( const bad_alloc& e )
+ {
+ if ( error != NULL )
+ {
+ error->message = strdup( e.what() );
+ error->badAlloc = true;
+ }
+ }
+ return failed;
+}
diff --git a/src/libcmis-c/internals.hxx b/src/libcmis-c/internals.hxx
new file mode 100644
index 0000000..e4a5b6b
--- /dev/null
+++ b/src/libcmis-c/internals.hxx
@@ -0,0 +1,242 @@
+/* libcmis
+ * Version: MPL 1.1 / GPLv2+ / LGPLv2+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License or as specified alternatively below. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * Major Contributor(s):
+ * Copyright (C) 2011 SUSE <cbosdonnat@suse.com>
+ *
+ *
+ * All Rights Reserved.
+ *
+ * For minor contributions see the git repository.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPLv2+"), or
+ * the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"),
+ * in which case the provisions of the GPLv2+ or the LGPLv2+ are applicable
+ * instead of those above.
+ */
+#ifndef _LIBCMIS_INTERNALS_H_
+#define _LIBCMIS_INTERNALS_H_
+
+#include <vector>
+
+#include <libcmis/allowable-actions.hxx>
+#include <libcmis/document.hxx>
+#include <libcmis/exception.hxx>
+#include <libcmis/folder.hxx>
+#include <libcmis/object.hxx>
+#include <libcmis/property.hxx>
+#include <libcmis/repository.hxx>
+#include <libcmis/session.hxx>
+#include <libcmis/session-factory.hxx>
+
+std::string createString( char* str );
+
+struct libcmis_error
+{
+ char* message;
+ char* type;
+ bool badAlloc;
+
+ libcmis_error( ) : message( NULL ), type( NULL ), badAlloc( false ) { }
+};
+
+struct libcmis_session
+{
+ libcmis::Session* handle;
+ libcmis::AuthProviderPtr provider;
+
+ // Constructors
+
+ libcmis_session( ) :
+ handle( NULL ),
+ provider( )
+ {
+ }
+
+ libcmis_session( const libcmis_session& copy ) :
+ handle( copy.handle ),
+ provider( copy.provider )
+ {
+ }
+
+ libcmis_session& operator=( const libcmis_session& copy )
+ {
+ if ( this != &copy )
+ {
+ handle = copy.handle;
+ provider = copy.provider;
+ }
+ return *this;
+ }
+};
+
+struct libcmis_repository
+{
+ libcmis::RepositoryPtr handle;
+
+ libcmis_repository( ) : handle( ) { }
+};
+
+struct libcmis_object
+{
+ libcmis::ObjectPtr handle;
+
+ libcmis_object( ) : handle( ) { }
+ virtual ~libcmis_object( ) { }
+};
+
+struct libcmis_object_type
+{
+ libcmis::ObjectTypePtr handle;
+
+ libcmis_object_type( ) : handle( ) { }
+};
+
+struct libcmis_allowable_actions
+{
+ libcmis::AllowableActionsPtr handle;
+
+ libcmis_allowable_actions( ) : handle ( ) { }
+};
+
+struct libcmis_property_type
+{
+ libcmis::PropertyTypePtr handle;
+
+ libcmis_property_type( ) : handle( ) { }
+};
+
+struct libcmis_property
+{
+ libcmis::PropertyPtr handle;
+
+ libcmis_property( ) : handle( ) { }
+};
+
+struct libcmis_folder : public libcmis_object
+{
+ libcmis_folder( ) : libcmis_object( ) { }
+};
+
+struct libcmis_document : public libcmis_object
+{
+ libcmis_document( ) : libcmis_object( ) { }
+};
+
+struct libcmis_oauth2data
+{
+ libcmis::OAuth2DataPtr handle;
+
+ libcmis_oauth2data( ) : handle( ) { }
+};
+
+struct libcmis_rendition
+{
+ libcmis::RenditionPtr handle;
+
+ libcmis_rendition( ) : handle( ) { }
+};
+
+struct libcmis_vector_bool
+{
+ std::vector< bool > handle;
+
+ libcmis_vector_bool( ) : handle( ) { }
+};
+
+struct libcmis_vector_string
+{
+ std::vector< std::string > handle;
+
+ libcmis_vector_string( ) : handle( ) { }
+};
+
+struct libcmis_vector_long
+{
+ std::vector< long > handle;
+
+ libcmis_vector_long( ) : handle( ) { }
+};
+
+struct libcmis_vector_double
+{
+ std::vector< double > handle;
+
+ libcmis_vector_double( ) : handle( ) { }
+};
+
+struct libcmis_vector_time
+{
+ std::vector< boost::posix_time::ptime > handle;
+
+ libcmis_vector_time( ) : handle( ) { }
+};
+
+struct libcmis_vector_object_type
+{
+ std::vector< libcmis::ObjectTypePtr > handle;
+
+ libcmis_vector_object_type( ) : handle( ) { }
+};
+
+struct libcmis_vector_property_type
+{
+ std::vector< libcmis::PropertyTypePtr > handle;
+
+ libcmis_vector_property_type( ) : handle( ) { }
+};
+
+struct libcmis_vector_property
+{
+ std::vector< libcmis::PropertyPtr > handle;
+
+ libcmis_vector_property( ) : handle( ) { }
+};
+
+struct libcmis_vector_object
+{
+ std::vector< libcmis::ObjectPtr > handle;
+
+ libcmis_vector_object( ) : handle( ) { }
+};
+
+struct libcmis_vector_folder
+{
+ std::vector< libcmis::FolderPtr > handle;
+
+ libcmis_vector_folder( ) : handle( ) { }
+};
+
+struct libcmis_vector_document
+{
+ std::vector< libcmis::DocumentPtr > handle;
+
+ libcmis_vector_document( ) : handle( ) { }
+};
+
+struct libcmis_vector_repository
+{
+ std::vector< libcmis::RepositoryPtr > handle;
+
+ libcmis_vector_repository( ) : handle( ) { }
+};
+
+struct libcmis_vector_rendition
+{
+ std::vector< libcmis::RenditionPtr > handle;
+
+ libcmis_vector_rendition( ) : handle( ) { }
+};
+
+#endif
diff --git a/src/libcmis-c/oauth2-data.cxx b/src/libcmis-c/oauth2-data.cxx
new file mode 100644
index 0000000..9b7c69f
--- /dev/null
+++ b/src/libcmis-c/oauth2-data.cxx
@@ -0,0 +1,110 @@
+/* libcmis
+ * Version: MPL 1.1 / GPLv2+ / LGPLv2+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License or as specified alternatively below. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * Major Contributor(s):
+ * Copyright (C) 2011 SUSE <cbosdonnat@suse.com>
+ *
+ *
+ * All Rights Reserved.
+ *
+ * For minor contributions see the git repository.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPLv2+"), or
+ * the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"),
+ * in which case the provisions of the GPLv2+ or the LGPLv2+ are applicable
+ * instead of those above.
+ */
+
+#include <libcmis-c/oauth2-data.h>
+
+#include "internals.hxx"
+
+using namespace std;
+
+
+libcmis_OAuth2DataPtr libcmis_oauth2data_create(
+ char* authUrl, char* tokenUrl, char* scope, char* redirectUri,
+ char* clientId, char* clientSecret )
+{
+ libcmis_OAuth2DataPtr data = new( nothrow ) libcmis_oauth2data( );
+
+ if ( NULL != data )
+ data->handle.reset( new libcmis::OAuth2Data(
+ authUrl, tokenUrl, scope, redirectUri,
+ clientId, clientSecret ) );
+ return data;
+}
+
+
+void libcmis_oauth2data_free( libcmis_OAuth2DataPtr oauth2 )
+{
+ delete oauth2;
+}
+
+
+bool libcmis_oauth2data_isComplete( libcmis_OAuth2DataPtr oauth2 )
+{
+ bool result = false;
+ if ( oauth2 != NULL && oauth2->handle != NULL )
+ result = oauth2->handle->isComplete();
+ return result;
+}
+
+
+const char* libcmis_oauth2data_getAuthUrl( libcmis_OAuth2DataPtr oauth2 )
+{
+ if ( oauth2 != NULL && oauth2->handle != NULL )
+ return oauth2->handle->getAuthUrl().c_str();
+ return NULL;
+}
+
+
+const char* libcmis_oauth2data_getTokenUrl( libcmis_OAuth2DataPtr oauth2 )
+{
+ if ( oauth2 != NULL && oauth2->handle != NULL )
+ return oauth2->handle->getTokenUrl().c_str();
+ return NULL;
+}
+
+
+const char* libcmis_oauth2data_getClientId( libcmis_OAuth2DataPtr oauth2 )
+{
+ if ( oauth2 != NULL && oauth2->handle != NULL )
+ return oauth2->handle->getClientId().c_str();
+ return NULL;
+}
+
+
+const char* libcmis_oauth2data_getClientSecret( libcmis_OAuth2DataPtr oauth2 )
+{
+ if ( oauth2 != NULL && oauth2->handle != NULL )
+ return oauth2->handle->getClientSecret().c_str();
+ return NULL;
+}
+
+
+const char* libcmis_oauth2data_getScope( libcmis_OAuth2DataPtr oauth2 )
+{
+ if ( oauth2 != NULL && oauth2->handle != NULL )
+ return oauth2->handle->getScope().c_str();
+ return NULL;
+}
+
+
+const char* libcmis_oauth2data_getRedirectUri( libcmis_OAuth2DataPtr oauth2 )
+{
+ if ( oauth2 != NULL && oauth2->handle != NULL )
+ return oauth2->handle->getRedirectUri().c_str();
+ return NULL;
+}
diff --git a/src/libcmis-c/object-type.cxx b/src/libcmis-c/object-type.cxx
new file mode 100644
index 0000000..f1b3b9f
--- /dev/null
+++ b/src/libcmis-c/object-type.cxx
@@ -0,0 +1,388 @@
+/* libcmis
+ * Version: MPL 1.1 / GPLv2+ / LGPLv2+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License or as specified alternatively below. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * Major Contributor(s):
+ * Copyright (C) 2011 SUSE <cbosdonnat@suse.com>
+ *
+ *
+ * All Rights Reserved.
+ *
+ * For minor contributions see the git repository.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPLv2+"), or
+ * the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"),
+ * in which case the provisions of the GPLv2+ or the LGPLv2+ are applicable
+ * instead of those above.
+ */
+
+#include <libcmis-c/object-type.h>
+
+#include "internals.hxx"
+
+using namespace std;
+
+
+void libcmis_vector_object_type_free( libcmis_vector_object_type_Ptr vector )
+{
+ delete vector;
+}
+
+
+size_t libcmis_vector_object_type_size( libcmis_vector_object_type_Ptr vector )
+{
+ size_t size = 0;
+ if ( vector != NULL )
+ size = vector->handle.size( );
+ return size;
+}
+
+
+libcmis_ObjectTypePtr libcmis_vector_object_type_get( libcmis_vector_object_type_Ptr vector, size_t i )
+{
+ libcmis_ObjectTypePtr item = NULL;
+ if ( vector != NULL && i < vector->handle.size( ) )
+ {
+ libcmis::ObjectTypePtr type = vector->handle[i];
+ item = new ( nothrow ) libcmis_object_type( );
+ if ( item )
+ item->handle = type;
+ }
+ return item;
+}
+
+
+void libcmis_object_type_free( libcmis_ObjectTypePtr type )
+{
+ delete type;
+}
+
+
+char* libcmis_object_type_getId( libcmis_ObjectTypePtr type )
+{
+ if ( type != NULL && type->handle.get( ) != NULL )
+ return strdup( type->handle->getId( ).c_str( ) );
+ else
+ return NULL;
+}
+
+
+char* libcmis_object_type_getLocalName( libcmis_ObjectTypePtr type )
+{
+ if ( type != NULL && type->handle.get( ) != NULL )
+ return strdup( type->handle->getLocalName( ).c_str( ) );
+ else
+ return NULL;
+}
+
+
+char* libcmis_object_type_getLocalNamespace( libcmis_ObjectTypePtr type )
+{
+ if ( type != NULL && type->handle.get( ) != NULL )
+ return strdup( type->handle->getLocalNamespace( ).c_str( ) );
+ else
+ return NULL;
+}
+
+
+char* libcmis_object_type_getQueryName( libcmis_ObjectTypePtr type )
+{
+ if ( type != NULL && type->handle.get( ) != NULL )
+ return strdup( type->handle->getQueryName( ).c_str( ) );
+ else
+ return NULL;
+}
+
+
+char* libcmis_object_type_getDisplayName( libcmis_ObjectTypePtr type )
+{
+ if ( type != NULL && type->handle.get( ) != NULL )
+ return strdup( type->handle->getDisplayName( ).c_str( ) );
+ else
+ return NULL;
+}
+
+
+char* libcmis_object_type_getDescription( libcmis_ObjectTypePtr type )
+{
+ if ( type != NULL && type->handle.get( ) != NULL )
+ return strdup( type->handle->getDescription( ).c_str( ) );
+ else
+ return NULL;
+}
+
+
+libcmis_ObjectTypePtr libcmis_object_type_getParentType(
+ libcmis_ObjectTypePtr type,
+ libcmis_ErrorPtr error )
+{
+ libcmis_ObjectTypePtr result = NULL;
+ if ( type != NULL && type->handle.get( ) != NULL )
+ {
+ try
+ {
+ libcmis::ObjectTypePtr handle = type->handle->getParentType( );
+ if ( handle.get ( ) )
+ {
+ result = new libcmis_object_type( );
+ result->handle = handle;
+ }
+ }
+ catch( const libcmis::Exception& e )
+ {
+ if ( error != NULL )
+ {
+ error->message = strdup( e.what() );
+ error->type = strdup( e.getType().c_str() );
+ }
+ }
+ catch ( const bad_alloc& e )
+ {
+ if ( error != NULL )
+ {
+ error->message = strdup( e.what() );
+ error->badAlloc = true;
+ }
+ }
+ }
+
+ return result;
+}
+
+
+libcmis_ObjectTypePtr libcmis_object_type_getBaseType(
+ libcmis_ObjectTypePtr type,
+ libcmis_ErrorPtr error )
+{
+ libcmis_ObjectTypePtr result = NULL;
+ if ( type != NULL && type->handle.get( ) != NULL )
+ {
+ try
+ {
+ libcmis::ObjectTypePtr handle = type->handle->getBaseType( );
+ result = new libcmis_object_type( );
+ result->handle = handle;
+ }
+ catch( const libcmis::Exception& e )
+ {
+ if ( error != NULL )
+ {
+ error->message = strdup( e.what() );
+ error->type = strdup( e.getType().c_str() );
+ }
+ }
+ catch ( const bad_alloc& e )
+ {
+ if ( error != NULL )
+ {
+ error->message = strdup( e.what() );
+ error->badAlloc = true;
+ }
+ }
+ }
+
+ return result;
+}
+
+
+char* libcmis_object_type_getParentTypeId( libcmis_ObjectTypePtr type )
+{
+ char* result = NULL;
+ if ( type != NULL && type->handle.get( ) != NULL )
+ {
+ result = strdup( type->handle->getParentTypeId( ).c_str() );
+ }
+
+ return result;
+}
+
+
+char* libcmis_object_type_getBaseTypeId( libcmis_ObjectTypePtr type )
+{
+ char* result = NULL;
+ if ( type != NULL && type->handle.get( ) != NULL )
+ {
+ result = strdup( type->handle->getBaseTypeId( ).c_str() );
+ }
+
+ return result;
+}
+
+
+libcmis_vector_object_type_Ptr libcmis_object_type_getChildren(
+ libcmis_ObjectTypePtr type, libcmis_ErrorPtr error )
+{
+ libcmis_vector_object_type_Ptr children = NULL;
+ if ( type != NULL && type->handle.get( ) != NULL )
+ {
+ try
+ {
+ std::vector< libcmis::ObjectTypePtr > types = type->handle->getChildren( );
+ children = new libcmis_vector_object_type( );
+ children->handle = types;
+ }
+ catch( const libcmis::Exception& e )
+ {
+ if ( error != NULL )
+ {
+ error->message = strdup( e.what() );
+ error->type = strdup( e.getType().c_str() );
+ }
+ }
+ catch ( const bad_alloc& e )
+ {
+ if ( error != NULL )
+ {
+ error->message = strdup( e.what() );
+ error->badAlloc = true;
+ }
+ }
+ }
+
+ return children;
+}
+
+
+bool libcmis_object_type_isCreatable( libcmis_ObjectTypePtr type )
+{
+ bool value = false;
+ if ( type != NULL && type->handle.get( ) != NULL )
+ value = type->handle->isCreatable( );
+ return value;
+}
+
+
+bool libcmis_object_type_isFileable( libcmis_ObjectTypePtr type )
+{
+ bool value = false;
+ if ( type != NULL && type->handle.get( ) != NULL )
+ value = type->handle->isFileable( );
+ return value;
+}
+
+
+bool libcmis_object_type_isQueryable( libcmis_ObjectTypePtr type )
+{
+ bool value = false;
+ if ( type != NULL && type->handle.get( ) != NULL )
+ value = type->handle->isQueryable( );
+ return value;
+}
+
+
+bool libcmis_object_type_isFulltextIndexed( libcmis_ObjectTypePtr type )
+{
+ bool value = false;
+ if ( type != NULL && type->handle.get( ) != NULL )
+ value = type->handle->isFulltextIndexed( );
+ return value;
+}
+
+
+bool libcmis_object_type_isIncludedInSupertypeQuery( libcmis_ObjectTypePtr type )
+{
+ bool value = false;
+ if ( type != NULL && type->handle.get( ) != NULL )
+ value = type->handle->isIncludedInSupertypeQuery( );
+ return value;
+}
+
+
+bool libcmis_object_type_isControllablePolicy( libcmis_ObjectTypePtr type )
+{
+ bool value = false;
+ if ( type != NULL && type->handle.get( ) != NULL )
+ value = type->handle->isControllablePolicy( );
+ return value;
+}
+
+
+bool libcmis_object_type_isControllableACL( libcmis_ObjectTypePtr type )
+{
+ bool value = false;
+ if ( type != NULL && type->handle.get( ) != NULL )
+ value = type->handle->isControllableACL( );
+ return value;
+}
+
+
+bool libcmis_object_type_isVersionable( libcmis_ObjectTypePtr type )
+{
+ bool value = false;
+ if ( type != NULL && type->handle.get( ) != NULL )
+ value = type->handle->isVersionable( );
+ return value;
+}
+
+
+libcmis_object_type_ContentStreamAllowed libcmis_object_type_getContentStreamAllowed( libcmis_ObjectTypePtr type )
+{
+ libcmis_object_type_ContentStreamAllowed result = libcmis_NotAllowed;
+ if ( type != NULL && type->handle.get( ) != NULL )
+ {
+ libcmis::ObjectType::ContentStreamAllowed value = type->handle->getContentStreamAllowed( );
+ result = libcmis_object_type_ContentStreamAllowed( value );
+ }
+ return result;
+}
+
+
+libcmis_vector_property_type_Ptr libcmis_object_type_getPropertiesTypes( libcmis_ObjectTypePtr type )
+{
+ libcmis_vector_property_type_Ptr propertyTypes = NULL;
+ if ( type != NULL && type->handle != NULL )
+ {
+ map< string, libcmis::PropertyTypePtr >& handles = type->handle->getPropertiesTypes( );
+ propertyTypes = new ( nothrow ) libcmis_vector_property_type( );
+ if ( propertyTypes )
+ {
+ int i = 0;
+ for ( map< string, libcmis::PropertyTypePtr >::iterator it = handles.begin( );
+ it != handles.end( ); ++it, ++i )
+ {
+ propertyTypes->handle.push_back( it->second );
+ }
+ }
+ }
+
+ return propertyTypes;
+}
+
+libcmis_PropertyTypePtr libcmis_object_type_getPropertyType( libcmis_ObjectTypePtr type, const char* id )
+{
+ libcmis_PropertyTypePtr propertyType = NULL;
+ if ( type != NULL && type->handle != NULL )
+ {
+ map< string, libcmis::PropertyTypePtr >& handles = type->handle->getPropertiesTypes( );
+ map< string, libcmis::PropertyTypePtr >::iterator it = handles.find( string( id ) );
+ if ( it != handles.end( ) )
+ {
+ propertyType = new ( nothrow ) libcmis_property_type( );
+ if ( propertyType )
+ propertyType->handle = it->second;
+ }
+ }
+
+ return propertyType;
+}
+
+
+char* libcmis_object_type_toString( libcmis_ObjectTypePtr type )
+{
+ if ( type != NULL && type->handle.get( ) != NULL )
+ return strdup( type->handle->toString( ).c_str( ) );
+ else
+ return NULL;
+}
+
+
diff --git a/src/libcmis-c/object.cxx b/src/libcmis-c/object.cxx
new file mode 100644
index 0000000..323cb31
--- /dev/null
+++ b/src/libcmis-c/object.cxx
@@ -0,0 +1,512 @@
+/* libcmis
+ * Version: MPL 1.1 / GPLv2+ / LGPLv2+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License or as specified alternatively below. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * Major Contributor(s):
+ * Copyright (C) 2011 SUSE <cbosdonnat@suse.com>
+ *
+ *
+ * All Rights Reserved.
+ *
+ * For minor contributions see the git repository.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPLv2+"), or
+ * the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"),
+ * in which case the provisions of the GPLv2+ or the LGPLv2+ are applicable
+ * instead of those above.
+ */
+
+#include <libcmis-c/object.h>
+
+#include <libcmis-c/folder.h>
+
+#include "internals.hxx"
+
+using namespace std;
+using libcmis::PropertyPtrMap;
+using boost::dynamic_pointer_cast;
+
+namespace
+{
+ string lcl_stdString( const char* str )
+ {
+ string result;
+ if ( str )
+ result = string( str );
+ return result;
+ }
+
+ PropertyPtrMap lcl_createPropertiesMap( libcmis_vector_property_Ptr properties )
+ {
+ PropertyPtrMap propertiesMap;
+ if ( properties )
+ {
+ for ( vector< libcmis::PropertyPtr >::iterator it = properties->handle.begin( );
+ it != properties->handle.end( ); ++it )
+ {
+ libcmis::PropertyPtr propHandle = *it;
+ propertiesMap[ propHandle->getPropertyType()->getId( ) ] = propHandle;
+ }
+ }
+ return propertiesMap;
+ }
+}
+
+void libcmis_vector_object_free( libcmis_vector_object_Ptr vector )
+{
+ delete vector;
+}
+
+
+size_t libcmis_vector_object_size( libcmis_vector_object_Ptr vector )
+{
+ size_t size = 0;
+ if ( vector != NULL )
+ size = vector->handle.size( );
+ return size;
+}
+
+
+libcmis_ObjectPtr libcmis_vector_object_get( libcmis_vector_object_Ptr vector, size_t i )
+{
+ libcmis_ObjectPtr item = NULL;
+ if ( vector != NULL && i < vector->handle.size( ) )
+ {
+ libcmis::ObjectPtr type = vector->handle[i];
+ item = new ( nothrow ) libcmis_object( );
+ if ( item )
+ item->handle = type;
+ }
+ return item;
+}
+
+
+void libcmis_object_free( libcmis_ObjectPtr object )
+{
+ delete object;
+}
+
+
+char* libcmis_object_getId( libcmis_ObjectPtr object )
+{
+ if ( object != NULL && object->handle != NULL )
+ return strdup( object->handle->getId( ).c_str( ) );
+ else
+ return NULL;
+}
+
+
+char* libcmis_object_getName( libcmis_ObjectPtr object )
+{
+ if ( object != NULL && object->handle != NULL )
+ return strdup( object->handle->getName( ).c_str( ) );
+ else
+ return NULL;
+}
+
+libcmis_vector_string_Ptr libcmis_object_getPaths( libcmis_ObjectPtr object )
+{
+ libcmis_vector_string_Ptr c_paths = NULL;
+ if ( object != NULL && object->handle != NULL )
+ {
+ std::vector< std::string > paths = object->handle->getPaths( );
+ c_paths = new ( nothrow ) libcmis_vector_string( );
+ if ( c_paths )
+ c_paths->handle = paths;
+ }
+ return c_paths;
+}
+
+char* libcmis_object_getBaseType( libcmis_ObjectPtr object )
+{
+ if ( object != NULL && object->handle != NULL )
+ return strdup( object->handle->getBaseType( ).c_str( ) );
+ else
+ return NULL;
+}
+
+
+char* libcmis_object_getType( libcmis_ObjectPtr object )
+{
+ if ( object != NULL && object->handle != NULL )
+ return strdup( object->handle->getType( ).c_str( ) );
+ else
+ return NULL;
+}
+
+
+char* libcmis_object_getCreatedBy( libcmis_ObjectPtr object )
+{
+ if ( object != NULL && object->handle != NULL )
+ return strdup( object->handle->getCreatedBy( ).c_str( ) );
+ else
+ return NULL;
+}
+
+
+time_t libcmis_object_getCreationDate( libcmis_ObjectPtr object )
+{
+ if ( object != NULL && object->handle != NULL )
+ {
+ tm time = boost::posix_time::to_tm( object->handle->getCreationDate( ) );
+ return mktime( &time );
+ }
+ else
+ return 0;
+}
+
+
+char* libcmis_object_getLastModifiedBy( libcmis_ObjectPtr object )
+{
+ if ( object != NULL && object->handle != NULL )
+ return strdup( object->handle->getLastModifiedBy( ).c_str( ) );
+ else
+ return NULL;
+}
+
+
+time_t libcmis_object_getLastModificationDate( libcmis_ObjectPtr object )
+{
+ if ( object != NULL && object->handle != NULL )
+ {
+ tm time = boost::posix_time::to_tm( object->handle->getLastModificationDate( ) );
+ return mktime( &time );
+ }
+ else
+ return 0;
+}
+
+
+char* libcmis_object_getChangeToken( libcmis_ObjectPtr object )
+{
+ if ( object != NULL && object->handle != NULL )
+ return strdup( object->handle->getChangeToken( ).c_str( ) );
+ else
+ return NULL;
+}
+
+char* libcmis_object_getThumbnailUrl( libcmis_ObjectPtr object )
+{
+ if ( object != NULL && object->handle != NULL )
+ return strdup( object->handle->getThumbnailUrl( ).c_str( ) );
+ else
+ return NULL;
+}
+
+libcmis_vector_rendition_Ptr libcmis_object_getRenditions( libcmis_ObjectPtr object,
+ libcmis_ErrorPtr error )
+{
+ libcmis_vector_rendition_Ptr result = NULL;
+ if ( object != NULL && object->handle.get( ) != NULL )
+ {
+ try
+ {
+ std::vector< libcmis::RenditionPtr > handles = object->handle->getRenditions( );
+ result = new libcmis_vector_rendition( );
+ result->handle = handles;
+ }
+
+ catch ( const bad_alloc& e )
+ {
+ if ( error != NULL )
+ {
+ error->message = strdup( e.what() );
+ error->badAlloc = true;
+ }
+ }
+ }
+ return result;
+}
+
+bool libcmis_object_isImmutable( libcmis_ObjectPtr object )
+{
+ if ( object != NULL && object->handle != NULL )
+ return object->handle->isImmutable( );
+ else
+ return true;
+}
+
+libcmis_vector_string_Ptr libcmis_object_getSecondaryTypes( libcmis_ObjectPtr object )
+{
+ libcmis_vector_string_Ptr c_types = NULL;
+ if ( object != NULL && object->handle != NULL )
+ {
+ vector< string > types = object->handle->getSecondaryTypes( );
+ c_types = new ( nothrow ) libcmis_vector_string( );
+ if ( c_types )
+ c_types->handle = types;
+ }
+ return c_types;
+}
+
+libcmis_ObjectPtr
+libcmis_object_addSecondaryType( libcmis_ObjectPtr object,
+ const char* id,
+ libcmis_vector_property_Ptr properties,
+ libcmis_ErrorPtr error )
+{
+ libcmis_ObjectPtr updated = NULL;
+ if ( object != NULL && object->handle != NULL && properties != NULL )
+ {
+ try
+ {
+ PropertyPtrMap propertiesMap = lcl_createPropertiesMap( properties );
+ libcmis::ObjectPtr result = object->handle->addSecondaryType(
+ lcl_stdString( id ),
+ propertiesMap );
+ updated = new libcmis_object( );
+ updated->handle = result;
+ }
+ catch ( const libcmis::Exception& e )
+ {
+ if ( error != NULL )
+ {
+ error->message = strdup( e.what() );
+ error->type = strdup( e.getType().c_str() );
+ }
+ }
+ catch ( const bad_alloc& e )
+ {
+ if ( error != NULL )
+ {
+ error->message = strdup( e.what() );
+ error->badAlloc = true;
+ }
+ }
+ }
+ return updated;
+}
+
+libcmis_ObjectPtr
+libcmis_object_removeSecondaryType( libcmis_ObjectPtr object,
+ const char* id,
+ libcmis_ErrorPtr error )
+{
+ libcmis_ObjectPtr updated = NULL;
+ if ( object != NULL && object->handle != NULL )
+ {
+ try
+ {
+ libcmis::ObjectPtr result = object->handle->removeSecondaryType(
+ lcl_stdString( id ) );
+ updated = new libcmis_object( );
+ updated->handle = result;
+ }
+ catch ( const libcmis::Exception& e )
+ {
+ if ( error != NULL )
+ {
+ error->message = strdup( e.what() );
+ error->type = strdup( e.getType().c_str() );
+ }
+ }
+ catch ( const bad_alloc& e )
+ {
+ if ( error != NULL )
+ {
+ error->message = strdup( e.what() );
+ error->badAlloc = true;
+ }
+ }
+ }
+ return updated;
+}
+
+libcmis_vector_property_Ptr libcmis_object_getProperties( libcmis_ObjectPtr object )
+{
+ libcmis_vector_property_Ptr properties = NULL;
+ if ( object != NULL && object->handle.get( ) != NULL )
+ {
+ PropertyPtrMap& handles = object->handle->getProperties( );
+ properties = new ( nothrow ) libcmis_vector_property( );
+ if ( properties )
+ {
+ int i = 0;
+ for ( PropertyPtrMap::iterator it = handles.begin( );
+ it != handles.end( ); ++it, ++i )
+ {
+ properties->handle.push_back( it->second );
+ }
+ }
+ }
+ return properties;
+}
+
+
+libcmis_PropertyPtr libcmis_object_getProperty( libcmis_ObjectPtr object, const char* name )
+{
+ libcmis_PropertyPtr property = NULL;
+ if ( object != NULL && object->handle.get( ) != NULL )
+ {
+ PropertyPtrMap& handles = object->handle->getProperties( );
+ PropertyPtrMap::iterator it = handles.find( lcl_stdString( name ) );
+ if ( it != handles.end( ) )
+ {
+ property = new ( nothrow ) libcmis_property( );
+ if ( property )
+ property->handle = it->second;
+ }
+ }
+ return property;
+}
+
+
+libcmis_ObjectPtr libcmis_object_updateProperties(
+ libcmis_ObjectPtr object,
+ libcmis_vector_property_Ptr properties,
+ libcmis_ErrorPtr error )
+{
+ libcmis_ObjectPtr result = NULL;
+ if ( object != NULL && object->handle != NULL && properties != NULL )
+ {
+ try
+ {
+ // Build the map of changed properties
+ PropertyPtrMap propertiesMap = lcl_createPropertiesMap( properties );
+ libcmis::ObjectPtr handle = object->handle->updateProperties( propertiesMap );
+ result = new libcmis_object( );
+ result->handle = handle;
+ }
+ catch ( const libcmis::Exception& e )
+ {
+ if ( error != NULL )
+ {
+ error->message = strdup( e.what() );
+ error->type = strdup( e.getType().c_str() );
+ }
+ }
+ catch ( const bad_alloc& e )
+ {
+ if ( error != NULL )
+ {
+ error->message = strdup( e.what() );
+ error->badAlloc = true;
+ }
+ }
+ }
+ return result;
+}
+
+
+libcmis_ObjectTypePtr libcmis_object_getTypeDescription( libcmis_ObjectPtr object )
+{
+ libcmis_ObjectTypePtr result = NULL;
+ if ( object != NULL && object->handle.get( ) != NULL )
+ {
+ result = new ( nothrow ) libcmis_object_type( );
+ if ( result )
+ result->handle = object->handle->getTypeDescription( );
+ }
+ return result;
+}
+
+
+libcmis_AllowableActionsPtr libcmis_object_getAllowableActions( libcmis_ObjectPtr object )
+{
+ libcmis_AllowableActionsPtr result = NULL;
+ if ( object != NULL && object->handle.get( ) != NULL )
+ {
+ result = new ( nothrow ) libcmis_allowable_actions( );
+ if ( result )
+ result->handle = object->handle->getAllowableActions( );
+ }
+ return result;
+}
+
+
+void libcmis_object_refresh( libcmis_ObjectPtr object, libcmis_ErrorPtr error )
+{
+ if ( object != NULL && object->handle != NULL )
+ {
+ try
+ {
+ object->handle->refresh( );
+ }
+ catch ( const libcmis::Exception& e )
+ {
+ if ( error != NULL )
+ {
+ error->message = strdup( e.what() );
+ error->type = strdup( e.getType().c_str() );
+ }
+ }
+ }
+}
+
+
+time_t libcmis_object_getRefreshTimestamp( libcmis_ObjectPtr object )
+{
+ if ( object != NULL && object->handle != NULL )
+ return object->handle->getRefreshTimestamp( );
+ else
+ return 0;
+}
+
+
+void libcmis_object_remove( libcmis_ObjectPtr object, bool allVersions, libcmis_ErrorPtr error )
+{
+ if ( object != NULL && object->handle != NULL )
+ {
+ try
+ {
+ object->handle->remove( allVersions );
+ }
+ catch ( const libcmis::Exception& e )
+ {
+ if ( error != NULL )
+ {
+ error->message = strdup( e.what() );
+ error->type = strdup( e.getType().c_str() );
+ }
+ }
+ }
+}
+
+
+void libcmis_object_move( libcmis_ObjectPtr object,
+ libcmis_FolderPtr source,
+ libcmis_FolderPtr dest,
+ libcmis_ErrorPtr error )
+{
+ if ( object != NULL && object->handle != NULL )
+ {
+ try
+ {
+ libcmis::FolderPtr sourceHandle;
+ if ( source != NULL )
+ sourceHandle = dynamic_pointer_cast< libcmis::Folder >( source->handle );
+ libcmis::FolderPtr destHandle;
+ if ( dest != NULL )
+ destHandle = dynamic_pointer_cast< libcmis::Folder >( dest->handle );
+
+ object->handle->move( sourceHandle, destHandle );
+ }
+ catch ( const libcmis::Exception& e )
+ {
+ if ( error != NULL )
+ {
+ error->message = strdup( e.what() );
+ error->type = strdup( e.getType().c_str() );
+ }
+ }
+ }
+}
+
+
+char* libcmis_object_toString( libcmis_ObjectPtr object )
+{
+ if ( object != NULL && object->handle != NULL )
+ return strdup( object->handle->toString( ).c_str( ) );
+ else
+ return NULL;
+}
diff --git a/src/libcmis-c/property-type.cxx b/src/libcmis-c/property-type.cxx
new file mode 100644
index 0000000..3f23939
--- /dev/null
+++ b/src/libcmis-c/property-type.cxx
@@ -0,0 +1,201 @@
+/* libcmis
+ * Version: MPL 1.1 / GPLv2+ / LGPLv2+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License or as specified alternatively below. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * Major Contributor(s):
+ * Copyright (C) 2011 SUSE <cbosdonnat@suse.com>
+ *
+ *
+ * All Rights Reserved.
+ *
+ * For minor contributions see the git repository.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPLv2+"), or
+ * the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"),
+ * in which case the provisions of the GPLv2+ or the LGPLv2+ are applicable
+ * instead of those above.
+ */
+
+#include <libcmis-c/property-type.h>
+
+#include "internals.hxx"
+
+void libcmis_vector_property_type_free( libcmis_vector_property_type* vector )
+{
+ delete vector;
+}
+
+
+size_t libcmis_vector_property_type_size( libcmis_vector_property_type* vector )
+{
+ size_t size = 0;
+ if ( vector != NULL )
+ size = vector->handle.size( );
+ return size;
+}
+
+
+libcmis_PropertyTypePtr libcmis_vector_property_type_get( libcmis_vector_property_type* vector, size_t i )
+{
+ libcmis_PropertyTypePtr item = NULL;
+ if ( vector != NULL && i < vector->handle.size( ) )
+ {
+ libcmis::PropertyTypePtr type = vector->handle[i];
+ item = new ( std::nothrow ) libcmis_property_type( );
+ if ( item )
+ item->handle = type;
+ }
+ return item;
+}
+
+
+void libcmis_property_type_free( libcmis_PropertyTypePtr type )
+{
+ delete type;
+}
+
+
+char* libcmis_property_type_getId( libcmis_PropertyTypePtr type )
+{
+ if ( type != NULL && type->handle.get( ) != NULL )
+ return strdup( type->handle->getId( ).c_str( ) );
+ else
+ return NULL;
+}
+
+
+char* libcmis_property_type_getLocalName( libcmis_PropertyTypePtr type )
+{
+ if ( type != NULL && type->handle.get( ) != NULL )
+ return strdup( type->handle->getLocalName( ).c_str( ) );
+ else
+ return NULL;
+}
+
+
+char* libcmis_property_type_getLocalNamespace( libcmis_PropertyTypePtr type )
+{
+ if ( type != NULL && type->handle.get( ) != NULL )
+ return strdup( type->handle->getLocalNamespace( ).c_str( ) );
+ else
+ return NULL;
+}
+
+
+char* libcmis_property_type_getDisplayName( libcmis_PropertyTypePtr type )
+{
+ if ( type != NULL && type->handle.get( ) != NULL )
+ return strdup( type->handle->getDisplayName( ).c_str( ) );
+ else
+ return NULL;
+}
+
+
+char* libcmis_property_type_getQueryName( libcmis_PropertyTypePtr type )
+{
+ if ( type != NULL && type->handle.get( ) != NULL )
+ return strdup( type->handle->getQueryName( ).c_str( ) );
+ else
+ return NULL;
+}
+
+
+libcmis_property_type_Type libcmis_property_type_getType( libcmis_PropertyTypePtr type )
+{
+ if ( type != NULL && type->handle.get( ) != NULL )
+ return libcmis_property_type_Type( type->handle->getType( ) );
+ else
+ return libcmis_String;
+}
+
+
+char* libcmis_property_type_getXmlType( libcmis_PropertyTypePtr type )
+{
+ if ( type != NULL && type->handle.get( ) != NULL )
+ return strdup( type->handle->getXmlType( ).c_str( ) );
+ else
+ return NULL;
+}
+
+
+bool libcmis_property_type_isMultiValued( libcmis_PropertyTypePtr type )
+{
+ bool value = false;
+ if ( type != NULL && type->handle.get( ) != NULL )
+ value = type->handle->isMultiValued( );
+ return value;
+}
+
+
+bool libcmis_property_type_isUpdatable( libcmis_PropertyTypePtr type )
+{
+ bool value = false;
+ if ( type != NULL && type->handle.get( ) != NULL )
+ value = type->handle->isUpdatable( );
+ return value;
+}
+
+
+bool libcmis_property_type_isInherited( libcmis_PropertyTypePtr type )
+{
+ bool value = false;
+ if ( type != NULL && type->handle.get( ) != NULL )
+ value = type->handle->isInherited( );
+ return value;
+}
+
+
+bool libcmis_property_type_isRequired( libcmis_PropertyTypePtr type )
+{
+ bool value = false;
+ if ( type != NULL && type->handle.get( ) != NULL )
+ value = type->handle->isRequired( );
+ return value;
+}
+
+
+bool libcmis_property_type_isQueryable( libcmis_PropertyTypePtr type )
+{
+ bool value = false;
+ if ( type != NULL && type->handle.get( ) != NULL )
+ value = type->handle->isQueryable( );
+ return value;
+}
+
+
+bool libcmis_property_type_isOrderable( libcmis_PropertyTypePtr type )
+{
+ bool value = false;
+ if ( type != NULL && type->handle.get( ) != NULL )
+ value = type->handle->isOrderable( );
+ return value;
+}
+
+
+bool libcmis_property_type_isOpenChoice( libcmis_PropertyTypePtr type )
+{
+ bool value = false;
+ if ( type != NULL && type->handle.get( ) != NULL )
+ value = type->handle->isOpenChoice( );
+ return value;
+}
+
+void libcmis_property_type_update( libcmis_PropertyTypePtr propDef,
+ libcmis_vector_object_type_Ptr types )
+{
+ if ( propDef != NULL && propDef->handle.get( ) != NULL && types != NULL )
+ {
+ std::vector< libcmis::ObjectTypePtr > typesHandle = types->handle;
+ propDef->handle->update( typesHandle );
+ }
+}
diff --git a/src/libcmis-c/property.cxx b/src/libcmis-c/property.cxx
new file mode 100644
index 0000000..2886d55
--- /dev/null
+++ b/src/libcmis-c/property.cxx
@@ -0,0 +1,200 @@
+/* libcmis
+ * Version: MPL 1.1 / GPLv2+ / LGPLv2+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License or as specified alternatively below. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * Major Contributor(s):
+ * Copyright (C) 2011 SUSE <cbosdonnat@suse.com>
+ *
+ *
+ * All Rights Reserved.
+ *
+ * For minor contributions see the git repository.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPLv2+"), or
+ * the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"),
+ * in which case the provisions of the GPLv2+ or the LGPLv2+ are applicable
+ * instead of those above.
+ */
+
+#include <libcmis-c/property.h>
+
+#include "internals.hxx"
+
+using namespace std;
+
+
+libcmis_vector_property_Ptr libcmis_vector_property_create( )
+{
+ return new ( nothrow ) libcmis_vector_property( );
+}
+
+
+void libcmis_vector_property_free( libcmis_vector_property_Ptr vector )
+{
+ delete vector;
+}
+
+
+size_t libcmis_vector_property_size( libcmis_vector_property_Ptr vector )
+{
+ size_t size = 0;
+ if ( vector != NULL )
+ size = vector->handle.size( );
+ return size;
+}
+
+
+libcmis_PropertyPtr libcmis_vector_property_get( libcmis_vector_property_Ptr vector, size_t i )
+{
+ libcmis_PropertyPtr item = NULL;
+ if ( vector != NULL && i < vector->handle.size( ) )
+ {
+ libcmis::PropertyPtr type = vector->handle[i];
+ item = new ( nothrow ) libcmis_property( );
+ if ( item )
+ item->handle = type;
+ }
+ return item;
+}
+
+
+void libcmis_vector_property_append( libcmis_vector_property_Ptr vector, libcmis_PropertyPtr item )
+{
+ if ( vector != NULL &&
+ item != NULL && item->handle.get( ) != NULL )
+ {
+ vector->handle.push_back( item->handle );
+ }
+}
+
+
+libcmis_PropertyPtr libcmis_property_create( libcmis_PropertyTypePtr type, const char** strValues, size_t size )
+{
+ libcmis_PropertyPtr property = NULL;
+ if ( type != NULL && type->handle.get( ) != NULL )
+ {
+ property = new ( nothrow ) libcmis_property( );
+ if ( property )
+ {
+ vector< string > values;
+ for ( size_t i = 0; i < size; ++i )
+ values.push_back( string( strValues[i] ) );
+ libcmis::PropertyPtr prop( new ( nothrow ) libcmis::Property( type->handle, values ) );
+ property->handle = prop;
+ }
+ }
+
+ return property;
+}
+
+
+void libcmis_property_free( libcmis_PropertyPtr property )
+{
+ delete property;
+}
+
+
+libcmis_PropertyTypePtr libcmis_property_getPropertyType( libcmis_PropertyPtr property )
+{
+ libcmis_PropertyTypePtr type = NULL;
+ if ( property != NULL && property->handle.get( ) != NULL )
+ {
+ libcmis::PropertyTypePtr handle = property->handle->getPropertyType( );
+ type = new ( nothrow ) libcmis_property_type( );
+ if ( type )
+ type->handle = handle;
+ }
+ return type;
+}
+
+
+libcmis_vector_time_Ptr libcmis_property_getDateTimes( libcmis_PropertyPtr property )
+{
+ libcmis_vector_time_Ptr times = NULL;
+ if ( property != NULL && property->handle.get( ) != NULL )
+ {
+ vector< boost::posix_time::ptime > handles = property->handle->getDateTimes( );
+ times = new ( nothrow ) libcmis_vector_time( );
+ if ( times )
+ times->handle = handles;
+ }
+ return times;
+}
+
+
+libcmis_vector_bool_Ptr libcmis_property_getBools( libcmis_PropertyPtr property )
+{
+ libcmis_vector_bool_Ptr values = NULL;
+ if ( property != NULL && property->handle.get( ) != NULL )
+ {
+ vector< bool > handles = property->handle->getBools( );
+ values = new ( nothrow ) libcmis_vector_bool( );
+ if ( values )
+ values->handle = handles;
+ }
+ return values;
+}
+
+
+libcmis_vector_string_Ptr libcmis_property_getStrings( libcmis_PropertyPtr property )
+{
+ libcmis_vector_string_Ptr values = NULL;
+ if ( property != NULL && property->handle.get( ) != NULL )
+ {
+ vector< string > handles = property->handle->getStrings( );
+ values = new ( nothrow ) libcmis_vector_string( );
+ if ( values )
+ values->handle = handles;
+ }
+ return values;
+}
+
+
+libcmis_vector_long_Ptr libcmis_property_getLongs( libcmis_PropertyPtr property )
+{
+ libcmis_vector_long_Ptr values = NULL;
+ if ( property != NULL && property->handle.get( ) != NULL )
+ {
+ vector< long > handles = property->handle->getLongs( );
+ values = new ( nothrow ) libcmis_vector_long( );
+ if ( values )
+ values->handle = handles;
+ }
+ return values;
+}
+
+
+libcmis_vector_double_Ptr libcmis_property_getDoubles( libcmis_PropertyPtr property )
+{
+ libcmis_vector_double_Ptr values = NULL;
+ if ( property != NULL && property->handle.get( ) != NULL )
+ {
+ vector< double > handles = property->handle->getDoubles( );
+ values = new ( nothrow ) libcmis_vector_double( );
+ if ( values )
+ values->handle = handles;
+ }
+ return values;
+}
+
+
+void libcmis_property_setValues( libcmis_PropertyPtr property, const char** strValues, size_t size )
+{
+ if ( property != NULL && property->handle.get() != NULL )
+ {
+ vector< string > values;
+ for ( size_t i = 0; i < size; ++i )
+ values.push_back( string( strValues[i] ) );
+ property->handle->setValues( values );
+ }
+}
diff --git a/src/libcmis-c/rendition.cxx b/src/libcmis-c/rendition.cxx
new file mode 100644
index 0000000..8adfd42
--- /dev/null
+++ b/src/libcmis-c/rendition.cxx
@@ -0,0 +1,110 @@
+/* libcmis
+ * Version: MPL 1.1 / GPLv2+ / LGPLv2+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License or as specified alternatively below. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * Major Contributor(s):
+ * Copyright (C) 2013 Cao Cuong Ngo <cao.cuong.ngo@gmail.com>
+ *
+ *
+ * All Rights Reserved.
+ *
+ * For minor contributions see the git repository.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPLv2+"), or
+ * the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"),
+ * in which case the provisions of the GPLv2+ or the LGPLv2+ are applicable
+ * instead of those above.
+ */
+
+#include <libcmis-c/rendition.h>
+
+#include "internals.hxx"
+
+using namespace std;
+
+void libcmis_rendition_free( libcmis_RenditionPtr rendition )
+{
+ delete rendition;
+}
+
+bool libcmis_rendition_isThumbnail( libcmis_RenditionPtr rendition )
+{
+ bool result = false;
+ if ( rendition != NULL && rendition->handle != NULL )
+ result = rendition->handle->isThumbnail();
+ return result;
+}
+
+const char* libcmis_rendition_getStreamId( libcmis_RenditionPtr rendition )
+{
+ if ( rendition != NULL && rendition->handle != NULL )
+ return rendition->handle->getStreamId().c_str();
+ return NULL;
+}
+
+const char* libcmis_rendition_getMimeType( libcmis_RenditionPtr rendition )
+{
+ if ( rendition != NULL && rendition->handle != NULL )
+ return rendition->handle->getMimeType().c_str();
+ return NULL;
+}
+
+const char* libcmis_rendition_getKind( libcmis_RenditionPtr rendition )
+{
+ if ( rendition != NULL && rendition->handle != NULL )
+ return rendition->handle->getKind().c_str();
+ return NULL;
+}
+
+const char* libcmis_rendition_getUrl( libcmis_RenditionPtr rendition )
+{
+ if ( rendition != NULL && rendition->handle != NULL )
+ return rendition->handle->getUrl().c_str();
+ return NULL;
+}
+
+const char* libcmis_rendition_getTitle( libcmis_RenditionPtr rendition )
+{
+ if ( rendition != NULL && rendition->handle != NULL )
+ return rendition->handle->getTitle().c_str();
+ return NULL;
+}
+
+long libcmis_rendition_getLength( libcmis_RenditionPtr rendition )
+{
+ if ( rendition != NULL && rendition->handle != NULL )
+ return rendition->handle->getLength();
+ return -1;
+}
+
+long libcmis_rendition_getWidth( libcmis_RenditionPtr rendition )
+{
+ if ( rendition != NULL && rendition->handle != NULL )
+ return rendition->handle->getWidth();
+ return -1;
+}
+
+long libcmis_rendition_getHeight( libcmis_RenditionPtr rendition )
+{
+ if ( rendition != NULL && rendition->handle != NULL )
+ return rendition->handle->getHeight();
+ return -1;
+}
+
+const char* libcmis_rendition_getRenditionDocumentId( libcmis_RenditionPtr rendition )
+{
+ if ( rendition != NULL && rendition->handle != NULL )
+ return rendition->handle->getRenditionDocumentId().c_str();
+ return NULL;
+}
+
diff --git a/src/libcmis-c/repository.cxx b/src/libcmis-c/repository.cxx
new file mode 100644
index 0000000..41169a1
--- /dev/null
+++ b/src/libcmis-c/repository.cxx
@@ -0,0 +1,208 @@
+/* libcmis
+ * Version: MPL 1.1 / GPLv2+ / LGPLv2+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License or as specified alternatively below. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * Major Contributor(s):
+ * Copyright (C) 2011 SUSE <cbosdonnat@suse.com>
+ *
+ *
+ * All Rights Reserved.
+ *
+ * For minor contributions see the git repository.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPLv2+"), or
+ * the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"),
+ * in which case the provisions of the GPLv2+ or the LGPLv2+ are applicable
+ * instead of those above.
+ */
+
+#include <libcmis-c/repository.h>
+
+#include "internals.hxx"
+
+using std::nothrow;
+
+void libcmis_vector_repository_free( libcmis_vector_Repository_Ptr vector )
+{
+ delete vector;
+}
+
+
+size_t libcmis_vector_repository_size( libcmis_vector_Repository_Ptr vector )
+{
+ size_t size = 0;
+ if ( vector != NULL )
+ size = vector->handle.size( );
+ return size;
+}
+
+
+libcmis_RepositoryPtr libcmis_vector_repository_get( libcmis_vector_Repository_Ptr vector, size_t i )
+{
+ libcmis_RepositoryPtr item = NULL;
+ if ( vector != NULL && i < vector->handle.size( ) )
+ {
+ libcmis::RepositoryPtr type = vector->handle[i];
+ item = new ( nothrow ) libcmis_repository( );
+ if ( item )
+ item->handle = type;
+ }
+ return item;
+}
+
+
+libcmis_RepositoryPtr libcmis_repository_create( xmlNodePtr node )
+{
+ libcmis_RepositoryPtr repository = new ( nothrow ) libcmis_repository( );
+
+ if ( repository )
+ {
+ libcmis::RepositoryPtr handle( new ( nothrow ) libcmis::Repository( node ) );
+ repository->handle = handle;
+ }
+
+ return repository;
+}
+
+
+void libcmis_repository_free( libcmis_RepositoryPtr repository )
+{
+ delete repository;
+}
+
+
+char* libcmis_repository_getId( libcmis_RepositoryPtr repository )
+{
+ if ( repository != NULL && repository->handle != NULL )
+ return strdup( repository->handle->getId( ).c_str( ) );
+ else
+ return NULL;
+}
+
+
+char* libcmis_repository_getName( libcmis_RepositoryPtr repository )
+{
+ if ( repository != NULL && repository->handle != NULL )
+ return strdup( repository->handle->getName( ).c_str( ) );
+ else
+ return NULL;
+}
+
+
+char* libcmis_repository_getDescription( libcmis_RepositoryPtr repository )
+{
+ if ( repository != NULL && repository->handle != NULL )
+ return strdup( repository->handle->getDescription( ).c_str( ) );
+ else
+ return NULL;
+}
+
+
+char* libcmis_repository_getVendorName( libcmis_RepositoryPtr repository )
+{
+ if ( repository != NULL && repository->handle != NULL )
+ return strdup( repository->handle->getVendorName( ).c_str( ) );
+ else
+ return NULL;
+}
+
+
+char* libcmis_repository_getProductName( libcmis_RepositoryPtr repository )
+{
+ if ( repository != NULL && repository->handle != NULL )
+ return strdup( repository->handle->getProductName( ).c_str( ) );
+ else
+ return NULL;
+}
+
+
+char* libcmis_repository_getProductVersion( libcmis_RepositoryPtr repository )
+{
+ if ( repository != NULL && repository->handle != NULL )
+ return strdup( repository->handle->getProductVersion( ).c_str( ) );
+ else
+ return NULL;
+}
+
+
+char* libcmis_repository_getRootId( libcmis_RepositoryPtr repository )
+{
+ if ( repository != NULL && repository->handle != NULL )
+ return strdup( repository->handle->getRootId( ).c_str( ) );
+ else
+ return NULL;
+}
+
+
+char* libcmis_repository_getCmisVersionSupported( libcmis_RepositoryPtr repository )
+{
+ if ( repository != NULL && repository->handle != NULL )
+ return strdup( repository->handle->getCmisVersionSupported( ).c_str( ) );
+ else
+ return NULL;
+}
+
+
+char* libcmis_repository_getThinClientUri( libcmis_RepositoryPtr repository )
+{
+ if ( repository != NULL && repository->handle != NULL &&
+ repository->handle->getThinClientUri( ).get( ) != NULL )
+ return strdup( repository->handle->getThinClientUri( )->c_str( ) );
+ else
+ return NULL;
+}
+
+
+char* libcmis_repository_getPrincipalAnonymous( libcmis_RepositoryPtr repository )
+{
+ if ( repository != NULL && repository->handle != NULL &&
+ repository->handle->getPrincipalAnonymous( ).get( ) != NULL )
+ return strdup( repository->handle->getPrincipalAnonymous( )->c_str( ) );
+ else
+ return NULL;
+}
+
+
+char* libcmis_repository_getPrincipalAnyone( libcmis_RepositoryPtr repository )
+{
+ if ( repository != NULL && repository->handle != NULL &&
+ repository->handle->getPrincipalAnyone( ).get( ) != NULL )
+ return strdup( repository->handle->getPrincipalAnyone( )->c_str( ) );
+ else
+ return NULL;
+}
+
+char* libcmis_repository_getCapability(
+ libcmis_RepositoryPtr repository,
+ libcmis_repository_capability_Type capability )
+{
+ if ( repository != NULL && repository->handle != NULL )
+ {
+ std::string value = repository->handle->getCapability( ( libcmis::Repository::Capability ) capability );
+ return strdup( value.c_str( ) );
+ }
+ else
+ return NULL;
+}
+
+bool libcmis_repository_getCapabilityAsBool(
+ libcmis_RepositoryPtr repository,
+ libcmis_repository_capability_Type capability )
+{
+ if ( repository != NULL && repository->handle != NULL )
+ {
+ return repository->handle->getCapabilityAsBool( ( libcmis::Repository::Capability ) capability );
+ }
+ else
+ return false;
+}
diff --git a/src/libcmis-c/session-factory.cxx b/src/libcmis-c/session-factory.cxx
new file mode 100644
index 0000000..cee4532
--- /dev/null
+++ b/src/libcmis-c/session-factory.cxx
@@ -0,0 +1,239 @@
+/* libcmis
+ * Version: MPL 1.1 / GPLv2+ / LGPLv2+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License or as specified alternatively below. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * Major Contributor(s):
+ * Copyright (C) 2011 SUSE <cbosdonnat@suse.com>
+ *
+ *
+ * All Rights Reserved.
+ *
+ * For minor contributions see the git repository.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPLv2+"), or
+ * the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"),
+ * in which case the provisions of the GPLv2+ or the LGPLv2+ are applicable
+ * instead of those above.
+ */
+
+#include <libcmis-c/session-factory.h>
+
+#include <map>
+#include <string>
+#include <stdlib.h>
+
+#include <libcmis/session-factory.hxx>
+
+#include <libcmis-c/session.h>
+#include <libcmis-c/vectors.h>
+
+#include "internals.hxx"
+
+using namespace std;
+
+namespace
+{
+ size_t const CRED_MAX_LEN = 1024;
+
+ class WrapperAuthProvider : public libcmis::AuthProvider
+ {
+ private:
+ libcmis_authenticationCallback m_callback;
+
+ public:
+ WrapperAuthProvider( libcmis_authenticationCallback callback ) :
+ m_callback( callback )
+ {
+ }
+ virtual ~WrapperAuthProvider( ) { };
+
+ virtual bool authenticationQuery( string& username, string& password );
+ };
+
+ bool WrapperAuthProvider::authenticationQuery( string& username, string& password )
+ {
+ /* NOTE: As I understand this, the callback is responsible for
+ * filling the correct username and password (possibly using
+ * the passed values as defaults in some dialog or so). But then
+ * there is no guarantee that the new username/password will
+ * not be longer than the present one, in which case it will
+ * not fit into the available space! For now, use a buffer size
+ * big enough for practical purposes.
+ *
+ * It might be a better idea to change the callback's signature
+ * to bool ( * )( char** username, char** password )
+ * and make it the callee's responsibility to reallocate the
+ * strings if it needs to.
+ */
+ char user[CRED_MAX_LEN];
+ strncpy(user, username.c_str( ), sizeof( user ) );
+ user[CRED_MAX_LEN - 1] = '\0';
+ char pass[CRED_MAX_LEN];
+ strncpy(pass, password.c_str( ), sizeof( pass ) );
+ pass[CRED_MAX_LEN - 1] = '\0';
+
+ bool result = m_callback( user, pass );
+
+ // Update the username and password with the input
+ username = user;
+ password = pass;
+
+ return result;
+ }
+
+
+ class WrapperCertHandler : public libcmis::CertValidationHandler
+ {
+ private:
+ libcmis_certValidationCallback m_callback;
+ public:
+ WrapperCertHandler( libcmis_certValidationCallback callback ) :
+ m_callback( callback )
+ {
+ }
+ virtual ~WrapperCertHandler( ) { };
+
+ virtual bool validateCertificate( vector< string > certificatesChain );
+ };
+
+ bool WrapperCertHandler::validateCertificate( vector< string > certificatesChain )
+ {
+ libcmis_vector_string_Ptr chain = new ( nothrow ) libcmis_vector_string( );
+ if ( chain )
+ chain->handle = certificatesChain;
+
+ bool result = m_callback( chain );
+
+ libcmis_vector_string_free( chain );
+ return result;
+ }
+}
+
+std::string createString( char* str )
+{
+ if ( str )
+ return string( str );
+ else
+ return string( );
+}
+
+void libcmis_setAuthenticationCallback( libcmis_authenticationCallback callback )
+{
+ libcmis::AuthProviderPtr provider( new ( nothrow ) WrapperAuthProvider( callback ) );
+ if ( provider )
+ libcmis::SessionFactory::setAuthenticationProvider( provider );
+}
+
+void libcmis_setCertValidationCallback( libcmis_certValidationCallback callback )
+{
+ libcmis::CertValidationHandlerPtr handler( new ( nothrow )WrapperCertHandler( callback ) );
+ if ( handler )
+ libcmis::SessionFactory::setCertificateValidationHandler( handler );
+}
+
+void libcmis_setOAuth2AuthCodeProvider( libcmis_oauth2AuthCodeProvider callback )
+{
+ libcmis::SessionFactory::setOAuth2AuthCodeProvider( callback );
+}
+
+libcmis_oauth2AuthCodeProvider libcmis_getOAuth2AuthCodeProvider( )
+{
+ return libcmis::SessionFactory::getOAuth2AuthCodeProvider( );
+}
+
+void libcmis_setProxySettings( char* proxy, char* noProxy,
+ char* proxyUser, char* proxyPass )
+{
+ libcmis::SessionFactory::setProxySettings( string( proxy ), string( noProxy ),
+ string( proxyUser ), string( proxyPass ) );
+}
+
+const char* libcmis_getProxy( )
+{
+ return libcmis::SessionFactory::getProxy( ).c_str();
+}
+
+const char* libcmis_getNoProxy( )
+{
+ return libcmis::SessionFactory::getNoProxy( ).c_str();
+}
+
+const char* libcmis_getProxyUser( )
+{
+ return libcmis::SessionFactory::getProxyUser( ).c_str();
+}
+
+const char* libcmis_getProxyPass( )
+{
+ return libcmis::SessionFactory::getProxyPass( ).c_str();
+}
+
+libcmis_SessionPtr libcmis_createSession(
+ char* bindingUrl,
+ char* repositoryId,
+ char* username,
+ char* password,
+ bool noSslCheck,
+ libcmis_OAuth2DataPtr oauth2,
+ bool verbose,
+ libcmis_ErrorPtr error )
+{
+ libcmis_SessionPtr session = NULL;
+
+ try
+ {
+ libcmis::OAuth2DataPtr oauth2Handle;
+ if ( oauth2 != NULL )
+ oauth2Handle = oauth2->handle;
+
+ libcmis::Session* handle = libcmis::SessionFactory::createSession(
+ createString( bindingUrl ),
+ createString( username ),
+ createString( password ),
+ createString( repositoryId ), noSslCheck, oauth2Handle, verbose );
+ session = new libcmis_session( );
+ session->handle = handle;
+ }
+ catch ( const libcmis::Exception& e )
+ {
+ if ( error != NULL )
+ {
+ error->message = strdup( e.what() );
+ error->type = strdup( e.getType().c_str() );
+ }
+ }
+ catch ( const bad_alloc& e )
+ {
+ if ( error != NULL )
+ {
+ error->message = strdup( e.what() );
+ error->badAlloc = true;
+ }
+ }
+
+ return session;
+}
+
+libcmis_vector_Repository_Ptr libcmis_getRepositories(
+ char* bindingUrl,
+ char* username,
+ char* password,
+ bool verbose,
+ libcmis_ErrorPtr error )
+{
+ libcmis_SessionPtr session = libcmis_createSession(
+ bindingUrl, NULL, username, password, false, NULL, verbose, error );
+ libcmis_vector_Repository_Ptr repositories = libcmis_session_getRepositories( session );
+ libcmis_session_free( session );
+ return repositories;
+}
diff --git a/src/libcmis-c/session.cxx b/src/libcmis-c/session.cxx
new file mode 100644
index 0000000..df6b503
--- /dev/null
+++ b/src/libcmis-c/session.cxx
@@ -0,0 +1,305 @@
+/* libcmis
+ * Version: MPL 1.1 / GPLv2+ / LGPLv2+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License or as specified alternatively below. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * Major Contributor(s):
+ * Copyright (C) 2011 SUSE <cbosdonnat@suse.com>
+ *
+ *
+ * All Rights Reserved.
+ *
+ * For minor contributions see the git repository.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPLv2+"), or
+ * the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"),
+ * in which case the provisions of the GPLv2+ or the LGPLv2+ are applicable
+ * instead of those above.
+ */
+
+#include <libcmis-c/session.h>
+
+#include <utility>
+
+#include "internals.hxx"
+
+using namespace std;
+
+void libcmis_session_free( libcmis_SessionPtr session )
+{
+ if ( session != NULL )
+ {
+ delete session->handle;
+ delete session;
+ }
+}
+
+libcmis_RepositoryPtr libcmis_session_getRepository(
+ libcmis_SessionPtr session,
+ libcmis_ErrorPtr error )
+{
+ libcmis_RepositoryPtr repository = NULL;
+
+ if ( session != NULL && session->handle != NULL )
+ {
+ try
+ {
+ libcmis::RepositoryPtr handle = session->handle->getRepository( );
+ if ( handle )
+ {
+ repository = new ( nothrow ) libcmis_repository( );
+ if ( repository )
+ repository->handle = handle;
+ }
+ }
+ catch ( const libcmis::Exception& e )
+ {
+ if ( error != NULL )
+ {
+ error->message = strdup( e.what() );
+ error->type = strdup( e.getType().c_str() );
+ }
+ }
+ }
+
+ return repository;
+}
+
+libcmis_vector_Repository_Ptr libcmis_session_getRepositories( libcmis_SessionPtr session )
+{
+ libcmis_vector_Repository_Ptr result = NULL;
+ if ( session != NULL && session->handle != NULL )
+ {
+ vector< libcmis::RepositoryPtr > handles = session->handle->getRepositories();
+ result = new ( nothrow ) libcmis_vector_repository( );
+ if ( result )
+ result->handle = handles;
+ }
+
+ return result;
+}
+
+bool libcmis_session_setRepository( libcmis_SessionPtr session, const char* id )
+{
+ bool success = false;
+ if ( session && session->handle && id )
+ {
+ success = session->handle->setRepository( id );
+ }
+ return success;
+}
+
+libcmis_FolderPtr libcmis_session_getRootFolder(
+ libcmis_SessionPtr session,
+ libcmis_ErrorPtr error )
+{
+ libcmis_FolderPtr folder = NULL;
+ if ( session != NULL && session->handle != NULL )
+ {
+ try
+ {
+ libcmis::FolderPtr handle = session->handle->getRootFolder( );
+ folder = new libcmis_folder( );
+ folder->handle = handle;
+ }
+ catch ( const libcmis::Exception& e )
+ {
+ if ( error != NULL )
+ {
+ error->message = strdup( e.what() );
+ error->type = strdup( e.getType().c_str() );
+ }
+ }
+ catch ( const bad_alloc& e )
+ {
+ if ( error != NULL )
+ {
+ error->message = strdup( e.what() );
+ error->badAlloc = true;
+ }
+ }
+ }
+ return folder;
+}
+
+
+libcmis_ObjectPtr libcmis_session_getObject(
+ libcmis_SessionPtr session,
+ const char* id,
+ libcmis_ErrorPtr error )
+{
+ libcmis_ObjectPtr object = NULL;
+ if ( session != NULL && session->handle != NULL )
+ {
+ try
+ {
+ libcmis::ObjectPtr handle = session->handle->getObject( string( id ) );
+ object = new libcmis_object( );
+ object->handle = handle;
+ }
+ catch ( const libcmis::Exception& e )
+ {
+ if ( error != NULL )
+ {
+ error->message = strdup( e.what() );
+ error->type = strdup( e.getType().c_str() );
+ }
+ }
+ catch ( const bad_alloc& e )
+ {
+ if ( error != NULL )
+ {
+ error->message = strdup( e.what() );
+ error->badAlloc = true;
+ }
+ }
+ }
+ return object;
+}
+
+
+libcmis_ObjectPtr libcmis_session_getObjectByPath(
+ libcmis_SessionPtr session,
+ const char* path,
+ libcmis_ErrorPtr error )
+{
+ libcmis_ObjectPtr object = NULL;
+ if ( session != NULL && session->handle != NULL )
+ {
+ try
+ {
+ libcmis::ObjectPtr handle = session->handle->getObjectByPath( string( path ) );
+ object = new libcmis_object( );
+ object->handle = handle;
+ }
+ catch ( const libcmis::Exception& e )
+ {
+ if ( error != NULL )
+ {
+ error->message = strdup( e.what() );
+ error->type = strdup( e.getType().c_str() );
+ }
+ }
+ catch ( const bad_alloc& e )
+ {
+ if ( error != NULL )
+ {
+ error->message = strdup( e.what() );
+ error->badAlloc = true;
+ }
+ }
+ }
+ return object;
+}
+
+
+libcmis_FolderPtr libcmis_session_getFolder(
+ libcmis_SessionPtr session,
+ const char* id,
+ libcmis_ErrorPtr error )
+{
+ libcmis_FolderPtr folder = NULL;
+ if ( session != NULL && session->handle != NULL )
+ {
+ try
+ {
+ libcmis::FolderPtr handle = session->handle->getFolder( string( id ) );
+ folder = new libcmis_folder( );
+ folder->handle = handle;
+ }
+ catch ( const libcmis::Exception& e )
+ {
+ if ( error != NULL )
+ {
+ error->message = strdup( e.what() );
+ error->type = strdup( e.getType().c_str() );
+ }
+ }
+ catch ( const bad_alloc& e )
+ {
+ if ( error != NULL )
+ {
+ error->message = strdup( e.what() );
+ error->badAlloc = true;
+ }
+ }
+ }
+ return folder;
+}
+
+
+libcmis_ObjectTypePtr libcmis_session_getType(
+ libcmis_SessionPtr session,
+ const char* id,
+ libcmis_ErrorPtr error )
+{
+ libcmis_ObjectTypePtr type = NULL;
+ if ( session != NULL && session->handle != NULL )
+ {
+ try
+ {
+ libcmis::ObjectTypePtr handle = session->handle->getType( string( id ) );
+ type = new libcmis_object_type( );
+ type->handle = handle;
+ }
+ catch ( const libcmis::Exception& e )
+ {
+ if ( error != NULL )
+ {
+ error->message = strdup( e.what() );
+ error->type = strdup( e.getType().c_str() );
+ }
+ }
+ catch ( const bad_alloc& e )
+ {
+ if ( error != NULL )
+ {
+ error->message = strdup( e.what() );
+ error->badAlloc = true;
+ }
+ }
+ }
+ return type;
+}
+
+libcmis_vector_object_type_Ptr libcmis_session_getBaseTypes(
+ libcmis_SessionPtr session,
+ libcmis_ErrorPtr error )
+{
+ libcmis_vector_object_type_Ptr types = NULL;
+ if ( session != NULL && session->handle != NULL )
+ {
+ try
+ {
+ vector< libcmis::ObjectTypePtr > handles = session->handle->getBaseTypes( );
+ types = new libcmis_vector_object_type( );
+ types->handle = handles;
+ }
+ catch ( const libcmis::Exception& e )
+ {
+ if ( error != NULL )
+ {
+ error->message = strdup( e.what() );
+ error->type = strdup( e.getType().c_str() );
+ }
+ }
+ catch ( const bad_alloc& e )
+ {
+ if ( error != NULL )
+ {
+ error->message = strdup( e.what() );
+ error->badAlloc = true;
+ }
+ }
+ }
+ return types;
+}
diff --git a/src/libcmis-c/vectors.cxx b/src/libcmis-c/vectors.cxx
new file mode 100644
index 0000000..e520751
--- /dev/null
+++ b/src/libcmis-c/vectors.cxx
@@ -0,0 +1,139 @@
+/* libcmis
+ * Version: MPL 1.1 / GPLv2+ / LGPLv2+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License or as specified alternatively below. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * Major Contributor(s):
+ * Copyright (C) 2011 SUSE <cbosdonnat@suse.com>
+ *
+ *
+ * All Rights Reserved.
+ *
+ * For minor contributions see the git repository.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPLv2+"), or
+ * the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"),
+ * in which case the provisions of the GPLv2+ or the LGPLv2+ are applicable
+ * instead of those above.
+ */
+
+#include <libcmis-c/vectors.h>
+
+#include "internals.hxx"
+
+void libcmis_vector_bool_free( libcmis_vector_bool_Ptr vector )
+{
+ delete vector;
+}
+
+size_t libcmis_vector_bool_size( libcmis_vector_bool_Ptr vector )
+{
+ size_t size = 0;
+ if ( vector != NULL )
+ size = vector->handle.size( );
+ return size;
+}
+
+bool libcmis_vector_bool_get( libcmis_vector_bool_Ptr vector, size_t i )
+{
+ bool item = false;
+ if ( vector != NULL && i < vector->handle.size( ) )
+ item = vector->handle[i];
+ return item;
+}
+
+void libcmis_vector_string_free( libcmis_vector_string_Ptr vector )
+{
+ delete vector;
+}
+
+size_t libcmis_vector_string_size( libcmis_vector_string_Ptr vector )
+{
+ size_t size = 0;
+ if ( vector != NULL )
+ size = vector->handle.size( );
+ return size;
+}
+
+const char* libcmis_vector_string_get( libcmis_vector_string_Ptr vector, size_t i )
+{
+ const char* item = NULL;
+ if ( vector != NULL && i < vector->handle.size( ) )
+ item = vector->handle[i].c_str( );
+ return item;
+}
+
+void libcmis_vector_long_free( libcmis_vector_long_Ptr vector )
+{
+ delete vector;
+}
+
+size_t libcmis_vector_long_size( libcmis_vector_long_Ptr vector )
+{
+ size_t size = 0;
+ if ( vector != NULL )
+ size = vector->handle.size( );
+ return size;
+}
+
+long libcmis_vector_long_get( libcmis_vector_long_Ptr vector, size_t i )
+{
+ long item = 0;
+ if ( vector != NULL && i < vector->handle.size( ) )
+ item = vector->handle[i];
+ return item;
+}
+
+void libcmis_vector_double_free( libcmis_vector_double_Ptr vector )
+{
+ delete vector;
+}
+
+size_t libcmis_vector_double_size( libcmis_vector_double_Ptr vector )
+{
+ size_t size = 0;
+ if ( vector != NULL )
+ size = vector->handle.size( );
+ return size;
+}
+
+double libcmis_vector_double_get( libcmis_vector_double_Ptr vector, size_t i )
+{
+ double item = 0.0;
+ if ( vector != NULL && i < vector->handle.size( ) )
+ item = vector->handle[i];
+ return item;
+}
+
+void libcmis_vector_time_free( libcmis_vector_time_Ptr vector )
+{
+ delete vector;
+}
+
+size_t libcmis_vector_time_size( libcmis_vector_time_Ptr vector )
+{
+ size_t size = 0;
+ if ( vector != NULL )
+ size = vector->handle.size( );
+ return size;
+}
+
+time_t libcmis_vector_time_get( libcmis_vector_time_Ptr vector, size_t i )
+{
+ time_t item = 0;
+ if ( vector != NULL && i < vector->handle.size( ) )
+ {
+ tm time = boost::posix_time::to_tm( vector->handle[i] );
+ item = mktime( &time );
+ }
+ return item;
+}