Update wrt-commons_0.2.53
[framework/web/wrt-commons.git] / modules / utils / include / dpl / utils / mime_type_utils.h
1 /*
2  * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
3  *
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
7  *
8  *        http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16 #ifndef MIME_TYPE_UTILS_H
17 #define MIME_TYPE_UTILS_H
18
19 #include <dpl/string.h>
20 #include <dpl/optional_typedefs.h>
21
22 class MimeTypeUtils
23 {
24   public:
25     class Exception
26     {
27       public:
28         DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
29         DECLARE_EXCEPTION_TYPE(Base, InvalidFileName)
30     };
31
32   private:
33     //TODO use hash_map if possible
34     static const std::set<DPL::String>& getMimeTypesSupportedForIcon();
35     static const std::set<DPL::String>& getMimeTypesSupportedForStartFile();
36
37     typedef std::map<DPL::String, DPL::String> FileIdentificationMap;
38
39     static DPL::String getFileNameFromPath(const DPL::String& path);
40     static const FileIdentificationMap& getFileIdentificationMap();
41     static DPL::String stripMimeParameters(const DPL::String& mimeType);
42
43   public:
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);
54 };
55
56 #endif  /* MIME_TYPE_UTILS_H */
57