当前位置: 首页>>代码示例>>C++>>正文


C++ http::Reply类代码示例

本文整理汇总了C++中cxxtools::http::Reply的典型用法代码示例。如果您正苦于以下问题:C++ Reply类的具体用法?C++ Reply怎么用?C++ Reply使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Reply类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


注:本文中的cxxtools::http::Reply类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。