Beispiel #1
0
void DlgJsRoboKey::loadMainScript(){
    QString mainScript = QDir::homePath() + "/jsrobokey_main.js";
    m_mainScriptLoaded = loadJSFile(mainScript);
    if (!m_mainScriptLoaded && !m_lastException.isEmpty()){
        showTrayMessage("Main Script had errors", m_lastException);
    }
    //remember, if the file doesn't exist we won't create it,
    //what if the user is running JsRoboKey portably?
}
Beispiel #2
0
void DlgJsRoboKey::closeEvent(QCloseEvent *event)
{
    if (trayIcon->isVisible()) {
        showTrayMessage("JsRoboKey is still running.",
                        "To exit the program completely and all running scripts, Right click -> quit ");
        hide();
        event->ignore();
    }
}
Beispiel #3
0
void MainWindow::slotMplayerProgessUpdate(int progress)
{
    bool ansValid = this->mplayerProcess->isAnsLenghtAndTimePositionValid();
    float valueAnsLenght = 0.0;
    float valueAnsTimePosition = 0.0;
    float sec = 0.0;

    if(ansValid)
    {
    valueAnsLenght = this->mplayerProcess->getAnsLenght();
    valueAnsTimePosition = this->mplayerProcess->getAnsTimePosition();
    sec = (valueAnsLenght-valueAnsTimePosition);
    }

    qDebug() << "MplayerProgress" << progress;

    if(ui->actionStop->isEnabled() && ui->comboBox->currentIndex() == 2)
    {

        if(ansValid)
        {
        ui->progressBar->setValue(progress);
        qDebug() << "MplayerProgressSetValue" << progress;

        qDebug() << "Mplayer Label info Update";
        ui->label->setText(statusBarMessage(sec));


            if((sec < 61.0) && (!this->shutdownTimer->isActive()))
            {
            showTrayMessage("qZleep","sheduled shutdown after 60 seconds!",this->timeoutForShowTrayMessage);
            qDebug() << "qZleep : sheduled shutdown after 60 seconds!";

            saveAllSetting();

            this->shutdownTimer->setInterval(62*1000);
            this->shutdownTimer->setSingleShot(true);
            this->shutdownTimer->start();
            }
        }

        ui->statusBar->showMessage("");
    }
    else
    {
        ui->statusBar->showMessage( "Movie: " + QString::number((int)(valueAnsTimePosition/60.0)) + "/" + QString::number((int)(valueAnsLenght/60.0)) +  "min      " + QString::number(progress) + "%");
    }

}
void MainWindow::changeEvent(QEvent *ev)
{
    if(ev->type() == QEvent::WindowStateChange){
        if(this->windowState() & Qt::WindowMinimized){
            tray->show();
            traymode = true;
            QTimer::singleShot(250, this, SLOT(hide()));
            QTimer::singleShot(600,this,SLOT(showTrayMessage()));
        }

        if(this->windowState() && !Qt::WindowMinimized){
            traymode = false;
        }
    }
    QMainWindow::changeEvent(ev);
}
Beispiel #5
0
void WpaGui::closeEvent(QCloseEvent *event)
{
	if (eh) {
		eh->close();
		delete eh;
		eh = NULL;
	}

	if (scanres) {
		scanres->close();
		delete scanres;
		scanres = NULL;
	}

	if (peers) {
		peers->close();
		delete peers;
		peers = NULL;
	}

	if (udr) {
		udr->close();
		delete udr;
		udr = NULL;
	}

	if (tray_icon && !ackTrayIcon) {
		/* give user a visual hint that the tray icon exists */
		if (QSystemTrayIcon::supportsMessages()) {
			hide();
			showTrayMessage(QSystemTrayIcon::Information, 3,
					qAppName() +
					tr(" will keep running in "
					   "the system tray."));
		} else {
			QMessageBox::information(this, qAppName() +
						 tr(" systray"),
						 tr("The program will keep "
						    "running in the system "
						    "tray."));
		}
		ackTrayIcon = true;
	}

	event->accept();
}
Beispiel #6
0
void WpaGui::showTrayStatus()
{
	char buf[2048];
	size_t len;

	len = sizeof(buf) - 1;
	if (ctrlRequest("STATUS", buf, &len) < 0)
		return;
	buf[len] = '\0';

	QString msg, status(buf);

	QStringList lines = status.split(QRegExp("\\n"));
	for (QStringList::Iterator it = lines.begin();
	     it != lines.end(); it++) {
		int pos = (*it).indexOf('=') + 1;
		if (pos < 1)
			continue;

		if ((*it).startsWith("bssid="))
			msg.append("BSSID:\t" + (*it).mid(pos) + "\n");
		else if ((*it).startsWith("ssid="))
			msg.append("SSID: \t" + (*it).mid(pos) + "\n");
		else if ((*it).startsWith("pairwise_cipher="))
			msg.append("PAIR: \t" + (*it).mid(pos) + "\n");
		else if ((*it).startsWith("group_cipher="))
			msg.append("GROUP:\t" + (*it).mid(pos) + "\n");
		else if ((*it).startsWith("key_mgmt="))
			msg.append("AUTH: \t" + (*it).mid(pos) + "\n");
		else if ((*it).startsWith("wpa_state="))
			msg.append("STATE:\t" + (*it).mid(pos) + "\n");
		else if ((*it).startsWith("ip_address="))
			msg.append("IP:   \t" + (*it).mid(pos) + "\n");
		else if ((*it).startsWith("Supplicant PAE state="))
			msg.append("PAE:  \t" + (*it).mid(pos) + "\n");
		else if ((*it).startsWith("EAP state="))
			msg.append("EAP:  \t" + (*it).mid(pos) + "\n");
	}

	if (!msg.isEmpty())
		showTrayMessage(QSystemTrayIcon::Information, 10, msg);
}
void TeachingLoginDialog::createActions()
{
    connect(ui->submitBtn,SIGNAL(clicked()),this,SLOT(checkUser()));
    connect(showMainWinAction,SIGNAL(triggered()),this,SLOT(showMainWin()));
    connect(quitAction,SIGNAL(triggered()),mainWin,SLOT(quitApp()));
    connect(sysTray,SIGNAL(activated(QSystemTrayIcon::ActivationReason)),this,SLOT(dbClickTray(QSystemTrayIcon::ActivationReason)));
    connect(this,SIGNAL(quitApp()),qApp,SLOT(quit()));
    connect(logoutAction,SIGNAL(triggered()),this,SLOT(showLoginDialog()));
    connect(ui->settingBtn,SIGNAL(clicked()),settingserverdialog,SLOT(exec()));
    //signals from mainwindow
    connect(mainWin,SIGNAL(logout()),this,SLOT(showLoginDialog()));
    connect(mainWin,SIGNAL(logout()),ui->passWord,SLOT(setFocus()));
    connect(mainWin,SIGNAL(minMe()),this,SLOT(showTrayMessage()));
    connect(mainWin,SIGNAL(refreshOnTrayMessage()),this,SLOT(refreshOnTrayMessage()));
    //signal from settingdbserver dialog
    connect(settingserverdialog,SIGNAL(imClosed()),ui->passWord,SLOT(setFocus()));
    //global shortcut
    connect(mainWin,SIGNAL(showMe()),this,SLOT(showMainWin()));
    //getserverconnectinfo
    connect(getInfo,SIGNAL(timeout()),this,SLOT(getServerConnectInfo()));
}
Beispiel #8
0
void MainWindow::timer_toggle()
{

    // Update current time
    //QTime now_time = QTime::currentTime();
    //ui->timeEdit_2->setTime(now_time);


    if(!access)
    {
        // periodicly check access and enbale start if access ok
        if(check_access)
        {
            ZleepShell  * sudoAccess = new ZleepShell(this);

            this->access = sudoAccess->checkSudoers();

            qDebug() << "sudoAccess:" << access;

            delete sudoAccess;

            if(access)
            {
            ui->actionStart->setEnabled(true);
            ui->actionConfigure->setVisible(false);
            }
        }


        // if no access ask for sudders config (use sigle shot timer)
        if(!config_msg)
        {
        config_msg=true;

        this->pTimer->stop();

        configure_sudoers();

        this->pTimer->start(1000);

        }
    }

    // if shedule started?
    if(ui->actionStop->isEnabled() && ui->comboBox->currentIndex() != 2)
    {
    // update progress bar
        int progress_max = ui->progressBar->maximum();

        if(progress_value<progress_max)
        {
        progress_value++;


            if(progress_value < (progress_max/100))
            {
            ui->progressBar->setValue((progress_max/100)+1);
            }
            else
            {
            ui->progressBar->setValue(progress_value);
            }


            if(progress_max > 60 && (progress_max-progress_value) == 60)
            {
                saveAllSetting();
                showTrayMessage("qZleep","sheduled shutdown after 60 seconds!",this->timeoutForShowTrayMessage);
            }

            //qDebug("%d/%d 1:%d",progress_value,progress_max,(progress_max/100));


        }

    }
}
Beispiel #9
0
void DlgJsRoboKey::showTrayMessage(const QString &title, const QString &body)
{
    QJSValue undefined;
    showTrayMessage(title, body, undefined);
}
Beispiel #10
0
DlgJsRoboKey::DlgJsRoboKey(QWidget *parent) :
    QDialog(parent, Qt::Window | Qt::WindowSystemMenuHint
            | Qt::WindowMinimizeButtonHint
            | Qt::WindowMaximizeButtonHint
            | Qt::WindowCloseButtonHint),
    ui(new Ui::DlgJsRoboKey),
    m_pjsrobokey(NULL), m_jsengine(NULL), m_mainScriptLoaded(false)
{
    ui->setupUi(this);
    ui->memoInstaScript->setSuppressCtrlEnter(true);
    connect(ui->memoInstaScript, SIGNAL(onCtrlEnter()), this, SLOT(on_btnInstaRun_clicked()));

    m_pjsrobokey = new JsRoboKey(this);

    JSEdit& editor = *ui->memoInstaScript;
    editor.setWindowTitle("Insta Run");
    editor.setFrameShape(JSEdit::NoFrame);
    editor.setWordWrapMode(QTextOption::NoWrap);
    editor.setTabStopWidth(4);
    //editor.resize(QApplication::desktop()->availableGeometry().size() / 2);
    QStringList keywords = editor.keywords();
    keywords << "const";
    keywords << "let";
    editor.setKeywords(keywords);

    // dark color scheme
    editor.setColor(JSEdit::Background,    QColor("#0C152B"));
    editor.setColor(JSEdit::Normal,        QColor("#FFFFFF"));
    editor.setColor(JSEdit::Comment,       QColor("#666666"));
    editor.setColor(JSEdit::Number,        QColor("#DBF76C"));
    editor.setColor(JSEdit::String,        QColor("#5ED363"));
    editor.setColor(JSEdit::Operator,      QColor("#FF7729"));
    editor.setColor(JSEdit::Identifier,    QColor("#FFFFFF"));
    editor.setColor(JSEdit::Keyword,       QColor("#FDE15D"));
    editor.setColor(JSEdit::BuiltIn,       QColor("#9CB6D4"));
    editor.setColor(JSEdit::Cursor,        QColor("#1E346B"));
    editor.setColor(JSEdit::Marker,        QColor("#DBF76C"));
    editor.setColor(JSEdit::BracketMatch,  QColor("#1AB0A6"));
    editor.setColor(JSEdit::BracketError,  QColor("#A82224"));
    editor.setColor(JSEdit::FoldIndicator, QColor("#555555"));

    createActions();
    createTrayIcon();

    connect(trayIcon, SIGNAL(messageClicked()), this, SLOT(on_trayMessageClicked()));
    connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
            this, SLOT(iconActivated(QSystemTrayIcon::ActivationReason)));

    setIcon(1);
    trayIcon->show();


    //initalize the v8 engine
    initialize();

    //Currently the tray icon ALWAYS loads, this is for safety, later on do we allow turning it off via command line argument?
    bool loadMainScriptFile = true;
    QStringList args = QApplication::arguments();
    for (int i = 1; i < args.length(); ++i){

        if (args[i] == "--hidetotray"){
            hide();
        }else if (args[i] == "--defaulteditor"){
            i++;
            if (i < args.length()){
                m_defaultEditor = args[i];
            }
            continue;
        }else if (args[i] == "--showtraymsg"){
            i++;
            if (i < args.length()){
                showTrayMessage("JSRoboKey Loaded", args[i]);
            }
            continue;
        }
        else if (QFile::exists(args[i])){
            //if the file exists, just load it
            bool scriptError = loadJSFile(args[i]);

            //TODO: if there was a script error, do we tell the user?

            //also do not load main script file
            loadMainScriptFile = false;

        }else{
            //TODO: not an existing file, is it something else like a command line option?
        }
    }//end looping through command line arguments

    if (loadMainScriptFile){
        loadMainScript();
    }

    //set the default editor for editing main file
#ifdef Q_OS_WIN32
    m_defaultEditor = "notepad";
#elif Q_OS_MAC
    m_defaultEditor = "TextEdit";
#else
    m_defaultEditor = "gedit";
#endif
    //TODO: the only REAL way to detect a valid editor is to spawn it and see if it returns false
}
Beispiel #11
0
void lmcTransferWindow::receiveMessage(MessageType type, QString* lpszUserId, XmlMessage* pMessage) {
    Q_UNUSED(type);
    Q_UNUSED(lpszUserId);
	
	int fileMode = Helper::indexOf(FileModeNames, FM_Max, pMessage->data(XN_MODE));
	int fileOp = Helper::indexOf(FileOpNames, FO_Max, pMessage->data(XN_FILEOP));
	QString id = pMessage->data(XN_FILEID);

	FileView* view = NULL;
    FileView::TransferMode transferMode = fileMode == FM_Send ? FileView::TM_Send : FileView::TM_Receive;
    int itemIndex = -1;
	QString trayMsg;

    switch(fileOp) {
    case FO_Decline:
        //	receiver has declined
        view = ui.lvTransferList->item(id, FileView::TM_Send);
        if(!view)
            return;
        itemIndex = ui.lvTransferList->itemIndex(id, FileView::TM_Send);
        view->state = FileView::TS_Decline;
        break;
    case FO_Cancel:
        view = ui.lvTransferList->item(id, transferMode);
        if(!view)
            return;
        itemIndex = ui.lvTransferList->itemIndex(id, transferMode);
        view->state = FileView::TS_Cancel;
        break;
    case FO_Progress:
        view = ui.lvTransferList->item(id, transferMode);
        if(!view)
            return;
        itemIndex = ui.lvTransferList->itemIndex(id, transferMode);
        updateProgress(view, pMessage->data(XN_FILESIZE).toLongLong());
        break;
    case FO_Error:
        view = ui.lvTransferList->item(id, transferMode);
        if(!view)
            return;
        itemIndex = ui.lvTransferList->itemIndex(id, transferMode);
        view->state = FileView::TS_Abort;
        break;
    case FO_Abort:
        view = ui.lvTransferList->item(id, transferMode);
        if(!view)
            return;
        itemIndex = ui.lvTransferList->itemIndex(id, transferMode);
        view->state = FileView::TS_Abort;
        break;
    case FO_Complete:
        if(fileMode == FM_Send) {
            view = ui.lvTransferList->item(id, FileView::TM_Send);
            if(!view)
                return;
            itemIndex = ui.lvTransferList->itemIndex(id, FileView::TM_Send);
            view->state = FileView::TS_Complete;
            if(isHidden() || !isActiveWindow()) {
                trayMsg = tr("'%1' has been sent to %2.");
                emit showTrayMessage(TM_Transfer, trayMsg.arg(view->fileName, view->userName),
                    tr("File Transfer Completed"), TMI_Info);
                pSoundPlayer->play(SE_FileDone);
            }
        } else {
            view = ui.lvTransferList->item(id, FileView::TM_Receive);
            if(!view)
                return;
            itemIndex = ui.lvTransferList->itemIndex(id, FileView::TM_Receive);
            view->filePath = QDir::fromNativeSeparators(pMessage->data(XN_FILEPATH));
            view->icon = getIcon(view->filePath);
            pactShowFolder->setEnabled(QFile::exists(view->filePath));
            view->state = FileView::TS_Complete;
            if(isHidden() || !isActiveWindow()) {
                trayMsg = tr("'%1' has been received from %2.");
                emit showTrayMessage(TM_Transfer, trayMsg.arg(view->fileName, view->userName),
                    tr("File Transfer Completed"), TMI_Info);
                pSoundPlayer->play(SE_FileDone);
            }
        }
        break;
    }

	ui.lvTransferList->itemChanged(itemIndex);

	FileView* current = ui.lvTransferList->currentItem();
	setButtonState(current->state);
}
Beispiel #12
0
/*this function update information about
 track in window. Load title and others information
 and cd picture
 */
void MainWindow::update() {
	if (lis != NULL) {
		if (newData()) {
			showTrayMessage();

			//load txt data
			ui->TerazPlyta->setText(
					"<font color=yellow>" + stringChange(lis->actual.disk)
							+ "</font>");

			ui->TerazRok->setText(
					"<font color=yellow>" + stringChange(lis->actual.year)
							+ "</font>");

			ui->TerazTytul->setText(
					"<font color=yellow>" + stringChange(lis->actual.title)
							+ "</font>");

			ui->TerazWykonawca->setText(
					"<font color=yellow>" + stringChange(lis->actual.artist)
							+ "</font>");

			ui->NastepnaWykonawca->setText(
					"<font color=yellow>" + stringChange(lis->next.artist)
							+ "</font>");

			ui->NastepnaPlyta->setText(
					"<font color=yellow>" + stringChange(lis->next.disk)
							+ "</font>");

			ui->NastepnaRok->setText(
					"<font color=yellow>" + stringChange(lis->next.year)
							+ "</font>");

			ui->NastepnaTytul->setText(
					"<font color=yellow>" + stringChange(lis->next.title)
							+ "</font>");

			//this loads played track picture
			//url picture depends aktualny->ipd length
			if (lis->actual.idp.length() > 4) {
				load->load(
						"http://doc.rmf.pl/media/img_muzyka/plyta/"
								+ lis->actual.idp[0] + lis->actual.idp[1] + "/"
								+ lis->actual.idp + ".jpg");
				qDebug() << ("http://doc.rmf.pl/media/img_muzyka/plyta/"
						+ lis->actual.idp[0] + lis->actual.idp[1] + "/"
						+ lis->actual.idp + ".jpg");
			} else if (lis->actual.idp.length() == 4) {
				load->load(
						"http://doc.rmf.pl/media/img_muzyka/plyta/"
								+ lis->actual.idp[0] + "/" + lis->actual.idp
								+ ".jpg");
				qDebug() << ("http://doc.rmf.pl/media/img_muzyka/plyta/"
						+ lis->actual.idp[0] + "/" + lis->actual.idp + ".jpg");
			} else {
				if (lis->actual.idp.length() > 0)
					load->load(
							"http://doc.rmf.pl/media/img_muzyka/plyta/0/"
									+ lis->actual.idp + ".jpg");
				else {
					image(new QPixmap(":/zaslepka.jpg"));
					//image(NULL);
				}

				qDebug() << ("http://doc.rmf.pl/media/img_muzyka/plyta/0/"
						+ lis->actual.idp + ".jpg");
			}

			//this do that same but for the next song
			if (lis->next.idp.length() > 4) {
				loadNext->load(
						"http://doc.rmf.pl/media/img_muzyka/plyta/"
								+ lis->next.idp[0] + lis->next.idp[1] + "/"
								+ lis->next.idp + ".jpg");
				qDebug() << ("http://doc.rmf.pl/media/img_muzyka/plyta/"
						+ lis->next.idp[0] + lis->next.idp[1] + "/"
						+ lis->next.idp + ".jpg");
			} else if (lis->next.idp.length() == 4) {
				loadNext->load(
						"http://doc.rmf.pl/media/img_muzyka/plyta/"
								+ lis->next.idp[0] + "/" + lis->next.idp
								+ ".jpg");
				qDebug() << ("http://doc.rmf.pl/media/img_muzyka/plyta/"
						+ lis->next.idp[0] + "/" + lis->next.idp + ".jpg");
			} else {
				if (lis->next.idp > 0)
					loadNext->load(
							"http://doc.rmf.pl/media/img_muzyka/plyta/0/"
									+ lis->next.idp + ".jpg");
				else {
					imageNext(new QPixmap(":/zaslepka.jpg"));
					//imageNext(NULL);
				}

				qDebug() << ("http://doc.rmf.pl/media/img_muzyka/plyta/0/"
						+ lis->next.idp + ".jpg");
			}
		}
	}
}
Beispiel #13
0
void WpaGui::processMsg(char *msg)
{
	char *pos = msg, *pos2;
	int priority = 2;

	if (*pos == '<') {
		/* skip priority */
		pos++;
		priority = atoi(pos);
		pos = strchr(pos, '>');
		if (pos)
			pos++;
		else
			pos = msg;
	}

	WpaMsg wm(pos, priority);
	if (eh)
		eh->addEvent(wm);
	if (peers)
		peers->event_notify(wm);
	msgs.append(wm);
	while (msgs.count() > 100)
		msgs.pop_front();

	/* Update last message with truncated version of the event */
	if (strncmp(pos, "CTRL-", 5) == 0) {
		pos2 = strchr(pos, str_match(pos, WPA_CTRL_REQ) ? ':' : ' ');
		if (pos2)
			pos2++;
		else
			pos2 = pos;
	} else
		pos2 = pos;
	QString lastmsg = pos2;
	lastmsg.truncate(40);
	textLastMessage->setText(lastmsg);

	pingsToStatusUpdate = 0;
	networkMayHaveChanged = true;

	if (str_match(pos, WPA_CTRL_REQ))
		processCtrlReq(pos + strlen(WPA_CTRL_REQ));
	else if (str_match(pos, WPA_EVENT_SCAN_RESULTS) && scanres)
		scanres->updateResults();
	else if (str_match(pos, WPA_EVENT_DISCONNECTED))
		showTrayMessage(QSystemTrayIcon::Information, 3,
				tr("Disconnected from network."));
	else if (str_match(pos, WPA_EVENT_CONNECTED)) {
		showTrayMessage(QSystemTrayIcon::Information, 3,
				tr("Connection to network established."));
		QTimer::singleShot(5 * 1000, this, SLOT(showTrayStatus()));
		stopWpsRun(true);
	} else if (str_match(pos, WPS_EVENT_AP_AVAILABLE_PBC)) {
		wpsStatusText->setText(tr("WPS AP in active PBC mode found"));
		if (textStatus->text() == "INACTIVE" ||
		    textStatus->text() == "DISCONNECTED")
			wpaguiTab->setCurrentWidget(wpsTab);
		wpsInstructions->setText(tr("Press the PBC button on the "
					    "screen to start registration"));
	} else if (str_match(pos, WPS_EVENT_AP_AVAILABLE_PIN)) {
		wpsStatusText->setText(tr("WPS AP with recently selected "
					  "registrar"));
		if (textStatus->text() == "INACTIVE" ||
		    textStatus->text() == "DISCONNECTED")
			wpaguiTab->setCurrentWidget(wpsTab);
	} else if (str_match(pos, WPS_EVENT_AP_AVAILABLE_AUTH)) {
		showTrayMessage(QSystemTrayIcon::Information, 3,
				"Wi-Fi Protected Setup (WPS) AP\n"
				"indicating this client is authorized.");
		wpsStatusText->setText("WPS AP indicating this client is "
				       "authorized");
		if (textStatus->text() == "INACTIVE" ||
		    textStatus->text() == "DISCONNECTED")
			wpaguiTab->setCurrentWidget(wpsTab);
	} else if (str_match(pos, WPS_EVENT_AP_AVAILABLE)) {
		wpsStatusText->setText(tr("WPS AP detected"));
	} else if (str_match(pos, WPS_EVENT_OVERLAP)) {
		wpsStatusText->setText(tr("PBC mode overlap detected"));
		wpsInstructions->setText(tr("More than one AP is currently in "
					    "active WPS PBC mode. Wait couple "
					    "of minutes and try again"));
		wpaguiTab->setCurrentWidget(wpsTab);
	} else if (str_match(pos, WPS_EVENT_CRED_RECEIVED)) {
		wpsStatusText->setText(tr("Network configuration received"));
		wpaguiTab->setCurrentWidget(wpsTab);
	} else if (str_match(pos, WPA_EVENT_EAP_METHOD)) {
		if (strstr(pos, "(WSC)"))
			wpsStatusText->setText(tr("Registration started"));
	} else if (str_match(pos, WPS_EVENT_M2D)) {
		wpsStatusText->setText(tr("Registrar does not yet know PIN"));
	} else if (str_match(pos, WPS_EVENT_FAIL)) {
		wpsStatusText->setText(tr("Registration failed"));
	} else if (str_match(pos, WPS_EVENT_SUCCESS)) {
		wpsStatusText->setText(tr("Registration succeeded"));
	}
}