Update of /cvsroot/gtkpod/libgpod/src
In directory sc8-pr-cvs2.sourceforge.net:/tmp/cvs-serv12369/src

Modified Files:
        itdb.h itdb_itunesdb.c itdb_playlist.c 
Log Message:
        * src/itdb.h
          src/itdb_itunesdb.c
          src/itdb_playlist.c: introduced splft_binary_and as separate
          field type as this will simplify handling in applications.

        * src/itdb_itunesdb.c (get_mhod, mk_mhod): replaced
          if()... with a switch()... to catch changes made to
          SPLFieldType more easily.

        * src/itdb.h: introduced Itdb_Mediatype enum.



Index: itdb.h
===================================================================
RCS file: /cvsroot/gtkpod/libgpod/src/itdb.h,v
retrieving revision 1.59
retrieving revision 1.60
diff -u -d -r1.59 -r1.60
--- itdb.h      24 Feb 2007 15:17:37 -0000      1.59
+++ itdb.h      25 Feb 2007 04:27:09 -0000      1.60
@@ -1,4 +1,4 @@
-/* Time-stamp: <2007-02-24 23:11:13 jcs>
+/* Time-stamp: <2007-02-25 13:26:22 jcs>
 |
 |  Copyright (C) 2002-2006 Jorg Schuler <jcsjcs at users sourceforge net>
 |  Part of the gtkpod project.
@@ -245,7 +245,8 @@
     splft_boolean,
     splft_date,
     splft_playlist,
-    splft_unknown
+    splft_unknown,
+    splft_binary_and
 } SPLFieldType;
 
 typedef enum
@@ -636,6 +637,17 @@
 } ItdbPlaylistSortOrder;
 
 
+/* Mediatype definitions */
+typedef enum
+{
+    ITDB_MEDIATYPE_AUDIO      = 0x0001,
+    ITDB_MEDIATYPE_MOVIE      = 0x0002,
+    ITDB_MEDIATYPE_PODCAST    = 0x0004,
+    ITDB_MEDIATYPE_AUDIOBOOK  = 0x0008,
+    ITDB_MEDIATYPE_MUSICVIDEO = 0x0020,
+    ITDB_MEDIATYPE_TVSHOW     = 0x0040,
+} Itdb_Mediatype;
+
 /* some of the descriptive comments below are copied verbatim from
    http://ipodlinux.org/ITunesDB. 
    http://ipodlinux.org/ITunesDB is the best source for information

Index: itdb_itunesdb.c
===================================================================
RCS file: /cvsroot/gtkpod/libgpod/src/itdb_itunesdb.c,v
retrieving revision 1.79
retrieving revision 1.80
diff -u -d -r1.79 -r1.80
--- itdb_itunesdb.c     24 Feb 2007 15:35:15 -0000      1.79
+++ itdb_itunesdb.c     25 Feb 2007 04:27:09 -0000      1.80
@@ -1,4 +1,4 @@
-/* Time-stamp: <2007-02-25 00:28:46 jcs>
+/* Time-stamp: <2007-02-25 11:54:25 jcs>
 |
 |  Copyright (C) 2002-2005 Jorg Schuler <jcsjcs at users sourceforge net>
 |  Part of the gtkpod project.
@@ -1427,7 +1427,8 @@
          for (i=0; i<numrules; ++i)
          {
              guint32 length;
-             gint ft;
+             SPLFieldType ft;
+             gunichar2 *string_utf16;
              SPLRule *splr = g_new0 (SPLRule, 1);
              result.data.splrules->rules = g_list_append (
                  result.data.splrules->rules, splr);
@@ -1446,10 +1447,10 @@
              g_return_val_if_fail (length < G_MAXUINT-2, result);
 
              ft = itdb_splr_get_field_type (splr);
-             if (ft == splft_string)
+             switch (ft)
              {
-                 gunichar2 *string_utf16 = g_new0 (gunichar2,
-                                                   (length+2)/2);
+             case splft_string:
+                 string_utf16 = g_new0 (gunichar2, (length+2)/2);
                  if (!seek_get_n_bytes (cts, (gchar *)string_utf16,
                                         seek+4, length))
                  {
@@ -1460,9 +1461,13 @@
                  splr->string = g_utf16_to_utf8 (
                      string_utf16, -1, NULL, NULL, NULL);
                  g_free (string_utf16);
-             }
-             else
-             {
+                 break;
+             case splft_int:
+             case splft_date:
+             case splft_boolean:
+             case splft_playlist:
+             case splft_unknown:
+             case splft_binary_and:
                  if (length != 0x44)
                  {
                      g_warning (_("Length of smart playlist rule field (%d) 
not as expected. Trying to continue anyhow.\n"), length);
@@ -1481,7 +1486,8 @@
                  splr->unk060 = get32bint (cts, seek+60);
                  splr->unk064 = get32bint (cts, seek+64);
                  splr->unk068 = get32bint (cts, seek+68);
-             }  
+                 break;
+             }
              seek += length+4;
          }
       }
@@ -3608,7 +3614,9 @@
          for (gl=mhod->data.splrules->rules; gl; gl=gl->next)
          {
              SPLRule *splr = gl->data;
-             gint ft;
+             SPLFieldType ft;
+             gint len;
+             gunichar2 *entry_utf16;
              g_return_if_fail (splr);
              ft = itdb_splr_get_field_type (splr);
 /*           printf ("%p: field: %d ft: %d\n", splr, splr->field, ft);*/
@@ -3616,10 +3624,11 @@
              put32bint (cts, splr->field);
              put32bint (cts, splr->action);
              put32_n0 (cts, 11);          /* unknown              */
-             if (ft == splft_string)
-             {   /* write string-type rule */
-                 gunichar2 *entry_utf16 = NULL;
-                 gint len;
+             switch (ft)
+             {
+             case splft_string:
+                 /* write string-type rule */
+                 entry_utf16 = NULL;
                  /* splr->string may be NULL */
                  if (splr->string)
                      entry_utf16 = g_utf8_to_utf16 (splr->string,
@@ -3629,9 +3638,14 @@
                  put32bint (cts, 2*len); /* length of string     */
                  put_data (cts, (gchar *)entry_utf16, 2*len);
                  g_free (entry_utf16);
-             }
-             else
-             {   /* write non-string-type rule */
+                 break;
+             case splft_int:
+             case splft_date:
+             case splft_boolean:
+             case splft_playlist:
+             case splft_unknown:
+             case splft_binary_and:
+                 /* write non-string-type rule */
                  put32bint (cts, 0x44); /* length of data        */
                  /* data */
                  put64bint (cts, splr->fromvalue);
@@ -3645,6 +3659,7 @@
                  put32bint (cts, splr->unk060);
                  put32bint (cts, splr->unk064);
                  put32bint (cts, splr->unk068);
+                 break;
              }
          }
          /* insert length of mhod junk */

Index: itdb_playlist.c
===================================================================
RCS file: /cvsroot/gtkpod/libgpod/src/itdb_playlist.c,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- itdb_playlist.c     24 Feb 2007 15:17:37 -0000      1.21
+++ itdb_playlist.c     25 Feb 2007 04:27:09 -0000      1.22
@@ -1,4 +1,4 @@
-/* Time-stamp: <2007-02-25 00:14:27 jcs>
+/* Time-stamp: <2007-02-25 11:52:48 jcs>
 |
 |  Copyright (C) 2002-2005 Jorg Schuler <jcsjcs at users sourceforge net>
 |  Part of the gtkpod project.
@@ -131,7 +131,7 @@
     case SPLFIELD_PLAYLIST:
        return splft_playlist;
     case SPLFIELD_VIDEO_KIND:
-       return splft_int;
+       return splft_binary_and;
     }
     return(splft_unknown);
 }
@@ -198,7 +198,6 @@
        case SPLACTION_IS_IN_THE_RANGE:
            return splat_range_int;
        case SPLACTION_BINARY_AND:
-           return splat_binary_and;
        case SPLACTION_IS_STRING:
        case SPLACTION_CONTAINS:
        case SPLACTION_STARTS_WITH:
@@ -245,6 +244,32 @@
        case SPLACTION_BINARY_AND:
            return splat_invalid;
        }
+    case splft_binary_and:
+       switch ((SPLAction)splr->action)
+       {
+       case SPLACTION_BINARY_AND:
+           return splat_binary_and;
+       case SPLACTION_IS_INT:
+       case SPLACTION_IS_NOT_INT:
+       case SPLACTION_IS_GREATER_THAN:
+       case SPLACTION_IS_NOT_GREATER_THAN:
+       case SPLACTION_IS_LESS_THAN:
+       case SPLACTION_IS_NOT_LESS_THAN:
+       case SPLACTION_IS_IN_THE_LAST:
+       case SPLACTION_IS_NOT_IN_THE_LAST:
+       case SPLACTION_IS_IN_THE_RANGE:
+       case SPLACTION_IS_NOT_IN_THE_RANGE:
+       case SPLACTION_IS_STRING:
+       case SPLACTION_CONTAINS:
+       case SPLACTION_STARTS_WITH:
+       case SPLACTION_DOES_NOT_START_WITH:
+       case SPLACTION_ENDS_WITH:
+       case SPLACTION_DOES_NOT_END_WITH:
+       case SPLACTION_IS_NOT:
+       case SPLACTION_DOES_NOT_CONTAIN:
+           return splat_invalid;
+       }
+
        /* Unknown action type */
        g_warning ("Unknown action type %d\n\n", splr->action);
        return splat_unknown;
@@ -507,6 +532,11 @@
                     intcomp < splr->tovalue) ||
                    (intcomp > splr->fromvalue &&
                     intcomp > splr->tovalue));
+       }
+       return FALSE;
+    case splft_binary_and:
+       switch(splr->action)
+       {
        case SPLACTION_BINARY_AND:
            return (intcomp & splr->fromvalue)? TRUE:FALSE;
        }


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
gtkpod-cvs2 mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gtkpod-cvs2

Reply via email to