crashanalysercmd/UI/CrashServer/CACommandLineUI.cs
changeset 0 818e61de6cd1
equal deleted inserted replaced
-1:000000000000 0:818e61de6cd1
       
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 *
       
    16 */
       
    17 using System;
       
    18 using System.IO;
       
    19 using System.Text;
       
    20 using System.Collections.Generic;
       
    21 using System.Data;
       
    22 using SymbianDebugLib.Engine;
       
    23 using SymbianXmlInputLib.Elements;
       
    24 using SymbianXmlInputLib.Parser;
       
    25 using SymbianXmlInputLib.Parser.Nodes;
       
    26 using SymbianUtils.FileSystem;
       
    27 using SymbianUtils.Tracer;
       
    28 using SymbianUtils;
       
    29 using CrashAnalyserServerExe.Engine;
       
    30 
       
    31 namespace CrashAnalyserServerExe
       
    32 {
       
    33     internal class CACommandLineUI : DisposableObject, ITracer
       
    34 	{
       
    35 		#region Constructors
       
    36         public CACommandLineUI( string[] aArguments, FSLog aLog )
       
    37 		{
       
    38             iLog = aLog;
       
    39 
       
    40             // Create engine
       
    41             iDebugEngine = new DbgEngine( this );
       
    42 
       
    43             // Work out if we are in verbose mode
       
    44             CheckArgsForVerbose();
       
    45 
       
    46             // Create main command line engine
       
    47             iEngine = new CACmdLineEngine( iDebugEngine );
       
    48         }
       
    49 		#endregion
       
    50 
       
    51         #region API
       
    52         public int Run()
       
    53         {
       
    54             iLog.TraceAlways( "[SvrExe] Run() - START" );
       
    55             //
       
    56             int error = CACmdLineException.KErrNone;
       
    57             try
       
    58             {
       
    59                 error = iEngine.RunCommandLineOperations();
       
    60             }
       
    61             finally
       
    62             {
       
    63                 iLog.TraceAlways( "[SvrExe] Run() - END - error: " + error );
       
    64             }
       
    65             //
       
    66             return error;
       
    67         }
       
    68         #endregion
       
    69 
       
    70         #region Properties
       
    71         public bool Verbose
       
    72         {
       
    73             get { return iLog.Verbose; }
       
    74             private set
       
    75             { 
       
    76                 iLog.Verbose = value;
       
    77                 iLog.TraceAlways( "[SvrExe] Verbose Mode: " + value.ToString() );
       
    78             }
       
    79         }
       
    80         #endregion
       
    81 
       
    82         #region Internal constants
       
    83         private const string KParamVerbose = "-V";
       
    84         #endregion
       
    85 
       
    86         #region Internal methods
       
    87         private void CheckArgsForVerbose()
       
    88         {
       
    89             bool ret = Environment.CommandLine.Contains( KParamVerbose );
       
    90             this.Verbose = ret;
       
    91         }
       
    92         #endregion
       
    93 
       
    94         #region From ITracer
       
    95         public void Trace( string aMessage )
       
    96         {
       
    97             iLog.Trace( aMessage );
       
    98         }
       
    99 
       
   100         public void Trace( string aFormat, params object[] aParams )
       
   101         {
       
   102             string msg = string.Format( aFormat, aParams );
       
   103             Trace( msg );
       
   104         }
       
   105         #endregion
       
   106 
       
   107         #region From DisposableObject
       
   108         protected override void CleanupManagedResources()
       
   109         {
       
   110             try
       
   111             {
       
   112                 base.CleanupManagedResources();
       
   113             }
       
   114             finally
       
   115             {
       
   116                 iEngine.Dispose();
       
   117             }
       
   118         }
       
   119         #endregion
       
   120 
       
   121         #region Data members
       
   122         private readonly DbgEngine iDebugEngine;
       
   123         private readonly FSLog iLog;
       
   124         private readonly CACmdLineEngine iEngine;
       
   125         #endregion
       
   126     }
       
   127 }