OLD | NEW |
1 /** | 1 /** |
2 * \file session.cpp Implementation of Session class. | 2 * \file session.cpp Implementation of Session class. |
3 */ | 3 */ |
4 | 4 |
| 5 #include "installer-lib.h" |
5 #include "session.h" | 6 #include "session.h" |
6 #include "property.h" | 7 #include "property.h" |
7 #include "msiquery.h" | 8 #include "msiquery.h" |
8 | 9 |
9 // Temporary for debugging | |
10 #include <sstream> | |
11 | |
12 | |
13 //------------------------------------------------------------------------------
----------- | 10 //------------------------------------------------------------------------------
----------- |
14 // Message | 11 // Message |
15 //------------------------------------------------------------------------------
----------- | 12 //------------------------------------------------------------------------------
----------- |
16 Message::Message( std::string message, INSTALLMESSAGE message_type ) | 13 Message::Message( std::string message, INSTALLMESSAGE message_type ) |
17 : r( 1 ), message_type( message_type ) | 14 : r( 1 ), message_type( message_type ) |
18 { | 15 { |
19 r.assign_string( 0, message ) ; | 16 r.assign_string( 0, message ) ; |
20 } | 17 } |
21 | 18 |
22 Message::Message( std::wstring message, INSTALLMESSAGE message_type ) | 19 Message::Message( std::wstring message, INSTALLMESSAGE message_type ) |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 void Session::log_noexcept( std::string message ) | 71 void Session::log_noexcept( std::string message ) |
75 { | 72 { |
76 write_message_noexcept( Log_Message( log_prefix + message ) ) ; | 73 write_message_noexcept( Log_Message( log_prefix + message ) ) ; |
77 } | 74 } |
78 | 75 |
79 int Session::write_message( Message & m ) | 76 int Session::write_message( Message & m ) |
80 { | 77 { |
81 int x = write_message_noexcept( m ) ; | 78 int x = write_message_noexcept( m ) ; |
82 if ( x == -1 ) | 79 if ( x == -1 ) |
83 { | 80 { |
84 DWORD z = ::GetLastError(); | 81 throw windows_api_error( "MsiProcessMessage", x, "attempt to write to log fi
le" ) ; |
85 std::ostringstream s ; | |
86 s << "Error writing message. err = 0x" << std::hex << z ; | |
87 throw std::runtime_error( s.str() ) ; | |
88 } | 82 } |
89 return x ; | 83 return x ; |
90 } | 84 } |
91 | 85 |
92 int Session::write_message_noexcept( Message & m ) | 86 int Session::write_message_noexcept( Message & m ) |
93 { | 87 { |
94 return MsiProcessMessage( handle, m.message_type, m.r.handle() ) ; | 88 return MsiProcessMessage( handle, m.message_type, m.r.handle() ) ; |
95 } | 89 } |
96 | 90 |
97 //------------------------------------------------------------------------------
----------- | 91 //------------------------------------------------------------------------------
----------- |
98 // Immediate_Session | 92 // Immediate_Session |
99 //------------------------------------------------------------------------------
----------- | 93 //------------------------------------------------------------------------------
----------- |
100 Immediate_Session::Immediate_Session( MSIHANDLE handle, std::string name ) | 94 Immediate_Session::Immediate_Session( MSIHANDLE handle, std::string name ) |
101 : Session( handle, name ) | 95 : Session( handle, name ) |
102 {} | 96 {} |
OLD | NEW |