Beispiel #1
0
/*********************************************************************
 *
 * Main Program.  Open and subscribe for events for two sessions.
 * Then run the above test.
 *
 * *******************************************************************/
int main()
{
	int ret = SAF_TEST_UNRESOLVED;
	SaHpiSessionIdT sessionId1;
	SaHpiSessionIdT sessionId2;

	if (openSession(&sessionId1) != SA_OK) {
		ret = SAF_TEST_UNRESOLVED;
	} else {
		if (openSession(&sessionId2) != SA_OK) {
			ret = SAF_TEST_UNRESOLVED;
		} else {
			if (subscribe(sessionId1) != SA_OK) {
				ret = SAF_TEST_UNRESOLVED;
			} else {
				if (subscribe(sessionId2) != SA_OK) {
					ret = SAF_TEST_UNRESOLVED;
				} else {
					ret = run_test(sessionId1, sessionId2);
					unsubscribe(sessionId2);
				}
				unsubscribe(sessionId1);
			}
			closeSession(sessionId2);
		}
		closeSession(sessionId1);
	}

	return ret;
}
    //PRE AND POST COMMAND should be used at the begining and the end of camera interaction functions
    //EG: taking a picture or starting / ending live view.
    //
    //They check if their is an open session to the camera and if there isn't they create a session
    //postCommand closes any sessions created by preCommand
    //
    // eg:
    // preCommand
    // takePicture
    // postCommand
    //---------------------------------------------------------------------
    bool CanonCameraWrapper::preCommand(){

        printf("pre command \n");

        if( state > CAMERA_UNKNOWN ){
            needToOpen = false;
            bool readyToGo  = false;
			
            if( state != CAMERA_OPEN ){
                needToOpen = true;
            }else{
                readyToGo = true;
                return true;
            }

            if( needToOpen ){
                readyToGo = openSession();
            }

            return readyToGo;

        }else{
            return false;
        }

    }
String
WinINetRequest::send()
{
    if (m_used) {
        throw XArch("class is one time use.");
    }
    m_used = true;

    openSession();
    connect();
    openRequest();
    
    String headers("Content-Type: text/html");
    if (!HttpSendRequest(m_request, headers.c_str(), (DWORD)headers.length(), NULL, NULL)) {
        throw XArch(new XArchEvalWindows());
    }
    
    std::stringstream result;
    CHAR buffer[1025];
    DWORD read = 0;

    while (InternetReadFile(m_request, buffer, sizeof(buffer) - 1, &read) && (read != 0)) {
        buffer[read] = 0;
        result << buffer;
        read = 0;
    }

    return result.str();
}
Beispiel #4
0
int XMPPClient::stateAction() {
 
  // Serial.print("State = ");
  // Serial.println(state);

  switch(state) {
    case INIT:
      openStream(server);
      break;
    case AUTH:
      authenticate(username, password);
      break;
    case AUTH_STREAM:
      openStream(server);
      break;
    case BIND:
      bindResource(resource);
      break;
    case SESS:
      openSession(server);
      break;
    case READY:
      return 1;
      break;
    case WAIT:
      break;
    default:
      return -1;
      break;
  }
  return 0;
}
Beispiel #5
0
SessionDlg::SessionDlg(QWidget* parent) : QDialog(parent), result_(0) {
	ui.setupUi(this);

	ui.sessionTree->header()->hide();

	QStringList sList = sessionList();
	foreach (QString session, sList) {
		if (session.compare("_empty_session_") != 0) {
			QStringList items;
			items << session;
			QTreeWidgetItem* it = new QTreeWidgetItem(items);
			ui.sessionTree->addTopLevelItem(it);
		}
	}
	if (sList.count() > 0) {
		ui.sessionTree->setCurrentItem(ui.sessionTree->topLevelItem(0));
	}
	else {
		ui.openSessionBtn->setEnabled(false);
		ui.removeSessionBtn->setEnabled(false);
	}

	connect(ui.openSessionBtn,   SIGNAL(clicked()), SLOT(openSession()));
	connect(ui.newSessionBtn,    SIGNAL(clicked()), SLOT(newSession()));
	connect(ui.removeSessionBtn, SIGNAL(clicked()), SLOT(removeSession()));
	connect(ui.sessionTree, SIGNAL(itemActivated(QTreeWidgetItem*, int)), SLOT(activated(QTreeWidgetItem*, int)));
}
int
ZnsHelper::loadChecks(const SourceT& srcInfo, ChecksT& checks,
                      const QString& filterValue, ngrt4n::RequestFilterT filterType)
{
  setBaseUrl(srcInfo.mon_url);

  // Log in if not yet the case
  if (! m_isLogged && openSession(srcInfo) != 0)
    return -1;

  if (! m_isLogged)
    return -1;

  checks.clear();
  QNetworkReply* response = NULL;

  setRouterEndpoint(Device);
  if (filterType == ngrt4n::GroupFilter) {
    response = postRequest(Device, ngrt4n::toByteArray(ReqPatterns[Device].arg("groups", filterValue, QString::number(Device))));
  } else {
    response = postRequest(Device, ngrt4n::toByteArray(ReqPatterns[Device].arg("name", filterValue, QString::number(Device))));
  }

  if (! response || processDeviceReply(response, checks) !=0) {
    return -1;
  }
  return 0;
}
void nsQtNetworkManager::create()
{
    if (!gQtNetworkManager) {
        gQtNetworkManager = new nsQtNetworkManager();
        connect(gQtNetworkManager, SIGNAL(openConnectionSignal()),
                gQtNetworkManager, SLOT(openSession()),
                Qt::BlockingQueuedConnection);
        connect(&gQtNetworkManager->networkConfigurationManager,
                SIGNAL(onlineStateChanged(bool)), gQtNetworkManager,
                SLOT(onlineStateChanged(bool)));
    }
Beispiel #8
0
SessionsManagerDialog::SessionsManagerDialog(QWidget *parent) : Dialog(parent),
	m_ui(new Ui::SessionsManagerDialog)
{
	m_ui->setupUi(this);
	m_ui->openInExistingWindowCheckBox->setChecked(SettingsManager::getValue(SettingsManager::Sessions_OpenInExistingWindowOption).toBool());

	const QStringList sessions(SessionsManager::getSessions());
	QMultiHash<QString, SessionInformation> information;

	for (int i = 0; i < sessions.count(); ++i)
	{
		const SessionInformation session(SessionsManager::getSession(sessions.at(i)));

		information.insert((session.title.isEmpty() ? tr("(Untitled)") : session.title), session);
	}

	QStandardItemModel *model(new QStandardItemModel(this));
	model->setHorizontalHeaderLabels(QStringList({tr("Title"), tr("Identifier"), tr("Windows")}));

	const QList<SessionInformation> sorted(information.values());
	const QString currentSession(SessionsManager::getCurrentSession());
	int row(0);

	for (int i = 0; i < sorted.count(); ++i)
	{
		int windows(0);

		for (int j = 0; j < sorted.at(i).windows.count(); ++j)
		{
			windows += sorted.at(i).windows.at(j).windows.count();
		}

		if (sorted.at(i).path == currentSession)
		{
			row = i;
		}

		QList<QStandardItem*> items({new QStandardItem(sorted.at(i).title.isEmpty() ? tr("(Untitled)") : sorted.at(i).title), new QStandardItem(sorted.at(i).path), new QStandardItem(tr("%n window(s) (%1)", "", sorted.at(i).windows.count()).arg(tr("%n tab(s)", "", windows)))});
		items[0]->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
		items[1]->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
		items[2]->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);

		model->appendRow(items);
	}

	m_ui->sessionsViewWidget->setModel(model);

	connect(m_ui->openButton, SIGNAL(clicked()), this, SLOT(openSession()));
	connect(m_ui->deleteButton, SIGNAL(clicked()), this, SLOT(deleteSession()));
	connect(m_ui->sessionsViewWidget, SIGNAL(needsActionsUpdate()), this, SLOT(updateActions()));

	m_ui->sessionsViewWidget->setCurrentIndex(m_ui->sessionsViewWidget->getIndex(row, 0));
}
Beispiel #9
0
// Startup methods.
bool synthv1_jack_application::setup (void)
{
	if (m_pApp == NULL)
		return false;

	if (!parse_args()) {
		m_pApp->quit();
		return false;
	}

	m_pSynth = new synthv1_jack();

	if (m_bGui) {
		m_pWidget = new synthv1widget_jack(m_pSynth);
		if (m_presets.isEmpty())
			m_pWidget->initPreset();
		else
			m_pWidget->loadPreset(m_presets.first());
		m_pWidget->show();
	}
	else
	if (!m_presets.isEmpty())
		synthv1_param::loadPreset(m_pSynth, m_presets.first());

#ifdef CONFIG_NSM
	// Check whether to participate into a NSM session...
	const QString& nsm_url
		= QString::fromLatin1(::getenv("NSM_URL"));
	if (!nsm_url.isEmpty()) {
		m_pNsmClient = new synthv1_nsm(nsm_url);
		QObject::connect(m_pNsmClient,
			SIGNAL(open()),
			SLOT(openSession()));
		QObject::connect(m_pNsmClient,
			SIGNAL(save()),
			SLOT(saveSession()));
		QObject::connect(m_pNsmClient,
			SIGNAL(show()),
			SLOT(showSession()));
		QObject::connect(m_pNsmClient,
			SIGNAL(hide()),
			SLOT(hideSession()));
		QString caps(":switch:dirty:");
		if (m_bGui)
			caps += "optional-gui:";
		m_pNsmClient->announce(SYNTHV1_TITLE, caps.toLatin1().constData());
		if (m_pWidget)
			m_pWidget->setNsmClient(m_pNsmClient);
	}
#endif	// CONFIG_NSM

	return true;
}
Beispiel #10
0
void MtpDevice::initialize() {
    openSession();
    mDeviceInfo = getDeviceInfo();
    if (mDeviceInfo) {
        if (mDeviceInfo->mDeviceProperties) {
            int count = mDeviceInfo->mDeviceProperties->size();
            for (int i = 0; i < count; i++) {
                MtpDeviceProperty propCode = (*mDeviceInfo->mDeviceProperties)[i];
                MtpProperty* property = getDevicePropDesc(propCode);
                if (property)
                    mDeviceProperties.push(property);
            }
        }
    }
}
Beispiel #11
0
void MainWindow::on_actionOpenSession_triggered()
{
    qDebug("Open Session Action");

    static QString dirName;
    QString fileName;
    QStringList fileTypes = SessionFileFormat::supportedFileTypes(
                                                SessionFileFormat::kOpenFile);
    QString fileType;
    QString errorStr;
    bool ret;

    if (portsWindow->portGroupCount()) {
        if (QMessageBox::question(this,
                tr("Open Session"),
                tr("Existing session will be lost. Proceed?"),
                QMessageBox::Yes | QMessageBox::No,
                QMessageBox::No) == QMessageBox::No)
            goto _exit;
    }

    if (fileTypes.size())
        fileType = fileTypes.at(0);

    fileName = QFileDialog::getOpenFileName(this, tr("Open Session"),
            dirName, fileTypes.join(";;"), &fileType);
    if (fileName.isEmpty())
        goto _exit;

    ret = openSession(fileName, errorStr);
    if (!ret || !errorStr.isEmpty()) {
        QMessageBox msgBox(this);
        QStringList str = errorStr.split("\n\n\n\n");

        msgBox.setIcon(ret ? QMessageBox::Warning : QMessageBox::Critical);
        msgBox.setWindowTitle(qApp->applicationName());
        msgBox.setText(str.at(0));
        if (str.size() > 1)
            msgBox.setDetailedText(str.at(1));
        msgBox.setStandardButtons(QMessageBox::Ok);

        msgBox.exec();
    }
    dirName = QFileInfo(fileName).absolutePath();

_exit:
    return;
}
SessionsManagerDialog::SessionsManagerDialog(QWidget *parent) : Dialog(parent),
	m_ui(new Ui::SessionsManagerDialog)
{
	m_ui->setupUi(this);
	m_ui->openInExistingWindowCheckBox->setChecked(SettingsManager::getValue(QLatin1String("Sessions/OpenInExistingWindow")).toBool());

	const QStringList sessions = SessionsManager::getSessions();
	QMultiHash<QString, SessionInformation> information;

	for (int i = 0; i < sessions.count(); ++i)
	{
		const SessionInformation session = SessionsManager::getSession(sessions.at(i));

		information.insert((session.title.isEmpty() ? tr("(Untitled)") : session.title), session);
	}

	const QList<SessionInformation> sorted = information.values();
	const QString currentSession = SessionsManager::getCurrentSession();
	int index = 0;

	m_ui->sessionsWidget->setRowCount(sorted.count());

	for (int i = 0; i < sorted.count(); ++i)
	{
		int windows = 0;

		for (int j = 0; j < sorted.at(i).windows.count(); ++j)
		{
			windows += sorted.at(i).windows.at(j).windows.count();
		}

		if (sorted.at(i).path == currentSession)
		{
			index = i;
		}

		m_ui->sessionsWidget->setItem(i, 0, new QTableWidgetItem(sorted.at(i).title.isEmpty() ? tr("(Untitled)") : sorted.at(i).title));
		m_ui->sessionsWidget->setItem(i, 1, new QTableWidgetItem(sorted.at(i).path));
		m_ui->sessionsWidget->setItem(i, 2, new QTableWidgetItem(QStringLiteral("%1 (%2)").arg(sorted.at(i).windows.count()).arg(windows)));
	}

	connect(m_ui->openButton, SIGNAL(clicked()), this, SLOT(openSession()));
	connect(m_ui->deleteButton, SIGNAL(clicked()), this, SLOT(deleteSession()));
	connect(m_ui->sessionsWidget, SIGNAL(currentCellChanged(int,int,int,int)), this, SLOT(currentChanged(int)));

	m_ui->sessionsWidget->setCurrentCell(index, 0);
}
Beispiel #13
0
Server::Server(QWidget *parent)
:   QDialog(parent), tcpServer(0), networkSession(0),
    mInternalSync(false)
{
    statusLabel = new QLabel;
    quitButton = new QPushButton(tr("Quit"));
    quitButton->setAutoDefault(false);
    mCurrentTrackName.clear();
    mProcess = new QProcess(this);
    mXmlQuery = new QXmlQuery;
    mCurrentRequest.clear();
    connect(mProcess,SIGNAL(finished(int,QProcess::ExitStatus)),this,SLOT(processFinished(int,QProcess::ExitStatus)));

// Populate command filename depending on the underlying platform
    QString commandsFileName;
#ifdef Q_OS_LINUX
    commandsFileName = ":/xml/linux_commands.xml";
    // TODO: Add support to get the player name dynamically
    mPlayerName = KRhythmbox;
#else Q_OS_WIN32
    commandsFileName = ":/xml/win_commands.xml";
    mPlayerName = KWinamp;
#endif

    mCommands = new QFile(commandsFileName,this);
    if(!mCommands->open(QIODevice::ReadOnly))
    {

    }

    openSession();
    connect(quitButton, SIGNAL(clicked()), this, SLOT(close()));
    connect(tcpServer, SIGNAL(newConnection()), this, SLOT(handleNewConnection()));

    QHBoxLayout *buttonLayout = new QHBoxLayout;
    buttonLayout->addStretch(1);
    buttonLayout->addWidget(quitButton);
    buttonLayout->addStretch(1);

    QVBoxLayout *mainLayout = new QVBoxLayout;
    mainLayout->addWidget(statusLabel);
    mainLayout->addLayout(buttonLayout);
    setLayout(mainLayout);
    setWindowTitle(tr("Angel Server"));
}
SessionWidget::SessionWidget(const QNetworkConfiguration &config, QWidget *parent)
:   QWidget(parent), statsTimer(-1)
{
    setupUi(this);

#ifdef QT_NO_NETWORKINTERFACE
    interfaceName->setVisible(false);
    interfaceNameLabel->setVisible(false);
    interfaceGuid->setVisible(false);
    interfaceGuidLabel->setVisible(false);
#endif

    session = new QNetworkSession(config, this);

    connect(session, SIGNAL(stateChanged(QNetworkSession::State)),
            this, SLOT(updateSession()));
    connect(session, SIGNAL(error(QNetworkSession::SessionError)),
            this, SLOT(updateSessionError(QNetworkSession::SessionError)));

    updateSession();

    sessionId->setText(QString("0x%1").arg(qulonglong(session), 8, 16, QChar('0')));

    configuration->setText(session->configuration().name());

    connect(openSessionButton, SIGNAL(clicked()),
            this, SLOT(openSession()));
    connect(openSyncSessionButton, SIGNAL(clicked()),
            this, SLOT(openSyncSession()));
    connect(closeSessionButton, SIGNAL(clicked()),
            this, SLOT(closeSession()));
    connect(stopSessionButton, SIGNAL(clicked()),
            this, SLOT(stopSession()));
#if defined(Q_WS_MAEMO_5) || defined(Q_WS_MAEMO_6)
    connect(deleteSessionButton, SIGNAL(clicked()),
            this, SLOT(deleteSession()));
#endif
}
Beispiel #15
0
void MainWindow::initMenuFile() {
	//connect menu "File" Action
	connect(actionNew, SIGNAL(triggered()), _documentManager, SLOT(newDocument()));
	connect(actionOpen, SIGNAL(triggered()), _documentManager, SLOT(open()));
	connect(actionSave, SIGNAL(triggered()), _documentManager, SLOT(save()));
	connect(actionSaveAs, SIGNAL(triggered()), _documentManager, SLOT(saveAs()));
	connect(actionSaveACopyAs, SIGNAL(triggered()), _documentManager, SLOT(saveACopyAs()));
	connect(actionSaveAll, SIGNAL(triggered()), _documentManager, SLOT(saveAll()));
	connect(actionClose, SIGNAL(triggered()), _documentManager, SLOT(close()));
	connect(actionCloseAll, SIGNAL(triggered()), _documentManager, SLOT(closeAll()));
	connect(actionCloseAllExceptCurrentDocument, SIGNAL(triggered()), _documentManager, SLOT(closeAllExceptCurrentDocument()));
	connect(actionReload, SIGNAL(triggered()), _documentManager, SLOT(reload()));
	connect(actionPrint, SIGNAL(triggered()), _documentManager, SLOT(print()));
	connect(actionExit, SIGNAL(triggered()), qApp, SLOT(closeAllWindows()));

	connect(actionExportAsHTML, SIGNAL(triggered()), this, SLOT(exportDocument()));

	connect(actionNewSession, SIGNAL(triggered()), _sessionManager, SLOT(newSession()));
	connect(actionOpenSession, SIGNAL(triggered()), _sessionManager, SLOT(openSession()));
	connect(actionSwitchSession, SIGNAL(triggered()), _sessionManager, SLOT(switchSession()));
	connect(actionSaveSession, SIGNAL(triggered()), _sessionManager, SLOT(saveSession()));
	connect(actionSaveSessionAs, SIGNAL(triggered()), _sessionManager, SLOT(saveSessionAs()));
	connect(actionManageSessions, SIGNAL(triggered()), _sessionManager, SLOT(manageSessions()));

	//recent file actions
	connect(actionEmptyRecentFilesList, SIGNAL(triggered()), this, SLOT(clearRecentFile()));
	connect(actionOpenAllRecentFiles, SIGNAL(triggered()), this, SLOT(openAllRecentFile()));
	_recentFileSeparator = menuRecentFiles->addSeparator();
	for (int i = 0; i < MaxRecentFiles; ++i) {
		_recentFileActions[i] = new QAction(this);
		_recentFileActions[i]->setVisible(false);
		connect(_recentFileActions[i], SIGNAL(triggered()),this, SLOT(openRecentFile()));
		menuRecentFiles->addAction(_recentFileActions[i]);
	}
	updateRecentFileActions();
}
Beispiel #16
0
void SessionDlg::activated(QTreeWidgetItem*, int) {
	openSession();
}
Beispiel #17
0
    bool GuiApp::perform (const InvocationInfo& info)
    {


        if (Commands::devicePadPress <= info.commandID
                && (Commands::devicePadPress + 13) > info.commandID)
        {
            const uint16 pad = info.commandID - Commands::devicePadPress;
            //ModifierKeys modKeys = ModifierKeys::getCurrentModifiersRealtime();
            //unsigned long modifiers = 13;//kNoModifiers;

            if (info.isKeyDown)
                std::clog << "Pad pressed: " << pad << std::endl;
            else
                std::clog << "Pad released: " << pad << std::endl;
        }

        if (Commands::isDeviceTrackCommand (info.commandID)) {
        //    pattern->setTrackIndex (info.commandID - Commands::deviceTrack);
            return true;
        }

        SessionRef sr (session());

        switch (info.commandID)
        {
            case Commands::mediaSave: {
                //if (MediaManager::Document* doc = sr->media().openFile (sr.get(), pattern->getFile()))
                 //   doc->save();
                return true;
            }
            case Commands::sessionClose:
                return true;
                break;
            case Commands::sessionNew:
                newSession();
                return true;
                break;
            case Commands::sessionOpen:
                openSession();
                return true;
                break;
            case Commands::sessionSave:
            {
                saveSession();
                return true;
                break;
            }
            case Commands::sessionSaveAs:
                saveSession (true);
                return true;
                break;
            case Commands::showAbout:
                return true;
                break;
            case Commands::showLegacyView:
                openWindow (ELEMENT_LEGACY_WINDOW);
                return true;
                break;
            case Commands::showPluginManager:
                openWindow (ELEMENT_PLUGIN_MANAGER);
                return true;
                break;
            case Commands::showPreferences:
                runDialog (ELEMENT_PREFERENCES);
                return true;
            break;
            case Commands::transportRewind:
                break;
            case Commands::transportForward:
                break;
            case Commands::transportPlay:
                sr->testSetPlaying (true);
                break;
            case Commands::transportRecord:
                break;
            case Commands::transportSeekZero:
                break;
            case Commands::transportStop:
                sr->testSetRecording (false);
                sr->testSetPlaying (false);
                break;
        }
        return true;
    }