FireBirdLib - Topfield TMS PVR TAP Programming Library
FlashServiceMove.c
Go to the documentation of this file.
1#include "FBLib_flash.h"
2
3bool FlashServiceMove(int SvcType, int FromSvcNum, int ToSvcNum)
4{
6
7 int NrServices;
8 tFlashService Service, tempSvc;
9 int i;
10
11 NrServices = FlashServiceGetTotal(SvcType);
12
13 //SvcType out of range
14 if((SvcType < 0) || (SvcType > SVC_TYPE_Radio))
15 {
16 TRACEEXIT();
17 return FALSE;
18 }
19
20 //SvcNum out of range
21 if((FromSvcNum < 0) || (FromSvcNum >= NrServices) || (ToSvcNum < 0) || (ToSvcNum >= NrServices))
22 {
23 TRACEEXIT();
24 return FALSE;
25 }
26
27 if(FromSvcNum == ToSvcNum)
28 {
29 TRACEEXIT();
30 return TRUE;
31 }
32
33 if(FromSvcNum < ToSvcNum)
34 {
35 //Case 3: a service has been moved up
36 if(!FlashServiceGetInfo(SvcType, FromSvcNum, &Service))
37 {
38 TRACEEXIT();
39
40 return FALSE;
41 }
42
43 for(i = FromSvcNum; i < ToSvcNum; i++)
44 {
45 FlashServiceGetInfo(SvcType, i + 1, &tempSvc);
46 FlashServiceSetInfo(SvcType, i, &tempSvc);
47 }
48 FlashServiceSetInfo(SvcType, ToSvcNum, &Service);
49 }
50 else
51 {
52 //Case 4: a service has been moved down
53 if(!FlashServiceGetInfo(SvcType, FromSvcNum, &Service))
54 {
55 TRACEEXIT();
56
57 return FALSE;
58 }
59
60 for(i = FromSvcNum; i > ToSvcNum; i--)
61 {
62 FlashServiceGetInfo(SvcType, i - 1, &tempSvc);
63 FlashServiceSetInfo(SvcType, i, &tempSvc);
64 }
65 FlashServiceSetInfo(SvcType, ToSvcNum, &Service);
66 }
67
68 FlashReindexFavorites(SvcType, FromSvcNum, ToSvcNum);
69 FlashReindexTimers(SvcType, FromSvcNum, ToSvcNum);
70
71 TRACEEXIT();
72 return TRUE;
73}
void FlashReindexTimers(int SvcType, int FromSvcNum, int ToSvcNum)
void FlashReindexFavorites(int SvcType, int FromSvcNum, int ToSvcNum)
bool FlashServiceGetInfo(int SvcType, int SvcNum, tFlashService *Service)
int FlashServiceGetTotal(int SvcType)
bool FlashServiceMove(int SvcType, int FromSvcNum, int ToSvcNum)
bool FlashServiceSetInfo(int SvcType, int SvcNum, tFlashService *Service)
#define TRACEEXIT()
Definition: libFireBird.h:1244
#define TRACEENTER()
Definition: libFireBird.h:1243