void WebClient::handleReadChunkSize(const boost_error_code& error, size_t bytes_transferred)
{
	cout << "HandleReadChunkSize" << endl;

	if (is_cancellation_pending_)
	{
		cancelConnect();
		return;
	}

	if (error)
	{
		cout << "Error on receive: " << error.message() << endl;
		cancelConnect();
		return;
	}

	string line = string(boost::asio::buffer_cast<const char*>(response_.data()), bytes_transferred);
	response_.consume(bytes_transferred);

	size_t size = -1;

	if(qi::parse(line.cbegin(), line.cend(), qi::hex[phoenix::ref(size) = qi::_1] >> (qi::lit("\r\n") | qi::lit("\n"))))
	{
		if(size == 0)
		{
			cancelConnect();
		}
		else
		{
			cout << "LoadHandleReadChunkedContent" << endl;
			cout << "Chunk Size:" <<size << endl;

			boost::asio::async_read(socket_, response_, 
				boost::asio::transfer_exactly(size),
				boost::bind(&WebClient::handleReadChunkedContent3, this,
				boost::asio::placeholders::error,
				boost::asio::placeholders::bytes_transferred));
		}
	}
	else
	{
예제 #2
0
ConnSettings::~ConnSettings()
{
    disconnect(ok, SIGNAL(clicked()), this, SLOT(saveConnect()));
    disconnect(cancel, SIGNAL(clicked()), this, SLOT(cancelConnect()));
    disconnect(ConnName, SIGNAL(textChanged(QString)), this, SLOT(set_Title_Name(QString)));
    disconnect(Drivers, SIGNAL(currentIndexChanged(QString)), this, SLOT(changeConnParameters(QString)));

    delete atStart;
    atStart = NULL;
    delete ok;
    ok = NULL;
    delete cancel;
    cancel = NULL;
    delete warning;
    warning = NULL;
    delete URI;
    URI = NULL;
    delete buttonsLayout;
    buttonsLayout = NULL;
    delete buttons;
    buttons = NULL;

    delete connName;
    connName = NULL;
    delete ConnName;
    ConnName = NULL;
    delete driver;
    driver = NULL;
    delete Drivers;
    Drivers = NULL;
    delete transport;
    transport = NULL;
    delete Transports;
    Transports = NULL;
    delete host;
    host = NULL;
    delete Host;
    Host = NULL;
    delete path;
    path = NULL;
    delete Path;
    Path = NULL;
    delete extra;
    extra = NULL;
    delete Extra;
    Extra = NULL;
    delete paramLayout;
    paramLayout = NULL;
    delete parameters;
    parameters = NULL;
    delete commonLayout;
    commonLayout = NULL;
}
예제 #3
0
void ConnSettings::initButtons()
{
    atStart = new QCheckBox("Connect at Start", this);
    atStart->setChecked(false);
    ok = new QPushButton(QIcon::fromTheme("dialog-ok"),"Ok");
    cancel = new QPushButton(QIcon::fromTheme("dialog-cancel"),"Cancel");
    buttonsLayout = new QHBoxLayout(this);
    buttonsLayout->addWidget(atStart);
    buttonsLayout->addWidget(ok);
    buttonsLayout->addWidget(cancel);
    buttons = new QWidget(this);
    buttons->setLayout(buttonsLayout);
    connect(ok, SIGNAL(clicked()), this, SLOT(saveConnect()));
    connect(cancel, SIGNAL(clicked()), this, SLOT(cancelConnect()));
}
예제 #4
0
RfcommClient::RfcommClient(QWidget *parent, Qt::WFlags f)
    : QMainWindow(parent, f)
{
    waiter = new QWaitWidget(this);
    connect(waiter, SIGNAL(cancelled()), this, SLOT(cancelConnect()));

    connectAction = new QAction(tr("Connect..."), this);
    connect(connectAction, SIGNAL(triggered()), this, SLOT(connectSocket()));
    QSoftMenuBar::menuFor(this)->addAction(connectAction);
    connectAction->setVisible(true);

    disconnectAction = new QAction(tr("Disconnect"), this);
    connect(disconnectAction, SIGNAL(triggered()), this, SLOT(disconnectSocket()));
    disconnectAction->setVisible(false);
    QSoftMenuBar::menuFor(this)->addAction(disconnectAction);

    sendAction = new QAction(tr("Send"), this);
    connect(sendAction, SIGNAL(triggered()), this, SLOT(newUserText()));
    sendAction->setVisible(false);
    QSoftMenuBar::menuFor(this)->addAction(sendAction);

    QWidget *frame = new QWidget(this);
    QVBoxLayout *layout = new QVBoxLayout;

    logArea = new QTextEdit(frame);
    layout->addWidget(logArea);
    logArea->append(tr("Not connected"));
    logArea->setReadOnly(true);
    logArea->setFocusPolicy(Qt::NoFocus);

    userEntry = new QLineEdit(frame);
    userEntry->setEnabled(false);
    connect(userEntry, SIGNAL(editingFinished()), this, SLOT(newUserText()));
    layout->addWidget(userEntry);

    frame->setLayout(layout);
    setCentralWidget(frame);

    socket = new QBluetoothRfcommSocket(this);
    connect(socket, SIGNAL(connected()), this, SLOT(socketConnected()));
    connect(socket, SIGNAL(readyRead()), this, SLOT(serverReplied()));

    setWindowTitle(tr("RFCOMM Client"));
}
예제 #5
0
파일: wicdapplet.cpp 프로젝트: KDE/wicd-kde
void WicdApplet::init()
{
    m_theme->resize(contentsRect().size());
    
    Plasma::ToolTipManager::self()->registerWidget(this);

    //load dataengine
    Plasma::DataEngine *engine = dataEngine("wicd");
    if (!engine->isValid()) {
        setFailedToLaunch(true, i18n("Unable to load the Wicd data engine."));
        return;
    }
    
    setupActions();
    
    //build the popup dialog
    QGraphicsWidget *appletDialog = new QGraphicsWidget(this);
    m_dialoglayout = new QGraphicsLinearLayout(Qt::Vertical);
    
    //Network list
    m_scrollWidget = new Plasma::ScrollWidget(appletDialog);
    m_scrollWidget->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    m_scrollWidget->setFlag(QGraphicsItem::ItemClipsChildrenToShape);
    m_scrollWidget->setMaximumHeight(400);

    m_networkView = new NetworkView(m_scrollWidget);
    m_scrollWidget->setWidget(m_networkView);

    m_busyWidget = new Plasma::BusyWidget(m_scrollWidget);
    m_busyWidget->hide();

    m_dialoglayout->addItem(m_scrollWidget);
    
    //Separator
    m_dialoglayout->addItem(new Plasma::Separator(appletDialog));
    
    //Bottom bar
    QGraphicsLinearLayout* bottombarLayout = new QGraphicsLinearLayout(Qt::Horizontal);
    
    m_messageBox = new Plasma::Label(appletDialog);
    m_messageBox->setWordWrap(false);
    bottombarLayout->addItem(m_messageBox);
    
    bottombarLayout->addStretch();
    
    m_abortButton = new Plasma::ToolButton(appletDialog);
    m_abortButton->setIcon(KIcon("dialog-cancel"));
    m_abortButton->nativeWidget()->setToolTip(i18n("Abort"));
    connect(m_abortButton, SIGNAL(clicked()), this, SLOT(cancelConnect()));
    bottombarLayout->addItem(m_abortButton);
    
    Plasma::ToolButton *reloadButton = new Plasma::ToolButton(appletDialog);
    reloadButton->nativeWidget()->setToolTip(i18n("Reload"));
    reloadButton->setAction(action("reload"));
    bottombarLayout->addItem(reloadButton);
    
    m_dialoglayout->addItem(bottombarLayout);
    
    appletDialog->setLayout(m_dialoglayout);
    setGraphicsWidget(appletDialog);

    setHasConfigurationInterface(true);
    
    // read config
    configChanged();

    connect(Plasma::Theme::defaultTheme(), SIGNAL(themeChanged()), SLOT(updateColors()));


    //prevent notification on startup
    m_status.State = 10;
    m_isScanning = false;
    //connect dataengine
    m_wicdService = engine->serviceForSource("");
    engine->connectSource("status", this);
    engine->connectSource("daemon", this);
}