summaryrefslogtreecommitdiff
path: root/setup.cpp
blob: 85521f537f99060d6fb83da8eb0323090e419570 (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
/*
 * setup.cpp: A plugin for the Video Disk Recorder
 *
 * See the README file for copyright information and how to reach the author.
 *
 * $Id$
 */

#include "setup.h"

// --- cMenuSetupInfosatepg
cMenuSetupInfosatepg::cMenuSetupInfosatepg(cGlobalInfosatepg *Global)
{
    global=Global;

    newChannel = global->Channel;
    newPid = global->Pid;
    newWaitTime = global->WaitTime;
    newWakeupTime = global->WakeupTime;
    newEventTimeDiff=(int) (global->EventTimeDiff/60);

    Add(NewTitle(tr("Scan parameter")));
    cOsdItem *firstItem = new cMenuEditIntItem( tr("Channel"), &newChannel,1,Channels.MaxNumber());
    Add(firstItem);
    Add(new cMenuEditIntItem( tr("Pid"), &newPid,1,8191));
    Add(NewTitle(tr("Event options")));
    Add(new cMenuEditIntItem( tr("Wait time [s]"), &newWaitTime,MIN_WAITTIME,MAX_WAITTIME));
    Add(new cMenuEditIntItem( tr("Time difference [min]"), &newEventTimeDiff,
                              MIN_EVENTTIMEDIFF,MAX_EVENTTIMEDIFF));

    Add(NewTitle(tr("Wakeup options")));
    Add(new cMenuEditTimeItem(tr("Wakeup time"),&newWakeupTime));

    if (global->InfosatChannels())
    {
        Add(NewTitle(tr("Infosat channels")),true);
        chanCurrent=Current()+1;
        SetCurrent(firstItem);

        for (int i=0; i<global->InfosatChannels(); i++)
        {
            cChannel *chan = Channels.GetByChannelID(global->GetChannelID(i));
            if (!chan) continue;
            Add(new cOsdItem(chan->Name()));
        }
    }
}

cOsdItem *cMenuSetupInfosatepg::NewTitle(const char *s)
{
    char *str;
    asprintf(&str,"---- %s ----", s);
    cOsdItem *tmp = new cOsdItem(str);
    tmp->SetSelectable(false);
    free(str);
    return tmp;
}

void cMenuSetupInfosatepg::Store(void)
{
    bool bReprocess=false;

    if (global->EventTimeDiff!=(60*newEventTimeDiff)) bReprocess=true;

    SetupStore("Channel", global->Channel = newChannel);
    SetupStore("Pid", global->Pid = newPid);
    SetupStore("WaitTime", global->WaitTime = newWaitTime);
    SetupStore("EventTimeDiff", newEventTimeDiff);
    SetupStore("WakeupTime",global->WakeupTime = newWakeupTime);
    global->EventTimeDiff = 60*newEventTimeDiff;

    if (bReprocess) global->ResetProcessedFlags();
}

eOSState cMenuSetupInfosatepg::Edit()
{
    if (HasSubMenu() || Count()==0)
        return osBack;
    if (Current()>=chanCurrent)
    {
        int chanIndex=Current()-chanCurrent;
        if (chanIndex<global->InfosatChannels())
            return AddSubMenu(new cMenuSetupChannelMenu(global,chanIndex));
        else
            return osBack;
    }
    else
        return osBack;
}

eOSState cMenuSetupInfosatepg::ProcessKey(eKeys Key)
{
    eOSState state = cOsdMenu::ProcessKey(Key);

    switch (state)
    {
    default:
        if (state==osUnknown)
        {
            switch (Key)
            {
            case kOk:
                state=Edit();
                if (state==osBack) Store();
                break;
            default:
                break;
            }
        }
    }
    return state;
}

cMenuSetupChannelMenu::cMenuSetupChannelMenu(cGlobalInfosatepg *Global, int Index)
{
    SetPlugin(cPluginManager::GetPlugin(PLUGIN_NAME_I18N));
    global=Global;
    index=Index;

    ChannelUseText[0]=tr("no");
    ChannelUseText[1]=tr("short text");
    ChannelUseText[2]=tr("short/long text");
    ChannelUseText[3]=tr("short text/extEPG");
    ChannelUseText[4]=tr("intelligent");
    ChannelUseText[5]=tr("complete");

    newChannelUse=global->GetChannelUse(index);
    if (newChannelUse<0) newChannelUse=USE_NOTHING; // to be safe!

    channel = Channels.GetByChannelID(global->GetChannelID(index));

    char *str;
    asprintf(&str,"---- %s ----", channel->Name());
    Add(new cOsdItem(str,osUnknown,false));
    free(str);

    Add(new cMenuEditStraItem("Usage",&newChannelUse,
                              sizeof(ChannelUseText)/sizeof(const char *),ChannelUseText));

}

void cMenuSetupChannelMenu::Store(void)
{
    bool bReprocess=false;

    if (!channel) return;
    cString ChannelID = channel->GetChannelID().ToString();
    char *name;
    asprintf(&name,"Channel-%s",*ChannelID);
    if (!name) return;
    if (global->SetChannelUse(index,newChannelUse)) bReprocess=true;
    SetupStore(name,newChannelUse);
    free(name);
    if (bReprocess) global->ResetProcessedFlags();
}