2 * ci.hh: Common Interface
4 * Copyright (C) 2000 Klaus Schmidinger
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
21 * The author can be reached at kls@cadsoft.de
23 * The project's page is at http://www.cadsoft.de/people/kls/vdr
34 #include <sys/types.h>
35 #include <sys/socket.h>
36 #include <netinet/in.h>
41 #define MAXCASYSTEMIDS 16
44 friend class cCondVar;
46 pthread_mutex_t mutex;
61 cMutexLock(cMutex *Mutex = NULL);
63 bool Lock(cMutex *Mutex);
72 enum { MAX_CIMENU_ENTRIES = 64 }; ///< XXX is there a specified maximum?
78 char *entries[MAX_CIMENU_ENTRIES];
80 bool AddEntry(char *s);
81 cCiMenu(cCiMMI *MMI, bool Selectable);
84 const char *TitleText(void) { return titleText; }
85 const char *SubTitleText(void) { return subTitleText; }
86 const char *BottomText(void) { return bottomText; }
87 const char *Entry(int n) { return n < numEntries ? entries[n] : NULL; }
88 int NumEntries(void) { return numEntries; }
89 bool Selectable(void) { return selectable; }
90 bool Select(int Index);
101 cCiEnquiry(cCiMMI *MMI);
104 const char *Text(void) { return text; }
105 bool Blind(void) { return blind; }
106 int ExpectedLength(void) { return expectedLength; }
107 bool Reply(const char *s);
112 friend class cCiConditionalAccessSupport;
116 uint8_t capmt[2048]; ///< XXX is there a specified maximum?
118 cCiCaPmt(int ProgramNumber);
119 void AddPid(int Pid);
120 void AddCaDescriptor(int Length, uint8_t *Data);
123 #define MAX_CI_SESSION 16 //XXX
126 class cCiTransportLayer;
127 class cCiTransportConnection;
135 cCiSession *sessions[MAX_CI_SESSION];
136 cCiTransportLayer *tpl;
137 cCiTransportConnection *tc;
138 int ResourceIdToInt(const uint8_t *Data);
139 bool Send(uint8_t Tag, int SessionId, int ResourceId = 0, int Status = -1);
140 cCiSession *GetSessionBySessionId(int SessionId);
141 cCiSession *GetSessionByResourceId(int ResourceId, int Slot);
142 cCiSession *CreateSession(int ResourceId);
143 bool OpenSession(int Length, const uint8_t *Data);
144 bool CloseSession(int SessionId);
145 int CloseAllSessions(int Slot);
146 cCiHandler(int Fd, int NumSlots);
149 static cCiHandler *CreateCiHandler(const char *FileName);
150 int NumSlots(void) { return numSlots; }
152 bool HasUserIO(void) { return hasUserIO; }
153 bool EnterMenu(int Slot);
154 cCiMenu *GetMenu(void);
155 cCiEnquiry *GetEnquiry(void);
156 bool SetCaPmt(cCiCaPmt &CaPmt);
157 const unsigned short *GetCaSystemIds(int Slot);
158 bool SetCaPmt(cCiCaPmt &CaPmt, int Slot);
159 bool Reset(int Slot);
162 int tcp_listen(struct sockaddr_in *name,int sckt,unsigned long address=INADDR_ANY);
163 int accept_tcp(int ip_sock,struct sockaddr_in *ip_name);
164 int udp_listen(struct sockaddr_un *name,char const * const filename);
165 int accept_udp(int ip_sock,struct sockaddr_un *ip_name);