diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 05:41:20 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 05:41:20 +0000 |
commit | 2cd20b3e73d0162e3fa23ebcee8e89a3b967ca6f (patch) | |
tree | 754a142de5cd8f987abe255e8a15b5ef94109da4 /inc | |
parent | Initial commit. (diff) | |
download | libcmis-2cd20b3e73d0162e3fa23ebcee8e89a3b967ca6f.tar.xz libcmis-2cd20b3e73d0162e3fa23ebcee8e89a3b967ca6f.zip |
Adding upstream version 0.6.2.upstream/0.6.2upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
37 files changed, 3350 insertions, 0 deletions
diff --git a/inc/Makefile.am b/inc/Makefile.am new file mode 100644 index 0000000..f088d50 --- /dev/null +++ b/inc/Makefile.am @@ -0,0 +1 @@ +SUBDIRS = libcmis libcmis-c diff --git a/inc/libcmis-c/Makefile.am b/inc/libcmis-c/Makefile.am new file mode 100644 index 0000000..eefbde2 --- /dev/null +++ b/inc/libcmis-c/Makefile.am @@ -0,0 +1,20 @@ +libcmis_cdir = $(includedir)/libcmis-c-@LIBCMIS_API_VERSION@/libcmis-c + +dist_libcmis_c_HEADERS = \ + allowable-actions.h \ + document.h \ + error.h \ + folder.h \ + libcmis-c-api.h \ + libcmis-c.h \ + oauth2-data.h \ + object-type.h \ + object.h \ + property-type.h \ + property.h \ + rendition.h \ + repository.h \ + session-factory.h \ + session.h \ + types.h \ + vectors.h diff --git a/inc/libcmis-c/allowable-actions.h b/inc/libcmis-c/allowable-actions.h new file mode 100644 index 0000000..c2764d3 --- /dev/null +++ b/inc/libcmis-c/allowable-actions.h @@ -0,0 +1,50 @@ +/* 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_ALLOWABLE_ACTIONS_H_ +#define _LIBCMIS_ALLOWABLE_ACTIONS_H_ + +#include "libcmis-c/libcmis-c-api.h" +#include "libcmis-c/types.h" + +#ifdef __cplusplus +extern "C" { +#endif + +LIBCMIS_C_API void libcmis_allowable_actions_free( libcmis_AllowableActionsPtr allowable ); + +LIBCMIS_C_API bool libcmis_allowable_actions_isAllowed( libcmis_AllowableActionsPtr allowable, + libcmis_allowable_actions_Type action ); + +LIBCMIS_C_API bool libcmis_allowable_actions_isDefined( libcmis_AllowableActionsPtr allowable, + libcmis_allowable_actions_Type action ); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/inc/libcmis-c/document.h b/inc/libcmis-c/document.h new file mode 100644 index 0000000..5436956 --- /dev/null +++ b/inc/libcmis-c/document.h @@ -0,0 +1,96 @@ +/* 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_DOCUMENT_H_ +#define _LIBCMIS_DOCUMENT_H_ + +#include "libcmis-c/libcmis-c-api.h" +#include "libcmis-c/types.h" + +#ifdef __cplusplus +extern "C" { +#endif + +LIBCMIS_C_API void libcmis_vector_document_free( libcmis_vector_document_Ptr vector ); +LIBCMIS_C_API size_t libcmis_vector_document_size( libcmis_vector_document_Ptr vector ); +LIBCMIS_C_API libcmis_DocumentPtr libcmis_vector_document_get( libcmis_vector_document_Ptr vector, size_t i ); + +LIBCMIS_C_API bool libcmis_is_document( libcmis_ObjectPtr object ); +LIBCMIS_C_API libcmis_DocumentPtr libcmis_document_cast( libcmis_ObjectPtr object ); + +LIBCMIS_C_API void libcmis_document_free( libcmis_DocumentPtr document ); + +LIBCMIS_C_API libcmis_vector_folder_Ptr libcmis_document_getParents( libcmis_DocumentPtr document, libcmis_ErrorPtr error ); + +LIBCMIS_C_API void libcmis_document_getContentStream( + libcmis_DocumentPtr document, + libcmis_writeFn writeFn, + void* userData, + libcmis_ErrorPtr error ); + +LIBCMIS_C_API void libcmis_document_setContentStream( + libcmis_DocumentPtr document, + libcmis_readFn readFn, + void* userData, + const char* contentType, + const char* filename, + bool overwrite, + libcmis_ErrorPtr ); + +/** The resulting value needs to be free'd + */ +LIBCMIS_C_API char* libcmis_document_getContentType( libcmis_DocumentPtr document ); + +/** The resulting value needs to be free'd + */ +LIBCMIS_C_API char* libcmis_document_getContentFilename( libcmis_DocumentPtr document ); + +LIBCMIS_C_API long libcmis_document_getContentLength( libcmis_DocumentPtr document ); + +LIBCMIS_C_API libcmis_DocumentPtr libcmis_document_checkOut( libcmis_DocumentPtr document, libcmis_ErrorPtr error ); +LIBCMIS_C_API void libcmis_document_cancelCheckout( libcmis_DocumentPtr document, libcmis_ErrorPtr error ); + +LIBCMIS_C_API 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_C_API libcmis_vector_document_Ptr libcmis_document_getAllVersions( + libcmis_DocumentPtr document, + libcmis_ErrorPtr error ); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/inc/libcmis-c/error.h b/inc/libcmis-c/error.h new file mode 100644 index 0000000..8a63bfa --- /dev/null +++ b/inc/libcmis-c/error.h @@ -0,0 +1,48 @@ +/* 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_ERROR_H_ +#define _LIBCMIS_ERROR_H_ + +#include "libcmis-c/libcmis-c-api.h" +#include "libcmis-c/types.h" + +#ifdef __cplusplus +extern "C" { +#endif + +LIBCMIS_C_API libcmis_ErrorPtr libcmis_error_create( ); +LIBCMIS_C_API void libcmis_error_free( libcmis_ErrorPtr e ); + +LIBCMIS_C_API const char* libcmis_error_getMessage( libcmis_ErrorPtr e ); +LIBCMIS_C_API const char* libcmis_error_getType( libcmis_ErrorPtr e ); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/inc/libcmis-c/folder.h b/inc/libcmis-c/folder.h new file mode 100644 index 0000000..e741e71 --- /dev/null +++ b/inc/libcmis-c/folder.h @@ -0,0 +1,81 @@ +/* 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_FOLDER_H_ +#define _LIBCMIS_FOLDER_H_ + +#include "libcmis-c/libcmis-c-api.h" +#include "libcmis-c/types.h" + +#ifdef __cplusplus +extern "C" { +#endif + +LIBCMIS_C_API void libcmis_vector_folder_free( libcmis_vector_folder_Ptr vector ); +LIBCMIS_C_API size_t libcmis_vector_folder_size( libcmis_vector_folder_Ptr vector ); +LIBCMIS_C_API libcmis_FolderPtr libcmis_vector_folder_get( libcmis_vector_folder_Ptr vector, size_t i ); + + +LIBCMIS_C_API bool libcmis_is_folder( libcmis_ObjectPtr object ); +LIBCMIS_C_API libcmis_FolderPtr libcmis_folder_cast( libcmis_ObjectPtr object ); + +LIBCMIS_C_API void libcmis_folder_free( libcmis_FolderPtr folder ); + +LIBCMIS_C_API libcmis_FolderPtr libcmis_folder_getParent( libcmis_FolderPtr folder, libcmis_ErrorPtr error ); +LIBCMIS_C_API libcmis_vector_object_Ptr libcmis_folder_getChildren( libcmis_FolderPtr folder, libcmis_ErrorPtr error ); + +/** Get the path of the folder. The returned string needs to be freed. + */ +LIBCMIS_C_API char* libcmis_folder_getPath( libcmis_FolderPtr folder ); + +LIBCMIS_C_API bool libcmis_folder_isRootFolder( libcmis_FolderPtr folder ); + +LIBCMIS_C_API libcmis_FolderPtr libcmis_folder_createFolder( + libcmis_FolderPtr folder, + libcmis_vector_property_Ptr properties, + libcmis_ErrorPtr error ); + +LIBCMIS_C_API 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_C_API libcmis_vector_string_Ptr libcmis_folder_removeTree( libcmis_FolderPtr folder, + bool allVersion, + libcmis_folder_UnfileObjects unfile, + bool continueOnError, + libcmis_ErrorPtr error ); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/inc/libcmis-c/libcmis-c-api.h b/inc/libcmis-c/libcmis-c-api.h new file mode 100644 index 0000000..3fe7986 --- /dev/null +++ b/inc/libcmis-c/libcmis-c-api.h @@ -0,0 +1,45 @@ +/* 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_C_API_H_ +#define _LIBCMIS_C_API_H_ + +#ifdef DLL_EXPORT +#ifdef LIBCMIS_C_BUILD +#define LIBCMIS_C_API __declspec(dllexport) +#else +#define LIBCMIS_C_API __declspec(dllimport) +#endif +#else /* !DLL_EXPORT */ +#ifdef LIBCMIS_C_VISIBILITY +#define LIBCMIS_C_API __attribute__((visibility("default"))) +#else +#define LIBCMIS_C_API +#endif +#endif + +#endif diff --git a/inc/libcmis-c/libcmis-c.h b/inc/libcmis-c/libcmis-c.h new file mode 100644 index 0000000..d9f6e4e --- /dev/null +++ b/inc/libcmis-c/libcmis-c.h @@ -0,0 +1,50 @@ +/* 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_C_H_ +#define _LIBCMIS_C_H_ + +#include "libcmis-c/libcmis-c-api.h" +#include "libcmis-c/types.h" + +#include "libcmis-c/allowable-actions.h" +#include "libcmis-c/document.h" +#include "libcmis-c/error.h" +#include "libcmis-c/folder.h" +#include "libcmis-c/object.h" +#include "libcmis-c/object-type.h" +#include "libcmis-c/property.h" +#include "libcmis-c/property-type.h" +#include "libcmis-c/oauth2-data.h" +#include "libcmis-c/rendition.h" +#include "libcmis-c/repository.h" +#include "libcmis-c/types.h" +#include "libcmis-c/session.h" +#include "libcmis-c/session-factory.h" +#include "libcmis-c/vectors.h" + +#endif diff --git a/inc/libcmis-c/oauth2-data.h b/inc/libcmis-c/oauth2-data.h new file mode 100644 index 0000000..ec4a9d3 --- /dev/null +++ b/inc/libcmis-c/oauth2-data.h @@ -0,0 +1,58 @@ + +/* 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_OAUTH2_DATA_H_ +#define _LIBCMIS_OAUTH2_DATA_H_ + +#include "libcmis-c/libcmis-c-api.h" +#include "libcmis-c/types.h" + +#ifdef __cplusplus +extern "C" { +#endif + +LIBCMIS_C_API libcmis_OAuth2DataPtr libcmis_oauth2data_create( + char* authUrl, char* tokenUrl, char* scopes, char* redirectUri, + char* clientId, char* clientSecret ); + +LIBCMIS_C_API void libcmis_oauth2data_free( libcmis_OAuth2DataPtr oauth2 ); + +LIBCMIS_C_API bool libcmis_oauth2data_isComplete( libcmis_OAuth2DataPtr oauth2 ); + +LIBCMIS_C_API const char* libcmis_oauth2data_getAuthUrl( libcmis_OAuth2DataPtr oauth2 ); +LIBCMIS_C_API const char* libcmis_oauth2data_getTokenUrl( libcmis_OAuth2DataPtr oauth2 ); +LIBCMIS_C_API const char* libcmis_oauth2data_getClientId( libcmis_OAuth2DataPtr oauth2 ); +LIBCMIS_C_API const char* libcmis_oauth2data_getClientSecret( libcmis_OAuth2DataPtr oauth2 ); +LIBCMIS_C_API const char* libcmis_oauth2data_getScope( libcmis_OAuth2DataPtr oauth2 ); +LIBCMIS_C_API const char* libcmis_oauth2data_getRedirectUri( libcmis_OAuth2DataPtr oauth2 ); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/inc/libcmis-c/object-type.h b/inc/libcmis-c/object-type.h new file mode 100644 index 0000000..0e0317c --- /dev/null +++ b/inc/libcmis-c/object-type.h @@ -0,0 +1,114 @@ +/* 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_OBJECT_TYPE_H_ +#define _LIBCMIS_OBJECT_TYPE_H_ + +#include "libcmis-c/libcmis-c-api.h" +#include "libcmis-c/types.h" + +#ifdef __cplusplus +extern "C" { +#endif + + +LIBCMIS_C_API void libcmis_vector_object_type_free( libcmis_vector_object_type_Ptr vector ); +LIBCMIS_C_API size_t libcmis_vector_object_type_size( libcmis_vector_object_type_Ptr vector ); +LIBCMIS_C_API libcmis_ObjectTypePtr libcmis_vector_object_type_get( libcmis_vector_object_type_Ptr vector, size_t i ); + + +LIBCMIS_C_API void libcmis_object_type_free( libcmis_ObjectTypePtr type ); + +/** The resulting value needs to be freed + */ +LIBCMIS_C_API char* libcmis_object_type_getId( libcmis_ObjectTypePtr type ); + +/** The resulting value needs to be freed + */ +LIBCMIS_C_API char* libcmis_object_type_getLocalName( libcmis_ObjectTypePtr type ); + +/** The resulting value needs to be freed + */ +LIBCMIS_C_API char* libcmis_object_type_getLocalNamespace( libcmis_ObjectTypePtr type ); + +/** The resulting value needs to be freed + */ +LIBCMIS_C_API char* libcmis_object_type_getQueryName( libcmis_ObjectTypePtr type ); + +/** The resulting value needs to be freed + */ +LIBCMIS_C_API char* libcmis_object_type_getDisplayName( libcmis_ObjectTypePtr type ); + +/** The resulting value needs to be freed + */ +LIBCMIS_C_API char* libcmis_object_type_getDescription( libcmis_ObjectTypePtr type ); + +LIBCMIS_C_API libcmis_ObjectTypePtr libcmis_object_type_getParentType( + libcmis_ObjectTypePtr type, + libcmis_ErrorPtr error ); +LIBCMIS_C_API libcmis_ObjectTypePtr libcmis_object_type_getBaseType( + libcmis_ObjectTypePtr type, + libcmis_ErrorPtr error ); + +LIBCMIS_C_API libcmis_vector_object_type_Ptr libcmis_object_type_getChildren( + libcmis_ObjectTypePtr type, + libcmis_ErrorPtr error ); + +/** The resulting value needs to be freed + \since libcmis 0.4 + */ +LIBCMIS_C_API char* libcmis_object_type_getParentTypeId( libcmis_ObjectTypePtr type ); + +/** The resulting value needs to be freed + \since libcmis 0.4 + */ +LIBCMIS_C_API char* libcmis_object_type_getBaseTypeId( libcmis_ObjectTypePtr type ); + +LIBCMIS_C_API bool libcmis_object_type_isCreatable( libcmis_ObjectTypePtr type ); +LIBCMIS_C_API bool libcmis_object_type_isFileable( libcmis_ObjectTypePtr type ); +LIBCMIS_C_API bool libcmis_object_type_isQueryable( libcmis_ObjectTypePtr type ); +LIBCMIS_C_API bool libcmis_object_type_isFulltextIndexed( libcmis_ObjectTypePtr type ); +LIBCMIS_C_API bool libcmis_object_type_isIncludedInSupertypeQuery( libcmis_ObjectTypePtr type ); +LIBCMIS_C_API bool libcmis_object_type_isControllablePolicy( libcmis_ObjectTypePtr type ); +LIBCMIS_C_API bool libcmis_object_type_isControllableACL( libcmis_ObjectTypePtr type ); +LIBCMIS_C_API bool libcmis_object_type_isVersionable( libcmis_ObjectTypePtr type ); + +LIBCMIS_C_API libcmis_object_type_ContentStreamAllowed libcmis_object_type_getContentStreamAllowed( libcmis_ObjectTypePtr type ); + +LIBCMIS_C_API libcmis_vector_property_type_Ptr libcmis_object_type_getPropertiesTypes( libcmis_ObjectTypePtr type ); +LIBCMIS_C_API libcmis_PropertyTypePtr libcmis_object_type_getPropertyType( libcmis_ObjectTypePtr type, const char* id ); + + +/** The resulting value needs to be freed + */ +LIBCMIS_C_API char* libcmis_object_type_toString( libcmis_ObjectTypePtr type ); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/inc/libcmis-c/object.h b/inc/libcmis-c/object.h new file mode 100644 index 0000000..8739cff --- /dev/null +++ b/inc/libcmis-c/object.h @@ -0,0 +1,134 @@ +/* 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_OBJECT_H_ +#define _LIBCMIS_OBJECT_H_ + +#include <time.h> + +#include "libcmis-c/libcmis-c-api.h" +#include "libcmis-c/types.h" + +#ifdef __cplusplus +extern "C" { +#endif + +LIBCMIS_C_API void libcmis_vector_object_free( libcmis_vector_object_Ptr vector ); +LIBCMIS_C_API size_t libcmis_vector_object_size( libcmis_vector_object_Ptr vector ); +LIBCMIS_C_API libcmis_ObjectPtr libcmis_vector_object_get( libcmis_vector_object_Ptr vector, size_t i ); + + +LIBCMIS_C_API void libcmis_object_free( libcmis_ObjectPtr object ); + +/** The resulting value needs to be free'd. + */ +LIBCMIS_C_API char* libcmis_object_getId( libcmis_ObjectPtr object ); + +/** The resulting value needs to be free'd. + */ +LIBCMIS_C_API char* libcmis_object_getName( libcmis_ObjectPtr object ); + +LIBCMIS_C_API libcmis_vector_string_Ptr libcmis_object_getPaths( libcmis_ObjectPtr object ); + + +/** The resulting value needs to be free'd. + */ +LIBCMIS_C_API char* libcmis_object_getBaseType( libcmis_ObjectPtr object ); + +/** The resulting value needs to be free'd. + */ +LIBCMIS_C_API char* libcmis_object_getType( libcmis_ObjectPtr object ); + + +/** The resulting value needs to be free'd. + */ +LIBCMIS_C_API char* libcmis_object_getCreatedBy( libcmis_ObjectPtr object ); +LIBCMIS_C_API time_t libcmis_object_getCreationDate( libcmis_ObjectPtr object ); + +/** The resulting value needs to be free'd. + */ +LIBCMIS_C_API char* libcmis_object_getLastModifiedBy( libcmis_ObjectPtr object ); +LIBCMIS_C_API time_t libcmis_object_getLastModificationDate( libcmis_ObjectPtr object ); + + +/** The resulting value needs to be free'd. + */ +LIBCMIS_C_API char* libcmis_object_getChangeToken( libcmis_ObjectPtr object ); +LIBCMIS_C_API bool libcmis_object_isImmutable( libcmis_ObjectPtr object ); + +/** The resulting value needs to be free'd. + */ +LIBCMIS_C_API libcmis_vector_string_Ptr libcmis_object_getSecondaryTypes( libcmis_ObjectPtr object ); + +/** The resulting value needs to be free'd. + */ +LIBCMIS_C_API char* libcmis_object_getThumbnailUrl( libcmis_ObjectPtr object ); + +LIBCMIS_C_API libcmis_vector_rendition_Ptr libcmis_object_getRenditions( libcmis_ObjectPtr object, libcmis_ErrorPtr error ); + +LIBCMIS_C_API libcmis_ObjectPtr +LIBCMIS_C_API libcmis_object_addSecondaryType( libcmis_ObjectPtr object, + const char* id, + libcmis_vector_property_Ptr properties, + libcmis_ErrorPtr error ); + +LIBCMIS_C_API libcmis_ObjectPtr +LIBCMIS_C_API libcmis_object_removeSecondaryType( libcmis_ObjectPtr object, + const char* id, + libcmis_ErrorPtr error ); + +LIBCMIS_C_API libcmis_vector_property_Ptr libcmis_object_getProperties( libcmis_ObjectPtr object ); +LIBCMIS_C_API libcmis_PropertyPtr libcmis_object_getProperty( libcmis_ObjectPtr object, const char* name ); +LIBCMIS_C_API void libcmis_object_setProperty( libcmis_ObjectPtr object, libcmis_PropertyPtr property ); +LIBCMIS_C_API libcmis_ObjectPtr libcmis_object_updateProperties( + libcmis_ObjectPtr object, + libcmis_vector_property_Ptr properties, + libcmis_ErrorPtr error ); + +LIBCMIS_C_API libcmis_ObjectTypePtr libcmis_object_getTypeDescription( libcmis_ObjectPtr object ); +LIBCMIS_C_API libcmis_AllowableActionsPtr libcmis_object_getAllowableActions( libcmis_ObjectPtr object ); + +LIBCMIS_C_API void libcmis_object_refresh( libcmis_ObjectPtr object, libcmis_ErrorPtr error ); +LIBCMIS_C_API time_t libcmis_object_getRefreshTimestamp( libcmis_ObjectPtr object ); + +LIBCMIS_C_API void libcmis_object_remove( libcmis_ObjectPtr object, bool allVersions, libcmis_ErrorPtr error ); + +LIBCMIS_C_API void libcmis_object_move( libcmis_ObjectPtr object, + libcmis_FolderPtr source, + libcmis_FolderPtr dest, + libcmis_ErrorPtr error ); + + +/** The resulting value needs to be free'd. + */ +LIBCMIS_C_API char* libcmis_object_toString( libcmis_ObjectPtr object ); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/inc/libcmis-c/property-type.h b/inc/libcmis-c/property-type.h new file mode 100644 index 0000000..f0faa90 --- /dev/null +++ b/inc/libcmis-c/property-type.h @@ -0,0 +1,86 @@ +/* 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_PROPERTY_TYPE_H_ +#define _LIBCMIS_PROPERTY_TYPE_H_ + +#include "libcmis-c/libcmis-c-api.h" +#include "libcmis-c/types.h" + +#ifdef __cplusplus +extern "C" { +#endif + + +LIBCMIS_C_API void libcmis_vector_property_type_free( libcmis_vector_property_type_Ptr vector ); +LIBCMIS_C_API size_t libcmis_vector_property_type_size( libcmis_vector_property_type_Ptr vector ); +LIBCMIS_C_API libcmis_PropertyTypePtr libcmis_vector_property_type_get( libcmis_vector_property_type_Ptr vector, size_t i ); + +LIBCMIS_C_API void libcmis_property_type_free( libcmis_PropertyTypePtr type ); + +/** The resulting value needs to be free'd. + */ +LIBCMIS_C_API char* libcmis_property_type_getId( libcmis_PropertyTypePtr type ); + +/** The resulting value needs to be free'd. + */ +LIBCMIS_C_API char* libcmis_property_type_getLocalName( libcmis_PropertyTypePtr type ); + +/** The resulting value needs to be free'd. + */ +LIBCMIS_C_API char* libcmis_property_type_getLocalNamespace( libcmis_PropertyTypePtr type ); + +/** The resulting value needs to be free'd. + */ +LIBCMIS_C_API char* libcmis_property_type_getDisplayName( libcmis_PropertyTypePtr type ); + +/** The resulting value needs to be free'd. + */ +LIBCMIS_C_API char* libcmis_property_type_getQueryName( libcmis_PropertyTypePtr type ); + +LIBCMIS_C_API libcmis_property_type_Type libcmis_property_type_getType( libcmis_PropertyTypePtr type ); + +/** The resulting value needs to be free'd. + */ +LIBCMIS_C_API char* libcmis_property_type_getXmlType( libcmis_PropertyTypePtr type ); + +LIBCMIS_C_API bool libcmis_property_type_isMultiValued( libcmis_PropertyTypePtr type ); +LIBCMIS_C_API bool libcmis_property_type_isUpdatable( libcmis_PropertyTypePtr type ); +LIBCMIS_C_API bool libcmis_property_type_isInherited( libcmis_PropertyTypePtr type ); +LIBCMIS_C_API bool libcmis_property_type_isRequired( libcmis_PropertyTypePtr type ); +LIBCMIS_C_API bool libcmis_property_type_isQueryable( libcmis_PropertyTypePtr type ); +LIBCMIS_C_API bool libcmis_property_type_isOrderable( libcmis_PropertyTypePtr type ); +LIBCMIS_C_API bool libcmis_property_type_isOpenChoice( libcmis_PropertyTypePtr type ); + +LIBCMIS_C_API void libcmis_property_type_update( libcmis_PropertyTypePtr propDef, + libcmis_vector_object_type_Ptr types ); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/inc/libcmis-c/property.h b/inc/libcmis-c/property.h new file mode 100644 index 0000000..7d06418 --- /dev/null +++ b/inc/libcmis-c/property.h @@ -0,0 +1,66 @@ +/* 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_PROPERTY_HXX_ +#define _LIBCMIS_PROPERTY_HXX_ + +#include "libcmis-c/libcmis-c-api.h" +#include "libcmis-c/types.h" + +#ifdef __cplusplus +extern "C" { +#endif + +LIBCMIS_C_API libcmis_vector_property_Ptr libcmis_vector_property_create( ); +LIBCMIS_C_API void libcmis_vector_property_free( libcmis_vector_property_Ptr vector ); +LIBCMIS_C_API size_t libcmis_vector_property_size( libcmis_vector_property_Ptr vector ); +LIBCMIS_C_API libcmis_PropertyPtr libcmis_vector_property_get( libcmis_vector_property_Ptr vector, size_t i ); + +/** The item object can be deleted after this call safely. + */ +LIBCMIS_C_API void libcmis_vector_property_append( libcmis_vector_property_Ptr vector, libcmis_PropertyPtr item ); + + +LIBCMIS_C_API libcmis_PropertyPtr libcmis_property_create( libcmis_PropertyTypePtr type, const char** strValues, size_t size ); +LIBCMIS_C_API void libcmis_property_free( libcmis_PropertyPtr property ); + +LIBCMIS_C_API libcmis_PropertyTypePtr libcmis_property_getPropertyType( libcmis_PropertyPtr property ); + +LIBCMIS_C_API libcmis_vector_time_Ptr libcmis_property_getDateTimes( libcmis_PropertyPtr property ); +LIBCMIS_C_API libcmis_vector_bool_Ptr libcmis_property_getBools( libcmis_PropertyPtr property ); +LIBCMIS_C_API libcmis_vector_string_Ptr libcmis_property_getStrings( libcmis_PropertyPtr property ); +LIBCMIS_C_API libcmis_vector_long_Ptr libcmis_property_getLongs( libcmis_PropertyPtr property ); +LIBCMIS_C_API libcmis_vector_double_Ptr libcmis_property_getDoubles( libcmis_PropertyPtr property ); + +LIBCMIS_C_API void libcmis_property_setValues( libcmis_PropertyPtr property, const char** strValues, size_t size ); + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/inc/libcmis-c/rendition.h b/inc/libcmis-c/rendition.h new file mode 100644 index 0000000..927fd28 --- /dev/null +++ b/inc/libcmis-c/rendition.h @@ -0,0 +1,59 @@ +/* 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. + */ + +#ifndef _LIBCMIS_RENDITION_H_ +#define _LIBCMIS_RENDITION_H_ + +#include "libcmis-c/libcmis-c-api.h" +#include "libcmis-c/types.h" + +#ifdef __cplusplus +extern "C" { +#endif + +LIBCMIS_C_API void libcmis_rendition_free( libcmis_RenditionPtr rendition ); + +LIBCMIS_C_API bool libcmis_rendition_isThumbnail( libcmis_RenditionPtr rendition ); + +LIBCMIS_C_API const char* libcmis_rendition_getStreamId( libcmis_RenditionPtr rendition ); +LIBCMIS_C_API const char* libcmis_rendition_getMimeType( libcmis_RenditionPtr rendition ); +LIBCMIS_C_API const char* libcmis_rendition_getKind( libcmis_RenditionPtr rendition ); +LIBCMIS_C_API const char* libcmis_rendition_getUrl( libcmis_RenditionPtr rendition ); +LIBCMIS_C_API const char* libcmis_rendition_getTitle( libcmis_RenditionPtr rendition ); +LIBCMIS_C_API long libcmis_rendition_getLength( libcmis_RenditionPtr rendition ); +LIBCMIS_C_API long libcmis_rendition_getWidth( libcmis_RenditionPtr rendition ); +LIBCMIS_C_API long libcmis_rendition_getHeight( libcmis_RenditionPtr rendition ); +LIBCMIS_C_API const char* libcmis_rendition_getRenditionDocumentId( libcmis_RenditionPtr rendition ); + +#ifdef __cplusplus +} +#endif + +#endif + + diff --git a/inc/libcmis-c/repository.h b/inc/libcmis-c/repository.h new file mode 100644 index 0000000..651a881 --- /dev/null +++ b/inc/libcmis-c/repository.h @@ -0,0 +1,107 @@ +/* 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 _REPOSITORY_H_ +#define _REPOSITORY_H_ + +#include <libxml/tree.h> + +#include "libcmis-c/libcmis-c-api.h" +#include "libcmis-c/types.h" + +#ifdef __cplusplus +extern "C" { +#endif + +LIBCMIS_C_API void libcmis_vector_repository_free( libcmis_vector_Repository_Ptr vector ); +LIBCMIS_C_API size_t libcmis_vector_repository_size( libcmis_vector_Repository_Ptr vector ); +LIBCMIS_C_API libcmis_RepositoryPtr libcmis_vector_repository_get( libcmis_vector_Repository_Ptr vector, size_t i ); + + +LIBCMIS_C_API libcmis_RepositoryPtr libcmis_repository_create( xmlNodePtr node ); + +LIBCMIS_C_API void libcmis_repository_free( libcmis_RepositoryPtr repository ); + +/** The resulting value needs to be freed. + */ +LIBCMIS_C_API char* libcmis_repository_getId( libcmis_RepositoryPtr repository ); + +/** The resulting value needs to be freed. + */ +LIBCMIS_C_API char* libcmis_repository_getName( libcmis_RepositoryPtr repository ); + +/** The resulting value needs to be freed. + */ +LIBCMIS_C_API char* libcmis_repository_getDescription( libcmis_RepositoryPtr repository ); + +/** The resulting value needs to be freed. + */ +LIBCMIS_C_API char* libcmis_repository_getVendorName( libcmis_RepositoryPtr repository ); + +/** The resulting value needs to be freed. + */ +LIBCMIS_C_API char* libcmis_repository_getProductName( libcmis_RepositoryPtr repository ); + +/** The resulting value needs to be freed. + */ +LIBCMIS_C_API char* libcmis_repository_getProductVersion( libcmis_RepositoryPtr repository ); + +/** The resulting value needs to be freed. + */ +LIBCMIS_C_API char* libcmis_repository_getRootId( libcmis_RepositoryPtr repository ); + +/** The resulting value needs to be freed. + */ +LIBCMIS_C_API char* libcmis_repository_getCmisVersionSupported( libcmis_RepositoryPtr repository ); + +/** The resulting value needs to be freed. + */ +LIBCMIS_C_API char* libcmis_repository_getThinClientUri( libcmis_RepositoryPtr repository ); + +/** The resulting value needs to be freed. + */ +LIBCMIS_C_API char* libcmis_repository_getPrincipalAnonymous( libcmis_RepositoryPtr repository ); + +/** The resulting value needs to be freed. + */ +LIBCMIS_C_API char* libcmis_repository_getPrincipalAnyone( libcmis_RepositoryPtr repository ); + +/** The resulting value needs to be freed. + */ +LIBCMIS_C_API char* libcmis_repository_getCapability( + libcmis_RepositoryPtr repository, + libcmis_repository_capability_Type capability ); + +LIBCMIS_C_API bool libcmis_repository_getCapabilityAsBool( + libcmis_RepositoryPtr repository, + libcmis_repository_capability_Type capability ); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/inc/libcmis-c/session-factory.h b/inc/libcmis-c/session-factory.h new file mode 100644 index 0000000..f10ddd2 --- /dev/null +++ b/inc/libcmis-c/session-factory.h @@ -0,0 +1,79 @@ +/* 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 _SESSION_FACTORY_H_ +#define _SESSION_FACTORY_H_ + +#include "libcmis-c/libcmis-c-api.h" +#include "libcmis-c/types.h" + +#ifdef __cplusplus +extern "C" { +#endif + +LIBCMIS_C_API void libcmis_setAuthenticationCallback( libcmis_authenticationCallback callback ); +LIBCMIS_C_API void libcmis_setCertValidationCallback( libcmis_certValidationCallback callback ); +LIBCMIS_C_API void libcmis_setOAuth2AuthCodeProvider( libcmis_oauth2AuthCodeProvider callback ); +LIBCMIS_C_API libcmis_oauth2AuthCodeProvider libcmis_getOAuth2AuthCodeProvider( ); + +LIBCMIS_C_API void libcmis_setProxySettings( + char* proxy, + char* noProxy, + char* proxyUser, + char* proxyPass ); + +LIBCMIS_C_API const char* libcmis_getProxy( ); +LIBCMIS_C_API const char* libcmis_getNoProxy( ); +LIBCMIS_C_API const char* libcmis_getProxyUser( ); +LIBCMIS_C_API const char* libcmis_getProxyPass( ); + +LIBCMIS_C_API libcmis_SessionPtr libcmis_createSession( + char* bindingUrl, + char* repositoryId, + char* username, + char* password, + bool noSslCheck, + libcmis_OAuth2DataPtr oauth2, + bool verbose, + libcmis_ErrorPtr error ); + +/** + \deprecated + use libcmis_createSession and libcmis_session_getRepositories instead + */ +LIBCMIS_C_API libcmis_vector_Repository_Ptr libcmis_getRepositories( + char* bindingUrl, + char* username, + char* password, + bool verbose, + libcmis_ErrorPtr error ); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/inc/libcmis-c/session.h b/inc/libcmis-c/session.h new file mode 100644 index 0000000..77c0d90 --- /dev/null +++ b/inc/libcmis-c/session.h @@ -0,0 +1,83 @@ +/* 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_SESSION_H_ +#define _LIBCMIS_SESSION_H_ + +#include "libcmis-c/libcmis-c-api.h" +#include "libcmis-c/types.h" + +#ifdef __cplusplus +extern "C" { +#endif + +LIBCMIS_C_API void libcmis_session_free( libcmis_SessionPtr session ); + +LIBCMIS_C_API libcmis_RepositoryPtr libcmis_session_getRepository( + libcmis_SessionPtr session, + libcmis_ErrorPtr error ); + +LIBCMIS_C_API libcmis_vector_Repository_Ptr libcmis_session_getRepositories( + libcmis_SessionPtr session ); + +LIBCMIS_C_API bool libcmis_session_setRepository( + libcmis_SessionPtr session, + const char* repositoryId ); + +LIBCMIS_C_API libcmis_FolderPtr libcmis_session_getRootFolder( + libcmis_SessionPtr session, + libcmis_ErrorPtr error ); + +LIBCMIS_C_API libcmis_ObjectPtr libcmis_session_getObject( + libcmis_SessionPtr session, + const char* id, + libcmis_ErrorPtr error ); + +LIBCMIS_C_API libcmis_ObjectPtr libcmis_session_getObjectByPath( + libcmis_SessionPtr session, + const char* path, + libcmis_ErrorPtr error ); + +LIBCMIS_C_API libcmis_FolderPtr libcmis_session_getFolder( + libcmis_SessionPtr session, + const char* id, + libcmis_ErrorPtr error ); + +LIBCMIS_C_API libcmis_ObjectTypePtr libcmis_session_getType( + libcmis_SessionPtr session, + const char* id, + libcmis_ErrorPtr error ); + +LIBCMIS_C_API libcmis_vector_object_type_Ptr libcmis_session_getBaseTypes( + libcmis_SessionPtr session, + libcmis_ErrorPtr error ); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/inc/libcmis-c/types.h b/inc/libcmis-c/types.h new file mode 100644 index 0000000..c3e784c --- /dev/null +++ b/inc/libcmis-c/types.h @@ -0,0 +1,228 @@ +/* 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_TYPES_H_ +#define _LIBCMIS_TYPES_H_ + +#ifndef __cplusplus +#include <stdbool.h> +#endif +#include <stddef.h> + +#ifdef __cplusplus +extern "C" { +#endif + + +/* Vectors of simple types */ + + +typedef struct libcmis_vector_bool* libcmis_vector_bool_Ptr; + +typedef struct libcmis_vector_string* libcmis_vector_string_Ptr; + +typedef struct libcmis_vector_long* libcmis_vector_long_Ptr; + +typedef struct libcmis_vector_double* libcmis_vector_double_Ptr; + +typedef struct libcmis_vector_time* libcmis_vector_time_Ptr; + +typedef struct libcmis_vector_repository* libcmis_vector_Repository_Ptr; + + +/* AllowableActions */ + + +typedef struct libcmis_allowable_actions* libcmis_AllowableActionsPtr; + +typedef enum +{ + libcmis_DeleteObject, + libcmis_UpdateProperties, + libcmis_GetFolderTree, + libcmis_GetProperties, + libcmis_GetObjectRelationships, + libcmis_GetObjectParents, + libcmis_GetFolderParent, + libcmis_GetDescendants, + libcmis_MoveObject, + libcmis_DeleteContentStream, + libcmis_CheckOut, + libcmis_CancelCheckOut, + libcmis_CheckIn, + libcmis_SetContentStream, + libcmis_GetAllVersions, + libcmis_AddObjectToFolder, + libcmis_RemoveObjectFromFolder, + libcmis_GetContentStream, + libcmis_ApplyPolicy, + libcmis_GetAppliedPolicies, + libcmis_RemovePolicy, + libcmis_GetChildren, + libcmis_CreateDocument, + libcmis_CreateFolder, + libcmis_CreateRelationship, + libcmis_DeleteTree, + libcmis_GetRenditions, + libcmis_GetACL, + libcmis_ApplyACL +} libcmis_allowable_actions_Type; + + +/* Document */ + + +typedef struct libcmis_document* libcmis_DocumentPtr; +typedef size_t ( *libcmis_writeFn )( const void*, size_t, size_t, void* ); +typedef size_t ( *libcmis_readFn )( void*, size_t, size_t, void* ); + +typedef struct libcmis_vector_document* libcmis_vector_document_Ptr; + +/* Error */ + + +typedef struct libcmis_error* libcmis_ErrorPtr; + + +/* Folder */ + + +typedef struct libcmis_folder* libcmis_FolderPtr; + + +typedef struct libcmis_vector_folder* libcmis_vector_folder_Ptr; + +typedef enum +{ + libcmis_Unfile, + libcmis_DeleteSingleFiled, + libcmis_Delete +} libcmis_folder_UnfileObjects; + + +/* ObjectType */ + + +typedef struct libcmis_object_type* libcmis_ObjectTypePtr; + +typedef struct libcmis_vector_object_type* libcmis_vector_object_type_Ptr; + +typedef enum +{ + libcmis_NotAllowed, + libcmis_Allowed, + libcmis_Required +} libcmis_object_type_ContentStreamAllowed; + + +/* Object */ + + +typedef struct libcmis_object* libcmis_ObjectPtr; + +typedef struct libcmis_vector_object* libcmis_vector_object_Ptr; + + +/* Property */ + + +typedef struct libcmis_property* libcmis_PropertyPtr; + +typedef struct libcmis_vector_property* libcmis_vector_property_Ptr; + + +/* PropertyType */ + + +typedef struct libcmis_property_type* libcmis_PropertyTypePtr; + +typedef struct libcmis_vector_property_type* libcmis_vector_property_type_Ptr; + +typedef enum +{ + libcmis_String, + libcmis_Integer, + libcmis_Decimal, + libcmis_Bool, + libcmis_DateTime +} libcmis_property_type_Type; + + +/* Repository */ + +typedef enum +{ + libcmis_capability_ACL, + libcmis_capability_AllVersionsSearchable, + libcmis_capability_Changes, + libcmis_capability_ContentStreamUpdatability, + libcmis_capability_GetDescendants, + libcmis_capability_GetFolderTree, + libcmis_capability_OrderBy, + libcmis_capability_Multifiling, + libcmis_capability_PWCSearchable, + libcmis_capability_PWCUpdatable, + libcmis_capability_Query, + libcmis_capability_Renditions, + libcmis_capability_Unfiling, + libcmis_capability_VersionSpecificFiling, + libcmis_capability_Join +} libcmis_repository_capability_Type; + +typedef struct libcmis_repository* libcmis_RepositoryPtr; + + +/* Session */ + + +typedef struct libcmis_session* libcmis_SessionPtr; + +typedef bool ( *libcmis_authenticationCallback )( char* username, char* password ); +typedef bool ( *libcmis_certValidationCallback )( libcmis_vector_string_Ptr certificatesChain ); +typedef char * ( *libcmis_oauth2AuthCodeProvider ) ( const char* authUrl, const char* username, const char* password ); + + +/* OAuth2Data */ + + +typedef struct libcmis_oauth2data* libcmis_OAuth2DataPtr; + +typedef char* ( *libcmis_OAuth2AuthCodeProvider )( const char* authUrl, + const char* username, const char* password ); + + +/* Rendition */ + + +typedef struct libcmis_rendition* libcmis_RenditionPtr; +typedef struct libcmis_vector_rendition* libcmis_vector_rendition_Ptr; + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/inc/libcmis-c/vectors.h b/inc/libcmis-c/vectors.h new file mode 100644 index 0000000..2c791c7 --- /dev/null +++ b/inc/libcmis-c/vectors.h @@ -0,0 +1,68 @@ +/* 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_VECTORS_HXX_ +#define _LIBCMIS_VECTORS_HXX_ + +#include <time.h> + +#include "libcmis-c/libcmis-c-api.h" +#include "libcmis-c/types.h" + +#ifdef __cplusplus +extern "C" { +#endif + +LIBCMIS_C_API void libcmis_vector_bool_free( libcmis_vector_bool_Ptr vector ); +LIBCMIS_C_API size_t libcmis_vector_bool_size( libcmis_vector_bool_Ptr vector ); +LIBCMIS_C_API bool libcmis_vector_bool_get( libcmis_vector_bool_Ptr vector, size_t i ); + + +LIBCMIS_C_API void libcmis_vector_string_free( libcmis_vector_string_Ptr vector ); +LIBCMIS_C_API size_t libcmis_vector_string_size( libcmis_vector_string_Ptr vector ); +LIBCMIS_C_API const char* libcmis_vector_string_get( libcmis_vector_string_Ptr vector, size_t i ); + + +LIBCMIS_C_API void libcmis_vector_long_free( libcmis_vector_long_Ptr vector ); +LIBCMIS_C_API size_t libcmis_vector_long_size( libcmis_vector_long_Ptr vector ); +LIBCMIS_C_API long libcmis_vector_long_get( libcmis_vector_long_Ptr vector, size_t i ); + + +LIBCMIS_C_API void libcmis_vector_double_free( libcmis_vector_double_Ptr vector ); +LIBCMIS_C_API size_t libcmis_vector_double_size( libcmis_vector_double_Ptr vector ); +LIBCMIS_C_API double libcmis_vector_double_get( libcmis_vector_double_Ptr vector, size_t i ); + + +LIBCMIS_C_API void libcmis_vector_time_free( libcmis_vector_time_Ptr vector ); +LIBCMIS_C_API size_t libcmis_vector_time_size( libcmis_vector_time_Ptr vector ); +LIBCMIS_C_API time_t libcmis_vector_time_get( libcmis_vector_time_Ptr vector, size_t i ); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/inc/libcmis/Makefile.am b/inc/libcmis/Makefile.am new file mode 100644 index 0000000..93b139b --- /dev/null +++ b/inc/libcmis/Makefile.am @@ -0,0 +1,20 @@ +libcmisdir = $(includedir)/libcmis-@LIBCMIS_API_VERSION@/libcmis + +dist_libcmis_HEADERS = \ + allowable-actions.hxx \ + document.hxx \ + exception.hxx \ + folder.hxx \ + libcmis-api.h \ + libcmis.hxx \ + oauth2-data.hxx \ + object-type.hxx \ + object.hxx \ + property-type.hxx \ + property.hxx \ + rendition.hxx \ + repository.hxx \ + session-factory.hxx \ + session.hxx \ + xml-utils.hxx \ + xmlserializable.hxx diff --git a/inc/libcmis/allowable-actions.hxx b/inc/libcmis/allowable-actions.hxx new file mode 100644 index 0000000..50e9402 --- /dev/null +++ b/inc/libcmis/allowable-actions.hxx @@ -0,0 +1,131 @@ +/* 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 _ALLOWABLE_ACTIONS_HXX_ +#define _ALLOWABLE_ACTIONS_HXX_ + +#include <map> +#include <string> + +#include <boost/shared_ptr.hpp> +#include <libxml/tree.h> + +#include "libcmis/exception.hxx" +#include "libcmis/libcmis-api.h" + +namespace libcmis +{ + class Object; + + class LIBCMIS_API ObjectAction + { + public: + enum Type + { + DeleteObject, + UpdateProperties, + GetFolderTree, + GetProperties, + GetObjectRelationships, + GetObjectParents, + GetFolderParent, + GetDescendants, + MoveObject, + DeleteContentStream, + CheckOut, + CancelCheckOut, + CheckIn, + SetContentStream, + GetAllVersions, + AddObjectToFolder, + RemoveObjectFromFolder, + GetContentStream, + ApplyPolicy, + GetAppliedPolicies, + RemovePolicy, + GetChildren, + CreateDocument, + CreateFolder, + CreateRelationship, + DeleteTree, + GetRenditions, + GetACL, + ApplyACL + }; + + private: + Type m_type; + bool m_enabled; + bool m_valid; + + public: + ObjectAction( xmlNodePtr node ); + virtual ~ObjectAction( ){ } + + Type getType( ) { return m_type; } + bool isEnabled( ) { return m_enabled; } + bool isValid( ) { return m_valid; } + + /** Parses the permission name into one of the enum values or throws + an exception for invalid input strings. + */ + static Type parseType( std::string type ); + + }; + + /** Class providing access to the allowed actions on an object. + */ + class LIBCMIS_API AllowableActions + { + protected: + std::map< ObjectAction::Type, bool > m_states; + + public: + /** Default constructor for testing purpose + */ + AllowableActions( ); + AllowableActions( xmlNodePtr node ); + AllowableActions( const AllowableActions& copy ); + virtual ~AllowableActions( ); + + AllowableActions& operator=( const AllowableActions& copy ); + + /** Returns the permissions for the corresponding actions. + */ + bool isAllowed( ObjectAction::Type action ); + + /** Returns true if the action was defined, false if the default + value is used. + */ + bool isDefined( ObjectAction::Type action ); + + std::string toString( ); + }; + typedef boost::shared_ptr< AllowableActions > AllowableActionsPtr; +} + +#endif diff --git a/inc/libcmis/document.hxx b/inc/libcmis/document.hxx new file mode 100644 index 0000000..8f44313 --- /dev/null +++ b/inc/libcmis/document.hxx @@ -0,0 +1,147 @@ +/* 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 _DOCUMENT_HXX_ +#define _DOCUMENT_HXX_ + +#include <iostream> +#include <string> +#include <vector> + +#include <boost/shared_ptr.hpp> + +#include "libcmis/exception.hxx" +#include "libcmis/libcmis-api.h" +#include "libcmis/object.hxx" + +namespace libcmis +{ + class Folder; + class Session; + + /** Interface for a CMIS Document object. + */ + class LIBCMIS_API Document : public virtual Object + { + public: + Document( Session* session ) : Object( session ) { } + virtual ~Document( ) { } + + /** Get the folder parents for the document. + + Note that an unfiled document will have no parent folder. + + @return the parents folder if any. + */ + virtual std::vector< boost::shared_ptr< Folder > > getParents( ) = 0; + + /** Get the content stream without using a temporary file. + + <p>The stream may not contain anything if there is + no content or if something wrong happened during the + download.</p> + + @param streamId of the rendition + @return + An input stream to read the data from. + + @throws Exception + if anything wrong happened during the file transfer. + In such a case, the content of the stream can't be + guaranteed. + */ + virtual boost::shared_ptr< std::istream > getContentStream( std::string streamId = std::string( ) ) + = 0; + + /** Set or replace the content stream of the document. + + @param is the output stream containing the new data for the content stream + @param contentType the mime-type of the new content stream + @param filename the filename to set for the file + @param overwrite if set to false, don't overwrite the content stream if one is already set. + + @throw Exception if anything happens during the upload like a wrong authentication, + no rights to set the stream, server doesn't have the ContentStreamUpdatability + capability. + */ + virtual void setContentStream( boost::shared_ptr< std::ostream > os, std::string contentType, + std::string filename, bool overwrite = true ) = 0; + + /** Get the content mime type. + */ + virtual std::string getContentType( ); + + /** Get the content stream filename. + */ + virtual std::string getContentFilename( ); + + /** Get the content length in bytes. + */ + virtual long getContentLength( ); + + /** Checks out the document and returns the object corresponding to the + created Private Working Copy. + + \return the Private Working Copy document + */ + virtual boost::shared_ptr< Document > checkOut( ) = 0; + + /** Cancels the checkout if the document is a private working copy, or + throws an exception. + */ + virtual void cancelCheckout( ) = 0; + + /** Check in the private working copy and create a new version or throw + an exception. + + The current object will be updated to reflect the changes performed + on the server side. + + \param isMajor defines it the version to create is a major or minor one + \param comment contains the checkin comment + \param properties the properties to set the new version + \param stream the content stream to set for the new version + \param contentType the mime type of the stream to set + + \return the document with the new version + */ + virtual boost::shared_ptr< Document > checkIn( bool isMajor, std::string comment, + const std::map< std::string, PropertyPtr >& properties, + boost::shared_ptr< std::ostream > stream, + std::string contentType, std::string fileName ) = 0; + + virtual std::vector< boost::shared_ptr< Document > > getAllVersions( ) = 0; + + // virtual methods form Object + virtual std::vector< std::string > getPaths( ); + + virtual std::string toString( ); + }; + typedef boost::shared_ptr< Document > DocumentPtr; +} + +#endif diff --git a/inc/libcmis/exception.hxx b/inc/libcmis/exception.hxx new file mode 100644 index 0000000..aa42ae7 --- /dev/null +++ b/inc/libcmis/exception.hxx @@ -0,0 +1,62 @@ +/* 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 _EXCEPTION_HXX_ +#define _EXCEPTION_HXX_ + +#include <exception> +#include <string> + +#include "libcmis/libcmis-api.h" + +namespace libcmis +{ + class LIBCMIS_API Exception : public std::exception + { + private: + std::string m_message; + std::string m_type; + + public: + Exception( std::string message, std::string type = "runtime" ) : + exception( ), + m_message( message ), + m_type( type ) + { + } + + ~Exception( ) noexcept { } + virtual const char* what() const noexcept + { + return m_message.c_str( ); + } + + std::string getType( ) const { return m_type; } + }; +} + +#endif diff --git a/inc/libcmis/folder.hxx b/inc/libcmis/folder.hxx new file mode 100644 index 0000000..0010dbd --- /dev/null +++ b/inc/libcmis/folder.hxx @@ -0,0 +1,84 @@ +/* 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 _FOLDER_HXX_ +#define _FOLDER_HXX_ + +#include <map> +#include <string> +#include <vector> + +#include "libcmis/exception.hxx" +#include "libcmis/libcmis-api.h" +#include "libcmis/object.hxx" + +namespace libcmis +{ + class Document; + class Session; + + struct LIBCMIS_API UnfileObjects { + enum Type + { + Unfile, + DeleteSingleFiled, + Delete + }; + }; + + /** Class representing a CMIS folder. + */ + class LIBCMIS_API Folder : public virtual Object + { + public: + Folder( Session* session ) : Object( session ) { } + virtual ~Folder() { } + + virtual std::vector< std::string > getPaths( ); + + virtual boost::shared_ptr< Folder > getFolderParent( ); + virtual std::vector< ObjectPtr > getChildren( ) = 0; + virtual std::string getParentId( ); + virtual std::string getPath( ); + + virtual bool isRootFolder( ); + + virtual boost::shared_ptr< Folder > createFolder( const std::map< std::string, PropertyPtr >& properties ) + = 0; + virtual boost::shared_ptr< Document > createDocument( const std::map< std::string, PropertyPtr >& properties, + boost::shared_ptr< std::ostream > os, std::string contentType, std::string fileName ) = 0; + + virtual std::vector< std::string > removeTree( bool allVersion = true, UnfileObjects::Type unfile = UnfileObjects::Delete, + bool continueOnError = false ) = 0; + + virtual std::string toString( ); + }; + typedef boost::shared_ptr< Folder > FolderPtr; + +} + +#endif diff --git a/inc/libcmis/libcmis-api.h b/inc/libcmis/libcmis-api.h new file mode 100644 index 0000000..983ff4f --- /dev/null +++ b/inc/libcmis/libcmis-api.h @@ -0,0 +1,45 @@ +/* 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_API_H_ +#define _LIBCMIS_API_H_ + +#ifdef DLL_EXPORT +#ifdef LIBCMIS_BUILD +#define LIBCMIS_API __declspec(dllexport) +#else +#define LIBCMIS_API __declspec(dllimport) +#endif +#else // !DLL_EXPORT +#ifdef LIBCMIS_VISIBILITY +#define LIBCMIS_API __attribute__((visibility("default"))) +#else +#define LIBCMIS_API +#endif +#endif + +#endif diff --git a/inc/libcmis/libcmis.hxx b/inc/libcmis/libcmis.hxx new file mode 100644 index 0000000..411850d --- /dev/null +++ b/inc/libcmis/libcmis.hxx @@ -0,0 +1,49 @@ +/* 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_HXX_ +#define _LIBCMIS_HXX_ + +#include "libcmis/libcmis-api.h" + +#include "libcmis/allowable-actions.hxx" +#include "libcmis/document.hxx" +#include "libcmis/exception.hxx" +#include "libcmis/folder.hxx" +#include "libcmis/oauth2-data.hxx" +#include "libcmis/object-type.hxx" +#include "libcmis/object.hxx" +#include "libcmis/property-type.hxx" +#include "libcmis/property.hxx" +#include "libcmis/rendition.hxx" +#include "libcmis/repository.hxx" +#include "libcmis/session-factory.hxx" +#include "libcmis/session.hxx" +#include "libcmis/xml-utils.hxx" +#include "libcmis/xmlserializable.hxx" + +#endif diff --git a/inc/libcmis/oauth2-data.hxx b/inc/libcmis/oauth2-data.hxx new file mode 100644 index 0000000..5321652 --- /dev/null +++ b/inc/libcmis/oauth2-data.hxx @@ -0,0 +1,78 @@ +/* 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_OAUTH2_DATA_HXX_ +#define _LIBCMIS_OAUTH2_DATA_HXX_ + +#include <string> +#include <boost/shared_ptr.hpp> + +#include "libcmis/libcmis-api.h" + +namespace libcmis +{ + /** Class storing the data needed for OAuth2 authentication. + */ + class LIBCMIS_API OAuth2Data + { + private: + + std::string m_authUrl; + std::string m_tokenUrl; + std::string m_clientId; + std::string m_clientSecret; + std::string m_scope; + std::string m_redirectUri; + public: + + OAuth2Data( ); + OAuth2Data( const std::string& authUrl, + const std::string& tokenUrl, + const std::string& scope, + const std::string& redirectUri, + const std::string& clientId, + const std::string& clientSecret ); + + OAuth2Data( const OAuth2Data& copy ); + ~OAuth2Data( ); + + OAuth2Data& operator=( const OAuth2Data& copy ); + + bool isComplete(); + + const std::string& getAuthUrl() { return m_authUrl; } + const std::string& getTokenUrl() { return m_tokenUrl; } + const std::string& getClientId() { return m_clientId; } + const std::string& getClientSecret() { return m_clientSecret; } + const std::string& getScope() { return m_scope; } + const std::string& getRedirectUri() { return m_redirectUri; } + }; + typedef boost::shared_ptr< OAuth2Data > OAuth2DataPtr; +} + +#endif //_LIBCMIS_OAUTH2_DATA_HXX_ + diff --git a/inc/libcmis/object-type.hxx b/inc/libcmis/object-type.hxx new file mode 100644 index 0000000..7fbf3e9 --- /dev/null +++ b/inc/libcmis/object-type.hxx @@ -0,0 +1,144 @@ +/* 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 _OBJECT_TYPE_HXX_ +#define _OBJECT_TYPE_HXX_ + +#include <boost/shared_ptr.hpp> +#include <libxml/tree.h> + +#include <string> +#include <vector> + +#include "libcmis/exception.hxx" +#include "libcmis/libcmis-api.h" +#include "libcmis/property-type.hxx" + +namespace libcmis +{ + /** Class representing a CMIS object type definition. + */ + class LIBCMIS_API ObjectType + { + public: + + enum ContentStreamAllowed + { + NotAllowed, + Allowed, + Required + }; + + protected: + time_t m_refreshTimestamp; + + std::string m_id; + std::string m_localName; + std::string m_localNamespace; + std::string m_displayName; + std::string m_queryName; + std::string m_description; + + std::string m_parentTypeId; + std::string m_baseTypeId; + + bool m_creatable; + bool m_fileable; + bool m_queryable; + bool m_fulltextIndexed; + bool m_includedInSupertypeQuery; + bool m_controllablePolicy; + bool m_controllableAcl; + bool m_versionable; + libcmis::ObjectType::ContentStreamAllowed m_contentStreamAllowed; + + std::map< std::string, libcmis::PropertyTypePtr > m_propertiesTypes; + + ObjectType( ); + void initializeFromNode( xmlNodePtr node ); + + public: + + ObjectType( xmlNodePtr node ); + ObjectType( const ObjectType& copy ); + virtual ~ObjectType() { } + + ObjectType& operator=( const ObjectType& copy ); + + /** Reload the data from the server. + + \attention + This method needs to be implemented in subclasses or it will + do nothing + */ + virtual void refresh( ); + virtual time_t getRefreshTimestamp( ) const; + + std::string getId( ) const; + std::string getLocalName( ) const; + std::string getLocalNamespace( ) const; + std::string getDisplayName( ) const; + std::string getQueryName( ) const; + std::string getDescription( ) const; + + virtual boost::shared_ptr< ObjectType > getParentType( ); + virtual boost::shared_ptr< ObjectType > getBaseType( ); + virtual std::vector< boost::shared_ptr< ObjectType > > getChildren( ); + + /** Get the parent type id without extracting the complete parent type from + the repository. This is mainly provided for performance reasons. + + \since libcmis 0.4 + */ + std::string getParentTypeId( ) const; + + /** Get the base type id without extracting the complete base type from + the repository. This is mainly provided for performance reasons. + + \since libcmis 0.4 + */ + std::string getBaseTypeId( ) const; + + bool isCreatable( ) const; + bool isFileable( ) const; + bool isQueryable( ) const; + bool isFulltextIndexed( ) const; + bool isIncludedInSupertypeQuery( ) const; + bool isControllablePolicy( ) const; + bool isControllableACL( ) const; + bool isVersionable( ) const; + ContentStreamAllowed getContentStreamAllowed( ) const; + + std::map< std::string, PropertyTypePtr >& getPropertiesTypes( ); + + virtual std::string toString( ); + }; + + typedef boost::shared_ptr< ObjectType > ObjectTypePtr; +} + +#endif diff --git a/inc/libcmis/object.hxx b/inc/libcmis/object.hxx new file mode 100644 index 0000000..5e5b3b5 --- /dev/null +++ b/inc/libcmis/object.hxx @@ -0,0 +1,218 @@ +/* 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 _OBJECT_HXX_ +#define _OBJECT_HXX_ + +#include <ctime> +#include <map> +#include <string> +#include <vector> + +#ifndef __cplusplus +#include <stdbool.h> +#endif + +#include <boost/date_time.hpp> +#include <boost/shared_ptr.hpp> +#include <libxml/tree.h> + +#include "libcmis/allowable-actions.hxx" +#include "libcmis/exception.hxx" +#include "libcmis/libcmis-api.h" +#include "libcmis/object-type.hxx" +#include "libcmis/property.hxx" +#include "libcmis/xmlserializable.hxx" +#include "libcmis/rendition.hxx" + +namespace libcmis +{ + class Folder; + class Session; + + /** Class representing any CMIS object. + */ + class LIBCMIS_API Object : public XmlSerializable + { + protected: + Session* m_session; + + ObjectTypePtr m_typeDescription; + time_t m_refreshTimestamp; + + /** Type id used as cache before we get it as a property + */ + std::string m_typeId; + + std::map< std::string, PropertyPtr > m_properties; + boost::shared_ptr< AllowableActions > m_allowableActions; + std::vector< RenditionPtr > m_renditions; + void initializeFromNode( xmlNodePtr node ); + + public: + + Object( Session* session ); + Object( Session* session, xmlNodePtr node ); + Object( const Object& copy ); + virtual ~Object( ) { } + + Object& operator=( const Object& copy ); + + virtual std::string getId( ); + virtual std::string getName( ); + virtual std::string getStringProperty( const std::string& propertyName ); + + /** Computes the paths for the objects. + + Note that folders will have only path, documents may have + several ones and there may be cases where there is no path + at all (unfilled objects); + */ + virtual std::vector< std::string > getPaths( ); + + virtual std::string getBaseType( ); + virtual std::string getType( ); + + virtual std::string getCreatedBy( ); + virtual boost::posix_time::ptime getCreationDate( ); + virtual std::string getLastModifiedBy( ); + virtual boost::posix_time::ptime getLastModificationDate( ); + + virtual std::string getChangeToken( ); + virtual bool isImmutable( ); + + virtual std::vector< std::string > getSecondaryTypes(); + + /** Convenience function adding a secondary type to the object. + + Behind the scene this function is basically computing the + properties and sets them for you to avoid reading the CMIS + 1.1 specification, section 2.1.9. + + \param id + the identifier of the secondary type to add + \param properties + the properties coming with the secondary type + + \return + the updated object. Note that it may represent the same + object on the server but it still is a different object + instance (see updateProperties method). + + \throw Exception + if anything wrong happens. Note that the server is likely + to throw a constraint exception if it doesn't allow the + operation. + */ + virtual boost::shared_ptr< Object > addSecondaryType( + std::string id, + PropertyPtrMap properties ); + + /** Convenience function removing a secondary type from the object. + + Behind the scene this function is basically computing the + correct property and sets it for you to avoid reading the + CMIS 1.1 specification, section 2.1.9. + + The server should remove the related properties, there is + normally no need to worry about them. + + \param id + the identifier of the secondary type to remove + + \return + the updated object. Note that it may represent the same + object on the server but it still is a different object + instance (see updateProperties method). + + \throw Exception + if anything wrong happens. Note that the server is likely + to throw a constraint exception if it doesn't allow the + operation. + */ + virtual boost::shared_ptr< Object > removeSecondaryType( std::string id ); + + /** Gives access to the properties of the object. + + \attention + API users should consider this method as read-only as the + changed properties won't be updated to the server. Updating + the returned map may lead to changes loss when calling + updateProperties. + + \sa updateProperties to change properties on the server + */ + virtual libcmis::PropertyPtrMap& getProperties( ); + + + /** Get the renditions of the object. + + \param filter is defined by the CMIS spec section 2.2.1.2.4.1. + By default, this value is just ignored, but some bindings and servers + may use it. + + \attention + The streamId of the rendition is used in getContentStream( ) + */ + virtual std::vector< RenditionPtr> getRenditions( std::string filter = std::string( ) ); + virtual AllowableActionsPtr getAllowableActions( ) { return m_allowableActions; } + + /** Update the object properties and return the updated object. + + \attention + even if the returned object may have the same Id than 'this' + and thus representing the same object on the server, those + are still two different instances to ease memory handling. + */ + virtual boost::shared_ptr< Object > updateProperties( + const PropertyPtrMap& properties ) = 0; + + virtual ObjectTypePtr getTypeDescription( ); + + /** Reload the data from the server. + */ + virtual void refresh( ) = 0; + virtual time_t getRefreshTimestamp( ) { return m_refreshTimestamp; } + + virtual void remove( bool allVersions = true ) = 0; + + virtual void move( boost::shared_ptr< Folder > source, boost::shared_ptr< Folder > destination ) = 0; + + + virtual std::string getThumbnailUrl( ); + + /** Dump the object as a string for debugging or display purpose. + */ + virtual std::string toString( ); + + void toXml( xmlTextWriterPtr writer ); + }; + + typedef boost::shared_ptr< Object > ObjectPtr; +} + +#endif diff --git a/inc/libcmis/property-type.hxx b/inc/libcmis/property-type.hxx new file mode 100644 index 0000000..350a7b2 --- /dev/null +++ b/inc/libcmis/property-type.hxx @@ -0,0 +1,127 @@ +/* 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 _PROPERTY_TYPE_HXX_ +#define _PROPERTY_TYPE_HXX_ + +#include <boost/date_time.hpp> +#include <libxml/tree.h> + +#include <string> + +#include "libcmis/libcmis-api.h" + +namespace libcmis +{ + class ObjectType; + typedef boost::shared_ptr< ObjectType > ObjectTypePtr; + + class LIBCMIS_API PropertyType + { + public: + + enum Type + { + String, + Integer, + Decimal, + Bool, + DateTime + }; + + private: + + std::string m_id; + std::string m_localName; + std::string m_localNamespace; + std::string m_displayName; + std::string m_queryName; + Type m_type; + std::string m_xmlType; + bool m_multiValued; + bool m_updatable; + bool m_inherited; + bool m_required; + bool m_queryable; + bool m_orderable; + bool m_openChoice; + bool m_temporary; + + public: + + /// Default constructor, mostly present for testing. + PropertyType( ); + PropertyType( xmlNodePtr node ); + PropertyType( const PropertyType& copy ); + /// constructor for temporary type definitions + PropertyType( std::string type, + std::string id, + std::string localName, + std::string displayName, + std::string queryName ); + virtual ~PropertyType( ) { }; + + PropertyType& operator=( const PropertyType& copy ); + + std::string getId( ) { return m_id; } + std::string getLocalName( ) { return m_localName; } + std::string getLocalNamespace( ) { return m_localNamespace; } + std::string getDisplayName( ) { return m_displayName; } + std::string getQueryName( ) { return m_queryName; } + Type getType( ) { return m_type; } + std::string getXmlType( ) { return m_xmlType; } + bool isMultiValued( ) { return m_multiValued; } + bool isUpdatable( ) { return m_updatable; } + bool isInherited( ) { return m_inherited; } + bool isRequired( ) { return m_required; } + bool isQueryable( ) { return m_queryable; } + bool isOrderable( ) { return m_orderable; } + bool isOpenChoice( ) { return m_openChoice; } + + void setId( std::string id ) { m_id = id; } + void setLocalName( std::string localName ) { m_localName = localName; } + void setLocalNamespace( std::string localNamespace ) { m_localNamespace = localNamespace; } + void setDisplayName( std::string displayName ) { m_displayName = displayName; } + void setQueryName( std::string queryName ) { m_queryName = queryName; } + void setType( Type type ) { m_type = type; } + void setMultiValued( bool multivalued ) { m_multiValued = multivalued; } + void setUpdatable( bool updatable ) { m_updatable = updatable; } + void setInherited( bool inherited ) { m_inherited = inherited; } + void setRequired( bool required ) { m_required = required; } + void setQueryable( bool queryable ) { m_queryable = queryable; } + void setOrderable( bool orderable ) { m_orderable = orderable; } + void setOpenChoice( bool openChoice ) { m_openChoice = openChoice; } + + void setTypeFromXml( std::string typeStr ); + void setTypeFromJsonType( std::string jsonType ); + + void update( std::vector< ObjectTypePtr > typesDefs ); + }; + typedef boost::shared_ptr< PropertyType > PropertyTypePtr; +} + +#endif diff --git a/inc/libcmis/property.hxx b/inc/libcmis/property.hxx new file mode 100644 index 0000000..9f67b55 --- /dev/null +++ b/inc/libcmis/property.hxx @@ -0,0 +1,89 @@ +/* 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 _PROPERTY_HXX_ +#define _PROPERTY_HXX_ + +#include <libxml/tree.h> +#include <libxml/xmlwriter.h> + +#include <boost/date_time.hpp> +#include <boost/shared_ptr.hpp> + +#include <string> +#include <vector> + +#include "libcmis/libcmis-api.h" +#include "libcmis/property-type.hxx" +#include "libcmis/xmlserializable.hxx" + +namespace libcmis +{ + class ObjectType; + + class LIBCMIS_API Property : public XmlSerializable + { + private: + PropertyTypePtr m_propertyType; + std::vector< std::string > m_strValues; + std::vector< bool > m_boolValues; + std::vector< long > m_longValues; + std::vector< double > m_doubleValues; + std::vector< boost::posix_time::ptime > m_dateTimeValues; + + protected: + Property( ); + + public: + /** Property constructor allowing to use different values for the id and names. + */ + Property( PropertyTypePtr propertyType, std::vector< std::string > strValues ); + + ~Property( ){ } + + PropertyTypePtr getPropertyType( ) { return m_propertyType; } + + std::vector< boost::posix_time::ptime > getDateTimes( ) { return m_dateTimeValues; } + std::vector< bool > getBools( ) { return m_boolValues; } + std::vector< std::string > getStrings( ) { return m_strValues; } + std::vector< long > getLongs( ) { return m_longValues; } + std::vector< double > getDoubles( ) { return m_doubleValues; } + + void setPropertyType( PropertyTypePtr propertyType); + void setValues( std::vector< std::string > strValues ); + + void toXml( xmlTextWriterPtr writer ); + + std::string toString( ); + }; + typedef boost::shared_ptr< Property > PropertyPtr; + typedef std::map< std::string, libcmis::PropertyPtr > PropertyPtrMap; + + PropertyPtr parseProperty( xmlNodePtr node, boost::shared_ptr< ObjectType > objectType ); +} + +#endif diff --git a/inc/libcmis/rendition.hxx b/inc/libcmis/rendition.hxx new file mode 100644 index 0000000..62dc59c --- /dev/null +++ b/inc/libcmis/rendition.hxx @@ -0,0 +1,90 @@ +/* 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. + */ + +#ifndef _RENDITION_HXX_ +#define _RENDITION_HXX_ + +#include <string> + +#include <boost/shared_ptr.hpp> +#include <libxml/tree.h> + +#include "libcmis/libcmis-api.h" + +namespace libcmis +{ + class LIBCMIS_API Rendition + { + private: + Rendition( ); + + std::string m_streamId; + std::string m_mimeType; + std::string m_kind; + std::string m_href; + std::string m_title; + long m_length; + long m_width; + long m_height; + std::string m_renditionDocumentId; + + public: + Rendition( std::string streamId, std::string mimeType, + std::string kind, std::string href, + std::string title = std::string( ), + long length = -1, long width = -1, long height = -1, + std::string renditionDocumentId = std::string( ) ); + + /** Parse an XML node of type cmisRenditionType + */ + Rendition( xmlNodePtr node ); + ~Rendition( ); + + bool isThumbnail( ); + + const std::string& getStreamId( ) const; + const std::string& getMimeType( ) const; + const std::string& getKind( ) const; + const std::string& getUrl( ) const; + const std::string& getTitle( ) const; + + /** Provides the stream length in bytes or a negative value if missing. + */ + long getLength( ) const; + long getWidth( ) const; + long getHeight( ) const; + const std::string& getRenditionDocumentId( ); + + std::string toString( ); + }; + + typedef boost::shared_ptr< Rendition > RenditionPtr; +} + +#endif + diff --git a/inc/libcmis/repository.hxx b/inc/libcmis/repository.hxx new file mode 100644 index 0000000..3c0f67c --- /dev/null +++ b/inc/libcmis/repository.hxx @@ -0,0 +1,119 @@ +/* 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 Cédric Bosdonnat <cbosdo@users.sourceforge.net> + * + * + * 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 _REPOSITORY_HXX_ +#define _REPOSITORY_HXX_ + +#include <map> +#include <string> + +#include <boost/shared_ptr.hpp> +#include <libxml/tree.h> + +#include "libcmis/libcmis-api.h" + +namespace libcmis +{ + /** Class representing a repository and its infos. + + \sa 2.2.2.2 section of the CMIS specifications + */ + class LIBCMIS_API Repository + { + public: + + enum Capability + { + ACL, + AllVersionsSearchable, + Changes, + ContentStreamUpdatability, + GetDescendants, + GetFolderTree, + OrderBy, + Multifiling, + PWCSearchable, + PWCUpdatable, + Query, + Renditions, + Unfiling, + VersionSpecificFiling, + Join + }; + + protected: + std::string m_id; + std::string m_name; + std::string m_description; + std::string m_vendorName; + std::string m_productName; + std::string m_productVersion; + std::string m_rootId; + std::string m_cmisVersionSupported; + boost::shared_ptr< std::string > m_thinClientUri; + boost::shared_ptr< std::string > m_principalAnonymous; + boost::shared_ptr< std::string > m_principalAnyone; + + std::map< Capability, std::string > m_capabilities ; + + Repository( ); + void initializeFromNode( xmlNodePtr node ); + + public: + Repository( xmlNodePtr node ); + virtual ~Repository( ) { }; + + std::string getId( ) const; + std::string getName( ) const; + std::string getDescription( ) const; + std::string getVendorName( ) const; + std::string getProductName( ) const; + std::string getProductVersion( ) const; + std::string getRootId( ) const; + std::string getCmisVersionSupported( ) const; + boost::shared_ptr< std::string > getThinClientUri( ) const; + boost::shared_ptr< std::string > getPrincipalAnonymous( ) const; + boost::shared_ptr< std::string > getPrincipalAnyone( ) const; + + std::string getCapability( Capability capability ) const; + + /** Wrapper function providing the capability as a boolean value. + If the capability value is not a boolean, returns false. + */ + bool getCapabilityAsBool( Capability capability ) const; + + std::string toString( ) const; + + private: + + static std::map< Capability, std::string > parseCapabilities( xmlNodePtr node ); + }; + + typedef boost::shared_ptr< Repository > RepositoryPtr; +} + +#endif diff --git a/inc/libcmis/session-factory.hxx b/inc/libcmis/session-factory.hxx new file mode 100644 index 0000000..227ac4d --- /dev/null +++ b/inc/libcmis/session-factory.hxx @@ -0,0 +1,157 @@ +/* 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 _SESSION_FACTORY_HXX_ +#define _SESSION_FACTORY_HXX_ + +#include <vector> +#include <map> +#include <string> + +#include "libcmis/exception.hxx" +#include "libcmis/libcmis-api.h" +#include "libcmis/oauth2-data.hxx" +#include "libcmis/repository.hxx" +#include "libcmis/session.hxx" + +// needed for a callback type +typedef void CURL; + +namespace libcmis +{ + /** This callback provides the OAuth2 code or NULL. + + The returned string must be free()d by the caller. + */ + typedef char* ( *OAuth2AuthCodeProvider )( const char* authUrl, + const char* username, const char* password ); + + class LIBCMIS_API AuthProvider + { + public: + virtual ~AuthProvider() { }; + + /** The function implementing it needs to fill the username and password parameters + and return true. Returning false means that the user cancelled the authentication + and will fail the query. + */ + virtual bool authenticationQuery( std::string& username, std::string& password ) = 0; + }; + typedef boost::shared_ptr< AuthProvider > AuthProviderPtr; + + /** Handler class used to request user input when an invalid SSL certificate is encountered. + */ + class LIBCMIS_API CertValidationHandler + { + public: + virtual ~CertValidationHandler( ){ }; + + /** This function is provided a vector of X509 certificates encoded in base64, with + the first certificate being the one to validate, and the others are the issuers + chain. + + The result will be stored in the session object to avoid asking several times + to validate the same certificate. + + \result true if the certificate should be ignored, false to fail the request. + */ + virtual bool validateCertificate( std::vector< std::string > certificatesChain ) = 0; + }; + typedef boost::shared_ptr< CertValidationHandler > CertValidationHandlerPtr; + + typedef void(*CurlInitProtocolsFunction)(CURL *); + + class LIBCMIS_API SessionFactory + { + private: + + static AuthProviderPtr s_authProvider; + + static std::string s_proxy; + static std::string s_noProxy; + static std::string s_proxyUser; + static std::string s_proxyPass; + + static OAuth2AuthCodeProvider s_oauth2AuthCodeProvider; + + static CertValidationHandlerPtr s_certValidationHandler; + + public: + + static void setAuthenticationProvider( AuthProviderPtr provider ) { s_authProvider = provider; } + static AuthProviderPtr getAuthenticationProvider( ) { return s_authProvider; } + + static void setOAuth2AuthCodeProvider( OAuth2AuthCodeProvider provider ) { s_oauth2AuthCodeProvider = provider; } + static OAuth2AuthCodeProvider getOAuth2AuthCodeProvider( ) { return s_oauth2AuthCodeProvider; } + + /** Set the handler to ask the user what to do with invalid SSL certificates. If not set, + every invalid certificate will raise an exception. + */ + static void setCertificateValidationHandler( CertValidationHandlerPtr handler ) { s_certValidationHandler = handler; } + static CertValidationHandlerPtr getCertificateValidationHandler( ) { return s_certValidationHandler; } + + static void setCurlInitProtocolsFunction(CurlInitProtocolsFunction); + + static void setProxySettings( std::string proxy, + std::string noProxy, + std::string proxyUser, + std::string proxyPass ); + + static const std::string& getProxy() { return s_proxy; } + static const std::string& getNoProxy() { return s_noProxy; } + static const std::string& getProxyUser() { return s_proxyUser; } + static const std::string& getProxyPass() { return s_proxyPass; } + + /** Create a session from the given parameters. The binding type is automatically + detected based on the provided URL. + + The resulting pointer should be deleted by the caller. + */ + static Session* createSession( std::string bindingUrl, + std::string username = std::string( ), + std::string password = std::string( ), + std::string repositoryId = std::string( ), + bool noSslCheck = false, + OAuth2DataPtr oauth2 = OAuth2DataPtr(), bool verbose = false ); + + /** + Gets the informations of the repositories on the server. + + \deprecated + Since libcmis 0.4.0, this helper function simply creates a session + using the createSession function with no repository and then calls + getRepositories on the resulting session. + Kept only for backward API compatibility. + */ + static std::vector< RepositoryPtr > getRepositories( std::string bindingUrl, + std::string username = std::string( ), + std::string password = std::string( ), + bool verbose = false ); + }; +} + +#endif diff --git a/inc/libcmis/session.hxx b/inc/libcmis/session.hxx new file mode 100644 index 0000000..ec95ab4 --- /dev/null +++ b/inc/libcmis/session.hxx @@ -0,0 +1,103 @@ +/* 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 _SESSION_HXX_ +#define _SESSION_HXX_ + +#include <vector> +#include <string> +#include <boost/shared_ptr.hpp> + +#include "libcmis/libcmis-api.h" +#include "libcmis/object-type.hxx" +#include "libcmis/object.hxx" +#include "libcmis/folder.hxx" +#include "libcmis/repository.hxx" + +namespace libcmis +{ + class LIBCMIS_API Session + { + public: + + virtual ~Session() { }; + + /** Get the current repository. + */ + virtual RepositoryPtr getRepository( ) = 0; + + virtual std::vector< RepositoryPtr > getRepositories( ) = 0; + + /** Change the current repository. + + \return + false if no repository with the provided id can be found on the server, + true otherwise + */ + virtual bool setRepository( std::string repositoryId ) = 0; + + /** Get the Root folder of the repository + */ + virtual FolderPtr getRootFolder()= 0; + + /** Get a CMIS object from its ID. + */ + virtual ObjectPtr getObject( std::string id ) = 0; + + /** Get a CMIS object from one of its path. + */ + virtual ObjectPtr getObjectByPath( std::string path ) = 0; + + /** Get a CMIS folder from its ID. + */ + virtual libcmis::FolderPtr getFolder( std::string id ) = 0; + + /** Get a CMIS object type from its ID. + */ + virtual ObjectTypePtr getType( std::string id ) = 0; + + /** Get all the CMIS base object types known by the server. + */ + virtual std::vector< ObjectTypePtr > getBaseTypes( ) = 0; + + /** Enable or disable the SSL certificate verification. + + By default, SSL certificates are verified and errors are thrown in case of + one is invalid. The user may decide to ignore the checks for this CMIS session + to workaround self-signed certificates or other similar problems. + + As each session only handles the connection to one CMIS server, it should + concern only one SSL certificate and should provide the same feature as the + certificate exception feature available on common web browser. + */ + virtual void setNoSSLCertificateCheck( bool noCheck ) = 0; + + virtual std::string getRefreshToken() { return ""; }; + }; +} + +#endif diff --git a/inc/libcmis/xml-utils.hxx b/inc/libcmis/xml-utils.hxx new file mode 100644 index 0000000..929385e --- /dev/null +++ b/inc/libcmis/xml-utils.hxx @@ -0,0 +1,166 @@ +/* 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 _XML_UTILS_HXX_ +#define _XML_UTILS_HXX_ + +#include <map> +#include <ostream> +#include <sstream> +#include <string> + +#include <boost/date_time.hpp> +#include <libxml/tree.h> +#include <libxml/xpathInternals.h> +#include <libxml/xmlwriter.h> + +#include "libcmis/exception.hxx" +#include "libcmis/libcmis-api.h" + +#define NS_CMIS_PREFIX "cmis" +#define NS_CMISRA_PREFIX "cmisra" +#define NS_SOAP_ENV_PREFIX "soap-env" +#define NS_CMIS_URL "http://docs.oasis-open.org/ns/cmis/core/200908/" +#define NS_CMISRA_URL "http://docs.oasis-open.org/ns/cmis/restatom/200908/" +#define NS_CMISM_URL "http://docs.oasis-open.org/ns/cmis/messaging/200908/" +#define NS_CMISW_URL "http://docs.oasis-open.org/ns/cmis/ws/200908/" +#define NS_APP_URL "http://www.w3.org/2007/app" +#define NS_ATOM_URL "http://www.w3.org/2005/Atom" +#define NS_SOAP_URL "http://schemas.xmlsoap.org/wsdl/soap/" +#define NS_SOAP_ENV_URL "http://schemas.xmlsoap.org/soap/envelope/" + +#define LIBCURL_VERSION_VALUE ( \ + ( LIBCURL_VERSION_MAJOR << 16 ) | ( LIBCURL_VERSION_MINOR << 8 ) | ( LIBCURL_VERSION_PATCH ) \ +) + +namespace libcmis +{ + /** Class used to decode a stream. + + An instance of this class can hold remaining un-decoded data to use + for a future decode call. + */ + class LIBCMIS_API EncodedData + { + private: + xmlTextWriterPtr m_writer; + FILE* m_stream; + std::ostream* m_outStream; + + std::string m_encoding; + bool m_decode; + unsigned long m_pendingValue; + int m_pendingRank; + size_t m_missingBytes; + + public: + EncodedData( FILE* stream ); + EncodedData( std::ostream* stream ); + EncodedData( const EncodedData& rCopy ); + EncodedData( xmlTextWriterPtr writer ); + + EncodedData& operator=( const EncodedData& rCopy ); + + void setEncoding( std::string encoding ) { m_encoding = encoding; } + void decode( void* buf, size_t size, size_t nmemb ); + void encode( void* buf, size_t size, size_t nmemb ); + void finish( ); + + private: + void write( void* buf, size_t size, size_t nmemb ); + void decodeBase64( const char* buf, size_t len ); + void encodeBase64( const char* buf, size_t len ); + }; + + class LIBCMIS_API HttpResponse + { + private: + std::map< std::string, std::string > m_headers; + boost::shared_ptr< std::stringstream > m_stream; + boost::shared_ptr< EncodedData > m_data; + + public: + HttpResponse( ); + ~HttpResponse( ) { }; + + std::map< std::string, std::string >& getHeaders( ) { return m_headers; } + boost::shared_ptr< EncodedData > getData( ) { return m_data; } + boost::shared_ptr< std::stringstream > getStream( ) { return m_stream; } + }; + typedef boost::shared_ptr< HttpResponse > HttpResponsePtr; + + LIBCMIS_API void registerNamespaces( xmlXPathContextPtr xpathCtx ); + + /** Register the CMIS and WSDL / SOAP namespaces + */ + LIBCMIS_API void registerCmisWSNamespaces( xmlXPathContextPtr xpathCtx ); + + /** Register only the WSD / SOAP namespaces. + */ + LIBCMIS_API void registerSoapNamespaces( xmlXPathContextPtr xpathCtx ); + + LIBCMIS_API std::string getXPathValue( xmlXPathContextPtr xpathCtx, std::string req ); + + LIBCMIS_API xmlDocPtr wrapInDoc( xmlNodePtr entryNode ); + + /** Utility extracting an attribute value from an Xml Node, + based on the attribute name. If the defaultValue is NULL and + the attribute can't be found then throw an exception. + */ + LIBCMIS_API std::string getXmlNodeAttributeValue( xmlNodePtr node, + const char* attributeName, + const char* defaultValue = NULL ); + + /** Parse a xsd:dateTime string and return the corresponding UTC posix time. + */ + LIBCMIS_API boost::posix_time::ptime parseDateTime( std::string dateTimeStr ); + + /// Write a UTC time object to an xsd:dateTime string + LIBCMIS_API std::string writeDateTime( boost::posix_time::ptime time ); + + LIBCMIS_API bool parseBool( std::string str ); + + LIBCMIS_API long parseInteger( std::string str ); + + LIBCMIS_API double parseDouble( std::string str ); + + /** Trim spaces on the left and right of a string. + */ + LIBCMIS_API std::string trim( const std::string& str ); + + LIBCMIS_API std::string base64encode( const std::string& str ); + + LIBCMIS_API std::string sha1( const std::string& str ); + + LIBCMIS_API int stringstream_write_callback(void * context, const char * s, int len); + + LIBCMIS_API std::string escape( std::string str ); + + LIBCMIS_API std::string unescape( std::string str ); +} + +#endif diff --git a/inc/libcmis/xmlserializable.hxx b/inc/libcmis/xmlserializable.hxx new file mode 100644 index 0000000..bd7c7c2 --- /dev/null +++ b/inc/libcmis/xmlserializable.hxx @@ -0,0 +1,48 @@ +/* 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 _XMLSERIALIZABLE_HXX_ +#define _XMLSERIALIZABLE_HXX_ + +#include <libxml/xmlwriter.h> + +#include "libcmis/libcmis-api.h" + +namespace libcmis +{ + + /// Interface for objects dumpable as XML + class LIBCMIS_API XmlSerializable + { + public: + virtual ~XmlSerializable( ) { } + + virtual void toXml( xmlTextWriterPtr writer ) = 0; + }; +} + +#endif |