sync with tizen_2.0
[platform/framework/native/appfw.git] / src / app / inc / FApp_Aul.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_Aul.h
20  * @brief       This is the header file of the _Aul class.
21  */
22
23 #ifndef _FAPP_INTERNAL_AUL_H_
24 #define _FAPP_INTERNAL_AUL_H_
25
26 #include <appsvc/appsvc.h>
27 #include <bundle.h>
28 #include <FOspConfig.h>
29 #include <FAppTypes.h>
30
31 #define MAX_SLP_PACKAGE_ID 128
32
33 namespace Tizen { namespace App
34 {
35
36 /**
37 * @class        _Aul
38 * @brief        SysDep class for AppManager
39 * @since 2.1
40 * @final        This class it not intended for extension.
41 */
42 class _OSP_EXPORT_ _Aul
43 {
44 public:
45         static result TerminateApplicationByPid(int pid);
46
47         static result SendResult(bundle* b, appsvc_result_val res);
48
49         static bool IsRunning(const AppId& appId, const Tizen::Base::String& exeName);
50
51         static bool IsRunning(const Tizen::Base::String& packageName);
52
53         static void SetOnAppTerminatedCb(int (* pf_app_dead_handler)(int pid, void* pData), void* pData);
54
55         static result SetOomAdj(int pid, int adj);
56
57         static result SetPowerOffNotiListener(void (*powerOffCb)(void *pData), void *pData);
58
59         static int GetAppType(const Tizen::Base::String& category);
60
61         static bool IsInstalled(const AppId& appId);
62
63 public:
64         /**
65          * This is static helper class for desktop file.
66          */
67         class _DesktopFile
68         {
69         public:
70                 /**
71                  * Updates the service value
72                  * @param[in]   appId                   The application's ID to be executed
73                  * @param[in]   value                   value to be added or updated.
74                  *
75                  * @remark              If operations is new, it will be appended.
76                  *              but, if same operation is already exist, 'url' and 'mimeType' will be updated.
77                  */
78                 static result UpdateService(const AppId& appId, const char* value);
79
80                 /**
81                  * Removes the service value by operation
82                  * @param[in]   appId   The application's ID to be executed
83                  * @param[in]   operationOnlyValue      operationId of service to be removed
84                  */
85                 static result RemoveService(const AppId& appId, const char* operationOnlyValue);
86
87         private:
88                 /**
89                  * Updates value of specified field
90                  */
91                 static result UpdateField(const char* path, const char* key, const char* value, bool isRemove = false);
92
93                 /**
94                  * Makes desktop file path from appId (retrives appName using _PackageMamagerImpl)
95                  */
96                 static result MakePath(const AppId& appId, const Tizen::Base::String* pExeName, char* path, int size);
97
98                 /**
99                  * Update service value of input buffer with specified value
100                  */
101                 static char* UpdateServiceValueN(char* buffer, const char* newValue, bool isRemove = false);
102
103                 /**
104                  * Extracts each informations from one service string.
105                  */
106                 static result ParseService(const Tizen::Base::String& service, Tizen::Base::String& operation, Tizen::Base::String& url, Tizen::Base::String& mimeType);
107
108                 static void AppendServiceValueToString(Tizen::Base::String& string, const Tizen::Base::String& newVaue);
109
110                 friend class UTs_Aul;
111         }; // _DesktopFile
112
113         friend class UTs_Aul;
114 }; // _Aul
115
116 } } // Tizen::App
117
118 #endif // _FAPP_INTERNAL_AUL_H_