void NovellVpnSettingWidget::readSecrets() { QStringMap secrets = d->setting->vpnSecrets(); kDebug() << "Value of" << NM_NOVELLVPN_KEY_CERT_PWD << secrets.value(QLatin1String(NM_NOVELLVPN_KEY_CERT_PWD)); d->ui.x509CertPass->setText(secrets.value(QLatin1String(NM_NOVELLVPN_KEY_CERT_PWD))); d->ui.leUserPass->setText(secrets.value(QLatin1String(NM_NOVELLVPN_KEY_USER_PWD))); d->ui.leGroupPass->setText(secrets.value(QLatin1String(NM_NOVELLVPN_KEY_GRP_PWD))); }
void MythFEXML::SendAction(HTTPRequest *pRequest) { QStringMap* map = &pRequest->m_mapParams; pRequest->m_eResponseType = ResponseTypeHTML; QString sText = map->value("action"); uint pcount = map->size(); VERBOSE(VB_UPNP, QString("UPNP Action: %1 (total %2 params)") .arg(sText).arg(pcount)); if (!IsValidAction(sText)) return; if (pcount > 1) { bool valid = false; QStringList args; if (ACTION_SCREENSHOT == sText && 3 == pcount) { args << map->value("width"); args << map->value("height"); valid = true; } else if (ACTION_HANDLEMEDIA == sText && 2 == pcount) { args << map->value("file"); valid = true; } if (valid) { MythEvent* me = new MythEvent(sText, args); qApp->postEvent(GetMythMainWindow(), me); return; } VERBOSE(VB_UPNP, QString("Failed to validate extra paramaters - ignoring")); } QKeyEvent* ke = new QKeyEvent(QEvent::KeyPress, 0, Qt::NoModifier, sText); qApp->postEvent(GetMythMainWindow(), (QEvent*)ke); }
void VpncSettingWidget::readSecrets() { Q_D(VpncSettingWidget); QStringMap secrets = d->setting->vpnSecrets(); Knm::Setting::secretsTypes userType; Knm::Setting::secretsTypes groupType; userType = (Knm::Setting::secretsTypes)d->setting->data().value(NM_VPNC_KEY_XAUTH_PASSWORD"-flags").toInt(); if (userType & Knm::Setting::AgentOwned || userType & Knm::Setting::None || !userType) { d->ui.leUserPassword->setText(secrets.value(QLatin1String(NM_VPNC_KEY_XAUTH_PASSWORD))); } fillOnePasswordCombo(d->ui.cboUserPassOptions, userType); groupType = (Knm::Setting::secretsTypes)d->setting->data().value(NM_VPNC_KEY_SECRET"-flags").toInt(); if (groupType & Knm::Setting::AgentOwned || groupType & Knm::Setting::None || !groupType) { d->ui.leGroupPassword->setText(secrets.value(QLatin1String(NM_VPNC_KEY_SECRET))); } fillOnePasswordCombo(d->ui.cboGroupPassOptions, groupType); }
void TabletServer::mainScreen(QTcpSocket *socket, const QStringList &path, const QStringMap &query) { Document * doc = mw->currentDocument(); if(!doc) { generic404(socket,path,query); return; } QStringList pathCopy = path; pathCopy.takeFirst(); // should be "tablet", but could be anything - /tablet/ is canonized for use in the tablet cache manifest for sfari QString control = pathCopy.isEmpty() ? "" : pathCopy.takeFirst().toLower(); //bool flag = pathCopy.isEmpty() ? 0 : pathCopy.takeFirst().toInt(); //qDebug() << "TabletServer::mainScreen(): control: "<<control; HttpUser *user = HttpUserUtil::instance()->currentUser(); if(control != "login") { if(!user) { QString from = QUrl::toPercentEncoding(toPathString(path,query).toAscii()).replace(" ", "+"); redirect(socket, "/tablet/login?from=" + from); return; } // I've decided to allow guests "view-only" access // else // if(user->level() == HttpUser::Guest) // { // Http_Send_Ok(socket) << "<html><head><title>Not Allowed</title></head><body><h1>Not Allowed</h1>Sorry, you're not allowed to access this site. (<a href='/tablet/login'>Login again</a>)</body></html"; // return; // } } if(control.isEmpty()) { SimpleTemplate tmpl("data/http/tablet.tmpl"); tmpl.param("user_name", user->user()); tmpl.param("user_level", (int)user->level()); tmpl.param("is_admin", user->level() == HttpUser::Admin); tmpl.param("is_user", user->level() == HttpUser::User); tmpl.param("is_guest", user->level() == HttpUser::Guest); // tmpl.param("list",outputGroupList); // // OutputControl * outputControl = mw->outputControl(liveId); // tmpl.param("black_toggled", outputControl->isBlackToggled()); // tmpl.param("clear_toggled", outputControl->isClearToggled()); // // SlideGroupViewControl *viewControl = mw->viewControl(liveId); // tmpl.param("qslide_toggled", viewControl->isQuickSlideToggled()); // // if(doc->filename().isEmpty()) // tmpl.param("docfile",tr("New File")); // else // tmpl.param("docfile",QFileInfo(doc->filename()).baseName()); // Http_Send_Ok(socket) << // "Content-Type: text/html\n\n" << // tmpl.toString(); QHttpResponseHeader header(QString("HTTP/1.0 200 OK")); header.setValue("Content-Type", "text/html"); respond(socket, header); QTextStream output(socket); output.setAutoDetectUnicode(true); output << tmpl.toString(); } else if(control == "login") { loginPage(socket, path, query, "/tablet/login"); } else if(control == "list") { QString filter = query["filter"]; // Can be empty // Don't allow non-admins to search because it would interfere with the main UI if(!filter.isEmpty() && user->level() < HttpUser::Admin) { Http_Send_500txt(socket, "Not Authorized"); return; } QString mode = query["mode"]; // Either "db" or "file" bool pollingFlag = query["poll"] == "true"; QString clientMD5 = query["md5"]; // the md5 of the list contents to use to check for changes if pollingFlag == true // Compile list of results matching mode (from db or from current sched) and the filter, and return as json string // TODO add button to search online //qDebug() << "TabletServer::mainScreen(): list: mode: "<<mode<<", filter: "<<filter; QVariantMap result; QVariantList resultList; bool moreResults = false; int listCutoffLimit = 10; // included in results even though only relevant to 'db' mode // Buffer for compiling MD5 hash QStringList md5sigList; if(mode == "db") { bool isChanged = true; if(pollingFlag) { int currentChangeSequence = m_songListModel->currentChangeSequence(); QString seqString = QString::number(currentChangeSequence); // md5sigList is used to generate the md5 to send back to the client md5sigList << seqString; QString seqMd5 = MD5::md5sum(md5sigList.join("")); isChanged = false; if(seqMd5 != clientMD5) isChanged = true; } // Only regen list if 'isChanged' - and isChanged is only set to 'false' if: // - Client is in polling mode // - Client MD5 matches the MD5 of current sequence number // We do this because generating the list makes a call to filter() // which can cause trouble if the filter string is empty and the user // in the DViz main UI is trying to search for something (which would NOT change // the sequence number above, but would change the filter) if(isChanged) { // List cutoff limit only relevant when searching/quering database. // Cutoff not honored or implemented for file schedule QString maxResults = query["max"]; if(!maxResults.isEmpty()) listCutoffLimit = maxResults.toInt(); if(listCutoffLimit < 1) listCutoffLimit = 1; m_songListModel->filter(filter); moreResults = m_songListModel->rowCount() > listCutoffLimit; int resultCount = qMin(listCutoffLimit, m_songListModel->rowCount()); for(int i=0; i<resultCount; i++) { SongRecord *song = m_songListModel->songAt(i); if(!song) { qDebug() << "TabletServer::mainScreen(): list: db: No song at index: "<<i; continue; } QVariantMap line; line["id"] = song->songId(); line["title"] = song->title(); line["text"] = song->text(); line["arr"] = song->defaultArrangement()->arrangement().join(", "); resultList << line; // We use the sequence md5 (above) for the md5 sig instead of the list contents now // md5sigList.append(QString::number(song->songId())); // md5sigList.append(song->title()); // md5sigList.append(song->text()); } } } else { // int liveId = AppSettings::taggedOutput("live")->id(); // SlideGroup *liveGroup = mw->outputInst(liveId)->slideGroup(); DocumentListModel * model = mw->documentListModel(); //uint secs = QDateTime::currentDateTime().toTime_t(); QString lowerFilter = filter.toLower(); for(int idx = 0; idx < model->rowCount(); idx++) { SlideGroup * group = model->groupAt(idx); SongSlideGroup *songGroup = dynamic_cast<SongSlideGroup*>(group); if(songGroup && ( songGroup->groupTitle().toLower().contains(lowerFilter) || songGroup->text().toLower().contains(lowerFilter))) { QVariantMap row; QVariant tooltip = model->data(model->index(group->groupNumber(),0), Qt::ToolTipRole); QString viewText = group->assumedName(); if(tooltip.isValid()) viewText = tooltip.toString(); row["id"] = idx; //songGroup->groupId(); row["title"] = viewText; row["text"] = songGroup->text(); row["arr"] = songGroup->arrangement().join(", "); row["mapping"] = genArrMapping(songGroup->text(), songGroup->arrangement()); resultList << row; md5sigList.append(QString::number(songGroup->groupId())); md5sigList.append(viewText); md5sigList.append(songGroup->text()); } // We don't limit the number of results in the document results moreResults = false; } } QString currentMD5 = MD5::md5sum(md5sigList.join("")); bool isChanged = true; if(pollingFlag && currentMD5 == clientMD5) isChanged = false; if(isChanged) { result["num"] = resultList.size(); result["list"] = QVariant(resultList); result["more"] = moreResults; result["cutoff"] = listCutoffLimit; } else result["nochange"] = true; result["md5"] = currentMD5; QString jsonString = m_toJson.serialize(result); //qDebug() << "TabletServer::mainScreen(): list: result: "<<result; //qDebug() << "TabletServer::mainScreen(): list: json: "<<jsonString; // Http_Send_Ok(socket) << // "Content-Type: application/json\n\n" << // jsonString; QHttpResponseHeader header(QString("HTTP/1.0 200 OK")); header.setValue("Content-Type", "application/json"); respond(socket, header); QTextStream output(socket); output.setAutoDetectUnicode(true); output << jsonString; } else if(control == "save_song") { if(user->level() < HttpUser::Admin) { Http_Send_500txt(socket, "Not Authorized"); return; } QString mode = query["mode"]; // Either "db" or "file" int itemid = query["itemid"].toInt(); // If mode is db, itemid is a songid, otherwise, it's a group index QString title = query["title"]; QString text = query["text"]; QString arrTxt = query["arr"]; QStringList newArrList = arrTxt.split(QRegExp("\\s*,\\s*")); SongRecord *song; if(mode == "file") { DocumentListModel * model = mw->documentListModel(); SlideGroup * group = model->groupAt(itemid); SongSlideGroup *songGroup = dynamic_cast<SongSlideGroup*>(group); // Update the document model songGroup->setArrangement(newArrList); songGroup->setGroupTitle(title); songGroup->setText(text); // automatically regenerates slides in document song = songGroup->song(); } else { song = SongRecord::retrieve(itemid); } if(!song) { Http_Send_404(socket) << "Invalid songid"; } song->setTitle(title); song->setText(text); SongArrangement *arr = song->defaultArrangement(); arr->setArrangement(newArrList); // Changes automatically committed to database QVariantMap result; result["mapping"] = genArrMapping(song->text(), arr->arrangement()); QString jsonString = m_toJson.serialize(result); QHttpResponseHeader header(QString("HTTP/1.0 200 OK")); header.setValue("Content-Type", "application/json"); respond(socket, header); QTextStream output(socket); output.setAutoDetectUnicode(true); output << jsonString; } else if(control == "add_song") { if(user->level() < HttpUser::Admin) { Http_Send_500txt(socket, "Not Authorized"); return; } int songid = query["songid"].toInt(); QVariantMap result; SongRecord *song = SongRecord::retrieve(songid); if(!song) { Http_Send_404(socket) << "Invalid songid"; } else { SlideGroup *group = mw->songBrowser()->createSlideGroup(song); group->setGroupNumber(mw->currentDocument()->numGroups()); mw->currentDocument()->addGroup(group); result["groupnum"] = group->groupNumber(); } QString jsonString = m_toJson.serialize(result); QHttpResponseHeader header(QString("HTTP/1.0 200 OK")); header.setValue("Content-Type", "application/json"); respond(socket, header); QTextStream output(socket); output.setAutoDetectUnicode(true); output << jsonString; } else if(control == "del_song") { if(user->level() < HttpUser::Admin) { Http_Send_500txt(socket, "Not Authorized"); return; } QString mode = query["mode"]; // Either "db" or "file" int itemid = query["itemid"].toInt(); if(mode == "file") { DocumentListModel * model = mw->documentListModel(); SlideGroup * group = model->groupAt(itemid); SongSlideGroup *songGroup = dynamic_cast<SongSlideGroup*>(group); if(!songGroup) { Http_Send_404(socket) << "Invalid songid"; } mw->currentDocument()->removeGroup(songGroup); } else { SongRecord *song = SongRecord::retrieve(itemid); if(!song) { Http_Send_404(socket) << "Invalid songid"; } SongRecord::deleteSong(song); } QVariantMap result; // Nothing to see here, move along. QString jsonString = m_toJson.serialize(result); QHttpResponseHeader header(QString("HTTP/1.0 200 OK")); header.setValue("Content-Type", "application/json"); respond(socket, header); QTextStream output(socket); output.setAutoDetectUnicode(true); output << jsonString; } else if(control == "show_slide") { if(user->level() < HttpUser::User) { Http_Send_500txt(socket, "Not Authorized"); return; } int groupIdx = query["group"].toInt(); Document * doc = mw->currentDocument(); if(!doc) { generic404(socket,path,query); return; } if(groupIdx < 0 || groupIdx >= doc->numGroups()) { generic404(socket,path,query); return; } DocumentListModel * docModel = mw->documentListModel(); SlideGroup *group = docModel->groupAt(groupIdx); if(!group) { generic404(socket,path,query); return; } int liveId = AppSettings::taggedOutput("live")->id(); SlideGroup *liveGroup = mw->outputInst(liveId)->slideGroup(); Slide * liveSlide = mw->outputInst(liveId)->slide(); //SlideGroupViewControl *viewControl = mw->viewControl(liveId); //Slide * liveSlide = viewControl->selectedSlide(); int idx = query.value("slide").toInt(); if(idx < 0 || idx > group->numSlides()) { generic404(socket,path,query); return; } Slide *slide = group->at(idx); if(liveGroup != group || liveSlide != slide) mw->setLiveGroup(group, ! slide ? liveSlide : slide); // prevent changing slides when loading the group page if group already live on different slide if(liveGroup == group && liveSlide != slide/* && nextPathElement != "icon"*/) { // this is JUST a change slide request mw->setLiveGroup(liveGroup,slide); // 204 = HTTP No Content, ("...[the browser] SHOULD NOT change its document view...") Http_Send_Response(socket,"HTTP/1.0 204 Changed Slide") << ""; // BlackBerry Internet Browser doesnt honor HTTP 204, so we have to use javascript to make it not change the current document return; } else Http_Send_Response(socket,"HTTP/1.0 204 No Change") << ""; } else if(control == "poll_live_slide") { if(user->level() < HttpUser::Guest) { Http_Send_500txt(socket, "Not Authorized"); return; } DocumentListModel * docModel = mw->documentListModel(); QVariantMap result; bool ok = true; int liveId = AppSettings::taggedOutput("live")->id(); SlideGroup *liveGroup = mw->outputInst(liveId)->slideGroup(); Slide *liveSlide = mw->outputInst(liveId)->slide(); if(!liveGroup) { ok = false; result["error"] = "NLG"; } // SlideGroupViewControl *viewControl = mw->viewControl(liveId); // Slide * liveSlide = viewControl->selectedSlide(); if(!liveSlide && ok) { ok = false; result["error"] = "NLS"; } if(ok) { int groupIdx = docModel->indexForGroup(liveGroup).row(); int slideIdx = liveGroup->indexOf(liveSlide); result["groupIdx"] = groupIdx; result["slideIdx"] = slideIdx; } QString jsonString = m_toJson.serialize(result); QHttpResponseHeader header(QString("HTTP/1.0 200 OK")); header.setValue("Content-Type", "application/json"); respond(socket, header); QTextStream output(socket); output.setAutoDetectUnicode(true); output << jsonString; } else { generic404(socket,path,query); } }
void VpncSettingWidget::readConfig() { Q_D(VpncSettingWidget); // General settings QStringMap dataMap = d->setting->data(); // gateway QString gateway = dataMap[NM_VPNC_KEY_GATEWAY]; if (!gateway.isEmpty()) { d->ui.leGateway->setText(gateway); } // username QString user = dataMap[NM_VPNC_KEY_XAUTH_USER]; if (!user.isEmpty()) { d->ui.leUserName->setText(user); } // group name QString group = dataMap[NM_VPNC_KEY_ID]; if (!group.isEmpty()) { d->ui.leGroupName->setText(group); } // hybrid auth if (dataMap[NM_VPNC_KEY_AUTHMODE] == QLatin1String("hybrid")) { d->ui.cbUseHybridAuth->setChecked(true); d->ui.leCaCertPath->setUrl(KUrl(dataMap[NM_VPNC_KEY_CA_FILE])); } // password storage type is set in readSecrets // Optional settings // domain QString domain = dataMap[NM_VPNC_KEY_DOMAIN]; if (!domain.isEmpty()) { d->ui.leDomain->setText(domain); } // encryption if (dataMap[NM_VPNC_KEY_SINGLE_DES] == QLatin1String("yes")) { d->ui.cboEncryptionMethod->setCurrentIndex(VpncSettingWidgetPrivate::EnumEncryptionMethod::Weak); } else if (dataMap[NM_VPNC_KEY_NO_ENCRYPTION] == QLatin1String("yes")) { d->ui.cboEncryptionMethod->setCurrentIndex(VpncSettingWidgetPrivate::EnumEncryptionMethod::None); } // nat traversal if (dataMap[NM_VPNC_KEY_NAT_TRAVERSAL_MODE] == NM_VPNC_NATT_MODE_NATT) d->ui.cboNatTraversal->setCurrentIndex(VpncSettingWidgetPrivate::EnumNatt::NattIfAvail); else if (dataMap[NM_VPNC_KEY_NAT_TRAVERSAL_MODE] == NM_VPNC_NATT_MODE_NATT_ALWAYS) d->ui.cboNatTraversal->setCurrentIndex(VpncSettingWidgetPrivate::EnumNatt::Force); else if (dataMap[NM_VPNC_KEY_NAT_TRAVERSAL_MODE] == NM_VPNC_NATT_MODE_CISCO) d->ui.cboNatTraversal->setCurrentIndex(VpncSettingWidgetPrivate::EnumNatt::CiscoUdp); else if (dataMap[NM_VPNC_KEY_NAT_TRAVERSAL_MODE] == NM_VPNC_NATT_MODE_NONE) d->ui.cboNatTraversal->setCurrentIndex(VpncSettingWidgetPrivate::EnumNatt::Disabled); // dead peer detection if (dataMap.contains(NM_VPNC_KEY_DPD_IDLE_TIMEOUT)) { uint dpdTimeout = dataMap.value(NM_VPNC_KEY_DPD_IDLE_TIMEOUT).toUInt(); if (dpdTimeout == 0) { d->ui.chkDeadPeerDetection->setChecked(false); d->dpdTimeout = dpdTimeout; } } // dh group if (dataMap.contains(NM_VPNC_KEY_DHGROUP)) { QString dhGroup = dataMap.value(NM_VPNC_KEY_DHGROUP); if (dhGroup == NM_VPNC_DHGROUP_DH1) { // DH Group 1 d->ui.cboDHGroup->setCurrentIndex(VpncSettingWidgetPrivate::EnumDh::Dh1); } else if (dhGroup == NM_VPNC_DHGROUP_DH2) { // DH Group 2 d->ui.cboDHGroup->setCurrentIndex(VpncSettingWidgetPrivate::EnumDh::Dh2); } else if (dhGroup == NM_VPNC_DHGROUP_DH5) { // DH Group 5 d->ui.cboDHGroup->setCurrentIndex(VpncSettingWidgetPrivate::EnumDh::Dh5); } } // Perfect Forward Secrecy if (dataMap.contains(NM_VPNC_KEY_PERFECT_FORWARD)) { QString forwardSecrecy = dataMap.value(NM_VPNC_KEY_PERFECT_FORWARD); if (forwardSecrecy == QLatin1String("nopfs")) { d->ui.cboPerfectForwardSecrecy->setCurrentIndex(VpncSettingWidgetPrivate::EnumPerfectForwardSecrecy::NoPfs); } else if (forwardSecrecy == QLatin1String("server")) { d->ui.cboPerfectForwardSecrecy->setCurrentIndex(VpncSettingWidgetPrivate::EnumPerfectForwardSecrecy::Server); } else if (forwardSecrecy == QLatin1String("dh1")) { d->ui.cboPerfectForwardSecrecy->setCurrentIndex(VpncSettingWidgetPrivate::EnumPerfectForwardSecrecy::Dh1); } else if (forwardSecrecy == QLatin1String("dh2")) { d->ui.cboPerfectForwardSecrecy->setCurrentIndex(VpncSettingWidgetPrivate::EnumPerfectForwardSecrecy::Dh2); } else if (forwardSecrecy == QLatin1String("dh5")) { d->ui.cboPerfectForwardSecrecy->setCurrentIndex(VpncSettingWidgetPrivate::EnumPerfectForwardSecrecy::Dh5); } } // Vendor if (dataMap.contains(NM_VPNC_KEY_VENDOR)) { QString vendor = dataMap.value(NM_VPNC_KEY_VENDOR); if (vendor == QLatin1String("cisco")) { d->ui.cboVendor->setCurrentIndex(VpncSettingWidgetPrivate::EnumVendor::Cisco); } else if (vendor == QLatin1String("netscreen")) { d->ui.cboVendor->setCurrentIndex(VpncSettingWidgetPrivate::EnumVendor::Netscreen); } } // Application Version if (dataMap.contains(NM_VPNC_KEY_APP_VERSION)) { d->ui.leApplicationVersion->setText(dataMap.value(NM_VPNC_KEY_APP_VERSION)); } // Local Port if (dataMap.contains(NM_VPNC_KEY_LOCAL_PORT)) { d->ui.spbLocalPort->setValue(dataMap.value(NM_VPNC_KEY_LOCAL_PORT).toInt()); } // Cisco UDP Encapsulation Port if (dataMap.contains(NM_VPNC_KEY_CISCO_UDP_ENCAPS_PORT)) { d->ui.spbCiscoUdpEncPort->setValue(dataMap.value(NM_VPNC_KEY_CISCO_UDP_ENCAPS_PORT).toInt()); } }