sync with master
[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 GetConvertedResult(const int aul_ret, const char* pFunctionName);
46
47         static result TerminateApplication(const AppId& appId);
48
49         static result TerminateApplicationByPid(int pid);
50
51         static result SendResult(bundle* b, appsvc_result_val res);
52
53         static bool IsRunning(const AppId& appId, const Tizen::Base::String& exeName);
54
55         static bool IsRunning(const Tizen::Base::String& packageName);
56
57         static void SetOnAppTerminatedCb(int (* pf_app_dead_handler)(int pid, void* pData), void* pData);
58
59         static result SetOomAdj(int pid, int adj);
60
61         static result SetPowerOffNotiListener(void (*powerOffCb)(void *pData), void *pData);
62
63         static int GetAppType(const Tizen::Base::String& category);
64
65         static bool IsInstalled(const AppId& appId);
66
67 public:
68         /**
69          * This is static helper class for desktop file.
70          */
71         class _DesktopFile
72         {
73         public:
74                 /**
75                  * Updates the service value
76                  * @param[in]   appId                   The application's ID to be executed
77                  * @param[in]   value                   value to be added or updated.
78                  *
79                  * @remark              If operations is new, it will be appended.
80                  *              but, if same operation is already exist, 'url' and 'mimeType' will be updated.
81                  */
82                 static result UpdateService(const AppId& appId, const char* value);
83
84                 /**
85                  * Removes the service value by operation
86                  * @param[in]   appId   The application's ID to be executed
87                  * @param[in]   operationOnlyValue      operationId of service to be removed
88                  */
89                 static result RemoveService(const AppId& appId, const char* operationOnlyValue);
90
91         private:
92                 /**
93                  * Updates value of specified field
94                  */
95                 static result UpdateField(const char* path, const char* key, const char* value, bool isRemove = false);
96
97                 /**
98                  * Makes desktop file path from appId (retrives appName using _PackageMamagerImpl)
99                  */
100                 static result MakePath(const AppId& appId, char* path, int size);
101
102                 /**
103                  * Update service value of input buffer with specified value
104                  */
105                 static char* UpdateServiceValueN(char* buffer, const char* newValue, bool isRemove = false);
106
107                 /**
108                  * Extracts each informations from one service string.
109                  */
110                 static result ParseService(const Tizen::Base::String& service, Tizen::Base::String& operation, Tizen::Base::String& url, Tizen::Base::String& mimeType);
111
112                 static void AppendServiceValueToString(Tizen::Base::String& string, const Tizen::Base::String& newVaue);
113
114                 friend class UTs_Aul;
115         }; // _DesktopFile
116
117         friend class UTs_Aul;
118 }; // _Aul
119
120 } } // Tizen::App
121
122 #endif // _FAPP_INTERNAL_AUL_H_