Skip to content
Browse files

ui

  • Loading branch information...
1 parent ab1a6fc commit f51b72991cf47f68579198bc0e8922034b774996 @iptton iptton committed May 16, 2012
Showing with 129 additions and 94 deletions.
  1. +2 −1 Rythem.pro
  2. +1 −5 httpfiles.qrc
  3. +1 −1 main.cpp
  4. +74 −65 mainwindow.cpp
  5. +1 −1 mainwindow.h
  6. +33 −16 mainwindow.ui
  7. +6 −2 proxy/ryconnection.cpp
  8. BIN remove.png
  9. +11 −3 ryconnectiontableview.cpp
View
3 Rythem.pro
@@ -136,7 +136,8 @@ OTHER_FILES += \
static/img3.png \
static/img2.png \
static/img1.png \
- logo.rc
+ logo.rc \
+ remove.png
CONFIG(release){
#DEFINES += DEBUGTOFILE
#message("debug")
View
6 httpfiles.qrc
@@ -19,11 +19,6 @@
<file>RythemTimes/lib/jo2.dom.js</file>
<file>RythemTimes/lib/jo2.js</file>
</qresource>
- <qresource prefix="/static">
- <file>static/icloud_64.png</file>
- <file>logo.png</file>
- <file>family.png</file>
- </qresource>
<qresource prefix="/">
<file>static/img1.png</file>
<file>static/img2.png</file>
@@ -41,5 +36,6 @@
<file>static/img14.png</file>
<file>static/img15.png</file>
<file>static/img16.png</file>
+ <file>remove.png</file>
</qresource>
</RCC>
View
2 main.cpp
@@ -64,7 +64,7 @@ int main(int argc, char *argv[])
// register metatypes
qRegisterMetaType<RyPipeData_ptr>("RyPipeData_ptr");
- //QTextCodec::setCodecForTr(QTextCodec::codecForName("utf8"));
+ QTextCodec::setCodecForTr(QTextCodec::codecForName("utf8"));
//QTextCodec::setCodecForCStrings(QTextCodec::codecForName("utf8"));
//QTextCodec::setCodecForLocale(QTextCodec::codecForName("utf8"));
View
139 mainwindow.cpp
@@ -208,7 +208,8 @@ MainWindow::MainWindow(QWidget *parent) :
_itemSelectModel = ui->tableView->selectionModel();
connect(ui->tableView,SIGNAL(doubleClicked(QModelIndex)),SLOT(onItemDoubleClicked(QModelIndex)));
- connect(_itemSelectModel,SIGNAL(currentChanged(QModelIndex,QModelIndex)),SLOT(onSelectionChange(QModelIndex)));
+ //connect(_itemSelectModel,SIGNAL(currentChanged(QModelIndex,QModelIndex)),SLOT(onSelectionChange(QModelIndex)));
+ connect(_itemSelectModel,SIGNAL(selectionChanged(QItemSelection,QItemSelection)),SLOT(onSelectionChange(QItemSelection,QItemSelection)));
//ui->tableView->setItemDelegate();
createMenus();
@@ -311,14 +312,19 @@ void MainWindow::onNewPipe(RyPipeData_ptr pipeData){
sortFilterProxyModel->addItem(pipeData);
}
-void MainWindow::onSelectionChange(QModelIndex index){
- if(ui->tollTabs->currentWidget() == ui->inspectorTab){
- onItemDoubleClicked(index);
+void MainWindow::onSelectionChange(QItemSelection selected,QItemSelection){
+ if(selected.indexes().isEmpty()){
+ ui->actionWaterfall->setEnabled(false);
+ }else{
+ if(ui->tollTabs->currentWidget() == ui->inspectorTab){
+ QModelIndex index = selected.indexes().first();
+ onItemDoubleClicked(index);
+ }
+ ui->actionWaterfall->setEnabled(true);
}
}
void MainWindow::onItemDoubleClicked(QModelIndex topLeft){
- //qDebug()<<"onSelectionChange";
RyPipeData_ptr data = sortFilterProxyModel->getItem(topLeft);
if(data.isNull()){
qDebug()<<QString("isNull %1").arg(topLeft.row());
@@ -423,8 +429,62 @@ void MainWindow::onWaterfallActionTriggered(){
void MainWindow::toggleProxy(){
+#ifdef Q_WS_MAC
+ /*
+ CFDictionaryRef dict = SCDynamicStoreCopyProxies(NULL);
+ if(!dict){
+ qDebug()<<"no proxy";
+ }
+ */
+
+
+ QNetworkConfigurationManager mgr;
+ QList<QNetworkConfiguration> activeConfigs = mgr.allConfigurations(QNetworkConfiguration::Active);
+ QList<QString> activeNames;
+ foreach(QNetworkConfiguration cf,activeConfigs){
+ //qDebug()<<"new work activated:"<<cf.type()<<cf.state()<<cf.name()<<cf.bearerTypeName()<<cf.identifier();
+
+ activeNames.append(cf.name());
+ }
+ ///Library/Preferences/SystemConfiguration
+ QSettings::setPath(QSettings::NativeFormat,QSettings::SystemScope,"/Library/Preferences/SystemConfiguration/");
+ QSettings plist("/Library/Preferences/SystemConfiguration/preferences.plist",QSettings::NativeFormat);
+
+ QMap<QString,QVariant> services = plist.value("NetworkServices").toMap();
+ QMap<QString,QVariant>::Iterator i;
+ QString theServiceKey;
+ QMap<QString,QVariant> theService;
+ QMap<QString,QVariant> interface;
+
+ for(i = services.begin();i!=services.end();i++){
+ //qDebug()<<i.key();
+ theService = i.value().toMap();
+ theServiceKey = i.key();
+ interface = theService["Interface"].toMap();
+ //qDebug()<<"interface"<<interface;
+ if(activeNames.contains(interface.value("DeviceName").toString())){
+ qDebug()<<"got it.."<<theService["Proxies"].toMap().value("HTTPEnable");
+ break;
+ }
+ }
+ if(i!=services.end()){
+ QMap<QString,QVariant> proxies = theService["Proxies"].toMap();
+ qDebug()<<"proxies="<<proxies;
+ qDebug()<<proxies.value("HTTPEnable");
+ proxies["HTTPEnable"]=0;
+ theService["Proxies"] = proxies;
+ services[theServiceKey]=theService;
+ qDebug()<<theService;
+ }
+ qDebug()<<services[theServiceKey];
+ plist.setValue("NetworkServices",services);
+ plist.sync();//doesn't work.. plist readonly
+#endif
+
+#ifdef Q_WS_WIN32
+ RyWinHttp::init();
if(_isUsingCapture){
- _isUsingCapture = false;
+ ui->ActionCapture->setText(tr("开始抓包"));
proxySetting.setValue("ProxyEnable",_previousProxyInfo.enable);
if(_previousProxyInfo.enable != 0){
proxySetting.setValue("ProxyServer",_previousProxyInfo.proxyString);
@@ -442,7 +502,7 @@ void MainWindow::toggleProxy(){
//}
*/
}else{
- _isUsingCapture = true;
+ ui->ActionCapture->setText(tr("停止抓包"));
_previousProxyInfo.isUsingPac = proxySetting.value("AutoConfigURL","0").toString();
_previousProxyInfo.enable = proxySetting.value("ProxyEnable").toInt();
_previousProxyInfo.proxyString =proxySetting.value("ProxyServer").toString();
@@ -481,71 +541,19 @@ void MainWindow::toggleProxy(){
proxySetting.setValue("ProxyServer",proxyServer);
}
proxySetting.sync();
-#ifdef Q_WS_WIN32
::InternetSetOption(0,39, INT_PTR(0),INT_PTR(0));
::InternetSetOption(0, 37,INT_PTR(0), INT_PTR(0));
#endif
+ _isUsingCapture = !_isUsingCapture;
+ if(_isUsingCapture){
+ ui->ActionCapture->setText(tr("停止抓包"));
+ }else{
+ ui->ActionCapture->setText(tr("开始抓包"));
+ }
}
void MainWindow::toggleCapture(){
- //captureAct->setChecked(!isUsingCapture);
-#ifdef Q_WS_WIN32
- RyWinHttp::init();
toggleProxy();
- //QtConcurrent::run(this,&MainWindow::toggleProxy);
- //qDebug()<<previousProxyInfo.isUsingPac;
-#endif
-#ifdef Q_WS_MAC
- /*
- CFDictionaryRef dict = SCDynamicStoreCopyProxies(NULL);
- if(!dict){
- qDebug()<<"no proxy";
- }
- */
-
-
- QNetworkConfigurationManager mgr;
- QList<QNetworkConfiguration> activeConfigs = mgr.allConfigurations(QNetworkConfiguration::Active);
- QList<QString> activeNames;
- foreach(QNetworkConfiguration cf,activeConfigs){
- //qDebug()<<"new work activated:"<<cf.type()<<cf.state()<<cf.name()<<cf.bearerTypeName()<<cf.identifier();
-
- activeNames.append(cf.name());
- }
- ///Library/Preferences/SystemConfiguration
- QSettings::setPath(QSettings::NativeFormat,QSettings::SystemScope,"/Library/Preferences/SystemConfiguration/");
- QSettings plist("/Library/Preferences/SystemConfiguration/preferences.plist",QSettings::NativeFormat);
-
- QMap<QString,QVariant> services = plist.value("NetworkServices").toMap();
- QMap<QString,QVariant>::Iterator i;
- QString theServiceKey;
- QMap<QString,QVariant> theService;
- QMap<QString,QVariant> interface;
-
- for(i = services.begin();i!=services.end();i++){
- //qDebug()<<i.key();
- theService = i.value().toMap();
- theServiceKey = i.key();
- interface = theService["Interface"].toMap();
- //qDebug()<<"interface"<<interface;
- if(activeNames.contains(interface.value("DeviceName").toString())){
- qDebug()<<"got it.."<<theService["Proxies"].toMap().value("HTTPEnable");
- break;
- }
- }
- if(i!=services.end()){
- QMap<QString,QVariant> proxies = theService["Proxies"].toMap();
- qDebug()<<"proxies="<<proxies;
- qDebug()<<proxies.value("HTTPEnable");
- proxies["HTTPEnable"]=0;
- theService["Proxies"] = proxies;
- services[theServiceKey]=theService;
- qDebug()<<theService;
- }
- qDebug()<<services[theServiceKey];
- plist.setValue("NetworkServices",services);
- plist.sync();//doesn't work.. plist readonly
-#endif
}
@@ -603,4 +611,5 @@ void MainWindow::on_actionLongCache_triggered(){
void MainWindow::onActionRemoveAll(){
pipeTableModel->removeAllItem();
sortFilterProxyModel->removeAllItem();
+ ui->actionWaterfall->setEnabled(false);
}
View
2 mainwindow.h
@@ -56,7 +56,7 @@ public slots:
void toggleProxy();
void onItemDoubleClicked(QModelIndex);
- void onSelectionChange(QModelIndex);
+ void onSelectionChange(QItemSelection selected,QItemSelection deselected);
void onWaterfallActionTriggered();
View
49 mainwindow.ui
@@ -13,6 +13,11 @@
<property name="windowTitle">
<string>Rythem</string>
</property>
+ <property name="styleSheet">
+ <string notr="true">MainWindow{
+background:#dddfe2;
+}</string>
+ </property>
<widget class="QWidget" name="centralWidget">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
@@ -33,7 +38,7 @@
</property>
<widget class="QWidget" name="inspectorTab">
<attribute name="title">
- <string>Inspector</string>
+ <string>查看器</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
@@ -90,8 +95,8 @@
<rect>
<x>0</x>
<y>0</y>
- <width>98</width>
- <height>40</height>
+ <width>523</width>
+ <height>164</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
@@ -120,7 +125,7 @@
</widget>
<widget class="QWidget" name="tab_2">
<attribute name="title">
- <string>rules</string>
+ <string>替换规则</string>
</attribute>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
@@ -160,32 +165,38 @@
</property>
</widget>
<widget class="QToolBar" name="mainToolBar">
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="toolButtonStyle">
+ <enum>Qt::ToolButtonTextBesideIcon</enum>
+ </property>
<attribute name="toolBarArea">
<enum>TopToolBarArea</enum>
</attribute>
<attribute name="toolBarBreak">
<bool>false</bool>
</attribute>
<addaction name="ActionCapture"/>
- <addaction name="separator"/>
+ <addaction name="actionWaterfall"/>
<addaction name="actionRemoveAll"/>
- <addaction name="separator"/>
<addaction name="actionLongCache"/>
- <addaction name="separator"/>
- <addaction name="actionWaterfall"/>
</widget>
<widget class="QStatusBar" name="statusBar"/>
<action name="actionRemoveAll">
<property name="icon">
<iconset resource="httpfiles.qrc">
- <normaloff>:/static/img9.png</normaloff>
- <normalon>:/static/img9.png</normalon>:/static/img9.png</iconset>
+ <normaloff>:/remove.png</normaloff>
+ <normalon>:/remove.png</normalon>:/remove.png</iconset>
</property>
<property name="text">
- <string>removeAll</string>
+ <string>清除</string>
</property>
<property name="toolTip">
- <string>remove capture history</string>
+ <string>清除所有</string>
+ </property>
+ <property name="iconVisibleInMenu">
+ <bool>true</bool>
</property>
</action>
<action name="ActionCapture">
@@ -198,13 +209,16 @@
<normalon>:/static/img16.png</normalon>:/static/img13.png</iconset>
</property>
<property name="text">
- <string>capture</string>
+ <string>开始抓包</string>
</property>
<property name="toolTip">
- <string>begin</string>
+ <string>开始捕获</string>
</property>
</action>
<action name="actionWaterfall">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
<property name="icon">
<iconset resource="httpfiles.qrc">
<normaloff>:/static/img11.png</normaloff>:/static/img11.png</iconset>
@@ -225,10 +239,13 @@
<normaloff>:/static/img10.png</normaloff>:/static/img10.png</iconset>
</property>
<property name="text">
- <string>longCache</string>
+ <string>长缓存</string>
</property>
<property name="toolTip">
- <string>long cache</string>
+ <string>被替换内容设置长时间缓存</string>
+ </property>
+ <property name="visible">
+ <bool>true</bool>
</property>
</action>
</widget>
View
8 proxy/ryconnection.cpp
@@ -241,7 +241,10 @@ void RyConnection::onResponseError(QAbstractSocket::SocketError){
if(_sendingPipeData){
if(_sendingPipeData->responseHeaderRawData().isEmpty()){
- QByteArray s = "[Rythem:remote server unreachable]";
+ QByteArray s = QByteArray().append(QString("[Rythem:remote server unreachable]\n host:%1\n port:%2\n fullUrl:%3")
+ .arg(_sendingPipeData->host)
+ .arg(_sendingPipeData->port)
+ .arg(_sendingPipeData->fullUrl));
int count = s.length();
QByteArray byteToWrite;
byteToWrite.append(QString("HTTP/1.0 %1 \r\n"
@@ -253,7 +256,8 @@ void RyConnection::onResponseError(QAbstractSocket::SocketError){
.arg(count)
);
byteToWrite.append(s);
- QByteArray ba = QByteArray("nRythem:remote server close");
+ _requestSocket->write(byteToWrite);
+ _requestSocket->flush();
_sendingPipeData->parseResponse(&byteToWrite);
onResponsePackageFound();
}else if(_sendingPipeData->isContentLenthUnLimit()){
View
BIN remove.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
14 ryconnectiontableview.cpp
@@ -5,7 +5,6 @@
#include "rytablesortfilterproxymodel.h"
#include "rymimedata.h"
-#include "savesessionsdialog.h"
extern QString appPath;
extern QByteArray gzipDecompress(QByteArray data);
@@ -35,20 +34,29 @@ void RyConnectionTableView::contextMenuEvent(QContextMenuEvent *event){
void RyConnectionTableView::createMenu(){
_contextMenu = new QMenu(this);
- _saveSelectedSessionAct = _contextMenu->addAction(tr("save selected session..."));
- _saveSessionRespnoseBodyAct = _contextMenu->addAction(tr("&save response body..."));
+ _saveSelectedSessionAct = _contextMenu->addAction(tr("save selected sessions..."));
+ _saveSessionRespnoseBodyAct = _contextMenu->addAction(tr("&save selected response body..."));
+ // TODO: finish these actions
_autoScrollAct = _contextMenu->addAction(tr("auto scroll session list"));
_autoScrollAct->setCheckable(true);
+ _autoScrollAct->setEnabled(false);
_saveMenu = _contextMenu->addMenu(tr("&save"));
+ _saveMenu->setEnabled(false);
_saveAllSessionAct = _saveMenu->addAction(tr("&save all sessions"));
+ _saveAllSessionAct->setEnabled(false);
_saveSessionsRevertAct = _saveMenu->addAction(tr("save sessions unselected"));
+ _saveSessionsRevertAct->setEnabled(false);
_removeMenu = _contextMenu->addMenu(tr("&remove"));
+ _removeMenu->setEnabled(false);
_removeSelectedSessionAct = _removeMenu->addAction(tr("remove selected session"));
+ _removeSelectedSessionAct->setEnabled(false);
_removeAllSessionAct = _removeMenu->addAction(tr("remove all sessions"));
+ _removeAllSessionAct->setEnabled(false);
_removeSessionsRevertAct = _removeMenu->addAction(tr("remove sessions unselected"));
+ _removeSessionsRevertAct->setEnabled(false);

0 comments on commit f51b729

Please sign in to comment.
Something went wrong with that request. Please try again.