Ejemplo n.º 1
0
        private static void ProcessCommandLine(Cruncher cruncher)
        {
            Console.WriteLine(Strings.WhatDoYouHave);
            Console.WriteLine(Strings.TitaniumBackupArchive);
            Console.WriteLine(Strings.DatabaseFile);

            while (true)
            {
                var key = Console.ReadKey();
                Console.WriteLine();

                switch (key.KeyChar)
                {
                case '1':
                    ChosePath(filePath => SaveCrunched(cruncher.CrunchTitaniumArchive(filePath)), "com.google.android.apps.authenticator2.tar.gz");
                    return;

                case '2':
                    ChosePath(filePath => SaveCrunched(cruncher.CrunchDbFile(filePath)), DbFileName);
                    return;
                }
            }
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            try
            {
                var cruncher = new Cruncher();

                var files = Directory.GetFiles(Directory.GetCurrentDirectory(), ArchiveFileType);

                if (files.Any())
                {
                    SaveCrunched(cruncher.CrunchTitaniumArchive(files.First()));
                }
                else if (File.Exists(DbFileName))
                {
                    SaveCrunched(cruncher.CrunchDbFile(DbFileName));
                }
                else if (!args.Any())
                {
                    ProcessCommandLine(cruncher);
                }
                else if (args.Length != 1)
                {
                    SaveCrunched(cruncher.CrunchTitaniumArchive(args[0]));
                }
                else if (args.Length != 2)
                {
                    Console.WriteLine(Strings.WrongCountOfArguments);
                    Console.WriteLine(Strings.Help);
                }
                else if (!File.Exists(args[1]))
                {
                    Console.WriteLine(Strings.FileDoesNotExist, args[1]);
                }
                else
                {
                    switch (args[0])
                    {
                    case "archive":
                        SaveCrunched(cruncher.CrunchTitaniumArchive(args[1]));
                        break;

                    case "db":
                        SaveCrunched(cruncher.CrunchDbFile(args[1]));
                        break;

                    default:
                        Console.WriteLine(Strings.UnexpectedArgument);
                        break;
                    }
                }
            }
            catch (GoogleAuthDatabaseException e)
            {
                AddToLog(e.InnerException);
                Console.WriteLine(Strings.DbFileUnrecognized);
            }
            catch (GoogleAuthUnarchiverException e)
            {
                AddToLog(e.InnerException);
                Console.WriteLine(Strings.ArchiveFileCannotBeProcessed);
            }
            catch (Exception e)
            {
                AddToLog(e);
                Console.WriteLine(Strings.UnexpectedBehaviour);
            }

            Console.WriteLine(Strings.PressAnyKey);
            Console.ReadKey();
            // TODO may be Wipe QR after approval
            //DirectoryHelper.WipeAndDelete(ExportDirectoryName);
        }