Qi Zhao | 7e52449 | 2017-03-02 15:05:45 -0800 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /** |
| 3 | * Copyright (c) 2017, Regents of the University of California, |
| 4 | * |
| 5 | * This file is part of NFD Control Center. See AUTHORS.md for complete list of NFD |
| 6 | * authors and contributors. |
| 7 | * |
| 8 | * NFD Control Center is free software: you can redistribute it and/or modify it under the |
| 9 | * terms of the GNU General Public License as published by the Free Software Foundation, |
| 10 | * either version 3 of the License, or (at your option) any later version. |
| 11 | * |
| 12 | * NFD Control Center is distributed in the hope that it will be useful, but WITHOUT ANY |
| 13 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A |
| 14 | * PARTICULAR PURPOSE. See the GNU General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License along with NFD |
| 17 | * Control Center, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>. |
| 18 | */ |
| 19 | |
| 20 | #ifndef NCC_STATUS_VIEWER_HPP |
| 21 | #define NCC_STATUS_VIEWER_HPP |
| 22 | |
| 23 | #include "forwarder-status.hpp" |
Qi Zhao | 078ac69 | 2017-03-02 16:28:51 -0800 | [diff] [blame^] | 24 | #include "face-status.hpp" |
Qi Zhao | 7e52449 | 2017-03-02 15:05:45 -0800 | [diff] [blame] | 25 | #include "fib-status.hpp" |
| 26 | #include "rib-status.hpp" |
| 27 | |
| 28 | #include <ndn-cxx/face.hpp> |
| 29 | #include <ndn-cxx/name.hpp> |
| 30 | #include <ndn-cxx/util/scheduler.hpp> |
Qi Zhao | 078ac69 | 2017-03-02 16:28:51 -0800 | [diff] [blame^] | 31 | #include <ndn-cxx/mgmt/nfd/face-status.hpp> |
Qi Zhao | 7e52449 | 2017-03-02 15:05:45 -0800 | [diff] [blame] | 32 | #include <ndn-cxx/mgmt/nfd/fib-entry.hpp> |
| 33 | #include <ndn-cxx/mgmt/nfd/rib-entry.hpp> |
| 34 | #include <ndn-cxx/mgmt/nfd/controller.hpp> |
| 35 | #include <ndn-cxx/mgmt/nfd/status-dataset.hpp> |
| 36 | |
| 37 | #include <QObject> |
| 38 | #include <QtQml/QQmlContext> |
| 39 | #include <QtQml/QQmlApplicationEngine> |
| 40 | |
| 41 | namespace ndn { |
| 42 | |
| 43 | class StatusViewer : public QObject |
| 44 | { |
| 45 | Q_OBJECT |
| 46 | public: |
| 47 | explicit |
| 48 | StatusViewer(Face& face, KeyChain& keyChain); |
| 49 | |
| 50 | void |
| 51 | onStatusRetrieved(const nfd::ForwarderStatus& status); |
| 52 | |
| 53 | void |
Qi Zhao | 078ac69 | 2017-03-02 16:28:51 -0800 | [diff] [blame^] | 54 | onFaceStatusRetrieved(const std::vector<nfd::FaceStatus>& status); |
| 55 | |
| 56 | void |
Qi Zhao | 7e52449 | 2017-03-02 15:05:45 -0800 | [diff] [blame] | 57 | onFibStatusRetrieved(const std::vector<nfd::FibEntry>& status); |
| 58 | |
| 59 | void |
| 60 | onRibStatusRetrieved(const std::vector<nfd::RibEntry>& status); |
| 61 | |
| 62 | void |
| 63 | onStatusTimeout(); |
| 64 | |
| 65 | private: |
| 66 | void |
| 67 | requestNfdStatus(); |
| 68 | |
| 69 | signals: |
| 70 | void |
| 71 | showStatus(); |
| 72 | |
| 73 | public slots: |
| 74 | void |
| 75 | present(); |
| 76 | |
| 77 | private: |
| 78 | Face& s_face; |
| 79 | KeyChain& s_keyChain; |
| 80 | nfd::Controller* s_controller; |
| 81 | Scheduler s_scheduler; |
| 82 | |
| 83 | QQmlApplicationEngine s_engine; |
| 84 | |
| 85 | ForwarderStatusModel s_forwarderStatusModel; |
Qi Zhao | 078ac69 | 2017-03-02 16:28:51 -0800 | [diff] [blame^] | 86 | FaceStatusModel s_faceModel; |
Qi Zhao | 7e52449 | 2017-03-02 15:05:45 -0800 | [diff] [blame] | 87 | FibStatusModel s_fibModel; |
| 88 | RibStatusModel s_ribModel; |
| 89 | }; |
| 90 | |
| 91 | } // namespace ndn |
| 92 | |
| 93 | #endif // NCC_STATUS_VIEWER_HPP |