aboutsummaryrefslogtreecommitdiff
path: root/Src/nu/SendTo.h
blob: 597b1b6c94a9ab955c2bbc8a91baf275bb614739 (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
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#ifndef NULLSOFT_SEND_TO_HELPER_CLASS_H
#define NULLSOFT_SEND_TO_HELPER_CLASS_H

#include "../gen_ml/ml_ipc.h"
#include "../gen_ml/ml.h"
#include "../winamp/wa_ipc.h"

class SendToMenu
{
public:
	SendToMenu(winampMediaLibraryPlugin &_plugin) : IPC_LIBRARY_SENDTOMENU(0), plugin(&_plugin)
	{
		memset(&sendTo, 0, sizeof(sendTo));
	}
	void AddHere(HWND hwnd, HMENU hMenu, int type)
	{
		sendTo.mode = 0;
		sendTo.hwnd = 0;
		sendTo.build_hMenu = 0;

		IPC_LIBRARY_SENDTOMENU = SendMessage(plugin->hwndWinampParent, WM_WA_IPC, (WPARAM)&"LibrarySendToMenu", IPC_REGISTER_WINAMP_IPCMESSAGE);
		if (IPC_LIBRARY_SENDTOMENU > 65536 && SendMessage(plugin->hwndWinampParent, WM_WA_IPC, (WPARAM)0, IPC_LIBRARY_SENDTOMENU) == (LRESULT)-1)
		{
			sendTo.mode = 1;
			sendTo.hwnd = hwnd;
			sendTo.data_type = type; //ML_TYPE_ITEMRECORDLIST;
			sendTo.build_hMenu = hMenu;
		}
	}
	bool WasClicked(int popUpReturnVal)
	{
		if (sendTo.mode == 2)
		{
			sendTo.menu_id = popUpReturnVal;
			if (SendMessage(plugin->hwndWinampParent, WM_WA_IPC, (WPARAM)&sendTo, IPC_LIBRARY_SENDTOMENU) == (LRESULT)-1)
				return true;
		}
		return false;
	}
	void Cleanup()
	{
		if (sendTo.mode)
		{
			sendTo.mode = 4;
			SendMessage(plugin->hwndWinampParent, WM_WA_IPC, (WPARAM)&sendTo, IPC_LIBRARY_SENDTOMENU); // cleanup
		}
		sendTo.build_hMenu = 0;
	}

	bool InitPopupMenu(WPARAM wParam)
	{
		if (wParam && (HMENU)wParam == sendTo.build_hMenu && sendTo.mode == 1)
		{
			if (SendMessage(plugin->hwndWinampParent, WM_WA_IPC, (WPARAM)&sendTo, IPC_LIBRARY_SENDTOMENU) == (LRESULT)-1)
				sendTo.mode = 2;

			return true;
		}
		return false;
	}

	// still need to free it on your own
	void SendItemRecordList(itemRecordList *obj)
	{
		sendTo.data_type = ML_TYPE_ITEMRECORDLIST;
		sendTo.mode = 3;
		sendTo.data = (void*) & obj;

		SendMessage(plugin->hwndWinampParent, WM_WA_IPC, (WPARAM)&sendTo, IPC_LIBRARY_SENDTOMENU);
	}

	void SendFilenames(const char *filenames)
	{
		sendTo.data_type = ML_TYPE_FILENAMES;
		sendTo.mode = 3;
		sendTo.data = (void*)filenames;

		SendMessage(plugin->hwndWinampParent, WM_WA_IPC, (WPARAM)&sendTo, IPC_LIBRARY_SENDTOMENU);
	}

		void SendFilenames(const wchar_t *filenames)
	{
		sendTo.data_type = ML_TYPE_FILENAMESW;
		sendTo.mode = 3;
		sendTo.data = (void*)filenames;

		SendMessage(plugin->hwndWinampParent, WM_WA_IPC, (WPARAM)&sendTo, IPC_LIBRARY_SENDTOMENU);
	}


	LRESULT SendPlaylist(mlPlaylist *playlist)
	{
		sendTo.data_type = ML_TYPE_PLAYLIST;
		sendTo.mode = 3;
		sendTo.data = (void*)playlist;

		return SendMessage(plugin->hwndWinampParent, WM_WA_IPC, (WPARAM)&sendTo, IPC_LIBRARY_SENDTOMENU);
	}

private:
	LRESULT IPC_LIBRARY_SENDTOMENU;
	librarySendToMenuStruct sendTo;
	winampMediaLibraryPlugin *plugin;
};

#endif