/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011-2015 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see .
**************************************************************************/
#ifndef CLIENT_ONLY
#include "action_header.h"
#include "../server_status.h"
void getLastActs(Helper &helper, JSON::Object &ret, std::vector clientids);
ACTION_IMPL(progress)
{
Helper helper(tid, &GET, &PARAMS);
JSON::Object ret;
std::vector clientids;
std::string rights=helper.getRights("progress");
if(rights!="none" && rights!="all")
{
std::vector s_cid;
Tokenize(rights, s_cid, ",");
for(size_t i=0;iid==SESSION_ID_INVALID) return;
if(session!=NULL && (rights=="all" || !clientids.empty()) )
{
if(GET.find("stop_clientid")!=GET.end() &&
GET.find("stop_id")!=GET.end())
{
int stop_clientid=watoi(GET["stop_clientid"]);
int stop_id=watoi(GET["stop_id"]);
std::string stop_rights=helper.getRights("stop_backup");
bool stop_ok=false;
if(stop_rights=="all")
{
stop_ok=true;
}
else
{
std::vector s_cid;
Tokenize(stop_rights, s_cid, ",");
for(size_t i=0;iPrepare("SELECT name FROM clients WHERE id=?");
q_get_name->Bind(stop_clientid);
db_results res=q_get_name->Read();
if(!res.empty())
{
ServerStatus::stopProcess(res[0]["name"], stop_id, true);
}
}
}
JSON::Array pg;
std::vector clients=ServerStatus::getStatus();
for(size_t i=0;i(clients[i].processes[j].action)));
obj.set("pcdone", JSON::Value(clients[i].processes[j].pcdone));
obj.set("queue", JSON::Value(clients[i].processes[j].prepare_hashqueuesize+
clients[i].processes[j].hashqueuesize));
obj.set("id", JSON::Value(clients[i].processes[j].id));
pg.add(obj);
}
}
}
ret.set("progress", pg);
}
else
{
ret.set("error", JSON::Value(1));
}
clientids.clear();
rights=helper.getRights("lastacts");
if(rights!="none" && rights!="all")
{
std::vector s_cid;
Tokenize(rights, s_cid, ",");
for(size_t i=0;i