1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727
|
/***************************************************************************
* *
* Copyright 2010 Eugene Petrov <dhamp@ya.ru> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#pragma once
#include <cassert>
#include <stdexcept>
#include <iostream>
#include <xmlrpc-c/base.hpp>
#include <xmlrpc-c/registry.hpp>
#include <xmlrpc-c/server_abyss.hpp>
#include "utility.h"
#include "ServerManager.h"
using namespace std;
xmlrpc_c::registry xmlrpcRegistry;
xmlrpc_c::serverAbyss * server;
class magnetAddMethod : public xmlrpc_c::method {
public:
magnetAddMethod() {
this->_signature = "i:ss";
this->_help = "Adds a magnet link to the queue. Params: magnet link, download directory; returns: 0 on success, non-zero otherwise";
}
void
execute(xmlrpc_c::paramList const& paramList,
xmlrpc_c::value * const retvalP) {
string const smagnet(paramList.getString(0));
string const sddir(paramList.getString(1));
paramList.verifyEnd(2);
string name, tth;
int64_t size;
bool ok = splitMagnet(smagnet, name, size, tth);
if (isVerbose) std::cout << "splitMagnet: \n tth: " << tth << "\n size: " << size << "\n name: " << name << std::endl;
if (ok && ServerThread::getInstance()->addInQueue(sddir, name, size, tth))
*retvalP = xmlrpc_c::value_int(0);
else
*retvalP = xmlrpc_c::value_int(1);
}
};
class stopDaemonMethod : public xmlrpc_c::method {
public:
stopDaemonMethod() {
this->_signature = "s:";
this->_help = "(DEPRECATED) Stops the daemon. Params: none; returns: deprecation warning";
}
void
execute(xmlrpc_c::paramList const& paramList,
xmlrpc_c::value * const retvalP) {
*retvalP = xmlrpc_c::value_string("This method is deprecated. Please use system.shutdown instead.");
bServerTerminated = true;
}
};
class hubAddMethod : public xmlrpc_c::method {
public:
hubAddMethod() {
this->_signature = "i:ss";
this->_help = "Adds a new hub and connects to it. Params: hub URL, encoding; returns: 0";
}
void
execute(xmlrpc_c::paramList const& paramList,
xmlrpc_c::value * const retvalP) {
string const shub(paramList.getString(0));
string const senc(paramList.getString(1));
paramList.verifyEnd(2);
ServerThread::getInstance()->connectClient(shub, senc);
*retvalP = xmlrpc_c::value_int(0);
}
};
class hubDelMethod : public xmlrpc_c::method {
public:
hubDelMethod() {
this->_signature = "i:s";
this->_help = "Disconnects from a hub. Params: hub URL; returns: 0";
}
void
execute(xmlrpc_c::paramList const& paramList,
xmlrpc_c::value * const retvalP) {
string const shub(paramList.getString(0));
paramList.verifyEnd(1);
ServerThread::getInstance()->disconnectClient(shub);
*retvalP = xmlrpc_c::value_int(0);
}
};
class hubSayMethod : public xmlrpc_c::method {
public:
hubSayMethod() {
this->_signature = "i:ss";
this->_help = "Sends a message on a hub. Params: hub URL, message; returns: 0 on success, non-zero otherwise";
}
void
execute(xmlrpc_c::paramList const& paramList,
xmlrpc_c::value * const retvalP) {
string const shub(paramList.getString(0));
string const smess(paramList.getString(1));
paramList.verifyEnd(2);
if (ServerThread::getInstance()->findHubInConnectedClients(shub)) {
ServerThread::getInstance()->sendMessage(shub, smess);
*retvalP = xmlrpc_c::value_int(0);
} else
*retvalP = xmlrpc_c::value_int(1);
}
};
class hubSayPrivateMethod : public xmlrpc_c::method {
public:
hubSayPrivateMethod() {
this->_signature = "s:sss";
this->_help = "Sends a private message on a hub. Params: hub URL, nick, message; returns: error string";
}
void
execute(xmlrpc_c::paramList const& paramList,
xmlrpc_c::value * const retvalP) {
string const shub(paramList.getString(0));
string const snick(paramList.getString(1));
string const smess(paramList.getString(2));
paramList.verifyEnd(3);
if (ServerThread::getInstance()->sendPrivateMessage(shub, snick, smess))
*retvalP = xmlrpc_c::value_int(0);
else
*retvalP = xmlrpc_c::value_int(1);
}
};
class listHubsMethod : public xmlrpc_c::method {
public:
listHubsMethod() {
this->_signature = "s:s";
this->_help = "Returns a list of connected hubs. Params: separator";
}
void
execute(xmlrpc_c::paramList const& paramList,
xmlrpc_c::value * const retvalP) {
string const sseparator(paramList.getString(0));
paramList.verifyEnd(1); string listhubs;
ServerThread::getInstance()->listConnectedClients(listhubs, sseparator);
*retvalP = xmlrpc_c::value_string(listhubs);
}
};
class showVersionMethod : public xmlrpc_c::method {
public:
showVersionMethod() {
this->_signature = "s:";
this->_help = "Returns full client version. Params: none";
}
void
execute(xmlrpc_c::paramList const& paramList,
xmlrpc_c::value * const retvalP) {
*retvalP = xmlrpc_c::value_string(eiskaltdcppVersionString);
}
};
class showRatioMethod : public xmlrpc_c::method {
public:
showRatioMethod() {
this->_signature = "s:";
this->_help = "Returns upload/download ratio and absolute upload and download. "
"Params: none; returns: \"ratio: X (uploads: Y, downloads: Z)\"";
}
void
execute(xmlrpc_c::paramList const& paramList,
xmlrpc_c::value * const retvalP) {
auto up = SETTING(TOTAL_UPLOAD);
auto down = SETTING(TOTAL_DOWNLOAD);
auto ratio = (down > 0) ? up / down : 0;
string upload = Util::formatBytes(up);
string download = Util::formatBytes(down);
map<string, xmlrpc_c::value> tmp_struct_in;
tmp_struct_in["ratio"] = xmlrpc_c::value_string(Util::toString(ratio));
tmp_struct_in["up"] = xmlrpc_c::value_string(upload);
tmp_struct_in["down"] = xmlrpc_c::value_string(download);
tmp_struct_in["up_bytes"] = xmlrpc_c::value_string(Util::toString(up));
tmp_struct_in["down_bytes"] = xmlrpc_c::value_string(Util::toString(down));
xmlrpc_c::value_struct const tmp_struct_out(tmp_struct_in);
*retvalP = tmp_struct_out;
}
};
class addDirInShareMethod : public xmlrpc_c::method {
public:
addDirInShareMethod() {
this->_signature = "s:ss";
this->_help = "Adds a directory to the share. Params: directory, virtual name; returns: error string";
}
void
execute(xmlrpc_c::paramList const& paramList,
xmlrpc_c::value * const retvalP) {
string const sdirectory(paramList.getString(0));
string const svirtname(paramList.getString(1));
paramList.verifyEnd(2);
try {
if (ServerThread::getInstance()->addDirInShare(sdirectory, svirtname))
*retvalP = xmlrpc_c::value_string("Directory added to share");
else
*retvalP = xmlrpc_c::value_string("Directory doesn't exist");
} catch (const ShareException& e) {
*retvalP = xmlrpc_c::value_string(e.getError());
}
}
};
class renameDirInShareMethod : public xmlrpc_c::method {
public:
renameDirInShareMethod() {
this->_signature = "s:ss";
this->_help = "Renames a directory in the share. Params: directory, new virtual name; returns: error string";
}
void
execute(xmlrpc_c::paramList const& paramList,
xmlrpc_c::value * const retvalP) {
string const sdirectory(paramList.getString(0));
string const svirtname(paramList.getString(1));
paramList.verifyEnd(2);
try {
if (ServerThread::getInstance()->renameDirInShare(sdirectory, svirtname))
*retvalP = xmlrpc_c::value_string("Directory has been renamed");
else
*retvalP = xmlrpc_c::value_string("Directory not found");
} catch (const ShareException& e) {
*retvalP = xmlrpc_c::value_string(e.getError());
}
}
};
class delDirFromShareMethod : public xmlrpc_c::method {
public:
delDirFromShareMethod() {
this->_signature = "i:s";
this->_help = "Deletes a directory from the share. Params: virtual name of directory; returns: 0 on success, non-zero otherwise";
}
void
execute(xmlrpc_c::paramList const& paramList,
xmlrpc_c::value * const retvalP) {
string const sdirectory(paramList.getString(0));
paramList.verifyEnd(1);
if (ServerThread::getInstance()->delDirFromShare(sdirectory))
*retvalP = xmlrpc_c::value_int(0);
else
*retvalP = xmlrpc_c::value_int(1);
}
};
class listShareMethod : public xmlrpc_c::method {
public:
listShareMethod() {
this->_signature = "s:s";
this->_help = "Returns a list of shared directories. Params: separator";
}
void
execute(xmlrpc_c::paramList const& paramList,
xmlrpc_c::value * const retvalP) {
string const sseparator(paramList.getString(0));
paramList.verifyEnd(1);
string listshare;
ServerThread::getInstance()->listShare(listshare, sseparator);
*retvalP = xmlrpc_c::value_string(listshare);
}
};
class refreshShareMethod : public xmlrpc_c::method {
public:
refreshShareMethod() {
this->_signature = "i:";
this->_help = "Refreshes the share. Params: none; returns: 0";
}
void
execute(xmlrpc_c::paramList const& paramList,
xmlrpc_c::value * const retvalP) {
ShareManager::getInstance()->setDirty();
ShareManager::getInstance()->refresh(true);
*retvalP = xmlrpc_c::value_int(0);
}
};
class getFileListMethod : public xmlrpc_c::method {
public:
getFileListMethod() {
this->_signature = "s:ss";
this->_help = "Adds the file list of a user to the download queue. Params: hub URL, nick; returns: error string";
}
void
execute(xmlrpc_c::paramList const& paramList,
xmlrpc_c::value * const retvalP) {
string const shub(paramList.getString(0));
string const snick(paramList.getString(1));
paramList.verifyEnd(2);
if (ServerThread::getInstance()->getFileList(shub, snick, false))
*retvalP = xmlrpc_c::value_int(0);
else
*retvalP = xmlrpc_c::value_int(1);
}
};
class getChatPubMethod : public xmlrpc_c::method {
public:
getChatPubMethod() {
this->_signature = "s:ss";
this->_help = "Returns a list of unread public chat messages on a hub. Params: hub URL, separator";
}
void
execute(xmlrpc_c::paramList const& paramList,
xmlrpc_c::value * const retvalP) {
string const shub(paramList.getString(0));
string const sseparator(paramList.getString(1));
paramList.verifyEnd(2);
string retchat;
ServerThread::getInstance()->getChatPubFromClient(retchat, shub, sseparator);
*retvalP = xmlrpc_c::value_string(retchat);
}
};
class sendSearchMethod : public xmlrpc_c::method {
public:
sendSearchMethod() {
this->_signature = "i:s";
this->_help = "Starts a search on all hubs. Params: search string; returns: 0 on success, non-zero otherwise";
}
void
execute(xmlrpc_c::paramList const& paramList,
xmlrpc_c::value * const retvalP) {
string const ssearch(paramList.getString(0));
paramList.verifyEnd(1);
if (ServerThread::getInstance()->sendSearchOnHubs(ssearch, 0, 0, 0, 0, ""))
*retvalP = xmlrpc_c::value_int(0);
else
*retvalP = xmlrpc_c::value_int(1);
}
};
class clearSearchResultsMethod : public xmlrpc_c::method {
public:
clearSearchResultsMethod() {
this->_signature = "i:s";
this->_help = "Clear search result on target hub/all hubs. Params: hub url; returns: array of search results";
}
void
execute(xmlrpc_c::paramList const& paramList,
xmlrpc_c::value * const retvalP) {
string const shuburl(paramList.getString(0));
if (ServerThread::getInstance()->clearSearchResults(shuburl))
*retvalP = xmlrpc_c::value_int(0);
else
*retvalP = xmlrpc_c::value_int(1);
}
};
class returnSearchResultsMethod : public xmlrpc_c::method {
public:
returnSearchResultsMethod() {
this->_signature = "A:s";
this->_help = "Returns a list of search results on a certain hub. Params: hub URL; returns: array of search results";
}
void
execute(xmlrpc_c::paramList const& paramList,
xmlrpc_c::value * const retvalP) {
string const shuburl(paramList.getString(0));
vector<StringMap> hublist;
ServerThread::getInstance()->returnSearchResults(hublist, shuburl);
vector<xmlrpc_c::value> tmp_array_in;
for (const auto& hub : hublist) {
map<string, xmlrpc_c::value> tmp_struct_in;
for (const auto& rearchresult : hub) {
pair<string, xmlrpc_c::value> member(rearchresult.first, xmlrpc_c::value_string(rearchresult.second));
tmp_struct_in.insert(member);
}
xmlrpc_c::value_struct const tmp_struct_out(tmp_struct_in);
tmp_array_in.push_back(xmlrpc_c::value_struct(tmp_struct_out));
}
xmlrpc_c::value_array tmp_array_out(tmp_array_in);
*retvalP = tmp_array_out;
}
};
class setPriorityQueueItemMethod : public xmlrpc_c::method {
public:
setPriorityQueueItemMethod() {
this->_signature = "i:si";
this->_help = "Sets the priority of a target. Params: target, priority in range from 0 (paused) to 5 (highest); returns: 0 on success; non-zero otherwise";
}
void
execute(xmlrpc_c::paramList const& paramList,
xmlrpc_c::value * const retvalP) {
string const starget(paramList.getString(0));
int const ipriority(paramList.getInt(1));
paramList.verifyEnd(2);
if (ServerThread::getInstance()->setPriorityQueueItem(starget, ipriority))
*retvalP = xmlrpc_c::value_int(0);
else
*retvalP = xmlrpc_c::value_int(1);
}
};
class moveQueueItemMethod : public xmlrpc_c::method {
public:
moveQueueItemMethod() {
this->_signature = "i:ss";
this->_help = "Move target param of queue item to new location. Params: target, new target; returns: 0 on success; non-zero otherwise";
}
void
execute(xmlrpc_c::paramList const& paramList,
xmlrpc_c::value * const retvalP) {
string const starget(paramList.getString(0));
string const snewtarget(paramList.getString(1));
paramList.verifyEnd(2);
if (ServerThread::getInstance()->moveQueueItem(starget, snewtarget))
*retvalP = xmlrpc_c::value_int(0);
else
*retvalP = xmlrpc_c::value_int(1);
}
};
class removeQueueItemMethod : public xmlrpc_c::method {
public:
removeQueueItemMethod() {
this->_signature = "i:ss";
this->_help = "Remove queue item by target. Params: target; returns: 0 on success; non-zero otherwise";
}
void
execute(xmlrpc_c::paramList const& paramList,
xmlrpc_c::value * const retvalP) {
string const starget(paramList.getString(0));;
paramList.verifyEnd(1);
if (ServerThread::getInstance()->removeQueueItem(starget))
*retvalP = xmlrpc_c::value_int(0);
else
*retvalP = xmlrpc_c::value_int(1);
}
};
class listQueueTargetsMethod : public xmlrpc_c::method {
public:
listQueueTargetsMethod() {
this->_signature = "i:s";
this->_help = "List queue item targets. Params: separator";
}
void
execute(xmlrpc_c::paramList const& paramList,
xmlrpc_c::value * const retvalP) {
string const sseparator(paramList.getString(0));;
paramList.verifyEnd(1);
string tmp;
ServerThread::getInstance()->listQueueTargets(tmp, sseparator);
*retvalP = xmlrpc_c::value_string(tmp);
}
};
class listQueueMethod : public xmlrpc_c::method {
public:
listQueueMethod() {
this->_signature = "i:s";
this->_help = "List queue items. Params: separator";
}
void
execute(xmlrpc_c::paramList const& paramList,
xmlrpc_c::value * const retvalP) {
unordered_map<string,StringMap> listqueue;
ServerThread::getInstance()->listQueue(listqueue);
map<string, xmlrpc_c::value> tmp_struct1_in;
for (const auto& item : listqueue) {
map<string, xmlrpc_c::value> tmp_struct2_in;
for (const auto& parameter : item.second) {
pair<string, xmlrpc_c::value> member2(parameter.first, xmlrpc_c::value_string(parameter.second));
tmp_struct2_in.insert(member2);
}
xmlrpc_c::value_struct const tmp_struct2_out(tmp_struct2_in);
pair<string, xmlrpc_c::value> member1(i->first, xmlrpc_c::value_struct(tmp_struct2_out));
tmp_struct1_in.insert(member1);
}
xmlrpc_c::value_struct tmp_struct1_out(tmp_struct1_in);
*retvalP = tmp_struct1_out;
}
};
class getSourcesItemMethod : public xmlrpc_c::method {
public:
getSourcesItemMethod() {
this->_signature = "i:s";
this->_help = "Return sources on target. Params: target, separator";
}
void
execute(xmlrpc_c::paramList const& paramList,
xmlrpc_c::value * const retvalP) {
string const starget(paramList.getString(0));;
string const sseparator(paramList.getString(1));;
paramList.verifyEnd(2);
string sources;
unsigned int online = 0;
ServerThread::getInstance()->getItemSourcesbyTarget(starget, sseparator, sources, online);
map<string, xmlrpc_c::value> tmp_struct_in;
tmp_struct_in["sources"] = xmlrpc_c::value_string(sources);
tmp_struct_in["online"] = xmlrpc_c::value_int(online);
xmlrpc_c::value_struct const tmp_struct_out(tmp_struct_in);
*retvalP = tmp_struct_out;
}
};
class getHashStatusMethod : public xmlrpc_c::method {
public:
getHashStatusMethod() {
this->_signature = "i:s";
this->_help = "Return hashing status. Params: none";
}
void
execute(xmlrpc_c::paramList const& paramList,
xmlrpc_c::value * const retvalP) {
string tmp = " ",status = " "; int64_t bytes = 0; size_t files = 0;
ServerThread::getInstance()->getHashStatus(tmp, bytes, files, status);
map<string, xmlrpc_c::value> tmp_struct_in;
tmp_struct_in["currentfile"] = xmlrpc_c::value_string(tmp);
tmp_struct_in["status"] = xmlrpc_c::value_string(status);
tmp_struct_in["bytesleft"] = xmlrpc_c::value_i8(bytes);
tmp_struct_in["filesleft"] = xmlrpc_c::value_i8(files);
xmlrpc_c::value_struct const tmp_struct_out(tmp_struct_in);
*retvalP = tmp_struct_out;
}
};
class pauseHashMethod : public xmlrpc_c::method {
public:
pauseHashMethod() {
this->_signature = "i:s";
this->_help = "Switch pause hashing. Params: none";
}
void
execute(xmlrpc_c::paramList const& paramList,
xmlrpc_c::value * const retvalP) {
if (ServerThread::getInstance()->pauseHash())
*retvalP = xmlrpc_c::value_int(0);
else
*retvalP = xmlrpc_c::value_int(1);
}
};
class getMethodListMethod : public xmlrpc_c::method {
public:
getMethodListMethod() {
this->_signature = "i:s";
this->_help = "Return method list separated by \"|\". Params: none";
}
void
execute(xmlrpc_c::paramList const& paramList,
xmlrpc_c::value * const retvalP) {
string tmp;
ServerThread::getInstance()->getMethodList(tmp);
*retvalP = xmlrpc_c::value_string(tmp);
}
};
class getHubUserListMethod: public xmlrpc_c::method {
public:
getHubUserListMethod() {
this->_signature = "i:ss";
this->_help = "Return user list on huburl. Params: huburl, separator";
}
void
execute(xmlrpc_c::paramList const& paramList,
xmlrpc_c::value * const retvalP) {
string const shuburl(paramList.getString(0));;
string const sseparator(paramList.getString(1));;
paramList.verifyEnd(2);
string tmp;
ServerThread::getInstance()->getHubUserList(tmp, shuburl, sseparator);
*retvalP = xmlrpc_c::value_string(tmp);
}
};
class getUserInfoMethod : public xmlrpc_c::method {
public:
getUserInfoMethod() {
this->_signature = "i:ss";
this->_help = "Return info about user on huburl. Params: nick, huburl";
}
void
execute(xmlrpc_c::paramList const& paramList,
xmlrpc_c::value * const retvalP) {
string const snick(paramList.getString(0));;
string const shuburl(paramList.getString(1));;
paramList.verifyEnd(2);
StringMap params;
if (ServerThread::getInstance()->getUserInfo(params, snick, shuburl)) {
map<string, xmlrpc_c::value> tmp_struct_in;
for (const auto& parameter : params) {
pair<string, xmlrpc_c::value> member(parameter.first, xmlrpc_c::value_string(parameter.second));
tmp_struct_in.insert(member);
}
xmlrpc_c::value_struct const tmp_struct_out(tmp_struct_in);
*retvalP = tmp_struct_out;
} else
*retvalP = xmlrpc_c::value_nil();
}
};
class matchAllListMethod : public xmlrpc_c::method {
public:
matchAllListMethod() {
this->_signature = "s:";
this->_help = "Match all local file lists. Params: none; returns: 0";
}
void
execute(xmlrpc_c::paramList const& paramList,
xmlrpc_c::value * const retvalP) {
ServerThread::getInstance()->matchAllList();
*retvalP = xmlrpc_c::value_int(0);
}
};
class listHubsFullDescMethod : public xmlrpc_c::method {
public:
listHubsFullDescMethod() {
this->_signature = "s:";
this->_help = "Return list all hubs with params. Params: none; returns: array of hub with params";
}
void
execute(xmlrpc_c::paramList const& paramList,
xmlrpc_c::value * const retvalP) {
unordered_map<string,StringMap> listhubs;
ServerThread::getInstance()->listHubsFullDesc(listhubs);
map<string, xmlrpc_c::value> tmp_struct1_in;
for (const auto& hub : listhubs) {
map<string, xmlrpc_c::value> tmp_struct2_in;
for (const auto& parameter : hub.second) {
pair<string, xmlrpc_c::value> member2(parameter.first, xmlrpc_c::value_string(parameter.second));
tmp_struct2_in.insert(member2);
}
xmlrpc_c::value_struct const tmp_struct2_out(tmp_struct2_in);
pair<string, xmlrpc_c::value> member1(hub.first, xmlrpc_c::value_struct(tmp_struct2_out));
tmp_struct1_in.insert(member1);
}
xmlrpc_c::value_struct tmp_struct1_out(tmp_struct1_in);
*retvalP = tmp_struct1_out;
}
};
class systemShutdownMethod : public xmlrpc_c::registry::shutdown {
public:
~systemShutdownMethod() {}
void
doit(std::string const& comment, void * const callInfo) const {
if (isVerbose) std::cout << "Shutting down, comment: " << comment << std::endl;
bServerTerminated = true;
}
};
|