本文整理汇总了C++中cxxtools::http::Reply类的典型用法代码示例。如果您正苦于以下问题:C++ Reply类的具体用法?C++ Reply怎么用?C++ Reply使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Reply类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: deleteRecording
void RecordingsResponder::deleteRecording(ostream& out, cxxtools::http::Request& request, cxxtools::http::Reply& reply)
{
QueryHandler q("/recordings", request);
cRecording* delRecording = getRecordingByRequestWrite(q);
string syncId = q.getOptionAsString("syncId");
if ( delRecording == NULL ) {
reply.httpReturn(404, "Recording not found!");
return;
}
esyslog("restfulapi: delete recording %s", delRecording->FileName());
if ( delRecording->Delete() ) {
if (syncId != "") {
SyncMap* syncMap = new SyncMap(q, true);
syncMap->erase(StringExtension::toString(delRecording->FileName()));
}
#if APIVERSNUM > 20300
LOCK_RECORDINGS_WRITE;
cRecordings& recordings = *Recordings;
#else
cRecordings& recordings = Recordings;
#endif
recordings.DelByName(delRecording->FileName());
reply.httpReturn(200, "Recording deleted!");
return;
}
reply.httpReturn(500, "Recording could not be deleted!");
}
开发者ID:yavdr,项目名称:vdr-plugin-restfulapi,代码行数:31,代码来源:recordings.cpp
示例2: reply
void RemoteResponder::reply(ostream& out, cxxtools::http::Request& request, cxxtools::http::Reply& reply)
{
QueryHandler::addHeader(reply);
if (request.method() != "POST") {
reply.httpReturn(403, "Only POST method is support by the remote control");
return;
}
if ( (int)request.url().find("/remote/switch") != -1 ) {
QueryHandler q("/remote/switch", request);
cChannel* channel = VdrExtension::getChannel(q.getParamAsString(0));
if ( channel == NULL ) {
reply.httpReturn(404, "Channel-Id is not valid.");
/*} else if ( !Channels.SwitchTo( channel->Number() ) ) {
reply.httpReturn(404, "Couldn't switch to channel.");
}*/
} else {
TaskScheduler::get()->SwitchableChannel(channel->GetChannelID());
}
return;
}
QueryHandler q("/remote", request);
string key = q.getParamAsString(0);
if (key.length() == 0) {
reply.httpReturn(404, "Please add a key to the parameter list, see API-file for more details.");
return;
}
if (!keyPairList->hitKey(key.c_str())) {
reply.httpReturn(404, "Remote Control does not support the requested key.");
}
}
开发者ID:Saman-VDR,项目名称:vdr-plugin-restfulapi,代码行数:35,代码来源:remote.cpp
示例3: rewindRecording
void RecordingsResponder::rewindRecording(std::ostream& out, cxxtools::http::Request& request, cxxtools::http::Reply& reply)
{
QueryHandler q("/recordings/rewind", request);
#if APIVERSNUM > 20300
LOCK_RECORDINGS_READ;
const cRecordings& recordings = *Recordings;
#else
cThreadLock RecordingsLock(&Recordings);
cRecordings& recordings = Recordings;
#endif
const cRecording* recording = NULL;
string recording_file = q.getBodyAsString("file");
if (recording_file.length() > 0)
recording = recordings.GetByName(recording_file.c_str());
else {
int recording_number = q.getParamAsInt(0);
if (recording_number < 0 || recording_number >= recordings.Count())
reply.httpReturn(404, "Wrong recording number!");
else
recording = recordings.Get(recording_number);
}
if (recording != NULL) {
TaskScheduler::get()->SetRewind(true);
TaskScheduler::get()->SwitchableRecording(recording);
} else {
reply.httpReturn(404, "Wrong recording name or number!");
}
}
开发者ID:yavdr,项目名称:vdr-plugin-restfulapi,代码行数:30,代码来源:recordings.cpp
示例4: showCutterStatus
void RecordingsResponder::showCutterStatus(ostream& out, cxxtools::http::Request& request, cxxtools::http::Reply& reply)
{
QueryHandler q("/recordings/cut", request);
StreamExtension s(&out);
bool active = cCutter::Active();
if (q.isFormat(".html")) {
reply.addHeader("Content-Type", "text/html; charset=utf-8");
s.writeHtmlHeader("HtmlCutterStatus");
s.write((active ? "True" : "False"));
s.write("</body></html>");
} else if (q.isFormat(".json")) {
reply.addHeader("Content-Type", "application/json; charset=utf-8");
cxxtools::JsonSerializer serializer(out);
serializer.serialize(active, "active");
serializer.finish();
} else if (q.isFormat(".xml")) {
reply.addHeader("Content-Type", "text/xml; charset=utf-8");
s.write("<cutter xmlns=\"http://www.domain.org/restfulapi/2011/cutter-xml\">\n");
s.write(cString::sprintf(" <param name=\"active\">%s</param>\n", (active ? "true" : "false")));
s.write("</cutter>");
} else {
reply.httpReturn(502, "Only the following formats are supported: .xml, .json and .html");
}
}
开发者ID:flensrocker,项目名称:vdr-plugin-restfulapi,代码行数:26,代码来源:recordings.cpp
示例5: saveMarks
void RecordingsResponder::saveMarks(ostream& out, cxxtools::http::Request& request, cxxtools::http::Reply& reply)
{
QueryHandler q("/recordings/marks", request);
int recording = q.getParamAsInt(0);
JsonArray* jsonArray = q.getBodyAsArray("marks");
if (jsonArray == NULL) {
reply.httpReturn(503, "Marks in HTTP-Body are missing.");
}
if (recording < 0 && recording >= Recordings.Count()) {
reply.httpReturn(504, "Recording number missing or invalid.");
}
vector< string > marks;
for(int i=0;i<jsonArray->CountItem();i++) {
JsonBase* jsonBase = jsonArray->GetItem(i);
if (jsonBase->IsBasicValue()) {
JsonBasicValue* jsonBasicValue = (JsonBasicValue*)jsonBase;
if (jsonBasicValue->IsString()) {
marks.push_back(jsonBasicValue->ValueAsString());
}
}
}
VdrMarks::get()->saveMarks(Recordings.Get(recording), marks);
}
开发者ID:flensrocker,项目名称:vdr-plugin-restfulapi,代码行数:28,代码来源:recordings.cpp
示例6: replyEditedFileName
void RecordingsResponder::replyEditedFileName(ostream& out, cxxtools::http::Request& request, cxxtools::http::Reply& reply) {
QueryHandler q("/recordings/editedfile", request);
const cRecording* recording = getRecordingByRequest(q);
if (recording == NULL) {
reply.httpReturn(404, "Requested recording not found!");
return;
}
RecordingList* recordingList = getRecordingList(out, q, reply);
if (recordingList == NULL) {
return;
}
#if APIVERSNUM > 20300
LOCK_RECORDINGS_READ;
const cRecordings& recordings = *Recordings;
#else
cRecordings& recordings = Recordings;
#endif
const cRecording* editedFile = recordings.GetByName(cCutter::EditedFileName(recording->FileName()));
if (editedFile == NULL) {
reply.httpReturn(404, "Requested edited file not found!");
return;
}
recordingList->init();
recordingList->addRecording(editedFile, editedFile->Index(), NULL, "");
recordingList->setTotal(recordings.Count());
recordingList->finish();
delete recordingList;
};
开发者ID:yavdr,项目名称:vdr-plugin-restfulapi,代码行数:34,代码来源:recordings.cpp
示例7: deleteTimer
void TimersResponder::deleteTimer(ostream& out, cxxtools::http::Request& request, cxxtools::http::Reply& reply)
{
QueryHandler q("/timers", request);
if ( Timers.BeingEdited() ) {
reply.httpReturn(502, "Timers are being edited - try again later");
return;
}
TimerValues v;
cTimer* timer = v.ConvertTimer(q.getParamAsString(0));
if ( timer == NULL) {
reply.httpReturn(404, "Timer id invalid!");
} else {
if ( timer->Recording() ) {
timer->Skip();
cRecordControls::Process(time(NULL));
}
Timers.Del(timer);
Timers.SetModified();
reply.httpReturn(200, "Timer deleted.");
}
}
开发者ID:illyah,项目名称:vdr-plugin-restfulapi,代码行数:25,代码来源:timers.cpp
示例8: reply
void SearchTimersResponder::reply(ostream& out, cxxtools::http::Request& request, cxxtools::http::Reply& reply)
{
QueryHandler::addHeader(reply);
cPlugin* plugin = cPluginManager::GetPlugin("epgsearch");
if (plugin == NULL) {
reply.httpReturn(403, "Epgsearch isn't installed!");
return;
}
if ((int)request.url().find("/searchtimers/search/") == 0 ) {
replySearch(out, request, reply);
} else {
if (request.method() == "GET") {
replyShow(out, request, reply);
} else if (request.method() == "POST") {
replyCreate(out, request, reply);
} else if (request.method() == "DELETE") {
replyDelete(out, request, reply);
} else if (request.method() == "OPTIONS") {
return;
} else {
reply.httpReturn(404, "The searchtimer-service does only support the following methods: GET, POST and DELETE.");
}
}
}
开发者ID:Saman-VDR,项目名称:vdr-plugin-restfulapi,代码行数:25,代码来源:searchtimers.cpp
示例9: reply
void RemoteResponder::reply(ostream& out, cxxtools::http::Request& request, cxxtools::http::Reply& reply)
{
QueryHandler::addHeader(reply);
if ( request.method() == "OPTIONS" ) {
reply.addHeader("Allow", "POST");
reply.httpReturn(200, "OK");
return;
}
if (request.method() != "POST") {
reply.httpReturn(403, "Only POST method is support by the remote control");
return;
}
if ( (int)request.url().find("/remote/switch") != -1 ) {
QueryHandler q("/remote/switch", request);
const cChannel* channel = VdrExtension::getChannel(q.getParamAsString(0));
if ( channel == NULL ) {
reply.httpReturn(404, "Channel-Id is not valid.");
} else {
TaskScheduler::get()->SwitchableChannel(channel->GetChannelID());
}
return;
}
if (!keyPairList->hitKey(request, reply)) {
reply.httpReturn(404, "Remote Control does not support the requested key.");
}
}
开发者ID:hannemann,项目名称:vdr-plugin-restfulapi,代码行数:31,代码来源:remote.cpp
示例10: replyImage
void ChannelsResponder::replyImage(std::ostream& out, cxxtools::http::Request& request, cxxtools::http::Reply& reply)
{
StreamExtension se(&out);
QueryHandler q("/channels/image/", request);
std::string channelid = q.getParamAsString(0);
cChannel* channel = VdrExtension::getChannel(channelid);
std::string imageFolder = Settings::get()->ChannelLogoDirectory() + (std::string)"/";
if (channel == NULL) {
reply.httpReturn(502, "Channel not found!");
return;
}
std::string imageName = FileCaches::get()->searchChannelLogo(channel);
if (imageName.length() == 0 ) {
reply.httpReturn(502, "No image found!");
return;
}
std::string absolute_path = imageFolder + imageName;
std::string contenttype = (std::string)"image/" + imageName.substr( imageName.find_last_of('.') + 1 );
if ( se.writeBinary(absolute_path) ) {
reply.addHeader("Content-Type", contenttype.c_str());
} else {
reply.httpReturn(502, "Binary Output failed");
}
}
开发者ID:sja,项目名称:vdr-plugin-restfulapi,代码行数:29,代码来源:channels.cpp
示例11: replyDelete
void SearchTimersResponder::replyDelete(ostream& out, cxxtools::http::Request& request, cxxtools::http::Reply& reply)
{
QueryHandler q("/searchtimers", request);
vdrlive::SearchTimers searchTimers;
string id = q.getParamAsString(0);
bool result = searchTimers.Delete(id);
if (!result)
reply.httpReturn(408, "Deleting searchtimer failed!");
else
reply.httpReturn(200, "Searchtimer deleted.");
}
开发者ID:Saman-VDR,项目名称:vdr-plugin-restfulapi,代码行数:12,代码来源:searchtimers.cpp
示例12: cutRecording
void RecordingsResponder::cutRecording(ostream& out, cxxtools::http::Request& request, cxxtools::http::Reply& reply)
{
QueryHandler q("/recordings/cut", request);
int rec_number = q.getParamAsInt(0);
if (rec_number >= 0 && rec_number < Recordings.Count()) {
cRecording* recording = Recordings.Get(rec_number);
if (cCutter::Active()) {
reply.httpReturn(504, "VDR Cutter currently busy.");
} else {
cCutter::Start(recording->FileName());
}
return;
}
reply.httpReturn(503, "Cutting recordings failed.");
}
开发者ID:flensrocker,项目名称:vdr-plugin-restfulapi,代码行数:15,代码来源:recordings.cpp
示例13: playRecording
void RecordingsResponder::playRecording(std::ostream& out, cxxtools::http::Request& request, cxxtools::http::Reply& reply)
{
QueryHandler q("/recordings/play", request);
int recording_number = q.getParamAsInt(0);
if ( recording_number < 0 || recording_number >= Recordings.Count() ) {
reply.httpReturn(404, "Wrong recording number!");
} else {
cRecording* recording = Recordings.Get(recording_number);
if ( recording != NULL ) {
TaskScheduler::get()->SwitchableRecording(recording);
} else {
reply.httpReturn(404, "Wrong recording number!");
}
}
}
开发者ID:flensrocker,项目名称:vdr-plugin-restfulapi,代码行数:15,代码来源:recordings.cpp
示例14: reply
void RecordingsResponder::reply(std::ostream& out, cxxtools::http::Request& request, cxxtools::http::Reply& reply)
{
QueryHandler::addHeader(reply);
bool found = false;
if ((int)request.url().find("/recordings/cut") == 0 ) {
if ( request.method() == "GET" ) {
showCutterStatus(out, request, reply);
} else if (request.method() == "POST") {
cutRecording(out, request, reply);
} else {
reply.httpReturn(501, "Only GET and POST methods are supported by the /recordings/cut service.");
}
found = true;
}
else if ((int)request.url().find("/recordings/marks") == 0 ) {
if ( request.method() == "DELETE" ) {
deleteMarks(out, request, reply);
} else if (request.method() == "POST" ) {
saveMarks(out, request, reply);
} else {
reply.httpReturn(501, "Only DELETE and POST methods are supported by the /recordings/marks service.");
}
found = true;
}
// original /recordings service
else if ((int) request.url().find("/recordings") == 0 ) {
if ( request.method() == "GET" ) {
showRecordings(out, request, reply);
found = true;
} else if (request.method() == "DELETE" ) {
deleteRecording(out, request,reply);
found = true;
} else {
reply.httpReturn(501, "Only GET and DELETE methods are supported by the /recordings service.");
}
found = true;
}
if (!found) {
reply.httpReturn(403, "Service not found");
}
}
开发者ID:sja,项目名称:vdr-plugin-restfulapi,代码行数:45,代码来源:recordings.cpp
示例15: rewindRecording
void RecordingsResponder::rewindRecording(std::ostream& out, cxxtools::http::Request& request, cxxtools::http::Reply& reply)
{
QueryHandler q("/recordings/play", request);
int recording_number = q.getParamAsInt(0);
if ( recording_number < 0 || recording_number >= Recordings.Count() ) {
reply.httpReturn(404, "Wrong recording number!");
} else {
cRecording* recording = Recordings.Get(recording_number);
if ( recording != NULL ) {
cDevice::PrimaryDevice()->StopReplay(); // must do this first to be able to rewind the currently replayed recording
cResumeFile ResumeFile(recording->FileName(), recording->IsPesRecording());
ResumeFile.Delete();
TaskScheduler::get()->SwitchableRecording(recording);
} else {
reply.httpReturn(404, "Wrong recording number!");
}
}
}
开发者ID:flensrocker,项目名称:vdr-plugin-restfulapi,代码行数:18,代码来源:recordings.cpp
示例16: showTimers
void TimersResponder::showTimers(ostream& out, cxxtools::http::Request& request, cxxtools::http::Reply& reply)
{
QueryHandler q("/timers", request);
TimerList* timerList;
Timers.SetModified();
if ( q.isFormat(".json") ) {
reply.addHeader("Content-Type", "application/json; charset=utf-8");
timerList = (TimerList*)new JsonTimerList(&out);
} else if ( q.isFormat(".html") ) {
reply.addHeader("Content-Type", "text/html; charset=utf-8");
timerList = (TimerList*)new HtmlTimerList(&out);
} else if ( q.isFormat(".xml") ) {
reply.addHeader("Content-Type", "text/xml; charset=utf-8");
timerList = (TimerList*)new XmlTimerList(&out);
} else {
reply.httpReturn(404, "Resources are not available for the selected format. (Use: .json, .html or .xml)");
return;
}
int start_filter = q.getOptionAsInt("start");
int limit_filter = q.getOptionAsInt("limit");
string timer_id = q.getParamAsString(0);
if ( start_filter >= 0 && limit_filter >= 1 ) {
timerList->activateLimit(start_filter, limit_filter);
}
timerList->init();
vector< cTimer* > timers = VdrExtension::SortedTimers();
for (int i=0;i<(int)timers.size();i++)
{
if ( VdrExtension::getTimerID(timers[i]) == timer_id || timer_id.length() == 0 ) {
timerList->addTimer(timers[i]);
}
}
timerList->setTotal((int)timers.size());
timerList->finish();
delete timerList;
}
开发者ID:illyah,项目名称:vdr-plugin-restfulapi,代码行数:44,代码来源:timers.cpp
示例17: showRecordings
void RecordingsResponder::showRecordings(ostream& out, cxxtools::http::Request& request, cxxtools::http::Reply& reply)
{
QueryHandler q("/recordings", request);
RecordingList* recordingList;
bool read_marks = q.getOptionAsString("marks") == "true";
if ( q.isFormat(".json") ) {
reply.addHeader("Content-Type", "application/json; charset=utf-8");
recordingList = (RecordingList*)new JsonRecordingList(&out, read_marks);
} else if ( q.isFormat(".html") ) {
reply.addHeader("Content-Type", "text/html; charset=utf-8");
recordingList = (RecordingList*)new HtmlRecordingList(&out, read_marks);
} else if ( q.isFormat(".xml") ) {
reply.addHeader("Content-Type", "text/xml; charset=utf-8");
recordingList = (RecordingList*)new XmlRecordingList(&out, read_marks);
} else {
reply.httpReturn(404, "Resources are not available for the selected format. (Use: .json or .html)");
return;
}
int start_filter = q.getOptionAsInt("start");
int limit_filter = q.getOptionAsInt("limit");
int requested_item = q.getParamAsInt(0);
if ( start_filter >= 0 && limit_filter >= 1 ) {
recordingList->activateLimit(start_filter, limit_filter);
}
recordingList->init();
cRecording* recording = NULL;
for (int i = 0; i < Recordings.Count();i++) {
if ( requested_item == i || requested_item < 0 ) {
recording = Recordings.Get(i);
recordingList->addRecording(recording, i);
}
}
recordingList->setTotal(Recordings.Count());
recordingList->finish();
delete recordingList;
}
开发者ID:flensrocker,项目名称:vdr-plugin-restfulapi,代码行数:43,代码来源:recordings.cpp
示例18: replyImage
void EventsResponder::replyImage(ostream& out, cxxtools::http::Request& request, cxxtools::http::Reply& reply)
{
QueryHandler q("/events/image", request);
if ( request.method() != "GET") {
reply.httpReturn(403, "To retrieve information use the GET method!");
return;
}
StreamExtension se(&out);
int eventid = q.getParamAsInt(0);
int number = q.getParamAsInt(1);
double timediff = -1;
vector< string > images;
FileCaches::get()->searchEventImages(eventid, images);
if (number < 0 || number >= (int)images.size()) {
reply.httpReturn(404, "Could not find image because of invalid image number!");
return;
}
string image = images[number];
string type = image.substr(image.find_last_of(".")+1);
string contenttype = (string)"image/" + type;
string path = Settings::get()->EpgImageDirectory() + (string)"/" + image;
if (request.hasHeader("If-Modified-Since")) {
timediff = difftime(FileExtension::get()->getModifiedTime(path), FileExtension::get()->getModifiedSinceTime(request));
}
if (timediff > 0.0 || timediff < 0.0) {
if ( se.writeBinary(path) ) {
reply.addHeader("Content-Type", contenttype.c_str());
FileExtension::get()->addModifiedHeader(path, reply);
} else {
reply.httpReturn(404, "Could not find image!");
}
} else {
reply.httpReturn(304, "Not-Modified");
}
}
开发者ID:hannemann,项目名称:vdr-plugin-restfulapi,代码行数:42,代码来源:events.cpp
示例19: deleteMarks
void RecordingsResponder::deleteMarks(ostream& out, cxxtools::http::Request& request, cxxtools::http::Reply& reply)
{
QueryHandler q("/recordings/marks", request);
const cRecording* recording = getRecordingByRequest(q);
if ( recording != NULL ) {
if (VdrMarks::get()->deleteMarks(recording)) {
return;
}
}
reply.httpReturn(503, "Deleting marks failed.");
}
开发者ID:yavdr,项目名称:vdr-plugin-restfulapi,代码行数:11,代码来源:recordings.cpp
示例20: replySearch
void SearchTimersResponder::replySearch(ostream& out, cxxtools::http::Request& request, cxxtools::http::Reply& reply)
{
QueryHandler q("/searchtimers/search", request);
vdrlive::SearchResults searchResults;
int id = q.getParamAsInt(0);
EventList* eventList;
if ( q.isFormat(".json") ) {
reply.addHeader("Content-Type", "application/json; charset=utf-8");
eventList = (EventList*)new JsonEventList(&out);
} else if ( q.isFormat(".html") ) {
reply.addHeader("Content-Type", "text/html; charset=utf-8");
eventList = (EventList*)new HtmlEventList(&out);
} else if ( q.isFormat(".xml") ) {
reply.addHeader("Content-Type", "text/xml; charset=utf-8");
eventList = (EventList*)new XmlEventList(&out);
} else {
reply.httpReturn(403, "Resources are not available for the selected format. (Use: .json, .xml or .html)");
return;
}
searchResults.GetByID(id);
int start_filter = q.getOptionAsInt("start");
int limit_filter = q.getOptionAsInt("limit");
if ( start_filter >= 0 && limit_filter >= 1 )
eventList->activateLimit(start_filter, limit_filter);
eventList->init();
int total = 0;
for (vdrlive::SearchResults::iterator item = searchResults.begin(); item != searchResults.end(); ++item) {
eventList->addEvent((cEvent*)item->GetEvent());
total++;
}
eventList->setTotal(total);
eventList->finish();
delete eventList;
}
开发者ID:Saman-VDR,项目名称:vdr-plugin-restfulapi,代码行数:41,代码来源:searchtimers.cpp
注:本文中的cxxtools::http::Reply类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论