-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathiphone.cpp
84 lines (76 loc) · 2.13 KB
/
iphone.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/* File: iphone.cpp
* Creation Date: 2/4/2010
* Last Modified Date: 2/21/2010
* Version: 0.0.1
* Contact: Adam Lamers <adam@millenniumsoftworks.com>
*/
#include "tungsten.h"
#include "itdb.h"
#include "glib.h"
#include <windows.h>
#include <commctrl.h>
#include "songlist.h"
#include "statusbar.h"
#ifdef __cplusplus
extern "C"
{
#endif
extern void __declspec(dllimport) ConvertiTunesCDB(char *filePath, char *newFilePath);
#ifdef __cplusplus
}
#endif
extern CSongList *SongList;
extern int DisplayType;
extern CStatusBar *StatusBar;
iPhone *phone;
Itdb_iTunesDB *itunesdb;
void FetchITunesDB()
{
std::list <Itdb_Track*> *tracksList = new std::list<Itdb_Track*>;
iPhone_CopyFileFromDevice(phone, "/private/var/mobile/Media/iTunes_Control/iTunes/iTunesCDB", "iTunesCDB");
ConvertiTunesCDB("iTunesCDB", "iTunesDB");
itunesdb = itdb_parse_file("iTunesDB", NULL);
GList *tracks = itunesdb->tracks;
Itdb_Track *track;
while(tracks != NULL)
{
track = (Itdb_Track*)tracks->data;
tracksList->push_back(track);
//if(track->mediatype & ITDB_MEDIATYPE_AUDIO)
SongList->AddRow(track->title, track->artist, track->album, track->genre);
tracks = tracks->next;
}
SongList->SetTrackList(tracksList);
}
DWORD WINAPI ThreadCallback(void *param)
{
FetchITunesDB();
return TRUE;
}
void NotifyCallback(AMDeviceNotificationCallbackInfo* callback)
{
switch(callback->msg)
{
case Connected:
phone->handle = callback->dev;
if(iPhone_Connect(phone) == TRUE)
{
CreateThread(NULL, 0, ThreadCallback, NULL, 0, NULL);
}
StatusBar->SetSegmentText(0, "Connected");
break;
case Disconnected:
phone->connected = FALSE;
StatusBar->SetSegmentText(0, "Disconnected");
break;
default:
break;
}
}
void InitiPhone(HWND hwndDlg)
{
phone = (iPhone*)malloc(sizeof(iPhone));
memset(phone, 0, sizeof(iPhone));
phone->dnc = NotifyCallback;
iPhone_init(phone);
}