Mailing List archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[vdr] [REVISED PATCH] yaepg plugin for 1.3.18



C.Y.M wrote:
Here is a patch for yaepg and vdr-1.3.18..


I just realized that I had made a few mistakes in the first patch I created for yaepg. Also, I didnt realize that the patch I had created was against another patch on yaepg I had found on the net (I cant take credit for that one). So, please let me repost both patches.. The first patch is for yaepg to support wrap around channel scrolling (ie; if you get to the bottom of the channel list, and keep going, you wrap around to the top again). Second patch is a fixed version of the one I had previously posted.

Regards,
Only in vdr-1.3.18/PLUGINS/src/yaepg-0.0.2.1: .dependencies
Only in vdr-1.3.18/PLUGINS/src/yaepg-0.0.2.1: i18n.o
Only in vdr-1.3.18/PLUGINS/src/yaepg-0.0.2.1: libvdr-yaepg.so
diff -ru yaepg-0.0.2.1/yaepg.c vdr-1.3.18/PLUGINS/src/yaepg-0.0.2.1/yaepg.c
--- yaepg-0.0.2.1/yaepg.c	2004-12-01 04:41:27.000000000 -0800
+++ vdr-1.3.18/PLUGINS/src/yaepg-0.0.2.1/yaepg.c	2005-01-12 00:44:21.000000000 -0800
@@ -1207,7 +1207,7 @@
 	cDateBox		*datebox;
 
 	cRecDlgBox		*recDlgBox;
-	int			msgboxStart;
+	uint64			msgboxStart;
 	cMessageBox		*msgbox;
 
 	/*
@@ -1233,7 +1233,7 @@
 	 * Direct Channel Change
 	 */
 	int			currChan;
-	int			lastInput;
+	uint64			lastInput;
 
 	/*
 	 * The last possible starting channel for the grid.
@@ -1638,7 +1638,7 @@
 			
 			/* Display the "Timer added" message" */
 			msgbox = new cMessageBox(tr("Timer added"));
-			msgboxStart = time_ms();
+			msgboxStart = cTimeMs::Now();
 
 			Draw();
 			break;
@@ -1649,7 +1649,7 @@
 
 			/* Display the "Timer cancelled" message */
 			msgbox = new cMessageBox(tr("Timer cancelled"));
-			msgboxStart = time_ms();
+			msgboxStart = cTimeMs::Now();
 
 			Draw();
 			break;
@@ -1772,7 +1772,7 @@
 					break;
 				}
 
-				lastInput = time_ms();
+				lastInput = cTimeMs::Now();
 				Draw();
 			}
 			break;
@@ -1802,7 +1802,7 @@
 	}
 
 	/* Cancel direct channel input ? */
-	if (currChan && (time_ms() - lastInput) > 1000) {
+	if (currChan && (cTimeMs::Now() - lastInput) > 1000) {
 		/* fprintf(stderr, "Timeout! %d\n", currChan); */
 		for (int i = 0; i < 100; i++) {
 			if (Channels.GetByNumber(currChan-i)) {
@@ -1816,7 +1816,7 @@
 	}
 
 	/* Did the message box expire ? */
-	if (msgbox != NULL && (time_ms() - msgboxStart) > 1000) {
+	if (msgbox != NULL && (cTimeMs::Now() - msgboxStart) > 1000) {
 		delete msgbox;
 		msgbox = NULL;
 		needDraw = true;
Only in vdr-1.3.18/PLUGINS/src/yaepg-0.0.2.1: yaepg.o
diff -ruN yaepg-0.0.2/yaepg.c yaepg-0.0.2.1/yaepg.c
--- yaepg-0.0.2/yaepg.c	2004-11-07 16:58:46.000000000 -0800
+++ yaepg-0.0.2.1/yaepg.c	2004-12-01 04:41:27.000000000 -0800
@@ -41,6 +41,15 @@
 #define ARROW_LEFT			1
 #define ARROW_RIGHT			2
 
+/* Order of channels (UP or DOWN) */
+#define CHANNEL_ORDER_UP      0
+#define CHANNEL_ORDER_DOWN      1
+
+/* Manner in which channel is changed while in YAEPG */
+#define CHANNEL_CHANGE_MANUAL      0
+#define CHANNEL_CHANGE_MANUAL_INEPG   1
+#define CHANNEL_CHANGE_AUTO_INEPG   2
+
 /*
  * PAL/NTSC Output
  */
@@ -61,10 +70,13 @@
 int iTvFormat				= TV_NTSC;
 int iChannelCount			= CHANNELS_NTSC;
 int iHideMenuEntry			= false;
-int bAutoChannelChange			= false;
+int iChannelChange                      = CHANNEL_CHANGE_MANUAL;
 int iTimeFormat				= TIME_24HR;
+int iChannelOrder                       = CHANNEL_ORDER_DOWN;
 static const char *TV_FORMATS[2]	= { "NTSC", "PAL" };
 static const char *TIME_FORMATS[2]	= { "24", "12" };
+static const char *CH_ORDER_FORMATS[2]   = { "UP", "DOWN" };
+static const char *CH_CHANGE_MODES[3]   = { "MANUAL", "MANUAL IN EPG", "AUTO IN EPG" };
 
 int iOutputResW				= TV_NTSC_W;  
 int iOutputResH				= TV_NTSC_H;  
@@ -1168,7 +1180,7 @@
 
 class cYaepg: public cOsdObject {
 private:
-	cOsd		*osd;
+	cOsd			*osd;
 	tArea			areas[3];
 	cBitmap			*EPGBitmap;
 	cBitmap			*InfoBitmap;
@@ -1184,7 +1196,9 @@
 	cTimeBox		*timebox[4];
 	cChanBox		*chans[6]; //TODO
 	sEventRow		eventgrid[6]; //TODO
-
+        
+	int                     last_channel, first_channel;
+	
 	/*
 	 * Info window stuff.
 	 */
@@ -1246,6 +1260,7 @@
 	void MoveCursor(int);
 	void ChangeChan(int);
 	int ChangeTime(int);
+	void GetChannelListEnds(void);
 	void UpdateTime(void);
 	static void LogMsg(eYlog_t, const char *fmt, ...);
 };
@@ -1391,6 +1406,16 @@
 }
 
 void
+cYaepg::GetChannelListEnds()
+{
+        // Set the first and last channel numbers
+        cChannel *c = Channels.First();
+        first_channel = c->Number();
+        c = Channels.Last();
+        last_channel = c->Number();
+}
+
+void
 cYaepg::Draw(void)
 {
 	cChannel *c;
@@ -1439,14 +1464,21 @@
 	 */
 	cx = 36, cy = 22;
 	c = Channels.GetByNumber(startChan);
+	GetChannelListEnds();
 	for (i = 0; i < iChannelCount; i++) {
 		if (c != NULL) {
 			chans[i] = new cChanBox(c);
 			chans[i]->Draw(cx, cy, EPGBitmap);
 			cy += chans[i]->Height() + 2;
 		}
-		while ((c = (cChannel *)c->Next()) && (c->GroupSep())) {
-			;
+                if (iChannelOrder == CHANNEL_ORDER_UP) {
+                   while ((c = (cChannel *)c->Prev()) && (c->GroupSep()));
+                   if (c == NULL)
+                      c = Channels.GetByNumber(last_channel);
+                } else {
+                   while ((c = (cChannel *)c->Next()) && (c->GroupSep()));
+                   if (c == NULL) 
+                      c = Channels.GetByNumber(first_channel);
 		}
 	}
 
@@ -1659,7 +1691,7 @@
 			MoveCursor(CURSOR_UP);
 			Draw();
 
-			if (bAutoChannelChange) {
+			if (iChannelChange == CHANNEL_CHANGE_AUTO_INEPG) {
 				SwitchToCurrentChannel();
                         }
 
@@ -1670,7 +1702,7 @@
 			MoveCursor(CURSOR_DOWN);
 			Draw(); 
 
-			if (bAutoChannelChange) {
+			if (iChannelChange == CHANNEL_CHANGE_AUTO_INEPG) {
 				SwitchToCurrentChannel();
 			}
 			
@@ -1684,7 +1716,10 @@
 			 */
 			if (selEvent->StartTime() <= time(NULL)) {
 				SwitchToCurrentChannel();
-				state = osEnd;
+				if (iChannelChange == CHANNEL_CHANGE_MANUAL_INEPG)
+				   state = osContinue;
+				else
+				   state = osEnd;
 			}
 			else {
 				recDlgBox = new cRecDlgBox(selEvent);
@@ -1694,7 +1729,7 @@
 
 		case kRed:
 		case kChanUp:
-			ChangeChan(iChannelCount * -1);
+			ChangeChan((iChannelOrder == CHANNEL_ORDER_UP ? 1 : -1) * iChannelCount * 1);
 			Draw();
 			state = osContinue;
 			break;
@@ -1706,7 +1741,7 @@
 
 		case kYellow:
 		case kChanDn:
-			ChangeChan(iChannelCount);
+			ChangeChan((iChannelOrder == CHANNEL_ORDER_UP ? 1 : -1) * iChannelCount * -1);
 			Draw();
 			state = osContinue;
 			break;
@@ -1801,13 +1836,14 @@
 	cChannel *c;
 
 	c = Channels.GetByNumber(startChan);
+	GetChannelListEnds();
 	if (change > 0) {
 		for (int i = 0; i < change; i++) {
 			while ((c = (cChannel *)c->Next()) && (c->GroupSep())) {
 				;
 			}
 			if (c == NULL) {
-				return;
+				c = Channels.GetByNumber(first_channel);
 			}
 			startChan = c->Number();
 			/*
@@ -1820,12 +1856,16 @@
 		}
 	}
 	else if (change < 0) {
+	        if (startChan < first_channel) {
+			startChan = last_channel;
+			return;
+		}
 		for (int i = 0; i > change; i--) {
 			while ((c = (cChannel *)c->Prev()) && (c->GroupSep())) {
 				;
 			}
 			if (c == NULL) {
-				return;
+				c = Channels.GetByNumber(last_channel);
 			}
 			startChan = c->Number();
 		}
@@ -1857,7 +1897,7 @@
 	switch (dir) {
 	case CURSOR_UP:
 		if (cursorY == 0) {
-			ChangeChan(-1);
+			ChangeChan(1 * (iChannelOrder == CHANNEL_ORDER_UP ? 1 : -1));
 		}
 		else {
 			cursorY--;
@@ -1866,7 +1906,7 @@
 
 	case CURSOR_DOWN:
 		if (cursorY == iChannelCount - 1) {
-			ChangeChan(+1);
+			ChangeChan(-1 * (iChannelOrder == CHANNEL_ORDER_UP ? 1 : -1));
 		}
 		else {
 			cursorY++;
@@ -1994,8 +2034,9 @@
 private:
 	int iNewTvFormat;
 	int iNewHideMenuEntry;
-	int bNewAutoChannelChange;
+	int iNewChannelChange;
 	int iNewTimeFormat;
+	int iNewChannelOrder;
 
 protected:
 	virtual void Store(void);
@@ -2072,26 +2113,30 @@
 {
 	iTvFormat		= iNewTvFormat;
 	iHideMenuEntry		= iNewHideMenuEntry;
-	bAutoChannelChange	= bNewAutoChannelChange;
+	iChannelChange          = iNewChannelChange;
 	iTimeFormat		= iNewTimeFormat;
+	iChannelOrder           = iNewChannelOrder;
 	
 	SetupStore("Format",		iTvFormat);
 	SetupStore("HideMenuEntry",	iHideMenuEntry);
-	SetupStore("AutoChannelChange",	bAutoChannelChange);
+	SetupStore("ChannelChange",     iChannelChange);
 	SetupStore("TimeFormat",	iTimeFormat);
+	SetupStore("ChannelOrder",      iChannelOrder);
 }
 
 cMenuSetupYaepg::cMenuSetupYaepg(void)
 {
 	iNewTvFormat		= iTvFormat;
 	iNewHideMenuEntry	= iHideMenuEntry;
-	bNewAutoChannelChange	= bAutoChannelChange;
+	iNewChannelChange       = iChannelChange;
 	iNewTimeFormat		= iTimeFormat;
+	iNewChannelOrder        = iChannelOrder;
 
 	Add(new cMenuEditStraItem (tr("TV output format"), &iNewTvFormat, 2, TV_FORMATS));
 	Add(new cMenuEditBoolItem (tr("Hide mainmenu entry"), &iNewHideMenuEntry));
-	Add(new cMenuEditBoolItem (tr("Change channel automatically"), &bNewAutoChannelChange));
+	Add(new cMenuEditStraItem (tr("Channel Change"), &iNewChannelChange, 3, CH_CHANGE_MODES));
 	Add(new cMenuEditStraItem (tr("Time format"), &iNewTimeFormat, 2, TIME_FORMATS));
+	Add(new cMenuEditStraItem (tr("Channel Order"), &iNewChannelOrder, 2, CH_ORDER_FORMATS));
 }
 
 cMenuSetupPage *cPluginYaepg::SetupMenu(void)
@@ -2109,12 +2154,15 @@
 	else if (!strcasecmp(Name, "HideMenuEntry")) {
 		iHideMenuEntry = atoi(Value);
 	}
-	else if (!strcasecmp(Name, "AutoChannelChange")) {
-		bAutoChannelChange = atoi(Value);
+	else if (!strcasecmp(Name, "ChannelChange")) {
+		iChannelChange = atoi(Value);
 	}
 	else if (!strcasecmp(Name, "TimeFormat")) {
 		iTimeFormat = atoi(Value);
 	}
+	else if (!strcasecmp(Name, "ChannelOrder")) {
+		iChannelOrder = atoi(Value);
+	}
 	else {
 		return false;
 	}

Home | Main Index | Thread Index