ClientApi_m.h #1

  • //
  • guest/
  • robert_cowham/
  • perforce/
  • API/
  • P4.Net/
  • main/
  • src/
  • p4dn/
  • ClientApi_m.h
  • View
  • Commits
  • Open Download .zip Download (6 KB)
/*
 * P4.Net *
Copyright (c) 2007 Shawn Hladky

Permission is hereby granted, free of charge, to any person obtaining a copy of this software 
and associated documentation files (the "Software"), to deal in the Software without 
restriction, including without limitation the rights to use, copy, modify, merge, publish, 
distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the 
Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or 
substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING 
BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 
 */


#pragma once

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

using namespace System::Runtime::InteropServices;

namespace p4dn {

        //================================================================
        // 
        // class for callbacks into the KeepAlive interfaces
        //
	class KeepAliveDelegate : public ::KeepAlive 
		{
        private:
            // handle to managed KeepAlive class
            //int _keepAliveHandle;        
		gcroot<p4dn::KeepAlive^> _KeepAlive;
        public:
            KeepAliveDelegate() 
			{
				 _KeepAlive = NULL;
			}
        void SetKeepAlive(gcroot<p4dn::KeepAlive^> mKeepAlive) 
			{
				_KeepAlive = mKeepAlive;
			}
            ~KeepAliveDelegate()
			{
				// Free the GC refererence
				delete _KeepAlive;
			}
            
			int IsAlive() {
				
			if ((p4dn::KeepAlive^)_KeepAlive == nullptr){
					//Console::WriteLine("p4dn::KeepAlive::IsAlive() -- _KeepAlive == NULL");
					return 1;
				}
                bool b = _KeepAlive->IsAlive();
				if (!b)
				{
					//Console::WriteLine("p4dn::KeepAlive::IsAlive() -- Not Alive!");
				}
				else
				{
					//Console::WriteLine("p4dn::KeepAlive::IsAlive() -- Is Alive!");
				}
                return ( b ? 1 : 0 );
            }
        };

	public ref class ClientApi : public System::IDisposable 
    {

    public:

        ClientApi();
        ~ClientApi();

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

        void Init( p4dn::Error^ e );
        void Run(System::String^ func, p4dn::ClientUser^ ui );
		//void SaveForm(System::String^ func, p4dn::ClientUser^ ui );
        int Final(p4dn::Error^ e );
        int	Dropped();
		p4dn::Error^ CreateError();
		p4dn::Spec^  CreateSpec(System::String^ specDef);

        //void RunTag( String^ func, p4dn::ClientUser^ ui );
        //void WaitTag( p4dn::ClientUser^ ui );
		void SetVar(System::String^ var, System::String^ val);
		void SetTag();

        void SetCharset( System::String^ c );
        void SetClient( System::String^ c );
        void SetCwd( System::String^ c );
        void SetHost( System::String^ c );
        void SetLanguage( System::String^ c );
        void SetPassword( System::String^ c );
        void SetPort( System::String^ c );
		void SetProg( System::String^ c );
		void SetVersion( System::String^ c );
		void SetTicketFile( System::String^ c );
        void SetUser( System::String^ c );
        void SetArgv( array<System::String^>^ args );
        void SetBreak( p4dn::KeepAlive^ keepAlive );

		void SetMaxResults(int maxResults);
		void SetMaxScanRows(int maxScanRows);
		void SetMaxLockTime(int maxLockTime);

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

		property System::String^ Charset     { System::String^ get() { return gcnew System::String(_clientApi->GetCharset().Text()); } }
		property System::String^ Client      { System::String^ get() { return gcnew System::String(_clientApi->GetClient().Text()); } }
		property System::String^ Cwd         { System::String^ get() { return gcnew System::String(_clientApi->GetCwd().Text()); } }
		property System::String^ Host        { System::String^ get() { return gcnew System::String(_clientApi->GetHost().Text()); } }
		property System::String^ Language    { System::String^ get() { return gcnew System::String(_clientApi->GetLanguage().Text()); } }
		property System::String^ Os          { System::String^ get() { return gcnew System::String(_clientApi->GetOs().Text()); } }
		property System::String^ Password    { System::String^ get() { return gcnew System::String(_clientApi->GetPassword().Text()); } }
		property System::String^ Port        { System::String^ get() { return gcnew System::String(_clientApi->GetPort().Text()); } }
		property System::String^ User        { System::String^ get() { return gcnew System::String(_clientApi->GetUser().Text()); } }

		property System::Text::Encoding^ Encoding     { System::Text::Encoding^ get() { return _encoding; } }

    private:
        ::ClientApi* _clientApi;
		::ClientApi* getClientApi();
		System::Text::Encoding^ _encoding;
		void CleanUp();
		bool _Disposed;

    private:
        KeepAliveDelegate* _keepAliveDelegate;
    };
}
# Change User Description Committed
#1 6414 Robert Cowham Initial branch
//guest/shawn_hladky/P4.Net/main/src/p4dn/ClientApi_m.h
#9 6387 Shawn Hladky P4.net: Upgrade to C++/CLI.
 Changes merged from Jim Gomes.
#8 6386 Shawn Hladky P4.Net: Optimized connections by not reconnecting between tagged/untagged transitions.
#7 6238 Shawn Hladky P4.Net: More work on callback interface.
 Run and RunUnparsed now use the callback interface under the covers.
#6 6102 Shawn Hladky P4.Net: Documentation.
 Fixed SetTicketFile bug.  Added form processing with SpecDef.  Stubbed-out code for launching external merge tool, but is disabled since it's too difficult to use.
#5 5915 Shawn Hladky p4.net
Fixed diff2 bug.
Re-worked array field logic
More unit tests
Organized P4Connection w/ #region blocks, and moved methods around
#4 5902 Shawn Hladky P4.net.
 More unit tests and bug fixes
#3 5878 Shawn Hladky P4.Net:  1.0, support for raw spec processing.
 Update copyright.  Fix build script.  Bugs found along the way.
#2 5838 Shawn Hladky P4.Net: WIP support for unicode server
#1 5830 Shawn Hladky P4.Net: reorg to support release branches
//guest/shawn_hladky/P4.Net/src/p4dn/ClientApi_m.h
#3 5798 Shawn Hladky P4.Net...  still not ready for beta
Added license to all files
Added several doc files
Misc bugs
#2 5373 Shawn Hladky P4.Net: Still WIP, but some things starting to work
#1 5348 Shawn Hladky Re-organizing, for the improved API
//guest/shawn_hladky/PerforceDotNet/p4dn/ClientApi_m.h
#3 5064 Shawn Hladky WIP -- Added ability to parse forms.
Added new tester application.
** not ready for human consumption, needs more review and testing.
#2 4545 Shawn Hladky Several Fixes:
Updated solution to Visual Studio 2003
Implemented InputData
Implemented OutPutBinary
Changed ClientAPI and Error objects to implement the IDisposable interface to improve Garbage Collection
Changed header files so you don't need to add #pragma once to the p4 api headers.
Refactored the ClientUserDelagate class
Fixed a few minor memory leaks
#1 4328 Shawn Hladky Branching from //guest/jacob_gladish/PerforceDotNet/...
//guest/jacob_gladish/PerforceDotNet/p4dn/ClientApi_m.h
#1 3787 Jacob Gladish initial code submission