Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: installer/src/installer-lib/session.h

Issue 22887001: Custom action library, initial version (Closed)
Patch Set: Created Oct. 28, 2013, 9:37 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 /**
2 * \file session.h The "install session" is the context for all custom installat ion behavior.
3 */
4
5 #ifndef SESSION_H
6 #define SESSION_H
7
8 #include "property.h"
9 #include "record.h"
Wladimir Palant 2013/10/29 08:49:26 You should forward-declare the classes instead of
Eric 2013/10/29 14:00:58 "record.h" I think is some dead code I forgot to r
10
11 #include <string>
12 #include "windows.h"
13 #include "msi.h"
14
15 //------------------------------------------------------------------------------ -----------
16 // Session
17 //------------------------------------------------------------------------------ -----------
18 /**
19 * A Windows Installer session
20 *
21 * Always instantiate an instance of this class at the start of each custom acti on.
22 * Copy and assignment are disabled, so session objects are always passed by ref erence.
23 *
24 * This class is the base for both immediate and deferred custom actions.
25 * Immediate custom actions always have an installer database associated with th em; deferred actions never do.
26 * Both immediate and deferred actions may be executed synchronously or asynchro nously; this class is silent about any difference.
27 *
28 * \par Notes
29 * This class is patterned after WcaInitialize/WcaFinalize of the WiX custom a ction library.
30 * There are two things that class does that this one does not.
31 * - Extract the file version information from the DLL using GetModuleFileName * and GetFileVersionInfo* system calls.
32 * - Set a "global atom" (a Windows system object) to store the logging state, later to be accessed by deferred actions.
33 */
34 class Session {
35 public:
36 /**
37 * Destructor.
38 */
39 ~Session() ;
40
41 /**
42 * Write a message to the installation log.
43 */
44 void log( std::wstring message ) ;
45
46 protected:
47 /**
48 * Ordinary constructor is protected; public constructors are all in subclasse s.
49 * The MSI system uses a single handle type for all types of sessions. This ha ndle is here in this base class.
50 *
51 * \param[in] handle
52 * Handle for the Windows Installer session provided as an argument to a cu stom action.
53 * \param[in] name
54 * The name of the custom action, used for logging.
55 */
56 Session( MSIHANDLE handle, std::wstring name ) ;
57
58 protected:
59 /**
60 * Handle for the Windows Installer session.
61 */
62 MSIHANDLE handle ;
63
64 private:
65 /**
66 * Prefix for log messages. Contains the name of the custom action.
67 */
68 std::wstring log_prefix ;
69
70 /**
71 * Private copy constructor is declared but not defined.
72 */
73 Session( const Session & ) ;
74
75 /**
76 * Private assignment operator is declared but not defined.
77 */
78 Session & operator=( const Session & ) ;
79
80 /**
81 * The Property class requires access to the session handle.
82 */
83 friend Property::Property( Session & session, std::wstring name ) ;
Wladimir Palant 2013/10/29 08:49:26 The main purpose of this class is holding the sess
Eric 2013/10/29 14:00:58 Well, it's a design goal of mine to hide the handl
Wladimir Palant 2013/10/29 15:06:38 Lifetime management is easily solved - either you
84 };
85
86 //------------------------------------------------------------------------------ -----------
87 // Immediate_Session
88 //------------------------------------------------------------------------------ -----------
89 /**
90 * Session for immediate custom actions.
91 *
92 * Access to the installer database is by passing a reference to a class of this subtype to a Database constructor.
93 */
94 class Immediate_Session : public Session
95 {
96 public:
97 /**
98 * Ordinary constructor.
99 *
100 * \param[in] handle
101 * Handle for the Windows Installer session provided as an argument to a cu stom action.
102 * \param[in] name
103 * The name of the custom action, used for logging.
104 */
105 Immediate_Session( MSIHANDLE handle, std::wstring name ) ;
106
107 private:
108 /*
109 * Allow helper function for Installation_Database constructor to have access to the handle.
110 */
111 friend MSIHANDLE get_active_database( Immediate_Session & session ) ;
112 };
113
114
115 //------------------------------------------------------------------------------ -----------
116 // Deferred_Session
117 //------------------------------------------------------------------------------ -----------
118 /**
119 * Session for deferred custom actions.
120 *
121 * There's much less context information easily available from a deferred custom action.
122 *
123 * /sa MDSN "Deferred Execution Custom Actions"
124 * http://msdn.microsoft.com/en-us/library/windows/desktop/aa368268%28v=vs.8 5%29.aspx
125 * for general information.
126 *
127 * /sa MSDN "Obtaining Context Information for Deferred Execution Custom Actions "
128 * http://msdn.microsoft.com/en-us/library/windows/desktop/aa370543%28v=vs.8 5%29.aspx
129 * lists the API calls available.
130 */
131 class Deferred_Session : public Session
132 {
133 public:
134 /**
135 * Ordinary constructor.
136 *
137 * \param[in] handle
138 * Handle for the Windows Installer session provided as an argument to a cu stom action.
139 * \param[in] name
140 * The name of the custom action, used for logging.
141 */
142 Deferred_Session( MSIHANDLE handle, std::wstring name ) ;
143 };
Wladimir Palant 2013/10/29 08:49:26 As with the Database object, I'm not a fan of the
144
145
146 //------------------------------------------------------------------------------ -----------
147 // Commit_Session
148 //------------------------------------------------------------------------------ -----------
149 /**
150 * The session for a commit custom action. NOT IMPLEMENTED.
151 *
152 * \sa MSDN "Commit Custom Actions" http://msdn.microsoft.com/en-us/library/wind ows/desktop/aa367991%28v=vs.85%29.aspx
153 */
154 class Commit_Session
155 {
156 };
157
158 //------------------------------------------------------------------------------ -----------
159 // Rollback_Session
160 //------------------------------------------------------------------------------ -----------
161 /**
162 * The session for a rollback custom action. NOT IMPLEMENTED.
163 *
164 * \sa MSDN "Rollback Custom Actions" http://msdn.microsoft.com/en-us/library/wi ndows/desktop/aa371369%28v=vs.85%29.aspx
165 */
166 class Rollback_Session
167 {
168 };
169
170 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld