static void sml() { int i; for (i = 0; i < 1; i++) { render("Line: %05d %s", i, "aaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbccccccccccccccccccddddddd<br/>\r\n"); } render("{ when: %Ld, uri: '%s', query: '%s' }\r\n", mprGetTicks(), getUri(), getQuery()); }
MediaRendererDevice::MediaRendererDevice(const std::string& udn, const std::string& descriptionXml, int32_t advertiseIntervalInSeconds, const std::string& audioOutput, const std::string& audioDevice, upnp::WebServer& webServer) : m_Playback(PlaybackFactory::create("Custom", "Doozy", audioOutput, audioDevice, m_Queue)) , m_RootDevice(udn, descriptionXml, advertiseIntervalInSeconds) , m_ConnectionManager(m_RootDevice, *this) , m_RenderingControl(m_RootDevice, *this) , m_AVTransport(m_RootDevice, *this) , m_WebServer(webServer) { m_Playback->PlaybackStateChanged.connect([this] (PlaybackState state) { setTransportVariable(0, AVTransport::Variable::TransportState, AVTransport::toString(PlaybackStateToTransportState(state))); }, this); m_Playback->AvailableActionsChanged.connect([this] (const std::set<PlaybackAction>& actions) { setTransportVariable(0, AVTransport::Variable::CurrentTransportActions, toString(actions)); }, this); m_Playback->ProgressChanged.connect([this] (double progress) { setTransportVariable(0, AVTransport::Variable::RelativeTimePosition, durationToString(progress)); }, this); m_Playback->NewTrackStarted.connect([this] (const std::shared_ptr<ITrack>& track) { auto item = std::dynamic_pointer_cast<PlayQueueItem>(track); assert(item); addAlbumArtToWebServer(item); setTransportVariable(0, AVTransport::Variable::CurrentTrackURI, item->getUri()); setTransportVariable(0, AVTransport::Variable::CurrentTrackMetaData, item->getMetadataString()); setTransportVariable(0, AVTransport::Variable::AVTransportURI, item->getAVTransportUri()); setTransportVariable(0, AVTransport::Variable::NextAVTransportURI, m_Queue.getNextUri()); setTransportVariable(0, AVTransport::Variable::CurrentTrackDuration, durationToString(m_Playback->getDuration())); setTransportVariable(0, AVTransport::Variable::NumberOfTracks, std::to_string(m_Queue.getNumberOfTracks())); }, this); }
static void huge() { int i; // This will emit ~762K (over the item limit) for (i = 0; i < 10000; i++) { render("Line: %05d %s", i, "aaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbccccccccccccccccccddddddd<br/>\r\n"); } render("{ when: %Ld, uri: '%s', query: '%s' }\r\n", mprGetTicks(), getUri(), getQuery()); }
static void manual() { if (smatch(getQuery(), "send")) { setHeader("X-SendCache", "true"); finalize(); } else if (!espRenderCached(getConn())) { render("{ when: %Ld, uri: '%s', query: '%s' }\r\n", mprGetTicks(), getUri(), getQuery()); } }
// フレームの更新処理 void update() { openni::VideoFrameRef colorFrame; openni::VideoFrameRef depthFrame; // 更新されたフレームを取得する colorStream.readFrame( &colorFrame ); depthStream.readFrame( &depthFrame ); // フレームのデータを表示できる形に変換する colorImage = showColorStream( colorFrame ); depthImage = showDepthStream( depthFrame ); // フレームのデータを表示する cv::imshow( "Color Stream " + getUri(), colorImage ); cv::imshow( "Depth Stream " + getUri(), depthImage ); }
KReferDialog::KReferDialog( KPhoneView * phv,int kcwn,QString uPrefix,QWidget *parent, const char *name ) : QDialog( parent, name, true ) { phoneView=phv; kcwNumber= kcwn; userPrefix=uPrefix; phoneBook = 0; QVBox *vbox = new QVBox( this ); vbox->setMargin( 3 ); vbox->setSpacing( 3 ); QVBoxLayout *vboxl = new QVBoxLayout( this, 5 ); vboxl->addWidget( vbox ); (void) new QLabel( tr("Refer-to URI:"), vbox ); touri = new QLineEdit( vbox ); touri->setMinimumWidth( fontMetrics().maxWidth() * 20 ); QHBoxLayout *buttonBox; buttonBox = new QHBoxLayout( vboxl, 6 ); loadUri = new QPushButton( "", this ); QIconSet icon; icon.setPixmap(SHARE_DIR "/icons/phonebook.png", QIconSet::Automatic ); loadUri->setIconSet( icon ); loadUri->setFixedWidth( loadUri->fontMetrics().maxWidth() * 2 ); buttonBox->addWidget( loadUri ); helpPushButton = new QPushButton( this, tr("help button") ); helpPushButton->setText( tr("&help...") ); helpPushButton->setEnabled( FALSE ); buttonBox->addWidget( helpPushButton ); QSpacerItem *spacer = new QSpacerItem( 0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum ); buttonBox->addItem( spacer ); okPushButton = new QPushButton( this, tr("ok button") ); okPushButton->setText( "OK" ); okPushButton->setDefault( TRUE ); buttonBox->addWidget( okPushButton ); cancelPushButton = new QPushButton( this,tr( "cancel button") ); cancelPushButton->setText( tr("Cancel") ); cancelPushButton->setAccel( Key_Escape ); buttonBox->addWidget( cancelPushButton ); connect( loadUri, SIGNAL( clicked() ), this, SLOT( getUri() ) ); connect( okPushButton, SIGNAL( clicked() ), this, SLOT( slotOk() ) ); connect( cancelPushButton, SIGNAL( clicked() ), this, SLOT( slotCancel() ) ); }
/* Common controller run for every action invoked This tests if the user is logged in and authenticated. Access to certain pages are permitted without authentication so the user can login */ static void commonController(HttpConn *conn) { cchar *uri; if (!httpLoggedIn(conn)) { uri = getUri(); if (sstarts(uri, "/public/") || smatch(uri, "/user/login") || smatch(uri, "/user/logout")) { return; } httpError(conn, HTTP_CODE_UNAUTHORIZED, "Access Denied. Login required"); } }
const char* HttpParser::getQueryString() const { const char* pos = getUri(); while( *pos ) { if ( *pos == '?' ) { pos++; break; } pos++; } return pos; }
void QQmlAndroidImageView::setImageURI(const QUrl &uri) { if (m_uri != uri) { m_uri = uri; if (isValid()) { QAndroidJniObject v = instance(); QAndroidJniObject u = getUri(); QtQmlAndroid::callFunction([=]() { v.callMethod<void>("setImageURI", "(Landroid/net/Uri;)V", u.object()); }); } emit imageURIChanged(); } }
bool ImagePyramidContent::readMetadata() { try { TiffPyramidReader reader{getUri()}; setDimensions(reader.getImageSize()); _transparent = reader.hasAlphaChannel(); } catch (const std::exception& e) { put_log(LOG_DEBUG, LOG_TIFF, e.what()); return false; } return true; }
void QQmlAndroidImageView::onInflate(QAndroidJniObject &instance) { QQmlAndroidView::onInflate(instance); if (m_uri.isValid()) instance.callMethod<void>("setImageURI", "(Landroid/net/Uri;)V", getUri().object()); if (m_resource > 0) instance.callMethod<void>("setImageResource", "(I)V", m_resource); if (!m_tint.isNull()) { QAndroidJniObject tint = QAndroidJniObject::callStaticObjectMethod("android/content/res/ColorStateList", "valueOf", "(I)Landroid/content/res/ColorStateList;", m_tint); instance.callMethod<void>("setImageTintList", "(Landroid/content/res/ColorStateList;)v", tint.object()); } }
/* Common base run for every request. */ static void commonBase(HttpStream *stream) { cchar *uri; if (!httpIsAuthenticated(stream)) { /* Access to certain pages are permitted without authentication so the user can login and logout. */ uri = getUri(); if (sstarts(uri, "/public/") || smatch(uri, "/user/login") || smatch(uri, "/user/logout")) { return; } feedback("error", "Access Denied. Login required."); redirect("/public/login.esp"); } }
int EmulateSp::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QObject::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { if (_id < 10) qt_static_metacall(this, _c, _id, _a); _id -= 10; } #ifndef QT_NO_PROPERTIES else if (_c == QMetaObject::ReadProperty) { void *_v = _a[0]; switch (_id) { case 0: *reinterpret_cast< QString*>(_v) = appVersion(); break; case 1: *reinterpret_cast< QString*>(_v) = getUri(); break; case 2: *reinterpret_cast< QString*>(_v) = getText(); break; } _id -= 3; } else if (_c == QMetaObject::WriteProperty) { void *_v = _a[0]; switch (_id) { case 0: setAppVersion(*reinterpret_cast< QString*>(_v)); break; case 1: setUri(*reinterpret_cast< QString*>(_v)); break; case 2: setText(*reinterpret_cast< QString*>(_v)); break; } _id -= 3; } else if (_c == QMetaObject::ResetProperty) { _id -= 3; } else if (_c == QMetaObject::QueryPropertyDesignable) { _id -= 3; } else if (_c == QMetaObject::QueryPropertyScriptable) { _id -= 3; } else if (_c == QMetaObject::QueryPropertyStored) { _id -= 3; } else if (_c == QMetaObject::QueryPropertyEditable) { _id -= 3; } else if (_c == QMetaObject::QueryPropertyUser) { _id -= 3; } #endif // QT_NO_PROPERTIES return _id; }
void Image::download() { if (m_status != down_undone) return; std::string file; if (m_filename == "") file = (m_dir + getFile(m_url)); else file = m_dir + m_filename + getExtension(m_url); FILE* f = fopen(file.c_str(), "rb"); if (f != NULL) //Cover was alreayd downloaded { m_status = down_done; } if (m_status == down_done) return; m_status = down_started; sf::Http web(getHost(m_url)); sf::Http::Request request(getUri(m_url)); std::cout<<"Downloading "<<m_url<<"\n"; sf::Http::Response response = web.sendRequest(request); sf::Http::Response::Status status = response.getStatus(); if (status == sf::Http::Response::Ok) { f = fopen(file.c_str(), "wb"); fwrite(response.getBody().c_str(), sizeof(char), response.getBody().size(), f); fclose(f); m_status = down_done; } else { std::cerr<<"Download fail, error: "<<status<<"\n"; m_status = down_fail; } }
void Chapter::download() { sf::Http web(Manga::MangaHost); sf::Http::Request request(m_uri); sf::Http::Response response = web.sendRequest(request); sf::Http::Response::Status status = response.getStatus(); if (status == sf::Http::Response::Ok) { std::string body(response.getBody()); //Erase all of the \n eraseN(body); if (testing) { char html_file[300]; sprintf(html_file, "test/chapter_%u_page1.html", m_num_chapter); FILE* f = fopen(html_file, "w"); fwrite(body.c_str(), sizeof(char), body.size(), f); fclose(f); std::cout<<"Html page output to file: "<<html_file<<"\n"; } sscanf(getParse(body, Manga::parseChapterPages).c_str(), "%u", &m_pages); if (testing) std::cout<<"number of pages for chapter "<<m_num_chapter<<" parsed: "<<m_pages<<"\n"; //Clean images for (std::vector<Image*>::iterator it(m_images.begin()); it != m_images.end(); ++it) delete *it; m_images.resize(m_pages); for (unsigned int i(0); i<m_images.size(); ++i) m_images[i] = new Image; //we ad the fisrt image m_images[0]->setUrl(getParse(body, Manga::parsePageImg)); m_images[0]->setDir(m_dir); char filename[300]; sprintf(filename, "%s %u-1", m_manga->m_name.c_str(), m_num_chapter); m_images[0]->setFileName(filename); if (!testing) { m_images[0]->thDownload(); std::cout<<"Image 1/"<<m_images.size()<<" found.\n"; } std::string next_page(getParse(body, Manga::parsePageNext)); switch (Manga::mangaPath) { case URL_uri: break; case URL_absolute: next_page = getUri(next_page); break; case URL_relative: next_page = getWorkingDirectory(m_uri) + next_page; break; default: break; } if (testing) std::cout<<"Image 1 parsed: "<<m_images[0]->getUrl()<<"\nNext page parsed (Uri format): "<<next_page<<"\n"; for (unsigned int i(1); i<m_images.size(); ++i) { request.setUri(next_page); response = web.sendRequest(request); status = response.getStatus(); if (status == sf::Http::Response::Ok) { std::string body(response.getBody()); //Erase all of the \n eraseN(body); if (testing && i == 1) { char html_file[300]; sprintf(html_file, "test/chapter_%u_other_page.html", m_num_chapter); FILE* f = fopen(html_file, "w"); fwrite(body.c_str(), sizeof(char), body.size(), f); fclose(f); std::cout<<"Html page output to file: "<<html_file<<"\n"; } m_images[i]->setUrl(getParse(body, Manga::parsePageImg)); m_images[i]->setDir(m_dir); sprintf(filename, "%s %u-%u", m_manga->m_name.c_str(), m_num_chapter, i+1); m_images[i]->setFileName(filename); if (!testing) { m_images[i]->thDownload(); std::cout<<"Image "<<i+1<<"/"<<m_images.size()<<" found.\n"; } next_page = getParse(body, Manga::parsePageNext); switch (Manga::mangaPath) { case URL_uri: break; case URL_absolute: next_page = getUri(next_page); break; case URL_relative: next_page = getWorkingDirectory(m_uri) + next_page; break; default: break; } if (testing) std::cout<<"Image "<<i+1<<" parsed: "<<m_images[i]->getUrl()<<"\nNext page parsed: "<<next_page<<"\n"; } else std::cout<<"Error getting page: "<<status<<"\n"; } //std::cout<<"img:"<<getParse(body, Manga::parsePageImg)<<" next page: "<<getParse(body, Manga::parsePageNext)<<"\n"; //Download imgs //for (int i=0; i<1; ++i) m_images[i]->thDownload(); } else std::cout<<"Error checking chapter: "<<status<<"\n"; }
int verify163Music(const struct redirect_conf *pstRedirectConf, char *url, char *ip, char *other) { char *p_cookie; //case3544: ST_163MUSIC_CFG* pstC = pstRedirectConf->other; char *uri = NULL; assert(pstC != NULL); /* //case3544 p_range = strstr(other,"Range:"); if(p_range) goto fail403; */ if(!getUri(url,&uri)) goto fail301; DEBUG("uri = %s\n",uri); int len = getCookie(other,&p_cookie); if (0 == len) { DEBUG("no cookie,goto fail\n"); goto fail301; } int deny_or_not = 1; int i = 0 ; // char *uri = strchr(strstr(url,"http://")+7,'/')+1; char *cookie = (char *)malloc(len); memset(cookie,0,len); if(NULL == cookie) { goto fail301; } else { memcpy(cookie,p_cookie,len-1); } DEBUG("cookie [%s],len[%d]\n",cookie,len); for(i=0 ; i < pstC->cookie_count;i++) { // if(0 == strcmp(cookie,pstC->cookie_value[i])) if(strstr(cookie,pstC->cookie_value[i])) { deny_or_not = 0; break; } } if(cookie) { free(cookie); cookie = NULL; } DEBUG("deny or not [%d],replace_url[%s],uri[%s]\n", deny_or_not,pstC->replace_url,uri); if(!deny_or_not) { printf("%s %s %s", url, ip, other); DEBUG("OUTPUT: %s %s %s", url, ip, other); fflush(stdout); } else { printf("301:%s?r=%s %s %s", pstC->replace_url ,uri,ip, other); DEBUG("VERIFY FAILED OUTPUT:301:%s?r=%s %s %s", pstC->replace_url, uri, ip, other); fflush(stdout); } return 1; fail301: if(NULL == uri) { printf("301:%s?r= %s %s", pstC->replace_url ,ip, other); DEBUG("VERIFY failed output:301:%s %s %s", pstC->replace_url, ip, other); } else { printf("301:%s?r=%s %s %s", pstC->replace_url ,uri,ip, other); DEBUG("VERIFY failed output:301:%s?r=%s %s %s", pstC->replace_url,uri, ip, other); } fflush(stdout); return 0; /* fail403: printf("403:%s %s %s", url, ip, other); DEBUG("OUTPUT:403: %s %s %s", url, ip, other); fflush(stdout); return 0; */ }
// This is configured for caching by API below static void api() { render("{ when: %Ld, uri: '%s', query: '%s' }\r\n", mprGetTicks(), getUri(), getQuery()); }
static void update() { cchar *data = sfmt("{ when: %Ld, uri: '%s', query: '%s' }\r\n", mprGetTicks(), getUri(), getQuery()); espUpdateCache(getConn(), "/cache/manual", data, 86400); render("done"); }
void PixelStreamUpdater::setNextFrame(deflect::server::FramePtr frame) { assert(frame->uri == getUri()); _swapSyncFrame.update(frame); }
bool CleverURI::operator==(const CleverURI& uri) const { if((uri.getUri()==getUri())&&(uri.getType()==getType())) return true; return false; }
void ThingsMaintenance::onGetChildInfoForUpdate(const HeaderOptions& headerOptions, const OCRepresentation& rep, const int eCode, std::string mnt) { if (eCode != OC_STACK_OK) { std::cout << "onGet Response error: " << eCode << std::endl; getCallback(mnt)(headerOptions, rep, eCode); return ; } std::cout << "GET request was successful" << std::endl; std::cout << "\tResource URI: " << rep.getUri() << std::endl; std::vector < OCRepresentation > children = rep.getChildren(); for (auto oit = children.begin(); oit != children.end(); ++oit) { std::cout << "\t\tChild Resource URI: " << oit->getUri() << std::endl; } // Get information by using maintenance name(mnt) std::shared_ptr < OCResource > resource = getResource(mnt); std::string actionstring = mnt; std::string uri = getUriByMaintenanceName(mnt); std::string attrKey = mnt; if (uri == "") return; if (resource) { // In this nest, we create a new action set of which name is the dignostics name. // Required information consists of a host address, URI, attribute key, and // attribute value. ActionSet *newActionSet = new ActionSet(); newActionSet->actionsetName = mnt; for (auto oit = children.begin(); oit != children.end(); ++oit) { Action *newAction = new Action(); // oit->getUri() includes a host address as well as URI. // We should split these to each other and only use the host address to create // a child resource's URI. Note that the collection resource and its child // resource are located in same host. newAction->target = getHostFromURI(oit->getUri()) + uri; Capability *newCapability = new Capability(); newCapability->capability = attrKey; newCapability->status = getUpdateVal(mnt); newAction->listOfCapability.push_back(newCapability); newActionSet->listOfAction.push_back(newAction); } // Request to create a new action set by using the above actionSet g_groupmanager->addActionSet(resource, newActionSet, std::function< void(const HeaderOptions& headerOptions, const OCRepresentation& rep, const int eCode) >( std::bind(&ThingsMaintenance::onCreateActionSet, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, mnt))); delete(newActionSet); } }
/** Computes the uri from an uri (ie add a prefix if any). */ std::string getUriByKey (const std::string& key) { return getUri (getInput()->getStr(key)); }
void Manga::downloadInformation() { sf::Http web(MangaHost); sf::Http::Request request(m_uri); sf::Http::Response response = web.sendRequest(request); sf::Http::Response::Status status = response.getStatus(); if (status == sf::Http::Response::Ok) { //std::cout<<"Link is valid\n"; std::string body(response.getBody()); //Erase all of the \n eraseN(body); if (testing) { if (!directoryExists("test")) createDirectory("test"); FILE* f = fopen("test/body.html", "w"); fwrite(body.c_str(), sizeof(char), body.size(), f); fclose(f); std::cout<<"Html page output to file: test/body.html\n"; } //Start parsing m_name = getParse(body, parseMangaName); //Supress all white spaces at the end of the name!! for (int i(m_name.size()-1); i>=0; --i) { if (m_name[i] == ' ') m_name.resize(i); else break; } std::string last_chapter(getParse(body, parseChapters)); sscanf(last_chapter.c_str(), "%u", &m_num_chapters); if (testing) std::cout<<"Name parsed: "<<m_name<<".\nChapter count parsed: "<<last_chapter<<"\n"; if (!testing) { if (!directoryExists("mangas")) createDirectory("mangas"); if (!directoryExists("mangas/" + m_name)) createDirectory("mangas/" + m_name); } if (m_cover != NULL) delete m_cover; m_cover = new Image(getParse(body, parseCover), "mangas/" + m_name + "/"); if (!testing) m_cover->thDownload(); else std::cout<<"Cover parsed: "<<m_cover->getUrl()<<"\n"; m_loaded = true; //Fill list of chapters sf::Clock clock; size_t first(0); std::string chapter_web_list(getParse(body, parseChapterList)); //erase all the \n!! eraseN(chapter_web_list); if (testing) { FILE* f = fopen("test/chapter_list.html", "w"); fwrite(chapter_web_list.c_str(), sizeof(char), chapter_web_list.size(), f); fclose(f); std::cout<<"Html page output to file: test/chapter_list.html\n"; } unsigned int chapter_i(1); while(true) { first = chapter_web_list.find(parseChapterListElement.begin[0], first); if (first == chapter_web_list.npos) break; else first += parseChapterListElement.begin[0].size(); std::string chapter_url, chapter_name(getParse(chapter_web_list.substr(first), Manga::parseChapterListName)); switch (Manga::chapterPath) { case URL_uri: chapter_url = getParse(chapter_web_list.substr(first), parseChapterListUri); break; case URL_absolute: //std::cout<<getParse(chapter_web_list.substr(first), parseChapterListUri)<<" tachan!\n"; chapter_url = getUri(getParse(chapter_web_list.substr(first), parseChapterListUri)); break; case URL_relative: chapter_url = getWorkingDirectory(m_uri) + getParse(chapter_web_list.substr(first), parseChapterListUri); break; default: break; } m_chapters.push_back(Chapter(chapter_url, this, chapter_i, chapter_name)); //std::cout<<"Added chapter: "<<m_chapters.back()<<"\n"; ++chapter_i; } if (Manga::chapterListReversed) // reverse the chapter list { m_chapters.reverse(); chapter_i = 1; for (std::list<Chapter>::iterator it(m_chapters.begin()); it != m_chapters.end(); ++it) { it->setChapter(chapter_i); ++chapter_i; } } if (testing) { std::cout<<m_chapters.size()<<" chapters were parsed\n"; for (std::list<Chapter>::iterator it(m_chapters.begin()); it != m_chapters.end(); ++it) std::cout<<"Chapter "<<it->m_num_chapter<<" parsed: "<<it->m_name<<" at "<<it->m_uri<<"\n"; } //std::cout<<"Chapter list created in: "<<clock.getElapsedTime().asSeconds()<<" sec\n"; } else std::cout<<"Error downloading manga info: "<<status<<"\n"; }