Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/iptton/Rythem
Browse files Browse the repository at this point in the history
Conflicts:
	Rythem.pro
  • Loading branch information
iptton committed Apr 13, 2012
2 parents b6d4c9f + 88a1557 commit 87421e4
Show file tree
Hide file tree
Showing 44 changed files with 7,114 additions and 59 deletions.
32 changes: 28 additions & 4 deletions Rythem.pro
Expand Up @@ -26,7 +26,17 @@ SOURCES += main.cpp\
proxy/rywinhttp.cpp \ proxy/rywinhttp.cpp \
proxy/ryproxyserver.cpp \ proxy/ryproxyserver.cpp \
proxy/rypipedata.cpp \ proxy/rypipedata.cpp \
proxy/ryconnection.cpp proxy/ryconnection.cpp \
ryconnectiontableview.cpp \
quazip/zip.c \
quazip/unzip.c \
quazip/quazipnewinfo.cpp \
quazip/quazipfile.cpp \
quazip/quazip.cpp \
quazip/quacrc32.cpp \
quazip/quaadler32.cpp \
quazip/qioapi.cpp \
quazip/JlCompress.cpp


mac:SOURCES -= qiwinhttp.cpp mac:SOURCES -= qiwinhttp.cpp


Expand All @@ -44,7 +54,22 @@ HEADERS += mainwindow.h \
proxy/rywinhttp.h \ proxy/rywinhttp.h \
proxy/ryproxyserver.h \ proxy/ryproxyserver.h \
proxy/rypipedata.h \ proxy/rypipedata.h \
proxy/ryconnection.h proxy/ryconnection.h \
ryconnectiontableview.h \
quazip/zip.h \
quazip/unzip.h \
quazip/quazipnewinfo.h \
quazip/quazipfileinfo.h \
quazip/quazipfile.h \
quazip/quazip.h \
quazip/quazip_global.h \
quazip/quacrc32.h \
quazip/quachecksum32.h \
quazip/quaadler32.h \
quazip/JlCompress.h \
quazip/ioapi.h \
quazip/crypt.h \
rymimedata.h
win32:HEADERS += zlib/zutil.h \ win32:HEADERS += zlib/zutil.h \
zlib/zlib.h \ zlib/zlib.h \
zlib/zconf.h \ zlib/zconf.h \
Expand Down Expand Up @@ -92,8 +117,7 @@ OTHER_FILES += \
static/icloud_64.png \ static/icloud_64.png \
RythemTimes/lib/parseuri.js \ RythemTimes/lib/parseuri.js \
RythemTimes/lib/jo2.js \ RythemTimes/lib/jo2.js \
RythemTimes/lib/jo2.dom.js \ RythemTimes/lib/jo2.dom.js
logo.rc
CONFIG(release){ CONFIG(release){
#DEFINES += DEBUGTOFILE #DEFINES += DEBUGTOFILE
#message("debug") #message("debug")
Expand Down
16 changes: 13 additions & 3 deletions composer.cpp
@@ -1,6 +1,9 @@
#include "composer.h" #include "composer.h"
#include "ui_composer.h" #include "ui_composer.h"
#include <QNetworkProxy> #include <QNetworkProxy>

#include "rymimedata.h"

Composer::Composer(QWidget *parent) : Composer::Composer(QWidget *parent) :
QWidget(parent), QWidget(parent),
ui(new Ui::Composer){ ui(new Ui::Composer){
Expand Down Expand Up @@ -177,6 +180,7 @@ void Composer::setupProxy(QString host,qint16 port){
} }


void Composer::dragEnterEvent(QDragEnterEvent *event){ void Composer::dragEnterEvent(QDragEnterEvent *event){

qDebug()<<"drag enter"; qDebug()<<"drag enter";
if (event->mimeData()->hasText()) { if (event->mimeData()->hasText()) {
if (event->source() == this) { if (event->source() == this) {
Expand All @@ -188,12 +192,18 @@ void Composer::dragEnterEvent(QDragEnterEvent *event){
} else { } else {
event->ignore(); event->ignore();
} }

} }


void Composer::dropEvent(QDropEvent *event){ void Composer::dropEvent(QDropEvent *event){
qDebug()<<event->source(); qDebug()<<"drop";
if (event->mimeData()->hasText()) { const RyMimeData* mime = dynamic_cast<const RyMimeData*>(event->mimeData());
const QMimeData *mime = event->mimeData();
if (mime) {
RyPipeData_ptr d = mime->pipeData();
this->ui->server->setText(d->host);
this->ui->port->setText(QString::number(d->port));
this->ui->request->setPlainText(QString(d->requestHeaderRawData()).append("\r\n\r\n").append(d->requestBodyRawData()));
qDebug()<<"drop text="<<mime->text(); qDebug()<<"drop text="<<mime->text();
event->acceptProposedAction(); event->acceptProposedAction();
} else { } else {
Expand Down
14 changes: 13 additions & 1 deletion composer.ui
Expand Up @@ -6,7 +6,7 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>624</width> <width>727</width>
<height>385</height> <height>385</height>
</rect> </rect>
</property> </property>
Expand All @@ -22,6 +22,9 @@
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<property name="acceptDrops">
<bool>false</bool>
</property>
<property name="text"> <property name="text">
<string>w.l.qq.com</string> <string>w.l.qq.com</string>
</property> </property>
Expand Down Expand Up @@ -50,6 +53,9 @@
<height>16777215</height> <height>16777215</height>
</size> </size>
</property> </property>
<property name="acceptDrops">
<bool>false</bool>
</property>
<property name="text"> <property name="text">
<string>80</string> <string>80</string>
</property> </property>
Expand Down Expand Up @@ -101,6 +107,9 @@
</item> </item>
<item row="1" column="0" colspan="6"> <item row="1" column="0" colspan="6">
<widget class="QPlainTextEdit" name="request"> <widget class="QPlainTextEdit" name="request">
<property name="acceptDrops">
<bool>false</bool>
</property>
<property name="toolTip"> <property name="toolTip">
<string>request</string> <string>request</string>
</property> </property>
Expand All @@ -126,6 +135,9 @@ Range: bytes=48-6116217
</item> </item>
<item row="2" column="0" colspan="6"> <item row="2" column="0" colspan="6">
<widget class="QPlainTextEdit" name="response"> <widget class="QPlainTextEdit" name="response">
<property name="acceptDrops">
<bool>false</bool>
</property>
<property name="toolTip"> <property name="toolTip">
<string>response</string> <string>response</string>
</property> </property>
Expand Down
3 changes: 3 additions & 0 deletions httpfiles.qrc
Expand Up @@ -23,5 +23,8 @@
<file>static/icloud_64.png</file> <file>static/icloud_64.png</file>
<file>logo.png</file> <file>logo.png</file>
<file>family.png</file> <file>family.png</file>
<file>915.png</file>
<file>201111291315331602.png</file>
<file>201111291315335930.png</file>
</qresource> </qresource>
</RCC> </RCC>
1 change: 1 addition & 0 deletions logo.rc
@@ -0,0 +1 @@
IDI_ICON1 ICON DISCARDABLE "lol.ico"
Binary file added lol.ico
Binary file not shown.
6 changes: 3 additions & 3 deletions main.cpp
Expand Up @@ -51,7 +51,7 @@ int main(int argc, char *argv[])
{ {
QApplication a(argc, argv); QApplication a(argc, argv);
a.setQuitOnLastWindowClosed(false); a.setQuitOnLastWindowClosed(false);
a.setWindowIcon(QIcon(":/static/logo.png")); //a.setWindowIcon(QIcon(":/static/rythem.icns"));
appPath = qApp->applicationDirPath(); appPath = qApp->applicationDirPath();




Expand Down Expand Up @@ -79,8 +79,8 @@ int main(int argc, char *argv[])
server->connect(server,SIGNAL(pipeError(RyPipeData_ptr)),&w,SLOT(onPipeUpdate(RyPipeData_ptr))); server->connect(server,SIGNAL(pipeError(RyPipeData_ptr)),&w,SLOT(onPipeUpdate(RyPipeData_ptr)));
server->listen(QHostAddress("127.0.0.1"),8889); server->listen(QHostAddress("127.0.0.1"),8889);


w.showMaximized(); //w.showMaximized();

w.show();
return a.exec(); return a.exec();


} }
89 changes: 60 additions & 29 deletions mainwindow.cpp
Expand Up @@ -37,6 +37,8 @@
#include <QMovie> #include <QMovie>
#include <QPixmap> #include <QPixmap>


#include <quazip/quazip.h>
#include <quazip/quazipfile.h>




QByteArray gzipDecompress(QByteArray data){ QByteArray gzipDecompress(QByteArray data){
Expand Down Expand Up @@ -219,15 +221,65 @@ MainWindow::~MainWindow()
} }
void MainWindow::createMenus(){ void MainWindow::createMenus(){
fileMenu = menuBar()->addMenu(tr("&File")); fileMenu = menuBar()->addMenu(tr("&File"));
captureAct = new QAction(tr("&Capture"),this); QAction *importSessions = fileMenu->addAction(tr("&import session..."));
captureAct->setCheckable(true); connect(importSessions,SIGNAL(triggered()),SLOT(importSessions()));
fileMenu->addAction(captureAct);
QAction *a = fileMenu->addAction(tr("&rules"));
connect(a,SIGNAL(triggered()),SLOT(showSettingsDialog()));
connect(captureAct,SIGNAL(triggered()),SLOT(toggleCapture()));
} }


void MainWindow::showSettingsDialog(){ void MainWindow::importSessions(){
QFileDialog dialog;
QString fileName = dialog.getOpenFileName(this,tr("select file to open"),"","Archiev Files(*.saz *.zip)");
QuaZip zip(fileName);
if(!zip.open(QuaZip::mdUnzip)){
qDebug()<<"cannot open "<<fileName;
return;
}
QuaZipFileInfo info;
QuaZipFile file(&zip);

RyPipeData_ptr pipeData;

QString name;
for (bool more = zip.goToFirstFile(); more; more = zip.goToNextFile()) {

if (!zip.getCurrentFileInfo(&info)) {
qWarning("testRead(): getCurrentFileInfo(): %d\n", zip.getZipError());
return;
}

if (!file.open(QIODevice::ReadOnly)) {
qWarning("testRead(): file.open(): %d", file.getZipError());
return;
}

name = file.getActualFileName();
QByteArray ba = file.readAll();
if(name.endsWith("_c.txt")){
//pipeData.clear();
pipeData = RyPipeData_ptr(new RyPipeData(0,0));
pipeData->isImported = true;
pipeData->parseRequest(&ba);
onNewPipe(pipeData);
}else if(name.endsWith("_s.txt")){
pipeData->parseResponse(&ba);
onPipeUpdate(pipeData);
pipeData.clear();
}

if (file.getZipError() != UNZ_OK) {
qWarning("testRead(): file.getFileName(): %d", file.getZipError());
return ;
}

file.close();

if (file.getZipError() != UNZ_OK) {
qWarning("testRead(): file.close(): %d", file.getZipError());
return ;
}

}

zip.close();


} }


Expand Down Expand Up @@ -345,27 +397,6 @@ void MainWindow::onWaterfallActionTriggered(){
} }




void MainWindow::mousePressEvent(QMouseEvent *event){
qDebug()<<"mouseenter";
QTableView *table = static_cast<QTableView*>(childAt(event->pos()));
if (!table || table!=ui->tableView){
return;
}
qDebug()<<"is table";
QPoint hotSpot = event->pos() - table->pos();
QMimeData *mimeData = new QMimeData;
mimeData->setText("child->text()");
QDrag *drag = new QDrag(this);
drag->setMimeData(mimeData);
//drag->setPixmap(pixmap);
drag->setHotSpot(hotSpot);
drag->exec(Qt::CopyAction | Qt::MoveAction, Qt::CopyAction);
}

void MainWindow::dragEnterEvent(QDragEnterEvent *){

}

void MainWindow::toggleProxy(){ void MainWindow::toggleProxy(){
if(isUsingCapture){ if(isUsingCapture){
isUsingCapture = false; isUsingCapture = false;
Expand Down Expand Up @@ -428,7 +459,7 @@ void MainWindow::toggleProxy(){
} }


void MainWindow::toggleCapture(){ void MainWindow::toggleCapture(){
captureAct->setChecked(!isUsingCapture); //captureAct->setChecked(!isUsingCapture);
#ifdef Q_WS_WIN32 #ifdef Q_WS_WIN32
RyWinHttp::init(); RyWinHttp::init();
toggleProxy(); toggleProxy();
Expand Down
5 changes: 1 addition & 4 deletions mainwindow.h
Expand Up @@ -46,7 +46,7 @@ class MainWindow : public QMainWindow


private slots: private slots:
void toggleCapture(); void toggleCapture();
void showSettingsDialog(); void importSessions();
public: public:
explicit MainWindow(QWidget *parent=0); explicit MainWindow(QWidget *parent=0);
~MainWindow(); ~MainWindow();
Expand All @@ -70,9 +70,6 @@ public slots:
}ProxyInfo; }ProxyInfo;
RyTableModel pipeTableModel; RyTableModel pipeTableModel;


protected:
void mousePressEvent(QMouseEvent *);
void dragEnterEvent(QDragEnterEvent *);


private: private:
Ui::MainWindow *ui; Ui::MainWindow *ui;
Expand Down
25 changes: 16 additions & 9 deletions mainwindow.ui
Expand Up @@ -13,21 +13,23 @@
<property name="windowTitle"> <property name="windowTitle">
<string>Rythem</string> <string>Rythem</string>
</property> </property>
<property name="windowIcon">
<iconset>
<normaloff>logo.png</normaloff>logo.png</iconset>
</property>
<widget class="QWidget" name="centralWidget"> <widget class="QWidget" name="centralWidget">
<layout class="QHBoxLayout" name="horizontalLayout"> <layout class="QHBoxLayout" name="horizontalLayout">
<item> <item>
<widget class="QSplitter" name="splitter"> <widget class="QSplitter" name="splitter">
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<widget class="QTableView" name="tableView"/> <widget class="RyConnectionTableView" name="tableView"/>
<widget class="QTabWidget" name="tollTabs"> <widget class="QTabWidget" name="tollTabs">
<property name="sizePolicy">
<sizepolicy hsizetype="Ignored" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="currentIndex"> <property name="currentIndex">
<number>0</number> <number>2</number>
</property> </property>
<widget class="QWidget" name="inspectorTab"> <widget class="QWidget" name="inspectorTab">
<attribute name="title"> <attribute name="title">
Expand Down Expand Up @@ -88,8 +90,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>557</width> <width>98</width>
<height>195</height> <height>40</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_3"> <layout class="QVBoxLayout" name="verticalLayout_3">
Expand Down Expand Up @@ -153,7 +155,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>818</width> <width>818</width>
<height>23</height> <height>22</height>
</rect> </rect>
</property> </property>
</widget> </widget>
Expand Down Expand Up @@ -241,6 +243,11 @@
<header>composer.h</header> <header>composer.h</header>
<container>1</container> <container>1</container>
</customwidget> </customwidget>
<customwidget>
<class>RyConnectionTableView</class>
<extends>QTableView</extends>
<header>ryconnectiontableview.h</header>
</customwidget>
</customwidgets> </customwidgets>
<resources> <resources>
<include location="httpfiles.qrc"/> <include location="httpfiles.qrc"/>
Expand Down
2 changes: 2 additions & 0 deletions proxy/rypipedata.cpp
Expand Up @@ -10,6 +10,8 @@ RyPipeData::RyPipeData(int _socketHandle,quint64 connectionId,QObject *parent):
socketConnectionId = connectionId; socketConnectionId = connectionId;
_isContentLenthUnLimit =false; _isContentLenthUnLimit =false;
_isResponseChunked = false; _isResponseChunked = false;
isMatchingRule = false;
isImported = false;
} }


bool RyPipeData::operator <(RyPipeData &pipeData){ bool RyPipeData::operator <(RyPipeData &pipeData){
Expand Down
1 change: 1 addition & 0 deletions proxy/rypipedata.h
Expand Up @@ -116,6 +116,7 @@ class RyPipeData : public QObject
QString getResponseHeader(const QString& name)const; QString getResponseHeader(const QString& name)const;


bool isMatchingRule; bool isMatchingRule;
bool isImported;
int ruleType; int ruleType;


QByteArray requestHeaderRawData()const{ QByteArray requestHeaderRawData()const{
Expand Down

0 comments on commit 87421e4

Please sign in to comment.