12f86921cSAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
32f86921cSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
42f86921cSAndrew Rist * or more contributor license agreements. See the NOTICE file
52f86921cSAndrew Rist * distributed with this work for additional information
62f86921cSAndrew Rist * regarding copyright ownership. The ASF licenses this file
72f86921cSAndrew Rist * to you under the Apache License, Version 2.0 (the
82f86921cSAndrew Rist * "License"); you may not use this file except in compliance
92f86921cSAndrew Rist * with the License. You may obtain a copy of the License at
102f86921cSAndrew Rist *
112f86921cSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
122f86921cSAndrew Rist *
132f86921cSAndrew Rist * Unless required by applicable law or agreed to in writing,
142f86921cSAndrew Rist * software distributed under the License is distributed on an
152f86921cSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
162f86921cSAndrew Rist * KIND, either express or implied. See the License for the
172f86921cSAndrew Rist * specific language governing permissions and limitations
182f86921cSAndrew Rist * under the License.
192f86921cSAndrew Rist *
202f86921cSAndrew Rist *************************************************************/
212f86921cSAndrew Rist
222f86921cSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir #include <string.h>
25cdf0e10cSrcweir #include <unistd.h>
26cdf0e10cSrcweir #include <sys/types.h>
27cdf0e10cSrcweir
28cdf0e10cSrcweir #include <osl/time.h>
29cdf0e10cSrcweir
30cdf0e10cSrcweir #include <osl/diagnose.h>
31cdf0e10cSrcweir #include <osl/doublecheckedlocking.h>
32cdf0e10cSrcweir
33cdf0e10cSrcweir #include <com/sun/star/beans/PropertyValue.hpp>
34cdf0e10cSrcweir #include <com/sun/star/beans/PropertyAttribute.hpp>
35cdf0e10cSrcweir #include <com/sun/star/beans/PropertySetInfoChange.hpp>
36cdf0e10cSrcweir #include <com/sun/star/beans/PropertySetInfoChangeEvent.hpp>
37cdf0e10cSrcweir #include <com/sun/star/io/XActiveDataSink.hpp>
38cdf0e10cSrcweir #include <com/sun/star/io/XOutputStream.hpp>
39cdf0e10cSrcweir #include <com/sun/star/lang/IllegalAccessException.hpp>
40cdf0e10cSrcweir #include <com/sun/star/ucb/ContentInfoAttribute.hpp>
41cdf0e10cSrcweir #include <com/sun/star/ucb/InsertCommandArgument.hpp>
42cdf0e10cSrcweir #include <com/sun/star/ucb/InteractiveBadTransferURLException.hpp>
43cdf0e10cSrcweir #include <com/sun/star/ucb/InteractiveAugmentedIOException.hpp>
44cdf0e10cSrcweir #include <com/sun/star/ucb/InteractiveNetworkWriteException.hpp>
45cdf0e10cSrcweir #include <com/sun/star/ucb/InteractiveAugmentedIOException.hpp>
46cdf0e10cSrcweir #include <com/sun/star/ucb/InteractiveNetworkConnectException.hpp>
47cdf0e10cSrcweir #include <com/sun/star/ucb/InteractiveNetworkGeneralException.hpp>
48cdf0e10cSrcweir #include <com/sun/star/ucb/InteractiveNetworkReadException.hpp>
49cdf0e10cSrcweir #include <com/sun/star/ucb/InteractiveNetworkResolveNameException.hpp>
50cdf0e10cSrcweir #include <com/sun/star/ucb/InteractiveNetworkWriteException.hpp>
51cdf0e10cSrcweir #include <com/sun/star/ucb/NameClash.hpp>
52cdf0e10cSrcweir #include <com/sun/star/ucb/NameClashException.hpp>
53cdf0e10cSrcweir #include <com/sun/star/ucb/OpenMode.hpp>
54cdf0e10cSrcweir #include <com/sun/star/ucb/PostCommandArgument2.hpp>
55cdf0e10cSrcweir #include <com/sun/star/ucb/XCommandInfo.hpp>
56cdf0e10cSrcweir #include <com/sun/star/ucb/XPersistentPropertySet.hpp>
57cdf0e10cSrcweir #include <com/sun/star/ucb/MissingInputStreamException.hpp>
58cdf0e10cSrcweir #include <com/sun/star/ucb/MissingPropertiesException.hpp>
59cdf0e10cSrcweir #include <com/sun/star/ucb/UnsupportedCommandException.hpp>
60cdf0e10cSrcweir #include <com/sun/star/ucb/UnsupportedDataSinkException.hpp>
61cdf0e10cSrcweir #include <com/sun/star/ucb/UnsupportedNameClashException.hpp>
62cdf0e10cSrcweir #include <com/sun/star/ucb/UnsupportedOpenModeException.hpp>
63cdf0e10cSrcweir #include <com/sun/star/ucb/UnsupportedOpenModeException.hpp>
64cdf0e10cSrcweir #include <com/sun/star/ucb/NameClashException.hpp>
65cdf0e10cSrcweir #include <com/sun/star/ucb/XDynamicResultSet.hpp>
66cdf0e10cSrcweir #include <com/sun/star/ucb/XContentCreator.hpp>
67cdf0e10cSrcweir
68cdf0e10cSrcweir #include <ucbhelper/contentidentifier.hxx>
69cdf0e10cSrcweir #include <ucbhelper/propertyvalueset.hxx>
70cdf0e10cSrcweir #include <ucbhelper/interactionrequest.hxx>
71cdf0e10cSrcweir #include <ucbhelper/cancelcommandexecution.hxx>
72cdf0e10cSrcweir
73cdf0e10cSrcweir #include <osl/conditn.hxx>
74cdf0e10cSrcweir
75cdf0e10cSrcweir #include "gio_content.hxx"
76cdf0e10cSrcweir #include "gio_provider.hxx"
77cdf0e10cSrcweir #include "gio_resultset.hxx"
78cdf0e10cSrcweir #include "gio_inputstream.hxx"
79cdf0e10cSrcweir #include "gio_outputstream.hxx"
80cdf0e10cSrcweir #include "gio_mount.hxx"
81cdf0e10cSrcweir
82cdf0e10cSrcweir #include <stdio.h>
83cdf0e10cSrcweir
84cdf0e10cSrcweir using namespace com::sun::star;
85cdf0e10cSrcweir
86cdf0e10cSrcweir namespace gio
87cdf0e10cSrcweir {
88cdf0e10cSrcweir
Content(const uno::Reference<lang::XMultiServiceFactory> & rxSMgr,ContentProvider * pProvider,const uno::Reference<ucb::XContentIdentifier> & Identifier)89cdf0e10cSrcweir Content::Content(
90cdf0e10cSrcweir const uno::Reference< lang::XMultiServiceFactory >& rxSMgr,
91cdf0e10cSrcweir ContentProvider* pProvider,
92cdf0e10cSrcweir const uno::Reference< ucb::XContentIdentifier >& Identifier)
93cdf0e10cSrcweir throw ( ucb::ContentCreationException )
94cdf0e10cSrcweir : ContentImplHelper( rxSMgr, pProvider, Identifier ),
95cdf0e10cSrcweir m_pProvider( pProvider ), mpFile (NULL), mpInfo( NULL ), mbTransient(false)
96cdf0e10cSrcweir {
97cdf0e10cSrcweir #ifdef DEBUG
98cdf0e10cSrcweir fprintf(stderr, "New Content ('%s')\n", rtl::OUStringToOString(m_xIdentifier->getContentIdentifier(), RTL_TEXTENCODING_UTF8).getStr());
99cdf0e10cSrcweir #endif
100cdf0e10cSrcweir }
101cdf0e10cSrcweir
Content(const uno::Reference<lang::XMultiServiceFactory> & rxSMgr,ContentProvider * pProvider,const uno::Reference<ucb::XContentIdentifier> & Identifier,sal_Bool bIsFolder)102cdf0e10cSrcweir Content::Content(
103cdf0e10cSrcweir const uno::Reference< lang::XMultiServiceFactory >& rxSMgr,
104cdf0e10cSrcweir ContentProvider* pProvider,
105cdf0e10cSrcweir const uno::Reference< ucb::XContentIdentifier >& Identifier,
106cdf0e10cSrcweir sal_Bool bIsFolder)
107cdf0e10cSrcweir throw ( ucb::ContentCreationException )
108cdf0e10cSrcweir : ContentImplHelper( rxSMgr, pProvider, Identifier ),
109cdf0e10cSrcweir m_pProvider( pProvider ), mpFile (NULL), mpInfo( NULL ), mbTransient(true)
110cdf0e10cSrcweir {
111cdf0e10cSrcweir #ifdef DEBUG
112cdf0e10cSrcweir fprintf(stderr, "Create Content ('%s')\n", rtl::OUStringToOString(m_xIdentifier->getContentIdentifier(), RTL_TEXTENCODING_UTF8).getStr());
113cdf0e10cSrcweir #endif
114cdf0e10cSrcweir mpInfo = g_file_info_new();
115cdf0e10cSrcweir g_file_info_set_file_type(mpInfo, bIsFolder ? G_FILE_TYPE_DIRECTORY : G_FILE_TYPE_REGULAR);
116cdf0e10cSrcweir }
117cdf0e10cSrcweir
~Content()118cdf0e10cSrcweir Content::~Content()
119cdf0e10cSrcweir {
120cdf0e10cSrcweir if (mpInfo) g_object_unref(mpInfo);
121cdf0e10cSrcweir if (mpFile) g_object_unref(mpFile);
122cdf0e10cSrcweir }
123cdf0e10cSrcweir
getParentURL()124cdf0e10cSrcweir rtl::OUString Content::getParentURL()
125cdf0e10cSrcweir {
126cdf0e10cSrcweir rtl::OUString sURL;
127cdf0e10cSrcweir if (GFile* pFile = g_file_get_parent(getGFile()))
128cdf0e10cSrcweir {
129cdf0e10cSrcweir char* pPath = g_file_get_uri(pFile);
130cdf0e10cSrcweir g_object_unref(pFile);
131cdf0e10cSrcweir sURL = rtl::OUString::createFromAscii(pPath);
132cdf0e10cSrcweir g_free(pPath);
133cdf0e10cSrcweir }
134cdf0e10cSrcweir return sURL;
135cdf0e10cSrcweir }
136cdf0e10cSrcweir
abort(sal_Int32)137cdf0e10cSrcweir void SAL_CALL Content::abort( sal_Int32 /*CommandId*/ )
138cdf0e10cSrcweir throw( uno::RuntimeException )
139cdf0e10cSrcweir {
140cdf0e10cSrcweir //TODO
141*86e1cf34SPedro Giffuni //stick a map from each CommandId to a new GCancellable and propagate
142cdf0e10cSrcweir //it throughout the g_file_* calls
143cdf0e10cSrcweir }
144cdf0e10cSrcweir
getContentType()145cdf0e10cSrcweir rtl::OUString SAL_CALL Content::getContentType() throw( uno::RuntimeException )
146cdf0e10cSrcweir {
147cdf0e10cSrcweir return isFolder(uno::Reference< ucb::XCommandEnvironment >())
148cdf0e10cSrcweir ? rtl::OUString::createFromAscii( GIO_FOLDER_TYPE )
149cdf0e10cSrcweir : rtl::OUString::createFromAscii( GIO_FILE_TYPE );
150cdf0e10cSrcweir }
151cdf0e10cSrcweir
152cdf0e10cSrcweir #define EXCEPT(aExcept) \
153cdf0e10cSrcweir do { \
154cdf0e10cSrcweir if (bThrow) throw aExcept;\
155cdf0e10cSrcweir aRet = uno::makeAny( aExcept );\
156cdf0e10cSrcweir } while(0)
157cdf0e10cSrcweir
convertToException(GError * pError,const uno::Reference<uno::XInterface> & rContext,bool bThrow)158cdf0e10cSrcweir uno::Any convertToException(GError *pError, const uno::Reference< uno::XInterface >& rContext, bool bThrow)
159cdf0e10cSrcweir {
160cdf0e10cSrcweir uno::Any aRet;
161cdf0e10cSrcweir
162cdf0e10cSrcweir gint eCode = pError->code;
163cdf0e10cSrcweir rtl::OUString sMessage(pError->message, strlen(pError->message), RTL_TEXTENCODING_UTF8);
164cdf0e10cSrcweir g_error_free(pError);
165cdf0e10cSrcweir
166cdf0e10cSrcweir rtl::OUString sName;
167cdf0e10cSrcweir rtl::OUString sHost;
168cdf0e10cSrcweir
169cdf0e10cSrcweir uno::Sequence< uno::Any > aArgs( 1 );
170cdf0e10cSrcweir aArgs[ 0 ] <<= sName;
171cdf0e10cSrcweir
172cdf0e10cSrcweir switch (eCode)
173cdf0e10cSrcweir {
174cdf0e10cSrcweir case G_IO_ERROR_FAILED:
175cdf0e10cSrcweir { io::IOException aExcept(sMessage, rContext);
176cdf0e10cSrcweir EXCEPT(aExcept); }
177cdf0e10cSrcweir break;
178cdf0e10cSrcweir case G_IO_ERROR_NOT_MOUNTED:
179cdf0e10cSrcweir { ucb::InteractiveAugmentedIOException aExcept(sMessage, rContext,
180cdf0e10cSrcweir task::InteractionClassification_ERROR, ucb::IOErrorCode_NOT_EXISTING_PATH, aArgs);
181cdf0e10cSrcweir EXCEPT(aExcept); }
182cdf0e10cSrcweir break;
183cdf0e10cSrcweir case G_IO_ERROR_NOT_FOUND:
184cdf0e10cSrcweir { ucb::InteractiveAugmentedIOException aExcept(sMessage, rContext,
185cdf0e10cSrcweir task::InteractionClassification_ERROR, ucb::IOErrorCode_NOT_EXISTING, aArgs);
186cdf0e10cSrcweir EXCEPT(aExcept); }
187cdf0e10cSrcweir break;
188cdf0e10cSrcweir case G_IO_ERROR_EXISTS:
189cdf0e10cSrcweir { ucb::NameClashException aExcept(sMessage, rContext,
190cdf0e10cSrcweir task::InteractionClassification_ERROR, sName);
191cdf0e10cSrcweir EXCEPT(aExcept); }
192cdf0e10cSrcweir break;
193cdf0e10cSrcweir case G_IO_ERROR_INVALID_ARGUMENT:
194cdf0e10cSrcweir { lang::IllegalArgumentException aExcept(sMessage, rContext, -1 );
195cdf0e10cSrcweir EXCEPT(aExcept); }
196cdf0e10cSrcweir break;
197cdf0e10cSrcweir case G_IO_ERROR_PERMISSION_DENIED:
198cdf0e10cSrcweir { ucb::InteractiveAugmentedIOException aExcept(sMessage, rContext,
199cdf0e10cSrcweir task::InteractionClassification_ERROR, ucb::IOErrorCode_ACCESS_DENIED, aArgs);
200cdf0e10cSrcweir EXCEPT(aExcept); }
201cdf0e10cSrcweir break;
202cdf0e10cSrcweir case G_IO_ERROR_IS_DIRECTORY:
203cdf0e10cSrcweir { ucb::InteractiveAugmentedIOException aExcept(sMessage, rContext,
204cdf0e10cSrcweir task::InteractionClassification_ERROR, ucb::IOErrorCode_NO_FILE, aArgs);
205cdf0e10cSrcweir EXCEPT(aExcept); }
206cdf0e10cSrcweir break;
207cdf0e10cSrcweir case G_IO_ERROR_NOT_REGULAR_FILE:
208cdf0e10cSrcweir { ucb::InteractiveAugmentedIOException aExcept(sMessage, rContext,
209cdf0e10cSrcweir task::InteractionClassification_ERROR, ucb::IOErrorCode_NO_FILE, aArgs);
210cdf0e10cSrcweir EXCEPT(aExcept); }
211cdf0e10cSrcweir break;
212cdf0e10cSrcweir case G_IO_ERROR_NOT_DIRECTORY:
213cdf0e10cSrcweir { ucb::InteractiveAugmentedIOException aExcept(sMessage, rContext,
214cdf0e10cSrcweir task::InteractionClassification_ERROR, ucb::IOErrorCode_NO_DIRECTORY, aArgs);
215cdf0e10cSrcweir EXCEPT(aExcept); }
216cdf0e10cSrcweir break;
217cdf0e10cSrcweir case G_IO_ERROR_FILENAME_TOO_LONG:
218cdf0e10cSrcweir { ucb::InteractiveAugmentedIOException aExcept(sMessage, rContext,
219cdf0e10cSrcweir task::InteractionClassification_ERROR, ucb::IOErrorCode_NAME_TOO_LONG, aArgs);
220cdf0e10cSrcweir EXCEPT(aExcept); }
221cdf0e10cSrcweir break;
222cdf0e10cSrcweir case G_IO_ERROR_PENDING:
223cdf0e10cSrcweir { ucb::InteractiveAugmentedIOException aExcept(sMessage, rContext,
224cdf0e10cSrcweir task::InteractionClassification_ERROR, ucb::IOErrorCode_PENDING, aArgs);
225cdf0e10cSrcweir EXCEPT(aExcept); }
226cdf0e10cSrcweir break;
227cdf0e10cSrcweir case G_IO_ERROR_CLOSED:
228cdf0e10cSrcweir case G_IO_ERROR_CANCELLED:
229cdf0e10cSrcweir case G_IO_ERROR_TOO_MANY_LINKS:
230cdf0e10cSrcweir case G_IO_ERROR_WRONG_ETAG:
231cdf0e10cSrcweir { ucb::InteractiveAugmentedIOException aExcept(sMessage, rContext,
232cdf0e10cSrcweir task::InteractionClassification_ERROR, ucb::IOErrorCode_GENERAL, aArgs);
233cdf0e10cSrcweir EXCEPT(aExcept); }
234cdf0e10cSrcweir break;
235cdf0e10cSrcweir case G_IO_ERROR_NOT_SUPPORTED:
236cdf0e10cSrcweir case G_IO_ERROR_CANT_CREATE_BACKUP:
237cdf0e10cSrcweir case G_IO_ERROR_WOULD_MERGE:
238cdf0e10cSrcweir { ucb::InteractiveAugmentedIOException aExcept(sMessage, rContext,
239cdf0e10cSrcweir task::InteractionClassification_ERROR, ucb::IOErrorCode_NOT_SUPPORTED, aArgs);
240cdf0e10cSrcweir EXCEPT(aExcept); }
241cdf0e10cSrcweir break;
242cdf0e10cSrcweir case G_IO_ERROR_NO_SPACE:
243cdf0e10cSrcweir { ucb::InteractiveAugmentedIOException aExcept(sMessage, rContext,
244cdf0e10cSrcweir task::InteractionClassification_ERROR, ucb::IOErrorCode_OUT_OF_DISK_SPACE, aArgs);
245cdf0e10cSrcweir EXCEPT(aExcept); }
246cdf0e10cSrcweir break;
247cdf0e10cSrcweir case G_IO_ERROR_INVALID_FILENAME:
248cdf0e10cSrcweir { ucb::InteractiveAugmentedIOException aExcept(sMessage, rContext,
249cdf0e10cSrcweir task::InteractionClassification_ERROR, ucb::IOErrorCode_INVALID_CHARACTER, aArgs);
250cdf0e10cSrcweir EXCEPT(aExcept); }
251cdf0e10cSrcweir break;
252cdf0e10cSrcweir case G_IO_ERROR_READ_ONLY:
253cdf0e10cSrcweir { ucb::InteractiveAugmentedIOException aExcept(sMessage, rContext,
254cdf0e10cSrcweir task::InteractionClassification_ERROR, ucb::IOErrorCode_WRITE_PROTECTED, aArgs);
255cdf0e10cSrcweir EXCEPT(aExcept); }
256cdf0e10cSrcweir break;
257cdf0e10cSrcweir case G_IO_ERROR_TIMED_OUT:
258cdf0e10cSrcweir { ucb::InteractiveAugmentedIOException aExcept(sMessage, rContext,
259cdf0e10cSrcweir task::InteractionClassification_ERROR, ucb::IOErrorCode_DEVICE_NOT_READY, aArgs);
260cdf0e10cSrcweir EXCEPT(aExcept); }
261cdf0e10cSrcweir break;
262cdf0e10cSrcweir case G_IO_ERROR_WOULD_RECURSE:
263cdf0e10cSrcweir { ucb::InteractiveAugmentedIOException aExcept(sMessage, rContext,
264cdf0e10cSrcweir task::InteractionClassification_ERROR, ucb::IOErrorCode_RECURSIVE, aArgs);
265cdf0e10cSrcweir EXCEPT(aExcept); }
266cdf0e10cSrcweir break;
267cdf0e10cSrcweir case G_IO_ERROR_BUSY:
268cdf0e10cSrcweir case G_IO_ERROR_WOULD_BLOCK:
269cdf0e10cSrcweir { ucb::InteractiveAugmentedIOException aExcept(sMessage, rContext,
270cdf0e10cSrcweir task::InteractionClassification_ERROR, ucb::IOErrorCode_LOCKING_VIOLATION, aArgs);
271cdf0e10cSrcweir EXCEPT(aExcept); }
272cdf0e10cSrcweir break;
273cdf0e10cSrcweir case G_IO_ERROR_HOST_NOT_FOUND:
274cdf0e10cSrcweir { ucb::InteractiveNetworkResolveNameException aExcept(sMessage, rContext,
275cdf0e10cSrcweir task::InteractionClassification_ERROR, sHost);
276cdf0e10cSrcweir EXCEPT(aExcept);}
277cdf0e10cSrcweir break;
278cdf0e10cSrcweir default:
279cdf0e10cSrcweir case G_IO_ERROR_ALREADY_MOUNTED:
280cdf0e10cSrcweir case G_IO_ERROR_NOT_EMPTY:
281cdf0e10cSrcweir case G_IO_ERROR_NOT_SYMBOLIC_LINK:
282cdf0e10cSrcweir case G_IO_ERROR_NOT_MOUNTABLE_FILE:
283cdf0e10cSrcweir case G_IO_ERROR_FAILED_HANDLED:
284cdf0e10cSrcweir { ucb::InteractiveNetworkGeneralException aExcept(sMessage, rContext,
285cdf0e10cSrcweir task::InteractionClassification_ERROR);
286cdf0e10cSrcweir EXCEPT(aExcept);}
287cdf0e10cSrcweir break;
288cdf0e10cSrcweir }
289cdf0e10cSrcweir return aRet;
290cdf0e10cSrcweir }
291cdf0e10cSrcweir
mapGIOError(GError * pError)292cdf0e10cSrcweir uno::Any Content::mapGIOError( GError *pError )
293cdf0e10cSrcweir {
294cdf0e10cSrcweir if (!pError)
295cdf0e10cSrcweir return getBadArgExcept();
296cdf0e10cSrcweir
297cdf0e10cSrcweir return convertToException(pError, static_cast< cppu::OWeakObject * >(this), false);
298cdf0e10cSrcweir }
299cdf0e10cSrcweir
getBadArgExcept()300cdf0e10cSrcweir uno::Any Content::getBadArgExcept()
301cdf0e10cSrcweir {
302cdf0e10cSrcweir return uno::makeAny( lang::IllegalArgumentException(
303cdf0e10cSrcweir rtl::OUString::createFromAscii( "Wrong argument type!" ),
304cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ), -1) );
305cdf0e10cSrcweir }
306cdf0e10cSrcweir
307cdf0e10cSrcweir class MountOperation
308cdf0e10cSrcweir {
309cdf0e10cSrcweir GMainLoop *mpLoop;
310cdf0e10cSrcweir GMountOperation *mpAuthentication;
311cdf0e10cSrcweir GError *mpError;
312cdf0e10cSrcweir static void Completed(GObject *source, GAsyncResult *res, gpointer user_data);
313cdf0e10cSrcweir public:
314cdf0e10cSrcweir MountOperation(const uno::Reference< ucb::XCommandEnvironment >& xEnv);
315cdf0e10cSrcweir ~MountOperation();
316cdf0e10cSrcweir GError *Mount(GFile *pFile);
317cdf0e10cSrcweir };
318cdf0e10cSrcweir
MountOperation(const uno::Reference<ucb::XCommandEnvironment> & xEnv)319cdf0e10cSrcweir MountOperation::MountOperation(const uno::Reference< ucb::XCommandEnvironment >& xEnv) : mpError(NULL)
320cdf0e10cSrcweir {
321cdf0e10cSrcweir mpLoop = g_main_loop_new(NULL, FALSE);
322cdf0e10cSrcweir mpAuthentication = ooo_mount_operation_new(xEnv);
323cdf0e10cSrcweir }
324cdf0e10cSrcweir
Completed(GObject * source,GAsyncResult * res,gpointer user_data)325cdf0e10cSrcweir void MountOperation::Completed(GObject *source, GAsyncResult *res, gpointer user_data)
326cdf0e10cSrcweir {
327cdf0e10cSrcweir MountOperation *pThis = (MountOperation*)user_data;
328cdf0e10cSrcweir g_file_mount_enclosing_volume_finish(G_FILE(source), res, &(pThis->mpError));
329cdf0e10cSrcweir g_main_loop_quit(pThis->mpLoop);
330cdf0e10cSrcweir }
331cdf0e10cSrcweir
Mount(GFile * pFile)332cdf0e10cSrcweir GError *MountOperation::Mount(GFile *pFile)
333cdf0e10cSrcweir {
334cdf0e10cSrcweir g_file_mount_enclosing_volume(pFile, G_MOUNT_MOUNT_NONE, mpAuthentication, NULL, MountOperation::Completed, this);
335cdf0e10cSrcweir g_main_loop_run(mpLoop);
336cdf0e10cSrcweir return mpError;
337cdf0e10cSrcweir }
338cdf0e10cSrcweir
~MountOperation()339cdf0e10cSrcweir MountOperation::~MountOperation()
340cdf0e10cSrcweir {
341cdf0e10cSrcweir g_object_unref(mpAuthentication);
342cdf0e10cSrcweir g_main_loop_unref(mpLoop);
343cdf0e10cSrcweir }
344cdf0e10cSrcweir
getGFileInfo(const uno::Reference<ucb::XCommandEnvironment> & xEnv,GError ** ppError)345cdf0e10cSrcweir GFileInfo* Content::getGFileInfo(const uno::Reference< ucb::XCommandEnvironment >& xEnv, GError **ppError)
346cdf0e10cSrcweir {
347cdf0e10cSrcweir /*If we don't have it already, and we're not a "pre-creation" content then query for the info"*/
348cdf0e10cSrcweir if (!mpInfo && !mbTransient)
349cdf0e10cSrcweir {
350cdf0e10cSrcweir if (!(mpInfo = g_file_query_info(getGFile(), "*", G_FILE_QUERY_INFO_NONE, NULL, ppError)))
351cdf0e10cSrcweir {
352cdf0e10cSrcweir //Try and mount if unmounted
353cdf0e10cSrcweir if (ppError && (*ppError)->code == G_IO_ERROR_NOT_MOUNTED)
354cdf0e10cSrcweir {
355cdf0e10cSrcweir g_error_free(*ppError);
356cdf0e10cSrcweir
357cdf0e10cSrcweir MountOperation aMounter(xEnv);
358cdf0e10cSrcweir *ppError = aMounter.Mount(getGFile());
359cdf0e10cSrcweir
360cdf0e10cSrcweir //No Mount error, reattempt query
361cdf0e10cSrcweir if (!*ppError)
362cdf0e10cSrcweir mpInfo = g_file_query_info(getGFile(), "*", G_FILE_QUERY_INFO_NONE, NULL, ppError);
363cdf0e10cSrcweir }
364cdf0e10cSrcweir }
365cdf0e10cSrcweir }
366cdf0e10cSrcweir return mpInfo;
367cdf0e10cSrcweir }
368cdf0e10cSrcweir
getGFile()369cdf0e10cSrcweir GFile* Content::getGFile()
370cdf0e10cSrcweir {
371cdf0e10cSrcweir if (!mpFile)
372cdf0e10cSrcweir mpFile = g_file_new_for_uri(rtl::OUStringToOString(m_xIdentifier->getContentIdentifier(), RTL_TEXTENCODING_UTF8).getStr());
373cdf0e10cSrcweir return mpFile;
374cdf0e10cSrcweir }
375cdf0e10cSrcweir
isFolder(const uno::Reference<ucb::XCommandEnvironment> & xEnv)376cdf0e10cSrcweir bool Content::isFolder(const uno::Reference< ucb::XCommandEnvironment >& xEnv)
377cdf0e10cSrcweir {
378cdf0e10cSrcweir GFileInfo *pInfo = getGFileInfo(xEnv);
379cdf0e10cSrcweir return pInfo && (g_file_info_get_file_type(pInfo) == G_FILE_TYPE_DIRECTORY);
380cdf0e10cSrcweir }
381cdf0e10cSrcweir
getDateFromUnix(time_t t)382cdf0e10cSrcweir static util::DateTime getDateFromUnix (time_t t)
383cdf0e10cSrcweir {
384cdf0e10cSrcweir TimeValue tv;
385cdf0e10cSrcweir tv.Nanosec = 0;
386cdf0e10cSrcweir tv.Seconds = t;
387cdf0e10cSrcweir oslDateTime dt;
388cdf0e10cSrcweir
389cdf0e10cSrcweir if ( osl_getDateTimeFromTimeValue( &tv, &dt ) )
390cdf0e10cSrcweir return util::DateTime( 0, dt.Seconds, dt.Minutes, dt.Hours,
391cdf0e10cSrcweir dt.Day, dt.Month, dt.Year);
392cdf0e10cSrcweir else
393cdf0e10cSrcweir return util::DateTime();
394cdf0e10cSrcweir }
395cdf0e10cSrcweir
getPropertyValuesFromGFileInfo(GFileInfo * pInfo,const uno::Reference<lang::XMultiServiceFactory> & rSMgr,const uno::Reference<ucb::XCommandEnvironment> & xEnv,const uno::Sequence<beans::Property> & rProperties)396cdf0e10cSrcweir uno::Reference< sdbc::XRow > Content::getPropertyValuesFromGFileInfo(GFileInfo *pInfo,
397cdf0e10cSrcweir const uno::Reference< lang::XMultiServiceFactory >& rSMgr,
398cdf0e10cSrcweir const uno::Reference< ucb::XCommandEnvironment > & xEnv,
399cdf0e10cSrcweir const uno::Sequence< beans::Property >& rProperties)
400cdf0e10cSrcweir {
401cdf0e10cSrcweir rtl::Reference< ::ucbhelper::PropertyValueSet > xRow = new ::ucbhelper::PropertyValueSet( rSMgr );
402cdf0e10cSrcweir
403cdf0e10cSrcweir sal_Int32 nProps;
404cdf0e10cSrcweir const beans::Property* pProps;
405cdf0e10cSrcweir
406cdf0e10cSrcweir nProps = rProperties.getLength();
407cdf0e10cSrcweir pProps = rProperties.getConstArray();
408cdf0e10cSrcweir
409cdf0e10cSrcweir for( sal_Int32 n = 0; n < nProps; ++n )
410cdf0e10cSrcweir {
411cdf0e10cSrcweir const beans::Property& rProp = pProps[ n ];
412cdf0e10cSrcweir
413cdf0e10cSrcweir if (rProp.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "IsDocument" ) ) )
414cdf0e10cSrcweir {
415cdf0e10cSrcweir if (g_file_info_has_attribute(pInfo, G_FILE_ATTRIBUTE_STANDARD_TYPE))
416cdf0e10cSrcweir xRow->appendBoolean( rProp, ( g_file_info_get_file_type( pInfo ) == G_FILE_TYPE_REGULAR ||
417cdf0e10cSrcweir g_file_info_get_file_type( pInfo ) == G_FILE_TYPE_UNKNOWN ) );
418cdf0e10cSrcweir else
419cdf0e10cSrcweir xRow->appendVoid( rProp );
420cdf0e10cSrcweir }
421cdf0e10cSrcweir else if (rProp.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "IsFolder" ) ) )
422cdf0e10cSrcweir {
423cdf0e10cSrcweir if( g_file_info_has_attribute( pInfo, G_FILE_ATTRIBUTE_STANDARD_TYPE) )
424cdf0e10cSrcweir xRow->appendBoolean( rProp, ( g_file_info_get_file_type( pInfo ) == G_FILE_TYPE_DIRECTORY ));
425cdf0e10cSrcweir else
426cdf0e10cSrcweir xRow->appendVoid( rProp );
427cdf0e10cSrcweir }
428cdf0e10cSrcweir else if (rProp.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Title" ) ) )
429cdf0e10cSrcweir {
430cdf0e10cSrcweir if (g_file_info_has_attribute(pInfo, G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME))
431cdf0e10cSrcweir {
432cdf0e10cSrcweir const char *pName = g_file_info_get_display_name(pInfo);
433cdf0e10cSrcweir xRow->appendString( rProp, rtl::OUString(pName, strlen(pName), RTL_TEXTENCODING_UTF8) );
434cdf0e10cSrcweir }
435cdf0e10cSrcweir else
436cdf0e10cSrcweir xRow->appendVoid( rProp );
437cdf0e10cSrcweir }
438cdf0e10cSrcweir else if (rProp.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "IsReadOnly" ) ) )
439cdf0e10cSrcweir {
440cdf0e10cSrcweir if( g_file_info_has_attribute( pInfo, G_FILE_ATTRIBUTE_ACCESS_CAN_WRITE ) )
441cdf0e10cSrcweir xRow->appendBoolean( rProp, !g_file_info_get_attribute_boolean( pInfo, G_FILE_ATTRIBUTE_ACCESS_CAN_WRITE) );
442cdf0e10cSrcweir else
443cdf0e10cSrcweir xRow->appendVoid( rProp );
444cdf0e10cSrcweir }
445cdf0e10cSrcweir else if (rProp.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "DateCreated" ) ) )
446cdf0e10cSrcweir {
447cdf0e10cSrcweir if( g_file_info_has_attribute( pInfo, G_FILE_ATTRIBUTE_TIME_CREATED ) )
448cdf0e10cSrcweir xRow->appendTimestamp( rProp, getDateFromUnix(g_file_info_get_attribute_uint64(pInfo, G_FILE_ATTRIBUTE_TIME_CREATED)) );
449cdf0e10cSrcweir else
450cdf0e10cSrcweir xRow->appendVoid( rProp );
451cdf0e10cSrcweir }
452cdf0e10cSrcweir else if (rProp.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "DateModified" ) ) )
453cdf0e10cSrcweir {
454cdf0e10cSrcweir if( g_file_info_has_attribute( pInfo, G_FILE_ATTRIBUTE_TIME_CHANGED ) )
455cdf0e10cSrcweir xRow->appendTimestamp( rProp, getDateFromUnix(g_file_info_get_attribute_uint64(pInfo, G_FILE_ATTRIBUTE_TIME_CHANGED)) );
456cdf0e10cSrcweir else
457cdf0e10cSrcweir xRow->appendVoid( rProp );
458cdf0e10cSrcweir }
459cdf0e10cSrcweir else if (rProp.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Size" ) ) )
460cdf0e10cSrcweir {
461cdf0e10cSrcweir if( g_file_info_has_attribute( pInfo, G_FILE_ATTRIBUTE_STANDARD_SIZE) )
462cdf0e10cSrcweir xRow->appendLong( rProp, ( g_file_info_get_size( pInfo ) ));
463cdf0e10cSrcweir else
464cdf0e10cSrcweir xRow->appendVoid( rProp );
465cdf0e10cSrcweir }
466cdf0e10cSrcweir else if (rProp.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "IsVolume" ) ) )
467cdf0e10cSrcweir {
468cdf0e10cSrcweir //What do we use this for ?
469cdf0e10cSrcweir xRow->appendBoolean( rProp, sal_False );
470cdf0e10cSrcweir }
471cdf0e10cSrcweir else if (rProp.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "IsCompactDisc" ) ) )
472cdf0e10cSrcweir {
473cdf0e10cSrcweir if( g_file_info_has_attribute( pInfo, G_FILE_ATTRIBUTE_MOUNTABLE_CAN_EJECT ) )
474cdf0e10cSrcweir xRow->appendBoolean( rProp, g_file_info_get_attribute_boolean(pInfo, G_FILE_ATTRIBUTE_MOUNTABLE_CAN_EJECT) );
475cdf0e10cSrcweir else
476cdf0e10cSrcweir xRow->appendVoid( rProp );
477cdf0e10cSrcweir }
478cdf0e10cSrcweir else if (rProp.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "IsRemoveable" ) ) )
479cdf0e10cSrcweir {
480cdf0e10cSrcweir if( g_file_info_has_attribute( pInfo, G_FILE_ATTRIBUTE_MOUNTABLE_CAN_UNMOUNT ) )
481cdf0e10cSrcweir xRow->appendBoolean( rProp, g_file_info_get_attribute_boolean(pInfo, G_FILE_ATTRIBUTE_MOUNTABLE_CAN_UNMOUNT ) );
482cdf0e10cSrcweir else
483cdf0e10cSrcweir xRow->appendVoid( rProp );
484cdf0e10cSrcweir }
485cdf0e10cSrcweir else if (rProp.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "IsFloppy" ) ) )
486cdf0e10cSrcweir {
487cdf0e10cSrcweir xRow->appendBoolean( rProp, sal_False );
488cdf0e10cSrcweir }
489cdf0e10cSrcweir else if (rProp.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "IsHidden" ) ) )
490cdf0e10cSrcweir {
491cdf0e10cSrcweir if( g_file_info_has_attribute( pInfo, G_FILE_ATTRIBUTE_STANDARD_IS_HIDDEN) )
492cdf0e10cSrcweir xRow->appendBoolean( rProp, ( g_file_info_get_is_hidden ( pInfo ) ) );
493cdf0e10cSrcweir else
494cdf0e10cSrcweir xRow->appendVoid( rProp );
495cdf0e10cSrcweir }
496cdf0e10cSrcweir else if (rProp.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "CreatableContentsInfo" ) ) )
497cdf0e10cSrcweir {
498cdf0e10cSrcweir xRow->appendObject( rProp, uno::makeAny( queryCreatableContentsInfo( xEnv ) ) );
499cdf0e10cSrcweir }
500cdf0e10cSrcweir #ifdef DEBUG
501cdf0e10cSrcweir else
502cdf0e10cSrcweir {
503cdf0e10cSrcweir fprintf(stderr, "Looking for unsupported property %s\n",
504cdf0e10cSrcweir rtl::OUStringToOString(rProp.Name, RTL_TEXTENCODING_UTF8).getStr());
505cdf0e10cSrcweir }
506cdf0e10cSrcweir #endif
507cdf0e10cSrcweir }
508cdf0e10cSrcweir
509cdf0e10cSrcweir return uno::Reference< sdbc::XRow >( xRow.get() );
510cdf0e10cSrcweir }
511cdf0e10cSrcweir
getPropertyValues(const uno::Sequence<beans::Property> & rProperties,const uno::Reference<ucb::XCommandEnvironment> & xEnv)512cdf0e10cSrcweir uno::Reference< sdbc::XRow > Content::getPropertyValues(
513cdf0e10cSrcweir const uno::Sequence< beans::Property >& rProperties,
514cdf0e10cSrcweir const uno::Reference< ucb::XCommandEnvironment >& xEnv )
515cdf0e10cSrcweir {
516cdf0e10cSrcweir GError *pError = NULL;
517cdf0e10cSrcweir GFileInfo *pInfo = getGFileInfo(xEnv, &pError);
518cdf0e10cSrcweir if (!pInfo)
519cdf0e10cSrcweir ucbhelper::cancelCommandExecution(mapGIOError(pError), xEnv);
520cdf0e10cSrcweir
521cdf0e10cSrcweir return getPropertyValuesFromGFileInfo(pInfo, m_xSMgr, xEnv, rProperties);
522cdf0e10cSrcweir }
523cdf0e10cSrcweir
524cdf0e10cSrcweir static lang::IllegalAccessException
getReadOnlyException(const uno::Reference<uno::XInterface> & rContext)525cdf0e10cSrcweir getReadOnlyException( const uno::Reference< uno::XInterface >& rContext )
526cdf0e10cSrcweir {
527cdf0e10cSrcweir return lang::IllegalAccessException ( rtl::OUString::createFromAscii( "Property is read-only!" ), rContext );
528cdf0e10cSrcweir }
529cdf0e10cSrcweir
queryChildren(ContentRefList & rChildren)530cdf0e10cSrcweir void Content::queryChildren( ContentRefList& rChildren )
531cdf0e10cSrcweir {
532cdf0e10cSrcweir // Obtain a list with a snapshot of all currently instanciated contents
533cdf0e10cSrcweir // from provider and extract the contents which are direct children
534cdf0e10cSrcweir // of this content.
535cdf0e10cSrcweir
536cdf0e10cSrcweir ucbhelper::ContentRefList aAllContents;
537cdf0e10cSrcweir m_xProvider->queryExistingContents( aAllContents );
538cdf0e10cSrcweir
539cdf0e10cSrcweir rtl::OUString aURL = m_xIdentifier->getContentIdentifier();
540cdf0e10cSrcweir sal_Int32 nURLPos = aURL.lastIndexOf( '/' );
541cdf0e10cSrcweir
542cdf0e10cSrcweir if ( nURLPos != ( aURL.getLength() - 1 ) )
543cdf0e10cSrcweir aURL += rtl::OUString::createFromAscii( "/" );
544cdf0e10cSrcweir
545cdf0e10cSrcweir sal_Int32 nLen = aURL.getLength();
546cdf0e10cSrcweir
547cdf0e10cSrcweir ucbhelper::ContentRefList::const_iterator it = aAllContents.begin();
548cdf0e10cSrcweir ucbhelper::ContentRefList::const_iterator end = aAllContents.end();
549cdf0e10cSrcweir
550cdf0e10cSrcweir while ( it != end )
551cdf0e10cSrcweir {
552cdf0e10cSrcweir ucbhelper::ContentImplHelperRef xChild = (*it);
553cdf0e10cSrcweir rtl::OUString aChildURL = xChild->getIdentifier()->getContentIdentifier();
554cdf0e10cSrcweir
555cdf0e10cSrcweir // Is aURL a prefix of aChildURL?
556cdf0e10cSrcweir if ( ( aChildURL.getLength() > nLen ) && ( aChildURL.compareTo( aURL, nLen ) == 0 ) )
557cdf0e10cSrcweir {
558cdf0e10cSrcweir sal_Int32 nPos = nLen;
559cdf0e10cSrcweir nPos = aChildURL.indexOf( '/', nPos );
560cdf0e10cSrcweir
561cdf0e10cSrcweir if ( ( nPos == -1 ) || ( nPos == ( aChildURL.getLength() - 1 ) ) )
562cdf0e10cSrcweir {
563cdf0e10cSrcweir // No further slashes / only a final slash. It's a child!
564cdf0e10cSrcweir rChildren.push_back( ::gio::Content::ContentRef (static_cast< ::gio::Content * >(xChild.get() ) ) );
565cdf0e10cSrcweir }
566cdf0e10cSrcweir }
567cdf0e10cSrcweir ++it;
568cdf0e10cSrcweir }
569cdf0e10cSrcweir }
570cdf0e10cSrcweir
exchangeIdentity(const uno::Reference<ucb::XContentIdentifier> & xNewId)571cdf0e10cSrcweir sal_Bool Content::exchangeIdentity( const uno::Reference< ucb::XContentIdentifier >& xNewId )
572cdf0e10cSrcweir {
573cdf0e10cSrcweir if ( !xNewId.is() )
574cdf0e10cSrcweir return sal_False;
575cdf0e10cSrcweir
576cdf0e10cSrcweir uno::Reference< ucb::XContent > xThis = this;
577cdf0e10cSrcweir
578cdf0e10cSrcweir if ( mbTransient )
579cdf0e10cSrcweir {
580cdf0e10cSrcweir m_xIdentifier = xNewId;
581cdf0e10cSrcweir return sal_False;
582cdf0e10cSrcweir }
583cdf0e10cSrcweir
584cdf0e10cSrcweir rtl::OUString aOldURL = m_xIdentifier->getContentIdentifier();
585cdf0e10cSrcweir
586cdf0e10cSrcweir // Exchange own identitity.
587cdf0e10cSrcweir if ( exchange( xNewId ) )
588cdf0e10cSrcweir {
589cdf0e10cSrcweir // Process instanciated children...
590cdf0e10cSrcweir ContentRefList aChildren;
591cdf0e10cSrcweir queryChildren( aChildren );
592cdf0e10cSrcweir
593cdf0e10cSrcweir ContentRefList::const_iterator it = aChildren.begin();
594cdf0e10cSrcweir ContentRefList::const_iterator end = aChildren.end();
595cdf0e10cSrcweir
596cdf0e10cSrcweir while ( it != end )
597cdf0e10cSrcweir {
598cdf0e10cSrcweir ContentRef xChild = (*it);
599cdf0e10cSrcweir
600cdf0e10cSrcweir // Create new content identifier for the child...
601cdf0e10cSrcweir uno::Reference< ucb::XContentIdentifier > xOldChildId = xChild->getIdentifier();
602cdf0e10cSrcweir rtl::OUString aOldChildURL = xOldChildId->getContentIdentifier();
603cdf0e10cSrcweir rtl::OUString aNewChildURL = aOldChildURL.replaceAt(
604cdf0e10cSrcweir 0, aOldURL.getLength(), xNewId->getContentIdentifier() );
605cdf0e10cSrcweir
606cdf0e10cSrcweir uno::Reference< ucb::XContentIdentifier > xNewChildId
607cdf0e10cSrcweir = new ::ucbhelper::ContentIdentifier( m_xSMgr, aNewChildURL );
608cdf0e10cSrcweir
609cdf0e10cSrcweir if ( !xChild->exchangeIdentity( xNewChildId ) )
610cdf0e10cSrcweir return sal_False;
611cdf0e10cSrcweir
612cdf0e10cSrcweir ++it;
613cdf0e10cSrcweir }
614cdf0e10cSrcweir return sal_True;
615cdf0e10cSrcweir }
616cdf0e10cSrcweir
617cdf0e10cSrcweir return sal_False;
618cdf0e10cSrcweir }
619cdf0e10cSrcweir
setPropertyValues(const uno::Sequence<beans::PropertyValue> & rValues,const uno::Reference<ucb::XCommandEnvironment> & xEnv)620cdf0e10cSrcweir uno::Sequence< uno::Any > Content::setPropertyValues(
621cdf0e10cSrcweir const uno::Sequence< beans::PropertyValue >& rValues,
622cdf0e10cSrcweir const uno::Reference< ucb::XCommandEnvironment >& xEnv )
623cdf0e10cSrcweir {
624cdf0e10cSrcweir GError *pError=NULL;
625cdf0e10cSrcweir GFileInfo *pNewInfo=NULL;
626cdf0e10cSrcweir GFileInfo *pInfo = getGFileInfo(xEnv, &pError);
627cdf0e10cSrcweir if (pInfo)
628cdf0e10cSrcweir pNewInfo = g_file_info_dup(pInfo);
629cdf0e10cSrcweir else
630cdf0e10cSrcweir {
631cdf0e10cSrcweir if (!mbTransient)
632cdf0e10cSrcweir ucbhelper::cancelCommandExecution(mapGIOError(pError), xEnv);
633cdf0e10cSrcweir else
634cdf0e10cSrcweir {
635cdf0e10cSrcweir if (pError)
636cdf0e10cSrcweir g_error_free(pError);
637cdf0e10cSrcweir pNewInfo = g_file_info_new();
638cdf0e10cSrcweir }
639cdf0e10cSrcweir }
640cdf0e10cSrcweir
641cdf0e10cSrcweir sal_Int32 nCount = rValues.getLength();
642cdf0e10cSrcweir
643cdf0e10cSrcweir beans::PropertyChangeEvent aEvent;
644cdf0e10cSrcweir aEvent.Source = static_cast< cppu::OWeakObject * >( this );
645cdf0e10cSrcweir aEvent.Further = sal_False;
646cdf0e10cSrcweir aEvent.PropertyHandle = -1;
647cdf0e10cSrcweir
648cdf0e10cSrcweir sal_Int32 nChanged = 0, nTitlePos = -1;
649cdf0e10cSrcweir const char *newName = NULL;
650cdf0e10cSrcweir uno::Sequence< beans::PropertyChangeEvent > aChanges(nCount);
651cdf0e10cSrcweir
652cdf0e10cSrcweir uno::Sequence< uno::Any > aRet( nCount );
653cdf0e10cSrcweir const beans::PropertyValue* pValues = rValues.getConstArray();
654cdf0e10cSrcweir for ( sal_Int32 n = 0; n < nCount; ++n )
655cdf0e10cSrcweir {
656cdf0e10cSrcweir const beans::PropertyValue& rValue = pValues[ n ];
657cdf0e10cSrcweir #ifdef DEBUG
658cdf0e10cSrcweir g_warning("Set prop '%s'", rtl::OUStringToOString(rValue.Name, RTL_TEXTENCODING_UTF8).getStr());
659cdf0e10cSrcweir #endif
660cdf0e10cSrcweir if ( rValue.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "ContentType" ) ) ||
661cdf0e10cSrcweir rValue.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "MediaType" ) ) ||
662cdf0e10cSrcweir rValue.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "IsDocument" ) ) ||
663cdf0e10cSrcweir rValue.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "IsFolder" ) ) ||
664cdf0e10cSrcweir rValue.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Size" ) ) ||
665cdf0e10cSrcweir rValue.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "CreatableContentsInfo" ) ) )
666cdf0e10cSrcweir {
667cdf0e10cSrcweir aRet[ n ] <<= getReadOnlyException( static_cast< cppu::OWeakObject * >(this) );
668cdf0e10cSrcweir }
669cdf0e10cSrcweir else if ( rValue.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Title" ) ) )
670cdf0e10cSrcweir {
671cdf0e10cSrcweir rtl::OUString aNewTitle;
672cdf0e10cSrcweir if (!( rValue.Value >>= aNewTitle ))
673cdf0e10cSrcweir {
674cdf0e10cSrcweir aRet[ n ] <<= beans::IllegalTypeException
675cdf0e10cSrcweir ( rtl::OUString::createFromAscii( "Property value has wrong type!" ),
676cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ) );
677cdf0e10cSrcweir continue;
678cdf0e10cSrcweir }
679cdf0e10cSrcweir
680cdf0e10cSrcweir if ( aNewTitle.getLength() <= 0 )
681cdf0e10cSrcweir {
682cdf0e10cSrcweir aRet[ n ] <<= lang::IllegalArgumentException
683cdf0e10cSrcweir ( rtl::OUString::createFromAscii( "Empty title not allowed!" ),
684cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ), -1 );
685cdf0e10cSrcweir continue;
686cdf0e10cSrcweir
687cdf0e10cSrcweir }
688cdf0e10cSrcweir
689cdf0e10cSrcweir rtl::OString sNewTitle = OUStringToOString(aNewTitle, RTL_TEXTENCODING_UTF8);
690cdf0e10cSrcweir newName = sNewTitle.getStr();
691cdf0e10cSrcweir const char *oldName = g_file_info_get_name( pInfo);
692cdf0e10cSrcweir
693cdf0e10cSrcweir if (!newName || !oldName || strcmp(newName, oldName))
694cdf0e10cSrcweir {
695cdf0e10cSrcweir #ifdef DEBUG
696cdf0e10cSrcweir g_warning ("Set new name to '%s'", newName);
697cdf0e10cSrcweir #endif
698cdf0e10cSrcweir
699cdf0e10cSrcweir aEvent.PropertyName = rtl::OUString::createFromAscii( "Title" );
700cdf0e10cSrcweir if (oldName)
701cdf0e10cSrcweir aEvent.OldValue = uno::makeAny(rtl::OUString(oldName, strlen(oldName), RTL_TEXTENCODING_UTF8));
702cdf0e10cSrcweir aEvent.NewValue = uno::makeAny(aNewTitle);
703cdf0e10cSrcweir aChanges.getArray()[ nChanged ] = aEvent;
704cdf0e10cSrcweir nTitlePos = nChanged++;
705cdf0e10cSrcweir
706cdf0e10cSrcweir g_file_info_set_name(pNewInfo, newName);
707cdf0e10cSrcweir }
708cdf0e10cSrcweir }
709cdf0e10cSrcweir else
710cdf0e10cSrcweir {
711cdf0e10cSrcweir #ifdef DEBUG
712cdf0e10cSrcweir fprintf(stderr, "Unknown property %s\n", rtl::OUStringToOString(rValue.Name, RTL_TEXTENCODING_UTF8).getStr());
713cdf0e10cSrcweir #endif
714cdf0e10cSrcweir aRet[ n ] <<= getReadOnlyException( static_cast< cppu::OWeakObject * >(this) );
715cdf0e10cSrcweir //TODO
716cdf0e10cSrcweir }
717cdf0e10cSrcweir }
718cdf0e10cSrcweir
719cdf0e10cSrcweir if (nChanged)
720cdf0e10cSrcweir {
721cdf0e10cSrcweir bool bOk = true;
722cdf0e10cSrcweir if (!mbTransient)
723cdf0e10cSrcweir {
724cdf0e10cSrcweir if ((bOk = doSetFileInfo(pNewInfo)))
725cdf0e10cSrcweir {
726cdf0e10cSrcweir for (sal_Int32 i = 0; i < nChanged; ++i)
727cdf0e10cSrcweir aRet[ i ] <<= getBadArgExcept();
728cdf0e10cSrcweir }
729cdf0e10cSrcweir }
730cdf0e10cSrcweir
731cdf0e10cSrcweir if (bOk)
732cdf0e10cSrcweir {
733cdf0e10cSrcweir if (nTitlePos > -1)
734cdf0e10cSrcweir {
735cdf0e10cSrcweir rtl::OUString aNewURL = getParentURL();
736cdf0e10cSrcweir aNewURL += rtl::OUString( newName, strlen(newName), RTL_TEXTENCODING_UTF8 );
737cdf0e10cSrcweir uno::Reference< ucb::XContentIdentifier > xNewId
738cdf0e10cSrcweir = new ::ucbhelper::ContentIdentifier( m_xSMgr, aNewURL );
739cdf0e10cSrcweir
740cdf0e10cSrcweir if (!exchangeIdentity( xNewId ) )
741cdf0e10cSrcweir {
742cdf0e10cSrcweir aRet[ nTitlePos ] <<= uno::Exception
743cdf0e10cSrcweir ( rtl::OUString::createFromAscii( "Exchange failed!" ),
744cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ) );
745cdf0e10cSrcweir }
746cdf0e10cSrcweir }
747cdf0e10cSrcweir
748cdf0e10cSrcweir if (!mbTransient) //Discard and refetch
749cdf0e10cSrcweir {
750cdf0e10cSrcweir g_object_unref(mpInfo);
751cdf0e10cSrcweir mpInfo = NULL;
752cdf0e10cSrcweir }
753cdf0e10cSrcweir
754cdf0e10cSrcweir if (mpInfo)
755cdf0e10cSrcweir {
756cdf0e10cSrcweir g_file_info_copy_into(pNewInfo, mpInfo);
757cdf0e10cSrcweir g_object_unref(pNewInfo);
758cdf0e10cSrcweir }
759cdf0e10cSrcweir else
760cdf0e10cSrcweir mpInfo = pNewInfo;
761cdf0e10cSrcweir
762cdf0e10cSrcweir if (mpFile) //Discard and refetch
763cdf0e10cSrcweir {
764cdf0e10cSrcweir g_object_unref(mpFile);
765cdf0e10cSrcweir mpFile = NULL;
766cdf0e10cSrcweir }
767cdf0e10cSrcweir }
768cdf0e10cSrcweir
769cdf0e10cSrcweir aChanges.realloc( nChanged );
770cdf0e10cSrcweir notifyPropertiesChange( aChanges );
771cdf0e10cSrcweir }
772cdf0e10cSrcweir
773cdf0e10cSrcweir return aRet;
774cdf0e10cSrcweir }
775cdf0e10cSrcweir
doSetFileInfo(GFileInfo * pNewInfo)776cdf0e10cSrcweir bool Content::doSetFileInfo(GFileInfo *pNewInfo)
777cdf0e10cSrcweir {
778cdf0e10cSrcweir g_assert (!mbTransient);
779cdf0e10cSrcweir
780cdf0e10cSrcweir bool bOk = true;
781cdf0e10cSrcweir GFile *pFile = getGFile();
782cdf0e10cSrcweir if(!g_file_set_attributes_from_info(pFile, pNewInfo, G_FILE_QUERY_INFO_NONE, NULL, NULL))
783cdf0e10cSrcweir bOk = false;
784cdf0e10cSrcweir return bOk;
785cdf0e10cSrcweir }
786cdf0e10cSrcweir
787cdf0e10cSrcweir const int TRANSFER_BUFFER_SIZE = 65536;
788cdf0e10cSrcweir
copyData(uno::Reference<io::XInputStream> xIn,uno::Reference<io::XOutputStream> xOut)789cdf0e10cSrcweir void Content::copyData( uno::Reference< io::XInputStream > xIn,
790cdf0e10cSrcweir uno::Reference< io::XOutputStream > xOut )
791cdf0e10cSrcweir {
792cdf0e10cSrcweir uno::Sequence< sal_Int8 > theData( TRANSFER_BUFFER_SIZE );
793cdf0e10cSrcweir
794cdf0e10cSrcweir g_return_if_fail( xIn.is() && xOut.is() );
795cdf0e10cSrcweir
796cdf0e10cSrcweir while ( xIn->readBytes( theData, TRANSFER_BUFFER_SIZE ) > 0 )
797cdf0e10cSrcweir xOut->writeBytes( theData );
798cdf0e10cSrcweir
799cdf0e10cSrcweir xOut->closeOutput();
800cdf0e10cSrcweir }
801cdf0e10cSrcweir
feedSink(uno::Reference<uno::XInterface> xSink,const uno::Reference<ucb::XCommandEnvironment> &)802cdf0e10cSrcweir sal_Bool Content::feedSink( uno::Reference< uno::XInterface > xSink,
803cdf0e10cSrcweir const uno::Reference< ucb::XCommandEnvironment >& /*xEnv*/ )
804cdf0e10cSrcweir {
805cdf0e10cSrcweir if ( !xSink.is() )
806cdf0e10cSrcweir return sal_False;
807cdf0e10cSrcweir
808cdf0e10cSrcweir uno::Reference< io::XOutputStream > xOut = uno::Reference< io::XOutputStream >(xSink, uno::UNO_QUERY );
809cdf0e10cSrcweir uno::Reference< io::XActiveDataSink > xDataSink = uno::Reference< io::XActiveDataSink >(xSink, uno::UNO_QUERY );
810cdf0e10cSrcweir
811cdf0e10cSrcweir if ( !xOut.is() && !xDataSink.is() )
812cdf0e10cSrcweir return sal_False;
813cdf0e10cSrcweir
814cdf0e10cSrcweir GError *pError=NULL;
815cdf0e10cSrcweir GFileInputStream *pStream = g_file_read(getGFile(), NULL, &pError);
816cdf0e10cSrcweir if (!pStream)
817cdf0e10cSrcweir convertToException(pError, static_cast< cppu::OWeakObject * >(this));
818cdf0e10cSrcweir
819cdf0e10cSrcweir uno::Reference< io::XInputStream > xIn = new ::gio::InputStream(pStream);
820cdf0e10cSrcweir if ( !xIn.is() )
821cdf0e10cSrcweir return sal_False;
822cdf0e10cSrcweir
823cdf0e10cSrcweir if ( xOut.is() )
824cdf0e10cSrcweir copyData( xIn, xOut );
825cdf0e10cSrcweir
826cdf0e10cSrcweir if ( xDataSink.is() )
827cdf0e10cSrcweir xDataSink->setInputStream( xIn );
828cdf0e10cSrcweir
829cdf0e10cSrcweir return sal_True;
830cdf0e10cSrcweir }
831cdf0e10cSrcweir
open(const ucb::OpenCommandArgument2 & rOpenCommand,const uno::Reference<ucb::XCommandEnvironment> & xEnv)832cdf0e10cSrcweir uno::Any Content::open(const ucb::OpenCommandArgument2 & rOpenCommand,
833cdf0e10cSrcweir const uno::Reference< ucb::XCommandEnvironment > & xEnv )
834cdf0e10cSrcweir throw( uno::Exception )
835cdf0e10cSrcweir {
836cdf0e10cSrcweir bool bIsFolder = isFolder(xEnv);
837cdf0e10cSrcweir
838cdf0e10cSrcweir if (!g_file_query_exists(getGFile(), NULL))
839cdf0e10cSrcweir {
840cdf0e10cSrcweir uno::Sequence< uno::Any > aArgs( 1 );
841cdf0e10cSrcweir aArgs[ 0 ] <<= m_xIdentifier->getContentIdentifier();
842cdf0e10cSrcweir uno::Any aErr = uno::makeAny(
843cdf0e10cSrcweir ucb::InteractiveAugmentedIOException(rtl::OUString(), static_cast< cppu::OWeakObject * >( this ),
844cdf0e10cSrcweir task::InteractionClassification_ERROR,
845cdf0e10cSrcweir bIsFolder ? ucb::IOErrorCode_NOT_EXISTING_PATH : ucb::IOErrorCode_NOT_EXISTING, aArgs)
846cdf0e10cSrcweir );
847cdf0e10cSrcweir
848cdf0e10cSrcweir ucbhelper::cancelCommandExecution(aErr, xEnv);
849cdf0e10cSrcweir }
850cdf0e10cSrcweir
851cdf0e10cSrcweir uno::Any aRet;
852cdf0e10cSrcweir
853cdf0e10cSrcweir sal_Bool bOpenFolder = (
854cdf0e10cSrcweir ( rOpenCommand.Mode == ucb::OpenMode::ALL ) ||
855cdf0e10cSrcweir ( rOpenCommand.Mode == ucb::OpenMode::FOLDERS ) ||
856cdf0e10cSrcweir ( rOpenCommand.Mode == ucb::OpenMode::DOCUMENTS )
857cdf0e10cSrcweir );
858cdf0e10cSrcweir
859cdf0e10cSrcweir if ( bOpenFolder && bIsFolder )
860cdf0e10cSrcweir {
861cdf0e10cSrcweir uno::Reference< ucb::XDynamicResultSet > xSet
862cdf0e10cSrcweir = new DynamicResultSet(m_xSMgr, this, rOpenCommand, xEnv );
863cdf0e10cSrcweir aRet <<= xSet;
864cdf0e10cSrcweir }
865cdf0e10cSrcweir else if ( rOpenCommand.Sink.is() )
866cdf0e10cSrcweir {
867cdf0e10cSrcweir if (
868cdf0e10cSrcweir ( rOpenCommand.Mode == ucb::OpenMode::DOCUMENT_SHARE_DENY_NONE ) ||
869cdf0e10cSrcweir ( rOpenCommand.Mode == ucb::OpenMode::DOCUMENT_SHARE_DENY_WRITE )
870cdf0e10cSrcweir )
871cdf0e10cSrcweir {
872cdf0e10cSrcweir ucbhelper::cancelCommandExecution(
873cdf0e10cSrcweir uno::makeAny ( ucb::UnsupportedOpenModeException
874cdf0e10cSrcweir ( rtl::OUString(), static_cast< cppu::OWeakObject * >( this ),
875cdf0e10cSrcweir sal_Int16( rOpenCommand.Mode ) ) ),
876cdf0e10cSrcweir xEnv );
877cdf0e10cSrcweir }
878cdf0e10cSrcweir
879cdf0e10cSrcweir if ( !feedSink( rOpenCommand.Sink, xEnv ) )
880cdf0e10cSrcweir {
881cdf0e10cSrcweir // Note: rOpenCommand.Sink may contain an XStream
882cdf0e10cSrcweir // implementation. Support for this type of
883cdf0e10cSrcweir // sink is optional...
884cdf0e10cSrcweir #ifdef DEBUG
885cdf0e10cSrcweir g_warning ("Failed to load data from '%s'",
886cdf0e10cSrcweir rtl::OUStringToOString(m_xIdentifier->getContentIdentifier(), RTL_TEXTENCODING_UTF8).getStr());
887cdf0e10cSrcweir #endif
888cdf0e10cSrcweir
889cdf0e10cSrcweir ucbhelper::cancelCommandExecution(
890cdf0e10cSrcweir uno::makeAny (ucb::UnsupportedDataSinkException
891cdf0e10cSrcweir ( rtl::OUString(), static_cast< cppu::OWeakObject * >( this ),
892cdf0e10cSrcweir rOpenCommand.Sink ) ),
893cdf0e10cSrcweir xEnv );
894cdf0e10cSrcweir }
895cdf0e10cSrcweir }
896cdf0e10cSrcweir else
897cdf0e10cSrcweir g_warning ("Open falling through ...");
898cdf0e10cSrcweir return aRet;
899cdf0e10cSrcweir }
900cdf0e10cSrcweir
execute(const ucb::Command & aCommand,sal_Int32,const uno::Reference<ucb::XCommandEnvironment> & xEnv)901cdf0e10cSrcweir uno::Any SAL_CALL Content::execute(
902cdf0e10cSrcweir const ucb::Command& aCommand,
903cdf0e10cSrcweir sal_Int32 /*CommandId*/,
904cdf0e10cSrcweir const uno::Reference< ucb::XCommandEnvironment >& xEnv )
905cdf0e10cSrcweir throw( uno::Exception,
906cdf0e10cSrcweir ucb::CommandAbortedException,
907cdf0e10cSrcweir uno::RuntimeException )
908cdf0e10cSrcweir {
909cdf0e10cSrcweir #ifdef DEBUG
910cdf0e10cSrcweir fprintf(stderr, "Content::execute %s\n", rtl::OUStringToOString(aCommand.Name, RTL_TEXTENCODING_UTF8).getStr());
911cdf0e10cSrcweir #endif
912cdf0e10cSrcweir uno::Any aRet;
913cdf0e10cSrcweir
914cdf0e10cSrcweir if (aCommand.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "getPropertyValues" ) ))
915cdf0e10cSrcweir {
916cdf0e10cSrcweir uno::Sequence< beans::Property > Properties;
917cdf0e10cSrcweir if ( !( aCommand.Argument >>= Properties ) )
918cdf0e10cSrcweir ucbhelper::cancelCommandExecution ( getBadArgExcept (), xEnv );
919cdf0e10cSrcweir aRet <<= getPropertyValues( Properties, xEnv );
920cdf0e10cSrcweir }
921cdf0e10cSrcweir else if (aCommand.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "getPropertySetInfo" ) ))
922cdf0e10cSrcweir aRet <<= getPropertySetInfo( xEnv, sal_False );
923cdf0e10cSrcweir else if (aCommand.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "getCommandInfo" ) ))
924cdf0e10cSrcweir aRet <<= getCommandInfo( xEnv, sal_False );
925cdf0e10cSrcweir else if (aCommand.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "open" ) ))
926cdf0e10cSrcweir {
927cdf0e10cSrcweir ucb::OpenCommandArgument2 aOpenCommand;
928cdf0e10cSrcweir if ( !( aCommand.Argument >>= aOpenCommand ) )
929cdf0e10cSrcweir ucbhelper::cancelCommandExecution ( getBadArgExcept (), xEnv );
930cdf0e10cSrcweir aRet = open( aOpenCommand, xEnv );
931cdf0e10cSrcweir }
932cdf0e10cSrcweir else if (aCommand.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "transfer" ) ))
933cdf0e10cSrcweir {
934cdf0e10cSrcweir ucb::TransferInfo transferArgs;
935cdf0e10cSrcweir if ( !( aCommand.Argument >>= transferArgs ) )
936cdf0e10cSrcweir ucbhelper::cancelCommandExecution ( getBadArgExcept (), xEnv );
937cdf0e10cSrcweir transfer( transferArgs, xEnv );
938cdf0e10cSrcweir }
939cdf0e10cSrcweir else if (aCommand.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "setPropertyValues" ) ))
940cdf0e10cSrcweir {
941cdf0e10cSrcweir uno::Sequence< beans::PropertyValue > aProperties;
942cdf0e10cSrcweir if ( !( aCommand.Argument >>= aProperties ) || !aProperties.getLength() )
943cdf0e10cSrcweir ucbhelper::cancelCommandExecution ( getBadArgExcept (), xEnv );
944cdf0e10cSrcweir aRet <<= setPropertyValues( aProperties, xEnv );
945cdf0e10cSrcweir }
946cdf0e10cSrcweir else if (aCommand.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "createNewContent" ) )
947cdf0e10cSrcweir && isFolder( xEnv ) )
948cdf0e10cSrcweir {
949cdf0e10cSrcweir ucb::ContentInfo arg;
950cdf0e10cSrcweir if ( !( aCommand.Argument >>= arg ) )
951cdf0e10cSrcweir ucbhelper::cancelCommandExecution ( getBadArgExcept (), xEnv );
952cdf0e10cSrcweir aRet <<= createNewContent( arg );
953cdf0e10cSrcweir }
954cdf0e10cSrcweir else if (aCommand.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "insert" ) ))
955cdf0e10cSrcweir {
956cdf0e10cSrcweir ucb::InsertCommandArgument arg;
957cdf0e10cSrcweir if ( !( aCommand.Argument >>= arg ) )
958cdf0e10cSrcweir ucbhelper::cancelCommandExecution ( getBadArgExcept (), xEnv );
959cdf0e10cSrcweir insert( arg.Data, arg.ReplaceExisting, xEnv );
960cdf0e10cSrcweir }
961cdf0e10cSrcweir else if (aCommand.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "delete" ) ))
962cdf0e10cSrcweir {
963cdf0e10cSrcweir sal_Bool bDeletePhysical = sal_False;
964cdf0e10cSrcweir aCommand.Argument >>= bDeletePhysical;
965cdf0e10cSrcweir
966cdf0e10cSrcweir //If no delete physical, try and trashcan it, if that doesn't work go
967cdf0e10cSrcweir //ahead and try and delete it anyway
968cdf0e10cSrcweir if (!bDeletePhysical && !g_file_trash(getGFile(), NULL, NULL))
969cdf0e10cSrcweir bDeletePhysical = true;
970cdf0e10cSrcweir
971cdf0e10cSrcweir if (bDeletePhysical)
972cdf0e10cSrcweir {
973cdf0e10cSrcweir GError *pError = NULL;
974cdf0e10cSrcweir if (!g_file_delete( getGFile(), NULL, &pError))
975cdf0e10cSrcweir ucbhelper::cancelCommandExecution(mapGIOError(pError), xEnv);
976cdf0e10cSrcweir }
977cdf0e10cSrcweir
978cdf0e10cSrcweir destroy( bDeletePhysical );
979cdf0e10cSrcweir }
980cdf0e10cSrcweir else
981cdf0e10cSrcweir {
982cdf0e10cSrcweir #ifdef DEBUG
983cdf0e10cSrcweir fprintf(stderr, "UNKNOWN COMMAND\n");
984cdf0e10cSrcweir //TODO
985cdf0e10cSrcweir #endif
986cdf0e10cSrcweir
987cdf0e10cSrcweir ucbhelper::cancelCommandExecution
988cdf0e10cSrcweir ( uno::makeAny( ucb::UnsupportedCommandException
989cdf0e10cSrcweir ( rtl::OUString(),
990cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ) ) ),
991cdf0e10cSrcweir xEnv );
992cdf0e10cSrcweir }
993cdf0e10cSrcweir
994cdf0e10cSrcweir return aRet;
995cdf0e10cSrcweir }
996cdf0e10cSrcweir
destroy(sal_Bool bDeletePhysical)997cdf0e10cSrcweir void Content::destroy( sal_Bool bDeletePhysical )
998cdf0e10cSrcweir throw( uno::Exception )
999cdf0e10cSrcweir {
1000cdf0e10cSrcweir uno::Reference< ucb::XContent > xThis = this;
1001cdf0e10cSrcweir
1002cdf0e10cSrcweir deleted();
1003cdf0e10cSrcweir
1004cdf0e10cSrcweir ::gio::Content::ContentRefList aChildren;
1005cdf0e10cSrcweir queryChildren( aChildren );
1006cdf0e10cSrcweir
1007cdf0e10cSrcweir ContentRefList::const_iterator it = aChildren.begin();
1008cdf0e10cSrcweir ContentRefList::const_iterator end = aChildren.end();
1009cdf0e10cSrcweir
1010cdf0e10cSrcweir while ( it != end )
1011cdf0e10cSrcweir {
1012cdf0e10cSrcweir (*it)->destroy( bDeletePhysical );
1013cdf0e10cSrcweir ++it;
1014cdf0e10cSrcweir }
1015cdf0e10cSrcweir }
1016cdf0e10cSrcweir
insert(const uno::Reference<io::XInputStream> & xInputStream,sal_Bool bReplaceExisting,const uno::Reference<ucb::XCommandEnvironment> & xEnv)1017cdf0e10cSrcweir void Content::insert(const uno::Reference< io::XInputStream > &xInputStream,
1018cdf0e10cSrcweir sal_Bool bReplaceExisting, const uno::Reference< ucb::XCommandEnvironment > &xEnv )
1019cdf0e10cSrcweir throw( uno::Exception )
1020cdf0e10cSrcweir {
1021cdf0e10cSrcweir GError *pError = NULL;
1022cdf0e10cSrcweir GFileInfo *pInfo = getGFileInfo(xEnv);
1023cdf0e10cSrcweir
1024cdf0e10cSrcweir if ( g_file_info_has_attribute(pInfo, G_FILE_ATTRIBUTE_STANDARD_TYPE) &&
1025cdf0e10cSrcweir g_file_info_get_file_type(pInfo) == G_FILE_TYPE_DIRECTORY )
1026cdf0e10cSrcweir {
1027cdf0e10cSrcweir #ifdef DEBUG
1028cdf0e10cSrcweir g_warning ("Make directory");
1029cdf0e10cSrcweir #endif
1030cdf0e10cSrcweir if( !g_file_make_directory( getGFile(), NULL, &pError))
1031cdf0e10cSrcweir ucbhelper::cancelCommandExecution(mapGIOError(pError), xEnv);
1032cdf0e10cSrcweir return;
1033cdf0e10cSrcweir }
1034cdf0e10cSrcweir
1035cdf0e10cSrcweir if ( !xInputStream.is() )
1036cdf0e10cSrcweir {
1037cdf0e10cSrcweir ucbhelper::cancelCommandExecution( uno::makeAny
1038cdf0e10cSrcweir ( ucb::MissingInputStreamException
1039cdf0e10cSrcweir ( rtl::OUString(), static_cast< cppu::OWeakObject * >( this ) ) ),
1040cdf0e10cSrcweir xEnv );
1041cdf0e10cSrcweir }
1042cdf0e10cSrcweir
1043cdf0e10cSrcweir GFileOutputStream* pOutStream = NULL;
1044cdf0e10cSrcweir if ( bReplaceExisting )
1045cdf0e10cSrcweir {
1046cdf0e10cSrcweir if (!(pOutStream = g_file_replace(getGFile(), NULL, false, G_FILE_CREATE_PRIVATE, NULL, &pError)))
1047cdf0e10cSrcweir ucbhelper::cancelCommandExecution(mapGIOError(pError), xEnv);
1048cdf0e10cSrcweir }
1049cdf0e10cSrcweir else
1050cdf0e10cSrcweir {
1051cdf0e10cSrcweir if (!(pOutStream = g_file_create (getGFile(), G_FILE_CREATE_PRIVATE, NULL, &pError)))
1052cdf0e10cSrcweir ucbhelper::cancelCommandExecution(mapGIOError(pError), xEnv);
1053cdf0e10cSrcweir }
1054cdf0e10cSrcweir
1055cdf0e10cSrcweir uno::Reference < io::XOutputStream > xOutput = new ::gio::OutputStream(pOutStream);
1056cdf0e10cSrcweir copyData( xInputStream, xOutput );
1057cdf0e10cSrcweir
1058cdf0e10cSrcweir if (mbTransient)
1059cdf0e10cSrcweir {
1060cdf0e10cSrcweir mbTransient = sal_False;
1061cdf0e10cSrcweir inserted();
1062cdf0e10cSrcweir }
1063cdf0e10cSrcweir }
1064cdf0e10cSrcweir
transfer(const ucb::TransferInfo & aTransferInfo,const uno::Reference<ucb::XCommandEnvironment> & xEnv)1065cdf0e10cSrcweir void Content::transfer( const ucb::TransferInfo& aTransferInfo, const uno::Reference< ucb::XCommandEnvironment >& xEnv )
1066cdf0e10cSrcweir throw( uno::Exception )
1067cdf0e10cSrcweir {
1068cdf0e10cSrcweir rtl::OUString sDest = m_xIdentifier->getContentIdentifier();
1069cdf0e10cSrcweir if (aTransferInfo.NewTitle.getLength())
1070cdf0e10cSrcweir sDest += aTransferInfo.NewTitle;
1071cdf0e10cSrcweir else
1072cdf0e10cSrcweir sDest += rtl::OUString::createFromAscii(g_file_get_basename(getGFile()));
1073cdf0e10cSrcweir
1074cdf0e10cSrcweir GFile *pDest = g_file_new_for_uri(rtl::OUStringToOString(sDest, RTL_TEXTENCODING_UTF8).getStr());
1075cdf0e10cSrcweir GFile *pSource = g_file_new_for_uri(rtl::OUStringToOString(aTransferInfo.SourceURL, RTL_TEXTENCODING_UTF8).getStr());
1076cdf0e10cSrcweir
1077cdf0e10cSrcweir gboolean bSuccess = false;
1078cdf0e10cSrcweir GError *pError = NULL;
1079cdf0e10cSrcweir if (aTransferInfo.MoveData)
1080cdf0e10cSrcweir bSuccess = g_file_move(pSource, pDest, G_FILE_COPY_OVERWRITE, NULL, NULL, 0, &pError);
1081cdf0e10cSrcweir else
1082cdf0e10cSrcweir bSuccess = g_file_copy(pSource, pDest, G_FILE_COPY_OVERWRITE, NULL, NULL, 0, &pError);
1083cdf0e10cSrcweir g_object_unref(pSource);
1084cdf0e10cSrcweir g_object_unref(pDest);
1085cdf0e10cSrcweir if (!bSuccess)
1086cdf0e10cSrcweir ucbhelper::cancelCommandExecution(mapGIOError(pError), xEnv);
1087cdf0e10cSrcweir }
1088cdf0e10cSrcweir
queryCreatableContentsInfo(const uno::Reference<ucb::XCommandEnvironment> & xEnv)1089cdf0e10cSrcweir uno::Sequence< ucb::ContentInfo > Content::queryCreatableContentsInfo(
1090cdf0e10cSrcweir const uno::Reference< ucb::XCommandEnvironment >& xEnv)
1091cdf0e10cSrcweir throw( uno::RuntimeException )
1092cdf0e10cSrcweir {
1093cdf0e10cSrcweir if ( isFolder( xEnv ) )
1094cdf0e10cSrcweir {
1095cdf0e10cSrcweir uno::Sequence< ucb::ContentInfo > seq(2);
1096cdf0e10cSrcweir
1097cdf0e10cSrcweir // Minimum set of props we really need
1098cdf0e10cSrcweir uno::Sequence< beans::Property > props( 1 );
1099cdf0e10cSrcweir props[0] = beans::Property(
1100cdf0e10cSrcweir rtl::OUString::createFromAscii( "Title" ),
1101cdf0e10cSrcweir -1,
1102cdf0e10cSrcweir getCppuType( static_cast< rtl::OUString* >( 0 ) ),
1103cdf0e10cSrcweir beans::PropertyAttribute::MAYBEVOID | beans::PropertyAttribute::BOUND );
1104cdf0e10cSrcweir
1105cdf0e10cSrcweir // file
1106cdf0e10cSrcweir seq[0].Type = rtl::OUString::createFromAscii( GIO_FILE_TYPE );
1107cdf0e10cSrcweir seq[0].Attributes = ( ucb::ContentInfoAttribute::INSERT_WITH_INPUTSTREAM |
1108cdf0e10cSrcweir ucb::ContentInfoAttribute::KIND_DOCUMENT );
1109cdf0e10cSrcweir seq[0].Properties = props;
1110cdf0e10cSrcweir
1111cdf0e10cSrcweir // folder
1112cdf0e10cSrcweir seq[1].Type = rtl::OUString::createFromAscii( GIO_FOLDER_TYPE );
1113cdf0e10cSrcweir seq[1].Attributes = ucb::ContentInfoAttribute::KIND_FOLDER;
1114cdf0e10cSrcweir seq[1].Properties = props;
1115cdf0e10cSrcweir
1116cdf0e10cSrcweir return seq;
1117cdf0e10cSrcweir }
1118cdf0e10cSrcweir else
1119cdf0e10cSrcweir {
1120cdf0e10cSrcweir return uno::Sequence< ucb::ContentInfo >();
1121cdf0e10cSrcweir }
1122cdf0e10cSrcweir }
1123cdf0e10cSrcweir
queryCreatableContentsInfo()1124cdf0e10cSrcweir uno::Sequence< ucb::ContentInfo > SAL_CALL Content::queryCreatableContentsInfo()
1125cdf0e10cSrcweir throw( uno::RuntimeException )
1126cdf0e10cSrcweir {
1127cdf0e10cSrcweir return queryCreatableContentsInfo( uno::Reference< ucb::XCommandEnvironment >() );
1128cdf0e10cSrcweir }
1129cdf0e10cSrcweir
1130cdf0e10cSrcweir uno::Reference< ucb::XContent >
createNewContent(const ucb::ContentInfo & Info)1131cdf0e10cSrcweir SAL_CALL Content::createNewContent( const ucb::ContentInfo& Info )
1132cdf0e10cSrcweir throw( uno::RuntimeException )
1133cdf0e10cSrcweir {
1134cdf0e10cSrcweir bool create_document;
1135cdf0e10cSrcweir const char *name;
1136cdf0e10cSrcweir
1137cdf0e10cSrcweir if ( Info.Type.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( GIO_FILE_TYPE ) ) )
1138cdf0e10cSrcweir create_document = true;
1139cdf0e10cSrcweir else if ( Info.Type.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( GIO_FOLDER_TYPE ) ) )
1140cdf0e10cSrcweir create_document = false;
1141cdf0e10cSrcweir else
1142cdf0e10cSrcweir {
1143cdf0e10cSrcweir #ifdef DEBUG
1144cdf0e10cSrcweir g_warning( "Failed to create new content '%s'", rtl::OUStringToOString(Info.Type,
1145cdf0e10cSrcweir RTL_TEXTENCODING_UTF8).getStr() );
1146cdf0e10cSrcweir #endif
1147cdf0e10cSrcweir return uno::Reference< ucb::XContent >();
1148cdf0e10cSrcweir }
1149cdf0e10cSrcweir
1150cdf0e10cSrcweir #ifdef DEBUG
1151cdf0e10cSrcweir g_warning( "createNewContent (%d)", (int) create_document );
1152cdf0e10cSrcweir #endif
1153cdf0e10cSrcweir
1154cdf0e10cSrcweir rtl::OUString aURL = m_xIdentifier->getContentIdentifier();
1155cdf0e10cSrcweir
1156cdf0e10cSrcweir if ( ( aURL.lastIndexOf( '/' ) + 1 ) != aURL.getLength() )
1157cdf0e10cSrcweir aURL += rtl::OUString::createFromAscii( "/" );
1158cdf0e10cSrcweir
1159cdf0e10cSrcweir name = create_document ? "[New_Content]" : "[New_Collection]";
1160cdf0e10cSrcweir aURL += rtl::OUString::createFromAscii( name );
1161cdf0e10cSrcweir
1162cdf0e10cSrcweir uno::Reference< ucb::XContentIdentifier > xId(new ::ucbhelper::ContentIdentifier(m_xSMgr, aURL));
1163cdf0e10cSrcweir
1164cdf0e10cSrcweir try
1165cdf0e10cSrcweir {
1166cdf0e10cSrcweir return new ::gio::Content( m_xSMgr, m_pProvider, xId, !create_document );
1167cdf0e10cSrcweir } catch ( ucb::ContentCreationException & )
1168cdf0e10cSrcweir {
1169cdf0e10cSrcweir return uno::Reference< ucb::XContent >();
1170cdf0e10cSrcweir }
1171cdf0e10cSrcweir }
1172cdf0e10cSrcweir
getTypes()1173cdf0e10cSrcweir uno::Sequence< uno::Type > SAL_CALL Content::getTypes()
1174cdf0e10cSrcweir throw( uno::RuntimeException )
1175cdf0e10cSrcweir {
1176cdf0e10cSrcweir if ( isFolder( uno::Reference< ucb::XCommandEnvironment >() ) )
1177cdf0e10cSrcweir {
1178cdf0e10cSrcweir static cppu::OTypeCollection aFolderCollection
1179cdf0e10cSrcweir (CPPU_TYPE_REF( lang::XTypeProvider ),
1180cdf0e10cSrcweir CPPU_TYPE_REF( lang::XServiceInfo ),
1181cdf0e10cSrcweir CPPU_TYPE_REF( lang::XComponent ),
1182cdf0e10cSrcweir CPPU_TYPE_REF( ucb::XContent ),
1183cdf0e10cSrcweir CPPU_TYPE_REF( ucb::XCommandProcessor ),
1184cdf0e10cSrcweir CPPU_TYPE_REF( beans::XPropertiesChangeNotifier ),
1185cdf0e10cSrcweir CPPU_TYPE_REF( ucb::XCommandInfoChangeNotifier ),
1186cdf0e10cSrcweir CPPU_TYPE_REF( beans::XPropertyContainer ),
1187cdf0e10cSrcweir CPPU_TYPE_REF( beans::XPropertySetInfoChangeNotifier ),
1188cdf0e10cSrcweir CPPU_TYPE_REF( container::XChild ),
1189cdf0e10cSrcweir CPPU_TYPE_REF( ucb::XContentCreator ) );
1190cdf0e10cSrcweir return aFolderCollection.getTypes();
1191cdf0e10cSrcweir }
1192cdf0e10cSrcweir else
1193cdf0e10cSrcweir {
1194cdf0e10cSrcweir static cppu::OTypeCollection aFileCollection
1195cdf0e10cSrcweir (CPPU_TYPE_REF( lang::XTypeProvider ),
1196cdf0e10cSrcweir CPPU_TYPE_REF( lang::XServiceInfo ),
1197cdf0e10cSrcweir CPPU_TYPE_REF( lang::XComponent ),
1198cdf0e10cSrcweir CPPU_TYPE_REF( ucb::XContent ),
1199cdf0e10cSrcweir CPPU_TYPE_REF( ucb::XCommandProcessor ),
1200cdf0e10cSrcweir CPPU_TYPE_REF( beans::XPropertiesChangeNotifier ),
1201cdf0e10cSrcweir CPPU_TYPE_REF( ucb::XCommandInfoChangeNotifier ),
1202cdf0e10cSrcweir CPPU_TYPE_REF( beans::XPropertyContainer ),
1203cdf0e10cSrcweir CPPU_TYPE_REF( beans::XPropertySetInfoChangeNotifier ),
1204cdf0e10cSrcweir CPPU_TYPE_REF( container::XChild ) );
1205cdf0e10cSrcweir
1206cdf0e10cSrcweir return aFileCollection.getTypes();
1207cdf0e10cSrcweir }
1208cdf0e10cSrcweir }
1209cdf0e10cSrcweir
getProperties(const uno::Reference<ucb::XCommandEnvironment> &)1210cdf0e10cSrcweir uno::Sequence< beans::Property > Content::getProperties(
1211cdf0e10cSrcweir const uno::Reference< ucb::XCommandEnvironment > & /*xEnv*/ )
1212cdf0e10cSrcweir {
1213cdf0e10cSrcweir static const beans::Property aGenericProperties[] =
1214cdf0e10cSrcweir {
1215cdf0e10cSrcweir beans::Property( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsDocument" ) ),
1216cdf0e10cSrcweir -1, getCppuBooleanType(),
1217cdf0e10cSrcweir beans::PropertyAttribute::BOUND | beans::PropertyAttribute::READONLY ),
1218cdf0e10cSrcweir beans::Property( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsFolder" ) ),
1219cdf0e10cSrcweir -1, getCppuBooleanType(),
1220cdf0e10cSrcweir beans::PropertyAttribute::BOUND | beans::PropertyAttribute::READONLY ),
1221cdf0e10cSrcweir beans::Property( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Title" ) ),
1222cdf0e10cSrcweir -1, getCppuType( static_cast< const rtl::OUString * >( 0 ) ),
1223cdf0e10cSrcweir beans::PropertyAttribute::BOUND ),
1224cdf0e10cSrcweir beans::Property( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsReadOnly" ) ),
1225cdf0e10cSrcweir -1, getCppuBooleanType(),
1226cdf0e10cSrcweir beans::PropertyAttribute::BOUND | beans::PropertyAttribute::READONLY ),
1227cdf0e10cSrcweir beans::Property( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DateCreated" ) ),
1228cdf0e10cSrcweir -1, getCppuType( static_cast< const util::DateTime * >( 0 ) ),
1229cdf0e10cSrcweir beans::PropertyAttribute::BOUND | beans::PropertyAttribute::READONLY ),
1230cdf0e10cSrcweir beans::Property( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DateModified" ) ),
1231cdf0e10cSrcweir -1, getCppuType( static_cast< const util::DateTime * >( 0 ) ),
1232cdf0e10cSrcweir beans::PropertyAttribute::BOUND | beans::PropertyAttribute::READONLY ),
1233cdf0e10cSrcweir beans::Property( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Size" ) ),
1234cdf0e10cSrcweir -1, getCppuType( static_cast< const sal_Int64 * >( 0 ) ),
1235cdf0e10cSrcweir beans::PropertyAttribute::BOUND | beans::PropertyAttribute::READONLY ),
1236cdf0e10cSrcweir beans::Property( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsVolume" ) ),
1237cdf0e10cSrcweir -1, getCppuBooleanType(),
1238cdf0e10cSrcweir beans::PropertyAttribute::BOUND | beans::PropertyAttribute::READONLY ),
1239cdf0e10cSrcweir beans::Property( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsCompactDisc" ) ),
1240cdf0e10cSrcweir -1, getCppuBooleanType(),
1241cdf0e10cSrcweir beans::PropertyAttribute::BOUND | beans::PropertyAttribute::READONLY ),
1242cdf0e10cSrcweir beans::Property( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsRemoveable" ) ),
1243cdf0e10cSrcweir -1, getCppuBooleanType(),
1244cdf0e10cSrcweir beans::PropertyAttribute::BOUND | beans::PropertyAttribute::READONLY ),
1245cdf0e10cSrcweir beans::Property( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsHidden" ) ),
1246cdf0e10cSrcweir -1, getCppuBooleanType(),
1247cdf0e10cSrcweir beans::PropertyAttribute::BOUND | beans::PropertyAttribute::READONLY ),
1248cdf0e10cSrcweir beans::Property( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CreatableContentsInfo" ) ),
1249cdf0e10cSrcweir -1, getCppuType( static_cast< const uno::Sequence< ucb::ContentInfo > * >( 0 ) ),
1250cdf0e10cSrcweir beans::PropertyAttribute::BOUND | beans::PropertyAttribute::READONLY )
1251cdf0e10cSrcweir };
1252cdf0e10cSrcweir
1253cdf0e10cSrcweir const int nProps = sizeof (aGenericProperties) / sizeof (aGenericProperties[0]);
1254cdf0e10cSrcweir return uno::Sequence< beans::Property > ( aGenericProperties, nProps );
1255cdf0e10cSrcweir }
1256cdf0e10cSrcweir
getCommands(const uno::Reference<ucb::XCommandEnvironment> & xEnv)1257cdf0e10cSrcweir uno::Sequence< ucb::CommandInfo > Content::getCommands( const uno::Reference< ucb::XCommandEnvironment > & xEnv)
1258cdf0e10cSrcweir {
1259cdf0e10cSrcweir static ucb::CommandInfo aCommandInfoTable[] =
1260cdf0e10cSrcweir {
1261cdf0e10cSrcweir // Required commands
1262cdf0e10cSrcweir ucb::CommandInfo
1263cdf0e10cSrcweir ( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "getCommandInfo" ) ),
1264cdf0e10cSrcweir -1, getCppuVoidType() ),
1265cdf0e10cSrcweir ucb::CommandInfo
1266cdf0e10cSrcweir ( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "getPropertySetInfo" ) ),
1267cdf0e10cSrcweir -1, getCppuVoidType() ),
1268cdf0e10cSrcweir ucb::CommandInfo
1269cdf0e10cSrcweir ( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "getPropertyValues" ) ),
1270cdf0e10cSrcweir -1, getCppuType( static_cast<uno::Sequence< beans::Property > * >( 0 ) ) ),
1271cdf0e10cSrcweir ucb::CommandInfo
1272cdf0e10cSrcweir ( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "setPropertyValues" ) ),
1273cdf0e10cSrcweir -1, getCppuType( static_cast<uno::Sequence< beans::PropertyValue > * >( 0 ) ) ),
1274cdf0e10cSrcweir
1275cdf0e10cSrcweir // Optional standard commands
1276cdf0e10cSrcweir ucb::CommandInfo
1277cdf0e10cSrcweir ( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "delete" ) ),
1278cdf0e10cSrcweir -1, getCppuBooleanType() ),
1279cdf0e10cSrcweir ucb::CommandInfo
1280cdf0e10cSrcweir ( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "insert" ) ),
1281cdf0e10cSrcweir -1, getCppuType( static_cast<ucb::InsertCommandArgument * >( 0 ) ) ),
1282cdf0e10cSrcweir ucb::CommandInfo
1283cdf0e10cSrcweir ( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "open" ) ),
1284cdf0e10cSrcweir -1, getCppuType( static_cast<ucb::OpenCommandArgument2 * >( 0 ) ) ),
1285cdf0e10cSrcweir
1286cdf0e10cSrcweir // Folder Only, omitted if not a folder
1287cdf0e10cSrcweir ucb::CommandInfo
1288cdf0e10cSrcweir ( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "transfer" ) ),
1289cdf0e10cSrcweir -1, getCppuType( static_cast<ucb::TransferInfo * >( 0 ) ) ),
1290cdf0e10cSrcweir ucb::CommandInfo
1291cdf0e10cSrcweir ( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "createNewContent" ) ),
1292cdf0e10cSrcweir -1, getCppuType( static_cast<ucb::ContentInfo * >( 0 ) ) )
1293cdf0e10cSrcweir };
1294cdf0e10cSrcweir
1295cdf0e10cSrcweir const int nProps = sizeof (aCommandInfoTable) / sizeof (aCommandInfoTable[0]);
1296cdf0e10cSrcweir return uno::Sequence< ucb::CommandInfo >(aCommandInfoTable, isFolder(xEnv) ? nProps : nProps - 2);
1297cdf0e10cSrcweir }
1298cdf0e10cSrcweir
1299cdf0e10cSrcweir XTYPEPROVIDER_COMMON_IMPL( Content );
1300cdf0e10cSrcweir
acquire()1301cdf0e10cSrcweir void SAL_CALL Content::acquire() throw()
1302cdf0e10cSrcweir {
1303cdf0e10cSrcweir ContentImplHelper::acquire();
1304cdf0e10cSrcweir }
1305cdf0e10cSrcweir
release()1306cdf0e10cSrcweir void SAL_CALL Content::release() throw()
1307cdf0e10cSrcweir {
1308cdf0e10cSrcweir ContentImplHelper::release();
1309cdf0e10cSrcweir }
1310cdf0e10cSrcweir
queryInterface(const uno::Type & rType)1311cdf0e10cSrcweir uno::Any SAL_CALL Content::queryInterface( const uno::Type & rType ) throw ( uno::RuntimeException )
1312cdf0e10cSrcweir {
1313cdf0e10cSrcweir uno::Any aRet = cppu::queryInterface( rType, static_cast< ucb::XContentCreator * >( this ) );
1314cdf0e10cSrcweir return aRet.hasValue() ? aRet : ContentImplHelper::queryInterface(rType);
1315cdf0e10cSrcweir }
1316cdf0e10cSrcweir
getImplementationName()1317cdf0e10cSrcweir rtl::OUString SAL_CALL Content::getImplementationName() throw( uno::RuntimeException )
1318cdf0e10cSrcweir {
1319cdf0e10cSrcweir return rtl::OUString::createFromAscii("com.sun.star.comp.GIOContent" );
1320cdf0e10cSrcweir }
1321cdf0e10cSrcweir
getSupportedServiceNames()1322cdf0e10cSrcweir uno::Sequence< rtl::OUString > SAL_CALL Content::getSupportedServiceNames()
1323cdf0e10cSrcweir throw( uno::RuntimeException )
1324cdf0e10cSrcweir {
1325cdf0e10cSrcweir uno::Sequence< rtl::OUString > aSNS( 1 );
1326cdf0e10cSrcweir aSNS.getArray()[ 0 ] = rtl::OUString::createFromAscii("com.sun.star.ucb.GIOContent" );
1327cdf0e10cSrcweir return aSNS;
1328cdf0e10cSrcweir }
1329cdf0e10cSrcweir
1330cdf0e10cSrcweir }
1331