about summary refs log tree commit diff
path: root/tools/eaglemode/plugins/yatracker/src/PlYaTracker/PlYaTracker.cpp
blob: 9bf05a17179f61b723fa74fea838f27672f6cfe7 (plain) (blame)
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
#include <emCore/emFilePanel.h>
#include <emCore/emFpPlugin.h>
#include <emCore/emRecFileModel.h>
#include <emCore/emToolkit.h>

class PlYaTrackerConfig final : public emRecFileModel, public emStructRec {
 public:
  static emRef<PlYaTrackerConfig> Acquire(emContext& context,
                                          const emString& name,
                                          bool common = true);

  virtual const char* GetFormatName() const;

  emStringRec URL;
  emStringRec Token;

 protected:
  PlYaTrackerConfig(emContext& context, const emString& name);
};

emRef<PlYaTrackerConfig> PlYaTrackerConfig::Acquire(emContext& context,
                                                    const emString& name,
                                                    bool common) {
  EM_IMPL_ACQUIRE(PlYaTrackerConfig, context, name, common)
}

const char* PlYaTrackerConfig::GetFormatName() const { return "PlYaTracker"; }

PlYaTrackerConfig::PlYaTrackerConfig(emContext& context, const emString& name)
    : emRecFileModel(context, name),
      emStructRec(),
      URL(this, "URL"),
      Token(this, "Token") {
  PostConstruct(*this);
}

class PlYaTrackerFilePanel : public emFilePanel {
 public:
  PlYaTrackerFilePanel(ParentArg parent, const emString& name,
                       emRef<PlYaTrackerConfig> config);

 private:
  emRef<PlYaTrackerConfig> Config;
};

PlYaTrackerFilePanel::PlYaTrackerFilePanel(ParentArg parent,
                                           const emString& name,
                                           emRef<PlYaTrackerConfig> config)
    : emFilePanel(parent, name, config), Config(config) {}

extern "C" {
emPanel* PlYaTrackerPluginFunc(emPanel::ParentArg parent, const emString& name,
                               const emString& path, emFpPlugin* plugin,
                               emString* errorBuf) {
  return new PlYaTrackerFilePanel(
      parent, name, PlYaTrackerConfig::Acquire(parent.GetRootContext(), path));
}
}