mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-24 08:41:26 -04:00
webui: added chat
This commit is contained in:
parent
1939ea9f54
commit
a9ef48d133
14 changed files with 1621 additions and 44 deletions
|
@ -11,13 +11,15 @@ namespace resource_api
|
|||
// the type returned by dereferencing the iterator should have a stream operator for StreamBase
|
||||
// the stream operator must not add an element "id", this is done by the pagination handler
|
||||
template<class C>
|
||||
void handlePaginationRequest(Request& req, Response& resp, const C& data)
|
||||
void handlePaginationRequest(Request& req, Response& resp, C& data)
|
||||
{
|
||||
/*
|
||||
if(!req.isGet()){
|
||||
resp.mDebug << "unsupported method. only GET is allowed." << std::endl;
|
||||
resp.setFail();
|
||||
return;
|
||||
}
|
||||
*/
|
||||
if(data.begin() == data.end()){
|
||||
// set result type to list
|
||||
resp.mDataStream.getStreamToMember();
|
||||
|
@ -25,15 +27,16 @@ void handlePaginationRequest(Request& req, Response& resp, const C& data)
|
|||
return;
|
||||
}
|
||||
|
||||
std::string first;
|
||||
std::string begin_after;
|
||||
std::string last;
|
||||
req.mStream << makeKeyValueReference("first", first) << makeKeyValueReference("last", last);
|
||||
req.mStream << makeKeyValueReference("begin_after", begin_after) << makeKeyValueReference("last", last);
|
||||
|
||||
C::iterator it_first = data.begin();
|
||||
if(first != "begin")
|
||||
typename C::iterator it_first = data.begin();
|
||||
if(begin_after != "begin" && begin_after != "")
|
||||
{
|
||||
while(it_first != data.end() && id(*it_first) != first)
|
||||
while(it_first != data.end() && id(*it_first) != begin_after)
|
||||
it_first++;
|
||||
it_first++; // get after the specified element
|
||||
if(it_first == data.end())
|
||||
{
|
||||
resp.setFail("Error: first id did not match any element");
|
||||
|
@ -41,8 +44,8 @@ void handlePaginationRequest(Request& req, Response& resp, const C& data)
|
|||
}
|
||||
}
|
||||
|
||||
C::iterator it_last = data.begin();
|
||||
if(last == "end")
|
||||
typename C::iterator it_last = data.begin();
|
||||
if(last == "end" || last == "")
|
||||
{
|
||||
it_last = data.end();
|
||||
}
|
||||
|
@ -59,7 +62,7 @@ void handlePaginationRequest(Request& req, Response& resp, const C& data)
|
|||
}
|
||||
|
||||
int count = 0;
|
||||
for(C::iterator it = it_first; it != it_last; ++it)
|
||||
for(typename C::iterator it = it_first; it != it_last; ++it)
|
||||
{
|
||||
StreamBase& stream = resp.mDataStream.getStreamToMember();
|
||||
stream << *it;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue