mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-26 23:13:13 +02:00
our current experimental Neutrino branch
git-svn-id: file:///home/bas/coolstream_public_svn/THIRDPARTY/applications/neutrino-experimental@27 e54a6e83-5905-42d5-8d5c-058d10e6a962
This commit is contained in:
11
lib/timerdclient/Makefile.am
Normal file
11
lib/timerdclient/Makefile.am
Normal file
@@ -0,0 +1,11 @@
|
||||
INCLUDES = \
|
||||
-I$(top_srcdir)/lib \
|
||||
-I$(top_srcdir)/src/zapit/include \
|
||||
-I$(top_srcdir)/lib/connection \
|
||||
-I$(top_srcdir)/lib/libeventserver
|
||||
|
||||
AM_CPPFLAGS = -fno-rtti -fno-exceptions
|
||||
|
||||
noinst_LIBRARIES = libtimerdclient.a
|
||||
|
||||
libtimerdclient_a_SOURCES = timerdclient.cpp
|
483
lib/timerdclient/timerdclient.cpp
Normal file
483
lib/timerdclient/timerdclient.cpp
Normal file
@@ -0,0 +1,483 @@
|
||||
/*
|
||||
Timer Daemon - DBoxII-Project
|
||||
|
||||
Copyright (C) 2002 Dirk Szymanski 'Dirch'
|
||||
|
||||
$Id: timerdclient.cpp,v 1.55 2007/10/09 20:46:05 guenther Exp $
|
||||
|
||||
License: GPL
|
||||
|
||||
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.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <eventserver.h>
|
||||
#include <timerdclient/timerdmsg.h>
|
||||
#include <timerdclient/timerdclient.h>
|
||||
|
||||
|
||||
const unsigned char CTimerdClient::getVersion () const
|
||||
{
|
||||
return CTimerdMsg::ACTVERSION;
|
||||
}
|
||||
|
||||
const char * CTimerdClient::getSocketName() const
|
||||
{
|
||||
return TIMERD_UDS_NAME;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
void CTimerdClient::registerEvent(unsigned int eventID, unsigned int clientID, const char * const udsName)
|
||||
{
|
||||
CEventServer::commandRegisterEvent msg2;
|
||||
|
||||
msg2.eventID = eventID;
|
||||
msg2.clientID = clientID;
|
||||
|
||||
strcpy(msg2.udsName, udsName);
|
||||
|
||||
send(CTimerdMsg::CMD_REGISTEREVENT, (char*)&msg2, sizeof(msg2));
|
||||
|
||||
close_connection();
|
||||
}
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
void CTimerdClient::unRegisterEvent(unsigned int eventID, unsigned int clientID)
|
||||
{
|
||||
CEventServer::commandUnRegisterEvent msg2;
|
||||
|
||||
msg2.eventID = eventID;
|
||||
msg2.clientID = clientID;
|
||||
|
||||
send(CTimerdMsg::CMD_UNREGISTEREVENT, (char*)&msg2, sizeof(msg2));
|
||||
|
||||
close_connection();
|
||||
}
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
int CTimerdClient::setSleeptimer(time_t announcetime, time_t alarmtime, int timerid)
|
||||
{
|
||||
int timerID;
|
||||
|
||||
if(timerid == 0)
|
||||
timerID = getSleeptimerID();
|
||||
else
|
||||
timerID = timerid;
|
||||
|
||||
if(timerID != 0)
|
||||
{
|
||||
modifyTimerEvent(timerID, announcetime, alarmtime, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
timerID = addTimerEvent(CTimerd::TIMER_SLEEPTIMER,NULL,announcetime,alarmtime,0);
|
||||
}
|
||||
|
||||
return timerID;
|
||||
}
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
int CTimerdClient::getSleeptimerID()
|
||||
{
|
||||
send(CTimerdMsg::CMD_GETSLEEPTIMER);
|
||||
CTimerdMsg::responseGetSleeptimer response;
|
||||
if(!receive_data((char*)&response, sizeof(CTimerdMsg::responseGetSleeptimer)))
|
||||
response.eventID =0;
|
||||
close_connection();
|
||||
return response.eventID;
|
||||
}
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
int CTimerdClient::getSleepTimerRemaining()
|
||||
{
|
||||
int timerID;
|
||||
if((timerID = getSleeptimerID()) != 0)
|
||||
{
|
||||
CTimerd::responseGetTimer timer;
|
||||
getTimer( timer, timerID);
|
||||
int min=(((timer.alarmTime + 1 - time(NULL)) / 60)+1); //aufrunden auf n<>chst gr<67><72>erere Min.
|
||||
if(min <1)
|
||||
min=1;
|
||||
return min;
|
||||
}
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
void CTimerdClient::getTimerList(CTimerd::TimerList &timerlist)
|
||||
{
|
||||
CTimerdMsg::generalInteger responseInteger;
|
||||
CTimerd::responseGetTimer response;
|
||||
|
||||
send(CTimerdMsg::CMD_GETTIMERLIST);
|
||||
|
||||
timerlist.clear();
|
||||
|
||||
if (CBasicClient::receive_data((char* )&responseInteger, sizeof(responseInteger)))
|
||||
{
|
||||
while (responseInteger.number-- > 0)
|
||||
{
|
||||
if (CBasicClient::receive_data((char*)&response, sizeof(response)))
|
||||
if (response.eventState != CTimerd::TIMERSTATE_TERMINATED)
|
||||
timerlist.push_back(response);
|
||||
};
|
||||
}
|
||||
|
||||
close_connection();
|
||||
}
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
void CTimerdClient::getTimer( CTimerd::responseGetTimer &timer, unsigned timerID)
|
||||
{
|
||||
send(CTimerdMsg::CMD_GETTIMER, (char*)&timerID, sizeof(timerID));
|
||||
|
||||
CTimerd::responseGetTimer response;
|
||||
receive_data((char*)&response, sizeof(CTimerd::responseGetTimer));
|
||||
timer = response;
|
||||
close_connection();
|
||||
}
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
|
||||
bool CTimerdClient::modifyTimerEvent(int eventid, time_t announcetime, time_t alarmtime, time_t stoptime, CTimerd::CTimerEventRepeat evrepeat, uint32_t repeatcount)
|
||||
{
|
||||
return modifyTimerEvent(eventid,announcetime,alarmtime,stoptime,evrepeat,repeatcount,NULL);
|
||||
}
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
bool CTimerdClient::modifyTimerEvent(int eventid, time_t announcetime, time_t alarmtime, time_t stoptime, CTimerd::CTimerEventRepeat evrepeat, uint32_t repeatcount, void *data,
|
||||
int datalen)
|
||||
{
|
||||
// set new time values for event eventid
|
||||
|
||||
CTimerdMsg::commandModifyTimer msgModifyTimer;
|
||||
msgModifyTimer.eventID = eventid;
|
||||
msgModifyTimer.announceTime = announcetime;
|
||||
msgModifyTimer.alarmTime = alarmtime;
|
||||
msgModifyTimer.stopTime = stoptime;
|
||||
msgModifyTimer.eventRepeat = evrepeat;
|
||||
msgModifyTimer.repeatCount = repeatcount;
|
||||
send(CTimerdMsg::CMD_MODIFYTIMER, (char*) &msgModifyTimer, sizeof(msgModifyTimer));
|
||||
|
||||
if (data && datalen)
|
||||
send_data((char*)data,datalen);
|
||||
|
||||
CTimerdMsg::responseStatus response;
|
||||
receive_data((char*)&response, sizeof(response));
|
||||
|
||||
close_connection();
|
||||
return true;
|
||||
}
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
bool CTimerdClient::modifyRecordTimerEvent(int eventid, time_t announcetime, time_t alarmtime, time_t stoptime, CTimerd::CTimerEventRepeat evrepeat, uint32_t repeatcount,
|
||||
const char * const recordingdir)
|
||||
{
|
||||
CTimerdMsg::commandRecordDir rdir;
|
||||
strncpy(rdir.recDir,recordingdir,RECORD_DIR_MAXLEN-1);
|
||||
return modifyTimerEvent(eventid,announcetime,alarmtime,stoptime,evrepeat,repeatcount,&rdir,sizeof(rdir));
|
||||
}
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
bool CTimerdClient::rescheduleTimerEvent(int eventid, time_t diff)
|
||||
{
|
||||
rescheduleTimerEvent(eventid,diff,diff,diff);
|
||||
return true;
|
||||
}
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
bool CTimerdClient::rescheduleTimerEvent(int eventid, time_t announcediff, time_t alarmdiff, time_t stopdiff)
|
||||
{
|
||||
CTimerdMsg::commandModifyTimer msgModifyTimer;
|
||||
msgModifyTimer.eventID = eventid;
|
||||
msgModifyTimer.announceTime = announcediff;
|
||||
msgModifyTimer.alarmTime = alarmdiff;
|
||||
msgModifyTimer.stopTime = stopdiff;
|
||||
|
||||
send(CTimerdMsg::CMD_RESCHEDULETIMER, (char*) &msgModifyTimer, sizeof(msgModifyTimer));
|
||||
|
||||
CTimerdMsg::responseStatus response;
|
||||
receive_data((char*)&response, sizeof(response));
|
||||
|
||||
close_connection();
|
||||
return response.status;
|
||||
}
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
/*
|
||||
int CTimerdClient::addTimerEvent( CTimerEventTypes evType, void* data , int min, int hour, int day, int month, CTimerd::CTimerEventRepeat evrepeat)
|
||||
{
|
||||
time_t actTime_t;
|
||||
time(&actTime_t);
|
||||
struct tm* actTime = localtime(&actTime_t);
|
||||
|
||||
actTime->tm_min = min;
|
||||
actTime->tm_hour = hour;
|
||||
|
||||
if (day > 0)
|
||||
actTime->tm_mday = day;
|
||||
if (month > 0)
|
||||
actTime->tm_mon = month -1;
|
||||
|
||||
addTimerEvent(evType,true,data,0,mktime(actTime),0);
|
||||
}
|
||||
*/
|
||||
//-------------------------------------------------------------------------
|
||||
int CTimerdClient::addTimerEvent( CTimerd::CTimerEventTypes evType, void* data, time_t announcetime, time_t alarmtime,time_t stoptime,
|
||||
CTimerd::CTimerEventRepeat evrepeat, uint32_t repeatcount,bool forceadd)
|
||||
{
|
||||
|
||||
if (!forceadd)
|
||||
{
|
||||
//printf("[CTimerdClient] checking for overlapping timers\n");
|
||||
CTimerd::TimerList overlappingTimer;
|
||||
overlappingTimer = getOverlappingTimers(alarmtime, stoptime);
|
||||
if (overlappingTimer.size() > 0)
|
||||
{
|
||||
// timerd starts eventID at 0 so we can return -1
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
CTimerd::TransferEventInfo tei;
|
||||
CTimerd::TransferRecordingInfo tri;
|
||||
CTimerdMsg::commandAddTimer msgAddTimer;
|
||||
msgAddTimer.alarmTime = alarmtime;
|
||||
msgAddTimer.announceTime = announcetime;
|
||||
msgAddTimer.stopTime = stoptime;
|
||||
msgAddTimer.eventType = evType;
|
||||
msgAddTimer.eventRepeat = evrepeat;
|
||||
msgAddTimer.repeatCount = repeatcount;
|
||||
int length;
|
||||
if( evType == CTimerd::TIMER_SHUTDOWN || evType == CTimerd::TIMER_SLEEPTIMER )
|
||||
{
|
||||
length = 0;
|
||||
}
|
||||
else if(evType == CTimerd::TIMER_NEXTPROGRAM || evType == CTimerd::TIMER_ZAPTO ||
|
||||
evType == CTimerd::TIMER_IMMEDIATE_RECORD )
|
||||
{
|
||||
CTimerd::EventInfo *ei=static_cast<CTimerd::EventInfo*>(data);
|
||||
tei.apids = ei->apids;
|
||||
tei.channel_id = ei->channel_id;
|
||||
tei.epg_starttime = ei->epg_starttime;
|
||||
tei.epgID = ei->epgID;
|
||||
tei.recordingSafety = ei->recordingSafety;
|
||||
length = sizeof( CTimerd::TransferEventInfo);
|
||||
data = &tei;
|
||||
}
|
||||
else if(evType == CTimerd::TIMER_RECORD)
|
||||
{
|
||||
CTimerd::RecordingInfo *ri=static_cast<CTimerd::RecordingInfo*>(data);
|
||||
tri.apids = ri->apids;
|
||||
tri.channel_id = ri->channel_id;
|
||||
tri.epg_starttime = ri->epg_starttime;
|
||||
tri.epgID = ri->epgID;
|
||||
tri.recordingSafety = ri->recordingSafety;
|
||||
strncpy(tri.recordingDir, ri->recordingDir, RECORD_DIR_MAXLEN-1);
|
||||
length = sizeof( CTimerd::TransferRecordingInfo);
|
||||
data = &tri;
|
||||
}
|
||||
else if(evType == CTimerd::TIMER_STANDBY)
|
||||
{
|
||||
length = sizeof(CTimerdMsg::commandSetStandby);
|
||||
}
|
||||
else if(evType == CTimerd::TIMER_REMIND)
|
||||
{
|
||||
length = sizeof(CTimerdMsg::commandRemind);
|
||||
}
|
||||
else if(evType == CTimerd::TIMER_EXEC_PLUGIN)
|
||||
{
|
||||
length = sizeof(CTimerdMsg::commandExecPlugin);
|
||||
}
|
||||
else
|
||||
{
|
||||
length = 0;
|
||||
}
|
||||
|
||||
send(CTimerdMsg::CMD_ADDTIMER, (char*)&msgAddTimer, sizeof(msgAddTimer));
|
||||
|
||||
if((data != NULL) && (length > 0))
|
||||
send_data((char*)data, length);
|
||||
|
||||
CTimerdMsg::responseAddTimer response;
|
||||
receive_data((char*)&response, sizeof(response));
|
||||
close_connection();
|
||||
|
||||
return( response.eventID);
|
||||
}
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
void CTimerdClient::removeTimerEvent( int evId)
|
||||
{
|
||||
CTimerdMsg::commandRemoveTimer msgRemoveTimer;
|
||||
|
||||
msgRemoveTimer.eventID = evId;
|
||||
|
||||
send(CTimerdMsg::CMD_REMOVETIMER, (char*) &msgRemoveTimer, sizeof(msgRemoveTimer));
|
||||
|
||||
close_connection();
|
||||
}
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
bool CTimerdClient::isTimerdAvailable()
|
||||
{
|
||||
if(!send(CTimerdMsg::CMD_TIMERDAVAILABLE))
|
||||
return false;
|
||||
|
||||
CTimerdMsg::responseAvailable response;
|
||||
bool ret=receive_data((char*)&response, sizeof(response));
|
||||
close_connection();
|
||||
return ret;
|
||||
}
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
CTimerd::TimerList CTimerdClient::getOverlappingTimers(time_t& startTime, time_t& stopTime)
|
||||
{
|
||||
CTimerd::TimerList timerlist;
|
||||
CTimerd::TimerList overlapping;
|
||||
int timerPre;
|
||||
int timerPost;
|
||||
|
||||
getTimerList(timerlist);
|
||||
getRecordingSafety(timerPre,timerPost);
|
||||
|
||||
for (CTimerd::TimerList::iterator it = timerlist.begin();
|
||||
it != timerlist.end();it++)
|
||||
{
|
||||
if(it->stopTime != 0 && stopTime != 0)
|
||||
{
|
||||
// Check if both timers have start and end. In this case do not show conflict, if endtime is the same than the starttime of the following timer
|
||||
if ((stopTime+timerPost > it->alarmTime) && (startTime-timerPre < it->stopTime))
|
||||
{
|
||||
overlapping.push_back(*it);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!((stopTime < it->announceTime) || (startTime > it->stopTime)))
|
||||
{
|
||||
overlapping.push_back(*it);
|
||||
}
|
||||
}
|
||||
}
|
||||
return overlapping;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
bool CTimerdClient::shutdown()
|
||||
{
|
||||
send(CTimerdMsg::CMD_SHUTDOWN);
|
||||
|
||||
CTimerdMsg::responseStatus response;
|
||||
receive_data((char*)&response, sizeof(response));
|
||||
|
||||
close_connection();
|
||||
return response.status;
|
||||
}
|
||||
//-------------------------------------------------------------------------
|
||||
void CTimerdClient::modifyTimerAPid(int eventid, unsigned char apids)
|
||||
{
|
||||
CTimerdMsg::commandSetAPid data;
|
||||
data.eventID=eventid;
|
||||
data.apids = apids;
|
||||
send(CTimerdMsg::CMD_SETAPID, (char*) &data, sizeof(data));
|
||||
close_connection();
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
void CTimerdClient::setRecordingSafety(int pre, int post)
|
||||
{
|
||||
CTimerdMsg::commandRecordingSafety data;
|
||||
data.pre = pre;
|
||||
data.post = post;
|
||||
send(CTimerdMsg::CMD_SETRECSAFETY, (char*) &data, sizeof(data));
|
||||
close_connection();
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
void CTimerdClient::getRecordingSafety(int &pre, int &post)
|
||||
{
|
||||
send(CTimerdMsg::CMD_GETRECSAFETY);
|
||||
CTimerdMsg::commandRecordingSafety data;
|
||||
|
||||
bool success = receive_data((char*)&data, sizeof(data));
|
||||
close_connection();
|
||||
if (success)
|
||||
{
|
||||
pre = data.pre;
|
||||
post = data.post;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* fill with default values (cf. timermanager.cpp) */
|
||||
pre = 0;
|
||||
post = 0;
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//void CTimerdClient::getWeekdaysFromStr(int *rep, const char* str)
|
||||
void CTimerdClient::getWeekdaysFromStr(CTimerd::CTimerEventRepeat *eventRepeat, const char* str)
|
||||
{
|
||||
int rep = (int) *eventRepeat;
|
||||
if(rep >= (int)CTimerd::TIMERREPEAT_WEEKDAYS)
|
||||
{
|
||||
for(int n=0;n<7;n++)
|
||||
{
|
||||
if(str[n]=='X' || str[n]=='x')
|
||||
{
|
||||
rep |= (1 << (n+9));
|
||||
}
|
||||
else
|
||||
{
|
||||
rep &= (~(1 << (n+9)));
|
||||
}
|
||||
}
|
||||
}
|
||||
*eventRepeat = (CTimerd::CTimerEventRepeat) rep;
|
||||
}
|
||||
//-------------------------------------------------------------------------
|
||||
void CTimerdClient::setWeekdaysToStr(CTimerd::CTimerEventRepeat rep, char* str)
|
||||
{
|
||||
if(rep >= CTimerd::TIMERREPEAT_WEEKDAYS)
|
||||
{
|
||||
for(int n=0;n<7;n++)
|
||||
{
|
||||
if(rep & (1 << (n+9)))
|
||||
str[n]='X';
|
||||
else
|
||||
str[n]='-';
|
||||
}
|
||||
str[7]=0;
|
||||
}
|
||||
else
|
||||
strcpy(str,"-------");
|
||||
}
|
||||
//-------------------------------------------------------------------------
|
||||
void CTimerdClient::stopTimerEvent( int evId)
|
||||
{
|
||||
CTimerdMsg::commandRemoveTimer msgRemoveTimer;
|
||||
|
||||
msgRemoveTimer.eventID = evId;
|
||||
|
||||
send(CTimerdMsg::CMD_STOPTIMER, (char*) &msgRemoveTimer, sizeof(msgRemoveTimer));
|
||||
|
||||
close_connection();
|
||||
}
|
||||
|
175
lib/timerdclient/timerdclient.h
Normal file
175
lib/timerdclient/timerdclient.h
Normal file
@@ -0,0 +1,175 @@
|
||||
/*
|
||||
Timer-Daemon - DBoxII-Project
|
||||
|
||||
Copyright (C) 2001 Steffen Hehn 'McClean'
|
||||
Homepage: http://dbox.cyberphoria.org/
|
||||
|
||||
$Id: timerdclient.h,v 1.47 2006/02/14 22:38:28 zwen Exp $
|
||||
|
||||
License: GPL
|
||||
|
||||
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.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __timerdclient__
|
||||
#define __timerdclient__
|
||||
|
||||
#include <string>
|
||||
#include <cstring>
|
||||
|
||||
#include <connection/basicclient.h>
|
||||
|
||||
#include <timerdclient/timerdtypes.h>
|
||||
|
||||
class CTimerdClient:private CBasicClient
|
||||
{
|
||||
private:
|
||||
virtual const unsigned char getVersion () const;
|
||||
virtual const char * getSocketName() const;
|
||||
|
||||
public:
|
||||
enum events
|
||||
{
|
||||
EVT_SHUTDOWN = 1,
|
||||
EVT_ANNOUNCE_SHUTDOWN,
|
||||
EVT_ZAPTO,
|
||||
EVT_ANNOUNCE_ZAPTO,
|
||||
EVT_NEXTPROGRAM,
|
||||
EVT_ANNOUNCE_NEXTPROGRAM,
|
||||
EVT_STANDBY_ON,
|
||||
EVT_STANDBY_OFF,
|
||||
EVT_RECORD_START,
|
||||
EVT_RECORD_STOP,
|
||||
EVT_ANNOUNCE_RECORD,
|
||||
EVT_ANNOUNCE_SLEEPTIMER,
|
||||
EVT_SLEEPTIMER,
|
||||
EVT_REMIND,
|
||||
EVT_EXEC_PLUGIN
|
||||
};
|
||||
|
||||
void registerEvent(unsigned int eventID, unsigned int clientID, const char * const udsName);
|
||||
void unRegisterEvent(unsigned int eventID, unsigned int clientID);
|
||||
|
||||
bool isTimerdAvailable(); // check if timerd is running
|
||||
|
||||
CTimerd::TimerList getOverlappingTimers(time_t& announcetime, time_t& stoptime);
|
||||
|
||||
int addTimerEvent( CTimerd::CTimerEventTypes evType, void* data, time_t alarmtime,time_t announcetime = 0, time_t stoptime = 0,
|
||||
CTimerd::CTimerEventRepeat evrepeat = CTimerd::TIMERREPEAT_ONCE, uint32_t repeatcount = 0, bool forceadd=true);
|
||||
|
||||
void removeTimerEvent( int evId); // remove timer event
|
||||
void stopTimerEvent( int evId); // set timer state to stoped (rescedule on demand)
|
||||
|
||||
void getTimerList( CTimerd::TimerList &timerlist); // returns the list of all timers
|
||||
void getTimer( CTimerd::responseGetTimer &timer, unsigned timerID); // returns specified timer
|
||||
|
||||
// modify existing timer event
|
||||
bool modifyTimerEvent(int eventid, time_t announcetime, time_t alarmtime, time_t stoptime, CTimerd::CTimerEventRepeat evrepeat = CTimerd::TIMERREPEAT_ONCE, uint32_t repeatcount=0);
|
||||
bool modifyTimerEvent(int eventid, time_t announcetime, time_t alarmtime, time_t stoptime, CTimerd::CTimerEventRepeat evrepeat, uint32_t repeatcount,
|
||||
void *data,int datalen=0);
|
||||
|
||||
bool modifyRecordTimerEvent(int eventid, time_t announcetime, time_t alarmtime, time_t stoptime, CTimerd::CTimerEventRepeat evrepeat, uint32_t repeatcount, const char * const recordingdir);
|
||||
|
||||
void modifyTimerAPid(int eventid, unsigned char apids);
|
||||
|
||||
// set existing sleeptimer to new times or create new sleeptimer with these times
|
||||
int setSleeptimer(time_t announcetime, time_t alarmtime, int timerid = 0);
|
||||
|
||||
// returns the id of sleeptimer, 0 of no sleeptimer exists
|
||||
int getSleeptimerID();
|
||||
// returns remaining mins, -1 if no sleeptimer exists
|
||||
int getSleepTimerRemaining();
|
||||
|
||||
|
||||
// add diff to existing timer event
|
||||
bool rescheduleTimerEvent(int eventid, time_t diff);
|
||||
|
||||
// add diff to existing timer event
|
||||
bool rescheduleTimerEvent(int eventid, time_t announcediff, time_t alarmdiff, time_t stoptime);
|
||||
|
||||
// adds new sleeptimer event
|
||||
int addSleepTimerEvent(time_t announcetime,time_t alarmtime) // sleeptimer setzen
|
||||
{return addTimerEvent(CTimerd::TIMER_SLEEPTIMER, NULL, announcetime, alarmtime, 0);};
|
||||
|
||||
// adds new shutdown timer event
|
||||
int addShutdownTimerEvent(time_t alarmtime, time_t announcetime = 0, time_t stoptime = 0)
|
||||
{return addTimerEvent(CTimerd::TIMER_SHUTDOWN, NULL, announcetime, alarmtime, stoptime);};
|
||||
|
||||
// adds new record timer event
|
||||
int addRecordTimerEvent(const t_channel_id channel_id, time_t alarmtime, time_t stoptime,
|
||||
unsigned long long epgID=0, time_t epg_starttime=0, time_t announcetime = 0,
|
||||
unsigned char apids=TIMERD_APIDS_STD, bool safety=false,std::string recDir="", bool forceAdd=true)
|
||||
{
|
||||
CTimerd::RecordingInfo eventInfo;
|
||||
eventInfo.channel_id = channel_id;
|
||||
eventInfo.epgID = epgID;
|
||||
eventInfo.epg_starttime = epg_starttime;
|
||||
eventInfo.apids = apids;
|
||||
eventInfo.recordingSafety = safety;
|
||||
strncpy(eventInfo.recordingDir, recDir.c_str(), RECORD_DIR_MAXLEN);
|
||||
return addTimerEvent(CTimerd::TIMER_RECORD, &eventInfo, announcetime, alarmtime, stoptime,CTimerd::TIMERREPEAT_ONCE, 0,forceAdd);
|
||||
};
|
||||
|
||||
int addImmediateRecordTimerEvent(const t_channel_id channel_id, time_t alarmtime, time_t stoptime,
|
||||
unsigned long long epgID=0, time_t epg_starttime=0,unsigned char apids=TIMERD_APIDS_STD)
|
||||
{
|
||||
CTimerd::EventInfo eventInfo;
|
||||
eventInfo.channel_id = channel_id;
|
||||
eventInfo.epgID = epgID;
|
||||
eventInfo.epg_starttime = epg_starttime;
|
||||
eventInfo.apids = apids;
|
||||
eventInfo.recordingSafety = false;
|
||||
return addTimerEvent(CTimerd::TIMER_IMMEDIATE_RECORD, &eventInfo, 0, alarmtime, stoptime);
|
||||
};
|
||||
|
||||
// adds new standby timer event
|
||||
int addStandbyTimerEvent(bool standby_on,time_t alarmtime, time_t announcetime = 0, time_t stoptime = 0)
|
||||
{return addTimerEvent(CTimerd::TIMER_STANDBY, &standby_on, announcetime, alarmtime, stoptime);};
|
||||
|
||||
// adds new zapto timer event
|
||||
int addZaptoTimerEvent(const t_channel_id channel_id, time_t alarmtime, time_t announcetime = 0,
|
||||
time_t stoptime = 0, unsigned long long epgID=0, time_t epg_starttime=0,
|
||||
unsigned char apids=TIMERD_APIDS_STD)
|
||||
{
|
||||
CTimerd::EventInfo eventInfo;
|
||||
eventInfo.channel_id = channel_id;
|
||||
eventInfo.epgID = epgID;
|
||||
eventInfo.epg_starttime = epg_starttime;
|
||||
eventInfo.apids = apids;
|
||||
return addTimerEvent(CTimerd::TIMER_ZAPTO, &eventInfo, announcetime, alarmtime, stoptime);
|
||||
};
|
||||
|
||||
int addNextProgramTimerEvent(CTimerd::EventInfo eventInfo,time_t alarmtime, time_t announcetime = 0, time_t stoptime = 0)
|
||||
{
|
||||
// mal auf verdacht eingebaut
|
||||
// keine ahnung ob / was hier noch fehlt
|
||||
return addTimerEvent(CTimerd::TIMER_NEXTPROGRAM, &eventInfo, alarmtime, announcetime, stoptime);
|
||||
};
|
||||
|
||||
// Exit timerd and programm wakeup
|
||||
bool shutdown();
|
||||
|
||||
// set and get recording safety time (in sec)
|
||||
void setRecordingSafety(int pre, int post);
|
||||
void getRecordingSafety(int &pre, int &post);
|
||||
|
||||
// Convert String of O and X to repeat type and vice versa
|
||||
//void getWeekdaysFromStr(int *rep, const char* str);
|
||||
void getWeekdaysFromStr(CTimerd::CTimerEventRepeat *rep, const char* str);
|
||||
void setWeekdaysToStr(CTimerd::CTimerEventRepeat rep, char* str);
|
||||
};
|
||||
|
||||
#endif
|
155
lib/timerdclient/timerdmsg.h
Normal file
155
lib/timerdclient/timerdmsg.h
Normal file
@@ -0,0 +1,155 @@
|
||||
/*
|
||||
* $Header: /cvs/tuxbox/apps/tuxbox/neutrino/lib/timerdclient/timerdmsg.h,v 1.11 2006/02/14 22:38:28 zwen Exp $
|
||||
*
|
||||
* types used for clientlib <-> timerd communication - d-box2 linux project
|
||||
*
|
||||
* (C) 2002 by thegoodguy <thegoodguy@berlios.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.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __timerdmsg_h__
|
||||
#define __timerdmsg_h__
|
||||
|
||||
|
||||
#include <connection/basicmessage.h>
|
||||
|
||||
#include "timerdtypes.h" // REMINDER_MESSAGE_MAXLEN
|
||||
|
||||
|
||||
#define TIMERD_UDS_NAME "/tmp/timerd.sock"
|
||||
|
||||
|
||||
class CTimerdMsg : public CBasicMessage
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
static const CBasicMessage::t_version ACTVERSION = 2;
|
||||
|
||||
enum commands
|
||||
{
|
||||
CMD_ADDTIMER = 1,
|
||||
CMD_REMOVETIMER,
|
||||
CMD_GETTIMER,
|
||||
CMD_GETTIMERLIST,
|
||||
CMD_MODIFYTIMER,
|
||||
CMD_GETSLEEPTIMER,
|
||||
CMD_RESCHEDULETIMER,
|
||||
|
||||
CMD_REGISTEREVENT,
|
||||
CMD_UNREGISTEREVENT,
|
||||
CMD_TIMERDAVAILABLE,
|
||||
CMD_SHUTDOWN,
|
||||
CMD_SETAPID,
|
||||
CMD_GETRECSAFETY,
|
||||
CMD_SETRECSAFETY,
|
||||
CMD_STOPTIMER
|
||||
};
|
||||
|
||||
|
||||
struct commandAddTimer
|
||||
{
|
||||
CTimerd::CTimerEventTypes eventType;
|
||||
CTimerd::CTimerEventRepeat eventRepeat;
|
||||
time_t alarmTime;
|
||||
time_t announceTime;
|
||||
time_t stopTime;
|
||||
uint32_t repeatCount;
|
||||
};
|
||||
|
||||
struct commandGetTimer
|
||||
{
|
||||
int eventID;
|
||||
};
|
||||
|
||||
struct commandModifyTimer
|
||||
{
|
||||
int eventID;
|
||||
time_t announceTime;
|
||||
time_t alarmTime;
|
||||
time_t stopTime;
|
||||
CTimerd::CTimerEventRepeat eventRepeat;
|
||||
uint32_t repeatCount;
|
||||
};
|
||||
|
||||
|
||||
struct commandRemind
|
||||
{
|
||||
char message[REMINDER_MESSAGE_MAXLEN];
|
||||
};
|
||||
|
||||
struct commandExecPlugin
|
||||
{
|
||||
char name[EXEC_PLUGIN_NAME_MAXLEN];
|
||||
};
|
||||
|
||||
struct commandRecordDir
|
||||
{
|
||||
char recDir[RECORD_DIR_MAXLEN];
|
||||
};
|
||||
|
||||
struct commandSetAPid
|
||||
{
|
||||
int eventID;
|
||||
unsigned char apids;
|
||||
};
|
||||
|
||||
struct commandRemoveTimer
|
||||
{
|
||||
int eventID;
|
||||
};
|
||||
|
||||
struct commandSetStandby
|
||||
{
|
||||
bool standby_on;
|
||||
};
|
||||
|
||||
struct commandRecordingSafety
|
||||
{
|
||||
int pre;
|
||||
int post;
|
||||
};
|
||||
|
||||
|
||||
struct generalInteger
|
||||
{
|
||||
int number;
|
||||
};
|
||||
|
||||
struct responseAddTimer
|
||||
{
|
||||
int eventID;
|
||||
};
|
||||
|
||||
struct responseAvailable
|
||||
{
|
||||
bool available;
|
||||
};
|
||||
|
||||
struct responseGetSleeptimer
|
||||
{
|
||||
int eventID;
|
||||
};
|
||||
|
||||
struct responseStatus
|
||||
{
|
||||
bool status;
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
#endif /* __timerdmsg_h__ */
|
168
lib/timerdclient/timerdtypes.h
Normal file
168
lib/timerdclient/timerdtypes.h
Normal file
@@ -0,0 +1,168 @@
|
||||
/*
|
||||
Timer-Daemon - DBoxII-Project
|
||||
|
||||
Copyright (C) 2001 Steffen Hehn 'McClean'
|
||||
Homepage: http://dbox.cyberphoria.org/
|
||||
|
||||
$Id: timerdtypes.h,v 1.20 2006/02/28 21:51:01 zwen Exp $
|
||||
|
||||
License: GPL
|
||||
|
||||
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.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __timerdtypes__
|
||||
#define __timerdtypes__
|
||||
|
||||
#include <zapit/client/zapittypes.h>
|
||||
#include <sectionsdclient/sectionsdtypes.h>
|
||||
|
||||
#include <vector>
|
||||
|
||||
#define REMINDER_MESSAGE_MAXLEN 31
|
||||
#define EXEC_PLUGIN_NAME_MAXLEN 31
|
||||
#define RECORD_DIR_MAXLEN 100
|
||||
#define EPG_TITLE_MAXLEN 50
|
||||
|
||||
#define TIMERD_APIDS_CONF 0x00
|
||||
#define TIMERD_APIDS_STD 0x01
|
||||
#define TIMERD_APIDS_ALT 0x02
|
||||
#define TIMERD_APIDS_AC3 0x04
|
||||
#define TIMERD_APIDS_ALL 0xFF
|
||||
|
||||
class CTimerd
|
||||
{
|
||||
public:
|
||||
enum CTimerEventRepeat
|
||||
{
|
||||
TIMERREPEAT_ONCE = 0,
|
||||
TIMERREPEAT_DAILY,
|
||||
TIMERREPEAT_WEEKLY,
|
||||
TIMERREPEAT_BIWEEKLY,
|
||||
TIMERREPEAT_FOURWEEKLY,
|
||||
TIMERREPEAT_MONTHLY,
|
||||
TIMERREPEAT_BYEVENTDESCRIPTION,
|
||||
TIMERREPEAT_WEEKDAYS = 0x100 // Bits 9-15 specify weekdays (9=mo,10=di,...)
|
||||
};
|
||||
|
||||
enum CTimerEventTypes
|
||||
{
|
||||
TIMER_SHUTDOWN = 1,
|
||||
TIMER_NEXTPROGRAM,
|
||||
TIMER_ZAPTO,
|
||||
TIMER_STANDBY,
|
||||
TIMER_RECORD,
|
||||
TIMER_REMIND,
|
||||
TIMER_SLEEPTIMER,
|
||||
TIMER_EXEC_PLUGIN,
|
||||
TIMER_IMMEDIATE_RECORD
|
||||
};
|
||||
|
||||
enum CTimerEventStates
|
||||
{
|
||||
TIMERSTATE_SCHEDULED,
|
||||
TIMERSTATE_PREANNOUNCE,
|
||||
TIMERSTATE_ISRUNNING,
|
||||
TIMERSTATE_HASFINISHED,
|
||||
TIMERSTATE_TERMINATED
|
||||
};
|
||||
|
||||
struct EventInfo
|
||||
{
|
||||
event_id_t epgID;
|
||||
time_t epg_starttime;
|
||||
t_channel_id channel_id;
|
||||
unsigned char apids;
|
||||
bool recordingSafety;
|
||||
};
|
||||
|
||||
struct TransferEventInfo
|
||||
{
|
||||
event_id_t epgID;
|
||||
time_t epg_starttime;
|
||||
t_channel_id channel_id;
|
||||
unsigned char apids;
|
||||
bool recordingSafety;
|
||||
};
|
||||
|
||||
struct TransferRecordingInfo : TransferEventInfo
|
||||
{
|
||||
char recordingDir[RECORD_DIR_MAXLEN];
|
||||
char epgTitle[EPG_TITLE_MAXLEN];
|
||||
|
||||
};
|
||||
|
||||
class RecordingInfo : public EventInfo
|
||||
{
|
||||
public:
|
||||
RecordingInfo(){};
|
||||
RecordingInfo(EventInfo& e)
|
||||
{
|
||||
apids = e.apids;
|
||||
channel_id = e.channel_id;
|
||||
epgID = e.epgID;
|
||||
epg_starttime = e.epg_starttime;
|
||||
recordingSafety = e.recordingSafety;
|
||||
};
|
||||
RecordingInfo& operator = (EventInfo& e)
|
||||
{
|
||||
apids = e.apids;
|
||||
channel_id = e.channel_id;
|
||||
epgID = e.epgID;
|
||||
epg_starttime = e.epg_starttime;
|
||||
recordingSafety = e.recordingSafety;
|
||||
return *this;
|
||||
}
|
||||
unsigned char apids;
|
||||
int eventID;
|
||||
char recordingDir[RECORD_DIR_MAXLEN];
|
||||
char epgTitle[EPG_TITLE_MAXLEN];
|
||||
};
|
||||
|
||||
struct RecordingStopInfo
|
||||
{
|
||||
int eventID;
|
||||
};
|
||||
|
||||
struct responseGetTimer
|
||||
{
|
||||
int eventID;
|
||||
CTimerEventTypes eventType;
|
||||
CTimerEventStates eventState;
|
||||
CTimerEventRepeat eventRepeat;
|
||||
uint32_t repeatCount;
|
||||
time_t alarmTime;
|
||||
time_t announceTime;
|
||||
time_t stopTime;
|
||||
t_channel_id channel_id; //only filled if applicable
|
||||
event_id_t epgID; //only filled if applicable
|
||||
time_t epg_starttime; //only filled if applicable
|
||||
unsigned char apids; //only filled if applicable
|
||||
bool standby_on; //only filled if applicable
|
||||
char message[REMINDER_MESSAGE_MAXLEN]; //only filled if applicable
|
||||
char pluginName[EXEC_PLUGIN_NAME_MAXLEN]; //only filled if applicable
|
||||
char recordingDir[RECORD_DIR_MAXLEN]; //only filled if applicable
|
||||
char epgTitle[EPG_TITLE_MAXLEN]; //only filled if applicable
|
||||
|
||||
bool operator< (const responseGetTimer& a) const
|
||||
{
|
||||
return this->alarmTime < a.alarmTime ;
|
||||
}
|
||||
};
|
||||
|
||||
typedef std::vector<responseGetTimer> TimerList;
|
||||
};
|
||||
#endif
|
Reference in New Issue
Block a user