2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 #ifndef MIME_TYPE_UTILS_H
17 #define MIME_TYPE_UTILS_H
19 #include <dpl/string.h>
20 #include <dpl/optional_typedefs.h>
28 DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
29 DECLARE_EXCEPTION_TYPE(Base, InvalidFileName)
33 //TODO use hash_map if possible
34 static const std::set<DPL::String>& getMimeTypesSupportedForIcon();
35 static const std::set<DPL::String>& getMimeTypesSupportedForStartFile();
37 typedef std::map<DPL::String, DPL::String> FileIdentificationMap;
39 static DPL::String getFileNameFromPath(const DPL::String& path);
40 static const FileIdentificationMap& getFileIdentificationMap();
41 static DPL::String stripMimeParameters(const DPL::String& mimeType);
44 typedef std::map<DPL::String, DPL::String> MimeAttributes;
45 static bool isValidIcon(const DPL::String& path);
46 static bool isValidStartFile(const DPL::String& path,
47 const DPL::OptionalString& providedMimeType);
48 static bool isMimeTypeSupportedForStartFile(const DPL::String& mimeType);
49 static bool isMimeTypeSupportedForIcon(const DPL::String& mimeType);
50 static MimeAttributes getMimeAttributes(const DPL::String& mimeType);
51 ///implements 9.1.10. (Rule for Identifying the Media Type of a File)
52 ///from W3C packaging specification
53 static DPL::String identifyFileMimeType(const DPL::String& path);
56 #endif /* MIME_TYPE_UTILS_H */