#using <mscorlib.dll> #include "StdAfx.h" #include "clientuser_m.h" #include "stdhdrs.h" using namespace System; using namespace System::Collections::Specialized; using namespace System::Runtime::InteropServices; System::String* ToDotNetString( const StrPtr& p ) { System::String* s = p.Text(); return s; } /* static ::StrBuf* _fromDotNetStringToStrBuf( System::String* s ) { System::IntPtr ptr = Marshal::StringToHGlobalAnsi( s ); const char* str = static_cast< const char * >( ptr.ToPointer() ); ::StrBuf* sb = new ::StrBuf(); sb->Set( str ); Marshal::FreeHGlobal( ptr ); return sb; } */ p4dn::ClientUser::ClientUser() { GCHandle h = GCHandle::Alloc( this ); IntPtr ptr = GCHandle::op_Explicit( h ); _clientUserDelegate = new ClientUserDelegate( ptr.ToInt32() ); } p4dn::ClientUser::~ClientUser() { delete _clientUserDelegate; } void p4dn::ClientUser::InputData( String* s, p4dn::Error* err ) { } void p4dn::ClientUser::HandleError( p4dn::Error* err ) { } void p4dn::ClientUser::Message( p4dn::Error* err ) { } void p4dn::ClientUser::OutputError( String* s ) { } void p4dn::ClientUser::OutputInfo( Char level, String* s ) { } //void p4dn::ClientUser::OutputBinary( unsigned char data[] ) //{ // //} void p4dn::ClientUser::OutputText( String* s ) { } void p4dn::ClientUser::OutputStat( StringDictionary* varList ) { } void p4dn::ClientUser::Prompt( const String* msg, String*& rsp, bool noEcho, p4dn::Error* err ) { } void p4dn::ClientUser::ErrorPause( System::String* errBuf, p4dn::Error* err ) { } void p4dn::ClientUser::Edit( System::IO::FileInfo* info, p4dn::Error *err ) { } void p4dn::ClientUser::Diff( System::IO::FileInfo* f1, System::IO::FileInfo* f2, int doPage, System::String* diffFlags, p4dn::Error *err ) { } void p4dn::ClientUser::Merge( System::IO::FileInfo* base, System::IO::FileInfo* leg1, System::IO::FileInfo* leg2, System::IO::FileInfo* result, p4dn::Error* err ) { } void p4dn::ClientUser::Help( System::String* help ) { } void p4dn::ClientUser::RunCmd( System::String* command, System::String* arg1, System::String* arg2, System::String* arg3, System::String* arg4, System::String* pager, Error* err ) { char* cmd = (char *)(void *) Marshal::StringToHGlobalAnsi( command ); char* a1 = (char *)(void *) Marshal::StringToHGlobalAnsi( arg1 ); char* a2 = (char *)(void *) Marshal::StringToHGlobalAnsi( arg2 ); char* a3 = (char *)(void *) Marshal::StringToHGlobalAnsi( arg3 ); char* a4 = (char *)(void *) Marshal::StringToHGlobalAnsi( arg4 ); char* pgr = (char *)(void *) Marshal::StringToHGlobalAnsi( pager ); ::ClientUser::RunCmd( cmd, a1, a2, a3, a4, pgr, err->get_InternalError() ); Marshal::FreeHGlobal( cmd ); Marshal::FreeHGlobal( a1 ); Marshal::FreeHGlobal( a2 ); Marshal::FreeHGlobal( a3 ); Marshal::FreeHGlobal( a4 ); Marshal::FreeHGlobal( pgr ); } //======================================================================== // Internal Object // p4dn::ClientUser* p4dn::ClientUser::ClientUserDelegate::_getClientUser() { GCHandle h = GCHandle::op_Explicit( IntPtr(_clientUserHandle) ); return static_cast< p4dn::ClientUser* >( h.Target ); } p4dn::ClientUser::ClientUserDelegate::~ClientUserDelegate() { GCHandle h = GCHandle::op_Explicit( IntPtr(_clientUserHandle) ); h.Free(); } void p4dn::ClientUser::ClientUserDelegate::InputData( StrBuf *strbuf, ::Error* err ) { System::String* s = strbuf->Text(); p4dn::Error* e = new p4dn::Error( err ); p4dn::ClientUser* cu = _getClientUser(); cu->InputData( s, e ); } void p4dn::ClientUser::ClientUserDelegate::HandleError( ::Error *err ) { p4dn::Error* e = new p4dn::Error( err); p4dn::ClientUser* cu = _getClientUser(); cu->HandleError( e ); } void p4dn::ClientUser::ClientUserDelegate::Message( ::Error *err ) { p4dn::Error* e = new p4dn::Error( err ); p4dn::ClientUser* cu = _getClientUser(); cu->Message( e ); // TODO: DO I need to delete the error??? } void p4dn::ClientUser::ClientUserDelegate::OutputError( const_char *errBuf ) { System::String* s = errBuf; p4dn::ClientUser* cu = _getClientUser(); cu->OutputError( s ); } void p4dn::ClientUser::ClientUserDelegate::OutputInfo( char level, const_char *data ) { System::String* s = data; p4dn::ClientUser* cu = _getClientUser(); cu->OutputInfo( level, s ); } // virtual void p4dn::ClientUser::ClientUserDelegate::OutputBinary( const_char *data, int length ){} void p4dn::ClientUser::ClientUserDelegate::OutputText( const_char *data, int length ) { System::String* s = data; p4dn::ClientUser* cu = _getClientUser(); cu->OutputText( s ); } void p4dn::ClientUser::ClientUserDelegate::OutputStat( StrDict *varList ) { System::Collections::Specialized::StringDictionary* dict = new System::Collections::Specialized::StringDictionary(); int i = 0; ::StrRef var, val; while (varList->GetVar(i,var,val) != -0) { System::String* key = var.Text(); System::String* value = val.Text(); if (!dict->ContainsKey(key)) { dict->Add( key, value ); } i++; } p4dn::ClientUser* cu = _getClientUser(); cu->OutputStat( dict ); } void p4dn::ClientUser::ClientUserDelegate::Prompt( const StrPtr& msg, StrBuf& rsp, int noEcho, ::Error *err ) { String* response; String* message = ToDotNetString( msg ); bool bEcho = ( noEcho != 0 ); p4dn::Error* e = new p4dn::Error( err ); p4dn::ClientUser* cu = _getClientUser(); cu->Prompt( message, response, bEcho, e ); char* str = (char *)(void *) Marshal::StringToHGlobalAnsi( response ); rsp.Set( str ); Marshal::FreeHGlobal( str ); } void p4dn::ClientUser::ClientUserDelegate::ErrorPause( char *errBuf, ::Error *err ) { System::String* s = errBuf; p4dn::Error* e = new p4dn::Error( err ); p4dn::ClientUser* cu = _getClientUser(); cu->ErrorPause( s, e ); } void p4dn::ClientUser::ClientUserDelegate::Edit( FileSys *f1, ::Error *err ) { p4dn::Error* e = new p4dn::Error( err ); System::String* name = f1->Name(); System::IO::FileInfo* info = new System::IO::FileInfo( name ); p4dn::ClientUser* cu = _getClientUser(); cu->Edit( info, e ); } void p4dn::ClientUser::ClientUserDelegate::Diff( FileSys *f1, FileSys *f2, int doPage, char *diffFlags, ::Error *e ) { // TODO: System::Console::WriteLine( "10" ); } void p4dn::ClientUser::ClientUserDelegate::Merge( FileSys *base, FileSys *leg1, FileSys *leg2, FileSys *result, ::Error *e ) { // TODO: } // virtual int p4dn::ClientUser::ClientUserDelegate::Resolve( ClientMerge *m, Error *e ){} void p4dn::ClientUser::ClientUserDelegate::Help( const_char *const *help ) { System::String* s = *help; p4dn::ClientUser* cu = _getClientUser(); cu->Help( s ); } FileSys* p4dn::ClientUser::ClientUserDelegate::File( FileSysType type ) { // TODO: does this need to be expose? I'm pretty sure it doesn't return FileSys::Create( type ); } void p4dn::ClientUser::ClientUserDelegate::Finished() { p4dn::ClientUser* cu = _getClientUser(); cu->Finished(); }
# | 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 |