Inheritance: IDisposable
 public CloudPrintInfoServer(string baseurl, CloudPrintProxy printproxy)
 {
     HttpSelfHostConfiguration cfg = new HttpSelfHostConfiguration(baseurl);
     cfg.Routes.MapHttpRoute(
         "default",
         "{controller}/{id}",
         new { controller = "Home", id = RouteParameter.Optional }
     );
     cfg.Filters.Add(new Filters.HandleErrorFilter());
     cfg.Filters.Add(new Filters.CookiesFilter());
     cfg.Filters.Add(new Filters.WindowsAuthorizationFilter());
     cfg.Filters.Add(new Filters.CloudPrintProxyFilter { PrintProxy = printproxy });
     Server = new HttpSelfHostServer(cfg);
     AuthServiceRegistration = new AuthServiceRegistration(printproxy);
 }
        protected override void OnStart(string[] args)
        {
            this.Stopped.Reset();
            Logger.Log(LogLevel.Info, "Starting service");
            PrintProcessor = new WindowsPrintJobProcessor();

            PrintProxy = new CloudPrintProxy(PrintProcessor, (p) => Stop());

            InfoServer = new CloudPrintInfoServer(Config.UserAuthHttpPort, PrintProxy);
            InfoServer.Start();

            if (PrintProxy.IsRegistered)
            {
                PrintProxy.Start(true);
            }
            Logger.Log(LogLevel.Info, "Service started");
        }
        protected CloudPrintJobImpl(CloudPrintProxy proxy, string basename)
        {
            this._Proxy = proxy;

            using (TextReader rdr = File.OpenText(basename + ".job.json"))
            {
                _JobAttributes = Util.JsonHelper.ReadJson(rdr);
            }

            using (TextReader rdr = File.OpenText(basename + ".job.xml"))
            {
            }

            this._PrintDataBasename = basename;
            this._PrintDataFileName = basename + ".pdf";

            _PrintJobs[this.JobID] = this;
        }
        public CloudPrintJobImpl(CloudPrintProxy proxy, CloudPrinter printer, dynamic job)
        {
            this._Proxy = proxy;
            this._Printer = printer;
            this._JobAttributes = job;
            string jobdirname = Path.Combine(Config.DataDirName, "PrintJobs", this.Username);
            this._PrintDataBasename = Path.Combine(jobdirname, job.id);
            this._PrintDataFileName = _PrintDataBasename + ".pdf";

            Directory.CreateDirectory(jobdirname);

            WriteJobData();
            WriteJobTicket();
            WriteJobXml();
            WriteJobJson();

            _PrintJobs[this.JobID] = this;
        }
        protected override void OnStop()
        {
            Logger.Log(LogLevel.Info, "Stopping service");
            if (InfoServer != null)
            {
                InfoServer.Dispose();
                InfoServer = null;
            }

            if (PrintProxy != null)
            {
                PrintProxy.Dispose();
                PrintProxy = null;
            }

            if (PrintProcessor != null)
            {
                PrintProcessor.Dispose();
                PrintProcessor = null;
            }
            Logger.Log(LogLevel.Info, "Service stopped");
            this.Stopped.Set();
        }
 public AuthServiceRegistration(CloudPrintProxy proxy)
 {
     this.PrintProxy = proxy;
     this.PrinterRegistrationTimes = new Dictionary<string, DateTime>();
     this.AuthRegistrationTimer = new Timer(RegisterAuthService);
 }
        public static IEnumerable<CloudPrintJob> GetIncompletePrintJobs(CloudPrintProxy proxy)
        {
            return new List<CloudPrintJob>();

            /*
            string jobrootdirname = Path.Combine(Config.DataDirName, "PrintJobs");
            foreach (string jobpdfpath in Directory.EnumerateFiles(jobrootdirname, "*.pdf", SearchOption.AllDirectories))
            {
                string jobid = Path.GetFileNameWithoutExtension(jobpdfpath);

                if (_PrintJobs.ContainsKey(jobid))
                {
                    yield return _PrintJobs[jobid];
                }
                else
                {
                    string jobpath = Path.GetDirectoryName(jobpdfpath);
                    string basename = Path.Combine(jobpath, jobid);
                    string jobjsonpath = basename + ".job.json";
                    string jobticketpath = basename + ".ticket.xml";

                    if (File.Exists(jobjsonpath) && File.Exists(jobticketpath))
                    {
                        CloudPrintJob job = null;

                        try
                        {
                            job = new CloudPrintJobImpl(proxy, basename);
                        }
                        catch
                        {
                        }

                        if (job != null)
                        {
                            yield return job;
                        }
                    }
                }
            }
             */
        }
 public CloudPrintInfoServer(int port, CloudPrintProxy printproxy)
     : this(String.Format("http://{0}:{1}", Environment.MachineName, port), printproxy)
 {
 }