#include "StdAfx.h" #using <mscorlib.dll> #include "clientapi_m.h" using namespace System::Runtime::InteropServices; p4dn::ClientApi::ClientApi() { _clientApi = new ::ClientApi(); _keepAliveDelegate = NULL; } p4dn::ClientApi::~ClientApi() { delete _clientApi; delete _keepAliveDelegate; } void p4dn::ClientApi::SetTrans( int output, int content, int fnames, int dialog ) { _clientApi->SetTrans( output, content, fnames, dialog ); } void p4dn::ClientApi::SetProtocol( String *p, String *v ) { char* str_p = (char *)(void *) Marshal::StringToHGlobalAnsi( p ); char* str_v = (char *)(void *) Marshal::StringToHGlobalAnsi( v ); _clientApi->SetProtocol( str_p, str_v ); Marshal::FreeHGlobal( str_p ); Marshal::FreeHGlobal( str_v ); } void p4dn::ClientApi::SetArgv( String* args[] ) { char** argsArray = new char* [ args->Length ]; for (int i = 0; i < args->Length; ++i) { argsArray[i] = (char *)(void *) Marshal::StringToHGlobalAnsi( args[i] ); } _clientApi->SetArgv( args->Length, argsArray ); for (int i = 0; i < args->Length; ++i) { Marshal::FreeHGlobal( argsArray[i] ); } } void p4dn::ClientApi::SetProtocolV( String* p ) { char* str_p = (char *)(void *) Marshal::StringToHGlobalAnsi( p ); _clientApi->SetProtocolV( str_p ); Marshal::FreeHGlobal( str_p ); } String* p4dn::ClientApi::GetProtocol( String *v ) { char* str_p = (char *)(void *) Marshal::StringToHGlobalAnsi( v ); StrPtr* ptr = _clientApi->GetProtocol( str_p ); String* s = ptr->Text(); delete ptr; Marshal::FreeHGlobal( str_p ); return s; } void p4dn::ClientApi::Init( p4dn::Error* e ) { _clientApi->Init( e->get_InternalError() ); } void p4dn::ClientApi::Run( String* func, p4dn::ClientUser *ui ) { // System::Console::WriteLine( "Running command {0}", func ); char* f = (char *)(void *) Marshal::StringToHGlobalAnsi( func ); _clientApi->Run( f, ui->_clientUserDelegate ); Marshal::FreeHGlobal( f ); } int p4dn::ClientApi::Final( p4dn::Error *e ) { return _clientApi->Final( e->get_InternalError() ); } int p4dn::ClientApi::Dropped() { return _clientApi->Dropped(); } void p4dn::ClientApi::RunTag( String* func, p4dn::ClientUser *ui ) { char* f = (char *)(void *) Marshal::StringToHGlobalAnsi( func ); _clientApi->RunTag( f, ui->_clientUserDelegate ); Marshal::FreeHGlobal( f ); } void p4dn::ClientApi::WaitTag( p4dn::ClientUser *ui ) { _clientApi->WaitTag( ui->_clientUserDelegate ); } void p4dn::ClientApi::SetCharset( String* c ) { char* f = (char *)(void *) Marshal::StringToHGlobalAnsi( c ); _clientApi->SetCharset( f ); Marshal::FreeHGlobal( f ); } void p4dn::ClientApi::SetClient( String* c ) { char* f = (char *)(void *) Marshal::StringToHGlobalAnsi( c ); _clientApi->SetClient( f ); Marshal::FreeHGlobal( f ); } void p4dn::ClientApi::SetCwd( String* c ) { char* f = (char *)(void *) Marshal::StringToHGlobalAnsi( c ); _clientApi->SetCwd( f ); Marshal::FreeHGlobal( f ); } void p4dn::ClientApi::SetHost( String* c ) { char* f = (char *)(void *) Marshal::StringToHGlobalAnsi( c ); _clientApi->SetHost( f ); Marshal::FreeHGlobal( f ); } void p4dn::ClientApi::SetLanguage( String* c ) { char* f = (char *)(void *) Marshal::StringToHGlobalAnsi( c ); _clientApi->SetLanguage( f ); Marshal::FreeHGlobal( f ); } void p4dn::ClientApi::SetPassword( String* c ) { char* f = (char *)(void *) Marshal::StringToHGlobalAnsi( c ); _clientApi->SetPassword( f ); Marshal::FreeHGlobal( f ); } void p4dn::ClientApi::SetPort( String* c ) { char* f = (char *)(void *) Marshal::StringToHGlobalAnsi( c ); _clientApi->SetPort( f ); Marshal::FreeHGlobal( f ); } void p4dn::ClientApi::SetUser( String* c ) { char* f = (char *)(void *) Marshal::StringToHGlobalAnsi( c ); _clientApi->SetUser( f ); Marshal::FreeHGlobal( f ); } void p4dn::ClientApi::SetBreak( p4dn::KeepAlive *keepAlive ) { if (_keepAliveDelegate != NULL) { return; } // get pinned handle and stach it away. GCHandle h =GCHandle::Alloc( keepAlive ); IntPtr ptr = GCHandle::op_Explicit( h ); int handle = ptr.ToInt32(); _keepAliveDelegate = new KeepAliveDelegate( handle ); } void p4dn::ClientApi::DefineCharset( String* c, p4dn::Error* e ) { char* f = (char *)(void *) Marshal::StringToHGlobalAnsi( c ); _clientApi->DefineCharset( f, e->get_InternalError() ); Marshal::FreeHGlobal( f ); } void p4dn::ClientApi::DefineClient( String* c, p4dn::Error* e ) { char* f = (char *)(void *) Marshal::StringToHGlobalAnsi( c ); _clientApi->DefineClient( f, e->get_InternalError() ); Marshal::FreeHGlobal( f ); } void p4dn::ClientApi::DefineHost( String* c, p4dn::Error* e ) { char* f = (char *)(void *) Marshal::StringToHGlobalAnsi( c ); _clientApi->DefineHost( f, e->get_InternalError() ); Marshal::FreeHGlobal( f ); } void p4dn::ClientApi::DefineLanguage( String* c, p4dn::Error* e ) { char* f = (char *)(void *) Marshal::StringToHGlobalAnsi( c ); _clientApi->DefineLanguage( f, e->get_InternalError() ); Marshal::FreeHGlobal( f ); } void p4dn::ClientApi::DefinePassword( String* c, p4dn::Error* e ) { char* f = (char *)(void *) Marshal::StringToHGlobalAnsi( c ); _clientApi->DefinePassword( f, e->get_InternalError() ); Marshal::FreeHGlobal( f ); } void p4dn::ClientApi::DefinePort( String* c, p4dn::Error* e ) { char* f = (char *)(void *) Marshal::StringToHGlobalAnsi( c ); _clientApi->DefinePort( f, e->get_InternalError() ); Marshal::FreeHGlobal( f ); } void p4dn::ClientApi::DefineUser( String* c, p4dn::Error* e ) { char* f = (char *)(void *) Marshal::StringToHGlobalAnsi( c ); _clientApi->DefineUser( f, e->get_InternalError() ); Marshal::FreeHGlobal( f ); }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#3 | 7712 | Jacob Gladish |
Removed license. Need to ensure proper assignment first. |
||
#2 | 7704 | Jacob Gladish | Updated license to freebsd | ||
#1 | 3787 | Jacob Gladish | initial code submission |