aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorFelix Domke <tmbinc@elitedvb.net>2005-02-07 09:14:02 +0000
committerFelix Domke <tmbinc@elitedvb.net>2005-02-07 09:14:02 +0000
commitd9ee52e4f0fbe9a1ae00d0e66f9e6f0a07fa319f (patch)
treef1084b85919b5590615e281331cfe535c3a160c8 /lib
parent4bc08995411e21f3564f09e136809be68ddf96a8 (diff)
downloadenigma2-d9ee52e4f0fbe9a1ae00d0e66f9e6f0a07fa319f.tar.gz
enigma2-d9ee52e4f0fbe9a1ae00d0e66f9e6f0a07fa319f.zip
- added iStaticServiceInformation
- added service list interface for dvb - started work on queries (currently only "instr" on servicename) - started work on infobar - added listbox with service - fixed dvbdb - remove some debug output
Diffstat (limited to 'lib')
-rw-r--r--lib/base/connection.cpp5
-rw-r--r--lib/dvb/db.cpp85
-rw-r--r--lib/dvb/db.h32
-rw-r--r--lib/dvb/idvb.h69
-rw-r--r--lib/dvb/stT1RVV70
-rw-r--r--lib/gdi/font.cpp2
-rw-r--r--lib/gui/elistbox.cpp69
-rw-r--r--lib/gui/elistbox.h18
-rw-r--r--lib/gui/elistboxcontent.cpp14
-rw-r--r--lib/gui/elistboxcontent.h2
-rw-r--r--lib/nav/core.cpp2
-rw-r--r--lib/python/enigma_python.i1
-rw-r--r--lib/service/iservice.h25
-rw-r--r--lib/service/listboxservice.cpp134
-rw-r--r--lib/service/listboxservice.h48
-rw-r--r--lib/service/service.cpp4
-rw-r--r--lib/service/service.h2
-rw-r--r--lib/service/servicedvb.cpp94
-rw-r--r--lib/service/servicedvb.h17
-rw-r--r--lib/service/servicefs.cpp10
-rw-r--r--lib/service/servicefs.h4
-rw-r--r--lib/service/servicemp3.cpp20
-rw-r--r--lib/service/servicemp3.h14
23 files changed, 589 insertions, 82 deletions
diff --git a/lib/base/connection.cpp b/lib/base/connection.cpp
new file mode 100644
index 00000000..f6a398ca
--- /dev/null
+++ b/lib/base/connection.cpp
@@ -0,0 +1,5 @@
+#include <connection.h>
+
+DEFINE_REF(eConnection);
+
+
diff --git a/lib/dvb/db.cpp b/lib/dvb/db.cpp
index 810aba04..fe4bcc76 100644
--- a/lib/dvb/db.cpp
+++ b/lib/dvb/db.cpp
@@ -27,6 +27,52 @@ eDVBService &eDVBService::operator=(const eDVBService &s)
return *this;
}
+RESULT eDVBService::getName(const eServiceReference &ref, std::string &name)
+{
+ name = m_service_name;
+}
+
+int eDVBService::checkFilter(const eServiceReferenceDVB &ref, const eDVBChannelQuery &query)
+{
+ int res = 0;
+ switch (query.m_type)
+ {
+ case eDVBChannelQuery::tName:
+ res = m_service_name.find(query.m_string) != std::string::npos;
+ break;
+ case eDVBChannelQuery::tProvider:
+ res = m_provider_name.find(query.m_string) != std::string::npos;
+ break;
+ case eDVBChannelQuery::tType:
+ res = ref.getServiceType() == query.m_int;
+ break;
+ case eDVBChannelQuery::tBouquet:
+ res = 0;
+ break;
+ case eDVBChannelQuery::tSatellitePosition:
+ res = (ref.getDVBNamespace().get() >> 16) == query.m_int;
+ break;
+ case eDVBChannelQuery::tChannelID:
+ {
+ eDVBChannelID chid;
+ ref.getChannelID(chid);
+ res = chid == query.m_channelid;
+ break;
+ }
+ case eDVBChannelQuery::tAND:
+ res = checkFilter(ref, *query.m_p1) && checkFilter(ref, *query.m_p2);
+ break;
+ case eDVBChannelQuery::tOR:
+ res = checkFilter(ref, *query.m_p1) || checkFilter(ref, *query.m_p2);
+ break;
+ }
+
+ if (query.m_inverse)
+ return !res;
+ else
+ return res;
+}
+
DEFINE_REF(eDVBDB);
eDVBDB::eDVBDB()
@@ -282,3 +328,42 @@ RESULT eDVBDB::getService(const eServiceReferenceDVB &reference, ePtr<eDVBServic
return 0;
}
+RESULT eDVBDB::startQuery(ePtr<iDVBChannelListQuery> &query, eDVBChannelQuery *q)
+{
+ query = new eDVBDBQuery(this, q);
+ return 0;
+}
+
+DEFINE_REF(eDVBDBQuery);
+
+eDVBDBQuery::eDVBDBQuery(eDVBDB *db, eDVBChannelQuery *query): m_db(db), m_query(query)
+{
+ m_cursor = m_db->m_services.begin();
+}
+
+RESULT eDVBDBQuery::getNextResult(eServiceReferenceDVB &ref)
+{
+ while (m_cursor != m_db->m_services.end())
+ {
+ ref = m_cursor->first;
+
+ int res = (!m_query) || m_cursor->second->checkFilter(ref, *m_query);
+
+ ++m_cursor;
+
+ if (res)
+ return 0;
+ }
+ return 1;
+}
+
+RESULT eDVBChannelQuery::compile(ePtr<eDVBChannelQuery> &res, std::string query)
+{
+ res = new eDVBChannelQuery();
+ res->m_type = eDVBChannelQuery::tName;
+ res->m_inverse = 0;
+ res->m_string = query;
+ return 0;
+}
+
+DEFINE_REF(eDVBChannelQuery);
diff --git a/lib/dvb/db.h b/lib/dvb/db.h
index e673b9e6..55998ebf 100644
--- a/lib/dvb/db.h
+++ b/lib/dvb/db.h
@@ -4,27 +4,12 @@
#include <lib/dvb/idvb.h>
#include <set>
-class eDVBService: public iObject
-{
- DECLARE_REF;
-public:
- eDVBService();
- std::string m_service_name;
- std::string m_provider_name;
-
- int m_flags;
- std::set<int> m_ca;
- std::map<int,int> m_cache;
- virtual ~eDVBService();
-
- eDVBService &operator=(const eDVBService &);
-};
-
class ServiceDescriptionTable;
class eDVBDB: public iDVBChannelList
{
DECLARE_REF;
+ friend class eDVBDBQuery;
private:
struct channel
{
@@ -45,6 +30,21 @@ public:
RESULT addService(const eServiceReferenceDVB &service, eDVBService *service);
RESULT getService(const eServiceReferenceDVB &reference, ePtr<eDVBService> &service);
+
+ RESULT startQuery(ePtr<iDVBChannelListQuery> &query, eDVBChannelQuery *query);
+};
+
+ // we have to add a possibility to invalidate here.
+class eDVBDBQuery: public iDVBChannelListQuery
+{
+DECLARE_REF;
+private:
+ std::map<eServiceReferenceDVB, ePtr<eDVBService> >::iterator m_cursor;
+ ePtr<eDVBDB> m_db;
+ ePtr<eDVBChannelQuery> m_query;
+public:
+ eDVBDBQuery(eDVBDB *db, eDVBChannelQuery *query);
+ virtual RESULT getNextResult(eServiceReferenceDVB &ref);
};
#endif
diff --git a/lib/dvb/idvb.h b/lib/dvb/idvb.h
index c68ad940..15796166 100644
--- a/lib/dvb/idvb.h
+++ b/lib/dvb/idvb.h
@@ -139,7 +139,7 @@ struct eServiceReferenceDVB: public eServiceReference
setTransportStreamID(chid.transport_stream_id);
}
- void getChannelID(eDVBChannelID &chid)
+ void getChannelID(eDVBChannelID &chid) const
{
chid = eDVBChannelID(getDVBNamespace(), getTransportStreamID(), getOriginalNetworkID());
}
@@ -151,14 +151,81 @@ struct eServiceReferenceDVB: public eServiceReference
};
+////////////////// TODO: we need an interface here, but what exactly?
+
+#include <set>
+// btw, still implemented in db.cpp. FIX THIS, TOO.
+
+class eDVBChannelQuery;
+
+class eDVBService: public iStaticServiceInformation
+{
+ DECLARE_REF;
+public:
+ eDVBService();
+ std::string m_service_name;
+ std::string m_provider_name;
+
+ int m_flags;
+ std::set<int> m_ca;
+ std::map<int,int> m_cache;
+ virtual ~eDVBService();
+
+ eDVBService &operator=(const eDVBService &);
+
+ // iStaticServiceInformation
+ RESULT getName(const eServiceReference &ref, std::string &name);
+
+ // for filtering:
+ int checkFilter(const eServiceReferenceDVB &ref, const eDVBChannelQuery &query);
+};
+
+//////////////////
+
class iDVBChannel;
class iDVBDemux;
class iDVBFrontendParameters;
+class iDVBChannelListQuery: public iObject
+{
+public:
+ virtual RESULT getNextResult(eServiceReferenceDVB &ref)=0;
+};
+
+class eDVBChannelQuery: public iObject
+{
+ DECLARE_REF;
+public:
+ enum
+ {
+ tName,
+ tProvider,
+ tType,
+ tBouquet,
+ tSatellitePosition,
+ tChannelID,
+ tAND,
+ tOR
+ };
+
+ int m_type;
+ int m_inverse;
+
+ std::string m_string;
+ int m_int;
+ eDVBChannelID m_channelid;
+
+ static RESULT compile(ePtr<eDVBChannelQuery> &res, std::string query);
+
+ ePtr<eDVBChannelQuery> m_p1, m_p2;
+};
+
class iDVBChannelList: public iObject
{
public:
virtual RESULT getChannelFrontendData(const eDVBChannelID &id, ePtr<iDVBFrontendParameters> &parm)=0;
+ virtual RESULT getService(const eServiceReferenceDVB &reference, ePtr<eDVBService> &service)=0;
+ virtual RESULT startQuery(ePtr<iDVBChannelListQuery> &query, eDVBChannelQuery *query)=0;
};
class iDVBResourceManager: public iObject
diff --git a/lib/dvb/stT1RVV7 b/lib/dvb/stT1RVV7
deleted file mode 100644
index e69de29b..00000000
--- a/lib/dvb/stT1RVV7
+++ /dev/null
diff --git a/lib/gdi/font.cpp b/lib/gdi/font.cpp
index 187512d5..9a7ec069 100644
--- a/lib/gdi/font.cpp
+++ b/lib/gdi/font.cpp
@@ -467,7 +467,7 @@ int eTextPara::renderString(const std::string &string, int rflags)
while(p != string.end())
{
- unsigned int unicode=*p++;
+ unsigned int unicode=(unsigned char)*p++;
if (unicode & 0x80) // we have (hopefully) UTF8 here, and we assume that the encoding is VALID
{
diff --git a/lib/gui/elistbox.cpp b/lib/gui/elistbox.cpp
index 5a9ee4d6..f530019d 100644
--- a/lib/gui/elistbox.cpp
+++ b/lib/gui/elistbox.cpp
@@ -1,3 +1,4 @@
+ /* written by: Felix Domke <tmbinc@elitedvb.net> */
#include <lib/gui/elistbox.h>
#include <lib/gui/elistboxcontent.h>
@@ -9,11 +10,7 @@ eListbox::eListbox(eWidget *parent): eWidget(parent)
void eListbox::setContent(iListboxContent *content)
{
m_content = content;
- invalidate();
- if (m_content)
- m_content->cursorHome();
- m_top = 0;
- m_selected = 0;
+ entryReset();
}
void eListbox::moveSelection(int dir)
@@ -46,6 +43,8 @@ void eListbox::moveSelection(int dir)
if (m_top < 0)
m_top = 0;
break;
+ case justCheck:
+ break;
}
/* note that we could be on an invalid cursor position, but we don't
@@ -54,6 +53,7 @@ void eListbox::moveSelection(int dir)
/* now, look wether the current selection is out of screen */
m_selected = m_content->cursorGet();
+
if (m_selected < m_top)
{
m_top -= m_items_per_page;
@@ -64,11 +64,12 @@ void eListbox::moveSelection(int dir)
/* m_top should be always valid here as it's selected */
m_top += m_items_per_page;
}
-
+
if (m_top != oldtop)
invalidate();
- else
+ else if (m_selected != oldsel)
{
+
/* redraw the old and newly selected */
gRegion inv = eRect(0, m_itemheight * (m_selected-m_top), size().width(), m_itemheight);
inv |= eRect(0, m_itemheight * (oldsel-m_top), size().width(), m_itemheight);
@@ -119,3 +120,57 @@ void eListbox::recalcSize()
m_content->setSize(eSize(size().width(), m_itemheight));
m_items_per_page = size().height() / m_itemheight;
}
+
+void eListbox::entryAdded(int index)
+{
+ /* manage our local pointers. when the entry was added before the current position, we have to advance. */
+
+ /* we need to check <= - when the new entry has the (old) index of the cursor, the cursor was just moved down. */
+ if (index <= m_selected)
+ ++m_selected;
+ if (index <= m_top)
+ ++m_top;
+
+ /* we have to check wether our current cursor is gone out of the screen. */
+ /* moveSelection will check for this case */
+ moveSelection(justCheck);
+
+ /* now, check if the new index is visible. */
+ if ((m_top <= index) && (index < (m_top + m_items_per_page)))
+ {
+ /* todo, calc exact invalidation... */
+ invalidate();
+ }
+}
+
+void eListbox::entryRemoved(int index)
+{
+ if (index == m_selected)
+ m_selected = m_content->cursorGet();
+
+ moveSelection(justCheck);
+
+ if ((m_top <= index) && (index < (m_top + m_items_per_page)))
+ {
+ /* todo, calc exact invalidation... */
+ invalidate();
+ }
+}
+
+void eListbox::entryChanged(int index)
+{
+ if ((m_top <= index) && (index < (m_top + m_items_per_page)))
+ {
+ gRegion inv = eRect(0, m_itemheight * (index-m_top), size().width(), m_itemheight);
+ invalidate(inv);
+ }
+}
+
+void eListbox::entryReset()
+{
+ invalidate();
+ if (m_content)
+ m_content->cursorHome();
+ m_top = 0;
+ m_selected = 0;
+}
diff --git a/lib/gui/elistbox.h b/lib/gui/elistbox.h
index d5464868..9ec94665 100644
--- a/lib/gui/elistbox.h
+++ b/lib/gui/elistbox.h
@@ -34,13 +34,15 @@ protected:
virtual int size()=0;
- virtual RESULT connectItemChanged(const Slot0<void> &itemChanged, ePtr<eConnection> &connection)=0;
+ void setListbox(eListbox *lb);
// void setOutputDevice ? (for allocating colors, ...) .. requires some work, though
virtual void setSize(const eSize &size)=0;
/* the following functions always refer to the selected item */
virtual void paint(gPainter &painter, eWindowStyle &style, const ePoint &offset, int selected)=0;
+
+ eListbox *m_listbox;
#endif
};
@@ -55,12 +57,24 @@ public:
moveUp,
moveDown,
moveTop,
- moveEnd
+ moveEnd,
+ justCheck
};
protected:
int event(int event, void *data=0, void *data2=0);
void recalcSize();
private:
+ friend class iListboxContent;
+
+ /* entryAdded: an entry was added *before* the given index. it's index is the given number. */
+ void entryAdded(int index);
+ /* entryRemoved: an entry with the given index was removed. */
+ void entryRemoved(int index);
+ /* entryChanged: the entry with the given index was changed and should be redrawn. */
+ void entryChanged(int index);
+ /* the complete list changed. you should not attemp to keep the current index. */
+ void entryReset();
+
int m_top, m_selected;
int m_itemheight;
int m_items_per_page;
diff --git a/lib/gui/elistboxcontent.cpp b/lib/gui/elistboxcontent.cpp
index d3a2e77a..0a10b27a 100644
--- a/lib/gui/elistboxcontent.cpp
+++ b/lib/gui/elistboxcontent.cpp
@@ -29,6 +29,10 @@ iListboxContent::~iListboxContent()
{
}
+void iListboxContent::setListbox(eListbox *lb)
+{
+ m_listbox = lb;
+}
DEFINE_REF(eListboxTestContent);
@@ -203,11 +207,6 @@ int eListboxStringContent::size()
return m_size;
}
-RESULT eListboxStringContent::connectItemChanged(const Slot0<void> &itemChanged, ePtr<eConnection> &connection)
-{
- return 0;
-}
-
void eListboxStringContent::setSize(const eSize &size)
{
m_itemsize = size;
@@ -316,11 +315,6 @@ int eListboxPythonStringContent::size()
return PyList_Size(m_list);
}
-RESULT eListboxPythonStringContent::connectItemChanged(const Slot0<void> &itemChanged, ePtr<eConnection> &connection)
-{
- return 0;
-}
-
void eListboxPythonStringContent::setSize(const eSize &size)
{
m_itemsize = size;
diff --git a/lib/gui/elistboxcontent.h b/lib/gui/elistboxcontent.h
index 7ef60116..deea3000 100644
--- a/lib/gui/elistboxcontent.h
+++ b/lib/gui/elistboxcontent.h
@@ -55,8 +55,6 @@ protected:
void cursorRestore();
int size();
- RESULT connectItemChanged(const Slot0<void> &itemChanged, ePtr<eConnection> &connection);
-
// void setOutputDevice ? (for allocating colors, ...) .. requires some work, though
void setSize(const eSize &size);
diff --git a/lib/nav/core.cpp b/lib/nav/core.cpp
index 72d3fc52..10d18e32 100644
--- a/lib/nav/core.cpp
+++ b/lib/nav/core.cpp
@@ -102,7 +102,7 @@ RESULT eNavigation::pause(int dop)
if (!m_runningService)
return -1;
ePtr<iPauseableService> p;
- if (m_runningService->getIPausableService(p))
+ if (m_runningService->pause(p))
return -2;
if (dop)
return p->pause();
diff --git a/lib/python/enigma_python.i b/lib/python/enigma_python.i
index 8e55b74f..4bd0cdcb 100644
--- a/lib/python/enigma_python.i
+++ b/lib/python/enigma_python.i
@@ -66,6 +66,7 @@ extern PSignal1<void,int> &keyPressedSignal();
%}
RefCount(eListboxPythonStringContent)
+RefCount(eListboxServiceContent)
#define DEBUG
%include "stl.i"
diff --git a/lib/service/iservice.h b/lib/service/iservice.h
index 01c61fcc..5a8a0627 100644
--- a/lib/service/iservice.h
+++ b/lib/service/iservice.h
@@ -147,13 +147,21 @@ public:
large list, provided that no state information is nessesary to deliver
the required information. Anyway - ref *must* be the same as the argument
to the info() or getIServiceInformation call! */
-class iServiceInformation: public iObject
+class iStaticServiceInformation: public iObject
{
public:
virtual RESULT getName(const eServiceReference &ref, std::string &name)=0;
};
-typedef ePtr<iServiceInformation> iServiceInformationPtr;
+TEMPLATE_TYPEDEF(ePtr<iStaticServiceInformation>, iStaticServiceInformationPtr);
+
+class iServiceInformation: public iStaticServiceInformation
+{
+public:
+
+};
+
+TEMPLATE_TYPEDEF(ePtr<iServiceInformation>, iServiceInformationPtr);
class iPauseableService: public iObject
{
@@ -162,7 +170,7 @@ public:
virtual RESULT unpause()=0;
};
-typedef ePtr<iPauseableService> iPauseableServicePtr;
+TEMPLATE_TYPEDEF(ePtr<iPauseableService>, iPauseableServicePtr);
class iPlayableService: public iObject
{
@@ -176,8 +184,8 @@ public:
virtual RESULT connectEvent(const Slot2<void,iPlayableService*,int> &event, ePtr<eConnection> &connection)=0;
virtual RESULT start()=0;
virtual RESULT stop()=0;
- virtual RESULT getIPausableService(ePtr<iPauseableService> &ptr)=0;
- virtual RESULT getIServiceInformation(ePtr<iServiceInformation> &ptr)=0;
+ virtual RESULT pause(ePtr<iPauseableService> &ptr)=0;
+ virtual RESULT info(ePtr<iServiceInformation> &ptr)=0;
};
TEMPLATE_TYPEDEF(ePtr<iPlayableService>, iPlayableServicePtr);
@@ -189,10 +197,9 @@ public:
virtual RESULT stop()=0;
};
-typedef ePtr<iRecordableService> iRecordableServicePtr;
+TEMPLATE_TYPEDEF(ePtr<iRecordableService>, iRecordableServicePtr);
// TEMPLATE_TYPEDEF(std::list<eServiceReference>, eServiceReferenceList);
-typedef std::list<eServiceReference> eServiceReferenceList;
class iListableService: public iObject
{
@@ -208,9 +215,9 @@ public:
virtual RESULT play(const eServiceReference &, ePtr<iPlayableService> &ptr)=0;
virtual RESULT record(const eServiceReference &, ePtr<iRecordableService> &ptr)=0;
virtual RESULT list(const eServiceReference &, ePtr<iListableService> &ptr)=0;
- virtual RESULT info(const eServiceReference &, ePtr<iServiceInformation> &ptr);
+ virtual RESULT info(const eServiceReference &, ePtr<iStaticServiceInformation> &ptr);
};
-typedef ePtr<iServiceHandler> iServiceHandlerPtr;
+TEMPLATE_TYPEDEF(ePtr<iServiceHandler>, iServiceHandlerPtr);
#endif
diff --git a/lib/service/listboxservice.cpp b/lib/service/listboxservice.cpp
new file mode 100644
index 00000000..011c96ca
--- /dev/null
+++ b/lib/service/listboxservice.cpp
@@ -0,0 +1,134 @@
+#include <lib/service/listboxservice.h>
+#include <lib/service/service.h>
+
+void eListboxServiceContent::setRoot(const eServiceReference &root)
+{
+ m_root = root;
+
+ assert(m_service_center);
+
+ ePtr<iListableService> lst;
+ if (m_service_center->list(m_root, lst))
+ eDebug("no list available!");
+ else
+ if (lst->getContent(m_list))
+ eDebug("getContent failed");
+
+ m_size = m_list.size();
+ cursorHome();
+}
+
+DEFINE_REF(eListboxServiceContent);
+
+eListboxServiceContent::eListboxServiceContent()
+{
+ m_size = 0;
+ cursorHome();
+ eServiceCenter::getInstance(m_service_center);
+}
+
+void eListboxServiceContent::cursorHome()
+{
+ m_cursor = m_list.begin();
+ m_cursor_number = 0;
+}
+
+void eListboxServiceContent::cursorEnd()
+{
+ m_cursor = m_list.end();
+ m_cursor_number = m_size;
+}
+
+int eListboxServiceContent::cursorMove(int count)
+{
+ if (count > 0)
+ {
+ while (count && (m_cursor != m_list.end()))
+ {
+ ++m_cursor;
+ ++m_cursor_number;
+ --count;
+ }
+ } else if (count < 0)
+ {
+ while (count && (m_cursor != m_list.begin()))
+ {
+ --m_cursor;
+ --m_cursor_number;
+ ++count;
+ }
+ }
+
+ return 0;
+}
+
+int eListboxServiceContent::cursorValid()
+{
+ return m_cursor != m_list.end();
+}
+
+int eListboxServiceContent::cursorSet(int n)
+{
+ cursorHome();
+ cursorMove(n);
+
+ return 0;
+}
+
+int eListboxServiceContent::cursorGet()
+{
+ return m_cursor_number;
+}
+
+void eListboxServiceContent::cursorSave()
+{
+ m_saved_cursor = m_cursor;
+ m_saved_cursor_number = m_cursor_number;
+}
+
+void eListboxServiceContent::cursorRestore()
+{
+ m_cursor = m_saved_cursor;
+ m_cursor_number = m_saved_cursor_number;
+}
+
+int eListboxServiceContent::size()
+{
+ return m_size;
+}
+
+void eListboxServiceContent::setSize(const eSize &size)
+{
+ m_itemsize = size;
+}
+
+void eListboxServiceContent::paint(gPainter &painter, eWindowStyle &style, const ePoint &offset, int selected)
+{
+ ePtr<gFont> fnt = new gFont("Arial", 14);
+ painter.clip(eRect(offset, m_itemsize));
+ style.setStyle(painter, selected ? eWindowStyle::styleListboxSelected : eWindowStyle::styleListboxNormal);
+ painter.clear();
+
+ if (cursorValid())
+ {
+ painter.setFont(fnt);
+
+ ePoint text_offset = offset + (selected ? ePoint(2, 2) : ePoint(1, 1));
+
+ /* get name of service */
+ ePtr<iStaticServiceInformation> service_info;
+ m_service_center->info(*m_cursor, service_info);
+ std::string name = "<n/a>";
+
+ if (service_info)
+ service_info->getName(*m_cursor, name);
+
+ painter.renderText(eRect(text_offset, m_itemsize), name);
+
+ if (selected)
+ style.drawFrame(painter, eRect(offset, m_itemsize), eWindowStyle::frameListboxEntry);
+ }
+
+ painter.clippop();
+}
+
diff --git a/lib/service/listboxservice.h b/lib/service/listboxservice.h
new file mode 100644
index 00000000..45e5ba71
--- /dev/null
+++ b/lib/service/listboxservice.h
@@ -0,0 +1,48 @@
+#ifndef __lib_service_listboxservice_h
+#define __lib_service_listboxservice_h
+
+#include <lib/gui/elistbox.h>
+#include <lib/service/iservice.h>
+
+class eServiceCenter;
+
+class eListboxServiceContent: public virtual iListboxContent
+{
+ DECLARE_REF;
+public:
+ eListboxServiceContent();
+ void setRoot(const eServiceReference &ref);
+
+protected:
+ void cursorHome();
+ void cursorEnd();
+ int cursorMove(int count=1);
+ int cursorValid();
+ int cursorSet(int n);
+ int cursorGet();
+
+ void cursorSave();
+ void cursorRestore();
+ int size();
+
+ // void setOutputDevice ? (for allocating colors, ...) .. requires some work, though
+ void setSize(const eSize &size);
+
+ /* the following functions always refer to the selected item */
+ void paint(gPainter &painter, eWindowStyle &style, const ePoint &offset, int selected);
+private:
+ typedef std::list<eServiceReference> list;
+
+ list m_list;
+ list::iterator m_cursor, m_saved_cursor;
+
+ int m_cursor_number, m_saved_cursor_number;
+ int m_size;
+
+ eSize m_itemsize;
+ ePtr<eServiceCenter> m_service_center;
+
+ eServiceReference m_root;
+};
+
+#endif
diff --git a/lib/service/service.cpp b/lib/service/service.cpp
index 40cbf8df..75d4987b 100644
--- a/lib/service/service.cpp
+++ b/lib/service/service.cpp
@@ -90,7 +90,7 @@ RESULT eServiceCenter::list(const eServiceReference &ref, ePtr<iListableService>
return i->second->list(ref, ptr);
}
-RESULT eServiceCenter::info(const eServiceReference &ref, ePtr<iServiceInformation> &ptr)
+RESULT eServiceCenter::info(const eServiceReference &ref, ePtr<iStaticServiceInformation> &ptr)
{
std::map<int,ePtr<iServiceHandler> >::iterator i = handler.find(ref.type);
if (i == handler.end())
@@ -114,7 +114,7 @@ RESULT eServiceCenter::removeServiceFactory(int id)
}
/* default handlers */
-RESULT iServiceHandler::info(const eServiceReference &, ePtr<iServiceInformation> &ptr)
+RESULT iServiceHandler::info(const eServiceReference &, ePtr<iStaticServiceInformation> &ptr)
{
ptr = 0;
return -1;
diff --git a/lib/service/service.h b/lib/service/service.h
index c3f0c482..9f4b4560 100644
--- a/lib/service/service.h
+++ b/lib/service/service.h
@@ -23,7 +23,7 @@ public:
RESULT play(const eServiceReference &, iPlayableServicePtr &ptr);
RESULT record(const eServiceReference &, iRecordableServicePtr &ptr);
RESULT list(const eServiceReference &, iListableServicePtr &ptr);
- RESULT info(const eServiceReference &, ePtr<iServiceInformation> &ptr);
+ RESULT info(const eServiceReference &, ePtr<iStaticServiceInformation> &ptr);
// eServiceCenter
static RESULT getInstance(eServiceCenterPtr &ptr) { ptr = instance; return 0; }
diff --git a/lib/service/servicedvb.cpp b/lib/service/servicedvb.cpp
index 0c6d72bd..d1ebeb30 100644
--- a/lib/service/servicedvb.cpp
+++ b/lib/service/servicedvb.cpp
@@ -6,6 +6,9 @@
#include <lib/base/init_num.h>
#include <lib/base/init.h>
+#include <lib/dvb/dvb.h>
+#include <lib/dvb/db.h>
+
DEFINE_REF(eServiceFactoryDVB)
eServiceFactoryDVB::eServiceFactoryDVB()
@@ -26,6 +29,53 @@ eServiceFactoryDVB::~eServiceFactoryDVB()
sc->removeServiceFactory(eServiceFactoryDVB::id);
}
+DEFINE_REF(eDVBServiceList);
+
+eDVBServiceList::eDVBServiceList(const eServiceReference &parent): m_parent(parent)
+{
+}
+
+eDVBServiceList::~eDVBServiceList()
+{
+}
+
+RESULT eDVBServiceList::getContent(std::list<eServiceReference> &list)
+{
+ ePtr<iDVBChannelList> db;
+ ePtr<eDVBResourceManager> res;
+
+ int err;
+ if ((err = eDVBResourceManager::getInstance(res)) != 0)
+ {
+ eDebug("no resource manager");
+ return err;
+ }
+ if ((err = res->getChannelList(db)) != 0)
+ {
+ eDebug("no channel list");
+ return err;
+ }
+
+ ePtr<iDVBChannelListQuery> query;
+
+ ePtr<eDVBChannelQuery> q;
+
+ if (m_parent.path.size())
+ eDVBChannelQuery::compile(q, m_parent.path);
+
+ if ((err = db->startQuery(query, q)) != 0)
+ {
+ eDebug("startQuery failed");
+ return err;
+ }
+
+ eServiceReferenceDVB ref;
+
+ while (!query->getNextResult(ref))
+ list.push_back(ref);
+ return 0;
+}
+
RESULT eServiceFactoryDVB::play(const eServiceReference &ref, ePtr<iPlayableService> &ptr)
{
// check resources...
@@ -39,10 +89,46 @@ RESULT eServiceFactoryDVB::record(const eServiceReference &, ePtr<iRecordableSer
return -1;
}
-RESULT eServiceFactoryDVB::list(const eServiceReference &, ePtr<iListableService> &ptr)
+RESULT eServiceFactoryDVB::list(const eServiceReference &ref, ePtr<iListableService> &ptr)
+{
+ ptr = new eDVBServiceList(ref);
+ return 0;
+}
+
+RESULT eServiceFactoryDVB::info(const eServiceReference &ref, ePtr<iStaticServiceInformation> &ptr)
{
ptr = 0;
- return -1;
+ // TODO: handle the listing itself
+ // if (ref.... == -1) .. return "... bouquets ...";
+ // could be also done in another serviceFactory (with seperate ID) to seperate actual services and lists
+ // TODO: cache
+ ePtr<iDVBChannelList> db;
+ ePtr<eDVBResourceManager> res;
+
+ int err;
+ if ((err = eDVBResourceManager::getInstance(res)) != 0)
+ {
+ eDebug("no resource manager");
+ return err;
+ }
+ if ((err = res->getChannelList(db)) != 0)
+ {
+ eDebug("no channel list");
+ return err;
+ }
+
+ ePtr<eDVBService> service;
+
+ /* we are sure to have a ..DVB reference as the info() call was forwarded here according to it's ID. */
+ if ((err = db->getService((eServiceReferenceDVB&)ref, service)) != 0)
+ {
+ eDebug("getService failed!");
+ return err;
+ }
+
+ /* eDVBService has the iStaticServiceInformation interface, so we pass it here. */
+ ptr = service;
+ return 0;
}
eDVBServicePlay::eDVBServicePlay(const eServiceReference &ref):
@@ -145,14 +231,14 @@ RESULT eDVBServicePlay::connectEvent(const Slot2<void,iPlayableService*,int> &ev
return -1;
}
-RESULT eDVBServicePlay::getIPausableService(ePtr<iPauseableService> &ptr)
+RESULT eDVBServicePlay::pause(ePtr<iPauseableService> &ptr)
{
// not yet possible, maybe later...
ptr = 0;
return -1;
}
-RESULT eDVBServicePlay::getIServiceInformation(ePtr<iServiceInformation> &ptr)
+RESULT eDVBServicePlay::info(ePtr<iServiceInformation> &ptr)
{
ptr = this;
return 0;
diff --git a/lib/service/servicedvb.h b/lib/service/servicedvb.h
index c54eb5c0..94659ed1 100644
--- a/lib/service/servicedvb.h
+++ b/lib/service/servicedvb.h
@@ -18,6 +18,19 @@ public:
RESULT play(const eServiceReference &, ePtr<iPlayableService> &ptr);
RESULT record(const eServiceReference &, ePtr<iRecordableService> &ptr);
RESULT list(const eServiceReference &, ePtr<iListableService> &ptr);
+ RESULT info(const eServiceReference &, ePtr<iStaticServiceInformation> &ptr);
+};
+
+class eDVBServiceList: public iListableService
+{
+DECLARE_REF;
+private:
+ eServiceReference m_parent;
+ friend class eServiceFactoryDVB;
+ eDVBServiceList(const eServiceReference &parent);
+public:
+ virtual ~eDVBServiceList();
+ RESULT getContent(std::list<eServiceReference> &list);
};
class eDVBServicePlay: public iPlayableService, public Object, public iServiceInformation
@@ -41,8 +54,8 @@ public:
RESULT connectEvent(const Slot2<void,iPlayableService*,int> &event, ePtr<eConnection> &connection);
RESULT start();
RESULT stop();
- RESULT getIPausableService(ePtr<iPauseableService> &ptr);
- RESULT getIServiceInformation(ePtr<iServiceInformation> &ptr);
+ RESULT pause(ePtr<iPauseableService> &ptr);
+ RESULT info(ePtr<iServiceInformation> &ptr);
// iServiceInformation
RESULT getName(const eServiceReference &ref, std::string &name);
diff --git a/lib/service/servicefs.cpp b/lib/service/servicefs.cpp
index de75cc67..5a945679 100644
--- a/lib/service/servicefs.cpp
+++ b/lib/service/servicefs.cpp
@@ -12,16 +12,16 @@
#include <unistd.h>
-class eServiceFSInformation: public iServiceInformation
+class eStaticServiceFSInformation: public iStaticServiceInformation
{
DECLARE_REF;
public:
RESULT getName(const eServiceReference &ref, std::string &name);
};
-DEFINE_REF(eServiceFSInformation);
+DEFINE_REF(eStaticServiceFSInformation);
-RESULT eServiceFSInformation::getName(const eServiceReference &ref, std::string &name)
+RESULT eStaticServiceFSInformation::getName(const eServiceReference &ref, std::string &name)
{
name = ref.path;
}
@@ -36,7 +36,7 @@ eServiceFactoryFS::eServiceFactoryFS()
if (sc)
sc->addServiceFactory(eServiceFactoryFS::id, this);
- m_service_information = new eServiceFSInformation();
+ m_service_information = new eStaticServiceFSInformation();
}
eServiceFactoryFS::~eServiceFactoryFS()
@@ -69,7 +69,7 @@ RESULT eServiceFactoryFS::list(const eServiceReference &ref, ePtr<iListableServi
return 0;
}
-RESULT eServiceFactoryFS::info(const eServiceReference &ref, ePtr<iServiceInformation> &ptr)
+RESULT eServiceFactoryFS::info(const eServiceReference &ref, ePtr<iStaticServiceInformation> &ptr)
{
ptr = m_service_information;
return 0;
diff --git a/lib/service/servicefs.h b/lib/service/servicefs.h
index d8e77609..337ff620 100644
--- a/lib/service/servicefs.h
+++ b/lib/service/servicefs.h
@@ -15,9 +15,9 @@ public:
RESULT play(const eServiceReference &, ePtr<iPlayableService> &ptr);
RESULT record(const eServiceReference &, ePtr<iRecordableService> &ptr);
RESULT list(const eServiceReference &, ePtr<iListableService> &ptr);
- RESULT info(const eServiceReference &, ePtr<iServiceInformation> &ptr);
+ RESULT info(const eServiceReference &, ePtr<iStaticServiceInformation> &ptr);
private:
- ePtr<iServiceInformation> m_service_information;
+ ePtr<iStaticServiceInformation> m_service_information;
};
class eServiceFS: public iListableService
diff --git a/lib/service/servicemp3.cpp b/lib/service/servicemp3.cpp
index 1f883f94..a5f1b773 100644
--- a/lib/service/servicemp3.cpp
+++ b/lib/service/servicemp3.cpp
@@ -17,7 +17,7 @@ eServiceFactoryMP3::eServiceFactoryMP3()
if (sc)
sc->addServiceFactory(eServiceFactoryMP3::id, this);
- m_service_info = new eServiceMP3Info();
+ m_service_info = new eStaticServiceMP3Info();
}
eServiceFactoryMP3::~eServiceFactoryMP3()
@@ -51,29 +51,29 @@ RESULT eServiceFactoryMP3::list(const eServiceReference &, ePtr<iListableService
return -1;
}
-RESULT eServiceFactoryMP3::info(const eServiceReference &ref, ePtr<iServiceInformation> &ptr)
+RESULT eServiceFactoryMP3::info(const eServiceReference &ref, ePtr<iStaticServiceInformation> &ptr)
{
ptr = m_service_info;
return 0;
}
-// eServiceMP3Info
+// eStaticServiceMP3Info
-// eServiceMP3Info is seperated from eServiceMP3 to give information
+// eStaticServiceMP3Info is seperated from eServiceMP3 to give information
// about unopened files.
-// probably eServiceMP3 should use this class as well, and eServiceMP3Info
+// probably eServiceMP3 should use this class as well, and eStaticServiceMP3Info
// should have a database backend where ID3-files etc. are cached.
// this would allow listing the mp3 database based on certain filters.
-DEFINE_REF(eServiceMP3Info)
+DEFINE_REF(eStaticServiceMP3Info)
-eServiceMP3Info::eServiceMP3Info()
+eStaticServiceMP3Info::eStaticServiceMP3Info()
{
}
-RESULT eServiceMP3Info::getName(const eServiceReference &ref, std::string &name)
+RESULT eStaticServiceMP3Info::getName(const eServiceReference &ref, std::string &name)
{
name = "MP3 file: " + ref.path;
return 0;
@@ -134,13 +134,13 @@ RESULT eServiceMP3::stop()
return 0;
}
-RESULT eServiceMP3::getIPausableService(ePtr<iPauseableService> &ptr) { ptr=this; return 0; }
+RESULT eServiceMP3::pause(ePtr<iPauseableService> &ptr) { ptr=this; return 0; }
// iPausableService
RESULT eServiceMP3::pause() { printf("mp3 pauses!\n"); return 0; }
RESULT eServiceMP3::unpause() { printf("mp3 unpauses!\n"); return 0; }
-RESULT eServiceMP3::getIServiceInformation(ePtr<iServiceInformation>&i) { i = this; return 0; }
+RESULT eServiceMP3::info(ePtr<iServiceInformation>&i) { i = this; return 0; }
RESULT eServiceMP3::getName(const eServiceReference &ref, std::string &name)
{
diff --git a/lib/service/servicemp3.h b/lib/service/servicemp3.h
index 7ef84025..40287ae5 100644
--- a/lib/service/servicemp3.h
+++ b/lib/service/servicemp3.h
@@ -3,7 +3,7 @@
#include <lib/service/iservice.h>
-class eServiceMP3Info ;
+class eStaticServiceMP3Info;
class eServiceFactoryMP3: public iServiceHandler
{
@@ -17,16 +17,16 @@ public:
RESULT play(const eServiceReference &, ePtr<iPlayableService> &ptr);
RESULT record(const eServiceReference &, ePtr<iRecordableService> &ptr);
RESULT list(const eServiceReference &, ePtr<iListableService> &ptr);
- RESULT info(const eServiceReference &, ePtr<iServiceInformation> &ptr);
+ RESULT info(const eServiceReference &, ePtr<iStaticServiceInformation> &ptr);
private:
- ePtr<eServiceMP3Info> m_service_info;
+ ePtr<eStaticServiceMP3Info> m_service_info;
};
-class eServiceMP3Info: public iServiceInformation
+class eStaticServiceMP3Info: public iServiceInformation
{
DECLARE_REF;
friend class eServiceFactoryMP3;
- eServiceMP3Info();
+ eStaticServiceMP3Info();
public:
RESULT getName(const eServiceReference &ref, std::string &name);
};
@@ -53,13 +53,13 @@ public:
RESULT connectEvent(const Slot2<void,iPlayableService*,int> &event, ePtr<eConnection> &connection);
RESULT start();
RESULT stop();
- RESULT getIPausableService(ePtr<iPauseableService> &ptr);
+ RESULT pause(ePtr<iPauseableService> &ptr);
// iPausableService
RESULT pause();
RESULT unpause();
- RESULT getIServiceInformation(ePtr<iServiceInformation>&);
+ RESULT info(ePtr<iServiceInformation>&);
// iServiceInformation
RESULT getName(const eServiceReference &ref, std::string &name);