Fix the crash while installing of ServiceApp
[platform/framework/native/installer.git] / src / Manager / InstallerManager.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  * @file        InstallerManager.h
19  * @brief       This is the header file for the %InstallerManager class.
20  *
21  * This header file contains the declarations of the %InstallerManager class.
22  */
23 #ifndef _INSTALLER_MANAGER_H_
24 #define _INSTALLER_MANAGER_H_
25
26 #include "InstallationContext.h"
27 #include "Installer.h"
28
29 /**
30  * @class               InstallerManager
31  * @brief               This class represents the class of InstallerManager.
32  * @since               1.0
33  *
34  * This class represents the class of InstallerManager.
35  *
36  */
37 class InstallerManager
38 {
39 public:
40         InstallerManager(void);
41         InstallerError Construct(const Tizen::Base::String& path, InstallerOperation op, InstallerOption option);
42         virtual ~InstallerManager(void);
43
44         static InstallerManager* GetInstance(void);
45         void Release(void);
46
47         bool RemoveGarbage(const Tizen::Base::String& filePath);
48
49         void PrintResult(void);
50         void PrintError(int errorType);
51
52         const Tizen::App::PackageId& GetId(void) const;
53         void SetId(const Tizen::App::PackageId& appId);
54
55         int GetErrorType(void) const;
56         void SetErrorType(int errorType);
57
58         void SetInstallerOperation(InstallerOperation op);
59         InstallerOperation GetInstallerOperation(void) const;
60
61         Tizen::Base::String GetLogFilePath() const;
62         bool IsFileLogOn() const;
63
64         static int Request(const Tizen::Base::String& path, InstallerOperation operation, InstallerOption option, Tizen::Base::String& packageId);
65         static int RequestRecursiveDirectory(const Tizen::Base::String& path, int& errorType);
66         static int RequestByCommand(int argc, char **argv);
67         static int ReqeustByTest(void);
68         static int RequestMove(const Tizen::App::PackageId& packageId, int moveType);
69
70 private:
71         InstallerManager(const InstallerManager& value);
72         InstallerManager& operator =(const InstallerManager& source);
73
74         InstallationStep GetNext(void);
75
76         InstallerError Init(void);
77         InstallerError Register(void);
78         InstallerError End(void);
79
80         InstallerError Error(void);
81         InstallerError Rollback(void);
82         InstallerError UserCancel(void);
83
84         InstallerError Activate(void);
85         InstallerError Progress(void);
86
87         Installer* CreateInstaller(InstallerType installerType);
88         InstallationContext* GetContext(void);
89
90         static int ParseCommandArg(int argc, char **argv, int *mode, char *buf, bool *output);
91
92 private:
93         static InstallerManager* __pInstallerManager;
94         InstallationContext* __pContext;
95         Installer* __pInstaller;
96
97         Tizen::App::PackageId __packageId;
98         int __errorType;
99         InstallerOperation __operation;
100
101         long long __startTick;
102         long long __endTick;
103         Tizen::Base::String __logFilePath;
104         bool __isFileLogOn;
105
106 }; // InstallerManager
107
108 #endif //_INSTALLER_MANAGER_H_