summaryrefslogtreecommitdiffstats
path: root/src/include/seekhelper.h
blob: b63355563c72e949ef25a6408da94ee8f9aaa840 (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
/***************************************************************************
                          seekhelper.h  -  description
                             -------------------
    begin                : Sam Mai 10 2003
    copyright            : (C) 2003 by Martin Witte
    email                : witte@kawo1.rwth-aachen.de
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#ifndef KRADIO_SEEKHELPER_H
#define KRADIO_SEEKHELPER_H

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <kdemacros.h>

#include "radiodevice_interfaces.h"
#include "soundstreamclient_interfaces.h"


class TDE_EXPORT SeekHelper : public IRadioDeviceClient,
                              public ISoundStreamClient
{
public:
    typedef enum { off, searchWorse, searchBest } state_t;
    typedef enum { up, down } direction_t;

    SeekHelper(ISeekRadio &parent);
    virtual ~SeekHelper();

    virtual bool     connectI   (Interface *i);
    virtual bool     disconnectI(Interface *i);

    virtual void start(const SoundStreamID &id, direction_t dir);
    virtual void step();
    virtual void stop();

    bool isRunning()     const { return m_state != off; }
    bool isRunningUp()   const { return m_state != off && m_direction == up; }
    bool isRunningDown() const { return m_state != off && m_direction == down; }


// IRadioDeviceClient
RECEIVERS:
    bool noticePowerChanged   (bool /*on*/, const IRadioDevice */*sender*/)          { return false; }
    bool noticeStationChanged (const RadioStation &, const IRadioDevice */*sender*/) { return false; }
    bool noticeDescriptionChanged (const TQString &, const IRadioDevice */*sender*/)  { return false; }

    bool noticeCurrentSoundStreamIDChanged(SoundStreamID /*id*/, const IRadioDevice */*sender*/) { return false; }

protected:

    virtual void finish();

    virtual void abort() = 0;
    virtual bool isGood() const = 0;
    virtual bool isBetter() const = 0;
    virtual bool isWorse() const = 0;
    virtual bool bestFound() const = 0;
    virtual void getData() = 0;
    virtual void rememberBest() = 0;
    virtual bool nextSeekStep() = 0;
    virtual void applyBest() = 0;

protected:
    state_t        m_state;
    direction_t    m_direction;
    bool           m_oldMute;

    ISeekRadio    &m_parent;
    SoundStreamID  m_SoundStreamID;
};

#endif