Menu

[r27]: / trunk / bindings / lua / SvnListener.cpp  Maximize  Restore  History

Download this file

127 lines (104 with data), 3.0 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
// STL
#include <iostream>
#include "SvnListener.h"
SvnListener::SvnListener( lua_State* luaState, int contextOptionReference )
:
m_luaState( luaState ),
m_contextOptionReference( contextOptionReference )
{
}
bool SvnListener::ContextGetLogin( const std::string& realm, std::string& username, std::string& password, bool& maySave )
{
bool retVal( false );
lua::state lState( m_luaState );
// Get the context options.
lState.rawgeti( m_contextOptionReference, LUA_REGISTRYINDEX );
// Place the listener on the stack.
lState.getfield( "listener" );
lState.getfield( "GetLogin" );
// Check if GetLogin is defined in Lua.
if ( lState.isfunction() )
{
// Push arguments
lState.push( realm );
lState.push( username );
lState.push( password );
lState.push( maySave );
// Call the function
lState.pcall( 4, 3 );
//Get the returns
maySave = lState.as( false );
lState.pop();
std::string passwordStr = lState.as( std::string() );
lState.pop();
username = lState.as( std::string() );
if ( passwordStr.length() > 0 )
{
password = passwordStr;
retVal = true;
}
}
else
{
std::cerr << "Ignoring prompt for credentials and dying" << std::endl;
}
return retVal;
}
void SvnListener::ContextNotify ( const char* path, svn_wc_notify_action_t action, svn_node_kind_t kind, const char * mime_type,
svn_wc_notify_state_t content_state, svn_wc_notify_state_t prop_state, svn_revnum_t revision )
{
lua::state lState( m_luaState );
// Get the context options.
lState.rawgeti( m_contextOptionReference, LUA_REGISTRYINDEX );
// Place the listener on the stack.
lState.getfield( "listener" );
lState.getfield( "Notify" );
// Check if Notify is defined in Lua.
if ( lState.isfunction() )
{
// Push arguments
lState.push( path );
lState.push( action );
lState.push( kind );
lState.push( mime_type );
lState.push( content_state );
lState.push( prop_state );
lState.push( revision );
// Call the function
lState.pcall( 7 );
}
}
bool SvnListener::ContextCancel()
{
return false;
}
bool SvnListener::ContextGetLogMessage( std::string& msg )
{
lua::state lState( m_luaState );
// Get the context options.
lState.rawgeti( m_contextOptionReference, LUA_REGISTRYINDEX );
// Place the listener on the stack.
lState.getfield( "listener" );
lState.getfield( "GetLogMessage" );
// Check if Notify is defined in Lua.
if ( lState.isfunction() )
{
lState.pcall( 0, 1 );
lState.to( msg );
lState.pop();
return true;
}
return false;
}
svn::ContextListener::SslServerTrustAnswer SvnListener::ContextSslServerTrustPrompt( const svn::ContextListener::SslServerTrustData& /* data */, apr_uint32_t& /* acceptedFailures */ )
{
return ACCEPT_TEMPORARILY;
}
bool SvnListener::ContextSslClientCertPrompt( std::string& /* certFile */ )
{
return false;
}
bool SvnListener::ContextSslClientCertPwPrompt( std::string& /* password */, const std::string& /* realm */, bool& /* maySave */ )
{
return false;
}
MongoDB Logo MongoDB