コード例 #1
0
        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);
        }
コード例 #2
0
        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;
        }
コード例 #3
0
 public static dynamic PostCloudPrintUrlEncodedRequest(OAuthTicket ticket, string iface, dynamic postdata)
 {
     return(HTTPHelper.ToJson(HTTPHelper.SendUrlEncodedPostData(CreateCloudPrintRequest(ticket, iface), postdata)));
 }
コード例 #4
0
 public static HttpWebRequest CreateCloudPrintRequest(OAuthTicket ticket, string iface)
 {
     return(CreateRequest(ticket, Config.CloudPrintBaseURL + "/" + iface));
 }
コード例 #5
0
        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");
                }
            }
        }
コード例 #6
0
 public static HttpWebRequest CreateCloudPrintRequest(OAuthTicket ticket, string iface)
 {
     return CreateRequest(ticket, Config.CloudPrintBaseURL + "/" + iface);
 }
コード例 #7
0
 public static dynamic PostCloudPrintUrlEncodedRequest(OAuthTicket ticket, string iface, dynamic postdata)
 {
     return HTTPHelper.ToJson(HTTPHelper.SendUrlEncodedPostData(CreateCloudPrintRequest(ticket, iface), postdata));
 }