public static HttpWebRequest CreateRequest(OAuthTicket ticket, string URL) { var req = (HttpWebRequest)HttpWebRequest.Create(URL); if (Config.WebProxyHost != null) { req.Proxy = new WebProxy(Config.WebProxyHost, Config.WebProxyPort); } else { req.Proxy = null; } req.UserAgent = Config.CloudPrintUserAgent; req.Headers.Add("X-CloudPrint-Proxy", Config.CloudPrintProxyName); if (ticket != null) { req.Headers.Add("Authorization", ticket.TokenType + " " + ticket.AccessToken); } return(req); }
public static HttpWebRequest CreateRequest(OAuthTicket ticket, string URL) { var req = (HttpWebRequest)HttpWebRequest.Create(URL); if (Config.WebProxyHost != null) { req.Proxy = new WebProxy(Config.WebProxyHost, Config.WebProxyPort); } else { req.Proxy = null; } req.UserAgent = Config.CloudPrintUserAgent; req.Headers.Add("X-CloudPrint-Proxy", Config.CloudPrintProxyName); if (ticket != null) { req.Headers.Add("Authorization", ticket.TokenType + " " + ticket.AccessToken); } return req; }
public static dynamic PostCloudPrintUrlEncodedRequest(OAuthTicket ticket, string iface, dynamic postdata) { return(HTTPHelper.ToJson(HTTPHelper.SendUrlEncodedPostData(CreateCloudPrintRequest(ticket, iface), postdata))); }
public static HttpWebRequest CreateCloudPrintRequest(OAuthTicket ticket, string iface) { return(CreateRequest(ticket, Config.CloudPrintBaseURL + "/" + iface)); }
public void Start(bool useXMPP) { lock (UpdateLock) { ThrowIfDisposed(); if (Config.OAuthRefreshToken != null && Config.OAuthCodeAccepted) { if (OAuthTicket == null) { OAuthTicket = new OAuthTicket(Config.OAuthRefreshToken, Config.OAuthClientID, Config.OAuthClientSecret, Config.OAuthRedirectURI); } if (PrintQueueUpdateTimer == null) { PrintQueueUpdateTimer = new Timer((obj) => { lock (UpdateLock) { PollUpdatePrintQueues(); } }, null, TimeSpan.Zero, PrintQueueUpdateInterval); } if (XMPP == null && PrintJobUpdateTimer == null) { PrintJobUpdateTimer = new Timer((obj) => PollUpdateCloudPrintJobs(), null, TimeSpan.FromSeconds(30), TimeSpan.FromSeconds(30)); if (useXMPP) { RunXMPP(); } } Logger.Log(LogLevel.Info, "Cloud Print Proxy started"); } else { throw new InvalidOperationException("Need to register and accept proxy before it can be started"); } } }
public static HttpWebRequest CreateCloudPrintRequest(OAuthTicket ticket, string iface) { return CreateRequest(ticket, Config.CloudPrintBaseURL + "/" + iface); }
public static dynamic PostCloudPrintUrlEncodedRequest(OAuthTicket ticket, string iface, dynamic postdata) { return HTTPHelper.ToJson(HTTPHelper.SendUrlEncodedPostData(CreateCloudPrintRequest(ticket, iface), postdata)); }