summaryrefslogtreecommitdiffstats
path: root/ucb/source/core/ucbprops.cxx
blob: fe52f20e135415141e63d6c5de5a4ac5c1a35a47 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
 * This file is part of the LibreOffice project.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 *
 * This file incorporates work covered by the following license notice:
 *
 *   Licensed to the Apache Software Foundation (ASF) under one or more
 *   contributor license agreements. See the NOTICE file distributed
 *   with this work for additional information regarding copyright
 *   ownership. The ASF licenses this file to you under the Apache
 *   License, Version 2.0 (the "License"); you may not use this file
 *   except in compliance with the License. You may obtain a copy of
 *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
 */

#include <sal/config.h>

#include <com/sun/star/uno/Sequence.hxx>
#include <com/sun/star/uno/Reference.hxx>
#include <com/sun/star/beans/PropertyAttribute.hpp>
#include <com/sun/star/ucb/CrossReference.hpp>
#include <com/sun/star/util/DateTime.hpp>
#include <com/sun/star/ucb/DocumentHeaderField.hpp>
#include <com/sun/star/ucb/DocumentStoreMode.hpp>
#include <com/sun/star/ucb/Priority.hpp>
#include <com/sun/star/ucb/RecipientInfo.hpp>
#include <com/sun/star/ucb/RuleSet.hpp>
#include <com/sun/star/ucb/SendInfo.hpp>
#include <com/sun/star/ucb/SendMediaTypes.hpp>
#include <com/sun/star/ucb/SynchronizePolicy.hpp>
#include <com/sun/star/ucb/VerificationMode.hpp>
#include <com/sun/star/ucb/XDataContainer.hpp>
#include <ucbhelper/macros.hxx>

#include "ucbprops.hxx"

using namespace com::sun::star::beans;
using namespace com::sun::star::lang;
using namespace com::sun::star::uno;

#define ATTR_DEFAULT ( PropertyAttribute::BOUND | PropertyAttribute::MAYBEVOID | PropertyAttribute::MAYBEDEFAULT )

UcbPropertiesManager::UcbPropertiesManager()
: m_pProps({
    { "Account", -1, cppu::UnoType<OUString>::get(), ATTR_DEFAULT },
    { "AutoUpdateInterval", -1, cppu::UnoType<sal_Int32>::get(), ATTR_DEFAULT },
    { "ConfirmEmpty", -1, cppu::UnoType<bool>::get(), ATTR_DEFAULT },
    { "ConnectionLimit", -1, cppu::UnoType<sal_Int16>::get(), ATTR_DEFAULT },
    { "ConnectionMode", -1, cppu::UnoType<sal_Int16>::get(), ATTR_DEFAULT },
    { "ContentCountLimit", -1, cppu::UnoType<sal_Int16>::get(), ATTR_DEFAULT },
    { "ContentType", -1, cppu::UnoType<OUString>::get(), ATTR_DEFAULT },
    { "Cookie", -1, cppu::UnoType<OUString>::get(), ATTR_DEFAULT },
    { "CrossReferences", -1,
      cppu::UnoType<css::uno::Sequence<css::ucb::CrossReference>>::get(),
      ATTR_DEFAULT },
    { "DateCreated", -1, cppu::UnoType<css::util::DateTime>::get(),
      ATTR_DEFAULT },
    { "DateModified", -1, cppu::UnoType<css::util::DateTime>::get(),
      ATTR_DEFAULT },
    { "DeleteOnServer", -1, cppu::UnoType<bool>::get(), ATTR_DEFAULT },
    { "DocumentBody", -1, cppu::UnoType<css::uno::Sequence<sal_Int8>>::get(),
      ATTR_DEFAULT },
    { "DocumentCount", -1, cppu::UnoType<sal_Int32>::get(),
      ATTR_DEFAULT | PropertyAttribute::READONLY },
    { "DocumentCountMarked", -1, cppu::UnoType<sal_Int32>::get(),
      ATTR_DEFAULT | PropertyAttribute::READONLY },
    { "DocumentHeader", -1,
      cppu::UnoType<css::uno::Sequence<css::ucb::DocumentHeaderField>>::get(),
      ATTR_DEFAULT },
    { "DocumentStoreMode", -1,
      cppu::UnoType<css::ucb::DocumentStoreMode>::get(), ATTR_DEFAULT },
    { "DocumentViewMode", -1, cppu::UnoType<sal_Int16>::get(), ATTR_DEFAULT },
    { "FTPAccount", -1, cppu::UnoType<OUString>::get(), ATTR_DEFAULT },
    { "Flags", -1, cppu::UnoType<sal_Int32>::get(), ATTR_DEFAULT },
    { "FolderCount", -1, cppu::UnoType<sal_Int32>::get(),
      ATTR_DEFAULT | PropertyAttribute::READONLY },
    { "FolderViewMode", -1, cppu::UnoType<sal_Int16>::get(), ATTR_DEFAULT },
    { "FreeSpace", -1, cppu::UnoType<sal_Int64>::get(),
      ATTR_DEFAULT | PropertyAttribute::READONLY },
    { "HasDocuments", -1, cppu::UnoType<bool>::get(),
      ATTR_DEFAULT | PropertyAttribute::READONLY },
    { "HasFolders", -1, cppu::UnoType<bool>::get(),
      ATTR_DEFAULT | PropertyAttribute::READONLY },
    { "IsAutoDelete", -1, cppu::UnoType<bool>::get(), ATTR_DEFAULT },
    { "IsAutoUpdate", -1, cppu::UnoType<bool>::get(), ATTR_DEFAULT },
    { "IsDocument", -1, cppu::UnoType<bool>::get(),
      ATTR_DEFAULT | PropertyAttribute::READONLY },
    { "IsFolder", -1, cppu::UnoType<bool>::get(),
      ATTR_DEFAULT | PropertyAttribute::READONLY },
    { "IsKeepExpired", -1, cppu::UnoType<bool>::get(), ATTR_DEFAULT },
    { "IsLimitedContentCount", -1, cppu::UnoType<bool>::get(), ATTR_DEFAULT },
    { "IsMarked", -1, cppu::UnoType<bool>::get(), ATTR_DEFAULT },
    { "IsRead", -1, cppu::UnoType<bool>::get(), ATTR_DEFAULT },
    { "IsReadOnly", -1, cppu::UnoType<bool>::get(), ATTR_DEFAULT },
    { "IsSubscribed", -1, cppu::UnoType<bool>::get(), ATTR_DEFAULT },
    { "IsTimeLimitedStore", -1, cppu::UnoType<bool>::get(), ATTR_DEFAULT },
    { "Keywords", -1, cppu::UnoType<OUString>::get(), ATTR_DEFAULT },
    { "LocalBase", -1, cppu::UnoType<OUString>::get(), ATTR_DEFAULT },
    { "MessageBCC", -1, cppu::UnoType<OUString>::get(), ATTR_DEFAULT },
    { "MessageBody", -1, cppu::UnoType<css::ucb::XDataContainer>::get(),
      ATTR_DEFAULT },
    { "MessageCC", -1, cppu::UnoType<OUString>::get(), ATTR_DEFAULT },
    { "MessageFrom", -1, cppu::UnoType<OUString>::get(), ATTR_DEFAULT },
    { "MessageId", -1, cppu::UnoType<OUString>::get(), ATTR_DEFAULT },
    { "MessageInReplyTo", -1, cppu::UnoType<OUString>::get(), ATTR_DEFAULT },
    { "MessageReplyTo", -1, cppu::UnoType<OUString>::get(), ATTR_DEFAULT },
    { "MessageTo", -1, cppu::UnoType<OUString>::get(), ATTR_DEFAULT },
    { "NewsGroups", -1, cppu::UnoType<OUString>::get(), ATTR_DEFAULT },
    { "NoCacheList", -1, cppu::UnoType<OUString>::get(), ATTR_DEFAULT },
    { "Origin", -1, cppu::UnoType<OUString>::get(),
      ATTR_DEFAULT | PropertyAttribute::READONLY },
    { "OutgoingMessageRecipients", -1,
      cppu::UnoType<css::uno::Sequence<css::ucb::RecipientInfo>>::get(),
      ATTR_DEFAULT },
    { "OutgoingMessageState", -1,
      cppu::UnoType<css::ucb::OutgoingMessageState>::get(),
      ATTR_DEFAULT | PropertyAttribute::READONLY },
    { "OutgoingMessageViewMode", -1, cppu::UnoType<sal_Int16>::get(),
      ATTR_DEFAULT },
    { "Password", -1, cppu::UnoType<OUString>::get(), ATTR_DEFAULT },
    { "Priority", -1, cppu::UnoType<css::ucb::Priority>::get(), ATTR_DEFAULT },
    { "References", -1, cppu::UnoType<OUString>::get(), ATTR_DEFAULT },
    { "Referer", -1, cppu::UnoType<OUString>::get(), ATTR_DEFAULT },
    { "Rules", -1, cppu::UnoType<css::ucb::RuleSet>::get(), ATTR_DEFAULT },
    { "SearchCriteria", -1, cppu::UnoType<css::ucb::RuleSet>::get(),
      ATTR_DEFAULT },
    { "SearchIndirections", -1, cppu::UnoType<bool>::get(), ATTR_DEFAULT },
    { "SearchLocations", -1, cppu::UnoType<OUString>::get(), ATTR_DEFAULT },
    { "SearchRecursive", -1, cppu::UnoType<bool>::get(), ATTR_DEFAULT },
    { "SeenCount", -1, cppu::UnoType<sal_Int32>::get(),
      ATTR_DEFAULT | PropertyAttribute::READONLY },
    { "SendCopyTarget", -1,
      cppu::UnoType<css::uno::Sequence<css::ucb::SendInfo>>::get(),
      ATTR_DEFAULT },
    { "SendFormats", -1,
      cppu::UnoType<css::uno::Sequence<css::ucb::SendMediaTypes>>::get(),
      ATTR_DEFAULT },
    { "SendFroms", -1,
      cppu::UnoType<css::uno::Sequence<css::ucb::SendInfo>>::get(),
      ATTR_DEFAULT },
    { "SendPasswords", -1,
      cppu::UnoType<css::uno::Sequence<css::ucb::SendInfo>>::get(),
      ATTR_DEFAULT },
    { "SendProtocolPrivate", -1, cppu::UnoType<sal_Int16>::get(),
      ATTR_DEFAULT },
    { "SendProtocolPublic", -1, cppu::UnoType<sal_Int16>::get(), ATTR_DEFAULT },
    { "SendReplyTos", -1,
      cppu::UnoType<css::uno::Sequence<css::ucb::SendInfo>>::get(),
      ATTR_DEFAULT },
    { "SendServerNames", -1,
      cppu::UnoType<css::uno::Sequence<css::ucb::SendInfo>>::get(),
      ATTR_DEFAULT },
    { "SendUserNames", -1,
      cppu::UnoType<css::uno::Sequence<css::ucb::SendInfo>>::get(),
      ATTR_DEFAULT },
    { "SendVIMPostOfficePath", -1, cppu::UnoType<OUString>::get(),
      ATTR_DEFAULT },
    { "ServerBase", -1, cppu::UnoType<OUString>::get(), ATTR_DEFAULT },
    { "ServerName", -1, cppu::UnoType<OUString>::get(), ATTR_DEFAULT },
    { "ServerPort", -1, cppu::UnoType<sal_Int16>::get(), ATTR_DEFAULT },
    { "Size", -1, cppu::UnoType<sal_Int64>::get(),
      ATTR_DEFAULT | PropertyAttribute::READONLY },
    { "SizeLimit", -1, cppu::UnoType<sal_Int64>::get(), ATTR_DEFAULT },
    { "SubscribedCount", -1, cppu::UnoType<sal_Int32>::get(),
      ATTR_DEFAULT | PropertyAttribute::READONLY },
    { "SynchronizePolicy", -1,
      cppu::UnoType<css::ucb::SynchronizePolicy>::get(), ATTR_DEFAULT },
    { "TargetFrames", -1, cppu::UnoType<OUString>::get(), ATTR_DEFAULT },
    { "TargetURL", -1, cppu::UnoType<OUString>::get(), ATTR_DEFAULT },
    { "TimeLimitStore", -1, cppu::UnoType<sal_Int16>::get(), ATTR_DEFAULT },
    { "Title", -1, cppu::UnoType<OUString>::get(), ATTR_DEFAULT },
    { "UpdateOnOpen", -1, cppu::UnoType<bool>::get(), ATTR_DEFAULT },
    { "UseOutBoxPrivateProtocolSettings", -1, cppu::UnoType<bool>::get(),
      ATTR_DEFAULT },
    { "UseOutBoxPublicProtocolSettings", -1, cppu::UnoType<bool>::get(),
      ATTR_DEFAULT },
    { "UserName", -1, cppu::UnoType<OUString>::get(), ATTR_DEFAULT },
    { "UserSortCriterium", -1, cppu::UnoType<OUString>::get(), ATTR_DEFAULT },
    { "VIMPostOfficePath", -1, cppu::UnoType<OUString>::get(), ATTR_DEFAULT },
    { "VerificationMode", -1, cppu::UnoType<css::ucb::VerificationMode>::get(),
      ATTR_DEFAULT }})
{
}


// virtual
UcbPropertiesManager::~UcbPropertiesManager()
{
}


// XServiceInfo methods.

XSERVICEINFO_COMMOM_IMPL( UcbPropertiesManager,
                          "com.sun.star.comp.ucb.UcbPropertiesManager" )
/// @throws css::uno::Exception
static css::uno::Reference< css::uno::XInterface >
UcbPropertiesManager_CreateInstance( const css::uno::Reference< css::lang::XMultiServiceFactory> & /*rSMgr*/ )
{
    return static_cast<css::lang::XServiceInfo*>(new UcbPropertiesManager);
}
css::uno::Sequence< OUString >
UcbPropertiesManager::getSupportedServiceNames_Static()
{
    return { PROPERTIES_MANAGER_SERVICE_NAME };
}

// Service factory implementation.


ONE_INSTANCE_SERVICE_FACTORY_IMPL( UcbPropertiesManager );


// XPropertySetInfo methods.


// virtual
Sequence< Property > SAL_CALL UcbPropertiesManager::getProperties()
{
    return m_pProps;
}


// virtual
Property SAL_CALL UcbPropertiesManager::getPropertyByName( const OUString& aName )
{
    Property aProp;
    if ( queryProperty( aName, aProp ) )
        return aProp;

    throw UnknownPropertyException(aName);
}


// virtual
sal_Bool SAL_CALL UcbPropertiesManager::hasPropertyByName( const OUString& Name )
{
    Property aProp;
    return queryProperty( Name, aProp );
}


// Non-Interface methods.


bool UcbPropertiesManager::queryProperty(
                                const OUString& rName, Property& rProp )
{
    auto pProp = std::find_if(m_pProps.begin(), m_pProps.end(),
        [&rName](const Property& rCurrProp) { return rCurrProp.Name == rName; });
    if (pProp != m_pProps.end())
    {
        rProp = *pProp;
        return true;
    }

    return false;
}

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */