summaryrefslogtreecommitdiff
path: root/extrecmenu.c
blob: 272b001b435d49343be7206df31ff88549507a2c (plain)
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
/*
 * See the README file for copyright information and how to reach the author.
 */

#include <string>
#include <vdr/plugin.h>
#include "mymenusetup.h"
#include "mymenurecordings.h"
#include "tools.h"

#if defined(APIVERSNUM)
#  if APIVERSNUM < 10600
#    error "VDR-1.6.0 API version or greater is required!"
#  else
#    if APIVERSNUM >= 10700 && APIVERSNUM < 10714
#      error "VDR-1.7.14 API version or greater is required!"
#    endif
#  endif
#endif

using namespace std;

static const char *VERSION        = "1.2.5-git";
static const char *DESCRIPTION    = tr("Extended recordings menu");
static const char *MAINMENUENTRY  = "ExtRecMenu";

// --- cPluginExtrecmenu ------------------------------------------------------
class cPluginExtrecmenu:public cPlugin
{
  private:
  public:
    cPluginExtrecmenu(void);
    virtual ~cPluginExtrecmenu();
    virtual const char *Version(void){return VERSION;}
    virtual const char *Description(void){return tr(DESCRIPTION);}
    virtual const char *CommandLineHelp(void);
    virtual bool ProcessArgs(int argc,char *argv[]);
    virtual bool Initialize(void);
    virtual bool Start(void);
    virtual void Stop(void);
    virtual void Housekeeping(void);
    virtual cString Active(void);
    virtual const char *MainMenuEntry(void){return mysetup.HideMainMenuEntry?NULL:MAINMENUENTRY;}
    virtual cOsdObject *MainMenuAction(void);
    virtual cMenuSetupPage *SetupMenu(void);
    virtual bool SetupParse(const char *_Name,const char *Value);
    virtual bool Service(const char *Id,void *Data = NULL);
    virtual const char **SVDRPHelpPages(void);
    virtual cString SVDRPCommand(const char *Command,const char *Option,int &ReplyCode);
};

cPluginExtrecmenu::cPluginExtrecmenu(void)
{
}

cPluginExtrecmenu::~cPluginExtrecmenu()
{
}

const char *cPluginExtrecmenu::CommandLineHelp(void)
{
  return NULL;
}

bool cPluginExtrecmenu::ProcessArgs(int /* argc */,char ** /* argv */)
{
  return true;
}

bool cPluginExtrecmenu::Initialize(void)
{
  return true;
}

bool cPluginExtrecmenu::Start(void)
{
  mySortList=new SortList;
  mySortList->ReadConfigFile();

  Icons::InitCharSet();

  MoveCutterThread=new WorkerThread();

#if VDRVERSNUM >= 10713
  RecordingDirCommands.Load(AddDirectory(cPlugin::ConfigDirectory(PLUGIN_NAME_I18N), "dircmds.conf"));
#else
  RecordingDirCommands.Load(AddDirectory(cPlugin::ConfigDirectory(PLUGIN_NAME_I18N), "dircmds.conf"), true);
#endif

  return true;
}

void cPluginExtrecmenu::Stop(void)
{
  delete mySortList;
  delete MoveCutterThread;
}

void cPluginExtrecmenu::Housekeeping(void)
{
}

cString cPluginExtrecmenu::Active(void)
{
  return MoveCutterThread->Working();
}

cOsdObject *cPluginExtrecmenu::MainMenuAction(void)
{
  return new myMenuRecordings();
}

cMenuSetupPage *cPluginExtrecmenu::SetupMenu(void)
{
  return new myMenuSetup();
}

bool cPluginExtrecmenu::SetupParse(const char *_Name,const char *Value)
{
  bool rc = true;

  if(!strcasecmp(_Name,"IsOrgRecMenu"))
    return (mysetup.ReplaceOrgRecMenu==false); // vdr-replace patch

  if(!strncasecmp(_Name,"RecListColumn.", 14)) {
    char *tmp=NULL;
    for (int i=0; i<MAX_RECLIST_COLUMNS; i++) {

      if(asprintf(&tmp,"RecListColumn.%d", i) == -1) {
        rc = false;
      } else {
        if (!strcasecmp(_Name,tmp)) {

          const char *m;

          // get 'Name' from config line
          m  = strstr(Value, "name=");
          if(m) {
            char *tmp = strdup(m + 5);
            if(strchr(tmp, ',')) *strchr(tmp, ',') = 0;
            STRN0CPY(mysetup.RecListColumn[i].Name, tmp);
            free(tmp);
          } else {
            mysetup.RecListColumn[i].Type = COLTYPE_NONE;
            rc = false;
            break;
          }

          // get 'Type' from config line
          m  = strstr(Value, "type=");
          if(m) {
            char *tmp = strdup(m + 5);
            if(strchr(tmp, ',')) *strchr(tmp, ',') = 0;
            mysetup.RecListColumn[i].Type=atoi(tmp);
            free(tmp);
          } else {
            mysetup.RecListColumn[i].Type = COLTYPE_NONE;
            rc = false;
            break;
          }

          // get 'Width' from config line
          m  = strstr(Value, "width=");
          if(m) {
            char *tmp = strdup(m + 6);
            if(strchr(tmp, ',')) *strchr(tmp, ',') = 0;
            mysetup.RecListColumn[i].Width=atoi(tmp);
            free(tmp);
          } else {
            mysetup.RecListColumn[i].Type = COLTYPE_NONE;
            rc = false;
            break;
          }

          // get 'Align' from config line
          m  = strstr(Value, "align=");
          if(m) {
            char *tmp = strdup(m + 6);
            if(strchr(tmp, ',')) *strchr(tmp, ',') = 0;
            mysetup.RecListColumn[i].Align=atoi(tmp);
            free(tmp);
          } else {
            mysetup.RecListColumn[i].Type = COLTYPE_NONE;
            rc = false;
            break;
          }

          // get 'Op1' from config line
          m  = strstr(Value, "op1=");
          if(m) {
            char *tmp = strdup(m + 4);
            if(strchr(tmp, ',')) *strchr(tmp, ',') = 0;
            STRN0CPY(mysetup.RecListColumn[i].Op1, tmp);
            free(tmp);
          } else {
            mysetup.RecListColumn[i].Type = COLTYPE_NONE;
            rc = false;
            break;
          }

          // get 'Op2' from config line
          m  = strstr(Value, "op2=");
          if(m) {
            char *tmp = strdup(m + 4);
            STRN0CPY(mysetup.RecListColumn[i].Op2, tmp);
            free(tmp);
          } else {
            mysetup.RecListColumn[i].Type = COLTYPE_NONE;
            rc = false;
            break;
          }
          break;
        } else {
        }
        free(tmp);
      }
    }
  }
  else if(!strcasecmp(_Name,"HideMainMenuEntry"))
    mysetup.HideMainMenuEntry=atoi(Value);
  else if(!strcasecmp(_Name,"ReplaceOrgRecMenu"))
    mysetup.ReplaceOrgRecMenu=atoi(Value);
  else if(!strcasecmp(_Name,"PatchNew"))
    mysetup.PatchNew=atoi(Value);
  else if(!strcasecmp(_Name,"ShowNewRecs"))
    mysetup.ShowNewRecs=atoi(Value);
  else if(!strcasecmp(_Name,"RecsPerDir"))
    mysetup.RecsPerDir=atoi(Value);
  else if(!strcasecmp(_Name,"DescendSorting"))
    mysetup.DescendSorting=atoi(Value);
  else if(!strcasecmp(_Name,"GoLastReplayed"))
    mysetup.GoLastReplayed=atoi(Value);
  else if(!strcasecmp(_Name,"ReturnToPlugin"))
    mysetup.ReturnToPlugin=atoi(Value);
  else if(!strcasecmp(_Name,"LimitBandwidth"))
    mysetup.LimitBandwidth=atoi(Value);
  else if(!strcasecmp(_Name,"UseVDRsRecInfoMenu"))
    mysetup.UseVDRsRecInfoMenu=atoi(Value);
  else if(!strcasecmp(_Name,"PatchFont"))
    mysetup.PatchFont=atoi(Value);
  else if(!strcasecmp(_Name,"FileSystemFreeMB"))
    mysetup.FileSystemFreeMB=atoi(Value);
#if VDRVERSNUM >= 10728
  else if(!strcasecmp(_Name,"SetRecordingCat"))
    mysetup.SetRecordingCat=atoi(Value);
#endif
  else if(!strcasecmp(_Name,"UseCutterQueue"))
    mysetup.UseCutterQueue=atoi(Value);
  else
    rc = false;

  return rc;
}

bool cPluginExtrecmenu::Service(const char *Id,void *Data)
{
  if(!Id)
    return false;

  if(mysetup.ReplaceOrgRecMenu && strcmp(Id,"MainMenuHooksPatch-v1.0::osRecordings")==0)
  {
    if(!Data)
      return true;

    cOsdMenu **menu=(cOsdMenu**)Data;
    if(menu)
      *menu=(cOsdMenu*)MainMenuAction();

    return true;
  }
  return false;
}

const char **cPluginExtrecmenu::SVDRPHelpPages(void)
{
 return NULL;
}

cString cPluginExtrecmenu::SVDRPCommand(const char * /* Command */,const char * /* Option */,int & /* ReplyCode */)
{
 return NULL;
}

VDRPLUGINCREATOR(cPluginExtrecmenu); // Don't touch this!