Diff
Modified: freeswitch/trunk/contrib/jmesquita/fsgui/fsgui.pro (14298 => 14299)
--- freeswitch/trunk/contrib/jmesquita/fsgui/fsgui.pro 2009-07-19 01:36:33 UTC (rev 14298)
+++ freeswitch/trunk/contrib/jmesquita/fsgui/fsgui.pro 2009-07-20 06:10:15 UTC (rev 14299)
@@ -1,5 +1,6 @@
DESTDIR = ./bin/
message(The project will be installed in $$DESTDIR)
+QT += network
TARGET = fs_gui
TEMPLATE = app
MOC_DIR = ./build/
@@ -11,7 +12,8 @@
src/esl_connection.cpp \
src/consolepage.cpp \
src/preferencesdialog.cpp \
- src/completers.cpp
+ src/completers.cpp \
+ src/pastebindialog.cpp
INCLUDEPATH += ../../../libs/esl/src/include \
src/include
HEADERS += src/include/fs_gui.h \
@@ -20,11 +22,13 @@
src/include/consolepage.h \
src/include/global_defines.h \
src/include/preferencesdialog.h \
- src/include/completers.h
+ src/include/completers.h \
+ src/include/pastebindialog.h
FORMS += resources/fs_gui.ui \
resources/server_manager.ui \
resources/consolepage.ui \
- resources/preferencesdialog.ui
+ resources/preferencesdialog.ui \
+ resources/pastebindialog.ui
LIBS += -L../../../libs/esl \
-lesl
RESOURCES += resources/resources.qrc
Modified: freeswitch/trunk/contrib/jmesquita/fsgui/resources/fs_gui.ui (14298 => 14299)
--- freeswitch/trunk/contrib/jmesquita/fsgui/resources/fs_gui.ui 2009-07-19 01:36:33 UTC (rev 14298)
+++ freeswitch/trunk/contrib/jmesquita/fsgui/resources/fs_gui.ui 2009-07-20 06:10:15 UTC (rev 14299)
@@ -59,6 +59,8 @@
<addaction name="actionConnect"/>
<addaction name="actionDisconnect"/>
<addaction name="separator"/>
+ <addaction name="actionSaveLog"/>
+ <addaction name="separator"/>
<addaction name="actionQuit"/>
</widget>
<widget class="QMenu" name="menuHelp">
@@ -75,8 +77,15 @@
</property>
<addaction name="actionPreferences"/>
</widget>
+ <widget class="QMenu" name="menu_Tools">
+ <property name="title">
+ <string>&Tools</string>
+ </property>
+ <addaction name="actionPastebinLog"/>
+ </widget>
<addaction name="menuFile"/>
<addaction name="menuEdit"/>
+ <addaction name="menu_Tools"/>
<addaction name="menuHelp"/>
</widget>
<widget class="QStatusBar" name="statusBar">
@@ -95,6 +104,9 @@
</property>
</action>
<action name="actionConnect">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
<property name="text">
<string>&Connect</string>
</property>
@@ -131,11 +143,31 @@
<string>Register to &ClueCon</string>
</property>
</action>
+ <action name="actionSaveLog">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>&Save Log</string>
+ </property>
+ <property name="shortcut">
+ <string>Ctrl+S</string>
+ </property>
+ </action>
+ <action name="actionPastebinLog">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>&Pastebin Log</string>
+ </property>
+ <property name="shortcut">
+ <string>Ctrl+Y</string>
+ </property>
+ </action>
</widget>
<layoutdefault spacing="6" margin="11"/>
- <resources>
- <include location="resources.qrc"/>
- </resources>
+ <resources/>
<connections>
<connection>
<sender>actionQuit</sender>
Added: freeswitch/trunk/contrib/jmesquita/fsgui/resources/pastebindialog.ui (0 => 14299)
--- freeswitch/trunk/contrib/jmesquita/fsgui/resources/pastebindialog.ui (rev 0)
+++ freeswitch/trunk/contrib/jmesquita/fsgui/resources/pastebindialog.ui 2009-07-20 06:10:15 UTC (rev 14299)
@@ -0,0 +1,233 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>pastebinDialog</class>
+ <widget class="QDialog" name="pastebinDialog">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>352</width>
+ <height>310</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Dialog</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout_3">
+ <item>
+ <widget class="QGroupBox" name="groupBox">
+ <property name="title">
+ <string>Pastebin</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_4">
+ <item>
+ <widget class="QLabel" name="label">
+ <property name="minimumSize">
+ <size>
+ <width>80</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="text">
+ <string>Url</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLineEdit" name="lineURL">
+ <property name="text">
+ <string>pastebin.freeswitch.org</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_3">
+ <item>
+ <widget class="QLabel" name="label_2">
+ <property name="minimumSize">
+ <size>
+ <width>80</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="text">
+ <string>Port</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLineEdit" name="linePort">
+ <property name="text">
+ <string>80</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <widget class="QLabel" name="label_3">
+ <property name="minimumSize">
+ <size>
+ <width>80</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="text">
+ <string>Username</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLineEdit" name="lineUsername">
+ <property name="text">
+ <string>pastebin</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_2">
+ <item>
+ <widget class="QLabel" name="label_4">
+ <property name="minimumSize">
+ <size>
+ <width>80</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="text">
+ <string>Password</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLineEdit" name="linePassword">
+ <property name="text">
+ <string>freeswitch</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <widget class="QGroupBox" name="groupBox_2">
+ <property name="title">
+ <string>Options</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout_2">
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_5">
+ <item>
+ <widget class="QLabel" name="label_5">
+ <property name="minimumSize">
+ <size>
+ <width>80</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="text">
+ <string>Your name</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLineEdit" name="lineName"/>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_6">
+ <item>
+ <widget class="QLabel" name="label_6">
+ <property name="text">
+ <string>Paste duration</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QRadioButton" name="radioDay">
+ <property name="text">
+ <string>A day</string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QRadioButton" name="radioMonth">
+ <property name="text">
+ <string>A month</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QRadioButton" name="radioForever">
+ <property name="text">
+ <string>Forever</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <widget class="QDialogButtonBox" name="buttonBox">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="standardButtons">
+ <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections>
+ <connection>
+ <sender>buttonBox</sender>
+ <signal>accepted()</signal>
+ <receiver>pastebinDialog</receiver>
+ <slot>accept()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>248</x>
+ <y>254</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>157</x>
+ <y>274</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>buttonBox</sender>
+ <signal>rejected()</signal>
+ <receiver>pastebinDialog</receiver>
+ <slot>reject()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>316</x>
+ <y>260</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>286</x>
+ <y>274</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
+</ui>
Modified: freeswitch/trunk/contrib/jmesquita/fsgui/src/consolepage.cpp (14298 => 14299)
--- freeswitch/trunk/contrib/jmesquita/fsgui/src/consolepage.cpp 2009-07-19 01:36:33 UTC (rev 14298)
+++ freeswitch/trunk/contrib/jmesquita/fsgui/src/consolepage.cpp 2009-07-20 06:10:15 UTC (rev 14299)
@@ -87,6 +87,10 @@
eslConnection->disconnect();
}
}
+QString consolePage::getConsoleText()
+{
+ return m_ui->textConsole->toPlainText();
+}
void consolePage::doConnect()
{
eslConnection->doConnect();
Modified: freeswitch/trunk/contrib/jmesquita/fsgui/src/fs_gui.cpp (14298 => 14299)
--- freeswitch/trunk/contrib/jmesquita/fsgui/src/fs_gui.cpp 2009-07-19 01:36:33 UTC (rev 14298)
+++ freeswitch/trunk/contrib/jmesquita/fsgui/src/fs_gui.cpp 2009-07-20 06:10:15 UTC (rev 14299)
@@ -39,12 +39,15 @@
#include "fs_gui.h"
#include "ui_fs_gui.h"
#include "consolepage.h"
+#include <QtNetwork>
Cfsgui::Cfsgui(QWidget *parent) :
QMainWindow(parent),
m_ui(new Ui::Cfsgui),
serverDialog(NULL),
- prefDialog(NULL)
+ prefDialog(NULL),
+ fileDialog(NULL),
+ pasteDialog(NULL)
{
m_ui->setupUi(this);
@@ -59,10 +62,15 @@
this, SLOT(doConnect()));
connect(m_ui->actionDisconnect, SIGNAL(triggered()),
this, SLOT(doDisconnect()));
+ connect(m_ui->actionSaveLog, SIGNAL(triggered()),
+ this, SLOT(saveLog()));
+ connect(m_ui->actionPastebinLog, SIGNAL(triggered()),
+ this, SLOT(pastebinLog()));
connect(m_ui->actionAbout, SIGNAL(triggered()),
this, SLOT(showAbout()));
connect(m_ui->actionRegisterClueCon, SIGNAL(triggered()),
this, SLOT(registerClueCon()));
+
connect(m_ui->tabWidget, SIGNAL(tabCloseRequested(int)),
this, SLOT(closeTab(int)));
connect(m_ui->tabWidget, SIGNAL(currentChanged(int)),
@@ -160,11 +168,15 @@
{
m_ui->actionConnect->setDisabled(true);
m_ui->actionDisconnect->setEnabled(true);
+ m_ui->actionSaveLog->setEnabled(true);
+ m_ui->actionPastebinLog->setEnabled(true);
}
void Cfsgui::gotDisconnected()
{
m_ui->actionConnect->setEnabled(true);
m_ui->actionDisconnect->setDisabled(true);
+ m_ui->actionSaveLog->setDisabled(true);
+ m_ui->actionPastebinLog->setDisabled(true);
}
void Cfsgui::backgroundColorChanged()
{
@@ -174,6 +186,43 @@
tab->setConsoleBackground();
}
}
+void Cfsgui::saveLog()
+{
+ consolePage *tab = static_cast<consolePage *>(m_ui->tabWidget->widget(m_ui->tabWidget->currentIndex()));
+ if (tab)
+ {
+ if(!fileDialog)
+ {
+ fileDialog = new QFileDialog(this);
+ }
+
+ fileDialog->setAcceptMode(QFileDialog::AcceptSave);
+
+ if (fileDialog->exec())
+ {
+ QStringList fileNames = fileDialog->selectedFiles();
+ QFile file(fileNames[0]);
+ file.open(QIODevice::WriteOnly|QIODevice::Truncate|QIODevice::Text);
+ file.write(tab->getConsoleText().toAscii());
+ file.close();
+ }
+ }
+}
+void Cfsgui::pastebinLog()
+{
+ consolePage *tab = static_cast<consolePage *>(m_ui->tabWidget->widget(m_ui->tabWidget->currentIndex()));
+ if (tab)
+ {
+ if (!pasteDialog)
+ {
+ pasteDialog = new pastebinDialog(this);
+ }
+ pasteDialog->setText(tab->getConsoleText());
+ pasteDialog->show();
+ pasteDialog->raise();
+ pasteDialog->activateWindow();
+ }
+}
void Cfsgui::registerClueCon()
{
QDesktopServices::openUrl(QUrl("http://www.cluecon.com/user/register"));
Modified: freeswitch/trunk/contrib/jmesquita/fsgui/src/include/consolepage.h (14298 => 14299)
--- freeswitch/trunk/contrib/jmesquita/fsgui/src/include/consolepage.h 2009-07-19 01:36:33 UTC (rev 14298)
+++ freeswitch/trunk/contrib/jmesquita/fsgui/src/include/consolepage.h 2009-07-20 06:10:15 UTC (rev 14299)
@@ -25,6 +25,7 @@
int isConnected();
void doConnect();
void doDisconnect();
+ QString getConsoleText();
protected:
virtual void changeEvent(QEvent *e);
Modified: freeswitch/trunk/contrib/jmesquita/fsgui/src/include/fs_gui.h (14298 => 14299)
--- freeswitch/trunk/contrib/jmesquita/fsgui/src/include/fs_gui.h 2009-07-19 01:36:33 UTC (rev 14298)
+++ freeswitch/trunk/contrib/jmesquita/fsgui/src/include/fs_gui.h 2009-07-20 06:10:15 UTC (rev 14299)
@@ -42,12 +42,12 @@
#include <QtGui>
#include "server_manager.h"
#include "preferencesdialog.h"
+#include "pastebindialog.h"
namespace Ui {
class Cfsgui;
}
-
class Cfsgui : public QMainWindow {
Q_OBJECT
Q_DISABLE_COPY(Cfsgui)
@@ -66,6 +66,8 @@
void closeTab(int);
void changeTab(int);
void backgroundColorChanged();
+ void saveLog();
+ void pastebinLog();
void registerClueCon();
void doConnect();
void doDisconnect();
@@ -76,6 +78,8 @@
Ui::Cfsgui *m_ui;
CserverManager *serverDialog;
preferencesDialog *prefDialog;
+ QFileDialog *fileDialog;
+ pastebinDialog *pasteDialog;
void saveWindowSettings();
};
Added: freeswitch/trunk/contrib/jmesquita/fsgui/src/include/pastebindialog.h (0 => 14299)
--- freeswitch/trunk/contrib/jmesquita/fsgui/src/include/pastebindialog.h (rev 0)
+++ freeswitch/trunk/contrib/jmesquita/fsgui/src/include/pastebindialog.h 2009-07-20 06:10:15 UTC (rev 14299)
@@ -0,0 +1,34 @@
+#ifndef PASTEBINDIALOG_H
+#define PASTEBINDIALOG_H
+
+#include <QtGui/QDialog>
+
+namespace Ui {
+ class pastebinDialog;
+}
+
+class QHttp;
+class QString;
+
+class pastebinDialog : public QDialog {
+ Q_OBJECT
+ Q_DISABLE_COPY(pastebinDialog)
+public:
+ explicit pastebinDialog(QWidget *parent = 0);
+ virtual ~pastebinDialog();
+ void setText(QString);
+
+protected:
+ virtual void changeEvent(QEvent *e);
+
+private:
+ Ui::pastebinDialog *m_ui;
+ QString text;
+ QHttp * pastebinHttp;
+
+private slots:
+ void pastebinFinished(int, bool);
+ void pasteIt();
+};
+
+#endif // PASTEBINDIALOG_H
Added: freeswitch/trunk/contrib/jmesquita/fsgui/src/pastebindialog.cpp (0 => 14299)
--- freeswitch/trunk/contrib/jmesquita/fsgui/src/pastebindialog.cpp (rev 0)
+++ freeswitch/trunk/contrib/jmesquita/fsgui/src/pastebindialog.cpp 2009-07-20 06:10:15 UTC (rev 14299)
@@ -0,0 +1,79 @@
+#include <QtGui>
+#include <QtNetwork>
+#include "pastebindialog.h"
+#include "ui_pastebindialog.h"
+
+pastebinDialog::pastebinDialog(QWidget *parent) :
+ QDialog(parent),
+ m_ui(new Ui::pastebinDialog)
+{
+ m_ui->setupUi(this);
+
+ connect(this, SIGNAL(accepted()),
+ this, SLOT(pasteIt()));
+}
+
+pastebinDialog::~pastebinDialog()
+{
+ delete m_ui;
+}
+
+void pastebinDialog::changeEvent(QEvent *e)
+{
+ QDialog::changeEvent(e);
+ switch (e->type()) {
+ case QEvent::LanguageChange:
+ m_ui->retranslateUi(this);
+ break;
+ default:
+ break;
+ }
+}
+void pastebinDialog::pastebinFinished(int req, bool isError)
+{
+ QMessageBox msgBox;
+ if (isError)
+ {
+ msgBox.setText(QString("Error on pastebin: %1").arg(pastebinHttp->errorString()));
+ msgBox.setIcon(QMessageBox::Critical);
+ msgBox.exec();
+ }
+ else
+ {
+ msgBox.setText("Pastebin correctly pasted!");
+ msgBox.setIcon(QMessageBox::Information);
+ msgBox.exec();
+ }
+}
+void pastebinDialog::pasteIt()
+{
+
+ pastebinHttp = new QHttp(this);
+
+ /* TODO: Make a progress thing? */
+ connect(pastebinHttp, SIGNAL(requestFinished(int,bool)),
+ this, SLOT(pastebinFinished(int,bool)));
+
+ QHttpRequestHeader header( "POST", "/pastebin.php") ;
+ header.setValue( "Host", "pastebin.freeswitch.org" ) ;
+ header.setContentType( "application/x-www-form-urlencoded" ) ;
+
+ pastebinHttp->setHost(m_ui->lineURL->text(), QHttp::ConnectionModeHttp, m_ui->linePort->text().toInt());
+ pastebinHttp->setUser(m_ui->lineUsername->text(), m_ui->linePassword->text());
+ header.setValue( "User-Agent", "FsGUI");
+ QString params("parent_pid=&format=fslog");
+ params.append("&code2=%1").arg(text);
+ if (m_ui->lineName->text().trimmed() == "")
+ params.append("&poster=%1&paste=Send&remember=0").arg(tr("Anonymous"));
+ if (m_ui->radioDay->isChecked())
+ params.append("&expiry=%1").arg("d");
+ if (m_ui->radioMonth->isChecked())
+ params.append("&expiry=%1").arg("m");
+ if (m_ui->radioForever->isChecked())
+ params.append("&expiry=%1").arg("f");
+ pastebinHttp->request(header, params.toUtf8());
+}
+void pastebinDialog::setText(QString consoleText)
+{
+ text = consoleText;
+}