qRFCview Proxy Patch

目录 开源

This patch enables qRFCview to load proxy settings from environment variables such as "http_proxy" and "socks_proxy". Yes, popping up a dialog to set these things is fancier, but that means more coding work. I am pretty satisfied with this solution.

You can download the modified source code tarball from http://share.solrex.org/ibuild/qrfcview-0.62-solrex2.tar.gz . Binary packets for special Linux distributions can be found at http://share.solrex.org/ibuild/ too.

diff -aurN qrfcview-0.62/src/mainwindow.cpp qrfcview-0.62-solrex/src/mainwindow.cpp
--- qrfcview-0.62/src/mainwindow.cpp    2006-01-13 17:56:45.000000000 +0800
+++ qrfcview-0.62-solrex/src/mainwindow.cpp    2009-07-14 16:03:56.000000000 +0800
@@ -122,8 +122,10 @@
{
   // Load a RFC number
   bool bOK;
+  /* NOTE 20090714/Solrex  <http://solrex.org>:
+     Enlarge RFC number limit to 10000. */
   int iRFCNum = QInputDialog::getInteger(this, tr("Please enter a RFC number"),
-                                             tr("RFC#:"), 0, 1, 5000, 1, &bOK);
+                                             tr("RFC#:"), 0, 1, 10000, 1, &bOK);
   if (bOK)
     RFCLoad( iRFCNum );
}
diff -aurN qrfcview-0.62/src/rfcloader.cpp qrfcview-0.62-solrex/src/rfcloader.cpp
--- qrfcview-0.62/src/rfcloader.cpp    2006-01-13 17:56:45.000000000 +0800
+++ qrfcview-0.62-solrex/src/rfcloader.cpp    2009-07-14 15:58:50.000000000 +0800
@@ -25,11 +25,41 @@
#include <QMessageBox>
#include <QtDebug>
#include <QDir>
+#include <QNetworkProxy>

QRFCLoader::QRFCLoader(QObject *parent)
  : QObject(parent)
{
   m_qHttp=new QHttp(this);
+  /* NOTE 20090714/Solrex <http://solrex.org>:
+     Detect proxy settings via system environment variable
+     ``http_proxy'' and ``socks_proxy''. */
+  char *p;
+  QNetworkProxy qNetworkProxy(QNetworkProxy::NoProxy);
+  if ((p = getenv("socks_proxy")) != NULL) {
+    qNetworkProxy.setType(QNetworkProxy::Socks5Proxy);
+  } else if ((p = getenv("http_proxy")) != NULL) {
+    qNetworkProxy.setType(QNetworkProxy::HttpProxy);
+  }
+  if (p != NULL) {
+    QString proxyStr = p;
+    proxyStr = proxyStr.trimmed();
+    proxyStr.remove("http://");
+    QStringList list = proxyStr.split("@");
+    QStringList list1 = list[0].split(":");
+    if (list.count() > 2) {
+      qNetworkProxy.setType(QNetworkProxy::NoProxy);
+      qDebug() << "Unresolvable proxy setting:" << list;
+    } else if ( list.count() == 2) {
+      qNetworkProxy.setUser(list1[0]);
+      qNetworkProxy.setPassword(list1[1]);
+      list1 = list[1].split(":");
+    }
+    qNetworkProxy.setHostName(list1[0]);
+    qNetworkProxy.setPort(list1[1].toInt());
+  }
+  m_qHttp->setProxy(qNetworkProxy);
+  qDebug() << "Loaded proxy:" << p;
   connect(m_qHttp, SIGNAL( requestStarted(int) ), this, SLOT( startDownload(int) ) );
   connect(m_qHttp, SIGNAL( requestFinished(int, bool) ), this, SLOT( fileDownload(int, bool) ) );
   connect(m_qHttp, SIGNAL( responseHeaderReceived(QHttpResponseHeader) ), this, SLOT( receivedHeader(QHttpResponseHeader) ) );

RFC number limit issue was discussed at deb-packages-of-qrfcview-and-jabref.html .

长按识别二维码关注《边际效应》
长按识别二维码关注《边际效应》

8 条评论

  • 木乃y
    2009-07-17

    picasa被封 默哀...
    把人往死里逼

  • 木乃y
    2009-07-17

    js嵌入可以显示图片,直接进主页 js css 全部丢失,单张访问--撞墙

  • Solrex Yang
    2009-07-17

    @木乃y
    把 picasaweb.google.com 和 ggpht.com 添加到使用代理的列表中,用 GAppProxy 还是可以上的。参考我上一篇文章: 浏览器自动选择 Proxy 配置案例

  • 木乃y
    2009-07-17

    @Solrex Yang
    看看你右边的相册..如今变成了红叉 ,做网民难啊

  • Solrex Yang
    2009-07-17

    @木乃y
    我看就不是红叉,因为我用代理。你看是红叉,那也是没办法的事情 :)

  • 园子
    2009-07-22

    全英文的?

    好厉害,你的代码高亮是用什么插件呢?

  • Solrex
    2009-07-22

    @园子
    没有用插件,人肉做的,稍微把代码发芽网得到的 HTML 处理一下。

  • 私人后花园 / 在 Mac 上编译安装 qRFCView
    2010-10-31

    [...] qRFCview Proxy Patch 杨文博同学给它写了代理补丁 。 Post a comment — Trackback URI RSS 2.0 feed for these comments This entry (permalink) was posted on Sunday, October 31, 2010, at 04:01 by Lee Li. Filed in GNU & Programming and tagged compile qt, rfc reader, rfc viewer. [...]

发表评论

电子邮件地址不会被公开。 必填项已用*标注