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

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

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.cpp Implementation of Session class.
3 */
4
5 #include "session.h"
6 #include "property.h"
7 #include "msiquery.h"
8
9 //------------------------------------------------------------------------------ -----------
10 // Session
11 //------------------------------------------------------------------------------ -----------
12 Session::Session( MSIHANDLE handle, std::wstring name )
13 : handle( handle ),
14 log_prefix( name + L": " )
15 {
16 log( L"Entering custom action" ) ;
17 }
18
19 /**
20 * \par Implementation Notes
21 * The session handle doesn't need to be closed.
22 * It's provided as an argument to the custom action at the outset, and we do not manage its life cycle.
23 */
24 Session::~Session()
25 {
26 log( L"Exiting custom action" ) ;
27 }
28
29 /**
30 * \par Implementation Notes
31 * To write to the installation log, we use a call to MsiProcessMessage with message type INSTALLMESSAGE_INFO.
32 * The text to be written needs to go in a "record" (yes, a database record) that acts as an argument vector.
33 * For the message type we're using, we need only a record with a single fiel d.
34 *
35 * \sa MSDN "MsiProcessMessage function"
36 * http://msdn.microsoft.com/en-us/library/windows/desktop/aa370354%28v=vs.85 %29.aspx
37 * MsiProcessMessage is mostly for user interaction with message boxes, but i t's also the access to the installation log.
38 */
39 void Session::log( std::wstring message )
40 {
41 Record r = Record( 1 );
42 r.assign_string( 0, log_prefix + message );
43 int e = MsiProcessMessage( handle, INSTALLMESSAGE_INFO, r.handle() ) ;
44 if ( e != IDOK )
45 {
46 throw std::runtime_error( "Did not succeed writing to log." ) ;
47 }
48 }
49
50 Immediate_Session::Immediate_Session( MSIHANDLE handle, std::wstring name )
51 : Session( handle, name )
52 {
53 }
OLDNEW
« installer/src/installer-lib/session.h ('K') | « installer/src/installer-lib/session.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld