Ejemplo n.º 1
0
//-----------------------------
void	APICALL MyPeercastApp::channelUpdate(ChanInfo *info)
{
	if (lastPlayID.isSet() && info && info->id.isSame(lastPlayID))
	{

		String tmp;
		tmp.append(info->track.artist);
		tmp.append(" ");
		tmp.append(info->track.title);


		if (!tmp.isSame(trackTitle))
		{
			if (ServMgr::NT_TRACKINFO & peercastInst->getNotifyMask())
			{
				trackTitle=tmp;
				clearChannelPopup();
				channelPopup(info->name.cstr(),trackTitle.cstr());
			}
		} else if (!info->comment.isSame(channelComment))
		{
			if (ServMgr::NT_BROADCASTERS & peercastInst->getNotifyMask())
			{
				channelComment = info->comment;
				clearChannelPopup();
				channelPopup(info->name.cstr(),channelComment.cstr());
			}
		}



	}
}
Ejemplo n.º 2
0
//-----------------------------
void	APICALL MyPeercastApp::channelStop(ChanInfo *info)
{
	if (info->id.isSame(lastPlayID))
	{
		lastPlayID.clear();
		clearChannelPopup();
	}
}
Ejemplo n.º 3
0
// ------------------------------------------
void PCPStream::readPushAtoms(AtomStream &atom, int numc, BroadcastState &bcs) {
    Host host;
    GnuID chanID;

    chanID.clear();

    for (int i = 0; i < numc; i++) {
        int c, d;
        ID4 id = atom.read(c, d);

        if (id == PCP_PUSH_IP)
            host.ip = atom.readInt();
        else if (id == PCP_PUSH_PORT)
            host.port = atom.readShort();
        else if (id == PCP_PUSH_CHANID)
            atom.readBytes(chanID.id, 16);
        else {
            LOG_DEBUG("PCP skip: %s,%d,%d", id.getString().str(), c, d);
            atom.skip(c, d);
        }
    }


    if (bcs.forMe) {
        char ipstr[64];
        host.toStr(ipstr);

        Servent *s = NULL;

        if (chanID.isSet()) {
            Channel *ch = chanMgr->findChannelByID(chanID);
            if (ch) if (ch->isBroadcasting() || !ch->isFull() && !servMgr->relaysFull() && ch->info.id.isSame(chanID))
                s = servMgr->allocServent();
        } else {
            s = servMgr->allocServent();
        }

        if (s) {
            LOG_DEBUG("GIVing to %s", ipstr);
            s->initGIV(host, chanID);
        }
    }

}
Ejemplo n.º 4
0
// ------------------------------------------
bool PCPStream::sendPacket(ChanPacket & pack, GnuID & destID) {
    if (destID.isSet()) if (!destID.isSame(remoteID)) if (!routeList.contains(destID))
        return false;

    return outData.writePacket(pack);
}
Ejemplo n.º 5
0
void	CHtmlFile::_writeVariable(const std::string& varName)
{
#if 0
	bool r = false;
	if (varName == "servMgr.")
		r=servMgr->writeVariable(s,varName+8);
	else if (varName.startsWith("chanMgr."))
		r=chanMgr->writeVariable(s,varName+8,loop);
	else if (varName.startsWith("stats."))
		r=stats.writeVariable(s,varName+6);
	else if (varName.startsWith("sys."))
	{
		if (varName == "sys.log.dumpHTML")
		{
			sys->logBuf->dumpHTML(s);
			r=true;
		}
	}
	else if (varName.startsWith("loop."))
	{
		if (varName.startsWith("loop.channel."))
		{
			Channel *ch = chanMgr->findChannelByIndex(loop);
			if (ch)
				r = ch->writeVariable(s,varName+13,loop);
		}else if (varName.startsWith("loop.servent."))
		{
			Servent *sv = servMgr->findServentByIndex(loop);
			if (sv)
				r = sv->writeVariable(s,varName+13);
		}else if (varName.startsWith("loop.filter."))
		{
			ServFilter *sf = &servMgr->filters[loop];
			r = sf->writeVariable(s,varName+12);

		}else if (varName.startsWith("loop.bcid."))
		{
			BCID *bcid = servMgr->findValidBCID(loop);
			if (bcid)
				r = bcid->writeVariable(s,varName+10);
		
		}else if (varName == "loop.indexEven")
		{
			s.writeStringF("%d",(loop&1)==0);
			r = true;
		}else if (varName == "loop.index")
		{
			s.writeStringF("%d",loop);
			r = true;
		}else if (varName.startsWith("loop.hit."))
		{
			char *idstr = getCGIarg(tmplArgs,"id=");
			if (idstr)
			{
				GnuID id;
				id.fromStr(idstr);
				ChanHitList *chl = chanMgr->findHitListByID(id);
				if (chl)
				{
					int cnt=0;
					ChanHit *ch = chl->hit;
					while (ch)
					{
						if (ch->host.ip && !ch->dead)
						{
							if (cnt == loop)
							{
								r = ch->writeVariable(s,varName+9);
								break;
							}
							cnt++;
						}
						ch=ch->next;
					}

				}
			}
		}

	}
	else if (varName.startsWith("page."))
	{
		if (varName.startsWith("page.channel."))
		{
			char *idstr = getCGIarg(tmplArgs,"id=");
			if (idstr)
			{
				GnuID id;
				id.fromStr(idstr);
				Channel *ch = chanMgr->findChannelByID(id);
				if (ch)
					r = ch->writeVariable(s,varName+13,loop);
			}
		}else
		{

			String v = varName+5;
			v.append('=');
			char *a = getCGIarg(tmplArgs,v);
			if (a)
			{
				s.writeString(a);		
				r=true;
			}
		}
	}


	if (!r)
		s.writeString(varName);
#endif
}