Esempio n. 1
0
        internal static String MarshalAndRelease(IntPtr pStr)
        {
            // TODO: figure out if this works
            String retVal = Marshal.PtrToStringAnsi(pStr);

            P4Bridge.ReleaseString(pStr);
            return(retVal);
        }
Esempio n. 2
0
        private static void RestoreP4Prefs()
        {
            P4Bridge.ReloadEnviro();

            for (int i = 0; i < settings.Length; i++)
            {
                P4Server.Set(settings[i], settingValues[i]);
            }
        }
Esempio n. 3
0
 internal void SetPromptCallback()
 {
     if (PromptCallbackFn_Int == null)
     {
         // initialize on first setting
         PromptCallbackFn_Int =
             new P4CallBacks.PromptDelegate(PromptCallback_Int);
         pPromptCallbackFn = Marshal.GetFunctionPointerForDelegate(PromptCallbackFn_Int);
         P4Bridge.SetPromptCallbackFn(pServer, pPromptCallbackFn);
     }
 }
Esempio n. 4
0
 /// <summary>
 /// Set the callback used to return real time info output.
 /// </summary>
 internal void SetInfoResultsCallback()         //InfoResultsDelegate cb )
 {
     if (InfoResultsCallbackFn_Int == null)
     {
         // initialize on first setting
         InfoResultsCallbackFn_Int =
             new P4CallBacks.InfoResultsDelegate(InfoResultsCallback_Int);
         pInfoResultsCallbackFn = Marshal.GetFunctionPointerForDelegate(InfoResultsCallbackFn_Int);
         P4Bridge.SetInfoResultsCallbackFn(pServer, pInfoResultsCallbackFn);
     }
 }
Esempio n. 5
0
 /// <summary>
 /// Set the callback used to return real time binary output.
 /// </summary>
 /// <remarks>
 /// Far large output, the client may receive multiple callbacks.
 /// Simply concatenate the data to get the complete data.
 /// </remarks>
 internal void SetBinaryResultsCallback()
 {
     if (BinaryResultsCallbackFn_Int == null)
     {
         // initialize on first setting
         BinaryResultsCallbackFn_Int =
             new P4CallBacks.BinaryResultsDelegate(BinaryResultsCallback_Int);
         pBinaryResultsCallbackFn = Marshal.GetFunctionPointerForDelegate(BinaryResultsCallbackFn_Int);
         P4Bridge.SetBinaryResultsCallbackFn(pServer, pBinaryResultsCallbackFn);
     }
 }
Esempio n. 6
0
 /// <summary>
 /// Set the callback used to return real time Errors.
 /// </summary>
 internal void SetErrorCallback()
 {
     if (ErrorCallbackFn_Int == null)
     {
         // initialize on first setting
         ErrorCallbackFn_Int =
             new P4CallBacks.ErrorDelegate(ErrorCallback_Int);
         pErrorCallbackFn = Marshal.GetFunctionPointerForDelegate(ErrorCallbackFn_Int);
         P4Bridge.SetErrorCallbackFn(pServer, pErrorCallbackFn);
     }
 }
Esempio n. 7
0
        //We'll receive multiple calls for each StrDict object, one for each
        //  key:value pair that will get combined into a single TaggedObject.

        /// <summary>
        /// Delegate used to send real time tagged results generated by a
        /// command
        /// </summary>
        /// <remarks>
        /// We receive multiple calls for each StrDict object, one for each
        /// key:value pair that will get combined into a single TaggedObject used
        /// to represent an 'object'. This client delegate receives a single
        /// TaggedObject representing the complete object.
        /// </remarks>
        internal void SetTaggedOutputCallback()
        {
            if (TaggedOutputCallbackFn_Int == null)
            {
                // initialize on first setting
                TaggedOutputCallbackFn_Int =
                    new P4CallBacks.TaggedOutputDelegate(TaggedOutputCallback_Int);
                pTaggedOutputCallbackFn = Marshal.GetFunctionPointerForDelegate(TaggedOutputCallbackFn_Int);
                P4Bridge.SetTaggedOutputCallbackFn(pServer, pTaggedOutputCallbackFn);
            }
        }
Esempio n. 8
0
        /// <summary>
        /// Set the character set encoding used to pass parameters to a Unicode
        /// enabled server.
        /// </summary>
        /// <remarks>
        /// This is handled automatically after connecting with a P4 server.
        /// </remarks>
        /// <param name="charSet">connection characterset</param>
        /// <param name="FileCharSet">filename characterset</param>
        internal void SetCharacterSet(String charSet, String FileCharSet)
        {
            IntPtr pErrorStr = P4Bridge.SetCharacterSet(pServer, charSet, FileCharSet);

            if (pErrorStr == IntPtr.Zero)              // no error
            {
                return;
            }

            String ErrorMsg = MarshalPtrToString(pErrorStr);

            P4Bridge.ReleaseString(pErrorStr);
            throw new P4Exception(ErrorSeverity.E_FAILED, ErrorMsg);
        }
Esempio n. 9
0
        /// <summary>
        /// Thread entry point for running more P4Servers
        /// </summary>
        private static void ParallelTransferThread(object args)
        {
            ParallelTransferArgs transferArgs = (ParallelTransferArgs)args;

            // make a new connection to the server and run the command
            // we should not need trust or fingerprint as this should initiate from a successful (trusted) session
            using (P4Server target = new P4Server(transferArgs.original))
            {
                // add the server for the original P4Server
                lock (transferArgs.original.parallelServers)
                {
                    transferArgs.original.parallelServers.Add(target);
                }

                // set the dictionary as protocol settings
                foreach (KeyValuePair p in transferArgs.dict)
                {
                    P4Bridge.SetProtocol(target.pServer, p.Key, p.Value);
                }

                try
                {
                    // Note: due to legacy (unused) cmdId code in p4bridge, cmdId < 0 will explicitly not call
                    //       the assigned callbacks.  set the cmdId from the other's cmdId generator
                    if (target.RunCommand(transferArgs.cmd, transferArgs.original.getCmdId(), true, transferArgs.args, transferArgs.args.Length))
                    {
                        target.Disconnect();
                        return;
                    }
                }
                catch (P4Exception e)
                {
                    Debug.Trace(e.Message);
                }
                // grab the errors and inject them into the original P4Server
                P4ClientErrorList list = target.GetErrorResults(0);
                // sometimes we get here without client errors (e.g. disconnect?)
                if (transferArgs.original.parallelErrors != null && list != null)
                {
                    // make sure the threads don't step on each other
                    lock (transferArgs.original.parallelErrors)
                    {
                        foreach (P4ClientError e in list)
                        {
                            transferArgs.original.parallelErrors.Add(e);
                        }
                    }
                }
            }
        }
Esempio n. 10
0
        /// <summary>
        ///  Translate a file path from on side of the mapping to the other
        /// </summary>
        /// <param name="path">The path to translate</param>
        /// <param name="direction">The direction to perform the translation L->R or R->L</param>
        /// <returns>Translated path, Null if no translation (path is not mapped)</returns>
        public String Translate(String path, Direction direction)
        {
            IntPtr pStr = IntPtr.Zero;

            if (UseUnicode)
            {
                using (PinnedByteArray pPath = MarshalStringToIntPtr(path))
                {
                    pStr = TranslateW(pMapApi, pPath, direction);
                }
            }
            else
            {
                pStr = TranslateA(pMapApi, path, direction);
            }

            if (pStr != IntPtr.Zero)
            {
                String translation = MarshalPtrToString(pStr);
                P4Bridge.ReleaseString(pStr);
                return(translation);
            }
            return(null);
        }