|
From: Árpád G. <arp...@gm...> - 2011-07-30 18:40:57
|
Dear gtkpod developers,
I'm writing an iPhone application which tries to implement the following
functionality: as there's no official way among Apple's frameworks to add
songs/videos to the iPod library, I'm trying to implement this using
libgpod. I've already compiled libgpod for iPhone (along with libplist, but
obiviously without libusb and libimobiledevice) and now I'm trying to use
it. However, when I add a track to the library using my - at the moment,
command line - application, all previously added tracks are gone from the
library, but only 'partially': the iPod app on the device can't see them,
but Gtkpod does. When I sync my iPhone with Gtkpod, everything goes well and
I can properly add tracks to my iPhone's library using Gtkpod (one single
warning is generated during mounting my iPhone: 'Extended info will not be
used'). Thus I'm assuming that I'm doing something wrong. I've tried to
extract a working example from gtkpod's source (the latest stable release
was which I downloaded), but I got confused... I kindly ask you whether you
could provide me a very simple, very basic but tutorial-like introduction to
the use of libgpod (the API reference didn't help much). FYI, I'm using
Ubuntu 11.04 on my PC and I have an (obiviously jailbroken) iPhone 3G with
the 4.2.1 firmware.
The code which I've written so far:
#include <libgpod/itdb.h>
#include <stdio.h>
int main () {
Itdb_iTunesDB *db = itdb_parse ("/var/mobile/Media", NULL);
// printf ("Db: %p\n", db);
Itdb_Track *track = itdb_track_new ();
track->transferred = 0;
track->year = 2011;
track->title = "Test2";
track->artist = "H2CO3";
track->album = "Carbon8";
track->genre = "Punk";
track->filetype = g_strdup ("MP3-file");
itdb_track_add (db, track, -1);
Itdb_Playlist *mpl = itdb_playlist_new ("New iPod", 0);
itdb_playlist_set_mpl (mpl);
Itdb_Playlist *podcasts = itdb_playlist_new ("Podcasts", 0);
itdb_playlist_set_podcasts (podcasts);
itdb_playlist_add (db, mpl, -1);
itdb_playlist_add (db, podcasts, -1);
itdb_playlist_add_track (mpl, track, -1);
itdb_playlist_add_track (podcasts, track, -1);
GError *err;
gboolean ret = itdb_cp_track_to_ipod (track,
"/var/mobile/song.mp3", &err);
if (!ret) {
printf ("Error: %s\n", err->message);
}
itdb_write (db, NULL);
return 0;
}
What have I done wrong?
Thanks in advance,
Árpád Goretity
|
|
From: Árpád G. <arp...@gm...> - 2011-07-31 17:27:40
|
Hello again,
So I've figured out what's missing: libgpod is only able to add music to the
iPhone's iPod Library if it's compiled with libimobiledevice support.
Obiviously, it's impossible to port libimobiledevice and libusb to iPhone,
so I'm looking for some explanation on how could I get it to work. Which is
the essential part of libimobiledevice which causes the iPod.app to properly
read and reload the library? I'd like to implement this by hand in my iPhone
app.
Regards, Árpád
2011/7/30 Árpád Goretity <arp...@gm...>
> Dear gtkpod developers,
>
> I'm writing an iPhone application which tries to implement the following
> functionality: as there's no official way among Apple's frameworks to add
> songs/videos to the iPod library, I'm trying to implement this using
> libgpod. I've already compiled libgpod for iPhone (along with libplist, but
> obiviously without libusb and libimobiledevice) and now I'm trying to use
> it. However, when I add a track to the library using my - at the moment,
> command line - application, all previously added tracks are gone from the
> library, but only 'partially': the iPod app on the device can't see them,
> but Gtkpod does. When I sync my iPhone with Gtkpod, everything goes well and
> I can properly add tracks to my iPhone's library using Gtkpod (one single
> warning is generated during mounting my iPhone: 'Extended info will not be
> used'). Thus I'm assuming that I'm doing something wrong. I've tried to
> extract a working example from gtkpod's source (the latest stable release
> was which I downloaded), but I got confused... I kindly ask you whether you
> could provide me a very simple, very basic but tutorial-like introduction to
> the use of libgpod (the API reference didn't help much). FYI, I'm using
> Ubuntu 11.04 on my PC and I have an (obiviously jailbroken) iPhone 3G with
> the 4.2.1 firmware.
>
> The code which I've written so far:
>
> #include <libgpod/itdb.h>
> #include <stdio.h>
>
> int main () {
>
> Itdb_iTunesDB *db = itdb_parse ("/var/mobile/Media", NULL);
> // printf ("Db: %p\n", db);
>
> Itdb_Track *track = itdb_track_new ();
> track->transferred = 0;
> track->year = 2011;
> track->title = "Test2";
> track->artist = "H2CO3";
> track->album = "Carbon8";
> track->genre = "Punk";
> track->filetype = g_strdup ("MP3-file");
>
> itdb_track_add (db, track, -1);
>
> Itdb_Playlist *mpl = itdb_playlist_new ("New iPod", 0);
> itdb_playlist_set_mpl (mpl);
> Itdb_Playlist *podcasts = itdb_playlist_new ("Podcasts", 0);
> itdb_playlist_set_podcasts (podcasts);
>
> itdb_playlist_add (db, mpl, -1);
> itdb_playlist_add (db, podcasts, -1);
>
> itdb_playlist_add_track (mpl, track, -1);
> itdb_playlist_add_track (podcasts, track, -1);
>
> GError *err;
>
> gboolean ret = itdb_cp_track_to_ipod (track,
> "/var/mobile/song.mp3", &err);
> if (!ret) {
> printf ("Error: %s\n", err->message);
> }
> itdb_write (db, NULL);
>
> return 0;
>
> }
>
> What have I done wrong?
>
> Thanks in advance,
>
> Árpád Goretity
>
>
|
|
From: Christophe F. <cfe...@gm...> - 2011-08-01 09:41:56
|
Hi, 2011/7/31 Árpád Goretity <arp...@gm...>: Which is > the essential part of libimobiledevice which causes the iPod.app to properly > read and reload the library? I'd like to implement this by hand in my iPhone > app. There are 2 things that are needed, first of all, libgpod uses some information it got from the iPod through libimobiledevice to automatically identify the ipod model that is connected. This is needed to know how the ipod database should be checksummed, and whether sqlite files should be written or not. I think this is the part that is missing in your case. Then, for iOS devices, a series of commands needs to be run on the sqlite databases as a postprocessing step (otherwise you get a long "updating database" screen on the device), and once again libgpod uses libimobiledevice to get these commands. I'm not sure either how to get them from the ipod directly. Last but not least, recent iOS devices are read-only as far as libgpod is concerned, that is everything that went out after the iPhone4/iTouch4/iPad Hope that helps, Christophe |
|
From: Árpád G. <arp...@gm...> - 2011-08-01 17:09:13
|
Hello, Thank you very much for pointing this out. As I've stated, my device is an iPhone 3G. I think I'll try the old DBVersion trick and let's see whether it works. AFAIK, the postprocess works fine, at least the logs show that a) the database is written to, and b) the checksum is correct, because iPod doesn't delete the entries from the database, just doesn't show them. When I tried to implement SQL insertions by hand (i. e., without the checksum), the app (or MusicLibrary.framework???) removed the tracks. Sent from my iPhone On 2011.08.01., at 11:41, Christophe Fergeau <cfe...@gm...> wrote: > Hi, > > 2011/7/31 Árpád Goretity <arp...@gm...>: > Which is >> the essential part of libimobiledevice which causes the iPod.app to properly >> read and reload the library? I'd like to implement this by hand in my iPhone >> app. > > There are 2 things that are needed, first of all, libgpod uses some > information it got from the iPod through libimobiledevice to > automatically identify the ipod model that is connected. This is > needed to know how the ipod database should be checksummed, and > whether sqlite files should be written or not. I think this is the > part that is missing in your case. > Then, for iOS devices, a series of commands needs to be run on the > sqlite databases as a postprocessing step (otherwise you get a long > "updating database" screen on the device), and once again libgpod uses > libimobiledevice to get these commands. I'm not sure either how to get > them from the ipod directly. > > Last but not least, recent iOS devices are read-only as far as libgpod > is concerned, that is everything that went out after the > iPhone4/iTouch4/iPad > > Hope that helps, > > Christophe |
|
From: Christophe F. <cfe...@gm...> - 2011-08-02 18:22:21
|
Le 1 août 2011 à 19:08, Árpád Goretity <arp...@gm...> a écrit : > Hello, > > Thank you very much for pointing this out. As I've stated, my device is an iPhone 3G. Ok the hashing should be fine then provided libgpod manages to detect the iPod model. > I think I'll try the old DBVersion trick and let's see whether it works. AFAIK, the postprocess works fine, at least the logs show that Writing the hash is one thing, the postprocessing commands are a bunch of SQL commands that are run at the end of the sync process. Libgpod gets these commands from the device through libimobiledevice. Christophe > a) the database is written to, and > b) the checksum is correct, because iPod doesn't delete the entries from the database, just doesn't show them. When I tried to implement SQL insertions by hand (i. e., without the checksum), the app (or MusicLibrary.framework???) removed the tracks. > > > Sent from my iPhone > > On 2011.08.01., at 11:41, Christophe Fergeau <cfe...@gm...> wrote: > >> Hi, >> >> 2011/7/31 Árpád Goretity <arp...@gm...>: >> Which is >>> the essential part of libimobiledevice which causes the iPod.app to properly >>> read and reload the library? I'd like to implement this by hand in my iPhone >>> app. >> >> There are 2 things that are needed, first of all, libgpod uses some >> information it got from the iPod through libimobiledevice to >> automatically identify the ipod model that is connected. This is >> needed to know how the ipod database should be checksummed, and >> whether sqlite files should be written or not. I think this is the >> part that is missing in your case. >> Then, for iOS devices, a series of commands needs to be run on the >> sqlite databases as a postprocessing step (otherwise you get a long >> "updating database" screen on the device), and once again libgpod uses >> libimobiledevice to get these commands. I'm not sure either how to get >> them from the ipod directly. >> >> Last but not least, recent iOS devices are read-only as far as libgpod >> is concerned, that is everything that went out after the >> iPhone4/iTouch4/iPad >> >> Hope that helps, >> >> Christophe |