ClientApi_m.h #3

  • //
  • guest/
  • jacob_gladish/
  • PerforceDotNet/
  • p4dn/
  • ClientApi_m.h
  • View
  • Commits
  • Open Download .zip Download (3 KB)
#pragma once
#using <mscorlib.dll>

#include "Error_m.h"
#include "ClientUser_m.h"
#include "KeepAlive_m.h"

using namespace System;
using namespace System::Runtime::InteropServices;

System::String* ToDotNetString( const StrPtr& p );


namespace p4dn {

    __gc public class ClientApi 
    {

    public:

        ClientApi();
        ~ClientApi();

        void SetTrans( int output, int content, int fnames, int dialog );
        void SetProtocol( String *p, String *v );
        void SetProtocolV( String *p );
        String*	GetProtocol( String *v );

        void Init( p4dn::Error *e );
        void Run( String* func, p4dn::ClientUser *ui );
        int Final( p4dn::Error *e );
        int	Dropped();

        void RunTag( String* func, p4dn::ClientUser *ui );
        void WaitTag( p4dn::ClientUser *ui );

        void SetCharset( String* c );
        void SetClient( String* c );
        void SetCwd( String* c );
        void SetHost( String* c );
        void SetLanguage( String* c );
        void SetPassword( String* c );
        void SetPort( String* c );
        void SetUser( String* c );
        void SetArgv( String* args[] );
        void SetBreak( p4dn::KeepAlive *keepAlive );

        void DefineCharset( String* c, p4dn::Error* e );
        void DefineClient( String* c, p4dn::Error* e );
        void DefineHost( String* c, p4dn::Error* e );
        void DefineLanguage( String* c, p4dn::Error* e );
        void DefinePassword( String* c, p4dn::Error* e );
        void DefinePort( String* c, p4dn::Error* e );
        void DefineUser( String* c, p4dn::Error* e );        

        __property String* get_Charset()  { return ToDotNetString(_clientApi->GetCharset()); }
        __property String* get_Client()   { return ToDotNetString(_clientApi->GetClient()); }
        __property String* get_Cwd()      { return ToDotNetString(_clientApi->GetCwd()); }
        __property String* get_Host()     { return ToDotNetString(_clientApi->GetHost()); }
        __property String* get_Language() { return ToDotNetString(_clientApi->GetLanguage()); }
        __property String* get_Os()       { return ToDotNetString(_clientApi->GetOs()); }
        __property String* get_Password() { return ToDotNetString(_clientApi->GetPassword()); }
        __property String* get_Port()     { return ToDotNetString(_clientApi->GetPort()); }
        __property String* get_User()     { return ToDotNetString(_clientApi->GetUser()); }

    private:
        ::ClientApi* _clientApi;

    private:
        //================================================================
        // 
        // class for callbacks into the KeepAlive interfaces
        //
        __nogc class KeepAliveDelegate : ::KeepAlive {
        private:
            // handle to managed KeepAlive class
            int _keepAliveHandle;        
        public:
            KeepAliveDelegate( int handle ) : _keepAliveHandle(handle) { }
            ~KeepAliveDelegate() { 
                GCHandle h = GCHandle::op_Explicit( IntPtr(_keepAliveHandle) );
                h.Free();
            }
            virtual int IsAlive() {
                GCHandle h = GCHandle::op_Explicit( IntPtr(_keepAliveHandle) );
                p4dn::KeepAlive* keepAlive = static_cast< p4dn::KeepAlive* >( h.Target );
                bool b = keepAlive->IsAlive();
                return ( b ? 1 : 0 );
            }
        };
        KeepAliveDelegate* _keepAliveDelegate;
    };
}
# 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