FireBirdLib - Topfield TMS PVR TAP Programming Library
LogoManager_GetLogoByChannelID.c
Go to the documentation of this file.
1#include <stdio.h>
2#include <string.h>
3#include <stdlib.h>
4#include "libFireBird.h"
5#include "FBLib_LogoManager.h"
6
7TYPE_GrData *LogoManager_GetLogoByChannelID(ulong64 ChannelID, tLogoStyle LogoStyle, tLogoSize LogoSize, tLogoAspect LogoAR)
8{
10
11 int i;
12 TYPE_File *f;
13 char s[20], LogoName[120];
14 TYPE_GrData *GrData;
15
17
18 for(i = 0; i < LogoManager_NrLogos; i++)
19 {
20 if(LogoManager_LogoData[i].ChannelID == ChannelID &&
21 LogoManager_LogoData[i].Style == LogoStyle &&
22 LogoManager_LogoData[i].Size == LogoSize &&
23 LogoManager_LogoData[i].Aspect == LogoAR)
24 {
25 if(!LogoManager_LogoData[i].grData)
26 {
27 //The graphics data is not yet available in memory. Load it
28 LogoManager_LogoData[i].grData = TAP_MemAlloc(LogoManager_LogoData[i].grDataSize);
29 if(!LogoManager_LogoData[i].grData)
30 {
31 TRACEEXIT();
32 return NULL;
33 }
34
37 f = TAP_Hdd_Fopen(LOGOCACHE);
38 if(f)
39 {
40 TAP_Hdd_Fseek(f, LogoManager_LogoData[i].CachePosition, SEEK_SET);
41 TAP_Hdd_Fread(LogoManager_LogoData[i].grData, LogoManager_LogoData[i].grDataSize, 1, f);
42 TAP_Hdd_Fclose(f);
43 LogoManager_LogoData[i].grData->data = (byte*)LogoManager_LogoData[i].grData + sizeof(TYPE_GrData);
44 }
46 }
47
48 TRACEEXIT();
50 }
51 }
52
53 //No hit, try to translate the channel ID into a name via the LIL
56 if(TAP_Hdd_Exist(LILNAME))
57 {
58 TAP_SPrint(s, "%16.16llx", ChannelID);
59 INIOpenFile(LILNAME, NULL);
60 INIGetString(s, LogoName, "", 119);
62 if(LogoName[0])
63 {
65 GrData = LogoManager_GetLogoByLogoName(LogoName, LogoStyle, LogoSize, LogoAR);
66
67 TRACEEXIT();
68 return GrData;
69 }
70 }
72
73 TRACEEXIT();
74 return NULL;
75}
tLogoData * LogoManager_LogoData
void(* LogoManager_CB)(int CallbackType, int Param1)
int LogoManager_NrLogos
bool HDD_ChangeDir(const char *Dir)
Definition: HDD_ChangeDir.c:5
void INICloseFile(void)
Definition: INICloseFile.c:5
bool INIGetString(char *Key, char *Value, char *DefaultValue, dword MaxLength)
Definition: INIGetString.c:5
INILOCATION INIOpenFile(char *FileName, char *AppName)
Definition: INIOpenFile.c:9
TYPE_GrData * LogoManager_GetLogoByChannelID(ulong64 ChannelID, tLogoStyle LogoStyle, tLogoSize LogoSize, tLogoAspect LogoAR)
#define LOGOROOT
Definition: libFireBird.h:2217
#define SEEK_SET
Definition: libFireBird.h:1875
#define LOGOCACHE
Definition: libFireBird.h:2219
bool HDD_TAP_PushDir(void)
#define TRACEEXIT()
Definition: libFireBird.h:1244
#define LILNAME
Definition: libFireBird.h:2222
#define TRACEENTER()
Definition: libFireBird.h:1243
bool HDD_TAP_PopDir(void)
Definition: HDD_TAP_PopDir.c:3
void LogoManager_Initialize(void *CallbackRoutine)
tLogoAspect
Definition: libFireBird.h:2247
tLogoSize
Definition: libFireBird.h:2239
TYPE_GrData * LogoManager_GetLogoByLogoName(char *LogoName, tLogoStyle LogoStyle, tLogoSize LogoSize, tLogoAspect LogoAR)
tLogoStyle
Definition: libFireBird.h:2225
TYPE_GrData * grData