Update privilege string, PackageAppInfo for wgt
[platform/framework/native/appfw.git] / src / app / FApp_AppResourceImpl.h
1 //
2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 //     http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17
18 /**
19  * @file        FApp_AppResourceImpl.h
20  * @brief       This is the header file of the _AppResourceImpl class.
21  */
22
23 #ifndef _FAPP_INTERNAL_APP_RESOURCE_IMPL_H_
24 #define _FAPP_INTERNAL_APP_RESOURCE_IMPL_H_
25
26 #include <FBaseObject.h>
27 #include <FBaseString.h>
28
29 #include <FGrpBitmapCommon.h>
30
31 namespace Tizen { namespace Base { namespace Collection { class HashMap; } } }
32 namespace Tizen { namespace Graphics { class Bitmap; } }
33
34 namespace Tizen { namespace App
35 {
36
37 class AppResource;
38 class _AppResourceString;
39 class _IAppResourceBitmap;
40
41 enum AppResourceBy
42 {
43         APP_RESOURCE_DEFAULT,
44         APP_RESOURCE_BY_APP_ID,
45         APP_RESOURCE_BY_LIBRARY_NAME
46 };
47
48 class _AppResourceImpl
49         : public Tizen::Base::Object
50 {
51 public:
52         /**
53         * This is the destructor for this class.
54         *
55         * @since                1.0
56         */
57         virtual ~_AppResourceImpl(void);
58
59         /**
60         * Gets the string at the specified resource ID.
61         *
62         * @since                1.0
63         * @return               An error code
64         * @param[in]    resourceId              The resource ID describing the String resource
65         * @param[out]   loadedString    The string obtained from the loaded application resource
66         * @exception    E_SUCCESS                                 The method was successful.
67         * @exception    E_FAILURE                       The argument passed is not found.
68         * @exception    E_INVALID_ARG                   The argument passed to a method contains an invalid resource ID.
69         */
70         result GetString(const Tizen::Base::String& resourceId, Tizen::Base::String& loadedString);
71
72         /**
73         * Gets the Bitmap at the specified path. @n
74         * This method interprets the given resource path and reads the best matching image file for the current device resolution. @n
75         * To load bitmap image from a file, you give the name of file as the input parameter not the file path (Ex: "img.png").
76         * Then, the system will first look for the image file in the folder specific to the current device resolution such as
77         * '320x480' and if the file does not exist, it will then search the folder that corresponds to the current screen density,
78         * such as 'ScreenDensity-Middle'. After searching density folder, all other density folders are searched in the order high to low.
79         * Currently supported image formats are JPEG, GIF, PNG, BMP, TIFF, and WBMP.
80         *
81         * @since                1.1
82         *
83         * @return               A Bitmap instance generated from the specified file
84         * @param[in]    imagePath                               The relative path starting from the directory "/res/screen-density-XXX/", @n
85         *                                       where A and B represents the screen width and height of the supported device models, respectively.
86         * @param[in]    pixelFormat                             The pixel format of the resulting bitmap
87         * @exception    E_SUCCESS                               The method was successful.
88         * @exception    E_INVALID_ARG                   A specified input parameter is invalid.
89         * @exception    E_UNSUPPORTED_FORMAT    The image file format or specified pixel format is not supported.
90         * @exception    E_OUT_OF_MEMORY                 Insufficient memory.
91         * @exception    E_FILE_NOT_FOUND                The specified file could not be found.
92         * @exception    E_SYSTEM                                A system error occurred.
93         */
94         Tizen::Graphics::Bitmap* GetBitmapN(const Tizen::Base::String& imagePath, Tizen::Graphics::BitmapPixelFormat pixelFormat);
95
96         /**
97         * Gets the Bitmap at the specified path. @n
98         * This method interprets the given resource path and reads the best matching image file for the current device resolution. @n
99         * To load bitmap image from a file, you give the name of file as the input parameter not the file path (Ex: "img.png").
100         * Then, the system will first look for the image file in the folder specific to the current device resolution such as
101         * '320x480' and if the file does not exist, it will then search the folder that corresponds to the current screen density,
102         * such as 'ScreenDensity-Middle'. After searching density folder, all other density folders are searched in the order high to low.
103         * Currently supported image formats are JPEG, GIF, PNG, BMP, TIFF, and WBMP.
104         *
105         * In this method, the system decides the proper pixel format and whether to use chroma key composition to enable transparency. @n
106         * If the input image file has the alpha channel, the pixel format is set to Tizen::Graphics::BITMAP_PIXEL_FORMAT_ARGB8888.
107         * Otherwise, the pixel format is set to BITMAP_PIXEL_FORMAT_RGB565 and the masking color of the bitmap is set to magenta, Tizen::Graphics::Color(255, 0, 255). @n
108         * Typically, a WVGA Tizen device would support alpha channel, while WQVGA device would support bitmap with masking color, to support transparency.
109         * You can place a 32-bit version of the resource and a 16-bit version in the WQVGA resource folder at the same folder. To distinguish the pixel format, you can use a postfix '@@16' such as 'image@@.bmp'.
110         * If you don't use postfix, this API would load the correct image and set the pixel format from the image file, that is appropriate for the current device. @n
111         * Currently supported image formats are JPEG, GIF, PNG, BMP, TIFF, and WBMP.
112         *
113         * @since                1.1
114         *
115         * @return               A Bitmap instance generated from the specified file.
116         * @param[in]    imagePath                               The relative path starting from the density directory "/res/screen-density-XXX/", @n
117         *                                       where A and B represents the width and height of the screen of the supported device models, respectively
118         * @exception    E_SUCCESS                               The method was successful.
119         * @exception    E_INVALID_ARG                   A specified input parameter is invalid.
120         * @exception    E_UNSUPPORTED_FORMAT    The image file format is not supported.
121         * @exception    E_OUT_OF_MEMORY                 Insufficient memory.
122         * @exception    E_FILE_NOT_FOUND                The specified file could not be found.
123         * @exception    E_SYSTEM                                A system error occurred.
124         */
125         Tizen::Graphics::Bitmap* GetBitmapN(const Tizen::Base::String& imagePath);
126
127         static void Reinitialize(void);
128
129         /**
130         * Gets the AppResoruce instance pointer.
131         *
132         * @since  2.0
133         * @return An AppResoruce instance pointer, if successful @n
134         *                 @c null, if it fails
135         */
136         static _AppResourceImpl* GetInstance(void);
137
138         static AppResource* GetInstanceN(AppResourceBy type, const Tizen::Base::String& value = L"");
139         static _IAppResourceBitmap* Get_IAppResourceBitmapN(AppResourceBy type, const Tizen::Base::String& value = L"");
140
141         static void ReinitializeAll(void);
142         static result ReleaseInstance(const Tizen::Base::String& key);
143
144 private:
145         /**
146         * This is the default constructor for this class.
147         *
148         * @since        1.0
149         */
150         _AppResourceImpl(void);
151
152         /**
153         * This is the copy constructor for this class.
154         *
155         * @since        1.0
156         */
157         _AppResourceImpl(const _AppResourceImpl& source);
158
159         /**
160          * This is the assignment operator for this class.
161          */
162         _AppResourceImpl& operator =(const _AppResourceImpl& source);
163
164 private:
165         _AppResourceString* __p_AppResourceString;
166         _IAppResourceBitmap* __p_IAppResourceBitmap;
167
168         AppResourceBy __type;
169         Tizen::Base::String __value;
170
171         static Tizen::Base::Collection::HashMap* __pContainer;
172
173 }; // _AppResourceImpl
174
175 } } // Tizen::App
176
177 #endif // _FAPP_INTERNAL_APP_RESOURCE_IMPL_H_