⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 trayctl.cpp

📁 P2P应用 : Peercast的源代码
💻 CPP
📖 第 1 页 / 共 2 页
字号:
// Winamp general purpose plug-in mini-SDK// Copyright (C) 1997, Justin Frankel/Nullsoft#include <windows.h>#include <process.h>#include <TCHAR.H>#include "gen.h"#include "resource.h"#include "win32/wsys.h"#include "channel.h"#include "servent.h"#include "servmgr.h"#include "peercast.h"BOOL WINAPI _DllMainCRTStartup(HANDLE hInst, ULONG ul_reason_for_call, LPVOID lpReserved){	return TRUE;}const char *ODDCAST_DLL = "dsp_oddcast.dll";#define ENABLE_PREV 1#define ENABLE_PLAY 2#define ENABLE_STOP 4#define ENABLE_NEXT 8#define ENABLE_EJECT 16int config_enabled=0;bool autoPlaylistUpdate=true;HICON Icon;// from systray.cextern "C"{BOOL systray_add(HWND hwnd, UINT uID, HICON hIcon, LPSTR lpszTip);BOOL systray_del(HWND hwnd, UINT uID);BOOL CALLBACK ConfigProc(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPARAM lParam);LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);__declspec( dllexport ) winampGeneralPurposePlugin * winampGetGeneralPurposePlugin();__declspec( dllexport ) playChannel(HWND hwnd, HINSTANCE hinst, LPSTR lpszCmdLine, int nCmdShow);__declspec( dllexport ) callURL(HWND hwnd, HINSTANCE hinst, LPSTR lpszCmdLine, int nCmdShow);};int numRuns=0;bool showChans=true;char broadcastName[128];char broadcastGenre[128];char broadcastURL[128];int broadcastQuality=0;bool broadcastManual=false;bool onAir=false;char pluginFilename[256];char iniFilename[256];char peercastPath[256];
HWND configWin;void config();void quit();int init();void config_write();void config_read();const char *szAppName = "PeerCast";winampGeneralPurposePlugin plugin ={	GPPHDR_VER,	"",	init,	config,	quit,};void main() {}int logID = 0;// ---------------------------------class MyPeercastInst : public PeercastInstance{public:	virtual Sys * APICALL createSys()	{		return new WSys(plugin.hwndParent);	}};// ---------------------------------class MyPeercastApp : public PeercastApplication{public:	virtual const char * APICALL getIniFilename()	{		return iniFilename;	}

	virtual const char * APICALL getPath() 
	{
		return peercastPath;
	}
	virtual const char *APICALL getClientTypeOS() 	{		return PCX_OS_WINAMP2;	}	virtual void APICALL addChannel(ChanInfo *);};#if 0// --------------------------------------------------void setSettingsUI(){}// --------------------------------------------------void setTrayIcon(int type, const char *title,const char *msg){#if 0	if ((type & Sys::NT_TRACKINFO) && (isPlaying))	{		titleStr.clear();		if (strlen(msg) || strlen(title))		{			if (title)				titleStr.append(title);			titleStr.append(" ");			if (msg)				titleStr.append(msg);		}else			titleStr.append("Untitled");	}#endif}#endif// --------------------------------------------------bool getButtonState(int id){	return SendDlgItemMessage(configWin, id,BM_GETCHECK, 0, 0) == BST_CHECKED;}// --------------------------------------------------void setButtonState(int id, bool on){	SendDlgItemMessage(configWin, id,BM_SETCHECK, on, 0);	SendMessage(configWin,WM_COMMAND,id,0);}// --------------------------------------------------void enableControl(int id, bool on){	EnableWindow(GetDlgItem(configWin,id),on);}// --------------------------------------------------void enableEdit(int id, bool on){	SendDlgItemMessage(configWin, id,WM_ENABLE, on, 0);	SendDlgItemMessage(configWin, id,EM_SETREADONLY, !on, 0);}// --------------------------------------------------int getEditInt(int id){	char str[128];	SendDlgItemMessage(configWin, id,WM_GETTEXT, 128, (LONG)str);	return atoi(str);}// --------------------------------------------------char * getEditStr(int id){	static char str[128];	SendDlgItemMessage(configWin, id,WM_GETTEXT, 128, (LONG)str);	return str;}// --------------------------------------------------void setEditStr(int id, char *str){	SendDlgItemMessage(configWin, id,WM_SETTEXT, 0, (LONG)str);}// --------------------------------------------------void setEditInt(int id, int v){	char str[128];	sprintf(str,"%d",v);	SendDlgItemMessage(configWin, id,WM_SETTEXT, 0, (LONG)str);}void addPlaylist(const char *url, const char *id){	int num = SendMessage(plugin.hwndParent,WM_USER, 0, 124); 	// num tracks	for(int i=0; i<num; i++)	{		char *name = (char *)SendMessage(plugin.hwndParent,WM_USER, i, 211); 	// filename		if (name) // if already in list, dont add		{			if (id)				if (strstr(name,id))					return;			if (strcmp(url,name)==0)				return;				}	}		COPYDATASTRUCT cds;	cds.dwData = 100;		// IPC_PLAYFILE	cds.cbData = lstrlen(url) + 1;	cds.lpData = (void *) url;	SendMessage(plugin.hwndParent, WM_COPYDATA, (WPARAM)NULL, (LPARAM)&cds);}void delPlaylist(const char *url){	int num = SendMessage(plugin.hwndParent,WM_USER, 0, 124); 	// num tracks	for(int i=0; i<num; i++)	{		char *name = (char *)SendMessage(plugin.hwndParent,WM_USER, i, 211); 	// num tracks		if (name)			if (strcmp(url,name)==0)			{			// cant do it aparently.			}	}	}// -----------------------------------void APICALL MyPeercastApp::addChannel(ChanInfo *info){#if 0	if ((autoPlaylistUpdate) && (info))	{		FileStream file;		try		{			file.openWriteReplace("c:\\add.pls");			char url[256];			sprintf(url,"http://localhost:%d",peercastInst->getServerPort());			PlayList *pls = new PlayList(PlayList::T_SCPLS,1);			pls->addChannel(url,*info);			pls->write(file);			file.close();			addPlaylist("c:\\add.pls",NULL);			delete pls;			SendMessage(plugin.hwndParent,WM_USER, (long)"", 245); 	// set pls#if 0			char str[256];			char idStr[64];			info->id.toStr(idStr);			sprintf(str,"http://localhost:%d/scpls/%s.pls",peercastInst->getServerPort(),idStr);			addPlaylist(str,idStr);#endif		}catch(StreamException &e)		{			LOG_ERROR("Unable to add Winamp pls: %s",e.msg);		}	}#endif}// -----------------------------------void updatePlaylist(){}#if 0int playlistThread(ThreadInfo *t){	while (t->active)	{		if (autoPlaylistUpdate)		{			for(int i=0; i<ChanMgr::MAX_HITLISTS; i++)			{				ChanHitList *chl = &chanMgr->hitlists[i];				if (chl->isUsed())				{					char str[256];					char idStr[64];					chl->info.id.toStr(idStr);					sprintf(str,"http://localhost:%d/scpls/%s.pls",peercastInst->getServerPort(),idStr);					addPlaylist(str,idStr);				}			}		}		sys->sleep(10000);	}	return 0;}#endifvoid showMiniBrowser(){	if (showChans)	{		if (!numRuns)			SendMessage(plugin.hwndParent,WM_USER, NULL, 249); 			char url[256];		sprintf(url,"http://localhost:%d/admin?page=winamp-chans",peercastInst->getServerPort());		SendMessage(plugin.hwndParent,WM_USER, (long)url, 249); // = 241 		SendMessage(plugin.hwndParent,WM_USER, 1, 248); 	// block updates		SetForegroundWindow(plugin.hwndParent);    	}}void config(){	//sys->callLocalURL("admin?page=settings",servMgr->serverHost.port);	DialogBox(plugin.hDllInstance,MAKEINTRESOURCE(IDD_DIALOG1),plugin.hwndParent,ConfigProc);//	showMiniBrowser();#if 0	SendMessage(plugin.hwndParent,WM_USER, NULL, 249); 		char url[256];	sprintf(url,"http://localhost:%d/admin?page=winamp-settings",servMgr->serverHost.port);	SendMessage(plugin.hwndParent,WM_USER, (long)url, 249); // = 241 	SendMessage(plugin.hwndParent,WM_USER, 1, 248); 	// block updates	SetForegroundWindow(plugin.hwndParent);    #endif}void quit(){	numRuns++;	peercastInst->saveSettings();	config_write();	config_enabled=0;	//systray_del(plugin.hwndParent,0);}
void *lpWndProcOld;LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam){		switch(message)	{
		case WM_COPYDATA:
			{
				COPYDATASTRUCT *pc = (COPYDATASTRUCT *)lParam;
				if (pc->dwData == WM_USER+1001)
				{
					try
					{
						LOG_DEBUG("Play request: %s",pc->lpData);
						ChanInfo info;
						servMgr->procConnectArgs((char *)pc->lpData,info);
						chanMgr->findAndPlayChannel(info,false);
					}catch(StreamException &e)
					{
						LOG_ERROR("Playing channel: %s",e.msg);
					}
					return 0;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -