File: ScanControl.cpp

package info (click to toggle)
w-scan-cpp 0~20230121-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 8,008 kB
  • sloc: ansic: 69,193; cpp: 9,599; makefile: 1,149; perl: 862; python: 74; sh: 70
file content (59 lines) | stat: -rw-r--r-- 1,945 bytes parent folder | download | duplicates (2)
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
/******************************************************************************
 * w_scan_cpp - a dtv channel scanner based on VDR (www.tvdr.de) and it's
 * Plugins.
 *
 * See the README file for copyright information and how to reach the author.
 *****************************************************************************/
#include "ScanControl.h"
#include "Helpers.h"
#include "CmdOpts.h"

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-parameter"
#include <vdr/plugin.h>
#include <vdr/PLUGINS/src/wirbelscan/wirbelscan_services.h>
#pragma GCC diagnostic pop

/*******************************************************************************
 * don't pollute the whole program with the namespace WIRBELSCAN_SERVICE or
 * wirbelscan_services.h
 * -> isolate it inside this object: ScanControl.o
 ******************************************************************************/
using namespace WIRBELSCAN_SERVICE;

bool StartScan(void) {
  cWirbelscanCmd cmd = { CmdStartScan, false };

  if (not wirbelscan->Service((SPlugin + std::string(SCommand)).c_str(), (void*) &cmd)) {
     ErrorMessage(__FUNCTION__ + std::string(" failed: unknown service."));
     return false;
     }
  if (not cmd.replycode)
     ErrorMessage("DoScan() failed.");
  return cmd.replycode;
}

static bool Status(cWirbelscanStatus& stat) {
  if (not wirbelscan->Service((SPlugin + std::string("Get") + SStatus).c_str(), (void*) &stat)) {
     ErrorMessage(__FUNCTION__ + std::string(" failed: unknown service."));
     return false;
     }
  return true;
}

bool Scanning(void) {
  cWirbelscanStatus stat;

  if (not Status(stat))
     return false;

  return stat.status == StatusScanning;
}

bool Import(std::vector<TChannel>& dest) {
  if (not wirbelscan->Service((SPlugin + std::string(SExport)).c_str(), (void*) &dest)) {
     ErrorMessage(__FUNCTION__ + std::string(" failed: unknown service."));
     return false;
     }
  return true;
}