aboutsummaryrefslogtreecommitdiff
path: root/Src/Plugins/Library/ml_plg/AlbumID.cpp
blob: 2fd6d14b012c9267d3a87972565f90833516bacb (plain) (blame)
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
#include "playlist.h"
#include "main.h"
#include "api__ml_plg.h"
#include "../../General/gen_ml/ml.h"
#include <atlbase.h>
#include "IDScanner.h"

IConnectionPoint *GetConnectionPoint(IUnknown *punk, REFIID riid)
{
	if (!punk)
		return 0;

	IConnectionPointContainer *pcpc;
	IConnectionPoint *pcp = 0;

	HRESULT hr = punk->QueryInterface(IID_IConnectionPointContainer, (void **) & pcpc);
	if (SUCCEEDED(hr))
	{
		pcpc->FindConnectionPoint(riid, &pcp);
		pcpc->Release();
	}
	return pcp;
}

bool IDScanner::SetupMusicID()
{
	if (!SetupPlaylistSDK())
		return false;

	if (musicID)
		return true;

	musicID = AGAVE_API_GRACENOTE->GetMusicID();
	if (musicID)
	{
		IConnectionPoint *icp = GetConnectionPoint(musicID, DIID__ICDDBMusicIDManagerEvents);
		if (icp)
		{
			icp->Advise(static_cast<IDispatch *>(this), &m_dwCookie);
			icp->Release();
		}
		return true;
	}
	return false;
}